@dxos/client-services 0.8.4-main.a4bbb77 → 0.8.4-main.ae835ea

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 (28) hide show
  1. package/dist/lib/browser/{chunk-FZDVFED2.mjs → chunk-KPYVJG6G.mjs} +780 -1139
  2. package/dist/lib/browser/chunk-KPYVJG6G.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +110 -135
  4. package/dist/lib/browser/index.mjs.map +2 -2
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +37 -66
  7. package/dist/lib/browser/testing/index.mjs.map +2 -2
  8. package/dist/lib/node-esm/{chunk-JDTIU3EP.mjs → chunk-BBBSS6UL.mjs} +780 -1139
  9. package/dist/lib/node-esm/chunk-BBBSS6UL.mjs.map +7 -0
  10. package/dist/lib/node-esm/index.mjs +110 -135
  11. package/dist/lib/node-esm/index.mjs.map +2 -2
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/lib/node-esm/testing/index.mjs +37 -66
  14. package/dist/lib/node-esm/testing/index.mjs.map +2 -2
  15. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  16. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  17. package/dist/types/src/version.d.ts +1 -1
  18. package/dist/types/tsconfig.tsbuildinfo +1 -1
  19. package/package.json +38 -38
  20. package/src/packlets/agents/edge-agent-service.ts +11 -1
  21. package/src/packlets/devices/devices-service.ts +1 -1
  22. package/src/packlets/identity/identity.test.ts +4 -4
  23. package/src/packlets/spaces/data-space-manager.ts +14 -2
  24. package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
  25. package/src/packlets/spaces/edge-feed-replicator.ts +1 -1
  26. package/src/version.ts +1 -1
  27. package/dist/lib/browser/chunk-FZDVFED2.mjs.map +0 -7
  28. package/dist/lib/node-esm/chunk-JDTIU3EP.mjs.map +0 -7
@@ -274,25 +274,14 @@ var subscribeToMetadata = ({ context }) => new Stream5(({ next, ctx }) => {
274
274
  });
275
275
 
276
276
  // src/packlets/devtools/devtools.ts
277
- function _define_property(obj, key, value) {
278
- if (key in obj) {
279
- Object.defineProperty(obj, key, {
280
- value,
281
- enumerable: true,
282
- configurable: true,
283
- writable: true
284
- });
285
- } else {
286
- obj[key] = value;
287
- }
288
- return obj;
289
- }
290
277
  var DevtoolsHostEvents = class {
291
- constructor() {
292
- _define_property(this, "ready", new AsyncEvent());
293
- }
278
+ ready = new AsyncEvent();
294
279
  };
295
280
  var DevtoolsServiceImpl = class {
281
+ params;
282
+ constructor(params) {
283
+ this.params = params;
284
+ }
296
285
  events(_request) {
297
286
  return new Stream6(({ next }) => {
298
287
  this.params.events.ready.on(() => {
@@ -395,10 +384,6 @@ var DevtoolsServiceImpl = class {
395
384
  context: this.params.context
396
385
  });
397
386
  }
398
- constructor(params) {
399
- _define_property(this, "params", void 0);
400
- this.params = params;
401
- }
402
387
  };
403
388
 
404
389
  // src/packlets/diagnostics/diagnostics.ts
@@ -411,7 +396,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
411
396
  import { TRACE_PROCESSOR } from "@dxos/tracing";
412
397
 
413
398
  // src/version.ts
414
- var DXOS_VERSION = "0.8.4-main.a4bbb77";
399
+ var DXOS_VERSION = "0.8.4-main.ae835ea";
415
400
 
416
401
  // src/packlets/services/platform.ts
417
402
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -657,21 +642,9 @@ import { ConfigResource } from "@dxos/config";
657
642
  import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
658
643
  import { TRACE_PROCESSOR as TRACE_PROCESSOR2 } from "@dxos/tracing";
659
644
  import { isNonNullable, jsonKeyReplacer } from "@dxos/util";
660
- function _define_property2(obj, key, value) {
661
- if (key in obj) {
662
- Object.defineProperty(obj, key, {
663
- value,
664
- enumerable: true,
665
- configurable: true,
666
- writable: true
667
- });
668
- } else {
669
- obj[key] = value;
670
- }
671
- return obj;
672
- }
673
645
  var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
674
646
  var DiagnosticsCollector = class {
647
+ static broadcastSender = createCollectDiagnosticsBroadcastSender();
675
648
  static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
676
649
  const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
677
650
  keys: options.humanize ? GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
@@ -692,7 +665,6 @@ var DiagnosticsCollector = class {
692
665
  return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer(options)));
693
666
  }
694
667
  };
695
- _define_property2(DiagnosticsCollector, "broadcastSender", createCollectDiagnosticsBroadcastSender());
696
668
  var findSystemServiceProvider = () => {
697
669
  const serviceProviders = TRACE_PROCESSOR2.findResourcesByAnnotation(ClientServicesProviderResource);
698
670
  const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
@@ -709,19 +681,6 @@ import { Context as Context2 } from "@dxos/context";
709
681
  import { verifyCredential } from "@dxos/credentials";
710
682
  import { log as log3 } from "@dxos/log";
711
683
  import { schema } from "@dxos/protocols/proto";
712
- function _define_property3(obj, key, value) {
713
- if (key in obj) {
714
- Object.defineProperty(obj, key, {
715
- value,
716
- enumerable: true,
717
- configurable: true,
718
- writable: true
719
- });
720
- } else {
721
- obj[key] = value;
722
- }
723
- return obj;
724
- }
725
684
  var __dxlog_file5 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
726
685
  var Credential = schema.getCodecForType("dxos.halo.credentials.Credential");
727
686
  var createAuthProvider = (signer) => async (nonce) => {
@@ -735,6 +694,14 @@ var createAuthProvider = (signer) => async (nonce) => {
735
694
  return Credential.encode(credential);
736
695
  };
737
696
  var TrustedKeySetAuthVerifier = class {
697
+ _params;
698
+ _ctx = new Context2(void 0, {
699
+ F: __dxlog_file5,
700
+ L: 45
701
+ });
702
+ constructor(_params) {
703
+ this._params = _params;
704
+ }
738
705
  async close() {
739
706
  await this._ctx.dispose();
740
707
  }
@@ -828,15 +795,6 @@ var TrustedKeySetAuthVerifier = class {
828
795
  const deviceSet = this._params.trustedKeysProvider();
829
796
  return deviceSet.has(deviceKey);
830
797
  }
831
- constructor(_params) {
832
- _define_property3(this, "_params", void 0);
833
- _define_property3(this, "_ctx", void 0);
834
- this._params = _params;
835
- this._ctx = new Context2(void 0, {
836
- F: __dxlog_file5,
837
- L: 45
838
- });
839
- }
840
798
  };
841
799
 
842
800
  // src/packlets/spaces/edge-feed-replicator.ts
@@ -852,19 +810,6 @@ import { buf } from "@dxos/protocols/buf";
852
810
  import { MessageSchema as RouterMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
853
811
  import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
854
812
  import { ComplexMap as ComplexMap2, arrayToBuffer, bufferToArray, defaultMap, rangeFromTo } from "@dxos/util";
855
- function _define_property4(obj, key, value) {
856
- if (key in obj) {
857
- Object.defineProperty(obj, key, {
858
- value,
859
- enumerable: true,
860
- configurable: true,
861
- writable: true
862
- });
863
- } else {
864
- obj[key] = value;
865
- }
866
- return obj;
867
- }
868
813
  function _ts_decorate(decorators, target, key, desc) {
869
814
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
870
815
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -938,6 +883,24 @@ function _ts_dispose_resources(env) {
938
883
  }
939
884
  var __dxlog_file6 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/edge-feed-replicator.ts";
940
885
  var EdgeFeedReplicator = class extends Resource {
886
+ _messenger;
887
+ _spaceId;
888
+ _feeds = new ComplexMap2(PublicKey3.hash);
889
+ _connectionCtx = void 0;
890
+ _connected = false;
891
+ /**
892
+ * Feed length at service.
893
+ */
894
+ _remoteLength = new ComplexMap2(PublicKey3.hash);
895
+ /**
896
+ * Protects against concurrent pushes so that remote length is updated consistently.
897
+ */
898
+ _pushMutex = new ComplexMap2(PublicKey3.hash);
899
+ constructor({ messenger, spaceId }) {
900
+ super();
901
+ this._messenger = messenger;
902
+ this._spaceId = spaceId;
903
+ }
941
904
  async _open() {
942
905
  log4("open", void 0, {
943
906
  F: __dxlog_file6,
@@ -985,7 +948,7 @@ var EdgeFeedReplicator = class extends Resource {
985
948
  }
986
949
  async _handleReconnect() {
987
950
  await this._resetConnection();
988
- if (this._messenger.status === EdgeStatus.CONNECTED) {
951
+ if (this._messenger.status.state === EdgeStatus.ConnectionState.CONNECTED) {
989
952
  this._startReplication();
990
953
  }
991
954
  }
@@ -1334,17 +1297,6 @@ var EdgeFeedReplicator = class extends Resource {
1334
1297
  });
1335
1298
  return connectionCtx;
1336
1299
  }
1337
- constructor({ messenger, spaceId }) {
1338
- super(), _define_property4(this, "_messenger", void 0), _define_property4(this, "_spaceId", void 0), _define_property4(this, "_feeds", new ComplexMap2(PublicKey3.hash)), _define_property4(this, "_connectionCtx", void 0), _define_property4(this, "_connected", false), /**
1339
- * Feed length at service.
1340
- */
1341
- _define_property4(this, "_remoteLength", new ComplexMap2(PublicKey3.hash)), /**
1342
- * Protects against concurrent pushes so that remote length is updated consistently.
1343
- */
1344
- _define_property4(this, "_pushMutex", new ComplexMap2(PublicKey3.hash));
1345
- this._messenger = messenger;
1346
- this._spaceId = spaceId;
1347
- }
1348
1300
  };
1349
1301
  _ts_decorate([
1350
1302
  logInfo
@@ -1397,9 +1349,9 @@ import { Event as Event2, synchronized, trackLeaks } from "@dxos/async";
1397
1349
  import { PropertiesType, TYPE_PROPERTIES } from "@dxos/client-protocol";
1398
1350
  import { Context as Context4, LifecycleState, Resource as Resource2, cancelWithContext } from "@dxos/context";
1399
1351
  import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
1352
+ import { ObjectId, getTypeReference } from "@dxos/echo/internal";
1400
1353
  import { AuthStatus, CredentialServerExtension, DatabaseRoot, FIND_PARAMS, findInlineObjectOfType } from "@dxos/echo-pipeline";
1401
1354
  import { SpaceDocVersion, createIdFromSpaceKey, encodeReference } from "@dxos/echo-protocol";
1402
- import { ObjectId, getTypeReference } from "@dxos/echo-schema";
1403
1355
  import { writeMessages } from "@dxos/feed-store";
1404
1356
  import { assertArgument, assertState, failedInvariant, invariant as invariant3 } from "@dxos/invariant";
1405
1357
  import { PublicKey as PublicKey4 } from "@dxos/keys";
@@ -1483,19 +1435,6 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1483
1435
  };
1484
1436
 
1485
1437
  // src/packlets/spaces/data-space-manager.ts
1486
- function _define_property5(obj, key, value) {
1487
- if (key in obj) {
1488
- Object.defineProperty(obj, key, {
1489
- value,
1490
- enumerable: true,
1491
- configurable: true,
1492
- writable: true
1493
- });
1494
- } else {
1495
- obj[key] = value;
1496
- }
1497
- return obj;
1498
- }
1499
1438
  function _ts_decorate2(decorators, target, key, desc) {
1500
1439
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1501
1440
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1507,6 +1446,61 @@ var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
1507
1446
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
1508
1447
  var DEFAULT_SPACE_KEY = "__DEFAULT__";
1509
1448
  var DataSpaceManager = class extends Resource2 {
1449
+ updated = new Event2();
1450
+ _spaces = new ComplexMap3(PublicKey4.hash);
1451
+ _instanceId = PublicKey4.random().toHex();
1452
+ _spaceManager;
1453
+ _metadataStore;
1454
+ _keyring;
1455
+ _signingContext;
1456
+ _feedStore;
1457
+ _echoHost;
1458
+ _invitationsManager;
1459
+ _edgeConnection = void 0;
1460
+ _edgeHttpClient = void 0;
1461
+ _edgeFeatures = void 0;
1462
+ _meshReplicator = void 0;
1463
+ _echoEdgeReplicator = void 0;
1464
+ _runtimeParams = void 0;
1465
+ constructor(params) {
1466
+ super();
1467
+ this._spaceManager = params.spaceManager;
1468
+ this._metadataStore = params.metadataStore;
1469
+ this._keyring = params.keyring;
1470
+ this._signingContext = params.signingContext;
1471
+ this._feedStore = params.feedStore;
1472
+ this._echoHost = params.echoHost;
1473
+ this._meshReplicator = params.meshReplicator;
1474
+ this._invitationsManager = params.invitationsManager;
1475
+ this._edgeConnection = params.edgeConnection;
1476
+ this._edgeFeatures = params.edgeFeatures;
1477
+ this._echoEdgeReplicator = params.echoEdgeReplicator;
1478
+ this._edgeHttpClient = params.edgeHttpClient;
1479
+ this._runtimeParams = params.runtimeParams;
1480
+ trace.diagnostic({
1481
+ id: "spaces",
1482
+ name: "Spaces",
1483
+ fetch: async () => {
1484
+ return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
1485
+ const rootUrl = space.automergeSpaceState.rootUrl;
1486
+ const rootHandle = rootUrl ? await this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS) : void 0;
1487
+ await rootHandle?.whenReady();
1488
+ const rootDoc = rootHandle?.doc();
1489
+ const properties = rootDoc && findInlineObjectOfType(rootDoc, TYPE_PROPERTIES);
1490
+ return {
1491
+ key: space.key.toHex(),
1492
+ state: SpaceState[space.state],
1493
+ name: properties?.[1].data.name ?? null,
1494
+ inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
1495
+ linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
1496
+ credentials: space.inner.spaceState.credentials.length,
1497
+ members: space.inner.spaceState.members.size,
1498
+ rootUrl
1499
+ };
1500
+ }));
1501
+ }
1502
+ });
1503
+ }
1510
1504
  // TODO(burdon): Remove.
1511
1505
  get spaces() {
1512
1506
  return this._spaces;
@@ -1633,6 +1627,11 @@ var DataSpaceManager = class extends Resource2 {
1633
1627
  const newDoc = await this._echoHost.createDoc(data, {
1634
1628
  preserveHistory: true
1635
1629
  });
1630
+ if (newDoc.doc().access !== void 0 && newDoc.doc().access.spaceKey !== spaceKey.toHex()) {
1631
+ newDoc.change((doc) => {
1632
+ doc.access.spaceKey = spaceKey.toHex();
1633
+ });
1634
+ }
1636
1635
  documentIdMapping[documentId] = newDoc.documentId;
1637
1636
  }));
1638
1637
  }
@@ -1640,7 +1639,7 @@ var DataSpaceManager = class extends Resource2 {
1640
1639
  spaceKey
1641
1640
  }, {
1642
1641
  F: __dxlog_file7,
1643
- L: 288,
1642
+ L: 299,
1644
1643
  S: this,
1645
1644
  C: (f, a) => f(...a)
1646
1645
  });
@@ -1649,18 +1648,19 @@ var DataSpaceManager = class extends Resource2 {
1649
1648
  const newRootDocId = documentIdMapping[interpretAsDocumentId(options.rootUrl)] ?? failedInvariant();
1650
1649
  const rootDocHandle = await this._echoHost.loadDoc(Context4.default(void 0, {
1651
1650
  F: __dxlog_file7,
1652
- L: 293
1651
+ L: 304
1653
1652
  }), newRootDocId);
1654
1653
  DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
1655
1654
  root = await this._echoHost.openSpaceRoot(spaceId, `automerge:${newRootDocId}`);
1656
1655
  } else {
1657
1656
  root = await this._echoHost.createSpaceRoot(spaceKey);
1658
1657
  }
1658
+ await this._echoHost.flush();
1659
1659
  log5("constructing space...", {
1660
1660
  spaceKey
1661
1661
  }, {
1662
1662
  F: __dxlog_file7,
1663
- L: 301,
1663
+ L: 313,
1664
1664
  S: this,
1665
1665
  C: (f, a) => f(...a)
1666
1666
  });
@@ -1670,7 +1670,7 @@ var DataSpaceManager = class extends Resource2 {
1670
1670
  spaceKey
1671
1671
  }, {
1672
1672
  F: __dxlog_file7,
1673
- L: 306,
1673
+ L: 318,
1674
1674
  S: this,
1675
1675
  C: (f, a) => f(...a)
1676
1676
  });
@@ -1679,7 +1679,7 @@ var DataSpaceManager = class extends Resource2 {
1679
1679
  const memberCredential = credentials[1];
1680
1680
  invariant3(getCredentialAssertion(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
1681
1681
  F: __dxlog_file7,
1682
- L: 312,
1682
+ L: 324,
1683
1683
  S: this,
1684
1684
  A: [
1685
1685
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -1693,7 +1693,7 @@ var DataSpaceManager = class extends Resource2 {
1693
1693
  spaceKey
1694
1694
  }, {
1695
1695
  F: __dxlog_file7,
1696
- L: 317,
1696
+ L: 329,
1697
1697
  S: this,
1698
1698
  C: (f, a) => f(...a)
1699
1699
  });
@@ -1711,7 +1711,7 @@ var DataSpaceManager = class extends Resource2 {
1711
1711
  spaceId: space.id
1712
1712
  }, {
1713
1713
  F: __dxlog_file7,
1714
- L: 330,
1714
+ L: 342,
1715
1715
  S: this,
1716
1716
  C: (f, a) => f(...a)
1717
1717
  });
@@ -1729,7 +1729,7 @@ var DataSpaceManager = class extends Resource2 {
1729
1729
  spaceId: space.id
1730
1730
  }, {
1731
1731
  F: __dxlog_file7,
1732
- L: 341,
1732
+ L: 353,
1733
1733
  S: this,
1734
1734
  C: (f, a) => f(...a)
1735
1735
  });
@@ -1764,7 +1764,7 @@ var DataSpaceManager = class extends Resource2 {
1764
1764
  const automergeIndex = space.automergeSpaceState.rootUrl;
1765
1765
  invariant3(automergeIndex, void 0, {
1766
1766
  F: __dxlog_file7,
1767
- L: 374,
1767
+ L: 386,
1768
1768
  S: this,
1769
1769
  A: [
1770
1770
  "automergeIndex",
@@ -1781,13 +1781,13 @@ var DataSpaceManager = class extends Resource2 {
1781
1781
  opts
1782
1782
  }, {
1783
1783
  F: __dxlog_file7,
1784
- L: 383,
1784
+ L: 395,
1785
1785
  S: this,
1786
1786
  C: (f, a) => f(...a)
1787
1787
  });
1788
1788
  invariant3(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
1789
1789
  F: __dxlog_file7,
1790
- L: 384,
1790
+ L: 396,
1791
1791
  S: this,
1792
1792
  A: [
1793
1793
  "this._lifecycleState === LifecycleState.OPEN",
@@ -1796,7 +1796,7 @@ var DataSpaceManager = class extends Resource2 {
1796
1796
  });
1797
1797
  invariant3(!this._spaces.has(opts.spaceKey), "Space already exists.", {
1798
1798
  F: __dxlog_file7,
1799
- L: 385,
1799
+ L: 397,
1800
1800
  S: this,
1801
1801
  A: [
1802
1802
  "!this._spaces.has(opts.spaceKey)",
@@ -1820,7 +1820,7 @@ var DataSpaceManager = class extends Resource2 {
1820
1820
  const space = this._spaceManager.spaces.get(options.spaceKey);
1821
1821
  invariant3(space, void 0, {
1822
1822
  F: __dxlog_file7,
1823
- L: 405,
1823
+ L: 417,
1824
1824
  S: this,
1825
1825
  A: [
1826
1826
  "space",
@@ -1833,7 +1833,7 @@ var DataSpaceManager = class extends Resource2 {
1833
1833
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
1834
1834
  invariant3(credentials[0].credential, void 0, {
1835
1835
  F: __dxlog_file7,
1836
- L: 424,
1836
+ L: 436,
1837
1837
  S: this,
1838
1838
  A: [
1839
1839
  "credentials[0].credential",
@@ -1843,7 +1843,7 @@ var DataSpaceManager = class extends Resource2 {
1843
1843
  const spaceMemberCredential = credentials[0].credential.credential;
1844
1844
  invariant3(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
1845
1845
  F: __dxlog_file7,
1846
- L: 426,
1846
+ L: 438,
1847
1847
  S: this,
1848
1848
  A: [
1849
1849
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -1881,7 +1881,7 @@ var DataSpaceManager = class extends Resource2 {
1881
1881
  const space = this._spaces.get(spaceKey);
1882
1882
  invariant3(space, "Space not found.", {
1883
1883
  F: __dxlog_file7,
1884
- L: 463,
1884
+ L: 475,
1885
1885
  S: this,
1886
1886
  A: [
1887
1887
  "space",
@@ -1906,7 +1906,7 @@ var DataSpaceManager = class extends Resource2 {
1906
1906
  metadata
1907
1907
  }, {
1908
1908
  F: __dxlog_file7,
1909
- L: 482,
1909
+ L: 494,
1910
1910
  S: this,
1911
1911
  C: (f, a) => f(...a)
1912
1912
  });
@@ -1950,7 +1950,7 @@ var DataSpaceManager = class extends Resource2 {
1950
1950
  err
1951
1951
  }, {
1952
1952
  F: __dxlog_file7,
1953
- L: 524,
1953
+ L: 536,
1954
1954
  S: this,
1955
1955
  C: (f, a) => f(...a)
1956
1956
  });
@@ -1960,7 +1960,7 @@ var DataSpaceManager = class extends Resource2 {
1960
1960
  onAuthFailure: () => {
1961
1961
  log5.warn("auth failure", void 0, {
1962
1962
  F: __dxlog_file7,
1963
- L: 529,
1963
+ L: 541,
1964
1964
  S: this,
1965
1965
  C: (f, a) => f(...a)
1966
1966
  });
@@ -1993,7 +1993,7 @@ var DataSpaceManager = class extends Resource2 {
1993
1993
  space: space.key
1994
1994
  }, {
1995
1995
  F: __dxlog_file7,
1996
- L: 556,
1996
+ L: 568,
1997
1997
  S: this,
1998
1998
  C: (f, a) => f(...a)
1999
1999
  });
@@ -2004,7 +2004,7 @@ var DataSpaceManager = class extends Resource2 {
2004
2004
  open: this._lifecycleState === LifecycleState.OPEN
2005
2005
  }, {
2006
2006
  F: __dxlog_file7,
2007
- L: 559,
2007
+ L: 571,
2008
2008
  S: this,
2009
2009
  C: (f, a) => f(...a)
2010
2010
  });
@@ -2023,7 +2023,7 @@ var DataSpaceManager = class extends Resource2 {
2023
2023
  space: space.key
2024
2024
  }, {
2025
2025
  F: __dxlog_file7,
2026
- L: 567,
2026
+ L: 579,
2027
2027
  S: this,
2028
2028
  C: (f, a) => f(...a)
2029
2029
  });
@@ -2044,7 +2044,7 @@ var DataSpaceManager = class extends Resource2 {
2044
2044
  spaceId: dataSpace.id
2045
2045
  }, {
2046
2046
  F: __dxlog_file7,
2047
- L: 581,
2047
+ L: 593,
2048
2048
  S: this,
2049
2049
  C: (f, a) => f(...a)
2050
2050
  });
@@ -2074,7 +2074,7 @@ var DataSpaceManager = class extends Resource2 {
2074
2074
  space: space.key
2075
2075
  }, {
2076
2076
  F: __dxlog_file7,
2077
- L: 608,
2077
+ L: 620,
2078
2078
  S: this,
2079
2079
  C: (f, a) => f(...a)
2080
2080
  });
@@ -2107,7 +2107,7 @@ var DataSpaceManager = class extends Resource2 {
2107
2107
  closedSessions
2108
2108
  }, {
2109
2109
  F: __dxlog_file7,
2110
- L: 634,
2110
+ L: 646,
2111
2111
  S: this,
2112
2112
  C: (f, a) => f(...a)
2113
2113
  });
@@ -2122,7 +2122,7 @@ var DataSpaceManager = class extends Resource2 {
2122
2122
  peerId: peerState.peerId
2123
2123
  }, {
2124
2124
  F: __dxlog_file7,
2125
- L: 648,
2125
+ L: 660,
2126
2126
  S: this,
2127
2127
  C: (f, a) => f(...a)
2128
2128
  });
@@ -2165,45 +2165,6 @@ var DataSpaceManager = class extends Resource2 {
2165
2165
  });
2166
2166
  await Promise.all(tasks);
2167
2167
  }
2168
- constructor(params) {
2169
- super(), _define_property5(this, "updated", new Event2()), _define_property5(this, "_spaces", new ComplexMap3(PublicKey4.hash)), _define_property5(this, "_instanceId", PublicKey4.random().toHex()), _define_property5(this, "_spaceManager", void 0), _define_property5(this, "_metadataStore", void 0), _define_property5(this, "_keyring", void 0), _define_property5(this, "_signingContext", void 0), _define_property5(this, "_feedStore", void 0), _define_property5(this, "_echoHost", void 0), _define_property5(this, "_invitationsManager", void 0), _define_property5(this, "_edgeConnection", void 0), _define_property5(this, "_edgeHttpClient", void 0), _define_property5(this, "_edgeFeatures", void 0), _define_property5(this, "_meshReplicator", void 0), _define_property5(this, "_echoEdgeReplicator", void 0), _define_property5(this, "_runtimeParams", void 0);
2170
- this._spaceManager = params.spaceManager;
2171
- this._metadataStore = params.metadataStore;
2172
- this._keyring = params.keyring;
2173
- this._signingContext = params.signingContext;
2174
- this._feedStore = params.feedStore;
2175
- this._echoHost = params.echoHost;
2176
- this._meshReplicator = params.meshReplicator;
2177
- this._invitationsManager = params.invitationsManager;
2178
- this._edgeConnection = params.edgeConnection;
2179
- this._edgeFeatures = params.edgeFeatures;
2180
- this._echoEdgeReplicator = params.echoEdgeReplicator;
2181
- this._edgeHttpClient = params.edgeHttpClient;
2182
- this._runtimeParams = params.runtimeParams;
2183
- trace.diagnostic({
2184
- id: "spaces",
2185
- name: "Spaces",
2186
- fetch: async () => {
2187
- return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
2188
- const rootUrl = space.automergeSpaceState.rootUrl;
2189
- const rootHandle = rootUrl ? await this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS) : void 0;
2190
- await rootHandle?.whenReady();
2191
- const rootDoc = rootHandle?.doc();
2192
- const properties = rootDoc && findInlineObjectOfType(rootDoc, TYPE_PROPERTIES);
2193
- return {
2194
- key: space.key.toHex(),
2195
- state: SpaceState[space.state],
2196
- name: properties?.[1].data.name ?? null,
2197
- inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
2198
- linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
2199
- credentials: space.inner.spaceState.credentials.length,
2200
- members: space.inner.spaceState.members.size,
2201
- rootUrl
2202
- };
2203
- }));
2204
- }
2205
- });
2206
- }
2207
2168
  };
2208
2169
  _ts_decorate2([
2209
2170
  synchronized
@@ -2238,21 +2199,12 @@ import { trace as trace2 } from "@dxos/tracing";
2238
2199
  import { Resource as Resource3 } from "@dxos/context";
2239
2200
  import { assertArgument as assertArgument2, assertState as assertState2 } from "@dxos/invariant";
2240
2201
  import { SpaceArchiveFileStructure, SpaceArchiveVersion } from "@dxos/protocols";
2241
- function _define_property6(obj, key, value) {
2242
- if (key in obj) {
2243
- Object.defineProperty(obj, key, {
2244
- value,
2245
- enumerable: true,
2246
- configurable: true,
2247
- writable: true
2248
- });
2249
- } else {
2250
- obj[key] = value;
2251
- }
2252
- return obj;
2253
- }
2254
2202
  var CURRENT_VERSION = SpaceArchiveVersion.V1;
2255
2203
  var SpaceArchiveWriter = class extends Resource3 {
2204
+ _tar;
2205
+ _archive;
2206
+ _meta = void 0;
2207
+ _currentRootUrl = void 0;
2256
2208
  async _open(ctx) {
2257
2209
  this._tar = await import("@obsidize/tar-browserify");
2258
2210
  }
@@ -2296,9 +2248,6 @@ var SpaceArchiveWriter = class extends Resource3 {
2296
2248
  contents: binary
2297
2249
  };
2298
2250
  }
2299
- constructor(...args) {
2300
- super(...args), _define_property6(this, "_tar", void 0), _define_property6(this, "_archive", void 0), _define_property6(this, "_meta", void 0), _define_property6(this, "_currentRootUrl", void 0);
2301
- }
2302
2251
  };
2303
2252
 
2304
2253
  // src/packlets/space-export/space-archive-reader.ts
@@ -2342,19 +2291,6 @@ var extractSpaceArchive = async (archive) => {
2342
2291
  };
2343
2292
 
2344
2293
  // src/packlets/spaces/spaces-service.ts
2345
- function _define_property7(obj, key, value) {
2346
- if (key in obj) {
2347
- Object.defineProperty(obj, key, {
2348
- value,
2349
- enumerable: true,
2350
- configurable: true,
2351
- writable: true
2352
- });
2353
- } else {
2354
- obj[key] = value;
2355
- }
2356
- return obj;
2357
- }
2358
2294
  function _ts_add_disposable_resource2(env, value, async) {
2359
2295
  if (value !== null && value !== void 0) {
2360
2296
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
@@ -2422,6 +2358,14 @@ function _ts_dispose_resources2(env) {
2422
2358
  }
2423
2359
  var __dxlog_file9 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2424
2360
  var SpacesServiceImpl = class {
2361
+ _identityManager;
2362
+ _spaceManager;
2363
+ _getDataSpaceManager;
2364
+ constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
2365
+ this._identityManager = _identityManager;
2366
+ this._spaceManager = _spaceManager;
2367
+ this._getDataSpaceManager = _getDataSpaceManager;
2368
+ }
2425
2369
  async createSpace() {
2426
2370
  this._requireIdentity();
2427
2371
  const dataSpaceManager = await this._getDataSpaceManager();
@@ -2799,14 +2743,6 @@ var SpacesServiceImpl = class {
2799
2743
  });
2800
2744
  }
2801
2745
  }
2802
- constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
2803
- _define_property7(this, "_identityManager", void 0);
2804
- _define_property7(this, "_spaceManager", void 0);
2805
- _define_property7(this, "_getDataSpaceManager", void 0);
2806
- this._identityManager = _identityManager;
2807
- this._spaceManager = _spaceManager;
2808
- this._getDataSpaceManager = _getDataSpaceManager;
2809
- }
2810
2746
  };
2811
2747
  var getChannelId = (channel) => `user-channel/${channel}`;
2812
2748
 
@@ -2814,21 +2750,13 @@ var getChannelId = (channel) => `user-channel/${channel}`;
2814
2750
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2815
2751
  import { SpaceId as SpaceId2 } from "@dxos/keys";
2816
2752
  import { log as log8 } from "@dxos/log";
2817
- function _define_property8(obj, key, value) {
2818
- if (key in obj) {
2819
- Object.defineProperty(obj, key, {
2820
- value,
2821
- enumerable: true,
2822
- configurable: true,
2823
- writable: true
2824
- });
2825
- } else {
2826
- obj[key] = value;
2827
- }
2828
- return obj;
2829
- }
2830
2753
  var __dxlog_file10 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
2831
2754
  var DefaultSpaceStateMachine = class {
2755
+ _params;
2756
+ _spaceId;
2757
+ constructor(_params) {
2758
+ this._params = _params;
2759
+ }
2832
2760
  get spaceId() {
2833
2761
  return this._spaceId;
2834
2762
  }
@@ -2864,27 +2792,9 @@ var DefaultSpaceStateMachine = class {
2864
2792
  }
2865
2793
  }
2866
2794
  }
2867
- constructor(_params) {
2868
- _define_property8(this, "_params", void 0);
2869
- _define_property8(this, "_spaceId", void 0);
2870
- this._params = _params;
2871
- }
2872
2795
  };
2873
2796
 
2874
2797
  // src/packlets/identity/identity.ts
2875
- function _define_property9(obj, key, value) {
2876
- if (key in obj) {
2877
- Object.defineProperty(obj, key, {
2878
- value,
2879
- enumerable: true,
2880
- configurable: true,
2881
- writable: true
2882
- });
2883
- } else {
2884
- obj[key] = value;
2885
- }
2886
- return obj;
2887
- }
2888
2798
  function _ts_decorate3(decorators, target, key, desc) {
2889
2799
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2890
2800
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2893,6 +2803,58 @@ function _ts_decorate3(decorators, target, key, desc) {
2893
2803
  }
2894
2804
  var __dxlog_file11 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
2895
2805
  var Identity = class {
2806
+ space;
2807
+ _signer;
2808
+ _presence;
2809
+ _deviceStateMachine;
2810
+ _profileStateMachine;
2811
+ _defaultSpaceStateMachine;
2812
+ _edgeFeedReplicator = void 0;
2813
+ authVerifier;
2814
+ did;
2815
+ identityKey;
2816
+ deviceKey;
2817
+ stateUpdate = new Event3();
2818
+ constructor(params) {
2819
+ this.space = params.space;
2820
+ this._signer = params.signer;
2821
+ this._presence = params.presence;
2822
+ this.did = params.did;
2823
+ this.identityKey = params.identityKey;
2824
+ this.deviceKey = params.deviceKey;
2825
+ log9.trace("dxos.halo.device", {
2826
+ deviceKey: params.deviceKey
2827
+ }, {
2828
+ F: __dxlog_file11,
2829
+ L: 83,
2830
+ S: this,
2831
+ C: (f, a) => f(...a)
2832
+ });
2833
+ this._deviceStateMachine = new DeviceStateMachine({
2834
+ identityKey: this.identityKey,
2835
+ deviceKey: this.deviceKey,
2836
+ onUpdate: () => this.stateUpdate.emit()
2837
+ });
2838
+ this._profileStateMachine = new ProfileStateMachine({
2839
+ identityKey: this.identityKey,
2840
+ onUpdate: () => this.stateUpdate.emit()
2841
+ });
2842
+ this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
2843
+ identityKey: this.identityKey,
2844
+ onUpdate: () => this.stateUpdate.emit()
2845
+ });
2846
+ this.authVerifier = new TrustedKeySetAuthVerifier({
2847
+ trustedKeysProvider: () => new ComplexSet(PublicKey5.hash, this.authorizedDeviceKeys.keys()),
2848
+ update: this.stateUpdate,
2849
+ authTimeout: AUTH_TIMEOUT
2850
+ });
2851
+ if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
2852
+ this._edgeFeedReplicator = new EdgeFeedReplicator({
2853
+ messenger: params.edgeConnection,
2854
+ spaceId: this.space.id
2855
+ });
2856
+ }
2857
+ }
2896
2858
  // TODO(burdon): Expose state object?
2897
2859
  get authorizedDeviceKeys() {
2898
2860
  return this._deviceStateMachine.authorizedDeviceKeys;
@@ -3052,61 +3014,9 @@ var Identity = class {
3052
3014
  })));
3053
3015
  return deviceCredential;
3054
3016
  }
3055
- constructor(params) {
3056
- _define_property9(this, "space", void 0);
3057
- _define_property9(this, "_signer", void 0);
3058
- _define_property9(this, "_presence", void 0);
3059
- _define_property9(this, "_deviceStateMachine", void 0);
3060
- _define_property9(this, "_profileStateMachine", void 0);
3061
- _define_property9(this, "_defaultSpaceStateMachine", void 0);
3062
- _define_property9(this, "_edgeFeedReplicator", void 0);
3063
- _define_property9(this, "authVerifier", void 0);
3064
- _define_property9(this, "did", void 0);
3065
- _define_property9(this, "identityKey", void 0);
3066
- _define_property9(this, "deviceKey", void 0);
3067
- _define_property9(this, "stateUpdate", new Event3());
3068
- _define_property9(this, "_onFeedAdded", async (feed) => {
3069
- await this._edgeFeedReplicator.addFeed(feed);
3070
- });
3071
- this.space = params.space;
3072
- this._signer = params.signer;
3073
- this._presence = params.presence;
3074
- this.did = params.did;
3075
- this.identityKey = params.identityKey;
3076
- this.deviceKey = params.deviceKey;
3077
- log9.trace("dxos.halo.device", {
3078
- deviceKey: params.deviceKey
3079
- }, {
3080
- F: __dxlog_file11,
3081
- L: 83,
3082
- S: this,
3083
- C: (f, a) => f(...a)
3084
- });
3085
- this._deviceStateMachine = new DeviceStateMachine({
3086
- identityKey: this.identityKey,
3087
- deviceKey: this.deviceKey,
3088
- onUpdate: () => this.stateUpdate.emit()
3089
- });
3090
- this._profileStateMachine = new ProfileStateMachine({
3091
- identityKey: this.identityKey,
3092
- onUpdate: () => this.stateUpdate.emit()
3093
- });
3094
- this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
3095
- identityKey: this.identityKey,
3096
- onUpdate: () => this.stateUpdate.emit()
3097
- });
3098
- this.authVerifier = new TrustedKeySetAuthVerifier({
3099
- trustedKeysProvider: () => new ComplexSet(PublicKey5.hash, this.authorizedDeviceKeys.keys()),
3100
- update: this.stateUpdate,
3101
- authTimeout: AUTH_TIMEOUT
3102
- });
3103
- if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
3104
- this._edgeFeedReplicator = new EdgeFeedReplicator({
3105
- messenger: params.edgeConnection,
3106
- spaceId: this.space.id
3107
- });
3108
- }
3109
- }
3017
+ _onFeedAdded = async (feed) => {
3018
+ await this._edgeFeedReplicator.addFeed(feed);
3019
+ };
3110
3020
  };
3111
3021
  _ts_decorate3([
3112
3022
  trace3.span()
@@ -3133,19 +3043,6 @@ import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extensi
3133
3043
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
3134
3044
  import { trace as Trace2 } from "@dxos/tracing";
3135
3045
  import { deferFunction as deferFunction2, isNode } from "@dxos/util";
3136
- function _define_property10(obj, key, value) {
3137
- if (key in obj) {
3138
- Object.defineProperty(obj, key, {
3139
- value,
3140
- enumerable: true,
3141
- configurable: true,
3142
- writable: true
3143
- });
3144
- } else {
3145
- obj[key] = value;
3146
- }
3147
- return obj;
3148
- }
3149
3046
  function _ts_decorate4(decorators, target, key, desc) {
3150
3047
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3151
3048
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3156,6 +3053,27 @@ var __dxlog_file12 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/i
3156
3053
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3157
3054
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
3158
3055
  var IdentityManager = class {
3056
+ stateUpdate = new Event4();
3057
+ _metadataStore;
3058
+ _keyring;
3059
+ _feedStore;
3060
+ _spaceManager;
3061
+ _devicePresenceAnnounceInterval;
3062
+ _devicePresenceOfflineTimeout;
3063
+ _edgeConnection;
3064
+ _edgeFeatures;
3065
+ _identity;
3066
+ // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
3067
+ constructor(params) {
3068
+ this._metadataStore = params.metadataStore;
3069
+ this._keyring = params.keyring;
3070
+ this._feedStore = params.feedStore;
3071
+ this._spaceManager = params.spaceManager;
3072
+ this._edgeConnection = params.edgeConnection;
3073
+ this._edgeFeatures = params.edgeFeatures;
3074
+ this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
3075
+ this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
3076
+ }
3159
3077
  get identity() {
3160
3078
  return this._identity;
3161
3079
  }
@@ -3590,27 +3508,6 @@ var IdentityManager = class {
3590
3508
  }
3591
3509
  });
3592
3510
  }
3593
- // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
3594
- constructor(params) {
3595
- _define_property10(this, "stateUpdate", new Event4());
3596
- _define_property10(this, "_metadataStore", void 0);
3597
- _define_property10(this, "_keyring", void 0);
3598
- _define_property10(this, "_feedStore", void 0);
3599
- _define_property10(this, "_spaceManager", void 0);
3600
- _define_property10(this, "_devicePresenceAnnounceInterval", void 0);
3601
- _define_property10(this, "_devicePresenceOfflineTimeout", void 0);
3602
- _define_property10(this, "_edgeConnection", void 0);
3603
- _define_property10(this, "_edgeFeatures", void 0);
3604
- _define_property10(this, "_identity", void 0);
3605
- this._metadataStore = params.metadataStore;
3606
- this._keyring = params.keyring;
3607
- this._feedStore = params.feedStore;
3608
- this._spaceManager = params.spaceManager;
3609
- this._edgeConnection = params.edgeConnection;
3610
- this._edgeFeatures = params.edgeFeatures;
3611
- this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
3612
- this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
3613
- }
3614
3511
  };
3615
3512
  _ts_decorate4([
3616
3513
  Trace2.span({
@@ -3630,22 +3527,18 @@ import { invariant as invariant8 } from "@dxos/invariant";
3630
3527
  import { log as log11 } from "@dxos/log";
3631
3528
  import { SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
3632
3529
  import { safeAwaitAll } from "@dxos/util";
3633
- function _define_property11(obj, key, value) {
3634
- if (key in obj) {
3635
- Object.defineProperty(obj, key, {
3636
- value,
3637
- enumerable: true,
3638
- configurable: true,
3639
- writable: true
3640
- });
3641
- } else {
3642
- obj[key] = value;
3643
- }
3644
- return obj;
3645
- }
3646
3530
  var __dxlog_file13 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
3647
3531
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
3648
3532
  var IdentityServiceImpl = class extends Resource4 {
3533
+ _identityManager;
3534
+ _recoveryManager;
3535
+ _keyring;
3536
+ _dataSpaceManagerProvider;
3537
+ _createIdentity;
3538
+ _onProfileUpdate;
3539
+ constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
3540
+ super(), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
3541
+ }
3649
3542
  async _open() {
3650
3543
  const identity = this._identityManager.identity;
3651
3544
  if (identity && !identity.defaultSpaceId) {
@@ -3820,29 +3713,21 @@ var IdentityServiceImpl = class extends Resource4 {
3820
3713
  await this._createDefaultSpace(dataSpaceManager);
3821
3714
  }
3822
3715
  }
3823
- constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
3824
- super(), _define_property11(this, "_identityManager", void 0), _define_property11(this, "_recoveryManager", void 0), _define_property11(this, "_keyring", void 0), _define_property11(this, "_dataSpaceManagerProvider", void 0), _define_property11(this, "_createIdentity", void 0), _define_property11(this, "_onProfileUpdate", void 0), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
3825
- }
3826
3716
  };
3827
3717
 
3828
3718
  // src/packlets/spaces/automerge-space-state.ts
3829
3719
  import { Event as Event5 } from "@dxos/async";
3830
3720
  import { Resource as Resource5 } from "@dxos/context";
3831
3721
  import { checkCredentialType } from "@dxos/credentials";
3832
- function _define_property12(obj, key, value) {
3833
- if (key in obj) {
3834
- Object.defineProperty(obj, key, {
3835
- value,
3836
- enumerable: true,
3837
- configurable: true,
3838
- writable: true
3839
- });
3840
- } else {
3841
- obj[key] = value;
3842
- }
3843
- return obj;
3844
- }
3845
3722
  var AutomergeSpaceState = class extends Resource5 {
3723
+ _onNewRoot;
3724
+ rootUrl = void 0;
3725
+ lastEpoch = void 0;
3726
+ onNewEpoch = new Event5();
3727
+ _isProcessingRootDocs = false;
3728
+ constructor(_onNewRoot) {
3729
+ super(), this._onNewRoot = _onNewRoot;
3730
+ }
3846
3731
  async _open(ctx) {
3847
3732
  }
3848
3733
  async _close(ctx) {
@@ -3873,9 +3758,6 @@ var AutomergeSpaceState = class extends Resource5 {
3873
3758
  async ensureEpochInitialized() {
3874
3759
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3875
3760
  }
3876
- constructor(_onNewRoot) {
3877
- super(), _define_property12(this, "_onNewRoot", void 0), _define_property12(this, "rootUrl", void 0), _define_property12(this, "lastEpoch", void 0), _define_property12(this, "onNewEpoch", void 0), _define_property12(this, "_isProcessingRootDocs", void 0), this._onNewRoot = _onNewRoot, this.rootUrl = void 0, this.lastEpoch = void 0, this.onNewEpoch = new Event5(), this._isProcessingRootDocs = false;
3878
- }
3879
3761
  };
3880
3762
 
3881
3763
  // src/packlets/spaces/epoch-migrations.ts
@@ -3942,19 +3824,6 @@ import { EdgeCallFailedError } from "@dxos/protocols";
3942
3824
  import { schema as schema2 } from "@dxos/protocols/proto";
3943
3825
  import { RpcExtension } from "@dxos/teleport";
3944
3826
  import { ComplexMap as ComplexMap4, ComplexSet as ComplexSet2, entry } from "@dxos/util";
3945
- function _define_property13(obj, key, value) {
3946
- if (key in obj) {
3947
- Object.defineProperty(obj, key, {
3948
- value,
3949
- enumerable: true,
3950
- configurable: true,
3951
- writable: true
3952
- });
3953
- } else {
3954
- obj[key] = value;
3955
- }
3956
- return obj;
3957
- }
3958
3827
  function _ts_decorate5(decorators, target, key, desc) {
3959
3828
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3960
3829
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3970,6 +3839,24 @@ var MAX_EDGE_RETRIES = 2;
3970
3839
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3971
3840
  var credentialCodec = schema2.getCodecForType("dxos.halo.credentials.Credential");
3972
3841
  var NotarizationPlugin = class extends Resource6 {
3842
+ _extensionOpened = new Event6();
3843
+ _writer;
3844
+ _extensions = /* @__PURE__ */ new Set();
3845
+ _processedCredentials = new ComplexSet2(PublicKey7.hash);
3846
+ _processCredentialsTriggers = new ComplexMap4(PublicKey7.hash);
3847
+ _activeEdgePollingIntervalHandle = void 0;
3848
+ _activeEdgePollingInterval;
3849
+ _activeEdgePollingEnabled = false;
3850
+ _spaceId;
3851
+ _edgeClient;
3852
+ constructor(params) {
3853
+ super();
3854
+ this._spaceId = params.spaceId;
3855
+ this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
3856
+ if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
3857
+ this._edgeClient = params.edgeClient;
3858
+ }
3859
+ }
3973
3860
  setActiveEdgePollingEnabled(enabled) {
3974
3861
  const client = this._edgeClient;
3975
3862
  invariant10(client, void 0, {
@@ -4329,14 +4216,6 @@ var NotarizationPlugin = class extends Resource6 {
4329
4216
  errors.throw(new TimeoutError(timeout, "Notarization timed out"));
4330
4217
  }, timeout);
4331
4218
  }
4332
- constructor(params) {
4333
- super(), _define_property13(this, "_extensionOpened", new Event6()), _define_property13(this, "_writer", void 0), _define_property13(this, "_extensions", /* @__PURE__ */ new Set()), _define_property13(this, "_processedCredentials", new ComplexSet2(PublicKey7.hash)), _define_property13(this, "_processCredentialsTriggers", new ComplexMap4(PublicKey7.hash)), _define_property13(this, "_activeEdgePollingIntervalHandle", void 0), _define_property13(this, "_activeEdgePollingInterval", void 0), _define_property13(this, "_activeEdgePollingEnabled", false), _define_property13(this, "_spaceId", void 0), _define_property13(this, "_edgeClient", void 0);
4334
- this._spaceId = params.spaceId;
4335
- this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
4336
- if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
4337
- this._edgeClient = params.edgeClient;
4338
- }
4339
- }
4340
4219
  };
4341
4220
  _ts_decorate5([
4342
4221
  logInfo2
@@ -4361,6 +4240,17 @@ var handleEdgeError = (error) => {
4361
4240
  }
4362
4241
  };
4363
4242
  var NotarizationTeleportExtension = class extends RpcExtension {
4243
+ _params;
4244
+ constructor(_params) {
4245
+ super({
4246
+ requested: {
4247
+ NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4248
+ },
4249
+ exposed: {
4250
+ NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4251
+ }
4252
+ }), this._params = _params;
4253
+ }
4364
4254
  async getHandlers() {
4365
4255
  return {
4366
4256
  NotarizationService: {
@@ -4378,32 +4268,9 @@ var NotarizationTeleportExtension = class extends RpcExtension {
4378
4268
  await this._params.onClose();
4379
4269
  await super.onClose(err);
4380
4270
  }
4381
- constructor(_params) {
4382
- super({
4383
- requested: {
4384
- NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4385
- },
4386
- exposed: {
4387
- NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4388
- }
4389
- }), _define_property13(this, "_params", void 0), this._params = _params;
4390
- }
4391
4271
  };
4392
4272
 
4393
4273
  // src/packlets/spaces/data-space.ts
4394
- function _define_property14(obj, key, value) {
4395
- if (key in obj) {
4396
- Object.defineProperty(obj, key, {
4397
- value,
4398
- enumerable: true,
4399
- configurable: true,
4400
- writable: true
4401
- });
4402
- } else {
4403
- obj[key] = value;
4404
- }
4405
- return obj;
4406
- }
4407
4274
  function _ts_decorate6(decorators, target, key, desc) {
4408
4275
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4409
4276
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -4477,6 +4344,75 @@ function _ts_dispose_resources3(env) {
4477
4344
  }
4478
4345
  var __dxlog_file16 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4479
4346
  var DataSpace = class {
4347
+ _ctx = new Context6(void 0, {
4348
+ F: __dxlog_file16,
4349
+ L: 101
4350
+ });
4351
+ _inner;
4352
+ _gossip;
4353
+ _presence;
4354
+ _keyring;
4355
+ _feedStore;
4356
+ _metadataStore;
4357
+ _signingContext;
4358
+ _notarizationPlugin;
4359
+ _callbacks;
4360
+ _cache = void 0;
4361
+ _echoHost;
4362
+ _edgeFeedReplicator = void 0;
4363
+ // TODO(dmaretskyi): Move into Space?
4364
+ _automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
4365
+ _epochProcessingMutex = new Mutex2();
4366
+ _state = SpaceState4.SPACE_CLOSED;
4367
+ _databaseRoot = null;
4368
+ /**
4369
+ * Error for _state === SpaceState.SPACE_ERROR.
4370
+ */
4371
+ error = void 0;
4372
+ authVerifier;
4373
+ stateUpdate = new Event7();
4374
+ postOpen = new CallbackCollection();
4375
+ preClose = new CallbackCollection();
4376
+ metrics = {};
4377
+ constructor(params) {
4378
+ this._inner = params.inner;
4379
+ this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
4380
+ this._gossip = params.gossip;
4381
+ this._presence = params.presence;
4382
+ this._keyring = params.keyring;
4383
+ this._feedStore = params.feedStore;
4384
+ this._metadataStore = params.metadataStore;
4385
+ this._signingContext = params.signingContext;
4386
+ this._callbacks = params.callbacks ?? {};
4387
+ this._echoHost = params.echoHost;
4388
+ this._notarizationPlugin = new NotarizationPlugin({
4389
+ spaceId: this._inner.id,
4390
+ edgeClient: params.edgeHttpClient,
4391
+ edgeFeatures: params.edgeFeatures,
4392
+ activeEdgePollingInterval: params.activeEdgeNotarizationPollingInterval
4393
+ });
4394
+ this.authVerifier = new TrustedKeySetAuthVerifier({
4395
+ trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
4396
+ update: this._inner.stateUpdate,
4397
+ authTimeout: AUTH_TIMEOUT2
4398
+ });
4399
+ this._cache = params.cache;
4400
+ if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
4401
+ this._edgeFeedReplicator = new EdgeFeedReplicator({
4402
+ messenger: params.edgeConnection,
4403
+ spaceId: this.id
4404
+ });
4405
+ }
4406
+ this._state = params.initialState;
4407
+ log13("new state", {
4408
+ state: SpaceState4[this._state]
4409
+ }, {
4410
+ F: __dxlog_file16,
4411
+ L: 177,
4412
+ S: this,
4413
+ C: (f, a) => f(...a)
4414
+ });
4415
+ }
4480
4416
  get id() {
4481
4417
  return this._inner.id;
4482
4418
  }
@@ -4963,74 +4899,9 @@ var DataSpace = class {
4963
4899
  getEdgeReplicationSetting() {
4964
4900
  return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
4965
4901
  }
4966
- constructor(params) {
4967
- _define_property14(this, "_ctx", new Context6(void 0, {
4968
- F: __dxlog_file16,
4969
- L: 101
4970
- }));
4971
- _define_property14(this, "_inner", void 0);
4972
- _define_property14(this, "_gossip", void 0);
4973
- _define_property14(this, "_presence", void 0);
4974
- _define_property14(this, "_keyring", void 0);
4975
- _define_property14(this, "_feedStore", void 0);
4976
- _define_property14(this, "_metadataStore", void 0);
4977
- _define_property14(this, "_signingContext", void 0);
4978
- _define_property14(this, "_notarizationPlugin", void 0);
4979
- _define_property14(this, "_callbacks", void 0);
4980
- _define_property14(this, "_cache", void 0);
4981
- _define_property14(this, "_echoHost", void 0);
4982
- _define_property14(this, "_edgeFeedReplicator", void 0);
4983
- _define_property14(this, "_automergeSpaceState", new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl)));
4984
- _define_property14(this, "_epochProcessingMutex", new Mutex2());
4985
- _define_property14(this, "_state", SpaceState4.SPACE_CLOSED);
4986
- _define_property14(this, "_databaseRoot", null);
4987
- _define_property14(this, "error", void 0);
4988
- _define_property14(this, "authVerifier", void 0);
4989
- _define_property14(this, "stateUpdate", new Event7());
4990
- _define_property14(this, "postOpen", new CallbackCollection());
4991
- _define_property14(this, "preClose", new CallbackCollection());
4992
- _define_property14(this, "metrics", {});
4993
- _define_property14(this, "_onFeedAdded", async (feed) => {
4994
- await this._edgeFeedReplicator.addFeed(feed);
4995
- });
4996
- this._inner = params.inner;
4997
- this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
4998
- this._gossip = params.gossip;
4999
- this._presence = params.presence;
5000
- this._keyring = params.keyring;
5001
- this._feedStore = params.feedStore;
5002
- this._metadataStore = params.metadataStore;
5003
- this._signingContext = params.signingContext;
5004
- this._callbacks = params.callbacks ?? {};
5005
- this._echoHost = params.echoHost;
5006
- this._notarizationPlugin = new NotarizationPlugin({
5007
- spaceId: this._inner.id,
5008
- edgeClient: params.edgeHttpClient,
5009
- edgeFeatures: params.edgeFeatures,
5010
- activeEdgePollingInterval: params.activeEdgeNotarizationPollingInterval
5011
- });
5012
- this.authVerifier = new TrustedKeySetAuthVerifier({
5013
- trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
5014
- update: this._inner.stateUpdate,
5015
- authTimeout: AUTH_TIMEOUT2
5016
- });
5017
- this._cache = params.cache;
5018
- if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
5019
- this._edgeFeedReplicator = new EdgeFeedReplicator({
5020
- messenger: params.edgeConnection,
5021
- spaceId: this.id
5022
- });
5023
- }
5024
- this._state = params.initialState;
5025
- log13("new state", {
5026
- state: SpaceState4[this._state]
5027
- }, {
5028
- F: __dxlog_file16,
5029
- L: 177,
5030
- S: this,
5031
- C: (f, a) => f(...a)
5032
- });
5033
- }
4902
+ _onFeedAdded = async (feed) => {
4903
+ await this._edgeFeedReplicator.addFeed(feed);
4904
+ };
5034
4905
  };
5035
4906
  _ts_decorate6([
5036
4907
  trace5.info()
@@ -5086,21 +4957,16 @@ import { getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credent
5086
4957
  import { invariant as invariant12 } from "@dxos/invariant";
5087
4958
  import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
5088
4959
  import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
5089
- function _define_property15(obj, key, value) {
5090
- if (key in obj) {
5091
- Object.defineProperty(obj, key, {
5092
- value,
5093
- enumerable: true,
5094
- configurable: true,
5095
- writable: true
5096
- });
5097
- } else {
5098
- obj[key] = value;
5099
- }
5100
- return obj;
5101
- }
5102
4960
  var __dxlog_file17 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
5103
4961
  var DeviceInvitationProtocol = class {
4962
+ _keyring;
4963
+ _getIdentity;
4964
+ _acceptIdentity;
4965
+ constructor(_keyring, _getIdentity, _acceptIdentity) {
4966
+ this._keyring = _keyring;
4967
+ this._getIdentity = _getIdentity;
4968
+ this._acceptIdentity = _acceptIdentity;
4969
+ }
5104
4970
  toJSON() {
5105
4971
  return {
5106
4972
  kind: "device"
@@ -5212,14 +5078,6 @@ var DeviceInvitationProtocol = class {
5212
5078
  identityKey
5213
5079
  };
5214
5080
  }
5215
- constructor(_keyring, _getIdentity, _acceptIdentity) {
5216
- _define_property15(this, "_keyring", void 0);
5217
- _define_property15(this, "_getIdentity", void 0);
5218
- _define_property15(this, "_acceptIdentity", void 0);
5219
- this._keyring = _keyring;
5220
- this._getIdentity = _getIdentity;
5221
- this._acceptIdentity = _acceptIdentity;
5222
- }
5223
5081
  };
5224
5082
 
5225
5083
  // src/packlets/invitations/invitations-handler.ts
@@ -5274,24 +5132,22 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
5274
5132
  };
5275
5133
 
5276
5134
  // src/packlets/invitations/edge-invitation-handler.ts
5277
- function _define_property16(obj, key, value) {
5278
- if (key in obj) {
5279
- Object.defineProperty(obj, key, {
5280
- value,
5281
- enumerable: true,
5282
- configurable: true,
5283
- writable: true
5284
- });
5285
- } else {
5286
- obj[key] = value;
5287
- }
5288
- return obj;
5289
- }
5290
5135
  var __dxlog_file18 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
5291
5136
  var MAX_RETRIES_PER_INVITATION = 5;
5292
5137
  var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
5293
5138
  var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
5294
5139
  var EdgeInvitationHandler = class {
5140
+ _client;
5141
+ _callbacks;
5142
+ _flowLock;
5143
+ _retryInterval;
5144
+ _retryJitter;
5145
+ constructor(config, _client, _callbacks) {
5146
+ this._client = _client;
5147
+ this._callbacks = _callbacks;
5148
+ this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
5149
+ this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
5150
+ }
5295
5151
  handle(ctx, guardedState, protocol, deviceProfile) {
5296
5152
  if (!this._client) {
5297
5153
  log14("edge disabled", void 0, {
@@ -5434,17 +5290,6 @@ var EdgeInvitationHandler = class {
5434
5290
  _calculateNextRetryMs() {
5435
5291
  return this._retryInterval + Math.random() * this._retryJitter;
5436
5292
  }
5437
- constructor(config, _client, _callbacks) {
5438
- _define_property16(this, "_client", void 0);
5439
- _define_property16(this, "_callbacks", void 0);
5440
- _define_property16(this, "_flowLock", void 0);
5441
- _define_property16(this, "_retryInterval", void 0);
5442
- _define_property16(this, "_retryJitter", void 0);
5443
- this._client = _client;
5444
- this._callbacks = _callbacks;
5445
- this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
5446
- this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
5447
- }
5448
5293
  };
5449
5294
 
5450
5295
  // src/packlets/invitations/invitation-guest-extenstion.ts
@@ -5456,22 +5301,31 @@ import { InvalidInvitationExtensionRoleError } from "@dxos/protocols";
5456
5301
  import { schema as schema4 } from "@dxos/protocols/proto";
5457
5302
  import { InvitationOptions } from "@dxos/protocols/proto/dxos/halo/invitations";
5458
5303
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
5459
- function _define_property17(obj, key, value) {
5460
- if (key in obj) {
5461
- Object.defineProperty(obj, key, {
5462
- value,
5463
- enumerable: true,
5464
- configurable: true,
5465
- writable: true
5466
- });
5467
- } else {
5468
- obj[key] = value;
5469
- }
5470
- return obj;
5471
- }
5472
5304
  var __dxlog_file19 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
5473
5305
  var OPTIONS_TIMEOUT = 1e4;
5474
5306
  var InvitationGuestExtension = class extends RpcExtension2 {
5307
+ _invitationFlowMutex;
5308
+ _callbacks;
5309
+ _ctx = new Context7(void 0, {
5310
+ F: __dxlog_file19,
5311
+ L: 38
5312
+ });
5313
+ _remoteOptions;
5314
+ _remoteOptionsTrigger = new Trigger5();
5315
+ /**
5316
+ * Held to allow only one invitation flow at a time to be active.
5317
+ */
5318
+ _invitationFlowLock = null;
5319
+ constructor(_invitationFlowMutex, _callbacks) {
5320
+ super({
5321
+ requested: {
5322
+ InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5323
+ },
5324
+ exposed: {
5325
+ InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5326
+ }
5327
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks;
5328
+ }
5475
5329
  hasFlowLock() {
5476
5330
  return this._invitationFlowLock != null;
5477
5331
  }
@@ -5573,22 +5427,6 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5573
5427
  });
5574
5428
  }
5575
5429
  }
5576
- constructor(_invitationFlowMutex, _callbacks) {
5577
- super({
5578
- requested: {
5579
- InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5580
- },
5581
- exposed: {
5582
- InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5583
- }
5584
- }), _define_property17(this, "_invitationFlowMutex", void 0), _define_property17(this, "_callbacks", void 0), _define_property17(this, "_ctx", void 0), _define_property17(this, "_remoteOptions", void 0), _define_property17(this, "_remoteOptionsTrigger", void 0), /**
5585
- * Held to allow only one invitation flow at a time to be active.
5586
- */
5587
- _define_property17(this, "_invitationFlowLock", void 0), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context7(void 0, {
5588
- F: __dxlog_file19,
5589
- L: 38
5590
- }), this._remoteOptionsTrigger = new Trigger5(), this._invitationFlowLock = null;
5591
- }
5592
5430
  };
5593
5431
 
5594
5432
  // src/packlets/invitations/invitation-host-extension.ts
@@ -5603,26 +5441,49 @@ import { schema as schema5 } from "@dxos/protocols/proto";
5603
5441
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
5604
5442
  import { AuthenticationResponse, InvitationOptions as InvitationOptions2 } from "@dxos/protocols/proto/dxos/halo/invitations";
5605
5443
  import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
5606
- function _define_property18(obj, key, value) {
5607
- if (key in obj) {
5608
- Object.defineProperty(obj, key, {
5609
- value,
5610
- enumerable: true,
5611
- configurable: true,
5612
- writable: true
5613
- });
5614
- } else {
5615
- obj[key] = value;
5616
- }
5617
- return obj;
5618
- }
5619
5444
  var __dxlog_file20 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
5620
5445
  var OPTIONS_TIMEOUT2 = 1e4;
5621
5446
  var MAX_OTP_ATTEMPTS = 3;
5622
5447
  var InvitationHostExtension = class extends RpcExtension3 {
5623
- hasFlowLock() {
5624
- return this._invitationFlowLock != null;
5625
- }
5448
+ _invitationFlowMutex;
5449
+ _callbacks;
5450
+ /**
5451
+ * @internal
5452
+ */
5453
+ _ctx = new Context8(void 0, {
5454
+ F: __dxlog_file20,
5455
+ L: 57
5456
+ });
5457
+ _remoteOptions;
5458
+ _remoteOptionsTrigger = new Trigger6();
5459
+ _challenge = void 0;
5460
+ guestProfile = void 0;
5461
+ authenticationPassed = false;
5462
+ /**
5463
+ * Retry counter for SHARED_SECRET authentication method.
5464
+ */
5465
+ authenticationRetry = 0;
5466
+ /**
5467
+ * Resolved when admission is completed.
5468
+ */
5469
+ completedTrigger = new Trigger6();
5470
+ /**
5471
+ * Held to allow only one invitation flow at a time to be active.
5472
+ */
5473
+ _invitationFlowLock = null;
5474
+ constructor(_invitationFlowMutex, _callbacks) {
5475
+ super({
5476
+ requested: {
5477
+ InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5478
+ },
5479
+ exposed: {
5480
+ InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5481
+ }
5482
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks;
5483
+ }
5484
+ hasFlowLock() {
5485
+ return this._invitationFlowLock != null;
5486
+ }
5626
5487
  async getHandlers() {
5627
5488
  return {
5628
5489
  // TODO(dmaretskyi): For now this is just forwarding the data to callbacks since we don't have session-specific logic.
@@ -5920,31 +5781,6 @@ var InvitationHostExtension = class extends RpcExtension3 {
5920
5781
  });
5921
5782
  }
5922
5783
  }
5923
- constructor(_invitationFlowMutex, _callbacks) {
5924
- super({
5925
- requested: {
5926
- InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5927
- },
5928
- exposed: {
5929
- InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5930
- }
5931
- }), _define_property18(this, "_invitationFlowMutex", void 0), _define_property18(this, "_callbacks", void 0), /**
5932
- * @internal
5933
- */
5934
- _define_property18(this, "_ctx", void 0), _define_property18(this, "_remoteOptions", void 0), _define_property18(this, "_remoteOptionsTrigger", void 0), _define_property18(this, "_challenge", void 0), _define_property18(this, "guestProfile", void 0), _define_property18(this, "authenticationPassed", void 0), /**
5935
- * Retry counter for SHARED_SECRET authentication method.
5936
- */
5937
- _define_property18(this, "authenticationRetry", void 0), /**
5938
- * Resolved when admission is completed.
5939
- */
5940
- _define_property18(this, "completedTrigger", void 0), /**
5941
- * Held to allow only one invitation flow at a time to be active.
5942
- */
5943
- _define_property18(this, "_invitationFlowLock", void 0), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context8(void 0, {
5944
- F: __dxlog_file20,
5945
- L: 57
5946
- }), this._remoteOptionsTrigger = new Trigger6(), this._challenge = void 0, this.guestProfile = void 0, this.authenticationPassed = false, this.authenticationRetry = 0, this.completedTrigger = new Trigger6(), this._invitationFlowLock = null;
5947
- }
5948
5784
  };
5949
5785
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation5.AuthMethod.NONE;
5950
5786
 
@@ -6050,21 +5886,22 @@ import { PublicKey as PublicKey10 } from "@dxos/keys";
6050
5886
  import { log as log18 } from "@dxos/log";
6051
5887
  import { InvitationOptions as InvitationOptions3 } from "@dxos/protocols/proto/dxos/halo/invitations";
6052
5888
  import { ComplexSet as ComplexSet4 } from "@dxos/util";
6053
- function _define_property19(obj, key, value) {
6054
- if (key in obj) {
6055
- Object.defineProperty(obj, key, {
6056
- value,
6057
- enumerable: true,
6058
- configurable: true,
6059
- writable: true
6060
- });
6061
- } else {
6062
- obj[key] = value;
6063
- }
6064
- return obj;
6065
- }
6066
5889
  var __dxlog_file22 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
6067
5890
  var InvitationTopology = class {
5891
+ _role;
5892
+ _controller;
5893
+ /**
5894
+ * Peers we tried to establish a connection with.
5895
+ * In invitation flow peers are assigned random ids when they join the swarm, so we'll retry
5896
+ * a peer if they reload an invitation.
5897
+ *
5898
+ * Consider keeping a separate set for peers we know are hosts and have some retry timeout
5899
+ * for guests we failed an invitation flow with (potentially due to a network error).
5900
+ */
5901
+ _seenPeers = new ComplexSet4(PublicKey10.hash);
5902
+ constructor(_role) {
5903
+ this._role = _role;
5904
+ }
6068
5905
  init(controller) {
6069
5906
  invariant16(!this._controller, "Already initialized.", {
6070
5907
  F: __dxlog_file22,
@@ -6129,33 +5966,24 @@ var InvitationTopology = class {
6129
5966
  toString() {
6130
5967
  return `InvitationTopology(${this._role === InvitationOptions3.Role.GUEST ? "guest" : "host"})`;
6131
5968
  }
6132
- constructor(_role) {
6133
- _define_property19(this, "_role", void 0);
6134
- _define_property19(this, "_controller", void 0);
6135
- _define_property19(this, "_seenPeers", void 0);
6136
- this._role = _role;
6137
- this._seenPeers = new ComplexSet4(PublicKey10.hash);
6138
- }
6139
5969
  };
6140
5970
 
6141
5971
  // src/packlets/invitations/invitations-handler.ts
6142
- function _define_property20(obj, key, value) {
6143
- if (key in obj) {
6144
- Object.defineProperty(obj, key, {
6145
- value,
6146
- enumerable: true,
6147
- configurable: true,
6148
- writable: true
6149
- });
6150
- } else {
6151
- obj[key] = value;
6152
- }
6153
- return obj;
6154
- }
6155
5972
  var __dxlog_file23 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
6156
5973
  var metrics = _trace.metrics;
6157
5974
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
6158
5975
  var InvitationsHandler = class {
5976
+ _networkManager;
5977
+ _edgeClient;
5978
+ _connectionParams;
5979
+ /**
5980
+ * @internal
5981
+ */
5982
+ constructor(_networkManager, _edgeClient, _connectionParams) {
5983
+ this._networkManager = _networkManager;
5984
+ this._edgeClient = _edgeClient;
5985
+ this._connectionParams = _connectionParams;
5986
+ }
6159
5987
  handleInvitationFlow(ctx, stream, protocol, invitation) {
6160
5988
  log19.verbose("dxos.sdk.invitations-handler.handleInvitationFlow", {
6161
5989
  state: invitation.state,
@@ -6726,17 +6554,6 @@ var InvitationsHandler = class {
6726
6554
  throw new Error(`Authentication failed with code: ${response.status}`);
6727
6555
  }
6728
6556
  }
6729
- /**
6730
- * @internal
6731
- */
6732
- constructor(_networkManager, _edgeClient, _connectionParams) {
6733
- _define_property20(this, "_networkManager", void 0);
6734
- _define_property20(this, "_edgeClient", void 0);
6735
- _define_property20(this, "_connectionParams", void 0);
6736
- this._networkManager = _networkManager;
6737
- this._edgeClient = _edgeClient;
6738
- this._connectionParams = _connectionParams;
6739
- }
6740
6557
  };
6741
6558
  var checkInvitation = (protocol, invitation) => {
6742
6559
  const expiresOn = getExpirationTime(invitation);
@@ -6757,20 +6574,11 @@ var createAdmissionKeypair = () => {
6757
6574
  import { Stream as Stream9 } from "@dxos/codec-protobuf/stream";
6758
6575
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
6759
6576
  import { trace as trace8 } from "@dxos/tracing";
6760
- function _define_property21(obj, key, value) {
6761
- if (key in obj) {
6762
- Object.defineProperty(obj, key, {
6763
- value,
6764
- enumerable: true,
6765
- configurable: true,
6766
- writable: true
6767
- });
6768
- } else {
6769
- obj[key] = value;
6770
- }
6771
- return obj;
6772
- }
6773
6577
  var InvitationsServiceImpl = class {
6578
+ _invitationsManager;
6579
+ constructor(_invitationsManager) {
6580
+ this._invitationsManager = _invitationsManager;
6581
+ }
6774
6582
  // TODO(burdon): Guest/host label.
6775
6583
  getLoggingContext() {
6776
6584
  return {};
@@ -6862,10 +6670,6 @@ var InvitationsServiceImpl = class {
6862
6670
  });
6863
6671
  });
6864
6672
  }
6865
- constructor(_invitationsManager) {
6866
- _define_property21(this, "_invitationsManager", void 0);
6867
- this._invitationsManager = _invitationsManager;
6868
- }
6869
6673
  };
6870
6674
 
6871
6675
  // src/packlets/invitations/space-invitation-protocol.ts
@@ -6876,21 +6680,18 @@ import { log as log20 } from "@dxos/log";
6876
6680
  import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError as InvalidInvitationError2, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
6877
6681
  import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
6878
6682
  import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
6879
- function _define_property22(obj, key, value) {
6880
- if (key in obj) {
6881
- Object.defineProperty(obj, key, {
6882
- value,
6883
- enumerable: true,
6884
- configurable: true,
6885
- writable: true
6886
- });
6887
- } else {
6888
- obj[key] = value;
6889
- }
6890
- return obj;
6891
- }
6892
6683
  var __dxlog_file24 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
6893
6684
  var SpaceInvitationProtocol = class {
6685
+ _spaceManager;
6686
+ _signingContext;
6687
+ _keyring;
6688
+ _spaceKey;
6689
+ constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
6690
+ this._spaceManager = _spaceManager;
6691
+ this._signingContext = _signingContext;
6692
+ this._keyring = _keyring;
6693
+ this._spaceKey = _spaceKey;
6694
+ }
6894
6695
  toJSON() {
6895
6696
  return {
6896
6697
  kind: "space",
@@ -7155,16 +6956,6 @@ var SpaceInvitationProtocol = class {
7155
6956
  spaceKey: assertion.spaceKey
7156
6957
  };
7157
6958
  }
7158
- constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
7159
- _define_property22(this, "_spaceManager", void 0);
7160
- _define_property22(this, "_signingContext", void 0);
7161
- _define_property22(this, "_keyring", void 0);
7162
- _define_property22(this, "_spaceKey", void 0);
7163
- this._spaceManager = _spaceManager;
7164
- this._signingContext = _signingContext;
7165
- this._keyring = _keyring;
7166
- this._spaceKey = _spaceKey;
7167
- }
7168
6959
  };
7169
6960
 
7170
6961
  // src/packlets/invitations/invitations-manager.ts
@@ -7178,21 +6969,25 @@ import { PublicKey as PublicKey12 } from "@dxos/keys";
7178
6969
  import { log as log21 } from "@dxos/log";
7179
6970
  import { Invitation as Invitation9 } from "@dxos/protocols/proto/dxos/client/services";
7180
6971
  import { SpaceMember as SpaceMember7 } from "@dxos/protocols/proto/dxos/halo/credentials";
7181
- function _define_property23(obj, key, value) {
7182
- if (key in obj) {
7183
- Object.defineProperty(obj, key, {
7184
- value,
7185
- enumerable: true,
7186
- configurable: true,
7187
- writable: true
7188
- });
7189
- } else {
7190
- obj[key] = value;
7191
- }
7192
- return obj;
7193
- }
7194
6972
  var __dxlog_file25 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
7195
6973
  var InvitationsManager = class {
6974
+ _invitationsHandler;
6975
+ _getHandler;
6976
+ _metadataStore;
6977
+ _createInvitations = /* @__PURE__ */ new Map();
6978
+ _acceptInvitations = /* @__PURE__ */ new Map();
6979
+ invitationCreated = new Event8();
6980
+ invitationAccepted = new Event8();
6981
+ removedCreated = new Event8();
6982
+ removedAccepted = new Event8();
6983
+ saved = new Event8();
6984
+ _persistentInvitationsLoadedEvent = new Event8();
6985
+ _persistentInvitationsLoaded = false;
6986
+ constructor(_invitationsHandler, _getHandler, _metadataStore) {
6987
+ this._invitationsHandler = _invitationsHandler;
6988
+ this._getHandler = _getHandler;
6989
+ this._metadataStore = _metadataStore;
6990
+ }
7196
6991
  async createInvitation(options) {
7197
6992
  if (options.invitationId) {
7198
6993
  const existingInvitation = this._createInvitations.get(options.invitationId);
@@ -7536,51 +7331,12 @@ var InvitationsManager = class {
7536
7331
  }, () => {
7537
7332
  }, callback);
7538
7333
  }
7539
- constructor(_invitationsHandler, _getHandler, _metadataStore) {
7540
- _define_property23(this, "_invitationsHandler", void 0);
7541
- _define_property23(this, "_getHandler", void 0);
7542
- _define_property23(this, "_metadataStore", void 0);
7543
- _define_property23(this, "_createInvitations", void 0);
7544
- _define_property23(this, "_acceptInvitations", void 0);
7545
- _define_property23(this, "invitationCreated", void 0);
7546
- _define_property23(this, "invitationAccepted", void 0);
7547
- _define_property23(this, "removedCreated", void 0);
7548
- _define_property23(this, "removedAccepted", void 0);
7549
- _define_property23(this, "saved", void 0);
7550
- _define_property23(this, "_persistentInvitationsLoadedEvent", void 0);
7551
- _define_property23(this, "_persistentInvitationsLoaded", void 0);
7552
- this._invitationsHandler = _invitationsHandler;
7553
- this._getHandler = _getHandler;
7554
- this._metadataStore = _metadataStore;
7555
- this._createInvitations = /* @__PURE__ */ new Map();
7556
- this._acceptInvitations = /* @__PURE__ */ new Map();
7557
- this.invitationCreated = new Event8();
7558
- this.invitationAccepted = new Event8();
7559
- this.removedCreated = new Event8();
7560
- this.removedAccepted = new Event8();
7561
- this.saved = new Event8();
7562
- this._persistentInvitationsLoadedEvent = new Event8();
7563
- this._persistentInvitationsLoaded = false;
7564
- }
7565
7334
  };
7566
7335
 
7567
7336
  // src/packlets/locks/browser.ts
7568
7337
  import { Trigger as Trigger8, asyncTimeout as asyncTimeout2 } from "@dxos/async";
7569
7338
  import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
7570
7339
  import { log as log22, logInfo as logInfo3 } from "@dxos/log";
7571
- function _define_property24(obj, key, value) {
7572
- if (key in obj) {
7573
- Object.defineProperty(obj, key, {
7574
- value,
7575
- enumerable: true,
7576
- configurable: true,
7577
- writable: true
7578
- });
7579
- } else {
7580
- obj[key] = value;
7581
- }
7582
- return obj;
7583
- }
7584
7340
  function _ts_decorate7(decorators, target, key, desc) {
7585
7341
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7586
7342
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7589,6 +7345,17 @@ function _ts_decorate7(decorators, target, key, desc) {
7589
7345
  }
7590
7346
  var __dxlog_file26 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
7591
7347
  var Lock = class {
7348
+ _broadcastChannel = new BroadcastChannel("vault-resource-lock");
7349
+ _lockKey;
7350
+ _onAcquire;
7351
+ _onRelease;
7352
+ _releaseTrigger = new Trigger8();
7353
+ constructor({ lockKey, onAcquire, onRelease }) {
7354
+ this._lockKey = lockKey;
7355
+ this._onAcquire = onAcquire;
7356
+ this._onRelease = onRelease;
7357
+ this._broadcastChannel.onmessage = this._onMessage.bind(this);
7358
+ }
7592
7359
  get lockKey() {
7593
7360
  return this._lockKey;
7594
7361
  }
@@ -7677,17 +7444,6 @@ var Lock = class {
7677
7444
  C: (f, a) => f(...a)
7678
7445
  });
7679
7446
  }
7680
- constructor({ lockKey, onAcquire, onRelease }) {
7681
- _define_property24(this, "_broadcastChannel", new BroadcastChannel("vault-resource-lock"));
7682
- _define_property24(this, "_lockKey", void 0);
7683
- _define_property24(this, "_onAcquire", void 0);
7684
- _define_property24(this, "_onRelease", void 0);
7685
- _define_property24(this, "_releaseTrigger", new Trigger8());
7686
- this._lockKey = lockKey;
7687
- this._onAcquire = onAcquire;
7688
- this._onRelease = onRelease;
7689
- this._broadcastChannel.onmessage = this._onMessage.bind(this);
7690
- }
7691
7447
  };
7692
7448
  _ts_decorate7([
7693
7449
  logInfo3
@@ -7701,19 +7457,6 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
7701
7457
  import { raise as raise2 } from "@dxos/debug";
7702
7458
  import { RpcPeer, parseMethodName } from "@dxos/rpc";
7703
7459
  import { MapCounter, trace as trace9 } from "@dxos/tracing";
7704
- function _define_property25(obj, key, value) {
7705
- if (key in obj) {
7706
- Object.defineProperty(obj, key, {
7707
- value,
7708
- enumerable: true,
7709
- configurable: true,
7710
- writable: true
7711
- });
7712
- } else {
7713
- obj[key] = value;
7714
- }
7715
- return obj;
7716
- }
7717
7460
  function _ts_decorate8(decorators, target, key, desc) {
7718
7461
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7719
7462
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7721,33 +7464,16 @@ function _ts_decorate8(decorators, target, key, desc) {
7721
7464
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7722
7465
  }
7723
7466
  var ClientRpcServer = class {
7467
+ _serviceRegistry;
7468
+ _rpcPeer;
7469
+ _handlerCache = /* @__PURE__ */ new Map();
7470
+ _handleCall;
7471
+ _handleStream;
7472
+ _callMetrics = new MapCounter();
7724
7473
  get _services() {
7725
7474
  return Object.keys(this._serviceRegistry.services);
7726
7475
  }
7727
- async open() {
7728
- await this._rpcPeer.open();
7729
- }
7730
- async close() {
7731
- await this._rpcPeer.close();
7732
- }
7733
- _getServiceHandler(serviceName) {
7734
- if (!this._handlerCache.has(serviceName)) {
7735
- const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise2(new Error(`Service not available: ${serviceName}`));
7736
- const service = this._serviceRegistry.services[key];
7737
- if (!service) {
7738
- throw new Error(`Service not available: ${serviceName}`);
7739
- }
7740
- this._handlerCache.set(serviceName, descriptor.createServer(service));
7741
- }
7742
- return this._handlerCache.get(serviceName);
7743
- }
7744
7476
  constructor(params) {
7745
- _define_property25(this, "_serviceRegistry", void 0);
7746
- _define_property25(this, "_rpcPeer", void 0);
7747
- _define_property25(this, "_handlerCache", /* @__PURE__ */ new Map());
7748
- _define_property25(this, "_handleCall", void 0);
7749
- _define_property25(this, "_handleStream", void 0);
7750
- _define_property25(this, "_callMetrics", new MapCounter());
7751
7477
  const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
7752
7478
  this._handleCall = handleCall;
7753
7479
  this._handleStream = handleStream;
@@ -7779,6 +7505,23 @@ var ClientRpcServer = class {
7779
7505
  }
7780
7506
  });
7781
7507
  }
7508
+ async open() {
7509
+ await this._rpcPeer.open();
7510
+ }
7511
+ async close() {
7512
+ await this._rpcPeer.close();
7513
+ }
7514
+ _getServiceHandler(serviceName) {
7515
+ if (!this._handlerCache.has(serviceName)) {
7516
+ const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise2(new Error(`Service not available: ${serviceName}`));
7517
+ const service = this._serviceRegistry.services[key];
7518
+ if (!service) {
7519
+ throw new Error(`Service not available: ${serviceName}`);
7520
+ }
7521
+ this._handlerCache.set(serviceName, descriptor.createServer(service));
7522
+ }
7523
+ return this._handlerCache.get(serviceName);
7524
+ }
7782
7525
  };
7783
7526
  _ts_decorate8([
7784
7527
  trace9.metricsCounter()
@@ -7799,19 +7542,6 @@ import { log as log23 } from "@dxos/log";
7799
7542
  import { EdgeAgentStatus, EdgeCallFailedError as EdgeCallFailedError3 } from "@dxos/protocols";
7800
7543
  import { SpaceState as SpaceState5 } from "@dxos/protocols/proto/dxos/client/services";
7801
7544
  import { EdgeReplicationSetting as EdgeReplicationSetting2 } from "@dxos/protocols/proto/dxos/echo/metadata";
7802
- function _define_property26(obj, key, value) {
7803
- if (key in obj) {
7804
- Object.defineProperty(obj, key, {
7805
- value,
7806
- enumerable: true,
7807
- configurable: true,
7808
- writable: true
7809
- });
7810
- } else {
7811
- obj[key] = value;
7812
- }
7813
- return obj;
7814
- }
7815
7545
  function _ts_decorate9(decorators, target, key, desc) {
7816
7546
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7817
7547
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7823,6 +7553,18 @@ var AGENT_STATUS_QUERY_RETRY_INTERVAL = 5e3;
7823
7553
  var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
7824
7554
  var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
7825
7555
  var EdgeAgentManager = class extends Resource7 {
7556
+ _edgeFeatures;
7557
+ _edgeHttpClient;
7558
+ _dataSpaceManager;
7559
+ _identity;
7560
+ agentStatusChanged = new Event9();
7561
+ _agentDeviceKey;
7562
+ _agentStatus;
7563
+ _lastKnownDeviceCount = 0;
7564
+ _fetchAgentStatusTask;
7565
+ constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7566
+ super(), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity;
7567
+ }
7826
7568
  get agentStatus() {
7827
7569
  return this._agentStatus;
7828
7570
  }
@@ -8031,9 +7773,6 @@ var EdgeAgentManager = class extends Resource7 {
8031
7773
  C: (f, a) => f(...a)
8032
7774
  });
8033
7775
  }
8034
- constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
8035
- super(), _define_property26(this, "_edgeFeatures", void 0), _define_property26(this, "_edgeHttpClient", void 0), _define_property26(this, "_dataSpaceManager", void 0), _define_property26(this, "_identity", void 0), _define_property26(this, "agentStatusChanged", void 0), _define_property26(this, "_agentDeviceKey", void 0), _define_property26(this, "_agentStatus", void 0), _define_property26(this, "_lastKnownDeviceCount", void 0), _define_property26(this, "_fetchAgentStatusTask", void 0), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity, this.agentStatusChanged = new Event9(), this._lastKnownDeviceCount = 0;
8036
- }
8037
7776
  };
8038
7777
  _ts_decorate9([
8039
7778
  synchronized3
@@ -8043,26 +7782,27 @@ _ts_decorate9([
8043
7782
  import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
8044
7783
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
8045
7784
  import { EdgeStatus as EdgeStatus2, QueryAgentStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
8046
- function _define_property27(obj, key, value) {
8047
- if (key in obj) {
8048
- Object.defineProperty(obj, key, {
8049
- value,
8050
- enumerable: true,
8051
- configurable: true,
8052
- writable: true
8053
- });
8054
- } else {
8055
- obj[key] = value;
8056
- }
8057
- return obj;
8058
- }
8059
7785
  var EdgeAgentServiceImpl = class {
7786
+ _agentManagerProvider;
7787
+ _edgeConnection;
7788
+ constructor(_agentManagerProvider, _edgeConnection) {
7789
+ this._agentManagerProvider = _agentManagerProvider;
7790
+ this._edgeConnection = _edgeConnection;
7791
+ }
8060
7792
  // TODO(mykola): Reconcile with NetworkService.queryStatus.
8061
7793
  queryEdgeStatus() {
8062
7794
  return new Stream11(({ ctx, next }) => {
8063
7795
  const update = () => {
8064
7796
  next({
8065
- status: this._edgeConnection?.status ?? EdgeStatus2.NOT_CONNECTED
7797
+ status: this._edgeConnection?.status ?? {
7798
+ state: EdgeStatus2.ConnectionState.NOT_CONNECTED,
7799
+ rtt: 0,
7800
+ uptime: 0,
7801
+ rateBytesUp: 0,
7802
+ rateBytesDown: 0,
7803
+ messagesSent: 0,
7804
+ messagesReceived: 0
7805
+ }
8066
7806
  });
8067
7807
  };
8068
7808
  this._edgeConnection?.statusChanged.on(ctx, update);
@@ -8089,12 +7829,6 @@ var EdgeAgentServiceImpl = class {
8089
7829
  });
8090
7830
  });
8091
7831
  }
8092
- constructor(_agentManagerProvider, _edgeConnection) {
8093
- _define_property27(this, "_agentManagerProvider", void 0);
8094
- _define_property27(this, "_edgeConnection", void 0);
8095
- this._agentManagerProvider = _agentManagerProvider;
8096
- this._edgeConnection = _edgeConnection;
8097
- }
8098
7832
  };
8099
7833
  var mapStatus = (agentStatus) => {
8100
7834
  switch (agentStatus) {
@@ -8136,21 +7870,18 @@ import { log as log24 } from "@dxos/log";
8136
7870
  import { EdgeAuthChallengeError as EdgeAuthChallengeError2 } from "@dxos/protocols";
8137
7871
  import { schema as schema6 } from "@dxos/protocols/proto";
8138
7872
  import { Timeframe as Timeframe5 } from "@dxos/timeframe";
8139
- function _define_property28(obj, key, value) {
8140
- if (key in obj) {
8141
- Object.defineProperty(obj, key, {
8142
- value,
8143
- enumerable: true,
8144
- configurable: true,
8145
- writable: true
8146
- });
8147
- } else {
8148
- obj[key] = value;
8149
- }
8150
- return obj;
8151
- }
8152
7873
  var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts";
8153
7874
  var EdgeIdentityRecoveryManager = class {
7875
+ _keyring;
7876
+ _edgeClient;
7877
+ _identityProvider;
7878
+ _acceptRecoveredIdentity;
7879
+ constructor(_keyring, _edgeClient, _identityProvider, _acceptRecoveredIdentity) {
7880
+ this._keyring = _keyring;
7881
+ this._edgeClient = _edgeClient;
7882
+ this._identityProvider = _identityProvider;
7883
+ this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
7884
+ }
8154
7885
  async createRecoveryCredential({ data }) {
8155
7886
  const identity = this._identityProvider();
8156
7887
  invariant21(identity, void 0, {
@@ -8343,16 +8074,6 @@ var EdgeIdentityRecoveryManager = class {
8343
8074
  dataFeedKey: await this._keyring.createKey()
8344
8075
  });
8345
8076
  }
8346
- constructor(_keyring, _edgeClient, _identityProvider, _acceptRecoveredIdentity) {
8347
- _define_property28(this, "_keyring", void 0);
8348
- _define_property28(this, "_edgeClient", void 0);
8349
- _define_property28(this, "_identityProvider", void 0);
8350
- _define_property28(this, "_acceptRecoveredIdentity", void 0);
8351
- this._keyring = _keyring;
8352
- this._edgeClient = _edgeClient;
8353
- this._identityProvider = _identityProvider;
8354
- this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
8355
- }
8356
8077
  };
8357
8078
  var decodeCredential = (credentialBase64) => {
8358
8079
  const credentialBytes = Buffer.from(credentialBase64, "base64");
@@ -8361,19 +8082,6 @@ var decodeCredential = (credentialBase64) => {
8361
8082
  };
8362
8083
 
8363
8084
  // src/packlets/services/service-context.ts
8364
- function _define_property29(obj, key, value) {
8365
- if (key in obj) {
8366
- Object.defineProperty(obj, key, {
8367
- value,
8368
- enumerable: true,
8369
- configurable: true,
8370
- writable: true
8371
- });
8372
- } else {
8373
- obj[key] = value;
8374
- }
8375
- return obj;
8376
- }
8377
8085
  function _ts_decorate10(decorators, target, key, desc) {
8378
8086
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8379
8087
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -8447,25 +8155,108 @@ function _ts_dispose_resources4(env) {
8447
8155
  }
8448
8156
  var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
8449
8157
  var ServiceContext = class extends Resource8 {
8450
- async _open(ctx) {
8451
- await this._checkStorageVersion();
8452
- log25("opening...", void 0, {
8453
- F: __dxlog_file29,
8454
- L: 204,
8455
- S: this,
8456
- C: (f, a) => f(...a)
8158
+ storage;
8159
+ level;
8160
+ networkManager;
8161
+ signalManager;
8162
+ _edgeConnection;
8163
+ _edgeHttpClient;
8164
+ _runtimeParams;
8165
+ _edgeFeatures;
8166
+ _edgeIdentityUpdateMutex = new Mutex4();
8167
+ initialized = new Trigger9();
8168
+ metadataStore;
8169
+ blobStore;
8170
+ feedStore;
8171
+ keyring;
8172
+ spaceManager;
8173
+ identityManager;
8174
+ recoveryManager;
8175
+ invitations;
8176
+ invitationsManager;
8177
+ echoHost;
8178
+ _meshReplicator = void 0;
8179
+ _echoEdgeReplicator = void 0;
8180
+ // Initialized after identity is initialized.
8181
+ dataSpaceManager;
8182
+ edgeAgentManager;
8183
+ _handlerFactories = /* @__PURE__ */ new Map();
8184
+ _deviceSpaceSync;
8185
+ _instanceId = PublicKey15.random().toHex();
8186
+ constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
8187
+ super(), this.storage = storage, this.level = level, this.networkManager = networkManager, this.signalManager = signalManager, this._edgeConnection = _edgeConnection, this._edgeHttpClient = _edgeHttpClient, this._runtimeParams = _runtimeParams, this._edgeFeatures = _edgeFeatures;
8188
+ this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
8189
+ this.blobStore = new BlobStore(storage.createDirectory("blobs"));
8190
+ this.keyring = new Keyring(storage.createDirectory("keyring"));
8191
+ this.feedStore = new FeedStore({
8192
+ factory: new FeedFactory({
8193
+ root: storage.createDirectory("feeds"),
8194
+ signer: this.keyring,
8195
+ hypercore: {
8196
+ valueEncoding,
8197
+ stats: true
8198
+ }
8199
+ })
8457
8200
  });
8458
- log25.trace("dxos.sdk.service-context.open", trace10.begin({
8459
- id: this._instanceId
8460
- }), {
8461
- F: __dxlog_file29,
8462
- L: 205,
8463
- S: this,
8464
- C: (f, a) => f(...a)
8201
+ this.spaceManager = new SpaceManager({
8202
+ feedStore: this.feedStore,
8203
+ networkManager: this.networkManager,
8204
+ blobStore: this.blobStore,
8205
+ metadataStore: this.metadataStore,
8206
+ disableP2pReplication: this._runtimeParams?.disableP2pReplication
8465
8207
  });
8466
- await this.identityManager.open(ctx);
8467
- await this._setNetworkIdentity();
8468
- await this._edgeConnection?.open();
8208
+ this.identityManager = new IdentityManager({
8209
+ metadataStore: this.metadataStore,
8210
+ keyring: this.keyring,
8211
+ feedStore: this.feedStore,
8212
+ spaceManager: this.spaceManager,
8213
+ devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
8214
+ devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
8215
+ edgeConnection: this._edgeConnection,
8216
+ edgeFeatures: this._edgeFeatures
8217
+ });
8218
+ this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
8219
+ this.echoHost = new EchoHost({
8220
+ kv: this.level,
8221
+ peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8222
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8223
+ indexing: {
8224
+ vector: this._runtimeParams?.enableVectorIndexing
8225
+ }
8226
+ });
8227
+ this._meshReplicator = new MeshEchoReplicator();
8228
+ this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
8229
+ this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
8230
+ this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
8231
+ if (!this._runtimeParams?.disableP2pReplication) {
8232
+ this._meshReplicator = new MeshEchoReplicator();
8233
+ }
8234
+ if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
8235
+ this._echoEdgeReplicator = new EchoEdgeReplicator({
8236
+ edgeConnection: this._edgeConnection,
8237
+ edgeHttpClient: this._edgeHttpClient
8238
+ });
8239
+ }
8240
+ }
8241
+ async _open(ctx) {
8242
+ await this._checkStorageVersion();
8243
+ log25("opening...", void 0, {
8244
+ F: __dxlog_file29,
8245
+ L: 204,
8246
+ S: this,
8247
+ C: (f, a) => f(...a)
8248
+ });
8249
+ log25.trace("dxos.sdk.service-context.open", trace10.begin({
8250
+ id: this._instanceId
8251
+ }), {
8252
+ F: __dxlog_file29,
8253
+ L: 205,
8254
+ S: this,
8255
+ C: (f, a) => f(...a)
8256
+ });
8257
+ await this.identityManager.open(ctx);
8258
+ await this._setNetworkIdentity();
8259
+ await this._edgeConnection?.open();
8469
8260
  await this.signalManager.open();
8470
8261
  await this.networkManager.open();
8471
8262
  await this.echoHost.open(ctx);
@@ -8749,62 +8540,6 @@ var ServiceContext = class extends Resource8 {
8749
8540
  _ts_dispose_resources4(env);
8750
8541
  }
8751
8542
  }
8752
- constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
8753
- super(), _define_property29(this, "storage", void 0), _define_property29(this, "level", void 0), _define_property29(this, "networkManager", void 0), _define_property29(this, "signalManager", void 0), _define_property29(this, "_edgeConnection", void 0), _define_property29(this, "_edgeHttpClient", void 0), _define_property29(this, "_runtimeParams", void 0), _define_property29(this, "_edgeFeatures", void 0), _define_property29(this, "_edgeIdentityUpdateMutex", void 0), _define_property29(this, "initialized", void 0), _define_property29(this, "metadataStore", void 0), _define_property29(this, "blobStore", void 0), _define_property29(this, "feedStore", void 0), _define_property29(this, "keyring", void 0), _define_property29(this, "spaceManager", void 0), _define_property29(this, "identityManager", void 0), _define_property29(this, "recoveryManager", void 0), _define_property29(this, "invitations", void 0), _define_property29(this, "invitationsManager", void 0), _define_property29(this, "echoHost", void 0), _define_property29(this, "_meshReplicator", void 0), _define_property29(this, "_echoEdgeReplicator", void 0), // Initialized after identity is initialized.
8754
- _define_property29(this, "dataSpaceManager", void 0), _define_property29(this, "edgeAgentManager", void 0), _define_property29(this, "_handlerFactories", void 0), _define_property29(this, "_deviceSpaceSync", void 0), _define_property29(this, "_instanceId", void 0), this.storage = storage, this.level = level, this.networkManager = networkManager, this.signalManager = signalManager, this._edgeConnection = _edgeConnection, this._edgeHttpClient = _edgeHttpClient, this._runtimeParams = _runtimeParams, this._edgeFeatures = _edgeFeatures, this._edgeIdentityUpdateMutex = new Mutex4(), this.initialized = new Trigger9(), this._meshReplicator = void 0, this._echoEdgeReplicator = void 0, this._handlerFactories = /* @__PURE__ */ new Map(), this._instanceId = PublicKey15.random().toHex();
8755
- this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
8756
- this.blobStore = new BlobStore(storage.createDirectory("blobs"));
8757
- this.keyring = new Keyring(storage.createDirectory("keyring"));
8758
- this.feedStore = new FeedStore({
8759
- factory: new FeedFactory({
8760
- root: storage.createDirectory("feeds"),
8761
- signer: this.keyring,
8762
- hypercore: {
8763
- valueEncoding,
8764
- stats: true
8765
- }
8766
- })
8767
- });
8768
- this.spaceManager = new SpaceManager({
8769
- feedStore: this.feedStore,
8770
- networkManager: this.networkManager,
8771
- blobStore: this.blobStore,
8772
- metadataStore: this.metadataStore,
8773
- disableP2pReplication: this._runtimeParams?.disableP2pReplication
8774
- });
8775
- this.identityManager = new IdentityManager({
8776
- metadataStore: this.metadataStore,
8777
- keyring: this.keyring,
8778
- feedStore: this.feedStore,
8779
- spaceManager: this.spaceManager,
8780
- devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
8781
- devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
8782
- edgeConnection: this._edgeConnection,
8783
- edgeFeatures: this._edgeFeatures
8784
- });
8785
- this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
8786
- this.echoHost = new EchoHost({
8787
- kv: this.level,
8788
- peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8789
- getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8790
- indexing: {
8791
- vector: this._runtimeParams?.enableVectorIndexing
8792
- }
8793
- });
8794
- this._meshReplicator = new MeshEchoReplicator();
8795
- this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
8796
- this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
8797
- this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
8798
- if (!this._runtimeParams?.disableP2pReplication) {
8799
- this._meshReplicator = new MeshEchoReplicator();
8800
- }
8801
- if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
8802
- this._echoEdgeReplicator = new EchoEdgeReplicator({
8803
- edgeConnection: this._edgeConnection,
8804
- edgeHttpClient: this._edgeHttpClient
8805
- });
8806
- }
8807
- }
8808
8543
  };
8809
8544
  _ts_decorate10([
8810
8545
  Trace3.span()
@@ -9051,20 +8786,14 @@ var importProfileData = async ({ storage, level }, archive) => {
9051
8786
  };
9052
8787
 
9053
8788
  // src/packlets/services/service-registry.ts
9054
- function _define_property30(obj, key, value) {
9055
- if (key in obj) {
9056
- Object.defineProperty(obj, key, {
9057
- value,
9058
- enumerable: true,
9059
- configurable: true,
9060
- writable: true
9061
- });
9062
- } else {
9063
- obj[key] = value;
9064
- }
9065
- return obj;
9066
- }
9067
8789
  var ServiceRegistry = class {
8790
+ _serviceBundle;
8791
+ _handlers;
8792
+ // prettier-ignore
8793
+ constructor(_serviceBundle, _handlers = {}) {
8794
+ this._serviceBundle = _serviceBundle;
8795
+ this._handlers = _handlers;
8796
+ }
9068
8797
  get descriptors() {
9069
8798
  return this._serviceBundle;
9070
8799
  }
@@ -9080,13 +8809,6 @@ var ServiceRegistry = class {
9080
8809
  removeService(name) {
9081
8810
  delete this._handlers[name];
9082
8811
  }
9083
- // prettier-ignore
9084
- constructor(_serviceBundle, _handlers = {}) {
9085
- _define_property30(this, "_serviceBundle", void 0);
9086
- _define_property30(this, "_handlers", void 0);
9087
- this._serviceBundle = _serviceBundle;
9088
- this._handlers = _handlers;
9089
- }
9090
8812
  };
9091
8813
 
9092
8814
  // src/packlets/services/service-host.ts
@@ -9109,21 +8831,14 @@ import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
9109
8831
  import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
9110
8832
  import { invariant as invariant24 } from "@dxos/invariant";
9111
8833
  import { Device as Device2, DeviceKind as DeviceKind2, EdgeStatus as EdgeStatus3 } from "@dxos/protocols/proto/dxos/client/services";
9112
- function _define_property31(obj, key, value) {
9113
- if (key in obj) {
9114
- Object.defineProperty(obj, key, {
9115
- value,
9116
- enumerable: true,
9117
- configurable: true,
9118
- writable: true
9119
- });
9120
- } else {
9121
- obj[key] = value;
9122
- }
9123
- return obj;
9124
- }
9125
8834
  var __dxlog_file31 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
9126
8835
  var DevicesServiceImpl = class {
8836
+ _identityManager;
8837
+ _edgeConnection;
8838
+ constructor(_identityManager, _edgeConnection) {
8839
+ this._identityManager = _identityManager;
8840
+ this._edgeConnection = _edgeConnection;
8841
+ }
9127
8842
  async updateDevice(profile) {
9128
8843
  return this._identityManager.updateDeviceProfile(profile);
9129
8844
  }
@@ -9153,7 +8868,7 @@ var DevicesServiceImpl = class {
9153
8868
  if (isMe) {
9154
8869
  presence = Device2.PresenceState.ONLINE;
9155
8870
  } else if (profile.os?.toUpperCase() === "EDGE") {
9156
- presence = this._edgeConnection?.status === EdgeStatus3.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8871
+ presence = this._edgeConnection?.status.state === EdgeStatus3.ConnectionState.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
9157
8872
  } else {
9158
8873
  presence = peers.some((peer) => peer.identityKey.equals(key)) ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
9159
8874
  }
@@ -9201,12 +8916,6 @@ var DevicesServiceImpl = class {
9201
8916
  return () => subscriptions.clear();
9202
8917
  });
9203
8918
  }
9204
- constructor(_identityManager, _edgeConnection) {
9205
- _define_property31(this, "_identityManager", void 0);
9206
- _define_property31(this, "_edgeConnection", void 0);
9207
- this._identityManager = _identityManager;
9208
- this._edgeConnection = _edgeConnection;
9209
- }
9210
8919
  };
9211
8920
 
9212
8921
  // src/packlets/identity/contacts-service.ts
@@ -9214,20 +8923,15 @@ import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateSchedul
9214
8923
  import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
9215
8924
  import { PublicKey as PublicKey17 } from "@dxos/keys";
9216
8925
  import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
9217
- function _define_property32(obj, key, value) {
9218
- if (key in obj) {
9219
- Object.defineProperty(obj, key, {
9220
- value,
9221
- enumerable: true,
9222
- configurable: true,
9223
- writable: true
9224
- });
9225
- } else {
9226
- obj[key] = value;
9227
- }
9228
- return obj;
9229
- }
9230
8926
  var ContactsServiceImpl = class {
8927
+ _identityManager;
8928
+ _spaceManager;
8929
+ _dataSpaceManagerProvider;
8930
+ constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
8931
+ this._identityManager = _identityManager;
8932
+ this._spaceManager = _spaceManager;
8933
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
8934
+ }
9231
8935
  async getContacts() {
9232
8936
  const identity = this._identityManager.identity;
9233
8937
  if (identity == null) {
@@ -9249,8 +8953,7 @@ var ContactsServiceImpl = class {
9249
8953
  }
9250
8954
  const existing = acc.get(memberInfo.key);
9251
8955
  if (existing != null) {
9252
- var _existing;
9253
- (_existing = existing).profile ?? (_existing.profile = memberInfo.profile);
8956
+ existing.profile ??= memberInfo.profile;
9254
8957
  existing.commonSpaces?.push(spaceKey);
9255
8958
  } else {
9256
8959
  acc.set(memberInfo.key, {
@@ -9299,14 +9002,6 @@ var ContactsServiceImpl = class {
9299
9002
  });
9300
9003
  });
9301
9004
  }
9302
- constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
9303
- _define_property32(this, "_identityManager", void 0);
9304
- _define_property32(this, "_spaceManager", void 0);
9305
- _define_property32(this, "_dataSpaceManagerProvider", void 0);
9306
- this._identityManager = _identityManager;
9307
- this._spaceManager = _spaceManager;
9308
- this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
9309
- }
9310
9005
  };
9311
9006
 
9312
9007
  // src/packlets/logging/logging-service.ts
@@ -9316,20 +9011,10 @@ import { PublicKey as PublicKey18 } from "@dxos/keys";
9316
9011
  import { getContextFromEntry, log as log27 } from "@dxos/log";
9317
9012
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
9318
9013
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
9319
- function _define_property33(obj, key, value) {
9320
- if (key in obj) {
9321
- Object.defineProperty(obj, key, {
9322
- value,
9323
- enumerable: true,
9324
- configurable: true,
9325
- writable: true
9326
- });
9327
- } else {
9328
- obj[key] = value;
9329
- }
9330
- return obj;
9331
- }
9332
9014
  var LoggingServiceImpl = class {
9015
+ _logs = new Event10();
9016
+ _started = Date.now();
9017
+ _sessionId = PublicKey18.random().toHex();
9333
9018
  async open() {
9334
9019
  log27.runtimeConfig.processors.push(this._logProcessor);
9335
9020
  }
@@ -9420,14 +9105,9 @@ var LoggingServiceImpl = class {
9420
9105
  this._logs.on(ctx, handler);
9421
9106
  });
9422
9107
  }
9423
- constructor() {
9424
- _define_property33(this, "_logs", new Event10());
9425
- _define_property33(this, "_started", Date.now());
9426
- _define_property33(this, "_sessionId", PublicKey18.random().toHex());
9427
- _define_property33(this, "_logProcessor", (_config, entry2) => {
9428
- this._logs.emit(entry2);
9429
- });
9430
- }
9108
+ _logProcessor = (_config, entry2) => {
9109
+ this._logs.emit(entry2);
9110
+ };
9431
9111
  };
9432
9112
  var matchFilter = (filter, level, path2, options) => {
9433
9113
  switch (options) {
@@ -9449,20 +9129,15 @@ var LOG_PROCESSING = 0;
9449
9129
 
9450
9130
  // src/packlets/network/network-service.ts
9451
9131
  import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
9452
- function _define_property34(obj, key, value) {
9453
- if (key in obj) {
9454
- Object.defineProperty(obj, key, {
9455
- value,
9456
- enumerable: true,
9457
- configurable: true,
9458
- writable: true
9459
- });
9460
- } else {
9461
- obj[key] = value;
9462
- }
9463
- return obj;
9464
- }
9465
9132
  var NetworkServiceImpl = class {
9133
+ networkManager;
9134
+ signalManager;
9135
+ edgeConnection;
9136
+ constructor(networkManager, signalManager, edgeConnection) {
9137
+ this.networkManager = networkManager;
9138
+ this.signalManager = signalManager;
9139
+ this.edgeConnection = edgeConnection;
9140
+ }
9466
9141
  queryStatus() {
9467
9142
  return new Stream15(({ ctx, next }) => {
9468
9143
  const update = () => {
@@ -9513,34 +9188,27 @@ var NetworkServiceImpl = class {
9513
9188
  });
9514
9189
  });
9515
9190
  }
9516
- constructor(networkManager, signalManager, edgeConnection) {
9517
- _define_property34(this, "networkManager", void 0);
9518
- _define_property34(this, "signalManager", void 0);
9519
- _define_property34(this, "edgeConnection", void 0);
9520
- this.networkManager = networkManager;
9521
- this.signalManager = signalManager;
9522
- this.edgeConnection = edgeConnection;
9523
- }
9524
9191
  };
9525
9192
 
9526
9193
  // src/packlets/system/system-service.ts
9527
9194
  import { Stream as Stream16 } from "@dxos/codec-protobuf/stream";
9528
9195
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
9529
9196
  import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
9530
- function _define_property35(obj, key, value) {
9531
- if (key in obj) {
9532
- Object.defineProperty(obj, key, {
9533
- value,
9534
- enumerable: true,
9535
- configurable: true,
9536
- writable: true
9537
- });
9538
- } else {
9539
- obj[key] = value;
9540
- }
9541
- return obj;
9542
- }
9543
9197
  var SystemServiceImpl = class {
9198
+ _config;
9199
+ _statusUpdate;
9200
+ _getCurrentStatus;
9201
+ _onUpdateStatus;
9202
+ _onReset;
9203
+ _getDiagnostics;
9204
+ constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
9205
+ this._config = config;
9206
+ this._statusUpdate = statusUpdate;
9207
+ this._getCurrentStatus = getCurrentStatus;
9208
+ this._getDiagnostics = getDiagnostics;
9209
+ this._onUpdateStatus = onUpdateStatus;
9210
+ this._onReset = onReset;
9211
+ }
9544
9212
  async getConfig() {
9545
9213
  return (await this._config?.())?.values ?? {};
9546
9214
  }
@@ -9583,36 +9251,9 @@ var SystemServiceImpl = class {
9583
9251
  async reset() {
9584
9252
  await this._onReset();
9585
9253
  }
9586
- constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
9587
- _define_property35(this, "_config", void 0);
9588
- _define_property35(this, "_statusUpdate", void 0);
9589
- _define_property35(this, "_getCurrentStatus", void 0);
9590
- _define_property35(this, "_onUpdateStatus", void 0);
9591
- _define_property35(this, "_onReset", void 0);
9592
- _define_property35(this, "_getDiagnostics", void 0);
9593
- this._config = config;
9594
- this._statusUpdate = statusUpdate;
9595
- this._getCurrentStatus = getCurrentStatus;
9596
- this._getDiagnostics = getDiagnostics;
9597
- this._onUpdateStatus = onUpdateStatus;
9598
- this._onReset = onReset;
9599
- }
9600
9254
  };
9601
9255
 
9602
9256
  // src/packlets/services/service-host.ts
9603
- function _define_property36(obj, key, value) {
9604
- if (key in obj) {
9605
- Object.defineProperty(obj, key, {
9606
- value,
9607
- enumerable: true,
9608
- configurable: true,
9609
- writable: true
9610
- });
9611
- } else {
9612
- obj[key] = value;
9613
- }
9614
- return obj;
9615
- }
9616
9257
  function _ts_decorate11(decorators, target, key, desc) {
9617
9258
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9618
9259
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -9621,6 +9262,94 @@ function _ts_decorate11(decorators, target, key, desc) {
9621
9262
  }
9622
9263
  var __dxlog_file32 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
9623
9264
  var ClientServicesHost = class {
9265
+ _resourceLock;
9266
+ _serviceRegistry;
9267
+ _systemService;
9268
+ _loggingService;
9269
+ _tracingService = TRACE_PROCESSOR3.createTraceSender();
9270
+ _statusUpdate = new Event11();
9271
+ _config;
9272
+ _signalManager;
9273
+ _networkManager;
9274
+ _storage;
9275
+ _level;
9276
+ _callbacks;
9277
+ _devtoolsProxy;
9278
+ _edgeConnection = void 0;
9279
+ _edgeHttpClient = void 0;
9280
+ _serviceContext;
9281
+ _runtimeParams;
9282
+ diagnosticsBroadcastHandler;
9283
+ _opening = false;
9284
+ _open = false;
9285
+ _resetting = false;
9286
+ constructor({
9287
+ config,
9288
+ transportFactory,
9289
+ signalManager,
9290
+ storage,
9291
+ level,
9292
+ // TODO(wittjosiah): Turn this on by default.
9293
+ lockKey,
9294
+ callbacks,
9295
+ runtimeParams
9296
+ } = {}) {
9297
+ this._storage = storage;
9298
+ this._level = level;
9299
+ this._callbacks = callbacks;
9300
+ this._runtimeParams = runtimeParams ?? {};
9301
+ if (this._runtimeParams.disableP2pReplication === void 0) {
9302
+ this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9303
+ }
9304
+ if (this._runtimeParams.enableVectorIndexing === void 0) {
9305
+ this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9306
+ }
9307
+ if (config) {
9308
+ this.initialize({
9309
+ config,
9310
+ transportFactory,
9311
+ signalManager
9312
+ });
9313
+ }
9314
+ if (lockKey) {
9315
+ this._resourceLock = new Lock({
9316
+ lockKey,
9317
+ onAcquire: () => {
9318
+ if (!this._opening) {
9319
+ void this.open(new Context11(void 0, {
9320
+ F: __dxlog_file32,
9321
+ L: 143
9322
+ }));
9323
+ }
9324
+ },
9325
+ onRelease: () => this.close()
9326
+ });
9327
+ }
9328
+ this._systemService = new SystemServiceImpl({
9329
+ config: () => this._config,
9330
+ statusUpdate: this._statusUpdate,
9331
+ getCurrentStatus: () => this.isOpen && !this._resetting ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
9332
+ getDiagnostics: () => {
9333
+ return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
9334
+ },
9335
+ onUpdateStatus: async (status) => {
9336
+ if (!this.isOpen && status === SystemStatus.ACTIVE) {
9337
+ await this._resourceLock?.acquire();
9338
+ } else if (this.isOpen && status === SystemStatus.INACTIVE) {
9339
+ await this._resourceLock?.release();
9340
+ }
9341
+ },
9342
+ onReset: async () => {
9343
+ await this.reset();
9344
+ }
9345
+ });
9346
+ this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
9347
+ this._loggingService = new LoggingServiceImpl();
9348
+ this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
9349
+ SystemService: this._systemService,
9350
+ TracingService: this._tracingService
9351
+ });
9352
+ }
9624
9353
  get isOpen() {
9625
9354
  return this._open;
9626
9355
  }
@@ -9928,94 +9657,6 @@ var ClientServicesHost = class {
9928
9657
  await this._serviceContext.initialized.wait();
9929
9658
  return identity;
9930
9659
  }
9931
- constructor({
9932
- config,
9933
- transportFactory,
9934
- signalManager,
9935
- storage,
9936
- level,
9937
- // TODO(wittjosiah): Turn this on by default.
9938
- lockKey,
9939
- callbacks,
9940
- runtimeParams
9941
- } = {}) {
9942
- _define_property36(this, "_resourceLock", void 0);
9943
- _define_property36(this, "_serviceRegistry", void 0);
9944
- _define_property36(this, "_systemService", void 0);
9945
- _define_property36(this, "_loggingService", void 0);
9946
- _define_property36(this, "_tracingService", TRACE_PROCESSOR3.createTraceSender());
9947
- _define_property36(this, "_statusUpdate", new Event11());
9948
- _define_property36(this, "_config", void 0);
9949
- _define_property36(this, "_signalManager", void 0);
9950
- _define_property36(this, "_networkManager", void 0);
9951
- _define_property36(this, "_storage", void 0);
9952
- _define_property36(this, "_level", void 0);
9953
- _define_property36(this, "_callbacks", void 0);
9954
- _define_property36(this, "_devtoolsProxy", void 0);
9955
- _define_property36(this, "_edgeConnection", void 0);
9956
- _define_property36(this, "_edgeHttpClient", void 0);
9957
- _define_property36(this, "_serviceContext", void 0);
9958
- _define_property36(this, "_runtimeParams", void 0);
9959
- _define_property36(this, "diagnosticsBroadcastHandler", void 0);
9960
- _define_property36(this, "_opening", false);
9961
- _define_property36(this, "_open", false);
9962
- _define_property36(this, "_resetting", false);
9963
- this._storage = storage;
9964
- this._level = level;
9965
- this._callbacks = callbacks;
9966
- this._runtimeParams = runtimeParams ?? {};
9967
- if (this._runtimeParams.disableP2pReplication === void 0) {
9968
- this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9969
- }
9970
- if (this._runtimeParams.enableVectorIndexing === void 0) {
9971
- this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9972
- }
9973
- if (config) {
9974
- this.initialize({
9975
- config,
9976
- transportFactory,
9977
- signalManager
9978
- });
9979
- }
9980
- if (lockKey) {
9981
- this._resourceLock = new Lock({
9982
- lockKey,
9983
- onAcquire: () => {
9984
- if (!this._opening) {
9985
- void this.open(new Context11(void 0, {
9986
- F: __dxlog_file32,
9987
- L: 143
9988
- }));
9989
- }
9990
- },
9991
- onRelease: () => this.close()
9992
- });
9993
- }
9994
- this._systemService = new SystemServiceImpl({
9995
- config: () => this._config,
9996
- statusUpdate: this._statusUpdate,
9997
- getCurrentStatus: () => this.isOpen && !this._resetting ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
9998
- getDiagnostics: () => {
9999
- return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
10000
- },
10001
- onUpdateStatus: async (status) => {
10002
- if (!this.isOpen && status === SystemStatus.ACTIVE) {
10003
- await this._resourceLock?.acquire();
10004
- } else if (this.isOpen && status === SystemStatus.INACTIVE) {
10005
- await this._resourceLock?.release();
10006
- }
10007
- },
10008
- onReset: async () => {
10009
- await this.reset();
10010
- }
10011
- });
10012
- this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
10013
- this._loggingService = new LoggingServiceImpl();
10014
- this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
10015
- SystemService: this._systemService,
10016
- TracingService: this._tracingService
10017
- });
10018
- }
10019
9660
  };
10020
9661
  _ts_decorate11([
10021
9662
  Trace4.info()
@@ -10083,4 +9724,4 @@ export {
10083
9724
  ServiceRegistry,
10084
9725
  ClientServicesHost
10085
9726
  };
10086
- //# sourceMappingURL=chunk-FZDVFED2.mjs.map
9727
+ //# sourceMappingURL=chunk-KPYVJG6G.mjs.map