├── .eslintrc ├── .eslintignore ├── tsconfig-build.json ├── src ├── types │ └── speedometer │ │ └── index.d.ts ├── logic │ ├── RtcMessage.ts │ ├── StorageConfig.ts │ ├── InstructionCounter.ts │ ├── LocationManager.ts │ ├── InstructionRetryManager.ts │ ├── rtcSignallingHandlers.ts │ ├── trackerSummaryUtils.ts │ ├── InstructionThrottler.ts │ └── PerStreamMetrics.ts ├── helpers │ ├── MessageEncoder.ts │ ├── PromiseTools.ts │ ├── SeenButNotPropagatedSet.ts │ ├── MessageBuffer.ts │ ├── Logger.ts │ └── MetricsContext.ts ├── NameDirectory.ts ├── resend │ └── proxyRequestStream.ts ├── connection │ ├── PeerBook.ts │ ├── IWebRtcEndpoint.ts │ ├── IWsEndpoint.ts │ ├── MessageQueue.ts │ └── NegotiatedProtocolVersions.ts ├── identifiers.ts └── NetworkNode.ts ├── .idea ├── codeStyles │ ├── codeStyleConfig.xml │ └── Project.xml ├── encodings.xml ├── vcs.xml ├── misc.xml ├── modules.xml ├── jsLibraryMappings.xml ├── inspectionProfiles │ └── Project_Default.xml ├── runConfigurations │ ├── subscriber__30335_.xml │ ├── subscriber__30345_.xml │ ├── test.xml │ ├── tracker__30300_.xml │ ├── run_network.xml │ ├── publisher__30308_.xml │ ├── publisher__30309_.xml │ ├── unit_test.xml │ ├── integration_test.xml │ └── test__disable_parallel_.xml └── network.iml ├── typedoc.js ├── .npmignore ├── .gitignore ├── examples └── system-metrics-pubsub │ ├── tsconfig.json │ ├── package.json │ ├── README.md │ ├── subscriber.ts │ └── index.ts ├── test ├── unit │ ├── NameDirectory.test.ts │ ├── SeenButNotPropagatedSet.test.ts │ ├── NumberPair.test.ts │ ├── encoder.test.ts │ ├── TrackerServer.test.ts │ ├── trackerSummaryUtils.test.ts │ ├── NegotiatedProtocolVersions.test.ts │ ├── MessageQueue.test.ts │ ├── PeerInfo.test.ts │ ├── proxyRequestStream.test.ts │ ├── Logger.test.ts │ ├── PerStreamMetrics.test.ts │ ├── QueueItem.test.ts │ ├── InstructionThrottler.test.ts │ └── LocationManager.test.ts ├── integration │ ├── MockStorageConfig.ts │ ├── passing-address-between-ws-endpoints.test.ts │ ├── duplicate-connections-are-closed.test.ts │ ├── ws-endpoint-back-pressure-handling.test.ts │ ├── tracker-storage-nodes-response-does-not-contain-self.test.ts │ ├── nodeMessageBuffering.test.ts │ ├── killing-dead-connections.test.ts │ ├── network-stabilization.test.ts │ ├── latency.test.ts │ ├── unsubscribe-from-stream.test.ts │ ├── tracker-node-reconnect-instructions.test.ts │ ├── webrtc-endpoint-back-pressure-handling.test.ts │ ├── webrtc-multi-signaller.test.ts │ ├── do-not-propagate-to-sender-optimization.test.ts │ ├── storage-config.test.ts │ ├── resend-request-on-streams-with-no-activity.test.ts │ ├── tracker-instructions.test.ts │ ├── l1-resend-requests.test.ts │ ├── request-resend-from-uninvolved-node.test.ts │ └── ws-endpoint.test.ts ├── benchmarks │ ├── overlay-topology-performance.ts │ ├── overlay-topology-randomness.ts │ └── tracker.instructions.ts └── fixtures │ ├── cert.pem │ └── key.pem ├── tsconfig.json ├── .github └── workflows │ ├── docs.yml │ └── nodejs.yml ├── jest.config.js ├── bin ├── network.js ├── tracker.js ├── subscriber.js └── publisher.js ├── package.json ├── LICENSE └── README.md /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint-config-streamr-ts" 3 | } 4 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/** 2 | examples/** 3 | coverage/** 4 | dist/** -------------------------------------------------------------------------------- /tsconfig-build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": [ 4 | "src/**/*" 5 | ] 6 | } -------------------------------------------------------------------------------- /src/types/speedometer/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'speedometer' { 2 | export default function speedometer(seconds?: number): (delta?: number) => number 3 | } 4 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /typedoc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | entryPoints: [ 3 | 'src/composition.ts', 4 | ], 5 | tsconfig: 'tsconfig.json', 6 | excludeInternal: true, 7 | includeVersion: true, 8 | } 9 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .codedeploy 2 | .eslintignore 3 | .eslintrc.js 4 | examples 5 | .github 6 | .idea 7 | jest.config.js 8 | .npmrc 9 | src 10 | test 11 | .travis.yml 12 | tsconfig.json 13 | *.tsbuildinfo 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | 4 | # IntelliJ IDEA 5 | .idea/workspace.xml 6 | .idea/tasks.xml 7 | .idea/dictionaries 8 | .idea/httpRequests 9 | .idea/git_toolbox_prj.xml 10 | bin/.idea 11 | 12 | .DS_Store 13 | docs 14 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /src/logic/RtcMessage.ts: -------------------------------------------------------------------------------- 1 | export enum RtcSubTypes { 2 | LOCAL_DESCRIPTION = 'localDescription', 3 | LOCAL_CANDIDATE = 'localCandidate', 4 | RTC_CONNECT = 'rtcConnect', 5 | RTC_OFFER = 'rtcOffer', 6 | RTC_ANSWER = 'rtcAnswer', 7 | REMOTE_CANDIDATE = 'remoteCandidate' 8 | } -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/jsLibraryMappings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/system-metrics-pubsub/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "lib": ["es6"], 6 | "allowJs": true, 7 | "outDir": "dist", 8 | "rootDir": ".", 9 | "strict": true, 10 | "esModuleInterop": true, 11 | "noImplicitAny": true, 12 | "resolveJsonModule": true 13 | }, 14 | "exclude": [ 15 | "dist" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /src/logic/StorageConfig.ts: -------------------------------------------------------------------------------- 1 | import { StreamIdAndPartition } from '../identifiers' 2 | 3 | export interface ChangeListener { 4 | onStreamAdded: (stream: StreamIdAndPartition) => void 5 | onStreamRemoved: (stream: StreamIdAndPartition) => void 6 | } 7 | 8 | export interface StorageConfig { 9 | getStreams: () => StreamIdAndPartition[] 10 | addChangeListener: (listener: ChangeListener) => void 11 | } -------------------------------------------------------------------------------- /test/unit/NameDirectory.test.ts: -------------------------------------------------------------------------------- 1 | import { NameDirectory } from '../../src/NameDirectory' 2 | 3 | describe('NameDirectory', () => { 4 | test('known', () => { 5 | expect(NameDirectory.getName('0xDE33390cC85aBf61d9c27715Fa61d8E5efC61e75')).toBe('T3') 6 | }) 7 | test('unknown', () => { 8 | expect(NameDirectory.getName('0x1234567890123456789012345678901234567890')).toBe('0x123456') 9 | }) 10 | }) -------------------------------------------------------------------------------- /src/helpers/MessageEncoder.ts: -------------------------------------------------------------------------------- 1 | export function decode(serializedMessage: M, deserializeFn: (serializedMessage: M) => R): R | null | never { 2 | try { 3 | return deserializeFn(serializedMessage) 4 | } catch (e) { 5 | // JSON parsing failed, version parse failed, type parse failed 6 | if (e.name === 'SyntaxError' || e.version != null || e.type != null) { 7 | return null 8 | } 9 | throw e 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "module": "commonjs", 5 | "lib": ["es2020"], 6 | "allowJs": true, 7 | "declaration": true, 8 | "outDir": "dist", 9 | "rootDirs": ["src", "test"], 10 | "strict": true, 11 | "esModuleInterop": true, 12 | "noImplicitAny": true, 13 | "resolveJsonModule": true, 14 | "incremental": true, 15 | "sourceMap": true 16 | }, 17 | "include": [ 18 | "src/**/*", 19 | "test/**/*" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /.idea/runConfigurations/subscriber__30335_.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |