import { VSBuffer } from "../../../common/buffer.js"; /** RFC 6455 frame opcode values supported by the framing codec. */ export declare enum WebSocketOpcode { Continuation = 0, Text = 1, Binary = 2, Close = 8, Ping = 9, Pong = 10 } /** A parsed RFC 6455 frame with an unmasked payload. */ export interface IWebSocketFrame { readonly final: boolean; readonly compressed: boolean; readonly opcode: WebSocketOpcode; readonly payload: VSBuffer; /** The mask from the wire, including a zero-valued mask, when present. */ readonly mask?: number; } /** Options for encoding an RFC 6455 frame. */ export interface IWebSocketFrameOptions { readonly final?: boolean; readonly compressed?: boolean; readonly opcode: WebSocketOpcode; /** Four mask bytes. When supplied, sets MASK and applies it to a payload copy. */ readonly mask?: number; } /** Options for parsing RFC 6455 frames. */ export interface IWebSocketFrameParserOptions { /** Maximum accepted frame payload length. */ readonly maxPayloadLength?: number; /** Unmask owned payload buffers in place instead of allocating a copy. */ readonly unmaskInPlace?: boolean; } /** Indicates that a WebSocket frame exceeded the configured payload limit. */ export declare class WebSocketFrameTooLargeError extends Error { readonly payloadLength: number; readonly maxPayloadLength: number; constructor(payloadLength: number, maxPayloadLength: number); } /** Incrementally parses RFC 6455 frames from arbitrarily chunked input. */ export declare class WebSocketFrameParser { private readonly _incomingData; private readonly _maxPayloadLength; private readonly _unmaskInPlace; constructor(options?: IWebSocketFrameParserOptions); /** * Accepts a network chunk and returns every complete frame it contains. */ acceptChunk(data: VSBuffer): readonly IWebSocketFrame[]; } /** * Encodes one RFC 6455 frame without mutating the supplied payload. */ export declare function encodeWebSocketFrame(payload: VSBuffer, options: IWebSocketFrameOptions): VSBuffer; /** Applies an RFC 6455 four-byte mask to a buffer in place. */ export declare function applyWebSocketMask(payload: VSBuffer, mask: number): void;