@dxos/network-manager 0.8.3 → 0.8.4-main.1068cf700f

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.
Files changed (102) hide show
  1. package/dist/lib/browser/{chunk-LFKR6BAF.mjs → chunk-AQSYW43M.mjs} +731 -955
  2. package/dist/lib/browser/chunk-AQSYW43M.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +342 -4
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +70 -51
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/browser/transport/tcp/index.mjs +2 -35
  9. package/dist/lib/browser/transport/tcp/index.mjs.map +4 -4
  10. package/dist/lib/browser/transport/tcp/tcp-transport.browser.mjs +36 -0
  11. package/dist/lib/browser/transport/tcp/tcp-transport.browser.mjs.map +7 -0
  12. package/dist/lib/browser/transport/tcp/tcp-transport.mjs +160 -0
  13. package/dist/lib/{node/transport/tcp/index.cjs.map → browser/transport/tcp/tcp-transport.mjs.map} +3 -3
  14. package/dist/lib/node-esm/{chunk-QQY4BF6O.mjs → chunk-SCX3PZRE.mjs} +731 -955
  15. package/dist/lib/node-esm/chunk-SCX3PZRE.mjs.map +7 -0
  16. package/dist/lib/node-esm/index.mjs +342 -4
  17. package/dist/lib/node-esm/index.mjs.map +4 -4
  18. package/dist/lib/node-esm/meta.json +1 -1
  19. package/dist/lib/node-esm/testing/index.mjs +70 -51
  20. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  21. package/dist/lib/node-esm/transport/tcp/index.mjs +2 -156
  22. package/dist/lib/node-esm/transport/tcp/index.mjs.map +4 -4
  23. package/dist/lib/node-esm/transport/tcp/tcp-transport.browser.mjs +36 -0
  24. package/dist/lib/node-esm/transport/tcp/tcp-transport.browser.mjs.map +7 -0
  25. package/dist/lib/{node/transport/tcp/index.cjs → node-esm/transport/tcp/tcp-transport.mjs} +27 -58
  26. package/dist/lib/node-esm/transport/tcp/tcp-transport.mjs.map +7 -0
  27. package/dist/types/src/connection-log.d.ts.map +1 -1
  28. package/dist/types/src/index.d.ts +1 -1
  29. package/dist/types/src/index.d.ts.map +1 -1
  30. package/dist/types/src/network-manager.d.ts.map +1 -1
  31. package/dist/types/src/signal/index.d.ts +2 -2
  32. package/dist/types/src/signal/index.d.ts.map +1 -1
  33. package/dist/types/src/signal/swarm-messenger.d.ts +1 -1
  34. package/dist/types/src/signal/swarm-messenger.d.ts.map +1 -1
  35. package/dist/types/src/swarm/connection.d.ts.map +1 -1
  36. package/dist/types/src/swarm/peer.d.ts +2 -2
  37. package/dist/types/src/swarm/peer.d.ts.map +1 -1
  38. package/dist/types/src/swarm/swarm.d.ts +3 -3
  39. package/dist/types/src/swarm/swarm.d.ts.map +1 -1
  40. package/dist/types/src/testing/test-builder.d.ts +1 -1
  41. package/dist/types/src/testing/test-builder.d.ts.map +1 -1
  42. package/dist/types/src/testing/test-wire-protocol.d.ts +1 -1
  43. package/dist/types/src/testing/test-wire-protocol.d.ts.map +1 -1
  44. package/dist/types/src/tests/basic-test-suite.d.ts.map +1 -1
  45. package/dist/types/src/topology/index.d.ts +1 -1
  46. package/dist/types/src/topology/index.d.ts.map +1 -1
  47. package/dist/types/src/transport/tcp/index.d.ts +1 -1
  48. package/dist/types/src/transport/tcp/index.d.ts.map +1 -1
  49. package/dist/types/src/transport/webrtc/rtc-peer-connection.d.ts +2 -2
  50. package/dist/types/src/transport/webrtc/rtc-peer-connection.d.ts.map +1 -1
  51. package/dist/types/src/transport/webrtc/rtc-transport-channel.d.ts +1 -1
  52. package/dist/types/src/transport/webrtc/rtc-transport-channel.d.ts.map +1 -1
  53. package/dist/types/src/transport/webrtc/rtc-transport-factory.d.ts.map +1 -1
  54. package/dist/types/src/transport/webrtc/rtc-transport-proxy.d.ts.map +1 -1
  55. package/dist/types/src/transport/webrtc/rtc-transport-service.d.ts +1 -1
  56. package/dist/types/src/transport/webrtc/rtc-transport-service.d.ts.map +1 -1
  57. package/dist/types/src/wire-protocol.d.ts +5 -5
  58. package/dist/types/src/wire-protocol.d.ts.map +1 -1
  59. package/dist/types/tsconfig.tsbuildinfo +1 -1
  60. package/package.json +39 -35
  61. package/src/connection-log.ts +1 -1
  62. package/src/index.ts +1 -1
  63. package/src/network-manager.ts +1 -1
  64. package/src/signal/ice.test.ts +1 -1
  65. package/src/signal/index.ts +2 -2
  66. package/src/signal/integration.node.test.ts +2 -2
  67. package/src/signal/swarm-messenger.node.test.ts +1 -1
  68. package/src/signal/swarm-messenger.ts +1 -1
  69. package/src/swarm/connection.test.ts +4 -2
  70. package/src/swarm/connection.ts +11 -9
  71. package/src/swarm/peer.ts +5 -3
  72. package/src/swarm/swarm-mapper.ts +1 -1
  73. package/src/swarm/swarm.test.ts +7 -5
  74. package/src/swarm/swarm.ts +5 -4
  75. package/src/testing/test-builder.ts +12 -4
  76. package/src/testing/test-wire-protocol.ts +2 -2
  77. package/src/tests/basic-test-suite.ts +3 -2
  78. package/src/tests/memory-transport.test.ts +4 -2
  79. package/src/tests/tcp-transport.node.test.ts +4 -2
  80. package/src/tests/webrtc-transport.test.ts +6 -3
  81. package/src/topology/index.ts +1 -1
  82. package/src/transport/tcp/index.ts +1 -1
  83. package/src/transport/tcp/tcp-transport.ts +1 -1
  84. package/src/transport/webrtc/rtc-connection-factory.ts +1 -1
  85. package/src/transport/webrtc/rtc-peer-connection.ts +5 -4
  86. package/src/transport/webrtc/rtc-transport-channel.test.ts +3 -1
  87. package/src/transport/webrtc/rtc-transport-channel.ts +3 -2
  88. package/src/transport/webrtc/rtc-transport-factory.ts +3 -2
  89. package/src/transport/webrtc/rtc-transport-proxy.test.ts +7 -4
  90. package/src/transport/webrtc/rtc-transport-proxy.ts +6 -4
  91. package/src/transport/webrtc/rtc-transport-service.ts +6 -5
  92. package/src/transport/webrtc/rtc-transport.test.ts +6 -4
  93. package/src/wire-protocol.ts +6 -6
  94. package/dist/lib/browser/chunk-LFKR6BAF.mjs.map +0 -7
  95. package/dist/lib/node/chunk-2G6RZMS5.cjs +0 -4460
  96. package/dist/lib/node/chunk-2G6RZMS5.cjs.map +0 -7
  97. package/dist/lib/node/index.cjs +0 -71
  98. package/dist/lib/node/index.cjs.map +0 -7
  99. package/dist/lib/node/meta.json +0 -1
  100. package/dist/lib/node/testing/index.cjs +0 -296
  101. package/dist/lib/node/testing/index.cjs.map +0 -7
  102. package/dist/lib/node-esm/chunk-QQY4BF6O.mjs.map +0 -7
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@dxos/network-manager",
3
- "version": "0.8.3",
3
+ "version": "0.8.4-main.1068cf700f",
4
4
  "description": "Network Manager",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
- "sideEffects": true,
13
+ "sideEffects": false,
10
14
  "type": "module",
11
15
  "imports": {
12
16
  "#node-datachannel": {
@@ -20,33 +24,43 @@
20
24
  "default": "node-datachannel/*"
21
25
  },
22
26
  "#tcp-transport": {
27
+ "source": "./src/transport/tcp/index.ts",
23
28
  "types": "./dist/types/src/transport/tcp/index.d.ts",
24
29
  "browser": "./dist/lib/browser/transport/tcp/index.mjs",
25
- "node": "./dist/lib/node/transport/tcp/index.cjs",
30
+ "node": "./dist/lib/node-esm/transport/tcp/index.mjs",
26
31
  "import": "./dist/lib/browser/transport/tcp/index.mjs",
27
- "require": "./dist/lib/node/transport/tcp/index.cjs"
32
+ "require": "./dist/lib/node-esm/transport/tcp/index.mjs"
33
+ },
34
+ "#tcp-transport-impl": {
35
+ "source": {
36
+ "browser": "./src/transport/tcp/tcp-transport.browser.ts",
37
+ "default": "./src/transport/tcp/tcp-transport.ts"
38
+ },
39
+ "types": "./dist/types/src/transport/tcp/tcp-transport.d.ts",
40
+ "browser": "./dist/lib/browser/transport/tcp/tcp-transport.browser.mjs",
41
+ "default": "./dist/lib/node-esm/transport/tcp/tcp-transport.mjs"
28
42
  }
29
43
  },
30
44
  "exports": {
31
45
  ".": {
46
+ "source": "./src/index.ts",
32
47
  "types": "./dist/types/src/index.d.ts",
33
48
  "browser": "./dist/lib/browser/index.mjs",
34
49
  "node": "./dist/lib/node-esm/index.mjs"
35
50
  },
36
51
  "./testing": {
52
+ "source": "./src/testing/index.ts",
37
53
  "types": "./dist/types/src/testing/index.d.ts",
38
54
  "browser": "./dist/lib/browser/testing/index.mjs",
39
55
  "node": "./dist/lib/node-esm/testing/index.mjs"
40
56
  },
41
57
  "./transport/tcp": {
58
+ "source": "./src/transport/tcp/index.ts",
42
59
  "types": "./dist/types/src/transport/tcp/index.d.ts",
43
60
  "browser": "./dist/lib/browser/transport/tcp/index.mjs",
44
61
  "node": "./dist/lib/node-esm/transport/tcp/index.mjs"
45
62
  }
46
63
  },
47
- "browser": {
48
- "./src/transport/tcp/tcp-transport.ts": "./src/transport/tcp/tcp-transport.browser.ts"
49
- },
50
64
  "types": "dist/types/src/index.d.ts",
51
65
  "typesVersions": {
52
66
  "*": {
@@ -66,37 +80,27 @@
66
80
  "src"
67
81
  ],
68
82
  "dependencies": {
69
- "isomorphic-ws": "^5.0.0",
70
- "nanomessage-rpc": "^3.0.0",
71
- "node-datachannel": "^0.9.2",
72
- "p-defer": "^3.0.0",
73
- "stream": "^0.0.3",
74
- "tiny-invariant": "^1.3.1",
75
- "ws": "^8.14.2",
76
- "xor-distance": "^2.0.0",
77
- "@dxos/async": "0.8.3",
78
- "@dxos/codec-protobuf": "0.8.3",
79
- "@dxos/context": "0.8.3",
80
- "@dxos/debug": "0.8.3",
81
- "@dxos/invariant": "0.8.3",
82
- "@dxos/log": "0.8.3",
83
- "@dxos/messaging": "0.8.3",
84
- "@dxos/keys": "0.8.3",
85
- "@dxos/node-std": "0.8.3",
86
- "@dxos/protocols": "0.8.3",
87
- "@dxos/rpc": "0.8.3",
88
- "@dxos/teleport": "0.8.3",
89
- "@dxos/util": "0.8.3",
90
- "@dxos/tracing": "0.8.3"
83
+ "node-datachannel": "^0.30.0",
84
+ "@dxos/async": "0.8.4-main.1068cf700f",
85
+ "@dxos/codec-protobuf": "0.8.4-main.1068cf700f",
86
+ "@dxos/context": "0.8.4-main.1068cf700f",
87
+ "@dxos/debug": "0.8.4-main.1068cf700f",
88
+ "@dxos/invariant": "0.8.4-main.1068cf700f",
89
+ "@dxos/keys": "0.8.4-main.1068cf700f",
90
+ "@dxos/messaging": "0.8.4-main.1068cf700f",
91
+ "@dxos/log": "0.8.4-main.1068cf700f",
92
+ "@dxos/node-std": "0.8.4-main.1068cf700f",
93
+ "@dxos/protocols": "0.8.4-main.1068cf700f",
94
+ "@dxos/rpc": "0.8.4-main.1068cf700f",
95
+ "@dxos/teleport": "0.8.4-main.1068cf700f",
96
+ "@dxos/tracing": "0.8.4-main.1068cf700f",
97
+ "@dxos/util": "0.8.4-main.1068cf700f"
91
98
  },
92
99
  "devDependencies": {
93
- "@swc-node/register": "1.9.1",
94
- "@types/ws": "^7.4.0",
95
- "fast-check": "^3.19.0",
96
100
  "fetch-mock": "^11.0.0",
97
- "@dxos/keyring": "0.8.3",
98
- "@dxos/signal": "0.8.3",
99
- "@dxos/edge-client": "0.8.3"
101
+ "@dxos/edge-client": "0.8.4-main.1068cf700f",
102
+ "@dxos/keyring": "0.8.4-main.1068cf700f",
103
+ "@dxos/signal": "0.8.4-main.1068cf700f"
100
104
  },
101
105
  "publishConfig": {
102
106
  "access": "public"
@@ -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 SwarmInfo, type ConnectionInfo } from '@dxos/protocols/proto/dxos/devtools/swarm';
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
@@ -8,5 +8,5 @@ export * from './signal';
8
8
  export * from './swarm';
9
9
  export * from './topology';
10
10
  export * from './transport';
11
- export * from './types';
11
+ export type * from './types';
12
12
  export * from './wire-protocol';
@@ -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, ConnectionLimiter } from './swarm';
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';
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import fetchMock from 'fetch-mock';
6
- import { afterEach, test, expect, describe } from 'vitest';
6
+ import { afterEach, describe, expect, test } from 'vitest';
7
7
 
8
8
  import { createIceProvider } from './ice';
9
9
 
@@ -4,5 +4,5 @@
4
4
 
5
5
  export * from './ice';
6
6
  export * from './swarm-messenger';
7
- export * from './signal-connection';
8
- export * from './signal-messenger';
7
+ export type * from './signal-connection';
8
+ export type * from './signal-messenger';
@@ -2,11 +2,11 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { afterAll, onTestFinished, beforeAll, describe, expect, test } from 'vitest';
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 { runTestSignalServer, type SignalServerRunner } from '@dxos/signal';
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, test, onTestFinished } from 'vitest';
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 PeerInfo, type Message } from '@dxos/messaging';
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,12 +7,14 @@ 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
 
15
- describe('Connection', () => {
14
+ import { Connection } from './connection';
15
+
16
+ // Segfault in node-datachannel.
17
+ describe.skip('Connection', () => {
16
18
  test('responder opens after initiator', async () => {
17
19
  const { initiator, responder } = createPeerKeys();
18
20
  await connectionTest({
@@ -2,8 +2,8 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- import { DeferredTask, Event, sleep, scheduleTask, scheduleTaskInterval, synchronized, Trigger } from '@dxos/async';
6
- import { Context, cancelWithContext, ContextDisposedError } from '@dxos/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';
@@ -185,16 +185,18 @@ export class Connection {
185
185
  this._protocol.stream.on('close', () => {
186
186
  log('protocol stream closed');
187
187
  this._protocolClosed.wake();
188
- this.close({ error: new ProtocolError('protocol stream closed') }).catch((err) => this.errors.raise(err));
188
+ this.close({ error: new ProtocolError({ message: 'protocol stream closed' }) }).catch((err) =>
189
+ this.errors.raise(err),
190
+ );
189
191
  });
190
192
 
191
193
  scheduleTask(
192
194
  this.connectedTimeoutContext,
193
195
  async () => {
194
196
  log.info(`timeout waiting ${TRANSPORT_CONNECTION_TIMEOUT / 1000}s for transport to connect, aborting`);
195
- await this.abort(new TimeoutError(`${TRANSPORT_CONNECTION_TIMEOUT / 1000}s for transport to connect`)).catch(
196
- (err) => this.errors.raise(err),
197
- );
197
+ await this.abort(
198
+ new TimeoutError({ message: `${TRANSPORT_CONNECTION_TIMEOUT / 1000}s for transport to connect` }),
199
+ ).catch((err) => this.errors.raise(err));
198
200
  },
199
201
  TRANSPORT_CONNECTION_TIMEOUT,
200
202
  );
@@ -397,7 +399,7 @@ export class Connection {
397
399
 
398
400
  // If signal fails treat connection as failed
399
401
  log.info('signal message failed to deliver', { err });
400
- await this.close({ error: new ConnectivityError('signal message failed to deliver', err) });
402
+ await this.close({ error: new ConnectivityError({ message: 'signal message failed to deliver', cause: err }) });
401
403
  }
402
404
  }
403
405
 
@@ -414,7 +416,7 @@ export class Connection {
414
416
  invariant(msg.author.peerKey === this.remoteInfo.peerKey);
415
417
  invariant(msg.recipient.peerKey === this.localInfo.peerKey);
416
418
 
417
- const signals = msg.data.signalBatch ? msg.data.signalBatch.signals ?? [] : [msg.data.signal];
419
+ const signals = msg.data.signalBatch ? (msg.data.signalBatch.signals ?? []) : [msg.data.signal];
418
420
  for (const signal of signals) {
419
421
  if (!signal) {
420
422
  continue;
package/src/swarm/peer.ts CHANGED
@@ -11,15 +11,16 @@ 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
- super('Connection displaced by remote initiator.');
23
+ super({ message: 'Connection displaced by remote initiator.' });
23
24
  }
24
25
  }
25
26
 
@@ -161,6 +162,7 @@ export class Peer {
161
162
  return { accept: true };
162
163
  }
163
164
  }
165
+
164
166
  return { accept: false };
165
167
  }
166
168
 
@@ -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 { PeerInfoHash, type PeerInfo as MessagingPeer } from '@dxos/messaging';
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';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { onTestFinished, describe, expect, test } from 'vitest';
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;
@@ -30,7 +31,8 @@ type TestPeer = {
30
31
  signalManager: SignalManager;
31
32
  };
32
33
 
33
- describe('Swarm', () => {
34
+ // Segfault in node-datachannel.
35
+ describe.skip('Swarm', () => {
34
36
  const context = new MemorySignalManagerContext();
35
37
 
36
38
  const setupSwarm = async ({
@@ -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 SwarmEvent, type ListeningHandle, type Messenger, type PeerInfo, PeerInfoHash } from '@dxos/messaging';
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, type ProtoRpcPeer } from '@dxos/rpc';
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
- import { type TestTeleportExtensionFactory, TestWireProtocol } from './test-wire-protocol';
20
+
21
21
  import { SwarmNetworkManager } from '../network-manager';
22
22
  import { FullyConnectedTopology } from '../topology';
23
- import { MemoryTransportFactory, type TransportFactory, TransportKind } from '../transport';
24
- import { createRtcTransportFactory, RtcTransportProxyFactory, RtcTransportService } from '../transport';
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 { asyncTimeout, Event } from '@dxos/async';
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 { TestStreamStats, TeleportExtension } from '@dxos/teleport';
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 { onTestFinished, expect, test } from 'vitest';
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,15 +4,18 @@
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
 
10
- describe('WebRTC transport', { timeout: 10_000 }, () => {
9
+ import { basicTestSuite } from './basic-test-suite';
10
+
11
+ // Segfault in node-datachannel.
12
+ describe.skip('WebRTC transport', { timeout: 10_000 }, () => {
11
13
  const testBuilder = new TestBuilder();
12
14
  basicTestSuite(testBuilder);
13
15
  });
14
16
 
15
- describe('WebRTC transport proxy', { timeout: 10_000 }, () => {
17
+ // Segfault in node-datachannel.
18
+ describe.skip('WebRTC transport proxy', { timeout: 10_000 }, () => {
16
19
  const testBuilder = new TestBuilder({ bridge: true });
17
20
  basicTestSuite(testBuilder);
18
21
  });
@@ -5,4 +5,4 @@
5
5
  export * from './fully-connected-topology';
6
6
  export * from './mmst-topology';
7
7
  export * from './star-topology';
8
- export * from './topology';
8
+ export type * from './topology';
@@ -2,4 +2,4 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- export * from './tcp-transport';
5
+ export * from '#tcp-transport-impl';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { type AddressInfo, Socket, type Server } from 'node:net';
5
+ import { type AddressInfo, type Server, Socket } from 'node:net';
6
6
 
7
7
  import { Event } from '@dxos/async';
8
8
  import { ErrorStream } from '@dxos/debug';
@@ -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-new-func
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 { synchronized, Trigger, Mutex } from '@dxos/async';
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;
@@ -468,7 +469,7 @@ type IceCandidateErrorDetails = { url: string; errorCode: number; errorText: str
468
469
 
469
470
  const createIceFailureError = (details: IceCandidateErrorDetails[]) => {
470
471
  const candidateErrors = details.map(({ url, errorCode, errorText }) => `${errorCode} ${url}: ${errorText}`);
471
- return new ConnectivityError(`ICE failed:\n${candidateErrors.join('\n')}`);
472
+ return new ConnectivityError({ message: `ICE failed:\n${candidateErrors.join('\n')}` });
472
473
  };
473
474
 
474
475
  type ChannelCreatedCallback = {
@@ -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;
@@ -70,7 +71,7 @@ export class RtcTransportChannel extends Resource implements Transport {
70
71
  const error =
71
72
  err instanceof Error
72
73
  ? err
73
- : new ConnectivityError(`Failed to create a channel: ${JSON.stringify(err?.message)}`);
74
+ : new ConnectivityError({ message: `Failed to create a channel: ${JSON.stringify(err?.message)}` });
74
75
  this.errors.raise(error);
75
76
  } else {
76
77
  log.verbose('connection establishment failed after transport was closed', { err });