@types/websocket
Advanced tools
Comparing version 0.0.40 to 1.0.0
@@ -1,2 +0,2 @@ | ||
// Type definitions for websocket | ||
// Type definitions for websocket 1.0 | ||
// Project: https://github.com/theturtle32/WebSocket-Node | ||
@@ -6,3 +6,4 @@ // Definitions by: Paul Loyd <https://github.com/loyd>, | ||
// Zhao Lei <https://github.com/zhaoleimxd> | ||
// Sheng Chen <https://github.com/jdneo> | ||
// Sheng Chen <https://github.com/jdneo>, | ||
// Matthew Peveler <https://github.com/MasterOdin> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
@@ -13,3 +14,2 @@ // TypeScript Version: 2.2 | ||
import events = require('events'); | ||
@@ -68,3 +68,3 @@ import http = require('http'); | ||
/** The http or https server instance(s) to attach to */ | ||
httpServer: http.Server | https.Server | (http.Server | https.Server)[]; | ||
httpServer: http.Server | https.Server | Array<http.Server | https.Server>; | ||
@@ -116,2 +116,14 @@ /** | ||
/** | ||
* Whether to use native TCP keep-alive instead of WebSockets ping | ||
* and pong packets. Native TCP keep-alive sends smaller packets | ||
* on the wire and so uses bandwidth more efficiently. This may | ||
* be more important when talking to mobile devices. | ||
* If this value is set to true, then these values will be ignored: | ||
* keepaliveGracePeriod | ||
* dropConnectionOnKeepaliveTimeout | ||
* @default false | ||
*/ | ||
useNativeKeepalive?: boolean; | ||
/** | ||
* If this is true, websocket connections will be accepted regardless of the path | ||
@@ -125,2 +137,14 @@ * and protocol specified by the client. The protocol accepted will be the first | ||
/** | ||
* Whether or not the X-Forwarded-For header should be respected. | ||
* It's important to set this to 'true' when accepting connections | ||
* from untrusted clients, as a malicious client could spoof its | ||
* IP address by simply setting this header. It's meant to be added | ||
* by a trusted proxy or other intermediary within your own | ||
* infrastructure. | ||
* See: http://en.wikipedia.org/wiki/X-Forwarded-For | ||
* @default false | ||
*/ | ||
ignoreXForwardedFor?: boolean; | ||
/** | ||
* The Nagle Algorithm makes more efficient use of network resources by introducing a | ||
@@ -134,13 +158,12 @@ * small delay before sending small packets so that multiple messages can be batched | ||
export declare class server extends events.EventEmitter { | ||
config: IServerConfig; | ||
export class server extends events.EventEmitter { | ||
config?: IServerConfig; | ||
connections: connection[]; | ||
pendingRequests: request[]; | ||
constructor(serverConfig?: IServerConfig); | ||
/** Send binary or UTF-8 message for each connection */ | ||
broadcast(data: Buffer | IStringified): void; | ||
/** Send binary message for each connection */ | ||
broadcast(data: Buffer): void; | ||
/** Send UTF-8 message for each connection */ | ||
broadcast(data: IStringified): void; | ||
/** Send binary message for each connection */ | ||
broadcastBytes(data: Buffer): void; | ||
@@ -164,8 +187,11 @@ /** Send UTF-8 message for each connection */ | ||
handleUpgrade(request: http.IncomingMessage, socket: net.Socket): void; | ||
handleRequestAccepted(connection: connection): void; | ||
handleConnectionClose(connection: connection, closeReason: number, description: string): void; | ||
handleRequestResolved(request: request): void; | ||
// Events | ||
on(event: string, listener: () => void): this; | ||
on(event: 'request', cb: (request: request) => void): this; | ||
on(event: 'connect', cb: (connection: connection) => void): this; | ||
on(event: 'close', cb: (connection: connection, reason: number, desc: string) => void): this; | ||
addListener(event: string, listener: () => void): this; | ||
addListener(event: 'request', cb: (request: request) => void): this; | ||
@@ -192,3 +218,3 @@ addListener(event: 'connect', cb: (connection: connection) => void): this; | ||
export declare class request extends events.EventEmitter { | ||
export class request extends events.EventEmitter { | ||
/** A reference to the original Node HTTP request object */ | ||
@@ -210,2 +236,3 @@ httpRequest: http.IncomingMessage; | ||
remoteAddress: string; | ||
remoteAddresses: string[]; | ||
@@ -237,2 +264,7 @@ /** | ||
serverConfig: IServerConfig; | ||
_resolved: boolean; | ||
_socketIsClosing: boolean; | ||
constructor(socket: net.Socket, httpRequest: http.IncomingMessage, config: IServerConfig); | ||
@@ -254,13 +286,21 @@ | ||
* `X-WebSocket-Reject-Reason` header. | ||
* Optional extra http headers can be added via Object key/values on extraHeaders. | ||
* Optional extra http headers can be added via Object key/values on extraHeaders. | ||
*/ | ||
reject(httpStatus?: number, reason?: string, extraHeaders?: Object): void; | ||
reject(httpStatus?: number, reason?: string, extraHeaders?: object): void; | ||
// Events | ||
on(event: string, listener: () => void): this; | ||
on(event: 'requestResolved' | 'requestRejected', cb: (request: this) => void): this; | ||
on(event: 'requestAccepted', cb: (connection: connection) => void): this; | ||
on(event: 'requestRejected', cb: () => void): this; | ||
addListener(event: string, listener: () => void): this; | ||
addListener(event: 'requestResolved' | 'requestRejected', cb: (request: this) => void): this; | ||
addListener(event: 'requestAccepted', cb: (connection: connection) => void): this; | ||
addListener(event: 'requestRejected', cb: () => void): this; | ||
readHandshake(): void; | ||
parseExtensions(extensionString: string): string[]; | ||
parseCookies(str: string): ICookie[] | void; | ||
_handleSocketCloseBeforeAccept(): void; | ||
_removeSocketCloseListeners(): void; | ||
_verifyResolution(): void; | ||
} | ||
@@ -279,2 +319,3 @@ | ||
end(buf: Buffer): void; | ||
push(): void; | ||
@@ -308,7 +349,7 @@ /** | ||
toString(): string; | ||
// Events | ||
on(event: string, listener: () => void): this; | ||
on(event: 'advance', cb: (n: number) => void): this; | ||
on(event: 'write', cb: (buf: Buffer) => void): this; | ||
addListener(event: string, listener: () => void): this; | ||
addListener(event: 'advance', cb: (n: number) => void): this; | ||
@@ -318,3 +359,3 @@ addListener(event: 'write', cb: (buf: Buffer) => void): this; | ||
declare class connection extends events.EventEmitter { | ||
export class connection extends events.EventEmitter { | ||
static CLOSE_REASON_NORMAL: number; | ||
@@ -332,2 +373,4 @@ static CLOSE_REASON_GOING_AWAY: number; | ||
static CLOSE_DESCRIPTIONS: {[code: number]: string}; | ||
/** | ||
@@ -362,6 +405,8 @@ * After the connection is closed, contains a textual description of the reason for | ||
waitingForCloseResponse: boolean; | ||
receivedEnd: boolean; | ||
closeTimeout: number; | ||
assembleFragments: number; | ||
maxReceivedMessageSize: number; | ||
outputPaused: boolean; | ||
outputBufferFull: boolean; | ||
inputPaused: boolean; | ||
bytesWaitingToFlush: number; | ||
@@ -386,2 +431,4 @@ socketHadError: boolean; | ||
_pingListenerCount: number; | ||
constructor(socket: net.Socket, extensions: IExtension[], protocol: string, | ||
@@ -396,3 +443,3 @@ maskOutgoingPackets: boolean, config: IConfig); | ||
*/ | ||
close(): void; | ||
close(reasonCode?: number, description?: string): void; | ||
@@ -403,3 +450,3 @@ /** | ||
*/ | ||
drop(reasonCode?: number, description?: string): void; | ||
drop(reasonCode?: number, description?: string, skipCloseFrame?: boolean): void; | ||
@@ -411,3 +458,3 @@ /** | ||
*/ | ||
sendUTF(data: IStringified): void; | ||
sendUTF(data: IStringified, cb?: (err?: Error) => void): void; | ||
@@ -419,11 +466,9 @@ /** | ||
*/ | ||
sendBytes(buffer: Buffer): void; | ||
sendBytes(buffer: Buffer, cb?: (err?: Error) => void): void; | ||
/** Auto-detect the data type and send UTF-8 or Binary message */ | ||
send(data: Buffer): void; | ||
send(data: IStringified): void; | ||
send(data: Buffer | IStringified, cb?: (err?: Error) => void): void; | ||
/** Sends a ping frame. Ping frames must not exceed 125 bytes in length. */ | ||
ping(data: Buffer): void; | ||
ping(data: IStringified): void; | ||
ping(data: Buffer | IStringified): void; | ||
@@ -445,18 +490,32 @@ /** | ||
*/ | ||
sendFrame(frame: frame): void; | ||
sendFrame(frame: frame, cb?: (err?: Error) => void): void; | ||
/** Set or reset the `keepalive` timer when data is received */ | ||
setKeepaliveTimer(): void; | ||
clearKeepaliveTimer(): void; | ||
handleKeepaliveTimer(): void; | ||
setGracePeriodTimer(): void; | ||
clearGracePeriodTimer(): void; | ||
handleGracePeriodTimer(): void; | ||
handleSocketData(data: Buffer): void; | ||
processReceivedData(): void; | ||
handleSocketError(error: Error): void; | ||
handleSocketEnd(): void; | ||
handleSocketClose(hadError: boolean): void; | ||
handleSocketDrain(): void; | ||
handleSocketPause(): void; | ||
handleSocketResume(): void; | ||
pause(): void; | ||
resume(): void; | ||
setCloseTimer(): void; | ||
clearCloseTimer(): void; | ||
handleCloseTimer(): void; | ||
processFrame(frame: frame): void; | ||
fragmentAndSend(frame: frame, cb?: (err: Error) => void): void; | ||
sendCloseFrame(reasonCode: number, reasonText: string, force: boolean): void; | ||
sendCloseFrame(): void; | ||
sendFrame(frame: frame, force: boolean, cb?: (msg: string) => void): void; | ||
sendFrame(frame: frame, cb?: (msg: string) => void): void; | ||
sendCloseFrame(reasonCode?: number, reasonText?: string, cb?: (err?: Error) => void): void; | ||
_addSocketEventListeners(): void; | ||
// Events | ||
on(event: string, listener: () => void): this; | ||
on(event: 'message', cb: (data: IMessage) => void): this; | ||
@@ -466,3 +525,5 @@ on(event: 'frame', cb: (frame: frame) => void): this; | ||
on(event: 'error', cb: (err: Error) => void): this; | ||
addListener(event: string, listener: () => void): this; | ||
on(event: 'drain' | 'pause' | 'resume', cb: () => void): this; | ||
on(event: 'ping', cb: (cancel: () => void, binaryPayload: Buffer) => void): this; | ||
on(event: 'pong', cb: (binaryPayload: Buffer) => void): this; | ||
addListener(event: 'message', cb: (data: IMessage) => void): this; | ||
@@ -472,5 +533,8 @@ addListener(event: 'frame', cb: (frame: frame) => void): this; | ||
addListener(event: 'error', cb: (err: Error) => void): this; | ||
addListener(event: 'drain' | 'pause' | 'resume', cb: () => void): this; | ||
addListener(event: 'ping', cb: (cancel: () => void, binaryPayload: Buffer) => void): this; | ||
addListener(event: 'pong', cb: (binaryPayload: Buffer) => void): this; | ||
} | ||
declare class frame { | ||
export class frame { | ||
/** Whether or not this is last frame in a fragmentation sequence */ | ||
@@ -534,4 +598,6 @@ fin: boolean; | ||
protocolError: boolean; | ||
dropReason: string; | ||
frameTooLarge: boolean; | ||
invalidCloseFrameLength: boolean; | ||
parseState: number; | ||
closeStatus: number; | ||
@@ -542,2 +608,3 @@ | ||
toBuffer(nullMask: boolean): Buffer; | ||
toString(): string; | ||
} | ||
@@ -577,3 +644,3 @@ | ||
declare class client extends events.EventEmitter { | ||
export class client extends events.EventEmitter { | ||
protocols: string[]; | ||
@@ -585,4 +652,5 @@ origin: string; | ||
response: http.IncomingMessage; | ||
firstDataChunk: Buffer | null; | ||
constructor(clientConfig?: IClientConfig); | ||
constructor(ClientConfig?: IClientConfig); | ||
@@ -597,7 +665,8 @@ /** | ||
*/ | ||
connect(requestUrl: url.Url, protocols?: string[], origin?: string, headers?: object, extraRequestOptions?: http.RequestOptions): void; | ||
connect(requestUrl: string, protocols?: string[], origin?: string, headers?: object, extraRequestOptions?: http.RequestOptions): void; | ||
connect(requestUrl: url.Url, protocols?: string, origin?: string, headers?: object, extraRequestOptions?: http.RequestOptions): void; | ||
connect(requestUrl: string, protocols?: string, origin?: string, headers?: object, extraRequestOptions?: http.RequestOptions): void; | ||
connect(requestUrl: url.Url | string, protocols?: string | string[], origin?: string, headers?: http.OutgoingHttpHeaders, extraRequestOptions?: http.RequestOptions): void; | ||
validateHandshake(): void; | ||
failHandshake(errorDescription: string): void; | ||
succeedHandshake(): void; | ||
/** | ||
@@ -610,14 +679,21 @@ * Will cancel an in-progress connection request before either the `connect` event or the `connectFailed` event has been emitted. | ||
// Events | ||
on(event: string, listener: () => void): this; | ||
on(event: 'connect', cb: (connection: connection) => void): this; | ||
on(event: 'connectFailed', cb: (err: Error) => void): this; | ||
addListener(event: string, listener: () => void): this; | ||
on(event: 'httpResponse', cb: (response: http.IncomingMessage, client: client) => void): this; | ||
addListener(event: 'connect', cb: (connection: connection) => void): this; | ||
addListener(event: 'connectFailed', cb: (err: Error) => void): this; | ||
addListener(event: 'httpResponse', cb: (response: http.IncomingMessage, client: client) => void): this; | ||
} | ||
declare class routerRequest extends events.EventEmitter { | ||
export interface IRouterRequest extends events.EventEmitter { | ||
webSocketRequest: request; | ||
protocol: string | null; | ||
/** A reference to the original Node HTTP request object */ | ||
httpRequest: http.IncomingMessage; | ||
/** | ||
* If the client is a web browser, origin will be a string containing the URL | ||
* of the page containing the script that opened the connection. | ||
* If the client is not a web browser, origin may be `null` or "*". | ||
*/ | ||
origin: string; | ||
/** A string containing the path that was requested by the client */ | ||
@@ -628,2 +704,5 @@ resource: string; | ||
/** A reference to the original Node HTTP request object */ | ||
httpRequest: http.IncomingMessage; | ||
/** | ||
@@ -635,9 +714,2 @@ * Client's IP. If an `X-Forwarded-For` header is present, the value will be taken | ||
/** | ||
* If the client is a web browser, origin will be a string containing the URL | ||
* of the page containing the script that opened the connection. | ||
* If the client is not a web browser, origin may be `null` or "*". | ||
*/ | ||
origin: string; | ||
/** The version of the WebSocket protocol requested by the client */ | ||
@@ -650,4 +722,2 @@ webSocketVersion: number; | ||
constructor(webSocketRequest: request, resolvedProtocol: string); | ||
/** | ||
@@ -671,19 +741,25 @@ * After inspecting the `request` properties, call this function on the | ||
// Events | ||
on(event: string, listener: () => void): this; | ||
on(event: 'requestAccepted', cb: (connection: connection) => void): this; | ||
on(event: 'requestRejected', cb: () => void): this; | ||
addListener(event: string, listener: () => void): this; | ||
on(event: 'requestRejected', cb: (request: this) => void): this; | ||
addListener(event: 'requestAccepted', cb: (connection: connection) => void): this; | ||
addListener(event: 'requestRejected', cb: () => void): this; | ||
addListener(event: 'requestRejected', cb: (request: this) => void): this; | ||
} | ||
interface IRouterConfig { | ||
export interface IRouterConfig { | ||
/* | ||
* The WebSocketServer instance to attach to. | ||
*/ | ||
server: server | ||
server: server; | ||
} | ||
declare class router extends events.EventEmitter { | ||
export interface IRouterHandler { | ||
path: string; | ||
pathString: string; | ||
protocol: string; | ||
callback: (request: IRouterRequest) => void; | ||
} | ||
export class router extends events.EventEmitter { | ||
handlers: IRouterHandler[]; | ||
constructor(config?: IRouterConfig); | ||
@@ -697,13 +773,25 @@ | ||
mount(path: string, cb: (request: routerRequest) => void): void; | ||
mount(path: string, protocol: string, cb: (request: routerRequest) => void): void; | ||
mount(path: RegExp, cb: (request: routerRequest) => void): void; | ||
mount(path: RegExp, protocol: string, cb: (request: routerRequest) => void): void; | ||
mount(path: string | RegExp, protocol: string | null, callback: (request: IRouterRequest) => void): void; | ||
unmount(path: string, protocol?: string): void; | ||
unmount(path: RegExp, protocol?: string): void; | ||
unmount(path: string | RegExp, protocol?: string): void; | ||
findHandlerIndex(pathString: string, protocol: string): number; | ||
pathToRegExp(path: string): RegExp; | ||
pathToRegEx(path: RegExp): RegExp; | ||
handleRequest(request: request): void; | ||
} | ||
declare class w3cwebsocket { | ||
export interface ICloseEvent { | ||
code: number; | ||
reason: string; | ||
wasClean: boolean; | ||
} | ||
export interface IMessageEvent { | ||
data: string | Buffer | ArrayBuffer; | ||
} | ||
export class w3cwebsocket { | ||
static CONNECTING: number; | ||
@@ -714,2 +802,11 @@ static OPEN: number; | ||
_url: string; | ||
_readyState: number; | ||
_protocol?: string; | ||
_extensions: IExtension[]; | ||
_bufferedAmount: number; | ||
_binaryType: 'arraybuffer'; | ||
_connection?: connection; | ||
_client: client; | ||
url: string; | ||
@@ -721,3 +818,3 @@ readyState: number; | ||
binaryType: "arraybuffer"; | ||
binaryType: 'arraybuffer'; | ||
@@ -731,15 +828,24 @@ CONNECTING: number; | ||
onerror: (error: Error) => void; | ||
onclose: () => void; | ||
onmessage: (message: any) => void; | ||
onclose: (event: ICloseEvent) => void; | ||
onmessage: (message: IMessageEvent) => void; | ||
constructor(url: string, protocols?: string | string[], origin?: string, headers?: any[], requestOptions?: object, clientConfig?: IClientConfig); | ||
constructor( | ||
url: string, | ||
protocols?: string | string[], | ||
origin?: string, | ||
headers?: http.OutgoingHttpHeaders, | ||
requestOptions?: object, | ||
IClientConfig?: IClientConfig, | ||
); | ||
send(data: Buffer): void; | ||
send(data: IStringified): void; | ||
send(data: ArrayBufferView | ArrayBuffer | Buffer | IStringified): void; | ||
close(code?: number, reason?: string): void; | ||
} | ||
export declare var version: string; | ||
export declare var constants: { | ||
DEBUG: boolean; | ||
export const deprecation: { | ||
disableWarnings: boolean; | ||
deprecationWarningMap: {[name: string]: string}; | ||
warn(deprecationName: string): void; | ||
}; | ||
export const version: string; |
{ | ||
"name": "@types/websocket", | ||
"version": "0.0.40", | ||
"version": "1.0.0", | ||
"description": "TypeScript definitions for websocket", | ||
@@ -26,16 +26,22 @@ "license": "MIT", | ||
"githubUsername": "jdneo" | ||
}, | ||
{ | ||
"name": "Matthew Peveler", | ||
"url": "https://github.com/MasterOdin", | ||
"githubUsername": "MasterOdin" | ||
} | ||
], | ||
"main": "", | ||
"types": "index", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git" | ||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", | ||
"directory": "types/websocket" | ||
}, | ||
"scripts": {}, | ||
"dependencies": { | ||
"@types/events": "*", | ||
"@types/node": "*" | ||
}, | ||
"typesPublisherContentHash": "1f262a6e85890a5dc72d5d79b48322ecd78ac9fc09f8e0a88362165e32de0682", | ||
"typesPublisherContentHash": "88109701fe99a4bb7dddd9b44db540e3c498938da879e7a4534f37d253d0bea8", | ||
"typeScriptVersion": "2.2" | ||
} |
@@ -11,7 +11,7 @@ # Installation | ||
Additional Details | ||
* Last updated: Thu, 30 Aug 2018 00:13:56 GMT | ||
* Dependencies: events, http, https, net, url, node | ||
* Last updated: Wed, 16 Oct 2019 17:28:14 GMT | ||
* Dependencies: @types/node | ||
* Global values: none | ||
# Credits | ||
These definitions were written by Paul Loyd <https://github.com/loyd>, Kay Schecker <https://github.com/flynetworks>, Zhao Lei <https://github.com/zhaoleimxd>, Sheng Chen <https://github.com/jdneo>. | ||
These definitions were written by Paul Loyd <https://github.com/loyd>, Kay Schecker <https://github.com/flynetworks>, Zhao Lei <https://github.com/zhaoleimxd>, Sheng Chen <https://github.com/jdneo>, and Matthew Peveler <https://github.com/MasterOdin>. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
32039
1
683
1
- Removed@types/events@*
- Removed@types/events@3.0.3(transitive)