@blazetrails/net-smtp 0.0.0-stage → 0.1.0-alpha0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dean Marano and Trails contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ import { Digest } from "@blazetrails/ruby-compat";
2
+ import { Authenticator } from "./authenticator.js";
3
+ import type { Response } from "./smtp.js";
4
+ export declare class AuthCramMD5 extends Authenticator {
5
+ /** @internal */
6
+ private _digestClass;
7
+ auth(user: string, secret: string): Promise<Response>;
8
+ static readonly IMASK = 54;
9
+ static readonly OMASK = 92;
10
+ cramMd5Response(secret: string, challenge: Uint8Array): string;
11
+ static readonly CRAM_BUFSIZE = 64;
12
+ cramSecret(secret: string, mask: number): Uint8Array;
13
+ get digestClass(): typeof Digest;
14
+ }
15
+ //# sourceMappingURL=auth-cram-md5.d.ts.map
@@ -0,0 +1,35 @@
1
+ import { Digest, unpack1 } from "@blazetrails/ruby-compat";
2
+ import { Authenticator } from "./authenticator.js";
3
+ export class AuthCramMD5 extends Authenticator {
4
+ static {
5
+ this.authType("cram_md5");
6
+ }
7
+ /** @internal */
8
+ _digestClass;
9
+ async auth(user, secret) {
10
+ const challenge = await this.continue("AUTH CRAM-MD5");
11
+ const crammed = this.cramMd5Response(secret, unpack1(challenge, "m"));
12
+ return await this.finish(this.base64Encode(`${user} ${crammed}`));
13
+ }
14
+ static IMASK = 0x36;
15
+ static OMASK = 0x5c;
16
+ cramMd5Response(secret, challenge) {
17
+ const tmp = this.digestClass.MD5.digest(new Uint8Array([...this.cramSecret(secret, AuthCramMD5.IMASK), ...challenge]));
18
+ return this.digestClass.MD5.hexdigest(new Uint8Array([...this.cramSecret(secret, AuthCramMD5.OMASK), ...tmp]));
19
+ }
20
+ static CRAM_BUFSIZE = 64;
21
+ cramSecret(secret, mask) {
22
+ let bytes = new TextEncoder().encode(secret);
23
+ if (bytes.length > AuthCramMD5.CRAM_BUFSIZE)
24
+ bytes = this.digestClass.MD5.digest(bytes);
25
+ const buf = new Uint8Array(AuthCramMD5.CRAM_BUFSIZE);
26
+ buf.set(bytes);
27
+ for (let i = 0; i < buf.length; i++)
28
+ buf[i] ^= mask;
29
+ return buf;
30
+ }
31
+ get digestClass() {
32
+ return (this._digestClass ??= Digest);
33
+ }
34
+ }
35
+ //# sourceMappingURL=auth-cram-md5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-cram-md5.js","sourceRoot":"","sources":["../lib/auth-cram-md5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,MAAM,OAAO,WAAY,SAAQ,aAAa;IAC5C;QACE,IAAI,CA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C,MAAM,CAAC,KAAK,CAAC,CAAC;QACxF,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACrD,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE;YAAE,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;QACpD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,WAAW;QACb,OAAO,CAAC,IAAI,CAAC,YAAY,KAAK,MAAM,CAAC,CAAC;IACxC,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import { Authenticator } from "./authenticator.js";
2
+ import type { Response } from "./smtp.js";
3
+ export declare class AuthLogin extends Authenticator {
4
+ auth(user: string, secret: string): Promise<Response>;
5
+ }
6
+ //# sourceMappingURL=auth-login.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { Authenticator } from "./authenticator.js";
2
+ export class AuthLogin extends Authenticator {
3
+ static {
4
+ this.authType("login");
5
+ }
6
+ async auth(user, secret) {
7
+ await this.continue("AUTH LOGIN");
8
+ await this.continue(this.base64Encode(user));
9
+ return await this.finish(this.base64Encode(secret));
10
+ }
11
+ }
12
+ //# sourceMappingURL=auth-login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-login.js","sourceRoot":"","sources":["../lib/auth-login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,MAAM,OAAO,SAAU,SAAQ,aAAa;IAC1C;QACE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,MAAc;QACrC,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAClC,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7C,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IACtD,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import { Authenticator } from "./authenticator.js";
2
+ import type { Response } from "./smtp.js";
3
+ export declare class AuthPlain extends Authenticator {
4
+ auth(user: string, secret: string): Promise<Response>;
5
+ }
6
+ //# sourceMappingURL=auth-plain.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { Authenticator } from "./authenticator.js";
2
+ export class AuthPlain extends Authenticator {
3
+ static {
4
+ this.authType("plain");
5
+ }
6
+ auth(user, secret) {
7
+ return this.finish("AUTH PLAIN " + this.base64Encode(`\0${user}\0${secret}`));
8
+ }
9
+ }
10
+ //# sourceMappingURL=auth-plain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-plain.js","sourceRoot":"","sources":["../lib/auth-plain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,MAAM,OAAO,SAAU,SAAQ,aAAa;IAC1C;QACE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,IAAY,EAAE,MAAc;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC;IAChF,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import { Authenticator } from "./authenticator.js";
2
+ import type { Response } from "./smtp.js";
3
+ export declare class AuthXoauth2 extends Authenticator {
4
+ auth(user: string, secret: string): Promise<Response>;
5
+ /** @internal */
6
+ private xoauth2String;
7
+ }
8
+ //# sourceMappingURL=auth-xoauth2.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { Authenticator } from "./authenticator.js";
2
+ export class AuthXoauth2 extends Authenticator {
3
+ static {
4
+ this.authType("xoauth2");
5
+ }
6
+ auth(user, secret) {
7
+ const token = this.xoauth2String(user, secret);
8
+ return this.finish(`AUTH XOAUTH2 ${this.base64Encode(token)}`);
9
+ }
10
+ /** @internal */
11
+ xoauth2String(user, secret) {
12
+ return `user=${user}\x01auth=Bearer ${secret}\x01\x01`;
13
+ }
14
+ }
15
+ //# sourceMappingURL=auth-xoauth2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-xoauth2.js","sourceRoot":"","sources":["../lib/auth-xoauth2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,MAAM,OAAO,WAAY,SAAQ,aAAa;IAC5C;QACE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI,CAAC,IAAY,EAAE,MAAc;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE/C,OAAO,IAAI,CAAC,MAAM,CAAC,gBAAgB,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,gBAAgB;IACR,aAAa,CAAC,IAAY,EAAE,MAAc;QAChD,OAAO,QAAQ,IAAI,mBAAmB,MAAM,UAAU,CAAC;IACzD,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import type { Response } from "./smtp.js";
2
+ interface AuthHost {
3
+ getResponse(reqline: string): Promise<Response>;
4
+ }
5
+ type AuthClass = (new (smtp: AuthHost) => Authenticator) & typeof Authenticator;
6
+ export declare abstract class Authenticator {
7
+ private static _classes;
8
+ static authClasses(): Record<string, AuthClass>;
9
+ static authType(type: string): void;
10
+ static authClass(type: string): AuthClass | undefined;
11
+ static checkArgs(userArg?: string | null, secretArg?: string | null): void;
12
+ readonly smtp: AuthHost;
13
+ abstract auth(user: string, secret: string): Promise<Response>;
14
+ constructor(smtp: AuthHost);
15
+ continue(arg: string): Promise<string>;
16
+ finish(arg: string): Promise<Response>;
17
+ base64Encode(str: string): string;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=authenticator.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { ArgumentError, pack } from "@blazetrails/ruby-compat";
2
+ import { Net } from "./protocol.js";
3
+ export class Authenticator {
4
+ static _classes = {};
5
+ static authClasses() {
6
+ return Authenticator._classes;
7
+ }
8
+ static authType(type) {
9
+ const key = type.toUpperCase().replaceAll("_", "-");
10
+ Authenticator.authClasses()[key] = this;
11
+ }
12
+ static authClass(type) {
13
+ return Authenticator.authClasses()[type.toUpperCase().replaceAll("_", "-")];
14
+ }
15
+ static checkArgs(userArg = null, secretArg = null) {
16
+ if (userArg == null)
17
+ throw new ArgumentError("SMTP-AUTH requested but missing user name");
18
+ if (secretArg == null)
19
+ throw new ArgumentError("SMTP-AUTH requested but missing secret phrase");
20
+ }
21
+ smtp;
22
+ constructor(smtp) {
23
+ this.smtp = smtp;
24
+ }
25
+ async continue(arg) {
26
+ const res = await this.smtp.getResponse(arg);
27
+ if (!res.isContinue())
28
+ throw new res.exceptionClass(res);
29
+ return res.string.trim().split(/\s+/)[1];
30
+ }
31
+ async finish(arg) {
32
+ const res = await this.smtp.getResponse(arg);
33
+ if (!res.isSuccess())
34
+ throw new Net.SMTPAuthenticationError(res);
35
+ return res;
36
+ }
37
+ base64Encode(str) {
38
+ return pack([str], "m0");
39
+ }
40
+ }
41
+ //# sourceMappingURL=authenticator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authenticator.js","sourceRoot":"","sources":["../lib/authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AASpC,MAAM,OAAgB,aAAa;IACzB,MAAM,CAAC,QAAQ,GAA8B,EAAE,CAAC;IAExD,MAAM,CAAC,WAAW;QAChB,OA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AAI,CAAC,GAAG,CAAC,SAAS,EAAE;YAAE,MAAM,IAAI,GAAG,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC;QACjE,OAAO,GAAG,CAAC;IACb,CAAC;IAED,YAAY,CAAC,GAAW;QACtB,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=constants.generated.d.ts.map
@@ -0,0 +1,25 @@
1
+ import { defineConstants } from "@blazetrails/ruby-compat";
2
+ import * as m0 from "./auth-cram-md5.js";
3
+ import * as m1 from "./auth-login.js";
4
+ import * as m2 from "./auth-plain.js";
5
+ import * as m3 from "./auth-xoauth2.js";
6
+ import * as m4 from "./authenticator.js";
7
+ import * as m5 from "./smtp.js";
8
+ defineConstants([
9
+ [m5, "SMTP", "Net::SMTP"],
10
+ [m5, "Address", "Net::SMTP::Address"],
11
+ [m0, "AuthCramMD5", "Net::SMTP::AuthCramMD5"],
12
+ [m4, "Authenticator", "Net::SMTP::Authenticator"],
13
+ [m1, "AuthLogin", "Net::SMTP::AuthLogin"],
14
+ [m2, "AuthPlain", "Net::SMTP::AuthPlain"],
15
+ [m3, "AuthXoauth2", "Net::SMTP::AuthXoauth2"],
16
+ [m5, "Response", "Net::SMTP::Response"],
17
+ [m5, "SMTPAuthenticationError", "Net::SMTPAuthenticationError"],
18
+ [m5, "SMTPError", "Net::SMTPError"],
19
+ [m5, "SMTPFatalError", "Net::SMTPFatalError"],
20
+ [m5, "SMTPServerBusy", "Net::SMTPServerBusy"],
21
+ [m5, "SMTPSyntaxError", "Net::SMTPSyntaxError"],
22
+ [m5, "SMTPUnknownError", "Net::SMTPUnknownError"],
23
+ [m5, "SMTPUnsupportedCommand", "Net::SMTPUnsupportedCommand"],
24
+ ]);
25
+ //# sourceMappingURL=constants.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.generated.js","sourceRoot":"","s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export { Net, Protocol, ProtocolError, ProtoSyntaxError, ProtoFatalError, ProtoUnknownError, ProtoServerError, ProtoAuthError, OpenTimeout, ReadTimeout, } from "@blazetrails/ruby-compat";
3
+ declare module "@blazetrails/ruby-compat" {
4
+ interface NetModule {
5
+ /** @noRailsEquivalent PERMANENT */
6
+ SMTP: typeof SMTP;
7
+ /** @noRailsEquivalent PERMANENT */
8
+ SMTPAuthenticationError: typeof SMTPAuthenticationError;
9
+ }
10
+ }
11
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { Net, Protocol, ProtocolError, ProtoSyntaxError, ProtoFatalError, ProtoUnknownError, ProtoServerError, ProtoAuthError, OpenTimeout, ReadTimeout, } from "@blazetrails/ruby-compat";
2
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../lib/protocol.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,GAAG,EACH,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,WAAW,GACZ,MAAM,0BAA0B,CAAC"}
package/dist/smtp.d.ts ADDED
@@ -0,0 +1,224 @@
1
+ import SMTPConnection from "nodemailer/lib/smtp-connection/index.js";
2
+ import { OpenSSL, type HttpSslOptions } from "@blazetrails/ruby-compat";
3
+ import { Authenticator } from "./authenticator.js";
4
+ import { Protocol, ProtoAuthError, ProtoFatalError, ProtocolError, ProtoServerError, ProtoSyntaxError, ProtoUnknownError } from "./protocol.js";
5
+ type Connection = SMTPConnection & {
6
+ _destroyed: boolean;
7
+ options: {
8
+ tls?: object;
9
+ };
10
+ _socket?: {
11
+ setTimeout(ms: number): unknown;
12
+ write(data: string | Uint8Array): unknown;
13
+ };
14
+ _sendCommand(str: string): void;
15
+ _responseActions: Array<(str: string) => void>;
16
+ _actionGreeting(str: string): void;
17
+ _clearPhase(): void;
18
+ _onConnect(): void;
19
+ _connectionDeadline: number | null;
20
+ _upgradeConnection(callback: (err: Error | null) => void): void;
21
+ startSsl(options: HttpSslOptions): Promise<void>;
22
+ };
23
+ type SSLContext = InstanceType<typeof OpenSSL.SSL.SSLContext>;
24
+ type SSLSocket = InstanceType<typeof OpenSSL.SSL.SSLSocket<Connection>>;
25
+ interface NewOptions {
26
+ tls?: boolean;
27
+ starttls?: boolean | string;
28
+ tlsVerify?: boolean;
29
+ tlsHostname?: string | null;
30
+ sslContextParams?: Record<string, unknown> | null;
31
+ }
32
+ export declare const SMTPError: {
33
+ readonly message: string;
34
+ };
35
+ export declare class SMTPAuthenticationError extends ProtoAuthError {
36
+ response: Response | null;
37
+ /** @internal */
38
+ _message: string | null;
39
+ constructor(response: Response | string, { message }?: {
40
+ message?: string | null;
41
+ });
42
+ }
43
+ export declare class SMTPServerBusy extends ProtoServerError {
44
+ response: Response | null;
45
+ /** @internal */
46
+ _message: string | null;
47
+ constructor(response: Response | string, { message }?: {
48
+ message?: string | null;
49
+ });
50
+ }
51
+ export declare class SMTPSyntaxError extends ProtoSyntaxError {
52
+ response: Response | null;
53
+ /** @internal */
54
+ _message: string | null;
55
+ constructor(response: Response | string, { message }?: {
56
+ message?: string | null;
57
+ });
58
+ }
59
+ export declare class SMTPFatalError extends ProtoFatalError {
60
+ response: Response | null;
61
+ /** @internal */
62
+ _message: string | null;
63
+ constructor(response: Response | string, { message }?: {
64
+ message?: string | null;
65
+ });
66
+ }
67
+ export declare class SMTPUnknownError extends ProtoUnknownError {
68
+ response: Response | null;
69
+ /** @internal */
70
+ _message: string | null;
71
+ constructor(response: Response | string, { message }?: {
72
+ message?: string | null;
73
+ });
74
+ }
75
+ export declare class SMTPUnsupportedCommand extends ProtocolError {
76
+ response: Response | null;
77
+ /** @internal */
78
+ _message: string | null;
79
+ constructor(response: Response | string, { message }?: {
80
+ message?: string | null;
81
+ });
82
+ }
83
+ export declare class Response {
84
+ static parse(str: string): Response;
85
+ readonly status: string;
86
+ readonly string: string;
87
+ constructor(status: string, string: string);
88
+ statusTypeChar(): string;
89
+ isSuccess(): boolean;
90
+ isContinue(): boolean;
91
+ get message(): string;
92
+ cramMd5Challenge(): string;
93
+ get capabilities(): Record<string, string[]>;
94
+ get exceptionClass(): new (response: Response) => Error;
95
+ }
96
+ export declare class Address {
97
+ readonly address: string;
98
+ readonly parameters: string[];
99
+ constructor(address: string | Address, ...args: unknown[]);
100
+ toString(): string;
101
+ }
102
+ export declare class SMTP extends Protocol {
103
+ static readonly VERSION = "0.5.1";
104
+ static readonly DEFAULT_AUTH_TYPE = "plain";
105
+ static readonly Response: typeof Response;
106
+ static readonly Address: typeof Address;
107
+ static readonly Authenticator: typeof Authenticator;
108
+ static defaultPort(): number;
109
+ static defaultSubmissionPort(): number;
110
+ static defaultTlsPort(): number;
111
+ static defaultSslPort(): number;
112
+ static defaultSslContext(sslContextParams?: Record<string, unknown> | null): SSLContext;
113
+ static start(address: string, port?: number | null, ...args: unknown[]): Promise<unknown>;
114
+ readonly address: string;
115
+ readonly port: number;
116
+ esmtp: unknown;
117
+ capabilities: Record<string, string[]> | null;
118
+ tlsVerify: boolean;
119
+ tlsHostname: string | null;
120
+ sslContextParams: Record<string, unknown> | null;
121
+ openTimeout: number;
122
+ /** @internal */
123
+ _socket: Connection | null;
124
+ private _started;
125
+ private _readTimeout;
126
+ private _errorOccurred;
127
+ private _debugOutput;
128
+ private _tls;
129
+ private _starttls;
130
+ private _sslContextTls;
131
+ private _sslContextStarttls;
132
+ constructor(address: string, port?: number | null, { tls, starttls, tlsVerify, tlsHostname, sslContextParams, }?: NewOptions);
133
+ inspect(): string;
134
+ isEsmtp(): unknown;
135
+ isCapableStarttls(): boolean | null;
136
+ isCapable(key: string): boolean | null;
137
+ isCapablePlainAuth(): boolean | null;
138
+ isCapableLoginAuth(): boolean | null;
139
+ isCapableCramMd5Auth(): boolean | null;
140
+ isAuthCapable(type: string): boolean | null;
141
+ capableAuthTypes(): string[];
142
+ isTls(): boolean;
143
+ isSsl(): boolean;
144
+ enableTls(context?: SSLContext | null): void;
145
+ enableSsl(context?: SSLContext | null): void;
146
+ disableTls(): void;
147
+ disableSsl(): void;
148
+ isStarttls(): boolean | string;
149
+ isStarttlsAlways(): boolean;
150
+ isStarttlsAuto(): boolean;
151
+ enableStarttls(context?: SSLContext | null): void;
152
+ enableStarttlsAuto(context?: SSLContext | null): void;
153
+ disableStarttls(): void;
154
+ get readTimeout(): number;
155
+ set readTimeout(sec: number);
156
+ set debugOutput(arg: {
157
+ write(str: string): unknown;
158
+ } | null);
159
+ setDebugOutput(arg: {
160
+ write(str: string): unknown;
161
+ } | null): void;
162
+ isStarted(): boolean;
163
+ start(...args: unknown[]): Promise<unknown>;
164
+ finish(): Promise<void>;
165
+ /**
166
+ * @internal
167
+ * @inventedArm rescue — PERMANENT
168
+ */
169
+ private doStart;
170
+ /** @internal */
171
+ protected sslSocket(socket: Connection, context: SSLContext): SSLSocket;
172
+ /** @internal */
173
+ private tlsconnect;
174
+ /** @internal */
175
+ private doHelo;
176
+ /** @internal */
177
+ private doFinish;
178
+ /** @internal */
179
+ private requiresSmtputf8;
180
+ /** @internal */
181
+ private anyRequireSmtputf8;
182
+ sendMessage(msgstr: string | Uint8Array, fromAddr: string | Address, ...toAddrs: Array<string | Address | Array<string | Address>>): Promise<Response>;
183
+ sendMail(msgstr: string | Uint8Array, fromAddr: string | Address, ...toAddrs: Array<string | Address | Array<string | Address>>): Promise<Response>;
184
+ sendmail(msgstr: string | Uint8Array, fromAddr: string | Address, ...toAddrs: Array<string | Address | Array<string | Address>>): Promise<Response>;
185
+ openMessageStream(fromAddr: string | Address, ...toAddrs: unknown[]): Promise<Response>;
186
+ ready(fromAddr: string | Address, ...toAddrs: unknown[]): Promise<Response>;
187
+ authenticate(user: string, secret: string | null, authtype?: string): Promise<Response>;
188
+ /** @internal */
189
+ private checkAuthArgs;
190
+ starttls(): Promise<Response>;
191
+ helo(domain: string): Promise<Response>;
192
+ ehlo(domain: string): Promise<Response>;
193
+ rset(): Promise<Response>;
194
+ mailfrom(fromAddr: string | Address): Promise<Response>;
195
+ rcpttoList<T>(toAddrs: Array<string | Address>, block: () => Promise<T>): Promise<T>;
196
+ rcptto(toAddr: string | Address): Promise<Response>;
197
+ data(msgstr?: string | Uint8Array | null, block?: ((stream: {
198
+ write(str: string): unknown;
199
+ }) => unknown) | null): Promise<Response>;
200
+ quit(): Promise<Response>;
201
+ getResponse(reqline: string): Promise<Response>;
202
+ /** @internal */
203
+ private validateLine;
204
+ /** @internal */
205
+ private getok;
206
+ /** @internal */
207
+ private recvResponse;
208
+ /** @internal */
209
+ critical<T>(block?: () => T | Promise<T>): Promise<T | Response>;
210
+ /** @internal */
211
+ private checkResponse;
212
+ /** @internal */
213
+ private checkContinue;
214
+ /** @internal */
215
+ private logging;
216
+ }
217
+ export declare const SMTPSession: typeof SMTP;
218
+ import "./auth-plain.js";
219
+ import "./auth-login.js";
220
+ import "./auth-cram-md5.js";
221
+ import "./auth-xoauth2.js";
222
+ import "./constants.generated.js";
223
+ export {};
224
+ //# sourceMappingURL=smtp.d.ts.map