libp2p 0.44.0 → 0.45.0-08d4c261
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 +32 -32
- package/dist/src/address-manager/index.d.ts +9 -5
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/index.js +44 -7
- package/dist/src/address-manager/index.js.map +1 -1
- package/dist/src/address-manager/utils.d.ts +2 -0
- package/dist/src/address-manager/utils.d.ts.map +1 -0
- package/dist/src/address-manager/utils.js +12 -0
- package/dist/src/address-manager/utils.js.map +1 -0
- 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 +12 -33
- package/dist/src/autonat/index.d.ts.map +1 -1
- package/dist/src/autonat/index.js +48 -33
- package/dist/src/autonat/index.js.map +1 -1
- package/dist/src/circuit-relay/index.d.ts +1 -1
- package/dist/src/circuit-relay/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.d.ts +2 -2
- package/dist/src/circuit-relay/server/advert-service.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.js +8 -4
- package/dist/src/circuit-relay/server/advert-service.js.map +1 -1
- package/dist/src/circuit-relay/server/index.d.ts +8 -8
- package/dist/src/circuit-relay/server/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/index.js +32 -12
- package/dist/src/circuit-relay/server/index.js.map +1 -1
- package/dist/src/circuit-relay/server/reservation-store.d.ts +5 -5
- package/dist/src/circuit-relay/server/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/reservation-store.js +10 -3
- package/dist/src/circuit-relay/server/reservation-store.js.map +1 -1
- package/dist/src/circuit-relay/server/reservation-voucher.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/reservation-voucher.js +5 -2
- package/dist/src/circuit-relay/server/reservation-voucher.js.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.d.ts +4 -4
- package/dist/src/circuit-relay/transport/discovery.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.js +13 -5
- package/dist/src/circuit-relay/transport/discovery.js.map +1 -1
- package/dist/src/circuit-relay/transport/index.d.ts +10 -8
- package/dist/src/circuit-relay/transport/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/index.js +26 -18
- package/dist/src/circuit-relay/transport/index.js.map +1 -1
- package/dist/src/circuit-relay/transport/listener.d.ts +1 -1
- package/dist/src/circuit-relay/transport/listener.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/listener.js +43 -43
- package/dist/src/circuit-relay/transport/listener.js.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.d.ts +8 -7
- package/dist/src/circuit-relay/transport/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.js +65 -52
- package/dist/src/circuit-relay/transport/reservation-store.js.map +1 -1
- package/dist/src/circuit-relay/utils.d.ts.map +1 -1
- package/dist/src/circuit-relay/utils.js +3 -3
- package/dist/src/circuit-relay/utils.js.map +1 -1
- package/dist/src/components.d.ts +10 -67
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/components.js +61 -165
- 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 +4 -66
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection/index.d.ts +3 -3
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/index.js +38 -8
- package/dist/src/connection/index.js.map +1 -1
- package/dist/src/connection-manager/auto-dial.d.ts +4 -1
- package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dial.js +44 -13
- 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 +28 -8
- package/dist/src/connection-manager/connection-pruner.js.map +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts +7 -6
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +59 -23
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +16 -15
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +44 -41
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/connection-manager/utils.d.ts +2 -3
- package/dist/src/connection-manager/utils.d.ts.map +1 -1
- package/dist/src/connection-manager/utils.js +3 -3
- package/dist/src/connection-manager/utils.js.map +1 -1
- package/dist/src/content-routing/index.d.ts +2 -12
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +12 -44
- package/dist/src/content-routing/index.js.map +1 -1
- package/dist/src/content-routing/utils.d.ts +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 +15 -37
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +19 -16
- package/dist/src/fetch/index.js.map +1 -1
- package/dist/src/get-peer.d.ts +1 -1
- package/dist/src/get-peer.d.ts.map +1 -1
- package/dist/src/get-peer.js +3 -3
- package/dist/src/get-peer.js.map +1 -1
- package/dist/src/identify/identify.d.ts +53 -0
- package/dist/src/identify/identify.d.ts.map +1 -0
- package/dist/src/identify/identify.js +417 -0
- package/dist/src/identify/identify.js.map +1 -0
- package/dist/src/identify/index.d.ts +14 -59
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/identify/index.js +5 -388
- package/dist/src/identify/index.js.map +1 -1
- package/dist/src/index.d.ts +28 -79
- 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/insecure/index.js +6 -8
- package/dist/src/insecure/index.js.map +1 -1
- package/dist/src/libp2p.d.ts +16 -47
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +141 -201
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.d.ts +3 -40
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +8 -65
- 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 +11 -28
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/ping/index.js +31 -28
- package/dist/src/ping/index.js.map +1 -1
- package/dist/src/pnet/crypto.js +3 -3
- package/dist/src/pnet/crypto.js.map +1 -1
- package/dist/src/pnet/index.d.ts.map +1 -1
- package/dist/src/pnet/index.js +9 -6
- package/dist/src/pnet/index.js.map +1 -1
- package/dist/src/pnet/key-generator.js +1 -1
- package/dist/src/pnet/key-generator.js.map +1 -1
- package/dist/src/pubsub/dummy-pubsub.d.ts.map +1 -1
- package/dist/src/pubsub/dummy-pubsub.js +2 -5
- package/dist/src/pubsub/dummy-pubsub.js.map +1 -1
- package/dist/src/registrar.d.ts +6 -4
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +33 -28
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/transport-manager.d.ts +14 -7
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +27 -13
- package/dist/src/transport-manager.js.map +1 -1
- package/dist/src/upgrader.d.ts +20 -15
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +49 -53
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/{nat-manager.d.ts → upnp-nat/index.d.ts} +12 -15
- package/dist/src/upnp-nat/index.d.ts.map +1 -0
- package/dist/src/{nat-manager.js → upnp-nat/index.js} +23 -10
- package/dist/src/upnp-nat/index.js.map +1 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +62 -47
- package/src/address-manager/index.ts +52 -10
- package/src/address-manager/utils.ts +14 -0
- package/src/autonat/constants.ts +17 -2
- package/src/autonat/index.ts +65 -57
- package/src/circuit-relay/index.ts +1 -1
- package/src/circuit-relay/server/advert-service.ts +5 -5
- package/src/circuit-relay/server/index.ts +28 -20
- package/src/circuit-relay/server/reservation-store.ts +5 -5
- package/src/circuit-relay/server/reservation-voucher.ts +1 -1
- package/src/circuit-relay/transport/discovery.ts +12 -10
- package/src/circuit-relay/transport/index.ts +26 -26
- package/src/circuit-relay/transport/listener.ts +43 -33
- package/src/circuit-relay/transport/reservation-store.ts +42 -28
- package/src/circuit-relay/utils.ts +6 -6
- package/src/components.ts +75 -238
- package/src/config/connection-gater.browser.ts +31 -0
- package/src/config/connection-gater.ts +19 -0
- package/src/config.ts +9 -70
- package/src/connection/index.ts +6 -10
- package/src/connection-manager/auto-dial.ts +46 -17
- package/src/connection-manager/connection-pruner.ts +30 -10
- package/src/connection-manager/dial-queue.ts +56 -35
- package/src/connection-manager/index.ts +45 -57
- package/src/connection-manager/utils.ts +4 -5
- package/src/content-routing/index.ts +11 -59
- package/src/content-routing/utils.ts +4 -2
- package/src/fetch/index.ts +63 -26
- package/src/get-peer.ts +4 -4
- package/src/identify/identify.ts +519 -0
- package/src/identify/index.ts +19 -509
- package/src/index.ts +25 -88
- package/src/insecure/index.ts +10 -10
- package/src/libp2p.ts +158 -279
- package/src/peer-routing.ts +10 -110
- package/src/ping/constants.ts +11 -0
- package/src/ping/index.ts +43 -39
- package/src/pnet/crypto.ts +3 -3
- package/src/pnet/index.ts +6 -6
- package/src/pnet/key-generator.ts +1 -1
- package/src/pubsub/dummy-pubsub.ts +2 -2
- package/src/registrar.ts +34 -31
- package/src/transport-manager.ts +33 -19
- package/src/upgrader.ts +75 -71
- package/src/{nat-manager.ts → upnp-nat/index.ts} +23 -24
- 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.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/dist/typedoc-urls.json +0 -41
- 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/components.js
CHANGED
|
@@ -1,189 +1,85 @@
|
|
|
1
1
|
import { CodeError } from '@libp2p/interfaces/errors';
|
|
2
2
|
import { isStartable } from '@libp2p/interfaces/startable';
|
|
3
|
-
|
|
3
|
+
class DefaultComponents {
|
|
4
|
+
components = {};
|
|
5
|
+
_started = false;
|
|
4
6
|
constructor(init = {}) {
|
|
5
|
-
this.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this._upgrader = init.upgrader;
|
|
10
|
-
this._metrics = init.metrics;
|
|
11
|
-
this._registrar = init.registrar;
|
|
12
|
-
this._connectionManager = init.connectionManager;
|
|
13
|
-
this._transportManager = init.transportManager;
|
|
14
|
-
this._connectionGater = init.connectionGater;
|
|
15
|
-
this._contentRouting = init.contentRouting;
|
|
16
|
-
this._peerRouting = init.peerRouting;
|
|
17
|
-
this._datastore = init.datastore;
|
|
18
|
-
this._connectionProtector = init.connectionProtector;
|
|
19
|
-
this._dht = init.dht;
|
|
20
|
-
this._pubsub = init.pubsub;
|
|
7
|
+
this.components = {};
|
|
8
|
+
for (const [key, value] of Object.entries(init)) {
|
|
9
|
+
this.components[key] = value;
|
|
10
|
+
}
|
|
21
11
|
}
|
|
22
12
|
isStarted() {
|
|
23
13
|
return this._started;
|
|
24
14
|
}
|
|
25
|
-
async
|
|
26
|
-
await Promise.all(Object.values(this
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
async _invokeStartableMethod(methodName) {
|
|
16
|
+
await Promise.all(Object.values(this.components)
|
|
17
|
+
.filter(obj => isStartable(obj))
|
|
18
|
+
.map(async (startable) => {
|
|
19
|
+
await startable[methodName]?.();
|
|
30
20
|
}));
|
|
31
21
|
}
|
|
22
|
+
async beforeStart() {
|
|
23
|
+
await this._invokeStartableMethod('beforeStart');
|
|
24
|
+
}
|
|
32
25
|
async start() {
|
|
33
|
-
await
|
|
34
|
-
await startable.start();
|
|
35
|
-
}));
|
|
26
|
+
await this._invokeStartableMethod('start');
|
|
36
27
|
this._started = true;
|
|
37
28
|
}
|
|
38
29
|
async afterStart() {
|
|
39
|
-
await
|
|
40
|
-
if (startable.afterStart != null) {
|
|
41
|
-
await startable.afterStart();
|
|
42
|
-
}
|
|
43
|
-
}));
|
|
30
|
+
await this._invokeStartableMethod('afterStart');
|
|
44
31
|
}
|
|
45
32
|
async beforeStop() {
|
|
46
|
-
await
|
|
47
|
-
if (startable.beforeStop != null) {
|
|
48
|
-
await startable.beforeStop();
|
|
49
|
-
}
|
|
50
|
-
}));
|
|
33
|
+
await this._invokeStartableMethod('beforeStop');
|
|
51
34
|
}
|
|
52
35
|
async stop() {
|
|
53
|
-
await
|
|
54
|
-
await startable.stop();
|
|
55
|
-
}));
|
|
36
|
+
await this._invokeStartableMethod('stop');
|
|
56
37
|
this._started = false;
|
|
57
38
|
}
|
|
58
39
|
async afterStop() {
|
|
59
|
-
await
|
|
60
|
-
if (startable.afterStop != null) {
|
|
61
|
-
await startable.afterStop();
|
|
62
|
-
}
|
|
63
|
-
}));
|
|
64
|
-
}
|
|
65
|
-
get peerId() {
|
|
66
|
-
if (this._peerId == null) {
|
|
67
|
-
throw new CodeError('peerId not set', 'ERR_SERVICE_MISSING');
|
|
68
|
-
}
|
|
69
|
-
return this._peerId;
|
|
70
|
-
}
|
|
71
|
-
set peerId(peerId) {
|
|
72
|
-
this._peerId = peerId;
|
|
73
|
-
}
|
|
74
|
-
get addressManager() {
|
|
75
|
-
if (this._addressManager == null) {
|
|
76
|
-
throw new CodeError('addressManager not set', 'ERR_SERVICE_MISSING');
|
|
77
|
-
}
|
|
78
|
-
return this._addressManager;
|
|
79
|
-
}
|
|
80
|
-
set addressManager(addressManager) {
|
|
81
|
-
this._addressManager = addressManager;
|
|
82
|
-
}
|
|
83
|
-
get peerStore() {
|
|
84
|
-
if (this._peerStore == null) {
|
|
85
|
-
throw new CodeError('peerStore not set', 'ERR_SERVICE_MISSING');
|
|
86
|
-
}
|
|
87
|
-
return this._peerStore;
|
|
88
|
-
}
|
|
89
|
-
set peerStore(peerStore) {
|
|
90
|
-
this._peerStore = peerStore;
|
|
91
|
-
}
|
|
92
|
-
get upgrader() {
|
|
93
|
-
if (this._upgrader == null) {
|
|
94
|
-
throw new CodeError('upgrader not set', 'ERR_SERVICE_MISSING');
|
|
95
|
-
}
|
|
96
|
-
return this._upgrader;
|
|
97
|
-
}
|
|
98
|
-
set upgrader(upgrader) {
|
|
99
|
-
this._upgrader = upgrader;
|
|
100
|
-
}
|
|
101
|
-
get registrar() {
|
|
102
|
-
if (this._registrar == null) {
|
|
103
|
-
throw new CodeError('registrar not set', 'ERR_SERVICE_MISSING');
|
|
104
|
-
}
|
|
105
|
-
return this._registrar;
|
|
106
|
-
}
|
|
107
|
-
set registrar(registrar) {
|
|
108
|
-
this._registrar = registrar;
|
|
40
|
+
await this._invokeStartableMethod('afterStop');
|
|
109
41
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
throw new CodeError('peerRouting not set', 'ERR_SERVICE_MISSING');
|
|
149
|
-
}
|
|
150
|
-
return this._peerRouting;
|
|
151
|
-
}
|
|
152
|
-
set peerRouting(peerRouting) {
|
|
153
|
-
this._peerRouting = peerRouting;
|
|
154
|
-
}
|
|
155
|
-
get datastore() {
|
|
156
|
-
if (this._datastore == null) {
|
|
157
|
-
throw new CodeError('datastore not set', 'ERR_SERVICE_MISSING');
|
|
42
|
+
}
|
|
43
|
+
const OPTIONAL_SERVICES = [
|
|
44
|
+
'metrics',
|
|
45
|
+
'connectionProtector'
|
|
46
|
+
];
|
|
47
|
+
const NON_SERVICE_PROPERTIES = [
|
|
48
|
+
'components',
|
|
49
|
+
'isStarted',
|
|
50
|
+
'beforeStart',
|
|
51
|
+
'start',
|
|
52
|
+
'afterStart',
|
|
53
|
+
'beforeStop',
|
|
54
|
+
'stop',
|
|
55
|
+
'afterStop',
|
|
56
|
+
'then',
|
|
57
|
+
'_invokeStartableMethod'
|
|
58
|
+
];
|
|
59
|
+
export function defaultComponents(init = {}) {
|
|
60
|
+
const components = new DefaultComponents(init);
|
|
61
|
+
const proxy = new Proxy(components, {
|
|
62
|
+
get(target, prop, receiver) {
|
|
63
|
+
if (typeof prop === 'string' && !NON_SERVICE_PROPERTIES.includes(prop)) {
|
|
64
|
+
const service = components.components[prop];
|
|
65
|
+
if (service == null && !OPTIONAL_SERVICES.includes(prop)) {
|
|
66
|
+
throw new CodeError(`${prop} not set`, 'ERR_SERVICE_MISSING');
|
|
67
|
+
}
|
|
68
|
+
return service;
|
|
69
|
+
}
|
|
70
|
+
return Reflect.get(target, prop, receiver);
|
|
71
|
+
},
|
|
72
|
+
set(target, prop, value) {
|
|
73
|
+
if (typeof prop === 'string') {
|
|
74
|
+
components.components[prop] = value;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
Reflect.set(target, prop, value);
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
158
80
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
this._datastore = datastore;
|
|
163
|
-
}
|
|
164
|
-
get connectionProtector() {
|
|
165
|
-
return this._connectionProtector;
|
|
166
|
-
}
|
|
167
|
-
set connectionProtector(connectionProtector) {
|
|
168
|
-
this._connectionProtector = connectionProtector;
|
|
169
|
-
}
|
|
170
|
-
get metrics() {
|
|
171
|
-
return this._metrics;
|
|
172
|
-
}
|
|
173
|
-
set metrics(metrics) {
|
|
174
|
-
this._metrics = metrics;
|
|
175
|
-
}
|
|
176
|
-
get dht() {
|
|
177
|
-
return this._dht;
|
|
178
|
-
}
|
|
179
|
-
set dht(dht) {
|
|
180
|
-
this._dht = dht;
|
|
181
|
-
}
|
|
182
|
-
get pubsub() {
|
|
183
|
-
return this._pubsub;
|
|
184
|
-
}
|
|
185
|
-
set pubsub(pubsub) {
|
|
186
|
-
this._pubsub = pubsub;
|
|
187
|
-
}
|
|
81
|
+
});
|
|
82
|
+
// @ts-expect-error component keys are proxied
|
|
83
|
+
return proxy;
|
|
188
84
|
}
|
|
189
85
|
//# sourceMappingURL=components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,WAAW,EAAkB,MAAM,8BAA8B,CAAA;AAkD1E,MAAM,iBAAiB;IACd,UAAU,GAAwB,EAAE,CAAA;IACnC,QAAQ,GAAG,KAAK,CAAA;IAExB,YAAa,OAAuB,EAAE;QACpC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;QAEpB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC/C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SAC7B;IACH,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAE,UAAwF;QAC5H,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;aAC3B,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;aAC/B,GAAG,CAAC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,CAAC,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACtE,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;gBAE3C,IAAI,OAAO,IAAI,IAAI,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;oBACxD,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,UAAU,EAAE,qBAAqB,CAAC,CAAA;iBAC9D;gBAED,OAAO,OAAO,CAAA;aACf;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;QAC5C,CAAC;QAED,GAAG,CAAE,MAAM,EAAE,IAAI,EAAE,KAAK;YACtB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;gBAC5B,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;aACpC;iBAAM;gBACL,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;aACjC;YAED,OAAO,IAAI,CAAA;QACb,CAAC;KACF,CAAC,CAAA;IAEF,8CAA8C;IAC9C,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ConnectionGater } from '@libp2p/interface-connection-gater';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a connection gater that disallows dialling private addresses by
|
|
4
|
+
* default. Browsers are severely limited in their resource usage so don't
|
|
5
|
+
* waste time trying to dial undiallable addresses.
|
|
6
|
+
*/
|
|
7
|
+
export declare function connectionGater(gater?: ConnectionGater): ConnectionGater;
|
|
8
|
+
//# sourceMappingURL=connection-gater.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-gater.browser.d.ts","sourceRoot":"","sources":["../../../src/config/connection-gater.browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAGzE;;;;GAIG;AACH,wBAAgB,eAAe,CAAE,KAAK,GAAE,eAAoB,GAAG,eAAe,CAqB7E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import isPrivate from 'private-ip';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a connection gater that disallows dialling private addresses by
|
|
4
|
+
* default. Browsers are severely limited in their resource usage so don't
|
|
5
|
+
* waste time trying to dial undiallable addresses.
|
|
6
|
+
*/
|
|
7
|
+
export function connectionGater(gater = {}) {
|
|
8
|
+
return {
|
|
9
|
+
denyDialPeer: async () => false,
|
|
10
|
+
denyDialMultiaddr: async (multiaddr) => {
|
|
11
|
+
const tuples = multiaddr.stringTuples();
|
|
12
|
+
if (tuples[0][0] === 4 || tuples[0][0] === 41) {
|
|
13
|
+
return Boolean(isPrivate(`${tuples[0][1]}`));
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
},
|
|
17
|
+
denyInboundConnection: async () => false,
|
|
18
|
+
denyOutboundConnection: async () => false,
|
|
19
|
+
denyInboundEncryptedConnection: async () => false,
|
|
20
|
+
denyOutboundEncryptedConnection: async () => false,
|
|
21
|
+
denyInboundUpgradedConnection: async () => false,
|
|
22
|
+
denyOutboundUpgradedConnection: async () => false,
|
|
23
|
+
filterMultiaddrForPeer: async () => true,
|
|
24
|
+
...gater
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=connection-gater.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-gater.browser.js","sourceRoot":"","sources":["../../../src/config/connection-gater.browser.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAE,QAAyB,EAAE;IAC1D,OAAO;QACL,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QAC/B,iBAAiB,EAAE,KAAK,EAAE,SAAoB,EAAE,EAAE;YAChD,MAAM,MAAM,GAAG,SAAS,CAAC,YAAY,EAAE,CAAA;YAEvC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC7C,OAAO,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;aAC7C;YAED,OAAO,KAAK,CAAA;QACd,CAAC;QACD,qBAAqB,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QACxC,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QACzC,8BAA8B,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QACjD,+BAA+B,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QAClD,6BAA6B,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QAChD,8BAA8B,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QACjD,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;QACxC,GAAG,KAAK;KACT,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ConnectionGater } from '@libp2p/interface-connection-gater';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a default connection gater implementation that allows everything
|
|
4
|
+
*/
|
|
5
|
+
export declare function connectionGater(gater?: ConnectionGater): ConnectionGater;
|
|
6
|
+
//# sourceMappingURL=connection-gater.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-gater.d.ts","sourceRoot":"","sources":["../../../src/config/connection-gater.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAEzE;;GAEG;AACH,wBAAgB,eAAe,CAAE,KAAK,GAAE,eAAoB,GAAG,eAAe,CAa7E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a default connection gater implementation that allows everything
|
|
3
|
+
*/
|
|
4
|
+
export function connectionGater(gater = {}) {
|
|
5
|
+
return {
|
|
6
|
+
denyDialPeer: async () => false,
|
|
7
|
+
denyDialMultiaddr: async () => false,
|
|
8
|
+
denyInboundConnection: async () => false,
|
|
9
|
+
denyOutboundConnection: async () => false,
|
|
10
|
+
denyInboundEncryptedConnection: async () => false,
|
|
11
|
+
denyOutboundEncryptedConnection: async () => false,
|
|
12
|
+
denyInboundUpgradedConnection: async () => false,
|
|
13
|
+
denyOutboundUpgradedConnection: async () => false,
|
|
14
|
+
filterMultiaddrForPeer: async () => true,
|
|
15
|
+
...gater
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=connection-gater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-gater.js","sourceRoot":"","sources":["../../../src/config/connection-gater.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,eAAe,CAAE,QAAyB,EAAE;IAC1D,OAAO;QACL,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QAC/B,iBAAiB,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QACpC,qBAAqB,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QACxC,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QACzC,8BAA8B,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QACjD,+BAA+B,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QAClD,6BAA6B,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QAChD,8BAA8B,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QACjD,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;QACxC,GAAG,KAAK;KACT,CAAA;AACH,CAAC"}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Libp2pInit } from './index.js';
|
|
2
|
+
import type { ServiceMap } from '@libp2p/interface-libp2p';
|
|
2
3
|
import type { RecursivePartial } from '@libp2p/interfaces';
|
|
3
|
-
export declare function validateConfig(opts: RecursivePartial<Libp2pInit
|
|
4
|
+
export declare function validateConfig<T extends ServiceMap = Record<string, unknown>>(opts: RecursivePartial<Libp2pInit<T>>): Libp2pInit<T>;
|
|
4
5
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAqB1D,wBAAgB,cAAc,CAAE,CAAC,SAAS,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAG,IAAI,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAgBrI"}
|
package/dist/src/config.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import mergeOptions from 'merge-options';
|
|
2
|
-
import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers';
|
|
3
|
-
import { AGENT_VERSION } from './identify/consts.js';
|
|
4
|
-
import { publicAddressesFirst } from '@libp2p/utils/address-sort';
|
|
5
1
|
import { FaultTolerance } from '@libp2p/interface-transport';
|
|
6
|
-
import { codes, messages } from './errors.js';
|
|
7
2
|
import { CodeError } from '@libp2p/interfaces/errors';
|
|
8
|
-
import {
|
|
3
|
+
import { publicAddressesFirst } from '@libp2p/utils/address-sort';
|
|
4
|
+
import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers';
|
|
5
|
+
import mergeOptions from 'merge-options';
|
|
6
|
+
import { codes, messages } from './errors.js';
|
|
9
7
|
const DefaultConfig = {
|
|
10
8
|
addresses: {
|
|
11
9
|
listen: [],
|
|
@@ -21,57 +19,6 @@ const DefaultConfig = {
|
|
|
21
19
|
},
|
|
22
20
|
transportManager: {
|
|
23
21
|
faultTolerance: FaultTolerance.FATAL_ALL
|
|
24
|
-
},
|
|
25
|
-
peerRouting: {
|
|
26
|
-
refreshManager: {
|
|
27
|
-
enabled: true,
|
|
28
|
-
interval: 6e5,
|
|
29
|
-
bootDelay: 10e3
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
nat: {
|
|
33
|
-
enabled: true,
|
|
34
|
-
ttl: 7200,
|
|
35
|
-
keepAlive: true
|
|
36
|
-
},
|
|
37
|
-
identify: {
|
|
38
|
-
protocolPrefix: 'ipfs',
|
|
39
|
-
host: {
|
|
40
|
-
agentVersion: AGENT_VERSION
|
|
41
|
-
},
|
|
42
|
-
// https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L48
|
|
43
|
-
timeout: 60000,
|
|
44
|
-
maxInboundStreams: 1,
|
|
45
|
-
maxOutboundStreams: 1,
|
|
46
|
-
maxPushIncomingStreams: 1,
|
|
47
|
-
maxPushOutgoingStreams: 1,
|
|
48
|
-
maxObservedAddresses: 10
|
|
49
|
-
},
|
|
50
|
-
ping: {
|
|
51
|
-
protocolPrefix: 'ipfs',
|
|
52
|
-
// See https://github.com/libp2p/specs/blob/d4b5fb0152a6bb86cfd9ea/ping/ping.md?plain=1#L38-L43
|
|
53
|
-
// The dialing peer MUST NOT keep more than one outbound stream for the ping protocol per peer.
|
|
54
|
-
// The listening peer SHOULD accept at most two streams per peer since cross-stream behavior is
|
|
55
|
-
// non-linear and stream writes occur asynchronously. The listening peer may perceive the
|
|
56
|
-
// dialing peer closing and opening the wrong streams (for instance, closing stream B and
|
|
57
|
-
// opening stream A even though the dialing peer is opening stream B and closing stream A).
|
|
58
|
-
maxInboundStreams: 2,
|
|
59
|
-
maxOutboundStreams: 1,
|
|
60
|
-
timeout: 10000
|
|
61
|
-
},
|
|
62
|
-
fetch: {
|
|
63
|
-
protocolPrefix: 'libp2p',
|
|
64
|
-
maxInboundStreams: 1,
|
|
65
|
-
maxOutboundStreams: 1,
|
|
66
|
-
timeout: 10000
|
|
67
|
-
},
|
|
68
|
-
autonat: {
|
|
69
|
-
protocolPrefix: 'libp2p',
|
|
70
|
-
maxInboundStreams: 1,
|
|
71
|
-
maxOutboundStreams: 1,
|
|
72
|
-
timeout: 30000,
|
|
73
|
-
startupDelay: 5000,
|
|
74
|
-
refreshInterval: 60000
|
|
75
22
|
}
|
|
76
23
|
};
|
|
77
24
|
export function validateConfig(opts) {
|
|
@@ -85,15 +32,6 @@ export function validateConfig(opts) {
|
|
|
85
32
|
if (resultingOptions.connectionProtector === null && globalThis.process?.env?.LIBP2P_FORCE_PNET != null) { // eslint-disable-line no-undef
|
|
86
33
|
throw new CodeError(messages.ERR_PROTECTOR_REQUIRED, codes.ERR_PROTECTOR_REQUIRED);
|
|
87
34
|
}
|
|
88
|
-
// Append user agent version to default AGENT_VERSION depending on the environment
|
|
89
|
-
if (resultingOptions.identify.host.agentVersion === AGENT_VERSION) {
|
|
90
|
-
if (isNode || isElectronMain) {
|
|
91
|
-
resultingOptions.identify.host.agentVersion += ` UserAgent=${globalThis.process.version}`;
|
|
92
|
-
}
|
|
93
|
-
else if (isBrowser || isWebWorker || isElectronRenderer || isReactNative) {
|
|
94
|
-
resultingOptions.identify.host.agentVersion += ` UserAgent=${globalThis.navigator.userAgent}`;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
35
|
return resultingOptions;
|
|
98
36
|
}
|
|
99
37
|
//# sourceMappingURL=config.js.map
|
package/dist/src/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAM7C,MAAM,aAAa,GAAwB;IACzC,SAAS,EAAE;QACT,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,cAAc,EAAE,CAAC,UAAuB,EAAE,EAAE,CAAC,UAAU;KACxD;IACD,iBAAiB,EAAE;QACjB,SAAS,EAAE;YACT,OAAO,EAAE,eAAe;SACzB;QACD,aAAa,EAAE,oBAAoB;KACpC;IACD,gBAAgB,EAAE;QAChB,cAAc,EAAE,cAAc,CAAC,SAAS;KACzC;CACF,CAAA;AAED,MAAM,UAAU,cAAc,CAAmD,IAAqC;IACpH,MAAM,gBAAgB,GAAkB,YAAY,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;IAEzE,IAAI,gBAAgB,CAAC,UAAU,IAAI,IAAI,IAAI,gBAAgB,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;QACjF,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAA;KACrF;IAED,IAAI,gBAAgB,CAAC,oBAAoB,IAAI,IAAI,IAAI,gBAAgB,CAAC,oBAAoB,CAAC,MAAM,KAAK,CAAC,EAAE;QACvG,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,wBAAwB,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAA;KACvF;IAED,IAAI,gBAAgB,CAAC,mBAAmB,KAAK,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,iBAAiB,IAAI,IAAI,EAAE,EAAE,+BAA+B;QACxI,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAA;KACnF;IAED,OAAO,gBAAgB,CAAA;AACzB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
2
1
|
import { symbol } from '@libp2p/interface-connection';
|
|
3
2
|
import type { Connection, ConnectionStat, Stream } from '@libp2p/interface-connection';
|
|
4
3
|
import type { PeerId } from '@libp2p/interface-peer-id';
|
|
5
4
|
import type { AbortOptions } from '@libp2p/interfaces';
|
|
5
|
+
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
6
6
|
interface ConnectionInit {
|
|
7
7
|
remoteAddr: Multiaddr;
|
|
8
8
|
remotePeer: PeerId;
|
|
@@ -55,8 +55,8 @@ export declare class ConnectionImpl implements Connection {
|
|
|
55
55
|
* Any libp2p transport should use an upgrader to return this connection.
|
|
56
56
|
*/
|
|
57
57
|
constructor(init: ConnectionInit);
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
readonly [Symbol.toStringTag] = "Connection";
|
|
59
|
+
readonly [symbol] = true;
|
|
60
60
|
/**
|
|
61
61
|
* Get all the streams of the muxer
|
|
62
62
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":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BAAe;IAE5C,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAO;IAExB;;OAEG;IACH,IAAI,OAAO,IAAK,MAAM,EAAE,CAEvB;IAED;;OAEG;IACG,SAAS,CAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBvF;;OAEG;IACH,SAAS,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAIhC;;OAEG;IACH,YAAY,CAAE,EAAE,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACG,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;CAsB9B;AAED,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,cAAc,GAAG,UAAU,CAElE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interfaces/errors';
|
|
2
|
-
import { OPEN, CLOSING, CLOSED } from '@libp2p/interface-connection/status';
|
|
3
1
|
import { symbol } from '@libp2p/interface-connection';
|
|
2
|
+
import { OPEN, CLOSING, CLOSED } from '@libp2p/interface-connection/status';
|
|
3
|
+
import { CodeError } from '@libp2p/interfaces/errors';
|
|
4
4
|
import { logger } from '@libp2p/logger';
|
|
5
5
|
const log = logger('libp2p:connection');
|
|
6
6
|
/**
|
|
@@ -8,6 +8,40 @@ const log = logger('libp2p:connection');
|
|
|
8
8
|
* Any libp2p transport should use an upgrader to return this connection.
|
|
9
9
|
*/
|
|
10
10
|
export class ConnectionImpl {
|
|
11
|
+
/**
|
|
12
|
+
* Connection identifier.
|
|
13
|
+
*/
|
|
14
|
+
id;
|
|
15
|
+
/**
|
|
16
|
+
* Observed multiaddr of the remote peer
|
|
17
|
+
*/
|
|
18
|
+
remoteAddr;
|
|
19
|
+
/**
|
|
20
|
+
* Remote peer id
|
|
21
|
+
*/
|
|
22
|
+
remotePeer;
|
|
23
|
+
/**
|
|
24
|
+
* Connection metadata
|
|
25
|
+
*/
|
|
26
|
+
stat;
|
|
27
|
+
/**
|
|
28
|
+
* User provided tags
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
tags;
|
|
32
|
+
/**
|
|
33
|
+
* Reference to the new stream function of the multiplexer
|
|
34
|
+
*/
|
|
35
|
+
_newStream;
|
|
36
|
+
/**
|
|
37
|
+
* Reference to the close function of the raw connection
|
|
38
|
+
*/
|
|
39
|
+
_close;
|
|
40
|
+
/**
|
|
41
|
+
* Reference to the getStreams function of the muxer
|
|
42
|
+
*/
|
|
43
|
+
_getStreams;
|
|
44
|
+
_closing;
|
|
11
45
|
/**
|
|
12
46
|
* An implementation of the js-libp2p connection.
|
|
13
47
|
* Any libp2p transport should use an upgrader to return this connection.
|
|
@@ -27,12 +61,8 @@ export class ConnectionImpl {
|
|
|
27
61
|
this.tags = [];
|
|
28
62
|
this._closing = false;
|
|
29
63
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
get [symbol]() {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
64
|
+
[Symbol.toStringTag] = 'Connection';
|
|
65
|
+
[symbol] = true;
|
|
36
66
|
/**
|
|
37
67
|
* Get all the streams of the muxer
|
|
38
68
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAMvC,MAAM,GAAG,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAA;AAWvC;;;GAGG;AACH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,EAAE,CAAA;QACnB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;QAErB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACrC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IAC3B,CAAC;CACF;AAED,MAAM,UAAU,gBAAgB,CAAE,IAAoB;IACpD,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAA;AACjC,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { PeerStore } from '@libp2p/interface-peer-store';
|
|
2
1
|
import type { ConnectionManager } from '@libp2p/interface-connection-manager';
|
|
2
|
+
import type { Libp2pEvents } from '@libp2p/interface-libp2p';
|
|
3
|
+
import type { PeerStore } from '@libp2p/interface-peer-store';
|
|
4
|
+
import type { EventEmitter } from '@libp2p/interfaces/events';
|
|
3
5
|
import type { Startable } from '@libp2p/interfaces/startable';
|
|
4
6
|
interface AutoDialInit {
|
|
5
7
|
minConnections?: number;
|
|
@@ -10,6 +12,7 @@ interface AutoDialInit {
|
|
|
10
12
|
interface AutoDialComponents {
|
|
11
13
|
connectionManager: ConnectionManager;
|
|
12
14
|
peerStore: PeerStore;
|
|
15
|
+
events: EventEmitter<Libp2pEvents>;
|
|
13
16
|
}
|
|
14
17
|
export declare class AutoDial implements Startable {
|
|
15
18
|
private readonly connectionManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-dial.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/auto-dial.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auto-dial.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/auto-dial.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,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