// Type definitions for libp2p 0.20.4 // Project: https://github.com/libp2p/js-libp2p // Definitions by: Jaco Greeff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// /// /// /// /// /// /// /// /// /// declare namespace LibP2p { type CreateOptions = { DHT: typeof LibP2pKadDht, connection: { crypto: Array, muxer: Array }, discovery: Array, transport: LibP2pTransport[] }; type Events = 'peer:connect' | 'peer:disconnect' | 'peer:discovery' | 'start' | 'stop'; } declare class LibP2p { constructor (peerInfo: PeerInfo, PeerBook: PeerBook, options: LibP2p.CreateOptions); dial (peerInfo: PeerInfo, cb: (error: Error | null) => any): void; dialProtocol (peerInfo: PeerInfo, protocol: string, cb: (error: Error | null, conn?: LibP2pConnection) => any): void; handle (protocol: string, handler: (protocol: string, conn: LibP2pConnection) => any, matcher?: (protocol: string, requestedProtocol: string, cb: (error: Error | null, accept: boolean) => void) => any): void; isStarted (): boolean; on (event: LibP2p.Events, cb: (event: any) => any): void; start (cb: (error: Error | null) => any): void; stop (cb: (error: Error | null) => any): void; } declare module 'libp2p' { export default LibP2p; }