@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,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isMaybeSupportedProtocolVersion } from '../../src/helpers/version'
|
|
2
2
|
|
|
3
3
|
describe('version', () => {
|
|
4
4
|
|
|
5
5
|
it('supported', () => {
|
|
6
|
-
expect(
|
|
7
|
-
expect(
|
|
8
|
-
expect(
|
|
9
|
-
expect(
|
|
6
|
+
expect(isMaybeSupportedProtocolVersion('1.0')).toBe(true)
|
|
7
|
+
expect(isMaybeSupportedProtocolVersion('1.1')).toBe(true)
|
|
8
|
+
expect(isMaybeSupportedProtocolVersion('2.0')).toBe(true)
|
|
9
|
+
expect(isMaybeSupportedProtocolVersion('3.5')).toBe(true)
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
it('not supported', () => {
|
|
13
|
-
expect(
|
|
14
|
-
expect(
|
|
15
|
-
expect(
|
|
16
|
-
expect(
|
|
13
|
+
expect(isMaybeSupportedProtocolVersion('')).toBe(false)
|
|
14
|
+
expect(isMaybeSupportedProtocolVersion('100.0.0-testnet-three.3')).toBe(false)
|
|
15
|
+
expect(isMaybeSupportedProtocolVersion('0.0')).toBe(false)
|
|
16
|
+
expect(isMaybeSupportedProtocolVersion('0.1')).toBe(false)
|
|
17
17
|
})
|
|
18
18
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PendingConnection } from '../../src/connection/PendingConnection'
|
|
2
2
|
import { DhtAddress } from '../../src/identifiers'
|
|
3
|
-
import { PeerDescriptor } from '../../
|
|
3
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { ITransport } from '../../src/transport/ITransport'
|
|
5
5
|
|
|
6
6
|
export class FakeConnectorFacade {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3'
|
|
2
|
-
import { DhtAddress,
|
|
3
|
-
import { Message, PeerDescriptor } from '../../
|
|
2
|
+
import { DhtAddress, toDhtAddress, toNodeId } from '../../src/identifiers'
|
|
3
|
+
import { Message, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { DEFAULT_SEND_OPTIONS, ITransport, SendOptions, TransportEvents } from '../../src/transport/ITransport'
|
|
5
5
|
import { ConnectionsView } from '../../src/exports'
|
|
6
6
|
|
|
@@ -22,8 +22,8 @@ class FakeTransport extends EventEmitter<TransportEvents> implements ITransport,
|
|
|
22
22
|
|
|
23
23
|
async send(msg: Message, opts?: SendOptions): Promise<void> {
|
|
24
24
|
const connect = opts?.connect ?? DEFAULT_SEND_OPTIONS.connect
|
|
25
|
-
const targetNodeId =
|
|
26
|
-
if (connect && !this.connections.some((c) =>
|
|
25
|
+
const targetNodeId = toNodeId(msg.targetDescriptor!)
|
|
26
|
+
if (connect && !this.connections.some((c) => toNodeId(c) === targetNodeId)) {
|
|
27
27
|
this.connect(msg.targetDescriptor!)
|
|
28
28
|
}
|
|
29
29
|
msg.sourceDescriptor = this.localPeerDescriptor
|
|
@@ -43,19 +43,22 @@ class FakeTransport extends EventEmitter<TransportEvents> implements ITransport,
|
|
|
43
43
|
return this.connections
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
// eslint-disable-next-line class-methods-use-this
|
|
47
46
|
getConnectionCount(): number {
|
|
48
47
|
return this.connections.length
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
// eslint-disable-next-line class-methods-use-this
|
|
52
50
|
hasConnection(nodeId: DhtAddress): boolean {
|
|
53
|
-
return this.connections.some((c) =>
|
|
51
|
+
return this.connections.some((c) => toNodeId(c) === nodeId)
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
// eslint-disable-next-line class-methods-use-this
|
|
57
55
|
stop(): void | Promise<void> {
|
|
58
56
|
}
|
|
57
|
+
|
|
58
|
+
// eslint-disable-next-line class-methods-use-this
|
|
59
|
+
getDiagnosticInfo(): Record<string, unknown> {
|
|
60
|
+
return {}
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
export class FakeEnvironment {
|
|
@@ -64,8 +67,8 @@ export class FakeEnvironment {
|
|
|
64
67
|
|
|
65
68
|
createTransport(peerDescriptor: PeerDescriptor): FakeTransport {
|
|
66
69
|
const transport = new FakeTransport(peerDescriptor, (msg) => {
|
|
67
|
-
const targetNode =
|
|
68
|
-
const targetTransport = this.transports.find((t) =>
|
|
70
|
+
const targetNode = toDhtAddress(msg.targetDescriptor!.nodeId)
|
|
71
|
+
const targetTransport = this.transports.find((t) => toNodeId(t.getLocalPeerDescriptor()) === targetNode)
|
|
69
72
|
if (targetTransport !== undefined) {
|
|
70
73
|
targetTransport.emit('message', msg)
|
|
71
74
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { areEqualBinaries } from '@streamr/utils'
|
|
2
2
|
import { printExpected, printReceived } from 'jest-matcher-utils'
|
|
3
3
|
import { isEqual } from 'lodash'
|
|
4
|
-
import { ConnectivityMethod, NodeType, PeerDescriptor } from '../../
|
|
5
|
-
import {
|
|
4
|
+
import { ConnectivityMethod, NodeType, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
|
+
import { toDhtAddress } from '../../src/identifiers'
|
|
6
6
|
|
|
7
7
|
// we could ES2015 module syntax (https://jestjs.io/docs/expect#expectextendmatchers),
|
|
8
8
|
// but the IDE doesn't find custom matchers if we do that
|
|
@@ -15,8 +15,8 @@ declare global {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const formErrorMessage = (
|
|
19
|
-
return
|
|
18
|
+
const formErrorMessage = (field: keyof PeerDescriptor, expected: string | number | undefined, actual: string | number | undefined): string => {
|
|
19
|
+
return `PeerDescriptor ${field} values don't match:\nExpected: ${printExpected(expected)}\nReceived: ${printReceived(actual)}`
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const toEqualPeerDescriptor = (
|
|
@@ -25,14 +25,14 @@ const toEqualPeerDescriptor = (
|
|
|
25
25
|
): jest.CustomMatcherResult => {
|
|
26
26
|
const messages: string[] = []
|
|
27
27
|
if (!areEqualBinaries(expected.nodeId, actual.nodeId)) {
|
|
28
|
-
messages.push(formErrorMessage('nodeId',
|
|
28
|
+
messages.push(formErrorMessage('nodeId', toDhtAddress(expected.nodeId), toDhtAddress(actual.nodeId)))
|
|
29
29
|
}
|
|
30
30
|
if (!isEqual(expected.type, actual.type)) {
|
|
31
31
|
const typeNames = { [NodeType.NODEJS]: 'NODEJS', [NodeType.BROWSER]: 'BROWSER' }
|
|
32
32
|
messages.push(formErrorMessage('type', typeNames[expected.type], typeNames[actual.type]))
|
|
33
33
|
}
|
|
34
34
|
expectEqualConnectivityMethod('udp', expected.udp, actual.udp, messages)
|
|
35
|
-
expectEqualConnectivityMethod('
|
|
35
|
+
expectEqualConnectivityMethod('tcp', expected.tcp, actual.tcp, messages)
|
|
36
36
|
expectEqualConnectivityMethod('websocket', expected.websocket, actual.websocket, messages)
|
|
37
37
|
if (expected.region !== actual.region) {
|
|
38
38
|
messages.push(formErrorMessage('region', expected?.region, actual?.region))
|
|
@@ -45,13 +45,13 @@ const toEqualPeerDescriptor = (
|
|
|
45
45
|
} else {
|
|
46
46
|
return {
|
|
47
47
|
pass: true,
|
|
48
|
-
message: () =>
|
|
48
|
+
message: () => 'PeerDescriptors are equal'
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const expectEqualConnectivityMethod = (
|
|
54
|
-
|
|
54
|
+
field: keyof PeerDescriptor,
|
|
55
55
|
method1: ConnectivityMethod | undefined,
|
|
56
56
|
method2: ConnectivityMethod | undefined,
|
|
57
57
|
messages: string[]
|
|
@@ -62,7 +62,7 @@ const expectEqualConnectivityMethod = (
|
|
|
62
62
|
: undefined
|
|
63
63
|
}
|
|
64
64
|
if (!isEqual(method1, method2)) {
|
|
65
|
-
messages.push(formErrorMessage(
|
|
65
|
+
messages.push(formErrorMessage(field, toOutput(method1), toOutput(method2)))
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Methods } from '@streamr/test-utils'
|
|
2
2
|
import { Router } from '../../../src/dht/routing/Router'
|
|
3
|
-
import { RouteMessageAck } from '../../../
|
|
3
|
+
import { RouteMessageAck } from '../../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
|
|
5
5
|
export class MockRouter implements Methods<Router> {
|
|
6
6
|
|
|
@@ -55,4 +55,8 @@ export class MockRouter implements Methods<Router> {
|
|
|
55
55
|
// eslint-disable-next-line class-methods-use-this
|
|
56
56
|
resetCache(): void {}
|
|
57
57
|
|
|
58
|
+
// eslint-disable-next-line class-methods-use-this
|
|
59
|
+
getDiagnosticInfo(): Record<string, unknown> {
|
|
60
|
+
return {}
|
|
61
|
+
}
|
|
58
62
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ITransport, TransportEvents } from '../../../src/transport/ITransport'
|
|
2
2
|
import { EventEmitter } from 'eventemitter3'
|
|
3
|
-
import { PeerDescriptor } from '../../../
|
|
3
|
+
import { PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
|
|
5
5
|
export class MockTransport extends EventEmitter<TransportEvents> implements ITransport {
|
|
6
6
|
|
|
@@ -18,4 +18,9 @@ export class MockTransport extends EventEmitter<TransportEvents> implements ITra
|
|
|
18
18
|
stop(): void {
|
|
19
19
|
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
// eslint-disable-next-line class-methods-use-this
|
|
23
|
+
getDiagnosticInfo(): Record<string, unknown> {
|
|
24
|
+
return {}
|
|
25
|
+
}
|
|
21
26
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MessageType as MessageType$, ScalarType } from '@protobuf-ts/runtime'
|
|
2
2
|
import { randomString } from '@streamr/utils'
|
|
3
|
-
import { Timestamp } from '../../../
|
|
4
|
-
import { Any } from '../../../
|
|
5
|
-
import { DataEntry } from '../../../
|
|
6
|
-
import { DhtAddress,
|
|
3
|
+
import { Timestamp } from '../../../generated/google/protobuf/timestamp'
|
|
4
|
+
import { Any } from '../../../generated/google/protobuf/any'
|
|
5
|
+
import { DataEntry } from '../../../generated/packages/dht/protos/DhtRpc'
|
|
6
|
+
import { DhtAddress, randomDhtAddress, toDhtAddressRaw } from '../../../src/identifiers'
|
|
7
7
|
import { omit } from 'lodash'
|
|
8
8
|
|
|
9
9
|
const MockData = new class extends MessageType$<{ foo: string }> {
|
|
@@ -18,9 +18,9 @@ export const createMockDataEntry = (
|
|
|
18
18
|
entry: Partial<Omit<DataEntry, 'key' | 'creator'> & { key: DhtAddress, creator: DhtAddress }> = {}
|
|
19
19
|
): DataEntry => {
|
|
20
20
|
return {
|
|
21
|
-
key:
|
|
21
|
+
key: toDhtAddressRaw(entry.key ?? randomDhtAddress()),
|
|
22
22
|
data: Any.pack({ foo: randomString(5) }, MockData),
|
|
23
|
-
creator:
|
|
23
|
+
creator: toDhtAddressRaw(entry.creator ?? randomDhtAddress()),
|
|
24
24
|
ttl: 10000,
|
|
25
25
|
stale: false,
|
|
26
26
|
deleted: false,
|
package/test/utils/topology.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Multimap } from '@streamr/utils'
|
|
2
|
-
import { DhtAddress,
|
|
2
|
+
import { DhtAddress, randomDhtAddress, toDhtAddressRaw } from '../../src/identifiers'
|
|
3
3
|
import { minBy, range, without } from 'lodash'
|
|
4
4
|
import { SortedContactList } from '../../src/dht/contact/SortedContactList'
|
|
5
5
|
import { getDistance } from '../../src/dht/PeerManager'
|
|
@@ -47,7 +47,7 @@ const getClosestNodes = (referenceId: DhtAddress, nodeIds: DhtAddress[], count:
|
|
|
47
47
|
*/
|
|
48
48
|
export const createTestTopology = (nodeCount: number, minNeighorCount: number): Multimap<DhtAddress, DhtAddress> => {
|
|
49
49
|
const topology: Multimap<DhtAddress, DhtAddress> = new Multimap()
|
|
50
|
-
const nodeIds = range(nodeCount).map(() =>
|
|
50
|
+
const nodeIds = range(nodeCount).map(() => randomDhtAddress())
|
|
51
51
|
for (const nodeId of nodeIds) {
|
|
52
52
|
const closestNodes = getClosestNodes(nodeId, nodeIds, minNeighorCount, false)
|
|
53
53
|
for (const closestNode of closestNodes) {
|
|
@@ -59,7 +59,6 @@ export const createTestTopology = (nodeCount: number, minNeighorCount: number):
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
// eslint-disable-next-line no-constant-condition
|
|
63
62
|
while (true) {
|
|
64
63
|
const partitions = getTopologyPartitions(topology)
|
|
65
64
|
if (partitions.length === 1) {
|
|
@@ -71,7 +70,7 @@ export const createTestTopology = (nodeCount: number, minNeighorCount: number):
|
|
|
71
70
|
const closestNodedId = getClosestNodes(nodeId, otherNodes, 1, false)[0]
|
|
72
71
|
return [nodeId, closestNodedId]
|
|
73
72
|
})
|
|
74
|
-
const mergePair = minBy(closestPairs, (pair) => getDistance(
|
|
73
|
+
const mergePair = minBy(closestPairs, (pair) => getDistance(toDhtAddressRaw(pair[0]), toDhtAddressRaw(pair[1])))!
|
|
75
74
|
topology.add(mergePair[0], mergePair[1])
|
|
76
75
|
topology.add(mergePair[1], mergePair[0])
|
|
77
76
|
}
|
package/test/utils/utils.ts
CHANGED
|
@@ -11,27 +11,27 @@ import {
|
|
|
11
11
|
StoreDataRequest,
|
|
12
12
|
StoreDataResponse,
|
|
13
13
|
ClosestRingPeersResponse
|
|
14
|
-
} from '../../
|
|
15
|
-
import { RpcMessage } from '../../
|
|
14
|
+
} from '../../generated/packages/dht/protos/DhtRpc'
|
|
15
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
16
16
|
import {
|
|
17
17
|
IDhtNodeRpc,
|
|
18
18
|
IRouterRpc,
|
|
19
19
|
IStoreRpc,
|
|
20
20
|
IWebsocketClientConnectorRpc
|
|
21
|
-
} from '../../
|
|
21
|
+
} from '../../generated/packages/dht/protos/DhtRpc.server'
|
|
22
22
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
23
23
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
24
24
|
import { v4 } from 'uuid'
|
|
25
25
|
import { getRandomRegion } from '../../src/connection/simulator/pings'
|
|
26
|
-
import { Empty } from '../../
|
|
27
|
-
import { Any } from '../../
|
|
28
|
-
import { wait,
|
|
26
|
+
import { Empty } from '../../generated/google/protobuf/empty'
|
|
27
|
+
import { Any } from '../../generated/google/protobuf/any'
|
|
28
|
+
import { wait, until } from '@streamr/utils'
|
|
29
29
|
import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
|
|
30
|
-
import { DhtAddress,
|
|
30
|
+
import { DhtAddress, randomDhtAddress, toDhtAddressRaw } from '../../src/identifiers'
|
|
31
31
|
|
|
32
32
|
export const createMockPeerDescriptor = (opts?: Partial<Omit<PeerDescriptor, 'nodeId'>>): PeerDescriptor => {
|
|
33
33
|
return {
|
|
34
|
-
nodeId:
|
|
34
|
+
nodeId: toDhtAddressRaw(randomDhtAddress()),
|
|
35
35
|
type: NodeType.NODEJS,
|
|
36
36
|
...opts
|
|
37
37
|
}
|
|
@@ -46,7 +46,7 @@ export const createMockRingNode = async (
|
|
|
46
46
|
const dhtJoinTimeout = 45000
|
|
47
47
|
|
|
48
48
|
const peerDescriptor: PeerDescriptor = {
|
|
49
|
-
nodeId:
|
|
49
|
+
nodeId: toDhtAddressRaw(nodeId ?? randomDhtAddress()),
|
|
50
50
|
type: NodeType.NODEJS,
|
|
51
51
|
region
|
|
52
52
|
//ipAddress: ipv4ToNumber(ipAddress)
|
|
@@ -80,7 +80,7 @@ export const createMockConnectionDhtNode = async (
|
|
|
80
80
|
dhtJoinTimeout = 45000
|
|
81
81
|
): Promise<DhtNode> => {
|
|
82
82
|
const peerDescriptor: PeerDescriptor = {
|
|
83
|
-
nodeId:
|
|
83
|
+
nodeId: toDhtAddressRaw(nodeId ?? randomDhtAddress()),
|
|
84
84
|
type: NodeType.NODEJS,
|
|
85
85
|
region: getRandomRegion()
|
|
86
86
|
}
|
|
@@ -258,7 +258,7 @@ export const waitForStableTopology = async (nodes: DhtNode[], maxConnectionCount
|
|
|
258
258
|
await Promise.all(connectionManagers.map(async (connectionManager) => {
|
|
259
259
|
connectionManager.garbageCollectConnections(maxConnectionCount, MAX_IDLE_TIME)
|
|
260
260
|
try {
|
|
261
|
-
await
|
|
261
|
+
await until(() => connectionManager.getConnections().length <= maxConnectionCount, waitTime)
|
|
262
262
|
} catch {
|
|
263
263
|
// the topology is very likely stable, but we can't be sure (maybe the node has more than maxConnectionCount
|
|
264
264
|
// locked connections and therefore it is ok to that garbage collector was not able to remove any of those
|
package/tsconfig.jest.json
CHANGED
package/tsconfig.node.json
CHANGED
package/.eslintignore
DELETED
package/.eslintrc
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
|
2
|
-
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
|
3
|
-
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
|
4
|
-
import type { PartialMessage } from "@protobuf-ts/runtime";
|
|
5
|
-
import type { JsonValue } from "@protobuf-ts/runtime";
|
|
6
|
-
import type { JsonReadOptions } from "@protobuf-ts/runtime";
|
|
7
|
-
import type { JsonWriteOptions } from "@protobuf-ts/runtime";
|
|
8
|
-
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
|
9
|
-
import type { IMessageType } from "@protobuf-ts/runtime";
|
|
10
|
-
import { MessageType } from "@protobuf-ts/runtime";
|
|
11
|
-
/**
|
|
12
|
-
* `Any` contains an arbitrary serialized protocol buffer message along with a
|
|
13
|
-
* URL that describes the type of the serialized message.
|
|
14
|
-
*
|
|
15
|
-
* Protobuf library provides support to pack/unpack Any values in the form
|
|
16
|
-
* of utility functions or additional generated methods of the Any type.
|
|
17
|
-
*
|
|
18
|
-
* Example 1: Pack and unpack a message in C++.
|
|
19
|
-
*
|
|
20
|
-
* Foo foo = ...;
|
|
21
|
-
* Any any;
|
|
22
|
-
* any.PackFrom(foo);
|
|
23
|
-
* ...
|
|
24
|
-
* if (any.UnpackTo(&foo)) {
|
|
25
|
-
* ...
|
|
26
|
-
* }
|
|
27
|
-
*
|
|
28
|
-
* Example 2: Pack and unpack a message in Java.
|
|
29
|
-
*
|
|
30
|
-
* Foo foo = ...;
|
|
31
|
-
* Any any = Any.pack(foo);
|
|
32
|
-
* ...
|
|
33
|
-
* if (any.is(Foo.class)) {
|
|
34
|
-
* foo = any.unpack(Foo.class);
|
|
35
|
-
* }
|
|
36
|
-
*
|
|
37
|
-
* Example 3: Pack and unpack a message in Python.
|
|
38
|
-
*
|
|
39
|
-
* foo = Foo(...)
|
|
40
|
-
* any = Any()
|
|
41
|
-
* any.Pack(foo)
|
|
42
|
-
* ...
|
|
43
|
-
* if any.Is(Foo.DESCRIPTOR):
|
|
44
|
-
* any.Unpack(foo)
|
|
45
|
-
* ...
|
|
46
|
-
*
|
|
47
|
-
* Example 4: Pack and unpack a message in Go
|
|
48
|
-
*
|
|
49
|
-
* foo := &pb.Foo{...}
|
|
50
|
-
* any, err := ptypes.MarshalAny(foo)
|
|
51
|
-
* ...
|
|
52
|
-
* foo := &pb.Foo{}
|
|
53
|
-
* if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
|
54
|
-
* ...
|
|
55
|
-
* }
|
|
56
|
-
*
|
|
57
|
-
* The pack methods provided by protobuf library will by default use
|
|
58
|
-
* 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
|
59
|
-
* methods only use the fully qualified type name after the last '/'
|
|
60
|
-
* in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
|
61
|
-
* name "y.z".
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* JSON
|
|
65
|
-
* ====
|
|
66
|
-
* The JSON representation of an `Any` value uses the regular
|
|
67
|
-
* representation of the deserialized, embedded message, with an
|
|
68
|
-
* additional field `@type` which contains the type URL. Example:
|
|
69
|
-
*
|
|
70
|
-
* package google.profile;
|
|
71
|
-
* message Person {
|
|
72
|
-
* string first_name = 1;
|
|
73
|
-
* string last_name = 2;
|
|
74
|
-
* }
|
|
75
|
-
*
|
|
76
|
-
* {
|
|
77
|
-
* "@type": "type.googleapis.com/google.profile.Person",
|
|
78
|
-
* "firstName": <string>,
|
|
79
|
-
* "lastName": <string>
|
|
80
|
-
* }
|
|
81
|
-
*
|
|
82
|
-
* If the embedded message type is well-known and has a custom JSON
|
|
83
|
-
* representation, that representation will be embedded adding a field
|
|
84
|
-
* `value` which holds the custom JSON in addition to the `@type`
|
|
85
|
-
* field. Example (for message [google.protobuf.Duration][]):
|
|
86
|
-
*
|
|
87
|
-
* {
|
|
88
|
-
* "@type": "type.googleapis.com/google.protobuf.Duration",
|
|
89
|
-
* "value": "1.212s"
|
|
90
|
-
* }
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* @generated from protobuf message google.protobuf.Any
|
|
94
|
-
*/
|
|
95
|
-
export interface Any {
|
|
96
|
-
/**
|
|
97
|
-
* A URL/resource name that uniquely identifies the type of the serialized
|
|
98
|
-
* protocol buffer message. This string must contain at least
|
|
99
|
-
* one "/" character. The last segment of the URL's path must represent
|
|
100
|
-
* the fully qualified name of the type (as in
|
|
101
|
-
* `path/google.protobuf.Duration`). The name should be in a canonical form
|
|
102
|
-
* (e.g., leading "." is not accepted).
|
|
103
|
-
*
|
|
104
|
-
* In practice, teams usually precompile into the binary all types that they
|
|
105
|
-
* expect it to use in the context of Any. However, for URLs which use the
|
|
106
|
-
* scheme `http`, `https`, or no scheme, one can optionally set up a type
|
|
107
|
-
* server that maps type URLs to message definitions as follows:
|
|
108
|
-
*
|
|
109
|
-
* * If no scheme is provided, `https` is assumed.
|
|
110
|
-
* * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
|
111
|
-
* value in binary format, or produce an error.
|
|
112
|
-
* * Applications are allowed to cache lookup results based on the
|
|
113
|
-
* URL, or have them precompiled into a binary to avoid any
|
|
114
|
-
* lookup. Therefore, binary compatibility needs to be preserved
|
|
115
|
-
* on changes to types. (Use versioned type names to manage
|
|
116
|
-
* breaking changes.)
|
|
117
|
-
*
|
|
118
|
-
* Note: this functionality is not currently available in the official
|
|
119
|
-
* protobuf release, and it is not used for type URLs beginning with
|
|
120
|
-
* type.googleapis.com.
|
|
121
|
-
*
|
|
122
|
-
* Schemes other than `http`, `https` (or the empty scheme) might be
|
|
123
|
-
* used with implementation specific semantics.
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* @generated from protobuf field: string type_url = 1;
|
|
127
|
-
*/
|
|
128
|
-
typeUrl: string;
|
|
129
|
-
/**
|
|
130
|
-
* Must be a valid serialized protocol buffer of the above specified type.
|
|
131
|
-
*
|
|
132
|
-
* @generated from protobuf field: bytes value = 2;
|
|
133
|
-
*/
|
|
134
|
-
value: Uint8Array;
|
|
135
|
-
}
|
|
136
|
-
declare class Any$Type extends MessageType<Any> {
|
|
137
|
-
constructor();
|
|
138
|
-
/**
|
|
139
|
-
* Pack the message into a new `Any`.
|
|
140
|
-
*
|
|
141
|
-
* Uses 'type.googleapis.com/full.type.name' as the type URL.
|
|
142
|
-
*/
|
|
143
|
-
pack<T extends object>(message: T, type: IMessageType<T>): Any;
|
|
144
|
-
/**
|
|
145
|
-
* Unpack the message from the `Any`.
|
|
146
|
-
*/
|
|
147
|
-
unpack<T extends object>(any: Any, type: IMessageType<T>, options?: Partial<BinaryReadOptions>): T;
|
|
148
|
-
/**
|
|
149
|
-
* Does the given `Any` contain a packed message of the given type?
|
|
150
|
-
*/
|
|
151
|
-
contains(any: Any, type: IMessageType<any> | string): boolean;
|
|
152
|
-
/**
|
|
153
|
-
* Convert the message to canonical JSON value.
|
|
154
|
-
*
|
|
155
|
-
* You have to provide the `typeRegistry` option so that the
|
|
156
|
-
* packed message can be converted to JSON.
|
|
157
|
-
*
|
|
158
|
-
* The `typeRegistry` option is also required to read
|
|
159
|
-
* `google.protobuf.Any` from JSON format.
|
|
160
|
-
*/
|
|
161
|
-
internalJsonWrite(any: Any, options: JsonWriteOptions): JsonValue;
|
|
162
|
-
internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Any): Any;
|
|
163
|
-
typeNameToUrl(name: string): string;
|
|
164
|
-
typeUrlToName(url: string): string;
|
|
165
|
-
create(value?: PartialMessage<Any>): Any;
|
|
166
|
-
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Any): Any;
|
|
167
|
-
internalBinaryWrite(message: Any, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* @generated MessageType for protobuf message google.protobuf.Any
|
|
171
|
-
*/
|
|
172
|
-
export declare const Any: Any$Type;
|
|
173
|
-
export {};
|