@streamr/dht 101.1.2 → 102.0.0-beta.1

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 (369) hide show
  1. package/dist/package.json +17 -18
  2. package/dist/src/connection/Connection.d.ts +1 -1
  3. package/dist/src/connection/ConnectionLockRpcLocal.d.ts +5 -3
  4. package/dist/src/connection/ConnectionLockRpcLocal.js +9 -3
  5. package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
  6. package/dist/src/connection/ConnectionLockRpcRemote.d.ts +3 -2
  7. package/dist/src/connection/ConnectionLockRpcRemote.js +14 -3
  8. package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
  9. package/dist/src/connection/ConnectionLockStates.d.ts +5 -0
  10. package/dist/src/connection/ConnectionLockStates.js +14 -0
  11. package/dist/src/connection/ConnectionLockStates.js.map +1 -1
  12. package/dist/src/connection/ConnectionManager.d.ts +8 -1
  13. package/dist/src/connection/ConnectionManager.js +96 -32
  14. package/dist/src/connection/ConnectionManager.js.map +1 -1
  15. package/dist/src/connection/ConnectionsView.d.ts +1 -1
  16. package/dist/src/connection/ConnectorFacade.d.ts +1 -1
  17. package/dist/src/connection/Handshaker.d.ts +2 -2
  18. package/dist/src/connection/Handshaker.js +11 -7
  19. package/dist/src/connection/Handshaker.js.map +1 -1
  20. package/dist/src/connection/ManagedConnection.d.ts +7 -1
  21. package/dist/src/connection/ManagedConnection.js +41 -8
  22. package/dist/src/connection/ManagedConnection.js.map +1 -1
  23. package/dist/src/connection/PendingConnection.d.ts +1 -1
  24. package/dist/src/connection/connectivityChecker.d.ts +1 -1
  25. package/dist/src/connection/connectivityChecker.js +22 -11
  26. package/dist/src/connection/connectivityChecker.js.map +1 -1
  27. package/dist/src/connection/connectivityRequestHandler.js +4 -4
  28. package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
  29. package/dist/src/connection/simulator/Simulator.d.ts +1 -1
  30. package/dist/src/connection/simulator/Simulator.js +5 -4
  31. package/dist/src/connection/simulator/Simulator.js.map +1 -1
  32. package/dist/src/connection/simulator/SimulatorConnection.d.ts +1 -1
  33. package/dist/src/connection/simulator/SimulatorConnection.js +9 -9
  34. package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
  35. package/dist/src/connection/simulator/SimulatorConnector.d.ts +1 -1
  36. package/dist/src/connection/simulator/SimulatorConnector.js +4 -4
  37. package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
  38. package/dist/src/connection/simulator/SimulatorTransport.d.ts +1 -1
  39. package/dist/src/connection/simulator/SimulatorTransport.js +2 -1
  40. package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -1
  41. package/dist/src/connection/simulator/pings.d.ts +1 -1
  42. package/dist/src/connection/simulator/pings.js +3 -3
  43. package/dist/src/connection/simulator/pings.js.map +1 -1
  44. package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +2 -1
  45. package/dist/src/connection/webrtc/NodeWebrtcConnection.js +13 -8
  46. package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
  47. package/dist/src/connection/webrtc/WebrtcConnector.d.ts +2 -1
  48. package/dist/src/connection/webrtc/WebrtcConnector.js +28 -17
  49. package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
  50. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +3 -3
  51. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +4 -4
  52. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
  53. package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +1 -1
  54. package/dist/src/connection/webrtc/iceServerAsString.js +1 -2
  55. package/dist/src/connection/webrtc/iceServerAsString.js.map +1 -1
  56. package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +0 -1
  57. package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +1 -1
  58. package/dist/src/connection/websocket/WebsocketClientConnector.js +3 -3
  59. package/dist/src/connection/websocket/WebsocketClientConnector.js.map +1 -1
  60. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +3 -4
  61. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +1 -1
  62. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +1 -1
  63. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +1 -1
  64. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js +1 -1
  65. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +1 -1
  66. package/dist/src/connection/websocket/WebsocketServerConnection.d.ts +0 -1
  67. package/dist/src/connection/websocket/WebsocketServerConnector.d.ts +1 -1
  68. package/dist/src/connection/websocket/WebsocketServerConnector.js +34 -24
  69. package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -1
  70. package/dist/src/dht/DhtNode.d.ts +5 -2
  71. package/dist/src/dht/DhtNode.js +20 -8
  72. package/dist/src/dht/DhtNode.js.map +1 -1
  73. package/dist/src/dht/DhtNodeRpcLocal.d.ts +4 -4
  74. package/dist/src/dht/DhtNodeRpcLocal.js +3 -3
  75. package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
  76. package/dist/src/dht/DhtNodeRpcRemote.d.ts +2 -2
  77. package/dist/src/dht/DhtNodeRpcRemote.js +3 -3
  78. package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
  79. package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
  80. package/dist/src/dht/ExternalApiRpcLocal.js +3 -3
  81. package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
  82. package/dist/src/dht/ExternalApiRpcRemote.d.ts +3 -3
  83. package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
  84. package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
  85. package/dist/src/dht/PeerManager.d.ts +3 -2
  86. package/dist/src/dht/PeerManager.js +12 -11
  87. package/dist/src/dht/PeerManager.js.map +1 -1
  88. package/dist/src/dht/contact/Contact.d.ts +1 -1
  89. package/dist/src/dht/contact/Contact.js +1 -1
  90. package/dist/src/dht/contact/Contact.js.map +1 -1
  91. package/dist/src/dht/contact/RingContactList.d.ts +1 -1
  92. package/dist/src/dht/contact/RingContactList.js +1 -1
  93. package/dist/src/dht/contact/RingContactList.js.map +1 -1
  94. package/dist/src/dht/contact/RpcRemote.d.ts +1 -1
  95. package/dist/src/dht/contact/SortedContactList.js +2 -2
  96. package/dist/src/dht/contact/SortedContactList.js.map +1 -1
  97. package/dist/src/dht/contact/ringIdentifiers.d.ts +1 -1
  98. package/dist/src/dht/discovery/DiscoverySession.d.ts +1 -2
  99. package/dist/src/dht/discovery/DiscoverySession.js +3 -3
  100. package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
  101. package/dist/src/dht/discovery/PeerDiscovery.d.ts +1 -2
  102. package/dist/src/dht/discovery/PeerDiscovery.js +7 -7
  103. package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
  104. package/dist/src/dht/discovery/RingDiscoverySession.d.ts +0 -1
  105. package/dist/src/dht/discovery/RingDiscoverySession.js +1 -1
  106. package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
  107. package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +3 -3
  108. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +8 -8
  109. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
  110. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +2 -2
  111. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +2 -2
  112. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
  113. package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +2 -2
  114. package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +3 -3
  115. package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -1
  116. package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +1 -1
  117. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +7 -7
  118. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
  119. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +3 -3
  120. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +1 -1
  121. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
  122. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +2 -2
  123. package/dist/src/dht/routing/DuplicateDetector.js.map +1 -1
  124. package/dist/src/dht/routing/Router.d.ts +4 -1
  125. package/dist/src/dht/routing/Router.js +17 -9
  126. package/dist/src/dht/routing/Router.js.map +1 -1
  127. package/dist/src/dht/routing/RouterRpcLocal.d.ts +2 -2
  128. package/dist/src/dht/routing/RouterRpcLocal.js +5 -5
  129. package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
  130. package/dist/src/dht/routing/RouterRpcRemote.d.ts +2 -2
  131. package/dist/src/dht/routing/RouterRpcRemote.js +7 -7
  132. package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
  133. package/dist/src/dht/routing/RoutingSession.d.ts +1 -1
  134. package/dist/src/dht/routing/RoutingSession.js +7 -8
  135. package/dist/src/dht/routing/RoutingSession.js.map +1 -1
  136. package/dist/src/dht/routing/RoutingTablesCache.d.ts +1 -1
  137. package/dist/src/dht/routing/getPreviousPeer.d.ts +1 -1
  138. package/dist/src/dht/store/LocalDataStore.d.ts +1 -1
  139. package/dist/src/dht/store/LocalDataStore.js +3 -3
  140. package/dist/src/dht/store/LocalDataStore.js.map +1 -1
  141. package/dist/src/dht/store/StoreManager.d.ts +3 -3
  142. package/dist/src/dht/store/StoreManager.js +8 -8
  143. package/dist/src/dht/store/StoreManager.js.map +1 -1
  144. package/dist/src/dht/store/StoreRpcLocal.d.ts +4 -4
  145. package/dist/src/dht/store/StoreRpcLocal.js +4 -4
  146. package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
  147. package/dist/src/dht/store/StoreRpcRemote.d.ts +3 -3
  148. package/dist/src/dht/store/StoreRpcRemote.js +7 -4
  149. package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
  150. package/dist/src/exports.d.ts +2 -2
  151. package/dist/src/exports.js +6 -6
  152. package/dist/src/exports.js.map +1 -1
  153. package/dist/src/helpers/AddressTools.js +2 -3
  154. package/dist/src/helpers/AddressTools.js.map +1 -1
  155. package/dist/src/helpers/Connectivity.d.ts +1 -1
  156. package/dist/src/helpers/Connectivity.js +1 -1
  157. package/dist/src/helpers/Connectivity.js.map +1 -1
  158. package/dist/src/helpers/createPeerDescriptor.d.ts +1 -1
  159. package/dist/src/helpers/createPeerDescriptor.js +2 -2
  160. package/dist/src/helpers/createPeerDescriptor.js.map +1 -1
  161. package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +1 -1
  162. package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +1 -1
  163. package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +1 -1
  164. package/dist/src/helpers/debugHelpers.js +2 -2
  165. package/dist/src/helpers/debugHelpers.js.map +1 -1
  166. package/dist/src/helpers/protoClasses.d.ts +1 -1
  167. package/dist/src/helpers/protoClasses.js +1 -1
  168. package/dist/src/helpers/protoClasses.js.map +1 -1
  169. package/dist/src/helpers/protoToString.js +1 -2
  170. package/dist/src/helpers/protoToString.js.map +1 -1
  171. package/dist/src/helpers/version.d.ts +1 -1
  172. package/dist/src/helpers/version.js +4 -4
  173. package/dist/src/helpers/version.js.map +1 -1
  174. package/dist/src/identifiers.d.ts +5 -5
  175. package/dist/src/identifiers.js +11 -11
  176. package/dist/src/identifiers.js.map +1 -1
  177. package/dist/src/rpc-protocol/DhtCallContext.d.ts +1 -1
  178. package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +1 -1
  179. package/dist/src/transport/ITransport.d.ts +2 -1
  180. package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -1
  181. package/dist/src/transport/ListeningRpcCommunicator.js +13 -4
  182. package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
  183. package/dist/src/transport/RoutingRpcCommunicator.d.ts +1 -1
  184. package/eslint.config.mjs +12 -0
  185. package/jest.config.ts +12 -0
  186. package/package.json +17 -18
  187. package/proto.sh +2 -3
  188. package/protos/DhtRpc.proto +11 -4
  189. package/src/connection/Connection.ts +1 -1
  190. package/src/connection/ConnectionLockRpcLocal.ts +16 -7
  191. package/src/connection/ConnectionLockRpcRemote.ts +18 -6
  192. package/src/connection/ConnectionLockStates.ts +18 -0
  193. package/src/connection/ConnectionManager.ts +93 -27
  194. package/src/connection/ConnectionsView.ts +1 -1
  195. package/src/connection/ConnectorFacade.ts +1 -1
  196. package/src/connection/Handshaker.ts +18 -14
  197. package/src/connection/ManagedConnection.ts +28 -3
  198. package/src/connection/PendingConnection.ts +1 -1
  199. package/src/connection/connectivityChecker.ts +6 -5
  200. package/src/connection/connectivityRequestHandler.ts +4 -4
  201. package/src/connection/simulator/Simulator.ts +8 -7
  202. package/src/connection/simulator/SimulatorConnection.ts +10 -10
  203. package/src/connection/simulator/SimulatorConnector.ts +5 -5
  204. package/src/connection/simulator/SimulatorTransport.ts +3 -2
  205. package/src/connection/simulator/pings.ts +1 -1
  206. package/src/connection/webrtc/BrowserWebrtcConnection.ts +10 -1
  207. package/src/connection/webrtc/NodeWebrtcConnection.ts +15 -11
  208. package/src/connection/webrtc/WebrtcConnector.ts +13 -11
  209. package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +8 -8
  210. package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +2 -2
  211. package/src/connection/websocket/WebsocketClientConnector.ts +5 -5
  212. package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +5 -5
  213. package/src/connection/websocket/WebsocketClientConnectorRpcRemote.ts +4 -4
  214. package/src/connection/websocket/WebsocketServerConnector.ts +24 -20
  215. package/src/dht/DhtNode.ts +29 -11
  216. package/src/dht/DhtNodeRpcLocal.ts +8 -8
  217. package/src/dht/DhtNodeRpcRemote.ts +5 -5
  218. package/src/dht/ExternalApiRpcLocal.ts +8 -8
  219. package/src/dht/ExternalApiRpcRemote.ts +6 -6
  220. package/src/dht/PeerManager.ts +16 -14
  221. package/src/dht/contact/Contact.ts +3 -3
  222. package/src/dht/contact/RingContactList.ts +3 -3
  223. package/src/dht/contact/RpcRemote.ts +1 -1
  224. package/src/dht/contact/SortedContactList.ts +3 -3
  225. package/src/dht/contact/ringIdentifiers.ts +1 -1
  226. package/src/dht/discovery/DiscoverySession.ts +5 -5
  227. package/src/dht/discovery/PeerDiscovery.ts +12 -12
  228. package/src/dht/discovery/RingDiscoverySession.ts +3 -3
  229. package/src/dht/recursive-operation/RecursiveOperationManager.ts +10 -10
  230. package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +4 -4
  231. package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +6 -6
  232. package/src/dht/recursive-operation/RecursiveOperationSession.ts +8 -8
  233. package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +5 -5
  234. package/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.ts +2 -2
  235. package/src/dht/routing/DuplicateDetector.ts +1 -1
  236. package/src/dht/routing/Router.ts +19 -10
  237. package/src/dht/routing/RouterRpcLocal.ts +7 -7
  238. package/src/dht/routing/RouterRpcRemote.ts +9 -9
  239. package/src/dht/routing/RoutingSession.ts +9 -10
  240. package/src/dht/routing/RoutingTablesCache.ts +1 -1
  241. package/src/dht/routing/getPreviousPeer.ts +1 -1
  242. package/src/dht/store/LocalDataStore.ts +5 -5
  243. package/src/dht/store/StoreManager.ts +13 -13
  244. package/src/dht/store/StoreRpcLocal.ts +9 -9
  245. package/src/dht/store/StoreRpcRemote.ts +10 -7
  246. package/src/exports.ts +5 -5
  247. package/src/helpers/Connectivity.ts +1 -1
  248. package/src/helpers/createPeerDescriptor.ts +3 -3
  249. package/src/helpers/createPeerDescriptorSignaturePayload.ts +1 -1
  250. package/src/helpers/protoClasses.ts +2 -2
  251. package/src/helpers/version.ts +2 -2
  252. package/src/identifiers.ts +7 -7
  253. package/src/rpc-protocol/DhtCallContext.ts +1 -1
  254. package/src/rpc-protocol/DhtRpcOptions.ts +1 -1
  255. package/src/transport/ITransport.ts +2 -1
  256. package/src/transport/ListeningRpcCommunicator.ts +14 -6
  257. package/src/transport/RoutingRpcCommunicator.ts +2 -2
  258. package/test/benchmark/Find.test.ts +9 -9
  259. package/test/benchmark/KademliaCorrectness.test.ts +7 -7
  260. package/test/benchmark/RingCorrectness.test.ts +8 -8
  261. package/test/benchmark/SortedContactListBenchmark.test.ts +10 -10
  262. package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +3 -3
  263. package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +6 -6
  264. package/test/end-to-end/Layer0Webrtc.test.ts +6 -6
  265. package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +1 -1
  266. package/test/end-to-end/WebsocketConnectionRequest.test.ts +3 -3
  267. package/test/end-to-end/memory-leak.test.ts +6 -6
  268. package/test/integration/ConnectionLocking.test.ts +48 -37
  269. package/test/integration/ConnectionManager.test.ts +62 -6
  270. package/test/integration/ConnectivityChecking.test.ts +3 -2
  271. package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
  272. package/test/integration/DhtNode.test.ts +6 -6
  273. package/test/integration/DhtNodeExternalAPI.test.ts +7 -7
  274. package/test/integration/DhtNodeRpcRemote.test.ts +9 -9
  275. package/test/integration/DhtRpc.test.ts +12 -13
  276. package/test/integration/Find.test.ts +5 -5
  277. package/test/integration/GeoIpConnectivityChecking.test.ts +8 -7
  278. package/test/integration/Layer1-scale.test.ts +3 -3
  279. package/test/integration/Mock-Layer1-Layer0.test.ts +6 -6
  280. package/test/integration/MultipleEntryPointJoining.test.ts +1 -1
  281. package/test/integration/ReplicateData.test.ts +10 -11
  282. package/test/integration/RouteMessage.test.ts +13 -13
  283. package/test/integration/RouterRpcRemote.test.ts +7 -7
  284. package/test/integration/SimultaneousConnections.test.ts +14 -13
  285. package/test/integration/Store.test.ts +9 -9
  286. package/test/integration/StoreAndDelete.test.ts +10 -10
  287. package/test/integration/StoreOnDhtWithThreeNodes.test.ts +10 -10
  288. package/test/integration/StoreOnDhtWithTwoNodes.test.ts +10 -10
  289. package/test/integration/StoreRpcRemote.test.ts +11 -11
  290. package/test/integration/WebrtcConnectionManagement.test.ts +4 -31
  291. package/test/integration/WebrtcConnectorRpc.test.ts +14 -14
  292. package/test/integration/Websocket.test.ts +0 -2
  293. package/test/integration/WebsocketClientConnectorRpc.test.ts +8 -8
  294. package/test/integration/WebsocketConnectionManagement.test.ts +11 -12
  295. package/test/integration/{rpc-connections-over-webrpc.test.ts → rpc-connections-over-webrtc.test.ts} +12 -46
  296. package/test/unit/AutoCertifierClientFacade.test.ts +6 -6
  297. package/test/unit/ConnectionManager.test.ts +4 -3
  298. package/test/unit/ConnectivityHelpers.test.ts +1 -1
  299. package/test/unit/DiscoverySession.test.ts +6 -6
  300. package/test/unit/Handshaker.test.ts +2 -2
  301. package/test/unit/ListeningRpcCommunicator.test.ts +52 -0
  302. package/test/unit/LocalDataStore.test.ts +21 -21
  303. package/test/unit/PeerManager.test.ts +15 -15
  304. package/test/unit/PendingConnection.test.ts +1 -1
  305. package/test/unit/ProtobufMessage.test.ts +1 -1
  306. package/test/unit/RandomContactList.test.ts +2 -2
  307. package/test/unit/RecursiveOperationManager.test.ts +3 -3
  308. package/test/unit/RecursiveOperationSession.test.ts +6 -6
  309. package/test/unit/Router.test.ts +6 -6
  310. package/test/unit/RoutingSession.test.ts +13 -6
  311. package/test/unit/SortedContactList.test.ts +8 -8
  312. package/test/unit/StoreManager.test.ts +12 -12
  313. package/test/unit/StoreRpcLocal.test.ts +9 -9
  314. package/test/unit/WebrtcConnection.test.ts +29 -0
  315. package/test/unit/WebsocketClientConnector.test.ts +1 -1
  316. package/test/unit/WebsocketServerConnector.test.ts +1 -1
  317. package/test/unit/connectivityRequestHandler.test.ts +6 -6
  318. package/test/unit/createPeerDescriptor.test.ts +4 -4
  319. package/test/unit/customMatchers.test.ts +18 -0
  320. package/test/unit/getClosestNodes.test.ts +5 -5
  321. package/test/unit/version.test.ts +9 -9
  322. package/test/utils/FakeConnectorFacade.ts +1 -1
  323. package/test/utils/FakeTransport.ts +12 -9
  324. package/test/utils/customMatchers.ts +9 -9
  325. package/test/utils/mock/MockConnectionsView.ts +1 -1
  326. package/test/utils/mock/MockRouter.ts +5 -1
  327. package/test/utils/mock/MockTransport.ts +6 -1
  328. package/test/utils/mock/mockDataEntry.ts +6 -6
  329. package/test/utils/topology.ts +3 -4
  330. package/test/utils/utils.ts +11 -11
  331. package/tsconfig.jest.json +2 -1
  332. package/tsconfig.node.json +1 -0
  333. package/.eslintignore +0 -5
  334. package/.eslintrc +0 -3
  335. package/dist/src/proto/google/protobuf/any.d.ts +0 -173
  336. package/dist/src/proto/google/protobuf/any.js +0 -155
  337. package/dist/src/proto/google/protobuf/any.js.map +0 -1
  338. package/dist/src/proto/google/protobuf/empty.d.ts +0 -32
  339. package/dist/src/proto/google/protobuf/empty.js +0 -32
  340. package/dist/src/proto/google/protobuf/empty.js.map +0 -1
  341. package/dist/src/proto/google/protobuf/timestamp.d.ts +0 -149
  342. package/dist/src/proto/google/protobuf/timestamp.js +0 -136
  343. package/dist/src/proto/google/protobuf/timestamp.js.map +0 -1
  344. package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +0 -352
  345. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +0 -278
  346. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +0 -1
  347. package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +0 -975
  348. package/dist/src/proto/packages/dht/protos/DhtRpc.js +0 -661
  349. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +0 -1
  350. package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +0 -157
  351. package/dist/src/proto/packages/dht/protos/DhtRpc.server.js +0 -3
  352. package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +0 -1
  353. package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -87
  354. package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +0 -66
  355. package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js.map +0 -1
  356. package/dist/src/proto/tests.d.ts +0 -39
  357. package/dist/src/proto/tests.js +0 -34
  358. package/dist/src/proto/tests.js.map +0 -1
  359. package/jest.config.js +0 -5
  360. package/src/proto/google/protobuf/any.ts +0 -319
  361. package/src/proto/google/protobuf/empty.ts +0 -82
  362. package/src/proto/google/protobuf/timestamp.ts +0 -281
  363. package/src/proto/packages/dht/protos/DhtRpc.client.ts +0 -407
  364. package/src/proto/packages/dht/protos/DhtRpc.server.ts +0 -160
  365. package/src/proto/packages/dht/protos/DhtRpc.ts +0 -1244
  366. package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +0 -108
  367. package/src/proto/tests.ts +0 -52
  368. package/test/benchmark/any.test.ts +0 -28
  369. /package/{src/types/glogal.d.ts → test/types/global.d.ts} +0 -0
@@ -1,18 +1,18 @@
1
- import { isMaybeSupportedVersion } from '../../src/helpers/version'
1
+ import { isMaybeSupportedProtocolVersion } from '../../src/helpers/version'
2
2
 
3
3
  describe('version', () => {
4
4
 
5
5
  it('supported', () => {
6
- expect(isMaybeSupportedVersion('1.0')).toBe(true)
7
- expect(isMaybeSupportedVersion('1.1')).toBe(true)
8
- expect(isMaybeSupportedVersion('2.0')).toBe(true)
9
- expect(isMaybeSupportedVersion('3.5')).toBe(true)
6
+ expect(isMaybeSupportedProtocolVersion('1.0')).toBe(true)
7
+ expect(isMaybeSupportedProtocolVersion('1.1')).toBe(true)
8
+ expect(isMaybeSupportedProtocolVersion('2.0')).toBe(true)
9
+ expect(isMaybeSupportedProtocolVersion('3.5')).toBe(true)
10
10
  })
11
11
 
12
12
  it('not supported', () => {
13
- expect(isMaybeSupportedVersion('')).toBe(false)
14
- expect(isMaybeSupportedVersion('100.0.0-testnet-three.3')).toBe(false)
15
- expect(isMaybeSupportedVersion('0.0')).toBe(false)
16
- expect(isMaybeSupportedVersion('0.1')).toBe(false)
13
+ expect(isMaybeSupportedProtocolVersion('')).toBe(false)
14
+ expect(isMaybeSupportedProtocolVersion('100.0.0-testnet-three.3')).toBe(false)
15
+ expect(isMaybeSupportedProtocolVersion('0.0')).toBe(false)
16
+ expect(isMaybeSupportedProtocolVersion('0.1')).toBe(false)
17
17
  })
18
18
  })
@@ -1,6 +1,6 @@
1
1
  import { PendingConnection } from '../../src/connection/PendingConnection'
2
2
  import { DhtAddress } from '../../src/identifiers'
3
- import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
3
+ import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
4
4
  import { ITransport } from '../../src/transport/ITransport'
5
5
 
6
6
  export class FakeConnectorFacade {
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'eventemitter3'
2
- import { DhtAddress, getDhtAddressFromRaw, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
3
- import { Message, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
2
+ import { DhtAddress, toDhtAddress, toNodeId } from '../../src/identifiers'
3
+ import { Message, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
4
4
  import { DEFAULT_SEND_OPTIONS, ITransport, SendOptions, TransportEvents } from '../../src/transport/ITransport'
5
5
  import { ConnectionsView } from '../../src/exports'
6
6
 
@@ -22,8 +22,8 @@ class FakeTransport extends EventEmitter<TransportEvents> implements ITransport,
22
22
 
23
23
  async send(msg: Message, opts?: SendOptions): Promise<void> {
24
24
  const connect = opts?.connect ?? DEFAULT_SEND_OPTIONS.connect
25
- const targetNodeId = getNodeIdFromPeerDescriptor(msg.targetDescriptor!)
26
- if (connect && !this.connections.some((c) => getNodeIdFromPeerDescriptor(c) === targetNodeId)) {
25
+ const targetNodeId = toNodeId(msg.targetDescriptor!)
26
+ if (connect && !this.connections.some((c) => toNodeId(c) === targetNodeId)) {
27
27
  this.connect(msg.targetDescriptor!)
28
28
  }
29
29
  msg.sourceDescriptor = this.localPeerDescriptor
@@ -43,19 +43,22 @@ class FakeTransport extends EventEmitter<TransportEvents> implements ITransport,
43
43
  return this.connections
44
44
  }
45
45
 
46
- // eslint-disable-next-line class-methods-use-this
47
46
  getConnectionCount(): number {
48
47
  return this.connections.length
49
48
  }
50
49
 
51
- // eslint-disable-next-line class-methods-use-this
52
50
  hasConnection(nodeId: DhtAddress): boolean {
53
- return this.connections.some((c) => getNodeIdFromPeerDescriptor(c) === nodeId)
51
+ return this.connections.some((c) => toNodeId(c) === nodeId)
54
52
  }
55
53
 
56
54
  // eslint-disable-next-line class-methods-use-this
57
55
  stop(): void | Promise<void> {
58
56
  }
57
+
58
+ // eslint-disable-next-line class-methods-use-this
59
+ getDiagnosticInfo(): Record<string, unknown> {
60
+ return {}
61
+ }
59
62
  }
60
63
 
61
64
  export class FakeEnvironment {
@@ -64,8 +67,8 @@ export class FakeEnvironment {
64
67
 
65
68
  createTransport(peerDescriptor: PeerDescriptor): FakeTransport {
66
69
  const transport = new FakeTransport(peerDescriptor, (msg) => {
67
- const targetNode = getDhtAddressFromRaw(msg.targetDescriptor!.nodeId)
68
- const targetTransport = this.transports.find((t) => getNodeIdFromPeerDescriptor(t.getLocalPeerDescriptor()) === targetNode)
70
+ const targetNode = toDhtAddress(msg.targetDescriptor!.nodeId)
71
+ const targetTransport = this.transports.find((t) => toNodeId(t.getLocalPeerDescriptor()) === targetNode)
69
72
  if (targetTransport !== undefined) {
70
73
  targetTransport.emit('message', msg)
71
74
  }
@@ -1,8 +1,8 @@
1
1
  import { areEqualBinaries } from '@streamr/utils'
2
2
  import { printExpected, printReceived } from 'jest-matcher-utils'
3
3
  import { isEqual } from 'lodash'
4
- import { ConnectivityMethod, NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
5
- import { getDhtAddressFromRaw } from '../../src/identifiers'
4
+ import { ConnectivityMethod, NodeType, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
5
+ import { toDhtAddress } from '../../src/identifiers'
6
6
 
7
7
  // we could ES2015 module syntax (https://jestjs.io/docs/expect#expectextendmatchers),
8
8
  // but the IDE doesn't find custom matchers if we do that
@@ -15,8 +15,8 @@ declare global {
15
15
  }
16
16
  }
17
17
 
18
- const formErrorMessage = (description: string, expected: string | number | undefined, actual: string | number | undefined): string => {
19
- return `${description}\nExpected: ${printExpected(expected)}\nReceived: ${printReceived(actual)}`
18
+ const formErrorMessage = (field: keyof PeerDescriptor, expected: string | number | undefined, actual: string | number | undefined): string => {
19
+ return `PeerDescriptor ${field} values don't match:\nExpected: ${printExpected(expected)}\nReceived: ${printReceived(actual)}`
20
20
  }
21
21
 
22
22
  const toEqualPeerDescriptor = (
@@ -25,14 +25,14 @@ const toEqualPeerDescriptor = (
25
25
  ): jest.CustomMatcherResult => {
26
26
  const messages: string[] = []
27
27
  if (!areEqualBinaries(expected.nodeId, actual.nodeId)) {
28
- messages.push(formErrorMessage('nodeId', getDhtAddressFromRaw(expected.nodeId), getDhtAddressFromRaw(actual.nodeId)))
28
+ messages.push(formErrorMessage('nodeId', toDhtAddress(expected.nodeId), toDhtAddress(actual.nodeId)))
29
29
  }
30
30
  if (!isEqual(expected.type, actual.type)) {
31
31
  const typeNames = { [NodeType.NODEJS]: 'NODEJS', [NodeType.BROWSER]: 'BROWSER' }
32
32
  messages.push(formErrorMessage('type', typeNames[expected.type], typeNames[actual.type]))
33
33
  }
34
34
  expectEqualConnectivityMethod('udp', expected.udp, actual.udp, messages)
35
- expectEqualConnectivityMethod('tpc', expected.tcp, actual.tcp, messages)
35
+ expectEqualConnectivityMethod('tcp', expected.tcp, actual.tcp, messages)
36
36
  expectEqualConnectivityMethod('websocket', expected.websocket, actual.websocket, messages)
37
37
  if (expected.region !== actual.region) {
38
38
  messages.push(formErrorMessage('region', expected?.region, actual?.region))
@@ -45,13 +45,13 @@ const toEqualPeerDescriptor = (
45
45
  } else {
46
46
  return {
47
47
  pass: true,
48
- message: () => `Expected not to throw ${printReceived('StreamrClientError')}`
48
+ message: () => 'PeerDescriptors are equal'
49
49
  }
50
50
  }
51
51
  }
52
52
 
53
53
  const expectEqualConnectivityMethod = (
54
- description: string,
54
+ field: keyof PeerDescriptor,
55
55
  method1: ConnectivityMethod | undefined,
56
56
  method2: ConnectivityMethod | undefined,
57
57
  messages: string[]
@@ -62,7 +62,7 @@ const expectEqualConnectivityMethod = (
62
62
  : undefined
63
63
  }
64
64
  if (!isEqual(method1, method2)) {
65
- messages.push(formErrorMessage(description, toOutput(method1), toOutput(method2)))
65
+ messages.push(formErrorMessage(field, toOutput(method1), toOutput(method2)))
66
66
  }
67
67
  }
68
68
 
@@ -1,4 +1,4 @@
1
- import { PeerDescriptor } from '../../../src/proto/packages/dht/protos/DhtRpc'
1
+ import { PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc'
2
2
 
3
3
  export class MockConnectionsView {
4
4
  // eslint-disable-next-line class-methods-use-this
@@ -1,6 +1,6 @@
1
1
  import { Methods } from '@streamr/test-utils'
2
2
  import { Router } from '../../../src/dht/routing/Router'
3
- import { RouteMessageAck } from '../../../src/proto/packages/dht/protos/DhtRpc'
3
+ import { RouteMessageAck } from '../../../generated/packages/dht/protos/DhtRpc'
4
4
 
5
5
  export class MockRouter implements Methods<Router> {
6
6
 
@@ -55,4 +55,8 @@ export class MockRouter implements Methods<Router> {
55
55
  // eslint-disable-next-line class-methods-use-this
56
56
  resetCache(): void {}
57
57
 
58
+ // eslint-disable-next-line class-methods-use-this
59
+ getDiagnosticInfo(): Record<string, unknown> {
60
+ return {}
61
+ }
58
62
  }
@@ -1,6 +1,6 @@
1
1
  import { ITransport, TransportEvents } from '../../../src/transport/ITransport'
2
2
  import { EventEmitter } from 'eventemitter3'
3
- import { PeerDescriptor } from '../../../src/proto/packages/dht/protos/DhtRpc'
3
+ import { PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc'
4
4
 
5
5
  export class MockTransport extends EventEmitter<TransportEvents> implements ITransport {
6
6
 
@@ -18,4 +18,9 @@ export class MockTransport extends EventEmitter<TransportEvents> implements ITra
18
18
  stop(): void {
19
19
 
20
20
  }
21
+
22
+ // eslint-disable-next-line class-methods-use-this
23
+ getDiagnosticInfo(): Record<string, unknown> {
24
+ return {}
25
+ }
21
26
  }
@@ -1,9 +1,9 @@
1
1
  import { MessageType as MessageType$, ScalarType } from '@protobuf-ts/runtime'
2
2
  import { randomString } from '@streamr/utils'
3
- import { Timestamp } from '../../../src/proto/google/protobuf/timestamp'
4
- import { Any } from '../../../src/proto/google/protobuf/any'
5
- import { DataEntry } from '../../../src/proto/packages/dht/protos/DhtRpc'
6
- import { DhtAddress, createRandomDhtAddress, getRawFromDhtAddress } from '../../../src/identifiers'
3
+ import { Timestamp } from '../../../generated/google/protobuf/timestamp'
4
+ import { Any } from '../../../generated/google/protobuf/any'
5
+ import { DataEntry } from '../../../generated/packages/dht/protos/DhtRpc'
6
+ import { DhtAddress, randomDhtAddress, toDhtAddressRaw } from '../../../src/identifiers'
7
7
  import { omit } from 'lodash'
8
8
 
9
9
  const MockData = new class extends MessageType$<{ foo: string }> {
@@ -18,9 +18,9 @@ export const createMockDataEntry = (
18
18
  entry: Partial<Omit<DataEntry, 'key' | 'creator'> & { key: DhtAddress, creator: DhtAddress }> = {}
19
19
  ): DataEntry => {
20
20
  return {
21
- key: getRawFromDhtAddress(entry.key ?? createRandomDhtAddress()),
21
+ key: toDhtAddressRaw(entry.key ?? randomDhtAddress()),
22
22
  data: Any.pack({ foo: randomString(5) }, MockData),
23
- creator: getRawFromDhtAddress(entry.creator ?? createRandomDhtAddress()),
23
+ creator: toDhtAddressRaw(entry.creator ?? randomDhtAddress()),
24
24
  ttl: 10000,
25
25
  stale: false,
26
26
  deleted: false,
@@ -1,5 +1,5 @@
1
1
  import { Multimap } from '@streamr/utils'
2
- import { DhtAddress, createRandomDhtAddress, getRawFromDhtAddress } from '../../src/identifiers'
2
+ import { DhtAddress, randomDhtAddress, toDhtAddressRaw } from '../../src/identifiers'
3
3
  import { minBy, range, without } from 'lodash'
4
4
  import { SortedContactList } from '../../src/dht/contact/SortedContactList'
5
5
  import { getDistance } from '../../src/dht/PeerManager'
@@ -47,7 +47,7 @@ const getClosestNodes = (referenceId: DhtAddress, nodeIds: DhtAddress[], count:
47
47
  */
48
48
  export const createTestTopology = (nodeCount: number, minNeighorCount: number): Multimap<DhtAddress, DhtAddress> => {
49
49
  const topology: Multimap<DhtAddress, DhtAddress> = new Multimap()
50
- const nodeIds = range(nodeCount).map(() => createRandomDhtAddress())
50
+ const nodeIds = range(nodeCount).map(() => randomDhtAddress())
51
51
  for (const nodeId of nodeIds) {
52
52
  const closestNodes = getClosestNodes(nodeId, nodeIds, minNeighorCount, false)
53
53
  for (const closestNode of closestNodes) {
@@ -59,7 +59,6 @@ export const createTestTopology = (nodeCount: number, minNeighorCount: number):
59
59
  }
60
60
  }
61
61
  }
62
- // eslint-disable-next-line no-constant-condition
63
62
  while (true) {
64
63
  const partitions = getTopologyPartitions(topology)
65
64
  if (partitions.length === 1) {
@@ -71,7 +70,7 @@ export const createTestTopology = (nodeCount: number, minNeighorCount: number):
71
70
  const closestNodedId = getClosestNodes(nodeId, otherNodes, 1, false)[0]
72
71
  return [nodeId, closestNodedId]
73
72
  })
74
- const mergePair = minBy(closestPairs, (pair) => getDistance(getRawFromDhtAddress(pair[0]), getRawFromDhtAddress(pair[1])))!
73
+ const mergePair = minBy(closestPairs, (pair) => getDistance(toDhtAddressRaw(pair[0]), toDhtAddressRaw(pair[1])))!
75
74
  topology.add(mergePair[0], mergePair[1])
76
75
  topology.add(mergePair[1], mergePair[0])
77
76
  }
@@ -11,27 +11,27 @@ import {
11
11
  StoreDataRequest,
12
12
  StoreDataResponse,
13
13
  ClosestRingPeersResponse
14
- } from '../../src/proto/packages/dht/protos/DhtRpc'
15
- import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
14
+ } from '../../generated/packages/dht/protos/DhtRpc'
15
+ import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
16
16
  import {
17
17
  IDhtNodeRpc,
18
18
  IRouterRpc,
19
19
  IStoreRpc,
20
20
  IWebsocketClientConnectorRpc
21
- } from '../../src/proto/packages/dht/protos/DhtRpc.server'
21
+ } from '../../generated/packages/dht/protos/DhtRpc.server'
22
22
  import { Simulator } from '../../src/connection/simulator/Simulator'
23
23
  import { ConnectionManager } from '../../src/connection/ConnectionManager'
24
24
  import { v4 } from 'uuid'
25
25
  import { getRandomRegion } from '../../src/connection/simulator/pings'
26
- import { Empty } from '../../src/proto/google/protobuf/empty'
27
- import { Any } from '../../src/proto/google/protobuf/any'
28
- import { wait, waitForCondition } from '@streamr/utils'
26
+ import { Empty } from '../../generated/google/protobuf/empty'
27
+ import { Any } from '../../generated/google/protobuf/any'
28
+ import { wait, until } from '@streamr/utils'
29
29
  import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
30
- import { DhtAddress, createRandomDhtAddress, getRawFromDhtAddress } from '../../src/identifiers'
30
+ import { DhtAddress, randomDhtAddress, toDhtAddressRaw } from '../../src/identifiers'
31
31
 
32
32
  export const createMockPeerDescriptor = (opts?: Partial<Omit<PeerDescriptor, 'nodeId'>>): PeerDescriptor => {
33
33
  return {
34
- nodeId: getRawFromDhtAddress(createRandomDhtAddress()),
34
+ nodeId: toDhtAddressRaw(randomDhtAddress()),
35
35
  type: NodeType.NODEJS,
36
36
  ...opts
37
37
  }
@@ -46,7 +46,7 @@ export const createMockRingNode = async (
46
46
  const dhtJoinTimeout = 45000
47
47
 
48
48
  const peerDescriptor: PeerDescriptor = {
49
- nodeId: getRawFromDhtAddress(nodeId ?? createRandomDhtAddress()),
49
+ nodeId: toDhtAddressRaw(nodeId ?? randomDhtAddress()),
50
50
  type: NodeType.NODEJS,
51
51
  region
52
52
  //ipAddress: ipv4ToNumber(ipAddress)
@@ -80,7 +80,7 @@ export const createMockConnectionDhtNode = async (
80
80
  dhtJoinTimeout = 45000
81
81
  ): Promise<DhtNode> => {
82
82
  const peerDescriptor: PeerDescriptor = {
83
- nodeId: getRawFromDhtAddress(nodeId ?? createRandomDhtAddress()),
83
+ nodeId: toDhtAddressRaw(nodeId ?? randomDhtAddress()),
84
84
  type: NodeType.NODEJS,
85
85
  region: getRandomRegion()
86
86
  }
@@ -258,7 +258,7 @@ export const waitForStableTopology = async (nodes: DhtNode[], maxConnectionCount
258
258
  await Promise.all(connectionManagers.map(async (connectionManager) => {
259
259
  connectionManager.garbageCollectConnections(maxConnectionCount, MAX_IDLE_TIME)
260
260
  try {
261
- await waitForCondition(() => connectionManager.getConnections().length <= maxConnectionCount, waitTime)
261
+ await until(() => connectionManager.getConnections().length <= maxConnectionCount, waitTime)
262
262
  } catch {
263
263
  // the topology is very likely stable, but we can't be sure (maybe the node has more than maxConnectionCount
264
264
  // locked connections and therefore it is ok to that garbage collector was not able to remove any of those
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "extends": "../../tsconfig.jest.json",
3
3
  "compilerOptions": {
4
- "outDir": "dist",
4
+ "noEmit": true,
5
5
  "noImplicitOverride": false
6
6
  },
7
7
  "include": [
8
8
  "src/**/*",
9
+ "generated/**/*",
9
10
  "test/**/*",
10
11
  "package.json"
11
12
  ],
@@ -6,6 +6,7 @@
6
6
  },
7
7
  "include": [
8
8
  "src/**/*",
9
+ "generated/**/*",
9
10
  "package.json"
10
11
  ],
11
12
  "exclude": [
package/.eslintignore DELETED
@@ -1,5 +0,0 @@
1
- node_modules/**
2
- coverage/**
3
- dist/**
4
- .idea/**
5
- src/proto/**
package/.eslintrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "../../.eslintrc.js"
3
- }
@@ -1,173 +0,0 @@
1
- import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
2
- import type { IBinaryWriter } from "@protobuf-ts/runtime";
3
- import type { IBinaryReader } from "@protobuf-ts/runtime";
4
- import type { PartialMessage } from "@protobuf-ts/runtime";
5
- import type { JsonValue } from "@protobuf-ts/runtime";
6
- import type { JsonReadOptions } from "@protobuf-ts/runtime";
7
- import type { JsonWriteOptions } from "@protobuf-ts/runtime";
8
- import type { BinaryReadOptions } from "@protobuf-ts/runtime";
9
- import type { IMessageType } from "@protobuf-ts/runtime";
10
- import { MessageType } from "@protobuf-ts/runtime";
11
- /**
12
- * `Any` contains an arbitrary serialized protocol buffer message along with a
13
- * URL that describes the type of the serialized message.
14
- *
15
- * Protobuf library provides support to pack/unpack Any values in the form
16
- * of utility functions or additional generated methods of the Any type.
17
- *
18
- * Example 1: Pack and unpack a message in C++.
19
- *
20
- * Foo foo = ...;
21
- * Any any;
22
- * any.PackFrom(foo);
23
- * ...
24
- * if (any.UnpackTo(&foo)) {
25
- * ...
26
- * }
27
- *
28
- * Example 2: Pack and unpack a message in Java.
29
- *
30
- * Foo foo = ...;
31
- * Any any = Any.pack(foo);
32
- * ...
33
- * if (any.is(Foo.class)) {
34
- * foo = any.unpack(Foo.class);
35
- * }
36
- *
37
- * Example 3: Pack and unpack a message in Python.
38
- *
39
- * foo = Foo(...)
40
- * any = Any()
41
- * any.Pack(foo)
42
- * ...
43
- * if any.Is(Foo.DESCRIPTOR):
44
- * any.Unpack(foo)
45
- * ...
46
- *
47
- * Example 4: Pack and unpack a message in Go
48
- *
49
- * foo := &pb.Foo{...}
50
- * any, err := ptypes.MarshalAny(foo)
51
- * ...
52
- * foo := &pb.Foo{}
53
- * if err := ptypes.UnmarshalAny(any, foo); err != nil {
54
- * ...
55
- * }
56
- *
57
- * The pack methods provided by protobuf library will by default use
58
- * 'type.googleapis.com/full.type.name' as the type URL and the unpack
59
- * methods only use the fully qualified type name after the last '/'
60
- * in the type URL, for example "foo.bar.com/x/y.z" will yield type
61
- * name "y.z".
62
- *
63
- *
64
- * JSON
65
- * ====
66
- * The JSON representation of an `Any` value uses the regular
67
- * representation of the deserialized, embedded message, with an
68
- * additional field `@type` which contains the type URL. Example:
69
- *
70
- * package google.profile;
71
- * message Person {
72
- * string first_name = 1;
73
- * string last_name = 2;
74
- * }
75
- *
76
- * {
77
- * "@type": "type.googleapis.com/google.profile.Person",
78
- * "firstName": <string>,
79
- * "lastName": <string>
80
- * }
81
- *
82
- * If the embedded message type is well-known and has a custom JSON
83
- * representation, that representation will be embedded adding a field
84
- * `value` which holds the custom JSON in addition to the `@type`
85
- * field. Example (for message [google.protobuf.Duration][]):
86
- *
87
- * {
88
- * "@type": "type.googleapis.com/google.protobuf.Duration",
89
- * "value": "1.212s"
90
- * }
91
- *
92
- *
93
- * @generated from protobuf message google.protobuf.Any
94
- */
95
- export interface Any {
96
- /**
97
- * A URL/resource name that uniquely identifies the type of the serialized
98
- * protocol buffer message. This string must contain at least
99
- * one "/" character. The last segment of the URL's path must represent
100
- * the fully qualified name of the type (as in
101
- * `path/google.protobuf.Duration`). The name should be in a canonical form
102
- * (e.g., leading "." is not accepted).
103
- *
104
- * In practice, teams usually precompile into the binary all types that they
105
- * expect it to use in the context of Any. However, for URLs which use the
106
- * scheme `http`, `https`, or no scheme, one can optionally set up a type
107
- * server that maps type URLs to message definitions as follows:
108
- *
109
- * * If no scheme is provided, `https` is assumed.
110
- * * An HTTP GET on the URL must yield a [google.protobuf.Type][]
111
- * value in binary format, or produce an error.
112
- * * Applications are allowed to cache lookup results based on the
113
- * URL, or have them precompiled into a binary to avoid any
114
- * lookup. Therefore, binary compatibility needs to be preserved
115
- * on changes to types. (Use versioned type names to manage
116
- * breaking changes.)
117
- *
118
- * Note: this functionality is not currently available in the official
119
- * protobuf release, and it is not used for type URLs beginning with
120
- * type.googleapis.com.
121
- *
122
- * Schemes other than `http`, `https` (or the empty scheme) might be
123
- * used with implementation specific semantics.
124
- *
125
- *
126
- * @generated from protobuf field: string type_url = 1;
127
- */
128
- typeUrl: string;
129
- /**
130
- * Must be a valid serialized protocol buffer of the above specified type.
131
- *
132
- * @generated from protobuf field: bytes value = 2;
133
- */
134
- value: Uint8Array;
135
- }
136
- declare class Any$Type extends MessageType<Any> {
137
- constructor();
138
- /**
139
- * Pack the message into a new `Any`.
140
- *
141
- * Uses 'type.googleapis.com/full.type.name' as the type URL.
142
- */
143
- pack<T extends object>(message: T, type: IMessageType<T>): Any;
144
- /**
145
- * Unpack the message from the `Any`.
146
- */
147
- unpack<T extends object>(any: Any, type: IMessageType<T>, options?: Partial<BinaryReadOptions>): T;
148
- /**
149
- * Does the given `Any` contain a packed message of the given type?
150
- */
151
- contains(any: Any, type: IMessageType<any> | string): boolean;
152
- /**
153
- * Convert the message to canonical JSON value.
154
- *
155
- * You have to provide the `typeRegistry` option so that the
156
- * packed message can be converted to JSON.
157
- *
158
- * The `typeRegistry` option is also required to read
159
- * `google.protobuf.Any` from JSON format.
160
- */
161
- internalJsonWrite(any: Any, options: JsonWriteOptions): JsonValue;
162
- internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Any): Any;
163
- typeNameToUrl(name: string): string;
164
- typeUrlToName(url: string): string;
165
- create(value?: PartialMessage<Any>): Any;
166
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Any): Any;
167
- internalBinaryWrite(message: Any, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
168
- }
169
- /**
170
- * @generated MessageType for protobuf message google.protobuf.Any
171
- */
172
- export declare const Any: Any$Type;
173
- export {};