@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.
@@ -32,7 +32,7 @@ __export(testing_exports, {
32
32
  sanitizeInvitation: () => sanitizeInvitation
33
33
  });
34
34
  module.exports = __toCommonJS(testing_exports);
35
- var import_chunk_PHNHOPRY = require("../chunk-PHNHOPRY.cjs");
35
+ var import_chunk_B64P5OCZ = require("../chunk-B64P5OCZ.cjs");
36
36
  var import_credentials = require("@dxos/credentials");
37
37
  var import_keys = require("@dxos/keys");
38
38
  var import_async = require("@dxos/async");
@@ -235,7 +235,7 @@ var createInvitation = async (host, options) => {
235
235
  authMethod: import_services.Invitation.AuthMethod.NONE,
236
236
  ...options ?? {}
237
237
  };
238
- if (host instanceof import_chunk_PHNHOPRY.ServiceContext) {
238
+ if (host instanceof import_chunk_B64P5OCZ.ServiceContext) {
239
239
  return host.invitationsManager.createInvitation({
240
240
  kind: import_services.Invitation.Kind.SPACE,
241
241
  ...options
@@ -245,7 +245,7 @@ var createInvitation = async (host, options) => {
245
245
  };
246
246
  var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
247
247
  invitation = sanitizeInvitation(invitation);
248
- if (guest instanceof import_chunk_PHNHOPRY.ServiceContext) {
248
+ if (guest instanceof import_chunk_B64P5OCZ.ServiceContext) {
249
249
  return guest.invitationsManager.acceptInvitation({
250
250
  invitation,
251
251
  deviceProfile: guestDeviceProfile
@@ -255,7 +255,7 @@ var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
255
255
  };
256
256
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/test-builder.ts";
257
257
  var createServiceHost = (config, signalManagerContext) => {
258
- return new import_chunk_PHNHOPRY.ClientServicesHost({
258
+ return new import_chunk_B64P5OCZ.ClientServicesHost({
259
259
  config,
260
260
  signalManager: new import_messaging.MemorySignalManager(signalManagerContext),
261
261
  transportFactory: import_network_manager.MemoryTransportFactory
@@ -274,7 +274,7 @@ var createServiceContext = async ({ signalManagerFactory = async () => {
274
274
  });
275
275
  const level = (0, import_testing.createTestLevel)();
276
276
  await level.open();
277
- return new import_chunk_PHNHOPRY.ServiceContext(storage, level, networkManager, signalManager, void 0, void 0, {
277
+ return new import_chunk_B64P5OCZ.ServiceContext(storage, level, networkManager, signalManager, void 0, void 0, {
278
278
  invitationConnectionDefaultParams: {
279
279
  teleport: {
280
280
  controlHeartbeatInterval: 200
@@ -385,7 +385,7 @@ var TestPeer = class {
385
385
  return this._props.meshEchoReplicator ??= new import_echo_pipeline.MeshEchoReplicator();
386
386
  }
387
387
  get dataSpaceManager() {
388
- return this._props.dataSpaceManager ??= new import_chunk_PHNHOPRY.DataSpaceManager({
388
+ return this._props.dataSpaceManager ??= new import_chunk_B64P5OCZ.DataSpaceManager({
389
389
  spaceManager: this.spaceManager,
390
390
  metadataStore: this.metadataStore,
391
391
  keyring: this.keyring,
@@ -400,9 +400,9 @@ var TestPeer = class {
400
400
  });
401
401
  }
402
402
  get invitationsManager() {
403
- return this._props.invitationsManager ??= new import_chunk_PHNHOPRY.InvitationsManager(new import_chunk_PHNHOPRY.InvitationsHandler(this.networkManager), (invitation) => {
403
+ return this._props.invitationsManager ??= new import_chunk_B64P5OCZ.InvitationsManager(new import_chunk_B64P5OCZ.InvitationsHandler(this.networkManager), (invitation) => {
404
404
  if (invitation.kind === import_services2.Invitation.Kind.SPACE) {
405
- return new import_chunk_PHNHOPRY.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
405
+ return new import_chunk_B64P5OCZ.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
406
406
  } else {
407
407
  throw new Error("not implemented");
408
408
  }
@@ -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.7.5-main.499c70c";
400
+ var DXOS_VERSION = "0.7.5-main.9cb18ac";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -1373,6 +1373,7 @@ var NotarizationPlugin = class extends Resource3 {
1373
1373
  this._processedCredentials = new ComplexSet(PublicKey4.hash);
1374
1374
  this._processCredentialsTriggers = new ComplexMap3(PublicKey4.hash);
1375
1375
  this._activeEdgePollingIntervalHandle = void 0;
1376
+ this._activeEdgePollingEnabled = false;
1376
1377
  this._spaceId = params.spaceId;
1377
1378
  this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
1378
1379
  if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
@@ -1380,15 +1381,6 @@ var NotarizationPlugin = class extends Resource3 {
1380
1381
  }
1381
1382
  }
1382
1383
  setActiveEdgePollingEnabled(enabled) {
1383
- invariant4(this.isOpen, void 0, {
1384
- F: __dxlog_file7,
1385
- L: 109,
1386
- S: this,
1387
- A: [
1388
- "this.isOpen",
1389
- ""
1390
- ]
1391
- });
1392
1384
  const client = this._edgeClient;
1393
1385
  invariant4(client, void 0, {
1394
1386
  F: __dxlog_file7,
@@ -1399,30 +1391,30 @@ var NotarizationPlugin = class extends Resource3 {
1399
1391
  ""
1400
1392
  ]
1401
1393
  });
1402
- if (enabled && !this._activeEdgePollingIntervalHandle) {
1403
- this._activeEdgePollingIntervalHandle = setInterval(() => {
1404
- if (this._writer) {
1405
- this._notarizePendingEdgeCredentials(client, this._writer);
1406
- }
1407
- }, this._activeEdgePollingInterval);
1408
- } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1409
- clearInterval(this._activeEdgePollingIntervalHandle);
1410
- this._activeEdgePollingIntervalHandle = void 0;
1394
+ this._activeEdgePollingEnabled = enabled;
1395
+ if (this.isOpen) {
1396
+ if (enabled && !this._activeEdgePollingIntervalHandle) {
1397
+ this._startPeriodicEdgePolling(client);
1398
+ } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1399
+ this._stopPeriodicEdgePolling();
1400
+ }
1411
1401
  }
1412
1402
  }
1413
1403
  get hasWriter() {
1414
1404
  return !!this._writer;
1415
1405
  }
1416
1406
  async _open() {
1417
- if (this._edgeClient && this._writer) {
1418
- this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1407
+ if (this._edgeClient) {
1408
+ if (this._activeEdgePollingEnabled) {
1409
+ this._startPeriodicEdgePolling(this._edgeClient);
1410
+ }
1411
+ if (this._writer) {
1412
+ this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1413
+ }
1419
1414
  }
1420
1415
  }
1421
1416
  async _close() {
1422
- if (this._activeEdgePollingIntervalHandle) {
1423
- clearInterval(this._activeEdgePollingIntervalHandle);
1424
- this._activeEdgePollingIntervalHandle = void 0;
1425
- }
1417
+ this._stopPeriodicEdgePolling();
1426
1418
  await this._ctx.dispose();
1427
1419
  }
1428
1420
  /**
@@ -1600,10 +1592,23 @@ var NotarizationPlugin = class extends Resource3 {
1600
1592
  ]
1601
1593
  });
1602
1594
  this._writer = writer;
1603
- if (this._edgeClient) {
1595
+ if (this._edgeClient && this.isOpen) {
1604
1596
  this._notarizePendingEdgeCredentials(this._edgeClient, writer);
1605
1597
  }
1606
1598
  }
1599
+ _startPeriodicEdgePolling(client) {
1600
+ this._activeEdgePollingIntervalHandle = setInterval(() => {
1601
+ if (this._writer) {
1602
+ this._notarizePendingEdgeCredentials(client, this._writer);
1603
+ }
1604
+ }, this._activeEdgePollingInterval);
1605
+ }
1606
+ _stopPeriodicEdgePolling() {
1607
+ if (this._activeEdgePollingIntervalHandle) {
1608
+ clearInterval(this._activeEdgePollingIntervalHandle);
1609
+ this._activeEdgePollingIntervalHandle = void 0;
1610
+ }
1611
+ }
1607
1612
  /**
1608
1613
  * The method is used only for adding agent feeds to spaces.
1609
1614
  * When an agent is created we can admit them into all the existing spaces. In case the operation fails
@@ -1622,7 +1627,7 @@ var NotarizationPlugin = class extends Resource3 {
1622
1627
  if (!credentials.length) {
1623
1628
  log4("edge did not return credentials for notarization", void 0, {
1624
1629
  F: __dxlog_file7,
1625
- L: 296,
1630
+ L: 311,
1626
1631
  S: this,
1627
1632
  C: (f, a) => f(...a)
1628
1633
  });
@@ -1632,7 +1637,7 @@ var NotarizationPlugin = class extends Resource3 {
1632
1637
  count: credentials.length
1633
1638
  }, {
1634
1639
  F: __dxlog_file7,
1635
- L: 300,
1640
+ L: 315,
1636
1641
  S: this,
1637
1642
  C: (f, a) => f(...a)
1638
1643
  });
@@ -1645,7 +1650,7 @@ var NotarizationPlugin = class extends Resource3 {
1645
1650
  count: decodedCredentials.length
1646
1651
  }, {
1647
1652
  F: __dxlog_file7,
1648
- L: 309,
1653
+ L: 324,
1649
1654
  S: this,
1650
1655
  C: (f, a) => f(...a)
1651
1656
  });
@@ -1673,7 +1678,7 @@ var NotarizationPlugin = class extends Resource3 {
1673
1678
  for (const credential of credentials) {
1674
1679
  invariant4(credential.id, "Credential must have an id", {
1675
1680
  F: __dxlog_file7,
1676
- L: 335,
1681
+ L: 350,
1677
1682
  S: this,
1678
1683
  A: [
1679
1684
  "credential.id",
@@ -1697,7 +1702,7 @@ var NotarizationPlugin = class extends Resource3 {
1697
1702
  peer: extension.localPeerId
1698
1703
  }, {
1699
1704
  F: __dxlog_file7,
1700
- L: 350,
1705
+ L: 365,
1701
1706
  S: this,
1702
1707
  C: (f, a) => f(...a)
1703
1708
  });
@@ -1709,7 +1714,7 @@ var NotarizationPlugin = class extends Resource3 {
1709
1714
  peer: extension.localPeerId
1710
1715
  }, {
1711
1716
  F: __dxlog_file7,
1712
- L: 355,
1717
+ L: 370,
1713
1718
  S: this,
1714
1719
  C: (f, a) => f(...a)
1715
1720
  });
@@ -1726,7 +1731,7 @@ var NotarizationPlugin = class extends Resource3 {
1726
1731
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1727
1732
  }, {
1728
1733
  F: __dxlog_file7,
1729
- L: 367,
1734
+ L: 382,
1730
1735
  S: this,
1731
1736
  C: (f, a) => f(...a)
1732
1737
  });
@@ -1742,7 +1747,7 @@ var handleEdgeError = (error) => {
1742
1747
  if (!(error instanceof EdgeCallFailedError) || error.errorData) {
1743
1748
  log4.catch(error, void 0, {
1744
1749
  F: __dxlog_file7,
1745
- L: 381,
1750
+ L: 396,
1746
1751
  S: void 0,
1747
1752
  C: (f, a) => f(...a)
1748
1753
  });
@@ -1751,7 +1756,7 @@ var handleEdgeError = (error) => {
1751
1756
  reason: error.reason
1752
1757
  }, {
1753
1758
  F: __dxlog_file7,
1754
- L: 383,
1759
+ L: 398,
1755
1760
  S: void 0,
1756
1761
  C: (f, a) => f(...a)
1757
1762
  });
@@ -7487,7 +7492,8 @@ var ServiceContext = class extends Resource7 {
7487
7492
  this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
7488
7493
  this.echoHost = new EchoHost({
7489
7494
  kv: this.level,
7490
- peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex()
7495
+ peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
7496
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key
7491
7497
  });
7492
7498
  this._meshReplicator = new MeshEchoReplicator();
7493
7499
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
@@ -7506,7 +7512,7 @@ var ServiceContext = class extends Resource7 {
7506
7512
  await this._checkStorageVersion();
7507
7513
  log23("opening...", void 0, {
7508
7514
  F: __dxlog_file27,
7509
- L: 198,
7515
+ L: 199,
7510
7516
  S: this,
7511
7517
  C: (f, a) => f(...a)
7512
7518
  });
@@ -7514,7 +7520,7 @@ var ServiceContext = class extends Resource7 {
7514
7520
  id: this._instanceId
7515
7521
  }), {
7516
7522
  F: __dxlog_file27,
7517
- L: 199,
7523
+ L: 200,
7518
7524
  S: this,
7519
7525
  C: (f, a) => f(...a)
7520
7526
  });
@@ -7541,7 +7547,7 @@ var ServiceContext = class extends Resource7 {
7541
7547
  count: loadedInvitations.invitations?.length
7542
7548
  }, {
7543
7549
  F: __dxlog_file27,
7544
- L: 227,
7550
+ L: 228,
7545
7551
  S: this,
7546
7552
  C: (f, a) => f(...a)
7547
7553
  });
@@ -7549,13 +7555,13 @@ var ServiceContext = class extends Resource7 {
7549
7555
  id: this._instanceId
7550
7556
  }), {
7551
7557
  F: __dxlog_file27,
7552
- L: 229,
7558
+ L: 230,
7553
7559
  S: this,
7554
7560
  C: (f, a) => f(...a)
7555
7561
  });
7556
7562
  log23("opened", void 0, {
7557
7563
  F: __dxlog_file27,
7558
- L: 230,
7564
+ L: 231,
7559
7565
  S: this,
7560
7566
  C: (f, a) => f(...a)
7561
7567
  });
@@ -7563,7 +7569,7 @@ var ServiceContext = class extends Resource7 {
7563
7569
  async _close(ctx) {
7564
7570
  log23("closing...", void 0, {
7565
7571
  F: __dxlog_file27,
7566
- L: 234,
7572
+ L: 235,
7567
7573
  S: this,
7568
7574
  C: (f, a) => f(...a)
7569
7575
  });
@@ -7582,7 +7588,7 @@ var ServiceContext = class extends Resource7 {
7582
7588
  await this._edgeConnection?.close();
7583
7589
  log23("closed", void 0, {
7584
7590
  F: __dxlog_file27,
7585
- L: 250,
7591
+ L: 251,
7586
7592
  S: this,
7587
7593
  C: (f, a) => f(...a)
7588
7594
  });
@@ -7593,7 +7599,7 @@ var ServiceContext = class extends Resource7 {
7593
7599
  await identity.joinNetwork();
7594
7600
  await this._initialize(new Context9(void 0, {
7595
7601
  F: __dxlog_file27,
7596
- L: 257
7602
+ L: 258
7597
7603
  }));
7598
7604
  return identity;
7599
7605
  }
@@ -7604,7 +7610,7 @@ var ServiceContext = class extends Resource7 {
7604
7610
  const factory = this._handlerFactories.get(invitation.kind);
7605
7611
  invariant21(factory, `Unknown invitation kind: ${invitation.kind}`, {
7606
7612
  F: __dxlog_file27,
7607
- L: 266,
7613
+ L: 267,
7608
7614
  S: this,
7609
7615
  A: [
7610
7616
  "factory",
@@ -7630,7 +7636,7 @@ var ServiceContext = class extends Resource7 {
7630
7636
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
7631
7637
  await this._initialize(new Context9(void 0, {
7632
7638
  F: __dxlog_file27,
7633
- L: 285
7639
+ L: 286
7634
7640
  }));
7635
7641
  return identity;
7636
7642
  }
@@ -7644,7 +7650,7 @@ var ServiceContext = class extends Resource7 {
7644
7650
  async _initialize(ctx) {
7645
7651
  log23("initializing spaces...", void 0, {
7646
7652
  F: __dxlog_file27,
7647
- L: 300,
7653
+ L: 301,
7648
7654
  S: this,
7649
7655
  C: (f, a) => f(...a)
7650
7656
  });
@@ -7683,7 +7689,7 @@ var ServiceContext = class extends Resource7 {
7683
7689
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
7684
7690
  invariant21(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7685
7691
  F: __dxlog_file27,
7686
- L: 338,
7692
+ L: 339,
7687
7693
  S: this,
7688
7694
  A: [
7689
7695
  "this.dataSpaceManager",
@@ -7707,7 +7713,7 @@ var ServiceContext = class extends Resource7 {
7707
7713
  details: assertion
7708
7714
  }, {
7709
7715
  F: __dxlog_file27,
7710
- L: 354,
7716
+ L: 355,
7711
7717
  S: this,
7712
7718
  C: (f, a) => f(...a)
7713
7719
  });
@@ -7718,7 +7724,7 @@ var ServiceContext = class extends Resource7 {
7718
7724
  details: assertion
7719
7725
  }, {
7720
7726
  F: __dxlog_file27,
7721
- L: 358,
7727
+ L: 359,
7722
7728
  S: this,
7723
7729
  C: (f, a) => f(...a)
7724
7730
  });
@@ -7729,7 +7735,7 @@ var ServiceContext = class extends Resource7 {
7729
7735
  details: assertion
7730
7736
  }, {
7731
7737
  F: __dxlog_file27,
7732
- L: 363,
7738
+ L: 364,
7733
7739
  S: this,
7734
7740
  C: (f, a) => f(...a)
7735
7741
  });
@@ -7740,7 +7746,7 @@ var ServiceContext = class extends Resource7 {
7740
7746
  } catch (err) {
7741
7747
  log23.catch(err, void 0, {
7742
7748
  F: __dxlog_file27,
7743
- L: 369,
7749
+ L: 370,
7744
7750
  S: this,
7745
7751
  C: (f, a) => f(...a)
7746
7752
  });
@@ -7761,7 +7767,7 @@ var ServiceContext = class extends Resource7 {
7761
7767
  swarms: this.networkManager.topics
7762
7768
  }, {
7763
7769
  F: __dxlog_file27,
7764
- L: 383,
7770
+ L: 384,
7765
7771
  S: this,
7766
7772
  C: (f, a) => f(...a)
7767
7773
  });
@@ -7775,7 +7781,7 @@ var ServiceContext = class extends Resource7 {
7775
7781
  });
7776
7782
  invariant21(identity.deviceCredentialChain, void 0, {
7777
7783
  F: __dxlog_file27,
7778
- L: 402,
7784
+ L: 403,
7779
7785
  S: this,
7780
7786
  A: [
7781
7787
  "identity.deviceCredentialChain",
@@ -8918,4 +8924,4 @@ export {
8918
8924
  importProfileData,
8919
8925
  ClientServicesHost
8920
8926
  };
8921
- //# sourceMappingURL=chunk-5LEHZOCS.mjs.map
8927
+ //# sourceMappingURL=chunk-C3BNCKWT.mjs.map