@dxos/client-services 0.5.9-main.bd9c8b3 → 0.5.9-main.bdb299c

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 (47) hide show
  1. package/dist/lib/browser/{chunk-KI7FY3ZO.mjs → chunk-366QXBJQ.mjs} +940 -523
  2. package/dist/lib/browser/chunk-366QXBJQ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +13 -2
  4. package/dist/lib/browser/index.mjs.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +10 -3
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +1 -1
  8. package/dist/lib/node/{chunk-XWMOEZYI.cjs → chunk-RZCXR5W4.cjs} +975 -558
  9. package/dist/lib/node/chunk-RZCXR5W4.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +53 -42
  11. package/dist/lib/node/index.cjs.map +1 -1
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/packlets/testing/index.cjs +17 -10
  14. package/dist/lib/node/packlets/testing/index.cjs.map +1 -1
  15. package/dist/types/src/packlets/identity/contacts-service.d.ts +14 -0
  16. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -0
  17. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  19. package/dist/types/src/packlets/invitations/space-invitation-protocol.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 +10 -1
  22. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  23. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  24. package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +2 -2
  25. package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -1
  26. package/dist/types/src/packlets/spaces/spaces-service.d.ts +4 -1
  27. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  28. package/dist/types/src/packlets/storage/index.d.ts +1 -0
  29. package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
  30. package/dist/types/src/packlets/storage/profile-archive.d.ts +14 -0
  31. package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -0
  32. package/dist/types/src/version.d.ts +1 -1
  33. package/package.json +36 -36
  34. package/src/packlets/identity/contacts-service.ts +85 -0
  35. package/src/packlets/identity/identity-service.ts +28 -22
  36. package/src/packlets/invitations/invitations-handler.ts +13 -5
  37. package/src/packlets/invitations/space-invitation-protocol.ts +11 -32
  38. package/src/packlets/services/service-host.ts +12 -4
  39. package/src/packlets/spaces/data-space-manager.ts +55 -2
  40. package/src/packlets/spaces/data-space.ts +3 -1
  41. package/src/packlets/spaces/epoch-migrations.ts +57 -38
  42. package/src/packlets/spaces/spaces-service.ts +40 -0
  43. package/src/packlets/storage/index.ts +1 -0
  44. package/src/packlets/storage/profile-archive.ts +111 -0
  45. package/src/version.ts +1 -1
  46. package/dist/lib/browser/chunk-KI7FY3ZO.mjs.map +0 -7
  47. package/dist/lib/node/chunk-XWMOEZYI.cjs.map +0 -7
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_XWMOEZYI_exports = {};
30
- __export(chunk_XWMOEZYI_exports, {
29
+ var chunk_RZCXR5W4_exports = {};
30
+ __export(chunk_RZCXR5W4_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  ClientServicesProviderResource: () => ClientServicesProviderResource,
@@ -56,7 +56,11 @@ __export(chunk_XWMOEZYI_exports, {
56
56
  createDiagnostics: () => createDiagnostics,
57
57
  createLevel: () => createLevel,
58
58
  createStorageObjects: () => createStorageObjects,
59
+ decodeProfileArchive: () => decodeProfileArchive,
60
+ encodeProfileArchive: () => encodeProfileArchive,
61
+ exportProfileData: () => exportProfileData,
59
62
  getNetworkPeers: () => getNetworkPeers,
63
+ importProfileData: () => importProfileData,
60
64
  isLocked: () => isLocked,
61
65
  subscribeToFeedBlocks: () => subscribeToFeedBlocks,
62
66
  subscribeToFeeds: () => subscribeToFeeds,
@@ -66,7 +70,7 @@ __export(chunk_XWMOEZYI_exports, {
66
70
  subscribeToSpaces: () => subscribeToSpaces,
67
71
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
68
72
  });
69
- module.exports = __toCommonJS(chunk_XWMOEZYI_exports);
73
+ module.exports = __toCommonJS(chunk_RZCXR5W4_exports);
70
74
  var import_async = require("@dxos/async");
71
75
  var import_codec_protobuf = require("@dxos/codec-protobuf");
72
76
  var import_feed_store = require("@dxos/feed-store");
@@ -212,32 +216,30 @@ var import_util7 = require("@dxos/util");
212
216
  var import_async14 = require("@dxos/async");
213
217
  var import_context11 = require("@dxos/context");
214
218
  var import_credentials14 = require("@dxos/credentials");
215
- var import_async15 = require("@dxos/async");
216
- var import_automerge = require("@dxos/automerge/automerge");
217
- var import_context12 = require("@dxos/context");
218
219
  var import_echo_db = require("@dxos/echo-db");
219
- var import_echo_pipeline3 = require("@dxos/echo-pipeline");
220
+ var import_echo_protocol2 = require("@dxos/echo-protocol");
220
221
  var import_echo_schema = require("@dxos/echo-schema");
221
222
  var import_invariant13 = require("@dxos/invariant");
222
223
  var import_log13 = require("@dxos/log");
223
224
  var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
224
- var import_util8 = require("@dxos/util");
225
- var import_async16 = require("@dxos/async");
226
- var import_context13 = require("@dxos/context");
225
+ var import_async15 = require("@dxos/async");
226
+ var import_context12 = require("@dxos/context");
227
227
  var import_invariant14 = require("@dxos/invariant");
228
228
  var import_keys11 = require("@dxos/keys");
229
229
  var import_log14 = require("@dxos/log");
230
230
  var import_protocols10 = require("@dxos/protocols");
231
231
  var import_teleport3 = require("@dxos/teleport");
232
- var import_util9 = require("@dxos/util");
233
- var import_async17 = require("@dxos/async");
232
+ var import_util8 = require("@dxos/util");
233
+ var import_async16 = require("@dxos/async");
234
234
  var import_client_protocol5 = require("@dxos/client-protocol");
235
- var import_context14 = require("@dxos/context");
235
+ var import_context13 = require("@dxos/context");
236
236
  var import_credentials15 = require("@dxos/credentials");
237
237
  var import_echo_db2 = require("@dxos/echo-db");
238
+ var import_echo_pipeline3 = require("@dxos/echo-pipeline");
238
239
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
239
- var import_echo_protocol2 = require("@dxos/echo-protocol");
240
+ var import_echo_protocol3 = require("@dxos/echo-protocol");
240
241
  var import_echo_schema2 = require("@dxos/echo-schema");
242
+ var import_feed_store4 = require("@dxos/feed-store");
241
243
  var import_invariant15 = require("@dxos/invariant");
242
244
  var import_keys12 = require("@dxos/keys");
243
245
  var import_log15 = require("@dxos/log");
@@ -246,28 +248,28 @@ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
246
248
  var import_credentials16 = require("@dxos/protocols/proto/dxos/halo/credentials");
247
249
  var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
248
250
  var import_tracing6 = require("@dxos/tracing");
249
- var import_util10 = require("@dxos/util");
251
+ var import_util9 = require("@dxos/util");
250
252
  var import_credentials17 = require("@dxos/credentials");
251
253
  var import_debug4 = require("@dxos/debug");
252
254
  var import_credentials18 = require("@dxos/protocols/proto/dxos/halo/credentials");
253
255
  var import_timeframe4 = require("@dxos/timeframe");
254
- var import_async18 = require("@dxos/async");
256
+ var import_async17 = require("@dxos/async");
255
257
  var import_codec_protobuf11 = require("@dxos/codec-protobuf");
256
258
  var import_credentials19 = require("@dxos/credentials");
257
259
  var import_debug5 = require("@dxos/debug");
258
- var import_feed_store4 = require("@dxos/feed-store");
260
+ var import_feed_store5 = require("@dxos/feed-store");
259
261
  var import_invariant16 = require("@dxos/invariant");
260
262
  var import_log16 = require("@dxos/log");
261
263
  var import_protocols12 = require("@dxos/protocols");
262
264
  var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
263
265
  var import_tracing7 = require("@dxos/tracing");
264
- var import_async19 = require("@dxos/async");
265
- var import_context15 = require("@dxos/context");
266
+ var import_async18 = require("@dxos/async");
267
+ var import_context14 = require("@dxos/context");
266
268
  var import_credentials20 = require("@dxos/credentials");
267
269
  var import_debug6 = require("@dxos/debug");
268
270
  var import_echo_db3 = require("@dxos/echo-db");
269
271
  var import_echo_pipeline5 = require("@dxos/echo-pipeline");
270
- var import_feed_store5 = require("@dxos/feed-store");
272
+ var import_feed_store6 = require("@dxos/feed-store");
271
273
  var import_invariant17 = require("@dxos/invariant");
272
274
  var import_keyring = require("@dxos/keyring");
273
275
  var import_keys13 = require("@dxos/keys");
@@ -276,7 +278,7 @@ var import_protocols13 = require("@dxos/protocols");
276
278
  var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
277
279
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
278
280
  var import_tracing8 = require("@dxos/tracing");
279
- var import_util11 = require("@dxos/util");
281
+ var import_util10 = require("@dxos/util");
280
282
  var import_invariant18 = require("@dxos/invariant");
281
283
  var import_lock_file = require("@dxos/lock-file");
282
284
  var import_log18 = require("@dxos/log");
@@ -285,25 +287,30 @@ var import_config = require("@dxos/protocols/proto/dxos/config");
285
287
  var import_random_access_storage = require("@dxos/random-access-storage");
286
288
  var import_client_protocol6 = require("@dxos/client-protocol");
287
289
  var import_config2 = require("@dxos/protocols/proto/dxos/config");
288
- var import_util12 = require("@dxos/util");
290
+ var import_util11 = require("@dxos/util");
289
291
  var import_node_path = __toESM(require("node:path"));
290
292
  var import_keys14 = require("@dxos/keys");
291
293
  var import_kv_store = require("@dxos/kv-store");
292
- var import_async20 = require("@dxos/async");
293
- var import_client_protocol7 = require("@dxos/client-protocol");
294
- var import_context16 = require("@dxos/context");
294
+ var import_automerge_repo = require("@dxos/automerge/automerge-repo");
295
295
  var import_invariant19 = require("@dxos/invariant");
296
- var import_keys15 = require("@dxos/keys");
297
296
  var import_log19 = require("@dxos/log");
297
+ var import_protocols15 = require("@dxos/protocols");
298
+ var import_util12 = require("@dxos/util");
299
+ var import_async19 = require("@dxos/async");
300
+ var import_client_protocol7 = require("@dxos/client-protocol");
301
+ var import_context15 = require("@dxos/context");
302
+ var import_invariant20 = require("@dxos/invariant");
303
+ var import_keys15 = require("@dxos/keys");
304
+ var import_log20 = require("@dxos/log");
298
305
  var import_messaging = require("@dxos/messaging");
299
306
  var import_network_manager2 = require("@dxos/network-manager");
300
- var import_protocols15 = require("@dxos/protocols");
307
+ var import_protocols16 = require("@dxos/protocols");
301
308
  var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
302
309
  var import_tracing9 = require("@dxos/tracing");
303
310
  var import_websocket_rpc = require("@dxos/websocket-rpc");
304
- var import_async21 = require("@dxos/async");
311
+ var import_async20 = require("@dxos/async");
305
312
  var import_codec_protobuf12 = require("@dxos/codec-protobuf");
306
- var import_invariant20 = require("@dxos/invariant");
313
+ var import_invariant21 = require("@dxos/invariant");
307
314
  var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
308
315
  var import_config3 = require("@dxos/config");
309
316
  var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
@@ -311,16 +318,20 @@ var import_tracing10 = require("@dxos/tracing");
311
318
  var import_util13 = require("@dxos/util");
312
319
  var import_keys16 = require("@dxos/keys");
313
320
  var import_util14 = require("@dxos/util");
314
- var import_async22 = require("@dxos/async");
321
+ var import_async21 = require("@dxos/async");
315
322
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
316
323
  var import_keys17 = require("@dxos/keys");
317
- var import_log20 = require("@dxos/log");
318
- var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
319
324
  var import_util15 = require("@dxos/util");
325
+ var import_async22 = require("@dxos/async");
320
326
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
327
+ var import_keys18 = require("@dxos/keys");
328
+ var import_log21 = require("@dxos/log");
329
+ var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
330
+ var import_util16 = require("@dxos/util");
321
331
  var import_codec_protobuf15 = require("@dxos/codec-protobuf");
332
+ var import_codec_protobuf16 = require("@dxos/codec-protobuf");
322
333
  var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
323
- var import_util16 = require("@dxos/util");
334
+ var import_util17 = require("@dxos/util");
324
335
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
325
336
  return new import_codec_protobuf.Stream(({ next }) => {
326
337
  const subscriptions = new import_async.EventSubscriptions();
@@ -388,6 +399,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
388
399
  };
389
400
  });
390
401
  };
402
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/network.ts";
391
403
  var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf2.Stream(({ next, close }) => {
392
404
  const update = () => {
393
405
  try {
@@ -403,7 +415,10 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf2
403
415
  update();
404
416
  });
405
417
  var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf2.Stream(({ next }) => {
406
- const ctx = new import_context.Context();
418
+ const ctx = new import_context.Context(void 0, {
419
+ F: __dxlog_file,
420
+ L: 36
421
+ });
407
422
  signalManager.onMessage.on(ctx, (message) => {
408
423
  next({
409
424
  message: {
@@ -631,7 +646,7 @@ var DevtoolsServiceImpl = class {
631
646
  });
632
647
  }
633
648
  };
634
- var DXOS_VERSION = "0.5.9-main.bd9c8b3";
649
+ var DXOS_VERSION = "0.5.9-main.bdb299c";
635
650
  var getPlatform = () => {
636
651
  if (process.browser) {
637
652
  if (typeof window !== "undefined") {
@@ -659,7 +674,7 @@ var getPlatform = () => {
659
674
  };
660
675
  }
661
676
  };
662
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
677
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
663
678
  var DEFAULT_TIMEOUT = 1e3;
664
679
  var createDiagnostics = async (clientServices, serviceContext, config) => {
665
680
  const diagnostics = {
@@ -676,7 +691,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
676
691
  await Promise.all([
677
692
  (async () => {
678
693
  (0, import_invariant.invariant)(clientServices.LoggingService, "SystemService is not available.", {
679
- F: __dxlog_file,
694
+ F: __dxlog_file2,
680
695
  L: 110,
681
696
  S: void 0,
682
697
  A: [
@@ -865,7 +880,7 @@ _ts_decorate([
865
880
  ClientRpcServer = _ts_decorate([
866
881
  import_tracing2.trace.resource()
867
882
  ], ClientRpcServer);
868
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
883
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
869
884
  var Credential = import_protocols2.schema.getCodecForType("dxos.halo.credentials.Credential");
870
885
  var createAuthProvider = (signer) => async (nonce) => {
871
886
  const credential = await signer.createCredential({
@@ -880,7 +895,10 @@ var createAuthProvider = (signer) => async (nonce) => {
880
895
  var TrustedKeySetAuthVerifier = class {
881
896
  constructor(_params) {
882
897
  this._params = _params;
883
- this._ctx = new import_context2.Context();
898
+ this._ctx = new import_context2.Context(void 0, {
899
+ F: __dxlog_file3,
900
+ L: 45
901
+ });
884
902
  }
885
903
  async close() {
886
904
  await this._ctx.dispose();
@@ -891,7 +909,7 @@ var TrustedKeySetAuthVerifier = class {
891
909
  (0, import_log.log)("authenticating...", {
892
910
  credential
893
911
  }, {
894
- F: __dxlog_file2,
912
+ F: __dxlog_file3,
895
913
  L: 56,
896
914
  S: this,
897
915
  C: (f, a) => f(...a)
@@ -901,7 +919,7 @@ var TrustedKeySetAuthVerifier = class {
901
919
  (0, import_log.log)("Invalid credential", {
902
920
  result
903
921
  }, {
904
- F: __dxlog_file2,
922
+ F: __dxlog_file3,
905
923
  L: 60,
906
924
  S: this,
907
925
  C: (f, a) => f(...a)
@@ -913,7 +931,7 @@ var TrustedKeySetAuthVerifier = class {
913
931
  nonce,
914
932
  credential
915
933
  }, {
916
- F: __dxlog_file2,
934
+ F: __dxlog_file3,
917
935
  L: 65,
918
936
  S: this,
919
937
  C: (f, a) => f(...a)
@@ -924,7 +942,7 @@ var TrustedKeySetAuthVerifier = class {
924
942
  (0, import_log.log)("key is not currently in trusted set, waiting...", {
925
943
  key: credential.issuer
926
944
  }, {
927
- F: __dxlog_file2,
945
+ F: __dxlog_file3,
928
946
  L: 70,
929
947
  S: this,
930
948
  C: (f, a) => f(...a)
@@ -940,7 +958,7 @@ var TrustedKeySetAuthVerifier = class {
940
958
  (0, import_log.log)("auth success", {
941
959
  key: credential.issuer
942
960
  }, {
943
- F: __dxlog_file2,
961
+ F: __dxlog_file3,
944
962
  L: 81,
945
963
  S: this,
946
964
  C: (f, a) => f(...a)
@@ -950,7 +968,7 @@ var TrustedKeySetAuthVerifier = class {
950
968
  (0, import_log.log)("key is not currently in trusted set, waiting...", {
951
969
  key: credential.issuer
952
970
  }, {
953
- F: __dxlog_file2,
971
+ F: __dxlog_file3,
954
972
  L: 84,
955
973
  S: this,
956
974
  C: (f, a) => f(...a)
@@ -973,7 +991,7 @@ var TrustedKeySetAuthVerifier = class {
973
991
  return deviceSet.has(deviceKey);
974
992
  }
975
993
  };
976
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
994
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
977
995
  var DefaultSpaceStateMachine = class {
978
996
  constructor(_params) {
979
997
  this._params = _params;
@@ -990,7 +1008,7 @@ var DefaultSpaceStateMachine = class {
990
1008
  expectedIdentity: this._params.identityKey,
991
1009
  credential
992
1010
  }, {
993
- F: __dxlog_file3,
1011
+ F: __dxlog_file4,
994
1012
  L: 32,
995
1013
  S: this,
996
1014
  C: (f, a) => f(...a)
@@ -1001,7 +1019,7 @@ var DefaultSpaceStateMachine = class {
1001
1019
  import_log3.log.warn("Invalid default space id", {
1002
1020
  id: assertion.spaceId
1003
1021
  }, {
1004
- F: __dxlog_file3,
1022
+ F: __dxlog_file4,
1005
1023
  L: 36,
1006
1024
  S: this,
1007
1025
  C: (f, a) => f(...a)
@@ -1024,7 +1042,7 @@ function _ts_decorate2(decorators, target, key, desc) {
1024
1042
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1025
1043
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1026
1044
  }
1027
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
1045
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
1028
1046
  var Identity = class {
1029
1047
  constructor({ space, signer, identityKey, deviceKey, presence }) {
1030
1048
  this.stateUpdate = new import_async6.Event();
@@ -1036,7 +1054,7 @@ var Identity = class {
1036
1054
  import_log2.log.trace("dxos.halo.device", {
1037
1055
  deviceKey
1038
1056
  }, {
1039
- F: __dxlog_file4,
1057
+ F: __dxlog_file5,
1040
1058
  L: 70,
1041
1059
  S: this,
1042
1060
  C: (f, a) => f(...a)
@@ -1115,7 +1133,7 @@ var Identity = class {
1115
1133
  */
1116
1134
  getIdentityCredentialSigner() {
1117
1135
  (0, import_invariant2.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
1118
- F: __dxlog_file4,
1136
+ F: __dxlog_file5,
1119
1137
  L: 159,
1120
1138
  S: this,
1121
1139
  A: [
@@ -1159,7 +1177,7 @@ var Identity = class {
1159
1177
  controlFeedKey,
1160
1178
  dataFeedKey
1161
1179
  }, {
1162
- F: __dxlog_file4,
1180
+ F: __dxlog_file5,
1163
1181
  L: 184,
1164
1182
  S: this,
1165
1183
  C: (f, a) => f(...a)
@@ -1220,7 +1238,7 @@ function _ts_decorate3(decorators, target, key, desc) {
1220
1238
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1221
1239
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1222
1240
  }
1223
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1241
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1224
1242
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
1225
1243
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
1226
1244
  var IdentityManager = class {
@@ -1244,7 +1262,7 @@ var IdentityManager = class {
1244
1262
  import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
1245
1263
  id: traceId
1246
1264
  }), {
1247
- F: __dxlog_file5,
1265
+ F: __dxlog_file6,
1248
1266
  L: 104,
1249
1267
  S: this,
1250
1268
  C: (f, a) => f(...a)
@@ -1253,7 +1271,7 @@ var IdentityManager = class {
1253
1271
  (0, import_log4.log)("identity record", {
1254
1272
  identityRecord
1255
1273
  }, {
1256
- F: __dxlog_file5,
1274
+ F: __dxlog_file6,
1257
1275
  L: 107,
1258
1276
  S: this,
1259
1277
  C: (f, a) => f(...a)
@@ -1266,7 +1284,7 @@ var IdentityManager = class {
1266
1284
  identityKey: identityRecord.identityKey,
1267
1285
  displayName: this._identity.profileDocument?.displayName
1268
1286
  }, {
1269
- F: __dxlog_file5,
1287
+ F: __dxlog_file6,
1270
1288
  L: 112,
1271
1289
  S: this,
1272
1290
  C: (f, a) => f(...a)
@@ -1276,18 +1294,21 @@ var IdentityManager = class {
1276
1294
  import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.end({
1277
1295
  id: traceId
1278
1296
  }), {
1279
- F: __dxlog_file5,
1297
+ F: __dxlog_file6,
1280
1298
  L: 119,
1281
1299
  S: this,
1282
1300
  C: (f, a) => f(...a)
1283
1301
  });
1284
1302
  }
1285
1303
  async close() {
1286
- await this._identity?.close(new import_context3.Context());
1304
+ await this._identity?.close(new import_context3.Context(void 0, {
1305
+ F: __dxlog_file6,
1306
+ L: 123
1307
+ }));
1287
1308
  }
1288
1309
  async createIdentity({ displayName, deviceProfile } = {}) {
1289
1310
  (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
1290
- F: __dxlog_file5,
1311
+ F: __dxlog_file6,
1291
1312
  L: 128,
1292
1313
  S: this,
1293
1314
  A: [
@@ -1296,7 +1317,7 @@ var IdentityManager = class {
1296
1317
  ]
1297
1318
  });
1298
1319
  (0, import_log4.log)("creating identity...", void 0, {
1299
- F: __dxlog_file5,
1320
+ F: __dxlog_file6,
1300
1321
  L: 129,
1301
1322
  S: this,
1302
1323
  C: (f, a) => f(...a)
@@ -1313,11 +1334,14 @@ var IdentityManager = class {
1313
1334
  }
1314
1335
  };
1315
1336
  const identity = await this._constructIdentity(identityRecord);
1316
- await identity.open(new import_context3.Context());
1337
+ await identity.open(new import_context3.Context(void 0, {
1338
+ F: __dxlog_file6,
1339
+ L: 144
1340
+ }));
1317
1341
  {
1318
1342
  const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
1319
1343
  (0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
1320
- F: __dxlog_file5,
1344
+ F: __dxlog_file6,
1321
1345
  L: 148,
1322
1346
  S: this,
1323
1347
  A: [
@@ -1326,7 +1350,7 @@ var IdentityManager = class {
1326
1350
  ]
1327
1351
  });
1328
1352
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
1329
- F: __dxlog_file5,
1353
+ F: __dxlog_file6,
1330
1354
  L: 149,
1331
1355
  S: this,
1332
1356
  A: [
@@ -1365,7 +1389,7 @@ var IdentityManager = class {
1365
1389
  identityKey: identityRecord.identityKey,
1366
1390
  displayName: this._identity.profileDocument?.displayName
1367
1391
  }, {
1368
- F: __dxlog_file5,
1392
+ F: __dxlog_file6,
1369
1393
  L: 191,
1370
1394
  S: this,
1371
1395
  C: (f, a) => f(...a)
@@ -1376,7 +1400,7 @@ var IdentityManager = class {
1376
1400
  deviceKey: identity.deviceKey,
1377
1401
  profile: identity.profileDocument
1378
1402
  }, {
1379
- F: __dxlog_file5,
1403
+ F: __dxlog_file6,
1380
1404
  L: 197,
1381
1405
  S: this,
1382
1406
  C: (f, a) => f(...a)
@@ -1413,13 +1437,13 @@ var IdentityManager = class {
1413
1437
  (0, import_log4.log)("accepting identity", {
1414
1438
  params
1415
1439
  }, {
1416
- F: __dxlog_file5,
1440
+ F: __dxlog_file6,
1417
1441
  L: 235,
1418
1442
  S: this,
1419
1443
  C: (f, a) => f(...a)
1420
1444
  });
1421
1445
  (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
1422
- F: __dxlog_file5,
1446
+ F: __dxlog_file6,
1423
1447
  L: 236,
1424
1448
  S: this,
1425
1449
  A: [
@@ -1439,7 +1463,10 @@ var IdentityManager = class {
1439
1463
  }
1440
1464
  };
1441
1465
  const identity = await this._constructIdentity(identityRecord);
1442
- await identity.open(new import_context3.Context());
1466
+ await identity.open(new import_context3.Context(void 0, {
1467
+ F: __dxlog_file6,
1468
+ L: 251
1469
+ }));
1443
1470
  this._identity = identity;
1444
1471
  await this._metadataStore.setIdentityRecord(identityRecord);
1445
1472
  await this._identity.ready();
@@ -1447,7 +1474,7 @@ var IdentityManager = class {
1447
1474
  identityKey: identityRecord.identityKey,
1448
1475
  displayName: this._identity.profileDocument?.displayName
1449
1476
  }, {
1450
- F: __dxlog_file5,
1477
+ F: __dxlog_file6,
1451
1478
  L: 255,
1452
1479
  S: this,
1453
1480
  C: (f, a) => f(...a)
@@ -1461,7 +1488,7 @@ var IdentityManager = class {
1461
1488
  identityKey: identity.identityKey,
1462
1489
  deviceKey: identity.deviceKey
1463
1490
  }, {
1464
- F: __dxlog_file5,
1491
+ F: __dxlog_file6,
1465
1492
  L: 265,
1466
1493
  S: this,
1467
1494
  C: (f, a) => f(...a)
@@ -1473,7 +1500,7 @@ var IdentityManager = class {
1473
1500
  */
1474
1501
  async updateProfile(profile) {
1475
1502
  (0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
1476
- F: __dxlog_file5,
1503
+ F: __dxlog_file6,
1477
1504
  L: 273,
1478
1505
  S: this,
1479
1506
  A: [
@@ -1504,7 +1531,7 @@ var IdentityManager = class {
1504
1531
  }
1505
1532
  async updateDeviceProfile(profile) {
1506
1533
  (0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
1507
- F: __dxlog_file5,
1534
+ F: __dxlog_file6,
1508
1535
  L: 290,
1509
1536
  S: this,
1510
1537
  A: [
@@ -1540,7 +1567,7 @@ var IdentityManager = class {
1540
1567
  }
1541
1568
  async _constructIdentity(identityRecord) {
1542
1569
  (0, import_invariant3.invariant)(!this._identity, void 0, {
1543
- F: __dxlog_file5,
1570
+ F: __dxlog_file6,
1544
1571
  L: 316,
1545
1572
  S: this,
1546
1573
  A: [
@@ -1551,7 +1578,7 @@ var IdentityManager = class {
1551
1578
  (0, import_log4.log)("constructing identity", {
1552
1579
  identityRecord
1553
1580
  }, {
1554
- F: __dxlog_file5,
1581
+ F: __dxlog_file6,
1555
1582
  L: 317,
1556
1583
  S: this,
1557
1584
  C: (f, a) => f(...a)
@@ -1566,7 +1593,7 @@ var IdentityManager = class {
1566
1593
  gossip
1567
1594
  });
1568
1595
  (0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
1569
- F: __dxlog_file5,
1596
+ F: __dxlog_file6,
1570
1597
  L: 330,
1571
1598
  S: this,
1572
1599
  A: [
@@ -1578,7 +1605,7 @@ var IdentityManager = class {
1578
1605
  writable: true
1579
1606
  });
1580
1607
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
1581
- F: __dxlog_file5,
1608
+ F: __dxlog_file6,
1582
1609
  L: 334,
1583
1610
  S: this,
1584
1611
  A: [
@@ -1612,7 +1639,7 @@ var IdentityManager = class {
1612
1639
  (0, import_log4.log)("done", {
1613
1640
  identityKey: identityRecord.identityKey
1614
1641
  }, {
1615
- F: __dxlog_file5,
1642
+ F: __dxlog_file6,
1616
1643
  L: 360,
1617
1644
  S: this,
1618
1645
  C: (f, a) => f(...a)
@@ -1637,7 +1664,7 @@ var IdentityManager = class {
1637
1664
  },
1638
1665
  onAuthFailure: () => {
1639
1666
  import_log4.log.warn("auth failure", void 0, {
1640
- F: __dxlog_file5,
1667
+ F: __dxlog_file6,
1641
1668
  L: 385,
1642
1669
  S: this,
1643
1670
  C: (f, a) => f(...a)
@@ -1659,7 +1686,7 @@ _ts_decorate3([
1659
1686
  IdentityManager = _ts_decorate3([
1660
1687
  import_tracing4.trace.resource()
1661
1688
  ], IdentityManager);
1662
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1689
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1663
1690
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
1664
1691
  var IdentityServiceImpl = class extends import_context4.Resource {
1665
1692
  constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
@@ -1689,7 +1716,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1689
1716
  const space = await dataSpaceManager.createDefaultSpace();
1690
1717
  const identity = this._identityManager.identity;
1691
1718
  (0, import_invariant4.invariant)(identity, void 0, {
1692
- F: __dxlog_file6,
1719
+ F: __dxlog_file7,
1693
1720
  L: 59,
1694
1721
  S: this,
1695
1722
  A: [
@@ -1723,7 +1750,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1723
1750
  }
1724
1751
  async updateProfile(profile) {
1725
1752
  (0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
1726
- F: __dxlog_file6,
1753
+ F: __dxlog_file7,
1727
1754
  L: 89,
1728
1755
  S: this,
1729
1756
  A: [
@@ -1737,7 +1764,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1737
1764
  }
1738
1765
  async signPresentation({ presentation, nonce }) {
1739
1766
  (0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
1740
- F: __dxlog_file6,
1767
+ F: __dxlog_file7,
1741
1768
  L: 96,
1742
1769
  S: this,
1743
1770
  A: [
@@ -1772,8 +1799,8 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1772
1799
  import_log5.log.warn("Multiple default spaces found. Using the first one.", {
1773
1800
  duplicate: space.id
1774
1801
  }, {
1775
- F: __dxlog_file6,
1776
- L: 127,
1802
+ F: __dxlog_file7,
1803
+ L: 129,
1777
1804
  S: this,
1778
1805
  C: (f, a) => f(...a)
1779
1806
  });
@@ -1784,6 +1811,13 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1784
1811
  recodedDefaultSpace = true;
1785
1812
  recordedDefaultSpaceTrigger.wake();
1786
1813
  }
1814
+ }, (err) => {
1815
+ import_log5.log.catch(err, void 0, {
1816
+ F: __dxlog_file7,
1817
+ L: 140,
1818
+ S: this,
1819
+ C: (f, a) => f(...a)
1820
+ });
1787
1821
  });
1788
1822
  await Promise.race([
1789
1823
  allProcessed,
@@ -1795,7 +1829,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1795
1829
  }
1796
1830
  }
1797
1831
  };
1798
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1832
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1799
1833
  var DeviceInvitationProtocol = class {
1800
1834
  constructor(_keyring, _getIdentity, _acceptIdentity) {
1801
1835
  this._keyring = _keyring;
@@ -1821,7 +1855,7 @@ var DeviceInvitationProtocol = class {
1821
1855
  }
1822
1856
  async admit(_, request) {
1823
1857
  (0, import_invariant5.invariant)(request.device, void 0, {
1824
- F: __dxlog_file7,
1858
+ F: __dxlog_file8,
1825
1859
  L: 50,
1826
1860
  S: this,
1827
1861
  A: [
@@ -1867,7 +1901,7 @@ var DeviceInvitationProtocol = class {
1867
1901
  }
1868
1902
  async accept(response, request) {
1869
1903
  (0, import_invariant5.invariant)(response.device, void 0, {
1870
- F: __dxlog_file7,
1904
+ F: __dxlog_file8,
1871
1905
  L: 95,
1872
1906
  S: this,
1873
1907
  A: [
@@ -1877,7 +1911,7 @@ var DeviceInvitationProtocol = class {
1877
1911
  });
1878
1912
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1879
1913
  (0, import_invariant5.invariant)(request.device, void 0, {
1880
- F: __dxlog_file7,
1914
+ F: __dxlog_file8,
1881
1915
  L: 98,
1882
1916
  S: this,
1883
1917
  A: [
@@ -1916,7 +1950,7 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
1916
1950
  return guard;
1917
1951
  })());
1918
1952
  };
1919
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1953
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1920
1954
  var OPTIONS_TIMEOUT = 1e4;
1921
1955
  var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1922
1956
  constructor(_invitationFlowMutex, _callbacks) {
@@ -1930,7 +1964,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1930
1964
  });
1931
1965
  this._invitationFlowMutex = _invitationFlowMutex;
1932
1966
  this._callbacks = _callbacks;
1933
- this._ctx = new import_context6.Context();
1967
+ this._ctx = new import_context6.Context(void 0, {
1968
+ F: __dxlog_file9,
1969
+ L: 33
1970
+ });
1934
1971
  this._remoteOptionsTrigger = new import_async10.Trigger();
1935
1972
  this._invitationFlowLock = null;
1936
1973
  }
@@ -1942,7 +1979,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1942
1979
  InvitationHostService: {
1943
1980
  options: async (options) => {
1944
1981
  (0, import_invariant7.invariant)(!this._remoteOptions, "Remote options already set.", {
1945
- F: __dxlog_file8,
1982
+ F: __dxlog_file9,
1946
1983
  L: 63,
1947
1984
  S: this,
1948
1985
  A: [
@@ -1969,14 +2006,14 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1969
2006
  await super.onOpen(context);
1970
2007
  try {
1971
2008
  (0, import_log7.log)("guest acquire lock", void 0, {
1972
- F: __dxlog_file8,
2009
+ F: __dxlog_file9,
1973
2010
  L: 84,
1974
2011
  S: this,
1975
2012
  C: (f, a) => f(...a)
1976
2013
  });
1977
2014
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
1978
2015
  (0, import_log7.log)("guest lock acquired", void 0, {
1979
- F: __dxlog_file8,
2016
+ F: __dxlog_file9,
1980
2017
  L: 86,
1981
2018
  S: this,
1982
2019
  C: (f, a) => f(...a)
@@ -1985,7 +2022,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1985
2022
  role: import_invitations3.Options.Role.GUEST
1986
2023
  }));
1987
2024
  (0, import_log7.log)("options sent", void 0, {
1988
- F: __dxlog_file8,
2025
+ F: __dxlog_file9,
1989
2026
  L: 88,
1990
2027
  S: this,
1991
2028
  C: (f, a) => f(...a)
@@ -1994,7 +2031,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1994
2031
  timeout: OPTIONS_TIMEOUT
1995
2032
  }));
1996
2033
  (0, import_log7.log)("options received", void 0, {
1997
- F: __dxlog_file8,
2034
+ F: __dxlog_file9,
1998
2035
  L: 90,
1999
2036
  S: this,
2000
2037
  C: (f, a) => f(...a)
@@ -2028,7 +2065,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
2028
2065
  this._invitationFlowLock.release();
2029
2066
  this._invitationFlowLock = null;
2030
2067
  (0, import_log7.log)("invitation flow lock released", void 0, {
2031
- F: __dxlog_file8,
2068
+ F: __dxlog_file9,
2032
2069
  L: 123,
2033
2070
  S: this,
2034
2071
  C: (f, a) => f(...a)
@@ -2036,7 +2073,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
2036
2073
  }
2037
2074
  }
2038
2075
  };
2039
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
2076
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
2040
2077
  var OPTIONS_TIMEOUT2 = 1e4;
2041
2078
  var MAX_OTP_ATTEMPTS = 3;
2042
2079
  var InvitationHostExtension = class extends import_teleport2.RpcExtension {
@@ -2051,7 +2088,10 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2051
2088
  });
2052
2089
  this._invitationFlowMutex = _invitationFlowMutex;
2053
2090
  this._callbacks = _callbacks;
2054
- this._ctx = new import_context8.Context();
2091
+ this._ctx = new import_context8.Context(void 0, {
2092
+ F: __dxlog_file10,
2093
+ L: 52
2094
+ });
2055
2095
  this._remoteOptionsTrigger = new import_async11.Trigger();
2056
2096
  this._challenge = void 0;
2057
2097
  this.guestProfile = void 0;
@@ -2070,7 +2110,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2070
2110
  InvitationHostService: {
2071
2111
  options: async (options) => {
2072
2112
  (0, import_invariant8.invariant)(!this._remoteOptions, "Remote options already set.", {
2073
- F: __dxlog_file9,
2113
+ F: __dxlog_file10,
2074
2114
  L: 101,
2075
2115
  S: this,
2076
2116
  A: [
@@ -2087,7 +2127,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2087
2127
  import_log8.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.begin({
2088
2128
  id: traceId
2089
2129
  }), {
2090
- F: __dxlog_file9,
2130
+ F: __dxlog_file10,
2091
2131
  L: 110,
2092
2132
  S: this,
2093
2133
  C: (f, a) => f(...a)
@@ -2099,7 +2139,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2099
2139
  expected: invitation.invitationId,
2100
2140
  actual: invitationId
2101
2141
  }, {
2102
- F: __dxlog_file9,
2142
+ F: __dxlog_file10,
2103
2143
  L: 116,
2104
2144
  S: this,
2105
2145
  C: (f, a) => f(...a)
@@ -2113,7 +2153,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2113
2153
  (0, import_log8.log)("guest introduced themselves", {
2114
2154
  guestProfile: profile
2115
2155
  }, {
2116
- F: __dxlog_file9,
2156
+ F: __dxlog_file10,
2117
2157
  L: 125,
2118
2158
  S: this,
2119
2159
  C: (f, a) => f(...a)
@@ -2124,7 +2164,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2124
2164
  import_log8.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.end({
2125
2165
  id: traceId
2126
2166
  }), {
2127
- F: __dxlog_file9,
2167
+ F: __dxlog_file10,
2128
2168
  L: 132,
2129
2169
  S: this,
2130
2170
  C: (f, a) => f(...a)
@@ -2139,7 +2179,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2139
2179
  import_log8.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.begin({
2140
2180
  id: traceId
2141
2181
  }), {
2142
- F: __dxlog_file9,
2182
+ F: __dxlog_file10,
2143
2183
  L: 141,
2144
2184
  S: this,
2145
2185
  C: (f, a) => f(...a)
@@ -2148,7 +2188,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2148
2188
  (0, import_log8.log)("received authentication request", {
2149
2189
  authCode: code
2150
2190
  }, {
2151
- F: __dxlog_file9,
2191
+ F: __dxlog_file10,
2152
2192
  L: 144,
2153
2193
  S: this,
2154
2194
  C: (f, a) => f(...a)
@@ -2162,7 +2202,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2162
2202
  switch (invitation.authMethod) {
2163
2203
  case import_services8.Invitation.AuthMethod.NONE: {
2164
2204
  (0, import_log8.log)("authentication not required", void 0, {
2165
- F: __dxlog_file9,
2205
+ F: __dxlog_file10,
2166
2206
  L: 152,
2167
2207
  S: this,
2168
2208
  C: (f, a) => f(...a)
@@ -2200,7 +2240,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2200
2240
  import_log8.log.error("invalid authentication method", {
2201
2241
  authMethod: invitation.authMethod
2202
2242
  }, {
2203
- F: __dxlog_file9,
2243
+ F: __dxlog_file10,
2204
2244
  L: 190,
2205
2245
  S: this,
2206
2246
  C: (f, a) => f(...a)
@@ -2225,7 +2265,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2225
2265
  status
2226
2266
  }
2227
2267
  }), {
2228
- F: __dxlog_file9,
2268
+ F: __dxlog_file10,
2229
2269
  L: 202,
2230
2270
  S: this,
2231
2271
  C: (f, a) => f(...a)
@@ -2239,7 +2279,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2239
2279
  import_log8.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.begin({
2240
2280
  id: traceId
2241
2281
  }), {
2242
- F: __dxlog_file9,
2282
+ F: __dxlog_file10,
2243
2283
  L: 208,
2244
2284
  S: this,
2245
2285
  C: (f, a) => f(...a)
@@ -2256,7 +2296,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2256
2296
  import_log8.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.end({
2257
2297
  id: traceId
2258
2298
  }), {
2259
- F: __dxlog_file9,
2299
+ F: __dxlog_file10,
2260
2300
  L: 222,
2261
2301
  S: this,
2262
2302
  C: (f, a) => f(...a)
@@ -2274,14 +2314,14 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2274
2314
  await super.onOpen(context);
2275
2315
  try {
2276
2316
  (0, import_log8.log)("host acquire lock", void 0, {
2277
- F: __dxlog_file9,
2317
+ F: __dxlog_file10,
2278
2318
  L: 237,
2279
2319
  S: this,
2280
2320
  C: (f, a) => f(...a)
2281
2321
  });
2282
2322
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
2283
2323
  (0, import_log8.log)("host lock acquired", void 0, {
2284
- F: __dxlog_file9,
2324
+ F: __dxlog_file10,
2285
2325
  L: 239,
2286
2326
  S: this,
2287
2327
  C: (f, a) => f(...a)
@@ -2292,7 +2332,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2292
2332
  role: import_invitations4.Options.Role.HOST
2293
2333
  });
2294
2334
  (0, import_log8.log)("options sent", void 0, {
2295
- F: __dxlog_file9,
2335
+ F: __dxlog_file10,
2296
2336
  L: 243,
2297
2337
  S: this,
2298
2338
  C: (f, a) => f(...a)
@@ -2301,7 +2341,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2301
2341
  timeout: OPTIONS_TIMEOUT2
2302
2342
  }));
2303
2343
  (0, import_log8.log)("options received", void 0, {
2304
- F: __dxlog_file9,
2344
+ F: __dxlog_file10,
2305
2345
  L: 245,
2306
2346
  S: this,
2307
2347
  C: (f, a) => f(...a)
@@ -2355,7 +2395,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2355
2395
  this._invitationFlowLock?.release();
2356
2396
  this._invitationFlowLock = null;
2357
2397
  (0, import_log8.log)("invitation flow lock released", void 0, {
2358
- F: __dxlog_file9,
2398
+ F: __dxlog_file10,
2359
2399
  L: 300,
2360
2400
  S: this,
2361
2401
  C: (f, a) => f(...a)
@@ -2364,7 +2404,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2364
2404
  }
2365
2405
  };
2366
2406
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services8.Invitation.AuthMethod.NONE;
2367
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2407
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2368
2408
  var InvitationTopology = class {
2369
2409
  constructor(_role) {
2370
2410
  this._role = _role;
@@ -2372,7 +2412,7 @@ var InvitationTopology = class {
2372
2412
  }
2373
2413
  init(controller) {
2374
2414
  (0, import_invariant9.invariant)(!this._controller, "Already initialized.", {
2375
- F: __dxlog_file10,
2415
+ F: __dxlog_file11,
2376
2416
  L: 42,
2377
2417
  S: this,
2378
2418
  A: [
@@ -2384,7 +2424,7 @@ var InvitationTopology = class {
2384
2424
  }
2385
2425
  update() {
2386
2426
  (0, import_invariant9.invariant)(this._controller, "Not initialized.", {
2387
- F: __dxlog_file10,
2427
+ F: __dxlog_file11,
2388
2428
  L: 47,
2389
2429
  S: this,
2390
2430
  A: [
@@ -2407,7 +2447,7 @@ var InvitationTopology = class {
2407
2447
  ownPeerId,
2408
2448
  remotePeerId: firstUnknownPeer
2409
2449
  }, {
2410
- F: __dxlog_file10,
2450
+ F: __dxlog_file11,
2411
2451
  L: 69,
2412
2452
  S: this,
2413
2453
  C: (f, a) => f(...a)
@@ -2418,7 +2458,7 @@ var InvitationTopology = class {
2418
2458
  }
2419
2459
  async onOffer(peer) {
2420
2460
  (0, import_invariant9.invariant)(this._controller, "Not initialized.", {
2421
- F: __dxlog_file10,
2461
+ F: __dxlog_file11,
2422
2462
  L: 76,
2423
2463
  S: this,
2424
2464
  A: [
@@ -2435,7 +2475,7 @@ var InvitationTopology = class {
2435
2475
  return `InvitationTopology(${this._role === import_invitations5.Options.Role.GUEST ? "guest" : "host"})`;
2436
2476
  }
2437
2477
  };
2438
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2478
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2439
2479
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
2440
2480
  var InvitationsHandler = class {
2441
2481
  /**
@@ -2460,7 +2500,7 @@ var InvitationsHandler = class {
2460
2500
  try {
2461
2501
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
2462
2502
  (0, import_invariant6.invariant)(deviceKey, void 0, {
2463
- F: __dxlog_file11,
2503
+ F: __dxlog_file12,
2464
2504
  L: 90,
2465
2505
  S: this,
2466
2506
  A: [
@@ -2489,7 +2529,7 @@ var InvitationsHandler = class {
2489
2529
  import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
2490
2530
  id: traceId
2491
2531
  }), {
2492
- F: __dxlog_file11,
2532
+ F: __dxlog_file12,
2493
2533
  L: 115,
2494
2534
  S: this,
2495
2535
  C: (f, a) => f(...a)
@@ -2497,7 +2537,7 @@ var InvitationsHandler = class {
2497
2537
  (0, import_log6.log)("connected", {
2498
2538
  ...protocol.toJSON()
2499
2539
  }, {
2500
- F: __dxlog_file11,
2540
+ F: __dxlog_file12,
2501
2541
  L: 116,
2502
2542
  S: this,
2503
2543
  C: (f, a) => f(...a)
@@ -2509,7 +2549,7 @@ var InvitationsHandler = class {
2509
2549
  guest: deviceKey,
2510
2550
  ...protocol.toJSON()
2511
2551
  }, {
2512
- F: __dxlog_file11,
2552
+ F: __dxlog_file12,
2513
2553
  L: 118,
2514
2554
  S: this,
2515
2555
  C: (f, a) => f(...a)
@@ -2518,7 +2558,7 @@ var InvitationsHandler = class {
2518
2558
  import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
2519
2559
  id: traceId
2520
2560
  }), {
2521
- F: __dxlog_file11,
2561
+ F: __dxlog_file12,
2522
2562
  L: 120,
2523
2563
  S: this,
2524
2564
  C: (f, a) => f(...a)
@@ -2533,7 +2573,7 @@ var InvitationsHandler = class {
2533
2573
  (0, import_log6.log)("timeout", {
2534
2574
  ...protocol.toJSON()
2535
2575
  }, {
2536
- F: __dxlog_file11,
2576
+ F: __dxlog_file12,
2537
2577
  L: 129,
2538
2578
  S: this,
2539
2579
  C: (f, a) => f(...a)
@@ -2542,7 +2582,7 @@ var InvitationsHandler = class {
2542
2582
  } else {
2543
2583
  if (guardedState.error(extension, err)) {
2544
2584
  import_log6.log.error("failed", err, {
2545
- F: __dxlog_file11,
2585
+ F: __dxlog_file12,
2546
2586
  L: 133,
2547
2587
  S: this,
2548
2588
  C: (f, a) => f(...a)
@@ -2553,7 +2593,7 @@ var InvitationsHandler = class {
2553
2593
  id: traceId,
2554
2594
  error: err
2555
2595
  }), {
2556
- F: __dxlog_file11,
2596
+ F: __dxlog_file12,
2557
2597
  L: 136,
2558
2598
  S: this,
2559
2599
  C: (f, a) => f(...a)
@@ -2567,7 +2607,7 @@ var InvitationsHandler = class {
2567
2607
  (0, import_log6.log)("invalid role", {
2568
2608
  ...err.context
2569
2609
  }, {
2570
- F: __dxlog_file11,
2610
+ F: __dxlog_file12,
2571
2611
  L: 144,
2572
2612
  S: this,
2573
2613
  C: (f, a) => f(...a)
@@ -2579,7 +2619,7 @@ var InvitationsHandler = class {
2579
2619
  (0, import_log6.log)("timeout", {
2580
2620
  err
2581
2621
  }, {
2582
- F: __dxlog_file11,
2622
+ F: __dxlog_file12,
2583
2623
  L: 149,
2584
2624
  S: this,
2585
2625
  C: (f, a) => f(...a)
@@ -2588,7 +2628,7 @@ var InvitationsHandler = class {
2588
2628
  } else {
2589
2629
  if (guardedState.error(extension, err)) {
2590
2630
  import_log6.log.error("failed", err, {
2591
- F: __dxlog_file11,
2631
+ F: __dxlog_file12,
2592
2632
  L: 153,
2593
2633
  S: this,
2594
2634
  C: (f, a) => f(...a)
@@ -2602,7 +2642,7 @@ var InvitationsHandler = class {
2602
2642
  if (invitation.lifetime && invitation.created) {
2603
2643
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
2604
2644
  import_log6.log.warn("invitation has already expired", void 0, {
2605
- F: __dxlog_file11,
2645
+ F: __dxlog_file12,
2606
2646
  L: 164,
2607
2647
  S: this,
2608
2648
  C: (f, a) => f(...a)
@@ -2625,7 +2665,7 @@ var InvitationsHandler = class {
2625
2665
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
2626
2666
  if (deviceProfile) {
2627
2667
  (0, import_invariant6.invariant)(invitation.kind === import_services6.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2628
- F: __dxlog_file11,
2668
+ F: __dxlog_file12,
2629
2669
  L: 197,
2630
2670
  S: this,
2631
2671
  A: [
@@ -2643,7 +2683,7 @@ var InvitationsHandler = class {
2643
2683
  invitationType: import_services6.Invitation.Type.DELEGATED,
2644
2684
  triedPeers: triedPeersIds.size
2645
2685
  }, {
2646
- F: __dxlog_file11,
2686
+ F: __dxlog_file12,
2647
2687
  L: 205,
2648
2688
  S: this,
2649
2689
  C: (f, a) => f(...a)
@@ -2670,7 +2710,7 @@ var InvitationsHandler = class {
2670
2710
  admitted,
2671
2711
  currentState: guardedState.current.state
2672
2712
  }, {
2673
- F: __dxlog_file11,
2713
+ F: __dxlog_file12,
2674
2714
  L: 233,
2675
2715
  S: this,
2676
2716
  C: (f, a) => f(...a)
@@ -2688,7 +2728,7 @@ var InvitationsHandler = class {
2688
2728
  import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
2689
2729
  id: traceId
2690
2730
  }), {
2691
- F: __dxlog_file11,
2731
+ F: __dxlog_file12,
2692
2732
  L: 245,
2693
2733
  S: this,
2694
2734
  C: (f, a) => f(...a)
@@ -2700,7 +2740,7 @@ var InvitationsHandler = class {
2700
2740
  (0, import_log6.log)("connected", {
2701
2741
  ...protocol.toJSON()
2702
2742
  }, {
2703
- F: __dxlog_file11,
2743
+ F: __dxlog_file12,
2704
2744
  L: 256,
2705
2745
  S: this,
2706
2746
  C: (f, a) => f(...a)
@@ -2709,7 +2749,7 @@ var InvitationsHandler = class {
2709
2749
  (0, import_log6.log)("introduce", {
2710
2750
  ...protocol.toJSON()
2711
2751
  }, {
2712
- F: __dxlog_file11,
2752
+ F: __dxlog_file12,
2713
2753
  L: 260,
2714
2754
  S: this,
2715
2755
  C: (f, a) => f(...a)
@@ -2722,7 +2762,7 @@ var InvitationsHandler = class {
2722
2762
  ...protocol.toJSON(),
2723
2763
  response: introductionResponse
2724
2764
  }, {
2725
- F: __dxlog_file11,
2765
+ F: __dxlog_file12,
2726
2766
  L: 265,
2727
2767
  S: this,
2728
2768
  C: (f, a) => f(...a)
@@ -2743,7 +2783,7 @@ var InvitationsHandler = class {
2743
2783
  (0, import_log6.log)("request admission", {
2744
2784
  ...protocol.toJSON()
2745
2785
  }, {
2746
- F: __dxlog_file11,
2786
+ F: __dxlog_file12,
2747
2787
  L: 291,
2748
2788
  S: this,
2749
2789
  C: (f, a) => f(...a)
@@ -2755,7 +2795,7 @@ var InvitationsHandler = class {
2755
2795
  (0, import_log6.log)("admitted by host", {
2756
2796
  ...protocol.toJSON()
2757
2797
  }, {
2758
- F: __dxlog_file11,
2798
+ F: __dxlog_file12,
2759
2799
  L: 302,
2760
2800
  S: this,
2761
2801
  C: (f, a) => f(...a)
@@ -2768,7 +2808,7 @@ var InvitationsHandler = class {
2768
2808
  import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
2769
2809
  id: traceId
2770
2810
  }), {
2771
- F: __dxlog_file11,
2811
+ F: __dxlog_file12,
2772
2812
  L: 308,
2773
2813
  S: this,
2774
2814
  C: (f, a) => f(...a)
@@ -2778,7 +2818,7 @@ var InvitationsHandler = class {
2778
2818
  (0, import_log6.log)("timeout", {
2779
2819
  ...protocol.toJSON()
2780
2820
  }, {
2781
- F: __dxlog_file11,
2821
+ F: __dxlog_file12,
2782
2822
  L: 311,
2783
2823
  S: this,
2784
2824
  C: (f, a) => f(...a)
@@ -2786,7 +2826,7 @@ var InvitationsHandler = class {
2786
2826
  guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
2787
2827
  } else {
2788
2828
  (0, import_log6.log)("auth failed", err, {
2789
- F: __dxlog_file11,
2829
+ F: __dxlog_file12,
2790
2830
  L: 314,
2791
2831
  S: this,
2792
2832
  C: (f, a) => f(...a)
@@ -2798,7 +2838,7 @@ var InvitationsHandler = class {
2798
2838
  id: traceId,
2799
2839
  error: err
2800
2840
  }), {
2801
- F: __dxlog_file11,
2841
+ F: __dxlog_file12,
2802
2842
  L: 318,
2803
2843
  S: this,
2804
2844
  C: (f, a) => f(...a)
@@ -2814,7 +2854,7 @@ var InvitationsHandler = class {
2814
2854
  (0, import_log6.log)("timeout", {
2815
2855
  ...protocol.toJSON()
2816
2856
  }, {
2817
- F: __dxlog_file11,
2857
+ F: __dxlog_file12,
2818
2858
  L: 327,
2819
2859
  S: this,
2820
2860
  C: (f, a) => f(...a)
@@ -2822,7 +2862,7 @@ var InvitationsHandler = class {
2822
2862
  guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
2823
2863
  } else {
2824
2864
  (0, import_log6.log)("auth failed", err, {
2825
- F: __dxlog_file11,
2865
+ F: __dxlog_file12,
2826
2866
  L: 330,
2827
2867
  S: this,
2828
2868
  C: (f, a) => f(...a)
@@ -2840,7 +2880,7 @@ var InvitationsHandler = class {
2840
2880
  await ctx.dispose();
2841
2881
  } else {
2842
2882
  (0, import_invariant6.invariant)(invitation.swarmKey, void 0, {
2843
- F: __dxlog_file11,
2883
+ F: __dxlog_file12,
2844
2884
  L: 345,
2845
2885
  S: this,
2846
2886
  A: [
@@ -2934,16 +2974,29 @@ var InvitationsHandler = class {
2934
2974
  };
2935
2975
  }
2936
2976
  _logStateUpdate(invitation, actor, newState) {
2937
- (0, import_log6.log)("invitation state update", {
2938
- actor: actor?.constructor.name,
2939
- newState: stateToString(newState),
2940
- oldState: stateToString(invitation.state)
2941
- }, {
2942
- F: __dxlog_file11,
2943
- L: 438,
2944
- S: this,
2945
- C: (f, a) => f(...a)
2946
- });
2977
+ if (this._isNotTerminal(newState)) {
2978
+ (0, import_log6.log)("invitation state update", {
2979
+ actor: actor?.constructor.name,
2980
+ newState: stateToString(newState),
2981
+ oldState: stateToString(invitation.state)
2982
+ }, {
2983
+ F: __dxlog_file12,
2984
+ L: 439,
2985
+ S: this,
2986
+ C: (f, a) => f(...a)
2987
+ });
2988
+ } else {
2989
+ import_log6.log.info("invitation state update", {
2990
+ actor: actor?.constructor.name,
2991
+ newState: stateToString(newState),
2992
+ oldState: stateToString(invitation.state)
2993
+ }, {
2994
+ F: __dxlog_file12,
2995
+ L: 445,
2996
+ S: this,
2997
+ C: (f, a) => f(...a)
2998
+ });
2999
+ }
2947
3000
  }
2948
3001
  _isNotTerminal(currentState) {
2949
3002
  return ![
@@ -2957,16 +3010,16 @@ var InvitationsHandler = class {
2957
3010
  async _handleGuestOtpAuth(extension, setState, authenticated, options) {
2958
3011
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2959
3012
  (0, import_log6.log)("guest waiting for authentication code...", void 0, {
2960
- F: __dxlog_file11,
2961
- L: 462,
3013
+ F: __dxlog_file12,
3014
+ L: 470,
2962
3015
  S: this,
2963
3016
  C: (f, a) => f(...a)
2964
3017
  });
2965
3018
  setState(import_services6.Invitation.State.READY_FOR_AUTHENTICATION);
2966
3019
  const authCode = await authenticated.wait(options);
2967
3020
  (0, import_log6.log)("sending authentication request", void 0, {
2968
- F: __dxlog_file11,
2969
- L: 466,
3021
+ F: __dxlog_file12,
3022
+ L: 474,
2970
3023
  S: this,
2971
3024
  C: (f, a) => f(...a)
2972
3025
  });
@@ -2984,8 +3037,8 @@ var InvitationsHandler = class {
2984
3037
  (0, import_log6.log)("retrying invalid code", {
2985
3038
  attempt
2986
3039
  }, {
2987
- F: __dxlog_file11,
2988
- L: 477,
3040
+ F: __dxlog_file12,
3041
+ L: 485,
2989
3042
  S: this,
2990
3043
  C: (f, a) => f(...a)
2991
3044
  });
@@ -3002,8 +3055,8 @@ var InvitationsHandler = class {
3002
3055
  throw new Error("challenge missing in the introduction");
3003
3056
  }
3004
3057
  (0, import_log6.log)("sending authentication request", void 0, {
3005
- F: __dxlog_file11,
3006
- L: 496,
3058
+ F: __dxlog_file12,
3059
+ L: 504,
3007
3060
  S: this,
3008
3061
  C: (f, a) => f(...a)
3009
3062
  });
@@ -3117,7 +3170,7 @@ var InvitationsServiceImpl = class {
3117
3170
  });
3118
3171
  }
3119
3172
  };
3120
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
3173
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
3121
3174
  var SpaceInvitationProtocol = class {
3122
3175
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
3123
3176
  this._spaceManager = _spaceManager;
@@ -3151,79 +3204,43 @@ var SpaceInvitationProtocol = class {
3151
3204
  };
3152
3205
  }
3153
3206
  async admit(invitation, request, guestProfile) {
3154
- (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3155
- F: __dxlog_file12,
3156
- L: 76,
3157
- S: this,
3158
- A: [
3159
- "this._spaceKey",
3160
- ""
3161
- ]
3162
- });
3163
- const space = this._spaceManager.spaces.get(this._spaceKey);
3164
- (0, import_invariant10.invariant)(space, void 0, {
3165
- F: __dxlog_file12,
3166
- L: 78,
3167
- S: this,
3168
- A: [
3169
- "space",
3170
- ""
3171
- ]
3172
- });
3173
- (0, import_invariant10.invariant)(request.space, void 0, {
3174
- F: __dxlog_file12,
3175
- L: 80,
3207
+ (0, import_invariant10.invariant)(this._spaceKey && request.space, void 0, {
3208
+ F: __dxlog_file13,
3209
+ L: 74,
3176
3210
  S: this,
3177
3211
  A: [
3178
- "request.space",
3212
+ "this._spaceKey && request.space",
3179
3213
  ""
3180
3214
  ]
3181
3215
  });
3182
- const { identityKey, deviceKey } = request.space;
3183
- if (space.inner.spaceState.getMemberRole(identityKey) !== import_credentials10.SpaceMember.Role.REMOVED) {
3184
- throw new import_protocols8.AlreadyJoinedError();
3185
- }
3186
3216
  (0, import_log10.log)("writing guest credentials", {
3187
3217
  host: this._signingContext.deviceKey,
3188
- guest: deviceKey
3218
+ guest: request.space.deviceKey
3189
3219
  }, {
3190
- F: __dxlog_file12,
3191
- L: 87,
3220
+ F: __dxlog_file13,
3221
+ L: 75,
3192
3222
  S: this,
3193
3223
  C: (f, a) => f(...a)
3194
3224
  });
3195
- const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, invitation.role ?? import_credentials10.SpaceMember.Role.ADMIN, space.inner.spaceState.membershipChainHeads, guestProfile, invitation.delegationCredentialId);
3196
- (0, import_invariant10.invariant)(credentials[0].credential, void 0, {
3197
- F: __dxlog_file12,
3198
- L: 101,
3199
- S: this,
3200
- A: [
3201
- "credentials[0].credential",
3202
- ""
3203
- ]
3204
- });
3205
- const spaceMemberCredential = credentials[0].credential.credential;
3206
- (0, import_invariant10.invariant)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3207
- F: __dxlog_file12,
3208
- L: 103,
3209
- S: this,
3210
- A: [
3211
- "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
3212
- ""
3213
- ]
3225
+ const spaceMemberCredential = await this._spaceManager.admitMember({
3226
+ spaceKey: this._spaceKey,
3227
+ identityKey: request.space.identityKey,
3228
+ role: invitation.role ?? import_credentials10.SpaceMember.Role.ADMIN,
3229
+ profile: guestProfile,
3230
+ delegationCredentialId: invitation.delegationCredentialId
3214
3231
  });
3215
- await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
3232
+ const space = this._spaceManager.spaces.get(this._spaceKey);
3216
3233
  return {
3217
3234
  space: {
3218
3235
  credential: spaceMemberCredential,
3219
- controlTimeframe: space.inner.controlPipeline.state.timeframe
3236
+ controlTimeframe: space?.inner.controlPipeline.state.timeframe
3220
3237
  }
3221
3238
  };
3222
3239
  }
3223
3240
  async delegate(invitation) {
3224
3241
  (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3225
- F: __dxlog_file12,
3226
- L: 116,
3242
+ F: __dxlog_file13,
3243
+ L: 95,
3227
3244
  S: this,
3228
3245
  A: [
3229
3246
  "this._spaceKey",
@@ -3232,8 +3249,8 @@ var SpaceInvitationProtocol = class {
3232
3249
  });
3233
3250
  const space = this._spaceManager.spaces.get(this._spaceKey);
3234
3251
  (0, import_invariant10.invariant)(space, void 0, {
3235
- F: __dxlog_file12,
3236
- L: 118,
3252
+ F: __dxlog_file13,
3253
+ L: 97,
3237
3254
  S: this,
3238
3255
  A: [
3239
3256
  "space",
@@ -3242,8 +3259,8 @@ var SpaceInvitationProtocol = class {
3242
3259
  });
3243
3260
  if (invitation.authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
3244
3261
  (0, import_invariant10.invariant)(invitation.guestKeypair?.publicKey, void 0, {
3245
- F: __dxlog_file12,
3246
- L: 120,
3262
+ F: __dxlog_file13,
3263
+ L: 99,
3247
3264
  S: this,
3248
3265
  A: [
3249
3266
  "invitation.guestKeypair?.publicKey",
@@ -3255,8 +3272,8 @@ var SpaceInvitationProtocol = class {
3255
3272
  host: this._signingContext.deviceKey,
3256
3273
  id: invitation.invitationId
3257
3274
  }, {
3258
- F: __dxlog_file12,
3259
- L: 123,
3275
+ F: __dxlog_file13,
3276
+ L: 102,
3260
3277
  S: this,
3261
3278
  C: (f, a) => f(...a)
3262
3279
  });
@@ -3270,8 +3287,8 @@ var SpaceInvitationProtocol = class {
3270
3287
  guestKey: invitation.authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
3271
3288
  });
3272
3289
  (0, import_invariant10.invariant)(credential.credential, void 0, {
3273
- F: __dxlog_file12,
3274
- L: 143,
3290
+ F: __dxlog_file13,
3291
+ L: 122,
3275
3292
  S: this,
3276
3293
  A: [
3277
3294
  "credential.credential",
@@ -3285,8 +3302,8 @@ var SpaceInvitationProtocol = class {
3285
3302
  }
3286
3303
  async cancelDelegation(invitation) {
3287
3304
  (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3288
- F: __dxlog_file12,
3289
- L: 149,
3305
+ F: __dxlog_file13,
3306
+ L: 128,
3290
3307
  S: this,
3291
3308
  A: [
3292
3309
  "this._spaceKey",
@@ -3294,8 +3311,8 @@ var SpaceInvitationProtocol = class {
3294
3311
  ]
3295
3312
  });
3296
3313
  (0, import_invariant10.invariant)(invitation.type === import_services10.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
3297
- F: __dxlog_file12,
3298
- L: 150,
3314
+ F: __dxlog_file13,
3315
+ L: 129,
3299
3316
  S: this,
3300
3317
  A: [
3301
3318
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -3304,8 +3321,8 @@ var SpaceInvitationProtocol = class {
3304
3321
  });
3305
3322
  const space = this._spaceManager.spaces.get(this._spaceKey);
3306
3323
  (0, import_invariant10.invariant)(space, void 0, {
3307
- F: __dxlog_file12,
3308
- L: 152,
3324
+ F: __dxlog_file13,
3325
+ L: 131,
3309
3326
  S: this,
3310
3327
  A: [
3311
3328
  "space",
@@ -3316,15 +3333,15 @@ var SpaceInvitationProtocol = class {
3316
3333
  host: this._signingContext.deviceKey,
3317
3334
  id: invitation.invitationId
3318
3335
  }, {
3319
- F: __dxlog_file12,
3320
- L: 154,
3336
+ F: __dxlog_file13,
3337
+ L: 133,
3321
3338
  S: this,
3322
3339
  C: (f, a) => f(...a)
3323
3340
  });
3324
3341
  const credential = await (0, import_credentials9.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
3325
3342
  (0, import_invariant10.invariant)(credential.credential, void 0, {
3326
- F: __dxlog_file12,
3327
- L: 161,
3343
+ F: __dxlog_file13,
3344
+ L: 140,
3328
3345
  S: this,
3329
3346
  A: [
3330
3347
  "credential.credential",
@@ -3362,8 +3379,8 @@ var SpaceInvitationProtocol = class {
3362
3379
  }
3363
3380
  async accept(response) {
3364
3381
  (0, import_invariant10.invariant)(response.space, void 0, {
3365
- F: __dxlog_file12,
3366
- L: 196,
3382
+ F: __dxlog_file13,
3383
+ L: 175,
3367
3384
  S: this,
3368
3385
  A: [
3369
3386
  "response.space",
@@ -3373,8 +3390,8 @@ var SpaceInvitationProtocol = class {
3373
3390
  const { credential, controlTimeframe, dataTimeframe } = response.space;
3374
3391
  const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
3375
3392
  (0, import_invariant10.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3376
- F: __dxlog_file12,
3377
- L: 199,
3393
+ F: __dxlog_file13,
3394
+ L: 178,
3378
3395
  S: this,
3379
3396
  A: [
3380
3397
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3382,8 +3399,8 @@ var SpaceInvitationProtocol = class {
3382
3399
  ]
3383
3400
  });
3384
3401
  (0, import_invariant10.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
3385
- F: __dxlog_file12,
3386
- L: 200,
3402
+ F: __dxlog_file13,
3403
+ L: 179,
3387
3404
  S: this,
3388
3405
  A: [
3389
3406
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -3405,7 +3422,7 @@ var SpaceInvitationProtocol = class {
3405
3422
  };
3406
3423
  }
3407
3424
  };
3408
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3425
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3409
3426
  var InvitationsManager = class {
3410
3427
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
3411
3428
  this._invitationsHandler = _invitationsHandler;
@@ -3448,7 +3465,7 @@ var InvitationsManager = class {
3448
3465
  await this._persistIfRequired(handler, stream, invitation);
3449
3466
  } catch (err) {
3450
3467
  import_log11.log.catch(err, void 0, {
3451
- F: __dxlog_file13,
3468
+ F: __dxlog_file14,
3452
3469
  L: 82,
3453
3470
  S: this,
3454
3471
  C: (f, a) => f(...a)
@@ -3471,7 +3488,7 @@ var InvitationsManager = class {
3471
3488
  const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
3472
3489
  const loadTasks = freshInvitations.map((persistentInvitation) => {
3473
3490
  (0, import_invariant11.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
3474
- F: __dxlog_file13,
3491
+ F: __dxlog_file14,
3475
3492
  L: 103,
3476
3493
  S: this,
3477
3494
  A: [
@@ -3490,7 +3507,7 @@ var InvitationsManager = class {
3490
3507
  };
3491
3508
  } catch (err) {
3492
3509
  import_log11.log.catch(err, void 0, {
3493
- F: __dxlog_file13,
3510
+ F: __dxlog_file14,
3494
3511
  L: 110,
3495
3512
  S: this,
3496
3513
  C: (f, a) => f(...a)
@@ -3522,13 +3539,13 @@ var InvitationsManager = class {
3522
3539
  }
3523
3540
  async authenticate({ invitationId, authCode }) {
3524
3541
  (0, import_log11.log)("authenticating...", void 0, {
3525
- F: __dxlog_file13,
3542
+ F: __dxlog_file14,
3526
3543
  L: 140,
3527
3544
  S: this,
3528
3545
  C: (f, a) => f(...a)
3529
3546
  });
3530
3547
  (0, import_invariant11.invariant)(invitationId, void 0, {
3531
- F: __dxlog_file13,
3548
+ F: __dxlog_file14,
3532
3549
  L: 141,
3533
3550
  S: this,
3534
3551
  A: [
@@ -3541,7 +3558,7 @@ var InvitationsManager = class {
3541
3558
  import_log11.log.warn("invalid invitation", {
3542
3559
  invitationId
3543
3560
  }, {
3544
- F: __dxlog_file13,
3561
+ F: __dxlog_file14,
3545
3562
  L: 144,
3546
3563
  S: this,
3547
3564
  C: (f, a) => f(...a)
@@ -3554,13 +3571,13 @@ var InvitationsManager = class {
3554
3571
  (0, import_log11.log)("cancelInvitation...", {
3555
3572
  invitationId
3556
3573
  }, {
3557
- F: __dxlog_file13,
3574
+ F: __dxlog_file14,
3558
3575
  L: 151,
3559
3576
  S: this,
3560
3577
  C: (f, a) => f(...a)
3561
3578
  });
3562
3579
  (0, import_invariant11.invariant)(invitationId, void 0, {
3563
- F: __dxlog_file13,
3580
+ F: __dxlog_file14,
3564
3581
  L: 152,
3565
3582
  S: this,
3566
3583
  A: [
@@ -3634,12 +3651,15 @@ var InvitationsManager = class {
3634
3651
  stream.error(err);
3635
3652
  void ctx.dispose();
3636
3653
  }
3654
+ }, {
3655
+ F: __dxlog_file14,
3656
+ L: 234
3637
3657
  });
3638
3658
  ctx.onDispose(() => {
3639
3659
  (0, import_log11.log)("complete", {
3640
3660
  ...handler.toJSON()
3641
3661
  }, {
3642
- F: __dxlog_file13,
3662
+ F: __dxlog_file14,
3643
3663
  L: 241,
3644
3664
  S: this,
3645
3665
  C: (f, a) => f(...a)
@@ -3672,7 +3692,7 @@ var InvitationsManager = class {
3672
3692
  (0, import_log11.log)("timeout", {
3673
3693
  ...handler.toJSON()
3674
3694
  }, {
3675
- F: __dxlog_file13,
3695
+ F: __dxlog_file14,
3676
3696
  L: 261,
3677
3697
  S: this,
3678
3698
  C: (f, a) => f(...a)
@@ -3683,7 +3703,7 @@ var InvitationsManager = class {
3683
3703
  });
3684
3704
  } else {
3685
3705
  import_log11.log.warn("auth failed", err, {
3686
- F: __dxlog_file13,
3706
+ F: __dxlog_file14,
3687
3707
  L: 264,
3688
3708
  S: this,
3689
3709
  C: (f, a) => f(...a)
@@ -3695,12 +3715,15 @@ var InvitationsManager = class {
3695
3715
  }
3696
3716
  void ctx.dispose();
3697
3717
  }
3718
+ }, {
3719
+ F: __dxlog_file14,
3720
+ L: 258
3698
3721
  });
3699
3722
  ctx.onDispose(() => {
3700
3723
  (0, import_log11.log)("complete", {
3701
3724
  ...handler.toJSON()
3702
3725
  }, {
3703
- F: __dxlog_file13,
3726
+ F: __dxlog_file14,
3704
3727
  L: 271,
3705
3728
  S: this,
3706
3729
  C: (f, a) => f(...a)
@@ -3745,7 +3768,7 @@ var InvitationsManager = class {
3745
3768
  await this._metadataStore.removeInvitation(invitation.invitationId);
3746
3769
  } catch (err) {
3747
3770
  import_log11.log.catch(err, void 0, {
3748
- F: __dxlog_file13,
3771
+ F: __dxlog_file14,
3749
3772
  L: 307,
3750
3773
  S: this,
3751
3774
  C: (f, a) => f(...a)
@@ -3798,12 +3821,13 @@ var AutomergeSpaceState = class extends import_context11.Resource {
3798
3821
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3799
3822
  }
3800
3823
  };
3801
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
3824
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
3825
+ var LOAD_DOC_TIMEOUT = 1e4;
3802
3826
  var runEpochMigration = async (ctx, context) => {
3803
3827
  switch (context.migration) {
3804
3828
  case import_services13.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
3805
- const document = context.repo.create();
3806
- await context.repo.flush();
3829
+ const document = context.echoHost.createDoc();
3830
+ await context.echoHost.flush();
3807
3831
  return {
3808
3832
  newRoot: document.url
3809
3833
  };
@@ -3812,77 +3836,88 @@ var runEpochMigration = async (ctx, context) => {
3812
3836
  if (!context.currentRoot) {
3813
3837
  throw new Error("Space does not have an automerge root");
3814
3838
  }
3815
- const rootHandle = context.repo.find(context.currentRoot);
3816
- await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
3817
- const newRoot = context.repo.create(rootHandle.docSync());
3818
- await context.repo.flush();
3839
+ const rootHandle = await context.echoHost.loadDoc(ctx, context.currentRoot, {
3840
+ timeout: LOAD_DOC_TIMEOUT
3841
+ });
3842
+ const newRoot = context.echoHost.createDoc(rootHandle.docSync());
3843
+ await context.echoHost.flush();
3819
3844
  return {
3820
3845
  newRoot: newRoot.url
3821
3846
  };
3822
3847
  }
3823
3848
  case import_services13.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
3824
3849
  import_log13.log.info("Fragmenting", void 0, {
3825
- F: __dxlog_file14,
3826
- L: 63,
3850
+ F: __dxlog_file15,
3851
+ L: 64,
3827
3852
  S: void 0,
3828
3853
  C: (f, a) => f(...a)
3829
3854
  });
3830
3855
  const currentRootUrl = context.currentRoot;
3831
- const rootHandle = context.repo.find(currentRootUrl);
3832
- await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
3856
+ const rootHandle = await context.echoHost.loadDoc(ctx, currentRootUrl, {
3857
+ timeout: LOAD_DOC_TIMEOUT
3858
+ });
3833
3859
  const objects = Object.entries(rootHandle.docSync().objects);
3834
3860
  const properties = (0, import_echo_db.findInlineObjectOfType)(rootHandle.docSync(), import_echo_schema.TYPE_PROPERTIES);
3835
3861
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3836
3862
  (0, import_invariant13.invariant)(properties, "Properties not found", {
3837
- F: __dxlog_file14,
3838
- L: 73,
3863
+ F: __dxlog_file15,
3864
+ L: 75,
3839
3865
  S: void 0,
3840
3866
  A: [
3841
3867
  "properties",
3842
3868
  "'Properties not found'"
3843
3869
  ]
3844
3870
  });
3845
- const newSpaceDoc = {
3871
+ const newRoot = context.echoHost.createDoc({
3846
3872
  ...rootHandle.docSync(),
3847
3873
  objects: Object.fromEntries([
3848
3874
  properties
3849
3875
  ])
3850
- };
3851
- const newRoot = context.repo.create(newSpaceDoc);
3876
+ });
3852
3877
  (0, import_invariant13.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3853
- F: __dxlog_file14,
3854
- L: 78,
3878
+ F: __dxlog_file15,
3879
+ L: 82,
3855
3880
  S: void 0,
3856
3881
  A: [
3857
3882
  "typeof newRoot.url === 'string' && newRoot.url.length > 0",
3858
3883
  ""
3859
3884
  ]
3860
3885
  });
3861
- const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(context.spaceId, context.repo, context.spaceKey);
3862
- await docLoader.loadSpaceRootDocHandle(ctx, {
3863
- rootUrl: newRoot.url
3864
- });
3865
- otherObjects.forEach(([key, value]) => {
3866
- const handle = docLoader.createDocumentForObject(key);
3867
- handle.change((doc) => {
3868
- (0, import_util8.assignDeep)(doc, [
3869
- "objects",
3870
- key
3871
- ], value);
3886
+ const newLinks = [];
3887
+ for (const [id, objData] of otherObjects) {
3888
+ const handle = context.echoHost.createDoc({
3889
+ version: import_echo_protocol2.SpaceDocVersion.CURRENT,
3890
+ access: {
3891
+ spaceKey: context.spaceKey.toHex()
3892
+ },
3893
+ objects: {
3894
+ [id]: objData
3895
+ }
3872
3896
  });
3897
+ newLinks.push([
3898
+ id,
3899
+ handle.url
3900
+ ]);
3901
+ }
3902
+ newRoot.change((doc) => {
3903
+ doc.links ??= {};
3904
+ for (const [id, url] of newLinks) {
3905
+ doc.links[id] = url;
3906
+ }
3873
3907
  });
3874
- await context.repo.flush();
3908
+ await context.echoHost.flush();
3875
3909
  return {
3876
3910
  newRoot: newRoot.url
3877
3911
  };
3878
3912
  }
3879
3913
  case import_services13.CreateEpochRequest.Migration.MIGRATE_REFERENCES_TO_DXN: {
3880
3914
  const currentRootUrl = context.currentRoot;
3881
- const rootHandle = context.repo.find(currentRootUrl);
3882
- await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
3915
+ const rootHandle = await context.echoHost.loadDoc(ctx, currentRootUrl, {
3916
+ timeout: LOAD_DOC_TIMEOUT
3917
+ });
3883
3918
  (0, import_invariant13.invariant)(rootHandle.docSync(), "Root doc not found", {
3884
- F: __dxlog_file14,
3885
- L: 100,
3919
+ F: __dxlog_file15,
3920
+ L: 115,
3886
3921
  S: void 0,
3887
3922
  A: [
3888
3923
  "rootHandle.docSync()",
@@ -3891,40 +3926,59 @@ var runEpochMigration = async (ctx, context) => {
3891
3926
  });
3892
3927
  const newRootContent = await (0, import_echo_db.convertLegacySpaceRootDoc)(structuredClone(rootHandle.docSync()));
3893
3928
  for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
3894
- const handle = context.repo.find(url);
3895
- await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(handle.whenReady(), 1e4));
3896
- (0, import_invariant13.invariant)(handle.docSync(), "Doc not found", {
3897
- F: __dxlog_file14,
3898
- L: 107,
3899
- S: void 0,
3900
- A: [
3901
- "handle.docSync()",
3902
- "'Doc not found'"
3903
- ]
3904
- });
3905
- const newDoc = await (0, import_echo_db.convertLegacyReferences)(structuredClone(handle.docSync()));
3906
- const migratedDoc = (0, import_echo_db.migrateDocument)(handle.docSync(), newDoc);
3907
- const newHandle = context.repo.import(import_automerge.next.save(migratedDoc));
3908
- newRootContent.links[id] = newHandle.url;
3929
+ try {
3930
+ const handle = await context.echoHost.loadDoc(ctx, url, {
3931
+ timeout: LOAD_DOC_TIMEOUT
3932
+ });
3933
+ (0, import_invariant13.invariant)(handle.docSync(), void 0, {
3934
+ F: __dxlog_file15,
3935
+ L: 122,
3936
+ S: void 0,
3937
+ A: [
3938
+ "handle.docSync()",
3939
+ ""
3940
+ ]
3941
+ });
3942
+ const newDoc = await (0, import_echo_db.convertLegacyReferences)(structuredClone(handle.docSync()));
3943
+ const migratedDoc = (0, import_echo_db.migrateDocument)(handle.docSync(), newDoc);
3944
+ const newHandle = context.echoHost.createDoc(migratedDoc, {
3945
+ preserveHistory: true
3946
+ });
3947
+ newRootContent.links[id] = newHandle.url;
3948
+ } catch (err) {
3949
+ import_log13.log.warn("Failed to migrate reference", {
3950
+ id,
3951
+ url,
3952
+ error: err
3953
+ }, {
3954
+ F: __dxlog_file15,
3955
+ L: 128,
3956
+ S: void 0,
3957
+ C: (f, a) => f(...a)
3958
+ });
3959
+ delete newRootContent.links[id];
3960
+ }
3909
3961
  }
3910
3962
  const migratedRoot = (0, import_echo_db.migrateDocument)(rootHandle.docSync(), newRootContent);
3911
- const newRoot = context.repo.import(import_automerge.next.save(migratedRoot));
3912
- await context.repo.flush();
3963
+ const newRoot = context.echoHost.createDoc(migratedRoot, {
3964
+ preserveHistory: true
3965
+ });
3966
+ await context.echoHost.flush();
3913
3967
  return {
3914
3968
  newRoot: newRoot.url
3915
3969
  };
3916
3970
  }
3917
3971
  case import_services13.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
3918
3972
  (0, import_invariant13.invariant)(context.newAutomergeRoot, void 0, {
3919
- F: __dxlog_file14,
3920
- L: 124,
3973
+ F: __dxlog_file15,
3974
+ L: 143,
3921
3975
  S: void 0,
3922
3976
  A: [
3923
3977
  "context.newAutomergeRoot",
3924
3978
  ""
3925
3979
  ]
3926
3980
  });
3927
- await context.repo.flush();
3981
+ await context.echoHost.flush();
3928
3982
  return {
3929
3983
  newRoot: context.newAutomergeRoot
3930
3984
  };
@@ -3932,18 +3986,21 @@ var runEpochMigration = async (ctx, context) => {
3932
3986
  }
3933
3987
  return {};
3934
3988
  };
3935
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3989
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3936
3990
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3937
3991
  var DEFAULT_SUCCESS_DELAY = 1e3;
3938
3992
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
3939
3993
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3940
3994
  var NotarizationPlugin = class {
3941
3995
  constructor() {
3942
- this._ctx = new import_context13.Context();
3943
- this._extensionOpened = new import_async16.Event();
3996
+ this._ctx = new import_context12.Context(void 0, {
3997
+ F: __dxlog_file16,
3998
+ L: 62
3999
+ });
4000
+ this._extensionOpened = new import_async15.Event();
3944
4001
  this._extensions = /* @__PURE__ */ new Set();
3945
- this._processedCredentials = new import_util9.ComplexSet(import_keys11.PublicKey.hash);
3946
- this._processCredentialsTriggers = new import_util9.ComplexMap(import_keys11.PublicKey.hash);
4002
+ this._processedCredentials = new import_util8.ComplexSet(import_keys11.PublicKey.hash);
4003
+ this._processCredentialsTriggers = new import_util8.ComplexMap(import_keys11.PublicKey.hash);
3947
4004
  }
3948
4005
  get hasWriter() {
3949
4006
  return !!this._writer;
@@ -3960,13 +4017,13 @@ var NotarizationPlugin = class {
3960
4017
  (0, import_log14.log)("notarize", {
3961
4018
  credentials
3962
4019
  }, {
3963
- F: __dxlog_file15,
4020
+ F: __dxlog_file16,
3964
4021
  L: 90,
3965
4022
  S: this,
3966
4023
  C: (f, a) => f(...a)
3967
4024
  });
3968
4025
  (0, import_invariant14.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
3969
- F: __dxlog_file15,
4026
+ F: __dxlog_file16,
3970
4027
  L: 91,
3971
4028
  S: this,
3972
4029
  A: [
@@ -3974,13 +4031,13 @@ var NotarizationPlugin = class {
3974
4031
  "'Credentials must have an id'"
3975
4032
  ]
3976
4033
  });
3977
- const errors = new import_async16.Trigger();
4034
+ const errors = new import_async15.Trigger();
3978
4035
  const ctx = this._ctx.derive({
3979
4036
  onError: (err) => {
3980
4037
  import_log14.log.warn("Notarization error", {
3981
4038
  err
3982
4039
  }, {
3983
- F: __dxlog_file15,
4040
+ F: __dxlog_file16,
3984
4041
  L: 99,
3985
4042
  S: this,
3986
4043
  C: (f, a) => f(...a)
@@ -3991,23 +4048,23 @@ var NotarizationPlugin = class {
3991
4048
  });
3992
4049
  opCtx?.onDispose(() => ctx.dispose());
3993
4050
  if (timeout !== 0) {
3994
- (0, import_async16.scheduleTask)(ctx, () => {
4051
+ (0, import_async15.scheduleTask)(ctx, () => {
3995
4052
  import_log14.log.warn("Notarization timeout", {
3996
4053
  timeout,
3997
4054
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
3998
4055
  }, {
3999
- F: __dxlog_file15,
4056
+ F: __dxlog_file16,
4000
4057
  L: 111,
4001
4058
  S: this,
4002
4059
  C: (f, a) => f(...a)
4003
4060
  });
4004
4061
  void ctx.dispose();
4005
- errors.throw(new import_async16.TimeoutError(timeout, "Notarization timed out"));
4062
+ errors.throw(new import_async15.TimeoutError(timeout, "Notarization timed out"));
4006
4063
  }, timeout);
4007
4064
  }
4008
4065
  const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
4009
4066
  const peersTried = /* @__PURE__ */ new Set();
4010
- const notarizeTask = new import_async16.DeferredTask(ctx, async () => {
4067
+ const notarizeTask = new import_async15.DeferredTask(ctx, async () => {
4011
4068
  try {
4012
4069
  if (this._extensions.size === 0) {
4013
4070
  return;
@@ -4019,13 +4076,13 @@ var NotarizationPlugin = class {
4019
4076
  import_log14.log.info("Exhausted all peers to notarize with", {
4020
4077
  retryIn: retryTimeout
4021
4078
  }, {
4022
- F: __dxlog_file15,
4079
+ F: __dxlog_file16,
4023
4080
  L: 136,
4024
4081
  S: this,
4025
4082
  C: (f, a) => f(...a)
4026
4083
  });
4027
4084
  peersTried.clear();
4028
- (0, import_async16.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
4085
+ (0, import_async15.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
4029
4086
  return;
4030
4087
  }
4031
4088
  peersTried.add(peer);
@@ -4033,7 +4090,7 @@ var NotarizationPlugin = class {
4033
4090
  peer: peer.localPeerId,
4034
4091
  credentialId: credentials.map((credential) => credential.id)
4035
4092
  }, {
4036
- F: __dxlog_file15,
4093
+ F: __dxlog_file16,
4037
4094
  L: 143,
4038
4095
  S: this,
4039
4096
  C: (f, a) => f(...a)
@@ -4042,16 +4099,16 @@ var NotarizationPlugin = class {
4042
4099
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
4043
4100
  });
4044
4101
  (0, import_log14.log)("success", void 0, {
4045
- F: __dxlog_file15,
4102
+ F: __dxlog_file16,
4046
4103
  L: 147,
4047
4104
  S: this,
4048
4105
  C: (f, a) => f(...a)
4049
4106
  });
4050
- await (0, import_async16.sleep)(successDelay);
4107
+ await (0, import_async15.sleep)(successDelay);
4051
4108
  } catch (err) {
4052
4109
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
4053
4110
  import_log14.log.info("error notarizing (recoverable)", err, {
4054
- F: __dxlog_file15,
4111
+ F: __dxlog_file16,
4055
4112
  L: 151,
4056
4113
  S: this,
4057
4114
  C: (f, a) => f(...a)
@@ -4064,12 +4121,12 @@ var NotarizationPlugin = class {
4064
4121
  this._extensionOpened.on(ctx, () => notarizeTask.schedule());
4065
4122
  try {
4066
4123
  await Promise.race([
4067
- (0, import_context13.rejectOnDispose)(ctx),
4124
+ (0, import_context12.rejectOnDispose)(ctx),
4068
4125
  allNotarized,
4069
4126
  errors.wait()
4070
4127
  ]);
4071
4128
  (0, import_log14.log)("done", void 0, {
4072
- F: __dxlog_file15,
4129
+ F: __dxlog_file16,
4073
4130
  L: 162,
4074
4131
  S: this,
4075
4132
  C: (f, a) => f(...a)
@@ -4091,7 +4148,7 @@ var NotarizationPlugin = class {
4091
4148
  }
4092
4149
  setWriter(writer) {
4093
4150
  (0, import_invariant14.invariant)(!this._writer, "Writer already set.", {
4094
- F: __dxlog_file15,
4151
+ F: __dxlog_file16,
4095
4152
  L: 181,
4096
4153
  S: this,
4097
4154
  A: [
@@ -4105,7 +4162,7 @@ var NotarizationPlugin = class {
4105
4162
  if (this._processedCredentials.has(id)) {
4106
4163
  return;
4107
4164
  }
4108
- await (0, import_util9.entry)(this._processCredentialsTriggers, id).orInsert(new import_async16.Trigger()).value.wait();
4165
+ await (0, import_util8.entry)(this._processCredentialsTriggers, id).orInsert(new import_async15.Trigger()).value.wait();
4109
4166
  }
4110
4167
  /**
4111
4168
  * Requests from other peers to notarize credentials.
@@ -4116,7 +4173,7 @@ var NotarizationPlugin = class {
4116
4173
  }
4117
4174
  for (const credential of request.credentials ?? []) {
4118
4175
  (0, import_invariant14.invariant)(credential.id, "Credential must have an id", {
4119
- F: __dxlog_file15,
4176
+ F: __dxlog_file16,
4120
4177
  L: 200,
4121
4178
  S: this,
4122
4179
  A: [
@@ -4136,7 +4193,7 @@ var NotarizationPlugin = class {
4136
4193
  (0, import_log14.log)("extension opened", {
4137
4194
  peer: extension.localPeerId
4138
4195
  }, {
4139
- F: __dxlog_file15,
4196
+ F: __dxlog_file16,
4140
4197
  L: 211,
4141
4198
  S: this,
4142
4199
  C: (f, a) => f(...a)
@@ -4148,7 +4205,7 @@ var NotarizationPlugin = class {
4148
4205
  (0, import_log14.log)("extension closed", {
4149
4206
  peer: extension.localPeerId
4150
4207
  }, {
4151
- F: __dxlog_file15,
4208
+ F: __dxlog_file16,
4152
4209
  L: 216,
4153
4210
  S: this,
4154
4211
  C: (f, a) => f(...a)
@@ -4263,10 +4320,13 @@ function _using_ctx() {
4263
4320
  }
4264
4321
  };
4265
4322
  }
4266
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4323
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4267
4324
  var DataSpace = class {
4268
4325
  constructor(params) {
4269
- this._ctx = new import_context10.Context();
4326
+ this._ctx = new import_context10.Context(void 0, {
4327
+ F: __dxlog_file17,
4328
+ L: 84
4329
+ });
4270
4330
  this._notarizationPlugin = new NotarizationPlugin();
4271
4331
  this._cache = void 0;
4272
4332
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
@@ -4296,7 +4356,7 @@ var DataSpace = class {
4296
4356
  (0, import_log12.log)("new state", {
4297
4357
  state: import_services12.SpaceState[this._state]
4298
4358
  }, {
4299
- F: __dxlog_file16,
4359
+ F: __dxlog_file17,
4300
4360
  L: 146,
4301
4361
  S: this,
4302
4362
  C: (f, a) => f(...a)
@@ -4351,12 +4411,15 @@ var DataSpace = class {
4351
4411
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
4352
4412
  await this._automergeSpaceState.open();
4353
4413
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
4354
- await this._inner.open(new import_context10.Context());
4414
+ await this._inner.open(new import_context10.Context(void 0, {
4415
+ F: __dxlog_file17,
4416
+ L: 215
4417
+ }));
4355
4418
  this._state = import_services12.SpaceState.CONTROL_ONLY;
4356
4419
  (0, import_log12.log)("new state", {
4357
4420
  state: import_services12.SpaceState[this._state]
4358
4421
  }, {
4359
- F: __dxlog_file16,
4422
+ F: __dxlog_file17,
4360
4423
  L: 217,
4361
4424
  S: this,
4362
4425
  C: (f, a) => f(...a)
@@ -4374,13 +4437,16 @@ var DataSpace = class {
4374
4437
  (0, import_log12.log)("new state", {
4375
4438
  state: import_services12.SpaceState[this._state]
4376
4439
  }, {
4377
- F: __dxlog_file16,
4440
+ F: __dxlog_file17,
4378
4441
  L: 231,
4379
4442
  S: this,
4380
4443
  C: (f, a) => f(...a)
4381
4444
  });
4382
4445
  await this._ctx.dispose();
4383
- this._ctx = new import_context10.Context();
4446
+ this._ctx = new import_context10.Context(void 0, {
4447
+ F: __dxlog_file17,
4448
+ L: 233
4449
+ });
4384
4450
  await this.authVerifier.close();
4385
4451
  await this._inner.close();
4386
4452
  await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
@@ -4407,7 +4473,7 @@ var DataSpace = class {
4407
4473
  } catch (err) {
4408
4474
  if (err instanceof import_protocols9.CancelledError || err instanceof import_context10.ContextDisposedError) {
4409
4475
  (0, import_log12.log)("data pipeline initialization cancelled", err, {
4410
- F: __dxlog_file16,
4476
+ F: __dxlog_file17,
4411
4477
  L: 265,
4412
4478
  S: this,
4413
4479
  C: (f, a) => f(...a)
@@ -4415,7 +4481,7 @@ var DataSpace = class {
4415
4481
  return;
4416
4482
  }
4417
4483
  import_log12.log.error("Error initializing data pipeline", err, {
4418
- F: __dxlog_file16,
4484
+ F: __dxlog_file17,
4419
4485
  L: 269,
4420
4486
  S: this,
4421
4487
  C: (f, a) => f(...a)
@@ -4424,7 +4490,7 @@ var DataSpace = class {
4424
4490
  (0, import_log12.log)("new state", {
4425
4491
  state: import_services12.SpaceState[this._state]
4426
4492
  }, {
4427
- F: __dxlog_file16,
4493
+ F: __dxlog_file17,
4428
4494
  L: 271,
4429
4495
  S: this,
4430
4496
  C: (f, a) => f(...a)
@@ -4444,7 +4510,7 @@ var DataSpace = class {
4444
4510
  (0, import_log12.log)("new state", {
4445
4511
  state: import_services12.SpaceState[this._state]
4446
4512
  }, {
4447
- F: __dxlog_file16,
4513
+ F: __dxlog_file17,
4448
4514
  L: 287,
4449
4515
  S: this,
4450
4516
  C: (f, a) => f(...a)
@@ -4461,7 +4527,7 @@ var DataSpace = class {
4461
4527
  (0, import_log12.log)("new state", {
4462
4528
  state: import_services12.SpaceState[this._state]
4463
4529
  }, {
4464
- F: __dxlog_file16,
4530
+ F: __dxlog_file17,
4465
4531
  L: 306,
4466
4532
  S: this,
4467
4533
  C: (f, a) => f(...a)
@@ -4477,7 +4543,7 @@ var DataSpace = class {
4477
4543
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
4478
4544
  await this._createWritableFeeds();
4479
4545
  (0, import_log12.log)("writable feeds created", void 0, {
4480
- F: __dxlog_file16,
4546
+ F: __dxlog_file17,
4481
4547
  L: 322,
4482
4548
  S: this,
4483
4549
  C: (f, a) => f(...a)
@@ -4540,7 +4606,7 @@ var DataSpace = class {
4540
4606
  space: this.key,
4541
4607
  rootUrl
4542
4608
  }, {
4543
- F: __dxlog_file16,
4609
+ F: __dxlog_file17,
4544
4610
  L: 388,
4545
4611
  S: this,
4546
4612
  C: (f, a) => f(...a)
@@ -4594,8 +4660,8 @@ var DataSpace = class {
4594
4660
  rootUrl,
4595
4661
  err
4596
4662
  }, {
4597
- F: __dxlog_file16,
4598
- L: 431,
4663
+ F: __dxlog_file17,
4664
+ L: 433,
4599
4665
  S: this,
4600
4666
  C: (f, a) => f(...a)
4601
4667
  });
@@ -4623,7 +4689,7 @@ var DataSpace = class {
4623
4689
  return null;
4624
4690
  }
4625
4691
  const { newRoot } = await runEpochMigration(ctx, {
4626
- repo: this._echoHost.automergeRepo,
4692
+ echoHost: this._echoHost,
4627
4693
  spaceId: this.id,
4628
4694
  spaceKey: this.key,
4629
4695
  migration: options.migration,
@@ -4680,8 +4746,8 @@ var DataSpace = class {
4680
4746
  (0, import_log12.log)("new state", {
4681
4747
  state: import_services12.SpaceState[this._state]
4682
4748
  }, {
4683
- F: __dxlog_file16,
4684
- L: 512,
4749
+ F: __dxlog_file17,
4750
+ L: 514,
4685
4751
  S: this,
4686
4752
  C: (f, a) => f(...a)
4687
4753
  });
@@ -4810,7 +4876,7 @@ function _ts_decorate5(decorators, target, key, desc) {
4810
4876
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4811
4877
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4812
4878
  }
4813
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4879
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4814
4880
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
4815
4881
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
4816
4882
  var DEFAULT_SPACE_KEY = "__DEFAULT__";
@@ -4824,9 +4890,12 @@ var DataSpaceManager = class {
4824
4890
  this._echoHost = _echoHost;
4825
4891
  this._invitationsManager = _invitationsManager;
4826
4892
  this._params = _params;
4827
- this._ctx = new import_context14.Context();
4828
- this.updated = new import_async17.Event();
4829
- this._spaces = new import_util10.ComplexMap(import_keys12.PublicKey.hash);
4893
+ this._ctx = new import_context13.Context(void 0, {
4894
+ F: __dxlog_file18,
4895
+ L: 104
4896
+ });
4897
+ this.updated = new import_async16.Event();
4898
+ this._spaces = new import_util9.ComplexMap(import_keys12.PublicKey.hash);
4830
4899
  this._isOpen = false;
4831
4900
  this._instanceId = import_keys12.PublicKey.random().toHex();
4832
4901
  import_tracing6.trace.diagnostic({
@@ -4858,34 +4927,34 @@ var DataSpaceManager = class {
4858
4927
  }
4859
4928
  async open() {
4860
4929
  (0, import_log15.log)("open", void 0, {
4861
- F: __dxlog_file17,
4862
- L: 146,
4930
+ F: __dxlog_file18,
4931
+ L: 156,
4863
4932
  S: this,
4864
4933
  C: (f, a) => f(...a)
4865
4934
  });
4866
4935
  import_log15.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
4867
4936
  id: this._instanceId
4868
4937
  }), {
4869
- F: __dxlog_file17,
4870
- L: 147,
4938
+ F: __dxlog_file18,
4939
+ L: 157,
4871
4940
  S: this,
4872
4941
  C: (f, a) => f(...a)
4873
4942
  });
4874
4943
  (0, import_log15.log)("metadata loaded", {
4875
4944
  spaces: this._metadataStore.spaces.length
4876
4945
  }, {
4877
- F: __dxlog_file17,
4878
- L: 148,
4946
+ F: __dxlog_file18,
4947
+ L: 158,
4879
4948
  S: this,
4880
4949
  C: (f, a) => f(...a)
4881
4950
  });
4882
- await (0, import_util10.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
4951
+ await (0, import_util9.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
4883
4952
  try {
4884
4953
  (0, import_log15.log)("load space", {
4885
4954
  spaceMetadata
4886
4955
  }, {
4887
- F: __dxlog_file17,
4888
- L: 152,
4956
+ F: __dxlog_file18,
4957
+ L: 162,
4889
4958
  S: this,
4890
4959
  C: (f, a) => f(...a)
4891
4960
  });
@@ -4895,8 +4964,8 @@ var DataSpaceManager = class {
4895
4964
  spaceMetadata,
4896
4965
  err
4897
4966
  }, {
4898
- F: __dxlog_file17,
4899
- L: 155,
4967
+ F: __dxlog_file18,
4968
+ L: 165,
4900
4969
  S: this,
4901
4970
  C: (f, a) => f(...a)
4902
4971
  });
@@ -4907,16 +4976,16 @@ var DataSpaceManager = class {
4907
4976
  import_log15.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
4908
4977
  id: this._instanceId
4909
4978
  }), {
4910
- F: __dxlog_file17,
4911
- L: 162,
4979
+ F: __dxlog_file18,
4980
+ L: 172,
4912
4981
  S: this,
4913
4982
  C: (f, a) => f(...a)
4914
4983
  });
4915
4984
  }
4916
4985
  async close() {
4917
4986
  (0, import_log15.log)("close", void 0, {
4918
- F: __dxlog_file17,
4919
- L: 167,
4987
+ F: __dxlog_file18,
4988
+ L: 177,
4920
4989
  S: this,
4921
4990
  C: (f, a) => f(...a)
4922
4991
  });
@@ -4932,8 +5001,8 @@ var DataSpaceManager = class {
4932
5001
  */
4933
5002
  async createSpace() {
4934
5003
  (0, import_invariant15.invariant)(this._isOpen, "Not open.", {
4935
- F: __dxlog_file17,
4936
- L: 181,
5004
+ F: __dxlog_file18,
5005
+ L: 191,
4937
5006
  S: this,
4938
5007
  A: [
4939
5008
  "this._isOpen",
@@ -4953,8 +5022,8 @@ var DataSpaceManager = class {
4953
5022
  (0, import_log15.log)("creating space...", {
4954
5023
  spaceKey
4955
5024
  }, {
4956
- F: __dxlog_file17,
4957
- L: 193,
5025
+ F: __dxlog_file18,
5026
+ L: 203,
4958
5027
  S: this,
4959
5028
  C: (f, a) => f(...a)
4960
5029
  });
@@ -4965,8 +5034,8 @@ var DataSpaceManager = class {
4965
5034
  await this._metadataStore.addSpace(metadata);
4966
5035
  const memberCredential = credentials[1];
4967
5036
  (0, import_invariant15.invariant)((0, import_credentials15.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4968
- F: __dxlog_file17,
4969
- L: 203,
5037
+ F: __dxlog_file18,
5038
+ L: 213,
4970
5039
  S: this,
4971
5040
  A: [
4972
5041
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -4983,13 +5052,13 @@ var DataSpaceManager = class {
4983
5052
  return false;
4984
5053
  }
4985
5054
  switch (space.databaseRoot.getVersion()) {
4986
- case import_echo_protocol2.SpaceDocVersion.CURRENT: {
5055
+ case import_echo_protocol3.SpaceDocVersion.CURRENT: {
4987
5056
  const [_, properties] = (0, import_echo_db2.findInlineObjectOfType)(space.databaseRoot.docSync(), import_echo_schema2.TYPE_PROPERTIES) ?? [];
4988
5057
  return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
4989
5058
  }
4990
- case import_echo_protocol2.SpaceDocVersion.LEGACY: {
5059
+ case import_echo_protocol3.SpaceDocVersion.LEGACY: {
4991
5060
  const convertedDoc = await (0, import_echo_db2.convertLegacyReferences)(space.databaseRoot.docSync());
4992
- const [_, properties] = (0, import_echo_db2.findInlineObjectOfType)(convertedDoc, import_echo_protocol2.LEGACY_TYPE_PROPERTIES) ?? [];
5061
+ const [_, properties] = (0, import_echo_db2.findInlineObjectOfType)(convertedDoc, import_echo_protocol3.LEGACY_TYPE_PROPERTIES) ?? [];
4993
5062
  return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
4994
5063
  }
4995
5064
  default:
@@ -4997,8 +5066,8 @@ var DataSpaceManager = class {
4997
5066
  version: space.databaseRoot.getVersion(),
4998
5067
  spaceId: space.id
4999
5068
  }, {
5000
- F: __dxlog_file17,
5001
- L: 228,
5069
+ F: __dxlog_file18,
5070
+ L: 238,
5002
5071
  S: this,
5003
5072
  C: (f, a) => f(...a)
5004
5073
  });
@@ -5010,7 +5079,7 @@ var DataSpaceManager = class {
5010
5079
  const document = await this._getSpaceRootDocument(space);
5011
5080
  const properties = {
5012
5081
  system: {
5013
- type: (0, import_echo_protocol2.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.PropertiesType))
5082
+ type: (0, import_echo_protocol3.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.PropertiesType))
5014
5083
  },
5015
5084
  data: {
5016
5085
  [DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
@@ -5021,7 +5090,7 @@ var DataSpaceManager = class {
5021
5090
  };
5022
5091
  const propertiesId = (0, import_echo_schema2.generateEchoId)();
5023
5092
  document.change((doc) => {
5024
- (0, import_util10.assignDeep)(doc, [
5093
+ (0, import_util9.assignDeep)(doc, [
5025
5094
  "objects",
5026
5095
  propertiesId
5027
5096
  ], properties);
@@ -5032,8 +5101,8 @@ var DataSpaceManager = class {
5032
5101
  async _getSpaceRootDocument(space) {
5033
5102
  const automergeIndex = space.automergeSpaceState.rootUrl;
5034
5103
  (0, import_invariant15.invariant)(automergeIndex, void 0, {
5035
- F: __dxlog_file17,
5036
- L: 261,
5104
+ F: __dxlog_file18,
5105
+ L: 271,
5037
5106
  S: this,
5038
5107
  A: [
5039
5108
  "automergeIndex",
@@ -5049,14 +5118,14 @@ var DataSpaceManager = class {
5049
5118
  (0, import_log15.log)("accept space", {
5050
5119
  opts
5051
5120
  }, {
5052
- F: __dxlog_file17,
5053
- L: 270,
5121
+ F: __dxlog_file18,
5122
+ L: 280,
5054
5123
  S: this,
5055
5124
  C: (f, a) => f(...a)
5056
5125
  });
5057
5126
  (0, import_invariant15.invariant)(this._isOpen, "Not open.", {
5058
- F: __dxlog_file17,
5059
- L: 271,
5127
+ F: __dxlog_file18,
5128
+ L: 281,
5060
5129
  S: this,
5061
5130
  A: [
5062
5131
  "this._isOpen",
@@ -5064,8 +5133,8 @@ var DataSpaceManager = class {
5064
5133
  ]
5065
5134
  });
5066
5135
  (0, import_invariant15.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
5067
- F: __dxlog_file17,
5068
- L: 272,
5136
+ F: __dxlog_file18,
5137
+ L: 282,
5069
5138
  S: this,
5070
5139
  A: [
5071
5140
  "!this._spaces.has(opts.spaceKey)",
@@ -5085,23 +5154,72 @@ var DataSpaceManager = class {
5085
5154
  this.updated.emit();
5086
5155
  return space;
5087
5156
  }
5157
+ async admitMember(options) {
5158
+ const space = this._spaceManager.spaces.get(options.spaceKey);
5159
+ (0, import_invariant15.invariant)(space, void 0, {
5160
+ F: __dxlog_file18,
5161
+ L: 302,
5162
+ S: this,
5163
+ A: [
5164
+ "space",
5165
+ ""
5166
+ ]
5167
+ });
5168
+ if (space.spaceState.getMemberRole(options.identityKey) !== import_credentials16.SpaceMember.Role.REMOVED) {
5169
+ throw new import_protocols11.AlreadyJoinedError();
5170
+ }
5171
+ const credentials = await (0, import_credentials15.createAdmissionCredentials)(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
5172
+ (0, import_invariant15.invariant)(credentials[0].credential, void 0, {
5173
+ F: __dxlog_file18,
5174
+ L: 321,
5175
+ S: this,
5176
+ A: [
5177
+ "credentials[0].credential",
5178
+ ""
5179
+ ]
5180
+ });
5181
+ const spaceMemberCredential = credentials[0].credential.credential;
5182
+ (0, import_invariant15.invariant)((0, import_credentials15.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5183
+ F: __dxlog_file18,
5184
+ L: 323,
5185
+ S: this,
5186
+ A: [
5187
+ "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5188
+ ""
5189
+ ]
5190
+ });
5191
+ await (0, import_feed_store4.writeMessages)(space.controlPipeline.writer, credentials);
5192
+ return spaceMemberCredential;
5193
+ }
5088
5194
  /**
5089
5195
  * Wait until the space data pipeline is fully initialized.
5090
5196
  * Used by invitation handler.
5091
5197
  * TODO(dmaretskyi): Consider removing.
5092
5198
  */
5093
5199
  async waitUntilSpaceReady(spaceKey) {
5094
- await (0, import_context14.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
5200
+ await (0, import_context13.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
5095
5201
  const space = this._spaces.get(spaceKey);
5096
5202
  return !!space && space.state === import_services14.SpaceState.READY;
5097
5203
  }));
5098
5204
  }
5205
+ async requestSpaceAdmissionCredential(spaceKey) {
5206
+ return this._spaceManager.requestSpaceAdmissionCredential({
5207
+ spaceKey,
5208
+ identityKey: this._signingContext.identityKey,
5209
+ timeout: 15e3,
5210
+ swarmIdentity: {
5211
+ peerKey: this._signingContext.deviceKey,
5212
+ credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5213
+ credentialAuthenticator: async () => true
5214
+ }
5215
+ });
5216
+ }
5099
5217
  async _constructSpace(metadata) {
5100
5218
  (0, import_log15.log)("construct space", {
5101
5219
  metadata
5102
5220
  }, {
5103
- F: __dxlog_file17,
5104
- L: 306,
5221
+ F: __dxlog_file18,
5222
+ L: 358,
5105
5223
  S: this,
5106
5224
  C: (f, a) => f(...a)
5107
5225
  });
@@ -5126,9 +5244,10 @@ var DataSpaceManager = class {
5126
5244
  swarmIdentity: {
5127
5245
  peerKey: this._signingContext.deviceKey,
5128
5246
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5129
- credentialAuthenticator: (0, import_util10.deferFunction)(() => dataSpace.authVerifier.verifier)
5247
+ credentialAuthenticator: (0, import_util9.deferFunction)(() => dataSpace.authVerifier.verifier)
5130
5248
  },
5131
5249
  onAuthorizedConnection: (session) => {
5250
+ session.addExtension("dxos.mesh.teleport.admission-discovery", new import_echo_pipeline4.CredentialServerExtension(space));
5132
5251
  session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5133
5252
  remotePeerId: session.remotePeerId
5134
5253
  }));
@@ -5138,8 +5257,8 @@ var DataSpaceManager = class {
5138
5257
  },
5139
5258
  onAuthFailure: () => {
5140
5259
  import_log15.log.warn("auth failure", void 0, {
5141
- F: __dxlog_file17,
5142
- L: 343,
5260
+ F: __dxlog_file18,
5261
+ L: 396,
5143
5262
  S: this,
5144
5263
  C: (f, a) => f(...a)
5145
5264
  });
@@ -5171,8 +5290,8 @@ var DataSpaceManager = class {
5171
5290
  (0, import_log15.log)("before space ready", {
5172
5291
  space: space.key
5173
5292
  }, {
5174
- F: __dxlog_file17,
5175
- L: 370,
5293
+ F: __dxlog_file18,
5294
+ L: 423,
5176
5295
  S: this,
5177
5296
  C: (f, a) => f(...a)
5178
5297
  });
@@ -5182,8 +5301,8 @@ var DataSpaceManager = class {
5182
5301
  space: space.key,
5183
5302
  open: this._isOpen
5184
5303
  }, {
5185
- F: __dxlog_file17,
5186
- L: 373,
5304
+ F: __dxlog_file18,
5305
+ L: 426,
5187
5306
  S: this,
5188
5307
  C: (f, a) => f(...a)
5189
5308
  });
@@ -5201,8 +5320,8 @@ var DataSpaceManager = class {
5201
5320
  (0, import_log15.log)("before space close", {
5202
5321
  space: space.key
5203
5322
  }, {
5204
- F: __dxlog_file17,
5205
- L: 381,
5323
+ F: __dxlog_file18,
5324
+ L: 434,
5206
5325
  S: this,
5207
5326
  C: (f, a) => f(...a)
5208
5327
  });
@@ -5230,7 +5349,7 @@ var DataSpaceManager = class {
5230
5349
  const peers = presence.getPeersByIdentityKey(member.key);
5231
5350
  const sessions = peers.map((p) => p.peerId && spaceProtocol.sessions.get(p.peerId));
5232
5351
  const sessionsToClose = sessions.filter((s) => {
5233
- return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline4.AuthStatus.FAILURE)) ?? false;
5352
+ return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline3.AuthStatus.FAILURE)) ?? false;
5234
5353
  });
5235
5354
  sessionsToClose.forEach((session) => {
5236
5355
  void session.close().catch(import_log15.log.error);
@@ -5242,8 +5361,8 @@ var DataSpaceManager = class {
5242
5361
  peersOnline: presence.getPeersOnline().length,
5243
5362
  closedSessions
5244
5363
  }, {
5245
- F: __dxlog_file17,
5246
- L: 417,
5364
+ F: __dxlog_file18,
5365
+ L: 470,
5247
5366
  S: this,
5248
5367
  C: (f, a) => f(...a)
5249
5368
  });
@@ -5257,8 +5376,8 @@ var DataSpaceManager = class {
5257
5376
  (0, import_log15.log)("closing a session with a removed peer", {
5258
5377
  peerId: peerState.peerId
5259
5378
  }, {
5260
- F: __dxlog_file17,
5261
- L: 431,
5379
+ F: __dxlog_file18,
5380
+ L: 484,
5262
5381
  S: this,
5263
5382
  C: (f, a) => f(...a)
5264
5383
  });
@@ -5303,21 +5422,21 @@ var DataSpaceManager = class {
5303
5422
  }
5304
5423
  };
5305
5424
  _ts_decorate5([
5306
- import_async17.synchronized
5425
+ import_async16.synchronized
5307
5426
  ], DataSpaceManager.prototype, "open", null);
5308
5427
  _ts_decorate5([
5309
- import_async17.synchronized
5428
+ import_async16.synchronized
5310
5429
  ], DataSpaceManager.prototype, "close", null);
5311
5430
  _ts_decorate5([
5312
- import_async17.synchronized
5431
+ import_async16.synchronized
5313
5432
  ], DataSpaceManager.prototype, "createSpace", null);
5314
5433
  _ts_decorate5([
5315
- import_async17.synchronized
5434
+ import_async16.synchronized
5316
5435
  ], DataSpaceManager.prototype, "acceptSpace", null);
5317
5436
  DataSpaceManager = _ts_decorate5([
5318
- (0, import_async17.trackLeaks)("open", "close")
5437
+ (0, import_async16.trackLeaks)("open", "close")
5319
5438
  ], DataSpaceManager);
5320
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5439
+ var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5321
5440
  var SpacesServiceImpl = class {
5322
5441
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
5323
5442
  this._identityManager = _identityManager;
@@ -5361,8 +5480,8 @@ var SpacesServiceImpl = class {
5361
5480
  }
5362
5481
  const credentials = await (0, import_credentials19.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
5363
5482
  (0, import_invariant16.invariant)(credentials[0].credential, void 0, {
5364
- F: __dxlog_file18,
5365
- L: 98,
5483
+ F: __dxlog_file19,
5484
+ L: 102,
5366
5485
  S: this,
5367
5486
  A: [
5368
5487
  "credentials[0].credential",
@@ -5371,26 +5490,26 @@ var SpacesServiceImpl = class {
5371
5490
  });
5372
5491
  const spaceMemberCredential = credentials[0].credential.credential;
5373
5492
  (0, import_invariant16.invariant)((0, import_credentials19.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5374
- F: __dxlog_file18,
5375
- L: 100,
5493
+ F: __dxlog_file19,
5494
+ L: 104,
5376
5495
  S: this,
5377
5496
  A: [
5378
5497
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5379
5498
  ""
5380
5499
  ]
5381
5500
  });
5382
- await (0, import_feed_store4.writeMessages)(space.controlPipeline.writer, credentials);
5501
+ await (0, import_feed_store5.writeMessages)(space.controlPipeline.writer, credentials);
5383
5502
  }
5384
5503
  querySpaces() {
5385
5504
  return new import_codec_protobuf11.Stream(({ next, ctx }) => {
5386
- const scheduler = new import_async18.UpdateScheduler(ctx, async () => {
5505
+ const scheduler = new import_async17.UpdateScheduler(ctx, async () => {
5387
5506
  const dataSpaceManager = await this._getDataSpaceManager();
5388
5507
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
5389
5508
  (0, import_log16.log)("update", {
5390
5509
  spaces
5391
5510
  }, {
5392
- F: __dxlog_file18,
5393
- L: 111,
5511
+ F: __dxlog_file19,
5512
+ L: 115,
5394
5513
  S: this,
5395
5514
  C: (f, a) => f(...a)
5396
5515
  });
@@ -5401,9 +5520,9 @@ var SpacesServiceImpl = class {
5401
5520
  }, {
5402
5521
  maxFrequency: process.env.NODE_ENV === "test" ? void 0 : 2
5403
5522
  });
5404
- (0, import_async18.scheduleTask)(ctx, async () => {
5523
+ (0, import_async17.scheduleTask)(ctx, async () => {
5405
5524
  const dataSpaceManager = await this._getDataSpaceManager();
5406
- const subscriptions = new import_async18.EventSubscriptions();
5525
+ const subscriptions = new import_async17.EventSubscriptions();
5407
5526
  ctx.onDispose(() => subscriptions.clear());
5408
5527
  const subscribeSpaces = () => {
5409
5528
  subscriptions.clear();
@@ -5443,7 +5562,7 @@ var SpacesServiceImpl = class {
5443
5562
  }
5444
5563
  subscribeMessages({ spaceKey, channel }) {
5445
5564
  return new import_codec_protobuf11.Stream(({ ctx, next }) => {
5446
- (0, import_async18.scheduleTask)(ctx, async () => {
5565
+ (0, import_async17.scheduleTask)(ctx, async () => {
5447
5566
  const dataSpaceManager = await this._getDataSpaceManager();
5448
5567
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
5449
5568
  const handle = space.listen(getChannelId(channel), (message) => {
@@ -5462,7 +5581,7 @@ var SpacesServiceImpl = class {
5462
5581
  }
5463
5582
  };
5464
5583
  ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
5465
- (0, import_async18.scheduleTask)(ctx, async () => {
5584
+ (0, import_async17.scheduleTask)(ctx, async () => {
5466
5585
  await space.spaceState.addCredentialProcessor(processor);
5467
5586
  if (noTail) {
5468
5587
  close();
@@ -5481,8 +5600,8 @@ var SpacesServiceImpl = class {
5481
5600
  });
5482
5601
  } else {
5483
5602
  (0, import_invariant16.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
5484
- F: __dxlog_file18,
5485
- L: 209,
5603
+ F: __dxlog_file19,
5604
+ L: 213,
5486
5605
  S: this,
5487
5606
  A: [
5488
5607
  "!credential.id",
@@ -5490,8 +5609,8 @@ var SpacesServiceImpl = class {
5490
5609
  ]
5491
5610
  });
5492
5611
  (0, import_invariant16.invariant)(this._identityManager.identity, "Identity is not available", {
5493
- F: __dxlog_file18,
5494
- L: 210,
5612
+ F: __dxlog_file19,
5613
+ L: 214,
5495
5614
  S: this,
5496
5615
  A: [
5497
5616
  "this._identityManager.identity",
@@ -5500,8 +5619,8 @@ var SpacesServiceImpl = class {
5500
5619
  });
5501
5620
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
5502
5621
  (0, import_invariant16.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
5503
- F: __dxlog_file18,
5504
- L: 212,
5622
+ F: __dxlog_file19,
5623
+ L: 216,
5505
5624
  S: this,
5506
5625
  A: [
5507
5626
  "credential.issuer.equals(signer.getIssuer())",
@@ -5531,6 +5650,59 @@ var SpacesServiceImpl = class {
5531
5650
  epochCredential: credential ?? void 0
5532
5651
  };
5533
5652
  }
5653
+ async admitContact(request) {
5654
+ const dataSpaceManager = await this._getDataSpaceManager();
5655
+ await dataSpaceManager.admitMember({
5656
+ spaceKey: request.spaceKey,
5657
+ identityKey: request.contact.identityKey,
5658
+ role: request.role
5659
+ });
5660
+ }
5661
+ async joinBySpaceKey({ spaceKey }) {
5662
+ const dataSpaceManager = await this._getDataSpaceManager();
5663
+ const credential = await dataSpaceManager.requestSpaceAdmissionCredential(spaceKey);
5664
+ return this._joinByAdmission({
5665
+ credential
5666
+ });
5667
+ }
5668
+ async _joinByAdmission({ credential }) {
5669
+ const assertion = (0, import_credentials19.getCredentialAssertion)(credential);
5670
+ (0, import_invariant16.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
5671
+ F: __dxlog_file19,
5672
+ L: 250,
5673
+ S: this,
5674
+ A: [
5675
+ "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
5676
+ "'Invalid credential'"
5677
+ ]
5678
+ });
5679
+ const myIdentity = this._identityManager.identity;
5680
+ (0, import_invariant16.invariant)(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
5681
+ F: __dxlog_file19,
5682
+ L: 252,
5683
+ S: this,
5684
+ A: [
5685
+ "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
5686
+ ""
5687
+ ]
5688
+ });
5689
+ const dataSpaceManager = await this._getDataSpaceManager();
5690
+ let dataSpace = dataSpaceManager.spaces.get(assertion.spaceKey);
5691
+ if (!dataSpace) {
5692
+ dataSpace = await dataSpaceManager.acceptSpace({
5693
+ spaceKey: assertion.spaceKey,
5694
+ genesisFeedKey: assertion.genesisFeedKey
5695
+ });
5696
+ await myIdentity.controlPipeline.writer.write({
5697
+ credential: {
5698
+ credential
5699
+ }
5700
+ });
5701
+ }
5702
+ return {
5703
+ space: this._serializeSpace(dataSpace)
5704
+ };
5705
+ }
5534
5706
  _serializeSpace(space) {
5535
5707
  return {
5536
5708
  id: space.id,
@@ -5548,7 +5720,8 @@ var SpacesServiceImpl = class {
5548
5720
  startDataTimeframe: void 0,
5549
5721
  currentDataTimeframe: void 0,
5550
5722
  targetDataTimeframe: void 0,
5551
- totalDataTimeframe: void 0
5723
+ totalDataTimeframe: void 0,
5724
+ spaceRootUrl: space.databaseRoot?.url
5552
5725
  },
5553
5726
  members: Array.from(space.inner.spaceState.members.values()).map((member) => {
5554
5727
  const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
@@ -5600,8 +5773,8 @@ function _ts_decorate6(decorators, target, key, desc) {
5600
5773
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5601
5774
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5602
5775
  }
5603
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5604
- var ServiceContext = class extends import_context15.Resource {
5776
+ var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5777
+ var ServiceContext = class extends import_context14.Resource {
5605
5778
  constructor(storage, level, networkManager, signalManager, _runtimeParams) {
5606
5779
  super();
5607
5780
  this.storage = storage;
@@ -5609,15 +5782,15 @@ var ServiceContext = class extends import_context15.Resource {
5609
5782
  this.networkManager = networkManager;
5610
5783
  this.signalManager = signalManager;
5611
5784
  this._runtimeParams = _runtimeParams;
5612
- this.initialized = new import_async19.Trigger();
5785
+ this.initialized = new import_async18.Trigger();
5613
5786
  this._handlerFactories = /* @__PURE__ */ new Map();
5614
5787
  this._instanceId = import_keys13.PublicKey.random().toHex();
5615
5788
  this.metadataStore = new import_echo_pipeline5.MetadataStore(storage.createDirectory("metadata"));
5616
5789
  this.snapshotStore = new import_echo_pipeline5.SnapshotStore(storage.createDirectory("snapshots"));
5617
5790
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
5618
5791
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
5619
- this.feedStore = new import_feed_store5.FeedStore({
5620
- factory: new import_feed_store5.FeedFactory({
5792
+ this.feedStore = new import_feed_store6.FeedStore({
5793
+ factory: new import_feed_store6.FeedFactory({
5621
5794
  root: storage.createDirectory("feeds"),
5622
5795
  signer: this.keyring,
5623
5796
  hypercore: {
@@ -5644,7 +5817,7 @@ var ServiceContext = class extends import_context15.Resource {
5644
5817
  async _open(ctx) {
5645
5818
  await this._checkStorageVersion();
5646
5819
  (0, import_log17.log)("opening...", void 0, {
5647
- F: __dxlog_file19,
5820
+ F: __dxlog_file20,
5648
5821
  L: 149,
5649
5822
  S: this,
5650
5823
  C: (f, a) => f(...a)
@@ -5652,7 +5825,7 @@ var ServiceContext = class extends import_context15.Resource {
5652
5825
  import_log17.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
5653
5826
  id: this._instanceId
5654
5827
  }), {
5655
- F: __dxlog_file19,
5828
+ F: __dxlog_file20,
5656
5829
  L: 150,
5657
5830
  S: this,
5658
5831
  C: (f, a) => f(...a)
@@ -5670,7 +5843,7 @@ var ServiceContext = class extends import_context15.Resource {
5670
5843
  (0, import_log17.log)("loaded persistent invitations", {
5671
5844
  count: loadedInvitations.invitations?.length
5672
5845
  }, {
5673
- F: __dxlog_file19,
5846
+ F: __dxlog_file20,
5674
5847
  L: 163,
5675
5848
  S: this,
5676
5849
  C: (f, a) => f(...a)
@@ -5678,13 +5851,13 @@ var ServiceContext = class extends import_context15.Resource {
5678
5851
  import_log17.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
5679
5852
  id: this._instanceId
5680
5853
  }), {
5681
- F: __dxlog_file19,
5854
+ F: __dxlog_file20,
5682
5855
  L: 165,
5683
5856
  S: this,
5684
5857
  C: (f, a) => f(...a)
5685
5858
  });
5686
5859
  (0, import_log17.log)("opened", void 0, {
5687
- F: __dxlog_file19,
5860
+ F: __dxlog_file20,
5688
5861
  L: 166,
5689
5862
  S: this,
5690
5863
  C: (f, a) => f(...a)
@@ -5692,7 +5865,7 @@ var ServiceContext = class extends import_context15.Resource {
5692
5865
  }
5693
5866
  async _close(ctx) {
5694
5867
  (0, import_log17.log)("closing...", void 0, {
5695
- F: __dxlog_file19,
5868
+ F: __dxlog_file20,
5696
5869
  L: 170,
5697
5870
  S: this,
5698
5871
  C: (f, a) => f(...a)
@@ -5709,7 +5882,7 @@ var ServiceContext = class extends import_context15.Resource {
5709
5882
  await this.networkManager.close();
5710
5883
  await this.signalManager.close();
5711
5884
  (0, import_log17.log)("closed", void 0, {
5712
- F: __dxlog_file19,
5885
+ F: __dxlog_file20,
5713
5886
  L: 182,
5714
5887
  S: this,
5715
5888
  C: (f, a) => f(...a)
@@ -5717,13 +5890,16 @@ var ServiceContext = class extends import_context15.Resource {
5717
5890
  }
5718
5891
  async createIdentity(params = {}) {
5719
5892
  const identity = await this.identityManager.createIdentity(params);
5720
- await this._initialize(new import_context15.Context());
5893
+ await this._initialize(new import_context14.Context(void 0, {
5894
+ F: __dxlog_file20,
5895
+ L: 187
5896
+ }));
5721
5897
  return identity;
5722
5898
  }
5723
5899
  getInvitationHandler(invitation) {
5724
5900
  const factory = this._handlerFactories.get(invitation.kind);
5725
5901
  (0, import_invariant17.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
5726
- F: __dxlog_file19,
5902
+ F: __dxlog_file20,
5727
5903
  L: 193,
5728
5904
  S: this,
5729
5905
  A: [
@@ -5743,7 +5919,10 @@ var ServiceContext = class extends import_context15.Resource {
5743
5919
  }
5744
5920
  async _acceptIdentity(params) {
5745
5921
  const identity = await this.identityManager.acceptIdentity(params);
5746
- await this._initialize(new import_context15.Context());
5922
+ await this._initialize(new import_context14.Context(void 0, {
5923
+ F: __dxlog_file20,
5924
+ L: 209
5925
+ }));
5747
5926
  return identity;
5748
5927
  }
5749
5928
  async _checkStorageVersion() {
@@ -5755,7 +5934,7 @@ var ServiceContext = class extends import_context15.Resource {
5755
5934
  // Called when identity is created.
5756
5935
  async _initialize(ctx) {
5757
5936
  (0, import_log17.log)("initializing spaces...", void 0, {
5758
- F: __dxlog_file19,
5937
+ F: __dxlog_file20,
5759
5938
  L: 224,
5760
5939
  S: this,
5761
5940
  C: (f, a) => f(...a)
@@ -5778,7 +5957,7 @@ var ServiceContext = class extends import_context15.Resource {
5778
5957
  await this.dataSpaceManager.open();
5779
5958
  this._handlerFactories.set(import_services16.Invitation.Kind.SPACE, (invitation) => {
5780
5959
  (0, import_invariant17.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
5781
- F: __dxlog_file19,
5960
+ F: __dxlog_file20,
5782
5961
  L: 249,
5783
5962
  S: this,
5784
5963
  A: [
@@ -5802,7 +5981,7 @@ var ServiceContext = class extends import_context15.Resource {
5802
5981
  (0, import_log17.log)("dataSpaceManager not initialized yet, ignoring space admission", {
5803
5982
  details: assertion
5804
5983
  }, {
5805
- F: __dxlog_file19,
5984
+ F: __dxlog_file20,
5806
5985
  L: 265,
5807
5986
  S: this,
5808
5987
  C: (f, a) => f(...a)
@@ -5813,7 +5992,7 @@ var ServiceContext = class extends import_context15.Resource {
5813
5992
  (0, import_log17.log)("space already exists, ignoring space admission", {
5814
5993
  details: assertion
5815
5994
  }, {
5816
- F: __dxlog_file19,
5995
+ F: __dxlog_file20,
5817
5996
  L: 269,
5818
5997
  S: this,
5819
5998
  C: (f, a) => f(...a)
@@ -5824,7 +6003,7 @@ var ServiceContext = class extends import_context15.Resource {
5824
6003
  (0, import_log17.log)("accepting space recorded in halo", {
5825
6004
  details: assertion
5826
6005
  }, {
5827
- F: __dxlog_file19,
6006
+ F: __dxlog_file20,
5828
6007
  L: 274,
5829
6008
  S: this,
5830
6009
  C: (f, a) => f(...a)
@@ -5835,7 +6014,7 @@ var ServiceContext = class extends import_context15.Resource {
5835
6014
  });
5836
6015
  } catch (err) {
5837
6016
  import_log17.log.catch(err, void 0, {
5838
- F: __dxlog_file19,
6017
+ F: __dxlog_file20,
5839
6018
  L: 280,
5840
6019
  S: this,
5841
6020
  C: (f, a) => f(...a)
@@ -5853,7 +6032,7 @@ _ts_decorate6([
5853
6032
  import_tracing8.trace.span()
5854
6033
  ], ServiceContext.prototype, "_initialize", null);
5855
6034
  ServiceContext = _ts_decorate6([
5856
- (0, import_util11.safeInstanceof)("dxos.client-services.ServiceContext"),
6035
+ (0, import_util10.safeInstanceof)("dxos.client-services.ServiceContext"),
5857
6036
  import_tracing8.trace.resource()
5858
6037
  ], ServiceContext);
5859
6038
  var ServiceRegistry = class {
@@ -5888,7 +6067,7 @@ function _ts_decorate7(decorators, target, key, desc) {
5888
6067
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5889
6068
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5890
6069
  }
5891
- var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
6070
+ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
5892
6071
  var Lock = class {
5893
6072
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
5894
6073
  this._lockPath = lockPath;
@@ -5900,7 +6079,7 @@ var Lock = class {
5900
6079
  }
5901
6080
  async acquire() {
5902
6081
  (0, import_log18.log)("acquiring lock...", void 0, {
5903
- F: __dxlog_file20,
6082
+ F: __dxlog_file21,
5904
6083
  L: 32,
5905
6084
  S: this,
5906
6085
  C: (f, a) => f(...a)
@@ -5908,7 +6087,7 @@ var Lock = class {
5908
6087
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
5909
6088
  await this._onAcquire?.();
5910
6089
  (0, import_log18.log)("acquired lock", void 0, {
5911
- F: __dxlog_file20,
6090
+ F: __dxlog_file21,
5912
6091
  L: 37,
5913
6092
  S: this,
5914
6093
  C: (f, a) => f(...a)
@@ -5917,7 +6096,7 @@ var Lock = class {
5917
6096
  async release() {
5918
6097
  await this._onRelease?.();
5919
6098
  (0, import_invariant18.invariant)(this._fileHandle, "Lock is not acquired", {
5920
- F: __dxlog_file20,
6099
+ F: __dxlog_file21,
5921
6100
  L: 42,
5922
6101
  S: this,
5923
6102
  A: [
@@ -5933,7 +6112,7 @@ _ts_decorate7([
5933
6112
  ], Lock.prototype, "lockKey", null);
5934
6113
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
5935
6114
  var getRootPath = (config) => {
5936
- const { dataRoot = (0, import_util12.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
6115
+ const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
5937
6116
  return `${dataRoot}/`;
5938
6117
  };
5939
6118
  var isPersistent = (config) => {
@@ -5989,7 +6168,159 @@ var createLevel = async (config) => {
5989
6168
  await level.open();
5990
6169
  return level;
5991
6170
  };
5992
- var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
6171
+ var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
6172
+ var encodeProfileArchive = (profile) => import_automerge_repo.cbor.encode(profile);
6173
+ var decodeProfileArchive = (data) => import_automerge_repo.cbor.decode(data);
6174
+ var exportProfileData = async ({ storage, level }) => {
6175
+ const archive = {
6176
+ storage: [],
6177
+ meta: {
6178
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
6179
+ }
6180
+ };
6181
+ {
6182
+ const directory = await storage.createDirectory();
6183
+ const files = await directory.list();
6184
+ import_log19.log.info("begin exporting files", {
6185
+ count: files.length
6186
+ }, {
6187
+ F: __dxlog_file22,
6188
+ L: 30,
6189
+ S: void 0,
6190
+ C: (f, a) => f(...a)
6191
+ });
6192
+ for (const filename of files) {
6193
+ const file = await directory.getOrCreateFile(filename);
6194
+ const { size } = await file.stat();
6195
+ const data = await file.read(0, size);
6196
+ archive.storage.push({
6197
+ type: import_protocols15.ProfileArchiveEntryType.FILE,
6198
+ key: filename,
6199
+ value: data
6200
+ });
6201
+ }
6202
+ import_log19.log.info("done exporting files", {
6203
+ count: files.length
6204
+ }, {
6205
+ F: __dxlog_file22,
6206
+ L: 41,
6207
+ S: void 0,
6208
+ C: (f, a) => f(...a)
6209
+ });
6210
+ }
6211
+ {
6212
+ import_log19.log.info("begin exporting kv pairs", void 0, {
6213
+ F: __dxlog_file22,
6214
+ L: 45,
6215
+ S: void 0,
6216
+ C: (f, a) => f(...a)
6217
+ });
6218
+ const iter = await level.iterator({
6219
+ keyEncoding: "binary",
6220
+ valueEncoding: "binary"
6221
+ });
6222
+ let count = 0;
6223
+ for await (const [key, value] of iter) {
6224
+ archive.storage.push({
6225
+ type: import_protocols15.ProfileArchiveEntryType.KEY_VALUE,
6226
+ key,
6227
+ value
6228
+ });
6229
+ count++;
6230
+ }
6231
+ import_log19.log.info("done exporting kv pairs", {
6232
+ count
6233
+ }, {
6234
+ F: __dxlog_file22,
6235
+ L: 56,
6236
+ S: void 0,
6237
+ C: (f, a) => f(...a)
6238
+ });
6239
+ }
6240
+ return archive;
6241
+ };
6242
+ var importProfileData = async ({ storage, level }, archive) => {
6243
+ let batch = level.batch();
6244
+ let count = 0;
6245
+ for (const entry2 of archive.storage) {
6246
+ switch (entry2.type) {
6247
+ case import_protocols15.ProfileArchiveEntryType.FILE: {
6248
+ const directory = await storage.createDirectory();
6249
+ (0, import_invariant19.invariant)(typeof entry2.key === "string", "Invalid key type", {
6250
+ F: __dxlog_file22,
6251
+ L: 79,
6252
+ S: void 0,
6253
+ A: [
6254
+ "typeof entry.key === 'string'",
6255
+ "'Invalid key type'"
6256
+ ]
6257
+ });
6258
+ const file = await directory.getOrCreateFile(entry2.key);
6259
+ (0, import_invariant19.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
6260
+ F: __dxlog_file22,
6261
+ L: 81,
6262
+ S: void 0,
6263
+ A: [
6264
+ "entry.value instanceof Uint8Array",
6265
+ "'Invalid value type'"
6266
+ ]
6267
+ });
6268
+ await file.write(0, (0, import_util12.arrayToBuffer)(entry2.value));
6269
+ await file.close();
6270
+ break;
6271
+ }
6272
+ case import_protocols15.ProfileArchiveEntryType.KEY_VALUE: {
6273
+ (0, import_invariant19.invariant)(entry2.key instanceof Uint8Array, "Invalid key type", {
6274
+ F: __dxlog_file22,
6275
+ L: 87,
6276
+ S: void 0,
6277
+ A: [
6278
+ "entry.key instanceof Uint8Array",
6279
+ "'Invalid key type'"
6280
+ ]
6281
+ });
6282
+ (0, import_invariant19.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
6283
+ F: __dxlog_file22,
6284
+ L: 88,
6285
+ S: void 0,
6286
+ A: [
6287
+ "entry.value instanceof Uint8Array",
6288
+ "'Invalid value type'"
6289
+ ]
6290
+ });
6291
+ batch.put(entry2.key, entry2.value, {
6292
+ keyEncoding: "binary",
6293
+ valueEncoding: "binary"
6294
+ });
6295
+ break;
6296
+ }
6297
+ default:
6298
+ throw new Error(`Invalid entry type: ${entry2.type}`);
6299
+ }
6300
+ if (++count % 1e3 === 0) {
6301
+ await batch.write();
6302
+ batch = level.batch();
6303
+ import_log19.log.info("importing", {
6304
+ count,
6305
+ total: archive.storage.length,
6306
+ progress: `${(count / archive.storage.length * 100).toFixed()}%`
6307
+ }, {
6308
+ F: __dxlog_file22,
6309
+ L: 101,
6310
+ S: void 0,
6311
+ C: (f, a) => f(...a)
6312
+ });
6313
+ }
6314
+ }
6315
+ import_log19.log.info("committing changes..", void 0, {
6316
+ F: __dxlog_file22,
6317
+ L: 109,
6318
+ S: void 0,
6319
+ C: (f, a) => f(...a)
6320
+ });
6321
+ await batch.write();
6322
+ };
6323
+ var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
5993
6324
  var DevicesServiceImpl = class {
5994
6325
  constructor(_identityManager) {
5995
6326
  this._identityManager = _identityManager;
@@ -6006,8 +6337,8 @@ var DevicesServiceImpl = class {
6006
6337
  devices: []
6007
6338
  });
6008
6339
  } else {
6009
- (0, import_invariant20.invariant)(this._identityManager.identity?.presence, "presence not present", {
6010
- F: __dxlog_file21,
6340
+ (0, import_invariant21.invariant)(this._identityManager.identity?.presence, "presence not present", {
6341
+ F: __dxlog_file23,
6011
6342
  L: 32,
6012
6343
  S: this,
6013
6344
  A: [
@@ -6048,7 +6379,7 @@ var DevicesServiceImpl = class {
6048
6379
  presenceSubscribed = true;
6049
6380
  }
6050
6381
  };
6051
- const subscriptions = new import_async21.EventSubscriptions();
6382
+ const subscriptions = new import_async20.EventSubscriptions();
6052
6383
  if (this._identityManager.identity) {
6053
6384
  subscribeIdentity();
6054
6385
  subscribePresence();
@@ -6100,33 +6431,110 @@ var findConfigs = () => {
6100
6431
  const configs = import_tracing10.TRACE_PROCESSOR.findResourcesByAnnotation(import_config3.ConfigResource);
6101
6432
  return configs.map((r) => r.instance.deref()).filter(import_util13.nonNullable);
6102
6433
  };
6434
+ var ContactsServiceImpl = class {
6435
+ constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
6436
+ this._identityManager = _identityManager;
6437
+ this._spaceManager = _spaceManager;
6438
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
6439
+ }
6440
+ async getContacts() {
6441
+ const identity = this._identityManager.identity;
6442
+ if (identity == null) {
6443
+ return {
6444
+ contacts: []
6445
+ };
6446
+ }
6447
+ const contacts = [
6448
+ ...this._spaceManager.spaces.values()
6449
+ ].flatMap((s) => [
6450
+ ...s.spaceState.members.values()
6451
+ ].map((m) => [
6452
+ s.key,
6453
+ m
6454
+ ])).reduce((acc, v) => {
6455
+ const [spaceKey, memberInfo] = v;
6456
+ if (memberInfo.key.equals(identity.identityKey)) {
6457
+ return acc;
6458
+ }
6459
+ const existing = acc.get(memberInfo.key);
6460
+ if (existing != null) {
6461
+ existing.profile ??= memberInfo.profile;
6462
+ existing.commonSpaces?.push(spaceKey);
6463
+ } else {
6464
+ acc.set(memberInfo.key, {
6465
+ identityKey: memberInfo.key,
6466
+ profile: memberInfo.profile,
6467
+ commonSpaces: [
6468
+ spaceKey
6469
+ ]
6470
+ });
6471
+ }
6472
+ return acc;
6473
+ }, new import_util15.ComplexMap(import_keys17.PublicKey.hash));
6474
+ return {
6475
+ contacts: [
6476
+ ...contacts.values()
6477
+ ]
6478
+ };
6479
+ }
6480
+ queryContacts() {
6481
+ const subscribedSpaceKeySet = new import_util15.ComplexSet(import_keys17.PublicKey.hash);
6482
+ return new import_codec_protobuf13.Stream(({ next, ctx }) => {
6483
+ const pushUpdateTask = new import_async21.UpdateScheduler(ctx, async () => {
6484
+ const contacts = await this.getContacts();
6485
+ next(contacts);
6486
+ }, {
6487
+ maxFrequency: 2
6488
+ });
6489
+ (0, import_async21.scheduleTask)(ctx, async () => {
6490
+ const subscriptions = new import_async21.EventSubscriptions();
6491
+ ctx.onDispose(() => subscriptions.clear());
6492
+ const subscribeToSpaceAndUpdate = () => {
6493
+ const oldSetSize = subscribedSpaceKeySet.size;
6494
+ for (const space of this._spaceManager.spaces.values()) {
6495
+ if (!subscribedSpaceKeySet.has(space.key)) {
6496
+ subscriptions.add(space.stateUpdate.on(ctx, () => pushUpdateTask.trigger()));
6497
+ subscribedSpaceKeySet.add(space.key);
6498
+ }
6499
+ }
6500
+ if (oldSetSize !== subscribedSpaceKeySet.size) {
6501
+ pushUpdateTask.trigger();
6502
+ }
6503
+ };
6504
+ const unsubscribe = (await this._dataSpaceManagerProvider()).updated.on(ctx, subscribeToSpaceAndUpdate);
6505
+ ctx.onDispose(unsubscribe);
6506
+ subscribeToSpaceAndUpdate();
6507
+ });
6508
+ });
6509
+ }
6510
+ };
6103
6511
  var LoggingServiceImpl = class {
6104
6512
  constructor() {
6105
6513
  this._logs = new import_async22.Event();
6106
6514
  this._started = Date.now();
6107
- this._sessionId = import_keys17.PublicKey.random().toHex();
6515
+ this._sessionId = import_keys18.PublicKey.random().toHex();
6108
6516
  this._logProcessor = (_config, entry2) => {
6109
6517
  this._logs.emit(entry2);
6110
6518
  };
6111
6519
  }
6112
6520
  async open() {
6113
- import_log20.log.runtimeConfig.processors.push(this._logProcessor);
6521
+ import_log21.log.runtimeConfig.processors.push(this._logProcessor);
6114
6522
  }
6115
6523
  async close() {
6116
- const index = import_log20.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6117
- import_log20.log.runtimeConfig.processors.splice(index, 1);
6524
+ const index = import_log21.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6525
+ import_log21.log.runtimeConfig.processors.splice(index, 1);
6118
6526
  }
6119
6527
  async controlMetrics({ reset, record }) {
6120
6528
  if (reset) {
6121
- import_util15.tracer.clear();
6529
+ import_util16.tracer.clear();
6122
6530
  }
6123
6531
  if (record === true) {
6124
- import_util15.tracer.start();
6532
+ import_util16.tracer.start();
6125
6533
  } else if (record === false) {
6126
- import_util15.tracer.stop();
6534
+ import_util16.tracer.stop();
6127
6535
  }
6128
6536
  return {
6129
- recording: import_util15.tracer.recording
6537
+ recording: import_util16.tracer.recording
6130
6538
  };
6131
6539
  }
6132
6540
  /**
@@ -6134,13 +6542,13 @@ var LoggingServiceImpl = class {
6134
6542
  */
6135
6543
  queryMetrics({ interval = 5e3 }) {
6136
6544
  const getNumericalValues = (key) => {
6137
- const events = import_util15.tracer.get(key) ?? [];
6545
+ const events = import_util16.tracer.get(key) ?? [];
6138
6546
  return {
6139
6547
  key,
6140
- stats: (0, import_util15.numericalValues)(events, "duration")
6548
+ stats: (0, import_util16.numericalValues)(events, "duration")
6141
6549
  };
6142
6550
  };
6143
- return new import_codec_protobuf13.Stream(({ next }) => {
6551
+ return new import_codec_protobuf14.Stream(({ next }) => {
6144
6552
  const update = () => {
6145
6553
  const metrics = {
6146
6554
  timestamp: /* @__PURE__ */ new Date(),
@@ -6162,7 +6570,7 @@ var LoggingServiceImpl = class {
6162
6570
  });
6163
6571
  }
6164
6572
  queryLogs(request) {
6165
- return new import_codec_protobuf13.Stream(({ ctx, next }) => {
6573
+ return new import_codec_protobuf14.Stream(({ ctx, next }) => {
6166
6574
  const handler = (entry2) => {
6167
6575
  if (LOG_PROCESSING > 0) {
6168
6576
  return;
@@ -6175,7 +6583,7 @@ var LoggingServiceImpl = class {
6175
6583
  }
6176
6584
  const record = {
6177
6585
  ...entry2,
6178
- context: (0, import_util15.jsonify)((0, import_log20.getContextFromEntry)(entry2)),
6586
+ context: (0, import_util16.jsonify)((0, import_log21.getContextFromEntry)(entry2)),
6179
6587
  timestamp: /* @__PURE__ */ new Date(),
6180
6588
  meta: {
6181
6589
  // TODO(dmaretskyi): Fix proto.
@@ -6184,7 +6592,7 @@ var LoggingServiceImpl = class {
6184
6592
  scope: {
6185
6593
  hostSessionId: this._sessionId,
6186
6594
  uptimeSeconds: (Date.now() - this._started) / 1e3,
6187
- name: (0, import_util15.getDebugName)(entry2.meta?.S)
6595
+ name: (0, import_util16.getDebugName)(entry2.meta?.S)
6188
6596
  }
6189
6597
  }
6190
6598
  };
@@ -6222,7 +6630,7 @@ var NetworkServiceImpl = class {
6222
6630
  this.signalManager = signalManager;
6223
6631
  }
6224
6632
  queryStatus() {
6225
- return new import_codec_protobuf14.Stream(({ next }) => {
6633
+ return new import_codec_protobuf15.Stream(({ next }) => {
6226
6634
  const update = () => {
6227
6635
  next({
6228
6636
  swarm: this.networkManager.connectionState,
@@ -6265,7 +6673,7 @@ var SystemServiceImpl = class {
6265
6673
  const diagnostics = await this._getDiagnostics();
6266
6674
  return {
6267
6675
  timestamp: /* @__PURE__ */ new Date(),
6268
- diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util16.jsonKeyReplacer)({
6676
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util17.jsonKeyReplacer)({
6269
6677
  truncate: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
6270
6678
  humanize: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
6271
6679
  })))
@@ -6279,7 +6687,7 @@ var SystemServiceImpl = class {
6279
6687
  }
6280
6688
  // TODO(burdon): Standardize interval option in stream request?
6281
6689
  queryStatus({ interval = 3e3 } = {}) {
6282
- return new import_codec_protobuf15.Stream(({ next }) => {
6690
+ return new import_codec_protobuf16.Stream(({ next }) => {
6283
6691
  const update = () => {
6284
6692
  next({
6285
6693
  status: this._getCurrentStatus()
@@ -6308,7 +6716,7 @@ function _ts_decorate8(decorators, target, key, desc) {
6308
6716
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6309
6717
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6310
6718
  }
6311
- var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6719
+ var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6312
6720
  var ClientServicesHost = class {
6313
6721
  constructor({
6314
6722
  config,
@@ -6322,7 +6730,7 @@ var ClientServicesHost = class {
6322
6730
  runtimeParams
6323
6731
  } = {}) {
6324
6732
  this._tracingService = import_tracing9.TRACE_PROCESSOR.createTraceSender();
6325
- this._statusUpdate = new import_async20.Event();
6733
+ this._statusUpdate = new import_async19.Event();
6326
6734
  this._opening = false;
6327
6735
  this._open = false;
6328
6736
  this._storage = storage;
@@ -6341,7 +6749,10 @@ var ClientServicesHost = class {
6341
6749
  lockKey,
6342
6750
  onAcquire: () => {
6343
6751
  if (!this._opening) {
6344
- void this.open(new import_context16.Context());
6752
+ void this.open(new import_context15.Context(void 0, {
6753
+ F: __dxlog_file24,
6754
+ L: 121
6755
+ }));
6345
6756
  }
6346
6757
  },
6347
6758
  onRelease: () => this.close()
@@ -6396,25 +6807,25 @@ var ClientServicesHost = class {
6396
6807
  * Can only be called once.
6397
6808
  */
6398
6809
  initialize({ config, ...options }) {
6399
- (0, import_invariant19.invariant)(!this._open, "service host is open", {
6400
- F: __dxlog_file22,
6401
- L: 186,
6810
+ (0, import_invariant20.invariant)(!this._open, "service host is open", {
6811
+ F: __dxlog_file24,
6812
+ L: 187,
6402
6813
  S: this,
6403
6814
  A: [
6404
6815
  "!this._open",
6405
6816
  "'service host is open'"
6406
6817
  ]
6407
6818
  });
6408
- (0, import_log19.log)("initializing...", void 0, {
6409
- F: __dxlog_file22,
6410
- L: 187,
6819
+ (0, import_log20.log)("initializing...", void 0, {
6820
+ F: __dxlog_file24,
6821
+ L: 188,
6411
6822
  S: this,
6412
6823
  C: (f, a) => f(...a)
6413
6824
  });
6414
6825
  if (config) {
6415
- (0, import_invariant19.invariant)(!this._config, "config already set", {
6416
- F: __dxlog_file22,
6417
- L: 190,
6826
+ (0, import_invariant20.invariant)(!this._config, "config already set", {
6827
+ F: __dxlog_file24,
6828
+ L: 191,
6418
6829
  S: this,
6419
6830
  A: [
6420
6831
  "!this._config",
@@ -6427,9 +6838,9 @@ var ClientServicesHost = class {
6427
6838
  }
6428
6839
  }
6429
6840
  if (!options.signalManager) {
6430
- import_log19.log.warn("running signaling without telemetry metadata.", void 0, {
6431
- F: __dxlog_file22,
6432
- L: 198,
6841
+ import_log20.log.warn("running signaling without telemetry metadata.", void 0, {
6842
+ F: __dxlog_file24,
6843
+ L: 199,
6433
6844
  S: this,
6434
6845
  C: (f, a) => f(...a)
6435
6846
  });
@@ -6438,9 +6849,9 @@ var ClientServicesHost = class {
6438
6849
  iceServers: this._config?.get("runtime.services.ice")
6439
6850
  }), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
6440
6851
  this._signalManager = signalManager;
6441
- (0, import_invariant19.invariant)(!this._networkManager, "network manager already set", {
6442
- F: __dxlog_file22,
6443
- L: 209,
6852
+ (0, import_invariant20.invariant)(!this._networkManager, "network manager already set", {
6853
+ F: __dxlog_file24,
6854
+ L: 210,
6444
6855
  S: this,
6445
6856
  A: [
6446
6857
  "!this._networkManager",
@@ -6452,9 +6863,9 @@ var ClientServicesHost = class {
6452
6863
  transportFactory,
6453
6864
  signalManager
6454
6865
  });
6455
- (0, import_log19.log)("initialized", void 0, {
6456
- F: __dxlog_file22,
6457
- L: 216,
6866
+ (0, import_log20.log)("initialized", void 0, {
6867
+ F: __dxlog_file24,
6868
+ L: 217,
6458
6869
  S: this,
6459
6870
  C: (f, a) => f(...a)
6460
6871
  });
@@ -6464,44 +6875,44 @@ var ClientServicesHost = class {
6464
6875
  return;
6465
6876
  }
6466
6877
  const traceId = import_keys15.PublicKey.random().toHex();
6467
- import_log19.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
6878
+ import_log20.log.trace("dxos.client-services.host.open", import_protocols16.trace.begin({
6468
6879
  id: traceId
6469
6880
  }), {
6470
- F: __dxlog_file22,
6471
- L: 227,
6881
+ F: __dxlog_file24,
6882
+ L: 228,
6472
6883
  S: this,
6473
6884
  C: (f, a) => f(...a)
6474
6885
  });
6475
- (0, import_invariant19.invariant)(this._config, "config not set", {
6476
- F: __dxlog_file22,
6477
- L: 229,
6886
+ (0, import_invariant20.invariant)(this._config, "config not set", {
6887
+ F: __dxlog_file24,
6888
+ L: 230,
6478
6889
  S: this,
6479
6890
  A: [
6480
6891
  "this._config",
6481
6892
  "'config not set'"
6482
6893
  ]
6483
6894
  });
6484
- (0, import_invariant19.invariant)(this._storage, "storage not set", {
6485
- F: __dxlog_file22,
6486
- L: 230,
6895
+ (0, import_invariant20.invariant)(this._storage, "storage not set", {
6896
+ F: __dxlog_file24,
6897
+ L: 231,
6487
6898
  S: this,
6488
6899
  A: [
6489
6900
  "this._storage",
6490
6901
  "'storage not set'"
6491
6902
  ]
6492
6903
  });
6493
- (0, import_invariant19.invariant)(this._signalManager, "signal manager not set", {
6494
- F: __dxlog_file22,
6495
- L: 231,
6904
+ (0, import_invariant20.invariant)(this._signalManager, "signal manager not set", {
6905
+ F: __dxlog_file24,
6906
+ L: 232,
6496
6907
  S: this,
6497
6908
  A: [
6498
6909
  "this._signalManager",
6499
6910
  "'signal manager not set'"
6500
6911
  ]
6501
6912
  });
6502
- (0, import_invariant19.invariant)(this._networkManager, "network manager not set", {
6503
- F: __dxlog_file22,
6504
- L: 232,
6913
+ (0, import_invariant20.invariant)(this._networkManager, "network manager not set", {
6914
+ F: __dxlog_file24,
6915
+ L: 233,
6505
6916
  S: this,
6506
6917
  A: [
6507
6918
  "this._networkManager",
@@ -6509,11 +6920,11 @@ var ClientServicesHost = class {
6509
6920
  ]
6510
6921
  });
6511
6922
  this._opening = true;
6512
- (0, import_log19.log)("opening...", {
6923
+ (0, import_log20.log)("opening...", {
6513
6924
  lockKey: this._resourceLock?.lockKey
6514
6925
  }, {
6515
- F: __dxlog_file22,
6516
- L: 235,
6926
+ F: __dxlog_file24,
6927
+ L: 236,
6517
6928
  S: this,
6518
6929
  C: (f, a) => f(...a)
6519
6930
  });
@@ -6524,16 +6935,18 @@ var ClientServicesHost = class {
6524
6935
  await this._level.open();
6525
6936
  await this._loggingService.open();
6526
6937
  this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
6938
+ const dataSpaceManagerProvider = async () => {
6939
+ await this._serviceContext.initialized.wait();
6940
+ return this._serviceContext.dataSpaceManager;
6941
+ };
6527
6942
  const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
6528
6943
  this._serviceRegistry.setServices({
6529
6944
  SystemService: this._systemService,
6530
6945
  IdentityService: identityService,
6946
+ ContactsService: new ContactsServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6531
6947
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
6532
6948
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
6533
- SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
6534
- await this._serviceContext.initialized.wait();
6535
- return this._serviceContext.dataSpaceManager;
6536
- }),
6949
+ SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6537
6950
  DataService: this._serviceContext.echoHost.dataService,
6538
6951
  QueryService: this._serviceContext.echoHost.queryService,
6539
6952
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
@@ -6563,19 +6976,19 @@ var ClientServicesHost = class {
6563
6976
  this._open = true;
6564
6977
  this._statusUpdate.emit();
6565
6978
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6566
- (0, import_log19.log)("opened", {
6979
+ (0, import_log20.log)("opened", {
6567
6980
  deviceKey
6568
6981
  }, {
6569
- F: __dxlog_file22,
6570
- L: 314,
6982
+ F: __dxlog_file24,
6983
+ L: 322,
6571
6984
  S: this,
6572
6985
  C: (f, a) => f(...a)
6573
6986
  });
6574
- import_log19.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
6987
+ import_log20.log.trace("dxos.client-services.host.open", import_protocols16.trace.end({
6575
6988
  id: traceId
6576
6989
  }), {
6577
- F: __dxlog_file22,
6578
- L: 315,
6990
+ F: __dxlog_file24,
6991
+ L: 323,
6579
6992
  S: this,
6580
6993
  C: (f, a) => f(...a)
6581
6994
  });
@@ -6585,11 +6998,11 @@ var ClientServicesHost = class {
6585
6998
  return;
6586
6999
  }
6587
7000
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6588
- (0, import_log19.log)("closing...", {
7001
+ (0, import_log20.log)("closing...", {
6589
7002
  deviceKey
6590
7003
  }, {
6591
- F: __dxlog_file22,
6592
- L: 326,
7004
+ F: __dxlog_file24,
7005
+ L: 334,
6593
7006
  S: this,
6594
7007
  C: (f, a) => f(...a)
6595
7008
  });
@@ -6603,44 +7016,44 @@ var ClientServicesHost = class {
6603
7016
  await this._level?.close();
6604
7017
  this._open = false;
6605
7018
  this._statusUpdate.emit();
6606
- (0, import_log19.log)("closed", {
7019
+ (0, import_log20.log)("closed", {
6607
7020
  deviceKey
6608
7021
  }, {
6609
- F: __dxlog_file22,
6610
- L: 335,
7022
+ F: __dxlog_file24,
7023
+ L: 343,
6611
7024
  S: this,
6612
7025
  C: (f, a) => f(...a)
6613
7026
  });
6614
7027
  }
6615
7028
  async reset() {
6616
7029
  const traceId = import_keys15.PublicKey.random().toHex();
6617
- import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
7030
+ import_log20.log.trace("dxos.sdk.client-services-host.reset", import_protocols16.trace.begin({
6618
7031
  id: traceId
6619
7032
  }), {
6620
- F: __dxlog_file22,
6621
- L: 340,
7033
+ F: __dxlog_file24,
7034
+ L: 348,
6622
7035
  S: this,
6623
7036
  C: (f, a) => f(...a)
6624
7037
  });
6625
- import_log19.log.info("resetting...", void 0, {
6626
- F: __dxlog_file22,
6627
- L: 342,
7038
+ import_log20.log.info("resetting...", void 0, {
7039
+ F: __dxlog_file24,
7040
+ L: 350,
6628
7041
  S: this,
6629
7042
  C: (f, a) => f(...a)
6630
7043
  });
6631
7044
  await this._serviceContext?.close();
6632
7045
  await this._storage.reset();
6633
- import_log19.log.info("reset", void 0, {
6634
- F: __dxlog_file22,
6635
- L: 345,
7046
+ import_log20.log.info("reset", void 0, {
7047
+ F: __dxlog_file24,
7048
+ L: 353,
6636
7049
  S: this,
6637
7050
  C: (f, a) => f(...a)
6638
7051
  });
6639
- import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
7052
+ import_log20.log.trace("dxos.sdk.client-services-host.reset", import_protocols16.trace.end({
6640
7053
  id: traceId
6641
7054
  }), {
6642
- F: __dxlog_file22,
6643
- L: 346,
7055
+ F: __dxlog_file24,
7056
+ L: 354,
6644
7057
  S: this,
6645
7058
  C: (f, a) => f(...a)
6646
7059
  });
@@ -6659,11 +7072,11 @@ _ts_decorate8([
6659
7072
  import_tracing9.trace.info()
6660
7073
  ], ClientServicesHost.prototype, "_open", void 0);
6661
7074
  _ts_decorate8([
6662
- import_async20.synchronized,
7075
+ import_async19.synchronized,
6663
7076
  import_tracing9.trace.span()
6664
7077
  ], ClientServicesHost.prototype, "open", null);
6665
7078
  _ts_decorate8([
6666
- import_async20.synchronized,
7079
+ import_async19.synchronized,
6667
7080
  import_tracing9.trace.span()
6668
7081
  ], ClientServicesHost.prototype, "close", null);
6669
7082
  ClientServicesHost = _ts_decorate8([
@@ -6699,7 +7112,11 @@ ClientServicesHost = _ts_decorate8([
6699
7112
  createDiagnostics,
6700
7113
  createLevel,
6701
7114
  createStorageObjects,
7115
+ decodeProfileArchive,
7116
+ encodeProfileArchive,
7117
+ exportProfileData,
6702
7118
  getNetworkPeers,
7119
+ importProfileData,
6703
7120
  isLocked,
6704
7121
  subscribeToFeedBlocks,
6705
7122
  subscribeToFeeds,
@@ -6709,4 +7126,4 @@ ClientServicesHost = _ts_decorate8([
6709
7126
  subscribeToSpaces,
6710
7127
  subscribeToSwarmInfo
6711
7128
  });
6712
- //# sourceMappingURL=chunk-XWMOEZYI.cjs.map
7129
+ //# sourceMappingURL=chunk-RZCXR5W4.cjs.map