mirror of
https://github.com/eleith/emailjs.git
synced 2024-07-05 20:10:37 +00:00
smtp: stricten property access modifiers
This commit is contained in:
parent
dc1bd28e73
commit
3c1681c0fb
@ -17,11 +17,12 @@ export interface MessageStack {
|
||||
}
|
||||
|
||||
export class Client {
|
||||
public smtp: SMTPConnection;
|
||||
public queue: MessageStack[] = [];
|
||||
public timer: NodeJS.Timer | null = null;
|
||||
public sending = false;
|
||||
public ready = false;
|
||||
public readonly smtp: SMTPConnection;
|
||||
public readonly queue: MessageStack[] = [];
|
||||
|
||||
protected sending = false;
|
||||
protected ready = false;
|
||||
protected timer: NodeJS.Timer | null = null;
|
||||
|
||||
/**
|
||||
* @param {SMTPConnectionOptions} server smtp options
|
||||
|
@ -93,16 +93,16 @@ function convertDashDelimitedTextToSnakeCase(text: string) {
|
||||
}
|
||||
|
||||
export class Message {
|
||||
attachments: any[] = [];
|
||||
alternative: AlternateMessageAttachment | null = null;
|
||||
header: Partial<MessageHeaders> = {
|
||||
public readonly attachments: any[] = [];
|
||||
public readonly header: Partial<MessageHeaders> = {
|
||||
'message-id': `<${new Date().getTime()}.${counter++}.${
|
||||
process.pid
|
||||
}@${hostname()}>`,
|
||||
date: getRFC2822Date(),
|
||||
};
|
||||
content = 'text/plain; charset=utf-8';
|
||||
text?: string;
|
||||
public readonly content = 'text/plain; charset=utf-8';
|
||||
public readonly text?: string;
|
||||
public alternative: AlternateMessageAttachment | null = null;
|
||||
|
||||
constructor(headers: Partial<MessageHeaders>) {
|
||||
for (const header in headers) {
|
||||
|
@ -3,7 +3,7 @@ import type { Socket } from 'net'; // eslint-disable-line no-unused-vars
|
||||
import type { TLSSocket } from 'tls'; // eslint-disable-line no-unused-vars
|
||||
|
||||
export class SMTPResponse {
|
||||
public stop: (err?: Error) => void;
|
||||
public readonly stop: (err?: Error) => void;
|
||||
|
||||
constructor(
|
||||
stream: Socket | TLSSocket,
|
||||
|
35
smtp/smtp.ts
35
smtp/smtp.ts
@ -91,24 +91,30 @@ export interface ConnectOptions {
|
||||
}
|
||||
|
||||
export class SMTPConnection extends EventEmitter {
|
||||
private _state: 0 | 1 | 2 = SMTPState.NOTCONNECTED;
|
||||
private _secure = false;
|
||||
public readonly user: () => string;
|
||||
public readonly password: () => string;
|
||||
public readonly timeout: number = DEFAULT_TIMEOUT;
|
||||
|
||||
protected readonly log = log;
|
||||
protected readonly authentication: (keyof typeof AUTH_METHODS)[] = [
|
||||
AUTH_METHODS['CRAM-MD5'],
|
||||
AUTH_METHODS.LOGIN,
|
||||
AUTH_METHODS.PLAIN,
|
||||
AUTH_METHODS.XOAUTH2,
|
||||
];
|
||||
|
||||
protected _state: 0 | 1 | 2 = SMTPState.NOTCONNECTED;
|
||||
protected _secure = false;
|
||||
protected loggedin = false;
|
||||
|
||||
protected sock: Socket | TLSSocket | null = null;
|
||||
protected features: Indexed<string | boolean> | null = null;
|
||||
protected monitor: SMTPResponse | null = null;
|
||||
protected authentication: (keyof typeof AUTH_METHODS)[];
|
||||
protected domain = hostname();
|
||||
protected host = 'localhost';
|
||||
protected ssl: boolean | SMTPSocketOptions = false;
|
||||
protected tls: boolean | SMTPSocketOptions = false;
|
||||
protected port: number;
|
||||
protected loggedin = false;
|
||||
protected log = log;
|
||||
|
||||
public user: () => string;
|
||||
public password: () => string;
|
||||
public timeout: number = DEFAULT_TIMEOUT;
|
||||
|
||||
/**
|
||||
* SMTP class written using python's (2.7) smtplib.py as a base
|
||||
@ -127,14 +133,9 @@ export class SMTPConnection extends EventEmitter {
|
||||
}: Partial<SMTPConnectionOptions> = {}) {
|
||||
super();
|
||||
|
||||
this.authentication = Array.isArray(authentication)
|
||||
? authentication
|
||||
: [
|
||||
AUTH_METHODS['CRAM-MD5'],
|
||||
AUTH_METHODS.LOGIN,
|
||||
AUTH_METHODS.PLAIN,
|
||||
AUTH_METHODS.XOAUTH2,
|
||||
];
|
||||
if (Array.isArray(authentication)) {
|
||||
this.authentication = authentication;
|
||||
}
|
||||
|
||||
if (typeof timeout === 'number') {
|
||||
this.timeout = timeout;
|
||||
|
Loading…
Reference in New Issue
Block a user