@dxos/client-services 0.6.3-main.d007b87 → 0.6.3-main.d76104f

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 (32) hide show
  1. package/dist/lib/browser/{chunk-Y7UULU6J.mjs → chunk-TRX3WZGF.mjs} +143 -122
  2. package/dist/lib/browser/chunk-TRX3WZGF.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-4VQMVHT4.cjs → chunk-JYYVESTN.cjs} +141 -120
  7. package/dist/lib/node/chunk-JYYVESTN.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/package.json +36 -36
  21. package/src/packlets/identity/identity-service.ts +2 -2
  22. package/src/packlets/invitations/invitation-guest-extenstion.ts +8 -5
  23. package/src/packlets/invitations/invitation-host-extension.ts +5 -5
  24. package/src/packlets/invitations/invitation-topology.ts +4 -4
  25. package/src/packlets/invitations/invitations-handler.ts +13 -12
  26. package/src/packlets/spaces/data-space-manager.test.ts +6 -6
  27. package/src/packlets/spaces/data-space-manager.ts +28 -16
  28. package/src/packlets/spaces/data-space.ts +31 -27
  29. package/src/packlets/spaces/spaces-service.ts +6 -6
  30. package/src/version.ts +1 -1
  31. package/dist/lib/browser/chunk-Y7UULU6J.mjs.map +0 -7
  32. package/dist/lib/node/chunk-4VQMVHT4.cjs.map +0 -7
@@ -359,7 +359,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
359
359
  import { TRACE_PROCESSOR } from "@dxos/tracing";
360
360
 
361
361
  // packages/sdk/client-services/src/version.ts
362
- var DXOS_VERSION = "0.6.3-main.d007b87";
362
+ var DXOS_VERSION = "0.6.3-main.d76104f";
363
363
 
364
364
  // packages/sdk/client-services/src/packlets/services/platform.ts
365
365
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -1644,9 +1644,9 @@ var IdentityServiceImpl = class extends Resource {
1644
1644
  const dataSpaceManager = this._dataSpaceManagerProvider();
1645
1645
  const recordedDefaultSpaceTrigger = new Trigger3();
1646
1646
  const allProcessed = safeAwaitAll(dataSpaceManager.spaces.values(), async (space) => {
1647
- if (space.state === SpaceState.CLOSED) {
1647
+ if (space.state === SpaceState.SPACE_CLOSED) {
1648
1648
  await space.open();
1649
- const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === SpaceState.REQUIRES_MIGRATION);
1649
+ const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === SpaceState.SPACE_REQUIRES_MIGRATION);
1650
1650
  await Promise.race([
1651
1651
  space.initializeDataPipeline(),
1652
1652
  requiresMigration
@@ -1811,7 +1811,7 @@ import { createTeleportProtocolFactory } from "@dxos/network-manager";
1811
1811
  import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace5 } from "@dxos/protocols";
1812
1812
  import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
1813
1813
  import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
1814
- import { Options as Options4 } from "@dxos/protocols/proto/dxos/halo/invitations";
1814
+ import { InvitationOptions as InvitationOptions4 } from "@dxos/protocols/proto/dxos/halo/invitations";
1815
1815
  import { trace as _trace } from "@dxos/tracing";
1816
1816
  import { ComplexSet as ComplexSet3 } from "@dxos/util";
1817
1817
 
@@ -1821,7 +1821,7 @@ import { cancelWithContext as cancelWithContext2, Context as Context4 } from "@d
1821
1821
  import { invariant as invariant6 } from "@dxos/invariant";
1822
1822
  import { log as log7 } from "@dxos/log";
1823
1823
  import { InvalidInvitationExtensionRoleError, schema as schema2 } from "@dxos/protocols";
1824
- import { Options } from "@dxos/protocols/proto/dxos/halo/invitations";
1824
+ import { InvitationOptions } from "@dxos/protocols/proto/dxos/halo/invitations";
1825
1825
  import { RpcExtension } from "@dxos/teleport";
1826
1826
 
1827
1827
  // packages/sdk/client-services/src/packlets/invitations/utils.ts
@@ -1913,11 +1913,11 @@ var InvitationGuestExtension = class extends RpcExtension {
1913
1913
  C: (f, a) => f(...a)
1914
1914
  });
1915
1915
  await cancelWithContext2(this._ctx, this.rpc.InvitationHostService.options({
1916
- role: Options.Role.GUEST
1916
+ role: InvitationOptions.Role.GUEST
1917
1917
  }));
1918
1918
  log7("options sent", void 0, {
1919
1919
  F: __dxlog_file10,
1920
- L: 88,
1920
+ L: 91,
1921
1921
  S: this,
1922
1922
  C: (f, a) => f(...a)
1923
1923
  });
@@ -1926,13 +1926,13 @@ var InvitationGuestExtension = class extends RpcExtension {
1926
1926
  }));
1927
1927
  log7("options received", void 0, {
1928
1928
  F: __dxlog_file10,
1929
- L: 90,
1929
+ L: 93,
1930
1930
  S: this,
1931
1931
  C: (f, a) => f(...a)
1932
1932
  });
1933
- if (this._remoteOptions?.role !== Options.Role.HOST) {
1933
+ if (this._remoteOptions?.role !== InvitationOptions.Role.HOST) {
1934
1934
  throw new InvalidInvitationExtensionRoleError(void 0, {
1935
- expected: Options.Role.HOST,
1935
+ expected: InvitationOptions.Role.HOST,
1936
1936
  remoteOptions: this._remoteOptions,
1937
1937
  remotePeerId: context.remotePeerId
1938
1938
  });
@@ -1960,7 +1960,7 @@ var InvitationGuestExtension = class extends RpcExtension {
1960
1960
  this._invitationFlowLock = null;
1961
1961
  log7("invitation flow lock released", void 0, {
1962
1962
  F: __dxlog_file10,
1963
- L: 123,
1963
+ L: 126,
1964
1964
  S: this,
1965
1965
  C: (f, a) => f(...a)
1966
1966
  });
@@ -1977,7 +1977,7 @@ import { PublicKey as PublicKey5 } from "@dxos/keys";
1977
1977
  import { log as log8 } from "@dxos/log";
1978
1978
  import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, schema as schema3, trace as trace4 } from "@dxos/protocols";
1979
1979
  import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
1980
- import { AuthenticationResponse, Options as Options2 } from "@dxos/protocols/proto/dxos/halo/invitations";
1980
+ import { AuthenticationResponse, InvitationOptions as InvitationOptions2 } from "@dxos/protocols/proto/dxos/halo/invitations";
1981
1981
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
1982
1982
  var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
1983
1983
  var OPTIONS_TIMEOUT2 = 1e4;
@@ -2235,7 +2235,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2235
2235
  const lastState = this._requireActiveInvitation().state;
2236
2236
  this._callbacks.onStateUpdate(Invitation3.State.CONNECTING);
2237
2237
  await this.rpc.InvitationHostService.options({
2238
- role: Options2.Role.HOST
2238
+ role: InvitationOptions2.Role.HOST
2239
2239
  });
2240
2240
  log8("options sent", void 0, {
2241
2241
  F: __dxlog_file11,
@@ -2252,10 +2252,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
2252
2252
  S: this,
2253
2253
  C: (f, a) => f(...a)
2254
2254
  });
2255
- if (this._remoteOptions?.role !== Options2.Role.GUEST) {
2255
+ if (this._remoteOptions?.role !== InvitationOptions2.Role.GUEST) {
2256
2256
  this._callbacks.onStateUpdate(lastState);
2257
2257
  throw new InvalidInvitationExtensionRoleError2(void 0, {
2258
- expected: Options2.Role.GUEST,
2258
+ expected: InvitationOptions2.Role.GUEST,
2259
2259
  remoteOptions: this._remoteOptions,
2260
2260
  remotePeerId: context.remotePeerId
2261
2261
  });
@@ -2315,7 +2315,7 @@ var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitat
2315
2315
  import { invariant as invariant8 } from "@dxos/invariant";
2316
2316
  import { PublicKey as PublicKey6 } from "@dxos/keys";
2317
2317
  import { log as log9 } from "@dxos/log";
2318
- import { Options as Options3 } from "@dxos/protocols/proto/dxos/halo/invitations";
2318
+ import { InvitationOptions as InvitationOptions3 } from "@dxos/protocols/proto/dxos/halo/invitations";
2319
2319
  import { ComplexSet as ComplexSet2 } from "@dxos/util";
2320
2320
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2321
2321
  var InvitationTopology = class {
@@ -2346,7 +2346,7 @@ var InvitationTopology = class {
2346
2346
  ]
2347
2347
  });
2348
2348
  const { ownPeerId, candidates, connected, allPeers } = this._controller.getState();
2349
- if (this._role === Options3.Role.GUEST) {
2349
+ if (this._role === InvitationOptions3.Role.GUEST) {
2350
2350
  return;
2351
2351
  }
2352
2352
  if (connected.length > 0) {
@@ -2385,7 +2385,7 @@ var InvitationTopology = class {
2385
2385
  this._seenPeers.clear();
2386
2386
  }
2387
2387
  toString() {
2388
- return `InvitationTopology(${this._role === Options3.Role.GUEST ? "guest" : "host"})`;
2388
+ return `InvitationTopology(${this._role === InvitationOptions3.Role.GUEST ? "guest" : "host"})`;
2389
2389
  }
2390
2390
  };
2391
2391
 
@@ -2402,7 +2402,7 @@ var InvitationsHandler = class {
2402
2402
  this._defaultTeleportParams = _defaultTeleportParams;
2403
2403
  }
2404
2404
  handleInvitationFlow(ctx, stream, protocol, invitation) {
2405
- metrics.increment("invitation.created");
2405
+ metrics.increment("dxos.invitation.created");
2406
2406
  const guardedState = this._createGuardedState(ctx, invitation, stream);
2407
2407
  const createExtension = () => {
2408
2408
  const extension = new InvitationHostExtension(guardedState.mutex, {
@@ -2418,7 +2418,7 @@ var InvitationsHandler = class {
2418
2418
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
2419
2419
  invariant9(deviceKey, void 0, {
2420
2420
  F: __dxlog_file13,
2421
- L: 93,
2421
+ L: 94,
2422
2422
  S: this,
2423
2423
  A: [
2424
2424
  "deviceKey",
@@ -2447,7 +2447,7 @@ var InvitationsHandler = class {
2447
2447
  id: traceId
2448
2448
  }), {
2449
2449
  F: __dxlog_file13,
2450
- L: 118,
2450
+ L: 119,
2451
2451
  S: this,
2452
2452
  C: (f, a) => f(...a)
2453
2453
  });
@@ -2455,7 +2455,7 @@ var InvitationsHandler = class {
2455
2455
  ...protocol.toJSON()
2456
2456
  }, {
2457
2457
  F: __dxlog_file13,
2458
- L: 119,
2458
+ L: 120,
2459
2459
  S: this,
2460
2460
  C: (f, a) => f(...a)
2461
2461
  });
@@ -2467,17 +2467,17 @@ var InvitationsHandler = class {
2467
2467
  ...protocol.toJSON()
2468
2468
  }, {
2469
2469
  F: __dxlog_file13,
2470
- L: 121,
2470
+ L: 122,
2471
2471
  S: this,
2472
2472
  C: (f, a) => f(...a)
2473
2473
  });
2474
2474
  guardedState.set(extension, Invitation4.State.SUCCESS);
2475
- metrics.increment("invitation.success");
2475
+ metrics.increment("dxos.invitation.success");
2476
2476
  log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.end({
2477
2477
  id: traceId
2478
2478
  }), {
2479
2479
  F: __dxlog_file13,
2480
- L: 124,
2480
+ L: 125,
2481
2481
  S: this,
2482
2482
  C: (f, a) => f(...a)
2483
2483
  });
@@ -2488,22 +2488,22 @@ var InvitationsHandler = class {
2488
2488
  } catch (err) {
2489
2489
  if (err instanceof TimeoutError) {
2490
2490
  if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
2491
- metrics.increment("invitation.timeout");
2491
+ metrics.increment("dxos.invitation.timeout");
2492
2492
  log10("timeout", {
2493
2493
  ...protocol.toJSON()
2494
2494
  }, {
2495
2495
  F: __dxlog_file13,
2496
- L: 134,
2496
+ L: 135,
2497
2497
  S: this,
2498
2498
  C: (f, a) => f(...a)
2499
2499
  });
2500
2500
  }
2501
2501
  } else {
2502
2502
  if (guardedState.error(extension, err)) {
2503
- metrics.increment("invitation.failed");
2503
+ metrics.increment("dxos.invitation.failed");
2504
2504
  log10.error("failed", err, {
2505
2505
  F: __dxlog_file13,
2506
- L: 139,
2506
+ L: 140,
2507
2507
  S: this,
2508
2508
  C: (f, a) => f(...a)
2509
2509
  });
@@ -2514,7 +2514,7 @@ var InvitationsHandler = class {
2514
2514
  error: err
2515
2515
  }), {
2516
2516
  F: __dxlog_file13,
2517
- L: 142,
2517
+ L: 143,
2518
2518
  S: this,
2519
2519
  C: (f, a) => f(...a)
2520
2520
  });
@@ -2528,7 +2528,7 @@ var InvitationsHandler = class {
2528
2528
  ...err.context
2529
2529
  }, {
2530
2530
  F: __dxlog_file13,
2531
- L: 150,
2531
+ L: 151,
2532
2532
  S: this,
2533
2533
  C: (f, a) => f(...a)
2534
2534
  });
@@ -2536,22 +2536,22 @@ var InvitationsHandler = class {
2536
2536
  }
2537
2537
  if (err instanceof TimeoutError) {
2538
2538
  if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
2539
- metrics.increment("invitation.timeout");
2539
+ metrics.increment("dxos.invitation.timeout");
2540
2540
  log10("timeout", {
2541
2541
  err
2542
2542
  }, {
2543
2543
  F: __dxlog_file13,
2544
- L: 156,
2544
+ L: 157,
2545
2545
  S: this,
2546
2546
  C: (f, a) => f(...a)
2547
2547
  });
2548
2548
  }
2549
2549
  } else {
2550
2550
  if (guardedState.error(extension, err)) {
2551
- metrics.increment("invitation.failed");
2551
+ metrics.increment("dxos.invitation.failed");
2552
2552
  log10.error("failed", err, {
2553
2553
  F: __dxlog_file13,
2554
- L: 161,
2554
+ L: 162,
2555
2555
  S: this,
2556
2556
  C: (f, a) => f(...a)
2557
2557
  });
@@ -2565,7 +2565,7 @@ var InvitationsHandler = class {
2565
2565
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
2566
2566
  log10.warn("invitation has already expired", void 0, {
2567
2567
  F: __dxlog_file13,
2568
- L: 172,
2568
+ L: 173,
2569
2569
  S: this,
2570
2570
  C: (f, a) => f(...a)
2571
2571
  });
@@ -2573,14 +2573,14 @@ var InvitationsHandler = class {
2573
2573
  scheduleTask3(ctx, async () => {
2574
2574
  await swarmConnection.close();
2575
2575
  guardedState.set(null, Invitation4.State.EXPIRED);
2576
- metrics.increment("invitation.expired");
2576
+ metrics.increment("dxos.invitation.expired");
2577
2577
  await ctx.dispose();
2578
2578
  }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
2579
2579
  }
2580
2580
  }
2581
2581
  let swarmConnection;
2582
2582
  scheduleTask3(ctx, async () => {
2583
- swarmConnection = await this._joinSwarm(ctx, invitation, Options4.Role.HOST, createExtension);
2583
+ swarmConnection = await this._joinSwarm(ctx, invitation, InvitationOptions4.Role.HOST, createExtension);
2584
2584
  guardedState.set(null, Invitation4.State.CONNECTING);
2585
2585
  });
2586
2586
  }
@@ -2589,7 +2589,7 @@ var InvitationsHandler = class {
2589
2589
  if (deviceProfile) {
2590
2590
  invariant9(invitation.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2591
2591
  F: __dxlog_file13,
2592
- L: 206,
2592
+ L: 207,
2593
2593
  S: this,
2594
2594
  A: [
2595
2595
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -2607,7 +2607,7 @@ var InvitationsHandler = class {
2607
2607
  triedPeers: triedPeersIds.size
2608
2608
  }, {
2609
2609
  F: __dxlog_file13,
2610
- L: 214,
2610
+ L: 215,
2611
2611
  S: this,
2612
2612
  C: (f, a) => f(...a)
2613
2613
  });
@@ -2634,7 +2634,7 @@ var InvitationsHandler = class {
2634
2634
  currentState: guardedState.current.state
2635
2635
  }, {
2636
2636
  F: __dxlog_file13,
2637
- L: 242,
2637
+ L: 243,
2638
2638
  S: this,
2639
2639
  C: (f, a) => f(...a)
2640
2640
  });
@@ -2652,7 +2652,7 @@ var InvitationsHandler = class {
2652
2652
  id: traceId
2653
2653
  }), {
2654
2654
  F: __dxlog_file13,
2655
- L: 254,
2655
+ L: 255,
2656
2656
  S: this,
2657
2657
  C: (f, a) => f(...a)
2658
2658
  });
@@ -2664,7 +2664,7 @@ var InvitationsHandler = class {
2664
2664
  ...protocol.toJSON()
2665
2665
  }, {
2666
2666
  F: __dxlog_file13,
2667
- L: 265,
2667
+ L: 266,
2668
2668
  S: this,
2669
2669
  C: (f, a) => f(...a)
2670
2670
  });
@@ -2673,7 +2673,7 @@ var InvitationsHandler = class {
2673
2673
  ...protocol.toJSON()
2674
2674
  }, {
2675
2675
  F: __dxlog_file13,
2676
- L: 269,
2676
+ L: 270,
2677
2677
  S: this,
2678
2678
  C: (f, a) => f(...a)
2679
2679
  });
@@ -2686,7 +2686,7 @@ var InvitationsHandler = class {
2686
2686
  response: introductionResponse
2687
2687
  }, {
2688
2688
  F: __dxlog_file13,
2689
- L: 274,
2689
+ L: 275,
2690
2690
  S: this,
2691
2691
  C: (f, a) => f(...a)
2692
2692
  });
@@ -2707,7 +2707,7 @@ var InvitationsHandler = class {
2707
2707
  ...protocol.toJSON()
2708
2708
  }, {
2709
2709
  F: __dxlog_file13,
2710
- L: 300,
2710
+ L: 301,
2711
2711
  S: this,
2712
2712
  C: (f, a) => f(...a)
2713
2713
  });
@@ -2719,7 +2719,7 @@ var InvitationsHandler = class {
2719
2719
  ...protocol.toJSON()
2720
2720
  }, {
2721
2721
  F: __dxlog_file13,
2722
- L: 311,
2722
+ L: 312,
2723
2723
  S: this,
2724
2724
  C: (f, a) => f(...a)
2725
2725
  });
@@ -2732,7 +2732,7 @@ var InvitationsHandler = class {
2732
2732
  id: traceId
2733
2733
  }), {
2734
2734
  F: __dxlog_file13,
2735
- L: 317,
2735
+ L: 318,
2736
2736
  S: this,
2737
2737
  C: (f, a) => f(...a)
2738
2738
  });
@@ -2742,7 +2742,7 @@ var InvitationsHandler = class {
2742
2742
  ...protocol.toJSON()
2743
2743
  }, {
2744
2744
  F: __dxlog_file13,
2745
- L: 320,
2745
+ L: 321,
2746
2746
  S: this,
2747
2747
  C: (f, a) => f(...a)
2748
2748
  });
@@ -2750,7 +2750,7 @@ var InvitationsHandler = class {
2750
2750
  } else {
2751
2751
  log10("auth failed", err, {
2752
2752
  F: __dxlog_file13,
2753
- L: 323,
2753
+ L: 324,
2754
2754
  S: this,
2755
2755
  C: (f, a) => f(...a)
2756
2756
  });
@@ -2762,7 +2762,7 @@ var InvitationsHandler = class {
2762
2762
  error: err
2763
2763
  }), {
2764
2764
  F: __dxlog_file13,
2765
- L: 327,
2765
+ L: 328,
2766
2766
  S: this,
2767
2767
  C: (f, a) => f(...a)
2768
2768
  });
@@ -2778,7 +2778,7 @@ var InvitationsHandler = class {
2778
2778
  ...protocol.toJSON()
2779
2779
  }, {
2780
2780
  F: __dxlog_file13,
2781
- L: 336,
2781
+ L: 337,
2782
2782
  S: this,
2783
2783
  C: (f, a) => f(...a)
2784
2784
  });
@@ -2786,7 +2786,7 @@ var InvitationsHandler = class {
2786
2786
  } else {
2787
2787
  log10("auth failed", err, {
2788
2788
  F: __dxlog_file13,
2789
- L: 339,
2789
+ L: 340,
2790
2790
  S: this,
2791
2791
  C: (f, a) => f(...a)
2792
2792
  });
@@ -2804,21 +2804,21 @@ var InvitationsHandler = class {
2804
2804
  } else {
2805
2805
  invariant9(invitation.swarmKey, void 0, {
2806
2806
  F: __dxlog_file13,
2807
- L: 354,
2807
+ L: 355,
2808
2808
  S: this,
2809
2809
  A: [
2810
2810
  "invitation.swarmKey",
2811
2811
  ""
2812
2812
  ]
2813
2813
  });
2814
- await this._joinSwarm(ctx, invitation, Options4.Role.GUEST, createExtension);
2814
+ await this._joinSwarm(ctx, invitation, InvitationOptions4.Role.GUEST, createExtension);
2815
2815
  guardedState.set(null, Invitation4.State.CONNECTING);
2816
2816
  }
2817
2817
  });
2818
2818
  }
2819
2819
  async _joinSwarm(ctx, invitation, role, extensionFactory) {
2820
2820
  let label;
2821
- if (role === Options4.Role.GUEST) {
2821
+ if (role === InvitationOptions4.Role.GUEST) {
2822
2822
  label = "invitation guest";
2823
2823
  } else if (invitation.kind === Invitation4.Kind.DEVICE) {
2824
2824
  label = "invitation host for device";
@@ -2904,7 +2904,7 @@ var InvitationsHandler = class {
2904
2904
  oldState: stateToString(invitation.state)
2905
2905
  }, {
2906
2906
  F: __dxlog_file13,
2907
- L: 448,
2907
+ L: 449,
2908
2908
  S: this,
2909
2909
  C: (f, a) => f(...a)
2910
2910
  });
@@ -2915,7 +2915,7 @@ var InvitationsHandler = class {
2915
2915
  oldState: stateToString(invitation.state)
2916
2916
  }, {
2917
2917
  F: __dxlog_file13,
2918
- L: 454,
2918
+ L: 455,
2919
2919
  S: this,
2920
2920
  C: (f, a) => f(...a)
2921
2921
  });
@@ -2934,7 +2934,7 @@ var InvitationsHandler = class {
2934
2934
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2935
2935
  log10("guest waiting for authentication code...", void 0, {
2936
2936
  F: __dxlog_file13,
2937
- L: 479,
2937
+ L: 480,
2938
2938
  S: this,
2939
2939
  C: (f, a) => f(...a)
2940
2940
  });
@@ -2942,7 +2942,7 @@ var InvitationsHandler = class {
2942
2942
  const authCode = await authenticated.wait(options);
2943
2943
  log10("sending authentication request", void 0, {
2944
2944
  F: __dxlog_file13,
2945
- L: 483,
2945
+ L: 484,
2946
2946
  S: this,
2947
2947
  C: (f, a) => f(...a)
2948
2948
  });
@@ -2961,7 +2961,7 @@ var InvitationsHandler = class {
2961
2961
  attempt
2962
2962
  }, {
2963
2963
  F: __dxlog_file13,
2964
- L: 494,
2964
+ L: 495,
2965
2965
  S: this,
2966
2966
  C: (f, a) => f(...a)
2967
2967
  });
@@ -2979,7 +2979,7 @@ var InvitationsHandler = class {
2979
2979
  }
2980
2980
  log10("sending authentication request", void 0, {
2981
2981
  F: __dxlog_file13,
2982
- L: 513,
2982
+ L: 514,
2983
2983
  S: this,
2984
2984
  C: (f, a) => f(...a)
2985
2985
  });
@@ -4322,10 +4322,10 @@ var DataSpace = class {
4322
4322
  // TODO(dmaretskyi): Move into Space?
4323
4323
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
4324
4324
  this._epochProcessingMutex = new Mutex2();
4325
- this._state = SpaceState2.CLOSED;
4325
+ this._state = SpaceState2.SPACE_CLOSED;
4326
4326
  this._databaseRoot = null;
4327
4327
  /**
4328
- * Error for _state === SpaceState.ERROR.
4328
+ * Error for _state === SpaceState.SPACE_ERROR.
4329
4329
  */
4330
4330
  this.error = void 0;
4331
4331
  this.stateUpdate = new Event6();
@@ -4394,7 +4394,7 @@ var DataSpace = class {
4394
4394
  };
4395
4395
  }
4396
4396
  async open() {
4397
- if (this._state === SpaceState2.CLOSED) {
4397
+ if (this._state === SpaceState2.SPACE_CLOSED) {
4398
4398
  await this._open();
4399
4399
  }
4400
4400
  }
@@ -4409,7 +4409,7 @@ var DataSpace = class {
4409
4409
  F: __dxlog_file18,
4410
4410
  L: 215
4411
4411
  }));
4412
- this._state = SpaceState2.CONTROL_ONLY;
4412
+ this._state = SpaceState2.SPACE_CONTROL_ONLY;
4413
4413
  log15("new state", {
4414
4414
  state: SpaceState2[this._state]
4415
4415
  }, {
@@ -4427,7 +4427,7 @@ var DataSpace = class {
4427
4427
  }
4428
4428
  async _close() {
4429
4429
  await this._callbacks.beforeClose?.();
4430
- this._state = SpaceState2.CLOSED;
4430
+ this._state = SpaceState2.SPACE_CLOSED;
4431
4431
  log15("new state", {
4432
4432
  state: SpaceState2[this._state]
4433
4433
  }, {
@@ -4480,7 +4480,7 @@ var DataSpace = class {
4480
4480
  S: this,
4481
4481
  C: (f, a) => f(...a)
4482
4482
  });
4483
- this._state = SpaceState2.ERROR;
4483
+ this._state = SpaceState2.SPACE_ERROR;
4484
4484
  log15("new state", {
4485
4485
  state: SpaceState2[this._state]
4486
4486
  }, {
@@ -4497,10 +4497,10 @@ var DataSpace = class {
4497
4497
  });
4498
4498
  }
4499
4499
  async initializeDataPipeline() {
4500
- if (this._state !== SpaceState2.CONTROL_ONLY) {
4500
+ if (this._state !== SpaceState2.SPACE_CONTROL_ONLY) {
4501
4501
  throw new SystemError("Invalid operation");
4502
4502
  }
4503
- this._state = SpaceState2.INITIALIZING;
4503
+ this._state = SpaceState2.SPACE_INITIALIZING;
4504
4504
  log15("new state", {
4505
4505
  state: SpaceState2[this._state]
4506
4506
  }, {
@@ -4511,13 +4511,13 @@ var DataSpace = class {
4511
4511
  });
4512
4512
  await this._initializeAndReadControlPipeline();
4513
4513
  await sleep3(1);
4514
- const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState2.READY);
4514
+ const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState2.SPACE_READY);
4515
4515
  this._automergeSpaceState.startProcessingRootDocs();
4516
4516
  await ready;
4517
4517
  }
4518
4518
  async _enterReadyState() {
4519
4519
  await this._callbacks.beforeReady?.();
4520
- this._state = SpaceState2.READY;
4520
+ this._state = SpaceState2.SPACE_READY;
4521
4521
  log15("new state", {
4522
4522
  state: SpaceState2[this._state]
4523
4523
  }, {
@@ -4628,17 +4628,15 @@ var DataSpace = class {
4628
4628
  };
4629
4629
  });
4630
4630
  }
4631
- const root = await this._echoHost.openSpaceRoot(handle.url);
4631
+ const root = await this._echoHost.openSpaceRoot(this.id, handle.url);
4632
4632
  this._databaseRoot = root;
4633
4633
  if (root.getVersion() !== SpaceDocVersion2.CURRENT) {
4634
- if (this._state !== SpaceState2.REQUIRES_MIGRATION) {
4635
- this._state = SpaceState2.REQUIRES_MIGRATION;
4636
- this.stateUpdate.emit();
4637
- }
4634
+ this._state = SpaceState2.SPACE_REQUIRES_MIGRATION;
4635
+ this.stateUpdate.emit();
4636
+ } else if (this._state !== SpaceState2.SPACE_READY) {
4637
+ await this._enterReadyState();
4638
4638
  } else {
4639
- if (this._state !== SpaceState2.READY) {
4640
- await this._enterReadyState();
4641
- }
4639
+ this.stateUpdate.emit();
4642
4640
  }
4643
4641
  } catch (_) {
4644
4642
  _usingCtx.e = _;
@@ -4655,7 +4653,7 @@ var DataSpace = class {
4655
4653
  err
4656
4654
  }, {
4657
4655
  F: __dxlog_file18,
4658
- L: 433,
4656
+ L: 431,
4659
4657
  S: this,
4660
4658
  C: (f, a) => f(...a)
4661
4659
  });
@@ -4708,40 +4706,44 @@ var DataSpace = class {
4708
4706
  credential
4709
4707
  }
4710
4708
  });
4711
- await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe3([
4709
+ const timeframe = new Timeframe3([
4712
4710
  [
4713
4711
  receipt.feedKey,
4714
4712
  receipt.seq
4715
4713
  ]
4716
- ]));
4714
+ ]);
4715
+ await this.inner.controlPipeline.state.waitUntilTimeframe(timeframe);
4717
4716
  await this._echoHost.updateIndexes();
4718
- return credential;
4717
+ return {
4718
+ credential,
4719
+ timeframe
4720
+ };
4719
4721
  }
4720
4722
  async activate() {
4721
4723
  if (![
4722
- SpaceState2.CLOSED,
4723
- SpaceState2.INACTIVE
4724
+ SpaceState2.SPACE_CLOSED,
4725
+ SpaceState2.SPACE_INACTIVE
4724
4726
  ].includes(this._state)) {
4725
4727
  return;
4726
4728
  }
4727
- await this._metadataStore.setSpaceState(this.key, SpaceState2.ACTIVE);
4729
+ await this._metadataStore.setSpaceState(this.key, SpaceState2.SPACE_ACTIVE);
4728
4730
  await this._open();
4729
4731
  this.initializeDataPipelineAsync();
4730
4732
  }
4731
4733
  async deactivate() {
4732
- if (this._state === SpaceState2.INACTIVE) {
4734
+ if (this._state === SpaceState2.SPACE_INACTIVE) {
4733
4735
  return;
4734
4736
  }
4735
- await this._metadataStore.setSpaceState(this.key, SpaceState2.INACTIVE);
4736
- if (this._state !== SpaceState2.CLOSED) {
4737
+ await this._metadataStore.setSpaceState(this.key, SpaceState2.SPACE_INACTIVE);
4738
+ if (this._state !== SpaceState2.SPACE_CLOSED) {
4737
4739
  await this._close();
4738
4740
  }
4739
- this._state = SpaceState2.INACTIVE;
4741
+ this._state = SpaceState2.SPACE_INACTIVE;
4740
4742
  log15("new state", {
4741
4743
  state: SpaceState2[this._state]
4742
4744
  }, {
4743
4745
  F: __dxlog_file18,
4744
- L: 514,
4746
+ L: 513,
4745
4747
  S: this,
4746
4748
  C: (f, a) => f(...a)
4747
4749
  });
@@ -5040,7 +5042,7 @@ var DataSpaceManager = class {
5040
5042
  genesisFeedKey: controlFeedKey,
5041
5043
  controlFeedKey,
5042
5044
  dataFeedKey,
5043
- state: SpaceState3.ACTIVE
5045
+ state: SpaceState3.SPACE_ACTIVE
5044
5046
  };
5045
5047
  log16("creating space...", {
5046
5048
  spaceKey
@@ -5222,7 +5224,7 @@ var DataSpaceManager = class {
5222
5224
  async waitUntilSpaceReady(spaceKey) {
5223
5225
  await cancelWithContext5(this._ctx, this.updated.waitForCondition(() => {
5224
5226
  const space = this._spaces.get(spaceKey);
5225
- return !!space && space.state === SpaceState3.READY;
5227
+ return !!space && space.state === SpaceState3.SPACE_READY;
5226
5228
  }));
5227
5229
  }
5228
5230
  async requestSpaceAdmissionCredential(spaceKey) {
@@ -5269,25 +5271,43 @@ var DataSpaceManager = class {
5269
5271
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5270
5272
  credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
5271
5273
  },
5272
- onAuthorizedConnection: (session) => {
5273
- session.addExtension("dxos.mesh.teleport.admission-discovery", new CredentialServerExtension(space));
5274
- session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5275
- remotePeerId: session.remotePeerId
5276
- }));
5277
- session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
5278
- this._echoHost.authorizeDevice(space.key, session.remotePeerId);
5279
- session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
5280
- },
5274
+ onAuthorizedConnection: (session) => queueMicrotask(async () => {
5275
+ try {
5276
+ if (!session.isOpen) {
5277
+ return;
5278
+ }
5279
+ session.addExtension("dxos.mesh.teleport.admission-discovery", new CredentialServerExtension(space));
5280
+ session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5281
+ remotePeerId: session.remotePeerId
5282
+ }));
5283
+ session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
5284
+ await this._echoHost.authorizeDevice(space.key, session.remotePeerId);
5285
+ if (!session.isOpen) {
5286
+ return;
5287
+ }
5288
+ session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
5289
+ } catch (err) {
5290
+ log16.warn("error on authorized connection", {
5291
+ err
5292
+ }, {
5293
+ F: __dxlog_file19,
5294
+ L: 403,
5295
+ S: this,
5296
+ C: (f, a) => f(...a)
5297
+ });
5298
+ await session.close(err);
5299
+ }
5300
+ }),
5281
5301
  onAuthFailure: () => {
5282
5302
  log16.warn("auth failure", void 0, {
5283
5303
  F: __dxlog_file19,
5284
- L: 396,
5304
+ L: 408,
5285
5305
  S: this,
5286
5306
  C: (f, a) => f(...a)
5287
5307
  });
5288
5308
  },
5289
5309
  onMemberRolesChanged: async (members) => {
5290
- if (dataSpace?.state === SpaceState3.READY) {
5310
+ if (dataSpace?.state === SpaceState3.SPACE_READY) {
5291
5311
  this._handleMemberRoleChanges(presence, space.protocol, members);
5292
5312
  }
5293
5313
  },
@@ -5300,7 +5320,7 @@ var DataSpaceManager = class {
5300
5320
  dataFeed && await space.setDataFeed(dataFeed);
5301
5321
  const dataSpace = new DataSpace({
5302
5322
  inner: space,
5303
- initialState: metadata.state === SpaceState3.INACTIVE ? SpaceState3.INACTIVE : SpaceState3.CLOSED,
5323
+ initialState: metadata.state === SpaceState3.SPACE_INACTIVE ? SpaceState3.SPACE_INACTIVE : SpaceState3.SPACE_CLOSED,
5304
5324
  metadataStore: this._metadataStore,
5305
5325
  gossip,
5306
5326
  presence,
@@ -5314,7 +5334,7 @@ var DataSpaceManager = class {
5314
5334
  space: space.key
5315
5335
  }, {
5316
5336
  F: __dxlog_file19,
5317
- L: 423,
5337
+ L: 435,
5318
5338
  S: this,
5319
5339
  C: (f, a) => f(...a)
5320
5340
  });
@@ -5325,7 +5345,7 @@ var DataSpaceManager = class {
5325
5345
  open: this._isOpen
5326
5346
  }, {
5327
5347
  F: __dxlog_file19,
5328
- L: 426,
5348
+ L: 438,
5329
5349
  S: this,
5330
5350
  C: (f, a) => f(...a)
5331
5351
  });
@@ -5344,7 +5364,7 @@ var DataSpaceManager = class {
5344
5364
  space: space.key
5345
5365
  }, {
5346
5366
  F: __dxlog_file19,
5347
- L: 434,
5367
+ L: 446,
5348
5368
  S: this,
5349
5369
  C: (f, a) => f(...a)
5350
5370
  });
@@ -5353,7 +5373,7 @@ var DataSpaceManager = class {
5353
5373
  cache: metadata.cache
5354
5374
  });
5355
5375
  presence.newPeer.on((peerState) => {
5356
- if (dataSpace.state === SpaceState3.READY) {
5376
+ if (dataSpace.state === SpaceState3.SPACE_READY) {
5357
5377
  this._handleNewPeerConnected(space, peerState);
5358
5378
  }
5359
5379
  });
@@ -5385,7 +5405,7 @@ var DataSpaceManager = class {
5385
5405
  closedSessions
5386
5406
  }, {
5387
5407
  F: __dxlog_file19,
5388
- L: 470,
5408
+ L: 482,
5389
5409
  S: this,
5390
5410
  C: (f, a) => f(...a)
5391
5411
  });
@@ -5400,7 +5420,7 @@ var DataSpaceManager = class {
5400
5420
  peerId: peerState.peerId
5401
5421
  }, {
5402
5422
  F: __dxlog_file19,
5403
- L: 484,
5423
+ L: 496,
5404
5424
  S: this,
5405
5425
  C: (f, a) => f(...a)
5406
5426
  });
@@ -5409,7 +5429,7 @@ var DataSpaceManager = class {
5409
5429
  }
5410
5430
  }
5411
5431
  async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
5412
- if (dataSpace?.state !== SpaceState3.READY) {
5432
+ if (dataSpace?.state !== SpaceState3.SPACE_READY) {
5413
5433
  return;
5414
5434
  }
5415
5435
  if (isActive) {
@@ -5490,10 +5510,10 @@ var SpacesServiceImpl = class {
5490
5510
  const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
5491
5511
  if (state) {
5492
5512
  switch (state) {
5493
- case SpaceState4.ACTIVE:
5513
+ case SpaceState4.SPACE_ACTIVE:
5494
5514
  await space.activate();
5495
5515
  break;
5496
- case SpaceState4.INACTIVE:
5516
+ case SpaceState4.SPACE_INACTIVE:
5497
5517
  await space.deactivate();
5498
5518
  break;
5499
5519
  default:
@@ -5540,9 +5560,9 @@ var SpacesServiceImpl = class {
5540
5560
  const scheduler = new UpdateScheduler(ctx, async () => {
5541
5561
  const dataSpaceManager = await this._getDataSpaceManager();
5542
5562
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
5543
- log17("update", {
5544
- spaces
5545
- }, {
5563
+ log17("update", () => ({
5564
+ ids: spaces.map((space) => space.id)
5565
+ }), {
5546
5566
  F: __dxlog_file20,
5547
5567
  L: 115,
5548
5568
  S: this,
@@ -5677,12 +5697,13 @@ var SpacesServiceImpl = class {
5677
5697
  async createEpoch({ spaceKey, migration, automergeRootUrl }) {
5678
5698
  const dataSpaceManager = await this._getDataSpaceManager();
5679
5699
  const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
5680
- const credential = await space.createEpoch({
5700
+ const result = await space.createEpoch({
5681
5701
  migration,
5682
5702
  newAutomergeRoot: automergeRootUrl
5683
5703
  });
5684
5704
  return {
5685
- epochCredential: credential ?? void 0
5705
+ epochCredential: result?.credential,
5706
+ controlTimeframe: result?.timeframe
5686
5707
  };
5687
5708
  }
5688
5709
  async admitContact(request) {
@@ -5789,7 +5810,7 @@ var SpacesServiceImpl = class {
5789
5810
  const dataSpaceManager = await this._getDataSpaceManager();
5790
5811
  const identity = this._identityManager.identity?.identityKey.truncate();
5791
5812
  if (identity) {
5792
- trace8.metrics.gauge("echo.space.count", dataSpaceManager.spaces.size, {
5813
+ trace8.metrics.gauge("dxos.echo.space.count", dataSpaceManager.spaces.size, {
5793
5814
  tags: {
5794
5815
  identity
5795
5816
  }
@@ -7332,4 +7353,4 @@ export {
7332
7353
  ClientServicesProviderResource,
7333
7354
  DiagnosticsCollector
7334
7355
  };
7335
- //# sourceMappingURL=chunk-Y7UULU6J.mjs.map
7356
+ //# sourceMappingURL=chunk-TRX3WZGF.mjs.map