@dxos/client-services 0.7.5-main.9d26e3a → 0.7.5-main.e9bb01b

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 (81) hide show
  1. package/dist/lib/browser/{chunk-27A4ATQX.mjs → chunk-O46EJ5BJ.mjs} +172 -123
  2. package/dist/lib/browser/chunk-O46EJ5BJ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/testing/index.mjs +1 -1
  6. package/dist/lib/node/{chunk-7FKXMJDD.cjs → chunk-WFDMSV4I.cjs} +202 -153
  7. package/dist/lib/node/chunk-WFDMSV4I.cjs.map +7 -0
  8. package/dist/lib/node/index.cjs +47 -47
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/testing/index.cjs +8 -8
  11. package/dist/lib/node-esm/{chunk-HGN7FHFK.mjs → chunk-UWR5XM7L.mjs} +172 -123
  12. package/dist/lib/node-esm/chunk-UWR5XM7L.mjs.map +7 -0
  13. package/dist/lib/node-esm/index.mjs +1 -1
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/testing/index.mjs +1 -1
  16. package/dist/types/src/packlets/agents/edge-agent-service.d.ts +1 -1
  17. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  18. package/dist/types/src/packlets/devices/devices-service.d.ts +1 -1
  19. package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
  20. package/dist/types/src/packlets/devtools/devtools.d.ts +1 -1
  21. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  22. package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
  23. package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
  24. package/dist/types/src/packlets/devtools/keys.d.ts +1 -1
  25. package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
  26. package/dist/types/src/packlets/devtools/metadata.d.ts +1 -1
  27. package/dist/types/src/packlets/devtools/metadata.d.ts.map +1 -1
  28. package/dist/types/src/packlets/devtools/network.d.ts +1 -1
  29. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  30. package/dist/types/src/packlets/devtools/spaces.d.ts +1 -1
  31. package/dist/types/src/packlets/devtools/spaces.d.ts.map +1 -1
  32. package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
  33. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
  34. package/dist/types/src/packlets/identity/identity-service.d.ts +1 -1
  35. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  36. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  37. package/dist/types/src/packlets/invitations/invitations-service.d.ts +1 -1
  38. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  39. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  40. package/dist/types/src/packlets/invitations/utils.d.ts +1 -0
  41. package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
  42. package/dist/types/src/packlets/logging/logging-service.d.ts +1 -1
  43. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  44. package/dist/types/src/packlets/network/network-service.d.ts +9 -2
  45. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  46. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  47. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +3 -0
  48. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  49. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  50. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  51. package/dist/types/src/packlets/system/system-service.d.ts +1 -1
  52. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  53. package/dist/types/src/version.d.ts +1 -1
  54. package/dist/types/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +38 -38
  56. package/src/packlets/agents/edge-agent-service.ts +1 -1
  57. package/src/packlets/devices/devices-service.ts +1 -1
  58. package/src/packlets/devtools/devtools.ts +1 -1
  59. package/src/packlets/devtools/feeds.ts +1 -1
  60. package/src/packlets/devtools/keys.ts +1 -1
  61. package/src/packlets/devtools/metadata.ts +1 -1
  62. package/src/packlets/devtools/network.ts +1 -1
  63. package/src/packlets/devtools/spaces.ts +1 -1
  64. package/src/packlets/identity/contacts-service.ts +1 -1
  65. package/src/packlets/identity/identity-service.ts +1 -1
  66. package/src/packlets/invitations/invitations-handler.ts +15 -6
  67. package/src/packlets/invitations/invitations-manager.ts +1 -1
  68. package/src/packlets/invitations/invitations-service.ts +1 -1
  69. package/src/packlets/invitations/space-invitation-protocol.ts +2 -3
  70. package/src/packlets/invitations/utils.ts +7 -0
  71. package/src/packlets/logging/logging-service.ts +1 -1
  72. package/src/packlets/network/network-service.ts +39 -1
  73. package/src/packlets/services/service-context.ts +1 -0
  74. package/src/packlets/spaces/data-space-manager.ts +1 -1
  75. package/src/packlets/spaces/notarization-plugin.ts +32 -17
  76. package/src/packlets/spaces/spaces-service.ts +1 -1
  77. package/src/packlets/system/system-service.ts +1 -1
  78. package/src/version.ts +1 -1
  79. package/dist/lib/browser/chunk-27A4ATQX.mjs.map +0 -7
  80. package/dist/lib/node/chunk-7FKXMJDD.cjs.map +0 -7
  81. package/dist/lib/node-esm/chunk-HGN7FHFK.mjs.map +0 -7
@@ -2,7 +2,7 @@ import "@dxos/node-std/globals";
2
2
 
3
3
  // packages/sdk/client-services/src/packlets/devtools/feeds.ts
4
4
  import { EventSubscriptions } from "@dxos/async";
5
- import { Stream } from "@dxos/codec-protobuf";
5
+ import { Stream } from "@dxos/codec-protobuf/stream";
6
6
  import { FeedIterator } from "@dxos/feed-store";
7
7
  import { PublicKey } from "@dxos/keys";
8
8
  import { log } from "@dxos/log";
@@ -113,7 +113,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
113
113
  };
114
114
 
115
115
  // packages/sdk/client-services/src/packlets/devtools/network.ts
116
- import { Stream as Stream2 } from "@dxos/codec-protobuf";
116
+ import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
117
117
  import { Context } from "@dxos/context";
118
118
  import { PublicKey as PublicKey2 } from "@dxos/keys";
119
119
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/network.ts";
@@ -210,7 +210,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
210
210
  };
211
211
 
212
212
  // packages/sdk/client-services/src/packlets/devtools/spaces.ts
213
- import { Stream as Stream3 } from "@dxos/codec-protobuf";
213
+ import { Stream as Stream3 } from "@dxos/codec-protobuf/stream";
214
214
  var subscribeToSpaces = (context, { spaceKeys = [] }) => {
215
215
  return new Stream3(({ next }) => {
216
216
  let unsubscribe;
@@ -247,11 +247,11 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
247
247
 
248
248
  // packages/sdk/client-services/src/packlets/devtools/devtools.ts
249
249
  import { Event as AsyncEvent } from "@dxos/async";
250
- import { Stream as Stream6 } from "@dxos/codec-protobuf";
250
+ import { Stream as Stream6 } from "@dxos/codec-protobuf/stream";
251
251
 
252
252
  // packages/sdk/client-services/src/packlets/devtools/keys.ts
253
253
  import { scheduleTask } from "@dxos/async";
254
- import { Stream as Stream4 } from "@dxos/codec-protobuf";
254
+ import { Stream as Stream4 } from "@dxos/codec-protobuf/stream";
255
255
  var subscribeToKeyringKeys = ({ keyring }) => new Stream4(({ next, ctx }) => {
256
256
  const update = async () => {
257
257
  next({
@@ -263,7 +263,7 @@ var subscribeToKeyringKeys = ({ keyring }) => new Stream4(({ next, ctx }) => {
263
263
  });
264
264
 
265
265
  // packages/sdk/client-services/src/packlets/devtools/metadata.ts
266
- import { Stream as Stream5 } from "@dxos/codec-protobuf";
266
+ import { Stream as Stream5 } from "@dxos/codec-protobuf/stream";
267
267
  var subscribeToMetadata = ({ context }) => new Stream5(({ next, ctx }) => {
268
268
  context.metadataStore.update.on(ctx, (data) => next({
269
269
  metadata: data
@@ -397,7 +397,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
397
397
  import { TRACE_PROCESSOR } from "@dxos/tracing";
398
398
 
399
399
  // packages/sdk/client-services/src/version.ts
400
- var DXOS_VERSION = "0.7.5-main.9d26e3a";
400
+ var DXOS_VERSION = "0.7.5-main.e9bb01b";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -1451,6 +1451,7 @@ var NotarizationPlugin = class extends Resource3 {
1451
1451
  this._processedCredentials = new ComplexSet(PublicKey4.hash);
1452
1452
  this._processCredentialsTriggers = new ComplexMap3(PublicKey4.hash);
1453
1453
  this._activeEdgePollingIntervalHandle = void 0;
1454
+ this._activeEdgePollingEnabled = false;
1454
1455
  this._spaceId = params.spaceId;
1455
1456
  this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
1456
1457
  if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
@@ -1458,15 +1459,6 @@ var NotarizationPlugin = class extends Resource3 {
1458
1459
  }
1459
1460
  }
1460
1461
  setActiveEdgePollingEnabled(enabled) {
1461
- invariant4(this.isOpen, void 0, {
1462
- F: __dxlog_file8,
1463
- L: 109,
1464
- S: this,
1465
- A: [
1466
- "this.isOpen",
1467
- ""
1468
- ]
1469
- });
1470
1462
  const client = this._edgeClient;
1471
1463
  invariant4(client, void 0, {
1472
1464
  F: __dxlog_file8,
@@ -1477,30 +1469,30 @@ var NotarizationPlugin = class extends Resource3 {
1477
1469
  ""
1478
1470
  ]
1479
1471
  });
1480
- if (enabled && !this._activeEdgePollingIntervalHandle) {
1481
- this._activeEdgePollingIntervalHandle = setInterval(() => {
1482
- if (this._writer) {
1483
- this._notarizePendingEdgeCredentials(client, this._writer);
1484
- }
1485
- }, this._activeEdgePollingInterval);
1486
- } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1487
- clearInterval(this._activeEdgePollingIntervalHandle);
1488
- this._activeEdgePollingIntervalHandle = void 0;
1472
+ this._activeEdgePollingEnabled = enabled;
1473
+ if (this.isOpen) {
1474
+ if (enabled && !this._activeEdgePollingIntervalHandle) {
1475
+ this._startPeriodicEdgePolling(client);
1476
+ } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1477
+ this._stopPeriodicEdgePolling();
1478
+ }
1489
1479
  }
1490
1480
  }
1491
1481
  get hasWriter() {
1492
1482
  return !!this._writer;
1493
1483
  }
1494
1484
  async _open() {
1495
- if (this._edgeClient && this._writer) {
1496
- this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1485
+ if (this._edgeClient) {
1486
+ if (this._activeEdgePollingEnabled) {
1487
+ this._startPeriodicEdgePolling(this._edgeClient);
1488
+ }
1489
+ if (this._writer) {
1490
+ this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1491
+ }
1497
1492
  }
1498
1493
  }
1499
1494
  async _close() {
1500
- if (this._activeEdgePollingIntervalHandle) {
1501
- clearInterval(this._activeEdgePollingIntervalHandle);
1502
- this._activeEdgePollingIntervalHandle = void 0;
1503
- }
1495
+ this._stopPeriodicEdgePolling();
1504
1496
  await this._ctx.dispose();
1505
1497
  }
1506
1498
  /**
@@ -1678,10 +1670,23 @@ var NotarizationPlugin = class extends Resource3 {
1678
1670
  ]
1679
1671
  });
1680
1672
  this._writer = writer;
1681
- if (this._edgeClient) {
1673
+ if (this._edgeClient && this.isOpen) {
1682
1674
  this._notarizePendingEdgeCredentials(this._edgeClient, writer);
1683
1675
  }
1684
1676
  }
1677
+ _startPeriodicEdgePolling(client) {
1678
+ this._activeEdgePollingIntervalHandle = setInterval(() => {
1679
+ if (this._writer) {
1680
+ this._notarizePendingEdgeCredentials(client, this._writer);
1681
+ }
1682
+ }, this._activeEdgePollingInterval);
1683
+ }
1684
+ _stopPeriodicEdgePolling() {
1685
+ if (this._activeEdgePollingIntervalHandle) {
1686
+ clearInterval(this._activeEdgePollingIntervalHandle);
1687
+ this._activeEdgePollingIntervalHandle = void 0;
1688
+ }
1689
+ }
1685
1690
  /**
1686
1691
  * The method is used only for adding agent feeds to spaces.
1687
1692
  * When an agent is created we can admit them into all the existing spaces. In case the operation fails
@@ -1700,7 +1705,7 @@ var NotarizationPlugin = class extends Resource3 {
1700
1705
  if (!credentials.length) {
1701
1706
  log5("edge did not return credentials for notarization", void 0, {
1702
1707
  F: __dxlog_file8,
1703
- L: 296,
1708
+ L: 311,
1704
1709
  S: this,
1705
1710
  C: (f, a) => f(...a)
1706
1711
  });
@@ -1710,7 +1715,7 @@ var NotarizationPlugin = class extends Resource3 {
1710
1715
  count: credentials.length
1711
1716
  }, {
1712
1717
  F: __dxlog_file8,
1713
- L: 300,
1718
+ L: 315,
1714
1719
  S: this,
1715
1720
  C: (f, a) => f(...a)
1716
1721
  });
@@ -1723,7 +1728,7 @@ var NotarizationPlugin = class extends Resource3 {
1723
1728
  count: decodedCredentials.length
1724
1729
  }, {
1725
1730
  F: __dxlog_file8,
1726
- L: 309,
1731
+ L: 324,
1727
1732
  S: this,
1728
1733
  C: (f, a) => f(...a)
1729
1734
  });
@@ -1751,7 +1756,7 @@ var NotarizationPlugin = class extends Resource3 {
1751
1756
  for (const credential of credentials) {
1752
1757
  invariant4(credential.id, "Credential must have an id", {
1753
1758
  F: __dxlog_file8,
1754
- L: 335,
1759
+ L: 350,
1755
1760
  S: this,
1756
1761
  A: [
1757
1762
  "credential.id",
@@ -1775,7 +1780,7 @@ var NotarizationPlugin = class extends Resource3 {
1775
1780
  peer: extension.localPeerId
1776
1781
  }, {
1777
1782
  F: __dxlog_file8,
1778
- L: 350,
1783
+ L: 365,
1779
1784
  S: this,
1780
1785
  C: (f, a) => f(...a)
1781
1786
  });
@@ -1787,7 +1792,7 @@ var NotarizationPlugin = class extends Resource3 {
1787
1792
  peer: extension.localPeerId
1788
1793
  }, {
1789
1794
  F: __dxlog_file8,
1790
- L: 355,
1795
+ L: 370,
1791
1796
  S: this,
1792
1797
  C: (f, a) => f(...a)
1793
1798
  });
@@ -1804,7 +1809,7 @@ var NotarizationPlugin = class extends Resource3 {
1804
1809
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1805
1810
  }, {
1806
1811
  F: __dxlog_file8,
1807
- L: 367,
1812
+ L: 382,
1808
1813
  S: this,
1809
1814
  C: (f, a) => f(...a)
1810
1815
  });
@@ -1820,7 +1825,7 @@ var handleEdgeError = (error) => {
1820
1825
  if (!(error instanceof EdgeCallFailedError) || error.errorData) {
1821
1826
  log5.catch(error, void 0, {
1822
1827
  F: __dxlog_file8,
1823
- L: 381,
1828
+ L: 396,
1824
1829
  S: void 0,
1825
1830
  C: (f, a) => f(...a)
1826
1831
  });
@@ -1829,7 +1834,7 @@ var handleEdgeError = (error) => {
1829
1834
  reason: error.reason
1830
1835
  }, {
1831
1836
  F: __dxlog_file8,
1832
- L: 383,
1837
+ L: 398,
1833
1838
  S: void 0,
1834
1839
  C: (f, a) => f(...a)
1835
1840
  });
@@ -2643,7 +2648,7 @@ var DataSpaceManager = class extends Resource4 {
2643
2648
  guestKeypair: invitation.guestKey ? {
2644
2649
  publicKey: invitation.guestKey
2645
2650
  } : void 0,
2646
- lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
2651
+ lifetime: invitation.expiresOn ? (invitation.expiresOn.getTime() - Date.now()) / 1e3 : void 0,
2647
2652
  multiUse: invitation.multiUse,
2648
2653
  delegationCredentialId: credentialId,
2649
2654
  persistent: false
@@ -2670,7 +2675,7 @@ DataSpaceManager = _ts_decorate3([
2670
2675
 
2671
2676
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
2672
2677
  import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask3 } from "@dxos/async";
2673
- import { Stream as Stream7 } from "@dxos/codec-protobuf";
2678
+ import { Stream as Stream7 } from "@dxos/codec-protobuf/stream";
2674
2679
  import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2675
2680
  import { raise } from "@dxos/debug";
2676
2681
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
@@ -3756,7 +3761,7 @@ IdentityManager = _ts_decorate5([
3756
3761
 
3757
3762
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
3758
3763
  import { Trigger as Trigger4, sleep as sleep2 } from "@dxos/async";
3759
- import { Stream as Stream8 } from "@dxos/codec-protobuf";
3764
+ import { Stream as Stream8 } from "@dxos/codec-protobuf/stream";
3760
3765
  import { Resource as Resource5 } from "@dxos/context";
3761
3766
  import { createCredential as createCredential2, signPresentation } from "@dxos/credentials";
3762
3767
  import { invariant as invariant9 } from "@dxos/invariant";
@@ -4700,14 +4705,14 @@ var DeviceInvitationProtocol = class {
4700
4705
 
4701
4706
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
4702
4707
  import { scheduleTask as scheduleTask7, TimeoutError as TimeoutError2 } from "@dxos/async";
4703
- import { INVITATION_TIMEOUT } from "@dxos/client-protocol";
4708
+ import { INVITATION_TIMEOUT, getExpirationTime } from "@dxos/client-protocol";
4704
4709
  import { ContextDisposedError as ContextDisposedError3 } from "@dxos/context";
4705
4710
  import { createKeyPair, sign as sign2 } from "@dxos/crypto";
4706
4711
  import { invariant as invariant15 } from "@dxos/invariant";
4707
4712
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4708
4713
  import { log as log18 } from "@dxos/log";
4709
4714
  import { createTeleportProtocolFactory } from "@dxos/network-manager";
4710
- import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace7 } from "@dxos/protocols";
4715
+ import { InvalidInvitationError, InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace7 } from "@dxos/protocols";
4711
4716
  import { Invitation as Invitation7 } from "@dxos/protocols/proto/dxos/client/services";
4712
4717
  import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
4713
4718
  import { InvitationOptions as InvitationOptions4 } from "@dxos/protocols/proto/dxos/halo/invitations";
@@ -4730,6 +4735,12 @@ import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/ser
4730
4735
  var stateToString = (state) => {
4731
4736
  return Object.entries(Invitation3.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
4732
4737
  };
4738
+ var computeExpirationTime = (invitation) => {
4739
+ if (!invitation.lifetime) {
4740
+ return;
4741
+ }
4742
+ return new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime * 1e3);
4743
+ };
4733
4744
  var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
4734
4745
  let guard;
4735
4746
  return cancelWithContext3(ctx, (async () => {
@@ -5745,18 +5756,19 @@ var InvitationsHandler = class {
5745
5756
  });
5746
5757
  return extension;
5747
5758
  };
5748
- if (invitation.lifetime && invitation.created) {
5749
- if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
5759
+ const expiresOn = getExpirationTime(invitation);
5760
+ if (expiresOn) {
5761
+ if (expiresOn.getTime() < Date.now()) {
5750
5762
  log18.warn("invitation has already expired", void 0, {
5751
5763
  F: __dxlog_file22,
5752
- L: 193,
5764
+ L: 194,
5753
5765
  S: this,
5754
5766
  C: (f, a) => f(...a)
5755
5767
  });
5756
5768
  guardedState.set(null, Invitation7.State.EXPIRED);
5757
5769
  void ctx.dispose().catch((err) => log18.catch(err, void 0, {
5758
5770
  F: __dxlog_file22,
5759
- L: 195,
5771
+ L: 196,
5760
5772
  S: this,
5761
5773
  C: (f, a) => f(...a)
5762
5774
  }));
@@ -5767,7 +5779,7 @@ var InvitationsHandler = class {
5767
5779
  guardedState.set(null, Invitation7.State.EXPIRED);
5768
5780
  metrics.increment("dxos.invitation.expired");
5769
5781
  await ctx.dispose();
5770
- }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
5782
+ }, expiresOn.getTime() - Date.now());
5771
5783
  }
5772
5784
  let swarmConnection;
5773
5785
  scheduleTask7(ctx, async () => {
@@ -5783,7 +5795,7 @@ var InvitationsHandler = class {
5783
5795
  type: invitation.type
5784
5796
  }, {
5785
5797
  F: __dxlog_file22,
5786
- L: 226,
5798
+ L: 227,
5787
5799
  S: this,
5788
5800
  C: (f, a) => f(...a)
5789
5801
  });
@@ -5791,7 +5803,7 @@ var InvitationsHandler = class {
5791
5803
  if (deviceProfile) {
5792
5804
  invariant15(invitation.kind === Invitation7.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
5793
5805
  F: __dxlog_file22,
5794
- L: 235,
5806
+ L: 236,
5795
5807
  S: this,
5796
5808
  A: [
5797
5809
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -5809,7 +5821,7 @@ var InvitationsHandler = class {
5809
5821
  triedPeers: triedPeersIds.size
5810
5822
  }, {
5811
5823
  F: __dxlog_file22,
5812
- L: 243,
5824
+ L: 244,
5813
5825
  S: this,
5814
5826
  C: (f, a) => f(...a)
5815
5827
  });
@@ -5836,7 +5848,7 @@ var InvitationsHandler = class {
5836
5848
  currentState: guardedState.current.state
5837
5849
  }, {
5838
5850
  F: __dxlog_file22,
5839
- L: 271,
5851
+ L: 272,
5840
5852
  S: this,
5841
5853
  C: (f, a) => f(...a)
5842
5854
  });
@@ -5854,7 +5866,7 @@ var InvitationsHandler = class {
5854
5866
  id: traceId
5855
5867
  }), {
5856
5868
  F: __dxlog_file22,
5857
- L: 283,
5869
+ L: 284,
5858
5870
  S: this,
5859
5871
  C: (f, a) => f(...a)
5860
5872
  });
@@ -5866,7 +5878,7 @@ var InvitationsHandler = class {
5866
5878
  ...protocol.toJSON()
5867
5879
  }, {
5868
5880
  F: __dxlog_file22,
5869
- L: 294,
5881
+ L: 295,
5870
5882
  S: this,
5871
5883
  C: (f, a) => f(...a)
5872
5884
  });
@@ -5876,7 +5888,7 @@ var InvitationsHandler = class {
5876
5888
  ...protocol.toJSON()
5877
5889
  }, {
5878
5890
  F: __dxlog_file22,
5879
- L: 298,
5891
+ L: 299,
5880
5892
  S: this,
5881
5893
  C: (f, a) => f(...a)
5882
5894
  });
@@ -5890,7 +5902,7 @@ var InvitationsHandler = class {
5890
5902
  authMethod: introductionResponse.authMethod
5891
5903
  }, {
5892
5904
  F: __dxlog_file22,
5893
- L: 306,
5905
+ L: 307,
5894
5906
  S: this,
5895
5907
  C: (f, a) => f(...a)
5896
5908
  });
@@ -5912,7 +5924,7 @@ var InvitationsHandler = class {
5912
5924
  ...protocol.toJSON()
5913
5925
  }, {
5914
5926
  F: __dxlog_file22,
5915
- L: 336,
5927
+ L: 337,
5916
5928
  S: this,
5917
5929
  C: (f, a) => f(...a)
5918
5930
  });
@@ -5925,7 +5937,7 @@ var InvitationsHandler = class {
5925
5937
  ...protocol.toJSON()
5926
5938
  }, {
5927
5939
  F: __dxlog_file22,
5928
- L: 350,
5940
+ L: 351,
5929
5941
  S: this,
5930
5942
  C: (f, a) => f(...a)
5931
5943
  });
@@ -5938,7 +5950,7 @@ var InvitationsHandler = class {
5938
5950
  id: traceId
5939
5951
  }), {
5940
5952
  F: __dxlog_file22,
5941
- L: 359,
5953
+ L: 360,
5942
5954
  S: this,
5943
5955
  C: (f, a) => f(...a)
5944
5956
  });
@@ -5948,7 +5960,7 @@ var InvitationsHandler = class {
5948
5960
  ...protocol.toJSON()
5949
5961
  }, {
5950
5962
  F: __dxlog_file22,
5951
- L: 362,
5963
+ L: 363,
5952
5964
  S: this,
5953
5965
  C: (f, a) => f(...a)
5954
5966
  });
@@ -5956,7 +5968,7 @@ var InvitationsHandler = class {
5956
5968
  } else {
5957
5969
  log18.verbose("auth failed", err, {
5958
5970
  F: __dxlog_file22,
5959
- L: 365,
5971
+ L: 366,
5960
5972
  S: this,
5961
5973
  C: (f, a) => f(...a)
5962
5974
  });
@@ -5968,7 +5980,7 @@ var InvitationsHandler = class {
5968
5980
  error: err
5969
5981
  }), {
5970
5982
  F: __dxlog_file22,
5971
- L: 369,
5983
+ L: 370,
5972
5984
  S: this,
5973
5985
  C: (f, a) => f(...a)
5974
5986
  });
@@ -5984,7 +5996,7 @@ var InvitationsHandler = class {
5984
5996
  ...protocol.toJSON()
5985
5997
  }, {
5986
5998
  F: __dxlog_file22,
5987
- L: 378,
5999
+ L: 379,
5988
6000
  S: this,
5989
6001
  C: (f, a) => f(...a)
5990
6002
  });
@@ -5992,7 +6004,7 @@ var InvitationsHandler = class {
5992
6004
  } else {
5993
6005
  log18.verbose("auth failed", err, {
5994
6006
  F: __dxlog_file22,
5995
- L: 381,
6007
+ L: 382,
5996
6008
  S: this,
5997
6009
  C: (f, a) => f(...a)
5998
6010
  });
@@ -6009,7 +6021,7 @@ var InvitationsHandler = class {
6009
6021
  ...protocol.toJSON()
6010
6022
  }, {
6011
6023
  F: __dxlog_file22,
6012
- L: 393,
6024
+ L: 394,
6013
6025
  S: this,
6014
6026
  C: (f, a) => f(...a)
6015
6027
  });
@@ -6022,14 +6034,14 @@ var InvitationsHandler = class {
6022
6034
  });
6023
6035
  edgeInvitationHandler.handle(ctx, guardedState, protocol, deviceProfile);
6024
6036
  scheduleTask7(ctx, async () => {
6025
- const error = protocol.checkInvitation(invitation);
6037
+ const error = checkInvitation(protocol, invitation);
6026
6038
  if (error) {
6027
6039
  stream.error(error);
6028
6040
  await ctx.dispose();
6029
6041
  } else {
6030
6042
  invariant15(invitation.swarmKey, void 0, {
6031
6043
  F: __dxlog_file22,
6032
- L: 405,
6044
+ L: 406,
6033
6045
  S: this,
6034
6046
  A: [
6035
6047
  "invitation.swarmKey",
@@ -6073,7 +6085,7 @@ var InvitationsHandler = class {
6073
6085
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
6074
6086
  log18("guest waiting for authentication code...", void 0, {
6075
6087
  F: __dxlog_file22,
6076
- L: 457,
6088
+ L: 458,
6077
6089
  S: this,
6078
6090
  C: (f, a) => f(...a)
6079
6091
  });
@@ -6081,7 +6093,7 @@ var InvitationsHandler = class {
6081
6093
  const authCode = await authenticated.wait(options);
6082
6094
  log18("sending authentication request", void 0, {
6083
6095
  F: __dxlog_file22,
6084
- L: 461,
6096
+ L: 462,
6085
6097
  S: this,
6086
6098
  C: (f, a) => f(...a)
6087
6099
  });
@@ -6100,7 +6112,7 @@ var InvitationsHandler = class {
6100
6112
  attempt
6101
6113
  }, {
6102
6114
  F: __dxlog_file22,
6103
- L: 472,
6115
+ L: 473,
6104
6116
  S: this,
6105
6117
  C: (f, a) => f(...a)
6106
6118
  });
@@ -6118,7 +6130,7 @@ var InvitationsHandler = class {
6118
6130
  }
6119
6131
  log18("sending authentication request", void 0, {
6120
6132
  F: __dxlog_file22,
6121
- L: 491,
6133
+ L: 492,
6122
6134
  S: this,
6123
6135
  C: (f, a) => f(...a)
6124
6136
  });
@@ -6131,6 +6143,13 @@ var InvitationsHandler = class {
6131
6143
  }
6132
6144
  }
6133
6145
  };
6146
+ var checkInvitation = (protocol, invitation) => {
6147
+ const expiresOn = getExpirationTime(invitation);
6148
+ if (expiresOn && expiresOn.getTime() < Date.now()) {
6149
+ return new InvalidInvitationError("Invitation already expired.");
6150
+ }
6151
+ return protocol.checkInvitation(invitation);
6152
+ };
6134
6153
  var createAdmissionKeypair = () => {
6135
6154
  const keypair = createKeyPair();
6136
6155
  return {
@@ -6140,7 +6159,7 @@ var createAdmissionKeypair = () => {
6140
6159
  };
6141
6160
 
6142
6161
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
6143
- import { Stream as Stream9 } from "@dxos/codec-protobuf";
6162
+ import { Stream as Stream9 } from "@dxos/codec-protobuf/stream";
6144
6163
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
6145
6164
  import { trace as trace8 } from "@dxos/tracing";
6146
6165
  var InvitationsServiceImpl = class {
@@ -6245,7 +6264,7 @@ import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInv
6245
6264
  import { writeMessages as writeMessages4 } from "@dxos/feed-store";
6246
6265
  import { invariant as invariant16 } from "@dxos/invariant";
6247
6266
  import { log as log19 } from "@dxos/log";
6248
- import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
6267
+ import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError as InvalidInvitationError2, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
6249
6268
  import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
6250
6269
  import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
6251
6270
  var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
@@ -6265,7 +6284,7 @@ var SpaceInvitationProtocol = class {
6265
6284
  }
6266
6285
  checkCanInviteNewMembers() {
6267
6286
  if (this._spaceKey == null) {
6268
- return new InvalidInvitationError("No spaceKey was provided for a space invitation.");
6287
+ return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
6269
6288
  }
6270
6289
  const space = this._spaceManager.spaces.get(this._spaceKey);
6271
6290
  if (space == null) {
@@ -6279,7 +6298,7 @@ var SpaceInvitationProtocol = class {
6279
6298
  getInvitationContext() {
6280
6299
  invariant16(this._spaceKey, void 0, {
6281
6300
  F: __dxlog_file23,
6282
- L: 64,
6301
+ L: 65,
6283
6302
  S: this,
6284
6303
  A: [
6285
6304
  "this._spaceKey",
@@ -6289,7 +6308,7 @@ var SpaceInvitationProtocol = class {
6289
6308
  const space = this._spaceManager.spaces.get(this._spaceKey);
6290
6309
  invariant16(space, void 0, {
6291
6310
  F: __dxlog_file23,
6292
- L: 66,
6311
+ L: 67,
6293
6312
  S: this,
6294
6313
  A: [
6295
6314
  "space",
@@ -6305,7 +6324,7 @@ var SpaceInvitationProtocol = class {
6305
6324
  async admit(invitation, request, guestProfile) {
6306
6325
  invariant16(this._spaceKey && request.space, void 0, {
6307
6326
  F: __dxlog_file23,
6308
- L: 79,
6327
+ L: 80,
6309
6328
  S: this,
6310
6329
  A: [
6311
6330
  "this._spaceKey && request.space",
@@ -6317,7 +6336,7 @@ var SpaceInvitationProtocol = class {
6317
6336
  guest: request.space.deviceKey
6318
6337
  }, {
6319
6338
  F: __dxlog_file23,
6320
- L: 80,
6339
+ L: 81,
6321
6340
  S: this,
6322
6341
  C: (f, a) => f(...a)
6323
6342
  });
@@ -6339,7 +6358,7 @@ var SpaceInvitationProtocol = class {
6339
6358
  async delegate(invitation) {
6340
6359
  invariant16(this._spaceKey, void 0, {
6341
6360
  F: __dxlog_file23,
6342
- L: 100,
6361
+ L: 101,
6343
6362
  S: this,
6344
6363
  A: [
6345
6364
  "this._spaceKey",
@@ -6349,7 +6368,7 @@ var SpaceInvitationProtocol = class {
6349
6368
  const space = this._spaceManager.spaces.get(this._spaceKey);
6350
6369
  invariant16(space, void 0, {
6351
6370
  F: __dxlog_file23,
6352
- L: 102,
6371
+ L: 103,
6353
6372
  S: this,
6354
6373
  A: [
6355
6374
  "space",
@@ -6359,7 +6378,7 @@ var SpaceInvitationProtocol = class {
6359
6378
  if (invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY) {
6360
6379
  invariant16(invitation.guestKeypair?.publicKey, void 0, {
6361
6380
  F: __dxlog_file23,
6362
- L: 104,
6381
+ L: 105,
6363
6382
  S: this,
6364
6383
  A: [
6365
6384
  "invitation.guestKeypair?.publicKey",
@@ -6372,7 +6391,7 @@ var SpaceInvitationProtocol = class {
6372
6391
  id: invitation.invitationId
6373
6392
  }, {
6374
6393
  F: __dxlog_file23,
6375
- L: 107,
6394
+ L: 108,
6376
6395
  S: this,
6377
6396
  C: (f, a) => f(...a)
6378
6397
  });
@@ -6381,13 +6400,13 @@ var SpaceInvitationProtocol = class {
6381
6400
  authMethod: invitation.authMethod,
6382
6401
  swarmKey: invitation.swarmKey,
6383
6402
  role: invitation.role ?? SpaceMember6.Role.ADMIN,
6384
- expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
6403
+ expiresOn: computeExpirationTime(invitation),
6385
6404
  multiUse: invitation.multiUse ?? false,
6386
6405
  guestKey: invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
6387
6406
  });
6388
6407
  invariant16(credential.credential, void 0, {
6389
6408
  F: __dxlog_file23,
6390
- L: 127,
6409
+ L: 126,
6391
6410
  S: this,
6392
6411
  A: [
6393
6412
  "credential.credential",
@@ -6402,7 +6421,7 @@ var SpaceInvitationProtocol = class {
6402
6421
  async cancelDelegation(invitation) {
6403
6422
  invariant16(this._spaceKey, void 0, {
6404
6423
  F: __dxlog_file23,
6405
- L: 133,
6424
+ L: 132,
6406
6425
  S: this,
6407
6426
  A: [
6408
6427
  "this._spaceKey",
@@ -6411,7 +6430,7 @@ var SpaceInvitationProtocol = class {
6411
6430
  });
6412
6431
  invariant16(invitation.type === Invitation8.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6413
6432
  F: __dxlog_file23,
6414
- L: 134,
6433
+ L: 133,
6415
6434
  S: this,
6416
6435
  A: [
6417
6436
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -6421,7 +6440,7 @@ var SpaceInvitationProtocol = class {
6421
6440
  const space = this._spaceManager.spaces.get(this._spaceKey);
6422
6441
  invariant16(space, void 0, {
6423
6442
  F: __dxlog_file23,
6424
- L: 136,
6443
+ L: 135,
6425
6444
  S: this,
6426
6445
  A: [
6427
6446
  "space",
@@ -6433,14 +6452,14 @@ var SpaceInvitationProtocol = class {
6433
6452
  id: invitation.invitationId
6434
6453
  }, {
6435
6454
  F: __dxlog_file23,
6436
- L: 138,
6455
+ L: 137,
6437
6456
  S: this,
6438
6457
  C: (f, a) => f(...a)
6439
6458
  });
6440
6459
  const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
6441
6460
  invariant16(credential.credential, void 0, {
6442
6461
  F: __dxlog_file23,
6443
- L: 145,
6462
+ L: 144,
6444
6463
  S: this,
6445
6464
  A: [
6446
6465
  "credential.credential",
@@ -6453,7 +6472,7 @@ var SpaceInvitationProtocol = class {
6453
6472
  }
6454
6473
  checkInvitation(invitation) {
6455
6474
  if (invitation.spaceKey == null) {
6456
- return new InvalidInvitationError("No spaceKey was provided for a space invitation.");
6475
+ return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
6457
6476
  }
6458
6477
  if (this._spaceManager.spaces.has(invitation.spaceKey)) {
6459
6478
  return new AlreadyJoinedError3("Already joined space.");
@@ -6479,7 +6498,7 @@ var SpaceInvitationProtocol = class {
6479
6498
  async accept(response) {
6480
6499
  invariant16(response.space, void 0, {
6481
6500
  F: __dxlog_file23,
6482
- L: 180,
6501
+ L: 179,
6483
6502
  S: this,
6484
6503
  A: [
6485
6504
  "response.space",
@@ -6490,7 +6509,7 @@ var SpaceInvitationProtocol = class {
6490
6509
  const assertion = getCredentialAssertion5(credential);
6491
6510
  invariant16(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
6492
6511
  F: __dxlog_file23,
6493
- L: 183,
6512
+ L: 182,
6494
6513
  S: this,
6495
6514
  A: [
6496
6515
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -6499,7 +6518,7 @@ var SpaceInvitationProtocol = class {
6499
6518
  });
6500
6519
  invariant16(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
6501
6520
  F: __dxlog_file23,
6502
- L: 184,
6521
+ L: 183,
6503
6522
  S: this,
6504
6523
  A: [
6505
6524
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -6735,7 +6754,7 @@ var InvitationsManager = class {
6735
6754
  }
6736
6755
  }
6737
6756
  _createInvitation(protocol, _options) {
6738
- const { invitationId = PublicKey12.random().toHex(), type = Invitation9.Type.INTERACTIVE, authMethod = Invitation9.AuthMethod.SHARED_SECRET, state = Invitation9.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey12.random(), persistent = _options?.authMethod !== Invitation9.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = SpaceMember7.Role.ADMIN, lifetime = 86400, multiUse = false, ...options } = _options ?? {};
6757
+ const { invitationId = PublicKey12.random().toHex(), type = Invitation9.Type.INTERACTIVE, authMethod = Invitation9.AuthMethod.SHARED_SECRET, state = Invitation9.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey12.random(), persistent = _options?.authMethod !== Invitation9.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = SpaceMember7.Role.ADMIN, lifetime = 86400 * 7, multiUse = false, ...options } = _options ?? {};
6739
6758
  const authCode = options?.authCode ?? (authMethod === Invitation9.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
6740
6759
  return {
6741
6760
  invitationId,
@@ -7322,7 +7341,7 @@ _ts_decorate9([
7322
7341
  ], EdgeAgentManager.prototype, "createAgent", null);
7323
7342
 
7324
7343
  // packages/sdk/client-services/src/packlets/agents/edge-agent-service.ts
7325
- import { Stream as Stream11 } from "@dxos/codec-protobuf";
7344
+ import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
7326
7345
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7327
7346
  import { QueryAgentStatusResponse, QueryEdgeStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
7328
7347
  var EdgeAgentServiceImpl = class {
@@ -7630,7 +7649,8 @@ var ServiceContext = class extends Resource7 {
7630
7649
  this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
7631
7650
  this.echoHost = new EchoHost({
7632
7651
  kv: this.level,
7633
- peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex()
7652
+ peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
7653
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key
7634
7654
  });
7635
7655
  this._meshReplicator = new MeshEchoReplicator();
7636
7656
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
@@ -7649,7 +7669,7 @@ var ServiceContext = class extends Resource7 {
7649
7669
  await this._checkStorageVersion();
7650
7670
  log24("opening...", void 0, {
7651
7671
  F: __dxlog_file28,
7652
- L: 198,
7672
+ L: 199,
7653
7673
  S: this,
7654
7674
  C: (f, a) => f(...a)
7655
7675
  });
@@ -7657,7 +7677,7 @@ var ServiceContext = class extends Resource7 {
7657
7677
  id: this._instanceId
7658
7678
  }), {
7659
7679
  F: __dxlog_file28,
7660
- L: 199,
7680
+ L: 200,
7661
7681
  S: this,
7662
7682
  C: (f, a) => f(...a)
7663
7683
  });
@@ -7684,7 +7704,7 @@ var ServiceContext = class extends Resource7 {
7684
7704
  count: loadedInvitations.invitations?.length
7685
7705
  }, {
7686
7706
  F: __dxlog_file28,
7687
- L: 227,
7707
+ L: 228,
7688
7708
  S: this,
7689
7709
  C: (f, a) => f(...a)
7690
7710
  });
@@ -7692,13 +7712,13 @@ var ServiceContext = class extends Resource7 {
7692
7712
  id: this._instanceId
7693
7713
  }), {
7694
7714
  F: __dxlog_file28,
7695
- L: 229,
7715
+ L: 230,
7696
7716
  S: this,
7697
7717
  C: (f, a) => f(...a)
7698
7718
  });
7699
7719
  log24("opened", void 0, {
7700
7720
  F: __dxlog_file28,
7701
- L: 230,
7721
+ L: 231,
7702
7722
  S: this,
7703
7723
  C: (f, a) => f(...a)
7704
7724
  });
@@ -7706,7 +7726,7 @@ var ServiceContext = class extends Resource7 {
7706
7726
  async _close(ctx) {
7707
7727
  log24("closing...", void 0, {
7708
7728
  F: __dxlog_file28,
7709
- L: 234,
7729
+ L: 235,
7710
7730
  S: this,
7711
7731
  C: (f, a) => f(...a)
7712
7732
  });
@@ -7725,7 +7745,7 @@ var ServiceContext = class extends Resource7 {
7725
7745
  await this._edgeConnection?.close();
7726
7746
  log24("closed", void 0, {
7727
7747
  F: __dxlog_file28,
7728
- L: 250,
7748
+ L: 251,
7729
7749
  S: this,
7730
7750
  C: (f, a) => f(...a)
7731
7751
  });
@@ -7736,7 +7756,7 @@ var ServiceContext = class extends Resource7 {
7736
7756
  await identity.joinNetwork();
7737
7757
  await this._initialize(new Context9(void 0, {
7738
7758
  F: __dxlog_file28,
7739
- L: 257
7759
+ L: 258
7740
7760
  }));
7741
7761
  return identity;
7742
7762
  }
@@ -7747,7 +7767,7 @@ var ServiceContext = class extends Resource7 {
7747
7767
  const factory = this._handlerFactories.get(invitation.kind);
7748
7768
  invariant20(factory, `Unknown invitation kind: ${invitation.kind}`, {
7749
7769
  F: __dxlog_file28,
7750
- L: 266,
7770
+ L: 267,
7751
7771
  S: this,
7752
7772
  A: [
7753
7773
  "factory",
@@ -7773,7 +7793,7 @@ var ServiceContext = class extends Resource7 {
7773
7793
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
7774
7794
  await this._initialize(new Context9(void 0, {
7775
7795
  F: __dxlog_file28,
7776
- L: 285
7796
+ L: 286
7777
7797
  }));
7778
7798
  return identity;
7779
7799
  }
@@ -7787,7 +7807,7 @@ var ServiceContext = class extends Resource7 {
7787
7807
  async _initialize(ctx) {
7788
7808
  log24("initializing spaces...", void 0, {
7789
7809
  F: __dxlog_file28,
7790
- L: 300,
7810
+ L: 301,
7791
7811
  S: this,
7792
7812
  C: (f, a) => f(...a)
7793
7813
  });
@@ -7826,7 +7846,7 @@ var ServiceContext = class extends Resource7 {
7826
7846
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
7827
7847
  invariant20(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7828
7848
  F: __dxlog_file28,
7829
- L: 338,
7849
+ L: 339,
7830
7850
  S: this,
7831
7851
  A: [
7832
7852
  "this.dataSpaceManager",
@@ -7850,7 +7870,7 @@ var ServiceContext = class extends Resource7 {
7850
7870
  details: assertion
7851
7871
  }, {
7852
7872
  F: __dxlog_file28,
7853
- L: 354,
7873
+ L: 355,
7854
7874
  S: this,
7855
7875
  C: (f, a) => f(...a)
7856
7876
  });
@@ -7861,7 +7881,7 @@ var ServiceContext = class extends Resource7 {
7861
7881
  details: assertion
7862
7882
  }, {
7863
7883
  F: __dxlog_file28,
7864
- L: 358,
7884
+ L: 359,
7865
7885
  S: this,
7866
7886
  C: (f, a) => f(...a)
7867
7887
  });
@@ -7872,7 +7892,7 @@ var ServiceContext = class extends Resource7 {
7872
7892
  details: assertion
7873
7893
  }, {
7874
7894
  F: __dxlog_file28,
7875
- L: 363,
7895
+ L: 364,
7876
7896
  S: this,
7877
7897
  C: (f, a) => f(...a)
7878
7898
  });
@@ -7883,7 +7903,7 @@ var ServiceContext = class extends Resource7 {
7883
7903
  } catch (err) {
7884
7904
  log24.catch(err, void 0, {
7885
7905
  F: __dxlog_file28,
7886
- L: 369,
7906
+ L: 370,
7887
7907
  S: this,
7888
7908
  C: (f, a) => f(...a)
7889
7909
  });
@@ -7904,7 +7924,7 @@ var ServiceContext = class extends Resource7 {
7904
7924
  swarms: this.networkManager.topics
7905
7925
  }, {
7906
7926
  F: __dxlog_file28,
7907
- L: 383,
7927
+ L: 384,
7908
7928
  S: this,
7909
7929
  C: (f, a) => f(...a)
7910
7930
  });
@@ -7918,7 +7938,7 @@ var ServiceContext = class extends Resource7 {
7918
7938
  });
7919
7939
  invariant20(identity.deviceCredentialChain, void 0, {
7920
7940
  F: __dxlog_file28,
7921
- L: 402,
7941
+ L: 403,
7922
7942
  S: this,
7923
7943
  A: [
7924
7944
  "identity.deviceCredentialChain",
@@ -8228,7 +8248,7 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
8228
8248
 
8229
8249
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
8230
8250
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
8231
- import { Stream as Stream12 } from "@dxos/codec-protobuf";
8251
+ import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8232
8252
  import { invariant as invariant22 } from "@dxos/invariant";
8233
8253
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
8234
8254
  var __dxlog_file30 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
@@ -8318,7 +8338,7 @@ var DevicesServiceImpl = class {
8318
8338
 
8319
8339
  // packages/sdk/client-services/src/packlets/identity/contacts-service.ts
8320
8340
  import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask9, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
8321
- import { Stream as Stream13 } from "@dxos/codec-protobuf";
8341
+ import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
8322
8342
  import { PublicKey as PublicKey17 } from "@dxos/keys";
8323
8343
  import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
8324
8344
  var ContactsServiceImpl = class {
@@ -8401,7 +8421,7 @@ var ContactsServiceImpl = class {
8401
8421
 
8402
8422
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
8403
8423
  import { Event as Event10 } from "@dxos/async";
8404
- import { Stream as Stream14 } from "@dxos/codec-protobuf";
8424
+ import { Stream as Stream14 } from "@dxos/codec-protobuf/stream";
8405
8425
  import { PublicKey as PublicKey18 } from "@dxos/keys";
8406
8426
  import { getContextFromEntry, log as log26 } from "@dxos/log";
8407
8427
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
@@ -8524,7 +8544,7 @@ var shouldLog = (entry2, request) => {
8524
8544
  var LOG_PROCESSING = 0;
8525
8545
 
8526
8546
  // packages/sdk/client-services/src/packlets/network/network-service.ts
8527
- import { Stream as Stream15 } from "@dxos/codec-protobuf";
8547
+ import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
8528
8548
  var NetworkServiceImpl = class {
8529
8549
  constructor(networkManager, signalManager) {
8530
8550
  this.networkManager = networkManager;
@@ -8554,10 +8574,39 @@ var NetworkServiceImpl = class {
8554
8574
  async updateConfig(request) {
8555
8575
  await this.networkManager.setConnectionState(request.swarm);
8556
8576
  }
8577
+ async joinSwarm(request) {
8578
+ return this.signalManager.join(request);
8579
+ }
8580
+ async leaveSwarm(request) {
8581
+ return this.signalManager.leave(request);
8582
+ }
8583
+ subscribeSwarmState(request) {
8584
+ return new Stream15(({ next }) => {
8585
+ const unsubscribe = this.signalManager.swarmState?.on((state) => {
8586
+ if (request.topic.equals(state.swarmKey)) {
8587
+ next(state);
8588
+ }
8589
+ });
8590
+ return unsubscribe;
8591
+ });
8592
+ }
8593
+ async sendMessage(message) {
8594
+ return this.signalManager.sendMessage(message);
8595
+ }
8596
+ subscribeMessages(peer) {
8597
+ return new Stream15(({ next }) => {
8598
+ const unsubscribe = this.signalManager.onMessage.on((message) => {
8599
+ if (message.recipient.peerKey === peer.peerKey) {
8600
+ next(message);
8601
+ }
8602
+ });
8603
+ return unsubscribe;
8604
+ });
8605
+ }
8557
8606
  };
8558
8607
 
8559
8608
  // packages/sdk/client-services/src/packlets/system/system-service.ts
8560
- import { Stream as Stream16 } from "@dxos/codec-protobuf";
8609
+ import { Stream as Stream16 } from "@dxos/codec-protobuf/stream";
8561
8610
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
8562
8611
  import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
8563
8612
  var SystemServiceImpl = class {
@@ -9061,4 +9110,4 @@ export {
9061
9110
  importProfileData,
9062
9111
  ClientServicesHost
9063
9112
  };
9064
- //# sourceMappingURL=chunk-27A4ATQX.mjs.map
9113
+ //# sourceMappingURL=chunk-O46EJ5BJ.mjs.map