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

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 (72) hide show
  1. package/dist/lib/browser/{chunk-27A4ATQX.mjs → chunk-RFZHCLFI.mjs} +105 -70
  2. package/dist/lib/browser/chunk-RFZHCLFI.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-WCTGAZLA.cjs} +140 -105
  7. package/dist/lib/node/chunk-WCTGAZLA.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-RSOLUJE6.mjs} +105 -70
  12. package/dist/lib/node-esm/chunk-RSOLUJE6.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-service.d.ts +1 -1
  37. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  38. package/dist/types/src/packlets/logging/logging-service.d.ts +1 -1
  39. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  40. package/dist/types/src/packlets/network/network-service.d.ts +9 -2
  41. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  42. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  43. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +3 -0
  44. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  45. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  46. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  47. package/dist/types/src/packlets/system/system-service.d.ts +1 -1
  48. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  49. package/dist/types/src/version.d.ts +1 -1
  50. package/dist/types/tsconfig.tsbuildinfo +1 -1
  51. package/package.json +38 -38
  52. package/src/packlets/agents/edge-agent-service.ts +1 -1
  53. package/src/packlets/devices/devices-service.ts +1 -1
  54. package/src/packlets/devtools/devtools.ts +1 -1
  55. package/src/packlets/devtools/feeds.ts +1 -1
  56. package/src/packlets/devtools/keys.ts +1 -1
  57. package/src/packlets/devtools/metadata.ts +1 -1
  58. package/src/packlets/devtools/network.ts +1 -1
  59. package/src/packlets/devtools/spaces.ts +1 -1
  60. package/src/packlets/identity/contacts-service.ts +1 -1
  61. package/src/packlets/identity/identity-service.ts +1 -1
  62. package/src/packlets/invitations/invitations-service.ts +1 -1
  63. package/src/packlets/logging/logging-service.ts +1 -1
  64. package/src/packlets/network/network-service.ts +39 -1
  65. package/src/packlets/services/service-context.ts +1 -0
  66. package/src/packlets/spaces/notarization-plugin.ts +32 -17
  67. package/src/packlets/spaces/spaces-service.ts +1 -1
  68. package/src/packlets/system/system-service.ts +1 -1
  69. package/src/version.ts +1 -1
  70. package/dist/lib/browser/chunk-27A4ATQX.mjs.map +0 -7
  71. package/dist/lib/node/chunk-7FKXMJDD.cjs.map +0 -7
  72. package/dist/lib/node-esm/chunk-HGN7FHFK.mjs.map +0 -7
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_7FKXMJDD_exports = {};
30
- __export(chunk_7FKXMJDD_exports, {
29
+ var chunk_WCTGAZLA_exports = {};
30
+ __export(chunk_WCTGAZLA_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -72,24 +72,24 @@ __export(chunk_7FKXMJDD_exports, {
72
72
  subscribeToSpaces: () => subscribeToSpaces,
73
73
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
74
74
  });
75
- module.exports = __toCommonJS(chunk_7FKXMJDD_exports);
75
+ module.exports = __toCommonJS(chunk_WCTGAZLA_exports);
76
76
  var import_async = require("@dxos/async");
77
- var import_codec_protobuf = require("@dxos/codec-protobuf");
77
+ var import_stream = require("@dxos/codec-protobuf/stream");
78
78
  var import_feed_store = require("@dxos/feed-store");
79
79
  var import_keys = require("@dxos/keys");
80
80
  var import_log = require("@dxos/log");
81
81
  var import_util = require("@dxos/util");
82
- var import_codec_protobuf2 = require("@dxos/codec-protobuf");
82
+ var import_stream2 = require("@dxos/codec-protobuf/stream");
83
83
  var import_context = require("@dxos/context");
84
84
  var import_keys2 = require("@dxos/keys");
85
- var import_codec_protobuf3 = require("@dxos/codec-protobuf");
85
+ var import_stream3 = require("@dxos/codec-protobuf/stream");
86
86
  var import_async2 = require("@dxos/async");
87
- var import_codec_protobuf4 = require("@dxos/codec-protobuf");
87
+ var import_stream4 = require("@dxos/codec-protobuf/stream");
88
88
  var import_async3 = require("@dxos/async");
89
- var import_codec_protobuf5 = require("@dxos/codec-protobuf");
90
- var import_codec_protobuf6 = require("@dxos/codec-protobuf");
89
+ var import_stream5 = require("@dxos/codec-protobuf/stream");
90
+ var import_stream6 = require("@dxos/codec-protobuf/stream");
91
91
  var import_async4 = require("@dxos/async");
92
- var import_codec_protobuf7 = require("@dxos/codec-protobuf");
92
+ var import_codec_protobuf = require("@dxos/codec-protobuf");
93
93
  var import_credentials = require("@dxos/credentials");
94
94
  var import_invariant = require("@dxos/invariant");
95
95
  var import_protocols = require("@dxos/protocols");
@@ -184,7 +184,7 @@ var import_debug2 = require("@dxos/debug");
184
184
  var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
185
185
  var import_timeframe3 = require("@dxos/timeframe");
186
186
  var import_async12 = require("@dxos/async");
187
- var import_codec_protobuf8 = require("@dxos/codec-protobuf");
187
+ var import_stream7 = require("@dxos/codec-protobuf/stream");
188
188
  var import_credentials13 = require("@dxos/credentials");
189
189
  var import_debug3 = require("@dxos/debug");
190
190
  var import_feed_store4 = require("@dxos/feed-store");
@@ -208,7 +208,7 @@ var import_timeframe4 = require("@dxos/timeframe");
208
208
  var import_tracing7 = require("@dxos/tracing");
209
209
  var import_util8 = require("@dxos/util");
210
210
  var import_async14 = require("@dxos/async");
211
- var import_codec_protobuf9 = require("@dxos/codec-protobuf");
211
+ var import_stream8 = require("@dxos/codec-protobuf/stream");
212
212
  var import_context9 = require("@dxos/context");
213
213
  var import_credentials16 = require("@dxos/credentials");
214
214
  var import_invariant10 = require("@dxos/invariant");
@@ -270,7 +270,7 @@ var import_keys13 = require("@dxos/keys");
270
270
  var import_log17 = require("@dxos/log");
271
271
  var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations");
272
272
  var import_util11 = require("@dxos/util");
273
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
273
+ var import_stream9 = require("@dxos/codec-protobuf/stream");
274
274
  var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
275
275
  var import_tracing9 = require("@dxos/tracing");
276
276
  var import_credentials18 = require("@dxos/credentials");
@@ -293,7 +293,7 @@ var import_credentials21 = require("@dxos/protocols/proto/dxos/halo/credentials"
293
293
  var import_invariant19 = require("@dxos/invariant");
294
294
  var import_lock_file = require("@dxos/lock-file");
295
295
  var import_log20 = require("@dxos/log");
296
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
296
+ var import_codec_protobuf2 = require("@dxos/codec-protobuf");
297
297
  var import_debug4 = require("@dxos/debug");
298
298
  var import_rpc = require("@dxos/rpc");
299
299
  var import_tracing10 = require("@dxos/tracing");
@@ -305,7 +305,7 @@ var import_log21 = require("@dxos/log");
305
305
  var import_protocols14 = require("@dxos/protocols");
306
306
  var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
307
307
  var import_metadata2 = require("@dxos/protocols/proto/dxos/echo/metadata");
308
- var import_codec_protobuf12 = require("@dxos/codec-protobuf");
308
+ var import_stream10 = require("@dxos/codec-protobuf/stream");
309
309
  var import_protocols15 = require("@dxos/protocols");
310
310
  var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
311
311
  var import_async22 = require("@dxos/async");
@@ -360,26 +360,26 @@ var import_services22 = require("@dxos/protocols/proto/dxos/client/services");
360
360
  var import_tracing12 = require("@dxos/tracing");
361
361
  var import_websocket_rpc = require("@dxos/websocket-rpc");
362
362
  var import_async24 = require("@dxos/async");
363
- var import_codec_protobuf13 = require("@dxos/codec-protobuf");
363
+ var import_stream11 = require("@dxos/codec-protobuf/stream");
364
364
  var import_invariant25 = require("@dxos/invariant");
365
365
  var import_services23 = require("@dxos/protocols/proto/dxos/client/services");
366
366
  var import_async25 = require("@dxos/async");
367
- var import_codec_protobuf14 = require("@dxos/codec-protobuf");
367
+ var import_stream12 = require("@dxos/codec-protobuf/stream");
368
368
  var import_keys20 = require("@dxos/keys");
369
369
  var import_util15 = require("@dxos/util");
370
370
  var import_async26 = require("@dxos/async");
371
- var import_codec_protobuf15 = require("@dxos/codec-protobuf");
371
+ var import_stream13 = require("@dxos/codec-protobuf/stream");
372
372
  var import_keys21 = require("@dxos/keys");
373
373
  var import_log26 = require("@dxos/log");
374
374
  var import_services24 = require("@dxos/protocols/proto/dxos/client/services");
375
375
  var import_util16 = require("@dxos/util");
376
- var import_codec_protobuf16 = require("@dxos/codec-protobuf");
377
- var import_codec_protobuf17 = require("@dxos/codec-protobuf");
376
+ var import_stream14 = require("@dxos/codec-protobuf/stream");
377
+ var import_stream15 = require("@dxos/codec-protobuf/stream");
378
378
  var import_services25 = require("@dxos/protocols/proto/dxos/client/services");
379
379
  var import_util17 = require("@dxos/util");
380
380
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/feeds.ts";
381
381
  var subscribeToFeeds = ({ feedStore, spaceManager }, { feedKeys }) => {
382
- return new import_codec_protobuf.Stream(({ next }) => {
382
+ return new import_stream.Stream(({ next }) => {
383
383
  const subscriptions = new import_async.EventSubscriptions();
384
384
  const feedMap = new import_util.ComplexMap(import_keys.PublicKey.hash);
385
385
  const update = () => {
@@ -438,7 +438,7 @@ var findFeedOwner = (spaceManager, feedKey) => {
438
438
  };
439
439
  };
440
440
  var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
441
- return new import_codec_protobuf.Stream(({ next }) => {
441
+ return new import_stream.Stream(({ next }) => {
442
442
  if (!feedKey) {
443
443
  return;
444
444
  }
@@ -482,7 +482,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
482
482
  });
483
483
  };
484
484
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/network.ts";
485
- var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf2.Stream(({ next, close }) => {
485
+ var subscribeToNetworkStatus = ({ signalManager }) => new import_stream2.Stream(({ next, close }) => {
486
486
  const update = () => {
487
487
  try {
488
488
  const status = signalManager.getStatus?.();
@@ -496,7 +496,7 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf2
496
496
  signalManager.statusChanged?.on(() => update());
497
497
  update();
498
498
  });
499
- var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf2.Stream(({ next }) => {
499
+ var subscribeToSignal = ({ signalManager }) => new import_stream2.Stream(({ next }) => {
500
500
  const ctx = new import_context.Context(void 0, {
501
501
  F: __dxlog_file2,
502
502
  L: 36
@@ -531,7 +531,7 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf2.Stream
531
531
  return ctx.dispose();
532
532
  };
533
533
  });
534
- var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf2.Stream(({ next, close }) => {
534
+ var subscribeToNetworkTopics = ({ networkManager }) => new import_stream2.Stream(({ next, close }) => {
535
535
  const update = () => {
536
536
  try {
537
537
  const topics = networkManager.topics;
@@ -549,7 +549,7 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
549
549
  networkManager.topicsUpdated.on(update);
550
550
  update();
551
551
  });
552
- var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf2.Stream(({ next }) => {
552
+ var subscribeToSwarmInfo = ({ networkManager }) => new import_stream2.Stream(({ next }) => {
553
553
  const update = () => {
554
554
  const info = networkManager.connectionLog?.swarms;
555
555
  if (info) {
@@ -574,7 +574,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
574
574
  };
575
575
  };
576
576
  var subscribeToSpaces = (context, { spaceKeys = [] }) => {
577
- return new import_codec_protobuf3.Stream(({ next }) => {
577
+ return new import_stream3.Stream(({ next }) => {
578
578
  let unsubscribe;
579
579
  const update = async () => {
580
580
  const spaces = [
@@ -606,7 +606,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
606
606
  };
607
607
  });
608
608
  };
609
- var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf5.Stream(({ next, ctx }) => {
609
+ var subscribeToKeyringKeys = ({ keyring }) => new import_stream5.Stream(({ next, ctx }) => {
610
610
  const update = async () => {
611
611
  next({
612
612
  keys: await keyring.list()
@@ -615,7 +615,7 @@ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf5.Stream(
615
615
  keyring.keysUpdate.on(ctx, update);
616
616
  (0, import_async3.scheduleTask)(ctx, update);
617
617
  });
618
- var subscribeToMetadata = ({ context }) => new import_codec_protobuf6.Stream(({ next, ctx }) => {
618
+ var subscribeToMetadata = ({ context }) => new import_stream6.Stream(({ next, ctx }) => {
619
619
  context.metadataStore.update.on(ctx, (data) => next({
620
620
  metadata: data
621
621
  }));
@@ -633,7 +633,7 @@ var DevtoolsServiceImpl = class {
633
633
  this.params = params;
634
634
  }
635
635
  events(request) {
636
- return new import_codec_protobuf4.Stream(({ next }) => {
636
+ return new import_stream4.Stream(({ next }) => {
637
637
  this.params.events.ready.on(() => {
638
638
  next({
639
639
  ready: {}
@@ -735,7 +735,7 @@ var DevtoolsServiceImpl = class {
735
735
  });
736
736
  }
737
737
  };
738
- var DXOS_VERSION = "0.7.5-main.9d26e3a";
738
+ var DXOS_VERSION = "0.7.5-main.9d2a38b";
739
739
  var getPlatform = () => {
740
740
  if (process.browser) {
741
741
  if (typeof window !== "undefined") {
@@ -788,7 +788,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
788
788
  "'SystemService is not available.'"
789
789
  ]
790
790
  });
791
- diagnostics.metrics = await (0, import_codec_protobuf7.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
791
+ diagnostics.metrics = await (0, import_codec_protobuf.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
792
792
  timeout: DEFAULT_TIMEOUT
793
793
  }).catch(() => void 0);
794
794
  })(),
@@ -803,14 +803,14 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
803
803
  spaceKey: identity.space.key,
804
804
  profile: identity.profileDocument
805
805
  };
806
- const { devices } = await (0, import_codec_protobuf7.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
806
+ const { devices } = await (0, import_codec_protobuf.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
807
807
  timeout: DEFAULT_TIMEOUT
808
808
  }).catch(() => void 0) ?? {};
809
809
  diagnostics.devices = devices;
810
810
  if (serviceContext.dataSpaceManager) {
811
811
  diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
812
812
  }
813
- const { feeds = [] } = await (0, import_codec_protobuf7.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
813
+ const { feeds = [] } = await (0, import_codec_protobuf.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
814
814
  timeout: DEFAULT_TIMEOUT
815
815
  }).catch(() => void 0) ?? {};
816
816
  diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
@@ -818,7 +818,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
818
818
  bytes,
819
819
  length
820
820
  }));
821
- const status = await (0, import_codec_protobuf7.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
821
+ const status = await (0, import_codec_protobuf.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
822
822
  timeout: DEFAULT_TIMEOUT
823
823
  }).catch(() => void 0);
824
824
  diagnostics.networkStatus = status;
@@ -1633,6 +1633,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1633
1633
  this._processedCredentials = new import_util5.ComplexSet(import_keys5.PublicKey.hash);
1634
1634
  this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys5.PublicKey.hash);
1635
1635
  this._activeEdgePollingIntervalHandle = void 0;
1636
+ this._activeEdgePollingEnabled = false;
1636
1637
  this._spaceId = params.spaceId;
1637
1638
  this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
1638
1639
  if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
@@ -1640,15 +1641,6 @@ var NotarizationPlugin = class extends import_context6.Resource {
1640
1641
  }
1641
1642
  }
1642
1643
  setActiveEdgePollingEnabled(enabled) {
1643
- (0, import_invariant5.invariant)(this.isOpen, void 0, {
1644
- F: __dxlog_file7,
1645
- L: 109,
1646
- S: this,
1647
- A: [
1648
- "this.isOpen",
1649
- ""
1650
- ]
1651
- });
1652
1644
  const client = this._edgeClient;
1653
1645
  (0, import_invariant5.invariant)(client, void 0, {
1654
1646
  F: __dxlog_file7,
@@ -1659,30 +1651,30 @@ var NotarizationPlugin = class extends import_context6.Resource {
1659
1651
  ""
1660
1652
  ]
1661
1653
  });
1662
- if (enabled && !this._activeEdgePollingIntervalHandle) {
1663
- this._activeEdgePollingIntervalHandle = setInterval(() => {
1664
- if (this._writer) {
1665
- this._notarizePendingEdgeCredentials(client, this._writer);
1666
- }
1667
- }, this._activeEdgePollingInterval);
1668
- } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1669
- clearInterval(this._activeEdgePollingIntervalHandle);
1670
- this._activeEdgePollingIntervalHandle = void 0;
1654
+ this._activeEdgePollingEnabled = enabled;
1655
+ if (this.isOpen) {
1656
+ if (enabled && !this._activeEdgePollingIntervalHandle) {
1657
+ this._startPeriodicEdgePolling(client);
1658
+ } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1659
+ this._stopPeriodicEdgePolling();
1660
+ }
1671
1661
  }
1672
1662
  }
1673
1663
  get hasWriter() {
1674
1664
  return !!this._writer;
1675
1665
  }
1676
1666
  async _open() {
1677
- if (this._edgeClient && this._writer) {
1678
- this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1667
+ if (this._edgeClient) {
1668
+ if (this._activeEdgePollingEnabled) {
1669
+ this._startPeriodicEdgePolling(this._edgeClient);
1670
+ }
1671
+ if (this._writer) {
1672
+ this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1673
+ }
1679
1674
  }
1680
1675
  }
1681
1676
  async _close() {
1682
- if (this._activeEdgePollingIntervalHandle) {
1683
- clearInterval(this._activeEdgePollingIntervalHandle);
1684
- this._activeEdgePollingIntervalHandle = void 0;
1685
- }
1677
+ this._stopPeriodicEdgePolling();
1686
1678
  await this._ctx.dispose();
1687
1679
  }
1688
1680
  /**
@@ -1860,10 +1852,23 @@ var NotarizationPlugin = class extends import_context6.Resource {
1860
1852
  ]
1861
1853
  });
1862
1854
  this._writer = writer;
1863
- if (this._edgeClient) {
1855
+ if (this._edgeClient && this.isOpen) {
1864
1856
  this._notarizePendingEdgeCredentials(this._edgeClient, writer);
1865
1857
  }
1866
1858
  }
1859
+ _startPeriodicEdgePolling(client) {
1860
+ this._activeEdgePollingIntervalHandle = setInterval(() => {
1861
+ if (this._writer) {
1862
+ this._notarizePendingEdgeCredentials(client, this._writer);
1863
+ }
1864
+ }, this._activeEdgePollingInterval);
1865
+ }
1866
+ _stopPeriodicEdgePolling() {
1867
+ if (this._activeEdgePollingIntervalHandle) {
1868
+ clearInterval(this._activeEdgePollingIntervalHandle);
1869
+ this._activeEdgePollingIntervalHandle = void 0;
1870
+ }
1871
+ }
1867
1872
  /**
1868
1873
  * The method is used only for adding agent feeds to spaces.
1869
1874
  * When an agent is created we can admit them into all the existing spaces. In case the operation fails
@@ -1882,7 +1887,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1882
1887
  if (!credentials.length) {
1883
1888
  (0, import_log5.log)("edge did not return credentials for notarization", void 0, {
1884
1889
  F: __dxlog_file7,
1885
- L: 296,
1890
+ L: 311,
1886
1891
  S: this,
1887
1892
  C: (f, a) => f(...a)
1888
1893
  });
@@ -1892,7 +1897,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1892
1897
  count: credentials.length
1893
1898
  }, {
1894
1899
  F: __dxlog_file7,
1895
- L: 300,
1900
+ L: 315,
1896
1901
  S: this,
1897
1902
  C: (f, a) => f(...a)
1898
1903
  });
@@ -1905,7 +1910,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1905
1910
  count: decodedCredentials.length
1906
1911
  }, {
1907
1912
  F: __dxlog_file7,
1908
- L: 309,
1913
+ L: 324,
1909
1914
  S: this,
1910
1915
  C: (f, a) => f(...a)
1911
1916
  });
@@ -1933,7 +1938,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1933
1938
  for (const credential of credentials) {
1934
1939
  (0, import_invariant5.invariant)(credential.id, "Credential must have an id", {
1935
1940
  F: __dxlog_file7,
1936
- L: 335,
1941
+ L: 350,
1937
1942
  S: this,
1938
1943
  A: [
1939
1944
  "credential.id",
@@ -1957,7 +1962,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1957
1962
  peer: extension.localPeerId
1958
1963
  }, {
1959
1964
  F: __dxlog_file7,
1960
- L: 350,
1965
+ L: 365,
1961
1966
  S: this,
1962
1967
  C: (f, a) => f(...a)
1963
1968
  });
@@ -1969,7 +1974,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1969
1974
  peer: extension.localPeerId
1970
1975
  }, {
1971
1976
  F: __dxlog_file7,
1972
- L: 355,
1977
+ L: 370,
1973
1978
  S: this,
1974
1979
  C: (f, a) => f(...a)
1975
1980
  });
@@ -1986,7 +1991,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1986
1991
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1987
1992
  }, {
1988
1993
  F: __dxlog_file7,
1989
- L: 367,
1994
+ L: 382,
1990
1995
  S: this,
1991
1996
  C: (f, a) => f(...a)
1992
1997
  });
@@ -2002,7 +2007,7 @@ var handleEdgeError = (error) => {
2002
2007
  if (!(error instanceof import_protocols4.EdgeCallFailedError) || error.errorData) {
2003
2008
  import_log5.log.catch(error, void 0, {
2004
2009
  F: __dxlog_file7,
2005
- L: 381,
2010
+ L: 396,
2006
2011
  S: void 0,
2007
2012
  C: (f, a) => f(...a)
2008
2013
  });
@@ -2011,7 +2016,7 @@ var handleEdgeError = (error) => {
2011
2016
  reason: error.reason
2012
2017
  }, {
2013
2018
  F: __dxlog_file7,
2014
- L: 383,
2019
+ L: 398,
2015
2020
  S: void 0,
2016
2021
  C: (f, a) => f(...a)
2017
2022
  });
@@ -2871,7 +2876,7 @@ var SpacesServiceImpl = class {
2871
2876
  await (0, import_feed_store4.writeMessages)(space.controlPipeline.writer, credentials);
2872
2877
  }
2873
2878
  querySpaces() {
2874
- return new import_codec_protobuf8.Stream(({ next, ctx }) => {
2879
+ return new import_stream7.Stream(({ next, ctx }) => {
2875
2880
  const scheduler = new import_async12.UpdateScheduler(ctx, async () => {
2876
2881
  const dataSpaceManager = await this._getDataSpaceManager();
2877
2882
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
@@ -2931,7 +2936,7 @@ var SpacesServiceImpl = class {
2931
2936
  await space.postMessage(getChannelId(channel), message);
2932
2937
  }
2933
2938
  subscribeMessages({ spaceKey, channel }) {
2934
- return new import_codec_protobuf8.Stream(({ ctx, next }) => {
2939
+ return new import_stream7.Stream(({ ctx, next }) => {
2935
2940
  (0, import_async12.scheduleTask)(ctx, async () => {
2936
2941
  const dataSpaceManager = await this._getDataSpaceManager();
2937
2942
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
@@ -2943,7 +2948,7 @@ var SpacesServiceImpl = class {
2943
2948
  });
2944
2949
  }
2945
2950
  queryCredentials({ spaceKey, noTail }) {
2946
- return new import_codec_protobuf8.Stream(({ ctx, next, close }) => {
2951
+ return new import_stream7.Stream(({ ctx, next, close }) => {
2947
2952
  const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2948
2953
  const processor = {
2949
2954
  processCredential: async (credential) => {
@@ -3901,7 +3906,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3901
3906
  await identity.updateDefaultSpace(space.id);
3902
3907
  }
3903
3908
  queryIdentity() {
3904
- return new import_codec_protobuf9.Stream(({ next }) => {
3909
+ return new import_stream8.Stream(({ next }) => {
3905
3910
  const emitNext = () => next({
3906
3911
  identity: this._getIdentity()
3907
3912
  });
@@ -6162,7 +6167,7 @@ var InvitationsServiceImpl = class {
6162
6167
  return {};
6163
6168
  }
6164
6169
  createInvitation(options) {
6165
- return new import_codec_protobuf10.Stream(({ next, close }) => {
6170
+ return new import_stream9.Stream(({ next, close }) => {
6166
6171
  void this._invitationsManager.createInvitation(options).then((invitation) => {
6167
6172
  import_tracing9.trace.metrics.increment("dxos.invitation.created");
6168
6173
  invitation.subscribe(next, close, close);
@@ -6171,7 +6176,7 @@ var InvitationsServiceImpl = class {
6171
6176
  }
6172
6177
  acceptInvitation(request) {
6173
6178
  const invitation = this._invitationsManager.acceptInvitation(request);
6174
- return new import_codec_protobuf10.Stream(({ next, close }) => {
6179
+ return new import_stream9.Stream(({ next, close }) => {
6175
6180
  invitation.subscribe(next, close, close);
6176
6181
  });
6177
6182
  }
@@ -6182,7 +6187,7 @@ var InvitationsServiceImpl = class {
6182
6187
  return this._invitationsManager.cancelInvitation(request);
6183
6188
  }
6184
6189
  queryInvitations() {
6185
- return new import_codec_protobuf10.Stream(({ next, ctx }) => {
6190
+ return new import_stream9.Stream(({ next, ctx }) => {
6186
6191
  this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
6187
6192
  next({
6188
6193
  action: import_services16.QueryInvitationsResponse.Action.ADDED,
@@ -6963,7 +6968,7 @@ var ClientRpcServer = class {
6963
6968
  const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
6964
6969
  this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
6965
6970
  if (this._handleStream) {
6966
- return import_codec_protobuf11.Stream.map(import_codec_protobuf11.Stream.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
6971
+ return import_codec_protobuf2.Stream.map(import_codec_protobuf2.Stream.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
6967
6972
  this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
6968
6973
  return data;
6969
6974
  });
@@ -7229,7 +7234,7 @@ var EdgeAgentServiceImpl = class {
7229
7234
  this._edgeConnection = _edgeConnection;
7230
7235
  }
7231
7236
  queryEdgeStatus() {
7232
- return new import_codec_protobuf12.Stream(({ ctx, next }) => {
7237
+ return new import_stream10.Stream(({ ctx, next }) => {
7233
7238
  next({
7234
7239
  status: import_services20.QueryEdgeStatusResponse.EdgeStatus.NOT_CONNECTED
7235
7240
  });
@@ -7250,7 +7255,7 @@ var EdgeAgentServiceImpl = class {
7250
7255
  return (await this._agentManagerProvider()).createAgent();
7251
7256
  }
7252
7257
  queryAgentStatus() {
7253
- return new import_codec_protobuf12.Stream(({ ctx, next }) => {
7258
+ return new import_stream10.Stream(({ ctx, next }) => {
7254
7259
  next({
7255
7260
  status: import_services20.QueryAgentStatusResponse.AgentStatus.UNKNOWN
7256
7261
  });
@@ -7498,7 +7503,8 @@ var ServiceContext = class extends import_context16.Resource {
7498
7503
  this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
7499
7504
  this.echoHost = new import_echo_pipeline4.EchoHost({
7500
7505
  kv: this.level,
7501
- peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex()
7506
+ peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
7507
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key
7502
7508
  });
7503
7509
  this._meshReplicator = new import_echo_pipeline4.MeshEchoReplicator();
7504
7510
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
@@ -7517,7 +7523,7 @@ var ServiceContext = class extends import_context16.Resource {
7517
7523
  await this._checkStorageVersion();
7518
7524
  (0, import_log22.log)("opening...", void 0, {
7519
7525
  F: __dxlog_file27,
7520
- L: 198,
7526
+ L: 199,
7521
7527
  S: this,
7522
7528
  C: (f, a) => f(...a)
7523
7529
  });
@@ -7525,7 +7531,7 @@ var ServiceContext = class extends import_context16.Resource {
7525
7531
  id: this._instanceId
7526
7532
  }), {
7527
7533
  F: __dxlog_file27,
7528
- L: 199,
7534
+ L: 200,
7529
7535
  S: this,
7530
7536
  C: (f, a) => f(...a)
7531
7537
  });
@@ -7552,7 +7558,7 @@ var ServiceContext = class extends import_context16.Resource {
7552
7558
  count: loadedInvitations.invitations?.length
7553
7559
  }, {
7554
7560
  F: __dxlog_file27,
7555
- L: 227,
7561
+ L: 228,
7556
7562
  S: this,
7557
7563
  C: (f, a) => f(...a)
7558
7564
  });
@@ -7560,13 +7566,13 @@ var ServiceContext = class extends import_context16.Resource {
7560
7566
  id: this._instanceId
7561
7567
  }), {
7562
7568
  F: __dxlog_file27,
7563
- L: 229,
7569
+ L: 230,
7564
7570
  S: this,
7565
7571
  C: (f, a) => f(...a)
7566
7572
  });
7567
7573
  (0, import_log22.log)("opened", void 0, {
7568
7574
  F: __dxlog_file27,
7569
- L: 230,
7575
+ L: 231,
7570
7576
  S: this,
7571
7577
  C: (f, a) => f(...a)
7572
7578
  });
@@ -7574,7 +7580,7 @@ var ServiceContext = class extends import_context16.Resource {
7574
7580
  async _close(ctx) {
7575
7581
  (0, import_log22.log)("closing...", void 0, {
7576
7582
  F: __dxlog_file27,
7577
- L: 234,
7583
+ L: 235,
7578
7584
  S: this,
7579
7585
  C: (f, a) => f(...a)
7580
7586
  });
@@ -7593,7 +7599,7 @@ var ServiceContext = class extends import_context16.Resource {
7593
7599
  await this._edgeConnection?.close();
7594
7600
  (0, import_log22.log)("closed", void 0, {
7595
7601
  F: __dxlog_file27,
7596
- L: 250,
7602
+ L: 251,
7597
7603
  S: this,
7598
7604
  C: (f, a) => f(...a)
7599
7605
  });
@@ -7604,7 +7610,7 @@ var ServiceContext = class extends import_context16.Resource {
7604
7610
  await identity.joinNetwork();
7605
7611
  await this._initialize(new import_context16.Context(void 0, {
7606
7612
  F: __dxlog_file27,
7607
- L: 257
7613
+ L: 258
7608
7614
  }));
7609
7615
  return identity;
7610
7616
  }
@@ -7615,7 +7621,7 @@ var ServiceContext = class extends import_context16.Resource {
7615
7621
  const factory = this._handlerFactories.get(invitation.kind);
7616
7622
  (0, import_invariant21.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
7617
7623
  F: __dxlog_file27,
7618
- L: 266,
7624
+ L: 267,
7619
7625
  S: this,
7620
7626
  A: [
7621
7627
  "factory",
@@ -7641,7 +7647,7 @@ var ServiceContext = class extends import_context16.Resource {
7641
7647
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
7642
7648
  await this._initialize(new import_context16.Context(void 0, {
7643
7649
  F: __dxlog_file27,
7644
- L: 285
7650
+ L: 286
7645
7651
  }));
7646
7652
  return identity;
7647
7653
  }
@@ -7655,7 +7661,7 @@ var ServiceContext = class extends import_context16.Resource {
7655
7661
  async _initialize(ctx) {
7656
7662
  (0, import_log22.log)("initializing spaces...", void 0, {
7657
7663
  F: __dxlog_file27,
7658
- L: 300,
7664
+ L: 301,
7659
7665
  S: this,
7660
7666
  C: (f, a) => f(...a)
7661
7667
  });
@@ -7694,7 +7700,7 @@ var ServiceContext = class extends import_context16.Resource {
7694
7700
  this._handlerFactories.set(import_services21.Invitation.Kind.SPACE, (invitation) => {
7695
7701
  (0, import_invariant21.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7696
7702
  F: __dxlog_file27,
7697
- L: 338,
7703
+ L: 339,
7698
7704
  S: this,
7699
7705
  A: [
7700
7706
  "this.dataSpaceManager",
@@ -7718,7 +7724,7 @@ var ServiceContext = class extends import_context16.Resource {
7718
7724
  details: assertion
7719
7725
  }, {
7720
7726
  F: __dxlog_file27,
7721
- L: 354,
7727
+ L: 355,
7722
7728
  S: this,
7723
7729
  C: (f, a) => f(...a)
7724
7730
  });
@@ -7729,7 +7735,7 @@ var ServiceContext = class extends import_context16.Resource {
7729
7735
  details: assertion
7730
7736
  }, {
7731
7737
  F: __dxlog_file27,
7732
- L: 358,
7738
+ L: 359,
7733
7739
  S: this,
7734
7740
  C: (f, a) => f(...a)
7735
7741
  });
@@ -7740,7 +7746,7 @@ var ServiceContext = class extends import_context16.Resource {
7740
7746
  details: assertion
7741
7747
  }, {
7742
7748
  F: __dxlog_file27,
7743
- L: 363,
7749
+ L: 364,
7744
7750
  S: this,
7745
7751
  C: (f, a) => f(...a)
7746
7752
  });
@@ -7751,7 +7757,7 @@ var ServiceContext = class extends import_context16.Resource {
7751
7757
  } catch (err) {
7752
7758
  import_log22.log.catch(err, void 0, {
7753
7759
  F: __dxlog_file27,
7754
- L: 369,
7760
+ L: 370,
7755
7761
  S: this,
7756
7762
  C: (f, a) => f(...a)
7757
7763
  });
@@ -7772,7 +7778,7 @@ var ServiceContext = class extends import_context16.Resource {
7772
7778
  swarms: this.networkManager.topics
7773
7779
  }, {
7774
7780
  F: __dxlog_file27,
7775
- L: 383,
7781
+ L: 384,
7776
7782
  S: this,
7777
7783
  C: (f, a) => f(...a)
7778
7784
  });
@@ -7786,7 +7792,7 @@ var ServiceContext = class extends import_context16.Resource {
7786
7792
  });
7787
7793
  (0, import_invariant21.invariant)(identity.deviceCredentialChain, void 0, {
7788
7794
  F: __dxlog_file27,
7789
- L: 402,
7795
+ L: 403,
7790
7796
  S: this,
7791
7797
  A: [
7792
7798
  "identity.deviceCredentialChain",
@@ -8062,7 +8068,7 @@ var DevicesServiceImpl = class {
8062
8068
  return this._identityManager.updateDeviceProfile(profile);
8063
8069
  }
8064
8070
  queryDevices() {
8065
- return new import_codec_protobuf13.Stream(({ next }) => {
8071
+ return new import_stream11.Stream(({ next }) => {
8066
8072
  const update = () => {
8067
8073
  const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
8068
8074
  if (!deviceKeys) {
@@ -8184,7 +8190,7 @@ var ContactsServiceImpl = class {
8184
8190
  }
8185
8191
  queryContacts() {
8186
8192
  const subscribedSpaceKeySet = new import_util15.ComplexSet(import_keys20.PublicKey.hash);
8187
- return new import_codec_protobuf14.Stream(({ next, ctx }) => {
8193
+ return new import_stream12.Stream(({ next, ctx }) => {
8188
8194
  const pushUpdateTask = new import_async25.UpdateScheduler(ctx, async () => {
8189
8195
  const contacts = await this.getContacts();
8190
8196
  next(contacts);
@@ -8253,7 +8259,7 @@ var LoggingServiceImpl = class {
8253
8259
  stats: (0, import_util16.numericalValues)(events, "duration")
8254
8260
  };
8255
8261
  };
8256
- return new import_codec_protobuf15.Stream(({ next }) => {
8262
+ return new import_stream13.Stream(({ next }) => {
8257
8263
  const update = () => {
8258
8264
  const metrics2 = {
8259
8265
  timestamp: /* @__PURE__ */ new Date(),
@@ -8275,7 +8281,7 @@ var LoggingServiceImpl = class {
8275
8281
  });
8276
8282
  }
8277
8283
  queryLogs(request) {
8278
- return new import_codec_protobuf15.Stream(({ ctx, next }) => {
8284
+ return new import_stream13.Stream(({ ctx, next }) => {
8279
8285
  const handler = (entry2) => {
8280
8286
  if (LOG_PROCESSING > 0) {
8281
8287
  return;
@@ -8335,7 +8341,7 @@ var NetworkServiceImpl = class {
8335
8341
  this.signalManager = signalManager;
8336
8342
  }
8337
8343
  queryStatus() {
8338
- return new import_codec_protobuf16.Stream(({ next }) => {
8344
+ return new import_stream14.Stream(({ next }) => {
8339
8345
  const update = () => {
8340
8346
  next({
8341
8347
  swarm: this.networkManager.connectionState,
@@ -8358,6 +8364,35 @@ var NetworkServiceImpl = class {
8358
8364
  async updateConfig(request) {
8359
8365
  await this.networkManager.setConnectionState(request.swarm);
8360
8366
  }
8367
+ async joinSwarm(request) {
8368
+ return this.signalManager.join(request);
8369
+ }
8370
+ async leaveSwarm(request) {
8371
+ return this.signalManager.leave(request);
8372
+ }
8373
+ subscribeSwarmState(request) {
8374
+ return new import_stream14.Stream(({ next }) => {
8375
+ const unsubscribe = this.signalManager.swarmState?.on((state) => {
8376
+ if (request.topic.equals(state.swarmKey)) {
8377
+ next(state);
8378
+ }
8379
+ });
8380
+ return unsubscribe;
8381
+ });
8382
+ }
8383
+ async sendMessage(message) {
8384
+ return this.signalManager.sendMessage(message);
8385
+ }
8386
+ subscribeMessages(peer) {
8387
+ return new import_stream14.Stream(({ next }) => {
8388
+ const unsubscribe = this.signalManager.onMessage.on((message) => {
8389
+ if (message.recipient.peerKey === peer.peerKey) {
8390
+ next(message);
8391
+ }
8392
+ });
8393
+ return unsubscribe;
8394
+ });
8395
+ }
8361
8396
  };
8362
8397
  var SystemServiceImpl = class {
8363
8398
  constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
@@ -8392,7 +8427,7 @@ var SystemServiceImpl = class {
8392
8427
  }
8393
8428
  // TODO(burdon): Standardize interval option in stream request?
8394
8429
  queryStatus({ interval = 3e3 } = {}) {
8395
- return new import_codec_protobuf17.Stream(({ next }) => {
8430
+ return new import_stream15.Stream(({ next }) => {
8396
8431
  const update = () => {
8397
8432
  next({
8398
8433
  status: this._getCurrentStatus()
@@ -8858,4 +8893,4 @@ ClientServicesHost = _ts_decorate11([
8858
8893
  subscribeToSpaces,
8859
8894
  subscribeToSwarmInfo
8860
8895
  });
8861
- //# sourceMappingURL=chunk-7FKXMJDD.cjs.map
8896
+ //# sourceMappingURL=chunk-WCTGAZLA.cjs.map