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
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import * as $protobuf from "protobufjs";
|
|
2
|
+
/** Properties of a Peer. */
|
|
3
|
+
export interface IPeer {
|
|
4
|
+
|
|
5
|
+
/** Peer addresses */
|
|
6
|
+
addresses?: (IAddress[]|null);
|
|
7
|
+
|
|
8
|
+
/** Peer protocols */
|
|
9
|
+
protocols?: (string[]|null);
|
|
10
|
+
|
|
11
|
+
/** Peer metadata */
|
|
12
|
+
metadata?: (IMetadata[]|null);
|
|
13
|
+
|
|
14
|
+
/** Peer pubKey */
|
|
15
|
+
pubKey?: (Uint8Array|null);
|
|
16
|
+
|
|
17
|
+
/** Peer peerRecordEnvelope */
|
|
18
|
+
peerRecordEnvelope?: (Uint8Array|null);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Represents a Peer. */
|
|
22
|
+
export class Peer implements IPeer {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Constructs a new Peer.
|
|
26
|
+
* @param [p] Properties to set
|
|
27
|
+
*/
|
|
28
|
+
constructor(p?: IPeer);
|
|
29
|
+
|
|
30
|
+
/** Peer addresses. */
|
|
31
|
+
public addresses: IAddress[];
|
|
32
|
+
|
|
33
|
+
/** Peer protocols. */
|
|
34
|
+
public protocols: string[];
|
|
35
|
+
|
|
36
|
+
/** Peer metadata. */
|
|
37
|
+
public metadata: IMetadata[];
|
|
38
|
+
|
|
39
|
+
/** Peer pubKey. */
|
|
40
|
+
public pubKey?: (Uint8Array|null);
|
|
41
|
+
|
|
42
|
+
/** Peer peerRecordEnvelope. */
|
|
43
|
+
public peerRecordEnvelope?: (Uint8Array|null);
|
|
44
|
+
|
|
45
|
+
/** Peer _pubKey. */
|
|
46
|
+
public _pubKey?: "pubKey";
|
|
47
|
+
|
|
48
|
+
/** Peer _peerRecordEnvelope. */
|
|
49
|
+
public _peerRecordEnvelope?: "peerRecordEnvelope";
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Encodes the specified Peer message. Does not implicitly {@link Peer.verify|verify} messages.
|
|
53
|
+
* @param m Peer message or plain object to encode
|
|
54
|
+
* @param [w] Writer to encode to
|
|
55
|
+
* @returns Writer
|
|
56
|
+
*/
|
|
57
|
+
public static encode(m: IPeer, w?: $protobuf.Writer): $protobuf.Writer;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Decodes a Peer message from the specified reader or buffer.
|
|
61
|
+
* @param r Reader or buffer to decode from
|
|
62
|
+
* @param [l] Message length if known beforehand
|
|
63
|
+
* @returns Peer
|
|
64
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
65
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
66
|
+
*/
|
|
67
|
+
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): Peer;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Creates a Peer message from a plain object. Also converts values to their respective internal types.
|
|
71
|
+
* @param d Plain object
|
|
72
|
+
* @returns Peer
|
|
73
|
+
*/
|
|
74
|
+
public static fromObject(d: { [k: string]: any }): Peer;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Creates a plain object from a Peer message. Also converts values to other types if specified.
|
|
78
|
+
* @param m Peer
|
|
79
|
+
* @param [o] Conversion options
|
|
80
|
+
* @returns Plain object
|
|
81
|
+
*/
|
|
82
|
+
public static toObject(m: Peer, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Converts this Peer to JSON.
|
|
86
|
+
* @returns JSON object
|
|
87
|
+
*/
|
|
88
|
+
public toJSON(): { [k: string]: any };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Properties of an Address. */
|
|
92
|
+
export interface IAddress {
|
|
93
|
+
|
|
94
|
+
/** Address multiaddr */
|
|
95
|
+
multiaddr?: (Uint8Array|null);
|
|
96
|
+
|
|
97
|
+
/** Address isCertified */
|
|
98
|
+
isCertified?: (boolean|null);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Represents an Address. */
|
|
102
|
+
export class Address implements IAddress {
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Constructs a new Address.
|
|
106
|
+
* @param [p] Properties to set
|
|
107
|
+
*/
|
|
108
|
+
constructor(p?: IAddress);
|
|
109
|
+
|
|
110
|
+
/** Address multiaddr. */
|
|
111
|
+
public multiaddr: Uint8Array;
|
|
112
|
+
|
|
113
|
+
/** Address isCertified. */
|
|
114
|
+
public isCertified?: (boolean|null);
|
|
115
|
+
|
|
116
|
+
/** Address _isCertified. */
|
|
117
|
+
public _isCertified?: "isCertified";
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Encodes the specified Address message. Does not implicitly {@link Address.verify|verify} messages.
|
|
121
|
+
* @param m Address message or plain object to encode
|
|
122
|
+
* @param [w] Writer to encode to
|
|
123
|
+
* @returns Writer
|
|
124
|
+
*/
|
|
125
|
+
public static encode(m: IAddress, w?: $protobuf.Writer): $protobuf.Writer;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Decodes an Address message from the specified reader or buffer.
|
|
129
|
+
* @param r Reader or buffer to decode from
|
|
130
|
+
* @param [l] Message length if known beforehand
|
|
131
|
+
* @returns Address
|
|
132
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
133
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
134
|
+
*/
|
|
135
|
+
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): Address;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Creates an Address message from a plain object. Also converts values to their respective internal types.
|
|
139
|
+
* @param d Plain object
|
|
140
|
+
* @returns Address
|
|
141
|
+
*/
|
|
142
|
+
public static fromObject(d: { [k: string]: any }): Address;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Creates a plain object from an Address message. Also converts values to other types if specified.
|
|
146
|
+
* @param m Address
|
|
147
|
+
* @param [o] Conversion options
|
|
148
|
+
* @returns Plain object
|
|
149
|
+
*/
|
|
150
|
+
public static toObject(m: Address, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Converts this Address to JSON.
|
|
154
|
+
* @returns JSON object
|
|
155
|
+
*/
|
|
156
|
+
public toJSON(): { [k: string]: any };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Properties of a Metadata. */
|
|
160
|
+
export interface IMetadata {
|
|
161
|
+
|
|
162
|
+
/** Metadata key */
|
|
163
|
+
key?: (string|null);
|
|
164
|
+
|
|
165
|
+
/** Metadata value */
|
|
166
|
+
value?: (Uint8Array|null);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Represents a Metadata. */
|
|
170
|
+
export class Metadata implements IMetadata {
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Constructs a new Metadata.
|
|
174
|
+
* @param [p] Properties to set
|
|
175
|
+
*/
|
|
176
|
+
constructor(p?: IMetadata);
|
|
177
|
+
|
|
178
|
+
/** Metadata key. */
|
|
179
|
+
public key: string;
|
|
180
|
+
|
|
181
|
+
/** Metadata value. */
|
|
182
|
+
public value: Uint8Array;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Encodes the specified Metadata message. Does not implicitly {@link Metadata.verify|verify} messages.
|
|
186
|
+
* @param m Metadata message or plain object to encode
|
|
187
|
+
* @param [w] Writer to encode to
|
|
188
|
+
* @returns Writer
|
|
189
|
+
*/
|
|
190
|
+
public static encode(m: IMetadata, w?: $protobuf.Writer): $protobuf.Writer;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Decodes a Metadata message from the specified reader or buffer.
|
|
194
|
+
* @param r Reader or buffer to decode from
|
|
195
|
+
* @param [l] Message length if known beforehand
|
|
196
|
+
* @returns Metadata
|
|
197
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
198
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
199
|
+
*/
|
|
200
|
+
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): Metadata;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Creates a Metadata message from a plain object. Also converts values to their respective internal types.
|
|
204
|
+
* @param d Plain object
|
|
205
|
+
* @returns Metadata
|
|
206
|
+
*/
|
|
207
|
+
public static fromObject(d: { [k: string]: any }): Metadata;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Creates a plain object from a Metadata message. Also converts values to other types if specified.
|
|
211
|
+
* @param m Metadata
|
|
212
|
+
* @param [o] Conversion options
|
|
213
|
+
* @returns Plain object
|
|
214
|
+
*/
|
|
215
|
+
public static toObject(m: Metadata, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Converts this Metadata to JSON.
|
|
219
|
+
* @returns JSON object
|
|
220
|
+
*/
|
|
221
|
+
public toJSON(): { [k: string]: any };
|
|
222
|
+
}
|
|
@@ -1,44 +1,43 @@
|
|
|
1
|
-
export =
|
|
1
|
+
export = PersistentProtoBook;
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
3
|
+
* @implements {ProtoBook}
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
declare class PersistentProtoBook implements ProtoBook {
|
|
6
|
+
/**
|
|
7
|
+
* @param {PeerStore["emit"]} emit
|
|
8
|
+
* @param {import('./types').Store} store
|
|
9
|
+
*/
|
|
10
|
+
constructor(emit: PeerStore["emit"], store: import('./types').Store);
|
|
11
|
+
_emit: <U extends keyof import("./types").PeerStoreEvents>(event: U, ...args: Parameters<import("./types").PeerStoreEvents[U]>) => boolean;
|
|
12
|
+
_store: import("./types").Store;
|
|
13
|
+
/**
|
|
14
|
+
* @param {PeerId} peerId
|
|
15
|
+
*/
|
|
16
|
+
get(peerId: PeerId): Promise<string[]>;
|
|
11
17
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @class
|
|
16
|
-
* @param {PeerStore} peerStore
|
|
18
|
+
* @param {PeerId} peerId
|
|
19
|
+
* @param {string[]} protocols
|
|
17
20
|
*/
|
|
18
|
-
|
|
21
|
+
set(peerId: PeerId, protocols: string[]): Promise<void>;
|
|
19
22
|
/**
|
|
20
|
-
* Adds known protocols of a provided peer.
|
|
21
|
-
* If the peer was not known before, it will be added.
|
|
22
|
-
*
|
|
23
23
|
* @param {PeerId} peerId
|
|
24
24
|
* @param {string[]} protocols
|
|
25
|
-
* @returns {ProtoBook}
|
|
26
25
|
*/
|
|
27
|
-
add(peerId: PeerId, protocols: string[]):
|
|
26
|
+
add(peerId: PeerId, protocols: string[]): Promise<void>;
|
|
28
27
|
/**
|
|
29
|
-
* Removes known protocols of a provided peer.
|
|
30
|
-
* If the protocols did not exist before, nothing will be done.
|
|
31
|
-
*
|
|
32
28
|
* @param {PeerId} peerId
|
|
33
29
|
* @param {string[]} protocols
|
|
34
|
-
* @returns {ProtoBook}
|
|
35
30
|
*/
|
|
36
|
-
remove(peerId: PeerId, protocols: string[]):
|
|
31
|
+
remove(peerId: PeerId, protocols: string[]): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* @param {PeerId} peerId
|
|
34
|
+
*/
|
|
35
|
+
delete(peerId: PeerId): Promise<void>;
|
|
37
36
|
}
|
|
38
|
-
declare namespace
|
|
39
|
-
export { PeerStore };
|
|
37
|
+
declare namespace PersistentProtoBook {
|
|
38
|
+
export { PeerStore, ProtoBook };
|
|
40
39
|
}
|
|
41
|
-
|
|
40
|
+
type ProtoBook = import('./types').ProtoBook;
|
|
42
41
|
import PeerId = require("peer-id");
|
|
43
|
-
type PeerStore = import('./');
|
|
42
|
+
type PeerStore = import('./types').PeerStore;
|
|
44
43
|
//# sourceMappingURL=proto-book.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proto-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/proto-book.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"proto-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/proto-book.js"],"names":[],"mappings":";AAkBA;;GAEG;AACH;IACE;;;OAGG;IACH,kBAHW,SAAS,CAAC,MAAM,CAAC,SACjB,OAAO,SAAS,EAAE,KAAK,EAKjC;IAFC,2IAAiB;IACjB,gCAAmB;IAGrB;;OAEG;IACH,YAFW,MAAM,qBAqBhB;IAED;;;OAGG;IACH,YAHW,MAAM,aACN,MAAM,EAAE,iBA6ClB;IAED;;;OAGG;IACH,YAHW,MAAM,aACN,MAAM,EAAE,iBA8ClB;IAED;;;OAGG;IACH,eAHW,MAAM,aACN,MAAM,EAAE,iBAgDlB;IAED;;OAEG;IACH,eAFW,MAAM,iBA0BhB;CACF;;;;iBAjOY,OAAO,SAAS,EAAE,SAAS;;iBAD3B,OAAO,SAAS,EAAE,SAAS"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export = PersistentStore;
|
|
2
|
+
declare class PersistentStore {
|
|
3
|
+
/**
|
|
4
|
+
* @param {import('interface-datastore').Datastore} datastore
|
|
5
|
+
*/
|
|
6
|
+
constructor(datastore: import('interface-datastore').Datastore);
|
|
7
|
+
_datastore: import("interface-datastore").Datastore;
|
|
8
|
+
lock: any;
|
|
9
|
+
/**
|
|
10
|
+
* @param {PeerId} peerId
|
|
11
|
+
* @returns {Key}
|
|
12
|
+
*/
|
|
13
|
+
_peerIdToDatastoreKey(peerId: PeerId): Key;
|
|
14
|
+
/**
|
|
15
|
+
* @param {PeerId} peerId
|
|
16
|
+
*/
|
|
17
|
+
has(peerId: PeerId): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* @param {PeerId} peerId
|
|
20
|
+
*/
|
|
21
|
+
delete(peerId: PeerId): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* @param {PeerId} peerId
|
|
24
|
+
* @returns {Promise<import('./types').Peer>} peer
|
|
25
|
+
*/
|
|
26
|
+
load(peerId: PeerId): Promise<import('./types').Peer>;
|
|
27
|
+
/**
|
|
28
|
+
* @param {Peer} peer
|
|
29
|
+
*/
|
|
30
|
+
save(peer: Peer): Promise<import("./types").Peer>;
|
|
31
|
+
/**
|
|
32
|
+
* @param {PeerId} peerId
|
|
33
|
+
* @param {Partial<Peer>} data
|
|
34
|
+
*/
|
|
35
|
+
patch(peerId: PeerId, data: Partial<Peer>): Promise<import("./types").Peer>;
|
|
36
|
+
/**
|
|
37
|
+
* @param {PeerId} peerId
|
|
38
|
+
* @param {Partial<Peer>} data
|
|
39
|
+
*/
|
|
40
|
+
patchOrCreate(peerId: PeerId, data: Partial<Peer>): Promise<import("./types").Peer>;
|
|
41
|
+
/**
|
|
42
|
+
* @param {PeerId} peerId
|
|
43
|
+
* @param {Partial<Peer>} data
|
|
44
|
+
* @param {Peer} peer
|
|
45
|
+
*/
|
|
46
|
+
_patch(peerId: PeerId, data: Partial<Peer>, peer: Peer): Promise<import("./types").Peer>;
|
|
47
|
+
/**
|
|
48
|
+
* @param {PeerId} peerId
|
|
49
|
+
* @param {Partial<Peer>} data
|
|
50
|
+
*/
|
|
51
|
+
merge(peerId: PeerId, data: Partial<Peer>): Promise<import("./types").Peer>;
|
|
52
|
+
/**
|
|
53
|
+
* @param {PeerId} peerId
|
|
54
|
+
* @param {Partial<Peer>} data
|
|
55
|
+
*/
|
|
56
|
+
mergeOrCreate(peerId: PeerId, data: Partial<Peer>): Promise<import("./types").Peer>;
|
|
57
|
+
/**
|
|
58
|
+
* @param {PeerId} peerId
|
|
59
|
+
* @param {Partial<Peer>} data
|
|
60
|
+
* @param {Peer} peer
|
|
61
|
+
*/
|
|
62
|
+
_merge(peerId: PeerId, data: Partial<Peer>, peer: Peer): Promise<import("./types").Peer>;
|
|
63
|
+
all(): AsyncGenerator<import("./types").Peer, void, unknown>;
|
|
64
|
+
}
|
|
65
|
+
declare namespace PersistentStore {
|
|
66
|
+
export { PeerStore, EventName, Peer };
|
|
67
|
+
}
|
|
68
|
+
import PeerId = require("peer-id");
|
|
69
|
+
import { Key } from "interface-datastore/key";
|
|
70
|
+
type Peer = import('./types').Peer;
|
|
71
|
+
type PeerStore = import('./types').PeerStore;
|
|
72
|
+
type EventName = import('./types').EventName;
|
|
73
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import type PeerId from 'peer-id';
|
|
2
|
+
import type { Multiaddr } from 'multiaddr';
|
|
3
|
+
import type Envelope from '../record/envelope';
|
|
4
|
+
import type { PublicKey } from 'libp2p-interfaces/src/keys/types';
|
|
5
|
+
export interface Address {
|
|
6
|
+
/**
|
|
7
|
+
* Peer multiaddr
|
|
8
|
+
*/
|
|
9
|
+
multiaddr: Multiaddr;
|
|
10
|
+
/**
|
|
11
|
+
* Obtained from a signed peer record
|
|
12
|
+
*/
|
|
13
|
+
isCertified: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface Peer {
|
|
16
|
+
/**
|
|
17
|
+
* Peer's peer-id instance
|
|
18
|
+
*/
|
|
19
|
+
id: PeerId;
|
|
20
|
+
/**
|
|
21
|
+
* Peer's addresses containing its multiaddrs and metadata
|
|
22
|
+
*/
|
|
23
|
+
addresses: Address[];
|
|
24
|
+
/**
|
|
25
|
+
* Peer's supported protocols
|
|
26
|
+
*/
|
|
27
|
+
protocols: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Peer's metadata map
|
|
30
|
+
*/
|
|
31
|
+
metadata: Map<string, Uint8Array>;
|
|
32
|
+
/**
|
|
33
|
+
* May be set if the key that this Peer has is an RSA key
|
|
34
|
+
*/
|
|
35
|
+
pubKey?: PublicKey;
|
|
36
|
+
/**
|
|
37
|
+
* The last peer record envelope received
|
|
38
|
+
*/
|
|
39
|
+
peerRecordEnvelope?: Uint8Array;
|
|
40
|
+
}
|
|
41
|
+
export interface CertifiedRecord {
|
|
42
|
+
raw: Uint8Array;
|
|
43
|
+
seqNumber: number;
|
|
44
|
+
}
|
|
45
|
+
export interface AddressBookEntry {
|
|
46
|
+
addresses: Address[];
|
|
47
|
+
record: CertifiedRecord;
|
|
48
|
+
}
|
|
49
|
+
export interface Book<Type> {
|
|
50
|
+
/**
|
|
51
|
+
* Get the known data of a peer
|
|
52
|
+
*/
|
|
53
|
+
get: (peerId: PeerId) => Promise<Type>;
|
|
54
|
+
/**
|
|
55
|
+
* Set the known data of a peer
|
|
56
|
+
*/
|
|
57
|
+
set: (peerId: PeerId, data: Type) => Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Remove the known data of a peer
|
|
60
|
+
*/
|
|
61
|
+
delete: (peerId: PeerId) => Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* AddressBook containing a map of peerIdStr to Address.
|
|
65
|
+
*/
|
|
66
|
+
export interface AddressBook {
|
|
67
|
+
/**
|
|
68
|
+
* ConsumePeerRecord adds addresses from a signed peer record contained in a record envelope.
|
|
69
|
+
* This will return a boolean that indicates if the record was successfully processed and added
|
|
70
|
+
* into the AddressBook
|
|
71
|
+
*/
|
|
72
|
+
consumePeerRecord: (envelope: Envelope) => Promise<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* Get the raw Envelope for a peer. Returns
|
|
75
|
+
* undefined if no Envelope is found
|
|
76
|
+
*/
|
|
77
|
+
getRawEnvelope: (peerId: PeerId) => Promise<Uint8Array | undefined>;
|
|
78
|
+
/**
|
|
79
|
+
* Get an Envelope containing a PeerRecord for the given peer.
|
|
80
|
+
* Returns undefined if no record exists.
|
|
81
|
+
*/
|
|
82
|
+
getPeerRecord: (peerId: PeerId) => Promise<Envelope | undefined>;
|
|
83
|
+
/**
|
|
84
|
+
* Add known addresses of a provided peer.
|
|
85
|
+
* If the peer is not known, it is set with the given addresses.
|
|
86
|
+
*/
|
|
87
|
+
add: (peerId: PeerId, multiaddrs: Multiaddr[]) => Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Set the known addresses of a peer
|
|
90
|
+
*/
|
|
91
|
+
set: (peerId: PeerId, data: Multiaddr[]) => Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Return the known addresses of a peer
|
|
94
|
+
*/
|
|
95
|
+
get: (peerId: PeerId) => Promise<Address[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Get the known multiaddrs for a given peer. All returned multiaddrs
|
|
98
|
+
* will include the encapsulated `PeerId` of the peer.
|
|
99
|
+
*/
|
|
100
|
+
getMultiaddrsForPeer: (peerId: PeerId, addressSorter?: (ms: Address[]) => Address[]) => Promise<Multiaddr[]>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* KeyBook containing a map of peerIdStr to their PeerId with public keys.
|
|
104
|
+
*/
|
|
105
|
+
export interface KeyBook {
|
|
106
|
+
/**
|
|
107
|
+
* Get the known data of a peer
|
|
108
|
+
*/
|
|
109
|
+
get: (peerId: PeerId) => Promise<PublicKey | undefined>;
|
|
110
|
+
/**
|
|
111
|
+
* Set the known data of a peer
|
|
112
|
+
*/
|
|
113
|
+
set: (peerId: PeerId, data: PublicKey) => Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Remove the known data of a peer
|
|
116
|
+
*/
|
|
117
|
+
delete: (peerId: PeerId) => Promise<void>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* MetadataBook containing a map of peerIdStr to their metadata Map.
|
|
121
|
+
*/
|
|
122
|
+
export interface MetadataBook extends Book<Map<string, Uint8Array>> {
|
|
123
|
+
/**
|
|
124
|
+
* Set a specific metadata value
|
|
125
|
+
*/
|
|
126
|
+
setValue: (peerId: PeerId, key: string, value: Uint8Array) => Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Get specific metadata value, if it exists
|
|
129
|
+
*/
|
|
130
|
+
getValue: (peerId: PeerId, key: string) => Promise<Uint8Array | undefined>;
|
|
131
|
+
/**
|
|
132
|
+
* Deletes the provided peer metadata key from the book
|
|
133
|
+
*/
|
|
134
|
+
deleteValue: (peerId: PeerId, key: string) => Promise<void>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* ProtoBook containing a map of peerIdStr to supported protocols.
|
|
138
|
+
*/
|
|
139
|
+
export interface ProtoBook extends Book<string[]> {
|
|
140
|
+
/**
|
|
141
|
+
* Adds known protocols of a provided peer.
|
|
142
|
+
* If the peer was not known before, it will be added.
|
|
143
|
+
*/
|
|
144
|
+
add: (peerId: PeerId, protocols: string[]) => Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Removes known protocols of a provided peer.
|
|
147
|
+
* If the protocols did not exist before, nothing will be done.
|
|
148
|
+
*/
|
|
149
|
+
remove: (peerId: PeerId, protocols: string[]) => Promise<void>;
|
|
150
|
+
}
|
|
151
|
+
export interface PeerProtocolsChangeEvent {
|
|
152
|
+
peerId: PeerId;
|
|
153
|
+
protocols: string[];
|
|
154
|
+
}
|
|
155
|
+
export interface PeerMultiaddrsChangeEvent {
|
|
156
|
+
peerId: PeerId;
|
|
157
|
+
multiaddrs: Multiaddr[];
|
|
158
|
+
}
|
|
159
|
+
export interface PeerPublicKeyChangeEvent {
|
|
160
|
+
peerId: PeerId;
|
|
161
|
+
pubKey?: PublicKey;
|
|
162
|
+
}
|
|
163
|
+
export interface PeerMetadataChangeEvent {
|
|
164
|
+
peerId: PeerId;
|
|
165
|
+
metadata: Map<string, Uint8Array>;
|
|
166
|
+
}
|
|
167
|
+
export declare type EventName = 'peer' | 'change:protocols' | 'change:multiaddrs' | 'change:pubkey' | 'change:metadata';
|
|
168
|
+
export interface PeerStoreEvents {
|
|
169
|
+
'peer': (event: PeerId) => void;
|
|
170
|
+
'change:protocols': (event: PeerProtocolsChangeEvent) => void;
|
|
171
|
+
'change:multiaddrs': (event: PeerMultiaddrsChangeEvent) => void;
|
|
172
|
+
'change:pubkey': (event: PeerPublicKeyChangeEvent) => void;
|
|
173
|
+
'change:metadata': (event: PeerMetadataChangeEvent) => void;
|
|
174
|
+
}
|
|
175
|
+
export interface PeerStore {
|
|
176
|
+
addressBook: AddressBook;
|
|
177
|
+
keyBook: KeyBook;
|
|
178
|
+
metadataBook: MetadataBook;
|
|
179
|
+
protoBook: ProtoBook;
|
|
180
|
+
getPeers: () => AsyncIterable<Peer>;
|
|
181
|
+
delete: (peerId: PeerId) => Promise<void>;
|
|
182
|
+
has: (peerId: PeerId) => Promise<boolean>;
|
|
183
|
+
get: (peerId: PeerId) => Promise<Peer>;
|
|
184
|
+
on: <U extends keyof PeerStoreEvents>(event: U, listener: PeerStoreEvents[U]) => this;
|
|
185
|
+
once: <U extends keyof PeerStoreEvents>(event: U, listener: PeerStoreEvents[U]) => this;
|
|
186
|
+
emit: <U extends keyof PeerStoreEvents>(event: U, ...args: Parameters<PeerStoreEvents[U]>) => boolean;
|
|
187
|
+
}
|
|
188
|
+
export interface Store {
|
|
189
|
+
has: (peerId: PeerId) => Promise<boolean>;
|
|
190
|
+
save: (peer: Peer) => Promise<Peer>;
|
|
191
|
+
load: (peerId: PeerId) => Promise<Peer>;
|
|
192
|
+
merge: (peerId: PeerId, data: Partial<Peer>) => Promise<Peer>;
|
|
193
|
+
mergeOrCreate: (peerId: PeerId, data: Partial<Peer>) => Promise<Peer>;
|
|
194
|
+
patch: (peerId: PeerId, data: Partial<Peer>) => Promise<Peer>;
|
|
195
|
+
patchOrCreate: (peerId: PeerId, data: Partial<Peer>) => Promise<Peer>;
|
|
196
|
+
all: () => AsyncIterable<Peer>;
|
|
197
|
+
lock: {
|
|
198
|
+
readLock: () => Promise<() => void>;
|
|
199
|
+
writeLock: () => Promise<() => void>;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/peer-store/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,SAAS,CAAA;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAEjE,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,SAAS,EAAE,SAAS,CAAA;IAEpB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;OAEG;IACH,SAAS,EAAE,OAAO,EAAE,CAAA;IAEpB;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,CAAA;IAEnB;;OAEG;IACH,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAEjC;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAA;IAElB;;OAEG;IACH,kBAAkB,CAAC,EAAE,UAAU,CAAA;CAChC;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,UAAU,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,EAAE,CAAA;I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AI,EAAE;QACJ,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,IAAI,CAAC,CAAA;QACnC,SAAS,EAAE,MAAM,OAAO,CAAC,MAAM,IAAI,CAAC,CAAA;KACrC,CAAA;CACF"}
|
package/dist/src/ping/index.d.ts
CHANGED
|
@@ -1,35 +1,42 @@
|
|
|
1
|
-
export =
|
|
1
|
+
export = PingService;
|
|
2
2
|
/**
|
|
3
3
|
* @typedef {import('../')} Libp2p
|
|
4
4
|
* @typedef {import('multiaddr').Multiaddr} Multiaddr
|
|
5
5
|
* @typedef {import('peer-id')} PeerId
|
|
6
6
|
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxedStream} MuxedStream
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
declare class PingService {
|
|
9
|
+
/**
|
|
10
|
+
* @param {import('../')} libp2p
|
|
11
|
+
*/
|
|
12
|
+
static getProtocolStr(libp2p: import('../')): string;
|
|
13
|
+
/**
|
|
14
|
+
* @param {Libp2p} libp2p
|
|
15
|
+
*/
|
|
16
|
+
constructor(libp2p: Libp2p);
|
|
17
|
+
_libp2p: import("../");
|
|
18
|
+
/**
|
|
19
|
+
* A handler to register with Libp2p to process ping messages
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} options
|
|
22
|
+
* @param {MuxedStream} options.stream
|
|
23
|
+
*/
|
|
24
|
+
handleMessage({ stream }: {
|
|
25
|
+
stream: MuxedStream;
|
|
26
|
+
}): any;
|
|
27
|
+
/**
|
|
28
|
+
* Ping a given peer and wait for its response, getting the operation latency.
|
|
29
|
+
*
|
|
30
|
+
* @param {PeerId|Multiaddr} peer
|
|
31
|
+
* @returns {Promise<number>}
|
|
32
|
+
*/
|
|
33
|
+
ping(peer: PeerId | Multiaddr): Promise<number>;
|
|
18
34
|
}
|
|
19
|
-
|
|
35
|
+
declare namespace PingService {
|
|
36
|
+
export { Libp2p, Multiaddr, PeerId, MuxedStream };
|
|
37
|
+
}
|
|
38
|
+
type MuxedStream = import('libp2p-interfaces/src/stream-muxer/types').MuxedStream;
|
|
20
39
|
type PeerId = import('peer-id');
|
|
21
40
|
type Multiaddr = import('multiaddr').Multiaddr;
|
|
22
|
-
|
|
23
|
-
* Subscribe ping protocol handler.
|
|
24
|
-
*
|
|
25
|
-
* @param {Libp2p} node
|
|
26
|
-
*/
|
|
27
|
-
declare function mount(node: Libp2p): void;
|
|
28
|
-
/**
|
|
29
|
-
* Unsubscribe ping protocol handler.
|
|
30
|
-
*
|
|
31
|
-
* @param {Libp2p} node
|
|
32
|
-
*/
|
|
33
|
-
declare function unmount(node: Libp2p): void;
|
|
34
|
-
type MuxedStream = import('libp2p-interfaces/src/stream-muxer/types').MuxedStream;
|
|
41
|
+
type Libp2p = import('../');
|
|
35
42
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ping/index.js"],"names":[],"mappings":";AAiBA;;;;;GAKG;AAEH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ping/index.js"],"names":[],"mappings":";AAiBA;;;;;GAKG;AAEH;IACE;;OAEG;IACH,8BAFW,OAAO,KAAK,CAAC,UAIvB;IAED;;OAEG;IACH,oBAFW,MAAM,EAIhB;IADC,uBAAqB;IAGvB;;;;;OAKG;IACH;QAFgC,MAAM,EAA3B,WAAW;YAIrB;IAED;;;;;OAKG;IACH,WAHW,MAAM,GAAC,SAAS,GACd,QAAQ,MAAM,CAAC,CA2B3B;CACF;;;;mBA5DY,OAAO,0CAA0C,EAAE,WAAW;cAD9D,OAAO,SAAS,CAAC;iBADjB,OAAO,WAAW,EAAE,SAAS;cAD7B,OAAO,KAAK,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export = PeerRecord;
|
|
2
2
|
/**
|
|
3
|
-
* @typedef {import('../../peer-store/
|
|
3
|
+
* @typedef {import('../../peer-store/types').Address} Address
|
|
4
4
|
* @typedef {import('libp2p-interfaces/src/record/types').Record} Record
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
@@ -56,5 +56,5 @@ import { Multiaddr } from "multiaddr";
|
|
|
56
56
|
*/
|
|
57
57
|
declare function createFromProtobuf(buf: Uint8Array): PeerRecord;
|
|
58
58
|
import { ENVELOPE_DOMAIN_PEER_RECORD } from "./consts";
|
|
59
|
-
type Address = import('../../peer-store/
|
|
59
|
+
type Address = import('../../peer-store/types').Address;
|
|
60
60
|
//# sourceMappingURL=index.d.ts.map
|