Skip to content

Commit

Permalink
Merge branch 'main' into user-id-as-UInt8Array
Browse files Browse the repository at this point in the history
  • Loading branch information
teogeb committed Oct 22, 2024
2 parents 91be96b + cc99d39 commit 7940ee9
Show file tree
Hide file tree
Showing 25 changed files with 204 additions and 509 deletions.
589 changes: 161 additions & 428 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
"packages/cli-tools"
],
"dependencies": {
"@manypkg/cli": "^0.21.2",
"@manypkg/cli": "^0.22.0",
"@protobuf-ts/plugin": "^2.9.3",
"@stylistic/eslint-plugin": "^2.9.0",
"@tsconfig/node18": "^18.2.4",
"@types/jest": "^29.5.13",
"@types/node": "^18.19.55",
"@types/node": "^18.19.57",
"@typescript-eslint/eslint-plugin": "8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"cli-table": "^0.3.6",
Expand Down
3 changes: 2 additions & 1 deletion packages/autocertifier-client/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/**
dist/**
.idea/**
src/proto/**
generated/**

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.1 with parameter server_generic,generate_dependencies,long_type_number
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
// @generated from protobuf file "packages/autocertifier-client/protos/AutoCertifier.proto" (syntax proto3)
// tslint:disable
import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.1 with parameter server_generic,generate_dependencies,long_type_number
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
// @generated from protobuf file "packages/autocertifier-client/protos/AutoCertifier.proto" (syntax proto3)
// tslint:disable
import { HasSessionResponse } from "./AutoCertifier";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.9.1 with parameter server_generic,generate_dependencies,long_type_number
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
// @generated from protobuf file "packages/autocertifier-client/protos/AutoCertifier.proto" (syntax proto3)
// tslint:disable
import { ServiceType } from "@protobuf-ts/runtime-rpc";
Expand Down
4 changes: 2 additions & 2 deletions packages/autocertifier-client/proto.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mkdir -p ./src/proto
npx protoc --ts_out ./src/proto --ts_opt server_generic,generate_dependencies,long_type_number --proto_path ../.. packages/autocertifier-client/protos/AutoCertifier.proto
mkdir -p ./generated
npx protoc --ts_out ./generated --ts_opt server_generic,generate_dependencies,long_type_number --proto_path ../.. packages/autocertifier-client/protos/AutoCertifier.proto
4 changes: 2 additions & 2 deletions packages/autocertifier-client/src/AutoCertifierClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEmitter } from 'eventemitter3'
import { IAutoCertifierRpc } from './proto/packages/autocertifier-client/protos/AutoCertifier.server'
import { HasSessionRequest, HasSessionResponse } from './proto/packages/autocertifier-client/protos/AutoCertifier'
import { IAutoCertifierRpc } from '../generated/packages/autocertifier-client/protos/AutoCertifier.server'
import { HasSessionRequest, HasSessionResponse } from '../generated/packages/autocertifier-client/protos/AutoCertifier'
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
import { filePathToNodeFormat, Logger } from '@streamr/utils'
import { RestClient } from './RestClient'
Expand Down
4 changes: 2 additions & 2 deletions packages/autocertifier-client/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export { InvalidSubdomainOrToken } from './errors'
export { FailedToConnectToStreamrWebSocket } from './errors'
export { ErrorCode } from './errors'
export { Err } from './errors'
export { HasSessionRequest, HasSessionResponse } from './proto/packages/autocertifier-client/protos/AutoCertifier'
export { AutoCertifierRpcClient } from './proto/packages/autocertifier-client/protos/AutoCertifier.client'
export { HasSessionRequest, HasSessionResponse } from '../generated/packages/autocertifier-client/protos/AutoCertifier'
export { AutoCertifierRpcClient } from '../generated/packages/autocertifier-client/protos/AutoCertifier.client'
export { createSelfSignedCertificate } from './createSelfSignedCertificate'
1 change: 1 addition & 0 deletions packages/autocertifier-client/tsconfig.browser.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"include": [
"src/**/*",
"generated/**/*",
"test/**/*"
],
}
1 change: 1 addition & 0 deletions packages/autocertifier-client/tsconfig.jest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.jest.json",
"include": [
"src/**/*",
"generated/**/*",
"test/**/*"
],
"references": [
Expand Down
3 changes: 2 additions & 1 deletion packages/autocertifier-client/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"noImplicitOverride": false
},
"include": [
"src/**/*"
"src/**/*",
"generated/**/*"
],
"references": [
{ "path": "../utils/tsconfig.node.json" },
Expand Down
2 changes: 1 addition & 1 deletion packages/autocertifier-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test-integration": "jest test/integration"
},
"dependencies": {
"@aws-sdk/client-route-53": "^3.670.0",
"@aws-sdk/client-route-53": "^3.675.0",
"@streamr/autocertifier-client": "102.0.0-beta.0",
"@streamr/dht": "102.0.0-beta.0",
"@streamr/proto-rpc": "102.0.0-beta.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"devDependencies": {
"@streamr/test-utils": "102.0.0-beta.0",
"@types/event-stream": "^4.0.5",
"@types/lodash": "^4.17.10",
"@types/lodash": "^4.17.12",
"@types/merge2": "^1.4.4",
"merge2": "^1.4.1"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dht/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@streamr/test-utils": "102.0.0-beta.0",
"@types/heap": "^0.2.34",
"@types/k-bucket": "^5.0.1",
"@types/lodash": "^4.17.10",
"@types/lodash": "^4.17.12",
"@types/uuid": "^10.0.0",
"@types/websocket": "^1.0.10",
"@types/ws": "^8.5.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/heap": "^0.2.34",
"@types/lodash": "^4.17.10",
"@types/lodash": "^4.17.12",
"@types/merge2": "^1.4.4",
"@types/node-fetch": "^2.6.4",
"@types/qs": "^6.9.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/proto-rpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"devDependencies": {
"@streamr/browser-test-runner": "^0.0.1",
"@streamr/test-utils": "102.0.0-beta.0",
"@types/lodash": "^4.17.10",
"@types/lodash": "^4.17.12",
"@types/uuid": "^10.0.0"
},
"optionalDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@jest/globals": "^29.7.0",
"@streamr/test-utils": "102.0.0-beta.0",
"@types/heap": "^0.2.34",
"@types/lodash": "^4.17.10",
"@types/lodash": "^4.17.12",
"@types/node-fetch": "^2.6.4",
"@types/uuid": "^10.0.0",
"ajv": "^8.17.1",
Expand Down Expand Up @@ -86,7 +86,7 @@
"@babel/runtime": "^7.25.7",
"@babel/runtime-corejs3": "^7.25.7",
"@lit-protocol/core": "2.2.5",
"@lit-protocol/uint8arrays": "^6.10.0",
"@lit-protocol/uint8arrays": "^6.11.0",
"@protobuf-ts/runtime": "^2.8.2",
"@protobuf-ts/runtime-rpc": "^2.8.2",
"@streamr/config": "^5.4.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/trackerless-network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"devDependencies": {
"@streamr/browser-test-runner": "^0.0.1",
"@types/lodash": "^4.17.10",
"@types/lodash": "^4.17.12",
"@types/uuid": "^10.0.0",
"@types/yallist": "^4.0.1",
"expect": "^29.6.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ describe('Proxy connections', () => {
}
})
await proxyNode1.start()
proxyNode1.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor1])
proxyNode1.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
proxyNode2 = createNetworkNode({
layer0: {
Expand All @@ -92,7 +91,6 @@ describe('Proxy connections', () => {
}
})
await proxyNode2.start()
proxyNode2.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor1])
proxyNode2.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
proxiedNode = createNetworkNode({
layer0: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ describe('proxy group key exchange', () => {
}
})
await proxyNode.start()
proxyNode.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor])
proxyNode.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
publisher = createNetworkNode({
layer0: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('Full node network with WebRTC connections', () => {
}
})
await entryPoint.start()
entryPoint.getContentDeliveryManager().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
entryPoint.getContentDeliveryManager().joinStreamPart(streamPartId)

await Promise.all(range(NUM_OF_NODES).map(async () => {
Expand All @@ -45,7 +44,6 @@ describe('Full node network with WebRTC connections', () => {
})
nodes.push(node)
await node.start()
node.getContentDeliveryManager().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
node.getContentDeliveryManager().joinStreamPart(streamPartId)
}))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe('Full node network with WebSocket connections only', () => {
}
})
await entryPoint.start()
entryPoint.getContentDeliveryManager().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
entryPoint.getContentDeliveryManager().joinStreamPart(streamPartId)

await Promise.all(range(NUM_OF_NODES).map(async (i) => {
Expand All @@ -43,7 +42,6 @@ describe('Full node network with WebSocket connections only', () => {
})
nodes.push(node)
await node.start()
node.getContentDeliveryManager().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
node.getContentDeliveryManager().joinStreamPart(streamPartId)
}))

Expand Down
63 changes: 14 additions & 49 deletions packages/trackerless-network/test/integration/Handshakes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import {
} from '@streamr/dht'
import { StreamPartIDUtils } from '@streamr/utils'
import { NodeList } from '../../src/logic/NodeList'
import { HandshakeRpcRemote } from '../../src/logic/neighbor-discovery/HandshakeRpcRemote'
import { Handshaker } from '../../src/logic/neighbor-discovery/Handshaker'
import { StreamPartHandshakeRequest, StreamPartHandshakeResponse } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
import {
HandshakeRpcClient
} from '../../generated/packages/trackerless-network/protos/NetworkRpc.client'
import { ContentDeliveryRpcClient } from '../../generated/packages/trackerless-network/protos/NetworkRpc.client'
import { ContentDeliveryRpcRemote } from '../../src/logic/ContentDeliveryRpcRemote'

describe('Handshakes', () => {

Expand Down Expand Up @@ -86,6 +84,12 @@ describe('Handshakes', () => {
leftNodeView = new NodeList(handshakerNodeId, 10)
rightNodeView = new NodeList(handshakerNodeId, 10)
nodeView = new NodeList(handshakerNodeId, 10)
nodeView.add(new ContentDeliveryRpcRemote(
peerDescriptor2,
peerDescriptor1,
rpcCommunicator2,
ContentDeliveryRpcClient
))
neighbors = new NodeList(handshakerNodeId, 4)
handshaker = new Handshaker({
localPeerDescriptor: peerDescriptor2,
Expand All @@ -112,64 +116,25 @@ describe('Handshakes', () => {
simulator.stop()
})

it('Two nodes can handshake', async () => {
rpcCommunicator1.registerRpcMethod(StreamPartHandshakeRequest, StreamPartHandshakeResponse, 'handshake', acceptHandshake)
// @ts-expect-error private
const res = await handshaker.handshakeWithTarget(
new HandshakeRpcRemote(
peerDescriptor2,
peerDescriptor1,
rpcCommunicator2,
HandshakeRpcClient
)
)
expect(res).toEqual(true)
expect(neighbors.has(toNodeId(peerDescriptor1))).toEqual(true)
})

it('Handshake accepted', async () => {
rpcCommunicator1.registerRpcMethod(StreamPartHandshakeRequest, StreamPartHandshakeResponse, 'handshake', acceptHandshake)
// @ts-expect-error private
const res = await handshaker.handshakeWithTarget(
new HandshakeRpcRemote(
peerDescriptor2,
peerDescriptor1,
rpcCommunicator2,
HandshakeRpcClient
)
)
expect(res).toEqual(true)
const res = await handshaker.attemptHandshakesOnContacts([])
expect(res).toHaveLength(0)
expect(neighbors.has(toNodeId(peerDescriptor1))).toEqual(true)
})

it('Handshake rejected', async () => {
rpcCommunicator1.registerRpcMethod(StreamPartHandshakeRequest, StreamPartHandshakeResponse, 'handshake', rejectHandshake)
// @ts-expect-error private
const res = await handshaker.handshakeWithTarget(
new HandshakeRpcRemote(
peerDescriptor2,
peerDescriptor1,
rpcCommunicator2,
HandshakeRpcClient
)
)
expect(res).toEqual(false)
const res = await handshaker.attemptHandshakesOnContacts([])
expect(res[0]).toEqual(toNodeId(peerDescriptor1))
expect(neighbors.has(toNodeId(peerDescriptor1))).toEqual(false)
})

it('Handshake with Interleaving', async () => {
rpcCommunicator1.registerRpcMethod(StreamPartHandshakeRequest, StreamPartHandshakeResponse, 'handshake', interleavingHandshake)
rpcCommunicator3.registerRpcMethod(StreamPartHandshakeRequest, StreamPartHandshakeResponse, 'handshake', acceptHandshake)
// @ts-expect-error private
const res = await handshaker.handshakeWithTarget(
new HandshakeRpcRemote(
peerDescriptor2,
peerDescriptor1,
rpcCommunicator2,
HandshakeRpcClient
)
)
expect(res).toEqual(true)
const res = await handshaker.attemptHandshakesOnContacts([])
expect(res).toHaveLength(0)
expect(neighbors.has(toNodeId(peerDescriptor1))).toEqual(true)
expect(neighbors.has(toNodeId(peerDescriptor3))).toEqual(true)
})
Expand Down
8 changes: 4 additions & 4 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
"dependencies": {
"eventemitter3": "^5.0.0",
"lodash": "^4.17.21",
"pino": "^9.4.0",
"pino-pretty": "^11.2.2",
"secp256k1": "^5.0.0",
"pino": "^9.5.0",
"pino-pretty": "^11.3.0",
"secp256k1": "^5.0.1",
"sha3": "^2.1.4"
},
"devDependencies": {
"@streamr/browser-test-runner": "^0.0.1",
"@types/lodash": "^4.17.10",
"@types/lodash": "^4.17.12",
"@types/node-fetch": "^2.6.4",
"@types/secp256k1": "^4.0.6",
"node-fetch": "^2.7.0"
Expand Down

0 comments on commit 7940ee9

Please sign in to comment.