Project

General

Profile

1
// Generated by typings
2
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/4008a51db44dabcdc368097a39a01ab7a5f9587f/node/node.d.ts
3
interface Error {
4
    stack?: string;
5
}
6

    
7
interface ErrorConstructor {
8
    captureStackTrace(targetObject: Object, constructorOpt?: Function): void;
9
    stackTraceLimit: number;
10
}
11

    
12
// compat for TypeScript 1.8
13
// if you use with --target es3 or --target es5 and use below definitions,
14
// use the lib.es6.d.ts that is bundled with TypeScript 1.8.
15
interface MapConstructor { }
16
interface WeakMapConstructor { }
17
interface SetConstructor { }
18
interface WeakSetConstructor { }
19

    
20
/************************************************
21
*                                               *
22
*                   GLOBAL                      *
23
*                                               *
24
************************************************/
25
declare var process: NodeJS.Process;
26
declare var global: NodeJS.Global;
27

    
28
declare var __filename: string;
29
declare var __dirname: string;
30

    
31
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
32
declare function clearTimeout(timeoutId: NodeJS.Timer): void;
33
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
34
declare function clearInterval(intervalId: NodeJS.Timer): void;
35
declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
36
declare function clearImmediate(immediateId: any): void;
37

    
38
interface NodeRequireFunction {
39
    (id: string): any;
40
}
41

    
42
interface NodeRequire extends NodeRequireFunction {
43
    resolve(id: string): string;
44
    cache: any;
45
    extensions: any;
46
    main: any;
47
}
48

    
49
declare var require: NodeRequire;
50

    
51
interface NodeModule {
52
    exports: any;
53
    require: NodeRequireFunction;
54
    id: string;
55
    filename: string;
56
    loaded: boolean;
57
    parent: any;
58
    children: any[];
59
}
60

    
61
declare var module: NodeModule;
62

    
63
// Same as module.exports
64
declare var exports: any;
65
declare var SlowBuffer: {
66
    new (str: string, encoding?: string): Buffer;
67
    new (size: number): Buffer;
68
    new (size: Uint8Array): Buffer;
69
    new (array: any[]): Buffer;
70
    prototype: Buffer;
71
    isBuffer(obj: any): boolean;
72
    byteLength(string: string, encoding?: string): number;
73
    concat(list: Buffer[], totalLength?: number): Buffer;
74
};
75

    
76

    
77
// Buffer class
78
type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "binary" | "hex";
79
interface Buffer extends NodeBuffer { }
80

    
81
/**
82
 * Raw data is stored in instances of the Buffer class.
83
 * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap.  A Buffer cannot be resized.
84
 * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
85
 */
86
declare var Buffer: {
87
    /**
88
     * Allocates a new buffer containing the given {str}.
89
     *
90
     * @param str String to store in buffer.
91
     * @param encoding encoding to use, optional.  Default is 'utf8'
92
     */
93
    new (str: string, encoding?: string): Buffer;
94
    /**
95
     * Allocates a new buffer of {size} octets.
96
     *
97
     * @param size count of octets to allocate.
98
     */
99
    new (size: number): Buffer;
100
    /**
101
     * Allocates a new buffer containing the given {array} of octets.
102
     *
103
     * @param array The octets to store.
104
     */
105
    new (array: Uint8Array): Buffer;
106
    /**
107
     * Produces a Buffer backed by the same allocated memory as
108
     * the given {ArrayBuffer}.
109
     *
110
     *
111
     * @param arrayBuffer The ArrayBuffer with which to share memory.
112
     */
113
    new (arrayBuffer: ArrayBuffer): Buffer;
114
    /**
115
     * Allocates a new buffer containing the given {array} of octets.
116
     *
117
     * @param array The octets to store.
118
     */
119
    new (array: any[]): Buffer;
120
    /**
121
     * Copies the passed {buffer} data onto a new {Buffer} instance.
122
     *
123
     * @param buffer The buffer to copy.
124
     */
125
    new (buffer: Buffer): Buffer;
126
    prototype: Buffer;
127
    /**
128
     * Allocates a new Buffer using an {array} of octets.
129
     *
130
     * @param array
131
     */
132
    from(array: any[]): Buffer;
133
    /**
134
     * When passed a reference to the .buffer property of a TypedArray instance,
135
     * the newly created Buffer will share the same allocated memory as the TypedArray.
136
     * The optional {byteOffset} and {length} arguments specify a memory range
137
     * within the {arrayBuffer} that will be shared by the Buffer.
138
     *
139
     * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
140
     * @param byteOffset
141
     * @param length
142
     */
143
    from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
144
    /**
145
     * Copies the passed {buffer} data onto a new Buffer instance.
146
     *
147
     * @param buffer
148
     */
149
    from(buffer: Buffer): Buffer;
150
    /**
151
     * Creates a new Buffer containing the given JavaScript string {str}.
152
     * If provided, the {encoding} parameter identifies the character encoding.
153
     * If not provided, {encoding} defaults to 'utf8'.
154
     *
155
     * @param str
156
     */
157
    from(str: string, encoding?: string): Buffer;
158
    /**
159
     * Returns true if {obj} is a Buffer
160
     *
161
     * @param obj object to test.
162
     */
163
    isBuffer(obj: any): obj is Buffer;
164
    /**
165
     * Returns true if {encoding} is a valid encoding argument.
166
     * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
167
     *
168
     * @param encoding string to test.
169
     */
170
    isEncoding(encoding: string): boolean;
171
    /**
172
     * Gives the actual byte length of a string. encoding defaults to 'utf8'.
173
     * This is not the same as String.prototype.length since that returns the number of characters in a string.
174
     *
175
     * @param string string to test.
176
     * @param encoding encoding used to evaluate (defaults to 'utf8')
177
     */
178
    byteLength(string: string, encoding?: string): number;
179
    /**
180
     * Returns a buffer which is the result of concatenating all the buffers in the list together.
181
     *
182
     * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
183
     * If the list has exactly one item, then the first item of the list is returned.
184
     * If the list has more than one item, then a new Buffer is created.
185
     *
186
     * @param list An array of Buffer objects to concatenate
187
     * @param totalLength Total length of the buffers when concatenated.
188
     *   If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
189
     */
190
    concat(list: Buffer[], totalLength?: number): Buffer;
191
    /**
192
     * The same as buf1.compare(buf2).
193
     */
194
    compare(buf1: Buffer, buf2: Buffer): number;
195
    /**
196
     * Allocates a new buffer of {size} octets.
197
     *
198
     * @param size count of octets to allocate.
199
     * @param fill if specified, buffer will be initialized by calling buf.fill(fill).
200
     *    If parameter is omitted, buffer will be filled with zeros.
201
     * @param encoding encoding used for call to buf.fill while initalizing
202
     */
203
    alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
204
    /**
205
     * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
206
     * of the newly created Buffer are unknown and may contain sensitive data.
207
     *
208
     * @param size count of octets to allocate
209
     */
210
    allocUnsafe(size: number): Buffer;
211
    /**
212
     * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
213
     * of the newly created Buffer are unknown and may contain sensitive data.
214
     *
215
     * @param size count of octets to allocate
216
     */
217
    allocUnsafeSlow(size: number): Buffer;
218
};
219

    
220
/************************************************
221
*                                               *
222
*               GLOBAL INTERFACES               *
223
*                                               *
224
************************************************/
225
declare namespace NodeJS {
226
    export interface ErrnoException extends Error {
227
        errno?: string;
228
        code?: string;
229
        path?: string;
230
        syscall?: string;
231
        stack?: string;
232
    }
233

    
234
    export class EventEmitter {
235
        addListener(event: string, listener: Function): this;
236
        on(event: string, listener: Function): this;
237
        once(event: string, listener: Function): this;
238
        removeListener(event: string, listener: Function): this;
239
        removeAllListeners(event?: string): this;
240
        setMaxListeners(n: number): this;
241
        getMaxListeners(): number;
242
        listeners(event: string): Function[];
243
        emit(event: string, ...args: any[]): boolean;
244
        listenerCount(type: string): number;
245
        // Added in Node 6...
246
        prependListener(event: string, listener: Function): this;
247
        prependOnceListener(event: string, listener: Function): this;
248
        eventNames(): string[];
249
    }
250

    
251
    export interface ReadableStream extends EventEmitter {
252
        readable: boolean;
253
        read(size?: number): string | Buffer;
254
        setEncoding(encoding: string): void;
255
        pause(): ReadableStream;
256
        resume(): ReadableStream;
257
        pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
258
        unpipe<T extends WritableStream>(destination?: T): void;
259
        unshift(chunk: string): void;
260
        unshift(chunk: Buffer): void;
261
        wrap(oldStream: ReadableStream): ReadableStream;
262
    }
263

    
264
    export interface WritableStream extends EventEmitter {
265
        writable: boolean;
266
        write(buffer: Buffer | string, cb?: Function): boolean;
267
        write(str: string, encoding?: string, cb?: Function): boolean;
268
        end(): void;
269
        end(buffer: Buffer, cb?: Function): void;
270
        end(str: string, cb?: Function): void;
271
        end(str: string, encoding?: string, cb?: Function): void;
272
    }
273

    
274
    export interface ReadWriteStream extends ReadableStream, WritableStream {
275
      pause(): ReadWriteStream;
276
      resume(): ReadWriteStream;
277
    }
278

    
279
    export interface Events extends EventEmitter { }
280

    
281
    export interface Domain extends Events {
282
        run(fn: Function): void;
283
        add(emitter: Events): void;
284
        remove(emitter: Events): void;
285
        bind(cb: (err: Error, data: any) => any): any;
286
        intercept(cb: (data: any) => any): any;
287
        dispose(): void;
288

    
289
        addListener(event: string, listener: Function): this;
290
        on(event: string, listener: Function): this;
291
        once(event: string, listener: Function): this;
292
        removeListener(event: string, listener: Function): this;
293
        removeAllListeners(event?: string): this;
294
    }
295

    
296
    export interface MemoryUsage {
297
        rss: number;
298
        heapTotal: number;
299
        heapUsed: number;
300
    }
301

    
302
    export interface ProcessVersions {
303
        http_parser: string;
304
        node: string;
305
        v8: string;
306
        ares: string;
307
        uv: string;
308
        zlib: string;
309
        modules: string;
310
        openssl: string;
311
    }
312

    
313
    export interface Process extends EventEmitter {
314
        stdout: WritableStream;
315
        stderr: WritableStream;
316
        stdin: ReadableStream;
317
        argv: string[];
318
        execArgv: string[];
319
        execPath: string;
320
        abort(): void;
321
        chdir(directory: string): void;
322
        cwd(): string;
323
        env: any;
324
        exit(code?: number): void;
325
        exitCode: number;
326
        getgid(): number;
327
        setgid(id: number): void;
328
        setgid(id: string): void;
329
        getuid(): number;
330
        setuid(id: number): void;
331
        setuid(id: string): void;
332
        version: string;
333
        versions: ProcessVersions;
334
        config: {
335
            target_defaults: {
336
                cflags: any[];
337
                default_configuration: string;
338
                defines: string[];
339
                include_dirs: string[];
340
                libraries: string[];
341
            };
342
            variables: {
343
                clang: number;
344
                host_arch: string;
345
                node_install_npm: boolean;
346
                node_install_waf: boolean;
347
                node_prefix: string;
348
                node_shared_openssl: boolean;
349
                node_shared_v8: boolean;
350
                node_shared_zlib: boolean;
351
                node_use_dtrace: boolean;
352
                node_use_etw: boolean;
353
                node_use_openssl: boolean;
354
                target_arch: string;
355
                v8_no_strict_aliasing: number;
356
                v8_use_snapshot: boolean;
357
                visibility: string;
358
            };
359
        };
360
        kill(pid: number, signal?: string | number): void;
361
        pid: number;
362
        title: string;
363
        arch: string;
364
        platform: string;
365
        memoryUsage(): MemoryUsage;
366
        nextTick(callback: Function, ...args: any[]): void;
367
        umask(mask?: number): number;
368
        uptime(): number;
369
        hrtime(time?: number[]): number[];
370
        domain: Domain;
371

    
372
        // Worker
373
        send?(message: any, sendHandle?: any): void;
374
        disconnect(): void;
375
        connected: boolean;
376
    }
377

    
378
    export interface Global {
379
        Array: typeof Array;
380
        ArrayBuffer: typeof ArrayBuffer;
381
        Boolean: typeof Boolean;
382
        Buffer: typeof Buffer;
383
        DataView: typeof DataView;
384
        Date: typeof Date;
385
        Error: typeof Error;
386
        EvalError: typeof EvalError;
387
        Float32Array: typeof Float32Array;
388
        Float64Array: typeof Float64Array;
389
        Function: typeof Function;
390
        GLOBAL: Global;
391
        Infinity: typeof Infinity;
392
        Int16Array: typeof Int16Array;
393
        Int32Array: typeof Int32Array;
394
        Int8Array: typeof Int8Array;
395
        Intl: typeof Intl;
396
        JSON: typeof JSON;
397
        Map: MapConstructor;
398
        Math: typeof Math;
399
        NaN: typeof NaN;
400
        Number: typeof Number;
401
        Object: typeof Object;
402
        Promise: Function;
403
        RangeError: typeof RangeError;
404
        ReferenceError: typeof ReferenceError;
405
        RegExp: typeof RegExp;
406
        Set: SetConstructor;
407
        String: typeof String;
408
        Symbol: Function;
409
        SyntaxError: typeof SyntaxError;
410
        TypeError: typeof TypeError;
411
        URIError: typeof URIError;
412
        Uint16Array: typeof Uint16Array;
413
        Uint32Array: typeof Uint32Array;
414
        Uint8Array: typeof Uint8Array;
415
        Uint8ClampedArray: Function;
416
        WeakMap: WeakMapConstructor;
417
        WeakSet: WeakSetConstructor;
418
        clearImmediate: (immediateId: any) => void;
419
        clearInterval: (intervalId: NodeJS.Timer) => void;
420
        clearTimeout: (timeoutId: NodeJS.Timer) => void;
421
        console: typeof console;
422
        decodeURI: typeof decodeURI;
423
        decodeURIComponent: typeof decodeURIComponent;
424
        encodeURI: typeof encodeURI;
425
        encodeURIComponent: typeof encodeURIComponent;
426
        escape: (str: string) => string;
427
        eval: typeof eval;
428
        global: Global;
429
        isFinite: typeof isFinite;
430
        isNaN: typeof isNaN;
431
        parseFloat: typeof parseFloat;
432
        parseInt: typeof parseInt;
433
        process: Process;
434
        root: Global;
435
        setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any;
436
        setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
437
        setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
438
        undefined: typeof undefined;
439
        unescape: (str: string) => string;
440
        gc: () => void;
441
        v8debug?: any;
442
    }
443

    
444
    export interface Timer {
445
        ref(): void;
446
        unref(): void;
447
    }
448
}
449

    
450
interface IterableIterator<T> {}
451

    
452
/**
453
 * @deprecated
454
 */
455
interface NodeBuffer extends Uint8Array {
456
    write(string: string, offset?: number, length?: number, encoding?: string): number;
457
    toString(encoding?: string, start?: number, end?: number): string;
458
    toJSON(): any;
459
    equals(otherBuffer: Buffer): boolean;
460
    compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
461
    copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
462
    slice(start?: number, end?: number): Buffer;
463
    writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
464
    writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
465
    writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
466
    writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
467
    readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
468
    readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
469
    readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
470
    readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
471
    readUInt8(offset: number, noAssert?: boolean): number;
472
    readUInt16LE(offset: number, noAssert?: boolean): number;
473
    readUInt16BE(offset: number, noAssert?: boolean): number;
474
    readUInt32LE(offset: number, noAssert?: boolean): number;
475
    readUInt32BE(offset: number, noAssert?: boolean): number;
476
    readInt8(offset: number, noAssert?: boolean): number;
477
    readInt16LE(offset: number, noAssert?: boolean): number;
478
    readInt16BE(offset: number, noAssert?: boolean): number;
479
    readInt32LE(offset: number, noAssert?: boolean): number;
480
    readInt32BE(offset: number, noAssert?: boolean): number;
481
    readFloatLE(offset: number, noAssert?: boolean): number;
482
    readFloatBE(offset: number, noAssert?: boolean): number;
483
    readDoubleLE(offset: number, noAssert?: boolean): number;
484
    readDoubleBE(offset: number, noAssert?: boolean): number;
485
    swap16(): Buffer;
486
    swap32(): Buffer;
487
    swap64(): Buffer;
488
    writeUInt8(value: number, offset: number, noAssert?: boolean): number;
489
    writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
490
    writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
491
    writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
492
    writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
493
    writeInt8(value: number, offset: number, noAssert?: boolean): number;
494
    writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
495
    writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
496
    writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
497
    writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
498
    writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
499
    writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
500
    writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
501
    writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
502
    fill(value: any, offset?: number, end?: number): this;
503
    indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
504
    lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
505
    entries(): IterableIterator<[number, number]>;
506
    includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
507
    keys(): IterableIterator<number>;
508
    values(): IterableIterator<number>;
509
}
510

    
511
/************************************************
512
*                                               *
513
*                   MODULES                     *
514
*                                               *
515
************************************************/
516
declare module "buffer" {
517
    export var INSPECT_MAX_BYTES: number;
518
    var BuffType: typeof Buffer;
519
    var SlowBuffType: typeof SlowBuffer;
520
    export { BuffType as Buffer, SlowBuffType as SlowBuffer };
521
}
522

    
523
declare module "querystring" {
524
    export interface StringifyOptions {
525
        encodeURIComponent?: Function;
526
    }
527

    
528
    export interface ParseOptions {
529
        maxKeys?: number;
530
        decodeURIComponent?: Function;
531
    }
532

    
533
    export function stringify<T>(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string;
534
    export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any;
535
    export function parse<T extends {}>(str: string, sep?: string, eq?: string, options?: ParseOptions): T;
536
    export function escape(str: string): string;
537
    export function unescape(str: string): string;
538
}
539

    
540
declare module "events" {
541
    export class EventEmitter extends NodeJS.EventEmitter {
542
        static EventEmitter: EventEmitter;
543
        static listenerCount(emitter: EventEmitter, event: string): number; // deprecated
544
        static defaultMaxListeners: number;
545

    
546
        addListener(event: string, listener: Function): this;
547
        on(event: string, listener: Function): this;
548
        once(event: string, listener: Function): this;
549
        prependListener(event: string, listener: Function): this;
550
        prependOnceListener(event: string, listener: Function): this;
551
        removeListener(event: string, listener: Function): this;
552
        removeAllListeners(event?: string): this;
553
        setMaxListeners(n: number): this;
554
        getMaxListeners(): number;
555
        listeners(event: string): Function[];
556
        emit(event: string, ...args: any[]): boolean;
557
        eventNames(): string[];
558
        listenerCount(type: string): number;
559
    }
560
}
561

    
562
declare module "http" {
563
    import * as events from "events";
564
    import * as net from "net";
565
    import * as stream from "stream";
566

    
567
    export interface RequestOptions {
568
        protocol?: string;
569
        host?: string;
570
        hostname?: string;
571
        family?: number;
572
        port?: number;
573
        localAddress?: string;
574
        socketPath?: string;
575
        method?: string;
576
        path?: string;
577
        headers?: { [key: string]: any };
578
        auth?: string;
579
        agent?: Agent | boolean;
580
    }
581

    
582
    export interface Server extends events.EventEmitter, net.Server {
583
        setTimeout(msecs: number, callback: Function): void;
584
        maxHeadersCount: number;
585
        timeout: number;
586
    }
587
    /**
588
     * @deprecated Use IncomingMessage
589
     */
590
    export interface ServerRequest extends IncomingMessage {
591
        connection: net.Socket;
592
    }
593
    export interface ServerResponse extends events.EventEmitter, stream.Writable {
594
        // Extended base methods
595
        write(buffer: Buffer): boolean;
596
        write(buffer: Buffer, cb?: Function): boolean;
597
        write(str: string, cb?: Function): boolean;
598
        write(str: string, encoding?: string, cb?: Function): boolean;
599
        write(str: string, encoding?: string, fd?: string): boolean;
600

    
601
        writeContinue(): void;
602
        writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void;
603
        writeHead(statusCode: number, headers?: any): void;
604
        statusCode: number;
605
        statusMessage: string;
606
        headersSent: boolean;
607
        setHeader(name: string, value: string | string[]): void;
608
        setTimeout(msecs: number, callback: Function): ServerResponse;
609
        sendDate: boolean;
610
        getHeader(name: string): string;
611
        removeHeader(name: string): void;
612
        write(chunk: any, encoding?: string): any;
613
        addTrailers(headers: any): void;
614
        finished: boolean;
615

    
616
        // Extended base methods
617
        end(): void;
618
        end(buffer: Buffer, cb?: Function): void;
619
        end(str: string, cb?: Function): void;
620
        end(str: string, encoding?: string, cb?: Function): void;
621
        end(data?: any, encoding?: string): void;
622
    }
623
    export interface ClientRequest extends events.EventEmitter, stream.Writable {
624
        // Extended base methods
625
        write(buffer: Buffer): boolean;
626
        write(buffer: Buffer, cb?: Function): boolean;
627
        write(str: string, cb?: Function): boolean;
628
        write(str: string, encoding?: string, cb?: Function): boolean;
629
        write(str: string, encoding?: string, fd?: string): boolean;
630

    
631
        write(chunk: any, encoding?: string): void;
632
        abort(): void;
633
        setTimeout(timeout: number, callback?: Function): void;
634
        setNoDelay(noDelay?: boolean): void;
635
        setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
636

    
637
        setHeader(name: string, value: string | string[]): void;
638
        getHeader(name: string): string;
639
        removeHeader(name: string): void;
640
        addTrailers(headers: any): void;
641

    
642
        // Extended base methods
643
        end(): void;
644
        end(buffer: Buffer, cb?: Function): void;
645
        end(str: string, cb?: Function): void;
646
        end(str: string, encoding?: string, cb?: Function): void;
647
        end(data?: any, encoding?: string): void;
648
    }
649
    export interface IncomingMessage extends events.EventEmitter, stream.Readable {
650
        httpVersion: string;
651
        httpVersionMajor: string;
652
        httpVersionMinor: string;
653
        connection: any;
654
        headers: any;
655
        rawHeaders: string[];
656
        trailers: any;
657
        rawTrailers: any;
658
        setTimeout(msecs: number, callback: Function): NodeJS.Timer;
659
        /**
660
         * Only valid for request obtained from http.Server.
661
         */
662
        method?: string;
663
        /**
664
         * Only valid for request obtained from http.Server.
665
         */
666
        url?: string;
667
        /**
668
         * Only valid for response obtained from http.ClientRequest.
669
         */
670
        statusCode?: number;
671
        /**
672
         * Only valid for response obtained from http.ClientRequest.
673
         */
674
        statusMessage?: string;
675
        socket: net.Socket;
676
        destroy(error?: Error): void;
677
    }
678
    /**
679
     * @deprecated Use IncomingMessage
680
     */
681
    export interface ClientResponse extends IncomingMessage { }
682

    
683
    export interface AgentOptions {
684
        /**
685
         * Keep sockets around in a pool to be used by other requests in the future. Default = false
686
         */
687
        keepAlive?: boolean;
688
        /**
689
         * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
690
         * Only relevant if keepAlive is set to true.
691
         */
692
        keepAliveMsecs?: number;
693
        /**
694
         * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
695
         */
696
        maxSockets?: number;
697
        /**
698
         * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
699
         */
700
        maxFreeSockets?: number;
701
    }
702

    
703
    export class Agent {
704
        maxSockets: number;
705
        sockets: any;
706
        requests: any;
707

    
708
        constructor(opts?: AgentOptions);
709

    
710
        /**
711
         * Destroy any sockets that are currently in use by the agent.
712
         * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled,
713
         * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise,
714
         * sockets may hang open for quite a long time before the server terminates them.
715
         */
716
        destroy(): void;
717
    }
718

    
719
    export var METHODS: string[];
720

    
721
    export var STATUS_CODES: {
722
        [errorCode: number]: string;
723
        [errorCode: string]: string;
724
    };
725
    export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server;
726
    export function createClient(port?: number, host?: string): any;
727
    export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
728
    export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest;
729
    export var globalAgent: Agent;
730
}
731

    
732
declare module "cluster" {
733
    import * as child from "child_process";
734
    import * as events from "events";
735

    
736
    export interface ClusterSettings {
737
        exec?: string;
738
        args?: string[];
739
        silent?: boolean;
740
    }
741

    
742
    export interface Address {
743
        address: string;
744
        port: number;
745
        addressType: string;
746
    }
747

    
748
    export class Worker extends events.EventEmitter {
749
        id: string;
750
        process: child.ChildProcess;
751
        suicide: boolean;
752
        send(message: any, sendHandle?: any): boolean;
753
        kill(signal?: string): void;
754
        destroy(signal?: string): void;
755
        disconnect(): void;
756
        isConnected(): boolean;
757
        isDead(): boolean;
758
    }
759

    
760
    export var settings: ClusterSettings;
761
    export var isMaster: boolean;
762
    export var isWorker: boolean;
763
    export function setupMaster(settings?: ClusterSettings): void;
764
    export function fork(env?: any): Worker;
765
    export function disconnect(callback?: Function): void;
766
    export var worker: Worker;
767
    export var workers: {
768
        [index: string]: Worker
769
    };
770

    
771
    // Event emitter
772
    export function addListener(event: string, listener: Function): void;
773
    export function on(event: "disconnect", listener: (worker: Worker) => void): void;
774
    export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): void;
775
    export function on(event: "fork", listener: (worker: Worker) => void): void;
776
    export function on(event: "listening", listener: (worker: Worker, address: any) => void): void;
777
    export function on(event: "message", listener: (worker: Worker, message: any) => void): void;
778
    export function on(event: "online", listener: (worker: Worker) => void): void;
779
    export function on(event: "setup", listener: (settings: any) => void): void;
780
    export function on(event: string, listener: Function): any;
781
    export function once(event: string, listener: Function): void;
782
    export function removeListener(event: string, listener: Function): void;
783
    export function removeAllListeners(event?: string): void;
784
    export function setMaxListeners(n: number): void;
785
    export function listeners(event: string): Function[];
786
    export function emit(event: string, ...args: any[]): boolean;
787
}
788

    
789
declare module "zlib" {
790
    import * as stream from "stream";
791
    export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; }
792

    
793
    export interface Gzip extends stream.Transform { }
794
    export interface Gunzip extends stream.Transform { }
795
    export interface Deflate extends stream.Transform { }
796
    export interface Inflate extends stream.Transform { }
797
    export interface DeflateRaw extends stream.Transform { }
798
    export interface InflateRaw extends stream.Transform { }
799
    export interface Unzip extends stream.Transform { }
800

    
801
    export function createGzip(options?: ZlibOptions): Gzip;
802
    export function createGunzip(options?: ZlibOptions): Gunzip;
803
    export function createDeflate(options?: ZlibOptions): Deflate;
804
    export function createInflate(options?: ZlibOptions): Inflate;
805
    export function createDeflateRaw(options?: ZlibOptions): DeflateRaw;
806
    export function createInflateRaw(options?: ZlibOptions): InflateRaw;
807
    export function createUnzip(options?: ZlibOptions): Unzip;
808

    
809
    export function deflate(buf: Buffer, callback: (error: Error, result: any) => void): void;
810
    export function deflateSync(buf: Buffer, options?: ZlibOptions): any;
811
    export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) => void): void;
812
    export function deflateRawSync(buf: Buffer, options?: ZlibOptions): any;
813
    export function gzip(buf: Buffer, callback: (error: Error, result: any) => void): void;
814
    export function gzipSync(buf: Buffer, options?: ZlibOptions): any;
815
    export function gunzip(buf: Buffer, callback: (error: Error, result: any) => void): void;
816
    export function gunzipSync(buf: Buffer, options?: ZlibOptions): any;
817
    export function inflate(buf: Buffer, callback: (error: Error, result: any) => void): void;
818
    export function inflateSync(buf: Buffer, options?: ZlibOptions): any;
819
    export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) => void): void;
820
    export function inflateRawSync(buf: Buffer, options?: ZlibOptions): any;
821
    export function unzip(buf: Buffer, callback: (error: Error, result: any) => void): void;
822
    export function unzipSync(buf: Buffer, options?: ZlibOptions): any;
823

    
824
    // Constants
825
    export var Z_NO_FLUSH: number;
826
    export var Z_PARTIAL_FLUSH: number;
827
    export var Z_SYNC_FLUSH: number;
828
    export var Z_FULL_FLUSH: number;
829
    export var Z_FINISH: number;
830
    export var Z_BLOCK: number;
831
    export var Z_TREES: number;
832
    export var Z_OK: number;
833
    export var Z_STREAM_END: number;
834
    export var Z_NEED_DICT: number;
835
    export var Z_ERRNO: number;
836
    export var Z_STREAM_ERROR: number;
837
    export var Z_DATA_ERROR: number;
838
    export var Z_MEM_ERROR: number;
839
    export var Z_BUF_ERROR: number;
840
    export var Z_VERSION_ERROR: number;
841
    export var Z_NO_COMPRESSION: number;
842
    export var Z_BEST_SPEED: number;
843
    export var Z_BEST_COMPRESSION: number;
844
    export var Z_DEFAULT_COMPRESSION: number;
845
    export var Z_FILTERED: number;
846
    export var Z_HUFFMAN_ONLY: number;
847
    export var Z_RLE: number;
848
    export var Z_FIXED: number;
849
    export var Z_DEFAULT_STRATEGY: number;
850
    export var Z_BINARY: number;
851
    export var Z_TEXT: number;
852
    export var Z_ASCII: number;
853
    export var Z_UNKNOWN: number;
854
    export var Z_DEFLATED: number;
855
    export var Z_NULL: number;
856
}
857

    
858
declare module "os" {
859
    export interface CpuInfo {
860
        model: string;
861
        speed: number;
862
        times: {
863
            user: number;
864
            nice: number;
865
            sys: number;
866
            idle: number;
867
            irq: number;
868
        };
869
    }
870

    
871
    export interface NetworkInterfaceInfo {
872
        address: string;
873
        netmask: string;
874
        family: string;
875
        mac: string;
876
        internal: boolean;
877
    }
878

    
879
    export function hostname(): string;
880
    export function loadavg(): number[];
881
    export function uptime(): number;
882
    export function freemem(): number;
883
    export function totalmem(): number;
884
    export function cpus(): CpuInfo[];
885
    export function type(): string;
886
    export function release(): string;
887
    export function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] };
888
    export function homedir(): string;
889
    export function userInfo(options?: { encoding: string }): { username: string, uid: number, gid: number, shell: any, homedir: string }
890
    export var constants: {
891
        UV_UDP_REUSEADDR: number,
892
        errno: {
893
            SIGHUP: number;
894
            SIGINT: number;
895
            SIGQUIT: number;
896
            SIGILL: number;
897
            SIGTRAP: number;
898
            SIGABRT: number;
899
            SIGIOT: number;
900
            SIGBUS: number;
901
            SIGFPE: number;
902
            SIGKILL: number;
903
            SIGUSR1: number;
904
            SIGSEGV: number;
905
            SIGUSR2: number;
906
            SIGPIPE: number;
907
            SIGALRM: number;
908
            SIGTERM: number;
909
            SIGCHLD: number;
910
            SIGSTKFLT: number;
911
            SIGCONT: number;
912
            SIGSTOP: number;
913
            SIGTSTP: number;
914
            SIGTTIN: number;
915
            SIGTTOU: number;
916
            SIGURG: number;
917
            SIGXCPU: number;
918
            SIGXFSZ: number;
919
            SIGVTALRM: number;
920
            SIGPROF: number;
921
            SIGWINCH: number;
922
            SIGIO: number;
923
            SIGPOLL: number;
924
            SIGPWR: number;
925
            SIGSYS: number;
926
            SIGUNUSED: number;
927
        },
928
        signals: {
929
            E2BIG: number;
930
            EACCES: number;
931
            EADDRINUSE: number;
932
            EADDRNOTAVAIL: number;
933
            EAFNOSUPPORT: number;
934
            EAGAIN: number;
935
            EALREADY: number;
936
            EBADF: number;
937
            EBADMSG: number;
938
            EBUSY: number;
939
            ECANCELED: number;
940
            ECHILD: number;
941
            ECONNABORTED: number;
942
            ECONNREFUSED: number;
943
            ECONNRESET: number;
944
            EDEADLK: number;
945
            EDESTADDRREQ: number;
946
            EDOM: number;
947
            EDQUOT: number;
948
            EEXIST: number;
949
            EFAULT: number;
950
            EFBIG: number;
951
            EHOSTUNREACH: number;
952
            EIDRM: number;
953
            EILSEQ: number;
954
            EINPROGRESS: number;
955
            EINTR: number;
956
            EINVAL: number;
957
            EIO: number;
958
            EISCONN: number;
959
            EISDIR: number;
960
            ELOOP: number;
961
            EMFILE: number;
962
            EMLINK: number;
963
            EMSGSIZE: number;
964
            EMULTIHOP: number;
965
            ENAMETOOLONG: number;
966
            ENETDOWN: number;
967
            ENETRESET: number;
968
            ENETUNREACH: number;
969
            ENFILE: number;
970
            ENOBUFS: number;
971
            ENODATA: number;
972
            ENODEV: number;
973
            ENOENT: number;
974
            ENOEXEC: number;
975
            ENOLCK: number;
976
            ENOLINK: number;
977
            ENOMEM: number;
978
            ENOMSG: number;
979
            ENOPROTOOPT: number;
980
            ENOSPC: number;
981
            ENOSR: number;
982
            ENOSTR: number;
983
            ENOSYS: number;
984
            ENOTCONN: number;
985
            ENOTDIR: number;
986
            ENOTEMPTY: number;
987
            ENOTSOCK: number;
988
            ENOTSUP: number;
989
            ENOTTY: number;
990
            ENXIO: number;
991
            EOPNOTSUPP: number;
992
            EOVERFLOW: number;
993
            EPERM: number;
994
            EPIPE: number;
995
            EPROTO: number;
996
            EPROTONOSUPPORT: number;
997
            EPROTOTYPE: number;
998
            ERANGE: number;
999
            EROFS: number;
1000
            ESPIPE: number;
1001
            ESRCH: number;
1002
            ESTALE: number;
1003
            ETIME: number;
1004
            ETIMEDOUT: number;
1005
            ETXTBSY: number;
1006
            EWOULDBLOCK: number;
1007
            EXDEV: number;
1008
        },
1009
    };
1010
    export function arch(): string;
1011
    export function platform(): string;
1012
    export function tmpdir(): string;
1013
    export function tmpDir(): string;
1014
    export function getNetworkInterfaces(): { [index: string]: NetworkInterfaceInfo[] };
1015
    export var EOL: string;
1016
    export function endianness(): "BE" | "LE";
1017
}
1018

    
1019
declare module "https" {
1020
    import * as tls from "tls";
1021
    import * as events from "events";
1022
    import * as http from "http";
1023

    
1024
    export interface ServerOptions {
1025
        pfx?: any;
1026
        key?: any;
1027
        passphrase?: string;
1028
        cert?: any;
1029
        ca?: any;
1030
        crl?: any;
1031
        ciphers?: string;
1032
        honorCipherOrder?: boolean;
1033
        requestCert?: boolean;
1034
        rejectUnauthorized?: boolean;
1035
        NPNProtocols?: any;
1036
        SNICallback?: (servername: string, cb:(err:Error,ctx:tls.SecureContext)=>any) => any;
1037
    }
1038

    
1039
    export interface RequestOptions extends http.RequestOptions {
1040
        pfx?: any;
1041
        key?: any;
1042
        passphrase?: string;
1043
        cert?: any;
1044
        ca?: any;
1045
        ciphers?: string;
1046
        rejectUnauthorized?: boolean;
1047
        secureProtocol?: string;
1048
    }
1049

    
1050
    export interface Agent extends http.Agent { }
1051

    
1052
    export interface AgentOptions extends http.AgentOptions {
1053
        pfx?: any;
1054
        key?: any;
1055
        passphrase?: string;
1056
        cert?: any;
1057
        ca?: any;
1058
        ciphers?: string;
1059
        rejectUnauthorized?: boolean;
1060
        secureProtocol?: string;
1061
        maxCachedSessions?: number;
1062
    }
1063

    
1064
    export var Agent: {
1065
        new (options?: AgentOptions): Agent;
1066
    };
1067
    export interface Server extends tls.Server { }
1068
    export function createServer(options: ServerOptions, requestListener?: Function): Server;
1069
    export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
1070
    export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
1071
    export var globalAgent: Agent;
1072
}
1073

    
1074
declare module "punycode" {
1075
    export function decode(string: string): string;
1076
    export function encode(string: string): string;
1077
    export function toUnicode(domain: string): string;
1078
    export function toASCII(domain: string): string;
1079
    export var ucs2: ucs2;
1080
    interface ucs2 {
1081
        decode(string: string): number[];
1082
        encode(codePoints: number[]): string;
1083
    }
1084
    export var version: any;
1085
}
1086

    
1087
declare module "repl" {
1088
    import * as stream from "stream";
1089
    import * as readline from "readline";
1090

    
1091
    export interface ReplOptions {
1092
        prompt?: string;
1093
        input?: NodeJS.ReadableStream;
1094
        output?: NodeJS.WritableStream;
1095
        terminal?: boolean;
1096
        eval?: Function;
1097
        useColors?: boolean;
1098
        useGlobal?: boolean;
1099
        ignoreUndefined?: boolean;
1100
        writer?: Function;
1101
        completer?: Function;
1102
        replMode?: any;
1103
        breakEvalOnSigint?: any;
1104
    }
1105

    
1106
    export interface REPLServer extends readline.ReadLine {
1107
        defineCommand(keyword: string, cmd: Function | { help: string, action: Function }): void;
1108
        displayPrompt(preserveCursor?: boolean): void
1109
    }
1110

    
1111
    export function start(options: ReplOptions): REPLServer;
1112
}
1113

    
1114
declare module "readline" {
1115
    import * as events from "events";
1116
    import * as stream from "stream";
1117

    
1118
    export interface Key {
1119
        sequence?: string;
1120
        name?: string;
1121
        ctrl?: boolean;
1122
        meta?: boolean;
1123
        shift?: boolean;
1124
    }
1125

    
1126
    export interface ReadLine extends events.EventEmitter {
1127
        setPrompt(prompt: string): void;
1128
        prompt(preserveCursor?: boolean): void;
1129
        question(query: string, callback: (answer: string) => void): void;
1130
        pause(): ReadLine;
1131
        resume(): ReadLine;
1132
        close(): void;
1133
        write(data: string | Buffer, key?: Key): void;
1134
    }
1135

    
1136
    export interface Completer {
1137
        (line: string): CompleterResult;
1138
        (line: string, callback: (err: any, result: CompleterResult) => void): any;
1139
    }
1140

    
1141
    export interface CompleterResult {
1142
        completions: string[];
1143
        line: string;
1144
    }
1145

    
1146
    export interface ReadLineOptions {
1147
        input: NodeJS.ReadableStream;
1148
        output?: NodeJS.WritableStream;
1149
        completer?: Completer;
1150
        terminal?: boolean;
1151
        historySize?: number;
1152
    }
1153

    
1154
    export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine;
1155
    export function createInterface(options: ReadLineOptions): ReadLine;
1156

    
1157
    export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void;
1158
    export function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void;
1159
    export function clearLine(stream: NodeJS.WritableStream, dir: number): void;
1160
    export function clearScreenDown(stream: NodeJS.WritableStream): void;
1161
}
1162

    
1163
declare module "vm" {
1164
    export interface Context { }
1165
    export interface ScriptOptions {
1166
        filename?: string;
1167
        lineOffset?: number;
1168
        columnOffset?: number;
1169
        displayErrors?: boolean;
1170
        timeout?: number;
1171
        cachedData?: Buffer;
1172
        produceCachedData?: boolean;
1173
    }
1174
    export interface RunningScriptOptions {
1175
        filename?: string;
1176
        lineOffset?: number;
1177
        columnOffset?: number;
1178
        displayErrors?: boolean;
1179
        timeout?: number;
1180
    }
1181
    export class Script {
1182
        constructor(code: string, options?: ScriptOptions);
1183
        runInContext(contextifiedSandbox: Context, options?: RunningScriptOptions): any;
1184
        runInNewContext(sandbox?: Context, options?: RunningScriptOptions): any;
1185
        runInThisContext(options?: RunningScriptOptions): any;
1186
    }
1187
    export function createContext(sandbox?: Context): Context;
1188
    export function isContext(sandbox: Context): boolean;
1189
    export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions): any;
1190
    export function runInDebugContext(code: string): any;
1191
    export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions): any;
1192
    export function runInThisContext(code: string, options?: RunningScriptOptions): any;
1193
}
1194

    
1195
declare module "child_process" {
1196
    import * as events from "events";
1197
    import * as stream from "stream";
1198

    
1199
    export interface ChildProcess extends events.EventEmitter {
1200
        stdin: stream.Writable;
1201
        stdout: stream.Readable;
1202
        stderr: stream.Readable;
1203
        stdio: [stream.Writable, stream.Readable, stream.Readable];
1204
        pid: number;
1205
        kill(signal?: string): void;
1206
        send(message: any, sendHandle?: any): boolean;
1207
        connected: boolean;
1208
        disconnect(): void;
1209
        unref(): void;
1210
        ref(): void;
1211
    }
1212

    
1213
    export interface SpawnOptions {
1214
        cwd?: string;
1215
        env?: any;
1216
        stdio?: any;
1217
        detached?: boolean;
1218
        uid?: number;
1219
        gid?: number;
1220
        shell?: boolean | string;
1221
    }
1222
    export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
1223

    
1224
    export interface ExecOptions {
1225
        cwd?: string;
1226
        env?: any;
1227
        shell?: string;
1228
        timeout?: number;
1229
        maxBuffer?: number;
1230
        killSignal?: string;
1231
        uid?: number;
1232
        gid?: number;
1233
    }
1234
    export interface ExecOptionsWithStringEncoding extends ExecOptions {
1235
        encoding: BufferEncoding;
1236
    }
1237
    export interface ExecOptionsWithBufferEncoding extends ExecOptions {
1238
        encoding: string; // specify `null`.
1239
    }
1240
    export function exec(command: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1241
    export function exec(command: string, options: ExecOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1242
    // usage. child_process.exec("tsc", {encoding: null as string}, (err, stdout, stderr) => {});
1243
    export function exec(command: string, options: ExecOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
1244
    export function exec(command: string, options: ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1245

    
1246
    export interface ExecFileOptions {
1247
        cwd?: string;
1248
        env?: any;
1249
        timeout?: number;
1250
        maxBuffer?: number;
1251
        killSignal?: string;
1252
        uid?: number;
1253
        gid?: number;
1254
    }
1255
    export interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
1256
        encoding: BufferEncoding;
1257
    }
1258
    export interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
1259
        encoding: string; // specify `null`.
1260
    }
1261
    export function execFile(file: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1262
    export function execFile(file: string, options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1263
    // usage. child_process.execFile("file.sh", {encoding: null as string}, (err, stdout, stderr) => {});
1264
    export function execFile(file: string, options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
1265
    export function execFile(file: string, options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1266
    export function execFile(file: string, args?: string[], callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1267
    export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1268
    // usage. child_process.execFile("file.sh", ["foo"], {encoding: null as string}, (err, stdout, stderr) => {});
1269
    export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
1270
    export function execFile(file: string, args?: string[], options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1271

    
1272
    export interface ForkOptions {
1273
        cwd?: string;
1274
        env?: any;
1275
        execPath?: string;
1276
        execArgv?: string[];
1277
        silent?: boolean;
1278
        uid?: number;
1279
        gid?: number;
1280
    }
1281
    export function fork(modulePath: string, args?: string[], options?: ForkOptions): ChildProcess;
1282

    
1283
    export interface SpawnSyncOptions {
1284
        cwd?: string;
1285
        input?: string | Buffer;
1286
        stdio?: any;
1287
        env?: any;
1288
        uid?: number;
1289
        gid?: number;
1290
        timeout?: number;
1291
        killSignal?: string;
1292
        maxBuffer?: number;
1293
        encoding?: string;
1294
        shell?: boolean | string;
1295
    }
1296
    export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
1297
        encoding: BufferEncoding;
1298
    }
1299
    export interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
1300
        encoding: string; // specify `null`.
1301
    }
1302
    export interface SpawnSyncReturns<T> {
1303
        pid: number;
1304
        output: string[];
1305
        stdout: T;
1306
        stderr: T;
1307
        status: number;
1308
        signal: string;
1309
        error: Error;
1310
    }
1311
    export function spawnSync(command: string): SpawnSyncReturns<Buffer>;
1312
    export function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
1313
    export function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
1314
    export function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
1315
    export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
1316
    export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
1317
    export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
1318

    
1319
    export interface ExecSyncOptions {
1320
        cwd?: string;
1321
        input?: string | Buffer;
1322
        stdio?: any;
1323
        env?: any;
1324
        shell?: string;
1325
        uid?: number;
1326
        gid?: number;
1327
        timeout?: number;
1328
        killSignal?: string;
1329
        maxBuffer?: number;
1330
        encoding?: string;
1331
    }
1332
    export interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
1333
        encoding: BufferEncoding;
1334
    }
1335
    export interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
1336
        encoding: string; // specify `null`.
1337
    }
1338
    export function execSync(command: string): Buffer;
1339
    export function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string;
1340
    export function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer;
1341
    export function execSync(command: string, options?: ExecSyncOptions): Buffer;
1342

    
1343
    export interface ExecFileSyncOptions {
1344
        cwd?: string;
1345
        input?: string | Buffer;
1346
        stdio?: any;
1347
        env?: any;
1348
        uid?: number;
1349
        gid?: number;
1350
        timeout?: number;
1351
        killSignal?: string;
1352
        maxBuffer?: number;
1353
        encoding?: string;
1354
    }
1355
    export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
1356
        encoding: BufferEncoding;
1357
    }
1358
    export interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
1359
        encoding: string; // specify `null`.
1360
    }
1361
    export function execFileSync(command: string): Buffer;
1362
    export function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string;
1363
    export function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
1364
    export function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer;
1365
    export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithStringEncoding): string;
1366
    export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
1367
    export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions): Buffer;
1368
}
1369

    
1370
declare module "url" {
1371
    export interface Url {
1372
        href?: string;
1373
        protocol?: string;
1374
        auth?: string;
1375
        hostname?: string;
1376
        port?: string;
1377
        host?: string;
1378
        pathname?: string;
1379
        search?: string;
1380
        query?: string | any;
1381
        slashes?: boolean;
1382
        hash?: string;
1383
        path?: string;
1384
    }
1385

    
1386
    export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url;
1387
    export function format(url: Url): string;
1388
    export function resolve(from: string, to: string): string;
1389
}
1390

    
1391
declare module "dns" {
1392
    export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) => void): string;
1393
    export function lookup(domain: string, callback: (err: Error, address: string, family: number) => void): string;
1394
    export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[];
1395
    export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1396
    export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1397
    export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1398
    export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1399
    export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1400
    export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1401
    export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1402
    export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1403
    export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[];
1404

    
1405
    //Error codes
1406
    export var NODATA: string;
1407
    export var FORMERR: string;
1408
    export var SERVFAIL: string;
1409
    export var NOTFOUND: string;
1410
    export var NOTIMP: string;
1411
    export var REFUSED: string;
1412
    export var BADQUERY: string;
1413
    export var BADNAME: string;
1414
    export var BADFAMILY: string;
1415
    export var BADRESP: string;
1416
    export var CONNREFUSED: string;
1417
    export var TIMEOUT: string;
1418
    export var EOF: string;
1419
    export var FILE: string;
1420
    export var NOMEM: string;
1421
    export var DESTRUCTION: string;
1422
    export var BADSTR: string;
1423
    export var BADFLAGS: string;
1424
    export var NONAME: string;
1425
    export var BADHINTS: string;
1426
    export var NOTINITIALIZED: string;
1427
    export var LOADIPHLPAPI: string;
1428
    export var ADDRGETNETWORKPARAMS: string;
1429
    export var CANCELLED: string;
1430
}
1431

    
1432
declare module "net" {
1433
    import * as stream from "stream";
1434

    
1435
    export interface Socket extends stream.Duplex {
1436
        // Extended base methods
1437
        write(buffer: Buffer): boolean;
1438
        write(buffer: Buffer, cb?: Function): boolean;
1439
        write(str: string, cb?: Function): boolean;
1440
        write(str: string, encoding?: string, cb?: Function): boolean;
1441
        write(str: string, encoding?: string, fd?: string): boolean;
1442

    
1443
        connect(port: number, host?: string, connectionListener?: Function): void;
1444
        connect(path: string, connectionListener?: Function): void;
1445
        bufferSize: number;
1446
        setEncoding(encoding?: string): void;
1447
        write(data: any, encoding?: string, callback?: Function): void;
1448
        destroy(): void;
1449
        pause(): Socket;
1450
        resume(): Socket;
1451
        setTimeout(timeout: number, callback?: Function): void;
1452
        setNoDelay(noDelay?: boolean): void;
1453
        setKeepAlive(enable?: boolean, initialDelay?: number): void;
1454
        address(): { port: number; family: string; address: string; };
1455
        unref(): void;
1456
        ref(): void;
1457

    
1458
        remoteAddress: string;
1459
        remoteFamily: string;
1460
        remotePort: number;
1461
        localAddress: string;
1462
        localPort: number;
1463
        bytesRead: number;
1464
        bytesWritten: number;
1465

    
1466
        // Extended base methods
1467
        end(): void;
1468
        end(buffer: Buffer, cb?: Function): void;
1469
        end(str: string, cb?: Function): void;
1470
        end(str: string, encoding?: string, cb?: Function): void;
1471
        end(data?: any, encoding?: string): void;
1472
    }
1473

    
1474
    export var Socket: {
1475
        new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket;
1476
    };
1477

    
1478
    export interface ListenOptions {
1479
        port?: number;
1480
        host?: string;
1481
        backlog?: number;
1482
        path?: string;
1483
        exclusive?: boolean;
1484
    }
1485

    
1486
    export interface Server extends Socket {
1487
        listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): Server;
1488
        listen(port: number, hostname?: string, listeningListener?: Function): Server;
1489
        listen(port: number, backlog?: number, listeningListener?: Function): Server;
1490
        listen(port: number, listeningListener?: Function): Server;
1491
        listen(path: string, backlog?: number, listeningListener?: Function): Server;
1492
        listen(path: string, listeningListener?: Function): Server;
1493
        listen(handle: any, backlog?: number, listeningListener?: Function): Server;
1494
        listen(handle: any, listeningListener?: Function): Server;
1495
        listen(options: ListenOptions, listeningListener?: Function): Server;
1496
        close(callback?: Function): Server;
1497
        address(): { port: number; family: string; address: string; };
1498
        getConnections(cb: (error: Error, count: number) => void): void;
1499
        ref(): Server;
1500
        unref(): Server;
1501
        maxConnections: number;
1502
        connections: number;
1503
    }
1504
    export function createServer(connectionListener?: (socket: Socket) => void): Server;
1505
    export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) => void): Server;
1506
    export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
1507
    export function connect(port: number, host?: string, connectionListener?: Function): Socket;
1508
    export function connect(path: string, connectionListener?: Function): Socket;
1509
    export function createConnection(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
1510
    export function createConnection(port: number, host?: string, connectionListener?: Function): Socket;
1511
    export function createConnection(path: string, connectionListener?: Function): Socket;
1512
    export function isIP(input: string): number;
1513
    export function isIPv4(input: string): boolean;
1514
    export function isIPv6(input: string): boolean;
1515
}
1516

    
1517
declare module "dgram" {
1518
    import * as events from "events";
1519

    
1520
    interface RemoteInfo {
1521
        address: string;
1522
        port: number;
1523
        size: number;
1524
    }
1525

    
1526
    interface AddressInfo {
1527
        address: string;
1528
        family: string;
1529
        port: number;
1530
    }
1531

    
1532
    interface BindOptions {
1533
        port: number;
1534
        address?: string;
1535
        exclusive?: boolean;
1536
    }
1537

    
1538
    interface SocketOptions {
1539
        type: "udp4" | "udp6";
1540
        reuseAddr?: boolean;
1541
    }
1542

    
1543
    export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
1544
    export function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
1545

    
1546
    export interface Socket extends events.EventEmitter {
1547
        send(msg: Buffer | String | any[], port: number, address: string, callback?: (error: Error, bytes: number) => void): void;
1548
        send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void;
1549
        bind(port?: number, address?: string, callback?: () => void): void;
1550
        bind(options: BindOptions, callback?: Function): void;
1551
        close(callback?: any): void;
1552
        address(): AddressInfo;
1553
        setBroadcast(flag: boolean): void;
1554
        setTTL(ttl: number): void;
1555
        setMulticastTTL(ttl: number): void;
1556
        setMulticastLoopback(flag: boolean): void;
1557
        addMembership(multicastAddress: string, multicastInterface?: string): void;
1558
        dropMembership(multicastAddress: string, multicastInterface?: string): void;
1559
        ref(): void;
1560
        unref(): void;
1561
    }
1562
}
1563

    
1564
declare module "fs" {
1565
    import * as stream from "stream";
1566
    import * as events from "events";
1567

    
1568
    interface Stats {
1569
        isFile(): boolean;
1570
        isDirectory(): boolean;
1571
        isBlockDevice(): boolean;
1572
        isCharacterDevice(): boolean;
1573
        isSymbolicLink(): boolean;
1574
        isFIFO(): boolean;
1575
        isSocket(): boolean;
1576
        dev: number;
1577
        ino: number;
1578
        mode: number;
1579
        nlink: number;
1580
        uid: number;
1581
        gid: number;
1582
        rdev: number;
1583
        size: number;
1584
        blksize: number;
1585
        blocks: number;
1586
        atime: Date;
1587
        mtime: Date;
1588
        ctime: Date;
1589
        birthtime: Date;
1590
    }
1591

    
1592
    interface FSWatcher extends events.EventEmitter {
1593
        close(): void;
1594
    }
1595

    
1596
    export interface ReadStream extends stream.Readable {
1597
        close(): void;
1598
        destroy(): void;
1599
    }
1600
    export interface WriteStream extends stream.Writable {
1601
        close(): void;
1602
        bytesWritten: number;
1603
        path: string | Buffer;
1604
    }
1605

    
1606
    /**
1607
     * Asynchronous rename.
1608
     * @param oldPath
1609
     * @param newPath
1610
     * @param callback No arguments other than a possible exception are given to the completion callback.
1611
     */
1612
    export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1613
    /**
1614
     * Synchronous rename
1615
     * @param oldPath
1616
     * @param newPath
1617
     */
1618
    export function renameSync(oldPath: string, newPath: string): void;
1619
    export function truncate(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void;
1620
    export function truncate(path: string | Buffer, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1621
    export function truncateSync(path: string | Buffer, len?: number): void;
1622
    export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1623
    export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1624
    export function ftruncateSync(fd: number, len?: number): void;
1625
    export function chown(path: string | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1626
    export function chownSync(path: string | Buffer, uid: number, gid: number): void;
1627
    export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1628
    export function fchownSync(fd: number, uid: number, gid: number): void;
1629
    export function lchown(path: string | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1630
    export function lchownSync(path: string | Buffer, uid: number, gid: number): void;
1631
    export function chmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1632
    export function chmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1633
    export function chmodSync(path: string | Buffer, mode: number): void;
1634
    export function chmodSync(path: string | Buffer, mode: string): void;
1635
    export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1636
    export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1637
    export function fchmodSync(fd: number, mode: number): void;
1638
    export function fchmodSync(fd: number, mode: string): void;
1639
    export function lchmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1640
    export function lchmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1641
    export function lchmodSync(path: string | Buffer, mode: number): void;
1642
    export function lchmodSync(path: string | Buffer, mode: string): void;
1643
    export function stat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
1644
    export function lstat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
1645
    export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
1646
    export function statSync(path: string | Buffer): Stats;
1647
    export function lstatSync(path: string | Buffer): Stats;
1648
    export function fstatSync(fd: number): Stats;
1649
    export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void;
1650
    export function linkSync(srcpath: string | Buffer, dstpath: string | Buffer): void;
1651
    export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1652
    export function symlinkSync(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): void;
1653
    export function readlink(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void;
1654
    export function readlinkSync(path: string | Buffer): string;
1655
    export function realpath(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
1656
    export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
1657
    export function realpathSync(path: string | Buffer, cache?: { [path: string]: string }): string;
1658
    /*
1659
     * Asynchronous unlink - deletes the file specified in {path}
1660
     *
1661
     * @param path
1662
     * @param callback No arguments other than a possible exception are given to the completion callback.
1663
     */
1664
    export function unlink(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void;
1665
    /*
1666
     * Synchronous unlink - deletes the file specified in {path}
1667
     *
1668
     * @param path
1669
     */
1670
    export function unlinkSync(path: string | Buffer): void;
1671
    /*
1672
     * Asynchronous rmdir - removes the directory specified in {path}
1673
     *
1674
     * @param path
1675
     * @param callback No arguments other than a possible exception are given to the completion callback.
1676
     */
1677
    export function rmdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void;
1678
    /*
1679
     * Synchronous rmdir - removes the directory specified in {path}
1680
     *
1681
     * @param path
1682
     */
1683
    export function rmdirSync(path: string | Buffer): void;
1684
    /*
1685
     * Asynchronous mkdir - creates the directory specified in {path}.  Parameter {mode} defaults to 0777.
1686
     *
1687
     * @param path
1688
     * @param callback No arguments other than a possible exception are given to the completion callback.
1689
     */
1690
    export function mkdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void;
1691
    /*
1692
     * Asynchronous mkdir - creates the directory specified in {path}.  Parameter {mode} defaults to 0777.
1693
     *
1694
     * @param path
1695
     * @param mode
1696
     * @param callback No arguments other than a possible exception are given to the completion callback.
1697
     */
1698
    export function mkdir(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1699
    /*
1700
     * Asynchronous mkdir - creates the directory specified in {path}.  Parameter {mode} defaults to 0777.
1701
     *
1702
     * @param path
1703
     * @param mode
1704
     * @param callback No arguments other than a possible exception are given to the completion callback.
1705
     */
1706
    export function mkdir(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1707
    /*
1708
     * Synchronous mkdir - creates the directory specified in {path}.  Parameter {mode} defaults to 0777.
1709
     *
1710
     * @param path
1711
     * @param mode
1712
     * @param callback No arguments other than a possible exception are given to the completion callback.
1713
     */
1714
    export function mkdirSync(path: string | Buffer, mode?: number): void;
1715
    /*
1716
     * Synchronous mkdir - creates the directory specified in {path}.  Parameter {mode} defaults to 0777.
1717
     *
1718
     * @param path
1719
     * @param mode
1720
     * @param callback No arguments other than a possible exception are given to the completion callback.
1721
     */
1722
    export function mkdirSync(path: string | Buffer, mode?: string): void;
1723
    /*
1724
     * Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1725
     *
1726
     * @param prefix
1727
     * @param callback The created folder path is passed as a string to the callback's second parameter.
1728
     */
1729
    export function mkdtemp(prefix: string, callback?: (err: NodeJS.ErrnoException, folder: string) => void): void;
1730
    /*
1731
     * Synchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1732
     *
1733
     * @param prefix
1734
     * @returns Returns the created folder path.
1735
     */
1736
    export function mkdtempSync(prefix: string): string;
1737
    export function readdir(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void;
1738
    export function readdirSync(path: string | Buffer): string[];
1739
    export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1740
    export function closeSync(fd: number): void;
1741
    export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void;
1742
    export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void;
1743
    export function openSync(path: string | Buffer, flags: string | number, mode?: number): number;
1744
    export function utimes(path: string | Buffer, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1745
    export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void;
1746
    export function utimesSync(path: string | Buffer, atime: number, mtime: number): void;
1747
    export function utimesSync(path: string | Buffer, atime: Date, mtime: Date): void;
1748
    export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1749
    export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void;
1750
    export function futimesSync(fd: number, atime: number, mtime: number): void;
1751
    export function futimesSync(fd: number, atime: Date, mtime: Date): void;
1752
    export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1753
    export function fsyncSync(fd: number): void;
1754
    export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
1755
    export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
1756
    export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
1757
    export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
1758
    export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
1759
    export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position?: number): number;
1760
    export function writeSync(fd: number, data: any, position?: number, enconding?: string): number;
1761
    export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void;
1762
    export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
1763
    /*
1764
     * Asynchronous readFile - Asynchronously reads the entire contents of a file.
1765
     *
1766
     * @param fileName
1767
     * @param encoding
1768
     * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
1769
     */
1770
    export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
1771
    /*
1772
     * Asynchronous readFile - Asynchronously reads the entire contents of a file.
1773
     *
1774
     * @param fileName
1775
     * @param options An object with optional {encoding} and {flag} properties.  If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer.
1776
     * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
1777
     */
1778
    export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
1779
    /*
1780
     * Asynchronous readFile - Asynchronously reads the entire contents of a file.
1781
     *
1782
     * @param fileName
1783
     * @param options An object with optional {encoding} and {flag} properties.  If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer.
1784
     * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
1785
     */
1786
    export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
1787
    /*
1788
     * Asynchronous readFile - Asynchronously reads the entire contents of a file.
1789
     *
1790
     * @param fileName
1791
     * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
1792
     */
1793
    export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
1794
    /*
1795
     * Synchronous readFile - Synchronously reads the entire contents of a file.
1796
     *
1797
     * @param fileName
1798
     * @param encoding
1799
     */
1800
    export function readFileSync(filename: string, encoding: string): string;
1801
    /*
1802
     * Synchronous readFile - Synchronously reads the entire contents of a file.
1803
     *
1804
     * @param fileName
1805
     * @param options An object with optional {encoding} and {flag} properties.  If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer.
1806
     */
1807
    export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string;
1808
    /*
1809
     * Synchronous readFile - Synchronously reads the entire contents of a file.
1810
     *
1811
     * @param fileName
1812
     * @param options An object with optional {encoding} and {flag} properties.  If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer.
1813
     */
1814
    export function readFileSync(filename: string, options?: { flag?: string; }): Buffer;
1815
    export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
1816
    export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
1817
    export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
1818
    export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
1819
    export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
1820
    export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
1821
    export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
1822
    export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
1823
    export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
1824
    export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
1825
    export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void;
1826
    export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void;
1827
    export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void;
1828
    export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher;
1829
    export function watch(filename: string, encoding: string, listener?: (event: string, filename: string | Buffer) => any): FSWatcher;
1830
    export function watch(filename: string, options: { persistent?: boolean; recursive?: boolean; encoding?: string }, listener?: (event: string, filename: string | Buffer) => any): FSWatcher;
1831
    export function exists(path: string | Buffer, callback?: (exists: boolean) => void): void;
1832
    export function existsSync(path: string | Buffer): boolean;
1833

    
1834
    interface Constants {
1835
        /** Constant for fs.access(). File is visible to the calling process. */
1836
        F_OK: number;
1837

    
1838
        /** Constant for fs.access(). File can be read by the calling process. */
1839
        R_OK: number;
1840

    
1841
        /** Constant for fs.access(). File can be written by the calling process. */
1842
        W_OK: number;
1843

    
1844
        /** Constant for fs.access(). File can be executed by the calling process. */
1845
        X_OK: number;
1846
    }
1847

    
1848
    export const constants: Constants;
1849
    
1850
    /** Tests a user's permissions for the file specified by path. */
1851
    export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
1852
    export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void;
1853
    /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */
1854
    export function accessSync(path: string | Buffer, mode?: number): void;
1855
    export function createReadStream(path: string | Buffer, options?: {
1856
        flags?: string;
1857
        encoding?: string;
1858
        fd?: number;
1859
        mode?: number;
1860
        autoClose?: boolean;
1861
        start?: number;
1862
        end?: number;
1863
    }): ReadStream;
1864
    export function createWriteStream(path: string | Buffer, options?: {
1865
        flags?: string;
1866
        encoding?: string;
1867
        fd?: number;
1868
        mode?: number;
1869
    }): WriteStream;
1870
    export function fdatasync(fd: number, callback: Function): void;
1871
    export function fdatasyncSync(fd: number): void;
1872
}
1873

    
1874
declare module "path" {
1875

    
1876
    /**
1877
     * A parsed path object generated by path.parse() or consumed by path.format().
1878
     */
1879
    export interface ParsedPath {
1880
        /**
1881
         * The root of the path such as '/' or 'c:\'
1882
         */
1883
        root: string;
1884
        /**
1885
         * The full directory path such as '/home/user/dir' or 'c:\path\dir'
1886
         */
1887
        dir: string;
1888
        /**
1889
         * The file name including extension (if any) such as 'index.html'
1890
         */
1891
        base: string;
1892
        /**
1893
         * The file extension (if any) such as '.html'
1894
         */
1895
        ext: string;
1896
        /**
1897
         * The file name without extension (if any) such as 'index'
1898
         */
1899
        name: string;
1900
    }
1901

    
1902
    /**
1903
     * Normalize a string path, reducing '..' and '.' parts.
1904
     * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
1905
     *
1906
     * @param p string path to normalize.
1907
     */
1908
    export function normalize(p: string): string;
1909
    /**
1910
     * Join all arguments together and normalize the resulting path.
1911
     * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
1912
     *
1913
     * @param paths string paths to join.
1914
     */
1915
    export function join(...paths: any[]): string;
1916
    /**
1917
     * Join all arguments together and normalize the resulting path.
1918
     * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
1919
     *
1920
     * @param paths string paths to join.
1921
     */
1922
    export function join(...paths: string[]): string;
1923
    /**
1924
     * The right-most parameter is considered {to}.  Other parameters are considered an array of {from}.
1925
     *
1926
     * Starting from leftmost {from} paramter, resolves {to} to an absolute path.
1927
     *
1928
     * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory.
1929
     *
1930
     * @param pathSegments string paths to join.  Non-string arguments are ignored.
1931
     */
1932
    export function resolve(...pathSegments: any[]): string;
1933
    /**
1934
     * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
1935
     *
1936
     * @param path path to test.
1937
     */
1938
    export function isAbsolute(path: string): boolean;
1939
    /**
1940
     * Solve the relative path from {from} to {to}.
1941
     * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
1942
     *
1943
     * @param from
1944
     * @param to
1945
     */
1946
    export function relative(from: string, to: string): string;
1947
    /**
1948
     * Return the directory name of a path. Similar to the Unix dirname command.
1949
     *
1950
     * @param p the path to evaluate.
1951
     */
1952
    export function dirname(p: string): string;
1953
    /**
1954
     * Return the last portion of a path. Similar to the Unix basename command.
1955
     * Often used to extract the file name from a fully qualified path.
1956
     *
1957
     * @param p the path to evaluate.
1958
     * @param ext optionally, an extension to remove from the result.
1959
     */
1960
    export function basename(p: string, ext?: string): string;
1961
    /**
1962
     * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
1963
     * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
1964
     *
1965
     * @param p the path to evaluate.
1966
     */
1967
    export function extname(p: string): string;
1968
    /**
1969
     * The platform-specific file separator. '\\' or '/'.
1970
     */
1971
    export var sep: string;
1972
    /**
1973
     * The platform-specific file delimiter. ';' or ':'.
1974
     */
1975
    export var delimiter: string;
1976
    /**
1977
     * Returns an object from a path string - the opposite of format().
1978
     *
1979
     * @param pathString path to evaluate.
1980
     */
1981
    export function parse(pathString: string): ParsedPath;
1982
    /**
1983
     * Returns a path string from an object - the opposite of parse().
1984
     *
1985
     * @param pathString path to evaluate.
1986
     */
1987
    export function format(pathObject: ParsedPath): string;
1988

    
1989
    export module posix {
1990
        export function normalize(p: string): string;
1991
        export function join(...paths: any[]): string;
1992
        export function resolve(...pathSegments: any[]): string;
1993
        export function isAbsolute(p: string): boolean;
1994
        export function relative(from: string, to: string): string;
1995
        export function dirname(p: string): string;
1996
        export function basename(p: string, ext?: string): string;
1997
        export function extname(p: string): string;
1998
        export var sep: string;
1999
        export var delimiter: string;
2000
        export function parse(p: string): ParsedPath;
2001
        export function format(pP: ParsedPath): string;
2002
    }
2003

    
2004
    export module win32 {
2005
        export function normalize(p: string): string;
2006
        export function join(...paths: any[]): string;
2007
        export function resolve(...pathSegments: any[]): string;
2008
        export function isAbsolute(p: string): boolean;
2009
        export function relative(from: string, to: string): string;
2010
        export function dirname(p: string): string;
2011
        export function basename(p: string, ext?: string): string;
2012
        export function extname(p: string): string;
2013
        export var sep: string;
2014
        export var delimiter: string;
2015
        export function parse(p: string): ParsedPath;
2016
        export function format(pP: ParsedPath): string;
2017
    }
2018
}
2019

    
2020
declare module "string_decoder" {
2021
    export interface NodeStringDecoder {
2022
        write(buffer: Buffer): string;
2023
        end(buffer?: Buffer): string;
2024
    }
2025
    export var StringDecoder: {
2026
        new (encoding?: string): NodeStringDecoder;
2027
    };
2028
}
2029

    
2030
declare module "tls" {
2031
    import * as crypto from "crypto";
2032
    import * as net from "net";
2033
    import * as stream from "stream";
2034

    
2035
    var CLIENT_RENEG_LIMIT: number;
2036
    var CLIENT_RENEG_WINDOW: number;
2037

    
2038
    export interface Certificate {
2039
        /**
2040
         * Country code.
2041
         */
2042
        C: string;
2043
        /**
2044
         * Street.
2045
         */
2046
        ST: string;
2047
        /**
2048
         * Locality.
2049
         */
2050
        L: string;
2051
        /**
2052
         * Organization.
2053
         */
2054
        O: string;
2055
        /**
2056
         * Organizational unit.
2057
         */
2058
        OU: string;
2059
        /**
2060
         * Common name.
2061
         */
2062
        CN: string;
2063
    }
2064

    
2065
    export interface CipherNameAndProtocol {
2066
        /**
2067
         * The cipher name.
2068
         */
2069
        name: string;
2070
        /**
2071
         * SSL/TLS protocol version.
2072
         */
2073
        version: string;
2074
    }
2075

    
2076
    export class TLSSocket extends stream.Duplex {
2077
        /**
2078
         * Returns the bound address, the address family name and port of the underlying socket as reported by
2079
         * the operating system.
2080
         * @returns {any} - An object with three properties, e.g. { port: 12346, family: 'IPv4', address: '127.0.0.1' }.
2081
         */
2082
        address(): { port: number; family: string; address: string };
2083
        /**
2084
         * A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false.
2085
         */
2086
        authorized: boolean;
2087
        /**
2088
         * The reason why the peer's certificate has not been verified.
2089
         * This property becomes available only when tlsSocket.authorized === false.
2090
         */
2091
        authorizationError: Error;
2092
        /**
2093
         * Static boolean value, always true.
2094
         * May be used to distinguish TLS sockets from regular ones.
2095
         */
2096
        encrypted: boolean;
2097
        /**
2098
         * Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection.
2099
         * @returns {CipherNameAndProtocol} - Returns an object representing the cipher name
2100
         * and the SSL/TLS protocol version of the current connection.
2101
         */
2102
        getCipher(): CipherNameAndProtocol;
2103
        /**
2104
         * Returns an object representing the peer's certificate.
2105
         * The returned object has some properties corresponding to the field of the certificate.
2106
         * If detailed argument is true the full chain with issuer property will be returned,
2107
         * if false only the top certificate without issuer property.
2108
         * If the peer does not provide a certificate, it returns null or an empty object.
2109
         * @param {boolean} detailed - If true; the full chain with issuer property will be returned.
2110
         * @returns {any} - An object representing the peer's certificate.
2111
         */
2112
        getPeerCertificate(detailed?: boolean): {
2113
            subject: Certificate;
2114
            issuerInfo: Certificate;
2115
            issuer: Certificate;
2116
            raw: any;
2117
            valid_from: string;
2118
            valid_to: string;
2119
            fingerprint: string;
2120
            serialNumber: string;
2121
        };
2122
        /**
2123
         * Could be used to speed up handshake establishment when reconnecting to the server.
2124
         * @returns {any} - ASN.1 encoded TLS session or undefined if none was negotiated.
2125
         */
2126
        getSession(): any;
2127
        /**
2128
         * NOTE: Works only with client TLS sockets.
2129
         * Useful only for debugging, for session reuse provide session option to tls.connect().
2130
         * @returns {any} - TLS session ticket or undefined if none was negotiated.
2131
         */
2132
        getTLSTicket(): any;
2133
        /**
2134
         * The string representation of the local IP address.
2135
         */
2136
        localAddress: string;
2137
        /**
2138
         * The numeric representation of the local port.
2139
         */
2140
        localPort: string;
2141
        /**
2142
         * The string representation of the remote IP address.
2143
         * For example, '74.125.127.100' or '2001:4860:a005::68'.
2144
         */
2145
        remoteAddress: string;
2146
        /**
2147
         * The string representation of the remote IP family. 'IPv4' or 'IPv6'.
2148
         */
2149
        remoteFamily: string;
2150
        /**
2151
         * The numeric representation of the remote port. For example, 443.
2152
         */
2153
        remotePort: number;
2154
        /**
2155
         * Initiate TLS renegotiation process.
2156
         *
2157
         * NOTE: Can be used to request peer's certificate after the secure connection has been established.
2158
         * ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout.
2159
         * @param {TlsOptions} options - The options may contain the following fields: rejectUnauthorized,
2160
         * requestCert (See tls.createServer() for details).
2161
         * @param {Function} callback - callback(err) will be executed with null as err, once the renegotiation
2162
         * is successfully completed.
2163
         */
2164
        renegotiate(options: TlsOptions, callback: (err: Error) => any): any;
2165
        /**
2166
         * Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512).
2167
         * Smaller fragment size decreases buffering latency on the client: large fragments are buffered by
2168
         * the TLS layer until the entire fragment is received and its integrity is verified;
2169
         * large fragments can span multiple roundtrips, and their processing can be delayed due to packet
2170
         * loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead,
2171
         * which may decrease overall server throughput.
2172
         * @param {number} size - TLS fragment size (default and maximum value is: 16384, minimum is: 512).
2173
         * @returns {boolean} - Returns true on success, false otherwise.
2174
         */
2175
        setMaxSendFragment(size: number): boolean;
2176
    }
2177

    
2178
    export interface TlsOptions {
2179
        host?: string;
2180
        port?: number;
2181
        pfx?: string | Buffer[];
2182
        key?: string | string[] | Buffer | any[];
2183
        passphrase?: string;
2184
        cert?: string | string[] | Buffer | Buffer[];
2185
        ca?: string | string[] | Buffer | Buffer[];
2186
        crl?: string | string[];
2187
        ciphers?: string;
2188
        honorCipherOrder?: boolean;
2189
        requestCert?: boolean;
2190
        rejectUnauthorized?: boolean;
2191
        NPNProtocols?: string[] | Buffer;
2192
        SNICallback?: (servername: string, cb:(err:Error,ctx:SecureContext)=>any) => any;
2193
        ecdhCurve?: string;
2194
        dhparam?: string | Buffer;
2195
        handshakeTimeout?: number;
2196
        ALPNProtocols?: string[] | Buffer;
2197
        sessionTimeout?: number;
2198
        ticketKeys?: any;
2199
        sessionIdContext?: string;
2200
        secureProtocol?: string;
2201
    }
2202

    
2203
    export interface ConnectionOptions {
2204
        host?: string;
2205
        port?: number;
2206
        socket?: net.Socket;
2207
        pfx?: string | Buffer
2208
        key?: string |string[] | Buffer | Buffer[];
2209
        passphrase?: string;
2210
        cert?: string | string[] | Buffer | Buffer[];
2211
        ca?: string | Buffer | (string | Buffer)[];
2212
        rejectUnauthorized?: boolean;
2213
        NPNProtocols?: (string | Buffer)[];
2214
        servername?: string;
2215
        path?: string;
2216
        ALPNProtocols?: (string | Buffer)[];
2217
        checkServerIdentity?: (servername: string, cert: string | Buffer | (string | Buffer)[]) => any;
2218
        secureProtocol?: string;
2219
        secureContext?: Object;
2220
        session?: Buffer;
2221
        minDHSize?: number;
2222
    }
2223

    
2224
    export interface Server extends net.Server {
2225
        close(): Server;
2226
        address(): { port: number; family: string; address: string; };
2227
        addContext(hostName: string, credentials: {
2228
            key: string;
2229
            cert: string;
2230
            ca: string;
2231
        }): void;
2232
        maxConnections: number;
2233
        connections: number;
2234
    }
2235

    
2236
    export interface ClearTextStream extends stream.Duplex {
2237
        authorized: boolean;
2238
        authorizationError: Error;
2239
        getPeerCertificate(): any;
2240
        getCipher: {
2241
            name: string;
2242
            version: string;
2243
        };
2244
        address: {
2245
            port: number;
2246
            family: string;
2247
            address: string;
2248
        };
2249
        remoteAddress: string;
2250
        remotePort: number;
2251
    }
2252

    
2253
    export interface SecurePair {
2254
        encrypted: any;
2255
        cleartext: any;
2256
    }
2257

    
2258
    export interface SecureContextOptions {
2259
        pfx?: string | Buffer;
2260
        key?: string | Buffer;
2261
        passphrase?: string;
2262
        cert?: string | Buffer;
2263
        ca?: string | Buffer;
2264
        crl?: string | string[]
2265
        ciphers?: string;
2266
        honorCipherOrder?: boolean;
2267
    }
2268

    
2269
    export interface SecureContext {
2270
        context: any;
2271
    }
2272

    
2273
    export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) => void): Server;
2274
    export function connect(options: ConnectionOptions, secureConnectionListener?: () => void): ClearTextStream;
2275
    export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): ClearTextStream;
2276
    export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): ClearTextStream;
2277
    export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
2278
    export function createSecureContext(details: SecureContextOptions): SecureContext;
2279
}
2280

    
2281
declare module "crypto" {
2282
    export interface Certificate {
2283
        exportChallenge(spkac: string | Buffer): Buffer;
2284
        exportPublicKey(spkac: string | Buffer): Buffer;
2285
        verifySpkac(spkac: Buffer): boolean;
2286
    }
2287
    export var Certificate: {
2288
        new (): Certificate;
2289
        (): Certificate;
2290
    }
2291

    
2292
    export var fips: boolean;
2293

    
2294
    export interface CredentialDetails {
2295
        pfx: string;
2296
        key: string;
2297
        passphrase: string;
2298
        cert: string;
2299
        ca: string | string[];
2300
        crl: string | string[];
2301
        ciphers: string;
2302
    }
2303
    export interface Credentials { context?: any; }
2304
    export function createCredentials(details: CredentialDetails): Credentials;
2305
    export function createHash(algorithm: string): Hash;
2306
    export function createHmac(algorithm: string, key: string | Buffer): Hmac;
2307

    
2308
    type Utf8AsciiLatin1Encoding = "utf8" | "ascii" | "latin1";
2309
    type HexBase64Latin1Encoding = "latin1" | "hex" | "base64";
2310
    type Utf8AsciiBinaryEncoding = "utf8" | "ascii" | "binary";
2311
    type HexBase64BinaryEncoding = "binary" | "base64" | "hex";
2312
    type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
2313

    
2314
    export interface Hash extends NodeJS.ReadWriteStream {
2315
        update(data: string | Buffer): Hash;
2316
        update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hash;
2317
        digest(): Buffer;
2318
        digest(encoding: HexBase64Latin1Encoding): string;
2319
    }
2320
    export interface Hmac extends NodeJS.ReadWriteStream {
2321
        update(data: string | Buffer): Hmac;
2322
        update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hmac;
2323
        digest(): Buffer;
2324
        digest(encoding: HexBase64Latin1Encoding): string;
2325
    }
2326
    export function createCipher(algorithm: string, password: any): Cipher;
2327
    export function createCipheriv(algorithm: string, key: any, iv: any): Cipher;
2328
    export interface Cipher extends NodeJS.ReadWriteStream {
2329
        update(data: Buffer): Buffer;
2330
        update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer;
2331
        update(data: Buffer, input_encoding: any, output_encoding: HexBase64BinaryEncoding): string;
2332
        update(data: string, input_encoding: Utf8AsciiBinaryEncoding, output_encoding: HexBase64BinaryEncoding): string;
2333
        final(): Buffer;
2334
        final(output_encoding: string): string;
2335
        setAutoPadding(auto_padding?: boolean): void;
2336
        getAuthTag(): Buffer;
2337
        setAAD(buffer: Buffer): void;
2338
    }
2339
    export function createDecipher(algorithm: string, password: any): Decipher;
2340
    export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher;
2341
    export interface Decipher extends NodeJS.ReadWriteStream {
2342
        update(data: Buffer): Buffer;
2343
        update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer;
2344
        update(data: Buffer, input_encoding: any, output_encoding: Utf8AsciiBinaryEncoding): string;
2345
        update(data: string, input_encoding: HexBase64BinaryEncoding, output_encoding: Utf8AsciiBinaryEncoding): string;
2346
        final(): Buffer;
2347
        final(output_encoding: string): string;
2348
        setAutoPadding(auto_padding?: boolean): void;
2349
        setAuthTag(tag: Buffer): void;
2350
        setAAD(buffer: Buffer): void;
2351
    }
2352
    export function createSign(algorithm: string): Signer;
2353
    export interface Signer extends NodeJS.WritableStream {
2354
        update(data: string | Buffer): Signer;
2355
        update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Signer;
2356
        sign(private_key: string | { key: string; passphrase: string }): Buffer;
2357
        sign(private_key: string | { key: string; passphrase: string }, output_format: HexBase64Latin1Encoding): string;
2358
    }
2359
    export function createVerify(algorith: string): Verify;
2360
    export interface Verify extends NodeJS.WritableStream {
2361
        update(data: string | Buffer): Verify;
2362
        update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Verify;
2363
        verify(object: string, signature: Buffer): boolean;
2364
        verify(object: string, signature: string, signature_format: HexBase64Latin1Encoding): boolean;
2365
    }
2366
    export function createDiffieHellman(prime_length: number, generator?: number): DiffieHellman;
2367
    export function createDiffieHellman(prime: Buffer): DiffieHellman;
2368
    export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman;
2369
    export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | Buffer): DiffieHellman;
2370
    export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman;
2371
    export interface DiffieHellman {
2372
        generateKeys(): Buffer;
2373
        generateKeys(encoding: HexBase64Latin1Encoding): string;
2374
        computeSecret(other_public_key: Buffer): Buffer;
2375
        computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
2376
        computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
2377
        getPrime(): Buffer;
2378
        getPrime(encoding: HexBase64Latin1Encoding): string;
2379
        getGenerator(): Buffer;
2380
        getGenerator(encoding: HexBase64Latin1Encoding): string;
2381
        getPublicKey(): Buffer;
2382
        getPublicKey(encoding: HexBase64Latin1Encoding): string;
2383
        getPrivateKey(): Buffer;
2384
        getPrivateKey(encoding: HexBase64Latin1Encoding): string;
2385
        setPublicKey(public_key: Buffer): void;
2386
        setPublicKey(public_key: string, encoding: string): void;
2387
        setPrivateKey(private_key: Buffer): void;
2388
        setPrivateKey(private_key: string, encoding: string): void;
2389
        verifyError: number;
2390
    }
2391
    export function getDiffieHellman(group_name: string): DiffieHellman;
2392
    export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void;
2393
    export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string): Buffer;
2394
    export function randomBytes(size: number): Buffer;
2395
    export function randomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void;
2396
    export function pseudoRandomBytes(size: number): Buffer;
2397
    export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void;
2398
    export interface RsaPublicKey {
2399
        key: string;
2400
        padding?: number;
2401
    }
2402
    export interface RsaPrivateKey {
2403
        key: string;
2404
        passphrase?: string,
2405
        padding?: number;
2406
    }
2407
    export function publicEncrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer
2408
    export function privateDecrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer
2409
    export function privateEncrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer
2410
    export function publicDecrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer
2411
    export function getCiphers(): string[];
2412
    export function getCurves(): string[];
2413
    export function getHashes(): string[];
2414
    export interface ECDH {
2415
        generateKeys(): Buffer;
2416
        generateKeys(encoding: HexBase64Latin1Encoding): string;
2417
        generateKeys(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string;
2418
        computeSecret(other_public_key: Buffer): Buffer;
2419
        computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
2420
        computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
2421
        getPrivateKey(): Buffer;
2422
        getPrivateKey(encoding: HexBase64Latin1Encoding): string;
2423
        getPublicKey(): Buffer;
2424
        getPublicKey(encoding: HexBase64Latin1Encoding): string;
2425
        getPublicKey(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string;
2426
        setPrivateKey(private_key: Buffer): void;
2427
        setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void;
2428
    }
2429
    export function createECDH(curve_name: string): ECDH;
2430
}
2431

    
2432
declare module "stream" {
2433
    import * as events from "events";
2434

    
2435
    class internal extends events.EventEmitter {
2436
        pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
2437
    }
2438
    namespace internal {
2439

    
2440
        export class Stream extends internal {}
2441

    
2442
        export interface ReadableOptions {
2443
            highWaterMark?: number;
2444
            encoding?: string;
2445
            objectMode?: boolean;
2446
            read?: (size?: number) => any;
2447
        }
2448

    
2449
        export class Readable extends events.EventEmitter implements NodeJS.ReadableStream {
2450
            readable: boolean;
2451
            constructor(opts?: ReadableOptions);
2452
            _read(size: number): void;
2453
            read(size?: number): any;
2454
            setEncoding(encoding: string): void;
2455
            pause(): Readable;
2456
            resume(): Readable;
2457
            pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
2458
            unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
2459
            unshift(chunk: any): void;
2460
            wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
2461
            push(chunk: any, encoding?: string): boolean;
2462
        }
2463

    
2464
        export interface WritableOptions {
2465
            highWaterMark?: number;
2466
            decodeStrings?: boolean;
2467
            objectMode?: boolean;
2468
            write?: (chunk: string|Buffer, encoding: string, callback: Function) => any;
2469
            writev?: (chunks: {chunk: string|Buffer, encoding: string}[], callback: Function) => any;
2470
        }
2471

    
2472
        export class Writable extends events.EventEmitter implements NodeJS.WritableStream {
2473
            writable: boolean;
2474
            constructor(opts?: WritableOptions);
2475
            _write(chunk: any, encoding: string, callback: Function): void;
2476
            write(chunk: any, cb?: Function): boolean;
2477
            write(chunk: any, encoding?: string, cb?: Function): boolean;
2478
            end(): void;
2479
            end(chunk: any, cb?: Function): void;
2480
            end(chunk: any, encoding?: string, cb?: Function): void;
2481
        }
2482

    
2483
        export interface DuplexOptions extends ReadableOptions, WritableOptions {
2484
            allowHalfOpen?: boolean;
2485
            readableObjectMode?: boolean;
2486
            writableObjectMode?: boolean;
2487
        }
2488

    
2489
        // Note: Duplex extends both Readable and Writable.
2490
        export class Duplex extends Readable implements NodeJS.ReadWriteStream {
2491
            // Readable
2492
            pause(): Duplex;
2493
            resume(): Duplex;
2494
            // Writeable
2495
            writable: boolean;
2496
            constructor(opts?: DuplexOptions);
2497
            _write(chunk: any, encoding: string, callback: Function): void;
2498
            write(chunk: any, cb?: Function): boolean;
2499
            write(chunk: any, encoding?: string, cb?: Function): boolean;
2500
            end(): void;
2501
            end(chunk: any, cb?: Function): void;
2502
            end(chunk: any, encoding?: string, cb?: Function): void;
2503
        }
2504

    
2505
        export interface TransformOptions extends ReadableOptions, WritableOptions {
2506
            transform?: (chunk: string|Buffer, encoding: string, callback: Function) => any;
2507
            flush?: (callback: Function) => any;
2508
        }
2509

    
2510
        // Note: Transform lacks the _read and _write methods of Readable/Writable.
2511
        export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream {
2512
            readable: boolean;
2513
            writable: boolean;
2514
            constructor(opts?: TransformOptions);
2515
            _transform(chunk: any, encoding: string, callback: Function): void;
2516
            _flush(callback: Function): void;
2517
            read(size?: number): any;
2518
            setEncoding(encoding: string): void;
2519
            pause(): Transform;
2520
            resume(): Transform;
2521
            pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
2522
            unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
2523
            unshift(chunk: any): void;
2524
            wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
2525
            push(chunk: any, encoding?: string): boolean;
2526
            write(chunk: any, cb?: Function): boolean;
2527
            write(chunk: any, encoding?: string, cb?: Function): boolean;
2528
            end(): void;
2529
            end(chunk: any, cb?: Function): void;
2530
            end(chunk: any, encoding?: string, cb?: Function): void;
2531
        }
2532

    
2533
        export class PassThrough extends Transform { }
2534
    }
2535

    
2536
    export = internal;
2537
}
2538

    
2539
declare module "util" {
2540
    export interface InspectOptions {
2541
        showHidden?: boolean;
2542
        depth?: number;
2543
        colors?: boolean;
2544
        customInspect?: boolean;
2545
    }
2546

    
2547
    export function format(format: any, ...param: any[]): string;
2548
    export function debug(string: string): void;
2549
    export function error(...param: any[]): void;
2550
    export function puts(...param: any[]): void;
2551
    export function print(...param: any[]): void;
2552
    export function log(string: string): void;
2553
    export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string;
2554
    export function inspect(object: any, options: InspectOptions): string;
2555
    export function isArray(object: any): boolean;
2556
    export function isRegExp(object: any): boolean;
2557
    export function isDate(object: any): boolean;
2558
    export function isError(object: any): boolean;
2559
    export function inherits(constructor: any, superConstructor: any): void;
2560
    export function debuglog(key: string): (msg: string, ...param: any[]) => void;
2561
    export function isBoolean(object: any): boolean;
2562
    export function isBuffer(object: any): boolean;
2563
    export function isFunction(object: any): boolean;
2564
    export function isNull(object: any): boolean;
2565
    export function isNullOrUndefined(object: any): boolean;
2566
    export function isNumber(object: any): boolean;
2567
    export function isObject(object: any): boolean;
2568
    export function isPrimitive(object: any): boolean;
2569
    export function isString(object: any): boolean;
2570
    export function isSymbol(object: any): boolean;
2571
    export function isUndefined(object: any): boolean;
2572
    export function deprecate(fn: Function, message: string): Function;
2573
}
2574

    
2575
declare module "assert" {
2576
    function internal(value: any, message?: string): void;
2577
    namespace internal {
2578
        export class AssertionError implements Error {
2579
            name: string;
2580
            message: string;
2581
            actual: any;
2582
            expected: any;
2583
            operator: string;
2584
            generatedMessage: boolean;
2585

    
2586
            constructor(options?: {
2587
                message?: string; actual?: any; expected?: any;
2588
                operator?: string; stackStartFunction?: Function
2589
            });
2590
        }
2591

    
2592
        export function fail(actual?: any, expected?: any, message?: string, operator?: string): void;
2593
        export function ok(value: any, message?: string): void;
2594
        export function equal(actual: any, expected: any, message?: string): void;
2595
        export function notEqual(actual: any, expected: any, message?: string): void;
2596
        export function deepEqual(actual: any, expected: any, message?: string): void;
2597
        export function notDeepEqual(acutal: any, expected: any, message?: string): void;
2598
        export function strictEqual(actual: any, expected: any, message?: string): void;
2599
        export function notStrictEqual(actual: any, expected: any, message?: string): void;
2600
        export function deepStrictEqual(actual: any, expected: any, message?: string): void;
2601
        export function notDeepStrictEqual(actual: any, expected: any, message?: string): void;
2602
        export var throws: {
2603
            (block: Function, message?: string): void;
2604
            (block: Function, error: Function, message?: string): void;
2605
            (block: Function, error: RegExp, message?: string): void;
2606
            (block: Function, error: (err: any) => boolean, message?: string): void;
2607
        };
2608

    
2609
        export var doesNotThrow: {
2610
            (block: Function, message?: string): void;
2611
            (block: Function, error: Function, message?: string): void;
2612
            (block: Function, error: RegExp, message?: string): void;
2613
            (block: Function, error: (err: any) => boolean, message?: string): void;
2614
        };
2615

    
2616
        export function ifError(value: any): void;
2617
    }
2618

    
2619
    export = internal;
2620
}
2621

    
2622
declare module "tty" {
2623
    import * as net from "net";
2624

    
2625
    export function isatty(fd: number): boolean;
2626
    export interface ReadStream extends net.Socket {
2627
        isRaw: boolean;
2628
        setRawMode(mode: boolean): void;
2629
        isTTY: boolean;
2630
    }
2631
    export interface WriteStream extends net.Socket {
2632
        columns: number;
2633
        rows: number;
2634
        isTTY: boolean;
2635
    }
2636
}
2637

    
2638
declare module "domain" {
2639
    import * as events from "events";
2640

    
2641
    export class Domain extends events.EventEmitter implements NodeJS.Domain {
2642
        run(fn: Function): void;
2643
        add(emitter: events.EventEmitter): void;
2644
        remove(emitter: events.EventEmitter): void;
2645
        bind(cb: (err: Error, data: any) => any): any;
2646
        intercept(cb: (data: any) => any): any;
2647
        dispose(): void;
2648
        members: any[];
2649
        enter(): void;
2650
        exit(): void;
2651
    }
2652

    
2653
    export function create(): Domain;
2654
}
2655

    
2656
declare module "constants" {
2657
    export var E2BIG: number;
2658
    export var EACCES: number;
2659
    export var EADDRINUSE: number;
2660
    export var EADDRNOTAVAIL: number;
2661
    export var EAFNOSUPPORT: number;
2662
    export var EAGAIN: number;
2663
    export var EALREADY: number;
2664
    export var EBADF: number;
2665
    export var EBADMSG: number;
2666
    export var EBUSY: number;
2667
    export var ECANCELED: number;
2668
    export var ECHILD: number;
2669
    export var ECONNABORTED: number;
2670
    export var ECONNREFUSED: number;
2671
    export var ECONNRESET: number;
2672
    export var EDEADLK: number;
2673
    export var EDESTADDRREQ: number;
2674
    export var EDOM: number;
2675
    export var EEXIST: number;
2676
    export var EFAULT: number;
2677
    export var EFBIG: number;
2678
    export var EHOSTUNREACH: number;
2679
    export var EIDRM: number;
2680
    export var EILSEQ: number;
2681
    export var EINPROGRESS: number;
2682
    export var EINTR: number;
2683
    export var EINVAL: number;
2684
    export var EIO: number;
2685
    export var EISCONN: number;
2686
    export var EISDIR: number;
2687
    export var ELOOP: number;
2688
    export var EMFILE: number;
2689
    export var EMLINK: number;
2690
    export var EMSGSIZE: number;
2691
    export var ENAMETOOLONG: number;
2692
    export var ENETDOWN: number;
2693
    export var ENETRESET: number;
2694
    export var ENETUNREACH: number;
2695
    export var ENFILE: number;
2696
    export var ENOBUFS: number;
2697
    export var ENODATA: number;
2698
    export var ENODEV: number;
2699
    export var ENOENT: number;
2700
    export var ENOEXEC: number;
2701
    export var ENOLCK: number;
2702
    export var ENOLINK: number;
2703
    export var ENOMEM: number;
2704
    export var ENOMSG: number;
2705
    export var ENOPROTOOPT: number;
2706
    export var ENOSPC: number;
2707
    export var ENOSR: number;
2708
    export var ENOSTR: number;
2709
    export var ENOSYS: number;
2710
    export var ENOTCONN: number;
2711
    export var ENOTDIR: number;
2712
    export var ENOTEMPTY: number;
2713
    export var ENOTSOCK: number;
2714
    export var ENOTSUP: number;
2715
    export var ENOTTY: number;
2716
    export var ENXIO: number;
2717
    export var EOPNOTSUPP: number;
2718
    export var EOVERFLOW: number;
2719
    export var EPERM: number;
2720
    export var EPIPE: number;
2721
    export var EPROTO: number;
2722
    export var EPROTONOSUPPORT: number;
2723
    export var EPROTOTYPE: number;
2724
    export var ERANGE: number;
2725
    export var EROFS: number;
2726
    export var ESPIPE: number;
2727
    export var ESRCH: number;
2728
    export var ETIME: number;
2729
    export var ETIMEDOUT: number;
2730
    export var ETXTBSY: number;
2731
    export var EWOULDBLOCK: number;
2732
    export var EXDEV: number;
2733
    export var WSAEINTR: number;
2734
    export var WSAEBADF: number;
2735
    export var WSAEACCES: number;
2736
    export var WSAEFAULT: number;
2737
    export var WSAEINVAL: number;
2738
    export var WSAEMFILE: number;
2739
    export var WSAEWOULDBLOCK: number;
2740
    export var WSAEINPROGRESS: number;
2741
    export var WSAEALREADY: number;
2742
    export var WSAENOTSOCK: number;
2743
    export var WSAEDESTADDRREQ: number;
2744
    export var WSAEMSGSIZE: number;
2745
    export var WSAEPROTOTYPE: number;
2746
    export var WSAENOPROTOOPT: number;
2747
    export var WSAEPROTONOSUPPORT: number;
2748
    export var WSAESOCKTNOSUPPORT: number;
2749
    export var WSAEOPNOTSUPP: number;
2750
    export var WSAEPFNOSUPPORT: number;
2751
    export var WSAEAFNOSUPPORT: number;
2752
    export var WSAEADDRINUSE: number;
2753
    export var WSAEADDRNOTAVAIL: number;
2754
    export var WSAENETDOWN: number;
2755
    export var WSAENETUNREACH: number;
2756
    export var WSAENETRESET: number;
2757
    export var WSAECONNABORTED: number;
2758
    export var WSAECONNRESET: number;
2759
    export var WSAENOBUFS: number;
2760
    export var WSAEISCONN: number;
2761
    export var WSAENOTCONN: number;
2762
    export var WSAESHUTDOWN: number;
2763
    export var WSAETOOMANYREFS: number;
2764
    export var WSAETIMEDOUT: number;
2765
    export var WSAECONNREFUSED: number;
2766
    export var WSAELOOP: number;
2767
    export var WSAENAMETOOLONG: number;
2768
    export var WSAEHOSTDOWN: number;
2769
    export var WSAEHOSTUNREACH: number;
2770
    export var WSAENOTEMPTY: number;
2771
    export var WSAEPROCLIM: number;
2772
    export var WSAEUSERS: number;
2773
    export var WSAEDQUOT: number;
2774
    export var WSAESTALE: number;
2775
    export var WSAEREMOTE: number;
2776
    export var WSASYSNOTREADY: number;
2777
    export var WSAVERNOTSUPPORTED: number;
2778
    export var WSANOTINITIALISED: number;
2779
    export var WSAEDISCON: number;
2780
    export var WSAENOMORE: number;
2781
    export var WSAECANCELLED: number;
2782
    export var WSAEINVALIDPROCTABLE: number;
2783
    export var WSAEINVALIDPROVIDER: number;
2784
    export var WSAEPROVIDERFAILEDINIT: number;
2785
    export var WSASYSCALLFAILURE: number;
2786
    export var WSASERVICE_NOT_FOUND: number;
2787
    export var WSATYPE_NOT_FOUND: number;
2788
    export var WSA_E_NO_MORE: number;
2789
    export var WSA_E_CANCELLED: number;
2790
    export var WSAEREFUSED: number;
2791
    export var SIGHUP: number;
2792
    export var SIGINT: number;
2793
    export var SIGILL: number;
2794
    export var SIGABRT: number;
2795
    export var SIGFPE: number;
2796
    export var SIGKILL: number;
2797
    export var SIGSEGV: number;
2798
    export var SIGTERM: number;
2799
    export var SIGBREAK: number;
2800
    export var SIGWINCH: number;
2801
    export var SSL_OP_ALL: number;
2802
    export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
2803
    export var SSL_OP_CIPHER_SERVER_PREFERENCE: number;
2804
    export var SSL_OP_CISCO_ANYCONNECT: number;
2805
    export var SSL_OP_COOKIE_EXCHANGE: number;
2806
    export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
2807
    export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
2808
    export var SSL_OP_EPHEMERAL_RSA: number;
2809
    export var SSL_OP_LEGACY_SERVER_CONNECT: number;
2810
    export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
2811
    export var SSL_OP_MICROSOFT_SESS_ID_BUG: number;
2812
    export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
2813
    export var SSL_OP_NETSCAPE_CA_DN_BUG: number;
2814
    export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
2815
    export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
2816
    export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
2817
    export var SSL_OP_NO_COMPRESSION: number;
2818
    export var SSL_OP_NO_QUERY_MTU: number;
2819
    export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
2820
    export var SSL_OP_NO_SSLv2: number;
2821
    export var SSL_OP_NO_SSLv3: number;
2822
    export var SSL_OP_NO_TICKET: number;
2823
    export var SSL_OP_NO_TLSv1: number;
2824
    export var SSL_OP_NO_TLSv1_1: number;
2825
    export var SSL_OP_NO_TLSv1_2: number;
2826
    export var SSL_OP_PKCS1_CHECK_1: number;
2827
    export var SSL_OP_PKCS1_CHECK_2: number;
2828
    export var SSL_OP_SINGLE_DH_USE: number;
2829
    export var SSL_OP_SINGLE_ECDH_USE: number;
2830
    export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
2831
    export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
2832
    export var SSL_OP_TLS_BLOCK_PADDING_BUG: number;
2833
    export var SSL_OP_TLS_D5_BUG: number;
2834
    export var SSL_OP_TLS_ROLLBACK_BUG: number;
2835
    export var ENGINE_METHOD_DSA: number;
2836
    export var ENGINE_METHOD_DH: number;
2837
    export var ENGINE_METHOD_RAND: number;
2838
    export var ENGINE_METHOD_ECDH: number;
2839
    export var ENGINE_METHOD_ECDSA: number;
2840
    export var ENGINE_METHOD_CIPHERS: number;
2841
    export var ENGINE_METHOD_DIGESTS: number;
2842
    export var ENGINE_METHOD_STORE: number;
2843
    export var ENGINE_METHOD_PKEY_METHS: number;
2844
    export var ENGINE_METHOD_PKEY_ASN1_METHS: number;
2845
    export var ENGINE_METHOD_ALL: number;
2846
    export var ENGINE_METHOD_NONE: number;
2847
    export var DH_CHECK_P_NOT_SAFE_PRIME: number;
2848
    export var DH_CHECK_P_NOT_PRIME: number;
2849
    export var DH_UNABLE_TO_CHECK_GENERATOR: number;
2850
    export var DH_NOT_SUITABLE_GENERATOR: number;
2851
    export var NPN_ENABLED: number;
2852
    export var RSA_PKCS1_PADDING: number;
2853
    export var RSA_SSLV23_PADDING: number;
2854
    export var RSA_NO_PADDING: number;
2855
    export var RSA_PKCS1_OAEP_PADDING: number;
2856
    export var RSA_X931_PADDING: number;
2857
    export var RSA_PKCS1_PSS_PADDING: number;
2858
    export var POINT_CONVERSION_COMPRESSED: number;
2859
    export var POINT_CONVERSION_UNCOMPRESSED: number;
2860
    export var POINT_CONVERSION_HYBRID: number;
2861
    export var O_RDONLY: number;
2862
    export var O_WRONLY: number;
2863
    export var O_RDWR: number;
2864
    export var S_IFMT: number;
2865
    export var S_IFREG: number;
2866
    export var S_IFDIR: number;
2867
    export var S_IFCHR: number;
2868
    export var S_IFBLK: number;
2869
    export var S_IFIFO: number;
2870
    export var S_IFSOCK: number;
2871
    export var S_IRWXU: number;
2872
    export var S_IRUSR: number;
2873
    export var S_IWUSR: number;
2874
    export var S_IXUSR: number;
2875
    export var S_IRWXG: number;
2876
    export var S_IRGRP: number;
2877
    export var S_IWGRP: number;
2878
    export var S_IXGRP: number;
2879
    export var S_IRWXO: number;
2880
    export var S_IROTH: number;
2881
    export var S_IWOTH: number;
2882
    export var S_IXOTH: number;
2883
    export var S_IFLNK: number;
2884
    export var O_CREAT: number;
2885
    export var O_EXCL: number;
2886
    export var O_NOCTTY: number;
2887
    export var O_DIRECTORY: number;
2888
    export var O_NOATIME: number;
2889
    export var O_NOFOLLOW: number;
2890
    export var O_SYNC: number;
2891
    export var O_SYMLINK: number;
2892
    export var O_DIRECT: number;
2893
    export var O_NONBLOCK: number;
2894
    export var O_TRUNC: number;
2895
    export var O_APPEND: number;
2896
    export var F_OK: number;
2897
    export var R_OK: number;
2898
    export var W_OK: number;
2899
    export var X_OK: number;
2900
    export var UV_UDP_REUSEADDR: number;
2901
    export var SIGQUIT: number;
2902
    export var SIGTRAP: number;
2903
    export var SIGIOT: number;
2904
    export var SIGBUS: number;
2905
    export var SIGUSR1: number;
2906
    export var SIGUSR2: number;
2907
    export var SIGPIPE: number;
2908
    export var SIGALRM: number;
2909
    export var SIGCHLD: number;
2910
    export var SIGSTKFLT: number;
2911
    export var SIGCONT: number;
2912
    export var SIGSTOP: number;
2913
    export var SIGTSTP: number;
2914
    export var SIGTTIN: number;
2915
    export var SIGTTOU: number;
2916
    export var SIGURG: number;
2917
    export var SIGXCPU: number;
2918
    export var SIGXFSZ: number;
2919
    export var SIGVTALRM: number;
2920
    export var SIGPROF: number;
2921
    export var SIGIO: number;
2922
    export var SIGPOLL: number;
2923
    export var SIGPWR: number;
2924
    export var SIGSYS: number;
2925
    export var SIGUNUSED: number;
2926
    export var defaultCoreCipherList: string;
2927
    export var defaultCipherList: string;
2928
    export var ENGINE_METHOD_RSA: number;
2929
    export var ALPN_ENABLED: number;
2930
}
2931

    
2932
declare module "process" {
2933
    export = process;
2934
}
2935

    
2936
declare module "v8" {
2937
    interface HeapSpaceInfo {
2938
        space_name: string;
2939
        space_size: number;
2940
        space_used_size: number;
2941
        space_available_size: number;
2942
        physical_space_size: number;
2943
    }
2944
    export function getHeapStatistics() : {total_heap_size: number, total_heap_size_executable: number, total_physical_size: number, total_avaialble_size: number, used_heap_size: number, heap_size_limit: number};
2945
    export function getHeapSpaceStatistics(): HeapSpaceInfo[];
2946
    export function setFlagsFromString(flags: string): void;
2947
}
2948

    
2949
declare module "timers" {
2950
    export function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
2951
    export function clearTimeout(timeoutId: NodeJS.Timer): void;
2952
    export function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
2953
    export function clearInterval(intervalId: NodeJS.Timer): void;
2954
    export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
2955
    export function clearImmediate(immediateId: any): void;
2956
}
2957

    
2958
declare module "console" {
2959
    export = console;
2960
}
(1-1/2)