/**
 * @argument encodedMessage a complete message from the lower transport layer
 */
export type P2PDataHandler = (encodedMessage: Uint8Array) => void;
export type P2PErrorHandler = (error: any) => void;
export type P2PHandler = () => void;
export type P2PEventMap = {
    data: P2PDataHandler;
    error: P2PErrorHandler;
    close: P2PHandler;
};
/**
 * Provider interface for P2P protocol responsible for re-assembling full message payloads before
 * delivering them upstream via event emission
 */
export interface P2PProvider {
    write(encodedMessage: Uint8Array, done?: P2PHandler): void;
    end(cb?: P2PHandler): void;
    destroy(err?: Error): void;
    on<T extends keyof P2PEventMap>(event: T, handler: P2PEventMap[T]): this;
}
/**
 * Reassembles length-prefixed P2P frames and fails closed when a peer declares an oversized frame.
 */
export declare class SimpleEnvelopeP2PProvider implements P2PProvider {
    static maxReadLength: number;
    private nextProvider;
    private dataHandlers;
    private errorHandlers;
    private remainingData;
    private destroyed;
    constructor(nextProvider: P2PProvider);
    write(data: Uint8Array, done?: P2PHandler): void;
    end(cb?: P2PHandler): void;
    destroy(err?: Error): void;
    on<T extends keyof P2PEventMap>(event: T, handler: P2PEventMap[T]): this;
    emitData(messageBuffer: Uint8Array): void;
    emitError(err: any): void;
    /**
     * Clears peer-controlled frame state before closing the lower transport.
     */
    private destroyWithError;
}
//# sourceMappingURL=Provider.d.ts.map