@dxos/network-manager 0.6.8-main.3be982f → 0.6.8-staging.63bcb81

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 (49) hide show
  1. package/dist/lib/browser/{chunk-ZT4NXID2.mjs → chunk-ZQ4OU7JZ.mjs} +289 -251
  2. package/dist/lib/browser/chunk-ZQ4OU7JZ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/testing/index.mjs +5 -2
  6. package/dist/lib/browser/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-DZJ3BJOK.cjs → chunk-IQBYIEAR.cjs} +294 -256
  8. package/dist/lib/node/chunk-IQBYIEAR.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +28 -28
  10. package/dist/lib/node/index.cjs.map +1 -1
  11. package/dist/lib/node/meta.json +1 -1
  12. package/dist/lib/node/testing/index.cjs +22 -19
  13. package/dist/lib/node/testing/index.cjs.map +3 -3
  14. package/dist/types/src/network-manager.d.ts +9 -6
  15. package/dist/types/src/network-manager.d.ts.map +1 -1
  16. package/dist/types/src/signal/signal-connection.d.ts +3 -2
  17. package/dist/types/src/signal/signal-connection.d.ts.map +1 -1
  18. package/dist/types/src/signal/signal-messenger.d.ts +5 -4
  19. package/dist/types/src/signal/signal-messenger.d.ts.map +1 -1
  20. package/dist/types/src/signal/swarm-messenger.d.ts +4 -7
  21. package/dist/types/src/signal/swarm-messenger.d.ts.map +1 -1
  22. package/dist/types/src/swarm/connection.d.ts +4 -4
  23. package/dist/types/src/swarm/connection.d.ts.map +1 -1
  24. package/dist/types/src/swarm/peer.d.ts +5 -4
  25. package/dist/types/src/swarm/peer.d.ts.map +1 -1
  26. package/dist/types/src/swarm/swarm-mapper.d.ts.map +1 -1
  27. package/dist/types/src/swarm/swarm.d.ts +4 -4
  28. package/dist/types/src/swarm/swarm.d.ts.map +1 -1
  29. package/dist/types/src/tests/basic-test-suite.d.ts.map +1 -1
  30. package/dist/types/src/tests/property-test-suite.d.ts.map +1 -1
  31. package/package.json +19 -18
  32. package/src/connection-log.ts +1 -1
  33. package/src/network-manager.ts +27 -13
  34. package/src/signal/integration.test.ts +25 -19
  35. package/src/signal/signal-connection.ts +3 -2
  36. package/src/signal/signal-messenger.ts +5 -4
  37. package/src/signal/swarm-messenger.test.ts +21 -21
  38. package/src/signal/swarm-messenger.ts +11 -10
  39. package/src/swarm/connection.test.ts +19 -17
  40. package/src/swarm/connection.ts +16 -15
  41. package/src/swarm/peer.ts +41 -35
  42. package/src/swarm/swarm-mapper.ts +7 -6
  43. package/src/swarm/swarm.test.ts +36 -28
  44. package/src/swarm/swarm.ts +57 -53
  45. package/src/testing/test-builder.ts +1 -1
  46. package/src/tests/basic-test-suite.ts +8 -5
  47. package/src/tests/property-test-suite.ts +4 -1
  48. package/dist/lib/browser/chunk-ZT4NXID2.mjs.map +0 -7
  49. package/dist/lib/node/chunk-DZJ3BJOK.cjs.map +0 -7
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_DZJ3BJOK_exports = {};
30
- __export(chunk_DZJ3BJOK_exports, {
29
+ var chunk_IQBYIEAR_exports = {};
30
+ __export(chunk_IQBYIEAR_exports, {
31
31
  Connection: () => Connection,
32
32
  ConnectionLimiter: () => ConnectionLimiter,
33
33
  ConnectionLog: () => ConnectionLog,
@@ -56,7 +56,7 @@ __export(chunk_DZJ3BJOK_exports, {
56
56
  createSimplePeerTransportFactory: () => createSimplePeerTransportFactory,
57
57
  createTeleportProtocolFactory: () => createTeleportProtocolFactory
58
58
  });
59
- module.exports = __toCommonJS(chunk_DZJ3BJOK_exports);
59
+ module.exports = __toCommonJS(chunk_IQBYIEAR_exports);
60
60
  var import_async = require("@dxos/async");
61
61
  var import_context = require("@dxos/context");
62
62
  var import_debug = require("@dxos/debug");
@@ -79,6 +79,7 @@ var import_debug2 = require("@dxos/debug");
79
79
  var import_invariant3 = require("@dxos/invariant");
80
80
  var import_keys3 = require("@dxos/keys");
81
81
  var import_log4 = require("@dxos/log");
82
+ var import_messaging = require("@dxos/messaging");
82
83
  var import_protocols3 = require("@dxos/protocols");
83
84
  var import_util3 = require("@dxos/util");
84
85
  var import_async4 = require("@dxos/async");
@@ -90,6 +91,7 @@ var import_protocols4 = require("@dxos/protocols");
90
91
  var import_async5 = require("@dxos/async");
91
92
  var import_keys5 = require("@dxos/keys");
92
93
  var import_log6 = require("@dxos/log");
94
+ var import_messaging2 = require("@dxos/messaging");
93
95
  var import_util4 = require("@dxos/util");
94
96
  var import_async6 = require("@dxos/async");
95
97
  var import_context5 = require("@dxos/context");
@@ -106,7 +108,7 @@ var import_async8 = require("@dxos/async");
106
108
  var import_invariant6 = require("@dxos/invariant");
107
109
  var import_keys8 = require("@dxos/keys");
108
110
  var import_log8 = require("@dxos/log");
109
- var import_messaging = require("@dxos/messaging");
111
+ var import_messaging3 = require("@dxos/messaging");
110
112
  var import_protocols6 = require("@dxos/protocols");
111
113
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
112
114
  var import_util7 = require("@dxos/util");
@@ -191,10 +193,10 @@ var ConnectionState;
191
193
  ConnectionState5["ABORTED"] = "ABORTED";
192
194
  })(ConnectionState || (ConnectionState = {}));
193
195
  var Connection = class {
194
- constructor(topic, ownId, remoteId, sessionId, initiator, _signalMessaging, _protocol, _transportFactory, _callbacks) {
196
+ constructor(topic, localInfo, remoteInfo, sessionId, initiator, _signalMessaging, _protocol, _transportFactory, _callbacks) {
195
197
  this.topic = topic;
196
- this.ownId = ownId;
197
- this.remoteId = remoteId;
198
+ this.localInfo = localInfo;
199
+ this.remoteInfo = remoteInfo;
198
200
  this.sessionId = sessionId;
199
201
  this.initiator = initiator;
200
202
  this._signalMessaging = _signalMessaging;
@@ -203,11 +205,11 @@ var Connection = class {
203
205
  this._callbacks = _callbacks;
204
206
  this._ctx = new import_context.Context(void 0, {
205
207
  F: __dxlog_file,
206
- L: 100
208
+ L: 101
207
209
  });
208
210
  this.connectedTimeoutContext = new import_context.Context(void 0, {
209
211
  F: __dxlog_file,
210
- L: 101
212
+ L: 102
211
213
  });
212
214
  this._protocolClosed = new import_async.Trigger();
213
215
  this._transportClosed = new import_async.Trigger();
@@ -225,12 +227,12 @@ var Connection = class {
225
227
  import_log.log.trace("dxos.mesh.connection.construct", {
226
228
  sessionId: this.sessionId,
227
229
  topic: this.topic,
228
- localPeerId: this.ownId,
229
- remotePeerId: this.remoteId,
230
+ localPeer: this.localInfo,
231
+ remotePeer: this.remoteInfo,
230
232
  initiator: this.initiator
231
233
  }, {
232
234
  F: __dxlog_file,
233
- L: 137,
235
+ L: 138,
234
236
  S: this,
235
237
  C: (f, a) => f(...a)
236
238
  });
@@ -253,7 +255,7 @@ var Connection = class {
253
255
  async openConnection() {
254
256
  (0, import_invariant.invariant)(this._state === "INITIAL", "Invalid state.", {
255
257
  F: __dxlog_file,
256
- L: 167,
258
+ L: 168,
257
259
  S: this,
258
260
  A: [
259
261
  "this._state === ConnectionState.INITIAL",
@@ -264,19 +266,19 @@ var Connection = class {
264
266
  id: this._instanceId
265
267
  }), {
266
268
  F: __dxlog_file,
267
- L: 168,
269
+ L: 169,
268
270
  S: this,
269
271
  C: (f, a) => f(...a)
270
272
  });
271
273
  import_log.log.trace("dxos.mesh.connection.open", {
272
274
  sessionId: this.sessionId,
273
275
  topic: this.topic,
274
- localPeerId: this.ownId,
275
- remotePeerId: this.remoteId,
276
+ localPeerId: this.localInfo,
277
+ remotePeerId: this.remoteInfo,
276
278
  initiator: this.initiator
277
279
  }, {
278
280
  F: __dxlog_file,
279
- L: 169,
281
+ L: 170,
280
282
  S: this,
281
283
  C: (f, a) => f(...a)
282
284
  });
@@ -287,7 +289,7 @@ var Connection = class {
287
289
  this._protocol.stream.on("close", () => {
288
290
  (0, import_log.log)("protocol stream closed", void 0, {
289
291
  F: __dxlog_file,
290
- L: 186,
292
+ L: 187,
291
293
  S: this,
292
294
  C: (f, a) => f(...a)
293
295
  });
@@ -297,7 +299,7 @@ var Connection = class {
297
299
  (0, import_async.scheduleTask)(this.connectedTimeoutContext, async () => {
298
300
  import_log.log.info(`timeout waiting ${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect, aborting`, void 0, {
299
301
  F: __dxlog_file,
300
- L: 194,
302
+ L: 195,
301
303
  S: this,
302
304
  C: (f, a) => f(...a)
303
305
  });
@@ -305,7 +307,7 @@ var Connection = class {
305
307
  }, TRANSPORT_CONNECTION_TIMEOUT);
306
308
  (0, import_invariant.invariant)(!this._transport, void 0, {
307
309
  F: __dxlog_file,
308
- L: 202,
310
+ L: 203,
309
311
  S: this,
310
312
  A: [
311
313
  "!this._transport",
@@ -330,7 +332,7 @@ var Connection = class {
330
332
  this._transportClosed.wake();
331
333
  (0, import_log.log)("abort triggered by transport close", void 0, {
332
334
  F: __dxlog_file,
333
- L: 223,
335
+ L: 224,
334
336
  S: this,
335
337
  C: (f, a) => f(...a)
336
338
  });
@@ -341,7 +343,7 @@ var Connection = class {
341
343
  err
342
344
  }, {
343
345
  F: __dxlog_file,
344
- L: 228,
346
+ L: 229,
345
347
  S: this,
346
348
  C: (f, a) => f(...a)
347
349
  });
@@ -351,7 +353,7 @@ var Connection = class {
351
353
  if (err instanceof import_protocols.ConnectionResetError) {
352
354
  import_log.log.info("aborting due to transport ConnectionResetError", void 0, {
353
355
  F: __dxlog_file,
354
- L: 235,
356
+ L: 236,
355
357
  S: this,
356
358
  C: (f, a) => f(...a)
357
359
  });
@@ -359,7 +361,7 @@ var Connection = class {
359
361
  } else if (err instanceof import_protocols.ConnectivityError) {
360
362
  import_log.log.info("aborting due to transport ConnectivityError", void 0, {
361
363
  F: __dxlog_file,
362
- L: 238,
364
+ L: 239,
363
365
  S: this,
364
366
  C: (f, a) => f(...a)
365
367
  });
@@ -369,7 +371,7 @@ var Connection = class {
369
371
  err
370
372
  }, {
371
373
  F: __dxlog_file,
372
- L: 241,
374
+ L: 242,
373
375
  S: this,
374
376
  C: (f, a) => f(...a)
375
377
  });
@@ -387,7 +389,7 @@ var Connection = class {
387
389
  id: this._instanceId
388
390
  }), {
389
391
  F: __dxlog_file,
390
- L: 257,
392
+ L: 258,
391
393
  S: this,
392
394
  C: (f, a) => f(...a)
393
395
  });
@@ -397,14 +399,14 @@ var Connection = class {
397
399
  err
398
400
  }, {
399
401
  F: __dxlog_file,
400
- L: 264,
402
+ L: 265,
401
403
  S: this,
402
404
  C: (f, a) => f(...a)
403
405
  });
404
406
  if (this._state === "CLOSED" || this._state === "ABORTED") {
405
407
  (0, import_log.log)(`abort ignored: already ${this._state}`, this.closeReason, {
406
408
  F: __dxlog_file,
407
- L: 266,
409
+ L: 267,
408
410
  S: this,
409
411
  C: (f, a) => f(...a)
410
412
  });
@@ -423,7 +425,7 @@ var Connection = class {
423
425
  } catch (err2) {
424
426
  import_log.log.catch(err2, void 0, {
425
427
  F: __dxlog_file,
426
- L: 282,
428
+ L: 283,
427
429
  S: this,
428
430
  C: (f, a) => f(...a)
429
431
  });
@@ -433,7 +435,7 @@ var Connection = class {
433
435
  } catch (err2) {
434
436
  import_log.log.catch(err2, void 0, {
435
437
  F: __dxlog_file,
436
- L: 289,
438
+ L: 290,
437
439
  S: this,
438
440
  C: (f, a) => f(...a)
439
441
  });
@@ -443,7 +445,7 @@ var Connection = class {
443
445
  } catch (err2) {
444
446
  import_log.log.catch(err2, void 0, {
445
447
  F: __dxlog_file,
446
- L: 295,
448
+ L: 296,
447
449
  S: this,
448
450
  C: (f, a) => f(...a)
449
451
  });
@@ -464,10 +466,10 @@ var Connection = class {
464
466
  await this.connectedTimeoutContext.dispose();
465
467
  await this._ctx.dispose();
466
468
  (0, import_log.log)("closing...", {
467
- peerId: this.ownId
469
+ peerId: this.localInfo
468
470
  }, {
469
471
  F: __dxlog_file,
470
- L: 320,
472
+ L: 321,
471
473
  S: this,
472
474
  C: (f, a) => f(...a)
473
475
  });
@@ -475,7 +477,7 @@ var Connection = class {
475
477
  if (lastState !== "CONNECTED") {
476
478
  (0, import_log.log)(`graceful close requested when we were in ${lastState} state? aborting`, void 0, {
477
479
  F: __dxlog_file,
478
- L: 324,
480
+ L: 325,
479
481
  S: this,
480
482
  C: (f, a) => f(...a)
481
483
  });
@@ -488,7 +490,7 @@ var Connection = class {
488
490
  } catch (err2) {
489
491
  import_log.log.catch(err2, void 0, {
490
492
  F: __dxlog_file,
491
- L: 330,
493
+ L: 331,
492
494
  S: this,
493
495
  C: (f, a) => f(...a)
494
496
  });
@@ -498,16 +500,16 @@ var Connection = class {
498
500
  } catch (err2) {
499
501
  import_log.log.catch(err2, void 0, {
500
502
  F: __dxlog_file,
501
- L: 336,
503
+ L: 337,
502
504
  S: this,
503
505
  C: (f, a) => f(...a)
504
506
  });
505
507
  }
506
508
  (0, import_log.log)("closed", {
507
- peerId: this.ownId
509
+ peerId: this.localInfo
508
510
  }, {
509
511
  F: __dxlog_file,
510
- L: 339,
512
+ L: 340,
511
513
  S: this,
512
514
  C: (f, a) => f(...a)
513
515
  });
@@ -517,7 +519,7 @@ var Connection = class {
517
519
  async _closeProtocol(options) {
518
520
  (0, import_log.log)("closing protocol", options, {
519
521
  F: __dxlog_file,
520
- L: 345,
522
+ L: 346,
521
523
  S: this,
522
524
  C: (f, a) => f(...a)
523
525
  });
@@ -527,7 +529,7 @@ var Connection = class {
527
529
  ]);
528
530
  (0, import_log.log)("protocol closed", options, {
529
531
  F: __dxlog_file,
530
- L: 347,
532
+ L: 348,
531
533
  S: this,
532
534
  C: (f, a) => f(...a)
533
535
  });
@@ -535,7 +537,7 @@ var Connection = class {
535
537
  async _closeTransport() {
536
538
  (0, import_log.log)("closing transport", void 0, {
537
539
  F: __dxlog_file,
538
- L: 351,
540
+ L: 352,
539
541
  S: this,
540
542
  C: (f, a) => f(...a)
541
543
  });
@@ -545,7 +547,7 @@ var Connection = class {
545
547
  ]);
546
548
  (0, import_log.log)("transport closed", void 0, {
547
549
  F: __dxlog_file,
548
- L: 353,
550
+ L: 354,
549
551
  S: this,
550
552
  C: (f, a) => f(...a)
551
553
  });
@@ -568,8 +570,8 @@ var Connection = class {
568
570
  ];
569
571
  this._outgoingSignalBuffer.length = 0;
570
572
  await this._signalMessaging.signal({
571
- author: this.ownId,
572
- recipient: this.remoteId,
573
+ author: this.localInfo,
574
+ recipient: this.remoteInfo,
573
575
  sessionId: this.sessionId,
574
576
  topic: this.topic,
575
577
  data: {
@@ -586,7 +588,7 @@ var Connection = class {
586
588
  err
587
589
  }, {
588
590
  F: __dxlog_file,
589
- L: 393,
591
+ L: 394,
590
592
  S: this,
591
593
  C: (f, a) => f(...a)
592
594
  });
@@ -599,7 +601,7 @@ var Connection = class {
599
601
  async signal(msg) {
600
602
  (0, import_invariant.invariant)(msg.sessionId, void 0, {
601
603
  F: __dxlog_file,
602
- L: 402,
604
+ L: 403,
603
605
  S: this,
604
606
  A: [
605
607
  "msg.sessionId",
@@ -609,7 +611,7 @@ var Connection = class {
609
611
  if (!msg.sessionId.equals(this.sessionId)) {
610
612
  (0, import_log.log)("dropping signal for incorrect session id", void 0, {
611
613
  F: __dxlog_file,
612
- L: 404,
614
+ L: 405,
613
615
  S: this,
614
616
  C: (f, a) => f(...a)
615
617
  });
@@ -617,28 +619,28 @@ var Connection = class {
617
619
  }
618
620
  (0, import_invariant.invariant)(msg.data.signal || msg.data.signalBatch, void 0, {
619
621
  F: __dxlog_file,
620
- L: 407,
622
+ L: 408,
621
623
  S: this,
622
624
  A: [
623
625
  "msg.data.signal || msg.data.signalBatch",
624
626
  ""
625
627
  ]
626
628
  });
627
- (0, import_invariant.invariant)(msg.author?.equals(this.remoteId), void 0, {
629
+ (0, import_invariant.invariant)(msg.author.peerKey === this.remoteInfo.peerKey, void 0, {
628
630
  F: __dxlog_file,
629
- L: 408,
631
+ L: 409,
630
632
  S: this,
631
633
  A: [
632
- "msg.author?.equals(this.remoteId)",
634
+ "msg.author.peerKey === this.remoteInfo.peerKey",
633
635
  ""
634
636
  ]
635
637
  });
636
- (0, import_invariant.invariant)(msg.recipient?.equals(this.ownId), void 0, {
638
+ (0, import_invariant.invariant)(msg.recipient.peerKey === this.localInfo.peerKey, void 0, {
637
639
  F: __dxlog_file,
638
- L: 409,
640
+ L: 410,
639
641
  S: this,
640
642
  A: [
641
- "msg.recipient?.equals(this.ownId)",
643
+ "msg.recipient.peerKey === this.localInfo.peerKey",
642
644
  ""
643
645
  ]
644
646
  });
@@ -654,12 +656,12 @@ var Connection = class {
654
656
  "INITIAL"
655
657
  ].includes(this.state)) {
656
658
  (0, import_log.log)("buffered signal", {
657
- peerId: this.ownId,
658
- remoteId: this.remoteId,
659
+ peerId: this.localInfo,
660
+ remoteId: this.remoteInfo,
659
661
  msg: msg.data
660
662
  }, {
661
663
  F: __dxlog_file,
662
- L: 418,
664
+ L: 419,
663
665
  S: this,
664
666
  C: (f, a) => f(...a)
665
667
  });
@@ -667,7 +669,7 @@ var Connection = class {
667
669
  } else {
668
670
  (0, import_invariant.invariant)(this._transport, "Connection not ready to accept signals.", {
669
671
  F: __dxlog_file,
670
- L: 421,
672
+ L: 422,
671
673
  S: this,
672
674
  A: [
673
675
  "this._transport",
@@ -675,12 +677,12 @@ var Connection = class {
675
677
  ]
676
678
  });
677
679
  (0, import_log.log)("received signal", {
678
- peerId: this.ownId,
679
- remoteId: this.remoteId,
680
+ peerId: this.localInfo,
681
+ remoteId: this.remoteInfo,
680
682
  msg: msg.data
681
683
  }, {
682
684
  F: __dxlog_file,
683
- L: 422,
685
+ L: 423,
684
686
  S: this,
685
687
  C: (f, a) => f(...a)
686
688
  });
@@ -695,16 +697,16 @@ var Connection = class {
695
697
  (0, import_log.log)("stateChanged", {
696
698
  from: this._state,
697
699
  to: state,
698
- peerId: this.ownId
700
+ peerId: this.localInfo
699
701
  }, {
700
702
  F: __dxlog_file,
701
- L: 433,
703
+ L: 434,
702
704
  S: this,
703
705
  C: (f, a) => f(...a)
704
706
  });
705
707
  (0, import_invariant.invariant)(state !== this._state, "Already in this state.", {
706
708
  F: __dxlog_file,
707
- L: 434,
709
+ L: 435,
708
710
  S: this,
709
711
  A: [
710
712
  "state !== this._state",
@@ -759,7 +761,7 @@ var SwarmMessenger = class {
759
761
  constructor({ sendMessage, onSignal, onOffer, topic }) {
760
762
  this._ctx = new import_context2.Context(void 0, {
761
763
  F: __dxlog_file3,
762
- L: 33
764
+ L: 34
763
765
  });
764
766
  this._offerRecords = new import_util2.ComplexMap((key) => key.toHex());
765
767
  this._sendMessage = sendMessage;
@@ -781,7 +783,7 @@ var SwarmMessenger = class {
781
783
  msg: message
782
784
  }, {
783
785
  F: __dxlog_file3,
784
- L: 69,
786
+ L: 70,
785
787
  S: this,
786
788
  C: (f, a) => f(...a)
787
789
  });
@@ -810,7 +812,7 @@ var SwarmMessenger = class {
810
812
  message
811
813
  }, {
812
814
  F: __dxlog_file3,
813
- L: 80,
815
+ L: 81,
814
816
  S: this,
815
817
  C: (f, a) => f(...a)
816
818
  });
@@ -819,7 +821,7 @@ var SwarmMessenger = class {
819
821
  async signal(message) {
820
822
  (0, import_invariant2.invariant)(message.data?.signal || message.data?.signalBatch, "Invalid message", {
821
823
  F: __dxlog_file3,
822
- L: 85,
824
+ L: 86,
823
825
  S: this,
824
826
  A: [
825
827
  "message.data?.signal || message.data?.signalBatch",
@@ -860,7 +862,7 @@ var SwarmMessenger = class {
860
862
  msg: networkMessage
861
863
  }, {
862
864
  F: __dxlog_file3,
863
- L: 123,
865
+ L: 124,
864
866
  S: this,
865
867
  C: (f, a) => f(...a)
866
868
  });
@@ -876,7 +878,7 @@ var SwarmMessenger = class {
876
878
  async _resolveAnswers(message) {
877
879
  (0, import_invariant2.invariant)(message.data?.answer?.offerMessageId, "No offerMessageId", {
878
880
  F: __dxlog_file3,
879
- L: 135,
881
+ L: 136,
880
882
  S: this,
881
883
  A: [
882
884
  "message.data?.answer?.offerMessageId",
@@ -888,7 +890,7 @@ var SwarmMessenger = class {
888
890
  this._offerRecords.delete(message.data.answer.offerMessageId);
889
891
  (0, import_invariant2.invariant)(message.data?.answer, "No answer", {
890
892
  F: __dxlog_file3,
891
- L: 139,
893
+ L: 140,
892
894
  S: this,
893
895
  A: [
894
896
  "message.data?.answer",
@@ -899,7 +901,7 @@ var SwarmMessenger = class {
899
901
  answer: message.data.answer
900
902
  }, {
901
903
  F: __dxlog_file3,
902
- L: 140,
904
+ L: 141,
903
905
  S: this,
904
906
  C: (f, a) => f(...a)
905
907
  });
@@ -909,7 +911,7 @@ var SwarmMessenger = class {
909
911
  async _handleOffer({ author, recipient, message }) {
910
912
  (0, import_invariant2.invariant)(message.data.offer, "No offer", {
911
913
  F: __dxlog_file3,
912
- L: 154,
914
+ L: 155,
913
915
  S: this,
914
916
  A: [
915
917
  "message.data.offer",
@@ -944,7 +946,7 @@ var SwarmMessenger = class {
944
946
  err
945
947
  }, {
946
948
  F: __dxlog_file3,
947
- L: 175,
949
+ L: 176,
948
950
  S: this,
949
951
  C: (f, a) => f(...a)
950
952
  });
@@ -953,7 +955,7 @@ var SwarmMessenger = class {
953
955
  err
954
956
  }, {
955
957
  F: __dxlog_file3,
956
- L: 177,
958
+ L: 178,
957
959
  S: this,
958
960
  C: (f, a) => f(...a)
959
961
  });
@@ -963,7 +965,7 @@ var SwarmMessenger = class {
963
965
  async _handleSignal({ author, recipient, message }) {
964
966
  (0, import_invariant2.invariant)(message.messageId, void 0, {
965
967
  F: __dxlog_file3,
966
- L: 191,
968
+ L: 192,
967
969
  S: this,
968
970
  A: [
969
971
  "message.messageId",
@@ -972,7 +974,7 @@ var SwarmMessenger = class {
972
974
  });
973
975
  (0, import_invariant2.invariant)(message.data.signal || message.data.signalBatch, "Invalid message", {
974
976
  F: __dxlog_file3,
975
- L: 192,
977
+ L: 193,
976
978
  S: this,
977
979
  A: [
978
980
  "message.data.signal || message.data.signalBatch",
@@ -1009,10 +1011,10 @@ var ConnectionDisplacedError = class extends import_protocols4.SystemError {
1009
1011
  };
1010
1012
  var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
1011
1013
  var Peer = class {
1012
- constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _connectionLimiter, _callbacks) {
1013
- this.id = id;
1014
+ constructor(remoteInfo, topic, localInfo, _signalMessaging, _protocolProvider, _transportFactory, _connectionLimiter, _callbacks) {
1015
+ this.remoteInfo = remoteInfo;
1014
1016
  this.topic = topic;
1015
- this.localPeerId = localPeerId;
1017
+ this.localInfo = localInfo;
1016
1018
  this._signalMessaging = _signalMessaging;
1017
1019
  this._protocolProvider = _protocolProvider;
1018
1020
  this._transportFactory = _transportFactory;
@@ -1022,7 +1024,7 @@ var Peer = class {
1022
1024
  this.availableToConnect = true;
1023
1025
  this._ctx = new import_context4.Context(void 0, {
1024
1026
  F: __dxlog_file4,
1025
- L: 79
1027
+ L: 80
1026
1028
  });
1027
1029
  this.advertizing = false;
1028
1030
  this.initiating = false;
@@ -1032,7 +1034,7 @@ var Peer = class {
1032
1034
  * Respond to remote offer.
1033
1035
  */
1034
1036
  async onOffer(message) {
1035
- const remoteId = message.author;
1037
+ const remote = message.author;
1036
1038
  if (this.connection && ![
1037
1039
  ConnectionState.CREATED,
1038
1040
  ConnectionState.INITIAL,
@@ -1040,7 +1042,7 @@ var Peer = class {
1040
1042
  ].includes(this.connection.state)) {
1041
1043
  import_log5.log.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
1042
1044
  F: __dxlog_file4,
1043
- L: 114,
1045
+ L: 115,
1044
1046
  S: this,
1045
1047
  C: (f, a) => f(...a)
1046
1048
  });
@@ -1049,15 +1051,15 @@ var Peer = class {
1049
1051
  };
1050
1052
  }
1051
1053
  if (this.connection || this.initiating) {
1052
- if (remoteId.toHex() < this.localPeerId.toHex()) {
1054
+ if (remote.peerKey < this.localInfo.peerKey) {
1053
1055
  (0, import_log5.log)("close local connection", {
1054
- localPeerId: this.id,
1056
+ localPeer: this.localInfo,
1055
1057
  topic: this.topic,
1056
- remotePeerId: this.localPeerId,
1058
+ remotePeer: this.remoteInfo,
1057
1059
  sessionId: this.connection?.sessionId
1058
1060
  }, {
1059
1061
  F: __dxlog_file4,
1060
- L: 123,
1062
+ L: 124,
1061
1063
  S: this,
1062
1064
  C: (f, a) => f(...a)
1063
1065
  });
@@ -1070,11 +1072,11 @@ var Peer = class {
1070
1072
  };
1071
1073
  }
1072
1074
  }
1073
- if (await this._callbacks.onOffer(remoteId)) {
1075
+ if (await this._callbacks.onOffer(remote)) {
1074
1076
  if (!this.connection) {
1075
1077
  (0, import_invariant4.invariant)(message.sessionId, void 0, {
1076
1078
  F: __dxlog_file4,
1077
- L: 143,
1079
+ L: 144,
1078
1080
  S: this,
1079
1081
  A: [
1080
1082
  "message.sessionId",
@@ -1090,12 +1092,12 @@ var Peer = class {
1090
1092
  if (!(err instanceof import_protocols4.CancelledError)) {
1091
1093
  import_log5.log.info("connection error", {
1092
1094
  topic: this.topic,
1093
- peerId: this.localPeerId,
1094
- remoteId: this.id,
1095
+ peerId: this.localInfo,
1096
+ remoteId: this.remoteInfo,
1095
1097
  err
1096
1098
  }, {
1097
1099
  F: __dxlog_file4,
1098
- L: 153,
1100
+ L: 154,
1099
1101
  S: this,
1100
1102
  C: (f, a) => f(...a)
1101
1103
  });
@@ -1117,7 +1119,7 @@ var Peer = class {
1117
1119
  async initiateConnection() {
1118
1120
  (0, import_invariant4.invariant)(!this.initiating, "Initiation in progress.", {
1119
1121
  F: __dxlog_file4,
1120
- L: 170,
1122
+ L: 171,
1121
1123
  S: this,
1122
1124
  A: [
1123
1125
  "!this.initiating",
@@ -1126,7 +1128,7 @@ var Peer = class {
1126
1128
  });
1127
1129
  (0, import_invariant4.invariant)(!this.connection, "Already connected.", {
1128
1130
  F: __dxlog_file4,
1129
- L: 171,
1131
+ L: 172,
1130
1132
  S: this,
1131
1133
  A: [
1132
1134
  "!this.connection",
@@ -1135,13 +1137,13 @@ var Peer = class {
1135
1137
  });
1136
1138
  const sessionId = import_keys4.PublicKey.random();
1137
1139
  (0, import_log5.log)("initiating...", {
1138
- ownPeerId: this.localPeerId,
1140
+ local: this.localInfo,
1139
1141
  topic: this.topic,
1140
- remotePeerId: this.id,
1142
+ remote: this.remoteInfo,
1141
1143
  sessionId
1142
1144
  }, {
1143
1145
  F: __dxlog_file4,
1144
- L: 173,
1146
+ L: 174,
1145
1147
  S: this,
1146
1148
  C: (f, a) => f(...a)
1147
1149
  });
@@ -1152,8 +1154,8 @@ var Peer = class {
1152
1154
  await this._connectionLimiter.connecting(sessionId);
1153
1155
  connection.initiate();
1154
1156
  answer = await this._signalMessaging.offer({
1155
- author: this.localPeerId,
1156
- recipient: this.id,
1157
+ author: this.localInfo,
1158
+ recipient: this.remoteInfo,
1157
1159
  sessionId,
1158
1160
  topic: this.topic,
1159
1161
  data: {
@@ -1163,18 +1165,18 @@ var Peer = class {
1163
1165
  (0, import_log5.log)("received", {
1164
1166
  answer,
1165
1167
  topic: this.topic,
1166
- ownId: this.localPeerId,
1167
- remoteId: this.id
1168
+ local: this.localInfo,
1169
+ remote: this.remoteInfo
1168
1170
  }, {
1169
1171
  F: __dxlog_file4,
1170
- L: 190,
1172
+ L: 191,
1171
1173
  S: this,
1172
1174
  C: (f, a) => f(...a)
1173
1175
  });
1174
1176
  if (connection.state !== ConnectionState.INITIAL) {
1175
1177
  (0, import_log5.log)("ignoring response", void 0, {
1176
1178
  F: __dxlog_file4,
1177
- L: 192,
1179
+ L: 193,
1178
1180
  S: this,
1179
1181
  C: (f, a) => f(...a)
1180
1182
  });
@@ -1184,11 +1186,11 @@ var Peer = class {
1184
1186
  (0, import_log5.log)("initiation error: send offer", {
1185
1187
  err,
1186
1188
  topic: this.topic,
1187
- peerId: this.localPeerId,
1188
- remoteId: this.id
1189
+ local: this.localInfo,
1190
+ remote: this.remoteInfo
1189
1191
  }, {
1190
1192
  F: __dxlog_file4,
1191
- L: 196,
1193
+ L: 197,
1192
1194
  S: this,
1193
1195
  C: (f, a) => f(...a)
1194
1196
  });
@@ -1206,11 +1208,11 @@ var Peer = class {
1206
1208
  (0, import_log5.log)("initiation error: accept answer", {
1207
1209
  err,
1208
1210
  topic: this.topic,
1209
- peerId: this.localPeerId,
1210
- remoteId: this.id
1211
+ local: this.localInfo,
1212
+ remote: this.remoteInfo
1211
1213
  }, {
1212
1214
  F: __dxlog_file4,
1213
- L: 209,
1215
+ L: 210,
1214
1216
  S: this,
1215
1217
  C: (f, a) => f(...a)
1216
1218
  });
@@ -1222,7 +1224,7 @@ var Peer = class {
1222
1224
  try {
1223
1225
  (0, import_log5.log)("opening connection as initiator", void 0, {
1224
1226
  F: __dxlog_file4,
1225
- L: 222,
1227
+ L: 223,
1226
1228
  S: this,
1227
1229
  C: (f, a) => f(...a)
1228
1230
  });
@@ -1232,11 +1234,11 @@ var Peer = class {
1232
1234
  (0, import_log5.log)("initiation error: open connection", {
1233
1235
  err,
1234
1236
  topic: this.topic,
1235
- peerId: this.localPeerId,
1236
- remoteId: this.id
1237
+ local: this.localInfo,
1238
+ remote: this.remoteInfo
1237
1239
  }, {
1238
1240
  F: __dxlog_file4,
1239
- L: 226,
1241
+ L: 227,
1240
1242
  S: this,
1241
1243
  C: (f, a) => f(...a)
1242
1244
  });
@@ -1244,7 +1246,7 @@ var Peer = class {
1244
1246
  err
1245
1247
  }, {
1246
1248
  F: __dxlog_file4,
1247
- L: 233,
1249
+ L: 234,
1248
1250
  S: this,
1249
1251
  C: (f, a) => f(...a)
1250
1252
  });
@@ -1261,19 +1263,19 @@ var Peer = class {
1261
1263
  _createConnection(initiator, sessionId) {
1262
1264
  (0, import_log5.log)("creating connection", {
1263
1265
  topic: this.topic,
1264
- peerId: this.localPeerId,
1265
- remoteId: this.id,
1266
+ peerId: this.localInfo,
1267
+ remoteId: this.remoteInfo,
1266
1268
  initiator,
1267
1269
  sessionId
1268
1270
  }, {
1269
1271
  F: __dxlog_file4,
1270
- L: 247,
1272
+ L: 248,
1271
1273
  S: this,
1272
1274
  C: (f, a) => f(...a)
1273
1275
  });
1274
1276
  (0, import_invariant4.invariant)(!this.connection, "Already connected.", {
1275
1277
  F: __dxlog_file4,
1276
- L: 254,
1278
+ L: 255,
1277
1279
  S: this,
1278
1280
  A: [
1279
1281
  "!this.connection",
@@ -1282,16 +1284,16 @@ var Peer = class {
1282
1284
  });
1283
1285
  const connection = new Connection(
1284
1286
  this.topic,
1285
- this.localPeerId,
1286
- this.id,
1287
+ this.localInfo,
1288
+ this.remoteInfo,
1287
1289
  sessionId,
1288
1290
  initiator,
1289
1291
  this._signalMessaging,
1290
1292
  // TODO(dmaretskyi): Init only when connection is established.
1291
1293
  this._protocolProvider({
1292
1294
  initiator,
1293
- localPeerId: this.localPeerId,
1294
- remotePeerId: this.id,
1295
+ localPeerId: import_keys4.PublicKey.from(this.localInfo.peerKey),
1296
+ remotePeerId: import_keys4.PublicKey.from(this.remoteInfo.peerKey),
1295
1297
  topic: this.topic
1296
1298
  }),
1297
1299
  this._transportFactory,
@@ -1303,13 +1305,13 @@ var Peer = class {
1303
1305
  this._connectionLimiter.doneConnecting(sessionId);
1304
1306
  import_log5.log.trace("dxos.mesh.connection.connected", {
1305
1307
  topic: this.topic,
1306
- localPeerId: this.localPeerId,
1307
- remotePeerId: this.id,
1308
+ localPeerId: this.localInfo,
1309
+ remotePeerId: this.remoteInfo,
1308
1310
  sessionId,
1309
1311
  initiator
1310
1312
  }, {
1311
1313
  F: __dxlog_file4,
1312
- L: 273,
1314
+ L: 279,
1313
1315
  S: this,
1314
1316
  C: (f, a) => f(...a)
1315
1317
  });
@@ -1317,19 +1319,19 @@ var Peer = class {
1317
1319
  onClosed: (err) => {
1318
1320
  (0, import_log5.log)("connection closed", {
1319
1321
  topic: this.topic,
1320
- peerId: this.localPeerId,
1321
- remoteId: this.id,
1322
+ peerId: this.localInfo,
1323
+ remoteId: this.remoteInfo,
1322
1324
  initiator
1323
1325
  }, {
1324
1326
  F: __dxlog_file4,
1325
- L: 282,
1327
+ L: 288,
1326
1328
  S: this,
1327
1329
  C: (f, a) => f(...a)
1328
1330
  });
1329
1331
  this._connectionLimiter.doneConnecting(sessionId);
1330
1332
  (0, import_invariant4.invariant)(this.connection === connection, "Connection mismatch (race condition).", {
1331
1333
  F: __dxlog_file4,
1332
- L: 287,
1334
+ L: 293,
1333
1335
  S: this,
1334
1336
  A: [
1335
1337
  "this.connection === connection",
@@ -1338,13 +1340,13 @@ var Peer = class {
1338
1340
  });
1339
1341
  import_log5.log.trace("dxos.mesh.connection.closed", {
1340
1342
  topic: this.topic,
1341
- localPeerId: this.localPeerId,
1342
- remotePeerId: this.id,
1343
+ localPeerId: this.localInfo,
1344
+ remotePeerId: this.remoteInfo,
1343
1345
  sessionId,
1344
1346
  initiator
1345
1347
  }, {
1346
1348
  F: __dxlog_file4,
1347
- L: 289,
1349
+ L: 295,
1348
1350
  S: this,
1349
1351
  C: (f, a) => f(...a)
1350
1352
  });
@@ -1373,26 +1375,26 @@ var Peer = class {
1373
1375
  connection.errors.handle((err) => {
1374
1376
  import_log5.log.info("connection error, closing", {
1375
1377
  topic: this.topic,
1376
- peerId: this.localPeerId,
1377
- remoteId: this.id,
1378
+ peerId: this.localInfo,
1379
+ remoteId: this.remoteInfo,
1378
1380
  initiator,
1379
1381
  err
1380
1382
  }, {
1381
1383
  F: __dxlog_file4,
1382
- L: 329,
1384
+ L: 335,
1383
1385
  S: this,
1384
1386
  C: (f, a) => f(...a)
1385
1387
  });
1386
1388
  import_log5.log.trace("dxos.mesh.connection.error", {
1387
1389
  topic: this.topic,
1388
- localPeerId: this.localPeerId,
1389
- remotePeerId: this.id,
1390
+ localPeerId: this.localInfo,
1391
+ remotePeerId: this.remoteInfo,
1390
1392
  sessionId,
1391
1393
  initiator,
1392
1394
  err
1393
1395
  }, {
1394
1396
  F: __dxlog_file4,
1395
- L: 336,
1397
+ L: 342,
1396
1398
  S: this,
1397
1399
  C: (f, a) => f(...a)
1398
1400
  });
@@ -1407,21 +1409,21 @@ var Peer = class {
1407
1409
  }
1408
1410
  const connection = this.connection;
1409
1411
  (0, import_log5.log)("closing...", {
1410
- peerId: this.id,
1412
+ peerId: this.remoteInfo,
1411
1413
  sessionId: connection.sessionId
1412
1414
  }, {
1413
1415
  F: __dxlog_file4,
1414
- L: 361,
1416
+ L: 367,
1415
1417
  S: this,
1416
1418
  C: (f, a) => f(...a)
1417
1419
  });
1418
1420
  await connection.close(err);
1419
1421
  (0, import_log5.log)("closed", {
1420
- peerId: this.id,
1422
+ peerId: this.remoteInfo,
1421
1423
  sessionId: connection.sessionId
1422
1424
  }, {
1423
1425
  F: __dxlog_file4,
1424
- L: 367,
1426
+ L: 373,
1425
1427
  S: this,
1426
1428
  C: (f, a) => f(...a)
1427
1429
  });
@@ -1432,7 +1434,7 @@ var Peer = class {
1432
1434
  message
1433
1435
  }, {
1434
1436
  F: __dxlog_file4,
1435
- L: 372,
1437
+ L: 378,
1436
1438
  S: this,
1437
1439
  C: (f, a) => f(...a)
1438
1440
  });
@@ -1443,11 +1445,11 @@ var Peer = class {
1443
1445
  async safeDestroy(reason) {
1444
1446
  await this._ctx.dispose();
1445
1447
  (0, import_log5.log)("Destroying peer", {
1446
- peerId: this.id,
1448
+ peerId: this.remoteInfo,
1447
1449
  topic: this.topic
1448
1450
  }, {
1449
1451
  F: __dxlog_file4,
1450
- L: 382,
1452
+ L: 388,
1451
1453
  S: this,
1452
1454
  C: (f, a) => f(...a)
1453
1455
  });
@@ -1485,9 +1487,9 @@ var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
1485
1487
  var Swarm = class {
1486
1488
  // TODO(burdon): Swarm => Peer.create/destroy =< Connection.open/close
1487
1489
  // TODO(burdon): Pass in object.
1488
- constructor(_topic, _ownPeerId, _topology, _protocolProvider, _messenger, _transportFactory, _label, _connectionLimiter, _initiationDelay = INITIATION_DELAY) {
1490
+ constructor(_topic, _ownPeer, _topology, _protocolProvider, _messenger, _transportFactory, _label, _connectionLimiter, _initiationDelay = INITIATION_DELAY) {
1489
1491
  this._topic = _topic;
1490
- this._ownPeerId = _ownPeerId;
1492
+ this._ownPeer = _ownPeer;
1491
1493
  this._topology = _topology;
1492
1494
  this._protocolProvider = _protocolProvider;
1493
1495
  this._messenger = _messenger;
@@ -1497,10 +1499,10 @@ var Swarm = class {
1497
1499
  this._initiationDelay = _initiationDelay;
1498
1500
  this._ctx = new import_context3.Context(void 0, {
1499
1501
  F: __dxlog_file5,
1500
- L: 39
1502
+ L: 38
1501
1503
  });
1502
1504
  this._listeningHandle = void 0;
1503
- this._peers = new import_util3.ComplexMap(import_keys3.PublicKey.hash);
1505
+ this._peers = new import_util3.ComplexMap(import_messaging.PeerInfoHash);
1504
1506
  this._instanceId = import_keys3.PublicKey.random().toHex();
1505
1507
  this.connectionAdded = new import_async3.Event();
1506
1508
  this.disconnected = new import_async3.Event();
@@ -1510,19 +1512,19 @@ var Swarm = class {
1510
1512
  id: this._instanceId,
1511
1513
  data: {
1512
1514
  topic: this._topic.toHex(),
1513
- peerId: this._ownPeerId.toHex()
1515
+ peer: this._ownPeer
1514
1516
  }
1515
1517
  }), {
1516
1518
  F: __dxlog_file5,
1517
- L: 89,
1519
+ L: 88,
1518
1520
  S: this,
1519
1521
  C: (f, a) => f(...a)
1520
1522
  });
1521
1523
  (0, import_log4.log)("creating swarm", {
1522
- peerId: _ownPeerId
1524
+ peerId: _ownPeer
1523
1525
  }, {
1524
1526
  F: __dxlog_file5,
1525
- L: 93,
1527
+ L: 92,
1526
1528
  S: this,
1527
1529
  C: (f, a) => f(...a)
1528
1530
  });
@@ -1537,7 +1539,7 @@ var Swarm = class {
1537
1539
  id: this._instanceId
1538
1540
  }), {
1539
1541
  F: __dxlog_file5,
1540
- L: 102,
1542
+ L: 101,
1541
1543
  S: this,
1542
1544
  C: (f, a) => f(...a)
1543
1545
  });
@@ -1546,7 +1548,10 @@ var Swarm = class {
1546
1548
  return Array.from(this._peers.values()).map((peer) => peer.connection).filter(import_util3.isNotNullOrUndefined);
1547
1549
  }
1548
1550
  get ownPeerId() {
1549
- return this._ownPeerId;
1551
+ return import_keys3.PublicKey.from(this._ownPeer.peerKey);
1552
+ }
1553
+ get ownPeer() {
1554
+ return this._ownPeer;
1550
1555
  }
1551
1556
  /**
1552
1557
  * Custom label assigned to this swarm. Used in devtools to display human-readable names for swarms.
@@ -1560,7 +1565,7 @@ var Swarm = class {
1560
1565
  async open() {
1561
1566
  (0, import_invariant3.invariant)(!this._listeningHandle, void 0, {
1562
1567
  F: __dxlog_file5,
1563
- L: 129,
1568
+ L: 132,
1564
1569
  S: this,
1565
1570
  A: [
1566
1571
  "!this._listeningHandle",
@@ -1568,14 +1573,14 @@ var Swarm = class {
1568
1573
  ]
1569
1574
  });
1570
1575
  this._listeningHandle = await this._messenger.listen({
1571
- peerId: this._ownPeerId,
1576
+ peer: this._ownPeer,
1572
1577
  payloadType: "dxos.mesh.swarm.SwarmMessage",
1573
1578
  onMessage: async (message) => {
1574
1579
  await this._swarmMessenger.receiveMessage(message).catch((err) => import_log4.log.info("Error while receiving message", {
1575
1580
  err
1576
1581
  }, {
1577
1582
  F: __dxlog_file5,
1578
- L: 137,
1583
+ L: 140,
1579
1584
  S: this,
1580
1585
  C: (f, a) => f(...a)
1581
1586
  }));
@@ -1585,7 +1590,7 @@ var Swarm = class {
1585
1590
  async destroy() {
1586
1591
  (0, import_log4.log)("destroying...", void 0, {
1587
1592
  F: __dxlog_file5,
1588
- L: 143,
1593
+ L: 146,
1589
1594
  S: this,
1590
1595
  C: (f, a) => f(...a)
1591
1596
  });
@@ -1596,7 +1601,7 @@ var Swarm = class {
1596
1601
  await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key, "swarm destroyed")));
1597
1602
  (0, import_log4.log)("destroyed", void 0, {
1598
1603
  F: __dxlog_file5,
1599
- L: 150,
1604
+ L: 153,
1600
1605
  S: this,
1601
1606
  C: (f, a) => f(...a)
1602
1607
  });
@@ -1604,7 +1609,7 @@ var Swarm = class {
1604
1609
  async setTopology(topology) {
1605
1610
  (0, import_invariant3.invariant)(!this._ctx.disposed, "Swarm is offline", {
1606
1611
  F: __dxlog_file5,
1607
- L: 154,
1612
+ L: 157,
1608
1613
  S: this,
1609
1614
  A: [
1610
1615
  "!this._ctx.disposed",
@@ -1619,7 +1624,7 @@ var Swarm = class {
1619
1624
  topology: getClassName(topology)
1620
1625
  }, {
1621
1626
  F: __dxlog_file5,
1622
- L: 158,
1627
+ L: 161,
1623
1628
  S: this,
1624
1629
  C: (f, a) => f(...a)
1625
1630
  });
@@ -1633,51 +1638,51 @@ var Swarm = class {
1633
1638
  swarmEvent
1634
1639
  }, {
1635
1640
  F: __dxlog_file5,
1636
- L: 171,
1641
+ L: 174,
1637
1642
  S: this,
1638
1643
  C: (f, a) => f(...a)
1639
1644
  });
1640
1645
  if (this._ctx.disposed) {
1641
1646
  (0, import_log4.log)("swarm event ignored for disposed swarm", void 0, {
1642
1647
  F: __dxlog_file5,
1643
- L: 174,
1648
+ L: 177,
1644
1649
  S: this,
1645
1650
  C: (f, a) => f(...a)
1646
1651
  });
1647
1652
  return;
1648
1653
  }
1649
1654
  if (swarmEvent.peerAvailable) {
1650
- const peerId = import_keys3.PublicKey.from(swarmEvent.peerAvailable.peer);
1651
- if (!peerId.equals(this._ownPeerId)) {
1655
+ const peerId = swarmEvent.peerAvailable.peer.peerKey;
1656
+ if (peerId !== this._ownPeer.peerKey) {
1652
1657
  (0, import_log4.log)("new peer", {
1653
1658
  peerId
1654
1659
  }, {
1655
1660
  F: __dxlog_file5,
1656
- L: 181,
1661
+ L: 184,
1657
1662
  S: this,
1658
1663
  C: (f, a) => f(...a)
1659
1664
  });
1660
- const peer = this._getOrCreatePeer(peerId);
1665
+ const peer = this._getOrCreatePeer(swarmEvent.peerAvailable.peer);
1661
1666
  peer.advertizing = true;
1662
1667
  }
1663
1668
  } else if (swarmEvent.peerLeft) {
1664
- const peer = this._peers.get(import_keys3.PublicKey.from(swarmEvent.peerLeft.peer));
1669
+ const peer = this._peers.get(swarmEvent.peerLeft.peer);
1665
1670
  if (peer) {
1666
1671
  peer.advertizing = false;
1667
1672
  if (peer.connection?.state !== ConnectionState.CONNECTED) {
1668
- void this._destroyPeer(peer.id, "peer left").catch((err) => import_log4.log.catch(err, void 0, {
1673
+ void this._destroyPeer(swarmEvent.peerLeft.peer, "peer left").catch((err) => import_log4.log.catch(err, void 0, {
1669
1674
  F: __dxlog_file5,
1670
- L: 191,
1675
+ L: 194,
1671
1676
  S: this,
1672
1677
  C: (f, a) => f(...a)
1673
1678
  }));
1674
1679
  }
1675
1680
  } else {
1676
1681
  (0, import_log4.log)("received peerLeft but no peer found", {
1677
- peer: swarmEvent.peerLeft.peer
1682
+ peer: swarmEvent.peerLeft.peer.peerKey
1678
1683
  }, {
1679
1684
  F: __dxlog_file5,
1680
- L: 194,
1685
+ L: 197,
1681
1686
  S: this,
1682
1687
  C: (f, a) => f(...a)
1683
1688
  });
@@ -1690,14 +1695,14 @@ var Swarm = class {
1690
1695
  message
1691
1696
  }, {
1692
1697
  F: __dxlog_file5,
1693
- L: 203,
1698
+ L: 206,
1694
1699
  S: this,
1695
1700
  C: (f, a) => f(...a)
1696
1701
  });
1697
1702
  if (this._ctx.disposed) {
1698
1703
  (0, import_log4.log)("ignored for disposed swarm", void 0, {
1699
1704
  F: __dxlog_file5,
1700
- L: 205,
1705
+ L: 208,
1701
1706
  S: this,
1702
1707
  C: (f, a) => f(...a)
1703
1708
  });
@@ -1707,19 +1712,19 @@ var Swarm = class {
1707
1712
  }
1708
1713
  (0, import_invariant3.invariant)(message.author, void 0, {
1709
1714
  F: __dxlog_file5,
1710
- L: 210,
1715
+ L: 213,
1711
1716
  S: this,
1712
1717
  A: [
1713
1718
  "message.author",
1714
1719
  ""
1715
1720
  ]
1716
1721
  });
1717
- if (!message.recipient?.equals(this._ownPeerId)) {
1722
+ if (message.recipient.peerKey !== this._ownPeer.peerKey) {
1718
1723
  (0, import_log4.log)("rejecting offer with incorrect peerId", {
1719
1724
  message
1720
1725
  }, {
1721
1726
  F: __dxlog_file5,
1722
- L: 212,
1727
+ L: 215,
1723
1728
  S: this,
1724
1729
  C: (f, a) => f(...a)
1725
1730
  });
@@ -1732,7 +1737,7 @@ var Swarm = class {
1732
1737
  message
1733
1738
  }, {
1734
1739
  F: __dxlog_file5,
1735
- L: 216,
1740
+ L: 219,
1736
1741
  S: this,
1737
1742
  C: (f, a) => f(...a)
1738
1743
  });
@@ -1750,31 +1755,31 @@ var Swarm = class {
1750
1755
  message
1751
1756
  }, {
1752
1757
  F: __dxlog_file5,
1753
- L: 227,
1758
+ L: 230,
1754
1759
  S: this,
1755
1760
  C: (f, a) => f(...a)
1756
1761
  });
1757
1762
  if (this._ctx.disposed) {
1758
1763
  import_log4.log.info("ignored for offline swarm", void 0, {
1759
1764
  F: __dxlog_file5,
1760
- L: 229,
1765
+ L: 232,
1761
1766
  S: this,
1762
1767
  C: (f, a) => f(...a)
1763
1768
  });
1764
1769
  return;
1765
1770
  }
1766
- (0, import_invariant3.invariant)(message.recipient?.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
1771
+ (0, import_invariant3.invariant)(message.recipient.peerKey === this._ownPeer.peerKey, `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
1767
1772
  F: __dxlog_file5,
1768
- L: 232,
1773
+ L: 235,
1769
1774
  S: this,
1770
1775
  A: [
1771
- "message.recipient?.equals(this._ownPeerId)",
1776
+ "message.recipient.peerKey === this._ownPeer.peerKey",
1772
1777
  "`Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`"
1773
1778
  ]
1774
1779
  });
1775
1780
  (0, import_invariant3.invariant)(message.topic?.equals(this._topic), void 0, {
1776
1781
  F: __dxlog_file5,
1777
- L: 236,
1782
+ L: 239,
1778
1783
  S: this,
1779
1784
  A: [
1780
1785
  "message.topic?.equals(this._topic)",
@@ -1783,7 +1788,7 @@ var Swarm = class {
1783
1788
  });
1784
1789
  (0, import_invariant3.invariant)(message.author, void 0, {
1785
1790
  F: __dxlog_file5,
1786
- L: 237,
1791
+ L: 240,
1787
1792
  S: this,
1788
1793
  A: [
1789
1794
  "message.author",
@@ -1804,77 +1809,86 @@ var Swarm = class {
1804
1809
  async goOnline() {
1805
1810
  this._ctx = new import_context3.Context(void 0, {
1806
1811
  F: __dxlog_file5,
1807
- L: 253
1812
+ L: 256
1808
1813
  });
1809
1814
  }
1810
- _getOrCreatePeer(peerId) {
1811
- let peer = this._peers.get(peerId);
1815
+ _getOrCreatePeer(peerInfo) {
1816
+ (0, import_invariant3.invariant)(peerInfo.peerKey, "PeerInfo.peerKey is required", {
1817
+ F: __dxlog_file5,
1818
+ L: 260,
1819
+ S: this,
1820
+ A: [
1821
+ "peerInfo.peerKey",
1822
+ "'PeerInfo.peerKey is required'"
1823
+ ]
1824
+ });
1825
+ let peer = this._peers.get(peerInfo);
1812
1826
  if (!peer) {
1813
- peer = new Peer(peerId, this._topic, this._ownPeerId, this._swarmMessenger, this._protocolProvider, this._transportFactory, this._connectionLimiter, {
1827
+ peer = new Peer(peerInfo, this._topic, this._ownPeer, this._swarmMessenger, this._protocolProvider, this._transportFactory, this._connectionLimiter, {
1814
1828
  onInitiated: (connection) => {
1815
1829
  this.connectionAdded.emit(connection);
1816
1830
  },
1817
1831
  onConnected: () => {
1818
- this.connected.emit(peerId);
1832
+ this.connected.emit(peerInfo);
1819
1833
  },
1820
1834
  onDisconnected: async () => {
1821
1835
  if (this._isUnregistered(peer)) {
1822
1836
  return;
1823
1837
  }
1824
1838
  if (!peer.advertizing) {
1825
- await this._destroyPeer(peer.id, "peer disconnected");
1839
+ await this._destroyPeer(peerInfo, "peer disconnected");
1826
1840
  }
1827
- this.disconnected.emit(peerId);
1841
+ this.disconnected.emit(peerInfo);
1828
1842
  this._topology.update();
1829
1843
  },
1830
1844
  onRejected: () => {
1831
1845
  if (!this._isUnregistered(peer)) {
1832
1846
  (0, import_log4.log)("peer rejected connection", {
1833
- peerId
1847
+ peerInfo
1834
1848
  }, {
1835
1849
  F: __dxlog_file5,
1836
- L: 289,
1850
+ L: 293,
1837
1851
  S: this,
1838
1852
  C: (f, a) => f(...a)
1839
1853
  });
1840
- void this._destroyPeer(peerId, "peer rejected connection");
1854
+ void this._destroyPeer(peerInfo, "peer rejected connection");
1841
1855
  }
1842
1856
  },
1843
1857
  onAccepted: () => {
1844
1858
  this._topology.update();
1845
1859
  },
1846
1860
  onOffer: (remoteId) => {
1847
- return this._topology.onOffer(remoteId);
1861
+ return this._topology.onOffer(import_keys3.PublicKey.from(remoteId.peerKey));
1848
1862
  },
1849
1863
  onPeerAvailable: () => {
1850
1864
  this._topology.update();
1851
1865
  }
1852
1866
  });
1853
- this._peers.set(peerId, peer);
1867
+ this._peers.set(peerInfo, peer);
1854
1868
  }
1855
1869
  return peer;
1856
1870
  }
1857
- async _destroyPeer(peerId, reason) {
1858
- const peer = this._peers.get(peerId);
1871
+ async _destroyPeer(peerInfo, reason) {
1872
+ const peer = this._peers.get(peerInfo);
1859
1873
  (0, import_invariant3.invariant)(peer, void 0, {
1860
1874
  F: __dxlog_file5,
1861
- L: 312,
1875
+ L: 316,
1862
1876
  S: this,
1863
1877
  A: [
1864
1878
  "peer",
1865
1879
  ""
1866
1880
  ]
1867
1881
  });
1868
- this._peers.delete(peerId);
1882
+ this._peers.delete(peerInfo);
1869
1883
  await peer.safeDestroy(new Error(reason));
1870
1884
  }
1871
1885
  _getSwarmController() {
1872
1886
  return {
1873
1887
  getState: () => ({
1874
- ownPeerId: this._ownPeerId,
1875
- connected: Array.from(this._peers.values()).filter((peer) => peer.connection).map((peer) => peer.id),
1876
- candidates: Array.from(this._peers.values()).filter((peer) => !peer.connection && peer.advertizing && peer.availableToConnect).map((peer) => peer.id),
1877
- allPeers: Array.from(this._peers.values()).map((peer) => peer.id)
1888
+ ownPeerId: import_keys3.PublicKey.from(this._ownPeer.peerKey),
1889
+ connected: Array.from(this._peers.entries()).filter(([_, peer]) => peer.connection).map(([info]) => import_keys3.PublicKey.from(info.peerKey)),
1890
+ candidates: Array.from(this._peers.entries()).filter(([_, peer]) => !peer.connection && peer.advertizing && peer.availableToConnect).map(([info]) => import_keys3.PublicKey.from(info.peerKey)),
1891
+ allPeers: Array.from(this._peers.keys()).map((info) => import_keys3.PublicKey.from(info.peerKey))
1878
1892
  }),
1879
1893
  connect: (peer) => {
1880
1894
  if (this._ctx.disposed) {
@@ -1882,11 +1896,13 @@ var Swarm = class {
1882
1896
  }
1883
1897
  (0, import_async3.scheduleTask)(this._ctx, async () => {
1884
1898
  try {
1885
- await this._initiateConnection(peer);
1899
+ await this._initiateConnection({
1900
+ peerKey: peer.toHex()
1901
+ });
1886
1902
  } catch (err) {
1887
1903
  (0, import_log4.log)("initiation error", err, {
1888
1904
  F: __dxlog_file5,
1889
- L: 339,
1905
+ L: 343,
1890
1906
  S: this,
1891
1907
  C: (f, a) => f(...a)
1892
1908
  });
@@ -1898,7 +1914,9 @@ var Swarm = class {
1898
1914
  return;
1899
1915
  }
1900
1916
  (0, import_async3.scheduleTask)(this._ctx, async () => {
1901
- await this._closeConnection(peer);
1917
+ await this._closeConnection({
1918
+ peerKey: peer.toHex()
1919
+ });
1902
1920
  this._topology.update();
1903
1921
  });
1904
1922
  }
@@ -1907,15 +1925,15 @@ var Swarm = class {
1907
1925
  /**
1908
1926
  * Creates a connection then sends message over signal network.
1909
1927
  */
1910
- async _initiateConnection(remoteId) {
1928
+ async _initiateConnection(remotePeer) {
1911
1929
  const ctx = this._ctx;
1912
- const peer = this._getOrCreatePeer(remoteId);
1913
- if (remoteId.toHex() < this._ownPeerId.toHex()) {
1930
+ const peer = this._getOrCreatePeer(remotePeer);
1931
+ if (remotePeer.peerKey < this._ownPeer.peerKey) {
1914
1932
  (0, import_log4.log)("initiation delay", {
1915
- remoteId
1933
+ remotePeer
1916
1934
  }, {
1917
1935
  F: __dxlog_file5,
1918
- L: 367,
1936
+ L: 371,
1919
1937
  S: this,
1920
1938
  C: (f, a) => f(...a)
1921
1939
  });
@@ -1931,33 +1949,33 @@ var Swarm = class {
1931
1949
  return;
1932
1950
  }
1933
1951
  (0, import_log4.log)("initiating connection...", {
1934
- remoteId
1952
+ remotePeer
1935
1953
  }, {
1936
1954
  F: __dxlog_file5,
1937
- L: 383,
1955
+ L: 387,
1938
1956
  S: this,
1939
1957
  C: (f, a) => f(...a)
1940
1958
  });
1941
1959
  await peer.initiateConnection();
1942
1960
  this._topology.update();
1943
1961
  (0, import_log4.log)("initiated", {
1944
- remoteId
1962
+ remotePeer
1945
1963
  }, {
1946
1964
  F: __dxlog_file5,
1947
- L: 386,
1965
+ L: 390,
1948
1966
  S: this,
1949
1967
  C: (f, a) => f(...a)
1950
1968
  });
1951
1969
  }
1952
- async _closeConnection(peerId) {
1953
- const peer = this._peers.get(peerId);
1970
+ async _closeConnection(peerInfo) {
1971
+ const peer = this._peers.get(peerInfo);
1954
1972
  if (!peer) {
1955
1973
  return;
1956
1974
  }
1957
1975
  await peer.closeConnection();
1958
1976
  }
1959
1977
  _isUnregistered(peer) {
1960
- return !peer || this._peers.get(peer.id) !== peer;
1978
+ return !peer || this._peers.get(peer.remoteInfo) !== peer;
1961
1979
  }
1962
1980
  };
1963
1981
  _ts_decorate3([
@@ -1965,7 +1983,7 @@ _ts_decorate3([
1965
1983
  ], Swarm.prototype, "_instanceId", void 0);
1966
1984
  _ts_decorate3([
1967
1985
  import_log4.logInfo
1968
- ], Swarm.prototype, "ownPeerId", null);
1986
+ ], Swarm.prototype, "ownPeer", null);
1969
1987
  _ts_decorate3([
1970
1988
  import_log4.logInfo
1971
1989
  ], Swarm.prototype, "topic", null);
@@ -1989,12 +2007,12 @@ var SwarmMapper = class {
1989
2007
  constructor(_swarm) {
1990
2008
  this._swarm = _swarm;
1991
2009
  this._subscriptions = new import_async5.EventSubscriptions();
1992
- this._connectionSubscriptions = new import_util4.ComplexMap(import_keys5.PublicKey.hash);
1993
- this._peers = new import_util4.ComplexMap(import_keys5.PublicKey.hash);
2010
+ this._connectionSubscriptions = new import_util4.ComplexMap(import_messaging2.PeerInfoHash);
2011
+ this._peers = new import_util4.ComplexMap(import_messaging2.PeerInfoHash);
1994
2012
  this.mapUpdated = new import_async5.Event();
1995
2013
  this._subscriptions.add(_swarm.connectionAdded.on((connection) => {
1996
2014
  this._update();
1997
- this._connectionSubscriptions.set(connection.remoteId, connection.stateChanged.on(() => {
2015
+ this._connectionSubscriptions.set(connection.remoteInfo, connection.stateChanged.on(() => {
1998
2016
  this._update();
1999
2017
  }));
2000
2018
  }));
@@ -2008,19 +2026,19 @@ var SwarmMapper = class {
2008
2026
  _update() {
2009
2027
  (0, import_log6.log)("updating swarm", void 0, {
2010
2028
  F: __dxlog_file6,
2011
- L: 72,
2029
+ L: 73,
2012
2030
  S: this,
2013
2031
  C: (f, a) => f(...a)
2014
2032
  });
2015
2033
  this._peers.clear();
2016
- this._peers.set(this._swarm.ownPeerId, {
2034
+ this._peers.set(this._swarm.ownPeer, {
2017
2035
  id: this._swarm.ownPeerId,
2018
2036
  state: "ME",
2019
2037
  connections: []
2020
2038
  });
2021
2039
  for (const connection of this._swarm.connections) {
2022
- this._peers.set(connection.remoteId, {
2023
- id: connection.remoteId,
2040
+ this._peers.set(connection.remoteInfo, {
2041
+ id: import_keys5.PublicKey.from(connection.remoteInfo.peerKey),
2024
2042
  state: connection.state,
2025
2043
  connections: [
2026
2044
  this._swarm.ownPeerId
@@ -2032,7 +2050,7 @@ var SwarmMapper = class {
2032
2050
  totalPeersInSwarm: this._peers.size
2033
2051
  }, {
2034
2052
  F: __dxlog_file6,
2035
- L: 113,
2053
+ L: 114,
2036
2054
  S: this,
2037
2055
  C: (f, a) => f(...a)
2038
2056
  });
@@ -2151,7 +2169,7 @@ var ConnectionLog = class {
2151
2169
  const connectionInfo = {
2152
2170
  state: ConnectionState.CREATED,
2153
2171
  closeReason: connection.closeReason,
2154
- remotePeerId: connection.remoteId,
2172
+ remotePeerId: import_keys7.PublicKey.from(connection.remoteInfo.peerKey),
2155
2173
  sessionId: connection.sessionId,
2156
2174
  transport: connection.transport && Object.getPrototypeOf(connection.transport).constructor.name,
2157
2175
  protocolExtensions: [],
@@ -2212,25 +2230,27 @@ function _ts_decorate4(decorators, target, key, desc) {
2212
2230
  }
2213
2231
  var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
2214
2232
  var SwarmNetworkManager = class {
2215
- constructor({ transportFactory, signalManager, log: log17 }) {
2233
+ constructor({ transportFactory, signalManager, enableDevtoolsLogging, peerInfo }) {
2216
2234
  this._swarms = new import_util7.ComplexMap(import_keys8.PublicKey.hash);
2217
2235
  this._mappers = new import_util7.ComplexMap(import_keys8.PublicKey.hash);
2218
2236
  this._instanceId = import_keys8.PublicKey.random().toHex();
2237
+ this._peerInfo = void 0;
2219
2238
  this._connectionState = import_services.ConnectionState.ONLINE;
2220
2239
  this.connectionStateChanged = new import_async8.Event();
2221
2240
  this.topicsUpdated = new import_async8.Event();
2222
2241
  this._transportFactory = transportFactory;
2223
2242
  this._signalManager = signalManager;
2224
- this._signalManager.swarmEvent.on(({ topic, swarmEvent: event }) => this._swarms.get(topic)?.onSwarmEvent(event));
2225
- this._messenger = new import_messaging.Messenger({
2243
+ this._signalManager.swarmEvent.on((event) => this._swarms.get(event.topic)?.onSwarmEvent(event));
2244
+ this._messenger = new import_messaging3.Messenger({
2226
2245
  signalManager: this._signalManager
2227
2246
  });
2228
2247
  this._signalConnection = {
2229
2248
  join: (opts) => this._signalManager.join(opts),
2230
2249
  leave: (opts) => this._signalManager.leave(opts)
2231
2250
  };
2251
+ this._peerInfo = peerInfo;
2232
2252
  this._connectionLimiter = new ConnectionLimiter();
2233
- if (log17) {
2253
+ if (enableDevtoolsLogging) {
2234
2254
  this._connectionLog = new ConnectionLog();
2235
2255
  }
2236
2256
  }
@@ -2251,12 +2271,15 @@ var SwarmNetworkManager = class {
2251
2271
  getSwarm(topic) {
2252
2272
  return this._swarms.get(topic);
2253
2273
  }
2274
+ setPeerInfo(peerInfo) {
2275
+ this._peerInfo = peerInfo;
2276
+ }
2254
2277
  async open() {
2255
2278
  import_log8.log.trace("dxos.mesh.network-manager.open", import_protocols6.trace.begin({
2256
2279
  id: this._instanceId
2257
2280
  }), {
2258
2281
  F: __dxlog_file8,
2259
- L: 126,
2282
+ L: 133,
2260
2283
  S: this,
2261
2284
  C: (f, a) => f(...a)
2262
2285
  });
@@ -2266,7 +2289,7 @@ var SwarmNetworkManager = class {
2266
2289
  id: this._instanceId
2267
2290
  }), {
2268
2291
  F: __dxlog_file8,
2269
- L: 129,
2292
+ L: 136,
2270
2293
  S: this,
2271
2294
  C: (f, a) => f(...a)
2272
2295
  });
@@ -2276,7 +2299,7 @@ var SwarmNetworkManager = class {
2276
2299
  await this.leaveSwarm(topic).catch((err) => {
2277
2300
  (0, import_log8.log)(err, void 0, {
2278
2301
  F: __dxlog_file8,
2279
- L: 135,
2302
+ L: 142,
2280
2303
  S: this,
2281
2304
  C: (f, a) => f(...a)
2282
2305
  });
@@ -2288,28 +2311,43 @@ var SwarmNetworkManager = class {
2288
2311
  /**
2289
2312
  * Join the swarm.
2290
2313
  */
2291
- async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
2314
+ async joinSwarm({ topic, peerInfo, topology, protocolProvider: protocol, label }) {
2292
2315
  (0, import_invariant6.invariant)(import_keys8.PublicKey.isPublicKey(topic), void 0, {
2293
2316
  F: __dxlog_file8,
2294
- L: 154,
2317
+ L: 161,
2295
2318
  S: this,
2296
2319
  A: [
2297
2320
  "PublicKey.isPublicKey(topic)",
2298
2321
  ""
2299
2322
  ]
2300
2323
  });
2301
- (0, import_invariant6.invariant)(import_keys8.PublicKey.isPublicKey(peerId), void 0, {
2324
+ if (!peerInfo) {
2325
+ peerInfo = {
2326
+ peerKey: this._peerInfo?.peerKey ?? import_keys8.PublicKey.random().toHex(),
2327
+ identityKey: this._peerInfo?.identityKey ?? import_keys8.PublicKey.random().toHex()
2328
+ };
2329
+ }
2330
+ (0, import_invariant6.invariant)(import_keys8.PublicKey.from(peerInfo.peerKey), void 0, {
2302
2331
  F: __dxlog_file8,
2303
- L: 155,
2332
+ L: 168,
2333
+ S: this,
2334
+ A: [
2335
+ "PublicKey.from(peerInfo.peerKey)",
2336
+ ""
2337
+ ]
2338
+ });
2339
+ (0, import_invariant6.invariant)(import_keys8.PublicKey.from(peerInfo.identityKey), void 0, {
2340
+ F: __dxlog_file8,
2341
+ L: 169,
2304
2342
  S: this,
2305
2343
  A: [
2306
- "PublicKey.isPublicKey(peerId)",
2344
+ "PublicKey.from(peerInfo.identityKey!)",
2307
2345
  ""
2308
2346
  ]
2309
2347
  });
2310
2348
  (0, import_invariant6.invariant)(topology, void 0, {
2311
2349
  F: __dxlog_file8,
2312
- L: 156,
2350
+ L: 170,
2313
2351
  S: this,
2314
2352
  A: [
2315
2353
  "topology",
@@ -2318,7 +2356,7 @@ var SwarmNetworkManager = class {
2318
2356
  });
2319
2357
  (0, import_invariant6.invariant)(typeof protocol === "function", void 0, {
2320
2358
  F: __dxlog_file8,
2321
- L: 157,
2359
+ L: 171,
2322
2360
  S: this,
2323
2361
  A: [
2324
2362
  "typeof protocol === 'function'",
@@ -2330,21 +2368,21 @@ var SwarmNetworkManager = class {
2330
2368
  }
2331
2369
  (0, import_log8.log)("joining", {
2332
2370
  topic: import_keys8.PublicKey.from(topic),
2333
- peerId,
2371
+ peerInfo,
2334
2372
  topology: topology.toString()
2335
2373
  }, {
2336
2374
  F: __dxlog_file8,
2337
- L: 162,
2375
+ L: 176,
2338
2376
  S: this,
2339
2377
  C: (f, a) => f(...a)
2340
2378
  });
2341
- const swarm = new Swarm(topic, peerId, topology, protocol, this._messenger, this._transportFactory, label, this._connectionLimiter);
2379
+ const swarm = new Swarm(topic, peerInfo, topology, protocol, this._messenger, this._transportFactory, label, this._connectionLimiter);
2342
2380
  swarm.errors.handle((error) => {
2343
2381
  (0, import_log8.log)("swarm error", {
2344
2382
  error
2345
2383
  }, {
2346
2384
  F: __dxlog_file8,
2347
- L: 175,
2385
+ L: 189,
2348
2386
  S: this,
2349
2387
  C: (f, a) => f(...a)
2350
2388
  });
@@ -2354,10 +2392,10 @@ var SwarmNetworkManager = class {
2354
2392
  await swarm.open();
2355
2393
  this._signalConnection.join({
2356
2394
  topic,
2357
- peerId
2395
+ peer: peerInfo
2358
2396
  }).catch((error) => import_log8.log.catch(error, void 0, {
2359
2397
  F: __dxlog_file8,
2360
- L: 184,
2398
+ L: 198,
2361
2399
  S: this,
2362
2400
  C: (f, a) => f(...a)
2363
2401
  }));
@@ -2368,7 +2406,7 @@ var SwarmNetworkManager = class {
2368
2406
  count: this._swarms.size
2369
2407
  }, {
2370
2408
  F: __dxlog_file8,
2371
- L: 188,
2409
+ L: 202,
2372
2410
  S: this,
2373
2411
  C: (f, a) => f(...a)
2374
2412
  });
@@ -2387,14 +2425,14 @@ var SwarmNetworkManager = class {
2387
2425
  topic: import_keys8.PublicKey.from(topic)
2388
2426
  }, {
2389
2427
  F: __dxlog_file8,
2390
- L: 205,
2428
+ L: 219,
2391
2429
  S: this,
2392
2430
  C: (f, a) => f(...a)
2393
2431
  });
2394
2432
  const swarm = this._swarms.get(topic);
2395
2433
  await this._signalConnection.leave({
2396
2434
  topic,
2397
- peerId: swarm.ownPeerId
2435
+ peer: swarm.ownPeer
2398
2436
  });
2399
2437
  const map = this._mappers.get(topic);
2400
2438
  map.destroy();
@@ -2408,7 +2446,7 @@ var SwarmNetworkManager = class {
2408
2446
  count: this._swarms.size
2409
2447
  }, {
2410
2448
  F: __dxlog_file8,
2411
- L: 219,
2449
+ L: 233,
2412
2450
  S: this,
2413
2451
  C: (f, a) => f(...a)
2414
2452
  });
@@ -4261,4 +4299,4 @@ var createTeleportProtocolFactory = (onConnection, defaultParams) => {
4261
4299
  createSimplePeerTransportFactory,
4262
4300
  createTeleportProtocolFactory
4263
4301
  });
4264
- //# sourceMappingURL=chunk-DZJ3BJOK.cjs.map
4302
+ //# sourceMappingURL=chunk-IQBYIEAR.cjs.map