@streamr/dht 103.1.2-rc.0 → 103.2.0-experiment.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/dist/exports-browser.cjs +7636 -0
- package/dist/exports-browser.cjs.map +1 -0
- package/dist/exports-browser.d.ts +1321 -0
- package/dist/exports-browser.js +7611 -0
- package/dist/exports-browser.js.map +1 -0
- package/dist/exports-nodejs.cjs +7833 -0
- package/dist/exports-nodejs.cjs.map +1 -0
- package/dist/exports-nodejs.d.ts +1321 -0
- package/dist/exports-nodejs.js +7808 -0
- package/dist/exports-nodejs.js.map +1 -0
- package/package.json +41 -25
- package/dist/generated/google/protobuf/any.d.ts +0 -180
- package/dist/generated/google/protobuf/any.js +0 -155
- package/dist/generated/google/protobuf/any.js.map +0 -1
- package/dist/generated/google/protobuf/empty.d.ts +0 -31
- package/dist/generated/google/protobuf/empty.js +0 -45
- package/dist/generated/google/protobuf/empty.js.map +0 -1
- package/dist/generated/google/protobuf/timestamp.d.ts +0 -156
- package/dist/generated/google/protobuf/timestamp.js +0 -136
- package/dist/generated/google/protobuf/timestamp.js.map +0 -1
- package/dist/generated/packages/dht/protos/DhtRpc.client.d.ts +0 -371
- package/dist/generated/packages/dht/protos/DhtRpc.client.js +0 -292
- package/dist/generated/packages/dht/protos/DhtRpc.client.js.map +0 -1
- package/dist/generated/packages/dht/protos/DhtRpc.d.ts +0 -1031
- package/dist/generated/packages/dht/protos/DhtRpc.js +0 -702
- package/dist/generated/packages/dht/protos/DhtRpc.js.map +0 -1
- package/dist/generated/packages/dht/protos/DhtRpc.server.d.ts +0 -168
- package/dist/generated/packages/dht/protos/DhtRpc.server.js +0 -3
- package/dist/generated/packages/dht/protos/DhtRpc.server.js.map +0 -1
- package/dist/generated/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -87
- package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js +0 -66
- package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js.map +0 -1
- package/dist/package.json +0 -61
- package/dist/src/connection/Connection.d.ts +0 -12
- package/dist/src/connection/Connection.js +0 -30
- package/dist/src/connection/Connection.js.map +0 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +0 -22
- package/dist/src/connection/ConnectionLockRpcLocal.js +0 -54
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +0 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +0 -10
- package/dist/src/connection/ConnectionLockRpcRemote.js +0 -61
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +0 -1
- package/dist/src/connection/ConnectionLockStates.d.ts +0 -27
- package/dist/src/connection/ConnectionLockStates.js +0 -114
- package/dist/src/connection/ConnectionLockStates.js.map +0 -1
- package/dist/src/connection/ConnectionManager.d.ts +0 -85
- package/dist/src/connection/ConnectionManager.js +0 -569
- package/dist/src/connection/ConnectionManager.js.map +0 -1
- package/dist/src/connection/ConnectionsView.d.ts +0 -7
- package/dist/src/connection/ConnectionsView.js +0 -3
- package/dist/src/connection/ConnectionsView.js.map +0 -1
- package/dist/src/connection/ConnectorFacade.d.ts +0 -58
- package/dist/src/connection/ConnectorFacade.js +0 -154
- package/dist/src/connection/ConnectorFacade.js.map +0 -1
- package/dist/src/connection/Handshaker.d.ts +0 -27
- package/dist/src/connection/Handshaker.js +0 -179
- package/dist/src/connection/Handshaker.js.map +0 -1
- package/dist/src/connection/IConnection.d.ts +0 -32
- package/dist/src/connection/IConnection.js +0 -12
- package/dist/src/connection/IConnection.js.map +0 -1
- package/dist/src/connection/ManagedConnection.d.ts +0 -30
- package/dist/src/connection/ManagedConnection.js +0 -129
- package/dist/src/connection/ManagedConnection.js.map +0 -1
- package/dist/src/connection/OutputBuffer.d.ts +0 -9
- package/dist/src/connection/OutputBuffer.js +0 -26
- package/dist/src/connection/OutputBuffer.js.map +0 -1
- package/dist/src/connection/PendingConnection.d.ts +0 -19
- package/dist/src/connection/PendingConnection.js +0 -59
- package/dist/src/connection/PendingConnection.js.map +0 -1
- package/dist/src/connection/connectivityChecker.d.ts +0 -9
- package/dist/src/connection/connectivityChecker.js +0 -138
- package/dist/src/connection/connectivityChecker.js.map +0 -1
- package/dist/src/connection/connectivityRequestHandler.d.ts +0 -4
- package/dist/src/connection/connectivityRequestHandler.js +0 -108
- package/dist/src/connection/connectivityRequestHandler.js.map +0 -1
- package/dist/src/connection/simulator/Simulator.d.ts +0 -36
- package/dist/src/connection/simulator/Simulator.js +0 -290
- package/dist/src/connection/simulator/Simulator.js.map +0 -1
- package/dist/src/connection/simulator/SimulatorConnection.d.ts +0 -18
- package/dist/src/connection/simulator/SimulatorConnection.js +0 -123
- package/dist/src/connection/simulator/SimulatorConnection.js.map +0 -1
- package/dist/src/connection/simulator/SimulatorConnector.d.ts +0 -16
- package/dist/src/connection/simulator/SimulatorConnector.js +0 -80
- package/dist/src/connection/simulator/SimulatorConnector.js.map +0 -1
- package/dist/src/connection/simulator/SimulatorTransport.d.ts +0 -6
- package/dist/src/connection/simulator/SimulatorTransport.js +0 -17
- package/dist/src/connection/simulator/SimulatorTransport.js.map +0 -1
- package/dist/src/connection/simulator/pings.d.ts +0 -21
- package/dist/src/connection/simulator/pings.js +0 -61
- package/dist/src/connection/simulator/pings.js.map +0 -1
- package/dist/src/connection/webrtc/BrowserWebrtcConnection.d.ts +0 -37
- package/dist/src/connection/webrtc/BrowserWebrtcConnection.js +0 -229
- package/dist/src/connection/webrtc/BrowserWebrtcConnection.js.map +0 -1
- package/dist/src/connection/webrtc/IWebrtcConnection.d.ts +0 -21
- package/dist/src/connection/webrtc/IWebrtcConnection.js +0 -9
- package/dist/src/connection/webrtc/IWebrtcConnection.js.map +0 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +0 -45
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +0 -229
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +0 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +0 -43
- package/dist/src/connection/webrtc/WebrtcConnector.js +0 -208
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +0 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +0 -26
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +0 -82
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +0 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +0 -8
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js +0 -50
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +0 -1
- package/dist/src/connection/webrtc/iceServerAsString.d.ts +0 -2
- package/dist/src/connection/webrtc/iceServerAsString.js +0 -17
- package/dist/src/connection/webrtc/iceServerAsString.js.map +0 -1
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +0 -27
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js +0 -107
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js.map +0 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +0 -26
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +0 -39
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +0 -1
- package/dist/src/connection/websocket/BrowserWebsocketClientConnection.d.ts +0 -7
- package/dist/src/connection/websocket/BrowserWebsocketClientConnection.js +0 -44
- package/dist/src/connection/websocket/BrowserWebsocketClientConnection.js.map +0 -1
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.d.ts +0 -7
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.js +0 -39
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.js.map +0 -1
- package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +0 -26
- package/dist/src/connection/websocket/WebsocketClientConnector.js +0 -86
- package/dist/src/connection/websocket/WebsocketClientConnector.js.map +0 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +0 -18
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +0 -23
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +0 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +0 -5
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js +0 -17
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +0 -1
- package/dist/src/connection/websocket/WebsocketServer.d.ts +0 -25
- package/dist/src/connection/websocket/WebsocketServer.js +0 -146
- package/dist/src/connection/websocket/WebsocketServer.js.map +0 -1
- package/dist/src/connection/websocket/WebsocketServerConnection.d.ts +0 -22
- package/dist/src/connection/websocket/WebsocketServerConnection.js +0 -101
- package/dist/src/connection/websocket/WebsocketServerConnection.js.map +0 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.d.ts +0 -44
- package/dist/src/connection/websocket/WebsocketServerConnector.js +0 -279
- package/dist/src/connection/websocket/WebsocketServerConnector.js.map +0 -1
- package/dist/src/dht/DhtNode.d.ts +0 -119
- package/dist/src/dht/DhtNode.js +0 -500
- package/dist/src/dht/DhtNode.js.map +0 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +0 -23
- package/dist/src/dht/DhtNodeRpcLocal.js +0 -54
- package/dist/src/dht/DhtNodeRpcLocal.js.map +0 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +0 -25
- package/dist/src/dht/DhtNodeRpcRemote.js +0 -83
- package/dist/src/dht/DhtNodeRpcRemote.js.map +0 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +0 -18
- package/dist/src/dht/ExternalApiRpcLocal.js +0 -32
- package/dist/src/dht/ExternalApiRpcLocal.js.map +0 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +0 -10
- package/dist/src/dht/ExternalApiRpcRemote.js +0 -58
- package/dist/src/dht/ExternalApiRpcRemote.js.map +0 -1
- package/dist/src/dht/PeerManager.d.ts +0 -63
- package/dist/src/dht/PeerManager.js +0 -251
- package/dist/src/dht/PeerManager.js.map +0 -1
- package/dist/src/dht/contact/Contact.d.ts +0 -8
- package/dist/src/dht/contact/Contact.js +0 -18
- package/dist/src/dht/contact/Contact.js.map +0 -1
- package/dist/src/dht/contact/ContactList.d.ts +0 -19
- package/dist/src/dht/contact/ContactList.js +0 -35
- package/dist/src/dht/contact/ContactList.js.map +0 -1
- package/dist/src/dht/contact/RandomContactList.d.ts +0 -11
- package/dist/src/dht/contact/RandomContactList.js +0 -47
- package/dist/src/dht/contact/RandomContactList.js.map +0 -1
- package/dist/src/dht/contact/RingContactList.d.ts +0 -28
- package/dist/src/dht/contact/RingContactList.js +0 -126
- package/dist/src/dht/contact/RingContactList.js.map +0 -1
- package/dist/src/dht/contact/RpcRemote.d.ts +0 -19
- package/dist/src/dht/contact/RpcRemote.js +0 -61
- package/dist/src/dht/contact/RpcRemote.js.map +0 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +0 -37
- package/dist/src/dht/contact/SortedContactList.js +0 -134
- package/dist/src/dht/contact/SortedContactList.js.map +0 -1
- package/dist/src/dht/contact/getClosestNodes.d.ts +0 -6
- package/dist/src/dht/contact/getClosestNodes.js +0 -19
- package/dist/src/dht/contact/getClosestNodes.js.map +0 -1
- package/dist/src/dht/contact/ringIdentifiers.d.ts +0 -16
- package/dist/src/dht/contact/ringIdentifiers.js +0 -54
- package/dist/src/dht/contact/ringIdentifiers.js.map +0 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +0 -29
- package/dist/src/dht/discovery/DiscoverySession.js +0 -102
- package/dist/src/dht/discovery/DiscoverySession.js.map +0 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +0 -42
- package/dist/src/dht/discovery/PeerDiscovery.js +0 -193
- package/dist/src/dht/discovery/PeerDiscovery.js.map +0 -1
- package/dist/src/dht/discovery/RingDiscoverySession.d.ts +0 -28
- package/dist/src/dht/discovery/RingDiscoverySession.js +0 -116
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +0 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +0 -38
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +0 -165
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +0 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +0 -14
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +0 -26
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +0 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +0 -6
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +0 -44
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +0 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +0 -45
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +0 -185
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +0 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +0 -14
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +0 -20
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +0 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +0 -6
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.js +0 -21
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.js.map +0 -1
- package/dist/src/dht/routing/DuplicateDetector.d.ts +0 -10
- package/dist/src/dht/routing/DuplicateDetector.js +0 -31
- package/dist/src/dht/routing/DuplicateDetector.js.map +0 -1
- package/dist/src/dht/routing/Router.d.ts +0 -35
- package/dist/src/dht/routing/Router.js +0 -204
- package/dist/src/dht/routing/Router.js.map +0 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +0 -20
- package/dist/src/dht/routing/RouterRpcLocal.js +0 -67
- package/dist/src/dht/routing/RouterRpcLocal.js.map +0 -1
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +0 -8
- package/dist/src/dht/routing/RouterRpcRemote.js +0 -81
- package/dist/src/dht/routing/RouterRpcRemote.js.map +0 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +0 -56
- package/dist/src/dht/routing/RoutingSession.js +0 -201
- package/dist/src/dht/routing/RoutingSession.js.map +0 -1
- package/dist/src/dht/routing/RoutingTablesCache.d.ts +0 -24
- package/dist/src/dht/routing/RoutingTablesCache.js +0 -46
- package/dist/src/dht/routing/RoutingTablesCache.js.map +0 -1
- package/dist/src/dht/routing/getPreviousPeer.d.ts +0 -2
- package/dist/src/dht/routing/getPreviousPeer.js +0 -12
- package/dist/src/dht/routing/getPreviousPeer.js.map +0 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +0 -14
- package/dist/src/dht/store/LocalDataStore.js +0 -78
- package/dist/src/dht/store/LocalDataStore.js.map +0 -1
- package/dist/src/dht/store/StoreManager.d.ts +0 -32
- package/dist/src/dht/store/StoreManager.js +0 -126
- package/dist/src/dht/store/StoreManager.js.map +0 -1
- package/dist/src/dht/store/StoreRpcLocal.d.ts +0 -21
- package/dist/src/dht/store/StoreRpcLocal.js +0 -65
- package/dist/src/dht/store/StoreRpcLocal.js.map +0 -1
- package/dist/src/dht/store/StoreRpcRemote.d.ts +0 -7
- package/dist/src/dht/store/StoreRpcRemote.js +0 -29
- package/dist/src/dht/store/StoreRpcRemote.js.map +0 -1
- package/dist/src/exports.d.ts +0 -25
- package/dist/src/exports.js +0 -48
- package/dist/src/exports.js.map +0 -1
- package/dist/src/helpers/AddressTools.d.ts +0 -2
- package/dist/src/helpers/AddressTools.js +0 -32
- package/dist/src/helpers/AddressTools.js.map +0 -1
- package/dist/src/helpers/Connectivity.d.ts +0 -4
- package/dist/src/helpers/Connectivity.js +0 -24
- package/dist/src/helpers/Connectivity.js.map +0 -1
- package/dist/src/helpers/browser/isBrowserEnvironment.d.ts +0 -1
- package/dist/src/helpers/browser/isBrowserEnvironment.js +0 -6
- package/dist/src/helpers/browser/isBrowserEnvironment.js.map +0 -1
- package/dist/src/helpers/browser/isBrowserEnvironment_override.d.ts +0 -1
- package/dist/src/helpers/browser/isBrowserEnvironment_override.js +0 -7
- package/dist/src/helpers/browser/isBrowserEnvironment_override.js.map +0 -1
- package/dist/src/helpers/createPeerDescriptor.d.ts +0 -3
- package/dist/src/helpers/createPeerDescriptor.js +0 -58
- package/dist/src/helpers/createPeerDescriptor.js.map +0 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +0 -2
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +0 -30
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +0 -1
- package/dist/src/helpers/debugHelpers.d.ts +0 -3
- package/dist/src/helpers/debugHelpers.js +0 -11
- package/dist/src/helpers/debugHelpers.js.map +0 -1
- package/dist/src/helpers/errors.d.ts +0 -72
- package/dist/src/helpers/errors.js +0 -97
- package/dist/src/helpers/errors.js.map +0 -1
- package/dist/src/helpers/offering.d.ts +0 -4
- package/dist/src/helpers/offering.js +0 -18
- package/dist/src/helpers/offering.js.map +0 -1
- package/dist/src/helpers/protoClasses.d.ts +0 -2
- package/dist/src/helpers/protoClasses.js +0 -32
- package/dist/src/helpers/protoClasses.js.map +0 -1
- package/dist/src/helpers/protoToString.d.ts +0 -2
- package/dist/src/helpers/protoToString.js +0 -19
- package/dist/src/helpers/protoToString.js.map +0 -1
- package/dist/src/helpers/version.d.ts +0 -6
- package/dist/src/helpers/version.js +0 -38
- package/dist/src/helpers/version.js.map +0 -1
- package/dist/src/identifiers.d.ts +0 -10
- package/dist/src/identifiers.js +0 -31
- package/dist/src/identifiers.js.map +0 -1
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +0 -12
- package/dist/src/rpc-protocol/DhtCallContext.js +0 -17
- package/dist/src/rpc-protocol/DhtCallContext.js.map +0 -1
- package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +0 -10
- package/dist/src/rpc-protocol/DhtRpcOptions.js +0 -3
- package/dist/src/rpc-protocol/DhtRpcOptions.js.map +0 -1
- package/dist/src/transport/ITransport.d.ts +0 -31
- package/dist/src/transport/ITransport.js +0 -9
- package/dist/src/transport/ITransport.js.map +0 -1
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +0 -11
- package/dist/src/transport/ListeningRpcCommunicator.js +0 -31
- package/dist/src/transport/ListeningRpcCommunicator.js.map +0 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +0 -10
- package/dist/src/transport/RoutingRpcCommunicator.js +0 -60
- package/dist/src/transport/RoutingRpcCommunicator.js.map +0 -1
- package/dist/src/types/ServiceID.d.ts +0 -1
- package/dist/src/types/ServiceID.js +0 -3
- package/dist/src/types/ServiceID.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeWebrtcConnection.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/NodeWebrtcConnection.ts"],"names":[],"mappings":";;;;;;AACA,gDAA0E;AAE1E,kEAAwC;AACxC,uDAA2F;AAC3F,0CAAuC;AACvC,iDAAoE;AACpE,2DAAuD;AACvD,uDAA4D;AAE5D,mDAA4C;AAC5C,8CAAwD;AAExD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAWjC,sGAAsG;AACtG,2DAA2D;AAE3D,IAAK,0BAOJ;AAPD,WAAK,0BAA0B;IAC3B,+CAAiB,CAAA;IACjB,qDAAuB,CAAA;IACvB,uDAAyB,CAAA;IACzB,2DAA6B,CAAA;IAC7B,+CAAiB,CAAA;IACjB,yCAAW,CAAA;AACf,CAAC,EAPI,0BAA0B,KAA1B,0BAA0B,QAO9B;AAED,IAAA,6BAAU,EAAC,OAAO,CAAC,CAAA;AAInB,MAAa,oBAAqB,SAAQ,uBAAoC;IAEnE,YAAY,CAAc;IACzB,UAAU,CAAiB;IAC3B,WAAW,CAAc;IACzB,SAAS,GAA2B,YAAY,CAAA;IAChD,oBAAoB,GAAG,KAAK,CAAA;IACpB,cAAc,GAAmB,4BAAc,CAAC,MAAM,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EAAE,CAAC;YACpF,MAAM,IAAI,sCAA6B,CAAC,8CAA8C,GAAG,KAAK,CAAC,CAAA;QACnG,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,SAAS,GAAG,KAA+B,CAAA;QACpD,CAAC;QAED,IAAI,KAAK,KAAK,0BAA0B,CAAC,MAAM;eACxC,KAAK,KAAK,0BAA0B,CAAC,YAAY;eACjD,KAAK,KAAK,0BAA0B,CAAC,MAAM,EAChD,CAAC;YACC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACvB,CAAC;IAEL,CAAC;IAED,MAAM;QACF,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,KAAK,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAA;IAC/E,CAAC;IAEM,eAAe,CAAC,YAA0B;QAC7C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IACpC,CAAC;CACJ;AArND,oDAqNC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc';
|
|
2
|
-
import { ITransport } from '../../transport/ITransport';
|
|
3
|
-
import { NodeWebrtcConnection } from './NodeWebrtcConnection';
|
|
4
|
-
import { PortRange } from '../ConnectionManager';
|
|
5
|
-
import { PendingConnection } from '../PendingConnection';
|
|
6
|
-
export declare const replaceInternalIpWithExternalIp: (candidate: string, ip: string) => string;
|
|
7
|
-
export declare const EARLY_TIMEOUT = 5000;
|
|
8
|
-
export interface WebrtcConnectorOptions {
|
|
9
|
-
onNewConnection: (connection: PendingConnection) => boolean;
|
|
10
|
-
transport: ITransport;
|
|
11
|
-
iceServers?: IceServer[];
|
|
12
|
-
allowPrivateAddresses?: boolean;
|
|
13
|
-
bufferThresholdLow?: number;
|
|
14
|
-
bufferThresholdHigh?: number;
|
|
15
|
-
maxMessageSize?: number;
|
|
16
|
-
externalIp?: string;
|
|
17
|
-
portRange?: PortRange;
|
|
18
|
-
}
|
|
19
|
-
export interface IceServer {
|
|
20
|
-
url: string;
|
|
21
|
-
port: number;
|
|
22
|
-
username?: string;
|
|
23
|
-
password?: string;
|
|
24
|
-
tcp?: boolean;
|
|
25
|
-
}
|
|
26
|
-
export interface ConnectingConnection {
|
|
27
|
-
managedConnection: PendingConnection;
|
|
28
|
-
connection: NodeWebrtcConnection;
|
|
29
|
-
}
|
|
30
|
-
export declare class WebrtcConnector {
|
|
31
|
-
private static readonly WEBRTC_CONNECTOR_SERVICE_ID;
|
|
32
|
-
private readonly rpcCommunicator;
|
|
33
|
-
private readonly ongoingConnectAttempts;
|
|
34
|
-
private localPeerDescriptor?;
|
|
35
|
-
private stopped;
|
|
36
|
-
private options;
|
|
37
|
-
constructor(options: WebrtcConnectorOptions);
|
|
38
|
-
private registerLocalRpcMethods;
|
|
39
|
-
connect(targetPeerDescriptor: PeerDescriptor, doNotRequestConnection: boolean): PendingConnection;
|
|
40
|
-
private createConnection;
|
|
41
|
-
setLocalPeerDescriptor(peerDescriptor: PeerDescriptor): void;
|
|
42
|
-
stop(): Promise<void>;
|
|
43
|
-
}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.WebrtcConnector = exports.EARLY_TIMEOUT = exports.replaceInternalIpWithExternalIp = void 0;
|
|
37
|
-
const DhtRpc_1 = require("../../../generated/packages/dht/protos/DhtRpc");
|
|
38
|
-
const ListeningRpcCommunicator_1 = require("../../transport/ListeningRpcCommunicator");
|
|
39
|
-
const NodeWebrtcConnection_1 = require("./NodeWebrtcConnection");
|
|
40
|
-
const WebrtcConnectorRpcRemote_1 = require("./WebrtcConnectorRpcRemote");
|
|
41
|
-
const DhtRpc_client_1 = require("../../../generated/packages/dht/protos/DhtRpc.client");
|
|
42
|
-
const utils_1 = require("@streamr/utils");
|
|
43
|
-
const Err = __importStar(require("../../helpers/errors"));
|
|
44
|
-
const WebrtcConnectorRpcLocal_1 = require("./WebrtcConnectorRpcLocal");
|
|
45
|
-
const identifiers_1 = require("../../identifiers");
|
|
46
|
-
const offering_1 = require("../../helpers/offering");
|
|
47
|
-
const Handshaker_1 = require("../Handshaker");
|
|
48
|
-
const version_1 = require("../../helpers/version");
|
|
49
|
-
const PendingConnection_1 = require("../PendingConnection");
|
|
50
|
-
const logger = new utils_1.Logger(module);
|
|
51
|
-
const replaceInternalIpWithExternalIp = (candidate, ip) => {
|
|
52
|
-
const parsed = candidate.split(' ');
|
|
53
|
-
const type = parsed[7];
|
|
54
|
-
if (type === 'host') {
|
|
55
|
-
parsed[4] = ip;
|
|
56
|
-
}
|
|
57
|
-
return parsed.join(' ');
|
|
58
|
-
};
|
|
59
|
-
exports.replaceInternalIpWithExternalIp = replaceInternalIpWithExternalIp;
|
|
60
|
-
exports.EARLY_TIMEOUT = 5000;
|
|
61
|
-
class WebrtcConnector {
|
|
62
|
-
static WEBRTC_CONNECTOR_SERVICE_ID = 'system/webrtc-connector';
|
|
63
|
-
rpcCommunicator;
|
|
64
|
-
ongoingConnectAttempts = new Map();
|
|
65
|
-
localPeerDescriptor;
|
|
66
|
-
stopped = false;
|
|
67
|
-
options;
|
|
68
|
-
constructor(options) {
|
|
69
|
-
this.options = options;
|
|
70
|
-
this.rpcCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(WebrtcConnector.WEBRTC_CONNECTOR_SERVICE_ID, options.transport, {
|
|
71
|
-
rpcRequestTimeout: 15000 // TODO use options option or named constant?
|
|
72
|
-
});
|
|
73
|
-
this.registerLocalRpcMethods(options);
|
|
74
|
-
}
|
|
75
|
-
registerLocalRpcMethods(options) {
|
|
76
|
-
const localRpc = new WebrtcConnectorRpcLocal_1.WebrtcConnectorRpcLocal({
|
|
77
|
-
connect: (targetPeerDescriptor, doNotRequestConnection) => this.connect(targetPeerDescriptor, doNotRequestConnection),
|
|
78
|
-
onNewConnection: (connection) => this.options.onNewConnection(connection),
|
|
79
|
-
ongoingConnectAttempts: this.ongoingConnectAttempts,
|
|
80
|
-
rpcCommunicator: this.rpcCommunicator,
|
|
81
|
-
getLocalPeerDescriptor: () => this.localPeerDescriptor,
|
|
82
|
-
allowPrivateAddresses: options.allowPrivateAddresses ?? true
|
|
83
|
-
});
|
|
84
|
-
this.rpcCommunicator.registerRpcNotification(DhtRpc_1.WebrtcConnectionRequest, 'requestConnection', async (_req, context) => {
|
|
85
|
-
if (!this.stopped) {
|
|
86
|
-
return localRpc.requestConnection(context);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
return {};
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
this.rpcCommunicator.registerRpcNotification(DhtRpc_1.RtcOffer, 'rtcOffer', async (req, context) => {
|
|
93
|
-
if (!this.stopped) {
|
|
94
|
-
return localRpc.rtcOffer(req, context);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
return {};
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
this.rpcCommunicator.registerRpcNotification(DhtRpc_1.RtcAnswer, 'rtcAnswer', async (req, context) => {
|
|
101
|
-
if (!this.stopped) {
|
|
102
|
-
return localRpc.rtcAnswer(req, context);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
return {};
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
this.rpcCommunicator.registerRpcNotification(DhtRpc_1.IceCandidate, 'iceCandidate', async (req, context) => {
|
|
109
|
-
if (!this.stopped) {
|
|
110
|
-
return localRpc.iceCandidate(req, context);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
return {};
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
connect(targetPeerDescriptor, doNotRequestConnection) {
|
|
118
|
-
if ((0, identifiers_1.areEqualPeerDescriptors)(targetPeerDescriptor, this.localPeerDescriptor)) {
|
|
119
|
-
throw new Err.CannotConnectToSelf('Cannot open WebRTC Connection to self');
|
|
120
|
-
}
|
|
121
|
-
logger.trace(`Opening WebRTC connection to ${(0, identifiers_1.toNodeId)(targetPeerDescriptor)}`);
|
|
122
|
-
const nodeId = (0, identifiers_1.toNodeId)(targetPeerDescriptor);
|
|
123
|
-
const existingConnection = this.ongoingConnectAttempts.get(nodeId);
|
|
124
|
-
if (existingConnection) {
|
|
125
|
-
return existingConnection.managedConnection;
|
|
126
|
-
}
|
|
127
|
-
const connection = this.createConnection(targetPeerDescriptor);
|
|
128
|
-
const localNodeId = (0, identifiers_1.toNodeId)(this.localPeerDescriptor);
|
|
129
|
-
const targetNodeId = (0, identifiers_1.toNodeId)(targetPeerDescriptor);
|
|
130
|
-
const offering = ((0, offering_1.getOfferer)(localNodeId, targetNodeId) === 'local');
|
|
131
|
-
let pendingConnection;
|
|
132
|
-
const remoteConnector = new WebrtcConnectorRpcRemote_1.WebrtcConnectorRpcRemote(this.localPeerDescriptor, targetPeerDescriptor, this.rpcCommunicator, DhtRpc_client_1.WebrtcConnectorRpcClient);
|
|
133
|
-
const delFunc = () => {
|
|
134
|
-
this.ongoingConnectAttempts.delete(nodeId);
|
|
135
|
-
connection.off('disconnected', delFunc);
|
|
136
|
-
pendingConnection.off('disconnected', delFunc);
|
|
137
|
-
pendingConnection.off('connected', delFunc);
|
|
138
|
-
};
|
|
139
|
-
if (offering) {
|
|
140
|
-
pendingConnection = new PendingConnection_1.PendingConnection(targetPeerDescriptor);
|
|
141
|
-
(0, Handshaker_1.createOutgoingHandshaker)(this.localPeerDescriptor, pendingConnection, connection, targetPeerDescriptor);
|
|
142
|
-
connection.once('localDescription', (description) => {
|
|
143
|
-
logger.trace('Sending offer to remote peer');
|
|
144
|
-
remoteConnector.sendRtcOffer(description, connection.connectionId);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
pendingConnection = new PendingConnection_1.PendingConnection(targetPeerDescriptor);
|
|
149
|
-
const handshaker = (0, Handshaker_1.createIncomingHandshaker)(this.localPeerDescriptor, pendingConnection, connection);
|
|
150
|
-
connection.once('localDescription', (description) => {
|
|
151
|
-
remoteConnector.sendRtcAnswer(description, connection.connectionId);
|
|
152
|
-
});
|
|
153
|
-
handshaker.on('handshakeRequest', (_sourceDescriptor, remoteVersion) => {
|
|
154
|
-
if (!(0, version_1.isMaybeSupportedProtocolVersion)(remoteVersion)) {
|
|
155
|
-
(0, Handshaker_1.rejectHandshake)(pendingConnection, connection, handshaker, DhtRpc_1.HandshakeError.UNSUPPORTED_PROTOCOL_VERSION);
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
(0, Handshaker_1.acceptHandshake)(handshaker, pendingConnection, connection);
|
|
159
|
-
}
|
|
160
|
-
delFunc();
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
this.ongoingConnectAttempts.set(targetNodeId, {
|
|
164
|
-
managedConnection: pendingConnection,
|
|
165
|
-
connection
|
|
166
|
-
});
|
|
167
|
-
connection.on('disconnected', delFunc);
|
|
168
|
-
pendingConnection.on('disconnected', delFunc);
|
|
169
|
-
pendingConnection.on('connected', delFunc);
|
|
170
|
-
connection.on('localCandidate', (candidate, mid) => {
|
|
171
|
-
if (this.options.externalIp !== undefined) {
|
|
172
|
-
candidate = (0, exports.replaceInternalIpWithExternalIp)(candidate, this.options.externalIp);
|
|
173
|
-
logger.debug(`onLocalCandidate injected external ip ${candidate} ${mid}`);
|
|
174
|
-
}
|
|
175
|
-
remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId);
|
|
176
|
-
});
|
|
177
|
-
connection.start(offering);
|
|
178
|
-
if (!doNotRequestConnection && !offering) {
|
|
179
|
-
remoteConnector.requestConnection();
|
|
180
|
-
}
|
|
181
|
-
return pendingConnection;
|
|
182
|
-
}
|
|
183
|
-
createConnection(targetPeerDescriptor) {
|
|
184
|
-
return new NodeWebrtcConnection_1.NodeWebrtcConnection({
|
|
185
|
-
remotePeerDescriptor: targetPeerDescriptor,
|
|
186
|
-
iceServers: this.options.iceServers,
|
|
187
|
-
bufferThresholdLow: this.options.bufferThresholdLow,
|
|
188
|
-
bufferThresholdHigh: this.options.bufferThresholdHigh,
|
|
189
|
-
portRange: this.options.portRange
|
|
190
|
-
// TODO should we pass maxMessageSize?
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
setLocalPeerDescriptor(peerDescriptor) {
|
|
194
|
-
this.localPeerDescriptor = peerDescriptor;
|
|
195
|
-
}
|
|
196
|
-
async stop() {
|
|
197
|
-
logger.trace('stop()');
|
|
198
|
-
this.stopped = true;
|
|
199
|
-
const attempts = Array.from(this.ongoingConnectAttempts.values());
|
|
200
|
-
await Promise.allSettled(attempts.map(async (conn) => {
|
|
201
|
-
conn.connection.destroy();
|
|
202
|
-
conn.managedConnection.close(false);
|
|
203
|
-
}));
|
|
204
|
-
this.rpcCommunicator.destroy();
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
exports.WebrtcConnector = WebrtcConnector;
|
|
208
|
-
//# sourceMappingURL=WebrtcConnector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebrtcConnector.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAMsD;AAEtD,uFAAmF;AACnF,iEAA6D;AAC7D,yEAAqE;AACrE,wFAA+F;AAC/F,0CAAuC;AACvC,0DAA2C;AAG3C,uEAAmE;AACnE,mDAAiF;AACjF,qDAAmD;AACnD,8CAAoH;AACpH,mDAAuE;AACvE,4DAAwD;AAExD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAE1B,MAAM,+BAA+B,GAAG,CAAC,SAAiB,EAAE,EAAU,EAAU,EAAE;IACrF,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IACtB,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAClB,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;IAClB,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC3B,CAAC,CAAA;AAPY,QAAA,+BAA+B,mCA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M,KAAK,CAAC,IAAI;QACb,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QAEnB,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,CAAC,CAAA;QACjE,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACjD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAA;YACzB,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACvC,CAAC,CAAC,CAAC,CAAA;QAEH,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;IAClC,CAAC;;AA3KL,0CA4KC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
|
|
2
|
-
import { Empty } from '../../../generated/google/protobuf/empty';
|
|
3
|
-
import { IceCandidate, PeerDescriptor, RtcAnswer, RtcOffer } from '../../../generated/packages/dht/protos/DhtRpc';
|
|
4
|
-
import { IWebrtcConnectorRpc } from '../../../generated/packages/dht/protos/DhtRpc.server';
|
|
5
|
-
import { ListeningRpcCommunicator } from '../../transport/ListeningRpcCommunicator';
|
|
6
|
-
import { DhtAddress } from '../../identifiers';
|
|
7
|
-
import { ConnectingConnection } from './WebrtcConnector';
|
|
8
|
-
import { PendingConnection } from '../PendingConnection';
|
|
9
|
-
interface WebrtcConnectorRpcLocalOptions {
|
|
10
|
-
connect: (targetPeerDescriptor: PeerDescriptor, doNotRequestConnection: boolean) => PendingConnection;
|
|
11
|
-
onNewConnection: (connection: PendingConnection) => boolean;
|
|
12
|
-
ongoingConnectAttempts: Map<DhtAddress, ConnectingConnection>;
|
|
13
|
-
rpcCommunicator: ListeningRpcCommunicator;
|
|
14
|
-
getLocalPeerDescriptor: () => PeerDescriptor;
|
|
15
|
-
allowPrivateAddresses: boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare class WebrtcConnectorRpcLocal implements IWebrtcConnectorRpc {
|
|
18
|
-
private readonly options;
|
|
19
|
-
constructor(options: WebrtcConnectorRpcLocalOptions);
|
|
20
|
-
requestConnection(context: ServerCallContext): Promise<Empty>;
|
|
21
|
-
rtcOffer(request: RtcOffer, context: ServerCallContext): Promise<Empty>;
|
|
22
|
-
rtcAnswer(request: RtcAnswer, context: ServerCallContext): Promise<Empty>;
|
|
23
|
-
iceCandidate(request: IceCandidate, context: ServerCallContext): Promise<Empty>;
|
|
24
|
-
private isIceCandidateAllowed;
|
|
25
|
-
}
|
|
26
|
-
export {};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebrtcConnectorRpcLocal = void 0;
|
|
4
|
-
const utils_1 = require("@streamr/utils");
|
|
5
|
-
const AddressTools_1 = require("../../helpers/AddressTools");
|
|
6
|
-
const identifiers_1 = require("../../identifiers");
|
|
7
|
-
const logger = new utils_1.Logger(module);
|
|
8
|
-
class WebrtcConnectorRpcLocal {
|
|
9
|
-
options;
|
|
10
|
-
constructor(options) {
|
|
11
|
-
this.options = options;
|
|
12
|
-
}
|
|
13
|
-
async requestConnection(context) {
|
|
14
|
-
const targetPeerDescriptor = context.incomingSourceDescriptor;
|
|
15
|
-
if (this.options.ongoingConnectAttempts.has((0, identifiers_1.toNodeId)(targetPeerDescriptor))) {
|
|
16
|
-
return {};
|
|
17
|
-
}
|
|
18
|
-
const pendingConnection = this.options.connect(targetPeerDescriptor, false);
|
|
19
|
-
this.options.onNewConnection(pendingConnection);
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
async rtcOffer(request, context) {
|
|
23
|
-
const remotePeerDescriptor = context.incomingSourceDescriptor;
|
|
24
|
-
const nodeId = (0, identifiers_1.toNodeId)(remotePeerDescriptor);
|
|
25
|
-
let connection;
|
|
26
|
-
let pendingConnection;
|
|
27
|
-
if (!this.options.ongoingConnectAttempts.has(nodeId)) {
|
|
28
|
-
pendingConnection = this.options.connect(remotePeerDescriptor, true);
|
|
29
|
-
connection = this.options.ongoingConnectAttempts.get(nodeId).connection;
|
|
30
|
-
this.options.onNewConnection(pendingConnection);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
pendingConnection = this.options.ongoingConnectAttempts.get(nodeId).managedConnection;
|
|
34
|
-
connection = this.options.ongoingConnectAttempts.get(nodeId).connection;
|
|
35
|
-
}
|
|
36
|
-
// Always use offerers connectionId
|
|
37
|
-
connection.setConnectionId(request.connectionId);
|
|
38
|
-
connection.setRemoteDescription(request.description, 'offer');
|
|
39
|
-
return {};
|
|
40
|
-
}
|
|
41
|
-
async rtcAnswer(request, context) {
|
|
42
|
-
const remotePeerDescriptor = context.incomingSourceDescriptor;
|
|
43
|
-
const nodeId = (0, identifiers_1.toNodeId)(remotePeerDescriptor);
|
|
44
|
-
const connection = this.options.ongoingConnectAttempts.get(nodeId)?.connection;
|
|
45
|
-
if (!connection) {
|
|
46
|
-
return {};
|
|
47
|
-
}
|
|
48
|
-
else if (connection.connectionId !== request.connectionId) {
|
|
49
|
-
logger.trace(`Ignoring RTC answer due to connectionId mismatch`);
|
|
50
|
-
return {};
|
|
51
|
-
}
|
|
52
|
-
connection.setRemoteDescription(request.description, 'answer');
|
|
53
|
-
return {};
|
|
54
|
-
}
|
|
55
|
-
async iceCandidate(request, context) {
|
|
56
|
-
const remotePeerDescriptor = context.incomingSourceDescriptor;
|
|
57
|
-
const nodeId = (0, identifiers_1.toNodeId)(remotePeerDescriptor);
|
|
58
|
-
const connection = this.options.ongoingConnectAttempts.get(nodeId)?.connection;
|
|
59
|
-
if (!connection) {
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
else if (connection.connectionId !== request.connectionId) {
|
|
63
|
-
logger.trace(`Ignoring remote candidate due to connectionId mismatch`);
|
|
64
|
-
return {};
|
|
65
|
-
}
|
|
66
|
-
else if (this.isIceCandidateAllowed(request.candidate)) {
|
|
67
|
-
connection.addRemoteCandidate(request.candidate, request.mid);
|
|
68
|
-
}
|
|
69
|
-
return {};
|
|
70
|
-
}
|
|
71
|
-
isIceCandidateAllowed(candidate) {
|
|
72
|
-
if (!this.options.allowPrivateAddresses) {
|
|
73
|
-
const address = (0, AddressTools_1.getAddressFromIceCandidate)(candidate);
|
|
74
|
-
if ((address !== undefined) && (0, AddressTools_1.isPrivateIPv4)(address)) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.WebrtcConnectorRpcLocal = WebrtcConnectorRpcLocal;
|
|
82
|
-
//# sourceMappingURL=WebrtcConnectorRpcLocal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebrtcConnectorRpcLocal.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnectorRpcLocal.ts"],"names":[],"mappings":";;;AACA,0CAAuC;AACvC,6DAAsF;AAYtF,mDAAwD;AAKxD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAYjC,MAAa,uBAAuB;IAEf,OAAO,CAAgC;IAExD,YAAY,OAAuC;QAC/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAC1B,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,OAA0B;QAC9C,MAAM,oBAAoB,GAAI,OAA0B,CAAC,wBAAyB,CAAA;QAClF,IAAI,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAA,sBAAQ,EAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC;YAC1E,OAAO,EAAE,CAAA;QACb,CAAC;QACD,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAoB,EAAE,KAAK,CAAC,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CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC;YACtC,MAAM,OAAO,GAAG,IAAA,yCAA0B,EAAC,SAAS,CAAC,CAAA;YACrD,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,IAAI,IAAA,4BAAa,EAAC,OAAO,CAAC,EAAE,CAAC;gBACpD,OAAO,KAAK,CAAA;YAChB,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AA5ED,0DA4EC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RpcRemote } from '../../dht/contact/RpcRemote';
|
|
2
|
-
import { WebrtcConnectorRpcClient } from '../../../generated/packages/dht/protos/DhtRpc.client';
|
|
3
|
-
export declare class WebrtcConnectorRpcRemote extends RpcRemote<WebrtcConnectorRpcClient> {
|
|
4
|
-
requestConnection(): void;
|
|
5
|
-
sendRtcOffer(description: string, connectionId: string): void;
|
|
6
|
-
sendRtcAnswer(description: string, connectionId: string): void;
|
|
7
|
-
sendIceCandidate(candidate: string, mid: string, connectionId: string): void;
|
|
8
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebrtcConnectorRpcRemote = void 0;
|
|
4
|
-
const utils_1 = require("@streamr/utils");
|
|
5
|
-
const RpcRemote_1 = require("../../dht/contact/RpcRemote");
|
|
6
|
-
const logger = new utils_1.Logger(module);
|
|
7
|
-
class WebrtcConnectorRpcRemote extends RpcRemote_1.RpcRemote {
|
|
8
|
-
requestConnection() {
|
|
9
|
-
const request = {};
|
|
10
|
-
const options = this.formDhtRpcOptions({
|
|
11
|
-
notification: true
|
|
12
|
-
});
|
|
13
|
-
this.getClient().requestConnection(request, options).catch((_e) => {
|
|
14
|
-
logger.trace('Failed to send requestConnection');
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
sendRtcOffer(description, connectionId) {
|
|
18
|
-
const request = {
|
|
19
|
-
connectionId,
|
|
20
|
-
description
|
|
21
|
-
};
|
|
22
|
-
const options = this.formDhtRpcOptions();
|
|
23
|
-
this.getClient().rtcOffer(request, options).catch((_e) => {
|
|
24
|
-
logger.trace('Failed to send rtcOffer');
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
sendRtcAnswer(description, connectionId) {
|
|
28
|
-
const request = {
|
|
29
|
-
connectionId,
|
|
30
|
-
description
|
|
31
|
-
};
|
|
32
|
-
const options = this.formDhtRpcOptions();
|
|
33
|
-
this.getClient().rtcAnswer(request, options).catch((_e) => {
|
|
34
|
-
logger.trace('Failed to send rtcAnswer');
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
sendIceCandidate(candidate, mid, connectionId) {
|
|
38
|
-
const request = {
|
|
39
|
-
connectionId,
|
|
40
|
-
mid,
|
|
41
|
-
candidate
|
|
42
|
-
};
|
|
43
|
-
const options = this.formDhtRpcOptions();
|
|
44
|
-
this.getClient().iceCandidate(request, options).catch((_e) => {
|
|
45
|
-
logger.trace('Failed to send iceCandidate');
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.WebrtcConnectorRpcRemote = WebrtcConnectorRpcRemote;
|
|
50
|
-
//# sourceMappingURL=WebrtcConnectorRpcRemote.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebrtcConnectorRpcRemote.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnectorRpcRemote.ts"],"names":[],"mappings":";;;AAAA,0CAAuC;AACvC,2DAAuD;AASvD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,wBAAyB,SAAQ,qBAAmC;IAE7E,iBAAiB;QACb,MAAM,OAAO,GAA4B,EACxC,CAAA;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC;YACnC,YAAY,EAAE,IAAI;SACrB,CAAC,CAAA;QACF,IAAI,CA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C,CAAA;QAC/C,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AA9CD,4DA8CC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.iceServerAsString = iceServerAsString;
|
|
4
|
-
function iceServerAsString({ url, port, username, password, tcp }) {
|
|
5
|
-
const [protocol, hostname] = url.split(':');
|
|
6
|
-
if (hostname === undefined) {
|
|
7
|
-
throw new Error(`invalid stun/turn format: ${url}`);
|
|
8
|
-
}
|
|
9
|
-
if (username === undefined && password === undefined) {
|
|
10
|
-
return `${protocol}:${hostname}:${port}`;
|
|
11
|
-
}
|
|
12
|
-
if (username !== undefined && password !== undefined) {
|
|
13
|
-
return `${protocol}:${username}:${password}@${hostname}:${port}${(tcp !== undefined) ? '?transport=tcp' : ''}`;
|
|
14
|
-
}
|
|
15
|
-
throw new Error(`username (${username}) and password (${password}) must be supplied together`);
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=iceServerAsString.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"iceServerAsString.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/iceServerAsString.ts"],"names":[],"mappings":";;AAEA,8CAYC;AAZD,SAAgB,iBAAiB,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAa;IAC/E,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC3C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,EAAE,CAAC,CAAA;IACvD,CAAC;IACD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACnD,OAAO,GAAG,QAAQ,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAA;IAC5C,CAAC;IACD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACnD,OAAO,GAAG,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,IAAI,GAAG,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;IAClH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,aAAa,QAAQ,mBAAmB,QAAQ,6BAA6B,CAAC,CAAA;AAClG,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import EventEmitter from 'eventemitter3';
|
|
2
|
-
import { ConnectionEvents, ConnectionID, ConnectionType, IConnection } from '../IConnection';
|
|
3
|
-
export interface Socket {
|
|
4
|
-
binaryType: string;
|
|
5
|
-
readyState: number;
|
|
6
|
-
close(code?: number, reason?: string): void;
|
|
7
|
-
send(data: string | Buffer | ArrayBuffer | ArrayBufferView): void;
|
|
8
|
-
}
|
|
9
|
-
export declare const GOING_AWAY = 1001;
|
|
10
|
-
export declare const CUSTOM_GOING_AWAY = 3001;
|
|
11
|
-
export declare abstract class AbstractWebsocketClientConnection extends EventEmitter<ConnectionEvents> implements IConnection {
|
|
12
|
-
readonly connectionId: ConnectionID;
|
|
13
|
-
protected abstract socket?: Socket;
|
|
14
|
-
connectionType: ConnectionType;
|
|
15
|
-
protected destroyed: boolean;
|
|
16
|
-
constructor();
|
|
17
|
-
abstract connect(address: string, allowSelfSignedCertificate: boolean): void;
|
|
18
|
-
protected abstract stopListening(): void;
|
|
19
|
-
send(data: Uint8Array): void;
|
|
20
|
-
close(gracefulLeave: boolean): Promise<void>;
|
|
21
|
-
destroy(): void;
|
|
22
|
-
protected onOpen(): void;
|
|
23
|
-
protected onMessage(message: Uint8Array): void;
|
|
24
|
-
protected onClose(code: number, reason: string): void;
|
|
25
|
-
protected onError(error: Error): void;
|
|
26
|
-
protected doDisconnect(code?: number, reason?: string): void;
|
|
27
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
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.AbstractWebsocketClientConnection = exports.CUSTOM_GOING_AWAY = exports.GOING_AWAY = void 0;
|
|
7
|
-
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
8
|
-
const Connection_1 = require("../Connection");
|
|
9
|
-
const IConnection_1 = require("../IConnection");
|
|
10
|
-
const utils_1 = require("@streamr/utils");
|
|
11
|
-
// https://kapeli.com/cheat_sheets/WebSocket_Status_Codes.docset/Contents/Resources/Documents/index
|
|
12
|
-
// Browsers send this automatically when closing a tab
|
|
13
|
-
exports.GOING_AWAY = 1001;
|
|
14
|
-
// The GOING_AWAY is a reserved code and we shouldn't send that from the application. Therefore
|
|
15
|
-
// we have a custom counterpart
|
|
16
|
-
exports.CUSTOM_GOING_AWAY = 3001;
|
|
17
|
-
// https://github.com/websockets/ws/blob/master/doc/ws.md#ready-state-constants
|
|
18
|
-
const OPEN = 1;
|
|
19
|
-
const logger = new utils_1.Logger(module);
|
|
20
|
-
class AbstractWebsocketClientConnection extends eventemitter3_1.default {
|
|
21
|
-
connectionId;
|
|
22
|
-
connectionType = IConnection_1.ConnectionType.WEBSOCKET_CLIENT;
|
|
23
|
-
destroyed = false;
|
|
24
|
-
constructor() {
|
|
25
|
-
super();
|
|
26
|
-
this.connectionId = (0, Connection_1.createRandomConnectionId)();
|
|
27
|
-
}
|
|
28
|
-
send(data) {
|
|
29
|
-
if (!this.destroyed) {
|
|
30
|
-
if (this.socket?.readyState === OPEN) {
|
|
31
|
-
logger.trace(`Sending data with size ${data.byteLength}`);
|
|
32
|
-
this.socket?.send(data);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
// Could this throw for faster feedback on RPC calls?
|
|
36
|
-
// Currently this log line is seen if a connection is closing but the disconnected event has not been emitted yet.
|
|
37
|
-
logger.debug('Tried to send data on a non-open connection', {
|
|
38
|
-
id: this.connectionId,
|
|
39
|
-
readyState: this.socket.readyState,
|
|
40
|
-
destroyed: this.destroyed
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
logger.debug('Tried to send() on stopped connection');
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
async close(gracefulLeave) {
|
|
49
|
-
this.emit('disconnected', gracefulLeave, undefined, 'close() called');
|
|
50
|
-
this.removeAllListeners();
|
|
51
|
-
if (!this.destroyed) {
|
|
52
|
-
logger.trace(`Closing socket for connection ${this.connectionId}`);
|
|
53
|
-
this.socket?.close(gracefulLeave ? exports.CUSTOM_GOING_AWAY : undefined);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
logger.debug('Tried to close() a stopped connection', { id: this.connectionId });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
destroy() {
|
|
60
|
-
logger.trace('destroy() a connection');
|
|
61
|
-
if (!this.destroyed) {
|
|
62
|
-
this.removeAllListeners();
|
|
63
|
-
if (this.socket) {
|
|
64
|
-
this.stopListening();
|
|
65
|
-
this.socket.close();
|
|
66
|
-
this.socket = undefined;
|
|
67
|
-
}
|
|
68
|
-
this.destroyed = true;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
logger.debug('Tried to destroy() a stopped connection');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
onOpen() {
|
|
75
|
-
if (!this.destroyed) {
|
|
76
|
-
logger.trace('WebSocket Client Connected');
|
|
77
|
-
if (this.socket?.readyState === OPEN) {
|
|
78
|
-
this.emit('connected');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
onMessage(message) {
|
|
83
|
-
this.emit('data', message);
|
|
84
|
-
}
|
|
85
|
-
onClose(code, reason) {
|
|
86
|
-
if (!this.destroyed) {
|
|
87
|
-
logger.trace('Websocket Closed');
|
|
88
|
-
this.doDisconnect(code, reason);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
onError(error) {
|
|
92
|
-
if (!this.destroyed) {
|
|
93
|
-
logger.trace('WebSocket Client error: ' + error?.message, { error });
|
|
94
|
-
this.emit('error', error.name);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
doDisconnect(code, reason) {
|
|
98
|
-
this.destroyed = true;
|
|
99
|
-
this.stopListening();
|
|
100
|
-
this.socket = undefined;
|
|
101
|
-
const gracefulLeave = (code === exports.GOING_AWAY) || (code === exports.CUSTOM_GOING_AWAY);
|
|
102
|
-
this.emit('disconnected', gracefulLeave, code, reason);
|
|
103
|
-
this.removeAllListeners();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.AbstractWebsocketClientConnection = AbstractWebsocketClientConnection;
|
|
107
|
-
//# sourceMappingURL=AbstractWebsocketClientConnection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractWebsocketClientConnection.js","sourceRoot":"","sources":["../../../../src/connection/websocket/AbstractWebsocketClientConnection.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAwC;AACxC,8CAAwD;AACxD,gDAA4F;AAC5F,0CAAuC;AASvC,mGAAmG;AACnG,sDAAsD;AACzC,QAAA,UAAU,GAAG,IAAI,CAAA;AAC9B,+FAA+F;AAC/F,+BAA+B;AAClB,QAAA,iBAAiB,GAAG,IAAI,CAAA;AACrC,+EAA+E;AAC/E,MAAM,IAAI,GAAG,CAAC,CAAA;AAEd,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAsB,iCAAkC,SAAQ,uBAA8B;IAE1E,YAAY,CAAc;IAEnC,cAAc,GAAG,4BAAc,CAAC,gBAAgB,CAAA;IAC7C,SAAS,GAAG,KAAK,CAAA;IAE3B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