From 673020868ed89f83fa8ca4a3b6d414583bee4451 Mon Sep 17 00:00:00 2001 From: Huw McNamara Date: Tue, 6 Feb 2018 18:55:42 +0000 Subject: [PATCH] made changes to v9 --- types/node/index.d.ts | 93 +++++++++++++++------------------------- types/node/tsconfig.json | 2 +- 2 files changed, 36 insertions(+), 59 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 38f043554b..3b12e6591e 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -18,7 +18,9 @@ // Hannes Magnusson // Alberto Schiabel // Klaus Meinhardt +// Huw // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /** inspector module types */ /// @@ -113,7 +115,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; } @@ -1740,33 +1742,21 @@ 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/dist/latest/docs/api/https.html#https_https_request_options_callback + type extendedRequestKeys = "ca" | + "cert" | + "ciphers" | + "clientCertEngine" | + "key" | + "passphrase" | + "pfx" | + "rejectUnauthorized" | + "secureProtocol" | + "servername"; + + export type RequestOptions = http.RequestOptions & Pick; export interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions { rejectUnauthorized?: boolean; @@ -4839,7 +4829,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 @@ -4847,7 +4837,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) A function that will be * called if the client supports SNI TLS extension. Two arguments @@ -4923,7 +4913,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 @@ -4966,30 +4956,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 { @@ -4998,8 +4974,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; - ALPNProtocols?: Array; + NPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array; + ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array; checkServerIdentity?: typeof checkServerIdentity; servername?: string; // SNI TLS Extension session?: Buffer; @@ -5097,6 +5073,7 @@ declare module "tls" { ciphers?: string; honorCipherOrder?: boolean; ecdhCurve?: string; + clientCertEngine?: string; crl?: string | Buffer | Array; dhparam?: string | Buffer; secureOptions?: number; // Value is a numeric bitmask of the `SSL_OP_*` options @@ -5116,7 +5093,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; @@ -5401,7 +5378,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; @@ -5494,7 +5471,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; @@ -5574,9 +5551,9 @@ declare module "util" { export function callbackify(fn: (arg1: T1, arg2: T2) => Promise): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException) => void) => void; export function callbackify(fn: (arg1: T1, arg2: T2) => Promise): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void; export function callbackify(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException) => void) => void; - export function callbackify(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void; + export function callbackify(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void; export function callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void; - export function callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void; + export function callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void; export function callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void; export function callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void; export function callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException) => void) => void; @@ -6169,7 +6146,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; @@ -6515,7 +6492,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; diff --git a/types/node/tsconfig.json b/types/node/tsconfig.json index 9f4317b9f4..81040f4013 100644 --- a/types/node/tsconfig.json +++ b/types/node/tsconfig.json @@ -21,4 +21,4 @@ "noEmit": true, "forceConsistentCasingInFileNames": true } -} \ No newline at end of file +}