@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";
@@ -586,21 +571,9 @@ import { ConfigResource } from "@dxos/config";
586
571
  import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
587
572
  import { TRACE_PROCESSOR as TRACE_PROCESSOR2 } from "@dxos/tracing";
588
573
  import { isNonNullable, jsonKeyReplacer } from "@dxos/util";
589
- function _define_property2(obj, key, value) {
590
- if (key in obj) {
591
- Object.defineProperty(obj, key, {
592
- value,
593
- enumerable: true,
594
- configurable: true,
595
- writable: true
596
- });
597
- } else {
598
- obj[key] = value;
599
- }
600
- return obj;
601
- }
602
574
  var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
603
575
  var DiagnosticsCollector = class {
576
+ static broadcastSender = createCollectDiagnosticsBroadcastSender();
604
577
  static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
605
578
  const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
606
579
  keys: options.humanize ? GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
@@ -621,7 +594,6 @@ var DiagnosticsCollector = class {
621
594
  return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer(options)));
622
595
  }
623
596
  };
624
- _define_property2(DiagnosticsCollector, "broadcastSender", createCollectDiagnosticsBroadcastSender());
625
597
  var findSystemServiceProvider = () => {
626
598
  const serviceProviders = TRACE_PROCESSOR2.findResourcesByAnnotation(ClientServicesProviderResource);
627
599
  const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
@@ -638,19 +610,6 @@ import { Context as Context2 } from "@dxos/context";
638
610
  import { verifyCredential } from "@dxos/credentials";
639
611
  import { log as log2 } from "@dxos/log";
640
612
  import { schema } from "@dxos/protocols/proto";
641
- function _define_property3(obj, key, value) {
642
- if (key in obj) {
643
- Object.defineProperty(obj, key, {
644
- value,
645
- enumerable: true,
646
- configurable: true,
647
- writable: true
648
- });
649
- } else {
650
- obj[key] = value;
651
- }
652
- return obj;
653
- }
654
613
  var __dxlog_file4 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
655
614
  var Credential = schema.getCodecForType("dxos.halo.credentials.Credential");
656
615
  var createAuthProvider = (signer) => async (nonce) => {
@@ -664,6 +623,14 @@ var createAuthProvider = (signer) => async (nonce) => {
664
623
  return Credential.encode(credential);
665
624
  };
666
625
  var TrustedKeySetAuthVerifier = class {
626
+ _params;
627
+ _ctx = new Context2(void 0, {
628
+ F: __dxlog_file4,
629
+ L: 45
630
+ });
631
+ constructor(_params) {
632
+ this._params = _params;
633
+ }
667
634
  async close() {
668
635
  await this._ctx.dispose();
669
636
  }
@@ -757,15 +724,6 @@ var TrustedKeySetAuthVerifier = class {
757
724
  const deviceSet = this._params.trustedKeysProvider();
758
725
  return deviceSet.has(deviceKey);
759
726
  }
760
- constructor(_params) {
761
- _define_property3(this, "_params", void 0);
762
- _define_property3(this, "_ctx", void 0);
763
- this._params = _params;
764
- this._ctx = new Context2(void 0, {
765
- F: __dxlog_file4,
766
- L: 45
767
- });
768
- }
769
727
  };
770
728
 
771
729
  // src/packlets/spaces/edge-feed-replicator.ts
@@ -781,19 +739,6 @@ import { buf } from "@dxos/protocols/buf";
781
739
  import { MessageSchema as RouterMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
782
740
  import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
783
741
  import { ComplexMap as ComplexMap2, arrayToBuffer, bufferToArray, defaultMap, rangeFromTo } from "@dxos/util";
784
- function _define_property4(obj, key, value) {
785
- if (key in obj) {
786
- Object.defineProperty(obj, key, {
787
- value,
788
- enumerable: true,
789
- configurable: true,
790
- writable: true
791
- });
792
- } else {
793
- obj[key] = value;
794
- }
795
- return obj;
796
- }
797
742
  function _ts_decorate(decorators, target, key, desc) {
798
743
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
799
744
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -867,6 +812,24 @@ function _ts_dispose_resources(env) {
867
812
  }
868
813
  var __dxlog_file5 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/edge-feed-replicator.ts";
869
814
  var EdgeFeedReplicator = class extends Resource {
815
+ _messenger;
816
+ _spaceId;
817
+ _feeds = new ComplexMap2(PublicKey3.hash);
818
+ _connectionCtx = void 0;
819
+ _connected = false;
820
+ /**
821
+ * Feed length at service.
822
+ */
823
+ _remoteLength = new ComplexMap2(PublicKey3.hash);
824
+ /**
825
+ * Protects against concurrent pushes so that remote length is updated consistently.
826
+ */
827
+ _pushMutex = new ComplexMap2(PublicKey3.hash);
828
+ constructor({ messenger, spaceId }) {
829
+ super();
830
+ this._messenger = messenger;
831
+ this._spaceId = spaceId;
832
+ }
870
833
  async _open() {
871
834
  log3("open", void 0, {
872
835
  F: __dxlog_file5,
@@ -914,7 +877,7 @@ var EdgeFeedReplicator = class extends Resource {
914
877
  }
915
878
  async _handleReconnect() {
916
879
  await this._resetConnection();
917
- if (this._messenger.status === EdgeStatus.CONNECTED) {
880
+ if (this._messenger.status.state === EdgeStatus.ConnectionState.CONNECTED) {
918
881
  this._startReplication();
919
882
  }
920
883
  }
@@ -1263,17 +1226,6 @@ var EdgeFeedReplicator = class extends Resource {
1263
1226
  });
1264
1227
  return connectionCtx;
1265
1228
  }
1266
- constructor({ messenger, spaceId }) {
1267
- 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), /**
1268
- * Feed length at service.
1269
- */
1270
- _define_property4(this, "_remoteLength", new ComplexMap2(PublicKey3.hash)), /**
1271
- * Protects against concurrent pushes so that remote length is updated consistently.
1272
- */
1273
- _define_property4(this, "_pushMutex", new ComplexMap2(PublicKey3.hash));
1274
- this._messenger = messenger;
1275
- this._spaceId = spaceId;
1276
- }
1277
1229
  };
1278
1230
  _ts_decorate([
1279
1231
  logInfo
@@ -1326,9 +1278,9 @@ import { Event as Event2, synchronized, trackLeaks } from "@dxos/async";
1326
1278
  import { PropertiesType, TYPE_PROPERTIES } from "@dxos/client-protocol";
1327
1279
  import { Context as Context4, LifecycleState, Resource as Resource2, cancelWithContext } from "@dxos/context";
1328
1280
  import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
1281
+ import { ObjectId, getTypeReference } from "@dxos/echo/internal";
1329
1282
  import { AuthStatus, CredentialServerExtension, DatabaseRoot, FIND_PARAMS, findInlineObjectOfType } from "@dxos/echo-pipeline";
1330
1283
  import { SpaceDocVersion, createIdFromSpaceKey, encodeReference } from "@dxos/echo-protocol";
1331
- import { ObjectId, getTypeReference } from "@dxos/echo-schema";
1332
1284
  import { writeMessages } from "@dxos/feed-store";
1333
1285
  import { assertArgument, assertState, failedInvariant, invariant as invariant3 } from "@dxos/invariant";
1334
1286
  import { PublicKey as PublicKey4 } from "@dxos/keys";
@@ -1412,19 +1364,6 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1412
1364
  };
1413
1365
 
1414
1366
  // src/packlets/spaces/data-space-manager.ts
1415
- function _define_property5(obj, key, value) {
1416
- if (key in obj) {
1417
- Object.defineProperty(obj, key, {
1418
- value,
1419
- enumerable: true,
1420
- configurable: true,
1421
- writable: true
1422
- });
1423
- } else {
1424
- obj[key] = value;
1425
- }
1426
- return obj;
1427
- }
1428
1367
  function _ts_decorate2(decorators, target, key, desc) {
1429
1368
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1430
1369
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1436,6 +1375,61 @@ var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
1436
1375
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
1437
1376
  var DEFAULT_SPACE_KEY = "__DEFAULT__";
1438
1377
  var DataSpaceManager = class extends Resource2 {
1378
+ updated = new Event2();
1379
+ _spaces = new ComplexMap3(PublicKey4.hash);
1380
+ _instanceId = PublicKey4.random().toHex();
1381
+ _spaceManager;
1382
+ _metadataStore;
1383
+ _keyring;
1384
+ _signingContext;
1385
+ _feedStore;
1386
+ _echoHost;
1387
+ _invitationsManager;
1388
+ _edgeConnection = void 0;
1389
+ _edgeHttpClient = void 0;
1390
+ _edgeFeatures = void 0;
1391
+ _meshReplicator = void 0;
1392
+ _echoEdgeReplicator = void 0;
1393
+ _runtimeParams = void 0;
1394
+ constructor(params) {
1395
+ super();
1396
+ this._spaceManager = params.spaceManager;
1397
+ this._metadataStore = params.metadataStore;
1398
+ this._keyring = params.keyring;
1399
+ this._signingContext = params.signingContext;
1400
+ this._feedStore = params.feedStore;
1401
+ this._echoHost = params.echoHost;
1402
+ this._meshReplicator = params.meshReplicator;
1403
+ this._invitationsManager = params.invitationsManager;
1404
+ this._edgeConnection = params.edgeConnection;
1405
+ this._edgeFeatures = params.edgeFeatures;
1406
+ this._echoEdgeReplicator = params.echoEdgeReplicator;
1407
+ this._edgeHttpClient = params.edgeHttpClient;
1408
+ this._runtimeParams = params.runtimeParams;
1409
+ trace.diagnostic({
1410
+ id: "spaces",
1411
+ name: "Spaces",
1412
+ fetch: async () => {
1413
+ return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
1414
+ const rootUrl = space.automergeSpaceState.rootUrl;
1415
+ const rootHandle = rootUrl ? await this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS) : void 0;
1416
+ await rootHandle?.whenReady();
1417
+ const rootDoc = rootHandle?.doc();
1418
+ const properties = rootDoc && findInlineObjectOfType(rootDoc, TYPE_PROPERTIES);
1419
+ return {
1420
+ key: space.key.toHex(),
1421
+ state: SpaceState[space.state],
1422
+ name: properties?.[1].data.name ?? null,
1423
+ inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
1424
+ linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
1425
+ credentials: space.inner.spaceState.credentials.length,
1426
+ members: space.inner.spaceState.members.size,
1427
+ rootUrl
1428
+ };
1429
+ }));
1430
+ }
1431
+ });
1432
+ }
1439
1433
  // TODO(burdon): Remove.
1440
1434
  get spaces() {
1441
1435
  return this._spaces;
@@ -1562,6 +1556,11 @@ var DataSpaceManager = class extends Resource2 {
1562
1556
  const newDoc = await this._echoHost.createDoc(data, {
1563
1557
  preserveHistory: true
1564
1558
  });
1559
+ if (newDoc.doc().access !== void 0 && newDoc.doc().access.spaceKey !== spaceKey.toHex()) {
1560
+ newDoc.change((doc) => {
1561
+ doc.access.spaceKey = spaceKey.toHex();
1562
+ });
1563
+ }
1565
1564
  documentIdMapping[documentId] = newDoc.documentId;
1566
1565
  }));
1567
1566
  }
@@ -1569,7 +1568,7 @@ var DataSpaceManager = class extends Resource2 {
1569
1568
  spaceKey
1570
1569
  }, {
1571
1570
  F: __dxlog_file6,
1572
- L: 288,
1571
+ L: 299,
1573
1572
  S: this,
1574
1573
  C: (f, a) => f(...a)
1575
1574
  });
@@ -1578,18 +1577,19 @@ var DataSpaceManager = class extends Resource2 {
1578
1577
  const newRootDocId = documentIdMapping[interpretAsDocumentId(options.rootUrl)] ?? failedInvariant();
1579
1578
  const rootDocHandle = await this._echoHost.loadDoc(Context4.default(void 0, {
1580
1579
  F: __dxlog_file6,
1581
- L: 293
1580
+ L: 304
1582
1581
  }), newRootDocId);
1583
1582
  DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
1584
1583
  root = await this._echoHost.openSpaceRoot(spaceId, `automerge:${newRootDocId}`);
1585
1584
  } else {
1586
1585
  root = await this._echoHost.createSpaceRoot(spaceKey);
1587
1586
  }
1587
+ await this._echoHost.flush();
1588
1588
  log4("constructing space...", {
1589
1589
  spaceKey
1590
1590
  }, {
1591
1591
  F: __dxlog_file6,
1592
- L: 301,
1592
+ L: 313,
1593
1593
  S: this,
1594
1594
  C: (f, a) => f(...a)
1595
1595
  });
@@ -1599,7 +1599,7 @@ var DataSpaceManager = class extends Resource2 {
1599
1599
  spaceKey
1600
1600
  }, {
1601
1601
  F: __dxlog_file6,
1602
- L: 306,
1602
+ L: 318,
1603
1603
  S: this,
1604
1604
  C: (f, a) => f(...a)
1605
1605
  });
@@ -1608,7 +1608,7 @@ var DataSpaceManager = class extends Resource2 {
1608
1608
  const memberCredential = credentials[1];
1609
1609
  invariant3(getCredentialAssertion(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
1610
1610
  F: __dxlog_file6,
1611
- L: 312,
1611
+ L: 324,
1612
1612
  S: this,
1613
1613
  A: [
1614
1614
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -1622,7 +1622,7 @@ var DataSpaceManager = class extends Resource2 {
1622
1622
  spaceKey
1623
1623
  }, {
1624
1624
  F: __dxlog_file6,
1625
- L: 317,
1625
+ L: 329,
1626
1626
  S: this,
1627
1627
  C: (f, a) => f(...a)
1628
1628
  });
@@ -1640,7 +1640,7 @@ var DataSpaceManager = class extends Resource2 {
1640
1640
  spaceId: space.id
1641
1641
  }, {
1642
1642
  F: __dxlog_file6,
1643
- L: 330,
1643
+ L: 342,
1644
1644
  S: this,
1645
1645
  C: (f, a) => f(...a)
1646
1646
  });
@@ -1658,7 +1658,7 @@ var DataSpaceManager = class extends Resource2 {
1658
1658
  spaceId: space.id
1659
1659
  }, {
1660
1660
  F: __dxlog_file6,
1661
- L: 341,
1661
+ L: 353,
1662
1662
  S: this,
1663
1663
  C: (f, a) => f(...a)
1664
1664
  });
@@ -1693,7 +1693,7 @@ var DataSpaceManager = class extends Resource2 {
1693
1693
  const automergeIndex = space.automergeSpaceState.rootUrl;
1694
1694
  invariant3(automergeIndex, void 0, {
1695
1695
  F: __dxlog_file6,
1696
- L: 374,
1696
+ L: 386,
1697
1697
  S: this,
1698
1698
  A: [
1699
1699
  "automergeIndex",
@@ -1710,13 +1710,13 @@ var DataSpaceManager = class extends Resource2 {
1710
1710
  opts
1711
1711
  }, {
1712
1712
  F: __dxlog_file6,
1713
- L: 383,
1713
+ L: 395,
1714
1714
  S: this,
1715
1715
  C: (f, a) => f(...a)
1716
1716
  });
1717
1717
  invariant3(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
1718
1718
  F: __dxlog_file6,
1719
- L: 384,
1719
+ L: 396,
1720
1720
  S: this,
1721
1721
  A: [
1722
1722
  "this._lifecycleState === LifecycleState.OPEN",
@@ -1725,7 +1725,7 @@ var DataSpaceManager = class extends Resource2 {
1725
1725
  });
1726
1726
  invariant3(!this._spaces.has(opts.spaceKey), "Space already exists.", {
1727
1727
  F: __dxlog_file6,
1728
- L: 385,
1728
+ L: 397,
1729
1729
  S: this,
1730
1730
  A: [
1731
1731
  "!this._spaces.has(opts.spaceKey)",
@@ -1749,7 +1749,7 @@ var DataSpaceManager = class extends Resource2 {
1749
1749
  const space = this._spaceManager.spaces.get(options.spaceKey);
1750
1750
  invariant3(space, void 0, {
1751
1751
  F: __dxlog_file6,
1752
- L: 405,
1752
+ L: 417,
1753
1753
  S: this,
1754
1754
  A: [
1755
1755
  "space",
@@ -1762,7 +1762,7 @@ var DataSpaceManager = class extends Resource2 {
1762
1762
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
1763
1763
  invariant3(credentials[0].credential, void 0, {
1764
1764
  F: __dxlog_file6,
1765
- L: 424,
1765
+ L: 436,
1766
1766
  S: this,
1767
1767
  A: [
1768
1768
  "credentials[0].credential",
@@ -1772,7 +1772,7 @@ var DataSpaceManager = class extends Resource2 {
1772
1772
  const spaceMemberCredential = credentials[0].credential.credential;
1773
1773
  invariant3(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
1774
1774
  F: __dxlog_file6,
1775
- L: 426,
1775
+ L: 438,
1776
1776
  S: this,
1777
1777
  A: [
1778
1778
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -1810,7 +1810,7 @@ var DataSpaceManager = class extends Resource2 {
1810
1810
  const space = this._spaces.get(spaceKey);
1811
1811
  invariant3(space, "Space not found.", {
1812
1812
  F: __dxlog_file6,
1813
- L: 463,
1813
+ L: 475,
1814
1814
  S: this,
1815
1815
  A: [
1816
1816
  "space",
@@ -1835,7 +1835,7 @@ var DataSpaceManager = class extends Resource2 {
1835
1835
  metadata
1836
1836
  }, {
1837
1837
  F: __dxlog_file6,
1838
- L: 482,
1838
+ L: 494,
1839
1839
  S: this,
1840
1840
  C: (f, a) => f(...a)
1841
1841
  });
@@ -1879,7 +1879,7 @@ var DataSpaceManager = class extends Resource2 {
1879
1879
  err
1880
1880
  }, {
1881
1881
  F: __dxlog_file6,
1882
- L: 524,
1882
+ L: 536,
1883
1883
  S: this,
1884
1884
  C: (f, a) => f(...a)
1885
1885
  });
@@ -1889,7 +1889,7 @@ var DataSpaceManager = class extends Resource2 {
1889
1889
  onAuthFailure: () => {
1890
1890
  log4.warn("auth failure", void 0, {
1891
1891
  F: __dxlog_file6,
1892
- L: 529,
1892
+ L: 541,
1893
1893
  S: this,
1894
1894
  C: (f, a) => f(...a)
1895
1895
  });
@@ -1922,7 +1922,7 @@ var DataSpaceManager = class extends Resource2 {
1922
1922
  space: space.key
1923
1923
  }, {
1924
1924
  F: __dxlog_file6,
1925
- L: 556,
1925
+ L: 568,
1926
1926
  S: this,
1927
1927
  C: (f, a) => f(...a)
1928
1928
  });
@@ -1933,7 +1933,7 @@ var DataSpaceManager = class extends Resource2 {
1933
1933
  open: this._lifecycleState === LifecycleState.OPEN
1934
1934
  }, {
1935
1935
  F: __dxlog_file6,
1936
- L: 559,
1936
+ L: 571,
1937
1937
  S: this,
1938
1938
  C: (f, a) => f(...a)
1939
1939
  });
@@ -1952,7 +1952,7 @@ var DataSpaceManager = class extends Resource2 {
1952
1952
  space: space.key
1953
1953
  }, {
1954
1954
  F: __dxlog_file6,
1955
- L: 567,
1955
+ L: 579,
1956
1956
  S: this,
1957
1957
  C: (f, a) => f(...a)
1958
1958
  });
@@ -1973,7 +1973,7 @@ var DataSpaceManager = class extends Resource2 {
1973
1973
  spaceId: dataSpace.id
1974
1974
  }, {
1975
1975
  F: __dxlog_file6,
1976
- L: 581,
1976
+ L: 593,
1977
1977
  S: this,
1978
1978
  C: (f, a) => f(...a)
1979
1979
  });
@@ -2003,7 +2003,7 @@ var DataSpaceManager = class extends Resource2 {
2003
2003
  space: space.key
2004
2004
  }, {
2005
2005
  F: __dxlog_file6,
2006
- L: 608,
2006
+ L: 620,
2007
2007
  S: this,
2008
2008
  C: (f, a) => f(...a)
2009
2009
  });
@@ -2036,7 +2036,7 @@ var DataSpaceManager = class extends Resource2 {
2036
2036
  closedSessions
2037
2037
  }, {
2038
2038
  F: __dxlog_file6,
2039
- L: 634,
2039
+ L: 646,
2040
2040
  S: this,
2041
2041
  C: (f, a) => f(...a)
2042
2042
  });
@@ -2051,7 +2051,7 @@ var DataSpaceManager = class extends Resource2 {
2051
2051
  peerId: peerState.peerId
2052
2052
  }, {
2053
2053
  F: __dxlog_file6,
2054
- L: 648,
2054
+ L: 660,
2055
2055
  S: this,
2056
2056
  C: (f, a) => f(...a)
2057
2057
  });
@@ -2094,45 +2094,6 @@ var DataSpaceManager = class extends Resource2 {
2094
2094
  });
2095
2095
  await Promise.all(tasks);
2096
2096
  }
2097
- constructor(params) {
2098
- 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);
2099
- this._spaceManager = params.spaceManager;
2100
- this._metadataStore = params.metadataStore;
2101
- this._keyring = params.keyring;
2102
- this._signingContext = params.signingContext;
2103
- this._feedStore = params.feedStore;
2104
- this._echoHost = params.echoHost;
2105
- this._meshReplicator = params.meshReplicator;
2106
- this._invitationsManager = params.invitationsManager;
2107
- this._edgeConnection = params.edgeConnection;
2108
- this._edgeFeatures = params.edgeFeatures;
2109
- this._echoEdgeReplicator = params.echoEdgeReplicator;
2110
- this._edgeHttpClient = params.edgeHttpClient;
2111
- this._runtimeParams = params.runtimeParams;
2112
- trace.diagnostic({
2113
- id: "spaces",
2114
- name: "Spaces",
2115
- fetch: async () => {
2116
- return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
2117
- const rootUrl = space.automergeSpaceState.rootUrl;
2118
- const rootHandle = rootUrl ? await this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS) : void 0;
2119
- await rootHandle?.whenReady();
2120
- const rootDoc = rootHandle?.doc();
2121
- const properties = rootDoc && findInlineObjectOfType(rootDoc, TYPE_PROPERTIES);
2122
- return {
2123
- key: space.key.toHex(),
2124
- state: SpaceState[space.state],
2125
- name: properties?.[1].data.name ?? null,
2126
- inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
2127
- linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
2128
- credentials: space.inner.spaceState.credentials.length,
2129
- members: space.inner.spaceState.members.size,
2130
- rootUrl
2131
- };
2132
- }));
2133
- }
2134
- });
2135
- }
2136
2097
  };
2137
2098
  _ts_decorate2([
2138
2099
  synchronized
@@ -2167,21 +2128,12 @@ import { trace as trace2 } from "@dxos/tracing";
2167
2128
  import { Resource as Resource3 } from "@dxos/context";
2168
2129
  import { assertArgument as assertArgument2, assertState as assertState2 } from "@dxos/invariant";
2169
2130
  import { SpaceArchiveFileStructure, SpaceArchiveVersion } from "@dxos/protocols";
2170
- function _define_property6(obj, key, value) {
2171
- if (key in obj) {
2172
- Object.defineProperty(obj, key, {
2173
- value,
2174
- enumerable: true,
2175
- configurable: true,
2176
- writable: true
2177
- });
2178
- } else {
2179
- obj[key] = value;
2180
- }
2181
- return obj;
2182
- }
2183
2131
  var CURRENT_VERSION = SpaceArchiveVersion.V1;
2184
2132
  var SpaceArchiveWriter = class extends Resource3 {
2133
+ _tar;
2134
+ _archive;
2135
+ _meta = void 0;
2136
+ _currentRootUrl = void 0;
2185
2137
  async _open(ctx) {
2186
2138
  this._tar = await import("@obsidize/tar-browserify");
2187
2139
  }
@@ -2225,9 +2177,6 @@ var SpaceArchiveWriter = class extends Resource3 {
2225
2177
  contents: binary
2226
2178
  };
2227
2179
  }
2228
- constructor(...args) {
2229
- 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);
2230
- }
2231
2180
  };
2232
2181
 
2233
2182
  // src/packlets/space-export/space-archive-reader.ts
@@ -2271,19 +2220,6 @@ var extractSpaceArchive = async (archive) => {
2271
2220
  };
2272
2221
 
2273
2222
  // src/packlets/spaces/spaces-service.ts
2274
- function _define_property7(obj, key, value) {
2275
- if (key in obj) {
2276
- Object.defineProperty(obj, key, {
2277
- value,
2278
- enumerable: true,
2279
- configurable: true,
2280
- writable: true
2281
- });
2282
- } else {
2283
- obj[key] = value;
2284
- }
2285
- return obj;
2286
- }
2287
2223
  function _ts_add_disposable_resource2(env, value, async) {
2288
2224
  if (value !== null && value !== void 0) {
2289
2225
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
@@ -2351,6 +2287,14 @@ function _ts_dispose_resources2(env) {
2351
2287
  }
2352
2288
  var __dxlog_file8 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2353
2289
  var SpacesServiceImpl = class {
2290
+ _identityManager;
2291
+ _spaceManager;
2292
+ _getDataSpaceManager;
2293
+ constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
2294
+ this._identityManager = _identityManager;
2295
+ this._spaceManager = _spaceManager;
2296
+ this._getDataSpaceManager = _getDataSpaceManager;
2297
+ }
2354
2298
  async createSpace() {
2355
2299
  this._requireIdentity();
2356
2300
  const dataSpaceManager = await this._getDataSpaceManager();
@@ -2728,14 +2672,6 @@ var SpacesServiceImpl = class {
2728
2672
  });
2729
2673
  }
2730
2674
  }
2731
- constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
2732
- _define_property7(this, "_identityManager", void 0);
2733
- _define_property7(this, "_spaceManager", void 0);
2734
- _define_property7(this, "_getDataSpaceManager", void 0);
2735
- this._identityManager = _identityManager;
2736
- this._spaceManager = _spaceManager;
2737
- this._getDataSpaceManager = _getDataSpaceManager;
2738
- }
2739
2675
  };
2740
2676
  var getChannelId = (channel) => `user-channel/${channel}`;
2741
2677
 
@@ -2743,21 +2679,13 @@ var getChannelId = (channel) => `user-channel/${channel}`;
2743
2679
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2744
2680
  import { SpaceId as SpaceId2 } from "@dxos/keys";
2745
2681
  import { log as log7 } from "@dxos/log";
2746
- function _define_property8(obj, key, value) {
2747
- if (key in obj) {
2748
- Object.defineProperty(obj, key, {
2749
- value,
2750
- enumerable: true,
2751
- configurable: true,
2752
- writable: true
2753
- });
2754
- } else {
2755
- obj[key] = value;
2756
- }
2757
- return obj;
2758
- }
2759
2682
  var __dxlog_file9 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
2760
2683
  var DefaultSpaceStateMachine = class {
2684
+ _params;
2685
+ _spaceId;
2686
+ constructor(_params) {
2687
+ this._params = _params;
2688
+ }
2761
2689
  get spaceId() {
2762
2690
  return this._spaceId;
2763
2691
  }
@@ -2793,27 +2721,9 @@ var DefaultSpaceStateMachine = class {
2793
2721
  }
2794
2722
  }
2795
2723
  }
2796
- constructor(_params) {
2797
- _define_property8(this, "_params", void 0);
2798
- _define_property8(this, "_spaceId", void 0);
2799
- this._params = _params;
2800
- }
2801
2724
  };
2802
2725
 
2803
2726
  // src/packlets/identity/identity.ts
2804
- function _define_property9(obj, key, value) {
2805
- if (key in obj) {
2806
- Object.defineProperty(obj, key, {
2807
- value,
2808
- enumerable: true,
2809
- configurable: true,
2810
- writable: true
2811
- });
2812
- } else {
2813
- obj[key] = value;
2814
- }
2815
- return obj;
2816
- }
2817
2727
  function _ts_decorate3(decorators, target, key, desc) {
2818
2728
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2819
2729
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2822,6 +2732,58 @@ function _ts_decorate3(decorators, target, key, desc) {
2822
2732
  }
2823
2733
  var __dxlog_file10 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
2824
2734
  var Identity = class {
2735
+ space;
2736
+ _signer;
2737
+ _presence;
2738
+ _deviceStateMachine;
2739
+ _profileStateMachine;
2740
+ _defaultSpaceStateMachine;
2741
+ _edgeFeedReplicator = void 0;
2742
+ authVerifier;
2743
+ did;
2744
+ identityKey;
2745
+ deviceKey;
2746
+ stateUpdate = new Event3();
2747
+ constructor(params) {
2748
+ this.space = params.space;
2749
+ this._signer = params.signer;
2750
+ this._presence = params.presence;
2751
+ this.did = params.did;
2752
+ this.identityKey = params.identityKey;
2753
+ this.deviceKey = params.deviceKey;
2754
+ log8.trace("dxos.halo.device", {
2755
+ deviceKey: params.deviceKey
2756
+ }, {
2757
+ F: __dxlog_file10,
2758
+ L: 83,
2759
+ S: this,
2760
+ C: (f, a) => f(...a)
2761
+ });
2762
+ this._deviceStateMachine = new DeviceStateMachine({
2763
+ identityKey: this.identityKey,
2764
+ deviceKey: this.deviceKey,
2765
+ onUpdate: () => this.stateUpdate.emit()
2766
+ });
2767
+ this._profileStateMachine = new ProfileStateMachine({
2768
+ identityKey: this.identityKey,
2769
+ onUpdate: () => this.stateUpdate.emit()
2770
+ });
2771
+ this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
2772
+ identityKey: this.identityKey,
2773
+ onUpdate: () => this.stateUpdate.emit()
2774
+ });
2775
+ this.authVerifier = new TrustedKeySetAuthVerifier({
2776
+ trustedKeysProvider: () => new ComplexSet(PublicKey5.hash, this.authorizedDeviceKeys.keys()),
2777
+ update: this.stateUpdate,
2778
+ authTimeout: AUTH_TIMEOUT
2779
+ });
2780
+ if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
2781
+ this._edgeFeedReplicator = new EdgeFeedReplicator({
2782
+ messenger: params.edgeConnection,
2783
+ spaceId: this.space.id
2784
+ });
2785
+ }
2786
+ }
2825
2787
  // TODO(burdon): Expose state object?
2826
2788
  get authorizedDeviceKeys() {
2827
2789
  return this._deviceStateMachine.authorizedDeviceKeys;
@@ -2981,61 +2943,9 @@ var Identity = class {
2981
2943
  })));
2982
2944
  return deviceCredential;
2983
2945
  }
2984
- constructor(params) {
2985
- _define_property9(this, "space", void 0);
2986
- _define_property9(this, "_signer", void 0);
2987
- _define_property9(this, "_presence", void 0);
2988
- _define_property9(this, "_deviceStateMachine", void 0);
2989
- _define_property9(this, "_profileStateMachine", void 0);
2990
- _define_property9(this, "_defaultSpaceStateMachine", void 0);
2991
- _define_property9(this, "_edgeFeedReplicator", void 0);
2992
- _define_property9(this, "authVerifier", void 0);
2993
- _define_property9(this, "did", void 0);
2994
- _define_property9(this, "identityKey", void 0);
2995
- _define_property9(this, "deviceKey", void 0);
2996
- _define_property9(this, "stateUpdate", new Event3());
2997
- _define_property9(this, "_onFeedAdded", async (feed) => {
2998
- await this._edgeFeedReplicator.addFeed(feed);
2999
- });
3000
- this.space = params.space;
3001
- this._signer = params.signer;
3002
- this._presence = params.presence;
3003
- this.did = params.did;
3004
- this.identityKey = params.identityKey;
3005
- this.deviceKey = params.deviceKey;
3006
- log8.trace("dxos.halo.device", {
3007
- deviceKey: params.deviceKey
3008
- }, {
3009
- F: __dxlog_file10,
3010
- L: 83,
3011
- S: this,
3012
- C: (f, a) => f(...a)
3013
- });
3014
- this._deviceStateMachine = new DeviceStateMachine({
3015
- identityKey: this.identityKey,
3016
- deviceKey: this.deviceKey,
3017
- onUpdate: () => this.stateUpdate.emit()
3018
- });
3019
- this._profileStateMachine = new ProfileStateMachine({
3020
- identityKey: this.identityKey,
3021
- onUpdate: () => this.stateUpdate.emit()
3022
- });
3023
- this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
3024
- identityKey: this.identityKey,
3025
- onUpdate: () => this.stateUpdate.emit()
3026
- });
3027
- this.authVerifier = new TrustedKeySetAuthVerifier({
3028
- trustedKeysProvider: () => new ComplexSet(PublicKey5.hash, this.authorizedDeviceKeys.keys()),
3029
- update: this.stateUpdate,
3030
- authTimeout: AUTH_TIMEOUT
3031
- });
3032
- if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
3033
- this._edgeFeedReplicator = new EdgeFeedReplicator({
3034
- messenger: params.edgeConnection,
3035
- spaceId: this.space.id
3036
- });
3037
- }
3038
- }
2946
+ _onFeedAdded = async (feed) => {
2947
+ await this._edgeFeedReplicator.addFeed(feed);
2948
+ };
3039
2949
  };
3040
2950
  _ts_decorate3([
3041
2951
  trace3.span()
@@ -3062,19 +2972,6 @@ import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extensi
3062
2972
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
3063
2973
  import { trace as Trace2 } from "@dxos/tracing";
3064
2974
  import { deferFunction as deferFunction2, isNode } from "@dxos/util";
3065
- function _define_property10(obj, key, value) {
3066
- if (key in obj) {
3067
- Object.defineProperty(obj, key, {
3068
- value,
3069
- enumerable: true,
3070
- configurable: true,
3071
- writable: true
3072
- });
3073
- } else {
3074
- obj[key] = value;
3075
- }
3076
- return obj;
3077
- }
3078
2975
  function _ts_decorate4(decorators, target, key, desc) {
3079
2976
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3080
2977
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3085,6 +2982,27 @@ var __dxlog_file11 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/i
3085
2982
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3086
2983
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
3087
2984
  var IdentityManager = class {
2985
+ stateUpdate = new Event4();
2986
+ _metadataStore;
2987
+ _keyring;
2988
+ _feedStore;
2989
+ _spaceManager;
2990
+ _devicePresenceAnnounceInterval;
2991
+ _devicePresenceOfflineTimeout;
2992
+ _edgeConnection;
2993
+ _edgeFeatures;
2994
+ _identity;
2995
+ // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
2996
+ constructor(params) {
2997
+ this._metadataStore = params.metadataStore;
2998
+ this._keyring = params.keyring;
2999
+ this._feedStore = params.feedStore;
3000
+ this._spaceManager = params.spaceManager;
3001
+ this._edgeConnection = params.edgeConnection;
3002
+ this._edgeFeatures = params.edgeFeatures;
3003
+ this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
3004
+ this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
3005
+ }
3088
3006
  get identity() {
3089
3007
  return this._identity;
3090
3008
  }
@@ -3519,27 +3437,6 @@ var IdentityManager = class {
3519
3437
  }
3520
3438
  });
3521
3439
  }
3522
- // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
3523
- constructor(params) {
3524
- _define_property10(this, "stateUpdate", new Event4());
3525
- _define_property10(this, "_metadataStore", void 0);
3526
- _define_property10(this, "_keyring", void 0);
3527
- _define_property10(this, "_feedStore", void 0);
3528
- _define_property10(this, "_spaceManager", void 0);
3529
- _define_property10(this, "_devicePresenceAnnounceInterval", void 0);
3530
- _define_property10(this, "_devicePresenceOfflineTimeout", void 0);
3531
- _define_property10(this, "_edgeConnection", void 0);
3532
- _define_property10(this, "_edgeFeatures", void 0);
3533
- _define_property10(this, "_identity", void 0);
3534
- this._metadataStore = params.metadataStore;
3535
- this._keyring = params.keyring;
3536
- this._feedStore = params.feedStore;
3537
- this._spaceManager = params.spaceManager;
3538
- this._edgeConnection = params.edgeConnection;
3539
- this._edgeFeatures = params.edgeFeatures;
3540
- this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
3541
- this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
3542
- }
3543
3440
  };
3544
3441
  _ts_decorate4([
3545
3442
  Trace2.span({
@@ -3559,22 +3456,18 @@ import { invariant as invariant8 } from "@dxos/invariant";
3559
3456
  import { log as log10 } from "@dxos/log";
3560
3457
  import { SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
3561
3458
  import { safeAwaitAll } from "@dxos/util";
3562
- function _define_property11(obj, key, value) {
3563
- if (key in obj) {
3564
- Object.defineProperty(obj, key, {
3565
- value,
3566
- enumerable: true,
3567
- configurable: true,
3568
- writable: true
3569
- });
3570
- } else {
3571
- obj[key] = value;
3572
- }
3573
- return obj;
3574
- }
3575
3459
  var __dxlog_file12 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
3576
3460
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
3577
3461
  var IdentityServiceImpl = class extends Resource4 {
3462
+ _identityManager;
3463
+ _recoveryManager;
3464
+ _keyring;
3465
+ _dataSpaceManagerProvider;
3466
+ _createIdentity;
3467
+ _onProfileUpdate;
3468
+ constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
3469
+ super(), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
3470
+ }
3578
3471
  async _open() {
3579
3472
  const identity = this._identityManager.identity;
3580
3473
  if (identity && !identity.defaultSpaceId) {
@@ -3749,29 +3642,21 @@ var IdentityServiceImpl = class extends Resource4 {
3749
3642
  await this._createDefaultSpace(dataSpaceManager);
3750
3643
  }
3751
3644
  }
3752
- constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
3753
- 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;
3754
- }
3755
3645
  };
3756
3646
 
3757
3647
  // src/packlets/spaces/automerge-space-state.ts
3758
3648
  import { Event as Event5 } from "@dxos/async";
3759
3649
  import { Resource as Resource5 } from "@dxos/context";
3760
3650
  import { checkCredentialType } from "@dxos/credentials";
3761
- function _define_property12(obj, key, value) {
3762
- if (key in obj) {
3763
- Object.defineProperty(obj, key, {
3764
- value,
3765
- enumerable: true,
3766
- configurable: true,
3767
- writable: true
3768
- });
3769
- } else {
3770
- obj[key] = value;
3771
- }
3772
- return obj;
3773
- }
3774
3651
  var AutomergeSpaceState = class extends Resource5 {
3652
+ _onNewRoot;
3653
+ rootUrl = void 0;
3654
+ lastEpoch = void 0;
3655
+ onNewEpoch = new Event5();
3656
+ _isProcessingRootDocs = false;
3657
+ constructor(_onNewRoot) {
3658
+ super(), this._onNewRoot = _onNewRoot;
3659
+ }
3775
3660
  async _open(ctx) {
3776
3661
  }
3777
3662
  async _close(ctx) {
@@ -3802,9 +3687,6 @@ var AutomergeSpaceState = class extends Resource5 {
3802
3687
  async ensureEpochInitialized() {
3803
3688
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3804
3689
  }
3805
- constructor(_onNewRoot) {
3806
- 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;
3807
- }
3808
3690
  };
3809
3691
 
3810
3692
  // src/packlets/spaces/epoch-migrations.ts
@@ -3871,19 +3753,6 @@ import { EdgeCallFailedError } from "@dxos/protocols";
3871
3753
  import { schema as schema2 } from "@dxos/protocols/proto";
3872
3754
  import { RpcExtension } from "@dxos/teleport";
3873
3755
  import { ComplexMap as ComplexMap4, ComplexSet as ComplexSet2, entry } from "@dxos/util";
3874
- function _define_property13(obj, key, value) {
3875
- if (key in obj) {
3876
- Object.defineProperty(obj, key, {
3877
- value,
3878
- enumerable: true,
3879
- configurable: true,
3880
- writable: true
3881
- });
3882
- } else {
3883
- obj[key] = value;
3884
- }
3885
- return obj;
3886
- }
3887
3756
  function _ts_decorate5(decorators, target, key, desc) {
3888
3757
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3889
3758
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3899,6 +3768,24 @@ var MAX_EDGE_RETRIES = 2;
3899
3768
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3900
3769
  var credentialCodec = schema2.getCodecForType("dxos.halo.credentials.Credential");
3901
3770
  var NotarizationPlugin = class extends Resource6 {
3771
+ _extensionOpened = new Event6();
3772
+ _writer;
3773
+ _extensions = /* @__PURE__ */ new Set();
3774
+ _processedCredentials = new ComplexSet2(PublicKey7.hash);
3775
+ _processCredentialsTriggers = new ComplexMap4(PublicKey7.hash);
3776
+ _activeEdgePollingIntervalHandle = void 0;
3777
+ _activeEdgePollingInterval;
3778
+ _activeEdgePollingEnabled = false;
3779
+ _spaceId;
3780
+ _edgeClient;
3781
+ constructor(params) {
3782
+ super();
3783
+ this._spaceId = params.spaceId;
3784
+ this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
3785
+ if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
3786
+ this._edgeClient = params.edgeClient;
3787
+ }
3788
+ }
3902
3789
  setActiveEdgePollingEnabled(enabled) {
3903
3790
  const client = this._edgeClient;
3904
3791
  invariant10(client, void 0, {
@@ -4258,14 +4145,6 @@ var NotarizationPlugin = class extends Resource6 {
4258
4145
  errors.throw(new TimeoutError(timeout, "Notarization timed out"));
4259
4146
  }, timeout);
4260
4147
  }
4261
- constructor(params) {
4262
- 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);
4263
- this._spaceId = params.spaceId;
4264
- this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
4265
- if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
4266
- this._edgeClient = params.edgeClient;
4267
- }
4268
- }
4269
4148
  };
4270
4149
  _ts_decorate5([
4271
4150
  logInfo2
@@ -4290,6 +4169,17 @@ var handleEdgeError = (error) => {
4290
4169
  }
4291
4170
  };
4292
4171
  var NotarizationTeleportExtension = class extends RpcExtension {
4172
+ _params;
4173
+ constructor(_params) {
4174
+ super({
4175
+ requested: {
4176
+ NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4177
+ },
4178
+ exposed: {
4179
+ NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4180
+ }
4181
+ }), this._params = _params;
4182
+ }
4293
4183
  async getHandlers() {
4294
4184
  return {
4295
4185
  NotarizationService: {
@@ -4307,32 +4197,9 @@ var NotarizationTeleportExtension = class extends RpcExtension {
4307
4197
  await this._params.onClose();
4308
4198
  await super.onClose(err);
4309
4199
  }
4310
- constructor(_params) {
4311
- super({
4312
- requested: {
4313
- NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4314
- },
4315
- exposed: {
4316
- NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4317
- }
4318
- }), _define_property13(this, "_params", void 0), this._params = _params;
4319
- }
4320
4200
  };
4321
4201
 
4322
4202
  // src/packlets/spaces/data-space.ts
4323
- function _define_property14(obj, key, value) {
4324
- if (key in obj) {
4325
- Object.defineProperty(obj, key, {
4326
- value,
4327
- enumerable: true,
4328
- configurable: true,
4329
- writable: true
4330
- });
4331
- } else {
4332
- obj[key] = value;
4333
- }
4334
- return obj;
4335
- }
4336
4203
  function _ts_decorate6(decorators, target, key, desc) {
4337
4204
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4338
4205
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -4406,6 +4273,75 @@ function _ts_dispose_resources3(env) {
4406
4273
  }
4407
4274
  var __dxlog_file15 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4408
4275
  var DataSpace = class {
4276
+ _ctx = new Context6(void 0, {
4277
+ F: __dxlog_file15,
4278
+ L: 101
4279
+ });
4280
+ _inner;
4281
+ _gossip;
4282
+ _presence;
4283
+ _keyring;
4284
+ _feedStore;
4285
+ _metadataStore;
4286
+ _signingContext;
4287
+ _notarizationPlugin;
4288
+ _callbacks;
4289
+ _cache = void 0;
4290
+ _echoHost;
4291
+ _edgeFeedReplicator = void 0;
4292
+ // TODO(dmaretskyi): Move into Space?
4293
+ _automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
4294
+ _epochProcessingMutex = new Mutex2();
4295
+ _state = SpaceState4.SPACE_CLOSED;
4296
+ _databaseRoot = null;
4297
+ /**
4298
+ * Error for _state === SpaceState.SPACE_ERROR.
4299
+ */
4300
+ error = void 0;
4301
+ authVerifier;
4302
+ stateUpdate = new Event7();
4303
+ postOpen = new CallbackCollection();
4304
+ preClose = new CallbackCollection();
4305
+ metrics = {};
4306
+ constructor(params) {
4307
+ this._inner = params.inner;
4308
+ this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
4309
+ this._gossip = params.gossip;
4310
+ this._presence = params.presence;
4311
+ this._keyring = params.keyring;
4312
+ this._feedStore = params.feedStore;
4313
+ this._metadataStore = params.metadataStore;
4314
+ this._signingContext = params.signingContext;
4315
+ this._callbacks = params.callbacks ?? {};
4316
+ this._echoHost = params.echoHost;
4317
+ this._notarizationPlugin = new NotarizationPlugin({
4318
+ spaceId: this._inner.id,
4319
+ edgeClient: params.edgeHttpClient,
4320
+ edgeFeatures: params.edgeFeatures,
4321
+ activeEdgePollingInterval: params.activeEdgeNotarizationPollingInterval
4322
+ });
4323
+ this.authVerifier = new TrustedKeySetAuthVerifier({
4324
+ trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
4325
+ update: this._inner.stateUpdate,
4326
+ authTimeout: AUTH_TIMEOUT2
4327
+ });
4328
+ this._cache = params.cache;
4329
+ if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
4330
+ this._edgeFeedReplicator = new EdgeFeedReplicator({
4331
+ messenger: params.edgeConnection,
4332
+ spaceId: this.id
4333
+ });
4334
+ }
4335
+ this._state = params.initialState;
4336
+ log12("new state", {
4337
+ state: SpaceState4[this._state]
4338
+ }, {
4339
+ F: __dxlog_file15,
4340
+ L: 177,
4341
+ S: this,
4342
+ C: (f, a) => f(...a)
4343
+ });
4344
+ }
4409
4345
  get id() {
4410
4346
  return this._inner.id;
4411
4347
  }
@@ -4892,74 +4828,9 @@ var DataSpace = class {
4892
4828
  getEdgeReplicationSetting() {
4893
4829
  return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
4894
4830
  }
4895
- constructor(params) {
4896
- _define_property14(this, "_ctx", new Context6(void 0, {
4897
- F: __dxlog_file15,
4898
- L: 101
4899
- }));
4900
- _define_property14(this, "_inner", void 0);
4901
- _define_property14(this, "_gossip", void 0);
4902
- _define_property14(this, "_presence", void 0);
4903
- _define_property14(this, "_keyring", void 0);
4904
- _define_property14(this, "_feedStore", void 0);
4905
- _define_property14(this, "_metadataStore", void 0);
4906
- _define_property14(this, "_signingContext", void 0);
4907
- _define_property14(this, "_notarizationPlugin", void 0);
4908
- _define_property14(this, "_callbacks", void 0);
4909
- _define_property14(this, "_cache", void 0);
4910
- _define_property14(this, "_echoHost", void 0);
4911
- _define_property14(this, "_edgeFeedReplicator", void 0);
4912
- _define_property14(this, "_automergeSpaceState", new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl)));
4913
- _define_property14(this, "_epochProcessingMutex", new Mutex2());
4914
- _define_property14(this, "_state", SpaceState4.SPACE_CLOSED);
4915
- _define_property14(this, "_databaseRoot", null);
4916
- _define_property14(this, "error", void 0);
4917
- _define_property14(this, "authVerifier", void 0);
4918
- _define_property14(this, "stateUpdate", new Event7());
4919
- _define_property14(this, "postOpen", new CallbackCollection());
4920
- _define_property14(this, "preClose", new CallbackCollection());
4921
- _define_property14(this, "metrics", {});
4922
- _define_property14(this, "_onFeedAdded", async (feed) => {
4923
- await this._edgeFeedReplicator.addFeed(feed);
4924
- });
4925
- this._inner = params.inner;
4926
- this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
4927
- this._gossip = params.gossip;
4928
- this._presence = params.presence;
4929
- this._keyring = params.keyring;
4930
- this._feedStore = params.feedStore;
4931
- this._metadataStore = params.metadataStore;
4932
- this._signingContext = params.signingContext;
4933
- this._callbacks = params.callbacks ?? {};
4934
- this._echoHost = params.echoHost;
4935
- this._notarizationPlugin = new NotarizationPlugin({
4936
- spaceId: this._inner.id,
4937
- edgeClient: params.edgeHttpClient,
4938
- edgeFeatures: params.edgeFeatures,
4939
- activeEdgePollingInterval: params.activeEdgeNotarizationPollingInterval
4940
- });
4941
- this.authVerifier = new TrustedKeySetAuthVerifier({
4942
- trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
4943
- update: this._inner.stateUpdate,
4944
- authTimeout: AUTH_TIMEOUT2
4945
- });
4946
- this._cache = params.cache;
4947
- if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
4948
- this._edgeFeedReplicator = new EdgeFeedReplicator({
4949
- messenger: params.edgeConnection,
4950
- spaceId: this.id
4951
- });
4952
- }
4953
- this._state = params.initialState;
4954
- log12("new state", {
4955
- state: SpaceState4[this._state]
4956
- }, {
4957
- F: __dxlog_file15,
4958
- L: 177,
4959
- S: this,
4960
- C: (f, a) => f(...a)
4961
- });
4962
- }
4831
+ _onFeedAdded = async (feed) => {
4832
+ await this._edgeFeedReplicator.addFeed(feed);
4833
+ };
4963
4834
  };
4964
4835
  _ts_decorate6([
4965
4836
  trace5.info()
@@ -5015,21 +4886,16 @@ import { getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credent
5015
4886
  import { invariant as invariant12 } from "@dxos/invariant";
5016
4887
  import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
5017
4888
  import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
5018
- function _define_property15(obj, key, value) {
5019
- if (key in obj) {
5020
- Object.defineProperty(obj, key, {
5021
- value,
5022
- enumerable: true,
5023
- configurable: true,
5024
- writable: true
5025
- });
5026
- } else {
5027
- obj[key] = value;
5028
- }
5029
- return obj;
5030
- }
5031
4889
  var __dxlog_file16 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
5032
4890
  var DeviceInvitationProtocol = class {
4891
+ _keyring;
4892
+ _getIdentity;
4893
+ _acceptIdentity;
4894
+ constructor(_keyring, _getIdentity, _acceptIdentity) {
4895
+ this._keyring = _keyring;
4896
+ this._getIdentity = _getIdentity;
4897
+ this._acceptIdentity = _acceptIdentity;
4898
+ }
5033
4899
  toJSON() {
5034
4900
  return {
5035
4901
  kind: "device"
@@ -5141,14 +5007,6 @@ var DeviceInvitationProtocol = class {
5141
5007
  identityKey
5142
5008
  };
5143
5009
  }
5144
- constructor(_keyring, _getIdentity, _acceptIdentity) {
5145
- _define_property15(this, "_keyring", void 0);
5146
- _define_property15(this, "_getIdentity", void 0);
5147
- _define_property15(this, "_acceptIdentity", void 0);
5148
- this._keyring = _keyring;
5149
- this._getIdentity = _getIdentity;
5150
- this._acceptIdentity = _acceptIdentity;
5151
- }
5152
5010
  };
5153
5011
 
5154
5012
  // src/packlets/invitations/invitations-handler.ts
@@ -5203,24 +5061,22 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
5203
5061
  };
5204
5062
 
5205
5063
  // src/packlets/invitations/edge-invitation-handler.ts
5206
- function _define_property16(obj, key, value) {
5207
- if (key in obj) {
5208
- Object.defineProperty(obj, key, {
5209
- value,
5210
- enumerable: true,
5211
- configurable: true,
5212
- writable: true
5213
- });
5214
- } else {
5215
- obj[key] = value;
5216
- }
5217
- return obj;
5218
- }
5219
5064
  var __dxlog_file17 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
5220
5065
  var MAX_RETRIES_PER_INVITATION = 5;
5221
5066
  var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
5222
5067
  var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
5223
5068
  var EdgeInvitationHandler = class {
5069
+ _client;
5070
+ _callbacks;
5071
+ _flowLock;
5072
+ _retryInterval;
5073
+ _retryJitter;
5074
+ constructor(config, _client, _callbacks) {
5075
+ this._client = _client;
5076
+ this._callbacks = _callbacks;
5077
+ this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
5078
+ this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
5079
+ }
5224
5080
  handle(ctx, guardedState, protocol, deviceProfile) {
5225
5081
  if (!this._client) {
5226
5082
  log13("edge disabled", void 0, {
@@ -5363,17 +5219,6 @@ var EdgeInvitationHandler = class {
5363
5219
  _calculateNextRetryMs() {
5364
5220
  return this._retryInterval + Math.random() * this._retryJitter;
5365
5221
  }
5366
- constructor(config, _client, _callbacks) {
5367
- _define_property16(this, "_client", void 0);
5368
- _define_property16(this, "_callbacks", void 0);
5369
- _define_property16(this, "_flowLock", void 0);
5370
- _define_property16(this, "_retryInterval", void 0);
5371
- _define_property16(this, "_retryJitter", void 0);
5372
- this._client = _client;
5373
- this._callbacks = _callbacks;
5374
- this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
5375
- this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
5376
- }
5377
5222
  };
5378
5223
 
5379
5224
  // src/packlets/invitations/invitation-guest-extenstion.ts
@@ -5385,22 +5230,31 @@ import { InvalidInvitationExtensionRoleError } from "@dxos/protocols";
5385
5230
  import { schema as schema4 } from "@dxos/protocols/proto";
5386
5231
  import { InvitationOptions } from "@dxos/protocols/proto/dxos/halo/invitations";
5387
5232
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
5388
- function _define_property17(obj, key, value) {
5389
- if (key in obj) {
5390
- Object.defineProperty(obj, key, {
5391
- value,
5392
- enumerable: true,
5393
- configurable: true,
5394
- writable: true
5395
- });
5396
- } else {
5397
- obj[key] = value;
5398
- }
5399
- return obj;
5400
- }
5401
5233
  var __dxlog_file18 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
5402
5234
  var OPTIONS_TIMEOUT = 1e4;
5403
5235
  var InvitationGuestExtension = class extends RpcExtension2 {
5236
+ _invitationFlowMutex;
5237
+ _callbacks;
5238
+ _ctx = new Context7(void 0, {
5239
+ F: __dxlog_file18,
5240
+ L: 38
5241
+ });
5242
+ _remoteOptions;
5243
+ _remoteOptionsTrigger = new Trigger4();
5244
+ /**
5245
+ * Held to allow only one invitation flow at a time to be active.
5246
+ */
5247
+ _invitationFlowLock = null;
5248
+ constructor(_invitationFlowMutex, _callbacks) {
5249
+ super({
5250
+ requested: {
5251
+ InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5252
+ },
5253
+ exposed: {
5254
+ InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5255
+ }
5256
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks;
5257
+ }
5404
5258
  hasFlowLock() {
5405
5259
  return this._invitationFlowLock != null;
5406
5260
  }
@@ -5502,22 +5356,6 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5502
5356
  });
5503
5357
  }
5504
5358
  }
5505
- constructor(_invitationFlowMutex, _callbacks) {
5506
- super({
5507
- requested: {
5508
- InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5509
- },
5510
- exposed: {
5511
- InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5512
- }
5513
- }), _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), /**
5514
- * Held to allow only one invitation flow at a time to be active.
5515
- */
5516
- _define_property17(this, "_invitationFlowLock", void 0), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context7(void 0, {
5517
- F: __dxlog_file18,
5518
- L: 38
5519
- }), this._remoteOptionsTrigger = new Trigger4(), this._invitationFlowLock = null;
5520
- }
5521
5359
  };
5522
5360
 
5523
5361
  // src/packlets/invitations/invitation-host-extension.ts
@@ -5532,26 +5370,49 @@ import { schema as schema5 } from "@dxos/protocols/proto";
5532
5370
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
5533
5371
  import { AuthenticationResponse, InvitationOptions as InvitationOptions2 } from "@dxos/protocols/proto/dxos/halo/invitations";
5534
5372
  import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
5535
- function _define_property18(obj, key, value) {
5536
- if (key in obj) {
5537
- Object.defineProperty(obj, key, {
5538
- value,
5539
- enumerable: true,
5540
- configurable: true,
5541
- writable: true
5542
- });
5543
- } else {
5544
- obj[key] = value;
5545
- }
5546
- return obj;
5547
- }
5548
5373
  var __dxlog_file19 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
5549
5374
  var OPTIONS_TIMEOUT2 = 1e4;
5550
5375
  var MAX_OTP_ATTEMPTS = 3;
5551
5376
  var InvitationHostExtension = class extends RpcExtension3 {
5552
- hasFlowLock() {
5553
- return this._invitationFlowLock != null;
5554
- }
5377
+ _invitationFlowMutex;
5378
+ _callbacks;
5379
+ /**
5380
+ * @internal
5381
+ */
5382
+ _ctx = new Context8(void 0, {
5383
+ F: __dxlog_file19,
5384
+ L: 57
5385
+ });
5386
+ _remoteOptions;
5387
+ _remoteOptionsTrigger = new Trigger5();
5388
+ _challenge = void 0;
5389
+ guestProfile = void 0;
5390
+ authenticationPassed = false;
5391
+ /**
5392
+ * Retry counter for SHARED_SECRET authentication method.
5393
+ */
5394
+ authenticationRetry = 0;
5395
+ /**
5396
+ * Resolved when admission is completed.
5397
+ */
5398
+ completedTrigger = new Trigger5();
5399
+ /**
5400
+ * Held to allow only one invitation flow at a time to be active.
5401
+ */
5402
+ _invitationFlowLock = null;
5403
+ constructor(_invitationFlowMutex, _callbacks) {
5404
+ super({
5405
+ requested: {
5406
+ InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5407
+ },
5408
+ exposed: {
5409
+ InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5410
+ }
5411
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks;
5412
+ }
5413
+ hasFlowLock() {
5414
+ return this._invitationFlowLock != null;
5415
+ }
5555
5416
  async getHandlers() {
5556
5417
  return {
5557
5418
  // TODO(dmaretskyi): For now this is just forwarding the data to callbacks since we don't have session-specific logic.
@@ -5849,31 +5710,6 @@ var InvitationHostExtension = class extends RpcExtension3 {
5849
5710
  });
5850
5711
  }
5851
5712
  }
5852
- constructor(_invitationFlowMutex, _callbacks) {
5853
- super({
5854
- requested: {
5855
- InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5856
- },
5857
- exposed: {
5858
- InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5859
- }
5860
- }), _define_property18(this, "_invitationFlowMutex", void 0), _define_property18(this, "_callbacks", void 0), /**
5861
- * @internal
5862
- */
5863
- _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), /**
5864
- * Retry counter for SHARED_SECRET authentication method.
5865
- */
5866
- _define_property18(this, "authenticationRetry", void 0), /**
5867
- * Resolved when admission is completed.
5868
- */
5869
- _define_property18(this, "completedTrigger", void 0), /**
5870
- * Held to allow only one invitation flow at a time to be active.
5871
- */
5872
- _define_property18(this, "_invitationFlowLock", void 0), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context8(void 0, {
5873
- F: __dxlog_file19,
5874
- L: 57
5875
- }), this._remoteOptionsTrigger = new Trigger5(), this._challenge = void 0, this.guestProfile = void 0, this.authenticationPassed = false, this.authenticationRetry = 0, this.completedTrigger = new Trigger5(), this._invitationFlowLock = null;
5876
- }
5877
5713
  };
5878
5714
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation5.AuthMethod.NONE;
5879
5715
 
@@ -5979,21 +5815,22 @@ import { PublicKey as PublicKey10 } from "@dxos/keys";
5979
5815
  import { log as log17 } from "@dxos/log";
5980
5816
  import { InvitationOptions as InvitationOptions3 } from "@dxos/protocols/proto/dxos/halo/invitations";
5981
5817
  import { ComplexSet as ComplexSet4 } from "@dxos/util";
5982
- function _define_property19(obj, key, value) {
5983
- if (key in obj) {
5984
- Object.defineProperty(obj, key, {
5985
- value,
5986
- enumerable: true,
5987
- configurable: true,
5988
- writable: true
5989
- });
5990
- } else {
5991
- obj[key] = value;
5992
- }
5993
- return obj;
5994
- }
5995
5818
  var __dxlog_file21 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
5996
5819
  var InvitationTopology = class {
5820
+ _role;
5821
+ _controller;
5822
+ /**
5823
+ * Peers we tried to establish a connection with.
5824
+ * In invitation flow peers are assigned random ids when they join the swarm, so we'll retry
5825
+ * a peer if they reload an invitation.
5826
+ *
5827
+ * Consider keeping a separate set for peers we know are hosts and have some retry timeout
5828
+ * for guests we failed an invitation flow with (potentially due to a network error).
5829
+ */
5830
+ _seenPeers = new ComplexSet4(PublicKey10.hash);
5831
+ constructor(_role) {
5832
+ this._role = _role;
5833
+ }
5997
5834
  init(controller) {
5998
5835
  invariant16(!this._controller, "Already initialized.", {
5999
5836
  F: __dxlog_file21,
@@ -6058,33 +5895,24 @@ var InvitationTopology = class {
6058
5895
  toString() {
6059
5896
  return `InvitationTopology(${this._role === InvitationOptions3.Role.GUEST ? "guest" : "host"})`;
6060
5897
  }
6061
- constructor(_role) {
6062
- _define_property19(this, "_role", void 0);
6063
- _define_property19(this, "_controller", void 0);
6064
- _define_property19(this, "_seenPeers", void 0);
6065
- this._role = _role;
6066
- this._seenPeers = new ComplexSet4(PublicKey10.hash);
6067
- }
6068
5898
  };
6069
5899
 
6070
5900
  // src/packlets/invitations/invitations-handler.ts
6071
- function _define_property20(obj, key, value) {
6072
- if (key in obj) {
6073
- Object.defineProperty(obj, key, {
6074
- value,
6075
- enumerable: true,
6076
- configurable: true,
6077
- writable: true
6078
- });
6079
- } else {
6080
- obj[key] = value;
6081
- }
6082
- return obj;
6083
- }
6084
5901
  var __dxlog_file22 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
6085
5902
  var metrics = _trace.metrics;
6086
5903
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
6087
5904
  var InvitationsHandler = class {
5905
+ _networkManager;
5906
+ _edgeClient;
5907
+ _connectionParams;
5908
+ /**
5909
+ * @internal
5910
+ */
5911
+ constructor(_networkManager, _edgeClient, _connectionParams) {
5912
+ this._networkManager = _networkManager;
5913
+ this._edgeClient = _edgeClient;
5914
+ this._connectionParams = _connectionParams;
5915
+ }
6088
5916
  handleInvitationFlow(ctx, stream, protocol, invitation) {
6089
5917
  log18.verbose("dxos.sdk.invitations-handler.handleInvitationFlow", {
6090
5918
  state: invitation.state,
@@ -6655,17 +6483,6 @@ var InvitationsHandler = class {
6655
6483
  throw new Error(`Authentication failed with code: ${response.status}`);
6656
6484
  }
6657
6485
  }
6658
- /**
6659
- * @internal
6660
- */
6661
- constructor(_networkManager, _edgeClient, _connectionParams) {
6662
- _define_property20(this, "_networkManager", void 0);
6663
- _define_property20(this, "_edgeClient", void 0);
6664
- _define_property20(this, "_connectionParams", void 0);
6665
- this._networkManager = _networkManager;
6666
- this._edgeClient = _edgeClient;
6667
- this._connectionParams = _connectionParams;
6668
- }
6669
6486
  };
6670
6487
  var checkInvitation = (protocol, invitation) => {
6671
6488
  const expiresOn = getExpirationTime(invitation);
@@ -6686,20 +6503,11 @@ var createAdmissionKeypair = () => {
6686
6503
  import { Stream as Stream9 } from "@dxos/codec-protobuf/stream";
6687
6504
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
6688
6505
  import { trace as trace8 } from "@dxos/tracing";
6689
- function _define_property21(obj, key, value) {
6690
- if (key in obj) {
6691
- Object.defineProperty(obj, key, {
6692
- value,
6693
- enumerable: true,
6694
- configurable: true,
6695
- writable: true
6696
- });
6697
- } else {
6698
- obj[key] = value;
6699
- }
6700
- return obj;
6701
- }
6702
6506
  var InvitationsServiceImpl = class {
6507
+ _invitationsManager;
6508
+ constructor(_invitationsManager) {
6509
+ this._invitationsManager = _invitationsManager;
6510
+ }
6703
6511
  // TODO(burdon): Guest/host label.
6704
6512
  getLoggingContext() {
6705
6513
  return {};
@@ -6791,10 +6599,6 @@ var InvitationsServiceImpl = class {
6791
6599
  });
6792
6600
  });
6793
6601
  }
6794
- constructor(_invitationsManager) {
6795
- _define_property21(this, "_invitationsManager", void 0);
6796
- this._invitationsManager = _invitationsManager;
6797
- }
6798
6602
  };
6799
6603
 
6800
6604
  // src/packlets/invitations/space-invitation-protocol.ts
@@ -6805,21 +6609,18 @@ import { log as log19 } from "@dxos/log";
6805
6609
  import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError as InvalidInvitationError2, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
6806
6610
  import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
6807
6611
  import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
6808
- function _define_property22(obj, key, value) {
6809
- if (key in obj) {
6810
- Object.defineProperty(obj, key, {
6811
- value,
6812
- enumerable: true,
6813
- configurable: true,
6814
- writable: true
6815
- });
6816
- } else {
6817
- obj[key] = value;
6818
- }
6819
- return obj;
6820
- }
6821
6612
  var __dxlog_file23 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
6822
6613
  var SpaceInvitationProtocol = class {
6614
+ _spaceManager;
6615
+ _signingContext;
6616
+ _keyring;
6617
+ _spaceKey;
6618
+ constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
6619
+ this._spaceManager = _spaceManager;
6620
+ this._signingContext = _signingContext;
6621
+ this._keyring = _keyring;
6622
+ this._spaceKey = _spaceKey;
6623
+ }
6823
6624
  toJSON() {
6824
6625
  return {
6825
6626
  kind: "space",
@@ -7084,16 +6885,6 @@ var SpaceInvitationProtocol = class {
7084
6885
  spaceKey: assertion.spaceKey
7085
6886
  };
7086
6887
  }
7087
- constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
7088
- _define_property22(this, "_spaceManager", void 0);
7089
- _define_property22(this, "_signingContext", void 0);
7090
- _define_property22(this, "_keyring", void 0);
7091
- _define_property22(this, "_spaceKey", void 0);
7092
- this._spaceManager = _spaceManager;
7093
- this._signingContext = _signingContext;
7094
- this._keyring = _keyring;
7095
- this._spaceKey = _spaceKey;
7096
- }
7097
6888
  };
7098
6889
 
7099
6890
  // src/packlets/invitations/invitations-manager.ts
@@ -7107,21 +6898,25 @@ import { PublicKey as PublicKey12 } from "@dxos/keys";
7107
6898
  import { log as log20 } from "@dxos/log";
7108
6899
  import { Invitation as Invitation9 } from "@dxos/protocols/proto/dxos/client/services";
7109
6900
  import { SpaceMember as SpaceMember7 } from "@dxos/protocols/proto/dxos/halo/credentials";
7110
- function _define_property23(obj, key, value) {
7111
- if (key in obj) {
7112
- Object.defineProperty(obj, key, {
7113
- value,
7114
- enumerable: true,
7115
- configurable: true,
7116
- writable: true
7117
- });
7118
- } else {
7119
- obj[key] = value;
7120
- }
7121
- return obj;
7122
- }
7123
6901
  var __dxlog_file24 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
7124
6902
  var InvitationsManager = class {
6903
+ _invitationsHandler;
6904
+ _getHandler;
6905
+ _metadataStore;
6906
+ _createInvitations = /* @__PURE__ */ new Map();
6907
+ _acceptInvitations = /* @__PURE__ */ new Map();
6908
+ invitationCreated = new Event8();
6909
+ invitationAccepted = new Event8();
6910
+ removedCreated = new Event8();
6911
+ removedAccepted = new Event8();
6912
+ saved = new Event8();
6913
+ _persistentInvitationsLoadedEvent = new Event8();
6914
+ _persistentInvitationsLoaded = false;
6915
+ constructor(_invitationsHandler, _getHandler, _metadataStore) {
6916
+ this._invitationsHandler = _invitationsHandler;
6917
+ this._getHandler = _getHandler;
6918
+ this._metadataStore = _metadataStore;
6919
+ }
7125
6920
  async createInvitation(options) {
7126
6921
  if (options.invitationId) {
7127
6922
  const existingInvitation = this._createInvitations.get(options.invitationId);
@@ -7465,51 +7260,12 @@ var InvitationsManager = class {
7465
7260
  }, () => {
7466
7261
  }, callback);
7467
7262
  }
7468
- constructor(_invitationsHandler, _getHandler, _metadataStore) {
7469
- _define_property23(this, "_invitationsHandler", void 0);
7470
- _define_property23(this, "_getHandler", void 0);
7471
- _define_property23(this, "_metadataStore", void 0);
7472
- _define_property23(this, "_createInvitations", void 0);
7473
- _define_property23(this, "_acceptInvitations", void 0);
7474
- _define_property23(this, "invitationCreated", void 0);
7475
- _define_property23(this, "invitationAccepted", void 0);
7476
- _define_property23(this, "removedCreated", void 0);
7477
- _define_property23(this, "removedAccepted", void 0);
7478
- _define_property23(this, "saved", void 0);
7479
- _define_property23(this, "_persistentInvitationsLoadedEvent", void 0);
7480
- _define_property23(this, "_persistentInvitationsLoaded", void 0);
7481
- this._invitationsHandler = _invitationsHandler;
7482
- this._getHandler = _getHandler;
7483
- this._metadataStore = _metadataStore;
7484
- this._createInvitations = /* @__PURE__ */ new Map();
7485
- this._acceptInvitations = /* @__PURE__ */ new Map();
7486
- this.invitationCreated = new Event8();
7487
- this.invitationAccepted = new Event8();
7488
- this.removedCreated = new Event8();
7489
- this.removedAccepted = new Event8();
7490
- this.saved = new Event8();
7491
- this._persistentInvitationsLoadedEvent = new Event8();
7492
- this._persistentInvitationsLoaded = false;
7493
- }
7494
7263
  };
7495
7264
 
7496
7265
  // src/packlets/locks/node.ts
7497
7266
  import { invariant as invariant20 } from "@dxos/invariant";
7498
7267
  import { LockFile } from "@dxos/lock-file";
7499
7268
  import { log as log21, logInfo as logInfo3 } from "@dxos/log";
7500
- function _define_property24(obj, key, value) {
7501
- if (key in obj) {
7502
- Object.defineProperty(obj, key, {
7503
- value,
7504
- enumerable: true,
7505
- configurable: true,
7506
- writable: true
7507
- });
7508
- } else {
7509
- obj[key] = value;
7510
- }
7511
- return obj;
7512
- }
7513
7269
  function _ts_decorate7(decorators, target, key, desc) {
7514
7270
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7515
7271
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7518,6 +7274,15 @@ function _ts_decorate7(decorators, target, key, desc) {
7518
7274
  }
7519
7275
  var __dxlog_file25 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
7520
7276
  var Lock = class {
7277
+ _lockPath;
7278
+ _onAcquire;
7279
+ _onRelease;
7280
+ _fileHandle;
7281
+ constructor({ lockKey: lockPath, onAcquire, onRelease }) {
7282
+ this._lockPath = lockPath;
7283
+ this._onAcquire = onAcquire;
7284
+ this._onRelease = onRelease;
7285
+ }
7521
7286
  get lockKey() {
7522
7287
  return this._lockPath;
7523
7288
  }
@@ -7550,15 +7315,6 @@ var Lock = class {
7550
7315
  });
7551
7316
  await LockFile.release(this._fileHandle);
7552
7317
  }
7553
- constructor({ lockKey: lockPath, onAcquire, onRelease }) {
7554
- _define_property24(this, "_lockPath", void 0);
7555
- _define_property24(this, "_onAcquire", void 0);
7556
- _define_property24(this, "_onRelease", void 0);
7557
- _define_property24(this, "_fileHandle", void 0);
7558
- this._lockPath = lockPath;
7559
- this._onAcquire = onAcquire;
7560
- this._onRelease = onRelease;
7561
- }
7562
7318
  };
7563
7319
  _ts_decorate7([
7564
7320
  logInfo3
@@ -7570,19 +7326,6 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
7570
7326
  import { raise as raise2 } from "@dxos/debug";
7571
7327
  import { RpcPeer, parseMethodName } from "@dxos/rpc";
7572
7328
  import { MapCounter, trace as trace9 } from "@dxos/tracing";
7573
- function _define_property25(obj, key, value) {
7574
- if (key in obj) {
7575
- Object.defineProperty(obj, key, {
7576
- value,
7577
- enumerable: true,
7578
- configurable: true,
7579
- writable: true
7580
- });
7581
- } else {
7582
- obj[key] = value;
7583
- }
7584
- return obj;
7585
- }
7586
7329
  function _ts_decorate8(decorators, target, key, desc) {
7587
7330
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7588
7331
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7590,33 +7333,16 @@ function _ts_decorate8(decorators, target, key, desc) {
7590
7333
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7591
7334
  }
7592
7335
  var ClientRpcServer = class {
7336
+ _serviceRegistry;
7337
+ _rpcPeer;
7338
+ _handlerCache = /* @__PURE__ */ new Map();
7339
+ _handleCall;
7340
+ _handleStream;
7341
+ _callMetrics = new MapCounter();
7593
7342
  get _services() {
7594
7343
  return Object.keys(this._serviceRegistry.services);
7595
7344
  }
7596
- async open() {
7597
- await this._rpcPeer.open();
7598
- }
7599
- async close() {
7600
- await this._rpcPeer.close();
7601
- }
7602
- _getServiceHandler(serviceName) {
7603
- if (!this._handlerCache.has(serviceName)) {
7604
- const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise2(new Error(`Service not available: ${serviceName}`));
7605
- const service = this._serviceRegistry.services[key];
7606
- if (!service) {
7607
- throw new Error(`Service not available: ${serviceName}`);
7608
- }
7609
- this._handlerCache.set(serviceName, descriptor.createServer(service));
7610
- }
7611
- return this._handlerCache.get(serviceName);
7612
- }
7613
7345
  constructor(params) {
7614
- _define_property25(this, "_serviceRegistry", void 0);
7615
- _define_property25(this, "_rpcPeer", void 0);
7616
- _define_property25(this, "_handlerCache", /* @__PURE__ */ new Map());
7617
- _define_property25(this, "_handleCall", void 0);
7618
- _define_property25(this, "_handleStream", void 0);
7619
- _define_property25(this, "_callMetrics", new MapCounter());
7620
7346
  const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
7621
7347
  this._handleCall = handleCall;
7622
7348
  this._handleStream = handleStream;
@@ -7648,6 +7374,23 @@ var ClientRpcServer = class {
7648
7374
  }
7649
7375
  });
7650
7376
  }
7377
+ async open() {
7378
+ await this._rpcPeer.open();
7379
+ }
7380
+ async close() {
7381
+ await this._rpcPeer.close();
7382
+ }
7383
+ _getServiceHandler(serviceName) {
7384
+ if (!this._handlerCache.has(serviceName)) {
7385
+ const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise2(new Error(`Service not available: ${serviceName}`));
7386
+ const service = this._serviceRegistry.services[key];
7387
+ if (!service) {
7388
+ throw new Error(`Service not available: ${serviceName}`);
7389
+ }
7390
+ this._handlerCache.set(serviceName, descriptor.createServer(service));
7391
+ }
7392
+ return this._handlerCache.get(serviceName);
7393
+ }
7651
7394
  };
7652
7395
  _ts_decorate8([
7653
7396
  trace9.metricsCounter()
@@ -7668,19 +7411,6 @@ import { log as log22 } from "@dxos/log";
7668
7411
  import { EdgeAgentStatus, EdgeCallFailedError as EdgeCallFailedError3 } from "@dxos/protocols";
7669
7412
  import { SpaceState as SpaceState5 } from "@dxos/protocols/proto/dxos/client/services";
7670
7413
  import { EdgeReplicationSetting as EdgeReplicationSetting2 } from "@dxos/protocols/proto/dxos/echo/metadata";
7671
- function _define_property26(obj, key, value) {
7672
- if (key in obj) {
7673
- Object.defineProperty(obj, key, {
7674
- value,
7675
- enumerable: true,
7676
- configurable: true,
7677
- writable: true
7678
- });
7679
- } else {
7680
- obj[key] = value;
7681
- }
7682
- return obj;
7683
- }
7684
7414
  function _ts_decorate9(decorators, target, key, desc) {
7685
7415
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7686
7416
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7692,6 +7422,18 @@ var AGENT_STATUS_QUERY_RETRY_INTERVAL = 5e3;
7692
7422
  var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
7693
7423
  var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
7694
7424
  var EdgeAgentManager = class extends Resource7 {
7425
+ _edgeFeatures;
7426
+ _edgeHttpClient;
7427
+ _dataSpaceManager;
7428
+ _identity;
7429
+ agentStatusChanged = new Event9();
7430
+ _agentDeviceKey;
7431
+ _agentStatus;
7432
+ _lastKnownDeviceCount = 0;
7433
+ _fetchAgentStatusTask;
7434
+ constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7435
+ super(), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity;
7436
+ }
7695
7437
  get agentStatus() {
7696
7438
  return this._agentStatus;
7697
7439
  }
@@ -7900,9 +7642,6 @@ var EdgeAgentManager = class extends Resource7 {
7900
7642
  C: (f, a) => f(...a)
7901
7643
  });
7902
7644
  }
7903
- constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7904
- 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;
7905
- }
7906
7645
  };
7907
7646
  _ts_decorate9([
7908
7647
  synchronized3
@@ -7912,26 +7651,27 @@ _ts_decorate9([
7912
7651
  import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
7913
7652
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7914
7653
  import { EdgeStatus as EdgeStatus2, QueryAgentStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
7915
- function _define_property27(obj, key, value) {
7916
- if (key in obj) {
7917
- Object.defineProperty(obj, key, {
7918
- value,
7919
- enumerable: true,
7920
- configurable: true,
7921
- writable: true
7922
- });
7923
- } else {
7924
- obj[key] = value;
7925
- }
7926
- return obj;
7927
- }
7928
7654
  var EdgeAgentServiceImpl = class {
7655
+ _agentManagerProvider;
7656
+ _edgeConnection;
7657
+ constructor(_agentManagerProvider, _edgeConnection) {
7658
+ this._agentManagerProvider = _agentManagerProvider;
7659
+ this._edgeConnection = _edgeConnection;
7660
+ }
7929
7661
  // TODO(mykola): Reconcile with NetworkService.queryStatus.
7930
7662
  queryEdgeStatus() {
7931
7663
  return new Stream11(({ ctx, next }) => {
7932
7664
  const update = () => {
7933
7665
  next({
7934
- status: this._edgeConnection?.status ?? EdgeStatus2.NOT_CONNECTED
7666
+ status: this._edgeConnection?.status ?? {
7667
+ state: EdgeStatus2.ConnectionState.NOT_CONNECTED,
7668
+ rtt: 0,
7669
+ uptime: 0,
7670
+ rateBytesUp: 0,
7671
+ rateBytesDown: 0,
7672
+ messagesSent: 0,
7673
+ messagesReceived: 0
7674
+ }
7935
7675
  });
7936
7676
  };
7937
7677
  this._edgeConnection?.statusChanged.on(ctx, update);
@@ -7958,12 +7698,6 @@ var EdgeAgentServiceImpl = class {
7958
7698
  });
7959
7699
  });
7960
7700
  }
7961
- constructor(_agentManagerProvider, _edgeConnection) {
7962
- _define_property27(this, "_agentManagerProvider", void 0);
7963
- _define_property27(this, "_edgeConnection", void 0);
7964
- this._agentManagerProvider = _agentManagerProvider;
7965
- this._edgeConnection = _edgeConnection;
7966
- }
7967
7701
  };
7968
7702
  var mapStatus = (agentStatus) => {
7969
7703
  switch (agentStatus) {
@@ -8005,21 +7739,18 @@ import { log as log23 } from "@dxos/log";
8005
7739
  import { EdgeAuthChallengeError as EdgeAuthChallengeError2 } from "@dxos/protocols";
8006
7740
  import { schema as schema6 } from "@dxos/protocols/proto";
8007
7741
  import { Timeframe as Timeframe5 } from "@dxos/timeframe";
8008
- function _define_property28(obj, key, value) {
8009
- if (key in obj) {
8010
- Object.defineProperty(obj, key, {
8011
- value,
8012
- enumerable: true,
8013
- configurable: true,
8014
- writable: true
8015
- });
8016
- } else {
8017
- obj[key] = value;
8018
- }
8019
- return obj;
8020
- }
8021
7742
  var __dxlog_file27 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts";
8022
7743
  var EdgeIdentityRecoveryManager = class {
7744
+ _keyring;
7745
+ _edgeClient;
7746
+ _identityProvider;
7747
+ _acceptRecoveredIdentity;
7748
+ constructor(_keyring, _edgeClient, _identityProvider, _acceptRecoveredIdentity) {
7749
+ this._keyring = _keyring;
7750
+ this._edgeClient = _edgeClient;
7751
+ this._identityProvider = _identityProvider;
7752
+ this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
7753
+ }
8023
7754
  async createRecoveryCredential({ data }) {
8024
7755
  const identity = this._identityProvider();
8025
7756
  invariant22(identity, void 0, {
@@ -8212,16 +7943,6 @@ var EdgeIdentityRecoveryManager = class {
8212
7943
  dataFeedKey: await this._keyring.createKey()
8213
7944
  });
8214
7945
  }
8215
- constructor(_keyring, _edgeClient, _identityProvider, _acceptRecoveredIdentity) {
8216
- _define_property28(this, "_keyring", void 0);
8217
- _define_property28(this, "_edgeClient", void 0);
8218
- _define_property28(this, "_identityProvider", void 0);
8219
- _define_property28(this, "_acceptRecoveredIdentity", void 0);
8220
- this._keyring = _keyring;
8221
- this._edgeClient = _edgeClient;
8222
- this._identityProvider = _identityProvider;
8223
- this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
8224
- }
8225
7946
  };
8226
7947
  var decodeCredential = (credentialBase64) => {
8227
7948
  const credentialBytes = Buffer.from(credentialBase64, "base64");
@@ -8230,19 +7951,6 @@ var decodeCredential = (credentialBase64) => {
8230
7951
  };
8231
7952
 
8232
7953
  // src/packlets/services/service-context.ts
8233
- function _define_property29(obj, key, value) {
8234
- if (key in obj) {
8235
- Object.defineProperty(obj, key, {
8236
- value,
8237
- enumerable: true,
8238
- configurable: true,
8239
- writable: true
8240
- });
8241
- } else {
8242
- obj[key] = value;
8243
- }
8244
- return obj;
8245
- }
8246
7954
  function _ts_decorate10(decorators, target, key, desc) {
8247
7955
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8248
7956
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -8316,27 +8024,110 @@ function _ts_dispose_resources4(env) {
8316
8024
  }
8317
8025
  var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
8318
8026
  var ServiceContext = class extends Resource8 {
8319
- async _open(ctx) {
8320
- await this._checkStorageVersion();
8321
- log24("opening...", void 0, {
8322
- F: __dxlog_file28,
8323
- L: 204,
8324
- S: this,
8325
- C: (f, a) => f(...a)
8027
+ storage;
8028
+ level;
8029
+ networkManager;
8030
+ signalManager;
8031
+ _edgeConnection;
8032
+ _edgeHttpClient;
8033
+ _runtimeParams;
8034
+ _edgeFeatures;
8035
+ _edgeIdentityUpdateMutex = new Mutex4();
8036
+ initialized = new Trigger7();
8037
+ metadataStore;
8038
+ blobStore;
8039
+ feedStore;
8040
+ keyring;
8041
+ spaceManager;
8042
+ identityManager;
8043
+ recoveryManager;
8044
+ invitations;
8045
+ invitationsManager;
8046
+ echoHost;
8047
+ _meshReplicator = void 0;
8048
+ _echoEdgeReplicator = void 0;
8049
+ // Initialized after identity is initialized.
8050
+ dataSpaceManager;
8051
+ edgeAgentManager;
8052
+ _handlerFactories = /* @__PURE__ */ new Map();
8053
+ _deviceSpaceSync;
8054
+ _instanceId = PublicKey15.random().toHex();
8055
+ constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
8056
+ 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;
8057
+ this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
8058
+ this.blobStore = new BlobStore(storage.createDirectory("blobs"));
8059
+ this.keyring = new Keyring(storage.createDirectory("keyring"));
8060
+ this.feedStore = new FeedStore({
8061
+ factory: new FeedFactory({
8062
+ root: storage.createDirectory("feeds"),
8063
+ signer: this.keyring,
8064
+ hypercore: {
8065
+ valueEncoding,
8066
+ stats: true
8067
+ }
8068
+ })
8326
8069
  });
8327
- log24.trace("dxos.sdk.service-context.open", trace10.begin({
8328
- id: this._instanceId
8329
- }), {
8330
- F: __dxlog_file28,
8331
- L: 205,
8332
- S: this,
8333
- C: (f, a) => f(...a)
8070
+ this.spaceManager = new SpaceManager({
8071
+ feedStore: this.feedStore,
8072
+ networkManager: this.networkManager,
8073
+ blobStore: this.blobStore,
8074
+ metadataStore: this.metadataStore,
8075
+ disableP2pReplication: this._runtimeParams?.disableP2pReplication
8334
8076
  });
8335
- await this.identityManager.open(ctx);
8336
- await this._setNetworkIdentity();
8337
- await this._edgeConnection?.open();
8338
- await this.signalManager.open();
8339
- await this.networkManager.open();
8077
+ this.identityManager = new IdentityManager({
8078
+ metadataStore: this.metadataStore,
8079
+ keyring: this.keyring,
8080
+ feedStore: this.feedStore,
8081
+ spaceManager: this.spaceManager,
8082
+ devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
8083
+ devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
8084
+ edgeConnection: this._edgeConnection,
8085
+ edgeFeatures: this._edgeFeatures
8086
+ });
8087
+ this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
8088
+ this.echoHost = new EchoHost({
8089
+ kv: this.level,
8090
+ peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8091
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8092
+ indexing: {
8093
+ vector: this._runtimeParams?.enableVectorIndexing
8094
+ }
8095
+ });
8096
+ this._meshReplicator = new MeshEchoReplicator();
8097
+ this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
8098
+ this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
8099
+ this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
8100
+ if (!this._runtimeParams?.disableP2pReplication) {
8101
+ this._meshReplicator = new MeshEchoReplicator();
8102
+ }
8103
+ if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
8104
+ this._echoEdgeReplicator = new EchoEdgeReplicator({
8105
+ edgeConnection: this._edgeConnection,
8106
+ edgeHttpClient: this._edgeHttpClient
8107
+ });
8108
+ }
8109
+ }
8110
+ async _open(ctx) {
8111
+ await this._checkStorageVersion();
8112
+ log24("opening...", void 0, {
8113
+ F: __dxlog_file28,
8114
+ L: 204,
8115
+ S: this,
8116
+ C: (f, a) => f(...a)
8117
+ });
8118
+ log24.trace("dxos.sdk.service-context.open", trace10.begin({
8119
+ id: this._instanceId
8120
+ }), {
8121
+ F: __dxlog_file28,
8122
+ L: 205,
8123
+ S: this,
8124
+ C: (f, a) => f(...a)
8125
+ });
8126
+ await this.identityManager.open(ctx);
8127
+ await this._setNetworkIdentity();
8128
+ await this._edgeConnection?.open();
8129
+ await this.signalManager.open();
8130
+ await this.networkManager.open();
8340
8131
  await this.echoHost.open(ctx);
8341
8132
  if (this._meshReplicator) {
8342
8133
  await this.echoHost.addReplicator(this._meshReplicator);
@@ -8618,62 +8409,6 @@ var ServiceContext = class extends Resource8 {
8618
8409
  _ts_dispose_resources4(env);
8619
8410
  }
8620
8411
  }
8621
- constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
8622
- 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.
8623
- _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 Trigger7(), this._meshReplicator = void 0, this._echoEdgeReplicator = void 0, this._handlerFactories = /* @__PURE__ */ new Map(), this._instanceId = PublicKey15.random().toHex();
8624
- this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
8625
- this.blobStore = new BlobStore(storage.createDirectory("blobs"));
8626
- this.keyring = new Keyring(storage.createDirectory("keyring"));
8627
- this.feedStore = new FeedStore({
8628
- factory: new FeedFactory({
8629
- root: storage.createDirectory("feeds"),
8630
- signer: this.keyring,
8631
- hypercore: {
8632
- valueEncoding,
8633
- stats: true
8634
- }
8635
- })
8636
- });
8637
- this.spaceManager = new SpaceManager({
8638
- feedStore: this.feedStore,
8639
- networkManager: this.networkManager,
8640
- blobStore: this.blobStore,
8641
- metadataStore: this.metadataStore,
8642
- disableP2pReplication: this._runtimeParams?.disableP2pReplication
8643
- });
8644
- this.identityManager = new IdentityManager({
8645
- metadataStore: this.metadataStore,
8646
- keyring: this.keyring,
8647
- feedStore: this.feedStore,
8648
- spaceManager: this.spaceManager,
8649
- devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
8650
- devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
8651
- edgeConnection: this._edgeConnection,
8652
- edgeFeatures: this._edgeFeatures
8653
- });
8654
- this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
8655
- this.echoHost = new EchoHost({
8656
- kv: this.level,
8657
- peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8658
- getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8659
- indexing: {
8660
- vector: this._runtimeParams?.enableVectorIndexing
8661
- }
8662
- });
8663
- this._meshReplicator = new MeshEchoReplicator();
8664
- this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
8665
- this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
8666
- this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
8667
- if (!this._runtimeParams?.disableP2pReplication) {
8668
- this._meshReplicator = new MeshEchoReplicator();
8669
- }
8670
- if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
8671
- this._echoEdgeReplicator = new EchoEdgeReplicator({
8672
- edgeConnection: this._edgeConnection,
8673
- edgeHttpClient: this._edgeHttpClient
8674
- });
8675
- }
8676
- }
8677
8412
  };
8678
8413
  _ts_decorate10([
8679
8414
  Trace3.span()
@@ -8920,20 +8655,14 @@ var importProfileData = async ({ storage, level }, archive) => {
8920
8655
  };
8921
8656
 
8922
8657
  // src/packlets/services/service-registry.ts
8923
- function _define_property30(obj, key, value) {
8924
- if (key in obj) {
8925
- Object.defineProperty(obj, key, {
8926
- value,
8927
- enumerable: true,
8928
- configurable: true,
8929
- writable: true
8930
- });
8931
- } else {
8932
- obj[key] = value;
8933
- }
8934
- return obj;
8935
- }
8936
8658
  var ServiceRegistry = class {
8659
+ _serviceBundle;
8660
+ _handlers;
8661
+ // prettier-ignore
8662
+ constructor(_serviceBundle, _handlers = {}) {
8663
+ this._serviceBundle = _serviceBundle;
8664
+ this._handlers = _handlers;
8665
+ }
8937
8666
  get descriptors() {
8938
8667
  return this._serviceBundle;
8939
8668
  }
@@ -8949,13 +8678,6 @@ var ServiceRegistry = class {
8949
8678
  removeService(name) {
8950
8679
  delete this._handlers[name];
8951
8680
  }
8952
- // prettier-ignore
8953
- constructor(_serviceBundle, _handlers = {}) {
8954
- _define_property30(this, "_serviceBundle", void 0);
8955
- _define_property30(this, "_handlers", void 0);
8956
- this._serviceBundle = _serviceBundle;
8957
- this._handlers = _handlers;
8958
- }
8959
8681
  };
8960
8682
 
8961
8683
  // src/packlets/services/service-host.ts
@@ -8978,21 +8700,14 @@ import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
8978
8700
  import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8979
8701
  import { invariant as invariant25 } from "@dxos/invariant";
8980
8702
  import { Device as Device2, DeviceKind as DeviceKind2, EdgeStatus as EdgeStatus3 } from "@dxos/protocols/proto/dxos/client/services";
8981
- function _define_property31(obj, key, value) {
8982
- if (key in obj) {
8983
- Object.defineProperty(obj, key, {
8984
- value,
8985
- enumerable: true,
8986
- configurable: true,
8987
- writable: true
8988
- });
8989
- } else {
8990
- obj[key] = value;
8991
- }
8992
- return obj;
8993
- }
8994
8703
  var __dxlog_file30 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8995
8704
  var DevicesServiceImpl = class {
8705
+ _identityManager;
8706
+ _edgeConnection;
8707
+ constructor(_identityManager, _edgeConnection) {
8708
+ this._identityManager = _identityManager;
8709
+ this._edgeConnection = _edgeConnection;
8710
+ }
8996
8711
  async updateDevice(profile) {
8997
8712
  return this._identityManager.updateDeviceProfile(profile);
8998
8713
  }
@@ -9022,7 +8737,7 @@ var DevicesServiceImpl = class {
9022
8737
  if (isMe) {
9023
8738
  presence = Device2.PresenceState.ONLINE;
9024
8739
  } else if (profile.os?.toUpperCase() === "EDGE") {
9025
- presence = this._edgeConnection?.status === EdgeStatus3.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8740
+ presence = this._edgeConnection?.status.state === EdgeStatus3.ConnectionState.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
9026
8741
  } else {
9027
8742
  presence = peers.some((peer) => peer.identityKey.equals(key)) ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
9028
8743
  }
@@ -9070,12 +8785,6 @@ var DevicesServiceImpl = class {
9070
8785
  return () => subscriptions.clear();
9071
8786
  });
9072
8787
  }
9073
- constructor(_identityManager, _edgeConnection) {
9074
- _define_property31(this, "_identityManager", void 0);
9075
- _define_property31(this, "_edgeConnection", void 0);
9076
- this._identityManager = _identityManager;
9077
- this._edgeConnection = _edgeConnection;
9078
- }
9079
8788
  };
9080
8789
 
9081
8790
  // src/packlets/identity/contacts-service.ts
@@ -9083,20 +8792,15 @@ import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateSchedul
9083
8792
  import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
9084
8793
  import { PublicKey as PublicKey17 } from "@dxos/keys";
9085
8794
  import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
9086
- function _define_property32(obj, key, value) {
9087
- if (key in obj) {
9088
- Object.defineProperty(obj, key, {
9089
- value,
9090
- enumerable: true,
9091
- configurable: true,
9092
- writable: true
9093
- });
9094
- } else {
9095
- obj[key] = value;
9096
- }
9097
- return obj;
9098
- }
9099
8795
  var ContactsServiceImpl = class {
8796
+ _identityManager;
8797
+ _spaceManager;
8798
+ _dataSpaceManagerProvider;
8799
+ constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
8800
+ this._identityManager = _identityManager;
8801
+ this._spaceManager = _spaceManager;
8802
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
8803
+ }
9100
8804
  async getContacts() {
9101
8805
  const identity = this._identityManager.identity;
9102
8806
  if (identity == null) {
@@ -9118,8 +8822,7 @@ var ContactsServiceImpl = class {
9118
8822
  }
9119
8823
  const existing = acc.get(memberInfo.key);
9120
8824
  if (existing != null) {
9121
- var _existing;
9122
- (_existing = existing).profile ?? (_existing.profile = memberInfo.profile);
8825
+ existing.profile ??= memberInfo.profile;
9123
8826
  existing.commonSpaces?.push(spaceKey);
9124
8827
  } else {
9125
8828
  acc.set(memberInfo.key, {
@@ -9168,14 +8871,6 @@ var ContactsServiceImpl = class {
9168
8871
  });
9169
8872
  });
9170
8873
  }
9171
- constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
9172
- _define_property32(this, "_identityManager", void 0);
9173
- _define_property32(this, "_spaceManager", void 0);
9174
- _define_property32(this, "_dataSpaceManagerProvider", void 0);
9175
- this._identityManager = _identityManager;
9176
- this._spaceManager = _spaceManager;
9177
- this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
9178
- }
9179
8874
  };
9180
8875
 
9181
8876
  // src/packlets/logging/logging-service.ts
@@ -9185,20 +8880,10 @@ import { PublicKey as PublicKey18 } from "@dxos/keys";
9185
8880
  import { getContextFromEntry, log as log26 } from "@dxos/log";
9186
8881
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
9187
8882
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
9188
- function _define_property33(obj, key, value) {
9189
- if (key in obj) {
9190
- Object.defineProperty(obj, key, {
9191
- value,
9192
- enumerable: true,
9193
- configurable: true,
9194
- writable: true
9195
- });
9196
- } else {
9197
- obj[key] = value;
9198
- }
9199
- return obj;
9200
- }
9201
8883
  var LoggingServiceImpl = class {
8884
+ _logs = new Event10();
8885
+ _started = Date.now();
8886
+ _sessionId = PublicKey18.random().toHex();
9202
8887
  async open() {
9203
8888
  log26.runtimeConfig.processors.push(this._logProcessor);
9204
8889
  }
@@ -9289,14 +8974,9 @@ var LoggingServiceImpl = class {
9289
8974
  this._logs.on(ctx, handler);
9290
8975
  });
9291
8976
  }
9292
- constructor() {
9293
- _define_property33(this, "_logs", new Event10());
9294
- _define_property33(this, "_started", Date.now());
9295
- _define_property33(this, "_sessionId", PublicKey18.random().toHex());
9296
- _define_property33(this, "_logProcessor", (_config, entry2) => {
9297
- this._logs.emit(entry2);
9298
- });
9299
- }
8977
+ _logProcessor = (_config, entry2) => {
8978
+ this._logs.emit(entry2);
8979
+ };
9300
8980
  };
9301
8981
  var matchFilter = (filter, level, path2, options) => {
9302
8982
  switch (options) {
@@ -9318,20 +8998,15 @@ var LOG_PROCESSING = 0;
9318
8998
 
9319
8999
  // src/packlets/network/network-service.ts
9320
9000
  import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
9321
- function _define_property34(obj, key, value) {
9322
- if (key in obj) {
9323
- Object.defineProperty(obj, key, {
9324
- value,
9325
- enumerable: true,
9326
- configurable: true,
9327
- writable: true
9328
- });
9329
- } else {
9330
- obj[key] = value;
9331
- }
9332
- return obj;
9333
- }
9334
9001
  var NetworkServiceImpl = class {
9002
+ networkManager;
9003
+ signalManager;
9004
+ edgeConnection;
9005
+ constructor(networkManager, signalManager, edgeConnection) {
9006
+ this.networkManager = networkManager;
9007
+ this.signalManager = signalManager;
9008
+ this.edgeConnection = edgeConnection;
9009
+ }
9335
9010
  queryStatus() {
9336
9011
  return new Stream15(({ ctx, next }) => {
9337
9012
  const update = () => {
@@ -9382,34 +9057,27 @@ var NetworkServiceImpl = class {
9382
9057
  });
9383
9058
  });
9384
9059
  }
9385
- constructor(networkManager, signalManager, edgeConnection) {
9386
- _define_property34(this, "networkManager", void 0);
9387
- _define_property34(this, "signalManager", void 0);
9388
- _define_property34(this, "edgeConnection", void 0);
9389
- this.networkManager = networkManager;
9390
- this.signalManager = signalManager;
9391
- this.edgeConnection = edgeConnection;
9392
- }
9393
9060
  };
9394
9061
 
9395
9062
  // src/packlets/system/system-service.ts
9396
9063
  import { Stream as Stream16 } from "@dxos/codec-protobuf/stream";
9397
9064
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
9398
9065
  import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
9399
- function _define_property35(obj, key, value) {
9400
- if (key in obj) {
9401
- Object.defineProperty(obj, key, {
9402
- value,
9403
- enumerable: true,
9404
- configurable: true,
9405
- writable: true
9406
- });
9407
- } else {
9408
- obj[key] = value;
9409
- }
9410
- return obj;
9411
- }
9412
9066
  var SystemServiceImpl = class {
9067
+ _config;
9068
+ _statusUpdate;
9069
+ _getCurrentStatus;
9070
+ _onUpdateStatus;
9071
+ _onReset;
9072
+ _getDiagnostics;
9073
+ constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
9074
+ this._config = config;
9075
+ this._statusUpdate = statusUpdate;
9076
+ this._getCurrentStatus = getCurrentStatus;
9077
+ this._getDiagnostics = getDiagnostics;
9078
+ this._onUpdateStatus = onUpdateStatus;
9079
+ this._onReset = onReset;
9080
+ }
9413
9081
  async getConfig() {
9414
9082
  return (await this._config?.())?.values ?? {};
9415
9083
  }
@@ -9452,36 +9120,9 @@ var SystemServiceImpl = class {
9452
9120
  async reset() {
9453
9121
  await this._onReset();
9454
9122
  }
9455
- constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
9456
- _define_property35(this, "_config", void 0);
9457
- _define_property35(this, "_statusUpdate", void 0);
9458
- _define_property35(this, "_getCurrentStatus", void 0);
9459
- _define_property35(this, "_onUpdateStatus", void 0);
9460
- _define_property35(this, "_onReset", void 0);
9461
- _define_property35(this, "_getDiagnostics", void 0);
9462
- this._config = config;
9463
- this._statusUpdate = statusUpdate;
9464
- this._getCurrentStatus = getCurrentStatus;
9465
- this._getDiagnostics = getDiagnostics;
9466
- this._onUpdateStatus = onUpdateStatus;
9467
- this._onReset = onReset;
9468
- }
9469
9123
  };
9470
9124
 
9471
9125
  // src/packlets/services/service-host.ts
9472
- function _define_property36(obj, key, value) {
9473
- if (key in obj) {
9474
- Object.defineProperty(obj, key, {
9475
- value,
9476
- enumerable: true,
9477
- configurable: true,
9478
- writable: true
9479
- });
9480
- } else {
9481
- obj[key] = value;
9482
- }
9483
- return obj;
9484
- }
9485
9126
  function _ts_decorate11(decorators, target, key, desc) {
9486
9127
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9487
9128
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -9490,6 +9131,94 @@ function _ts_decorate11(decorators, target, key, desc) {
9490
9131
  }
9491
9132
  var __dxlog_file31 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
9492
9133
  var ClientServicesHost = class {
9134
+ _resourceLock;
9135
+ _serviceRegistry;
9136
+ _systemService;
9137
+ _loggingService;
9138
+ _tracingService = TRACE_PROCESSOR3.createTraceSender();
9139
+ _statusUpdate = new Event11();
9140
+ _config;
9141
+ _signalManager;
9142
+ _networkManager;
9143
+ _storage;
9144
+ _level;
9145
+ _callbacks;
9146
+ _devtoolsProxy;
9147
+ _edgeConnection = void 0;
9148
+ _edgeHttpClient = void 0;
9149
+ _serviceContext;
9150
+ _runtimeParams;
9151
+ diagnosticsBroadcastHandler;
9152
+ _opening = false;
9153
+ _open = false;
9154
+ _resetting = false;
9155
+ constructor({
9156
+ config,
9157
+ transportFactory,
9158
+ signalManager,
9159
+ storage,
9160
+ level,
9161
+ // TODO(wittjosiah): Turn this on by default.
9162
+ lockKey,
9163
+ callbacks,
9164
+ runtimeParams
9165
+ } = {}) {
9166
+ this._storage = storage;
9167
+ this._level = level;
9168
+ this._callbacks = callbacks;
9169
+ this._runtimeParams = runtimeParams ?? {};
9170
+ if (this._runtimeParams.disableP2pReplication === void 0) {
9171
+ this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9172
+ }
9173
+ if (this._runtimeParams.enableVectorIndexing === void 0) {
9174
+ this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9175
+ }
9176
+ if (config) {
9177
+ this.initialize({
9178
+ config,
9179
+ transportFactory,
9180
+ signalManager
9181
+ });
9182
+ }
9183
+ if (lockKey) {
9184
+ this._resourceLock = new Lock({
9185
+ lockKey,
9186
+ onAcquire: () => {
9187
+ if (!this._opening) {
9188
+ void this.open(new Context11(void 0, {
9189
+ F: __dxlog_file31,
9190
+ L: 143
9191
+ }));
9192
+ }
9193
+ },
9194
+ onRelease: () => this.close()
9195
+ });
9196
+ }
9197
+ this._systemService = new SystemServiceImpl({
9198
+ config: () => this._config,
9199
+ statusUpdate: this._statusUpdate,
9200
+ getCurrentStatus: () => this.isOpen && !this._resetting ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
9201
+ getDiagnostics: () => {
9202
+ return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
9203
+ },
9204
+ onUpdateStatus: async (status) => {
9205
+ if (!this.isOpen && status === SystemStatus.ACTIVE) {
9206
+ await this._resourceLock?.acquire();
9207
+ } else if (this.isOpen && status === SystemStatus.INACTIVE) {
9208
+ await this._resourceLock?.release();
9209
+ }
9210
+ },
9211
+ onReset: async () => {
9212
+ await this.reset();
9213
+ }
9214
+ });
9215
+ this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
9216
+ this._loggingService = new LoggingServiceImpl();
9217
+ this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
9218
+ SystemService: this._systemService,
9219
+ TracingService: this._tracingService
9220
+ });
9221
+ }
9493
9222
  get isOpen() {
9494
9223
  return this._open;
9495
9224
  }
@@ -9797,94 +9526,6 @@ var ClientServicesHost = class {
9797
9526
  await this._serviceContext.initialized.wait();
9798
9527
  return identity;
9799
9528
  }
9800
- constructor({
9801
- config,
9802
- transportFactory,
9803
- signalManager,
9804
- storage,
9805
- level,
9806
- // TODO(wittjosiah): Turn this on by default.
9807
- lockKey,
9808
- callbacks,
9809
- runtimeParams
9810
- } = {}) {
9811
- _define_property36(this, "_resourceLock", void 0);
9812
- _define_property36(this, "_serviceRegistry", void 0);
9813
- _define_property36(this, "_systemService", void 0);
9814
- _define_property36(this, "_loggingService", void 0);
9815
- _define_property36(this, "_tracingService", TRACE_PROCESSOR3.createTraceSender());
9816
- _define_property36(this, "_statusUpdate", new Event11());
9817
- _define_property36(this, "_config", void 0);
9818
- _define_property36(this, "_signalManager", void 0);
9819
- _define_property36(this, "_networkManager", void 0);
9820
- _define_property36(this, "_storage", void 0);
9821
- _define_property36(this, "_level", void 0);
9822
- _define_property36(this, "_callbacks", void 0);
9823
- _define_property36(this, "_devtoolsProxy", void 0);
9824
- _define_property36(this, "_edgeConnection", void 0);
9825
- _define_property36(this, "_edgeHttpClient", void 0);
9826
- _define_property36(this, "_serviceContext", void 0);
9827
- _define_property36(this, "_runtimeParams", void 0);
9828
- _define_property36(this, "diagnosticsBroadcastHandler", void 0);
9829
- _define_property36(this, "_opening", false);
9830
- _define_property36(this, "_open", false);
9831
- _define_property36(this, "_resetting", false);
9832
- this._storage = storage;
9833
- this._level = level;
9834
- this._callbacks = callbacks;
9835
- this._runtimeParams = runtimeParams ?? {};
9836
- if (this._runtimeParams.disableP2pReplication === void 0) {
9837
- this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9838
- }
9839
- if (this._runtimeParams.enableVectorIndexing === void 0) {
9840
- this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9841
- }
9842
- if (config) {
9843
- this.initialize({
9844
- config,
9845
- transportFactory,
9846
- signalManager
9847
- });
9848
- }
9849
- if (lockKey) {
9850
- this._resourceLock = new Lock({
9851
- lockKey,
9852
- onAcquire: () => {
9853
- if (!this._opening) {
9854
- void this.open(new Context11(void 0, {
9855
- F: __dxlog_file31,
9856
- L: 143
9857
- }));
9858
- }
9859
- },
9860
- onRelease: () => this.close()
9861
- });
9862
- }
9863
- this._systemService = new SystemServiceImpl({
9864
- config: () => this._config,
9865
- statusUpdate: this._statusUpdate,
9866
- getCurrentStatus: () => this.isOpen && !this._resetting ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
9867
- getDiagnostics: () => {
9868
- return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
9869
- },
9870
- onUpdateStatus: async (status) => {
9871
- if (!this.isOpen && status === SystemStatus.ACTIVE) {
9872
- await this._resourceLock?.acquire();
9873
- } else if (this.isOpen && status === SystemStatus.INACTIVE) {
9874
- await this._resourceLock?.release();
9875
- }
9876
- },
9877
- onReset: async () => {
9878
- await this.reset();
9879
- }
9880
- });
9881
- this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
9882
- this._loggingService = new LoggingServiceImpl();
9883
- this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
9884
- SystemService: this._systemService,
9885
- TracingService: this._tracingService
9886
- });
9887
- }
9888
9529
  };
9889
9530
  _ts_decorate11([
9890
9531
  Trace4.info()
@@ -9952,4 +9593,4 @@ export {
9952
9593
  ServiceRegistry,
9953
9594
  ClientServicesHost
9954
9595
  };
9955
- //# sourceMappingURL=chunk-JDTIU3EP.mjs.map
9596
+ //# sourceMappingURL=chunk-BBBSS6UL.mjs.map