mirror of https://github.com/eleith/emailjs.git
chore: remove jsdoc bureaucracy
This commit is contained in:
parent
dd3db098c0
commit
a5ff7bd85e
|
@ -17,6 +17,12 @@
|
||||||
"error",
|
"error",
|
||||||
"unix"
|
"unix"
|
||||||
],
|
],
|
||||||
"valid-jsdoc": "error"
|
"valid-jsdoc": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"requireParamDescription": false,
|
||||||
|
"requireReturnDescription": false
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ export interface AddressObject {
|
||||||
group?: AddressObject[];
|
group?: AddressObject[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Operator tokens and which tokens are expected to end the sequence
|
* Operator tokens and which tokens are expected to end the sequence
|
||||||
*/
|
*/
|
||||||
const OPERATORS = new Map([
|
const OPERATORS = new Map([
|
||||||
|
@ -32,7 +32,7 @@ const OPERATORS = new Map([
|
||||||
* Tokenizes the original input string
|
* Tokenizes the original input string
|
||||||
*
|
*
|
||||||
* @param {string | string[] | undefined} address string(s) to tokenize
|
* @param {string | string[] | undefined} address string(s) to tokenize
|
||||||
* @return {AddressToken[]} An array of operator|text tokens
|
* @return {AddressToken[]} An array of operator & text tokens
|
||||||
*/
|
*/
|
||||||
function tokenizeAddress(address: string | string[] = '') {
|
function tokenizeAddress(address: string | string[] = '') {
|
||||||
const tokens: AddressToken[] = [];
|
const tokens: AddressToken[] = [];
|
||||||
|
@ -69,8 +69,8 @@ function tokenizeAddress(address: string | string[] = '') {
|
||||||
/**
|
/**
|
||||||
* Converts tokens for a single address into an address object
|
* Converts tokens for a single address into an address object
|
||||||
*
|
*
|
||||||
* @param {AddressToken[]} tokens Tokens object
|
* @param {AddressToken[]} tokens
|
||||||
* @return {AddressObject[]} addresses object array
|
* @return {AddressObject[]}
|
||||||
*/
|
*/
|
||||||
function convertAddressTokens(tokens: AddressToken[]) {
|
function convertAddressTokens(tokens: AddressToken[]) {
|
||||||
const addressObjects: AddressObject[] = [];
|
const addressObjects: AddressObject[] = [];
|
||||||
|
@ -208,8 +208,8 @@ function convertAddressTokens(tokens: AddressToken[]) {
|
||||||
*
|
*
|
||||||
* [{name: "Name", address: "address@domain"}]
|
* [{name: "Name", address: "address@domain"}]
|
||||||
*
|
*
|
||||||
* @param {string | string[] | undefined} address Address field
|
* @param {string | string[] | undefined} address
|
||||||
* @return {AddressObject[]} An array of address objects
|
* @return {AddressObject[]}
|
||||||
*/
|
*/
|
||||||
export function addressparser(address?: string | string[]) {
|
export function addressparser(address?: string | string[]) {
|
||||||
const addresses: AddressObject[] = [];
|
const addresses: AddressObject[] = [];
|
||||||
|
|
|
@ -44,7 +44,7 @@ export class SMTPClient {
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @template {Message | MessageHeaders} T
|
* @template {Message | MessageHeaders} T
|
||||||
* @param {T} msg the message to send
|
* @param {T} msg
|
||||||
* @param {MessageCallback<T>} callback receiver for the error (if any) as well as the passed-in message / headers
|
* @param {MessageCallback<T>} callback receiver for the error (if any) as well as the passed-in message / headers
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
@ -71,8 +71,8 @@ export class SMTPClient {
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @template {Message | MessageHeaders} T
|
* @template {Message | MessageHeaders} T
|
||||||
* @param {T} msg the message to send
|
* @param {T} msg
|
||||||
* @returns {Promise<T>} a promise that resolves to the passed-in message / headers
|
* @returns {Promise<Message>} a promise that resolves to the message / headers
|
||||||
*/
|
*/
|
||||||
public sendAsync<T extends Message | MessageHeaders>(msg: T) {
|
public sendAsync<T extends Message | MessageHeaders>(msg: T) {
|
||||||
return new Promise<Message>((resolve, reject) => {
|
return new Promise<Message>((resolve, reject) => {
|
||||||
|
@ -176,18 +176,18 @@ export class SMTPClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {MessageStack} stack stack
|
* @param {MessageStack} stack
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
protected _connect(stack: MessageStack) {
|
protected _connect(stack: MessageStack) {
|
||||||
/**
|
/**
|
||||||
* @param {Error | null} err callback error
|
* @param {Error | null} err
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const connect = (err: Error | null) => {
|
const connect = (err: Error | null) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
/**
|
/**
|
||||||
* @param {Error | null} err callback error
|
* @param {Error | null} err
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const begin = (err: Error | null) => {
|
const begin = (err: Error | null) => {
|
||||||
|
@ -223,8 +223,8 @@ export class SMTPClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {MessageAttachment | MessageAttachment[]} attachment attachment
|
* @param {MessageAttachment | MessageAttachment[]} attachment
|
||||||
* @returns {boolean} whether the attachment contains inlined html
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
protected _containsInlinedHtml(
|
protected _containsInlinedHtml(
|
||||||
attachment?: MessageAttachment | MessageAttachment[]
|
attachment?: MessageAttachment | MessageAttachment[]
|
||||||
|
@ -240,8 +240,8 @@ export class SMTPClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {MessageAttachment} attachment attachment
|
* @param {MessageAttachment} attachment
|
||||||
* @returns {boolean} whether the attachment is inlined html
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
protected _isAttachmentInlinedHtml(attachment?: MessageAttachment) {
|
protected _isAttachmentInlinedHtml(attachment?: MessageAttachment) {
|
||||||
return (
|
return (
|
||||||
|
@ -253,9 +253,9 @@ export class SMTPClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {MessageStack} stack stack
|
* @param {MessageStack} stack
|
||||||
* @param {function(MessageStack): void} next next
|
* @param {function(MessageStack): void} next
|
||||||
* @returns {function(Error): void} callback
|
* @returns {function(Error): void}
|
||||||
*/
|
*/
|
||||||
protected _sendsmtp(stack: MessageStack, next: (msg: MessageStack) => void) {
|
protected _sendsmtp(stack: MessageStack, next: (msg: MessageStack) => void) {
|
||||||
return (err: Error | null) => {
|
return (err: Error | null) => {
|
||||||
|
@ -271,7 +271,7 @@ export class SMTPClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {MessageStack} stack stack
|
* @param {MessageStack} stack
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
protected _sendmail(stack: MessageStack) {
|
protected _sendmail(stack: MessageStack) {
|
||||||
|
@ -282,7 +282,7 @@ export class SMTPClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {MessageStack} stack stack
|
* @param {MessageStack} stack
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
protected _sendrcpt(stack: MessageStack) {
|
protected _sendrcpt(stack: MessageStack) {
|
||||||
|
@ -299,7 +299,7 @@ export class SMTPClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {MessageStack} stack stack
|
* @param {MessageStack} stack
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
protected _senddata(stack: MessageStack) {
|
protected _senddata(stack: MessageStack) {
|
||||||
|
@ -308,7 +308,7 @@ export class SMTPClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {MessageStack} stack stack
|
* @param {MessageStack} stack
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
protected _sendmessage(stack: MessageStack) {
|
protected _sendmessage(stack: MessageStack) {
|
||||||
|
@ -331,8 +331,8 @@ export class SMTPClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {Error | null} err err
|
* @param {Error | null} err
|
||||||
* @param {MessageStack} stack stack
|
* @param {MessageStack} stack
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
protected _senddone(err: Error | null, stack: MessageStack) {
|
protected _senddone(err: Error | null, stack: MessageStack) {
|
||||||
|
|
|
@ -127,7 +127,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
*
|
*
|
||||||
* NOTE: `host` is trimmed before being used to establish a connection; however, the original untrimmed value will still be visible in configuration.
|
* NOTE: `host` is trimmed before being used to establish a connection; however, the original untrimmed value will still be visible in configuration.
|
||||||
*
|
*
|
||||||
* @param {Partial<SMTPConnectionOptions>} options options
|
* @param {Partial<SMTPConnectionOptions>} options
|
||||||
*/
|
*/
|
||||||
constructor({
|
constructor({
|
||||||
timeout,
|
timeout,
|
||||||
|
@ -193,7 +193,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {0 | 1} level -
|
* @param {0 | 1} level
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public debug(level: 0 | 1) {
|
public debug(level: 0 | 1) {
|
||||||
|
@ -202,7 +202,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @returns {SMTPState} the current state
|
* @returns {SMTPState}
|
||||||
*/
|
*/
|
||||||
public state() {
|
public state() {
|
||||||
return this._state;
|
return this._state;
|
||||||
|
@ -210,7 +210,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @returns {boolean} whether or not the instance is authorized
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
public authorized() {
|
public authorized() {
|
||||||
return this.loggedin;
|
return this.loggedin;
|
||||||
|
@ -222,10 +222,10 @@ export class SMTPConnection extends EventEmitter {
|
||||||
* NOTE: `host` is trimmed before being used to establish a connection; however, the original untrimmed value will still be visible in configuration.
|
* NOTE: `host` is trimmed before being used to establish a connection; however, the original untrimmed value will still be visible in configuration.
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @param {number} [port] the port to use for the connection
|
* @param {number} [port]
|
||||||
* @param {string} [host] the hostname to use for the connection
|
* @param {string} [host]
|
||||||
* @param {ConnectOptions} [options={}] the options
|
* @param {ConnectOptions} [options={}]
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public connect(
|
public connect(
|
||||||
|
@ -269,7 +269,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Error} err err
|
* @param {Error} err
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const connectedErrBack = (err?: Error) => {
|
const connectedErrBack = (err?: Error) => {
|
||||||
|
@ -343,8 +343,8 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {string} str the string to send
|
* @param {string} str
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public send(str: string, callback: SMTPCommandCallback) {
|
public send(str: string, callback: SMTPCommandCallback) {
|
||||||
|
@ -376,9 +376,9 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {string} cmd command to issue
|
* @param {string} cmd
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @param {(number[] | number)} [codes=[250]] array codes
|
* @param {(number[] | number)} [codes=[250]] SMTP response code(s)
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public command(
|
public command(
|
||||||
|
@ -448,8 +448,8 @@ export class SMTPConnection extends EventEmitter {
|
||||||
* As this command was deprecated by rfc2821, it should only be used for compatibility with non-compliant servers.
|
* As this command was deprecated by rfc2821, it should only be used for compatibility with non-compliant servers.
|
||||||
* @see https://tools.ietf.org/html/rfc2821#appendix-F.3
|
* @see https://tools.ietf.org/html/rfc2821#appendix-F.3
|
||||||
*
|
*
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @param {string} [domain] the domain to associate with the 'helo' request
|
* @param {string} [domain]
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public helo(callback: SMTPCommandCallback, domain?: string) {
|
public helo(callback: SMTPCommandCallback, domain?: string) {
|
||||||
|
@ -465,7 +465,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public starttls(callback: SMTPCommandCallback) {
|
public starttls(callback: SMTPCommandCallback) {
|
||||||
|
@ -503,7 +503,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {string} data the string to parse for features
|
* @param {string} data
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public parse_smtp_features(data: string) {
|
public parse_smtp_features(data: string) {
|
||||||
|
@ -533,8 +533,8 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @param {string} [domain] the domain to associate with the 'ehlo' request
|
* @param {string} [domain]
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public ehlo(callback: SMTPCommandCallback, domain?: string) {
|
public ehlo(callback: SMTPCommandCallback, domain?: string) {
|
||||||
|
@ -557,7 +557,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {string} opt the features keyname to check
|
* @param {string} opt the features keyname to check
|
||||||
* @returns {boolean} whether the extension exists
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
public has_extn(opt: string) {
|
public has_extn(opt: string) {
|
||||||
return (this.features ?? {})[opt.toLowerCase()] === undefined;
|
return (this.features ?? {})[opt.toLowerCase()] === undefined;
|
||||||
|
@ -566,8 +566,8 @@ export class SMTPConnection extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @description SMTP 'help' command, returns text from the server
|
* @description SMTP 'help' command, returns text from the server
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @param {string} domain the domain to associate with the 'help' request
|
* @param {string} domain
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public help(callback: SMTPCommandCallback, domain: string) {
|
public help(callback: SMTPCommandCallback, domain: string) {
|
||||||
|
@ -576,7 +576,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public rset(callback: SMTPCommandCallback) {
|
public rset(callback: SMTPCommandCallback) {
|
||||||
|
@ -585,7 +585,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public noop(callback: SMTPCommandCallback) {
|
public noop(callback: SMTPCommandCallback) {
|
||||||
|
@ -594,7 +594,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @param {string} from the sender
|
* @param {string} from the sender
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
@ -604,7 +604,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @param {string} to the receiver
|
* @param {string} to the receiver
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
@ -614,7 +614,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public data(callback: SMTPCommandCallback) {
|
public data(callback: SMTPCommandCallback) {
|
||||||
|
@ -623,7 +623,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public data_end(callback: SMTPCommandCallback) {
|
public data_end(callback: SMTPCommandCallback) {
|
||||||
|
@ -643,8 +643,8 @@ export class SMTPConnection extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @description SMTP 'verify' command -- checks for address validity.
|
* @description SMTP 'verify' command -- checks for address validity.
|
||||||
* @param {string} address the address to validate
|
* @param {string} address
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public verify(address: string, callback: SMTPCommandCallback) {
|
public verify(address: string, callback: SMTPCommandCallback) {
|
||||||
|
@ -654,8 +654,8 @@ export class SMTPConnection extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @description SMTP 'expn' command -- expands a mailing list.
|
* @description SMTP 'expn' command -- expands a mailing list.
|
||||||
* @param {string} address the mailing list to expand
|
* @param {string} address
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public expn(address: string, callback: SMTPCommandCallback) {
|
public expn(address: string, callback: SMTPCommandCallback) {
|
||||||
|
@ -669,7 +669,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
* If there has been no previous EHLO or HELO command self session, self
|
* If there has been no previous EHLO or HELO command self session, self
|
||||||
* method tries ESMTP EHLO first.
|
* method tries ESMTP EHLO first.
|
||||||
*
|
*
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @param {string} [domain] the domain to associate with the command
|
* @param {string} [domain] the domain to associate with the command
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
@ -698,12 +698,12 @@ export class SMTPConnection extends EventEmitter {
|
||||||
*
|
*
|
||||||
* This method will return normally if the authentication was successful.
|
* This method will return normally if the authentication was successful.
|
||||||
*
|
*
|
||||||
* @param {SMTPCommandCallback} callback function to call after response
|
* @param {SMTPCommandCallback} callback
|
||||||
* @param {string} [user] the username to authenticate with
|
* @param {string} [user]
|
||||||
* @param {string} [password] the password for the authentication
|
* @param {string} [password]
|
||||||
* @param {Object} [options] login options
|
* @param {Object} [options]
|
||||||
* @param {string} [options.method] login method
|
* @param {string} [options.method]
|
||||||
* @param {string} [options.domain] login domain
|
* @param {string} [options.domain]
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public login(
|
public login(
|
||||||
|
@ -721,8 +721,8 @@ export class SMTPConnection extends EventEmitter {
|
||||||
const domain = options?.domain || this.domain;
|
const domain = options?.domain || this.domain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Error | null} err err
|
* @param {Error | null} err
|
||||||
* @param {unknown} data data
|
* @param {unknown} data
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const initiate = (err: Error | null | undefined, data: unknown) => {
|
const initiate = (err: Error | null | undefined, data: unknown) => {
|
||||||
|
@ -734,7 +734,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
let method: keyof typeof AUTH_METHODS | null = null;
|
let method: keyof typeof AUTH_METHODS | null = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} challenge challenge
|
* @param {string} challenge
|
||||||
* @returns {string} base64 cram hash
|
* @returns {string} base64 cram hash
|
||||||
*/
|
*/
|
||||||
const encodeCramMd5 = (challenge: string) => {
|
const encodeCramMd5 = (challenge: string) => {
|
||||||
|
@ -785,8 +785,8 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle bad responses from command differently
|
* handle bad responses from command differently
|
||||||
* @param {Error} err err
|
* @param {Error} err
|
||||||
* @param {unknown} data data
|
* @param {unknown} data
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const failed = (err: Error, data: unknown) => {
|
const failed = (err: Error, data: unknown) => {
|
||||||
|
@ -803,12 +803,12 @@ export class SMTPConnection extends EventEmitter {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Error | SMTPError | null} err err
|
* @param {Error | SMTPError | null} err
|
||||||
* @param {(
|
* @param {(
|
||||||
* string |
|
* string |
|
||||||
* { code: (string | number), data: string, message: string } |
|
* { code: (string | number), data: string, message: string } |
|
||||||
* null
|
* null
|
||||||
* )} [data] data
|
* )} [data]
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const response: SMTPCommandCallback = (err, data) => {
|
const response: SMTPCommandCallback = (err, data) => {
|
||||||
|
@ -821,13 +821,13 @@ export class SMTPConnection extends EventEmitter {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Error | SMTPError | null} err err
|
* @param {Error | SMTPError | null} err
|
||||||
* @param {(
|
* @param {(
|
||||||
* string |
|
* string |
|
||||||
* { code: (string | number), data: string, message: string } |
|
* { code: (string | number), data: string, message: string } |
|
||||||
* null
|
* null
|
||||||
* )} data data
|
* )} data
|
||||||
* @param {string} msg message
|
* @param {string} msg
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const attempt: SMTPCommandCallback = (err, data, msg) => {
|
const attempt: SMTPCommandCallback = (err, data, msg) => {
|
||||||
|
@ -847,12 +847,12 @@ export class SMTPConnection extends EventEmitter {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Error | SMTPError | null} err err
|
* @param {Error | SMTPError | null} err
|
||||||
* @param {(
|
* @param {(
|
||||||
* string |
|
* string |
|
||||||
* { code: (string | number), data: string, message: string } |
|
* { code: (string | number), data: string, message: string } |
|
||||||
* null
|
* null
|
||||||
* )} [data] data
|
* )} [data]
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const attemptUser: SMTPCommandCallback = (err, data) => {
|
const attemptUser: SMTPCommandCallback = (err, data) => {
|
||||||
|
@ -908,7 +908,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {boolean} [force=false] whether or not to force destroy the connection
|
* @param {boolean} [force=false]
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public close(force = false) {
|
public close(force = false) {
|
||||||
|
@ -936,7 +936,7 @@ export class SMTPConnection extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {SMTPCommandCallback} [callback] function to call after response
|
* @param {SMTPCommandCallback} [callback]
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public quit(callback?: SMTPCommandCallback) {
|
public quit(callback?: SMTPCommandCallback) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ const rfc2822re =
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} date a string to check for conformance to the [rfc2822](https://tools.ietf.org/html/rfc2822#section-3.3) standard
|
* @param {string} date a string to check for conformance to the [rfc2822](https://tools.ietf.org/html/rfc2822#section-3.3) standard
|
||||||
* @returns {boolean} the result of the conformance check
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
export function isRFC2822Date(date: string) {
|
export function isRFC2822Date(date: string) {
|
||||||
return rfc2822re.test(date);
|
return rfc2822re.test(date);
|
||||||
|
|
|
@ -22,7 +22,7 @@ export class SMTPError extends Error {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {string} message error message
|
* @param {string} message
|
||||||
*/
|
*/
|
||||||
protected constructor(message: string) {
|
protected constructor(message: string) {
|
||||||
super(message);
|
super(message);
|
||||||
|
@ -30,11 +30,11 @@ export class SMTPError extends Error {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {string} message error message
|
* @param {string} message
|
||||||
* @param {number} code smtp error state
|
* @param {number} code smtp error state
|
||||||
* @param {Error | null} [error] previous error
|
* @param {Error | null} [error] previous error
|
||||||
* @param {unknown} [smtp] arbitrary data
|
* @param {unknown} [smtp] arbitrary data
|
||||||
* @returns {SMTPError} error
|
* @returns {SMTPError}
|
||||||
*/
|
*/
|
||||||
public static create(
|
public static create(
|
||||||
message: string,
|
message: string,
|
||||||
|
|
|
@ -135,7 +135,7 @@ export class Message {
|
||||||
* - You can also add whatever other headers you want.
|
* - You can also add whatever other headers you want.
|
||||||
*
|
*
|
||||||
* @see https://tools.ietf.org/html/rfc2822
|
* @see https://tools.ietf.org/html/rfc2822
|
||||||
* @param {Partial<MessageHeaders>} headers Message headers
|
* @param {Partial<MessageHeaders>} headers
|
||||||
*/
|
*/
|
||||||
constructor(headers: Partial<MessageHeaders> = {}) {
|
constructor(headers: Partial<MessageHeaders> = {}) {
|
||||||
for (const header in headers) {
|
for (const header in headers) {
|
||||||
|
@ -175,7 +175,7 @@ export class Message {
|
||||||
* Can be called multiple times, each adding a new attachment.
|
* Can be called multiple times, each adding a new attachment.
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
* @param {MessageAttachment} options attachment options
|
* @param {MessageAttachment} options
|
||||||
* @returns {Message} the current instance for chaining
|
* @returns {Message} the current instance for chaining
|
||||||
*/
|
*/
|
||||||
public attach(options: MessageAttachment) {
|
public attach(options: MessageAttachment) {
|
||||||
|
@ -257,7 +257,7 @@ export class Message {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @param {function(Error, string): void} callback the function to call with the error and buffer
|
* @param {function(Error, string): void} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public read(callback: (err: Error, buffer: string) => void) {
|
public read(callback: (err: Error, buffer: string) => void) {
|
||||||
|
@ -270,7 +270,7 @@ export class Message {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* @returns {Promise<string>} promise that resolves to the read result
|
* @returns {Promise<string>}
|
||||||
*/
|
*/
|
||||||
public readAsync() {
|
public readAsync() {
|
||||||
return new Promise<string>((resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
|
@ -293,13 +293,13 @@ class MessageStream extends Stream {
|
||||||
readable = true;
|
readable = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Message} message the message to stream
|
* @param {Message} message
|
||||||
*/
|
*/
|
||||||
constructor(private message: Message) {
|
constructor(private message: Message) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} data the data to output
|
* @param {string} data
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const output = (data: string) => {
|
const output = (data: string) => {
|
||||||
|
@ -351,7 +351,7 @@ class MessageStream extends Stream {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {MessageAttachment} attachment the attachment whose headers you would like to output
|
* @param {MessageAttachment} attachment
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const outputAttachmentHeaders = (attachment: MessageAttachment) => {
|
const outputAttachmentHeaders = (attachment: MessageAttachment) => {
|
||||||
|
@ -389,8 +389,8 @@ class MessageStream extends Stream {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} data the data to output as base64
|
* @param {string} data
|
||||||
* @param {function(): void} [callback] the function to call after output is finished
|
* @param {function(): void} [callback]
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const outputBase64 = (data: string, callback?: () => void) => {
|
const outputBase64 = (data: string, callback?: () => void) => {
|
||||||
|
@ -406,8 +406,8 @@ class MessageStream extends Stream {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {MessageAttachment} attachment attachment
|
* @param {MessageAttachment} attachment
|
||||||
* @param {function((NodeJS.ErrnoException | null)): void} next next
|
* @param {function((NodeJS.ErrnoException | null)): void} next
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const outputFile = (
|
const outputFile = (
|
||||||
|
@ -427,7 +427,7 @@ class MessageStream extends Stream {
|
||||||
: inputEncoding;
|
: inputEncoding;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {NodeJS.ErrnoException | null} err the error to emit
|
* @param {NodeJS.ErrnoException | null} err
|
||||||
* @param {number} fd the file descriptor
|
* @param {number} fd the file descriptor
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
@ -467,8 +467,8 @@ class MessageStream extends Stream {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {MessageAttachment} attachment the metadata to use as headers
|
* @param {MessageAttachment} attachment
|
||||||
* @param {function(): void} callback the function to call after output is finished
|
* @param {function(): void} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const outputStream = (
|
const outputStream = (
|
||||||
|
@ -516,8 +516,8 @@ class MessageStream extends Stream {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {MessageAttachment} attachment attachment
|
* @param {MessageAttachment} attachment
|
||||||
* @param {function(): void} callback the function to call
|
* @param {function(): void} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const outputAttachment = (
|
const outputAttachment = (
|
||||||
|
@ -585,8 +585,8 @@ class MessageStream extends Stream {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {MessageAttachment} attachment the metadata to use as headers
|
* @param {MessageAttachment} attachment
|
||||||
* @param {function(): void} callback the function to call after output is finished
|
* @param {function(): void} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const outputData = (
|
const outputData = (
|
||||||
|
@ -602,7 +602,7 @@ class MessageStream extends Stream {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Message} message the message to output
|
* @param {Message} message
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const outputText = (message: Message) => {
|
const outputText = (message: Message) => {
|
||||||
|
@ -622,8 +622,8 @@ class MessageStream extends Stream {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {MessageAttachment} message the message to output
|
* @param {MessageAttachment} message
|
||||||
* @param {function(): void} callback the function to call after output is finished
|
* @param {function(): void} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const outputRelated = (
|
const outputRelated = (
|
||||||
|
@ -643,8 +643,8 @@ class MessageStream extends Stream {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Message} message the message to output
|
* @param {Message} message
|
||||||
* @param {function(): void} callback the function to call after output is finished
|
* @param {function(): void} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const outputAlternative = (message: Message, callback: () => void) => {
|
const outputAlternative = (message: Message, callback: () => void) => {
|
||||||
|
@ -678,7 +678,7 @@ class MessageStream extends Stream {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Error} [err] err
|
* @param {Error} [err]
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const close = (err?: Error) => {
|
const close = (err?: Error) => {
|
||||||
|
@ -746,7 +746,7 @@ class MessageStream extends Stream {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* pause the stream
|
* @description pause the stream
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public pause() {
|
public pause() {
|
||||||
|
@ -756,7 +756,7 @@ class MessageStream extends Stream {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* resume the stream
|
* @description resume the stream
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public resume() {
|
public resume() {
|
||||||
|
@ -766,7 +766,7 @@ class MessageStream extends Stream {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* destroy the stream
|
* @description destroy the stream
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public destroy() {
|
public destroy() {
|
||||||
|
@ -778,7 +778,7 @@ class MessageStream extends Stream {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* destroy the stream at first opportunity
|
* @description destroy the stream at first opportunity
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public destroySoon() {
|
public destroySoon() {
|
||||||
|
|
|
@ -3,9 +3,7 @@ import { TextDecoder, TextEncoder } from 'util';
|
||||||
|
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
|
|
||||||
/**
|
/** @see https://tools.ietf.org/html/rfc2045#section-6.7 */
|
||||||
* @see https://tools.ietf.org/html/rfc2045#section-6.7
|
|
||||||
*/
|
|
||||||
const RANGES = [
|
const RANGES = [
|
||||||
[0x09], // <TAB>
|
[0x09], // <TAB>
|
||||||
[0x0a], // <LF>
|
[0x0a], // <LF>
|
||||||
|
@ -114,8 +112,7 @@ function splitMimeEncodedString(str: string, maxlen = 12) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param {number} nr
|
||||||
* @param {number} nr number
|
|
||||||
* @returns {boolean} if number is in range
|
* @returns {boolean} if number is in range
|
||||||
*/
|
*/
|
||||||
function checkRanges(nr: number) {
|
function checkRanges(nr: number) {
|
||||||
|
|
Loading…
Reference in New Issue