libp2p 0.35.9-rc.2 → 0.36.0
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.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.map +1 -1
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/dialer/index.d.ts +7 -2
- 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.map +1 -1
- package/dist/src/index.d.ts +110 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/peer-store/address-book.d.ts +3 -1
- package/dist/src/peer-store/address-book.d.ts.map +1 -1
- package/dist/src/peer-store/index.d.ts +5 -2
- package/dist/src/peer-store/index.d.ts.map +1 -1
- package/dist/src/peer-store/store.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 +14 -14
- package/src/circuit/auto-relay.js +36 -22
- package/src/config.js +2 -0
- package/src/connection-manager/auto-dialler.js +15 -6
- package/src/connection-manager/index.js +3 -0
- package/src/dialer/index.js +20 -1
- 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 +21 -17
- package/src/index.js +40 -1
- package/src/peer-store/address-book.js +41 -28
- package/src/peer-store/index.js +4 -2
- package/src/peer-store/store.js +19 -6
- package/src/types.ts +98 -0
- package/src/upgrader.js +29 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-relay.d.ts","sourceRoot":"","sources":["../../../src/circuit/auto-relay.js"],"names":[],"mappings":";
|
|
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"}
|
|
@@ -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"}
|
|
@@ -5,11 +5,13 @@ export = Dialer;
|
|
|
5
5
|
* @typedef {import('../peer-store/types').PeerStore} PeerStore
|
|
6
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,7 +39,8 @@ 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
45
|
peerStore: import("../peer-store/types").PeerStore;
|
|
43
46
|
addressSorter: (addresses: Address[]) => Address[];
|
|
@@ -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
|
/**
|
|
@@ -173,5 +177,6 @@ type DialerOptions = {
|
|
|
173
177
|
type PeerStore = import('../peer-store/types').PeerStore;
|
|
174
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
|
+
}
|
|
@@ -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,6 +70,7 @@ 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
|
|
@@ -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
|
};
|
|
@@ -134,6 +137,98 @@ declare class Libp2p extends EventEmitter {
|
|
|
134
137
|
enabled: boolean;
|
|
135
138
|
};
|
|
136
139
|
peerStore: {
|
|
140
|
+
/**
|
|
141
|
+
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
|
142
|
+
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxedStream} MuxedStream
|
|
143
|
+
* @typedef {import('libp2p-interfaces/src/transport/types').TransportFactory<any, any>} TransportFactory
|
|
144
|
+
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxerFactory} MuxerFactory
|
|
145
|
+
* @typedef {import('libp2p-interfaces/src/content-routing/types').ContentRouting} ContentRoutingModule
|
|
146
|
+
* @typedef {import('libp2p-interfaces/src/peer-discovery/types').PeerDiscoveryFactory} PeerDiscoveryFactory
|
|
147
|
+
* @typedef {import('libp2p-interfaces/src/peer-routing/types').PeerRouting} PeerRoutingModule
|
|
148
|
+
* @typedef {import('libp2p-interfaces/src/crypto/types').Crypto} Crypto
|
|
149
|
+
* @typedef {import('libp2p-interfaces/src/pubsub')} Pubsub
|
|
150
|
+
* @typedef {import('libp2p-interfaces/src/pubsub').PubsubOptions} PubsubOptions
|
|
151
|
+
* @typedef {import('interface-datastore').Datastore} Datastore
|
|
152
|
+
* @typedef {import('./pnet')} Protector
|
|
153
|
+
* @typedef {import('./types').ConnectionGater} ConnectionGater
|
|
154
|
+
* @typedef {Object} PersistentPeerStoreOptions
|
|
155
|
+
* @property {number} [threshold]
|
|
156
|
+
*/
|
|
157
|
+
/**
|
|
158
|
+
* @typedef {Object} HandlerProps
|
|
159
|
+
* @property {Connection} connection
|
|
160
|
+
* @property {MuxedStream} stream
|
|
161
|
+
* @property {string} protocol
|
|
162
|
+
*
|
|
163
|
+
* @typedef {Object} DhtOptions
|
|
164
|
+
* @property {boolean} [enabled = false]
|
|
165
|
+
* @property {number} [kBucketSize = 20]
|
|
166
|
+
* @property {boolean} [clientMode]
|
|
167
|
+
* @property {import('libp2p-interfaces/src/types').DhtSelectors} [selectors]
|
|
168
|
+
* @property {import('libp2p-interfaces/src/types').DhtValidators} [validators]
|
|
169
|
+
*
|
|
170
|
+
* @typedef {Object} KeychainOptions
|
|
171
|
+
* @property {Datastore} [datastore]
|
|
172
|
+
*
|
|
173
|
+
* @typedef {Object} PeerStoreOptions
|
|
174
|
+
* @property {boolean} persistence
|
|
175
|
+
*
|
|
176
|
+
* @typedef {Object} PubsubLocalOptions
|
|
177
|
+
* @property {boolean} enabled
|
|
178
|
+
*
|
|
179
|
+
* @typedef {Object} MetricsOptions
|
|
180
|
+
* @property {boolean} enabled
|
|
181
|
+
*
|
|
182
|
+
* @typedef {Object} RelayOptions
|
|
183
|
+
* @property {boolean} [enabled = true]
|
|
184
|
+
* @property {import('./circuit').RelayAdvertiseOptions} [advertise]
|
|
185
|
+
* @property {import('./circuit').HopOptions} [hop]
|
|
186
|
+
* @property {import('./circuit').AutoRelayOptions} [autoRelay]
|
|
187
|
+
*
|
|
188
|
+
* @typedef {Object} Libp2pConfig
|
|
189
|
+
* @property {DhtOptions} [dht] dht module options
|
|
190
|
+
* @property {import('./nat-manager').NatManagerOptions} [nat]
|
|
191
|
+
* @property {Record<string, Object|boolean>} [peerDiscovery]
|
|
192
|
+
* @property {PubsubLocalOptions & PubsubOptions} [pubsub] pubsub module options
|
|
193
|
+
* @property {RelayOptions} [relay]
|
|
194
|
+
* @property {Record<string, Object>} [transport] transport options indexed by transport key
|
|
195
|
+
*
|
|
196
|
+
* @typedef {Object} Libp2pModules
|
|
197
|
+
* @property {TransportFactory[]} transport
|
|
198
|
+
* @property {MuxerFactory[]} streamMuxer
|
|
199
|
+
* @property {Crypto[]} connEncryption
|
|
200
|
+
* @property {PeerDiscoveryFactory[]} [peerDiscovery]
|
|
201
|
+
* @property {PeerRoutingModule[]} [peerRouting]
|
|
202
|
+
* @property {ContentRoutingModule[]} [contentRouting]
|
|
203
|
+
* @property {Object} [dht]
|
|
204
|
+
* @property {{new(...args: any[]): Pubsub}} [pubsub]
|
|
205
|
+
* @property {Protector} [connProtector]
|
|
206
|
+
*
|
|
207
|
+
* @typedef {Object} Libp2pOptions
|
|
208
|
+
* @property {Libp2pModules} modules libp2p modules to use
|
|
209
|
+
* @property {import('./address-manager').AddressManagerOptions} [addresses]
|
|
210
|
+
* @property {import('./connection-manager').ConnectionManagerOptions} [connectionManager]
|
|
211
|
+
* @property {Partial<import('./types').ConnectionGater>} [connectionGater]
|
|
212
|
+
* @property {Datastore} [datastore]
|
|
213
|
+
* @property {import('./dialer').DialerOptions} [dialer]
|
|
214
|
+
* @property {import('./identify/index').HostProperties} [host] libp2p host
|
|
215
|
+
* @property {KeychainOptions & import('./keychain/index').KeychainOptions} [keychain]
|
|
216
|
+
* @property {MetricsOptions & import('./metrics').MetricsOptions} [metrics]
|
|
217
|
+
* @property {import('./peer-routing').PeerRoutingOptions} [peerRouting]
|
|
218
|
+
* @property {PeerStoreOptions} [peerStore]
|
|
219
|
+
* @property {import('./transport-manager').TransportManagerOptions} [transportManager]
|
|
220
|
+
* @property {Libp2pConfig} [config]
|
|
221
|
+
*
|
|
222
|
+
* @typedef {Object} constructorOptions
|
|
223
|
+
* @property {PeerId} peerId
|
|
224
|
+
*
|
|
225
|
+
* @typedef {Object} CreateOptions
|
|
226
|
+
* @property {PeerId} [peerId]
|
|
227
|
+
*
|
|
228
|
+
* @extends {EventEmitter}
|
|
229
|
+
* @fires Libp2p#error Emitted when an error occurs
|
|
230
|
+
* @fires Libp2p#peer:discovery Emitted when a peer is discovered
|
|
231
|
+
*/
|
|
137
232
|
persistence: boolean;
|
|
138
233
|
threshold: number;
|
|
139
234
|
};
|
|
@@ -189,6 +284,8 @@ declare class Libp2p extends EventEmitter {
|
|
|
189
284
|
peerId: PeerId;
|
|
190
285
|
datastore: import("interface-datastore").Datastore | undefined;
|
|
191
286
|
metrics: Metrics | undefined;
|
|
287
|
+
/** @type {ConnectionGater} */
|
|
288
|
+
connectionGater: ConnectionGater;
|
|
192
289
|
/** @type {import('./peer-store/types').PeerStore} */
|
|
193
290
|
peerStore: import('./peer-store/types').PeerStore;
|
|
194
291
|
addresses: {
|
|
@@ -271,6 +368,7 @@ declare class Libp2p extends EventEmitter {
|
|
|
271
368
|
* @param {{ id: PeerId, multiaddrs: Multiaddr[], protocols: string[] }} peer
|
|
272
369
|
*/
|
|
273
370
|
private _onDiscoveryPeer;
|
|
371
|
+
fetchService: FetchService;
|
|
274
372
|
/**
|
|
275
373
|
* Starts the libp2p node and all its subsystems
|
|
276
374
|
*
|
|
@@ -355,6 +453,14 @@ declare class Libp2p extends EventEmitter {
|
|
|
355
453
|
* @returns {Promise<void>}
|
|
356
454
|
*/
|
|
357
455
|
hangUp(peer: PeerId | Multiaddr | string): Promise<void>;
|
|
456
|
+
/**
|
|
457
|
+
* Sends a request to fetch the value associated with the given key from the given peer.
|
|
458
|
+
*
|
|
459
|
+
* @param {PeerId|Multiaddr} peer
|
|
460
|
+
* @param {string} key
|
|
461
|
+
* @returns {Promise<Uint8Array | null>}
|
|
462
|
+
*/
|
|
463
|
+
fetch(peer: PeerId | Multiaddr, key: string): Promise<Uint8Array | null>;
|
|
358
464
|
/**
|
|
359
465
|
* Pings the given peer in order to obtain the operation latency.
|
|
360
466
|
*
|
|
@@ -394,7 +500,7 @@ declare class Libp2p extends EventEmitter {
|
|
|
394
500
|
private _setupPeerDiscovery;
|
|
395
501
|
}
|
|
396
502
|
declare namespace Libp2p {
|
|
397
|
-
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 };
|
|
503
|
+
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 };
|
|
398
504
|
}
|
|
399
505
|
import { EventEmitter } from "events";
|
|
400
506
|
type Libp2pOptions = {
|
|
@@ -404,6 +510,7 @@ type Libp2pOptions = {
|
|
|
404
510
|
modules: Libp2pModules;
|
|
405
511
|
addresses?: AddressManager.AddressManagerOptions | undefined;
|
|
406
512
|
connectionManager?: ConnectionManager.ConnectionManagerOptions | undefined;
|
|
513
|
+
connectionGater?: Partial<import("./types").ConnectionGater> | undefined;
|
|
407
514
|
datastore?: import("interface-datastore").Datastore | undefined;
|
|
408
515
|
dialer?: Dialer.DialerOptions | undefined;
|
|
409
516
|
/**
|
|
@@ -422,6 +529,7 @@ type constructorOptions = {
|
|
|
422
529
|
};
|
|
423
530
|
import PeerId = require("peer-id");
|
|
424
531
|
import Metrics = require("./metrics");
|
|
532
|
+
type ConnectionGater = import('./types').ConnectionGater;
|
|
425
533
|
import AddressManager = require("./address-manager");
|
|
426
534
|
type Libp2pModules = {
|
|
427
535
|
transport: import("libp2p-interfaces/src/transport/types").TransportFactory<any, any>[];
|
|
@@ -468,6 +576,7 @@ import Relay = require("./circuit");
|
|
|
468
576
|
import IdentifyService = require("./identify");
|
|
469
577
|
import PeerRouting = require("./peer-routing");
|
|
470
578
|
import ContentRouting = require("./content-routing");
|
|
579
|
+
import FetchService = require("./fetch");
|
|
471
580
|
import { Multiaddr } from "multiaddr";
|
|
472
581
|
type Connection = import("libp2p-interfaces/src/connection/connection");
|
|
473
582
|
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":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":"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"}
|
|
@@ -6,10 +6,12 @@ declare class PeerStoreAddressBook implements AddressBook {
|
|
|
6
6
|
/**
|
|
7
7
|
* @param {PeerStore["emit"]} emit
|
|
8
8
|
* @param {import('./types').Store} store
|
|
9
|
+
* @param {(peerId: PeerId, multiaddr: Multiaddr) => Promise<boolean>} addressFilter
|
|
9
10
|
*/
|
|
10
|
-
constructor(emit: PeerStore["emit"], store: import('./types').Store);
|
|
11
|
+
constructor(emit: PeerStore["emit"], store: import('./types').Store, addressFilter: (peerId: PeerId, multiaddr: Multiaddr) => Promise<boolean>);
|
|
11
12
|
_emit: <U extends keyof import("./types").PeerStoreEvents>(event: U, ...args: Parameters<import("./types").PeerStoreEvents[U]>) => boolean;
|
|
12
13
|
_store: import("./types").Store;
|
|
14
|
+
_addressFilter: (peerId: PeerId, multiaddr: Multiaddr) => Promise<boolean>;
|
|
13
15
|
/**
|
|
14
16
|
* ConsumePeerRecord adds addresses from a signed peer record contained in a record envelope.
|
|
15
17
|
* This will return a boolean that indicates if the record was successfully processed and added
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/address-book.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/address-book.js"],"names":[],"mappings":";AA2BA;;GAEG;AACH;IACE;;;;OAIG;IACH,kBAJW,SAAS,CAAC,MAAM,CAAC,SACjB,OAAO,SAAS,EAAE,KAAK,0BACd,MAAM,aAAa,SAAS,KAAK,QAAQ,OAAO,CAAC,EAMpE;IAHC,2IAAiB;IACjB,gCAAmB;IACnB,yBALkB,MAAM,aAAa,SAAS,KAAK,QAAQ,OAAO,CAAC,CAKhC;IAGrC;;;;;;OAMG;IACH,4BAFW,QAAQ,oBA+DlB;IAED;;OAEG;IACH,uBAFW,MAAM,mCAmBhB;IAED;;;;;OAKG;IACH,sBAFW,MAAM,iCAUhB;IAED;;OAEG;IACH,YAFW,MAAM,wCA0BhB;IAED;;;OAGG;IACH,YAHW,MAAM,cACN,SAAS,EAAE,iBA2DrB;IAED;;;OAGG;IACH,YAHW,MAAM,cACN,SAAS,EAAE,iBA0DrB;IAED;;OAEG;IACH,eAFW,MAAM,iBA4BhB;IAED;;;OAGG;IACH,6BAHW,MAAM,+BACM,OAAO,EAAE,KAAK,OAAO,EAAE,qCAe7C;CACF;;;;mBA/UY,OAAO,SAAS,EAAE,WAAW;;;;iBAF7B,OAAO,SAAS,EAAE,SAAS;eAC3B,OAAO,SAAS,EAAE,OAAO"}
|
|
@@ -9,10 +9,12 @@ declare class DefaultPeerStore extends EventEmitter implements PeerStore {
|
|
|
9
9
|
* @param {object} properties
|
|
10
10
|
* @param {PeerId} properties.peerId
|
|
11
11
|
* @param {import('interface-datastore').Datastore} properties.datastore
|
|
12
|
+
* @param {(peerId: PeerId, multiaddr: Multiaddr) => Promise<boolean>} properties.addressFilter
|
|
12
13
|
*/
|
|
13
|
-
constructor({ peerId, datastore }: {
|
|
14
|
+
constructor({ peerId, datastore, addressFilter }: {
|
|
14
15
|
peerId: PeerId;
|
|
15
16
|
datastore: import('interface-datastore').Datastore;
|
|
17
|
+
addressFilter: (peerId: PeerId, multiaddr: Multiaddr) => Promise<boolean>;
|
|
16
18
|
});
|
|
17
19
|
_peerId: import("peer-id");
|
|
18
20
|
_store: Store;
|
|
@@ -41,7 +43,7 @@ declare class DefaultPeerStore extends EventEmitter implements PeerStore {
|
|
|
41
43
|
has(peerId: PeerId): Promise<boolean>;
|
|
42
44
|
}
|
|
43
45
|
declare namespace DefaultPeerStore {
|
|
44
|
-
export { PeerStore, Peer, PeerId };
|
|
46
|
+
export { PeerStore, Peer, PeerId, Multiaddr };
|
|
45
47
|
}
|
|
46
48
|
type PeerStore = import('./types').PeerStore;
|
|
47
49
|
import { EventEmitter } from "events";
|
|
@@ -51,5 +53,6 @@ import KeyBook = require("./key-book");
|
|
|
51
53
|
import MetadataBook = require("./metadata-book");
|
|
52
54
|
import ProtoBook = require("./proto-book");
|
|
53
55
|
type PeerId = import('peer-id');
|
|
56
|
+
type Multiaddr = import('multiaddr').Multiaddr;
|
|
54
57
|
type Peer = import('./types').Peer;
|
|
55
58
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-store/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-store/index.js"],"names":[],"mappings":";AAqBA;;;;GAIG;AACH;IACE;;;;;OAKG;IACH;gBAJW,MAAM;mBACN,OAAO,qBAAqB,EAAE,SAAS;gCAC9B,MAAM,aAAa,SAAS,KAAK,QAAQ,OAAO,CAAC;OAYpE;IAPC,2BAAqB;IACrB,cAAkC;IAElC,yBAAoF;IACpF,iBAA6D;IAC7D,2BAAuE;IACvE,qBAAiE;IAGnE,kEAkBC;IAED;;;;OAIG;IACH,eAFW,MAAM,iBAahB;IAED;;;;OAIG;IACH,YAFW,MAAM,mCAahB;IAED;;;;OAIG;IACH,YAFW,MAAM,oBAahB;CACF;;;;iBA3GY,OAAO,SAAS,EAAE,SAAS;;;;;;;cAE3B,OAAO,SAAS,CAAC;iBACjB,OAAO,WAAW,EAAE,SAAS;YAF7B,OAAO,SAAS,EAAE,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/peer-store/store.js"],"names":[],"mappings":";AA2BA;IACE;;OAEG;IACH,uBAFW,OAAO,qBAAqB,EAAE,SAAS,EAOjD;IAJC,oDAA2B;IAC3B,UAEE;IAGJ;;;OAGG;IACH,8BAHW,MAAM,GACJ,GAAG,CAUf;IAED;;OAEG;IACH,YAFW,MAAM,oBAIhB;IAED;;OAEG;IACH,eAFW,MAAM,iBAIhB;IAED;;;OAGG;IACH,aAHW,MAAM,GACJ,QAAQ,OAAO,SAAS,EAAE,IAAI,CAAC,CAuB3C;IAED;;OAEG;IACH,WAFW,IAAI,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/peer-store/store.js"],"names":[],"mappings":";AA2BA;IACE;;OAEG;IACH,uBAFW,OAAO,qBAAqB,EAAE,SAAS,EAOjD;IAJC,oDAA2B;IAC3B,UAEE;IAGJ;;;OAGG;IACH,8BAHW,MAAM,GACJ,GAAG,CAUf;IAED;;OAEG;IACH,YAFW,MAAM,oBAIhB;IAED;;OAEG;IACH,eAFW,MAAM,iBAIhB;IAED;;;OAGG;IACH,aAHW,MAAM,GACJ,QAAQ,OAAO,SAAS,EAAE,IAAI,CAAC,CAuB3C;IAED;;OAEG;IACH,WAFW,IAAI,mCAqCd;IAED;;;OAGG;IACH,cAHW,MAAM,QACN,QAAQ,IAAI,CAAC,mCAMvB;IAED;;;OAGG;IACH,sBAHW,MAAM,QACN,QAAQ,IAAI,CAAC,mCAiBvB;IAED;;;;OAIG;IACH,eAJW,MAAM,QACN,QAAQ,IAAI,CAAC,QACb,IAAI,mCAQd;IAED;;;OAGG;IACH,cAHW,MAAM,QACN,QAAQ,IAAI,CAAC,mCAMvB;IAED;;;OAGG;IACH,sBAHW,MAAM,QACN,QAAQ,IAAI,CAAC,mCAiBvB;IAED;;;;OAIG;IACH,eAJW,MAAM,QACN,QAAQ,IAAI,CAAC,QACb,IAAI,mCAoCd;IAED,6DAUC;CACF;;;;;;YA9OY,OAAO,SAAS,EAAE,IAAI;iBAFtB,OAAO,SAAS,EAAE,SAAS;iBAC3B,OAAO,SAAS,EAAE,SAAS"}
|