@streamr/dht 0.0.1-tatum.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 (344) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc +3 -0
  3. package/README.md +38 -0
  4. package/dist/src/connection/Connection.d.ts +11 -0
  5. package/dist/src/connection/Connection.js +23 -0
  6. package/dist/src/connection/Connection.js.map +1 -0
  7. package/dist/src/connection/ConnectionLockHandler.d.ts +23 -0
  8. package/dist/src/connection/ConnectionLockHandler.js +94 -0
  9. package/dist/src/connection/ConnectionLockHandler.js.map +1 -0
  10. package/dist/src/connection/ConnectionManager.d.ts +94 -0
  11. package/dist/src/connection/ConnectionManager.js +554 -0
  12. package/dist/src/connection/ConnectionManager.js.map +1 -0
  13. package/dist/src/connection/ConnectivityChecker.d.ts +17 -0
  14. package/dist/src/connection/ConnectivityChecker.js +187 -0
  15. package/dist/src/connection/ConnectivityChecker.js.map +1 -0
  16. package/dist/src/connection/Handshaker.d.ts +19 -0
  17. package/dist/src/connection/Handshaker.js +77 -0
  18. package/dist/src/connection/Handshaker.js.map +1 -0
  19. package/dist/src/connection/IConnection.d.ts +38 -0
  20. package/dist/src/connection/IConnection.js +19 -0
  21. package/dist/src/connection/IConnection.js.map +1 -0
  22. package/dist/src/connection/IConnectionSource.d.ts +4 -0
  23. package/dist/src/connection/IConnectionSource.js +3 -0
  24. package/dist/src/connection/IConnectionSource.js.map +1 -0
  25. package/dist/src/connection/ManagedConnection.d.ts +60 -0
  26. package/dist/src/connection/ManagedConnection.js +352 -0
  27. package/dist/src/connection/ManagedConnection.js.map +1 -0
  28. package/dist/src/connection/ManagedWebRtcConnection.d.ts +7 -0
  29. package/dist/src/connection/ManagedWebRtcConnection.js +20 -0
  30. package/dist/src/connection/ManagedWebRtcConnection.js.map +1 -0
  31. package/dist/src/connection/RemoteConnectionLocker.d.ts +14 -0
  32. package/dist/src/connection/RemoteConnectionLocker.js +93 -0
  33. package/dist/src/connection/RemoteConnectionLocker.js.map +1 -0
  34. package/dist/src/connection/Simulator/Simulator.d.ts +42 -0
  35. package/dist/src/connection/Simulator/Simulator.js +325 -0
  36. package/dist/src/connection/Simulator/Simulator.js.map +1 -0
  37. package/dist/src/connection/Simulator/SimulatorConnection.d.ts +19 -0
  38. package/dist/src/connection/Simulator/SimulatorConnection.js +118 -0
  39. package/dist/src/connection/Simulator/SimulatorConnection.js.map +1 -0
  40. package/dist/src/connection/Simulator/SimulatorConnector.d.ts +17 -0
  41. package/dist/src/connection/Simulator/SimulatorConnector.js +72 -0
  42. package/dist/src/connection/Simulator/SimulatorConnector.js.map +1 -0
  43. package/dist/src/connection/Simulator/SimulatorTransport.d.ts +6 -0
  44. package/dist/src/connection/Simulator/SimulatorTransport.js +11 -0
  45. package/dist/src/connection/Simulator/SimulatorTransport.js.map +1 -0
  46. package/dist/src/connection/Simulator/pings.d.ts +21 -0
  47. package/dist/src/connection/Simulator/pings.js +61 -0
  48. package/dist/src/connection/Simulator/pings.js.map +1 -0
  49. package/dist/src/connection/WebRTC/IWebRtcConnection.d.ts +20 -0
  50. package/dist/src/connection/WebRTC/IWebRtcConnection.js +9 -0
  51. package/dist/src/connection/WebRTC/IWebRtcConnection.js.map +1 -0
  52. package/dist/src/connection/WebRTC/NodeWebRtcConnection.d.ts +47 -0
  53. package/dist/src/connection/WebRTC/NodeWebRtcConnection.js +233 -0
  54. package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +1 -0
  55. package/dist/src/connection/WebRTC/RemoteWebrtcConnector.d.ts +12 -0
  56. package/dist/src/connection/WebRTC/RemoteWebrtcConnector.js +74 -0
  57. package/dist/src/connection/WebRTC/RemoteWebrtcConnector.js.map +1 -0
  58. package/dist/src/connection/WebRTC/WebRtcConnector.d.ts +47 -0
  59. package/dist/src/connection/WebRTC/WebRtcConnector.js +227 -0
  60. package/dist/src/connection/WebRTC/WebRtcConnector.js.map +1 -0
  61. package/dist/src/connection/WebRTC/iceServerAsString.d.ts +2 -0
  62. package/dist/src/connection/WebRTC/iceServerAsString.js +18 -0
  63. package/dist/src/connection/WebRTC/iceServerAsString.js.map +1 -0
  64. package/dist/src/connection/WebSocket/ClientWebSocket.d.ts +15 -0
  65. package/dist/src/connection/WebSocket/ClientWebSocket.js +113 -0
  66. package/dist/src/connection/WebSocket/ClientWebSocket.js.map +1 -0
  67. package/dist/src/connection/WebSocket/RemoteWebSocketConnector.d.ts +9 -0
  68. package/dist/src/connection/WebSocket/RemoteWebSocketConnector.js +63 -0
  69. package/dist/src/connection/WebSocket/RemoteWebSocketConnector.js.map +1 -0
  70. package/dist/src/connection/WebSocket/ServerWebSocket.d.ts +18 -0
  71. package/dist/src/connection/WebSocket/ServerWebSocket.js +103 -0
  72. package/dist/src/connection/WebSocket/ServerWebSocket.js.map +1 -0
  73. package/dist/src/connection/WebSocket/WebSocketConnector.d.ts +31 -0
  74. package/dist/src/connection/WebSocket/WebSocketConnector.js +202 -0
  75. package/dist/src/connection/WebSocket/WebSocketConnector.js.map +1 -0
  76. package/dist/src/connection/WebSocket/WebSocketServer.d.ts +9 -0
  77. package/dist/src/connection/WebSocket/WebSocketServer.js +101 -0
  78. package/dist/src/connection/WebSocket/WebSocketServer.js.map +1 -0
  79. package/dist/src/dht/DhtNode.d.ts +153 -0
  80. package/dist/src/dht/DhtNode.js +599 -0
  81. package/dist/src/dht/DhtNode.js.map +1 -0
  82. package/dist/src/dht/DhtPeer.d.ts +18 -0
  83. package/dist/src/dht/DhtPeer.js +74 -0
  84. package/dist/src/dht/DhtPeer.js.map +1 -0
  85. package/dist/src/dht/ExternalApi.d.ts +8 -0
  86. package/dist/src/dht/ExternalApi.js +26 -0
  87. package/dist/src/dht/ExternalApi.js.map +1 -0
  88. package/dist/src/dht/RemoteExternalApi.d.ts +6 -0
  89. package/dist/src/dht/RemoteExternalApi.js +26 -0
  90. package/dist/src/dht/RemoteExternalApi.js.map +1 -0
  91. package/dist/src/dht/contact/Contact.d.ts +22 -0
  92. package/dist/src/dht/contact/Contact.js +25 -0
  93. package/dist/src/dht/contact/Contact.js.map +1 -0
  94. package/dist/src/dht/contact/RandomContactList.d.ts +20 -0
  95. package/dist/src/dht/contact/RandomContactList.js +78 -0
  96. package/dist/src/dht/contact/RandomContactList.js.map +1 -0
  97. package/dist/src/dht/contact/Remote.d.ts +15 -0
  98. package/dist/src/dht/contact/Remote.js +24 -0
  99. package/dist/src/dht/contact/Remote.js.map +1 -0
  100. package/dist/src/dht/contact/SortedContactList.d.ts +35 -0
  101. package/dist/src/dht/contact/SortedContactList.js +156 -0
  102. package/dist/src/dht/contact/SortedContactList.js.map +1 -0
  103. package/dist/src/dht/discovery/DiscoverySession.d.ts +36 -0
  104. package/dist/src/dht/discovery/DiscoverySession.js +116 -0
  105. package/dist/src/dht/discovery/DiscoverySession.js.map +1 -0
  106. package/dist/src/dht/discovery/PeerDiscovery.d.ts +42 -0
  107. package/dist/src/dht/discovery/PeerDiscovery.js +157 -0
  108. package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -0
  109. package/dist/src/dht/find/RecursiveFindSession.d.ts +46 -0
  110. package/dist/src/dht/find/RecursiveFindSession.js +142 -0
  111. package/dist/src/dht/find/RecursiveFindSession.js.map +1 -0
  112. package/dist/src/dht/find/RecursiveFinder.d.ts +54 -0
  113. package/dist/src/dht/find/RecursiveFinder.js +180 -0
  114. package/dist/src/dht/find/RecursiveFinder.js.map +1 -0
  115. package/dist/src/dht/find/RemoteRecursiveFindSession.d.ts +6 -0
  116. package/dist/src/dht/find/RemoteRecursiveFindSession.js +25 -0
  117. package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +1 -0
  118. package/dist/src/dht/routing/DuplicateDetector.d.ts +13 -0
  119. package/dist/src/dht/routing/DuplicateDetector.js +41 -0
  120. package/dist/src/dht/routing/DuplicateDetector.js.map +1 -0
  121. package/dist/src/dht/routing/RemoteRouter.d.ts +8 -0
  122. package/dist/src/dht/routing/RemoteRouter.js +106 -0
  123. package/dist/src/dht/routing/RemoteRouter.js.map +1 -0
  124. package/dist/src/dht/routing/Router.d.ts +60 -0
  125. package/dist/src/dht/routing/Router.js +207 -0
  126. package/dist/src/dht/routing/Router.js.map +1 -0
  127. package/dist/src/dht/routing/RoutingSession.d.ts +42 -0
  128. package/dist/src/dht/routing/RoutingSession.js +178 -0
  129. package/dist/src/dht/routing/RoutingSession.js.map +1 -0
  130. package/dist/src/dht/store/DataStore.d.ts +45 -0
  131. package/dist/src/dht/store/DataStore.js +244 -0
  132. package/dist/src/dht/store/DataStore.js.map +1 -0
  133. package/dist/src/dht/store/LocalDataStore.d.ts +19 -0
  134. package/dist/src/dht/store/LocalDataStore.js +104 -0
  135. package/dist/src/dht/store/LocalDataStore.js.map +1 -0
  136. package/dist/src/dht/store/RemoteStore.d.ts +8 -0
  137. package/dist/src/dht/store/RemoteStore.js +44 -0
  138. package/dist/src/dht/store/RemoteStore.js.map +1 -0
  139. package/dist/src/exports.d.ts +19 -0
  140. package/dist/src/exports.js +41 -0
  141. package/dist/src/exports.js.map +1 -0
  142. package/dist/src/helpers/AddressTools.d.ts +2 -0
  143. package/dist/src/helpers/AddressTools.js +31 -0
  144. package/dist/src/helpers/AddressTools.js.map +1 -0
  145. package/dist/src/helpers/PeerID.d.ts +25 -0
  146. package/dist/src/helpers/PeerID.js +84 -0
  147. package/dist/src/helpers/PeerID.js.map +1 -0
  148. package/dist/src/helpers/UUID.d.ts +7 -0
  149. package/dist/src/helpers/UUID.js +32 -0
  150. package/dist/src/helpers/UUID.js.map +1 -0
  151. package/dist/src/helpers/debugHelpers.d.ts +3 -0
  152. package/dist/src/helpers/debugHelpers.js +11 -0
  153. package/dist/src/helpers/debugHelpers.js.map +1 -0
  154. package/dist/src/helpers/errors.d.ts +72 -0
  155. package/dist/src/helpers/errors.js +95 -0
  156. package/dist/src/helpers/errors.js.map +1 -0
  157. package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +5 -0
  158. package/dist/src/helpers/peerIdFromPeerDescriptor.js +17 -0
  159. package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -0
  160. package/dist/src/helpers/protoClasses.d.ts +2 -0
  161. package/dist/src/helpers/protoClasses.js +35 -0
  162. package/dist/src/helpers/protoClasses.js.map +1 -0
  163. package/dist/src/helpers/protoToString.d.ts +2 -0
  164. package/dist/src/helpers/protoToString.js +20 -0
  165. package/dist/src/helpers/protoToString.js.map +1 -0
  166. package/dist/src/proto/google/protobuf/any.d.ts +173 -0
  167. package/dist/src/proto/google/protobuf/any.js +155 -0
  168. package/dist/src/proto/google/protobuf/any.js.map +1 -0
  169. package/dist/src/proto/google/protobuf/empty.d.ts +32 -0
  170. package/dist/src/proto/google/protobuf/empty.js +34 -0
  171. package/dist/src/proto/google/protobuf/empty.js.map +1 -0
  172. package/dist/src/proto/google/protobuf/timestamp.d.ts +149 -0
  173. package/dist/src/proto/google/protobuf/timestamp.js +136 -0
  174. package/dist/src/proto/google/protobuf/timestamp.js.map +1 -0
  175. package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +320 -0
  176. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +245 -0
  177. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -0
  178. package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +1089 -0
  179. package/dist/src/proto/packages/dht/protos/DhtRpc.js +710 -0
  180. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -0
  181. package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +145 -0
  182. package/dist/src/proto/packages/dht/protos/DhtRpc.server.js +3 -0
  183. package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +1 -0
  184. package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.d.ts +87 -0
  185. package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +66 -0
  186. package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js.map +1 -0
  187. package/dist/src/proto/tests.d.ts +39 -0
  188. package/dist/src/proto/tests.js +34 -0
  189. package/dist/src/proto/tests.js.map +1 -0
  190. package/dist/src/rpc-protocol/DhtCallContext.d.ts +12 -0
  191. package/dist/src/rpc-protocol/DhtCallContext.js +8 -0
  192. package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -0
  193. package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +8 -0
  194. package/dist/src/rpc-protocol/DhtRpcOptions.js +3 -0
  195. package/dist/src/rpc-protocol/DhtRpcOptions.js.map +1 -0
  196. package/dist/src/transport/ITransport.d.ts +22 -0
  197. package/dist/src/transport/ITransport.js +3 -0
  198. package/dist/src/transport/ITransport.js.map +1 -0
  199. package/dist/src/transport/ListeningRpcCommunicator.d.ts +6 -0
  200. package/dist/src/transport/ListeningRpcCommunicator.js +14 -0
  201. package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -0
  202. package/dist/src/transport/RoutingRpcCommunicator.d.ts +8 -0
  203. package/dist/src/transport/RoutingRpcCommunicator.js +52 -0
  204. package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -0
  205. package/jest.config.js +2 -0
  206. package/karma.config.js +20 -0
  207. package/package.json +64 -0
  208. package/proto.sh +3 -0
  209. package/protos/DhtRpc.proto +330 -0
  210. package/protos/tests.proto +16 -0
  211. package/src/connection/Connection.ts +23 -0
  212. package/src/connection/ConnectionLockHandler.ts +105 -0
  213. package/src/connection/ConnectionManager.ts +676 -0
  214. package/src/connection/ConnectivityChecker.ts +173 -0
  215. package/src/connection/Handshaker.ts +92 -0
  216. package/src/connection/IConnection.ts +47 -0
  217. package/src/connection/IConnectionSource.ts +6 -0
  218. package/src/connection/ManagedConnection.ts +398 -0
  219. package/src/connection/ManagedWebRtcConnection.ts +27 -0
  220. package/src/connection/RemoteConnectionLocker.ts +88 -0
  221. package/src/connection/Simulator/Simulator.ts +399 -0
  222. package/src/connection/Simulator/SimulatorConnection.ts +137 -0
  223. package/src/connection/Simulator/SimulatorConnector.ts +104 -0
  224. package/src/connection/Simulator/SimulatorTransport.ts +9 -0
  225. package/src/connection/Simulator/pings.ts +42 -0
  226. package/src/connection/WebRTC/BrowserWebRtcConnection.ts +227 -0
  227. package/src/connection/WebRTC/IWebRtcConnection.ts +24 -0
  228. package/src/connection/WebRTC/NodeWebRtcConnection.ts +256 -0
  229. package/src/connection/WebRTC/RemoteWebrtcConnector.ts +93 -0
  230. package/src/connection/WebRTC/WebRtcConnector.ts +306 -0
  231. package/src/connection/WebRTC/iceServerAsString.ts +15 -0
  232. package/src/connection/WebSocket/ClientWebSocket.ts +118 -0
  233. package/src/connection/WebSocket/RemoteWebSocketConnector.ts +49 -0
  234. package/src/connection/WebSocket/ServerWebSocket.ts +119 -0
  235. package/src/connection/WebSocket/WebSocketConnector.ts +264 -0
  236. package/src/connection/WebSocket/WebSocketServer.ts +97 -0
  237. package/src/dht/DhtNode.ts +776 -0
  238. package/src/dht/DhtPeer.ts +96 -0
  239. package/src/dht/ExternalApi.ts +29 -0
  240. package/src/dht/RemoteExternalApi.ts +25 -0
  241. package/src/dht/contact/Contact.ts +36 -0
  242. package/src/dht/contact/RandomContactList.ts +92 -0
  243. package/src/dht/contact/Remote.ts +40 -0
  244. package/src/dht/contact/SortedContactList.ts +196 -0
  245. package/src/dht/discovery/DiscoverySession.ts +150 -0
  246. package/src/dht/discovery/PeerDiscovery.ts +162 -0
  247. package/src/dht/find/RecursiveFindSession.ts +178 -0
  248. package/src/dht/find/RecursiveFinder.ts +272 -0
  249. package/src/dht/find/RemoteRecursiveFindSession.ts +33 -0
  250. package/src/dht/routing/DuplicateDetector.ts +53 -0
  251. package/src/dht/routing/RemoteRouter.ts +115 -0
  252. package/src/dht/routing/Router.ts +266 -0
  253. package/src/dht/routing/RoutingSession.ts +222 -0
  254. package/src/dht/store/DataStore.ts +321 -0
  255. package/src/dht/store/LocalDataStore.ts +114 -0
  256. package/src/dht/store/RemoteStore.ts +58 -0
  257. package/src/exports.ts +19 -0
  258. package/src/helpers/AddressTools.ts +26 -0
  259. package/src/helpers/PeerID.ts +95 -0
  260. package/src/helpers/UUID.ts +30 -0
  261. package/src/helpers/debugHelpers.ts +9 -0
  262. package/src/helpers/errors.ts +49 -0
  263. package/src/helpers/peerIdFromPeerDescriptor.ts +14 -0
  264. package/src/helpers/protoClasses.ts +63 -0
  265. package/src/helpers/protoToString.ts +21 -0
  266. package/src/proto/google/protobuf/any.ts +319 -0
  267. package/src/proto/google/protobuf/empty.ts +84 -0
  268. package/src/proto/google/protobuf/timestamp.ts +281 -0
  269. package/src/proto/packages/dht/protos/DhtRpc.client.ts +373 -0
  270. package/src/proto/packages/dht/protos/DhtRpc.server.ts +148 -0
  271. package/src/proto/packages/dht/protos/DhtRpc.ts +1399 -0
  272. package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +108 -0
  273. package/src/proto/tests.ts +52 -0
  274. package/src/rpc-protocol/DhtCallContext.ts +15 -0
  275. package/src/rpc-protocol/DhtRpcOptions.ts +9 -0
  276. package/src/transport/ITransport.ts +31 -0
  277. package/src/transport/ListeningRpcCommunicator.ts +14 -0
  278. package/src/transport/RoutingRpcCommunicator.ts +59 -0
  279. package/src/types/glogal.d.ts +1 -0
  280. package/src/types/textencoding.d.ts +7 -0
  281. package/test/RandomGraphSimulation.ts +52 -0
  282. package/test/benchmark/KademliaCorrectness.test.ts +115 -0
  283. package/test/benchmark/RecursiveFind.test.ts +87 -0
  284. package/test/benchmark/any.test.ts +28 -0
  285. package/test/benchmark/kademlia-simulation/Contact.ts +32 -0
  286. package/test/benchmark/kademlia-simulation/KademliaSimulation.ts +94 -0
  287. package/test/benchmark/kademlia-simulation/SimulationNode.ts +125 -0
  288. package/test/data/generateGroundTruthData.ts +70 -0
  289. package/test/end-to-end/Layer0-Layer1.test.ts +87 -0
  290. package/test/end-to-end/Layer0.test.ts +60 -0
  291. package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +94 -0
  292. package/test/end-to-end/Layer0WebRTC-Layer1.test.ts +134 -0
  293. package/test/end-to-end/Layer0WebRTC.test.ts +98 -0
  294. package/test/end-to-end/Layer1-Scale-WebRTC.test.ts +69 -0
  295. package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +73 -0
  296. package/test/end-to-end/WebSocketConnectionRequest.test.ts +62 -0
  297. package/test/integration/ConnectionLocking.test.ts +166 -0
  298. package/test/integration/ConnectionManager.test.ts +291 -0
  299. package/test/integration/DhtNodeExternalAPI.test.ts +43 -0
  300. package/test/integration/DhtPeer.test.ts +73 -0
  301. package/test/integration/DhtRpc.test.ts +131 -0
  302. package/test/integration/DhtWithMockConnectionLatencies.test.ts +46 -0
  303. package/test/integration/DhtWithMockConnections.test.ts +46 -0
  304. package/test/integration/DhtWithRealConnectionLatencies.test.ts +47 -0
  305. package/test/integration/Layer1-scale.test.ts +200 -0
  306. package/test/integration/MigrateData.test.ts +203 -0
  307. package/test/integration/Mock-Layer1-Layer0.test.ts +106 -0
  308. package/test/integration/MultipleEntryPointJoining.test.ts +105 -0
  309. package/test/integration/RecursiveFind.test.ts +50 -0
  310. package/test/integration/RemoteRouter.test.ts +83 -0
  311. package/test/integration/RemoteStore.test.ts +66 -0
  312. package/test/integration/RouteMessage.test.ts +254 -0
  313. package/test/integration/RpcErrors.test.ts +153 -0
  314. package/test/integration/ScaleDownDht.test.ts +66 -0
  315. package/test/integration/SimultaneousConnections.test.ts +308 -0
  316. package/test/integration/Store.test.ts +72 -0
  317. package/test/integration/StoreAndDelete.test.ts +93 -0
  318. package/test/integration/StoreOnDhtWithTwoNodes.test.ts +71 -0
  319. package/test/integration/WebRtcConnectionManagement.test.ts +205 -0
  320. package/test/integration/WebRtcConnectorRpc.test.ts +145 -0
  321. package/test/integration/WebSocket.test.ts +64 -0
  322. package/test/integration/WebSocketConnectionManagement.test.ts +131 -0
  323. package/test/integration/WebSocketConnectorRpc.test.ts +86 -0
  324. package/test/kademlia-simulation/data/nodeids.json +13002 -0
  325. package/test/kademlia-simulation/data/orderedneighbors.json +1001 -0
  326. package/test/unit/AddressTools.test.ts +40 -0
  327. package/test/unit/DuplicateDetector.test.ts +29 -0
  328. package/test/unit/LocalDataStore.test.ts +107 -0
  329. package/test/unit/PeerID.test.ts +22 -0
  330. package/test/unit/ProtobufMessage.test.ts +21 -0
  331. package/test/unit/RandomContactList.test.ts +87 -0
  332. package/test/unit/RecursiveFinder.test.ts +112 -0
  333. package/test/unit/Router.test.ts +124 -0
  334. package/test/unit/SortedContactList.test.ts +127 -0
  335. package/test/unit/UUID.test.ts +49 -0
  336. package/test/unit/WebSocketServer.test.ts +42 -0
  337. package/test/utils/mock/RecursiveFinder.ts +19 -0
  338. package/test/utils/mock/Router.ts +53 -0
  339. package/test/utils/mock/Transport.ts +26 -0
  340. package/test/utils/utils.ts +311 -0
  341. package/tsconfig.browser.json +15 -0
  342. package/tsconfig.jest.json +19 -0
  343. package/tsconfig.json +3 -0
  344. package/tsconfig.node.json +18 -0
@@ -0,0 +1,49 @@
1
+ /* eslint-disable max-len */
2
+
3
+ export enum ErrorCode {
4
+ CONNECTION_FAILED = 'CONNECTION_FAILED',
5
+ COULD_NOT_ROUTE = 'COULD_NOT_ROUTE',
6
+ STARTING_WEBSOCKET_SERVER_FAILED = 'STARTING_WEBSOCKET_SERVER_FAILED',
7
+ WEBSOCKET_CONNECTION_REQUEST_REJECTED = 'WEBSOCKET_CONNECTION_REQUEST_REJECTED',
8
+ COULD_NOT_START = 'COULD_NOT_START',
9
+ COULD_NOT_STOP = 'COULD_NOT_STOP',
10
+ CANNOT_CONNECT_TO_SELF = 'CANNOT_CONNECT_TO_SELF',
11
+ NOT_IMPLEMENTED = 'NOT_IMPLEMENTED',
12
+ ILLEGAL_RTC_PEER_CONNECTION_STATE = 'ILLEGAL_RTC_PEER_CONNECTION_STATE',
13
+ ILLEGAL_ARGUMENTS = 'ILLEGAL_ARGUMENTS',
14
+ CONNECTIVITY_RESPONSE_NOT_RECEIVED_BEFORE_TIMEOUT = 'CONNECTIVITY_RESPONSE_NOT_RECEIVED_BEFORE_TIMEOUT',
15
+ CONNECTION_LOCKER = 'CONNECTION_LOCKER',
16
+ DHT_JOIN_TIMEOUT = 'DHT_JOIN_TIMEOUT',
17
+ SEND_FAILED = 'SEND_FAILED',
18
+ GETTING_DATA_FAILED = 'GETTING_DATA_FAILED',
19
+ CONNECTION_NOT_OPEN = 'CONNECTION_NOT_OPEN'
20
+ }
21
+
22
+ class Err extends Error {
23
+
24
+ public code: ErrorCode
25
+ public originalError?: Error | string
26
+
27
+ constructor(code: ErrorCode, message?: string, originalError?: Error | string) {
28
+ super(message)
29
+ this.code = code
30
+ this.originalError = originalError
31
+ }
32
+ }
33
+
34
+ export class ConnectionFailed extends Err { constructor( message?: string, originalError?: Error | string) { super(ErrorCode.CONNECTION_FAILED, message, originalError) } }
35
+ export class CouldNotRoute extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.COULD_NOT_ROUTE, message, originalError) } }
36
+ export class StartingWebSocketServerFailed extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.STARTING_WEBSOCKET_SERVER_FAILED, message, originalError) } }
37
+ export class WebSocketConnectionRequestRejected extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.WEBSOCKET_CONNECTION_REQUEST_REJECTED, message, originalError) } }
38
+ export class CouldNotStart extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.COULD_NOT_START, message, originalError) } }
39
+ export class CouldNotStop extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.COULD_NOT_STOP, message, originalError) } }
40
+ export class CannotConnectToSelf extends Err { constructor(message?: string, originalError?: Error | string) {super(ErrorCode.CANNOT_CONNECT_TO_SELF, message, originalError) } }
41
+ export class NotImplemented extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.NOT_IMPLEMENTED, message, originalError) } }
42
+ export class IllegalRTCPeerConnectionState extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.ILLEGAL_RTC_PEER_CONNECTION_STATE, message, originalError) } }
43
+ export class IllegalArguments extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.ILLEGAL_ARGUMENTS, message, originalError) } }
44
+ export class ConnectivityResponseTimeout extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.CONNECTIVITY_RESPONSE_NOT_RECEIVED_BEFORE_TIMEOUT, message, originalError) } }
45
+ export class ConnectionLocker extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.CONNECTION_LOCKER, message, originalError) } }
46
+ export class DhtJoinTimeout extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.DHT_JOIN_TIMEOUT, message, originalError) } }
47
+ export class SendFailed extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.SEND_FAILED, message, originalError) } }
48
+ export class GettingDataFailed extends Err { constructor(message?: string, originalError?: Error | string) { super(ErrorCode.GETTING_DATA_FAILED, message, originalError) } }
49
+ export class ConnectionNotOpen extends Err { constructor( message?: string, originalError?: Error | string) { super(ErrorCode.CONNECTION_NOT_OPEN, message, originalError) } }
@@ -0,0 +1,14 @@
1
+ import { PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc'
2
+ import { PeerID, PeerIDKey } from './PeerID'
3
+
4
+ export const peerIdFromPeerDescriptor = (peerDescriptor: PeerDescriptor): PeerID => {
5
+ return PeerID.fromValue(peerDescriptor.kademliaId)
6
+ }
7
+
8
+ export const keyFromPeerDescriptor = (peerDescriptor: PeerDescriptor): PeerIDKey => {
9
+ return PeerID.fromValue(peerDescriptor.kademliaId).toKey()
10
+ }
11
+
12
+ export const isSamePeerDescriptor = (peerDescriptor1: PeerDescriptor, peerDescriptor2: PeerDescriptor): boolean => {
13
+ return peerIdFromPeerDescriptor(peerDescriptor1).equals(peerIdFromPeerDescriptor(peerDescriptor2))
14
+ }
@@ -0,0 +1,63 @@
1
+ import { IMessageType } from '@protobuf-ts/runtime'
2
+ import {
3
+ ClosestPeersRequest,
4
+ ClosestPeersResponse,
5
+ ConnectivityMethod,
6
+ ConnectivityReportRequest,
7
+ ConnectivityReportResponse,
8
+ ConnectivityRequest,
9
+ ConnectivityResponse,
10
+ DisconnectNotice,
11
+ HandshakeRequest,
12
+ HandshakeResponse,
13
+ LeaveNotice,
14
+ Message,
15
+ PeerDescriptor,
16
+ PingRequest,
17
+ PingResponse,
18
+ RecursiveFindReport,
19
+ RecursiveFindRequest,
20
+ RouteMessageAck,
21
+ RouteMessageWrapper,
22
+ WebSocketConnectionRequest,
23
+ WebSocketConnectionResponse,
24
+ WebRtcConnectionRequest,
25
+ RtcOffer,
26
+ RtcAnswer,
27
+ IceCandidate,
28
+ LockRequest,
29
+ UnlockRequest,
30
+ LockResponse
31
+
32
+ } from '../proto/packages/dht/protos/DhtRpc'
33
+
34
+ export const protoClasses: Array<IMessageType<any>> = [
35
+ ClosestPeersRequest,
36
+ ClosestPeersResponse,
37
+ RecursiveFindRequest,
38
+ RecursiveFindReport,
39
+ PingRequest,
40
+ PingResponse,
41
+ LeaveNotice,
42
+ PeerDescriptor,
43
+ ConnectivityMethod,
44
+ ConnectivityReportRequest,
45
+ ConnectivityReportResponse,
46
+ DisconnectNotice,
47
+ RouteMessageWrapper,
48
+ RouteMessageAck,
49
+ ConnectivityRequest,
50
+ ConnectivityResponse,
51
+ HandshakeRequest,
52
+ HandshakeResponse,
53
+ Message,
54
+ WebSocketConnectionRequest,
55
+ WebSocketConnectionResponse,
56
+ WebRtcConnectionRequest,
57
+ RtcOffer,
58
+ RtcAnswer,
59
+ IceCandidate,
60
+ LockRequest,
61
+ UnlockRequest,
62
+ LockResponse
63
+ ]
@@ -0,0 +1,21 @@
1
+ import { IMessageType } from '@protobuf-ts/runtime'
2
+
3
+ import { protoClasses } from './protoClasses'
4
+ import { protoClasses as rpcProtoClasses } from '@streamr/proto-rpc'
5
+
6
+ const typeRegistry = protoClasses.concat(rpcProtoClasses)
7
+
8
+ export function protoToString<T extends object, ClassType extends IMessageType<T>>(protoObj: T,
9
+ objectType: ClassType): string {
10
+
11
+ let ret = ''
12
+ try {
13
+ ret = objectType.toJsonString(protoObj, {
14
+ typeRegistry
15
+ })
16
+ } catch (_e) {
17
+ ret = '[type not in type registry]'
18
+ }
19
+
20
+ return ret
21
+ }
@@ -0,0 +1,319 @@
1
+ // @generated by protobuf-ts 2.8.2 with parameter server_generic,generate_dependencies,long_type_number
2
+ // @generated from protobuf file "google/protobuf/any.proto" (package "google.protobuf", syntax proto3)
3
+ // tslint:disable
4
+ //
5
+ // Protocol Buffers - Google's data interchange format
6
+ // Copyright 2008 Google Inc. All rights reserved.
7
+ // https://developers.google.com/protocol-buffers/
8
+ //
9
+ // Redistribution and use in source and binary forms, with or without
10
+ // modification, are permitted provided that the following conditions are
11
+ // met:
12
+ //
13
+ // * Redistributions of source code must retain the above copyright
14
+ // notice, this list of conditions and the following disclaimer.
15
+ // * Redistributions in binary form must reproduce the above
16
+ // copyright notice, this list of conditions and the following disclaimer
17
+ // in the documentation and/or other materials provided with the
18
+ // distribution.
19
+ // * Neither the name of Google Inc. nor the names of its
20
+ // contributors may be used to endorse or promote products derived from
21
+ // this software without specific prior written permission.
22
+ //
23
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ //
35
+ import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
36
+ import type { IBinaryWriter } from "@protobuf-ts/runtime";
37
+ import { WireType } from "@protobuf-ts/runtime";
38
+ import type { IBinaryReader } from "@protobuf-ts/runtime";
39
+ import { UnknownFieldHandler } from "@protobuf-ts/runtime";
40
+ import type { PartialMessage } from "@protobuf-ts/runtime";
41
+ import { reflectionMergePartial } from "@protobuf-ts/runtime";
42
+ import { MESSAGE_TYPE } from "@protobuf-ts/runtime";
43
+ import { isJsonObject } from "@protobuf-ts/runtime";
44
+ import { typeofJsonValue } from "@protobuf-ts/runtime";
45
+ import type { JsonValue } from "@protobuf-ts/runtime";
46
+ import { jsonWriteOptions } from "@protobuf-ts/runtime";
47
+ import type { JsonReadOptions } from "@protobuf-ts/runtime";
48
+ import type { JsonWriteOptions } from "@protobuf-ts/runtime";
49
+ import type { BinaryReadOptions } from "@protobuf-ts/runtime";
50
+ import type { IMessageType } from "@protobuf-ts/runtime";
51
+ import { MessageType } from "@protobuf-ts/runtime";
52
+ /**
53
+ * `Any` contains an arbitrary serialized protocol buffer message along with a
54
+ * URL that describes the type of the serialized message.
55
+ *
56
+ * Protobuf library provides support to pack/unpack Any values in the form
57
+ * of utility functions or additional generated methods of the Any type.
58
+ *
59
+ * Example 1: Pack and unpack a message in C++.
60
+ *
61
+ * Foo foo = ...;
62
+ * Any any;
63
+ * any.PackFrom(foo);
64
+ * ...
65
+ * if (any.UnpackTo(&foo)) {
66
+ * ...
67
+ * }
68
+ *
69
+ * Example 2: Pack and unpack a message in Java.
70
+ *
71
+ * Foo foo = ...;
72
+ * Any any = Any.pack(foo);
73
+ * ...
74
+ * if (any.is(Foo.class)) {
75
+ * foo = any.unpack(Foo.class);
76
+ * }
77
+ *
78
+ * Example 3: Pack and unpack a message in Python.
79
+ *
80
+ * foo = Foo(...)
81
+ * any = Any()
82
+ * any.Pack(foo)
83
+ * ...
84
+ * if any.Is(Foo.DESCRIPTOR):
85
+ * any.Unpack(foo)
86
+ * ...
87
+ *
88
+ * Example 4: Pack and unpack a message in Go
89
+ *
90
+ * foo := &pb.Foo{...}
91
+ * any, err := ptypes.MarshalAny(foo)
92
+ * ...
93
+ * foo := &pb.Foo{}
94
+ * if err := ptypes.UnmarshalAny(any, foo); err != nil {
95
+ * ...
96
+ * }
97
+ *
98
+ * The pack methods provided by protobuf library will by default use
99
+ * 'type.googleapis.com/full.type.name' as the type URL and the unpack
100
+ * methods only use the fully qualified type name after the last '/'
101
+ * in the type URL, for example "foo.bar.com/x/y.z" will yield type
102
+ * name "y.z".
103
+ *
104
+ *
105
+ * JSON
106
+ * ====
107
+ * The JSON representation of an `Any` value uses the regular
108
+ * representation of the deserialized, embedded message, with an
109
+ * additional field `@type` which contains the type URL. Example:
110
+ *
111
+ * package google.profile;
112
+ * message Person {
113
+ * string first_name = 1;
114
+ * string last_name = 2;
115
+ * }
116
+ *
117
+ * {
118
+ * "@type": "type.googleapis.com/google.profile.Person",
119
+ * "firstName": <string>,
120
+ * "lastName": <string>
121
+ * }
122
+ *
123
+ * If the embedded message type is well-known and has a custom JSON
124
+ * representation, that representation will be embedded adding a field
125
+ * `value` which holds the custom JSON in addition to the `@type`
126
+ * field. Example (for message [google.protobuf.Duration][]):
127
+ *
128
+ * {
129
+ * "@type": "type.googleapis.com/google.protobuf.Duration",
130
+ * "value": "1.212s"
131
+ * }
132
+ *
133
+ *
134
+ * @generated from protobuf message google.protobuf.Any
135
+ */
136
+ export interface Any {
137
+ /**
138
+ * A URL/resource name that uniquely identifies the type of the serialized
139
+ * protocol buffer message. This string must contain at least
140
+ * one "/" character. The last segment of the URL's path must represent
141
+ * the fully qualified name of the type (as in
142
+ * `path/google.protobuf.Duration`). The name should be in a canonical form
143
+ * (e.g., leading "." is not accepted).
144
+ *
145
+ * In practice, teams usually precompile into the binary all types that they
146
+ * expect it to use in the context of Any. However, for URLs which use the
147
+ * scheme `http`, `https`, or no scheme, one can optionally set up a type
148
+ * server that maps type URLs to message definitions as follows:
149
+ *
150
+ * * If no scheme is provided, `https` is assumed.
151
+ * * An HTTP GET on the URL must yield a [google.protobuf.Type][]
152
+ * value in binary format, or produce an error.
153
+ * * Applications are allowed to cache lookup results based on the
154
+ * URL, or have them precompiled into a binary to avoid any
155
+ * lookup. Therefore, binary compatibility needs to be preserved
156
+ * on changes to types. (Use versioned type names to manage
157
+ * breaking changes.)
158
+ *
159
+ * Note: this functionality is not currently available in the official
160
+ * protobuf release, and it is not used for type URLs beginning with
161
+ * type.googleapis.com.
162
+ *
163
+ * Schemes other than `http`, `https` (or the empty scheme) might be
164
+ * used with implementation specific semantics.
165
+ *
166
+ *
167
+ * @generated from protobuf field: string type_url = 1;
168
+ */
169
+ typeUrl: string;
170
+ /**
171
+ * Must be a valid serialized protocol buffer of the above specified type.
172
+ *
173
+ * @generated from protobuf field: bytes value = 2;
174
+ */
175
+ value: Uint8Array;
176
+ }
177
+ // @generated message type with reflection information, may provide speed optimized methods
178
+ class Any$Type extends MessageType<Any> {
179
+ constructor() {
180
+ super("google.protobuf.Any", [
181
+ { no: 1, name: "type_url", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
182
+ { no: 2, name: "value", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }
183
+ ]);
184
+ }
185
+ /**
186
+ * Pack the message into a new `Any`.
187
+ *
188
+ * Uses 'type.googleapis.com/full.type.name' as the type URL.
189
+ */
190
+ pack<T extends object>(message: T, type: IMessageType<T>): Any {
191
+ return {
192
+ typeUrl: this.typeNameToUrl(type.typeName), value: type.toBinary(message),
193
+ };
194
+ }
195
+ /**
196
+ * Unpack the message from the `Any`.
197
+ */
198
+ unpack<T extends object>(any: Any, type: IMessageType<T>, options?: Partial<BinaryReadOptions>): T {
199
+ if (!this.contains(any, type))
200
+ throw new Error("Cannot unpack google.protobuf.Any with typeUrl '" + any.typeUrl + "' as " + type.typeName + ".");
201
+ return type.fromBinary(any.value, options);
202
+ }
203
+ /**
204
+ * Does the given `Any` contain a packed message of the given type?
205
+ */
206
+ contains(any: Any, type: IMessageType<any> | string): boolean {
207
+ if (!any.typeUrl.length)
208
+ return false;
209
+ let wants = typeof type == "string" ? type : type.typeName;
210
+ let has = this.typeUrlToName(any.typeUrl);
211
+ return wants === has;
212
+ }
213
+ /**
214
+ * Convert the message to canonical JSON value.
215
+ *
216
+ * You have to provide the `typeRegistry` option so that the
217
+ * packed message can be converted to JSON.
218
+ *
219
+ * The `typeRegistry` option is also required to read
220
+ * `google.protobuf.Any` from JSON format.
221
+ */
222
+ internalJsonWrite(any: Any, options: JsonWriteOptions): JsonValue {
223
+ if (any.typeUrl === "")
224
+ return {};
225
+ let typeName = this.typeUrlToName(any.typeUrl);
226
+ let opt = jsonWriteOptions(options);
227
+ let type = opt.typeRegistry?.find(t => t.typeName === typeName);
228
+ if (!type)
229
+ throw new globalThis.Error("Unable to convert google.protobuf.Any with typeUrl '" + any.typeUrl + "' to JSON. The specified type " + typeName + " is not available in the type registry.");
230
+ let value = type.fromBinary(any.value, { readUnknownField: false });
231
+ let json = type.internalJsonWrite(value, opt);
232
+ if (typeName.startsWith("google.protobuf.") || !isJsonObject(json))
233
+ json = { value: json };
234
+ json["@type"] = any.typeUrl;
235
+ return json;
236
+ }
237
+ internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Any): Any {
238
+ if (!isJsonObject(json))
239
+ throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON " + typeofJsonValue(json) + ".");
240
+ if (typeof json["@type"] != "string" || json["@type"] == "")
241
+ return this.create();
242
+ let typeName = this.typeUrlToName(json["@type"]);
243
+ let type = options?.typeRegistry?.find(t => t.typeName == typeName);
244
+ if (!type)
245
+ throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON. The specified type " + typeName + " is not available in the type registry.");
246
+ let value;
247
+ if (typeName.startsWith("google.protobuf.") && json.hasOwnProperty("value"))
248
+ value = type.fromJson(json["value"], options);
249
+ else {
250
+ let copy = Object.assign({}, json);
251
+ delete copy["@type"];
252
+ value = type.fromJson(copy, options);
253
+ }
254
+ if (target === undefined)
255
+ target = this.create();
256
+ target.typeUrl = json["@type"];
257
+ target.value = type.toBinary(value);
258
+ return target;
259
+ }
260
+ typeNameToUrl(name: string): string {
261
+ if (!name.length)
262
+ throw new Error("invalid type name: " + name);
263
+ return "type.googleapis.com/" + name;
264
+ }
265
+ typeUrlToName(url: string): string {
266
+ if (!url.length)
267
+ throw new Error("invalid type url: " + url);
268
+ let slash = url.lastIndexOf("/");
269
+ let name = slash > 0 ? url.substring(slash + 1) : url;
270
+ if (!name.length)
271
+ throw new Error("invalid type url: " + url);
272
+ return name;
273
+ }
274
+ create(value?: PartialMessage<Any>): Any {
275
+ const message = { typeUrl: "", value: new Uint8Array(0) };
276
+ globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
277
+ if (value !== undefined)
278
+ reflectionMergePartial<Any>(this, message, value);
279
+ return message;
280
+ }
281
+ internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Any): Any {
282
+ let message = target ?? this.create(), end = reader.pos + length;
283
+ while (reader.pos < end) {
284
+ let [fieldNo, wireType] = reader.tag();
285
+ switch (fieldNo) {
286
+ case /* string type_url */ 1:
287
+ message.typeUrl = reader.string();
288
+ break;
289
+ case /* bytes value */ 2:
290
+ message.value = reader.bytes();
291
+ break;
292
+ default:
293
+ let u = options.readUnknownField;
294
+ if (u === "throw")
295
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
296
+ let d = reader.skip(wireType);
297
+ if (u !== false)
298
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
299
+ }
300
+ }
301
+ return message;
302
+ }
303
+ internalBinaryWrite(message: Any, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
304
+ /* string type_url = 1; */
305
+ if (message.typeUrl !== "")
306
+ writer.tag(1, WireType.LengthDelimited).string(message.typeUrl);
307
+ /* bytes value = 2; */
308
+ if (message.value.length)
309
+ writer.tag(2, WireType.LengthDelimited).bytes(message.value);
310
+ let u = options.writeUnknownFields;
311
+ if (u !== false)
312
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
313
+ return writer;
314
+ }
315
+ }
316
+ /**
317
+ * @generated MessageType for protobuf message google.protobuf.Any
318
+ */
319
+ export const Any = new Any$Type();
@@ -0,0 +1,84 @@
1
+ // @generated by protobuf-ts 2.8.2 with parameter server_generic,generate_dependencies,long_type_number
2
+ // @generated from protobuf file "google/protobuf/empty.proto" (package "google.protobuf", syntax proto3)
3
+ // tslint:disable
4
+ //
5
+ // Protocol Buffers - Google's data interchange format
6
+ // Copyright 2008 Google Inc. All rights reserved.
7
+ // https://developers.google.com/protocol-buffers/
8
+ //
9
+ // Redistribution and use in source and binary forms, with or without
10
+ // modification, are permitted provided that the following conditions are
11
+ // met:
12
+ //
13
+ // * Redistributions of source code must retain the above copyright
14
+ // notice, this list of conditions and the following disclaimer.
15
+ // * Redistributions in binary form must reproduce the above
16
+ // copyright notice, this list of conditions and the following disclaimer
17
+ // in the documentation and/or other materials provided with the
18
+ // distribution.
19
+ // * Neither the name of Google Inc. nor the names of its
20
+ // contributors may be used to endorse or promote products derived from
21
+ // this software without specific prior written permission.
22
+ //
23
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ //
35
+ import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
36
+ import type { IBinaryWriter } from "@protobuf-ts/runtime";
37
+ import { UnknownFieldHandler } from "@protobuf-ts/runtime";
38
+ import type { BinaryReadOptions } from "@protobuf-ts/runtime";
39
+ import type { IBinaryReader } from "@protobuf-ts/runtime";
40
+ import type { PartialMessage } from "@protobuf-ts/runtime";
41
+ import { reflectionMergePartial } from "@protobuf-ts/runtime";
42
+ import { MESSAGE_TYPE } from "@protobuf-ts/runtime";
43
+ import { MessageType } from "@protobuf-ts/runtime";
44
+ /**
45
+ * A generic empty message that you can re-use to avoid defining duplicated
46
+ * empty messages in your APIs. A typical example is to use it as the request
47
+ * or the response type of an API method. For instance:
48
+ *
49
+ * service Foo {
50
+ * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
51
+ * }
52
+ *
53
+ * The JSON representation for `Empty` is empty JSON object `{}`.
54
+ *
55
+ * @generated from protobuf message google.protobuf.Empty
56
+ */
57
+ export interface Empty {
58
+ }
59
+ // @generated message type with reflection information, may provide speed optimized methods
60
+ class Empty$Type extends MessageType<Empty> {
61
+ constructor() {
62
+ super("google.protobuf.Empty", []);
63
+ }
64
+ create(value?: PartialMessage<Empty>): Empty {
65
+ const message = {};
66
+ globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
67
+ if (value !== undefined)
68
+ reflectionMergePartial<Empty>(this, message, value);
69
+ return message;
70
+ }
71
+ internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Empty): Empty {
72
+ return target ?? this.create();
73
+ }
74
+ internalBinaryWrite(message: Empty, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
75
+ let u = options.writeUnknownFields;
76
+ if (u !== false)
77
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
78
+ return writer;
79
+ }
80
+ }
81
+ /**
82
+ * @generated MessageType for protobuf message google.protobuf.Empty
83
+ */
84
+ export const Empty = new Empty$Type();