@upyo/smtp 0.5.0-dev.136 → 0.5.0-dev.156
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 +24 -27
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +24 -27
- package/package.json +3 -12
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
+
const __upyo_core = __toESM(require("@upyo/core"));
|
|
24
25
|
const node_net = __toESM(require("node:net"));
|
|
25
26
|
const node_tls = __toESM(require("node:tls"));
|
|
26
27
|
const node_buffer = __toESM(require("node:buffer"));
|
|
@@ -1224,6 +1225,7 @@ function encodeBase64(data) {
|
|
|
1224
1225
|
* ```
|
|
1225
1226
|
*/
|
|
1226
1227
|
var SmtpTransport = class {
|
|
1228
|
+
id = "smtp";
|
|
1227
1229
|
/**
|
|
1228
1230
|
* The SMTP configuration used by this transport.
|
|
1229
1231
|
*/
|
|
@@ -1277,6 +1279,8 @@ var SmtpTransport = class {
|
|
|
1277
1279
|
* cancellation.
|
|
1278
1280
|
* @returns A promise that resolves to a receipt indicating success or
|
|
1279
1281
|
* failure.
|
|
1282
|
+
* @throws {DOMException} If the operation is aborted through
|
|
1283
|
+
* `options.signal`.
|
|
1280
1284
|
*/
|
|
1281
1285
|
async send(message, options) {
|
|
1282
1286
|
options?.signal?.throwIfAborted();
|
|
@@ -1290,15 +1294,13 @@ var SmtpTransport = class {
|
|
|
1290
1294
|
await this.returnConnection(connection);
|
|
1291
1295
|
return {
|
|
1292
1296
|
successful: true,
|
|
1293
|
-
messageId
|
|
1297
|
+
messageId,
|
|
1298
|
+
provider: "smtp"
|
|
1294
1299
|
};
|
|
1295
1300
|
} catch (error) {
|
|
1296
1301
|
if (connection != null) await this.discardConnection(connection);
|
|
1297
1302
|
options?.signal?.throwIfAborted();
|
|
1298
|
-
return
|
|
1299
|
-
successful: false,
|
|
1300
|
-
errorMessages: [error instanceof Error ? error.message : String(error)]
|
|
1301
|
-
};
|
|
1303
|
+
return createSmtpFailure(error instanceof Error ? error.message : String(error));
|
|
1302
1304
|
}
|
|
1303
1305
|
}
|
|
1304
1306
|
/**
|
|
@@ -1328,6 +1330,8 @@ var SmtpTransport = class {
|
|
|
1328
1330
|
* @param options Optional transport options including `AbortSignal` for
|
|
1329
1331
|
* cancellation.
|
|
1330
1332
|
* @returns An async iterable of receipts, one for each message.
|
|
1333
|
+
* @throws {DOMException} If the operation is aborted through
|
|
1334
|
+
* `options.signal`.
|
|
1331
1335
|
*/
|
|
1332
1336
|
async *sendMany(messages, options) {
|
|
1333
1337
|
options?.signal?.throwIfAborted();
|
|
@@ -1339,10 +1343,7 @@ var SmtpTransport = class {
|
|
|
1339
1343
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1340
1344
|
for await (const _ of messages) {
|
|
1341
1345
|
options?.signal?.throwIfAborted();
|
|
1342
|
-
yield
|
|
1343
|
-
successful: false,
|
|
1344
|
-
errorMessages: [errorMessage]
|
|
1345
|
-
};
|
|
1346
|
+
yield createSmtpFailure(errorMessage);
|
|
1346
1347
|
}
|
|
1347
1348
|
return;
|
|
1348
1349
|
}
|
|
@@ -1352,10 +1353,7 @@ var SmtpTransport = class {
|
|
|
1352
1353
|
if (isAsyncIterable) for await (const message of messages) {
|
|
1353
1354
|
options?.signal?.throwIfAborted();
|
|
1354
1355
|
if (!connectionValid) {
|
|
1355
|
-
yield
|
|
1356
|
-
successful: false,
|
|
1357
|
-
errorMessages: ["Connection is no longer valid"]
|
|
1358
|
-
};
|
|
1356
|
+
yield createSmtpFailure("Connection is no longer valid");
|
|
1359
1357
|
continue;
|
|
1360
1358
|
}
|
|
1361
1359
|
try {
|
|
@@ -1364,24 +1362,19 @@ var SmtpTransport = class {
|
|
|
1364
1362
|
const messageId = await connection.sendMessage(smtpMessage, options?.signal);
|
|
1365
1363
|
yield {
|
|
1366
1364
|
successful: true,
|
|
1367
|
-
messageId
|
|
1365
|
+
messageId,
|
|
1366
|
+
provider: "smtp"
|
|
1368
1367
|
};
|
|
1369
1368
|
} catch (error) {
|
|
1370
1369
|
options?.signal?.throwIfAborted();
|
|
1371
1370
|
connectionValid = false;
|
|
1372
|
-
yield
|
|
1373
|
-
successful: false,
|
|
1374
|
-
errorMessages: [error instanceof Error ? error.message : String(error)]
|
|
1375
|
-
};
|
|
1371
|
+
yield createSmtpFailure(error instanceof Error ? error.message : String(error));
|
|
1376
1372
|
}
|
|
1377
1373
|
}
|
|
1378
1374
|
else for (const message of messages) {
|
|
1379
1375
|
options?.signal?.throwIfAborted();
|
|
1380
1376
|
if (!connectionValid) {
|
|
1381
|
-
yield
|
|
1382
|
-
successful: false,
|
|
1383
|
-
errorMessages: ["Connection is no longer valid"]
|
|
1384
|
-
};
|
|
1377
|
+
yield createSmtpFailure("Connection is no longer valid");
|
|
1385
1378
|
continue;
|
|
1386
1379
|
}
|
|
1387
1380
|
try {
|
|
@@ -1390,15 +1383,13 @@ var SmtpTransport = class {
|
|
|
1390
1383
|
const messageId = await connection.sendMessage(smtpMessage, options?.signal);
|
|
1391
1384
|
yield {
|
|
1392
1385
|
successful: true,
|
|
1393
|
-
messageId
|
|
1386
|
+
messageId,
|
|
1387
|
+
provider: "smtp"
|
|
1394
1388
|
};
|
|
1395
1389
|
} catch (error) {
|
|
1396
1390
|
options?.signal?.throwIfAborted();
|
|
1397
1391
|
connectionValid = false;
|
|
1398
|
-
yield
|
|
1399
|
-
successful: false,
|
|
1400
|
-
errorMessages: [error instanceof Error ? error.message : String(error)]
|
|
1401
|
-
};
|
|
1392
|
+
yield createSmtpFailure(error instanceof Error ? error.message : String(error));
|
|
1402
1393
|
}
|
|
1403
1394
|
}
|
|
1404
1395
|
if (connectionValid) await this.returnConnection(connection);
|
|
@@ -1491,6 +1482,12 @@ var SmtpTransport = class {
|
|
|
1491
1482
|
await this.closeAllConnections();
|
|
1492
1483
|
}
|
|
1493
1484
|
};
|
|
1485
|
+
function createSmtpFailure(message) {
|
|
1486
|
+
return (0, __upyo_core.createFailedReceipt)(message, {
|
|
1487
|
+
provider: "smtp",
|
|
1488
|
+
attempts: 1
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1494
1491
|
|
|
1495
1492
|
//#endregion
|
|
1496
1493
|
exports.SmtpAuthError = SmtpAuthError;
|
package/dist/index.d.cts
CHANGED
|
@@ -442,7 +442,8 @@ interface SmtpTlsOptions {
|
|
|
442
442
|
* }
|
|
443
443
|
* ```
|
|
444
444
|
*/
|
|
445
|
-
declare class SmtpTransport implements Transport
|
|
445
|
+
declare class SmtpTransport implements Transport<"smtp">, AsyncDisposable {
|
|
446
|
+
readonly id = "smtp";
|
|
446
447
|
/**
|
|
447
448
|
* The SMTP configuration used by this transport.
|
|
448
449
|
*/
|
|
@@ -491,8 +492,10 @@ declare class SmtpTransport implements Transport, AsyncDisposable {
|
|
|
491
492
|
* cancellation.
|
|
492
493
|
* @returns A promise that resolves to a receipt indicating success or
|
|
493
494
|
* failure.
|
|
495
|
+
* @throws {DOMException} If the operation is aborted through
|
|
496
|
+
* `options.signal`.
|
|
494
497
|
*/
|
|
495
|
-
send(message: Message, options?: TransportOptions): Promise<Receipt
|
|
498
|
+
send(message: Message, options?: TransportOptions): Promise<Receipt<"smtp">>;
|
|
496
499
|
/**
|
|
497
500
|
* Sends multiple email messages efficiently using a single SMTP connection.
|
|
498
501
|
*
|
|
@@ -520,8 +523,10 @@ declare class SmtpTransport implements Transport, AsyncDisposable {
|
|
|
520
523
|
* @param options Optional transport options including `AbortSignal` for
|
|
521
524
|
* cancellation.
|
|
522
525
|
* @returns An async iterable of receipts, one for each message.
|
|
526
|
+
* @throws {DOMException} If the operation is aborted through
|
|
527
|
+
* `options.signal`.
|
|
523
528
|
*/
|
|
524
|
-
sendMany(messages: Iterable<Message> | AsyncIterable<Message>, options?: TransportOptions): AsyncIterable<Receipt
|
|
529
|
+
sendMany(messages: Iterable<Message> | AsyncIterable<Message>, options?: TransportOptions): AsyncIterable<Receipt<"smtp">>;
|
|
525
530
|
private getConnection;
|
|
526
531
|
private connectAndSetup;
|
|
527
532
|
private returnConnection;
|
package/dist/index.d.ts
CHANGED
|
@@ -442,7 +442,8 @@ interface SmtpTlsOptions {
|
|
|
442
442
|
* }
|
|
443
443
|
* ```
|
|
444
444
|
*/
|
|
445
|
-
declare class SmtpTransport implements Transport
|
|
445
|
+
declare class SmtpTransport implements Transport<"smtp">, AsyncDisposable {
|
|
446
|
+
readonly id = "smtp";
|
|
446
447
|
/**
|
|
447
448
|
* The SMTP configuration used by this transport.
|
|
448
449
|
*/
|
|
@@ -491,8 +492,10 @@ declare class SmtpTransport implements Transport, AsyncDisposable {
|
|
|
491
492
|
* cancellation.
|
|
492
493
|
* @returns A promise that resolves to a receipt indicating success or
|
|
493
494
|
* failure.
|
|
495
|
+
* @throws {DOMException} If the operation is aborted through
|
|
496
|
+
* `options.signal`.
|
|
494
497
|
*/
|
|
495
|
-
send(message: Message, options?: TransportOptions): Promise<Receipt
|
|
498
|
+
send(message: Message, options?: TransportOptions): Promise<Receipt<"smtp">>;
|
|
496
499
|
/**
|
|
497
500
|
* Sends multiple email messages efficiently using a single SMTP connection.
|
|
498
501
|
*
|
|
@@ -520,8 +523,10 @@ declare class SmtpTransport implements Transport, AsyncDisposable {
|
|
|
520
523
|
* @param options Optional transport options including `AbortSignal` for
|
|
521
524
|
* cancellation.
|
|
522
525
|
* @returns An async iterable of receipts, one for each message.
|
|
526
|
+
* @throws {DOMException} If the operation is aborted through
|
|
527
|
+
* `options.signal`.
|
|
523
528
|
*/
|
|
524
|
-
sendMany(messages: Iterable<Message> | AsyncIterable<Message>, options?: TransportOptions): AsyncIterable<Receipt
|
|
529
|
+
sendMany(messages: Iterable<Message> | AsyncIterable<Message>, options?: TransportOptions): AsyncIterable<Receipt<"smtp">>;
|
|
525
530
|
private getConnection;
|
|
526
531
|
private connectAndSetup;
|
|
527
532
|
private returnConnection;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createFailedReceipt } from "@upyo/core";
|
|
1
2
|
import { Socket } from "node:net";
|
|
2
3
|
import { TLSSocket, connect } from "node:tls";
|
|
3
4
|
import { Buffer } from "node:buffer";
|
|
@@ -1201,6 +1202,7 @@ function encodeBase64(data) {
|
|
|
1201
1202
|
* ```
|
|
1202
1203
|
*/
|
|
1203
1204
|
var SmtpTransport = class {
|
|
1205
|
+
id = "smtp";
|
|
1204
1206
|
/**
|
|
1205
1207
|
* The SMTP configuration used by this transport.
|
|
1206
1208
|
*/
|
|
@@ -1254,6 +1256,8 @@ var SmtpTransport = class {
|
|
|
1254
1256
|
* cancellation.
|
|
1255
1257
|
* @returns A promise that resolves to a receipt indicating success or
|
|
1256
1258
|
* failure.
|
|
1259
|
+
* @throws {DOMException} If the operation is aborted through
|
|
1260
|
+
* `options.signal`.
|
|
1257
1261
|
*/
|
|
1258
1262
|
async send(message, options) {
|
|
1259
1263
|
options?.signal?.throwIfAborted();
|
|
@@ -1267,15 +1271,13 @@ var SmtpTransport = class {
|
|
|
1267
1271
|
await this.returnConnection(connection);
|
|
1268
1272
|
return {
|
|
1269
1273
|
successful: true,
|
|
1270
|
-
messageId
|
|
1274
|
+
messageId,
|
|
1275
|
+
provider: "smtp"
|
|
1271
1276
|
};
|
|
1272
1277
|
} catch (error) {
|
|
1273
1278
|
if (connection != null) await this.discardConnection(connection);
|
|
1274
1279
|
options?.signal?.throwIfAborted();
|
|
1275
|
-
return
|
|
1276
|
-
successful: false,
|
|
1277
|
-
errorMessages: [error instanceof Error ? error.message : String(error)]
|
|
1278
|
-
};
|
|
1280
|
+
return createSmtpFailure(error instanceof Error ? error.message : String(error));
|
|
1279
1281
|
}
|
|
1280
1282
|
}
|
|
1281
1283
|
/**
|
|
@@ -1305,6 +1307,8 @@ var SmtpTransport = class {
|
|
|
1305
1307
|
* @param options Optional transport options including `AbortSignal` for
|
|
1306
1308
|
* cancellation.
|
|
1307
1309
|
* @returns An async iterable of receipts, one for each message.
|
|
1310
|
+
* @throws {DOMException} If the operation is aborted through
|
|
1311
|
+
* `options.signal`.
|
|
1308
1312
|
*/
|
|
1309
1313
|
async *sendMany(messages, options) {
|
|
1310
1314
|
options?.signal?.throwIfAborted();
|
|
@@ -1316,10 +1320,7 @@ var SmtpTransport = class {
|
|
|
1316
1320
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1317
1321
|
for await (const _ of messages) {
|
|
1318
1322
|
options?.signal?.throwIfAborted();
|
|
1319
|
-
yield
|
|
1320
|
-
successful: false,
|
|
1321
|
-
errorMessages: [errorMessage]
|
|
1322
|
-
};
|
|
1323
|
+
yield createSmtpFailure(errorMessage);
|
|
1323
1324
|
}
|
|
1324
1325
|
return;
|
|
1325
1326
|
}
|
|
@@ -1329,10 +1330,7 @@ var SmtpTransport = class {
|
|
|
1329
1330
|
if (isAsyncIterable) for await (const message of messages) {
|
|
1330
1331
|
options?.signal?.throwIfAborted();
|
|
1331
1332
|
if (!connectionValid) {
|
|
1332
|
-
yield
|
|
1333
|
-
successful: false,
|
|
1334
|
-
errorMessages: ["Connection is no longer valid"]
|
|
1335
|
-
};
|
|
1333
|
+
yield createSmtpFailure("Connection is no longer valid");
|
|
1336
1334
|
continue;
|
|
1337
1335
|
}
|
|
1338
1336
|
try {
|
|
@@ -1341,24 +1339,19 @@ var SmtpTransport = class {
|
|
|
1341
1339
|
const messageId = await connection.sendMessage(smtpMessage, options?.signal);
|
|
1342
1340
|
yield {
|
|
1343
1341
|
successful: true,
|
|
1344
|
-
messageId
|
|
1342
|
+
messageId,
|
|
1343
|
+
provider: "smtp"
|
|
1345
1344
|
};
|
|
1346
1345
|
} catch (error) {
|
|
1347
1346
|
options?.signal?.throwIfAborted();
|
|
1348
1347
|
connectionValid = false;
|
|
1349
|
-
yield
|
|
1350
|
-
successful: false,
|
|
1351
|
-
errorMessages: [error instanceof Error ? error.message : String(error)]
|
|
1352
|
-
};
|
|
1348
|
+
yield createSmtpFailure(error instanceof Error ? error.message : String(error));
|
|
1353
1349
|
}
|
|
1354
1350
|
}
|
|
1355
1351
|
else for (const message of messages) {
|
|
1356
1352
|
options?.signal?.throwIfAborted();
|
|
1357
1353
|
if (!connectionValid) {
|
|
1358
|
-
yield
|
|
1359
|
-
successful: false,
|
|
1360
|
-
errorMessages: ["Connection is no longer valid"]
|
|
1361
|
-
};
|
|
1354
|
+
yield createSmtpFailure("Connection is no longer valid");
|
|
1362
1355
|
continue;
|
|
1363
1356
|
}
|
|
1364
1357
|
try {
|
|
@@ -1367,15 +1360,13 @@ var SmtpTransport = class {
|
|
|
1367
1360
|
const messageId = await connection.sendMessage(smtpMessage, options?.signal);
|
|
1368
1361
|
yield {
|
|
1369
1362
|
successful: true,
|
|
1370
|
-
messageId
|
|
1363
|
+
messageId,
|
|
1364
|
+
provider: "smtp"
|
|
1371
1365
|
};
|
|
1372
1366
|
} catch (error) {
|
|
1373
1367
|
options?.signal?.throwIfAborted();
|
|
1374
1368
|
connectionValid = false;
|
|
1375
|
-
yield
|
|
1376
|
-
successful: false,
|
|
1377
|
-
errorMessages: [error instanceof Error ? error.message : String(error)]
|
|
1378
|
-
};
|
|
1369
|
+
yield createSmtpFailure(error instanceof Error ? error.message : String(error));
|
|
1379
1370
|
}
|
|
1380
1371
|
}
|
|
1381
1372
|
if (connectionValid) await this.returnConnection(connection);
|
|
@@ -1468,6 +1459,12 @@ var SmtpTransport = class {
|
|
|
1468
1459
|
await this.closeAllConnections();
|
|
1469
1460
|
}
|
|
1470
1461
|
};
|
|
1462
|
+
function createSmtpFailure(message) {
|
|
1463
|
+
return createFailedReceipt(message, {
|
|
1464
|
+
provider: "smtp",
|
|
1465
|
+
attempts: 1
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1471
1468
|
|
|
1472
1469
|
//#endregion
|
|
1473
1470
|
export { SmtpAuthError, SmtpTransport };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upyo/smtp",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.156",
|
|
4
4
|
"description": "SMTP transport for Upyo email library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -53,22 +53,13 @@
|
|
|
53
53
|
},
|
|
54
54
|
"sideEffects": false,
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@upyo/core": "0.5.0-dev.
|
|
56
|
+
"@upyo/core": "0.5.0-dev.156+edad9790"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@dotenvx/dotenvx": "^1.47.3",
|
|
60
59
|
"tsdown": "^0.12.7",
|
|
61
60
|
"typescript": "5.8.3"
|
|
62
61
|
},
|
|
63
62
|
"scripts": {
|
|
64
|
-
"
|
|
65
|
-
"prepublish": "tsdown",
|
|
66
|
-
"test": "tsdown && dotenvx run --ignore=MISSING_ENV_FILE -- node --experimental-transform-types --test",
|
|
67
|
-
"test:bun": "tsdown && bun test --timeout=30000 --env-file=.env",
|
|
68
|
-
"test:deno": "deno test --allow-env --allow-net --env-file=.env",
|
|
69
|
-
"mailpit:start": "docker run -d --name upyo-mailpit -p 1025:1025 -p 8025:8025 axllent/mailpit:latest",
|
|
70
|
-
"mailpit:stop": "docker stop upyo-mailpit && docker rm upyo-mailpit",
|
|
71
|
-
"mailpit:logs": "docker logs upyo-mailpit",
|
|
72
|
-
"dev:mailpit": "docker run --rm -p 1025:1025 -p 8025:8025 axllent/mailpit:latest"
|
|
63
|
+
"prepublish": "mise run --no-deps :build"
|
|
73
64
|
}
|
|
74
65
|
}
|