libp2p 0.35.8 → 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.
Files changed (107) hide show
  1. package/dist/index.min.js +55 -0
  2. package/dist/src/circuit/auto-relay.d.ts +8 -10
  3. package/dist/src/circuit/auto-relay.d.ts.map +1 -1
  4. package/dist/src/config.d.ts +2 -0
  5. package/dist/src/config.d.ts.map +1 -1
  6. package/dist/src/connection-manager/auto-dialler.d.ts +1 -1
  7. package/dist/src/connection-manager/auto-dialler.d.ts.map +1 -1
  8. package/dist/src/connection-manager/index.d.ts +1 -2
  9. package/dist/src/connection-manager/index.d.ts.map +1 -1
  10. package/dist/src/content-routing/utils.d.ts +3 -3
  11. package/dist/src/content-routing/utils.d.ts.map +1 -1
  12. package/dist/src/dialer/dial-request.d.ts.map +1 -1
  13. package/dist/src/dialer/index.d.ts +12 -7
  14. package/dist/src/dialer/index.d.ts.map +1 -1
  15. package/dist/src/errors.d.ts +2 -0
  16. package/dist/src/fetch/constants.d.ts +2 -0
  17. package/dist/src/fetch/constants.d.ts.map +1 -0
  18. package/dist/src/fetch/index.d.ts +76 -0
  19. package/dist/src/fetch/index.d.ts.map +1 -0
  20. package/dist/src/fetch/proto.d.ts +134 -0
  21. package/dist/src/identify/index.d.ts +4 -4
  22. package/dist/src/identify/index.d.ts.map +1 -1
  23. package/dist/src/index.d.ts +116 -7
  24. package/dist/src/index.d.ts.map +1 -1
  25. package/dist/src/metrics/index.d.ts +9 -4
  26. package/dist/src/metrics/index.d.ts.map +1 -1
  27. package/dist/src/metrics/tracked-map.d.ts +6 -1
  28. package/dist/src/metrics/tracked-map.d.ts.map +1 -1
  29. package/dist/src/peer-routing.d.ts +1 -1
  30. package/dist/src/peer-routing.d.ts.map +1 -1
  31. package/dist/src/peer-store/address-book.d.ts +30 -84
  32. package/dist/src/peer-store/address-book.d.ts.map +1 -1
  33. package/dist/src/peer-store/index.d.ts +28 -94
  34. package/dist/src/peer-store/index.d.ts.map +1 -1
  35. package/dist/src/peer-store/key-book.d.ts +31 -15
  36. package/dist/src/peer-store/key-book.d.ts.map +1 -1
  37. package/dist/src/peer-store/metadata-book.d.ts +33 -29
  38. package/dist/src/peer-store/metadata-book.d.ts.map +1 -1
  39. package/dist/src/peer-store/pb/peer.d.ts +222 -0
  40. package/dist/src/peer-store/proto-book.d.ts +27 -28
  41. package/dist/src/peer-store/proto-book.d.ts.map +1 -1
  42. package/dist/src/peer-store/store.d.ts +73 -0
  43. package/dist/src/peer-store/store.d.ts.map +1 -0
  44. package/dist/src/peer-store/types.d.ts +202 -0
  45. package/dist/src/peer-store/types.d.ts.map +1 -0
  46. package/dist/src/ping/index.d.ts.map +1 -1
  47. package/dist/src/record/peer-record/index.d.ts +2 -2
  48. package/dist/src/record/peer-record/index.d.ts.map +1 -1
  49. package/dist/src/registrar.d.ts +5 -5
  50. package/dist/src/registrar.d.ts.map +1 -1
  51. package/dist/src/types.d.ts +90 -0
  52. package/dist/src/types.d.ts.map +1 -0
  53. package/dist/src/upgrader.d.ts +8 -2
  54. package/dist/src/upgrader.d.ts.map +1 -1
  55. package/package.json +23 -26
  56. package/src/circuit/auto-relay.js +52 -38
  57. package/src/config.js +2 -0
  58. package/src/connection-manager/auto-dialler.js +20 -8
  59. package/src/connection-manager/index.js +42 -22
  60. package/src/content-routing/utils.js +4 -4
  61. package/src/dialer/dial-request.js +4 -1
  62. package/src/dialer/index.js +38 -8
  63. package/src/errors.js +2 -0
  64. package/src/fetch/README.md +36 -0
  65. package/src/fetch/constants.js +6 -0
  66. package/src/fetch/index.js +159 -0
  67. package/src/fetch/proto.d.ts +134 -0
  68. package/src/fetch/proto.js +333 -0
  69. package/src/fetch/proto.proto +15 -0
  70. package/src/identify/index.js +47 -38
  71. package/src/index.js +72 -27
  72. package/src/metrics/index.js +15 -8
  73. package/src/metrics/tracked-map.js +40 -14
  74. package/src/peer-routing.js +4 -1
  75. package/src/peer-store/address-book.js +254 -226
  76. package/src/peer-store/index.js +79 -110
  77. package/src/peer-store/key-book.js +99 -54
  78. package/src/peer-store/metadata-book.js +171 -101
  79. package/src/peer-store/pb/peer.d.ts +222 -0
  80. package/src/peer-store/pb/peer.js +643 -0
  81. package/src/peer-store/pb/peer.proto +31 -0
  82. package/src/peer-store/proto-book.js +171 -105
  83. package/src/peer-store/store.js +263 -0
  84. package/src/peer-store/types.ts +245 -0
  85. package/src/ping/index.js +6 -0
  86. package/src/record/peer-record/index.js +1 -1
  87. package/src/record/utils.js +1 -1
  88. package/src/registrar.js +4 -4
  89. package/src/types.ts +98 -0
  90. package/src/upgrader.js +32 -2
  91. package/dist/src/peer-store/book.d.ts +0 -81
  92. package/dist/src/peer-store/book.d.ts.map +0 -1
  93. package/dist/src/peer-store/persistent/consts.d.ts +0 -6
  94. package/dist/src/peer-store/persistent/consts.d.ts.map +0 -1
  95. package/dist/src/peer-store/persistent/index.d.ts +0 -129
  96. package/dist/src/peer-store/persistent/index.d.ts.map +0 -1
  97. package/dist/src/peer-store/persistent/pb/address-book.d.ts +0 -198
  98. package/dist/src/peer-store/persistent/pb/proto-book.d.ts +0 -59
  99. package/src/peer-store/book.js +0 -124
  100. package/src/peer-store/persistent/consts.js +0 -15
  101. package/src/peer-store/persistent/index.js +0 -408
  102. package/src/peer-store/persistent/pb/address-book.d.ts +0 -198
  103. package/src/peer-store/persistent/pb/address-book.js +0 -522
  104. package/src/peer-store/persistent/pb/address-book.proto +0 -27
  105. package/src/peer-store/persistent/pb/proto-book.d.ts +0 -59
  106. package/src/peer-store/persistent/pb/proto-book.js +0 -157
  107. package/src/peer-store/persistent/pb/proto-book.proto +0 -5
@@ -1,24 +1,40 @@
1
- export = KeyBook;
1
+ export = PeerStoreKeyBook;
2
2
  /**
3
- * @typedef {import('./')} PeerStore
4
- * @typedef {import('libp2p-crypto').PublicKey} PublicKey
3
+ * @implements {KeyBook}
5
4
  */
6
- /**
7
- * @extends {Book}
8
- */
9
- declare class KeyBook extends Book {
5
+ declare class PeerStoreKeyBook implements KeyBook {
10
6
  /**
11
7
  * The KeyBook is responsible for keeping the known public keys of a peer.
12
8
  *
13
- * @class
14
- * @param {PeerStore} peerStore
9
+ * @param {PeerStore["emit"]} emit
10
+ * @param {import('./types').Store} store
11
+ */
12
+ constructor(emit: PeerStore["emit"], store: import('./types').Store);
13
+ _emit: <U extends keyof import("./types").PeerStoreEvents>(event: U, ...args: Parameters<import("./types").PeerStoreEvents[U]>) => boolean;
14
+ _store: import("./types").Store;
15
+ /**
16
+ * Set the Peer public key
17
+ *
18
+ * @param {PeerId} peerId
19
+ * @param {PublicKey} publicKey
20
+ */
21
+ set(peerId: PeerId, publicKey: PublicKey): Promise<void>;
22
+ /**
23
+ * Get Public key of the given PeerId, if stored
24
+ *
25
+ * @param {PeerId} peerId
26
+ */
27
+ get(peerId: PeerId): Promise<import("libp2p-interfaces/src/keys/types").PublicKey | undefined>;
28
+ /**
29
+ * @param {PeerId} peerId
15
30
  */
16
- constructor(peerStore: PeerStore);
31
+ delete(peerId: PeerId): Promise<void>;
17
32
  }
18
- declare namespace KeyBook {
19
- export { PeerStore, PublicKey };
33
+ declare namespace PeerStoreKeyBook {
34
+ export { PeerStore, KeyBook, PublicKey };
20
35
  }
21
- import Book = require("./book");
22
- type PeerStore = import('./');
23
- type PublicKey = import('libp2p-crypto').PublicKey;
36
+ type KeyBook = import('./types').KeyBook;
37
+ import PeerId = require("peer-id");
38
+ type PublicKey = import('libp2p-interfaces/src/keys/types').PublicKey;
39
+ type PeerStore = import('./types').PeerStore;
24
40
  //# sourceMappingURL=key-book.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"key-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/key-book.js"],"names":[],"mappings":";AAgBA;;;GAGG;AAEH;;GAEG;AACH;IACE;;;;;OAKG;IACH,uBAFW,SAAS,EAgBnB;CAgDF;;;;;iBA5EY,OAAO,IAAI,CAAC;iBACZ,OAAO,eAAe,EAAE,SAAS"}
1
+ {"version":3,"file":"key-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/key-book.js"],"names":[],"mappings":";AAoBA;;GAEG;AACH;IACE;;;;;OAKG;IACH,kBAHW,SAAS,CAAC,MAAM,CAAC,SACjB,OAAO,SAAS,EAAE,KAAK,EAKjC;IAFC,2IAAiB;IACjB,gCAAmB;IAGrB;;;;;OAKG;IACH,YAHW,MAAM,aACN,SAAS,iBA4CnB;IAED;;;;OAIG;IACH,YAFW,MAAM,6EAwBhB;IAED;;OAEG;IACH,eAFW,MAAM,iBAsBhB;CACF;;;;eAhIY,OAAO,SAAS,EAAE,OAAO;;iBACzB,OAAO,kCAAkC,EAAE,SAAS;iBAFpD,OAAO,SAAS,EAAE,SAAS"}
@@ -1,54 +1,58 @@
1
- export = MetadataBook;
1
+ export = PeerStoreMetadataBook;
2
2
  /**
3
- * @typedef {import('./')} PeerStore
3
+ * @implements {MetadataBook}
4
4
  */
5
- /**
6
- * @extends {Book}
7
- *
8
- * @fires MetadataBook#change:metadata
9
- */
10
- declare class MetadataBook extends Book {
5
+ declare class PeerStoreMetadataBook implements MetadataBook {
11
6
  /**
12
7
  * The MetadataBook is responsible for keeping the known supported
13
- * protocols of a peer.
8
+ * protocols of a peer
14
9
  *
15
- * @class
16
- * @param {PeerStore} peerStore
10
+ * @param {PeerStore["emit"]} emit
11
+ * @param {import('./types').Store} store
17
12
  */
18
- constructor(peerStore: PeerStore);
13
+ constructor(emit: PeerStore["emit"], store: import('./types').Store);
14
+ _emit: <U extends keyof import("./types").PeerStoreEvents>(event: U, ...args: Parameters<import("./types").PeerStoreEvents[U]>) => boolean;
15
+ _store: import("./types").Store;
19
16
  /**
20
- * Set data into the datastructure
17
+ * Get the known data of a provided peer
21
18
  *
22
19
  * @param {PeerId} peerId
23
- * @param {string} key
24
- * @param {Uint8Array} value
25
- * @param {object} [opts]
26
- * @param {boolean} [opts.emit]
27
20
  */
28
- _setValue(peerId: PeerId, key: string, value: Uint8Array, { emit }?: {
29
- emit?: boolean | undefined;
30
- } | undefined): void;
21
+ get(peerId: PeerId): Promise<Map<any, any>>;
31
22
  /**
32
23
  * Get specific metadata value, if it exists
33
24
  *
34
25
  * @param {PeerId} peerId
35
26
  * @param {string} key
36
- * @returns {Uint8Array | undefined}
37
27
  */
38
- getValue(peerId: PeerId, key: string): Uint8Array | undefined;
28
+ getValue(peerId: PeerId, key: string): Promise<Uint8Array | undefined>;
29
+ /**
30
+ * @param {PeerId} peerId
31
+ * @param {Map<string, Uint8Array>} metadata
32
+ */
33
+ set(peerId: PeerId, metadata: Map<string, Uint8Array>): Promise<void>;
39
34
  /**
40
- * Deletes the provided peer metadata key from the book.
35
+ * Set metadata key and value of a provided peer
41
36
  *
37
+ * @param {PeerId} peerId
38
+ * @param {string} key - metadata key
39
+ * @param {Uint8Array} value - metadata value
40
+ */
41
+ setValue(peerId: PeerId, key: string, value: Uint8Array): Promise<void>;
42
+ /**
43
+ * @param {PeerId} peerId
44
+ */
45
+ delete(peerId: PeerId): Promise<void>;
46
+ /**
42
47
  * @param {PeerId} peerId
43
48
  * @param {string} key
44
- * @returns {boolean}
45
49
  */
46
- deleteValue(peerId: PeerId, key: string): boolean;
50
+ deleteValue(peerId: PeerId, key: string): Promise<void>;
47
51
  }
48
- declare namespace MetadataBook {
49
- export { PeerStore };
52
+ declare namespace PeerStoreMetadataBook {
53
+ export { PeerStore, MetadataBook };
50
54
  }
51
- import Book = require("./book");
55
+ type MetadataBook = import('./types').MetadataBook;
52
56
  import PeerId = require("peer-id");
53
- type PeerStore = import('./');
57
+ type PeerStore = import('./types').PeerStore;
54
58
  //# sourceMappingURL=metadata-book.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"metadata-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/metadata-book.js"],"names":[],"mappings":";AAiBA;;GAEG;AAEH;;;;GAIG;AACH;IACE;;;;;;OAMG;IACH,uBAFW,SAAS,EAmBnB;IA4BD;;;;;;;;OAQG;IACH,kBANW,MAAM,OACN,MAAM,SACN,UAAU;;yBAmBpB;IAgBD;;;;;;OAMG;IACH,iBAJW,MAAM,OACN,MAAM,GACJ,UAAU,GAAG,SAAS,CASlC;IAsBD;;;;;;OAMG;IACH,oBAJW,MAAM,OACN,MAAM,GACJ,OAAO,CAgBnB;CACF;;;;;;iBA/JY,OAAO,IAAI,CAAC"}
1
+ {"version":3,"file":"metadata-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/metadata-book.js"],"names":[],"mappings":";AAmBA;;GAEG;AACH;IACE;;;;;;OAMG;IACH,kBAHW,SAAS,CAAC,MAAM,CAAC,SACjB,OAAO,SAAS,EAAE,KAAK,EAKjC;IAFC,2IAAiB;IACjB,gCAAmB;IAGrB;;;;OAIG;IACH,YAFW,MAAM,0BA0BhB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,OACN,MAAM,mCAwBhB;IAED;;;OAGG;IACH,YAHW,MAAM,YACN,IAAI,MAAM,EAAE,UAAU,CAAC,iBA2BjC;IAED;;;;;;OAMG;IACH,iBAJW,MAAM,OACN,MAAM,SACN,UAAU,iBA0CpB;IAED;;OAEG;IACH,eAFW,MAAM,iBA8BhB;IAED;;;OAGG;IACH,oBAHW,MAAM,OACN,MAAM,iBAmChB;CACF;;;;oBAzOY,OAAO,SAAS,EAAE,YAAY;;iBAD9B,OAAO,SAAS,EAAE,SAAS"}
@@ -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 = ProtoBook;
1
+ export = PersistentProtoBook;
2
2
  /**
3
- * @typedef {import('./')} PeerStore
3
+ * @implements {ProtoBook}
4
4
  */
5
- /**
6
- * @extends {Book}
7
- *
8
- * @fires ProtoBook#change:protocols
9
- */
10
- declare class ProtoBook extends Book {
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
- * The ProtoBook is responsible for keeping the known supported
13
- * protocols of a peer.
14
- *
15
- * @class
16
- * @param {PeerStore} peerStore
18
+ * @param {PeerId} peerId
19
+ * @param {string[]} protocols
17
20
  */
18
- constructor(peerStore: PeerStore);
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[]): ProtoBook;
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[]): ProtoBook;
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 ProtoBook {
39
- export { PeerStore };
37
+ declare namespace PersistentProtoBook {
38
+ export { PeerStore, ProtoBook };
40
39
  }
41
- import Book = require("./book");
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":";AAeA;;GAEG;AAEH;;;;GAIG;AACH;IACE;;;;;;OAMG;IACH,uBAFW,SAAS,EAoBnB;IA6CD;;;;;;;OAOG;IACH,YAJW,MAAM,aACN,MAAM,EAAE,GACN,SAAS,CA2BrB;IAED;;;;;;;OAOG;IACH,eAJW,MAAM,aACN,MAAM,EAAE,GACN,SAAS,CA+BrB;CACF;;;;;;iBAxJY,OAAO,IAAI,CAAC"}
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"}