/**
 * Protocol definition fetching and caching utilities for {@link AgentDwnApi}.
 *
 * Extracted from `dwn-api.ts` to keep protocol-resolution logic in its own
 * module.
 *
 * @module
 */
import type { DidUrlDereferencer } from '@enbox/dids';
import type { PublicKeyJwk } from '@enbox/crypto';
import type { TtlCache } from '@enbox/common';
import type { ProtocolDefinition } from '@enbox/dwn-sdk-js';
import type { DwnInterface, DwnMessage, DwnMessageReply, DwnSigner, MessageHandler } from './types/dwn.js';
/** Callback to obtain a DWN signer for a given DID. */
type GetSignerFn = (author: string) => Promise<DwnSigner>;
/** Callback to send a raw DWN request to a remote endpoint. */
type SendDwnRpcRequestFn = <T extends DwnInterface>(params: {
    targetDid: string;
    dwnEndpointUrls: string[];
    message: DwnMessage[T];
    data?: Blob;
    subscriptionHandler?: MessageHandler[T];
}) => Promise<DwnMessageReply[T]>;
/** Minimal DWN interface needed for local `processMessage` calls. */
interface DwnNode {
    processMessage(tenant: string, message: unknown, options?: unknown): Promise<any>;
}
/**
 * Fetches a protocol definition from the **local** DWN, backed by a TTL cache.
 *
 * @param tenantDid - The DID whose DWN to query
 * @param protocolUri - The protocol URI to look up
 * @param dwn - The local DWN instance
 * @param getSigner - Callback to obtain the signer for `tenantDid`
 * @param cache - The shared protocol definition cache
 * @returns The protocol definition, or `undefined` if not installed
 */
export declare function getProtocolDefinition(tenantDid: string, protocolUri: string, dwn: DwnNode, getSigner: GetSignerFn, cache: TtlCache<string, ProtocolDefinition>): Promise<ProtocolDefinition | undefined>;
/**
 * Fetches a protocol definition from a **remote** DWN.
 *
 * Uses an unsigned `ProtocolsQuery` since public protocols can be queried
 * anonymously.
 *
 * @param targetDid - The remote DWN owner
 * @param protocolUri - The protocol URI to look up
 * @param didDereferencer - A DID URL dereferencer for resolving service endpoints
 * @param sendDwnRpcRequest - Callback to send the RPC query
 * @param cache - The shared protocol definition cache
 * @returns The protocol definition
 * @throws If the protocol cannot be fetched
 */
export declare function fetchRemoteProtocolDefinition(targetDid: string, protocolUri: string, didDereferencer: DidUrlDereferencer, sendDwnRpcRequest: SendDwnRpcRequestFn, cache: TtlCache<string, ProtocolDefinition>): Promise<ProtocolDefinition>;
/**
 * Extracts the `derivedPublicKey` from an existing `ProtocolContext`-encrypted
 * record in a context on a remote DWN.
 *
 * This key allows an external author to encrypt new records in the same
 * context without knowing the context private key.
 *
 * @param targetDid      - The DWN owner's DID
 * @param protocolUri    - The protocol URI to search
 * @param rootContextId  - The root context ID
 * @param requesterDid   - The DID of the requester (used for signing the query)
 * @param didDereferencer - A DID URL dereferencer for resolving service endpoints
 * @param getSigner      - Callback to obtain the signer for `requesterDid`
 * @param sendDwnRpcRequest - Callback to send the RPC query
 * @returns The rootKeyId and derivedPublicKey, or `undefined` if no
 *          `ProtocolContext` record exists yet
 */
export declare function extractDerivedPublicKey(targetDid: string, protocolUri: string, rootContextId: string, requesterDid: string, didDereferencer: DidUrlDereferencer, getSigner: GetSignerFn, sendDwnRpcRequest: SendDwnRpcRequestFn): Promise<{
    rootKeyId: string;
    derivedPublicKey: PublicKeyJwk;
} | undefined>;
export {};
//# sourceMappingURL=dwn-protocol-cache.d.ts.map