@dxos/network-manager 2.33.7-dev.c2ba88fb → 2.33.8-dev.6bc74570

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 (96) hide show
  1. package/dist/browser-mocha/bundle.js +62376 -62233
  2. package/dist/src/connection-log.d.ts +1 -1
  3. package/dist/src/connection-log.d.ts.map +1 -1
  4. package/dist/src/connection-log.js.map +1 -1
  5. package/dist/src/network-manager.blueprint-test.js +23 -23
  6. package/dist/src/network-manager.blueprint-test.js.map +1 -1
  7. package/dist/src/network-manager.d.ts +1 -1
  8. package/dist/src/network-manager.d.ts.map +1 -1
  9. package/dist/src/network-manager.js +3 -3
  10. package/dist/src/network-manager.js.map +1 -1
  11. package/dist/src/presence.test.js +4 -4
  12. package/dist/src/presence.test.js.map +1 -1
  13. package/dist/src/protocol-factory.d.ts +1 -1
  14. package/dist/src/protocol-factory.d.ts.map +1 -1
  15. package/dist/src/protocol-factory.js +4 -3
  16. package/dist/src/protocol-factory.js.map +1 -1
  17. package/dist/src/signal/in-memory-signal-manager.d.ts +1 -1
  18. package/dist/src/signal/in-memory-signal-manager.d.ts.map +1 -1
  19. package/dist/src/signal/signal-api.d.ts +1 -1
  20. package/dist/src/signal/signal-api.d.ts.map +1 -1
  21. package/dist/src/signal/signal-client.d.ts +1 -1
  22. package/dist/src/signal/signal-client.d.ts.map +1 -1
  23. package/dist/src/signal/signal-client.js +11 -11
  24. package/dist/src/signal/signal-client.js.map +1 -1
  25. package/dist/src/signal/signal-client.test.js +7 -7
  26. package/dist/src/signal/signal-client.test.js.map +1 -1
  27. package/dist/src/signal/signal-manager.d.ts +1 -1
  28. package/dist/src/signal/signal-manager.d.ts.map +1 -1
  29. package/dist/src/signal/websocket-signal-manager.d.ts +1 -1
  30. package/dist/src/signal/websocket-signal-manager.d.ts.map +1 -1
  31. package/dist/src/swarm/connection.d.ts +1 -1
  32. package/dist/src/swarm/connection.d.ts.map +1 -1
  33. package/dist/src/swarm/connection.js.map +1 -1
  34. package/dist/src/swarm/swarm-mapper.d.ts +1 -1
  35. package/dist/src/swarm/swarm-mapper.d.ts.map +1 -1
  36. package/dist/src/swarm/swarm-mapper.js +4 -4
  37. package/dist/src/swarm/swarm-mapper.js.map +1 -1
  38. package/dist/src/swarm/swarm.d.ts +1 -1
  39. package/dist/src/swarm/swarm.d.ts.map +1 -1
  40. package/dist/src/swarm/swarm.js +3 -2
  41. package/dist/src/swarm/swarm.js.map +1 -1
  42. package/dist/src/swarm/swarm.test.js +4 -4
  43. package/dist/src/swarm/swarm.test.js.map +1 -1
  44. package/dist/src/testing/test-protocol.d.ts.map +1 -1
  45. package/dist/src/testing/test-protocol.js +7 -7
  46. package/dist/src/testing/test-protocol.js.map +1 -1
  47. package/dist/src/topology/fully-connected-topology.d.ts +1 -1
  48. package/dist/src/topology/fully-connected-topology.d.ts.map +1 -1
  49. package/dist/src/topology/mmst-topology.d.ts +1 -1
  50. package/dist/src/topology/mmst-topology.d.ts.map +1 -1
  51. package/dist/src/topology/star-topology.d.ts +1 -1
  52. package/dist/src/topology/star-topology.d.ts.map +1 -1
  53. package/dist/src/topology/topology.d.ts +1 -1
  54. package/dist/src/topology/topology.d.ts.map +1 -1
  55. package/dist/src/transport/in-memory-transport.d.ts +1 -1
  56. package/dist/src/transport/in-memory-transport.d.ts.map +1 -1
  57. package/dist/src/transport/in-memory-transport.js.map +1 -1
  58. package/dist/src/transport/in-memory-transport.test.js +5 -4
  59. package/dist/src/transport/in-memory-transport.test.js.map +1 -1
  60. package/dist/src/transport/transport.d.ts +1 -1
  61. package/dist/src/transport/transport.d.ts.map +1 -1
  62. package/dist/src/transport/webrtc-transport.d.ts +1 -1
  63. package/dist/src/transport/webrtc-transport.d.ts.map +1 -1
  64. package/dist/src/transport/webrtc-transport.js.map +1 -1
  65. package/dist/src/transport/webrtc-transport.test.js +6 -5
  66. package/dist/src/transport/webrtc-transport.test.js.map +1 -1
  67. package/dist/src/types.d.ts +1 -1
  68. package/dist/src/types.d.ts.map +1 -1
  69. package/dist/tsconfig.tsbuildinfo +1 -1
  70. package/package.json +13 -12
  71. package/src/connection-log.ts +1 -1
  72. package/src/network-manager.blueprint-test.ts +1 -1
  73. package/src/network-manager.ts +1 -1
  74. package/src/presence.test.ts +1 -1
  75. package/src/protocol-factory.ts +5 -4
  76. package/src/signal/in-memory-signal-manager.ts +1 -1
  77. package/src/signal/signal-api.ts +1 -1
  78. package/src/signal/signal-client.test.ts +1 -1
  79. package/src/signal/signal-client.ts +1 -1
  80. package/src/signal/signal-manager.ts +1 -1
  81. package/src/signal/websocket-signal-manager.ts +1 -1
  82. package/src/swarm/connection.ts +1 -1
  83. package/src/swarm/swarm-mapper.ts +1 -1
  84. package/src/swarm/swarm.test.ts +1 -1
  85. package/src/swarm/swarm.ts +2 -1
  86. package/src/testing/test-protocol.ts +7 -7
  87. package/src/topology/fully-connected-topology.ts +1 -1
  88. package/src/topology/mmst-topology.ts +1 -1
  89. package/src/topology/star-topology.ts +1 -1
  90. package/src/topology/topology.ts +1 -1
  91. package/src/transport/in-memory-transport.test.ts +2 -1
  92. package/src/transport/in-memory-transport.ts +1 -1
  93. package/src/transport/transport.ts +1 -1
  94. package/src/transport/webrtc-transport.test.ts +2 -1
  95. package/src/transport/webrtc-transport.ts +1 -1
  96. package/src/types.ts +1 -1
@@ -5,8 +5,8 @@
5
5
  import expect from 'expect';
6
6
  import waitForExpect from 'wait-for-expect';
7
7
 
8
- import { PublicKey } from '@dxos/crypto';
9
8
  import { PresencePlugin } from '@dxos/protocol-plugin-presence';
9
+ import { PublicKey } from '@dxos/protocols';
10
10
  import { afterTest } from '@dxos/testutils';
11
11
 
12
12
  import { NetworkManager } from './network-manager';
@@ -5,8 +5,9 @@
5
5
  import assert from 'assert';
6
6
  import debug from 'debug';
7
7
 
8
- import { discoveryKey, keyToString, PublicKey } from '@dxos/crypto';
8
+ import { discoveryKey } from '@dxos/crypto';
9
9
  import { Extension, Protocol } from '@dxos/mesh-protocol';
10
+ import { PublicKey } from '@dxos/protocols';
10
11
 
11
12
  import { ProtocolProvider } from './network-manager';
12
13
 
@@ -36,7 +37,7 @@ export const protocolFactory = ({ session = {}, plugins = [], getTopics }: Proto
36
37
  discoveryToPublicKey: (dk) => {
37
38
  const publicKey = getTopics().find(topic => discoveryKey(topic).equals(dk));
38
39
  if (publicKey) {
39
- protocol.setContext({ topic: keyToString(publicKey) });
40
+ protocol.setContext({ topic: PublicKey.stringify(publicKey) });
40
41
  }
41
42
  assert(publicKey, 'PublicKey not found in discovery.');
42
43
  return publicKey;
@@ -61,7 +62,7 @@ export interface Plugin {
61
62
 
62
63
  export const createProtocolFactory = (topic: PublicKey, peerId: PublicKey, plugins: Plugin[]) => protocolFactory({
63
64
  getTopics: () => [topic.asBuffer()],
64
- session: { peerId: keyToString(peerId.asBuffer()) },
65
+ session: { peerId: PublicKey.stringify(peerId.asBuffer()) },
65
66
  plugins
66
67
  });
67
68
 
@@ -71,6 +72,6 @@ export const createProtocolFactory = (topic: PublicKey, peerId: PublicKey, plugi
71
72
  */
72
73
  export const transportProtocolProvider = (rendezvousKey: Buffer, peerId: Buffer, protocolPlugin: any): ProtocolProvider => protocolFactory({
73
74
  getTopics: () => [rendezvousKey],
74
- session: { peerId: keyToString(peerId) },
75
+ session: { peerId: PublicKey.stringify(peerId) },
75
76
  plugins: [protocolPlugin]
76
77
  });
@@ -5,7 +5,7 @@
5
5
  import assert from 'assert';
6
6
 
7
7
  import { Event } from '@dxos/async';
8
- import { PublicKey } from '@dxos/crypto';
8
+ import { PublicKey } from '@dxos/protocols';
9
9
  import { ComplexMap, ComplexSet } from '@dxos/util';
10
10
 
11
11
  import { SignalApi } from './signal-api';
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { SignalData } from 'simple-peer';
6
6
 
7
- import { PublicKey } from '@dxos/crypto';
7
+ import { PublicKey } from '@dxos/protocols';
8
8
 
9
9
  // TODO(burdon): Define message types as protobuf.
10
10
 
@@ -7,7 +7,7 @@ import { it as test, describe } from 'mocha';
7
7
  import waitForExpect from 'wait-for-expect';
8
8
 
9
9
  import { Awaited, sleep } from '@dxos/async';
10
- import { PublicKey } from '@dxos/crypto';
10
+ import { PublicKey } from '@dxos/protocols';
11
11
  import { createTestBroker } from '@dxos/signal';
12
12
  import { randomInt } from '@dxos/util';
13
13
 
@@ -5,7 +5,7 @@
5
5
  import debug from 'debug';
6
6
 
7
7
  import { Event } from '@dxos/async';
8
- import { PublicKey } from '@dxos/crypto';
8
+ import { PublicKey } from '@dxos/protocols';
9
9
 
10
10
  import { SignalApi } from './signal-api';
11
11
  import { WebsocketRpc } from './websocket-rpc';
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { Event } from '@dxos/async';
6
- import { PublicKey } from '@dxos/crypto';
6
+ import { PublicKey } from '@dxos/protocols';
7
7
 
8
8
  import { SignalApi } from './signal-api';
9
9
 
@@ -6,7 +6,7 @@ import assert from 'assert';
6
6
  import debug from 'debug';
7
7
 
8
8
  import { Event, synchronized } from '@dxos/async';
9
- import { PublicKey } from '@dxos/crypto';
9
+ import { PublicKey } from '@dxos/protocols';
10
10
  import { ComplexMap } from '@dxos/util';
11
11
 
12
12
  import { SignalApi } from './signal-api';
@@ -6,9 +6,9 @@ import assert from 'assert';
6
6
  import debug from 'debug';
7
7
 
8
8
  import { Event, synchronized } from '@dxos/async';
9
- import { PublicKey } from '@dxos/crypto';
10
9
  import { ErrorStream } from '@dxos/debug';
11
10
  import { Protocol } from '@dxos/mesh-protocol';
11
+ import { PublicKey } from '@dxos/protocols';
12
12
 
13
13
  import { SignalApi } from '../signal';
14
14
  import { Transport, TransportFactory } from '../transport';
@@ -5,8 +5,8 @@
5
5
  import debug from 'debug';
6
6
 
7
7
  import { Event } from '@dxos/async';
8
- import { PublicKey } from '@dxos/crypto';
9
8
  import { PresencePlugin } from '@dxos/protocol-plugin-presence';
9
+ import { PublicKey } from '@dxos/protocols';
10
10
  import { ComplexMap, SubscriptionGroup } from '@dxos/util';
11
11
 
12
12
  import { ConnectionState } from './connection';
@@ -8,8 +8,8 @@ import { it as test } from 'mocha';
8
8
  import waitForExpect from 'wait-for-expect';
9
9
 
10
10
  import { sleep, promiseTimeout } from '@dxos/async';
11
- import { PublicKey } from '@dxos/crypto';
12
11
  import { Protocol } from '@dxos/mesh-protocol';
12
+ import { PublicKey } from '@dxos/protocols';
13
13
  import { afterTest } from '@dxos/testutils';
14
14
 
15
15
  import { SignalApi, SignalConnection } from '../signal';
@@ -6,8 +6,9 @@ import assert from 'assert';
6
6
  import debug from 'debug';
7
7
 
8
8
  import { Event } from '@dxos/async';
9
- import { discoveryKey, PublicKey } from '@dxos/crypto';
9
+ import { discoveryKey } from '@dxos/crypto';
10
10
  import { ErrorStream } from '@dxos/debug';
11
+ import { PublicKey } from '@dxos/protocols';
11
12
  import { ComplexMap, ComplexSet } from '@dxos/util';
12
13
 
13
14
  import { ProtocolProvider } from '../network-manager';
@@ -8,8 +8,8 @@ import assert from 'assert';
8
8
  import debug from 'debug';
9
9
  import { EventEmitter } from 'events';
10
10
 
11
- import { keyToBuffer, keyToString } from '@dxos/crypto';
12
11
  import { Extension, Protocol } from '@dxos/mesh-protocol';
12
+ import { PublicKey } from '@dxos/protocols';
13
13
 
14
14
  import { protocolFactory } from '../protocol-factory';
15
15
 
@@ -20,7 +20,7 @@ const EXTENSION_NAME = 'test';
20
20
  // TODO(dboreham): This method should be added to Protocol (and one for "my ID"?).
21
21
  export const getPeerId = (protocol: Protocol) => {
22
22
  const { peerId } = protocol.getSession() ?? {};
23
- return keyToBuffer(peerId);
23
+ return PublicKey.bufferize(peerId);
24
24
  };
25
25
 
26
26
  /**
@@ -97,7 +97,7 @@ export class TestProtocolPlugin extends EventEmitter {
97
97
  */
98
98
  async send (peerId: Buffer, payload: string): Promise<string> {
99
99
  assert(Buffer.isBuffer(peerId));
100
- const peerIdStr = keyToString(peerId);
100
+ const peerIdStr = PublicKey.stringify(peerId);
101
101
  const peer = this._peers.get(peerIdStr);
102
102
  // TODO(dboreham): Throw fatal error if peer not found.
103
103
  const extension = peer.getExtension(EXTENSION_NAME);
@@ -111,7 +111,7 @@ export class TestProtocolPlugin extends EventEmitter {
111
111
  }
112
112
 
113
113
  async _receive (protocol: Protocol, data: any) {
114
- const peerIdStr = keyToString(getPeerId(protocol));
114
+ const peerIdStr = PublicKey.stringify(getPeerId(protocol));
115
115
  let payload = data.data.toString();
116
116
  if (this._uppercase) {
117
117
  payload = payload.toUpperCase();
@@ -125,7 +125,7 @@ export class TestProtocolPlugin extends EventEmitter {
125
125
  if (peerId === undefined) {
126
126
  return;
127
127
  }
128
- const peerIdStr = keyToString(peerId);
128
+ const peerIdStr = PublicKey.stringify(peerId);
129
129
  if (this._peers.has(peerIdStr)) {
130
130
  return;
131
131
  }
@@ -140,7 +140,7 @@ export class TestProtocolPlugin extends EventEmitter {
140
140
  return;
141
141
  }
142
142
 
143
- this._peers.delete(keyToString(peerId));
143
+ this._peers.delete(PublicKey.stringify(peerId));
144
144
  this.emit('disconnect', peerId);
145
145
  }
146
146
  }
@@ -151,6 +151,6 @@ export class TestProtocolPlugin extends EventEmitter {
151
151
  // TODO(dboreham): Try to encapsulate swarmKey, nodeId.
152
152
  export const testProtocolProvider = (swarmKey: Buffer, nodeId: Buffer, protocolPlugin: any) => protocolFactory({
153
153
  getTopics: () => [swarmKey],
154
- session: { peerId: keyToString(nodeId) },
154
+ session: { peerId: PublicKey.stringify(nodeId) },
155
155
  plugins: [protocolPlugin]
156
156
  });
@@ -4,7 +4,7 @@
4
4
 
5
5
  import assert from 'assert';
6
6
 
7
- import { PublicKey } from '@dxos/crypto';
7
+ import { PublicKey } from '@dxos/protocols';
8
8
 
9
9
  import { SwarmController, Topology } from './topology';
10
10
 
@@ -6,7 +6,7 @@ import assert from 'assert';
6
6
  import debug from 'debug';
7
7
  import distance from 'xor-distance';
8
8
 
9
- import { PublicKey } from '@dxos/crypto';
9
+ import { PublicKey } from '@dxos/protocols';
10
10
 
11
11
  import { SwarmController, Topology } from './topology';
12
12
 
@@ -5,7 +5,7 @@
5
5
  import assert from 'assert';
6
6
  import debug from 'debug';
7
7
 
8
- import { PublicKey } from '@dxos/crypto';
8
+ import { PublicKey } from '@dxos/protocols';
9
9
 
10
10
  import { SwarmController, Topology } from './topology';
11
11
 
@@ -2,7 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { PublicKey } from '@dxos/crypto';
5
+ import { PublicKey } from '@dxos/protocols';
6
6
 
7
7
  export interface SwarmController {
8
8
  /**
@@ -5,8 +5,9 @@
5
5
  import expect from 'expect';
6
6
  import waitForExpect from 'wait-for-expect';
7
7
 
8
- import { discoveryKey, PublicKey } from '@dxos/crypto';
8
+ import { discoveryKey } from '@dxos/crypto';
9
9
  import { Protocol } from '@dxos/mesh-protocol';
10
+ import { PublicKey } from '@dxos/protocols';
10
11
  import { afterTest } from '@dxos/testutils';
11
12
  import { range } from '@dxos/util';
12
13
 
@@ -7,8 +7,8 @@ import debug from 'debug';
7
7
  import { Transform } from 'stream';
8
8
 
9
9
  import { Event } from '@dxos/async';
10
- import { PublicKey } from '@dxos/crypto';
11
10
  import { ErrorStream } from '@dxos/debug';
11
+ import { PublicKey } from '@dxos/protocols';
12
12
  import { ComplexMap } from '@dxos/util';
13
13
 
14
14
  import { SignalApi } from '../signal';
@@ -3,8 +3,8 @@
3
3
  //
4
4
 
5
5
  import { Event } from '@dxos/async';
6
- import { PublicKey } from '@dxos/crypto';
7
6
  import { ErrorStream } from '@dxos/debug';
7
+ import { PublicKey } from '@dxos/protocols';
8
8
 
9
9
  import { SignalApi } from '../signal';
10
10
 
@@ -8,8 +8,9 @@ import { Duplex } from 'stream';
8
8
  import waitForExpect from 'wait-for-expect';
9
9
 
10
10
  import { sleep } from '@dxos/async';
11
- import { discoveryKey, PublicKey } from '@dxos/crypto';
11
+ import { discoveryKey } from '@dxos/crypto';
12
12
  import { Protocol } from '@dxos/mesh-protocol';
13
+ import { PublicKey } from '@dxos/protocols';
13
14
  import { afterTest } from '@dxos/testutils';
14
15
 
15
16
  import { TestProtocolPlugin, testProtocolProvider } from '../testing/test-protocol';
@@ -8,8 +8,8 @@ import debug from 'debug';
8
8
  import SimplePeerConstructor, { Instance as SimplePeer } from 'simple-peer';
9
9
 
10
10
  import { Event } from '@dxos/async';
11
- import { PublicKey } from '@dxos/crypto';
12
11
  import { ErrorStream } from '@dxos/debug';
12
+ import { PublicKey } from '@dxos/protocols';
13
13
 
14
14
  import { SignalApi } from '../signal';
15
15
  import { Transport, TransportFactory } from './transport';
package/src/types.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- import { PublicKey } from '@dxos/crypto';
5
+ import { PublicKey } from '@dxos/protocols';
6
6
 
7
7
  /**
8
8
  * Swarm topic.