@streamr/dht 0.0.1-tatum.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +5 -0
- package/.eslintrc +3 -0
- package/README.md +38 -0
- package/dist/src/connection/Connection.d.ts +11 -0
- package/dist/src/connection/Connection.js +23 -0
- package/dist/src/connection/Connection.js.map +1 -0
- package/dist/src/connection/ConnectionLockHandler.d.ts +23 -0
- package/dist/src/connection/ConnectionLockHandler.js +94 -0
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -0
- package/dist/src/connection/ConnectionManager.d.ts +94 -0
- package/dist/src/connection/ConnectionManager.js +554 -0
- package/dist/src/connection/ConnectionManager.js.map +1 -0
- package/dist/src/connection/ConnectivityChecker.d.ts +17 -0
- package/dist/src/connection/ConnectivityChecker.js +187 -0
- package/dist/src/connection/ConnectivityChecker.js.map +1 -0
- package/dist/src/connection/Handshaker.d.ts +19 -0
- package/dist/src/connection/Handshaker.js +77 -0
- package/dist/src/connection/Handshaker.js.map +1 -0
- package/dist/src/connection/IConnection.d.ts +38 -0
- package/dist/src/connection/IConnection.js +19 -0
- package/dist/src/connection/IConnection.js.map +1 -0
- package/dist/src/connection/IConnectionSource.d.ts +4 -0
- package/dist/src/connection/IConnectionSource.js +3 -0
- package/dist/src/connection/IConnectionSource.js.map +1 -0
- package/dist/src/connection/ManagedConnection.d.ts +60 -0
- package/dist/src/connection/ManagedConnection.js +352 -0
- package/dist/src/connection/ManagedConnection.js.map +1 -0
- package/dist/src/connection/ManagedWebRtcConnection.d.ts +7 -0
- package/dist/src/connection/ManagedWebRtcConnection.js +20 -0
- package/dist/src/connection/ManagedWebRtcConnection.js.map +1 -0
- package/dist/src/connection/RemoteConnectionLocker.d.ts +14 -0
- package/dist/src/connection/RemoteConnectionLocker.js +93 -0
- package/dist/src/connection/RemoteConnectionLocker.js.map +1 -0
- package/dist/src/connection/Simulator/Simulator.d.ts +42 -0
- package/dist/src/connection/Simulator/Simulator.js +325 -0
- package/dist/src/connection/Simulator/Simulator.js.map +1 -0
- package/dist/src/connection/Simulator/SimulatorConnection.d.ts +19 -0
- package/dist/src/connection/Simulator/SimulatorConnection.js +118 -0
- package/dist/src/connection/Simulator/SimulatorConnection.js.map +1 -0
- package/dist/src/connection/Simulator/SimulatorConnector.d.ts +17 -0
- package/dist/src/connection/Simulator/SimulatorConnector.js +72 -0
- package/dist/src/connection/Simulator/SimulatorConnector.js.map +1 -0
- package/dist/src/connection/Simulator/SimulatorTransport.d.ts +6 -0
- package/dist/src/connection/Simulator/SimulatorTransport.js +11 -0
- package/dist/src/connection/Simulator/SimulatorTransport.js.map +1 -0
- package/dist/src/connection/Simulator/pings.d.ts +21 -0
- package/dist/src/connection/Simulator/pings.js +61 -0
- package/dist/src/connection/Simulator/pings.js.map +1 -0
- package/dist/src/connection/WebRTC/IWebRtcConnection.d.ts +20 -0
- package/dist/src/connection/WebRTC/IWebRtcConnection.js +9 -0
- package/dist/src/connection/WebRTC/IWebRtcConnection.js.map +1 -0
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.d.ts +47 -0
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js +233 -0
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +1 -0
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.d.ts +12 -0
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.js +74 -0
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.js.map +1 -0
- package/dist/src/connection/WebRTC/WebRtcConnector.d.ts +47 -0
- package/dist/src/connection/WebRTC/WebRtcConnector.js +227 -0
- package/dist/src/connection/WebRTC/WebRtcConnector.js.map +1 -0
- package/dist/src/connection/WebRTC/iceServerAsString.d.ts +2 -0
- package/dist/src/connection/WebRTC/iceServerAsString.js +18 -0
- package/dist/src/connection/WebRTC/iceServerAsString.js.map +1 -0
- package/dist/src/connection/WebSocket/ClientWebSocket.d.ts +15 -0
- package/dist/src/connection/WebSocket/ClientWebSocket.js +113 -0
- package/dist/src/connection/WebSocket/ClientWebSocket.js.map +1 -0
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.d.ts +9 -0
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.js +63 -0
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.js.map +1 -0
- package/dist/src/connection/WebSocket/ServerWebSocket.d.ts +18 -0
- package/dist/src/connection/WebSocket/ServerWebSocket.js +103 -0
- package/dist/src/connection/WebSocket/ServerWebSocket.js.map +1 -0
- package/dist/src/connection/WebSocket/WebSocketConnector.d.ts +31 -0
- package/dist/src/connection/WebSocket/WebSocketConnector.js +202 -0
- package/dist/src/connection/WebSocket/WebSocketConnector.js.map +1 -0
- package/dist/src/connection/WebSocket/WebSocketServer.d.ts +9 -0
- package/dist/src/connection/WebSocket/WebSocketServer.js +101 -0
- package/dist/src/connection/WebSocket/WebSocketServer.js.map +1 -0
- package/dist/src/dht/DhtNode.d.ts +153 -0
- package/dist/src/dht/DhtNode.js +599 -0
- package/dist/src/dht/DhtNode.js.map +1 -0
- package/dist/src/dht/DhtPeer.d.ts +18 -0
- package/dist/src/dht/DhtPeer.js +74 -0
- package/dist/src/dht/DhtPeer.js.map +1 -0
- package/dist/src/dht/ExternalApi.d.ts +8 -0
- package/dist/src/dht/ExternalApi.js +26 -0
- package/dist/src/dht/ExternalApi.js.map +1 -0
- package/dist/src/dht/RemoteExternalApi.d.ts +6 -0
- package/dist/src/dht/RemoteExternalApi.js +26 -0
- package/dist/src/dht/RemoteExternalApi.js.map +1 -0
- package/dist/src/dht/contact/Contact.d.ts +22 -0
- package/dist/src/dht/contact/Contact.js +25 -0
- package/dist/src/dht/contact/Contact.js.map +1 -0
- package/dist/src/dht/contact/RandomContactList.d.ts +20 -0
- package/dist/src/dht/contact/RandomContactList.js +78 -0
- package/dist/src/dht/contact/RandomContactList.js.map +1 -0
- package/dist/src/dht/contact/Remote.d.ts +15 -0
- package/dist/src/dht/contact/Remote.js +24 -0
- package/dist/src/dht/contact/Remote.js.map +1 -0
- package/dist/src/dht/contact/SortedContactList.d.ts +35 -0
- package/dist/src/dht/contact/SortedContactList.js +156 -0
- package/dist/src/dht/contact/SortedContactList.js.map +1 -0
- package/dist/src/dht/discovery/DiscoverySession.d.ts +36 -0
- package/dist/src/dht/discovery/DiscoverySession.js +116 -0
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -0
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +42 -0
- package/dist/src/dht/discovery/PeerDiscovery.js +157 -0
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -0
- package/dist/src/dht/find/RecursiveFindSession.d.ts +46 -0
- package/dist/src/dht/find/RecursiveFindSession.js +142 -0
- package/dist/src/dht/find/RecursiveFindSession.js.map +1 -0
- package/dist/src/dht/find/RecursiveFinder.d.ts +54 -0
- package/dist/src/dht/find/RecursiveFinder.js +180 -0
- package/dist/src/dht/find/RecursiveFinder.js.map +1 -0
- package/dist/src/dht/find/RemoteRecursiveFindSession.d.ts +6 -0
- package/dist/src/dht/find/RemoteRecursiveFindSession.js +25 -0
- package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +1 -0
- package/dist/src/dht/routing/DuplicateDetector.d.ts +13 -0
- package/dist/src/dht/routing/DuplicateDetector.js +41 -0
- package/dist/src/dht/routing/DuplicateDetector.js.map +1 -0
- package/dist/src/dht/routing/RemoteRouter.d.ts +8 -0
- package/dist/src/dht/routing/RemoteRouter.js +106 -0
- package/dist/src/dht/routing/RemoteRouter.js.map +1 -0
- package/dist/src/dht/routing/Router.d.ts +60 -0
- package/dist/src/dht/routing/Router.js +207 -0
- package/dist/src/dht/routing/Router.js.map +1 -0
- package/dist/src/dht/routing/RoutingSession.d.ts +42 -0
- package/dist/src/dht/routing/RoutingSession.js +178 -0
- package/dist/src/dht/routing/RoutingSession.js.map +1 -0
- package/dist/src/dht/store/DataStore.d.ts +45 -0
- package/dist/src/dht/store/DataStore.js +244 -0
- package/dist/src/dht/store/DataStore.js.map +1 -0
- package/dist/src/dht/store/LocalDataStore.d.ts +19 -0
- package/dist/src/dht/store/LocalDataStore.js +104 -0
- package/dist/src/dht/store/LocalDataStore.js.map +1 -0
- package/dist/src/dht/store/RemoteStore.d.ts +8 -0
- package/dist/src/dht/store/RemoteStore.js +44 -0
- package/dist/src/dht/store/RemoteStore.js.map +1 -0
- package/dist/src/exports.d.ts +19 -0
- package/dist/src/exports.js +41 -0
- package/dist/src/exports.js.map +1 -0
- package/dist/src/helpers/AddressTools.d.ts +2 -0
- package/dist/src/helpers/AddressTools.js +31 -0
- package/dist/src/helpers/AddressTools.js.map +1 -0
- package/dist/src/helpers/PeerID.d.ts +25 -0
- package/dist/src/helpers/PeerID.js +84 -0
- package/dist/src/helpers/PeerID.js.map +1 -0
- package/dist/src/helpers/UUID.d.ts +7 -0
- package/dist/src/helpers/UUID.js +32 -0
- package/dist/src/helpers/UUID.js.map +1 -0
- package/dist/src/helpers/debugHelpers.d.ts +3 -0
- package/dist/src/helpers/debugHelpers.js +11 -0
- package/dist/src/helpers/debugHelpers.js.map +1 -0
- package/dist/src/helpers/errors.d.ts +72 -0
- package/dist/src/helpers/errors.js +95 -0
- package/dist/src/helpers/errors.js.map +1 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +5 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +17 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -0
- package/dist/src/helpers/protoClasses.d.ts +2 -0
- package/dist/src/helpers/protoClasses.js +35 -0
- package/dist/src/helpers/protoClasses.js.map +1 -0
- package/dist/src/helpers/protoToString.d.ts +2 -0
- package/dist/src/helpers/protoToString.js +20 -0
- package/dist/src/helpers/protoToString.js.map +1 -0
- package/dist/src/proto/google/protobuf/any.d.ts +173 -0
- package/dist/src/proto/google/protobuf/any.js +155 -0
- package/dist/src/proto/google/protobuf/any.js.map +1 -0
- package/dist/src/proto/google/protobuf/empty.d.ts +32 -0
- package/dist/src/proto/google/protobuf/empty.js +34 -0
- package/dist/src/proto/google/protobuf/empty.js.map +1 -0
- package/dist/src/proto/google/protobuf/timestamp.d.ts +149 -0
- package/dist/src/proto/google/protobuf/timestamp.js +136 -0
- package/dist/src/proto/google/protobuf/timestamp.js.map +1 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +320 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +245 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +1089 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +710 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +145 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js +3 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +1 -0
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.d.ts +87 -0
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +66 -0
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js.map +1 -0
- package/dist/src/proto/tests.d.ts +39 -0
- package/dist/src/proto/tests.js +34 -0
- package/dist/src/proto/tests.js.map +1 -0
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +12 -0
- package/dist/src/rpc-protocol/DhtCallContext.js +8 -0
- package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -0
- package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +8 -0
- package/dist/src/rpc-protocol/DhtRpcOptions.js +3 -0
- package/dist/src/rpc-protocol/DhtRpcOptions.js.map +1 -0
- package/dist/src/transport/ITransport.d.ts +22 -0
- package/dist/src/transport/ITransport.js +3 -0
- package/dist/src/transport/ITransport.js.map +1 -0
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +6 -0
- package/dist/src/transport/ListeningRpcCommunicator.js +14 -0
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -0
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +8 -0
- package/dist/src/transport/RoutingRpcCommunicator.js +52 -0
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -0
- package/jest.config.js +2 -0
- package/karma.config.js +20 -0
- package/package.json +64 -0
- package/proto.sh +3 -0
- package/protos/DhtRpc.proto +330 -0
- package/protos/tests.proto +16 -0
- package/src/connection/Connection.ts +23 -0
- package/src/connection/ConnectionLockHandler.ts +105 -0
- package/src/connection/ConnectionManager.ts +676 -0
- package/src/connection/ConnectivityChecker.ts +173 -0
- package/src/connection/Handshaker.ts +92 -0
- package/src/connection/IConnection.ts +47 -0
- package/src/connection/IConnectionSource.ts +6 -0
- package/src/connection/ManagedConnection.ts +398 -0
- package/src/connection/ManagedWebRtcConnection.ts +27 -0
- package/src/connection/RemoteConnectionLocker.ts +88 -0
- package/src/connection/Simulator/Simulator.ts +399 -0
- package/src/connection/Simulator/SimulatorConnection.ts +137 -0
- package/src/connection/Simulator/SimulatorConnector.ts +104 -0
- package/src/connection/Simulator/SimulatorTransport.ts +9 -0
- package/src/connection/Simulator/pings.ts +42 -0
- package/src/connection/WebRTC/BrowserWebRtcConnection.ts +227 -0
- package/src/connection/WebRTC/IWebRtcConnection.ts +24 -0
- package/src/connection/WebRTC/NodeWebRtcConnection.ts +256 -0
- package/src/connection/WebRTC/RemoteWebrtcConnector.ts +93 -0
- package/src/connection/WebRTC/WebRtcConnector.ts +306 -0
- package/src/connection/WebRTC/iceServerAsString.ts +15 -0
- package/src/connection/WebSocket/ClientWebSocket.ts +118 -0
- package/src/connection/WebSocket/RemoteWebSocketConnector.ts +49 -0
- package/src/connection/WebSocket/ServerWebSocket.ts +119 -0
- package/src/connection/WebSocket/WebSocketConnector.ts +264 -0
- package/src/connection/WebSocket/WebSocketServer.ts +97 -0
- package/src/dht/DhtNode.ts +776 -0
- package/src/dht/DhtPeer.ts +96 -0
- package/src/dht/ExternalApi.ts +29 -0
- package/src/dht/RemoteExternalApi.ts +25 -0
- package/src/dht/contact/Contact.ts +36 -0
- package/src/dht/contact/RandomContactList.ts +92 -0
- package/src/dht/contact/Remote.ts +40 -0
- package/src/dht/contact/SortedContactList.ts +196 -0
- package/src/dht/discovery/DiscoverySession.ts +150 -0
- package/src/dht/discovery/PeerDiscovery.ts +162 -0
- package/src/dht/find/RecursiveFindSession.ts +178 -0
- package/src/dht/find/RecursiveFinder.ts +272 -0
- package/src/dht/find/RemoteRecursiveFindSession.ts +33 -0
- package/src/dht/routing/DuplicateDetector.ts +53 -0
- package/src/dht/routing/RemoteRouter.ts +115 -0
- package/src/dht/routing/Router.ts +266 -0
- package/src/dht/routing/RoutingSession.ts +222 -0
- package/src/dht/store/DataStore.ts +321 -0
- package/src/dht/store/LocalDataStore.ts +114 -0
- package/src/dht/store/RemoteStore.ts +58 -0
- package/src/exports.ts +19 -0
- package/src/helpers/AddressTools.ts +26 -0
- package/src/helpers/PeerID.ts +95 -0
- package/src/helpers/UUID.ts +30 -0
- package/src/helpers/debugHelpers.ts +9 -0
- package/src/helpers/errors.ts +49 -0
- package/src/helpers/peerIdFromPeerDescriptor.ts +14 -0
- package/src/helpers/protoClasses.ts +63 -0
- package/src/helpers/protoToString.ts +21 -0
- package/src/proto/google/protobuf/any.ts +319 -0
- package/src/proto/google/protobuf/empty.ts +84 -0
- package/src/proto/google/protobuf/timestamp.ts +281 -0
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +373 -0
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +148 -0
- package/src/proto/packages/dht/protos/DhtRpc.ts +1399 -0
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +108 -0
- package/src/proto/tests.ts +52 -0
- package/src/rpc-protocol/DhtCallContext.ts +15 -0
- package/src/rpc-protocol/DhtRpcOptions.ts +9 -0
- package/src/transport/ITransport.ts +31 -0
- package/src/transport/ListeningRpcCommunicator.ts +14 -0
- package/src/transport/RoutingRpcCommunicator.ts +59 -0
- package/src/types/glogal.d.ts +1 -0
- package/src/types/textencoding.d.ts +7 -0
- package/test/RandomGraphSimulation.ts +52 -0
- package/test/benchmark/KademliaCorrectness.test.ts +115 -0
- package/test/benchmark/RecursiveFind.test.ts +87 -0
- package/test/benchmark/any.test.ts +28 -0
- package/test/benchmark/kademlia-simulation/Contact.ts +32 -0
- package/test/benchmark/kademlia-simulation/KademliaSimulation.ts +94 -0
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +125 -0
- package/test/data/generateGroundTruthData.ts +70 -0
- package/test/end-to-end/Layer0-Layer1.test.ts +87 -0
- package/test/end-to-end/Layer0.test.ts +60 -0
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +94 -0
- package/test/end-to-end/Layer0WebRTC-Layer1.test.ts +134 -0
- package/test/end-to-end/Layer0WebRTC.test.ts +98 -0
- package/test/end-to-end/Layer1-Scale-WebRTC.test.ts +69 -0
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +73 -0
- package/test/end-to-end/WebSocketConnectionRequest.test.ts +62 -0
- package/test/integration/ConnectionLocking.test.ts +166 -0
- package/test/integration/ConnectionManager.test.ts +291 -0
- package/test/integration/DhtNodeExternalAPI.test.ts +43 -0
- package/test/integration/DhtPeer.test.ts +73 -0
- package/test/integration/DhtRpc.test.ts +131 -0
- package/test/integration/DhtWithMockConnectionLatencies.test.ts +46 -0
- package/test/integration/DhtWithMockConnections.test.ts +46 -0
- package/test/integration/DhtWithRealConnectionLatencies.test.ts +47 -0
- package/test/integration/Layer1-scale.test.ts +200 -0
- package/test/integration/MigrateData.test.ts +203 -0
- package/test/integration/Mock-Layer1-Layer0.test.ts +106 -0
- package/test/integration/MultipleEntryPointJoining.test.ts +105 -0
- package/test/integration/RecursiveFind.test.ts +50 -0
- package/test/integration/RemoteRouter.test.ts +83 -0
- package/test/integration/RemoteStore.test.ts +66 -0
- package/test/integration/RouteMessage.test.ts +254 -0
- package/test/integration/RpcErrors.test.ts +153 -0
- package/test/integration/ScaleDownDht.test.ts +66 -0
- package/test/integration/SimultaneousConnections.test.ts +308 -0
- package/test/integration/Store.test.ts +72 -0
- package/test/integration/StoreAndDelete.test.ts +93 -0
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +71 -0
- package/test/integration/WebRtcConnectionManagement.test.ts +205 -0
- package/test/integration/WebRtcConnectorRpc.test.ts +145 -0
- package/test/integration/WebSocket.test.ts +64 -0
- package/test/integration/WebSocketConnectionManagement.test.ts +131 -0
- package/test/integration/WebSocketConnectorRpc.test.ts +86 -0
- package/test/kademlia-simulation/data/nodeids.json +13002 -0
- package/test/kademlia-simulation/data/orderedneighbors.json +1001 -0
- package/test/unit/AddressTools.test.ts +40 -0
- package/test/unit/DuplicateDetector.test.ts +29 -0
- package/test/unit/LocalDataStore.test.ts +107 -0
- package/test/unit/PeerID.test.ts +22 -0
- package/test/unit/ProtobufMessage.test.ts +21 -0
- package/test/unit/RandomContactList.test.ts +87 -0
- package/test/unit/RecursiveFinder.test.ts +112 -0
- package/test/unit/Router.test.ts +124 -0
- package/test/unit/SortedContactList.test.ts +127 -0
- package/test/unit/UUID.test.ts +49 -0
- package/test/unit/WebSocketServer.test.ts +42 -0
- package/test/utils/mock/RecursiveFinder.ts +19 -0
- package/test/utils/mock/Router.ts +53 -0
- package/test/utils/mock/Transport.ts +26 -0
- package/test/utils/utils.ts +311 -0
- package/tsconfig.browser.json +15 -0
- package/tsconfig.jest.json +19 -0
- package/tsconfig.json +3 -0
- package/tsconfig.node.json +18 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PeerID = void 0;
|
|
7
|
+
const UUID_1 = require("./UUID");
|
|
8
|
+
const errors_1 = require("./errors");
|
|
9
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
10
|
+
class PeerID {
|
|
11
|
+
constructor({ ip, value, stringValue } = {}) {
|
|
12
|
+
if (ip) {
|
|
13
|
+
this.data = new Uint8Array(20);
|
|
14
|
+
const ipNum = this.ip2Int(ip);
|
|
15
|
+
const view = new DataView(this.data.buffer);
|
|
16
|
+
view.setInt32(0, ipNum);
|
|
17
|
+
this.data.set((new UUID_1.UUID()).value, 4);
|
|
18
|
+
}
|
|
19
|
+
else if (value) {
|
|
20
|
+
this.data = new Uint8Array(value.slice(0));
|
|
21
|
+
}
|
|
22
|
+
else if (stringValue) {
|
|
23
|
+
const ab = PeerID.textEncoder.encode(stringValue); //toUTF8Array(stringValue)
|
|
24
|
+
this.data = ab;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
throw new errors_1.IllegalArguments('Constructor of PeerID must be given either ip, value or stringValue');
|
|
28
|
+
}
|
|
29
|
+
this.key = Buffer.from(this.data).toString('hex');
|
|
30
|
+
}
|
|
31
|
+
static fromIp(ip) {
|
|
32
|
+
return new PeerID({ ip });
|
|
33
|
+
}
|
|
34
|
+
static fromValue(value) {
|
|
35
|
+
return new PeerID({ value });
|
|
36
|
+
}
|
|
37
|
+
static fromKey(value) {
|
|
38
|
+
return new PeerID({ value: Buffer.from(value, 'hex') });
|
|
39
|
+
}
|
|
40
|
+
static fromString(stringValue) {
|
|
41
|
+
return new PeerID({ stringValue });
|
|
42
|
+
}
|
|
43
|
+
static generateRandom() {
|
|
44
|
+
// generate 160 bit random Uint8array
|
|
45
|
+
const value = new Uint8Array(20);
|
|
46
|
+
crypto_1.default.randomFillSync(value);
|
|
47
|
+
return new PeerID({ value });
|
|
48
|
+
}
|
|
49
|
+
// TODO convert to static method?
|
|
50
|
+
// eslint-disable-next-line class-methods-use-this
|
|
51
|
+
ip2Int(ip) {
|
|
52
|
+
return ip.split('.').map((octet, index, array) => {
|
|
53
|
+
return parseInt(octet) * Math.pow(256, (array.length - index - 1));
|
|
54
|
+
}).reduce((prev, curr) => {
|
|
55
|
+
return prev + curr;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
equals(other) {
|
|
59
|
+
return (Buffer.compare(this.data, other.value) === 0);
|
|
60
|
+
}
|
|
61
|
+
toString() {
|
|
62
|
+
return PeerID.textDecoder.decode(this.data); //utf8ArrayToString(this.data)
|
|
63
|
+
}
|
|
64
|
+
toKey() {
|
|
65
|
+
return this.key;
|
|
66
|
+
}
|
|
67
|
+
get value() {
|
|
68
|
+
return this.data;
|
|
69
|
+
}
|
|
70
|
+
hasSmallerHashThan(other) {
|
|
71
|
+
const myId = this.toKey();
|
|
72
|
+
const theirId = other.toKey();
|
|
73
|
+
return PeerID.offeringHash(myId + ',' + theirId) < PeerID.offeringHash(theirId + ',' + myId);
|
|
74
|
+
}
|
|
75
|
+
static offeringHash(idPair) {
|
|
76
|
+
const buffer = crypto_1.default.createHash('md5').update(idPair).digest();
|
|
77
|
+
return buffer.readInt32LE(0);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.PeerID = PeerID;
|
|
81
|
+
// avoid creating a new instance for every operation
|
|
82
|
+
PeerID.textEncoder = new TextEncoder();
|
|
83
|
+
PeerID.textDecoder = new TextDecoder();
|
|
84
|
+
//# sourceMappingURL=PeerID.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PeerID.js","sourceRoot":"","sources":["../../../src/helpers/PeerID.ts"],"names":[],"mappings":";;;;;;AACA,iCAA6B;AAC7B,qCAA2C;AAC3C,oDAA2B;AAI3B,MAAa,MAAM;IAQf,YAAsB,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,KAAgE,EAAE;QAC5G,IAAI,EAAE,EAAE;YACJ,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAA;YAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YAC7B,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,C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C,YAAY,CAAC,OAAO,GAAG,GAAG,GAAG,IAAI,CAAC,CAAA;IAChG,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,MAAc;QACtC,MAAM,MAAM,GAAG,gBAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAA;QAC/D,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;IAChC,CAAC;;AAtFL,wBAuFC;AAtFG,oDAAoD;AAC5B,kBAAW,GAAG,IAAI,WAAW,EAAE,CAAA;AAC/B,kBAAW,GAAG,IAAI,WAAW,EAAE,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UUID = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
class UUID {
|
|
6
|
+
constructor(other) {
|
|
7
|
+
if (!other) {
|
|
8
|
+
this.buf = new Uint8Array(16);
|
|
9
|
+
(0, uuid_1.v4)(null, this.buf);
|
|
10
|
+
}
|
|
11
|
+
else if (other.constructor === UUID) {
|
|
12
|
+
this.buf = other.buf;
|
|
13
|
+
}
|
|
14
|
+
else if (typeof other === 'string') {
|
|
15
|
+
this.buf = new Uint8Array((0, uuid_1.parse)(other));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.buf = other;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
toString() {
|
|
22
|
+
return (0, uuid_1.stringify)(this.buf);
|
|
23
|
+
}
|
|
24
|
+
equals(other) {
|
|
25
|
+
return (Buffer.compare(this.buf, other.value) === 0);
|
|
26
|
+
}
|
|
27
|
+
get value() {
|
|
28
|
+
return this.buf;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.UUID = UUID;
|
|
32
|
+
//# sourceMappingURL=UUID.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UUID.js","sourceRoot":"","sources":["../../../src/helpers/UUID.ts"],"names":[],"mappings":";;;AAAA,+BAA2C;AAE3C,MAAa,IAAI;IAGb,YAAY,KAAoC;QAC5C,IAAI,CAAC,KAAK,EAAE;YACR,IAAI,CAAC,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAA;YAC7B,IAAA,SAAE,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;SACrB;aAAM,IAAI,KAAK,CAAC,WAAW,KAAK,IAAI,EAAE;YACnC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAA;SACvB;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAClC,IAAI,CAAC,GAAG,GAAG,IAAI,UAAU,CAAC,IAAA,YAAK,EAAC,KAAK,CAAC,CAAC,CAAA;SAC1C;aAAM;YACH,IAAI,CAAC,GAAG,GAAG,KAAmB,CAAA;SACjC;IACL,CAAC;IAED,QAAQ;QACJ,OAAO,IAAA,gBAAS,EAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;IAED,MAAM,CAAC,KAAW;QACd,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IACxD,CAAC;IAED,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,GAAG,CAAA;IACnB,CAAC;CACJ;AA3BD,oBA2BC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logInfoIf = exports.debugVars = void 0;
|
|
4
|
+
exports.debugVars = [];
|
|
5
|
+
function logInfoIf(logger, condition, msg) {
|
|
6
|
+
if (condition) {
|
|
7
|
+
logger.info(msg);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.logInfoIf = logInfoIf;
|
|
11
|
+
//# sourceMappingURL=debugHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugHelpers.js","sourceRoot":"","sources":["../../../src/helpers/debugHelpers.ts"],"names":[],"mappings":";;;AAEa,QAAA,SAAS,GAAwB,EAAE,CAAA;AAEhD,SAAgB,SAAS,CAAC,MAAc,EAAE,SAAkB,EAAE,GAAW;IACrE,IAAI,SAAS,EAAE;QACX,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;KACnB;AACL,CAAC;AAJD,8BAIC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export declare enum ErrorCode {
|
|
2
|
+
CONNECTION_FAILED = "CONNECTION_FAILED",
|
|
3
|
+
COULD_NOT_ROUTE = "COULD_NOT_ROUTE",
|
|
4
|
+
STARTING_WEBSOCKET_SERVER_FAILED = "STARTING_WEBSOCKET_SERVER_FAILED",
|
|
5
|
+
WEBSOCKET_CONNECTION_REQUEST_REJECTED = "WEBSOCKET_CONNECTION_REQUEST_REJECTED",
|
|
6
|
+
COULD_NOT_START = "COULD_NOT_START",
|
|
7
|
+
COULD_NOT_STOP = "COULD_NOT_STOP",
|
|
8
|
+
CANNOT_CONNECT_TO_SELF = "CANNOT_CONNECT_TO_SELF",
|
|
9
|
+
NOT_IMPLEMENTED = "NOT_IMPLEMENTED",
|
|
10
|
+
ILLEGAL_RTC_PEER_CONNECTION_STATE = "ILLEGAL_RTC_PEER_CONNECTION_STATE",
|
|
11
|
+
ILLEGAL_ARGUMENTS = "ILLEGAL_ARGUMENTS",
|
|
12
|
+
CONNECTIVITY_RESPONSE_NOT_RECEIVED_BEFORE_TIMEOUT = "CONNECTIVITY_RESPONSE_NOT_RECEIVED_BEFORE_TIMEOUT",
|
|
13
|
+
CONNECTION_LOCKER = "CONNECTION_LOCKER",
|
|
14
|
+
DHT_JOIN_TIMEOUT = "DHT_JOIN_TIMEOUT",
|
|
15
|
+
SEND_FAILED = "SEND_FAILED",
|
|
16
|
+
GETTING_DATA_FAILED = "GETTING_DATA_FAILED",
|
|
17
|
+
CONNECTION_NOT_OPEN = "CONNECTION_NOT_OPEN"
|
|
18
|
+
}
|
|
19
|
+
declare class Err extends Error {
|
|
20
|
+
code: ErrorCode;
|
|
21
|
+
originalError?: Error | string;
|
|
22
|
+
constructor(code: ErrorCode, message?: string, originalError?: Error | string);
|
|
23
|
+
}
|
|
24
|
+
export declare class ConnectionFailed extends Err {
|
|
25
|
+
constructor(message?: string, originalError?: Error | string);
|
|
26
|
+
}
|
|
27
|
+
export declare class CouldNotRoute extends Err {
|
|
28
|
+
constructor(message?: string, originalError?: Error | string);
|
|
29
|
+
}
|
|
30
|
+
export declare class StartingWebSocketServerFailed extends Err {
|
|
31
|
+
constructor(message?: string, originalError?: Error | string);
|
|
32
|
+
}
|
|
33
|
+
export declare class WebSocketConnectionRequestRejected extends Err {
|
|
34
|
+
constructor(message?: string, originalError?: Error | string);
|
|
35
|
+
}
|
|
36
|
+
export declare class CouldNotStart extends Err {
|
|
37
|
+
constructor(message?: string, originalError?: Error | string);
|
|
38
|
+
}
|
|
39
|
+
export declare class CouldNotStop extends Err {
|
|
40
|
+
constructor(message?: string, originalError?: Error | string);
|
|
41
|
+
}
|
|
42
|
+
export declare class CannotConnectToSelf extends Err {
|
|
43
|
+
constructor(message?: string, originalError?: Error | string);
|
|
44
|
+
}
|
|
45
|
+
export declare class NotImplemented extends Err {
|
|
46
|
+
constructor(message?: string, originalError?: Error | string);
|
|
47
|
+
}
|
|
48
|
+
export declare class IllegalRTCPeerConnectionState extends Err {
|
|
49
|
+
constructor(message?: string, originalError?: Error | string);
|
|
50
|
+
}
|
|
51
|
+
export declare class IllegalArguments extends Err {
|
|
52
|
+
constructor(message?: string, originalError?: Error | string);
|
|
53
|
+
}
|
|
54
|
+
export declare class ConnectivityResponseTimeout extends Err {
|
|
55
|
+
constructor(message?: string, originalError?: Error | string);
|
|
56
|
+
}
|
|
57
|
+
export declare class ConnectionLocker extends Err {
|
|
58
|
+
constructor(message?: string, originalError?: Error | string);
|
|
59
|
+
}
|
|
60
|
+
export declare class DhtJoinTimeout extends Err {
|
|
61
|
+
constructor(message?: string, originalError?: Error | string);
|
|
62
|
+
}
|
|
63
|
+
export declare class SendFailed extends Err {
|
|
64
|
+
constructor(message?: string, originalError?: Error | string);
|
|
65
|
+
}
|
|
66
|
+
export declare class GettingDataFailed extends Err {
|
|
67
|
+
constructor(message?: string, originalError?: Error | string);
|
|
68
|
+
}
|
|
69
|
+
export declare class ConnectionNotOpen extends Err {
|
|
70
|
+
constructor(message?: string, originalError?: Error | string);
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable max-len */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ConnectionNotOpen = exports.GettingDataFailed = exports.SendFailed = exports.DhtJoinTimeout = exports.ConnectionLocker = exports.ConnectivityResponseTimeout = exports.IllegalArguments = exports.IllegalRTCPeerConnectionState = exports.NotImplemented = exports.CannotConnectToSelf = exports.CouldNotStop = exports.CouldNotStart = exports.WebSocketConnectionRequestRejected = exports.StartingWebSocketServerFailed = exports.CouldNotRoute = exports.ConnectionFailed = exports.ErrorCode = void 0;
|
|
5
|
+
var ErrorCode;
|
|
6
|
+
(function (ErrorCode) {
|
|
7
|
+
ErrorCode["CONNECTION_FAILED"] = "CONNECTION_FAILED";
|
|
8
|
+
ErrorCode["COULD_NOT_ROUTE"] = "COULD_NOT_ROUTE";
|
|
9
|
+
ErrorCode["STARTING_WEBSOCKET_SERVER_FAILED"] = "STARTING_WEBSOCKET_SERVER_FAILED";
|
|
10
|
+
ErrorCode["WEBSOCKET_CONNECTION_REQUEST_REJECTED"] = "WEBSOCKET_CONNECTION_REQUEST_REJECTED";
|
|
11
|
+
ErrorCode["COULD_NOT_START"] = "COULD_NOT_START";
|
|
12
|
+
ErrorCode["COULD_NOT_STOP"] = "COULD_NOT_STOP";
|
|
13
|
+
ErrorCode["CANNOT_CONNECT_TO_SELF"] = "CANNOT_CONNECT_TO_SELF";
|
|
14
|
+
ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
|
|
15
|
+
ErrorCode["ILLEGAL_RTC_PEER_CONNECTION_STATE"] = "ILLEGAL_RTC_PEER_CONNECTION_STATE";
|
|
16
|
+
ErrorCode["ILLEGAL_ARGUMENTS"] = "ILLEGAL_ARGUMENTS";
|
|
17
|
+
ErrorCode["CONNECTIVITY_RESPONSE_NOT_RECEIVED_BEFORE_TIMEOUT"] = "CONNECTIVITY_RESPONSE_NOT_RECEIVED_BEFORE_TIMEOUT";
|
|
18
|
+
ErrorCode["CONNECTION_LOCKER"] = "CONNECTION_LOCKER";
|
|
19
|
+
ErrorCode["DHT_JOIN_TIMEOUT"] = "DHT_JOIN_TIMEOUT";
|
|
20
|
+
ErrorCode["SEND_FAILED"] = "SEND_FAILED";
|
|
21
|
+
ErrorCode["GETTING_DATA_FAILED"] = "GETTING_DATA_FAILED";
|
|
22
|
+
ErrorCode["CONNECTION_NOT_OPEN"] = "CONNECTION_NOT_OPEN";
|
|
23
|
+
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
|
|
24
|
+
class Err extends Error {
|
|
25
|
+
constructor(code, message, originalError) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.code = code;
|
|
28
|
+
this.originalError = originalError;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
class ConnectionFailed extends Err {
|
|
32
|
+
constructor(message, originalError) { super(ErrorCode.CONNECTION_FAILED, message, originalError); }
|
|
33
|
+
}
|
|
34
|
+
exports.ConnectionFailed = ConnectionFailed;
|
|
35
|
+
class CouldNotRoute extends Err {
|
|
36
|
+
constructor(message, originalError) { super(ErrorCode.COULD_NOT_ROUTE, message, originalError); }
|
|
37
|
+
}
|
|
38
|
+
exports.CouldNotRoute = CouldNotRoute;
|
|
39
|
+
class StartingWebSocketServerFailed extends Err {
|
|
40
|
+
constructor(message, originalError) { super(ErrorCode.STARTING_WEBSOCKET_SERVER_FAILED, message, originalError); }
|
|
41
|
+
}
|
|
42
|
+
exports.StartingWebSocketServerFailed = StartingWebSocketServerFailed;
|
|
43
|
+
class WebSocketConnectionRequestRejected extends Err {
|
|
44
|
+
constructor(message, originalError) { super(ErrorCode.WEBSOCKET_CONNECTION_REQUEST_REJECTED, message, originalError); }
|
|
45
|
+
}
|
|
46
|
+
exports.WebSocketConnectionRequestRejected = WebSocketConnectionRequestRejected;
|
|
47
|
+
class CouldNotStart extends Err {
|
|
48
|
+
constructor(message, originalError) { super(ErrorCode.COULD_NOT_START, message, originalError); }
|
|
49
|
+
}
|
|
50
|
+
exports.CouldNotStart = CouldNotStart;
|
|
51
|
+
class CouldNotStop extends Err {
|
|
52
|
+
constructor(message, originalError) { super(ErrorCode.COULD_NOT_STOP, message, originalError); }
|
|
53
|
+
}
|
|
54
|
+
exports.CouldNotStop = CouldNotStop;
|
|
55
|
+
class CannotConnectToSelf extends Err {
|
|
56
|
+
constructor(message, originalError) { super(ErrorCode.CANNOT_CONNECT_TO_SELF, message, originalError); }
|
|
57
|
+
}
|
|
58
|
+
exports.CannotConnectToSelf = CannotConnectToSelf;
|
|
59
|
+
class NotImplemented extends Err {
|
|
60
|
+
constructor(message, originalError) { super(ErrorCode.NOT_IMPLEMENTED, message, originalError); }
|
|
61
|
+
}
|
|
62
|
+
exports.NotImplemented = NotImplemented;
|
|
63
|
+
class IllegalRTCPeerConnectionState extends Err {
|
|
64
|
+
constructor(message, originalError) { super(ErrorCode.ILLEGAL_RTC_PEER_CONNECTION_STATE, message, originalError); }
|
|
65
|
+
}
|
|
66
|
+
exports.IllegalRTCPeerConnectionState = IllegalRTCPeerConnectionState;
|
|
67
|
+
class IllegalArguments extends Err {
|
|
68
|
+
constructor(message, originalError) { super(ErrorCode.ILLEGAL_ARGUMENTS, message, originalError); }
|
|
69
|
+
}
|
|
70
|
+
exports.IllegalArguments = IllegalArguments;
|
|
71
|
+
class ConnectivityResponseTimeout extends Err {
|
|
72
|
+
constructor(message, originalError) { super(ErrorCode.CONNECTIVITY_RESPONSE_NOT_RECEIVED_BEFORE_TIMEOUT, message, originalError); }
|
|
73
|
+
}
|
|
74
|
+
exports.ConnectivityResponseTimeout = ConnectivityResponseTimeout;
|
|
75
|
+
class ConnectionLocker extends Err {
|
|
76
|
+
constructor(message, originalError) { super(ErrorCode.CONNECTION_LOCKER, message, originalError); }
|
|
77
|
+
}
|
|
78
|
+
exports.ConnectionLocker = ConnectionLocker;
|
|
79
|
+
class DhtJoinTimeout extends Err {
|
|
80
|
+
constructor(message, originalError) { super(ErrorCode.DHT_JOIN_TIMEOUT, message, originalError); }
|
|
81
|
+
}
|
|
82
|
+
exports.DhtJoinTimeout = DhtJoinTimeout;
|
|
83
|
+
class SendFailed extends Err {
|
|
84
|
+
constructor(message, originalError) { super(ErrorCode.SEND_FAILED, message, originalError); }
|
|
85
|
+
}
|
|
86
|
+
exports.SendFailed = SendFailed;
|
|
87
|
+
class GettingDataFailed extends Err {
|
|
88
|
+
constructor(message, originalError) { super(ErrorCode.GETTING_DATA_FAILED, message, originalError); }
|
|
89
|
+
}
|
|
90
|
+
exports.GettingDataFailed = GettingDataFailed;
|
|
91
|
+
class ConnectionNotOpen extends Err {
|
|
92
|
+
constructor(message, originalError) { super(ErrorCode.CONNECTION_NOT_OPEN, message, originalError); }
|
|
93
|
+
}
|
|
94
|
+
exports.ConnectionNotOpen = ConnectionNotOpen;
|
|
95
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/helpers/errors.ts"],"names":[],"mappings":";AAAA,4BAA4B;;;AAE5B,IAAY,SAiBX;AAjBD,WAAY,SAAS;IACjB,oDAAuC,CAAA;IACvC,gDAAmC,CAAA;IACnC,kFAAqE,CAAA;IACrE,4FAA+E,CAAA;IAC/E,gDAAmC,CAAA;IACnC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,SAAS,CAAC,iBAAiB,EAAE,OAAO,EAAE,aAAa,CAAC,CAAA,CAAC,CAAC;CAAE;AAA1K,4CAA0K;AAC1K,MAAa,cAAe,SAAQ,GAAG;IAAG,YAAY,OAAgB,EAAE,aAA8B,IAAI,KAAK,CAAC,SAAS,CAAC,gBAAgB,EAAE,OAAO,EAAE,aAAa,CAAC,CAAA,CAAC,CAAC;CAAE;AAAvK,wCAAuK;AACvK,MAAa,UAAW,SAAQ,GAAG;IAAG,YAAY,OAAgB,EAAE,aAA8B,IAAI,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,EAAE,aAAa,CAAC,CAAA,CAAC,CAAC;CAAE;AAA9J,gCAA8J;AAC9J,MAAa,iBAAkB,SAAQ,GAAG;IAAG,YAAY,OAAgB,EAAE,aAA8B,IAAI,KAAK,CAAC,SAAS,CAAC,mBAAmB,EAAE,OAAO,EAAE,aAAa,CAAC,CAAA,CAAC,CAAC;CAAE;AAA7K,8CAA6K;AAC7K,MAAa,iBAAkB,SAAQ,GAAG;IAAG,YAAa,OAAgB,EAAE,aAA8B,IAAI,KAAK,CAAC,SAAS,CAAC,mBAAmB,EAAE,OAAO,EAAE,aAAa,CAAC,CAAA,CAAC,CAAC;CAAE;AAA9K,8CAA8K"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc';
|
|
2
|
+
import { PeerID, PeerIDKey } from './PeerID';
|
|
3
|
+
export declare const peerIdFromPeerDescriptor: (peerDescriptor: PeerDescriptor) => PeerID;
|
|
4
|
+
export declare const keyFromPeerDescriptor: (peerDescriptor: PeerDescriptor) => PeerIDKey;
|
|
5
|
+
export declare const isSamePeerDescriptor: (peerDescriptor1: PeerDescriptor, peerDescriptor2: PeerDescriptor) => boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSamePeerDescriptor = exports.keyFromPeerDescriptor = exports.peerIdFromPeerDescriptor = void 0;
|
|
4
|
+
const PeerID_1 = require("./PeerID");
|
|
5
|
+
const peerIdFromPeerDescriptor = (peerDescriptor) => {
|
|
6
|
+
return PeerID_1.PeerID.fromValue(peerDescriptor.kademliaId);
|
|
7
|
+
};
|
|
8
|
+
exports.peerIdFromPeerDescriptor = peerIdFromPeerDescriptor;
|
|
9
|
+
const keyFromPeerDescriptor = (peerDescriptor) => {
|
|
10
|
+
return PeerID_1.PeerID.fromValue(peerDescriptor.kademliaId).toKey();
|
|
11
|
+
};
|
|
12
|
+
exports.keyFromPeerDescriptor = keyFromPeerDescriptor;
|
|
13
|
+
const isSamePeerDescriptor = (peerDescriptor1, peerDescriptor2) => {
|
|
14
|
+
return (0, exports.peerIdFromPeerDescriptor)(peerDescriptor1).equals((0, exports.peerIdFromPeerDescriptor)(peerDescriptor2));
|
|
15
|
+
};
|
|
16
|
+
exports.isSamePeerDescriptor = isSamePeerDescriptor;
|
|
17
|
+
//# sourceMappingURL=peerIdFromPeerDescriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peerIdFromPeerDescriptor.js","sourceRoot":"","sources":["../../../src/helpers/peerIdFromPeerDescriptor.ts"],"names":[],"mappings":";;;AACA,qCAA4C;AAErC,MAAM,wBAAwB,GAAG,CAAC,cAA8B,EAAU,EAAE;IAC/E,OAAO,eAAM,CAAC,SAAS,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;AACtD,CAAC,CAAA;AAFY,QAAA,wBAAwB,4BAEpC;AAEM,MAAM,qBAAqB,GAAG,CAAC,cAA8B,EAAa,EAAE;IAC/E,OAAO,eAAM,CAAC,SAAS,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,CAAA;AAC9D,CAAC,CAAA;AAFY,QAAA,qBAAqB,yBAEjC;AAEM,MAAM,oBAAoB,GAAG,CAAC,eAA+B,EAAE,eAA+B,EAAW,EAAE;IAC9G,OAAO,IAAA,gCAAwB,EAAC,eAAe,CAAC,CAAC,MAAM,CAAC,IAAA,gCAAwB,EAAC,eAAe,CAAC,CAAC,CAAA;AACtG,CAAC,CAAA;AAFY,QAAA,oBAAoB,wBAEhC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.protoClasses = void 0;
|
|
4
|
+
const DhtRpc_1 = require("../proto/packages/dht/protos/DhtRpc");
|
|
5
|
+
exports.protoClasses = [
|
|
6
|
+
DhtRpc_1.ClosestPeersRequest,
|
|
7
|
+
DhtRpc_1.ClosestPeersResponse,
|
|
8
|
+
DhtRpc_1.RecursiveFindRequest,
|
|
9
|
+
DhtRpc_1.RecursiveFindReport,
|
|
10
|
+
DhtRpc_1.PingRequest,
|
|
11
|
+
DhtRpc_1.PingResponse,
|
|
12
|
+
DhtRpc_1.LeaveNotice,
|
|
13
|
+
DhtRpc_1.PeerDescriptor,
|
|
14
|
+
DhtRpc_1.ConnectivityMethod,
|
|
15
|
+
DhtRpc_1.ConnectivityReportRequest,
|
|
16
|
+
DhtRpc_1.ConnectivityReportResponse,
|
|
17
|
+
DhtRpc_1.DisconnectNotice,
|
|
18
|
+
DhtRpc_1.RouteMessageWrapper,
|
|
19
|
+
DhtRpc_1.RouteMessageAck,
|
|
20
|
+
DhtRpc_1.ConnectivityRequest,
|
|
21
|
+
DhtRpc_1.ConnectivityResponse,
|
|
22
|
+
DhtRpc_1.HandshakeRequest,
|
|
23
|
+
DhtRpc_1.HandshakeResponse,
|
|
24
|
+
DhtRpc_1.Message,
|
|
25
|
+
DhtRpc_1.WebSocketConnectionRequest,
|
|
26
|
+
DhtRpc_1.WebSocketConnectionResponse,
|
|
27
|
+
DhtRpc_1.WebRtcConnectionRequest,
|
|
28
|
+
DhtRpc_1.RtcOffer,
|
|
29
|
+
DhtRpc_1.RtcAnswer,
|
|
30
|
+
DhtRpc_1.IceCandidate,
|
|
31
|
+
DhtRpc_1.LockRequest,
|
|
32
|
+
DhtRpc_1.UnlockRequest,
|
|
33
|
+
DhtRpc_1.LockResponse
|
|
34
|
+
];
|
|
35
|
+
//# sourceMappingURL=protoClasses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protoClasses.js","sourceRoot":"","sources":["../../../src/helpers/protoClasses.ts"],"names":[],"mappings":";;;AACA,gEA8B4C;AAE/B,QAAA,YAAY,GAA6B;IAClD,4BAAmB;IACnB,6BAAoB;IACpB,6BAAoB;IACpB,4BAAmB;IACnB,oBAAW;IACX,qBAAY;IACZ,oBAAW;IACX,uBAAc;IACd,2BAAkB;IAClB,kCAAyB;IACzB,mCAA0B;IAC1B,yBAAgB;IAChB,4BAAmB;IACnB,wBAAe;IACf,4BAAmB;IACnB,6BAAoB;IACpB,yBAAgB;IAChB,0BAAiB;IACjB,gBAAO;IACP,mCAA0B;IAC1B,oCAA2B;IAC3B,gCAAuB;IACvB,iBAAQ;IACR,kBAAS;IACT,qBAAY;IACZ,oBAAW;IACX,sBAAa;IACb,qBAAY;CACf,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.protoToString = void 0;
|
|
4
|
+
const protoClasses_1 = require("./protoClasses");
|
|
5
|
+
const proto_rpc_1 = require("@streamr/proto-rpc");
|
|
6
|
+
const typeRegistry = protoClasses_1.protoClasses.concat(proto_rpc_1.protoClasses);
|
|
7
|
+
function protoToString(protoObj, objectType) {
|
|
8
|
+
let ret = '';
|
|
9
|
+
try {
|
|
10
|
+
ret = objectType.toJsonString(protoObj, {
|
|
11
|
+
typeRegistry
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
catch (_e) {
|
|
15
|
+
ret = '[type not in type registry]';
|
|
16
|
+
}
|
|
17
|
+
return ret;
|
|
18
|
+
}
|
|
19
|
+
exports.protoToString = protoToString;
|
|
20
|
+
//# sourceMappingURL=protoToString.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protoToString.js","sourceRoot":"","sources":["../../../src/helpers/protoToString.ts"],"names":[],"mappings":";;;AAEA,iDAA6C;AAC7C,kDAAoE;AAEpE,MAAM,YAAY,GAAG,2BAAY,CAAC,MAAM,CAAC,wBAAe,CAAC,CAAA;AAEzD,SAAgB,aAAa,CAAsD,QAAW,EAC1F,UAAqB;IAErB,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,IAAI;QACA,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE;YACpC,YAAY;SACf,CAAC,CAAA;KACL;IAAC,OAAO,EAAE,EAAE;QACT,GAAG,GAAG,6BAA6B,CAAA;KACtC;IAED,OAAO,GAAG,CAAA;AACd,CAAC;AAbD,sCAaC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
|
2
|
+
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
|
3
|
+
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
|
4
|
+
import type { PartialMessage } from "@protobuf-ts/runtime";
|
|
5
|
+
import type { JsonValue } from "@protobuf-ts/runtime";
|
|
6
|
+
import type { JsonReadOptions } from "@protobuf-ts/runtime";
|
|
7
|
+
import type { JsonWriteOptions } from "@protobuf-ts/runtime";
|
|
8
|
+
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
|
9
|
+
import type { IMessageType } from "@protobuf-ts/runtime";
|
|
10
|
+
import { MessageType } from "@protobuf-ts/runtime";
|
|
11
|
+
/**
|
|
12
|
+
* `Any` contains an arbitrary serialized protocol buffer message along with a
|
|
13
|
+
* URL that describes the type of the serialized message.
|
|
14
|
+
*
|
|
15
|
+
* Protobuf library provides support to pack/unpack Any values in the form
|
|
16
|
+
* of utility functions or additional generated methods of the Any type.
|
|
17
|
+
*
|
|
18
|
+
* Example 1: Pack and unpack a message in C++.
|
|
19
|
+
*
|
|
20
|
+
* Foo foo = ...;
|
|
21
|
+
* Any any;
|
|
22
|
+
* any.PackFrom(foo);
|
|
23
|
+
* ...
|
|
24
|
+
* if (any.UnpackTo(&foo)) {
|
|
25
|
+
* ...
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* Example 2: Pack and unpack a message in Java.
|
|
29
|
+
*
|
|
30
|
+
* Foo foo = ...;
|
|
31
|
+
* Any any = Any.pack(foo);
|
|
32
|
+
* ...
|
|
33
|
+
* if (any.is(Foo.class)) {
|
|
34
|
+
* foo = any.unpack(Foo.class);
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* Example 3: Pack and unpack a message in Python.
|
|
38
|
+
*
|
|
39
|
+
* foo = Foo(...)
|
|
40
|
+
* any = Any()
|
|
41
|
+
* any.Pack(foo)
|
|
42
|
+
* ...
|
|
43
|
+
* if any.Is(Foo.DESCRIPTOR):
|
|
44
|
+
* any.Unpack(foo)
|
|
45
|
+
* ...
|
|
46
|
+
*
|
|
47
|
+
* Example 4: Pack and unpack a message in Go
|
|
48
|
+
*
|
|
49
|
+
* foo := &pb.Foo{...}
|
|
50
|
+
* any, err := ptypes.MarshalAny(foo)
|
|
51
|
+
* ...
|
|
52
|
+
* foo := &pb.Foo{}
|
|
53
|
+
* if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
|
54
|
+
* ...
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* The pack methods provided by protobuf library will by default use
|
|
58
|
+
* 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
|
59
|
+
* methods only use the fully qualified type name after the last '/'
|
|
60
|
+
* in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
|
61
|
+
* name "y.z".
|
|
62
|
+
*
|
|
63
|
+
*
|
|
64
|
+
* JSON
|
|
65
|
+
* ====
|
|
66
|
+
* The JSON representation of an `Any` value uses the regular
|
|
67
|
+
* representation of the deserialized, embedded message, with an
|
|
68
|
+
* additional field `@type` which contains the type URL. Example:
|
|
69
|
+
*
|
|
70
|
+
* package google.profile;
|
|
71
|
+
* message Person {
|
|
72
|
+
* string first_name = 1;
|
|
73
|
+
* string last_name = 2;
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* {
|
|
77
|
+
* "@type": "type.googleapis.com/google.profile.Person",
|
|
78
|
+
* "firstName": <string>,
|
|
79
|
+
* "lastName": <string>
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* If the embedded message type is well-known and has a custom JSON
|
|
83
|
+
* representation, that representation will be embedded adding a field
|
|
84
|
+
* `value` which holds the custom JSON in addition to the `@type`
|
|
85
|
+
* field. Example (for message [google.protobuf.Duration][]):
|
|
86
|
+
*
|
|
87
|
+
* {
|
|
88
|
+
* "@type": "type.googleapis.com/google.protobuf.Duration",
|
|
89
|
+
* "value": "1.212s"
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
*
|
|
93
|
+
* @generated from protobuf message google.protobuf.Any
|
|
94
|
+
*/
|
|
95
|
+
export interface Any {
|
|
96
|
+
/**
|
|
97
|
+
* A URL/resource name that uniquely identifies the type of the serialized
|
|
98
|
+
* protocol buffer message. This string must contain at least
|
|
99
|
+
* one "/" character. The last segment of the URL's path must represent
|
|
100
|
+
* the fully qualified name of the type (as in
|
|
101
|
+
* `path/google.protobuf.Duration`). The name should be in a canonical form
|
|
102
|
+
* (e.g., leading "." is not accepted).
|
|
103
|
+
*
|
|
104
|
+
* In practice, teams usually precompile into the binary all types that they
|
|
105
|
+
* expect it to use in the context of Any. However, for URLs which use the
|
|
106
|
+
* scheme `http`, `https`, or no scheme, one can optionally set up a type
|
|
107
|
+
* server that maps type URLs to message definitions as follows:
|
|
108
|
+
*
|
|
109
|
+
* * If no scheme is provided, `https` is assumed.
|
|
110
|
+
* * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
|
111
|
+
* value in binary format, or produce an error.
|
|
112
|
+
* * Applications are allowed to cache lookup results based on the
|
|
113
|
+
* URL, or have them precompiled into a binary to avoid any
|
|
114
|
+
* lookup. Therefore, binary compatibility needs to be preserved
|
|
115
|
+
* on changes to types. (Use versioned type names to manage
|
|
116
|
+
* breaking changes.)
|
|
117
|
+
*
|
|
118
|
+
* Note: this functionality is not currently available in the official
|
|
119
|
+
* protobuf release, and it is not used for type URLs beginning with
|
|
120
|
+
* type.googleapis.com.
|
|
121
|
+
*
|
|
122
|
+
* Schemes other than `http`, `https` (or the empty scheme) might be
|
|
123
|
+
* used with implementation specific semantics.
|
|
124
|
+
*
|
|
125
|
+
*
|
|
126
|
+
* @generated from protobuf field: string type_url = 1;
|
|
127
|
+
*/
|
|
128
|
+
typeUrl: string;
|
|
129
|
+
/**
|
|
130
|
+
* Must be a valid serialized protocol buffer of the above specified type.
|
|
131
|
+
*
|
|
132
|
+
* @generated from protobuf field: bytes value = 2;
|
|
133
|
+
*/
|
|
134
|
+
value: Uint8Array;
|
|
135
|
+
}
|
|
136
|
+
declare class Any$Type extends MessageType<Any> {
|
|
137
|
+
constructor();
|
|
138
|
+
/**
|
|
139
|
+
* Pack the message into a new `Any`.
|
|
140
|
+
*
|
|
141
|
+
* Uses 'type.googleapis.com/full.type.name' as the type URL.
|
|
142
|
+
*/
|
|
143
|
+
pack<T extends object>(message: T, type: IMessageType<T>): Any;
|
|
144
|
+
/**
|
|
145
|
+
* Unpack the message from the `Any`.
|
|
146
|
+
*/
|
|
147
|
+
unpack<T extends object>(any: Any, type: IMessageType<T>, options?: Partial<BinaryReadOptions>): T;
|
|
148
|
+
/**
|
|
149
|
+
* Does the given `Any` contain a packed message of the given type?
|
|
150
|
+
*/
|
|
151
|
+
contains(any: Any, type: IMessageType<any> | string): boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Convert the message to canonical JSON value.
|
|
154
|
+
*
|
|
155
|
+
* You have to provide the `typeRegistry` option so that the
|
|
156
|
+
* packed message can be converted to JSON.
|
|
157
|
+
*
|
|
158
|
+
* The `typeRegistry` option is also required to read
|
|
159
|
+
* `google.protobuf.Any` from JSON format.
|
|
160
|
+
*/
|
|
161
|
+
internalJsonWrite(any: Any, options: JsonWriteOptions): JsonValue;
|
|
162
|
+
internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Any): Any;
|
|
163
|
+
typeNameToUrl(name: string): string;
|
|
164
|
+
typeUrlToName(url: string): string;
|
|
165
|
+
create(value?: PartialMessage<Any>): Any;
|
|
166
|
+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Any): Any;
|
|
167
|
+
internalBinaryWrite(message: Any, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* @generated MessageType for protobuf message google.protobuf.Any
|
|
171
|
+
*/
|
|
172
|
+
export declare const Any: Any$Type;
|
|
173
|
+
export {};
|