@dxos/client-services 0.6.2 → 0.6.3-main.0308ae2

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 (33) hide show
  1. package/dist/lib/browser/{chunk-CFKVGKP3.mjs → chunk-5VHFFY7B.mjs} +143 -122
  2. package/dist/lib/browser/chunk-5VHFFY7B.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/packlets/testing/index.mjs +1 -1
  6. package/dist/lib/node/{chunk-7XBIZ7NK.cjs → chunk-CVLKGJK5.cjs} +141 -120
  7. package/dist/lib/node/chunk-CVLKGJK5.cjs.map +7 -0
  8. package/dist/lib/node/index.cjs +45 -45
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/packlets/testing/index.cjs +8 -8
  11. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
  12. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  13. package/dist/types/src/packlets/invitations/invitation-topology.d.ts +2 -2
  14. package/dist/types/src/packlets/invitations/invitation-topology.d.ts.map +1 -1
  15. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  16. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  17. package/dist/types/src/packlets/spaces/data-space.d.ts +8 -2
  18. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  19. package/dist/types/src/version.d.ts +1 -1
  20. package/dist/types/src/version.d.ts.map +1 -1
  21. package/package.json +36 -36
  22. package/src/packlets/identity/identity-service.ts +2 -2
  23. package/src/packlets/invitations/invitation-guest-extenstion.ts +8 -5
  24. package/src/packlets/invitations/invitation-host-extension.ts +5 -5
  25. package/src/packlets/invitations/invitation-topology.ts +4 -4
  26. package/src/packlets/invitations/invitations-handler.ts +13 -12
  27. package/src/packlets/spaces/data-space-manager.test.ts +6 -6
  28. package/src/packlets/spaces/data-space-manager.ts +28 -16
  29. package/src/packlets/spaces/data-space.ts +31 -27
  30. package/src/packlets/spaces/spaces-service.ts +6 -6
  31. package/src/version.ts +1 -5
  32. package/dist/lib/browser/chunk-CFKVGKP3.mjs.map +0 -7
  33. package/dist/lib/node/chunk-7XBIZ7NK.cjs.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_7XBIZ7NK_exports = {};
30
- __export(chunk_7XBIZ7NK_exports, {
29
+ var chunk_CVLKGJK5_exports = {};
30
+ __export(chunk_CVLKGJK5_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  ClientServicesProviderResource: () => ClientServicesProviderResource,
@@ -70,7 +70,7 @@ __export(chunk_7XBIZ7NK_exports, {
70
70
  subscribeToSpaces: () => subscribeToSpaces,
71
71
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
72
72
  });
73
- module.exports = __toCommonJS(chunk_7XBIZ7NK_exports);
73
+ module.exports = __toCommonJS(chunk_CVLKGJK5_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");
@@ -647,7 +647,7 @@ var DevtoolsServiceImpl = class {
647
647
  });
648
648
  }
649
649
  };
650
- var DXOS_VERSION = "0.6.2";
650
+ var DXOS_VERSION = "0.6.3-main.0308ae2";
651
651
  var getPlatform = () => {
652
652
  if (process.browser) {
653
653
  if (typeof window !== "undefined") {
@@ -1787,9 +1787,9 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1787
1787
  const dataSpaceManager = this._dataSpaceManagerProvider();
1788
1788
  const recordedDefaultSpaceTrigger = new import_async8.Trigger();
1789
1789
  const allProcessed = (0, import_util4.safeAwaitAll)(dataSpaceManager.spaces.values(), async (space) => {
1790
- if (space.state === import_services4.SpaceState.CLOSED) {
1790
+ if (space.state === import_services4.SpaceState.SPACE_CLOSED) {
1791
1791
  await space.open();
1792
- const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === import_services4.SpaceState.REQUIRES_MIGRATION);
1792
+ const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === import_services4.SpaceState.SPACE_REQUIRES_MIGRATION);
1793
1793
  await Promise.race([
1794
1794
  space.initializeDataPipeline(),
1795
1795
  requiresMigration
@@ -2020,11 +2020,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
2020
2020
  C: (f, a) => f(...a)
2021
2021
  });
2022
2022
  await (0, import_context6.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
2023
- role: import_invitations3.Options.Role.GUEST
2023
+ role: import_invitations3.InvitationOptions.Role.GUEST
2024
2024
  }));
2025
2025
  (0, import_log7.log)("options sent", void 0, {
2026
2026
  F: __dxlog_file9,
2027
- L: 88,
2027
+ L: 91,
2028
2028
  S: this,
2029
2029
  C: (f, a) => f(...a)
2030
2030
  });
@@ -2033,13 +2033,13 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
2033
2033
  }));
2034
2034
  (0, import_log7.log)("options received", void 0, {
2035
2035
  F: __dxlog_file9,
2036
- L: 90,
2036
+ L: 93,
2037
2037
  S: this,
2038
2038
  C: (f, a) => f(...a)
2039
2039
  });
2040
- if (this._remoteOptions?.role !== import_invitations3.Options.Role.HOST) {
2040
+ if (this._remoteOptions?.role !== import_invitations3.InvitationOptions.Role.HOST) {
2041
2041
  throw new import_protocols6.InvalidInvitationExtensionRoleError(void 0, {
2042
- expected: import_invitations3.Options.Role.HOST,
2042
+ expected: import_invitations3.InvitationOptions.Role.HOST,
2043
2043
  remoteOptions: this._remoteOptions,
2044
2044
  remotePeerId: context.remotePeerId
2045
2045
  });
@@ -2067,7 +2067,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
2067
2067
  this._invitationFlowLock = null;
2068
2068
  (0, import_log7.log)("invitation flow lock released", void 0, {
2069
2069
  F: __dxlog_file9,
2070
- L: 123,
2070
+ L: 126,
2071
2071
  S: this,
2072
2072
  C: (f, a) => f(...a)
2073
2073
  });
@@ -2330,7 +2330,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2330
2330
  const lastState = this._requireActiveInvitation().state;
2331
2331
  this._callbacks.onStateUpdate(import_services8.Invitation.State.CONNECTING);
2332
2332
  await this.rpc.InvitationHostService.options({
2333
- role: import_invitations4.Options.Role.HOST
2333
+ role: import_invitations4.InvitationOptions.Role.HOST
2334
2334
  });
2335
2335
  (0, import_log8.log)("options sent", void 0, {
2336
2336
  F: __dxlog_file10,
@@ -2347,10 +2347,10 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2347
2347
  S: this,
2348
2348
  C: (f, a) => f(...a)
2349
2349
  });
2350
- if (this._remoteOptions?.role !== import_invitations4.Options.Role.GUEST) {
2350
+ if (this._remoteOptions?.role !== import_invitations4.InvitationOptions.Role.GUEST) {
2351
2351
  this._callbacks.onStateUpdate(lastState);
2352
2352
  throw new import_protocols7.InvalidInvitationExtensionRoleError(void 0, {
2353
- expected: import_invitations4.Options.Role.GUEST,
2353
+ expected: import_invitations4.InvitationOptions.Role.GUEST,
2354
2354
  remoteOptions: this._remoteOptions,
2355
2355
  remotePeerId: context.remotePeerId
2356
2356
  });
@@ -2434,7 +2434,7 @@ var InvitationTopology = class {
2434
2434
  ]
2435
2435
  });
2436
2436
  const { ownPeerId, candidates, connected, allPeers } = this._controller.getState();
2437
- if (this._role === import_invitations5.Options.Role.GUEST) {
2437
+ if (this._role === import_invitations5.InvitationOptions.Role.GUEST) {
2438
2438
  return;
2439
2439
  }
2440
2440
  if (connected.length > 0) {
@@ -2473,7 +2473,7 @@ var InvitationTopology = class {
2473
2473
  this._seenPeers.clear();
2474
2474
  }
2475
2475
  toString() {
2476
- return `InvitationTopology(${this._role === import_invitations5.Options.Role.GUEST ? "guest" : "host"})`;
2476
+ return `InvitationTopology(${this._role === import_invitations5.InvitationOptions.Role.GUEST ? "guest" : "host"})`;
2477
2477
  }
2478
2478
  };
2479
2479
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
@@ -2488,7 +2488,7 @@ var InvitationsHandler = class {
2488
2488
  this._defaultTeleportParams = _defaultTeleportParams;
2489
2489
  }
2490
2490
  handleInvitationFlow(ctx, stream, protocol, invitation) {
2491
- metrics.increment("invitation.created");
2491
+ metrics.increment("dxos.invitation.created");
2492
2492
  const guardedState = this._createGuardedState(ctx, invitation, stream);
2493
2493
  const createExtension = () => {
2494
2494
  const extension = new InvitationHostExtension(guardedState.mutex, {
@@ -2504,7 +2504,7 @@ var InvitationsHandler = class {
2504
2504
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
2505
2505
  (0, import_invariant6.invariant)(deviceKey, void 0, {
2506
2506
  F: __dxlog_file12,
2507
- L: 93,
2507
+ L: 94,
2508
2508
  S: this,
2509
2509
  A: [
2510
2510
  "deviceKey",
@@ -2533,7 +2533,7 @@ var InvitationsHandler = class {
2533
2533
  id: traceId
2534
2534
  }), {
2535
2535
  F: __dxlog_file12,
2536
- L: 118,
2536
+ L: 119,
2537
2537
  S: this,
2538
2538
  C: (f, a) => f(...a)
2539
2539
  });
@@ -2541,7 +2541,7 @@ var InvitationsHandler = class {
2541
2541
  ...protocol.toJSON()
2542
2542
  }, {
2543
2543
  F: __dxlog_file12,
2544
- L: 119,
2544
+ L: 120,
2545
2545
  S: this,
2546
2546
  C: (f, a) => f(...a)
2547
2547
  });
@@ -2553,17 +2553,17 @@ var InvitationsHandler = class {
2553
2553
  ...protocol.toJSON()
2554
2554
  }, {
2555
2555
  F: __dxlog_file12,
2556
- L: 121,
2556
+ L: 122,
2557
2557
  S: this,
2558
2558
  C: (f, a) => f(...a)
2559
2559
  });
2560
2560
  guardedState.set(extension, import_services6.Invitation.State.SUCCESS);
2561
- metrics.increment("invitation.success");
2561
+ metrics.increment("dxos.invitation.success");
2562
2562
  import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
2563
2563
  id: traceId
2564
2564
  }), {
2565
2565
  F: __dxlog_file12,
2566
- L: 124,
2566
+ L: 125,
2567
2567
  S: this,
2568
2568
  C: (f, a) => f(...a)
2569
2569
  });
@@ -2574,22 +2574,22 @@ var InvitationsHandler = class {
2574
2574
  } catch (err) {
2575
2575
  if (err instanceof import_async9.TimeoutError) {
2576
2576
  if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
2577
- metrics.increment("invitation.timeout");
2577
+ metrics.increment("dxos.invitation.timeout");
2578
2578
  (0, import_log6.log)("timeout", {
2579
2579
  ...protocol.toJSON()
2580
2580
  }, {
2581
2581
  F: __dxlog_file12,
2582
- L: 134,
2582
+ L: 135,
2583
2583
  S: this,
2584
2584
  C: (f, a) => f(...a)
2585
2585
  });
2586
2586
  }
2587
2587
  } else {
2588
2588
  if (guardedState.error(extension, err)) {
2589
- metrics.increment("invitation.failed");
2589
+ metrics.increment("dxos.invitation.failed");
2590
2590
  import_log6.log.error("failed", err, {
2591
2591
  F: __dxlog_file12,
2592
- L: 139,
2592
+ L: 140,
2593
2593
  S: this,
2594
2594
  C: (f, a) => f(...a)
2595
2595
  });
@@ -2600,7 +2600,7 @@ var InvitationsHandler = class {
2600
2600
  error: err
2601
2601
  }), {
2602
2602
  F: __dxlog_file12,
2603
- L: 142,
2603
+ L: 143,
2604
2604
  S: this,
2605
2605
  C: (f, a) => f(...a)
2606
2606
  });
@@ -2614,7 +2614,7 @@ var InvitationsHandler = class {
2614
2614
  ...err.context
2615
2615
  }, {
2616
2616
  F: __dxlog_file12,
2617
- L: 150,
2617
+ L: 151,
2618
2618
  S: this,
2619
2619
  C: (f, a) => f(...a)
2620
2620
  });
@@ -2622,22 +2622,22 @@ var InvitationsHandler = class {
2622
2622
  }
2623
2623
  if (err instanceof import_async9.TimeoutError) {
2624
2624
  if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
2625
- metrics.increment("invitation.timeout");
2625
+ metrics.increment("dxos.invitation.timeout");
2626
2626
  (0, import_log6.log)("timeout", {
2627
2627
  err
2628
2628
  }, {
2629
2629
  F: __dxlog_file12,
2630
- L: 156,
2630
+ L: 157,
2631
2631
  S: this,
2632
2632
  C: (f, a) => f(...a)
2633
2633
  });
2634
2634
  }
2635
2635
  } else {
2636
2636
  if (guardedState.error(extension, err)) {
2637
- metrics.increment("invitation.failed");
2637
+ metrics.increment("dxos.invitation.failed");
2638
2638
  import_log6.log.error("failed", err, {
2639
2639
  F: __dxlog_file12,
2640
- L: 161,
2640
+ L: 162,
2641
2641
  S: this,
2642
2642
  C: (f, a) => f(...a)
2643
2643
  });
@@ -2651,7 +2651,7 @@ var InvitationsHandler = class {
2651
2651
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
2652
2652
  import_log6.log.warn("invitation has already expired", void 0, {
2653
2653
  F: __dxlog_file12,
2654
- L: 172,
2654
+ L: 173,
2655
2655
  S: this,
2656
2656
  C: (f, a) => f(...a)
2657
2657
  });
@@ -2659,14 +2659,14 @@ var InvitationsHandler = class {
2659
2659
  (0, import_async9.scheduleTask)(ctx, async () => {
2660
2660
  await swarmConnection.close();
2661
2661
  guardedState.set(null, import_services6.Invitation.State.EXPIRED);
2662
- metrics.increment("invitation.expired");
2662
+ metrics.increment("dxos.invitation.expired");
2663
2663
  await ctx.dispose();
2664
2664
  }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
2665
2665
  }
2666
2666
  }
2667
2667
  let swarmConnection;
2668
2668
  (0, import_async9.scheduleTask)(ctx, async () => {
2669
- swarmConnection = await this._joinSwarm(ctx, invitation, import_invitations2.Options.Role.HOST, createExtension);
2669
+ swarmConnection = await this._joinSwarm(ctx, invitation, import_invitations2.InvitationOptions.Role.HOST, createExtension);
2670
2670
  guardedState.set(null, import_services6.Invitation.State.CONNECTING);
2671
2671
  });
2672
2672
  }
@@ -2675,7 +2675,7 @@ var InvitationsHandler = class {
2675
2675
  if (deviceProfile) {
2676
2676
  (0, import_invariant6.invariant)(invitation.kind === import_services6.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2677
2677
  F: __dxlog_file12,
2678
- L: 206,
2678
+ L: 207,
2679
2679
  S: this,
2680
2680
  A: [
2681
2681
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -2693,7 +2693,7 @@ var InvitationsHandler = class {
2693
2693
  triedPeers: triedPeersIds.size
2694
2694
  }, {
2695
2695
  F: __dxlog_file12,
2696
- L: 214,
2696
+ L: 215,
2697
2697
  S: this,
2698
2698
  C: (f, a) => f(...a)
2699
2699
  });
@@ -2720,7 +2720,7 @@ var InvitationsHandler = class {
2720
2720
  currentState: guardedState.current.state
2721
2721
  }, {
2722
2722
  F: __dxlog_file12,
2723
- L: 242,
2723
+ L: 243,
2724
2724
  S: this,
2725
2725
  C: (f, a) => f(...a)
2726
2726
  });
@@ -2738,7 +2738,7 @@ var InvitationsHandler = class {
2738
2738
  id: traceId
2739
2739
  }), {
2740
2740
  F: __dxlog_file12,
2741
- L: 254,
2741
+ L: 255,
2742
2742
  S: this,
2743
2743
  C: (f, a) => f(...a)
2744
2744
  });
@@ -2750,7 +2750,7 @@ var InvitationsHandler = class {
2750
2750
  ...protocol.toJSON()
2751
2751
  }, {
2752
2752
  F: __dxlog_file12,
2753
- L: 265,
2753
+ L: 266,
2754
2754
  S: this,
2755
2755
  C: (f, a) => f(...a)
2756
2756
  });
@@ -2759,7 +2759,7 @@ var InvitationsHandler = class {
2759
2759
  ...protocol.toJSON()
2760
2760
  }, {
2761
2761
  F: __dxlog_file12,
2762
- L: 269,
2762
+ L: 270,
2763
2763
  S: this,
2764
2764
  C: (f, a) => f(...a)
2765
2765
  });
@@ -2772,7 +2772,7 @@ var InvitationsHandler = class {
2772
2772
  response: introductionResponse
2773
2773
  }, {
2774
2774
  F: __dxlog_file12,
2775
- L: 274,
2775
+ L: 275,
2776
2776
  S: this,
2777
2777
  C: (f, a) => f(...a)
2778
2778
  });
@@ -2793,7 +2793,7 @@ var InvitationsHandler = class {
2793
2793
  ...protocol.toJSON()
2794
2794
  }, {
2795
2795
  F: __dxlog_file12,
2796
- L: 300,
2796
+ L: 301,
2797
2797
  S: this,
2798
2798
  C: (f, a) => f(...a)
2799
2799
  });
@@ -2805,7 +2805,7 @@ var InvitationsHandler = class {
2805
2805
  ...protocol.toJSON()
2806
2806
  }, {
2807
2807
  F: __dxlog_file12,
2808
- L: 311,
2808
+ L: 312,
2809
2809
  S: this,
2810
2810
  C: (f, a) => f(...a)
2811
2811
  });
@@ -2818,7 +2818,7 @@ var InvitationsHandler = class {
2818
2818
  id: traceId
2819
2819
  }), {
2820
2820
  F: __dxlog_file12,
2821
- L: 317,
2821
+ L: 318,
2822
2822
  S: this,
2823
2823
  C: (f, a) => f(...a)
2824
2824
  });
@@ -2828,7 +2828,7 @@ var InvitationsHandler = class {
2828
2828
  ...protocol.toJSON()
2829
2829
  }, {
2830
2830
  F: __dxlog_file12,
2831
- L: 320,
2831
+ L: 321,
2832
2832
  S: this,
2833
2833
  C: (f, a) => f(...a)
2834
2834
  });
@@ -2836,7 +2836,7 @@ var InvitationsHandler = class {
2836
2836
  } else {
2837
2837
  (0, import_log6.log)("auth failed", err, {
2838
2838
  F: __dxlog_file12,
2839
- L: 323,
2839
+ L: 324,
2840
2840
  S: this,
2841
2841
  C: (f, a) => f(...a)
2842
2842
  });
@@ -2848,7 +2848,7 @@ var InvitationsHandler = class {
2848
2848
  error: err
2849
2849
  }), {
2850
2850
  F: __dxlog_file12,
2851
- L: 327,
2851
+ L: 328,
2852
2852
  S: this,
2853
2853
  C: (f, a) => f(...a)
2854
2854
  });
@@ -2864,7 +2864,7 @@ var InvitationsHandler = class {
2864
2864
  ...protocol.toJSON()
2865
2865
  }, {
2866
2866
  F: __dxlog_file12,
2867
- L: 336,
2867
+ L: 337,
2868
2868
  S: this,
2869
2869
  C: (f, a) => f(...a)
2870
2870
  });
@@ -2872,7 +2872,7 @@ var InvitationsHandler = class {
2872
2872
  } else {
2873
2873
  (0, import_log6.log)("auth failed", err, {
2874
2874
  F: __dxlog_file12,
2875
- L: 339,
2875
+ L: 340,
2876
2876
  S: this,
2877
2877
  C: (f, a) => f(...a)
2878
2878
  });
@@ -2890,21 +2890,21 @@ var InvitationsHandler = class {
2890
2890
  } else {
2891
2891
  (0, import_invariant6.invariant)(invitation.swarmKey, void 0, {
2892
2892
  F: __dxlog_file12,
2893
- L: 354,
2893
+ L: 355,
2894
2894
  S: this,
2895
2895
  A: [
2896
2896
  "invitation.swarmKey",
2897
2897
  ""
2898
2898
  ]
2899
2899
  });
2900
- await this._joinSwarm(ctx, invitation, import_invitations2.Options.Role.GUEST, createExtension);
2900
+ await this._joinSwarm(ctx, invitation, import_invitations2.InvitationOptions.Role.GUEST, createExtension);
2901
2901
  guardedState.set(null, import_services6.Invitation.State.CONNECTING);
2902
2902
  }
2903
2903
  });
2904
2904
  }
2905
2905
  async _joinSwarm(ctx, invitation, role, extensionFactory) {
2906
2906
  let label;
2907
- if (role === import_invitations2.Options.Role.GUEST) {
2907
+ if (role === import_invitations2.InvitationOptions.Role.GUEST) {
2908
2908
  label = "invitation guest";
2909
2909
  } else if (invitation.kind === import_services6.Invitation.Kind.DEVICE) {
2910
2910
  label = "invitation host for device";
@@ -2990,7 +2990,7 @@ var InvitationsHandler = class {
2990
2990
  oldState: stateToString(invitation.state)
2991
2991
  }, {
2992
2992
  F: __dxlog_file12,
2993
- L: 448,
2993
+ L: 449,
2994
2994
  S: this,
2995
2995
  C: (f, a) => f(...a)
2996
2996
  });
@@ -3001,7 +3001,7 @@ var InvitationsHandler = class {
3001
3001
  oldState: stateToString(invitation.state)
3002
3002
  }, {
3003
3003
  F: __dxlog_file12,
3004
- L: 454,
3004
+ L: 455,
3005
3005
  S: this,
3006
3006
  C: (f, a) => f(...a)
3007
3007
  });
@@ -3020,7 +3020,7 @@ var InvitationsHandler = class {
3020
3020
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
3021
3021
  (0, import_log6.log)("guest waiting for authentication code...", void 0, {
3022
3022
  F: __dxlog_file12,
3023
- L: 479,
3023
+ L: 480,
3024
3024
  S: this,
3025
3025
  C: (f, a) => f(...a)
3026
3026
  });
@@ -3028,7 +3028,7 @@ var InvitationsHandler = class {
3028
3028
  const authCode = await authenticated.wait(options);
3029
3029
  (0, import_log6.log)("sending authentication request", void 0, {
3030
3030
  F: __dxlog_file12,
3031
- L: 483,
3031
+ L: 484,
3032
3032
  S: this,
3033
3033
  C: (f, a) => f(...a)
3034
3034
  });
@@ -3047,7 +3047,7 @@ var InvitationsHandler = class {
3047
3047
  attempt
3048
3048
  }, {
3049
3049
  F: __dxlog_file12,
3050
- L: 494,
3050
+ L: 495,
3051
3051
  S: this,
3052
3052
  C: (f, a) => f(...a)
3053
3053
  });
@@ -3065,7 +3065,7 @@ var InvitationsHandler = class {
3065
3065
  }
3066
3066
  (0, import_log6.log)("sending authentication request", void 0, {
3067
3067
  F: __dxlog_file12,
3068
- L: 513,
3068
+ L: 514,
3069
3069
  S: this,
3070
3070
  C: (f, a) => f(...a)
3071
3071
  });
@@ -4340,7 +4340,7 @@ var DataSpace = class {
4340
4340
  this._cache = void 0;
4341
4341
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
4342
4342
  this._epochProcessingMutex = new import_async13.Mutex();
4343
- this._state = import_services12.SpaceState.CLOSED;
4343
+ this._state = import_services12.SpaceState.SPACE_CLOSED;
4344
4344
  this._databaseRoot = null;
4345
4345
  this.error = void 0;
4346
4346
  this.stateUpdate = new import_async13.Event();
@@ -4409,7 +4409,7 @@ var DataSpace = class {
4409
4409
  };
4410
4410
  }
4411
4411
  async open() {
4412
- if (this._state === import_services12.SpaceState.CLOSED) {
4412
+ if (this._state === import_services12.SpaceState.SPACE_CLOSED) {
4413
4413
  await this._open();
4414
4414
  }
4415
4415
  }
@@ -4424,7 +4424,7 @@ var DataSpace = class {
4424
4424
  F: __dxlog_file17,
4425
4425
  L: 215
4426
4426
  }));
4427
- this._state = import_services12.SpaceState.CONTROL_ONLY;
4427
+ this._state = import_services12.SpaceState.SPACE_CONTROL_ONLY;
4428
4428
  (0, import_log12.log)("new state", {
4429
4429
  state: import_services12.SpaceState[this._state]
4430
4430
  }, {
@@ -4442,7 +4442,7 @@ var DataSpace = class {
4442
4442
  }
4443
4443
  async _close() {
4444
4444
  await this._callbacks.beforeClose?.();
4445
- this._state = import_services12.SpaceState.CLOSED;
4445
+ this._state = import_services12.SpaceState.SPACE_CLOSED;
4446
4446
  (0, import_log12.log)("new state", {
4447
4447
  state: import_services12.SpaceState[this._state]
4448
4448
  }, {
@@ -4495,7 +4495,7 @@ var DataSpace = class {
4495
4495
  S: this,
4496
4496
  C: (f, a) => f(...a)
4497
4497
  });
4498
- this._state = import_services12.SpaceState.ERROR;
4498
+ this._state = import_services12.SpaceState.SPACE_ERROR;
4499
4499
  (0, import_log12.log)("new state", {
4500
4500
  state: import_services12.SpaceState[this._state]
4501
4501
  }, {
@@ -4512,10 +4512,10 @@ var DataSpace = class {
4512
4512
  });
4513
4513
  }
4514
4514
  async initializeDataPipeline() {
4515
- if (this._state !== import_services12.SpaceState.CONTROL_ONLY) {
4515
+ if (this._state !== import_services12.SpaceState.SPACE_CONTROL_ONLY) {
4516
4516
  throw new import_protocols9.SystemError("Invalid operation");
4517
4517
  }
4518
- this._state = import_services12.SpaceState.INITIALIZING;
4518
+ this._state = import_services12.SpaceState.SPACE_INITIALIZING;
4519
4519
  (0, import_log12.log)("new state", {
4520
4520
  state: import_services12.SpaceState[this._state]
4521
4521
  }, {
@@ -4526,13 +4526,13 @@ var DataSpace = class {
4526
4526
  });
4527
4527
  await this._initializeAndReadControlPipeline();
4528
4528
  await (0, import_async13.sleep)(1);
4529
- const ready = this.stateUpdate.waitForCondition(() => this._state === import_services12.SpaceState.READY);
4529
+ const ready = this.stateUpdate.waitForCondition(() => this._state === import_services12.SpaceState.SPACE_READY);
4530
4530
  this._automergeSpaceState.startProcessingRootDocs();
4531
4531
  await ready;
4532
4532
  }
4533
4533
  async _enterReadyState() {
4534
4534
  await this._callbacks.beforeReady?.();
4535
- this._state = import_services12.SpaceState.READY;
4535
+ this._state = import_services12.SpaceState.SPACE_READY;
4536
4536
  (0, import_log12.log)("new state", {
4537
4537
  state: import_services12.SpaceState[this._state]
4538
4538
  }, {
@@ -4643,17 +4643,15 @@ var DataSpace = class {
4643
4643
  };
4644
4644
  });
4645
4645
  }
4646
- const root = await this._echoHost.openSpaceRoot(handle.url);
4646
+ const root = await this._echoHost.openSpaceRoot(this.id, handle.url);
4647
4647
  this._databaseRoot = root;
4648
4648
  if (root.getVersion() !== import_echo_protocol.SpaceDocVersion.CURRENT) {
4649
- if (this._state !== import_services12.SpaceState.REQUIRES_MIGRATION) {
4650
- this._state = import_services12.SpaceState.REQUIRES_MIGRATION;
4651
- this.stateUpdate.emit();
4652
- }
4649
+ this._state = import_services12.SpaceState.SPACE_REQUIRES_MIGRATION;
4650
+ this.stateUpdate.emit();
4651
+ } else if (this._state !== import_services12.SpaceState.SPACE_READY) {
4652
+ await this._enterReadyState();
4653
4653
  } else {
4654
- if (this._state !== import_services12.SpaceState.READY) {
4655
- await this._enterReadyState();
4656
- }
4654
+ this.stateUpdate.emit();
4657
4655
  }
4658
4656
  } catch (_) {
4659
4657
  _usingCtx.e = _;
@@ -4670,7 +4668,7 @@ var DataSpace = class {
4670
4668
  err
4671
4669
  }, {
4672
4670
  F: __dxlog_file17,
4673
- L: 433,
4671
+ L: 431,
4674
4672
  S: this,
4675
4673
  C: (f, a) => f(...a)
4676
4674
  });
@@ -4723,40 +4721,44 @@ var DataSpace = class {
4723
4721
  credential
4724
4722
  }
4725
4723
  });
4726
- await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe3.Timeframe([
4724
+ const timeframe = new import_timeframe3.Timeframe([
4727
4725
  [
4728
4726
  receipt.feedKey,
4729
4727
  receipt.seq
4730
4728
  ]
4731
- ]));
4729
+ ]);
4730
+ await this.inner.controlPipeline.state.waitUntilTimeframe(timeframe);
4732
4731
  await this._echoHost.updateIndexes();
4733
- return credential;
4732
+ return {
4733
+ credential,
4734
+ timeframe
4735
+ };
4734
4736
  }
4735
4737
  async activate() {
4736
4738
  if (![
4737
- import_services12.SpaceState.CLOSED,
4738
- import_services12.SpaceState.INACTIVE
4739
+ import_services12.SpaceState.SPACE_CLOSED,
4740
+ import_services12.SpaceState.SPACE_INACTIVE
4739
4741
  ].includes(this._state)) {
4740
4742
  return;
4741
4743
  }
4742
- await this._metadataStore.setSpaceState(this.key, import_services12.SpaceState.ACTIVE);
4744
+ await this._metadataStore.setSpaceState(this.key, import_services12.SpaceState.SPACE_ACTIVE);
4743
4745
  await this._open();
4744
4746
  this.initializeDataPipelineAsync();
4745
4747
  }
4746
4748
  async deactivate() {
4747
- if (this._state === import_services12.SpaceState.INACTIVE) {
4749
+ if (this._state === import_services12.SpaceState.SPACE_INACTIVE) {
4748
4750
  return;
4749
4751
  }
4750
- await this._metadataStore.setSpaceState(this.key, import_services12.SpaceState.INACTIVE);
4751
- if (this._state !== import_services12.SpaceState.CLOSED) {
4752
+ await this._metadataStore.setSpaceState(this.key, import_services12.SpaceState.SPACE_INACTIVE);
4753
+ if (this._state !== import_services12.SpaceState.SPACE_CLOSED) {
4752
4754
  await this._close();
4753
4755
  }
4754
- this._state = import_services12.SpaceState.INACTIVE;
4756
+ this._state = import_services12.SpaceState.SPACE_INACTIVE;
4755
4757
  (0, import_log12.log)("new state", {
4756
4758
  state: import_services12.SpaceState[this._state]
4757
4759
  }, {
4758
4760
  F: __dxlog_file17,
4759
- L: 514,
4761
+ L: 513,
4760
4762
  S: this,
4761
4763
  C: (f, a) => f(...a)
4762
4764
  });
@@ -5026,7 +5028,7 @@ var DataSpaceManager = class {
5026
5028
  genesisFeedKey: controlFeedKey,
5027
5029
  controlFeedKey,
5028
5030
  dataFeedKey,
5029
- state: import_services14.SpaceState.ACTIVE
5031
+ state: import_services14.SpaceState.SPACE_ACTIVE
5030
5032
  };
5031
5033
  (0, import_log15.log)("creating space...", {
5032
5034
  spaceKey
@@ -5208,7 +5210,7 @@ var DataSpaceManager = class {
5208
5210
  async waitUntilSpaceReady(spaceKey) {
5209
5211
  await (0, import_context13.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
5210
5212
  const space = this._spaces.get(spaceKey);
5211
- return !!space && space.state === import_services14.SpaceState.READY;
5213
+ return !!space && space.state === import_services14.SpaceState.SPACE_READY;
5212
5214
  }));
5213
5215
  }
5214
5216
  async requestSpaceAdmissionCredential(spaceKey) {
@@ -5255,25 +5257,43 @@ var DataSpaceManager = class {
5255
5257
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5256
5258
  credentialAuthenticator: (0, import_util9.deferFunction)(() => dataSpace.authVerifier.verifier)
5257
5259
  },
5258
- onAuthorizedConnection: (session) => {
5259
- session.addExtension("dxos.mesh.teleport.admission-discovery", new import_echo_pipeline4.CredentialServerExtension(space));
5260
- session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5261
- remotePeerId: session.remotePeerId
5262
- }));
5263
- session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
5264
- this._echoHost.authorizeDevice(space.key, session.remotePeerId);
5265
- session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
5266
- },
5260
+ onAuthorizedConnection: (session) => queueMicrotask(async () => {
5261
+ try {
5262
+ if (!session.isOpen) {
5263
+ return;
5264
+ }
5265
+ session.addExtension("dxos.mesh.teleport.admission-discovery", new import_echo_pipeline4.CredentialServerExtension(space));
5266
+ session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5267
+ remotePeerId: session.remotePeerId
5268
+ }));
5269
+ session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
5270
+ await this._echoHost.authorizeDevice(space.key, session.remotePeerId);
5271
+ if (!session.isOpen) {
5272
+ return;
5273
+ }
5274
+ session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
5275
+ } catch (err) {
5276
+ import_log15.log.warn("error on authorized connection", {
5277
+ err
5278
+ }, {
5279
+ F: __dxlog_file18,
5280
+ L: 403,
5281
+ S: this,
5282
+ C: (f, a) => f(...a)
5283
+ });
5284
+ await session.close(err);
5285
+ }
5286
+ }),
5267
5287
  onAuthFailure: () => {
5268
5288
  import_log15.log.warn("auth failure", void 0, {
5269
5289
  F: __dxlog_file18,
5270
- L: 396,
5290
+ L: 408,
5271
5291
  S: this,
5272
5292
  C: (f, a) => f(...a)
5273
5293
  });
5274
5294
  },
5275
5295
  onMemberRolesChanged: async (members) => {
5276
- if (dataSpace?.state === import_services14.SpaceState.READY) {
5296
+ if (dataSpace?.state === import_services14.SpaceState.SPACE_READY) {
5277
5297
  this._handleMemberRoleChanges(presence, space.protocol, members);
5278
5298
  }
5279
5299
  },
@@ -5286,7 +5306,7 @@ var DataSpaceManager = class {
5286
5306
  dataFeed && await space.setDataFeed(dataFeed);
5287
5307
  const dataSpace = new DataSpace({
5288
5308
  inner: space,
5289
- initialState: metadata.state === import_services14.SpaceState.INACTIVE ? import_services14.SpaceState.INACTIVE : import_services14.SpaceState.CLOSED,
5309
+ initialState: metadata.state === import_services14.SpaceState.SPACE_INACTIVE ? import_services14.SpaceState.SPACE_INACTIVE : import_services14.SpaceState.SPACE_CLOSED,
5290
5310
  metadataStore: this._metadataStore,
5291
5311
  gossip,
5292
5312
  presence,
@@ -5300,7 +5320,7 @@ var DataSpaceManager = class {
5300
5320
  space: space.key
5301
5321
  }, {
5302
5322
  F: __dxlog_file18,
5303
- L: 423,
5323
+ L: 435,
5304
5324
  S: this,
5305
5325
  C: (f, a) => f(...a)
5306
5326
  });
@@ -5311,7 +5331,7 @@ var DataSpaceManager = class {
5311
5331
  open: this._isOpen
5312
5332
  }, {
5313
5333
  F: __dxlog_file18,
5314
- L: 426,
5334
+ L: 438,
5315
5335
  S: this,
5316
5336
  C: (f, a) => f(...a)
5317
5337
  });
@@ -5330,7 +5350,7 @@ var DataSpaceManager = class {
5330
5350
  space: space.key
5331
5351
  }, {
5332
5352
  F: __dxlog_file18,
5333
- L: 434,
5353
+ L: 446,
5334
5354
  S: this,
5335
5355
  C: (f, a) => f(...a)
5336
5356
  });
@@ -5339,7 +5359,7 @@ var DataSpaceManager = class {
5339
5359
  cache: metadata.cache
5340
5360
  });
5341
5361
  presence.newPeer.on((peerState) => {
5342
- if (dataSpace.state === import_services14.SpaceState.READY) {
5362
+ if (dataSpace.state === import_services14.SpaceState.SPACE_READY) {
5343
5363
  this._handleNewPeerConnected(space, peerState);
5344
5364
  }
5345
5365
  });
@@ -5371,7 +5391,7 @@ var DataSpaceManager = class {
5371
5391
  closedSessions
5372
5392
  }, {
5373
5393
  F: __dxlog_file18,
5374
- L: 470,
5394
+ L: 482,
5375
5395
  S: this,
5376
5396
  C: (f, a) => f(...a)
5377
5397
  });
@@ -5386,7 +5406,7 @@ var DataSpaceManager = class {
5386
5406
  peerId: peerState.peerId
5387
5407
  }, {
5388
5408
  F: __dxlog_file18,
5389
- L: 484,
5409
+ L: 496,
5390
5410
  S: this,
5391
5411
  C: (f, a) => f(...a)
5392
5412
  });
@@ -5395,7 +5415,7 @@ var DataSpaceManager = class {
5395
5415
  }
5396
5416
  }
5397
5417
  async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
5398
- if (dataSpace?.state !== import_services14.SpaceState.READY) {
5418
+ if (dataSpace?.state !== import_services14.SpaceState.SPACE_READY) {
5399
5419
  return;
5400
5420
  }
5401
5421
  if (isActive) {
@@ -5464,10 +5484,10 @@ var SpacesServiceImpl = class {
5464
5484
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
5465
5485
  if (state) {
5466
5486
  switch (state) {
5467
- case import_services15.SpaceState.ACTIVE:
5487
+ case import_services15.SpaceState.SPACE_ACTIVE:
5468
5488
  await space.activate();
5469
5489
  break;
5470
- case import_services15.SpaceState.INACTIVE:
5490
+ case import_services15.SpaceState.SPACE_INACTIVE:
5471
5491
  await space.deactivate();
5472
5492
  break;
5473
5493
  default:
@@ -5514,9 +5534,9 @@ var SpacesServiceImpl = class {
5514
5534
  const scheduler = new import_async17.UpdateScheduler(ctx, async () => {
5515
5535
  const dataSpaceManager = await this._getDataSpaceManager();
5516
5536
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
5517
- (0, import_log16.log)("update", {
5518
- spaces
5519
- }, {
5537
+ (0, import_log16.log)("update", () => ({
5538
+ ids: spaces.map((space) => space.id)
5539
+ }), {
5520
5540
  F: __dxlog_file19,
5521
5541
  L: 115,
5522
5542
  S: this,
@@ -5651,12 +5671,13 @@ var SpacesServiceImpl = class {
5651
5671
  async createEpoch({ spaceKey, migration, automergeRootUrl }) {
5652
5672
  const dataSpaceManager = await this._getDataSpaceManager();
5653
5673
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
5654
- const credential = await space.createEpoch({
5674
+ const result = await space.createEpoch({
5655
5675
  migration,
5656
5676
  newAutomergeRoot: automergeRootUrl
5657
5677
  });
5658
5678
  return {
5659
- epochCredential: credential ?? void 0
5679
+ epochCredential: result?.credential,
5680
+ controlTimeframe: result?.timeframe
5660
5681
  };
5661
5682
  }
5662
5683
  async admitContact(request) {
@@ -5763,7 +5784,7 @@ var SpacesServiceImpl = class {
5763
5784
  const dataSpaceManager = await this._getDataSpaceManager();
5764
5785
  const identity = this._identityManager.identity?.identityKey.truncate();
5765
5786
  if (identity) {
5766
- import_tracing8.trace.metrics.gauge("echo.space.count", dataSpaceManager.spaces.size, {
5787
+ import_tracing8.trace.metrics.gauge("dxos.echo.space.count", dataSpaceManager.spaces.size, {
5767
5788
  tags: {
5768
5789
  identity
5769
5790
  }
@@ -7135,4 +7156,4 @@ ClientServicesHost = _ts_decorate8([
7135
7156
  subscribeToSpaces,
7136
7157
  subscribeToSwarmInfo
7137
7158
  });
7138
- //# sourceMappingURL=chunk-7XBIZ7NK.cjs.map
7159
+ //# sourceMappingURL=chunk-CVLKGJK5.cjs.map