@streamr/dht 100.0.0-pretestnet.2 → 100.0.0-pretestnet.3

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 (316) hide show
  1. package/dist/src/connection/ConnectionLockHandler.d.ts +7 -8
  2. package/dist/src/connection/ConnectionLockHandler.js +16 -14
  3. package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
  4. package/dist/src/connection/ConnectionLockRpcLocal.d.ts +20 -0
  5. package/dist/src/connection/ConnectionLockRpcLocal.js +47 -0
  6. package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -0
  7. package/dist/src/connection/ConnectionLockRpcRemote.d.ts +4 -3
  8. package/dist/src/connection/ConnectionLockRpcRemote.js +6 -6
  9. package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
  10. package/dist/src/connection/ConnectionManager.d.ts +5 -8
  11. package/dist/src/connection/ConnectionManager.js +77 -107
  12. package/dist/src/connection/ConnectionManager.js.map +1 -1
  13. package/dist/src/connection/ConnectivityChecker.d.ts +7 -6
  14. package/dist/src/connection/ConnectivityChecker.js +23 -20
  15. package/dist/src/connection/ConnectivityChecker.js.map +1 -1
  16. package/dist/src/connection/ConnectorFacade.d.ts +15 -12
  17. package/dist/src/connection/ConnectorFacade.js +61 -26
  18. package/dist/src/connection/ConnectorFacade.js.map +1 -1
  19. package/dist/src/connection/Handshaker.d.ts +2 -2
  20. package/dist/src/connection/Handshaker.js +28 -28
  21. package/dist/src/connection/Handshaker.js.map +1 -1
  22. package/dist/src/connection/IConnection.d.ts +5 -6
  23. package/dist/src/connection/IConnection.js.map +1 -1
  24. package/dist/src/connection/ManagedConnection.d.ts +3 -4
  25. package/dist/src/connection/ManagedConnection.js +30 -30
  26. package/dist/src/connection/ManagedConnection.js.map +1 -1
  27. package/dist/src/connection/ManagedWebrtcConnection.d.ts +7 -0
  28. package/dist/src/connection/ManagedWebrtcConnection.js +20 -0
  29. package/dist/src/connection/ManagedWebrtcConnection.js.map +1 -0
  30. package/dist/src/connection/{Simulator → simulator}/Simulator.js +3 -3
  31. package/dist/src/connection/{Simulator → simulator}/Simulator.js.map +1 -1
  32. package/dist/src/connection/{Simulator → simulator}/SimulatorConnection.d.ts +3 -4
  33. package/dist/src/connection/{Simulator → simulator}/SimulatorConnection.js +22 -22
  34. package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -0
  35. package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.d.ts +2 -2
  36. package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js +11 -11
  37. package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js.map +1 -1
  38. package/dist/src/connection/{Simulator → simulator}/SimulatorTransport.d.ts +1 -1
  39. package/dist/src/connection/{Simulator → simulator}/SimulatorTransport.js +2 -2
  40. package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -0
  41. package/dist/src/connection/{Simulator → simulator}/pings.js.map +1 -1
  42. package/dist/src/connection/{WebRTC/IWebRtcConnection.d.ts → webrtc/IWebrtcConnection.d.ts} +2 -2
  43. package/dist/src/connection/{WebRTC/IWebRtcConnection.js → webrtc/IWebrtcConnection.js} +1 -1
  44. package/dist/src/connection/webrtc/IWebrtcConnection.js.map +1 -0
  45. package/dist/src/connection/{WebRTC/NodeWebRtcConnection.d.ts → webrtc/NodeWebrtcConnection.d.ts} +6 -7
  46. package/dist/src/connection/{WebRTC/NodeWebRtcConnection.js → webrtc/NodeWebrtcConnection.js} +36 -36
  47. package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -0
  48. package/dist/src/connection/webrtc/WebrtcConnector.d.ts +38 -0
  49. package/dist/src/connection/webrtc/WebrtcConnector.js +178 -0
  50. package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -0
  51. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +26 -0
  52. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +99 -0
  53. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -0
  54. package/dist/src/connection/{WebRTC/WebRtcConnectorRpcRemote.d.ts → webrtc/WebrtcConnectorRpcRemote.d.ts} +4 -4
  55. package/dist/src/connection/{WebRTC/WebRtcConnectorRpcRemote.js → webrtc/WebrtcConnectorRpcRemote.js} +6 -8
  56. package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -0
  57. package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.d.ts +1 -1
  58. package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js.map +1 -1
  59. package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +26 -0
  60. package/dist/src/connection/websocket/AutoCertifierClientFacade.js +37 -0
  61. package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -0
  62. package/dist/src/connection/{WebSocket/ClientWebSocket.d.ts → websocket/ClientWebsocket.d.ts} +5 -4
  63. package/dist/src/connection/{WebSocket/ClientWebSocket.js → websocket/ClientWebsocket.js} +20 -16
  64. package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -0
  65. package/dist/src/connection/{WebSocket/ServerWebSocket.d.ts → websocket/ServerWebsocket.d.ts} +2 -2
  66. package/dist/src/connection/{WebSocket/ServerWebSocket.js → websocket/ServerWebsocket.js} +23 -27
  67. package/dist/src/connection/websocket/ServerWebsocket.js.map +1 -0
  68. package/dist/src/connection/{WebSocket/WebSocketConnectorRpcLocal.d.ts → websocket/WebsocketConnector.d.ts} +23 -15
  69. package/dist/src/connection/{WebSocket/WebSocketConnectorRpcLocal.js → websocket/WebsocketConnector.js} +107 -101
  70. package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -0
  71. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +17 -0
  72. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +26 -0
  73. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -0
  74. package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.d.ts → websocket/WebsocketConnectorRpcRemote.d.ts} +3 -3
  75. package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.js → websocket/WebsocketConnectorRpcRemote.js} +5 -10
  76. package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.js.map → websocket/WebsocketConnectorRpcRemote.js.map} +1 -1
  77. package/dist/src/connection/{WebSocket/WebSocketServer.d.ts → websocket/WebsocketServer.d.ts} +6 -3
  78. package/dist/src/connection/{WebSocket/WebSocketServer.js → websocket/WebsocketServer.js} +39 -19
  79. package/dist/src/connection/websocket/WebsocketServer.js.map +1 -0
  80. package/dist/src/dht/DhtNode.d.ts +11 -19
  81. package/dist/src/dht/DhtNode.js +119 -150
  82. package/dist/src/dht/DhtNode.js.map +1 -1
  83. package/dist/src/dht/DhtNodeRpcLocal.d.ts +22 -0
  84. package/dist/src/dht/DhtNodeRpcLocal.js +42 -0
  85. package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -0
  86. package/dist/src/dht/{RemoteDhtNode.d.ts → DhtNodeRpcRemote.d.ts} +5 -3
  87. package/dist/src/dht/{RemoteDhtNode.js → DhtNodeRpcRemote.js} +17 -21
  88. package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -0
  89. package/dist/src/dht/ExternalApiRpcLocal.d.ts +16 -0
  90. package/dist/src/dht/ExternalApiRpcLocal.js +30 -0
  91. package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -0
  92. package/dist/src/dht/ExternalApiRpcRemote.d.ts +1 -1
  93. package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
  94. package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
  95. package/dist/src/dht/contact/Remote.d.ts +4 -1
  96. package/dist/src/dht/contact/Remote.js +28 -2
  97. package/dist/src/dht/contact/Remote.js.map +1 -1
  98. package/dist/src/dht/contact/SortedContactList.d.ts +2 -2
  99. package/dist/src/dht/contact/SortedContactList.js +3 -3
  100. package/dist/src/dht/contact/SortedContactList.js.map +1 -1
  101. package/dist/src/dht/discovery/DiscoverySession.d.ts +9 -7
  102. package/dist/src/dht/discovery/DiscoverySession.js +8 -8
  103. package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
  104. package/dist/src/dht/discovery/PeerDiscovery.d.ts +7 -10
  105. package/dist/src/dht/discovery/PeerDiscovery.js +5 -5
  106. package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
  107. package/dist/src/dht/find/FindRpcLocal.d.ts +14 -0
  108. package/dist/src/dht/find/FindRpcLocal.js +25 -0
  109. package/dist/src/dht/find/FindRpcLocal.js.map +1 -0
  110. package/dist/src/dht/find/{RecursiveFindSession.d.ts → FindSession.d.ts} +12 -13
  111. package/dist/src/dht/find/{RecursiveFindSession.js → FindSession.js} +17 -15
  112. package/dist/src/dht/find/FindSession.js.map +1 -0
  113. package/dist/src/dht/find/FindSessionRpcLocal.d.ts +12 -0
  114. package/dist/src/dht/find/FindSessionRpcLocal.js +17 -0
  115. package/dist/src/dht/find/FindSessionRpcLocal.js.map +1 -0
  116. package/dist/src/dht/find/{RemoteRecursiveFindSession.d.ts → FindSessionRpcRemote.d.ts} +2 -2
  117. package/dist/src/dht/find/{RemoteRecursiveFindSession.js → FindSessionRpcRemote.js} +5 -5
  118. package/dist/src/dht/find/FindSessionRpcRemote.js.map +1 -0
  119. package/dist/src/dht/find/{RecursiveFinder.d.ts → Finder.d.ts} +16 -19
  120. package/dist/src/dht/find/{RecursiveFinder.js → Finder.js} +50 -46
  121. package/dist/src/dht/find/Finder.js.map +1 -0
  122. package/dist/src/dht/routing/FindRpcRemote.d.ts +6 -0
  123. package/dist/src/dht/routing/FindRpcRemote.js +41 -0
  124. package/dist/src/dht/routing/FindRpcRemote.js.map +1 -0
  125. package/dist/src/dht/routing/Router.d.ts +10 -17
  126. package/dist/src/dht/routing/Router.js +47 -90
  127. package/dist/src/dht/routing/Router.js.map +1 -1
  128. package/dist/src/dht/routing/RouterRpcLocal.d.ts +22 -0
  129. package/dist/src/dht/routing/RouterRpcLocal.js +66 -0
  130. package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -0
  131. package/dist/src/dht/routing/RouterRpcRemote.d.ts +0 -1
  132. package/dist/src/dht/routing/RouterRpcRemote.js +15 -43
  133. package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
  134. package/dist/src/dht/routing/RoutingSession.d.ts +17 -8
  135. package/dist/src/dht/routing/RoutingSession.js +124 -131
  136. package/dist/src/dht/routing/RoutingSession.js.map +1 -1
  137. package/dist/src/dht/routing/getPreviousPeer.d.ts +2 -0
  138. package/dist/src/dht/routing/getPreviousPeer.js +9 -0
  139. package/dist/src/dht/routing/getPreviousPeer.js.map +1 -0
  140. package/dist/src/dht/store/StoreRpcLocal.d.ts +11 -8
  141. package/dist/src/dht/store/StoreRpcLocal.js +25 -24
  142. package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
  143. package/dist/src/dht/store/StoreRpcRemote.js +3 -7
  144. package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
  145. package/dist/src/exports.d.ts +11 -5
  146. package/dist/src/exports.js +17 -4
  147. package/dist/src/exports.js.map +1 -1
  148. package/dist/src/helpers/Connectivity.d.ts +4 -0
  149. package/dist/src/helpers/Connectivity.js +24 -0
  150. package/dist/src/helpers/Connectivity.js.map +1 -0
  151. package/dist/src/helpers/errors.d.ts +3 -3
  152. package/dist/src/helpers/errors.js +7 -7
  153. package/dist/src/helpers/protoClasses.js +3 -3
  154. package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +56 -39
  155. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +49 -36
  156. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
  157. package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +64 -84
  158. package/dist/src/proto/packages/dht/protos/DhtRpc.js +64 -66
  159. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
  160. package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +26 -21
  161. package/dist/src/rpc-protocol/DhtCallContext.d.ts +0 -1
  162. package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -1
  163. package/dist/src/transport/ITransport.d.ts +5 -6
  164. package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -1
  165. package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
  166. package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -1
  167. package/dist/src/transport/RoutingRpcCommunicator.js +0 -1
  168. package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
  169. package/dist/src/types/ServiceID.d.ts +1 -0
  170. package/dist/src/types/ServiceID.js +3 -0
  171. package/dist/src/types/ServiceID.js.map +1 -0
  172. package/karma.config.js +4 -4
  173. package/package.json +10 -8
  174. package/protos/DhtRpc.proto +32 -35
  175. package/src/connection/ConnectionLockHandler.ts +19 -17
  176. package/src/connection/ConnectionLockRpcLocal.ts +74 -0
  177. package/src/connection/ConnectionLockRpcRemote.ts +7 -6
  178. package/src/connection/ConnectionManager.ts +59 -95
  179. package/src/connection/ConnectivityChecker.ts +30 -26
  180. package/src/connection/ConnectorFacade.ts +74 -34
  181. package/src/connection/Handshaker.ts +9 -9
  182. package/src/connection/IConnection.ts +5 -6
  183. package/src/connection/ManagedConnection.ts +21 -22
  184. package/src/connection/{ManagedWebRtcConnection.ts → ManagedWebrtcConnection.ts} +9 -9
  185. package/src/connection/{Simulator → simulator}/Simulator.ts +4 -4
  186. package/src/connection/{Simulator → simulator}/SimulatorConnection.ts +23 -24
  187. package/src/connection/{Simulator → simulator}/SimulatorConnector.ts +13 -13
  188. package/src/connection/{Simulator → simulator}/SimulatorTransport.ts +2 -2
  189. package/src/connection/{WebRTC/BrowserWebRtcConnection.ts → webrtc/BrowserWebrtcConnection.ts} +12 -13
  190. package/src/connection/{WebRTC/IWebRtcConnection.ts → webrtc/IWebrtcConnection.ts} +2 -2
  191. package/src/connection/{WebRTC/NodeWebRtcConnection.ts → webrtc/NodeWebrtcConnection.ts} +32 -33
  192. package/src/connection/webrtc/WebrtcConnector.ts +225 -0
  193. package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +132 -0
  194. package/src/connection/{WebRTC/WebRtcConnectorRpcRemote.ts → webrtc/WebrtcConnectorRpcRemote.ts} +6 -7
  195. package/src/connection/{WebRTC → webrtc}/iceServerAsString.ts +1 -1
  196. package/src/connection/websocket/AutoCertifierClientFacade.ts +91 -0
  197. package/src/connection/{WebSocket/ClientWebSocket.ts → websocket/ClientWebsocket.ts} +19 -17
  198. package/src/connection/{WebSocket/ServerWebSocket.ts → websocket/ServerWebsocket.ts} +21 -27
  199. package/src/connection/{WebSocket/WebSocketConnectorRpcLocal.ts → websocket/WebsocketConnector.ts} +109 -100
  200. package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +41 -0
  201. package/src/connection/{WebSocket/WebSocketConnectorRpcRemote.ts → websocket/WebsocketConnectorRpcRemote.ts} +6 -12
  202. package/src/connection/{WebSocket/WebSocketServer.ts → websocket/WebsocketServer.ts} +40 -22
  203. package/src/dht/DhtNode.ts +144 -179
  204. package/src/dht/DhtNodeRpcLocal.ts +68 -0
  205. package/src/dht/{RemoteDhtNode.ts → DhtNodeRpcRemote.ts} +12 -13
  206. package/src/dht/ExternalApiRpcLocal.ts +46 -0
  207. package/src/dht/ExternalApiRpcRemote.ts +4 -4
  208. package/src/dht/contact/Remote.ts +32 -4
  209. package/src/dht/contact/SortedContactList.ts +4 -4
  210. package/src/dht/discovery/DiscoverySession.ts +23 -20
  211. package/src/dht/discovery/PeerDiscovery.ts +14 -17
  212. package/src/dht/find/FindRpcLocal.ts +35 -0
  213. package/src/dht/find/{RecursiveFindSession.ts → FindSession.ts} +25 -25
  214. package/src/dht/find/FindSessionRpcLocal.ts +25 -0
  215. package/src/dht/find/{RemoteRecursiveFindSession.ts → FindSessionRpcRemote.ts} +9 -5
  216. package/src/dht/find/{RecursiveFinder.ts → Finder.ts} +77 -71
  217. package/src/dht/routing/FindRpcRemote.ts +40 -0
  218. package/src/dht/routing/Router.ts +69 -105
  219. package/src/dht/routing/RouterRpcLocal.ts +81 -0
  220. package/src/dht/routing/RouterRpcRemote.ts +15 -45
  221. package/src/dht/routing/RoutingSession.ts +56 -61
  222. package/src/dht/routing/getPreviousPeer.ts +6 -0
  223. package/src/dht/store/StoreRpcLocal.ts +44 -37
  224. package/src/dht/store/StoreRpcRemote.ts +4 -8
  225. package/src/exports.ts +11 -5
  226. package/src/helpers/Connectivity.ts +19 -0
  227. package/src/helpers/errors.ts +3 -3
  228. package/src/helpers/protoClasses.ts +6 -6
  229. package/src/proto/packages/dht/protos/DhtRpc.client.ts +75 -59
  230. package/src/proto/packages/dht/protos/DhtRpc.server.ts +26 -21
  231. package/src/proto/packages/dht/protos/DhtRpc.ts +87 -114
  232. package/src/rpc-protocol/DhtCallContext.ts +0 -1
  233. package/src/transport/ITransport.ts +5 -8
  234. package/src/transport/ListeningRpcCommunicator.ts +2 -1
  235. package/src/transport/RoutingRpcCommunicator.ts +3 -4
  236. package/src/types/ServiceID.ts +1 -0
  237. package/test/benchmark/{RecursiveFind.test.ts → Find.test.ts} +6 -6
  238. package/test/benchmark/KademliaCorrectness.test.ts +2 -2
  239. package/test/benchmark/kademlia-simulation/SimulationNode.ts +3 -3
  240. package/test/end-to-end/Layer0-Layer1.test.ts +13 -5
  241. package/test/end-to-end/Layer0.test.ts +35 -17
  242. package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +24 -6
  243. package/test/end-to-end/{Layer0WebRTC-Layer1.test.ts → Layer0Webrtc-Layer1.test.ts} +1 -1
  244. package/test/end-to-end/{Layer0WebRTC.test.ts → Layer0Webrtc.test.ts} +14 -10
  245. package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +8 -4
  246. package/test/end-to-end/{Layer1-Scale-WebRTC.test.ts → Layer1-Scale-Webrtc.test.ts} +2 -2
  247. package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +52 -0
  248. package/test/end-to-end/{WebSocketConnectionRequest.test.ts → WebsocketConnectionRequest.test.ts} +16 -8
  249. package/test/end-to-end/memory-leak.test.ts +85 -0
  250. package/test/integration/ConnectionLocking.test.ts +4 -4
  251. package/test/integration/ConnectionManager.test.ts +37 -28
  252. package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
  253. package/test/integration/DhtNodeExternalAPI.test.ts +10 -10
  254. package/test/integration/{RemoteDhtNode.test.ts → DhtNodeRpcRemote.test.ts} +10 -10
  255. package/test/integration/DhtRpc.test.ts +5 -5
  256. package/test/integration/{RecursiveFind.test.ts → Find.test.ts} +3 -3
  257. package/test/integration/Layer1-scale.test.ts +1 -1
  258. package/test/integration/MigrateData.test.ts +6 -5
  259. package/test/integration/Mock-Layer1-Layer0.test.ts +1 -1
  260. package/test/integration/MultipleEntryPointJoining.test.ts +6 -6
  261. package/test/integration/RouteMessage.test.ts +26 -26
  262. package/test/integration/RpcErrors.test.ts +10 -10
  263. package/test/integration/ScaleDownDht.test.ts +3 -3
  264. package/test/integration/SimultaneousConnections.test.ts +10 -7
  265. package/test/integration/Store.test.ts +1 -1
  266. package/test/integration/StoreAndDelete.test.ts +1 -1
  267. package/test/integration/StoreOnDhtWithTwoNodes.test.ts +12 -12
  268. package/test/integration/{WebRtcConnectionManagement.test.ts → WebrtcConnectionManagement.test.ts} +4 -4
  269. package/test/integration/{WebRtcConnectorRpc.test.ts → WebrtcConnectorRpc.test.ts} +7 -8
  270. package/test/integration/{WebSocket.test.ts → Websocket.test.ts} +14 -13
  271. package/test/integration/{WebSocketConnectionManagement.test.ts → WebsocketConnectionManagement.test.ts} +4 -4
  272. package/test/integration/{WebSocketConnectorRpc.test.ts → WebsocketConnectorRpc.test.ts} +15 -15
  273. package/test/unit/AutoCertifierClientFacade.test.ts +58 -0
  274. package/test/unit/ConnectivityHelpers.test.ts +69 -0
  275. package/test/unit/{RecursiveFinder.test.ts → Finder.test.ts} +19 -17
  276. package/test/unit/Router.test.ts +26 -26
  277. package/test/unit/UUID.test.ts +1 -1
  278. package/test/unit/{WebSocketConnectorRpcLocal.test.ts → WebsocketConnector.test.ts} +8 -8
  279. package/test/unit/{WebSocketServer.test.ts → WebsocketServer.test.ts} +20 -14
  280. package/test/unit/webrtcReplaceInternalIpWithExternalIp.test.ts +1 -1
  281. package/test/utils/FakeRpcCommunicator.ts +23 -0
  282. package/test/utils/mock/Transport.ts +1 -1
  283. package/test/utils/utils.ts +14 -24
  284. package/tsconfig.browser.json +1 -1
  285. package/tsconfig.jest.json +3 -2
  286. package/tsconfig.node.json +3 -2
  287. package/dist/src/connection/ManagedWebRtcConnection.d.ts +0 -7
  288. package/dist/src/connection/ManagedWebRtcConnection.js +0 -20
  289. package/dist/src/connection/ManagedWebRtcConnection.js.map +0 -1
  290. package/dist/src/connection/Simulator/SimulatorConnection.js.map +0 -1
  291. package/dist/src/connection/Simulator/SimulatorTransport.js.map +0 -1
  292. package/dist/src/connection/WebRTC/IWebRtcConnection.js.map +0 -1
  293. package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +0 -1
  294. package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.d.ts +0 -51
  295. package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js +0 -249
  296. package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js.map +0 -1
  297. package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js.map +0 -1
  298. package/dist/src/connection/WebSocket/ClientWebSocket.js.map +0 -1
  299. package/dist/src/connection/WebSocket/ServerWebSocket.js.map +0 -1
  300. package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js.map +0 -1
  301. package/dist/src/connection/WebSocket/WebSocketServer.js.map +0 -1
  302. package/dist/src/dht/RemoteDhtNode.js.map +0 -1
  303. package/dist/src/dht/find/RecursiveFindSession.js.map +0 -1
  304. package/dist/src/dht/find/RecursiveFinder.js.map +0 -1
  305. package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +0 -1
  306. package/dist/src/dht/registerExternalApiRpcMethods.d.ts +0 -2
  307. package/dist/src/dht/registerExternalApiRpcMethods.js +0 -32
  308. package/dist/src/dht/registerExternalApiRpcMethods.js.map +0 -1
  309. package/src/connection/WebRTC/WebRtcConnectorRpcLocal.ts +0 -335
  310. package/src/dht/registerExternalApiRpcMethods.ts +0 -44
  311. package/test/utils/mock/RecursiveFinder.ts +0 -19
  312. /package/dist/src/connection/{Simulator → simulator}/Simulator.d.ts +0 -0
  313. /package/dist/src/connection/{Simulator → simulator}/pings.d.ts +0 -0
  314. /package/dist/src/connection/{Simulator → simulator}/pings.js +0 -0
  315. /package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js +0 -0
  316. /package/src/connection/{Simulator → simulator}/pings.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClientWebsocket.js","sourceRoot":"","sources":["../../../../src/connection/websocket/ClientWebsocket.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAuC;AACvC,kEAAwC;AACxC,yCAAiF;AACjF,gDAA4F;AAE5F,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,mGAAmG;AACnG,sDAAsD;AACzC,QAAA,UAAU,GAAG,IAAI,CAAA;AAE9B,MAAM,WAAW,GAAG,aAAa,CAAA;AAEjC,MAAa,eAAgB,SAAQ,uBAA8B;IAO/D;QACI,KAAK,EAAE,CAAA;QALJ,mBAAc,GAAG,4BAAc,CAAC,gBAAgB,CAAA;QAE/C,cAAS,GAAG,KAAK,CAAA;QAIrB,IAAI,CAAC,YAAY,GAAG,IAAI,0BAAY,EAAE,CAAA;IAC1C,CAAC;IAEM,OAAO,CAAC,OAAe,EAAE,UAAoB;QAChD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAS,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,kBAAkB,EAAE,CAAC,UAAU,EAAE,CAAC,CAAA;YAC1G,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,WAAW,CAA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CAAC,kBAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;SACtE;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAA;SACxD;IACL,CAAC;IAEO,aAAa;QACjB,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,SAAoC,CAAA;YACzD,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,SAAoC,CAAA;YAC1D,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,SAAoC,CAAA;YAC1D,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,SAAoC,CAAA;SAC/D;IACL,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,kBAAkB,EAAE,CAAA;YACzB,IAAI,IAAI,CAAC,MAAM,EAAE;gBACb,IAAI,CAAC,aAAa,EAAE,CAAA;gBACpB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;gBACnB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAA;aAC1B;YACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;SACxB;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAA;SAC1D;IACL,CAAC;CACJ;AA1GD,0CA0GC"}
@@ -3,7 +3,7 @@ import EventEmitter from 'eventemitter3';
3
3
  import { IConnection, ConnectionID, ConnectionEvents, ConnectionType } from '../IConnection';
4
4
  import { connection as WsConnection } from 'websocket';
5
5
  import { Url } from 'url';
6
- export declare class ServerWebSocket extends EventEmitter<ConnectionEvents> implements IConnection {
6
+ export declare class ServerWebsocket extends EventEmitter<ConnectionEvents> implements IConnection {
7
7
  readonly connectionId: ConnectionID;
8
8
  readonly connectionType = ConnectionType.WEBSOCKET_SERVER;
9
9
  readonly resourceURL: Url;
@@ -12,7 +12,7 @@ export declare class ServerWebSocket extends EventEmitter<ConnectionEvents> impl
12
12
  constructor(socket: WsConnection, resourceURL: Url);
13
13
  private doDisconnect;
14
14
  send(data: Uint8Array): void;
15
- close(): Promise<void>;
15
+ close(gracefulLeave: boolean): Promise<void>;
16
16
  destroy(): void;
17
17
  getRemoteAddress(): string;
18
18
  }
@@ -3,17 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ServerWebSocket = void 0;
6
+ exports.ServerWebsocket = void 0;
7
7
  const eventemitter3_1 = __importDefault(require("eventemitter3"));
8
8
  const IConnection_1 = require("../IConnection");
9
9
  const utils_1 = require("@streamr/utils");
10
+ const ClientWebsocket_1 = require("./ClientWebsocket");
10
11
  const logger = new utils_1.Logger(module);
11
12
  var MessageType;
12
13
  (function (MessageType) {
13
14
  MessageType["UTF8"] = "utf8";
14
15
  MessageType["BINARY"] = "binary";
15
16
  })(MessageType || (MessageType = {}));
16
- class ServerWebSocket extends eventemitter3_1.default {
17
+ class ServerWebsocket extends eventemitter3_1.default {
17
18
  constructor(socket, resourceURL) {
18
19
  super();
19
20
  this.connectionType = IConnection_1.ConnectionType.WEBSOCKET_SERVER;
@@ -21,35 +22,30 @@ class ServerWebSocket extends eventemitter3_1.default {
21
22
  this.resourceURL = resourceURL;
22
23
  this.connectionId = new IConnection_1.ConnectionID();
23
24
  socket.on('message', (message) => {
24
- if (!this.stopped) {
25
- logger.trace('ServerWebSocket::onMessage');
26
- if (message.type === MessageType.UTF8) {
27
- logger.debug('Received string Message: ' + message.utf8Data);
28
- }
29
- else if (message.type === MessageType.BINARY) {
30
- logger.trace('Received Binary Message of ' + message.binaryData.length + ' bytes');
31
- this.emit('data', new Uint8Array(message.binaryData.buffer, message.binaryData.byteOffset, message.binaryData.byteLength / Uint8Array.BYTES_PER_ELEMENT));
32
- }
25
+ logger.trace('ServerWebsocket::onMessage');
26
+ if (message.type === MessageType.UTF8) {
27
+ logger.debug('Received string Message: ' + message.utf8Data);
28
+ }
29
+ else if (message.type === MessageType.BINARY) {
30
+ logger.trace('Received Binary Message of ' + message.binaryData.length + ' bytes');
31
+ this.emit('data', new Uint8Array(message.binaryData.buffer, message.binaryData.byteOffset, message.binaryData.byteLength / Uint8Array.BYTES_PER_ELEMENT));
33
32
  }
34
33
  });
35
34
  socket.on('close', (reasonCode, description) => {
36
- if (!this.stopped) {
37
- logger.trace(' Peer ' + socket.remoteAddress + ' disconnected.');
38
- this.doDisconnect('OTHER', reasonCode, description);
39
- }
35
+ logger.trace('Peer ' + socket.remoteAddress + ' disconnected.');
36
+ this.doDisconnect(reasonCode, description);
40
37
  });
41
38
  socket.on('error', (error) => {
42
- if (!this.stopped) {
43
- this.emit('error', error.name);
44
- }
39
+ this.emit('error', error.name);
45
40
  });
46
41
  this.socket = socket;
47
42
  }
48
- doDisconnect(disconnectionType, reasonCode, description) {
43
+ doDisconnect(reasonCode, description) {
49
44
  this.stopped = true;
50
45
  this.socket?.removeAllListeners();
51
46
  this.socket = undefined;
52
- this.emit('disconnected', disconnectionType, reasonCode, description);
47
+ const gracefulLeave = reasonCode === ClientWebsocket_1.GOING_AWAY;
48
+ this.emit('disconnected', gracefulLeave, reasonCode, description);
53
49
  }
54
50
  send(data) {
55
51
  // If in an Karma / Electron test, use the NodeJS implementation
@@ -63,15 +59,15 @@ class ServerWebSocket extends eventemitter3_1.default {
63
59
  }
64
60
  }
65
61
  else {
66
- logger.error('Tried to call send() on a stopped socket');
62
+ logger.debug('Tried to call send() on a stopped socket');
67
63
  }
68
64
  }
69
- async close() {
65
+ async close(gracefulLeave) {
70
66
  if (!this.stopped) {
71
- this.socket?.close();
67
+ this.socket?.close(gracefulLeave === true ? ClientWebsocket_1.GOING_AWAY : undefined);
72
68
  }
73
69
  else {
74
- logger.error('Tried to close a stopped connection');
70
+ logger.debug('Tried to close a stopped connection');
75
71
  }
76
72
  }
77
73
  destroy() {
@@ -85,7 +81,7 @@ class ServerWebSocket extends eventemitter3_1.default {
85
81
  this.stopped = true;
86
82
  }
87
83
  else {
88
- logger.error('Tried to destroy() a stopped connection');
84
+ logger.debug('Tried to destroy() a stopped connection');
89
85
  }
90
86
  }
91
87
  getRemoteAddress() {
@@ -98,5 +94,5 @@ class ServerWebSocket extends eventemitter3_1.default {
98
94
  }
99
95
  }
100
96
  }
101
- exports.ServerWebSocket = ServerWebSocket;
102
- //# sourceMappingURL=ServerWebSocket.js.map
97
+ exports.ServerWebsocket = ServerWebsocket;
98
+ //# sourceMappingURL=ServerWebsocket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServerWebsocket.js","sourceRoot":"","sources":["../../../../src/connection/websocket/ServerWebsocket.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAwC;AACxC,gDAA4F;AAE5F,0CAAuC;AAEvC,uDAA8C;AAE9C,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAQjC,IAAK,WAGJ;AAHD,WAAK,WAAW;IACZ,4BAAa,CAAA;IACb,gCAAiB,CAAA;AACrB,CAAC,EAHI,WAAW,KAAX,WAAW,QAGf;AAED,MAAa,eAAgB,SAAQ,uBAA8B;IAQ/D,YAAY,MAAoB,EAAE,WAAgB;QAC9C,KAAK,EAAE,CAAA;QANK,mBAAc,GAAG,4BAAc,CAAC,gBAAgB,CAAA;QAGxD,YAAO,GAAG,KAAK,CAAA;QAKnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,YAAY,GAAG,IAAI,0BAAY,EAAE,CAAA;QAEtC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;YAC7B,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAA;YAC1C,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,EAAE;gBACnC,MAAM,CAAC,KAAK,CAAC,2BAA2B,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;aAC/D;iBAAM,IAAI,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AAC,wDAAwD,CAAC,CAAA;YACtE,OAAO,EAAE,CAAA;SACZ;IACL,CAAC;CACJ;AA3FD,0CA2FC"}
@@ -1,45 +1,53 @@
1
1
  import { ITransport } from '../../transport/ITransport';
2
- import { ConnectivityMethod, ConnectivityResponse, PeerDescriptor, WebSocketConnectionRequest, WebSocketConnectionResponse } from '../../proto/packages/dht/protos/DhtRpc';
3
- import { IWebSocketConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server';
2
+ import { ConnectivityMethod, ConnectivityResponse, PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
4
3
  import { ManagedConnection } from '../ManagedConnection';
5
4
  import { PortRange, TlsCertificate } from '../ConnectionManager';
6
- import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
7
- export declare const connectivityMethodToWebSocketUrl: (ws: ConnectivityMethod) => string;
8
- interface WebSocketConnectorRpcLocalConfig {
5
+ export declare const connectivityMethodToWebsocketUrl: (ws: ConnectivityMethod) => string;
6
+ interface WebsocketConnectorConfig {
9
7
  transport: ITransport;
10
- canConnect: (peerDescriptor: PeerDescriptor, _ip: string, port: number) => boolean;
8
+ canConnect: (peerDescriptor: PeerDescriptor) => boolean;
11
9
  onIncomingConnection: (connection: ManagedConnection) => boolean;
12
10
  portRange?: PortRange;
13
11
  maxMessageSize?: number;
14
12
  host?: string;
15
13
  entrypoints?: PeerDescriptor[];
16
14
  tlsCertificate?: TlsCertificate;
15
+ autoCertifierTransport: ITransport;
16
+ autoCertifierUrl: string;
17
+ autoCertifierConfigFile: string;
18
+ serverEnableTls: boolean;
17
19
  }
18
- export declare class WebSocketConnectorRpcLocal implements IWebSocketConnectorRpc {
20
+ export declare class WebsocketConnector {
19
21
  private static readonly WEBSOCKET_CONNECTOR_SERVICE_ID;
20
22
  private readonly rpcCommunicator;
21
- private readonly canConnectFunction;
22
- private readonly webSocketServer?;
23
+ private readonly websocketServer?;
23
24
  private connectivityChecker?;
24
25
  private readonly ongoingConnectRequests;
25
26
  private onIncomingConnection;
26
27
  private host?;
27
28
  private readonly entrypoints?;
28
29
  private readonly tlsCertificate?;
30
+ private readonly autoCertifierTransport;
31
+ private readonly autoCertifierUrl;
32
+ private readonly autoCertifierConfigFile;
33
+ private readonly serverEnableTls;
34
+ private autoCertifierClient?;
29
35
  private selectedPort?;
30
- private ownPeerDescriptor?;
36
+ private localPeerDescriptor?;
31
37
  private connectingConnections;
32
- private destroyed;
33
- constructor(config: WebSocketConnectorRpcLocalConfig);
38
+ private abortController;
39
+ constructor(config: WebsocketConnectorConfig);
40
+ private registerLocalRpcMethods;
34
41
  private attachHandshaker;
42
+ autoCertify(): Promise<void>;
43
+ private setHost;
35
44
  start(): Promise<void>;
36
- checkConnectivity(): Promise<ConnectivityResponse>;
45
+ checkConnectivity(selfSigned: boolean): Promise<ConnectivityResponse>;
37
46
  isPossibleToFormConnection(targetPeerDescriptor: PeerDescriptor): boolean;
38
47
  connect(targetPeerDescriptor: PeerDescriptor): ManagedConnection;
39
48
  private requestConnectionFromPeer;
40
49
  private onServerSocketHandshakeRequest;
41
- setOwnPeerDescriptor(ownPeerDescriptor: PeerDescriptor): void;
50
+ setLocalPeerDescriptor(localPeerDescriptor: PeerDescriptor): void;
42
51
  destroy(): Promise<void>;
43
- requestConnection(request: WebSocketConnectionRequest, context: ServerCallContext): Promise<WebSocketConnectionResponse>;
44
52
  }
45
53
  export {};
@@ -1,81 +1,97 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebSocketConnectorRpcLocal = exports.connectivityMethodToWebSocketUrl = void 0;
4
- const ClientWebSocket_1 = require("./ClientWebSocket");
3
+ exports.WebsocketConnector = exports.connectivityMethodToWebsocketUrl = void 0;
4
+ const ClientWebsocket_1 = require("./ClientWebsocket");
5
5
  const IConnection_1 = require("../IConnection");
6
6
  const ListeningRpcCommunicator_1 = require("../../transport/ListeningRpcCommunicator");
7
- const WebSocketConnectorRpcRemote_1 = require("./WebSocketConnectorRpcRemote");
7
+ const WebsocketConnectorRpcLocal_1 = require("./WebsocketConnectorRpcLocal");
8
+ const WebsocketConnectorRpcRemote_1 = require("./WebsocketConnectorRpcRemote");
8
9
  const DhtRpc_1 = require("../../proto/packages/dht/protos/DhtRpc");
9
10
  const DhtRpc_client_1 = require("../../proto/packages/dht/protos/DhtRpc.client");
10
11
  const utils_1 = require("@streamr/utils");
11
12
  const ManagedConnection_1 = require("../ManagedConnection");
12
- const WebSocketServer_1 = require("./WebSocketServer");
13
+ const WebsocketServer_1 = require("./WebsocketServer");
13
14
  const ConnectivityChecker_1 = require("../ConnectivityChecker");
14
15
  const ConnectionManager_1 = require("../ConnectionManager");
15
16
  const proto_rpc_1 = require("@streamr/proto-rpc");
16
17
  const Handshaker_1 = require("../Handshaker");
17
18
  const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
18
19
  const lodash_1 = require("lodash");
19
- const AddressTools_1 = require("../../helpers/AddressTools");
20
+ const Connectivity_1 = require("../../helpers/Connectivity");
21
+ const errors_1 = require("../../helpers/errors");
22
+ const AutoCertifierClientFacade_1 = require("./AutoCertifierClientFacade");
20
23
  const logger = new utils_1.Logger(module);
21
- const connectivityMethodToWebSocketUrl = (ws) => {
24
+ const connectivityMethodToWebsocketUrl = (ws) => {
22
25
  return (ws.tls ? 'wss://' : 'ws://') + ws.host + ':' + ws.port;
23
26
  };
24
- exports.connectivityMethodToWebSocketUrl = connectivityMethodToWebSocketUrl;
25
- const canOpenConnectionFromBrowser = (websocketServer) => {
26
- const hasPrivateAddress = ((websocketServer.host === 'localhost') || (0, AddressTools_1.isPrivateIPv4)(websocketServer.host));
27
- return websocketServer.tls || hasPrivateAddress;
28
- };
27
+ exports.connectivityMethodToWebsocketUrl = connectivityMethodToWebsocketUrl;
29
28
  const ENTRY_POINT_CONNECTION_ATTEMPTS = 5;
30
- class WebSocketConnectorRpcLocal {
29
+ class WebsocketConnector {
31
30
  constructor(config) {
32
31
  this.ongoingConnectRequests = new Map();
33
32
  this.connectingConnections = new Map();
34
- this.destroyed = false;
35
- this.onServerSocketHandshakeRequest = (peerDescriptor, serverWebSocket) => {
36
- const peerId = (0, peerIdFromPeerDescriptor_1.peerIdFromPeerDescriptor)(peerDescriptor);
37
- if (this.ongoingConnectRequests.has(peerId.toKey())) {
38
- const ongoingConnectReguest = this.ongoingConnectRequests.get(peerId.toKey());
39
- ongoingConnectReguest.attachImplementation(serverWebSocket);
40
- ongoingConnectReguest.acceptHandshake();
41
- this.ongoingConnectRequests.delete(peerId.toKey());
42
- }
43
- else {
44
- const managedConnection = new ManagedConnection_1.ManagedConnection(this.ownPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_SERVER, undefined, serverWebSocket);
45
- managedConnection.setPeerDescriptor(peerDescriptor);
46
- if (this.onIncomingConnection(managedConnection)) {
47
- managedConnection.acceptHandshake();
48
- }
49
- else {
50
- managedConnection.rejectHandshake('Duplicate connection');
51
- managedConnection.destroy();
52
- }
53
- }
54
- };
55
- this.webSocketServer = config.portRange ? new WebSocketServer_1.WebSocketServer({
33
+ this.abortController = new AbortController();
34
+ this.websocketServer = config.portRange ? new WebsocketServer_1.WebsocketServer({
56
35
  portRange: config.portRange,
57
36
  tlsCertificate: config.tlsCertificate,
58
- maxMessageSize: config.maxMessageSize
37
+ maxMessageSize: config.maxMessageSize,
38
+ enableTls: config.serverEnableTls
59
39
  }) : undefined;
60
40
  this.onIncomingConnection = config.onIncomingConnection;
61
41
  this.host = config.host;
62
42
  this.entrypoints = config.entrypoints;
63
43
  this.tlsCertificate = config.tlsCertificate;
64
- this.canConnectFunction = config.canConnect.bind(this);
65
- this.rpcCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(WebSocketConnectorRpcLocal.WEBSOCKET_CONNECTOR_SERVICE_ID, config.transport, {
44
+ this.autoCertifierTransport = config.autoCertifierTransport;
45
+ this.autoCertifierUrl = config.autoCertifierUrl;
46
+ this.autoCertifierConfigFile = config.autoCertifierConfigFile;
47
+ this.serverEnableTls = config.serverEnableTls;
48
+ this.rpcCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(WebsocketConnector.WEBSOCKET_CONNECTOR_SERVICE_ID, config.transport, {
66
49
  rpcRequestTimeout: 15000
67
50
  });
68
- this.rpcCommunicator.registerRpcMethod(DhtRpc_1.WebSocketConnectionRequest, DhtRpc_1.WebSocketConnectionResponse, 'requestConnection', (req, context) => this.requestConnection(req, context));
51
+ this.registerLocalRpcMethods(config);
52
+ }
53
+ registerLocalRpcMethods(config) {
54
+ const rpcLocal = new WebsocketConnectorRpcLocal_1.WebsocketConnectorRpcLocal({
55
+ canConnect: (peerDescriptor) => config.canConnect(peerDescriptor),
56
+ connect: (targetPeerDescriptor) => this.connect(targetPeerDescriptor),
57
+ onIncomingConnection: (connection) => config.onIncomingConnection(connection),
58
+ abortSignal: this.abortController.signal
59
+ });
60
+ this.rpcCommunicator.registerRpcMethod(DhtRpc_1.WebsocketConnectionRequest, DhtRpc_1.WebsocketConnectionResponse, 'requestConnection', async (req, context) => {
61
+ if (!this.abortController.signal.aborted) {
62
+ return rpcLocal.requestConnection(req, context);
63
+ }
64
+ else {
65
+ return { accepted: false };
66
+ }
67
+ });
69
68
  }
70
69
  attachHandshaker(connection) {
71
- const handshaker = new Handshaker_1.Handshaker(this.ownPeerDescriptor, connection);
70
+ const handshaker = new Handshaker_1.Handshaker(this.localPeerDescriptor, connection);
72
71
  handshaker.once('handshakeRequest', (peerDescriptor) => {
73
72
  this.onServerSocketHandshakeRequest(peerDescriptor, connection);
74
73
  });
75
74
  }
75
+ async autoCertify() {
76
+ this.autoCertifierClient = new AutoCertifierClientFacade_1.AutoCertifierClientFacade({
77
+ configFile: this.autoCertifierConfigFile,
78
+ transport: this.autoCertifierTransport,
79
+ url: this.autoCertifierUrl,
80
+ wsServerPort: this.selectedPort,
81
+ setHost: (hostName) => this.setHost(hostName),
82
+ updateCertificate: (certificate, privateKey) => this.websocketServer.updateCertificate(certificate, privateKey)
83
+ });
84
+ logger.trace(`AutoCertifying subdomain...`);
85
+ await this.autoCertifierClient.start();
86
+ }
87
+ setHost(hostName) {
88
+ logger.trace(`Setting host name to ${hostName}`);
89
+ this.host = hostName;
90
+ this.connectivityChecker.setHost(hostName);
91
+ }
76
92
  async start() {
77
- if (!this.destroyed && this.webSocketServer) {
78
- this.webSocketServer.on('connected', (connection) => {
93
+ if (!this.abortController.signal.aborted && this.websocketServer) {
94
+ this.websocketServer.on('connected', (connection) => {
79
95
  const serverSocket = connection;
80
96
  if (serverSocket.resourceURL &&
81
97
  serverSocket.resourceURL.query) {
@@ -95,33 +111,30 @@ class WebSocketConnectorRpcLocal {
95
111
  this.attachHandshaker(connection);
96
112
  }
97
113
  });
98
- const port = await this.webSocketServer.start();
114
+ const port = await this.websocketServer.start();
99
115
  this.selectedPort = port;
100
- this.connectivityChecker = new ConnectivityChecker_1.ConnectivityChecker(this.selectedPort, this.tlsCertificate !== undefined, this.host);
116
+ this.connectivityChecker = new ConnectivityChecker_1.ConnectivityChecker(this.selectedPort, this.serverEnableTls, this.host);
101
117
  }
102
118
  }
103
- async checkConnectivity() {
119
+ async checkConnectivity(selfSigned) {
104
120
  // TODO: this could throw if the server is not running
105
121
  const noServerConnectivityResponse = {
106
- openInternet: false,
107
122
  host: '127.0.0.1',
108
123
  natType: ConnectionManager_1.NatType.UNKNOWN
109
124
  };
110
- if (this.destroyed) {
125
+ if (this.abortController.signal.aborted) {
111
126
  return noServerConnectivityResponse;
112
127
  }
113
128
  for (const reattempt of (0, lodash_1.range)(ENTRY_POINT_CONNECTION_ATTEMPTS)) {
114
129
  const entryPoint = (0, lodash_1.sample)(this.entrypoints);
115
130
  try {
116
- if (!this.webSocketServer) {
117
- // If no websocket server, return openInternet: false
131
+ if (!this.websocketServer) {
118
132
  return noServerConnectivityResponse;
119
133
  }
120
134
  else {
121
- if (!this.entrypoints || this.entrypoints.length < 1) {
135
+ if (!this.entrypoints || this.entrypoints.length === 0) {
122
136
  // return connectivity info given in config
123
137
  const preconfiguredConnectivityResponse = {
124
- openInternet: true,
125
138
  host: this.host,
126
139
  natType: ConnectionManager_1.NatType.OPEN_INTERNET,
127
140
  websocket: { host: this.host, port: this.selectedPort, tls: this.tlsCertificate !== undefined }
@@ -129,32 +142,25 @@ class WebSocketConnectorRpcLocal {
129
142
  return preconfiguredConnectivityResponse;
130
143
  }
131
144
  else {
132
- // Do real connectivity checking
133
- return await this.connectivityChecker.sendConnectivityRequest(entryPoint);
145
+ // Do real connectivity checking
146
+ return await this.connectivityChecker.sendConnectivityRequest(entryPoint, selfSigned);
134
147
  }
135
148
  }
136
149
  }
137
150
  catch (err) {
138
151
  if (reattempt < ENTRY_POINT_CONNECTION_ATTEMPTS) {
139
152
  const error = `Failed to connect to entrypoint with id ${(0, utils_1.binaryToHex)(entryPoint.kademliaId)} `
140
- + `and URL ${(0, exports.connectivityMethodToWebSocketUrl)(entryPoint.websocket)}`;
153
+ + `and URL ${(0, exports.connectivityMethodToWebsocketUrl)(entryPoint.websocket)}`;
141
154
  logger.error(error, { error: err });
142
155
  await (0, utils_1.wait)(2000);
143
156
  }
144
157
  }
145
158
  }
146
- throw Error(`Failed to connect to the entrypoints after ${ENTRY_POINT_CONNECTION_ATTEMPTS} attempts`);
159
+ throw new errors_1.WebsocketServerStartError(`Failed to connect to the entrypoints after ${ENTRY_POINT_CONNECTION_ATTEMPTS} attempts`);
147
160
  }
148
161
  isPossibleToFormConnection(targetPeerDescriptor) {
149
- if (this.ownPeerDescriptor.websocket !== undefined) {
150
- return (targetPeerDescriptor.type !== DhtRpc_1.NodeType.BROWSER) || canOpenConnectionFromBrowser(this.ownPeerDescriptor.websocket);
151
- }
152
- else if (targetPeerDescriptor.websocket !== undefined) {
153
- return (this.ownPeerDescriptor.type !== DhtRpc_1.NodeType.BROWSER) || canOpenConnectionFromBrowser(targetPeerDescriptor.websocket);
154
- }
155
- else {
156
- return false;
157
- }
162
+ const connectionType = (0, Connectivity_1.expectedConnectionType)(this.localPeerDescriptor, targetPeerDescriptor);
163
+ return (connectionType === IConnection_1.ConnectionType.WEBSOCKET_CLIENT || connectionType === IConnection_1.ConnectionType.WEBSOCKET_SERVER);
158
164
  }
159
165
  connect(targetPeerDescriptor) {
160
166
  const peerKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor);
@@ -162,13 +168,13 @@ class WebSocketConnectorRpcLocal {
162
168
  if (existingConnection) {
163
169
  return existingConnection;
164
170
  }
165
- if (this.ownPeerDescriptor.websocket && !targetPeerDescriptor.websocket) {
166
- return this.requestConnectionFromPeer(this.ownPeerDescriptor, targetPeerDescriptor);
171
+ if (this.localPeerDescriptor.websocket && !targetPeerDescriptor.websocket) {
172
+ return this.requestConnectionFromPeer(this.localPeerDescriptor, targetPeerDescriptor);
167
173
  }
168
174
  else {
169
- const socket = new ClientWebSocket_1.ClientWebSocket();
170
- const url = (0, exports.connectivityMethodToWebSocketUrl)(targetPeerDescriptor.websocket);
171
- const managedConnection = new ManagedConnection_1.ManagedConnection(this.ownPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_CLIENT, socket, undefined);
175
+ const socket = new ClientWebsocket_1.ClientWebsocket();
176
+ const url = (0, exports.connectivityMethodToWebsocketUrl)(targetPeerDescriptor.websocket);
177
+ const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_CLIENT, socket, undefined);
172
178
  managedConnection.setPeerDescriptor(targetPeerDescriptor);
173
179
  this.connectingConnections.set((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor), managedConnection);
174
180
  const delFunc = () => {
@@ -184,51 +190,51 @@ class WebSocketConnectorRpcLocal {
184
190
  return managedConnection;
185
191
  }
186
192
  }
187
- requestConnectionFromPeer(ownPeerDescriptor, targetPeerDescriptor) {
193
+ requestConnectionFromPeer(localPeerDescriptor, targetPeerDescriptor) {
188
194
  setImmediate(() => {
189
- const remoteConnector = new WebSocketConnectorRpcRemote_1.WebSocketConnectorRpcRemote(ownPeerDescriptor, targetPeerDescriptor, (0, proto_rpc_1.toProtoRpcClient)(new DhtRpc_client_1.WebSocketConnectorRpcClient(this.rpcCommunicator.getRpcClientTransport())));
190
- remoteConnector.requestConnection(ownPeerDescriptor.websocket.host, ownPeerDescriptor.websocket.port);
195
+ const remoteConnector = new WebsocketConnectorRpcRemote_1.WebsocketConnectorRpcRemote(localPeerDescriptor, targetPeerDescriptor, (0, proto_rpc_1.toProtoRpcClient)(new DhtRpc_client_1.WebsocketConnectorRpcClient(this.rpcCommunicator.getRpcClientTransport())));
196
+ remoteConnector.requestConnection(localPeerDescriptor.websocket.host, localPeerDescriptor.websocket.port);
191
197
  });
192
- const managedConnection = new ManagedConnection_1.ManagedConnection(this.ownPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_SERVER);
198
+ const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_SERVER);
193
199
  managedConnection.on('disconnected', () => this.ongoingConnectRequests.delete((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor)));
194
200
  managedConnection.setPeerDescriptor(targetPeerDescriptor);
195
201
  this.ongoingConnectRequests.set((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor), managedConnection);
196
202
  return managedConnection;
197
203
  }
198
- setOwnPeerDescriptor(ownPeerDescriptor) {
199
- this.ownPeerDescriptor = ownPeerDescriptor;
204
+ onServerSocketHandshakeRequest(peerDescriptor, serverWebsocket) {
205
+ const peerId = (0, peerIdFromPeerDescriptor_1.peerIdFromPeerDescriptor)(peerDescriptor);
206
+ if (this.ongoingConnectRequests.has(peerId.toKey())) {
207
+ const ongoingConnectReguest = this.ongoingConnectRequests.get(peerId.toKey());
208
+ ongoingConnectReguest.attachImplementation(serverWebsocket);
209
+ ongoingConnectReguest.acceptHandshake();
210
+ this.ongoingConnectRequests.delete(peerId.toKey());
211
+ }
212
+ else {
213
+ const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_SERVER, undefined, serverWebsocket);
214
+ managedConnection.setPeerDescriptor(peerDescriptor);
215
+ if (this.onIncomingConnection(managedConnection)) {
216
+ managedConnection.acceptHandshake();
217
+ }
218
+ else {
219
+ managedConnection.rejectHandshake('Duplicate connection');
220
+ managedConnection.destroy();
221
+ }
222
+ }
223
+ }
224
+ setLocalPeerDescriptor(localPeerDescriptor) {
225
+ this.localPeerDescriptor = localPeerDescriptor;
200
226
  }
201
227
  async destroy() {
202
- this.destroyed = true;
228
+ this.abortController.abort();
203
229
  this.rpcCommunicator.destroy();
204
230
  const requests = Array.from(this.ongoingConnectRequests.values());
205
- await Promise.allSettled(requests.map((conn) => conn.close('OTHER')));
231
+ await Promise.allSettled(requests.map((conn) => conn.close(false)));
206
232
  const attempts = Array.from(this.connectingConnections.values());
207
- await Promise.allSettled(attempts.map((conn) => conn.close('OTHER')));
233
+ await Promise.allSettled(attempts.map((conn) => conn.close(false)));
208
234
  this.connectivityChecker?.destroy();
209
- await this.webSocketServer?.stop();
210
- }
211
- // IWebSocketConnectorRpc implementation
212
- async requestConnection(request, context) {
213
- const senderPeerDescriptor = context.incomingSourceDescriptor;
214
- if (!this.destroyed && this.canConnectFunction(senderPeerDescriptor, request.ip, request.port)) {
215
- setImmediate(() => {
216
- if (this.destroyed) {
217
- return;
218
- }
219
- const connection = this.connect(senderPeerDescriptor);
220
- this.onIncomingConnection(connection);
221
- });
222
- const res = {
223
- accepted: true
224
- };
225
- return res;
226
- }
227
- return {
228
- accepted: false
229
- };
235
+ await this.websocketServer?.stop();
230
236
  }
231
237
  }
232
- exports.WebSocketConnectorRpcLocal = WebSocketConnectorRpcLocal;
233
- WebSocketConnectorRpcLocal.WEBSOCKET_CONNECTOR_SERVICE_ID = 'system/websocket-connector';
234
- //# sourceMappingURL=WebSocketConnectorRpcLocal.js.map
238
+ exports.WebsocketConnector = WebsocketConnector;
239
+ WebsocketConnector.WEBSOCKET_CONNECTOR_SERVICE_ID = 'system/websocket-connector';
240
+ //# sourceMappingURL=WebsocketConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebsocketConnector.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketConnector.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,gDAA4D;AAE5D,uFAAmF;AACnF,6EAAyE;AACzE,+EAA2E;AAC3E,mEAM+C;AAC/C,iFAA2F;AAC3F,0CAA0D;AAC1D,4DAAwD;AACxD,uDAAmD;AACnD,gEAA4D;AAC5D,4DAAyE;AAGzE,kDAAqD;AACrD,8CAA0C;AAC1C,qFAAwG;AAExG,mCAAsC;AAEtC,6DAAmE;AACnE,iDAAgE;AAChE,2EAAuE;AACvE,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAE1B,MAAM,gCAAgC,GAAG,CAAC,EAAsB,EAAU,EAAE;IAC/E,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC,IAAI,CAAA;AAClE,CAAC,CAAA;AAFY,QAAA,gCAAgC,oCAE5C;AAED,MAAM,+BAA+B,GAAG,CAAC,CAAA;AAiBzC,MAAa,kBAAkB;IAqB3B,YAAY,MAAgC;QAf3B,2BAAsB,GAAsC,IAAI,GAAG,EAAE,CAAA;QAY9E,0BAAqB,GAAsC,IAAI,GAAG,EAAE,CAAA;QACpE,oBAAe,GAAG,IAAI,eAAe,EAAE,CAAA;QAG3C,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,iCAAe,CAAC;YAC1D,SAAS,EAAE,MAAM,CAAC,SAAU;YAC5B,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,cAAc,EAAE,MAAM,CAAC,cAAc;Y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AAmB,GAAG,mBAAmB,CAAA;IAClD,CAAC;IAEM,KAAK,CAAC,OAAO;QAChB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;QAC5B,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;QAE9B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,CAAC,CAAA;QACjE,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAEnE,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC,CAAA;QAChE,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACnE,IAAI,CAAC,mBAAmB,EAAE,OAAO,EAAE,CAAA;QACnC,MAAM,IAAI,CAAC,eAAe,EAAE,IAAI,EAAE,CAAA;IACtC,CAAC;;AAzPL,gDA0PC;AAxP2B,iDAA8B,GAAG,4BAA4B,AAA/B,CAA+B"}
@@ -0,0 +1,17 @@
1
+ /// <reference types="node" />
2
+ import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
3
+ import { PeerDescriptor, WebsocketConnectionRequest, WebsocketConnectionResponse } from '../../proto/packages/dht/protos/DhtRpc';
4
+ import { IWebsocketConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server';
5
+ import { ManagedConnection } from '../ManagedConnection';
6
+ interface WebsocketConnectorRpcLocalConfig {
7
+ canConnect: (peerDescriptor: PeerDescriptor) => boolean;
8
+ connect: (targetPeerDescriptor: PeerDescriptor) => ManagedConnection;
9
+ onIncomingConnection: (connection: ManagedConnection) => boolean;
10
+ abortSignal: AbortSignal;
11
+ }
12
+ export declare class WebsocketConnectorRpcLocal implements IWebsocketConnectorRpc {
13
+ private readonly config;
14
+ constructor(config: WebsocketConnectorRpcLocalConfig);
15
+ requestConnection(_request: WebsocketConnectionRequest, context: ServerCallContext): Promise<WebsocketConnectionResponse>;
16
+ }
17
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebsocketConnectorRpcLocal = void 0;
4
+ class WebsocketConnectorRpcLocal {
5
+ constructor(config) {
6
+ this.config = config;
7
+ }
8
+ async requestConnection(_request, context) {
9
+ const senderPeerDescriptor = context.incomingSourceDescriptor;
10
+ if (this.config.canConnect(senderPeerDescriptor)) {
11
+ setImmediate(() => {
12
+ if (this.config.abortSignal.aborted) {
13
+ return;
14
+ }
15
+ const connection = this.config.connect(senderPeerDescriptor);
16
+ this.config.onIncomingConnection(connection);
17
+ });
18
+ return { accepted: true };
19
+ }
20
+ else {
21
+ return { accepted: false };
22
+ }
23
+ }
24
+ }
25
+ exports.WebsocketConnectorRpcLocal = WebsocketConnectorRpcLocal;
26
+ //# sourceMappingURL=WebsocketConnectorRpcLocal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebsocketConnectorRpcLocal.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketConnectorRpcLocal.ts"],"names":[],"mappings":";;;AAiBA,MAAa,0BAA0B;IAInC,YAAY,MAAwC;QAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,QAAoC,EAAE,OAA0B;QAC3F,MAAM,oBAAoB,GAAI,OAA0B,CAAC,wBAAyB,CAAA;QAClF,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE;YAC9C,YAAY,CAAC,GAAG,EAAE;gBACd,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE;oBACjC,OAAM;iBACT;gBACD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAA;gBAC5D,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAA;YAChD,CAAC,CAAC,CAAA;YACF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;SAC5B;aAAM;YACH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;SAC7B;IACL,CAAC;CACJ;AAvBD,gEAuBC"}
@@ -1,8 +1,8 @@
1
1
  import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
2
- import { IWebSocketConnectorRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client';
2
+ import { IWebsocketConnectorRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client';
3
3
  import { ProtoRpcClient } from '@streamr/proto-rpc';
4
4
  import { Remote } from '../../dht/contact/Remote';
5
- export declare class WebSocketConnectorRpcRemote extends Remote<IWebSocketConnectorRpcClient> {
6
- constructor(localPeerDescriptor: PeerDescriptor, remotePeerDescriptor: PeerDescriptor, client: ProtoRpcClient<IWebSocketConnectorRpcClient>);
5
+ export declare class WebsocketConnectorRpcRemote extends Remote<IWebsocketConnectorRpcClient> {
6
+ constructor(localPeerDescriptor: PeerDescriptor, remotePeerDescriptor: PeerDescriptor, client: ProtoRpcClient<IWebsocketConnectorRpcClient>);
7
7
  requestConnection(ip: string, port: number): Promise<boolean>;
8
8
  }