libp2p 0.36.0 → 0.36.2-199395d

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 (398) hide show
  1. package/LICENSE +3 -21
  2. package/README.md +13 -10
  3. package/dist/src/address-manager/index.d.ts +33 -52
  4. package/dist/src/address-manager/index.d.ts.map +1 -1
  5. package/dist/src/address-manager/index.js +81 -0
  6. package/dist/src/address-manager/index.js.map +1 -0
  7. package/dist/src/circuit/auto-relay.d.ts +24 -85
  8. package/dist/src/circuit/auto-relay.d.ts.map +1 -1
  9. package/dist/src/circuit/auto-relay.js +215 -0
  10. package/dist/src/circuit/auto-relay.js.map +1 -0
  11. package/dist/src/circuit/circuit/hop.d.ts +25 -52
  12. package/dist/src/circuit/circuit/hop.d.ts.map +1 -1
  13. package/dist/src/circuit/circuit/hop.js +138 -0
  14. package/dist/src/circuit/circuit/hop.js.map +1 -0
  15. package/dist/src/circuit/circuit/stop.d.ts +16 -8
  16. package/dist/src/circuit/circuit/stop.d.ts.map +1 -1
  17. package/dist/src/circuit/circuit/stop.js +49 -0
  18. package/dist/src/circuit/circuit/stop.js.map +1 -0
  19. package/dist/src/circuit/circuit/stream-handler.d.ts +16 -35
  20. package/dist/src/circuit/circuit/stream-handler.d.ts.map +1 -1
  21. package/dist/src/circuit/circuit/stream-handler.js +60 -0
  22. package/dist/src/circuit/circuit/stream-handler.js.map +1 -0
  23. package/dist/src/circuit/circuit/utils.d.ts +3 -6
  24. package/dist/src/circuit/circuit/utils.d.ts.map +1 -1
  25. package/dist/src/circuit/circuit/utils.js +43 -0
  26. package/dist/src/circuit/circuit/utils.js.map +1 -0
  27. package/dist/src/circuit/constants.d.ts +24 -6
  28. package/dist/src/circuit/constants.d.ts.map +1 -1
  29. package/dist/src/circuit/constants.js +26 -0
  30. package/dist/src/circuit/constants.js.map +1 -0
  31. package/dist/src/circuit/index.d.ts +41 -74
  32. package/dist/src/circuit/index.d.ts.map +1 -1
  33. package/dist/src/circuit/index.js +69 -0
  34. package/dist/src/circuit/index.js.map +1 -0
  35. package/dist/src/circuit/listener.d.ts +8 -3
  36. package/dist/src/circuit/listener.d.ts.map +1 -1
  37. package/dist/src/circuit/listener.js +54 -0
  38. package/dist/src/circuit/listener.js.map +1 -0
  39. package/dist/src/circuit/multicodec.d.ts +1 -1
  40. package/dist/src/circuit/multicodec.d.ts.map +1 -1
  41. package/dist/src/circuit/multicodec.js +2 -0
  42. package/dist/src/circuit/multicodec.js.map +1 -0
  43. package/dist/src/circuit/{protocol → pb}/index.d.ts +0 -0
  44. package/{src/circuit/protocol → dist/src/circuit/pb}/index.js +7 -9
  45. package/dist/src/circuit/transport.d.ts +18 -78
  46. package/dist/src/circuit/transport.d.ts.map +1 -1
  47. package/dist/src/circuit/transport.js +190 -0
  48. package/dist/src/circuit/transport.js.map +1 -0
  49. package/dist/src/circuit/utils.d.ts +5 -2
  50. package/dist/src/circuit/utils.d.ts.map +1 -1
  51. package/dist/src/circuit/utils.js +11 -0
  52. package/dist/src/circuit/utils.js.map +1 -0
  53. package/dist/src/config.d.ts +3 -85
  54. package/dist/src/config.d.ts.map +1 -1
  55. package/dist/src/config.js +93 -0
  56. package/dist/src/config.js.map +1 -0
  57. package/dist/src/connection-manager/auto-dialler.d.ts +24 -41
  58. package/dist/src/connection-manager/auto-dialler.d.ts.map +1 -1
  59. package/dist/src/connection-manager/auto-dialler.js +105 -0
  60. package/dist/src/connection-manager/auto-dialler.js.map +1 -0
  61. package/dist/src/connection-manager/index.d.ts +79 -144
  62. package/dist/src/connection-manager/index.d.ts.map +1 -1
  63. package/dist/src/connection-manager/index.js +295 -0
  64. package/dist/src/connection-manager/index.js.map +1 -0
  65. package/dist/src/connection-manager/latency-monitor.d.ts +72 -97
  66. package/dist/src/connection-manager/latency-monitor.d.ts.map +1 -1
  67. package/dist/src/connection-manager/latency-monitor.js +220 -0
  68. package/dist/src/connection-manager/latency-monitor.js.map +1 -0
  69. package/dist/src/connection-manager/visibility-change-emitter.d.ts +15 -16
  70. package/dist/src/connection-manager/visibility-change-emitter.d.ts.map +1 -1
  71. package/dist/src/connection-manager/visibility-change-emitter.js +118 -0
  72. package/dist/src/connection-manager/visibility-change-emitter.js.map +1 -0
  73. package/dist/src/constants.d.ts +22 -10
  74. package/dist/src/constants.d.ts.map +1 -1
  75. package/dist/src/constants.js +27 -0
  76. package/dist/src/constants.js.map +1 -0
  77. package/dist/src/content-routing/index.d.ts +26 -81
  78. package/dist/src/content-routing/index.d.ts.map +1 -1
  79. package/dist/src/content-routing/index.js +99 -0
  80. package/dist/src/content-routing/index.js.map +1 -0
  81. package/dist/src/content-routing/utils.d.ts +6 -49
  82. package/dist/src/content-routing/utils.d.ts.map +1 -1
  83. package/dist/src/content-routing/utils.js +42 -0
  84. package/dist/src/content-routing/utils.js.map +1 -0
  85. package/dist/src/dht/dht-content-routing.d.ts +10 -24
  86. package/dist/src/dht/dht-content-routing.d.ts.map +1 -1
  87. package/dist/src/dht/dht-content-routing.js +32 -0
  88. package/dist/src/dht/dht-content-routing.js.map +1 -0
  89. package/dist/src/dht/dht-peer-routing.d.ts +9 -24
  90. package/dist/src/dht/dht-peer-routing.d.ts.map +1 -1
  91. package/dist/src/dht/dht-peer-routing.js +26 -0
  92. package/dist/src/dht/dht-peer-routing.js.map +1 -0
  93. package/dist/src/dialer/auto-dialer.d.ts +14 -0
  94. package/dist/src/dialer/auto-dialer.d.ts.map +1 -0
  95. package/dist/src/dialer/auto-dialer.js +24 -0
  96. package/dist/src/dialer/auto-dialer.js.map +1 -0
  97. package/dist/src/dialer/dial-request.d.ts +18 -46
  98. package/dist/src/dialer/dial-request.d.ts.map +1 -1
  99. package/dist/src/dialer/dial-request.js +83 -0
  100. package/dist/src/dialer/dial-request.js.map +1 -0
  101. package/dist/src/dialer/index.d.ts +41 -148
  102. package/dist/src/dialer/index.d.ts.map +1 -1
  103. package/dist/src/dialer/index.js +281 -0
  104. package/dist/src/dialer/index.js.map +1 -0
  105. package/dist/src/errors.d.ts +68 -63
  106. package/dist/src/errors.d.ts.map +1 -1
  107. package/dist/src/errors.js +73 -0
  108. package/dist/src/errors.js.map +1 -0
  109. package/dist/src/fetch/constants.d.ts +1 -1
  110. package/dist/src/fetch/constants.d.ts.map +1 -1
  111. package/dist/src/fetch/constants.js +3 -0
  112. package/dist/src/fetch/constants.js.map +1 -0
  113. package/dist/src/fetch/index.d.ts +30 -49
  114. package/dist/src/fetch/index.d.ts.map +1 -1
  115. package/dist/src/fetch/index.js +130 -0
  116. package/dist/src/fetch/index.js.map +1 -0
  117. package/dist/src/fetch/{proto.d.ts → pb/proto.d.ts} +0 -0
  118. package/{src/fetch → dist/src/fetch/pb}/proto.js +7 -9
  119. package/dist/src/get-peer.d.ts +4 -11
  120. package/dist/src/get-peer.d.ts.map +1 -1
  121. package/dist/src/get-peer.js +43 -0
  122. package/dist/src/get-peer.js.map +1 -0
  123. package/dist/src/identify/consts.d.ts +9 -9
  124. package/dist/src/identify/consts.d.ts.map +1 -1
  125. package/dist/src/identify/consts.js +11 -0
  126. package/dist/src/identify/consts.js.map +1 -0
  127. package/dist/src/identify/index.d.ts +40 -96
  128. package/dist/src/identify/index.d.ts.map +1 -1
  129. package/dist/src/identify/index.js +322 -0
  130. package/dist/src/identify/index.js.map +1 -0
  131. package/{src/identify → dist/src/identify/pb}/message.d.ts +20 -5
  132. package/{src/identify → dist/src/identify/pb}/message.js +83 -42
  133. package/dist/src/index.d.ts +157 -583
  134. package/dist/src/index.d.ts.map +1 -1
  135. package/dist/src/index.js +9 -0
  136. package/dist/src/index.js.map +1 -0
  137. package/dist/src/insecure/index.d.ts +9 -0
  138. package/dist/src/insecure/index.d.ts.map +1 -0
  139. package/dist/src/insecure/index.js +78 -0
  140. package/dist/src/insecure/index.js.map +1 -0
  141. package/dist/src/insecure/{proto.d.ts → pb/proto.d.ts} +7 -1
  142. package/{src/insecure → dist/src/insecure/pb}/proto.js +39 -22
  143. package/dist/src/keychain/cms.d.ts +6 -14
  144. package/dist/src/keychain/cms.d.ts.map +1 -1
  145. package/dist/src/keychain/cms.js +129 -0
  146. package/dist/src/keychain/cms.js.map +1 -0
  147. package/dist/src/keychain/index.d.ts +62 -82
  148. package/dist/src/keychain/index.d.ts.map +1 -1
  149. package/dist/src/keychain/index.js +493 -0
  150. package/dist/src/keychain/index.js.map +1 -0
  151. package/dist/src/keychain/util.d.ts +3 -6
  152. package/dist/src/keychain/util.d.ts.map +1 -1
  153. package/dist/src/keychain/util.js +79 -0
  154. package/dist/src/keychain/util.js.map +1 -0
  155. package/dist/src/libp2p.d.ts +75 -0
  156. package/dist/src/libp2p.d.ts.map +1 -0
  157. package/dist/src/libp2p.js +368 -0
  158. package/dist/src/libp2p.js.map +1 -0
  159. package/dist/src/metrics/index.d.ts +47 -104
  160. package/dist/src/metrics/index.d.ts.map +1 -1
  161. package/dist/src/metrics/index.js +231 -0
  162. package/dist/src/metrics/index.js.map +1 -0
  163. package/dist/src/metrics/moving-average.d.ts +14 -0
  164. package/dist/src/metrics/moving-average.d.ts.map +1 -0
  165. package/dist/src/metrics/moving-average.js +40 -0
  166. package/dist/src/metrics/moving-average.js.map +1 -0
  167. package/dist/src/metrics/stats.d.ts +45 -93
  168. package/dist/src/metrics/stats.d.ts.map +1 -1
  169. package/dist/src/metrics/stats.js +183 -0
  170. package/dist/src/metrics/stats.js.map +1 -0
  171. package/dist/src/nat-manager.d.ts +42 -99
  172. package/dist/src/nat-manager.d.ts.map +1 -1
  173. package/dist/src/nat-manager.js +114 -0
  174. package/dist/src/nat-manager.js.map +1 -0
  175. package/dist/src/peer-record-updater.d.ts +15 -0
  176. package/dist/src/peer-record-updater.d.ts.map +1 -0
  177. package/dist/src/peer-record-updater.js +44 -0
  178. package/dist/src/peer-record-updater.js.map +1 -0
  179. package/dist/src/peer-routing.d.ts +39 -84
  180. package/dist/src/peer-routing.d.ts.map +1 -1
  181. package/dist/src/peer-routing.js +108 -0
  182. package/dist/src/peer-routing.js.map +1 -0
  183. package/dist/src/ping/constants.d.ts +4 -4
  184. package/dist/src/ping/constants.d.ts.map +1 -1
  185. package/dist/src/ping/constants.js +5 -0
  186. package/dist/src/ping/constants.js.map +1 -0
  187. package/dist/src/ping/index.d.ts +26 -33
  188. package/dist/src/ping/index.d.ts.map +1 -1
  189. package/dist/src/ping/index.js +56 -0
  190. package/dist/src/ping/index.js.map +1 -0
  191. package/dist/src/pnet/crypto.d.ts +15 -5
  192. package/dist/src/pnet/crypto.d.ts.map +1 -1
  193. package/dist/src/pnet/crypto.js +60 -0
  194. package/dist/src/pnet/crypto.js.map +1 -0
  195. package/dist/src/pnet/errors.d.ts +5 -5
  196. package/dist/src/pnet/errors.d.ts.map +1 -1
  197. package/dist/src/pnet/errors.js +6 -0
  198. package/dist/src/pnet/errors.js.map +1 -0
  199. package/dist/src/pnet/index.d.ts +11 -20
  200. package/dist/src/pnet/index.d.ts.map +1 -1
  201. package/dist/src/pnet/index.js +66 -0
  202. package/dist/src/pnet/index.js.map +1 -0
  203. package/dist/src/pnet/key-generator.d.ts +3 -7
  204. package/dist/src/pnet/key-generator.d.ts.map +1 -1
  205. package/dist/src/pnet/key-generator.js +25 -0
  206. package/dist/src/pnet/key-generator.js.map +1 -0
  207. package/dist/src/registrar.d.ts +27 -65
  208. package/dist/src/registrar.d.ts.map +1 -1
  209. package/dist/src/registrar.js +159 -0
  210. package/dist/src/registrar.js.map +1 -0
  211. package/dist/src/transport-manager.d.ts +34 -82
  212. package/dist/src/transport-manager.d.ts.map +1 -1
  213. package/dist/src/transport-manager.js +223 -0
  214. package/dist/src/transport-manager.js.map +1 -0
  215. package/dist/src/upgrader.d.ts +49 -129
  216. package/dist/src/upgrader.d.ts.map +1 -1
  217. package/dist/src/upgrader.js +402 -0
  218. package/dist/src/upgrader.js.map +1 -0
  219. package/dist/src/version.d.ts +3 -0
  220. package/dist/src/version.d.ts.map +1 -0
  221. package/dist/src/version.js +3 -0
  222. package/dist/src/version.js.map +1 -0
  223. package/package.json +145 -197
  224. package/src/address-manager/index.ts +129 -0
  225. package/src/circuit/README.md +16 -11
  226. package/src/circuit/auto-relay.ts +284 -0
  227. package/src/circuit/circuit/hop.ts +211 -0
  228. package/src/circuit/circuit/stop.ts +78 -0
  229. package/src/circuit/circuit/stream-handler.ts +87 -0
  230. package/src/circuit/circuit/{utils.js → utils.ts} +9 -25
  231. package/src/circuit/constants.ts +31 -0
  232. package/src/circuit/index.ts +120 -0
  233. package/src/circuit/{listener.js → listener.ts} +21 -27
  234. package/src/circuit/multicodec.ts +2 -0
  235. package/src/circuit/{protocol → pb}/index.d.ts +0 -0
  236. package/src/circuit/pb/index.js +528 -0
  237. package/src/circuit/{protocol → pb}/index.proto +0 -0
  238. package/src/circuit/transport.ts +216 -0
  239. package/src/circuit/utils.ts +12 -0
  240. package/src/config.ts +101 -0
  241. package/src/connection-manager/auto-dialler.ts +154 -0
  242. package/src/connection-manager/index.ts +422 -0
  243. package/src/connection-manager/latency-monitor.ts +319 -0
  244. package/src/connection-manager/{visibility-change-emitter.js → visibility-change-emitter.ts} +48 -38
  245. package/src/constants.ts +31 -0
  246. package/src/content-routing/index.ts +143 -0
  247. package/src/content-routing/utils.ts +54 -0
  248. package/src/dht/dht-content-routing.ts +43 -0
  249. package/src/dht/dht-peer-routing.ts +35 -0
  250. package/src/dialer/auto-dialer.ts +40 -0
  251. package/src/dialer/{dial-request.js → dial-request.ts} +60 -51
  252. package/src/dialer/index.ts +374 -0
  253. package/src/errors.ts +71 -0
  254. package/src/fetch/README.md +1 -1
  255. package/src/fetch/constants.ts +3 -0
  256. package/src/fetch/{index.js → index.ts} +79 -70
  257. package/src/fetch/{proto.d.ts → pb/proto.d.ts} +0 -0
  258. package/src/fetch/pb/proto.js +331 -0
  259. package/src/fetch/{proto.proto → pb/proto.proto} +0 -0
  260. package/src/get-peer.ts +57 -0
  261. package/src/identify/consts.ts +13 -0
  262. package/src/identify/index.ts +445 -0
  263. package/{dist/src/identify → src/identify/pb}/message.d.ts +20 -5
  264. package/src/identify/pb/message.js +369 -0
  265. package/src/identify/{message.proto → pb/message.proto} +0 -0
  266. package/src/index.ts +234 -0
  267. package/src/insecure/index.ts +97 -0
  268. package/src/insecure/{proto.d.ts → pb/proto.d.ts} +7 -1
  269. package/src/insecure/pb/proto.js +388 -0
  270. package/src/insecure/{proto.proto → pb/proto.proto} +0 -0
  271. package/src/keychain/{cms.js → cms.ts} +62 -58
  272. package/src/keychain/index.ts +588 -0
  273. package/src/keychain/{util.js → util.ts} +7 -17
  274. package/src/libp2p.ts +501 -0
  275. package/src/metrics/index.ts +310 -0
  276. package/src/metrics/moving-average.ts +53 -0
  277. package/src/metrics/stats.ts +243 -0
  278. package/src/nat-manager.ts +194 -0
  279. package/src/peer-record-updater.ts +55 -0
  280. package/src/peer-routing.ts +185 -0
  281. package/src/ping/README.md +1 -1
  282. package/src/ping/constants.ts +5 -0
  283. package/src/ping/index.ts +83 -0
  284. package/src/pnet/README.md +2 -2
  285. package/src/pnet/crypto.ts +67 -0
  286. package/src/pnet/errors.ts +5 -0
  287. package/src/pnet/index.ts +95 -0
  288. package/src/pnet/key-generator.ts +28 -0
  289. package/src/registrar.ts +205 -0
  290. package/src/transport-manager.ts +279 -0
  291. package/src/upgrader.ts +499 -0
  292. package/src/version.ts +3 -0
  293. package/dist/index.min.js +0 -55
  294. package/dist/src/insecure/plaintext.d.ts +0 -12
  295. package/dist/src/insecure/plaintext.d.ts.map +0 -1
  296. package/dist/src/metrics/old-peers.d.ts +0 -3
  297. package/dist/src/metrics/old-peers.d.ts.map +0 -1
  298. package/dist/src/metrics/tracked-map.d.ts +0 -8
  299. package/dist/src/metrics/tracked-map.d.ts.map +0 -1
  300. package/dist/src/peer-store/address-book.d.ts +0 -67
  301. package/dist/src/peer-store/address-book.d.ts.map +0 -1
  302. package/dist/src/peer-store/index.d.ts +0 -58
  303. package/dist/src/peer-store/index.d.ts.map +0 -1
  304. package/dist/src/peer-store/key-book.d.ts +0 -40
  305. package/dist/src/peer-store/key-book.d.ts.map +0 -1
  306. package/dist/src/peer-store/metadata-book.d.ts +0 -58
  307. package/dist/src/peer-store/metadata-book.d.ts.map +0 -1
  308. package/dist/src/peer-store/pb/peer.d.ts +0 -222
  309. package/dist/src/peer-store/proto-book.d.ts +0 -43
  310. package/dist/src/peer-store/proto-book.d.ts.map +0 -1
  311. package/dist/src/peer-store/store.d.ts +0 -73
  312. package/dist/src/peer-store/store.d.ts.map +0 -1
  313. package/dist/src/peer-store/types.d.ts +0 -202
  314. package/dist/src/peer-store/types.d.ts.map +0 -1
  315. package/dist/src/ping/util.d.ts +0 -5
  316. package/dist/src/ping/util.d.ts.map +0 -1
  317. package/dist/src/pubsub-adapter.d.ts +0 -22
  318. package/dist/src/pubsub-adapter.d.ts.map +0 -1
  319. package/dist/src/record/envelope/envelope.d.ts +0 -77
  320. package/dist/src/record/envelope/index.d.ts +0 -80
  321. package/dist/src/record/envelope/index.d.ts.map +0 -1
  322. package/dist/src/record/peer-record/consts.d.ts +0 -4
  323. package/dist/src/record/peer-record/consts.d.ts.map +0 -1
  324. package/dist/src/record/peer-record/index.d.ts +0 -60
  325. package/dist/src/record/peer-record/index.d.ts.map +0 -1
  326. package/dist/src/record/peer-record/peer-record.d.ts +0 -133
  327. package/dist/src/record/utils.d.ts +0 -12
  328. package/dist/src/record/utils.d.ts.map +0 -1
  329. package/dist/src/types.d.ts +0 -90
  330. package/dist/src/types.d.ts.map +0 -1
  331. package/src/address-manager/index.js +0 -96
  332. package/src/circuit/auto-relay.js +0 -302
  333. package/src/circuit/circuit/hop.js +0 -205
  334. package/src/circuit/circuit/stop.js +0 -81
  335. package/src/circuit/circuit/stream-handler.js +0 -94
  336. package/src/circuit/constants.js +0 -12
  337. package/src/circuit/index.js +0 -102
  338. package/src/circuit/multicodec.js +0 -5
  339. package/src/circuit/transport.js +0 -229
  340. package/src/circuit/utils.js +0 -17
  341. package/src/config.js +0 -114
  342. package/src/connection-manager/auto-dialler.js +0 -132
  343. package/src/connection-manager/index.js +0 -363
  344. package/src/connection-manager/latency-monitor.js +0 -264
  345. package/src/constants.js +0 -18
  346. package/src/content-routing/index.js +0 -163
  347. package/src/content-routing/utils.js +0 -89
  348. package/src/dht/dht-content-routing.js +0 -44
  349. package/src/dht/dht-peer-routing.js +0 -51
  350. package/src/dialer/index.js +0 -376
  351. package/src/errors.js +0 -66
  352. package/src/fetch/constants.js +0 -6
  353. package/src/get-peer.js +0 -49
  354. package/src/identify/consts.js +0 -15
  355. package/src/identify/index.js +0 -384
  356. package/src/index.js +0 -811
  357. package/src/insecure/plaintext.js +0 -95
  358. package/src/keychain/index.js +0 -561
  359. package/src/metrics/index.js +0 -290
  360. package/src/metrics/old-peers.js +0 -16
  361. package/src/metrics/stats.js +0 -270
  362. package/src/metrics/tracked-map.js +0 -94
  363. package/src/nat-manager.js +0 -197
  364. package/src/peer-routing.js +0 -176
  365. package/src/peer-store/README.md +0 -145
  366. package/src/peer-store/address-book.js +0 -382
  367. package/src/peer-store/index.js +0 -121
  368. package/src/peer-store/key-book.js +0 -141
  369. package/src/peer-store/metadata-book.js +0 -250
  370. package/src/peer-store/pb/peer.d.ts +0 -222
  371. package/src/peer-store/pb/peer.js +0 -643
  372. package/src/peer-store/pb/peer.proto +0 -31
  373. package/src/peer-store/proto-book.js +0 -237
  374. package/src/peer-store/store.js +0 -263
  375. package/src/peer-store/types.ts +0 -245
  376. package/src/ping/constants.js +0 -8
  377. package/src/ping/index.js +0 -85
  378. package/src/ping/util.js +0 -18
  379. package/src/pnet/crypto.js +0 -84
  380. package/src/pnet/errors.js +0 -7
  381. package/src/pnet/index.js +0 -86
  382. package/src/pnet/key-generator.js +0 -33
  383. package/src/pubsub-adapter.js +0 -61
  384. package/src/record/README.md +0 -130
  385. package/src/record/envelope/envelope.d.ts +0 -77
  386. package/src/record/envelope/envelope.js +0 -243
  387. package/src/record/envelope/envelope.proto +0 -19
  388. package/src/record/envelope/index.js +0 -183
  389. package/src/record/peer-record/consts.js +0 -14
  390. package/src/record/peer-record/index.js +0 -113
  391. package/src/record/peer-record/peer-record.d.ts +0 -133
  392. package/src/record/peer-record/peer-record.js +0 -367
  393. package/src/record/peer-record/peer-record.proto +0 -18
  394. package/src/record/utils.js +0 -25
  395. package/src/registrar.js +0 -127
  396. package/src/transport-manager.js +0 -269
  397. package/src/types.ts +0 -98
  398. package/src/upgrader.js +0 -492
@@ -0,0 +1,322 @@
1
+ import { logger } from '@libp2p/logger';
2
+ import errCode from 'err-code';
3
+ import * as lp from 'it-length-prefixed';
4
+ import { pipe } from 'it-pipe';
5
+ import all from 'it-all';
6
+ import take from 'it-take';
7
+ import drain from 'it-drain';
8
+ import first from 'it-first';
9
+ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
10
+ import { Multiaddr, protocols } from '@multiformats/multiaddr';
11
+ import Message from './pb/message.js';
12
+ import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record';
13
+ import { MULTICODEC_IDENTIFY, MULTICODEC_IDENTIFY_PUSH, IDENTIFY_PROTOCOL_VERSION, MULTICODEC_IDENTIFY_PROTOCOL_NAME, MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME, MULTICODEC_IDENTIFY_PROTOCOL_VERSION, MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION } from './consts.js';
14
+ import { codes } from '../errors.js';
15
+ import { peerIdFromKeys, peerIdFromString } from '@libp2p/peer-id';
16
+ const log = logger('libp2p:identify');
17
+ export class IdentifyService {
18
+ constructor(components, init) {
19
+ this.components = components;
20
+ this.started = false;
21
+ this.handleMessage = this.handleMessage.bind(this);
22
+ this.identifyProtocolStr = `/${init.protocolPrefix}/${MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`;
23
+ this.identifyPushProtocolStr = `/${init.protocolPrefix}/${MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION}`;
24
+ // Store self host metadata
25
+ this.host = {
26
+ protocolVersion: `${init.protocolPrefix}/${IDENTIFY_PROTOCOL_VERSION}`,
27
+ ...init.host
28
+ };
29
+ // When a new connection happens, trigger identify
30
+ this.components.getConnectionManager().addEventListener('peer:connect', (evt) => {
31
+ const connection = evt.detail;
32
+ this.identify(connection).catch(log.error);
33
+ });
34
+ // When self multiaddrs change, trigger identify-push
35
+ this.components.getPeerStore().addEventListener('change:multiaddrs', (evt) => {
36
+ const { peerId } = evt.detail;
37
+ if (this.components.getPeerId().equals(peerId)) {
38
+ void this.pushToPeerStore().catch(err => log.error(err));
39
+ }
40
+ });
41
+ // When self protocols change, trigger identify-push
42
+ this.components.getPeerStore().addEventListener('change:protocols', (evt) => {
43
+ const { peerId } = evt.detail;
44
+ if (this.components.getPeerId().equals(peerId)) {
45
+ void this.pushToPeerStore().catch(err => log.error(err));
46
+ }
47
+ });
48
+ }
49
+ isStarted() {
50
+ return this.started;
51
+ }
52
+ async start() {
53
+ if (this.started) {
54
+ return;
55
+ }
56
+ await this.components.getPeerStore().metadataBook.setValue(this.components.getPeerId(), 'AgentVersion', uint8ArrayFromString(this.host.agentVersion));
57
+ await this.components.getPeerStore().metadataBook.setValue(this.components.getPeerId(), 'ProtocolVersion', uint8ArrayFromString(this.host.protocolVersion));
58
+ await this.components.getRegistrar().handle([
59
+ this.identifyProtocolStr,
60
+ this.identifyPushProtocolStr
61
+ ], (data) => {
62
+ void this.handleMessage(data)?.catch(err => {
63
+ log.error(err);
64
+ });
65
+ });
66
+ this.started = true;
67
+ }
68
+ async stop() {
69
+ await this.components.getRegistrar().unhandle(this.identifyProtocolStr);
70
+ await this.components.getRegistrar().unhandle(this.identifyPushProtocolStr);
71
+ this.started = false;
72
+ }
73
+ /**
74
+ * Send an Identify Push update to the list of connections
75
+ */
76
+ async push(connections) {
77
+ const signedPeerRecord = await this.components.getPeerStore().addressBook.getRawEnvelope(this.components.getPeerId());
78
+ const listenAddrs = this.components.getAddressManager().getAddresses().map((ma) => ma.bytes);
79
+ const protocols = await this.components.getPeerStore().protoBook.get(this.components.getPeerId());
80
+ const pushes = connections.map(async (connection) => {
81
+ try {
82
+ const { stream } = await connection.newStream([this.identifyPushProtocolStr]);
83
+ await pipe([Message.Identify.encode({
84
+ listenAddrs,
85
+ signedPeerRecord,
86
+ protocols
87
+ }).finish()], lp.encode(), stream, drain);
88
+ }
89
+ catch (err) {
90
+ // Just log errors
91
+ log.error('could not push identify update to peer', err);
92
+ }
93
+ });
94
+ await Promise.all(pushes);
95
+ }
96
+ /**
97
+ * Calls `push` on all peer connections
98
+ */
99
+ async pushToPeerStore() {
100
+ // Do not try to push if we are not running
101
+ if (!this.isStarted()) {
102
+ return;
103
+ }
104
+ const connections = [];
105
+ for (const [peerIdStr, conns] of this.components.getConnectionManager().getConnectionMap().entries()) {
106
+ const peerId = peerIdFromString(peerIdStr);
107
+ const peer = await this.components.getPeerStore().get(peerId);
108
+ if (!peer.protocols.includes(this.identifyPushProtocolStr)) {
109
+ continue;
110
+ }
111
+ connections.push(...conns);
112
+ }
113
+ await this.push(connections);
114
+ }
115
+ /**
116
+ * Requests the `Identify` message from peer associated with the given `connection`.
117
+ * If the identified peer does not match the `PeerId` associated with the connection,
118
+ * an error will be thrown.
119
+ */
120
+ async identify(connection) {
121
+ const { stream } = await connection.newStream([this.identifyProtocolStr]);
122
+ const [data] = await pipe([], stream, lp.decode(), (source) => take(source, 1), async (source) => await all(source));
123
+ if (data == null) {
124
+ throw errCode(new Error('No data could be retrieved'), codes.ERR_CONNECTION_ENDED);
125
+ }
126
+ let message;
127
+ try {
128
+ message = Message.Identify.decode(data);
129
+ }
130
+ catch (err) {
131
+ throw errCode(err, codes.ERR_INVALID_MESSAGE);
132
+ }
133
+ const { publicKey, listenAddrs, protocols, observedAddr, signedPeerRecord, agentVersion, protocolVersion } = message;
134
+ if (publicKey == null) {
135
+ throw errCode(new Error('public key was missing from identify message'), codes.ERR_MISSING_PUBLIC_KEY);
136
+ }
137
+ const id = await peerIdFromKeys(publicKey);
138
+ if (!connection.remotePeer.equals(id)) {
139
+ throw errCode(new Error('identified peer does not match the expected peer'), codes.ERR_INVALID_PEER);
140
+ }
141
+ if (this.components.getPeerId().equals(id)) {
142
+ throw errCode(new Error('identified peer is our own peer id?'), codes.ERR_INVALID_PEER);
143
+ }
144
+ // Get the observedAddr if there is one
145
+ const cleanObservedAddr = IdentifyService.getCleanMultiaddr(observedAddr);
146
+ if (signedPeerRecord != null) {
147
+ log('received signed peer record from %p', id);
148
+ try {
149
+ const envelope = await RecordEnvelope.openAndCertify(signedPeerRecord, PeerRecord.DOMAIN);
150
+ if (!envelope.peerId.equals(id)) {
151
+ throw errCode(new Error('identified peer does not match the expected peer'), codes.ERR_INVALID_PEER);
152
+ }
153
+ if (await this.components.getPeerStore().addressBook.consumePeerRecord(envelope)) {
154
+ await this.components.getPeerStore().protoBook.set(id, protocols);
155
+ if (agentVersion != null) {
156
+ await this.components.getPeerStore().metadataBook.setValue(id, 'AgentVersion', uint8ArrayFromString(agentVersion));
157
+ }
158
+ if (protocolVersion != null) {
159
+ await this.components.getPeerStore().metadataBook.setValue(id, 'ProtocolVersion', uint8ArrayFromString(protocolVersion));
160
+ }
161
+ log('identify completed for peer %p and protocols %o', id, protocols);
162
+ return;
163
+ }
164
+ }
165
+ catch (err) {
166
+ log('received invalid envelope, discard it and fallback to listenAddrs is available', err);
167
+ }
168
+ }
169
+ else {
170
+ log('no signed peer record received from %p', id);
171
+ }
172
+ log('falling back to legacy addresses from %p', id);
173
+ // LEGACY: Update peers data in PeerStore
174
+ try {
175
+ await this.components.getPeerStore().addressBook.set(id, listenAddrs.map((addr) => new Multiaddr(addr)));
176
+ }
177
+ catch (err) {
178
+ log.error('received invalid addrs', err);
179
+ }
180
+ await this.components.getPeerStore().protoBook.set(id, protocols);
181
+ if (agentVersion != null) {
182
+ await this.components.getPeerStore().metadataBook.setValue(id, 'AgentVersion', uint8ArrayFromString(agentVersion));
183
+ }
184
+ if (protocolVersion != null) {
185
+ await this.components.getPeerStore().metadataBook.setValue(id, 'ProtocolVersion', uint8ArrayFromString(protocolVersion));
186
+ }
187
+ log('identify completed for peer %p and protocols %o', id, protocols);
188
+ // TODO: Add and score our observed addr
189
+ log('received observed address of %s', cleanObservedAddr?.toString());
190
+ // this.components.getAddressManager().addObservedAddr(observedAddr)
191
+ }
192
+ /**
193
+ * A handler to register with Libp2p to process identify messages
194
+ */
195
+ handleMessage(data) {
196
+ const { protocol } = data;
197
+ switch (protocol) {
198
+ case this.identifyProtocolStr:
199
+ return this._handleIdentify(data);
200
+ case this.identifyPushProtocolStr:
201
+ return this._handlePush(data);
202
+ default:
203
+ log.error('cannot handle unknown protocol %s', protocol);
204
+ }
205
+ }
206
+ /**
207
+ * Sends the `Identify` response with the Signed Peer Record
208
+ * to the requesting peer over the given `connection`
209
+ */
210
+ async _handleIdentify(data) {
211
+ const { connection, stream } = data;
212
+ try {
213
+ const publicKey = this.components.getPeerId().publicKey ?? new Uint8Array(0);
214
+ const peerData = await this.components.getPeerStore().get(this.components.getPeerId());
215
+ const multiaddrs = this.components.getAddressManager().getAddresses().map(ma => ma.decapsulateCode(protocols('p2p').code));
216
+ let signedPeerRecord = peerData.peerRecordEnvelope;
217
+ if (multiaddrs.length > 0 && signedPeerRecord == null) {
218
+ const peerRecord = new PeerRecord({
219
+ peerId: this.components.getPeerId(),
220
+ multiaddrs
221
+ });
222
+ const envelope = await RecordEnvelope.seal(peerRecord, this.components.getPeerId());
223
+ await this.components.getPeerStore().addressBook.consumePeerRecord(envelope);
224
+ signedPeerRecord = envelope.marshal();
225
+ }
226
+ const message = Message.Identify.encode({
227
+ protocolVersion: this.host.protocolVersion,
228
+ agentVersion: this.host.agentVersion,
229
+ publicKey,
230
+ listenAddrs: multiaddrs.map(addr => addr.bytes),
231
+ signedPeerRecord,
232
+ observedAddr: connection.remoteAddr.bytes,
233
+ protocols: peerData.protocols
234
+ }).finish();
235
+ await pipe([message], lp.encode(), stream, drain);
236
+ }
237
+ catch (err) {
238
+ log.error('could not respond to identify request', err);
239
+ }
240
+ }
241
+ /**
242
+ * Reads the Identify Push message from the given `connection`
243
+ */
244
+ async _handlePush(data) {
245
+ const { connection, stream } = data;
246
+ let message;
247
+ try {
248
+ const data = await pipe([], stream, lp.decode(), async (source) => await first(source));
249
+ if (data != null) {
250
+ message = Message.Identify.decode(data);
251
+ }
252
+ }
253
+ catch (err) {
254
+ return log.error('received invalid message', err);
255
+ }
256
+ if (message == null) {
257
+ return log.error('received invalid message');
258
+ }
259
+ const id = connection.remotePeer;
260
+ if (this.components.getPeerId().equals(id)) {
261
+ log('received push from ourselves?');
262
+ return;
263
+ }
264
+ log('received push from %p', id);
265
+ if (message.signedPeerRecord != null) {
266
+ log('received signedPeerRecord in push');
267
+ try {
268
+ const envelope = await RecordEnvelope.openAndCertify(message.signedPeerRecord, PeerRecord.DOMAIN);
269
+ if (await this.components.getPeerStore().addressBook.consumePeerRecord(envelope)) {
270
+ log('consumed signedPeerRecord sent in push');
271
+ await this.components.getPeerStore().protoBook.set(id, message.protocols);
272
+ return;
273
+ }
274
+ else {
275
+ log('failed to consume signedPeerRecord sent in push');
276
+ }
277
+ }
278
+ catch (err) {
279
+ log('received invalid envelope, discard it and fallback to listenAddrs is available', err);
280
+ }
281
+ }
282
+ else {
283
+ log('did not receive signedPeerRecord in push');
284
+ }
285
+ // LEGACY: Update peers data in PeerStore
286
+ try {
287
+ await this.components.getPeerStore().addressBook.set(id, message.listenAddrs.map((addr) => new Multiaddr(addr)));
288
+ }
289
+ catch (err) {
290
+ log.error('received invalid addrs', err);
291
+ }
292
+ // Update the protocols
293
+ try {
294
+ await this.components.getPeerStore().protoBook.set(id, message.protocols);
295
+ }
296
+ catch (err) {
297
+ log.error('received invalid protocols', err);
298
+ }
299
+ log('handled push from %p', id);
300
+ }
301
+ /**
302
+ * Takes the `addr` and converts it to a Multiaddr if possible
303
+ */
304
+ static getCleanMultiaddr(addr) {
305
+ if (addr != null && addr.length > 0) {
306
+ try {
307
+ return new Multiaddr(addr);
308
+ }
309
+ catch {
310
+ }
311
+ }
312
+ }
313
+ }
314
+ /**
315
+ * The protocols the IdentifyService supports
316
+ */
317
+ export const multicodecs = {
318
+ IDENTIFY: MULTICODEC_IDENTIFY,
319
+ IDENTIFY_PUSH: MULTICODEC_IDENTIFY_PUSH
320
+ };
321
+ export { Message };
322
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identify/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,OAAO,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,iCAAiC,EACjC,sCAAsC,EACtC,oCAAoC,EACpC,yCAAyC,EAC1C,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAIpC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGlE,MAAM,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAA;AAWrC,MAAM,OAAO,eAAe;IAW1B,YAAa,UAAsB,EAAE,IAAyB;QAC5D,IA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,OAAO,GAAQ,EAAE;YACjB,GAAG,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAA;SACzC;QAED,uBAAuB;QACvB,IAAI;YACF,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;SAC1E;QAAC,OAAO,GAAQ,EAAE;YACjB,GAAG,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAA;SAC7C;QAED,GAAG,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAA;IACjC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAE,IAA4C;QACpE,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACnC,IAAI;gBACF,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,CAAA;aAC3B;YAAC,MAAM;aAEP;SACF;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,mBAAmB;IAC7B,aAAa,EAAE,wBAAwB;CACxC,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,CAAA"}
@@ -34,25 +34,40 @@ export class Identify implements IIdentify {
34
34
  constructor(p?: IIdentify);
35
35
 
36
36
  /** Identify protocolVersion. */
37
- public protocolVersion: string;
37
+ public protocolVersion?: (string|null);
38
38
 
39
39
  /** Identify agentVersion. */
40
- public agentVersion: string;
40
+ public agentVersion?: (string|null);
41
41
 
42
42
  /** Identify publicKey. */
43
- public publicKey: Uint8Array;
43
+ public publicKey?: (Uint8Array|null);
44
44
 
45
45
  /** Identify listenAddrs. */
46
46
  public listenAddrs: Uint8Array[];
47
47
 
48
48
  /** Identify observedAddr. */
49
- public observedAddr: Uint8Array;
49
+ public observedAddr?: (Uint8Array|null);
50
50
 
51
51
  /** Identify protocols. */
52
52
  public protocols: string[];
53
53
 
54
54
  /** Identify signedPeerRecord. */
55
- public signedPeerRecord: Uint8Array;
55
+ public signedPeerRecord?: (Uint8Array|null);
56
+
57
+ /** Identify _protocolVersion. */
58
+ public _protocolVersion?: "protocolVersion";
59
+
60
+ /** Identify _agentVersion. */
61
+ public _agentVersion?: "agentVersion";
62
+
63
+ /** Identify _publicKey. */
64
+ public _publicKey?: "publicKey";
65
+
66
+ /** Identify _observedAddr. */
67
+ public _observedAddr?: "observedAddr";
68
+
69
+ /** Identify _signedPeerRecord. */
70
+ public _signedPeerRecord?: "signedPeerRecord";
56
71
 
57
72
  /**
58
73
  * Encodes the specified Identify message. Does not implicitly {@link Identify.verify|verify} messages.
@@ -1,15 +1,13 @@
1
1
  /*eslint-disable*/
2
- "use strict";
3
-
4
- var $protobuf = require("protobufjs/minimal");
2
+ import $protobuf from "protobufjs/minimal.js";
5
3
 
6
4
  // Common aliases
7
- var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
5
+ const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
8
6
 
9
7
  // Exported root namespace
10
- var $root = $protobuf.roots["libp2p-identify"] || ($protobuf.roots["libp2p-identify"] = {});
8
+ const $root = $protobuf.roots["libp2p-identify"] || ($protobuf.roots["libp2p-identify"] = {});
11
9
 
12
- $root.Identify = (function() {
10
+ export const Identify = $root.Identify = (() => {
13
11
 
14
12
  /**
15
13
  * Properties of an Identify.
@@ -43,27 +41,27 @@ $root.Identify = (function() {
43
41
 
44
42
  /**
45
43
  * Identify protocolVersion.
46
- * @member {string} protocolVersion
44
+ * @member {string|null|undefined} protocolVersion
47
45
  * @memberof Identify
48
46
  * @instance
49
47
  */
50
- Identify.prototype.protocolVersion = "";
48
+ Identify.prototype.protocolVersion = null;
51
49
 
52
50
  /**
53
51
  * Identify agentVersion.
54
- * @member {string} agentVersion
52
+ * @member {string|null|undefined} agentVersion
55
53
  * @memberof Identify
56
54
  * @instance
57
55
  */
58
- Identify.prototype.agentVersion = "";
56
+ Identify.prototype.agentVersion = null;
59
57
 
60
58
  /**
61
59
  * Identify publicKey.
62
- * @member {Uint8Array} publicKey
60
+ * @member {Uint8Array|null|undefined} publicKey
63
61
  * @memberof Identify
64
62
  * @instance
65
63
  */
66
- Identify.prototype.publicKey = $util.newBuffer([]);
64
+ Identify.prototype.publicKey = null;
67
65
 
68
66
  /**
69
67
  * Identify listenAddrs.
@@ -75,11 +73,11 @@ $root.Identify = (function() {
75
73
 
76
74
  /**
77
75
  * Identify observedAddr.
78
- * @member {Uint8Array} observedAddr
76
+ * @member {Uint8Array|null|undefined} observedAddr
79
77
  * @memberof Identify
80
78
  * @instance
81
79
  */
82
- Identify.prototype.observedAddr = $util.newBuffer([]);
80
+ Identify.prototype.observedAddr = null;
83
81
 
84
82
  /**
85
83
  * Identify protocols.
@@ -91,11 +89,69 @@ $root.Identify = (function() {
91
89
 
92
90
  /**
93
91
  * Identify signedPeerRecord.
94
- * @member {Uint8Array} signedPeerRecord
92
+ * @member {Uint8Array|null|undefined} signedPeerRecord
93
+ * @memberof Identify
94
+ * @instance
95
+ */
96
+ Identify.prototype.signedPeerRecord = null;
97
+
98
+ // OneOf field names bound to virtual getters and setters
99
+ let $oneOfFields;
100
+
101
+ /**
102
+ * Identify _protocolVersion.
103
+ * @member {"protocolVersion"|undefined} _protocolVersion
104
+ * @memberof Identify
105
+ * @instance
106
+ */
107
+ Object.defineProperty(Identify.prototype, "_protocolVersion", {
108
+ get: $util.oneOfGetter($oneOfFields = ["protocolVersion"]),
109
+ set: $util.oneOfSetter($oneOfFields)
110
+ });
111
+
112
+ /**
113
+ * Identify _agentVersion.
114
+ * @member {"agentVersion"|undefined} _agentVersion
95
115
  * @memberof Identify
96
116
  * @instance
97
117
  */
98
- Identify.prototype.signedPeerRecord = $util.newBuffer([]);
118
+ Object.defineProperty(Identify.prototype, "_agentVersion", {
119
+ get: $util.oneOfGetter($oneOfFields = ["agentVersion"]),
120
+ set: $util.oneOfSetter($oneOfFields)
121
+ });
122
+
123
+ /**
124
+ * Identify _publicKey.
125
+ * @member {"publicKey"|undefined} _publicKey
126
+ * @memberof Identify
127
+ * @instance
128
+ */
129
+ Object.defineProperty(Identify.prototype, "_publicKey", {
130
+ get: $util.oneOfGetter($oneOfFields = ["publicKey"]),
131
+ set: $util.oneOfSetter($oneOfFields)
132
+ });
133
+
134
+ /**
135
+ * Identify _observedAddr.
136
+ * @member {"observedAddr"|undefined} _observedAddr
137
+ * @memberof Identify
138
+ * @instance
139
+ */
140
+ Object.defineProperty(Identify.prototype, "_observedAddr", {
141
+ get: $util.oneOfGetter($oneOfFields = ["observedAddr"]),
142
+ set: $util.oneOfSetter($oneOfFields)
143
+ });
144
+
145
+ /**
146
+ * Identify _signedPeerRecord.
147
+ * @member {"signedPeerRecord"|undefined} _signedPeerRecord
148
+ * @memberof Identify
149
+ * @instance
150
+ */
151
+ Object.defineProperty(Identify.prototype, "_signedPeerRecord", {
152
+ get: $util.oneOfGetter($oneOfFields = ["signedPeerRecord"]),
153
+ set: $util.oneOfSetter($oneOfFields)
154
+ });
99
155
 
100
156
  /**
101
157
  * Encodes the specified Identify message. Does not implicitly {@link Identify.verify|verify} messages.
@@ -256,33 +312,10 @@ $root.Identify = (function() {
256
312
  d.listenAddrs = [];
257
313
  d.protocols = [];
258
314
  }
259
- if (o.defaults) {
260
- if (o.bytes === String)
261
- d.publicKey = "";
262
- else {
263
- d.publicKey = [];
264
- if (o.bytes !== Array)
265
- d.publicKey = $util.newBuffer(d.publicKey);
266
- }
267
- if (o.bytes === String)
268
- d.observedAddr = "";
269
- else {
270
- d.observedAddr = [];
271
- if (o.bytes !== Array)
272
- d.observedAddr = $util.newBuffer(d.observedAddr);
273
- }
274
- d.protocolVersion = "";
275
- d.agentVersion = "";
276
- if (o.bytes === String)
277
- d.signedPeerRecord = "";
278
- else {
279
- d.signedPeerRecord = [];
280
- if (o.bytes !== Array)
281
- d.signedPeerRecord = $util.newBuffer(d.signedPeerRecord);
282
- }
283
- }
284
315
  if (m.publicKey != null && m.hasOwnProperty("publicKey")) {
285
316
  d.publicKey = o.bytes === String ? $util.base64.encode(m.publicKey, 0, m.publicKey.length) : o.bytes === Array ? Array.prototype.slice.call(m.publicKey) : m.publicKey;
317
+ if (o.oneofs)
318
+ d._publicKey = "publicKey";
286
319
  }
287
320
  if (m.listenAddrs && m.listenAddrs.length) {
288
321
  d.listenAddrs = [];
@@ -298,15 +331,23 @@ $root.Identify = (function() {
298
331
  }
299
332
  if (m.observedAddr != null && m.hasOwnProperty("observedAddr")) {
300
333
  d.observedAddr = o.bytes === String ? $util.base64.encode(m.observedAddr, 0, m.observedAddr.length) : o.bytes === Array ? Array.prototype.slice.call(m.observedAddr) : m.observedAddr;
334
+ if (o.oneofs)
335
+ d._observedAddr = "observedAddr";
301
336
  }
302
337
  if (m.protocolVersion != null && m.hasOwnProperty("protocolVersion")) {
303
338
  d.protocolVersion = m.protocolVersion;
339
+ if (o.oneofs)
340
+ d._protocolVersion = "protocolVersion";
304
341
  }
305
342
  if (m.agentVersion != null && m.hasOwnProperty("agentVersion")) {
306
343
  d.agentVersion = m.agentVersion;
344
+ if (o.oneofs)
345
+ d._agentVersion = "agentVersion";
307
346
  }
308
347
  if (m.signedPeerRecord != null && m.hasOwnProperty("signedPeerRecord")) {
309
348
  d.signedPeerRecord = o.bytes === String ? $util.base64.encode(m.signedPeerRecord, 0, m.signedPeerRecord.length) : o.bytes === Array ? Array.prototype.slice.call(m.signedPeerRecord) : m.signedPeerRecord;
349
+ if (o.oneofs)
350
+ d._signedPeerRecord = "signedPeerRecord";
310
351
  }
311
352
  return d;
312
353
  };
@@ -325,4 +366,4 @@ $root.Identify = (function() {
325
366
  return Identify;
326
367
  })();
327
368
 
328
- module.exports = $root;
369
+ export { $root as default };