@dxos/client-services 0.1.56-main.c19b7cd → 0.1.56-main.c277f68

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 (38) hide show
  1. package/dist/lib/browser/{chunk-ZOTHWLK5.mjs → chunk-E7EKG5QQ.mjs} +267 -280
  2. package/dist/lib/browser/chunk-E7EKG5QQ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +8 -13
  4. package/dist/lib/browser/index.mjs.map +2 -2
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +30 -45
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +2 -2
  8. package/dist/lib/node/index.cjs +287 -305
  9. package/dist/lib/node/index.cjs.map +3 -3
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +299 -323
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts +5 -0
  14. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  15. package/dist/types/src/packlets/identity/identity-service.d.ts +7 -3
  16. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  17. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  18. package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  21. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  22. package/dist/types/src/version.d.ts +1 -1
  23. package/package.json +34 -34
  24. package/src/packlets/identity/identity-manager.test.ts +11 -0
  25. package/src/packlets/identity/identity-manager.ts +18 -1
  26. package/src/packlets/identity/identity-service.test.ts +15 -1
  27. package/src/packlets/identity/identity-service.ts +23 -14
  28. package/src/packlets/invitations/invitations-handler.ts +2 -0
  29. package/src/packlets/services/diagnostics.ts +2 -1
  30. package/src/packlets/services/service-context.ts +7 -4
  31. package/src/packlets/services/service-host.test.ts +1 -1
  32. package/src/packlets/services/service-host.ts +11 -7
  33. package/src/packlets/spaces/data-space-manager.test.ts +80 -22
  34. package/src/packlets/spaces/data-space-manager.ts +5 -1
  35. package/src/packlets/spaces/spaces-service.ts +1 -1
  36. package/src/packlets/vault/worker-runtime.ts +1 -1
  37. package/src/version.ts +1 -1
  38. package/dist/lib/browser/chunk-ZOTHWLK5.mjs.map +0 -7
@@ -75,7 +75,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
75
75
  const feedMap = new import_util.ComplexMap(import_keys.PublicKey.hash);
76
76
  const update = () => {
77
77
  const { feeds } = feedStore;
78
- feeds.filter((feed) => !(feedKeys == null ? void 0 : feedKeys.length) || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
78
+ feeds.filter((feed) => !feedKeys?.length || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
79
79
  if (!feedMap.has(feed.key)) {
80
80
  feedMap.set(feed.key, feed);
81
81
  feed.on("close", update);
@@ -83,15 +83,12 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
83
83
  }
84
84
  });
85
85
  next({
86
- feeds: Array.from(feedMap.values()).map((feed) => {
87
- var _a, _b;
88
- return {
89
- feedKey: feed.key,
90
- length: feed.properties.length,
91
- bytes: feed.core.byteLength,
92
- downloaded: (_b = (_a = feed.core.bitfield) == null ? void 0 : _a.data.toBuffer()) != null ? _b : new Uint8Array()
93
- };
94
- })
86
+ feeds: Array.from(feedMap.values()).map((feed) => ({
87
+ feedKey: feed.key,
88
+ length: feed.properties.length,
89
+ bytes: feed.core.byteLength,
90
+ downloaded: feed.core.bitfield?.data.toBuffer() ?? new Uint8Array()
91
+ }))
95
92
  });
96
93
  };
97
94
  subscriptions.add(feedStore.feedOpened.on(update));
@@ -191,13 +188,13 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf4.Stream
191
188
  recipient: message.recipient.asUint8Array(),
192
189
  payload: message.payload
193
190
  },
194
- receivedAt: new Date()
191
+ receivedAt: /* @__PURE__ */ new Date()
195
192
  });
196
193
  });
197
194
  signalManager.swarmEvent.on(ctx, (swarmEvent) => {
198
195
  next({
199
196
  swarmEvent: swarmEvent.swarmEvent,
200
- receivedAt: new Date()
197
+ receivedAt: /* @__PURE__ */ new Date()
201
198
  });
202
199
  });
203
200
  return () => {
@@ -208,13 +205,10 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
208
205
  const update = () => {
209
206
  try {
210
207
  const topics = networkManager.topics;
211
- const labeledTopics = topics.map((topic) => {
212
- var _a, _b;
213
- return {
214
- topic,
215
- label: (_b = (_a = networkManager.getSwarm(topic)) == null ? void 0 : _a.label) != null ? _b : topic.toHex()
216
- };
217
- });
208
+ const labeledTopics = topics.map((topic) => ({
209
+ topic,
210
+ label: networkManager.getSwarm(topic)?.label ?? topic.toHex()
211
+ }));
218
212
  next({
219
213
  topics: labeledTopics
220
214
  });
@@ -226,17 +220,15 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
226
220
  update();
227
221
  });
228
222
  var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf4.Stream(({ next }) => {
229
- var _a;
230
223
  const update = () => {
231
- var _a2;
232
- const info = (_a2 = networkManager.connectionLog) == null ? void 0 : _a2.swarms;
224
+ const info = networkManager.connectionLog?.swarms;
233
225
  if (info) {
234
226
  next({
235
227
  data: info
236
228
  });
237
229
  }
238
230
  };
239
- (_a = networkManager.connectionLog) == null ? void 0 : _a.update.on(update);
231
+ networkManager.connectionLog?.update.on(update);
240
232
  update();
241
233
  });
242
234
  var getNetworkPeers = ({ networkManager }, request) => {
@@ -245,7 +237,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
245
237
  }
246
238
  const map = networkManager.getSwarmMap(import_keys2.PublicKey.from(request.topic));
247
239
  return {
248
- peers: map == null ? void 0 : map.peers.map((peer) => ({
240
+ peers: map?.peers.map((peer) => ({
249
241
  ...peer,
250
242
  connections: peer.connections.map((connection) => connection.asUint8Array())
251
243
  }))
@@ -261,14 +253,14 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
261
253
  const spaces = [
262
254
  ...context.spaceManager.spaces.values()
263
255
  ];
264
- const filteredSpaces = spaces.filter((space) => !(spaceKeys == null ? void 0 : spaceKeys.length) || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
256
+ const filteredSpaces = spaces.filter((space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
265
257
  next({
266
258
  spaces: filteredSpaces.map((space) => {
267
259
  const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata2) => spaceMetadata2.key.equals(space.key));
268
260
  return {
269
261
  key: space.key,
270
262
  isOpen: space.isOpen,
271
- timeframe: spaceMetadata == null ? void 0 : spaceMetadata.dataTimeframe,
263
+ timeframe: spaceMetadata?.dataTimeframe,
272
264
  genesisFeed: space.genesisFeedKey,
273
265
  controlFeed: space.controlFeedKey,
274
266
  dataFeed: space.dataFeedKey
@@ -282,7 +274,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
282
274
  await update();
283
275
  });
284
276
  return () => {
285
- unsubscribe == null ? void 0 : unsubscribe();
277
+ unsubscribe?.();
286
278
  clearTimeout(timeout);
287
279
  };
288
280
  });
@@ -313,16 +305,15 @@ var DevtoolsServiceImpl = class {
313
305
  };
314
306
  }
315
307
  async getStorageInfo() {
316
- var _a, _b, _c, _d, _e;
317
- const storageUsage = (_c = await ((_b = (_a = this.params.context.storage).getDiskInfo) == null ? void 0 : _b.call(_a))) != null ? _c : {
308
+ const storageUsage = await this.params.context.storage.getDiskInfo?.() ?? {
318
309
  used: 0
319
310
  };
320
311
  const navigatorInfo = typeof navigator === "object" ? await navigator.storage.estimate() : void 0;
321
312
  return {
322
313
  type: this.params.context.storage.type,
323
314
  storageUsage: storageUsage.used,
324
- originUsage: (_d = navigatorInfo == null ? void 0 : navigatorInfo.usage) != null ? _d : 0,
325
- usageQuota: (_e = navigatorInfo == null ? void 0 : navigatorInfo.quota) != null ? _e : 0
315
+ originUsage: navigatorInfo?.usage ?? 0,
316
+ usageQuota: navigatorInfo?.quota ?? 0
326
317
  };
327
318
  }
328
319
  async getBlobs() {
@@ -508,7 +499,7 @@ var TrustedKeySetAuthVerifier = class {
508
499
  return await trigger.wait({
509
500
  timeout: this._params.authTimeout
510
501
  });
511
- } catch (e) {
502
+ } catch {
512
503
  return false;
513
504
  } finally {
514
505
  clear();
@@ -604,11 +595,10 @@ var Identity = class Identity2 {
604
595
  return this._deviceStateMachine.deviceCredentialChain;
605
596
  }
606
597
  getAdmissionCredentials() {
607
- var _a, _b;
608
598
  return {
609
599
  deviceKey: this.deviceKey,
610
- controlFeedKey: (_a = this.space.controlFeedKey) != null ? _a : (0, import_debug.failUndefined)(),
611
- dataFeedKey: (_b = this.space.dataFeedKey) != null ? _b : (0, import_debug.failUndefined)()
600
+ controlFeedKey: this.space.controlFeedKey ?? (0, import_debug.failUndefined)(),
601
+ dataFeedKey: this.space.dataFeedKey ?? (0, import_debug.failUndefined)()
612
602
  };
613
603
  }
614
604
  /**
@@ -702,6 +692,7 @@ var import_keys4 = require("@dxos/keys");
702
692
  var import_log3 = require("@dxos/log");
703
693
  var import_protocols2 = require("@dxos/protocols");
704
694
  var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
695
+ var import_timeframe = require("@dxos/timeframe");
705
696
  var import_tracing2 = require("@dxos/tracing");
706
697
  var import_util2 = require("@dxos/util");
707
698
  function _ts_decorate2(decorators, target, key, desc) {
@@ -729,7 +720,6 @@ var IdentityManager = class IdentityManager2 {
729
720
  return this._identity;
730
721
  }
731
722
  async open(ctx) {
732
- var _a;
733
723
  const traceId = import_keys4.PublicKey.random().toHex();
734
724
  import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
735
725
  id: traceId
@@ -755,7 +745,7 @@ var IdentityManager = class IdentityManager2 {
755
745
  await this._identity.ready();
756
746
  import_log3.log.trace("dxos.halo.identity", {
757
747
  identityKey: identityRecord.identityKey,
758
- displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
748
+ displayName: this._identity.profileDocument?.displayName
759
749
  }, {
760
750
  F: __dxlog_file3,
761
751
  L: 82,
@@ -774,11 +764,9 @@ var IdentityManager = class IdentityManager2 {
774
764
  });
775
765
  }
776
766
  async close() {
777
- var _a;
778
- await ((_a = this._identity) == null ? void 0 : _a.close(new import_context3.Context()));
767
+ await this._identity?.close(new import_context3.Context());
779
768
  }
780
769
  async createIdentity({ displayName } = {}) {
781
- var _a;
782
770
  (0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
783
771
  F: __dxlog_file3,
784
772
  L: 96,
@@ -852,7 +840,7 @@ var IdentityManager = class IdentityManager2 {
852
840
  await this._identity.ready();
853
841
  import_log3.log.trace("dxos.halo.identity", {
854
842
  identityKey: identityRecord.identityKey,
855
- displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
843
+ displayName: this._identity.profileDocument?.displayName
856
844
  }, {
857
845
  F: __dxlog_file3,
858
846
  L: 152,
@@ -875,7 +863,6 @@ var IdentityManager = class IdentityManager2 {
875
863
  * Accept an existing identity. Expects it's device key to be authorized (now or later).
876
864
  */
877
865
  async acceptIdentity(params) {
878
- var _a;
879
866
  (0, import_log3.log)("accepting identity", {
880
867
  params
881
868
  }, {
@@ -911,7 +898,7 @@ var IdentityManager = class IdentityManager2 {
911
898
  await this._identity.ready();
912
899
  import_log3.log.trace("dxos.halo.identity", {
913
900
  identityKey: identityRecord.identityKey,
914
- displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
901
+ displayName: this._identity.profileDocument?.displayName
915
902
  }, {
916
903
  F: __dxlog_file3,
917
904
  L: 186,
@@ -930,10 +917,42 @@ var IdentityManager = class IdentityManager2 {
930
917
  });
931
918
  return identity;
932
919
  }
920
+ /**
921
+ * Update the profile document of an existing identity.
922
+ */
923
+ async updateProfile(profile) {
924
+ (0, import_invariant2.invariant)(this._identity, "Identity not initialized.", {
925
+ F: __dxlog_file3,
926
+ L: 200,
927
+ S: this,
928
+ A: [
929
+ "this._identity",
930
+ "'Identity not initialized.'"
931
+ ]
932
+ });
933
+ const credential = await this._identity.getIdentityCredentialSigner().createCredential({
934
+ subject: this._identity.identityKey,
935
+ assertion: {
936
+ "@type": "dxos.halo.credentials.IdentityProfile",
937
+ profile
938
+ }
939
+ });
940
+ const receipt = await this._identity.controlPipeline.writer.write({
941
+ credential: {
942
+ credential
943
+ }
944
+ });
945
+ await this._identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
946
+ [
947
+ receipt.feedKey,
948
+ receipt.seq
949
+ ]
950
+ ]));
951
+ }
933
952
  async _constructIdentity(identityRecord) {
934
953
  (0, import_invariant2.invariant)(!this._identity, void 0, {
935
954
  F: __dxlog_file3,
936
- L: 197,
955
+ L: 214,
937
956
  S: this,
938
957
  A: [
939
958
  "!this._identity",
@@ -944,13 +963,13 @@ var IdentityManager = class IdentityManager2 {
944
963
  identityRecord
945
964
  }, {
946
965
  F: __dxlog_file3,
947
- L: 198,
966
+ L: 215,
948
967
  S: this,
949
968
  C: (f, a) => f(...a)
950
969
  });
951
970
  (0, import_invariant2.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
952
971
  F: __dxlog_file3,
953
- L: 201,
972
+ L: 218,
954
973
  S: this,
955
974
  A: [
956
975
  "identityRecord.haloSpace.controlFeedKey",
@@ -962,7 +981,7 @@ var IdentityManager = class IdentityManager2 {
962
981
  });
963
982
  (0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
964
983
  F: __dxlog_file3,
965
- L: 205,
984
+ L: 222,
966
985
  S: this,
967
986
  A: [
968
987
  "identityRecord.haloSpace.dataFeedKey",
@@ -994,7 +1013,7 @@ var IdentityManager = class IdentityManager2 {
994
1013
  identityKey: identityRecord.identityKey
995
1014
  }, {
996
1015
  F: __dxlog_file3,
997
- L: 229,
1016
+ L: 246,
998
1017
  S: this,
999
1018
  C: (f, a) => f(...a)
1000
1019
  });
@@ -1015,7 +1034,7 @@ var IdentityManager = class IdentityManager2 {
1015
1034
  onAuthFailure: () => {
1016
1035
  import_log3.log.warn("auth failure", void 0, {
1017
1036
  F: __dxlog_file3,
1018
- L: 248,
1037
+ L: 265,
1019
1038
  S: this,
1020
1039
  C: (f, a) => f(...a)
1021
1040
  });
@@ -1038,12 +1057,13 @@ var import_debug2 = require("@dxos/debug");
1038
1057
  var import_invariant3 = require("@dxos/invariant");
1039
1058
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1040
1059
  var IdentityServiceImpl = class {
1041
- // TODO(wittjosiah): Remove dependency on service context.
1042
- constructor(_serviceContext) {
1043
- this._serviceContext = _serviceContext;
1060
+ constructor(_createIdentity, _identityManager, _keyring) {
1061
+ this._createIdentity = _createIdentity;
1062
+ this._identityManager = _identityManager;
1063
+ this._keyring = _keyring;
1044
1064
  }
1045
1065
  async createIdentity(request) {
1046
- await this._serviceContext.createIdentity(request);
1066
+ await this._createIdentity(request);
1047
1067
  return this._getIdentity();
1048
1068
  }
1049
1069
  async recoverIdentity(request) {
@@ -1055,34 +1075,47 @@ var IdentityServiceImpl = class {
1055
1075
  identity: this._getIdentity()
1056
1076
  });
1057
1077
  emitNext();
1058
- return this._serviceContext.identityManager.stateUpdate.on(emitNext);
1078
+ return this._identityManager.stateUpdate.on(emitNext);
1059
1079
  });
1060
1080
  }
1061
1081
  _getIdentity() {
1062
- if (!this._serviceContext.identityManager.identity) {
1082
+ if (!this._identityManager.identity) {
1063
1083
  return void 0;
1064
1084
  }
1065
1085
  return {
1066
- identityKey: this._serviceContext.identityManager.identity.identityKey,
1067
- spaceKey: this._serviceContext.identityManager.identity.space.key,
1068
- profile: this._serviceContext.identityManager.identity.profileDocument
1086
+ identityKey: this._identityManager.identity.identityKey,
1087
+ spaceKey: this._identityManager.identity.space.key,
1088
+ profile: this._identityManager.identity.profileDocument
1069
1089
  };
1070
1090
  }
1091
+ async updateProfile(profile) {
1092
+ (0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
1093
+ F: __dxlog_file4,
1094
+ L: 59,
1095
+ S: this,
1096
+ A: [
1097
+ "this._identityManager.identity",
1098
+ "'Identity not initialized.'"
1099
+ ]
1100
+ });
1101
+ await this._identityManager.updateProfile(profile);
1102
+ return this._getIdentity();
1103
+ }
1071
1104
  async signPresentation({ presentation, nonce }) {
1072
- (0, import_invariant3.invariant)(this._serviceContext.identityManager.identity, "Identity not initialized.", {
1105
+ (0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
1073
1106
  F: __dxlog_file4,
1074
- L: 56,
1107
+ L: 65,
1075
1108
  S: this,
1076
1109
  A: [
1077
- "this._serviceContext.identityManager.identity",
1110
+ "this._identityManager.identity",
1078
1111
  "'Identity not initialized.'"
1079
1112
  ]
1080
1113
  });
1081
1114
  return await (0, import_credentials6.signPresentation)({
1082
1115
  presentation,
1083
- signer: this._serviceContext.keyring,
1084
- signerKey: this._serviceContext.identityManager.identity.deviceKey,
1085
- chain: this._serviceContext.identityManager.identity.deviceCredentialChain,
1116
+ signer: this._keyring,
1117
+ signerKey: this._identityManager.identity.deviceKey,
1118
+ chain: this._identityManager.identity.deviceCredentialChain,
1086
1119
  nonce
1087
1120
  });
1088
1121
  }
@@ -1418,7 +1451,6 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1418
1451
  };
1419
1452
  }
1420
1453
  async onOpen(context) {
1421
- var _a;
1422
1454
  await super.onOpen(context);
1423
1455
  try {
1424
1456
  await this.rpc.InvitationHostService.options({
@@ -1427,7 +1459,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1427
1459
  await (0, import_context4.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1428
1460
  timeout: OPTIONS_TIMEOUT
1429
1461
  }));
1430
- if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.GUEST) {
1462
+ if (this._remoteOptions?.role !== import_invitations.Options.Role.GUEST) {
1431
1463
  throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
1432
1464
  expected: import_invitations.Options.Role.GUEST,
1433
1465
  remoteOptions: this._remoteOptions
@@ -1485,7 +1517,6 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1485
1517
  };
1486
1518
  }
1487
1519
  async onOpen(context) {
1488
- var _a;
1489
1520
  await super.onOpen(context);
1490
1521
  try {
1491
1522
  (0, import_log4.log)("begin options", void 0, {
@@ -1506,7 +1537,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1506
1537
  S: this,
1507
1538
  C: (f, a) => f(...a)
1508
1539
  });
1509
- if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.HOST) {
1540
+ if (this._remoteOptions?.role !== import_invitations.Options.Role.HOST) {
1510
1541
  throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
1511
1542
  expected: import_invitations.Options.Role.HOST,
1512
1543
  remoteOptions: this._remoteOptions
@@ -1545,9 +1576,8 @@ var InvitationsHandler = class {
1545
1576
  this._networkManager = _networkManager;
1546
1577
  }
1547
1578
  createInvitation(protocol, options) {
1548
- var _a;
1549
- const { invitationId = import_keys6.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys6.PublicKey.random() } = options != null ? options : {};
1550
- const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1579
+ const { invitationId = import_keys6.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys6.PublicKey.random() } = options ?? {};
1580
+ const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
1551
1581
  (0, import_invariant6.invariant)(protocol, void 0, {
1552
1582
  F: __dxlog_file7,
1553
1583
  L: 76,
@@ -1600,9 +1630,8 @@ var InvitationsHandler = class {
1600
1630
  return invitation;
1601
1631
  },
1602
1632
  admit: async (admissionRequest) => {
1603
- var _a2, _b, _c;
1604
1633
  try {
1605
- const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
1634
+ const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
1606
1635
  (0, import_invariant6.invariant)(deviceKey, void 0, {
1607
1636
  F: __dxlog_file7,
1608
1637
  L: 119,
@@ -1747,7 +1776,8 @@ var InvitationsHandler = class {
1747
1776
  protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
1748
1777
  teleport.addExtension("dxos.halo.invitations", createExtension());
1749
1778
  }),
1750
- topology: new import_network_manager.StarTopology(topic)
1779
+ topology: new import_network_manager.StarTopology(topic),
1780
+ label: "invitation host"
1751
1781
  });
1752
1782
  ctx.onDispose(() => swarmConnection.close());
1753
1783
  stream.next({
@@ -1772,7 +1802,7 @@ var InvitationsHandler = class {
1772
1802
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
1773
1803
  (0, import_invariant6.invariant)(protocol, void 0, {
1774
1804
  F: __dxlog_file7,
1775
- L: 210,
1805
+ L: 211,
1776
1806
  S: this,
1777
1807
  A: [
1778
1808
  "protocol",
@@ -1786,7 +1816,7 @@ var InvitationsHandler = class {
1786
1816
  const setState = (newData) => {
1787
1817
  (0, import_invariant6.invariant)(newData.state !== void 0, void 0, {
1788
1818
  F: __dxlog_file7,
1789
- L: 221,
1819
+ L: 222,
1790
1820
  S: this,
1791
1821
  A: [
1792
1822
  "newData.state !== undefined",
@@ -1806,7 +1836,7 @@ var InvitationsHandler = class {
1806
1836
  ...protocol.toJSON()
1807
1837
  }, {
1808
1838
  F: __dxlog_file7,
1809
- L: 229,
1839
+ L: 230,
1810
1840
  S: this,
1811
1841
  C: (f, a) => f(...a)
1812
1842
  });
@@ -1816,7 +1846,7 @@ var InvitationsHandler = class {
1816
1846
  } else {
1817
1847
  import_log5.log.warn("auth failed", err, {
1818
1848
  F: __dxlog_file7,
1819
- L: 232,
1849
+ L: 233,
1820
1850
  S: this,
1821
1851
  C: (f, a) => f(...a)
1822
1852
  });
@@ -1830,7 +1860,7 @@ var InvitationsHandler = class {
1830
1860
  ...protocol.toJSON()
1831
1861
  }, {
1832
1862
  F: __dxlog_file7,
1833
- L: 240,
1863
+ L: 241,
1834
1864
  S: this,
1835
1865
  C: (f, a) => f(...a)
1836
1866
  });
@@ -1845,7 +1875,7 @@ var InvitationsHandler = class {
1845
1875
  currentState
1846
1876
  }, {
1847
1877
  F: __dxlog_file7,
1848
- L: 250,
1878
+ L: 251,
1849
1879
  S: this,
1850
1880
  C: (f, a) => f(...a)
1851
1881
  });
@@ -1860,7 +1890,7 @@ var InvitationsHandler = class {
1860
1890
  id: traceId
1861
1891
  }), {
1862
1892
  F: __dxlog_file7,
1863
- L: 259,
1893
+ L: 260,
1864
1894
  S: this,
1865
1895
  C: (f, a) => f(...a)
1866
1896
  });
@@ -1872,7 +1902,7 @@ var InvitationsHandler = class {
1872
1902
  ...protocol.toJSON()
1873
1903
  }, {
1874
1904
  F: __dxlog_file7,
1875
- L: 267,
1905
+ L: 268,
1876
1906
  S: this,
1877
1907
  C: (f, a) => f(...a)
1878
1908
  });
@@ -1883,7 +1913,7 @@ var InvitationsHandler = class {
1883
1913
  ...protocol.toJSON()
1884
1914
  }, {
1885
1915
  F: __dxlog_file7,
1886
- L: 271,
1916
+ L: 272,
1887
1917
  S: this,
1888
1918
  C: (f, a) => f(...a)
1889
1919
  });
@@ -1893,7 +1923,7 @@ var InvitationsHandler = class {
1893
1923
  response: introductionResponse
1894
1924
  }, {
1895
1925
  F: __dxlog_file7,
1896
- L: 275,
1926
+ L: 276,
1897
1927
  S: this,
1898
1928
  C: (f, a) => f(...a)
1899
1929
  });
@@ -1905,7 +1935,7 @@ var InvitationsHandler = class {
1905
1935
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1906
1936
  (0, import_log5.log)("guest waiting for authentication code...", void 0, {
1907
1937
  F: __dxlog_file7,
1908
- L: 284,
1938
+ L: 285,
1909
1939
  S: this,
1910
1940
  C: (f, a) => f(...a)
1911
1941
  });
@@ -1917,7 +1947,7 @@ var InvitationsHandler = class {
1917
1947
  });
1918
1948
  (0, import_log5.log)("sending authentication request", void 0, {
1919
1949
  F: __dxlog_file7,
1920
- L: 288,
1950
+ L: 289,
1921
1951
  S: this,
1922
1952
  C: (f, a) => f(...a)
1923
1953
  });
@@ -1938,7 +1968,7 @@ var InvitationsHandler = class {
1938
1968
  attempt
1939
1969
  }, {
1940
1970
  F: __dxlog_file7,
1941
- L: 299,
1971
+ L: 300,
1942
1972
  S: this,
1943
1973
  C: (f, a) => f(...a)
1944
1974
  });
@@ -1955,7 +1985,7 @@ var InvitationsHandler = class {
1955
1985
  ...protocol.toJSON()
1956
1986
  }, {
1957
1987
  F: __dxlog_file7,
1958
- L: 310,
1988
+ L: 311,
1959
1989
  S: this,
1960
1990
  C: (f, a) => f(...a)
1961
1991
  });
@@ -1967,7 +1997,7 @@ var InvitationsHandler = class {
1967
1997
  ...protocol.toJSON()
1968
1998
  }, {
1969
1999
  F: __dxlog_file7,
1970
- L: 321,
2000
+ L: 322,
1971
2001
  S: this,
1972
2002
  C: (f, a) => f(...a)
1973
2003
  });
@@ -1979,7 +2009,7 @@ var InvitationsHandler = class {
1979
2009
  id: traceId
1980
2010
  }), {
1981
2011
  F: __dxlog_file7,
1982
- L: 323,
2012
+ L: 324,
1983
2013
  S: this,
1984
2014
  C: (f, a) => f(...a)
1985
2015
  });
@@ -1989,7 +2019,7 @@ var InvitationsHandler = class {
1989
2019
  ...protocol.toJSON()
1990
2020
  }, {
1991
2021
  F: __dxlog_file7,
1992
- L: 326,
2022
+ L: 327,
1993
2023
  S: this,
1994
2024
  C: (f, a) => f(...a)
1995
2025
  });
@@ -1999,7 +2029,7 @@ var InvitationsHandler = class {
1999
2029
  } else {
2000
2030
  (0, import_log5.log)("auth failed", err, {
2001
2031
  F: __dxlog_file7,
2002
- L: 329,
2032
+ L: 330,
2003
2033
  S: this,
2004
2034
  C: (f, a) => f(...a)
2005
2035
  });
@@ -2010,7 +2040,7 @@ var InvitationsHandler = class {
2010
2040
  error: err
2011
2041
  }), {
2012
2042
  F: __dxlog_file7,
2013
- L: 332,
2043
+ L: 333,
2014
2044
  S: this,
2015
2045
  C: (f, a) => f(...a)
2016
2046
  });
@@ -2028,7 +2058,7 @@ var InvitationsHandler = class {
2028
2058
  ...protocol.toJSON()
2029
2059
  }, {
2030
2060
  F: __dxlog_file7,
2031
- L: 343,
2061
+ L: 344,
2032
2062
  S: this,
2033
2063
  C: (f, a) => f(...a)
2034
2064
  });
@@ -2038,7 +2068,7 @@ var InvitationsHandler = class {
2038
2068
  } else {
2039
2069
  (0, import_log5.log)("auth failed", err, {
2040
2070
  F: __dxlog_file7,
2041
- L: 346,
2071
+ L: 347,
2042
2072
  S: this,
2043
2073
  C: (f, a) => f(...a)
2044
2074
  });
@@ -2051,7 +2081,7 @@ var InvitationsHandler = class {
2051
2081
  (0, import_async8.scheduleTask)(ctx, async () => {
2052
2082
  (0, import_invariant6.invariant)(invitation.swarmKey, void 0, {
2053
2083
  F: __dxlog_file7,
2054
- L: 356,
2084
+ L: 357,
2055
2085
  S: this,
2056
2086
  A: [
2057
2087
  "invitation.swarmKey",
@@ -2065,7 +2095,8 @@ var InvitationsHandler = class {
2065
2095
  protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
2066
2096
  teleport.addExtension("dxos.halo.invitations", createExtension());
2067
2097
  }),
2068
- topology: new import_network_manager.StarTopology(topic)
2098
+ topology: new import_network_manager.StarTopology(topic),
2099
+ label: "invitation guest"
2069
2100
  });
2070
2101
  ctx.onDispose(() => swarmConnection.close());
2071
2102
  setState({
@@ -2301,7 +2332,6 @@ var SpaceInvitationProtocol = class {
2301
2332
  };
2302
2333
  }
2303
2334
  async admit(request, guestProfile) {
2304
- var _a;
2305
2335
  (0, import_invariant8.invariant)(this._spaceKey, void 0, {
2306
2336
  F: __dxlog_file9,
2307
2337
  L: 42,
@@ -2365,7 +2395,7 @@ var SpaceInvitationProtocol = class {
2365
2395
  space: {
2366
2396
  credential: spaceMemberCredential,
2367
2397
  controlTimeframe: space.inner.controlPipeline.state.timeframe,
2368
- dataTimeframe: (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.timeframe
2398
+ dataTimeframe: space.dataPipeline.pipelineState?.timeframe
2369
2399
  }
2370
2400
  };
2371
2401
  }
@@ -2469,9 +2499,8 @@ var ClientRpcServer = class {
2469
2499
  await this._rpcPeer.close();
2470
2500
  }
2471
2501
  _getServiceHandler(serviceName) {
2472
- var _a;
2473
2502
  if (!this._handlerCache.has(serviceName)) {
2474
- const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : (0, import_debug3.raise)(new Error(`Service not available: ${serviceName}`));
2503
+ const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug3.raise)(new Error(`Service not available: ${serviceName}`));
2475
2504
  const service = this._serviceRegistry.services[key];
2476
2505
  if (!service) {
2477
2506
  throw new Error(`Service not available: ${serviceName}`);
@@ -2486,13 +2515,14 @@ var ClientRpcServer = class {
2486
2515
  var import_codec_protobuf10 = require("@dxos/codec-protobuf");
2487
2516
  var import_credentials9 = require("@dxos/credentials");
2488
2517
  var import_document_model = require("@dxos/document-model");
2518
+ var import_echo_db = require("@dxos/echo-db");
2489
2519
  var import_invariant9 = require("@dxos/invariant");
2490
2520
  var import_log8 = require("@dxos/log");
2491
2521
  var import_protocols5 = require("@dxos/protocols");
2492
2522
  var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2493
2523
 
2494
2524
  // packages/sdk/client-services/src/version.ts
2495
- var DXOS_VERSION = "0.1.56-main.c19b7cd";
2525
+ var DXOS_VERSION = "0.1.56-main.c277f68";
2496
2526
 
2497
2527
  // packages/sdk/client-services/src/packlets/services/platform.ts
2498
2528
  var getPlatform = () => {
@@ -2526,9 +2556,8 @@ var getPlatform = () => {
2526
2556
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2527
2557
  var DEFAULT_TIMEOUT = 1e3;
2528
2558
  var createDiagnostics = async (clientServices, serviceContext, config) => {
2529
- var _a, _b, _c;
2530
2559
  const diagnostics = {
2531
- created: new Date().toISOString(),
2560
+ created: (/* @__PURE__ */ new Date()).toISOString(),
2532
2561
  platform: getPlatform(),
2533
2562
  client: {
2534
2563
  version: DXOS_VERSION,
@@ -2540,7 +2569,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
2540
2569
  {
2541
2570
  (0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
2542
2571
  F: __dxlog_file10,
2543
- L: 87,
2572
+ L: 88,
2544
2573
  S: void 0,
2545
2574
  A: [
2546
2575
  "clientServices.LoggingService",
@@ -2558,16 +2587,16 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
2558
2587
  spaceKey: identity.space.key,
2559
2588
  profile: identity.profileDocument
2560
2589
  };
2561
- const { devices } = (_a = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
2590
+ const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
2562
2591
  timeout: DEFAULT_TIMEOUT
2563
- }).catch(() => void 0)) != null ? _a : {};
2592
+ }).catch(() => void 0) ?? {};
2564
2593
  diagnostics.devices = devices;
2565
2594
  if (serviceContext.dataSpaceManager) {
2566
- diagnostics.spaces = await Promise.all((_b = Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space))) != null ? _b : []);
2595
+ diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
2567
2596
  }
2568
- const { feeds = [] } = (_c = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2597
+ const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2569
2598
  timeout: DEFAULT_TIMEOUT
2570
- }).catch(() => void 0)) != null ? _c : {};
2599
+ }).catch(() => void 0) ?? {};
2571
2600
  diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
2572
2601
  feedKey,
2573
2602
  bytes,
@@ -2580,16 +2609,13 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
2580
2609
  var getProperties = (space) => {
2581
2610
  let properties = {};
2582
2611
  try {
2583
- const propertiesItem = space.dataPipeline.itemManager.items.find((item) => {
2584
- var _a, _b;
2585
- return ((_a = item.modelMeta) == null ? void 0 : _a.type) === import_document_model.DocumentModel.meta.type && ((_b = item.state) == null ? void 0 : _b.type) === "dxos.sdk.client.Properties";
2586
- });
2587
- const state = propertiesItem == null ? void 0 : propertiesItem.state;
2588
- properties = state == null ? void 0 : state.data;
2612
+ const propertiesItem = space.dataPipeline.itemManager.items.find((item) => item.modelMeta?.type === import_document_model.DocumentModel.meta.type && item.state?.type === import_echo_db.TYPE_PROPERTIES);
2613
+ const state = propertiesItem?.state;
2614
+ properties = state?.data;
2589
2615
  } catch (err) {
2590
2616
  import_log8.log.warn(err.message, void 0, {
2591
2617
  F: __dxlog_file10,
2592
- L: 144,
2618
+ L: 145,
2593
2619
  S: void 0,
2594
2620
  C: (f, a) => f(...a)
2595
2621
  });
@@ -2597,7 +2623,6 @@ var getProperties = (space) => {
2597
2623
  return properties;
2598
2624
  };
2599
2625
  var getSpaceStats = async (space) => {
2600
- var _a, _b, _c, _d, _e, _f;
2601
2626
  const stats = {
2602
2627
  key: space.key,
2603
2628
  metrics: space.metrics,
@@ -2605,18 +2630,15 @@ var getSpaceStats = async (space) => {
2605
2630
  ...credential.subject.assertion,
2606
2631
  id: credential.id
2607
2632
  })),
2608
- members: Array.from(space.inner.spaceState.members.values()).map((member) => {
2609
- var _a2;
2610
- return {
2611
- identity: {
2612
- identityKey: member.key,
2613
- profile: {
2614
- displayName: (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName
2615
- }
2616
- },
2617
- presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services6.SpaceMember.PresenceState.ONLINE : import_services6.SpaceMember.PresenceState.OFFLINE
2618
- };
2619
- }),
2633
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
2634
+ identity: {
2635
+ identityKey: member.key,
2636
+ profile: {
2637
+ displayName: member.assertion.profile?.displayName
2638
+ }
2639
+ },
2640
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services6.SpaceMember.PresenceState.ONLINE : import_services6.SpaceMember.PresenceState.OFFLINE
2641
+ })),
2620
2642
  pipeline: {
2621
2643
  // TODO(burdon): Pick properties from credentials if needed.
2622
2644
  // currentEpoch: space.dataPipeline.currentEpoch,
@@ -2626,11 +2648,11 @@ var getSpaceStats = async (space) => {
2626
2648
  targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
2627
2649
  totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
2628
2650
  // TODO(burdon): Empty?
2629
- dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
2630
- startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
2631
- currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
2632
- targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
2633
- totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
2651
+ dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
2652
+ startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
2653
+ currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
2654
+ targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
2655
+ totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
2634
2656
  }
2635
2657
  };
2636
2658
  if (space.dataPipeline.itemManager) {
@@ -2663,6 +2685,7 @@ var import_protocols9 = require("@dxos/protocols");
2663
2685
  var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
2664
2686
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
2665
2687
  var import_tracing3 = require("@dxos/tracing");
2688
+ var import_util7 = require("@dxos/util");
2666
2689
 
2667
2690
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2668
2691
  var import_async12 = require("@dxos/async");
@@ -2687,7 +2710,7 @@ var import_keys8 = require("@dxos/keys");
2687
2710
  var import_log10 = require("@dxos/log");
2688
2711
  var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2689
2712
  var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
2690
- var import_timeframe = require("@dxos/timeframe");
2713
+ var import_timeframe2 = require("@dxos/timeframe");
2691
2714
  var import_util4 = require("@dxos/util");
2692
2715
 
2693
2716
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
@@ -2756,7 +2779,7 @@ var NotarizationPlugin = class {
2756
2779
  errors.throw(err);
2757
2780
  }
2758
2781
  });
2759
- opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
2782
+ opCtx?.onDispose(() => ctx.dispose());
2760
2783
  if (timeout !== 0) {
2761
2784
  (0, import_async10.scheduleTask)(ctx, () => {
2762
2785
  import_log9.log.warn("Notarization timeout", {
@@ -2849,11 +2872,10 @@ var NotarizationPlugin = class {
2849
2872
  * Called with credentials arriving from the control pipeline.
2850
2873
  */
2851
2874
  async processCredential(credential) {
2852
- var _a;
2853
2875
  if (!credential.id) {
2854
2876
  return;
2855
2877
  }
2856
- (_a = this._processCredentialsTriggers.get(credential.id)) == null ? void 0 : _a.wake();
2878
+ this._processCredentialsTriggers.get(credential.id)?.wake();
2857
2879
  this._processedCredentials.add(credential.id);
2858
2880
  this._processCredentialsTriggers.delete(credential.id);
2859
2881
  }
@@ -2879,11 +2901,10 @@ var NotarizationPlugin = class {
2879
2901
  * Requests from other peers to notarize credentials.
2880
2902
  */
2881
2903
  async _onNotarize(request) {
2882
- var _a;
2883
2904
  if (!this._writer) {
2884
2905
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2885
2906
  }
2886
- for (const credential of (_a = request.credentials) != null ? _a : []) {
2907
+ for (const credential of request.credentials ?? []) {
2887
2908
  (0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
2888
2909
  F: __dxlog_file11,
2889
2910
  L: 200,
@@ -2984,7 +3005,6 @@ var DataSpace = class DataSpace2 {
2984
3005
  this.error = void 0;
2985
3006
  this.stateUpdate = new import_async11.Event();
2986
3007
  this.metrics = {};
2987
- var _a;
2988
3008
  this._inner = params.inner;
2989
3009
  this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
2990
3010
  this._gossip = params.gossip;
@@ -2993,7 +3013,7 @@ var DataSpace = class DataSpace2 {
2993
3013
  this._feedStore = params.feedStore;
2994
3014
  this._metadataStore = params.metadataStore;
2995
3015
  this._signingContext = params.signingContext;
2996
- this._callbacks = (_a = params.callbacks) != null ? _a : {};
3016
+ this._callbacks = params.callbacks ?? {};
2997
3017
  this.authVerifier = new TrustedKeySetAuthVerifier({
2998
3018
  trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
2999
3019
  update: this._inner.stateUpdate,
@@ -3037,14 +3057,13 @@ var DataSpace = class DataSpace2 {
3037
3057
  this._state = import_services7.SpaceState.CONTROL_ONLY;
3038
3058
  this.stateUpdate.emit();
3039
3059
  this.metrics = {};
3040
- this.metrics.open = new Date();
3060
+ this.metrics.open = /* @__PURE__ */ new Date();
3041
3061
  }
3042
3062
  async close() {
3043
3063
  await this._close();
3044
3064
  }
3045
3065
  async _close() {
3046
- var _a, _b;
3047
- await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
3066
+ await this._callbacks.beforeClose?.();
3048
3067
  this._state = import_services7.SpaceState.CLOSED;
3049
3068
  await this._ctx.dispose();
3050
3069
  this._ctx = new import_context7.Context();
@@ -3066,7 +3085,7 @@ var DataSpace = class DataSpace2 {
3066
3085
  initializeDataPipelineAsync() {
3067
3086
  (0, import_async11.scheduleTask)(this._ctx, async () => {
3068
3087
  try {
3069
- this.metrics.pipelineInitBegin = new Date();
3088
+ this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
3070
3089
  await this.initializeDataPipeline();
3071
3090
  } catch (err) {
3072
3091
  if (err instanceof import_errors3.CancelledError) {
@@ -3088,12 +3107,11 @@ var DataSpace = class DataSpace2 {
3088
3107
  this.error = err;
3089
3108
  this.stateUpdate.emit();
3090
3109
  } finally {
3091
- this.metrics.ready = new Date();
3110
+ this.metrics.ready = /* @__PURE__ */ new Date();
3092
3111
  }
3093
3112
  });
3094
3113
  }
3095
3114
  async initializeDataPipeline() {
3096
- var _a, _b, _c, _d;
3097
3115
  if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
3098
3116
  throw new import_errors3.SystemError("Invalid operation");
3099
3117
  }
@@ -3102,7 +3120,7 @@ var DataSpace = class DataSpace2 {
3102
3120
  ctx: this._ctx,
3103
3121
  breakOnStall: false
3104
3122
  });
3105
- this.metrics.controlPipelineReady = new Date();
3123
+ this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
3106
3124
  await this._createWritableFeeds();
3107
3125
  (0, import_log10.log)("writable feeds created", void 0, {
3108
3126
  F: __dxlog_file12,
@@ -3119,7 +3137,7 @@ var DataSpace = class DataSpace2 {
3119
3137
  }), this._inner.controlPipeline.writer));
3120
3138
  }
3121
3139
  await this._inner.initializeDataPipeline();
3122
- this.metrics.dataPipelineOpen = new Date();
3140
+ this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
3123
3141
  await (0, import_context7.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
3124
3142
  (0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
3125
3143
  F: __dxlog_file12,
@@ -3131,17 +3149,17 @@ var DataSpace = class DataSpace2 {
3131
3149
  ctx: this._ctx,
3132
3150
  breakOnStall: false
3133
3151
  });
3134
- this.metrics.dataPipelineReady = new Date();
3152
+ this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
3135
3153
  (0, import_log10.log)("data pipeline ready", void 0, {
3136
3154
  F: __dxlog_file12,
3137
3155
  L: 257,
3138
3156
  S: this,
3139
3157
  C: (f, a) => f(...a)
3140
3158
  });
3141
- await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
3159
+ await this._callbacks.beforeReady?.();
3142
3160
  this._state = import_services7.SpaceState.READY;
3143
3161
  this.stateUpdate.emit();
3144
- await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
3162
+ await this._callbacks.afterReady?.();
3145
3163
  }
3146
3164
  async _createWritableFeeds() {
3147
3165
  const credentials = [];
@@ -3188,7 +3206,6 @@ var DataSpace = class DataSpace2 {
3188
3206
  await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
3189
3207
  }
3190
3208
  async createEpoch() {
3191
- var _a, _b;
3192
3209
  const epoch = await this.dataPipeline.createEpoch();
3193
3210
  const receipt = await this.inner.controlPipeline.writer.write({
3194
3211
  credential: {
@@ -3201,14 +3218,14 @@ var DataSpace = class DataSpace2 {
3201
3218
  })
3202
3219
  }
3203
3220
  });
3204
- await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
3221
+ await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
3205
3222
  [
3206
3223
  receipt.feedKey,
3207
3224
  receipt.seq
3208
3225
  ]
3209
3226
  ]));
3210
3227
  if (ENABLE_FEED_PURGE) {
3211
- for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
3228
+ for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
3212
3229
  const indexBeforeEpoch = epoch.timeframe.get(feed.key);
3213
3230
  if (indexBeforeEpoch === void 0) {
3214
3231
  continue;
@@ -3258,9 +3275,8 @@ DataSpace = _ts_decorate3([
3258
3275
  var import_credentials11 = require("@dxos/credentials");
3259
3276
  var import_debug5 = require("@dxos/debug");
3260
3277
  var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
3261
- var import_timeframe2 = require("@dxos/timeframe");
3278
+ var import_timeframe3 = require("@dxos/timeframe");
3262
3279
  var spaceGenesis = async (keyring, signingContext, space) => {
3263
- var _a, _b, _c, _d;
3264
3280
  const credentials = [
3265
3281
  await (0, import_credentials11.createCredential)({
3266
3282
  signer: keyring,
@@ -3280,11 +3296,11 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3280
3296
  spaceKey: space.key,
3281
3297
  role: import_credentials12.SpaceMember.Role.ADMIN,
3282
3298
  profile: signingContext.profile,
3283
- genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0, import_debug5.failUndefined)()
3299
+ genesisFeedKey: space.controlFeedKey ?? (0, import_debug5.failUndefined)()
3284
3300
  }
3285
3301
  }),
3286
3302
  await signingContext.credentialSigner.createCredential({
3287
- subject: (_b = space.controlFeedKey) != null ? _b : (0, import_debug5.failUndefined)(),
3303
+ subject: space.controlFeedKey ?? (0, import_debug5.failUndefined)(),
3288
3304
  assertion: {
3289
3305
  "@type": "dxos.halo.credentials.AdmittedFeed",
3290
3306
  spaceKey: space.key,
@@ -3294,7 +3310,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3294
3310
  }
3295
3311
  }),
3296
3312
  await signingContext.credentialSigner.createCredential({
3297
- subject: (_c = space.dataFeedKey) != null ? _c : (0, import_debug5.failUndefined)(),
3313
+ subject: space.dataFeedKey ?? (0, import_debug5.failUndefined)(),
3298
3314
  assertion: {
3299
3315
  "@type": "dxos.halo.credentials.AdmittedFeed",
3300
3316
  spaceKey: space.key,
@@ -3304,12 +3320,12 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3304
3320
  }
3305
3321
  }),
3306
3322
  await signingContext.credentialSigner.createCredential({
3307
- subject: (_d = space.key) != null ? _d : (0, import_debug5.failUndefined)(),
3323
+ subject: space.key ?? (0, import_debug5.failUndefined)(),
3308
3324
  assertion: {
3309
3325
  "@type": "dxos.halo.credentials.Epoch",
3310
3326
  number: 0,
3311
3327
  previousId: void 0,
3312
- timeframe: new import_timeframe2.Timeframe(),
3328
+ timeframe: new import_timeframe3.Timeframe(),
3313
3329
  snapshotCid: void 0
3314
3330
  }
3315
3331
  })
@@ -3569,7 +3585,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3569
3585
  onAuthFailure: () => {
3570
3586
  import_log11.log.warn("auth failure", void 0, {
3571
3587
  F: __dxlog_file13,
3572
- L: 213,
3588
+ L: 217,
3573
3589
  S: this,
3574
3590
  C: (f, a) => f(...a)
3575
3591
  });
@@ -3593,7 +3609,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3593
3609
  space: space.key
3594
3610
  }, {
3595
3611
  F: __dxlog_file13,
3596
- L: 231,
3612
+ L: 235,
3597
3613
  S: this,
3598
3614
  C: (f, a) => f(...a)
3599
3615
  });
@@ -3605,7 +3621,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3605
3621
  open: this._isOpen
3606
3622
  }, {
3607
3623
  F: __dxlog_file13,
3608
- L: 238,
3624
+ L: 242,
3609
3625
  S: this,
3610
3626
  C: (f, a) => f(...a)
3611
3627
  });
@@ -3618,7 +3634,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3618
3634
  space: space.key
3619
3635
  }, {
3620
3636
  F: __dxlog_file13,
3621
- L: 244,
3637
+ L: 248,
3622
3638
  S: this,
3623
3639
  C: (f, a) => f(...a)
3624
3640
  });
@@ -3683,9 +3699,8 @@ var SpacesServiceImpl = class {
3683
3699
  return this._serializeSpace(space);
3684
3700
  }
3685
3701
  async updateSpace({ spaceKey, state }) {
3686
- var _a;
3687
3702
  const dataSpaceManager = await this._getDataSpaceManager();
3688
- const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3703
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3689
3704
  if (state) {
3690
3705
  switch (state) {
3691
3706
  case import_services9.SpaceState.ACTIVE:
@@ -3716,7 +3731,7 @@ var SpacesServiceImpl = class {
3716
3731
  spaces
3717
3732
  });
3718
3733
  }, {
3719
- maxFrequency: 2
3734
+ maxFrequency: process.env.NODE_ENV === "test" ? void 0 : 2
3720
3735
  });
3721
3736
  (0, import_async13.scheduleTask)(ctx, async () => {
3722
3737
  const dataSpaceManager = await this._getDataSpaceManager();
@@ -3749,17 +3764,15 @@ var SpacesServiceImpl = class {
3749
3764
  });
3750
3765
  }
3751
3766
  async postMessage({ spaceKey, channel, message }) {
3752
- var _a;
3753
3767
  const dataSpaceManager = await this._getDataSpaceManager();
3754
- const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3768
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3755
3769
  await space.postMessage(getChannelId(channel), message);
3756
3770
  }
3757
3771
  subscribeMessages({ spaceKey, channel }) {
3758
3772
  return new import_codec_protobuf11.Stream(({ ctx, next }) => {
3759
3773
  (0, import_async13.scheduleTask)(ctx, async () => {
3760
- var _a;
3761
3774
  const dataSpaceManager = await this._getDataSpaceManager();
3762
- const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3775
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3763
3776
  const handle = space.listen(getChannelId(channel), (message) => {
3764
3777
  next(message);
3765
3778
  });
@@ -3769,8 +3782,7 @@ var SpacesServiceImpl = class {
3769
3782
  }
3770
3783
  queryCredentials({ spaceKey }) {
3771
3784
  return new import_codec_protobuf11.Stream(({ ctx, next }) => {
3772
- var _a;
3773
- const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3785
+ const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3774
3786
  const processor = {
3775
3787
  processCredential: async (credential) => {
3776
3788
  next(credential);
@@ -3781,9 +3793,8 @@ var SpacesServiceImpl = class {
3781
3793
  });
3782
3794
  }
3783
3795
  async writeCredentials({ spaceKey, credentials }) {
3784
- var _a;
3785
- const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3786
- for (const credential of credentials != null ? credentials : []) {
3796
+ const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3797
+ for (const credential of credentials ?? []) {
3787
3798
  await space.controlPipeline.writer.write({
3788
3799
  credential: {
3789
3800
  credential
@@ -3792,13 +3803,11 @@ var SpacesServiceImpl = class {
3792
3803
  }
3793
3804
  }
3794
3805
  async createEpoch({ spaceKey }) {
3795
- var _a;
3796
3806
  const dataSpaceManager = await this._getDataSpaceManager();
3797
- const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3807
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3798
3808
  await space.createEpoch();
3799
3809
  }
3800
3810
  _serializeSpace(space) {
3801
- var _a, _b, _c, _d, _e, _f, _g;
3802
3811
  return {
3803
3812
  spaceKey: space.key,
3804
3813
  state: space.state,
@@ -3810,16 +3819,15 @@ var SpacesServiceImpl = class {
3810
3819
  currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
3811
3820
  targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
3812
3821
  totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
3813
- dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
3814
- startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
3815
- currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
3816
- targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
3817
- totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
3822
+ dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
3823
+ startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
3824
+ currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
3825
+ targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
3826
+ totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
3818
3827
  },
3819
3828
  members: Array.from(space.inner.spaceState.members.values()).map((member) => {
3820
- var _a2, _b2, _c2;
3821
3829
  const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
3822
- const isMe = (_a2 = this._identityManager.identity) == null ? void 0 : _a2.identityKey.equals(member.key);
3830
+ const isMe = this._identityManager.identity?.identityKey.equals(member.key);
3823
3831
  if (isMe) {
3824
3832
  peers.push(space.presence.getLocalState());
3825
3833
  }
@@ -3827,14 +3835,14 @@ var SpacesServiceImpl = class {
3827
3835
  identity: {
3828
3836
  identityKey: member.key,
3829
3837
  profile: {
3830
- displayName: (_c2 = (_b2 = member.assertion.profile) == null ? void 0 : _b2.displayName) != null ? _c2 : (0, import_util6.humanize)(member.key)
3838
+ displayName: member.assertion.profile?.displayName ?? (0, import_util6.humanize)(member.key)
3831
3839
  }
3832
3840
  },
3833
3841
  presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
3834
3842
  peerStates: peers
3835
3843
  };
3836
3844
  }),
3837
- creator: (_g = space.inner.spaceState.creator) == null ? void 0 : _g.key,
3845
+ creator: space.inner.spaceState.creator?.key,
3838
3846
  cache: space.cache,
3839
3847
  metrics: space.metrics
3840
3848
  };
@@ -3874,7 +3882,8 @@ var ServiceContext = class ServiceContext2 {
3874
3882
  root: storage.createDirectory("feeds"),
3875
3883
  signer: this.keyring,
3876
3884
  hypercore: {
3877
- valueEncoding: import_echo_pipeline3.valueEncoding
3885
+ valueEncoding: import_echo_pipeline3.valueEncoding,
3886
+ stats: true
3878
3887
  }
3879
3888
  })
3880
3889
  });
@@ -3888,16 +3897,13 @@ var ServiceContext = class ServiceContext2 {
3888
3897
  });
3889
3898
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
3890
3899
  this.invitations = new InvitationsHandler(this.networkManager);
3891
- this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3892
- var _a;
3893
- return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
3894
- }, this._acceptIdentity.bind(this)));
3900
+ this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
3895
3901
  }
3896
3902
  async open(ctx) {
3897
3903
  await this._checkStorageVersion();
3898
3904
  (0, import_log13.log)("opening...", void 0, {
3899
3905
  F: __dxlog_file15,
3900
- L: 131,
3906
+ L: 135,
3901
3907
  S: this,
3902
3908
  C: (f, a) => f(...a)
3903
3909
  });
@@ -3905,7 +3911,7 @@ var ServiceContext = class ServiceContext2 {
3905
3911
  id: this._instanceId
3906
3912
  }), {
3907
3913
  F: __dxlog_file15,
3908
- L: 132,
3914
+ L: 136,
3909
3915
  S: this,
3910
3916
  C: (f, a) => f(...a)
3911
3917
  });
@@ -3920,29 +3926,28 @@ var ServiceContext = class ServiceContext2 {
3920
3926
  id: this._instanceId
3921
3927
  }), {
3922
3928
  F: __dxlog_file15,
3923
- L: 140,
3929
+ L: 144,
3924
3930
  S: this,
3925
3931
  C: (f, a) => f(...a)
3926
3932
  });
3927
3933
  (0, import_log13.log)("opened", void 0, {
3928
3934
  F: __dxlog_file15,
3929
- L: 141,
3935
+ L: 145,
3930
3936
  S: this,
3931
3937
  C: (f, a) => f(...a)
3932
3938
  });
3933
3939
  }
3934
3940
  async close() {
3935
- var _a;
3936
3941
  (0, import_log13.log)("closing...", void 0, {
3937
3942
  F: __dxlog_file15,
3938
- L: 145,
3943
+ L: 149,
3939
3944
  S: this,
3940
3945
  C: (f, a) => f(...a)
3941
3946
  });
3942
3947
  if (this._deviceSpaceSync && this.identityManager.identity) {
3943
3948
  await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
3944
3949
  }
3945
- await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
3950
+ await this.dataSpaceManager?.close();
3946
3951
  await this.identityManager.close();
3947
3952
  await this.spaceManager.close();
3948
3953
  await this.feedStore.close();
@@ -3951,7 +3956,7 @@ var ServiceContext = class ServiceContext2 {
3951
3956
  this.dataServiceSubscriptions.clear();
3952
3957
  (0, import_log13.log)("closed", void 0, {
3953
3958
  F: __dxlog_file15,
3954
- L: 156,
3959
+ L: 160,
3955
3960
  S: this,
3956
3961
  C: (f, a) => f(...a)
3957
3962
  });
@@ -3965,7 +3970,7 @@ var ServiceContext = class ServiceContext2 {
3965
3970
  const factory = this._handlerFactories.get(invitation.kind);
3966
3971
  (0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
3967
3972
  F: __dxlog_file15,
3968
- L: 168,
3973
+ L: 171,
3969
3974
  S: this,
3970
3975
  A: [
3971
3976
  "factory",
@@ -3987,14 +3992,13 @@ var ServiceContext = class ServiceContext2 {
3987
3992
  }
3988
3993
  // Called when identity is created.
3989
3994
  async _initialize(ctx) {
3990
- var _a;
3991
3995
  (0, import_log13.log)("initializing spaces...", void 0, {
3992
3996
  F: __dxlog_file15,
3993
- L: 190,
3997
+ L: 192,
3994
3998
  S: this,
3995
3999
  C: (f, a) => f(...a)
3996
4000
  });
3997
- const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
4001
+ const identity = this.identityManager.identity ?? (0, import_debug7.failUndefined)();
3998
4002
  const signingContext = {
3999
4003
  credentialSigner: identity.getIdentityCredentialSigner(),
4000
4004
  identityKey: identity.identityKey,
@@ -4013,7 +4017,7 @@ var ServiceContext = class ServiceContext2 {
4013
4017
  this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
4014
4018
  (0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4015
4019
  F: __dxlog_file15,
4016
- L: 213,
4020
+ L: 215,
4017
4021
  S: this,
4018
4022
  A: [
4019
4023
  "this.dataSpaceManager",
@@ -4037,7 +4041,7 @@ var ServiceContext = class ServiceContext2 {
4037
4041
  details: assertion
4038
4042
  }, {
4039
4043
  F: __dxlog_file15,
4040
- L: 229,
4044
+ L: 231,
4041
4045
  S: this,
4042
4046
  C: (f, a) => f(...a)
4043
4047
  });
@@ -4048,7 +4052,7 @@ var ServiceContext = class ServiceContext2 {
4048
4052
  details: assertion
4049
4053
  }, {
4050
4054
  F: __dxlog_file15,
4051
- L: 233,
4055
+ L: 235,
4052
4056
  S: this,
4053
4057
  C: (f, a) => f(...a)
4054
4058
  });
@@ -4059,7 +4063,7 @@ var ServiceContext = class ServiceContext2 {
4059
4063
  details: assertion
4060
4064
  }, {
4061
4065
  F: __dxlog_file15,
4062
- L: 238,
4066
+ L: 240,
4063
4067
  S: this,
4064
4068
  C: (f, a) => f(...a)
4065
4069
  });
@@ -4070,7 +4074,7 @@ var ServiceContext = class ServiceContext2 {
4070
4074
  } catch (err) {
4071
4075
  import_log13.log.catch(err, void 0, {
4072
4076
  F: __dxlog_file15,
4073
- L: 244,
4077
+ L: 246,
4074
4078
  S: this,
4075
4079
  C: (f, a) => f(...a)
4076
4080
  });
@@ -4087,6 +4091,7 @@ _ts_decorate5([
4087
4091
  import_tracing3.trace.span()
4088
4092
  ], ServiceContext.prototype, "_initialize", null);
4089
4093
  ServiceContext = _ts_decorate5([
4094
+ (0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
4090
4095
  import_tracing3.trace.resource()
4091
4096
  ], ServiceContext);
4092
4097
 
@@ -4121,21 +4126,17 @@ var DevicesServiceImpl = class {
4121
4126
  queryDevices() {
4122
4127
  return new import_codec_protobuf12.Stream(({ next }) => {
4123
4128
  const update = () => {
4124
- var _a;
4125
- const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
4129
+ const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
4126
4130
  if (!deviceKeys) {
4127
4131
  next({
4128
4132
  devices: []
4129
4133
  });
4130
4134
  } else {
4131
4135
  next({
4132
- devices: Array.from(deviceKeys.values()).map((key) => {
4133
- var _a2;
4134
- return {
4135
- deviceKey: key,
4136
- kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
4137
- };
4138
- })
4136
+ devices: Array.from(deviceKeys.values()).map((key) => ({
4137
+ deviceKey: key,
4138
+ kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
4139
+ }))
4139
4140
  });
4140
4141
  }
4141
4142
  };
@@ -4179,7 +4180,6 @@ var Lock = class {
4179
4180
  return this._lockPath;
4180
4181
  }
4181
4182
  async acquire() {
4182
- var _a;
4183
4183
  (0, import_log14.log)("acquiring lock...", void 0, {
4184
4184
  F: __dxlog_file16,
4185
4185
  L: 32,
@@ -4187,7 +4187,7 @@ var Lock = class {
4187
4187
  C: (f, a) => f(...a)
4188
4188
  });
4189
4189
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
4190
- await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
4190
+ await this._onAcquire?.();
4191
4191
  (0, import_log14.log)("acquired lock", void 0, {
4192
4192
  F: __dxlog_file16,
4193
4193
  L: 37,
@@ -4196,8 +4196,7 @@ var Lock = class {
4196
4196
  });
4197
4197
  }
4198
4198
  async release() {
4199
- var _a;
4200
- await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
4199
+ await this._onRelease?.();
4201
4200
  (0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
4202
4201
  F: __dxlog_file16,
4203
4202
  L: 42,
@@ -4220,11 +4219,11 @@ var import_async16 = require("@dxos/async");
4220
4219
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
4221
4220
  var import_log15 = require("@dxos/log");
4222
4221
  var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
4223
- var import_util7 = require("@dxos/util");
4222
+ var import_util8 = require("@dxos/util");
4224
4223
  var LoggingServiceImpl = class {
4225
4224
  constructor() {
4226
4225
  this._logs = new import_async16.Event();
4227
- this._started = new Date();
4226
+ this._started = /* @__PURE__ */ new Date();
4228
4227
  this._logProcessor = (_config, entry2) => {
4229
4228
  this._logs.emit(entry2);
4230
4229
  };
@@ -4238,15 +4237,15 @@ var LoggingServiceImpl = class {
4238
4237
  }
4239
4238
  async controlMetrics({ reset, record }) {
4240
4239
  if (reset) {
4241
- import_util7.tracer.clear();
4240
+ import_util8.tracer.clear();
4242
4241
  }
4243
4242
  if (record === true) {
4244
- import_util7.tracer.start();
4243
+ import_util8.tracer.start();
4245
4244
  } else if (record === false) {
4246
- import_util7.tracer.stop();
4245
+ import_util8.tracer.stop();
4247
4246
  }
4248
4247
  return {
4249
- recording: import_util7.tracer.recording
4248
+ recording: import_util8.tracer.recording
4250
4249
  };
4251
4250
  }
4252
4251
  /**
@@ -4254,24 +4253,23 @@ var LoggingServiceImpl = class {
4254
4253
  */
4255
4254
  queryMetrics({ interval = 5e3 }) {
4256
4255
  const getNumericalValues = (key) => {
4257
- var _a;
4258
- const events = (_a = import_util7.tracer.get(key)) != null ? _a : [];
4256
+ const events = import_util8.tracer.get(key) ?? [];
4259
4257
  return {
4260
4258
  key,
4261
- stats: (0, import_util7.numericalValues)(events, "duration")
4259
+ stats: (0, import_util8.numericalValues)(events, "duration")
4262
4260
  };
4263
4261
  };
4264
4262
  return new import_codec_protobuf13.Stream(({ next }) => {
4265
4263
  const update = () => {
4266
4264
  const metrics = {
4267
- timestamp: new Date(),
4265
+ timestamp: /* @__PURE__ */ new Date(),
4268
4266
  values: [
4269
4267
  getNumericalValues("dxos.echo.pipeline.control"),
4270
4268
  getNumericalValues("dxos.echo.pipeline.data")
4271
4269
  ].filter(Boolean)
4272
4270
  };
4273
4271
  next({
4274
- timestamp: new Date(),
4272
+ timestamp: /* @__PURE__ */ new Date(),
4275
4273
  metrics
4276
4274
  });
4277
4275
  };
@@ -4285,11 +4283,10 @@ var LoggingServiceImpl = class {
4285
4283
  queryLogs(request) {
4286
4284
  return new import_codec_protobuf13.Stream(({ ctx, next }) => {
4287
4285
  const handler = (entry2) => {
4288
- var _a, _b, _c, _d, _e;
4289
4286
  if (LOG_PROCESSING > 0) {
4290
4287
  return;
4291
4288
  }
4292
- if (((_a = entry2.meta) == null ? void 0 : _a.F.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
4289
+ if (entry2.meta?.F.includes("logging-service") || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
4293
4290
  return;
4294
4291
  }
4295
4292
  if (!shouldLog(entry2, request)) {
@@ -4297,12 +4294,12 @@ var LoggingServiceImpl = class {
4297
4294
  }
4298
4295
  const record = {
4299
4296
  ...entry2,
4300
- context: (0, import_util7.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
4301
- timestamp: new Date(),
4297
+ context: (0, import_util8.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
4298
+ timestamp: /* @__PURE__ */ new Date(),
4302
4299
  meta: {
4303
4300
  // TODO(dmaretskyi): Fix proto.
4304
- file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
4305
- line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
4301
+ file: entry2.meta?.F ?? "",
4302
+ line: entry2.meta?.L ?? 0
4306
4303
  }
4307
4304
  };
4308
4305
  try {
@@ -4325,15 +4322,11 @@ var matchFilter = (filter, level, path, options) => {
4325
4322
  }
4326
4323
  };
4327
4324
  var shouldLog = (entry2, request) => {
4328
- var _a;
4329
- const options = (_a = request.options) != null ? _a : import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4325
+ const options = request.options ?? import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4330
4326
  if (request.filters === void 0) {
4331
4327
  return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4332
4328
  } else {
4333
- return request.filters.some((filter) => {
4334
- var _a2, _b;
4335
- return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
4336
- });
4329
+ return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
4337
4330
  }
4338
4331
  };
4339
4332
  var LOG_PROCESSING = 0;
@@ -4375,10 +4368,10 @@ var import_client_protocol4 = require("@dxos/client-protocol");
4375
4368
  var import_errors5 = require("@dxos/errors");
4376
4369
  var import_config = require("@dxos/protocols/proto/dxos/config");
4377
4370
  var import_random_access_storage = require("@dxos/random-access-storage");
4378
- var import_util8 = require("@dxos/util");
4371
+ var import_util9 = require("@dxos/util");
4379
4372
  var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
4380
4373
  var createStorageObjects = (config) => {
4381
- const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
4374
+ const { path = (0, import_util9.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config ?? {};
4382
4375
  if (persistent && storageType === StorageDriver.RAM) {
4383
4376
  throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
4384
4377
  }
@@ -4422,7 +4415,7 @@ var toStorageType = (type) => {
4422
4415
  // packages/sdk/client-services/src/packlets/system/system-service.ts
4423
4416
  var import_codec_protobuf15 = require("@dxos/codec-protobuf");
4424
4417
  var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
4425
- var import_util9 = require("@dxos/util");
4418
+ var import_util10 = require("@dxos/util");
4426
4419
  var SystemServiceImpl = class {
4427
4420
  constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
4428
4421
  this._config = config;
@@ -4433,8 +4426,7 @@ var SystemServiceImpl = class {
4433
4426
  this._onReset = onReset;
4434
4427
  }
4435
4428
  async getConfig() {
4436
- var _a, _b;
4437
- return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
4429
+ return this._config?.values ?? {};
4438
4430
  }
4439
4431
  /**
4440
4432
  * NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
@@ -4442,8 +4434,8 @@ var SystemServiceImpl = class {
4442
4434
  async getDiagnostics({ keys } = {}) {
4443
4435
  const diagnostics = await this._getDiagnostics();
4444
4436
  return {
4445
- timestamp: new Date(),
4446
- diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util9.jsonKeyReplacer)({
4437
+ timestamp: /* @__PURE__ */ new Date(),
4438
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util10.jsonKeyReplacer)({
4447
4439
  truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
4448
4440
  humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
4449
4441
  })))
@@ -4557,11 +4549,10 @@ var ClientServicesHost = class ClientServicesHost2 {
4557
4549
  return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
4558
4550
  },
4559
4551
  onUpdateStatus: async (status) => {
4560
- var _a, _b;
4561
4552
  if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
4562
- await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
4553
+ await this._resourceLock?.acquire();
4563
4554
  } else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
4564
- await ((_b = this._resourceLock) == null ? void 0 : _b.release());
4555
+ await this._resourceLock?.release();
4565
4556
  }
4566
4557
  },
4567
4558
  onReset: async () => {
@@ -4598,7 +4589,6 @@ var ClientServicesHost = class ClientServicesHost2 {
4598
4589
  * Can only be called once.
4599
4590
  */
4600
4591
  initialize({ config, ...options }) {
4601
- var _a, _b, _c;
4602
4592
  (0, import_invariant14.invariant)(!this._open, "service host is open", {
4603
4593
  F: __dxlog_file17,
4604
4594
  L: 181,
@@ -4608,7 +4598,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4608
4598
  "'service host is open'"
4609
4599
  ]
4610
4600
  });
4611
- import_log16.log.info("initializing...", void 0, {
4601
+ (0, import_log16.log)("initializing...", void 0, {
4612
4602
  F: __dxlog_file17,
4613
4603
  L: 182,
4614
4604
  S: this,
@@ -4630,8 +4620,8 @@ var ClientServicesHost = class ClientServicesHost2 {
4630
4620
  }
4631
4621
  }
4632
4622
  const { connectionLog = true, transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
4633
- iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
4634
- }), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
4623
+ iceServers: this._config?.get("runtime.services.ice")
4624
+ }), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
4635
4625
  this._signalManager = signalManager;
4636
4626
  (0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
4637
4627
  F: __dxlog_file17,
@@ -4647,7 +4637,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4647
4637
  transportFactory,
4648
4638
  signalManager
4649
4639
  });
4650
- import_log16.log.info("initialized", void 0, {
4640
+ (0, import_log16.log)("initialized", void 0, {
4651
4641
  F: __dxlog_file17,
4652
4642
  L: 208,
4653
4643
  S: this,
@@ -4655,7 +4645,6 @@ var ClientServicesHost = class ClientServicesHost2 {
4655
4645
  });
4656
4646
  }
4657
4647
  async open(ctx) {
4658
- var _a, _b, _c;
4659
4648
  if (this._open) {
4660
4649
  return;
4661
4650
  }
@@ -4705,20 +4694,20 @@ var ClientServicesHost = class ClientServicesHost2 {
4705
4694
  ]
4706
4695
  });
4707
4696
  this._opening = true;
4708
- import_log16.log.info("opening...", {
4709
- lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4697
+ (0, import_log16.log)("opening...", {
4698
+ lockKey: this._resourceLock?.lockKey
4710
4699
  }, {
4711
4700
  F: __dxlog_file17,
4712
4701
  L: 227,
4713
4702
  S: this,
4714
4703
  C: (f, a) => f(...a)
4715
4704
  });
4716
- await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
4705
+ await this._resourceLock?.acquire();
4717
4706
  await this._loggingService.open();
4718
4707
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
4719
4708
  this._serviceRegistry.setServices({
4720
4709
  SystemService: this._systemService,
4721
- IdentityService: new IdentityServiceImpl(this._serviceContext),
4710
+ IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
4722
4711
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
4723
4712
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
4724
4713
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
@@ -4740,12 +4729,12 @@ var ClientServicesHost = class ClientServicesHost2 {
4740
4729
  this._opening = false;
4741
4730
  this._open = true;
4742
4731
  this._statusUpdate.emit();
4743
- const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
4744
- import_log16.log.info("opened", {
4732
+ const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
4733
+ (0, import_log16.log)("opened", {
4745
4734
  deviceKey
4746
4735
  }, {
4747
4736
  F: __dxlog_file17,
4748
- L: 280,
4737
+ L: 284,
4749
4738
  S: this,
4750
4739
  C: (f, a) => f(...a)
4751
4740
  });
@@ -4753,22 +4742,21 @@ var ClientServicesHost = class ClientServicesHost2 {
4753
4742
  id: traceId
4754
4743
  }), {
4755
4744
  F: __dxlog_file17,
4756
- L: 281,
4745
+ L: 285,
4757
4746
  S: this,
4758
4747
  C: (f, a) => f(...a)
4759
4748
  });
4760
4749
  }
4761
4750
  async close() {
4762
- var _a;
4763
4751
  if (!this._open) {
4764
4752
  return;
4765
4753
  }
4766
- const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
4767
- import_log16.log.info("closing...", {
4754
+ const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
4755
+ (0, import_log16.log)("closing...", {
4768
4756
  deviceKey
4769
4757
  }, {
4770
4758
  F: __dxlog_file17,
4771
- L: 292,
4759
+ L: 296,
4772
4760
  S: this,
4773
4761
  C: (f, a) => f(...a)
4774
4762
  });
@@ -4779,37 +4767,36 @@ var ClientServicesHost = class ClientServicesHost2 {
4779
4767
  await this._serviceContext.close();
4780
4768
  this._open = false;
4781
4769
  this._statusUpdate.emit();
4782
- import_log16.log.info("closed", {
4770
+ (0, import_log16.log)("closed", {
4783
4771
  deviceKey
4784
4772
  }, {
4785
4773
  F: __dxlog_file17,
4786
- L: 298,
4774
+ L: 302,
4787
4775
  S: this,
4788
4776
  C: (f, a) => f(...a)
4789
4777
  });
4790
4778
  }
4791
4779
  async reset() {
4792
- var _a, _b, _c;
4793
4780
  const traceId = import_keys11.PublicKey.random().toHex();
4794
4781
  import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
4795
4782
  id: traceId
4796
4783
  }), {
4797
4784
  F: __dxlog_file17,
4798
- L: 303,
4785
+ L: 307,
4799
4786
  S: this,
4800
4787
  C: (f, a) => f(...a)
4801
4788
  });
4802
4789
  (0, import_log16.log)("resetting...", void 0, {
4803
4790
  F: __dxlog_file17,
4804
- L: 305,
4791
+ L: 309,
4805
4792
  S: this,
4806
4793
  C: (f, a) => f(...a)
4807
4794
  });
4808
- await ((_a = this._serviceContext) == null ? void 0 : _a.close());
4795
+ await this._serviceContext?.close();
4809
4796
  await this._storage.reset();
4810
4797
  (0, import_log16.log)("reset", void 0, {
4811
4798
  F: __dxlog_file17,
4812
- L: 308,
4799
+ L: 312,
4813
4800
  S: this,
4814
4801
  C: (f, a) => f(...a)
4815
4802
  });
@@ -4817,11 +4804,11 @@ var ClientServicesHost = class ClientServicesHost2 {
4817
4804
  id: traceId
4818
4805
  }), {
4819
4806
  F: __dxlog_file17,
4820
- L: 309,
4807
+ L: 313,
4821
4808
  S: this,
4822
4809
  C: (f, a) => f(...a)
4823
4810
  });
4824
- await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
4811
+ await this._callbacks?.onReset?.();
4825
4812
  }
4826
4813
  };
4827
4814
  _ts_decorate7([
@@ -4849,7 +4836,7 @@ var import_context11 = require("@dxos/context");
4849
4836
  var import_log17 = require("@dxos/log");
4850
4837
  var import_messaging2 = require("@dxos/messaging");
4851
4838
  var import_network_manager3 = require("@dxos/network-manager");
4852
- var import_util10 = require("@dxos/util");
4839
+ var import_util11 = require("@dxos/util");
4853
4840
 
4854
4841
  // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
4855
4842
  var import_async18 = require("@dxos/async");
@@ -4913,8 +4900,7 @@ var ShellRuntimeImpl = class {
4913
4900
  await this._appRpc.open();
4914
4901
  }
4915
4902
  async close() {
4916
- var _a;
4917
- await ((_a = this._appRpc) == null ? void 0 : _a.close());
4903
+ await this._appRpc?.close();
4918
4904
  this._appRpc = void 0;
4919
4905
  }
4920
4906
  };
@@ -4950,7 +4936,6 @@ var IFrameHostRuntime = class {
4950
4936
  return this._shellRuntime;
4951
4937
  }
4952
4938
  async start() {
4953
- var _a;
4954
4939
  (0, import_log17.log)("starting...", void 0, {
4955
4940
  F: __dxlog_file19,
4956
4941
  L: 71,
@@ -4958,7 +4943,7 @@ var IFrameHostRuntime = class {
4958
4943
  C: (f, a) => f(...a)
4959
4944
  });
4960
4945
  try {
4961
- this._config = await (0, import_util10.getAsyncValue)(this._configProvider);
4946
+ this._config = await (0, import_util11.getAsyncValue)(this._configProvider);
4962
4947
  this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)({
4963
4948
  iceServers: this._config.get("runtime.services.ice")
4964
4949
  });
@@ -4997,7 +4982,7 @@ var IFrameHostRuntime = class {
4997
4982
  await Promise.all([
4998
4983
  this._clientServices.open(new import_context11.Context()),
4999
4984
  this._clientRpc.open(),
5000
- (_a = this._shellRuntime) == null ? void 0 : _a.open()
4985
+ this._shellRuntime?.open()
5001
4986
  ]);
5002
4987
  this._ready.wake(void 0);
5003
4988
  (0, import_log17.log)("started", void 0, {
@@ -5017,7 +5002,6 @@ var IFrameHostRuntime = class {
5017
5002
  }
5018
5003
  }
5019
5004
  async stop() {
5020
- var _a;
5021
5005
  (0, import_log17.log)("stopping...", void 0, {
5022
5006
  F: __dxlog_file19,
5023
5007
  L: 122,
@@ -5026,7 +5010,7 @@ var IFrameHostRuntime = class {
5026
5010
  });
5027
5011
  await this._clientRpc.close();
5028
5012
  await this._clientServices.close();
5029
- await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
5013
+ await this._shellRuntime?.close();
5030
5014
  (0, import_log17.log)("stopped", void 0, {
5031
5015
  F: __dxlog_file19,
5032
5016
  L: 126,
@@ -5046,7 +5030,7 @@ var import_errors6 = require("@dxos/errors");
5046
5030
  var import_log18 = require("@dxos/log");
5047
5031
  var import_network_manager4 = require("@dxos/network-manager");
5048
5032
  var import_rpc3 = require("@dxos/rpc");
5049
- var import_util11 = require("@dxos/util");
5033
+ var import_util12 = require("@dxos/util");
5050
5034
  var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts";
5051
5035
  var IFrameProxyRuntime = class {
5052
5036
  constructor({ config, systemPort, shellPort }) {
@@ -5063,8 +5047,7 @@ var IFrameProxyRuntime = class {
5063
5047
  return this._shellRuntime;
5064
5048
  }
5065
5049
  async open(origin) {
5066
- var _a;
5067
- this._config = await (0, import_util11.getAsyncValue)(this._configProvider);
5050
+ this._config = await (0, import_util12.getAsyncValue)(this._configProvider);
5068
5051
  this._transportService = new import_network_manager4.WebRTCTransportService({
5069
5052
  iceServers: this._config.get("runtime.services.ice")
5070
5053
  });
@@ -5103,12 +5086,11 @@ var IFrameProxyRuntime = class {
5103
5086
  });
5104
5087
  throw new import_errors6.RemoteServiceConnectionError("Failed to connect to worker");
5105
5088
  }
5106
- await ((_a = this._shellRuntime) == null ? void 0 : _a.open());
5089
+ await this._shellRuntime?.open();
5107
5090
  }
5108
5091
  async close() {
5109
- var _a;
5110
5092
  this._release.wake();
5111
- await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
5093
+ await this._shellRuntime?.close();
5112
5094
  await this._systemRpc.rpc.WorkerService.stop();
5113
5095
  await this._systemRpc.close();
5114
5096
  }
@@ -5130,7 +5112,7 @@ var import_client_protocol9 = require("@dxos/client-protocol");
5130
5112
  var import_invariant16 = require("@dxos/invariant");
5131
5113
  var import_log19 = require("@dxos/log");
5132
5114
  var import_rpc4 = require("@dxos/rpc");
5133
- var import_util12 = require("@dxos/util");
5115
+ var import_util13 = require("@dxos/util");
5134
5116
  function _ts_decorate9(decorators, target, key, desc) {
5135
5117
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5136
5118
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -5145,7 +5127,7 @@ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
5145
5127
  var WorkerSession = class {
5146
5128
  constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
5147
5129
  this._startTrigger = new import_async21.Trigger();
5148
- this.onClose = new import_util12.Callback();
5130
+ this.onClose = new import_util13.Callback();
5149
5131
  (0, import_invariant16.invariant)(serviceHost, void 0, {
5150
5132
  F: __dxlog_file21,
5151
5133
  L: 49,
@@ -5273,7 +5255,7 @@ var WorkerSession = class {
5273
5255
  async _maybeOpenShell() {
5274
5256
  try {
5275
5257
  await (0, import_async21.asyncTimeout)(this._shellClientRpc.open(), 1e3);
5276
- } catch (e) {
5258
+ } catch {
5277
5259
  import_log19.log.info("No shell connected.", void 0, {
5278
5260
  F: __dxlog_file21,
5279
5261
  L: 143,
@@ -5339,7 +5321,7 @@ var WorkerRuntime = class {
5339
5321
  });
5340
5322
  } catch (err) {
5341
5323
  this._ready.wake(err);
5342
- import_log20.log.catch(err, void 0, {
5324
+ import_log20.log.catch("starting", err, {
5343
5325
  F: __dxlog_file22,
5344
5326
  L: 66,
5345
5327
  S: this,