@libp2p/interfaces
Advanced tools
Comparing version 1.3.13 to 1.3.14
@@ -1,6 +0,3 @@ | ||
import type { PeerId } from '../peer-id'; | ||
import type { MultiaddrConnection } from '../transport'; | ||
export interface EncrypterFactory<EncrypterInit> { | ||
new (init?: EncrypterInit): Crypto; | ||
} | ||
import type { PeerId } from '../peer-id/index.js'; | ||
import type { Duplex } from 'it-stream-types'; | ||
/** | ||
@@ -10,3 +7,3 @@ * A libp2p connection encrypter module must be compliant to this interface | ||
*/ | ||
export interface Encrypter { | ||
export interface ConnectionEncrypter { | ||
protocol: string; | ||
@@ -16,10 +13,10 @@ /** | ||
*/ | ||
secureOutbound: (localPeer: PeerId, connection: MultiaddrConnection, remotePeer: PeerId) => Promise<SecureOutbound>; | ||
secureOutbound: (localPeer: PeerId, connection: Duplex<Uint8Array>, remotePeer: PeerId) => Promise<SecuredConnection>; | ||
/** | ||
* Decrypt incoming data. | ||
*/ | ||
secureInbound: (localPeer: PeerId, connection: MultiaddrConnection, remotePeer?: PeerId) => Promise<SecureOutbound>; | ||
secureInbound: (localPeer: PeerId, connection: Duplex<Uint8Array>, remotePeer?: PeerId) => Promise<SecuredConnection>; | ||
} | ||
export interface SecureOutbound { | ||
conn: MultiaddrConnection; | ||
export interface SecuredConnection { | ||
conn: Duplex<Uint8Array>; | ||
remoteEarlyData: Uint8Array; | ||
@@ -26,0 +23,0 @@ remotePeer: PeerId; |
@@ -54,7 +54,9 @@ import type { Multiaddr } from '@multiformats/multiaddr'; | ||
streams: Stream[]; | ||
newStream: (multicodecs: string[]) => Promise<ProtocolStream>; | ||
addStream: (stream: Stream, data: Metadata) => void; | ||
newStream: (multicodecs: string | string[]) => Promise<ProtocolStream>; | ||
addStream: (stream: Stream, data: Partial<Metadata>) => void; | ||
removeStream: (id: string) => void; | ||
close: () => Promise<void>; | ||
} | ||
export declare const symbol: unique symbol; | ||
export declare function isConnection(other: any): other is Connection; | ||
export interface ConnectionGater { | ||
@@ -146,2 +148,10 @@ /** | ||
} | ||
export interface ConnectionProtector { | ||
/** | ||
* Takes a given Connection and creates a private encryption stream | ||
* between its two peers from the PSK the Protector instance was | ||
* created with. | ||
*/ | ||
protect: (connection: MultiaddrConnection) => Promise<MultiaddrConnection>; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,5 @@ | ||
export {}; | ||
export const symbol = Symbol.for('@libp2p/connection'); | ||
export function isConnection(other) { | ||
return symbol in other; | ||
} | ||
//# sourceMappingURL=index.js.map |
import type { CID } from 'multiformats/cid'; | ||
import type { AbortOptions } from '../index'; | ||
import type { PeerData } from '../peer-data'; | ||
export interface ContentRoutingFactory<ContentRoutingInit> { | ||
new (init?: ContentRoutingInit): ContentRouting; | ||
import type { AbortOptions } from '../index.js'; | ||
import type { PeerData } from '../peer-data/index.js'; | ||
import type { PeerId } from '../peer-id/index.js'; | ||
export interface GetResult { | ||
from: PeerId; | ||
val: Uint8Array; | ||
} | ||
export interface ContentRouting { | ||
provide: (cid: CID, options: AbortOptions) => Promise<void>; | ||
findProviders: (cid: CID, options: AbortOptions) => AsyncIterable<PeerData>; | ||
provide: (cid: CID, options?: AbortOptions) => Promise<void>; | ||
findProviders: (cid: CID, options?: AbortOptions) => AsyncIterable<PeerData>; | ||
put: (key: Uint8Array, value: Uint8Array, options?: AbortOptions) => Promise<void>; | ||
get: (key: Uint8Array, options?: AbortOptions) => Promise<GetResult>; | ||
} | ||
export default ContentRouting; | ||
//# sourceMappingURL=index.d.ts.map |
import type { PeerId } from '../peer-id/index.js'; | ||
import type { CID } from 'multiformats/cid'; | ||
import type { PeerData } from '../peer-data/index.js'; | ||
import type { AbortOptions, Startable } from '../index.js'; | ||
import type { AbortOptions } from '../index.js'; | ||
import type { PeerDiscovery } from '../peer-discovery/index.js'; | ||
@@ -116,3 +116,6 @@ /** | ||
export declare type QueryEvent = SendingQueryEvent | PeerResponseEvent | FinalPeerEvent | QueryErrorEvent | ProviderEvent | ValueEvent | AddingPeerEvent | DialingPeerEvent; | ||
export interface DHT extends PeerDiscovery, Startable { | ||
export interface RoutingTable { | ||
size: number; | ||
} | ||
export interface DHT extends PeerDiscovery { | ||
/** | ||
@@ -155,2 +158,9 @@ * Get a value from the DHT, the final ValueEvent will be the best value | ||
} | ||
export interface SingleDHT extends DHT { | ||
routingTable: RoutingTable; | ||
} | ||
export interface DualDHT extends DHT { | ||
wan: SingleDHT; | ||
lan: SingleDHT; | ||
} | ||
export interface SelectFn { | ||
@@ -157,0 +167,0 @@ (key: Uint8Array, records: Uint8Array[]): number; |
export declare class AbortError extends Error { | ||
readonly code: string; | ||
readonly type: string; | ||
constructor(); | ||
constructor(message?: string); | ||
static get code(): string; | ||
@@ -6,0 +6,0 @@ static get type(): string; |
export class AbortError extends Error { | ||
constructor() { | ||
super('The operation was aborted'); | ||
constructor(message = 'The operation was aborted') { | ||
super(message); | ||
this.code = AbortError.code; | ||
@@ -5,0 +5,0 @@ this.type = AbortError.type; |
@@ -1,4 +0,2 @@ | ||
import type { PeerId } from './peer-id/index.js'; | ||
import type { Multiaddr } from '@multiformats/multiaddr'; | ||
import type { ProtocolStream, Connection } from './connection/index.js'; | ||
export interface AbortOptions { | ||
@@ -8,19 +6,7 @@ signal?: AbortSignal; | ||
export interface Startable { | ||
isStarted: () => boolean; | ||
start: () => void | Promise<void>; | ||
stop: () => void | Promise<void>; | ||
isStarted: () => boolean; | ||
} | ||
export interface Dialer { | ||
dial: (peer: PeerId, options?: { | ||
signal?: AbortSignal; | ||
}) => Promise<Connection>; | ||
dialProtocol: (peer: PeerId, protocol: string, options?: { | ||
signal?: AbortSignal; | ||
}) => Promise<ProtocolStream>; | ||
getTokens: (count: number) => number[]; | ||
releaseToken: (token: number) => void; | ||
} | ||
export interface Addressable { | ||
multiaddrs: Multiaddr[]; | ||
} | ||
export declare function isStartable(obj: any): obj is Startable; | ||
export interface EventCallback<EventType> { | ||
@@ -45,3 +31,3 @@ (evt: EventType): void; | ||
removeEventListener<U extends keyof EventMap>(type: U, callback?: EventHandler<EventMap[U]> | undefined, options?: EventListenerOptions | boolean): void; | ||
dispatchEvent(event: CustomEvent): boolean; | ||
dispatchEvent(event: Event): boolean; | ||
} | ||
@@ -52,2 +38,33 @@ export declare const CustomEvent: { | ||
}; | ||
export interface AddressManagerEvents { | ||
/** | ||
* Emitted when the current node's addresses change | ||
*/ | ||
'change:addresses': CustomEvent; | ||
} | ||
export interface AddressManager extends EventEmitter<AddressManagerEvents> { | ||
/** | ||
* Get peer listen multiaddrs | ||
*/ | ||
getListenAddrs: () => Multiaddr[]; | ||
/** | ||
* Get peer announcing multiaddrs | ||
*/ | ||
getAnnounceAddrs: () => Multiaddr[]; | ||
/** | ||
* Get observed multiaddrs | ||
*/ | ||
getObservedAddrs: () => Multiaddr[]; | ||
/** | ||
* Add peer observed addresses | ||
*/ | ||
addObservedAddr: (addr: Multiaddr) => void; | ||
/** | ||
* Get the current node's addresses | ||
*/ | ||
getAddresses: () => Multiaddr[]; | ||
} | ||
export declare type RecursivePartial<T> = { | ||
[P in keyof T]?: T[P] extends Array<infer I> ? Array<RecursivePartial<I>> : T[P] extends (...args: any[]) => any ? T[P] : RecursivePartial<T[P]>; | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,2 +7,5 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
var _EventEmitter_listeners; | ||
export function isStartable(obj) { | ||
return obj != null && typeof obj.start === 'function' && typeof obj.stop === 'function'; | ||
} | ||
/** | ||
@@ -9,0 +12,0 @@ * Adds types to the EventTarget class. Hopefully this won't be necessary forever. |
@@ -1,9 +0,15 @@ | ||
import type { Startable } from '..'; | ||
import type { PeerId } from '../peer-id'; | ||
import type { MultiaddrConnection } from '../transport'; | ||
import type { Duplex } from 'it-stream-types'; | ||
export interface MetricsInit { | ||
enabled: boolean; | ||
computeThrottleMaxQueueSize: number; | ||
computeThrottleTimeout: number; | ||
movingAverageIntervals: number[]; | ||
maxOldPeersRetention: number; | ||
} | ||
export interface MovingAverage { | ||
variance: () => number; | ||
movingAverage: () => number; | ||
deviation: () => number; | ||
forecast: () => number; | ||
variance: number; | ||
movingAverage: number; | ||
deviation: number; | ||
forecast: number; | ||
push: (time: number, value: number) => void; | ||
@@ -15,12 +21,11 @@ } | ||
} | ||
export interface StatsJSON { | ||
dataReceived: string; | ||
dataSent: string; | ||
movingAverages: Record<string, Record<string, number>>; | ||
export interface TransferStats { | ||
dataReceived: BigInt; | ||
dataSent: BigInt; | ||
} | ||
export interface Stats extends Startable { | ||
export interface Stats { | ||
/** | ||
* Returns a clone of the current stats. | ||
*/ | ||
getSnapshot: Record<string, any>; | ||
getSnapshot: () => TransferStats; | ||
/** | ||
@@ -31,6 +36,2 @@ * Returns a clone of the internal movingAverages | ||
/** | ||
* Returns a plain JSON object of the stats | ||
*/ | ||
toJSON: () => StatsJSON; | ||
/** | ||
* Pushes the given operation data to the queue, along with the | ||
@@ -41,4 +42,18 @@ * current Timestamp, then resets the update timer. | ||
} | ||
export interface Metrics extends Startable { | ||
export interface TrackStreamOptions<T extends Duplex<Uint8Array>> { | ||
/** | ||
* A duplex iterable stream | ||
*/ | ||
stream: T; | ||
/** | ||
* The id of the remote peer that's connected | ||
*/ | ||
remotePeer: PeerId; | ||
/** | ||
* The protocol the stream is running | ||
*/ | ||
protocol?: string; | ||
} | ||
export interface StreamMetrics { | ||
/** | ||
* Returns the global `Stats` object | ||
@@ -55,3 +70,3 @@ */ | ||
*/ | ||
forPeer: (peerId: PeerId) => Stats; | ||
forPeer: (peerId: PeerId) => Stats | undefined; | ||
/** | ||
@@ -62,8 +77,5 @@ * Returns a list of all protocol strings currently being tracked. | ||
/** | ||
* Returns the `Stats` object for the given `protocol`. | ||
* | ||
* @param {string} protocol | ||
* @returns {Stats} | ||
* Returns the `Stats` object for the given `protocol` | ||
*/ | ||
forProtocol: (protocol: string) => Stats; | ||
forProtocol: (protocol: string) => Stats | undefined; | ||
/** | ||
@@ -88,7 +100,3 @@ * Should be called when all connections to a given peer | ||
*/ | ||
trackStream: (data: { | ||
stream: MultiaddrConnection; | ||
remotePeer: PeerId; | ||
protocol: string; | ||
}) => MultiaddrConnection; | ||
trackStream: <T extends Duplex<Uint8Array>>(data: TrackStreamOptions<T>) => T; | ||
} | ||
@@ -111,2 +119,4 @@ export interface ComponentMetricsUpdate { | ||
} | ||
export interface Metrics extends StreamMetrics, ComponentMetricsTracker { | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
import type { PeerData } from '../peer-data/index.js'; | ||
import type { EventEmitter, Startable } from '../index.js'; | ||
export interface PeerDiscoveryFactory<PeerDiscoveryInit> { | ||
new (init?: PeerDiscoveryInit): PeerDiscovery; | ||
tag: string; | ||
} | ||
import type { EventEmitter } from '../index.js'; | ||
export interface PeerDiscoveryEvents { | ||
'peer': CustomEvent<PeerData>; | ||
} | ||
export interface PeerDiscovery extends EventEmitter<PeerDiscoveryEvents>, Startable { | ||
export interface PeerDiscovery extends EventEmitter<PeerDiscoveryEvents> { | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
import type { CID } from 'multiformats/cid'; | ||
import type { MultihashDigest } from 'multiformats/hashes/interface'; | ||
import type { MultibaseEncoder } from 'multiformats/bases/interface'; | ||
interface BasePeerId { | ||
@@ -9,6 +8,6 @@ readonly type: 'RSA' | 'Ed25519' | 'secp256k1'; | ||
readonly publicKey?: Uint8Array; | ||
toString: (codec?: MultibaseEncoder<any>) => string; | ||
toString: () => string; | ||
toCID: () => CID; | ||
toBytes: () => Uint8Array; | ||
equals: (other: any) => boolean; | ||
equals: (other: PeerId | Uint8Array | string) => boolean; | ||
} | ||
@@ -15,0 +14,0 @@ export interface RSAPeerId extends BasePeerId { |
import type { PeerId } from '../peer-id/index.js'; | ||
import type { PeerData } from '../peer-data/index.js'; | ||
import type { AbortOptions } from '../index.js'; | ||
export interface PeerRoutingFactory<PeerRoutingInit> { | ||
new (init?: PeerRoutingInit): PeerRouting; | ||
} | ||
export interface PeerRouting { | ||
@@ -11,3 +8,2 @@ findPeer: (peerId: PeerId, options?: AbortOptions) => Promise<PeerData>; | ||
} | ||
export default PeerRouting; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -16,5 +16,2 @@ import type { PeerId } from '../peer-id/index.js'; | ||
} | ||
export interface AddressSorter { | ||
(ms: Address[]): Address[]; | ||
} | ||
export interface Peer { | ||
@@ -105,7 +102,2 @@ /** | ||
delete: (peerId: PeerId) => Promise<void>; | ||
/** | ||
* Get the known multiaddrs for a given peer. All returned multiaddrs | ||
* will include the encapsulated `PeerId` of the peer. | ||
*/ | ||
getMultiaddrsForPeer: (peerId: PeerId, addressSorter?: AddressSorter) => Promise<Multiaddr[]>; | ||
} | ||
@@ -164,2 +156,3 @@ /** | ||
protocols: string[]; | ||
oldProtocols: string[]; | ||
} | ||
@@ -169,6 +162,8 @@ export interface PeerMultiaddrsChangeData { | ||
multiaddrs: Multiaddr[]; | ||
oldMultiaddrs: Multiaddr[]; | ||
} | ||
export interface PeerPublicKeyChangeData { | ||
peerId: PeerId; | ||
pubKey?: Uint8Array; | ||
publicKey?: Uint8Array; | ||
oldPublicKey?: Uint8Array; | ||
} | ||
@@ -178,2 +173,3 @@ export interface PeerMetadataChangeData { | ||
metadata: Map<string, Uint8Array>; | ||
oldMetadata: Map<string, Uint8Array>; | ||
} | ||
@@ -188,2 +184,11 @@ export declare type EventName = 'peer' | 'change:protocols' | 'change:multiaddrs' | 'change:pubkey' | 'change:metadata'; | ||
} | ||
export interface AddressFilter { | ||
(peerId: PeerId, multiaddr: Multiaddr): Promise<boolean>; | ||
} | ||
export interface AddressSorter { | ||
(a: Address, b: Address): -1 | 0 | 1; | ||
} | ||
export interface PeerStoreInit { | ||
addressFilter?: AddressFilter; | ||
} | ||
export interface PeerStore extends EventEmitter<PeerStoreEvents> { | ||
@@ -194,3 +199,11 @@ addressBook: AddressBook; | ||
protoBook: ProtoBook; | ||
getPeers: () => AsyncIterable<Peer>; | ||
/** | ||
* Loop over every peer - the looping is async because we read from a | ||
* datastore but the peer operation is sync, this is to prevent | ||
* long-lived peer operations causing deadlocks over the datastore | ||
* which can happen if they try to access the peer store during the | ||
* loop | ||
*/ | ||
forEach: (fn: (peer: Peer) => void) => Promise<void>; | ||
all: () => Promise<Peer[]>; | ||
delete: (peerId: PeerId) => Promise<void>; | ||
@@ -197,0 +210,0 @@ has: (peerId: PeerId) => Promise<boolean>; |
import type { PeerId } from '../peer-id/index.js'; | ||
import type { Pushable } from 'it-pushable'; | ||
import type { Registrar } from '../registrar/index.js'; | ||
import type { EventEmitter, Startable } from '../index.js'; | ||
@@ -30,21 +29,21 @@ import type { Stream } from '../connection/index.js'; | ||
data: Uint8Array; | ||
seqno?: BigInt; | ||
sequenceNumber?: BigInt; | ||
signature?: Uint8Array; | ||
key?: Uint8Array; | ||
} | ||
export interface RPCMessage { | ||
from: Uint8Array; | ||
topic: string; | ||
data: Uint8Array; | ||
seqno?: Uint8Array; | ||
signature?: Uint8Array; | ||
key?: Uint8Array; | ||
export interface PubSubRPCMessage { | ||
from?: Uint8Array | null; | ||
topic?: string | null; | ||
data?: Uint8Array | null; | ||
sequenceNumber?: Uint8Array | null; | ||
signature?: Uint8Array | null; | ||
key?: Uint8Array | null; | ||
} | ||
export interface RPCSubscription { | ||
subscribe: boolean; | ||
topic: string; | ||
export interface PubSubRPCSubscription { | ||
subscribe?: boolean | null; | ||
topic?: string | null; | ||
} | ||
export interface RPC { | ||
subscriptions: RPCSubscription[]; | ||
messages: RPCMessage[]; | ||
export interface PubSubRPC { | ||
subscriptions?: PubSubRPCSubscription[] | null; | ||
messages?: PubSubRPCMessage[] | null; | ||
} | ||
@@ -62,6 +61,4 @@ export interface PeerStreams extends EventEmitter<PeerStreamEvents> { | ||
} | ||
export interface PubSubOptions { | ||
registrar: Registrar; | ||
peerId: PeerId; | ||
debugName?: string; | ||
export interface PubSubInit { | ||
enabled?: boolean; | ||
multicodecs?: string[]; | ||
@@ -104,3 +101,3 @@ /** | ||
getSubscribers: (topic: string) => PeerId[]; | ||
validate: (message: Message) => Promise<void>; | ||
dispatchEvent: (event: CustomEvent<Uint8Array | Message>) => boolean; | ||
} | ||
@@ -107,0 +104,0 @@ export interface PeerStreamEvents { |
@@ -15,13 +15,28 @@ import type { EventEmitter } from '../index.js'; | ||
export interface ConnectionManager extends EventEmitter<ConnectionManagerEvents> { | ||
/** | ||
* Return all connections to the remote peer or an empty array | ||
*/ | ||
getConnections: (peerId: PeerId) => Connection[]; | ||
/** | ||
* Return the first connection to a remote peer, if any | ||
*/ | ||
getConnection: (peerId: PeerId) => Connection | undefined; | ||
/** | ||
* Returns all connections keyed by the stringified peer ID of the remote peer | ||
*/ | ||
getConnectionMap: () => Map<string, Connection[]>; | ||
/** | ||
* Returns all connections | ||
*/ | ||
getConnectionList: () => Connection[]; | ||
} | ||
export interface StreamHandler { | ||
(event: CustomEvent<IncomingStreamData>): void; | ||
(data: IncomingStreamData): void; | ||
} | ||
export interface Registrar { | ||
getProtocols: () => string[]; | ||
handle: (protocol: string | string[], handler: StreamHandler) => Promise<string>; | ||
unhandle: (id: string) => Promise<void>; | ||
handle: (protocol: string | string[], handler: StreamHandler) => Promise<void>; | ||
unhandle: (protocol: string | string[]) => Promise<void>; | ||
getHandler: (protocol: string) => StreamHandler; | ||
register: (protocols: string | string[], topology: Topology) => string; | ||
register: (protocols: string | string[], topology: Topology) => Promise<string>; | ||
unregister: (id: string) => void; | ||
@@ -28,0 +43,0 @@ getTopologies: (protocol: string) => Topology[]; |
import type { Duplex } from 'it-stream-types'; | ||
import type { Components } from '../components.js'; | ||
import type { Stream } from '../connection/index.js'; | ||
import type { AbortOptions } from '../index.js'; | ||
export interface MuxerFactory<T extends MuxerInit> { | ||
new (init?: T): Muxer; | ||
multicodec: string; | ||
export interface StreamMuxerFactory { | ||
protocol: string; | ||
createStreamMuxer: (components: Components, init?: StreamMuxerInit) => StreamMuxer; | ||
} | ||
@@ -11,3 +12,4 @@ /** | ||
*/ | ||
export interface Muxer extends Duplex<Uint8Array> { | ||
export interface StreamMuxer extends Duplex<Uint8Array> { | ||
protocol: string; | ||
readonly streams: Stream[]; | ||
@@ -20,3 +22,3 @@ /** | ||
} | ||
export interface MuxerInit extends AbortOptions { | ||
export interface StreamMuxerInit extends AbortOptions { | ||
onIncomingStream?: (stream: Stream) => void; | ||
@@ -23,0 +25,0 @@ onStreamEnd?: (stream: Stream) => void; |
import type { PeerId } from '../peer-id/index.js'; | ||
import type { Connection } from '../connection/index.js'; | ||
import type { Registrar } from '../registrar/index.js'; | ||
export interface onConnectHandler { | ||
@@ -27,2 +28,3 @@ (peerId: PeerId, conn: Connection): void; | ||
onDisconnect: (peerId: PeerId) => void; | ||
setRegistrar: (registrar: Registrar) => Promise<void>; | ||
} | ||
@@ -29,0 +31,0 @@ export declare const symbol: unique symbol; |
@@ -5,7 +5,3 @@ import type { EventEmitter, AbortOptions } from '../index.js'; | ||
import type { Duplex } from 'it-stream-types'; | ||
export interface TransportFactory<DialOptions extends { | ||
signal?: AbortSignal; | ||
}, ListenerOptions> { | ||
new (upgrader: Upgrader): Transport<DialOptions, ListenerOptions>; | ||
} | ||
export declare const symbol: unique symbol; | ||
export interface ConnectionHandler { | ||
@@ -17,17 +13,29 @@ (connection: Connection): void; | ||
} | ||
export interface ListenerOptions { | ||
export interface CreateListenerOptions { | ||
handler?: ConnectionHandler; | ||
upgrader: Upgrader; | ||
} | ||
export interface DialOptions extends AbortOptions { | ||
upgrader: Upgrader; | ||
} | ||
/** | ||
* A libp2p transport is understood as something that offers a dial and listen interface to establish connections. | ||
*/ | ||
export interface Transport<DialOptions extends AbortOptions = AbortOptions, CreateListenerOptions extends ListenerOptions = ListenerOptions> { | ||
export interface Transport { | ||
/** | ||
* Used to identify the transport | ||
*/ | ||
[Symbol.toStringTag]: string; | ||
/** | ||
* Used by the isTransport function | ||
*/ | ||
[symbol]: true; | ||
/** | ||
* Dial a given multiaddr. | ||
*/ | ||
dial: (ma: Multiaddr, options?: DialOptions) => Promise<Connection>; | ||
dial: (ma: Multiaddr, options: DialOptions) => Promise<Connection>; | ||
/** | ||
* Create transport listeners. | ||
*/ | ||
createListener: (options?: CreateListenerOptions) => Listener; | ||
createListener: (options: CreateListenerOptions) => Listener; | ||
/** | ||
@@ -60,3 +68,7 @@ * Takes a list of `Multiaddr`s and returns only valid addresses for the transport | ||
} | ||
export interface Upgrader { | ||
export interface UpgraderEvents { | ||
'connection': CustomEvent<Connection>; | ||
'connectionEnd': CustomEvent<Connection>; | ||
} | ||
export interface Upgrader extends EventEmitter<UpgraderEvents> { | ||
/** | ||
@@ -89,2 +101,17 @@ * Upgrades an outbound connection on `transport.dial`. | ||
} | ||
export declare function isTransport(other: any): other is Transport; | ||
export interface TransportManagerEvents { | ||
'listener:listening': CustomEvent<Listener>; | ||
'listener:close': CustomEvent<Listener>; | ||
} | ||
export interface TransportManager extends EventEmitter<TransportManagerEvents> { | ||
add: (transport: Transport) => void; | ||
dial: (ma: Multiaddr, options?: any) => Promise<Connection>; | ||
getAddrs: () => Multiaddr[]; | ||
getTransports: () => Transport[]; | ||
transportForMultiaddr: (ma: Multiaddr) => Transport | undefined; | ||
listen: (addrs: Multiaddr[]) => Promise<void>; | ||
remove: (key: string) => Promise<void>; | ||
removeAll: () => Promise<void>; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,5 @@ | ||
export {}; | ||
export const symbol = Symbol.for('@libp2p/transport'); | ||
export function isTransport(other) { | ||
return symbol in other; | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@libp2p/interfaces", | ||
"version": "1.3.13", | ||
"version": "1.3.14", | ||
"description": "Interfaces for JS Libp2p", | ||
@@ -51,2 +51,6 @@ "license": "Apache-2.0 OR MIT", | ||
}, | ||
"./components": { | ||
"import": "./dist/src/components.js", | ||
"types": "./dist/src/components.d.ts" | ||
}, | ||
"./connection": { | ||
@@ -223,2 +227,3 @@ "import": "./dist/src/connection/index.js", | ||
"@multiformats/multiaddr": "^10.1.5", | ||
"interface-datastore": "^6.1.0", | ||
"multiformats": "^9.6.3" | ||
@@ -225,0 +230,0 @@ }, |
@@ -1,8 +0,4 @@ | ||
import type { PeerId } from '../peer-id' | ||
import type { MultiaddrConnection } from '../transport' | ||
import type { PeerId } from '../peer-id/index.js' | ||
import type { Duplex } from 'it-stream-types' | ||
export interface EncrypterFactory<EncrypterInit> { | ||
new (init?: EncrypterInit): Crypto | ||
} | ||
/** | ||
@@ -12,18 +8,19 @@ * A libp2p connection encrypter module must be compliant to this interface | ||
*/ | ||
export interface Encrypter { | ||
export interface ConnectionEncrypter { | ||
protocol: string | ||
/** | ||
* Encrypt outgoing data to the remote party. | ||
*/ | ||
secureOutbound: (localPeer: PeerId, connection: MultiaddrConnection, remotePeer: PeerId) => Promise<SecureOutbound> | ||
secureOutbound: (localPeer: PeerId, connection: Duplex<Uint8Array>, remotePeer: PeerId) => Promise<SecuredConnection> | ||
/** | ||
* Decrypt incoming data. | ||
*/ | ||
secureInbound: (localPeer: PeerId, connection: MultiaddrConnection, remotePeer?: PeerId) => Promise<SecureOutbound> | ||
secureInbound: (localPeer: PeerId, connection: Duplex<Uint8Array>, remotePeer?: PeerId) => Promise<SecuredConnection> | ||
} | ||
export interface SecureOutbound { | ||
conn: MultiaddrConnection | ||
export interface SecuredConnection { | ||
conn: Duplex<Uint8Array> | ||
remoteEarlyData: Uint8Array | ||
remotePeer: PeerId | ||
} |
@@ -61,4 +61,4 @@ import type { Multiaddr } from '@multiformats/multiaddr' | ||
newStream: (multicodecs: string[]) => Promise<ProtocolStream> | ||
addStream: (stream: Stream, data: Metadata) => void | ||
newStream: (multicodecs: string | string[]) => Promise<ProtocolStream> | ||
addStream: (stream: Stream, data: Partial<Metadata>) => void | ||
removeStream: (id: string) => void | ||
@@ -68,2 +68,8 @@ close: () => Promise<void> | ||
export const symbol = Symbol.for('@libp2p/connection') | ||
export function isConnection (other: any): other is Connection { | ||
return symbol in other | ||
} | ||
export interface ConnectionGater { | ||
@@ -163,1 +169,11 @@ /** | ||
} | ||
export interface ConnectionProtector { | ||
/** | ||
* Takes a given Connection and creates a private encryption stream | ||
* between its two peers from the PSK the Protector instance was | ||
* created with. | ||
*/ | ||
protect: (connection: MultiaddrConnection) => Promise<MultiaddrConnection> | ||
} |
import type { CID } from 'multiformats/cid' | ||
import type { AbortOptions } from '../index' | ||
import type { PeerData } from '../peer-data' | ||
import type { AbortOptions } from '../index.js' | ||
import type { PeerData } from '../peer-data/index.js' | ||
import type { PeerId } from '../peer-id/index.js' | ||
export interface ContentRoutingFactory<ContentRoutingInit> { | ||
new (init?: ContentRoutingInit): ContentRouting | ||
export interface GetResult { | ||
from: PeerId | ||
val: Uint8Array | ||
} | ||
export interface ContentRouting { | ||
provide: (cid: CID, options: AbortOptions) => Promise<void> | ||
findProviders: (cid: CID, options: AbortOptions) => AsyncIterable<PeerData> | ||
provide: (cid: CID, options?: AbortOptions) => Promise<void> | ||
findProviders: (cid: CID, options?: AbortOptions) => AsyncIterable<PeerData> | ||
put: (key: Uint8Array, value: Uint8Array, options?: AbortOptions) => Promise<void> | ||
get: (key: Uint8Array, options?: AbortOptions) => Promise<GetResult> | ||
} | ||
export default ContentRouting |
import type { PeerId } from '../peer-id/index.js' | ||
import type { CID } from 'multiformats/cid' | ||
import type { PeerData } from '../peer-data/index.js' | ||
import type { AbortOptions, Startable } from '../index.js' | ||
import type { AbortOptions } from '../index.js' | ||
import type { PeerDiscovery } from '../peer-discovery/index.js' | ||
@@ -131,3 +131,7 @@ | ||
export interface DHT extends PeerDiscovery, Startable { | ||
export interface RoutingTable { | ||
size: number | ||
} | ||
export interface DHT extends PeerDiscovery { | ||
/** | ||
@@ -179,2 +183,11 @@ * Get a value from the DHT, the final ValueEvent will be the best value | ||
export interface SingleDHT extends DHT { | ||
routingTable: RoutingTable | ||
} | ||
export interface DualDHT extends DHT { | ||
wan: SingleDHT | ||
lan: SingleDHT | ||
} | ||
export interface SelectFn { (key: Uint8Array, records: Uint8Array[]): number } | ||
@@ -181,0 +194,0 @@ export interface ValidateFn { (a: Uint8Array, b: Uint8Array): Promise<void> } |
@@ -6,4 +6,4 @@ | ||
constructor () { | ||
super('The operation was aborted') | ||
constructor (message: string = 'The operation was aborted') { | ||
super(message) | ||
this.code = AbortError.code | ||
@@ -10,0 +10,0 @@ this.type = AbortError.type |
@@ -1,4 +0,2 @@ | ||
import type { PeerId } from './peer-id/index.js' | ||
import type { Multiaddr } from '@multiformats/multiaddr' | ||
import type { ProtocolStream, Connection } from './connection/index.js' | ||
@@ -10,18 +8,11 @@ export interface AbortOptions { | ||
export interface Startable { | ||
isStarted: () => boolean | ||
start: () => void | Promise<void> | ||
stop: () => void | Promise<void> | ||
isStarted: () => boolean | ||
} | ||
export interface Dialer { | ||
dial: (peer: PeerId, options?: { signal?: AbortSignal }) => Promise<Connection> | ||
dialProtocol: (peer: PeerId, protocol: string, options?: { signal?: AbortSignal }) => Promise<ProtocolStream> | ||
getTokens: (count: number) => number[] | ||
releaseToken: (token: number) => void | ||
export function isStartable (obj: any): obj is Startable { | ||
return obj != null && typeof obj.start === 'function' && typeof obj.stop === 'function' | ||
} | ||
export interface Addressable { | ||
multiaddrs: Multiaddr[] | ||
} | ||
export interface EventCallback<EventType> { (evt: EventType): void } | ||
@@ -89,3 +80,3 @@ export type EventHandler<EventType> = EventCallback<EventType> | ({ handleEvent: EventCallback<EventType> }) | null | ||
dispatchEvent (event: CustomEvent): boolean { | ||
dispatchEvent (event: Event): boolean { | ||
const result = super.dispatchEvent(event) | ||
@@ -125,1 +116,40 @@ | ||
export const CustomEvent = globalThis.CustomEvent ?? CustomEventPolyfill | ||
export interface AddressManagerEvents { | ||
/** | ||
* Emitted when the current node's addresses change | ||
*/ | ||
'change:addresses': CustomEvent | ||
} | ||
export interface AddressManager extends EventEmitter<AddressManagerEvents> { | ||
/** | ||
* Get peer listen multiaddrs | ||
*/ | ||
getListenAddrs: () => Multiaddr[] | ||
/** | ||
* Get peer announcing multiaddrs | ||
*/ | ||
getAnnounceAddrs: () => Multiaddr[] | ||
/** | ||
* Get observed multiaddrs | ||
*/ | ||
getObservedAddrs: () => Multiaddr[] | ||
/** | ||
* Add peer observed addresses | ||
*/ | ||
addObservedAddr: (addr: Multiaddr) => void | ||
/** | ||
* Get the current node's addresses | ||
*/ | ||
getAddresses: () => Multiaddr[] | ||
} | ||
// Borrowed from the tsdef module | ||
export type RecursivePartial<T> = { | ||
[P in keyof T]?: T[P] extends Array<infer I> ? Array<RecursivePartial<I>> : T[P] extends (...args: any[]) => any ? T[P] : RecursivePartial<T[P]> | ||
} |
@@ -1,12 +0,18 @@ | ||
import type { Startable } from '..' | ||
import type { PeerId } from '../peer-id' | ||
import type { MultiaddrConnection } from '../transport' | ||
import type { Duplex } from 'it-stream-types' | ||
export interface MetricsInit { | ||
enabled: boolean | ||
computeThrottleMaxQueueSize: number | ||
computeThrottleTimeout: number | ||
movingAverageIntervals: number[] | ||
maxOldPeersRetention: number | ||
} | ||
export interface MovingAverage { | ||
variance: () => number | ||
movingAverage: () => number | ||
variance: number | ||
movingAverage: number | ||
deviation: number | ||
forecast: number | ||
deviation: () => number | ||
forecast: () => number | ||
push: (time: number, value: number) => void | ||
@@ -20,13 +26,12 @@ } | ||
export interface StatsJSON { | ||
dataReceived: string | ||
dataSent: string | ||
movingAverages: Record<string, Record<string, number>> | ||
export interface TransferStats { | ||
dataReceived: BigInt | ||
dataSent: BigInt | ||
} | ||
export interface Stats extends Startable { | ||
export interface Stats { | ||
/** | ||
* Returns a clone of the current stats. | ||
*/ | ||
getSnapshot: Record<string, any> | ||
getSnapshot: () => TransferStats | ||
@@ -39,7 +44,2 @@ /** | ||
/** | ||
* Returns a plain JSON object of the stats | ||
*/ | ||
toJSON: () => StatsJSON | ||
/** | ||
* Pushes the given operation data to the queue, along with the | ||
@@ -51,4 +51,21 @@ * current Timestamp, then resets the update timer. | ||
export interface Metrics extends Startable { | ||
export interface TrackStreamOptions <T extends Duplex<Uint8Array>> { | ||
/** | ||
* A duplex iterable stream | ||
*/ | ||
stream: T | ||
/** | ||
* The id of the remote peer that's connected | ||
*/ | ||
remotePeer: PeerId | ||
/** | ||
* The protocol the stream is running | ||
*/ | ||
protocol?: string | ||
} | ||
export interface StreamMetrics { | ||
/** | ||
* Returns the global `Stats` object | ||
@@ -67,3 +84,3 @@ */ | ||
*/ | ||
forPeer: (peerId: PeerId) => Stats | ||
forPeer: (peerId: PeerId) => Stats | undefined | ||
@@ -76,8 +93,5 @@ /** | ||
/** | ||
* Returns the `Stats` object for the given `protocol`. | ||
* | ||
* @param {string} protocol | ||
* @returns {Stats} | ||
* Returns the `Stats` object for the given `protocol` | ||
*/ | ||
forProtocol: (protocol: string) => Stats | ||
forProtocol: (protocol: string) => Stats | undefined | ||
@@ -105,3 +119,3 @@ /** | ||
*/ | ||
trackStream: (data: { stream: MultiaddrConnection, remotePeer: PeerId, protocol: string }) => MultiaddrConnection | ||
trackStream: <T extends Duplex<Uint8Array>> (data: TrackStreamOptions<T>) => T | ||
} | ||
@@ -127,1 +141,5 @@ | ||
} | ||
export interface Metrics extends StreamMetrics, ComponentMetricsTracker { | ||
} |
import type { PeerData } from '../peer-data/index.js' | ||
import type { EventEmitter, Startable } from '../index.js' | ||
import type { EventEmitter } from '../index.js' | ||
export interface PeerDiscoveryFactory<PeerDiscoveryInit> { | ||
new (init?: PeerDiscoveryInit): PeerDiscovery | ||
tag: string | ||
} | ||
export interface PeerDiscoveryEvents { | ||
@@ -13,4 +8,4 @@ 'peer': CustomEvent<PeerData> | ||
export interface PeerDiscovery extends EventEmitter<PeerDiscoveryEvents>, Startable { | ||
export interface PeerDiscovery extends EventEmitter<PeerDiscoveryEvents> { | ||
} |
import type { CID } from 'multiformats/cid' | ||
import type { MultihashDigest } from 'multiformats/hashes/interface' | ||
import type { MultibaseEncoder } from 'multiformats/bases/interface' | ||
@@ -11,6 +10,6 @@ interface BasePeerId { | ||
toString: (codec?: MultibaseEncoder<any>) => string | ||
toString: () => string | ||
toCID: () => CID | ||
toBytes: () => Uint8Array | ||
equals: (other: any) => boolean | ||
equals: (other: PeerId | Uint8Array | string) => boolean | ||
} | ||
@@ -17,0 +16,0 @@ |
@@ -5,6 +5,2 @@ import type { PeerId } from '../peer-id/index.js' | ||
export interface PeerRoutingFactory<PeerRoutingInit> { | ||
new (init?: PeerRoutingInit): PeerRouting | ||
} | ||
export interface PeerRouting { | ||
@@ -14,3 +10,1 @@ findPeer: (peerId: PeerId, options?: AbortOptions) => Promise<PeerData> | ||
} | ||
export default PeerRouting |
@@ -19,6 +19,2 @@ import type { PeerId } from '../peer-id/index.js' | ||
export interface AddressSorter { | ||
(ms: Address[]): Address[] | ||
} | ||
export interface Peer { | ||
@@ -126,8 +122,2 @@ /** | ||
delete: (peerId: PeerId) => Promise<void> | ||
/** | ||
* Get the known multiaddrs for a given peer. All returned multiaddrs | ||
* will include the encapsulated `PeerId` of the peer. | ||
*/ | ||
getMultiaddrsForPeer: (peerId: PeerId, addressSorter?: AddressSorter) => Promise<Multiaddr[]> | ||
} | ||
@@ -195,2 +185,3 @@ | ||
protocols: string[] | ||
oldProtocols: string[] | ||
} | ||
@@ -201,2 +192,3 @@ | ||
multiaddrs: Multiaddr[] | ||
oldMultiaddrs: Multiaddr[] | ||
} | ||
@@ -206,3 +198,4 @@ | ||
peerId: PeerId | ||
pubKey?: Uint8Array | ||
publicKey?: Uint8Array | ||
oldPublicKey?: Uint8Array | ||
} | ||
@@ -213,2 +206,3 @@ | ||
metadata: Map<string, Uint8Array> | ||
oldMetadata: Map<string, Uint8Array> | ||
} | ||
@@ -226,2 +220,14 @@ | ||
export interface AddressFilter { | ||
(peerId: PeerId, multiaddr: Multiaddr): Promise<boolean> | ||
} | ||
export interface AddressSorter { | ||
(a: Address, b: Address): -1 | 0 | 1 | ||
} | ||
export interface PeerStoreInit { | ||
addressFilter?: AddressFilter | ||
} | ||
export interface PeerStore extends EventEmitter<PeerStoreEvents> { | ||
@@ -233,3 +239,11 @@ addressBook: AddressBook | ||
getPeers: () => AsyncIterable<Peer> | ||
/** | ||
* Loop over every peer - the looping is async because we read from a | ||
* datastore but the peer operation is sync, this is to prevent | ||
* long-lived peer operations causing deadlocks over the datastore | ||
* which can happen if they try to access the peer store during the | ||
* loop | ||
*/ | ||
forEach: (fn: (peer: Peer) => void) => Promise<void> | ||
all: () => Promise<Peer[]> | ||
delete: (peerId: PeerId) => Promise<void> | ||
@@ -236,0 +250,0 @@ has: (peerId: PeerId) => Promise<boolean> |
import type { PeerId } from '../peer-id/index.js' | ||
import type { Pushable } from 'it-pushable' | ||
import type { Registrar } from '../registrar/index.js' | ||
import type { EventEmitter, Startable } from '../index.js' | ||
@@ -33,3 +32,3 @@ import type { Stream } from '../connection/index.js' | ||
data: Uint8Array | ||
seqno?: BigInt | ||
sequenceNumber?: BigInt | ||
signature?: Uint8Array | ||
@@ -39,19 +38,19 @@ key?: Uint8Array | ||
export interface RPCMessage { | ||
from: Uint8Array | ||
topic: string | ||
data: Uint8Array | ||
seqno?: Uint8Array | ||
signature?: Uint8Array | ||
key?: Uint8Array | ||
export interface PubSubRPCMessage { | ||
from?: Uint8Array | null | ||
topic?: string | null | ||
data?: Uint8Array | null | ||
sequenceNumber?: Uint8Array | null | ||
signature?: Uint8Array | null | ||
key?: Uint8Array | null | ||
} | ||
export interface RPCSubscription { | ||
subscribe: boolean | ||
topic: string | ||
export interface PubSubRPCSubscription { | ||
subscribe?: boolean | null | ||
topic?: string | null | ||
} | ||
export interface RPC { | ||
subscriptions: RPCSubscription[] | ||
messages: RPCMessage[] | ||
export interface PubSubRPC { | ||
subscriptions?: PubSubRPCSubscription[] | null | ||
messages?: PubSubRPCMessage[] | null | ||
} | ||
@@ -72,6 +71,5 @@ | ||
export interface PubSubOptions { | ||
registrar: Registrar | ||
peerId: PeerId | ||
debugName?: string | ||
export interface PubSubInit { | ||
enabled?: boolean | ||
multicodecs?: string[] | ||
@@ -123,3 +121,4 @@ | ||
getSubscribers: (topic: string) => PeerId[] | ||
validate: (message: Message) => Promise<void> | ||
dispatchEvent: (event: CustomEvent<Uint8Array | Message>) => boolean | ||
} | ||
@@ -126,0 +125,0 @@ |
@@ -18,7 +18,25 @@ import type { EventEmitter } from '../index.js' | ||
export interface ConnectionManager extends EventEmitter<ConnectionManagerEvents> { | ||
/** | ||
* Return all connections to the remote peer or an empty array | ||
*/ | ||
getConnections: (peerId: PeerId) => Connection[] | ||
/** | ||
* Return the first connection to a remote peer, if any | ||
*/ | ||
getConnection: (peerId: PeerId) => Connection | undefined | ||
/** | ||
* Returns all connections keyed by the stringified peer ID of the remote peer | ||
*/ | ||
getConnectionMap: () => Map<string, Connection[]> | ||
/** | ||
* Returns all connections | ||
*/ | ||
getConnectionList: () => Connection[] | ||
} | ||
export interface StreamHandler { | ||
(event: CustomEvent<IncomingStreamData>): void | ||
(data: IncomingStreamData): void | ||
} | ||
@@ -28,9 +46,9 @@ | ||
getProtocols: () => string[] | ||
handle: (protocol: string | string[], handler: StreamHandler) => Promise<string> | ||
unhandle: (id: string) => Promise<void> | ||
handle: (protocol: string | string[], handler: StreamHandler) => Promise<void> | ||
unhandle: (protocol: string | string[]) => Promise<void> | ||
getHandler: (protocol: string) => StreamHandler | ||
register: (protocols: string | string[], topology: Topology) => string | ||
register: (protocols: string | string[], topology: Topology) => Promise<string> | ||
unregister: (id: string) => void | ||
getTopologies: (protocol: string) => Topology[] | ||
} |
import type { Duplex } from 'it-stream-types' | ||
import type { Components } from '../components.js' | ||
import type { Stream } from '../connection/index.js' | ||
import type { AbortOptions } from '../index.js' | ||
export interface MuxerFactory<T extends MuxerInit> { | ||
new (init?: T): Muxer | ||
multicodec: string | ||
export interface StreamMuxerFactory { | ||
protocol: string | ||
createStreamMuxer: (components: Components, init?: StreamMuxerInit) => StreamMuxer | ||
} | ||
@@ -13,3 +14,5 @@ | ||
*/ | ||
export interface Muxer extends Duplex<Uint8Array> { | ||
export interface StreamMuxer extends Duplex<Uint8Array> { | ||
protocol: string | ||
readonly streams: Stream[] | ||
@@ -23,5 +26,5 @@ /** | ||
export interface MuxerInit extends AbortOptions { | ||
export interface StreamMuxerInit extends AbortOptions { | ||
onIncomingStream?: (stream: Stream) => void | ||
onStreamEnd?: (stream: Stream) => void | ||
} |
import type { PeerId } from '../peer-id/index.js' | ||
import type { Connection } from '../connection/index.js' | ||
import type { Registrar } from '../registrar/index.js' | ||
@@ -33,2 +34,3 @@ export interface onConnectHandler { | ||
onDisconnect: (peerId: PeerId) => void | ||
setRegistrar: (registrar: Registrar) => Promise<void> | ||
} | ||
@@ -35,0 +37,0 @@ |
@@ -6,5 +6,3 @@ import type { EventEmitter, AbortOptions } from '../index.js' | ||
export interface TransportFactory<DialOptions extends { signal?: AbortSignal }, ListenerOptions> { | ||
new(upgrader: Upgrader): Transport<DialOptions, ListenerOptions> | ||
} | ||
export const symbol = Symbol.for('@libp2p/transport') | ||
@@ -15,18 +13,35 @@ export interface ConnectionHandler { (connection: Connection): void } | ||
export interface ListenerOptions { | ||
export interface CreateListenerOptions { | ||
handler?: ConnectionHandler | ||
upgrader: Upgrader | ||
} | ||
export interface DialOptions extends AbortOptions { | ||
upgrader: Upgrader | ||
} | ||
/** | ||
* A libp2p transport is understood as something that offers a dial and listen interface to establish connections. | ||
*/ | ||
export interface Transport <DialOptions extends AbortOptions = AbortOptions, CreateListenerOptions extends ListenerOptions = ListenerOptions> { | ||
export interface Transport { | ||
/** | ||
* Used to identify the transport | ||
*/ | ||
[Symbol.toStringTag]: string | ||
/** | ||
* Used by the isTransport function | ||
*/ | ||
[symbol]: true | ||
/** | ||
* Dial a given multiaddr. | ||
*/ | ||
dial: (ma: Multiaddr, options?: DialOptions) => Promise<Connection> | ||
dial: (ma: Multiaddr, options: DialOptions) => Promise<Connection> | ||
/** | ||
* Create transport listeners. | ||
*/ | ||
createListener: (options?: CreateListenerOptions) => Listener | ||
createListener: (options: CreateListenerOptions) => Listener | ||
/** | ||
@@ -62,3 +77,8 @@ * Takes a list of `Multiaddr`s and returns only valid addresses for the transport | ||
export interface Upgrader { | ||
export interface UpgraderEvents { | ||
'connection': CustomEvent<Connection> | ||
'connectionEnd': CustomEvent<Connection> | ||
} | ||
export interface Upgrader extends EventEmitter<UpgraderEvents> { | ||
/** | ||
@@ -95,1 +115,21 @@ * Upgrades an outbound connection on `transport.dial`. | ||
} | ||
export function isTransport (other: any): other is Transport { | ||
return symbol in other | ||
} | ||
export interface TransportManagerEvents { | ||
'listener:listening': CustomEvent<Listener> | ||
'listener:close': CustomEvent<Listener> | ||
} | ||
export interface TransportManager extends EventEmitter<TransportManagerEvents> { | ||
add: (transport: Transport) => void | ||
dial: (ma: Multiaddr, options?: any) => Promise<Connection> | ||
getAddrs: () => Multiaddr[] | ||
getTransports: () => Transport[] | ||
transportForMultiaddr: (ma: Multiaddr) => Transport | undefined | ||
listen: (addrs: Multiaddr[]) => Promise<void> | ||
remove: (key: string) => Promise<void> | ||
removeAll: () => Promise<void> | ||
} |
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
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
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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1361917
154
3272
3
+ Addedinterface-datastore@^6.1.0
+ Addedinterface-datastore@6.1.1(transitive)
+ Addedinterface-store@2.0.2(transitive)
+ Addednanoid@3.3.8(transitive)