import { Gettable } from '@atproto/xrpc';
import { Agent } from './agent.js';
import { ComAtprotoServerCreateAccount, ComAtprotoServerCreateSession, ComAtprotoServerGetSession, ComAtprotoServerNS, ComAtprotoServerRefreshSession } from './client/index.js';
import { SessionManager } from './session-manager.js';
import { AtpAgentLoginOpts, AtpPersistSessionHandler, AtpSessionData } from './types.js';
export type AtpAgentOptions = {
    service: string | URL;
    persistSession?: AtpPersistSessionHandler;
    fetch?: typeof globalThis.fetch;
    headers?: Iterable<[string, Gettable<null | string>]>;
};
/**
 * A wrapper around the {@link Agent} class that uses credential based session
 * management. This class also exposes most of the session management methods
 * directly.
 *
 * This class will be deprecated in the near future. Use {@link Agent} directly
 * with a {@link CredentialSession} instead:
 *
 *  ```ts
 *  const session = new CredentialSession({
 *    service: new URL('https://example.com'),
 *  })
 *
 *  const agent = new Agent(session)
 *  ```
 */
export declare class AtpAgent extends Agent {
    readonly sessionManager: CredentialSession;
    constructor(options: AtpAgentOptions | CredentialSession);
    clone(): AtpAgent;
    get session(): AtpSessionData | undefined;
    get hasSession(): boolean;
    get serviceUrl(): URL;
    get pdsUrl(): URL | undefined;
    get dispatchUrl(): URL;
    /** @deprecated use {@link serviceUrl} instead */
    get service(): URL;
    get persistSession(): unknown;
    set persistSession(v: unknown);
    /** @deprecated use {@link AtpAgent.serviceUrl} instead */
    getServiceUrl(): URL;
    resumeSession(session: AtpSessionData): Promise<ComAtprotoServerGetSession.Response>;
    createAccount(data: ComAtprotoServerCreateAccount.InputSchema, opts?: ComAtprotoServerCreateAccount.CallOptions): Promise<ComAtprotoServerCreateAccount.Response>;
    login(opts: AtpAgentLoginOpts): Promise<ComAtprotoServerCreateSession.Response>;
    logout(): Promise<void>;
}
/**
 * Credentials (username / password) based session manager. Instances of this
 * class will typically be used as the session manager for an {@link AtpAgent}.
 * They can also be used with an {@link XrpcClient}, if you want to use you
 * own Lexicons.
 */
export declare class CredentialSession implements SessionManager {
    readonly serviceUrl: URL;
    fetch: typeof fetch;
    protected readonly persistSession?: AtpPersistSessionHandler | undefined;
    pdsUrl?: URL;
    session?: AtpSessionData;
    refreshSessionPromise?: Promise<ComAtprotoServerRefreshSession.Response>;
    /**
     * Private {@link ComAtprotoServerNS} used to perform session management API
     * calls on the service endpoint. Calls performed by this agent will not be
     * authenticated using the user's session to allow proper manual configuration
     * of the headers when performing session management operations.
     */
    protected server: ComAtprotoServerNS;
    constructor(serviceUrl: URL, fetch?: typeof globalThis.fetch, persistSession?: AtpPersistSessionHandler | undefined);
    get did(): string | undefined;
    get dispatchUrl(): URL;
    get hasSession(): boolean;
    /**
     * Sets a WhatWG "fetch()" function to be used for making HTTP requests.
     */
    setFetch(fetch?: typeof globalThis.fetch): void;
    fetchHandler(url: string, init?: RequestInit): Promise<Response>;
    /**
     * Create a new account and hydrate its session in this agent.
     */
    createAccount(data: ComAtprotoServerCreateAccount.InputSchema, opts?: ComAtprotoServerCreateAccount.CallOptions): Promise<ComAtprotoServerCreateAccount.Response>;
    /**
     * Start a new session with this agent.
     */
    login(opts: AtpAgentLoginOpts): Promise<ComAtprotoServerCreateSession.Response>;
    logout(): Promise<void>;
    /**
     * Resume a pre-existing session with this agent.
     *
     * @note that a rejected promise from this method indicates a failure to
     * refresh the session after resuming it but does not indicate a failure to
     * set the session itself. In case of rejection, check the presence of
     * {@link CredentialSession.session} after calling this method to ensure the
     * session was set.
     */
    resumeSession(session: AtpSessionData): Promise<ComAtprotoServerRefreshSession.Response>;
    /**
     * Internal helper to refresh sessions
     * - Wraps the actual implementation in a promise-guard to ensure only
     *   one refresh is attempted at a time.
     */
    refreshSession(): Promise<ComAtprotoServerRefreshSession.Response>;
    /**
     * Internal helper to refresh sessions (actual behavior)
     */
    private _refreshSessionInner;
    /**
     * Helper to update the pds endpoint dynamically.
     *
     * The session methods (create, resume, refresh) may respond with the user's
     * did document which contains the user's canonical PDS endpoint. That endpoint
     * may differ from the endpoint used to contact the server. We capture that
     * PDS endpoint and update the client to use that given endpoint for future
     * requests. (This helps ensure smooth migrations between PDSes, especially
     * when the PDSes are operated by a single org.)
     */
    private _updateApiEndpoint;
}
//# sourceMappingURL=atp-agent.d.ts.map