/**
 * @module discovery
 * Service discovery for zero-config XBind connections.
 *
 * Enables: `xbind connect payments-service`
 *
 * Four-tier discovery:
 * 1. Public registry (xbind.registry.io)
 * 2. Well-known URL (https://service.com/.well-known/xbind)
 * 3. DNS TXT record (_xbind.service.com)
 * 4. Direct URL/QR code
 */
import { Result } from '@private.me/shared';
/**
 * Service metadata returned from discovery.
 */
export interface ServiceInfo {
    /** Service identifier (e.g., "payments-service") */
    name: string;
    /** XBind endpoint URL */
    endpoint: string;
    /** DID of the service */
    did: string;
    /** Public key (Ed25519, base64) */
    publicKey: string;
    /** X25519 public key for ECDH (optional, base64) */
    x25519PublicKey?: string;
    /** ML-KEM-768 public key for PQ KEM (optional, base64) */
    mlKemPublicKey?: string;
    /** Service description */
    description?: string;
    /** Logo URL */
    logo?: string;
    /** Documentation URL */
    docs?: string;
    /** Whether this service is verified */
    verified?: boolean;
}
/**
 * Discovery error codes.
 */
export declare enum DiscoveryErrorCode {
    SERVICE_NOT_FOUND = "DISCOVERY_SERVICE_NOT_FOUND",
    REGISTRY_UNREACHABLE = "DISCOVERY_REGISTRY_UNREACHABLE",
    INVALID_RESPONSE = "DISCOVERY_INVALID_RESPONSE",
    NETWORK_ERROR = "DISCOVERY_NETWORK_ERROR",
    INVALID_SERVICE_NAME = "DISCOVERY_INVALID_SERVICE_NAME",
    DNS_ERROR = "DISCOVERY_DNS_ERROR",
    INVALID_EMAIL = "DISCOVERY_INVALID_EMAIL",
    PERSONAL_EMAIL_DOMAIN = "DISCOVERY_PERSONAL_EMAIL_DOMAIN"
}
/**
 * Discovery error.
 */
export interface DiscoveryError {
    code: DiscoveryErrorCode;
    message: string;
    hint?: string;
}
/**
 * Discovery client for finding services.
 */
export declare class ServiceDiscovery {
    private registryUrl;
    private dnsCache;
    /**
     * Create a discovery client.
     *
     * @param options - Configuration options
     * @param options.registryUrl - Registry URL (default: https://xbind.registry.io)
     */
    constructor(options?: {
        registryUrl?: string;
    });
    /**
     * Discover a service by name.
     *
     * Tries:
     * 1. Email-based discovery (extracts domain from email)
     * 2. Public registry lookup
     * 3. Well-known URL if name is a domain
     * 4. DNS TXT record (_xbind.domain)
     * 5. Direct URL if name is a full URL
     *
     * @param nameOrUrl - Service name, email, domain, or URL
     * @returns Service info or error
     *
     * @example
     * ```ts
     * const discovery = new ServiceDiscovery();
     *
     * // By name (registry lookup):
     * const result = await discovery.discover('payments-service');
     *
     * // By email (domain extraction):
     * const result = await discovery.discover('alice@company.com');
     *
     * // By domain (well-known):
     * const result = await discovery.discover('payments.example.com');
     *
     * // By URL (direct):
     * const result = await discovery.discover('https://api.payments.com/xbind');
     * ```
     */
    discover(nameOrUrl: string): Promise<Result<ServiceInfo, DiscoveryError>>;
    /**
     * Look up service in public registry.
     *
     * GET https://xbind.registry.io/lookup/:name
     */
    private discoverRegistry;
    /**
     * Discover via .well-known/xbind.
     *
     * GET https://domain/.well-known/xbind
     */
    private discoverWellKnown;
    /**
     * Discover via direct URL.
     */
    private discoverDirect;
    /**
     * Discover via DNS TXT record.
     *
     * Looks up TXT record at _xbind.domain
     *
     * Supports two formats:
     * 1. Full record: "xbind-endpoint=https://...;did=did:web:...;publicKey=..." (all fields in DNS)
     * 2. Simple redirect: "xbind=https://api.example.com/xbind" (fetch from endpoint)
     *
     * Includes 5-minute caching to reduce DNS queries.
     */
    private discoverDnsTxt;
    /**
     * Parse DNS TXT record into ServiceInfo.
     *
     * Expected format:
     * xbind-endpoint=https://...;did=did:web:...;publicKey=...;version=1.0
     *
     * Optional fields:
     * x25519PublicKey=...;mlKemPublicKey=...;description=...;logo=...;docs=...
     */
    private parseDnsTxtRecord;
    /**
     * Discover service via email address.
     *
     * Extracts domain from email and performs discovery.
     * Personal email domains (gmail.com, outlook.com, etc.) are rejected.
     *
     * @param email - Email address (e.g., "alice@company.com")
     * @returns Service info or error
     *
     * @example
     * ```ts
     * const discovery = new ServiceDiscovery();
     * const result = await discovery.discoverEmail('alice@company.com');
     * // Discovers service at company.com
     * ```
     */
    private discoverEmail;
    /**
     * Extract domain from email address.
     * Handles edge cases: subdomains, plus addressing, etc.
     *
     * @param email - Email address
     * @returns Domain or null if extraction fails
     *
     * @example
     * ```ts
     * extractDomain('alice@company.com') // 'company.com'
     * extractDomain('alice+label@company.com') // 'company.com'
     * extractDomain('alice@mail.company.com') // 'mail.company.com'
     * ```
     */
    private extractDomain;
}
