diff --git a/types/socketcluster-server/scserver.d.ts b/types/socketcluster-server/scserver.d.ts index 751a646bbd..cef90acfed 100644 --- a/types/socketcluster-server/scserver.d.ts +++ b/types/socketcluster-server/scserver.d.ts @@ -33,6 +33,13 @@ declare class SCServer extends EventEmitter { constructor(options?: SCServer.SCServerOptions); on(event: "connection", listener: SCServer.connectionListenerFunction): this; + on(event: "ready", listener: () => void): this; + on(event: "error", listener: (error: Error) => void): this; + on(event: "disconnection" | "connectionAbort" | "closure", listener: SCServer.disconnectionListenerFunction): this; + on(event: "subscription", listener: SCServer.subscriptionListenerFunction): this; + on(event: "unsubscription", listener: SCServer.unsubscriptionListenerFunction): this; + on(event: "handshake", listener: SCServer.handshakeListenerFunction): this; + on(event: "badSocketAuthToken", listener: SCServer.badSocketAuthTokenListenerFunction): this; addMiddleware(type: "handshakeWS", middlewareFn: (req: IncomingMessage, next: SCServer.nextMiddlewareFunction) => void): void; addMiddleware(type: "handshakeSC", middlewareFn: (req: SCServer.HandshakeSCRequest, next: SCServer.nextHandshakeSCMiddlewareFunction) => void): void; @@ -305,10 +312,20 @@ declare namespace SCServer { data?: any; } + interface badAuthStatus { + authError: Error; + signedAuthToken: string; + } + type nextMiddlewareFunction = (error?: true | string | Error) => void; type nextHandshakeSCMiddlewareFunction = (error?: true | string | Error | null, statusCode?: number) => void; type nextAuthenticateMiddlewareFunction = (error?: true | string | Error | null, isBadToken?: boolean) => void; type connectionListenerFunction = (scSocket: SCServerSocket, serverSocketStatus: SCServerSocketStatus) => void; + type disconnectionListenerFunction = (scSocket: SCServerSocket, code: number, data: any) => void; + type subscriptionListenerFunction = (scSocket: SCServerSocket, name: string, options: {channel: string}) => void; + type unsubscriptionListenerFunction = (scSocket: SCServerSocket, name: string, channel: string) => void; + type handshakeListenerFunction = (scSocket: SCServerSocket) => void; + type badSocketAuthTokenListenerFunction = (scSocket: SCServerSocket, status: badAuthStatus) => void; interface SCCodecEngine { decode: (input: any) => any;