/**
 * NOTE: Added reference types here to avoid a `pnpm` bug during build.
 * https://github.com/enboxorg/enbox/pull/507
 */
import type { AuthSession } from '@enbox/auth';
import type { DidMethodResolver } from '@enbox/dids';
import type { EnboxAgent } from '@enbox/agent';
import type { ProtocolDefinition } from '@enbox/dwn-sdk-js';
import type { SchemaMap, TypedProtocol } from './protocol-types.js';
import { DidApi } from './did-api.js';
import { DwnReaderApi } from './dwn-reader-api.js';
import { TypedEnbox } from './typed-enbox.js';
import { VcApi } from './vc-api.js';
/**
 * Options for creating an anonymous (read-only) Enbox instance via {@link Enbox.anonymous}.
 *
 * @beta
 */
export type EnboxAnonymousOptions = {
    /** Override the default DID method resolvers. Defaults to `[DidDht, DidJwk, DidKey, DidWeb]`. */
    didResolvers?: DidMethodResolver[];
};
/**
 * The result of calling {@link Enbox.anonymous}.
 *
 * Contains only a read-only `dwn` property — no `did`, `vc`, or `agent`.
 *
 * @beta
 */
export type EnboxAnonymousApi = {
    /** A read-only DWN API for querying public data on remote DWNs. */
    dwn: DwnReaderApi;
};
/**
 * Parameters for constructing an {@link Enbox} instance.
 *
 * These are the minimal primitives needed to interact with the DWN network.
 * Typically obtained from an {@link AuthSession} via `@enbox/auth`.
 */
export type EnboxParams = {
    /**
     * A {@link EnboxAgent} instance that handles DIDs, DWNs and VCs requests. The agent manages the
     * user keys and identities, and is responsible to sign and verify messages.
     */
    agent: EnboxAgent;
    /** The DID of the tenant under which all DID, DWN, and VC requests are being performed. */
    connectedDid: string;
    /** The DID that will be signing messages using grants from the connectedDid. */
    delegateDid?: string;
};
/**
 * The main Enbox API interface. It provides protocol-scoped access to
 * Decentralized Web Nodes (DWNs), Decentralized Identifiers (DIDs),
 * and Verifiable Credentials (VCs).
 *
 * Authentication and identity management are handled externally by
 * `@enbox/auth`. Use {@link Enbox.connect} to create an instance from
 * an {@link AuthSession} or raw parameters.
 *
 * @example
 * ```ts
 * import { AuthManager } from '@enbox/auth';
 * import { Enbox } from '@enbox/api';
 *
 * const auth = await AuthManager.create({ sync: '15s' });
 * const session = await auth.connect();
 *
 * const enbox = Enbox.connect({ session });
 * const social = enbox.using(SocialProtocol);
 * ```
 */
export declare class Enbox {
    /**
     * A {@link EnboxAgent} instance that handles DIDs, DWNs and VCs requests. The agent manages the
     * user keys and identities, and is responsible to sign and verify messages.
     */
    agent: EnboxAgent;
    /** Exposed instance to the DID APIs, allow users to create and resolve DIDs. */
    did: DidApi;
    /** Internal DWN API instance. Use {@link Enbox.using} for protocol-scoped access. */
    private _dwn;
    /**
     * Cache of {@link TypedEnbox} instances keyed by protocol URI.
     *
     * Ensures that `enbox.using(Protocol)` returns the **same** `TypedEnbox`
     * instance for a given protocol across multiple call sites, avoiding
     * redundant protocol installations and duplicated internal state.
     */
    private _typedInstances;
    /** Exposed instance to the VC APIs, allow users to issue, present and verify VCs. */
    vc: VcApi;
    constructor({ agent, connectedDid, delegateDid }: EnboxParams);
    /**
     * Returns a {@link TypedEnbox} instance scoped to the given protocol.
     *
     * This is the **primary developer interface** for interacting with
     * protocol-backed records. It auto-injects the protocol URI, protocolPath,
     * and schema into every operation, and provides compile-time path
     * autocompletion plus typed data payloads via the schema map.
     *
     * Instances are **cached by protocol URI** — calling `using()` multiple
     * times with the same protocol returns the same `TypedEnbox` instance,
     * so auto-configure only runs once and all call sites share state.
     *
     * @param protocol - A typed protocol created via `defineProtocol()`.
     * @returns A `TypedEnbox` instance bound to the given protocol.
     *
     * @example
     * ```ts
     * const social = enbox.using(SocialProtocol);
     *
     * await social.configure();
     *
     * const { record } = await social.records.write('friend', {
     *   data: { did: 'did:example:alice', alias: 'Alice' },
     * });
     *
     * const { records } = await social.records.query('friend');
     * ```
     */
    using<D extends ProtocolDefinition, M extends SchemaMap>(protocol: TypedProtocol<D, M>): TypedEnbox<D, M>;
    /**
     * Stops DWN sync and clears the cached {@link TypedEnbox} instances.
     *
     * Call this when the application is shutting down or the user is
     * disconnecting to cleanly release background resources. After calling
     * `disconnect()`, the `Enbox` instance should not be reused.
     *
     * @param timeout - Maximum milliseconds to wait for an in-progress sync
     *   cycle to finish before force-stopping. Defaults to `2000`.
     *
     * @example
     * ```ts
     * await enbox.disconnect();
     * ```
     *
     * @beta
     */
    disconnect(timeout?: number): Promise<void>;
    /**
     * Creates a lightweight, read-only Enbox instance for querying public DWN data.
     *
     * No identity, vault, password, or signing keys are required. The returned
     * API supports querying and reading published records and protocols from any
     * remote DWN, using **unsigned** (anonymous) DWN messages.
     *
     * @param options - Optional configuration overrides.
     * @returns An {@link EnboxAnonymousApi} with a read-only `dwn` property.
     *
     * @example
     * ```ts
     * const { dwn } = Enbox.anonymous();
     *
     * const { records } = await dwn.records.query({
     *   from: 'did:dht:alice...',
     *   filter: { protocol: 'https://social.example/posts', protocolPath: 'post' },
     * });
     *
     * for (const record of records) {
     *   console.log(record.id, await record.data.text());
     * }
     * ```
     *
     * @beta
     */
    static anonymous(options?: EnboxAnonymousOptions): EnboxAnonymousApi;
    /**
     * Creates an {@link Enbox} instance from an {@link AuthSession} or raw parameters.
     *
     * This is a thin factory — all authentication, identity management, vault
     * initialization, DWN registration, and sync setup are handled externally
     * by `@enbox/auth` via {@link AuthSession}.
     *
     * @param params - Either `{ session }` with an {@link AuthSession} from
     *   `@enbox/auth`, or raw `{ agent, connectedDid, delegateDid? }` parameters.
     * @returns A new {@link Enbox} instance ready for use.
     *
     * @example
     * ```ts
     * // Using an AuthSession from @enbox/auth
     * import { AuthManager } from '@enbox/auth';
     * const auth = await AuthManager.create({ sync: '15s' });
     * const session = await auth.connect();
     * const enbox = Enbox.connect({ session });
     *
     * // Using raw parameters
     * const enbox = Enbox.connect({ agent, connectedDid: did });
     * ```
     */
    static connect(params: {
        session: AuthSession;
    } | EnboxParams): Enbox;
}
//# sourceMappingURL=enbox.d.ts.map