import type { Result } from '@private.me/shared';
import type { AnyTransportEnvelope } from './envelope.js';
/** Transport-level error codes. */
export type TransportError = 'SEND_FAILED' | 'NETWORK_ERROR' | 'RECIPIENT_UNREACHABLE' | 'TIMEOUT' | 'HTTPS_REQUIRED' | 'INVALID_URL';
/** Handler invoked when an envelope is received. */
export type EnvelopeHandler = (envelope: AnyTransportEnvelope) => void;
/**
 * Transport adapter interface for delivering signed envelopes.
 *
 * Both HTTPS (SDK default) and WebRTC (P2P, Phase 2) implement this contract.
 * Accepts v1 and v2 envelopes.
 */
export interface XailTransportAdapter {
    /** Send a signed envelope to a recipient. */
    send(envelope: AnyTransportEnvelope, recipientDid: string): Promise<Result<void, TransportError>>;
    /** Register a handler for incoming envelopes. */
    onReceive(handler: EnvelopeHandler): void;
    /** Shut down the transport (close connections, clear handlers). */
    dispose(): void;
}
/** Options for HttpsTransportAdapter. */
export interface HttpsTransportOptions {
    /** Base URL for envelope delivery endpoint. */
    readonly baseUrl: string;
    /** Request timeout in milliseconds. Default: 10000. */
    readonly timeoutMs?: number;
    /** Custom fetch implementation (for testing). */
    readonly fetch?: typeof globalThis.fetch;
}
/**
 * HTTPS transport adapter — sends envelopes as JSON POST requests.
 *
 * Recipient URL resolved as: baseUrl/deliver/{recipientDid}
 * This is the SDK's default transport for server-to-server delivery.
 */
export declare class HttpsTransportAdapter implements XailTransportAdapter {
    private readonly baseUrl;
    private readonly timeoutMs;
    private readonly fetchFn;
    private handlers;
    constructor(opts: HttpsTransportOptions);
    send(envelope: AnyTransportEnvelope, recipientDid: string): Promise<Result<void, TransportError>>;
    onReceive(handler: EnvelopeHandler): void;
    /**
     * Dispatch a received envelope to all handlers.
     * Called by the server when an incoming POST is received.
     */
    dispatch(envelope: AnyTransportEnvelope): void;
    dispose(): void;
}
