@dxos/client-services 0.6.14-staging.54a8bab → 0.6.14-staging.8758a12

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 (36) hide show
  1. package/dist/lib/browser/{chunk-GFOAZHIO.mjs → chunk-5GW6342T.mjs} +118 -102
  2. package/dist/lib/browser/{chunk-GFOAZHIO.mjs.map → chunk-5GW6342T.mjs.map} +3 -3
  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 +9 -2
  6. package/dist/lib/browser/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-MDM5R5PA.cjs → chunk-4B7346FH.cjs} +126 -110
  8. package/dist/lib/node/chunk-4B7346FH.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +47 -47
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/testing/index.cjs +16 -9
  12. package/dist/lib/node/testing/index.cjs.map +3 -3
  13. package/dist/lib/node-esm/{chunk-CH4BRI7M.mjs → chunk-VXDTX5EP.mjs} +118 -102
  14. package/dist/lib/node-esm/{chunk-CH4BRI7M.mjs.map → chunk-VXDTX5EP.mjs.map} +3 -3
  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 +9 -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 +1 -0
  20. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
  21. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  22. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  23. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  24. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  25. package/dist/types/src/version.d.ts +1 -1
  26. package/package.json +38 -38
  27. package/src/packlets/invitations/edge-invitation-handler.ts +6 -3
  28. package/src/packlets/invitations/invitation-guest-extenstion.ts +5 -5
  29. package/src/packlets/invitations/invitation-host-extension.ts +7 -10
  30. package/src/packlets/invitations/invitations-handler.test.ts +3 -6
  31. package/src/packlets/invitations/invitations-handler.ts +34 -28
  32. package/src/packlets/invitations/invitations-service.ts +5 -1
  33. package/src/packlets/services/service-context.ts +2 -2
  34. package/src/packlets/testing/invitation-utils.ts +7 -0
  35. package/src/version.ts +1 -1
  36. package/dist/lib/node/chunk-MDM5R5PA.cjs.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.14-staging.54a8bab";
400
+ var DXOS_VERSION = "0.6.14-staging.8758a12";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -4839,6 +4839,7 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
4839
4839
 
4840
4840
  // packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts
4841
4841
  var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
4842
+ var MAX_RETRIES_PER_INVITATION = 5;
4842
4843
  var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
4843
4844
  var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
4844
4845
  var EdgeInvitationHandler = class {
@@ -4852,7 +4853,7 @@ var EdgeInvitationHandler = class {
4852
4853
  if (!this._client) {
4853
4854
  log14("edge disabled", void 0, {
4854
4855
  F: __dxlog_file17,
4855
- L: 65,
4856
+ L: 66,
4856
4857
  S: this,
4857
4858
  C: (f, a) => f(...a)
4858
4859
  });
@@ -4866,7 +4867,7 @@ var EdgeInvitationHandler = class {
4866
4867
  invitation
4867
4868
  }, {
4868
4869
  F: __dxlog_file17,
4869
- L: 79,
4870
+ L: 80,
4870
4871
  S: this,
4871
4872
  C: (f, a) => f(...a)
4872
4873
  });
@@ -4876,7 +4877,9 @@ var EdgeInvitationHandler = class {
4876
4877
  this._flowLock?.release();
4877
4878
  this._flowLock = void 0;
4878
4879
  });
4880
+ let requestCount = 0;
4879
4881
  const tryHandleInvitation = async () => {
4882
+ requestCount++;
4880
4883
  const admissionRequest = await protocol.createAdmissionRequest(deviceProfile);
4881
4884
  if (admissionRequest.space) {
4882
4885
  try {
@@ -4889,19 +4892,19 @@ var EdgeInvitationHandler = class {
4889
4892
  after: error.retryAfterMs ?? this._calculateNextRetryMs()
4890
4893
  }, {
4891
4894
  F: __dxlog_file17,
4892
- L: 95,
4895
+ L: 98,
4893
4896
  S: this,
4894
4897
  C: (f, a) => f(...a)
4895
4898
  });
4896
- if (error.isRetryable) {
4899
+ if (error.isRetryable && requestCount < MAX_RETRIES_PER_INVITATION) {
4897
4900
  scheduleTask5(ctx, tryHandleInvitation, error.retryAfterMs ?? this._calculateNextRetryMs());
4898
4901
  }
4899
- } else {
4902
+ } else if (requestCount < MAX_RETRIES_PER_INVITATION) {
4900
4903
  log14.info("failed to handle invitation with edge", {
4901
4904
  error
4902
4905
  }, {
4903
4906
  F: __dxlog_file17,
4904
- L: 104,
4907
+ L: 107,
4905
4908
  S: this,
4906
4909
  C: (f, a) => f(...a)
4907
4910
  });
@@ -4916,14 +4919,14 @@ var EdgeInvitationHandler = class {
4916
4919
  try {
4917
4920
  log14("edge invitation flow", void 0, {
4918
4921
  F: __dxlog_file17,
4919
- L: 120,
4922
+ L: 123,
4920
4923
  S: this,
4921
4924
  C: (f, a) => f(...a)
4922
4925
  });
4923
4926
  this._flowLock = await tryAcquireBeforeContextDisposed(ctx, guardedState.mutex);
4924
- log14("edge invitation flow acquired the lock", void 0, {
4927
+ log14.verbose("edge invitation flow acquired the lock", void 0, {
4925
4928
  F: __dxlog_file17,
4926
- L: 122,
4929
+ L: 125,
4927
4930
  S: this,
4928
4931
  C: (f, a) => f(...a)
4929
4932
  });
@@ -4956,7 +4959,7 @@ var EdgeInvitationHandler = class {
4956
4959
  async _joinSpaceByInvitation(guardedState, spaceId, request) {
4957
4960
  invariant11(this._client, void 0, {
4958
4961
  F: __dxlog_file17,
4959
- L: 157,
4962
+ L: 160,
4960
4963
  S: this,
4961
4964
  A: [
4962
4965
  "this._client",
@@ -5054,14 +5057,14 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5054
5057
  async onOpen(context) {
5055
5058
  await super.onOpen(context);
5056
5059
  try {
5057
- log15("guest acquire lock", void 0, {
5060
+ log15.verbose("guest acquire lock", void 0, {
5058
5061
  F: __dxlog_file18,
5059
5062
  L: 89,
5060
5063
  S: this,
5061
5064
  C: (f, a) => f(...a)
5062
5065
  });
5063
5066
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
5064
- log15("guest lock acquired", void 0, {
5067
+ log15.verbose("guest lock acquired", void 0, {
5065
5068
  F: __dxlog_file18,
5066
5069
  L: 91,
5067
5070
  S: this,
@@ -5070,7 +5073,7 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5070
5073
  await cancelWithContext4(this._ctx, this.rpc.InvitationHostService.options({
5071
5074
  role: InvitationOptions.Role.GUEST
5072
5075
  }));
5073
- log15("options sent", void 0, {
5076
+ log15.verbose("options sent", void 0, {
5074
5077
  F: __dxlog_file18,
5075
5078
  L: 96,
5076
5079
  S: this,
@@ -5079,7 +5082,7 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5079
5082
  await cancelWithContext4(this._ctx, this._remoteOptionsTrigger.wait({
5080
5083
  timeout: OPTIONS_TIMEOUT
5081
5084
  }));
5082
- log15("options received", void 0, {
5085
+ log15.verbose("options received", void 0, {
5083
5086
  F: __dxlog_file18,
5084
5087
  L: 98,
5085
5088
  S: this,
@@ -5113,7 +5116,7 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5113
5116
  if (this._invitationFlowLock != null) {
5114
5117
  this._invitationFlowLock.release();
5115
5118
  this._invitationFlowLock = null;
5116
- log15("invitation flow lock released", void 0, {
5119
+ log15.verbose("invitation flow lock released", void 0, {
5117
5120
  F: __dxlog_file18,
5118
5121
  L: 131,
5119
5122
  S: this,
@@ -5212,7 +5215,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
5212
5215
  authMethod: Invitation5.AuthMethod.NONE
5213
5216
  };
5214
5217
  }
5215
- log16("guest introduced themselves", {
5218
+ log16.verbose("guest introduced themselves", {
5216
5219
  guestProfile: profile
5217
5220
  }, {
5218
5221
  F: __dxlog_file19,
@@ -5247,7 +5250,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
5247
5250
  C: (f, a) => f(...a)
5248
5251
  });
5249
5252
  const invitation = this._requireActiveInvitation();
5250
- log16("received authentication request", {
5253
+ log16.verbose("received authentication request", {
5251
5254
  authCode: code
5252
5255
  }, {
5253
5256
  F: __dxlog_file19,
@@ -5375,41 +5378,39 @@ var InvitationHostExtension = class extends RpcExtension3 {
5375
5378
  async onOpen(context) {
5376
5379
  await super.onOpen(context);
5377
5380
  try {
5378
- log16("host acquire lock", void 0, {
5381
+ log16.verbose("host acquire lock", void 0, {
5379
5382
  F: __dxlog_file19,
5380
5383
  L: 239,
5381
5384
  S: this,
5382
5385
  C: (f, a) => f(...a)
5383
5386
  });
5384
5387
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
5385
- log16("host lock acquired", void 0, {
5388
+ log16.verbose("host lock acquired", void 0, {
5386
5389
  F: __dxlog_file19,
5387
5390
  L: 241,
5388
5391
  S: this,
5389
5392
  C: (f, a) => f(...a)
5390
5393
  });
5391
- const lastState = this._requireActiveInvitation().state;
5392
5394
  this._callbacks.onStateUpdate(Invitation5.State.CONNECTING);
5393
5395
  await this.rpc.InvitationHostService.options({
5394
5396
  role: InvitationOptions2.Role.HOST
5395
5397
  });
5396
- log16("options sent", void 0, {
5398
+ log16.verbose("options sent", void 0, {
5397
5399
  F: __dxlog_file19,
5398
- L: 245,
5400
+ L: 244,
5399
5401
  S: this,
5400
5402
  C: (f, a) => f(...a)
5401
5403
  });
5402
5404
  await cancelWithContext5(this._ctx, this._remoteOptionsTrigger.wait({
5403
5405
  timeout: OPTIONS_TIMEOUT2
5404
5406
  }));
5405
- log16("options received", void 0, {
5407
+ log16.verbose("options received", void 0, {
5406
5408
  F: __dxlog_file19,
5407
- L: 247,
5409
+ L: 246,
5408
5410
  S: this,
5409
5411
  C: (f, a) => f(...a)
5410
5412
  });
5411
5413
  if (this._remoteOptions?.role !== InvitationOptions2.Role.GUEST) {
5412
- this._callbacks.onStateUpdate(lastState);
5413
5414
  throw new InvalidInvitationExtensionRoleError2(void 0, {
5414
5415
  expected: InvitationOptions2.Role.GUEST,
5415
5416
  remoteOptions: this._remoteOptions,
@@ -5456,9 +5457,9 @@ var InvitationHostExtension = class extends RpcExtension3 {
5456
5457
  if (this._invitationFlowLock != null) {
5457
5458
  this._invitationFlowLock?.release();
5458
5459
  this._invitationFlowLock = null;
5459
- log16("invitation flow lock released", void 0, {
5460
+ log16.verbose("invitation flow lock released", void 0, {
5460
5461
  F: __dxlog_file19,
5461
- L: 302,
5462
+ L: 299,
5462
5463
  S: this,
5463
5464
  C: (f, a) => f(...a)
5464
5465
  });
@@ -5666,7 +5667,7 @@ var InvitationsHandler = class {
5666
5667
  S: this,
5667
5668
  C: (f, a) => f(...a)
5668
5669
  });
5669
- metrics.increment("dxos.invitation.created");
5670
+ metrics.increment("dxos.invitation.host");
5670
5671
  const guardedState = createGuardedInvitationState(ctx, invitation, stream);
5671
5672
  const createExtension = () => {
5672
5673
  const extension = new InvitationHostExtension(guardedState.mutex, {
@@ -5674,7 +5675,9 @@ var InvitationsHandler = class {
5674
5675
  return ctx.disposed ? null : guardedState.current;
5675
5676
  },
5676
5677
  onStateUpdate: (newState) => {
5677
- guardedState.set(extension, newState);
5678
+ if (newState !== Invitation7.State.ERROR && newState !== Invitation7.State.TIMEOUT) {
5679
+ guardedState.set(extension, newState);
5680
+ }
5678
5681
  return guardedState.current;
5679
5682
  },
5680
5683
  admit: async (admissionRequest) => {
@@ -5684,14 +5687,14 @@ var InvitationsHandler = class {
5684
5687
  ...protocol.toJSON()
5685
5688
  }, {
5686
5689
  F: __dxlog_file22,
5687
- L: 105,
5690
+ L: 107,
5688
5691
  S: this,
5689
5692
  C: (f, a) => f(...a)
5690
5693
  });
5691
5694
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
5692
5695
  invariant15(deviceKey, void 0, {
5693
5696
  F: __dxlog_file22,
5694
- L: 110,
5697
+ L: 112,
5695
5698
  S: this,
5696
5699
  A: [
5697
5700
  "deviceKey",
@@ -5710,7 +5713,7 @@ var InvitationsHandler = class {
5710
5713
  let admitted = false;
5711
5714
  connectionCtx.onDispose(() => {
5712
5715
  if (!admitted) {
5713
- guardedState.error(extension, new ContextDisposedError3());
5716
+ guardedState.set(extension, Invitation7.State.CONNECTING);
5714
5717
  }
5715
5718
  });
5716
5719
  scheduleTask7(connectionCtx, async () => {
@@ -5720,27 +5723,27 @@ var InvitationsHandler = class {
5720
5723
  id: traceId
5721
5724
  }), {
5722
5725
  F: __dxlog_file22,
5723
- L: 135,
5726
+ L: 137,
5724
5727
  S: this,
5725
5728
  C: (f, a) => f(...a)
5726
5729
  });
5727
- log19("connected", {
5730
+ log19.verbose("connected", {
5728
5731
  ...protocol.toJSON()
5729
5732
  }, {
5730
5733
  F: __dxlog_file22,
5731
- L: 136,
5734
+ L: 138,
5732
5735
  S: this,
5733
5736
  C: (f, a) => f(...a)
5734
5737
  });
5735
5738
  const deviceKey = await extension.completedTrigger.wait({
5736
5739
  timeout: invitation.timeout
5737
5740
  });
5738
- log19("admitted guest", {
5741
+ log19.verbose("admitted guest", {
5739
5742
  guest: deviceKey,
5740
5743
  ...protocol.toJSON()
5741
5744
  }, {
5742
5745
  F: __dxlog_file22,
5743
- L: 138,
5746
+ L: 140,
5744
5747
  S: this,
5745
5748
  C: (f, a) => f(...a)
5746
5749
  });
@@ -5750,7 +5753,7 @@ var InvitationsHandler = class {
5750
5753
  id: traceId
5751
5754
  }), {
5752
5755
  F: __dxlog_file22,
5753
- L: 141,
5756
+ L: 143,
5754
5757
  S: this,
5755
5758
  C: (f, a) => f(...a)
5756
5759
  });
@@ -5759,24 +5762,25 @@ var InvitationsHandler = class {
5759
5762
  await ctx.dispose();
5760
5763
  }
5761
5764
  } catch (err) {
5765
+ const stateChanged = guardedState.set(extension, Invitation7.State.CONNECTING);
5762
5766
  if (err instanceof TimeoutError2) {
5763
- if (guardedState.set(extension, Invitation7.State.TIMEOUT)) {
5767
+ if (stateChanged) {
5764
5768
  metrics.increment("dxos.invitation.timeout");
5765
- log19("timeout", {
5769
+ log19.verbose("timeout", {
5766
5770
  ...protocol.toJSON()
5767
5771
  }, {
5768
5772
  F: __dxlog_file22,
5769
- L: 151,
5773
+ L: 154,
5770
5774
  S: this,
5771
5775
  C: (f, a) => f(...a)
5772
5776
  });
5773
5777
  }
5774
5778
  } else {
5775
- if (guardedState.error(extension, err)) {
5779
+ if (stateChanged) {
5776
5780
  metrics.increment("dxos.invitation.failed");
5777
5781
  log19.error("failed", err, {
5778
5782
  F: __dxlog_file22,
5779
- L: 156,
5783
+ L: 159,
5780
5784
  S: this,
5781
5785
  C: (f, a) => f(...a)
5782
5786
  });
@@ -5787,7 +5791,7 @@ var InvitationsHandler = class {
5787
5791
  error: err
5788
5792
  }), {
5789
5793
  F: __dxlog_file22,
5790
- L: 159,
5794
+ L: 162,
5791
5795
  S: this,
5792
5796
  C: (f, a) => f(...a)
5793
5797
  });
@@ -5796,35 +5800,36 @@ var InvitationsHandler = class {
5796
5800
  });
5797
5801
  },
5798
5802
  onError: (err) => {
5803
+ const stateChanged = guardedState.set(extension, Invitation7.State.CONNECTING);
5799
5804
  if (err instanceof InvalidInvitationExtensionRoleError3) {
5800
5805
  log19("invalid role", {
5801
5806
  ...err.context
5802
5807
  }, {
5803
5808
  F: __dxlog_file22,
5804
- L: 167,
5809
+ L: 171,
5805
5810
  S: this,
5806
5811
  C: (f, a) => f(...a)
5807
5812
  });
5808
5813
  return;
5809
5814
  }
5810
5815
  if (err instanceof TimeoutError2) {
5811
- if (guardedState.set(extension, Invitation7.State.TIMEOUT)) {
5816
+ if (stateChanged) {
5812
5817
  metrics.increment("dxos.invitation.timeout");
5813
- log19("timeout", {
5818
+ log19.verbose("timeout", {
5814
5819
  err
5815
5820
  }, {
5816
5821
  F: __dxlog_file22,
5817
- L: 173,
5822
+ L: 177,
5818
5823
  S: this,
5819
5824
  C: (f, a) => f(...a)
5820
5825
  });
5821
5826
  }
5822
5827
  } else {
5823
- if (guardedState.error(extension, err)) {
5828
+ if (stateChanged) {
5824
5829
  metrics.increment("dxos.invitation.failed");
5825
5830
  log19.error("failed", err, {
5826
5831
  F: __dxlog_file22,
5827
- L: 178,
5832
+ L: 182,
5828
5833
  S: this,
5829
5834
  C: (f, a) => f(...a)
5830
5835
  });
@@ -5838,18 +5843,25 @@ var InvitationsHandler = class {
5838
5843
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
5839
5844
  log19.warn("invitation has already expired", void 0, {
5840
5845
  F: __dxlog_file22,
5841
- L: 189,
5846
+ L: 193,
5842
5847
  S: this,
5843
5848
  C: (f, a) => f(...a)
5844
5849
  });
5845
- } else {
5846
- scheduleTask7(ctx, async () => {
5847
- await swarmConnection.close();
5848
- guardedState.set(null, Invitation7.State.EXPIRED);
5849
- metrics.increment("dxos.invitation.expired");
5850
- await ctx.dispose();
5851
- }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
5850
+ guardedState.set(null, Invitation7.State.EXPIRED);
5851
+ void ctx.dispose().catch((err) => log19.catch(err, void 0, {
5852
+ F: __dxlog_file22,
5853
+ L: 195,
5854
+ S: this,
5855
+ C: (f, a) => f(...a)
5856
+ }));
5857
+ return;
5852
5858
  }
5859
+ scheduleTask7(ctx, async () => {
5860
+ await swarmConnection.close();
5861
+ guardedState.set(null, Invitation7.State.EXPIRED);
5862
+ metrics.increment("dxos.invitation.expired");
5863
+ await ctx.dispose();
5864
+ }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
5853
5865
  }
5854
5866
  let swarmConnection;
5855
5867
  scheduleTask7(ctx, async () => {
@@ -5865,7 +5877,7 @@ var InvitationsHandler = class {
5865
5877
  type: invitation.type
5866
5878
  }, {
5867
5879
  F: __dxlog_file22,
5868
- L: 220,
5880
+ L: 226,
5869
5881
  S: this,
5870
5882
  C: (f, a) => f(...a)
5871
5883
  });
@@ -5873,7 +5885,7 @@ var InvitationsHandler = class {
5873
5885
  if (deviceProfile) {
5874
5886
  invariant15(invitation.kind === Invitation7.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
5875
5887
  F: __dxlog_file22,
5876
- L: 229,
5888
+ L: 235,
5877
5889
  S: this,
5878
5890
  A: [
5879
5891
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -5891,7 +5903,7 @@ var InvitationsHandler = class {
5891
5903
  triedPeers: triedPeersIds.size
5892
5904
  }, {
5893
5905
  F: __dxlog_file22,
5894
- L: 237,
5906
+ L: 243,
5895
5907
  S: this,
5896
5908
  C: (f, a) => f(...a)
5897
5909
  });
@@ -5913,12 +5925,12 @@ var InvitationsHandler = class {
5913
5925
  return;
5914
5926
  }
5915
5927
  connectionCtx.onDispose(async () => {
5916
- log19("extension disposed", {
5928
+ log19.verbose("extension disposed", {
5917
5929
  admitted,
5918
5930
  currentState: guardedState.current.state
5919
5931
  }, {
5920
5932
  F: __dxlog_file22,
5921
- L: 265,
5933
+ L: 271,
5922
5934
  S: this,
5923
5935
  C: (f, a) => f(...a)
5924
5936
  });
@@ -5936,7 +5948,7 @@ var InvitationsHandler = class {
5936
5948
  id: traceId
5937
5949
  }), {
5938
5950
  F: __dxlog_file22,
5939
- L: 277,
5951
+ L: 283,
5940
5952
  S: this,
5941
5953
  C: (f, a) => f(...a)
5942
5954
  });
@@ -5948,7 +5960,7 @@ var InvitationsHandler = class {
5948
5960
  ...protocol.toJSON()
5949
5961
  }, {
5950
5962
  F: __dxlog_file22,
5951
- L: 288,
5963
+ L: 294,
5952
5964
  S: this,
5953
5965
  C: (f, a) => f(...a)
5954
5966
  });
@@ -5958,7 +5970,7 @@ var InvitationsHandler = class {
5958
5970
  ...protocol.toJSON()
5959
5971
  }, {
5960
5972
  F: __dxlog_file22,
5961
- L: 292,
5973
+ L: 298,
5962
5974
  S: this,
5963
5975
  C: (f, a) => f(...a)
5964
5976
  });
@@ -5972,7 +5984,7 @@ var InvitationsHandler = class {
5972
5984
  authMethod: introductionResponse.authMethod
5973
5985
  }, {
5974
5986
  F: __dxlog_file22,
5975
- L: 300,
5987
+ L: 306,
5976
5988
  S: this,
5977
5989
  C: (f, a) => f(...a)
5978
5990
  });
@@ -5994,7 +6006,7 @@ var InvitationsHandler = class {
5994
6006
  ...protocol.toJSON()
5995
6007
  }, {
5996
6008
  F: __dxlog_file22,
5997
- L: 330,
6009
+ L: 336,
5998
6010
  S: this,
5999
6011
  C: (f, a) => f(...a)
6000
6012
  });
@@ -6007,7 +6019,7 @@ var InvitationsHandler = class {
6007
6019
  ...protocol.toJSON()
6008
6020
  }, {
6009
6021
  F: __dxlog_file22,
6010
- L: 344,
6022
+ L: 350,
6011
6023
  S: this,
6012
6024
  C: (f, a) => f(...a)
6013
6025
  });
@@ -6020,25 +6032,25 @@ var InvitationsHandler = class {
6020
6032
  id: traceId
6021
6033
  }), {
6022
6034
  F: __dxlog_file22,
6023
- L: 353,
6035
+ L: 359,
6024
6036
  S: this,
6025
6037
  C: (f, a) => f(...a)
6026
6038
  });
6027
6039
  } catch (err) {
6028
6040
  if (err instanceof TimeoutError2) {
6029
- log19("timeout", {
6041
+ log19.verbose("timeout", {
6030
6042
  ...protocol.toJSON()
6031
6043
  }, {
6032
6044
  F: __dxlog_file22,
6033
- L: 356,
6045
+ L: 362,
6034
6046
  S: this,
6035
6047
  C: (f, a) => f(...a)
6036
6048
  });
6037
6049
  guardedState.set(extension, Invitation7.State.TIMEOUT);
6038
6050
  } else {
6039
- log19("auth failed", err, {
6051
+ log19.verbose("auth failed", err, {
6040
6052
  F: __dxlog_file22,
6041
- L: 359,
6053
+ L: 365,
6042
6054
  S: this,
6043
6055
  C: (f, a) => f(...a)
6044
6056
  });
@@ -6050,7 +6062,7 @@ var InvitationsHandler = class {
6050
6062
  error: err
6051
6063
  }), {
6052
6064
  F: __dxlog_file22,
6053
- L: 363,
6065
+ L: 369,
6054
6066
  S: this,
6055
6067
  C: (f, a) => f(...a)
6056
6068
  });
@@ -6062,19 +6074,19 @@ var InvitationsHandler = class {
6062
6074
  return;
6063
6075
  }
6064
6076
  if (err instanceof TimeoutError2) {
6065
- log19("timeout", {
6077
+ log19.verbose("timeout", {
6066
6078
  ...protocol.toJSON()
6067
6079
  }, {
6068
6080
  F: __dxlog_file22,
6069
- L: 372,
6081
+ L: 378,
6070
6082
  S: this,
6071
6083
  C: (f, a) => f(...a)
6072
6084
  });
6073
6085
  guardedState.set(extension, Invitation7.State.TIMEOUT);
6074
6086
  } else {
6075
- log19("auth failed", err, {
6087
+ log19.verbose("auth failed", err, {
6076
6088
  F: __dxlog_file22,
6077
- L: 375,
6089
+ L: 381,
6078
6090
  S: this,
6079
6091
  C: (f, a) => f(...a)
6080
6092
  });
@@ -6091,7 +6103,7 @@ var InvitationsHandler = class {
6091
6103
  ...protocol.toJSON()
6092
6104
  }, {
6093
6105
  F: __dxlog_file22,
6094
- L: 387,
6106
+ L: 393,
6095
6107
  S: this,
6096
6108
  C: (f, a) => f(...a)
6097
6109
  });
@@ -6111,7 +6123,7 @@ var InvitationsHandler = class {
6111
6123
  } else {
6112
6124
  invariant15(invitation.swarmKey, void 0, {
6113
6125
  F: __dxlog_file22,
6114
- L: 399,
6126
+ L: 405,
6115
6127
  S: this,
6116
6128
  A: [
6117
6129
  "invitation.swarmKey",
@@ -6155,7 +6167,7 @@ var InvitationsHandler = class {
6155
6167
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
6156
6168
  log19("guest waiting for authentication code...", void 0, {
6157
6169
  F: __dxlog_file22,
6158
- L: 451,
6170
+ L: 457,
6159
6171
  S: this,
6160
6172
  C: (f, a) => f(...a)
6161
6173
  });
@@ -6163,7 +6175,7 @@ var InvitationsHandler = class {
6163
6175
  const authCode = await authenticated.wait(options);
6164
6176
  log19("sending authentication request", void 0, {
6165
6177
  F: __dxlog_file22,
6166
- L: 455,
6178
+ L: 461,
6167
6179
  S: this,
6168
6180
  C: (f, a) => f(...a)
6169
6181
  });
@@ -6182,7 +6194,7 @@ var InvitationsHandler = class {
6182
6194
  attempt
6183
6195
  }, {
6184
6196
  F: __dxlog_file22,
6185
- L: 466,
6197
+ L: 472,
6186
6198
  S: this,
6187
6199
  C: (f, a) => f(...a)
6188
6200
  });
@@ -6200,7 +6212,7 @@ var InvitationsHandler = class {
6200
6212
  }
6201
6213
  log19("sending authentication request", void 0, {
6202
6214
  F: __dxlog_file22,
6203
- L: 485,
6215
+ L: 491,
6204
6216
  S: this,
6205
6217
  C: (f, a) => f(...a)
6206
6218
  });
@@ -6224,6 +6236,7 @@ var createAdmissionKeypair = () => {
6224
6236
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
6225
6237
  import { Stream as Stream9 } from "@dxos/codec-protobuf";
6226
6238
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
6239
+ import { trace as trace8 } from "@dxos/tracing";
6227
6240
  var InvitationsServiceImpl = class {
6228
6241
  constructor(_invitationsManager) {
6229
6242
  this._invitationsManager = _invitationsManager;
@@ -6234,7 +6247,10 @@ var InvitationsServiceImpl = class {
6234
6247
  }
6235
6248
  createInvitation(options) {
6236
6249
  return new Stream9(({ next, close }) => {
6237
- void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
6250
+ void this._invitationsManager.createInvitation(options).then((invitation) => {
6251
+ trace8.metrics.increment("dxos.invitation.created");
6252
+ invitation.subscribe(next, close, close);
6253
+ }).catch(close);
6238
6254
  });
6239
6255
  }
6240
6256
  acceptInvitation(request) {
@@ -7095,7 +7111,7 @@ var isLocked = (lockPath) => {
7095
7111
  import { Stream as Stream10 } from "@dxos/codec-protobuf";
7096
7112
  import { raise as raise2 } from "@dxos/debug";
7097
7113
  import { parseMethodName, RpcPeer } from "@dxos/rpc";
7098
- import { MapCounter, trace as trace8 } from "@dxos/tracing";
7114
+ import { MapCounter, trace as trace9 } from "@dxos/tracing";
7099
7115
  function _ts_decorate8(decorators, target, key, desc) {
7100
7116
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7101
7117
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7159,13 +7175,13 @@ var ClientRpcServer = class {
7159
7175
  }
7160
7176
  };
7161
7177
  _ts_decorate8([
7162
- trace8.metricsCounter()
7178
+ trace9.metricsCounter()
7163
7179
  ], ClientRpcServer.prototype, "_callMetrics", void 0);
7164
7180
  _ts_decorate8([
7165
- trace8.info()
7181
+ trace9.info()
7166
7182
  ], ClientRpcServer.prototype, "_services", null);
7167
7183
  ClientRpcServer = _ts_decorate8([
7168
- trace8.resource()
7184
+ trace9.resource()
7169
7185
  ], ClientRpcServer);
7170
7186
 
7171
7187
  // packages/sdk/client-services/src/packlets/agents/edge-agent-manager.ts
@@ -7440,7 +7456,7 @@ import { invariant as invariant20 } from "@dxos/invariant";
7440
7456
  import { Keyring } from "@dxos/keyring";
7441
7457
  import { PublicKey as PublicKey15 } from "@dxos/keys";
7442
7458
  import { log as log25 } from "@dxos/log";
7443
- import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
7459
+ import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace10 } from "@dxos/protocols";
7444
7460
  import { Invitation as Invitation10 } from "@dxos/protocols/proto/dxos/client/services";
7445
7461
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
7446
7462
  import { trace as Trace3 } from "@dxos/tracing";
@@ -7698,7 +7714,7 @@ var ServiceContext = class extends Resource7 {
7698
7714
  S: this,
7699
7715
  C: (f, a) => f(...a)
7700
7716
  });
7701
- log25.trace("dxos.sdk.service-context.open", trace9.begin({
7717
+ log25.trace("dxos.sdk.service-context.open", trace10.begin({
7702
7718
  id: this._instanceId
7703
7719
  }), {
7704
7720
  F: __dxlog_file28,
@@ -7733,7 +7749,7 @@ var ServiceContext = class extends Resource7 {
7733
7749
  S: this,
7734
7750
  C: (f, a) => f(...a)
7735
7751
  });
7736
- log25.trace("dxos.sdk.service-context.open", trace9.end({
7752
+ log25.trace("dxos.sdk.service-context.open", trace10.end({
7737
7753
  id: this._instanceId
7738
7754
  }), {
7739
7755
  F: __dxlog_file28,
@@ -7953,8 +7969,8 @@ var ServiceContext = class extends Resource7 {
7953
7969
  S: this,
7954
7970
  C: (f, a) => f(...a)
7955
7971
  });
7956
- if (params?.deviceCredential) {
7957
- edgeIdentity = await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, {
7972
+ if (params?.deviceCredential || Boolean(globalThis?.DEVICE_INVITE_INTEROP)) {
7973
+ edgeIdentity = await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, params?.deviceCredential && {
7958
7974
  credential: params.deviceCredential
7959
7975
  }, []);
7960
7976
  } else {
@@ -8266,7 +8282,7 @@ import { PublicKey as PublicKey19 } from "@dxos/keys";
8266
8282
  import { log as log28 } from "@dxos/log";
8267
8283
  import { EdgeSignalManager, WebsocketSignalManager } from "@dxos/messaging";
8268
8284
  import { SwarmNetworkManager, createIceProvider, createRtcTransportFactory } from "@dxos/network-manager";
8269
- import { trace as trace10 } from "@dxos/protocols";
8285
+ import { trace as trace11 } from "@dxos/protocols";
8270
8286
  import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
8271
8287
  import { TRACE_PROCESSOR as TRACE_PROCESSOR3, trace as Trace4 } from "@dxos/tracing";
8272
8288
  import { WebsocketRpcClient } from "@dxos/websocket-rpc";
@@ -8843,7 +8859,7 @@ var ClientServicesHost = class {
8843
8859
  return;
8844
8860
  }
8845
8861
  const traceId = PublicKey19.random().toHex();
8846
- log28.trace("dxos.client-services.host.open", trace10.begin({
8862
+ log28.trace("dxos.client-services.host.open", trace11.begin({
8847
8863
  id: traceId
8848
8864
  }), {
8849
8865
  F: __dxlog_file31,
@@ -8957,7 +8973,7 @@ var ClientServicesHost = class {
8957
8973
  S: this,
8958
8974
  C: (f, a) => f(...a)
8959
8975
  });
8960
- log28.trace("dxos.client-services.host.open", trace10.end({
8976
+ log28.trace("dxos.client-services.host.open", trace11.end({
8961
8977
  id: traceId
8962
8978
  }), {
8963
8979
  F: __dxlog_file31,
@@ -9000,7 +9016,7 @@ var ClientServicesHost = class {
9000
9016
  }
9001
9017
  async reset() {
9002
9018
  const traceId = PublicKey19.random().toHex();
9003
- log28.trace("dxos.sdk.client-services-host.reset", trace10.begin({
9019
+ log28.trace("dxos.sdk.client-services-host.reset", trace11.begin({
9004
9020
  id: traceId
9005
9021
  }), {
9006
9022
  F: __dxlog_file31,
@@ -9024,7 +9040,7 @@ var ClientServicesHost = class {
9024
9040
  S: this,
9025
9041
  C: (f, a) => f(...a)
9026
9042
  });
9027
- log28.trace("dxos.sdk.client-services-host.reset", trace10.end({
9043
+ log28.trace("dxos.sdk.client-services-host.reset", trace11.end({
9028
9044
  id: traceId
9029
9045
  }), {
9030
9046
  F: __dxlog_file31,
@@ -9106,4 +9122,4 @@ export {
9106
9122
  importProfileData,
9107
9123
  ClientServicesHost
9108
9124
  };
9109
- //# sourceMappingURL=chunk-GFOAZHIO.mjs.map
9125
+ //# sourceMappingURL=chunk-5GW6342T.mjs.map