@dxos/client-services 0.6.2 → 0.6.3-main.226a8ae

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.
@@ -7,7 +7,7 @@ import {
7
7
  InvitationsManager,
8
8
  ServiceContext,
9
9
  SpaceInvitationProtocol
10
- } from "../../chunk-CFKVGKP3.mjs";
10
+ } from "../../chunk-ZCJ2EH5C.mjs";
11
11
 
12
12
  // packages/sdk/client-services/src/packlets/testing/credential-utils.ts
13
13
  import { createCredential } from "@dxos/credentials";
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_7XBIZ7NK_exports = {};
30
- __export(chunk_7XBIZ7NK_exports, {
29
+ var chunk_LHYZLG23_exports = {};
30
+ __export(chunk_LHYZLG23_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  ClientServicesProviderResource: () => ClientServicesProviderResource,
@@ -70,7 +70,7 @@ __export(chunk_7XBIZ7NK_exports, {
70
70
  subscribeToSpaces: () => subscribeToSpaces,
71
71
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
72
72
  });
73
- module.exports = __toCommonJS(chunk_7XBIZ7NK_exports);
73
+ module.exports = __toCommonJS(chunk_LHYZLG23_exports);
74
74
  var import_async = require("@dxos/async");
75
75
  var import_codec_protobuf = require("@dxos/codec-protobuf");
76
76
  var import_feed_store = require("@dxos/feed-store");
@@ -647,7 +647,7 @@ var DevtoolsServiceImpl = class {
647
647
  });
648
648
  }
649
649
  };
650
- var DXOS_VERSION = "0.6.2";
650
+ var DXOS_VERSION = "0.6.3-main.226a8ae";
651
651
  var getPlatform = () => {
652
652
  if (process.browser) {
653
653
  if (typeof window !== "undefined") {
@@ -2488,7 +2488,7 @@ var InvitationsHandler = class {
2488
2488
  this._defaultTeleportParams = _defaultTeleportParams;
2489
2489
  }
2490
2490
  handleInvitationFlow(ctx, stream, protocol, invitation) {
2491
- metrics.increment("invitation.created");
2491
+ metrics.increment("dxos.invitation.created");
2492
2492
  const guardedState = this._createGuardedState(ctx, invitation, stream);
2493
2493
  const createExtension = () => {
2494
2494
  const extension = new InvitationHostExtension(guardedState.mutex, {
@@ -2558,7 +2558,7 @@ var InvitationsHandler = class {
2558
2558
  C: (f, a) => f(...a)
2559
2559
  });
2560
2560
  guardedState.set(extension, import_services6.Invitation.State.SUCCESS);
2561
- metrics.increment("invitation.success");
2561
+ metrics.increment("dxos.invitation.success");
2562
2562
  import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
2563
2563
  id: traceId
2564
2564
  }), {
@@ -2574,7 +2574,7 @@ var InvitationsHandler = class {
2574
2574
  } catch (err) {
2575
2575
  if (err instanceof import_async9.TimeoutError) {
2576
2576
  if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
2577
- metrics.increment("invitation.timeout");
2577
+ metrics.increment("dxos.invitation.timeout");
2578
2578
  (0, import_log6.log)("timeout", {
2579
2579
  ...protocol.toJSON()
2580
2580
  }, {
@@ -2586,7 +2586,7 @@ var InvitationsHandler = class {
2586
2586
  }
2587
2587
  } else {
2588
2588
  if (guardedState.error(extension, err)) {
2589
- metrics.increment("invitation.failed");
2589
+ metrics.increment("dxos.invitation.failed");
2590
2590
  import_log6.log.error("failed", err, {
2591
2591
  F: __dxlog_file12,
2592
2592
  L: 139,
@@ -2622,7 +2622,7 @@ var InvitationsHandler = class {
2622
2622
  }
2623
2623
  if (err instanceof import_async9.TimeoutError) {
2624
2624
  if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
2625
- metrics.increment("invitation.timeout");
2625
+ metrics.increment("dxos.invitation.timeout");
2626
2626
  (0, import_log6.log)("timeout", {
2627
2627
  err
2628
2628
  }, {
@@ -2634,7 +2634,7 @@ var InvitationsHandler = class {
2634
2634
  }
2635
2635
  } else {
2636
2636
  if (guardedState.error(extension, err)) {
2637
- metrics.increment("invitation.failed");
2637
+ metrics.increment("dxos.invitation.failed");
2638
2638
  import_log6.log.error("failed", err, {
2639
2639
  F: __dxlog_file12,
2640
2640
  L: 161,
@@ -2659,7 +2659,7 @@ var InvitationsHandler = class {
2659
2659
  (0, import_async9.scheduleTask)(ctx, async () => {
2660
2660
  await swarmConnection.close();
2661
2661
  guardedState.set(null, import_services6.Invitation.State.EXPIRED);
2662
- metrics.increment("invitation.expired");
2662
+ metrics.increment("dxos.invitation.expired");
2663
2663
  await ctx.dispose();
2664
2664
  }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
2665
2665
  }
@@ -4643,17 +4643,15 @@ var DataSpace = class {
4643
4643
  };
4644
4644
  });
4645
4645
  }
4646
- const root = await this._echoHost.openSpaceRoot(handle.url);
4646
+ const root = await this._echoHost.openSpaceRoot(this.id, handle.url);
4647
4647
  this._databaseRoot = root;
4648
4648
  if (root.getVersion() !== import_echo_protocol.SpaceDocVersion.CURRENT) {
4649
- if (this._state !== import_services12.SpaceState.REQUIRES_MIGRATION) {
4650
- this._state = import_services12.SpaceState.REQUIRES_MIGRATION;
4651
- this.stateUpdate.emit();
4652
- }
4649
+ this._state = import_services12.SpaceState.REQUIRES_MIGRATION;
4650
+ this.stateUpdate.emit();
4651
+ } else if (this._state !== import_services12.SpaceState.READY) {
4652
+ await this._enterReadyState();
4653
4653
  } else {
4654
- if (this._state !== import_services12.SpaceState.READY) {
4655
- await this._enterReadyState();
4656
- }
4654
+ this.stateUpdate.emit();
4657
4655
  }
4658
4656
  } catch (_) {
4659
4657
  _usingCtx.e = _;
@@ -4670,7 +4668,7 @@ var DataSpace = class {
4670
4668
  err
4671
4669
  }, {
4672
4670
  F: __dxlog_file17,
4673
- L: 433,
4671
+ L: 431,
4674
4672
  S: this,
4675
4673
  C: (f, a) => f(...a)
4676
4674
  });
@@ -4723,14 +4721,18 @@ var DataSpace = class {
4723
4721
  credential
4724
4722
  }
4725
4723
  });
4726
- await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe3.Timeframe([
4724
+ const timeframe = new import_timeframe3.Timeframe([
4727
4725
  [
4728
4726
  receipt.feedKey,
4729
4727
  receipt.seq
4730
4728
  ]
4731
- ]));
4729
+ ]);
4730
+ await this.inner.controlPipeline.state.waitUntilTimeframe(timeframe);
4732
4731
  await this._echoHost.updateIndexes();
4733
- return credential;
4732
+ return {
4733
+ credential,
4734
+ timeframe
4735
+ };
4734
4736
  }
4735
4737
  async activate() {
4736
4738
  if (![
@@ -4756,7 +4758,7 @@ var DataSpace = class {
4756
4758
  state: import_services12.SpaceState[this._state]
4757
4759
  }, {
4758
4760
  F: __dxlog_file17,
4759
- L: 514,
4761
+ L: 513,
4760
4762
  S: this,
4761
4763
  C: (f, a) => f(...a)
4762
4764
  });
@@ -5255,19 +5257,37 @@ var DataSpaceManager = class {
5255
5257
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5256
5258
  credentialAuthenticator: (0, import_util9.deferFunction)(() => dataSpace.authVerifier.verifier)
5257
5259
  },
5258
- onAuthorizedConnection: (session) => {
5259
- session.addExtension("dxos.mesh.teleport.admission-discovery", new import_echo_pipeline4.CredentialServerExtension(space));
5260
- session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5261
- remotePeerId: session.remotePeerId
5262
- }));
5263
- session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
5264
- this._echoHost.authorizeDevice(space.key, session.remotePeerId);
5265
- session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
5266
- },
5260
+ onAuthorizedConnection: (session) => queueMicrotask(async () => {
5261
+ try {
5262
+ if (!session.isOpen) {
5263
+ return;
5264
+ }
5265
+ session.addExtension("dxos.mesh.teleport.admission-discovery", new import_echo_pipeline4.CredentialServerExtension(space));
5266
+ session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5267
+ remotePeerId: session.remotePeerId
5268
+ }));
5269
+ session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
5270
+ await this._echoHost.authorizeDevice(space.key, session.remotePeerId);
5271
+ if (!session.isOpen) {
5272
+ return;
5273
+ }
5274
+ session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
5275
+ } catch (err) {
5276
+ import_log15.log.warn("error on authorized connection", {
5277
+ err
5278
+ }, {
5279
+ F: __dxlog_file18,
5280
+ L: 403,
5281
+ S: this,
5282
+ C: (f, a) => f(...a)
5283
+ });
5284
+ await session.close(err);
5285
+ }
5286
+ }),
5267
5287
  onAuthFailure: () => {
5268
5288
  import_log15.log.warn("auth failure", void 0, {
5269
5289
  F: __dxlog_file18,
5270
- L: 396,
5290
+ L: 408,
5271
5291
  S: this,
5272
5292
  C: (f, a) => f(...a)
5273
5293
  });
@@ -5300,7 +5320,7 @@ var DataSpaceManager = class {
5300
5320
  space: space.key
5301
5321
  }, {
5302
5322
  F: __dxlog_file18,
5303
- L: 423,
5323
+ L: 435,
5304
5324
  S: this,
5305
5325
  C: (f, a) => f(...a)
5306
5326
  });
@@ -5311,7 +5331,7 @@ var DataSpaceManager = class {
5311
5331
  open: this._isOpen
5312
5332
  }, {
5313
5333
  F: __dxlog_file18,
5314
- L: 426,
5334
+ L: 438,
5315
5335
  S: this,
5316
5336
  C: (f, a) => f(...a)
5317
5337
  });
@@ -5330,7 +5350,7 @@ var DataSpaceManager = class {
5330
5350
  space: space.key
5331
5351
  }, {
5332
5352
  F: __dxlog_file18,
5333
- L: 434,
5353
+ L: 446,
5334
5354
  S: this,
5335
5355
  C: (f, a) => f(...a)
5336
5356
  });
@@ -5371,7 +5391,7 @@ var DataSpaceManager = class {
5371
5391
  closedSessions
5372
5392
  }, {
5373
5393
  F: __dxlog_file18,
5374
- L: 470,
5394
+ L: 482,
5375
5395
  S: this,
5376
5396
  C: (f, a) => f(...a)
5377
5397
  });
@@ -5386,7 +5406,7 @@ var DataSpaceManager = class {
5386
5406
  peerId: peerState.peerId
5387
5407
  }, {
5388
5408
  F: __dxlog_file18,
5389
- L: 484,
5409
+ L: 496,
5390
5410
  S: this,
5391
5411
  C: (f, a) => f(...a)
5392
5412
  });
@@ -5514,9 +5534,9 @@ var SpacesServiceImpl = class {
5514
5534
  const scheduler = new import_async17.UpdateScheduler(ctx, async () => {
5515
5535
  const dataSpaceManager = await this._getDataSpaceManager();
5516
5536
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
5517
- (0, import_log16.log)("update", {
5518
- spaces
5519
- }, {
5537
+ (0, import_log16.log)("update", () => ({
5538
+ ids: spaces.map((space) => space.id)
5539
+ }), {
5520
5540
  F: __dxlog_file19,
5521
5541
  L: 115,
5522
5542
  S: this,
@@ -5651,12 +5671,13 @@ var SpacesServiceImpl = class {
5651
5671
  async createEpoch({ spaceKey, migration, automergeRootUrl }) {
5652
5672
  const dataSpaceManager = await this._getDataSpaceManager();
5653
5673
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
5654
- const credential = await space.createEpoch({
5674
+ const result = await space.createEpoch({
5655
5675
  migration,
5656
5676
  newAutomergeRoot: automergeRootUrl
5657
5677
  });
5658
5678
  return {
5659
- epochCredential: credential ?? void 0
5679
+ epochCredential: result?.credential,
5680
+ controlTimeframe: result?.timeframe
5660
5681
  };
5661
5682
  }
5662
5683
  async admitContact(request) {
@@ -5763,7 +5784,7 @@ var SpacesServiceImpl = class {
5763
5784
  const dataSpaceManager = await this._getDataSpaceManager();
5764
5785
  const identity = this._identityManager.identity?.identityKey.truncate();
5765
5786
  if (identity) {
5766
- import_tracing8.trace.metrics.gauge("echo.space.count", dataSpaceManager.spaces.size, {
5787
+ import_tracing8.trace.metrics.gauge("dxos.echo.space.count", dataSpaceManager.spaces.size, {
5767
5788
  tags: {
5768
5789
  identity
5769
5790
  }
@@ -7135,4 +7156,4 @@ ClientServicesHost = _ts_decorate8([
7135
7156
  subscribeToSpaces,
7136
7157
  subscribeToSwarmInfo
7137
7158
  });
7138
- //# sourceMappingURL=chunk-7XBIZ7NK.cjs.map
7159
+ //# sourceMappingURL=chunk-LHYZLG23.cjs.map