UNPKG

pocket-messaging

Version:

A small cryptographic messaging library written in TypeScript both for browser and nodejs supporting TCP and WebSockets

33 lines (32 loc) 1.67 kB
import { SocketFactory, SocketFactoryConnectCallback } from "pocket-sockets"; import { HandshakeFactoryConfig, HandshakeFactoryInterface, HandshakeFactoryHandshakeCallback, HandshakeFactoryHandshakeErrorCallback, HandshakeFactoryPublicKeyOverflowCallback } from "./types"; /** * This class extends the SocketFactory with handshake capabilties. * The SocketFactory EVENTS objects is redeclared here and extended. */ export declare class HandshakeFactory extends SocketFactory implements HandshakeFactoryInterface { protected handshakeFactoryConfig: HandshakeFactoryConfig; constructor(handshakeFactoryConfig: HandshakeFactoryConfig); /** Override from parent. */ protected checkConnectionsOverflow(address: string, isServer?: boolean): boolean; protected handleOnConnect: SocketFactoryConnectCallback; init(): void; getHandshakeFactoryConfig(): HandshakeFactoryConfig; /** * Increase the counter connections per client public key. */ protected increaseClientsCounter(peerPublicKey: string): void; protected decreaseClientsCounter(peerPublicKey: string): void; /** * @params peerPublicKey * @returns true if any limit is reached. */ protected checkClientsOverflow(peerPublicKey: string): boolean; /** * Detect specific error in the handshake process. * This error is also emitted on the general onError event hook provided by SocketFactory. */ onHandshakeError(callback: HandshakeFactoryHandshakeErrorCallback): void; onHandshake(callback: HandshakeFactoryHandshakeCallback): void; onPublicKeyOverflow(callback: HandshakeFactoryPublicKeyOverflowCallback): void; }