libp2p 0.44.0-44b30cc8 → 0.44.0-59f34a21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +27 -27
- package/dist/src/address-manager/index.d.ts +4 -4
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/index.js +9 -6
- package/dist/src/address-manager/index.js.map +1 -1
- package/dist/src/autonat/constants.d.ts +16 -2
- package/dist/src/autonat/constants.d.ts.map +1 -1
- package/dist/src/autonat/constants.js +16 -2
- package/dist/src/autonat/constants.js.map +1 -1
- package/dist/src/autonat/index.d.ts +9 -30
- package/dist/src/autonat/index.d.ts.map +1 -1
- package/dist/src/autonat/index.js +35 -29
- package/dist/src/autonat/index.js.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.js +2 -2
- package/dist/src/circuit-relay/server/advert-service.js.map +1 -1
- package/dist/src/circuit-relay/server/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/index.js +10 -3
- package/dist/src/circuit-relay/server/index.js.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.js +4 -2
- package/dist/src/circuit-relay/transport/discovery.js.map +1 -1
- package/dist/src/circuit-relay/transport/index.d.ts +3 -0
- package/dist/src/circuit-relay/transport/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/index.js +6 -4
- package/dist/src/circuit-relay/transport/index.js.map +1 -1
- package/dist/src/circuit-relay/transport/listener.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/listener.js +30 -26
- package/dist/src/circuit-relay/transport/listener.js.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.d.ts +5 -4
- package/dist/src/circuit-relay/transport/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.js +37 -30
- package/dist/src/circuit-relay/transport/reservation-store.js.map +1 -1
- package/dist/src/components.d.ts +6 -63
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/components.js +60 -164
- package/dist/src/components.js.map +1 -1
- package/dist/src/config/connection-gater.browser.d.ts +8 -0
- package/dist/src/config/connection-gater.browser.d.ts.map +1 -0
- package/dist/src/config/connection-gater.browser.js +27 -0
- package/dist/src/config/connection-gater.browser.js.map +1 -0
- package/dist/src/config/connection-gater.d.ts +6 -0
- package/dist/src/config/connection-gater.d.ts.map +1 -0
- package/dist/src/config/connection-gater.js +18 -0
- package/dist/src/config/connection-gater.js.map +1 -0
- package/dist/src/config.d.ts +2 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +0 -62
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection-manager/auto-dial.d.ts +3 -0
- package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dial.js +18 -4
- package/dist/src/connection-manager/auto-dial.js.map +1 -1
- package/dist/src/connection-manager/connection-pruner.d.ts +4 -0
- package/dist/src/connection-manager/connection-pruner.d.ts.map +1 -1
- package/dist/src/connection-manager/connection-pruner.js +23 -8
- package/dist/src/connection-manager/connection-pruner.js.map +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts +2 -1
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +18 -12
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +8 -6
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +23 -34
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/content-routing/index.d.ts +0 -10
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +7 -42
- package/dist/src/content-routing/index.js.map +1 -1
- package/dist/src/content-routing/utils.d.ts.map +1 -1
- package/dist/src/content-routing/utils.js +3 -1
- package/dist/src/content-routing/utils.js.map +1 -1
- package/dist/src/fetch/index.d.ts +13 -35
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +7 -9
- package/dist/src/fetch/index.js.map +1 -1
- package/dist/src/identify/index.d.ts +16 -48
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/identify/index.js +200 -198
- package/dist/src/identify/index.js.map +1 -1
- package/dist/src/index.d.ts +13 -68
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/libp2p.d.ts +11 -36
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +137 -196
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.d.ts +1 -38
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +0 -59
- package/dist/src/peer-routing.js.map +1 -1
- package/dist/src/ping/constants.d.ts +4 -0
- package/dist/src/ping/constants.d.ts.map +1 -1
- package/dist/src/ping/constants.js +10 -0
- package/dist/src/ping/constants.js.map +1 -1
- package/dist/src/ping/index.d.ts +10 -27
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/ping/index.js +18 -21
- package/dist/src/ping/index.js.map +1 -1
- package/dist/src/registrar.d.ts +5 -2
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +27 -25
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/transport-manager.d.ts +15 -4
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +37 -12
- package/dist/src/transport-manager.js.map +1 -1
- package/dist/src/upgrader.d.ts +8 -3
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +39 -48
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/upnp-nat/index.d.ts +42 -0
- package/dist/src/upnp-nat/index.d.ts.map +1 -0
- package/dist/src/{nat-manager.js → upnp-nat/index.js} +11 -7
- package/dist/src/upnp-nat/index.js.map +1 -0
- package/package.json +42 -26
- package/src/address-manager/index.ts +12 -8
- package/src/autonat/constants.ts +17 -2
- package/src/autonat/index.ts +49 -41
- package/src/circuit-relay/server/advert-service.ts +2 -2
- package/src/circuit-relay/server/index.ts +11 -3
- package/src/circuit-relay/transport/discovery.ts +5 -3
- package/src/circuit-relay/transport/index.ts +9 -4
- package/src/circuit-relay/transport/listener.ts +38 -28
- package/src/circuit-relay/transport/reservation-store.ts +34 -20
- package/src/components.ts +71 -234
- package/src/config/connection-gater.browser.ts +31 -0
- package/src/config/connection-gater.ts +19 -0
- package/src/config.ts +3 -64
- package/src/connection-manager/auto-dial.ts +24 -5
- package/src/connection-manager/connection-pruner.ts +28 -8
- package/src/connection-manager/dial-queue.ts +21 -19
- package/src/connection-manager/index.ts +31 -42
- package/src/content-routing/index.ts +7 -55
- package/src/content-routing/utils.ts +3 -1
- package/src/fetch/index.ts +51 -14
- package/src/identify/index.ts +235 -225
- package/src/index.ts +14 -77
- package/src/libp2p.ts +139 -252
- package/src/peer-routing.ts +1 -101
- package/src/ping/constants.ts +11 -0
- package/src/ping/index.ts +32 -28
- package/src/registrar.ts +31 -27
- package/src/transport-manager.ts +49 -15
- package/src/upgrader.ts +51 -49
- package/src/{nat-manager.ts → upnp-nat/index.ts} +16 -17
- package/src/version.ts +1 -1
- package/dist/src/dht/dht-content-routing.d.ts +0 -17
- package/dist/src/dht/dht-content-routing.d.ts.map +0 -1
- package/dist/src/dht/dht-content-routing.js +0 -32
- package/dist/src/dht/dht-content-routing.js.map +0 -1
- package/dist/src/dht/dht-peer-routing.d.ts +0 -15
- package/dist/src/dht/dht-peer-routing.d.ts.map +0 -1
- package/dist/src/dht/dht-peer-routing.js +0 -26
- package/dist/src/dht/dht-peer-routing.js.map +0 -1
- package/dist/src/dht/dummy-dht.d.ts +0 -20
- package/dist/src/dht/dummy-dht.d.ts.map +0 -1
- package/dist/src/dht/dummy-dht.js +0 -46
- package/dist/src/dht/dummy-dht.js.map +0 -1
- package/dist/src/nat-manager.d.ts +0 -74
- package/dist/src/nat-manager.d.ts.map +0 -1
- package/dist/src/nat-manager.js.map +0 -1
- package/dist/src/peer-record-updater.d.ts +0 -24
- package/dist/src/peer-record-updater.d.ts.map +0 -1
- package/dist/src/peer-record-updater.js +0 -44
- package/dist/src/peer-record-updater.js.map +0 -1
- package/src/dht/dht-content-routing.ts +0 -44
- package/src/dht/dht-peer-routing.ts +0 -36
- package/src/dht/dummy-dht.ts +0 -60
- package/src/peer-record-updater.ts +0 -65
package/dist/src/index.d.ts
CHANGED
|
@@ -15,10 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { RecursivePartial } from '@libp2p/interfaces';
|
|
17
17
|
import type { TransportManagerInit } from './transport-manager.js';
|
|
18
|
-
import type { IdentifyServiceInit } from './identify/index.js';
|
|
19
|
-
import type { DualDHT } from '@libp2p/interface-dht';
|
|
20
18
|
import type { Datastore } from 'interface-datastore';
|
|
21
|
-
import type { PeerStoreInit } from '@libp2p/interface-peer-store';
|
|
22
19
|
import type { PeerId } from '@libp2p/interface-peer-id';
|
|
23
20
|
import type { PeerDiscovery } from '@libp2p/interface-peer-discovery';
|
|
24
21
|
import type { ConnectionProtector } from '@libp2p/interface-connection';
|
|
@@ -28,24 +25,20 @@ import type { StreamMuxerFactory } from '@libp2p/interface-stream-muxer';
|
|
|
28
25
|
import type { ConnectionEncrypter } from '@libp2p/interface-connection-encrypter';
|
|
29
26
|
import type { PeerRouting } from '@libp2p/interface-peer-routing';
|
|
30
27
|
import type { ContentRouting } from '@libp2p/interface-content-routing';
|
|
31
|
-
import type { PubSub } from '@libp2p/interface-pubsub';
|
|
32
28
|
import type { Metrics } from '@libp2p/interface-metrics';
|
|
33
|
-
import type { PeerInfo } from '@libp2p/interface-peer-info';
|
|
34
|
-
import type { PingServiceInit } from './ping/index.js';
|
|
35
|
-
import type { FetchServiceInit } from './fetch/index.js';
|
|
36
|
-
import type { AutonatServiceInit } from './autonat/index.js';
|
|
37
29
|
import type { Components } from './components.js';
|
|
38
|
-
import type { Libp2p } from '@libp2p/interface-libp2p';
|
|
30
|
+
import type { Libp2p, ServiceMap } from '@libp2p/interface-libp2p';
|
|
39
31
|
import type { KeyChainInit } from '@libp2p/keychain';
|
|
40
|
-
import type { NatManagerInit } from './nat-manager.js';
|
|
41
32
|
import type { AddressManagerInit } from './address-manager/index.js';
|
|
42
|
-
import type { PeerRoutingInit } from './peer-routing.js';
|
|
43
33
|
import type { ConnectionManagerInit } from './connection-manager/index.js';
|
|
44
|
-
import type {
|
|
34
|
+
import type { PersistentPeerStoreInit } from '@libp2p/peer-store';
|
|
35
|
+
export type ServiceFactoryMap<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
36
|
+
[Property in keyof T]: (components: Components) => T[Property];
|
|
37
|
+
};
|
|
45
38
|
/**
|
|
46
39
|
* For Libp2p configurations and modules details read the [Configuration Document](./CONFIGURATION.md).
|
|
47
40
|
*/
|
|
48
|
-
export interface Libp2pInit {
|
|
41
|
+
export interface Libp2pInit<T extends ServiceMap = {}> {
|
|
49
42
|
/**
|
|
50
43
|
* peerId instance (it will be created if not provided)
|
|
51
44
|
*/
|
|
@@ -75,40 +68,11 @@ export interface Libp2pInit {
|
|
|
75
68
|
/**
|
|
76
69
|
* libp2p PeerStore configuration
|
|
77
70
|
*/
|
|
78
|
-
peerStore:
|
|
79
|
-
/**
|
|
80
|
-
* libp2p Peer routing service configuration
|
|
81
|
-
*/
|
|
82
|
-
peerRouting: PeerRoutingInit;
|
|
71
|
+
peerStore: PersistentPeerStoreInit;
|
|
83
72
|
/**
|
|
84
73
|
* keychain configuration
|
|
85
74
|
*/
|
|
86
75
|
keychain: KeyChainInit;
|
|
87
|
-
/**
|
|
88
|
-
* The NAT manager controls uPNP hole punching
|
|
89
|
-
*/
|
|
90
|
-
nat: NatManagerInit;
|
|
91
|
-
/**
|
|
92
|
-
* If configured as a relay this node will relay certain
|
|
93
|
-
* types of traffic for other peers
|
|
94
|
-
*/
|
|
95
|
-
relay: (components: Components) => CircuitRelayService;
|
|
96
|
-
/**
|
|
97
|
-
* identify protocol options
|
|
98
|
-
*/
|
|
99
|
-
identify: IdentifyServiceInit;
|
|
100
|
-
/**
|
|
101
|
-
* ping protocol options
|
|
102
|
-
*/
|
|
103
|
-
ping: PingServiceInit;
|
|
104
|
-
/**
|
|
105
|
-
* fetch protocol options
|
|
106
|
-
*/
|
|
107
|
-
fetch: FetchServiceInit;
|
|
108
|
-
/**
|
|
109
|
-
* autonat protocol options
|
|
110
|
-
*/
|
|
111
|
-
autonat: AutonatServiceInit;
|
|
112
76
|
/**
|
|
113
77
|
* An array that must include at least 1 compliant transport
|
|
114
78
|
*/
|
|
@@ -118,41 +82,21 @@ export interface Libp2pInit {
|
|
|
118
82
|
peerDiscovery?: Array<(components: Components) => PeerDiscovery>;
|
|
119
83
|
peerRouters?: Array<(components: Components) => PeerRouting>;
|
|
120
84
|
contentRouters?: Array<(components: Components) => ContentRouting>;
|
|
121
|
-
/**
|
|
122
|
-
* Pass a DHT implementation to enable DHT operations
|
|
123
|
-
*/
|
|
124
|
-
dht?: (components: Components) => DualDHT;
|
|
125
85
|
/**
|
|
126
86
|
* A Metrics implementation can be supplied to collect metrics on this node
|
|
127
87
|
*/
|
|
128
88
|
metrics?: (components: Components) => Metrics;
|
|
129
|
-
/**
|
|
130
|
-
* If a PubSub implmentation is supplied, PubSub operations will become available
|
|
131
|
-
*/
|
|
132
|
-
pubsub?: (components: Components) => PubSub;
|
|
133
89
|
/**
|
|
134
90
|
* A ConnectionProtector can be used to create a secure overlay on top of the network using pre-shared keys
|
|
135
91
|
*/
|
|
136
92
|
connectionProtector?: (components: Components) => ConnectionProtector;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Once you have a libp2p instance, you can listen to several events it emits, so that you can be notified of relevant network events.
|
|
140
|
-
*/
|
|
141
|
-
export interface Libp2pEvents {
|
|
142
93
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* ```js
|
|
146
|
-
* libp2p.addEventListener('peer:discovery', (event) => {
|
|
147
|
-
* const peerInfo = event.detail
|
|
148
|
-
* // ...
|
|
149
|
-
* })
|
|
150
|
-
* ```
|
|
94
|
+
* Arbitrary libp2p modules
|
|
151
95
|
*/
|
|
152
|
-
|
|
96
|
+
services: ServiceFactoryMap<T>;
|
|
153
97
|
}
|
|
154
98
|
export type { Libp2p };
|
|
155
|
-
export type Libp2pOptions = RecursivePartial<Libp2pInit
|
|
99
|
+
export type Libp2pOptions<T extends ServiceMap = {}> = RecursivePartial<Libp2pInit<T>> & {
|
|
156
100
|
start?: boolean;
|
|
157
101
|
};
|
|
158
102
|
/**
|
|
@@ -168,11 +112,12 @@ export type Libp2pOptions = RecursivePartial<Libp2pInit> & {
|
|
|
168
112
|
* import { tcp } from '@libp2p/tcp'
|
|
169
113
|
* import { mplex } from '@libp2p/mplex'
|
|
170
114
|
* import { noise } from '@chainsafe/libp2p-noise'
|
|
115
|
+
* import { yamux } from '@chainsafe/libp2p-yamux'
|
|
171
116
|
*
|
|
172
117
|
* // specify options
|
|
173
118
|
* const options = {
|
|
174
119
|
* transports: [tcp()],
|
|
175
|
-
* streamMuxers: [mplex()],
|
|
120
|
+
* streamMuxers: [yamux(), mplex()],
|
|
176
121
|
* connectionEncryption: [noise()]
|
|
177
122
|
* }
|
|
178
123
|
*
|
|
@@ -180,5 +125,5 @@ export type Libp2pOptions = RecursivePartial<Libp2pInit> & {
|
|
|
180
125
|
* const libp2p = await createLibp2p(options)
|
|
181
126
|
* ```
|
|
182
127
|
*/
|
|
183
|
-
export declare function createLibp2p(options: Libp2pOptions): Promise<Libp2p
|
|
128
|
+
export declare function createLibp2p<T extends ServiceMap = {}>(options: Libp2pOptions<T>): Promise<Libp2p<T>>;
|
|
184
129
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;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A;IAC5D,cAAc,CAAC,EAAE,KAAK,CAAC,CAAC,UAAU,EAAE,UAAU,KAAK,cAAc,CAAC,CAAA;IAElE;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAA;IAE7C;;OAEG;IACH,mBAAmB,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,mBAAmB,CAAA;IAErE;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAA;CAC/B;AAED,YAAY,EAAE,MAAM,EAAE,CAAA;AAEtB,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,UAAU,GAAG,EAAE,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAE5G;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,YAAY,CAAE,CAAC,SAAS,UAAU,GAAG,EAAE,EAAG,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAQ7G"}
|
package/dist/src/index.js
CHANGED
|
@@ -27,11 +27,12 @@ import { createLibp2pNode } from './libp2p.js';
|
|
|
27
27
|
* import { tcp } from '@libp2p/tcp'
|
|
28
28
|
* import { mplex } from '@libp2p/mplex'
|
|
29
29
|
* import { noise } from '@chainsafe/libp2p-noise'
|
|
30
|
+
* import { yamux } from '@chainsafe/libp2p-yamux'
|
|
30
31
|
*
|
|
31
32
|
* // specify options
|
|
32
33
|
* const options = {
|
|
33
34
|
* transports: [tcp()],
|
|
34
|
-
* streamMuxers: [mplex()],
|
|
35
|
+
* streamMuxers: [yamux(), mplex()],
|
|
35
36
|
* connectionEncryption: [noise()]
|
|
36
37
|
* }
|
|
37
38
|
*
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAqG9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAA8B,OAAyB;IACvF,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAE5C,IAAI,OAAO,CAAC,KAAK,KAAK,KAAK,EAAE;QAC3B,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;KACnB;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/dist/src/libp2p.d.ts
CHANGED
|
@@ -1,46 +1,28 @@
|
|
|
1
1
|
import type { AbortOptions } from '@libp2p/interfaces';
|
|
2
2
|
import { EventEmitter } from '@libp2p/interfaces/events';
|
|
3
3
|
import { Multiaddr } from '@multiformats/multiaddr';
|
|
4
|
-
import { IdentifyService } from './identify/index.js';
|
|
5
|
-
import { FetchService } from './fetch/index.js';
|
|
6
|
-
import { PingService } from './ping/index.js';
|
|
7
|
-
import { AutonatService } from './autonat/index.js';
|
|
8
4
|
import type { Components } from './components.js';
|
|
9
5
|
import type { PeerId } from '@libp2p/interface-peer-id';
|
|
10
6
|
import type { Connection, Stream } from '@libp2p/interface-connection';
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import type { PubSub } from '@libp2p/interface-pubsub';
|
|
14
|
-
import type { Registrar, StreamHandler, StreamHandlerOptions, Topology } from '@libp2p/interface-registrar';
|
|
15
|
-
import type { ConnectionManager } from '@libp2p/interface-connection-manager';
|
|
16
|
-
import type { PeerInfo } from '@libp2p/interface-peer-info';
|
|
17
|
-
import type { Libp2p, Libp2pEvents, Libp2pInit, Libp2pOptions } from './index.js';
|
|
7
|
+
import type { StreamHandler, StreamHandlerOptions, Topology } from '@libp2p/interface-registrar';
|
|
8
|
+
import type { Libp2p, Libp2pInit, Libp2pOptions } from './index.js';
|
|
18
9
|
import type { PeerStore } from '@libp2p/interface-peer-store';
|
|
19
|
-
import type { DualDHT } from '@libp2p/interface-dht';
|
|
20
10
|
import type { Metrics } from '@libp2p/interface-metrics';
|
|
21
11
|
import type { KeyChain } from '@libp2p/interface-keychain';
|
|
22
|
-
import type {
|
|
23
|
-
import
|
|
24
|
-
|
|
12
|
+
import type { Libp2pEvents, PendingDial, ServiceMap } from '@libp2p/interface-libp2p';
|
|
13
|
+
import { ContentRouting } from '@libp2p/interface-content-routing';
|
|
14
|
+
import { PeerRouting } from '@libp2p/interface-peer-routing';
|
|
15
|
+
export declare class Libp2pNode<T extends ServiceMap = {}> extends EventEmitter<Libp2pEvents> implements Libp2p<T> {
|
|
16
|
+
#private;
|
|
25
17
|
peerId: PeerId;
|
|
26
|
-
dht: DualDHT;
|
|
27
|
-
pubsub: PubSub;
|
|
28
|
-
identifyService: IdentifyService;
|
|
29
|
-
circuitService?: CircuitRelayService;
|
|
30
|
-
fetchService: FetchService;
|
|
31
|
-
pingService: PingService;
|
|
32
|
-
autonatService: AutonatService;
|
|
33
|
-
components: Components;
|
|
34
18
|
peerStore: PeerStore;
|
|
35
19
|
contentRouting: ContentRouting;
|
|
36
20
|
peerRouting: PeerRouting;
|
|
37
21
|
keychain: KeyChain;
|
|
38
|
-
connectionManager: ConnectionManager;
|
|
39
|
-
registrar: Registrar;
|
|
40
22
|
metrics?: Metrics;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
constructor(init: Libp2pInit);
|
|
23
|
+
services: T;
|
|
24
|
+
components: Components;
|
|
25
|
+
constructor(init: Libp2pInit<T>);
|
|
44
26
|
private configureComponent;
|
|
45
27
|
/**
|
|
46
28
|
* Starts the libp2p node and all its subsystems
|
|
@@ -63,21 +45,14 @@ export declare class Libp2pNode extends EventEmitter<Libp2pEvents> implements Li
|
|
|
63
45
|
* Get the public key for the given peer id
|
|
64
46
|
*/
|
|
65
47
|
getPublicKey(peer: PeerId, options?: AbortOptions): Promise<Uint8Array>;
|
|
66
|
-
fetch(peer: PeerId | Multiaddr, key: string, options?: AbortOptions): Promise<Uint8Array | null>;
|
|
67
|
-
ping(peer: PeerId | Multiaddr, options?: AbortOptions): Promise<number>;
|
|
68
48
|
handle(protocols: string | string[], handler: StreamHandler, options?: StreamHandlerOptions): Promise<void>;
|
|
69
49
|
unhandle(protocols: string[] | string): Promise<void>;
|
|
70
50
|
register(protocol: string, topology: Topology): Promise<string>;
|
|
71
51
|
unregister(id: string): void;
|
|
72
|
-
/**
|
|
73
|
-
* Called whenever peer discovery services emit `peer` events and adds peers
|
|
74
|
-
* to the peer store.
|
|
75
|
-
*/
|
|
76
|
-
onDiscoveryPeer(evt: CustomEvent<PeerInfo>): void;
|
|
77
52
|
}
|
|
78
53
|
/**
|
|
79
54
|
* Returns a new Libp2pNode instance - this exposes more of the internals than the
|
|
80
55
|
* libp2p interface and is useful for testing and debugging.
|
|
81
56
|
*/
|
|
82
|
-
export declare function createLibp2pNode(options: Libp2pOptions): Promise<Libp2pNode
|
|
57
|
+
export declare function createLibp2pNode<T extends ServiceMap = {}>(options: Libp2pOptions<T>): Promise<Libp2pNode<T>>;
|
|
83
58
|
//# sourceMappingURL=libp2p.d.ts.map
|
package/dist/src/libp2p.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libp2p.d.ts","sourceRoot":"","sources":["../../src/libp2p.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAe,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"libp2p.d.ts","sourceRoot":"","sources":["../../src/libp2p.ts"],"names":[],"mappings":"AACA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