/**
 * Gateway transport adapter for delivering envelopes to Xail inbox users.
 *
 * Sends envelopes via POST /gateway/deliver on the hosted gateway API.
 * For agent-to-agent (M2M), use HttpsTransportAdapter with direct URLs.
 * Optionally polls for incoming messages.
 */
import type { Result } from '@private.me/shared';
import type { TransportEnvelope } from './envelope.js';
import type { XailTransportAdapter, TransportError, EnvelopeHandler } from './transport.js';
/** Options for GatewayTransport. */
export interface GatewayTransportOptions {
    /** API key for gateway authentication. */
    readonly apiKey: string;
    /** Gateway base URL. Required — no default to prevent accidental sends. */
    readonly gateway: string;
    /** Request timeout in ms. Default: 15000. */
    readonly timeoutMs?: number;
    /** Custom fetch implementation (for testing). */
    readonly fetch?: typeof globalThis.fetch;
    /** Polling interval for incoming messages in ms. Default: 0 (disabled). */
    readonly pollIntervalMs?: number;
}
/**
 * Transport adapter for the Xail Gateway.
 *
 * Sends envelopes via POST /gateway/deliver with API key auth.
 * Optionally polls GET /gateway/messages/:did for incoming messages.
 */
export declare class GatewayTransport implements XailTransportAdapter {
    private readonly apiKey;
    private readonly gateway;
    private readonly timeoutMs;
    private readonly fetchFn;
    private readonly pollIntervalMs;
    private handlers;
    private pollTimer;
    private senderDid;
    constructor(opts: GatewayTransportOptions);
    /**
     * Send a signed envelope to a recipient via the gateway.
     * @param envelope - The signed transport envelope.
     * @param _recipientDid - Recipient DID (already in envelope.recipient).
     * @returns Success or transport error.
     */
    send(envelope: TransportEnvelope, _recipientDid: string): Promise<Result<void, TransportError>>;
    /** Register a handler for incoming envelopes. */
    onReceive(handler: EnvelopeHandler): void;
    /**
     * Start polling for incoming messages.
     * Must be called after Agent.create() sets the sender DID.
     * @param did - The agent's own DID for polling.
     */
    startPolling(did: string): void;
    /** Shut down the transport (stop polling, clear handlers). */
    dispose(): void;
    /** Poll for incoming messages and dispatch to handlers. */
    private poll;
}
