@upyo/smtp 0.2.0 → 0.2.1-dev.29
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/index.cjs +12 -7
- package/dist/index.js +12 -7
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
//#endregion
|
|
24
24
|
const node_net = __toESM(require("node:net"));
|
|
25
25
|
const node_tls = __toESM(require("node:tls"));
|
|
26
|
-
const
|
|
26
|
+
const node_buffer = __toESM(require("node:buffer"));
|
|
27
27
|
|
|
28
28
|
//#region src/config.ts
|
|
29
29
|
/**
|
|
@@ -278,10 +278,10 @@ async function buildRawMessage(message) {
|
|
|
278
278
|
const hasHtml = "html" in message.content;
|
|
279
279
|
const hasText = "text" in message.content;
|
|
280
280
|
const isMultipart = hasAttachments || hasHtml && hasText;
|
|
281
|
-
lines.push(`From: ${
|
|
282
|
-
lines.push(`To: ${
|
|
283
|
-
if (message.ccRecipients.length > 0) lines.push(`Cc: ${
|
|
284
|
-
if (message.replyRecipients.length > 0) lines.push(`Reply-To: ${
|
|
281
|
+
lines.push(`From: ${encodeAddress(message.sender)}`);
|
|
282
|
+
lines.push(`To: ${message.recipients.map(encodeAddress).join(", ")}`);
|
|
283
|
+
if (message.ccRecipients.length > 0) lines.push(`Cc: ${message.ccRecipients.map(encodeAddress).join(", ")}`);
|
|
284
|
+
if (message.replyRecipients.length > 0) lines.push(`Reply-To: ${message.replyRecipients.map(encodeAddress).join(", ")}`);
|
|
285
285
|
lines.push(`Subject: ${encodeHeaderValue(message.subject)}`);
|
|
286
286
|
lines.push(`Date: ${(/* @__PURE__ */ new Date()).toUTCString()}`);
|
|
287
287
|
lines.push(`Message-ID: <${generateMessageId()}>`);
|
|
@@ -361,10 +361,15 @@ function generateMessageId() {
|
|
|
361
361
|
const random = Math.random().toString(36).substr(2, 9);
|
|
362
362
|
return `${timestamp}.${random}@upyo.local`;
|
|
363
363
|
}
|
|
364
|
+
function encodeAddress(address) {
|
|
365
|
+
if (address.name == null) return address.address;
|
|
366
|
+
const encodedDisplayName = encodeHeaderValue(address.name);
|
|
367
|
+
return `${encodedDisplayName} <${address.address}>`;
|
|
368
|
+
}
|
|
364
369
|
function encodeHeaderValue(value) {
|
|
365
370
|
if (!/^[\x20-\x7E]*$/.test(value)) {
|
|
366
371
|
const utf8Bytes = new TextEncoder().encode(value);
|
|
367
|
-
const base64 =
|
|
372
|
+
const base64 = node_buffer.Buffer.from(utf8Bytes).toString("base64");
|
|
368
373
|
const maxEncodedLength = 75;
|
|
369
374
|
const encodedWord = `=?UTF-8?B?${base64}?=`;
|
|
370
375
|
if (encodedWord.length <= maxEncodedLength) return encodedWord;
|
|
@@ -409,7 +414,7 @@ function encodeQuotedPrintable(text) {
|
|
|
409
414
|
return result;
|
|
410
415
|
}
|
|
411
416
|
function encodeBase64(data) {
|
|
412
|
-
const base64 =
|
|
417
|
+
const base64 = node_buffer.Buffer.from(data).toString("base64");
|
|
413
418
|
return base64.replace(/(.{76})/g, "$1\r\n").trim();
|
|
414
419
|
}
|
|
415
420
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Socket } from "node:net";
|
|
2
2
|
import { connect } from "node:tls";
|
|
3
|
-
import {
|
|
3
|
+
import { Buffer } from "node:buffer";
|
|
4
4
|
|
|
5
5
|
//#region src/config.ts
|
|
6
6
|
/**
|
|
@@ -255,10 +255,10 @@ async function buildRawMessage(message) {
|
|
|
255
255
|
const hasHtml = "html" in message.content;
|
|
256
256
|
const hasText = "text" in message.content;
|
|
257
257
|
const isMultipart = hasAttachments || hasHtml && hasText;
|
|
258
|
-
lines.push(`From: ${
|
|
259
|
-
lines.push(`To: ${
|
|
260
|
-
if (message.ccRecipients.length > 0) lines.push(`Cc: ${
|
|
261
|
-
if (message.replyRecipients.length > 0) lines.push(`Reply-To: ${
|
|
258
|
+
lines.push(`From: ${encodeAddress(message.sender)}`);
|
|
259
|
+
lines.push(`To: ${message.recipients.map(encodeAddress).join(", ")}`);
|
|
260
|
+
if (message.ccRecipients.length > 0) lines.push(`Cc: ${message.ccRecipients.map(encodeAddress).join(", ")}`);
|
|
261
|
+
if (message.replyRecipients.length > 0) lines.push(`Reply-To: ${message.replyRecipients.map(encodeAddress).join(", ")}`);
|
|
262
262
|
lines.push(`Subject: ${encodeHeaderValue(message.subject)}`);
|
|
263
263
|
lines.push(`Date: ${(/* @__PURE__ */ new Date()).toUTCString()}`);
|
|
264
264
|
lines.push(`Message-ID: <${generateMessageId()}>`);
|
|
@@ -338,10 +338,15 @@ function generateMessageId() {
|
|
|
338
338
|
const random = Math.random().toString(36).substr(2, 9);
|
|
339
339
|
return `${timestamp}.${random}@upyo.local`;
|
|
340
340
|
}
|
|
341
|
+
function encodeAddress(address) {
|
|
342
|
+
if (address.name == null) return address.address;
|
|
343
|
+
const encodedDisplayName = encodeHeaderValue(address.name);
|
|
344
|
+
return `${encodedDisplayName} <${address.address}>`;
|
|
345
|
+
}
|
|
341
346
|
function encodeHeaderValue(value) {
|
|
342
347
|
if (!/^[\x20-\x7E]*$/.test(value)) {
|
|
343
348
|
const utf8Bytes = new TextEncoder().encode(value);
|
|
344
|
-
const base64 =
|
|
349
|
+
const base64 = Buffer.from(utf8Bytes).toString("base64");
|
|
345
350
|
const maxEncodedLength = 75;
|
|
346
351
|
const encodedWord = `=?UTF-8?B?${base64}?=`;
|
|
347
352
|
if (encodedWord.length <= maxEncodedLength) return encodedWord;
|
|
@@ -386,7 +391,7 @@ function encodeQuotedPrintable(text) {
|
|
|
386
391
|
return result;
|
|
387
392
|
}
|
|
388
393
|
function encodeBase64(data) {
|
|
389
|
-
const base64 =
|
|
394
|
+
const base64 = Buffer.from(data).toString("base64");
|
|
390
395
|
return base64.replace(/(.{76})/g, "$1\r\n").trim();
|
|
391
396
|
}
|
|
392
397
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upyo/smtp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-dev.29+e2006b62",
|
|
4
4
|
"description": "SMTP transport for Upyo email library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"sideEffects": false,
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@upyo/core": "0.2.
|
|
56
|
+
"@upyo/core": "0.2.1-dev.29+e2006b62"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@dotenvx/dotenvx": "^1.47.3",
|