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

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 (101) hide show
  1. package/dist/lib/browser/{chunk-27A4ATQX.mjs → chunk-Z6PWUKRZ.mjs} +364 -248
  2. package/dist/lib/browser/chunk-Z6PWUKRZ.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-PK4NC3T7.cjs} +389 -273
  7. package/dist/lib/node/chunk-PK4NC3T7.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-2FL5LYPQ.mjs} +364 -248
  12. package/dist/lib/node-esm/chunk-2FL5LYPQ.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-manager.d.ts.map +1 -1
  17. package/dist/types/src/packlets/agents/edge-agent-service.d.ts +1 -1
  18. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  19. package/dist/types/src/packlets/devices/devices-service.d.ts +1 -1
  20. package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
  21. package/dist/types/src/packlets/devtools/devtools.d.ts +1 -1
  22. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  23. package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
  24. package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
  25. package/dist/types/src/packlets/devtools/keys.d.ts +1 -1
  26. package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
  27. package/dist/types/src/packlets/devtools/metadata.d.ts +1 -1
  28. package/dist/types/src/packlets/devtools/metadata.d.ts.map +1 -1
  29. package/dist/types/src/packlets/devtools/network.d.ts +1 -1
  30. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  31. package/dist/types/src/packlets/devtools/spaces.d.ts +1 -1
  32. package/dist/types/src/packlets/devtools/spaces.d.ts.map +1 -1
  33. package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -1
  34. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
  35. package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
  36. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
  37. package/dist/types/src/packlets/identity/identity-manager.d.ts +0 -3
  38. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  39. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +12 -4
  40. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  41. package/dist/types/src/packlets/identity/identity-service.d.ts +9 -4
  42. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  43. package/dist/types/src/packlets/identity/identity.d.ts +3 -1
  44. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  45. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  46. package/dist/types/src/packlets/invitations/invitations-service.d.ts +1 -1
  47. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  48. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  49. package/dist/types/src/packlets/invitations/utils.d.ts +1 -0
  50. package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
  51. package/dist/types/src/packlets/logging/logging-service.d.ts +1 -1
  52. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  53. package/dist/types/src/packlets/network/network-service.d.ts +9 -2
  54. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  55. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  56. package/dist/types/src/packlets/services/service-host.d.ts +1 -1
  57. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  58. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +3 -0
  59. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  60. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  61. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  62. package/dist/types/src/packlets/system/system-service.d.ts +1 -1
  63. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  64. package/dist/types/src/version.d.ts +1 -1
  65. package/dist/types/tsconfig.tsbuildinfo +1 -1
  66. package/package.json +39 -38
  67. package/src/packlets/agents/edge-agent-manager.ts +6 -0
  68. package/src/packlets/agents/edge-agent-service.ts +1 -1
  69. package/src/packlets/devices/devices-service.ts +1 -1
  70. package/src/packlets/devtools/devtools.ts +1 -1
  71. package/src/packlets/devtools/feeds.ts +1 -1
  72. package/src/packlets/devtools/keys.ts +1 -1
  73. package/src/packlets/devtools/metadata.ts +1 -1
  74. package/src/packlets/devtools/network.ts +1 -1
  75. package/src/packlets/devtools/spaces.ts +1 -1
  76. package/src/packlets/diagnostics/diagnostics-collector.ts +2 -2
  77. package/src/packlets/diagnostics/diagnostics.ts +17 -13
  78. package/src/packlets/identity/contacts-service.ts +1 -1
  79. package/src/packlets/identity/identity-manager.ts +3 -29
  80. package/src/packlets/identity/identity-recovery-manager.ts +86 -9
  81. package/src/packlets/identity/identity-service.ts +17 -4
  82. package/src/packlets/identity/identity.test.ts +2 -1
  83. package/src/packlets/identity/identity.ts +4 -1
  84. package/src/packlets/invitations/invitations-handler.ts +15 -6
  85. package/src/packlets/invitations/invitations-manager.ts +1 -1
  86. package/src/packlets/invitations/invitations-service.ts +1 -1
  87. package/src/packlets/invitations/space-invitation-protocol.ts +2 -3
  88. package/src/packlets/invitations/utils.ts +7 -0
  89. package/src/packlets/logging/logging-service.ts +1 -1
  90. package/src/packlets/network/network-service.ts +39 -1
  91. package/src/packlets/services/service-context.ts +1 -0
  92. package/src/packlets/spaces/data-space-manager.ts +3 -3
  93. package/src/packlets/spaces/data-space.ts +2 -2
  94. package/src/packlets/spaces/edge-feed-replicator.ts +8 -8
  95. package/src/packlets/spaces/notarization-plugin.ts +32 -17
  96. package/src/packlets/spaces/spaces-service.ts +31 -21
  97. package/src/packlets/system/system-service.ts +1 -1
  98. package/src/version.ts +1 -1
  99. package/dist/lib/browser/chunk-27A4ATQX.mjs.map +0 -7
  100. package/dist/lib/node/chunk-7FKXMJDD.cjs.map +0 -7
  101. package/dist/lib/node-esm/chunk-HGN7FHFK.mjs.map +0 -7
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module';const require = createRequire(import
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
@@ -390,14 +390,14 @@ var DevtoolsServiceImpl = class {
390
390
  // packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
391
391
  import { asyncTimeout } from "@dxos/async";
392
392
  import { getFirstStreamValue } from "@dxos/codec-protobuf";
393
- import { credentialTypeFilter } from "@dxos/credentials";
393
+ import { createDidFromIdentityKey, credentialTypeFilter } from "@dxos/credentials";
394
394
  import { invariant } from "@dxos/invariant";
395
395
  import { STORAGE_VERSION } from "@dxos/protocols";
396
396
  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.b19bfc8";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -466,6 +466,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
466
466
  const identity = serviceContext.identityManager.identity;
467
467
  if (identity) {
468
468
  diagnostics.identity = {
469
+ did: identity.did,
469
470
  identityKey: identity.identityKey,
470
471
  spaceKey: identity.space.key,
471
472
  profile: identity.profileDocument
@@ -504,16 +505,17 @@ var getSpaceStats = async (space) => {
504
505
  ...credential.subject.assertion,
505
506
  id: credential.id
506
507
  })),
507
- members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
508
+ members: await Promise.all(Array.from(space.inner.spaceState.members.values()).map(async (member) => ({
508
509
  role: member.role,
509
510
  identity: {
511
+ did: await createDidFromIdentityKey(member.key),
510
512
  identityKey: member.key,
511
513
  profile: {
512
514
  displayName: member.assertion.profile?.displayName
513
515
  }
514
516
  },
515
517
  presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
516
- })),
518
+ }))),
517
519
  pipeline: {
518
520
  // TODO(burdon): Pick properties from credentials if needed.
519
521
  currentEpoch: space.automergeSpaceState.lastEpoch,
@@ -569,7 +571,7 @@ import { ClientServicesProviderResource } from "@dxos/client-protocol";
569
571
  import { ConfigResource } from "@dxos/config";
570
572
  import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
571
573
  import { TRACE_PROCESSOR as TRACE_PROCESSOR2 } from "@dxos/tracing";
572
- import { jsonKeyReplacer, nonNullable } from "@dxos/util";
574
+ import { jsonKeyReplacer, isNonNullable } from "@dxos/util";
573
575
  var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
574
576
  var DiagnosticsCollector = class {
575
577
  static {
@@ -602,7 +604,7 @@ var findSystemServiceProvider = () => {
602
604
  };
603
605
  var findConfigs = () => {
604
606
  const configs = TRACE_PROCESSOR2.findResourcesByAnnotation(ConfigResource);
605
- return configs.map((r) => r.instance.deref()).filter(nonNullable);
607
+ return configs.map((r) => r.instance.deref()).filter(isNonNullable);
606
608
  };
607
609
 
608
610
  // packages/sdk/client-services/src/packlets/identity/authenticator.ts
@@ -913,7 +915,7 @@ var EdgeFeedReplicator = class extends Resource {
913
915
  this._remoteLength.clear();
914
916
  }
915
917
  async addFeed(feed) {
916
- log3.info("addFeed", {
918
+ log3("addFeed", {
917
919
  key: feed.key,
918
920
  connected: this._connected,
919
921
  hasConnectionCtx: !!this._connectionCtx
@@ -950,7 +952,7 @@ var EdgeFeedReplicator = class extends Resource {
950
952
  }
951
953
  async _sendMessage(message) {
952
954
  if (!this._connectionCtx) {
953
- log3.info("message dropped because connection was disposed", void 0, {
955
+ log3("message dropped because connection was disposed", void 0, {
954
956
  F: __dxlog_file5,
955
957
  L: 146,
956
958
  S: this,
@@ -959,7 +961,7 @@ var EdgeFeedReplicator = class extends Resource {
959
961
  return;
960
962
  }
961
963
  if (message.type === "data") {
962
- log3.info("sending blocks", {
964
+ log3("sending blocks", {
963
965
  feedKey: message.feedKey,
964
966
  blocks: message.blocks.map((b) => b.index)
965
967
  }, {
@@ -1034,7 +1036,7 @@ var EdgeFeedReplicator = class extends Resource {
1034
1036
  feedKey
1035
1037
  };
1036
1038
  if (message.length > feed.length) {
1037
- log3.info("requesting missing blocks", logMeta, {
1039
+ log3("requesting missing blocks", logMeta, {
1038
1040
  F: __dxlog_file5,
1039
1041
  L: 194,
1040
1042
  S: this,
@@ -1049,7 +1051,7 @@ var EdgeFeedReplicator = class extends Resource {
1049
1051
  }
1050
1052
  });
1051
1053
  } else if (message.length < feed.length) {
1052
- log3.info("pushing blocks to remote", logMeta, {
1054
+ log3("pushing blocks to remote", logMeta, {
1053
1055
  F: __dxlog_file5,
1054
1056
  L: 202,
1055
1057
  S: this,
@@ -1065,7 +1067,7 @@ var EdgeFeedReplicator = class extends Resource {
1065
1067
  }
1066
1068
  }
1067
1069
  case "data": {
1068
- log3.info("received data", {
1070
+ log3("received data", {
1069
1071
  feed: message.feedKey,
1070
1072
  blocks: message.blocks.map((b) => b.index)
1071
1073
  }, {
@@ -1104,7 +1106,7 @@ var EdgeFeedReplicator = class extends Resource {
1104
1106
  });
1105
1107
  }
1106
1108
  async _pushBlocks(feed, from, to) {
1107
- log3.info("pushing blocks", {
1109
+ log3("pushing blocks", {
1108
1110
  feed: feed.key.toHex(),
1109
1111
  from,
1110
1112
  to
@@ -1143,7 +1145,7 @@ var EdgeFeedReplicator = class extends Resource {
1143
1145
  this._remoteLength.set(feed.key, to);
1144
1146
  }
1145
1147
  async _integrateBlocks(feed, blocks) {
1146
- log3.info("integrating blocks", {
1148
+ log3("integrating blocks", {
1147
1149
  feed: feed.key.toHex(),
1148
1150
  blocks: blocks.length
1149
1151
  }, {
@@ -1373,6 +1375,7 @@ var NotarizationPlugin = class extends Resource3 {
1373
1375
  this._processedCredentials = new ComplexSet(PublicKey4.hash);
1374
1376
  this._processCredentialsTriggers = new ComplexMap3(PublicKey4.hash);
1375
1377
  this._activeEdgePollingIntervalHandle = void 0;
1378
+ this._activeEdgePollingEnabled = false;
1376
1379
  this._spaceId = params.spaceId;
1377
1380
  this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
1378
1381
  if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
@@ -1380,15 +1383,6 @@ var NotarizationPlugin = class extends Resource3 {
1380
1383
  }
1381
1384
  }
1382
1385
  setActiveEdgePollingEnabled(enabled) {
1383
- invariant4(this.isOpen, void 0, {
1384
- F: __dxlog_file7,
1385
- L: 109,
1386
- S: this,
1387
- A: [
1388
- "this.isOpen",
1389
- ""
1390
- ]
1391
- });
1392
1386
  const client = this._edgeClient;
1393
1387
  invariant4(client, void 0, {
1394
1388
  F: __dxlog_file7,
@@ -1399,30 +1393,30 @@ var NotarizationPlugin = class extends Resource3 {
1399
1393
  ""
1400
1394
  ]
1401
1395
  });
1402
- if (enabled && !this._activeEdgePollingIntervalHandle) {
1403
- this._activeEdgePollingIntervalHandle = setInterval(() => {
1404
- if (this._writer) {
1405
- this._notarizePendingEdgeCredentials(client, this._writer);
1406
- }
1407
- }, this._activeEdgePollingInterval);
1408
- } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1409
- clearInterval(this._activeEdgePollingIntervalHandle);
1410
- this._activeEdgePollingIntervalHandle = void 0;
1396
+ this._activeEdgePollingEnabled = enabled;
1397
+ if (this.isOpen) {
1398
+ if (enabled && !this._activeEdgePollingIntervalHandle) {
1399
+ this._startPeriodicEdgePolling(client);
1400
+ } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1401
+ this._stopPeriodicEdgePolling();
1402
+ }
1411
1403
  }
1412
1404
  }
1413
1405
  get hasWriter() {
1414
1406
  return !!this._writer;
1415
1407
  }
1416
1408
  async _open() {
1417
- if (this._edgeClient && this._writer) {
1418
- this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1409
+ if (this._edgeClient) {
1410
+ if (this._activeEdgePollingEnabled) {
1411
+ this._startPeriodicEdgePolling(this._edgeClient);
1412
+ }
1413
+ if (this._writer) {
1414
+ this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1415
+ }
1419
1416
  }
1420
1417
  }
1421
1418
  async _close() {
1422
- if (this._activeEdgePollingIntervalHandle) {
1423
- clearInterval(this._activeEdgePollingIntervalHandle);
1424
- this._activeEdgePollingIntervalHandle = void 0;
1425
- }
1419
+ this._stopPeriodicEdgePolling();
1426
1420
  await this._ctx.dispose();
1427
1421
  }
1428
1422
  /**
@@ -1600,10 +1594,23 @@ var NotarizationPlugin = class extends Resource3 {
1600
1594
  ]
1601
1595
  });
1602
1596
  this._writer = writer;
1603
- if (this._edgeClient) {
1597
+ if (this._edgeClient && this.isOpen) {
1604
1598
  this._notarizePendingEdgeCredentials(this._edgeClient, writer);
1605
1599
  }
1606
1600
  }
1601
+ _startPeriodicEdgePolling(client) {
1602
+ this._activeEdgePollingIntervalHandle = setInterval(() => {
1603
+ if (this._writer) {
1604
+ this._notarizePendingEdgeCredentials(client, this._writer);
1605
+ }
1606
+ }, this._activeEdgePollingInterval);
1607
+ }
1608
+ _stopPeriodicEdgePolling() {
1609
+ if (this._activeEdgePollingIntervalHandle) {
1610
+ clearInterval(this._activeEdgePollingIntervalHandle);
1611
+ this._activeEdgePollingIntervalHandle = void 0;
1612
+ }
1613
+ }
1607
1614
  /**
1608
1615
  * The method is used only for adding agent feeds to spaces.
1609
1616
  * When an agent is created we can admit them into all the existing spaces. In case the operation fails
@@ -1622,7 +1629,7 @@ var NotarizationPlugin = class extends Resource3 {
1622
1629
  if (!credentials.length) {
1623
1630
  log4("edge did not return credentials for notarization", void 0, {
1624
1631
  F: __dxlog_file7,
1625
- L: 296,
1632
+ L: 311,
1626
1633
  S: this,
1627
1634
  C: (f, a) => f(...a)
1628
1635
  });
@@ -1632,7 +1639,7 @@ var NotarizationPlugin = class extends Resource3 {
1632
1639
  count: credentials.length
1633
1640
  }, {
1634
1641
  F: __dxlog_file7,
1635
- L: 300,
1642
+ L: 315,
1636
1643
  S: this,
1637
1644
  C: (f, a) => f(...a)
1638
1645
  });
@@ -1645,7 +1652,7 @@ var NotarizationPlugin = class extends Resource3 {
1645
1652
  count: decodedCredentials.length
1646
1653
  }, {
1647
1654
  F: __dxlog_file7,
1648
- L: 309,
1655
+ L: 324,
1649
1656
  S: this,
1650
1657
  C: (f, a) => f(...a)
1651
1658
  });
@@ -1673,7 +1680,7 @@ var NotarizationPlugin = class extends Resource3 {
1673
1680
  for (const credential of credentials) {
1674
1681
  invariant4(credential.id, "Credential must have an id", {
1675
1682
  F: __dxlog_file7,
1676
- L: 335,
1683
+ L: 350,
1677
1684
  S: this,
1678
1685
  A: [
1679
1686
  "credential.id",
@@ -1697,7 +1704,7 @@ var NotarizationPlugin = class extends Resource3 {
1697
1704
  peer: extension.localPeerId
1698
1705
  }, {
1699
1706
  F: __dxlog_file7,
1700
- L: 350,
1707
+ L: 365,
1701
1708
  S: this,
1702
1709
  C: (f, a) => f(...a)
1703
1710
  });
@@ -1709,7 +1716,7 @@ var NotarizationPlugin = class extends Resource3 {
1709
1716
  peer: extension.localPeerId
1710
1717
  }, {
1711
1718
  F: __dxlog_file7,
1712
- L: 355,
1719
+ L: 370,
1713
1720
  S: this,
1714
1721
  C: (f, a) => f(...a)
1715
1722
  });
@@ -1726,7 +1733,7 @@ var NotarizationPlugin = class extends Resource3 {
1726
1733
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1727
1734
  }, {
1728
1735
  F: __dxlog_file7,
1729
- L: 367,
1736
+ L: 382,
1730
1737
  S: this,
1731
1738
  C: (f, a) => f(...a)
1732
1739
  });
@@ -1742,7 +1749,7 @@ var handleEdgeError = (error) => {
1742
1749
  if (!(error instanceof EdgeCallFailedError) || error.errorData) {
1743
1750
  log4.catch(error, void 0, {
1744
1751
  F: __dxlog_file7,
1745
- L: 381,
1752
+ L: 396,
1746
1753
  S: void 0,
1747
1754
  C: (f, a) => f(...a)
1748
1755
  });
@@ -1751,7 +1758,7 @@ var handleEdgeError = (error) => {
1751
1758
  reason: error.reason
1752
1759
  }, {
1753
1760
  F: __dxlog_file7,
1754
- L: 383,
1761
+ L: 398,
1755
1762
  S: void 0,
1756
1763
  C: (f, a) => f(...a)
1757
1764
  });
@@ -2445,7 +2452,7 @@ var DataSpaceManager = class extends Resource4 {
2445
2452
  });
2446
2453
  dataSpace.postOpen.append(async () => {
2447
2454
  const setting = dataSpace.getEdgeReplicationSetting();
2448
- if (setting === EdgeReplicationSetting.ENABLED) {
2455
+ if (!setting || setting === EdgeReplicationSetting.ENABLED) {
2449
2456
  await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2450
2457
  } else if (this._echoEdgeReplicator) {
2451
2458
  log6("not connecting EchoEdgeReplicator because of EdgeReplicationSetting", {
@@ -2460,7 +2467,7 @@ var DataSpaceManager = class extends Resource4 {
2460
2467
  });
2461
2468
  dataSpace.preClose.append(async () => {
2462
2469
  const setting = dataSpace.getEdgeReplicationSetting();
2463
- if (setting === EdgeReplicationSetting.ENABLED) {
2470
+ if (!setting || setting === EdgeReplicationSetting.ENABLED) {
2464
2471
  await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2465
2472
  }
2466
2473
  });
@@ -2565,7 +2572,7 @@ var DataSpaceManager = class extends Resource4 {
2565
2572
  guestKeypair: invitation.guestKey ? {
2566
2573
  publicKey: invitation.guestKey
2567
2574
  } : void 0,
2568
- lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
2575
+ lifetime: invitation.expiresOn ? (invitation.expiresOn.getTime() - Date.now()) / 1e3 : void 0,
2569
2576
  multiUse: invitation.multiUse,
2570
2577
  delegationCredentialId: credentialId,
2571
2578
  persistent: false
@@ -2592,8 +2599,8 @@ DataSpaceManager = _ts_decorate3([
2592
2599
 
2593
2600
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
2594
2601
  import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask3 } from "@dxos/async";
2595
- import { Stream as Stream7 } from "@dxos/codec-protobuf";
2596
- import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2602
+ import { Stream as Stream7 } from "@dxos/codec-protobuf/stream";
2603
+ import { createAdmissionCredentials as createAdmissionCredentials2, createDidFromIdentityKey as createDidFromIdentityKey2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2597
2604
  import { raise } from "@dxos/debug";
2598
2605
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
2599
2606
  import { invariant as invariant6 } from "@dxos/invariant";
@@ -2649,7 +2656,7 @@ var SpacesServiceImpl = class {
2649
2656
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2650
2657
  invariant6(credentials[0].credential, void 0, {
2651
2658
  F: __dxlog_file10,
2652
- L: 106,
2659
+ L: 111,
2653
2660
  S: this,
2654
2661
  A: [
2655
2662
  "credentials[0].credential",
@@ -2659,7 +2666,7 @@ var SpacesServiceImpl = class {
2659
2666
  const spaceMemberCredential = credentials[0].credential.credential;
2660
2667
  invariant6(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2661
2668
  F: __dxlog_file10,
2662
- L: 108,
2669
+ L: 113,
2663
2670
  S: this,
2664
2671
  A: [
2665
2672
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2672,12 +2679,12 @@ var SpacesServiceImpl = class {
2672
2679
  return new Stream7(({ next, ctx }) => {
2673
2680
  const scheduler = new UpdateScheduler(ctx, async () => {
2674
2681
  const dataSpaceManager = await this._getDataSpaceManager();
2675
- const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
2682
+ const spaces = await Promise.all(Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space)));
2676
2683
  log7("update", () => ({
2677
2684
  ids: spaces.map((space) => space.id)
2678
2685
  }), {
2679
2686
  F: __dxlog_file10,
2680
- L: 119,
2687
+ L: 126,
2681
2688
  S: this,
2682
2689
  C: (f, a) => f(...a)
2683
2690
  });
@@ -2769,7 +2776,7 @@ var SpacesServiceImpl = class {
2769
2776
  } else {
2770
2777
  invariant6(!credential.id, "Id on unsigned credentials is not allowed", {
2771
2778
  F: __dxlog_file10,
2772
- L: 217,
2779
+ L: 224,
2773
2780
  S: this,
2774
2781
  A: [
2775
2782
  "!credential.id",
@@ -2778,7 +2785,7 @@ var SpacesServiceImpl = class {
2778
2785
  });
2779
2786
  invariant6(this._identityManager.identity, "Identity is not available", {
2780
2787
  F: __dxlog_file10,
2781
- L: 218,
2788
+ L: 225,
2782
2789
  S: this,
2783
2790
  A: [
2784
2791
  "this._identityManager.identity",
@@ -2788,7 +2795,7 @@ var SpacesServiceImpl = class {
2788
2795
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
2789
2796
  invariant6(credential.issuer.equals(signer.getIssuer()), void 0, {
2790
2797
  F: __dxlog_file10,
2791
- L: 220,
2798
+ L: 227,
2792
2799
  S: this,
2793
2800
  A: [
2794
2801
  "credential.issuer.equals(signer.getIssuer())",
@@ -2838,7 +2845,7 @@ var SpacesServiceImpl = class {
2838
2845
  const assertion = getCredentialAssertion3(credential);
2839
2846
  invariant6(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2840
2847
  F: __dxlog_file10,
2841
- L: 254,
2848
+ L: 261,
2842
2849
  S: this,
2843
2850
  A: [
2844
2851
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2848,7 +2855,7 @@ var SpacesServiceImpl = class {
2848
2855
  const myIdentity = this._identityManager.identity;
2849
2856
  invariant6(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
2850
2857
  F: __dxlog_file10,
2851
- L: 256,
2858
+ L: 263,
2852
2859
  S: this,
2853
2860
  A: [
2854
2861
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -2869,10 +2876,10 @@ var SpacesServiceImpl = class {
2869
2876
  });
2870
2877
  }
2871
2878
  return {
2872
- space: this._serializeSpace(dataSpace)
2879
+ space: await this._serializeSpace(dataSpace)
2873
2880
  };
2874
2881
  }
2875
- _serializeSpace(space) {
2882
+ async _serializeSpace(space) {
2876
2883
  return {
2877
2884
  id: space.id,
2878
2885
  spaceKey: space.key,
@@ -2892,7 +2899,7 @@ var SpacesServiceImpl = class {
2892
2899
  totalDataTimeframe: void 0,
2893
2900
  spaceRootUrl: space.databaseRoot?.url
2894
2901
  },
2895
- members: Array.from(space.inner.spaceState.members.values()).map((member) => {
2902
+ members: await Promise.all(Array.from(space.inner.spaceState.members.values()).map(async (member) => {
2896
2903
  const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
2897
2904
  const isMe = this._identityManager.identity?.identityKey.equals(member.key);
2898
2905
  if (isMe) {
@@ -2900,6 +2907,7 @@ var SpacesServiceImpl = class {
2900
2907
  }
2901
2908
  return {
2902
2909
  identity: {
2910
+ did: await createDidFromIdentityKey2(member.key),
2903
2911
  identityKey: member.key,
2904
2912
  profile: member.profile ?? {}
2905
2913
  },
@@ -2907,7 +2915,7 @@ var SpacesServiceImpl = class {
2907
2915
  presence: peers.length > 0 ? SpaceMember4.PresenceState.ONLINE : SpaceMember4.PresenceState.OFFLINE,
2908
2916
  peerStates: peers
2909
2917
  };
2910
- }),
2918
+ })),
2911
2919
  creator: space.inner.spaceState.creator?.key,
2912
2920
  cache: space.cache,
2913
2921
  metrics: space.metrics,
@@ -2952,13 +2960,14 @@ var Identity = class {
2952
2960
  this.space = params.space;
2953
2961
  this._signer = params.signer;
2954
2962
  this._presence = params.presence;
2963
+ this.did = params.did;
2955
2964
  this.identityKey = params.identityKey;
2956
2965
  this.deviceKey = params.deviceKey;
2957
2966
  log8.trace("dxos.halo.device", {
2958
2967
  deviceKey: params.deviceKey
2959
2968
  }, {
2960
2969
  F: __dxlog_file11,
2961
- L: 79,
2970
+ L: 82,
2962
2971
  S: this,
2963
2972
  C: (f, a) => f(...a)
2964
2973
  });
@@ -3060,7 +3069,7 @@ var Identity = class {
3060
3069
  getIdentityCredentialSigner() {
3061
3070
  invariant7(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
3062
3071
  F: __dxlog_file11,
3063
- L: 195,
3072
+ L: 198,
3064
3073
  S: this,
3065
3074
  A: [
3066
3075
  "this._deviceStateMachine.deviceCredentialChain",
@@ -3104,7 +3113,7 @@ var Identity = class {
3104
3113
  dataFeedKey
3105
3114
  }, {
3106
3115
  F: __dxlog_file11,
3107
- L: 220,
3116
+ L: 223,
3108
3117
  S: this,
3109
3118
  C: (f, a) => f(...a)
3110
3119
  });
@@ -3161,7 +3170,7 @@ Identity = _ts_decorate4([
3161
3170
  import platform from "platform";
3162
3171
  import { Event as Event6 } from "@dxos/async";
3163
3172
  import { Context as Context4 } from "@dxos/context";
3164
- import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator, generateSeedPhrase, keyPairFromSeedPhrase } from "@dxos/credentials";
3173
+ import { createCredentialSignerWithKey as createCredentialSignerWithKey2, createDidFromIdentityKey as createDidFromIdentityKey3, CredentialGenerator } from "@dxos/credentials";
3165
3174
  import { invariant as invariant8 } from "@dxos/invariant";
3166
3175
  import { PublicKey as PublicKey7 } from "@dxos/keys";
3167
3176
  import { log as log9 } from "@dxos/log";
@@ -3203,7 +3212,7 @@ var IdentityManager = class {
3203
3212
  id: traceId
3204
3213
  }), {
3205
3214
  F: __dxlog_file12,
3206
- L: 121,
3215
+ L: 116,
3207
3216
  S: this,
3208
3217
  C: (f, a) => f(...a)
3209
3218
  });
@@ -3212,7 +3221,7 @@ var IdentityManager = class {
3212
3221
  identityRecord
3213
3222
  }, {
3214
3223
  F: __dxlog_file12,
3215
- L: 124,
3224
+ L: 119,
3216
3225
  S: this,
3217
3226
  C: (f, a) => f(...a)
3218
3227
  });
@@ -3225,7 +3234,7 @@ var IdentityManager = class {
3225
3234
  displayName: this._identity.profileDocument?.displayName
3226
3235
  }, {
3227
3236
  F: __dxlog_file12,
3228
- L: 129,
3237
+ L: 124,
3229
3238
  S: this,
3230
3239
  C: (f, a) => f(...a)
3231
3240
  });
@@ -3235,7 +3244,7 @@ var IdentityManager = class {
3235
3244
  id: traceId
3236
3245
  }), {
3237
3246
  F: __dxlog_file12,
3238
- L: 136,
3247
+ L: 131,
3239
3248
  S: this,
3240
3249
  C: (f, a) => f(...a)
3241
3250
  });
@@ -3243,13 +3252,13 @@ var IdentityManager = class {
3243
3252
  async close() {
3244
3253
  await this._identity?.close(new Context4(void 0, {
3245
3254
  F: __dxlog_file12,
3246
- L: 140
3255
+ L: 135
3247
3256
  }));
3248
3257
  }
3249
3258
  async createIdentity({ displayName, deviceProfile } = {}) {
3250
3259
  invariant8(!this._identity, "Identity already exists.", {
3251
3260
  F: __dxlog_file12,
3252
- L: 145,
3261
+ L: 140,
3253
3262
  S: this,
3254
3263
  A: [
3255
3264
  "!this._identity",
@@ -3258,7 +3267,7 @@ var IdentityManager = class {
3258
3267
  });
3259
3268
  log9("creating identity...", void 0, {
3260
3269
  F: __dxlog_file12,
3261
- L: 146,
3270
+ L: 141,
3262
3271
  S: this,
3263
3272
  C: (f, a) => f(...a)
3264
3273
  });
@@ -3276,13 +3285,13 @@ var IdentityManager = class {
3276
3285
  const identity = await this._constructIdentity(identityRecord);
3277
3286
  await identity.open(new Context4(void 0, {
3278
3287
  F: __dxlog_file12,
3279
- L: 161
3288
+ L: 156
3280
3289
  }));
3281
3290
  {
3282
3291
  const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
3283
3292
  invariant8(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
3284
3293
  F: __dxlog_file12,
3285
- L: 165,
3294
+ L: 160,
3286
3295
  S: this,
3287
3296
  A: [
3288
3297
  "identityRecord.haloSpace.genesisFeedKey",
@@ -3291,7 +3300,7 @@ var IdentityManager = class {
3291
3300
  });
3292
3301
  invariant8(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
3293
3302
  F: __dxlog_file12,
3294
- L: 166,
3303
+ L: 161,
3295
3304
  S: this,
3296
3305
  A: [
3297
3306
  "identityRecord.haloSpace.dataFeedKey",
@@ -3330,7 +3339,7 @@ var IdentityManager = class {
3330
3339
  displayName: this._identity.profileDocument?.displayName
3331
3340
  }, {
3332
3341
  F: __dxlog_file12,
3333
- L: 204,
3342
+ L: 199,
3334
3343
  S: this,
3335
3344
  C: (f, a) => f(...a)
3336
3345
  });
@@ -3341,7 +3350,7 @@ var IdentityManager = class {
3341
3350
  profile: identity.profileDocument
3342
3351
  }, {
3343
3352
  F: __dxlog_file12,
3344
- L: 210,
3353
+ L: 205,
3345
3354
  S: this,
3346
3355
  C: (f, a) => f(...a)
3347
3356
  });
@@ -3378,13 +3387,13 @@ var IdentityManager = class {
3378
3387
  params
3379
3388
  }, {
3380
3389
  F: __dxlog_file12,
3381
- L: 249,
3390
+ L: 244,
3382
3391
  S: this,
3383
3392
  C: (f, a) => f(...a)
3384
3393
  });
3385
3394
  invariant8(!this._identity, "Identity already exists.", {
3386
3395
  F: __dxlog_file12,
3387
- L: 250,
3396
+ L: 245,
3388
3397
  S: this,
3389
3398
  A: [
3390
3399
  "!this._identity",
@@ -3405,7 +3414,7 @@ var IdentityManager = class {
3405
3414
  const identity = await this._constructIdentity(identityRecord);
3406
3415
  await identity.open(new Context4(void 0, {
3407
3416
  F: __dxlog_file12,
3408
- L: 264
3417
+ L: 259
3409
3418
  }));
3410
3419
  return {
3411
3420
  identity,
@@ -3424,7 +3433,7 @@ var IdentityManager = class {
3424
3433
  displayName: this._identity.profileDocument?.displayName
3425
3434
  }, {
3426
3435
  F: __dxlog_file12,
3427
- L: 278,
3436
+ L: 273,
3428
3437
  S: this,
3429
3438
  C: (f, a) => f(...a)
3430
3439
  });
@@ -3438,7 +3447,7 @@ var IdentityManager = class {
3438
3447
  deviceKey: identity.deviceKey
3439
3448
  }, {
3440
3449
  F: __dxlog_file12,
3441
- L: 289,
3450
+ L: 284,
3442
3451
  S: this,
3443
3452
  C: (f, a) => f(...a)
3444
3453
  });
@@ -3449,7 +3458,7 @@ var IdentityManager = class {
3449
3458
  async updateProfile(profile) {
3450
3459
  invariant8(this._identity, "Identity not initialized.", {
3451
3460
  F: __dxlog_file12,
3452
- L: 296,
3461
+ L: 291,
3453
3462
  S: this,
3454
3463
  A: [
3455
3464
  "this._identity",
@@ -3480,7 +3489,7 @@ var IdentityManager = class {
3480
3489
  async updateDeviceProfile(profile) {
3481
3490
  invariant8(this._identity, "Identity not initialized.", {
3482
3491
  F: __dxlog_file12,
3483
- L: 313,
3492
+ L: 308,
3484
3493
  S: this,
3485
3494
  A: [
3486
3495
  "this._identity",
@@ -3513,48 +3522,10 @@ var IdentityManager = class {
3513
3522
  profile
3514
3523
  };
3515
3524
  }
3516
- async createRecoveryPhrase() {
3517
- const identity = this._identity;
3518
- invariant8(identity, void 0, {
3519
- F: __dxlog_file12,
3520
- L: 340,
3521
- S: this,
3522
- A: [
3523
- "identity",
3524
- ""
3525
- ]
3526
- });
3527
- const seedphrase = generateSeedPhrase();
3528
- const keypair = keyPairFromSeedPhrase(seedphrase);
3529
- const recoveryKey = PublicKey7.from(keypair.publicKey);
3530
- const identityKey = identity.identityKey;
3531
- const credential = await identity.getIdentityCredentialSigner().createCredential({
3532
- subject: identityKey,
3533
- assertion: {
3534
- "@type": "dxos.halo.credentials.IdentityRecovery",
3535
- recoveryKey,
3536
- identityKey
3537
- }
3538
- });
3539
- const receipt = await identity.controlPipeline.writer.write({
3540
- credential: {
3541
- credential
3542
- }
3543
- });
3544
- await identity.controlPipeline.state.waitUntilTimeframe(new Timeframe3([
3545
- [
3546
- receipt.feedKey,
3547
- receipt.seq
3548
- ]
3549
- ]));
3550
- return {
3551
- seedphrase
3552
- };
3553
- }
3554
3525
  async _constructIdentity(identityRecord) {
3555
3526
  invariant8(!this._identity, void 0, {
3556
3527
  F: __dxlog_file12,
3557
- L: 362,
3528
+ L: 334,
3558
3529
  S: this,
3559
3530
  A: [
3560
3531
  "!this._identity",
@@ -3565,7 +3536,7 @@ var IdentityManager = class {
3565
3536
  identityRecord
3566
3537
  }, {
3567
3538
  F: __dxlog_file12,
3568
- L: 363,
3539
+ L: 335,
3569
3540
  S: this,
3570
3541
  C: (f, a) => f(...a)
3571
3542
  });
@@ -3580,7 +3551,7 @@ var IdentityManager = class {
3580
3551
  });
3581
3552
  invariant8(identityRecord.haloSpace.controlFeedKey, void 0, {
3582
3553
  F: __dxlog_file12,
3583
- L: 376,
3554
+ L: 348,
3584
3555
  S: this,
3585
3556
  A: [
3586
3557
  "identityRecord.haloSpace.controlFeedKey",
@@ -3592,7 +3563,7 @@ var IdentityManager = class {
3592
3563
  });
3593
3564
  invariant8(identityRecord.haloSpace.dataFeedKey, void 0, {
3594
3565
  F: __dxlog_file12,
3595
- L: 380,
3566
+ L: 352,
3596
3567
  S: this,
3597
3568
  A: [
3598
3569
  "identityRecord.haloSpace.dataFeedKey",
@@ -3616,10 +3587,12 @@ var IdentityManager = class {
3616
3587
  });
3617
3588
  await space.setControlFeed(controlFeed);
3618
3589
  await space.setDataFeed(dataFeed);
3590
+ const did = await createDidFromIdentityKey3(identityRecord.identityKey);
3619
3591
  const identity = new Identity({
3620
3592
  space,
3621
3593
  presence,
3622
3594
  signer: this._keyring,
3595
+ did,
3623
3596
  identityKey: identityRecord.identityKey,
3624
3597
  deviceKey: identityRecord.deviceKey,
3625
3598
  edgeConnection: this._edgeConnection,
@@ -3629,7 +3602,7 @@ var IdentityManager = class {
3629
3602
  identityKey: identityRecord.identityKey
3630
3603
  }, {
3631
3604
  F: __dxlog_file12,
3632
- L: 409,
3605
+ L: 383,
3633
3606
  S: this,
3634
3607
  C: (f, a) => f(...a)
3635
3608
  });
@@ -3654,7 +3627,7 @@ var IdentityManager = class {
3654
3627
  onAuthFailure: () => {
3655
3628
  log9.warn("auth failure", void 0, {
3656
3629
  F: __dxlog_file12,
3657
- L: 434,
3630
+ L: 408,
3658
3631
  S: this,
3659
3632
  C: (f, a) => f(...a)
3660
3633
  });
@@ -3678,7 +3651,7 @@ IdentityManager = _ts_decorate5([
3678
3651
 
3679
3652
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
3680
3653
  import { Trigger as Trigger3, sleep as sleep2 } from "@dxos/async";
3681
- import { Stream as Stream8 } from "@dxos/codec-protobuf";
3654
+ import { Stream as Stream8 } from "@dxos/codec-protobuf/stream";
3682
3655
  import { Resource as Resource5 } from "@dxos/context";
3683
3656
  import { createCredential as createCredential2, signPresentation } from "@dxos/credentials";
3684
3657
  import { invariant as invariant9 } from "@dxos/invariant";
@@ -3717,7 +3690,7 @@ var IdentityServiceImpl = class extends Resource5 {
3717
3690
  const identity = this._identityManager.identity;
3718
3691
  invariant9(identity, void 0, {
3719
3692
  F: __dxlog_file13,
3720
- L: 60,
3693
+ L: 61,
3721
3694
  S: this,
3722
3695
  A: [
3723
3696
  "identity",
@@ -3740,6 +3713,7 @@ var IdentityServiceImpl = class extends Resource5 {
3740
3713
  return void 0;
3741
3714
  }
3742
3715
  return {
3716
+ did: this._identityManager.identity.did,
3743
3717
  identityKey: this._identityManager.identity.identityKey,
3744
3718
  spaceKey: this._identityManager.identity.space.key,
3745
3719
  profile: this._identityManager.identity.profileDocument
@@ -3748,7 +3722,7 @@ var IdentityServiceImpl = class extends Resource5 {
3748
3722
  async updateProfile(profile) {
3749
3723
  invariant9(this._identityManager.identity, "Identity not initialized.", {
3750
3724
  F: __dxlog_file13,
3751
- L: 86,
3725
+ L: 88,
3752
3726
  S: this,
3753
3727
  A: [
3754
3728
  "this._identityManager.identity",
@@ -3759,18 +3733,29 @@ var IdentityServiceImpl = class extends Resource5 {
3759
3733
  await this._onProfileUpdate?.(this._identityManager.identity.profileDocument);
3760
3734
  return this._getIdentity();
3761
3735
  }
3762
- async createRecoveryPhrase() {
3763
- return this._recoveryManager.createRecoveryPhrase();
3736
+ async createRecoveryCredential(request) {
3737
+ return this._recoveryManager.createRecoveryCredential(request);
3738
+ }
3739
+ async requestRecoveryChallenge() {
3740
+ return this._recoveryManager.requestRecoveryChallenge();
3764
3741
  }
3765
3742
  async recoverIdentity(request) {
3766
- await this._recoveryManager.recoverIdentity(request);
3743
+ if (request.recoveryCode) {
3744
+ await this._recoveryManager.recoverIdentity({
3745
+ recoveryCode: request.recoveryCode
3746
+ });
3747
+ } else if (request.external) {
3748
+ await this._recoveryManager.recoverIdentityWithExternalSignature(request.external);
3749
+ } else {
3750
+ throw new Error("Invalid request.");
3751
+ }
3767
3752
  return this._getIdentity();
3768
3753
  }
3769
3754
  // TODO(burdon): Rename createPresentation?
3770
3755
  async signPresentation({ presentation, nonce }) {
3771
3756
  invariant9(this._identityManager.identity, "Identity not initialized.", {
3772
3757
  F: __dxlog_file13,
3773
- L: 103,
3758
+ L: 116,
3774
3759
  S: this,
3775
3760
  A: [
3776
3761
  "this._identityManager.identity",
@@ -3789,7 +3774,7 @@ var IdentityServiceImpl = class extends Resource5 {
3789
3774
  const identity = this._identityManager.identity;
3790
3775
  invariant9(identity, "Identity not initialized.", {
3791
3776
  F: __dxlog_file13,
3792
- L: 117,
3777
+ L: 130,
3793
3778
  S: this,
3794
3779
  A: [
3795
3780
  "identity",
@@ -3827,7 +3812,7 @@ var IdentityServiceImpl = class extends Resource5 {
3827
3812
  duplicate: space.id
3828
3813
  }, {
3829
3814
  F: __dxlog_file13,
3830
- L: 151,
3815
+ L: 164,
3831
3816
  S: this,
3832
3817
  C: (f, a) => f(...a)
3833
3818
  });
@@ -3841,7 +3826,7 @@ var IdentityServiceImpl = class extends Resource5 {
3841
3826
  }, (err) => {
3842
3827
  log10.catch(err, void 0, {
3843
3828
  F: __dxlog_file13,
3844
- L: 162,
3829
+ L: 175,
3845
3830
  S: this,
3846
3831
  C: (f, a) => f(...a)
3847
3832
  });
@@ -4622,14 +4607,14 @@ var DeviceInvitationProtocol = class {
4622
4607
 
4623
4608
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
4624
4609
  import { scheduleTask as scheduleTask7, TimeoutError as TimeoutError2 } from "@dxos/async";
4625
- import { INVITATION_TIMEOUT } from "@dxos/client-protocol";
4610
+ import { INVITATION_TIMEOUT, getExpirationTime } from "@dxos/client-protocol";
4626
4611
  import { ContextDisposedError as ContextDisposedError3 } from "@dxos/context";
4627
4612
  import { createKeyPair, sign as sign2 } from "@dxos/crypto";
4628
4613
  import { invariant as invariant15 } from "@dxos/invariant";
4629
4614
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4630
4615
  import { log as log17 } from "@dxos/log";
4631
4616
  import { createTeleportProtocolFactory } from "@dxos/network-manager";
4632
- import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace7 } from "@dxos/protocols";
4617
+ import { InvalidInvitationError, InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace7 } from "@dxos/protocols";
4633
4618
  import { Invitation as Invitation7 } from "@dxos/protocols/proto/dxos/client/services";
4634
4619
  import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
4635
4620
  import { InvitationOptions as InvitationOptions4 } from "@dxos/protocols/proto/dxos/halo/invitations";
@@ -4652,6 +4637,12 @@ import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/ser
4652
4637
  var stateToString = (state) => {
4653
4638
  return Object.entries(Invitation3.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
4654
4639
  };
4640
+ var computeExpirationTime = (invitation) => {
4641
+ if (!invitation.lifetime) {
4642
+ return;
4643
+ }
4644
+ return new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime * 1e3);
4645
+ };
4655
4646
  var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
4656
4647
  let guard;
4657
4648
  return cancelWithContext3(ctx, (async () => {
@@ -5667,18 +5658,19 @@ var InvitationsHandler = class {
5667
5658
  });
5668
5659
  return extension;
5669
5660
  };
5670
- if (invitation.lifetime && invitation.created) {
5671
- if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
5661
+ const expiresOn = getExpirationTime(invitation);
5662
+ if (expiresOn) {
5663
+ if (expiresOn.getTime() < Date.now()) {
5672
5664
  log17.warn("invitation has already expired", void 0, {
5673
5665
  F: __dxlog_file21,
5674
- L: 193,
5666
+ L: 194,
5675
5667
  S: this,
5676
5668
  C: (f, a) => f(...a)
5677
5669
  });
5678
5670
  guardedState.set(null, Invitation7.State.EXPIRED);
5679
5671
  void ctx.dispose().catch((err) => log17.catch(err, void 0, {
5680
5672
  F: __dxlog_file21,
5681
- L: 195,
5673
+ L: 196,
5682
5674
  S: this,
5683
5675
  C: (f, a) => f(...a)
5684
5676
  }));
@@ -5689,7 +5681,7 @@ var InvitationsHandler = class {
5689
5681
  guardedState.set(null, Invitation7.State.EXPIRED);
5690
5682
  metrics.increment("dxos.invitation.expired");
5691
5683
  await ctx.dispose();
5692
- }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
5684
+ }, expiresOn.getTime() - Date.now());
5693
5685
  }
5694
5686
  let swarmConnection;
5695
5687
  scheduleTask7(ctx, async () => {
@@ -5705,7 +5697,7 @@ var InvitationsHandler = class {
5705
5697
  type: invitation.type
5706
5698
  }, {
5707
5699
  F: __dxlog_file21,
5708
- L: 226,
5700
+ L: 227,
5709
5701
  S: this,
5710
5702
  C: (f, a) => f(...a)
5711
5703
  });
@@ -5713,7 +5705,7 @@ var InvitationsHandler = class {
5713
5705
  if (deviceProfile) {
5714
5706
  invariant15(invitation.kind === Invitation7.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
5715
5707
  F: __dxlog_file21,
5716
- L: 235,
5708
+ L: 236,
5717
5709
  S: this,
5718
5710
  A: [
5719
5711
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -5731,7 +5723,7 @@ var InvitationsHandler = class {
5731
5723
  triedPeers: triedPeersIds.size
5732
5724
  }, {
5733
5725
  F: __dxlog_file21,
5734
- L: 243,
5726
+ L: 244,
5735
5727
  S: this,
5736
5728
  C: (f, a) => f(...a)
5737
5729
  });
@@ -5758,7 +5750,7 @@ var InvitationsHandler = class {
5758
5750
  currentState: guardedState.current.state
5759
5751
  }, {
5760
5752
  F: __dxlog_file21,
5761
- L: 271,
5753
+ L: 272,
5762
5754
  S: this,
5763
5755
  C: (f, a) => f(...a)
5764
5756
  });
@@ -5776,7 +5768,7 @@ var InvitationsHandler = class {
5776
5768
  id: traceId
5777
5769
  }), {
5778
5770
  F: __dxlog_file21,
5779
- L: 283,
5771
+ L: 284,
5780
5772
  S: this,
5781
5773
  C: (f, a) => f(...a)
5782
5774
  });
@@ -5788,7 +5780,7 @@ var InvitationsHandler = class {
5788
5780
  ...protocol.toJSON()
5789
5781
  }, {
5790
5782
  F: __dxlog_file21,
5791
- L: 294,
5783
+ L: 295,
5792
5784
  S: this,
5793
5785
  C: (f, a) => f(...a)
5794
5786
  });
@@ -5798,7 +5790,7 @@ var InvitationsHandler = class {
5798
5790
  ...protocol.toJSON()
5799
5791
  }, {
5800
5792
  F: __dxlog_file21,
5801
- L: 298,
5793
+ L: 299,
5802
5794
  S: this,
5803
5795
  C: (f, a) => f(...a)
5804
5796
  });
@@ -5812,7 +5804,7 @@ var InvitationsHandler = class {
5812
5804
  authMethod: introductionResponse.authMethod
5813
5805
  }, {
5814
5806
  F: __dxlog_file21,
5815
- L: 306,
5807
+ L: 307,
5816
5808
  S: this,
5817
5809
  C: (f, a) => f(...a)
5818
5810
  });
@@ -5834,7 +5826,7 @@ var InvitationsHandler = class {
5834
5826
  ...protocol.toJSON()
5835
5827
  }, {
5836
5828
  F: __dxlog_file21,
5837
- L: 336,
5829
+ L: 337,
5838
5830
  S: this,
5839
5831
  C: (f, a) => f(...a)
5840
5832
  });
@@ -5847,7 +5839,7 @@ var InvitationsHandler = class {
5847
5839
  ...protocol.toJSON()
5848
5840
  }, {
5849
5841
  F: __dxlog_file21,
5850
- L: 350,
5842
+ L: 351,
5851
5843
  S: this,
5852
5844
  C: (f, a) => f(...a)
5853
5845
  });
@@ -5860,7 +5852,7 @@ var InvitationsHandler = class {
5860
5852
  id: traceId
5861
5853
  }), {
5862
5854
  F: __dxlog_file21,
5863
- L: 359,
5855
+ L: 360,
5864
5856
  S: this,
5865
5857
  C: (f, a) => f(...a)
5866
5858
  });
@@ -5870,7 +5862,7 @@ var InvitationsHandler = class {
5870
5862
  ...protocol.toJSON()
5871
5863
  }, {
5872
5864
  F: __dxlog_file21,
5873
- L: 362,
5865
+ L: 363,
5874
5866
  S: this,
5875
5867
  C: (f, a) => f(...a)
5876
5868
  });
@@ -5878,7 +5870,7 @@ var InvitationsHandler = class {
5878
5870
  } else {
5879
5871
  log17.verbose("auth failed", err, {
5880
5872
  F: __dxlog_file21,
5881
- L: 365,
5873
+ L: 366,
5882
5874
  S: this,
5883
5875
  C: (f, a) => f(...a)
5884
5876
  });
@@ -5890,7 +5882,7 @@ var InvitationsHandler = class {
5890
5882
  error: err
5891
5883
  }), {
5892
5884
  F: __dxlog_file21,
5893
- L: 369,
5885
+ L: 370,
5894
5886
  S: this,
5895
5887
  C: (f, a) => f(...a)
5896
5888
  });
@@ -5906,7 +5898,7 @@ var InvitationsHandler = class {
5906
5898
  ...protocol.toJSON()
5907
5899
  }, {
5908
5900
  F: __dxlog_file21,
5909
- L: 378,
5901
+ L: 379,
5910
5902
  S: this,
5911
5903
  C: (f, a) => f(...a)
5912
5904
  });
@@ -5914,7 +5906,7 @@ var InvitationsHandler = class {
5914
5906
  } else {
5915
5907
  log17.verbose("auth failed", err, {
5916
5908
  F: __dxlog_file21,
5917
- L: 381,
5909
+ L: 382,
5918
5910
  S: this,
5919
5911
  C: (f, a) => f(...a)
5920
5912
  });
@@ -5931,7 +5923,7 @@ var InvitationsHandler = class {
5931
5923
  ...protocol.toJSON()
5932
5924
  }, {
5933
5925
  F: __dxlog_file21,
5934
- L: 393,
5926
+ L: 394,
5935
5927
  S: this,
5936
5928
  C: (f, a) => f(...a)
5937
5929
  });
@@ -5944,14 +5936,14 @@ var InvitationsHandler = class {
5944
5936
  });
5945
5937
  edgeInvitationHandler.handle(ctx, guardedState, protocol, deviceProfile);
5946
5938
  scheduleTask7(ctx, async () => {
5947
- const error = protocol.checkInvitation(invitation);
5939
+ const error = checkInvitation(protocol, invitation);
5948
5940
  if (error) {
5949
5941
  stream.error(error);
5950
5942
  await ctx.dispose();
5951
5943
  } else {
5952
5944
  invariant15(invitation.swarmKey, void 0, {
5953
5945
  F: __dxlog_file21,
5954
- L: 405,
5946
+ L: 406,
5955
5947
  S: this,
5956
5948
  A: [
5957
5949
  "invitation.swarmKey",
@@ -5995,7 +5987,7 @@ var InvitationsHandler = class {
5995
5987
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
5996
5988
  log17("guest waiting for authentication code...", void 0, {
5997
5989
  F: __dxlog_file21,
5998
- L: 457,
5990
+ L: 458,
5999
5991
  S: this,
6000
5992
  C: (f, a) => f(...a)
6001
5993
  });
@@ -6003,7 +5995,7 @@ var InvitationsHandler = class {
6003
5995
  const authCode = await authenticated.wait(options);
6004
5996
  log17("sending authentication request", void 0, {
6005
5997
  F: __dxlog_file21,
6006
- L: 461,
5998
+ L: 462,
6007
5999
  S: this,
6008
6000
  C: (f, a) => f(...a)
6009
6001
  });
@@ -6022,7 +6014,7 @@ var InvitationsHandler = class {
6022
6014
  attempt
6023
6015
  }, {
6024
6016
  F: __dxlog_file21,
6025
- L: 472,
6017
+ L: 473,
6026
6018
  S: this,
6027
6019
  C: (f, a) => f(...a)
6028
6020
  });
@@ -6040,7 +6032,7 @@ var InvitationsHandler = class {
6040
6032
  }
6041
6033
  log17("sending authentication request", void 0, {
6042
6034
  F: __dxlog_file21,
6043
- L: 491,
6035
+ L: 492,
6044
6036
  S: this,
6045
6037
  C: (f, a) => f(...a)
6046
6038
  });
@@ -6053,6 +6045,13 @@ var InvitationsHandler = class {
6053
6045
  }
6054
6046
  }
6055
6047
  };
6048
+ var checkInvitation = (protocol, invitation) => {
6049
+ const expiresOn = getExpirationTime(invitation);
6050
+ if (expiresOn && expiresOn.getTime() < Date.now()) {
6051
+ return new InvalidInvitationError("Invitation already expired.");
6052
+ }
6053
+ return protocol.checkInvitation(invitation);
6054
+ };
6056
6055
  var createAdmissionKeypair = () => {
6057
6056
  const keypair = createKeyPair();
6058
6057
  return {
@@ -6062,7 +6061,7 @@ var createAdmissionKeypair = () => {
6062
6061
  };
6063
6062
 
6064
6063
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
6065
- import { Stream as Stream9 } from "@dxos/codec-protobuf";
6064
+ import { Stream as Stream9 } from "@dxos/codec-protobuf/stream";
6066
6065
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
6067
6066
  import { trace as trace8 } from "@dxos/tracing";
6068
6067
  var InvitationsServiceImpl = class {
@@ -6167,7 +6166,7 @@ import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInv
6167
6166
  import { writeMessages as writeMessages4 } from "@dxos/feed-store";
6168
6167
  import { invariant as invariant16 } from "@dxos/invariant";
6169
6168
  import { log as log18 } from "@dxos/log";
6170
- import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
6169
+ import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError as InvalidInvitationError2, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
6171
6170
  import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
6172
6171
  import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
6173
6172
  var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
@@ -6187,7 +6186,7 @@ var SpaceInvitationProtocol = class {
6187
6186
  }
6188
6187
  checkCanInviteNewMembers() {
6189
6188
  if (this._spaceKey == null) {
6190
- return new InvalidInvitationError("No spaceKey was provided for a space invitation.");
6189
+ return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
6191
6190
  }
6192
6191
  const space = this._spaceManager.spaces.get(this._spaceKey);
6193
6192
  if (space == null) {
@@ -6201,7 +6200,7 @@ var SpaceInvitationProtocol = class {
6201
6200
  getInvitationContext() {
6202
6201
  invariant16(this._spaceKey, void 0, {
6203
6202
  F: __dxlog_file22,
6204
- L: 64,
6203
+ L: 65,
6205
6204
  S: this,
6206
6205
  A: [
6207
6206
  "this._spaceKey",
@@ -6211,7 +6210,7 @@ var SpaceInvitationProtocol = class {
6211
6210
  const space = this._spaceManager.spaces.get(this._spaceKey);
6212
6211
  invariant16(space, void 0, {
6213
6212
  F: __dxlog_file22,
6214
- L: 66,
6213
+ L: 67,
6215
6214
  S: this,
6216
6215
  A: [
6217
6216
  "space",
@@ -6227,7 +6226,7 @@ var SpaceInvitationProtocol = class {
6227
6226
  async admit(invitation, request, guestProfile) {
6228
6227
  invariant16(this._spaceKey && request.space, void 0, {
6229
6228
  F: __dxlog_file22,
6230
- L: 79,
6229
+ L: 80,
6231
6230
  S: this,
6232
6231
  A: [
6233
6232
  "this._spaceKey && request.space",
@@ -6239,7 +6238,7 @@ var SpaceInvitationProtocol = class {
6239
6238
  guest: request.space.deviceKey
6240
6239
  }, {
6241
6240
  F: __dxlog_file22,
6242
- L: 80,
6241
+ L: 81,
6243
6242
  S: this,
6244
6243
  C: (f, a) => f(...a)
6245
6244
  });
@@ -6261,7 +6260,7 @@ var SpaceInvitationProtocol = class {
6261
6260
  async delegate(invitation) {
6262
6261
  invariant16(this._spaceKey, void 0, {
6263
6262
  F: __dxlog_file22,
6264
- L: 100,
6263
+ L: 101,
6265
6264
  S: this,
6266
6265
  A: [
6267
6266
  "this._spaceKey",
@@ -6271,7 +6270,7 @@ var SpaceInvitationProtocol = class {
6271
6270
  const space = this._spaceManager.spaces.get(this._spaceKey);
6272
6271
  invariant16(space, void 0, {
6273
6272
  F: __dxlog_file22,
6274
- L: 102,
6273
+ L: 103,
6275
6274
  S: this,
6276
6275
  A: [
6277
6276
  "space",
@@ -6281,7 +6280,7 @@ var SpaceInvitationProtocol = class {
6281
6280
  if (invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY) {
6282
6281
  invariant16(invitation.guestKeypair?.publicKey, void 0, {
6283
6282
  F: __dxlog_file22,
6284
- L: 104,
6283
+ L: 105,
6285
6284
  S: this,
6286
6285
  A: [
6287
6286
  "invitation.guestKeypair?.publicKey",
@@ -6294,7 +6293,7 @@ var SpaceInvitationProtocol = class {
6294
6293
  id: invitation.invitationId
6295
6294
  }, {
6296
6295
  F: __dxlog_file22,
6297
- L: 107,
6296
+ L: 108,
6298
6297
  S: this,
6299
6298
  C: (f, a) => f(...a)
6300
6299
  });
@@ -6303,13 +6302,13 @@ var SpaceInvitationProtocol = class {
6303
6302
  authMethod: invitation.authMethod,
6304
6303
  swarmKey: invitation.swarmKey,
6305
6304
  role: invitation.role ?? SpaceMember6.Role.ADMIN,
6306
- expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
6305
+ expiresOn: computeExpirationTime(invitation),
6307
6306
  multiUse: invitation.multiUse ?? false,
6308
6307
  guestKey: invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
6309
6308
  });
6310
6309
  invariant16(credential.credential, void 0, {
6311
6310
  F: __dxlog_file22,
6312
- L: 127,
6311
+ L: 126,
6313
6312
  S: this,
6314
6313
  A: [
6315
6314
  "credential.credential",
@@ -6324,7 +6323,7 @@ var SpaceInvitationProtocol = class {
6324
6323
  async cancelDelegation(invitation) {
6325
6324
  invariant16(this._spaceKey, void 0, {
6326
6325
  F: __dxlog_file22,
6327
- L: 133,
6326
+ L: 132,
6328
6327
  S: this,
6329
6328
  A: [
6330
6329
  "this._spaceKey",
@@ -6333,7 +6332,7 @@ var SpaceInvitationProtocol = class {
6333
6332
  });
6334
6333
  invariant16(invitation.type === Invitation8.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6335
6334
  F: __dxlog_file22,
6336
- L: 134,
6335
+ L: 133,
6337
6336
  S: this,
6338
6337
  A: [
6339
6338
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -6343,7 +6342,7 @@ var SpaceInvitationProtocol = class {
6343
6342
  const space = this._spaceManager.spaces.get(this._spaceKey);
6344
6343
  invariant16(space, void 0, {
6345
6344
  F: __dxlog_file22,
6346
- L: 136,
6345
+ L: 135,
6347
6346
  S: this,
6348
6347
  A: [
6349
6348
  "space",
@@ -6355,14 +6354,14 @@ var SpaceInvitationProtocol = class {
6355
6354
  id: invitation.invitationId
6356
6355
  }, {
6357
6356
  F: __dxlog_file22,
6358
- L: 138,
6357
+ L: 137,
6359
6358
  S: this,
6360
6359
  C: (f, a) => f(...a)
6361
6360
  });
6362
6361
  const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
6363
6362
  invariant16(credential.credential, void 0, {
6364
6363
  F: __dxlog_file22,
6365
- L: 145,
6364
+ L: 144,
6366
6365
  S: this,
6367
6366
  A: [
6368
6367
  "credential.credential",
@@ -6375,7 +6374,7 @@ var SpaceInvitationProtocol = class {
6375
6374
  }
6376
6375
  checkInvitation(invitation) {
6377
6376
  if (invitation.spaceKey == null) {
6378
- return new InvalidInvitationError("No spaceKey was provided for a space invitation.");
6377
+ return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
6379
6378
  }
6380
6379
  if (this._spaceManager.spaces.has(invitation.spaceKey)) {
6381
6380
  return new AlreadyJoinedError3("Already joined space.");
@@ -6401,7 +6400,7 @@ var SpaceInvitationProtocol = class {
6401
6400
  async accept(response) {
6402
6401
  invariant16(response.space, void 0, {
6403
6402
  F: __dxlog_file22,
6404
- L: 180,
6403
+ L: 179,
6405
6404
  S: this,
6406
6405
  A: [
6407
6406
  "response.space",
@@ -6412,7 +6411,7 @@ var SpaceInvitationProtocol = class {
6412
6411
  const assertion = getCredentialAssertion5(credential);
6413
6412
  invariant16(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
6414
6413
  F: __dxlog_file22,
6415
- L: 183,
6414
+ L: 182,
6416
6415
  S: this,
6417
6416
  A: [
6418
6417
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -6421,7 +6420,7 @@ var SpaceInvitationProtocol = class {
6421
6420
  });
6422
6421
  invariant16(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
6423
6422
  F: __dxlog_file22,
6424
- L: 184,
6423
+ L: 183,
6425
6424
  S: this,
6426
6425
  A: [
6427
6426
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -6657,7 +6656,7 @@ var InvitationsManager = class {
6657
6656
  }
6658
6657
  }
6659
6658
  _createInvitation(protocol, _options) {
6660
- 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 ?? {};
6659
+ 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 ?? {};
6661
6660
  const authCode = options?.authCode ?? (authMethod === Invitation9.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
6662
6661
  return {
6663
6662
  invitationId,
@@ -7017,6 +7016,18 @@ var EdgeAgentManager = class extends Resource6 {
7017
7016
  haloSpaceKey: this._identity.haloSpaceKey.toHex()
7018
7017
  });
7019
7018
  const deviceKey = PublicKey13.fromHex(response.deviceKey);
7019
+ if (await this._identity.authorizedDeviceKeys.has(deviceKey)) {
7020
+ log21.info("agent was already added to HALO, ignoring response", {
7021
+ response
7022
+ }, {
7023
+ F: __dxlog_file25,
7024
+ L: 67,
7025
+ S: this,
7026
+ C: (f, a) => f(...a)
7027
+ });
7028
+ this._updateStatus(EdgeAgentStatus.ACTIVE, deviceKey);
7029
+ return;
7030
+ }
7020
7031
  await this._identity.admitDevice({
7021
7032
  deviceKey,
7022
7033
  controlFeedKey: PublicKey13.fromHex(response.feedKey),
@@ -7025,7 +7036,7 @@ var EdgeAgentManager = class extends Resource6 {
7025
7036
  });
7026
7037
  log21("agent created", response, {
7027
7038
  F: __dxlog_file25,
7028
- L: 73,
7039
+ L: 79,
7029
7040
  S: this,
7030
7041
  C: (f, a) => f(...a)
7031
7042
  });
@@ -7037,7 +7048,7 @@ var EdgeAgentManager = class extends Resource6 {
7037
7048
  isEnabled
7038
7049
  }, {
7039
7050
  F: __dxlog_file25,
7040
- L: 81,
7051
+ L: 87,
7041
7052
  S: this,
7042
7053
  C: (f, a) => f(...a)
7043
7054
  });
@@ -7070,7 +7081,7 @@ var EdgeAgentManager = class extends Resource6 {
7070
7081
  async _fetchAgentStatus() {
7071
7082
  invariant19(this._edgeHttpClient, void 0, {
7072
7083
  F: __dxlog_file25,
7073
- L: 115,
7084
+ L: 121,
7074
7085
  S: this,
7075
7086
  A: [
7076
7087
  "this._edgeHttpClient",
@@ -7080,7 +7091,7 @@ var EdgeAgentManager = class extends Resource6 {
7080
7091
  try {
7081
7092
  log21("fetching agent status", void 0, {
7082
7093
  F: __dxlog_file25,
7083
- L: 117,
7094
+ L: 123,
7084
7095
  S: this,
7085
7096
  C: (f, a) => f(...a)
7086
7097
  });
@@ -7099,7 +7110,7 @@ var EdgeAgentManager = class extends Resource6 {
7099
7110
  err
7100
7111
  }, {
7101
7112
  F: __dxlog_file25,
7102
- L: 127,
7113
+ L: 133,
7103
7114
  S: this,
7104
7115
  C: (f, a) => f(...a)
7105
7116
  });
@@ -7112,7 +7123,7 @@ var EdgeAgentManager = class extends Resource6 {
7112
7123
  retryAfterMs
7113
7124
  }, {
7114
7125
  F: __dxlog_file25,
7115
- L: 132,
7126
+ L: 138,
7116
7127
  S: this,
7117
7128
  C: (f, a) => f(...a)
7118
7129
  });
@@ -7148,7 +7159,7 @@ var EdgeAgentManager = class extends Resource6 {
7148
7159
  spaceId: space.id
7149
7160
  }, {
7150
7161
  F: __dxlog_file25,
7151
- L: 159,
7162
+ L: 165,
7152
7163
  S: this,
7153
7164
  C: (f, a) => f(...a)
7154
7165
  });
@@ -7168,7 +7179,7 @@ var EdgeAgentManager = class extends Resource6 {
7168
7179
  status
7169
7180
  }, {
7170
7181
  F: __dxlog_file25,
7171
- L: 175,
7182
+ L: 181,
7172
7183
  S: this,
7173
7184
  C: (f, a) => f(...a)
7174
7185
  });
@@ -7179,7 +7190,7 @@ _ts_decorate9([
7179
7190
  ], EdgeAgentManager.prototype, "createAgent", null);
7180
7191
 
7181
7192
  // packages/sdk/client-services/src/packlets/agents/edge-agent-service.ts
7182
- import { Stream as Stream11 } from "@dxos/codec-protobuf";
7193
+ import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
7183
7194
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7184
7195
  import { QueryAgentStatusResponse, QueryEdgeStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
7185
7196
  var EdgeAgentServiceImpl = class {
@@ -7258,7 +7269,7 @@ import { trace as Trace3 } from "@dxos/tracing";
7258
7269
  import { safeInstanceof } from "@dxos/util";
7259
7270
 
7260
7271
  // packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts
7261
- import { generateSeedPhrase as generateSeedPhrase2, keyPairFromSeedPhrase as keyPairFromSeedPhrase2 } from "@dxos/credentials";
7272
+ import { generateSeedPhrase, keyPairFromSeedPhrase } from "@dxos/credentials";
7262
7273
  import { sign as sign3 } from "@dxos/crypto";
7263
7274
  import { invariant as invariant20 } from "@dxos/invariant";
7264
7275
  import { PublicKey as PublicKey14 } from "@dxos/keys";
@@ -7274,27 +7285,41 @@ var EdgeIdentityRecoveryManager = class {
7274
7285
  this._identityProvider = _identityProvider;
7275
7286
  this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
7276
7287
  }
7277
- async createRecoveryPhrase() {
7288
+ async createRecoveryCredential({ recoveryKey, algorithm }) {
7278
7289
  const identity = this._identityProvider();
7279
7290
  invariant20(identity, void 0, {
7280
7291
  F: __dxlog_file26,
7281
- L: 29,
7292
+ L: 37,
7282
7293
  S: this,
7283
7294
  A: [
7284
7295
  "identity",
7285
7296
  ""
7286
7297
  ]
7287
7298
  });
7288
- const seedphrase = generateSeedPhrase2();
7289
- const keypair = keyPairFromSeedPhrase2(seedphrase);
7290
- const recoveryKey = PublicKey14.from(keypair.publicKey);
7299
+ let recoveryCode;
7300
+ if (!recoveryKey) {
7301
+ recoveryCode = generateSeedPhrase();
7302
+ const keypair = keyPairFromSeedPhrase(recoveryCode);
7303
+ recoveryKey = PublicKey14.from(keypair.publicKey);
7304
+ algorithm = "ED25519";
7305
+ }
7306
+ invariant20(algorithm, "Algorithm is required.", {
7307
+ F: __dxlog_file26,
7308
+ L: 47,
7309
+ S: this,
7310
+ A: [
7311
+ "algorithm",
7312
+ "'Algorithm is required.'"
7313
+ ]
7314
+ });
7291
7315
  const identityKey = identity.identityKey;
7292
7316
  const credential = await identity.getIdentityCredentialSigner().createCredential({
7293
7317
  subject: identityKey,
7294
7318
  assertion: {
7295
7319
  "@type": "dxos.halo.credentials.IdentityRecovery",
7296
7320
  recoveryKey,
7297
- identityKey
7321
+ identityKey,
7322
+ algorithm
7298
7323
  }
7299
7324
  });
7300
7325
  const receipt = await identity.controlPipeline.writer.write({
@@ -7309,20 +7334,81 @@ var EdgeIdentityRecoveryManager = class {
7309
7334
  ]
7310
7335
  ]));
7311
7336
  return {
7312
- seedphrase
7337
+ recoveryCode
7313
7338
  };
7314
7339
  }
7315
- async recoverIdentity(args) {
7340
+ async requestRecoveryChallenge() {
7316
7341
  invariant20(this._edgeClient, "Not connected to EDGE.", {
7317
7342
  F: __dxlog_file26,
7318
- L: 51,
7343
+ L: 66,
7319
7344
  S: this,
7320
7345
  A: [
7321
7346
  "this._edgeClient",
7322
7347
  "'Not connected to EDGE.'"
7323
7348
  ]
7324
7349
  });
7325
- const recoveryKeypair = keyPairFromSeedPhrase2(args.seedphrase);
7350
+ const deviceKey = await this._keyring.createKey();
7351
+ const controlFeedKey = await this._keyring.createKey();
7352
+ const request = {
7353
+ deviceKey: deviceKey.toHex(),
7354
+ controlFeedKey: controlFeedKey.toHex()
7355
+ };
7356
+ try {
7357
+ await this._edgeClient.recoverIdentity(request);
7358
+ throw new Error("No challenge received.");
7359
+ } catch (error) {
7360
+ if (!(error instanceof EdgeAuthChallengeError2)) {
7361
+ throw error;
7362
+ }
7363
+ return {
7364
+ deviceKey,
7365
+ controlFeedKey,
7366
+ challenge: error.challenge
7367
+ };
7368
+ }
7369
+ }
7370
+ async recoverIdentityWithExternalSignature({ identityDid, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7371
+ invariant20(this._edgeClient, "Not connected to EDGE.", {
7372
+ F: __dxlog_file26,
7373
+ L: 98,
7374
+ S: this,
7375
+ A: [
7376
+ "this._edgeClient",
7377
+ "'Not connected to EDGE.'"
7378
+ ]
7379
+ });
7380
+ const request = {
7381
+ identityDid,
7382
+ deviceKey: deviceKey.toHex(),
7383
+ controlFeedKey: controlFeedKey.toHex(),
7384
+ signature: clientDataJson && authenticatorData ? {
7385
+ signature: Buffer.from(signature).toString("base64"),
7386
+ clientDataJson: Buffer.from(clientDataJson).toString("base64"),
7387
+ authenticatorData: Buffer.from(authenticatorData).toString("base64")
7388
+ } : Buffer.from(signature).toString("base64")
7389
+ };
7390
+ const response = await this._edgeClient.recoverIdentity(request);
7391
+ await this._acceptRecoveredIdentity({
7392
+ authorizedDeviceCredential: decodeCredential(response.deviceAuthCredential),
7393
+ haloGenesisFeedKey: PublicKey14.fromHex(response.genesisFeedKey),
7394
+ haloSpaceKey: PublicKey14.fromHex(response.haloSpaceKey),
7395
+ identityKey: PublicKey14.fromHex(response.identityKey),
7396
+ deviceKey,
7397
+ controlFeedKey,
7398
+ dataFeedKey: await this._keyring.createKey()
7399
+ });
7400
+ }
7401
+ async recoverIdentity({ recoveryCode }) {
7402
+ invariant20(this._edgeClient, "Not connected to EDGE.", {
7403
+ F: __dxlog_file26,
7404
+ L: 128,
7405
+ S: this,
7406
+ A: [
7407
+ "this._edgeClient",
7408
+ "'Not connected to EDGE.'"
7409
+ ]
7410
+ });
7411
+ const recoveryKeypair = keyPairFromSeedPhrase(recoveryCode);
7326
7412
  const recoveryKey = PublicKey14.from(recoveryKeypair.publicKey);
7327
7413
  const deviceKey = await this._keyring.createKey();
7328
7414
  const controlFeedKey = await this._keyring.createKey();
@@ -7346,7 +7432,7 @@ var EdgeIdentityRecoveryManager = class {
7346
7432
  }
7347
7433
  log22.info("recovering identity", response, {
7348
7434
  F: __dxlog_file26,
7349
- L: 77,
7435
+ L: 154,
7350
7436
  S: this,
7351
7437
  C: (f, a) => f(...a)
7352
7438
  });
@@ -7487,7 +7573,8 @@ var ServiceContext = class extends Resource7 {
7487
7573
  this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
7488
7574
  this.echoHost = new EchoHost({
7489
7575
  kv: this.level,
7490
- peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex()
7576
+ peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
7577
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key
7491
7578
  });
7492
7579
  this._meshReplicator = new MeshEchoReplicator();
7493
7580
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
@@ -7506,7 +7593,7 @@ var ServiceContext = class extends Resource7 {
7506
7593
  await this._checkStorageVersion();
7507
7594
  log23("opening...", void 0, {
7508
7595
  F: __dxlog_file27,
7509
- L: 198,
7596
+ L: 199,
7510
7597
  S: this,
7511
7598
  C: (f, a) => f(...a)
7512
7599
  });
@@ -7514,7 +7601,7 @@ var ServiceContext = class extends Resource7 {
7514
7601
  id: this._instanceId
7515
7602
  }), {
7516
7603
  F: __dxlog_file27,
7517
- L: 199,
7604
+ L: 200,
7518
7605
  S: this,
7519
7606
  C: (f, a) => f(...a)
7520
7607
  });
@@ -7541,7 +7628,7 @@ var ServiceContext = class extends Resource7 {
7541
7628
  count: loadedInvitations.invitations?.length
7542
7629
  }, {
7543
7630
  F: __dxlog_file27,
7544
- L: 227,
7631
+ L: 228,
7545
7632
  S: this,
7546
7633
  C: (f, a) => f(...a)
7547
7634
  });
@@ -7549,13 +7636,13 @@ var ServiceContext = class extends Resource7 {
7549
7636
  id: this._instanceId
7550
7637
  }), {
7551
7638
  F: __dxlog_file27,
7552
- L: 229,
7639
+ L: 230,
7553
7640
  S: this,
7554
7641
  C: (f, a) => f(...a)
7555
7642
  });
7556
7643
  log23("opened", void 0, {
7557
7644
  F: __dxlog_file27,
7558
- L: 230,
7645
+ L: 231,
7559
7646
  S: this,
7560
7647
  C: (f, a) => f(...a)
7561
7648
  });
@@ -7563,7 +7650,7 @@ var ServiceContext = class extends Resource7 {
7563
7650
  async _close(ctx) {
7564
7651
  log23("closing...", void 0, {
7565
7652
  F: __dxlog_file27,
7566
- L: 234,
7653
+ L: 235,
7567
7654
  S: this,
7568
7655
  C: (f, a) => f(...a)
7569
7656
  });
@@ -7582,7 +7669,7 @@ var ServiceContext = class extends Resource7 {
7582
7669
  await this._edgeConnection?.close();
7583
7670
  log23("closed", void 0, {
7584
7671
  F: __dxlog_file27,
7585
- L: 250,
7672
+ L: 251,
7586
7673
  S: this,
7587
7674
  C: (f, a) => f(...a)
7588
7675
  });
@@ -7593,7 +7680,7 @@ var ServiceContext = class extends Resource7 {
7593
7680
  await identity.joinNetwork();
7594
7681
  await this._initialize(new Context9(void 0, {
7595
7682
  F: __dxlog_file27,
7596
- L: 257
7683
+ L: 258
7597
7684
  }));
7598
7685
  return identity;
7599
7686
  }
@@ -7604,7 +7691,7 @@ var ServiceContext = class extends Resource7 {
7604
7691
  const factory = this._handlerFactories.get(invitation.kind);
7605
7692
  invariant21(factory, `Unknown invitation kind: ${invitation.kind}`, {
7606
7693
  F: __dxlog_file27,
7607
- L: 266,
7694
+ L: 267,
7608
7695
  S: this,
7609
7696
  A: [
7610
7697
  "factory",
@@ -7630,7 +7717,7 @@ var ServiceContext = class extends Resource7 {
7630
7717
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
7631
7718
  await this._initialize(new Context9(void 0, {
7632
7719
  F: __dxlog_file27,
7633
- L: 285
7720
+ L: 286
7634
7721
  }));
7635
7722
  return identity;
7636
7723
  }
@@ -7644,7 +7731,7 @@ var ServiceContext = class extends Resource7 {
7644
7731
  async _initialize(ctx) {
7645
7732
  log23("initializing spaces...", void 0, {
7646
7733
  F: __dxlog_file27,
7647
- L: 300,
7734
+ L: 301,
7648
7735
  S: this,
7649
7736
  C: (f, a) => f(...a)
7650
7737
  });
@@ -7683,7 +7770,7 @@ var ServiceContext = class extends Resource7 {
7683
7770
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
7684
7771
  invariant21(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7685
7772
  F: __dxlog_file27,
7686
- L: 338,
7773
+ L: 339,
7687
7774
  S: this,
7688
7775
  A: [
7689
7776
  "this.dataSpaceManager",
@@ -7707,7 +7794,7 @@ var ServiceContext = class extends Resource7 {
7707
7794
  details: assertion
7708
7795
  }, {
7709
7796
  F: __dxlog_file27,
7710
- L: 354,
7797
+ L: 355,
7711
7798
  S: this,
7712
7799
  C: (f, a) => f(...a)
7713
7800
  });
@@ -7718,7 +7805,7 @@ var ServiceContext = class extends Resource7 {
7718
7805
  details: assertion
7719
7806
  }, {
7720
7807
  F: __dxlog_file27,
7721
- L: 358,
7808
+ L: 359,
7722
7809
  S: this,
7723
7810
  C: (f, a) => f(...a)
7724
7811
  });
@@ -7729,7 +7816,7 @@ var ServiceContext = class extends Resource7 {
7729
7816
  details: assertion
7730
7817
  }, {
7731
7818
  F: __dxlog_file27,
7732
- L: 363,
7819
+ L: 364,
7733
7820
  S: this,
7734
7821
  C: (f, a) => f(...a)
7735
7822
  });
@@ -7740,7 +7827,7 @@ var ServiceContext = class extends Resource7 {
7740
7827
  } catch (err) {
7741
7828
  log23.catch(err, void 0, {
7742
7829
  F: __dxlog_file27,
7743
- L: 369,
7830
+ L: 370,
7744
7831
  S: this,
7745
7832
  C: (f, a) => f(...a)
7746
7833
  });
@@ -7761,7 +7848,7 @@ var ServiceContext = class extends Resource7 {
7761
7848
  swarms: this.networkManager.topics
7762
7849
  }, {
7763
7850
  F: __dxlog_file27,
7764
- L: 383,
7851
+ L: 384,
7765
7852
  S: this,
7766
7853
  C: (f, a) => f(...a)
7767
7854
  });
@@ -7775,7 +7862,7 @@ var ServiceContext = class extends Resource7 {
7775
7862
  });
7776
7863
  invariant21(identity.deviceCredentialChain, void 0, {
7777
7864
  F: __dxlog_file27,
7778
- L: 402,
7865
+ L: 403,
7779
7866
  S: this,
7780
7867
  A: [
7781
7868
  "identity.deviceCredentialChain",
@@ -8085,7 +8172,7 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
8085
8172
 
8086
8173
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
8087
8174
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
8088
- import { Stream as Stream12 } from "@dxos/codec-protobuf";
8175
+ import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8089
8176
  import { invariant as invariant23 } from "@dxos/invariant";
8090
8177
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
8091
8178
  var __dxlog_file29 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
@@ -8175,7 +8262,7 @@ var DevicesServiceImpl = class {
8175
8262
 
8176
8263
  // packages/sdk/client-services/src/packlets/identity/contacts-service.ts
8177
8264
  import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask9, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
8178
- import { Stream as Stream13 } from "@dxos/codec-protobuf";
8265
+ import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
8179
8266
  import { PublicKey as PublicKey17 } from "@dxos/keys";
8180
8267
  import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
8181
8268
  var ContactsServiceImpl = class {
@@ -8258,7 +8345,7 @@ var ContactsServiceImpl = class {
8258
8345
 
8259
8346
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
8260
8347
  import { Event as Event10 } from "@dxos/async";
8261
- import { Stream as Stream14 } from "@dxos/codec-protobuf";
8348
+ import { Stream as Stream14 } from "@dxos/codec-protobuf/stream";
8262
8349
  import { PublicKey as PublicKey18 } from "@dxos/keys";
8263
8350
  import { getContextFromEntry, log as log25 } from "@dxos/log";
8264
8351
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
@@ -8381,7 +8468,7 @@ var shouldLog = (entry2, request) => {
8381
8468
  var LOG_PROCESSING = 0;
8382
8469
 
8383
8470
  // packages/sdk/client-services/src/packlets/network/network-service.ts
8384
- import { Stream as Stream15 } from "@dxos/codec-protobuf";
8471
+ import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
8385
8472
  var NetworkServiceImpl = class {
8386
8473
  constructor(networkManager, signalManager) {
8387
8474
  this.networkManager = networkManager;
@@ -8411,10 +8498,39 @@ var NetworkServiceImpl = class {
8411
8498
  async updateConfig(request) {
8412
8499
  await this.networkManager.setConnectionState(request.swarm);
8413
8500
  }
8501
+ async joinSwarm(request) {
8502
+ return this.signalManager.join(request);
8503
+ }
8504
+ async leaveSwarm(request) {
8505
+ return this.signalManager.leave(request);
8506
+ }
8507
+ subscribeSwarmState(request) {
8508
+ return new Stream15(({ next }) => {
8509
+ const unsubscribe = this.signalManager.swarmState?.on((state) => {
8510
+ if (request.topic.equals(state.swarmKey)) {
8511
+ next(state);
8512
+ }
8513
+ });
8514
+ return unsubscribe;
8515
+ });
8516
+ }
8517
+ async sendMessage(message) {
8518
+ return this.signalManager.sendMessage(message);
8519
+ }
8520
+ subscribeMessages(peer) {
8521
+ return new Stream15(({ next }) => {
8522
+ const unsubscribe = this.signalManager.onMessage.on((message) => {
8523
+ if (message.recipient.peerKey === peer.peerKey) {
8524
+ next(message);
8525
+ }
8526
+ });
8527
+ return unsubscribe;
8528
+ });
8529
+ }
8414
8530
  };
8415
8531
 
8416
8532
  // packages/sdk/client-services/src/packlets/system/system-service.ts
8417
- import { Stream as Stream16 } from "@dxos/codec-protobuf";
8533
+ import { Stream as Stream16 } from "@dxos/codec-protobuf/stream";
8418
8534
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
8419
8535
  import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
8420
8536
  var SystemServiceImpl = class {
@@ -8918,4 +9034,4 @@ export {
8918
9034
  importProfileData,
8919
9035
  ClientServicesHost
8920
9036
  };
8921
- //# sourceMappingURL=chunk-HGN7FHFK.mjs.map
9037
+ //# sourceMappingURL=chunk-2FL5LYPQ.mjs.map