/** * Society Protocol — P2P Networking Module v1.0 (State of the Art) * * Features: * - GossipSub for scalable pub/sub messaging * - Kad-DHT for peer discovery and content routing * - mDNS for local network discovery * - Direct protocol streaming for large data * - Connection management and circuit relays */ import { type Libp2p } from 'libp2p'; import { EventEmitter } from 'events'; import { type SecurityManager } from './security.js'; export declare const SOCIETY_PROTOCOL = "/society/1.0.0"; export declare const TOPIC_PREFIX = "society/v1.0"; export declare function presenceTopic(roomId: string): string; export declare function chatTopic(roomId: string): string; export declare function cocTopic(roomId: string): string; export declare function adapterTopic(roomId: string): string; export declare function capsuleTopic(roomId: string): string; export declare function knowledgeTopic(spaceId: string): string; export declare function reputationTopic(roomId: string): string; export declare function federationTopic(roomId: string): string; export declare function personaTopic(roomId: string): string; export declare function missionTopic(roomId: string): string; export declare function researchTopic(roomId: string): string; export declare function cotStreamTopic(roomId: string): string; export interface P2PConfig { port?: number; wsPort?: number; bootstrapAddrs?: string[]; enableMdns?: boolean; enableDht?: boolean; enableGossipsub?: boolean; relayListenAddrs?: string[]; } export interface PeerInfo { id: string; addresses: string[]; protocols: string[]; latency?: number; connected: boolean; } export interface BandwidthStats { bytesSent: number; bytesReceived: number; messagesSent: number; messagesReceived: number; } export declare class P2PNode extends EventEmitter { private static inProcessTopicSubscribers; node: Libp2p; private config; private subscribedTopics; private seenMessages; private messageHandlers; private peerLatencies; private connectionPool; private gossipsubAvailable; private security?; private encryptedTopics; private stats; constructor(config?: P2PConfig); start(config?: P2PConfig): Promise; subscribe(topic: string, handler?: (data: Uint8Array, from: string) => void): Promise; unsubscribe(topic: string): Promise; publish(topic: string, data: Uint8Array, priority?: 'high' | 'normal' | 'low'): Promise; private publishDirect; subscribeRoom(roomId: string): void; unsubscribeRoom(roomId: string): void; provide(key: string): Promise; findProviders(key: string, maxNum?: number): Promise; findPeer(peerId: string): Promise; sendDirect(peerId: string, data: Uint8Array, topic?: string): Promise; getPeers(): string[]; getMultiaddrs(): string[]; getPeerId(): string; getPeerLatency(peerId: string): number | undefined; isSubscribed(topic: string): boolean; getBandwidthStats(): BandwidthStats; connectToPeer(address: string): Promise; getConnectedPeers(): PeerInfo[]; private handleProtocolStream; private handleGossipMessage; private publishInProcess; private deliverInProcess; private connectToBootstraps; private measureLatency; private startMaintenance; private hashMessage; /** * Attach a SecurityManager for E2E encryption. * Call this before publishing encrypted messages. */ setSecurityManager(security: SecurityManager): void; /** * Enable encryption for all messages on a given topic. */ enableEncryption(topic: string): void; /** * Disable encryption for a topic. */ disableEncryption(topic: string): void; /** * Check if encryption is enabled for a topic. */ isEncrypted(topic: string): boolean; /** * Get the local encryption public key (for key exchange). */ getEncryptionPublicKey(): Promise; stop(): Promise; } //# sourceMappingURL=p2p.d.ts.map