import { Socket } from 'socket.io-client';
import { AuthenticationMessage, Message, SwapTokenMessage, VerificationMessage } from '../../services/communication/message';
export type Subscriber = (message: Message) => void;
export type VeriffSubscriber = (message: VerificationMessage) => Promise<void>;
export declare const SOCKET_TIMEOUT = 100000;
export declare const SESSION_TIMEOUT = 40000;
export type WebsocketReturnType = {
    status: number;
    details?: any;
    error?: any;
};
export declare class Communication {
    socketServer: Socket;
    private static singleton;
    private static identifier;
    private subscribers;
    private authMessage?;
    private loggedIn;
    private url;
    private seenMessages;
    private readonly seemMessageTTL;
    /**
     * Checks if a message has been seen before
     * Run duplicate check only in CI or local test environment; skip elsewhere (e.g. production)
     *
     * @description Fixes an issue where subscriber were triggered twice
     * @link https://chatgpt.com/share/e/6866b6e9-96a4-8013-b25d-381a3518567e
     * TODO: figure out the root cause and solve
     *
     * @param {string} message - the message to check
     * @returns {boolean} true if the message has been seen before
     */
    private checkSeenMessage;
    private trimSeenMessages;
    private addSeenMessage;
    constructor(singleton?: boolean);
    isConnected(): boolean;
    isLoggedIn(): boolean;
    /**
     * Connects to the Tonomy Communication server
     *
     * @returns {Promise<void>}
     * @throws {SdkError} CommunicationNotConnected
     */
    private connect;
    /**
     * Sends a Message object through a websocket connection to the Tonomy Communication server
     *
     * @param {string} event - the name of the event to emit
     * @param {Message} message - the Message object to send
     * @returns {Promise<boolean>} - true if successful and acknowledged by the server
     * @throws {SdkError} - CommunicationTimeout
     */
    private emitMessage;
    /**
     * connects to the Tonomy Communication server, authenticates with it's DID
     * @param {AuthenticationMessage} authorization - the VC the user sent
     *
     * @returns {boolean} - true if successful
     */
    login(authorization: AuthenticationMessage): Promise<boolean>;
    sendMessage(message: Message): Promise<boolean>;
    sendSwapMessage(message: SwapTokenMessage): Promise<boolean>;
    /**
     * function that adds a new subscriber, which is called every time a message is received
     *
     * @param {Subscriber} subscriber - the message object
     * @param {string} type - the type of message to subscribe to
     * @returns {number} - identifier which will be used for unsubscribe
     */
    subscribeMessage(subscriber: Subscriber, type: string): number;
    /**
     * unsubscribes a function from the receiving a message
     *
     * @param {number} id - identifier which will be used for unsubscribe
     *
     */
    unsubscribeMessage(id: number): void;
    disconnect(): void;
    /**
     * Subscribes to Veriff verification messages.
     * Calls the handler every time a verification message is received.
     *
     * @param {VeriffSubscriber} handler - Callback invoked with the message.
     * @returns {number} - Identifier for unsubscribing.
     */
    subscribeVeriffVerification(subscriber: VeriffSubscriber): number;
    unsubscribeVeriffVerification(id: number): void;
}
//# sourceMappingURL=communication.d.ts.map