libp2p 0.35.8 → 0.36.0-d44bd90
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 +55 -0
- package/dist/src/circuit/auto-relay.d.ts +8 -10
- package/dist/src/circuit/auto-relay.d.ts.map +1 -1
- package/dist/src/config.d.ts +2 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dialler.d.ts +1 -1
- package/dist/src/connection-manager/auto-dialler.d.ts.map +1 -1
- package/dist/src/connection-manager/index.d.ts +1 -2
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/content-routing/utils.d.ts +3 -3
- package/dist/src/content-routing/utils.d.ts.map +1 -1
- package/dist/src/dialer/dial-request.d.ts.map +1 -1
- package/dist/src/dialer/index.d.ts +12 -7
- package/dist/src/dialer/index.d.ts.map +1 -1
- package/dist/src/errors.d.ts +2 -0
- package/dist/src/fetch/constants.d.ts +2 -0
- package/dist/src/fetch/constants.d.ts.map +1 -0
- package/dist/src/fetch/index.d.ts +76 -0
- package/dist/src/fetch/index.d.ts.map +1 -0
- package/dist/src/fetch/proto.d.ts +134 -0
- package/dist/src/identify/index.d.ts +4 -4
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/index.d.ts +26 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/metrics/index.d.ts +9 -4
- package/dist/src/metrics/index.d.ts.map +1 -1
- package/dist/src/metrics/tracked-map.d.ts +6 -1
- package/dist/src/metrics/tracked-map.d.ts.map +1 -1
- package/dist/src/peer-routing.d.ts +1 -1
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-store/address-book.d.ts +30 -84
- package/dist/src/peer-store/address-book.d.ts.map +1 -1
- package/dist/src/peer-store/index.d.ts +28 -94
- package/dist/src/peer-store/index.d.ts.map +1 -1
- package/dist/src/peer-store/key-book.d.ts +31 -15
- package/dist/src/peer-store/key-book.d.ts.map +1 -1
- package/dist/src/peer-store/metadata-book.d.ts +33 -29
- package/dist/src/peer-store/metadata-book.d.ts.map +1 -1
- package/dist/src/peer-store/pb/peer.d.ts +222 -0
- package/dist/src/peer-store/proto-book.d.ts +27 -28
- package/dist/src/peer-store/proto-book.d.ts.map +1 -1
- package/dist/src/peer-store/store.d.ts +73 -0
- package/dist/src/peer-store/store.d.ts.map +1 -0
- package/dist/src/peer-store/types.d.ts +202 -0
- package/dist/src/peer-store/types.d.ts.map +1 -0
- package/dist/src/ping/index.d.ts +32 -25
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/record/peer-record/index.d.ts +2 -2
- package/dist/src/record/peer-record/index.d.ts.map +1 -1
- package/dist/src/registrar.d.ts +5 -5
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/types.d.ts +90 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/upgrader.d.ts +8 -2
- package/dist/src/upgrader.d.ts.map +1 -1
- package/package.json +23 -26
- package/src/circuit/auto-relay.js +52 -38
- package/src/config.js +2 -0
- package/src/connection-manager/auto-dialler.js +20 -8
- package/src/connection-manager/index.js +42 -22
- package/src/content-routing/utils.js +4 -4
- package/src/dialer/dial-request.js +4 -1
- package/src/dialer/index.js +38 -8
- package/src/errors.js +2 -0
- package/src/fetch/README.md +36 -0
- package/src/fetch/constants.js +6 -0
- package/src/fetch/index.js +159 -0
- package/src/fetch/proto.d.ts +134 -0
- package/src/fetch/proto.js +333 -0
- package/src/fetch/proto.proto +15 -0
- package/src/identify/index.js +47 -38
- package/src/index.js +81 -34
- package/src/metrics/index.js +15 -8
- package/src/metrics/tracked-map.js +40 -14
- package/src/peer-routing.js +4 -1
- package/src/peer-store/address-book.js +254 -226
- package/src/peer-store/index.js +79 -110
- package/src/peer-store/key-book.js +99 -54
- package/src/peer-store/metadata-book.js +171 -101
- package/src/peer-store/pb/peer.d.ts +222 -0
- package/src/peer-store/pb/peer.js +643 -0
- package/src/peer-store/pb/peer.proto +31 -0
- package/src/peer-store/proto-book.js +171 -105
- package/src/peer-store/store.js +263 -0
- package/src/peer-store/types.ts +245 -0
- package/src/ping/index.js +51 -46
- package/src/record/peer-record/index.js +1 -1
- package/src/record/utils.js +1 -1
- package/src/registrar.js +4 -4
- package/src/types.ts +98 -0
- package/src/upgrader.js +32 -2
- package/dist/src/peer-store/book.d.ts +0 -81
- package/dist/src/peer-store/book.d.ts.map +0 -1
- package/dist/src/peer-store/persistent/consts.d.ts +0 -6
- package/dist/src/peer-store/persistent/consts.d.ts.map +0 -1
- package/dist/src/peer-store/persistent/index.d.ts +0 -129
- package/dist/src/peer-store/persistent/index.d.ts.map +0 -1
- package/dist/src/peer-store/persistent/pb/address-book.d.ts +0 -198
- package/dist/src/peer-store/persistent/pb/proto-book.d.ts +0 -59
- package/src/peer-store/book.js +0 -124
- package/src/peer-store/persistent/consts.js +0 -15
- package/src/peer-store/persistent/index.js +0 -408
- package/src/peer-store/persistent/pb/address-book.d.ts +0 -198
- package/src/peer-store/persistent/pb/address-book.js +0 -522
- package/src/peer-store/persistent/pb/address-book.proto +0 -27
- package/src/peer-store/persistent/pb/proto-book.d.ts +0 -59
- package/src/peer-store/persistent/pb/proto-book.js +0 -157
- package/src/peer-store/persistent/pb/proto-book.proto +0 -5
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export = AutoRelay;
|
|
2
2
|
/**
|
|
3
3
|
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
|
4
|
-
* @typedef {import('../peer-store/
|
|
4
|
+
* @typedef {import('../peer-store/types').Address} Address
|
|
5
|
+
* @typedef {import('peer-id')} PeerId
|
|
5
6
|
*/
|
|
6
7
|
/**
|
|
7
8
|
* @typedef {Object} AutoRelayProperties
|
|
@@ -20,11 +21,11 @@ declare class AutoRelay {
|
|
|
20
21
|
*/
|
|
21
22
|
constructor({ libp2p, maxListeners, onError }: AutoRelayProperties & AutoRelayOptions);
|
|
22
23
|
_libp2p: import("../");
|
|
23
|
-
_peerId:
|
|
24
|
-
_peerStore: import("../peer-store");
|
|
24
|
+
_peerId: import("peer-id");
|
|
25
|
+
_peerStore: import("../peer-store/types").PeerStore;
|
|
25
26
|
_connectionManager: import("../connection-manager");
|
|
26
27
|
_transportManager: import("../transport-manager");
|
|
27
|
-
_addressSorter: (addresses: import("../peer-store/
|
|
28
|
+
_addressSorter: (addresses: import("../peer-store/types").Address[]) => import("../peer-store/types").Address[];
|
|
28
29
|
maxListeners: number;
|
|
29
30
|
/**
|
|
30
31
|
* @type {Set<string>}
|
|
@@ -49,7 +50,6 @@ declare class AutoRelay {
|
|
|
49
50
|
* Peer disconnects.
|
|
50
51
|
*
|
|
51
52
|
* @param {Connection} connection - connection to the peer
|
|
52
|
-
* @returns {void}
|
|
53
53
|
*/
|
|
54
54
|
_onPeerDisconnected(connection: Connection): void;
|
|
55
55
|
/**
|
|
@@ -71,7 +71,6 @@ declare class AutoRelay {
|
|
|
71
71
|
*
|
|
72
72
|
* @private
|
|
73
73
|
* @param {string} id - peer identifier string.
|
|
74
|
-
* @returns {void}
|
|
75
74
|
*/
|
|
76
75
|
private _removeListenRelay;
|
|
77
76
|
/**
|
|
@@ -82,7 +81,6 @@ declare class AutoRelay {
|
|
|
82
81
|
* 3. Search the network.
|
|
83
82
|
*
|
|
84
83
|
* @param {string[]} [peersToIgnore]
|
|
85
|
-
* @returns {Promise<void>}
|
|
86
84
|
*/
|
|
87
85
|
_listenOnAvailableHopRelays(peersToIgnore?: string[] | undefined): Promise<void>;
|
|
88
86
|
/**
|
|
@@ -91,9 +89,9 @@ declare class AutoRelay {
|
|
|
91
89
|
_tryToListenOnRelay(peerId: PeerId): Promise<void>;
|
|
92
90
|
}
|
|
93
91
|
declare namespace AutoRelay {
|
|
94
|
-
export { Connection, Address, AutoRelayProperties, AutoRelayOptions };
|
|
92
|
+
export { Connection, Address, PeerId, AutoRelayProperties, AutoRelayOptions };
|
|
95
93
|
}
|
|
96
|
-
|
|
94
|
+
type PeerId = import('peer-id');
|
|
97
95
|
type Connection = import("libp2p-interfaces/src/connection/connection");
|
|
98
96
|
type AutoRelayProperties = {
|
|
99
97
|
libp2p: import('../');
|
|
@@ -105,5 +103,5 @@ type AutoRelayOptions = {
|
|
|
105
103
|
maxListeners?: number | undefined;
|
|
106
104
|
onError?: ((error: Error, msg?: string | undefined) => {}) | undefined;
|
|
107
105
|
};
|
|
108
|
-
type Address = import('../peer-store/
|
|
106
|
+
type Address = import('../peer-store/types').Address;
|
|
109
107
|
//# sourceMappingURL=auto-relay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-relay.d.ts","sourceRoot":"","sources":["../../../src/circuit/auto-relay.js"],"names":[],"mappings":";AAsBA
|
|
1
|
+
{"version":3,"file":"auto-relay.d.ts","sourceRoot":"","sources":["../../../src/circuit/auto-relay.js"],"names":[],"mappings":";AAsBA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH;IACE;;;;;OAKG;IACH,+CAFW,mBAAmB,GAAG,gBAAgB,EA+BhD;IA5BC,uBAAqB;IACrB,2BAA4B;IAC5B,oDAAkC;IAClC,oDAAkD;IAClD,kDAAgD;IAChD,gHAAiD;IAEjD,qBAAgC;IAEhC;;OAEG;IACH,eAFU,IAAI,MAAM,CAAC,CAES;IAkBhC;;;;;;;;;;OAUG;IACH;QAJyB,MAAM,EAApB,MAAM;QACU,SAAS,EAAzB,MAAM,EAAE;QACN,QAAQ,IAAI,CAAC,CAsCzB;IAED;;;;OAIG;IACH,gCAFW,UAAU,QAcpB;IA5EC;;;OAGG;IACH,kBAHW,KAAK,oCAMf;IAuEH;;;;;;;OAOG;IACH,wBAkCC;IAED;;;;;OAKG;IACH,2BAKC;IAED;;;;;;;;OAQG;IACH,iFA6EC;IAED;;OAEG;IACH,4BAFW,MAAM,iBAShB;CACF;;;;cAlRY,OAAO,SAAS,CAAC;;;YAKhB,OAAO,KAAK,CAAC;;;;;;;uBAIL,KAAK,+BAAmB,EAAE;;eAVnC,OAAO,qBAAqB,EAAE,OAAO"}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export function validate(opts: Libp2pOptions): {
|
|
|
8
8
|
connectionManager: {
|
|
9
9
|
minConnections: number;
|
|
10
10
|
};
|
|
11
|
+
connectionGater: {};
|
|
11
12
|
transportManager: {
|
|
12
13
|
faultTolerance: number;
|
|
13
14
|
};
|
|
@@ -79,6 +80,7 @@ export function validate(opts: Libp2pOptions): {
|
|
|
79
80
|
};
|
|
80
81
|
} & Libp2pOptions & constructorOptions;
|
|
81
82
|
export type Multiaddr = import('multiaddr').Multiaddr;
|
|
83
|
+
export type ConnectionGater = import('./types').ConnectionGater;
|
|
82
84
|
export type Libp2pOptions = import('.').Libp2pOptions;
|
|
83
85
|
export type constructorOptions = import('.').constructorOptions;
|
|
84
86
|
//# 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.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.js"],"names":[],"mappings":"AA0G0B,+BAHf,aAAa,GACX;;;;;qCA/EmB,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+Ed,aAAa,GAAG,kBAAkB,CAS9D;wBAnGY,OAAO,WAAW,EAAE,SAAS;8BAC7B,OAAO,SAAS,EAAE,eAAe;4BACjC,OAAO,GAAG,EAAE,aAAa;iCACzB,OAAO,GAAG,EAAE,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-dialler.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/auto-dialler.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"auto-dialler.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/auto-dialler.js"],"names":[],"mappings":";AAqBA;;;GAGG;AAEH;;;;;GAKG;AAEH;IACE;;;;;;;;OAQG;IACH,oBAHW,MAAM,YACN,kBAAkB,EAU5B;IAPC,cAAqF;IACrF,4BAAqB;IACrB,kBAAqB;IACrB,sBAA4B;IAoC9B,2BA6CC;IA3ED;;OAEG;IACH,uBAWC;IAED;;OAEG;IACH,sBASC;CAgDF;;;;cA3GY,OAAO,UAAU,CAAC"}
|
|
@@ -97,9 +97,8 @@ declare class ConnectionManager extends EventEmitter {
|
|
|
97
97
|
* Tracks the incoming connection and check the connection limit
|
|
98
98
|
*
|
|
99
99
|
* @param {Connection} connection
|
|
100
|
-
* @returns {void}
|
|
101
100
|
*/
|
|
102
|
-
onConnect(connection: Connection): void
|
|
101
|
+
onConnect(connection: Connection): Promise<void>;
|
|
103
102
|
/**
|
|
104
103
|
* Removes the connection from tracking
|
|
105
104
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/index.js"],"names":[],"mappings":";AAsCA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH;IACE;;;;;;OAMG;IACH,oBAHW,MAAM,YACN,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/index.js"],"names":[],"mappings":";AAsCA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH;IACE;;;;;;OAMG;IACH,oBAHW,MAAM,YACN,wBAAwB,EAgDlC;IA3CC,uBAAqB;IACrB,gBAA0C;IAE1C,cAAqF;IAOrF;;;;OAIG;IACH,aAFU,IAAI,MAAM,EAAE,MAAM,CAAC,CAM3B;IAEF;;;;OAIG;IACH,aAFU,IAAI,MAAM,EAAE,UAAU,EAAE,CAAC,CAMjC;IAEF,kBAAqB;IACrB,YAAkB;IAuFpB;;;;;OAKG;IACH,sBAiBC;IA3GC,gCAGE;IAMJ;;OAEG;IACH,mBAGC;IAED;;;OAGG;IACH,cAYC;IAgKD;;;;;OAKG;IACH,0BAKC;IAzKD;;;;OAIG;IACH,sBASC;IAED;;;;OAIG;IACH,wBAWC;IAED;;;;;;;OAOG;IACH,qBAJW,MAAM,SACN,MAAM,GACJ,IAAI,CAOhB;IA2BD;;;;OAIG;IACH,sBAFW,UAAU,iBAsBpB;IAED;;;;;OAKG;IACH,yBAHW,UAAU,GACR,IAAI,CAgBhB;IAED;;;;;OAKG;IACH,YAHW,MAAM,GACJ,UAAU,GAAC,IAAI,CAQ3B;IAED;;;;;OAKG;IACH,eAHW,MAAM,GACJ,UAAU,EAAE,CAexB;IAeD;;;;;;OAMG;IACH,uBAOC;IAED;;;;;OAKG;IACH,4BAqBC;CACF;;;;;;;;cAjUY,OAAO,KAAK,CAAC"}
|
|
@@ -8,15 +8,15 @@ export type Multiaddr = import('multiaddr').Multiaddr;
|
|
|
8
8
|
* Store the multiaddrs from every peer in the passed peer store
|
|
9
9
|
*
|
|
10
10
|
* @param {AsyncIterable<{ id: PeerId, multiaddrs: Multiaddr[] }>} source
|
|
11
|
-
* @param {import('../peer-store')} peerStore
|
|
11
|
+
* @param {import('../peer-store/types').PeerStore} peerStore
|
|
12
12
|
*/
|
|
13
13
|
export function storeAddresses(source: AsyncIterable<{
|
|
14
14
|
id: PeerId;
|
|
15
15
|
multiaddrs: Multiaddr[];
|
|
16
|
-
}>, peerStore: import('../peer-store')):
|
|
16
|
+
}>, peerStore: import('../peer-store/types').PeerStore): AsyncGenerator<{
|
|
17
17
|
id: PeerId;
|
|
18
18
|
multiaddrs: Multiaddr[];
|
|
19
|
-
}>;
|
|
19
|
+
}, void, undefined>;
|
|
20
20
|
/**
|
|
21
21
|
* Filter peers by unique peer id
|
|
22
22
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/content-routing/utils.js"],"names":[],"mappings":"qBAQa,OAAO,SAAS,CAAC;wBACjB,OAAO,WAAW,EAAE,SAAS;AAF1C;;;GAGG;AAEH;;;;;GAKG;AACH,uCAHW,cAAc;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,SAAS,EAAE,CAAA;CAAE,CAAC,aACtD,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/content-routing/utils.js"],"names":[],"mappings":"qBAQa,OAAO,SAAS,CAAC;wBACjB,OAAO,WAAW,EAAE,SAAS;AAF1C;;;GAGG;AAEH;;;;;GAKG;AACH,uCAHW,cAAc;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,SAAS,EAAE,CAAA;CAAE,CAAC,aACtD,OAAO,qBAAqB,EAAE,SAAS;QADnB,MAAM;gBAAc,SAAS,EAAE;oBAU7D;AAED;;;;GAIG;AACH,oCAFW,cAAc;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,SAAS,EAAE,CAAA;CAAE,CAAC;QAAlC,MAAM;gBAAc,SAAS,EAAE;kBAgB7D;AAED;;;;;GAKG;AACH,qCAHW,cAAc;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,SAAS,EAAE,CAAA;CAAE,CAAC,QACtD,MAAM;QADc,MAAM;gBAAc,SAAS,EAAE;kBAe7D;AAED;;;;;;GAMG;AACH,yCAHW,cAAc;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,SAAS,EAAE,CAAA;CAAE,CAAC;QAAlC,MAAM;gBAAc,SAAS,EAAE;GAS7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dial-request.d.ts","sourceRoot":"","sources":["../../../src/dialer/dial-request.js"],"names":[],"mappings":";AAWA;;;;GAIG;AAEH;;;;;;;;GAQG;AAEH;IACE;;;;;;;;;OASG;IACH,2CAFW,kBAAkB,EAU5B;IAHC,uCAAkB;IAClB,qBAAoB;IACpB,gBAtBc,SAAS,WAAW,WAAW,KAAK,QAAQ,UAAU,CAAC,CAsBzC;IAG9B;;;;;OAKG;IACH;;oBAFa,QAAQ,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"dial-request.d.ts","sourceRoot":"","sources":["../../../src/dialer/dial-request.js"],"names":[],"mappings":";AAWA;;;;GAIG;AAEH;;;;;;;;GAQG;AAEH;IACE;;;;;;;;;OASG;IACH,2CAFW,kBAAkB,EAU5B;IAHC,uCAAkB;IAClB,qBAAoB;IACpB,gBAtBc,SAAS,WAAW,WAAW,KAAK,QAAQ,UAAU,CAAC,CAsBzC;IAG9B;;;;;OAKG;IACH;;oBAFa,QAAQ,UAAU,CAAC,CA+C/B;CACF;;;;;;WA9Ea,SAAS,EAAE;oBACP,SAAS,WAAW,WAAW,KAAK,QAAQ,UAAU,CAAC;YAC3D,MAAM;;cAXP,OAAO,IAAI,CAAC;iBACZ,OAAO,WAAW,EAAE,SAAS;;YAK5B,WAAW"}
|
|
@@ -2,14 +2,16 @@ export = Dialer;
|
|
|
2
2
|
/**
|
|
3
3
|
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
|
4
4
|
* @typedef {import('peer-id')} PeerId
|
|
5
|
-
* @typedef {import('../peer-store')} PeerStore
|
|
6
|
-
* @typedef {import('../peer-store/
|
|
5
|
+
* @typedef {import('../peer-store/types').PeerStore} PeerStore
|
|
6
|
+
* @typedef {import('../peer-store/types').Address} Address
|
|
7
7
|
* @typedef {import('../transport-manager')} TransportManager
|
|
8
|
+
* @typedef {import('../types').ConnectionGater} ConnectionGater
|
|
8
9
|
*/
|
|
9
10
|
/**
|
|
10
11
|
* @typedef {Object} DialerProperties
|
|
11
12
|
* @property {PeerStore} peerStore
|
|
12
13
|
* @property {TransportManager} transportManager
|
|
14
|
+
* @property {ConnectionGater} connectionGater
|
|
13
15
|
*
|
|
14
16
|
* @typedef {(addr:Multiaddr) => Promise<string[]>} Resolver
|
|
15
17
|
*
|
|
@@ -37,9 +39,10 @@ declare class Dialer {
|
|
|
37
39
|
* @class
|
|
38
40
|
* @param {DialerProperties & DialerOptions} options
|
|
39
41
|
*/
|
|
40
|
-
constructor({ transportManager, peerStore, addressSorter, maxParallelDials, maxAddrsToDial, dialTimeout, maxDialsPerPeer, resolvers, metrics }: DialerProperties & DialerOptions);
|
|
42
|
+
constructor({ transportManager, peerStore, connectionGater, addressSorter, maxParallelDials, maxAddrsToDial, dialTimeout, maxDialsPerPeer, resolvers, metrics }: DialerProperties & DialerOptions);
|
|
43
|
+
connectionGater: import("../types").ConnectionGater;
|
|
41
44
|
transportManager: import("../transport-manager");
|
|
42
|
-
peerStore: import("../peer-store");
|
|
45
|
+
peerStore: import("../peer-store/types").PeerStore;
|
|
43
46
|
addressSorter: (addresses: Address[]) => Address[];
|
|
44
47
|
maxParallelDials: number;
|
|
45
48
|
maxAddrsToDial: number;
|
|
@@ -124,7 +127,7 @@ declare class Dialer {
|
|
|
124
127
|
_resolveRecord(ma: Multiaddr): Promise<Multiaddr[]>;
|
|
125
128
|
}
|
|
126
129
|
declare namespace Dialer {
|
|
127
|
-
export { Connection, PeerId, PeerStore, Address, TransportManager, DialerProperties, Resolver, DialerOptions, DialTarget, PendingDial };
|
|
130
|
+
export { Connection, PeerId, PeerStore, Address, TransportManager, ConnectionGater, DialerProperties, Resolver, DialerOptions, DialTarget, PendingDial };
|
|
128
131
|
}
|
|
129
132
|
type PendingDial = {
|
|
130
133
|
dialRequest: import('./dial-request');
|
|
@@ -142,6 +145,7 @@ type DialTarget = {
|
|
|
142
145
|
type DialerProperties = {
|
|
143
146
|
peerStore: PeerStore;
|
|
144
147
|
transportManager: TransportManager;
|
|
148
|
+
connectionGater: ConnectionGater;
|
|
145
149
|
};
|
|
146
150
|
type DialerOptions = {
|
|
147
151
|
/**
|
|
@@ -170,8 +174,9 @@ type DialerOptions = {
|
|
|
170
174
|
resolvers?: Record<string, Resolver> | undefined;
|
|
171
175
|
metrics?: import("../metrics") | undefined;
|
|
172
176
|
};
|
|
173
|
-
type PeerStore = import('../peer-store');
|
|
174
|
-
type Address = import('../peer-store/
|
|
177
|
+
type PeerStore = import('../peer-store/types').PeerStore;
|
|
178
|
+
type Address = import('../peer-store/types').Address;
|
|
175
179
|
type TransportManager = import('../transport-manager');
|
|
180
|
+
type ConnectionGater = import('../types').ConnectionGater;
|
|
176
181
|
type Resolver = (addr: Multiaddr) => Promise<string[]>;
|
|
177
182
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dialer/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dialer/index.js"],"names":[],"mappings":";AAgCA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;IACE;;;OAGG;IACH,iKAFW,gBAAgB,GAAG,aAAa,EAyC1C;IA3BC,oDAAsC;IACtC,iDAAwC;IACxC,mDAA0B;IAC1B,2BAvCsB,OAAO,EAAE,KAAK,OAAO,EAAE,CAuCX;IAClC,yBAAwC;IACxC,uBAAoC;IACpC,gBAA0B;IAC1B,wBAAsC;IACtC,iBAAuE;IAEvE,uCAAuC;IACvC,eADW,IAAI,MAAM,EAAE,WAAW,CAAC,CAKjC;IAEF,0FAA0F;IAC1F;yBAD0C,GAAG,KAAK,IAAI;sBAAgB,KAAK,KAAK,IAAI;OAKlF;IAOJ;;OAEG;IACH,gBAcC;IAED;;;;;;;;;OASG;IACH,oBALW,MAAM,GAAC,SAAS,GAAC,MAAM;;oBAGrB,QAAQ,UAAU,CAAC,CA8B/B;IAED;;;;;;;OAOG;IACH,mCAHW,MAAM,GAAC,SAAS,GAAC,MAAM,GACrB,QAAQ,UAAU,CAAC,CAmB/B;IAED;;;;;;;;;OASG;IACH,0BAyCC;IAED;;;;;;;;OAQG;IACH,2BA0CC;IAED;;OAEG;IACH,eAFW,MAAM,YAOhB;IAED;;OAEG;IACH,oBAFW,MAAM,QAOhB;IAED;;;;;OAKG;IACH,aAHW,SAAS,GACP,QAAQ,SAAS,EAAE,CAAC,CAwBhC;IAED;;;;;OAKG;IACH,mBAHW,SAAS,GACP,QAAQ,SAAS,EAAE,CAAC,CAWhC;CACF;;;;;iBAtTa,OAAO,gBAAgB,CAAC;gBACxB,OAAO,0BAA0B,EAAE,iBAAiB;aACpD,QAAQ,UAAU,CAAC;mBACR,IAAI;;cAhChB,OAAO,SAAS,CAAC;;;;QAyBhB,MAAM;WACN,SAAS,EAAE;;;eAjBX,SAAS;sBACT,gBAAgB;qBAChB,eAAe;;;;;;iCAKH,OAAO,EAAE,KAAK,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;iBAfpC,OAAO,qBAAqB,EAAE,SAAS;eACvC,OAAO,qBAAqB,EAAE,OAAO;wBACrC,OAAO,sBAAsB,CAAC;uBAC9B,OAAO,UAAU,EAAE,eAAe;uBAS5B,SAAS,KAAK,QAAQ,MAAM,EAAE,CAAC"}
|
package/dist/src/errors.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export namespace codes {
|
|
|
11
11
|
export const DHT_NOT_STARTED: string;
|
|
12
12
|
const CONN_ENCRYPTION_REQUIRED_1: string;
|
|
13
13
|
export { CONN_ENCRYPTION_REQUIRED_1 as CONN_ENCRYPTION_REQUIRED };
|
|
14
|
+
export const ERR_PEER_DIAL_INTERCEPTED: string;
|
|
15
|
+
export const ERR_CONNECTION_INTERCEPTED: string;
|
|
14
16
|
export const ERR_INVALID_PROTOCOLS_FOR_STREAM: string;
|
|
15
17
|
export const ERR_CONNECTION_ENDED: string;
|
|
16
18
|
export const ERR_CONNECTION_FAILED: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/fetch/constants.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export = FetchProtocol;
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {import('../')} Libp2p
|
|
4
|
+
* @typedef {import('multiaddr').Multiaddr} Multiaddr
|
|
5
|
+
* @typedef {import('peer-id')} PeerId
|
|
6
|
+
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxedStream} MuxedStream
|
|
7
|
+
* @typedef {(key: string) => Promise<Uint8Array | null>} LookupFunction
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* A simple libp2p protocol for requesting a value corresponding to a key from a peer.
|
|
11
|
+
* Developers can register one or more lookup function for retrieving the value corresponding to
|
|
12
|
+
* a given key. Each lookup function must act on a distinct part of the overall key space, defined
|
|
13
|
+
* by a fixed prefix that all keys that should be routed to that lookup function will start with.
|
|
14
|
+
*/
|
|
15
|
+
declare class FetchProtocol {
|
|
16
|
+
/**
|
|
17
|
+
* @param {Libp2p} libp2p
|
|
18
|
+
*/
|
|
19
|
+
constructor(libp2p: Libp2p);
|
|
20
|
+
_lookupFunctions: Map<any, any>;
|
|
21
|
+
_libp2p: import("../");
|
|
22
|
+
/**
|
|
23
|
+
* Invoked when a fetch request is received. Reads the request message off the given stream and
|
|
24
|
+
* responds based on looking up the key in the request via the lookup callback that corresponds
|
|
25
|
+
* to the key's prefix.
|
|
26
|
+
*
|
|
27
|
+
* @param {object} options
|
|
28
|
+
* @param {MuxedStream} options.stream
|
|
29
|
+
* @param {string} options.protocol
|
|
30
|
+
*/
|
|
31
|
+
handleMessage(options: {
|
|
32
|
+
stream: MuxedStream;
|
|
33
|
+
protocol: string;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Sends a request to fetch the value associated with the given key from the given peer.
|
|
37
|
+
*
|
|
38
|
+
* @param {PeerId|Multiaddr} peer
|
|
39
|
+
* @param {string} key
|
|
40
|
+
* @returns {Promise<Uint8Array | null>}
|
|
41
|
+
*/
|
|
42
|
+
fetch(peer: PeerId | Multiaddr, key: string): Promise<Uint8Array | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Given a key, finds the appropriate function for looking up its corresponding value, based on
|
|
45
|
+
* the key's prefix.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} key
|
|
48
|
+
*/
|
|
49
|
+
_getLookupFunction(key: string): any;
|
|
50
|
+
/**
|
|
51
|
+
* Registers a new lookup callback that can map keys to values, for a given set of keys that
|
|
52
|
+
* share the same prefix.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} prefix
|
|
55
|
+
* @param {LookupFunction} lookup
|
|
56
|
+
*/
|
|
57
|
+
registerLookupFunction(prefix: string, lookup: LookupFunction): void;
|
|
58
|
+
/**
|
|
59
|
+
* Registers a new lookup callback that can map keys to values, for a given set of keys that
|
|
60
|
+
* share the same prefix.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} prefix
|
|
63
|
+
* @param {LookupFunction} [lookup]
|
|
64
|
+
*/
|
|
65
|
+
unregisterLookupFunction(prefix: string, lookup?: LookupFunction | undefined): void;
|
|
66
|
+
}
|
|
67
|
+
declare namespace FetchProtocol {
|
|
68
|
+
export { PROTOCOL, Libp2p, Multiaddr, PeerId, MuxedStream, LookupFunction };
|
|
69
|
+
}
|
|
70
|
+
type MuxedStream = import('libp2p-interfaces/src/stream-muxer/types').MuxedStream;
|
|
71
|
+
type PeerId = import('peer-id');
|
|
72
|
+
type Multiaddr = import('multiaddr').Multiaddr;
|
|
73
|
+
type LookupFunction = (key: string) => Promise<Uint8Array | null>;
|
|
74
|
+
type Libp2p = import('../');
|
|
75
|
+
import { PROTOCOL } from "./constants";
|
|
76
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fetch/index.js"],"names":[],"mappings":";AAcA;;;;;;GAMG;AAEH;;;;;GAKG;AACH;IACE;;OAEG;IACH,oBAFW,MAAM,EAMhB;IAHC,gCAAiC;IACjC,uBAAqB;IA0CvB;;;;;;;;OAQG;IACH;QAHgC,MAAM,EAA3B,WAAW;QACK,QAAQ,EAAxB,MAAM;sBAsBhB;IAnED;;;;;;OAMG;IACH,YAJW,MAAM,GAAC,SAAS,OAChB,MAAM,GACJ,QAAQ,UAAU,GAAG,IAAI,CAAC,CA+BtC;IAiCD;;;;;OAKG;IACH,wBAFW,MAAM,OAShB;IAED;;;;;;OAMG;IACH,+BAHW,MAAM,gCAQhB;IAED;;;;;;OAMG;IACH,iCAHW,MAAM,6CAahB;CACF;;;;mBAxIY,OAAO,0CAA0C,EAAE,WAAW;cAD9D,OAAO,SAAS,CAAC;iBADjB,OAAO,WAAW,EAAE,SAAS;4BAGvB,MAAM,KAAK,QAAQ,UAAU,GAAG,IAAI,CAAC;cAJ3C,OAAO,KAAK,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as $protobuf from "protobufjs";
|
|
2
|
+
/** Properties of a FetchRequest. */
|
|
3
|
+
export interface IFetchRequest {
|
|
4
|
+
|
|
5
|
+
/** FetchRequest identifier */
|
|
6
|
+
identifier?: (string|null);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Represents a FetchRequest. */
|
|
10
|
+
export class FetchRequest implements IFetchRequest {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Constructs a new FetchRequest.
|
|
14
|
+
* @param [p] Properties to set
|
|
15
|
+
*/
|
|
16
|
+
constructor(p?: IFetchRequest);
|
|
17
|
+
|
|
18
|
+
/** FetchRequest identifier. */
|
|
19
|
+
public identifier: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Encodes the specified FetchRequest message. Does not implicitly {@link FetchRequest.verify|verify} messages.
|
|
23
|
+
* @param m FetchRequest message or plain object to encode
|
|
24
|
+
* @param [w] Writer to encode to
|
|
25
|
+
* @returns Writer
|
|
26
|
+
*/
|
|
27
|
+
public static encode(m: IFetchRequest, w?: $protobuf.Writer): $protobuf.Writer;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Decodes a FetchRequest message from the specified reader or buffer.
|
|
31
|
+
* @param r Reader or buffer to decode from
|
|
32
|
+
* @param [l] Message length if known beforehand
|
|
33
|
+
* @returns FetchRequest
|
|
34
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
35
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
36
|
+
*/
|
|
37
|
+
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): FetchRequest;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates a FetchRequest message from a plain object. Also converts values to their respective internal types.
|
|
41
|
+
* @param d Plain object
|
|
42
|
+
* @returns FetchRequest
|
|
43
|
+
*/
|
|
44
|
+
public static fromObject(d: { [k: string]: any }): FetchRequest;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Creates a plain object from a FetchRequest message. Also converts values to other types if specified.
|
|
48
|
+
* @param m FetchRequest
|
|
49
|
+
* @param [o] Conversion options
|
|
50
|
+
* @returns Plain object
|
|
51
|
+
*/
|
|
52
|
+
public static toObject(m: FetchRequest, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Converts this FetchRequest to JSON.
|
|
56
|
+
* @returns JSON object
|
|
57
|
+
*/
|
|
58
|
+
public toJSON(): { [k: string]: any };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Properties of a FetchResponse. */
|
|
62
|
+
export interface IFetchResponse {
|
|
63
|
+
|
|
64
|
+
/** FetchResponse status */
|
|
65
|
+
status?: (FetchResponse.StatusCode|null);
|
|
66
|
+
|
|
67
|
+
/** FetchResponse data */
|
|
68
|
+
data?: (Uint8Array|null);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Represents a FetchResponse. */
|
|
72
|
+
export class FetchResponse implements IFetchResponse {
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Constructs a new FetchResponse.
|
|
76
|
+
* @param [p] Properties to set
|
|
77
|
+
*/
|
|
78
|
+
constructor(p?: IFetchResponse);
|
|
79
|
+
|
|
80
|
+
/** FetchResponse status. */
|
|
81
|
+
public status: FetchResponse.StatusCode;
|
|
82
|
+
|
|
83
|
+
/** FetchResponse data. */
|
|
84
|
+
public data: Uint8Array;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Encodes the specified FetchResponse message. Does not implicitly {@link FetchResponse.verify|verify} messages.
|
|
88
|
+
* @param m FetchResponse message or plain object to encode
|
|
89
|
+
* @param [w] Writer to encode to
|
|
90
|
+
* @returns Writer
|
|
91
|
+
*/
|
|
92
|
+
public static encode(m: IFetchResponse, w?: $protobuf.Writer): $protobuf.Writer;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Decodes a FetchResponse message from the specified reader or buffer.
|
|
96
|
+
* @param r Reader or buffer to decode from
|
|
97
|
+
* @param [l] Message length if known beforehand
|
|
98
|
+
* @returns FetchResponse
|
|
99
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
100
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
101
|
+
*/
|
|
102
|
+
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): FetchResponse;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Creates a FetchResponse message from a plain object. Also converts values to their respective internal types.
|
|
106
|
+
* @param d Plain object
|
|
107
|
+
* @returns FetchResponse
|
|
108
|
+
*/
|
|
109
|
+
public static fromObject(d: { [k: string]: any }): FetchResponse;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Creates a plain object from a FetchResponse message. Also converts values to other types if specified.
|
|
113
|
+
* @param m FetchResponse
|
|
114
|
+
* @param [o] Conversion options
|
|
115
|
+
* @returns Plain object
|
|
116
|
+
*/
|
|
117
|
+
public static toObject(m: FetchResponse, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Converts this FetchResponse to JSON.
|
|
121
|
+
* @returns JSON object
|
|
122
|
+
*/
|
|
123
|
+
public toJSON(): { [k: string]: any };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export namespace FetchResponse {
|
|
127
|
+
|
|
128
|
+
/** StatusCode enum. */
|
|
129
|
+
enum StatusCode {
|
|
130
|
+
OK = 0,
|
|
131
|
+
NOT_FOUND = 1,
|
|
132
|
+
ERROR = 2
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -31,7 +31,7 @@ declare class IdentifyService {
|
|
|
31
31
|
libp2p: import('../');
|
|
32
32
|
});
|
|
33
33
|
_libp2p: import("../");
|
|
34
|
-
peerStore: import("../peer-store");
|
|
34
|
+
peerStore: import("../peer-store/types").PeerStore;
|
|
35
35
|
addressManager: import("../address-manager");
|
|
36
36
|
connectionManager: import("../connection-manager");
|
|
37
37
|
peerId: PeerId;
|
|
@@ -55,6 +55,8 @@ declare class IdentifyService {
|
|
|
55
55
|
agentVersion: string;
|
|
56
56
|
protocolVersion: string;
|
|
57
57
|
};
|
|
58
|
+
start(): Promise<void>;
|
|
59
|
+
stop(): Promise<void>;
|
|
58
60
|
/**
|
|
59
61
|
* Send an Identify Push update to the list of connections
|
|
60
62
|
*
|
|
@@ -64,10 +66,8 @@ declare class IdentifyService {
|
|
|
64
66
|
push(connections: Connection[]): Promise<void[]>;
|
|
65
67
|
/**
|
|
66
68
|
* Calls `push` for all peers in the `peerStore` that are connected
|
|
67
|
-
*
|
|
68
|
-
* @returns {void}
|
|
69
69
|
*/
|
|
70
|
-
pushToPeerStore(): void
|
|
70
|
+
pushToPeerStore(): Promise<void>;
|
|
71
71
|
/**
|
|
72
72
|
* Requests the `Identify` message from peer associated with the given `connection`.
|
|
73
73
|
* If the identified peer does not match the `PeerId` associated with the connection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/identify/index.js"],"names":[],"mappings":";AAkCA;;;GAGG;AAEH;;;GAGG;AAEH;IACE;;OAEG;IACH,8BAFW,OAAO,KAAK,CAAC;;;MAOvB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/identify/index.js"],"names":[],"mappings":";AAkCA;;;GAGG;AAEH;;;GAGG;AAEH;IACE;;OAEG;IACH,8BAFW,OAAO,KAAK,CAAC;;;MAOvB;IA2SD;;;;;OAKG;IACH,+BAHW,UAAU,GAAG,MAAM,GACjB,SAAS,GAAC,IAAI,CAW1B;IAxTD;;;;OAIG;IACH;QAFkC,MAAM,EAA7B,OAAO,KAAK,CAAC;OAuCvB;IApCC,uBAAqB;IACrB,mDAAiC;IACjC,6CAA2C;IAC3C,mDAAiD;IACjD,eAA2B;IA6K7B;;;;;;;;OAQG;IACH;oBALW,UAAU;gBACV,WAAW;kBACX,MAAM;QACJ,QAAQ,IAAI,CAAC,GAAC,SAAS,CAWnC;IA1LC,4BAA0D;IAC1D,gCAAkE;IAGlE;sBAjCU,MAAM;;MAoCf;IAsBH,uBAGC;IAED,sBAEC;IAED;;;;;OAKG;IACH,kBAHW,UAAU,EAAE,GACV,QAAQ,IAAI,EAAE,CAAC,CA4B3B;IAED;;OAEG;IACH,iCAeC;IAED;;;;;;;;OAQG;IACH,qBAHW,UAAU,GACR,QAAQ,IAAI,CAAC,CAmEzB;IAsBD;;;;;;;;;OASG;IACH,wBA6BC;IAED;;;;;;;;OAQG;IACH,oBA0CC;CAkBF;;;;;;;;;;;;mBA5UY,OAAO,0CAA0C,EAAE,WAAW;;kBAK7D,MAAM"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export = Libp2p;
|
|
|
12
12
|
* @typedef {import('libp2p-interfaces/src/pubsub').PubsubOptions} PubsubOptions
|
|
13
13
|
* @typedef {import('interface-datastore').Datastore} Datastore
|
|
14
14
|
* @typedef {import('./pnet')} Protector
|
|
15
|
+
* @typedef {import('./types').ConnectionGater} ConnectionGater
|
|
15
16
|
* @typedef {Object} PersistentPeerStoreOptions
|
|
16
17
|
* @property {number} [threshold]
|
|
17
18
|
*/
|
|
@@ -69,13 +70,14 @@ export = Libp2p;
|
|
|
69
70
|
* @property {Libp2pModules} modules libp2p modules to use
|
|
70
71
|
* @property {import('./address-manager').AddressManagerOptions} [addresses]
|
|
71
72
|
* @property {import('./connection-manager').ConnectionManagerOptions} [connectionManager]
|
|
73
|
+
* @property {Partial<import('./types').ConnectionGater>} [connectionGater]
|
|
72
74
|
* @property {Datastore} [datastore]
|
|
73
75
|
* @property {import('./dialer').DialerOptions} [dialer]
|
|
74
76
|
* @property {import('./identify/index').HostProperties} [host] libp2p host
|
|
75
77
|
* @property {KeychainOptions & import('./keychain/index').KeychainOptions} [keychain]
|
|
76
78
|
* @property {MetricsOptions & import('./metrics').MetricsOptions} [metrics]
|
|
77
79
|
* @property {import('./peer-routing').PeerRoutingOptions} [peerRouting]
|
|
78
|
-
* @property {PeerStoreOptions
|
|
80
|
+
* @property {PeerStoreOptions} [peerStore]
|
|
79
81
|
* @property {import('./transport-manager').TransportManagerOptions} [transportManager]
|
|
80
82
|
* @property {Libp2pConfig} [config]
|
|
81
83
|
*
|
|
@@ -115,6 +117,7 @@ declare class Libp2p extends EventEmitter {
|
|
|
115
117
|
connectionManager: {
|
|
116
118
|
minConnections: number;
|
|
117
119
|
};
|
|
120
|
+
connectionGater: {};
|
|
118
121
|
transportManager: {
|
|
119
122
|
faultTolerance: number;
|
|
120
123
|
};
|
|
@@ -189,7 +192,10 @@ declare class Libp2p extends EventEmitter {
|
|
|
189
192
|
peerId: PeerId;
|
|
190
193
|
datastore: import("interface-datastore").Datastore | undefined;
|
|
191
194
|
metrics: Metrics | undefined;
|
|
192
|
-
|
|
195
|
+
/** @type {ConnectionGater} */
|
|
196
|
+
connectionGater: ConnectionGater;
|
|
197
|
+
/** @type {import('./peer-store/types').PeerStore} */
|
|
198
|
+
peerStore: import('./peer-store/types').PeerStore;
|
|
193
199
|
addresses: {
|
|
194
200
|
listen: never[];
|
|
195
201
|
announce: never[];
|
|
@@ -253,7 +259,7 @@ declare class Libp2p extends EventEmitter {
|
|
|
253
259
|
* @param {string[]|string} protocols
|
|
254
260
|
* @param {(props: HandlerProps) => void} handler
|
|
255
261
|
*/
|
|
256
|
-
handle(protocols: string[] | string, handler: (props: HandlerProps) => void): void
|
|
262
|
+
handle(protocols: string[] | string, handler: (props: HandlerProps) => void): Promise<void>;
|
|
257
263
|
dialer: Dialer;
|
|
258
264
|
relay: Relay | undefined;
|
|
259
265
|
identifyService: IdentifyService | undefined;
|
|
@@ -270,6 +276,8 @@ declare class Libp2p extends EventEmitter {
|
|
|
270
276
|
* @param {{ id: PeerId, multiaddrs: Multiaddr[], protocols: string[] }} peer
|
|
271
277
|
*/
|
|
272
278
|
private _onDiscoveryPeer;
|
|
279
|
+
fetchService: FetchService;
|
|
280
|
+
pingService: PingService;
|
|
273
281
|
/**
|
|
274
282
|
* Starts the libp2p node and all its subsystems
|
|
275
283
|
*
|
|
@@ -354,6 +362,14 @@ declare class Libp2p extends EventEmitter {
|
|
|
354
362
|
* @returns {Promise<void>}
|
|
355
363
|
*/
|
|
356
364
|
hangUp(peer: PeerId | Multiaddr | string): Promise<void>;
|
|
365
|
+
/**
|
|
366
|
+
* Sends a request to fetch the value associated with the given key from the given peer.
|
|
367
|
+
*
|
|
368
|
+
* @param {PeerId|Multiaddr} peer
|
|
369
|
+
* @param {string} key
|
|
370
|
+
* @returns {Promise<Uint8Array | null>}
|
|
371
|
+
*/
|
|
372
|
+
fetch(peer: PeerId | Multiaddr, key: string): Promise<Uint8Array | null>;
|
|
357
373
|
/**
|
|
358
374
|
* Pings the given peer in order to obtain the operation latency.
|
|
359
375
|
*
|
|
@@ -367,7 +383,7 @@ declare class Libp2p extends EventEmitter {
|
|
|
367
383
|
*
|
|
368
384
|
* @param {string[]|string} protocols
|
|
369
385
|
*/
|
|
370
|
-
unhandle(protocols: string[] | string): void
|
|
386
|
+
unhandle(protocols: string[] | string): Promise<void>;
|
|
371
387
|
_onStarting(): Promise<void>;
|
|
372
388
|
/**
|
|
373
389
|
* Called when libp2p has started and before it returns
|
|
@@ -393,7 +409,7 @@ declare class Libp2p extends EventEmitter {
|
|
|
393
409
|
private _setupPeerDiscovery;
|
|
394
410
|
}
|
|
395
411
|
declare namespace Libp2p {
|
|
396
|
-
export { Connection, MuxedStream, TransportFactory, MuxerFactory, ContentRoutingModule, PeerDiscoveryFactory, PeerRoutingModule, Crypto, Pubsub, PubsubOptions, Datastore, Protector, PersistentPeerStoreOptions, HandlerProps, DhtOptions, KeychainOptions, PeerStoreOptions, PubsubLocalOptions, MetricsOptions, RelayOptions, Libp2pConfig, Libp2pModules, Libp2pOptions, constructorOptions, CreateOptions };
|
|
412
|
+
export { Connection, MuxedStream, TransportFactory, MuxerFactory, ContentRoutingModule, PeerDiscoveryFactory, PeerRoutingModule, Crypto, Pubsub, PubsubOptions, Datastore, Protector, ConnectionGater, PersistentPeerStoreOptions, HandlerProps, DhtOptions, KeychainOptions, PeerStoreOptions, PubsubLocalOptions, MetricsOptions, RelayOptions, Libp2pConfig, Libp2pModules, Libp2pOptions, constructorOptions, CreateOptions };
|
|
397
413
|
}
|
|
398
414
|
import { EventEmitter } from "events";
|
|
399
415
|
type Libp2pOptions = {
|
|
@@ -403,6 +419,7 @@ type Libp2pOptions = {
|
|
|
403
419
|
modules: Libp2pModules;
|
|
404
420
|
addresses?: AddressManager.AddressManagerOptions | undefined;
|
|
405
421
|
connectionManager?: ConnectionManager.ConnectionManagerOptions | undefined;
|
|
422
|
+
connectionGater?: Partial<import("./types").ConnectionGater> | undefined;
|
|
406
423
|
datastore?: import("interface-datastore").Datastore | undefined;
|
|
407
424
|
dialer?: Dialer.DialerOptions | undefined;
|
|
408
425
|
/**
|
|
@@ -412,7 +429,7 @@ type Libp2pOptions = {
|
|
|
412
429
|
keychain?: (KeychainOptions & Keychain.KeychainOptions) | undefined;
|
|
413
430
|
metrics?: (MetricsOptions & Metrics.MetricsOptions) | undefined;
|
|
414
431
|
peerRouting?: PeerRouting.PeerRoutingOptions | undefined;
|
|
415
|
-
peerStore?:
|
|
432
|
+
peerStore?: PeerStoreOptions | undefined;
|
|
416
433
|
transportManager?: TransportManager.TransportManagerOptions | undefined;
|
|
417
434
|
config?: Libp2pConfig | undefined;
|
|
418
435
|
};
|
|
@@ -421,7 +438,7 @@ type constructorOptions = {
|
|
|
421
438
|
};
|
|
422
439
|
import PeerId = require("peer-id");
|
|
423
440
|
import Metrics = require("./metrics");
|
|
424
|
-
|
|
441
|
+
type ConnectionGater = import('./types').ConnectionGater;
|
|
425
442
|
import AddressManager = require("./address-manager");
|
|
426
443
|
type Libp2pModules = {
|
|
427
444
|
transport: import("libp2p-interfaces/src/transport/types").TransportFactory<any, any>[];
|
|
@@ -468,6 +485,8 @@ import Relay = require("./circuit");
|
|
|
468
485
|
import IdentifyService = require("./identify");
|
|
469
486
|
import PeerRouting = require("./peer-routing");
|
|
470
487
|
import ContentRouting = require("./content-routing");
|
|
488
|
+
import FetchService = require("./fetch");
|
|
489
|
+
import PingService = require("./ping");
|
|
471
490
|
import { Multiaddr } from "multiaddr";
|
|
472
491
|
type Connection = import("libp2p-interfaces/src/connection/connection");
|
|
473
492
|
type CreateOptions = {
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":";AAqCA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":";AAqCA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AACH;IACE;;;;;;OAMG;IACH,uBAHW,aAAa,GAAG,aAAa,GAC3B,QAAQ,MAAM,CAAC,CAa3B;IAED;;;;;OAKG;IACH,sBAFW,aAAa,GAAG,kBAAkB,EA8L5C;IAxLC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAAwC;IAExC,qBAAqB;IACrB,QADW,MAAM,CACiB;IAClC,+DAAwC;IAQtC,6BAAsB;IAGxB,8BAA8B;IAC9B,iBADW,eAAe,CAYzB;IAED,qDAAqD;IACrD,WADW,OAAO,oBAAoB,EAAE,SAAS,CAK/C;IAGF;;;;;6CAAwC;IACxC,+BAA8E;IAS9E,wBAAqC;IACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAAmC;IACnC,kBAAoB;IACpB,0BAA2B;IAG3B,qCAEE;IACF,0BAIE;IAQA,+BAGE;IAMJ,mBAME;IAGF,mCAIE;IAGF,uBAME;IAGF,qBAGE;IAiWJ;;;;;OAKG;IACH,kBAHW,MAAM,EAAE,GAAC,MAAM,mBACP,YAAY,KAAK,IAAI,iBAUvC;IAjWC,eAME;IAWA,yBAA4B;IAW5B,6CAA4D;IAc5D,UAGE;IAOF,qBAAqB;IACrB,+CAA8D;IAKhE,yBAAwC;IACxC,+BAA8C;IAsXhD;;;;;;OAMG;IACH,yBAQC;IAjYC,2BAA0C;IAC1C,yBAAwC;IAsB1C;;;;OAIG;IACH,SAFa,QAAQ,IAAI,CAAC,CA2BzB;IAED;;;;;OAKG;IACH,QAFa,QAAQ,IAAI,CAAC,CA8CzB;IAxCG,gCAAuB;IA0C3B;;;;;;OAMG;IACH,gBAFa,QAAQ,IAAI,CAAC,CAYzB;IAED,iCAEC;IAED;;;;;OAKG;IACH,wFAEC;IAED;;;;;;;;OAQG;IACH,WALW,MAAM,GAAC,SAAS,GAAC,MAAM;;oBAGrB,QAAQ,UAAU,CAAC,CAI/B;IAED;;;;;;;;;;OAUG;IACH,mBALW,MAAM,GAAC,SAAS,GAAC,MAAM,aACvB,MAAM,EAAE,GAAC,MAAM;;;;;OAWzB;IAED;;;;;OAKG;IACH,YAJW,MAAM,GAAC,SAAS,GAAC,MAAM,iCAErB,QAAQ,UAAU,CAAC,CAkB/B;IAED;;;;;;;;;OASG;IACH,8BAiBC;IAED;;;;;OAKG;IACH,aAHW,MAAM,GAAC,SAAS,GAAC,MAAM,GACrB,QAAQ,IAAI,CAAC,CAgBzB;IAED;;;;;;OAMG;IACH,YAJW,MAAM,GAAC,SAAS,OAChB,MAAM,GACJ,QAAQ,UAAU,GAAG,IAAI,CAAC,CAItC;IAED;;;;;OAKG;IACH,WAHW,MAAM,GAAC,SAAS,GAAC,MAAM,GACrB,QAAQ,MAAM,CAAC,CAW3B;IAkBD;;;;;OAKG;IACH,oBAFW,MAAM,EAAE,GAAC,MAAM,iBAUzB;IAED,6BA2BC;IAED;;;;OAIG;IACH,oBA0BC;IAmBD;;;;;;;OAOG;IACH,sBAaC;IAED;;;;;OAKG;IACH,4BAkDC;CACF;;;;;;;;;aAhsBa,aAAa;;;;;;;;;;;;;;;;;;YAeb,MAAM;;;;uBAvEP,OAAO,SAAS,EAAE,eAAe;;;eA6ChC,4EAAkB;iBAClB,YAAY,EAAE;oBACd,MAAM,EAAE;;;;;4BAKM,GAAG,EAAE,KAAG,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA7C5B,UAAU;YACV,WAAW;cACX,MAAM;;;;;;;;;;;;;;mBApBP,OAAO,0CAA0C,EAAE,WAAW;wBAC9D,OAAO,uCAAuC,EAAE,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC;oBAC1E,OAAO,0CAA0C,EAAE,YAAY;4BAC/D,OAAO,6CAA6C,EAAE,cAAc;4BACpE,OAAO,4CAA4C,EAAE,oBAAoB;yBACzE,OAAO,0CAA0C,EAAE,WAAW;cAC9D,OAAO,oCAAoC,EAAE,MAAM;cACnD,OAAO,8BAA8B,CAAC;qBACtC,OAAO,8BAA8B,EAAE,aAAa;iBACpD,OAAO,qBAAqB,EAAE,SAAS;iBACvC,OAAO,QAAQ,CAAC;;;;;;;;;;;;;;;iBAuBf,OAAO;;;aAGP,OAAO;;;aAGP,OAAO"}
|