add more typings between 5.1 and 6.0

This commit is contained in:
Yuan Gao
2018-08-07 19:41:38 +08:00
parent 8dc60fa7a7
commit ca6cf73a8e
2 changed files with 27 additions and 5 deletions

17
types/ws/index.d.ts vendored
View File

@@ -1,4 +1,4 @@
// Type definitions for ws 5.1
// Type definitions for ws 6.0
// Project: https://github.com/websockets/ws
// Definitions by: Paul Loyd <https://github.com/loyd>
// Matt Silverlock <https://github.com/elithrar>
@@ -120,7 +120,7 @@ declare namespace WebSocket {
* whether or not to accept the handshake.
*/
type VerifyClientCallbackAsync = (info: { origin: string; secure: boolean; req: http.IncomingMessage }
, callback: (res: boolean, code?: number, message?: string) => void) => void;
, callback: (res: boolean, code?: number, message?: string, headers?: http.OutgoingHttpHeaders) => void) => void;
interface ClientOptions {
protocol?: string;
@@ -149,8 +149,17 @@ declare namespace WebSocket {
clientNoContextTakeover?: boolean;
serverMaxWindowBits?: number;
clientMaxWindowBits?: number;
level?: number;
memLevel?: number;
zlibDeflateOptions?: {
flush?: number;
finishFlush?: number;
chunkSize?: number;
windowBits?: number;
level?: number;
memLevel?: number;
strategy?: number;
dictionary?: Buffer | Buffer[] | DataView;
info?: boolean;
};
threshold?: number;
concurrencyLimit?: number;
}

View File

@@ -88,7 +88,20 @@ import * as https from 'https';
clientNoContextTakeover: true,
serverMaxWindowBits: 0,
clientMaxWindowBits: 0,
memLevel: 0
zlibDeflateOptions: {
flush: 0,
finishFlush: 0,
chunkSize: 0,
windowBits: 0,
level: 0,
memLevel: 0,
strategy: 0,
dictionary: new Buffer('test'),
info: false
}
},
verifyClient: (info: any, cb: any) => {
cb(true, 123, 'message', { Upgrade: "websocket" });
}
});
}