@dxos/client-services 0.5.9-main.b06c86b → 0.5.9-main.b752d7f

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 (45) hide show
  1. package/dist/lib/browser/{chunk-2JCI5YEM.mjs → chunk-PA5DAU64.mjs} +906 -502
  2. package/dist/lib/browser/chunk-PA5DAU64.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-HRQTR7UW.cjs → chunk-G6UXW6DQ.cjs} +950 -546
  9. package/dist/lib/node/chunk-G6UXW6DQ.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/space-invitation-protocol.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  20. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +10 -1
  21. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  23. package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +2 -2
  24. package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -1
  25. package/dist/types/src/packlets/spaces/spaces-service.d.ts +4 -1
  26. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  27. package/dist/types/src/packlets/storage/index.d.ts +1 -0
  28. package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
  29. package/dist/types/src/packlets/storage/profile-archive.d.ts +14 -0
  30. package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -0
  31. package/dist/types/src/version.d.ts +1 -1
  32. package/package.json +36 -36
  33. package/src/packlets/identity/contacts-service.ts +85 -0
  34. package/src/packlets/identity/identity-service.ts +28 -22
  35. package/src/packlets/invitations/space-invitation-protocol.ts +11 -32
  36. package/src/packlets/services/service-host.ts +12 -4
  37. package/src/packlets/spaces/data-space-manager.ts +55 -2
  38. package/src/packlets/spaces/data-space.ts +3 -1
  39. package/src/packlets/spaces/epoch-migrations.ts +57 -38
  40. package/src/packlets/spaces/spaces-service.ts +40 -0
  41. package/src/packlets/storage/index.ts +1 -0
  42. package/src/packlets/storage/profile-archive.ts +111 -0
  43. package/src/version.ts +1 -1
  44. package/dist/lib/browser/chunk-2JCI5YEM.mjs.map +0 -7
  45. package/dist/lib/node/chunk-HRQTR7UW.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_HRQTR7UW_exports = {};
30
- __export(chunk_HRQTR7UW_exports, {
29
+ var chunk_G6UXW6DQ_exports = {};
30
+ __export(chunk_G6UXW6DQ_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  ClientServicesProviderResource: () => ClientServicesProviderResource,
@@ -56,7 +56,11 @@ __export(chunk_HRQTR7UW_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_HRQTR7UW_exports, {
66
70
  subscribeToSpaces: () => subscribeToSpaces,
67
71
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
68
72
  });
69
- module.exports = __toCommonJS(chunk_HRQTR7UW_exports);
73
+ module.exports = __toCommonJS(chunk_G6UXW6DQ_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.b06c86b";
649
+ var DXOS_VERSION = "0.5.9-main.b752d7f";
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: [
@@ -2940,7 +2980,7 @@ var InvitationsHandler = class {
2940
2980
  newState: stateToString(newState),
2941
2981
  oldState: stateToString(invitation.state)
2942
2982
  }, {
2943
- F: __dxlog_file11,
2983
+ F: __dxlog_file12,
2944
2984
  L: 439,
2945
2985
  S: this,
2946
2986
  C: (f, a) => f(...a)
@@ -2951,7 +2991,7 @@ var InvitationsHandler = class {
2951
2991
  newState: stateToString(newState),
2952
2992
  oldState: stateToString(invitation.state)
2953
2993
  }, {
2954
- F: __dxlog_file11,
2994
+ F: __dxlog_file12,
2955
2995
  L: 445,
2956
2996
  S: this,
2957
2997
  C: (f, a) => f(...a)
@@ -2970,7 +3010,7 @@ var InvitationsHandler = class {
2970
3010
  async _handleGuestOtpAuth(extension, setState, authenticated, options) {
2971
3011
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2972
3012
  (0, import_log6.log)("guest waiting for authentication code...", void 0, {
2973
- F: __dxlog_file11,
3013
+ F: __dxlog_file12,
2974
3014
  L: 470,
2975
3015
  S: this,
2976
3016
  C: (f, a) => f(...a)
@@ -2978,7 +3018,7 @@ var InvitationsHandler = class {
2978
3018
  setState(import_services6.Invitation.State.READY_FOR_AUTHENTICATION);
2979
3019
  const authCode = await authenticated.wait(options);
2980
3020
  (0, import_log6.log)("sending authentication request", void 0, {
2981
- F: __dxlog_file11,
3021
+ F: __dxlog_file12,
2982
3022
  L: 474,
2983
3023
  S: this,
2984
3024
  C: (f, a) => f(...a)
@@ -2997,7 +3037,7 @@ var InvitationsHandler = class {
2997
3037
  (0, import_log6.log)("retrying invalid code", {
2998
3038
  attempt
2999
3039
  }, {
3000
- F: __dxlog_file11,
3040
+ F: __dxlog_file12,
3001
3041
  L: 485,
3002
3042
  S: this,
3003
3043
  C: (f, a) => f(...a)
@@ -3015,7 +3055,7 @@ var InvitationsHandler = class {
3015
3055
  throw new Error("challenge missing in the introduction");
3016
3056
  }
3017
3057
  (0, import_log6.log)("sending authentication request", void 0, {
3018
- F: __dxlog_file11,
3058
+ F: __dxlog_file12,
3019
3059
  L: 504,
3020
3060
  S: this,
3021
3061
  C: (f, a) => f(...a)
@@ -3130,7 +3170,7 @@ var InvitationsServiceImpl = class {
3130
3170
  });
3131
3171
  }
3132
3172
  };
3133
- 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";
3134
3174
  var SpaceInvitationProtocol = class {
3135
3175
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
3136
3176
  this._spaceManager = _spaceManager;
@@ -3164,79 +3204,43 @@ var SpaceInvitationProtocol = class {
3164
3204
  };
3165
3205
  }
3166
3206
  async admit(invitation, request, guestProfile) {
3167
- (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3168
- F: __dxlog_file12,
3169
- L: 76,
3170
- S: this,
3171
- A: [
3172
- "this._spaceKey",
3173
- ""
3174
- ]
3175
- });
3176
- const space = this._spaceManager.spaces.get(this._spaceKey);
3177
- (0, import_invariant10.invariant)(space, void 0, {
3178
- F: __dxlog_file12,
3179
- L: 78,
3180
- S: this,
3181
- A: [
3182
- "space",
3183
- ""
3184
- ]
3185
- });
3186
- (0, import_invariant10.invariant)(request.space, void 0, {
3187
- F: __dxlog_file12,
3188
- L: 80,
3207
+ (0, import_invariant10.invariant)(this._spaceKey && request.space, void 0, {
3208
+ F: __dxlog_file13,
3209
+ L: 74,
3189
3210
  S: this,
3190
3211
  A: [
3191
- "request.space",
3212
+ "this._spaceKey && request.space",
3192
3213
  ""
3193
3214
  ]
3194
3215
  });
3195
- const { identityKey, deviceKey } = request.space;
3196
- if (space.inner.spaceState.getMemberRole(identityKey) !== import_credentials10.SpaceMember.Role.REMOVED) {
3197
- throw new import_protocols8.AlreadyJoinedError();
3198
- }
3199
3216
  (0, import_log10.log)("writing guest credentials", {
3200
3217
  host: this._signingContext.deviceKey,
3201
- guest: deviceKey
3218
+ guest: request.space.deviceKey
3202
3219
  }, {
3203
- F: __dxlog_file12,
3204
- L: 87,
3220
+ F: __dxlog_file13,
3221
+ L: 75,
3205
3222
  S: this,
3206
3223
  C: (f, a) => f(...a)
3207
3224
  });
3208
- 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);
3209
- (0, import_invariant10.invariant)(credentials[0].credential, void 0, {
3210
- F: __dxlog_file12,
3211
- L: 101,
3212
- S: this,
3213
- A: [
3214
- "credentials[0].credential",
3215
- ""
3216
- ]
3217
- });
3218
- const spaceMemberCredential = credentials[0].credential.credential;
3219
- (0, import_invariant10.invariant)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3220
- F: __dxlog_file12,
3221
- L: 103,
3222
- S: this,
3223
- A: [
3224
- "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
3225
- ""
3226
- ]
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
3227
3231
  });
3228
- await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
3232
+ const space = this._spaceManager.spaces.get(this._spaceKey);
3229
3233
  return {
3230
3234
  space: {
3231
3235
  credential: spaceMemberCredential,
3232
- controlTimeframe: space.inner.controlPipeline.state.timeframe
3236
+ controlTimeframe: space?.inner.controlPipeline.state.timeframe
3233
3237
  }
3234
3238
  };
3235
3239
  }
3236
3240
  async delegate(invitation) {
3237
3241
  (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3238
- F: __dxlog_file12,
3239
- L: 116,
3242
+ F: __dxlog_file13,
3243
+ L: 95,
3240
3244
  S: this,
3241
3245
  A: [
3242
3246
  "this._spaceKey",
@@ -3245,8 +3249,8 @@ var SpaceInvitationProtocol = class {
3245
3249
  });
3246
3250
  const space = this._spaceManager.spaces.get(this._spaceKey);
3247
3251
  (0, import_invariant10.invariant)(space, void 0, {
3248
- F: __dxlog_file12,
3249
- L: 118,
3252
+ F: __dxlog_file13,
3253
+ L: 97,
3250
3254
  S: this,
3251
3255
  A: [
3252
3256
  "space",
@@ -3255,8 +3259,8 @@ var SpaceInvitationProtocol = class {
3255
3259
  });
3256
3260
  if (invitation.authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
3257
3261
  (0, import_invariant10.invariant)(invitation.guestKeypair?.publicKey, void 0, {
3258
- F: __dxlog_file12,
3259
- L: 120,
3262
+ F: __dxlog_file13,
3263
+ L: 99,
3260
3264
  S: this,
3261
3265
  A: [
3262
3266
  "invitation.guestKeypair?.publicKey",
@@ -3268,8 +3272,8 @@ var SpaceInvitationProtocol = class {
3268
3272
  host: this._signingContext.deviceKey,
3269
3273
  id: invitation.invitationId
3270
3274
  }, {
3271
- F: __dxlog_file12,
3272
- L: 123,
3275
+ F: __dxlog_file13,
3276
+ L: 102,
3273
3277
  S: this,
3274
3278
  C: (f, a) => f(...a)
3275
3279
  });
@@ -3283,8 +3287,8 @@ var SpaceInvitationProtocol = class {
3283
3287
  guestKey: invitation.authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
3284
3288
  });
3285
3289
  (0, import_invariant10.invariant)(credential.credential, void 0, {
3286
- F: __dxlog_file12,
3287
- L: 143,
3290
+ F: __dxlog_file13,
3291
+ L: 122,
3288
3292
  S: this,
3289
3293
  A: [
3290
3294
  "credential.credential",
@@ -3298,8 +3302,8 @@ var SpaceInvitationProtocol = class {
3298
3302
  }
3299
3303
  async cancelDelegation(invitation) {
3300
3304
  (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3301
- F: __dxlog_file12,
3302
- L: 149,
3305
+ F: __dxlog_file13,
3306
+ L: 128,
3303
3307
  S: this,
3304
3308
  A: [
3305
3309
  "this._spaceKey",
@@ -3307,8 +3311,8 @@ var SpaceInvitationProtocol = class {
3307
3311
  ]
3308
3312
  });
3309
3313
  (0, import_invariant10.invariant)(invitation.type === import_services10.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
3310
- F: __dxlog_file12,
3311
- L: 150,
3314
+ F: __dxlog_file13,
3315
+ L: 129,
3312
3316
  S: this,
3313
3317
  A: [
3314
3318
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -3317,8 +3321,8 @@ var SpaceInvitationProtocol = class {
3317
3321
  });
3318
3322
  const space = this._spaceManager.spaces.get(this._spaceKey);
3319
3323
  (0, import_invariant10.invariant)(space, void 0, {
3320
- F: __dxlog_file12,
3321
- L: 152,
3324
+ F: __dxlog_file13,
3325
+ L: 131,
3322
3326
  S: this,
3323
3327
  A: [
3324
3328
  "space",
@@ -3329,15 +3333,15 @@ var SpaceInvitationProtocol = class {
3329
3333
  host: this._signingContext.deviceKey,
3330
3334
  id: invitation.invitationId
3331
3335
  }, {
3332
- F: __dxlog_file12,
3333
- L: 154,
3336
+ F: __dxlog_file13,
3337
+ L: 133,
3334
3338
  S: this,
3335
3339
  C: (f, a) => f(...a)
3336
3340
  });
3337
3341
  const credential = await (0, import_credentials9.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
3338
3342
  (0, import_invariant10.invariant)(credential.credential, void 0, {
3339
- F: __dxlog_file12,
3340
- L: 161,
3343
+ F: __dxlog_file13,
3344
+ L: 140,
3341
3345
  S: this,
3342
3346
  A: [
3343
3347
  "credential.credential",
@@ -3375,8 +3379,8 @@ var SpaceInvitationProtocol = class {
3375
3379
  }
3376
3380
  async accept(response) {
3377
3381
  (0, import_invariant10.invariant)(response.space, void 0, {
3378
- F: __dxlog_file12,
3379
- L: 196,
3382
+ F: __dxlog_file13,
3383
+ L: 175,
3380
3384
  S: this,
3381
3385
  A: [
3382
3386
  "response.space",
@@ -3386,8 +3390,8 @@ var SpaceInvitationProtocol = class {
3386
3390
  const { credential, controlTimeframe, dataTimeframe } = response.space;
3387
3391
  const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
3388
3392
  (0, import_invariant10.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3389
- F: __dxlog_file12,
3390
- L: 199,
3393
+ F: __dxlog_file13,
3394
+ L: 178,
3391
3395
  S: this,
3392
3396
  A: [
3393
3397
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3395,8 +3399,8 @@ var SpaceInvitationProtocol = class {
3395
3399
  ]
3396
3400
  });
3397
3401
  (0, import_invariant10.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
3398
- F: __dxlog_file12,
3399
- L: 200,
3402
+ F: __dxlog_file13,
3403
+ L: 179,
3400
3404
  S: this,
3401
3405
  A: [
3402
3406
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -3418,7 +3422,7 @@ var SpaceInvitationProtocol = class {
3418
3422
  };
3419
3423
  }
3420
3424
  };
3421
- 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";
3422
3426
  var InvitationsManager = class {
3423
3427
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
3424
3428
  this._invitationsHandler = _invitationsHandler;
@@ -3461,7 +3465,7 @@ var InvitationsManager = class {
3461
3465
  await this._persistIfRequired(handler, stream, invitation);
3462
3466
  } catch (err) {
3463
3467
  import_log11.log.catch(err, void 0, {
3464
- F: __dxlog_file13,
3468
+ F: __dxlog_file14,
3465
3469
  L: 82,
3466
3470
  S: this,
3467
3471
  C: (f, a) => f(...a)
@@ -3484,7 +3488,7 @@ var InvitationsManager = class {
3484
3488
  const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
3485
3489
  const loadTasks = freshInvitations.map((persistentInvitation) => {
3486
3490
  (0, import_invariant11.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
3487
- F: __dxlog_file13,
3491
+ F: __dxlog_file14,
3488
3492
  L: 103,
3489
3493
  S: this,
3490
3494
  A: [
@@ -3503,7 +3507,7 @@ var InvitationsManager = class {
3503
3507
  };
3504
3508
  } catch (err) {
3505
3509
  import_log11.log.catch(err, void 0, {
3506
- F: __dxlog_file13,
3510
+ F: __dxlog_file14,
3507
3511
  L: 110,
3508
3512
  S: this,
3509
3513
  C: (f, a) => f(...a)
@@ -3535,13 +3539,13 @@ var InvitationsManager = class {
3535
3539
  }
3536
3540
  async authenticate({ invitationId, authCode }) {
3537
3541
  (0, import_log11.log)("authenticating...", void 0, {
3538
- F: __dxlog_file13,
3542
+ F: __dxlog_file14,
3539
3543
  L: 140,
3540
3544
  S: this,
3541
3545
  C: (f, a) => f(...a)
3542
3546
  });
3543
3547
  (0, import_invariant11.invariant)(invitationId, void 0, {
3544
- F: __dxlog_file13,
3548
+ F: __dxlog_file14,
3545
3549
  L: 141,
3546
3550
  S: this,
3547
3551
  A: [
@@ -3554,7 +3558,7 @@ var InvitationsManager = class {
3554
3558
  import_log11.log.warn("invalid invitation", {
3555
3559
  invitationId
3556
3560
  }, {
3557
- F: __dxlog_file13,
3561
+ F: __dxlog_file14,
3558
3562
  L: 144,
3559
3563
  S: this,
3560
3564
  C: (f, a) => f(...a)
@@ -3567,13 +3571,13 @@ var InvitationsManager = class {
3567
3571
  (0, import_log11.log)("cancelInvitation...", {
3568
3572
  invitationId
3569
3573
  }, {
3570
- F: __dxlog_file13,
3574
+ F: __dxlog_file14,
3571
3575
  L: 151,
3572
3576
  S: this,
3573
3577
  C: (f, a) => f(...a)
3574
3578
  });
3575
3579
  (0, import_invariant11.invariant)(invitationId, void 0, {
3576
- F: __dxlog_file13,
3580
+ F: __dxlog_file14,
3577
3581
  L: 152,
3578
3582
  S: this,
3579
3583
  A: [
@@ -3647,12 +3651,15 @@ var InvitationsManager = class {
3647
3651
  stream.error(err);
3648
3652
  void ctx.dispose();
3649
3653
  }
3654
+ }, {
3655
+ F: __dxlog_file14,
3656
+ L: 234
3650
3657
  });
3651
3658
  ctx.onDispose(() => {
3652
3659
  (0, import_log11.log)("complete", {
3653
3660
  ...handler.toJSON()
3654
3661
  }, {
3655
- F: __dxlog_file13,
3662
+ F: __dxlog_file14,
3656
3663
  L: 241,
3657
3664
  S: this,
3658
3665
  C: (f, a) => f(...a)
@@ -3685,7 +3692,7 @@ var InvitationsManager = class {
3685
3692
  (0, import_log11.log)("timeout", {
3686
3693
  ...handler.toJSON()
3687
3694
  }, {
3688
- F: __dxlog_file13,
3695
+ F: __dxlog_file14,
3689
3696
  L: 261,
3690
3697
  S: this,
3691
3698
  C: (f, a) => f(...a)
@@ -3696,7 +3703,7 @@ var InvitationsManager = class {
3696
3703
  });
3697
3704
  } else {
3698
3705
  import_log11.log.warn("auth failed", err, {
3699
- F: __dxlog_file13,
3706
+ F: __dxlog_file14,
3700
3707
  L: 264,
3701
3708
  S: this,
3702
3709
  C: (f, a) => f(...a)
@@ -3708,12 +3715,15 @@ var InvitationsManager = class {
3708
3715
  }
3709
3716
  void ctx.dispose();
3710
3717
  }
3718
+ }, {
3719
+ F: __dxlog_file14,
3720
+ L: 258
3711
3721
  });
3712
3722
  ctx.onDispose(() => {
3713
3723
  (0, import_log11.log)("complete", {
3714
3724
  ...handler.toJSON()
3715
3725
  }, {
3716
- F: __dxlog_file13,
3726
+ F: __dxlog_file14,
3717
3727
  L: 271,
3718
3728
  S: this,
3719
3729
  C: (f, a) => f(...a)
@@ -3758,7 +3768,7 @@ var InvitationsManager = class {
3758
3768
  await this._metadataStore.removeInvitation(invitation.invitationId);
3759
3769
  } catch (err) {
3760
3770
  import_log11.log.catch(err, void 0, {
3761
- F: __dxlog_file13,
3771
+ F: __dxlog_file14,
3762
3772
  L: 307,
3763
3773
  S: this,
3764
3774
  C: (f, a) => f(...a)
@@ -3811,12 +3821,13 @@ var AutomergeSpaceState = class extends import_context11.Resource {
3811
3821
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3812
3822
  }
3813
3823
  };
3814
- 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;
3815
3826
  var runEpochMigration = async (ctx, context) => {
3816
3827
  switch (context.migration) {
3817
3828
  case import_services13.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
3818
- const document = context.repo.create();
3819
- await context.repo.flush();
3829
+ const document = context.echoHost.createDoc();
3830
+ await context.echoHost.flush();
3820
3831
  return {
3821
3832
  newRoot: document.url
3822
3833
  };
@@ -3825,77 +3836,88 @@ var runEpochMigration = async (ctx, context) => {
3825
3836
  if (!context.currentRoot) {
3826
3837
  throw new Error("Space does not have an automerge root");
3827
3838
  }
3828
- const rootHandle = context.repo.find(context.currentRoot);
3829
- await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
3830
- const newRoot = context.repo.create(rootHandle.docSync());
3831
- 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();
3832
3844
  return {
3833
3845
  newRoot: newRoot.url
3834
3846
  };
3835
3847
  }
3836
3848
  case import_services13.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
3837
3849
  import_log13.log.info("Fragmenting", void 0, {
3838
- F: __dxlog_file14,
3839
- L: 63,
3850
+ F: __dxlog_file15,
3851
+ L: 64,
3840
3852
  S: void 0,
3841
3853
  C: (f, a) => f(...a)
3842
3854
  });
3843
3855
  const currentRootUrl = context.currentRoot;
3844
- const rootHandle = context.repo.find(currentRootUrl);
3845
- 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
+ });
3846
3859
  const objects = Object.entries(rootHandle.docSync().objects);
3847
3860
  const properties = (0, import_echo_db.findInlineObjectOfType)(rootHandle.docSync(), import_echo_schema.TYPE_PROPERTIES);
3848
3861
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3849
3862
  (0, import_invariant13.invariant)(properties, "Properties not found", {
3850
- F: __dxlog_file14,
3851
- L: 73,
3863
+ F: __dxlog_file15,
3864
+ L: 75,
3852
3865
  S: void 0,
3853
3866
  A: [
3854
3867
  "properties",
3855
3868
  "'Properties not found'"
3856
3869
  ]
3857
3870
  });
3858
- const newSpaceDoc = {
3871
+ const newRoot = context.echoHost.createDoc({
3859
3872
  ...rootHandle.docSync(),
3860
3873
  objects: Object.fromEntries([
3861
3874
  properties
3862
3875
  ])
3863
- };
3864
- const newRoot = context.repo.create(newSpaceDoc);
3876
+ });
3865
3877
  (0, import_invariant13.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3866
- F: __dxlog_file14,
3867
- L: 78,
3878
+ F: __dxlog_file15,
3879
+ L: 82,
3868
3880
  S: void 0,
3869
3881
  A: [
3870
3882
  "typeof newRoot.url === 'string' && newRoot.url.length > 0",
3871
3883
  ""
3872
3884
  ]
3873
3885
  });
3874
- const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(context.spaceId, context.repo, context.spaceKey);
3875
- await docLoader.loadSpaceRootDocHandle(ctx, {
3876
- rootUrl: newRoot.url
3877
- });
3878
- otherObjects.forEach(([key, value]) => {
3879
- const handle = docLoader.createDocumentForObject(key);
3880
- handle.change((doc) => {
3881
- (0, import_util8.assignDeep)(doc, [
3882
- "objects",
3883
- key
3884
- ], 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
+ }
3885
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
+ }
3886
3907
  });
3887
- await context.repo.flush();
3908
+ await context.echoHost.flush();
3888
3909
  return {
3889
3910
  newRoot: newRoot.url
3890
3911
  };
3891
3912
  }
3892
3913
  case import_services13.CreateEpochRequest.Migration.MIGRATE_REFERENCES_TO_DXN: {
3893
3914
  const currentRootUrl = context.currentRoot;
3894
- const rootHandle = context.repo.find(currentRootUrl);
3895
- 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
+ });
3896
3918
  (0, import_invariant13.invariant)(rootHandle.docSync(), "Root doc not found", {
3897
- F: __dxlog_file14,
3898
- L: 100,
3919
+ F: __dxlog_file15,
3920
+ L: 115,
3899
3921
  S: void 0,
3900
3922
  A: [
3901
3923
  "rootHandle.docSync()",
@@ -3904,40 +3926,59 @@ var runEpochMigration = async (ctx, context) => {
3904
3926
  });
3905
3927
  const newRootContent = await (0, import_echo_db.convertLegacySpaceRootDoc)(structuredClone(rootHandle.docSync()));
3906
3928
  for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
3907
- const handle = context.repo.find(url);
3908
- await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(handle.whenReady(), 1e4));
3909
- (0, import_invariant13.invariant)(handle.docSync(), "Doc not found", {
3910
- F: __dxlog_file14,
3911
- L: 107,
3912
- S: void 0,
3913
- A: [
3914
- "handle.docSync()",
3915
- "'Doc not found'"
3916
- ]
3917
- });
3918
- const newDoc = await (0, import_echo_db.convertLegacyReferences)(structuredClone(handle.docSync()));
3919
- const migratedDoc = (0, import_echo_db.migrateDocument)(handle.docSync(), newDoc);
3920
- const newHandle = context.repo.import(import_automerge.next.save(migratedDoc));
3921
- 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
+ }
3922
3961
  }
3923
3962
  const migratedRoot = (0, import_echo_db.migrateDocument)(rootHandle.docSync(), newRootContent);
3924
- const newRoot = context.repo.import(import_automerge.next.save(migratedRoot));
3925
- await context.repo.flush();
3963
+ const newRoot = context.echoHost.createDoc(migratedRoot, {
3964
+ preserveHistory: true
3965
+ });
3966
+ await context.echoHost.flush();
3926
3967
  return {
3927
3968
  newRoot: newRoot.url
3928
3969
  };
3929
3970
  }
3930
3971
  case import_services13.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
3931
3972
  (0, import_invariant13.invariant)(context.newAutomergeRoot, void 0, {
3932
- F: __dxlog_file14,
3933
- L: 124,
3973
+ F: __dxlog_file15,
3974
+ L: 143,
3934
3975
  S: void 0,
3935
3976
  A: [
3936
3977
  "context.newAutomergeRoot",
3937
3978
  ""
3938
3979
  ]
3939
3980
  });
3940
- await context.repo.flush();
3981
+ await context.echoHost.flush();
3941
3982
  return {
3942
3983
  newRoot: context.newAutomergeRoot
3943
3984
  };
@@ -3945,18 +3986,21 @@ var runEpochMigration = async (ctx, context) => {
3945
3986
  }
3946
3987
  return {};
3947
3988
  };
3948
- 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";
3949
3990
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3950
3991
  var DEFAULT_SUCCESS_DELAY = 1e3;
3951
3992
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
3952
3993
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3953
3994
  var NotarizationPlugin = class {
3954
3995
  constructor() {
3955
- this._ctx = new import_context13.Context();
3956
- 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();
3957
4001
  this._extensions = /* @__PURE__ */ new Set();
3958
- this._processedCredentials = new import_util9.ComplexSet(import_keys11.PublicKey.hash);
3959
- 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);
3960
4004
  }
3961
4005
  get hasWriter() {
3962
4006
  return !!this._writer;
@@ -3973,13 +4017,13 @@ var NotarizationPlugin = class {
3973
4017
  (0, import_log14.log)("notarize", {
3974
4018
  credentials
3975
4019
  }, {
3976
- F: __dxlog_file15,
4020
+ F: __dxlog_file16,
3977
4021
  L: 90,
3978
4022
  S: this,
3979
4023
  C: (f, a) => f(...a)
3980
4024
  });
3981
4025
  (0, import_invariant14.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
3982
- F: __dxlog_file15,
4026
+ F: __dxlog_file16,
3983
4027
  L: 91,
3984
4028
  S: this,
3985
4029
  A: [
@@ -3987,13 +4031,13 @@ var NotarizationPlugin = class {
3987
4031
  "'Credentials must have an id'"
3988
4032
  ]
3989
4033
  });
3990
- const errors = new import_async16.Trigger();
4034
+ const errors = new import_async15.Trigger();
3991
4035
  const ctx = this._ctx.derive({
3992
4036
  onError: (err) => {
3993
4037
  import_log14.log.warn("Notarization error", {
3994
4038
  err
3995
4039
  }, {
3996
- F: __dxlog_file15,
4040
+ F: __dxlog_file16,
3997
4041
  L: 99,
3998
4042
  S: this,
3999
4043
  C: (f, a) => f(...a)
@@ -4004,23 +4048,23 @@ var NotarizationPlugin = class {
4004
4048
  });
4005
4049
  opCtx?.onDispose(() => ctx.dispose());
4006
4050
  if (timeout !== 0) {
4007
- (0, import_async16.scheduleTask)(ctx, () => {
4051
+ (0, import_async15.scheduleTask)(ctx, () => {
4008
4052
  import_log14.log.warn("Notarization timeout", {
4009
4053
  timeout,
4010
4054
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
4011
4055
  }, {
4012
- F: __dxlog_file15,
4056
+ F: __dxlog_file16,
4013
4057
  L: 111,
4014
4058
  S: this,
4015
4059
  C: (f, a) => f(...a)
4016
4060
  });
4017
4061
  void ctx.dispose();
4018
- errors.throw(new import_async16.TimeoutError(timeout, "Notarization timed out"));
4062
+ errors.throw(new import_async15.TimeoutError(timeout, "Notarization timed out"));
4019
4063
  }, timeout);
4020
4064
  }
4021
4065
  const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
4022
4066
  const peersTried = /* @__PURE__ */ new Set();
4023
- const notarizeTask = new import_async16.DeferredTask(ctx, async () => {
4067
+ const notarizeTask = new import_async15.DeferredTask(ctx, async () => {
4024
4068
  try {
4025
4069
  if (this._extensions.size === 0) {
4026
4070
  return;
@@ -4032,13 +4076,13 @@ var NotarizationPlugin = class {
4032
4076
  import_log14.log.info("Exhausted all peers to notarize with", {
4033
4077
  retryIn: retryTimeout
4034
4078
  }, {
4035
- F: __dxlog_file15,
4079
+ F: __dxlog_file16,
4036
4080
  L: 136,
4037
4081
  S: this,
4038
4082
  C: (f, a) => f(...a)
4039
4083
  });
4040
4084
  peersTried.clear();
4041
- (0, import_async16.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
4085
+ (0, import_async15.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
4042
4086
  return;
4043
4087
  }
4044
4088
  peersTried.add(peer);
@@ -4046,7 +4090,7 @@ var NotarizationPlugin = class {
4046
4090
  peer: peer.localPeerId,
4047
4091
  credentialId: credentials.map((credential) => credential.id)
4048
4092
  }, {
4049
- F: __dxlog_file15,
4093
+ F: __dxlog_file16,
4050
4094
  L: 143,
4051
4095
  S: this,
4052
4096
  C: (f, a) => f(...a)
@@ -4055,16 +4099,16 @@ var NotarizationPlugin = class {
4055
4099
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
4056
4100
  });
4057
4101
  (0, import_log14.log)("success", void 0, {
4058
- F: __dxlog_file15,
4102
+ F: __dxlog_file16,
4059
4103
  L: 147,
4060
4104
  S: this,
4061
4105
  C: (f, a) => f(...a)
4062
4106
  });
4063
- await (0, import_async16.sleep)(successDelay);
4107
+ await (0, import_async15.sleep)(successDelay);
4064
4108
  } catch (err) {
4065
4109
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
4066
4110
  import_log14.log.info("error notarizing (recoverable)", err, {
4067
- F: __dxlog_file15,
4111
+ F: __dxlog_file16,
4068
4112
  L: 151,
4069
4113
  S: this,
4070
4114
  C: (f, a) => f(...a)
@@ -4077,12 +4121,12 @@ var NotarizationPlugin = class {
4077
4121
  this._extensionOpened.on(ctx, () => notarizeTask.schedule());
4078
4122
  try {
4079
4123
  await Promise.race([
4080
- (0, import_context13.rejectOnDispose)(ctx),
4124
+ (0, import_context12.rejectOnDispose)(ctx),
4081
4125
  allNotarized,
4082
4126
  errors.wait()
4083
4127
  ]);
4084
4128
  (0, import_log14.log)("done", void 0, {
4085
- F: __dxlog_file15,
4129
+ F: __dxlog_file16,
4086
4130
  L: 162,
4087
4131
  S: this,
4088
4132
  C: (f, a) => f(...a)
@@ -4104,7 +4148,7 @@ var NotarizationPlugin = class {
4104
4148
  }
4105
4149
  setWriter(writer) {
4106
4150
  (0, import_invariant14.invariant)(!this._writer, "Writer already set.", {
4107
- F: __dxlog_file15,
4151
+ F: __dxlog_file16,
4108
4152
  L: 181,
4109
4153
  S: this,
4110
4154
  A: [
@@ -4118,7 +4162,7 @@ var NotarizationPlugin = class {
4118
4162
  if (this._processedCredentials.has(id)) {
4119
4163
  return;
4120
4164
  }
4121
- 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();
4122
4166
  }
4123
4167
  /**
4124
4168
  * Requests from other peers to notarize credentials.
@@ -4129,7 +4173,7 @@ var NotarizationPlugin = class {
4129
4173
  }
4130
4174
  for (const credential of request.credentials ?? []) {
4131
4175
  (0, import_invariant14.invariant)(credential.id, "Credential must have an id", {
4132
- F: __dxlog_file15,
4176
+ F: __dxlog_file16,
4133
4177
  L: 200,
4134
4178
  S: this,
4135
4179
  A: [
@@ -4149,7 +4193,7 @@ var NotarizationPlugin = class {
4149
4193
  (0, import_log14.log)("extension opened", {
4150
4194
  peer: extension.localPeerId
4151
4195
  }, {
4152
- F: __dxlog_file15,
4196
+ F: __dxlog_file16,
4153
4197
  L: 211,
4154
4198
  S: this,
4155
4199
  C: (f, a) => f(...a)
@@ -4161,7 +4205,7 @@ var NotarizationPlugin = class {
4161
4205
  (0, import_log14.log)("extension closed", {
4162
4206
  peer: extension.localPeerId
4163
4207
  }, {
4164
- F: __dxlog_file15,
4208
+ F: __dxlog_file16,
4165
4209
  L: 216,
4166
4210
  S: this,
4167
4211
  C: (f, a) => f(...a)
@@ -4276,10 +4320,13 @@ function _using_ctx() {
4276
4320
  }
4277
4321
  };
4278
4322
  }
4279
- 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";
4280
4324
  var DataSpace = class {
4281
4325
  constructor(params) {
4282
- this._ctx = new import_context10.Context();
4326
+ this._ctx = new import_context10.Context(void 0, {
4327
+ F: __dxlog_file17,
4328
+ L: 84
4329
+ });
4283
4330
  this._notarizationPlugin = new NotarizationPlugin();
4284
4331
  this._cache = void 0;
4285
4332
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
@@ -4309,7 +4356,7 @@ var DataSpace = class {
4309
4356
  (0, import_log12.log)("new state", {
4310
4357
  state: import_services12.SpaceState[this._state]
4311
4358
  }, {
4312
- F: __dxlog_file16,
4359
+ F: __dxlog_file17,
4313
4360
  L: 146,
4314
4361
  S: this,
4315
4362
  C: (f, a) => f(...a)
@@ -4364,12 +4411,15 @@ var DataSpace = class {
4364
4411
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
4365
4412
  await this._automergeSpaceState.open();
4366
4413
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
4367
- 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
+ }));
4368
4418
  this._state = import_services12.SpaceState.CONTROL_ONLY;
4369
4419
  (0, import_log12.log)("new state", {
4370
4420
  state: import_services12.SpaceState[this._state]
4371
4421
  }, {
4372
- F: __dxlog_file16,
4422
+ F: __dxlog_file17,
4373
4423
  L: 217,
4374
4424
  S: this,
4375
4425
  C: (f, a) => f(...a)
@@ -4387,13 +4437,16 @@ var DataSpace = class {
4387
4437
  (0, import_log12.log)("new state", {
4388
4438
  state: import_services12.SpaceState[this._state]
4389
4439
  }, {
4390
- F: __dxlog_file16,
4440
+ F: __dxlog_file17,
4391
4441
  L: 231,
4392
4442
  S: this,
4393
4443
  C: (f, a) => f(...a)
4394
4444
  });
4395
4445
  await this._ctx.dispose();
4396
- this._ctx = new import_context10.Context();
4446
+ this._ctx = new import_context10.Context(void 0, {
4447
+ F: __dxlog_file17,
4448
+ L: 233
4449
+ });
4397
4450
  await this.authVerifier.close();
4398
4451
  await this._inner.close();
4399
4452
  await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
@@ -4420,7 +4473,7 @@ var DataSpace = class {
4420
4473
  } catch (err) {
4421
4474
  if (err instanceof import_protocols9.CancelledError || err instanceof import_context10.ContextDisposedError) {
4422
4475
  (0, import_log12.log)("data pipeline initialization cancelled", err, {
4423
- F: __dxlog_file16,
4476
+ F: __dxlog_file17,
4424
4477
  L: 265,
4425
4478
  S: this,
4426
4479
  C: (f, a) => f(...a)
@@ -4428,7 +4481,7 @@ var DataSpace = class {
4428
4481
  return;
4429
4482
  }
4430
4483
  import_log12.log.error("Error initializing data pipeline", err, {
4431
- F: __dxlog_file16,
4484
+ F: __dxlog_file17,
4432
4485
  L: 269,
4433
4486
  S: this,
4434
4487
  C: (f, a) => f(...a)
@@ -4437,7 +4490,7 @@ var DataSpace = class {
4437
4490
  (0, import_log12.log)("new state", {
4438
4491
  state: import_services12.SpaceState[this._state]
4439
4492
  }, {
4440
- F: __dxlog_file16,
4493
+ F: __dxlog_file17,
4441
4494
  L: 271,
4442
4495
  S: this,
4443
4496
  C: (f, a) => f(...a)
@@ -4457,7 +4510,7 @@ var DataSpace = class {
4457
4510
  (0, import_log12.log)("new state", {
4458
4511
  state: import_services12.SpaceState[this._state]
4459
4512
  }, {
4460
- F: __dxlog_file16,
4513
+ F: __dxlog_file17,
4461
4514
  L: 287,
4462
4515
  S: this,
4463
4516
  C: (f, a) => f(...a)
@@ -4474,7 +4527,7 @@ var DataSpace = class {
4474
4527
  (0, import_log12.log)("new state", {
4475
4528
  state: import_services12.SpaceState[this._state]
4476
4529
  }, {
4477
- F: __dxlog_file16,
4530
+ F: __dxlog_file17,
4478
4531
  L: 306,
4479
4532
  S: this,
4480
4533
  C: (f, a) => f(...a)
@@ -4490,7 +4543,7 @@ var DataSpace = class {
4490
4543
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
4491
4544
  await this._createWritableFeeds();
4492
4545
  (0, import_log12.log)("writable feeds created", void 0, {
4493
- F: __dxlog_file16,
4546
+ F: __dxlog_file17,
4494
4547
  L: 322,
4495
4548
  S: this,
4496
4549
  C: (f, a) => f(...a)
@@ -4553,7 +4606,7 @@ var DataSpace = class {
4553
4606
  space: this.key,
4554
4607
  rootUrl
4555
4608
  }, {
4556
- F: __dxlog_file16,
4609
+ F: __dxlog_file17,
4557
4610
  L: 388,
4558
4611
  S: this,
4559
4612
  C: (f, a) => f(...a)
@@ -4607,8 +4660,8 @@ var DataSpace = class {
4607
4660
  rootUrl,
4608
4661
  err
4609
4662
  }, {
4610
- F: __dxlog_file16,
4611
- L: 431,
4663
+ F: __dxlog_file17,
4664
+ L: 433,
4612
4665
  S: this,
4613
4666
  C: (f, a) => f(...a)
4614
4667
  });
@@ -4636,7 +4689,7 @@ var DataSpace = class {
4636
4689
  return null;
4637
4690
  }
4638
4691
  const { newRoot } = await runEpochMigration(ctx, {
4639
- repo: this._echoHost.automergeRepo,
4692
+ echoHost: this._echoHost,
4640
4693
  spaceId: this.id,
4641
4694
  spaceKey: this.key,
4642
4695
  migration: options.migration,
@@ -4693,8 +4746,8 @@ var DataSpace = class {
4693
4746
  (0, import_log12.log)("new state", {
4694
4747
  state: import_services12.SpaceState[this._state]
4695
4748
  }, {
4696
- F: __dxlog_file16,
4697
- L: 512,
4749
+ F: __dxlog_file17,
4750
+ L: 514,
4698
4751
  S: this,
4699
4752
  C: (f, a) => f(...a)
4700
4753
  });
@@ -4823,7 +4876,7 @@ function _ts_decorate5(decorators, target, key, desc) {
4823
4876
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4824
4877
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4825
4878
  }
4826
- 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";
4827
4880
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
4828
4881
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
4829
4882
  var DEFAULT_SPACE_KEY = "__DEFAULT__";
@@ -4837,9 +4890,12 @@ var DataSpaceManager = class {
4837
4890
  this._echoHost = _echoHost;
4838
4891
  this._invitationsManager = _invitationsManager;
4839
4892
  this._params = _params;
4840
- this._ctx = new import_context14.Context();
4841
- this.updated = new import_async17.Event();
4842
- 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);
4843
4899
  this._isOpen = false;
4844
4900
  this._instanceId = import_keys12.PublicKey.random().toHex();
4845
4901
  import_tracing6.trace.diagnostic({
@@ -4871,34 +4927,34 @@ var DataSpaceManager = class {
4871
4927
  }
4872
4928
  async open() {
4873
4929
  (0, import_log15.log)("open", void 0, {
4874
- F: __dxlog_file17,
4875
- L: 146,
4930
+ F: __dxlog_file18,
4931
+ L: 156,
4876
4932
  S: this,
4877
4933
  C: (f, a) => f(...a)
4878
4934
  });
4879
4935
  import_log15.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
4880
4936
  id: this._instanceId
4881
4937
  }), {
4882
- F: __dxlog_file17,
4883
- L: 147,
4938
+ F: __dxlog_file18,
4939
+ L: 157,
4884
4940
  S: this,
4885
4941
  C: (f, a) => f(...a)
4886
4942
  });
4887
4943
  (0, import_log15.log)("metadata loaded", {
4888
4944
  spaces: this._metadataStore.spaces.length
4889
4945
  }, {
4890
- F: __dxlog_file17,
4891
- L: 148,
4946
+ F: __dxlog_file18,
4947
+ L: 158,
4892
4948
  S: this,
4893
4949
  C: (f, a) => f(...a)
4894
4950
  });
4895
- await (0, import_util10.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
4951
+ await (0, import_util9.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
4896
4952
  try {
4897
4953
  (0, import_log15.log)("load space", {
4898
4954
  spaceMetadata
4899
4955
  }, {
4900
- F: __dxlog_file17,
4901
- L: 152,
4956
+ F: __dxlog_file18,
4957
+ L: 162,
4902
4958
  S: this,
4903
4959
  C: (f, a) => f(...a)
4904
4960
  });
@@ -4908,8 +4964,8 @@ var DataSpaceManager = class {
4908
4964
  spaceMetadata,
4909
4965
  err
4910
4966
  }, {
4911
- F: __dxlog_file17,
4912
- L: 155,
4967
+ F: __dxlog_file18,
4968
+ L: 165,
4913
4969
  S: this,
4914
4970
  C: (f, a) => f(...a)
4915
4971
  });
@@ -4920,16 +4976,16 @@ var DataSpaceManager = class {
4920
4976
  import_log15.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
4921
4977
  id: this._instanceId
4922
4978
  }), {
4923
- F: __dxlog_file17,
4924
- L: 162,
4979
+ F: __dxlog_file18,
4980
+ L: 172,
4925
4981
  S: this,
4926
4982
  C: (f, a) => f(...a)
4927
4983
  });
4928
4984
  }
4929
4985
  async close() {
4930
4986
  (0, import_log15.log)("close", void 0, {
4931
- F: __dxlog_file17,
4932
- L: 167,
4987
+ F: __dxlog_file18,
4988
+ L: 177,
4933
4989
  S: this,
4934
4990
  C: (f, a) => f(...a)
4935
4991
  });
@@ -4945,8 +5001,8 @@ var DataSpaceManager = class {
4945
5001
  */
4946
5002
  async createSpace() {
4947
5003
  (0, import_invariant15.invariant)(this._isOpen, "Not open.", {
4948
- F: __dxlog_file17,
4949
- L: 181,
5004
+ F: __dxlog_file18,
5005
+ L: 191,
4950
5006
  S: this,
4951
5007
  A: [
4952
5008
  "this._isOpen",
@@ -4966,8 +5022,8 @@ var DataSpaceManager = class {
4966
5022
  (0, import_log15.log)("creating space...", {
4967
5023
  spaceKey
4968
5024
  }, {
4969
- F: __dxlog_file17,
4970
- L: 193,
5025
+ F: __dxlog_file18,
5026
+ L: 203,
4971
5027
  S: this,
4972
5028
  C: (f, a) => f(...a)
4973
5029
  });
@@ -4978,8 +5034,8 @@ var DataSpaceManager = class {
4978
5034
  await this._metadataStore.addSpace(metadata);
4979
5035
  const memberCredential = credentials[1];
4980
5036
  (0, import_invariant15.invariant)((0, import_credentials15.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4981
- F: __dxlog_file17,
4982
- L: 203,
5037
+ F: __dxlog_file18,
5038
+ L: 213,
4983
5039
  S: this,
4984
5040
  A: [
4985
5041
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -4996,13 +5052,13 @@ var DataSpaceManager = class {
4996
5052
  return false;
4997
5053
  }
4998
5054
  switch (space.databaseRoot.getVersion()) {
4999
- case import_echo_protocol2.SpaceDocVersion.CURRENT: {
5055
+ case import_echo_protocol3.SpaceDocVersion.CURRENT: {
5000
5056
  const [_, properties] = (0, import_echo_db2.findInlineObjectOfType)(space.databaseRoot.docSync(), import_echo_schema2.TYPE_PROPERTIES) ?? [];
5001
5057
  return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
5002
5058
  }
5003
- case import_echo_protocol2.SpaceDocVersion.LEGACY: {
5059
+ case import_echo_protocol3.SpaceDocVersion.LEGACY: {
5004
5060
  const convertedDoc = await (0, import_echo_db2.convertLegacyReferences)(space.databaseRoot.docSync());
5005
- 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) ?? [];
5006
5062
  return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
5007
5063
  }
5008
5064
  default:
@@ -5010,8 +5066,8 @@ var DataSpaceManager = class {
5010
5066
  version: space.databaseRoot.getVersion(),
5011
5067
  spaceId: space.id
5012
5068
  }, {
5013
- F: __dxlog_file17,
5014
- L: 228,
5069
+ F: __dxlog_file18,
5070
+ L: 238,
5015
5071
  S: this,
5016
5072
  C: (f, a) => f(...a)
5017
5073
  });
@@ -5023,7 +5079,7 @@ var DataSpaceManager = class {
5023
5079
  const document = await this._getSpaceRootDocument(space);
5024
5080
  const properties = {
5025
5081
  system: {
5026
- 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))
5027
5083
  },
5028
5084
  data: {
5029
5085
  [DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
@@ -5034,7 +5090,7 @@ var DataSpaceManager = class {
5034
5090
  };
5035
5091
  const propertiesId = (0, import_echo_schema2.generateEchoId)();
5036
5092
  document.change((doc) => {
5037
- (0, import_util10.assignDeep)(doc, [
5093
+ (0, import_util9.assignDeep)(doc, [
5038
5094
  "objects",
5039
5095
  propertiesId
5040
5096
  ], properties);
@@ -5045,8 +5101,8 @@ var DataSpaceManager = class {
5045
5101
  async _getSpaceRootDocument(space) {
5046
5102
  const automergeIndex = space.automergeSpaceState.rootUrl;
5047
5103
  (0, import_invariant15.invariant)(automergeIndex, void 0, {
5048
- F: __dxlog_file17,
5049
- L: 261,
5104
+ F: __dxlog_file18,
5105
+ L: 271,
5050
5106
  S: this,
5051
5107
  A: [
5052
5108
  "automergeIndex",
@@ -5062,14 +5118,14 @@ var DataSpaceManager = class {
5062
5118
  (0, import_log15.log)("accept space", {
5063
5119
  opts
5064
5120
  }, {
5065
- F: __dxlog_file17,
5066
- L: 270,
5121
+ F: __dxlog_file18,
5122
+ L: 280,
5067
5123
  S: this,
5068
5124
  C: (f, a) => f(...a)
5069
5125
  });
5070
5126
  (0, import_invariant15.invariant)(this._isOpen, "Not open.", {
5071
- F: __dxlog_file17,
5072
- L: 271,
5127
+ F: __dxlog_file18,
5128
+ L: 281,
5073
5129
  S: this,
5074
5130
  A: [
5075
5131
  "this._isOpen",
@@ -5077,8 +5133,8 @@ var DataSpaceManager = class {
5077
5133
  ]
5078
5134
  });
5079
5135
  (0, import_invariant15.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
5080
- F: __dxlog_file17,
5081
- L: 272,
5136
+ F: __dxlog_file18,
5137
+ L: 282,
5082
5138
  S: this,
5083
5139
  A: [
5084
5140
  "!this._spaces.has(opts.spaceKey)",
@@ -5098,23 +5154,72 @@ var DataSpaceManager = class {
5098
5154
  this.updated.emit();
5099
5155
  return space;
5100
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
+ }
5101
5194
  /**
5102
5195
  * Wait until the space data pipeline is fully initialized.
5103
5196
  * Used by invitation handler.
5104
5197
  * TODO(dmaretskyi): Consider removing.
5105
5198
  */
5106
5199
  async waitUntilSpaceReady(spaceKey) {
5107
- await (0, import_context14.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
5200
+ await (0, import_context13.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
5108
5201
  const space = this._spaces.get(spaceKey);
5109
5202
  return !!space && space.state === import_services14.SpaceState.READY;
5110
5203
  }));
5111
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
+ }
5112
5217
  async _constructSpace(metadata) {
5113
5218
  (0, import_log15.log)("construct space", {
5114
5219
  metadata
5115
5220
  }, {
5116
- F: __dxlog_file17,
5117
- L: 306,
5221
+ F: __dxlog_file18,
5222
+ L: 358,
5118
5223
  S: this,
5119
5224
  C: (f, a) => f(...a)
5120
5225
  });
@@ -5139,9 +5244,10 @@ var DataSpaceManager = class {
5139
5244
  swarmIdentity: {
5140
5245
  peerKey: this._signingContext.deviceKey,
5141
5246
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5142
- credentialAuthenticator: (0, import_util10.deferFunction)(() => dataSpace.authVerifier.verifier)
5247
+ credentialAuthenticator: (0, import_util9.deferFunction)(() => dataSpace.authVerifier.verifier)
5143
5248
  },
5144
5249
  onAuthorizedConnection: (session) => {
5250
+ session.addExtension("dxos.mesh.teleport.admission-discovery", new import_echo_pipeline4.CredentialServerExtension(space));
5145
5251
  session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5146
5252
  remotePeerId: session.remotePeerId
5147
5253
  }));
@@ -5151,8 +5257,8 @@ var DataSpaceManager = class {
5151
5257
  },
5152
5258
  onAuthFailure: () => {
5153
5259
  import_log15.log.warn("auth failure", void 0, {
5154
- F: __dxlog_file17,
5155
- L: 343,
5260
+ F: __dxlog_file18,
5261
+ L: 396,
5156
5262
  S: this,
5157
5263
  C: (f, a) => f(...a)
5158
5264
  });
@@ -5184,8 +5290,8 @@ var DataSpaceManager = class {
5184
5290
  (0, import_log15.log)("before space ready", {
5185
5291
  space: space.key
5186
5292
  }, {
5187
- F: __dxlog_file17,
5188
- L: 370,
5293
+ F: __dxlog_file18,
5294
+ L: 423,
5189
5295
  S: this,
5190
5296
  C: (f, a) => f(...a)
5191
5297
  });
@@ -5195,8 +5301,8 @@ var DataSpaceManager = class {
5195
5301
  space: space.key,
5196
5302
  open: this._isOpen
5197
5303
  }, {
5198
- F: __dxlog_file17,
5199
- L: 373,
5304
+ F: __dxlog_file18,
5305
+ L: 426,
5200
5306
  S: this,
5201
5307
  C: (f, a) => f(...a)
5202
5308
  });
@@ -5214,8 +5320,8 @@ var DataSpaceManager = class {
5214
5320
  (0, import_log15.log)("before space close", {
5215
5321
  space: space.key
5216
5322
  }, {
5217
- F: __dxlog_file17,
5218
- L: 381,
5323
+ F: __dxlog_file18,
5324
+ L: 434,
5219
5325
  S: this,
5220
5326
  C: (f, a) => f(...a)
5221
5327
  });
@@ -5243,7 +5349,7 @@ var DataSpaceManager = class {
5243
5349
  const peers = presence.getPeersByIdentityKey(member.key);
5244
5350
  const sessions = peers.map((p) => p.peerId && spaceProtocol.sessions.get(p.peerId));
5245
5351
  const sessionsToClose = sessions.filter((s) => {
5246
- 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;
5247
5353
  });
5248
5354
  sessionsToClose.forEach((session) => {
5249
5355
  void session.close().catch(import_log15.log.error);
@@ -5255,8 +5361,8 @@ var DataSpaceManager = class {
5255
5361
  peersOnline: presence.getPeersOnline().length,
5256
5362
  closedSessions
5257
5363
  }, {
5258
- F: __dxlog_file17,
5259
- L: 417,
5364
+ F: __dxlog_file18,
5365
+ L: 470,
5260
5366
  S: this,
5261
5367
  C: (f, a) => f(...a)
5262
5368
  });
@@ -5270,8 +5376,8 @@ var DataSpaceManager = class {
5270
5376
  (0, import_log15.log)("closing a session with a removed peer", {
5271
5377
  peerId: peerState.peerId
5272
5378
  }, {
5273
- F: __dxlog_file17,
5274
- L: 431,
5379
+ F: __dxlog_file18,
5380
+ L: 484,
5275
5381
  S: this,
5276
5382
  C: (f, a) => f(...a)
5277
5383
  });
@@ -5316,21 +5422,21 @@ var DataSpaceManager = class {
5316
5422
  }
5317
5423
  };
5318
5424
  _ts_decorate5([
5319
- import_async17.synchronized
5425
+ import_async16.synchronized
5320
5426
  ], DataSpaceManager.prototype, "open", null);
5321
5427
  _ts_decorate5([
5322
- import_async17.synchronized
5428
+ import_async16.synchronized
5323
5429
  ], DataSpaceManager.prototype, "close", null);
5324
5430
  _ts_decorate5([
5325
- import_async17.synchronized
5431
+ import_async16.synchronized
5326
5432
  ], DataSpaceManager.prototype, "createSpace", null);
5327
5433
  _ts_decorate5([
5328
- import_async17.synchronized
5434
+ import_async16.synchronized
5329
5435
  ], DataSpaceManager.prototype, "acceptSpace", null);
5330
5436
  DataSpaceManager = _ts_decorate5([
5331
- (0, import_async17.trackLeaks)("open", "close")
5437
+ (0, import_async16.trackLeaks)("open", "close")
5332
5438
  ], DataSpaceManager);
5333
- 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";
5334
5440
  var SpacesServiceImpl = class {
5335
5441
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
5336
5442
  this._identityManager = _identityManager;
@@ -5374,8 +5480,8 @@ var SpacesServiceImpl = class {
5374
5480
  }
5375
5481
  const credentials = await (0, import_credentials19.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
5376
5482
  (0, import_invariant16.invariant)(credentials[0].credential, void 0, {
5377
- F: __dxlog_file18,
5378
- L: 98,
5483
+ F: __dxlog_file19,
5484
+ L: 102,
5379
5485
  S: this,
5380
5486
  A: [
5381
5487
  "credentials[0].credential",
@@ -5384,26 +5490,26 @@ var SpacesServiceImpl = class {
5384
5490
  });
5385
5491
  const spaceMemberCredential = credentials[0].credential.credential;
5386
5492
  (0, import_invariant16.invariant)((0, import_credentials19.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5387
- F: __dxlog_file18,
5388
- L: 100,
5493
+ F: __dxlog_file19,
5494
+ L: 104,
5389
5495
  S: this,
5390
5496
  A: [
5391
5497
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5392
5498
  ""
5393
5499
  ]
5394
5500
  });
5395
- await (0, import_feed_store4.writeMessages)(space.controlPipeline.writer, credentials);
5501
+ await (0, import_feed_store5.writeMessages)(space.controlPipeline.writer, credentials);
5396
5502
  }
5397
5503
  querySpaces() {
5398
5504
  return new import_codec_protobuf11.Stream(({ next, ctx }) => {
5399
- const scheduler = new import_async18.UpdateScheduler(ctx, async () => {
5505
+ const scheduler = new import_async17.UpdateScheduler(ctx, async () => {
5400
5506
  const dataSpaceManager = await this._getDataSpaceManager();
5401
5507
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
5402
5508
  (0, import_log16.log)("update", {
5403
5509
  spaces
5404
5510
  }, {
5405
- F: __dxlog_file18,
5406
- L: 111,
5511
+ F: __dxlog_file19,
5512
+ L: 115,
5407
5513
  S: this,
5408
5514
  C: (f, a) => f(...a)
5409
5515
  });
@@ -5414,9 +5520,9 @@ var SpacesServiceImpl = class {
5414
5520
  }, {
5415
5521
  maxFrequency: process.env.NODE_ENV === "test" ? void 0 : 2
5416
5522
  });
5417
- (0, import_async18.scheduleTask)(ctx, async () => {
5523
+ (0, import_async17.scheduleTask)(ctx, async () => {
5418
5524
  const dataSpaceManager = await this._getDataSpaceManager();
5419
- const subscriptions = new import_async18.EventSubscriptions();
5525
+ const subscriptions = new import_async17.EventSubscriptions();
5420
5526
  ctx.onDispose(() => subscriptions.clear());
5421
5527
  const subscribeSpaces = () => {
5422
5528
  subscriptions.clear();
@@ -5456,7 +5562,7 @@ var SpacesServiceImpl = class {
5456
5562
  }
5457
5563
  subscribeMessages({ spaceKey, channel }) {
5458
5564
  return new import_codec_protobuf11.Stream(({ ctx, next }) => {
5459
- (0, import_async18.scheduleTask)(ctx, async () => {
5565
+ (0, import_async17.scheduleTask)(ctx, async () => {
5460
5566
  const dataSpaceManager = await this._getDataSpaceManager();
5461
5567
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
5462
5568
  const handle = space.listen(getChannelId(channel), (message) => {
@@ -5475,7 +5581,7 @@ var SpacesServiceImpl = class {
5475
5581
  }
5476
5582
  };
5477
5583
  ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
5478
- (0, import_async18.scheduleTask)(ctx, async () => {
5584
+ (0, import_async17.scheduleTask)(ctx, async () => {
5479
5585
  await space.spaceState.addCredentialProcessor(processor);
5480
5586
  if (noTail) {
5481
5587
  close();
@@ -5494,8 +5600,8 @@ var SpacesServiceImpl = class {
5494
5600
  });
5495
5601
  } else {
5496
5602
  (0, import_invariant16.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
5497
- F: __dxlog_file18,
5498
- L: 209,
5603
+ F: __dxlog_file19,
5604
+ L: 213,
5499
5605
  S: this,
5500
5606
  A: [
5501
5607
  "!credential.id",
@@ -5503,8 +5609,8 @@ var SpacesServiceImpl = class {
5503
5609
  ]
5504
5610
  });
5505
5611
  (0, import_invariant16.invariant)(this._identityManager.identity, "Identity is not available", {
5506
- F: __dxlog_file18,
5507
- L: 210,
5612
+ F: __dxlog_file19,
5613
+ L: 214,
5508
5614
  S: this,
5509
5615
  A: [
5510
5616
  "this._identityManager.identity",
@@ -5513,8 +5619,8 @@ var SpacesServiceImpl = class {
5513
5619
  });
5514
5620
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
5515
5621
  (0, import_invariant16.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
5516
- F: __dxlog_file18,
5517
- L: 212,
5622
+ F: __dxlog_file19,
5623
+ L: 216,
5518
5624
  S: this,
5519
5625
  A: [
5520
5626
  "credential.issuer.equals(signer.getIssuer())",
@@ -5544,6 +5650,59 @@ var SpacesServiceImpl = class {
5544
5650
  epochCredential: credential ?? void 0
5545
5651
  };
5546
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
+ }
5547
5706
  _serializeSpace(space) {
5548
5707
  return {
5549
5708
  id: space.id,
@@ -5561,7 +5720,8 @@ var SpacesServiceImpl = class {
5561
5720
  startDataTimeframe: void 0,
5562
5721
  currentDataTimeframe: void 0,
5563
5722
  targetDataTimeframe: void 0,
5564
- totalDataTimeframe: void 0
5723
+ totalDataTimeframe: void 0,
5724
+ spaceRootUrl: space.databaseRoot?.url
5565
5725
  },
5566
5726
  members: Array.from(space.inner.spaceState.members.values()).map((member) => {
5567
5727
  const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
@@ -5613,8 +5773,8 @@ function _ts_decorate6(decorators, target, key, desc) {
5613
5773
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5614
5774
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5615
5775
  }
5616
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5617
- 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 {
5618
5778
  constructor(storage, level, networkManager, signalManager, _runtimeParams) {
5619
5779
  super();
5620
5780
  this.storage = storage;
@@ -5622,15 +5782,15 @@ var ServiceContext = class extends import_context15.Resource {
5622
5782
  this.networkManager = networkManager;
5623
5783
  this.signalManager = signalManager;
5624
5784
  this._runtimeParams = _runtimeParams;
5625
- this.initialized = new import_async19.Trigger();
5785
+ this.initialized = new import_async18.Trigger();
5626
5786
  this._handlerFactories = /* @__PURE__ */ new Map();
5627
5787
  this._instanceId = import_keys13.PublicKey.random().toHex();
5628
5788
  this.metadataStore = new import_echo_pipeline5.MetadataStore(storage.createDirectory("metadata"));
5629
5789
  this.snapshotStore = new import_echo_pipeline5.SnapshotStore(storage.createDirectory("snapshots"));
5630
5790
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
5631
5791
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
5632
- this.feedStore = new import_feed_store5.FeedStore({
5633
- factory: new import_feed_store5.FeedFactory({
5792
+ this.feedStore = new import_feed_store6.FeedStore({
5793
+ factory: new import_feed_store6.FeedFactory({
5634
5794
  root: storage.createDirectory("feeds"),
5635
5795
  signer: this.keyring,
5636
5796
  hypercore: {
@@ -5657,7 +5817,7 @@ var ServiceContext = class extends import_context15.Resource {
5657
5817
  async _open(ctx) {
5658
5818
  await this._checkStorageVersion();
5659
5819
  (0, import_log17.log)("opening...", void 0, {
5660
- F: __dxlog_file19,
5820
+ F: __dxlog_file20,
5661
5821
  L: 149,
5662
5822
  S: this,
5663
5823
  C: (f, a) => f(...a)
@@ -5665,7 +5825,7 @@ var ServiceContext = class extends import_context15.Resource {
5665
5825
  import_log17.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
5666
5826
  id: this._instanceId
5667
5827
  }), {
5668
- F: __dxlog_file19,
5828
+ F: __dxlog_file20,
5669
5829
  L: 150,
5670
5830
  S: this,
5671
5831
  C: (f, a) => f(...a)
@@ -5683,7 +5843,7 @@ var ServiceContext = class extends import_context15.Resource {
5683
5843
  (0, import_log17.log)("loaded persistent invitations", {
5684
5844
  count: loadedInvitations.invitations?.length
5685
5845
  }, {
5686
- F: __dxlog_file19,
5846
+ F: __dxlog_file20,
5687
5847
  L: 163,
5688
5848
  S: this,
5689
5849
  C: (f, a) => f(...a)
@@ -5691,13 +5851,13 @@ var ServiceContext = class extends import_context15.Resource {
5691
5851
  import_log17.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
5692
5852
  id: this._instanceId
5693
5853
  }), {
5694
- F: __dxlog_file19,
5854
+ F: __dxlog_file20,
5695
5855
  L: 165,
5696
5856
  S: this,
5697
5857
  C: (f, a) => f(...a)
5698
5858
  });
5699
5859
  (0, import_log17.log)("opened", void 0, {
5700
- F: __dxlog_file19,
5860
+ F: __dxlog_file20,
5701
5861
  L: 166,
5702
5862
  S: this,
5703
5863
  C: (f, a) => f(...a)
@@ -5705,7 +5865,7 @@ var ServiceContext = class extends import_context15.Resource {
5705
5865
  }
5706
5866
  async _close(ctx) {
5707
5867
  (0, import_log17.log)("closing...", void 0, {
5708
- F: __dxlog_file19,
5868
+ F: __dxlog_file20,
5709
5869
  L: 170,
5710
5870
  S: this,
5711
5871
  C: (f, a) => f(...a)
@@ -5722,7 +5882,7 @@ var ServiceContext = class extends import_context15.Resource {
5722
5882
  await this.networkManager.close();
5723
5883
  await this.signalManager.close();
5724
5884
  (0, import_log17.log)("closed", void 0, {
5725
- F: __dxlog_file19,
5885
+ F: __dxlog_file20,
5726
5886
  L: 182,
5727
5887
  S: this,
5728
5888
  C: (f, a) => f(...a)
@@ -5730,13 +5890,16 @@ var ServiceContext = class extends import_context15.Resource {
5730
5890
  }
5731
5891
  async createIdentity(params = {}) {
5732
5892
  const identity = await this.identityManager.createIdentity(params);
5733
- 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
+ }));
5734
5897
  return identity;
5735
5898
  }
5736
5899
  getInvitationHandler(invitation) {
5737
5900
  const factory = this._handlerFactories.get(invitation.kind);
5738
5901
  (0, import_invariant17.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
5739
- F: __dxlog_file19,
5902
+ F: __dxlog_file20,
5740
5903
  L: 193,
5741
5904
  S: this,
5742
5905
  A: [
@@ -5756,7 +5919,10 @@ var ServiceContext = class extends import_context15.Resource {
5756
5919
  }
5757
5920
  async _acceptIdentity(params) {
5758
5921
  const identity = await this.identityManager.acceptIdentity(params);
5759
- 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
+ }));
5760
5926
  return identity;
5761
5927
  }
5762
5928
  async _checkStorageVersion() {
@@ -5768,7 +5934,7 @@ var ServiceContext = class extends import_context15.Resource {
5768
5934
  // Called when identity is created.
5769
5935
  async _initialize(ctx) {
5770
5936
  (0, import_log17.log)("initializing spaces...", void 0, {
5771
- F: __dxlog_file19,
5937
+ F: __dxlog_file20,
5772
5938
  L: 224,
5773
5939
  S: this,
5774
5940
  C: (f, a) => f(...a)
@@ -5791,7 +5957,7 @@ var ServiceContext = class extends import_context15.Resource {
5791
5957
  await this.dataSpaceManager.open();
5792
5958
  this._handlerFactories.set(import_services16.Invitation.Kind.SPACE, (invitation) => {
5793
5959
  (0, import_invariant17.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
5794
- F: __dxlog_file19,
5960
+ F: __dxlog_file20,
5795
5961
  L: 249,
5796
5962
  S: this,
5797
5963
  A: [
@@ -5815,7 +5981,7 @@ var ServiceContext = class extends import_context15.Resource {
5815
5981
  (0, import_log17.log)("dataSpaceManager not initialized yet, ignoring space admission", {
5816
5982
  details: assertion
5817
5983
  }, {
5818
- F: __dxlog_file19,
5984
+ F: __dxlog_file20,
5819
5985
  L: 265,
5820
5986
  S: this,
5821
5987
  C: (f, a) => f(...a)
@@ -5826,7 +5992,7 @@ var ServiceContext = class extends import_context15.Resource {
5826
5992
  (0, import_log17.log)("space already exists, ignoring space admission", {
5827
5993
  details: assertion
5828
5994
  }, {
5829
- F: __dxlog_file19,
5995
+ F: __dxlog_file20,
5830
5996
  L: 269,
5831
5997
  S: this,
5832
5998
  C: (f, a) => f(...a)
@@ -5837,7 +6003,7 @@ var ServiceContext = class extends import_context15.Resource {
5837
6003
  (0, import_log17.log)("accepting space recorded in halo", {
5838
6004
  details: assertion
5839
6005
  }, {
5840
- F: __dxlog_file19,
6006
+ F: __dxlog_file20,
5841
6007
  L: 274,
5842
6008
  S: this,
5843
6009
  C: (f, a) => f(...a)
@@ -5848,7 +6014,7 @@ var ServiceContext = class extends import_context15.Resource {
5848
6014
  });
5849
6015
  } catch (err) {
5850
6016
  import_log17.log.catch(err, void 0, {
5851
- F: __dxlog_file19,
6017
+ F: __dxlog_file20,
5852
6018
  L: 280,
5853
6019
  S: this,
5854
6020
  C: (f, a) => f(...a)
@@ -5866,7 +6032,7 @@ _ts_decorate6([
5866
6032
  import_tracing8.trace.span()
5867
6033
  ], ServiceContext.prototype, "_initialize", null);
5868
6034
  ServiceContext = _ts_decorate6([
5869
- (0, import_util11.safeInstanceof)("dxos.client-services.ServiceContext"),
6035
+ (0, import_util10.safeInstanceof)("dxos.client-services.ServiceContext"),
5870
6036
  import_tracing8.trace.resource()
5871
6037
  ], ServiceContext);
5872
6038
  var ServiceRegistry = class {
@@ -5901,7 +6067,7 @@ function _ts_decorate7(decorators, target, key, desc) {
5901
6067
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5902
6068
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5903
6069
  }
5904
- 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";
5905
6071
  var Lock = class {
5906
6072
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
5907
6073
  this._lockPath = lockPath;
@@ -5913,7 +6079,7 @@ var Lock = class {
5913
6079
  }
5914
6080
  async acquire() {
5915
6081
  (0, import_log18.log)("acquiring lock...", void 0, {
5916
- F: __dxlog_file20,
6082
+ F: __dxlog_file21,
5917
6083
  L: 32,
5918
6084
  S: this,
5919
6085
  C: (f, a) => f(...a)
@@ -5921,7 +6087,7 @@ var Lock = class {
5921
6087
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
5922
6088
  await this._onAcquire?.();
5923
6089
  (0, import_log18.log)("acquired lock", void 0, {
5924
- F: __dxlog_file20,
6090
+ F: __dxlog_file21,
5925
6091
  L: 37,
5926
6092
  S: this,
5927
6093
  C: (f, a) => f(...a)
@@ -5930,7 +6096,7 @@ var Lock = class {
5930
6096
  async release() {
5931
6097
  await this._onRelease?.();
5932
6098
  (0, import_invariant18.invariant)(this._fileHandle, "Lock is not acquired", {
5933
- F: __dxlog_file20,
6099
+ F: __dxlog_file21,
5934
6100
  L: 42,
5935
6101
  S: this,
5936
6102
  A: [
@@ -5946,7 +6112,7 @@ _ts_decorate7([
5946
6112
  ], Lock.prototype, "lockKey", null);
5947
6113
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
5948
6114
  var getRootPath = (config) => {
5949
- 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 ?? {};
5950
6116
  return `${dataRoot}/`;
5951
6117
  };
5952
6118
  var isPersistent = (config) => {
@@ -6002,7 +6168,159 @@ var createLevel = async (config) => {
6002
6168
  await level.open();
6003
6169
  return level;
6004
6170
  };
6005
- 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";
6006
6324
  var DevicesServiceImpl = class {
6007
6325
  constructor(_identityManager) {
6008
6326
  this._identityManager = _identityManager;
@@ -6019,8 +6337,8 @@ var DevicesServiceImpl = class {
6019
6337
  devices: []
6020
6338
  });
6021
6339
  } else {
6022
- (0, import_invariant20.invariant)(this._identityManager.identity?.presence, "presence not present", {
6023
- F: __dxlog_file21,
6340
+ (0, import_invariant21.invariant)(this._identityManager.identity?.presence, "presence not present", {
6341
+ F: __dxlog_file23,
6024
6342
  L: 32,
6025
6343
  S: this,
6026
6344
  A: [
@@ -6061,7 +6379,7 @@ var DevicesServiceImpl = class {
6061
6379
  presenceSubscribed = true;
6062
6380
  }
6063
6381
  };
6064
- const subscriptions = new import_async21.EventSubscriptions();
6382
+ const subscriptions = new import_async20.EventSubscriptions();
6065
6383
  if (this._identityManager.identity) {
6066
6384
  subscribeIdentity();
6067
6385
  subscribePresence();
@@ -6113,33 +6431,110 @@ var findConfigs = () => {
6113
6431
  const configs = import_tracing10.TRACE_PROCESSOR.findResourcesByAnnotation(import_config3.ConfigResource);
6114
6432
  return configs.map((r) => r.instance.deref()).filter(import_util13.nonNullable);
6115
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
+ };
6116
6511
  var LoggingServiceImpl = class {
6117
6512
  constructor() {
6118
6513
  this._logs = new import_async22.Event();
6119
6514
  this._started = Date.now();
6120
- this._sessionId = import_keys17.PublicKey.random().toHex();
6515
+ this._sessionId = import_keys18.PublicKey.random().toHex();
6121
6516
  this._logProcessor = (_config, entry2) => {
6122
6517
  this._logs.emit(entry2);
6123
6518
  };
6124
6519
  }
6125
6520
  async open() {
6126
- import_log20.log.runtimeConfig.processors.push(this._logProcessor);
6521
+ import_log21.log.runtimeConfig.processors.push(this._logProcessor);
6127
6522
  }
6128
6523
  async close() {
6129
- const index = import_log20.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6130
- 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);
6131
6526
  }
6132
6527
  async controlMetrics({ reset, record }) {
6133
6528
  if (reset) {
6134
- import_util15.tracer.clear();
6529
+ import_util16.tracer.clear();
6135
6530
  }
6136
6531
  if (record === true) {
6137
- import_util15.tracer.start();
6532
+ import_util16.tracer.start();
6138
6533
  } else if (record === false) {
6139
- import_util15.tracer.stop();
6534
+ import_util16.tracer.stop();
6140
6535
  }
6141
6536
  return {
6142
- recording: import_util15.tracer.recording
6537
+ recording: import_util16.tracer.recording
6143
6538
  };
6144
6539
  }
6145
6540
  /**
@@ -6147,13 +6542,13 @@ var LoggingServiceImpl = class {
6147
6542
  */
6148
6543
  queryMetrics({ interval = 5e3 }) {
6149
6544
  const getNumericalValues = (key) => {
6150
- const events = import_util15.tracer.get(key) ?? [];
6545
+ const events = import_util16.tracer.get(key) ?? [];
6151
6546
  return {
6152
6547
  key,
6153
- stats: (0, import_util15.numericalValues)(events, "duration")
6548
+ stats: (0, import_util16.numericalValues)(events, "duration")
6154
6549
  };
6155
6550
  };
6156
- return new import_codec_protobuf13.Stream(({ next }) => {
6551
+ return new import_codec_protobuf14.Stream(({ next }) => {
6157
6552
  const update = () => {
6158
6553
  const metrics = {
6159
6554
  timestamp: /* @__PURE__ */ new Date(),
@@ -6175,7 +6570,7 @@ var LoggingServiceImpl = class {
6175
6570
  });
6176
6571
  }
6177
6572
  queryLogs(request) {
6178
- return new import_codec_protobuf13.Stream(({ ctx, next }) => {
6573
+ return new import_codec_protobuf14.Stream(({ ctx, next }) => {
6179
6574
  const handler = (entry2) => {
6180
6575
  if (LOG_PROCESSING > 0) {
6181
6576
  return;
@@ -6188,7 +6583,7 @@ var LoggingServiceImpl = class {
6188
6583
  }
6189
6584
  const record = {
6190
6585
  ...entry2,
6191
- context: (0, import_util15.jsonify)((0, import_log20.getContextFromEntry)(entry2)),
6586
+ context: (0, import_util16.jsonify)((0, import_log21.getContextFromEntry)(entry2)),
6192
6587
  timestamp: /* @__PURE__ */ new Date(),
6193
6588
  meta: {
6194
6589
  // TODO(dmaretskyi): Fix proto.
@@ -6197,7 +6592,7 @@ var LoggingServiceImpl = class {
6197
6592
  scope: {
6198
6593
  hostSessionId: this._sessionId,
6199
6594
  uptimeSeconds: (Date.now() - this._started) / 1e3,
6200
- name: (0, import_util15.getDebugName)(entry2.meta?.S)
6595
+ name: (0, import_util16.getDebugName)(entry2.meta?.S)
6201
6596
  }
6202
6597
  }
6203
6598
  };
@@ -6235,7 +6630,7 @@ var NetworkServiceImpl = class {
6235
6630
  this.signalManager = signalManager;
6236
6631
  }
6237
6632
  queryStatus() {
6238
- return new import_codec_protobuf14.Stream(({ next }) => {
6633
+ return new import_codec_protobuf15.Stream(({ next }) => {
6239
6634
  const update = () => {
6240
6635
  next({
6241
6636
  swarm: this.networkManager.connectionState,
@@ -6278,7 +6673,7 @@ var SystemServiceImpl = class {
6278
6673
  const diagnostics = await this._getDiagnostics();
6279
6674
  return {
6280
6675
  timestamp: /* @__PURE__ */ new Date(),
6281
- diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util16.jsonKeyReplacer)({
6676
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util17.jsonKeyReplacer)({
6282
6677
  truncate: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
6283
6678
  humanize: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
6284
6679
  })))
@@ -6292,7 +6687,7 @@ var SystemServiceImpl = class {
6292
6687
  }
6293
6688
  // TODO(burdon): Standardize interval option in stream request?
6294
6689
  queryStatus({ interval = 3e3 } = {}) {
6295
- return new import_codec_protobuf15.Stream(({ next }) => {
6690
+ return new import_codec_protobuf16.Stream(({ next }) => {
6296
6691
  const update = () => {
6297
6692
  next({
6298
6693
  status: this._getCurrentStatus()
@@ -6321,7 +6716,7 @@ function _ts_decorate8(decorators, target, key, desc) {
6321
6716
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6322
6717
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6323
6718
  }
6324
- 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";
6325
6720
  var ClientServicesHost = class {
6326
6721
  constructor({
6327
6722
  config,
@@ -6335,7 +6730,7 @@ var ClientServicesHost = class {
6335
6730
  runtimeParams
6336
6731
  } = {}) {
6337
6732
  this._tracingService = import_tracing9.TRACE_PROCESSOR.createTraceSender();
6338
- this._statusUpdate = new import_async20.Event();
6733
+ this._statusUpdate = new import_async19.Event();
6339
6734
  this._opening = false;
6340
6735
  this._open = false;
6341
6736
  this._storage = storage;
@@ -6354,7 +6749,10 @@ var ClientServicesHost = class {
6354
6749
  lockKey,
6355
6750
  onAcquire: () => {
6356
6751
  if (!this._opening) {
6357
- 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
+ }));
6358
6756
  }
6359
6757
  },
6360
6758
  onRelease: () => this.close()
@@ -6409,25 +6807,25 @@ var ClientServicesHost = class {
6409
6807
  * Can only be called once.
6410
6808
  */
6411
6809
  initialize({ config, ...options }) {
6412
- (0, import_invariant19.invariant)(!this._open, "service host is open", {
6413
- F: __dxlog_file22,
6414
- L: 186,
6810
+ (0, import_invariant20.invariant)(!this._open, "service host is open", {
6811
+ F: __dxlog_file24,
6812
+ L: 187,
6415
6813
  S: this,
6416
6814
  A: [
6417
6815
  "!this._open",
6418
6816
  "'service host is open'"
6419
6817
  ]
6420
6818
  });
6421
- (0, import_log19.log)("initializing...", void 0, {
6422
- F: __dxlog_file22,
6423
- L: 187,
6819
+ (0, import_log20.log)("initializing...", void 0, {
6820
+ F: __dxlog_file24,
6821
+ L: 188,
6424
6822
  S: this,
6425
6823
  C: (f, a) => f(...a)
6426
6824
  });
6427
6825
  if (config) {
6428
- (0, import_invariant19.invariant)(!this._config, "config already set", {
6429
- F: __dxlog_file22,
6430
- L: 190,
6826
+ (0, import_invariant20.invariant)(!this._config, "config already set", {
6827
+ F: __dxlog_file24,
6828
+ L: 191,
6431
6829
  S: this,
6432
6830
  A: [
6433
6831
  "!this._config",
@@ -6440,9 +6838,9 @@ var ClientServicesHost = class {
6440
6838
  }
6441
6839
  }
6442
6840
  if (!options.signalManager) {
6443
- import_log19.log.warn("running signaling without telemetry metadata.", void 0, {
6444
- F: __dxlog_file22,
6445
- L: 198,
6841
+ import_log20.log.warn("running signaling without telemetry metadata.", void 0, {
6842
+ F: __dxlog_file24,
6843
+ L: 199,
6446
6844
  S: this,
6447
6845
  C: (f, a) => f(...a)
6448
6846
  });
@@ -6451,9 +6849,9 @@ var ClientServicesHost = class {
6451
6849
  iceServers: this._config?.get("runtime.services.ice")
6452
6850
  }), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
6453
6851
  this._signalManager = signalManager;
6454
- (0, import_invariant19.invariant)(!this._networkManager, "network manager already set", {
6455
- F: __dxlog_file22,
6456
- L: 209,
6852
+ (0, import_invariant20.invariant)(!this._networkManager, "network manager already set", {
6853
+ F: __dxlog_file24,
6854
+ L: 210,
6457
6855
  S: this,
6458
6856
  A: [
6459
6857
  "!this._networkManager",
@@ -6465,9 +6863,9 @@ var ClientServicesHost = class {
6465
6863
  transportFactory,
6466
6864
  signalManager
6467
6865
  });
6468
- (0, import_log19.log)("initialized", void 0, {
6469
- F: __dxlog_file22,
6470
- L: 216,
6866
+ (0, import_log20.log)("initialized", void 0, {
6867
+ F: __dxlog_file24,
6868
+ L: 217,
6471
6869
  S: this,
6472
6870
  C: (f, a) => f(...a)
6473
6871
  });
@@ -6477,44 +6875,44 @@ var ClientServicesHost = class {
6477
6875
  return;
6478
6876
  }
6479
6877
  const traceId = import_keys15.PublicKey.random().toHex();
6480
- 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({
6481
6879
  id: traceId
6482
6880
  }), {
6483
- F: __dxlog_file22,
6484
- L: 227,
6881
+ F: __dxlog_file24,
6882
+ L: 228,
6485
6883
  S: this,
6486
6884
  C: (f, a) => f(...a)
6487
6885
  });
6488
- (0, import_invariant19.invariant)(this._config, "config not set", {
6489
- F: __dxlog_file22,
6490
- L: 229,
6886
+ (0, import_invariant20.invariant)(this._config, "config not set", {
6887
+ F: __dxlog_file24,
6888
+ L: 230,
6491
6889
  S: this,
6492
6890
  A: [
6493
6891
  "this._config",
6494
6892
  "'config not set'"
6495
6893
  ]
6496
6894
  });
6497
- (0, import_invariant19.invariant)(this._storage, "storage not set", {
6498
- F: __dxlog_file22,
6499
- L: 230,
6895
+ (0, import_invariant20.invariant)(this._storage, "storage not set", {
6896
+ F: __dxlog_file24,
6897
+ L: 231,
6500
6898
  S: this,
6501
6899
  A: [
6502
6900
  "this._storage",
6503
6901
  "'storage not set'"
6504
6902
  ]
6505
6903
  });
6506
- (0, import_invariant19.invariant)(this._signalManager, "signal manager not set", {
6507
- F: __dxlog_file22,
6508
- L: 231,
6904
+ (0, import_invariant20.invariant)(this._signalManager, "signal manager not set", {
6905
+ F: __dxlog_file24,
6906
+ L: 232,
6509
6907
  S: this,
6510
6908
  A: [
6511
6909
  "this._signalManager",
6512
6910
  "'signal manager not set'"
6513
6911
  ]
6514
6912
  });
6515
- (0, import_invariant19.invariant)(this._networkManager, "network manager not set", {
6516
- F: __dxlog_file22,
6517
- L: 232,
6913
+ (0, import_invariant20.invariant)(this._networkManager, "network manager not set", {
6914
+ F: __dxlog_file24,
6915
+ L: 233,
6518
6916
  S: this,
6519
6917
  A: [
6520
6918
  "this._networkManager",
@@ -6522,11 +6920,11 @@ var ClientServicesHost = class {
6522
6920
  ]
6523
6921
  });
6524
6922
  this._opening = true;
6525
- (0, import_log19.log)("opening...", {
6923
+ (0, import_log20.log)("opening...", {
6526
6924
  lockKey: this._resourceLock?.lockKey
6527
6925
  }, {
6528
- F: __dxlog_file22,
6529
- L: 235,
6926
+ F: __dxlog_file24,
6927
+ L: 236,
6530
6928
  S: this,
6531
6929
  C: (f, a) => f(...a)
6532
6930
  });
@@ -6537,16 +6935,18 @@ var ClientServicesHost = class {
6537
6935
  await this._level.open();
6538
6936
  await this._loggingService.open();
6539
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
+ };
6540
6942
  const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
6541
6943
  this._serviceRegistry.setServices({
6542
6944
  SystemService: this._systemService,
6543
6945
  IdentityService: identityService,
6946
+ ContactsService: new ContactsServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6544
6947
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
6545
6948
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
6546
- SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
6547
- await this._serviceContext.initialized.wait();
6548
- return this._serviceContext.dataSpaceManager;
6549
- }),
6949
+ SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6550
6950
  DataService: this._serviceContext.echoHost.dataService,
6551
6951
  QueryService: this._serviceContext.echoHost.queryService,
6552
6952
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
@@ -6576,19 +6976,19 @@ var ClientServicesHost = class {
6576
6976
  this._open = true;
6577
6977
  this._statusUpdate.emit();
6578
6978
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6579
- (0, import_log19.log)("opened", {
6979
+ (0, import_log20.log)("opened", {
6580
6980
  deviceKey
6581
6981
  }, {
6582
- F: __dxlog_file22,
6583
- L: 314,
6982
+ F: __dxlog_file24,
6983
+ L: 322,
6584
6984
  S: this,
6585
6985
  C: (f, a) => f(...a)
6586
6986
  });
6587
- 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({
6588
6988
  id: traceId
6589
6989
  }), {
6590
- F: __dxlog_file22,
6591
- L: 315,
6990
+ F: __dxlog_file24,
6991
+ L: 323,
6592
6992
  S: this,
6593
6993
  C: (f, a) => f(...a)
6594
6994
  });
@@ -6598,11 +6998,11 @@ var ClientServicesHost = class {
6598
6998
  return;
6599
6999
  }
6600
7000
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6601
- (0, import_log19.log)("closing...", {
7001
+ (0, import_log20.log)("closing...", {
6602
7002
  deviceKey
6603
7003
  }, {
6604
- F: __dxlog_file22,
6605
- L: 326,
7004
+ F: __dxlog_file24,
7005
+ L: 334,
6606
7006
  S: this,
6607
7007
  C: (f, a) => f(...a)
6608
7008
  });
@@ -6616,44 +7016,44 @@ var ClientServicesHost = class {
6616
7016
  await this._level?.close();
6617
7017
  this._open = false;
6618
7018
  this._statusUpdate.emit();
6619
- (0, import_log19.log)("closed", {
7019
+ (0, import_log20.log)("closed", {
6620
7020
  deviceKey
6621
7021
  }, {
6622
- F: __dxlog_file22,
6623
- L: 335,
7022
+ F: __dxlog_file24,
7023
+ L: 343,
6624
7024
  S: this,
6625
7025
  C: (f, a) => f(...a)
6626
7026
  });
6627
7027
  }
6628
7028
  async reset() {
6629
7029
  const traceId = import_keys15.PublicKey.random().toHex();
6630
- 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({
6631
7031
  id: traceId
6632
7032
  }), {
6633
- F: __dxlog_file22,
6634
- L: 340,
7033
+ F: __dxlog_file24,
7034
+ L: 348,
6635
7035
  S: this,
6636
7036
  C: (f, a) => f(...a)
6637
7037
  });
6638
- import_log19.log.info("resetting...", void 0, {
6639
- F: __dxlog_file22,
6640
- L: 342,
7038
+ import_log20.log.info("resetting...", void 0, {
7039
+ F: __dxlog_file24,
7040
+ L: 350,
6641
7041
  S: this,
6642
7042
  C: (f, a) => f(...a)
6643
7043
  });
6644
7044
  await this._serviceContext?.close();
6645
7045
  await this._storage.reset();
6646
- import_log19.log.info("reset", void 0, {
6647
- F: __dxlog_file22,
6648
- L: 345,
7046
+ import_log20.log.info("reset", void 0, {
7047
+ F: __dxlog_file24,
7048
+ L: 353,
6649
7049
  S: this,
6650
7050
  C: (f, a) => f(...a)
6651
7051
  });
6652
- 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({
6653
7053
  id: traceId
6654
7054
  }), {
6655
- F: __dxlog_file22,
6656
- L: 346,
7055
+ F: __dxlog_file24,
7056
+ L: 354,
6657
7057
  S: this,
6658
7058
  C: (f, a) => f(...a)
6659
7059
  });
@@ -6672,11 +7072,11 @@ _ts_decorate8([
6672
7072
  import_tracing9.trace.info()
6673
7073
  ], ClientServicesHost.prototype, "_open", void 0);
6674
7074
  _ts_decorate8([
6675
- import_async20.synchronized,
7075
+ import_async19.synchronized,
6676
7076
  import_tracing9.trace.span()
6677
7077
  ], ClientServicesHost.prototype, "open", null);
6678
7078
  _ts_decorate8([
6679
- import_async20.synchronized,
7079
+ import_async19.synchronized,
6680
7080
  import_tracing9.trace.span()
6681
7081
  ], ClientServicesHost.prototype, "close", null);
6682
7082
  ClientServicesHost = _ts_decorate8([
@@ -6712,7 +7112,11 @@ ClientServicesHost = _ts_decorate8([
6712
7112
  createDiagnostics,
6713
7113
  createLevel,
6714
7114
  createStorageObjects,
7115
+ decodeProfileArchive,
7116
+ encodeProfileArchive,
7117
+ exportProfileData,
6715
7118
  getNetworkPeers,
7119
+ importProfileData,
6716
7120
  isLocked,
6717
7121
  subscribeToFeedBlocks,
6718
7122
  subscribeToFeeds,
@@ -6722,4 +7126,4 @@ ClientServicesHost = _ts_decorate8([
6722
7126
  subscribeToSpaces,
6723
7127
  subscribeToSwarmInfo
6724
7128
  });
6725
- //# sourceMappingURL=chunk-HRQTR7UW.cjs.map
7129
+ //# sourceMappingURL=chunk-G6UXW6DQ.cjs.map