UNPKG

1.06 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as http from 'http';
3import { ContributionProvider, MaybePromise } from '../common';
4/**
5 * Bind components to this symbol to filter WebSocket connections.
6 */
7export declare const WsRequestValidatorContribution: unique symbol;
8export interface WsRequestValidatorContribution {
9 /**
10 * Return `false` to prevent the protocol upgrade from going through, blocking the WebSocket connection.
11 *
12 * @param request The HTTP connection upgrade request received by the server.
13 */
14 allowWsUpgrade(request: http.IncomingMessage): MaybePromise<boolean>;
15}
16/**
17 * Central handler of `WsRequestValidatorContribution`.
18 */
19export declare class WsRequestValidator {
20 protected readonly requestValidators: ContributionProvider<WsRequestValidatorContribution>;
21 /**
22 * Ask all bound `WsRequestValidatorContributions` if the WebSocket connection should be allowed or not.
23 */
24 allowWsUpgrade(request: http.IncomingMessage): Promise<boolean>;
25}
26//# sourceMappingURL=ws-request-validators.d.ts.map
\No newline at end of file