import { MessageInterface, MessageListener } from '../communication-interface/MessageInterface';
import { RsaOaepAesMessage } from '../crypto/rsa-oaep-aes-message';
import { WebRTCTransport } from '../webrtc-transport/WebRTCTransport';
import { EcdheAesGcmMessage } from '../crypto/ecdhe-aes-gcm-message';
import { ContactManager } from '../contact-management/ContactManager';
declare class DhtContact {
    id: Uint8Array;
    vectorClock: number;
    publicKey: string;
    signature: string;
    constructor(id: Uint8Array, publicKey: string, signature: string, vectorClock?: number);
}
declare type DhtContactDto = {
    id: string;
    publicKey: string;
    signature: string;
    vectorClock: number;
};
interface DhtParameterMap {
    'ping': {
        pingId: string;
    };
    'pong': {
        pingId: string;
    };
    'findNode': {
        id: string;
        respondTo?: string;
    };
    'foundNode': {
        contacts: DhtContactDto[];
    };
    'handshakeWith': {
        from: string;
        fromPK: string;
        pkSignature: string;
        webRTCAddressBundle: string;
    };
    'handshakeResponse': {
        from: string;
        fromPK: string;
        pkSignature: string;
        webRTCAddressBundle: string;
        respondVia: string;
    };
    'handshakeCompleted': {
        from: string;
        fromPK: string;
        pkSignature: string;
        respondVia: string;
    };
    'send': {
        to: string;
        message: string;
        ttl: number;
    };
    'broadcast': {
        message: string;
        type: string;
    };
}
export declare class WebRtcDht implements MessageInterface {
    private kBucket;
    private _initPromise;
    private webRTCTransport;
    private ecdhAesMessage;
    private longAsyncRF;
    private contactManager;
    private pkSignatures;
    private readonly textEncoder;
    private readonly textDecoder;
    private timeAddressToUserId;
    private rsaOaepeAesMessage;
    /**
     *
     * @param userId The local userId
     * @param webRTCTransport an existing WebRTCTransport with at least one connection
     * @param ecdheMessageWebRTCTransport the EcdheAesGcmMessage used by the WebRTCTransport
     */
    constructor(userId: string, webRTCTransport: WebRTCTransport, ecdheMessageWebRTCTransport: EcdheAesGcmMessage, rsaOaepAesMessage: RsaOaepAesMessage, contactManager: ContactManager);
    addRTCConnection(userId: string, fromPK: string, signature: string): Promise<void>;
    connectToMorePeers(): Promise<void>;
    getNodeAddress(userId: string, prev?: string, depthLimit?: number): Promise<void>;
    connectTo(userId: string): Promise<void>;
    private outstandingConnections;
    padMessage(message: string): string;
    sendOnion(userId: string, message: string, onion: string[]): Promise<void>;
    _getClosestContact(userId: string, ignoreUserId?: string): Promise<DhtContact | undefined>;
    /**
     * Sends a message via the DHT network
     * @param userId the time based address of the recipient
     * @param message the message to send
     * @param isRetry do not set, for internal use only
     * @param from do not set, for internal use only
     */
    send(userId: string, message: string, isRetry?: boolean, from?: string, ttl?: number): Promise<void>;
    private listeners;
    _r_onMessage(from: string, { message, to, ttl }: DhtParameterMap['send']): Promise<void>;
    private knownBroadcasts;
    _r_onBroadcast(from: string, { message, type }: {
        message: string;
        type: string;
    }): Promise<void>;
    addMessageListener(listener: MessageListener): void;
    private knownNodes;
    addContact(userId: string, keyInformation: any, replaceExisting?: boolean): Promise<string | void>;
    getKnownNodes(): string[];
    getKeyInformation(): Promise<any>;
    /**
     * identical to getTimeBasedUserId
     * @returns the time based address of the user
     */
    getOwnUserId(): Promise<string>;
    /**
     * identical to getOwnUserId
     * @returns the time based address of the user
     */
    getTimeBasedUserId(): Promise<string>;
    findNodeOn(search: string, userId: string): Promise<void>;
    _r_findNode(from: string, findNode: DhtParameterMap['findNode']): Promise<void>;
    _r_foundNode(from: string, foundNode: {
        contacts: DhtContactDto[];
    }): Promise<void>;
    _r_handshakeWith(fromTransportAddress: string, { from, fromPK, pkSignature, webRTCAddressBundle }: DhtParameterMap['handshakeWith']): Promise<void>;
    _r_handshakeResponse(fromTransportAddress: string, { from, fromPK, pkSignature, webRTCAddressBundle, respondVia }: DhtParameterMap['handshakeResponse']): Promise<void>;
    _r_handshakeCompleted(fromTransport: string, { from, fromPK, pkSignature }: DhtParameterMap['handshakeCompleted']): Promise<void>;
    _r_ping(from: string, { pingId }: {
        pingId: string;
    }): Promise<void>;
    _r_pong(from: string, { pingId }: {
        pingId: string;
    }): void;
    init(userId: string): Promise<void>;
    private outstandingPings;
    sendPing(oldContacts: DhtContact[], newContact: DhtContact): Promise<void>;
    contactAdded(contact: DhtContact): Promise<void>;
}
export {};
//# sourceMappingURL=DhtTransport.d.ts.map