import { NetworkNode, Peering } from './types'; /** * Fetch peering information from a Duniter node * * Uses the `duniter_peerings` RPC method to discover other nodes * in the network. * * @param endpoint - RPC endpoint URL (wss:// or ws://) * @param timeout - Timeout in milliseconds (default: 5000) * @returns Array of peering information * * @example * ```ts * const peerings = await fetchPeerings('wss://gdev.cgeek.fr') * for (const peer of peerings) { * console.log(`Peer ${peer.peer_id}: ${peer.endpoints.length} endpoints`) * } * ``` */ export declare function fetchPeerings(endpoint: string, timeout?: number): Promise; /** * Reduce peerings to a map of peer_id -> endpoints for a specific protocol * * @param peerings - Array of peering information * @param protocol - Protocol to filter ('rpc' or 'squid') * @returns Map of peer_id to endpoint URLs * * @example * ```ts * const peerings = await fetchPeerings('wss://gdev.cgeek.fr') * const rpcByPeer = reduceEndpoints(peerings, 'rpc') * // { 'peer123': ['wss://node1.example.com', 'wss://node2.example.com'] } * ``` */ export declare function reduceEndpoints(peerings: Peering[], protocol: 'rpc' | 'squid'): Record; /** * Filter peerings to get unique endpoints for a specific protocol * * @param peerings - Array of peering information * @param protocol - Protocol to filter ('rpc' or 'squid') * @returns Array of unique endpoint URLs * * @example * ```ts * const peerings = await fetchPeerings('wss://gdev.cgeek.fr') * const rpcEndpoints = filterEndpoints(peerings, 'rpc') * // ['wss://node1.example.com', 'wss://node2.example.com', ...] * ``` */ export declare function filterEndpoints(peerings: Peering[], protocol: 'rpc' | 'squid'): string[]; /** * Discover peers from an RPC endpoint and return as NetworkNode array * * @param endpoint - RPC endpoint to query for peerings * @param timeout - Timeout in milliseconds (default: 5000) * @returns Array of discovered NetworkNode (status: pending) * * @example * ```ts * const nodes = await discoverPeers('wss://gdev.cgeek.fr') * // Returns nodes with type 'rpc' or 'squid', status 'pending' * ``` */ export declare function discoverPeers(endpoint: string, timeout?: number): Promise; /** * Normalize endpoint URL * * Ensures consistent URL format: * - Removes trailing slashes * - Lowercases the protocol * * @param endpoint - Endpoint URL to normalize * @returns Normalized URL */ export declare function normalizeEndpoint(endpoint: string): string; /** * Get unique endpoints from an array, removing duplicates * * @param endpoints - Array of endpoint URLs * @returns Array of unique, normalized endpoints */ export declare function uniqueEndpoints(endpoints: string[]): string[];