@dxos/client-services 0.8.4-main.dedc0f3 → 0.8.4-main.e8ec1fe

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 (33) hide show
  1. package/dist/lib/browser/{chunk-LZ5JMQR7.mjs → chunk-CZSLDMSL.mjs} +796 -1142
  2. package/dist/lib/browser/chunk-CZSLDMSL.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-JXUVAXX5.mjs → chunk-EUNILIU5.mjs} +796 -1142
  9. package/dist/lib/node-esm/chunk-EUNILIU5.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/services/service-host.d.ts.map +1 -1
  17. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
  18. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  19. package/dist/types/src/version.d.ts +1 -1
  20. package/dist/types/tsconfig.tsbuildinfo +1 -1
  21. package/package.json +39 -39
  22. package/src/packlets/agents/edge-agent-service.ts +11 -1
  23. package/src/packlets/devices/devices-service.ts +1 -1
  24. package/src/packlets/identity/identity.test.ts +4 -4
  25. package/src/packlets/logging/logging-service.ts +1 -1
  26. package/src/packlets/services/service-host.ts +6 -0
  27. package/src/packlets/space-export/space-archive-writer.ts +2 -1
  28. package/src/packlets/spaces/data-space-manager.ts +14 -2
  29. package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
  30. package/src/packlets/spaces/edge-feed-replicator.ts +1 -1
  31. package/src/version.ts +1 -1
  32. package/dist/lib/browser/chunk-LZ5JMQR7.mjs.map +0 -7
  33. package/dist/lib/node-esm/chunk-JXUVAXX5.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.dedc0f3";
399
+ var DXOS_VERSION = "0.8.4-main.e8ec1fe";
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
  }
@@ -2221,13 +2173,11 @@ var SpaceArchiveWriter = class extends Resource3 {
2221
2173
  this._archive.addTextFile(SpaceArchiveFileStructure.metadata, JSON.stringify(metadata));
2222
2174
  const binary = this._archive.toUint8Array();
2223
2175
  return {
2224
- filename: `${this._meta.spaceId}.tar`,
2176
+ // TODO(wittjosiah): Factor out file name construction.
2177
+ filename: `${(/* @__PURE__ */ new Date()).toISOString()}-${this._meta.spaceId}.tar`,
2225
2178
  contents: binary
2226
2179
  };
2227
2180
  }
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
2181
  };
2232
2182
 
2233
2183
  // src/packlets/space-export/space-archive-reader.ts
@@ -2271,19 +2221,6 @@ var extractSpaceArchive = async (archive) => {
2271
2221
  };
2272
2222
 
2273
2223
  // 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
2224
  function _ts_add_disposable_resource2(env, value, async) {
2288
2225
  if (value !== null && value !== void 0) {
2289
2226
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
@@ -2351,6 +2288,14 @@ function _ts_dispose_resources2(env) {
2351
2288
  }
2352
2289
  var __dxlog_file8 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2353
2290
  var SpacesServiceImpl = class {
2291
+ _identityManager;
2292
+ _spaceManager;
2293
+ _getDataSpaceManager;
2294
+ constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
2295
+ this._identityManager = _identityManager;
2296
+ this._spaceManager = _spaceManager;
2297
+ this._getDataSpaceManager = _getDataSpaceManager;
2298
+ }
2354
2299
  async createSpace() {
2355
2300
  this._requireIdentity();
2356
2301
  const dataSpaceManager = await this._getDataSpaceManager();
@@ -2728,14 +2673,6 @@ var SpacesServiceImpl = class {
2728
2673
  });
2729
2674
  }
2730
2675
  }
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
2676
  };
2740
2677
  var getChannelId = (channel) => `user-channel/${channel}`;
2741
2678
 
@@ -2743,21 +2680,13 @@ var getChannelId = (channel) => `user-channel/${channel}`;
2743
2680
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2744
2681
  import { SpaceId as SpaceId2 } from "@dxos/keys";
2745
2682
  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
2683
  var __dxlog_file9 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
2760
2684
  var DefaultSpaceStateMachine = class {
2685
+ _params;
2686
+ _spaceId;
2687
+ constructor(_params) {
2688
+ this._params = _params;
2689
+ }
2761
2690
  get spaceId() {
2762
2691
  return this._spaceId;
2763
2692
  }
@@ -2793,27 +2722,9 @@ var DefaultSpaceStateMachine = class {
2793
2722
  }
2794
2723
  }
2795
2724
  }
2796
- constructor(_params) {
2797
- _define_property8(this, "_params", void 0);
2798
- _define_property8(this, "_spaceId", void 0);
2799
- this._params = _params;
2800
- }
2801
2725
  };
2802
2726
 
2803
2727
  // 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
2728
  function _ts_decorate3(decorators, target, key, desc) {
2818
2729
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2819
2730
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2822,6 +2733,58 @@ function _ts_decorate3(decorators, target, key, desc) {
2822
2733
  }
2823
2734
  var __dxlog_file10 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
2824
2735
  var Identity = class {
2736
+ space;
2737
+ _signer;
2738
+ _presence;
2739
+ _deviceStateMachine;
2740
+ _profileStateMachine;
2741
+ _defaultSpaceStateMachine;
2742
+ _edgeFeedReplicator = void 0;
2743
+ authVerifier;
2744
+ did;
2745
+ identityKey;
2746
+ deviceKey;
2747
+ stateUpdate = new Event3();
2748
+ constructor(params) {
2749
+ this.space = params.space;
2750
+ this._signer = params.signer;
2751
+ this._presence = params.presence;
2752
+ this.did = params.did;
2753
+ this.identityKey = params.identityKey;
2754
+ this.deviceKey = params.deviceKey;
2755
+ log8.trace("dxos.halo.device", {
2756
+ deviceKey: params.deviceKey
2757
+ }, {
2758
+ F: __dxlog_file10,
2759
+ L: 83,
2760
+ S: this,
2761
+ C: (f, a) => f(...a)
2762
+ });
2763
+ this._deviceStateMachine = new DeviceStateMachine({
2764
+ identityKey: this.identityKey,
2765
+ deviceKey: this.deviceKey,
2766
+ onUpdate: () => this.stateUpdate.emit()
2767
+ });
2768
+ this._profileStateMachine = new ProfileStateMachine({
2769
+ identityKey: this.identityKey,
2770
+ onUpdate: () => this.stateUpdate.emit()
2771
+ });
2772
+ this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
2773
+ identityKey: this.identityKey,
2774
+ onUpdate: () => this.stateUpdate.emit()
2775
+ });
2776
+ this.authVerifier = new TrustedKeySetAuthVerifier({
2777
+ trustedKeysProvider: () => new ComplexSet(PublicKey5.hash, this.authorizedDeviceKeys.keys()),
2778
+ update: this.stateUpdate,
2779
+ authTimeout: AUTH_TIMEOUT
2780
+ });
2781
+ if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
2782
+ this._edgeFeedReplicator = new EdgeFeedReplicator({
2783
+ messenger: params.edgeConnection,
2784
+ spaceId: this.space.id
2785
+ });
2786
+ }
2787
+ }
2825
2788
  // TODO(burdon): Expose state object?
2826
2789
  get authorizedDeviceKeys() {
2827
2790
  return this._deviceStateMachine.authorizedDeviceKeys;
@@ -2981,61 +2944,9 @@ var Identity = class {
2981
2944
  })));
2982
2945
  return deviceCredential;
2983
2946
  }
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
- }
2947
+ _onFeedAdded = async (feed) => {
2948
+ await this._edgeFeedReplicator.addFeed(feed);
2949
+ };
3039
2950
  };
3040
2951
  _ts_decorate3([
3041
2952
  trace3.span()
@@ -3062,19 +2973,6 @@ import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extensi
3062
2973
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
3063
2974
  import { trace as Trace2 } from "@dxos/tracing";
3064
2975
  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
2976
  function _ts_decorate4(decorators, target, key, desc) {
3079
2977
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3080
2978
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3085,6 +2983,27 @@ var __dxlog_file11 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/i
3085
2983
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3086
2984
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
3087
2985
  var IdentityManager = class {
2986
+ stateUpdate = new Event4();
2987
+ _metadataStore;
2988
+ _keyring;
2989
+ _feedStore;
2990
+ _spaceManager;
2991
+ _devicePresenceAnnounceInterval;
2992
+ _devicePresenceOfflineTimeout;
2993
+ _edgeConnection;
2994
+ _edgeFeatures;
2995
+ _identity;
2996
+ // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
2997
+ constructor(params) {
2998
+ this._metadataStore = params.metadataStore;
2999
+ this._keyring = params.keyring;
3000
+ this._feedStore = params.feedStore;
3001
+ this._spaceManager = params.spaceManager;
3002
+ this._edgeConnection = params.edgeConnection;
3003
+ this._edgeFeatures = params.edgeFeatures;
3004
+ this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
3005
+ this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
3006
+ }
3088
3007
  get identity() {
3089
3008
  return this._identity;
3090
3009
  }
@@ -3519,27 +3438,6 @@ var IdentityManager = class {
3519
3438
  }
3520
3439
  });
3521
3440
  }
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
3441
  };
3544
3442
  _ts_decorate4([
3545
3443
  Trace2.span({
@@ -3559,22 +3457,18 @@ import { invariant as invariant8 } from "@dxos/invariant";
3559
3457
  import { log as log10 } from "@dxos/log";
3560
3458
  import { SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
3561
3459
  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
3460
  var __dxlog_file12 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
3576
3461
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
3577
3462
  var IdentityServiceImpl = class extends Resource4 {
3463
+ _identityManager;
3464
+ _recoveryManager;
3465
+ _keyring;
3466
+ _dataSpaceManagerProvider;
3467
+ _createIdentity;
3468
+ _onProfileUpdate;
3469
+ constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
3470
+ super(), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
3471
+ }
3578
3472
  async _open() {
3579
3473
  const identity = this._identityManager.identity;
3580
3474
  if (identity && !identity.defaultSpaceId) {
@@ -3749,29 +3643,21 @@ var IdentityServiceImpl = class extends Resource4 {
3749
3643
  await this._createDefaultSpace(dataSpaceManager);
3750
3644
  }
3751
3645
  }
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
3646
  };
3756
3647
 
3757
3648
  // src/packlets/spaces/automerge-space-state.ts
3758
3649
  import { Event as Event5 } from "@dxos/async";
3759
3650
  import { Resource as Resource5 } from "@dxos/context";
3760
3651
  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
3652
  var AutomergeSpaceState = class extends Resource5 {
3653
+ _onNewRoot;
3654
+ rootUrl = void 0;
3655
+ lastEpoch = void 0;
3656
+ onNewEpoch = new Event5();
3657
+ _isProcessingRootDocs = false;
3658
+ constructor(_onNewRoot) {
3659
+ super(), this._onNewRoot = _onNewRoot;
3660
+ }
3775
3661
  async _open(ctx) {
3776
3662
  }
3777
3663
  async _close(ctx) {
@@ -3802,9 +3688,6 @@ var AutomergeSpaceState = class extends Resource5 {
3802
3688
  async ensureEpochInitialized() {
3803
3689
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3804
3690
  }
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
3691
  };
3809
3692
 
3810
3693
  // src/packlets/spaces/epoch-migrations.ts
@@ -3871,19 +3754,6 @@ import { EdgeCallFailedError } from "@dxos/protocols";
3871
3754
  import { schema as schema2 } from "@dxos/protocols/proto";
3872
3755
  import { RpcExtension } from "@dxos/teleport";
3873
3756
  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
3757
  function _ts_decorate5(decorators, target, key, desc) {
3888
3758
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3889
3759
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3899,6 +3769,24 @@ var MAX_EDGE_RETRIES = 2;
3899
3769
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3900
3770
  var credentialCodec = schema2.getCodecForType("dxos.halo.credentials.Credential");
3901
3771
  var NotarizationPlugin = class extends Resource6 {
3772
+ _extensionOpened = new Event6();
3773
+ _writer;
3774
+ _extensions = /* @__PURE__ */ new Set();
3775
+ _processedCredentials = new ComplexSet2(PublicKey7.hash);
3776
+ _processCredentialsTriggers = new ComplexMap4(PublicKey7.hash);
3777
+ _activeEdgePollingIntervalHandle = void 0;
3778
+ _activeEdgePollingInterval;
3779
+ _activeEdgePollingEnabled = false;
3780
+ _spaceId;
3781
+ _edgeClient;
3782
+ constructor(params) {
3783
+ super();
3784
+ this._spaceId = params.spaceId;
3785
+ this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
3786
+ if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
3787
+ this._edgeClient = params.edgeClient;
3788
+ }
3789
+ }
3902
3790
  setActiveEdgePollingEnabled(enabled) {
3903
3791
  const client = this._edgeClient;
3904
3792
  invariant10(client, void 0, {
@@ -4258,14 +4146,6 @@ var NotarizationPlugin = class extends Resource6 {
4258
4146
  errors.throw(new TimeoutError(timeout, "Notarization timed out"));
4259
4147
  }, timeout);
4260
4148
  }
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
4149
  };
4270
4150
  _ts_decorate5([
4271
4151
  logInfo2
@@ -4290,6 +4170,17 @@ var handleEdgeError = (error) => {
4290
4170
  }
4291
4171
  };
4292
4172
  var NotarizationTeleportExtension = class extends RpcExtension {
4173
+ _params;
4174
+ constructor(_params) {
4175
+ super({
4176
+ requested: {
4177
+ NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4178
+ },
4179
+ exposed: {
4180
+ NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4181
+ }
4182
+ }), this._params = _params;
4183
+ }
4293
4184
  async getHandlers() {
4294
4185
  return {
4295
4186
  NotarizationService: {
@@ -4307,32 +4198,9 @@ var NotarizationTeleportExtension = class extends RpcExtension {
4307
4198
  await this._params.onClose();
4308
4199
  await super.onClose(err);
4309
4200
  }
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
4201
  };
4321
4202
 
4322
4203
  // 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
4204
  function _ts_decorate6(decorators, target, key, desc) {
4337
4205
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4338
4206
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -4406,6 +4274,75 @@ function _ts_dispose_resources3(env) {
4406
4274
  }
4407
4275
  var __dxlog_file15 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4408
4276
  var DataSpace = class {
4277
+ _ctx = new Context6(void 0, {
4278
+ F: __dxlog_file15,
4279
+ L: 101
4280
+ });
4281
+ _inner;
4282
+ _gossip;
4283
+ _presence;
4284
+ _keyring;
4285
+ _feedStore;
4286
+ _metadataStore;
4287
+ _signingContext;
4288
+ _notarizationPlugin;
4289
+ _callbacks;
4290
+ _cache = void 0;
4291
+ _echoHost;
4292
+ _edgeFeedReplicator = void 0;
4293
+ // TODO(dmaretskyi): Move into Space?
4294
+ _automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
4295
+ _epochProcessingMutex = new Mutex2();
4296
+ _state = SpaceState4.SPACE_CLOSED;
4297
+ _databaseRoot = null;
4298
+ /**
4299
+ * Error for _state === SpaceState.SPACE_ERROR.
4300
+ */
4301
+ error = void 0;
4302
+ authVerifier;
4303
+ stateUpdate = new Event7();
4304
+ postOpen = new CallbackCollection();
4305
+ preClose = new CallbackCollection();
4306
+ metrics = {};
4307
+ constructor(params) {
4308
+ this._inner = params.inner;
4309
+ this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
4310
+ this._gossip = params.gossip;
4311
+ this._presence = params.presence;
4312
+ this._keyring = params.keyring;
4313
+ this._feedStore = params.feedStore;
4314
+ this._metadataStore = params.metadataStore;
4315
+ this._signingContext = params.signingContext;
4316
+ this._callbacks = params.callbacks ?? {};
4317
+ this._echoHost = params.echoHost;
4318
+ this._notarizationPlugin = new NotarizationPlugin({
4319
+ spaceId: this._inner.id,
4320
+ edgeClient: params.edgeHttpClient,
4321
+ edgeFeatures: params.edgeFeatures,
4322
+ activeEdgePollingInterval: params.activeEdgeNotarizationPollingInterval
4323
+ });
4324
+ this.authVerifier = new TrustedKeySetAuthVerifier({
4325
+ trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
4326
+ update: this._inner.stateUpdate,
4327
+ authTimeout: AUTH_TIMEOUT2
4328
+ });
4329
+ this._cache = params.cache;
4330
+ if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
4331
+ this._edgeFeedReplicator = new EdgeFeedReplicator({
4332
+ messenger: params.edgeConnection,
4333
+ spaceId: this.id
4334
+ });
4335
+ }
4336
+ this._state = params.initialState;
4337
+ log12("new state", {
4338
+ state: SpaceState4[this._state]
4339
+ }, {
4340
+ F: __dxlog_file15,
4341
+ L: 177,
4342
+ S: this,
4343
+ C: (f, a) => f(...a)
4344
+ });
4345
+ }
4409
4346
  get id() {
4410
4347
  return this._inner.id;
4411
4348
  }
@@ -4892,74 +4829,9 @@ var DataSpace = class {
4892
4829
  getEdgeReplicationSetting() {
4893
4830
  return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
4894
4831
  }
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
- }
4832
+ _onFeedAdded = async (feed) => {
4833
+ await this._edgeFeedReplicator.addFeed(feed);
4834
+ };
4963
4835
  };
4964
4836
  _ts_decorate6([
4965
4837
  trace5.info()
@@ -5015,21 +4887,16 @@ import { getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credent
5015
4887
  import { invariant as invariant12 } from "@dxos/invariant";
5016
4888
  import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
5017
4889
  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
4890
  var __dxlog_file16 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
5032
4891
  var DeviceInvitationProtocol = class {
4892
+ _keyring;
4893
+ _getIdentity;
4894
+ _acceptIdentity;
4895
+ constructor(_keyring, _getIdentity, _acceptIdentity) {
4896
+ this._keyring = _keyring;
4897
+ this._getIdentity = _getIdentity;
4898
+ this._acceptIdentity = _acceptIdentity;
4899
+ }
5033
4900
  toJSON() {
5034
4901
  return {
5035
4902
  kind: "device"
@@ -5141,14 +5008,6 @@ var DeviceInvitationProtocol = class {
5141
5008
  identityKey
5142
5009
  };
5143
5010
  }
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
5011
  };
5153
5012
 
5154
5013
  // src/packlets/invitations/invitations-handler.ts
@@ -5203,24 +5062,22 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
5203
5062
  };
5204
5063
 
5205
5064
  // 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
5065
  var __dxlog_file17 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
5220
5066
  var MAX_RETRIES_PER_INVITATION = 5;
5221
5067
  var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
5222
5068
  var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
5223
5069
  var EdgeInvitationHandler = class {
5070
+ _client;
5071
+ _callbacks;
5072
+ _flowLock;
5073
+ _retryInterval;
5074
+ _retryJitter;
5075
+ constructor(config, _client, _callbacks) {
5076
+ this._client = _client;
5077
+ this._callbacks = _callbacks;
5078
+ this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
5079
+ this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
5080
+ }
5224
5081
  handle(ctx, guardedState, protocol, deviceProfile) {
5225
5082
  if (!this._client) {
5226
5083
  log13("edge disabled", void 0, {
@@ -5363,17 +5220,6 @@ var EdgeInvitationHandler = class {
5363
5220
  _calculateNextRetryMs() {
5364
5221
  return this._retryInterval + Math.random() * this._retryJitter;
5365
5222
  }
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
5223
  };
5378
5224
 
5379
5225
  // src/packlets/invitations/invitation-guest-extenstion.ts
@@ -5385,22 +5231,31 @@ import { InvalidInvitationExtensionRoleError } from "@dxos/protocols";
5385
5231
  import { schema as schema4 } from "@dxos/protocols/proto";
5386
5232
  import { InvitationOptions } from "@dxos/protocols/proto/dxos/halo/invitations";
5387
5233
  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
5234
  var __dxlog_file18 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
5402
5235
  var OPTIONS_TIMEOUT = 1e4;
5403
5236
  var InvitationGuestExtension = class extends RpcExtension2 {
5237
+ _invitationFlowMutex;
5238
+ _callbacks;
5239
+ _ctx = new Context7(void 0, {
5240
+ F: __dxlog_file18,
5241
+ L: 38
5242
+ });
5243
+ _remoteOptions;
5244
+ _remoteOptionsTrigger = new Trigger4();
5245
+ /**
5246
+ * Held to allow only one invitation flow at a time to be active.
5247
+ */
5248
+ _invitationFlowLock = null;
5249
+ constructor(_invitationFlowMutex, _callbacks) {
5250
+ super({
5251
+ requested: {
5252
+ InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5253
+ },
5254
+ exposed: {
5255
+ InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5256
+ }
5257
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks;
5258
+ }
5404
5259
  hasFlowLock() {
5405
5260
  return this._invitationFlowLock != null;
5406
5261
  }
@@ -5502,22 +5357,6 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5502
5357
  });
5503
5358
  }
5504
5359
  }
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
5360
  };
5522
5361
 
5523
5362
  // src/packlets/invitations/invitation-host-extension.ts
@@ -5532,26 +5371,49 @@ import { schema as schema5 } from "@dxos/protocols/proto";
5532
5371
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
5533
5372
  import { AuthenticationResponse, InvitationOptions as InvitationOptions2 } from "@dxos/protocols/proto/dxos/halo/invitations";
5534
5373
  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
5374
  var __dxlog_file19 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
5549
5375
  var OPTIONS_TIMEOUT2 = 1e4;
5550
5376
  var MAX_OTP_ATTEMPTS = 3;
5551
5377
  var InvitationHostExtension = class extends RpcExtension3 {
5552
- hasFlowLock() {
5553
- return this._invitationFlowLock != null;
5554
- }
5378
+ _invitationFlowMutex;
5379
+ _callbacks;
5380
+ /**
5381
+ * @internal
5382
+ */
5383
+ _ctx = new Context8(void 0, {
5384
+ F: __dxlog_file19,
5385
+ L: 57
5386
+ });
5387
+ _remoteOptions;
5388
+ _remoteOptionsTrigger = new Trigger5();
5389
+ _challenge = void 0;
5390
+ guestProfile = void 0;
5391
+ authenticationPassed = false;
5392
+ /**
5393
+ * Retry counter for SHARED_SECRET authentication method.
5394
+ */
5395
+ authenticationRetry = 0;
5396
+ /**
5397
+ * Resolved when admission is completed.
5398
+ */
5399
+ completedTrigger = new Trigger5();
5400
+ /**
5401
+ * Held to allow only one invitation flow at a time to be active.
5402
+ */
5403
+ _invitationFlowLock = null;
5404
+ constructor(_invitationFlowMutex, _callbacks) {
5405
+ super({
5406
+ requested: {
5407
+ InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5408
+ },
5409
+ exposed: {
5410
+ InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5411
+ }
5412
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks;
5413
+ }
5414
+ hasFlowLock() {
5415
+ return this._invitationFlowLock != null;
5416
+ }
5555
5417
  async getHandlers() {
5556
5418
  return {
5557
5419
  // TODO(dmaretskyi): For now this is just forwarding the data to callbacks since we don't have session-specific logic.
@@ -5849,31 +5711,6 @@ var InvitationHostExtension = class extends RpcExtension3 {
5849
5711
  });
5850
5712
  }
5851
5713
  }
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
5714
  };
5878
5715
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation5.AuthMethod.NONE;
5879
5716
 
@@ -5979,21 +5816,22 @@ import { PublicKey as PublicKey10 } from "@dxos/keys";
5979
5816
  import { log as log17 } from "@dxos/log";
5980
5817
  import { InvitationOptions as InvitationOptions3 } from "@dxos/protocols/proto/dxos/halo/invitations";
5981
5818
  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
5819
  var __dxlog_file21 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
5996
5820
  var InvitationTopology = class {
5821
+ _role;
5822
+ _controller;
5823
+ /**
5824
+ * Peers we tried to establish a connection with.
5825
+ * In invitation flow peers are assigned random ids when they join the swarm, so we'll retry
5826
+ * a peer if they reload an invitation.
5827
+ *
5828
+ * Consider keeping a separate set for peers we know are hosts and have some retry timeout
5829
+ * for guests we failed an invitation flow with (potentially due to a network error).
5830
+ */
5831
+ _seenPeers = new ComplexSet4(PublicKey10.hash);
5832
+ constructor(_role) {
5833
+ this._role = _role;
5834
+ }
5997
5835
  init(controller) {
5998
5836
  invariant16(!this._controller, "Already initialized.", {
5999
5837
  F: __dxlog_file21,
@@ -6058,33 +5896,24 @@ var InvitationTopology = class {
6058
5896
  toString() {
6059
5897
  return `InvitationTopology(${this._role === InvitationOptions3.Role.GUEST ? "guest" : "host"})`;
6060
5898
  }
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
5899
  };
6069
5900
 
6070
5901
  // 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
5902
  var __dxlog_file22 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
6085
5903
  var metrics = _trace.metrics;
6086
5904
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
6087
5905
  var InvitationsHandler = class {
5906
+ _networkManager;
5907
+ _edgeClient;
5908
+ _connectionParams;
5909
+ /**
5910
+ * @internal
5911
+ */
5912
+ constructor(_networkManager, _edgeClient, _connectionParams) {
5913
+ this._networkManager = _networkManager;
5914
+ this._edgeClient = _edgeClient;
5915
+ this._connectionParams = _connectionParams;
5916
+ }
6088
5917
  handleInvitationFlow(ctx, stream, protocol, invitation) {
6089
5918
  log18.verbose("dxos.sdk.invitations-handler.handleInvitationFlow", {
6090
5919
  state: invitation.state,
@@ -6655,17 +6484,6 @@ var InvitationsHandler = class {
6655
6484
  throw new Error(`Authentication failed with code: ${response.status}`);
6656
6485
  }
6657
6486
  }
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
6487
  };
6670
6488
  var checkInvitation = (protocol, invitation) => {
6671
6489
  const expiresOn = getExpirationTime(invitation);
@@ -6686,20 +6504,11 @@ var createAdmissionKeypair = () => {
6686
6504
  import { Stream as Stream9 } from "@dxos/codec-protobuf/stream";
6687
6505
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
6688
6506
  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
6507
  var InvitationsServiceImpl = class {
6508
+ _invitationsManager;
6509
+ constructor(_invitationsManager) {
6510
+ this._invitationsManager = _invitationsManager;
6511
+ }
6703
6512
  // TODO(burdon): Guest/host label.
6704
6513
  getLoggingContext() {
6705
6514
  return {};
@@ -6791,10 +6600,6 @@ var InvitationsServiceImpl = class {
6791
6600
  });
6792
6601
  });
6793
6602
  }
6794
- constructor(_invitationsManager) {
6795
- _define_property21(this, "_invitationsManager", void 0);
6796
- this._invitationsManager = _invitationsManager;
6797
- }
6798
6603
  };
6799
6604
 
6800
6605
  // src/packlets/invitations/space-invitation-protocol.ts
@@ -6805,21 +6610,18 @@ import { log as log19 } from "@dxos/log";
6805
6610
  import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError as InvalidInvitationError2, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
6806
6611
  import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
6807
6612
  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
6613
  var __dxlog_file23 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
6822
6614
  var SpaceInvitationProtocol = class {
6615
+ _spaceManager;
6616
+ _signingContext;
6617
+ _keyring;
6618
+ _spaceKey;
6619
+ constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
6620
+ this._spaceManager = _spaceManager;
6621
+ this._signingContext = _signingContext;
6622
+ this._keyring = _keyring;
6623
+ this._spaceKey = _spaceKey;
6624
+ }
6823
6625
  toJSON() {
6824
6626
  return {
6825
6627
  kind: "space",
@@ -7084,16 +6886,6 @@ var SpaceInvitationProtocol = class {
7084
6886
  spaceKey: assertion.spaceKey
7085
6887
  };
7086
6888
  }
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
6889
  };
7098
6890
 
7099
6891
  // src/packlets/invitations/invitations-manager.ts
@@ -7107,21 +6899,25 @@ import { PublicKey as PublicKey12 } from "@dxos/keys";
7107
6899
  import { log as log20 } from "@dxos/log";
7108
6900
  import { Invitation as Invitation9 } from "@dxos/protocols/proto/dxos/client/services";
7109
6901
  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
6902
  var __dxlog_file24 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
7124
6903
  var InvitationsManager = class {
6904
+ _invitationsHandler;
6905
+ _getHandler;
6906
+ _metadataStore;
6907
+ _createInvitations = /* @__PURE__ */ new Map();
6908
+ _acceptInvitations = /* @__PURE__ */ new Map();
6909
+ invitationCreated = new Event8();
6910
+ invitationAccepted = new Event8();
6911
+ removedCreated = new Event8();
6912
+ removedAccepted = new Event8();
6913
+ saved = new Event8();
6914
+ _persistentInvitationsLoadedEvent = new Event8();
6915
+ _persistentInvitationsLoaded = false;
6916
+ constructor(_invitationsHandler, _getHandler, _metadataStore) {
6917
+ this._invitationsHandler = _invitationsHandler;
6918
+ this._getHandler = _getHandler;
6919
+ this._metadataStore = _metadataStore;
6920
+ }
7125
6921
  async createInvitation(options) {
7126
6922
  if (options.invitationId) {
7127
6923
  const existingInvitation = this._createInvitations.get(options.invitationId);
@@ -7465,51 +7261,12 @@ var InvitationsManager = class {
7465
7261
  }, () => {
7466
7262
  }, callback);
7467
7263
  }
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
7264
  };
7495
7265
 
7496
7266
  // src/packlets/locks/node.ts
7497
7267
  import { invariant as invariant20 } from "@dxos/invariant";
7498
7268
  import { LockFile } from "@dxos/lock-file";
7499
7269
  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
7270
  function _ts_decorate7(decorators, target, key, desc) {
7514
7271
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7515
7272
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7518,6 +7275,15 @@ function _ts_decorate7(decorators, target, key, desc) {
7518
7275
  }
7519
7276
  var __dxlog_file25 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
7520
7277
  var Lock = class {
7278
+ _lockPath;
7279
+ _onAcquire;
7280
+ _onRelease;
7281
+ _fileHandle;
7282
+ constructor({ lockKey: lockPath, onAcquire, onRelease }) {
7283
+ this._lockPath = lockPath;
7284
+ this._onAcquire = onAcquire;
7285
+ this._onRelease = onRelease;
7286
+ }
7521
7287
  get lockKey() {
7522
7288
  return this._lockPath;
7523
7289
  }
@@ -7550,15 +7316,6 @@ var Lock = class {
7550
7316
  });
7551
7317
  await LockFile.release(this._fileHandle);
7552
7318
  }
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
7319
  };
7563
7320
  _ts_decorate7([
7564
7321
  logInfo3
@@ -7570,19 +7327,6 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
7570
7327
  import { raise as raise2 } from "@dxos/debug";
7571
7328
  import { RpcPeer, parseMethodName } from "@dxos/rpc";
7572
7329
  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
7330
  function _ts_decorate8(decorators, target, key, desc) {
7587
7331
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7588
7332
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7590,33 +7334,16 @@ function _ts_decorate8(decorators, target, key, desc) {
7590
7334
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7591
7335
  }
7592
7336
  var ClientRpcServer = class {
7337
+ _serviceRegistry;
7338
+ _rpcPeer;
7339
+ _handlerCache = /* @__PURE__ */ new Map();
7340
+ _handleCall;
7341
+ _handleStream;
7342
+ _callMetrics = new MapCounter();
7593
7343
  get _services() {
7594
7344
  return Object.keys(this._serviceRegistry.services);
7595
7345
  }
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
7346
  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
7347
  const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
7621
7348
  this._handleCall = handleCall;
7622
7349
  this._handleStream = handleStream;
@@ -7648,6 +7375,23 @@ var ClientRpcServer = class {
7648
7375
  }
7649
7376
  });
7650
7377
  }
7378
+ async open() {
7379
+ await this._rpcPeer.open();
7380
+ }
7381
+ async close() {
7382
+ await this._rpcPeer.close();
7383
+ }
7384
+ _getServiceHandler(serviceName) {
7385
+ if (!this._handlerCache.has(serviceName)) {
7386
+ const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise2(new Error(`Service not available: ${serviceName}`));
7387
+ const service = this._serviceRegistry.services[key];
7388
+ if (!service) {
7389
+ throw new Error(`Service not available: ${serviceName}`);
7390
+ }
7391
+ this._handlerCache.set(serviceName, descriptor.createServer(service));
7392
+ }
7393
+ return this._handlerCache.get(serviceName);
7394
+ }
7651
7395
  };
7652
7396
  _ts_decorate8([
7653
7397
  trace9.metricsCounter()
@@ -7668,19 +7412,6 @@ import { log as log22 } from "@dxos/log";
7668
7412
  import { EdgeAgentStatus, EdgeCallFailedError as EdgeCallFailedError3 } from "@dxos/protocols";
7669
7413
  import { SpaceState as SpaceState5 } from "@dxos/protocols/proto/dxos/client/services";
7670
7414
  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
7415
  function _ts_decorate9(decorators, target, key, desc) {
7685
7416
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7686
7417
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7692,6 +7423,18 @@ var AGENT_STATUS_QUERY_RETRY_INTERVAL = 5e3;
7692
7423
  var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
7693
7424
  var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
7694
7425
  var EdgeAgentManager = class extends Resource7 {
7426
+ _edgeFeatures;
7427
+ _edgeHttpClient;
7428
+ _dataSpaceManager;
7429
+ _identity;
7430
+ agentStatusChanged = new Event9();
7431
+ _agentDeviceKey;
7432
+ _agentStatus;
7433
+ _lastKnownDeviceCount = 0;
7434
+ _fetchAgentStatusTask;
7435
+ constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7436
+ super(), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity;
7437
+ }
7695
7438
  get agentStatus() {
7696
7439
  return this._agentStatus;
7697
7440
  }
@@ -7900,9 +7643,6 @@ var EdgeAgentManager = class extends Resource7 {
7900
7643
  C: (f, a) => f(...a)
7901
7644
  });
7902
7645
  }
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
7646
  };
7907
7647
  _ts_decorate9([
7908
7648
  synchronized3
@@ -7912,26 +7652,27 @@ _ts_decorate9([
7912
7652
  import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
7913
7653
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7914
7654
  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
7655
  var EdgeAgentServiceImpl = class {
7656
+ _agentManagerProvider;
7657
+ _edgeConnection;
7658
+ constructor(_agentManagerProvider, _edgeConnection) {
7659
+ this._agentManagerProvider = _agentManagerProvider;
7660
+ this._edgeConnection = _edgeConnection;
7661
+ }
7929
7662
  // TODO(mykola): Reconcile with NetworkService.queryStatus.
7930
7663
  queryEdgeStatus() {
7931
7664
  return new Stream11(({ ctx, next }) => {
7932
7665
  const update = () => {
7933
7666
  next({
7934
- status: this._edgeConnection?.status ?? EdgeStatus2.NOT_CONNECTED
7667
+ status: this._edgeConnection?.status ?? {
7668
+ state: EdgeStatus2.ConnectionState.NOT_CONNECTED,
7669
+ rtt: 0,
7670
+ uptime: 0,
7671
+ rateBytesUp: 0,
7672
+ rateBytesDown: 0,
7673
+ messagesSent: 0,
7674
+ messagesReceived: 0
7675
+ }
7935
7676
  });
7936
7677
  };
7937
7678
  this._edgeConnection?.statusChanged.on(ctx, update);
@@ -7958,12 +7699,6 @@ var EdgeAgentServiceImpl = class {
7958
7699
  });
7959
7700
  });
7960
7701
  }
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
7702
  };
7968
7703
  var mapStatus = (agentStatus) => {
7969
7704
  switch (agentStatus) {
@@ -8005,21 +7740,18 @@ import { log as log23 } from "@dxos/log";
8005
7740
  import { EdgeAuthChallengeError as EdgeAuthChallengeError2 } from "@dxos/protocols";
8006
7741
  import { schema as schema6 } from "@dxos/protocols/proto";
8007
7742
  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
7743
  var __dxlog_file27 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts";
8022
7744
  var EdgeIdentityRecoveryManager = class {
7745
+ _keyring;
7746
+ _edgeClient;
7747
+ _identityProvider;
7748
+ _acceptRecoveredIdentity;
7749
+ constructor(_keyring, _edgeClient, _identityProvider, _acceptRecoveredIdentity) {
7750
+ this._keyring = _keyring;
7751
+ this._edgeClient = _edgeClient;
7752
+ this._identityProvider = _identityProvider;
7753
+ this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
7754
+ }
8023
7755
  async createRecoveryCredential({ data }) {
8024
7756
  const identity = this._identityProvider();
8025
7757
  invariant22(identity, void 0, {
@@ -8212,16 +7944,6 @@ var EdgeIdentityRecoveryManager = class {
8212
7944
  dataFeedKey: await this._keyring.createKey()
8213
7945
  });
8214
7946
  }
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
7947
  };
8226
7948
  var decodeCredential = (credentialBase64) => {
8227
7949
  const credentialBytes = Buffer.from(credentialBase64, "base64");
@@ -8230,19 +7952,6 @@ var decodeCredential = (credentialBase64) => {
8230
7952
  };
8231
7953
 
8232
7954
  // 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
7955
  function _ts_decorate10(decorators, target, key, desc) {
8247
7956
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8248
7957
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -8316,27 +8025,110 @@ function _ts_dispose_resources4(env) {
8316
8025
  }
8317
8026
  var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
8318
8027
  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)
8028
+ storage;
8029
+ level;
8030
+ networkManager;
8031
+ signalManager;
8032
+ _edgeConnection;
8033
+ _edgeHttpClient;
8034
+ _runtimeParams;
8035
+ _edgeFeatures;
8036
+ _edgeIdentityUpdateMutex = new Mutex4();
8037
+ initialized = new Trigger7();
8038
+ metadataStore;
8039
+ blobStore;
8040
+ feedStore;
8041
+ keyring;
8042
+ spaceManager;
8043
+ identityManager;
8044
+ recoveryManager;
8045
+ invitations;
8046
+ invitationsManager;
8047
+ echoHost;
8048
+ _meshReplicator = void 0;
8049
+ _echoEdgeReplicator = void 0;
8050
+ // Initialized after identity is initialized.
8051
+ dataSpaceManager;
8052
+ edgeAgentManager;
8053
+ _handlerFactories = /* @__PURE__ */ new Map();
8054
+ _deviceSpaceSync;
8055
+ _instanceId = PublicKey15.random().toHex();
8056
+ constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
8057
+ 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;
8058
+ this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
8059
+ this.blobStore = new BlobStore(storage.createDirectory("blobs"));
8060
+ this.keyring = new Keyring(storage.createDirectory("keyring"));
8061
+ this.feedStore = new FeedStore({
8062
+ factory: new FeedFactory({
8063
+ root: storage.createDirectory("feeds"),
8064
+ signer: this.keyring,
8065
+ hypercore: {
8066
+ valueEncoding,
8067
+ stats: true
8068
+ }
8069
+ })
8326
8070
  });
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)
8071
+ this.spaceManager = new SpaceManager({
8072
+ feedStore: this.feedStore,
8073
+ networkManager: this.networkManager,
8074
+ blobStore: this.blobStore,
8075
+ metadataStore: this.metadataStore,
8076
+ disableP2pReplication: this._runtimeParams?.disableP2pReplication
8334
8077
  });
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();
8078
+ this.identityManager = new IdentityManager({
8079
+ metadataStore: this.metadataStore,
8080
+ keyring: this.keyring,
8081
+ feedStore: this.feedStore,
8082
+ spaceManager: this.spaceManager,
8083
+ devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
8084
+ devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
8085
+ edgeConnection: this._edgeConnection,
8086
+ edgeFeatures: this._edgeFeatures
8087
+ });
8088
+ this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
8089
+ this.echoHost = new EchoHost({
8090
+ kv: this.level,
8091
+ peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8092
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8093
+ indexing: {
8094
+ vector: this._runtimeParams?.enableVectorIndexing
8095
+ }
8096
+ });
8097
+ this._meshReplicator = new MeshEchoReplicator();
8098
+ this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
8099
+ this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
8100
+ this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
8101
+ if (!this._runtimeParams?.disableP2pReplication) {
8102
+ this._meshReplicator = new MeshEchoReplicator();
8103
+ }
8104
+ if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
8105
+ this._echoEdgeReplicator = new EchoEdgeReplicator({
8106
+ edgeConnection: this._edgeConnection,
8107
+ edgeHttpClient: this._edgeHttpClient
8108
+ });
8109
+ }
8110
+ }
8111
+ async _open(ctx) {
8112
+ await this._checkStorageVersion();
8113
+ log24("opening...", void 0, {
8114
+ F: __dxlog_file28,
8115
+ L: 204,
8116
+ S: this,
8117
+ C: (f, a) => f(...a)
8118
+ });
8119
+ log24.trace("dxos.sdk.service-context.open", trace10.begin({
8120
+ id: this._instanceId
8121
+ }), {
8122
+ F: __dxlog_file28,
8123
+ L: 205,
8124
+ S: this,
8125
+ C: (f, a) => f(...a)
8126
+ });
8127
+ await this.identityManager.open(ctx);
8128
+ await this._setNetworkIdentity();
8129
+ await this._edgeConnection?.open();
8130
+ await this.signalManager.open();
8131
+ await this.networkManager.open();
8340
8132
  await this.echoHost.open(ctx);
8341
8133
  if (this._meshReplicator) {
8342
8134
  await this.echoHost.addReplicator(this._meshReplicator);
@@ -8618,62 +8410,6 @@ var ServiceContext = class extends Resource8 {
8618
8410
  _ts_dispose_resources4(env);
8619
8411
  }
8620
8412
  }
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
8413
  };
8678
8414
  _ts_decorate10([
8679
8415
  Trace3.span()
@@ -8920,20 +8656,14 @@ var importProfileData = async ({ storage, level }, archive) => {
8920
8656
  };
8921
8657
 
8922
8658
  // 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
8659
  var ServiceRegistry = class {
8660
+ _serviceBundle;
8661
+ _handlers;
8662
+ // prettier-ignore
8663
+ constructor(_serviceBundle, _handlers = {}) {
8664
+ this._serviceBundle = _serviceBundle;
8665
+ this._handlers = _handlers;
8666
+ }
8937
8667
  get descriptors() {
8938
8668
  return this._serviceBundle;
8939
8669
  }
@@ -8949,13 +8679,6 @@ var ServiceRegistry = class {
8949
8679
  removeService(name) {
8950
8680
  delete this._handlers[name];
8951
8681
  }
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
8682
  };
8960
8683
 
8961
8684
  // src/packlets/services/service-host.ts
@@ -8978,21 +8701,14 @@ import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
8978
8701
  import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8979
8702
  import { invariant as invariant25 } from "@dxos/invariant";
8980
8703
  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
8704
  var __dxlog_file30 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8995
8705
  var DevicesServiceImpl = class {
8706
+ _identityManager;
8707
+ _edgeConnection;
8708
+ constructor(_identityManager, _edgeConnection) {
8709
+ this._identityManager = _identityManager;
8710
+ this._edgeConnection = _edgeConnection;
8711
+ }
8996
8712
  async updateDevice(profile) {
8997
8713
  return this._identityManager.updateDeviceProfile(profile);
8998
8714
  }
@@ -9022,7 +8738,7 @@ var DevicesServiceImpl = class {
9022
8738
  if (isMe) {
9023
8739
  presence = Device2.PresenceState.ONLINE;
9024
8740
  } else if (profile.os?.toUpperCase() === "EDGE") {
9025
- presence = this._edgeConnection?.status === EdgeStatus3.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8741
+ presence = this._edgeConnection?.status.state === EdgeStatus3.ConnectionState.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
9026
8742
  } else {
9027
8743
  presence = peers.some((peer) => peer.identityKey.equals(key)) ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
9028
8744
  }
@@ -9070,12 +8786,6 @@ var DevicesServiceImpl = class {
9070
8786
  return () => subscriptions.clear();
9071
8787
  });
9072
8788
  }
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
8789
  };
9080
8790
 
9081
8791
  // src/packlets/identity/contacts-service.ts
@@ -9083,20 +8793,15 @@ import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateSchedul
9083
8793
  import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
9084
8794
  import { PublicKey as PublicKey17 } from "@dxos/keys";
9085
8795
  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
8796
  var ContactsServiceImpl = class {
8797
+ _identityManager;
8798
+ _spaceManager;
8799
+ _dataSpaceManagerProvider;
8800
+ constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
8801
+ this._identityManager = _identityManager;
8802
+ this._spaceManager = _spaceManager;
8803
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
8804
+ }
9100
8805
  async getContacts() {
9101
8806
  const identity = this._identityManager.identity;
9102
8807
  if (identity == null) {
@@ -9118,8 +8823,7 @@ var ContactsServiceImpl = class {
9118
8823
  }
9119
8824
  const existing = acc.get(memberInfo.key);
9120
8825
  if (existing != null) {
9121
- var _existing;
9122
- (_existing = existing).profile ?? (_existing.profile = memberInfo.profile);
8826
+ existing.profile ??= memberInfo.profile;
9123
8827
  existing.commonSpaces?.push(spaceKey);
9124
8828
  } else {
9125
8829
  acc.set(memberInfo.key, {
@@ -9168,14 +8872,6 @@ var ContactsServiceImpl = class {
9168
8872
  });
9169
8873
  });
9170
8874
  }
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
8875
  };
9180
8876
 
9181
8877
  // src/packlets/logging/logging-service.ts
@@ -9185,20 +8881,10 @@ import { PublicKey as PublicKey18 } from "@dxos/keys";
9185
8881
  import { getContextFromEntry, log as log26 } from "@dxos/log";
9186
8882
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
9187
8883
  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
8884
  var LoggingServiceImpl = class {
8885
+ _logs = new Event10();
8886
+ _started = Date.now();
8887
+ _sessionId = PublicKey18.random().toHex();
9202
8888
  async open() {
9203
8889
  log26.runtimeConfig.processors.push(this._logProcessor);
9204
8890
  }
@@ -9289,14 +8975,9 @@ var LoggingServiceImpl = class {
9289
8975
  this._logs.on(ctx, handler);
9290
8976
  });
9291
8977
  }
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
- }
8978
+ _logProcessor = (_config, entry2) => {
8979
+ this._logs.emit(entry2);
8980
+ };
9300
8981
  };
9301
8982
  var matchFilter = (filter, level, path2, options) => {
9302
8983
  switch (options) {
@@ -9318,20 +8999,15 @@ var LOG_PROCESSING = 0;
9318
8999
 
9319
9000
  // src/packlets/network/network-service.ts
9320
9001
  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
9002
  var NetworkServiceImpl = class {
9003
+ networkManager;
9004
+ signalManager;
9005
+ edgeConnection;
9006
+ constructor(networkManager, signalManager, edgeConnection) {
9007
+ this.networkManager = networkManager;
9008
+ this.signalManager = signalManager;
9009
+ this.edgeConnection = edgeConnection;
9010
+ }
9335
9011
  queryStatus() {
9336
9012
  return new Stream15(({ ctx, next }) => {
9337
9013
  const update = () => {
@@ -9382,34 +9058,27 @@ var NetworkServiceImpl = class {
9382
9058
  });
9383
9059
  });
9384
9060
  }
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
9061
  };
9394
9062
 
9395
9063
  // src/packlets/system/system-service.ts
9396
9064
  import { Stream as Stream16 } from "@dxos/codec-protobuf/stream";
9397
9065
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
9398
9066
  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
9067
  var SystemServiceImpl = class {
9068
+ _config;
9069
+ _statusUpdate;
9070
+ _getCurrentStatus;
9071
+ _onUpdateStatus;
9072
+ _onReset;
9073
+ _getDiagnostics;
9074
+ constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
9075
+ this._config = config;
9076
+ this._statusUpdate = statusUpdate;
9077
+ this._getCurrentStatus = getCurrentStatus;
9078
+ this._getDiagnostics = getDiagnostics;
9079
+ this._onUpdateStatus = onUpdateStatus;
9080
+ this._onReset = onReset;
9081
+ }
9413
9082
  async getConfig() {
9414
9083
  return (await this._config?.())?.values ?? {};
9415
9084
  }
@@ -9452,36 +9121,9 @@ var SystemServiceImpl = class {
9452
9121
  async reset() {
9453
9122
  await this._onReset();
9454
9123
  }
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
9124
  };
9470
9125
 
9471
9126
  // 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
9127
  function _ts_decorate11(decorators, target, key, desc) {
9486
9128
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9487
9129
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -9490,6 +9132,94 @@ function _ts_decorate11(decorators, target, key, desc) {
9490
9132
  }
9491
9133
  var __dxlog_file31 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
9492
9134
  var ClientServicesHost = class {
9135
+ _resourceLock;
9136
+ _serviceRegistry;
9137
+ _systemService;
9138
+ _loggingService;
9139
+ _tracingService = TRACE_PROCESSOR3.createTraceSender();
9140
+ _statusUpdate = new Event11();
9141
+ _config;
9142
+ _signalManager;
9143
+ _networkManager;
9144
+ _storage;
9145
+ _level;
9146
+ _callbacks;
9147
+ _devtoolsProxy;
9148
+ _edgeConnection = void 0;
9149
+ _edgeHttpClient = void 0;
9150
+ _serviceContext;
9151
+ _runtimeParams;
9152
+ diagnosticsBroadcastHandler;
9153
+ _opening = false;
9154
+ _open = false;
9155
+ _resetting = false;
9156
+ constructor({
9157
+ config,
9158
+ transportFactory,
9159
+ signalManager,
9160
+ storage,
9161
+ level,
9162
+ // TODO(wittjosiah): Turn this on by default.
9163
+ lockKey,
9164
+ callbacks,
9165
+ runtimeParams
9166
+ } = {}) {
9167
+ this._storage = storage;
9168
+ this._level = level;
9169
+ this._callbacks = callbacks;
9170
+ this._runtimeParams = runtimeParams ?? {};
9171
+ if (this._runtimeParams.disableP2pReplication === void 0) {
9172
+ this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9173
+ }
9174
+ if (this._runtimeParams.enableVectorIndexing === void 0) {
9175
+ this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9176
+ }
9177
+ if (config) {
9178
+ this.initialize({
9179
+ config,
9180
+ transportFactory,
9181
+ signalManager
9182
+ });
9183
+ }
9184
+ if (lockKey) {
9185
+ this._resourceLock = new Lock({
9186
+ lockKey,
9187
+ onAcquire: () => {
9188
+ if (!this._opening) {
9189
+ void this.open(new Context11(void 0, {
9190
+ F: __dxlog_file31,
9191
+ L: 143
9192
+ }));
9193
+ }
9194
+ },
9195
+ onRelease: () => this.close()
9196
+ });
9197
+ }
9198
+ this._systemService = new SystemServiceImpl({
9199
+ config: () => this._config,
9200
+ statusUpdate: this._statusUpdate,
9201
+ getCurrentStatus: () => this.isOpen && !this._resetting ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
9202
+ getDiagnostics: () => {
9203
+ return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
9204
+ },
9205
+ onUpdateStatus: async (status) => {
9206
+ if (!this.isOpen && status === SystemStatus.ACTIVE) {
9207
+ await this._resourceLock?.acquire();
9208
+ } else if (this.isOpen && status === SystemStatus.INACTIVE) {
9209
+ await this._resourceLock?.release();
9210
+ }
9211
+ },
9212
+ onReset: async () => {
9213
+ await this.reset();
9214
+ }
9215
+ });
9216
+ this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
9217
+ this._loggingService = new LoggingServiceImpl();
9218
+ this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
9219
+ SystemService: this._systemService,
9220
+ TracingService: this._tracingService
9221
+ });
9222
+ }
9493
9223
  get isOpen() {
9494
9224
  return this._open;
9495
9225
  }
@@ -9763,10 +9493,22 @@ var ClientServicesHost = class {
9763
9493
  this._resetting = true;
9764
9494
  this._statusUpdate.emit();
9765
9495
  await this._serviceContext?.close();
9496
+ try {
9497
+ await this._level.clear();
9498
+ } catch (err) {
9499
+ log27.warn("failed to clear leveldb during reset", {
9500
+ err
9501
+ }, {
9502
+ F: __dxlog_file31,
9503
+ L: 415,
9504
+ S: this,
9505
+ C: (f, a) => f(...a)
9506
+ });
9507
+ }
9766
9508
  await this._storage.reset();
9767
9509
  log27.info("reset", void 0, {
9768
9510
  F: __dxlog_file31,
9769
- L: 412,
9511
+ L: 418,
9770
9512
  S: this,
9771
9513
  C: (f, a) => f(...a)
9772
9514
  });
@@ -9774,7 +9516,7 @@ var ClientServicesHost = class {
9774
9516
  id: traceId
9775
9517
  }), {
9776
9518
  F: __dxlog_file31,
9777
- L: 413,
9519
+ L: 419,
9778
9520
  S: this,
9779
9521
  C: (f, a) => f(...a)
9780
9522
  });
@@ -9785,94 +9527,6 @@ var ClientServicesHost = class {
9785
9527
  await this._serviceContext.initialized.wait();
9786
9528
  return identity;
9787
9529
  }
9788
- constructor({
9789
- config,
9790
- transportFactory,
9791
- signalManager,
9792
- storage,
9793
- level,
9794
- // TODO(wittjosiah): Turn this on by default.
9795
- lockKey,
9796
- callbacks,
9797
- runtimeParams
9798
- } = {}) {
9799
- _define_property36(this, "_resourceLock", void 0);
9800
- _define_property36(this, "_serviceRegistry", void 0);
9801
- _define_property36(this, "_systemService", void 0);
9802
- _define_property36(this, "_loggingService", void 0);
9803
- _define_property36(this, "_tracingService", TRACE_PROCESSOR3.createTraceSender());
9804
- _define_property36(this, "_statusUpdate", new Event11());
9805
- _define_property36(this, "_config", void 0);
9806
- _define_property36(this, "_signalManager", void 0);
9807
- _define_property36(this, "_networkManager", void 0);
9808
- _define_property36(this, "_storage", void 0);
9809
- _define_property36(this, "_level", void 0);
9810
- _define_property36(this, "_callbacks", void 0);
9811
- _define_property36(this, "_devtoolsProxy", void 0);
9812
- _define_property36(this, "_edgeConnection", void 0);
9813
- _define_property36(this, "_edgeHttpClient", void 0);
9814
- _define_property36(this, "_serviceContext", void 0);
9815
- _define_property36(this, "_runtimeParams", void 0);
9816
- _define_property36(this, "diagnosticsBroadcastHandler", void 0);
9817
- _define_property36(this, "_opening", false);
9818
- _define_property36(this, "_open", false);
9819
- _define_property36(this, "_resetting", false);
9820
- this._storage = storage;
9821
- this._level = level;
9822
- this._callbacks = callbacks;
9823
- this._runtimeParams = runtimeParams ?? {};
9824
- if (this._runtimeParams.disableP2pReplication === void 0) {
9825
- this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9826
- }
9827
- if (this._runtimeParams.enableVectorIndexing === void 0) {
9828
- this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9829
- }
9830
- if (config) {
9831
- this.initialize({
9832
- config,
9833
- transportFactory,
9834
- signalManager
9835
- });
9836
- }
9837
- if (lockKey) {
9838
- this._resourceLock = new Lock({
9839
- lockKey,
9840
- onAcquire: () => {
9841
- if (!this._opening) {
9842
- void this.open(new Context11(void 0, {
9843
- F: __dxlog_file31,
9844
- L: 143
9845
- }));
9846
- }
9847
- },
9848
- onRelease: () => this.close()
9849
- });
9850
- }
9851
- this._systemService = new SystemServiceImpl({
9852
- config: () => this._config,
9853
- statusUpdate: this._statusUpdate,
9854
- getCurrentStatus: () => this.isOpen && !this._resetting ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
9855
- getDiagnostics: () => {
9856
- return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
9857
- },
9858
- onUpdateStatus: async (status) => {
9859
- if (!this.isOpen && status === SystemStatus.ACTIVE) {
9860
- await this._resourceLock?.acquire();
9861
- } else if (this.isOpen && status === SystemStatus.INACTIVE) {
9862
- await this._resourceLock?.release();
9863
- }
9864
- },
9865
- onReset: async () => {
9866
- await this.reset();
9867
- }
9868
- });
9869
- this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
9870
- this._loggingService = new LoggingServiceImpl();
9871
- this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
9872
- SystemService: this._systemService,
9873
- TracingService: this._tracingService
9874
- });
9875
- }
9876
9530
  };
9877
9531
  _ts_decorate11([
9878
9532
  Trace4.info()
@@ -9940,4 +9594,4 @@ export {
9940
9594
  ServiceRegistry,
9941
9595
  ClientServicesHost
9942
9596
  };
9943
- //# sourceMappingURL=chunk-JXUVAXX5.mjs.map
9597
+ //# sourceMappingURL=chunk-EUNILIU5.mjs.map