@dxos/client-services 0.8.4-main.5ea62a8 → 0.8.4-main.66e292d

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 (53) hide show
  1. package/dist/lib/browser/{chunk-JBVOLD57.mjs → chunk-PWKWJATU.mjs} +899 -1209
  2. package/dist/lib/browser/chunk-PWKWJATU.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-AADRC6MD.mjs → chunk-7NQQ5F2Q.mjs} +900 -1210
  9. package/dist/lib/node-esm/chunk-7NQQ5F2Q.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/invitations/device-invitation-protocol.d.ts +2 -2
  17. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
  19. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  20. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +2 -3
  21. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
  22. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -2
  23. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  24. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  25. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
  26. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  27. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  28. package/dist/types/src/version.d.ts +1 -1
  29. package/dist/types/tsconfig.tsbuildinfo +1 -1
  30. package/package.json +39 -39
  31. package/src/packlets/agents/edge-agent-service.ts +11 -1
  32. package/src/packlets/devices/devices-service.ts +1 -1
  33. package/src/packlets/identity/identity.test.ts +4 -4
  34. package/src/packlets/invitations/device-invitation-protocol.ts +3 -3
  35. package/src/packlets/invitations/invitation-guest-extenstion.ts +6 -4
  36. package/src/packlets/invitations/invitation-host-extension.ts +6 -4
  37. package/src/packlets/invitations/invitation-protocol.ts +2 -3
  38. package/src/packlets/invitations/invitations-handler.ts +1 -1
  39. package/src/packlets/invitations/space-invitation-protocol.ts +7 -13
  40. package/src/packlets/logging/logging-service.ts +1 -1
  41. package/src/packlets/services/service-host.ts +6 -0
  42. package/src/packlets/space-export/space-archive-reader.ts +2 -2
  43. package/src/packlets/space-export/space-archive-writer.ts +4 -3
  44. package/src/packlets/spaces/data-space-manager.ts +28 -8
  45. package/src/packlets/spaces/data-space.ts +1 -1
  46. package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
  47. package/src/packlets/spaces/edge-feed-replicator.ts +1 -1
  48. package/src/packlets/spaces/notarization-plugin.ts +2 -2
  49. package/src/packlets/spaces/spaces-service.ts +11 -8
  50. package/src/packlets/storage/storage.ts +4 -4
  51. package/src/version.ts +1 -1
  52. package/dist/lib/browser/chunk-JBVOLD57.mjs.map +0 -7
  53. package/dist/lib/node-esm/chunk-AADRC6MD.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.5ea62a8";
399
+ var DXOS_VERSION = "0.8.4-main.66e292d";
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
@@ -1323,15 +1275,16 @@ import { ComplexSet } from "@dxos/util";
1323
1275
  // src/packlets/spaces/data-space-manager.ts
1324
1276
  import { interpretAsDocumentId } from "@automerge/automerge-repo";
1325
1277
  import { Event as Event2, synchronized, trackLeaks } from "@dxos/async";
1326
- import { PropertiesType, TYPE_PROPERTIES } from "@dxos/client-protocol";
1278
+ import { SpaceProperties } 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 { Type } from "@dxos/echo";
1282
+ import { getTypeReference } from "@dxos/echo/internal";
1329
1283
  import { AuthStatus, CredentialServerExtension, DatabaseRoot, FIND_PARAMS, findInlineObjectOfType } from "@dxos/echo-pipeline";
1330
1284
  import { SpaceDocVersion, createIdFromSpaceKey, encodeReference } from "@dxos/echo-protocol";
1331
- import { ObjectId, getTypeReference } from "@dxos/echo-schema";
1332
1285
  import { writeMessages } from "@dxos/feed-store";
1333
1286
  import { assertArgument, assertState, failedInvariant, invariant as invariant3 } from "@dxos/invariant";
1334
- import { PublicKey as PublicKey4 } from "@dxos/keys";
1287
+ import { ObjectId, PublicKey as PublicKey4 } from "@dxos/keys";
1335
1288
  import { log as log4 } from "@dxos/log";
1336
1289
  import { AlreadyJoinedError, trace as Trace } from "@dxos/protocols";
1337
1290
  import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
@@ -1412,19 +1365,6 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1412
1365
  };
1413
1366
 
1414
1367
  // 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
1368
  function _ts_decorate2(decorators, target, key, desc) {
1429
1369
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1430
1370
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1436,6 +1376,61 @@ var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
1436
1376
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
1437
1377
  var DEFAULT_SPACE_KEY = "__DEFAULT__";
1438
1378
  var DataSpaceManager = class extends Resource2 {
1379
+ updated = new Event2();
1380
+ _spaces = new ComplexMap3(PublicKey4.hash);
1381
+ _instanceId = PublicKey4.random().toHex();
1382
+ _spaceManager;
1383
+ _metadataStore;
1384
+ _keyring;
1385
+ _signingContext;
1386
+ _feedStore;
1387
+ _echoHost;
1388
+ _invitationsManager;
1389
+ _edgeConnection = void 0;
1390
+ _edgeHttpClient = void 0;
1391
+ _edgeFeatures = void 0;
1392
+ _meshReplicator = void 0;
1393
+ _echoEdgeReplicator = void 0;
1394
+ _runtimeParams = void 0;
1395
+ constructor(params) {
1396
+ super();
1397
+ this._spaceManager = params.spaceManager;
1398
+ this._metadataStore = params.metadataStore;
1399
+ this._keyring = params.keyring;
1400
+ this._signingContext = params.signingContext;
1401
+ this._feedStore = params.feedStore;
1402
+ this._echoHost = params.echoHost;
1403
+ this._meshReplicator = params.meshReplicator;
1404
+ this._invitationsManager = params.invitationsManager;
1405
+ this._edgeConnection = params.edgeConnection;
1406
+ this._edgeFeatures = params.edgeFeatures;
1407
+ this._echoEdgeReplicator = params.echoEdgeReplicator;
1408
+ this._edgeHttpClient = params.edgeHttpClient;
1409
+ this._runtimeParams = params.runtimeParams;
1410
+ trace.diagnostic({
1411
+ id: "spaces",
1412
+ name: "Spaces",
1413
+ fetch: async () => {
1414
+ return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
1415
+ const rootUrl = space.automergeSpaceState.rootUrl;
1416
+ const rootHandle = rootUrl ? await this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS) : void 0;
1417
+ await rootHandle?.whenReady();
1418
+ const rootDoc = rootHandle?.doc();
1419
+ const properties = rootDoc && findInlineObjectOfType(rootDoc, Type.getTypename(SpaceProperties));
1420
+ return {
1421
+ key: space.key.toHex(),
1422
+ state: SpaceState[space.state],
1423
+ name: properties?.[1].data.name ?? null,
1424
+ inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
1425
+ linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
1426
+ credentials: space.inner.spaceState.credentials.length,
1427
+ members: space.inner.spaceState.members.size,
1428
+ rootUrl
1429
+ };
1430
+ }));
1431
+ }
1432
+ });
1433
+ }
1439
1434
  // TODO(burdon): Remove.
1440
1435
  get spaces() {
1441
1436
  return this._spaces;
@@ -1448,7 +1443,7 @@ var DataSpaceManager = class extends Resource2 {
1448
1443
  async _open() {
1449
1444
  log4("open", void 0, {
1450
1445
  F: __dxlog_file6,
1451
- L: 216,
1446
+ L: 217,
1452
1447
  S: this,
1453
1448
  C: (f, a) => f(...a)
1454
1449
  });
@@ -1456,7 +1451,7 @@ var DataSpaceManager = class extends Resource2 {
1456
1451
  id: this._instanceId
1457
1452
  }), {
1458
1453
  F: __dxlog_file6,
1459
- L: 217,
1454
+ L: 218,
1460
1455
  S: this,
1461
1456
  C: (f, a) => f(...a)
1462
1457
  });
@@ -1464,7 +1459,7 @@ var DataSpaceManager = class extends Resource2 {
1464
1459
  spaces: this._metadataStore.spaces.length
1465
1460
  }, {
1466
1461
  F: __dxlog_file6,
1467
- L: 218,
1462
+ L: 219,
1468
1463
  S: this,
1469
1464
  C: (f, a) => f(...a)
1470
1465
  });
@@ -1474,7 +1469,7 @@ var DataSpaceManager = class extends Resource2 {
1474
1469
  spaceMetadata
1475
1470
  }, {
1476
1471
  F: __dxlog_file6,
1477
- L: 222,
1472
+ L: 223,
1478
1473
  S: this,
1479
1474
  C: (f, a) => f(...a)
1480
1475
  });
@@ -1485,7 +1480,7 @@ var DataSpaceManager = class extends Resource2 {
1485
1480
  err
1486
1481
  }, {
1487
1482
  F: __dxlog_file6,
1488
- L: 225,
1483
+ L: 226,
1489
1484
  S: this,
1490
1485
  C: (f, a) => f(...a)
1491
1486
  });
@@ -1496,7 +1491,7 @@ var DataSpaceManager = class extends Resource2 {
1496
1491
  id: this._instanceId
1497
1492
  }), {
1498
1493
  F: __dxlog_file6,
1499
- L: 231,
1494
+ L: 232,
1500
1495
  S: this,
1501
1496
  C: (f, a) => f(...a)
1502
1497
  });
@@ -1504,7 +1499,7 @@ var DataSpaceManager = class extends Resource2 {
1504
1499
  async _close() {
1505
1500
  log4("close", void 0, {
1506
1501
  F: __dxlog_file6,
1507
- L: 236,
1502
+ L: 237,
1508
1503
  S: this,
1509
1504
  C: (f, a) => f(...a)
1510
1505
  });
@@ -1517,7 +1512,7 @@ var DataSpaceManager = class extends Resource2 {
1517
1512
  * Creates a new space writing the genesis credentials to the control feed.
1518
1513
  */
1519
1514
  async createSpace(options = {}) {
1520
- assertArgument(!!options.rootUrl === !!options.documents, "root url must be required when providing documents");
1515
+ assertArgument(!!options.rootUrl === !!options.documents, "options", "root url must be required when providing documents");
1521
1516
  assertState(this._lifecycleState === LifecycleState.OPEN, "Not open.");
1522
1517
  const spaceKey = await this._keyring.createKey();
1523
1518
  const controlFeedKey = await this._keyring.createKey();
@@ -1535,7 +1530,7 @@ var DataSpaceManager = class extends Resource2 {
1535
1530
  spaceKey
1536
1531
  }, {
1537
1532
  F: __dxlog_file6,
1538
- L: 265,
1533
+ L: 270,
1539
1534
  S: this,
1540
1535
  C: (f, a) => f(...a)
1541
1536
  });
@@ -1543,7 +1538,7 @@ var DataSpaceManager = class extends Resource2 {
1543
1538
  if (options.documents) {
1544
1539
  invariant3(Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId)), "Invalid document IDs", {
1545
1540
  F: __dxlog_file6,
1546
- L: 270,
1541
+ L: 275,
1547
1542
  S: this,
1548
1543
  A: [
1549
1544
  "Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId))",
@@ -1555,13 +1550,18 @@ var DataSpaceManager = class extends Resource2 {
1555
1550
  documentId
1556
1551
  }, {
1557
1552
  F: __dxlog_file6,
1558
- L: 277,
1553
+ L: 282,
1559
1554
  S: this,
1560
1555
  C: (f, a) => f(...a)
1561
1556
  });
1562
1557
  const newDoc = await this._echoHost.createDoc(data, {
1563
1558
  preserveHistory: true
1564
1559
  });
1560
+ if (newDoc.doc().access !== void 0 && newDoc.doc().access.spaceKey !== spaceKey.toHex()) {
1561
+ newDoc.change((doc) => {
1562
+ doc.access.spaceKey = spaceKey.toHex();
1563
+ });
1564
+ }
1565
1565
  documentIdMapping[documentId] = newDoc.documentId;
1566
1566
  }));
1567
1567
  }
@@ -1569,7 +1569,7 @@ var DataSpaceManager = class extends Resource2 {
1569
1569
  spaceKey
1570
1570
  }, {
1571
1571
  F: __dxlog_file6,
1572
- L: 284,
1572
+ L: 300,
1573
1573
  S: this,
1574
1574
  C: (f, a) => f(...a)
1575
1575
  });
@@ -1578,18 +1578,19 @@ var DataSpaceManager = class extends Resource2 {
1578
1578
  const newRootDocId = documentIdMapping[interpretAsDocumentId(options.rootUrl)] ?? failedInvariant();
1579
1579
  const rootDocHandle = await this._echoHost.loadDoc(Context4.default(void 0, {
1580
1580
  F: __dxlog_file6,
1581
- L: 289
1581
+ L: 305
1582
1582
  }), newRootDocId);
1583
1583
  DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
1584
1584
  root = await this._echoHost.openSpaceRoot(spaceId, `automerge:${newRootDocId}`);
1585
1585
  } else {
1586
1586
  root = await this._echoHost.createSpaceRoot(spaceKey);
1587
1587
  }
1588
+ await this._echoHost.flush();
1588
1589
  log4("constructing space...", {
1589
1590
  spaceKey
1590
1591
  }, {
1591
1592
  F: __dxlog_file6,
1592
- L: 297,
1593
+ L: 314,
1593
1594
  S: this,
1594
1595
  C: (f, a) => f(...a)
1595
1596
  });
@@ -1599,7 +1600,7 @@ var DataSpaceManager = class extends Resource2 {
1599
1600
  spaceKey
1600
1601
  }, {
1601
1602
  F: __dxlog_file6,
1602
- L: 302,
1603
+ L: 319,
1603
1604
  S: this,
1604
1605
  C: (f, a) => f(...a)
1605
1606
  });
@@ -1608,7 +1609,7 @@ var DataSpaceManager = class extends Resource2 {
1608
1609
  const memberCredential = credentials[1];
1609
1610
  invariant3(getCredentialAssertion(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
1610
1611
  F: __dxlog_file6,
1611
- L: 308,
1612
+ L: 325,
1612
1613
  S: this,
1613
1614
  A: [
1614
1615
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -1622,7 +1623,7 @@ var DataSpaceManager = class extends Resource2 {
1622
1623
  spaceKey
1623
1624
  }, {
1624
1625
  F: __dxlog_file6,
1625
- L: 313,
1626
+ L: 330,
1626
1627
  S: this,
1627
1628
  C: (f, a) => f(...a)
1628
1629
  });
@@ -1640,13 +1641,13 @@ var DataSpaceManager = class extends Resource2 {
1640
1641
  spaceId: space.id
1641
1642
  }, {
1642
1643
  F: __dxlog_file6,
1643
- L: 326,
1644
+ L: 343,
1644
1645
  S: this,
1645
1646
  C: (f, a) => f(...a)
1646
1647
  });
1647
1648
  await space.databaseRoot.handle.whenReady();
1648
1649
  }
1649
- const [_, properties] = findInlineObjectOfType(space.databaseRoot.doc(), TYPE_PROPERTIES) ?? [];
1650
+ const [_, properties] = findInlineObjectOfType(space.databaseRoot.doc(), Type.getTypename(SpaceProperties)) ?? [];
1650
1651
  return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
1651
1652
  }
1652
1653
  case SpaceDocVersion.LEGACY: {
@@ -1658,7 +1659,7 @@ var DataSpaceManager = class extends Resource2 {
1658
1659
  spaceId: space.id
1659
1660
  }, {
1660
1661
  F: __dxlog_file6,
1661
- L: 337,
1662
+ L: 357,
1662
1663
  S: this,
1663
1664
  C: (f, a) => f(...a)
1664
1665
  });
@@ -1670,7 +1671,7 @@ var DataSpaceManager = class extends Resource2 {
1670
1671
  const document = await this._getSpaceRootDocument(space);
1671
1672
  const properties = {
1672
1673
  system: {
1673
- type: encodeReference(getTypeReference(PropertiesType))
1674
+ type: encodeReference(getTypeReference(SpaceProperties))
1674
1675
  },
1675
1676
  data: {
1676
1677
  [DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
@@ -1693,7 +1694,7 @@ var DataSpaceManager = class extends Resource2 {
1693
1694
  const automergeIndex = space.automergeSpaceState.rootUrl;
1694
1695
  invariant3(automergeIndex, void 0, {
1695
1696
  F: __dxlog_file6,
1696
- L: 370,
1697
+ L: 390,
1697
1698
  S: this,
1698
1699
  A: [
1699
1700
  "automergeIndex",
@@ -1710,13 +1711,13 @@ var DataSpaceManager = class extends Resource2 {
1710
1711
  opts
1711
1712
  }, {
1712
1713
  F: __dxlog_file6,
1713
- L: 379,
1714
+ L: 399,
1714
1715
  S: this,
1715
1716
  C: (f, a) => f(...a)
1716
1717
  });
1717
1718
  invariant3(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
1718
1719
  F: __dxlog_file6,
1719
- L: 380,
1720
+ L: 400,
1720
1721
  S: this,
1721
1722
  A: [
1722
1723
  "this._lifecycleState === LifecycleState.OPEN",
@@ -1725,7 +1726,7 @@ var DataSpaceManager = class extends Resource2 {
1725
1726
  });
1726
1727
  invariant3(!this._spaces.has(opts.spaceKey), "Space already exists.", {
1727
1728
  F: __dxlog_file6,
1728
- L: 381,
1729
+ L: 401,
1729
1730
  S: this,
1730
1731
  A: [
1731
1732
  "!this._spaces.has(opts.spaceKey)",
@@ -1749,7 +1750,7 @@ var DataSpaceManager = class extends Resource2 {
1749
1750
  const space = this._spaceManager.spaces.get(options.spaceKey);
1750
1751
  invariant3(space, void 0, {
1751
1752
  F: __dxlog_file6,
1752
- L: 401,
1753
+ L: 421,
1753
1754
  S: this,
1754
1755
  A: [
1755
1756
  "space",
@@ -1762,7 +1763,7 @@ var DataSpaceManager = class extends Resource2 {
1762
1763
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
1763
1764
  invariant3(credentials[0].credential, void 0, {
1764
1765
  F: __dxlog_file6,
1765
- L: 420,
1766
+ L: 440,
1766
1767
  S: this,
1767
1768
  A: [
1768
1769
  "credentials[0].credential",
@@ -1772,7 +1773,7 @@ var DataSpaceManager = class extends Resource2 {
1772
1773
  const spaceMemberCredential = credentials[0].credential.credential;
1773
1774
  invariant3(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
1774
1775
  F: __dxlog_file6,
1775
- L: 422,
1776
+ L: 442,
1776
1777
  S: this,
1777
1778
  A: [
1778
1779
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -1810,7 +1811,7 @@ var DataSpaceManager = class extends Resource2 {
1810
1811
  const space = this._spaces.get(spaceKey);
1811
1812
  invariant3(space, "Space not found.", {
1812
1813
  F: __dxlog_file6,
1813
- L: 459,
1814
+ L: 479,
1814
1815
  S: this,
1815
1816
  A: [
1816
1817
  "space",
@@ -1835,7 +1836,7 @@ var DataSpaceManager = class extends Resource2 {
1835
1836
  metadata
1836
1837
  }, {
1837
1838
  F: __dxlog_file6,
1838
- L: 478,
1839
+ L: 498,
1839
1840
  S: this,
1840
1841
  C: (f, a) => f(...a)
1841
1842
  });
@@ -1879,7 +1880,7 @@ var DataSpaceManager = class extends Resource2 {
1879
1880
  err
1880
1881
  }, {
1881
1882
  F: __dxlog_file6,
1882
- L: 520,
1883
+ L: 540,
1883
1884
  S: this,
1884
1885
  C: (f, a) => f(...a)
1885
1886
  });
@@ -1889,7 +1890,7 @@ var DataSpaceManager = class extends Resource2 {
1889
1890
  onAuthFailure: () => {
1890
1891
  log4.warn("auth failure", void 0, {
1891
1892
  F: __dxlog_file6,
1892
- L: 525,
1893
+ L: 545,
1893
1894
  S: this,
1894
1895
  C: (f, a) => f(...a)
1895
1896
  });
@@ -1922,7 +1923,7 @@ var DataSpaceManager = class extends Resource2 {
1922
1923
  space: space.key
1923
1924
  }, {
1924
1925
  F: __dxlog_file6,
1925
- L: 552,
1926
+ L: 572,
1926
1927
  S: this,
1927
1928
  C: (f, a) => f(...a)
1928
1929
  });
@@ -1933,7 +1934,7 @@ var DataSpaceManager = class extends Resource2 {
1933
1934
  open: this._lifecycleState === LifecycleState.OPEN
1934
1935
  }, {
1935
1936
  F: __dxlog_file6,
1936
- L: 555,
1937
+ L: 575,
1937
1938
  S: this,
1938
1939
  C: (f, a) => f(...a)
1939
1940
  });
@@ -1952,7 +1953,7 @@ var DataSpaceManager = class extends Resource2 {
1952
1953
  space: space.key
1953
1954
  }, {
1954
1955
  F: __dxlog_file6,
1955
- L: 563,
1956
+ L: 583,
1956
1957
  S: this,
1957
1958
  C: (f, a) => f(...a)
1958
1959
  });
@@ -1973,7 +1974,7 @@ var DataSpaceManager = class extends Resource2 {
1973
1974
  spaceId: dataSpace.id
1974
1975
  }, {
1975
1976
  F: __dxlog_file6,
1976
- L: 577,
1977
+ L: 597,
1977
1978
  S: this,
1978
1979
  C: (f, a) => f(...a)
1979
1980
  });
@@ -2003,7 +2004,7 @@ var DataSpaceManager = class extends Resource2 {
2003
2004
  space: space.key
2004
2005
  }, {
2005
2006
  F: __dxlog_file6,
2006
- L: 604,
2007
+ L: 624,
2007
2008
  S: this,
2008
2009
  C: (f, a) => f(...a)
2009
2010
  });
@@ -2036,7 +2037,7 @@ var DataSpaceManager = class extends Resource2 {
2036
2037
  closedSessions
2037
2038
  }, {
2038
2039
  F: __dxlog_file6,
2039
- L: 630,
2040
+ L: 650,
2040
2041
  S: this,
2041
2042
  C: (f, a) => f(...a)
2042
2043
  });
@@ -2051,7 +2052,7 @@ var DataSpaceManager = class extends Resource2 {
2051
2052
  peerId: peerState.peerId
2052
2053
  }, {
2053
2054
  F: __dxlog_file6,
2054
- L: 644,
2055
+ L: 664,
2055
2056
  S: this,
2056
2057
  C: (f, a) => f(...a)
2057
2058
  });
@@ -2094,45 +2095,6 @@ var DataSpaceManager = class extends Resource2 {
2094
2095
  });
2095
2096
  await Promise.all(tasks);
2096
2097
  }
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
2098
  };
2137
2099
  _ts_decorate2([
2138
2100
  synchronized
@@ -2167,21 +2129,12 @@ import { trace as trace2 } from "@dxos/tracing";
2167
2129
  import { Resource as Resource3 } from "@dxos/context";
2168
2130
  import { assertArgument as assertArgument2, assertState as assertState2 } from "@dxos/invariant";
2169
2131
  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
2132
  var CURRENT_VERSION = SpaceArchiveVersion.V1;
2184
2133
  var SpaceArchiveWriter = class extends Resource3 {
2134
+ _tar;
2135
+ _archive;
2136
+ _meta = void 0;
2137
+ _currentRootUrl = void 0;
2185
2138
  async _open(ctx) {
2186
2139
  this._tar = await import("@obsidize/tar-browserify");
2187
2140
  }
@@ -2195,13 +2148,13 @@ var SpaceArchiveWriter = class extends Resource3 {
2195
2148
  this._archive = new this._tar.Archive();
2196
2149
  }
2197
2150
  async setCurrentRootUrl(url) {
2198
- assertArgument2(url.startsWith("automerge:"), "Invalid root URL");
2151
+ assertArgument2(url.startsWith("automerge:"), "url", "Invalid root URL");
2199
2152
  assertState2(this._tar, "Not open");
2200
2153
  assertState2(this._meta, "Not started");
2201
2154
  this._currentRootUrl = url;
2202
2155
  }
2203
2156
  async writeDocument(documentId, data) {
2204
- assertArgument2(!documentId.startsWith("automerge:"), "Invalid document ID");
2157
+ assertArgument2(!documentId.startsWith("automerge:"), "documentId", "Invalid document ID");
2205
2158
  assertState2(this._archive, "Not open");
2206
2159
  this._archive.addBinaryFile(`${SpaceArchiveFileStructure.documents}/${documentId}.bin`, data);
2207
2160
  }
@@ -2221,13 +2174,11 @@ var SpaceArchiveWriter = class extends Resource3 {
2221
2174
  this._archive.addTextFile(SpaceArchiveFileStructure.metadata, JSON.stringify(metadata));
2222
2175
  const binary = this._archive.toUint8Array();
2223
2176
  return {
2224
- filename: `${this._meta.spaceId}.tar`,
2177
+ // TODO(wittjosiah): Factor out file name construction.
2178
+ filename: `${(/* @__PURE__ */ new Date()).toISOString()}-${this._meta.spaceId}.tar`,
2225
2179
  contents: binary
2226
2180
  };
2227
2181
  }
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
2182
  };
2232
2183
 
2233
2184
  // src/packlets/space-export/space-archive-reader.ts
@@ -2239,7 +2190,7 @@ var extractSpaceArchive = async (archive) => {
2239
2190
  const { Archive } = await import("@obsidize/tar-browserify");
2240
2191
  const { entries } = await Archive.extract(archive.contents);
2241
2192
  const metadataEntry = entries.find((entry2) => entry2.fileName === SpaceArchiveFileStructure2.metadata);
2242
- assertArgument3(metadataEntry, "Metadata entry not found");
2193
+ assertArgument3(metadataEntry, "metadataEntry", "Metadata entry not found");
2243
2194
  const metadata = JSON.parse(metadataEntry.getContentAsText());
2244
2195
  const documents = {};
2245
2196
  for (const entry2 of entries.filter((entry3) => entry3.fileName.startsWith(`${SpaceArchiveFileStructure2.documents}/`))) {
@@ -2255,7 +2206,7 @@ var extractSpaceArchive = async (archive) => {
2255
2206
  });
2256
2207
  documents[documentId] = entry2.content ?? failedInvariant2();
2257
2208
  }
2258
- log5.info("extracted space archive", {
2209
+ log5("extracted space archive", {
2259
2210
  metadata,
2260
2211
  documents
2261
2212
  }, {
@@ -2271,19 +2222,6 @@ var extractSpaceArchive = async (archive) => {
2271
2222
  };
2272
2223
 
2273
2224
  // 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
2225
  function _ts_add_disposable_resource2(env, value, async) {
2288
2226
  if (value !== null && value !== void 0) {
2289
2227
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
@@ -2351,6 +2289,14 @@ function _ts_dispose_resources2(env) {
2351
2289
  }
2352
2290
  var __dxlog_file8 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2353
2291
  var SpacesServiceImpl = class {
2292
+ _identityManager;
2293
+ _spaceManager;
2294
+ _getDataSpaceManager;
2295
+ constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
2296
+ this._identityManager = _identityManager;
2297
+ this._spaceManager = _spaceManager;
2298
+ this._getDataSpaceManager = _getDataSpaceManager;
2299
+ }
2354
2300
  async createSpace() {
2355
2301
  this._requireIdentity();
2356
2302
  const dataSpaceManager = await this._getDataSpaceManager();
@@ -2370,7 +2316,9 @@ var SpacesServiceImpl = class {
2370
2316
  await space.deactivate();
2371
2317
  break;
2372
2318
  default:
2373
- throw new ApiError("Invalid space state");
2319
+ throw new ApiError({
2320
+ message: "Invalid space state"
2321
+ });
2374
2322
  }
2375
2323
  }
2376
2324
  if (edgeReplication !== void 0) {
@@ -2384,15 +2332,18 @@ var SpacesServiceImpl = class {
2384
2332
  throw new SpaceNotFoundError(request.spaceKey);
2385
2333
  }
2386
2334
  if (!space.spaceState.hasMembershipManagementPermission(identity.identityKey)) {
2387
- throw new AuthorizationError("No member management permission.", {
2388
- spaceKey: space.key,
2389
- role: space.spaceState.getMemberRole(identity.identityKey)
2335
+ throw new AuthorizationError({
2336
+ message: "No member management permission.",
2337
+ context: {
2338
+ spaceKey: space.key,
2339
+ role: space.spaceState.getMemberRole(identity.identityKey)
2340
+ }
2390
2341
  });
2391
2342
  }
2392
2343
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2393
2344
  invariant5(credentials[0].credential, void 0, {
2394
2345
  F: __dxlog_file8,
2395
- L: 120,
2346
+ L: 123,
2396
2347
  S: this,
2397
2348
  A: [
2398
2349
  "credentials[0].credential",
@@ -2402,7 +2353,7 @@ var SpacesServiceImpl = class {
2402
2353
  const spaceMemberCredential = credentials[0].credential.credential;
2403
2354
  invariant5(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2404
2355
  F: __dxlog_file8,
2405
- L: 122,
2356
+ L: 125,
2406
2357
  S: this,
2407
2358
  A: [
2408
2359
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2420,7 +2371,7 @@ var SpacesServiceImpl = class {
2420
2371
  ids: spaces.map((space) => space.id)
2421
2372
  }), {
2422
2373
  F: __dxlog_file8,
2423
- L: 135,
2374
+ L: 138,
2424
2375
  S: this,
2425
2376
  C: (f, a) => f(...a)
2426
2377
  });
@@ -2512,7 +2463,7 @@ var SpacesServiceImpl = class {
2512
2463
  } else {
2513
2464
  invariant5(!credential.id, "Id on unsigned credentials is not allowed", {
2514
2465
  F: __dxlog_file8,
2515
- L: 233,
2466
+ L: 236,
2516
2467
  S: this,
2517
2468
  A: [
2518
2469
  "!credential.id",
@@ -2521,7 +2472,7 @@ var SpacesServiceImpl = class {
2521
2472
  });
2522
2473
  invariant5(this._identityManager.identity, "Identity is not available", {
2523
2474
  F: __dxlog_file8,
2524
- L: 234,
2475
+ L: 237,
2525
2476
  S: this,
2526
2477
  A: [
2527
2478
  "this._identityManager.identity",
@@ -2531,7 +2482,7 @@ var SpacesServiceImpl = class {
2531
2482
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
2532
2483
  invariant5(credential.issuer.equals(signer.getIssuer()), void 0, {
2533
2484
  F: __dxlog_file8,
2534
- L: 236,
2485
+ L: 239,
2535
2486
  S: this,
2536
2487
  A: [
2537
2488
  "credential.issuer.equals(signer.getIssuer())",
@@ -2585,7 +2536,7 @@ var SpacesServiceImpl = class {
2585
2536
  };
2586
2537
  try {
2587
2538
  const writer = _ts_add_disposable_resource2(env, await new SpaceArchiveWriter().open(), true);
2588
- assertArgument4(SpaceId.isValid(request.spaceId), "Invalid space ID");
2539
+ assertArgument4(SpaceId.isValid(request.spaceId), "spaceId", "Invalid space ID");
2589
2540
  const dataSpaceManager = await this._getDataSpaceManager();
2590
2541
  const space = dataSpaceManager.getSpaceById(request.spaceId) ?? raise(new Error("Space not found"));
2591
2542
  await writer.begin({
@@ -2614,7 +2565,7 @@ var SpacesServiceImpl = class {
2614
2565
  const extracted = await extractSpaceArchive(request.archive);
2615
2566
  invariant5(extracted.metadata.echo?.currentRootUrl, "Space archive does not contain a root URL", {
2616
2567
  F: __dxlog_file8,
2617
- L: 290,
2568
+ L: 293,
2618
2569
  S: this,
2619
2570
  A: [
2620
2571
  "extracted.metadata.echo?.currentRootUrl",
@@ -2634,7 +2585,7 @@ var SpacesServiceImpl = class {
2634
2585
  const assertion = getCredentialAssertion2(credential);
2635
2586
  invariant5(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2636
2587
  F: __dxlog_file8,
2637
- L: 301,
2588
+ L: 304,
2638
2589
  S: this,
2639
2590
  A: [
2640
2591
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2644,7 +2595,7 @@ var SpacesServiceImpl = class {
2644
2595
  const myIdentity = this._identityManager.identity;
2645
2596
  invariant5(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
2646
2597
  F: __dxlog_file8,
2647
- L: 303,
2598
+ L: 306,
2648
2599
  S: this,
2649
2600
  A: [
2650
2601
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -2713,7 +2664,9 @@ var SpacesServiceImpl = class {
2713
2664
  }
2714
2665
  _requireIdentity() {
2715
2666
  if (!this._identityManager.identity) {
2716
- throw new IdentityNotInitializedError("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
2667
+ throw new IdentityNotInitializedError({
2668
+ message: "This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo"
2669
+ });
2717
2670
  }
2718
2671
  return this._identityManager.identity;
2719
2672
  }
@@ -2728,14 +2681,6 @@ var SpacesServiceImpl = class {
2728
2681
  });
2729
2682
  }
2730
2683
  }
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
2684
  };
2740
2685
  var getChannelId = (channel) => `user-channel/${channel}`;
2741
2686
 
@@ -2743,21 +2688,13 @@ var getChannelId = (channel) => `user-channel/${channel}`;
2743
2688
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2744
2689
  import { SpaceId as SpaceId2 } from "@dxos/keys";
2745
2690
  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
2691
  var __dxlog_file9 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
2760
2692
  var DefaultSpaceStateMachine = class {
2693
+ _params;
2694
+ _spaceId;
2695
+ constructor(_params) {
2696
+ this._params = _params;
2697
+ }
2761
2698
  get spaceId() {
2762
2699
  return this._spaceId;
2763
2700
  }
@@ -2793,27 +2730,9 @@ var DefaultSpaceStateMachine = class {
2793
2730
  }
2794
2731
  }
2795
2732
  }
2796
- constructor(_params) {
2797
- _define_property8(this, "_params", void 0);
2798
- _define_property8(this, "_spaceId", void 0);
2799
- this._params = _params;
2800
- }
2801
2733
  };
2802
2734
 
2803
2735
  // 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
2736
  function _ts_decorate3(decorators, target, key, desc) {
2818
2737
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2819
2738
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2822,6 +2741,58 @@ function _ts_decorate3(decorators, target, key, desc) {
2822
2741
  }
2823
2742
  var __dxlog_file10 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
2824
2743
  var Identity = class {
2744
+ space;
2745
+ _signer;
2746
+ _presence;
2747
+ _deviceStateMachine;
2748
+ _profileStateMachine;
2749
+ _defaultSpaceStateMachine;
2750
+ _edgeFeedReplicator = void 0;
2751
+ authVerifier;
2752
+ did;
2753
+ identityKey;
2754
+ deviceKey;
2755
+ stateUpdate = new Event3();
2756
+ constructor(params) {
2757
+ this.space = params.space;
2758
+ this._signer = params.signer;
2759
+ this._presence = params.presence;
2760
+ this.did = params.did;
2761
+ this.identityKey = params.identityKey;
2762
+ this.deviceKey = params.deviceKey;
2763
+ log8.trace("dxos.halo.device", {
2764
+ deviceKey: params.deviceKey
2765
+ }, {
2766
+ F: __dxlog_file10,
2767
+ L: 83,
2768
+ S: this,
2769
+ C: (f, a) => f(...a)
2770
+ });
2771
+ this._deviceStateMachine = new DeviceStateMachine({
2772
+ identityKey: this.identityKey,
2773
+ deviceKey: this.deviceKey,
2774
+ onUpdate: () => this.stateUpdate.emit()
2775
+ });
2776
+ this._profileStateMachine = new ProfileStateMachine({
2777
+ identityKey: this.identityKey,
2778
+ onUpdate: () => this.stateUpdate.emit()
2779
+ });
2780
+ this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
2781
+ identityKey: this.identityKey,
2782
+ onUpdate: () => this.stateUpdate.emit()
2783
+ });
2784
+ this.authVerifier = new TrustedKeySetAuthVerifier({
2785
+ trustedKeysProvider: () => new ComplexSet(PublicKey5.hash, this.authorizedDeviceKeys.keys()),
2786
+ update: this.stateUpdate,
2787
+ authTimeout: AUTH_TIMEOUT
2788
+ });
2789
+ if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
2790
+ this._edgeFeedReplicator = new EdgeFeedReplicator({
2791
+ messenger: params.edgeConnection,
2792
+ spaceId: this.space.id
2793
+ });
2794
+ }
2795
+ }
2825
2796
  // TODO(burdon): Expose state object?
2826
2797
  get authorizedDeviceKeys() {
2827
2798
  return this._deviceStateMachine.authorizedDeviceKeys;
@@ -2981,61 +2952,9 @@ var Identity = class {
2981
2952
  })));
2982
2953
  return deviceCredential;
2983
2954
  }
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
- }
2955
+ _onFeedAdded = async (feed) => {
2956
+ await this._edgeFeedReplicator.addFeed(feed);
2957
+ };
3039
2958
  };
3040
2959
  _ts_decorate3([
3041
2960
  trace3.span()
@@ -3062,19 +2981,6 @@ import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extensi
3062
2981
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
3063
2982
  import { trace as Trace2 } from "@dxos/tracing";
3064
2983
  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
2984
  function _ts_decorate4(decorators, target, key, desc) {
3079
2985
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3080
2986
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3085,6 +2991,27 @@ var __dxlog_file11 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/i
3085
2991
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3086
2992
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
3087
2993
  var IdentityManager = class {
2994
+ stateUpdate = new Event4();
2995
+ _metadataStore;
2996
+ _keyring;
2997
+ _feedStore;
2998
+ _spaceManager;
2999
+ _devicePresenceAnnounceInterval;
3000
+ _devicePresenceOfflineTimeout;
3001
+ _edgeConnection;
3002
+ _edgeFeatures;
3003
+ _identity;
3004
+ // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
3005
+ constructor(params) {
3006
+ this._metadataStore = params.metadataStore;
3007
+ this._keyring = params.keyring;
3008
+ this._feedStore = params.feedStore;
3009
+ this._spaceManager = params.spaceManager;
3010
+ this._edgeConnection = params.edgeConnection;
3011
+ this._edgeFeatures = params.edgeFeatures;
3012
+ this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
3013
+ this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
3014
+ }
3088
3015
  get identity() {
3089
3016
  return this._identity;
3090
3017
  }
@@ -3519,27 +3446,6 @@ var IdentityManager = class {
3519
3446
  }
3520
3447
  });
3521
3448
  }
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
3449
  };
3544
3450
  _ts_decorate4([
3545
3451
  Trace2.span({
@@ -3559,22 +3465,18 @@ import { invariant as invariant8 } from "@dxos/invariant";
3559
3465
  import { log as log10 } from "@dxos/log";
3560
3466
  import { SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
3561
3467
  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
3468
  var __dxlog_file12 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
3576
3469
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
3577
3470
  var IdentityServiceImpl = class extends Resource4 {
3471
+ _identityManager;
3472
+ _recoveryManager;
3473
+ _keyring;
3474
+ _dataSpaceManagerProvider;
3475
+ _createIdentity;
3476
+ _onProfileUpdate;
3477
+ constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
3478
+ super(), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
3479
+ }
3578
3480
  async _open() {
3579
3481
  const identity = this._identityManager.identity;
3580
3482
  if (identity && !identity.defaultSpaceId) {
@@ -3749,29 +3651,21 @@ var IdentityServiceImpl = class extends Resource4 {
3749
3651
  await this._createDefaultSpace(dataSpaceManager);
3750
3652
  }
3751
3653
  }
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
3654
  };
3756
3655
 
3757
3656
  // src/packlets/spaces/automerge-space-state.ts
3758
3657
  import { Event as Event5 } from "@dxos/async";
3759
3658
  import { Resource as Resource5 } from "@dxos/context";
3760
3659
  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
3660
  var AutomergeSpaceState = class extends Resource5 {
3661
+ _onNewRoot;
3662
+ rootUrl = void 0;
3663
+ lastEpoch = void 0;
3664
+ onNewEpoch = new Event5();
3665
+ _isProcessingRootDocs = false;
3666
+ constructor(_onNewRoot) {
3667
+ super(), this._onNewRoot = _onNewRoot;
3668
+ }
3775
3669
  async _open(ctx) {
3776
3670
  }
3777
3671
  async _close(ctx) {
@@ -3802,9 +3696,6 @@ var AutomergeSpaceState = class extends Resource5 {
3802
3696
  async ensureEpochInitialized() {
3803
3697
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3804
3698
  }
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
3699
  };
3809
3700
 
3810
3701
  // src/packlets/spaces/epoch-migrations.ts
@@ -3871,19 +3762,6 @@ import { EdgeCallFailedError } from "@dxos/protocols";
3871
3762
  import { schema as schema2 } from "@dxos/protocols/proto";
3872
3763
  import { RpcExtension } from "@dxos/teleport";
3873
3764
  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
3765
  function _ts_decorate5(decorators, target, key, desc) {
3888
3766
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3889
3767
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3899,6 +3777,24 @@ var MAX_EDGE_RETRIES = 2;
3899
3777
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3900
3778
  var credentialCodec = schema2.getCodecForType("dxos.halo.credentials.Credential");
3901
3779
  var NotarizationPlugin = class extends Resource6 {
3780
+ _extensionOpened = new Event6();
3781
+ _writer;
3782
+ _extensions = /* @__PURE__ */ new Set();
3783
+ _processedCredentials = new ComplexSet2(PublicKey7.hash);
3784
+ _processCredentialsTriggers = new ComplexMap4(PublicKey7.hash);
3785
+ _activeEdgePollingIntervalHandle = void 0;
3786
+ _activeEdgePollingInterval;
3787
+ _activeEdgePollingEnabled = false;
3788
+ _spaceId;
3789
+ _edgeClient;
3790
+ constructor(params) {
3791
+ super();
3792
+ this._spaceId = params.spaceId;
3793
+ this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
3794
+ if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
3795
+ this._edgeClient = params.edgeClient;
3796
+ }
3797
+ }
3902
3798
  setActiveEdgePollingEnabled(enabled) {
3903
3799
  const client = this._edgeClient;
3904
3800
  invariant10(client, void 0, {
@@ -4258,20 +4154,12 @@ var NotarizationPlugin = class extends Resource6 {
4258
4154
  errors.throw(new TimeoutError(timeout, "Notarization timed out"));
4259
4155
  }, timeout);
4260
4156
  }
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
4157
  };
4270
4158
  _ts_decorate5([
4271
4159
  logInfo2
4272
4160
  ], NotarizationPlugin.prototype, "_spaceId", void 0);
4273
4161
  var handleEdgeError = (error) => {
4274
- if (!(error instanceof EdgeCallFailedError) || error.errorData) {
4162
+ if (!(error instanceof EdgeCallFailedError) || error.data) {
4275
4163
  log11.catch(error, void 0, {
4276
4164
  F: __dxlog_file14,
4277
4165
  L: 396,
@@ -4280,7 +4168,7 @@ var handleEdgeError = (error) => {
4280
4168
  });
4281
4169
  } else {
4282
4170
  log11.info("Edge notarization failure", {
4283
- reason: error.reason
4171
+ message: error.message
4284
4172
  }, {
4285
4173
  F: __dxlog_file14,
4286
4174
  L: 398,
@@ -4290,6 +4178,17 @@ var handleEdgeError = (error) => {
4290
4178
  }
4291
4179
  };
4292
4180
  var NotarizationTeleportExtension = class extends RpcExtension {
4181
+ _params;
4182
+ constructor(_params) {
4183
+ super({
4184
+ requested: {
4185
+ NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4186
+ },
4187
+ exposed: {
4188
+ NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
4189
+ }
4190
+ }), this._params = _params;
4191
+ }
4293
4192
  async getHandlers() {
4294
4193
  return {
4295
4194
  NotarizationService: {
@@ -4307,32 +4206,9 @@ var NotarizationTeleportExtension = class extends RpcExtension {
4307
4206
  await this._params.onClose();
4308
4207
  await super.onClose(err);
4309
4208
  }
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
4209
  };
4321
4210
 
4322
4211
  // 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
4212
  function _ts_decorate6(decorators, target, key, desc) {
4337
4213
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4338
4214
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -4406,6 +4282,75 @@ function _ts_dispose_resources3(env) {
4406
4282
  }
4407
4283
  var __dxlog_file15 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4408
4284
  var DataSpace = class {
4285
+ _ctx = new Context6(void 0, {
4286
+ F: __dxlog_file15,
4287
+ L: 101
4288
+ });
4289
+ _inner;
4290
+ _gossip;
4291
+ _presence;
4292
+ _keyring;
4293
+ _feedStore;
4294
+ _metadataStore;
4295
+ _signingContext;
4296
+ _notarizationPlugin;
4297
+ _callbacks;
4298
+ _cache = void 0;
4299
+ _echoHost;
4300
+ _edgeFeedReplicator = void 0;
4301
+ // TODO(dmaretskyi): Move into Space?
4302
+ _automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
4303
+ _epochProcessingMutex = new Mutex2();
4304
+ _state = SpaceState4.SPACE_CLOSED;
4305
+ _databaseRoot = null;
4306
+ /**
4307
+ * Error for _state === SpaceState.SPACE_ERROR.
4308
+ */
4309
+ error = void 0;
4310
+ authVerifier;
4311
+ stateUpdate = new Event7();
4312
+ postOpen = new CallbackCollection();
4313
+ preClose = new CallbackCollection();
4314
+ metrics = {};
4315
+ constructor(params) {
4316
+ this._inner = params.inner;
4317
+ this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
4318
+ this._gossip = params.gossip;
4319
+ this._presence = params.presence;
4320
+ this._keyring = params.keyring;
4321
+ this._feedStore = params.feedStore;
4322
+ this._metadataStore = params.metadataStore;
4323
+ this._signingContext = params.signingContext;
4324
+ this._callbacks = params.callbacks ?? {};
4325
+ this._echoHost = params.echoHost;
4326
+ this._notarizationPlugin = new NotarizationPlugin({
4327
+ spaceId: this._inner.id,
4328
+ edgeClient: params.edgeHttpClient,
4329
+ edgeFeatures: params.edgeFeatures,
4330
+ activeEdgePollingInterval: params.activeEdgeNotarizationPollingInterval
4331
+ });
4332
+ this.authVerifier = new TrustedKeySetAuthVerifier({
4333
+ trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
4334
+ update: this._inner.stateUpdate,
4335
+ authTimeout: AUTH_TIMEOUT2
4336
+ });
4337
+ this._cache = params.cache;
4338
+ if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
4339
+ this._edgeFeedReplicator = new EdgeFeedReplicator({
4340
+ messenger: params.edgeConnection,
4341
+ spaceId: this.id
4342
+ });
4343
+ }
4344
+ this._state = params.initialState;
4345
+ log12("new state", {
4346
+ state: SpaceState4[this._state]
4347
+ }, {
4348
+ F: __dxlog_file15,
4349
+ L: 177,
4350
+ S: this,
4351
+ C: (f, a) => f(...a)
4352
+ });
4353
+ }
4409
4354
  get id() {
4410
4355
  return this._inner.id;
4411
4356
  }
@@ -4559,7 +4504,9 @@ var DataSpace = class {
4559
4504
  }
4560
4505
  async initializeDataPipeline() {
4561
4506
  if (this._state !== SpaceState4.SPACE_CONTROL_ONLY) {
4562
- throw new SystemError("Invalid operation");
4507
+ throw new SystemError({
4508
+ message: "Invalid operation"
4509
+ });
4563
4510
  }
4564
4511
  this._state = SpaceState4.SPACE_INITIALIZING;
4565
4512
  log12("new state", {
@@ -4892,74 +4839,9 @@ var DataSpace = class {
4892
4839
  getEdgeReplicationSetting() {
4893
4840
  return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
4894
4841
  }
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
- }
4842
+ _onFeedAdded = async (feed) => {
4843
+ await this._edgeFeedReplicator.addFeed(feed);
4844
+ };
4963
4845
  };
4964
4846
  _ts_decorate6([
4965
4847
  trace5.info()
@@ -5015,21 +4897,16 @@ import { getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credent
5015
4897
  import { invariant as invariant12 } from "@dxos/invariant";
5016
4898
  import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
5017
4899
  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
4900
  var __dxlog_file16 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
5032
4901
  var DeviceInvitationProtocol = class {
4902
+ _keyring;
4903
+ _getIdentity;
4904
+ _acceptIdentity;
4905
+ constructor(_keyring, _getIdentity, _acceptIdentity) {
4906
+ this._keyring = _keyring;
4907
+ this._getIdentity = _getIdentity;
4908
+ this._acceptIdentity = _acceptIdentity;
4909
+ }
5033
4910
  toJSON() {
5034
4911
  return {
5035
4912
  kind: "device"
@@ -5084,7 +4961,9 @@ var DeviceInvitationProtocol = class {
5084
4961
  try {
5085
4962
  const identity = this._getIdentity();
5086
4963
  if (identity) {
5087
- return new AlreadyJoinedError2("Currently only one identity per client is supported.");
4964
+ return new AlreadyJoinedError2({
4965
+ message: "Currently only one identity per client is supported."
4966
+ });
5088
4967
  }
5089
4968
  } catch {
5090
4969
  }
@@ -5141,14 +5020,6 @@ var DeviceInvitationProtocol = class {
5141
5020
  identityKey
5142
5021
  };
5143
5022
  }
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
5023
  };
5153
5024
 
5154
5025
  // src/packlets/invitations/invitations-handler.ts
@@ -5203,24 +5074,22 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
5203
5074
  };
5204
5075
 
5205
5076
  // 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
5077
  var __dxlog_file17 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
5220
5078
  var MAX_RETRIES_PER_INVITATION = 5;
5221
5079
  var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
5222
5080
  var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
5223
5081
  var EdgeInvitationHandler = class {
5082
+ _client;
5083
+ _callbacks;
5084
+ _flowLock;
5085
+ _retryInterval;
5086
+ _retryJitter;
5087
+ constructor(config, _client, _callbacks) {
5088
+ this._client = _client;
5089
+ this._callbacks = _callbacks;
5090
+ this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
5091
+ this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
5092
+ }
5224
5093
  handle(ctx, guardedState, protocol, deviceProfile) {
5225
5094
  if (!this._client) {
5226
5095
  log13("edge disabled", void 0, {
@@ -5363,17 +5232,6 @@ var EdgeInvitationHandler = class {
5363
5232
  _calculateNextRetryMs() {
5364
5233
  return this._retryInterval + Math.random() * this._retryJitter;
5365
5234
  }
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
5235
  };
5378
5236
 
5379
5237
  // src/packlets/invitations/invitation-guest-extenstion.ts
@@ -5385,22 +5243,31 @@ import { InvalidInvitationExtensionRoleError } from "@dxos/protocols";
5385
5243
  import { schema as schema4 } from "@dxos/protocols/proto";
5386
5244
  import { InvitationOptions } from "@dxos/protocols/proto/dxos/halo/invitations";
5387
5245
  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
5246
  var __dxlog_file18 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
5402
5247
  var OPTIONS_TIMEOUT = 1e4;
5403
5248
  var InvitationGuestExtension = class extends RpcExtension2 {
5249
+ _invitationFlowMutex;
5250
+ _callbacks;
5251
+ _ctx = new Context7(void 0, {
5252
+ F: __dxlog_file18,
5253
+ L: 38
5254
+ });
5255
+ _remoteOptions;
5256
+ _remoteOptionsTrigger = new Trigger4();
5257
+ /**
5258
+ * Held to allow only one invitation flow at a time to be active.
5259
+ */
5260
+ _invitationFlowLock = null;
5261
+ constructor(_invitationFlowMutex, _callbacks) {
5262
+ super({
5263
+ requested: {
5264
+ InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5265
+ },
5266
+ exposed: {
5267
+ InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5268
+ }
5269
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks;
5270
+ }
5404
5271
  hasFlowLock() {
5405
5272
  return this._invitationFlowLock != null;
5406
5273
  }
@@ -5467,10 +5334,12 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5467
5334
  C: (f, a) => f(...a)
5468
5335
  });
5469
5336
  if (this._remoteOptions?.role !== InvitationOptions.Role.HOST) {
5470
- throw new InvalidInvitationExtensionRoleError(void 0, {
5471
- expected: InvitationOptions.Role.HOST,
5472
- remoteOptions: this._remoteOptions,
5473
- remotePeerId: context.remotePeerId
5337
+ throw new InvalidInvitationExtensionRoleError({
5338
+ context: {
5339
+ expected: InvitationOptions.Role.HOST,
5340
+ remoteOptions: this._remoteOptions,
5341
+ remotePeerId: context.remotePeerId
5342
+ }
5474
5343
  });
5475
5344
  }
5476
5345
  this._callbacks.onOpen(this._ctx, context);
@@ -5496,28 +5365,12 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5496
5365
  this._invitationFlowLock = null;
5497
5366
  log14.verbose("invitation flow lock released", void 0, {
5498
5367
  F: __dxlog_file18,
5499
- L: 131,
5368
+ L: 133,
5500
5369
  S: this,
5501
5370
  C: (f, a) => f(...a)
5502
5371
  });
5503
5372
  }
5504
5373
  }
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
5374
  };
5522
5375
 
5523
5376
  // src/packlets/invitations/invitation-host-extension.ts
@@ -5532,23 +5385,46 @@ import { schema as schema5 } from "@dxos/protocols/proto";
5532
5385
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
5533
5386
  import { AuthenticationResponse, InvitationOptions as InvitationOptions2 } from "@dxos/protocols/proto/dxos/halo/invitations";
5534
5387
  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
5388
  var __dxlog_file19 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
5549
5389
  var OPTIONS_TIMEOUT2 = 1e4;
5550
5390
  var MAX_OTP_ATTEMPTS = 3;
5551
5391
  var InvitationHostExtension = class extends RpcExtension3 {
5392
+ _invitationFlowMutex;
5393
+ _callbacks;
5394
+ /**
5395
+ * @internal
5396
+ */
5397
+ _ctx = new Context8(void 0, {
5398
+ F: __dxlog_file19,
5399
+ L: 57
5400
+ });
5401
+ _remoteOptions;
5402
+ _remoteOptionsTrigger = new Trigger5();
5403
+ _challenge = void 0;
5404
+ guestProfile = void 0;
5405
+ authenticationPassed = false;
5406
+ /**
5407
+ * Retry counter for SHARED_SECRET authentication method.
5408
+ */
5409
+ authenticationRetry = 0;
5410
+ /**
5411
+ * Resolved when admission is completed.
5412
+ */
5413
+ completedTrigger = new Trigger5();
5414
+ /**
5415
+ * Held to allow only one invitation flow at a time to be active.
5416
+ */
5417
+ _invitationFlowLock = null;
5418
+ constructor(_invitationFlowMutex, _callbacks) {
5419
+ super({
5420
+ requested: {
5421
+ InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5422
+ },
5423
+ exposed: {
5424
+ InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5425
+ }
5426
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks;
5427
+ }
5552
5428
  hasFlowLock() {
5553
5429
  return this._invitationFlowLock != null;
5554
5430
  }
@@ -5795,10 +5671,12 @@ var InvitationHostExtension = class extends RpcExtension3 {
5795
5671
  C: (f, a) => f(...a)
5796
5672
  });
5797
5673
  if (this._remoteOptions?.role !== InvitationOptions2.Role.GUEST) {
5798
- throw new InvalidInvitationExtensionRoleError2(void 0, {
5799
- expected: InvitationOptions2.Role.GUEST,
5800
- remoteOptions: this._remoteOptions,
5801
- remotePeerId: context.remotePeerId
5674
+ throw new InvalidInvitationExtensionRoleError2({
5675
+ context: {
5676
+ expected: InvitationOptions2.Role.GUEST,
5677
+ remoteOptions: this._remoteOptions,
5678
+ remotePeerId: context.remotePeerId
5679
+ }
5802
5680
  });
5803
5681
  }
5804
5682
  this._callbacks.onStateUpdate(Invitation5.State.CONNECTED);
@@ -5843,37 +5721,12 @@ var InvitationHostExtension = class extends RpcExtension3 {
5843
5721
  this._invitationFlowLock = null;
5844
5722
  log15.verbose("invitation flow lock released", void 0, {
5845
5723
  F: __dxlog_file19,
5846
- L: 299,
5724
+ L: 301,
5847
5725
  S: this,
5848
5726
  C: (f, a) => f(...a)
5849
5727
  });
5850
5728
  }
5851
5729
  }
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
5730
  };
5878
5731
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation5.AuthMethod.NONE;
5879
5732
 
@@ -5979,21 +5832,22 @@ import { PublicKey as PublicKey10 } from "@dxos/keys";
5979
5832
  import { log as log17 } from "@dxos/log";
5980
5833
  import { InvitationOptions as InvitationOptions3 } from "@dxos/protocols/proto/dxos/halo/invitations";
5981
5834
  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
5835
  var __dxlog_file21 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
5996
5836
  var InvitationTopology = class {
5837
+ _role;
5838
+ _controller;
5839
+ /**
5840
+ * Peers we tried to establish a connection with.
5841
+ * In invitation flow peers are assigned random ids when they join the swarm, so we'll retry
5842
+ * a peer if they reload an invitation.
5843
+ *
5844
+ * Consider keeping a separate set for peers we know are hosts and have some retry timeout
5845
+ * for guests we failed an invitation flow with (potentially due to a network error).
5846
+ */
5847
+ _seenPeers = new ComplexSet4(PublicKey10.hash);
5848
+ constructor(_role) {
5849
+ this._role = _role;
5850
+ }
5997
5851
  init(controller) {
5998
5852
  invariant16(!this._controller, "Already initialized.", {
5999
5853
  F: __dxlog_file21,
@@ -6058,33 +5912,24 @@ var InvitationTopology = class {
6058
5912
  toString() {
6059
5913
  return `InvitationTopology(${this._role === InvitationOptions3.Role.GUEST ? "guest" : "host"})`;
6060
5914
  }
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
5915
  };
6069
5916
 
6070
5917
  // 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
5918
  var __dxlog_file22 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
6085
5919
  var metrics = _trace.metrics;
6086
5920
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
6087
5921
  var InvitationsHandler = class {
5922
+ _networkManager;
5923
+ _edgeClient;
5924
+ _connectionParams;
5925
+ /**
5926
+ * @internal
5927
+ */
5928
+ constructor(_networkManager, _edgeClient, _connectionParams) {
5929
+ this._networkManager = _networkManager;
5930
+ this._edgeClient = _edgeClient;
5931
+ this._connectionParams = _connectionParams;
5932
+ }
6088
5933
  handleInvitationFlow(ctx, stream, protocol, invitation) {
6089
5934
  log18.verbose("dxos.sdk.invitations-handler.handleInvitationFlow", {
6090
5935
  state: invitation.state,
@@ -6655,22 +6500,13 @@ var InvitationsHandler = class {
6655
6500
  throw new Error(`Authentication failed with code: ${response.status}`);
6656
6501
  }
6657
6502
  }
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
6503
  };
6670
6504
  var checkInvitation = (protocol, invitation) => {
6671
6505
  const expiresOn = getExpirationTime(invitation);
6672
6506
  if (expiresOn && expiresOn.getTime() < Date.now()) {
6673
- return new InvalidInvitationError("Invitation already expired.");
6507
+ return new InvalidInvitationError({
6508
+ message: "Invitation already expired."
6509
+ });
6674
6510
  }
6675
6511
  return protocol.checkInvitation(invitation);
6676
6512
  };
@@ -6686,20 +6522,11 @@ var createAdmissionKeypair = () => {
6686
6522
  import { Stream as Stream9 } from "@dxos/codec-protobuf/stream";
6687
6523
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
6688
6524
  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
6525
  var InvitationsServiceImpl = class {
6526
+ _invitationsManager;
6527
+ constructor(_invitationsManager) {
6528
+ this._invitationsManager = _invitationsManager;
6529
+ }
6703
6530
  // TODO(burdon): Guest/host label.
6704
6531
  getLoggingContext() {
6705
6532
  return {};
@@ -6791,10 +6618,6 @@ var InvitationsServiceImpl = class {
6791
6618
  });
6792
6619
  });
6793
6620
  }
6794
- constructor(_invitationsManager) {
6795
- _define_property21(this, "_invitationsManager", void 0);
6796
- this._invitationsManager = _invitationsManager;
6797
- }
6798
6621
  };
6799
6622
 
6800
6623
  // src/packlets/invitations/space-invitation-protocol.ts
@@ -6805,21 +6628,18 @@ import { log as log19 } from "@dxos/log";
6805
6628
  import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError as InvalidInvitationError2, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
6806
6629
  import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
6807
6630
  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
6631
  var __dxlog_file23 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
6822
6632
  var SpaceInvitationProtocol = class {
6633
+ _spaceManager;
6634
+ _signingContext;
6635
+ _keyring;
6636
+ _spaceKey;
6637
+ constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
6638
+ this._spaceManager = _spaceManager;
6639
+ this._signingContext = _signingContext;
6640
+ this._keyring = _keyring;
6641
+ this._spaceKey = _spaceKey;
6642
+ }
6823
6643
  toJSON() {
6824
6644
  return {
6825
6645
  kind: "space",
@@ -6829,21 +6649,25 @@ var SpaceInvitationProtocol = class {
6829
6649
  }
6830
6650
  checkCanInviteNewMembers() {
6831
6651
  if (this._spaceKey == null) {
6832
- return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
6652
+ return new InvalidInvitationError2({
6653
+ message: "No spaceKey was provided for a space invitation."
6654
+ });
6833
6655
  }
6834
6656
  const space = this._spaceManager.spaces.get(this._spaceKey);
6835
6657
  if (space == null) {
6836
6658
  return new SpaceNotFoundError2(this._spaceKey);
6837
6659
  }
6838
6660
  if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
6839
- return new AuthorizationError2("No member management permission.");
6661
+ return new AuthorizationError2({
6662
+ message: "No member management permission."
6663
+ });
6840
6664
  }
6841
6665
  return void 0;
6842
6666
  }
6843
6667
  getInvitationContext() {
6844
6668
  invariant18(this._spaceKey, void 0, {
6845
6669
  F: __dxlog_file23,
6846
- L: 66,
6670
+ L: 60,
6847
6671
  S: this,
6848
6672
  A: [
6849
6673
  "this._spaceKey",
@@ -6853,7 +6677,7 @@ var SpaceInvitationProtocol = class {
6853
6677
  const space = this._spaceManager.spaces.get(this._spaceKey);
6854
6678
  invariant18(space, void 0, {
6855
6679
  F: __dxlog_file23,
6856
- L: 68,
6680
+ L: 62,
6857
6681
  S: this,
6858
6682
  A: [
6859
6683
  "space",
@@ -6869,7 +6693,7 @@ var SpaceInvitationProtocol = class {
6869
6693
  async admit(invitation, request, guestProfile) {
6870
6694
  invariant18(this._spaceKey && request.space, void 0, {
6871
6695
  F: __dxlog_file23,
6872
- L: 81,
6696
+ L: 75,
6873
6697
  S: this,
6874
6698
  A: [
6875
6699
  "this._spaceKey && request.space",
@@ -6881,7 +6705,7 @@ var SpaceInvitationProtocol = class {
6881
6705
  guest: request.space.deviceKey
6882
6706
  }, {
6883
6707
  F: __dxlog_file23,
6884
- L: 82,
6708
+ L: 76,
6885
6709
  S: this,
6886
6710
  C: (f, a) => f(...a)
6887
6711
  });
@@ -6903,7 +6727,7 @@ var SpaceInvitationProtocol = class {
6903
6727
  async delegate(invitation) {
6904
6728
  invariant18(this._spaceKey, void 0, {
6905
6729
  F: __dxlog_file23,
6906
- L: 102,
6730
+ L: 96,
6907
6731
  S: this,
6908
6732
  A: [
6909
6733
  "this._spaceKey",
@@ -6913,7 +6737,7 @@ var SpaceInvitationProtocol = class {
6913
6737
  const space = this._spaceManager.spaces.get(this._spaceKey);
6914
6738
  invariant18(space, void 0, {
6915
6739
  F: __dxlog_file23,
6916
- L: 104,
6740
+ L: 98,
6917
6741
  S: this,
6918
6742
  A: [
6919
6743
  "space",
@@ -6923,7 +6747,7 @@ var SpaceInvitationProtocol = class {
6923
6747
  if (invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY) {
6924
6748
  invariant18(invitation.guestKeypair?.publicKey, void 0, {
6925
6749
  F: __dxlog_file23,
6926
- L: 106,
6750
+ L: 100,
6927
6751
  S: this,
6928
6752
  A: [
6929
6753
  "invitation.guestKeypair?.publicKey",
@@ -6936,7 +6760,7 @@ var SpaceInvitationProtocol = class {
6936
6760
  id: invitation.invitationId
6937
6761
  }, {
6938
6762
  F: __dxlog_file23,
6939
- L: 109,
6763
+ L: 103,
6940
6764
  S: this,
6941
6765
  C: (f, a) => f(...a)
6942
6766
  });
@@ -6951,7 +6775,7 @@ var SpaceInvitationProtocol = class {
6951
6775
  });
6952
6776
  invariant18(credential.credential, void 0, {
6953
6777
  F: __dxlog_file23,
6954
- L: 127,
6778
+ L: 121,
6955
6779
  S: this,
6956
6780
  A: [
6957
6781
  "credential.credential",
@@ -6966,7 +6790,7 @@ var SpaceInvitationProtocol = class {
6966
6790
  async cancelDelegation(invitation) {
6967
6791
  invariant18(this._spaceKey, void 0, {
6968
6792
  F: __dxlog_file23,
6969
- L: 133,
6793
+ L: 127,
6970
6794
  S: this,
6971
6795
  A: [
6972
6796
  "this._spaceKey",
@@ -6975,7 +6799,7 @@ var SpaceInvitationProtocol = class {
6975
6799
  });
6976
6800
  invariant18(invitation.type === Invitation8.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6977
6801
  F: __dxlog_file23,
6978
- L: 134,
6802
+ L: 128,
6979
6803
  S: this,
6980
6804
  A: [
6981
6805
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -6985,7 +6809,7 @@ var SpaceInvitationProtocol = class {
6985
6809
  const space = this._spaceManager.spaces.get(this._spaceKey);
6986
6810
  invariant18(space, void 0, {
6987
6811
  F: __dxlog_file23,
6988
- L: 136,
6812
+ L: 130,
6989
6813
  S: this,
6990
6814
  A: [
6991
6815
  "space",
@@ -6997,14 +6821,14 @@ var SpaceInvitationProtocol = class {
6997
6821
  id: invitation.invitationId
6998
6822
  }, {
6999
6823
  F: __dxlog_file23,
7000
- L: 138,
6824
+ L: 132,
7001
6825
  S: this,
7002
6826
  C: (f, a) => f(...a)
7003
6827
  });
7004
6828
  const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
7005
6829
  invariant18(credential.credential, void 0, {
7006
6830
  F: __dxlog_file23,
7007
- L: 145,
6831
+ L: 139,
7008
6832
  S: this,
7009
6833
  A: [
7010
6834
  "credential.credential",
@@ -7017,10 +6841,14 @@ var SpaceInvitationProtocol = class {
7017
6841
  }
7018
6842
  checkInvitation(invitation) {
7019
6843
  if (invitation.spaceKey == null) {
7020
- return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
6844
+ return new InvalidInvitationError2({
6845
+ message: "No spaceKey was provided for a space invitation."
6846
+ });
7021
6847
  }
7022
6848
  if (this._spaceManager.spaces.has(invitation.spaceKey)) {
7023
- return new AlreadyJoinedError3("Already joined space.");
6849
+ return new AlreadyJoinedError3({
6850
+ message: "Already joined space."
6851
+ });
7024
6852
  }
7025
6853
  }
7026
6854
  createIntroduction() {
@@ -7043,7 +6871,7 @@ var SpaceInvitationProtocol = class {
7043
6871
  async accept(response) {
7044
6872
  invariant18(response.space, void 0, {
7045
6873
  F: __dxlog_file23,
7046
- L: 180,
6874
+ L: 174,
7047
6875
  S: this,
7048
6876
  A: [
7049
6877
  "response.space",
@@ -7054,7 +6882,7 @@ var SpaceInvitationProtocol = class {
7054
6882
  const assertion = getCredentialAssertion5(credential);
7055
6883
  invariant18(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
7056
6884
  F: __dxlog_file23,
7057
- L: 183,
6885
+ L: 177,
7058
6886
  S: this,
7059
6887
  A: [
7060
6888
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -7063,7 +6891,7 @@ var SpaceInvitationProtocol = class {
7063
6891
  });
7064
6892
  invariant18(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
7065
6893
  F: __dxlog_file23,
7066
- L: 184,
6894
+ L: 178,
7067
6895
  S: this,
7068
6896
  A: [
7069
6897
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -7071,7 +6899,9 @@ var SpaceInvitationProtocol = class {
7071
6899
  ]
7072
6900
  });
7073
6901
  if (this._spaceManager.spaces.has(assertion.spaceKey)) {
7074
- throw new AlreadyJoinedError3("Already joined space.");
6902
+ throw new AlreadyJoinedError3({
6903
+ message: "Already joined space."
6904
+ });
7075
6905
  }
7076
6906
  await this._spaceManager.acceptSpace({
7077
6907
  spaceKey: assertion.spaceKey,
@@ -7084,16 +6914,6 @@ var SpaceInvitationProtocol = class {
7084
6914
  spaceKey: assertion.spaceKey
7085
6915
  };
7086
6916
  }
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
6917
  };
7098
6918
 
7099
6919
  // src/packlets/invitations/invitations-manager.ts
@@ -7107,21 +6927,25 @@ import { PublicKey as PublicKey12 } from "@dxos/keys";
7107
6927
  import { log as log20 } from "@dxos/log";
7108
6928
  import { Invitation as Invitation9 } from "@dxos/protocols/proto/dxos/client/services";
7109
6929
  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
6930
  var __dxlog_file24 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
7124
6931
  var InvitationsManager = class {
6932
+ _invitationsHandler;
6933
+ _getHandler;
6934
+ _metadataStore;
6935
+ _createInvitations = /* @__PURE__ */ new Map();
6936
+ _acceptInvitations = /* @__PURE__ */ new Map();
6937
+ invitationCreated = new Event8();
6938
+ invitationAccepted = new Event8();
6939
+ removedCreated = new Event8();
6940
+ removedAccepted = new Event8();
6941
+ saved = new Event8();
6942
+ _persistentInvitationsLoadedEvent = new Event8();
6943
+ _persistentInvitationsLoaded = false;
6944
+ constructor(_invitationsHandler, _getHandler, _metadataStore) {
6945
+ this._invitationsHandler = _invitationsHandler;
6946
+ this._getHandler = _getHandler;
6947
+ this._metadataStore = _metadataStore;
6948
+ }
7125
6949
  async createInvitation(options) {
7126
6950
  if (options.invitationId) {
7127
6951
  const existingInvitation = this._createInvitations.get(options.invitationId);
@@ -7465,51 +7289,12 @@ var InvitationsManager = class {
7465
7289
  }, () => {
7466
7290
  }, callback);
7467
7291
  }
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
7292
  };
7495
7293
 
7496
7294
  // src/packlets/locks/node.ts
7497
7295
  import { invariant as invariant20 } from "@dxos/invariant";
7498
7296
  import { LockFile } from "@dxos/lock-file";
7499
7297
  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
7298
  function _ts_decorate7(decorators, target, key, desc) {
7514
7299
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7515
7300
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7518,6 +7303,15 @@ function _ts_decorate7(decorators, target, key, desc) {
7518
7303
  }
7519
7304
  var __dxlog_file25 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
7520
7305
  var Lock = class {
7306
+ _lockPath;
7307
+ _onAcquire;
7308
+ _onRelease;
7309
+ _fileHandle;
7310
+ constructor({ lockKey: lockPath, onAcquire, onRelease }) {
7311
+ this._lockPath = lockPath;
7312
+ this._onAcquire = onAcquire;
7313
+ this._onRelease = onRelease;
7314
+ }
7521
7315
  get lockKey() {
7522
7316
  return this._lockPath;
7523
7317
  }
@@ -7550,15 +7344,6 @@ var Lock = class {
7550
7344
  });
7551
7345
  await LockFile.release(this._fileHandle);
7552
7346
  }
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
7347
  };
7563
7348
  _ts_decorate7([
7564
7349
  logInfo3
@@ -7570,19 +7355,6 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
7570
7355
  import { raise as raise2 } from "@dxos/debug";
7571
7356
  import { RpcPeer, parseMethodName } from "@dxos/rpc";
7572
7357
  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
7358
  function _ts_decorate8(decorators, target, key, desc) {
7587
7359
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7588
7360
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7590,33 +7362,16 @@ function _ts_decorate8(decorators, target, key, desc) {
7590
7362
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7591
7363
  }
7592
7364
  var ClientRpcServer = class {
7365
+ _serviceRegistry;
7366
+ _rpcPeer;
7367
+ _handlerCache = /* @__PURE__ */ new Map();
7368
+ _handleCall;
7369
+ _handleStream;
7370
+ _callMetrics = new MapCounter();
7593
7371
  get _services() {
7594
7372
  return Object.keys(this._serviceRegistry.services);
7595
7373
  }
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
7374
  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
7375
  const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
7621
7376
  this._handleCall = handleCall;
7622
7377
  this._handleStream = handleStream;
@@ -7648,6 +7403,23 @@ var ClientRpcServer = class {
7648
7403
  }
7649
7404
  });
7650
7405
  }
7406
+ async open() {
7407
+ await this._rpcPeer.open();
7408
+ }
7409
+ async close() {
7410
+ await this._rpcPeer.close();
7411
+ }
7412
+ _getServiceHandler(serviceName) {
7413
+ if (!this._handlerCache.has(serviceName)) {
7414
+ const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise2(new Error(`Service not available: ${serviceName}`));
7415
+ const service = this._serviceRegistry.services[key];
7416
+ if (!service) {
7417
+ throw new Error(`Service not available: ${serviceName}`);
7418
+ }
7419
+ this._handlerCache.set(serviceName, descriptor.createServer(service));
7420
+ }
7421
+ return this._handlerCache.get(serviceName);
7422
+ }
7651
7423
  };
7652
7424
  _ts_decorate8([
7653
7425
  trace9.metricsCounter()
@@ -7668,19 +7440,6 @@ import { log as log22 } from "@dxos/log";
7668
7440
  import { EdgeAgentStatus, EdgeCallFailedError as EdgeCallFailedError3 } from "@dxos/protocols";
7669
7441
  import { SpaceState as SpaceState5 } from "@dxos/protocols/proto/dxos/client/services";
7670
7442
  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
7443
  function _ts_decorate9(decorators, target, key, desc) {
7685
7444
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7686
7445
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7692,6 +7451,18 @@ var AGENT_STATUS_QUERY_RETRY_INTERVAL = 5e3;
7692
7451
  var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
7693
7452
  var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
7694
7453
  var EdgeAgentManager = class extends Resource7 {
7454
+ _edgeFeatures;
7455
+ _edgeHttpClient;
7456
+ _dataSpaceManager;
7457
+ _identity;
7458
+ agentStatusChanged = new Event9();
7459
+ _agentDeviceKey;
7460
+ _agentStatus;
7461
+ _lastKnownDeviceCount = 0;
7462
+ _fetchAgentStatusTask;
7463
+ constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7464
+ super(), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity;
7465
+ }
7695
7466
  get agentStatus() {
7696
7467
  return this._agentStatus;
7697
7468
  }
@@ -7900,9 +7671,6 @@ var EdgeAgentManager = class extends Resource7 {
7900
7671
  C: (f, a) => f(...a)
7901
7672
  });
7902
7673
  }
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
7674
  };
7907
7675
  _ts_decorate9([
7908
7676
  synchronized3
@@ -7912,26 +7680,27 @@ _ts_decorate9([
7912
7680
  import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
7913
7681
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7914
7682
  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
7683
  var EdgeAgentServiceImpl = class {
7684
+ _agentManagerProvider;
7685
+ _edgeConnection;
7686
+ constructor(_agentManagerProvider, _edgeConnection) {
7687
+ this._agentManagerProvider = _agentManagerProvider;
7688
+ this._edgeConnection = _edgeConnection;
7689
+ }
7929
7690
  // TODO(mykola): Reconcile with NetworkService.queryStatus.
7930
7691
  queryEdgeStatus() {
7931
7692
  return new Stream11(({ ctx, next }) => {
7932
7693
  const update = () => {
7933
7694
  next({
7934
- status: this._edgeConnection?.status ?? EdgeStatus2.NOT_CONNECTED
7695
+ status: this._edgeConnection?.status ?? {
7696
+ state: EdgeStatus2.ConnectionState.NOT_CONNECTED,
7697
+ rtt: 0,
7698
+ uptime: 0,
7699
+ rateBytesUp: 0,
7700
+ rateBytesDown: 0,
7701
+ messagesSent: 0,
7702
+ messagesReceived: 0
7703
+ }
7935
7704
  });
7936
7705
  };
7937
7706
  this._edgeConnection?.statusChanged.on(ctx, update);
@@ -7958,12 +7727,6 @@ var EdgeAgentServiceImpl = class {
7958
7727
  });
7959
7728
  });
7960
7729
  }
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
7730
  };
7968
7731
  var mapStatus = (agentStatus) => {
7969
7732
  switch (agentStatus) {
@@ -8005,21 +7768,18 @@ import { log as log23 } from "@dxos/log";
8005
7768
  import { EdgeAuthChallengeError as EdgeAuthChallengeError2 } from "@dxos/protocols";
8006
7769
  import { schema as schema6 } from "@dxos/protocols/proto";
8007
7770
  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
7771
  var __dxlog_file27 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts";
8022
7772
  var EdgeIdentityRecoveryManager = class {
7773
+ _keyring;
7774
+ _edgeClient;
7775
+ _identityProvider;
7776
+ _acceptRecoveredIdentity;
7777
+ constructor(_keyring, _edgeClient, _identityProvider, _acceptRecoveredIdentity) {
7778
+ this._keyring = _keyring;
7779
+ this._edgeClient = _edgeClient;
7780
+ this._identityProvider = _identityProvider;
7781
+ this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
7782
+ }
8023
7783
  async createRecoveryCredential({ data }) {
8024
7784
  const identity = this._identityProvider();
8025
7785
  invariant22(identity, void 0, {
@@ -8212,16 +7972,6 @@ var EdgeIdentityRecoveryManager = class {
8212
7972
  dataFeedKey: await this._keyring.createKey()
8213
7973
  });
8214
7974
  }
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
7975
  };
8226
7976
  var decodeCredential = (credentialBase64) => {
8227
7977
  const credentialBytes = Buffer.from(credentialBase64, "base64");
@@ -8230,19 +7980,6 @@ var decodeCredential = (credentialBase64) => {
8230
7980
  };
8231
7981
 
8232
7982
  // 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
7983
  function _ts_decorate10(decorators, target, key, desc) {
8247
7984
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8248
7985
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -8316,21 +8053,104 @@ function _ts_dispose_resources4(env) {
8316
8053
  }
8317
8054
  var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
8318
8055
  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)
8326
- });
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)
8056
+ storage;
8057
+ level;
8058
+ networkManager;
8059
+ signalManager;
8060
+ _edgeConnection;
8061
+ _edgeHttpClient;
8062
+ _runtimeParams;
8063
+ _edgeFeatures;
8064
+ _edgeIdentityUpdateMutex = new Mutex4();
8065
+ initialized = new Trigger7();
8066
+ metadataStore;
8067
+ blobStore;
8068
+ feedStore;
8069
+ keyring;
8070
+ spaceManager;
8071
+ identityManager;
8072
+ recoveryManager;
8073
+ invitations;
8074
+ invitationsManager;
8075
+ echoHost;
8076
+ _meshReplicator = void 0;
8077
+ _echoEdgeReplicator = void 0;
8078
+ // Initialized after identity is initialized.
8079
+ dataSpaceManager;
8080
+ edgeAgentManager;
8081
+ _handlerFactories = /* @__PURE__ */ new Map();
8082
+ _deviceSpaceSync;
8083
+ _instanceId = PublicKey15.random().toHex();
8084
+ constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
8085
+ 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;
8086
+ this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
8087
+ this.blobStore = new BlobStore(storage.createDirectory("blobs"));
8088
+ this.keyring = new Keyring(storage.createDirectory("keyring"));
8089
+ this.feedStore = new FeedStore({
8090
+ factory: new FeedFactory({
8091
+ root: storage.createDirectory("feeds"),
8092
+ signer: this.keyring,
8093
+ hypercore: {
8094
+ valueEncoding,
8095
+ stats: true
8096
+ }
8097
+ })
8098
+ });
8099
+ this.spaceManager = new SpaceManager({
8100
+ feedStore: this.feedStore,
8101
+ networkManager: this.networkManager,
8102
+ blobStore: this.blobStore,
8103
+ metadataStore: this.metadataStore,
8104
+ disableP2pReplication: this._runtimeParams?.disableP2pReplication
8105
+ });
8106
+ this.identityManager = new IdentityManager({
8107
+ metadataStore: this.metadataStore,
8108
+ keyring: this.keyring,
8109
+ feedStore: this.feedStore,
8110
+ spaceManager: this.spaceManager,
8111
+ devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
8112
+ devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
8113
+ edgeConnection: this._edgeConnection,
8114
+ edgeFeatures: this._edgeFeatures
8115
+ });
8116
+ this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
8117
+ this.echoHost = new EchoHost({
8118
+ kv: this.level,
8119
+ peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8120
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8121
+ indexing: {
8122
+ vector: this._runtimeParams?.enableVectorIndexing
8123
+ }
8124
+ });
8125
+ this._meshReplicator = new MeshEchoReplicator();
8126
+ this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
8127
+ this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
8128
+ this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
8129
+ if (!this._runtimeParams?.disableP2pReplication) {
8130
+ this._meshReplicator = new MeshEchoReplicator();
8131
+ }
8132
+ if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
8133
+ this._echoEdgeReplicator = new EchoEdgeReplicator({
8134
+ edgeConnection: this._edgeConnection,
8135
+ edgeHttpClient: this._edgeHttpClient
8136
+ });
8137
+ }
8138
+ }
8139
+ async _open(ctx) {
8140
+ await this._checkStorageVersion();
8141
+ log24("opening...", void 0, {
8142
+ F: __dxlog_file28,
8143
+ L: 204,
8144
+ S: this,
8145
+ C: (f, a) => f(...a)
8146
+ });
8147
+ log24.trace("dxos.sdk.service-context.open", trace10.begin({
8148
+ id: this._instanceId
8149
+ }), {
8150
+ F: __dxlog_file28,
8151
+ L: 205,
8152
+ S: this,
8153
+ C: (f, a) => f(...a)
8334
8154
  });
8335
8155
  await this.identityManager.open(ctx);
8336
8156
  await this._setNetworkIdentity();
@@ -8618,62 +8438,6 @@ var ServiceContext = class extends Resource8 {
8618
8438
  _ts_dispose_resources4(env);
8619
8439
  }
8620
8440
  }
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
8441
  };
8678
8442
  _ts_decorate10([
8679
8443
  Trace3.span()
@@ -8709,16 +8473,24 @@ var StorageDriver = Runtime2.Client.Storage.StorageDriver;
8709
8473
  var createStorageObjects = (config) => {
8710
8474
  const { persistent = false, keyStore, dataStore } = config ?? {};
8711
8475
  if (persistent && dataStore === StorageDriver.RAM) {
8712
- throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
8476
+ throw new InvalidConfigError({
8477
+ message: "RAM storage cannot be used in persistent mode."
8478
+ });
8713
8479
  }
8714
8480
  if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
8715
- throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
8481
+ throw new InvalidConfigError({
8482
+ message: "Cannot use a persistent storage in not persistent mode."
8483
+ });
8716
8484
  }
8717
8485
  if (persistent && keyStore === StorageDriver.RAM) {
8718
- throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
8486
+ throw new InvalidConfigError({
8487
+ message: "RAM key storage cannot be used in persistent mode."
8488
+ });
8719
8489
  }
8720
8490
  if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
8721
- throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
8491
+ throw new InvalidConfigError({
8492
+ message: "Cannot use a persistent key storage in not persistent mode."
8493
+ });
8722
8494
  }
8723
8495
  return {
8724
8496
  storage: createStorage({
@@ -8920,20 +8692,14 @@ var importProfileData = async ({ storage, level }, archive) => {
8920
8692
  };
8921
8693
 
8922
8694
  // 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
8695
  var ServiceRegistry = class {
8696
+ _serviceBundle;
8697
+ _handlers;
8698
+ // prettier-ignore
8699
+ constructor(_serviceBundle, _handlers = {}) {
8700
+ this._serviceBundle = _serviceBundle;
8701
+ this._handlers = _handlers;
8702
+ }
8937
8703
  get descriptors() {
8938
8704
  return this._serviceBundle;
8939
8705
  }
@@ -8949,13 +8715,6 @@ var ServiceRegistry = class {
8949
8715
  removeService(name) {
8950
8716
  delete this._handlers[name];
8951
8717
  }
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
8718
  };
8960
8719
 
8961
8720
  // src/packlets/services/service-host.ts
@@ -8978,21 +8737,14 @@ import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
8978
8737
  import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8979
8738
  import { invariant as invariant25 } from "@dxos/invariant";
8980
8739
  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
8740
  var __dxlog_file30 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8995
8741
  var DevicesServiceImpl = class {
8742
+ _identityManager;
8743
+ _edgeConnection;
8744
+ constructor(_identityManager, _edgeConnection) {
8745
+ this._identityManager = _identityManager;
8746
+ this._edgeConnection = _edgeConnection;
8747
+ }
8996
8748
  async updateDevice(profile) {
8997
8749
  return this._identityManager.updateDeviceProfile(profile);
8998
8750
  }
@@ -9022,7 +8774,7 @@ var DevicesServiceImpl = class {
9022
8774
  if (isMe) {
9023
8775
  presence = Device2.PresenceState.ONLINE;
9024
8776
  } else if (profile.os?.toUpperCase() === "EDGE") {
9025
- presence = this._edgeConnection?.status === EdgeStatus3.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8777
+ presence = this._edgeConnection?.status.state === EdgeStatus3.ConnectionState.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
9026
8778
  } else {
9027
8779
  presence = peers.some((peer) => peer.identityKey.equals(key)) ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
9028
8780
  }
@@ -9070,12 +8822,6 @@ var DevicesServiceImpl = class {
9070
8822
  return () => subscriptions.clear();
9071
8823
  });
9072
8824
  }
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
8825
  };
9080
8826
 
9081
8827
  // src/packlets/identity/contacts-service.ts
@@ -9083,20 +8829,15 @@ import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateSchedul
9083
8829
  import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
9084
8830
  import { PublicKey as PublicKey17 } from "@dxos/keys";
9085
8831
  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
8832
  var ContactsServiceImpl = class {
8833
+ _identityManager;
8834
+ _spaceManager;
8835
+ _dataSpaceManagerProvider;
8836
+ constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
8837
+ this._identityManager = _identityManager;
8838
+ this._spaceManager = _spaceManager;
8839
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
8840
+ }
9100
8841
  async getContacts() {
9101
8842
  const identity = this._identityManager.identity;
9102
8843
  if (identity == null) {
@@ -9118,8 +8859,7 @@ var ContactsServiceImpl = class {
9118
8859
  }
9119
8860
  const existing = acc.get(memberInfo.key);
9120
8861
  if (existing != null) {
9121
- var _existing;
9122
- (_existing = existing).profile ?? (_existing.profile = memberInfo.profile);
8862
+ existing.profile ??= memberInfo.profile;
9123
8863
  existing.commonSpaces?.push(spaceKey);
9124
8864
  } else {
9125
8865
  acc.set(memberInfo.key, {
@@ -9168,14 +8908,6 @@ var ContactsServiceImpl = class {
9168
8908
  });
9169
8909
  });
9170
8910
  }
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
8911
  };
9180
8912
 
9181
8913
  // src/packlets/logging/logging-service.ts
@@ -9185,20 +8917,10 @@ import { PublicKey as PublicKey18 } from "@dxos/keys";
9185
8917
  import { getContextFromEntry, log as log26 } from "@dxos/log";
9186
8918
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
9187
8919
  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
8920
  var LoggingServiceImpl = class {
8921
+ _logs = new Event10();
8922
+ _started = Date.now();
8923
+ _sessionId = PublicKey18.random().toHex();
9202
8924
  async open() {
9203
8925
  log26.runtimeConfig.processors.push(this._logProcessor);
9204
8926
  }
@@ -9289,14 +9011,9 @@ var LoggingServiceImpl = class {
9289
9011
  this._logs.on(ctx, handler);
9290
9012
  });
9291
9013
  }
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
- }
9014
+ _logProcessor = (_config, entry2) => {
9015
+ this._logs.emit(entry2);
9016
+ };
9300
9017
  };
9301
9018
  var matchFilter = (filter, level, path2, options) => {
9302
9019
  switch (options) {
@@ -9318,20 +9035,15 @@ var LOG_PROCESSING = 0;
9318
9035
 
9319
9036
  // src/packlets/network/network-service.ts
9320
9037
  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
9038
  var NetworkServiceImpl = class {
9039
+ networkManager;
9040
+ signalManager;
9041
+ edgeConnection;
9042
+ constructor(networkManager, signalManager, edgeConnection) {
9043
+ this.networkManager = networkManager;
9044
+ this.signalManager = signalManager;
9045
+ this.edgeConnection = edgeConnection;
9046
+ }
9335
9047
  queryStatus() {
9336
9048
  return new Stream15(({ ctx, next }) => {
9337
9049
  const update = () => {
@@ -9382,34 +9094,27 @@ var NetworkServiceImpl = class {
9382
9094
  });
9383
9095
  });
9384
9096
  }
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
9097
  };
9394
9098
 
9395
9099
  // src/packlets/system/system-service.ts
9396
9100
  import { Stream as Stream16 } from "@dxos/codec-protobuf/stream";
9397
9101
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
9398
9102
  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
9103
  var SystemServiceImpl = class {
9104
+ _config;
9105
+ _statusUpdate;
9106
+ _getCurrentStatus;
9107
+ _onUpdateStatus;
9108
+ _onReset;
9109
+ _getDiagnostics;
9110
+ constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
9111
+ this._config = config;
9112
+ this._statusUpdate = statusUpdate;
9113
+ this._getCurrentStatus = getCurrentStatus;
9114
+ this._getDiagnostics = getDiagnostics;
9115
+ this._onUpdateStatus = onUpdateStatus;
9116
+ this._onReset = onReset;
9117
+ }
9413
9118
  async getConfig() {
9414
9119
  return (await this._config?.())?.values ?? {};
9415
9120
  }
@@ -9452,36 +9157,9 @@ var SystemServiceImpl = class {
9452
9157
  async reset() {
9453
9158
  await this._onReset();
9454
9159
  }
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
9160
  };
9470
9161
 
9471
9162
  // 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
9163
  function _ts_decorate11(decorators, target, key, desc) {
9486
9164
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9487
9165
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -9490,6 +9168,94 @@ function _ts_decorate11(decorators, target, key, desc) {
9490
9168
  }
9491
9169
  var __dxlog_file31 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
9492
9170
  var ClientServicesHost = class {
9171
+ _resourceLock;
9172
+ _serviceRegistry;
9173
+ _systemService;
9174
+ _loggingService;
9175
+ _tracingService = TRACE_PROCESSOR3.createTraceSender();
9176
+ _statusUpdate = new Event11();
9177
+ _config;
9178
+ _signalManager;
9179
+ _networkManager;
9180
+ _storage;
9181
+ _level;
9182
+ _callbacks;
9183
+ _devtoolsProxy;
9184
+ _edgeConnection = void 0;
9185
+ _edgeHttpClient = void 0;
9186
+ _serviceContext;
9187
+ _runtimeParams;
9188
+ diagnosticsBroadcastHandler;
9189
+ _opening = false;
9190
+ _open = false;
9191
+ _resetting = false;
9192
+ constructor({
9193
+ config,
9194
+ transportFactory,
9195
+ signalManager,
9196
+ storage,
9197
+ level,
9198
+ // TODO(wittjosiah): Turn this on by default.
9199
+ lockKey,
9200
+ callbacks,
9201
+ runtimeParams
9202
+ } = {}) {
9203
+ this._storage = storage;
9204
+ this._level = level;
9205
+ this._callbacks = callbacks;
9206
+ this._runtimeParams = runtimeParams ?? {};
9207
+ if (this._runtimeParams.disableP2pReplication === void 0) {
9208
+ this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9209
+ }
9210
+ if (this._runtimeParams.enableVectorIndexing === void 0) {
9211
+ this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9212
+ }
9213
+ if (config) {
9214
+ this.initialize({
9215
+ config,
9216
+ transportFactory,
9217
+ signalManager
9218
+ });
9219
+ }
9220
+ if (lockKey) {
9221
+ this._resourceLock = new Lock({
9222
+ lockKey,
9223
+ onAcquire: () => {
9224
+ if (!this._opening) {
9225
+ void this.open(new Context11(void 0, {
9226
+ F: __dxlog_file31,
9227
+ L: 143
9228
+ }));
9229
+ }
9230
+ },
9231
+ onRelease: () => this.close()
9232
+ });
9233
+ }
9234
+ this._systemService = new SystemServiceImpl({
9235
+ config: () => this._config,
9236
+ statusUpdate: this._statusUpdate,
9237
+ getCurrentStatus: () => this.isOpen && !this._resetting ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
9238
+ getDiagnostics: () => {
9239
+ return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
9240
+ },
9241
+ onUpdateStatus: async (status) => {
9242
+ if (!this.isOpen && status === SystemStatus.ACTIVE) {
9243
+ await this._resourceLock?.acquire();
9244
+ } else if (this.isOpen && status === SystemStatus.INACTIVE) {
9245
+ await this._resourceLock?.release();
9246
+ }
9247
+ },
9248
+ onReset: async () => {
9249
+ await this.reset();
9250
+ }
9251
+ });
9252
+ this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
9253
+ this._loggingService = new LoggingServiceImpl();
9254
+ this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
9255
+ SystemService: this._systemService,
9256
+ TracingService: this._tracingService
9257
+ });
9258
+ }
9493
9259
  get isOpen() {
9494
9260
  return this._open;
9495
9261
  }
@@ -9763,10 +9529,22 @@ var ClientServicesHost = class {
9763
9529
  this._resetting = true;
9764
9530
  this._statusUpdate.emit();
9765
9531
  await this._serviceContext?.close();
9532
+ try {
9533
+ await this._level.clear();
9534
+ } catch (err) {
9535
+ log27.warn("failed to clear leveldb during reset", {
9536
+ err
9537
+ }, {
9538
+ F: __dxlog_file31,
9539
+ L: 415,
9540
+ S: this,
9541
+ C: (f, a) => f(...a)
9542
+ });
9543
+ }
9766
9544
  await this._storage.reset();
9767
9545
  log27.info("reset", void 0, {
9768
9546
  F: __dxlog_file31,
9769
- L: 412,
9547
+ L: 418,
9770
9548
  S: this,
9771
9549
  C: (f, a) => f(...a)
9772
9550
  });
@@ -9774,7 +9552,7 @@ var ClientServicesHost = class {
9774
9552
  id: traceId
9775
9553
  }), {
9776
9554
  F: __dxlog_file31,
9777
- L: 413,
9555
+ L: 419,
9778
9556
  S: this,
9779
9557
  C: (f, a) => f(...a)
9780
9558
  });
@@ -9785,94 +9563,6 @@ var ClientServicesHost = class {
9785
9563
  await this._serviceContext.initialized.wait();
9786
9564
  return identity;
9787
9565
  }
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
9566
  };
9877
9567
  _ts_decorate11([
9878
9568
  Trace4.info()
@@ -9940,4 +9630,4 @@ export {
9940
9630
  ServiceRegistry,
9941
9631
  ClientServicesHost
9942
9632
  };
9943
- //# sourceMappingURL=chunk-AADRC6MD.mjs.map
9633
+ //# sourceMappingURL=chunk-7NQQ5F2Q.mjs.map