smtp/connection: relax ssl/tls options passthrough

This commit is contained in:
Zack Schuster 2020-05-30 09:58:55 -07:00
parent 6dc31da7ac
commit 0781d02cbf
2 changed files with 13 additions and 9 deletions

View File

@ -165,13 +165,15 @@ const options = {
password, // password for logging into smtp
host, // smtp host (defaults to 'localhost')
port, // smtp port (defaults to 25 for unencrypted, 465 for `ssl`, and 587 for `tls`)
ssl, // boolean or object {key, ca, cert} (if true or object, ssl connection will be made)
ssl, // boolean or object (if true or object, ssl connection will be made)
tls, // boolean or object (if true or object, starttls will be initiated)
timeout, // max number of milliseconds to wait for smtp responses (defaults to 5000)
domain, // domain to greet smtp with (defaults to os.hostname)
authentication, // array of preferred authentication methods ('PLAIN', 'LOGIN', 'CRAM-MD5', 'XOAUTH2')
logger, // override the built-in logger (useful for e.g. Azure Function Apps, where console.log doesn't work)
};
// ssl/tls objects are an abbreviated form of [`tls.connect`](https://nodejs.org/dist/latest-v14.x/docs/api/tls.html#tls_tls_connect_options_callback)'s options
// the missing items are: `port`, `host`, `path`, `socket`, `timeout` and `secureContext`
// NOTE: `host` is trimmed before being used to establish a connection;
// however, the original untrimmed value will still be visible in configuration.
```
@ -240,13 +242,15 @@ const options = {
password, // password for logging into smtp
host, // smtp host (defaults to 'localhost')
port, // smtp port (defaults to 25 for unencrypted, 465 for `ssl`, and 587 for `tls`)
ssl, // boolean or object {key, ca, cert} (if true or object, ssl connection will be made)
ssl, // boolean or object (if true or object, ssl connection will be made)
tls, // boolean or object (if true or object, starttls will be initiated)
timeout, // max number of milliseconds to wait for smtp responses (defaults to 5000)
domain, // domain to greet smtp with (defaults to os.hostname)
authentication, // array of preferred authentication methods ('PLAIN', 'LOGIN', 'CRAM-MD5', 'XOAUTH2')
logger, // override the built-in logger (useful for e.g. Azure Function Apps, where console.log doesn't work)
};
// ssl/tls objects are an abbreviated form of [`tls.connect`](https://nodejs.org/dist/latest-v14.x/docs/api/tls.html#tls_tls_connect_options_callback)'s options
// the missing items are: `port`, `host`, `path`, `socket`, `timeout` and `secureContext`
// NOTE: `host` is trimmed before being used to establish a connection;
// however, the original untrimmed value will still be visible in configuration.
```

View File

@ -1,8 +1,9 @@
import { Socket } from 'net';
import { createHmac } from 'crypto';
import { EventEmitter } from 'events';
import { Socket } from 'net';
import { hostname } from 'os';
import { connect, createSecureContext, TLSSocket } from 'tls';
import { EventEmitter } from 'events';
import type { ConnectionOptions } from 'tls';
import { SMTPError, SMTPErrorStates } from './error';
import { SMTPResponseMonitor } from './response';
@ -66,11 +67,10 @@ const caller = (callback?: (...rest: any[]) => void, ...args: any[]) => {
}
};
export interface SMTPSocketOptions {
key: string;
ca: string;
cert: string;
}
export type SMTPSocketOptions = Omit<
ConnectionOptions,
'port' | 'host' | 'path' | 'socket' | 'timeout' | 'secureContext'
>;
export interface SMTPConnectionOptions {
timeout: number | null;