libp2p 0.35.4 → 0.35.8-bf1fc32

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 (93) hide show
  1. package/README.md +2 -2
  2. package/dist/index.min.js +55 -0
  3. package/dist/src/circuit/auto-relay.d.ts +8 -10
  4. package/dist/src/circuit/auto-relay.d.ts.map +1 -1
  5. package/dist/src/connection-manager/auto-dialler.d.ts +1 -1
  6. package/dist/src/connection-manager/auto-dialler.d.ts.map +1 -1
  7. package/dist/src/connection-manager/index.d.ts +1 -2
  8. package/dist/src/connection-manager/index.d.ts.map +1 -1
  9. package/dist/src/content-routing/utils.d.ts +3 -3
  10. package/dist/src/content-routing/utils.d.ts.map +1 -1
  11. package/dist/src/dht/dht-peer-routing.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 +20 -16
  14. package/dist/src/dialer/index.d.ts.map +1 -1
  15. package/dist/src/identify/index.d.ts +4 -4
  16. package/dist/src/identify/index.d.ts.map +1 -1
  17. package/dist/src/index.d.ts +14 -9
  18. package/dist/src/index.d.ts.map +1 -1
  19. package/dist/src/metrics/index.d.ts +9 -4
  20. package/dist/src/metrics/index.d.ts.map +1 -1
  21. package/dist/src/metrics/stats.d.ts +3 -1
  22. package/dist/src/metrics/stats.d.ts.map +1 -1
  23. package/dist/src/metrics/tracked-map.d.ts +8 -0
  24. package/dist/src/metrics/tracked-map.d.ts.map +1 -0
  25. package/dist/src/peer-routing.d.ts +1 -1
  26. package/dist/src/peer-routing.d.ts.map +1 -1
  27. package/dist/src/peer-store/address-book.d.ts +28 -84
  28. package/dist/src/peer-store/address-book.d.ts.map +1 -1
  29. package/dist/src/peer-store/index.d.ts +25 -94
  30. package/dist/src/peer-store/index.d.ts.map +1 -1
  31. package/dist/src/peer-store/key-book.d.ts +31 -15
  32. package/dist/src/peer-store/key-book.d.ts.map +1 -1
  33. package/dist/src/peer-store/metadata-book.d.ts +33 -29
  34. package/dist/src/peer-store/metadata-book.d.ts.map +1 -1
  35. package/dist/src/peer-store/pb/peer.d.ts +222 -0
  36. package/dist/src/peer-store/proto-book.d.ts +27 -28
  37. package/dist/src/peer-store/proto-book.d.ts.map +1 -1
  38. package/dist/src/peer-store/store.d.ts +73 -0
  39. package/dist/src/peer-store/store.d.ts.map +1 -0
  40. package/dist/src/peer-store/types.d.ts +202 -0
  41. package/dist/src/peer-store/types.d.ts.map +1 -0
  42. package/dist/src/ping/index.d.ts.map +1 -1
  43. package/dist/src/record/peer-record/index.d.ts +2 -2
  44. package/dist/src/record/peer-record/index.d.ts.map +1 -1
  45. package/dist/src/registrar.d.ts +5 -5
  46. package/dist/src/registrar.d.ts.map +1 -1
  47. package/dist/src/upgrader.d.ts.map +1 -1
  48. package/package.json +26 -30
  49. package/src/circuit/auto-relay.js +19 -19
  50. package/src/connection-manager/auto-dialler.js +9 -4
  51. package/src/connection-manager/index.js +41 -31
  52. package/src/content-routing/utils.js +4 -4
  53. package/src/dht/dht-peer-routing.js +2 -6
  54. package/src/dialer/dial-request.js +4 -1
  55. package/src/dialer/index.js +33 -21
  56. package/src/identify/index.js +28 -23
  57. package/src/index.js +43 -35
  58. package/src/metrics/index.js +15 -8
  59. package/src/metrics/stats.js +1 -0
  60. package/src/metrics/tracked-map.js +94 -0
  61. package/src/peer-routing.js +11 -1
  62. package/src/peer-store/address-book.js +242 -227
  63. package/src/peer-store/index.js +77 -110
  64. package/src/peer-store/key-book.js +99 -54
  65. package/src/peer-store/metadata-book.js +171 -101
  66. package/src/peer-store/pb/peer.d.ts +222 -0
  67. package/src/peer-store/pb/peer.js +643 -0
  68. package/src/peer-store/pb/peer.proto +31 -0
  69. package/src/peer-store/proto-book.js +171 -105
  70. package/src/peer-store/store.js +250 -0
  71. package/src/peer-store/types.ts +245 -0
  72. package/src/ping/index.js +6 -0
  73. package/src/record/peer-record/index.js +1 -1
  74. package/src/record/utils.js +1 -1
  75. package/src/registrar.js +4 -4
  76. package/src/upgrader.js +3 -1
  77. package/dist/src/peer-store/book.d.ts +0 -81
  78. package/dist/src/peer-store/book.d.ts.map +0 -1
  79. package/dist/src/peer-store/persistent/consts.d.ts +0 -6
  80. package/dist/src/peer-store/persistent/consts.d.ts.map +0 -1
  81. package/dist/src/peer-store/persistent/index.d.ts +0 -129
  82. package/dist/src/peer-store/persistent/index.d.ts.map +0 -1
  83. package/dist/src/peer-store/persistent/pb/address-book.d.ts +0 -198
  84. package/dist/src/peer-store/persistent/pb/proto-book.d.ts +0 -59
  85. package/src/peer-store/book.js +0 -124
  86. package/src/peer-store/persistent/consts.js +0 -15
  87. package/src/peer-store/persistent/index.js +0 -408
  88. package/src/peer-store/persistent/pb/address-book.d.ts +0 -198
  89. package/src/peer-store/persistent/pb/address-book.js +0 -522
  90. package/src/peer-store/persistent/pb/address-book.proto +0 -27
  91. package/src/peer-store/persistent/pb/proto-book.d.ts +0 -59
  92. package/src/peer-store/persistent/pb/proto-book.js +0 -157
  93. package/src/peer-store/persistent/pb/proto-book.proto +0 -5
@@ -1 +1 @@
1
- {"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/address-book.js"],"names":[],"mappings":";AAmBA;;GAEG;AAEH;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH;IACE;;;;;OAKG;IACH,uBAFW,SAAS,EA0BnB;IAED;;;;;;;OAOG;IACH,4BAHW,QAAQ,GACN,OAAO,CA8CnB;IAED;;;;;;OAMG;IACH,uBAHW,MAAM,GACJ,UAAU,GAAC,SAAS,CAUhC;IAED;;;;;;OAMG;IACH,sBAHW,MAAM,GACJ,QAAQ,QAAQ,GAAC,IAAI,CAAC,GAAC,SAAS,CAU5C;IAuDD;;;;;;;OAOG;IACH,YAJW,MAAM,cACN,SAAS,EAAE,GACT,WAAW,CA+CvB;IAmBD;;;;;;;OAOG;IACH,qBAyBC;IAED;;;;;;;;OAQG;IACH,6BAJW,MAAM,+BACM,OAAO,EAAE,KAAK,OAAO,EAAE,gBACjC,SAAS,EAAE,GAAC,SAAS,CAsBjC;CACF;;;;;;;;iBA3UY,OAAO,IAAI,CAAC;;;;;eAKX,SAAS;;;;iBACT,OAAO;;;;;;SAGP,UAAU;;;;eACV,MAAM;;;;;;eAGN,OAAO,EAAE;;;;YACT,eAAe"}
1
+ {"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/address-book.js"],"names":[],"mappings":";AAsBA;;GAEG;AACH;IACE;;;OAGG;IACH,kBAHW,SAAS,CAAC,MAAM,CAAC,SACjB,OAAO,SAAS,EAAE,KAAK,EAKjC;IAFC,2IAAiB;IACjB,gCAAmB;IAGrB;;;;;;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,iBAsDrB;IAED;;;OAGG;IACH,YAHW,MAAM,cACN,SAAS,EAAE,iBAqDrB;IAED;;OAEG;IACH,eAFW,MAAM,iBA4BhB;IAED;;;OAGG;IACH,6BAHW,MAAM,+BACM,OAAO,EAAE,KAAK,OAAO,EAAE,qCAe7C;CACF;;;;mBAnUY,OAAO,SAAS,EAAE,WAAW;;;;iBAF7B,OAAO,SAAS,EAAE,SAAS;eAC3B,OAAO,SAAS,EAAE,OAAO"}
@@ -1,124 +1,55 @@
1
- export = PeerStore;
1
+ export = DefaultPeerStore;
2
2
  /**
3
- * @typedef {import('./address-book').Address} Address
4
- */
5
- /**
6
- * @extends {EventEmitter}
3
+ * An implementation of PeerStore that stores data in a Datastore
7
4
  *
8
- * @fires PeerStore#peer Emitted when a new peer is added.
9
- * @fires PeerStore#change:protocols Emitted when a known peer supports a different set of protocols.
10
- * @fires PeerStore#change:multiaddrs Emitted when a known peer has a different set of multiaddrs.
11
- * @fires PeerStore#change:pubkey Emitted emitted when a peer's public key is known.
12
- * @fires PeerStore#change:metadata Emitted when the known metadata of a peer change.
5
+ * @implements {PeerStore}
13
6
  */
14
- declare class PeerStore extends EventEmitter {
15
- /**
16
- * Peer object
17
- *
18
- * @typedef {Object} Peer
19
- * @property {PeerId} id peer's peer-id instance.
20
- * @property {Address[]} addresses peer's addresses containing its multiaddrs and metadata.
21
- * @property {string[]} protocols peer's supported protocols.
22
- * @property {Map<string, Uint8Array>|undefined} metadata peer's metadata map.
23
- */
7
+ declare class DefaultPeerStore extends EventEmitter implements PeerStore {
24
8
  /**
25
- * Responsible for managing known peers, as well as their addresses, protocols and metadata.
26
- *
27
- * @param {object} options
28
- * @param {PeerId} options.peerId
29
- * @class
9
+ * @param {object} properties
10
+ * @param {PeerId} properties.peerId
11
+ * @param {import('interface-datastore').Datastore} properties.datastore
30
12
  */
31
- constructor({ peerId }: {
13
+ constructor({ peerId, datastore }: {
32
14
  peerId: PeerId;
15
+ datastore: import('interface-datastore').Datastore;
33
16
  });
34
- _peerId: PeerId;
35
- /**
36
- * AddressBook containing a map of peerIdStr to Address.
37
- */
17
+ _peerId: import("peer-id");
18
+ _store: Store;
38
19
  addressBook: AddressBook;
39
- /**
40
- * KeyBook containing a map of peerIdStr to their PeerId with public keys.
41
- */
42
20
  keyBook: KeyBook;
43
- /**
44
- * MetadataBook containing a map of peerIdStr to their metadata Map.
45
- */
46
21
  metadataBook: MetadataBook;
47
- /**
48
- * ProtoBook containing a map of peerIdStr to supported protocols.
49
- */
50
22
  protoBook: ProtoBook;
23
+ getPeers(): AsyncGenerator<import("./types").Peer, void, unknown>;
51
24
  /**
52
- * Start the PeerStore.
53
- */
54
- start(): void;
55
- /**
56
- * Stop the PeerStore.
57
- */
58
- stop(): void;
59
- /**
60
- * Get all the stored information of every peer known.
25
+ * Delete the information of the given peer in every book
61
26
  *
62
- * @returns {Map<string, Peer>}
27
+ * @param {PeerId} peerId
63
28
  */
64
- get peers(): Map<string, {
65
- /**
66
- * peer's peer-id instance.
67
- */
68
- id: PeerId;
69
- /**
70
- * peer's addresses containing its multiaddrs and metadata.
71
- */
72
- addresses: Address[];
73
- /**
74
- * peer's supported protocols.
75
- */
76
- protocols: string[];
77
- /**
78
- * peer's metadata map.
79
- */
80
- metadata: Map<string, Uint8Array> | undefined;
81
- }>;
29
+ delete(peerId: PeerId): Promise<void>;
82
30
  /**
83
- * Delete the information of the given peer in every book.
31
+ * Get the stored information of a given peer
84
32
  *
85
33
  * @param {PeerId} peerId
86
- * @returns {boolean} true if found and removed
87
34
  */
88
- delete(peerId: PeerId): boolean;
35
+ get(peerId: PeerId): Promise<import("./types").Peer>;
89
36
  /**
90
- * Get the stored information of a given peer.
37
+ * Returns true if we have a record of the peer
91
38
  *
92
39
  * @param {PeerId} peerId
93
- * @returns {Peer|undefined}
94
40
  */
95
- get(peerId: PeerId): {
96
- /**
97
- * peer's peer-id instance.
98
- */
99
- id: PeerId;
100
- /**
101
- * peer's addresses containing its multiaddrs and metadata.
102
- */
103
- addresses: Address[];
104
- /**
105
- * peer's supported protocols.
106
- */
107
- protocols: string[];
108
- /**
109
- * peer's metadata map.
110
- */
111
- metadata: Map<string, Uint8Array> | undefined;
112
- } | undefined;
41
+ has(peerId: PeerId): Promise<boolean>;
113
42
  }
114
- declare namespace PeerStore {
115
- export { Address };
43
+ declare namespace DefaultPeerStore {
44
+ export { PeerStore, Peer, PeerId };
116
45
  }
46
+ type PeerStore = import('./types').PeerStore;
117
47
  import { EventEmitter } from "events";
118
- import PeerId = require("peer-id");
48
+ import Store = require("./store");
119
49
  import AddressBook = require("./address-book");
120
50
  import KeyBook = require("./key-book");
121
51
  import MetadataBook = require("./metadata-book");
122
52
  import ProtoBook = require("./proto-book");
123
- type Address = import('./address-book').Address;
53
+ type PeerId = import('peer-id');
54
+ type Peer = import('./types').Peer;
124
55
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-store/index.js"],"names":[],"mappings":";AAgBA;;GAEG;AAEH;;;;;;;;GAQG;AACH;IACE;;;;;;;;OAQG;IAEH;;;;;;OAMG;IACH;QAH2B,MAAM,EAAtB,MAAM;OA2BhB;IArBC,gBAAqB;IAErB;;OAEG;IACH,yBAAwC;IAExC;;OAEG;IACH,iBAAgC;IAEhC;;OAEG;IACH,2BAA0C;IAE1C;;OAEG;IACH,qBAAoC;IAGtC;;OAEG;IACH,cAAW;IAEX;;OAEG;IACH,aAAU;IAEV;;;;OAIG;IACH;;;;YAtDc,MAAM;;;;mBACN,OAAO,EAAE;;;;mBACT,MAAM,EAAE;;;;kBACR,IAAI,MAAM,EAAE,UAAU,CAAC,GAAC,SAAS;OAoE9C;IAED;;;;;OAKG;IACH,eAHW,MAAM,GACJ,OAAO,CASnB;IAED;;;;;OAKG;IACH,YAHW,MAAM;;;;YA3FH,MAAM;;;;mBACN,OAAO,EAAE;;;;mBACT,MAAM,EAAE;;;;kBACR,IAAI,MAAM,EAAE,UAAU,CAAC,GAAC,SAAS;kBA+G9C;CACF;;;;;;;;;;eApIY,OAAO,gBAAgB,EAAE,OAAO"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-store/index.js"],"names":[],"mappings":";AAoBA;;;;GAIG;AACH;IACE;;;;OAIG;IACH;QAH8B,MAAM,EAAzB,MAAM;QAC8C,SAAS,EAA7D,OAAO,qBAAqB,EAAE,SAAS;OAYjD;IAPC,2BAAqB;IACrB,cAAkC;IAElC,yBAAqE;IACrE,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;;;;iBAzGY,OAAO,SAAS,EAAE,SAAS;;;;;;;cAE3B,OAAO,SAAS,CAAC;YADjB,OAAO,SAAS,EAAE,IAAI"}
@@ -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"}