Merge pull request #23393 from hoo29/master

[node] tidied up and de-duplicated tls related options
This commit is contained in:
Daniel Rosenwasser
2018-02-10 10:34:57 -08:00
committed by GitHub
12 changed files with 104 additions and 154 deletions
+1 -1
View File
@@ -75,7 +75,7 @@ export interface FtpServerOptions {
/**
* If this is set, the server will allow explicit TLS authentication. Value should be a dictionary which is suitable as the options argument of tls.createServer.
*/
tlsOptions?: tls.TlsOptions;
tlsOptions?: tls.TlsServerOptions;
/**
* If this is set to true, and tlsOptions is also set, then the server will not allow logins over non-secure connections.
* Default false
+1 -1
View File
@@ -43,7 +43,7 @@ declare namespace proxy {
target?: string;
forward?: string;
agent?: http.Agent;
ssl?: tls.TlsOptions;
ssl?: tls.TlsServerOptions;
ws?: boolean;
xfwd?: boolean;
secure?: boolean;
+31 -56
View File
@@ -18,6 +18,7 @@
// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
// Alberto Schiabel <https://github.com/jkomyno>
// Klaus Meinhardt <https://github.com/ajafff>
// Huw <https://github.com/hoo29>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/** inspector module types */
@@ -113,7 +114,7 @@ declare function clearImmediate(immediateId: any): void;
// TODO: change to `type NodeRequireFunction = (id: string) => any;` in next mayor version.
interface NodeRequireFunction {
/* tslint:disable-next-line:callable-types */
/* tslint:disable-next-line:callable-types */
(id: string): any;
}
@@ -1745,33 +1746,20 @@ declare module "https" {
import * as http from "http";
import { URL } from "url";
export interface ServerOptions {
pfx?: any;
key?: any;
passphrase?: string;
cert?: any;
ca?: any;
crl?: any;
ciphers?: string;
honorCipherOrder?: boolean;
requestCert?: boolean;
rejectUnauthorized?: boolean;
NPNProtocols?: any;
SNICallback?: (servername: string, cb: (err: Error | null, ctx: tls.SecureContext) => void) => void;
secureProtocol?: string;
}
export type ServerOptions = tls.SecureContextOptions & tls.TlsServerOptions;
export interface RequestOptions extends http.RequestOptions {
pfx?: any;
key?: any;
export type RequestOptions = http.RequestOptions & {
rejectUnauthorized?: boolean; // Defaults to true
servername?: string; // SNI TLS Extension
pfx?: string | Buffer | Array<string | Buffer | Object>;
key?: string | Buffer | Array<Buffer | Object>;
passphrase?: string;
cert?: any;
ca?: any;
cert?: string | Buffer | Array<string | Buffer>;
ca?: string | Buffer | Array<string | Buffer>;
ciphers?: string;
rejectUnauthorized?: boolean;
secureProtocol?: string;
servername?: string;
}
clientCertEngine?: string;
secureProtocol?: string; // SSL Method, e.g. SSLv23_method
};
export interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
rejectUnauthorized?: boolean;
@@ -4844,7 +4832,7 @@ declare module "tls" {
* An array of strings or a Buffer naming possible NPN protocols.
* (Protocols should be ordered by their priority.)
*/
NPNProtocols?: string[] | Buffer,
NPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array,
/**
* An array of strings or a Buffer naming possible ALPN protocols.
* (Protocols should be ordered by their priority.) When the server
@@ -4852,7 +4840,7 @@ declare module "tls" {
* precedence over NPN and the server does not send an NPN extension
* to the client.
*/
ALPNProtocols?: string[] | Buffer,
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array,
/**
* SNICallback(servername, cb) <Function> A function that will be
* called if the client supports SNI TLS extension. Two arguments
@@ -4928,7 +4916,7 @@ declare module "tls" {
* @param callback - callback(err) will be executed with null as err, once the renegotiation
* is successfully completed.
*/
renegotiate(options: TlsOptions, callback: (err: Error | null) => void): any;
renegotiate(options: { rejectUnauthorized?: boolean, requestCert?: boolean }, callback: (err: Error | null) => void): any;
/**
* Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512).
* Smaller fragment size decreases buffering latency on the client: large fragments are buffered by
@@ -4971,30 +4959,16 @@ declare module "tls" {
prependOnceListener(event: "secureConnect", listener: () => void): this;
}
export interface TlsOptions {
host?: string;
port?: number;
pfx?: string | Buffer[];
key?: string | string[] | Buffer | any[];
passphrase?: string;
cert?: string | string[] | Buffer | Buffer[];
ca?: string | string[] | Buffer | Buffer[];
crl?: string | string[];
ciphers?: string;
honorCipherOrder?: boolean;
export interface TlsServerOptions extends SecureContextOptions {
clientCertEngine?: string;
handshakeTimeout?: number;
requestCert?: boolean;
rejectUnauthorized?: boolean;
NPNProtocols?: string[] | Buffer;
NPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
SNICallback?: (servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void;
ecdhCurve?: string;
dhparam?: string | Buffer;
handshakeTimeout?: number;
ALPNProtocols?: string[] | Buffer;
sessionTimeout?: number;
ticketKeys?: Buffer;
sessionIdContext?: string;
secureProtocol?: string;
secureOptions?: number;
}
export interface ConnectionOptions extends SecureContextOptions {
@@ -5003,8 +4977,8 @@ declare module "tls" {
path?: string; // Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored.
socket?: net.Socket; // Establish secure connection on a given socket rather than creating a new socket
rejectUnauthorized?: boolean; // Defaults to true
NPNProtocols?: Array<string | Buffer>;
ALPNProtocols?: Array<string | Buffer>;
NPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
checkServerIdentity?: typeof checkServerIdentity;
servername?: string; // SNI TLS Extension
session?: Buffer;
@@ -5102,6 +5076,7 @@ declare module "tls" {
ciphers?: string;
honorCipherOrder?: boolean;
ecdhCurve?: string;
clientCertEngine?: string;
crl?: string | Buffer | Array<string | Buffer>;
dhparam?: string | Buffer;
secureOptions?: number; // Value is a numeric bitmask of the `SSL_OP_*` options
@@ -5121,7 +5096,7 @@ declare module "tls" {
* Returns Error object, populating it with the reason, host and cert on failure. On success, returns undefined.
*/
export function checkServerIdentity(host: string, cert: PeerCertificate): Error | undefined;
export function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server;
export function createServer(options: TlsServerOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server;
export function connect(options: ConnectionOptions, secureConnectionListener?: () => void): TLSSocket;
export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
@@ -5405,7 +5380,7 @@ declare module "stream" {
readonly writableLength: number;
constructor(opts?: WritableOptions);
_write(chunk: any, encoding: string, callback: (err?: Error) => void): void;
_writev?(chunks: Array<{chunk: any, encoding: string}>, callback: (err?: Error) => void): void;
_writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (err?: Error) => void): void;
_destroy(err: Error, callback: Function): void;
_final(callback: Function): void;
write(chunk: any, cb?: Function): boolean;
@@ -5498,7 +5473,7 @@ declare module "stream" {
readonly writableLength: number;
constructor(opts?: DuplexOptions);
_write(chunk: any, encoding: string, callback: (err?: Error) => void): void;
_writev?(chunks: Array<{chunk: any, encoding: string}>, callback: (err?: Error) => void): void;
_writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (err?: Error) => void): void;
_destroy(err: Error, callback: Function): void;
_final(callback: Function): void;
write(chunk: any, cb?: Function): boolean;
@@ -5578,9 +5553,9 @@ declare module "util" {
export function callbackify<T1, T2>(fn: (arg1: T1, arg2: T2) => Promise<void>): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2) => Promise<TResult>): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, T3, T4, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, T4, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, T4, T5>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, T3, T4, T5, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, T4, T5, T6>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException) => void) => void;
@@ -6173,7 +6148,7 @@ declare module "http2" {
}
export interface ServerStreamFileResponseOptions {
statCheck?: (stats: fs.Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions) => void|boolean;
statCheck?: (stats: fs.Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions) => void | boolean;
getTrailers?: (trailers: OutgoingHttpHeaders) => void;
offset?: number;
length?: number;
@@ -6519,7 +6494,7 @@ declare module "http2" {
export type ServerSessionOptions = SessionOptions;
export interface SecureClientSessionOptions extends ClientSessionOptions, tls.ConnectionOptions { }
export interface SecureServerSessionOptions extends ServerSessionOptions, tls.TlsOptions { }
export interface SecureServerSessionOptions extends ServerSessionOptions, tls.TlsServerOptions { }
export interface ServerOptions extends ServerSessionOptions {
allowHTTP1?: boolean;
+1 -1
View File
@@ -22,4 +22,4 @@
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
}
}
}
+32 -58
View File
@@ -17,7 +17,9 @@
// Sebastian Silbermann <https://github.com/eps1lon>
// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
// Alberto Schiabel <https://github.com/jkomyno>
// Huw <https://github.com/hoo29>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/** inspector module types */
/// <reference path="./inspector.d.ts" />
@@ -111,7 +113,7 @@ declare function clearImmediate(immediateId: any): void;
// TODO: change to `type NodeRequireFunction = (id: string) => any;` in next mayor version.
interface NodeRequireFunction {
/* tslint:disable-next-line:callable-types */
/* tslint:disable-next-line:callable-types */
(id: string): any;
}
@@ -1733,33 +1735,20 @@ declare module "https" {
import * as http from "http";
import { URL } from "url";
export interface ServerOptions {
pfx?: any;
key?: any;
passphrase?: string;
cert?: any;
ca?: any;
crl?: any;
ciphers?: string;
honorCipherOrder?: boolean;
requestCert?: boolean;
rejectUnauthorized?: boolean;
NPNProtocols?: any;
SNICallback?: (servername: string, cb: (err: Error | null, ctx: tls.SecureContext) => void) => void;
secureProtocol?: string;
}
export type ServerOptions = tls.SecureContextOptions & tls.TlsServerOptions;
export interface RequestOptions extends http.RequestOptions {
pfx?: any;
key?: any;
passphrase?: string;
cert?: any;
ca?: any;
ciphers?: string;
rejectUnauthorized?: boolean;
secureProtocol?: string;
servername?: string;
}
// see https://nodejs.org/docs/latest-v8.x/api/https.html#https_https_request_options_callback
type extendedRequestKeys = "pfx" |
"key" |
"passphrase" |
"cert" |
"ca" |
"ciphers" |
"rejectUnauthorized" |
"secureProtocol" |
"servername";
export type RequestOptions = http.RequestOptions & Pick<tls.ConnectionOptions, extendedRequestKeys>;
export interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
rejectUnauthorized?: boolean;
@@ -4821,7 +4810,7 @@ declare module "tls" {
* An array of strings or a Buffer naming possible NPN protocols.
* (Protocols should be ordered by their priority.)
*/
NPNProtocols?: string[] | Buffer,
NPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array,
/**
* An array of strings or a Buffer naming possible ALPN protocols.
* (Protocols should be ordered by their priority.) When the server
@@ -4829,7 +4818,7 @@ declare module "tls" {
* precedence over NPN and the server does not send an NPN extension
* to the client.
*/
ALPNProtocols?: string[] | Buffer,
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array,
/**
* SNICallback(servername, cb) <Function> A function that will be
* called if the client supports SNI TLS extension. Two arguments
@@ -4905,7 +4894,7 @@ declare module "tls" {
* @param callback - callback(err) will be executed with null as err, once the renegotiation
* is successfully completed.
*/
renegotiate(options: TlsOptions, callback: (err: Error | null) => void): any;
renegotiate(options: { rejectUnauthorized?: boolean, requestCert?: boolean }, callback: (err: Error | null) => void): any;
/**
* Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512).
* Smaller fragment size decreases buffering latency on the client: large fragments are buffered by
@@ -4948,30 +4937,15 @@ declare module "tls" {
prependOnceListener(event: "secureConnect", listener: () => void): this;
}
export interface TlsOptions {
host?: string;
port?: number;
pfx?: string | Buffer[];
key?: string | string[] | Buffer | any[];
passphrase?: string;
cert?: string | string[] | Buffer | Buffer[];
ca?: string | string[] | Buffer | Buffer[];
crl?: string | string[];
ciphers?: string;
honorCipherOrder?: boolean;
export interface TlsServerOptions extends SecureContextOptions {
handshakeTimeout?: number;
requestCert?: boolean;
rejectUnauthorized?: boolean;
NPNProtocols?: string[] | Buffer;
NPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
SNICallback?: (servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void;
ecdhCurve?: string;
dhparam?: string | Buffer;
handshakeTimeout?: number;
ALPNProtocols?: string[] | Buffer;
sessionTimeout?: number;
ticketKeys?: Buffer;
sessionIdContext?: string;
secureProtocol?: string;
secureOptions?: number;
}
export interface ConnectionOptions extends SecureContextOptions {
@@ -4980,8 +4954,8 @@ declare module "tls" {
path?: string; // Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored.
socket?: net.Socket; // Establish secure connection on a given socket rather than creating a new socket
rejectUnauthorized?: boolean; // Defaults to true
NPNProtocols?: Array<string | Buffer>;
ALPNProtocols?: Array<string | Buffer>;
NPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
checkServerIdentity?: typeof checkServerIdentity;
servername?: string; // SNI TLS Extension
session?: Buffer;
@@ -5098,7 +5072,7 @@ declare module "tls" {
* Returns Error object, populating it with the reason, host and cert on failure. On success, returns undefined.
*/
export function checkServerIdentity(host: string, cert: PeerCertificate): Error | undefined;
export function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server;
export function createServer(options: TlsServerOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server;
export function connect(options: ConnectionOptions, secureConnectionListener?: () => void): TLSSocket;
export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
@@ -5378,7 +5352,7 @@ declare module "stream" {
writable: boolean;
constructor(opts?: WritableOptions);
_write(chunk: any, encoding: string, callback: (err?: Error) => void): void;
_writev?(chunks: Array<{chunk: any, encoding: string}>, callback: (err?: Error) => void): void;
_writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (err?: Error) => void): void;
_destroy(err: Error, callback: Function): void;
_final(callback: Function): void;
write(chunk: any, cb?: Function): boolean;
@@ -5469,7 +5443,7 @@ declare module "stream" {
writable: boolean;
constructor(opts?: DuplexOptions);
_write(chunk: any, encoding: string, callback: (err?: Error) => void): void;
_writev?(chunks: Array<{chunk: any, encoding: string}>, callback: (err?: Error) => void): void;
_writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (err?: Error) => void): void;
_destroy(err: Error, callback: Function): void;
_final(callback: Function): void;
write(chunk: any, cb?: Function): boolean;
@@ -5549,9 +5523,9 @@ declare module "util" {
export function callbackify<T1, T2>(fn: (arg1: T1, arg2: T2) => Promise<void>): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2) => Promise<TResult>): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, T3, T4, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, T4, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, T4, T5>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void;
export function callbackify<T1, T2, T3, T4, T5, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function callbackify<T1, T2, T3, T4, T5, T6>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException) => void) => void;
@@ -6146,7 +6120,7 @@ declare module "http2" {
}
export interface ServerStreamFileResponseOptions {
statCheck?: (stats: fs.Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions) => void|boolean;
statCheck?: (stats: fs.Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions) => void | boolean;
getTrailers?: (trailers: OutgoingHttpHeaders) => void;
offset?: number;
length?: number;
@@ -6492,7 +6466,7 @@ declare module "http2" {
export type ServerSessionOptions = SessionOptions;
export interface SecureClientSessionOptions extends ClientSessionOptions, tls.ConnectionOptions { }
export interface SecureServerSessionOptions extends ServerSessionOptions, tls.TlsOptions { }
export interface SecureServerSessionOptions extends ServerSessionOptions, tls.TlsServerOptions { }
export interface ServerOptions extends ServerSessionOptions {
allowHTTP1?: boolean;
+1 -1
View File
@@ -21,7 +21,7 @@ declare namespace fetch {
userAgent?: string;
body?: Buffer | string | { [key: string]: string };
contentType?: string | false;
tls?: tls.TlsOptions;
tls?: tls.TlsServerOptions;
timeout?: ms;
allowErrorResponse?: boolean;
}
+9 -9
View File
@@ -26,21 +26,21 @@ export interface Defaults extends ConnectionConfig {
parseInt8?: boolean;
}
import { TlsOptions } from "tls";
import { TlsServerOptions } from "tls";
export interface ClientConfig extends ConnectionConfig {
ssl?: boolean | TlsOptions;
ssl?: boolean | TlsServerOptions;
}
export interface PoolConfig extends ClientConfig {
// properties from module 'node-pool'
max?: number;
min?: number;
connectionTimeoutMillis?: number;
idleTimeoutMillis?: number;
// properties from module 'node-pool'
max?: number;
min?: number;
connectionTimeoutMillis?: number;
idleTimeoutMillis?: number;
application_name?: string;
Promise?: PromiseConstructorLike;
application_name?: string;
Promise?: PromiseConstructorLike;
}
export interface QueryConfig {
+11 -11
View File
@@ -29,22 +29,22 @@ export interface Defaults extends ConnectionConfig {
parseInt8?: boolean;
}
import { TlsOptions } from "tls";
import { TlsServerOptions } from "tls";
export interface ClientConfig extends ConnectionConfig {
ssl?: boolean | TlsOptions;
ssl?: boolean | TlsServerOptions;
}
export interface PoolConfig extends ClientConfig {
// properties from module 'node-pool'
max?: number;
min?: number;
refreshIdle?: boolean;
idleTimeoutMillis?: number;
reapIntervalMillis?: number;
returnToHead?: boolean;
application_name?: string;
Promise?: PromiseConstructorLike;
// properties from module 'node-pool'
max?: number;
min?: number;
refreshIdle?: boolean;
idleTimeoutMillis?: number;
reapIntervalMillis?: number;
returnToHead?: boolean;
application_name?: string;
Promise?: PromiseConstructorLike;
}
export interface QueryConfig {
+4 -4
View File
@@ -93,7 +93,7 @@ export interface SMTPServerSession {
envelope: SMTPServerEnvelope;
transmissionType: string;
tlsOptions: tls.TlsOptions;
tlsOptions: tls.TlsServerOptions;
}
export interface SMTPServerEnvelope {
@@ -107,7 +107,7 @@ export interface SMTPServerEnvelope {
rcptTo: SMTPServerAddress[];
}
export interface SMTPServerOptions extends tls.TlsOptions {
export interface SMTPServerOptions extends tls.TlsServerOptions {
/**
* if true, the connection will use TLS. The default is false.
* If the server doesn't start in TLS mode,
@@ -188,7 +188,7 @@ export interface SMTPServerOptions extends tls.TlsOptions {
/**
* optional Map or an object of TLS options for SNI where servername is the key. Overrided by SNICallback.
*/
sniOptions?: { [servername: string]: tls.TlsOptions } | Map<string, tls.TlsOptions>;
sniOptions?: { [servername: string]: tls.TlsServerOptions } | Map<string, tls.TlsServerOptions>;
/**
* optional boolean, if set to true then upgrade sockets to TLS immediately after connection is established. Works with secure: true
*/
@@ -282,7 +282,7 @@ export class SMTPServer extends EventEmitter {
/** Closes the server */
close(callback: (err?: Error | null) => void): void;
updateSecureContext(options: tls.TlsOptions): void;
updateSecureContext(options: tls.TlsServerOptions): void;
/** Authentication handler. Override this */
onAuth(auth: SMTPServerAuthentication, session: SMTPServerSession, callback: (err: Error | null | undefined, response: SMTPServerAuthenticationResponse) => void): void;
+3 -2
View File
@@ -8,9 +8,10 @@ const options: SMTPServerOptions = {
onRcptTo,
onData,
onClose,
port: 2525
};
const port = 2525;
function onConnect(session: SMTPServerSession, callback: (err?: Error) => void): void {
console.log(`[${session.id}] onConnect`);
callback();
@@ -69,7 +70,7 @@ server.on('close', () => {
console.log('Server closed');
});
server.listen(options.port, () => {
server.listen(port, () => {
const address = server.server.address();
console.log(`Listening on [${address.address}]:${address.port}`);
});
+8 -8
View File
@@ -227,7 +227,7 @@ export interface ServiceMap<TProcessor, THandler> {
export interface ServiceOptions<TProcessor, THandler> {
transport?: TTransportConstructor;
protocol?: TProtocolConstructor;
processor?: { new (handler: THandler): TProcessor };
processor?: { new(handler: THandler): TProcessor };
handler?: THandler;
}
@@ -236,7 +236,7 @@ export interface ServerOptions<TProcessor, THandler> extends ServiceOptions<TPro
files?: string;
headers?: HttpHeaders;
services?: ServiceMap<TProcessor, THandler>;
tls?: tls.TlsOptions;
tls?: tls.TlsServerOptions;
}
export interface ConnectOptions {
@@ -263,12 +263,12 @@ export interface WSConnectOptions {
}
export type TClientConstructor<TClient> =
{ new (output: TTransport, pClass: { new (trans: TTransport): TProtocol }): TClient; } |
{ Client: { new (output: TTransport, pClass: { new (trans: TTransport): TProtocol }): TClient; } };
{ new(output: TTransport, pClass: { new(trans: TTransport): TProtocol }): TClient; } |
{ Client: { new(output: TTransport, pClass: { new(trans: TTransport): TProtocol }): TClient; } };
export type TProcessorConstructor<TProcessor, THandler> =
{ new (handler: THandler): TProcessor } |
{ Processor: { new (handler: THandler): TProcessor }};
{ new(handler: THandler): TProcessor } |
{ Processor: { new(handler: THandler): TProcessor } };
export interface WebServerOptions<TProcessor, THandler> {
services: {
@@ -361,7 +361,7 @@ export class TFramedTransport implements TTransport {
}
export interface TTransportConstructor {
new (buffer?: Buffer, callback?: TTransportCallback): TTransport;
new(buffer?: Buffer, callback?: TTransportCallback): TTransport;
}
export class TBinaryProtocol implements TProtocol {
@@ -509,7 +509,7 @@ export class TCompactProtocol implements TProtocol {
}
export interface TProtocolConstructor {
new (trans: TTransport, strictRead?: boolean, strictWrite?: boolean): TProtocol;
new(trans: TTransport, strictRead?: boolean, strictWrite?: boolean): TProtocol;
}
// thrift.js
+2 -2
View File
@@ -9,7 +9,7 @@ declare module 'xmlrpc' {
import { EventEmitter } from 'events';
import { Server as HttpServer } from 'http';
import { Server as HttpsServer } from 'https';
import { TlsOptions } from 'tls';
import { TlsServerOptions } from 'tls';
interface ClientOptions {
host?: string;
@@ -47,7 +47,7 @@ declare module 'xmlrpc' {
function createSecureClient(options: string | ClientOptions): Client;
function createServer(options: string | ServerOptions, callback: () => void): Server;
function createSecureServer(options: string | TlsOptions, callback: () => void): Server;
function createSecureServer(options: string | TlsServerOptions, callback: () => void): Server;
interface Client {
options: ClientOptions;