import { Socket } from "socket.io-client";
import { Emitter } from "mitt";
import { BucketServiceInterface } from "./services/bucket";
import { MediaServiceInterface } from "./services/media";
import { PluginServiceInterface } from "./services/plugin";
import { PlanServiceInterface } from "./services/plan";
import { WebsiteServiceInterface } from "./services/website";
/**************************************************************************
 * TYPES
 ***************************************************************************/
export type RTM_MODES = "websockets" | "webhooks";
export type CrispTier = "user" | "website" | "plugin";
/**************************************************************************
 * INTERFACES
 ***************************************************************************/
interface CrispAuth {
    tier: CrispTier;
    identifier: string | null;
    key: string | null;
    token: string | null;
}
/**************************************************************************
 * CLASSES
 ***************************************************************************/
/**
 * Crisp
 */
declare class Crisp {
    bucket: BucketServiceInterface;
    media: MediaServiceInterface;
    plugin: PluginServiceInterface;
    plan: PlanServiceInterface;
    website: WebsiteServiceInterface;
    /**
     * @deprecated Use import { RTM_MODES } instead
     */
    static RTM_MODES: {
        WebSockets: RTM_MODES;
        WebHooks: RTM_MODES;
    };
    auth: CrispAuth;
    protected _rest: {
        host: string;
        basePath: string;
    };
    protected _rtm: {
        host: string;
        mode: RTM_MODES;
    };
    protected _useragent: string;
    protected _customHeaders: Record<string, string>;
    protected _emitter: Emitter<Record<import("mitt").EventType, unknown>>;
    protected _socket: Socket | null;
    protected _loopback: Emitter<Record<string, unknown>> | null;
    protected _lastEventRebind: any;
    protected _brokerScheduler: typeof setTimeout | null;
    protected _brokerBindHooks: ((modeInstance: any, emitter: any) => void)[];
    protected _boundEvents: {};
    /**
     * Constructor
     */
    constructor();
    /**
     * Sets the REST API host
     */
    setRestHost(host: string): void;
    /**
     * Sets the RTM API host
     */
    setRtmHost(host: string): void;
    /**
     * Sets the RTM channel mode (ie. WebSockets or Web Hooks)
     */
    setRtmMode(mode: "websockets" | "webhooks"): void;
    /**
     * Sets custom headers to be included in all API requests
     */
    setCustomHeaders(headers: Record<string, string>): void;
    /**
     * Sets the authentication tier
     */
    setTier(tier: "user" | "website" | "plugin"): void;
    /**
     * Authenticates
     */
    authenticate(identifier: string, key: string): void;
    /**
     * Authenticates (with tier)
     */
    authenticateTier(tier: CrispTier, identifier: string, key: string): void;
    /**
     * Method wrapper to HEAD a resource
     */
    head(resource: string, query?: object | null): Promise<any>;
    /**
     * Method wrapper to GET a resource
     */
    get(resource: string, query?: object): Promise<any>;
    /**
     * Method wrapper to POST a resource
     */
    post(resource: string, query: object | null, body: object | null): Promise<any>;
    /**
     * Method wrapper to PATCH a resource
     */
    patch(resource: string, query: object | null, body: object | null): Promise<any>;
    /**
     * Method wrapper to PUT a resource
     */
    put(resource: string, query: object | null, body: object | null): Promise<any>;
    /**
     * Method wrapper to DELETE a resource
     */
    delete(resource: string, query?: object | null, body?: object | null): Promise<any>;
    /**
     * Binds RTM event
     */
    on(event: string, callback: (data: any) => any): Promise<unknown>;
    /**
     * Receives a raw event and dispatches it to the listener (used for Web Hooks)
     */
    receiveHook(body: Record<string, unknown>): Error;
    /**
     * Verifies an event string and checks that signatures match (used for Web \
     *   Hooks)
     */
    verifyHook(secret: string, body: object, timestamp: number, signature: string): boolean;
    /**
     * Verifies an event string and checks that signatures match (used for \
     *   Widgets)
     */
    verifyWidget(secret: string, body: object, timestamp: number, signature: string): boolean;
    /**
     * Rebinds socket events (used for WebSockets)
     */
    rebindSocket(): Promise<void>;
    /**
     * Prepares a URI based from path segments
     */
    prepareRestUrl(paths: string[]): string;
    /**
     * Binds services to the main object
     */
    protected _prepareServices(): void;
    /**
     * Binds resources to the service object
     */
    private __prepareResources;
    /**
     * Binds broker to the main object
     */
    private __prepareBroker;
    /**
     * Connects loopback (used for Web Hooks)
     */
    private __connectLoopback;
    /**
     * Connects socket, using preferred RTM API host (used for WebSockets)
     */
    private __connectSocket;
    /**
     * Authenticates client (used for WebSockets)
     */
    private __emitAuthenticateSocket;
    /**
     * Unstacks pending broker bind hooks
     */
    private __unstackBrokerBindHooks;
    /**
     * Performs a request to REST API
     */
    private __request;
    /**
     * Reads reason for error response
     */
    private __readErrorResponseReason;
    /**
     * Verifies an event string and checks that signatures match
     */
    private __verifySignature;
}
/**************************************************************************
 * EXPORTS
 ***************************************************************************/
export * from "./resources";
export { Crisp };
export default Crisp;
