@upyo/smtp 0.1.0-dev.14 → 0.1.0-dev.17
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 +10 -15
- package/dist/index.d.cts +12 -69
- package/dist/index.d.ts +12 -69
- package/dist/index.js +10 -14
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -31,21 +31,11 @@ const __upyo_core = __toESM(require("@upyo/core"));
|
|
|
31
31
|
*
|
|
32
32
|
* This function takes a partial SMTP configuration and returns a complete
|
|
33
33
|
* configuration with all optional fields filled with sensible defaults.
|
|
34
|
+
* It is used internally by the SMTP transport.
|
|
34
35
|
*
|
|
35
36
|
* @param config - The SMTP configuration with optional fields
|
|
36
37
|
* @returns A resolved configuration with all defaults applied
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const resolved = createSmtpConfig({
|
|
41
|
-
* host: 'smtp.example.com',
|
|
42
|
-
* auth: { user: 'user', pass: 'pass' }
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* // resolved.port will be 587 (default)
|
|
46
|
-
* // resolved.secure will be true (default)
|
|
47
|
-
* // resolved.poolSize will be 5 (default)
|
|
48
|
-
* ```
|
|
38
|
+
* @internal
|
|
49
39
|
*/
|
|
50
40
|
function createSmtpConfig(config) {
|
|
51
41
|
return {
|
|
@@ -428,9 +418,15 @@ function encodeBase64(data) {
|
|
|
428
418
|
* ```
|
|
429
419
|
*/
|
|
430
420
|
var SmtpTransport = class {
|
|
421
|
+
/**
|
|
422
|
+
* The SMTP configuration used by this transport.
|
|
423
|
+
*/
|
|
431
424
|
config;
|
|
432
|
-
|
|
425
|
+
/**
|
|
426
|
+
* The maximum number of connections in the pool.
|
|
427
|
+
*/
|
|
433
428
|
poolSize;
|
|
429
|
+
connectionPool = [];
|
|
434
430
|
/**
|
|
435
431
|
* Creates a new SMTP transport instance.
|
|
436
432
|
*
|
|
@@ -653,5 +649,4 @@ var SmtpTransport = class {
|
|
|
653
649
|
};
|
|
654
650
|
|
|
655
651
|
//#endregion
|
|
656
|
-
exports.SmtpTransport = SmtpTransport;
|
|
657
|
-
exports.createSmtpConfig = createSmtpConfig;
|
|
652
|
+
exports.SmtpTransport = SmtpTransport;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Message, Receipt, Transport, TransportOptions } from "@upyo/core";
|
|
2
|
-
import { Socket } from "node:net";
|
|
3
|
-
import { TLSSocket } from "node:tls";
|
|
4
2
|
|
|
5
3
|
//#region src/config.d.ts
|
|
6
4
|
|
|
@@ -154,67 +152,6 @@ interface SmtpTlsOptions {
|
|
|
154
152
|
* This type represents the final configuration after applying defaults,
|
|
155
153
|
* used internally by the SMTP transport implementation.
|
|
156
154
|
*/
|
|
157
|
-
type ResolvedSmtpConfig = Omit<Required<SmtpConfig>, "auth" | "tls"> & {
|
|
158
|
-
readonly auth?: SmtpAuth;
|
|
159
|
-
readonly tls?: SmtpTlsOptions;
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Creates a resolved SMTP configuration by applying default values to optional fields.
|
|
163
|
-
*
|
|
164
|
-
* This function takes a partial SMTP configuration and returns a complete
|
|
165
|
-
* configuration with all optional fields filled with sensible defaults.
|
|
166
|
-
*
|
|
167
|
-
* @param config - The SMTP configuration with optional fields
|
|
168
|
-
* @returns A resolved configuration with all defaults applied
|
|
169
|
-
*
|
|
170
|
-
* @example
|
|
171
|
-
* ```typescript
|
|
172
|
-
* const resolved = createSmtpConfig({
|
|
173
|
-
* host: 'smtp.example.com',
|
|
174
|
-
* auth: { user: 'user', pass: 'pass' }
|
|
175
|
-
* });
|
|
176
|
-
*
|
|
177
|
-
* // resolved.port will be 587 (default)
|
|
178
|
-
* // resolved.secure will be true (default)
|
|
179
|
-
* // resolved.poolSize will be 5 (default)
|
|
180
|
-
* ```
|
|
181
|
-
*/
|
|
182
|
-
declare function createSmtpConfig(config: SmtpConfig): ResolvedSmtpConfig;
|
|
183
|
-
//#endregion
|
|
184
|
-
//#region src/message-converter.d.ts
|
|
185
|
-
interface SmtpMessage {
|
|
186
|
-
readonly envelope: SmtpEnvelope;
|
|
187
|
-
readonly raw: string;
|
|
188
|
-
}
|
|
189
|
-
interface SmtpEnvelope {
|
|
190
|
-
readonly from: string;
|
|
191
|
-
readonly to: string[];
|
|
192
|
-
}
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/smtp-connection.d.ts
|
|
195
|
-
declare class SmtpConnection {
|
|
196
|
-
socket: Socket | TLSSocket | null;
|
|
197
|
-
config: ResolvedSmtpConfig;
|
|
198
|
-
authenticated: boolean;
|
|
199
|
-
capabilities: string[];
|
|
200
|
-
constructor(config: SmtpConfig);
|
|
201
|
-
connect(signal?: AbortSignal): Promise<void>;
|
|
202
|
-
sendCommand(command: string, signal?: AbortSignal): Promise<SmtpResponse>;
|
|
203
|
-
greeting(signal?: AbortSignal): Promise<SmtpResponse>;
|
|
204
|
-
ehlo(signal?: AbortSignal): Promise<void>;
|
|
205
|
-
authenticate(signal?: AbortSignal): Promise<void>;
|
|
206
|
-
private authPlain;
|
|
207
|
-
authLogin(signal?: AbortSignal): Promise<void>;
|
|
208
|
-
sendMessage(message: SmtpMessage, signal?: AbortSignal): Promise<string>;
|
|
209
|
-
extractMessageId(response: string): string;
|
|
210
|
-
quit(): Promise<void>;
|
|
211
|
-
reset(signal?: AbortSignal): Promise<void>;
|
|
212
|
-
}
|
|
213
|
-
interface SmtpResponse {
|
|
214
|
-
readonly code: number;
|
|
215
|
-
readonly message: string;
|
|
216
|
-
readonly raw: string;
|
|
217
|
-
}
|
|
218
155
|
//#endregion
|
|
219
156
|
//#region src/smtp-transport.d.ts
|
|
220
157
|
/**
|
|
@@ -251,9 +188,15 @@ interface SmtpResponse {
|
|
|
251
188
|
* ```
|
|
252
189
|
*/
|
|
253
190
|
declare class SmtpTransport implements Transport, AsyncDisposable {
|
|
191
|
+
/**
|
|
192
|
+
* The SMTP configuration used by this transport.
|
|
193
|
+
*/
|
|
254
194
|
config: SmtpConfig;
|
|
255
|
-
|
|
195
|
+
/**
|
|
196
|
+
* The maximum number of connections in the pool.
|
|
197
|
+
*/
|
|
256
198
|
poolSize: number;
|
|
199
|
+
private connectionPool;
|
|
257
200
|
/**
|
|
258
201
|
* Creates a new SMTP transport instance.
|
|
259
202
|
*
|
|
@@ -317,10 +260,10 @@ declare class SmtpTransport implements Transport, AsyncDisposable {
|
|
|
317
260
|
* @returns An async iterable of receipts, one for each message.
|
|
318
261
|
*/
|
|
319
262
|
sendMany(messages: Iterable<Message> | AsyncIterable<Message>, options?: TransportOptions): AsyncIterable<Receipt>;
|
|
320
|
-
getConnection
|
|
321
|
-
connectAndSetup
|
|
322
|
-
returnConnection
|
|
323
|
-
discardConnection
|
|
263
|
+
private getConnection;
|
|
264
|
+
private connectAndSetup;
|
|
265
|
+
private returnConnection;
|
|
266
|
+
private discardConnection;
|
|
324
267
|
/**
|
|
325
268
|
* Closes all active SMTP connections in the connection pool.
|
|
326
269
|
*
|
|
@@ -352,4 +295,4 @@ declare class SmtpTransport implements Transport, AsyncDisposable {
|
|
|
352
295
|
[Symbol.asyncDispose](): Promise<void>;
|
|
353
296
|
}
|
|
354
297
|
//#endregion
|
|
355
|
-
export { SmtpAuth, SmtpConfig, SmtpTlsOptions, SmtpTransport
|
|
298
|
+
export { SmtpAuth, SmtpConfig, SmtpTlsOptions, SmtpTransport };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Socket } from "node:net";
|
|
2
|
-
import { TLSSocket } from "node:tls";
|
|
3
1
|
import { Message, Receipt, Transport, TransportOptions } from "@upyo/core";
|
|
4
2
|
|
|
5
3
|
//#region src/config.d.ts
|
|
@@ -154,67 +152,6 @@ interface SmtpTlsOptions {
|
|
|
154
152
|
* This type represents the final configuration after applying defaults,
|
|
155
153
|
* used internally by the SMTP transport implementation.
|
|
156
154
|
*/
|
|
157
|
-
type ResolvedSmtpConfig = Omit<Required<SmtpConfig>, "auth" | "tls"> & {
|
|
158
|
-
readonly auth?: SmtpAuth;
|
|
159
|
-
readonly tls?: SmtpTlsOptions;
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Creates a resolved SMTP configuration by applying default values to optional fields.
|
|
163
|
-
*
|
|
164
|
-
* This function takes a partial SMTP configuration and returns a complete
|
|
165
|
-
* configuration with all optional fields filled with sensible defaults.
|
|
166
|
-
*
|
|
167
|
-
* @param config - The SMTP configuration with optional fields
|
|
168
|
-
* @returns A resolved configuration with all defaults applied
|
|
169
|
-
*
|
|
170
|
-
* @example
|
|
171
|
-
* ```typescript
|
|
172
|
-
* const resolved = createSmtpConfig({
|
|
173
|
-
* host: 'smtp.example.com',
|
|
174
|
-
* auth: { user: 'user', pass: 'pass' }
|
|
175
|
-
* });
|
|
176
|
-
*
|
|
177
|
-
* // resolved.port will be 587 (default)
|
|
178
|
-
* // resolved.secure will be true (default)
|
|
179
|
-
* // resolved.poolSize will be 5 (default)
|
|
180
|
-
* ```
|
|
181
|
-
*/
|
|
182
|
-
declare function createSmtpConfig(config: SmtpConfig): ResolvedSmtpConfig;
|
|
183
|
-
//#endregion
|
|
184
|
-
//#region src/message-converter.d.ts
|
|
185
|
-
interface SmtpMessage {
|
|
186
|
-
readonly envelope: SmtpEnvelope;
|
|
187
|
-
readonly raw: string;
|
|
188
|
-
}
|
|
189
|
-
interface SmtpEnvelope {
|
|
190
|
-
readonly from: string;
|
|
191
|
-
readonly to: string[];
|
|
192
|
-
}
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/smtp-connection.d.ts
|
|
195
|
-
declare class SmtpConnection {
|
|
196
|
-
socket: Socket | TLSSocket | null;
|
|
197
|
-
config: ResolvedSmtpConfig;
|
|
198
|
-
authenticated: boolean;
|
|
199
|
-
capabilities: string[];
|
|
200
|
-
constructor(config: SmtpConfig);
|
|
201
|
-
connect(signal?: AbortSignal): Promise<void>;
|
|
202
|
-
sendCommand(command: string, signal?: AbortSignal): Promise<SmtpResponse>;
|
|
203
|
-
greeting(signal?: AbortSignal): Promise<SmtpResponse>;
|
|
204
|
-
ehlo(signal?: AbortSignal): Promise<void>;
|
|
205
|
-
authenticate(signal?: AbortSignal): Promise<void>;
|
|
206
|
-
private authPlain;
|
|
207
|
-
authLogin(signal?: AbortSignal): Promise<void>;
|
|
208
|
-
sendMessage(message: SmtpMessage, signal?: AbortSignal): Promise<string>;
|
|
209
|
-
extractMessageId(response: string): string;
|
|
210
|
-
quit(): Promise<void>;
|
|
211
|
-
reset(signal?: AbortSignal): Promise<void>;
|
|
212
|
-
}
|
|
213
|
-
interface SmtpResponse {
|
|
214
|
-
readonly code: number;
|
|
215
|
-
readonly message: string;
|
|
216
|
-
readonly raw: string;
|
|
217
|
-
}
|
|
218
155
|
//#endregion
|
|
219
156
|
//#region src/smtp-transport.d.ts
|
|
220
157
|
/**
|
|
@@ -251,9 +188,15 @@ interface SmtpResponse {
|
|
|
251
188
|
* ```
|
|
252
189
|
*/
|
|
253
190
|
declare class SmtpTransport implements Transport, AsyncDisposable {
|
|
191
|
+
/**
|
|
192
|
+
* The SMTP configuration used by this transport.
|
|
193
|
+
*/
|
|
254
194
|
config: SmtpConfig;
|
|
255
|
-
|
|
195
|
+
/**
|
|
196
|
+
* The maximum number of connections in the pool.
|
|
197
|
+
*/
|
|
256
198
|
poolSize: number;
|
|
199
|
+
private connectionPool;
|
|
257
200
|
/**
|
|
258
201
|
* Creates a new SMTP transport instance.
|
|
259
202
|
*
|
|
@@ -317,10 +260,10 @@ declare class SmtpTransport implements Transport, AsyncDisposable {
|
|
|
317
260
|
* @returns An async iterable of receipts, one for each message.
|
|
318
261
|
*/
|
|
319
262
|
sendMany(messages: Iterable<Message> | AsyncIterable<Message>, options?: TransportOptions): AsyncIterable<Receipt>;
|
|
320
|
-
getConnection
|
|
321
|
-
connectAndSetup
|
|
322
|
-
returnConnection
|
|
323
|
-
discardConnection
|
|
263
|
+
private getConnection;
|
|
264
|
+
private connectAndSetup;
|
|
265
|
+
private returnConnection;
|
|
266
|
+
private discardConnection;
|
|
324
267
|
/**
|
|
325
268
|
* Closes all active SMTP connections in the connection pool.
|
|
326
269
|
*
|
|
@@ -352,4 +295,4 @@ declare class SmtpTransport implements Transport, AsyncDisposable {
|
|
|
352
295
|
[Symbol.asyncDispose](): Promise<void>;
|
|
353
296
|
}
|
|
354
297
|
//#endregion
|
|
355
|
-
export { SmtpAuth, SmtpConfig, SmtpTlsOptions, SmtpTransport
|
|
298
|
+
export { SmtpAuth, SmtpConfig, SmtpTlsOptions, SmtpTransport };
|
package/dist/index.js
CHANGED
|
@@ -8,21 +8,11 @@ import { formatAddress } from "@upyo/core";
|
|
|
8
8
|
*
|
|
9
9
|
* This function takes a partial SMTP configuration and returns a complete
|
|
10
10
|
* configuration with all optional fields filled with sensible defaults.
|
|
11
|
+
* It is used internally by the SMTP transport.
|
|
11
12
|
*
|
|
12
13
|
* @param config - The SMTP configuration with optional fields
|
|
13
14
|
* @returns A resolved configuration with all defaults applied
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const resolved = createSmtpConfig({
|
|
18
|
-
* host: 'smtp.example.com',
|
|
19
|
-
* auth: { user: 'user', pass: 'pass' }
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* // resolved.port will be 587 (default)
|
|
23
|
-
* // resolved.secure will be true (default)
|
|
24
|
-
* // resolved.poolSize will be 5 (default)
|
|
25
|
-
* ```
|
|
15
|
+
* @internal
|
|
26
16
|
*/
|
|
27
17
|
function createSmtpConfig(config) {
|
|
28
18
|
return {
|
|
@@ -405,9 +395,15 @@ function encodeBase64(data) {
|
|
|
405
395
|
* ```
|
|
406
396
|
*/
|
|
407
397
|
var SmtpTransport = class {
|
|
398
|
+
/**
|
|
399
|
+
* The SMTP configuration used by this transport.
|
|
400
|
+
*/
|
|
408
401
|
config;
|
|
409
|
-
|
|
402
|
+
/**
|
|
403
|
+
* The maximum number of connections in the pool.
|
|
404
|
+
*/
|
|
410
405
|
poolSize;
|
|
406
|
+
connectionPool = [];
|
|
411
407
|
/**
|
|
412
408
|
* Creates a new SMTP transport instance.
|
|
413
409
|
*
|
|
@@ -630,4 +626,4 @@ var SmtpTransport = class {
|
|
|
630
626
|
};
|
|
631
627
|
|
|
632
628
|
//#endregion
|
|
633
|
-
export { SmtpTransport
|
|
629
|
+
export { SmtpTransport };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upyo/smtp",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.17+3ffd074a",
|
|
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.1.0-dev.
|
|
56
|
+
"@upyo/core": "0.1.0-dev.17+3ffd074a"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@dotenvx/dotenvx": "^1.47.3",
|