import type { DataStore } from './types/data-store.js';
import type { DidResolver } from '@enbox/dids';
import type { MessageStore } from './types/message-store.js';
import type { ResumableTaskStore } from './types/resumable-task-store.js';
import type { TenantGate } from './core/tenant-gate.js';
import type { UnionMessageReply } from './core/message-reply.js';
import type { ValidationStateReader } from './types/validation-state-reader.js';
import type { EventLog, SubscriptionListener } from './types/subscriptions.js';
import type { GenericMessage, GenericMessageReply } from './types/message-types.js';
import type { MessagesQueryMessage, MessagesQueryReply, MessagesReadMessage, MessagesReadReply, MessagesSubscribeMessage, MessagesSubscribeMessageOptions, MessagesSubscribeReply } from './types/messages-types.js';
import type { ProtocolsConfigureMessage, ProtocolsQueryMessage, ProtocolsQueryReply } from './types/protocols-types.js';
import type { RecordsCountMessage, RecordsCountReply, RecordsDeleteMessage, RecordsQueryMessage, RecordsQueryReply, RecordsReadMessage, RecordsReadReply, RecordsSubscribeMessage, RecordsSubscribeMessageOptions, RecordsSubscribeReply, RecordsWriteMessage, RecordsWriteMessageOptions } from './types/records-types.js';
import type { ReplicationApplyOptions, ReplicationApplyResult } from './core/replication-apply.js';
import { CoreProtocolRegistry } from './core/core-protocol.js';
type DwnStorage = {
    dataStore: DataStore;
    messageStore: MessageStore;
    eventLog: EventLog | undefined;
};
export declare class Dwn {
    private readonly methodHandlers;
    private readonly didResolver;
    private readonly messageStore;
    private readonly dataStore;
    private readonly resumableTaskStore;
    private readonly tenantGate;
    private readonly eventLog?;
    private readonly storageController;
    private readonly resumableTaskManager;
    private readonly _coreProtocols;
    private readonly validationStateReader;
    /** Whether the DWN owns the resolver's lifecycle (i.e., created it via defaults). */
    private readonly ownsResolver;
    private constructor();
    /**
     * Creates an instance of the DWN.
     */
    static create(config: DwnConfig): Promise<Dwn>;
    /**
     * Initializes the DWN instance and opens the connection to it.
     */
    open(): Promise<void>;
    close(): Promise<void>;
    /**
     * The registry of core protocols (hardcoded, immutable, always-installed).
     * Used by handlers and utilities that need to check whether a protocol URI
     * belongs to a core protocol or to dispatch lifecycle hooks.
     */
    get coreProtocols(): CoreProtocolRegistry;
    /**
     * Returns the internal storage components for advanced operations that
     * cannot be expressed through the standard `processMessage()` pipeline.
     *
     * Callers are responsible for maintaining consistency across stores.
     */
    get storage(): DwnStorage;
    /**
     * Processes the given DWN message and returns with a reply.
     * @param tenant The tenant DID to route the given message to.
     */
    processMessage(tenant: string, rawMessage: MessagesSubscribeMessage, options?: MessagesSubscribeMessageOptions): Promise<MessagesSubscribeReply>;
    processMessage(tenant: string, rawMessage: MessagesReadMessage): Promise<MessagesReadReply>;
    processMessage(tenant: string, rawMessage: MessagesQueryMessage): Promise<MessagesQueryReply>;
    processMessage(tenant: string, rawMessage: ProtocolsConfigureMessage): Promise<GenericMessageReply>;
    processMessage(tenant: string, rawMessage: ProtocolsQueryMessage): Promise<ProtocolsQueryReply>;
    processMessage(tenant: string, rawMessage: RecordsCountMessage): Promise<RecordsCountReply>;
    processMessage(tenant: string, rawMessage: RecordsDeleteMessage): Promise<GenericMessageReply>;
    processMessage(tenant: string, rawMessage: RecordsQueryMessage): Promise<RecordsQueryReply>;
    processMessage(tenant: string, rawMessage: RecordsSubscribeMessage, options: RecordsSubscribeMessageOptions): Promise<RecordsSubscribeReply>;
    processMessage(tenant: string, rawMessage: RecordsReadMessage): Promise<RecordsReadReply>;
    processMessage(tenant: string, rawMessage: RecordsWriteMessage, options?: RecordsWriteMessageOptions): Promise<GenericMessageReply>;
    processMessage(tenant: string, rawMessage: unknown, options?: MessageOptions): Promise<UnionMessageReply>;
    /**
     * Applies a message obtained through replication and returns a structured
     * outcome instead of an HTTP-like handler status. Normal authoring still
     * uses `processMessage`; sync uses this entry point so missing local
     * dependencies can be fetched and retried without treating the replicated
     * message as permanently invalid.
     */
    applyReplicatedMessage(tenant: string, rawMessage: GenericMessage, options?: ReplicationApplyOptions): Promise<ReplicationApplyResult>;
    /**
     * Computes the layer-batched missing-ancestor set for a replicated message that failed on a
     * missing ancestor (immediate parent or record-chain construction), so the resulting
     * `Incomplete` names every locally-absent ancestor at once. Returns `undefined`
     * (single-ancestor emission) when the set cannot be computed.
     */
    private getReplicationApplyMissingAncestors;
    private storeReplicatedWriteBeatenByDelete;
    private validateReplicatedWriteBeatenByDelete;
    private validateReplicatedWriteBeatenByDeleteOrThrow;
    private static validateReplicatedWriteBeatenByDeleteDataStream;
    private validateReplicatedWriteBeatenByDeleteExistingData;
    private static getDataStreamByteLength;
    private getReplicationApplyProtocolDefinition;
    private static getReplicationApplyProtocolDefinitionLookup;
    private static getEncryptionRecordTaggedProtocol;
    private static getMessageProtocolForReplicationApply;
    private static isRecordsWriteMessage;
    private replicatedMessageAlreadyStored;
    private getExistingMessagesForReplicationDedup;
    /**
     * Checks tenant gate to see if tenant is allowed.
     * @param tenant The tenant DID to route the given message to.
     * @returns GenericMessageReply if the message has an integrity error, otherwise undefined.
     */
    validateTenant(tenant: string): Promise<GenericMessageReply | undefined>;
    /**
     * Validates structure of DWN message
     * @param tenant The tenant DID to route the given message to.
     * @param dwnMessageInterface The interface of DWN message.
     * @param dwnMessageMethod The interface of DWN message.
  
     * @returns GenericMessageReply if the message has an integrity error, otherwise undefined.
     */
    validateMessageIntegrity(rawMessage: any): Promise<GenericMessageReply | undefined>;
}
/**
 *  MessageOptions that are used when processing a message.
 */
export interface MessageOptions {
    dataStream?: ReadableStream<Uint8Array>;
    subscriptionHandler?: SubscriptionListener;
}
/**
 * DWN configuration.
 */
export type DwnConfig = {
    didResolver?: DidResolver;
    tenantGate?: TenantGate;
    /**
     * Internal flag indicating the DWN created and owns the resolver's lifecycle.
     * When true, the DWN will call open()/close() on the resolver during its own lifecycle.
     * Set automatically by `Dwn.create()` when it creates a default resolver.
     * @internal
     */
    ownsResolver?: boolean;
    /**
     * Persistent event log with cursor-based reads and in-process subscriptions.
     * Optional — if not provided, subscriptions will not be supported.
     */
    eventLog?: EventLog;
    /**
     * Instrumentation seam: wraps the internally constructed `ValidationStateReader` before it is
     * handed to the handlers (e.g. with a `RecordingValidationStateReader`). Used by the
     * replay-basis closure tests and harnesses to record every validation-time state read.
     */
    instrumentValidationStateReader?: (validationStateReader: ValidationStateReader) => ValidationStateReader;
    messageStore: MessageStore;
    dataStore: DataStore;
    resumableTaskStore: ResumableTaskStore;
};
export {};
//# sourceMappingURL=dwn.d.ts.map