@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.
- package/dist/package.json +17 -18
- package/dist/src/connection/Connection.d.ts +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +5 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js +9 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +3 -2
- package/dist/src/connection/ConnectionLockRpcRemote.js +14 -3
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionLockStates.d.ts +5 -0
- package/dist/src/connection/ConnectionLockStates.js +14 -0
- package/dist/src/connection/ConnectionLockStates.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +8 -1
- package/dist/src/connection/ConnectionManager.js +96 -32
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectionsView.d.ts +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +1 -1
- package/dist/src/connection/Handshaker.d.ts +2 -2
- package/dist/src/connection/Handshaker.js +11 -7
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +7 -1
- package/dist/src/connection/ManagedConnection.js +41 -8
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/PendingConnection.d.ts +1 -1
- package/dist/src/connection/connectivityChecker.d.ts +1 -1
- package/dist/src/connection/connectivityChecker.js +22 -11
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.js +4 -4
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
- package/dist/src/connection/simulator/Simulator.d.ts +1 -1
- package/dist/src/connection/simulator/Simulator.js +5 -4
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +9 -9
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.js +4 -4
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorTransport.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorTransport.js +2 -1
- package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -1
- package/dist/src/connection/simulator/pings.d.ts +1 -1
- package/dist/src/connection/simulator/pings.js +3 -3
- package/dist/src/connection/simulator/pings.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +2 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +13 -8
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +2 -1
- package/dist/src/connection/webrtc/WebrtcConnector.js +28 -17
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +3 -3
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +4 -4
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +1 -1
- package/dist/src/connection/webrtc/iceServerAsString.js +1 -2
- package/dist/src/connection/webrtc/iceServerAsString.js.map +1 -1
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +0 -1
- package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnector.js +3 -3
- package/dist/src/connection/websocket/WebsocketClientConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +3 -4
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketServerConnection.d.ts +0 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.js +34 -24
- package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +5 -2
- package/dist/src/dht/DhtNode.js +20 -8
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +4 -4
- package/dist/src/dht/DhtNodeRpcLocal.js +3 -3
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +2 -2
- package/dist/src/dht/DhtNodeRpcRemote.js +3 -3
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +3 -2
- package/dist/src/dht/PeerManager.js +12 -11
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/Contact.d.ts +1 -1
- package/dist/src/dht/contact/Contact.js +1 -1
- package/dist/src/dht/contact/Contact.js.map +1 -1
- package/dist/src/dht/contact/RingContactList.d.ts +1 -1
- package/dist/src/dht/contact/RingContactList.js +1 -1
- package/dist/src/dht/contact/RingContactList.js.map +1 -1
- package/dist/src/dht/contact/RpcRemote.d.ts +1 -1
- package/dist/src/dht/contact/SortedContactList.js +2 -2
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/contact/ringIdentifiers.d.ts +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +1 -2
- package/dist/src/dht/discovery/DiscoverySession.js +3 -3
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +1 -2
- package/dist/src/dht/discovery/PeerDiscovery.js +7 -7
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.d.ts +0 -1
- package/dist/src/dht/discovery/RingDiscoverySession.js +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +8 -8
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +7 -7
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +2 -2
- package/dist/src/dht/routing/DuplicateDetector.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +4 -1
- package/dist/src/dht/routing/Router.js +17 -9
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +2 -2
- package/dist/src/dht/routing/RouterRpcLocal.js +5 -5
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +2 -2
- package/dist/src/dht/routing/RouterRpcRemote.js +7 -7
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +1 -1
- package/dist/src/dht/routing/RoutingSession.js +7 -8
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/RoutingTablesCache.d.ts +1 -1
- package/dist/src/dht/routing/getPreviousPeer.d.ts +1 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +1 -1
- package/dist/src/dht/store/LocalDataStore.js +3 -3
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +3 -3
- package/dist/src/dht/store/StoreManager.js +8 -8
- package/dist/src/dht/store/StoreManager.js.map +1 -1
- package/dist/src/dht/store/StoreRpcLocal.d.ts +4 -4
- package/dist/src/dht/store/StoreRpcLocal.js +4 -4
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.d.ts +3 -3
- package/dist/src/dht/store/StoreRpcRemote.js +7 -4
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +2 -2
- package/dist/src/exports.js +6 -6
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/AddressTools.js +2 -3
- package/dist/src/helpers/AddressTools.js.map +1 -1
- package/dist/src/helpers/Connectivity.d.ts +1 -1
- package/dist/src/helpers/Connectivity.js +1 -1
- package/dist/src/helpers/Connectivity.js.map +1 -1
- package/dist/src/helpers/createPeerDescriptor.d.ts +1 -1
- package/dist/src/helpers/createPeerDescriptor.js +2 -2
- package/dist/src/helpers/createPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +1 -1
- package/dist/src/helpers/debugHelpers.js +2 -2
- package/dist/src/helpers/debugHelpers.js.map +1 -1
- package/dist/src/helpers/protoClasses.d.ts +1 -1
- package/dist/src/helpers/protoClasses.js +1 -1
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/helpers/protoToString.js +1 -2
- package/dist/src/helpers/protoToString.js.map +1 -1
- package/dist/src/helpers/version.d.ts +1 -1
- package/dist/src/helpers/version.js +4 -4
- package/dist/src/helpers/version.js.map +1 -1
- package/dist/src/identifiers.d.ts +5 -5
- package/dist/src/identifiers.js +11 -11
- package/dist/src/identifiers.js.map +1 -1
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +1 -1
- package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +1 -1
- package/dist/src/transport/ITransport.d.ts +2 -1
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/ListeningRpcCommunicator.js +13 -4
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +1 -1
- package/eslint.config.mjs +12 -0
- package/jest.config.ts +12 -0
- package/package.json +17 -18
- package/proto.sh +2 -3
- package/protos/DhtRpc.proto +11 -4
- package/src/connection/Connection.ts +1 -1
- package/src/connection/ConnectionLockRpcLocal.ts +16 -7
- package/src/connection/ConnectionLockRpcRemote.ts +18 -6
- package/src/connection/ConnectionLockStates.ts +18 -0
- package/src/connection/ConnectionManager.ts +93 -27
- package/src/connection/ConnectionsView.ts +1 -1
- package/src/connection/ConnectorFacade.ts +1 -1
- package/src/connection/Handshaker.ts +18 -14
- package/src/connection/ManagedConnection.ts +28 -3
- package/src/connection/PendingConnection.ts +1 -1
- package/src/connection/connectivityChecker.ts +6 -5
- package/src/connection/connectivityRequestHandler.ts +4 -4
- package/src/connection/simulator/Simulator.ts +8 -7
- package/src/connection/simulator/SimulatorConnection.ts +10 -10
- package/src/connection/simulator/SimulatorConnector.ts +5 -5
- package/src/connection/simulator/SimulatorTransport.ts +3 -2
- package/src/connection/simulator/pings.ts +1 -1
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +10 -1
- package/src/connection/webrtc/NodeWebrtcConnection.ts +15 -11
- package/src/connection/webrtc/WebrtcConnector.ts +13 -11
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +8 -8
- package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +2 -2
- package/src/connection/websocket/WebsocketClientConnector.ts +5 -5
- package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +5 -5
- package/src/connection/websocket/WebsocketClientConnectorRpcRemote.ts +4 -4
- package/src/connection/websocket/WebsocketServerConnector.ts +24 -20
- package/src/dht/DhtNode.ts +29 -11
- package/src/dht/DhtNodeRpcLocal.ts +8 -8
- package/src/dht/DhtNodeRpcRemote.ts +5 -5
- package/src/dht/ExternalApiRpcLocal.ts +8 -8
- package/src/dht/ExternalApiRpcRemote.ts +6 -6
- package/src/dht/PeerManager.ts +16 -14
- package/src/dht/contact/Contact.ts +3 -3
- package/src/dht/contact/RingContactList.ts +3 -3
- package/src/dht/contact/RpcRemote.ts +1 -1
- package/src/dht/contact/SortedContactList.ts +3 -3
- package/src/dht/contact/ringIdentifiers.ts +1 -1
- package/src/dht/discovery/DiscoverySession.ts +5 -5
- package/src/dht/discovery/PeerDiscovery.ts +12 -12
- package/src/dht/discovery/RingDiscoverySession.ts +3 -3
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +10 -10
- package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +4 -4
- package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +6 -6
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +8 -8
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +5 -5
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.ts +2 -2
- package/src/dht/routing/DuplicateDetector.ts +1 -1
- package/src/dht/routing/Router.ts +19 -10
- package/src/dht/routing/RouterRpcLocal.ts +7 -7
- package/src/dht/routing/RouterRpcRemote.ts +9 -9
- package/src/dht/routing/RoutingSession.ts +9 -10
- package/src/dht/routing/RoutingTablesCache.ts +1 -1
- package/src/dht/routing/getPreviousPeer.ts +1 -1
- package/src/dht/store/LocalDataStore.ts +5 -5
- package/src/dht/store/StoreManager.ts +13 -13
- package/src/dht/store/StoreRpcLocal.ts +9 -9
- package/src/dht/store/StoreRpcRemote.ts +10 -7
- package/src/exports.ts +5 -5
- package/src/helpers/Connectivity.ts +1 -1
- package/src/helpers/createPeerDescriptor.ts +3 -3
- package/src/helpers/createPeerDescriptorSignaturePayload.ts +1 -1
- package/src/helpers/protoClasses.ts +2 -2
- package/src/helpers/version.ts +2 -2
- package/src/identifiers.ts +7 -7
- package/src/rpc-protocol/DhtCallContext.ts +1 -1
- package/src/rpc-protocol/DhtRpcOptions.ts +1 -1
- package/src/transport/ITransport.ts +2 -1
- package/src/transport/ListeningRpcCommunicator.ts +14 -6
- package/src/transport/RoutingRpcCommunicator.ts +2 -2
- package/test/benchmark/Find.test.ts +9 -9
- package/test/benchmark/KademliaCorrectness.test.ts +7 -7
- package/test/benchmark/RingCorrectness.test.ts +8 -8
- package/test/benchmark/SortedContactListBenchmark.test.ts +10 -10
- package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +3 -3
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +6 -6
- package/test/end-to-end/Layer0Webrtc.test.ts +6 -6
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +1 -1
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +3 -3
- package/test/end-to-end/memory-leak.test.ts +6 -6
- package/test/integration/ConnectionLocking.test.ts +48 -37
- package/test/integration/ConnectionManager.test.ts +62 -6
- package/test/integration/ConnectivityChecking.test.ts +3 -2
- package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
- package/test/integration/DhtNode.test.ts +6 -6
- package/test/integration/DhtNodeExternalAPI.test.ts +7 -7
- package/test/integration/DhtNodeRpcRemote.test.ts +9 -9
- package/test/integration/DhtRpc.test.ts +12 -13
- package/test/integration/Find.test.ts +5 -5
- package/test/integration/GeoIpConnectivityChecking.test.ts +8 -7
- package/test/integration/Layer1-scale.test.ts +3 -3
- package/test/integration/Mock-Layer1-Layer0.test.ts +6 -6
- package/test/integration/MultipleEntryPointJoining.test.ts +1 -1
- package/test/integration/ReplicateData.test.ts +10 -11
- package/test/integration/RouteMessage.test.ts +13 -13
- package/test/integration/RouterRpcRemote.test.ts +7 -7
- package/test/integration/SimultaneousConnections.test.ts +14 -13
- package/test/integration/Store.test.ts +9 -9
- package/test/integration/StoreAndDelete.test.ts +10 -10
- package/test/integration/StoreOnDhtWithThreeNodes.test.ts +10 -10
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +10 -10
- package/test/integration/StoreRpcRemote.test.ts +11 -11
- package/test/integration/WebrtcConnectionManagement.test.ts +4 -31
- package/test/integration/WebrtcConnectorRpc.test.ts +14 -14
- package/test/integration/Websocket.test.ts +0 -2
- package/test/integration/WebsocketClientConnectorRpc.test.ts +8 -8
- package/test/integration/WebsocketConnectionManagement.test.ts +11 -12
- package/test/integration/{rpc-connections-over-webrpc.test.ts → rpc-connections-over-webrtc.test.ts} +12 -46
- package/test/unit/AutoCertifierClientFacade.test.ts +6 -6
- package/test/unit/ConnectionManager.test.ts +4 -3
- package/test/unit/ConnectivityHelpers.test.ts +1 -1
- package/test/unit/DiscoverySession.test.ts +6 -6
- package/test/unit/Handshaker.test.ts +2 -2
- package/test/unit/ListeningRpcCommunicator.test.ts +52 -0
- package/test/unit/LocalDataStore.test.ts +21 -21
- package/test/unit/PeerManager.test.ts +15 -15
- package/test/unit/PendingConnection.test.ts +1 -1
- package/test/unit/ProtobufMessage.test.ts +1 -1
- package/test/unit/RandomContactList.test.ts +2 -2
- package/test/unit/RecursiveOperationManager.test.ts +3 -3
- package/test/unit/RecursiveOperationSession.test.ts +6 -6
- package/test/unit/Router.test.ts +6 -6
- package/test/unit/RoutingSession.test.ts +13 -6
- package/test/unit/SortedContactList.test.ts +8 -8
- package/test/unit/StoreManager.test.ts +12 -12
- package/test/unit/StoreRpcLocal.test.ts +9 -9
- package/test/unit/WebrtcConnection.test.ts +29 -0
- package/test/unit/WebsocketClientConnector.test.ts +1 -1
- package/test/unit/WebsocketServerConnector.test.ts +1 -1
- package/test/unit/connectivityRequestHandler.test.ts +6 -6
- package/test/unit/createPeerDescriptor.test.ts +4 -4
- package/test/unit/customMatchers.test.ts +18 -0
- package/test/unit/getClosestNodes.test.ts +5 -5
- package/test/unit/version.test.ts +9 -9
- package/test/utils/FakeConnectorFacade.ts +1 -1
- package/test/utils/FakeTransport.ts +12 -9
- package/test/utils/customMatchers.ts +9 -9
- package/test/utils/mock/MockConnectionsView.ts +1 -1
- package/test/utils/mock/MockRouter.ts +5 -1
- package/test/utils/mock/MockTransport.ts +6 -1
- package/test/utils/mock/mockDataEntry.ts +6 -6
- package/test/utils/topology.ts +3 -4
- package/test/utils/utils.ts +11 -11
- package/tsconfig.jest.json +2 -1
- package/tsconfig.node.json +1 -0
- package/.eslintignore +0 -5
- package/.eslintrc +0 -3
- package/dist/src/proto/google/protobuf/any.d.ts +0 -173
- package/dist/src/proto/google/protobuf/any.js +0 -155
- package/dist/src/proto/google/protobuf/any.js.map +0 -1
- package/dist/src/proto/google/protobuf/empty.d.ts +0 -32
- package/dist/src/proto/google/protobuf/empty.js +0 -32
- package/dist/src/proto/google/protobuf/empty.js.map +0 -1
- package/dist/src/proto/google/protobuf/timestamp.d.ts +0 -149
- package/dist/src/proto/google/protobuf/timestamp.js +0 -136
- package/dist/src/proto/google/protobuf/timestamp.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +0 -352
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +0 -278
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +0 -975
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +0 -661
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +0 -157
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js +0 -3
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +0 -1
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -87
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +0 -66
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js.map +0 -1
- package/dist/src/proto/tests.d.ts +0 -39
- package/dist/src/proto/tests.js +0 -34
- package/dist/src/proto/tests.js.map +0 -1
- package/jest.config.js +0 -5
- package/src/proto/google/protobuf/any.ts +0 -319
- package/src/proto/google/protobuf/empty.ts +0 -82
- package/src/proto/google/protobuf/timestamp.ts +0 -281
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +0 -407
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +0 -160
- package/src/proto/packages/dht/protos/DhtRpc.ts +0 -1244
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +0 -108
- package/src/proto/tests.ts +0 -52
- package/test/benchmark/any.test.ts +0 -28
- /package/{src/types/glogal.d.ts → test/types/global.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/helpers/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,KAAK,CAAA;AAE3C;;;;;;;GAOG;AACI,MAAM,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/helpers/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,KAAK,CAAA;AAE3C;;;;;;;GAOG;AACI,MAAM,+BAA+B,GAAG,CAAC,aAAqB,EAAW,EAAE;IAC9E,MAAM,UAAU,GAAG,IAAA,oBAAY,EAAC,8BAAsB,CAAE,CAAC,KAAK,CAAA;IAC9D,MAAM,WAAW,GAAG,IAAA,oBAAY,EAAC,aAAa,CAAC,EAAE,KAAK,CAAA;IACtD,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,EAAE,CAAC;QAC5D,OAAO,KAAK,CAAA;IAChB,CAAC;SAAM,CAAC;QACJ,sEAAsE;QACtE,OAAO,IAAI,CAAA;IACf,CAAC;AACL,CAAC,CAAA;AATY,QAAA,+BAA+B,mCAS3C;AAEM,MAAM,YAAY,GAAG,CAAC,OAAe,EAAgD,EAAE;IAC1F,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAChC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAChC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;QACjD,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,OAAO,SAAS,CAAA;IACpB,CAAC;AACL,CAAC,CAAA;AAVY,QAAA,YAAY,gBAUxB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BrandedString } from '@streamr/utils';
|
|
2
|
-
import { PeerDescriptor } from '
|
|
2
|
+
import { PeerDescriptor } from '../generated/packages/dht/protos/DhtRpc';
|
|
3
3
|
export declare const KADEMLIA_ID_LENGTH_IN_BYTES = 20;
|
|
4
4
|
export type DhtAddress = BrandedString<'DhtAddress'>;
|
|
5
5
|
export type DhtAddressRaw = Uint8Array;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
6
|
+
export declare const toDhtAddress: (raw: DhtAddressRaw) => DhtAddress;
|
|
7
|
+
export declare const toDhtAddressRaw: (address: DhtAddress) => DhtAddressRaw;
|
|
8
|
+
export declare const toNodeId: (peerDescriptor: PeerDescriptor) => DhtAddress;
|
|
9
9
|
export declare const areEqualPeerDescriptors: (peerDescriptor1: PeerDescriptor, peerDescriptor2: PeerDescriptor) => boolean;
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const randomDhtAddress: () => DhtAddress;
|
package/dist/src/identifiers.js
CHANGED
|
@@ -3,29 +3,29 @@ 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.
|
|
6
|
+
exports.randomDhtAddress = exports.areEqualPeerDescriptors = exports.toNodeId = exports.toDhtAddressRaw = exports.toDhtAddress = exports.KADEMLIA_ID_LENGTH_IN_BYTES = void 0;
|
|
7
7
|
const utils_1 = require("@streamr/utils");
|
|
8
8
|
const crypto_1 = __importDefault(require("crypto"));
|
|
9
9
|
// https://www.scs.stanford.edu/~dm/home/papers/kpos.pdf
|
|
10
10
|
exports.KADEMLIA_ID_LENGTH_IN_BYTES = 20;
|
|
11
|
-
const
|
|
11
|
+
const toDhtAddress = (raw) => {
|
|
12
12
|
return (0, utils_1.binaryToHex)(raw);
|
|
13
13
|
};
|
|
14
|
-
exports.
|
|
15
|
-
const
|
|
14
|
+
exports.toDhtAddress = toDhtAddress;
|
|
15
|
+
const toDhtAddressRaw = (address) => {
|
|
16
16
|
return (0, utils_1.hexToBinary)(address);
|
|
17
17
|
};
|
|
18
|
-
exports.
|
|
19
|
-
const
|
|
20
|
-
return (0, exports.
|
|
18
|
+
exports.toDhtAddressRaw = toDhtAddressRaw;
|
|
19
|
+
const toNodeId = (peerDescriptor) => {
|
|
20
|
+
return (0, exports.toDhtAddress)(peerDescriptor.nodeId);
|
|
21
21
|
};
|
|
22
|
-
exports.
|
|
22
|
+
exports.toNodeId = toNodeId;
|
|
23
23
|
const areEqualPeerDescriptors = (peerDescriptor1, peerDescriptor2) => {
|
|
24
24
|
return (0, utils_1.areEqualBinaries)(peerDescriptor1.nodeId, peerDescriptor2.nodeId);
|
|
25
25
|
};
|
|
26
26
|
exports.areEqualPeerDescriptors = areEqualPeerDescriptors;
|
|
27
|
-
const
|
|
28
|
-
return (0, exports.
|
|
27
|
+
const randomDhtAddress = () => {
|
|
28
|
+
return (0, exports.toDhtAddress)(crypto_1.default.randomBytes(exports.KADEMLIA_ID_LENGTH_IN_BYTES));
|
|
29
29
|
};
|
|
30
|
-
exports.
|
|
30
|
+
exports.randomDhtAddress = randomDhtAddress;
|
|
31
31
|
//# sourceMappingURL=identifiers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifiers.js","sourceRoot":"","sources":["../../src/identifiers.ts"],"names":[],"mappings":";;;;;;AAAA,0CAA0F;AAC1F,oDAA2B;AAG3B,wDAAwD;AAC3C,QAAA,2BAA2B,GAAG,EAAE,CAAA;AAKtC,MAAM,
|
|
1
|
+
{"version":3,"file":"identifiers.js","sourceRoot":"","sources":["../../src/identifiers.ts"],"names":[],"mappings":";;;;;;AAAA,0CAA0F;AAC1F,oDAA2B;AAG3B,wDAAwD;AAC3C,QAAA,2BAA2B,GAAG,EAAE,CAAA;AAKtC,MAAM,YAAY,GAAG,CAAC,GAAkB,EAAc,EAAE;IAC3D,OAAO,IAAA,mBAAW,EAAC,GAAG,CAA0B,CAAA;AACpD,CAAC,CAAA;AAFY,QAAA,YAAY,gBAExB;AAEM,MAAM,eAAe,GAAG,CAAC,OAAmB,EAAiB,EAAE;IAClE,OAAO,IAAA,mBAAW,EAAC,OAAO,CAA6B,CAAA;AAC3D,CAAC,CAAA;AAFY,QAAA,eAAe,mBAE3B;AAEM,MAAM,QAAQ,GAAG,CAAC,cAA8B,EAAc,EAAE;IACnE,OAAO,IAAA,oBAAY,EAAC,cAAc,CAAC,MAAM,CAAC,CAAA;AAC9C,CAAC,CAAA;AAFY,QAAA,QAAQ,YAEpB;AAEM,MAAM,uBAAuB,GAAG,CAAC,eAA+B,EAAE,eAA+B,EAAW,EAAE;IACjH,OAAO,IAAA,wBAAgB,EAAC,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;AAC3E,CAAC,CAAA;AAFY,QAAA,uBAAuB,2BAEnC;AAEM,MAAM,gBAAgB,GAAG,GAAe,EAAE;IAC7C,OAAO,IAAA,oBAAY,EAAC,gBAAM,CAAC,WAAW,CAAC,mCAA2B,CAAC,CAAC,CAAA;AACxE,CAAC,CAAA;AAFY,QAAA,gBAAgB,oBAE5B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProtoCallContext } from '@streamr/proto-rpc';
|
|
2
|
-
import { PeerDescriptor } from '
|
|
2
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc';
|
|
3
3
|
import { DhtRpcOptions } from './DhtRpcOptions';
|
|
4
4
|
export declare class DhtCallContext extends ProtoCallContext implements DhtRpcOptions {
|
|
5
5
|
targetDescriptor?: PeerDescriptor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProtoRpcOptions } from '@streamr/proto-rpc';
|
|
2
|
-
import { PeerDescriptor } from '
|
|
2
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc';
|
|
3
3
|
export interface DhtRpcOptions extends ProtoRpcOptions {
|
|
4
4
|
targetDescriptor?: PeerDescriptor;
|
|
5
5
|
sourceDescriptor?: PeerDescriptor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Message, PeerDescriptor } from '
|
|
1
|
+
import { Message, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc';
|
|
2
2
|
export interface TransportEvents {
|
|
3
3
|
disconnected: (peerDescriptor: PeerDescriptor, gracefulLeave: boolean) => void;
|
|
4
4
|
message: (message: Message) => void;
|
|
@@ -25,4 +25,5 @@ export interface ITransport {
|
|
|
25
25
|
send(msg: Message, opts?: SendOptions): Promise<void>;
|
|
26
26
|
getLocalPeerDescriptor(): PeerDescriptor;
|
|
27
27
|
stop(): void | Promise<void>;
|
|
28
|
+
getDiagnosticInfo(): Record<string, unknown>;
|
|
28
29
|
}
|
|
@@ -4,7 +4,8 @@ import { RpcCommunicatorOptions } from '@streamr/proto-rpc';
|
|
|
4
4
|
import { ServiceID } from '../types/ServiceID';
|
|
5
5
|
export declare class ListeningRpcCommunicator extends RoutingRpcCommunicator {
|
|
6
6
|
private readonly transport;
|
|
7
|
-
private readonly
|
|
7
|
+
private readonly messageListener;
|
|
8
|
+
private readonly disconnectedListener;
|
|
8
9
|
constructor(ownServiceId: ServiceID, transport: ITransport, options?: RpcCommunicatorOptions);
|
|
9
10
|
destroy(): void;
|
|
10
11
|
}
|
|
@@ -2,19 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ListeningRpcCommunicator = void 0;
|
|
4
4
|
const RoutingRpcCommunicator_1 = require("./RoutingRpcCommunicator");
|
|
5
|
+
const proto_rpc_1 = require("@streamr/proto-rpc");
|
|
6
|
+
const identifiers_1 = require("../identifiers");
|
|
5
7
|
class ListeningRpcCommunicator extends RoutingRpcCommunicator_1.RoutingRpcCommunicator {
|
|
6
8
|
transport;
|
|
7
|
-
|
|
9
|
+
messageListener;
|
|
10
|
+
disconnectedListener;
|
|
8
11
|
constructor(ownServiceId, transport, options) {
|
|
9
12
|
super(ownServiceId, (msg, opts) => transport.send(msg, opts), options);
|
|
10
|
-
this.
|
|
13
|
+
this.messageListener = (msg) => {
|
|
11
14
|
this.handleMessageFromPeer(msg);
|
|
12
15
|
};
|
|
16
|
+
this.disconnectedListener = (peerDescriptor) => {
|
|
17
|
+
const requests = this.getRequestIds((request) => (0, identifiers_1.areEqualPeerDescriptors)(peerDescriptor, request.getCallContext().targetDescriptor));
|
|
18
|
+
requests.forEach((id) => this.handleClientError(id, new proto_rpc_1.RpcError.Disconnected('Peer disconnected')));
|
|
19
|
+
};
|
|
13
20
|
this.transport = transport;
|
|
14
|
-
transport.on('message', this.
|
|
21
|
+
transport.on('message', this.messageListener);
|
|
22
|
+
transport.on('disconnected', this.disconnectedListener);
|
|
15
23
|
}
|
|
16
24
|
destroy() {
|
|
17
|
-
this.transport.off('message', this.
|
|
25
|
+
this.transport.off('message', this.messageListener);
|
|
26
|
+
this.transport.off('disconnected', this.disconnectedListener);
|
|
18
27
|
this.stop();
|
|
19
28
|
}
|
|
20
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListeningRpcCommunicator.js","sourceRoot":"","sources":["../../../src/transport/ListeningRpcCommunicator.ts"],"names":[],"mappings":";;;AACA,qEAAiE;
|
|
1
|
+
{"version":3,"file":"ListeningRpcCommunicator.js","sourceRoot":"","sources":["../../../src/transport/ListeningRpcCommunicator.ts"],"names":[],"mappings":";;;AACA,qEAAiE;AACjE,kDAAqE;AAGrE,gDAAwD;AAExD,MAAa,wBAAyB,SAAQ,+CAAsB;IAC/C,SAAS,CAAY;IACrB,eAAe,CAAwB;IACvC,oBAAoB,CAA0C;IAE/E,YAAY,YAAuB,EAAE,SAAqB,EAAE,OAAgC;QACxF,KAAK,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;QACtE,IAAI,CAAC,eAAe,GAAG,CAAC,GAAY,EAAE,EAAE;YACpC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;QACnC,CAAC,CAAA;QACD,IAAI,CAAC,oBAAoB,GAAG,CAAC,cAA8B,EAAE,EAAE;YAC3D,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,qCAAuB,EAAC,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,gBAAiB,CAAC,CAAC,CAAA;YACrI,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,EAAE,IAAI,oBAAQ,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAA;QACxG,CAAC,CAAA;QACD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,CAAA;QAC7C,SAAS,CAAC,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAA;IAC3D,CAAC;IAED,OAAO;QACH,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,CAAA;QACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAA;QAC7D,IAAI,CAAC,IAAI,EAAE,CAAA;IACf,CAAC;CACJ;AAxBD,4DAwBC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Message } from '
|
|
1
|
+
import { Message } from '../../generated/packages/dht/protos/DhtRpc';
|
|
2
2
|
import { RpcCommunicator, RpcCommunicatorOptions } from '@streamr/proto-rpc';
|
|
3
3
|
import { DhtCallContext } from '../rpc-protocol/DhtCallContext';
|
|
4
4
|
import { ServiceID } from '../types/ServiceID';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import baseConfig from '../../eslint.config.mjs'
|
|
2
|
+
|
|
3
|
+
export default [
|
|
4
|
+
{
|
|
5
|
+
// TODO remove when https://github.com/streamr-dev/network/pull/2848 merged to main
|
|
6
|
+
ignores: [
|
|
7
|
+
'src/connection/webrtc/BrowserWebrtcConnection.ts',
|
|
8
|
+
'src/connection/websocket/BrowserWebsocketClientConnection.ts'
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
...baseConfig
|
|
12
|
+
]
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Config } from '@jest/types'
|
|
2
|
+
import defaultConfig from '../../jest.config'
|
|
3
|
+
|
|
4
|
+
const config: Config.InitialOptions = {
|
|
5
|
+
...defaultConfig,
|
|
6
|
+
setupFilesAfterEnv: [
|
|
7
|
+
...defaultConfig.setupFilesAfterEnv,
|
|
8
|
+
'./test/utils/customMatchers.ts',
|
|
9
|
+
],
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default config
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/dht",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "102.0.0-beta.1",
|
|
4
4
|
"description": "Streamr Network DHT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"license": "STREAMR NETWORK OPEN SOURCE LICENSE",
|
|
13
13
|
"author": "Streamr Network AG <contact@streamr.network>",
|
|
14
14
|
"scripts": {
|
|
15
|
-
"
|
|
15
|
+
"prebuild": "./proto.sh",
|
|
16
16
|
"build": "tsc -b tsconfig.node.json",
|
|
17
17
|
"build-browser": "webpack --mode=development --progress",
|
|
18
|
-
"check": "tsc -p ./tsconfig.jest.json
|
|
18
|
+
"check": "tsc -p ./tsconfig.jest.json",
|
|
19
19
|
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
|
|
20
20
|
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
|
|
21
21
|
"test": "npm run test-unit && npm run test-integration && npm run test-end-to-end",
|
|
@@ -29,38 +29,37 @@
|
|
|
29
29
|
"@js-sdsl/ordered-map": "^4.4.2",
|
|
30
30
|
"@protobuf-ts/runtime": "^2.8.2",
|
|
31
31
|
"@protobuf-ts/runtime-rpc": "^2.8.2",
|
|
32
|
-
"@streamr/autocertifier-client": "
|
|
33
|
-
"@streamr/cdn-location": "
|
|
34
|
-
"@streamr/geoip-location": "
|
|
35
|
-
"@streamr/proto-rpc": "
|
|
36
|
-
"@streamr/utils": "
|
|
32
|
+
"@streamr/autocertifier-client": "102.0.0-beta.1",
|
|
33
|
+
"@streamr/cdn-location": "102.0.0-beta.1",
|
|
34
|
+
"@streamr/geoip-location": "102.0.0-beta.1",
|
|
35
|
+
"@streamr/proto-rpc": "102.0.0-beta.1",
|
|
36
|
+
"@streamr/utils": "102.0.0-beta.1",
|
|
37
37
|
"eventemitter3": "^5.0.0",
|
|
38
38
|
"heap": "^0.2.6",
|
|
39
39
|
"ipaddr.js": "^2.0.1",
|
|
40
40
|
"k-bucket": "^5.1.0",
|
|
41
41
|
"lodash": "^4.17.21",
|
|
42
|
-
"lru-cache": "11.0.
|
|
42
|
+
"lru-cache": "^11.0.2",
|
|
43
43
|
"node-datachannel": "^0.10.1",
|
|
44
44
|
"querystring": "0.2.1",
|
|
45
|
-
"uuid": "^
|
|
45
|
+
"uuid": "^11.0.5",
|
|
46
46
|
"websocket": "^1.0.34",
|
|
47
47
|
"ws": "^8.18.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@streamr/browser-test-runner": "^0.0.1",
|
|
51
|
-
"@streamr/test-utils": "
|
|
51
|
+
"@streamr/test-utils": "102.0.0-beta.1",
|
|
52
52
|
"@types/heap": "^0.2.34",
|
|
53
53
|
"@types/k-bucket": "^5.0.1",
|
|
54
|
-
"@types/lodash": "^4.17.
|
|
55
|
-
"@types/uuid": "^10.0.0",
|
|
54
|
+
"@types/lodash": "^4.17.14",
|
|
56
55
|
"@types/websocket": "^1.0.10",
|
|
57
|
-
"@types/ws": "^8.5.
|
|
56
|
+
"@types/ws": "^8.5.13",
|
|
58
57
|
"jest-leak-detector": "^27.3.1",
|
|
59
|
-
"jest-matcher-utils": "^29.
|
|
60
|
-
"ts-essentials": "^10.0.
|
|
58
|
+
"jest-matcher-utils": "^29.7.0",
|
|
59
|
+
"ts-essentials": "^10.0.4"
|
|
61
60
|
},
|
|
62
61
|
"optionalDependencies": {
|
|
63
|
-
"bufferutil": "^4.0.
|
|
64
|
-
"utf-8-validate": "^6.0.
|
|
62
|
+
"bufferutil": "^4.0.9",
|
|
63
|
+
"utf-8-validate": "^6.0.5"
|
|
65
64
|
}
|
|
66
65
|
}
|
package/proto.sh
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
mkdir -p ./
|
|
2
|
-
|
|
3
|
-
npx protoc --ts_out ./src/proto --ts_opt server_generic,generate_dependencies,long_type_number --proto_path ../.. packages/dht/protos/DhtRpc.proto
|
|
1
|
+
mkdir -p ./generated
|
|
2
|
+
npx protoc --ts_out ./generated --ts_opt server_generic,generate_dependencies,long_type_number --proto_path ../.. packages/dht/protos/DhtRpc.proto
|
package/protos/DhtRpc.proto
CHANGED
|
@@ -50,6 +50,7 @@ service ConnectionLockRpc {
|
|
|
50
50
|
rpc lockRequest (LockRequest) returns (LockResponse);
|
|
51
51
|
rpc unlockRequest (UnlockRequest) returns (google.protobuf.Empty);
|
|
52
52
|
rpc gracefulDisconnect (DisconnectNotice) returns (google.protobuf.Empty);
|
|
53
|
+
rpc setPrivate (SetPrivateRequest) returns (google.protobuf.Empty);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
service ExternalApiRpc {
|
|
@@ -214,7 +215,7 @@ message ConnectivityResponse {
|
|
|
214
215
|
string natType = 2;
|
|
215
216
|
ConnectivityMethod websocket = 3;
|
|
216
217
|
uint32 ipAddress = 4;
|
|
217
|
-
string
|
|
218
|
+
string protocolVersion = 5;
|
|
218
219
|
optional double latitude = 6;
|
|
219
220
|
optional double longitude = 7;
|
|
220
221
|
}
|
|
@@ -222,19 +223,21 @@ message ConnectivityResponse {
|
|
|
222
223
|
message HandshakeRequest {
|
|
223
224
|
PeerDescriptor sourcePeerDescriptor = 1;
|
|
224
225
|
optional PeerDescriptor targetPeerDescriptor = 2;
|
|
225
|
-
string
|
|
226
|
+
string protocolVersion = 3;
|
|
227
|
+
string applicationVersion = 4;
|
|
226
228
|
}
|
|
227
229
|
|
|
228
230
|
message HandshakeResponse {
|
|
229
231
|
PeerDescriptor sourcePeerDescriptor = 1;
|
|
230
232
|
optional HandshakeError error = 2;
|
|
231
|
-
string
|
|
233
|
+
string protocolVersion = 3;
|
|
234
|
+
string applicationVersion = 4;
|
|
232
235
|
}
|
|
233
236
|
|
|
234
237
|
enum HandshakeError {
|
|
235
238
|
DUPLICATE_CONNECTION = 0;
|
|
236
239
|
INVALID_TARGET_PEER_DESCRIPTOR = 1;
|
|
237
|
-
|
|
240
|
+
UNSUPPORTED_PROTOCOL_VERSION = 2;
|
|
238
241
|
}
|
|
239
242
|
|
|
240
243
|
// Wraps all messages
|
|
@@ -301,6 +304,10 @@ message DisconnectNotice {
|
|
|
301
304
|
DisconnectMode disconnectMode = 1;
|
|
302
305
|
}
|
|
303
306
|
|
|
307
|
+
message SetPrivateRequest {
|
|
308
|
+
bool isPrivate = 1;
|
|
309
|
+
}
|
|
310
|
+
|
|
304
311
|
message ExternalFetchDataRequest {
|
|
305
312
|
bytes key = 1;
|
|
306
313
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3'
|
|
2
|
-
import { PeerDescriptor } from '
|
|
2
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
3
3
|
import { ConnectionID, ConnectionType, ConnectionEvents } from './IConnection'
|
|
4
4
|
import { v4 as uuid } from 'uuid'
|
|
5
5
|
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
2
2
|
import { Logger } from '@streamr/utils'
|
|
3
|
-
import { Empty } from '
|
|
3
|
+
import { Empty } from '../../generated/google/protobuf/empty'
|
|
4
4
|
import {
|
|
5
5
|
DisconnectMode,
|
|
6
6
|
DisconnectNotice,
|
|
7
7
|
LockRequest,
|
|
8
8
|
LockResponse,
|
|
9
9
|
PeerDescriptor,
|
|
10
|
-
UnlockRequest
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
UnlockRequest,
|
|
11
|
+
SetPrivateRequest
|
|
12
|
+
} from '../../generated/packages/dht/protos/DhtRpc'
|
|
13
|
+
import { IConnectionLockRpc } from '../../generated/packages/dht/protos/DhtRpc.server'
|
|
13
14
|
import { DhtCallContext } from '../rpc-protocol/DhtCallContext'
|
|
14
15
|
import { getNodeIdOrUnknownFromPeerDescriptor } from './ConnectionManager'
|
|
15
16
|
import { LockID } from './ConnectionLockStates'
|
|
16
|
-
import { DhtAddress, areEqualPeerDescriptors,
|
|
17
|
+
import { DhtAddress, areEqualPeerDescriptors, toNodeId } from '../identifiers'
|
|
17
18
|
|
|
18
19
|
interface ConnectionLockRpcLocalOptions {
|
|
19
20
|
addRemoteLocked: (id: DhtAddress, lockId: LockID) => void
|
|
20
21
|
removeRemoteLocked: (id: DhtAddress, lockId: LockID) => void
|
|
21
22
|
closeConnection: (peerDescriptor: PeerDescriptor, gracefulLeave: boolean, reason?: string) => Promise<void>
|
|
22
23
|
getLocalPeerDescriptor: () => PeerDescriptor
|
|
24
|
+
setPrivate: (id: DhtAddress, isPrivate: boolean) => void
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
const logger = new Logger(module)
|
|
@@ -40,7 +42,7 @@ export class ConnectionLockRpcLocal implements IConnectionLockRpc {
|
|
|
40
42
|
}
|
|
41
43
|
return response
|
|
42
44
|
}
|
|
43
|
-
const remoteNodeId =
|
|
45
|
+
const remoteNodeId = toNodeId(senderPeerDescriptor)
|
|
44
46
|
this.options.addRemoteLocked(remoteNodeId, lockRequest.lockId)
|
|
45
47
|
const response: LockResponse = {
|
|
46
48
|
accepted: true
|
|
@@ -50,7 +52,7 @@ export class ConnectionLockRpcLocal implements IConnectionLockRpc {
|
|
|
50
52
|
|
|
51
53
|
async unlockRequest(unlockRequest: UnlockRequest, context: ServerCallContext): Promise<Empty> {
|
|
52
54
|
const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
53
|
-
const nodeId =
|
|
55
|
+
const nodeId = toNodeId(senderPeerDescriptor)
|
|
54
56
|
this.options.removeRemoteLocked(nodeId, unlockRequest.lockId)
|
|
55
57
|
return {}
|
|
56
58
|
}
|
|
@@ -66,4 +68,11 @@ export class ConnectionLockRpcLocal implements IConnectionLockRpc {
|
|
|
66
68
|
}
|
|
67
69
|
return {}
|
|
68
70
|
}
|
|
71
|
+
|
|
72
|
+
async setPrivate(request: SetPrivateRequest, context: ServerCallContext): Promise<Empty> {
|
|
73
|
+
const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
74
|
+
const senderId = toNodeId(senderPeerDescriptor)
|
|
75
|
+
this.options.setPrivate(senderId, request.isPrivate)
|
|
76
|
+
return {}
|
|
77
|
+
}
|
|
69
78
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Logger } from '@streamr/utils'
|
|
2
2
|
import { RpcRemote } from '../dht/contact/RpcRemote'
|
|
3
|
-
import { DisconnectMode, DisconnectNotice, LockRequest, UnlockRequest } from '
|
|
4
|
-
import { ConnectionLockRpcClient } from '
|
|
3
|
+
import { DisconnectMode, DisconnectNotice, LockRequest, UnlockRequest, SetPrivateRequest } from '../../generated/packages/dht/protos/DhtRpc'
|
|
4
|
+
import { ConnectionLockRpcClient } from '../../generated/packages/dht/protos/DhtRpc.client'
|
|
5
5
|
import { LockID } from './ConnectionLockStates'
|
|
6
|
-
import {
|
|
6
|
+
import { toNodeId } from '../identifiers'
|
|
7
7
|
|
|
8
8
|
const logger = new Logger(module)
|
|
9
9
|
|
|
10
10
|
export class ConnectionLockRpcRemote extends RpcRemote<ConnectionLockRpcClient> {
|
|
11
11
|
|
|
12
12
|
public async lockRequest(lockId: LockID): Promise<boolean> {
|
|
13
|
-
logger.trace(`Requesting locked connection to ${
|
|
13
|
+
logger.trace(`Requesting locked connection to ${toNodeId(this.getPeerDescriptor())}`)
|
|
14
14
|
const request: LockRequest = {
|
|
15
15
|
lockId
|
|
16
16
|
}
|
|
@@ -25,7 +25,7 @@ export class ConnectionLockRpcRemote extends RpcRemote<ConnectionLockRpcClient>
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
public unlockRequest(lockId: LockID): void {
|
|
28
|
-
logger.trace(`Requesting connection to be unlocked from ${
|
|
28
|
+
logger.trace(`Requesting connection to be unlocked from ${toNodeId(this.getPeerDescriptor())}`)
|
|
29
29
|
const request: UnlockRequest = {
|
|
30
30
|
lockId
|
|
31
31
|
}
|
|
@@ -38,7 +38,7 @@ export class ConnectionLockRpcRemote extends RpcRemote<ConnectionLockRpcClient>
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
public async gracefulDisconnect(disconnectMode: DisconnectMode): Promise<void> {
|
|
41
|
-
logger.trace(`Notifying a graceful disconnect to ${
|
|
41
|
+
logger.trace(`Notifying a graceful disconnect to ${toNodeId(this.getPeerDescriptor())}`)
|
|
42
42
|
const request: DisconnectNotice = {
|
|
43
43
|
disconnectMode
|
|
44
44
|
}
|
|
@@ -49,4 +49,16 @@ export class ConnectionLockRpcRemote extends RpcRemote<ConnectionLockRpcClient>
|
|
|
49
49
|
})
|
|
50
50
|
await this.getClient().gracefulDisconnect(request, options)
|
|
51
51
|
}
|
|
52
|
+
|
|
53
|
+
public async setPrivate(isPrivate: boolean): Promise<void> {
|
|
54
|
+
logger.trace(`Setting isPrivate: ${isPrivate} for ${toNodeId(this.getPeerDescriptor())}`)
|
|
55
|
+
const request: SetPrivateRequest = {
|
|
56
|
+
isPrivate
|
|
57
|
+
}
|
|
58
|
+
const options = this.formDhtRpcOptions({
|
|
59
|
+
connect: false,
|
|
60
|
+
notification: true
|
|
61
|
+
})
|
|
62
|
+
await this.getClient().setPrivate(request, options)
|
|
63
|
+
}
|
|
52
64
|
}
|
|
@@ -12,6 +12,8 @@ export class ConnectionLockStates {
|
|
|
12
12
|
// TODO: remove weakLocks use localLocks instead. When opening weakLocks from the ConnectioManager,
|
|
13
13
|
// simply do not send lock requests.
|
|
14
14
|
private weakLocks: Map<DhtAddress, Set<LockID>> = new Map()
|
|
15
|
+
// Used to filter proxy connections from the connections view
|
|
16
|
+
private remotePrivateConnections: Set<DhtAddress> = new Set()
|
|
15
17
|
|
|
16
18
|
public getLocalLockedConnectionCount(): number {
|
|
17
19
|
return this.localLocks.size
|
|
@@ -99,6 +101,22 @@ export class ConnectionLockStates {
|
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
|
|
104
|
+
public addPrivate(id: DhtAddress): void {
|
|
105
|
+
this.remotePrivateConnections.add(id)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public removePrivate(id: DhtAddress): void {
|
|
109
|
+
this.remotePrivateConnections.delete(id)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public getPrivateConnections(): Set<DhtAddress> {
|
|
113
|
+
return this.remotePrivateConnections
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public isPrivate(id: DhtAddress): boolean {
|
|
117
|
+
return this.remotePrivateConnections.has(id)
|
|
118
|
+
}
|
|
119
|
+
|
|
102
120
|
public clearAllLocks(id: DhtAddress): void {
|
|
103
121
|
this.localLocks.delete(id)
|
|
104
122
|
this.remoteLocks.delete(id)
|