@dxos/client-services 0.8.4-main.03d5cd7b56 → 0.8.4-main.05e74ebcff

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 (34) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +1 -1
  3. package/dist/lib/browser/{chunk-LWIXGESH.mjs → chunk-U2YFOK57.mjs} +129 -110
  4. package/dist/lib/browser/chunk-U2YFOK57.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +1 -1
  6. package/dist/lib/browser/index.mjs.map +2 -2
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/packlets/locks/browser.mjs.map +1 -1
  9. package/dist/lib/browser/testing/index.mjs +1 -1
  10. package/dist/lib/node-esm/{chunk-LOVO5YB5.mjs → chunk-OMK2O7UD.mjs} +129 -110
  11. package/dist/lib/node-esm/chunk-OMK2O7UD.mjs.map +7 -0
  12. package/dist/lib/node-esm/index.mjs +1 -1
  13. package/dist/lib/node-esm/index.mjs.map +2 -2
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/packlets/locks/browser.mjs.map +1 -1
  16. package/dist/lib/node-esm/testing/index.mjs +1 -1
  17. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  18. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +2 -2
  19. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  20. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  21. package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  23. package/dist/types/src/version.d.ts +1 -1
  24. package/dist/types/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +40 -40
  26. package/src/packlets/services/service-context.ts +15 -6
  27. package/src/packlets/space-export/serialized-space-writer.ts +9 -9
  28. package/src/packlets/spaces/data-space-manager.ts +5 -4
  29. package/src/packlets/spaces/data-space.ts +6 -2
  30. package/src/packlets/spaces/epoch-migrations.ts +1 -0
  31. package/src/packlets/spaces/spaces-service.ts +3 -1
  32. package/src/version.ts +1 -1
  33. package/dist/lib/browser/chunk-LWIXGESH.mjs.map +0 -7
  34. package/dist/lib/node-esm/chunk-LOVO5YB5.mjs.map +0 -7
@@ -395,7 +395,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
395
395
  import { TRACE_PROCESSOR } from "@dxos/tracing";
396
396
 
397
397
  // src/version.ts
398
- var DXOS_VERSION = "0.8.4-main.03d5cd7b56";
398
+ var DXOS_VERSION = "0.8.4-main.05e74ebcff";
399
399
 
400
400
  // src/packlets/services/platform.ts
401
401
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -1357,6 +1357,7 @@ var DataSpaceManager = class extends Resource2 {
1357
1357
  if (options.rootUrl) {
1358
1358
  const newRootDocId = documentIdMapping[interpretAsDocumentId(options.rootUrl)] ?? failedInvariant();
1359
1359
  const rootDocHandle = await this._echoHost.loadDoc(ctx, newRootDocId);
1360
+ invariant3(rootDocHandle, "Root document must be available after import.", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 191, S: this, A: ["rootDocHandle", "'Root document must be available after import.'"] });
1360
1361
  DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
1361
1362
  root = await this._echoHost.openSpaceRoot(ctx, spaceId, `automerge:${newRootDocId}`);
1362
1363
  } else {
@@ -1365,22 +1366,22 @@ var DataSpaceManager = class extends Resource2 {
1365
1366
  await this._echoHost.flush(ctx);
1366
1367
  log4("constructing space...", {
1367
1368
  spaceKey
1368
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 197, S: this });
1369
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 198, S: this });
1369
1370
  const space = await this._constructSpace(ctx, metadata);
1370
1371
  await space.open(ctx);
1371
1372
  log4("adding space...", {
1372
1373
  spaceKey
1373
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 202, S: this });
1374
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 203, S: this });
1374
1375
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url, tags, options.membershipPolicy);
1375
1376
  await this._metadataStore.addSpace(metadata);
1376
1377
  const memberCredential = credentials[1];
1377
- invariant3(getCredentialAssertion(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 208, S: this, A: ["getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'", ""] });
1378
+ invariant3(getCredentialAssertion(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 209, S: this, A: ["getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'", ""] });
1378
1379
  await this._signingContext.recordCredential(memberCredential);
1379
1380
  await space.initializeDataPipeline(ctx);
1380
1381
  log4("space ready.", {
1381
1382
  spaceId,
1382
1383
  spaceKey
1383
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 211, S: this });
1384
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 212, S: this });
1384
1385
  this.updated.emit();
1385
1386
  return space;
1386
1387
  }
@@ -1393,9 +1394,9 @@ var DataSpaceManager = class extends Resource2 {
1393
1394
  async acceptSpace(ctx, opts) {
1394
1395
  log4("accept space", {
1395
1396
  opts
1396
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 224, S: this });
1397
- invariant3(this._lifecycleState === LifecycleState.OPEN, "Not open.", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 227, S: this, A: ["this._lifecycleState === LifecycleState.OPEN", "'Not open.'"] });
1398
- invariant3(!this._spaces.has(opts.spaceKey), "Space already exists.", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 228, S: this, A: ["!this._spaces.has(opts.spaceKey)", "'Space already exists.'"] });
1397
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 225, S: this });
1398
+ invariant3(this._lifecycleState === LifecycleState.OPEN, "Not open.", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 228, S: this, A: ["this._lifecycleState === LifecycleState.OPEN", "'Not open.'"] });
1399
+ invariant3(!this._spaces.has(opts.spaceKey), "Space already exists.", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 229, S: this, A: ["!this._spaces.has(opts.spaceKey)", "'Space already exists.'"] });
1399
1400
  const tags = opts.tags ? Array.from(opts.tags) : [];
1400
1401
  const metadata = {
1401
1402
  key: opts.spaceKey,
@@ -1413,14 +1414,14 @@ var DataSpaceManager = class extends Resource2 {
1413
1414
  }
1414
1415
  async admitMember(options) {
1415
1416
  const space = this._spaceManager.spaces.get(options.spaceKey);
1416
- invariant3(space, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 250, S: this, A: ["space", ""] });
1417
+ invariant3(space, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 251, S: this, A: ["space", ""] });
1417
1418
  if (space.spaceState.getMemberRole(options.identityKey) !== SpaceMember3.Role.REMOVED) {
1418
1419
  throw new AlreadyJoinedError();
1419
1420
  }
1420
1421
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId, space.spaceState.tags);
1421
- invariant3(credentials[0].credential, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 257, S: this, A: ["credentials[0].credential", ""] });
1422
+ invariant3(credentials[0].credential, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 258, S: this, A: ["credentials[0].credential", ""] });
1422
1423
  const spaceMemberCredential = credentials[0].credential.credential;
1423
- invariant3(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 259, S: this, A: ["getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'", ""] });
1424
+ invariant3(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 260, S: this, A: ["getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'", ""] });
1424
1425
  await writeMessages(space.controlPipeline.writer, credentials);
1425
1426
  return spaceMemberCredential;
1426
1427
  }
@@ -1450,7 +1451,7 @@ var DataSpaceManager = class extends Resource2 {
1450
1451
  }
1451
1452
  async setSpaceEdgeReplicationSetting(ctx, spaceKey, setting) {
1452
1453
  const space = this._spaces.get(spaceKey);
1453
- invariant3(space, "Space not found.", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 288, S: this, A: ["space", "'Space not found.'"] });
1454
+ invariant3(space, "Space not found.", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 289, S: this, A: ["space", "'Space not found.'"] });
1454
1455
  await this._metadataStore.setSpaceEdgeReplicationSetting(spaceKey, setting);
1455
1456
  if (space.isOpen) {
1456
1457
  switch (setting) {
@@ -1467,7 +1468,7 @@ var DataSpaceManager = class extends Resource2 {
1467
1468
  async _constructSpace(ctx, metadata) {
1468
1469
  log4("construct space", {
1469
1470
  metadata
1470
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 303, S: this });
1471
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 304, S: this });
1471
1472
  const gossip = new Gossip({
1472
1473
  localPeerId: this._signingContext.deviceKey
1473
1474
  });
@@ -1506,12 +1507,12 @@ var DataSpaceManager = class extends Resource2 {
1506
1507
  } catch (err) {
1507
1508
  log4.warn("error on authorized connection", {
1508
1509
  err
1509
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 342, S: this });
1510
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 343, S: this });
1510
1511
  await session.close(err);
1511
1512
  }
1512
1513
  }),
1513
1514
  onAuthFailure: () => {
1514
- log4.warn("auth failure", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 349, S: this });
1515
+ log4.warn("auth failure", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 350, S: this });
1515
1516
  },
1516
1517
  onMemberRolesChanged: async (members) => {
1517
1518
  if (dataSpace?.state === SpaceState.SPACE_READY) {
@@ -1539,13 +1540,13 @@ var DataSpaceManager = class extends Resource2 {
1539
1540
  beforeReady: async () => {
1540
1541
  log4("before space ready", {
1541
1542
  space: space.key
1542
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 375, S: this });
1543
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 376, S: this });
1543
1544
  },
1544
1545
  afterReady: async () => {
1545
1546
  log4("after space ready", {
1546
1547
  space: space.key,
1547
1548
  open: this._lifecycleState === LifecycleState.OPEN
1548
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 380, S: this });
1549
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 381, S: this });
1549
1550
  if (this._lifecycleState === LifecycleState.OPEN) {
1550
1551
  await this._createDelegatedInvitations(dataSpace, [
1551
1552
  ...space.spaceState.invitations.entries()
@@ -1559,7 +1560,7 @@ var DataSpaceManager = class extends Resource2 {
1559
1560
  beforeClose: async () => {
1560
1561
  log4("before space close", {
1561
1562
  space: space.key
1562
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 395, S: this });
1563
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 396, S: this });
1563
1564
  }
1564
1565
  },
1565
1566
  cache: metadata.cache,
@@ -1574,9 +1575,9 @@ var DataSpaceManager = class extends Resource2 {
1574
1575
  if (!setting || setting === EdgeReplicationSetting.ENABLED) {
1575
1576
  await this._echoEdgeReplicator?.connectToSpace(this._ctx, dataSpace.id);
1576
1577
  } else if (this._echoEdgeReplicator) {
1577
- log4("not connecting EchoEdgeReplicator because of EdgeReplicationSetting", {
1578
+ log4("not connecting edge replicator because of EdgeReplicationSetting", {
1578
1579
  spaceId: dataSpace.id
1579
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 413, S: this });
1580
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 414, S: this });
1580
1581
  }
1581
1582
  });
1582
1583
  dataSpace.preClose.append(async () => {
@@ -1601,7 +1602,7 @@ var DataSpaceManager = class extends Resource2 {
1601
1602
  if (!replicator) {
1602
1603
  log4.warn("p2p automerge replication disabled", {
1603
1604
  space: space.key
1604
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 438, S: this });
1605
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 439, S: this });
1605
1606
  return;
1606
1607
  }
1607
1608
  await replicator.authorizeDevice(space.key, session.remotePeerId);
@@ -1629,7 +1630,7 @@ var DataSpaceManager = class extends Resource2 {
1629
1630
  roleChangeCount: memberInfo.length,
1630
1631
  peersOnline: presence.getPeersOnline().length,
1631
1632
  closedSessions
1632
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 465, S: this });
1633
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 466, S: this });
1633
1634
  spaceProtocol.updateTopology();
1634
1635
  }
1635
1636
  _handleNewPeerConnected(space, peerState) {
@@ -1639,7 +1640,7 @@ var DataSpaceManager = class extends Resource2 {
1639
1640
  if (session != null) {
1640
1641
  log4("closing a session with a removed peer", {
1641
1642
  peerId: peerState.peerId
1642
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 478, S: this });
1643
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 479, S: this });
1643
1644
  void session.close().catch(log4.error);
1644
1645
  }
1645
1646
  }
@@ -1908,13 +1909,13 @@ var writeSerializedSpaceArchive = async (options) => {
1908
1909
  collectObjectsFromDoc(rootDoc, objects);
1909
1910
  for (const linkedUrl of databaseRoot.getAllLinkedDocuments()) {
1910
1911
  const handle = await echoHost.loadDoc(Context4.default(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 77 }), linkedUrl);
1911
- const doc = handle.doc();
1912
- if (!doc) {
1913
- log5.warn("linked document did not load; skipping", {
1912
+ if (!handle) {
1913
+ log5.warn("linked document handle not available; skipping", {
1914
1914
  url: linkedUrl
1915
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 80, S: void 0 });
1915
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 79, S: void 0 });
1916
1916
  continue;
1917
1917
  }
1918
+ const doc = handle.doc();
1918
1919
  collectObjectsFromDoc(doc, objects);
1919
1920
  }
1920
1921
  const feeds = await exportFeedData(space, echoHost, objects);
@@ -1982,18 +1983,18 @@ var exportFeedData = async (space, echoHost, objects) => {
1982
1983
  if (obj[ATTR_TYPE2] == null) {
1983
1984
  continue;
1984
1985
  }
1985
- const typeDxn = DXN.tryParse(obj[ATTR_TYPE2]);
1986
- if (typeDxn?.asTypeDXN()?.type !== FEED_TYPENAME) {
1986
+ const typeDXN = DXN.tryParse(obj[ATTR_TYPE2]);
1987
+ if (typeDXN?.asTypeDXN()?.type !== FEED_TYPENAME) {
1987
1988
  continue;
1988
1989
  }
1989
1990
  const namespace = obj.namespace === "trace" ? "trace" : "data";
1990
- const queueDxn = new DXN(DXN.kind.QUEUE, [
1991
+ const queueDXN = new DXN(DXN.kind.QUEUE, [
1991
1992
  namespace,
1992
1993
  spaceId,
1993
1994
  obj.id
1994
1995
  ]);
1995
1996
  try {
1996
- const messages = await collectQueueMessages(echoHost, queueDxn);
1997
+ const messages = await collectQueueMessages(echoHost, queueDXN);
1997
1998
  if (messages.length > 0) {
1998
1999
  feeds.push({
1999
2000
  feedObjectId: obj.id,
@@ -2010,8 +2011,8 @@ var exportFeedData = async (space, echoHost, objects) => {
2010
2011
  }
2011
2012
  return feeds;
2012
2013
  };
2013
- var collectQueueMessages = async (echoHost, queueDxn) => {
2014
- const parts = queueDxn.asQueueDXN();
2014
+ var collectQueueMessages = async (echoHost, queueDXN) => {
2015
+ const parts = queueDXN.asQueueDXN();
2015
2016
  invariant4(parts, "Expected a queue DXN", { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 189, S: void 0, A: ["parts", "'Expected a queue DXN'"] });
2016
2017
  const namespace = parts.subspaceTag === "trace" ? FeedProtocol.WellKnownNamespaces.trace : FeedProtocol.WellKnownNamespaces.data;
2017
2018
  const messages = [];
@@ -2539,7 +2540,9 @@ var SpacesServiceImpl = class {
2539
2540
  const format = request.archive.format ?? detectSpaceArchiveFormat(request.archive);
2540
2541
  if (format === SpaceArchive4.Format.JSON) {
2541
2542
  const serialized = readSerializedSpaceArchive(request.archive);
2542
- const space2 = await dataSpaceManager.createSpace(ctx);
2543
+ const space2 = await dataSpaceManager.createSpace(ctx, {
2544
+ tags: request.tags
2545
+ });
2543
2546
  await this._hydrateSpaceFromSerialized(space2, serialized);
2544
2547
  await this._updateMetrics();
2545
2548
  return {
@@ -2547,10 +2550,11 @@ var SpacesServiceImpl = class {
2547
2550
  };
2548
2551
  }
2549
2552
  const extracted = await extractSpaceArchive(request.archive);
2550
- invariant6(extracted.metadata.echo?.currentRootUrl, "Space archive does not contain a root URL", { "~LogMeta": "~LogMeta", F: __dxlog_file9, L: 357, S: this, A: ["extracted.metadata.echo?.currentRootUrl", "'Space archive does not contain a root URL'"] });
2553
+ invariant6(extracted.metadata.echo?.currentRootUrl, "Space archive does not contain a root URL", { "~LogMeta": "~LogMeta", F: __dxlog_file9, L: 359, S: this, A: ["extracted.metadata.echo?.currentRootUrl", "'Space archive does not contain a root URL'"] });
2551
2554
  const space = await dataSpaceManager.createSpace(ctx, {
2552
2555
  documents: extracted.documents,
2553
- rootUrl: extracted.metadata.echo?.currentRootUrl
2556
+ rootUrl: extracted.metadata.echo?.currentRootUrl,
2557
+ tags: request.tags
2554
2558
  });
2555
2559
  await this._updateMetrics();
2556
2560
  return {
@@ -2591,15 +2595,15 @@ var SpacesServiceImpl = class {
2591
2595
  log7.warn("failed to import feed data", {
2592
2596
  feedObjectId: feed.feedObjectId,
2593
2597
  error: err
2594
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file9, L: 397, S: this });
2598
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file9, L: 400, S: this });
2595
2599
  }
2596
2600
  }
2597
2601
  }
2598
2602
  async _joinByAdmission(ctx, { credential }) {
2599
2603
  const assertion = getCredentialAssertion2(credential);
2600
- invariant6(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", { "~LogMeta": "~LogMeta", F: __dxlog_file9, L: 406, S: this, A: ["assertion['@type'] === 'dxos.halo.credentials.SpaceMember'", "'Invalid credential'"] });
2604
+ invariant6(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", { "~LogMeta": "~LogMeta", F: __dxlog_file9, L: 409, S: this, A: ["assertion['@type'] === 'dxos.halo.credentials.SpaceMember'", "'Invalid credential'"] });
2601
2605
  const myIdentity = this._identityManager.identity;
2602
- invariant6(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file9, L: 408, S: this, A: ["myIdentity && credential.subject.id.equals(myIdentity.identityKey)", ""] });
2606
+ invariant6(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file9, L: 411, S: this, A: ["myIdentity && credential.subject.id.equals(myIdentity.identityKey)", ""] });
2603
2607
  const dataSpaceManager = await this._getDataSpaceManager();
2604
2608
  let dataSpace = dataSpaceManager.spaces.get(assertion.spaceKey);
2605
2609
  if (!dataSpace) {
@@ -3378,6 +3382,7 @@ var runEpochMigration = async (ctx, context) => {
3378
3382
  const rootHandle = await context.echoHost.loadDoc(ctx, context.currentRoot, {
3379
3383
  timeout: LOAD_DOC_TIMEOUT
3380
3384
  });
3385
+ invariant10(rootHandle, "Automerge root document must load for history prune migration.", { "~LogMeta": "~LogMeta", F: __dxlog_file13, L: 25, S: void 0, A: ["rootHandle", "'Automerge root document must load for history prune migration.'"] });
3381
3386
  const newRoot = await context.echoHost.createDoc(rootHandle.doc());
3382
3387
  await context.echoHost.flush(ctx);
3383
3388
  return {
@@ -3392,7 +3397,7 @@ var runEpochMigration = async (ctx, context) => {
3392
3397
  }
3393
3398
  // TODO(dmaretskyi): This path doesn't seem to fit here. This is not a migration.
3394
3399
  case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
3395
- invariant10(context.newAutomergeRoot, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file13, L: 42, S: void 0, A: ["context.newAutomergeRoot", ""] });
3400
+ invariant10(context.newAutomergeRoot, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file13, L: 43, S: void 0, A: ["context.newAutomergeRoot", ""] });
3396
3401
  await context.echoHost.flush(ctx);
3397
3402
  return {
3398
3403
  newRoot: context.newAutomergeRoot
@@ -4142,7 +4147,7 @@ var DataSpace = class {
4142
4147
  space: this.key,
4143
4148
  rootUrl
4144
4149
  }, { "~LogMeta": "~LogMeta", F: __dxlog_file15, L: 413, S: this });
4145
- let handle;
4150
+ let handle = null;
4146
4151
  queueMicrotask(async () => {
4147
4152
  try {
4148
4153
  const env = {
@@ -4159,8 +4164,15 @@ var DataSpace = class {
4159
4164
  if (this._ctx.disposed) {
4160
4165
  return;
4161
4166
  }
4167
+ if (!handle) {
4168
+ log11.warn("automerge root doc not available yet", {
4169
+ space: this.key,
4170
+ rootUrl
4171
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file15, L: 436, S: this });
4172
+ return;
4173
+ }
4162
4174
  const _guard = _ts_add_disposable_resource3(env, await this._epochProcessingMutex.acquire(), false);
4163
- const doc = handle.doc() ?? failedInvariant3();
4175
+ const doc = handle.doc();
4164
4176
  if (!doc.access?.spaceKey) {
4165
4177
  handle.change((doc2) => {
4166
4178
  doc2.access = {
@@ -4192,7 +4204,7 @@ var DataSpace = class {
4192
4204
  space: this.key,
4193
4205
  rootUrl,
4194
4206
  err
4195
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file15, L: 468, S: this });
4207
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file15, L: 475, S: this });
4196
4208
  }
4197
4209
  });
4198
4210
  }
@@ -4277,7 +4289,7 @@ var DataSpace = class {
4277
4289
  this._state = SpaceState3.SPACE_INACTIVE;
4278
4290
  log11("new state", {
4279
4291
  state: SpaceState3[this._state]
4280
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file15, L: 556, S: this });
4292
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file15, L: 563, S: this });
4281
4293
  this.stateUpdate.emit();
4282
4294
  }
4283
4295
  getEdgeReplicationSetting() {
@@ -6396,7 +6408,7 @@ import { Mutex as Mutex4, Trigger as Trigger6 } from "@dxos/async";
6396
6408
  import { Resource as Resource9 } from "@dxos/context";
6397
6409
  import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
6398
6410
  import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
6399
- import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
6411
+ import { EchoEdgeReplicator, EchoEdgeSubductionReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
6400
6412
  import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from "@dxos/edge-client";
6401
6413
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
6402
6414
  import { invariant as invariant24 } from "@dxos/invariant";
@@ -6994,11 +7006,18 @@ var ServiceContext = class extends Resource9 {
6994
7006
  if (!this._runtimeProps?.disableP2pReplication) {
6995
7007
  this._meshReplicator = new MeshEchoReplicator();
6996
7008
  }
6997
- if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
6998
- this._echoEdgeReplicator = new EchoEdgeReplicator({
6999
- edgeConnection: this._edgeConnection,
7000
- edgeHttpClient: this._edgeHttpClient
7001
- });
7009
+ if (this._edgeConnection && this._edgeHttpClient) {
7010
+ if (this._edgeFeatures?.subductionReplicator) {
7011
+ this._echoEdgeReplicator = new EchoEdgeSubductionReplicator({
7012
+ edgeConnection: this._edgeConnection,
7013
+ edgeHttpClient: this._edgeHttpClient
7014
+ });
7015
+ } else if (this._edgeFeatures?.echoReplicator) {
7016
+ this._echoEdgeReplicator = new EchoEdgeReplicator({
7017
+ edgeConnection: this._edgeConnection,
7018
+ edgeHttpClient: this._edgeHttpClient
7019
+ });
7020
+ }
7002
7021
  }
7003
7022
  if (this.echoHost.feedStore && this._edgeConnection) {
7004
7023
  this._feedSyncer = new FeedSyncer({
@@ -7016,67 +7035,67 @@ var ServiceContext = class extends Resource9 {
7016
7035
  }
7017
7036
  async _open(ctx) {
7018
7037
  await this._checkStorageVersion();
7019
- log23("opening...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 208, S: this });
7020
- log23("opening identityManager...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 209, S: this });
7038
+ log23("opening...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 215, S: this });
7039
+ log23("opening identityManager...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 216, S: this });
7021
7040
  await this.identityManager.open(ctx);
7022
7041
  log23("identityManager opened", {
7023
7042
  hasIdentity: !!this.identityManager.identity
7024
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 211, S: this });
7025
- log23("setting network identity...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 214, S: this });
7043
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 218, S: this });
7044
+ log23("setting network identity...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 221, S: this });
7026
7045
  await this._setNetworkIdentity({
7027
7046
  identity: this.identityManager.identity
7028
7047
  });
7029
- log23("network identity set", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 218, S: this });
7030
- log23("opening edge connection...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 219, S: this });
7048
+ log23("network identity set", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 225, S: this });
7049
+ log23("opening edge connection...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 226, S: this });
7031
7050
  await this._edgeConnection?.open(ctx);
7032
- log23("edge connection opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 221, S: this });
7033
- log23("opening signal manager...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 222, S: this });
7051
+ log23("edge connection opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 228, S: this });
7052
+ log23("opening signal manager...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 229, S: this });
7034
7053
  await this.signalManager.open(ctx);
7035
- log23("signal manager opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 224, S: this });
7036
- log23("opening network manager...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 225, S: this });
7054
+ log23("signal manager opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 231, S: this });
7055
+ log23("opening network manager...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 232, S: this });
7037
7056
  await this.networkManager.open();
7038
- log23("network manager opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 227, S: this });
7039
- log23("opening echo host...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 228, S: this });
7057
+ log23("network manager opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 234, S: this });
7058
+ log23("opening echo host...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 235, S: this });
7040
7059
  await this.echoHost.open(ctx);
7041
- log23("echo host opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 230, S: this });
7060
+ log23("echo host opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 237, S: this });
7042
7061
  if (this._meshReplicator) {
7043
- log23("adding mesh replicator...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 232, S: this });
7062
+ log23("adding mesh replicator...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 239, S: this });
7044
7063
  await this.echoHost.addReplicator(ctx, this._meshReplicator);
7045
- log23("mesh replicator added", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 234, S: this });
7064
+ log23("mesh replicator added", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 241, S: this });
7046
7065
  }
7047
7066
  if (this._echoEdgeReplicator) {
7048
- log23("adding edge replicator...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 237, S: this });
7067
+ log23("adding edge replicator...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 244, S: this });
7049
7068
  await this.echoHost.addReplicator(ctx, this._echoEdgeReplicator);
7050
- log23("edge replicator added", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 239, S: this });
7069
+ log23("edge replicator added", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 246, S: this });
7051
7070
  }
7052
- log23("loading metadata store...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 241, S: this });
7071
+ log23("loading metadata store...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 248, S: this });
7053
7072
  await this.metadataStore.load();
7054
- log23("metadata store loaded", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 243, S: this });
7055
- log23("opening space manager...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 244, S: this });
7073
+ log23("metadata store loaded", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 250, S: this });
7074
+ log23("opening space manager...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 251, S: this });
7056
7075
  await this.spaceManager.open();
7057
- log23("space manager opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 246, S: this });
7076
+ log23("space manager opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 253, S: this });
7058
7077
  if (this.identityManager.identity) {
7059
- log23("joining network...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 248, S: this });
7078
+ log23("joining network...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 255, S: this });
7060
7079
  await this.identityManager.identity.joinNetwork(ctx);
7061
- log23("network joined", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 250, S: this });
7062
- log23("initializing spaces...(calling _initialize)", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 251, S: this });
7080
+ log23("network joined", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 257, S: this });
7081
+ log23("initializing spaces...(calling _initialize)", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 258, S: this });
7063
7082
  await this._initialize(ctx);
7064
- log23("spaces initialized", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 253, S: this });
7083
+ log23("spaces initialized", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 260, S: this });
7065
7084
  } else {
7066
- log23("no identity, skipping network join and space initialization", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 255, S: this });
7085
+ log23("no identity, skipping network join and space initialization", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 262, S: this });
7067
7086
  }
7068
- log23("opening feed syncer...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 257, S: this });
7087
+ log23("opening feed syncer...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 264, S: this });
7069
7088
  await this._feedSyncer?.open(ctx);
7070
- log23("feed syncer opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 259, S: this });
7071
- log23("loading persistent invitations...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 260, S: this });
7089
+ log23("feed syncer opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 266, S: this });
7090
+ log23("loading persistent invitations...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 267, S: this });
7072
7091
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations(ctx);
7073
7092
  log23("loaded persistent invitations", {
7074
7093
  count: loadedInvitations.invitations?.length
7075
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 262, S: this });
7076
- log23("opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 265, S: this });
7094
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 269, S: this });
7095
+ log23("opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 272, S: this });
7077
7096
  }
7078
7097
  async _close(ctx) {
7079
- log23("closing...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 268, S: this });
7098
+ log23("closing...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 275, S: this });
7080
7099
  await this._feedSyncer?.close();
7081
7100
  if (this._deviceSpaceSync && this.identityManager.identity) {
7082
7101
  await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
@@ -7091,7 +7110,7 @@ var ServiceContext = class extends Resource9 {
7091
7110
  await this._edgeConnection?.close();
7092
7111
  await this.feedStore.close();
7093
7112
  await this.metadataStore.close();
7094
- log23("closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 283, S: this });
7113
+ log23("closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 290, S: this });
7095
7114
  }
7096
7115
  async createIdentity(params = {}, ctx) {
7097
7116
  ctx ??= this._ctx;
@@ -7108,7 +7127,7 @@ var ServiceContext = class extends Resource9 {
7108
7127
  throw new Error("Identity must be created before joining a space.");
7109
7128
  }
7110
7129
  const factory = this._handlerFactories.get(invitation.kind);
7111
- invariant24(factory, `Unknown invitation kind: ${invitation.kind}`, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 300, S: this, A: ["factory", "`Unknown invitation kind: ${invitation.kind}`"] });
7130
+ invariant24(factory, `Unknown invitation kind: ${invitation.kind}`, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 307, S: this, A: ["factory", "`Unknown invitation kind: ${invitation.kind}`"] });
7112
7131
  return factory(invitation);
7113
7132
  }
7114
7133
  async broadcastProfileUpdate(profile) {
@@ -7138,7 +7157,7 @@ var ServiceContext = class extends Resource9 {
7138
7157
  }
7139
7158
  // Called when identity is created.
7140
7159
  async _initialize(ctx) {
7141
- log23("_initialize: start", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 331, S: this });
7160
+ log23("_initialize: start", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 338, S: this });
7142
7161
  const identity = this.identityManager.identity ?? failUndefined2();
7143
7162
  const signingContext = {
7144
7163
  credentialSigner: identity.getIdentityCredentialSigner(),
@@ -7153,7 +7172,7 @@ var ServiceContext = class extends Resource9 {
7153
7172
  });
7154
7173
  }
7155
7174
  };
7156
- log23("_initialize: creating DataSpaceManager", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 346, S: this });
7175
+ log23("_initialize: creating DataSpaceManager", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 353, S: this });
7157
7176
  this.dataSpaceManager = new DataSpaceManager({
7158
7177
  spaceManager: this.spaceManager,
7159
7178
  metadataStore: this.metadataStore,
@@ -7169,19 +7188,19 @@ var ServiceContext = class extends Resource9 {
7169
7188
  runtimeProps: this._runtimeProps,
7170
7189
  edgeFeatures: this._edgeFeatures
7171
7190
  });
7172
- log23("_initialize: opening DataSpaceManager...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 362, S: this });
7191
+ log23("_initialize: opening DataSpaceManager...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 369, S: this });
7173
7192
  await this.dataSpaceManager.open(ctx);
7174
- log23("_initialize: DataSpaceManager opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 364, S: this });
7193
+ log23("_initialize: DataSpaceManager opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 371, S: this });
7175
7194
  this.edgeAgentManager = new EdgeAgentManager(this._edgeFeatures, this._edgeHttpClient, this.dataSpaceManager, identity);
7176
- log23("_initialize: opening EdgeAgentManager...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 366, S: this });
7195
+ log23("_initialize: opening EdgeAgentManager...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 373, S: this });
7177
7196
  await this.edgeAgentManager.open(ctx);
7178
- log23("_initialize: EdgeAgentManager opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 368, S: this });
7197
+ log23("_initialize: EdgeAgentManager opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 375, S: this });
7179
7198
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
7180
- invariant24(this.dataSpaceManager, "dataSpaceManager not initialized yet", { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 370, S: this, A: ["this.dataSpaceManager", "'dataSpaceManager not initialized yet'"] });
7199
+ invariant24(this.dataSpaceManager, "dataSpaceManager not initialized yet", { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 377, S: this, A: ["this.dataSpaceManager", "'dataSpaceManager not initialized yet'"] });
7181
7200
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
7182
7201
  });
7183
7202
  this.initialized.wake();
7184
- log23("_initialize: initialized.wake() called", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 374, S: this });
7203
+ log23("_initialize: initialized.wake() called", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 381, S: this });
7185
7204
  this._deviceSpaceSync = {
7186
7205
  processCredential: async (credential) => {
7187
7206
  const assertion = getCredentialAssertion5(credential);
@@ -7194,26 +7213,26 @@ var ServiceContext = class extends Resource9 {
7194
7213
  if (!this.dataSpaceManager) {
7195
7214
  log23("dataSpaceManager not initialized yet, ignoring space admission", {
7196
7215
  details: assertion
7197
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 386, S: this });
7216
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 393, S: this });
7198
7217
  return;
7199
7218
  }
7200
7219
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
7201
7220
  log23("space already exists, ignoring space admission", {
7202
7221
  details: assertion
7203
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 392, S: this });
7222
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 399, S: this });
7204
7223
  return;
7205
7224
  }
7206
7225
  try {
7207
7226
  log23("accepting space recorded in halo", {
7208
7227
  details: assertion
7209
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 398, S: this });
7228
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 405, S: this });
7210
7229
  await this.dataSpaceManager.acceptSpace(this._ctx, {
7211
7230
  spaceKey: assertion.spaceKey,
7212
7231
  genesisFeedKey: assertion.genesisFeedKey,
7213
7232
  tags: assertion.tags
7214
7233
  });
7215
7234
  } catch (err) {
7216
- log23.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 407, S: this });
7235
+ log23.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 414, S: this });
7217
7236
  }
7218
7237
  }
7219
7238
  };
@@ -7226,39 +7245,39 @@ var ServiceContext = class extends Resource9 {
7226
7245
  hasError: false
7227
7246
  };
7228
7247
  try {
7229
- log23("_setNetworkIdentity: acquiring mutex...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 420, S: this });
7248
+ log23("_setNetworkIdentity: acquiring mutex...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 427, S: this });
7230
7249
  const _ = _ts_add_disposable_resource4(env, await this._edgeIdentityUpdateMutex.acquire(), false);
7231
- log23("_setNetworkIdentity: mutex acquired", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 422, S: this });
7250
+ log23("_setNetworkIdentity: mutex acquired", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 429, S: this });
7232
7251
  let edgeIdentity;
7233
7252
  const identity = params?.identity;
7234
7253
  if (identity) {
7235
7254
  log23("_setNetworkIdentity: has identity", {
7236
7255
  identity: identity.identityKey.toHex(),
7237
7256
  hasDeviceCredential: !!params?.deviceCredential
7238
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 426, S: this });
7257
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 433, S: this });
7239
7258
  if (params?.deviceCredential) {
7240
- log23("_setNetworkIdentity: creating chain edge identity with device credential...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 431, S: this });
7259
+ log23("_setNetworkIdentity: creating chain edge identity with device credential...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 438, S: this });
7241
7260
  edgeIdentity = await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, {
7242
7261
  credential: params.deviceCredential
7243
7262
  }, []);
7244
- log23("_setNetworkIdentity: chain edge identity created", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 435, S: this });
7263
+ log23("_setNetworkIdentity: chain edge identity created", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 442, S: this });
7245
7264
  } else {
7246
- log23("_setNetworkIdentity: waiting for identity.ready()...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 437, S: this });
7265
+ log23("_setNetworkIdentity: waiting for identity.ready()...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 444, S: this });
7247
7266
  await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
7248
7267
  await identity.ready();
7249
7268
  });
7250
7269
  log23("_setNetworkIdentity: identity.ready() resolved", {
7251
7270
  hasDeviceCredentialChain: !!identity.deviceCredentialChain
7252
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 442, S: this });
7253
- invariant24(identity.deviceCredentialChain, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 445, S: this, A: ["identity.deviceCredentialChain", ""] });
7254
- log23("_setNetworkIdentity: creating chain edge identity...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 446, S: this });
7271
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 449, S: this });
7272
+ invariant24(identity.deviceCredentialChain, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 452, S: this, A: ["identity.deviceCredentialChain", ""] });
7273
+ log23("_setNetworkIdentity: creating chain edge identity...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 453, S: this });
7255
7274
  edgeIdentity = await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, identity.deviceCredentialChain, []);
7256
- log23("_setNetworkIdentity: chain edge identity created", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 448, S: this });
7275
+ log23("_setNetworkIdentity: chain edge identity created", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 455, S: this });
7257
7276
  }
7258
7277
  } else {
7259
- log23("_setNetworkIdentity: no identity, creating ephemeral edge identity...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 451, S: this });
7278
+ log23("_setNetworkIdentity: no identity, creating ephemeral edge identity...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 458, S: this });
7260
7279
  edgeIdentity = await createEphemeralEdgeIdentity();
7261
- log23("_setNetworkIdentity: ephemeral edge identity created", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 453, S: this });
7280
+ log23("_setNetworkIdentity: ephemeral edge identity created", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 460, S: this });
7262
7281
  }
7263
7282
  this._edgeConnection?.setIdentity(edgeIdentity);
7264
7283
  this._edgeHttpClient?.setIdentity(edgeIdentity);
@@ -7266,7 +7285,7 @@ var ServiceContext = class extends Resource9 {
7266
7285
  identityKey: edgeIdentity.identityKey,
7267
7286
  peerKey: edgeIdentity.peerKey
7268
7287
  });
7269
- log23("_setNetworkIdentity: done", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 461, S: this });
7288
+ log23("_setNetworkIdentity: done", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file29, L: 468, S: this });
7270
7289
  } catch (e) {
7271
7290
  env.error = e;
7272
7291
  env.hasError = true;
@@ -8207,4 +8226,4 @@ export {
8207
8226
  ServiceRegistry,
8208
8227
  ClientServicesHost
8209
8228
  };
8210
- //# sourceMappingURL=chunk-LWIXGESH.mjs.map
8229
+ //# sourceMappingURL=chunk-U2YFOK57.mjs.map