@dxos/client-services 0.7.5-main.499c70c → 0.7.5-main.9cb18ac

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.
@@ -6,7 +6,7 @@ import {
6
6
  InvitationsManager,
7
7
  ServiceContext,
8
8
  SpaceInvitationProtocol
9
- } from "../chunk-BXVZXTZM.mjs";
9
+ } from "../chunk-2VSGKKFD.mjs";
10
10
 
11
11
  // packages/sdk/client-services/src/packlets/testing/credential-utils.ts
12
12
  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_PHNHOPRY_exports = {};
30
- __export(chunk_PHNHOPRY_exports, {
29
+ var chunk_B64P5OCZ_exports = {};
30
+ __export(chunk_B64P5OCZ_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -72,7 +72,7 @@ __export(chunk_PHNHOPRY_exports, {
72
72
  subscribeToSpaces: () => subscribeToSpaces,
73
73
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
74
74
  });
75
- module.exports = __toCommonJS(chunk_PHNHOPRY_exports);
75
+ module.exports = __toCommonJS(chunk_B64P5OCZ_exports);
76
76
  var import_async = require("@dxos/async");
77
77
  var import_codec_protobuf = require("@dxos/codec-protobuf");
78
78
  var import_feed_store = require("@dxos/feed-store");
@@ -735,7 +735,7 @@ var DevtoolsServiceImpl = class {
735
735
  });
736
736
  }
737
737
  };
738
- var DXOS_VERSION = "0.7.5-main.499c70c";
738
+ var DXOS_VERSION = "0.7.5-main.9cb18ac";
739
739
  var getPlatform = () => {
740
740
  if (process.browser) {
741
741
  if (typeof window !== "undefined") {
@@ -1633,6 +1633,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1633
1633
  this._processedCredentials = new import_util5.ComplexSet(import_keys5.PublicKey.hash);
1634
1634
  this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys5.PublicKey.hash);
1635
1635
  this._activeEdgePollingIntervalHandle = void 0;
1636
+ this._activeEdgePollingEnabled = false;
1636
1637
  this._spaceId = params.spaceId;
1637
1638
  this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
1638
1639
  if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
@@ -1640,15 +1641,6 @@ var NotarizationPlugin = class extends import_context6.Resource {
1640
1641
  }
1641
1642
  }
1642
1643
  setActiveEdgePollingEnabled(enabled) {
1643
- (0, import_invariant5.invariant)(this.isOpen, void 0, {
1644
- F: __dxlog_file7,
1645
- L: 109,
1646
- S: this,
1647
- A: [
1648
- "this.isOpen",
1649
- ""
1650
- ]
1651
- });
1652
1644
  const client = this._edgeClient;
1653
1645
  (0, import_invariant5.invariant)(client, void 0, {
1654
1646
  F: __dxlog_file7,
@@ -1659,30 +1651,30 @@ var NotarizationPlugin = class extends import_context6.Resource {
1659
1651
  ""
1660
1652
  ]
1661
1653
  });
1662
- if (enabled && !this._activeEdgePollingIntervalHandle) {
1663
- this._activeEdgePollingIntervalHandle = setInterval(() => {
1664
- if (this._writer) {
1665
- this._notarizePendingEdgeCredentials(client, this._writer);
1666
- }
1667
- }, this._activeEdgePollingInterval);
1668
- } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1669
- clearInterval(this._activeEdgePollingIntervalHandle);
1670
- this._activeEdgePollingIntervalHandle = void 0;
1654
+ this._activeEdgePollingEnabled = enabled;
1655
+ if (this.isOpen) {
1656
+ if (enabled && !this._activeEdgePollingIntervalHandle) {
1657
+ this._startPeriodicEdgePolling(client);
1658
+ } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1659
+ this._stopPeriodicEdgePolling();
1660
+ }
1671
1661
  }
1672
1662
  }
1673
1663
  get hasWriter() {
1674
1664
  return !!this._writer;
1675
1665
  }
1676
1666
  async _open() {
1677
- if (this._edgeClient && this._writer) {
1678
- this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1667
+ if (this._edgeClient) {
1668
+ if (this._activeEdgePollingEnabled) {
1669
+ this._startPeriodicEdgePolling(this._edgeClient);
1670
+ }
1671
+ if (this._writer) {
1672
+ this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1673
+ }
1679
1674
  }
1680
1675
  }
1681
1676
  async _close() {
1682
- if (this._activeEdgePollingIntervalHandle) {
1683
- clearInterval(this._activeEdgePollingIntervalHandle);
1684
- this._activeEdgePollingIntervalHandle = void 0;
1685
- }
1677
+ this._stopPeriodicEdgePolling();
1686
1678
  await this._ctx.dispose();
1687
1679
  }
1688
1680
  /**
@@ -1860,10 +1852,23 @@ var NotarizationPlugin = class extends import_context6.Resource {
1860
1852
  ]
1861
1853
  });
1862
1854
  this._writer = writer;
1863
- if (this._edgeClient) {
1855
+ if (this._edgeClient && this.isOpen) {
1864
1856
  this._notarizePendingEdgeCredentials(this._edgeClient, writer);
1865
1857
  }
1866
1858
  }
1859
+ _startPeriodicEdgePolling(client) {
1860
+ this._activeEdgePollingIntervalHandle = setInterval(() => {
1861
+ if (this._writer) {
1862
+ this._notarizePendingEdgeCredentials(client, this._writer);
1863
+ }
1864
+ }, this._activeEdgePollingInterval);
1865
+ }
1866
+ _stopPeriodicEdgePolling() {
1867
+ if (this._activeEdgePollingIntervalHandle) {
1868
+ clearInterval(this._activeEdgePollingIntervalHandle);
1869
+ this._activeEdgePollingIntervalHandle = void 0;
1870
+ }
1871
+ }
1867
1872
  /**
1868
1873
  * The method is used only for adding agent feeds to spaces.
1869
1874
  * When an agent is created we can admit them into all the existing spaces. In case the operation fails
@@ -1882,7 +1887,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1882
1887
  if (!credentials.length) {
1883
1888
  (0, import_log5.log)("edge did not return credentials for notarization", void 0, {
1884
1889
  F: __dxlog_file7,
1885
- L: 296,
1890
+ L: 311,
1886
1891
  S: this,
1887
1892
  C: (f, a) => f(...a)
1888
1893
  });
@@ -1892,7 +1897,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1892
1897
  count: credentials.length
1893
1898
  }, {
1894
1899
  F: __dxlog_file7,
1895
- L: 300,
1900
+ L: 315,
1896
1901
  S: this,
1897
1902
  C: (f, a) => f(...a)
1898
1903
  });
@@ -1905,7 +1910,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1905
1910
  count: decodedCredentials.length
1906
1911
  }, {
1907
1912
  F: __dxlog_file7,
1908
- L: 309,
1913
+ L: 324,
1909
1914
  S: this,
1910
1915
  C: (f, a) => f(...a)
1911
1916
  });
@@ -1933,7 +1938,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1933
1938
  for (const credential of credentials) {
1934
1939
  (0, import_invariant5.invariant)(credential.id, "Credential must have an id", {
1935
1940
  F: __dxlog_file7,
1936
- L: 335,
1941
+ L: 350,
1937
1942
  S: this,
1938
1943
  A: [
1939
1944
  "credential.id",
@@ -1957,7 +1962,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1957
1962
  peer: extension.localPeerId
1958
1963
  }, {
1959
1964
  F: __dxlog_file7,
1960
- L: 350,
1965
+ L: 365,
1961
1966
  S: this,
1962
1967
  C: (f, a) => f(...a)
1963
1968
  });
@@ -1969,7 +1974,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1969
1974
  peer: extension.localPeerId
1970
1975
  }, {
1971
1976
  F: __dxlog_file7,
1972
- L: 355,
1977
+ L: 370,
1973
1978
  S: this,
1974
1979
  C: (f, a) => f(...a)
1975
1980
  });
@@ -1986,7 +1991,7 @@ var NotarizationPlugin = class extends import_context6.Resource {
1986
1991
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1987
1992
  }, {
1988
1993
  F: __dxlog_file7,
1989
- L: 367,
1994
+ L: 382,
1990
1995
  S: this,
1991
1996
  C: (f, a) => f(...a)
1992
1997
  });
@@ -2002,7 +2007,7 @@ var handleEdgeError = (error) => {
2002
2007
  if (!(error instanceof import_protocols4.EdgeCallFailedError) || error.errorData) {
2003
2008
  import_log5.log.catch(error, void 0, {
2004
2009
  F: __dxlog_file7,
2005
- L: 381,
2010
+ L: 396,
2006
2011
  S: void 0,
2007
2012
  C: (f, a) => f(...a)
2008
2013
  });
@@ -2011,7 +2016,7 @@ var handleEdgeError = (error) => {
2011
2016
  reason: error.reason
2012
2017
  }, {
2013
2018
  F: __dxlog_file7,
2014
- L: 383,
2019
+ L: 398,
2015
2020
  S: void 0,
2016
2021
  C: (f, a) => f(...a)
2017
2022
  });
@@ -7498,7 +7503,8 @@ var ServiceContext = class extends import_context16.Resource {
7498
7503
  this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
7499
7504
  this.echoHost = new import_echo_pipeline4.EchoHost({
7500
7505
  kv: this.level,
7501
- peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex()
7506
+ peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
7507
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key
7502
7508
  });
7503
7509
  this._meshReplicator = new import_echo_pipeline4.MeshEchoReplicator();
7504
7510
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
@@ -7517,7 +7523,7 @@ var ServiceContext = class extends import_context16.Resource {
7517
7523
  await this._checkStorageVersion();
7518
7524
  (0, import_log22.log)("opening...", void 0, {
7519
7525
  F: __dxlog_file27,
7520
- L: 198,
7526
+ L: 199,
7521
7527
  S: this,
7522
7528
  C: (f, a) => f(...a)
7523
7529
  });
@@ -7525,7 +7531,7 @@ var ServiceContext = class extends import_context16.Resource {
7525
7531
  id: this._instanceId
7526
7532
  }), {
7527
7533
  F: __dxlog_file27,
7528
- L: 199,
7534
+ L: 200,
7529
7535
  S: this,
7530
7536
  C: (f, a) => f(...a)
7531
7537
  });
@@ -7552,7 +7558,7 @@ var ServiceContext = class extends import_context16.Resource {
7552
7558
  count: loadedInvitations.invitations?.length
7553
7559
  }, {
7554
7560
  F: __dxlog_file27,
7555
- L: 227,
7561
+ L: 228,
7556
7562
  S: this,
7557
7563
  C: (f, a) => f(...a)
7558
7564
  });
@@ -7560,13 +7566,13 @@ var ServiceContext = class extends import_context16.Resource {
7560
7566
  id: this._instanceId
7561
7567
  }), {
7562
7568
  F: __dxlog_file27,
7563
- L: 229,
7569
+ L: 230,
7564
7570
  S: this,
7565
7571
  C: (f, a) => f(...a)
7566
7572
  });
7567
7573
  (0, import_log22.log)("opened", void 0, {
7568
7574
  F: __dxlog_file27,
7569
- L: 230,
7575
+ L: 231,
7570
7576
  S: this,
7571
7577
  C: (f, a) => f(...a)
7572
7578
  });
@@ -7574,7 +7580,7 @@ var ServiceContext = class extends import_context16.Resource {
7574
7580
  async _close(ctx) {
7575
7581
  (0, import_log22.log)("closing...", void 0, {
7576
7582
  F: __dxlog_file27,
7577
- L: 234,
7583
+ L: 235,
7578
7584
  S: this,
7579
7585
  C: (f, a) => f(...a)
7580
7586
  });
@@ -7593,7 +7599,7 @@ var ServiceContext = class extends import_context16.Resource {
7593
7599
  await this._edgeConnection?.close();
7594
7600
  (0, import_log22.log)("closed", void 0, {
7595
7601
  F: __dxlog_file27,
7596
- L: 250,
7602
+ L: 251,
7597
7603
  S: this,
7598
7604
  C: (f, a) => f(...a)
7599
7605
  });
@@ -7604,7 +7610,7 @@ var ServiceContext = class extends import_context16.Resource {
7604
7610
  await identity.joinNetwork();
7605
7611
  await this._initialize(new import_context16.Context(void 0, {
7606
7612
  F: __dxlog_file27,
7607
- L: 257
7613
+ L: 258
7608
7614
  }));
7609
7615
  return identity;
7610
7616
  }
@@ -7615,7 +7621,7 @@ var ServiceContext = class extends import_context16.Resource {
7615
7621
  const factory = this._handlerFactories.get(invitation.kind);
7616
7622
  (0, import_invariant21.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
7617
7623
  F: __dxlog_file27,
7618
- L: 266,
7624
+ L: 267,
7619
7625
  S: this,
7620
7626
  A: [
7621
7627
  "factory",
@@ -7641,7 +7647,7 @@ var ServiceContext = class extends import_context16.Resource {
7641
7647
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
7642
7648
  await this._initialize(new import_context16.Context(void 0, {
7643
7649
  F: __dxlog_file27,
7644
- L: 285
7650
+ L: 286
7645
7651
  }));
7646
7652
  return identity;
7647
7653
  }
@@ -7655,7 +7661,7 @@ var ServiceContext = class extends import_context16.Resource {
7655
7661
  async _initialize(ctx) {
7656
7662
  (0, import_log22.log)("initializing spaces...", void 0, {
7657
7663
  F: __dxlog_file27,
7658
- L: 300,
7664
+ L: 301,
7659
7665
  S: this,
7660
7666
  C: (f, a) => f(...a)
7661
7667
  });
@@ -7694,7 +7700,7 @@ var ServiceContext = class extends import_context16.Resource {
7694
7700
  this._handlerFactories.set(import_services21.Invitation.Kind.SPACE, (invitation) => {
7695
7701
  (0, import_invariant21.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7696
7702
  F: __dxlog_file27,
7697
- L: 338,
7703
+ L: 339,
7698
7704
  S: this,
7699
7705
  A: [
7700
7706
  "this.dataSpaceManager",
@@ -7718,7 +7724,7 @@ var ServiceContext = class extends import_context16.Resource {
7718
7724
  details: assertion
7719
7725
  }, {
7720
7726
  F: __dxlog_file27,
7721
- L: 354,
7727
+ L: 355,
7722
7728
  S: this,
7723
7729
  C: (f, a) => f(...a)
7724
7730
  });
@@ -7729,7 +7735,7 @@ var ServiceContext = class extends import_context16.Resource {
7729
7735
  details: assertion
7730
7736
  }, {
7731
7737
  F: __dxlog_file27,
7732
- L: 358,
7738
+ L: 359,
7733
7739
  S: this,
7734
7740
  C: (f, a) => f(...a)
7735
7741
  });
@@ -7740,7 +7746,7 @@ var ServiceContext = class extends import_context16.Resource {
7740
7746
  details: assertion
7741
7747
  }, {
7742
7748
  F: __dxlog_file27,
7743
- L: 363,
7749
+ L: 364,
7744
7750
  S: this,
7745
7751
  C: (f, a) => f(...a)
7746
7752
  });
@@ -7751,7 +7757,7 @@ var ServiceContext = class extends import_context16.Resource {
7751
7757
  } catch (err) {
7752
7758
  import_log22.log.catch(err, void 0, {
7753
7759
  F: __dxlog_file27,
7754
- L: 369,
7760
+ L: 370,
7755
7761
  S: this,
7756
7762
  C: (f, a) => f(...a)
7757
7763
  });
@@ -7772,7 +7778,7 @@ var ServiceContext = class extends import_context16.Resource {
7772
7778
  swarms: this.networkManager.topics
7773
7779
  }, {
7774
7780
  F: __dxlog_file27,
7775
- L: 383,
7781
+ L: 384,
7776
7782
  S: this,
7777
7783
  C: (f, a) => f(...a)
7778
7784
  });
@@ -7786,7 +7792,7 @@ var ServiceContext = class extends import_context16.Resource {
7786
7792
  });
7787
7793
  (0, import_invariant21.invariant)(identity.deviceCredentialChain, void 0, {
7788
7794
  F: __dxlog_file27,
7789
- L: 402,
7795
+ L: 403,
7790
7796
  S: this,
7791
7797
  A: [
7792
7798
  "identity.deviceCredentialChain",
@@ -8858,4 +8864,4 @@ ClientServicesHost = _ts_decorate11([
8858
8864
  subscribeToSpaces,
8859
8865
  subscribeToSwarmInfo
8860
8866
  });
8861
- //# sourceMappingURL=chunk-PHNHOPRY.cjs.map
8867
+ //# sourceMappingURL=chunk-B64P5OCZ.cjs.map