@dxos/network-manager 0.8.4-main.84f28bd → 0.8.4-main.ae835ea
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/lib/browser/{chunk-HQNQOWFA.mjs → chunk-E3P563GT.mjs} +329 -230
- package/dist/lib/browser/chunk-E3P563GT.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +65 -46
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/transport/tcp/index.mjs +3 -5
- package/dist/lib/browser/transport/tcp/index.mjs.map +1 -1
- package/dist/lib/node-esm/{chunk-JPPMRZTH.mjs → chunk-PKBROUZV.mjs} +329 -230
- package/dist/lib/node-esm/chunk-PKBROUZV.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +65 -46
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/transport/tcp/index.mjs +8 -7
- package/dist/lib/node-esm/transport/tcp/index.mjs.map +2 -2
- package/dist/types/src/connection-log.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/network-manager.d.ts.map +1 -1
- package/dist/types/src/signal/index.d.ts +2 -2
- package/dist/types/src/signal/index.d.ts.map +1 -1
- package/dist/types/src/signal/swarm-messenger.d.ts +1 -1
- package/dist/types/src/signal/swarm-messenger.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts +2 -2
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/swarm/swarm.d.ts +3 -3
- package/dist/types/src/swarm/swarm.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts +1 -1
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-wire-protocol.d.ts +1 -1
- package/dist/types/src/testing/test-wire-protocol.d.ts.map +1 -1
- package/dist/types/src/tests/basic-test-suite.d.ts.map +1 -1
- package/dist/types/src/topology/index.d.ts +1 -1
- package/dist/types/src/topology/index.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc/rtc-peer-connection.d.ts +2 -2
- package/dist/types/src/transport/webrtc/rtc-peer-connection.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc/rtc-transport-channel.d.ts +1 -1
- package/dist/types/src/transport/webrtc/rtc-transport-channel.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc/rtc-transport-factory.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc/rtc-transport-service.d.ts +1 -1
- package/dist/types/src/transport/webrtc/rtc-transport-service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -29
- package/src/connection-log.ts +1 -1
- package/src/index.ts +1 -1
- package/src/network-manager.ts +1 -1
- package/src/signal/ice.test.ts +1 -1
- package/src/signal/index.ts +2 -2
- package/src/signal/integration.node.test.ts +2 -2
- package/src/signal/swarm-messenger.node.test.ts +1 -1
- package/src/signal/swarm-messenger.ts +1 -1
- package/src/swarm/connection.test.ts +2 -1
- package/src/swarm/connection.ts +4 -4
- package/src/swarm/peer.ts +3 -2
- package/src/swarm/swarm-mapper.ts +1 -1
- package/src/swarm/swarm.test.ts +5 -4
- package/src/swarm/swarm.ts +5 -4
- package/src/testing/test-builder.ts +12 -4
- package/src/testing/test-wire-protocol.ts +2 -2
- package/src/tests/basic-test-suite.ts +3 -2
- package/src/tests/memory-transport.test.ts +4 -2
- package/src/tests/tcp-transport.node.test.ts +4 -2
- package/src/tests/webrtc-transport.test.ts +2 -1
- package/src/topology/index.ts +1 -1
- package/src/transport/tcp/tcp-transport.ts +1 -1
- package/src/transport/webrtc/rtc-connection-factory.ts +1 -1
- package/src/transport/webrtc/rtc-peer-connection.ts +4 -3
- package/src/transport/webrtc/rtc-transport-channel.test.ts +3 -1
- package/src/transport/webrtc/rtc-transport-channel.ts +2 -1
- package/src/transport/webrtc/rtc-transport-factory.ts +3 -2
- package/src/transport/webrtc/rtc-transport-proxy.test.ts +5 -3
- package/src/transport/webrtc/rtc-transport-service.ts +6 -5
- package/src/transport/webrtc/rtc-transport.test.ts +4 -3
- package/dist/lib/browser/chunk-HQNQOWFA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JPPMRZTH.mjs.map +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/network-manager",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.ae835ea",
|
|
4
4
|
"description": "Network Manager",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"default": "node-datachannel/*"
|
|
21
21
|
},
|
|
22
22
|
"#tcp-transport": {
|
|
23
|
+
"source": "./src/transport/tcp/index.ts",
|
|
23
24
|
"types": "./dist/types/src/transport/tcp/index.d.ts",
|
|
24
25
|
"browser": "./dist/lib/browser/transport/tcp/index.mjs",
|
|
25
26
|
"node": "./dist/lib/node-esm/transport/tcp/index.mjs",
|
|
@@ -29,16 +30,19 @@
|
|
|
29
30
|
},
|
|
30
31
|
"exports": {
|
|
31
32
|
".": {
|
|
33
|
+
"source": "./src/index.ts",
|
|
32
34
|
"types": "./dist/types/src/index.d.ts",
|
|
33
35
|
"browser": "./dist/lib/browser/index.mjs",
|
|
34
36
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
35
37
|
},
|
|
36
38
|
"./testing": {
|
|
39
|
+
"source": "./src/testing/index.ts",
|
|
37
40
|
"types": "./dist/types/src/testing/index.d.ts",
|
|
38
41
|
"browser": "./dist/lib/browser/testing/index.mjs",
|
|
39
42
|
"node": "./dist/lib/node-esm/testing/index.mjs"
|
|
40
43
|
},
|
|
41
44
|
"./transport/tcp": {
|
|
45
|
+
"source": "./src/transport/tcp/index.ts",
|
|
42
46
|
"types": "./dist/types/src/transport/tcp/index.d.ts",
|
|
43
47
|
"browser": "./dist/lib/browser/transport/tcp/index.mjs",
|
|
44
48
|
"node": "./dist/lib/node-esm/transport/tcp/index.mjs"
|
|
@@ -66,37 +70,27 @@
|
|
|
66
70
|
"src"
|
|
67
71
|
],
|
|
68
72
|
"dependencies": {
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/messaging": "0.8.4-main.84f28bd",
|
|
85
|
-
"@dxos/node-std": "0.8.4-main.84f28bd",
|
|
86
|
-
"@dxos/protocols": "0.8.4-main.84f28bd",
|
|
87
|
-
"@dxos/teleport": "0.8.4-main.84f28bd",
|
|
88
|
-
"@dxos/rpc": "0.8.4-main.84f28bd",
|
|
89
|
-
"@dxos/tracing": "0.8.4-main.84f28bd",
|
|
90
|
-
"@dxos/util": "0.8.4-main.84f28bd"
|
|
73
|
+
"node-datachannel": "^0.30.0",
|
|
74
|
+
"@dxos/async": "0.8.4-main.ae835ea",
|
|
75
|
+
"@dxos/codec-protobuf": "0.8.4-main.ae835ea",
|
|
76
|
+
"@dxos/invariant": "0.8.4-main.ae835ea",
|
|
77
|
+
"@dxos/context": "0.8.4-main.ae835ea",
|
|
78
|
+
"@dxos/keys": "0.8.4-main.ae835ea",
|
|
79
|
+
"@dxos/debug": "0.8.4-main.ae835ea",
|
|
80
|
+
"@dxos/log": "0.8.4-main.ae835ea",
|
|
81
|
+
"@dxos/node-std": "0.8.4-main.ae835ea",
|
|
82
|
+
"@dxos/protocols": "0.8.4-main.ae835ea",
|
|
83
|
+
"@dxos/rpc": "0.8.4-main.ae835ea",
|
|
84
|
+
"@dxos/teleport": "0.8.4-main.ae835ea",
|
|
85
|
+
"@dxos/messaging": "0.8.4-main.ae835ea",
|
|
86
|
+
"@dxos/tracing": "0.8.4-main.ae835ea",
|
|
87
|
+
"@dxos/util": "0.8.4-main.ae835ea"
|
|
91
88
|
},
|
|
92
89
|
"devDependencies": {
|
|
93
|
-
"@swc-node/register": "1.9.1",
|
|
94
|
-
"@types/ws": "^7.4.0",
|
|
95
|
-
"fast-check": "^3.19.0",
|
|
96
90
|
"fetch-mock": "^11.0.0",
|
|
97
|
-
"@dxos/
|
|
98
|
-
"@dxos/
|
|
99
|
-
"@dxos/signal": "0.8.4-main.
|
|
91
|
+
"@dxos/keyring": "0.8.4-main.ae835ea",
|
|
92
|
+
"@dxos/edge-client": "0.8.4-main.ae835ea",
|
|
93
|
+
"@dxos/signal": "0.8.4-main.ae835ea"
|
|
100
94
|
},
|
|
101
95
|
"publishConfig": {
|
|
102
96
|
"access": "public"
|
package/src/connection-log.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Event } from '@dxos/async';
|
|
6
6
|
import { raise } from '@dxos/debug';
|
|
7
7
|
import { PublicKey } from '@dxos/keys';
|
|
8
|
-
import { type
|
|
8
|
+
import { type ConnectionInfo, type SwarmInfo } from '@dxos/protocols/proto/dxos/devtools/swarm';
|
|
9
9
|
import { type MuxerStats } from '@dxos/teleport';
|
|
10
10
|
import { ComplexMap } from '@dxos/util';
|
|
11
11
|
|
package/src/index.ts
CHANGED
package/src/network-manager.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { ComplexMap } from '@dxos/util';
|
|
|
13
13
|
|
|
14
14
|
import { ConnectionLog } from './connection-log';
|
|
15
15
|
import { type SignalConnection } from './signal';
|
|
16
|
-
import { Swarm, SwarmMapper
|
|
16
|
+
import { ConnectionLimiter, Swarm, SwarmMapper } from './swarm';
|
|
17
17
|
import { type Topology } from './topology';
|
|
18
18
|
import { type TransportFactory } from './transport';
|
|
19
19
|
import { type WireProtocolProvider } from './wire-protocol';
|
package/src/signal/ice.test.ts
CHANGED
package/src/signal/index.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { afterAll,
|
|
5
|
+
import { afterAll, beforeAll, describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { PublicKey } from '@dxos/keys';
|
|
8
8
|
import { Messenger, type PeerInfo, WebsocketSignalManager } from '@dxos/messaging';
|
|
9
|
-
import {
|
|
9
|
+
import { type SignalServerRunner, runTestSignalServer } from '@dxos/signal';
|
|
10
10
|
|
|
11
11
|
import { type SignalMessage } from './signal-messenger';
|
|
12
12
|
import { SwarmMessenger } from './swarm-messenger';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { afterAll, beforeAll, beforeEach, describe, expect,
|
|
5
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { type Awaited } from '@dxos/async';
|
|
8
8
|
import { PublicKey } from '@dxos/keys';
|
|
@@ -7,7 +7,7 @@ import { Context } from '@dxos/context';
|
|
|
7
7
|
import { invariant } from '@dxos/invariant';
|
|
8
8
|
import { PublicKey } from '@dxos/keys';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
|
-
import { type
|
|
10
|
+
import { type Message, type PeerInfo } from '@dxos/messaging';
|
|
11
11
|
import { TimeoutError } from '@dxos/protocols';
|
|
12
12
|
import { schema } from '@dxos/protocols/proto';
|
|
13
13
|
import { type Answer, type SwarmMessage } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
@@ -7,11 +7,12 @@ import { describe, test } from 'vitest';
|
|
|
7
7
|
import { sleep } from '@dxos/async';
|
|
8
8
|
import { PublicKey } from '@dxos/keys';
|
|
9
9
|
|
|
10
|
-
import { Connection } from './connection';
|
|
11
10
|
import { TestWireProtocol } from '../testing/test-wire-protocol';
|
|
12
11
|
import { createRtcTransportFactory } from '../transport';
|
|
13
12
|
import { chooseInitiatorPeer } from '../transport/webrtc/utils';
|
|
14
13
|
|
|
14
|
+
import { Connection } from './connection';
|
|
15
|
+
|
|
15
16
|
describe('Connection', () => {
|
|
16
17
|
test('responder opens after initiator', async () => {
|
|
17
18
|
const { initiator, responder } = createPeerKeys();
|
package/src/swarm/connection.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { DeferredTask, Event,
|
|
6
|
-
import { Context,
|
|
5
|
+
import { DeferredTask, Event, Trigger, scheduleTask, scheduleTaskInterval, sleep, synchronized } from '@dxos/async';
|
|
6
|
+
import { Context, ContextDisposedError, cancelWithContext } from '@dxos/context';
|
|
7
7
|
import { ErrorStream } from '@dxos/debug';
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
@@ -11,9 +11,9 @@ import { log, logInfo } from '@dxos/log';
|
|
|
11
11
|
import { type PeerInfo } from '@dxos/messaging';
|
|
12
12
|
import {
|
|
13
13
|
CancelledError,
|
|
14
|
-
ProtocolError,
|
|
15
14
|
ConnectionResetError,
|
|
16
15
|
ConnectivityError,
|
|
16
|
+
ProtocolError,
|
|
17
17
|
TimeoutError,
|
|
18
18
|
trace,
|
|
19
19
|
} from '@dxos/protocols';
|
|
@@ -414,7 +414,7 @@ export class Connection {
|
|
|
414
414
|
invariant(msg.author.peerKey === this.remoteInfo.peerKey);
|
|
415
415
|
invariant(msg.recipient.peerKey === this.localInfo.peerKey);
|
|
416
416
|
|
|
417
|
-
const signals = msg.data.signalBatch ? msg.data.signalBatch.signals ?? [] : [msg.data.signal];
|
|
417
|
+
const signals = msg.data.signalBatch ? (msg.data.signalBatch.signals ?? []) : [msg.data.signal];
|
|
418
418
|
for (const signal of signals) {
|
|
419
419
|
if (!signal) {
|
|
420
420
|
continue;
|
package/src/swarm/peer.ts
CHANGED
|
@@ -11,12 +11,13 @@ import { type PeerInfo } from '@dxos/messaging';
|
|
|
11
11
|
import { CancelledError, SystemError } from '@dxos/protocols';
|
|
12
12
|
import { type Answer } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
13
13
|
|
|
14
|
-
import { Connection, ConnectionState } from './connection';
|
|
15
|
-
import { type ConnectionLimiter } from './connection-limiter';
|
|
16
14
|
import { type OfferMessage, type SignalMessage, type SignalMessenger } from '../signal';
|
|
17
15
|
import { type TransportFactory } from '../transport';
|
|
18
16
|
import { type WireProtocolProvider } from '../wire-protocol';
|
|
19
17
|
|
|
18
|
+
import { Connection, ConnectionState } from './connection';
|
|
19
|
+
import { type ConnectionLimiter } from './connection-limiter';
|
|
20
|
+
|
|
20
21
|
export class ConnectionDisplacedError extends SystemError {
|
|
21
22
|
constructor() {
|
|
22
23
|
super('Connection displaced by remote initiator.');
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type CleanupFn, Event, SubscriptionList } from '@dxos/async';
|
|
6
6
|
import { PublicKey } from '@dxos/keys';
|
|
7
7
|
import { log } from '@dxos/log';
|
|
8
|
-
import {
|
|
8
|
+
import { type PeerInfo as MessagingPeer, PeerInfoHash } from '@dxos/messaging';
|
|
9
9
|
import { ComplexMap } from '@dxos/util';
|
|
10
10
|
|
|
11
11
|
import { type ConnectionState } from './connection';
|
package/src/swarm/swarm.test.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { asyncTimeout, sleep } from '@dxos/async';
|
|
8
8
|
import { PublicKey } from '@dxos/keys';
|
|
@@ -15,13 +15,14 @@ import {
|
|
|
15
15
|
} from '@dxos/messaging';
|
|
16
16
|
import { ComplexSet } from '@dxos/util';
|
|
17
17
|
|
|
18
|
-
import { ConnectionState } from './connection';
|
|
19
|
-
import { ConnectionLimiter } from './connection-limiter';
|
|
20
|
-
import { Swarm } from './swarm';
|
|
21
18
|
import { TestWireProtocol } from '../testing/test-wire-protocol';
|
|
22
19
|
import { FullyConnectedTopology } from '../topology';
|
|
23
20
|
import { createRtcTransportFactory } from '../transport';
|
|
24
21
|
|
|
22
|
+
import { ConnectionState } from './connection';
|
|
23
|
+
import { ConnectionLimiter } from './connection-limiter';
|
|
24
|
+
import { Swarm } from './swarm';
|
|
25
|
+
|
|
25
26
|
type TestPeer = {
|
|
26
27
|
swarm: Swarm;
|
|
27
28
|
peer: PeerInfo;
|
package/src/swarm/swarm.ts
CHANGED
|
@@ -8,20 +8,21 @@ import { ErrorStream } from '@dxos/debug';
|
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
10
10
|
import { log, logInfo } from '@dxos/log';
|
|
11
|
-
import { type
|
|
11
|
+
import { type ListeningHandle, type Messenger, type PeerInfo, PeerInfoHash, type SwarmEvent } from '@dxos/messaging';
|
|
12
12
|
import { trace } from '@dxos/protocols';
|
|
13
13
|
import { type Answer } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
14
14
|
import { ComplexMap, isNonNullable } from '@dxos/util';
|
|
15
15
|
|
|
16
|
-
import { type Connection, ConnectionState } from './connection';
|
|
17
|
-
import { type ConnectionLimiter } from './connection-limiter';
|
|
18
|
-
import { Peer } from './peer';
|
|
19
16
|
import { type OfferMessage, type SignalMessage, SwarmMessenger } from '../signal';
|
|
20
17
|
import { type SwarmController, type Topology } from '../topology';
|
|
21
18
|
import { type TransportFactory } from '../transport';
|
|
22
19
|
import { type Topic } from '../types';
|
|
23
20
|
import { type WireProtocolProvider } from '../wire-protocol';
|
|
24
21
|
|
|
22
|
+
import { type Connection, ConnectionState } from './connection';
|
|
23
|
+
import { type ConnectionLimiter } from './connection-limiter';
|
|
24
|
+
import { Peer } from './peer';
|
|
25
|
+
|
|
25
26
|
const INITIATION_DELAY = 100;
|
|
26
27
|
|
|
27
28
|
// TODO(burdon): Factor out.
|
|
@@ -13,15 +13,23 @@ import {
|
|
|
13
13
|
import { schema } from '@dxos/protocols/proto';
|
|
14
14
|
import { ConnectionState } from '@dxos/protocols/proto/dxos/client/services';
|
|
15
15
|
import { type Runtime } from '@dxos/protocols/proto/dxos/config';
|
|
16
|
-
import { createLinkedPorts, createProtoRpcPeer
|
|
16
|
+
import { type ProtoRpcPeer, createLinkedPorts, createProtoRpcPeer } from '@dxos/rpc';
|
|
17
17
|
import { ComplexMap } from '@dxos/util';
|
|
18
18
|
|
|
19
19
|
import { TcpTransportFactory } from '#tcp-transport';
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
import { SwarmNetworkManager } from '../network-manager';
|
|
22
22
|
import { FullyConnectedTopology } from '../topology';
|
|
23
|
-
import {
|
|
24
|
-
|
|
23
|
+
import {
|
|
24
|
+
MemoryTransportFactory,
|
|
25
|
+
RtcTransportProxyFactory,
|
|
26
|
+
RtcTransportService,
|
|
27
|
+
type TransportFactory,
|
|
28
|
+
TransportKind,
|
|
29
|
+
createRtcTransportFactory,
|
|
30
|
+
} from '../transport';
|
|
31
|
+
|
|
32
|
+
import { type TestTeleportExtensionFactory, TestWireProtocol } from './test-wire-protocol';
|
|
25
33
|
|
|
26
34
|
// Signal server will be started by the setup script.
|
|
27
35
|
const port = process.env.SIGNAL_PORT ?? 4000;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Event, asyncTimeout } from '@dxos/async';
|
|
6
6
|
import { PublicKey } from '@dxos/keys';
|
|
7
7
|
import { log } from '@dxos/log';
|
|
8
8
|
import { TestExtension, TestExtensionWithStreams } from '@dxos/teleport';
|
|
9
|
-
import type {
|
|
9
|
+
import type { TeleportExtension, TestStreamStats } from '@dxos/teleport';
|
|
10
10
|
import { ComplexMap } from '@dxos/util';
|
|
11
11
|
|
|
12
12
|
import { createTeleportProtocolFactory } from '../wire-protocol';
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { asyncTimeout } from '@dxos/async';
|
|
8
8
|
import { PublicKey } from '@dxos/keys';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
import { range } from '@dxos/util';
|
|
11
11
|
|
|
12
|
-
import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
|
|
13
12
|
import { type TestBuilder } from '../testing';
|
|
14
13
|
import { FullyConnectedTopology, StarTopology } from '../topology';
|
|
15
14
|
|
|
15
|
+
import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
|
|
16
|
+
|
|
16
17
|
// TODO(burdon): Use PublicKey throughout (remove conversion to strings, from buffers, etc.)
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { randomBytes } from 'node:crypto';
|
|
6
|
+
|
|
6
7
|
import { describe, test } from 'vitest';
|
|
7
8
|
|
|
8
9
|
import { PublicKey } from '@dxos/keys';
|
|
9
10
|
import { range } from '@dxos/util';
|
|
10
11
|
|
|
11
|
-
import { basicTestSuite } from './basic-test-suite';
|
|
12
|
-
import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
|
|
13
12
|
import { TestBuilder } from '../testing';
|
|
14
13
|
import { FullyConnectedTopology } from '../topology';
|
|
15
14
|
|
|
15
|
+
import { basicTestSuite } from './basic-test-suite';
|
|
16
|
+
import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
|
|
17
|
+
|
|
16
18
|
describe('Memory transport', () => {
|
|
17
19
|
const testBuilder = new TestBuilder();
|
|
18
20
|
basicTestSuite(testBuilder);
|
|
@@ -3,17 +3,19 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { randomBytes } from 'node:crypto';
|
|
6
|
+
|
|
6
7
|
import { describe, test } from 'vitest';
|
|
7
8
|
|
|
8
9
|
import { PublicKey } from '@dxos/keys';
|
|
9
10
|
import { range } from '@dxos/util';
|
|
10
11
|
|
|
11
|
-
import { basicTestSuite } from './basic-test-suite';
|
|
12
|
-
import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
|
|
13
12
|
import { TestBuilder } from '../testing';
|
|
14
13
|
import { FullyConnectedTopology } from '../topology';
|
|
15
14
|
import { TransportKind } from '../transport';
|
|
16
15
|
|
|
16
|
+
import { basicTestSuite } from './basic-test-suite';
|
|
17
|
+
import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
|
|
18
|
+
|
|
17
19
|
describe('Tcp transport', () => {
|
|
18
20
|
const testBuilder = new TestBuilder({
|
|
19
21
|
transport: TransportKind.TCP,
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import { basicTestSuite } from './basic-test-suite';
|
|
8
7
|
import { TEST_SIGNAL_HOSTS, TestBuilder } from '../testing';
|
|
9
8
|
|
|
9
|
+
import { basicTestSuite } from './basic-test-suite';
|
|
10
|
+
|
|
10
11
|
describe('WebRTC transport', { timeout: 10_000 }, () => {
|
|
11
12
|
const testBuilder = new TestBuilder();
|
|
12
13
|
basicTestSuite(testBuilder);
|
package/src/topology/index.ts
CHANGED
|
@@ -38,7 +38,7 @@ class NodeRtcConnectionFactory implements RtcConnectionFactory {
|
|
|
38
38
|
private static _cleanupMutex = new Mutex();
|
|
39
39
|
|
|
40
40
|
// This should be inside the function to avoid triggering `eval` in the global scope.
|
|
41
|
-
// eslint-disable-next-line no-
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
42
42
|
|
|
43
43
|
// TODO(burdon): Do imports here?
|
|
44
44
|
async initialize(): Promise<void> {}
|
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Mutex, Trigger, synchronized } from '@dxos/async';
|
|
6
6
|
import { invariant } from '@dxos/invariant';
|
|
7
7
|
import { log, logInfo } from '@dxos/log';
|
|
8
8
|
import { ConnectivityError } from '@dxos/protocols';
|
|
9
9
|
import { type Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
10
10
|
import { trace } from '@dxos/tracing';
|
|
11
11
|
|
|
12
|
+
import type { IceProvider } from '../../signal';
|
|
13
|
+
import { type TransportOptions } from '../transport';
|
|
14
|
+
|
|
12
15
|
import { type RtcConnectionFactory } from './rtc-connection-factory';
|
|
13
16
|
import { RtcTransportChannel } from './rtc-transport-channel';
|
|
14
17
|
import { areSdpEqual, chooseInitiatorPeer } from './utils';
|
|
15
|
-
import type { IceProvider } from '../../signal';
|
|
16
|
-
import { type TransportOptions } from '../transport';
|
|
17
18
|
|
|
18
19
|
export type RtcPeerChannelFactoryOptions = {
|
|
19
20
|
ownPeerKey: string;
|
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Duplex } from 'node:stream';
|
|
6
|
+
|
|
6
7
|
import { describe, expect, test } from 'vitest';
|
|
7
8
|
|
|
8
9
|
import { sleep } from '@dxos/async';
|
|
9
10
|
|
|
11
|
+
import { type TransportOptions } from '../transport';
|
|
12
|
+
|
|
10
13
|
import { type RtcPeerConnection } from './rtc-peer-connection';
|
|
11
14
|
import { RtcTransportChannel } from './rtc-transport-channel';
|
|
12
15
|
import { handleChannelErrors } from './test-utils';
|
|
13
|
-
import { type TransportOptions } from '../transport';
|
|
14
16
|
|
|
15
17
|
describe('RtcTransportChannel', () => {
|
|
16
18
|
test('transport error raised if channel creation fails', async () => {
|
|
@@ -12,9 +12,10 @@ import { log } from '@dxos/log';
|
|
|
12
12
|
import { ConnectivityError } from '@dxos/protocols';
|
|
13
13
|
import { type Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
14
14
|
|
|
15
|
+
import { type Transport, type TransportOptions, type TransportStats } from '../transport';
|
|
16
|
+
|
|
15
17
|
import { type RtcPeerConnection } from './rtc-peer-connection';
|
|
16
18
|
import { createRtcTransportStats, describeSelectedRemoteCandidate } from './rtc-transport-stats';
|
|
17
|
-
import { type Transport, type TransportOptions, type TransportStats } from '../transport';
|
|
18
19
|
|
|
19
20
|
// https://viblast.com/blog/2015/2/5/webrtc-data-channel-message-size
|
|
20
21
|
const MAX_MESSAGE_SIZE = 64 * 1024;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { getRtcConnectionFactory } from './rtc-connection-factory';
|
|
6
|
-
import { RtcPeerConnection } from './rtc-peer-connection';
|
|
7
5
|
import type { IceProvider } from '../../signal';
|
|
8
6
|
import type { TransportFactory } from '../transport';
|
|
9
7
|
|
|
8
|
+
import { getRtcConnectionFactory } from './rtc-connection-factory';
|
|
9
|
+
import { RtcPeerConnection } from './rtc-peer-connection';
|
|
10
|
+
|
|
10
11
|
export const createRtcTransportFactory = (
|
|
11
12
|
webrtcConfig?: RTCConfiguration,
|
|
12
13
|
iceProvider?: IceProvider,
|
|
@@ -3,19 +3,21 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Duplex } from 'stream';
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
import { describe, expect, onTestFinished, test } from 'vitest';
|
|
7
8
|
|
|
8
9
|
import { Event as AsyncEvent, TestStream, Trigger, sleep } from '@dxos/async';
|
|
9
10
|
import { ErrorStream } from '@dxos/debug';
|
|
10
11
|
import { PublicKey } from '@dxos/keys';
|
|
11
12
|
import { schema } from '@dxos/protocols/proto';
|
|
12
13
|
import { type BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
|
|
13
|
-
import { createLinkedPorts, createProtoRpcPeer
|
|
14
|
+
import { type RpcPort, createLinkedPorts, createProtoRpcPeer } from '@dxos/rpc';
|
|
15
|
+
|
|
16
|
+
import { type Transport, type TransportFactory, type TransportOptions, type TransportStats } from '../transport';
|
|
14
17
|
|
|
15
18
|
import { RtcTransportProxy } from './rtc-transport-proxy';
|
|
16
19
|
import { RtcTransportService } from './rtc-transport-service';
|
|
17
20
|
import { handleChannelErrors } from './test-utils';
|
|
18
|
-
import { type Transport, type TransportFactory, type TransportOptions, type TransportStats } from '../transport';
|
|
19
21
|
|
|
20
22
|
describe('RtcPeerTransportProxy', () => {
|
|
21
23
|
test('open and close', async () => {
|
|
@@ -9,24 +9,25 @@ import { invariant } from '@dxos/invariant';
|
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import {
|
|
12
|
+
type BridgeEvent,
|
|
12
13
|
type BridgeService,
|
|
14
|
+
type CloseRequest,
|
|
13
15
|
type ConnectionRequest,
|
|
14
|
-
type SignalRequest,
|
|
15
|
-
type DataRequest,
|
|
16
|
-
type BridgeEvent,
|
|
17
16
|
ConnectionState,
|
|
18
|
-
type
|
|
17
|
+
type DataRequest,
|
|
19
18
|
type DetailsRequest,
|
|
20
19
|
type DetailsResponse,
|
|
20
|
+
type SignalRequest,
|
|
21
21
|
type StatsRequest,
|
|
22
22
|
type StatsResponse,
|
|
23
23
|
} from '@dxos/protocols/proto/dxos/mesh/bridge';
|
|
24
24
|
import { ComplexMap } from '@dxos/util';
|
|
25
25
|
|
|
26
|
-
import { createRtcTransportFactory } from './rtc-transport-factory';
|
|
27
26
|
import { type IceProvider } from '../../signal';
|
|
28
27
|
import { type Transport, type TransportFactory } from '../transport';
|
|
29
28
|
|
|
29
|
+
import { createRtcTransportFactory } from './rtc-transport-factory';
|
|
30
|
+
|
|
30
31
|
type TransportState = {
|
|
31
32
|
proxyId: PublicKey;
|
|
32
33
|
transport: Transport;
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { TestStream, sleep } from '@dxos/async';
|
|
8
8
|
import { PublicKey } from '@dxos/keys';
|
|
9
9
|
|
|
10
|
+
import { type TransportOptions } from '../transport';
|
|
11
|
+
|
|
10
12
|
import { getRtcConnectionFactory } from './rtc-connection-factory';
|
|
11
13
|
import { RtcPeerConnection } from './rtc-peer-connection';
|
|
12
14
|
import { type RtcTransportChannel } from './rtc-transport-channel';
|
|
13
15
|
import { chooseInitiatorPeer } from './utils';
|
|
14
|
-
import { type TransportOptions } from '../transport';
|
|
15
16
|
|
|
16
17
|
const connectionFactory = getRtcConnectionFactory();
|
|
17
18
|
|