@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
@@ -397,7 +397,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
397
397
  import { TRACE_PROCESSOR } from "@dxos/tracing";
398
398
 
399
399
  // packages/sdk/client-services/src/version.ts
400
- var DXOS_VERSION = "0.6.12-staging.e11e696";
400
+ var DXOS_VERSION = "0.6.13-main.548ca8d";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -1935,6 +1935,7 @@ import { PublicKey as PublicKey5 } from "@dxos/keys";
1935
1935
  import { log as log7 } from "@dxos/log";
1936
1936
  import { AlreadyJoinedError, trace as Trace } from "@dxos/protocols";
1937
1937
  import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
1938
+ import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
1938
1939
  import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
1939
1940
  import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
1940
1941
  import { trace } from "@dxos/tracing";
@@ -2360,12 +2361,36 @@ var DataSpaceManager = class extends Resource4 {
2360
2361
  }
2361
2362
  });
2362
2363
  }
2364
+ async setSpaceEdgeReplicationSetting(spaceKey, setting) {
2365
+ const space = this._spaces.get(spaceKey);
2366
+ invariant5(space, "Space not found.", {
2367
+ F: __dxlog_file9,
2368
+ L: 399,
2369
+ S: this,
2370
+ A: [
2371
+ "space",
2372
+ "'Space not found.'"
2373
+ ]
2374
+ });
2375
+ await this._metadataStore.setSpaceEdgeReplicationSetting(spaceKey, setting);
2376
+ if (space.isOpen) {
2377
+ switch (setting) {
2378
+ case EdgeReplicationSetting.DISABLED:
2379
+ await this._echoEdgeReplicator?.disconnectFromSpace(space.id);
2380
+ break;
2381
+ case EdgeReplicationSetting.ENABLED:
2382
+ await this._echoEdgeReplicator?.connectToSpace(space.id);
2383
+ break;
2384
+ }
2385
+ }
2386
+ space.stateUpdate.emit();
2387
+ }
2363
2388
  async _constructSpace(metadata) {
2364
2389
  log7("construct space", {
2365
2390
  metadata
2366
2391
  }, {
2367
2392
  F: __dxlog_file9,
2368
- L: 398,
2393
+ L: 418,
2369
2394
  S: this,
2370
2395
  C: (f, a) => f(...a)
2371
2396
  });
@@ -2409,7 +2434,7 @@ var DataSpaceManager = class extends Resource4 {
2409
2434
  err
2410
2435
  }, {
2411
2436
  F: __dxlog_file9,
2412
- L: 440,
2437
+ L: 460,
2413
2438
  S: this,
2414
2439
  C: (f, a) => f(...a)
2415
2440
  });
@@ -2419,7 +2444,7 @@ var DataSpaceManager = class extends Resource4 {
2419
2444
  onAuthFailure: () => {
2420
2445
  log7.warn("auth failure", void 0, {
2421
2446
  F: __dxlog_file9,
2422
- L: 445,
2447
+ L: 465,
2423
2448
  S: this,
2424
2449
  C: (f, a) => f(...a)
2425
2450
  });
@@ -2452,7 +2477,7 @@ var DataSpaceManager = class extends Resource4 {
2452
2477
  space: space.key
2453
2478
  }, {
2454
2479
  F: __dxlog_file9,
2455
- L: 472,
2480
+ L: 492,
2456
2481
  S: this,
2457
2482
  C: (f, a) => f(...a)
2458
2483
  });
@@ -2463,7 +2488,7 @@ var DataSpaceManager = class extends Resource4 {
2463
2488
  open: this._lifecycleState === LifecycleState.OPEN
2464
2489
  }, {
2465
2490
  F: __dxlog_file9,
2466
- L: 475,
2491
+ L: 495,
2467
2492
  S: this,
2468
2493
  C: (f, a) => f(...a)
2469
2494
  });
@@ -2482,7 +2507,7 @@ var DataSpaceManager = class extends Resource4 {
2482
2507
  space: space.key
2483
2508
  }, {
2484
2509
  F: __dxlog_file9,
2485
- L: 483,
2510
+ L: 503,
2486
2511
  S: this,
2487
2512
  C: (f, a) => f(...a)
2488
2513
  });
@@ -2494,10 +2519,25 @@ var DataSpaceManager = class extends Resource4 {
2494
2519
  edgeFeatures: this._edgeFeatures
2495
2520
  });
2496
2521
  dataSpace.postOpen.append(async () => {
2497
- await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2522
+ const setting = dataSpace.getEdgeReplicationSetting();
2523
+ if (setting === EdgeReplicationSetting.ENABLED) {
2524
+ await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2525
+ } else if (this._echoEdgeReplicator) {
2526
+ log7("not connecting EchoEdgeReplicator because of EdgeReplicationSetting", {
2527
+ spaceId: dataSpace.id
2528
+ }, {
2529
+ F: __dxlog_file9,
2530
+ L: 516,
2531
+ S: this,
2532
+ C: (f, a) => f(...a)
2533
+ });
2534
+ }
2498
2535
  });
2499
2536
  dataSpace.preClose.append(async () => {
2500
- await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2537
+ const setting = dataSpace.getEdgeReplicationSetting();
2538
+ if (setting === EdgeReplicationSetting.ENABLED) {
2539
+ await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2540
+ }
2501
2541
  });
2502
2542
  presence.newPeer.on((peerState) => {
2503
2543
  if (dataSpace.state === SpaceState.SPACE_READY) {
@@ -2517,7 +2557,7 @@ var DataSpaceManager = class extends Resource4 {
2517
2557
  space: space.key
2518
2558
  }, {
2519
2559
  F: __dxlog_file9,
2520
- L: 515,
2560
+ L: 543,
2521
2561
  S: this,
2522
2562
  C: (f, a) => f(...a)
2523
2563
  });
@@ -2550,7 +2590,7 @@ var DataSpaceManager = class extends Resource4 {
2550
2590
  closedSessions
2551
2591
  }, {
2552
2592
  F: __dxlog_file9,
2553
- L: 541,
2593
+ L: 569,
2554
2594
  S: this,
2555
2595
  C: (f, a) => f(...a)
2556
2596
  });
@@ -2565,7 +2605,7 @@ var DataSpaceManager = class extends Resource4 {
2565
2605
  peerId: peerState.peerId
2566
2606
  }, {
2567
2607
  F: __dxlog_file9,
2568
- L: 555,
2608
+ L: 583,
2569
2609
  S: this,
2570
2610
  C: (f, a) => f(...a)
2571
2611
  });
@@ -2650,7 +2690,7 @@ var SpacesServiceImpl = class {
2650
2690
  await this._updateMetrics();
2651
2691
  return this._serializeSpace(space);
2652
2692
  }
2653
- async updateSpace({ spaceKey, state }) {
2693
+ async updateSpace({ spaceKey, state, edgeReplication }) {
2654
2694
  const dataSpaceManager = await this._getDataSpaceManager();
2655
2695
  const space = dataSpaceManager.spaces.get(spaceKey) ?? raise(new SpaceNotFoundError(spaceKey));
2656
2696
  if (state) {
@@ -2665,6 +2705,9 @@ var SpacesServiceImpl = class {
2665
2705
  throw new ApiError("Invalid space state");
2666
2706
  }
2667
2707
  }
2708
+ if (edgeReplication !== void 0) {
2709
+ await dataSpaceManager.setSpaceEdgeReplicationSetting(spaceKey, edgeReplication);
2710
+ }
2668
2711
  }
2669
2712
  async updateMemberRole(request) {
2670
2713
  const identity = this._requireIdentity();
@@ -2681,7 +2724,7 @@ var SpacesServiceImpl = class {
2681
2724
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2682
2725
  invariant6(credentials[0].credential, void 0, {
2683
2726
  F: __dxlog_file10,
2684
- L: 102,
2727
+ L: 106,
2685
2728
  S: this,
2686
2729
  A: [
2687
2730
  "credentials[0].credential",
@@ -2691,7 +2734,7 @@ var SpacesServiceImpl = class {
2691
2734
  const spaceMemberCredential = credentials[0].credential.credential;
2692
2735
  invariant6(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2693
2736
  F: __dxlog_file10,
2694
- L: 104,
2737
+ L: 108,
2695
2738
  S: this,
2696
2739
  A: [
2697
2740
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2709,7 +2752,7 @@ var SpacesServiceImpl = class {
2709
2752
  ids: spaces.map((space) => space.id)
2710
2753
  }), {
2711
2754
  F: __dxlog_file10,
2712
- L: 115,
2755
+ L: 119,
2713
2756
  S: this,
2714
2757
  C: (f, a) => f(...a)
2715
2758
  });
@@ -2801,7 +2844,7 @@ var SpacesServiceImpl = class {
2801
2844
  } else {
2802
2845
  invariant6(!credential.id, "Id on unsigned credentials is not allowed", {
2803
2846
  F: __dxlog_file10,
2804
- L: 213,
2847
+ L: 217,
2805
2848
  S: this,
2806
2849
  A: [
2807
2850
  "!credential.id",
@@ -2810,7 +2853,7 @@ var SpacesServiceImpl = class {
2810
2853
  });
2811
2854
  invariant6(this._identityManager.identity, "Identity is not available", {
2812
2855
  F: __dxlog_file10,
2813
- L: 214,
2856
+ L: 218,
2814
2857
  S: this,
2815
2858
  A: [
2816
2859
  "this._identityManager.identity",
@@ -2820,7 +2863,7 @@ var SpacesServiceImpl = class {
2820
2863
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
2821
2864
  invariant6(credential.issuer.equals(signer.getIssuer()), void 0, {
2822
2865
  F: __dxlog_file10,
2823
- L: 216,
2866
+ L: 220,
2824
2867
  S: this,
2825
2868
  A: [
2826
2869
  "credential.issuer.equals(signer.getIssuer())",
@@ -2870,7 +2913,7 @@ var SpacesServiceImpl = class {
2870
2913
  const assertion = getCredentialAssertion3(credential);
2871
2914
  invariant6(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2872
2915
  F: __dxlog_file10,
2873
- L: 250,
2916
+ L: 254,
2874
2917
  S: this,
2875
2918
  A: [
2876
2919
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2880,7 +2923,7 @@ var SpacesServiceImpl = class {
2880
2923
  const myIdentity = this._identityManager.identity;
2881
2924
  invariant6(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
2882
2925
  F: __dxlog_file10,
2883
- L: 252,
2926
+ L: 256,
2884
2927
  S: this,
2885
2928
  A: [
2886
2929
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -2942,7 +2985,8 @@ var SpacesServiceImpl = class {
2942
2985
  }),
2943
2986
  creator: space.inner.spaceState.creator?.key,
2944
2987
  cache: space.cache,
2945
- metrics: space.metrics
2988
+ metrics: space.metrics,
2989
+ edgeReplication: space.getEdgeReplicationSetting()
2946
2990
  };
2947
2991
  }
2948
2992
  _requireIdentity() {
@@ -4393,6 +4437,9 @@ var DataSpace = class {
4393
4437
  });
4394
4438
  this.stateUpdate.emit();
4395
4439
  }
4440
+ getEdgeReplicationSetting() {
4441
+ return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
4442
+ }
4396
4443
  };
4397
4444
  _ts_decorate6([
4398
4445
  trace5.info()
@@ -4555,30 +4602,30 @@ var DeviceInvitationProtocol = class {
4555
4602
  };
4556
4603
 
4557
4604
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
4558
- import { Mutex as Mutex3, scheduleTask as scheduleTask6, TimeoutError as TimeoutError2 } from "@dxos/async";
4605
+ import { scheduleTask as scheduleTask7, TimeoutError as TimeoutError2 } from "@dxos/async";
4559
4606
  import { INVITATION_TIMEOUT } from "@dxos/client-protocol";
4560
4607
  import { ContextDisposedError as ContextDisposedError3 } from "@dxos/context";
4561
4608
  import { createKeyPair, sign } from "@dxos/crypto";
4562
- import { invariant as invariant14 } from "@dxos/invariant";
4609
+ import { invariant as invariant15 } from "@dxos/invariant";
4563
4610
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4564
- import { log as log16 } from "@dxos/log";
4611
+ import { log as log18 } from "@dxos/log";
4565
4612
  import { createTeleportProtocolFactory } from "@dxos/network-manager";
4566
4613
  import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace7 } from "@dxos/protocols";
4567
- import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
4614
+ import { Invitation as Invitation7 } from "@dxos/protocols/proto/dxos/client/services";
4568
4615
  import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
4569
4616
  import { InvitationOptions as InvitationOptions4 } from "@dxos/protocols/proto/dxos/halo/invitations";
4570
4617
  import { trace as _trace } from "@dxos/tracing";
4571
4618
  import { ComplexSet as ComplexSet5 } from "@dxos/util";
4572
4619
 
4573
- // packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
4574
- import { Trigger as Trigger4 } from "@dxos/async";
4575
- import { cancelWithContext as cancelWithContext4, Context as Context6 } from "@dxos/context";
4620
+ // packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts
4621
+ import { scheduleMicroTask as scheduleMicroTask3, scheduleTask as scheduleTask5 } from "@dxos/async";
4622
+ import { ed25519Signature } from "@dxos/crypto";
4576
4623
  import { invariant as invariant11 } from "@dxos/invariant";
4624
+ import { SpaceId as SpaceId2 } from "@dxos/keys";
4577
4625
  import { log as log13 } from "@dxos/log";
4578
- import { InvalidInvitationExtensionRoleError } from "@dxos/protocols";
4626
+ import { EdgeAuthChallengeError, EdgeCallFailedError as EdgeCallFailedError2 } from "@dxos/protocols";
4579
4627
  import { schema as schema3 } from "@dxos/protocols/proto";
4580
- import { InvitationOptions } from "@dxos/protocols/proto/dxos/halo/invitations";
4581
- import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
4628
+ import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
4582
4629
 
4583
4630
  // packages/sdk/client-services/src/packlets/invitations/utils.ts
4584
4631
  import { cancelWithContext as cancelWithContext3, ContextDisposedError as ContextDisposedError2 } from "@dxos/context";
@@ -4599,24 +4646,184 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
4599
4646
  })());
4600
4647
  };
4601
4648
 
4649
+ // packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts
4650
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
4651
+ var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
4652
+ var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
4653
+ var EdgeInvitationHandler = class {
4654
+ constructor(config, _client, _callbacks) {
4655
+ this._client = _client;
4656
+ this._callbacks = _callbacks;
4657
+ this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
4658
+ this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
4659
+ }
4660
+ handle(ctx, guardedState, protocol, deviceProfile) {
4661
+ if (!this._client) {
4662
+ log13("edge disabled", void 0, {
4663
+ F: __dxlog_file16,
4664
+ L: 65,
4665
+ S: this,
4666
+ C: (f, a) => f(...a)
4667
+ });
4668
+ return;
4669
+ }
4670
+ const invitation = guardedState.current;
4671
+ const spaceId = invitation.spaceId;
4672
+ const canBeHandledByEdge = invitation.authMethod !== Invitation4.AuthMethod.SHARED_SECRET && invitation.type === Invitation4.Type.DELEGATED && invitation.kind === Invitation4.Kind.SPACE && spaceId != null && SpaceId2.isValid(spaceId);
4673
+ if (!canBeHandledByEdge) {
4674
+ log13("invitation could not be handled by edge", {
4675
+ invitation
4676
+ }, {
4677
+ F: __dxlog_file16,
4678
+ L: 79,
4679
+ S: this,
4680
+ C: (f, a) => f(...a)
4681
+ });
4682
+ return;
4683
+ }
4684
+ ctx.onDispose(() => {
4685
+ this._flowLock?.release();
4686
+ this._flowLock = void 0;
4687
+ });
4688
+ const tryHandleInvitation = async () => {
4689
+ const admissionRequest = await protocol.createAdmissionRequest(deviceProfile);
4690
+ if (admissionRequest.space) {
4691
+ try {
4692
+ await this._handleSpaceInvitationFlow(ctx, guardedState, admissionRequest.space, spaceId);
4693
+ } catch (error) {
4694
+ if (error instanceof EdgeCallFailedError2) {
4695
+ log13.info("join space with edge unsuccessful", {
4696
+ reason: error.message,
4697
+ retryable: error.isRetryable,
4698
+ after: error.retryAfterMs ?? this._calculateNextRetryMs()
4699
+ }, {
4700
+ F: __dxlog_file16,
4701
+ L: 95,
4702
+ S: this,
4703
+ C: (f, a) => f(...a)
4704
+ });
4705
+ if (error.isRetryable) {
4706
+ scheduleTask5(ctx, tryHandleInvitation, error.retryAfterMs ?? this._calculateNextRetryMs());
4707
+ }
4708
+ } else {
4709
+ log13.info("failed to handle invitation with edge", {
4710
+ error
4711
+ }, {
4712
+ F: __dxlog_file16,
4713
+ L: 104,
4714
+ S: this,
4715
+ C: (f, a) => f(...a)
4716
+ });
4717
+ scheduleTask5(ctx, tryHandleInvitation, this._calculateNextRetryMs());
4718
+ }
4719
+ }
4720
+ }
4721
+ };
4722
+ scheduleMicroTask3(ctx, tryHandleInvitation);
4723
+ }
4724
+ async _handleSpaceInvitationFlow(ctx, guardedState, admissionRequest, spaceId) {
4725
+ try {
4726
+ log13("edge invitation flow", void 0, {
4727
+ F: __dxlog_file16,
4728
+ L: 120,
4729
+ S: this,
4730
+ C: (f, a) => f(...a)
4731
+ });
4732
+ this._flowLock = await tryAcquireBeforeContextDisposed(ctx, guardedState.mutex);
4733
+ log13("edge invitation flow acquired the lock", void 0, {
4734
+ F: __dxlog_file16,
4735
+ L: 122,
4736
+ S: this,
4737
+ C: (f, a) => f(...a)
4738
+ });
4739
+ guardedState.set(this, Invitation4.State.CONNECTING);
4740
+ const response = await this._joinSpaceByInvitation(guardedState, spaceId, {
4741
+ identityKey: admissionRequest.identityKey.toHex(),
4742
+ invitationId: guardedState.current.invitationId
4743
+ });
4744
+ const admissionResponse = await this._mapToAdmissionResponse(response);
4745
+ await this._callbacks.onInvitationSuccess(admissionResponse, {
4746
+ space: admissionRequest
4747
+ });
4748
+ } catch (error) {
4749
+ guardedState.set(this, Invitation4.State.ERROR);
4750
+ throw error;
4751
+ } finally {
4752
+ this._flowLock?.release();
4753
+ this._flowLock = void 0;
4754
+ }
4755
+ }
4756
+ async _mapToAdmissionResponse(edgeResponse) {
4757
+ const credentialBytes = Buffer.from(edgeResponse.spaceMemberCredential, "base64");
4758
+ const codec = schema3.getCodecForType("dxos.halo.credentials.Credential");
4759
+ return {
4760
+ space: {
4761
+ credential: codec.decode(credentialBytes)
4762
+ }
4763
+ };
4764
+ }
4765
+ async _joinSpaceByInvitation(guardedState, spaceId, request) {
4766
+ invariant11(this._client, void 0, {
4767
+ F: __dxlog_file16,
4768
+ L: 157,
4769
+ S: this,
4770
+ A: [
4771
+ "this._client",
4772
+ ""
4773
+ ]
4774
+ });
4775
+ try {
4776
+ return await this._client.joinSpaceByInvitation(spaceId, request);
4777
+ } catch (error) {
4778
+ if (error instanceof EdgeAuthChallengeError) {
4779
+ guardedState.set(this, Invitation4.State.AUTHENTICATING);
4780
+ const publicKey = guardedState.current.guestKeypair?.publicKey;
4781
+ const privateKey = guardedState.current.guestKeypair?.privateKey;
4782
+ if (!privateKey || !publicKey) {
4783
+ throw error;
4784
+ }
4785
+ const signature = await ed25519Signature(privateKey, Buffer.from(error.challenge, "base64"));
4786
+ request.signature = Buffer.from(signature).toString("base64");
4787
+ return this._client.joinSpaceByInvitation(spaceId, request);
4788
+ } else {
4789
+ throw error;
4790
+ }
4791
+ }
4792
+ }
4793
+ hasFlowLock() {
4794
+ return this._flowLock != null;
4795
+ }
4796
+ _calculateNextRetryMs() {
4797
+ return this._retryInterval + Math.random() * this._retryJitter;
4798
+ }
4799
+ };
4800
+
4602
4801
  // packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
4603
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
4802
+ import { Trigger as Trigger4 } from "@dxos/async";
4803
+ import { cancelWithContext as cancelWithContext4, Context as Context6 } from "@dxos/context";
4804
+ import { invariant as invariant12 } from "@dxos/invariant";
4805
+ import { log as log14 } from "@dxos/log";
4806
+ import { InvalidInvitationExtensionRoleError } from "@dxos/protocols";
4807
+ import { schema as schema4 } from "@dxos/protocols/proto";
4808
+ import { InvitationOptions } from "@dxos/protocols/proto/dxos/halo/invitations";
4809
+ import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
4810
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
4604
4811
  var OPTIONS_TIMEOUT = 1e4;
4605
4812
  var InvitationGuestExtension = class extends RpcExtension2 {
4606
4813
  constructor(_invitationFlowMutex, _callbacks) {
4607
4814
  super({
4608
4815
  requested: {
4609
- InvitationHostService: schema3.getService("dxos.halo.invitations.InvitationHostService")
4816
+ InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
4610
4817
  },
4611
4818
  exposed: {
4612
- InvitationHostService: schema3.getService("dxos.halo.invitations.InvitationHostService")
4819
+ InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
4613
4820
  }
4614
4821
  });
4615
4822
  this._invitationFlowMutex = _invitationFlowMutex;
4616
4823
  this._callbacks = _callbacks;
4617
4824
  this._ctx = new Context6(void 0, {
4618
- F: __dxlog_file16,
4619
- L: 34
4825
+ F: __dxlog_file17,
4826
+ L: 38
4620
4827
  });
4621
4828
  this._remoteOptionsTrigger = new Trigger4();
4622
4829
  this._invitationFlowLock = null;
@@ -4628,9 +4835,9 @@ var InvitationGuestExtension = class extends RpcExtension2 {
4628
4835
  return {
4629
4836
  InvitationHostService: {
4630
4837
  options: async (options) => {
4631
- invariant11(!this._remoteOptions, "Remote options already set.", {
4632
- F: __dxlog_file16,
4633
- L: 64,
4838
+ invariant12(!this._remoteOptions, "Remote options already set.", {
4839
+ F: __dxlog_file17,
4840
+ L: 68,
4634
4841
  S: this,
4635
4842
  A: [
4636
4843
  "!this._remoteOptions",
@@ -4655,34 +4862,34 @@ var InvitationGuestExtension = class extends RpcExtension2 {
4655
4862
  async onOpen(context) {
4656
4863
  await super.onOpen(context);
4657
4864
  try {
4658
- log13("guest acquire lock", void 0, {
4659
- F: __dxlog_file16,
4660
- L: 85,
4865
+ log14("guest acquire lock", void 0, {
4866
+ F: __dxlog_file17,
4867
+ L: 89,
4661
4868
  S: this,
4662
4869
  C: (f, a) => f(...a)
4663
4870
  });
4664
4871
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
4665
- log13("guest lock acquired", void 0, {
4666
- F: __dxlog_file16,
4667
- L: 87,
4872
+ log14("guest lock acquired", void 0, {
4873
+ F: __dxlog_file17,
4874
+ L: 91,
4668
4875
  S: this,
4669
4876
  C: (f, a) => f(...a)
4670
4877
  });
4671
4878
  await cancelWithContext4(this._ctx, this.rpc.InvitationHostService.options({
4672
4879
  role: InvitationOptions.Role.GUEST
4673
4880
  }));
4674
- log13("options sent", void 0, {
4675
- F: __dxlog_file16,
4676
- L: 92,
4881
+ log14("options sent", void 0, {
4882
+ F: __dxlog_file17,
4883
+ L: 96,
4677
4884
  S: this,
4678
4885
  C: (f, a) => f(...a)
4679
4886
  });
4680
4887
  await cancelWithContext4(this._ctx, this._remoteOptionsTrigger.wait({
4681
4888
  timeout: OPTIONS_TIMEOUT
4682
4889
  }));
4683
- log13("options received", void 0, {
4684
- F: __dxlog_file16,
4685
- L: 94,
4890
+ log14("options received", void 0, {
4891
+ F: __dxlog_file17,
4892
+ L: 98,
4686
4893
  S: this,
4687
4894
  C: (f, a) => f(...a)
4688
4895
  });
@@ -4714,9 +4921,9 @@ var InvitationGuestExtension = class extends RpcExtension2 {
4714
4921
  if (this._invitationFlowLock != null) {
4715
4922
  this._invitationFlowLock.release();
4716
4923
  this._invitationFlowLock = null;
4717
- log13("invitation flow lock released", void 0, {
4718
- F: __dxlog_file16,
4719
- L: 127,
4924
+ log14("invitation flow lock released", void 0, {
4925
+ F: __dxlog_file17,
4926
+ L: 131,
4720
4927
  S: this,
4721
4928
  C: (f, a) => f(...a)
4722
4929
  });
@@ -4725,35 +4932,35 @@ var InvitationGuestExtension = class extends RpcExtension2 {
4725
4932
  };
4726
4933
 
4727
4934
  // packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts
4728
- import { Trigger as Trigger5, scheduleTask as scheduleTask5 } from "@dxos/async";
4935
+ import { Trigger as Trigger5, scheduleTask as scheduleTask6 } from "@dxos/async";
4729
4936
  import { cancelWithContext as cancelWithContext5, Context as Context7 } from "@dxos/context";
4730
4937
  import { randomBytes, verify } from "@dxos/crypto";
4731
- import { invariant as invariant12, InvariantViolation } from "@dxos/invariant";
4938
+ import { invariant as invariant13, InvariantViolation } from "@dxos/invariant";
4732
4939
  import { PublicKey as PublicKey9 } from "@dxos/keys";
4733
- import { log as log14 } from "@dxos/log";
4940
+ import { log as log15 } from "@dxos/log";
4734
4941
  import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, trace as trace6 } from "@dxos/protocols";
4735
- import { schema as schema4 } from "@dxos/protocols/proto";
4736
- import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
4942
+ import { schema as schema5 } from "@dxos/protocols/proto";
4943
+ import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
4737
4944
  import { AuthenticationResponse, InvitationOptions as InvitationOptions2 } from "@dxos/protocols/proto/dxos/halo/invitations";
4738
4945
  import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
4739
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
4946
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
4740
4947
  var OPTIONS_TIMEOUT2 = 1e4;
4741
4948
  var MAX_OTP_ATTEMPTS = 3;
4742
4949
  var InvitationHostExtension = class extends RpcExtension3 {
4743
4950
  constructor(_invitationFlowMutex, _callbacks) {
4744
4951
  super({
4745
4952
  requested: {
4746
- InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
4953
+ InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
4747
4954
  },
4748
4955
  exposed: {
4749
- InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
4956
+ InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
4750
4957
  }
4751
4958
  });
4752
4959
  this._invitationFlowMutex = _invitationFlowMutex;
4753
4960
  this._callbacks = _callbacks;
4754
4961
  this._ctx = new Context7(void 0, {
4755
- F: __dxlog_file17,
4756
- L: 53
4962
+ F: __dxlog_file18,
4963
+ L: 57
4757
4964
  });
4758
4965
  this._remoteOptionsTrigger = new Trigger5();
4759
4966
  this._challenge = void 0;
@@ -4772,9 +4979,9 @@ var InvitationHostExtension = class extends RpcExtension3 {
4772
4979
  // Perhaps in the future we will have more complex logic here.
4773
4980
  InvitationHostService: {
4774
4981
  options: async (options) => {
4775
- invariant12(!this._remoteOptions, "Remote options already set.", {
4776
- F: __dxlog_file17,
4777
- L: 102,
4982
+ invariant13(!this._remoteOptions, "Remote options already set.", {
4983
+ F: __dxlog_file18,
4984
+ L: 106,
4778
4985
  S: this,
4779
4986
  A: [
4780
4987
  "!this._remoteOptions",
@@ -4787,48 +4994,48 @@ var InvitationHostExtension = class extends RpcExtension3 {
4787
4994
  introduce: async (request) => {
4788
4995
  const { profile, invitationId } = request;
4789
4996
  const traceId = PublicKey9.random().toHex();
4790
- log14.trace("dxos.sdk.invitation-handler.host.introduce", trace6.begin({
4997
+ log15.trace("dxos.sdk.invitation-handler.host.introduce", trace6.begin({
4791
4998
  id: traceId
4792
4999
  }), {
4793
- F: __dxlog_file17,
4794
- L: 110,
5000
+ F: __dxlog_file18,
5001
+ L: 114,
4795
5002
  S: this,
4796
5003
  C: (f, a) => f(...a)
4797
5004
  });
4798
5005
  const invitation = this._requireActiveInvitation();
4799
- this._assertInvitationState(Invitation4.State.CONNECTED);
5006
+ this._assertInvitationState(Invitation5.State.CONNECTED);
4800
5007
  if (invitationId !== invitation?.invitationId) {
4801
- log14.warn("incorrect invitationId", {
5008
+ log15.warn("incorrect invitationId", {
4802
5009
  expected: invitation.invitationId,
4803
5010
  actual: invitationId
4804
5011
  }, {
4805
- F: __dxlog_file17,
4806
- L: 115,
5012
+ F: __dxlog_file18,
5013
+ L: 119,
4807
5014
  S: this,
4808
5015
  C: (f, a) => f(...a)
4809
5016
  });
4810
5017
  this._callbacks.onError(new Error("Incorrect invitationId."));
4811
- scheduleTask5(this._ctx, () => this.close());
5018
+ scheduleTask6(this._ctx, () => this.close());
4812
5019
  return {
4813
- authMethod: Invitation4.AuthMethod.NONE
5020
+ authMethod: Invitation5.AuthMethod.NONE
4814
5021
  };
4815
5022
  }
4816
- log14("guest introduced themselves", {
5023
+ log15("guest introduced themselves", {
4817
5024
  guestProfile: profile
4818
5025
  }, {
4819
- F: __dxlog_file17,
4820
- L: 124,
5026
+ F: __dxlog_file18,
5027
+ L: 128,
4821
5028
  S: this,
4822
5029
  C: (f, a) => f(...a)
4823
5030
  });
4824
5031
  this.guestProfile = profile;
4825
- this._callbacks.onStateUpdate(Invitation4.State.READY_FOR_AUTHENTICATION);
4826
- this._challenge = invitation.authMethod === Invitation4.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
4827
- log14.trace("dxos.sdk.invitation-handler.host.introduce", trace6.end({
5032
+ this._callbacks.onStateUpdate(Invitation5.State.READY_FOR_AUTHENTICATION);
5033
+ this._challenge = invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
5034
+ log15.trace("dxos.sdk.invitation-handler.host.introduce", trace6.end({
4828
5035
  id: traceId
4829
5036
  }), {
4830
- F: __dxlog_file17,
4831
- L: 130,
5037
+ F: __dxlog_file18,
5038
+ L: 134,
4832
5039
  S: this,
4833
5040
  C: (f, a) => f(...a)
4834
5041
  });
@@ -4839,34 +5046,34 @@ var InvitationHostExtension = class extends RpcExtension3 {
4839
5046
  },
4840
5047
  authenticate: async ({ authCode: code, signedChallenge }) => {
4841
5048
  const traceId = PublicKey9.random().toHex();
4842
- log14.trace("dxos.sdk.invitation-handler.host.authenticate", trace6.begin({
5049
+ log15.trace("dxos.sdk.invitation-handler.host.authenticate", trace6.begin({
4843
5050
  id: traceId
4844
5051
  }), {
4845
- F: __dxlog_file17,
4846
- L: 139,
5052
+ F: __dxlog_file18,
5053
+ L: 143,
4847
5054
  S: this,
4848
5055
  C: (f, a) => f(...a)
4849
5056
  });
4850
5057
  const invitation = this._requireActiveInvitation();
4851
- log14("received authentication request", {
5058
+ log15("received authentication request", {
4852
5059
  authCode: code
4853
5060
  }, {
4854
- F: __dxlog_file17,
4855
- L: 142,
5061
+ F: __dxlog_file18,
5062
+ L: 146,
4856
5063
  S: this,
4857
5064
  C: (f, a) => f(...a)
4858
5065
  });
4859
5066
  let status = AuthenticationResponse.Status.OK;
4860
5067
  this._assertInvitationState([
4861
- Invitation4.State.AUTHENTICATING,
4862
- Invitation4.State.READY_FOR_AUTHENTICATION
5068
+ Invitation5.State.AUTHENTICATING,
5069
+ Invitation5.State.READY_FOR_AUTHENTICATION
4863
5070
  ]);
4864
- this._callbacks.onStateUpdate(Invitation4.State.AUTHENTICATING);
5071
+ this._callbacks.onStateUpdate(Invitation5.State.AUTHENTICATING);
4865
5072
  switch (invitation.authMethod) {
4866
- case Invitation4.AuthMethod.NONE: {
4867
- log14("authentication not required", void 0, {
4868
- F: __dxlog_file17,
4869
- L: 150,
5073
+ case Invitation5.AuthMethod.NONE: {
5074
+ log15("authentication not required", void 0, {
5075
+ F: __dxlog_file18,
5076
+ L: 154,
4870
5077
  S: this,
4871
5078
  C: (f, a) => f(...a)
4872
5079
  });
@@ -4874,7 +5081,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
4874
5081
  status: AuthenticationResponse.Status.OK
4875
5082
  };
4876
5083
  }
4877
- case Invitation4.AuthMethod.SHARED_SECRET: {
5084
+ case Invitation5.AuthMethod.SHARED_SECRET: {
4878
5085
  if (invitation.authCode) {
4879
5086
  if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
4880
5087
  status = AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
@@ -4886,7 +5093,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
4886
5093
  }
4887
5094
  break;
4888
5095
  }
4889
- case Invitation4.AuthMethod.KNOWN_PUBLIC_KEY: {
5096
+ case Invitation5.AuthMethod.KNOWN_PUBLIC_KEY: {
4890
5097
  if (!invitation.guestKeypair) {
4891
5098
  status = AuthenticationResponse.Status.INTERNAL_ERROR;
4892
5099
  break;
@@ -4900,11 +5107,11 @@ var InvitationHostExtension = class extends RpcExtension3 {
4900
5107
  break;
4901
5108
  }
4902
5109
  default: {
4903
- log14.error("invalid authentication method", {
5110
+ log15.error("invalid authentication method", {
4904
5111
  authMethod: invitation.authMethod
4905
5112
  }, {
4906
- F: __dxlog_file17,
4907
- L: 188,
5113
+ F: __dxlog_file18,
5114
+ L: 192,
4908
5115
  S: this,
4909
5116
  C: (f, a) => f(...a)
4910
5117
  });
@@ -4917,19 +5124,19 @@ var InvitationHostExtension = class extends RpcExtension3 {
4917
5124
  AuthenticationResponse.Status.INVALID_OTP
4918
5125
  ].includes(status)) {
4919
5126
  this._callbacks.onError(new Error(`Authentication failed, with status=${status}`));
4920
- scheduleTask5(this._ctx, () => this.close());
5127
+ scheduleTask6(this._ctx, () => this.close());
4921
5128
  return {
4922
5129
  status
4923
5130
  };
4924
5131
  }
4925
- log14.trace("dxos.sdk.invitation-handler.host.authenticate", trace6.end({
5132
+ log15.trace("dxos.sdk.invitation-handler.host.authenticate", trace6.end({
4926
5133
  id: traceId,
4927
5134
  data: {
4928
5135
  status
4929
5136
  }
4930
5137
  }), {
4931
- F: __dxlog_file17,
4932
- L: 200,
5138
+ F: __dxlog_file18,
5139
+ L: 204,
4933
5140
  S: this,
4934
5141
  C: (f, a) => f(...a)
4935
5142
  });
@@ -4939,28 +5146,28 @@ var InvitationHostExtension = class extends RpcExtension3 {
4939
5146
  },
4940
5147
  admit: async (request) => {
4941
5148
  const traceId = PublicKey9.random().toHex();
4942
- log14.trace("dxos.sdk.invitation-handler.host.admit", trace6.begin({
5149
+ log15.trace("dxos.sdk.invitation-handler.host.admit", trace6.begin({
4943
5150
  id: traceId
4944
5151
  }), {
4945
- F: __dxlog_file17,
4946
- L: 206,
5152
+ F: __dxlog_file18,
5153
+ L: 210,
4947
5154
  S: this,
4948
5155
  C: (f, a) => f(...a)
4949
5156
  });
4950
5157
  const invitation = this._requireActiveInvitation();
4951
5158
  try {
4952
5159
  if (isAuthenticationRequired(invitation)) {
4953
- this._assertInvitationState(Invitation4.State.AUTHENTICATING);
5160
+ this._assertInvitationState(Invitation5.State.AUTHENTICATING);
4954
5161
  if (!this.authenticationPassed) {
4955
5162
  throw new Error("Not authenticated");
4956
5163
  }
4957
5164
  }
4958
5165
  const response = await this._callbacks.admit(request);
4959
- log14.trace("dxos.sdk.invitation-handler.host.admit", trace6.end({
5166
+ log15.trace("dxos.sdk.invitation-handler.host.admit", trace6.end({
4960
5167
  id: traceId
4961
5168
  }), {
4962
- F: __dxlog_file17,
4963
- L: 220,
5169
+ F: __dxlog_file18,
5170
+ L: 224,
4964
5171
  S: this,
4965
5172
  C: (f, a) => f(...a)
4966
5173
  });
@@ -4976,36 +5183,36 @@ var InvitationHostExtension = class extends RpcExtension3 {
4976
5183
  async onOpen(context) {
4977
5184
  await super.onOpen(context);
4978
5185
  try {
4979
- log14("host acquire lock", void 0, {
4980
- F: __dxlog_file17,
4981
- L: 235,
5186
+ log15("host acquire lock", void 0, {
5187
+ F: __dxlog_file18,
5188
+ L: 239,
4982
5189
  S: this,
4983
5190
  C: (f, a) => f(...a)
4984
5191
  });
4985
5192
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
4986
- log14("host lock acquired", void 0, {
4987
- F: __dxlog_file17,
4988
- L: 237,
5193
+ log15("host lock acquired", void 0, {
5194
+ F: __dxlog_file18,
5195
+ L: 241,
4989
5196
  S: this,
4990
5197
  C: (f, a) => f(...a)
4991
5198
  });
4992
5199
  const lastState = this._requireActiveInvitation().state;
4993
- this._callbacks.onStateUpdate(Invitation4.State.CONNECTING);
5200
+ this._callbacks.onStateUpdate(Invitation5.State.CONNECTING);
4994
5201
  await this.rpc.InvitationHostService.options({
4995
5202
  role: InvitationOptions2.Role.HOST
4996
5203
  });
4997
- log14("options sent", void 0, {
4998
- F: __dxlog_file17,
4999
- L: 241,
5204
+ log15("options sent", void 0, {
5205
+ F: __dxlog_file18,
5206
+ L: 245,
5000
5207
  S: this,
5001
5208
  C: (f, a) => f(...a)
5002
5209
  });
5003
5210
  await cancelWithContext5(this._ctx, this._remoteOptionsTrigger.wait({
5004
5211
  timeout: OPTIONS_TIMEOUT2
5005
5212
  }));
5006
- log14("options received", void 0, {
5007
- F: __dxlog_file17,
5008
- L: 243,
5213
+ log15("options received", void 0, {
5214
+ F: __dxlog_file18,
5215
+ L: 247,
5009
5216
  S: this,
5010
5217
  C: (f, a) => f(...a)
5011
5218
  });
@@ -5017,7 +5224,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
5017
5224
  remotePeerId: context.remotePeerId
5018
5225
  });
5019
5226
  }
5020
- this._callbacks.onStateUpdate(Invitation4.State.CONNECTED);
5227
+ this._callbacks.onStateUpdate(Invitation5.State.CONNECTED);
5021
5228
  this._callbacks.onOpen(this._ctx, context);
5022
5229
  } catch (err) {
5023
5230
  if (this._invitationFlowLock != null) {
@@ -5031,7 +5238,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
5031
5238
  _requireActiveInvitation() {
5032
5239
  const invitation = this._callbacks.activeInvitation;
5033
5240
  if (invitation == null) {
5034
- scheduleTask5(this._ctx, () => this.close());
5241
+ scheduleTask6(this._ctx, () => this.close());
5035
5242
  throw new Error("Active invitation not found");
5036
5243
  }
5037
5244
  return invitation;
@@ -5042,7 +5249,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
5042
5249
  stateOrMany
5043
5250
  ];
5044
5251
  if (!validStates.includes(invitation.state)) {
5045
- scheduleTask5(this._ctx, () => this.close());
5252
+ scheduleTask6(this._ctx, () => this.close());
5046
5253
  throw new InvariantViolation(`Expected ${stateToString(invitation.state)} to be one of [${validStates.map(stateToString).join(", ")}]`);
5047
5254
  }
5048
5255
  }
@@ -5057,32 +5264,127 @@ var InvitationHostExtension = class extends RpcExtension3 {
5057
5264
  if (this._invitationFlowLock != null) {
5058
5265
  this._invitationFlowLock?.release();
5059
5266
  this._invitationFlowLock = null;
5060
- log14("invitation flow lock released", void 0, {
5061
- F: __dxlog_file17,
5062
- L: 298,
5267
+ log15("invitation flow lock released", void 0, {
5268
+ F: __dxlog_file18,
5269
+ L: 302,
5063
5270
  S: this,
5064
5271
  C: (f, a) => f(...a)
5065
5272
  });
5066
5273
  }
5067
5274
  }
5068
5275
  };
5069
- var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation4.AuthMethod.NONE;
5276
+ var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation5.AuthMethod.NONE;
5277
+
5278
+ // packages/sdk/client-services/src/packlets/invitations/invitation-state.ts
5279
+ import { Mutex as Mutex3 } from "@dxos/async";
5280
+ import { log as log16 } from "@dxos/log";
5281
+ import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
5282
+ var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-state.ts";
5283
+ var createGuardedInvitationState = (ctx, invitation, stream) => {
5284
+ const mutex = new Mutex3();
5285
+ let lastActiveLockHolder = null;
5286
+ let currentInvitation = {
5287
+ ...invitation
5288
+ };
5289
+ const isStateChangeAllowed = (lockHolder) => {
5290
+ if (ctx.disposed || lockHolder !== null && mutex.isLocked() && !lockHolder.hasFlowLock()) {
5291
+ return false;
5292
+ }
5293
+ return lockHolder == null || lastActiveLockHolder !== lockHolder || isNonTerminalState(currentInvitation.state);
5294
+ };
5295
+ return {
5296
+ mutex,
5297
+ get current() {
5298
+ return currentInvitation;
5299
+ },
5300
+ // disposing context prevents any further state updates
5301
+ complete: (newState) => {
5302
+ currentInvitation = {
5303
+ ...currentInvitation,
5304
+ ...newState
5305
+ };
5306
+ stream.next(currentInvitation);
5307
+ return ctx.dispose();
5308
+ },
5309
+ set: (lockHolder, newState) => {
5310
+ if (isStateChangeAllowed(lockHolder)) {
5311
+ logStateUpdate(currentInvitation, lockHolder, newState);
5312
+ currentInvitation = {
5313
+ ...currentInvitation,
5314
+ state: newState
5315
+ };
5316
+ stream.next(currentInvitation);
5317
+ lastActiveLockHolder = lockHolder;
5318
+ return true;
5319
+ }
5320
+ return false;
5321
+ },
5322
+ error: (lockHolder, error) => {
5323
+ if (isStateChangeAllowed(lockHolder)) {
5324
+ logStateUpdate(currentInvitation, lockHolder, Invitation6.State.ERROR);
5325
+ currentInvitation = {
5326
+ ...currentInvitation,
5327
+ state: Invitation6.State.ERROR
5328
+ };
5329
+ stream.next(currentInvitation);
5330
+ stream.error(error);
5331
+ lastActiveLockHolder = lockHolder;
5332
+ return true;
5333
+ }
5334
+ return false;
5335
+ }
5336
+ };
5337
+ };
5338
+ var logStateUpdate = (invitation, actor, newState) => {
5339
+ if (isNonTerminalState(newState)) {
5340
+ log16("invitation state update", {
5341
+ actor: actor?.constructor.name,
5342
+ newState: stateToString(newState),
5343
+ oldState: stateToString(invitation.state)
5344
+ }, {
5345
+ F: __dxlog_file19,
5346
+ L: 89,
5347
+ S: void 0,
5348
+ C: (f, a) => f(...a)
5349
+ });
5350
+ } else {
5351
+ log16.info("invitation state update", {
5352
+ actor: actor?.constructor.name,
5353
+ newState: stateToString(newState),
5354
+ oldState: stateToString(invitation.state)
5355
+ }, {
5356
+ F: __dxlog_file19,
5357
+ L: 95,
5358
+ S: void 0,
5359
+ C: (f, a) => f(...a)
5360
+ });
5361
+ }
5362
+ };
5363
+ var isNonTerminalState = (currentState) => {
5364
+ return ![
5365
+ Invitation6.State.SUCCESS,
5366
+ Invitation6.State.ERROR,
5367
+ Invitation6.State.CANCELLED,
5368
+ Invitation6.State.TIMEOUT,
5369
+ Invitation6.State.EXPIRED
5370
+ ].includes(currentState);
5371
+ };
5070
5372
 
5071
5373
  // packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts
5072
- import { invariant as invariant13 } from "@dxos/invariant";
5374
+ import { invariant as invariant14 } from "@dxos/invariant";
5073
5375
  import { PublicKey as PublicKey10 } from "@dxos/keys";
5074
- import { log as log15 } from "@dxos/log";
5376
+ import { log as log17 } from "@dxos/log";
5075
5377
  import { InvitationOptions as InvitationOptions3 } from "@dxos/protocols/proto/dxos/halo/invitations";
5076
5378
  import { ComplexSet as ComplexSet4 } from "@dxos/util";
5077
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
5379
+ var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
5078
5380
  var InvitationTopology = class {
5079
5381
  constructor(_role) {
5080
5382
  this._role = _role;
5081
5383
  this._seenPeers = new ComplexSet4(PublicKey10.hash);
5082
5384
  }
5083
5385
  init(controller) {
5084
- invariant13(!this._controller, "Already initialized.", {
5085
- F: __dxlog_file18,
5386
+ invariant14(!this._controller, "Already initialized.", {
5387
+ F: __dxlog_file20,
5086
5388
  L: 42,
5087
5389
  S: this,
5088
5390
  A: [
@@ -5093,8 +5395,8 @@ var InvitationTopology = class {
5093
5395
  this._controller = controller;
5094
5396
  }
5095
5397
  update() {
5096
- invariant13(this._controller, "Not initialized.", {
5097
- F: __dxlog_file18,
5398
+ invariant14(this._controller, "Not initialized.", {
5399
+ F: __dxlog_file20,
5098
5400
  L: 47,
5099
5401
  S: this,
5100
5402
  A: [
@@ -5113,11 +5415,11 @@ var InvitationTopology = class {
5113
5415
  const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
5114
5416
  this._seenPeers = new ComplexSet4(PublicKey10.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
5115
5417
  if (firstUnknownPeer != null) {
5116
- log15("invitation connect", {
5418
+ log17("invitation connect", {
5117
5419
  ownPeerId,
5118
5420
  remotePeerId: firstUnknownPeer
5119
5421
  }, {
5120
- F: __dxlog_file18,
5422
+ F: __dxlog_file20,
5121
5423
  L: 69,
5122
5424
  S: this,
5123
5425
  C: (f, a) => f(...a)
@@ -5127,8 +5429,8 @@ var InvitationTopology = class {
5127
5429
  }
5128
5430
  }
5129
5431
  async onOffer(peer) {
5130
- invariant13(this._controller, "Not initialized.", {
5131
- F: __dxlog_file18,
5432
+ invariant14(this._controller, "Not initialized.", {
5433
+ F: __dxlog_file20,
5132
5434
  L: 76,
5133
5435
  S: this,
5134
5436
  A: [
@@ -5147,20 +5449,21 @@ var InvitationTopology = class {
5147
5449
  };
5148
5450
 
5149
5451
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
5150
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
5452
+ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
5151
5453
  var metrics = _trace.metrics;
5152
5454
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
5153
5455
  var InvitationsHandler = class {
5154
5456
  /**
5155
5457
  * @internal
5156
5458
  */
5157
- constructor(_networkManager, _defaultTeleportParams) {
5459
+ constructor(_networkManager, _edgeClient, _connectionParams) {
5158
5460
  this._networkManager = _networkManager;
5159
- this._defaultTeleportParams = _defaultTeleportParams;
5461
+ this._edgeClient = _edgeClient;
5462
+ this._connectionParams = _connectionParams;
5160
5463
  }
5161
5464
  handleInvitationFlow(ctx, stream, protocol, invitation) {
5162
5465
  metrics.increment("dxos.invitation.created");
5163
- const guardedState = this._createGuardedState(ctx, invitation, stream);
5466
+ const guardedState = createGuardedInvitationState(ctx, invitation, stream);
5164
5467
  const createExtension = () => {
5165
5468
  const extension = new InvitationHostExtension(guardedState.mutex, {
5166
5469
  get activeInvitation() {
@@ -5173,9 +5476,9 @@ var InvitationsHandler = class {
5173
5476
  admit: async (admissionRequest) => {
5174
5477
  try {
5175
5478
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
5176
- invariant14(deviceKey, void 0, {
5177
- F: __dxlog_file19,
5178
- L: 94,
5479
+ invariant15(deviceKey, void 0, {
5480
+ F: __dxlog_file21,
5481
+ L: 100,
5179
5482
  S: this,
5180
5483
  A: [
5181
5484
  "deviceKey",
@@ -5197,44 +5500,44 @@ var InvitationsHandler = class {
5197
5500
  guardedState.error(extension, new ContextDisposedError3());
5198
5501
  }
5199
5502
  });
5200
- scheduleTask6(connectionCtx, async () => {
5503
+ scheduleTask7(connectionCtx, async () => {
5201
5504
  const traceId = PublicKey11.random().toHex();
5202
5505
  try {
5203
- log16.trace("dxos.sdk.invitations-handler.host.onOpen", trace7.begin({
5506
+ log18.trace("dxos.sdk.invitations-handler.host.onOpen", trace7.begin({
5204
5507
  id: traceId
5205
5508
  }), {
5206
- F: __dxlog_file19,
5207
- L: 119,
5509
+ F: __dxlog_file21,
5510
+ L: 125,
5208
5511
  S: this,
5209
5512
  C: (f, a) => f(...a)
5210
5513
  });
5211
- log16("connected", {
5514
+ log18("connected", {
5212
5515
  ...protocol.toJSON()
5213
5516
  }, {
5214
- F: __dxlog_file19,
5215
- L: 120,
5517
+ F: __dxlog_file21,
5518
+ L: 126,
5216
5519
  S: this,
5217
5520
  C: (f, a) => f(...a)
5218
5521
  });
5219
5522
  const deviceKey = await extension.completedTrigger.wait({
5220
5523
  timeout: invitation.timeout
5221
5524
  });
5222
- log16("admitted guest", {
5525
+ log18("admitted guest", {
5223
5526
  guest: deviceKey,
5224
5527
  ...protocol.toJSON()
5225
5528
  }, {
5226
- F: __dxlog_file19,
5227
- L: 122,
5529
+ F: __dxlog_file21,
5530
+ L: 128,
5228
5531
  S: this,
5229
5532
  C: (f, a) => f(...a)
5230
5533
  });
5231
- guardedState.set(extension, Invitation5.State.SUCCESS);
5534
+ guardedState.set(extension, Invitation7.State.SUCCESS);
5232
5535
  metrics.increment("dxos.invitation.success");
5233
- log16.trace("dxos.sdk.invitations-handler.host.onOpen", trace7.end({
5536
+ log18.trace("dxos.sdk.invitations-handler.host.onOpen", trace7.end({
5234
5537
  id: traceId
5235
5538
  }), {
5236
- F: __dxlog_file19,
5237
- L: 125,
5539
+ F: __dxlog_file21,
5540
+ L: 131,
5238
5541
  S: this,
5239
5542
  C: (f, a) => f(...a)
5240
5543
  });
@@ -5244,13 +5547,13 @@ var InvitationsHandler = class {
5244
5547
  }
5245
5548
  } catch (err) {
5246
5549
  if (err instanceof TimeoutError2) {
5247
- if (guardedState.set(extension, Invitation5.State.TIMEOUT)) {
5550
+ if (guardedState.set(extension, Invitation7.State.TIMEOUT)) {
5248
5551
  metrics.increment("dxos.invitation.timeout");
5249
- log16("timeout", {
5552
+ log18("timeout", {
5250
5553
  ...protocol.toJSON()
5251
5554
  }, {
5252
- F: __dxlog_file19,
5253
- L: 135,
5555
+ F: __dxlog_file21,
5556
+ L: 141,
5254
5557
  S: this,
5255
5558
  C: (f, a) => f(...a)
5256
5559
  });
@@ -5258,20 +5561,20 @@ var InvitationsHandler = class {
5258
5561
  } else {
5259
5562
  if (guardedState.error(extension, err)) {
5260
5563
  metrics.increment("dxos.invitation.failed");
5261
- log16.error("failed", err, {
5262
- F: __dxlog_file19,
5263
- L: 140,
5564
+ log18.error("failed", err, {
5565
+ F: __dxlog_file21,
5566
+ L: 146,
5264
5567
  S: this,
5265
5568
  C: (f, a) => f(...a)
5266
5569
  });
5267
5570
  }
5268
5571
  }
5269
- log16.trace("dxos.sdk.invitations-handler.host.onOpen", trace7.error({
5572
+ log18.trace("dxos.sdk.invitations-handler.host.onOpen", trace7.error({
5270
5573
  id: traceId,
5271
5574
  error: err
5272
5575
  }), {
5273
- F: __dxlog_file19,
5274
- L: 143,
5576
+ F: __dxlog_file21,
5577
+ L: 149,
5275
5578
  S: this,
5276
5579
  C: (f, a) => f(...a)
5277
5580
  });
@@ -5281,24 +5584,24 @@ var InvitationsHandler = class {
5281
5584
  },
5282
5585
  onError: (err) => {
5283
5586
  if (err instanceof InvalidInvitationExtensionRoleError3) {
5284
- log16("invalid role", {
5587
+ log18("invalid role", {
5285
5588
  ...err.context
5286
5589
  }, {
5287
- F: __dxlog_file19,
5288
- L: 151,
5590
+ F: __dxlog_file21,
5591
+ L: 157,
5289
5592
  S: this,
5290
5593
  C: (f, a) => f(...a)
5291
5594
  });
5292
5595
  return;
5293
5596
  }
5294
5597
  if (err instanceof TimeoutError2) {
5295
- if (guardedState.set(extension, Invitation5.State.TIMEOUT)) {
5598
+ if (guardedState.set(extension, Invitation7.State.TIMEOUT)) {
5296
5599
  metrics.increment("dxos.invitation.timeout");
5297
- log16("timeout", {
5600
+ log18("timeout", {
5298
5601
  err
5299
5602
  }, {
5300
- F: __dxlog_file19,
5301
- L: 157,
5603
+ F: __dxlog_file21,
5604
+ L: 163,
5302
5605
  S: this,
5303
5606
  C: (f, a) => f(...a)
5304
5607
  });
@@ -5306,9 +5609,9 @@ var InvitationsHandler = class {
5306
5609
  } else {
5307
5610
  if (guardedState.error(extension, err)) {
5308
5611
  metrics.increment("dxos.invitation.failed");
5309
- log16.error("failed", err, {
5310
- F: __dxlog_file19,
5311
- L: 162,
5612
+ log18.error("failed", err, {
5613
+ F: __dxlog_file21,
5614
+ L: 168,
5312
5615
  S: this,
5313
5616
  C: (f, a) => f(...a)
5314
5617
  });
@@ -5320,33 +5623,33 @@ var InvitationsHandler = class {
5320
5623
  };
5321
5624
  if (invitation.lifetime && invitation.created) {
5322
5625
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
5323
- log16.warn("invitation has already expired", void 0, {
5324
- F: __dxlog_file19,
5325
- L: 173,
5626
+ log18.warn("invitation has already expired", void 0, {
5627
+ F: __dxlog_file21,
5628
+ L: 179,
5326
5629
  S: this,
5327
5630
  C: (f, a) => f(...a)
5328
5631
  });
5329
5632
  } else {
5330
- scheduleTask6(ctx, async () => {
5633
+ scheduleTask7(ctx, async () => {
5331
5634
  await swarmConnection.close();
5332
- guardedState.set(null, Invitation5.State.EXPIRED);
5635
+ guardedState.set(null, Invitation7.State.EXPIRED);
5333
5636
  metrics.increment("dxos.invitation.expired");
5334
5637
  await ctx.dispose();
5335
5638
  }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
5336
5639
  }
5337
5640
  }
5338
5641
  let swarmConnection;
5339
- scheduleTask6(ctx, async () => {
5642
+ scheduleTask7(ctx, async () => {
5340
5643
  swarmConnection = await this._joinSwarm(ctx, invitation, InvitationOptions4.Role.HOST, createExtension);
5341
- guardedState.set(null, Invitation5.State.CONNECTING);
5644
+ guardedState.set(null, Invitation7.State.CONNECTING);
5342
5645
  });
5343
5646
  }
5344
5647
  acceptInvitation(ctx, stream, protocol, invitation, otpEnteredTrigger, deviceProfile) {
5345
5648
  const { timeout = INVITATION_TIMEOUT } = invitation;
5346
5649
  if (deviceProfile) {
5347
- invariant14(invitation.kind === Invitation5.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
5348
- F: __dxlog_file19,
5349
- L: 207,
5650
+ invariant15(invitation.kind === Invitation7.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
5651
+ F: __dxlog_file21,
5652
+ L: 213,
5350
5653
  S: this,
5351
5654
  A: [
5352
5655
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -5355,23 +5658,23 @@ var InvitationsHandler = class {
5355
5658
  });
5356
5659
  }
5357
5660
  const triedPeersIds = new ComplexSet5(PublicKey11.hash);
5358
- const guardedState = this._createGuardedState(ctx, invitation, stream);
5661
+ const guardedState = createGuardedInvitationState(ctx, invitation, stream);
5359
5662
  const shouldCancelInvitationFlow = (extension) => {
5360
5663
  const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
5361
- log16("should cancel invitation flow", {
5664
+ log18("should cancel invitation flow", {
5362
5665
  isLockedByAnotherConnection,
5363
- invitationType: Invitation5.Type.DELEGATED,
5666
+ invitationType: Invitation7.Type.DELEGATED,
5364
5667
  triedPeers: triedPeersIds.size
5365
5668
  }, {
5366
- F: __dxlog_file19,
5367
- L: 215,
5669
+ F: __dxlog_file21,
5670
+ L: 221,
5368
5671
  S: this,
5369
5672
  C: (f, a) => f(...a)
5370
5673
  });
5371
5674
  if (isLockedByAnotherConnection) {
5372
5675
  return false;
5373
5676
  }
5374
- return invitation.type !== Invitation5.Type.DELEGATED || triedPeersIds.size >= MAX_DELEGATED_INVITATION_HOST_TRIES;
5677
+ return invitation.type !== Invitation7.Type.DELEGATED || triedPeersIds.size >= MAX_DELEGATED_INVITATION_HOST_TRIES;
5375
5678
  };
5376
5679
  let admitted = false;
5377
5680
  const createExtension = () => {
@@ -5386,12 +5689,12 @@ var InvitationsHandler = class {
5386
5689
  return;
5387
5690
  }
5388
5691
  connectionCtx.onDispose(async () => {
5389
- log16("extension disposed", {
5692
+ log18("extension disposed", {
5390
5693
  admitted,
5391
5694
  currentState: guardedState.current.state
5392
5695
  }, {
5393
- F: __dxlog_file19,
5394
- L: 243,
5696
+ F: __dxlog_file21,
5697
+ L: 249,
5395
5698
  S: this,
5396
5699
  C: (f, a) => f(...a)
5397
5700
  });
@@ -5402,35 +5705,35 @@ var InvitationsHandler = class {
5402
5705
  }
5403
5706
  }
5404
5707
  });
5405
- scheduleTask6(connectionCtx, async () => {
5708
+ scheduleTask7(connectionCtx, async () => {
5406
5709
  const traceId = PublicKey11.random().toHex();
5407
5710
  try {
5408
- log16.trace("dxos.sdk.invitations-handler.guest.onOpen", trace7.begin({
5711
+ log18.trace("dxos.sdk.invitations-handler.guest.onOpen", trace7.begin({
5409
5712
  id: traceId
5410
5713
  }), {
5411
- F: __dxlog_file19,
5412
- L: 255,
5714
+ F: __dxlog_file21,
5715
+ L: 261,
5413
5716
  S: this,
5414
5717
  C: (f, a) => f(...a)
5415
5718
  });
5416
- scheduleTask6(connectionCtx, () => {
5417
- guardedState.set(extension, Invitation5.State.TIMEOUT);
5719
+ scheduleTask7(connectionCtx, () => {
5720
+ guardedState.set(extension, Invitation7.State.TIMEOUT);
5418
5721
  extensionCtx.close();
5419
5722
  }, timeout);
5420
- log16("connected", {
5723
+ log18("connected", {
5421
5724
  ...protocol.toJSON()
5422
5725
  }, {
5423
- F: __dxlog_file19,
5424
- L: 266,
5726
+ F: __dxlog_file21,
5727
+ L: 272,
5425
5728
  S: this,
5426
5729
  C: (f, a) => f(...a)
5427
5730
  });
5428
- guardedState.set(extension, Invitation5.State.CONNECTED);
5429
- log16("introduce", {
5731
+ guardedState.set(extension, Invitation7.State.CONNECTED);
5732
+ log18("introduce", {
5430
5733
  ...protocol.toJSON()
5431
5734
  }, {
5432
- F: __dxlog_file19,
5433
- L: 270,
5735
+ F: __dxlog_file21,
5736
+ L: 276,
5434
5737
  S: this,
5435
5738
  C: (f, a) => f(...a)
5436
5739
  });
@@ -5438,33 +5741,33 @@ var InvitationsHandler = class {
5438
5741
  invitationId: invitation.invitationId,
5439
5742
  ...protocol.createIntroduction()
5440
5743
  });
5441
- log16("introduce response", {
5744
+ log18("introduce response", {
5442
5745
  ...protocol.toJSON(),
5443
5746
  response: introductionResponse
5444
5747
  }, {
5445
- F: __dxlog_file19,
5446
- L: 275,
5748
+ F: __dxlog_file21,
5749
+ L: 281,
5447
5750
  S: this,
5448
5751
  C: (f, a) => f(...a)
5449
5752
  });
5450
5753
  invitation.authMethod = introductionResponse.authMethod;
5451
5754
  if (isAuthenticationRequired(invitation)) {
5452
5755
  switch (invitation.authMethod) {
5453
- case Invitation5.AuthMethod.SHARED_SECRET:
5756
+ case Invitation7.AuthMethod.SHARED_SECRET:
5454
5757
  await this._handleGuestOtpAuth(extension, (state) => guardedState.set(extension, state), otpEnteredTrigger, {
5455
5758
  timeout
5456
5759
  });
5457
5760
  break;
5458
- case Invitation5.AuthMethod.KNOWN_PUBLIC_KEY:
5761
+ case Invitation7.AuthMethod.KNOWN_PUBLIC_KEY:
5459
5762
  await this._handleGuestKpkAuth(extension, (state) => guardedState.set(extension, state), invitation, introductionResponse);
5460
5763
  break;
5461
5764
  }
5462
5765
  }
5463
- log16("request admission", {
5766
+ log18("request admission", {
5464
5767
  ...protocol.toJSON()
5465
5768
  }, {
5466
- F: __dxlog_file19,
5467
- L: 301,
5769
+ F: __dxlog_file21,
5770
+ L: 307,
5468
5771
  S: this,
5469
5772
  C: (f, a) => f(...a)
5470
5773
  });
@@ -5472,54 +5775,54 @@ var InvitationsHandler = class {
5472
5775
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
5473
5776
  admitted = true;
5474
5777
  const result = await protocol.accept(admissionResponse, admissionRequest);
5475
- log16("admitted by host", {
5778
+ log18("admitted by host", {
5476
5779
  ...protocol.toJSON()
5477
5780
  }, {
5478
- F: __dxlog_file19,
5479
- L: 312,
5781
+ F: __dxlog_file21,
5782
+ L: 318,
5480
5783
  S: this,
5481
5784
  C: (f, a) => f(...a)
5482
5785
  });
5483
- await guardedState.complete({
5786
+ guardedState.complete({
5484
5787
  ...guardedState.current,
5485
5788
  ...result,
5486
- state: Invitation5.State.SUCCESS
5789
+ state: Invitation7.State.SUCCESS
5487
5790
  });
5488
- log16.trace("dxos.sdk.invitations-handler.guest.onOpen", trace7.end({
5791
+ log18.trace("dxos.sdk.invitations-handler.guest.onOpen", trace7.end({
5489
5792
  id: traceId
5490
5793
  }), {
5491
- F: __dxlog_file19,
5492
- L: 318,
5794
+ F: __dxlog_file21,
5795
+ L: 324,
5493
5796
  S: this,
5494
5797
  C: (f, a) => f(...a)
5495
5798
  });
5496
5799
  } catch (err) {
5497
5800
  if (err instanceof TimeoutError2) {
5498
- log16("timeout", {
5801
+ log18("timeout", {
5499
5802
  ...protocol.toJSON()
5500
5803
  }, {
5501
- F: __dxlog_file19,
5502
- L: 321,
5804
+ F: __dxlog_file21,
5805
+ L: 327,
5503
5806
  S: this,
5504
5807
  C: (f, a) => f(...a)
5505
5808
  });
5506
- guardedState.set(extension, Invitation5.State.TIMEOUT);
5809
+ guardedState.set(extension, Invitation7.State.TIMEOUT);
5507
5810
  } else {
5508
- log16("auth failed", err, {
5509
- F: __dxlog_file19,
5510
- L: 324,
5811
+ log18("auth failed", err, {
5812
+ F: __dxlog_file21,
5813
+ L: 330,
5511
5814
  S: this,
5512
5815
  C: (f, a) => f(...a)
5513
5816
  });
5514
5817
  guardedState.error(extension, err);
5515
5818
  }
5516
5819
  extensionCtx.close(err);
5517
- log16.trace("dxos.sdk.invitations-handler.guest.onOpen", trace7.error({
5820
+ log18.trace("dxos.sdk.invitations-handler.guest.onOpen", trace7.error({
5518
5821
  id: traceId,
5519
5822
  error: err
5520
5823
  }), {
5521
- F: __dxlog_file19,
5522
- L: 328,
5824
+ F: __dxlog_file21,
5825
+ L: 334,
5523
5826
  S: this,
5524
5827
  C: (f, a) => f(...a)
5525
5828
  });
@@ -5531,19 +5834,19 @@ var InvitationsHandler = class {
5531
5834
  return;
5532
5835
  }
5533
5836
  if (err instanceof TimeoutError2) {
5534
- log16("timeout", {
5837
+ log18("timeout", {
5535
5838
  ...protocol.toJSON()
5536
5839
  }, {
5537
- F: __dxlog_file19,
5538
- L: 337,
5840
+ F: __dxlog_file21,
5841
+ L: 343,
5539
5842
  S: this,
5540
5843
  C: (f, a) => f(...a)
5541
5844
  });
5542
- guardedState.set(extension, Invitation5.State.TIMEOUT);
5845
+ guardedState.set(extension, Invitation7.State.TIMEOUT);
5543
5846
  } else {
5544
- log16("auth failed", err, {
5545
- F: __dxlog_file19,
5546
- L: 340,
5847
+ log18("auth failed", err, {
5848
+ F: __dxlog_file21,
5849
+ L: 346,
5547
5850
  S: this,
5548
5851
  C: (f, a) => f(...a)
5549
5852
  });
@@ -5553,15 +5856,34 @@ var InvitationsHandler = class {
5553
5856
  });
5554
5857
  return extension;
5555
5858
  };
5556
- scheduleTask6(ctx, async () => {
5859
+ const edgeInvitationHandler = new EdgeInvitationHandler(this._connectionParams?.edgeInvitations, this._edgeClient, {
5860
+ onInvitationSuccess: async (admissionResponse, admissionRequest) => {
5861
+ const result = await protocol.accept(admissionResponse, admissionRequest);
5862
+ log18("admitted by edge", {
5863
+ ...protocol.toJSON()
5864
+ }, {
5865
+ F: __dxlog_file21,
5866
+ L: 358,
5867
+ S: this,
5868
+ C: (f, a) => f(...a)
5869
+ });
5870
+ guardedState.complete({
5871
+ ...guardedState.current,
5872
+ ...result,
5873
+ state: Invitation7.State.SUCCESS
5874
+ });
5875
+ }
5876
+ });
5877
+ edgeInvitationHandler.handle(ctx, guardedState, protocol, deviceProfile);
5878
+ scheduleTask7(ctx, async () => {
5557
5879
  const error = protocol.checkInvitation(invitation);
5558
5880
  if (error) {
5559
5881
  stream.error(error);
5560
5882
  await ctx.dispose();
5561
5883
  } else {
5562
- invariant14(invitation.swarmKey, void 0, {
5563
- F: __dxlog_file19,
5564
- L: 355,
5884
+ invariant15(invitation.swarmKey, void 0, {
5885
+ F: __dxlog_file21,
5886
+ L: 370,
5565
5887
  S: this,
5566
5888
  A: [
5567
5889
  "invitation.swarmKey",
@@ -5570,14 +5892,14 @@ var InvitationsHandler = class {
5570
5892
  });
5571
5893
  const timeoutInactive = () => {
5572
5894
  if (guardedState.mutex.isLocked()) {
5573
- scheduleTask6(ctx, timeoutInactive, timeout);
5895
+ scheduleTask7(ctx, timeoutInactive, timeout);
5574
5896
  } else {
5575
- guardedState.set(null, Invitation5.State.TIMEOUT);
5897
+ guardedState.set(null, Invitation7.State.TIMEOUT);
5576
5898
  }
5577
5899
  };
5578
- scheduleTask6(ctx, timeoutInactive, timeout);
5900
+ scheduleTask7(ctx, timeoutInactive, timeout);
5579
5901
  await this._joinSwarm(ctx, invitation, InvitationOptions4.Role.GUEST, createExtension);
5580
- guardedState.set(null, Invitation5.State.CONNECTING);
5902
+ guardedState.set(null, Invitation7.State.CONNECTING);
5581
5903
  }
5582
5904
  });
5583
5905
  }
@@ -5585,7 +5907,7 @@ var InvitationsHandler = class {
5585
5907
  let label;
5586
5908
  if (role === InvitationOptions4.Role.GUEST) {
5587
5909
  label = "invitation guest";
5588
- } else if (invitation.kind === Invitation5.Kind.DEVICE) {
5910
+ } else if (invitation.kind === Invitation7.Kind.DEVICE) {
5589
5911
  label = "invitation host for device";
5590
5912
  } else {
5591
5913
  label = `invitation host for space ${invitation.spaceKey?.truncate()}`;
@@ -5594,123 +5916,30 @@ var InvitationsHandler = class {
5594
5916
  topic: invitation.swarmKey,
5595
5917
  protocolProvider: createTeleportProtocolFactory(async (teleport) => {
5596
5918
  teleport.addExtension("dxos.halo.invitations", extensionFactory());
5597
- }, this._defaultTeleportParams),
5919
+ }, this._connectionParams?.teleport),
5598
5920
  topology: new InvitationTopology(role),
5599
5921
  label
5600
5922
  });
5601
5923
  ctx.onDispose(() => swarmConnection.close());
5602
5924
  return swarmConnection;
5603
5925
  }
5604
- /**
5605
- * A utility object for serializing invitation state changes by multiple concurrent
5606
- * invitation flow connections.
5607
- */
5608
- _createGuardedState(ctx, invitation, stream) {
5609
- const mutex = new Mutex3();
5610
- let lastActiveExtension = null;
5611
- let currentInvitation = {
5612
- ...invitation
5613
- };
5614
- const isStateChangeAllowed = (extension) => {
5615
- if (ctx.disposed || extension !== null && mutex.isLocked() && !extension.hasFlowLock()) {
5616
- return false;
5617
- }
5618
- return extension == null || lastActiveExtension !== extension || this._isNotTerminal(currentInvitation.state);
5619
- };
5620
- return {
5621
- mutex,
5622
- get current() {
5623
- return currentInvitation;
5624
- },
5625
- // disposing context prevents any further state updates
5626
- complete: (newState) => {
5627
- currentInvitation = {
5628
- ...currentInvitation,
5629
- ...newState
5630
- };
5631
- stream.next(currentInvitation);
5632
- return ctx.dispose();
5633
- },
5634
- set: (extension, newState) => {
5635
- if (isStateChangeAllowed(extension)) {
5636
- this._logStateUpdate(currentInvitation, extension, newState);
5637
- currentInvitation = {
5638
- ...currentInvitation,
5639
- state: newState
5640
- };
5641
- stream.next(currentInvitation);
5642
- lastActiveExtension = extension;
5643
- return true;
5644
- }
5645
- return false;
5646
- },
5647
- error: (extension, error) => {
5648
- if (isStateChangeAllowed(extension)) {
5649
- this._logStateUpdate(currentInvitation, extension, Invitation5.State.ERROR);
5650
- currentInvitation = {
5651
- ...currentInvitation,
5652
- state: Invitation5.State.ERROR
5653
- };
5654
- stream.next(currentInvitation);
5655
- stream.error(error);
5656
- lastActiveExtension = extension;
5657
- return true;
5658
- }
5659
- return false;
5660
- }
5661
- };
5662
- }
5663
- _logStateUpdate(invitation, actor, newState) {
5664
- if (this._isNotTerminal(newState)) {
5665
- log16("invitation state update", {
5666
- actor: actor?.constructor.name,
5667
- newState: stateToString(newState),
5668
- oldState: stateToString(invitation.state)
5669
- }, {
5670
- F: __dxlog_file19,
5671
- L: 460,
5672
- S: this,
5673
- C: (f, a) => f(...a)
5674
- });
5675
- } else {
5676
- log16("invitation state update", {
5677
- actor: actor?.constructor.name,
5678
- newState: stateToString(newState),
5679
- oldState: stateToString(invitation.state)
5680
- }, {
5681
- F: __dxlog_file19,
5682
- L: 466,
5683
- S: this,
5684
- C: (f, a) => f(...a)
5685
- });
5686
- }
5687
- }
5688
- _isNotTerminal(currentState) {
5689
- return ![
5690
- Invitation5.State.SUCCESS,
5691
- Invitation5.State.ERROR,
5692
- Invitation5.State.CANCELLED,
5693
- Invitation5.State.TIMEOUT,
5694
- Invitation5.State.EXPIRED
5695
- ].includes(currentState);
5696
- }
5697
5926
  async _handleGuestOtpAuth(extension, setState, authenticated, options) {
5698
5927
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
5699
- log16("guest waiting for authentication code...", void 0, {
5700
- F: __dxlog_file19,
5701
- L: 491,
5928
+ log18("guest waiting for authentication code...", void 0, {
5929
+ F: __dxlog_file21,
5930
+ L: 422,
5702
5931
  S: this,
5703
5932
  C: (f, a) => f(...a)
5704
5933
  });
5705
- setState(Invitation5.State.READY_FOR_AUTHENTICATION);
5934
+ setState(Invitation7.State.READY_FOR_AUTHENTICATION);
5706
5935
  const authCode = await authenticated.wait(options);
5707
- log16("sending authentication request", void 0, {
5708
- F: __dxlog_file19,
5709
- L: 495,
5936
+ log18("sending authentication request", void 0, {
5937
+ F: __dxlog_file21,
5938
+ L: 426,
5710
5939
  S: this,
5711
5940
  C: (f, a) => f(...a)
5712
5941
  });
5713
- setState(Invitation5.State.AUTHENTICATING);
5942
+ setState(Invitation7.State.AUTHENTICATING);
5714
5943
  const response = await extension.rpc.InvitationHostService.authenticate({
5715
5944
  authCode
5716
5945
  });
@@ -5721,11 +5950,11 @@ var InvitationsHandler = class {
5721
5950
  if (attempt === MAX_OTP_ATTEMPTS) {
5722
5951
  throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
5723
5952
  } else {
5724
- log16("retrying invalid code", {
5953
+ log18("retrying invalid code", {
5725
5954
  attempt
5726
5955
  }, {
5727
- F: __dxlog_file19,
5728
- L: 506,
5956
+ F: __dxlog_file21,
5957
+ L: 437,
5729
5958
  S: this,
5730
5959
  C: (f, a) => f(...a)
5731
5960
  });
@@ -5741,13 +5970,13 @@ var InvitationsHandler = class {
5741
5970
  if (introductionResponse.challenge == null) {
5742
5971
  throw new Error("challenge missing in the introduction");
5743
5972
  }
5744
- log16("sending authentication request", void 0, {
5745
- F: __dxlog_file19,
5746
- L: 525,
5973
+ log18("sending authentication request", void 0, {
5974
+ F: __dxlog_file21,
5975
+ L: 456,
5747
5976
  S: this,
5748
5977
  C: (f, a) => f(...a)
5749
5978
  });
5750
- setState(Invitation5.State.AUTHENTICATING);
5979
+ setState(Invitation7.State.AUTHENTICATING);
5751
5980
  const signature = sign(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
5752
5981
  const response = await extension.rpc.InvitationHostService.authenticate({
5753
5982
  signedChallenge: signature
@@ -5865,12 +6094,12 @@ var InvitationsServiceImpl = class {
5865
6094
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
5866
6095
  import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
5867
6096
  import { writeMessages as writeMessages4 } from "@dxos/feed-store";
5868
- import { invariant as invariant15 } from "@dxos/invariant";
5869
- import { log as log17 } from "@dxos/log";
6097
+ import { invariant as invariant16 } from "@dxos/invariant";
6098
+ import { log as log19 } from "@dxos/log";
5870
6099
  import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
5871
- import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
6100
+ import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
5872
6101
  import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
5873
- var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
6102
+ var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
5874
6103
  var SpaceInvitationProtocol = class {
5875
6104
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
5876
6105
  this._spaceManager = _spaceManager;
@@ -5898,27 +6127,47 @@ var SpaceInvitationProtocol = class {
5898
6127
  return void 0;
5899
6128
  }
5900
6129
  getInvitationContext() {
6130
+ invariant16(this._spaceKey, void 0, {
6131
+ F: __dxlog_file22,
6132
+ L: 63,
6133
+ S: this,
6134
+ A: [
6135
+ "this._spaceKey",
6136
+ ""
6137
+ ]
6138
+ });
6139
+ const space = this._spaceManager.spaces.get(this._spaceKey);
6140
+ invariant16(space, void 0, {
6141
+ F: __dxlog_file22,
6142
+ L: 65,
6143
+ S: this,
6144
+ A: [
6145
+ "space",
6146
+ ""
6147
+ ]
6148
+ });
5901
6149
  return {
5902
- kind: Invitation6.Kind.SPACE,
5903
- spaceKey: this._spaceKey
6150
+ kind: Invitation8.Kind.SPACE,
6151
+ spaceKey: this._spaceKey,
6152
+ spaceId: space.id
5904
6153
  };
5905
6154
  }
5906
6155
  async admit(invitation, request, guestProfile) {
5907
- invariant15(this._spaceKey && request.space, void 0, {
5908
- F: __dxlog_file20,
5909
- L: 74,
6156
+ invariant16(this._spaceKey && request.space, void 0, {
6157
+ F: __dxlog_file22,
6158
+ L: 78,
5910
6159
  S: this,
5911
6160
  A: [
5912
6161
  "this._spaceKey && request.space",
5913
6162
  ""
5914
6163
  ]
5915
6164
  });
5916
- log17("writing guest credentials", {
6165
+ log19("writing guest credentials", {
5917
6166
  host: this._signingContext.deviceKey,
5918
6167
  guest: request.space.deviceKey
5919
6168
  }, {
5920
- F: __dxlog_file20,
5921
- L: 75,
6169
+ F: __dxlog_file22,
6170
+ L: 79,
5922
6171
  S: this,
5923
6172
  C: (f, a) => f(...a)
5924
6173
  });
@@ -5938,9 +6187,9 @@ var SpaceInvitationProtocol = class {
5938
6187
  };
5939
6188
  }
5940
6189
  async delegate(invitation) {
5941
- invariant15(this._spaceKey, void 0, {
5942
- F: __dxlog_file20,
5943
- L: 95,
6190
+ invariant16(this._spaceKey, void 0, {
6191
+ F: __dxlog_file22,
6192
+ L: 99,
5944
6193
  S: this,
5945
6194
  A: [
5946
6195
  "this._spaceKey",
@@ -5948,19 +6197,19 @@ var SpaceInvitationProtocol = class {
5948
6197
  ]
5949
6198
  });
5950
6199
  const space = this._spaceManager.spaces.get(this._spaceKey);
5951
- invariant15(space, void 0, {
5952
- F: __dxlog_file20,
5953
- L: 97,
6200
+ invariant16(space, void 0, {
6201
+ F: __dxlog_file22,
6202
+ L: 101,
5954
6203
  S: this,
5955
6204
  A: [
5956
6205
  "space",
5957
6206
  ""
5958
6207
  ]
5959
6208
  });
5960
- if (invitation.authMethod === Invitation6.AuthMethod.KNOWN_PUBLIC_KEY) {
5961
- invariant15(invitation.guestKeypair?.publicKey, void 0, {
5962
- F: __dxlog_file20,
5963
- L: 99,
6209
+ if (invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY) {
6210
+ invariant16(invitation.guestKeypair?.publicKey, void 0, {
6211
+ F: __dxlog_file22,
6212
+ L: 103,
5964
6213
  S: this,
5965
6214
  A: [
5966
6215
  "invitation.guestKeypair?.publicKey",
@@ -5968,12 +6217,12 @@ var SpaceInvitationProtocol = class {
5968
6217
  ]
5969
6218
  });
5970
6219
  }
5971
- log17("writing delegate space invitation", {
6220
+ log19("writing delegate space invitation", {
5972
6221
  host: this._signingContext.deviceKey,
5973
6222
  id: invitation.invitationId
5974
6223
  }, {
5975
- F: __dxlog_file20,
5976
- L: 102,
6224
+ F: __dxlog_file22,
6225
+ L: 106,
5977
6226
  S: this,
5978
6227
  C: (f, a) => f(...a)
5979
6228
  });
@@ -5984,11 +6233,11 @@ var SpaceInvitationProtocol = class {
5984
6233
  role: invitation.role ?? SpaceMember6.Role.ADMIN,
5985
6234
  expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
5986
6235
  multiUse: invitation.multiUse ?? false,
5987
- guestKey: invitation.authMethod === Invitation6.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
6236
+ guestKey: invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
5988
6237
  });
5989
- invariant15(credential.credential, void 0, {
5990
- F: __dxlog_file20,
5991
- L: 122,
6238
+ invariant16(credential.credential, void 0, {
6239
+ F: __dxlog_file22,
6240
+ L: 126,
5992
6241
  S: this,
5993
6242
  A: [
5994
6243
  "credential.credential",
@@ -6001,18 +6250,18 @@ var SpaceInvitationProtocol = class {
6001
6250
  return credential.credential.credential.id;
6002
6251
  }
6003
6252
  async cancelDelegation(invitation) {
6004
- invariant15(this._spaceKey, void 0, {
6005
- F: __dxlog_file20,
6006
- L: 128,
6253
+ invariant16(this._spaceKey, void 0, {
6254
+ F: __dxlog_file22,
6255
+ L: 132,
6007
6256
  S: this,
6008
6257
  A: [
6009
6258
  "this._spaceKey",
6010
6259
  ""
6011
6260
  ]
6012
6261
  });
6013
- invariant15(invitation.type === Invitation6.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6014
- F: __dxlog_file20,
6015
- L: 129,
6262
+ invariant16(invitation.type === Invitation8.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6263
+ F: __dxlog_file22,
6264
+ L: 133,
6016
6265
  S: this,
6017
6266
  A: [
6018
6267
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -6020,28 +6269,28 @@ var SpaceInvitationProtocol = class {
6020
6269
  ]
6021
6270
  });
6022
6271
  const space = this._spaceManager.spaces.get(this._spaceKey);
6023
- invariant15(space, void 0, {
6024
- F: __dxlog_file20,
6025
- L: 131,
6272
+ invariant16(space, void 0, {
6273
+ F: __dxlog_file22,
6274
+ L: 135,
6026
6275
  S: this,
6027
6276
  A: [
6028
6277
  "space",
6029
6278
  ""
6030
6279
  ]
6031
6280
  });
6032
- log17("cancelling delegated space invitation", {
6281
+ log19("cancelling delegated space invitation", {
6033
6282
  host: this._signingContext.deviceKey,
6034
6283
  id: invitation.invitationId
6035
6284
  }, {
6036
- F: __dxlog_file20,
6037
- L: 133,
6285
+ F: __dxlog_file22,
6286
+ L: 137,
6038
6287
  S: this,
6039
6288
  C: (f, a) => f(...a)
6040
6289
  });
6041
6290
  const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
6042
- invariant15(credential.credential, void 0, {
6043
- F: __dxlog_file20,
6044
- L: 140,
6291
+ invariant16(credential.credential, void 0, {
6292
+ F: __dxlog_file22,
6293
+ L: 144,
6045
6294
  S: this,
6046
6295
  A: [
6047
6296
  "credential.credential",
@@ -6078,9 +6327,9 @@ var SpaceInvitationProtocol = class {
6078
6327
  };
6079
6328
  }
6080
6329
  async accept(response) {
6081
- invariant15(response.space, void 0, {
6082
- F: __dxlog_file20,
6083
- L: 175,
6330
+ invariant16(response.space, void 0, {
6331
+ F: __dxlog_file22,
6332
+ L: 179,
6084
6333
  S: this,
6085
6334
  A: [
6086
6335
  "response.space",
@@ -6089,18 +6338,18 @@ var SpaceInvitationProtocol = class {
6089
6338
  });
6090
6339
  const { credential, controlTimeframe, dataTimeframe } = response.space;
6091
6340
  const assertion = getCredentialAssertion4(credential);
6092
- invariant15(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
6093
- F: __dxlog_file20,
6094
- L: 178,
6341
+ invariant16(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
6342
+ F: __dxlog_file22,
6343
+ L: 182,
6095
6344
  S: this,
6096
6345
  A: [
6097
6346
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
6098
6347
  "'Invalid credential'"
6099
6348
  ]
6100
6349
  });
6101
- invariant15(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
6102
- F: __dxlog_file20,
6103
- L: 179,
6350
+ invariant16(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
6351
+ F: __dxlog_file22,
6352
+ L: 183,
6104
6353
  S: this,
6105
6354
  A: [
6106
6355
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -6129,12 +6378,12 @@ import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvita
6129
6378
  import { Context as Context8 } from "@dxos/context";
6130
6379
  import { generatePasscode } from "@dxos/credentials";
6131
6380
  import { hasInvitationExpired } from "@dxos/echo-pipeline";
6132
- import { invariant as invariant16 } from "@dxos/invariant";
6381
+ import { invariant as invariant17 } from "@dxos/invariant";
6133
6382
  import { PublicKey as PublicKey12 } from "@dxos/keys";
6134
- import { log as log18 } from "@dxos/log";
6135
- import { Invitation as Invitation7 } from "@dxos/protocols/proto/dxos/client/services";
6383
+ import { log as log20 } from "@dxos/log";
6384
+ import { Invitation as Invitation9 } from "@dxos/protocols/proto/dxos/client/services";
6136
6385
  import { SpaceMember as SpaceMember7 } from "@dxos/protocols/proto/dxos/halo/credentials";
6137
- var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
6386
+ var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
6138
6387
  var InvitationsManager = class {
6139
6388
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
6140
6389
  this._invitationsHandler = _invitationsHandler;
@@ -6176,8 +6425,8 @@ var InvitationsManager = class {
6176
6425
  try {
6177
6426
  await this._persistIfRequired(handler, stream, invitation);
6178
6427
  } catch (err) {
6179
- log18.catch(err, void 0, {
6180
- F: __dxlog_file21,
6428
+ log20.catch(err, void 0, {
6429
+ F: __dxlog_file23,
6181
6430
  L: 82,
6182
6431
  S: this,
6183
6432
  C: (f, a) => f(...a)
@@ -6199,8 +6448,8 @@ var InvitationsManager = class {
6199
6448
  const persistentInvitations = this._metadataStore.getInvitations();
6200
6449
  const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
6201
6450
  const loadTasks = freshInvitations.map((persistentInvitation) => {
6202
- invariant16(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
6203
- F: __dxlog_file21,
6451
+ invariant17(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
6452
+ F: __dxlog_file23,
6204
6453
  L: 103,
6205
6454
  S: this,
6206
6455
  A: [
@@ -6218,8 +6467,8 @@ var InvitationsManager = class {
6218
6467
  invitations: cInvitations.map((invitation) => invitation.get())
6219
6468
  };
6220
6469
  } catch (err) {
6221
- log18.catch(err, void 0, {
6222
- F: __dxlog_file21,
6470
+ log20.catch(err, void 0, {
6471
+ F: __dxlog_file23,
6223
6472
  L: 110,
6224
6473
  S: this,
6225
6474
  C: (f, a) => f(...a)
@@ -6250,14 +6499,14 @@ var InvitationsManager = class {
6250
6499
  return invitation;
6251
6500
  }
6252
6501
  async authenticate({ invitationId, authCode }) {
6253
- log18("authenticating...", void 0, {
6254
- F: __dxlog_file21,
6502
+ log20("authenticating...", void 0, {
6503
+ F: __dxlog_file23,
6255
6504
  L: 140,
6256
6505
  S: this,
6257
6506
  C: (f, a) => f(...a)
6258
6507
  });
6259
- invariant16(invitationId, void 0, {
6260
- F: __dxlog_file21,
6508
+ invariant17(invitationId, void 0, {
6509
+ F: __dxlog_file23,
6261
6510
  L: 141,
6262
6511
  S: this,
6263
6512
  A: [
@@ -6267,10 +6516,10 @@ var InvitationsManager = class {
6267
6516
  });
6268
6517
  const observable = this._acceptInvitations.get(invitationId);
6269
6518
  if (!observable) {
6270
- log18.warn("invalid invitation", {
6519
+ log20.warn("invalid invitation", {
6271
6520
  invitationId
6272
6521
  }, {
6273
- F: __dxlog_file21,
6522
+ F: __dxlog_file23,
6274
6523
  L: 144,
6275
6524
  S: this,
6276
6525
  C: (f, a) => f(...a)
@@ -6280,16 +6529,16 @@ var InvitationsManager = class {
6280
6529
  }
6281
6530
  }
6282
6531
  async cancelInvitation({ invitationId }) {
6283
- log18("cancelInvitation...", {
6532
+ log20("cancelInvitation...", {
6284
6533
  invitationId
6285
6534
  }, {
6286
- F: __dxlog_file21,
6535
+ F: __dxlog_file23,
6287
6536
  L: 151,
6288
6537
  S: this,
6289
6538
  C: (f, a) => f(...a)
6290
6539
  });
6291
- invariant16(invitationId, void 0, {
6292
- F: __dxlog_file21,
6540
+ invariant17(invitationId, void 0, {
6541
+ F: __dxlog_file23,
6293
6542
  L: 152,
6294
6543
  S: this,
6295
6544
  A: [
@@ -6302,7 +6551,7 @@ var InvitationsManager = class {
6302
6551
  if (created.get().persistent) {
6303
6552
  await this._metadataStore.removeInvitation(invitationId);
6304
6553
  }
6305
- if (created.get().type === Invitation7.Type.DELEGATED) {
6554
+ if (created.get().type === Invitation9.Type.DELEGATED) {
6306
6555
  const handler = this._getHandler(created.get());
6307
6556
  await handler.cancelDelegation(created.get());
6308
6557
  }
@@ -6336,8 +6585,8 @@ var InvitationsManager = class {
6336
6585
  }
6337
6586
  }
6338
6587
  _createInvitation(protocol, options) {
6339
- const { invitationId = PublicKey12.random().toHex(), type = Invitation7.Type.INTERACTIVE, authMethod = Invitation7.AuthMethod.SHARED_SECRET, state = Invitation7.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey12.random(), persistent = options?.authMethod !== Invitation7.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = SpaceMember7.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
6340
- const authCode = options?.authCode ?? (authMethod === Invitation7.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
6588
+ const { invitationId = PublicKey12.random().toHex(), type = Invitation9.Type.INTERACTIVE, authMethod = Invitation9.AuthMethod.SHARED_SECRET, state = Invitation9.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey12.random(), persistent = options?.authMethod !== Invitation9.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = SpaceMember7.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
6589
+ const authCode = options?.authCode ?? (authMethod === Invitation9.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
6341
6590
  return {
6342
6591
  invitationId,
6343
6592
  type,
@@ -6346,8 +6595,8 @@ var InvitationsManager = class {
6346
6595
  swarmKey,
6347
6596
  authCode,
6348
6597
  timeout,
6349
- persistent: persistent && type !== Invitation7.Type.DELEGATED,
6350
- guestKeypair: guestKeypair ?? (authMethod === Invitation7.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
6598
+ persistent: persistent && type !== Invitation9.Type.DELEGATED,
6599
+ guestKeypair: guestKeypair ?? (authMethod === Invitation9.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
6351
6600
  created,
6352
6601
  lifetime,
6353
6602
  role,
@@ -6364,14 +6613,14 @@ var InvitationsManager = class {
6364
6613
  void ctx.dispose();
6365
6614
  }
6366
6615
  }, {
6367
- F: __dxlog_file21,
6616
+ F: __dxlog_file23,
6368
6617
  L: 234
6369
6618
  });
6370
6619
  ctx.onDispose(() => {
6371
- log18("complete", {
6620
+ log20("complete", {
6372
6621
  ...handler.toJSON()
6373
6622
  }, {
6374
- F: __dxlog_file21,
6623
+ F: __dxlog_file23,
6375
6624
  L: 241,
6376
6625
  S: this,
6377
6626
  C: (f, a) => f(...a)
@@ -6384,7 +6633,7 @@ var InvitationsManager = class {
6384
6633
  onCancel: async () => {
6385
6634
  stream.next({
6386
6635
  ...invitation,
6387
- state: Invitation7.State.CANCELLED
6636
+ state: Invitation9.State.CANCELLED
6388
6637
  });
6389
6638
  await ctx.dispose();
6390
6639
  }
@@ -6401,41 +6650,41 @@ var InvitationsManager = class {
6401
6650
  const ctx = new Context8({
6402
6651
  onError: (err) => {
6403
6652
  if (err instanceof TimeoutError3) {
6404
- log18("timeout", {
6653
+ log20("timeout", {
6405
6654
  ...handler.toJSON()
6406
6655
  }, {
6407
- F: __dxlog_file21,
6656
+ F: __dxlog_file23,
6408
6657
  L: 261,
6409
6658
  S: this,
6410
6659
  C: (f, a) => f(...a)
6411
6660
  });
6412
6661
  stream.next({
6413
6662
  ...initialState,
6414
- state: Invitation7.State.TIMEOUT
6663
+ state: Invitation9.State.TIMEOUT
6415
6664
  });
6416
6665
  } else {
6417
- log18.warn("auth failed", err, {
6418
- F: __dxlog_file21,
6666
+ log20.warn("auth failed", err, {
6667
+ F: __dxlog_file23,
6419
6668
  L: 264,
6420
6669
  S: this,
6421
6670
  C: (f, a) => f(...a)
6422
6671
  });
6423
6672
  stream.next({
6424
6673
  ...initialState,
6425
- state: Invitation7.State.ERROR
6674
+ state: Invitation9.State.ERROR
6426
6675
  });
6427
6676
  }
6428
6677
  void ctx.dispose();
6429
6678
  }
6430
6679
  }, {
6431
- F: __dxlog_file21,
6680
+ F: __dxlog_file23,
6432
6681
  L: 258
6433
6682
  });
6434
6683
  ctx.onDispose(() => {
6435
- log18("complete", {
6684
+ log20("complete", {
6436
6685
  ...handler.toJSON()
6437
6686
  }, {
6438
- F: __dxlog_file21,
6687
+ F: __dxlog_file23,
6439
6688
  L: 271,
6440
6689
  S: this,
6441
6690
  C: (f, a) => f(...a)
@@ -6448,7 +6697,7 @@ var InvitationsManager = class {
6448
6697
  onCancel: async () => {
6449
6698
  stream.next({
6450
6699
  ...initialState,
6451
- state: Invitation7.State.CANCELLED
6700
+ state: Invitation9.State.CANCELLED
6452
6701
  });
6453
6702
  await ctx.dispose();
6454
6703
  },
@@ -6464,7 +6713,7 @@ var InvitationsManager = class {
6464
6713
  };
6465
6714
  }
6466
6715
  async _persistIfRequired(handler, changeStream, invitation) {
6467
- if (invitation.type === Invitation7.Type.DELEGATED && invitation.delegationCredentialId == null) {
6716
+ if (invitation.type === Invitation9.Type.DELEGATED && invitation.delegationCredentialId == null) {
6468
6717
  const delegationCredentialId = await handler.delegate(invitation);
6469
6718
  changeStream.next({
6470
6719
  ...invitation,
@@ -6479,8 +6728,8 @@ var InvitationsManager = class {
6479
6728
  try {
6480
6729
  await this._metadataStore.removeInvitation(invitation.invitationId);
6481
6730
  } catch (err) {
6482
- log18.catch(err, void 0, {
6483
- F: __dxlog_file21,
6731
+ log20.catch(err, void 0, {
6732
+ F: __dxlog_file23,
6484
6733
  L: 307,
6485
6734
  S: this,
6486
6735
  C: (f, a) => f(...a)
@@ -6495,16 +6744,16 @@ var InvitationsManager = class {
6495
6744
  };
6496
6745
 
6497
6746
  // packages/sdk/client-services/src/packlets/locks/node.ts
6498
- import { invariant as invariant17 } from "@dxos/invariant";
6747
+ import { invariant as invariant18 } from "@dxos/invariant";
6499
6748
  import { LockFile } from "@dxos/lock-file";
6500
- import { log as log19, logInfo as logInfo3 } from "@dxos/log";
6749
+ import { log as log21, logInfo as logInfo3 } from "@dxos/log";
6501
6750
  function _ts_decorate7(decorators, target, key, desc) {
6502
6751
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6503
6752
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6504
6753
  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;
6505
6754
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6506
6755
  }
6507
- var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
6756
+ var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
6508
6757
  var Lock = class {
6509
6758
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
6510
6759
  this._lockPath = lockPath;
@@ -6515,16 +6764,16 @@ var Lock = class {
6515
6764
  return this._lockPath;
6516
6765
  }
6517
6766
  async acquire() {
6518
- log19("acquiring lock...", void 0, {
6519
- F: __dxlog_file22,
6767
+ log21("acquiring lock...", void 0, {
6768
+ F: __dxlog_file24,
6520
6769
  L: 32,
6521
6770
  S: this,
6522
6771
  C: (f, a) => f(...a)
6523
6772
  });
6524
6773
  this._fileHandle = await LockFile.acquire(this._lockPath);
6525
6774
  await this._onAcquire?.();
6526
- log19("acquired lock", void 0, {
6527
- F: __dxlog_file22,
6775
+ log21("acquired lock", void 0, {
6776
+ F: __dxlog_file24,
6528
6777
  L: 37,
6529
6778
  S: this,
6530
6779
  C: (f, a) => f(...a)
@@ -6532,8 +6781,8 @@ var Lock = class {
6532
6781
  }
6533
6782
  async release() {
6534
6783
  await this._onRelease?.();
6535
- invariant17(this._fileHandle, "Lock is not acquired", {
6536
- F: __dxlog_file22,
6784
+ invariant18(this._fileHandle, "Lock is not acquired", {
6785
+ F: __dxlog_file24,
6537
6786
  L: 42,
6538
6787
  S: this,
6539
6788
  A: [
@@ -6627,19 +6876,19 @@ ClientRpcServer = _ts_decorate8([
6627
6876
  ], ClientRpcServer);
6628
6877
 
6629
6878
  // packages/sdk/client-services/src/packlets/services/service-context.ts
6630
- import { Mutex as Mutex4, scheduleMicroTask as scheduleMicroTask3, Trigger as Trigger7 } from "@dxos/async";
6879
+ import { Mutex as Mutex4, scheduleMicroTask as scheduleMicroTask4, Trigger as Trigger7 } from "@dxos/async";
6631
6880
  import { Context as Context9, Resource as Resource6 } from "@dxos/context";
6632
6881
  import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
6633
6882
  import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
6634
6883
  import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
6635
6884
  import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from "@dxos/edge-client";
6636
6885
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
6637
- import { invariant as invariant18 } from "@dxos/invariant";
6886
+ import { invariant as invariant19 } from "@dxos/invariant";
6638
6887
  import { Keyring } from "@dxos/keyring";
6639
6888
  import { PublicKey as PublicKey13 } from "@dxos/keys";
6640
- import { log as log20 } from "@dxos/log";
6889
+ import { log as log22 } from "@dxos/log";
6641
6890
  import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
6642
- import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
6891
+ import { Invitation as Invitation10 } from "@dxos/protocols/proto/dxos/client/services";
6643
6892
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
6644
6893
  import { trace as Trace3 } from "@dxos/tracing";
6645
6894
  import { safeInstanceof } from "@dxos/util";
@@ -6711,7 +6960,7 @@ function _using_ctx3() {
6711
6960
  }
6712
6961
  };
6713
6962
  }
6714
- var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
6963
+ var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
6715
6964
  var ServiceContext = class extends Resource6 {
6716
6965
  constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
6717
6966
  super();
@@ -6761,16 +7010,16 @@ var ServiceContext = class extends Resource6 {
6761
7010
  callbacks: {
6762
7011
  onIdentityConstruction: (identity) => {
6763
7012
  if (this._edgeConnection) {
6764
- scheduleMicroTask3(this._ctx, async () => {
7013
+ scheduleMicroTask4(this._ctx, async () => {
6765
7014
  try {
6766
7015
  var _usingCtx = _using_ctx3();
6767
7016
  const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
6768
- log20.info("Setting identity on edge connection", {
7017
+ log22.info("Setting identity on edge connection", {
6769
7018
  identity: identity.identityKey.toHex(),
6770
7019
  oldIdentity: this._edgeConnection.identityKey,
6771
7020
  swarms: this.networkManager.topics
6772
7021
  }, {
6773
- F: __dxlog_file23,
7022
+ F: __dxlog_file25,
6774
7023
  L: 147,
6775
7024
  S: this,
6776
7025
  C: (f, a) => f(...a)
@@ -6778,8 +7027,8 @@ var ServiceContext = class extends Resource6 {
6778
7027
  await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
6779
7028
  await identity.ready();
6780
7029
  });
6781
- invariant18(identity.deviceCredentialChain, void 0, {
6782
- F: __dxlog_file23,
7030
+ invariant19(identity.deviceCredentialChain, void 0, {
7031
+ F: __dxlog_file25,
6783
7032
  L: 157,
6784
7033
  S: this,
6785
7034
  A: [
@@ -6806,9 +7055,9 @@ var ServiceContext = class extends Resource6 {
6806
7055
  kv: this.level
6807
7056
  });
6808
7057
  this._meshReplicator = new MeshEchoReplicator();
6809
- this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
7058
+ this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
6810
7059
  this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
6811
- this._handlerFactories.set(Invitation8.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
7060
+ this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
6812
7061
  if (!this._runtimeParams?.disableP2pReplication) {
6813
7062
  this._meshReplicator = new MeshEchoReplicator();
6814
7063
  }
@@ -6820,17 +7069,17 @@ var ServiceContext = class extends Resource6 {
6820
7069
  }
6821
7070
  async _open(ctx) {
6822
7071
  await this._checkStorageVersion();
6823
- log20("opening...", void 0, {
6824
- F: __dxlog_file23,
6825
- L: 217,
7072
+ log22("opening...", void 0, {
7073
+ F: __dxlog_file25,
7074
+ L: 218,
6826
7075
  S: this,
6827
7076
  C: (f, a) => f(...a)
6828
7077
  });
6829
- log20.trace("dxos.sdk.service-context.open", trace9.begin({
7078
+ log22.trace("dxos.sdk.service-context.open", trace9.begin({
6830
7079
  id: this._instanceId
6831
7080
  }), {
6832
- F: __dxlog_file23,
6833
- L: 218,
7081
+ F: __dxlog_file25,
7082
+ L: 219,
6834
7083
  S: this,
6835
7084
  C: (f, a) => f(...a)
6836
7085
  });
@@ -6854,33 +7103,33 @@ var ServiceContext = class extends Resource6 {
6854
7103
  await this._initialize(ctx);
6855
7104
  }
6856
7105
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
6857
- log20("loaded persistent invitations", {
7106
+ log22("loaded persistent invitations", {
6858
7107
  count: loadedInvitations.invitations?.length
6859
7108
  }, {
6860
- F: __dxlog_file23,
6861
- L: 245,
7109
+ F: __dxlog_file25,
7110
+ L: 246,
6862
7111
  S: this,
6863
7112
  C: (f, a) => f(...a)
6864
7113
  });
6865
- log20.trace("dxos.sdk.service-context.open", trace9.end({
7114
+ log22.trace("dxos.sdk.service-context.open", trace9.end({
6866
7115
  id: this._instanceId
6867
7116
  }), {
6868
- F: __dxlog_file23,
6869
- L: 247,
7117
+ F: __dxlog_file25,
7118
+ L: 248,
6870
7119
  S: this,
6871
7120
  C: (f, a) => f(...a)
6872
7121
  });
6873
- log20("opened", void 0, {
6874
- F: __dxlog_file23,
6875
- L: 248,
7122
+ log22("opened", void 0, {
7123
+ F: __dxlog_file25,
7124
+ L: 249,
6876
7125
  S: this,
6877
7126
  C: (f, a) => f(...a)
6878
7127
  });
6879
7128
  }
6880
7129
  async _close(ctx) {
6881
- log20("closing...", void 0, {
6882
- F: __dxlog_file23,
6883
- L: 252,
7130
+ log22("closing...", void 0, {
7131
+ F: __dxlog_file25,
7132
+ L: 253,
6884
7133
  S: this,
6885
7134
  C: (f, a) => f(...a)
6886
7135
  });
@@ -6896,9 +7145,9 @@ var ServiceContext = class extends Resource6 {
6896
7145
  await this.networkManager.close();
6897
7146
  await this.signalManager.close();
6898
7147
  await this._edgeConnection?.close();
6899
- log20("closed", void 0, {
6900
- F: __dxlog_file23,
6901
- L: 267,
7148
+ log22("closed", void 0, {
7149
+ F: __dxlog_file25,
7150
+ L: 268,
6902
7151
  S: this,
6903
7152
  C: (f, a) => f(...a)
6904
7153
  });
@@ -6906,16 +7155,16 @@ var ServiceContext = class extends Resource6 {
6906
7155
  async createIdentity(params = {}) {
6907
7156
  const identity = await this.identityManager.createIdentity(params);
6908
7157
  await this._initialize(new Context9(void 0, {
6909
- F: __dxlog_file23,
6910
- L: 272
7158
+ F: __dxlog_file25,
7159
+ L: 273
6911
7160
  }));
6912
7161
  return identity;
6913
7162
  }
6914
7163
  getInvitationHandler(invitation) {
6915
7164
  const factory = this._handlerFactories.get(invitation.kind);
6916
- invariant18(factory, `Unknown invitation kind: ${invitation.kind}`, {
6917
- F: __dxlog_file23,
6918
- L: 278,
7165
+ invariant19(factory, `Unknown invitation kind: ${invitation.kind}`, {
7166
+ F: __dxlog_file25,
7167
+ L: 279,
6919
7168
  S: this,
6920
7169
  A: [
6921
7170
  "factory",
@@ -6935,8 +7184,8 @@ var ServiceContext = class extends Resource6 {
6935
7184
  async _acceptIdentity(params) {
6936
7185
  const identity = await this.identityManager.acceptIdentity(params);
6937
7186
  await this._initialize(new Context9(void 0, {
6938
- F: __dxlog_file23,
6939
- L: 294
7187
+ F: __dxlog_file25,
7188
+ L: 295
6940
7189
  }));
6941
7190
  return identity;
6942
7191
  }
@@ -6948,9 +7197,9 @@ var ServiceContext = class extends Resource6 {
6948
7197
  }
6949
7198
  // Called when identity is created.
6950
7199
  async _initialize(ctx) {
6951
- log20("initializing spaces...", void 0, {
6952
- F: __dxlog_file23,
6953
- L: 309,
7200
+ log22("initializing spaces...", void 0, {
7201
+ F: __dxlog_file25,
7202
+ L: 310,
6954
7203
  S: this,
6955
7204
  C: (f, a) => f(...a)
6956
7205
  });
@@ -6984,10 +7233,10 @@ var ServiceContext = class extends Resource6 {
6984
7233
  edgeFeatures: this._edgeFeatures
6985
7234
  });
6986
7235
  await this.dataSpaceManager.open();
6987
- this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
6988
- invariant18(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
6989
- F: __dxlog_file23,
6990
- L: 339,
7236
+ this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
7237
+ invariant19(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7238
+ F: __dxlog_file25,
7239
+ L: 340,
6991
7240
  S: this,
6992
7241
  A: [
6993
7242
  "this.dataSpaceManager",
@@ -7007,33 +7256,33 @@ var ServiceContext = class extends Resource6 {
7007
7256
  return;
7008
7257
  }
7009
7258
  if (!this.dataSpaceManager) {
7010
- log20("dataSpaceManager not initialized yet, ignoring space admission", {
7259
+ log22("dataSpaceManager not initialized yet, ignoring space admission", {
7011
7260
  details: assertion
7012
7261
  }, {
7013
- F: __dxlog_file23,
7014
- L: 355,
7262
+ F: __dxlog_file25,
7263
+ L: 356,
7015
7264
  S: this,
7016
7265
  C: (f, a) => f(...a)
7017
7266
  });
7018
7267
  return;
7019
7268
  }
7020
7269
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
7021
- log20("space already exists, ignoring space admission", {
7270
+ log22("space already exists, ignoring space admission", {
7022
7271
  details: assertion
7023
7272
  }, {
7024
- F: __dxlog_file23,
7025
- L: 359,
7273
+ F: __dxlog_file25,
7274
+ L: 360,
7026
7275
  S: this,
7027
7276
  C: (f, a) => f(...a)
7028
7277
  });
7029
7278
  return;
7030
7279
  }
7031
7280
  try {
7032
- log20("accepting space recorded in halo", {
7281
+ log22("accepting space recorded in halo", {
7033
7282
  details: assertion
7034
7283
  }, {
7035
- F: __dxlog_file23,
7036
- L: 364,
7284
+ F: __dxlog_file25,
7285
+ L: 365,
7037
7286
  S: this,
7038
7287
  C: (f, a) => f(...a)
7039
7288
  });
@@ -7042,9 +7291,9 @@ var ServiceContext = class extends Resource6 {
7042
7291
  genesisFeedKey: assertion.genesisFeedKey
7043
7292
  });
7044
7293
  } catch (err) {
7045
- log20.catch(err, void 0, {
7046
- F: __dxlog_file23,
7047
- L: 370,
7294
+ log22.catch(err, void 0, {
7295
+ F: __dxlog_file25,
7296
+ L: 371,
7048
7297
  S: this,
7049
7298
  C: (f, a) => f(...a)
7050
7299
  });
@@ -7165,11 +7414,11 @@ var createLevel = async (config) => {
7165
7414
 
7166
7415
  // packages/sdk/client-services/src/packlets/storage/profile-archive.ts
7167
7416
  import { cbor } from "@dxos/automerge/automerge-repo";
7168
- import { invariant as invariant19 } from "@dxos/invariant";
7169
- import { log as log21 } from "@dxos/log";
7417
+ import { invariant as invariant20 } from "@dxos/invariant";
7418
+ import { log as log23 } from "@dxos/log";
7170
7419
  import { ProfileArchiveEntryType } from "@dxos/protocols";
7171
7420
  import { arrayToBuffer as arrayToBuffer2 } from "@dxos/util";
7172
- var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
7421
+ var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
7173
7422
  var encodeProfileArchive = (profile) => cbor.encode(profile);
7174
7423
  var decodeProfileArchive = (data) => cbor.decode(data);
7175
7424
  var exportProfileData = async ({ storage, level }) => {
@@ -7182,10 +7431,10 @@ var exportProfileData = async ({ storage, level }) => {
7182
7431
  {
7183
7432
  const directory = await storage.createDirectory();
7184
7433
  const files = await directory.list();
7185
- log21.info("begin exporting files", {
7434
+ log23.info("begin exporting files", {
7186
7435
  count: files.length
7187
7436
  }, {
7188
- F: __dxlog_file24,
7437
+ F: __dxlog_file26,
7189
7438
  L: 30,
7190
7439
  S: void 0,
7191
7440
  C: (f, a) => f(...a)
@@ -7200,18 +7449,18 @@ var exportProfileData = async ({ storage, level }) => {
7200
7449
  value: data
7201
7450
  });
7202
7451
  }
7203
- log21.info("done exporting files", {
7452
+ log23.info("done exporting files", {
7204
7453
  count: files.length
7205
7454
  }, {
7206
- F: __dxlog_file24,
7455
+ F: __dxlog_file26,
7207
7456
  L: 41,
7208
7457
  S: void 0,
7209
7458
  C: (f, a) => f(...a)
7210
7459
  });
7211
7460
  }
7212
7461
  {
7213
- log21.info("begin exporting kv pairs", void 0, {
7214
- F: __dxlog_file24,
7462
+ log23.info("begin exporting kv pairs", void 0, {
7463
+ F: __dxlog_file26,
7215
7464
  L: 45,
7216
7465
  S: void 0,
7217
7466
  C: (f, a) => f(...a)
@@ -7229,10 +7478,10 @@ var exportProfileData = async ({ storage, level }) => {
7229
7478
  });
7230
7479
  count++;
7231
7480
  }
7232
- log21.info("done exporting kv pairs", {
7481
+ log23.info("done exporting kv pairs", {
7233
7482
  count
7234
7483
  }, {
7235
- F: __dxlog_file24,
7484
+ F: __dxlog_file26,
7236
7485
  L: 56,
7237
7486
  S: void 0,
7238
7487
  C: (f, a) => f(...a)
@@ -7247,8 +7496,8 @@ var importProfileData = async ({ storage, level }, archive) => {
7247
7496
  switch (entry2.type) {
7248
7497
  case ProfileArchiveEntryType.FILE: {
7249
7498
  const directory = await storage.createDirectory();
7250
- invariant19(typeof entry2.key === "string", "Invalid key type", {
7251
- F: __dxlog_file24,
7499
+ invariant20(typeof entry2.key === "string", "Invalid key type", {
7500
+ F: __dxlog_file26,
7252
7501
  L: 79,
7253
7502
  S: void 0,
7254
7503
  A: [
@@ -7257,8 +7506,8 @@ var importProfileData = async ({ storage, level }, archive) => {
7257
7506
  ]
7258
7507
  });
7259
7508
  const file = await directory.getOrCreateFile(entry2.key);
7260
- invariant19(entry2.value instanceof Uint8Array, "Invalid value type", {
7261
- F: __dxlog_file24,
7509
+ invariant20(entry2.value instanceof Uint8Array, "Invalid value type", {
7510
+ F: __dxlog_file26,
7262
7511
  L: 81,
7263
7512
  S: void 0,
7264
7513
  A: [
@@ -7271,8 +7520,8 @@ var importProfileData = async ({ storage, level }, archive) => {
7271
7520
  break;
7272
7521
  }
7273
7522
  case ProfileArchiveEntryType.KEY_VALUE: {
7274
- invariant19(entry2.key instanceof Uint8Array, "Invalid key type", {
7275
- F: __dxlog_file24,
7523
+ invariant20(entry2.key instanceof Uint8Array, "Invalid key type", {
7524
+ F: __dxlog_file26,
7276
7525
  L: 87,
7277
7526
  S: void 0,
7278
7527
  A: [
@@ -7280,8 +7529,8 @@ var importProfileData = async ({ storage, level }, archive) => {
7280
7529
  "'Invalid key type'"
7281
7530
  ]
7282
7531
  });
7283
- invariant19(entry2.value instanceof Uint8Array, "Invalid value type", {
7284
- F: __dxlog_file24,
7532
+ invariant20(entry2.value instanceof Uint8Array, "Invalid value type", {
7533
+ F: __dxlog_file26,
7285
7534
  L: 88,
7286
7535
  S: void 0,
7287
7536
  A: [
@@ -7301,20 +7550,20 @@ var importProfileData = async ({ storage, level }, archive) => {
7301
7550
  if (++count % 1e3 === 0) {
7302
7551
  await batch.write();
7303
7552
  batch = level.batch();
7304
- log21.info("importing", {
7553
+ log23.info("importing", {
7305
7554
  count,
7306
7555
  total: archive.storage.length,
7307
7556
  progress: `${(count / archive.storage.length * 100).toFixed()}%`
7308
7557
  }, {
7309
- F: __dxlog_file24,
7558
+ F: __dxlog_file26,
7310
7559
  L: 101,
7311
7560
  S: void 0,
7312
7561
  C: (f, a) => f(...a)
7313
7562
  });
7314
7563
  }
7315
7564
  }
7316
- log21.info("committing changes..", void 0, {
7317
- F: __dxlog_file24,
7565
+ log23.info("committing changes..", void 0, {
7566
+ F: __dxlog_file26,
7318
7567
  L: 109,
7319
7568
  S: void 0,
7320
7569
  C: (f, a) => f(...a)
@@ -7327,9 +7576,9 @@ import { Event as Event10, synchronized as synchronized3 } from "@dxos/async";
7327
7576
  import { clientServiceBundle } from "@dxos/client-protocol";
7328
7577
  import { Context as Context10 } from "@dxos/context";
7329
7578
  import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity } from "@dxos/edge-client";
7330
- import { invariant as invariant21 } from "@dxos/invariant";
7579
+ import { invariant as invariant22 } from "@dxos/invariant";
7331
7580
  import { PublicKey as PublicKey17 } from "@dxos/keys";
7332
- import { log as log23 } from "@dxos/log";
7581
+ import { log as log25 } from "@dxos/log";
7333
7582
  import { EdgeSignalManager, WebsocketSignalManager } from "@dxos/messaging";
7334
7583
  import { SwarmNetworkManager, createIceProvider, createRtcTransportFactory } from "@dxos/network-manager";
7335
7584
  import { trace as trace10 } from "@dxos/protocols";
@@ -7340,9 +7589,9 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
7340
7589
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
7341
7590
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
7342
7591
  import { Stream as Stream11 } from "@dxos/codec-protobuf";
7343
- import { invariant as invariant20 } from "@dxos/invariant";
7592
+ import { invariant as invariant21 } from "@dxos/invariant";
7344
7593
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
7345
- var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
7594
+ var __dxlog_file27 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
7346
7595
  var DevicesServiceImpl = class {
7347
7596
  constructor(_identityManager) {
7348
7597
  this._identityManager = _identityManager;
@@ -7359,8 +7608,8 @@ var DevicesServiceImpl = class {
7359
7608
  devices: []
7360
7609
  });
7361
7610
  } else {
7362
- invariant20(this._identityManager.identity?.presence, "presence not present", {
7363
- F: __dxlog_file25,
7611
+ invariant21(this._identityManager.identity?.presence, "presence not present", {
7612
+ F: __dxlog_file27,
7364
7613
  L: 32,
7365
7614
  S: this,
7366
7615
  A: [
@@ -7420,7 +7669,7 @@ var DevicesServiceImpl = class {
7420
7669
  };
7421
7670
 
7422
7671
  // packages/sdk/client-services/src/packlets/identity/contacts-service.ts
7423
- import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask7, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
7672
+ import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask8, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
7424
7673
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
7425
7674
  import { PublicKey as PublicKey15 } from "@dxos/keys";
7426
7675
  import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
@@ -7479,7 +7728,7 @@ var ContactsServiceImpl = class {
7479
7728
  }, {
7480
7729
  maxFrequency: 2
7481
7730
  });
7482
- scheduleTask7(ctx, async () => {
7731
+ scheduleTask8(ctx, async () => {
7483
7732
  const subscriptions = new EventSubscriptions4();
7484
7733
  ctx.onDispose(() => subscriptions.clear());
7485
7734
  const subscribeToSpaceAndUpdate = () => {
@@ -7506,7 +7755,7 @@ var ContactsServiceImpl = class {
7506
7755
  import { Event as Event9 } from "@dxos/async";
7507
7756
  import { Stream as Stream13 } from "@dxos/codec-protobuf";
7508
7757
  import { PublicKey as PublicKey16 } from "@dxos/keys";
7509
- import { getContextFromEntry, log as log22 } from "@dxos/log";
7758
+ import { getContextFromEntry, log as log24 } from "@dxos/log";
7510
7759
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
7511
7760
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
7512
7761
  var LoggingServiceImpl = class {
@@ -7519,11 +7768,11 @@ var LoggingServiceImpl = class {
7519
7768
  };
7520
7769
  }
7521
7770
  async open() {
7522
- log22.runtimeConfig.processors.push(this._logProcessor);
7771
+ log24.runtimeConfig.processors.push(this._logProcessor);
7523
7772
  }
7524
7773
  async close() {
7525
- const index = log22.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
7526
- log22.runtimeConfig.processors.splice(index, 1);
7774
+ const index = log24.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
7775
+ log24.runtimeConfig.processors.splice(index, 1);
7527
7776
  }
7528
7777
  async controlMetrics({ reset, record }) {
7529
7778
  if (reset) {
@@ -7723,7 +7972,7 @@ function _ts_decorate10(decorators, target, key, desc) {
7723
7972
  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;
7724
7973
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7725
7974
  }
7726
- var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
7975
+ var __dxlog_file28 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
7727
7976
  var ClientServicesHost = class {
7728
7977
  constructor({
7729
7978
  config,
@@ -7762,7 +8011,7 @@ var ClientServicesHost = class {
7762
8011
  onAcquire: () => {
7763
8012
  if (!this._opening) {
7764
8013
  void this.open(new Context10(void 0, {
7765
- F: __dxlog_file26,
8014
+ F: __dxlog_file28,
7766
8015
  L: 133
7767
8016
  }));
7768
8017
  }
@@ -7819,8 +8068,8 @@ var ClientServicesHost = class {
7819
8068
  * Can only be called once.
7820
8069
  */
7821
8070
  initialize({ config, ...options }) {
7822
- invariant21(!this._open, "service host is open", {
7823
- F: __dxlog_file26,
8071
+ invariant22(!this._open, "service host is open", {
8072
+ F: __dxlog_file28,
7824
8073
  L: 199,
7825
8074
  S: this,
7826
8075
  A: [
@@ -7828,15 +8077,15 @@ var ClientServicesHost = class {
7828
8077
  "'service host is open'"
7829
8078
  ]
7830
8079
  });
7831
- log23("initializing...", void 0, {
7832
- F: __dxlog_file26,
8080
+ log25("initializing...", void 0, {
8081
+ F: __dxlog_file28,
7833
8082
  L: 200,
7834
8083
  S: this,
7835
8084
  C: (f, a) => f(...a)
7836
8085
  });
7837
8086
  if (config) {
7838
- invariant21(!this._config, "config already set", {
7839
- F: __dxlog_file26,
8087
+ invariant22(!this._config, "config already set", {
8088
+ F: __dxlog_file28,
7840
8089
  L: 203,
7841
8090
  S: this,
7842
8091
  A: [
@@ -7850,8 +8099,8 @@ var ClientServicesHost = class {
7850
8099
  }
7851
8100
  }
7852
8101
  if (!options.signalManager) {
7853
- log23.warn("running signaling without telemetry metadata.", void 0, {
7854
- F: __dxlog_file26,
8102
+ log25.warn("running signaling without telemetry metadata.", void 0, {
8103
+ F: __dxlog_file28,
7855
8104
  L: 211,
7856
8105
  S: this,
7857
8106
  C: (f, a) => f(...a)
@@ -7870,8 +8119,8 @@ var ClientServicesHost = class {
7870
8119
  edgeConnection: this._edgeConnection
7871
8120
  }) : new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
7872
8121
  this._signalManager = signalManager;
7873
- invariant21(!this._networkManager, "network manager already set", {
7874
- F: __dxlog_file26,
8122
+ invariant22(!this._networkManager, "network manager already set", {
8123
+ F: __dxlog_file28,
7875
8124
  L: 233,
7876
8125
  S: this,
7877
8126
  A: [
@@ -7888,8 +8137,8 @@ var ClientServicesHost = class {
7888
8137
  peerKey: this._edgeConnection.peerKey
7889
8138
  } : void 0
7890
8139
  });
7891
- log23("initialized", void 0, {
7892
- F: __dxlog_file26,
8140
+ log25("initialized", void 0, {
8141
+ F: __dxlog_file28,
7893
8142
  L: 246,
7894
8143
  S: this,
7895
8144
  C: (f, a) => f(...a)
@@ -7900,16 +8149,16 @@ var ClientServicesHost = class {
7900
8149
  return;
7901
8150
  }
7902
8151
  const traceId = PublicKey17.random().toHex();
7903
- log23.trace("dxos.client-services.host.open", trace10.begin({
8152
+ log25.trace("dxos.client-services.host.open", trace10.begin({
7904
8153
  id: traceId
7905
8154
  }), {
7906
- F: __dxlog_file26,
8155
+ F: __dxlog_file28,
7907
8156
  L: 257,
7908
8157
  S: this,
7909
8158
  C: (f, a) => f(...a)
7910
8159
  });
7911
- invariant21(this._config, "config not set", {
7912
- F: __dxlog_file26,
8160
+ invariant22(this._config, "config not set", {
8161
+ F: __dxlog_file28,
7913
8162
  L: 259,
7914
8163
  S: this,
7915
8164
  A: [
@@ -7917,8 +8166,8 @@ var ClientServicesHost = class {
7917
8166
  "'config not set'"
7918
8167
  ]
7919
8168
  });
7920
- invariant21(this._storage, "storage not set", {
7921
- F: __dxlog_file26,
8169
+ invariant22(this._storage, "storage not set", {
8170
+ F: __dxlog_file28,
7922
8171
  L: 260,
7923
8172
  S: this,
7924
8173
  A: [
@@ -7926,8 +8175,8 @@ var ClientServicesHost = class {
7926
8175
  "'storage not set'"
7927
8176
  ]
7928
8177
  });
7929
- invariant21(this._signalManager, "signal manager not set", {
7930
- F: __dxlog_file26,
8178
+ invariant22(this._signalManager, "signal manager not set", {
8179
+ F: __dxlog_file28,
7931
8180
  L: 261,
7932
8181
  S: this,
7933
8182
  A: [
@@ -7935,8 +8184,8 @@ var ClientServicesHost = class {
7935
8184
  "'signal manager not set'"
7936
8185
  ]
7937
8186
  });
7938
- invariant21(this._networkManager, "network manager not set", {
7939
- F: __dxlog_file26,
8187
+ invariant22(this._networkManager, "network manager not set", {
8188
+ F: __dxlog_file28,
7940
8189
  L: 262,
7941
8190
  S: this,
7942
8191
  A: [
@@ -7945,10 +8194,10 @@ var ClientServicesHost = class {
7945
8194
  ]
7946
8195
  });
7947
8196
  this._opening = true;
7948
- log23("opening...", {
8197
+ log25("opening...", {
7949
8198
  lockKey: this._resourceLock?.lockKey
7950
8199
  }, {
7951
- F: __dxlog_file26,
8200
+ F: __dxlog_file28,
7952
8201
  L: 265,
7953
8202
  S: this,
7954
8203
  C: (f, a) => f(...a)
@@ -8001,18 +8250,18 @@ var ClientServicesHost = class {
8001
8250
  this._open = true;
8002
8251
  this._statusUpdate.emit();
8003
8252
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
8004
- log23("opened", {
8253
+ log25("opened", {
8005
8254
  deviceKey
8006
8255
  }, {
8007
- F: __dxlog_file26,
8256
+ F: __dxlog_file28,
8008
8257
  L: 354,
8009
8258
  S: this,
8010
8259
  C: (f, a) => f(...a)
8011
8260
  });
8012
- log23.trace("dxos.client-services.host.open", trace10.end({
8261
+ log25.trace("dxos.client-services.host.open", trace10.end({
8013
8262
  id: traceId
8014
8263
  }), {
8015
- F: __dxlog_file26,
8264
+ F: __dxlog_file28,
8016
8265
  L: 355,
8017
8266
  S: this,
8018
8267
  C: (f, a) => f(...a)
@@ -8023,10 +8272,10 @@ var ClientServicesHost = class {
8023
8272
  return;
8024
8273
  }
8025
8274
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
8026
- log23("closing...", {
8275
+ log25("closing...", {
8027
8276
  deviceKey
8028
8277
  }, {
8029
- F: __dxlog_file26,
8278
+ F: __dxlog_file28,
8030
8279
  L: 366,
8031
8280
  S: this,
8032
8281
  C: (f, a) => f(...a)
@@ -8041,10 +8290,10 @@ var ClientServicesHost = class {
8041
8290
  await this._level?.close();
8042
8291
  this._open = false;
8043
8292
  this._statusUpdate.emit();
8044
- log23("closed", {
8293
+ log25("closed", {
8045
8294
  deviceKey
8046
8295
  }, {
8047
- F: __dxlog_file26,
8296
+ F: __dxlog_file28,
8048
8297
  L: 375,
8049
8298
  S: this,
8050
8299
  C: (f, a) => f(...a)
@@ -8052,32 +8301,32 @@ var ClientServicesHost = class {
8052
8301
  }
8053
8302
  async reset() {
8054
8303
  const traceId = PublicKey17.random().toHex();
8055
- log23.trace("dxos.sdk.client-services-host.reset", trace10.begin({
8304
+ log25.trace("dxos.sdk.client-services-host.reset", trace10.begin({
8056
8305
  id: traceId
8057
8306
  }), {
8058
- F: __dxlog_file26,
8307
+ F: __dxlog_file28,
8059
8308
  L: 380,
8060
8309
  S: this,
8061
8310
  C: (f, a) => f(...a)
8062
8311
  });
8063
- log23.info("resetting...", void 0, {
8064
- F: __dxlog_file26,
8312
+ log25.info("resetting...", void 0, {
8313
+ F: __dxlog_file28,
8065
8314
  L: 382,
8066
8315
  S: this,
8067
8316
  C: (f, a) => f(...a)
8068
8317
  });
8069
8318
  await this._serviceContext?.close();
8070
8319
  await this._storage.reset();
8071
- log23.info("reset", void 0, {
8072
- F: __dxlog_file26,
8320
+ log25.info("reset", void 0, {
8321
+ F: __dxlog_file28,
8073
8322
  L: 385,
8074
8323
  S: this,
8075
8324
  C: (f, a) => f(...a)
8076
8325
  });
8077
- log23.trace("dxos.sdk.client-services-host.reset", trace10.end({
8326
+ log25.trace("dxos.sdk.client-services-host.reset", trace10.end({
8078
8327
  id: traceId
8079
8328
  }), {
8080
- F: __dxlog_file26,
8329
+ F: __dxlog_file28,
8081
8330
  L: 386,
8082
8331
  S: this,
8083
8332
  C: (f, a) => f(...a)
@@ -8151,4 +8400,4 @@ export {
8151
8400
  importProfileData,
8152
8401
  ClientServicesHost
8153
8402
  };
8154
- //# sourceMappingURL=chunk-36ZRRDQI.mjs.map
8403
+ //# sourceMappingURL=chunk-AIBLDI4U.mjs.map