@libp2p/interfaces
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -143,9 +143,9 @@ import type { PeerId } from '../peer-id'; | ||
/** | ||
* Enable server mode (e.g. allow publishing provider records) | ||
* Returns the mode this node is in | ||
*/ | ||
enableServerMode: () => void; | ||
getMode: () => Promise<'client' | 'server'>; | ||
/** | ||
* Enable server mode (e.g. disallow publishing provider records) | ||
* If 'server' this node will respond to DHT queries, if 'client' this node will not | ||
*/ | ||
enableClientMode: () => void; | ||
setMode: (mode: 'client' | 'server') => Promise<void>; | ||
/** | ||
@@ -152,0 +152,0 @@ * Force a routing table refresh |
import type { PeerId } from './peer-id/index.js'; | ||
import type { Multiaddr } from '@multiformats/multiaddr'; | ||
import type { Duplex } from 'it-stream-types'; | ||
import type { ProtocolStream, Connection } from './connection/index.js'; | ||
export interface AbortOptions { | ||
@@ -13,7 +13,8 @@ signal?: AbortSignal; | ||
export interface Dialer { | ||
dial: (peer: PeerId, options?: { | ||
signal?: AbortSignal; | ||
}) => Promise<Connection>; | ||
dialProtocol: (peer: PeerId, protocol: string, options?: { | ||
signal?: AbortSignal; | ||
}) => Promise<{ | ||
stream: Duplex<Uint8Array>; | ||
}>; | ||
}) => Promise<ProtocolStream>; | ||
} | ||
@@ -20,0 +21,0 @@ export interface Addressable { |
import type { EventEmitter } from '../index.js'; | ||
import type { Connection, Stream } from '../connection/index.js'; | ||
import type { PeerId } from '../peer-id/index.js'; | ||
import type { Topology } from '../topology/index.js'; | ||
export interface IncomingStreamData { | ||
@@ -19,7 +20,9 @@ protocol: string; | ||
export interface Registrar { | ||
handle: (multicodec: string | string[], handler: StreamHandler) => Promise<void>; | ||
unhandle: (multicodec: string) => Promise<void>; | ||
register: (topology: any) => string; | ||
handle: (protocol: string | string[], handler: StreamHandler) => Promise<string>; | ||
unhandle: (id: string) => Promise<void>; | ||
getHandlers: (protocol: string) => StreamHandler[]; | ||
register: (protocols: string | string[], topology: Topology) => string; | ||
unregister: (id: string) => void; | ||
getTopologies: (protocol: string) => Topology[]; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
import type { PeerId } from '../peer-id/index.js'; | ||
import type { Connection } from '../connection/index.js'; | ||
import type { ConnectionManager } from '../registrar/index.js'; | ||
import type { PeerStore } from '../peer-store/index.js'; | ||
export interface onConnectHandler { | ||
@@ -11,6 +9,2 @@ (peerId: PeerId, conn: Connection): void; | ||
} | ||
export interface Handlers { | ||
onConnect?: onConnectHandler; | ||
onDisconnect?: onDisconnectHandler; | ||
} | ||
export interface TopologyOptions { | ||
@@ -25,3 +19,4 @@ /** | ||
max?: number; | ||
handlers: Handlers; | ||
onConnect?: onConnectHandler; | ||
onDisconnect?: onDisconnectHandler; | ||
} | ||
@@ -32,12 +27,5 @@ export interface Topology { | ||
peers: Set<string>; | ||
disconnect: (id: PeerId) => void; | ||
onConnect: (peerId: PeerId, conn: Connection) => void; | ||
onDisconnect: (peerId: PeerId) => void; | ||
} | ||
export interface MulticodecTopologyOptions extends TopologyOptions { | ||
multicodecs: string[]; | ||
peerStore: PeerStore; | ||
connectionManager: ConnectionManager; | ||
} | ||
export interface MulticodecTopology extends Topology { | ||
multicodecs: string[]; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@libp2p/interfaces", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Interfaces for JS Libp2p", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT", |
@@ -164,10 +164,10 @@ import type { PeerId } from '../peer-id' | ||
/** | ||
* Enable server mode (e.g. allow publishing provider records) | ||
* Returns the mode this node is in | ||
*/ | ||
enableServerMode: () => void | ||
getMode: () => Promise<'client' | 'server'> | ||
/** | ||
* Enable server mode (e.g. disallow publishing provider records) | ||
* If 'server' this node will respond to DHT queries, if 'client' this node will not | ||
*/ | ||
enableClientMode: () => void | ||
setMode: (mode: 'client' | 'server') => Promise<void> | ||
@@ -174,0 +174,0 @@ /** |
import type { PeerId } from './peer-id/index.js' | ||
import type { Multiaddr } from '@multiformats/multiaddr' | ||
import type { Duplex } from 'it-stream-types' | ||
import type { ProtocolStream, Connection } from './connection/index.js' | ||
@@ -15,8 +15,7 @@ export interface AbortOptions { | ||
// Implemented by libp2p, should be moved to libp2p-interfaces eventually | ||
export interface Dialer { | ||
dialProtocol: (peer: PeerId, protocol: string, options?: { signal?: AbortSignal }) => Promise<{ stream: Duplex<Uint8Array> }> | ||
dial: (peer: PeerId, options?: { signal?: AbortSignal }) => Promise<Connection> | ||
dialProtocol: (peer: PeerId, protocol: string, options?: { signal?: AbortSignal }) => Promise<ProtocolStream> | ||
} | ||
// Implemented by libp2p, should be moved to libp2p-interfaces eventually | ||
export interface Addressable { | ||
@@ -23,0 +22,0 @@ multiaddrs: Multiaddr[] |
import type { EventEmitter } from '../index.js' | ||
import type { Connection, Stream } from '../connection/index.js' | ||
import type { PeerId } from '../peer-id/index.js' | ||
import type { Topology } from '../topology/index.js' | ||
@@ -24,7 +25,9 @@ export interface IncomingStreamData { | ||
export interface Registrar { | ||
handle: (multicodec: string | string[], handler: StreamHandler) => Promise<void> | ||
unhandle: (multicodec: string) => Promise<void> | ||
handle: (protocol: string | string[], handler: StreamHandler) => Promise<string> | ||
unhandle: (id: string) => Promise<void> | ||
getHandlers: (protocol: string) => StreamHandler[] | ||
register: (topology: any) => string | ||
register: (protocols: string | string[], topology: Topology) => string | ||
unregister: (id: string) => void | ||
getTopologies: (protocol: string) => Topology[] | ||
} |
import type { PeerId } from '../peer-id/index.js' | ||
import type { Connection } from '../connection/index.js' | ||
import type { ConnectionManager } from '../registrar/index.js' | ||
import type { PeerStore } from '../peer-store/index.js' | ||
export interface onConnectHandler { (peerId: PeerId, conn: Connection): void } | ||
export interface onDisconnectHandler { (peerId: PeerId, conn?: Connection): void } | ||
export interface onConnectHandler { | ||
(peerId: PeerId, conn: Connection): void | ||
} | ||
export interface Handlers { | ||
onConnect?: onConnectHandler | ||
onDisconnect?: onDisconnectHandler | ||
export interface onDisconnectHandler { | ||
(peerId: PeerId, conn?: Connection): void | ||
} | ||
@@ -24,3 +22,4 @@ | ||
max?: number | ||
handlers: Handlers | ||
onConnect?: onConnectHandler | ||
onDisconnect?: onDisconnectHandler | ||
} | ||
@@ -33,13 +32,4 @@ | ||
disconnect: (id: PeerId) => void | ||
onConnect: (peerId: PeerId, conn: Connection) => void | ||
onDisconnect: (peerId: PeerId) => void | ||
} | ||
export interface MulticodecTopologyOptions extends TopologyOptions { | ||
multicodecs: string[] | ||
peerStore: PeerStore | ||
connectionManager: ConnectionManager | ||
} | ||
export interface MulticodecTopology extends Topology { | ||
multicodecs: string[] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1310018
2203