@dxos/client-services 0.6.8-main.3be982f → 0.6.8-staging.77f93a3

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 (46) hide show
  1. package/dist/lib/browser/{chunk-I6MMWGWX.mjs → chunk-RZ5JISVH.mjs} +183 -135
  2. package/dist/lib/browser/chunk-RZ5JISVH.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +7 -7
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +17 -10
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-PAH5HN65.cjs → chunk-3A3QU6K5.cjs} +185 -137
  9. package/dist/lib/node/chunk-3A3QU6K5.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +51 -51
  11. package/dist/lib/node/index.cjs.map +3 -3
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +23 -16
  14. package/dist/lib/node/testing/index.cjs.map +3 -3
  15. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  16. package/dist/types/src/packlets/identity/identity-manager.d.ts +4 -1
  17. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/service-context.d.ts +3 -1
  20. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  21. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +4 -0
  23. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  24. package/dist/types/src/packlets/spaces/data-space.d.ts +2 -0
  25. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  26. package/dist/types/src/packlets/testing/test-builder.d.ts +6 -4
  27. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  28. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  29. package/dist/types/src/version.d.ts +1 -1
  30. package/dist/types/src/version.d.ts.map +1 -1
  31. package/package.json +37 -37
  32. package/src/packlets/devtools/network.ts +12 -5
  33. package/src/packlets/identity/identity-manager.ts +5 -0
  34. package/src/packlets/identity/identity.test.ts +3 -0
  35. package/src/packlets/invitations/invitations-handler.ts +0 -1
  36. package/src/packlets/network/network-service.ts +3 -3
  37. package/src/packlets/services/service-context.test.ts +4 -2
  38. package/src/packlets/services/service-context.ts +31 -3
  39. package/src/packlets/services/service-host.ts +20 -11
  40. package/src/packlets/spaces/data-space-manager.ts +8 -0
  41. package/src/packlets/spaces/data-space.ts +3 -1
  42. package/src/packlets/testing/test-builder.ts +21 -9
  43. package/src/packlets/worker/worker-runtime.ts +5 -3
  44. package/src/version.ts +1 -1
  45. package/dist/lib/browser/chunk-I6MMWGWX.mjs.map +0 -7
  46. package/dist/lib/node/chunk-PAH5HN65.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_PAH5HN65_exports = {};
30
- __export(chunk_PAH5HN65_exports, {
29
+ var chunk_3A3QU6K5_exports = {};
30
+ __export(chunk_3A3QU6K5_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -70,7 +70,7 @@ __export(chunk_PAH5HN65_exports, {
70
70
  subscribeToSpaces: () => subscribeToSpaces,
71
71
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
72
72
  });
73
- module.exports = __toCommonJS(chunk_PAH5HN65_exports);
73
+ module.exports = __toCommonJS(chunk_3A3QU6K5_exports);
74
74
  var import_async = require("@dxos/async");
75
75
  var import_codec_protobuf = require("@dxos/codec-protobuf");
76
76
  var import_feed_store = require("@dxos/feed-store");
@@ -413,7 +413,7 @@ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src
413
413
  var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf2.Stream(({ next, close }) => {
414
414
  const update = () => {
415
415
  try {
416
- const status = signalManager.getStatus();
416
+ const status = signalManager.getStatus?.();
417
417
  next({
418
418
  servers: status
419
419
  });
@@ -421,7 +421,7 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf2
421
421
  close(err);
422
422
  }
423
423
  };
424
- signalManager.statusChanged.on(() => update());
424
+ signalManager.statusChanged?.on(() => update());
425
425
  update();
426
426
  });
427
427
  var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf2.Stream(({ next }) => {
@@ -432,8 +432,8 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf2.Stream
432
432
  signalManager.onMessage.on(ctx, (message) => {
433
433
  next({
434
434
  message: {
435
- author: message.author.asUint8Array(),
436
- recipient: message.recipient.asUint8Array(),
435
+ author: import_keys2.PublicKey.from(message.author.peerKey).asUint8Array(),
436
+ recipient: import_keys2.PublicKey.from(message.recipient.peerKey).asUint8Array(),
437
437
  payload: message.payload
438
438
  },
439
439
  receivedAt: /* @__PURE__ */ new Date()
@@ -441,7 +441,16 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf2.Stream
441
441
  });
442
442
  signalManager.swarmEvent.on(ctx, (swarmEvent) => {
443
443
  next({
444
- swarmEvent: swarmEvent.swarmEvent,
444
+ swarmEvent: swarmEvent.peerAvailable ? {
445
+ peerAvailable: {
446
+ peer: import_keys2.PublicKey.from(swarmEvent.peerAvailable.peer.peerKey).asUint8Array(),
447
+ since: swarmEvent.peerAvailable.since
448
+ }
449
+ } : {
450
+ peerLeft: {
451
+ peer: import_keys2.PublicKey.from(swarmEvent.peerLeft.peer.peerKey).asUint8Array()
452
+ }
453
+ },
445
454
  topic: swarmEvent.topic.asUint8Array(),
446
455
  receivedAt: /* @__PURE__ */ new Date()
447
456
  });
@@ -656,7 +665,7 @@ var DevtoolsServiceImpl = class {
656
665
  });
657
666
  }
658
667
  };
659
- var DXOS_VERSION = "0.6.8-main.3be982f";
668
+ var DXOS_VERSION = "0.6.8-staging.77f93a3";
660
669
  var getPlatform = () => {
661
670
  if (process.browser) {
662
671
  if (typeof window !== "undefined") {
@@ -1213,11 +1222,12 @@ var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
1213
1222
  var IdentityManager = class {
1214
1223
  // TODO(burdon): IdentityManagerParams.
1215
1224
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
1216
- constructor(_metadataStore, _keyring, _feedStore, _spaceManager, params) {
1225
+ constructor(_metadataStore, _keyring, _feedStore, _spaceManager, params, _callbacks) {
1217
1226
  this._metadataStore = _metadataStore;
1218
1227
  this._keyring = _keyring;
1219
1228
  this._feedStore = _feedStore;
1220
1229
  this._spaceManager = _spaceManager;
1230
+ this._callbacks = _callbacks;
1221
1231
  this.stateUpdate = new import_async7.Event();
1222
1232
  const { devicePresenceAnnounceInterval = DEVICE_PRESENCE_ANNOUNCE_INTERVAL, devicePresenceOfflineTimeout = DEVICE_PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
1223
1233
  this._devicePresenceAnnounceInterval = devicePresenceAnnounceInterval;
@@ -1232,7 +1242,7 @@ var IdentityManager = class {
1232
1242
  id: traceId
1233
1243
  }), {
1234
1244
  F: __dxlog_file6,
1235
- L: 104,
1245
+ L: 107,
1236
1246
  S: this,
1237
1247
  C: (f, a) => f(...a)
1238
1248
  });
@@ -1241,7 +1251,7 @@ var IdentityManager = class {
1241
1251
  identityRecord
1242
1252
  }, {
1243
1253
  F: __dxlog_file6,
1244
- L: 107,
1254
+ L: 110,
1245
1255
  S: this,
1246
1256
  C: (f, a) => f(...a)
1247
1257
  });
@@ -1254,7 +1264,7 @@ var IdentityManager = class {
1254
1264
  displayName: this._identity.profileDocument?.displayName
1255
1265
  }, {
1256
1266
  F: __dxlog_file6,
1257
- L: 112,
1267
+ L: 115,
1258
1268
  S: this,
1259
1269
  C: (f, a) => f(...a)
1260
1270
  });
@@ -1264,7 +1274,7 @@ var IdentityManager = class {
1264
1274
  id: traceId
1265
1275
  }), {
1266
1276
  F: __dxlog_file6,
1267
- L: 119,
1277
+ L: 122,
1268
1278
  S: this,
1269
1279
  C: (f, a) => f(...a)
1270
1280
  });
@@ -1272,13 +1282,13 @@ var IdentityManager = class {
1272
1282
  async close() {
1273
1283
  await this._identity?.close(new import_context3.Context(void 0, {
1274
1284
  F: __dxlog_file6,
1275
- L: 123
1285
+ L: 126
1276
1286
  }));
1277
1287
  }
1278
1288
  async createIdentity({ displayName, deviceProfile } = {}) {
1279
1289
  (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
1280
1290
  F: __dxlog_file6,
1281
- L: 128,
1291
+ L: 131,
1282
1292
  S: this,
1283
1293
  A: [
1284
1294
  "!this._identity",
@@ -1287,7 +1297,7 @@ var IdentityManager = class {
1287
1297
  });
1288
1298
  (0, import_log4.log)("creating identity...", void 0, {
1289
1299
  F: __dxlog_file6,
1290
- L: 129,
1300
+ L: 132,
1291
1301
  S: this,
1292
1302
  C: (f, a) => f(...a)
1293
1303
  });
@@ -1305,13 +1315,13 @@ var IdentityManager = class {
1305
1315
  const identity = await this._constructIdentity(identityRecord);
1306
1316
  await identity.open(new import_context3.Context(void 0, {
1307
1317
  F: __dxlog_file6,
1308
- L: 144
1318
+ L: 147
1309
1319
  }));
1310
1320
  {
1311
1321
  const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
1312
1322
  (0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
1313
1323
  F: __dxlog_file6,
1314
- L: 148,
1324
+ L: 151,
1315
1325
  S: this,
1316
1326
  A: [
1317
1327
  "identityRecord.haloSpace.genesisFeedKey",
@@ -1320,7 +1330,7 @@ var IdentityManager = class {
1320
1330
  });
1321
1331
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
1322
1332
  F: __dxlog_file6,
1323
- L: 149,
1333
+ L: 152,
1324
1334
  S: this,
1325
1335
  A: [
1326
1336
  "identityRecord.haloSpace.dataFeedKey",
@@ -1359,7 +1369,7 @@ var IdentityManager = class {
1359
1369
  displayName: this._identity.profileDocument?.displayName
1360
1370
  }, {
1361
1371
  F: __dxlog_file6,
1362
- L: 191,
1372
+ L: 194,
1363
1373
  S: this,
1364
1374
  C: (f, a) => f(...a)
1365
1375
  });
@@ -1370,7 +1380,7 @@ var IdentityManager = class {
1370
1380
  profile: identity.profileDocument
1371
1381
  }, {
1372
1382
  F: __dxlog_file6,
1373
- L: 197,
1383
+ L: 200,
1374
1384
  S: this,
1375
1385
  C: (f, a) => f(...a)
1376
1386
  });
@@ -1407,13 +1417,13 @@ var IdentityManager = class {
1407
1417
  params
1408
1418
  }, {
1409
1419
  F: __dxlog_file6,
1410
- L: 235,
1420
+ L: 238,
1411
1421
  S: this,
1412
1422
  C: (f, a) => f(...a)
1413
1423
  });
1414
1424
  (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
1415
1425
  F: __dxlog_file6,
1416
- L: 236,
1426
+ L: 239,
1417
1427
  S: this,
1418
1428
  A: [
1419
1429
  "!this._identity",
@@ -1434,7 +1444,7 @@ var IdentityManager = class {
1434
1444
  const identity = await this._constructIdentity(identityRecord);
1435
1445
  await identity.open(new import_context3.Context(void 0, {
1436
1446
  F: __dxlog_file6,
1437
- L: 251
1447
+ L: 254
1438
1448
  }));
1439
1449
  this._identity = identity;
1440
1450
  await this._metadataStore.setIdentityRecord(identityRecord);
@@ -1444,7 +1454,7 @@ var IdentityManager = class {
1444
1454
  displayName: this._identity.profileDocument?.displayName
1445
1455
  }, {
1446
1456
  F: __dxlog_file6,
1447
- L: 255,
1457
+ L: 258,
1448
1458
  S: this,
1449
1459
  C: (f, a) => f(...a)
1450
1460
  });
@@ -1458,7 +1468,7 @@ var IdentityManager = class {
1458
1468
  deviceKey: identity.deviceKey
1459
1469
  }, {
1460
1470
  F: __dxlog_file6,
1461
- L: 265,
1471
+ L: 268,
1462
1472
  S: this,
1463
1473
  C: (f, a) => f(...a)
1464
1474
  });
@@ -1470,7 +1480,7 @@ var IdentityManager = class {
1470
1480
  async updateProfile(profile) {
1471
1481
  (0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
1472
1482
  F: __dxlog_file6,
1473
- L: 273,
1483
+ L: 276,
1474
1484
  S: this,
1475
1485
  A: [
1476
1486
  "this._identity",
@@ -1501,7 +1511,7 @@ var IdentityManager = class {
1501
1511
  async updateDeviceProfile(profile) {
1502
1512
  (0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
1503
1513
  F: __dxlog_file6,
1504
- L: 290,
1514
+ L: 293,
1505
1515
  S: this,
1506
1516
  A: [
1507
1517
  "this._identity",
@@ -1537,7 +1547,7 @@ var IdentityManager = class {
1537
1547
  async _constructIdentity(identityRecord) {
1538
1548
  (0, import_invariant3.invariant)(!this._identity, void 0, {
1539
1549
  F: __dxlog_file6,
1540
- L: 316,
1550
+ L: 319,
1541
1551
  S: this,
1542
1552
  A: [
1543
1553
  "!this._identity",
@@ -1548,7 +1558,7 @@ var IdentityManager = class {
1548
1558
  identityRecord
1549
1559
  }, {
1550
1560
  F: __dxlog_file6,
1551
- L: 317,
1561
+ L: 320,
1552
1562
  S: this,
1553
1563
  C: (f, a) => f(...a)
1554
1564
  });
@@ -1563,7 +1573,7 @@ var IdentityManager = class {
1563
1573
  });
1564
1574
  (0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
1565
1575
  F: __dxlog_file6,
1566
- L: 330,
1576
+ L: 333,
1567
1577
  S: this,
1568
1578
  A: [
1569
1579
  "identityRecord.haloSpace.controlFeedKey",
@@ -1575,7 +1585,7 @@ var IdentityManager = class {
1575
1585
  });
1576
1586
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
1577
1587
  F: __dxlog_file6,
1578
- L: 334,
1588
+ L: 337,
1579
1589
  S: this,
1580
1590
  A: [
1581
1591
  "identityRecord.haloSpace.dataFeedKey",
@@ -1589,6 +1599,7 @@ var IdentityManager = class {
1589
1599
  const space = await this._constructSpace({
1590
1600
  spaceRecord: identityRecord.haloSpace,
1591
1601
  swarmIdentity: {
1602
+ identityKey: identityRecord.identityKey,
1592
1603
  peerKey: identityRecord.deviceKey,
1593
1604
  credentialProvider: createAuthProvider((0, import_credentials6.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
1594
1605
  credentialAuthenticator: (0, import_util4.deferFunction)(() => identity.authVerifier.verifier)
@@ -1609,10 +1620,11 @@ var IdentityManager = class {
1609
1620
  identityKey: identityRecord.identityKey
1610
1621
  }, {
1611
1622
  F: __dxlog_file6,
1612
- L: 360,
1623
+ L: 364,
1613
1624
  S: this,
1614
1625
  C: (f, a) => f(...a)
1615
1626
  });
1627
+ this._callbacks?.onIdentityConstruction?.(identity);
1616
1628
  if (identityRecord.haloSpace.controlTimeframe) {
1617
1629
  identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
1618
1630
  }
@@ -1634,7 +1646,7 @@ var IdentityManager = class {
1634
1646
  onAuthFailure: () => {
1635
1647
  import_log4.log.warn("auth failure", void 0, {
1636
1648
  F: __dxlog_file6,
1637
- L: 385,
1649
+ L: 390,
1638
1650
  S: this,
1639
1651
  C: (f, a) => f(...a)
1640
1652
  });
@@ -2890,7 +2902,6 @@ var InvitationsHandler = class {
2890
2902
  }
2891
2903
  const swarmConnection = await this._networkManager.joinSwarm({
2892
2904
  topic: invitation.swarmKey,
2893
- peerId: import_keys6.PublicKey.random(),
2894
2905
  protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
2895
2906
  teleport.addExtension("dxos.halo.invitations", extensionFactory());
2896
2907
  }, this._defaultTeleportParams),
@@ -2967,7 +2978,7 @@ var InvitationsHandler = class {
2967
2978
  oldState: stateToString(invitation.state)
2968
2979
  }, {
2969
2980
  F: __dxlog_file12,
2970
- L: 461,
2981
+ L: 460,
2971
2982
  S: this,
2972
2983
  C: (f, a) => f(...a)
2973
2984
  });
@@ -2978,7 +2989,7 @@ var InvitationsHandler = class {
2978
2989
  oldState: stateToString(invitation.state)
2979
2990
  }, {
2980
2991
  F: __dxlog_file12,
2981
- L: 467,
2992
+ L: 466,
2982
2993
  S: this,
2983
2994
  C: (f, a) => f(...a)
2984
2995
  });
@@ -2997,7 +3008,7 @@ var InvitationsHandler = class {
2997
3008
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2998
3009
  (0, import_log6.log)("guest waiting for authentication code...", void 0, {
2999
3010
  F: __dxlog_file12,
3000
- L: 492,
3011
+ L: 491,
3001
3012
  S: this,
3002
3013
  C: (f, a) => f(...a)
3003
3014
  });
@@ -3005,7 +3016,7 @@ var InvitationsHandler = class {
3005
3016
  const authCode = await authenticated.wait(options);
3006
3017
  (0, import_log6.log)("sending authentication request", void 0, {
3007
3018
  F: __dxlog_file12,
3008
- L: 496,
3019
+ L: 495,
3009
3020
  S: this,
3010
3021
  C: (f, a) => f(...a)
3011
3022
  });
@@ -3024,7 +3035,7 @@ var InvitationsHandler = class {
3024
3035
  attempt
3025
3036
  }, {
3026
3037
  F: __dxlog_file12,
3027
- L: 507,
3038
+ L: 506,
3028
3039
  S: this,
3029
3040
  C: (f, a) => f(...a)
3030
3041
  });
@@ -3042,7 +3053,7 @@ var InvitationsHandler = class {
3042
3053
  }
3043
3054
  (0, import_log6.log)("sending authentication request", void 0, {
3044
3055
  F: __dxlog_file12,
3045
- L: 526,
3056
+ L: 525,
3046
3057
  S: this,
3047
3058
  C: (f, a) => f(...a)
3048
3059
  });
@@ -4793,7 +4804,7 @@ var DataSpace = class {
4793
4804
  constructor(params) {
4794
4805
  this._ctx = new import_context11.Context(void 0, {
4795
4806
  F: __dxlog_file19,
4796
- L: 87
4807
+ L: 89
4797
4808
  });
4798
4809
  this._notarizationPlugin = new NotarizationPlugin();
4799
4810
  this._cache = void 0;
@@ -4826,7 +4837,7 @@ var DataSpace = class {
4826
4837
  authTimeout: import_client_protocol5.AUTH_TIMEOUT
4827
4838
  });
4828
4839
  this._cache = params.cache;
4829
- if (params.edgeConnection) {
4840
+ if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
4830
4841
  this._edgeFeedReplicator = new EdgeFeedReplicator({
4831
4842
  messenger: params.edgeConnection,
4832
4843
  spaceId: this.id
@@ -4837,7 +4848,7 @@ var DataSpace = class {
4837
4848
  state: import_services13.SpaceState[this._state]
4838
4849
  }, {
4839
4850
  F: __dxlog_file19,
4840
- L: 157,
4851
+ L: 159,
4841
4852
  S: this,
4842
4853
  C: (f, a) => f(...a)
4843
4854
  });
@@ -4896,7 +4907,7 @@ var DataSpace = class {
4896
4907
  }
4897
4908
  await this._inner.open(new import_context11.Context(void 0, {
4898
4909
  F: __dxlog_file19,
4899
- L: 231
4910
+ L: 233
4900
4911
  }));
4901
4912
  await this._edgeFeedReplicator?.open();
4902
4913
  this._state = import_services13.SpaceState.SPACE_CONTROL_ONLY;
@@ -4904,7 +4915,7 @@ var DataSpace = class {
4904
4915
  state: import_services13.SpaceState[this._state]
4905
4916
  }, {
4906
4917
  F: __dxlog_file19,
4907
- L: 236,
4918
+ L: 238,
4908
4919
  S: this,
4909
4920
  C: (f, a) => f(...a)
4910
4921
  });
@@ -4924,14 +4935,14 @@ var DataSpace = class {
4924
4935
  state: import_services13.SpaceState[this._state]
4925
4936
  }, {
4926
4937
  F: __dxlog_file19,
4927
- L: 255,
4938
+ L: 257,
4928
4939
  S: this,
4929
4940
  C: (f, a) => f(...a)
4930
4941
  });
4931
4942
  await this._ctx.dispose();
4932
4943
  this._ctx = new import_context11.Context(void 0, {
4933
4944
  F: __dxlog_file19,
4934
- L: 257
4945
+ L: 259
4935
4946
  });
4936
4947
  if (this._edgeFeedReplicator) {
4937
4948
  this.inner.protocol.feedAdded.remove(this._onFeedAdded);
@@ -4964,7 +4975,7 @@ var DataSpace = class {
4964
4975
  if (err instanceof import_protocols10.CancelledError || err instanceof import_context11.ContextDisposedError) {
4965
4976
  (0, import_log14.log)("data pipeline initialization cancelled", err, {
4966
4977
  F: __dxlog_file19,
4967
- L: 295,
4978
+ L: 297,
4968
4979
  S: this,
4969
4980
  C: (f, a) => f(...a)
4970
4981
  });
@@ -4972,7 +4983,7 @@ var DataSpace = class {
4972
4983
  }
4973
4984
  import_log14.log.error("Error initializing data pipeline", err, {
4974
4985
  F: __dxlog_file19,
4975
- L: 299,
4986
+ L: 301,
4976
4987
  S: this,
4977
4988
  C: (f, a) => f(...a)
4978
4989
  });
@@ -4981,7 +4992,7 @@ var DataSpace = class {
4981
4992
  state: import_services13.SpaceState[this._state]
4982
4993
  }, {
4983
4994
  F: __dxlog_file19,
4984
- L: 301,
4995
+ L: 303,
4985
4996
  S: this,
4986
4997
  C: (f, a) => f(...a)
4987
4998
  });
@@ -5001,7 +5012,7 @@ var DataSpace = class {
5001
5012
  state: import_services13.SpaceState[this._state]
5002
5013
  }, {
5003
5014
  F: __dxlog_file19,
5004
- L: 317,
5015
+ L: 319,
5005
5016
  S: this,
5006
5017
  C: (f, a) => f(...a)
5007
5018
  });
@@ -5018,7 +5029,7 @@ var DataSpace = class {
5018
5029
  state: import_services13.SpaceState[this._state]
5019
5030
  }, {
5020
5031
  F: __dxlog_file19,
5021
- L: 336,
5032
+ L: 338,
5022
5033
  S: this,
5023
5034
  C: (f, a) => f(...a)
5024
5035
  });
@@ -5034,7 +5045,7 @@ var DataSpace = class {
5034
5045
  await this._createWritableFeeds();
5035
5046
  (0, import_log14.log)("writable feeds created", void 0, {
5036
5047
  F: __dxlog_file19,
5037
- L: 352,
5048
+ L: 354,
5038
5049
  S: this,
5039
5050
  C: (f, a) => f(...a)
5040
5051
  });
@@ -5097,7 +5108,7 @@ var DataSpace = class {
5097
5108
  rootUrl
5098
5109
  }, {
5099
5110
  F: __dxlog_file19,
5100
- L: 418,
5111
+ L: 420,
5101
5112
  S: this,
5102
5113
  C: (f, a) => f(...a)
5103
5114
  });
@@ -5149,7 +5160,7 @@ var DataSpace = class {
5149
5160
  err
5150
5161
  }, {
5151
5162
  F: __dxlog_file19,
5152
- L: 461,
5163
+ L: 463,
5153
5164
  S: this,
5154
5165
  C: (f, a) => f(...a)
5155
5166
  });
@@ -5239,7 +5250,7 @@ var DataSpace = class {
5239
5250
  state: import_services13.SpaceState[this._state]
5240
5251
  }, {
5241
5252
  F: __dxlog_file19,
5242
- L: 543,
5253
+ L: 545,
5243
5254
  S: this,
5244
5255
  C: (f, a) => f(...a)
5245
5256
  });
@@ -5379,6 +5390,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5379
5390
  this._spaces = new import_util11.ComplexMap(import_keys13.PublicKey.hash);
5380
5391
  this._instanceId = import_keys13.PublicKey.random().toHex();
5381
5392
  this._edgeConnection = void 0;
5393
+ this._edgeFeatures = void 0;
5382
5394
  this._meshReplicator = void 0;
5383
5395
  this._echoEdgeReplicator = void 0;
5384
5396
  this._runtimeParams = void 0;
@@ -5391,6 +5403,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5391
5403
  this._meshReplicator = params.meshReplicator;
5392
5404
  this._invitationsManager = params.invitationsManager;
5393
5405
  this._edgeConnection = params.edgeConnection;
5406
+ this._edgeFeatures = params.edgeFeatures;
5394
5407
  this._echoEdgeReplicator = params.echoEdgeReplicator;
5395
5408
  this._runtimeParams = params.runtimeParams;
5396
5409
  import_tracing8.trace.diagnostic({
@@ -5423,7 +5436,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5423
5436
  async _open() {
5424
5437
  (0, import_log17.log)("open", void 0, {
5425
5438
  F: __dxlog_file20,
5426
- L: 187,
5439
+ L: 192,
5427
5440
  S: this,
5428
5441
  C: (f, a) => f(...a)
5429
5442
  });
@@ -5431,7 +5444,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5431
5444
  id: this._instanceId
5432
5445
  }), {
5433
5446
  F: __dxlog_file20,
5434
- L: 188,
5447
+ L: 193,
5435
5448
  S: this,
5436
5449
  C: (f, a) => f(...a)
5437
5450
  });
@@ -5439,7 +5452,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5439
5452
  spaces: this._metadataStore.spaces.length
5440
5453
  }, {
5441
5454
  F: __dxlog_file20,
5442
- L: 189,
5455
+ L: 194,
5443
5456
  S: this,
5444
5457
  C: (f, a) => f(...a)
5445
5458
  });
@@ -5449,7 +5462,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5449
5462
  spaceMetadata
5450
5463
  }, {
5451
5464
  F: __dxlog_file20,
5452
- L: 193,
5465
+ L: 198,
5453
5466
  S: this,
5454
5467
  C: (f, a) => f(...a)
5455
5468
  });
@@ -5460,7 +5473,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5460
5473
  err
5461
5474
  }, {
5462
5475
  F: __dxlog_file20,
5463
- L: 196,
5476
+ L: 201,
5464
5477
  S: this,
5465
5478
  C: (f, a) => f(...a)
5466
5479
  });
@@ -5471,7 +5484,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5471
5484
  id: this._instanceId
5472
5485
  }), {
5473
5486
  F: __dxlog_file20,
5474
- L: 202,
5487
+ L: 207,
5475
5488
  S: this,
5476
5489
  C: (f, a) => f(...a)
5477
5490
  });
@@ -5479,7 +5492,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5479
5492
  async _close() {
5480
5493
  (0, import_log17.log)("close", void 0, {
5481
5494
  F: __dxlog_file20,
5482
- L: 207,
5495
+ L: 212,
5483
5496
  S: this,
5484
5497
  C: (f, a) => f(...a)
5485
5498
  });
@@ -5494,7 +5507,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5494
5507
  async createSpace() {
5495
5508
  (0, import_invariant17.invariant)(this._lifecycleState === import_context14.LifecycleState.OPEN, "Not open.", {
5496
5509
  F: __dxlog_file20,
5497
- L: 219,
5510
+ L: 224,
5498
5511
  S: this,
5499
5512
  A: [
5500
5513
  "this._lifecycleState === LifecycleState.OPEN",
@@ -5515,7 +5528,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5515
5528
  spaceKey
5516
5529
  }, {
5517
5530
  F: __dxlog_file20,
5518
- L: 231,
5531
+ L: 236,
5519
5532
  S: this,
5520
5533
  C: (f, a) => f(...a)
5521
5534
  });
@@ -5527,7 +5540,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5527
5540
  const memberCredential = credentials[1];
5528
5541
  (0, import_invariant17.invariant)((0, import_credentials15.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5529
5542
  F: __dxlog_file20,
5530
- L: 241,
5543
+ L: 246,
5531
5544
  S: this,
5532
5545
  A: [
5533
5546
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -5559,7 +5572,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5559
5572
  spaceId: space.id
5560
5573
  }, {
5561
5574
  F: __dxlog_file20,
5562
- L: 266,
5575
+ L: 271,
5563
5576
  S: this,
5564
5577
  C: (f, a) => f(...a)
5565
5578
  });
@@ -5594,7 +5607,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5594
5607
  const automergeIndex = space.automergeSpaceState.rootUrl;
5595
5608
  (0, import_invariant17.invariant)(automergeIndex, void 0, {
5596
5609
  F: __dxlog_file20,
5597
- L: 299,
5610
+ L: 304,
5598
5611
  S: this,
5599
5612
  A: [
5600
5613
  "automergeIndex",
@@ -5611,13 +5624,13 @@ var DataSpaceManager = class extends import_context14.Resource {
5611
5624
  opts
5612
5625
  }, {
5613
5626
  F: __dxlog_file20,
5614
- L: 308,
5627
+ L: 313,
5615
5628
  S: this,
5616
5629
  C: (f, a) => f(...a)
5617
5630
  });
5618
5631
  (0, import_invariant17.invariant)(this._lifecycleState === import_context14.LifecycleState.OPEN, "Not open.", {
5619
5632
  F: __dxlog_file20,
5620
- L: 309,
5633
+ L: 314,
5621
5634
  S: this,
5622
5635
  A: [
5623
5636
  "this._lifecycleState === LifecycleState.OPEN",
@@ -5626,7 +5639,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5626
5639
  });
5627
5640
  (0, import_invariant17.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
5628
5641
  F: __dxlog_file20,
5629
- L: 310,
5642
+ L: 315,
5630
5643
  S: this,
5631
5644
  A: [
5632
5645
  "!this._spaces.has(opts.spaceKey)",
@@ -5650,7 +5663,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5650
5663
  const space = this._spaceManager.spaces.get(options.spaceKey);
5651
5664
  (0, import_invariant17.invariant)(space, void 0, {
5652
5665
  F: __dxlog_file20,
5653
- L: 330,
5666
+ L: 335,
5654
5667
  S: this,
5655
5668
  A: [
5656
5669
  "space",
@@ -5663,7 +5676,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5663
5676
  const credentials = await (0, import_credentials15.createAdmissionCredentials)(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
5664
5677
  (0, import_invariant17.invariant)(credentials[0].credential, void 0, {
5665
5678
  F: __dxlog_file20,
5666
- L: 349,
5679
+ L: 354,
5667
5680
  S: this,
5668
5681
  A: [
5669
5682
  "credentials[0].credential",
@@ -5673,7 +5686,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5673
5686
  const spaceMemberCredential = credentials[0].credential.credential;
5674
5687
  (0, import_invariant17.invariant)((0, import_credentials15.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5675
5688
  F: __dxlog_file20,
5676
- L: 351,
5689
+ L: 356,
5677
5690
  S: this,
5678
5691
  A: [
5679
5692
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -5700,6 +5713,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5700
5713
  identityKey: this._signingContext.identityKey,
5701
5714
  timeout: 15e3,
5702
5715
  swarmIdentity: {
5716
+ identityKey: this._signingContext.identityKey,
5703
5717
  peerKey: this._signingContext.deviceKey,
5704
5718
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5705
5719
  credentialAuthenticator: async () => true
@@ -5711,7 +5725,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5711
5725
  metadata
5712
5726
  }, {
5713
5727
  F: __dxlog_file20,
5714
- L: 386,
5728
+ L: 392,
5715
5729
  S: this,
5716
5730
  C: (f, a) => f(...a)
5717
5731
  });
@@ -5734,6 +5748,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5734
5748
  const space = await this._spaceManager.constructSpace({
5735
5749
  metadata,
5736
5750
  swarmIdentity: {
5751
+ identityKey: this._signingContext.identityKey,
5737
5752
  peerKey: this._signingContext.deviceKey,
5738
5753
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5739
5754
  credentialAuthenticator: (0, import_util11.deferFunction)(() => dataSpace.authVerifier.verifier)
@@ -5754,7 +5769,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5754
5769
  err
5755
5770
  }, {
5756
5771
  F: __dxlog_file20,
5757
- L: 427,
5772
+ L: 434,
5758
5773
  S: this,
5759
5774
  C: (f, a) => f(...a)
5760
5775
  });
@@ -5764,7 +5779,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5764
5779
  onAuthFailure: () => {
5765
5780
  import_log17.log.warn("auth failure", void 0, {
5766
5781
  F: __dxlog_file20,
5767
- L: 432,
5782
+ L: 439,
5768
5783
  S: this,
5769
5784
  C: (f, a) => f(...a)
5770
5785
  });
@@ -5797,7 +5812,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5797
5812
  space: space.key
5798
5813
  }, {
5799
5814
  F: __dxlog_file20,
5800
- L: 459,
5815
+ L: 466,
5801
5816
  S: this,
5802
5817
  C: (f, a) => f(...a)
5803
5818
  });
@@ -5808,7 +5823,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5808
5823
  open: this._lifecycleState === import_context14.LifecycleState.OPEN
5809
5824
  }, {
5810
5825
  F: __dxlog_file20,
5811
- L: 462,
5826
+ L: 469,
5812
5827
  S: this,
5813
5828
  C: (f, a) => f(...a)
5814
5829
  });
@@ -5827,14 +5842,15 @@ var DataSpaceManager = class extends import_context14.Resource {
5827
5842
  space: space.key
5828
5843
  }, {
5829
5844
  F: __dxlog_file20,
5830
- L: 470,
5845
+ L: 477,
5831
5846
  S: this,
5832
5847
  C: (f, a) => f(...a)
5833
5848
  });
5834
5849
  }
5835
5850
  },
5836
5851
  cache: metadata.cache,
5837
- edgeConnection: this._edgeConnection
5852
+ edgeConnection: this._edgeConnection,
5853
+ edgeFeatures: this._edgeFeatures
5838
5854
  });
5839
5855
  dataSpace.postOpen.append(async () => {
5840
5856
  await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
@@ -5860,7 +5876,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5860
5876
  space: space.key
5861
5877
  }, {
5862
5878
  F: __dxlog_file20,
5863
- L: 500,
5879
+ L: 508,
5864
5880
  S: this,
5865
5881
  C: (f, a) => f(...a)
5866
5882
  });
@@ -5893,7 +5909,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5893
5909
  closedSessions
5894
5910
  }, {
5895
5911
  F: __dxlog_file20,
5896
- L: 526,
5912
+ L: 534,
5897
5913
  S: this,
5898
5914
  C: (f, a) => f(...a)
5899
5915
  });
@@ -5908,7 +5924,7 @@ var DataSpaceManager = class extends import_context14.Resource {
5908
5924
  peerId: peerState.peerId
5909
5925
  }, {
5910
5926
  F: __dxlog_file20,
5911
- L: 540,
5927
+ L: 548,
5912
5928
  S: this,
5913
5929
  C: (f, a) => f(...a)
5914
5930
  });
@@ -6307,7 +6323,7 @@ function _ts_decorate7(decorators, target, key, desc) {
6307
6323
  }
6308
6324
  var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
6309
6325
  var ServiceContext = class extends import_context15.Resource {
6310
- constructor(storage, level, networkManager, signalManager, _edgeConnection, _runtimeParams) {
6326
+ constructor(storage, level, networkManager, signalManager, _edgeConnection, _runtimeParams, _edgeFeatures) {
6311
6327
  super();
6312
6328
  this.storage = storage;
6313
6329
  this.level = level;
@@ -6315,6 +6331,7 @@ var ServiceContext = class extends import_context15.Resource {
6315
6331
  this.signalManager = signalManager;
6316
6332
  this._edgeConnection = _edgeConnection;
6317
6333
  this._runtimeParams = _runtimeParams;
6334
+ this._edgeFeatures = _edgeFeatures;
6318
6335
  this.initialized = new import_async19.Trigger();
6319
6336
  this._meshReplicator = void 0;
6320
6337
  this._echoEdgeReplicator = void 0;
@@ -6340,17 +6357,41 @@ var ServiceContext = class extends import_context15.Resource {
6340
6357
  metadataStore: this.metadataStore,
6341
6358
  disableP2pReplication: this._runtimeParams?.disableP2pReplication
6342
6359
  });
6343
- this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
6360
+ this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams, {
6361
+ onIdentityConstruction: (identity) => {
6362
+ if (this._edgeConnection) {
6363
+ import_log19.log.info("Setting identity on edge connection", {
6364
+ identity: identity.identityKey.toHex(),
6365
+ oldIdentity: this._edgeConnection.identityKey.toHex(),
6366
+ swarms: this.networkManager.topics
6367
+ }, {
6368
+ F: __dxlog_file22,
6369
+ L: 128,
6370
+ S: this,
6371
+ C: (f, a) => f(...a)
6372
+ });
6373
+ this._edgeConnection.setIdentity({
6374
+ deviceKey: identity.deviceKey,
6375
+ identityKey: identity.identityKey
6376
+ });
6377
+ this.networkManager.setPeerInfo({
6378
+ identityKey: identity.identityKey.toHex(),
6379
+ peerKey: identity.deviceKey.toHex()
6380
+ });
6381
+ }
6382
+ }
6383
+ });
6344
6384
  this.echoHost = new import_echo_db3.EchoHost({
6345
6385
  kv: this.level
6346
6386
  });
6387
+ this._meshReplicator = new import_echo_pipeline4.MeshEchoReplicator();
6347
6388
  this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
6348
6389
  this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
6349
6390
  this._handlerFactories.set(import_services17.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
6350
6391
  if (!this._runtimeParams?.disableP2pReplication) {
6351
6392
  this._meshReplicator = new import_echo_pipeline4.MeshEchoReplicator();
6352
6393
  }
6353
- if (this._edgeConnection) {
6394
+ if (this._edgeConnection && this._edgeFeatures?.echoReplicator) {
6354
6395
  this._echoEdgeReplicator = new import_echo_db3.EchoEdgeReplicator({
6355
6396
  edgeConnection: this._edgeConnection
6356
6397
  });
@@ -6360,7 +6401,7 @@ var ServiceContext = class extends import_context15.Resource {
6360
6401
  await this._checkStorageVersion();
6361
6402
  (0, import_log19.log)("opening...", void 0, {
6362
6403
  F: __dxlog_file22,
6363
- L: 160,
6404
+ L: 186,
6364
6405
  S: this,
6365
6406
  C: (f, a) => f(...a)
6366
6407
  });
@@ -6368,13 +6409,13 @@ var ServiceContext = class extends import_context15.Resource {
6368
6409
  id: this._instanceId
6369
6410
  }), {
6370
6411
  F: __dxlog_file22,
6371
- L: 161,
6412
+ L: 187,
6372
6413
  S: this,
6373
6414
  C: (f, a) => f(...a)
6374
6415
  });
6416
+ await this._edgeConnection?.open();
6375
6417
  await this.signalManager.open();
6376
6418
  await this.networkManager.open();
6377
- await this._edgeConnection?.open();
6378
6419
  await this.echoHost.open(ctx);
6379
6420
  if (this._meshReplicator) {
6380
6421
  await this.echoHost.addReplicator(this._meshReplicator);
@@ -6393,7 +6434,7 @@ var ServiceContext = class extends import_context15.Resource {
6393
6434
  count: loadedInvitations.invitations?.length
6394
6435
  }, {
6395
6436
  F: __dxlog_file22,
6396
- L: 183,
6437
+ L: 210,
6397
6438
  S: this,
6398
6439
  C: (f, a) => f(...a)
6399
6440
  });
@@ -6401,13 +6442,13 @@ var ServiceContext = class extends import_context15.Resource {
6401
6442
  id: this._instanceId
6402
6443
  }), {
6403
6444
  F: __dxlog_file22,
6404
- L: 185,
6445
+ L: 212,
6405
6446
  S: this,
6406
6447
  C: (f, a) => f(...a)
6407
6448
  });
6408
6449
  (0, import_log19.log)("opened", void 0, {
6409
6450
  F: __dxlog_file22,
6410
- L: 186,
6451
+ L: 213,
6411
6452
  S: this,
6412
6453
  C: (f, a) => f(...a)
6413
6454
  });
@@ -6415,7 +6456,7 @@ var ServiceContext = class extends import_context15.Resource {
6415
6456
  async _close(ctx) {
6416
6457
  (0, import_log19.log)("closing...", void 0, {
6417
6458
  F: __dxlog_file22,
6418
- L: 190,
6459
+ L: 217,
6419
6460
  S: this,
6420
6461
  C: (f, a) => f(...a)
6421
6462
  });
@@ -6433,7 +6474,7 @@ var ServiceContext = class extends import_context15.Resource {
6433
6474
  await this._edgeConnection?.close();
6434
6475
  (0, import_log19.log)("closed", void 0, {
6435
6476
  F: __dxlog_file22,
6436
- L: 205,
6477
+ L: 232,
6437
6478
  S: this,
6438
6479
  C: (f, a) => f(...a)
6439
6480
  });
@@ -6442,7 +6483,7 @@ var ServiceContext = class extends import_context15.Resource {
6442
6483
  const identity = await this.identityManager.createIdentity(params);
6443
6484
  await this._initialize(new import_context15.Context(void 0, {
6444
6485
  F: __dxlog_file22,
6445
- L: 210
6486
+ L: 237
6446
6487
  }));
6447
6488
  return identity;
6448
6489
  }
@@ -6450,7 +6491,7 @@ var ServiceContext = class extends import_context15.Resource {
6450
6491
  const factory = this._handlerFactories.get(invitation.kind);
6451
6492
  (0, import_invariant19.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
6452
6493
  F: __dxlog_file22,
6453
- L: 216,
6494
+ L: 243,
6454
6495
  S: this,
6455
6496
  A: [
6456
6497
  "factory",
@@ -6471,7 +6512,7 @@ var ServiceContext = class extends import_context15.Resource {
6471
6512
  const identity = await this.identityManager.acceptIdentity(params);
6472
6513
  await this._initialize(new import_context15.Context(void 0, {
6473
6514
  F: __dxlog_file22,
6474
- L: 232
6515
+ L: 259
6475
6516
  }));
6476
6517
  return identity;
6477
6518
  }
@@ -6485,7 +6526,7 @@ var ServiceContext = class extends import_context15.Resource {
6485
6526
  async _initialize(ctx) {
6486
6527
  (0, import_log19.log)("initializing spaces...", void 0, {
6487
6528
  F: __dxlog_file22,
6488
- L: 247,
6529
+ L: 274,
6489
6530
  S: this,
6490
6531
  C: (f, a) => f(...a)
6491
6532
  });
@@ -6514,13 +6555,14 @@ var ServiceContext = class extends import_context15.Resource {
6514
6555
  edgeConnection: this._edgeConnection,
6515
6556
  echoEdgeReplicator: this._echoEdgeReplicator,
6516
6557
  meshReplicator: this._meshReplicator,
6517
- runtimeParams: this._runtimeParams
6558
+ runtimeParams: this._runtimeParams,
6559
+ edgeFeatures: this._edgeFeatures
6518
6560
  });
6519
6561
  await this.dataSpaceManager.open();
6520
6562
  this._handlerFactories.set(import_services17.Invitation.Kind.SPACE, (invitation) => {
6521
6563
  (0, import_invariant19.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
6522
6564
  F: __dxlog_file22,
6523
- L: 275,
6565
+ L: 303,
6524
6566
  S: this,
6525
6567
  A: [
6526
6568
  "this.dataSpaceManager",
@@ -6544,7 +6586,7 @@ var ServiceContext = class extends import_context15.Resource {
6544
6586
  details: assertion
6545
6587
  }, {
6546
6588
  F: __dxlog_file22,
6547
- L: 291,
6589
+ L: 319,
6548
6590
  S: this,
6549
6591
  C: (f, a) => f(...a)
6550
6592
  });
@@ -6555,7 +6597,7 @@ var ServiceContext = class extends import_context15.Resource {
6555
6597
  details: assertion
6556
6598
  }, {
6557
6599
  F: __dxlog_file22,
6558
- L: 295,
6600
+ L: 323,
6559
6601
  S: this,
6560
6602
  C: (f, a) => f(...a)
6561
6603
  });
@@ -6566,7 +6608,7 @@ var ServiceContext = class extends import_context15.Resource {
6566
6608
  details: assertion
6567
6609
  }, {
6568
6610
  F: __dxlog_file22,
6569
- L: 300,
6611
+ L: 328,
6570
6612
  S: this,
6571
6613
  C: (f, a) => f(...a)
6572
6614
  });
@@ -6577,7 +6619,7 @@ var ServiceContext = class extends import_context15.Resource {
6577
6619
  } catch (err) {
6578
6620
  import_log19.log.catch(err, void 0, {
6579
6621
  F: __dxlog_file22,
6580
- L: 306,
6622
+ L: 334,
6581
6623
  S: this,
6582
6624
  C: (f, a) => f(...a)
6583
6625
  });
@@ -7108,18 +7150,18 @@ var NetworkServiceImpl = class {
7108
7150
  next({
7109
7151
  swarm: this.networkManager.connectionState,
7110
7152
  connectionInfo: this.networkManager.connectionLog?.swarms,
7111
- signaling: this.signalManager.getStatus().map(({ host, state }) => ({
7153
+ signaling: this.signalManager.getStatus?.().map(({ host, state }) => ({
7112
7154
  server: host,
7113
7155
  state
7114
7156
  }))
7115
7157
  });
7116
7158
  };
7117
7159
  const unsubscribeSwarm = this.networkManager.connectionStateChanged.on(() => update());
7118
- const unsubscribeSignal = this.signalManager.statusChanged.on(() => update());
7160
+ const unsubscribeSignal = this.signalManager.statusChanged?.on(() => update());
7119
7161
  update();
7120
7162
  return () => {
7121
7163
  unsubscribeSwarm();
7122
- unsubscribeSignal();
7164
+ unsubscribeSignal?.();
7123
7165
  };
7124
7166
  });
7125
7167
  }
@@ -7322,13 +7364,21 @@ var ClientServicesHost = class {
7322
7364
  C: (f, a) => f(...a)
7323
7365
  });
7324
7366
  }
7367
+ const edgeEndpoint = config?.get("runtime.services.edge.url");
7368
+ if (edgeEndpoint) {
7369
+ this._edgeConnection = new import_edge_client.EdgeClient(import_keys16.PublicKey.random(), import_keys16.PublicKey.random(), {
7370
+ socketEndpoint: edgeEndpoint
7371
+ });
7372
+ }
7325
7373
  const { connectionLog = true, transportFactory = (0, import_network_manager2.createSimplePeerTransportFactory)({
7326
7374
  iceServers: this._config?.get("runtime.services.ice")
7327
- }, this._config?.get("runtime.services.iceProviders") && (0, import_network_manager2.createIceProvider)(this._config.get("runtime.services.iceProviders"))), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
7375
+ }, this._config?.get("runtime.services.iceProviders") && (0, import_network_manager2.createIceProvider)(this._config.get("runtime.services.iceProviders"))), signalManager = this._edgeConnection && this._config?.get("runtime.client.edgeFeatures")?.signaling ? new import_messaging.EdgeSignalManager({
7376
+ edgeConnection: this._edgeConnection
7377
+ }) : new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
7328
7378
  this._signalManager = signalManager;
7329
7379
  (0, import_invariant21.invariant)(!this._networkManager, "network manager already set", {
7330
7380
  F: __dxlog_file25,
7331
- L: 223,
7381
+ L: 233,
7332
7382
  S: this,
7333
7383
  A: [
7334
7384
  "!this._networkManager",
@@ -7336,19 +7386,17 @@ var ClientServicesHost = class {
7336
7386
  ]
7337
7387
  });
7338
7388
  this._networkManager = new import_network_manager2.SwarmNetworkManager({
7339
- log: connectionLog,
7389
+ enableDevtoolsLogging: connectionLog,
7340
7390
  transportFactory,
7341
- signalManager
7391
+ signalManager,
7392
+ peerInfo: this._edgeConnection ? {
7393
+ identityKey: this._edgeConnection.identityKey.toHex(),
7394
+ peerKey: this._edgeConnection.deviceKey.toHex()
7395
+ } : void 0
7342
7396
  });
7343
- const edgeEndpoint = config?.get("runtime.services.edge.url");
7344
- if (edgeEndpoint) {
7345
- this._edgeConnection = new import_edge_client.EdgeClient(import_keys16.PublicKey.random(), import_keys16.PublicKey.random(), {
7346
- socketEndpoint: edgeEndpoint
7347
- });
7348
- }
7349
7397
  (0, import_log21.log)("initialized", void 0, {
7350
7398
  F: __dxlog_file25,
7351
- L: 238,
7399
+ L: 246,
7352
7400
  S: this,
7353
7401
  C: (f, a) => f(...a)
7354
7402
  });
@@ -7362,13 +7410,13 @@ var ClientServicesHost = class {
7362
7410
  id: traceId
7363
7411
  }), {
7364
7412
  F: __dxlog_file25,
7365
- L: 249,
7413
+ L: 257,
7366
7414
  S: this,
7367
7415
  C: (f, a) => f(...a)
7368
7416
  });
7369
7417
  (0, import_invariant21.invariant)(this._config, "config not set", {
7370
7418
  F: __dxlog_file25,
7371
- L: 251,
7419
+ L: 259,
7372
7420
  S: this,
7373
7421
  A: [
7374
7422
  "this._config",
@@ -7377,7 +7425,7 @@ var ClientServicesHost = class {
7377
7425
  });
7378
7426
  (0, import_invariant21.invariant)(this._storage, "storage not set", {
7379
7427
  F: __dxlog_file25,
7380
- L: 252,
7428
+ L: 260,
7381
7429
  S: this,
7382
7430
  A: [
7383
7431
  "this._storage",
@@ -7386,7 +7434,7 @@ var ClientServicesHost = class {
7386
7434
  });
7387
7435
  (0, import_invariant21.invariant)(this._signalManager, "signal manager not set", {
7388
7436
  F: __dxlog_file25,
7389
- L: 253,
7437
+ L: 261,
7390
7438
  S: this,
7391
7439
  A: [
7392
7440
  "this._signalManager",
@@ -7395,7 +7443,7 @@ var ClientServicesHost = class {
7395
7443
  });
7396
7444
  (0, import_invariant21.invariant)(this._networkManager, "network manager not set", {
7397
7445
  F: __dxlog_file25,
7398
- L: 254,
7446
+ L: 262,
7399
7447
  S: this,
7400
7448
  A: [
7401
7449
  "this._networkManager",
@@ -7407,7 +7455,7 @@ var ClientServicesHost = class {
7407
7455
  lockKey: this._resourceLock?.lockKey
7408
7456
  }, {
7409
7457
  F: __dxlog_file25,
7410
- L: 257,
7458
+ L: 265,
7411
7459
  S: this,
7412
7460
  C: (f, a) => f(...a)
7413
7461
  });
@@ -7417,7 +7465,7 @@ var ClientServicesHost = class {
7417
7465
  }
7418
7466
  await this._level.open();
7419
7467
  await this._loggingService.open();
7420
- this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._runtimeParams);
7468
+ this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._runtimeParams, this._config.get("runtime.client.edgeFeatures"));
7421
7469
  const dataSpaceManagerProvider = async () => {
7422
7470
  await this._serviceContext.initialized.wait();
7423
7471
  return this._serviceContext.dataSpaceManager;
@@ -7463,7 +7511,7 @@ var ClientServicesHost = class {
7463
7511
  deviceKey
7464
7512
  }, {
7465
7513
  F: __dxlog_file25,
7466
- L: 344,
7514
+ L: 353,
7467
7515
  S: this,
7468
7516
  C: (f, a) => f(...a)
7469
7517
  });
@@ -7471,7 +7519,7 @@ var ClientServicesHost = class {
7471
7519
  id: traceId
7472
7520
  }), {
7473
7521
  F: __dxlog_file25,
7474
- L: 345,
7522
+ L: 354,
7475
7523
  S: this,
7476
7524
  C: (f, a) => f(...a)
7477
7525
  });
@@ -7485,7 +7533,7 @@ var ClientServicesHost = class {
7485
7533
  deviceKey
7486
7534
  }, {
7487
7535
  F: __dxlog_file25,
7488
- L: 356,
7536
+ L: 365,
7489
7537
  S: this,
7490
7538
  C: (f, a) => f(...a)
7491
7539
  });
@@ -7503,7 +7551,7 @@ var ClientServicesHost = class {
7503
7551
  deviceKey
7504
7552
  }, {
7505
7553
  F: __dxlog_file25,
7506
- L: 365,
7554
+ L: 374,
7507
7555
  S: this,
7508
7556
  C: (f, a) => f(...a)
7509
7557
  });
@@ -7514,13 +7562,13 @@ var ClientServicesHost = class {
7514
7562
  id: traceId
7515
7563
  }), {
7516
7564
  F: __dxlog_file25,
7517
- L: 370,
7565
+ L: 379,
7518
7566
  S: this,
7519
7567
  C: (f, a) => f(...a)
7520
7568
  });
7521
7569
  import_log21.log.info("resetting...", void 0, {
7522
7570
  F: __dxlog_file25,
7523
- L: 372,
7571
+ L: 381,
7524
7572
  S: this,
7525
7573
  C: (f, a) => f(...a)
7526
7574
  });
@@ -7528,7 +7576,7 @@ var ClientServicesHost = class {
7528
7576
  await this._storage.reset();
7529
7577
  import_log21.log.info("reset", void 0, {
7530
7578
  F: __dxlog_file25,
7531
- L: 375,
7579
+ L: 384,
7532
7580
  S: this,
7533
7581
  C: (f, a) => f(...a)
7534
7582
  });
@@ -7536,7 +7584,7 @@ var ClientServicesHost = class {
7536
7584
  id: traceId
7537
7585
  }), {
7538
7586
  F: __dxlog_file25,
7539
- L: 376,
7587
+ L: 385,
7540
7588
  S: this,
7541
7589
  C: (f, a) => f(...a)
7542
7590
  });
@@ -7609,4 +7657,4 @@ ClientServicesHost = _ts_decorate8([
7609
7657
  subscribeToSpaces,
7610
7658
  subscribeToSwarmInfo
7611
7659
  });
7612
- //# sourceMappingURL=chunk-PAH5HN65.cjs.map
7660
+ //# sourceMappingURL=chunk-3A3QU6K5.cjs.map