@dxos/client-services 0.6.12-staging.e11e696 → 0.6.13-main.548ca8d

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 (57) hide show
  1. package/dist/lib/browser/{chunk-67FEJJ6J.mjs → chunk-UEQIHAL2.mjs} +868 -619
  2. package/dist/lib/browser/chunk-UEQIHAL2.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 +4 -2
  6. package/dist/lib/browser/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-2KIDYJ7O.cjs → chunk-MA5EWTRH.cjs} +900 -655
  8. package/dist/lib/node/chunk-MA5EWTRH.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +45 -45
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/testing/index.cjs +11 -9
  12. package/dist/lib/node/testing/index.cjs.map +3 -3
  13. package/dist/lib/node-esm/{chunk-36ZRRDQI.mjs → chunk-AIBLDI4U.mjs} +859 -610
  14. package/dist/lib/node-esm/chunk-AIBLDI4U.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +1 -1
  16. package/dist/lib/node-esm/meta.json +1 -1
  17. package/dist/lib/node-esm/testing/index.mjs +4 -2
  18. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  19. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts +30 -0
  20. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -0
  21. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts +2 -1
  22. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
  23. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts +2 -1
  24. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  25. package/dist/types/src/packlets/invitations/invitation-state.d.ts +19 -0
  26. package/dist/types/src/packlets/invitations/invitation-state.d.ts.map +1 -0
  27. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +8 -8
  28. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  29. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  30. package/dist/types/src/packlets/services/service-context.d.ts +2 -3
  31. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  32. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +2 -0
  33. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  34. package/dist/types/src/packlets/spaces/data-space.d.ts +1 -0
  35. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  36. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  37. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  38. package/dist/types/src/version.d.ts +1 -1
  39. package/dist/types/src/version.d.ts.map +1 -1
  40. package/package.json +38 -38
  41. package/src/packlets/invitations/edge-invitation-handler.ts +184 -0
  42. package/src/packlets/invitations/invitation-guest-extenstion.ts +8 -4
  43. package/src/packlets/invitations/invitation-host-extension.ts +8 -4
  44. package/src/packlets/invitations/invitation-state.ts +111 -0
  45. package/src/packlets/invitations/invitations-handler.test.ts +2 -2
  46. package/src/packlets/invitations/invitations-handler.ts +23 -92
  47. package/src/packlets/invitations/space-invitation-protocol.ts +4 -0
  48. package/src/packlets/services/service-context.ts +4 -3
  49. package/src/packlets/spaces/data-space-manager.ts +31 -3
  50. package/src/packlets/spaces/data-space.ts +4 -0
  51. package/src/packlets/spaces/edge-feed-replicator.test.ts +2 -0
  52. package/src/packlets/spaces/spaces-service.ts +6 -1
  53. package/src/packlets/testing/test-builder.ts +1 -1
  54. package/src/version.ts +1 -1
  55. package/dist/lib/browser/chunk-67FEJJ6J.mjs.map +0 -7
  56. package/dist/lib/node/chunk-2KIDYJ7O.cjs.map +0 -7
  57. package/dist/lib/node-esm/chunk-36ZRRDQI.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_2KIDYJ7O_exports = {};
30
- __export(chunk_2KIDYJ7O_exports, {
29
+ var chunk_MA5EWTRH_exports = {};
30
+ __export(chunk_MA5EWTRH_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -70,7 +70,7 @@ __export(chunk_2KIDYJ7O_exports, {
70
70
  subscribeToSpaces: () => subscribeToSpaces,
71
71
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
72
72
  });
73
- module.exports = __toCommonJS(chunk_2KIDYJ7O_exports);
73
+ module.exports = __toCommonJS(chunk_MA5EWTRH_exports);
74
74
  var import_async = require("@dxos/async");
75
75
  var import_codec_protobuf = require("@dxos/codec-protobuf");
76
76
  var import_feed_store = require("@dxos/feed-store");
@@ -177,6 +177,7 @@ var import_keys8 = require("@dxos/keys");
177
177
  var import_log9 = require("@dxos/log");
178
178
  var import_protocols5 = require("@dxos/protocols");
179
179
  var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
180
+ var import_metadata = require("@dxos/protocols/proto/dxos/echo/metadata");
180
181
  var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
181
182
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
182
183
  var import_tracing5 = require("@dxos/tracing");
@@ -236,117 +237,128 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
236
237
  var import_tracing8 = require("@dxos/tracing");
237
238
  var import_util10 = require("@dxos/util");
238
239
  var import_async16 = require("@dxos/async");
239
- var import_context11 = require("@dxos/context");
240
+ var import_crypto2 = require("@dxos/crypto");
240
241
  var import_invariant13 = require("@dxos/invariant");
242
+ var import_keys11 = require("@dxos/keys");
241
243
  var import_log14 = require("@dxos/log");
242
244
  var import_protocols10 = require("@dxos/protocols");
243
245
  var import_proto3 = require("@dxos/protocols/proto");
244
- var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
245
- var import_teleport2 = require("@dxos/teleport");
246
- var import_context12 = require("@dxos/context");
247
246
  var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
247
+ var import_context11 = require("@dxos/context");
248
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
248
249
  var import_async17 = require("@dxos/async");
249
- var import_context13 = require("@dxos/context");
250
- var import_crypto2 = require("@dxos/crypto");
250
+ var import_context12 = require("@dxos/context");
251
251
  var import_invariant14 = require("@dxos/invariant");
252
- var import_keys11 = require("@dxos/keys");
253
252
  var import_log15 = require("@dxos/log");
254
253
  var import_protocols11 = require("@dxos/protocols");
255
254
  var import_proto4 = require("@dxos/protocols/proto");
256
- var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
257
- var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
258
- var import_teleport3 = require("@dxos/teleport");
255
+ var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
256
+ var import_teleport2 = require("@dxos/teleport");
257
+ var import_async18 = require("@dxos/async");
258
+ var import_context13 = require("@dxos/context");
259
+ var import_crypto3 = require("@dxos/crypto");
259
260
  var import_invariant15 = require("@dxos/invariant");
260
261
  var import_keys12 = require("@dxos/keys");
261
262
  var import_log16 = require("@dxos/log");
263
+ var import_protocols12 = require("@dxos/protocols");
264
+ var import_proto5 = require("@dxos/protocols/proto");
265
+ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
266
+ var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
267
+ var import_teleport3 = require("@dxos/teleport");
268
+ var import_async19 = require("@dxos/async");
269
+ var import_log17 = require("@dxos/log");
270
+ var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
271
+ var import_invariant16 = require("@dxos/invariant");
272
+ var import_keys13 = require("@dxos/keys");
273
+ var import_log18 = require("@dxos/log");
262
274
  var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations");
263
275
  var import_util11 = require("@dxos/util");
264
276
  var import_codec_protobuf10 = require("@dxos/codec-protobuf");
265
- var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
277
+ var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
266
278
  var import_credentials17 = require("@dxos/credentials");
267
279
  var import_feed_store5 = require("@dxos/feed-store");
268
- var import_invariant16 = require("@dxos/invariant");
269
- var import_log17 = require("@dxos/log");
270
- var import_protocols12 = require("@dxos/protocols");
271
- var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
280
+ var import_invariant17 = require("@dxos/invariant");
281
+ var import_log19 = require("@dxos/log");
282
+ var import_protocols13 = require("@dxos/protocols");
283
+ var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
272
284
  var import_credentials18 = require("@dxos/protocols/proto/dxos/halo/credentials");
273
- var import_async18 = require("@dxos/async");
285
+ var import_async20 = require("@dxos/async");
274
286
  var import_client_protocol6 = require("@dxos/client-protocol");
275
287
  var import_context14 = require("@dxos/context");
276
288
  var import_credentials19 = require("@dxos/credentials");
277
289
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
278
- var import_invariant17 = require("@dxos/invariant");
279
- var import_keys13 = require("@dxos/keys");
280
- var import_log18 = require("@dxos/log");
281
- var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
282
- var import_credentials20 = require("@dxos/protocols/proto/dxos/halo/credentials");
283
290
  var import_invariant18 = require("@dxos/invariant");
291
+ var import_keys14 = require("@dxos/keys");
292
+ var import_log20 = require("@dxos/log");
293
+ var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
294
+ var import_credentials20 = require("@dxos/protocols/proto/dxos/halo/credentials");
295
+ var import_invariant19 = require("@dxos/invariant");
284
296
  var import_lock_file = require("@dxos/lock-file");
285
- var import_log19 = require("@dxos/log");
297
+ var import_log21 = require("@dxos/log");
286
298
  var import_codec_protobuf11 = require("@dxos/codec-protobuf");
287
299
  var import_debug5 = require("@dxos/debug");
288
300
  var import_rpc = require("@dxos/rpc");
289
301
  var import_tracing9 = require("@dxos/tracing");
290
- var import_async19 = require("@dxos/async");
302
+ var import_async21 = require("@dxos/async");
291
303
  var import_context15 = require("@dxos/context");
292
304
  var import_credentials21 = require("@dxos/credentials");
293
305
  var import_debug6 = require("@dxos/debug");
294
306
  var import_echo_pipeline5 = require("@dxos/echo-pipeline");
295
307
  var import_edge_client2 = require("@dxos/edge-client");
296
308
  var import_feed_store6 = require("@dxos/feed-store");
297
- var import_invariant19 = require("@dxos/invariant");
309
+ var import_invariant20 = require("@dxos/invariant");
298
310
  var import_keyring = require("@dxos/keyring");
299
- var import_keys14 = require("@dxos/keys");
300
- var import_log20 = require("@dxos/log");
301
- var import_protocols13 = require("@dxos/protocols");
302
- var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
311
+ var import_keys15 = require("@dxos/keys");
312
+ var import_log22 = require("@dxos/log");
313
+ var import_protocols14 = require("@dxos/protocols");
314
+ var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
303
315
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
304
316
  var import_tracing10 = require("@dxos/tracing");
305
317
  var import_util12 = require("@dxos/util");
306
- var import_protocols14 = require("@dxos/protocols");
318
+ var import_protocols15 = require("@dxos/protocols");
307
319
  var import_config2 = require("@dxos/protocols/proto/dxos/config");
308
320
  var import_random_access_storage = require("@dxos/random-access-storage");
309
321
  var import_client_protocol7 = require("@dxos/client-protocol");
310
322
  var import_config3 = require("@dxos/protocols/proto/dxos/config");
311
323
  var import_util13 = require("@dxos/util");
312
324
  var import_node_path = __toESM(require("node:path"));
313
- var import_keys15 = require("@dxos/keys");
325
+ var import_keys16 = require("@dxos/keys");
314
326
  var import_kv_store = require("@dxos/kv-store");
315
327
  var import_automerge_repo = require("@dxos/automerge/automerge-repo");
316
- var import_invariant20 = require("@dxos/invariant");
317
- var import_log21 = require("@dxos/log");
318
- var import_protocols15 = require("@dxos/protocols");
328
+ var import_invariant21 = require("@dxos/invariant");
329
+ var import_log23 = require("@dxos/log");
330
+ var import_protocols16 = require("@dxos/protocols");
319
331
  var import_util14 = require("@dxos/util");
320
- var import_async20 = require("@dxos/async");
332
+ var import_async22 = require("@dxos/async");
321
333
  var import_client_protocol8 = require("@dxos/client-protocol");
322
334
  var import_context16 = require("@dxos/context");
323
335
  var import_edge_client3 = require("@dxos/edge-client");
324
- var import_invariant21 = require("@dxos/invariant");
325
- var import_keys16 = require("@dxos/keys");
326
- var import_log22 = require("@dxos/log");
336
+ var import_invariant22 = require("@dxos/invariant");
337
+ var import_keys17 = require("@dxos/keys");
338
+ var import_log24 = require("@dxos/log");
327
339
  var import_messaging = require("@dxos/messaging");
328
340
  var import_network_manager2 = require("@dxos/network-manager");
329
- var import_protocols16 = require("@dxos/protocols");
330
- var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
341
+ var import_protocols17 = require("@dxos/protocols");
342
+ var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
331
343
  var import_tracing11 = require("@dxos/tracing");
332
344
  var import_websocket_rpc = require("@dxos/websocket-rpc");
333
- var import_async21 = require("@dxos/async");
345
+ var import_async23 = require("@dxos/async");
334
346
  var import_codec_protobuf12 = require("@dxos/codec-protobuf");
335
- var import_invariant22 = require("@dxos/invariant");
336
- var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
337
- var import_async22 = require("@dxos/async");
347
+ var import_invariant23 = require("@dxos/invariant");
348
+ var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
349
+ var import_async24 = require("@dxos/async");
338
350
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
339
- var import_keys17 = require("@dxos/keys");
351
+ var import_keys18 = require("@dxos/keys");
340
352
  var import_util15 = require("@dxos/util");
341
- var import_async23 = require("@dxos/async");
353
+ var import_async25 = require("@dxos/async");
342
354
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
343
- var import_keys18 = require("@dxos/keys");
344
- var import_log23 = require("@dxos/log");
345
- var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
355
+ var import_keys19 = require("@dxos/keys");
356
+ var import_log25 = require("@dxos/log");
357
+ var import_services22 = require("@dxos/protocols/proto/dxos/client/services");
346
358
  var import_util16 = require("@dxos/util");
347
359
  var import_codec_protobuf15 = require("@dxos/codec-protobuf");
348
360
  var import_codec_protobuf16 = require("@dxos/codec-protobuf");
349
- var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
361
+ var import_services23 = require("@dxos/protocols/proto/dxos/client/services");
350
362
  var import_util17 = require("@dxos/util");
351
363
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/feeds.ts";
352
364
  var subscribeToFeeds = ({ feedStore, spaceManager }, { feedKeys }) => {
@@ -706,7 +718,7 @@ var DevtoolsServiceImpl = class {
706
718
  });
707
719
  }
708
720
  };
709
- var DXOS_VERSION = "0.6.12-staging.e11e696";
721
+ var DXOS_VERSION = "0.6.13-main.548ca8d";
710
722
  var getPlatform = () => {
711
723
  if (process.browser) {
712
724
  if (typeof window !== "undefined") {
@@ -2541,12 +2553,36 @@ var DataSpaceManager = class extends import_context7.Resource {
2541
2553
  }
2542
2554
  });
2543
2555
  }
2556
+ async setSpaceEdgeReplicationSetting(spaceKey, setting) {
2557
+ const space = this._spaces.get(spaceKey);
2558
+ (0, import_invariant7.invariant)(space, "Space not found.", {
2559
+ F: __dxlog_file9,
2560
+ L: 399,
2561
+ S: this,
2562
+ A: [
2563
+ "space",
2564
+ "'Space not found.'"
2565
+ ]
2566
+ });
2567
+ await this._metadataStore.setSpaceEdgeReplicationSetting(spaceKey, setting);
2568
+ if (space.isOpen) {
2569
+ switch (setting) {
2570
+ case import_metadata.EdgeReplicationSetting.DISABLED:
2571
+ await this._echoEdgeReplicator?.disconnectFromSpace(space.id);
2572
+ break;
2573
+ case import_metadata.EdgeReplicationSetting.ENABLED:
2574
+ await this._echoEdgeReplicator?.connectToSpace(space.id);
2575
+ break;
2576
+ }
2577
+ }
2578
+ space.stateUpdate.emit();
2579
+ }
2544
2580
  async _constructSpace(metadata) {
2545
2581
  (0, import_log9.log)("construct space", {
2546
2582
  metadata
2547
2583
  }, {
2548
2584
  F: __dxlog_file9,
2549
- L: 398,
2585
+ L: 418,
2550
2586
  S: this,
2551
2587
  C: (f, a) => f(...a)
2552
2588
  });
@@ -2590,7 +2626,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2590
2626
  err
2591
2627
  }, {
2592
2628
  F: __dxlog_file9,
2593
- L: 440,
2629
+ L: 460,
2594
2630
  S: this,
2595
2631
  C: (f, a) => f(...a)
2596
2632
  });
@@ -2600,7 +2636,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2600
2636
  onAuthFailure: () => {
2601
2637
  import_log9.log.warn("auth failure", void 0, {
2602
2638
  F: __dxlog_file9,
2603
- L: 445,
2639
+ L: 465,
2604
2640
  S: this,
2605
2641
  C: (f, a) => f(...a)
2606
2642
  });
@@ -2633,7 +2669,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2633
2669
  space: space.key
2634
2670
  }, {
2635
2671
  F: __dxlog_file9,
2636
- L: 472,
2672
+ L: 492,
2637
2673
  S: this,
2638
2674
  C: (f, a) => f(...a)
2639
2675
  });
@@ -2644,7 +2680,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2644
2680
  open: this._lifecycleState === import_context7.LifecycleState.OPEN
2645
2681
  }, {
2646
2682
  F: __dxlog_file9,
2647
- L: 475,
2683
+ L: 495,
2648
2684
  S: this,
2649
2685
  C: (f, a) => f(...a)
2650
2686
  });
@@ -2663,7 +2699,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2663
2699
  space: space.key
2664
2700
  }, {
2665
2701
  F: __dxlog_file9,
2666
- L: 483,
2702
+ L: 503,
2667
2703
  S: this,
2668
2704
  C: (f, a) => f(...a)
2669
2705
  });
@@ -2675,10 +2711,25 @@ var DataSpaceManager = class extends import_context7.Resource {
2675
2711
  edgeFeatures: this._edgeFeatures
2676
2712
  });
2677
2713
  dataSpace.postOpen.append(async () => {
2678
- await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2714
+ const setting = dataSpace.getEdgeReplicationSetting();
2715
+ if (setting === import_metadata.EdgeReplicationSetting.ENABLED) {
2716
+ await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2717
+ } else if (this._echoEdgeReplicator) {
2718
+ (0, import_log9.log)("not connecting EchoEdgeReplicator because of EdgeReplicationSetting", {
2719
+ spaceId: dataSpace.id
2720
+ }, {
2721
+ F: __dxlog_file9,
2722
+ L: 516,
2723
+ S: this,
2724
+ C: (f, a) => f(...a)
2725
+ });
2726
+ }
2679
2727
  });
2680
2728
  dataSpace.preClose.append(async () => {
2681
- await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2729
+ const setting = dataSpace.getEdgeReplicationSetting();
2730
+ if (setting === import_metadata.EdgeReplicationSetting.ENABLED) {
2731
+ await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2732
+ }
2682
2733
  });
2683
2734
  presence.newPeer.on((peerState) => {
2684
2735
  if (dataSpace.state === import_services6.SpaceState.SPACE_READY) {
@@ -2698,7 +2749,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2698
2749
  space: space.key
2699
2750
  }, {
2700
2751
  F: __dxlog_file9,
2701
- L: 515,
2752
+ L: 543,
2702
2753
  S: this,
2703
2754
  C: (f, a) => f(...a)
2704
2755
  });
@@ -2731,7 +2782,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2731
2782
  closedSessions
2732
2783
  }, {
2733
2784
  F: __dxlog_file9,
2734
- L: 541,
2785
+ L: 569,
2735
2786
  S: this,
2736
2787
  C: (f, a) => f(...a)
2737
2788
  });
@@ -2746,7 +2797,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2746
2797
  peerId: peerState.peerId
2747
2798
  }, {
2748
2799
  F: __dxlog_file9,
2749
- L: 555,
2800
+ L: 583,
2750
2801
  S: this,
2751
2802
  C: (f, a) => f(...a)
2752
2803
  });
@@ -2819,7 +2870,7 @@ var SpacesServiceImpl = class {
2819
2870
  await this._updateMetrics();
2820
2871
  return this._serializeSpace(space);
2821
2872
  }
2822
- async updateSpace({ spaceKey, state }) {
2873
+ async updateSpace({ spaceKey, state, edgeReplication }) {
2823
2874
  const dataSpaceManager = await this._getDataSpaceManager();
2824
2875
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2825
2876
  if (state) {
@@ -2834,6 +2885,9 @@ var SpacesServiceImpl = class {
2834
2885
  throw new import_protocols6.ApiError("Invalid space state");
2835
2886
  }
2836
2887
  }
2888
+ if (edgeReplication !== void 0) {
2889
+ await dataSpaceManager.setSpaceEdgeReplicationSetting(spaceKey, edgeReplication);
2890
+ }
2837
2891
  }
2838
2892
  async updateMemberRole(request) {
2839
2893
  const identity = this._requireIdentity();
@@ -2850,7 +2904,7 @@ var SpacesServiceImpl = class {
2850
2904
  const credentials = await (0, import_credentials13.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2851
2905
  (0, import_invariant8.invariant)(credentials[0].credential, void 0, {
2852
2906
  F: __dxlog_file10,
2853
- L: 102,
2907
+ L: 106,
2854
2908
  S: this,
2855
2909
  A: [
2856
2910
  "credentials[0].credential",
@@ -2860,7 +2914,7 @@ var SpacesServiceImpl = class {
2860
2914
  const spaceMemberCredential = credentials[0].credential.credential;
2861
2915
  (0, import_invariant8.invariant)((0, import_credentials13.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2862
2916
  F: __dxlog_file10,
2863
- L: 104,
2917
+ L: 108,
2864
2918
  S: this,
2865
2919
  A: [
2866
2920
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2878,7 +2932,7 @@ var SpacesServiceImpl = class {
2878
2932
  ids: spaces.map((space) => space.id)
2879
2933
  }), {
2880
2934
  F: __dxlog_file10,
2881
- L: 115,
2935
+ L: 119,
2882
2936
  S: this,
2883
2937
  C: (f, a) => f(...a)
2884
2938
  });
@@ -2970,7 +3024,7 @@ var SpacesServiceImpl = class {
2970
3024
  } else {
2971
3025
  (0, import_invariant8.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
2972
3026
  F: __dxlog_file10,
2973
- L: 213,
3027
+ L: 217,
2974
3028
  S: this,
2975
3029
  A: [
2976
3030
  "!credential.id",
@@ -2979,7 +3033,7 @@ var SpacesServiceImpl = class {
2979
3033
  });
2980
3034
  (0, import_invariant8.invariant)(this._identityManager.identity, "Identity is not available", {
2981
3035
  F: __dxlog_file10,
2982
- L: 214,
3036
+ L: 218,
2983
3037
  S: this,
2984
3038
  A: [
2985
3039
  "this._identityManager.identity",
@@ -2989,7 +3043,7 @@ var SpacesServiceImpl = class {
2989
3043
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
2990
3044
  (0, import_invariant8.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
2991
3045
  F: __dxlog_file10,
2992
- L: 216,
3046
+ L: 220,
2993
3047
  S: this,
2994
3048
  A: [
2995
3049
  "credential.issuer.equals(signer.getIssuer())",
@@ -3039,7 +3093,7 @@ var SpacesServiceImpl = class {
3039
3093
  const assertion = (0, import_credentials13.getCredentialAssertion)(credential);
3040
3094
  (0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3041
3095
  F: __dxlog_file10,
3042
- L: 250,
3096
+ L: 254,
3043
3097
  S: this,
3044
3098
  A: [
3045
3099
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3049,7 +3103,7 @@ var SpacesServiceImpl = class {
3049
3103
  const myIdentity = this._identityManager.identity;
3050
3104
  (0, import_invariant8.invariant)(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
3051
3105
  F: __dxlog_file10,
3052
- L: 252,
3106
+ L: 256,
3053
3107
  S: this,
3054
3108
  A: [
3055
3109
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -3111,7 +3165,8 @@ var SpacesServiceImpl = class {
3111
3165
  }),
3112
3166
  creator: space.inner.spaceState.creator?.key,
3113
3167
  cache: space.cache,
3114
- metrics: space.metrics
3168
+ metrics: space.metrics,
3169
+ edgeReplication: space.getEdgeReplicationSetting()
3115
3170
  };
3116
3171
  }
3117
3172
  _requireIdentity() {
@@ -4527,6 +4582,9 @@ var DataSpace = class {
4527
4582
  });
4528
4583
  this.stateUpdate.emit();
4529
4584
  }
4585
+ getEdgeReplicationSetting() {
4586
+ return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
4587
+ }
4530
4588
  };
4531
4589
  _ts_decorate6([
4532
4590
  import_tracing3.trace.info()
@@ -4683,39 +4741,189 @@ var DeviceInvitationProtocol = class {
4683
4741
  }
4684
4742
  };
4685
4743
  var stateToString = (state) => {
4686
- return Object.entries(import_services12.Invitation.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
4744
+ return Object.entries(import_services13.Invitation.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
4687
4745
  };
4688
4746
  var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
4689
4747
  let guard;
4690
- return (0, import_context12.cancelWithContext)(ctx, (async () => {
4748
+ return (0, import_context11.cancelWithContext)(ctx, (async () => {
4691
4749
  guard = await mutex.acquire();
4692
4750
  if (ctx.disposed) {
4693
4751
  guard.release();
4694
4752
  guard = void 0;
4695
- throw new import_context12.ContextDisposedError();
4753
+ throw new import_context11.ContextDisposedError();
4696
4754
  }
4697
4755
  return guard;
4698
4756
  })());
4699
4757
  };
4700
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
4758
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
4759
+ var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
4760
+ var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
4761
+ var EdgeInvitationHandler = class {
4762
+ constructor(config, _client, _callbacks) {
4763
+ this._client = _client;
4764
+ this._callbacks = _callbacks;
4765
+ this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
4766
+ this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
4767
+ }
4768
+ handle(ctx, guardedState, protocol, deviceProfile) {
4769
+ if (!this._client) {
4770
+ (0, import_log14.log)("edge disabled", void 0, {
4771
+ F: __dxlog_file16,
4772
+ L: 65,
4773
+ S: this,
4774
+ C: (f, a) => f(...a)
4775
+ });
4776
+ return;
4777
+ }
4778
+ const invitation = guardedState.current;
4779
+ const spaceId = invitation.spaceId;
4780
+ const canBeHandledByEdge = invitation.authMethod !== import_services12.Invitation.AuthMethod.SHARED_SECRET && invitation.type === import_services12.Invitation.Type.DELEGATED && invitation.kind === import_services12.Invitation.Kind.SPACE && spaceId != null && import_keys11.SpaceId.isValid(spaceId);
4781
+ if (!canBeHandledByEdge) {
4782
+ (0, import_log14.log)("invitation could not be handled by edge", {
4783
+ invitation
4784
+ }, {
4785
+ F: __dxlog_file16,
4786
+ L: 79,
4787
+ S: this,
4788
+ C: (f, a) => f(...a)
4789
+ });
4790
+ return;
4791
+ }
4792
+ ctx.onDispose(() => {
4793
+ this._flowLock?.release();
4794
+ this._flowLock = void 0;
4795
+ });
4796
+ const tryHandleInvitation = async () => {
4797
+ const admissionRequest = await protocol.createAdmissionRequest(deviceProfile);
4798
+ if (admissionRequest.space) {
4799
+ try {
4800
+ await this._handleSpaceInvitationFlow(ctx, guardedState, admissionRequest.space, spaceId);
4801
+ } catch (error) {
4802
+ if (error instanceof import_protocols10.EdgeCallFailedError) {
4803
+ import_log14.log.info("join space with edge unsuccessful", {
4804
+ reason: error.message,
4805
+ retryable: error.isRetryable,
4806
+ after: error.retryAfterMs ?? this._calculateNextRetryMs()
4807
+ }, {
4808
+ F: __dxlog_file16,
4809
+ L: 95,
4810
+ S: this,
4811
+ C: (f, a) => f(...a)
4812
+ });
4813
+ if (error.isRetryable) {
4814
+ (0, import_async16.scheduleTask)(ctx, tryHandleInvitation, error.retryAfterMs ?? this._calculateNextRetryMs());
4815
+ }
4816
+ } else {
4817
+ import_log14.log.info("failed to handle invitation with edge", {
4818
+ error
4819
+ }, {
4820
+ F: __dxlog_file16,
4821
+ L: 104,
4822
+ S: this,
4823
+ C: (f, a) => f(...a)
4824
+ });
4825
+ (0, import_async16.scheduleTask)(ctx, tryHandleInvitation, this._calculateNextRetryMs());
4826
+ }
4827
+ }
4828
+ }
4829
+ };
4830
+ (0, import_async16.scheduleMicroTask)(ctx, tryHandleInvitation);
4831
+ }
4832
+ async _handleSpaceInvitationFlow(ctx, guardedState, admissionRequest, spaceId) {
4833
+ try {
4834
+ (0, import_log14.log)("edge invitation flow", void 0, {
4835
+ F: __dxlog_file16,
4836
+ L: 120,
4837
+ S: this,
4838
+ C: (f, a) => f(...a)
4839
+ });
4840
+ this._flowLock = await tryAcquireBeforeContextDisposed(ctx, guardedState.mutex);
4841
+ (0, import_log14.log)("edge invitation flow acquired the lock", void 0, {
4842
+ F: __dxlog_file16,
4843
+ L: 122,
4844
+ S: this,
4845
+ C: (f, a) => f(...a)
4846
+ });
4847
+ guardedState.set(this, import_services12.Invitation.State.CONNECTING);
4848
+ const response = await this._joinSpaceByInvitation(guardedState, spaceId, {
4849
+ identityKey: admissionRequest.identityKey.toHex(),
4850
+ invitationId: guardedState.current.invitationId
4851
+ });
4852
+ const admissionResponse = await this._mapToAdmissionResponse(response);
4853
+ await this._callbacks.onInvitationSuccess(admissionResponse, {
4854
+ space: admissionRequest
4855
+ });
4856
+ } catch (error) {
4857
+ guardedState.set(this, import_services12.Invitation.State.ERROR);
4858
+ throw error;
4859
+ } finally {
4860
+ this._flowLock?.release();
4861
+ this._flowLock = void 0;
4862
+ }
4863
+ }
4864
+ async _mapToAdmissionResponse(edgeResponse) {
4865
+ const credentialBytes = Buffer.from(edgeResponse.spaceMemberCredential, "base64");
4866
+ const codec = import_proto3.schema.getCodecForType("dxos.halo.credentials.Credential");
4867
+ return {
4868
+ space: {
4869
+ credential: codec.decode(credentialBytes)
4870
+ }
4871
+ };
4872
+ }
4873
+ async _joinSpaceByInvitation(guardedState, spaceId, request) {
4874
+ (0, import_invariant13.invariant)(this._client, void 0, {
4875
+ F: __dxlog_file16,
4876
+ L: 157,
4877
+ S: this,
4878
+ A: [
4879
+ "this._client",
4880
+ ""
4881
+ ]
4882
+ });
4883
+ try {
4884
+ return await this._client.joinSpaceByInvitation(spaceId, request);
4885
+ } catch (error) {
4886
+ if (error instanceof import_protocols10.EdgeAuthChallengeError) {
4887
+ guardedState.set(this, import_services12.Invitation.State.AUTHENTICATING);
4888
+ const publicKey = guardedState.current.guestKeypair?.publicKey;
4889
+ const privateKey = guardedState.current.guestKeypair?.privateKey;
4890
+ if (!privateKey || !publicKey) {
4891
+ throw error;
4892
+ }
4893
+ const signature = await (0, import_crypto2.ed25519Signature)(privateKey, Buffer.from(error.challenge, "base64"));
4894
+ request.signature = Buffer.from(signature).toString("base64");
4895
+ return this._client.joinSpaceByInvitation(spaceId, request);
4896
+ } else {
4897
+ throw error;
4898
+ }
4899
+ }
4900
+ }
4901
+ hasFlowLock() {
4902
+ return this._flowLock != null;
4903
+ }
4904
+ _calculateNextRetryMs() {
4905
+ return this._retryInterval + Math.random() * this._retryJitter;
4906
+ }
4907
+ };
4908
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
4701
4909
  var OPTIONS_TIMEOUT = 1e4;
4702
4910
  var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
4703
4911
  constructor(_invitationFlowMutex, _callbacks) {
4704
4912
  super({
4705
4913
  requested: {
4706
- InvitationHostService: import_proto3.schema.getService("dxos.halo.invitations.InvitationHostService")
4914
+ InvitationHostService: import_proto4.schema.getService("dxos.halo.invitations.InvitationHostService")
4707
4915
  },
4708
4916
  exposed: {
4709
- InvitationHostService: import_proto3.schema.getService("dxos.halo.invitations.InvitationHostService")
4917
+ InvitationHostService: import_proto4.schema.getService("dxos.halo.invitations.InvitationHostService")
4710
4918
  }
4711
4919
  });
4712
4920
  this._invitationFlowMutex = _invitationFlowMutex;
4713
4921
  this._callbacks = _callbacks;
4714
- this._ctx = new import_context11.Context(void 0, {
4715
- F: __dxlog_file16,
4716
- L: 34
4922
+ this._ctx = new import_context12.Context(void 0, {
4923
+ F: __dxlog_file17,
4924
+ L: 38
4717
4925
  });
4718
- this._remoteOptionsTrigger = new import_async16.Trigger();
4926
+ this._remoteOptionsTrigger = new import_async17.Trigger();
4719
4927
  this._invitationFlowLock = null;
4720
4928
  }
4721
4929
  hasFlowLock() {
@@ -4725,9 +4933,9 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
4725
4933
  return {
4726
4934
  InvitationHostService: {
4727
4935
  options: async (options) => {
4728
- (0, import_invariant13.invariant)(!this._remoteOptions, "Remote options already set.", {
4729
- F: __dxlog_file16,
4730
- L: 64,
4936
+ (0, import_invariant14.invariant)(!this._remoteOptions, "Remote options already set.", {
4937
+ F: __dxlog_file17,
4938
+ L: 68,
4731
4939
  S: this,
4732
4940
  A: [
4733
4941
  "!this._remoteOptions",
@@ -4752,39 +4960,39 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
4752
4960
  async onOpen(context) {
4753
4961
  await super.onOpen(context);
4754
4962
  try {
4755
- (0, import_log14.log)("guest acquire lock", void 0, {
4756
- F: __dxlog_file16,
4757
- L: 85,
4963
+ (0, import_log15.log)("guest acquire lock", void 0, {
4964
+ F: __dxlog_file17,
4965
+ L: 89,
4758
4966
  S: this,
4759
4967
  C: (f, a) => f(...a)
4760
4968
  });
4761
4969
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
4762
- (0, import_log14.log)("guest lock acquired", void 0, {
4763
- F: __dxlog_file16,
4764
- L: 87,
4970
+ (0, import_log15.log)("guest lock acquired", void 0, {
4971
+ F: __dxlog_file17,
4972
+ L: 91,
4765
4973
  S: this,
4766
4974
  C: (f, a) => f(...a)
4767
4975
  });
4768
- await (0, import_context11.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
4976
+ await (0, import_context12.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
4769
4977
  role: import_invitations3.InvitationOptions.Role.GUEST
4770
4978
  }));
4771
- (0, import_log14.log)("options sent", void 0, {
4772
- F: __dxlog_file16,
4773
- L: 92,
4979
+ (0, import_log15.log)("options sent", void 0, {
4980
+ F: __dxlog_file17,
4981
+ L: 96,
4774
4982
  S: this,
4775
4983
  C: (f, a) => f(...a)
4776
4984
  });
4777
- await (0, import_context11.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
4985
+ await (0, import_context12.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
4778
4986
  timeout: OPTIONS_TIMEOUT
4779
4987
  }));
4780
- (0, import_log14.log)("options received", void 0, {
4781
- F: __dxlog_file16,
4782
- L: 94,
4988
+ (0, import_log15.log)("options received", void 0, {
4989
+ F: __dxlog_file17,
4990
+ L: 98,
4783
4991
  S: this,
4784
4992
  C: (f, a) => f(...a)
4785
4993
  });
4786
4994
  if (this._remoteOptions?.role !== import_invitations3.InvitationOptions.Role.HOST) {
4787
- throw new import_protocols10.InvalidInvitationExtensionRoleError(void 0, {
4995
+ throw new import_protocols11.InvalidInvitationExtensionRoleError(void 0, {
4788
4996
  expected: import_invitations3.InvitationOptions.Role.HOST,
4789
4997
  remoteOptions: this._remoteOptions,
4790
4998
  remotePeerId: context.remotePeerId
@@ -4811,40 +5019,40 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
4811
5019
  if (this._invitationFlowLock != null) {
4812
5020
  this._invitationFlowLock.release();
4813
5021
  this._invitationFlowLock = null;
4814
- (0, import_log14.log)("invitation flow lock released", void 0, {
4815
- F: __dxlog_file16,
4816
- L: 127,
5022
+ (0, import_log15.log)("invitation flow lock released", void 0, {
5023
+ F: __dxlog_file17,
5024
+ L: 131,
4817
5025
  S: this,
4818
5026
  C: (f, a) => f(...a)
4819
5027
  });
4820
5028
  }
4821
5029
  }
4822
5030
  };
4823
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
5031
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
4824
5032
  var OPTIONS_TIMEOUT2 = 1e4;
4825
5033
  var MAX_OTP_ATTEMPTS = 3;
4826
5034
  var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4827
5035
  constructor(_invitationFlowMutex, _callbacks) {
4828
5036
  super({
4829
5037
  requested: {
4830
- InvitationHostService: import_proto4.schema.getService("dxos.halo.invitations.InvitationHostService")
5038
+ InvitationHostService: import_proto5.schema.getService("dxos.halo.invitations.InvitationHostService")
4831
5039
  },
4832
5040
  exposed: {
4833
- InvitationHostService: import_proto4.schema.getService("dxos.halo.invitations.InvitationHostService")
5041
+ InvitationHostService: import_proto5.schema.getService("dxos.halo.invitations.InvitationHostService")
4834
5042
  }
4835
5043
  });
4836
5044
  this._invitationFlowMutex = _invitationFlowMutex;
4837
5045
  this._callbacks = _callbacks;
4838
5046
  this._ctx = new import_context13.Context(void 0, {
4839
- F: __dxlog_file17,
4840
- L: 53
5047
+ F: __dxlog_file18,
5048
+ L: 57
4841
5049
  });
4842
- this._remoteOptionsTrigger = new import_async17.Trigger();
5050
+ this._remoteOptionsTrigger = new import_async18.Trigger();
4843
5051
  this._challenge = void 0;
4844
5052
  this.guestProfile = void 0;
4845
5053
  this.authenticationPassed = false;
4846
5054
  this.authenticationRetry = 0;
4847
- this.completedTrigger = new import_async17.Trigger();
5055
+ this.completedTrigger = new import_async18.Trigger();
4848
5056
  this._invitationFlowLock = null;
4849
5057
  }
4850
5058
  hasFlowLock() {
@@ -4856,9 +5064,9 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4856
5064
  // Perhaps in the future we will have more complex logic here.
4857
5065
  InvitationHostService: {
4858
5066
  options: async (options) => {
4859
- (0, import_invariant14.invariant)(!this._remoteOptions, "Remote options already set.", {
4860
- F: __dxlog_file17,
4861
- L: 102,
5067
+ (0, import_invariant15.invariant)(!this._remoteOptions, "Remote options already set.", {
5068
+ F: __dxlog_file18,
5069
+ L: 106,
4862
5070
  S: this,
4863
5071
  A: [
4864
5072
  "!this._remoteOptions",
@@ -4870,49 +5078,49 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4870
5078
  },
4871
5079
  introduce: async (request) => {
4872
5080
  const { profile, invitationId } = request;
4873
- const traceId = import_keys11.PublicKey.random().toHex();
4874
- import_log15.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols11.trace.begin({
5081
+ const traceId = import_keys12.PublicKey.random().toHex();
5082
+ import_log16.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols12.trace.begin({
4875
5083
  id: traceId
4876
5084
  }), {
4877
- F: __dxlog_file17,
4878
- L: 110,
5085
+ F: __dxlog_file18,
5086
+ L: 114,
4879
5087
  S: this,
4880
5088
  C: (f, a) => f(...a)
4881
5089
  });
4882
5090
  const invitation = this._requireActiveInvitation();
4883
- this._assertInvitationState(import_services13.Invitation.State.CONNECTED);
5091
+ this._assertInvitationState(import_services14.Invitation.State.CONNECTED);
4884
5092
  if (invitationId !== invitation?.invitationId) {
4885
- import_log15.log.warn("incorrect invitationId", {
5093
+ import_log16.log.warn("incorrect invitationId", {
4886
5094
  expected: invitation.invitationId,
4887
5095
  actual: invitationId
4888
5096
  }, {
4889
- F: __dxlog_file17,
4890
- L: 115,
5097
+ F: __dxlog_file18,
5098
+ L: 119,
4891
5099
  S: this,
4892
5100
  C: (f, a) => f(...a)
4893
5101
  });
4894
5102
  this._callbacks.onError(new Error("Incorrect invitationId."));
4895
- (0, import_async17.scheduleTask)(this._ctx, () => this.close());
5103
+ (0, import_async18.scheduleTask)(this._ctx, () => this.close());
4896
5104
  return {
4897
- authMethod: import_services13.Invitation.AuthMethod.NONE
5105
+ authMethod: import_services14.Invitation.AuthMethod.NONE
4898
5106
  };
4899
5107
  }
4900
- (0, import_log15.log)("guest introduced themselves", {
5108
+ (0, import_log16.log)("guest introduced themselves", {
4901
5109
  guestProfile: profile
4902
5110
  }, {
4903
- F: __dxlog_file17,
4904
- L: 124,
5111
+ F: __dxlog_file18,
5112
+ L: 128,
4905
5113
  S: this,
4906
5114
  C: (f, a) => f(...a)
4907
5115
  });
4908
5116
  this.guestProfile = profile;
4909
- this._callbacks.onStateUpdate(import_services13.Invitation.State.READY_FOR_AUTHENTICATION);
4910
- this._challenge = invitation.authMethod === import_services13.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
4911
- import_log15.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols11.trace.end({
5117
+ this._callbacks.onStateUpdate(import_services14.Invitation.State.READY_FOR_AUTHENTICATION);
5118
+ this._challenge = invitation.authMethod === import_services14.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto3.randomBytes)(32) : void 0;
5119
+ import_log16.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols12.trace.end({
4912
5120
  id: traceId
4913
5121
  }), {
4914
- F: __dxlog_file17,
4915
- L: 130,
5122
+ F: __dxlog_file18,
5123
+ L: 134,
4916
5124
  S: this,
4917
5125
  C: (f, a) => f(...a)
4918
5126
  });
@@ -4922,35 +5130,35 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4922
5130
  };
4923
5131
  },
4924
5132
  authenticate: async ({ authCode: code, signedChallenge }) => {
4925
- const traceId = import_keys11.PublicKey.random().toHex();
4926
- import_log15.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols11.trace.begin({
5133
+ const traceId = import_keys12.PublicKey.random().toHex();
5134
+ import_log16.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols12.trace.begin({
4927
5135
  id: traceId
4928
5136
  }), {
4929
- F: __dxlog_file17,
4930
- L: 139,
5137
+ F: __dxlog_file18,
5138
+ L: 143,
4931
5139
  S: this,
4932
5140
  C: (f, a) => f(...a)
4933
5141
  });
4934
5142
  const invitation = this._requireActiveInvitation();
4935
- (0, import_log15.log)("received authentication request", {
5143
+ (0, import_log16.log)("received authentication request", {
4936
5144
  authCode: code
4937
5145
  }, {
4938
- F: __dxlog_file17,
4939
- L: 142,
5146
+ F: __dxlog_file18,
5147
+ L: 146,
4940
5148
  S: this,
4941
5149
  C: (f, a) => f(...a)
4942
5150
  });
4943
5151
  let status = import_invitations4.AuthenticationResponse.Status.OK;
4944
5152
  this._assertInvitationState([
4945
- import_services13.Invitation.State.AUTHENTICATING,
4946
- import_services13.Invitation.State.READY_FOR_AUTHENTICATION
5153
+ import_services14.Invitation.State.AUTHENTICATING,
5154
+ import_services14.Invitation.State.READY_FOR_AUTHENTICATION
4947
5155
  ]);
4948
- this._callbacks.onStateUpdate(import_services13.Invitation.State.AUTHENTICATING);
5156
+ this._callbacks.onStateUpdate(import_services14.Invitation.State.AUTHENTICATING);
4949
5157
  switch (invitation.authMethod) {
4950
- case import_services13.Invitation.AuthMethod.NONE: {
4951
- (0, import_log15.log)("authentication not required", void 0, {
4952
- F: __dxlog_file17,
4953
- L: 150,
5158
+ case import_services14.Invitation.AuthMethod.NONE: {
5159
+ (0, import_log16.log)("authentication not required", void 0, {
5160
+ F: __dxlog_file18,
5161
+ L: 154,
4954
5162
  S: this,
4955
5163
  C: (f, a) => f(...a)
4956
5164
  });
@@ -4958,7 +5166,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4958
5166
  status: import_invitations4.AuthenticationResponse.Status.OK
4959
5167
  };
4960
5168
  }
4961
- case import_services13.Invitation.AuthMethod.SHARED_SECRET: {
5169
+ case import_services14.Invitation.AuthMethod.SHARED_SECRET: {
4962
5170
  if (invitation.authCode) {
4963
5171
  if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
4964
5172
  status = import_invitations4.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
@@ -4970,12 +5178,12 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4970
5178
  }
4971
5179
  break;
4972
5180
  }
4973
- case import_services13.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
5181
+ case import_services14.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
4974
5182
  if (!invitation.guestKeypair) {
4975
5183
  status = import_invitations4.AuthenticationResponse.Status.INTERNAL_ERROR;
4976
5184
  break;
4977
5185
  }
4978
- const isSignatureValid = this._challenge && (0, import_crypto2.verify)(this._challenge, Buffer.from(signedChallenge ?? []), invitation.guestKeypair.publicKey.asBuffer());
5186
+ const isSignatureValid = this._challenge && (0, import_crypto3.verify)(this._challenge, Buffer.from(signedChallenge ?? []), invitation.guestKeypair.publicKey.asBuffer());
4979
5187
  if (isSignatureValid) {
4980
5188
  this.authenticationPassed = true;
4981
5189
  } else {
@@ -4984,11 +5192,11 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4984
5192
  break;
4985
5193
  }
4986
5194
  default: {
4987
- import_log15.log.error("invalid authentication method", {
5195
+ import_log16.log.error("invalid authentication method", {
4988
5196
  authMethod: invitation.authMethod
4989
5197
  }, {
4990
- F: __dxlog_file17,
4991
- L: 188,
5198
+ F: __dxlog_file18,
5199
+ L: 192,
4992
5200
  S: this,
4993
5201
  C: (f, a) => f(...a)
4994
5202
  });
@@ -5001,19 +5209,19 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5001
5209
  import_invitations4.AuthenticationResponse.Status.INVALID_OTP
5002
5210
  ].includes(status)) {
5003
5211
  this._callbacks.onError(new Error(`Authentication failed, with status=${status}`));
5004
- (0, import_async17.scheduleTask)(this._ctx, () => this.close());
5212
+ (0, import_async18.scheduleTask)(this._ctx, () => this.close());
5005
5213
  return {
5006
5214
  status
5007
5215
  };
5008
5216
  }
5009
- import_log15.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols11.trace.end({
5217
+ import_log16.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols12.trace.end({
5010
5218
  id: traceId,
5011
5219
  data: {
5012
5220
  status
5013
5221
  }
5014
5222
  }), {
5015
- F: __dxlog_file17,
5016
- L: 200,
5223
+ F: __dxlog_file18,
5224
+ L: 204,
5017
5225
  S: this,
5018
5226
  C: (f, a) => f(...a)
5019
5227
  });
@@ -5022,29 +5230,29 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5022
5230
  };
5023
5231
  },
5024
5232
  admit: async (request) => {
5025
- const traceId = import_keys11.PublicKey.random().toHex();
5026
- import_log15.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols11.trace.begin({
5233
+ const traceId = import_keys12.PublicKey.random().toHex();
5234
+ import_log16.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols12.trace.begin({
5027
5235
  id: traceId
5028
5236
  }), {
5029
- F: __dxlog_file17,
5030
- L: 206,
5237
+ F: __dxlog_file18,
5238
+ L: 210,
5031
5239
  S: this,
5032
5240
  C: (f, a) => f(...a)
5033
5241
  });
5034
5242
  const invitation = this._requireActiveInvitation();
5035
5243
  try {
5036
5244
  if (isAuthenticationRequired(invitation)) {
5037
- this._assertInvitationState(import_services13.Invitation.State.AUTHENTICATING);
5245
+ this._assertInvitationState(import_services14.Invitation.State.AUTHENTICATING);
5038
5246
  if (!this.authenticationPassed) {
5039
5247
  throw new Error("Not authenticated");
5040
5248
  }
5041
5249
  }
5042
5250
  const response = await this._callbacks.admit(request);
5043
- import_log15.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols11.trace.end({
5251
+ import_log16.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols12.trace.end({
5044
5252
  id: traceId
5045
5253
  }), {
5046
- F: __dxlog_file17,
5047
- L: 220,
5254
+ F: __dxlog_file18,
5255
+ L: 224,
5048
5256
  S: this,
5049
5257
  C: (f, a) => f(...a)
5050
5258
  });
@@ -5060,48 +5268,48 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5060
5268
  async onOpen(context) {
5061
5269
  await super.onOpen(context);
5062
5270
  try {
5063
- (0, import_log15.log)("host acquire lock", void 0, {
5064
- F: __dxlog_file17,
5065
- L: 235,
5271
+ (0, import_log16.log)("host acquire lock", void 0, {
5272
+ F: __dxlog_file18,
5273
+ L: 239,
5066
5274
  S: this,
5067
5275
  C: (f, a) => f(...a)
5068
5276
  });
5069
5277
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
5070
- (0, import_log15.log)("host lock acquired", void 0, {
5071
- F: __dxlog_file17,
5072
- L: 237,
5278
+ (0, import_log16.log)("host lock acquired", void 0, {
5279
+ F: __dxlog_file18,
5280
+ L: 241,
5073
5281
  S: this,
5074
5282
  C: (f, a) => f(...a)
5075
5283
  });
5076
5284
  const lastState = this._requireActiveInvitation().state;
5077
- this._callbacks.onStateUpdate(import_services13.Invitation.State.CONNECTING);
5285
+ this._callbacks.onStateUpdate(import_services14.Invitation.State.CONNECTING);
5078
5286
  await this.rpc.InvitationHostService.options({
5079
5287
  role: import_invitations4.InvitationOptions.Role.HOST
5080
5288
  });
5081
- (0, import_log15.log)("options sent", void 0, {
5082
- F: __dxlog_file17,
5083
- L: 241,
5289
+ (0, import_log16.log)("options sent", void 0, {
5290
+ F: __dxlog_file18,
5291
+ L: 245,
5084
5292
  S: this,
5085
5293
  C: (f, a) => f(...a)
5086
5294
  });
5087
5295
  await (0, import_context13.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
5088
5296
  timeout: OPTIONS_TIMEOUT2
5089
5297
  }));
5090
- (0, import_log15.log)("options received", void 0, {
5091
- F: __dxlog_file17,
5092
- L: 243,
5298
+ (0, import_log16.log)("options received", void 0, {
5299
+ F: __dxlog_file18,
5300
+ L: 247,
5093
5301
  S: this,
5094
5302
  C: (f, a) => f(...a)
5095
5303
  });
5096
5304
  if (this._remoteOptions?.role !== import_invitations4.InvitationOptions.Role.GUEST) {
5097
5305
  this._callbacks.onStateUpdate(lastState);
5098
- throw new import_protocols11.InvalidInvitationExtensionRoleError(void 0, {
5306
+ throw new import_protocols12.InvalidInvitationExtensionRoleError(void 0, {
5099
5307
  expected: import_invitations4.InvitationOptions.Role.GUEST,
5100
5308
  remoteOptions: this._remoteOptions,
5101
5309
  remotePeerId: context.remotePeerId
5102
5310
  });
5103
5311
  }
5104
- this._callbacks.onStateUpdate(import_services13.Invitation.State.CONNECTED);
5312
+ this._callbacks.onStateUpdate(import_services14.Invitation.State.CONNECTED);
5105
5313
  this._callbacks.onOpen(this._ctx, context);
5106
5314
  } catch (err) {
5107
5315
  if (this._invitationFlowLock != null) {
@@ -5115,7 +5323,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5115
5323
  _requireActiveInvitation() {
5116
5324
  const invitation = this._callbacks.activeInvitation;
5117
5325
  if (invitation == null) {
5118
- (0, import_async17.scheduleTask)(this._ctx, () => this.close());
5326
+ (0, import_async18.scheduleTask)(this._ctx, () => this.close());
5119
5327
  throw new Error("Active invitation not found");
5120
5328
  }
5121
5329
  return invitation;
@@ -5126,8 +5334,8 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5126
5334
  stateOrMany
5127
5335
  ];
5128
5336
  if (!validStates.includes(invitation.state)) {
5129
- (0, import_async17.scheduleTask)(this._ctx, () => this.close());
5130
- throw new import_invariant14.InvariantViolation(`Expected ${stateToString(invitation.state)} to be one of [${validStates.map(stateToString).join(", ")}]`);
5337
+ (0, import_async18.scheduleTask)(this._ctx, () => this.close());
5338
+ throw new import_invariant15.InvariantViolation(`Expected ${stateToString(invitation.state)} to be one of [${validStates.map(stateToString).join(", ")}]`);
5131
5339
  }
5132
5340
  }
5133
5341
  async onClose() {
@@ -5141,25 +5349,115 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5141
5349
  if (this._invitationFlowLock != null) {
5142
5350
  this._invitationFlowLock?.release();
5143
5351
  this._invitationFlowLock = null;
5144
- (0, import_log15.log)("invitation flow lock released", void 0, {
5145
- F: __dxlog_file17,
5146
- L: 298,
5352
+ (0, import_log16.log)("invitation flow lock released", void 0, {
5353
+ F: __dxlog_file18,
5354
+ L: 302,
5147
5355
  S: this,
5148
5356
  C: (f, a) => f(...a)
5149
5357
  });
5150
5358
  }
5151
5359
  }
5152
5360
  };
5153
- var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services13.Invitation.AuthMethod.NONE;
5154
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
5361
+ var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services14.Invitation.AuthMethod.NONE;
5362
+ var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-state.ts";
5363
+ var createGuardedInvitationState = (ctx, invitation, stream) => {
5364
+ const mutex = new import_async19.Mutex();
5365
+ let lastActiveLockHolder = null;
5366
+ let currentInvitation = {
5367
+ ...invitation
5368
+ };
5369
+ const isStateChangeAllowed = (lockHolder) => {
5370
+ if (ctx.disposed || lockHolder !== null && mutex.isLocked() && !lockHolder.hasFlowLock()) {
5371
+ return false;
5372
+ }
5373
+ return lockHolder == null || lastActiveLockHolder !== lockHolder || isNonTerminalState(currentInvitation.state);
5374
+ };
5375
+ return {
5376
+ mutex,
5377
+ get current() {
5378
+ return currentInvitation;
5379
+ },
5380
+ // disposing context prevents any further state updates
5381
+ complete: (newState) => {
5382
+ currentInvitation = {
5383
+ ...currentInvitation,
5384
+ ...newState
5385
+ };
5386
+ stream.next(currentInvitation);
5387
+ return ctx.dispose();
5388
+ },
5389
+ set: (lockHolder, newState) => {
5390
+ if (isStateChangeAllowed(lockHolder)) {
5391
+ logStateUpdate(currentInvitation, lockHolder, newState);
5392
+ currentInvitation = {
5393
+ ...currentInvitation,
5394
+ state: newState
5395
+ };
5396
+ stream.next(currentInvitation);
5397
+ lastActiveLockHolder = lockHolder;
5398
+ return true;
5399
+ }
5400
+ return false;
5401
+ },
5402
+ error: (lockHolder, error) => {
5403
+ if (isStateChangeAllowed(lockHolder)) {
5404
+ logStateUpdate(currentInvitation, lockHolder, import_services15.Invitation.State.ERROR);
5405
+ currentInvitation = {
5406
+ ...currentInvitation,
5407
+ state: import_services15.Invitation.State.ERROR
5408
+ };
5409
+ stream.next(currentInvitation);
5410
+ stream.error(error);
5411
+ lastActiveLockHolder = lockHolder;
5412
+ return true;
5413
+ }
5414
+ return false;
5415
+ }
5416
+ };
5417
+ };
5418
+ var logStateUpdate = (invitation, actor, newState) => {
5419
+ if (isNonTerminalState(newState)) {
5420
+ (0, import_log17.log)("invitation state update", {
5421
+ actor: actor?.constructor.name,
5422
+ newState: stateToString(newState),
5423
+ oldState: stateToString(invitation.state)
5424
+ }, {
5425
+ F: __dxlog_file19,
5426
+ L: 89,
5427
+ S: void 0,
5428
+ C: (f, a) => f(...a)
5429
+ });
5430
+ } else {
5431
+ import_log17.log.info("invitation state update", {
5432
+ actor: actor?.constructor.name,
5433
+ newState: stateToString(newState),
5434
+ oldState: stateToString(invitation.state)
5435
+ }, {
5436
+ F: __dxlog_file19,
5437
+ L: 95,
5438
+ S: void 0,
5439
+ C: (f, a) => f(...a)
5440
+ });
5441
+ }
5442
+ };
5443
+ var isNonTerminalState = (currentState) => {
5444
+ return ![
5445
+ import_services15.Invitation.State.SUCCESS,
5446
+ import_services15.Invitation.State.ERROR,
5447
+ import_services15.Invitation.State.CANCELLED,
5448
+ import_services15.Invitation.State.TIMEOUT,
5449
+ import_services15.Invitation.State.EXPIRED
5450
+ ].includes(currentState);
5451
+ };
5452
+ var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
5155
5453
  var InvitationTopology = class {
5156
5454
  constructor(_role) {
5157
5455
  this._role = _role;
5158
- this._seenPeers = new import_util11.ComplexSet(import_keys12.PublicKey.hash);
5456
+ this._seenPeers = new import_util11.ComplexSet(import_keys13.PublicKey.hash);
5159
5457
  }
5160
5458
  init(controller) {
5161
- (0, import_invariant15.invariant)(!this._controller, "Already initialized.", {
5162
- F: __dxlog_file18,
5459
+ (0, import_invariant16.invariant)(!this._controller, "Already initialized.", {
5460
+ F: __dxlog_file20,
5163
5461
  L: 42,
5164
5462
  S: this,
5165
5463
  A: [
@@ -5170,8 +5468,8 @@ var InvitationTopology = class {
5170
5468
  this._controller = controller;
5171
5469
  }
5172
5470
  update() {
5173
- (0, import_invariant15.invariant)(this._controller, "Not initialized.", {
5174
- F: __dxlog_file18,
5471
+ (0, import_invariant16.invariant)(this._controller, "Not initialized.", {
5472
+ F: __dxlog_file20,
5175
5473
  L: 47,
5176
5474
  S: this,
5177
5475
  A: [
@@ -5188,13 +5486,13 @@ var InvitationTopology = class {
5188
5486
  return;
5189
5487
  }
5190
5488
  const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
5191
- this._seenPeers = new import_util11.ComplexSet(import_keys12.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
5489
+ this._seenPeers = new import_util11.ComplexSet(import_keys13.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
5192
5490
  if (firstUnknownPeer != null) {
5193
- (0, import_log16.log)("invitation connect", {
5491
+ (0, import_log18.log)("invitation connect", {
5194
5492
  ownPeerId,
5195
5493
  remotePeerId: firstUnknownPeer
5196
5494
  }, {
5197
- F: __dxlog_file18,
5495
+ F: __dxlog_file20,
5198
5496
  L: 69,
5199
5497
  S: this,
5200
5498
  C: (f, a) => f(...a)
@@ -5204,8 +5502,8 @@ var InvitationTopology = class {
5204
5502
  }
5205
5503
  }
5206
5504
  async onOffer(peer) {
5207
- (0, import_invariant15.invariant)(this._controller, "Not initialized.", {
5208
- F: __dxlog_file18,
5505
+ (0, import_invariant16.invariant)(this._controller, "Not initialized.", {
5506
+ F: __dxlog_file20,
5209
5507
  L: 76,
5210
5508
  S: this,
5211
5509
  A: [
@@ -5222,20 +5520,21 @@ var InvitationTopology = class {
5222
5520
  return `InvitationTopology(${this._role === import_invitations5.InvitationOptions.Role.GUEST ? "guest" : "host"})`;
5223
5521
  }
5224
5522
  };
5225
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
5523
+ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
5226
5524
  var metrics = import_tracing8.trace.metrics;
5227
5525
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
5228
5526
  var InvitationsHandler = class {
5229
5527
  /**
5230
5528
  * @internal
5231
5529
  */
5232
- constructor(_networkManager, _defaultTeleportParams) {
5530
+ constructor(_networkManager, _edgeClient, _connectionParams) {
5233
5531
  this._networkManager = _networkManager;
5234
- this._defaultTeleportParams = _defaultTeleportParams;
5532
+ this._edgeClient = _edgeClient;
5533
+ this._connectionParams = _connectionParams;
5235
5534
  }
5236
5535
  handleInvitationFlow(ctx, stream, protocol, invitation) {
5237
5536
  metrics.increment("dxos.invitation.created");
5238
- const guardedState = this._createGuardedState(ctx, invitation, stream);
5537
+ const guardedState = createGuardedInvitationState(ctx, invitation, stream);
5239
5538
  const createExtension = () => {
5240
5539
  const extension = new InvitationHostExtension(guardedState.mutex, {
5241
5540
  get activeInvitation() {
@@ -5249,8 +5548,8 @@ var InvitationsHandler = class {
5249
5548
  try {
5250
5549
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
5251
5550
  (0, import_invariant12.invariant)(deviceKey, void 0, {
5252
- F: __dxlog_file19,
5253
- L: 94,
5551
+ F: __dxlog_file21,
5552
+ L: 100,
5254
5553
  S: this,
5255
5554
  A: [
5256
5555
  "deviceKey",
@@ -5278,16 +5577,16 @@ var InvitationsHandler = class {
5278
5577
  import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.begin({
5279
5578
  id: traceId
5280
5579
  }), {
5281
- F: __dxlog_file19,
5282
- L: 119,
5580
+ F: __dxlog_file21,
5581
+ L: 125,
5283
5582
  S: this,
5284
5583
  C: (f, a) => f(...a)
5285
5584
  });
5286
5585
  (0, import_log13.log)("connected", {
5287
5586
  ...protocol.toJSON()
5288
5587
  }, {
5289
- F: __dxlog_file19,
5290
- L: 120,
5588
+ F: __dxlog_file21,
5589
+ L: 126,
5291
5590
  S: this,
5292
5591
  C: (f, a) => f(...a)
5293
5592
  });
@@ -5298,8 +5597,8 @@ var InvitationsHandler = class {
5298
5597
  guest: deviceKey,
5299
5598
  ...protocol.toJSON()
5300
5599
  }, {
5301
- F: __dxlog_file19,
5302
- L: 122,
5600
+ F: __dxlog_file21,
5601
+ L: 128,
5303
5602
  S: this,
5304
5603
  C: (f, a) => f(...a)
5305
5604
  });
@@ -5308,8 +5607,8 @@ var InvitationsHandler = class {
5308
5607
  import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.end({
5309
5608
  id: traceId
5310
5609
  }), {
5311
- F: __dxlog_file19,
5312
- L: 125,
5610
+ F: __dxlog_file21,
5611
+ L: 131,
5313
5612
  S: this,
5314
5613
  C: (f, a) => f(...a)
5315
5614
  });
@@ -5324,8 +5623,8 @@ var InvitationsHandler = class {
5324
5623
  (0, import_log13.log)("timeout", {
5325
5624
  ...protocol.toJSON()
5326
5625
  }, {
5327
- F: __dxlog_file19,
5328
- L: 135,
5626
+ F: __dxlog_file21,
5627
+ L: 141,
5329
5628
  S: this,
5330
5629
  C: (f, a) => f(...a)
5331
5630
  });
@@ -5334,8 +5633,8 @@ var InvitationsHandler = class {
5334
5633
  if (guardedState.error(extension, err)) {
5335
5634
  metrics.increment("dxos.invitation.failed");
5336
5635
  import_log13.log.error("failed", err, {
5337
- F: __dxlog_file19,
5338
- L: 140,
5636
+ F: __dxlog_file21,
5637
+ L: 146,
5339
5638
  S: this,
5340
5639
  C: (f, a) => f(...a)
5341
5640
  });
@@ -5345,8 +5644,8 @@ var InvitationsHandler = class {
5345
5644
  id: traceId,
5346
5645
  error: err
5347
5646
  }), {
5348
- F: __dxlog_file19,
5349
- L: 143,
5647
+ F: __dxlog_file21,
5648
+ L: 149,
5350
5649
  S: this,
5351
5650
  C: (f, a) => f(...a)
5352
5651
  });
@@ -5359,8 +5658,8 @@ var InvitationsHandler = class {
5359
5658
  (0, import_log13.log)("invalid role", {
5360
5659
  ...err.context
5361
5660
  }, {
5362
- F: __dxlog_file19,
5363
- L: 151,
5661
+ F: __dxlog_file21,
5662
+ L: 157,
5364
5663
  S: this,
5365
5664
  C: (f, a) => f(...a)
5366
5665
  });
@@ -5372,8 +5671,8 @@ var InvitationsHandler = class {
5372
5671
  (0, import_log13.log)("timeout", {
5373
5672
  err
5374
5673
  }, {
5375
- F: __dxlog_file19,
5376
- L: 157,
5674
+ F: __dxlog_file21,
5675
+ L: 163,
5377
5676
  S: this,
5378
5677
  C: (f, a) => f(...a)
5379
5678
  });
@@ -5382,8 +5681,8 @@ var InvitationsHandler = class {
5382
5681
  if (guardedState.error(extension, err)) {
5383
5682
  metrics.increment("dxos.invitation.failed");
5384
5683
  import_log13.log.error("failed", err, {
5385
- F: __dxlog_file19,
5386
- L: 162,
5684
+ F: __dxlog_file21,
5685
+ L: 168,
5387
5686
  S: this,
5388
5687
  C: (f, a) => f(...a)
5389
5688
  });
@@ -5396,8 +5695,8 @@ var InvitationsHandler = class {
5396
5695
  if (invitation.lifetime && invitation.created) {
5397
5696
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
5398
5697
  import_log13.log.warn("invitation has already expired", void 0, {
5399
- F: __dxlog_file19,
5400
- L: 173,
5698
+ F: __dxlog_file21,
5699
+ L: 179,
5401
5700
  S: this,
5402
5701
  C: (f, a) => f(...a)
5403
5702
  });
@@ -5420,8 +5719,8 @@ var InvitationsHandler = class {
5420
5719
  const { timeout = import_client_protocol5.INVITATION_TIMEOUT } = invitation;
5421
5720
  if (deviceProfile) {
5422
5721
  (0, import_invariant12.invariant)(invitation.kind === import_services11.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
5423
- F: __dxlog_file19,
5424
- L: 207,
5722
+ F: __dxlog_file21,
5723
+ L: 213,
5425
5724
  S: this,
5426
5725
  A: [
5427
5726
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -5430,7 +5729,7 @@ var InvitationsHandler = class {
5430
5729
  });
5431
5730
  }
5432
5731
  const triedPeersIds = new import_util10.ComplexSet(import_keys10.PublicKey.hash);
5433
- const guardedState = this._createGuardedState(ctx, invitation, stream);
5732
+ const guardedState = createGuardedInvitationState(ctx, invitation, stream);
5434
5733
  const shouldCancelInvitationFlow = (extension) => {
5435
5734
  const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
5436
5735
  (0, import_log13.log)("should cancel invitation flow", {
@@ -5438,8 +5737,8 @@ var InvitationsHandler = class {
5438
5737
  invitationType: import_services11.Invitation.Type.DELEGATED,
5439
5738
  triedPeers: triedPeersIds.size
5440
5739
  }, {
5441
- F: __dxlog_file19,
5442
- L: 215,
5740
+ F: __dxlog_file21,
5741
+ L: 221,
5443
5742
  S: this,
5444
5743
  C: (f, a) => f(...a)
5445
5744
  });
@@ -5465,8 +5764,8 @@ var InvitationsHandler = class {
5465
5764
  admitted,
5466
5765
  currentState: guardedState.current.state
5467
5766
  }, {
5468
- F: __dxlog_file19,
5469
- L: 243,
5767
+ F: __dxlog_file21,
5768
+ L: 249,
5470
5769
  S: this,
5471
5770
  C: (f, a) => f(...a)
5472
5771
  });
@@ -5483,8 +5782,8 @@ var InvitationsHandler = class {
5483
5782
  import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.begin({
5484
5783
  id: traceId
5485
5784
  }), {
5486
- F: __dxlog_file19,
5487
- L: 255,
5785
+ F: __dxlog_file21,
5786
+ L: 261,
5488
5787
  S: this,
5489
5788
  C: (f, a) => f(...a)
5490
5789
  });
@@ -5495,8 +5794,8 @@ var InvitationsHandler = class {
5495
5794
  (0, import_log13.log)("connected", {
5496
5795
  ...protocol.toJSON()
5497
5796
  }, {
5498
- F: __dxlog_file19,
5499
- L: 266,
5797
+ F: __dxlog_file21,
5798
+ L: 272,
5500
5799
  S: this,
5501
5800
  C: (f, a) => f(...a)
5502
5801
  });
@@ -5504,8 +5803,8 @@ var InvitationsHandler = class {
5504
5803
  (0, import_log13.log)("introduce", {
5505
5804
  ...protocol.toJSON()
5506
5805
  }, {
5507
- F: __dxlog_file19,
5508
- L: 270,
5806
+ F: __dxlog_file21,
5807
+ L: 276,
5509
5808
  S: this,
5510
5809
  C: (f, a) => f(...a)
5511
5810
  });
@@ -5517,8 +5816,8 @@ var InvitationsHandler = class {
5517
5816
  ...protocol.toJSON(),
5518
5817
  response: introductionResponse
5519
5818
  }, {
5520
- F: __dxlog_file19,
5521
- L: 275,
5819
+ F: __dxlog_file21,
5820
+ L: 281,
5522
5821
  S: this,
5523
5822
  C: (f, a) => f(...a)
5524
5823
  });
@@ -5538,8 +5837,8 @@ var InvitationsHandler = class {
5538
5837
  (0, import_log13.log)("request admission", {
5539
5838
  ...protocol.toJSON()
5540
5839
  }, {
5541
- F: __dxlog_file19,
5542
- L: 301,
5840
+ F: __dxlog_file21,
5841
+ L: 307,
5543
5842
  S: this,
5544
5843
  C: (f, a) => f(...a)
5545
5844
  });
@@ -5550,12 +5849,12 @@ var InvitationsHandler = class {
5550
5849
  (0, import_log13.log)("admitted by host", {
5551
5850
  ...protocol.toJSON()
5552
5851
  }, {
5553
- F: __dxlog_file19,
5554
- L: 312,
5852
+ F: __dxlog_file21,
5853
+ L: 318,
5555
5854
  S: this,
5556
5855
  C: (f, a) => f(...a)
5557
5856
  });
5558
- await guardedState.complete({
5857
+ guardedState.complete({
5559
5858
  ...guardedState.current,
5560
5859
  ...result,
5561
5860
  state: import_services11.Invitation.State.SUCCESS
@@ -5563,8 +5862,8 @@ var InvitationsHandler = class {
5563
5862
  import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.end({
5564
5863
  id: traceId
5565
5864
  }), {
5566
- F: __dxlog_file19,
5567
- L: 318,
5865
+ F: __dxlog_file21,
5866
+ L: 324,
5568
5867
  S: this,
5569
5868
  C: (f, a) => f(...a)
5570
5869
  });
@@ -5573,16 +5872,16 @@ var InvitationsHandler = class {
5573
5872
  (0, import_log13.log)("timeout", {
5574
5873
  ...protocol.toJSON()
5575
5874
  }, {
5576
- F: __dxlog_file19,
5577
- L: 321,
5875
+ F: __dxlog_file21,
5876
+ L: 327,
5578
5877
  S: this,
5579
5878
  C: (f, a) => f(...a)
5580
5879
  });
5581
5880
  guardedState.set(extension, import_services11.Invitation.State.TIMEOUT);
5582
5881
  } else {
5583
5882
  (0, import_log13.log)("auth failed", err, {
5584
- F: __dxlog_file19,
5585
- L: 324,
5883
+ F: __dxlog_file21,
5884
+ L: 330,
5586
5885
  S: this,
5587
5886
  C: (f, a) => f(...a)
5588
5887
  });
@@ -5593,8 +5892,8 @@ var InvitationsHandler = class {
5593
5892
  id: traceId,
5594
5893
  error: err
5595
5894
  }), {
5596
- F: __dxlog_file19,
5597
- L: 328,
5895
+ F: __dxlog_file21,
5896
+ L: 334,
5598
5897
  S: this,
5599
5898
  C: (f, a) => f(...a)
5600
5899
  });
@@ -5609,16 +5908,16 @@ var InvitationsHandler = class {
5609
5908
  (0, import_log13.log)("timeout", {
5610
5909
  ...protocol.toJSON()
5611
5910
  }, {
5612
- F: __dxlog_file19,
5613
- L: 337,
5911
+ F: __dxlog_file21,
5912
+ L: 343,
5614
5913
  S: this,
5615
5914
  C: (f, a) => f(...a)
5616
5915
  });
5617
5916
  guardedState.set(extension, import_services11.Invitation.State.TIMEOUT);
5618
5917
  } else {
5619
5918
  (0, import_log13.log)("auth failed", err, {
5620
- F: __dxlog_file19,
5621
- L: 340,
5919
+ F: __dxlog_file21,
5920
+ L: 346,
5622
5921
  S: this,
5623
5922
  C: (f, a) => f(...a)
5624
5923
  });
@@ -5628,6 +5927,25 @@ var InvitationsHandler = class {
5628
5927
  });
5629
5928
  return extension;
5630
5929
  };
5930
+ const edgeInvitationHandler = new EdgeInvitationHandler(this._connectionParams?.edgeInvitations, this._edgeClient, {
5931
+ onInvitationSuccess: async (admissionResponse, admissionRequest) => {
5932
+ const result = await protocol.accept(admissionResponse, admissionRequest);
5933
+ (0, import_log13.log)("admitted by edge", {
5934
+ ...protocol.toJSON()
5935
+ }, {
5936
+ F: __dxlog_file21,
5937
+ L: 358,
5938
+ S: this,
5939
+ C: (f, a) => f(...a)
5940
+ });
5941
+ guardedState.complete({
5942
+ ...guardedState.current,
5943
+ ...result,
5944
+ state: import_services11.Invitation.State.SUCCESS
5945
+ });
5946
+ }
5947
+ });
5948
+ edgeInvitationHandler.handle(ctx, guardedState, protocol, deviceProfile);
5631
5949
  (0, import_async15.scheduleTask)(ctx, async () => {
5632
5950
  const error = protocol.checkInvitation(invitation);
5633
5951
  if (error) {
@@ -5635,8 +5953,8 @@ var InvitationsHandler = class {
5635
5953
  await ctx.dispose();
5636
5954
  } else {
5637
5955
  (0, import_invariant12.invariant)(invitation.swarmKey, void 0, {
5638
- F: __dxlog_file19,
5639
- L: 355,
5956
+ F: __dxlog_file21,
5957
+ L: 370,
5640
5958
  S: this,
5641
5959
  A: [
5642
5960
  "invitation.swarmKey",
@@ -5669,119 +5987,26 @@ var InvitationsHandler = class {
5669
5987
  topic: invitation.swarmKey,
5670
5988
  protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
5671
5989
  teleport.addExtension("dxos.halo.invitations", extensionFactory());
5672
- }, this._defaultTeleportParams),
5990
+ }, this._connectionParams?.teleport),
5673
5991
  topology: new InvitationTopology(role),
5674
5992
  label
5675
5993
  });
5676
5994
  ctx.onDispose(() => swarmConnection.close());
5677
5995
  return swarmConnection;
5678
5996
  }
5679
- /**
5680
- * A utility object for serializing invitation state changes by multiple concurrent
5681
- * invitation flow connections.
5682
- */
5683
- _createGuardedState(ctx, invitation, stream) {
5684
- const mutex = new import_async15.Mutex();
5685
- let lastActiveExtension = null;
5686
- let currentInvitation = {
5687
- ...invitation
5688
- };
5689
- const isStateChangeAllowed = (extension) => {
5690
- if (ctx.disposed || extension !== null && mutex.isLocked() && !extension.hasFlowLock()) {
5691
- return false;
5692
- }
5693
- return extension == null || lastActiveExtension !== extension || this._isNotTerminal(currentInvitation.state);
5694
- };
5695
- return {
5696
- mutex,
5697
- get current() {
5698
- return currentInvitation;
5699
- },
5700
- // disposing context prevents any further state updates
5701
- complete: (newState) => {
5702
- currentInvitation = {
5703
- ...currentInvitation,
5704
- ...newState
5705
- };
5706
- stream.next(currentInvitation);
5707
- return ctx.dispose();
5708
- },
5709
- set: (extension, newState) => {
5710
- if (isStateChangeAllowed(extension)) {
5711
- this._logStateUpdate(currentInvitation, extension, newState);
5712
- currentInvitation = {
5713
- ...currentInvitation,
5714
- state: newState
5715
- };
5716
- stream.next(currentInvitation);
5717
- lastActiveExtension = extension;
5718
- return true;
5719
- }
5720
- return false;
5721
- },
5722
- error: (extension, error) => {
5723
- if (isStateChangeAllowed(extension)) {
5724
- this._logStateUpdate(currentInvitation, extension, import_services11.Invitation.State.ERROR);
5725
- currentInvitation = {
5726
- ...currentInvitation,
5727
- state: import_services11.Invitation.State.ERROR
5728
- };
5729
- stream.next(currentInvitation);
5730
- stream.error(error);
5731
- lastActiveExtension = extension;
5732
- return true;
5733
- }
5734
- return false;
5735
- }
5736
- };
5737
- }
5738
- _logStateUpdate(invitation, actor, newState) {
5739
- if (this._isNotTerminal(newState)) {
5740
- (0, import_log13.log)("invitation state update", {
5741
- actor: actor?.constructor.name,
5742
- newState: stateToString(newState),
5743
- oldState: stateToString(invitation.state)
5744
- }, {
5745
- F: __dxlog_file19,
5746
- L: 460,
5747
- S: this,
5748
- C: (f, a) => f(...a)
5749
- });
5750
- } else {
5751
- (0, import_log13.log)("invitation state update", {
5752
- actor: actor?.constructor.name,
5753
- newState: stateToString(newState),
5754
- oldState: stateToString(invitation.state)
5755
- }, {
5756
- F: __dxlog_file19,
5757
- L: 466,
5758
- S: this,
5759
- C: (f, a) => f(...a)
5760
- });
5761
- }
5762
- }
5763
- _isNotTerminal(currentState) {
5764
- return ![
5765
- import_services11.Invitation.State.SUCCESS,
5766
- import_services11.Invitation.State.ERROR,
5767
- import_services11.Invitation.State.CANCELLED,
5768
- import_services11.Invitation.State.TIMEOUT,
5769
- import_services11.Invitation.State.EXPIRED
5770
- ].includes(currentState);
5771
- }
5772
5997
  async _handleGuestOtpAuth(extension, setState, authenticated, options) {
5773
5998
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
5774
5999
  (0, import_log13.log)("guest waiting for authentication code...", void 0, {
5775
- F: __dxlog_file19,
5776
- L: 491,
6000
+ F: __dxlog_file21,
6001
+ L: 422,
5777
6002
  S: this,
5778
6003
  C: (f, a) => f(...a)
5779
6004
  });
5780
6005
  setState(import_services11.Invitation.State.READY_FOR_AUTHENTICATION);
5781
6006
  const authCode = await authenticated.wait(options);
5782
6007
  (0, import_log13.log)("sending authentication request", void 0, {
5783
- F: __dxlog_file19,
5784
- L: 495,
6008
+ F: __dxlog_file21,
6009
+ L: 426,
5785
6010
  S: this,
5786
6011
  C: (f, a) => f(...a)
5787
6012
  });
@@ -5799,8 +6024,8 @@ var InvitationsHandler = class {
5799
6024
  (0, import_log13.log)("retrying invalid code", {
5800
6025
  attempt
5801
6026
  }, {
5802
- F: __dxlog_file19,
5803
- L: 506,
6027
+ F: __dxlog_file21,
6028
+ L: 437,
5804
6029
  S: this,
5805
6030
  C: (f, a) => f(...a)
5806
6031
  });
@@ -5817,8 +6042,8 @@ var InvitationsHandler = class {
5817
6042
  throw new Error("challenge missing in the introduction");
5818
6043
  }
5819
6044
  (0, import_log13.log)("sending authentication request", void 0, {
5820
- F: __dxlog_file19,
5821
- L: 525,
6045
+ F: __dxlog_file21,
6046
+ L: 456,
5822
6047
  S: this,
5823
6048
  C: (f, a) => f(...a)
5824
6049
  });
@@ -5868,8 +6093,8 @@ var InvitationsServiceImpl = class {
5868
6093
  return new import_codec_protobuf10.Stream(({ next, ctx }) => {
5869
6094
  this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
5870
6095
  next({
5871
- action: import_services14.QueryInvitationsResponse.Action.ADDED,
5872
- type: import_services14.QueryInvitationsResponse.Type.CREATED,
6096
+ action: import_services16.QueryInvitationsResponse.Action.ADDED,
6097
+ type: import_services16.QueryInvitationsResponse.Type.CREATED,
5873
6098
  invitations: [
5874
6099
  invitation
5875
6100
  ]
@@ -5877,8 +6102,8 @@ var InvitationsServiceImpl = class {
5877
6102
  });
5878
6103
  this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
5879
6104
  next({
5880
- action: import_services14.QueryInvitationsResponse.Action.ADDED,
5881
- type: import_services14.QueryInvitationsResponse.Type.ACCEPTED,
6105
+ action: import_services16.QueryInvitationsResponse.Action.ADDED,
6106
+ type: import_services16.QueryInvitationsResponse.Type.ACCEPTED,
5882
6107
  invitations: [
5883
6108
  invitation
5884
6109
  ]
@@ -5886,8 +6111,8 @@ var InvitationsServiceImpl = class {
5886
6111
  });
5887
6112
  this._invitationsManager.removedCreated.on(ctx, (invitation) => {
5888
6113
  next({
5889
- action: import_services14.QueryInvitationsResponse.Action.REMOVED,
5890
- type: import_services14.QueryInvitationsResponse.Type.CREATED,
6114
+ action: import_services16.QueryInvitationsResponse.Action.REMOVED,
6115
+ type: import_services16.QueryInvitationsResponse.Type.CREATED,
5891
6116
  invitations: [
5892
6117
  invitation
5893
6118
  ]
@@ -5895,8 +6120,8 @@ var InvitationsServiceImpl = class {
5895
6120
  });
5896
6121
  this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
5897
6122
  next({
5898
- action: import_services14.QueryInvitationsResponse.Action.REMOVED,
5899
- type: import_services14.QueryInvitationsResponse.Type.ACCEPTED,
6123
+ action: import_services16.QueryInvitationsResponse.Action.REMOVED,
6124
+ type: import_services16.QueryInvitationsResponse.Type.ACCEPTED,
5900
6125
  invitations: [
5901
6126
  invitation
5902
6127
  ]
@@ -5904,35 +6129,35 @@ var InvitationsServiceImpl = class {
5904
6129
  });
5905
6130
  this._invitationsManager.saved.on(ctx, (invitation) => {
5906
6131
  next({
5907
- action: import_services14.QueryInvitationsResponse.Action.SAVED,
5908
- type: import_services14.QueryInvitationsResponse.Type.CREATED,
6132
+ action: import_services16.QueryInvitationsResponse.Action.SAVED,
6133
+ type: import_services16.QueryInvitationsResponse.Type.CREATED,
5909
6134
  invitations: [
5910
6135
  invitation
5911
6136
  ]
5912
6137
  });
5913
6138
  });
5914
6139
  next({
5915
- action: import_services14.QueryInvitationsResponse.Action.ADDED,
5916
- type: import_services14.QueryInvitationsResponse.Type.CREATED,
6140
+ action: import_services16.QueryInvitationsResponse.Action.ADDED,
6141
+ type: import_services16.QueryInvitationsResponse.Type.CREATED,
5917
6142
  invitations: this._invitationsManager.getCreatedInvitations(),
5918
6143
  existing: true
5919
6144
  });
5920
6145
  next({
5921
- action: import_services14.QueryInvitationsResponse.Action.ADDED,
5922
- type: import_services14.QueryInvitationsResponse.Type.ACCEPTED,
6146
+ action: import_services16.QueryInvitationsResponse.Action.ADDED,
6147
+ type: import_services16.QueryInvitationsResponse.Type.ACCEPTED,
5923
6148
  invitations: this._invitationsManager.getAcceptedInvitations(),
5924
6149
  existing: true
5925
6150
  });
5926
6151
  this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
5927
6152
  next({
5928
- action: import_services14.QueryInvitationsResponse.Action.LOAD_COMPLETE,
5929
- type: import_services14.QueryInvitationsResponse.Type.CREATED
6153
+ action: import_services16.QueryInvitationsResponse.Action.LOAD_COMPLETE,
6154
+ type: import_services16.QueryInvitationsResponse.Type.CREATED
5930
6155
  });
5931
6156
  });
5932
6157
  });
5933
6158
  }
5934
6159
  };
5935
- var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
6160
+ var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
5936
6161
  var SpaceInvitationProtocol = class {
5937
6162
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
5938
6163
  this._spaceManager = _spaceManager;
@@ -5948,39 +6173,59 @@ var SpaceInvitationProtocol = class {
5948
6173
  }
5949
6174
  checkCanInviteNewMembers() {
5950
6175
  if (this._spaceKey == null) {
5951
- return new import_protocols12.InvalidInvitationError("No spaceKey was provided for a space invitation.");
6176
+ return new import_protocols13.InvalidInvitationError("No spaceKey was provided for a space invitation.");
5952
6177
  }
5953
6178
  const space = this._spaceManager.spaces.get(this._spaceKey);
5954
6179
  if (space == null) {
5955
- return new import_protocols12.SpaceNotFoundError(this._spaceKey);
6180
+ return new import_protocols13.SpaceNotFoundError(this._spaceKey);
5956
6181
  }
5957
6182
  if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
5958
- return new import_protocols12.AuthorizationError("No member management permission.");
6183
+ return new import_protocols13.AuthorizationError("No member management permission.");
5959
6184
  }
5960
6185
  return void 0;
5961
6186
  }
5962
6187
  getInvitationContext() {
6188
+ (0, import_invariant17.invariant)(this._spaceKey, void 0, {
6189
+ F: __dxlog_file22,
6190
+ L: 63,
6191
+ S: this,
6192
+ A: [
6193
+ "this._spaceKey",
6194
+ ""
6195
+ ]
6196
+ });
6197
+ const space = this._spaceManager.spaces.get(this._spaceKey);
6198
+ (0, import_invariant17.invariant)(space, void 0, {
6199
+ F: __dxlog_file22,
6200
+ L: 65,
6201
+ S: this,
6202
+ A: [
6203
+ "space",
6204
+ ""
6205
+ ]
6206
+ });
5963
6207
  return {
5964
- kind: import_services15.Invitation.Kind.SPACE,
5965
- spaceKey: this._spaceKey
6208
+ kind: import_services17.Invitation.Kind.SPACE,
6209
+ spaceKey: this._spaceKey,
6210
+ spaceId: space.id
5966
6211
  };
5967
6212
  }
5968
6213
  async admit(invitation, request, guestProfile) {
5969
- (0, import_invariant16.invariant)(this._spaceKey && request.space, void 0, {
5970
- F: __dxlog_file20,
5971
- L: 74,
6214
+ (0, import_invariant17.invariant)(this._spaceKey && request.space, void 0, {
6215
+ F: __dxlog_file22,
6216
+ L: 78,
5972
6217
  S: this,
5973
6218
  A: [
5974
6219
  "this._spaceKey && request.space",
5975
6220
  ""
5976
6221
  ]
5977
6222
  });
5978
- (0, import_log17.log)("writing guest credentials", {
6223
+ (0, import_log19.log)("writing guest credentials", {
5979
6224
  host: this._signingContext.deviceKey,
5980
6225
  guest: request.space.deviceKey
5981
6226
  }, {
5982
- F: __dxlog_file20,
5983
- L: 75,
6227
+ F: __dxlog_file22,
6228
+ L: 79,
5984
6229
  S: this,
5985
6230
  C: (f, a) => f(...a)
5986
6231
  });
@@ -6000,9 +6245,9 @@ var SpaceInvitationProtocol = class {
6000
6245
  };
6001
6246
  }
6002
6247
  async delegate(invitation) {
6003
- (0, import_invariant16.invariant)(this._spaceKey, void 0, {
6004
- F: __dxlog_file20,
6005
- L: 95,
6248
+ (0, import_invariant17.invariant)(this._spaceKey, void 0, {
6249
+ F: __dxlog_file22,
6250
+ L: 99,
6006
6251
  S: this,
6007
6252
  A: [
6008
6253
  "this._spaceKey",
@@ -6010,19 +6255,19 @@ var SpaceInvitationProtocol = class {
6010
6255
  ]
6011
6256
  });
6012
6257
  const space = this._spaceManager.spaces.get(this._spaceKey);
6013
- (0, import_invariant16.invariant)(space, void 0, {
6014
- F: __dxlog_file20,
6015
- L: 97,
6258
+ (0, import_invariant17.invariant)(space, void 0, {
6259
+ F: __dxlog_file22,
6260
+ L: 101,
6016
6261
  S: this,
6017
6262
  A: [
6018
6263
  "space",
6019
6264
  ""
6020
6265
  ]
6021
6266
  });
6022
- if (invitation.authMethod === import_services15.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
6023
- (0, import_invariant16.invariant)(invitation.guestKeypair?.publicKey, void 0, {
6024
- F: __dxlog_file20,
6025
- L: 99,
6267
+ if (invitation.authMethod === import_services17.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
6268
+ (0, import_invariant17.invariant)(invitation.guestKeypair?.publicKey, void 0, {
6269
+ F: __dxlog_file22,
6270
+ L: 103,
6026
6271
  S: this,
6027
6272
  A: [
6028
6273
  "invitation.guestKeypair?.publicKey",
@@ -6030,12 +6275,12 @@ var SpaceInvitationProtocol = class {
6030
6275
  ]
6031
6276
  });
6032
6277
  }
6033
- (0, import_log17.log)("writing delegate space invitation", {
6278
+ (0, import_log19.log)("writing delegate space invitation", {
6034
6279
  host: this._signingContext.deviceKey,
6035
6280
  id: invitation.invitationId
6036
6281
  }, {
6037
- F: __dxlog_file20,
6038
- L: 102,
6282
+ F: __dxlog_file22,
6283
+ L: 106,
6039
6284
  S: this,
6040
6285
  C: (f, a) => f(...a)
6041
6286
  });
@@ -6046,11 +6291,11 @@ var SpaceInvitationProtocol = class {
6046
6291
  role: invitation.role ?? import_credentials18.SpaceMember.Role.ADMIN,
6047
6292
  expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
6048
6293
  multiUse: invitation.multiUse ?? false,
6049
- guestKey: invitation.authMethod === import_services15.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
6294
+ guestKey: invitation.authMethod === import_services17.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
6050
6295
  });
6051
- (0, import_invariant16.invariant)(credential.credential, void 0, {
6052
- F: __dxlog_file20,
6053
- L: 122,
6296
+ (0, import_invariant17.invariant)(credential.credential, void 0, {
6297
+ F: __dxlog_file22,
6298
+ L: 126,
6054
6299
  S: this,
6055
6300
  A: [
6056
6301
  "credential.credential",
@@ -6063,18 +6308,18 @@ var SpaceInvitationProtocol = class {
6063
6308
  return credential.credential.credential.id;
6064
6309
  }
6065
6310
  async cancelDelegation(invitation) {
6066
- (0, import_invariant16.invariant)(this._spaceKey, void 0, {
6067
- F: __dxlog_file20,
6068
- L: 128,
6311
+ (0, import_invariant17.invariant)(this._spaceKey, void 0, {
6312
+ F: __dxlog_file22,
6313
+ L: 132,
6069
6314
  S: this,
6070
6315
  A: [
6071
6316
  "this._spaceKey",
6072
6317
  ""
6073
6318
  ]
6074
6319
  });
6075
- (0, import_invariant16.invariant)(invitation.type === import_services15.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6076
- F: __dxlog_file20,
6077
- L: 129,
6320
+ (0, import_invariant17.invariant)(invitation.type === import_services17.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6321
+ F: __dxlog_file22,
6322
+ L: 133,
6078
6323
  S: this,
6079
6324
  A: [
6080
6325
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -6082,28 +6327,28 @@ var SpaceInvitationProtocol = class {
6082
6327
  ]
6083
6328
  });
6084
6329
  const space = this._spaceManager.spaces.get(this._spaceKey);
6085
- (0, import_invariant16.invariant)(space, void 0, {
6086
- F: __dxlog_file20,
6087
- L: 131,
6330
+ (0, import_invariant17.invariant)(space, void 0, {
6331
+ F: __dxlog_file22,
6332
+ L: 135,
6088
6333
  S: this,
6089
6334
  A: [
6090
6335
  "space",
6091
6336
  ""
6092
6337
  ]
6093
6338
  });
6094
- (0, import_log17.log)("cancelling delegated space invitation", {
6339
+ (0, import_log19.log)("cancelling delegated space invitation", {
6095
6340
  host: this._signingContext.deviceKey,
6096
6341
  id: invitation.invitationId
6097
6342
  }, {
6098
- F: __dxlog_file20,
6099
- L: 133,
6343
+ F: __dxlog_file22,
6344
+ L: 137,
6100
6345
  S: this,
6101
6346
  C: (f, a) => f(...a)
6102
6347
  });
6103
6348
  const credential = await (0, import_credentials17.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
6104
- (0, import_invariant16.invariant)(credential.credential, void 0, {
6105
- F: __dxlog_file20,
6106
- L: 140,
6349
+ (0, import_invariant17.invariant)(credential.credential, void 0, {
6350
+ F: __dxlog_file22,
6351
+ L: 144,
6107
6352
  S: this,
6108
6353
  A: [
6109
6354
  "credential.credential",
@@ -6116,10 +6361,10 @@ var SpaceInvitationProtocol = class {
6116
6361
  }
6117
6362
  checkInvitation(invitation) {
6118
6363
  if (invitation.spaceKey == null) {
6119
- return new import_protocols12.InvalidInvitationError("No spaceKey was provided for a space invitation.");
6364
+ return new import_protocols13.InvalidInvitationError("No spaceKey was provided for a space invitation.");
6120
6365
  }
6121
6366
  if (this._spaceManager.spaces.has(invitation.spaceKey)) {
6122
- return new import_protocols12.AlreadyJoinedError("Already joined space.");
6367
+ return new import_protocols13.AlreadyJoinedError("Already joined space.");
6123
6368
  }
6124
6369
  }
6125
6370
  createIntroduction() {
@@ -6140,9 +6385,9 @@ var SpaceInvitationProtocol = class {
6140
6385
  };
6141
6386
  }
6142
6387
  async accept(response) {
6143
- (0, import_invariant16.invariant)(response.space, void 0, {
6144
- F: __dxlog_file20,
6145
- L: 175,
6388
+ (0, import_invariant17.invariant)(response.space, void 0, {
6389
+ F: __dxlog_file22,
6390
+ L: 179,
6146
6391
  S: this,
6147
6392
  A: [
6148
6393
  "response.space",
@@ -6151,18 +6396,18 @@ var SpaceInvitationProtocol = class {
6151
6396
  });
6152
6397
  const { credential, controlTimeframe, dataTimeframe } = response.space;
6153
6398
  const assertion = (0, import_credentials17.getCredentialAssertion)(credential);
6154
- (0, import_invariant16.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
6155
- F: __dxlog_file20,
6156
- L: 178,
6399
+ (0, import_invariant17.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
6400
+ F: __dxlog_file22,
6401
+ L: 182,
6157
6402
  S: this,
6158
6403
  A: [
6159
6404
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
6160
6405
  "'Invalid credential'"
6161
6406
  ]
6162
6407
  });
6163
- (0, import_invariant16.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
6164
- F: __dxlog_file20,
6165
- L: 179,
6408
+ (0, import_invariant17.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
6409
+ F: __dxlog_file22,
6410
+ L: 183,
6166
6411
  S: this,
6167
6412
  A: [
6168
6413
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -6170,7 +6415,7 @@ var SpaceInvitationProtocol = class {
6170
6415
  ]
6171
6416
  });
6172
6417
  if (this._spaceManager.spaces.has(assertion.spaceKey)) {
6173
- throw new import_protocols12.AlreadyJoinedError("Already joined space.");
6418
+ throw new import_protocols13.AlreadyJoinedError("Already joined space.");
6174
6419
  }
6175
6420
  await this._spaceManager.acceptSpace({
6176
6421
  spaceKey: assertion.spaceKey,
@@ -6184,7 +6429,7 @@ var SpaceInvitationProtocol = class {
6184
6429
  };
6185
6430
  }
6186
6431
  };
6187
- var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
6432
+ var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
6188
6433
  var InvitationsManager = class {
6189
6434
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
6190
6435
  this._invitationsHandler = _invitationsHandler;
@@ -6192,12 +6437,12 @@ var InvitationsManager = class {
6192
6437
  this._metadataStore = _metadataStore;
6193
6438
  this._createInvitations = /* @__PURE__ */ new Map();
6194
6439
  this._acceptInvitations = /* @__PURE__ */ new Map();
6195
- this.invitationCreated = new import_async18.Event();
6196
- this.invitationAccepted = new import_async18.Event();
6197
- this.removedCreated = new import_async18.Event();
6198
- this.removedAccepted = new import_async18.Event();
6199
- this.saved = new import_async18.Event();
6200
- this._persistentInvitationsLoadedEvent = new import_async18.Event();
6440
+ this.invitationCreated = new import_async20.Event();
6441
+ this.invitationAccepted = new import_async20.Event();
6442
+ this.removedCreated = new import_async20.Event();
6443
+ this.removedAccepted = new import_async20.Event();
6444
+ this.saved = new import_async20.Event();
6445
+ this._persistentInvitationsLoadedEvent = new import_async20.Event();
6201
6446
  this._persistentInvitationsLoaded = false;
6202
6447
  }
6203
6448
  async createInvitation(options) {
@@ -6226,8 +6471,8 @@ var InvitationsManager = class {
6226
6471
  try {
6227
6472
  await this._persistIfRequired(handler, stream, invitation);
6228
6473
  } catch (err) {
6229
- import_log18.log.catch(err, void 0, {
6230
- F: __dxlog_file21,
6474
+ import_log20.log.catch(err, void 0, {
6475
+ F: __dxlog_file23,
6231
6476
  L: 82,
6232
6477
  S: this,
6233
6478
  C: (f, a) => f(...a)
@@ -6249,8 +6494,8 @@ var InvitationsManager = class {
6249
6494
  const persistentInvitations = this._metadataStore.getInvitations();
6250
6495
  const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline4.hasInvitationExpired)(invitation));
6251
6496
  const loadTasks = freshInvitations.map((persistentInvitation) => {
6252
- (0, import_invariant17.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
6253
- F: __dxlog_file21,
6497
+ (0, import_invariant18.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
6498
+ F: __dxlog_file23,
6254
6499
  L: 103,
6255
6500
  S: this,
6256
6501
  A: [
@@ -6268,8 +6513,8 @@ var InvitationsManager = class {
6268
6513
  invitations: cInvitations.map((invitation) => invitation.get())
6269
6514
  };
6270
6515
  } catch (err) {
6271
- import_log18.log.catch(err, void 0, {
6272
- F: __dxlog_file21,
6516
+ import_log20.log.catch(err, void 0, {
6517
+ F: __dxlog_file23,
6273
6518
  L: 110,
6274
6519
  S: this,
6275
6520
  C: (f, a) => f(...a)
@@ -6300,14 +6545,14 @@ var InvitationsManager = class {
6300
6545
  return invitation;
6301
6546
  }
6302
6547
  async authenticate({ invitationId, authCode }) {
6303
- (0, import_log18.log)("authenticating...", void 0, {
6304
- F: __dxlog_file21,
6548
+ (0, import_log20.log)("authenticating...", void 0, {
6549
+ F: __dxlog_file23,
6305
6550
  L: 140,
6306
6551
  S: this,
6307
6552
  C: (f, a) => f(...a)
6308
6553
  });
6309
- (0, import_invariant17.invariant)(invitationId, void 0, {
6310
- F: __dxlog_file21,
6554
+ (0, import_invariant18.invariant)(invitationId, void 0, {
6555
+ F: __dxlog_file23,
6311
6556
  L: 141,
6312
6557
  S: this,
6313
6558
  A: [
@@ -6317,10 +6562,10 @@ var InvitationsManager = class {
6317
6562
  });
6318
6563
  const observable = this._acceptInvitations.get(invitationId);
6319
6564
  if (!observable) {
6320
- import_log18.log.warn("invalid invitation", {
6565
+ import_log20.log.warn("invalid invitation", {
6321
6566
  invitationId
6322
6567
  }, {
6323
- F: __dxlog_file21,
6568
+ F: __dxlog_file23,
6324
6569
  L: 144,
6325
6570
  S: this,
6326
6571
  C: (f, a) => f(...a)
@@ -6330,16 +6575,16 @@ var InvitationsManager = class {
6330
6575
  }
6331
6576
  }
6332
6577
  async cancelInvitation({ invitationId }) {
6333
- (0, import_log18.log)("cancelInvitation...", {
6578
+ (0, import_log20.log)("cancelInvitation...", {
6334
6579
  invitationId
6335
6580
  }, {
6336
- F: __dxlog_file21,
6581
+ F: __dxlog_file23,
6337
6582
  L: 151,
6338
6583
  S: this,
6339
6584
  C: (f, a) => f(...a)
6340
6585
  });
6341
- (0, import_invariant17.invariant)(invitationId, void 0, {
6342
- F: __dxlog_file21,
6586
+ (0, import_invariant18.invariant)(invitationId, void 0, {
6587
+ F: __dxlog_file23,
6343
6588
  L: 152,
6344
6589
  S: this,
6345
6590
  A: [
@@ -6352,7 +6597,7 @@ var InvitationsManager = class {
6352
6597
  if (created.get().persistent) {
6353
6598
  await this._metadataStore.removeInvitation(invitationId);
6354
6599
  }
6355
- if (created.get().type === import_services16.Invitation.Type.DELEGATED) {
6600
+ if (created.get().type === import_services18.Invitation.Type.DELEGATED) {
6356
6601
  const handler = this._getHandler(created.get());
6357
6602
  await handler.cancelDelegation(created.get());
6358
6603
  }
@@ -6386,8 +6631,8 @@ var InvitationsManager = class {
6386
6631
  }
6387
6632
  }
6388
6633
  _createInvitation(protocol, options) {
6389
- const { invitationId = import_keys13.PublicKey.random().toHex(), type = import_services16.Invitation.Type.INTERACTIVE, authMethod = import_services16.Invitation.AuthMethod.SHARED_SECRET, state = import_services16.Invitation.State.INIT, timeout = import_client_protocol6.INVITATION_TIMEOUT, swarmKey = import_keys13.PublicKey.random(), persistent = options?.authMethod !== import_services16.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials20.SpaceMember.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
6390
- const authCode = options?.authCode ?? (authMethod === import_services16.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials19.generatePasscode)(import_client_protocol6.AUTHENTICATION_CODE_LENGTH) : void 0);
6634
+ const { invitationId = import_keys14.PublicKey.random().toHex(), type = import_services18.Invitation.Type.INTERACTIVE, authMethod = import_services18.Invitation.AuthMethod.SHARED_SECRET, state = import_services18.Invitation.State.INIT, timeout = import_client_protocol6.INVITATION_TIMEOUT, swarmKey = import_keys14.PublicKey.random(), persistent = options?.authMethod !== import_services18.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials20.SpaceMember.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
6635
+ const authCode = options?.authCode ?? (authMethod === import_services18.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials19.generatePasscode)(import_client_protocol6.AUTHENTICATION_CODE_LENGTH) : void 0);
6391
6636
  return {
6392
6637
  invitationId,
6393
6638
  type,
@@ -6396,8 +6641,8 @@ var InvitationsManager = class {
6396
6641
  swarmKey,
6397
6642
  authCode,
6398
6643
  timeout,
6399
- persistent: persistent && type !== import_services16.Invitation.Type.DELEGATED,
6400
- guestKeypair: guestKeypair ?? (authMethod === import_services16.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
6644
+ persistent: persistent && type !== import_services18.Invitation.Type.DELEGATED,
6645
+ guestKeypair: guestKeypair ?? (authMethod === import_services18.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
6401
6646
  created,
6402
6647
  lifetime,
6403
6648
  role,
@@ -6407,21 +6652,21 @@ var InvitationsManager = class {
6407
6652
  };
6408
6653
  }
6409
6654
  _createObservableInvitation(handler, invitation) {
6410
- const stream = new import_async18.PushStream();
6655
+ const stream = new import_async20.PushStream();
6411
6656
  const ctx = new import_context14.Context({
6412
6657
  onError: (err) => {
6413
6658
  stream.error(err);
6414
6659
  void ctx.dispose();
6415
6660
  }
6416
6661
  }, {
6417
- F: __dxlog_file21,
6662
+ F: __dxlog_file23,
6418
6663
  L: 234
6419
6664
  });
6420
6665
  ctx.onDispose(() => {
6421
- (0, import_log18.log)("complete", {
6666
+ (0, import_log20.log)("complete", {
6422
6667
  ...handler.toJSON()
6423
6668
  }, {
6424
- F: __dxlog_file21,
6669
+ F: __dxlog_file23,
6425
6670
  L: 241,
6426
6671
  S: this,
6427
6672
  C: (f, a) => f(...a)
@@ -6434,7 +6679,7 @@ var InvitationsManager = class {
6434
6679
  onCancel: async () => {
6435
6680
  stream.next({
6436
6681
  ...invitation,
6437
- state: import_services16.Invitation.State.CANCELLED
6682
+ state: import_services18.Invitation.State.CANCELLED
6438
6683
  });
6439
6684
  await ctx.dispose();
6440
6685
  }
@@ -6446,46 +6691,46 @@ var InvitationsManager = class {
6446
6691
  };
6447
6692
  }
6448
6693
  _createObservableAcceptingInvitation(handler, initialState) {
6449
- const otpEnteredTrigger = new import_async18.Trigger();
6450
- const stream = new import_async18.PushStream();
6694
+ const otpEnteredTrigger = new import_async20.Trigger();
6695
+ const stream = new import_async20.PushStream();
6451
6696
  const ctx = new import_context14.Context({
6452
6697
  onError: (err) => {
6453
- if (err instanceof import_async18.TimeoutError) {
6454
- (0, import_log18.log)("timeout", {
6698
+ if (err instanceof import_async20.TimeoutError) {
6699
+ (0, import_log20.log)("timeout", {
6455
6700
  ...handler.toJSON()
6456
6701
  }, {
6457
- F: __dxlog_file21,
6702
+ F: __dxlog_file23,
6458
6703
  L: 261,
6459
6704
  S: this,
6460
6705
  C: (f, a) => f(...a)
6461
6706
  });
6462
6707
  stream.next({
6463
6708
  ...initialState,
6464
- state: import_services16.Invitation.State.TIMEOUT
6709
+ state: import_services18.Invitation.State.TIMEOUT
6465
6710
  });
6466
6711
  } else {
6467
- import_log18.log.warn("auth failed", err, {
6468
- F: __dxlog_file21,
6712
+ import_log20.log.warn("auth failed", err, {
6713
+ F: __dxlog_file23,
6469
6714
  L: 264,
6470
6715
  S: this,
6471
6716
  C: (f, a) => f(...a)
6472
6717
  });
6473
6718
  stream.next({
6474
6719
  ...initialState,
6475
- state: import_services16.Invitation.State.ERROR
6720
+ state: import_services18.Invitation.State.ERROR
6476
6721
  });
6477
6722
  }
6478
6723
  void ctx.dispose();
6479
6724
  }
6480
6725
  }, {
6481
- F: __dxlog_file21,
6726
+ F: __dxlog_file23,
6482
6727
  L: 258
6483
6728
  });
6484
6729
  ctx.onDispose(() => {
6485
- (0, import_log18.log)("complete", {
6730
+ (0, import_log20.log)("complete", {
6486
6731
  ...handler.toJSON()
6487
6732
  }, {
6488
- F: __dxlog_file21,
6733
+ F: __dxlog_file23,
6489
6734
  L: 271,
6490
6735
  S: this,
6491
6736
  C: (f, a) => f(...a)
@@ -6498,7 +6743,7 @@ var InvitationsManager = class {
6498
6743
  onCancel: async () => {
6499
6744
  stream.next({
6500
6745
  ...initialState,
6501
- state: import_services16.Invitation.State.CANCELLED
6746
+ state: import_services18.Invitation.State.CANCELLED
6502
6747
  });
6503
6748
  await ctx.dispose();
6504
6749
  },
@@ -6514,7 +6759,7 @@ var InvitationsManager = class {
6514
6759
  };
6515
6760
  }
6516
6761
  async _persistIfRequired(handler, changeStream, invitation) {
6517
- if (invitation.type === import_services16.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
6762
+ if (invitation.type === import_services18.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
6518
6763
  const delegationCredentialId = await handler.delegate(invitation);
6519
6764
  changeStream.next({
6520
6765
  ...invitation,
@@ -6529,8 +6774,8 @@ var InvitationsManager = class {
6529
6774
  try {
6530
6775
  await this._metadataStore.removeInvitation(invitation.invitationId);
6531
6776
  } catch (err) {
6532
- import_log18.log.catch(err, void 0, {
6533
- F: __dxlog_file21,
6777
+ import_log20.log.catch(err, void 0, {
6778
+ F: __dxlog_file23,
6534
6779
  L: 307,
6535
6780
  S: this,
6536
6781
  C: (f, a) => f(...a)
@@ -6549,7 +6794,7 @@ function _ts_decorate7(decorators, target, key, desc) {
6549
6794
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6550
6795
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6551
6796
  }
6552
- var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
6797
+ var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
6553
6798
  var Lock = class {
6554
6799
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
6555
6800
  this._lockPath = lockPath;
@@ -6560,16 +6805,16 @@ var Lock = class {
6560
6805
  return this._lockPath;
6561
6806
  }
6562
6807
  async acquire() {
6563
- (0, import_log19.log)("acquiring lock...", void 0, {
6564
- F: __dxlog_file22,
6808
+ (0, import_log21.log)("acquiring lock...", void 0, {
6809
+ F: __dxlog_file24,
6565
6810
  L: 32,
6566
6811
  S: this,
6567
6812
  C: (f, a) => f(...a)
6568
6813
  });
6569
6814
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
6570
6815
  await this._onAcquire?.();
6571
- (0, import_log19.log)("acquired lock", void 0, {
6572
- F: __dxlog_file22,
6816
+ (0, import_log21.log)("acquired lock", void 0, {
6817
+ F: __dxlog_file24,
6573
6818
  L: 37,
6574
6819
  S: this,
6575
6820
  C: (f, a) => f(...a)
@@ -6577,8 +6822,8 @@ var Lock = class {
6577
6822
  }
6578
6823
  async release() {
6579
6824
  await this._onRelease?.();
6580
- (0, import_invariant18.invariant)(this._fileHandle, "Lock is not acquired", {
6581
- F: __dxlog_file22,
6825
+ (0, import_invariant19.invariant)(this._fileHandle, "Lock is not acquired", {
6826
+ F: __dxlog_file24,
6582
6827
  L: 42,
6583
6828
  S: this,
6584
6829
  A: [
@@ -6590,7 +6835,7 @@ var Lock = class {
6590
6835
  }
6591
6836
  };
6592
6837
  _ts_decorate7([
6593
- import_log19.logInfo
6838
+ import_log21.logInfo
6594
6839
  ], Lock.prototype, "lockKey", null);
6595
6840
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
6596
6841
  function _ts_decorate8(decorators, target, key, desc) {
@@ -6732,7 +6977,7 @@ function _using_ctx3() {
6732
6977
  }
6733
6978
  };
6734
6979
  }
6735
- var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
6980
+ var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
6736
6981
  var ServiceContext = class extends import_context15.Resource {
6737
6982
  constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
6738
6983
  super();
@@ -6744,12 +6989,12 @@ var ServiceContext = class extends import_context15.Resource {
6744
6989
  this._edgeHttpClient = _edgeHttpClient;
6745
6990
  this._runtimeParams = _runtimeParams;
6746
6991
  this._edgeFeatures = _edgeFeatures;
6747
- this._edgeIdentityUpdateMutex = new import_async19.Mutex();
6748
- this.initialized = new import_async19.Trigger();
6992
+ this._edgeIdentityUpdateMutex = new import_async21.Mutex();
6993
+ this.initialized = new import_async21.Trigger();
6749
6994
  this._meshReplicator = void 0;
6750
6995
  this._echoEdgeReplicator = void 0;
6751
6996
  this._handlerFactories = /* @__PURE__ */ new Map();
6752
- this._instanceId = import_keys14.PublicKey.random().toHex();
6997
+ this._instanceId = import_keys15.PublicKey.random().toHex();
6753
6998
  this.metadataStore = new import_echo_pipeline5.MetadataStore(storage.createDirectory("metadata"));
6754
6999
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
6755
7000
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
@@ -6782,16 +7027,16 @@ var ServiceContext = class extends import_context15.Resource {
6782
7027
  callbacks: {
6783
7028
  onIdentityConstruction: (identity) => {
6784
7029
  if (this._edgeConnection) {
6785
- (0, import_async19.scheduleMicroTask)(this._ctx, async () => {
7030
+ (0, import_async21.scheduleMicroTask)(this._ctx, async () => {
6786
7031
  try {
6787
7032
  var _usingCtx = _using_ctx3();
6788
7033
  const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
6789
- import_log20.log.info("Setting identity on edge connection", {
7034
+ import_log22.log.info("Setting identity on edge connection", {
6790
7035
  identity: identity.identityKey.toHex(),
6791
7036
  oldIdentity: this._edgeConnection.identityKey,
6792
7037
  swarms: this.networkManager.topics
6793
7038
  }, {
6794
- F: __dxlog_file23,
7039
+ F: __dxlog_file25,
6795
7040
  L: 147,
6796
7041
  S: this,
6797
7042
  C: (f, a) => f(...a)
@@ -6799,8 +7044,8 @@ var ServiceContext = class extends import_context15.Resource {
6799
7044
  await (0, import_debug6.warnAfterTimeout)(1e4, "Waiting for identity to be ready for edge connection", async () => {
6800
7045
  await identity.ready();
6801
7046
  });
6802
- (0, import_invariant19.invariant)(identity.deviceCredentialChain, void 0, {
6803
- F: __dxlog_file23,
7047
+ (0, import_invariant20.invariant)(identity.deviceCredentialChain, void 0, {
7048
+ F: __dxlog_file25,
6804
7049
  L: 157,
6805
7050
  S: this,
6806
7051
  A: [
@@ -6827,9 +7072,9 @@ var ServiceContext = class extends import_context15.Resource {
6827
7072
  kv: this.level
6828
7073
  });
6829
7074
  this._meshReplicator = new import_echo_pipeline5.MeshEchoReplicator();
6830
- this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
7075
+ this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
6831
7076
  this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
6832
- this._handlerFactories.set(import_services17.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
7077
+ this._handlerFactories.set(import_services19.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
6833
7078
  if (!this._runtimeParams?.disableP2pReplication) {
6834
7079
  this._meshReplicator = new import_echo_pipeline5.MeshEchoReplicator();
6835
7080
  }
@@ -6841,17 +7086,17 @@ var ServiceContext = class extends import_context15.Resource {
6841
7086
  }
6842
7087
  async _open(ctx) {
6843
7088
  await this._checkStorageVersion();
6844
- (0, import_log20.log)("opening...", void 0, {
6845
- F: __dxlog_file23,
6846
- L: 217,
7089
+ (0, import_log22.log)("opening...", void 0, {
7090
+ F: __dxlog_file25,
7091
+ L: 218,
6847
7092
  S: this,
6848
7093
  C: (f, a) => f(...a)
6849
7094
  });
6850
- import_log20.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
7095
+ import_log22.log.trace("dxos.sdk.service-context.open", import_protocols14.trace.begin({
6851
7096
  id: this._instanceId
6852
7097
  }), {
6853
- F: __dxlog_file23,
6854
- L: 218,
7098
+ F: __dxlog_file25,
7099
+ L: 219,
6855
7100
  S: this,
6856
7101
  C: (f, a) => f(...a)
6857
7102
  });
@@ -6875,33 +7120,33 @@ var ServiceContext = class extends import_context15.Resource {
6875
7120
  await this._initialize(ctx);
6876
7121
  }
6877
7122
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
6878
- (0, import_log20.log)("loaded persistent invitations", {
7123
+ (0, import_log22.log)("loaded persistent invitations", {
6879
7124
  count: loadedInvitations.invitations?.length
6880
7125
  }, {
6881
- F: __dxlog_file23,
6882
- L: 245,
7126
+ F: __dxlog_file25,
7127
+ L: 246,
6883
7128
  S: this,
6884
7129
  C: (f, a) => f(...a)
6885
7130
  });
6886
- import_log20.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
7131
+ import_log22.log.trace("dxos.sdk.service-context.open", import_protocols14.trace.end({
6887
7132
  id: this._instanceId
6888
7133
  }), {
6889
- F: __dxlog_file23,
6890
- L: 247,
7134
+ F: __dxlog_file25,
7135
+ L: 248,
6891
7136
  S: this,
6892
7137
  C: (f, a) => f(...a)
6893
7138
  });
6894
- (0, import_log20.log)("opened", void 0, {
6895
- F: __dxlog_file23,
6896
- L: 248,
7139
+ (0, import_log22.log)("opened", void 0, {
7140
+ F: __dxlog_file25,
7141
+ L: 249,
6897
7142
  S: this,
6898
7143
  C: (f, a) => f(...a)
6899
7144
  });
6900
7145
  }
6901
7146
  async _close(ctx) {
6902
- (0, import_log20.log)("closing...", void 0, {
6903
- F: __dxlog_file23,
6904
- L: 252,
7147
+ (0, import_log22.log)("closing...", void 0, {
7148
+ F: __dxlog_file25,
7149
+ L: 253,
6905
7150
  S: this,
6906
7151
  C: (f, a) => f(...a)
6907
7152
  });
@@ -6917,9 +7162,9 @@ var ServiceContext = class extends import_context15.Resource {
6917
7162
  await this.networkManager.close();
6918
7163
  await this.signalManager.close();
6919
7164
  await this._edgeConnection?.close();
6920
- (0, import_log20.log)("closed", void 0, {
6921
- F: __dxlog_file23,
6922
- L: 267,
7165
+ (0, import_log22.log)("closed", void 0, {
7166
+ F: __dxlog_file25,
7167
+ L: 268,
6923
7168
  S: this,
6924
7169
  C: (f, a) => f(...a)
6925
7170
  });
@@ -6927,16 +7172,16 @@ var ServiceContext = class extends import_context15.Resource {
6927
7172
  async createIdentity(params = {}) {
6928
7173
  const identity = await this.identityManager.createIdentity(params);
6929
7174
  await this._initialize(new import_context15.Context(void 0, {
6930
- F: __dxlog_file23,
6931
- L: 272
7175
+ F: __dxlog_file25,
7176
+ L: 273
6932
7177
  }));
6933
7178
  return identity;
6934
7179
  }
6935
7180
  getInvitationHandler(invitation) {
6936
7181
  const factory = this._handlerFactories.get(invitation.kind);
6937
- (0, import_invariant19.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
6938
- F: __dxlog_file23,
6939
- L: 278,
7182
+ (0, import_invariant20.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
7183
+ F: __dxlog_file25,
7184
+ L: 279,
6940
7185
  S: this,
6941
7186
  A: [
6942
7187
  "factory",
@@ -6956,22 +7201,22 @@ var ServiceContext = class extends import_context15.Resource {
6956
7201
  async _acceptIdentity(params) {
6957
7202
  const identity = await this.identityManager.acceptIdentity(params);
6958
7203
  await this._initialize(new import_context15.Context(void 0, {
6959
- F: __dxlog_file23,
6960
- L: 294
7204
+ F: __dxlog_file25,
7205
+ L: 295
6961
7206
  }));
6962
7207
  return identity;
6963
7208
  }
6964
7209
  async _checkStorageVersion() {
6965
7210
  await this.metadataStore.load();
6966
- if (this.metadataStore.version !== import_protocols13.STORAGE_VERSION) {
6967
- throw new import_protocols13.InvalidStorageVersionError(import_protocols13.STORAGE_VERSION, this.metadataStore.version);
7211
+ if (this.metadataStore.version !== import_protocols14.STORAGE_VERSION) {
7212
+ throw new import_protocols14.InvalidStorageVersionError(import_protocols14.STORAGE_VERSION, this.metadataStore.version);
6968
7213
  }
6969
7214
  }
6970
7215
  // Called when identity is created.
6971
7216
  async _initialize(ctx) {
6972
- (0, import_log20.log)("initializing spaces...", void 0, {
6973
- F: __dxlog_file23,
6974
- L: 309,
7217
+ (0, import_log22.log)("initializing spaces...", void 0, {
7218
+ F: __dxlog_file25,
7219
+ L: 310,
6975
7220
  S: this,
6976
7221
  C: (f, a) => f(...a)
6977
7222
  });
@@ -7005,10 +7250,10 @@ var ServiceContext = class extends import_context15.Resource {
7005
7250
  edgeFeatures: this._edgeFeatures
7006
7251
  });
7007
7252
  await this.dataSpaceManager.open();
7008
- this._handlerFactories.set(import_services17.Invitation.Kind.SPACE, (invitation) => {
7009
- (0, import_invariant19.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7010
- F: __dxlog_file23,
7011
- L: 339,
7253
+ this._handlerFactories.set(import_services19.Invitation.Kind.SPACE, (invitation) => {
7254
+ (0, import_invariant20.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7255
+ F: __dxlog_file25,
7256
+ L: 340,
7012
7257
  S: this,
7013
7258
  A: [
7014
7259
  "this.dataSpaceManager",
@@ -7028,33 +7273,33 @@ var ServiceContext = class extends import_context15.Resource {
7028
7273
  return;
7029
7274
  }
7030
7275
  if (!this.dataSpaceManager) {
7031
- (0, import_log20.log)("dataSpaceManager not initialized yet, ignoring space admission", {
7276
+ (0, import_log22.log)("dataSpaceManager not initialized yet, ignoring space admission", {
7032
7277
  details: assertion
7033
7278
  }, {
7034
- F: __dxlog_file23,
7035
- L: 355,
7279
+ F: __dxlog_file25,
7280
+ L: 356,
7036
7281
  S: this,
7037
7282
  C: (f, a) => f(...a)
7038
7283
  });
7039
7284
  return;
7040
7285
  }
7041
7286
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
7042
- (0, import_log20.log)("space already exists, ignoring space admission", {
7287
+ (0, import_log22.log)("space already exists, ignoring space admission", {
7043
7288
  details: assertion
7044
7289
  }, {
7045
- F: __dxlog_file23,
7046
- L: 359,
7290
+ F: __dxlog_file25,
7291
+ L: 360,
7047
7292
  S: this,
7048
7293
  C: (f, a) => f(...a)
7049
7294
  });
7050
7295
  return;
7051
7296
  }
7052
7297
  try {
7053
- (0, import_log20.log)("accepting space recorded in halo", {
7298
+ (0, import_log22.log)("accepting space recorded in halo", {
7054
7299
  details: assertion
7055
7300
  }, {
7056
- F: __dxlog_file23,
7057
- L: 364,
7301
+ F: __dxlog_file25,
7302
+ L: 365,
7058
7303
  S: this,
7059
7304
  C: (f, a) => f(...a)
7060
7305
  });
@@ -7063,9 +7308,9 @@ var ServiceContext = class extends import_context15.Resource {
7063
7308
  genesisFeedKey: assertion.genesisFeedKey
7064
7309
  });
7065
7310
  } catch (err) {
7066
- import_log20.log.catch(err, void 0, {
7067
- F: __dxlog_file23,
7068
- L: 370,
7311
+ import_log22.log.catch(err, void 0, {
7312
+ F: __dxlog_file25,
7313
+ L: 371,
7069
7314
  S: this,
7070
7315
  C: (f, a) => f(...a)
7071
7316
  });
@@ -7119,16 +7364,16 @@ var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
7119
7364
  var createStorageObjects = (config) => {
7120
7365
  const { persistent = false, keyStore, dataStore } = config ?? {};
7121
7366
  if (persistent && dataStore === StorageDriver.RAM) {
7122
- throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
7367
+ throw new import_protocols15.InvalidConfigError("RAM storage cannot be used in persistent mode.");
7123
7368
  }
7124
7369
  if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
7125
- throw new import_protocols14.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
7370
+ throw new import_protocols15.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
7126
7371
  }
7127
7372
  if (persistent && keyStore === StorageDriver.RAM) {
7128
- throw new import_protocols14.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
7373
+ throw new import_protocols15.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
7129
7374
  }
7130
7375
  if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
7131
- throw new import_protocols14.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
7376
+ throw new import_protocols15.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
7132
7377
  }
7133
7378
  return {
7134
7379
  storage: (0, import_random_access_storage.createStorage)({
@@ -7159,12 +7404,12 @@ var toStorageType = (type) => {
7159
7404
  };
7160
7405
  var createLevel = async (config) => {
7161
7406
  const persistent = isPersistent(config);
7162
- const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys15.PublicKey.random().toHex()}`;
7407
+ const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys16.PublicKey.random().toHex()}`;
7163
7408
  const level = (0, import_kv_store.createLevel)(storagePath);
7164
7409
  await level.open();
7165
7410
  return level;
7166
7411
  };
7167
- var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
7412
+ var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
7168
7413
  var encodeProfileArchive = (profile) => import_automerge_repo.cbor.encode(profile);
7169
7414
  var decodeProfileArchive = (data) => import_automerge_repo.cbor.decode(data);
7170
7415
  var exportProfileData = async ({ storage, level }) => {
@@ -7177,10 +7422,10 @@ var exportProfileData = async ({ storage, level }) => {
7177
7422
  {
7178
7423
  const directory = await storage.createDirectory();
7179
7424
  const files = await directory.list();
7180
- import_log21.log.info("begin exporting files", {
7425
+ import_log23.log.info("begin exporting files", {
7181
7426
  count: files.length
7182
7427
  }, {
7183
- F: __dxlog_file24,
7428
+ F: __dxlog_file26,
7184
7429
  L: 30,
7185
7430
  S: void 0,
7186
7431
  C: (f, a) => f(...a)
@@ -7190,23 +7435,23 @@ var exportProfileData = async ({ storage, level }) => {
7190
7435
  const { size } = await file.stat();
7191
7436
  const data = await file.read(0, size);
7192
7437
  archive.storage.push({
7193
- type: import_protocols15.ProfileArchiveEntryType.FILE,
7438
+ type: import_protocols16.ProfileArchiveEntryType.FILE,
7194
7439
  key: filename,
7195
7440
  value: data
7196
7441
  });
7197
7442
  }
7198
- import_log21.log.info("done exporting files", {
7443
+ import_log23.log.info("done exporting files", {
7199
7444
  count: files.length
7200
7445
  }, {
7201
- F: __dxlog_file24,
7446
+ F: __dxlog_file26,
7202
7447
  L: 41,
7203
7448
  S: void 0,
7204
7449
  C: (f, a) => f(...a)
7205
7450
  });
7206
7451
  }
7207
7452
  {
7208
- import_log21.log.info("begin exporting kv pairs", void 0, {
7209
- F: __dxlog_file24,
7453
+ import_log23.log.info("begin exporting kv pairs", void 0, {
7454
+ F: __dxlog_file26,
7210
7455
  L: 45,
7211
7456
  S: void 0,
7212
7457
  C: (f, a) => f(...a)
@@ -7218,16 +7463,16 @@ var exportProfileData = async ({ storage, level }) => {
7218
7463
  let count = 0;
7219
7464
  for await (const [key, value] of iter) {
7220
7465
  archive.storage.push({
7221
- type: import_protocols15.ProfileArchiveEntryType.KEY_VALUE,
7466
+ type: import_protocols16.ProfileArchiveEntryType.KEY_VALUE,
7222
7467
  key,
7223
7468
  value
7224
7469
  });
7225
7470
  count++;
7226
7471
  }
7227
- import_log21.log.info("done exporting kv pairs", {
7472
+ import_log23.log.info("done exporting kv pairs", {
7228
7473
  count
7229
7474
  }, {
7230
- F: __dxlog_file24,
7475
+ F: __dxlog_file26,
7231
7476
  L: 56,
7232
7477
  S: void 0,
7233
7478
  C: (f, a) => f(...a)
@@ -7240,10 +7485,10 @@ var importProfileData = async ({ storage, level }, archive) => {
7240
7485
  let count = 0;
7241
7486
  for (const entry2 of archive.storage) {
7242
7487
  switch (entry2.type) {
7243
- case import_protocols15.ProfileArchiveEntryType.FILE: {
7488
+ case import_protocols16.ProfileArchiveEntryType.FILE: {
7244
7489
  const directory = await storage.createDirectory();
7245
- (0, import_invariant20.invariant)(typeof entry2.key === "string", "Invalid key type", {
7246
- F: __dxlog_file24,
7490
+ (0, import_invariant21.invariant)(typeof entry2.key === "string", "Invalid key type", {
7491
+ F: __dxlog_file26,
7247
7492
  L: 79,
7248
7493
  S: void 0,
7249
7494
  A: [
@@ -7252,8 +7497,8 @@ var importProfileData = async ({ storage, level }, archive) => {
7252
7497
  ]
7253
7498
  });
7254
7499
  const file = await directory.getOrCreateFile(entry2.key);
7255
- (0, import_invariant20.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
7256
- F: __dxlog_file24,
7500
+ (0, import_invariant21.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
7501
+ F: __dxlog_file26,
7257
7502
  L: 81,
7258
7503
  S: void 0,
7259
7504
  A: [
@@ -7265,9 +7510,9 @@ var importProfileData = async ({ storage, level }, archive) => {
7265
7510
  await file.close();
7266
7511
  break;
7267
7512
  }
7268
- case import_protocols15.ProfileArchiveEntryType.KEY_VALUE: {
7269
- (0, import_invariant20.invariant)(entry2.key instanceof Uint8Array, "Invalid key type", {
7270
- F: __dxlog_file24,
7513
+ case import_protocols16.ProfileArchiveEntryType.KEY_VALUE: {
7514
+ (0, import_invariant21.invariant)(entry2.key instanceof Uint8Array, "Invalid key type", {
7515
+ F: __dxlog_file26,
7271
7516
  L: 87,
7272
7517
  S: void 0,
7273
7518
  A: [
@@ -7275,8 +7520,8 @@ var importProfileData = async ({ storage, level }, archive) => {
7275
7520
  "'Invalid key type'"
7276
7521
  ]
7277
7522
  });
7278
- (0, import_invariant20.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
7279
- F: __dxlog_file24,
7523
+ (0, import_invariant21.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
7524
+ F: __dxlog_file26,
7280
7525
  L: 88,
7281
7526
  S: void 0,
7282
7527
  A: [
@@ -7296,27 +7541,27 @@ var importProfileData = async ({ storage, level }, archive) => {
7296
7541
  if (++count % 1e3 === 0) {
7297
7542
  await batch.write();
7298
7543
  batch = level.batch();
7299
- import_log21.log.info("importing", {
7544
+ import_log23.log.info("importing", {
7300
7545
  count,
7301
7546
  total: archive.storage.length,
7302
7547
  progress: `${(count / archive.storage.length * 100).toFixed()}%`
7303
7548
  }, {
7304
- F: __dxlog_file24,
7549
+ F: __dxlog_file26,
7305
7550
  L: 101,
7306
7551
  S: void 0,
7307
7552
  C: (f, a) => f(...a)
7308
7553
  });
7309
7554
  }
7310
7555
  }
7311
- import_log21.log.info("committing changes..", void 0, {
7312
- F: __dxlog_file24,
7556
+ import_log23.log.info("committing changes..", void 0, {
7557
+ F: __dxlog_file26,
7313
7558
  L: 109,
7314
7559
  S: void 0,
7315
7560
  C: (f, a) => f(...a)
7316
7561
  });
7317
7562
  await batch.write();
7318
7563
  };
7319
- var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
7564
+ var __dxlog_file27 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
7320
7565
  var DevicesServiceImpl = class {
7321
7566
  constructor(_identityManager) {
7322
7567
  this._identityManager = _identityManager;
@@ -7333,8 +7578,8 @@ var DevicesServiceImpl = class {
7333
7578
  devices: []
7334
7579
  });
7335
7580
  } else {
7336
- (0, import_invariant22.invariant)(this._identityManager.identity?.presence, "presence not present", {
7337
- F: __dxlog_file25,
7581
+ (0, import_invariant23.invariant)(this._identityManager.identity?.presence, "presence not present", {
7582
+ F: __dxlog_file27,
7338
7583
  L: 32,
7339
7584
  S: this,
7340
7585
  A: [
@@ -7349,9 +7594,9 @@ var DevicesServiceImpl = class {
7349
7594
  const peerState = peers.find((peer) => peer.identityKey.equals(key));
7350
7595
  return {
7351
7596
  deviceKey: key,
7352
- kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services19.DeviceKind.CURRENT : import_services19.DeviceKind.TRUSTED,
7597
+ kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services21.DeviceKind.CURRENT : import_services21.DeviceKind.TRUSTED,
7353
7598
  profile,
7354
- presence: isMe ? import_services19.Device.PresenceState.ONLINE : peerState ? import_services19.Device.PresenceState.ONLINE : import_services19.Device.PresenceState.OFFLINE
7599
+ presence: isMe ? import_services21.Device.PresenceState.ONLINE : peerState ? import_services21.Device.PresenceState.ONLINE : import_services21.Device.PresenceState.OFFLINE
7355
7600
  };
7356
7601
  })
7357
7602
  });
@@ -7375,7 +7620,7 @@ var DevicesServiceImpl = class {
7375
7620
  presenceSubscribed = true;
7376
7621
  }
7377
7622
  };
7378
- const subscriptions = new import_async21.EventSubscriptions();
7623
+ const subscriptions = new import_async23.EventSubscriptions();
7379
7624
  if (this._identityManager.identity) {
7380
7625
  subscribeIdentity();
7381
7626
  subscribePresence();
@@ -7431,7 +7676,7 @@ var ContactsServiceImpl = class {
7431
7676
  });
7432
7677
  }
7433
7678
  return acc;
7434
- }, new import_util15.ComplexMap(import_keys17.PublicKey.hash));
7679
+ }, new import_util15.ComplexMap(import_keys18.PublicKey.hash));
7435
7680
  return {
7436
7681
  contacts: [
7437
7682
  ...contacts.values()
@@ -7439,16 +7684,16 @@ var ContactsServiceImpl = class {
7439
7684
  };
7440
7685
  }
7441
7686
  queryContacts() {
7442
- const subscribedSpaceKeySet = new import_util15.ComplexSet(import_keys17.PublicKey.hash);
7687
+ const subscribedSpaceKeySet = new import_util15.ComplexSet(import_keys18.PublicKey.hash);
7443
7688
  return new import_codec_protobuf13.Stream(({ next, ctx }) => {
7444
- const pushUpdateTask = new import_async22.UpdateScheduler(ctx, async () => {
7689
+ const pushUpdateTask = new import_async24.UpdateScheduler(ctx, async () => {
7445
7690
  const contacts = await this.getContacts();
7446
7691
  next(contacts);
7447
7692
  }, {
7448
7693
  maxFrequency: 2
7449
7694
  });
7450
- (0, import_async22.scheduleTask)(ctx, async () => {
7451
- const subscriptions = new import_async22.EventSubscriptions();
7695
+ (0, import_async24.scheduleTask)(ctx, async () => {
7696
+ const subscriptions = new import_async24.EventSubscriptions();
7452
7697
  ctx.onDispose(() => subscriptions.clear());
7453
7698
  const subscribeToSpaceAndUpdate = () => {
7454
7699
  const oldSetSize = subscribedSpaceKeySet.size;
@@ -7471,19 +7716,19 @@ var ContactsServiceImpl = class {
7471
7716
  };
7472
7717
  var LoggingServiceImpl = class {
7473
7718
  constructor() {
7474
- this._logs = new import_async23.Event();
7719
+ this._logs = new import_async25.Event();
7475
7720
  this._started = Date.now();
7476
- this._sessionId = import_keys18.PublicKey.random().toHex();
7721
+ this._sessionId = import_keys19.PublicKey.random().toHex();
7477
7722
  this._logProcessor = (_config, entry2) => {
7478
7723
  this._logs.emit(entry2);
7479
7724
  };
7480
7725
  }
7481
7726
  async open() {
7482
- import_log23.log.runtimeConfig.processors.push(this._logProcessor);
7727
+ import_log25.log.runtimeConfig.processors.push(this._logProcessor);
7483
7728
  }
7484
7729
  async close() {
7485
- const index = import_log23.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
7486
- import_log23.log.runtimeConfig.processors.splice(index, 1);
7730
+ const index = import_log25.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
7731
+ import_log25.log.runtimeConfig.processors.splice(index, 1);
7487
7732
  }
7488
7733
  async controlMetrics({ reset, record }) {
7489
7734
  if (reset) {
@@ -7544,7 +7789,7 @@ var LoggingServiceImpl = class {
7544
7789
  }
7545
7790
  const record = {
7546
7791
  ...entry2,
7547
- context: (0, import_util16.jsonify)((0, import_log23.getContextFromEntry)(entry2)),
7792
+ context: (0, import_util16.jsonify)((0, import_log25.getContextFromEntry)(entry2)),
7548
7793
  timestamp: /* @__PURE__ */ new Date(),
7549
7794
  meta: {
7550
7795
  // TODO(dmaretskyi): Fix proto.
@@ -7570,16 +7815,16 @@ var LoggingServiceImpl = class {
7570
7815
  };
7571
7816
  var matchFilter = (filter, level, path2, options) => {
7572
7817
  switch (options) {
7573
- case import_services20.QueryLogsRequest.MatchingOptions.INCLUSIVE:
7818
+ case import_services22.QueryLogsRequest.MatchingOptions.INCLUSIVE:
7574
7819
  return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
7575
- case import_services20.QueryLogsRequest.MatchingOptions.EXPLICIT:
7820
+ case import_services22.QueryLogsRequest.MatchingOptions.EXPLICIT:
7576
7821
  return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
7577
7822
  }
7578
7823
  };
7579
7824
  var shouldLog = (entry2, request) => {
7580
- const options = request.options ?? import_services20.QueryLogsRequest.MatchingOptions.INCLUSIVE;
7825
+ const options = request.options ?? import_services22.QueryLogsRequest.MatchingOptions.INCLUSIVE;
7581
7826
  if (request.filters === void 0) {
7582
- return options === import_services20.QueryLogsRequest.MatchingOptions.INCLUSIVE;
7827
+ return options === import_services22.QueryLogsRequest.MatchingOptions.INCLUSIVE;
7583
7828
  } else {
7584
7829
  return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
7585
7830
  }
@@ -7635,8 +7880,8 @@ var SystemServiceImpl = class {
7635
7880
  return {
7636
7881
  timestamp: /* @__PURE__ */ new Date(),
7637
7882
  diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util17.jsonKeyReplacer)({
7638
- truncate: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
7639
- humanize: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
7883
+ truncate: keys === import_services23.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
7884
+ humanize: keys === import_services23.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
7640
7885
  })))
7641
7886
  };
7642
7887
  }
@@ -7673,7 +7918,7 @@ function _ts_decorate10(decorators, target, key, desc) {
7673
7918
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7674
7919
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7675
7920
  }
7676
- var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
7921
+ var __dxlog_file28 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
7677
7922
  var ClientServicesHost = class {
7678
7923
  constructor({
7679
7924
  config,
@@ -7687,7 +7932,7 @@ var ClientServicesHost = class {
7687
7932
  runtimeParams
7688
7933
  } = {}) {
7689
7934
  this._tracingService = import_tracing11.TRACE_PROCESSOR.createTraceSender();
7690
- this._statusUpdate = new import_async20.Event();
7935
+ this._statusUpdate = new import_async22.Event();
7691
7936
  this._edgeConnection = void 0;
7692
7937
  this._edgeHttpClient = void 0;
7693
7938
  this._opening = false;
@@ -7712,7 +7957,7 @@ var ClientServicesHost = class {
7712
7957
  onAcquire: () => {
7713
7958
  if (!this._opening) {
7714
7959
  void this.open(new import_context16.Context(void 0, {
7715
- F: __dxlog_file26,
7960
+ F: __dxlog_file28,
7716
7961
  L: 133
7717
7962
  }));
7718
7963
  }
@@ -7723,14 +7968,14 @@ var ClientServicesHost = class {
7723
7968
  this._systemService = new SystemServiceImpl({
7724
7969
  config: () => this._config,
7725
7970
  statusUpdate: this._statusUpdate,
7726
- getCurrentStatus: () => this.isOpen ? import_services18.SystemStatus.ACTIVE : import_services18.SystemStatus.INACTIVE,
7971
+ getCurrentStatus: () => this.isOpen ? import_services20.SystemStatus.ACTIVE : import_services20.SystemStatus.INACTIVE,
7727
7972
  getDiagnostics: () => {
7728
7973
  return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
7729
7974
  },
7730
7975
  onUpdateStatus: async (status) => {
7731
- if (!this.isOpen && status === import_services18.SystemStatus.ACTIVE) {
7976
+ if (!this.isOpen && status === import_services20.SystemStatus.ACTIVE) {
7732
7977
  await this._resourceLock?.acquire();
7733
- } else if (this.isOpen && status === import_services18.SystemStatus.INACTIVE) {
7978
+ } else if (this.isOpen && status === import_services20.SystemStatus.INACTIVE) {
7734
7979
  await this._resourceLock?.release();
7735
7980
  }
7736
7981
  },
@@ -7769,8 +8014,8 @@ var ClientServicesHost = class {
7769
8014
  * Can only be called once.
7770
8015
  */
7771
8016
  initialize({ config, ...options }) {
7772
- (0, import_invariant21.invariant)(!this._open, "service host is open", {
7773
- F: __dxlog_file26,
8017
+ (0, import_invariant22.invariant)(!this._open, "service host is open", {
8018
+ F: __dxlog_file28,
7774
8019
  L: 199,
7775
8020
  S: this,
7776
8021
  A: [
@@ -7778,15 +8023,15 @@ var ClientServicesHost = class {
7778
8023
  "'service host is open'"
7779
8024
  ]
7780
8025
  });
7781
- (0, import_log22.log)("initializing...", void 0, {
7782
- F: __dxlog_file26,
8026
+ (0, import_log24.log)("initializing...", void 0, {
8027
+ F: __dxlog_file28,
7783
8028
  L: 200,
7784
8029
  S: this,
7785
8030
  C: (f, a) => f(...a)
7786
8031
  });
7787
8032
  if (config) {
7788
- (0, import_invariant21.invariant)(!this._config, "config already set", {
7789
- F: __dxlog_file26,
8033
+ (0, import_invariant22.invariant)(!this._config, "config already set", {
8034
+ F: __dxlog_file28,
7790
8035
  L: 203,
7791
8036
  S: this,
7792
8037
  A: [
@@ -7800,8 +8045,8 @@ var ClientServicesHost = class {
7800
8045
  }
7801
8046
  }
7802
8047
  if (!options.signalManager) {
7803
- import_log22.log.warn("running signaling without telemetry metadata.", void 0, {
7804
- F: __dxlog_file26,
8048
+ import_log24.log.warn("running signaling without telemetry metadata.", void 0, {
8049
+ F: __dxlog_file28,
7805
8050
  L: 211,
7806
8051
  S: this,
7807
8052
  C: (f, a) => f(...a)
@@ -7820,8 +8065,8 @@ var ClientServicesHost = class {
7820
8065
  edgeConnection: this._edgeConnection
7821
8066
  }) : new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
7822
8067
  this._signalManager = signalManager;
7823
- (0, import_invariant21.invariant)(!this._networkManager, "network manager already set", {
7824
- F: __dxlog_file26,
8068
+ (0, import_invariant22.invariant)(!this._networkManager, "network manager already set", {
8069
+ F: __dxlog_file28,
7825
8070
  L: 233,
7826
8071
  S: this,
7827
8072
  A: [
@@ -7838,8 +8083,8 @@ var ClientServicesHost = class {
7838
8083
  peerKey: this._edgeConnection.peerKey
7839
8084
  } : void 0
7840
8085
  });
7841
- (0, import_log22.log)("initialized", void 0, {
7842
- F: __dxlog_file26,
8086
+ (0, import_log24.log)("initialized", void 0, {
8087
+ F: __dxlog_file28,
7843
8088
  L: 246,
7844
8089
  S: this,
7845
8090
  C: (f, a) => f(...a)
@@ -7849,17 +8094,17 @@ var ClientServicesHost = class {
7849
8094
  if (this._open) {
7850
8095
  return;
7851
8096
  }
7852
- const traceId = import_keys16.PublicKey.random().toHex();
7853
- import_log22.log.trace("dxos.client-services.host.open", import_protocols16.trace.begin({
8097
+ const traceId = import_keys17.PublicKey.random().toHex();
8098
+ import_log24.log.trace("dxos.client-services.host.open", import_protocols17.trace.begin({
7854
8099
  id: traceId
7855
8100
  }), {
7856
- F: __dxlog_file26,
8101
+ F: __dxlog_file28,
7857
8102
  L: 257,
7858
8103
  S: this,
7859
8104
  C: (f, a) => f(...a)
7860
8105
  });
7861
- (0, import_invariant21.invariant)(this._config, "config not set", {
7862
- F: __dxlog_file26,
8106
+ (0, import_invariant22.invariant)(this._config, "config not set", {
8107
+ F: __dxlog_file28,
7863
8108
  L: 259,
7864
8109
  S: this,
7865
8110
  A: [
@@ -7867,8 +8112,8 @@ var ClientServicesHost = class {
7867
8112
  "'config not set'"
7868
8113
  ]
7869
8114
  });
7870
- (0, import_invariant21.invariant)(this._storage, "storage not set", {
7871
- F: __dxlog_file26,
8115
+ (0, import_invariant22.invariant)(this._storage, "storage not set", {
8116
+ F: __dxlog_file28,
7872
8117
  L: 260,
7873
8118
  S: this,
7874
8119
  A: [
@@ -7876,8 +8121,8 @@ var ClientServicesHost = class {
7876
8121
  "'storage not set'"
7877
8122
  ]
7878
8123
  });
7879
- (0, import_invariant21.invariant)(this._signalManager, "signal manager not set", {
7880
- F: __dxlog_file26,
8124
+ (0, import_invariant22.invariant)(this._signalManager, "signal manager not set", {
8125
+ F: __dxlog_file28,
7881
8126
  L: 261,
7882
8127
  S: this,
7883
8128
  A: [
@@ -7885,8 +8130,8 @@ var ClientServicesHost = class {
7885
8130
  "'signal manager not set'"
7886
8131
  ]
7887
8132
  });
7888
- (0, import_invariant21.invariant)(this._networkManager, "network manager not set", {
7889
- F: __dxlog_file26,
8133
+ (0, import_invariant22.invariant)(this._networkManager, "network manager not set", {
8134
+ F: __dxlog_file28,
7890
8135
  L: 262,
7891
8136
  S: this,
7892
8137
  A: [
@@ -7895,10 +8140,10 @@ var ClientServicesHost = class {
7895
8140
  ]
7896
8141
  });
7897
8142
  this._opening = true;
7898
- (0, import_log22.log)("opening...", {
8143
+ (0, import_log24.log)("opening...", {
7899
8144
  lockKey: this._resourceLock?.lockKey
7900
8145
  }, {
7901
- F: __dxlog_file26,
8146
+ F: __dxlog_file28,
7902
8147
  L: 265,
7903
8148
  S: this,
7904
8149
  C: (f, a) => f(...a)
@@ -7951,18 +8196,18 @@ var ClientServicesHost = class {
7951
8196
  this._open = true;
7952
8197
  this._statusUpdate.emit();
7953
8198
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
7954
- (0, import_log22.log)("opened", {
8199
+ (0, import_log24.log)("opened", {
7955
8200
  deviceKey
7956
8201
  }, {
7957
- F: __dxlog_file26,
8202
+ F: __dxlog_file28,
7958
8203
  L: 354,
7959
8204
  S: this,
7960
8205
  C: (f, a) => f(...a)
7961
8206
  });
7962
- import_log22.log.trace("dxos.client-services.host.open", import_protocols16.trace.end({
8207
+ import_log24.log.trace("dxos.client-services.host.open", import_protocols17.trace.end({
7963
8208
  id: traceId
7964
8209
  }), {
7965
- F: __dxlog_file26,
8210
+ F: __dxlog_file28,
7966
8211
  L: 355,
7967
8212
  S: this,
7968
8213
  C: (f, a) => f(...a)
@@ -7973,10 +8218,10 @@ var ClientServicesHost = class {
7973
8218
  return;
7974
8219
  }
7975
8220
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
7976
- (0, import_log22.log)("closing...", {
8221
+ (0, import_log24.log)("closing...", {
7977
8222
  deviceKey
7978
8223
  }, {
7979
- F: __dxlog_file26,
8224
+ F: __dxlog_file28,
7980
8225
  L: 366,
7981
8226
  S: this,
7982
8227
  C: (f, a) => f(...a)
@@ -7991,43 +8236,43 @@ var ClientServicesHost = class {
7991
8236
  await this._level?.close();
7992
8237
  this._open = false;
7993
8238
  this._statusUpdate.emit();
7994
- (0, import_log22.log)("closed", {
8239
+ (0, import_log24.log)("closed", {
7995
8240
  deviceKey
7996
8241
  }, {
7997
- F: __dxlog_file26,
8242
+ F: __dxlog_file28,
7998
8243
  L: 375,
7999
8244
  S: this,
8000
8245
  C: (f, a) => f(...a)
8001
8246
  });
8002
8247
  }
8003
8248
  async reset() {
8004
- const traceId = import_keys16.PublicKey.random().toHex();
8005
- import_log22.log.trace("dxos.sdk.client-services-host.reset", import_protocols16.trace.begin({
8249
+ const traceId = import_keys17.PublicKey.random().toHex();
8250
+ import_log24.log.trace("dxos.sdk.client-services-host.reset", import_protocols17.trace.begin({
8006
8251
  id: traceId
8007
8252
  }), {
8008
- F: __dxlog_file26,
8253
+ F: __dxlog_file28,
8009
8254
  L: 380,
8010
8255
  S: this,
8011
8256
  C: (f, a) => f(...a)
8012
8257
  });
8013
- import_log22.log.info("resetting...", void 0, {
8014
- F: __dxlog_file26,
8258
+ import_log24.log.info("resetting...", void 0, {
8259
+ F: __dxlog_file28,
8015
8260
  L: 382,
8016
8261
  S: this,
8017
8262
  C: (f, a) => f(...a)
8018
8263
  });
8019
8264
  await this._serviceContext?.close();
8020
8265
  await this._storage.reset();
8021
- import_log22.log.info("reset", void 0, {
8022
- F: __dxlog_file26,
8266
+ import_log24.log.info("reset", void 0, {
8267
+ F: __dxlog_file28,
8023
8268
  L: 385,
8024
8269
  S: this,
8025
8270
  C: (f, a) => f(...a)
8026
8271
  });
8027
- import_log22.log.trace("dxos.sdk.client-services-host.reset", import_protocols16.trace.end({
8272
+ import_log24.log.trace("dxos.sdk.client-services-host.reset", import_protocols17.trace.end({
8028
8273
  id: traceId
8029
8274
  }), {
8030
- F: __dxlog_file26,
8275
+ F: __dxlog_file28,
8031
8276
  L: 386,
8032
8277
  S: this,
8033
8278
  C: (f, a) => f(...a)
@@ -8047,11 +8292,11 @@ _ts_decorate10([
8047
8292
  import_tracing11.trace.info()
8048
8293
  ], ClientServicesHost.prototype, "_open", void 0);
8049
8294
  _ts_decorate10([
8050
- import_async20.synchronized,
8295
+ import_async22.synchronized,
8051
8296
  import_tracing11.trace.span()
8052
8297
  ], ClientServicesHost.prototype, "open", null);
8053
8298
  _ts_decorate10([
8054
- import_async20.synchronized,
8299
+ import_async22.synchronized,
8055
8300
  import_tracing11.trace.span()
8056
8301
  ], ClientServicesHost.prototype, "close", null);
8057
8302
  ClientServicesHost = _ts_decorate10([
@@ -8101,4 +8346,4 @@ ClientServicesHost = _ts_decorate10([
8101
8346
  subscribeToSpaces,
8102
8347
  subscribeToSwarmInfo
8103
8348
  });
8104
- //# sourceMappingURL=chunk-2KIDYJ7O.cjs.map
8349
+ //# sourceMappingURL=chunk-MA5EWTRH.cjs.map