@dxos/client-services 0.5.9-main.e183eeb → 0.5.9-main.e9b9049

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 (43) hide show
  1. package/dist/lib/browser/{chunk-S5DPO2DT.mjs → chunk-3DXQACFA.mjs} +847 -463
  2. package/dist/lib/browser/chunk-3DXQACFA.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-F2EIFQZH.cjs → chunk-4LN54Y73.cjs} +861 -477
  9. package/dist/lib/node/chunk-4LN54Y73.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/invitations/invitations-handler.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/epoch-migrations.d.ts.map +1 -1
  23. package/dist/types/src/packlets/spaces/spaces-service.d.ts +4 -1
  24. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  25. package/dist/types/src/packlets/storage/index.d.ts +1 -0
  26. package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
  27. package/dist/types/src/packlets/storage/profile-archive.d.ts +14 -0
  28. package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -0
  29. package/dist/types/src/version.d.ts +1 -1
  30. package/package.json +36 -36
  31. package/src/packlets/identity/contacts-service.ts +85 -0
  32. package/src/packlets/invitations/invitations-handler.ts +13 -5
  33. package/src/packlets/invitations/space-invitation-protocol.ts +11 -32
  34. package/src/packlets/services/service-host.ts +12 -4
  35. package/src/packlets/spaces/data-space-manager.ts +55 -2
  36. package/src/packlets/spaces/data-space.ts +5 -5
  37. package/src/packlets/spaces/epoch-migrations.ts +12 -7
  38. package/src/packlets/spaces/spaces-service.ts +50 -2
  39. package/src/packlets/storage/index.ts +1 -0
  40. package/src/packlets/storage/profile-archive.ts +97 -0
  41. package/src/version.ts +1 -1
  42. package/dist/lib/browser/chunk-S5DPO2DT.mjs.map +0 -7
  43. package/dist/lib/node/chunk-F2EIFQZH.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_F2EIFQZH_exports = {};
30
- __export(chunk_F2EIFQZH_exports, {
29
+ var chunk_4LN54Y73_exports = {};
30
+ __export(chunk_4LN54Y73_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  ClientServicesProviderResource: () => ClientServicesProviderResource,
@@ -56,7 +56,11 @@ __export(chunk_F2EIFQZH_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_F2EIFQZH_exports, {
66
70
  subscribeToSpaces: () => subscribeToSpaces,
67
71
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
68
72
  });
69
- module.exports = __toCommonJS(chunk_F2EIFQZH_exports);
73
+ module.exports = __toCommonJS(chunk_4LN54Y73_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");
@@ -236,8 +240,10 @@ var import_context14 = require("@dxos/context");
236
240
  var import_credentials15 = require("@dxos/credentials");
237
241
  var import_echo_db2 = require("@dxos/echo-db");
238
242
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
243
+ var import_echo_pipeline5 = require("@dxos/echo-pipeline");
239
244
  var import_echo_protocol2 = require("@dxos/echo-protocol");
240
245
  var import_echo_schema2 = require("@dxos/echo-schema");
246
+ var import_feed_store4 = require("@dxos/feed-store");
241
247
  var import_invariant15 = require("@dxos/invariant");
242
248
  var import_keys12 = require("@dxos/keys");
243
249
  var import_log15 = require("@dxos/log");
@@ -255,7 +261,7 @@ var import_async18 = require("@dxos/async");
255
261
  var import_codec_protobuf11 = require("@dxos/codec-protobuf");
256
262
  var import_credentials19 = require("@dxos/credentials");
257
263
  var import_debug5 = require("@dxos/debug");
258
- var import_feed_store4 = require("@dxos/feed-store");
264
+ var import_feed_store5 = require("@dxos/feed-store");
259
265
  var import_invariant16 = require("@dxos/invariant");
260
266
  var import_log16 = require("@dxos/log");
261
267
  var import_protocols12 = require("@dxos/protocols");
@@ -266,8 +272,8 @@ var import_context15 = require("@dxos/context");
266
272
  var import_credentials20 = require("@dxos/credentials");
267
273
  var import_debug6 = require("@dxos/debug");
268
274
  var import_echo_db3 = require("@dxos/echo-db");
269
- var import_echo_pipeline5 = require("@dxos/echo-pipeline");
270
- var import_feed_store5 = require("@dxos/feed-store");
275
+ var import_echo_pipeline6 = require("@dxos/echo-pipeline");
276
+ var import_feed_store6 = require("@dxos/feed-store");
271
277
  var import_invariant17 = require("@dxos/invariant");
272
278
  var import_keyring = require("@dxos/keyring");
273
279
  var import_keys13 = require("@dxos/keys");
@@ -289,38 +295,47 @@ var import_util12 = require("@dxos/util");
289
295
  var import_node_path = __toESM(require("node:path"));
290
296
  var import_keys14 = require("@dxos/keys");
291
297
  var import_kv_store = require("@dxos/kv-store");
298
+ var import_automerge_repo = require("@dxos/automerge/automerge-repo");
299
+ var import_invariant19 = require("@dxos/invariant");
300
+ var import_log19 = require("@dxos/log");
301
+ var import_protocols15 = require("@dxos/protocols");
302
+ var import_util13 = require("@dxos/util");
292
303
  var import_async20 = require("@dxos/async");
293
304
  var import_client_protocol7 = require("@dxos/client-protocol");
294
305
  var import_context16 = require("@dxos/context");
295
- var import_invariant19 = require("@dxos/invariant");
306
+ var import_invariant20 = require("@dxos/invariant");
296
307
  var import_keys15 = require("@dxos/keys");
297
- var import_log19 = require("@dxos/log");
308
+ var import_log20 = require("@dxos/log");
298
309
  var import_messaging = require("@dxos/messaging");
299
310
  var import_network_manager2 = require("@dxos/network-manager");
300
- var import_protocols15 = require("@dxos/protocols");
311
+ var import_protocols16 = require("@dxos/protocols");
301
312
  var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
302
313
  var import_tracing9 = require("@dxos/tracing");
303
314
  var import_websocket_rpc = require("@dxos/websocket-rpc");
304
315
  var import_async21 = require("@dxos/async");
305
316
  var import_codec_protobuf12 = require("@dxos/codec-protobuf");
306
- var import_invariant20 = require("@dxos/invariant");
317
+ var import_invariant21 = require("@dxos/invariant");
307
318
  var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
308
319
  var import_config3 = require("@dxos/config");
309
320
  var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
310
321
  var import_tracing10 = require("@dxos/tracing");
311
- var import_util13 = require("@dxos/util");
312
- var import_keys16 = require("@dxos/keys");
313
322
  var import_util14 = require("@dxos/util");
323
+ var import_keys16 = require("@dxos/keys");
324
+ var import_util15 = require("@dxos/util");
314
325
  var import_async22 = require("@dxos/async");
315
326
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
316
327
  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
- var import_util15 = require("@dxos/util");
328
+ var import_util16 = require("@dxos/util");
329
+ var import_async23 = require("@dxos/async");
320
330
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
331
+ var import_keys18 = require("@dxos/keys");
332
+ var import_log21 = require("@dxos/log");
333
+ var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
334
+ var import_util17 = require("@dxos/util");
321
335
  var import_codec_protobuf15 = require("@dxos/codec-protobuf");
336
+ var import_codec_protobuf16 = require("@dxos/codec-protobuf");
322
337
  var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
323
- var import_util16 = require("@dxos/util");
338
+ var import_util18 = require("@dxos/util");
324
339
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
325
340
  return new import_codec_protobuf.Stream(({ next }) => {
326
341
  const subscriptions = new import_async.EventSubscriptions();
@@ -388,6 +403,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
388
403
  };
389
404
  });
390
405
  };
406
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/network.ts";
391
407
  var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf2.Stream(({ next, close }) => {
392
408
  const update = () => {
393
409
  try {
@@ -403,7 +419,10 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf2
403
419
  update();
404
420
  });
405
421
  var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf2.Stream(({ next }) => {
406
- const ctx = new import_context.Context();
422
+ const ctx = new import_context.Context(void 0, {
423
+ F: __dxlog_file,
424
+ L: 36
425
+ });
407
426
  signalManager.onMessage.on(ctx, (message) => {
408
427
  next({
409
428
  message: {
@@ -631,7 +650,7 @@ var DevtoolsServiceImpl = class {
631
650
  });
632
651
  }
633
652
  };
634
- var DXOS_VERSION = "0.5.9-main.e183eeb";
653
+ var DXOS_VERSION = "0.5.9-main.e9b9049";
635
654
  var getPlatform = () => {
636
655
  if (process.browser) {
637
656
  if (typeof window !== "undefined") {
@@ -659,7 +678,7 @@ var getPlatform = () => {
659
678
  };
660
679
  }
661
680
  };
662
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
681
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
663
682
  var DEFAULT_TIMEOUT = 1e3;
664
683
  var createDiagnostics = async (clientServices, serviceContext, config) => {
665
684
  const diagnostics = {
@@ -676,7 +695,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
676
695
  await Promise.all([
677
696
  (async () => {
678
697
  (0, import_invariant.invariant)(clientServices.LoggingService, "SystemService is not available.", {
679
- F: __dxlog_file,
698
+ F: __dxlog_file2,
680
699
  L: 110,
681
700
  S: void 0,
682
701
  A: [
@@ -865,7 +884,7 @@ _ts_decorate([
865
884
  ClientRpcServer = _ts_decorate([
866
885
  import_tracing2.trace.resource()
867
886
  ], ClientRpcServer);
868
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
887
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
869
888
  var Credential = import_protocols2.schema.getCodecForType("dxos.halo.credentials.Credential");
870
889
  var createAuthProvider = (signer) => async (nonce) => {
871
890
  const credential = await signer.createCredential({
@@ -880,7 +899,10 @@ var createAuthProvider = (signer) => async (nonce) => {
880
899
  var TrustedKeySetAuthVerifier = class {
881
900
  constructor(_params) {
882
901
  this._params = _params;
883
- this._ctx = new import_context2.Context();
902
+ this._ctx = new import_context2.Context(void 0, {
903
+ F: __dxlog_file3,
904
+ L: 45
905
+ });
884
906
  }
885
907
  async close() {
886
908
  await this._ctx.dispose();
@@ -891,7 +913,7 @@ var TrustedKeySetAuthVerifier = class {
891
913
  (0, import_log.log)("authenticating...", {
892
914
  credential
893
915
  }, {
894
- F: __dxlog_file2,
916
+ F: __dxlog_file3,
895
917
  L: 56,
896
918
  S: this,
897
919
  C: (f, a) => f(...a)
@@ -901,7 +923,7 @@ var TrustedKeySetAuthVerifier = class {
901
923
  (0, import_log.log)("Invalid credential", {
902
924
  result
903
925
  }, {
904
- F: __dxlog_file2,
926
+ F: __dxlog_file3,
905
927
  L: 60,
906
928
  S: this,
907
929
  C: (f, a) => f(...a)
@@ -913,7 +935,7 @@ var TrustedKeySetAuthVerifier = class {
913
935
  nonce,
914
936
  credential
915
937
  }, {
916
- F: __dxlog_file2,
938
+ F: __dxlog_file3,
917
939
  L: 65,
918
940
  S: this,
919
941
  C: (f, a) => f(...a)
@@ -924,7 +946,7 @@ var TrustedKeySetAuthVerifier = class {
924
946
  (0, import_log.log)("key is not currently in trusted set, waiting...", {
925
947
  key: credential.issuer
926
948
  }, {
927
- F: __dxlog_file2,
949
+ F: __dxlog_file3,
928
950
  L: 70,
929
951
  S: this,
930
952
  C: (f, a) => f(...a)
@@ -940,7 +962,7 @@ var TrustedKeySetAuthVerifier = class {
940
962
  (0, import_log.log)("auth success", {
941
963
  key: credential.issuer
942
964
  }, {
943
- F: __dxlog_file2,
965
+ F: __dxlog_file3,
944
966
  L: 81,
945
967
  S: this,
946
968
  C: (f, a) => f(...a)
@@ -950,7 +972,7 @@ var TrustedKeySetAuthVerifier = class {
950
972
  (0, import_log.log)("key is not currently in trusted set, waiting...", {
951
973
  key: credential.issuer
952
974
  }, {
953
- F: __dxlog_file2,
975
+ F: __dxlog_file3,
954
976
  L: 84,
955
977
  S: this,
956
978
  C: (f, a) => f(...a)
@@ -973,7 +995,7 @@ var TrustedKeySetAuthVerifier = class {
973
995
  return deviceSet.has(deviceKey);
974
996
  }
975
997
  };
976
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
998
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
977
999
  var DefaultSpaceStateMachine = class {
978
1000
  constructor(_params) {
979
1001
  this._params = _params;
@@ -990,7 +1012,7 @@ var DefaultSpaceStateMachine = class {
990
1012
  expectedIdentity: this._params.identityKey,
991
1013
  credential
992
1014
  }, {
993
- F: __dxlog_file3,
1015
+ F: __dxlog_file4,
994
1016
  L: 32,
995
1017
  S: this,
996
1018
  C: (f, a) => f(...a)
@@ -1001,7 +1023,7 @@ var DefaultSpaceStateMachine = class {
1001
1023
  import_log3.log.warn("Invalid default space id", {
1002
1024
  id: assertion.spaceId
1003
1025
  }, {
1004
- F: __dxlog_file3,
1026
+ F: __dxlog_file4,
1005
1027
  L: 36,
1006
1028
  S: this,
1007
1029
  C: (f, a) => f(...a)
@@ -1024,7 +1046,7 @@ function _ts_decorate2(decorators, target, key, desc) {
1024
1046
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1025
1047
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1026
1048
  }
1027
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
1049
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
1028
1050
  var Identity = class {
1029
1051
  constructor({ space, signer, identityKey, deviceKey, presence }) {
1030
1052
  this.stateUpdate = new import_async6.Event();
@@ -1036,7 +1058,7 @@ var Identity = class {
1036
1058
  import_log2.log.trace("dxos.halo.device", {
1037
1059
  deviceKey
1038
1060
  }, {
1039
- F: __dxlog_file4,
1061
+ F: __dxlog_file5,
1040
1062
  L: 70,
1041
1063
  S: this,
1042
1064
  C: (f, a) => f(...a)
@@ -1115,7 +1137,7 @@ var Identity = class {
1115
1137
  */
1116
1138
  getIdentityCredentialSigner() {
1117
1139
  (0, import_invariant2.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
1118
- F: __dxlog_file4,
1140
+ F: __dxlog_file5,
1119
1141
  L: 159,
1120
1142
  S: this,
1121
1143
  A: [
@@ -1159,7 +1181,7 @@ var Identity = class {
1159
1181
  controlFeedKey,
1160
1182
  dataFeedKey
1161
1183
  }, {
1162
- F: __dxlog_file4,
1184
+ F: __dxlog_file5,
1163
1185
  L: 184,
1164
1186
  S: this,
1165
1187
  C: (f, a) => f(...a)
@@ -1220,7 +1242,7 @@ function _ts_decorate3(decorators, target, key, desc) {
1220
1242
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1221
1243
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1222
1244
  }
1223
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1245
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1224
1246
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
1225
1247
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
1226
1248
  var IdentityManager = class {
@@ -1244,7 +1266,7 @@ var IdentityManager = class {
1244
1266
  import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
1245
1267
  id: traceId
1246
1268
  }), {
1247
- F: __dxlog_file5,
1269
+ F: __dxlog_file6,
1248
1270
  L: 104,
1249
1271
  S: this,
1250
1272
  C: (f, a) => f(...a)
@@ -1253,7 +1275,7 @@ var IdentityManager = class {
1253
1275
  (0, import_log4.log)("identity record", {
1254
1276
  identityRecord
1255
1277
  }, {
1256
- F: __dxlog_file5,
1278
+ F: __dxlog_file6,
1257
1279
  L: 107,
1258
1280
  S: this,
1259
1281
  C: (f, a) => f(...a)
@@ -1266,7 +1288,7 @@ var IdentityManager = class {
1266
1288
  identityKey: identityRecord.identityKey,
1267
1289
  displayName: this._identity.profileDocument?.displayName
1268
1290
  }, {
1269
- F: __dxlog_file5,
1291
+ F: __dxlog_file6,
1270
1292
  L: 112,
1271
1293
  S: this,
1272
1294
  C: (f, a) => f(...a)
@@ -1276,18 +1298,21 @@ var IdentityManager = class {
1276
1298
  import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.end({
1277
1299
  id: traceId
1278
1300
  }), {
1279
- F: __dxlog_file5,
1301
+ F: __dxlog_file6,
1280
1302
  L: 119,
1281
1303
  S: this,
1282
1304
  C: (f, a) => f(...a)
1283
1305
  });
1284
1306
  }
1285
1307
  async close() {
1286
- await this._identity?.close(new import_context3.Context());
1308
+ await this._identity?.close(new import_context3.Context(void 0, {
1309
+ F: __dxlog_file6,
1310
+ L: 123
1311
+ }));
1287
1312
  }
1288
1313
  async createIdentity({ displayName, deviceProfile } = {}) {
1289
1314
  (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
1290
- F: __dxlog_file5,
1315
+ F: __dxlog_file6,
1291
1316
  L: 128,
1292
1317
  S: this,
1293
1318
  A: [
@@ -1296,7 +1321,7 @@ var IdentityManager = class {
1296
1321
  ]
1297
1322
  });
1298
1323
  (0, import_log4.log)("creating identity...", void 0, {
1299
- F: __dxlog_file5,
1324
+ F: __dxlog_file6,
1300
1325
  L: 129,
1301
1326
  S: this,
1302
1327
  C: (f, a) => f(...a)
@@ -1313,11 +1338,14 @@ var IdentityManager = class {
1313
1338
  }
1314
1339
  };
1315
1340
  const identity = await this._constructIdentity(identityRecord);
1316
- await identity.open(new import_context3.Context());
1341
+ await identity.open(new import_context3.Context(void 0, {
1342
+ F: __dxlog_file6,
1343
+ L: 144
1344
+ }));
1317
1345
  {
1318
1346
  const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
1319
1347
  (0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
1320
- F: __dxlog_file5,
1348
+ F: __dxlog_file6,
1321
1349
  L: 148,
1322
1350
  S: this,
1323
1351
  A: [
@@ -1326,7 +1354,7 @@ var IdentityManager = class {
1326
1354
  ]
1327
1355
  });
1328
1356
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
1329
- F: __dxlog_file5,
1357
+ F: __dxlog_file6,
1330
1358
  L: 149,
1331
1359
  S: this,
1332
1360
  A: [
@@ -1365,7 +1393,7 @@ var IdentityManager = class {
1365
1393
  identityKey: identityRecord.identityKey,
1366
1394
  displayName: this._identity.profileDocument?.displayName
1367
1395
  }, {
1368
- F: __dxlog_file5,
1396
+ F: __dxlog_file6,
1369
1397
  L: 191,
1370
1398
  S: this,
1371
1399
  C: (f, a) => f(...a)
@@ -1376,7 +1404,7 @@ var IdentityManager = class {
1376
1404
  deviceKey: identity.deviceKey,
1377
1405
  profile: identity.profileDocument
1378
1406
  }, {
1379
- F: __dxlog_file5,
1407
+ F: __dxlog_file6,
1380
1408
  L: 197,
1381
1409
  S: this,
1382
1410
  C: (f, a) => f(...a)
@@ -1413,13 +1441,13 @@ var IdentityManager = class {
1413
1441
  (0, import_log4.log)("accepting identity", {
1414
1442
  params
1415
1443
  }, {
1416
- F: __dxlog_file5,
1444
+ F: __dxlog_file6,
1417
1445
  L: 235,
1418
1446
  S: this,
1419
1447
  C: (f, a) => f(...a)
1420
1448
  });
1421
1449
  (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
1422
- F: __dxlog_file5,
1450
+ F: __dxlog_file6,
1423
1451
  L: 236,
1424
1452
  S: this,
1425
1453
  A: [
@@ -1439,7 +1467,10 @@ var IdentityManager = class {
1439
1467
  }
1440
1468
  };
1441
1469
  const identity = await this._constructIdentity(identityRecord);
1442
- await identity.open(new import_context3.Context());
1470
+ await identity.open(new import_context3.Context(void 0, {
1471
+ F: __dxlog_file6,
1472
+ L: 251
1473
+ }));
1443
1474
  this._identity = identity;
1444
1475
  await this._metadataStore.setIdentityRecord(identityRecord);
1445
1476
  await this._identity.ready();
@@ -1447,7 +1478,7 @@ var IdentityManager = class {
1447
1478
  identityKey: identityRecord.identityKey,
1448
1479
  displayName: this._identity.profileDocument?.displayName
1449
1480
  }, {
1450
- F: __dxlog_file5,
1481
+ F: __dxlog_file6,
1451
1482
  L: 255,
1452
1483
  S: this,
1453
1484
  C: (f, a) => f(...a)
@@ -1461,7 +1492,7 @@ var IdentityManager = class {
1461
1492
  identityKey: identity.identityKey,
1462
1493
  deviceKey: identity.deviceKey
1463
1494
  }, {
1464
- F: __dxlog_file5,
1495
+ F: __dxlog_file6,
1465
1496
  L: 265,
1466
1497
  S: this,
1467
1498
  C: (f, a) => f(...a)
@@ -1473,7 +1504,7 @@ var IdentityManager = class {
1473
1504
  */
1474
1505
  async updateProfile(profile) {
1475
1506
  (0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
1476
- F: __dxlog_file5,
1507
+ F: __dxlog_file6,
1477
1508
  L: 273,
1478
1509
  S: this,
1479
1510
  A: [
@@ -1504,7 +1535,7 @@ var IdentityManager = class {
1504
1535
  }
1505
1536
  async updateDeviceProfile(profile) {
1506
1537
  (0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
1507
- F: __dxlog_file5,
1538
+ F: __dxlog_file6,
1508
1539
  L: 290,
1509
1540
  S: this,
1510
1541
  A: [
@@ -1540,7 +1571,7 @@ var IdentityManager = class {
1540
1571
  }
1541
1572
  async _constructIdentity(identityRecord) {
1542
1573
  (0, import_invariant3.invariant)(!this._identity, void 0, {
1543
- F: __dxlog_file5,
1574
+ F: __dxlog_file6,
1544
1575
  L: 316,
1545
1576
  S: this,
1546
1577
  A: [
@@ -1551,7 +1582,7 @@ var IdentityManager = class {
1551
1582
  (0, import_log4.log)("constructing identity", {
1552
1583
  identityRecord
1553
1584
  }, {
1554
- F: __dxlog_file5,
1585
+ F: __dxlog_file6,
1555
1586
  L: 317,
1556
1587
  S: this,
1557
1588
  C: (f, a) => f(...a)
@@ -1566,7 +1597,7 @@ var IdentityManager = class {
1566
1597
  gossip
1567
1598
  });
1568
1599
  (0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
1569
- F: __dxlog_file5,
1600
+ F: __dxlog_file6,
1570
1601
  L: 330,
1571
1602
  S: this,
1572
1603
  A: [
@@ -1578,7 +1609,7 @@ var IdentityManager = class {
1578
1609
  writable: true
1579
1610
  });
1580
1611
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
1581
- F: __dxlog_file5,
1612
+ F: __dxlog_file6,
1582
1613
  L: 334,
1583
1614
  S: this,
1584
1615
  A: [
@@ -1612,7 +1643,7 @@ var IdentityManager = class {
1612
1643
  (0, import_log4.log)("done", {
1613
1644
  identityKey: identityRecord.identityKey
1614
1645
  }, {
1615
- F: __dxlog_file5,
1646
+ F: __dxlog_file6,
1616
1647
  L: 360,
1617
1648
  S: this,
1618
1649
  C: (f, a) => f(...a)
@@ -1637,7 +1668,7 @@ var IdentityManager = class {
1637
1668
  },
1638
1669
  onAuthFailure: () => {
1639
1670
  import_log4.log.warn("auth failure", void 0, {
1640
- F: __dxlog_file5,
1671
+ F: __dxlog_file6,
1641
1672
  L: 385,
1642
1673
  S: this,
1643
1674
  C: (f, a) => f(...a)
@@ -1659,7 +1690,7 @@ _ts_decorate3([
1659
1690
  IdentityManager = _ts_decorate3([
1660
1691
  import_tracing4.trace.resource()
1661
1692
  ], IdentityManager);
1662
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1693
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1663
1694
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
1664
1695
  var IdentityServiceImpl = class extends import_context4.Resource {
1665
1696
  constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
@@ -1689,7 +1720,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1689
1720
  const space = await dataSpaceManager.createDefaultSpace();
1690
1721
  const identity = this._identityManager.identity;
1691
1722
  (0, import_invariant4.invariant)(identity, void 0, {
1692
- F: __dxlog_file6,
1723
+ F: __dxlog_file7,
1693
1724
  L: 59,
1694
1725
  S: this,
1695
1726
  A: [
@@ -1723,7 +1754,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1723
1754
  }
1724
1755
  async updateProfile(profile) {
1725
1756
  (0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
1726
- F: __dxlog_file6,
1757
+ F: __dxlog_file7,
1727
1758
  L: 89,
1728
1759
  S: this,
1729
1760
  A: [
@@ -1737,7 +1768,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1737
1768
  }
1738
1769
  async signPresentation({ presentation, nonce }) {
1739
1770
  (0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
1740
- F: __dxlog_file6,
1771
+ F: __dxlog_file7,
1741
1772
  L: 96,
1742
1773
  S: this,
1743
1774
  A: [
@@ -1772,7 +1803,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1772
1803
  import_log5.log.warn("Multiple default spaces found. Using the first one.", {
1773
1804
  duplicate: space.id
1774
1805
  }, {
1775
- F: __dxlog_file6,
1806
+ F: __dxlog_file7,
1776
1807
  L: 127,
1777
1808
  S: this,
1778
1809
  C: (f, a) => f(...a)
@@ -1795,7 +1826,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1795
1826
  }
1796
1827
  }
1797
1828
  };
1798
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1829
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1799
1830
  var DeviceInvitationProtocol = class {
1800
1831
  constructor(_keyring, _getIdentity, _acceptIdentity) {
1801
1832
  this._keyring = _keyring;
@@ -1821,7 +1852,7 @@ var DeviceInvitationProtocol = class {
1821
1852
  }
1822
1853
  async admit(_, request) {
1823
1854
  (0, import_invariant5.invariant)(request.device, void 0, {
1824
- F: __dxlog_file7,
1855
+ F: __dxlog_file8,
1825
1856
  L: 50,
1826
1857
  S: this,
1827
1858
  A: [
@@ -1867,7 +1898,7 @@ var DeviceInvitationProtocol = class {
1867
1898
  }
1868
1899
  async accept(response, request) {
1869
1900
  (0, import_invariant5.invariant)(response.device, void 0, {
1870
- F: __dxlog_file7,
1901
+ F: __dxlog_file8,
1871
1902
  L: 95,
1872
1903
  S: this,
1873
1904
  A: [
@@ -1877,7 +1908,7 @@ var DeviceInvitationProtocol = class {
1877
1908
  });
1878
1909
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1879
1910
  (0, import_invariant5.invariant)(request.device, void 0, {
1880
- F: __dxlog_file7,
1911
+ F: __dxlog_file8,
1881
1912
  L: 98,
1882
1913
  S: this,
1883
1914
  A: [
@@ -1916,7 +1947,7 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
1916
1947
  return guard;
1917
1948
  })());
1918
1949
  };
1919
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1950
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1920
1951
  var OPTIONS_TIMEOUT = 1e4;
1921
1952
  var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1922
1953
  constructor(_invitationFlowMutex, _callbacks) {
@@ -1930,7 +1961,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1930
1961
  });
1931
1962
  this._invitationFlowMutex = _invitationFlowMutex;
1932
1963
  this._callbacks = _callbacks;
1933
- this._ctx = new import_context6.Context();
1964
+ this._ctx = new import_context6.Context(void 0, {
1965
+ F: __dxlog_file9,
1966
+ L: 33
1967
+ });
1934
1968
  this._remoteOptionsTrigger = new import_async10.Trigger();
1935
1969
  this._invitationFlowLock = null;
1936
1970
  }
@@ -1942,7 +1976,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1942
1976
  InvitationHostService: {
1943
1977
  options: async (options) => {
1944
1978
  (0, import_invariant7.invariant)(!this._remoteOptions, "Remote options already set.", {
1945
- F: __dxlog_file8,
1979
+ F: __dxlog_file9,
1946
1980
  L: 63,
1947
1981
  S: this,
1948
1982
  A: [
@@ -1969,14 +2003,14 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1969
2003
  await super.onOpen(context);
1970
2004
  try {
1971
2005
  (0, import_log7.log)("guest acquire lock", void 0, {
1972
- F: __dxlog_file8,
2006
+ F: __dxlog_file9,
1973
2007
  L: 84,
1974
2008
  S: this,
1975
2009
  C: (f, a) => f(...a)
1976
2010
  });
1977
2011
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
1978
2012
  (0, import_log7.log)("guest lock acquired", void 0, {
1979
- F: __dxlog_file8,
2013
+ F: __dxlog_file9,
1980
2014
  L: 86,
1981
2015
  S: this,
1982
2016
  C: (f, a) => f(...a)
@@ -1985,7 +2019,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1985
2019
  role: import_invitations3.Options.Role.GUEST
1986
2020
  }));
1987
2021
  (0, import_log7.log)("options sent", void 0, {
1988
- F: __dxlog_file8,
2022
+ F: __dxlog_file9,
1989
2023
  L: 88,
1990
2024
  S: this,
1991
2025
  C: (f, a) => f(...a)
@@ -1994,7 +2028,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1994
2028
  timeout: OPTIONS_TIMEOUT
1995
2029
  }));
1996
2030
  (0, import_log7.log)("options received", void 0, {
1997
- F: __dxlog_file8,
2031
+ F: __dxlog_file9,
1998
2032
  L: 90,
1999
2033
  S: this,
2000
2034
  C: (f, a) => f(...a)
@@ -2028,7 +2062,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
2028
2062
  this._invitationFlowLock.release();
2029
2063
  this._invitationFlowLock = null;
2030
2064
  (0, import_log7.log)("invitation flow lock released", void 0, {
2031
- F: __dxlog_file8,
2065
+ F: __dxlog_file9,
2032
2066
  L: 123,
2033
2067
  S: this,
2034
2068
  C: (f, a) => f(...a)
@@ -2036,7 +2070,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
2036
2070
  }
2037
2071
  }
2038
2072
  };
2039
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
2073
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
2040
2074
  var OPTIONS_TIMEOUT2 = 1e4;
2041
2075
  var MAX_OTP_ATTEMPTS = 3;
2042
2076
  var InvitationHostExtension = class extends import_teleport2.RpcExtension {
@@ -2051,7 +2085,10 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2051
2085
  });
2052
2086
  this._invitationFlowMutex = _invitationFlowMutex;
2053
2087
  this._callbacks = _callbacks;
2054
- this._ctx = new import_context8.Context();
2088
+ this._ctx = new import_context8.Context(void 0, {
2089
+ F: __dxlog_file10,
2090
+ L: 52
2091
+ });
2055
2092
  this._remoteOptionsTrigger = new import_async11.Trigger();
2056
2093
  this._challenge = void 0;
2057
2094
  this.guestProfile = void 0;
@@ -2070,7 +2107,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2070
2107
  InvitationHostService: {
2071
2108
  options: async (options) => {
2072
2109
  (0, import_invariant8.invariant)(!this._remoteOptions, "Remote options already set.", {
2073
- F: __dxlog_file9,
2110
+ F: __dxlog_file10,
2074
2111
  L: 101,
2075
2112
  S: this,
2076
2113
  A: [
@@ -2087,7 +2124,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2087
2124
  import_log8.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.begin({
2088
2125
  id: traceId
2089
2126
  }), {
2090
- F: __dxlog_file9,
2127
+ F: __dxlog_file10,
2091
2128
  L: 110,
2092
2129
  S: this,
2093
2130
  C: (f, a) => f(...a)
@@ -2099,7 +2136,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2099
2136
  expected: invitation.invitationId,
2100
2137
  actual: invitationId
2101
2138
  }, {
2102
- F: __dxlog_file9,
2139
+ F: __dxlog_file10,
2103
2140
  L: 116,
2104
2141
  S: this,
2105
2142
  C: (f, a) => f(...a)
@@ -2113,7 +2150,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2113
2150
  (0, import_log8.log)("guest introduced themselves", {
2114
2151
  guestProfile: profile
2115
2152
  }, {
2116
- F: __dxlog_file9,
2153
+ F: __dxlog_file10,
2117
2154
  L: 125,
2118
2155
  S: this,
2119
2156
  C: (f, a) => f(...a)
@@ -2124,7 +2161,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2124
2161
  import_log8.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.end({
2125
2162
  id: traceId
2126
2163
  }), {
2127
- F: __dxlog_file9,
2164
+ F: __dxlog_file10,
2128
2165
  L: 132,
2129
2166
  S: this,
2130
2167
  C: (f, a) => f(...a)
@@ -2139,7 +2176,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2139
2176
  import_log8.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.begin({
2140
2177
  id: traceId
2141
2178
  }), {
2142
- F: __dxlog_file9,
2179
+ F: __dxlog_file10,
2143
2180
  L: 141,
2144
2181
  S: this,
2145
2182
  C: (f, a) => f(...a)
@@ -2148,7 +2185,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2148
2185
  (0, import_log8.log)("received authentication request", {
2149
2186
  authCode: code
2150
2187
  }, {
2151
- F: __dxlog_file9,
2188
+ F: __dxlog_file10,
2152
2189
  L: 144,
2153
2190
  S: this,
2154
2191
  C: (f, a) => f(...a)
@@ -2162,7 +2199,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2162
2199
  switch (invitation.authMethod) {
2163
2200
  case import_services8.Invitation.AuthMethod.NONE: {
2164
2201
  (0, import_log8.log)("authentication not required", void 0, {
2165
- F: __dxlog_file9,
2202
+ F: __dxlog_file10,
2166
2203
  L: 152,
2167
2204
  S: this,
2168
2205
  C: (f, a) => f(...a)
@@ -2200,7 +2237,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2200
2237
  import_log8.log.error("invalid authentication method", {
2201
2238
  authMethod: invitation.authMethod
2202
2239
  }, {
2203
- F: __dxlog_file9,
2240
+ F: __dxlog_file10,
2204
2241
  L: 190,
2205
2242
  S: this,
2206
2243
  C: (f, a) => f(...a)
@@ -2225,7 +2262,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2225
2262
  status
2226
2263
  }
2227
2264
  }), {
2228
- F: __dxlog_file9,
2265
+ F: __dxlog_file10,
2229
2266
  L: 202,
2230
2267
  S: this,
2231
2268
  C: (f, a) => f(...a)
@@ -2239,7 +2276,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2239
2276
  import_log8.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.begin({
2240
2277
  id: traceId
2241
2278
  }), {
2242
- F: __dxlog_file9,
2279
+ F: __dxlog_file10,
2243
2280
  L: 208,
2244
2281
  S: this,
2245
2282
  C: (f, a) => f(...a)
@@ -2256,7 +2293,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2256
2293
  import_log8.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.end({
2257
2294
  id: traceId
2258
2295
  }), {
2259
- F: __dxlog_file9,
2296
+ F: __dxlog_file10,
2260
2297
  L: 222,
2261
2298
  S: this,
2262
2299
  C: (f, a) => f(...a)
@@ -2274,14 +2311,14 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2274
2311
  await super.onOpen(context);
2275
2312
  try {
2276
2313
  (0, import_log8.log)("host acquire lock", void 0, {
2277
- F: __dxlog_file9,
2314
+ F: __dxlog_file10,
2278
2315
  L: 237,
2279
2316
  S: this,
2280
2317
  C: (f, a) => f(...a)
2281
2318
  });
2282
2319
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
2283
2320
  (0, import_log8.log)("host lock acquired", void 0, {
2284
- F: __dxlog_file9,
2321
+ F: __dxlog_file10,
2285
2322
  L: 239,
2286
2323
  S: this,
2287
2324
  C: (f, a) => f(...a)
@@ -2292,7 +2329,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2292
2329
  role: import_invitations4.Options.Role.HOST
2293
2330
  });
2294
2331
  (0, import_log8.log)("options sent", void 0, {
2295
- F: __dxlog_file9,
2332
+ F: __dxlog_file10,
2296
2333
  L: 243,
2297
2334
  S: this,
2298
2335
  C: (f, a) => f(...a)
@@ -2301,7 +2338,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2301
2338
  timeout: OPTIONS_TIMEOUT2
2302
2339
  }));
2303
2340
  (0, import_log8.log)("options received", void 0, {
2304
- F: __dxlog_file9,
2341
+ F: __dxlog_file10,
2305
2342
  L: 245,
2306
2343
  S: this,
2307
2344
  C: (f, a) => f(...a)
@@ -2355,7 +2392,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2355
2392
  this._invitationFlowLock?.release();
2356
2393
  this._invitationFlowLock = null;
2357
2394
  (0, import_log8.log)("invitation flow lock released", void 0, {
2358
- F: __dxlog_file9,
2395
+ F: __dxlog_file10,
2359
2396
  L: 300,
2360
2397
  S: this,
2361
2398
  C: (f, a) => f(...a)
@@ -2364,7 +2401,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2364
2401
  }
2365
2402
  };
2366
2403
  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";
2404
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2368
2405
  var InvitationTopology = class {
2369
2406
  constructor(_role) {
2370
2407
  this._role = _role;
@@ -2372,7 +2409,7 @@ var InvitationTopology = class {
2372
2409
  }
2373
2410
  init(controller) {
2374
2411
  (0, import_invariant9.invariant)(!this._controller, "Already initialized.", {
2375
- F: __dxlog_file10,
2412
+ F: __dxlog_file11,
2376
2413
  L: 42,
2377
2414
  S: this,
2378
2415
  A: [
@@ -2384,7 +2421,7 @@ var InvitationTopology = class {
2384
2421
  }
2385
2422
  update() {
2386
2423
  (0, import_invariant9.invariant)(this._controller, "Not initialized.", {
2387
- F: __dxlog_file10,
2424
+ F: __dxlog_file11,
2388
2425
  L: 47,
2389
2426
  S: this,
2390
2427
  A: [
@@ -2407,7 +2444,7 @@ var InvitationTopology = class {
2407
2444
  ownPeerId,
2408
2445
  remotePeerId: firstUnknownPeer
2409
2446
  }, {
2410
- F: __dxlog_file10,
2447
+ F: __dxlog_file11,
2411
2448
  L: 69,
2412
2449
  S: this,
2413
2450
  C: (f, a) => f(...a)
@@ -2418,7 +2455,7 @@ var InvitationTopology = class {
2418
2455
  }
2419
2456
  async onOffer(peer) {
2420
2457
  (0, import_invariant9.invariant)(this._controller, "Not initialized.", {
2421
- F: __dxlog_file10,
2458
+ F: __dxlog_file11,
2422
2459
  L: 76,
2423
2460
  S: this,
2424
2461
  A: [
@@ -2435,7 +2472,7 @@ var InvitationTopology = class {
2435
2472
  return `InvitationTopology(${this._role === import_invitations5.Options.Role.GUEST ? "guest" : "host"})`;
2436
2473
  }
2437
2474
  };
2438
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2475
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2439
2476
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
2440
2477
  var InvitationsHandler = class {
2441
2478
  /**
@@ -2460,7 +2497,7 @@ var InvitationsHandler = class {
2460
2497
  try {
2461
2498
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
2462
2499
  (0, import_invariant6.invariant)(deviceKey, void 0, {
2463
- F: __dxlog_file11,
2500
+ F: __dxlog_file12,
2464
2501
  L: 90,
2465
2502
  S: this,
2466
2503
  A: [
@@ -2489,7 +2526,7 @@ var InvitationsHandler = class {
2489
2526
  import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
2490
2527
  id: traceId
2491
2528
  }), {
2492
- F: __dxlog_file11,
2529
+ F: __dxlog_file12,
2493
2530
  L: 115,
2494
2531
  S: this,
2495
2532
  C: (f, a) => f(...a)
@@ -2497,7 +2534,7 @@ var InvitationsHandler = class {
2497
2534
  (0, import_log6.log)("connected", {
2498
2535
  ...protocol.toJSON()
2499
2536
  }, {
2500
- F: __dxlog_file11,
2537
+ F: __dxlog_file12,
2501
2538
  L: 116,
2502
2539
  S: this,
2503
2540
  C: (f, a) => f(...a)
@@ -2509,7 +2546,7 @@ var InvitationsHandler = class {
2509
2546
  guest: deviceKey,
2510
2547
  ...protocol.toJSON()
2511
2548
  }, {
2512
- F: __dxlog_file11,
2549
+ F: __dxlog_file12,
2513
2550
  L: 118,
2514
2551
  S: this,
2515
2552
  C: (f, a) => f(...a)
@@ -2518,7 +2555,7 @@ var InvitationsHandler = class {
2518
2555
  import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
2519
2556
  id: traceId
2520
2557
  }), {
2521
- F: __dxlog_file11,
2558
+ F: __dxlog_file12,
2522
2559
  L: 120,
2523
2560
  S: this,
2524
2561
  C: (f, a) => f(...a)
@@ -2533,7 +2570,7 @@ var InvitationsHandler = class {
2533
2570
  (0, import_log6.log)("timeout", {
2534
2571
  ...protocol.toJSON()
2535
2572
  }, {
2536
- F: __dxlog_file11,
2573
+ F: __dxlog_file12,
2537
2574
  L: 129,
2538
2575
  S: this,
2539
2576
  C: (f, a) => f(...a)
@@ -2542,7 +2579,7 @@ var InvitationsHandler = class {
2542
2579
  } else {
2543
2580
  if (guardedState.error(extension, err)) {
2544
2581
  import_log6.log.error("failed", err, {
2545
- F: __dxlog_file11,
2582
+ F: __dxlog_file12,
2546
2583
  L: 133,
2547
2584
  S: this,
2548
2585
  C: (f, a) => f(...a)
@@ -2553,7 +2590,7 @@ var InvitationsHandler = class {
2553
2590
  id: traceId,
2554
2591
  error: err
2555
2592
  }), {
2556
- F: __dxlog_file11,
2593
+ F: __dxlog_file12,
2557
2594
  L: 136,
2558
2595
  S: this,
2559
2596
  C: (f, a) => f(...a)
@@ -2567,7 +2604,7 @@ var InvitationsHandler = class {
2567
2604
  (0, import_log6.log)("invalid role", {
2568
2605
  ...err.context
2569
2606
  }, {
2570
- F: __dxlog_file11,
2607
+ F: __dxlog_file12,
2571
2608
  L: 144,
2572
2609
  S: this,
2573
2610
  C: (f, a) => f(...a)
@@ -2579,7 +2616,7 @@ var InvitationsHandler = class {
2579
2616
  (0, import_log6.log)("timeout", {
2580
2617
  err
2581
2618
  }, {
2582
- F: __dxlog_file11,
2619
+ F: __dxlog_file12,
2583
2620
  L: 149,
2584
2621
  S: this,
2585
2622
  C: (f, a) => f(...a)
@@ -2588,7 +2625,7 @@ var InvitationsHandler = class {
2588
2625
  } else {
2589
2626
  if (guardedState.error(extension, err)) {
2590
2627
  import_log6.log.error("failed", err, {
2591
- F: __dxlog_file11,
2628
+ F: __dxlog_file12,
2592
2629
  L: 153,
2593
2630
  S: this,
2594
2631
  C: (f, a) => f(...a)
@@ -2602,7 +2639,7 @@ var InvitationsHandler = class {
2602
2639
  if (invitation.lifetime && invitation.created) {
2603
2640
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
2604
2641
  import_log6.log.warn("invitation has already expired", void 0, {
2605
- F: __dxlog_file11,
2642
+ F: __dxlog_file12,
2606
2643
  L: 164,
2607
2644
  S: this,
2608
2645
  C: (f, a) => f(...a)
@@ -2625,7 +2662,7 @@ var InvitationsHandler = class {
2625
2662
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
2626
2663
  if (deviceProfile) {
2627
2664
  (0, import_invariant6.invariant)(invitation.kind === import_services6.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2628
- F: __dxlog_file11,
2665
+ F: __dxlog_file12,
2629
2666
  L: 197,
2630
2667
  S: this,
2631
2668
  A: [
@@ -2643,7 +2680,7 @@ var InvitationsHandler = class {
2643
2680
  invitationType: import_services6.Invitation.Type.DELEGATED,
2644
2681
  triedPeers: triedPeersIds.size
2645
2682
  }, {
2646
- F: __dxlog_file11,
2683
+ F: __dxlog_file12,
2647
2684
  L: 205,
2648
2685
  S: this,
2649
2686
  C: (f, a) => f(...a)
@@ -2670,7 +2707,7 @@ var InvitationsHandler = class {
2670
2707
  admitted,
2671
2708
  currentState: guardedState.current.state
2672
2709
  }, {
2673
- F: __dxlog_file11,
2710
+ F: __dxlog_file12,
2674
2711
  L: 233,
2675
2712
  S: this,
2676
2713
  C: (f, a) => f(...a)
@@ -2688,7 +2725,7 @@ var InvitationsHandler = class {
2688
2725
  import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
2689
2726
  id: traceId
2690
2727
  }), {
2691
- F: __dxlog_file11,
2728
+ F: __dxlog_file12,
2692
2729
  L: 245,
2693
2730
  S: this,
2694
2731
  C: (f, a) => f(...a)
@@ -2700,7 +2737,7 @@ var InvitationsHandler = class {
2700
2737
  (0, import_log6.log)("connected", {
2701
2738
  ...protocol.toJSON()
2702
2739
  }, {
2703
- F: __dxlog_file11,
2740
+ F: __dxlog_file12,
2704
2741
  L: 256,
2705
2742
  S: this,
2706
2743
  C: (f, a) => f(...a)
@@ -2709,7 +2746,7 @@ var InvitationsHandler = class {
2709
2746
  (0, import_log6.log)("introduce", {
2710
2747
  ...protocol.toJSON()
2711
2748
  }, {
2712
- F: __dxlog_file11,
2749
+ F: __dxlog_file12,
2713
2750
  L: 260,
2714
2751
  S: this,
2715
2752
  C: (f, a) => f(...a)
@@ -2722,7 +2759,7 @@ var InvitationsHandler = class {
2722
2759
  ...protocol.toJSON(),
2723
2760
  response: introductionResponse
2724
2761
  }, {
2725
- F: __dxlog_file11,
2762
+ F: __dxlog_file12,
2726
2763
  L: 265,
2727
2764
  S: this,
2728
2765
  C: (f, a) => f(...a)
@@ -2743,7 +2780,7 @@ var InvitationsHandler = class {
2743
2780
  (0, import_log6.log)("request admission", {
2744
2781
  ...protocol.toJSON()
2745
2782
  }, {
2746
- F: __dxlog_file11,
2783
+ F: __dxlog_file12,
2747
2784
  L: 291,
2748
2785
  S: this,
2749
2786
  C: (f, a) => f(...a)
@@ -2755,7 +2792,7 @@ var InvitationsHandler = class {
2755
2792
  (0, import_log6.log)("admitted by host", {
2756
2793
  ...protocol.toJSON()
2757
2794
  }, {
2758
- F: __dxlog_file11,
2795
+ F: __dxlog_file12,
2759
2796
  L: 302,
2760
2797
  S: this,
2761
2798
  C: (f, a) => f(...a)
@@ -2768,7 +2805,7 @@ var InvitationsHandler = class {
2768
2805
  import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
2769
2806
  id: traceId
2770
2807
  }), {
2771
- F: __dxlog_file11,
2808
+ F: __dxlog_file12,
2772
2809
  L: 308,
2773
2810
  S: this,
2774
2811
  C: (f, a) => f(...a)
@@ -2778,7 +2815,7 @@ var InvitationsHandler = class {
2778
2815
  (0, import_log6.log)("timeout", {
2779
2816
  ...protocol.toJSON()
2780
2817
  }, {
2781
- F: __dxlog_file11,
2818
+ F: __dxlog_file12,
2782
2819
  L: 311,
2783
2820
  S: this,
2784
2821
  C: (f, a) => f(...a)
@@ -2786,7 +2823,7 @@ var InvitationsHandler = class {
2786
2823
  guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
2787
2824
  } else {
2788
2825
  (0, import_log6.log)("auth failed", err, {
2789
- F: __dxlog_file11,
2826
+ F: __dxlog_file12,
2790
2827
  L: 314,
2791
2828
  S: this,
2792
2829
  C: (f, a) => f(...a)
@@ -2798,7 +2835,7 @@ var InvitationsHandler = class {
2798
2835
  id: traceId,
2799
2836
  error: err
2800
2837
  }), {
2801
- F: __dxlog_file11,
2838
+ F: __dxlog_file12,
2802
2839
  L: 318,
2803
2840
  S: this,
2804
2841
  C: (f, a) => f(...a)
@@ -2814,7 +2851,7 @@ var InvitationsHandler = class {
2814
2851
  (0, import_log6.log)("timeout", {
2815
2852
  ...protocol.toJSON()
2816
2853
  }, {
2817
- F: __dxlog_file11,
2854
+ F: __dxlog_file12,
2818
2855
  L: 327,
2819
2856
  S: this,
2820
2857
  C: (f, a) => f(...a)
@@ -2822,7 +2859,7 @@ var InvitationsHandler = class {
2822
2859
  guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
2823
2860
  } else {
2824
2861
  (0, import_log6.log)("auth failed", err, {
2825
- F: __dxlog_file11,
2862
+ F: __dxlog_file12,
2826
2863
  L: 330,
2827
2864
  S: this,
2828
2865
  C: (f, a) => f(...a)
@@ -2840,7 +2877,7 @@ var InvitationsHandler = class {
2840
2877
  await ctx.dispose();
2841
2878
  } else {
2842
2879
  (0, import_invariant6.invariant)(invitation.swarmKey, void 0, {
2843
- F: __dxlog_file11,
2880
+ F: __dxlog_file12,
2844
2881
  L: 345,
2845
2882
  S: this,
2846
2883
  A: [
@@ -2934,16 +2971,29 @@ var InvitationsHandler = class {
2934
2971
  };
2935
2972
  }
2936
2973
  _logStateUpdate(invitation, actor, newState) {
2937
- (0, import_log6.log)("invitation state update", {
2938
- actor: actor?.constructor.name,
2939
- newState: stateToString(newState),
2940
- oldState: stateToString(invitation.state)
2941
- }, {
2942
- F: __dxlog_file11,
2943
- L: 438,
2944
- S: this,
2945
- C: (f, a) => f(...a)
2946
- });
2974
+ if (this._isNotTerminal(newState)) {
2975
+ (0, import_log6.log)("invitation state update", {
2976
+ actor: actor?.constructor.name,
2977
+ newState: stateToString(newState),
2978
+ oldState: stateToString(invitation.state)
2979
+ }, {
2980
+ F: __dxlog_file12,
2981
+ L: 439,
2982
+ S: this,
2983
+ C: (f, a) => f(...a)
2984
+ });
2985
+ } else {
2986
+ import_log6.log.info("invitation state update", {
2987
+ actor: actor?.constructor.name,
2988
+ newState: stateToString(newState),
2989
+ oldState: stateToString(invitation.state)
2990
+ }, {
2991
+ F: __dxlog_file12,
2992
+ L: 445,
2993
+ S: this,
2994
+ C: (f, a) => f(...a)
2995
+ });
2996
+ }
2947
2997
  }
2948
2998
  _isNotTerminal(currentState) {
2949
2999
  return ![
@@ -2957,16 +3007,16 @@ var InvitationsHandler = class {
2957
3007
  async _handleGuestOtpAuth(extension, setState, authenticated, options) {
2958
3008
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2959
3009
  (0, import_log6.log)("guest waiting for authentication code...", void 0, {
2960
- F: __dxlog_file11,
2961
- L: 462,
3010
+ F: __dxlog_file12,
3011
+ L: 470,
2962
3012
  S: this,
2963
3013
  C: (f, a) => f(...a)
2964
3014
  });
2965
3015
  setState(import_services6.Invitation.State.READY_FOR_AUTHENTICATION);
2966
3016
  const authCode = await authenticated.wait(options);
2967
3017
  (0, import_log6.log)("sending authentication request", void 0, {
2968
- F: __dxlog_file11,
2969
- L: 466,
3018
+ F: __dxlog_file12,
3019
+ L: 474,
2970
3020
  S: this,
2971
3021
  C: (f, a) => f(...a)
2972
3022
  });
@@ -2984,8 +3034,8 @@ var InvitationsHandler = class {
2984
3034
  (0, import_log6.log)("retrying invalid code", {
2985
3035
  attempt
2986
3036
  }, {
2987
- F: __dxlog_file11,
2988
- L: 477,
3037
+ F: __dxlog_file12,
3038
+ L: 485,
2989
3039
  S: this,
2990
3040
  C: (f, a) => f(...a)
2991
3041
  });
@@ -3002,8 +3052,8 @@ var InvitationsHandler = class {
3002
3052
  throw new Error("challenge missing in the introduction");
3003
3053
  }
3004
3054
  (0, import_log6.log)("sending authentication request", void 0, {
3005
- F: __dxlog_file11,
3006
- L: 496,
3055
+ F: __dxlog_file12,
3056
+ L: 504,
3007
3057
  S: this,
3008
3058
  C: (f, a) => f(...a)
3009
3059
  });
@@ -3117,7 +3167,7 @@ var InvitationsServiceImpl = class {
3117
3167
  });
3118
3168
  }
3119
3169
  };
3120
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
3170
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
3121
3171
  var SpaceInvitationProtocol = class {
3122
3172
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
3123
3173
  this._spaceManager = _spaceManager;
@@ -3151,79 +3201,43 @@ var SpaceInvitationProtocol = class {
3151
3201
  };
3152
3202
  }
3153
3203
  async admit(invitation, request, guestProfile) {
3154
- (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3155
- F: __dxlog_file12,
3156
- L: 76,
3157
- S: this,
3158
- A: [
3159
- "this._spaceKey",
3160
- ""
3161
- ]
3162
- });
3163
- const space = this._spaceManager.spaces.get(this._spaceKey);
3164
- (0, import_invariant10.invariant)(space, void 0, {
3165
- F: __dxlog_file12,
3166
- L: 78,
3167
- S: this,
3168
- A: [
3169
- "space",
3170
- ""
3171
- ]
3172
- });
3173
- (0, import_invariant10.invariant)(request.space, void 0, {
3174
- F: __dxlog_file12,
3175
- L: 80,
3204
+ (0, import_invariant10.invariant)(this._spaceKey && request.space, void 0, {
3205
+ F: __dxlog_file13,
3206
+ L: 74,
3176
3207
  S: this,
3177
3208
  A: [
3178
- "request.space",
3209
+ "this._spaceKey && request.space",
3179
3210
  ""
3180
3211
  ]
3181
3212
  });
3182
- const { identityKey, deviceKey } = request.space;
3183
- if (space.inner.spaceState.getMemberRole(identityKey) !== import_credentials10.SpaceMember.Role.REMOVED) {
3184
- throw new import_protocols8.AlreadyJoinedError();
3185
- }
3186
3213
  (0, import_log10.log)("writing guest credentials", {
3187
3214
  host: this._signingContext.deviceKey,
3188
- guest: deviceKey
3215
+ guest: request.space.deviceKey
3189
3216
  }, {
3190
- F: __dxlog_file12,
3191
- L: 87,
3217
+ F: __dxlog_file13,
3218
+ L: 75,
3192
3219
  S: this,
3193
3220
  C: (f, a) => f(...a)
3194
3221
  });
3195
- const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, invitation.role ?? import_credentials10.SpaceMember.Role.ADMIN, space.inner.spaceState.membershipChainHeads, guestProfile, invitation.delegationCredentialId);
3196
- (0, import_invariant10.invariant)(credentials[0].credential, void 0, {
3197
- F: __dxlog_file12,
3198
- L: 101,
3199
- S: this,
3200
- A: [
3201
- "credentials[0].credential",
3202
- ""
3203
- ]
3204
- });
3205
- const spaceMemberCredential = credentials[0].credential.credential;
3206
- (0, import_invariant10.invariant)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3207
- F: __dxlog_file12,
3208
- L: 103,
3209
- S: this,
3210
- A: [
3211
- "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
3212
- ""
3213
- ]
3222
+ const spaceMemberCredential = await this._spaceManager.admitMember({
3223
+ spaceKey: this._spaceKey,
3224
+ identityKey: request.space.identityKey,
3225
+ role: invitation.role ?? import_credentials10.SpaceMember.Role.ADMIN,
3226
+ profile: guestProfile,
3227
+ delegationCredentialId: invitation.delegationCredentialId
3214
3228
  });
3215
- await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
3229
+ const space = this._spaceManager.spaces.get(this._spaceKey);
3216
3230
  return {
3217
3231
  space: {
3218
3232
  credential: spaceMemberCredential,
3219
- controlTimeframe: space.inner.controlPipeline.state.timeframe
3233
+ controlTimeframe: space?.inner.controlPipeline.state.timeframe
3220
3234
  }
3221
3235
  };
3222
3236
  }
3223
3237
  async delegate(invitation) {
3224
3238
  (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3225
- F: __dxlog_file12,
3226
- L: 116,
3239
+ F: __dxlog_file13,
3240
+ L: 95,
3227
3241
  S: this,
3228
3242
  A: [
3229
3243
  "this._spaceKey",
@@ -3232,8 +3246,8 @@ var SpaceInvitationProtocol = class {
3232
3246
  });
3233
3247
  const space = this._spaceManager.spaces.get(this._spaceKey);
3234
3248
  (0, import_invariant10.invariant)(space, void 0, {
3235
- F: __dxlog_file12,
3236
- L: 118,
3249
+ F: __dxlog_file13,
3250
+ L: 97,
3237
3251
  S: this,
3238
3252
  A: [
3239
3253
  "space",
@@ -3242,8 +3256,8 @@ var SpaceInvitationProtocol = class {
3242
3256
  });
3243
3257
  if (invitation.authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
3244
3258
  (0, import_invariant10.invariant)(invitation.guestKeypair?.publicKey, void 0, {
3245
- F: __dxlog_file12,
3246
- L: 120,
3259
+ F: __dxlog_file13,
3260
+ L: 99,
3247
3261
  S: this,
3248
3262
  A: [
3249
3263
  "invitation.guestKeypair?.publicKey",
@@ -3255,8 +3269,8 @@ var SpaceInvitationProtocol = class {
3255
3269
  host: this._signingContext.deviceKey,
3256
3270
  id: invitation.invitationId
3257
3271
  }, {
3258
- F: __dxlog_file12,
3259
- L: 123,
3272
+ F: __dxlog_file13,
3273
+ L: 102,
3260
3274
  S: this,
3261
3275
  C: (f, a) => f(...a)
3262
3276
  });
@@ -3270,8 +3284,8 @@ var SpaceInvitationProtocol = class {
3270
3284
  guestKey: invitation.authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
3271
3285
  });
3272
3286
  (0, import_invariant10.invariant)(credential.credential, void 0, {
3273
- F: __dxlog_file12,
3274
- L: 143,
3287
+ F: __dxlog_file13,
3288
+ L: 122,
3275
3289
  S: this,
3276
3290
  A: [
3277
3291
  "credential.credential",
@@ -3285,8 +3299,8 @@ var SpaceInvitationProtocol = class {
3285
3299
  }
3286
3300
  async cancelDelegation(invitation) {
3287
3301
  (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3288
- F: __dxlog_file12,
3289
- L: 149,
3302
+ F: __dxlog_file13,
3303
+ L: 128,
3290
3304
  S: this,
3291
3305
  A: [
3292
3306
  "this._spaceKey",
@@ -3294,8 +3308,8 @@ var SpaceInvitationProtocol = class {
3294
3308
  ]
3295
3309
  });
3296
3310
  (0, import_invariant10.invariant)(invitation.type === import_services10.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
3297
- F: __dxlog_file12,
3298
- L: 150,
3311
+ F: __dxlog_file13,
3312
+ L: 129,
3299
3313
  S: this,
3300
3314
  A: [
3301
3315
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -3304,8 +3318,8 @@ var SpaceInvitationProtocol = class {
3304
3318
  });
3305
3319
  const space = this._spaceManager.spaces.get(this._spaceKey);
3306
3320
  (0, import_invariant10.invariant)(space, void 0, {
3307
- F: __dxlog_file12,
3308
- L: 152,
3321
+ F: __dxlog_file13,
3322
+ L: 131,
3309
3323
  S: this,
3310
3324
  A: [
3311
3325
  "space",
@@ -3316,15 +3330,15 @@ var SpaceInvitationProtocol = class {
3316
3330
  host: this._signingContext.deviceKey,
3317
3331
  id: invitation.invitationId
3318
3332
  }, {
3319
- F: __dxlog_file12,
3320
- L: 154,
3333
+ F: __dxlog_file13,
3334
+ L: 133,
3321
3335
  S: this,
3322
3336
  C: (f, a) => f(...a)
3323
3337
  });
3324
3338
  const credential = await (0, import_credentials9.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
3325
3339
  (0, import_invariant10.invariant)(credential.credential, void 0, {
3326
- F: __dxlog_file12,
3327
- L: 161,
3340
+ F: __dxlog_file13,
3341
+ L: 140,
3328
3342
  S: this,
3329
3343
  A: [
3330
3344
  "credential.credential",
@@ -3362,8 +3376,8 @@ var SpaceInvitationProtocol = class {
3362
3376
  }
3363
3377
  async accept(response) {
3364
3378
  (0, import_invariant10.invariant)(response.space, void 0, {
3365
- F: __dxlog_file12,
3366
- L: 196,
3379
+ F: __dxlog_file13,
3380
+ L: 175,
3367
3381
  S: this,
3368
3382
  A: [
3369
3383
  "response.space",
@@ -3373,8 +3387,8 @@ var SpaceInvitationProtocol = class {
3373
3387
  const { credential, controlTimeframe, dataTimeframe } = response.space;
3374
3388
  const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
3375
3389
  (0, import_invariant10.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3376
- F: __dxlog_file12,
3377
- L: 199,
3390
+ F: __dxlog_file13,
3391
+ L: 178,
3378
3392
  S: this,
3379
3393
  A: [
3380
3394
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3382,8 +3396,8 @@ var SpaceInvitationProtocol = class {
3382
3396
  ]
3383
3397
  });
3384
3398
  (0, import_invariant10.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
3385
- F: __dxlog_file12,
3386
- L: 200,
3399
+ F: __dxlog_file13,
3400
+ L: 179,
3387
3401
  S: this,
3388
3402
  A: [
3389
3403
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -3405,7 +3419,7 @@ var SpaceInvitationProtocol = class {
3405
3419
  };
3406
3420
  }
3407
3421
  };
3408
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3422
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3409
3423
  var InvitationsManager = class {
3410
3424
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
3411
3425
  this._invitationsHandler = _invitationsHandler;
@@ -3448,7 +3462,7 @@ var InvitationsManager = class {
3448
3462
  await this._persistIfRequired(handler, stream, invitation);
3449
3463
  } catch (err) {
3450
3464
  import_log11.log.catch(err, void 0, {
3451
- F: __dxlog_file13,
3465
+ F: __dxlog_file14,
3452
3466
  L: 82,
3453
3467
  S: this,
3454
3468
  C: (f, a) => f(...a)
@@ -3471,7 +3485,7 @@ var InvitationsManager = class {
3471
3485
  const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
3472
3486
  const loadTasks = freshInvitations.map((persistentInvitation) => {
3473
3487
  (0, import_invariant11.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
3474
- F: __dxlog_file13,
3488
+ F: __dxlog_file14,
3475
3489
  L: 103,
3476
3490
  S: this,
3477
3491
  A: [
@@ -3490,7 +3504,7 @@ var InvitationsManager = class {
3490
3504
  };
3491
3505
  } catch (err) {
3492
3506
  import_log11.log.catch(err, void 0, {
3493
- F: __dxlog_file13,
3507
+ F: __dxlog_file14,
3494
3508
  L: 110,
3495
3509
  S: this,
3496
3510
  C: (f, a) => f(...a)
@@ -3522,13 +3536,13 @@ var InvitationsManager = class {
3522
3536
  }
3523
3537
  async authenticate({ invitationId, authCode }) {
3524
3538
  (0, import_log11.log)("authenticating...", void 0, {
3525
- F: __dxlog_file13,
3539
+ F: __dxlog_file14,
3526
3540
  L: 140,
3527
3541
  S: this,
3528
3542
  C: (f, a) => f(...a)
3529
3543
  });
3530
3544
  (0, import_invariant11.invariant)(invitationId, void 0, {
3531
- F: __dxlog_file13,
3545
+ F: __dxlog_file14,
3532
3546
  L: 141,
3533
3547
  S: this,
3534
3548
  A: [
@@ -3541,7 +3555,7 @@ var InvitationsManager = class {
3541
3555
  import_log11.log.warn("invalid invitation", {
3542
3556
  invitationId
3543
3557
  }, {
3544
- F: __dxlog_file13,
3558
+ F: __dxlog_file14,
3545
3559
  L: 144,
3546
3560
  S: this,
3547
3561
  C: (f, a) => f(...a)
@@ -3554,13 +3568,13 @@ var InvitationsManager = class {
3554
3568
  (0, import_log11.log)("cancelInvitation...", {
3555
3569
  invitationId
3556
3570
  }, {
3557
- F: __dxlog_file13,
3571
+ F: __dxlog_file14,
3558
3572
  L: 151,
3559
3573
  S: this,
3560
3574
  C: (f, a) => f(...a)
3561
3575
  });
3562
3576
  (0, import_invariant11.invariant)(invitationId, void 0, {
3563
- F: __dxlog_file13,
3577
+ F: __dxlog_file14,
3564
3578
  L: 152,
3565
3579
  S: this,
3566
3580
  A: [
@@ -3634,12 +3648,15 @@ var InvitationsManager = class {
3634
3648
  stream.error(err);
3635
3649
  void ctx.dispose();
3636
3650
  }
3651
+ }, {
3652
+ F: __dxlog_file14,
3653
+ L: 234
3637
3654
  });
3638
3655
  ctx.onDispose(() => {
3639
3656
  (0, import_log11.log)("complete", {
3640
3657
  ...handler.toJSON()
3641
3658
  }, {
3642
- F: __dxlog_file13,
3659
+ F: __dxlog_file14,
3643
3660
  L: 241,
3644
3661
  S: this,
3645
3662
  C: (f, a) => f(...a)
@@ -3672,7 +3689,7 @@ var InvitationsManager = class {
3672
3689
  (0, import_log11.log)("timeout", {
3673
3690
  ...handler.toJSON()
3674
3691
  }, {
3675
- F: __dxlog_file13,
3692
+ F: __dxlog_file14,
3676
3693
  L: 261,
3677
3694
  S: this,
3678
3695
  C: (f, a) => f(...a)
@@ -3683,7 +3700,7 @@ var InvitationsManager = class {
3683
3700
  });
3684
3701
  } else {
3685
3702
  import_log11.log.warn("auth failed", err, {
3686
- F: __dxlog_file13,
3703
+ F: __dxlog_file14,
3687
3704
  L: 264,
3688
3705
  S: this,
3689
3706
  C: (f, a) => f(...a)
@@ -3695,12 +3712,15 @@ var InvitationsManager = class {
3695
3712
  }
3696
3713
  void ctx.dispose();
3697
3714
  }
3715
+ }, {
3716
+ F: __dxlog_file14,
3717
+ L: 258
3698
3718
  });
3699
3719
  ctx.onDispose(() => {
3700
3720
  (0, import_log11.log)("complete", {
3701
3721
  ...handler.toJSON()
3702
3722
  }, {
3703
- F: __dxlog_file13,
3723
+ F: __dxlog_file14,
3704
3724
  L: 271,
3705
3725
  S: this,
3706
3726
  C: (f, a) => f(...a)
@@ -3745,7 +3765,7 @@ var InvitationsManager = class {
3745
3765
  await this._metadataStore.removeInvitation(invitation.invitationId);
3746
3766
  } catch (err) {
3747
3767
  import_log11.log.catch(err, void 0, {
3748
- F: __dxlog_file13,
3768
+ F: __dxlog_file14,
3749
3769
  L: 307,
3750
3770
  S: this,
3751
3771
  C: (f, a) => f(...a)
@@ -3798,7 +3818,7 @@ var AutomergeSpaceState = class extends import_context11.Resource {
3798
3818
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3799
3819
  }
3800
3820
  };
3801
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
3821
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
3802
3822
  var runEpochMigration = async (ctx, context) => {
3803
3823
  switch (context.migration) {
3804
3824
  case import_services13.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
@@ -3822,7 +3842,7 @@ var runEpochMigration = async (ctx, context) => {
3822
3842
  }
3823
3843
  case import_services13.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
3824
3844
  import_log13.log.info("Fragmenting", void 0, {
3825
- F: __dxlog_file14,
3845
+ F: __dxlog_file15,
3826
3846
  L: 63,
3827
3847
  S: void 0,
3828
3848
  C: (f, a) => f(...a)
@@ -3834,7 +3854,7 @@ var runEpochMigration = async (ctx, context) => {
3834
3854
  const properties = (0, import_echo_db.findInlineObjectOfType)(rootHandle.docSync(), import_echo_schema.TYPE_PROPERTIES);
3835
3855
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3836
3856
  (0, import_invariant13.invariant)(properties, "Properties not found", {
3837
- F: __dxlog_file14,
3857
+ F: __dxlog_file15,
3838
3858
  L: 73,
3839
3859
  S: void 0,
3840
3860
  A: [
@@ -3850,7 +3870,7 @@ var runEpochMigration = async (ctx, context) => {
3850
3870
  };
3851
3871
  const newRoot = context.repo.create(newSpaceDoc);
3852
3872
  (0, import_invariant13.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3853
- F: __dxlog_file14,
3873
+ F: __dxlog_file15,
3854
3874
  L: 78,
3855
3875
  S: void 0,
3856
3876
  A: [
@@ -3881,7 +3901,7 @@ var runEpochMigration = async (ctx, context) => {
3881
3901
  const rootHandle = context.repo.find(currentRootUrl);
3882
3902
  await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
3883
3903
  (0, import_invariant13.invariant)(rootHandle.docSync(), "Root doc not found", {
3884
- F: __dxlog_file14,
3904
+ F: __dxlog_file15,
3885
3905
  L: 100,
3886
3906
  S: void 0,
3887
3907
  A: [
@@ -3891,23 +3911,37 @@ var runEpochMigration = async (ctx, context) => {
3891
3911
  });
3892
3912
  const newRootContent = await (0, import_echo_db.convertLegacySpaceRootDoc)(structuredClone(rootHandle.docSync()));
3893
3913
  for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
3894
- const handle = context.repo.find(url);
3895
- await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(handle.whenReady(), 1e4));
3896
- (0, import_invariant13.invariant)(handle.docSync(), "Doc not found", {
3897
- F: __dxlog_file14,
3898
- L: 107,
3899
- S: void 0,
3900
- A: [
3901
- "handle.docSync()",
3902
- "'Doc not found'"
3903
- ]
3904
- });
3905
- const newDoc = await (0, import_echo_db.convertLegacyReferences)(structuredClone(handle.docSync()));
3906
- const migratedDoc = (0, import_echo_db.migrateDocument)(handle.docSync(), newDoc);
3907
- const newHandle = context.repo.import(import_automerge.next.save(migratedDoc));
3908
- newRootContent.links[id] = newHandle.url;
3909
- }
3910
- const migratedRoot = (0, import_echo_db.migrateDocument)(rootHandle.docSync(), newRootContent);
3914
+ try {
3915
+ const handle = context.repo.find(url);
3916
+ await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(handle.whenReady(), 1e4));
3917
+ (0, import_invariant13.invariant)(handle.docSync(), "Doc not found", {
3918
+ F: __dxlog_file15,
3919
+ L: 108,
3920
+ S: void 0,
3921
+ A: [
3922
+ "handle.docSync()",
3923
+ "'Doc not found'"
3924
+ ]
3925
+ });
3926
+ const newDoc = await (0, import_echo_db.convertLegacyReferences)(structuredClone(handle.docSync()));
3927
+ const migratedDoc = (0, import_echo_db.migrateDocument)(handle.docSync(), newDoc);
3928
+ const newHandle = context.repo.import(import_automerge.next.save(migratedDoc));
3929
+ newRootContent.links[id] = newHandle.url;
3930
+ } catch (err) {
3931
+ import_log13.log.warn("Failed to migrate reference", {
3932
+ id,
3933
+ url,
3934
+ error: err
3935
+ }, {
3936
+ F: __dxlog_file15,
3937
+ L: 114,
3938
+ S: void 0,
3939
+ C: (f, a) => f(...a)
3940
+ });
3941
+ delete newRootContent.links[id];
3942
+ }
3943
+ }
3944
+ const migratedRoot = (0, import_echo_db.migrateDocument)(rootHandle.docSync(), newRootContent);
3911
3945
  const newRoot = context.repo.import(import_automerge.next.save(migratedRoot));
3912
3946
  await context.repo.flush();
3913
3947
  return {
@@ -3916,8 +3950,8 @@ var runEpochMigration = async (ctx, context) => {
3916
3950
  }
3917
3951
  case import_services13.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
3918
3952
  (0, import_invariant13.invariant)(context.newAutomergeRoot, void 0, {
3919
- F: __dxlog_file14,
3920
- L: 124,
3953
+ F: __dxlog_file15,
3954
+ L: 129,
3921
3955
  S: void 0,
3922
3956
  A: [
3923
3957
  "context.newAutomergeRoot",
@@ -3932,14 +3966,17 @@ var runEpochMigration = async (ctx, context) => {
3932
3966
  }
3933
3967
  return {};
3934
3968
  };
3935
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3969
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3936
3970
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3937
3971
  var DEFAULT_SUCCESS_DELAY = 1e3;
3938
3972
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
3939
3973
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3940
3974
  var NotarizationPlugin = class {
3941
3975
  constructor() {
3942
- this._ctx = new import_context13.Context();
3976
+ this._ctx = new import_context13.Context(void 0, {
3977
+ F: __dxlog_file16,
3978
+ L: 62
3979
+ });
3943
3980
  this._extensionOpened = new import_async16.Event();
3944
3981
  this._extensions = /* @__PURE__ */ new Set();
3945
3982
  this._processedCredentials = new import_util9.ComplexSet(import_keys11.PublicKey.hash);
@@ -3960,13 +3997,13 @@ var NotarizationPlugin = class {
3960
3997
  (0, import_log14.log)("notarize", {
3961
3998
  credentials
3962
3999
  }, {
3963
- F: __dxlog_file15,
4000
+ F: __dxlog_file16,
3964
4001
  L: 90,
3965
4002
  S: this,
3966
4003
  C: (f, a) => f(...a)
3967
4004
  });
3968
4005
  (0, import_invariant14.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
3969
- F: __dxlog_file15,
4006
+ F: __dxlog_file16,
3970
4007
  L: 91,
3971
4008
  S: this,
3972
4009
  A: [
@@ -3980,7 +4017,7 @@ var NotarizationPlugin = class {
3980
4017
  import_log14.log.warn("Notarization error", {
3981
4018
  err
3982
4019
  }, {
3983
- F: __dxlog_file15,
4020
+ F: __dxlog_file16,
3984
4021
  L: 99,
3985
4022
  S: this,
3986
4023
  C: (f, a) => f(...a)
@@ -3996,7 +4033,7 @@ var NotarizationPlugin = class {
3996
4033
  timeout,
3997
4034
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
3998
4035
  }, {
3999
- F: __dxlog_file15,
4036
+ F: __dxlog_file16,
4000
4037
  L: 111,
4001
4038
  S: this,
4002
4039
  C: (f, a) => f(...a)
@@ -4019,7 +4056,7 @@ var NotarizationPlugin = class {
4019
4056
  import_log14.log.info("Exhausted all peers to notarize with", {
4020
4057
  retryIn: retryTimeout
4021
4058
  }, {
4022
- F: __dxlog_file15,
4059
+ F: __dxlog_file16,
4023
4060
  L: 136,
4024
4061
  S: this,
4025
4062
  C: (f, a) => f(...a)
@@ -4033,7 +4070,7 @@ var NotarizationPlugin = class {
4033
4070
  peer: peer.localPeerId,
4034
4071
  credentialId: credentials.map((credential) => credential.id)
4035
4072
  }, {
4036
- F: __dxlog_file15,
4073
+ F: __dxlog_file16,
4037
4074
  L: 143,
4038
4075
  S: this,
4039
4076
  C: (f, a) => f(...a)
@@ -4042,7 +4079,7 @@ var NotarizationPlugin = class {
4042
4079
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
4043
4080
  });
4044
4081
  (0, import_log14.log)("success", void 0, {
4045
- F: __dxlog_file15,
4082
+ F: __dxlog_file16,
4046
4083
  L: 147,
4047
4084
  S: this,
4048
4085
  C: (f, a) => f(...a)
@@ -4051,7 +4088,7 @@ var NotarizationPlugin = class {
4051
4088
  } catch (err) {
4052
4089
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
4053
4090
  import_log14.log.info("error notarizing (recoverable)", err, {
4054
- F: __dxlog_file15,
4091
+ F: __dxlog_file16,
4055
4092
  L: 151,
4056
4093
  S: this,
4057
4094
  C: (f, a) => f(...a)
@@ -4069,7 +4106,7 @@ var NotarizationPlugin = class {
4069
4106
  errors.wait()
4070
4107
  ]);
4071
4108
  (0, import_log14.log)("done", void 0, {
4072
- F: __dxlog_file15,
4109
+ F: __dxlog_file16,
4073
4110
  L: 162,
4074
4111
  S: this,
4075
4112
  C: (f, a) => f(...a)
@@ -4091,7 +4128,7 @@ var NotarizationPlugin = class {
4091
4128
  }
4092
4129
  setWriter(writer) {
4093
4130
  (0, import_invariant14.invariant)(!this._writer, "Writer already set.", {
4094
- F: __dxlog_file15,
4131
+ F: __dxlog_file16,
4095
4132
  L: 181,
4096
4133
  S: this,
4097
4134
  A: [
@@ -4116,7 +4153,7 @@ var NotarizationPlugin = class {
4116
4153
  }
4117
4154
  for (const credential of request.credentials ?? []) {
4118
4155
  (0, import_invariant14.invariant)(credential.id, "Credential must have an id", {
4119
- F: __dxlog_file15,
4156
+ F: __dxlog_file16,
4120
4157
  L: 200,
4121
4158
  S: this,
4122
4159
  A: [
@@ -4136,7 +4173,7 @@ var NotarizationPlugin = class {
4136
4173
  (0, import_log14.log)("extension opened", {
4137
4174
  peer: extension.localPeerId
4138
4175
  }, {
4139
- F: __dxlog_file15,
4176
+ F: __dxlog_file16,
4140
4177
  L: 211,
4141
4178
  S: this,
4142
4179
  C: (f, a) => f(...a)
@@ -4148,7 +4185,7 @@ var NotarizationPlugin = class {
4148
4185
  (0, import_log14.log)("extension closed", {
4149
4186
  peer: extension.localPeerId
4150
4187
  }, {
4151
- F: __dxlog_file15,
4188
+ F: __dxlog_file16,
4152
4189
  L: 216,
4153
4190
  S: this,
4154
4191
  C: (f, a) => f(...a)
@@ -4263,10 +4300,13 @@ function _using_ctx() {
4263
4300
  }
4264
4301
  };
4265
4302
  }
4266
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4303
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4267
4304
  var DataSpace = class {
4268
4305
  constructor(params) {
4269
- this._ctx = new import_context10.Context();
4306
+ this._ctx = new import_context10.Context(void 0, {
4307
+ F: __dxlog_file17,
4308
+ L: 84
4309
+ });
4270
4310
  this._notarizationPlugin = new NotarizationPlugin();
4271
4311
  this._cache = void 0;
4272
4312
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
@@ -4296,7 +4336,7 @@ var DataSpace = class {
4296
4336
  (0, import_log12.log)("new state", {
4297
4337
  state: import_services12.SpaceState[this._state]
4298
4338
  }, {
4299
- F: __dxlog_file16,
4339
+ F: __dxlog_file17,
4300
4340
  L: 146,
4301
4341
  S: this,
4302
4342
  C: (f, a) => f(...a)
@@ -4351,12 +4391,15 @@ var DataSpace = class {
4351
4391
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
4352
4392
  await this._automergeSpaceState.open();
4353
4393
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
4354
- await this._inner.open(new import_context10.Context());
4394
+ await this._inner.open(new import_context10.Context(void 0, {
4395
+ F: __dxlog_file17,
4396
+ L: 215
4397
+ }));
4355
4398
  this._state = import_services12.SpaceState.CONTROL_ONLY;
4356
4399
  (0, import_log12.log)("new state", {
4357
4400
  state: import_services12.SpaceState[this._state]
4358
4401
  }, {
4359
- F: __dxlog_file16,
4402
+ F: __dxlog_file17,
4360
4403
  L: 217,
4361
4404
  S: this,
4362
4405
  C: (f, a) => f(...a)
@@ -4374,13 +4417,16 @@ var DataSpace = class {
4374
4417
  (0, import_log12.log)("new state", {
4375
4418
  state: import_services12.SpaceState[this._state]
4376
4419
  }, {
4377
- F: __dxlog_file16,
4420
+ F: __dxlog_file17,
4378
4421
  L: 231,
4379
4422
  S: this,
4380
4423
  C: (f, a) => f(...a)
4381
4424
  });
4382
4425
  await this._ctx.dispose();
4383
- this._ctx = new import_context10.Context();
4426
+ this._ctx = new import_context10.Context(void 0, {
4427
+ F: __dxlog_file17,
4428
+ L: 233
4429
+ });
4384
4430
  await this.authVerifier.close();
4385
4431
  await this._inner.close();
4386
4432
  await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
@@ -4407,7 +4453,7 @@ var DataSpace = class {
4407
4453
  } catch (err) {
4408
4454
  if (err instanceof import_protocols9.CancelledError || err instanceof import_context10.ContextDisposedError) {
4409
4455
  (0, import_log12.log)("data pipeline initialization cancelled", err, {
4410
- F: __dxlog_file16,
4456
+ F: __dxlog_file17,
4411
4457
  L: 265,
4412
4458
  S: this,
4413
4459
  C: (f, a) => f(...a)
@@ -4415,7 +4461,7 @@ var DataSpace = class {
4415
4461
  return;
4416
4462
  }
4417
4463
  import_log12.log.error("Error initializing data pipeline", err, {
4418
- F: __dxlog_file16,
4464
+ F: __dxlog_file17,
4419
4465
  L: 269,
4420
4466
  S: this,
4421
4467
  C: (f, a) => f(...a)
@@ -4424,7 +4470,7 @@ var DataSpace = class {
4424
4470
  (0, import_log12.log)("new state", {
4425
4471
  state: import_services12.SpaceState[this._state]
4426
4472
  }, {
4427
- F: __dxlog_file16,
4473
+ F: __dxlog_file17,
4428
4474
  L: 271,
4429
4475
  S: this,
4430
4476
  C: (f, a) => f(...a)
@@ -4444,7 +4490,7 @@ var DataSpace = class {
4444
4490
  (0, import_log12.log)("new state", {
4445
4491
  state: import_services12.SpaceState[this._state]
4446
4492
  }, {
4447
- F: __dxlog_file16,
4493
+ F: __dxlog_file17,
4448
4494
  L: 287,
4449
4495
  S: this,
4450
4496
  C: (f, a) => f(...a)
@@ -4461,7 +4507,7 @@ var DataSpace = class {
4461
4507
  (0, import_log12.log)("new state", {
4462
4508
  state: import_services12.SpaceState[this._state]
4463
4509
  }, {
4464
- F: __dxlog_file16,
4510
+ F: __dxlog_file17,
4465
4511
  L: 306,
4466
4512
  S: this,
4467
4513
  C: (f, a) => f(...a)
@@ -4477,7 +4523,7 @@ var DataSpace = class {
4477
4523
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
4478
4524
  await this._createWritableFeeds();
4479
4525
  (0, import_log12.log)("writable feeds created", void 0, {
4480
- F: __dxlog_file16,
4526
+ F: __dxlog_file17,
4481
4527
  L: 322,
4482
4528
  S: this,
4483
4529
  C: (f, a) => f(...a)
@@ -4540,12 +4586,11 @@ var DataSpace = class {
4540
4586
  space: this.key,
4541
4587
  rootUrl
4542
4588
  }, {
4543
- F: __dxlog_file16,
4589
+ F: __dxlog_file17,
4544
4590
  L: 388,
4545
4591
  S: this,
4546
4592
  C: (f, a) => f(...a)
4547
4593
  });
4548
- this._echoHost.replicateDocument(rootUrl);
4549
4594
  const handle = this._echoHost.automergeRepo.find(rootUrl);
4550
4595
  queueMicrotask(async () => {
4551
4596
  try {
@@ -4572,8 +4617,10 @@ var DataSpace = class {
4572
4617
  const root = await this._echoHost.openSpaceRoot(handle.url);
4573
4618
  this._databaseRoot = root;
4574
4619
  if (root.getVersion() !== import_echo_protocol.SpaceDocVersion.CURRENT) {
4575
- this._state = import_services12.SpaceState.REQUIRES_MIGRATION;
4576
- this.stateUpdate.emit();
4620
+ if (this._state !== import_services12.SpaceState.REQUIRES_MIGRATION) {
4621
+ this._state = import_services12.SpaceState.REQUIRES_MIGRATION;
4622
+ this.stateUpdate.emit();
4623
+ }
4577
4624
  } else {
4578
4625
  if (this._state !== import_services12.SpaceState.READY) {
4579
4626
  await this._enterReadyState();
@@ -4593,7 +4640,7 @@ var DataSpace = class {
4593
4640
  rootUrl,
4594
4641
  err
4595
4642
  }, {
4596
- F: __dxlog_file16,
4643
+ F: __dxlog_file17,
4597
4644
  L: 431,
4598
4645
  S: this,
4599
4646
  C: (f, a) => f(...a)
@@ -4679,7 +4726,7 @@ var DataSpace = class {
4679
4726
  (0, import_log12.log)("new state", {
4680
4727
  state: import_services12.SpaceState[this._state]
4681
4728
  }, {
4682
- F: __dxlog_file16,
4729
+ F: __dxlog_file17,
4683
4730
  L: 512,
4684
4731
  S: this,
4685
4732
  C: (f, a) => f(...a)
@@ -4809,7 +4856,7 @@ function _ts_decorate5(decorators, target, key, desc) {
4809
4856
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4810
4857
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4811
4858
  }
4812
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4859
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4813
4860
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
4814
4861
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
4815
4862
  var DEFAULT_SPACE_KEY = "__DEFAULT__";
@@ -4823,7 +4870,10 @@ var DataSpaceManager = class {
4823
4870
  this._echoHost = _echoHost;
4824
4871
  this._invitationsManager = _invitationsManager;
4825
4872
  this._params = _params;
4826
- this._ctx = new import_context14.Context();
4873
+ this._ctx = new import_context14.Context(void 0, {
4874
+ F: __dxlog_file18,
4875
+ L: 104
4876
+ });
4827
4877
  this.updated = new import_async17.Event();
4828
4878
  this._spaces = new import_util10.ComplexMap(import_keys12.PublicKey.hash);
4829
4879
  this._isOpen = false;
@@ -4857,24 +4907,24 @@ var DataSpaceManager = class {
4857
4907
  }
4858
4908
  async open() {
4859
4909
  (0, import_log15.log)("open", void 0, {
4860
- F: __dxlog_file17,
4861
- L: 146,
4910
+ F: __dxlog_file18,
4911
+ L: 156,
4862
4912
  S: this,
4863
4913
  C: (f, a) => f(...a)
4864
4914
  });
4865
4915
  import_log15.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
4866
4916
  id: this._instanceId
4867
4917
  }), {
4868
- F: __dxlog_file17,
4869
- L: 147,
4918
+ F: __dxlog_file18,
4919
+ L: 157,
4870
4920
  S: this,
4871
4921
  C: (f, a) => f(...a)
4872
4922
  });
4873
4923
  (0, import_log15.log)("metadata loaded", {
4874
4924
  spaces: this._metadataStore.spaces.length
4875
4925
  }, {
4876
- F: __dxlog_file17,
4877
- L: 148,
4926
+ F: __dxlog_file18,
4927
+ L: 158,
4878
4928
  S: this,
4879
4929
  C: (f, a) => f(...a)
4880
4930
  });
@@ -4883,8 +4933,8 @@ var DataSpaceManager = class {
4883
4933
  (0, import_log15.log)("load space", {
4884
4934
  spaceMetadata
4885
4935
  }, {
4886
- F: __dxlog_file17,
4887
- L: 152,
4936
+ F: __dxlog_file18,
4937
+ L: 162,
4888
4938
  S: this,
4889
4939
  C: (f, a) => f(...a)
4890
4940
  });
@@ -4894,8 +4944,8 @@ var DataSpaceManager = class {
4894
4944
  spaceMetadata,
4895
4945
  err
4896
4946
  }, {
4897
- F: __dxlog_file17,
4898
- L: 155,
4947
+ F: __dxlog_file18,
4948
+ L: 165,
4899
4949
  S: this,
4900
4950
  C: (f, a) => f(...a)
4901
4951
  });
@@ -4906,16 +4956,16 @@ var DataSpaceManager = class {
4906
4956
  import_log15.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
4907
4957
  id: this._instanceId
4908
4958
  }), {
4909
- F: __dxlog_file17,
4910
- L: 162,
4959
+ F: __dxlog_file18,
4960
+ L: 172,
4911
4961
  S: this,
4912
4962
  C: (f, a) => f(...a)
4913
4963
  });
4914
4964
  }
4915
4965
  async close() {
4916
4966
  (0, import_log15.log)("close", void 0, {
4917
- F: __dxlog_file17,
4918
- L: 167,
4967
+ F: __dxlog_file18,
4968
+ L: 177,
4919
4969
  S: this,
4920
4970
  C: (f, a) => f(...a)
4921
4971
  });
@@ -4931,8 +4981,8 @@ var DataSpaceManager = class {
4931
4981
  */
4932
4982
  async createSpace() {
4933
4983
  (0, import_invariant15.invariant)(this._isOpen, "Not open.", {
4934
- F: __dxlog_file17,
4935
- L: 181,
4984
+ F: __dxlog_file18,
4985
+ L: 191,
4936
4986
  S: this,
4937
4987
  A: [
4938
4988
  "this._isOpen",
@@ -4952,8 +5002,8 @@ var DataSpaceManager = class {
4952
5002
  (0, import_log15.log)("creating space...", {
4953
5003
  spaceKey
4954
5004
  }, {
4955
- F: __dxlog_file17,
4956
- L: 193,
5005
+ F: __dxlog_file18,
5006
+ L: 203,
4957
5007
  S: this,
4958
5008
  C: (f, a) => f(...a)
4959
5009
  });
@@ -4964,8 +5014,8 @@ var DataSpaceManager = class {
4964
5014
  await this._metadataStore.addSpace(metadata);
4965
5015
  const memberCredential = credentials[1];
4966
5016
  (0, import_invariant15.invariant)((0, import_credentials15.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4967
- F: __dxlog_file17,
4968
- L: 203,
5017
+ F: __dxlog_file18,
5018
+ L: 213,
4969
5019
  S: this,
4970
5020
  A: [
4971
5021
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -4996,8 +5046,8 @@ var DataSpaceManager = class {
4996
5046
  version: space.databaseRoot.getVersion(),
4997
5047
  spaceId: space.id
4998
5048
  }, {
4999
- F: __dxlog_file17,
5000
- L: 228,
5049
+ F: __dxlog_file18,
5050
+ L: 238,
5001
5051
  S: this,
5002
5052
  C: (f, a) => f(...a)
5003
5053
  });
@@ -5031,8 +5081,8 @@ var DataSpaceManager = class {
5031
5081
  async _getSpaceRootDocument(space) {
5032
5082
  const automergeIndex = space.automergeSpaceState.rootUrl;
5033
5083
  (0, import_invariant15.invariant)(automergeIndex, void 0, {
5034
- F: __dxlog_file17,
5035
- L: 261,
5084
+ F: __dxlog_file18,
5085
+ L: 271,
5036
5086
  S: this,
5037
5087
  A: [
5038
5088
  "automergeIndex",
@@ -5048,14 +5098,14 @@ var DataSpaceManager = class {
5048
5098
  (0, import_log15.log)("accept space", {
5049
5099
  opts
5050
5100
  }, {
5051
- F: __dxlog_file17,
5052
- L: 270,
5101
+ F: __dxlog_file18,
5102
+ L: 280,
5053
5103
  S: this,
5054
5104
  C: (f, a) => f(...a)
5055
5105
  });
5056
5106
  (0, import_invariant15.invariant)(this._isOpen, "Not open.", {
5057
- F: __dxlog_file17,
5058
- L: 271,
5107
+ F: __dxlog_file18,
5108
+ L: 281,
5059
5109
  S: this,
5060
5110
  A: [
5061
5111
  "this._isOpen",
@@ -5063,8 +5113,8 @@ var DataSpaceManager = class {
5063
5113
  ]
5064
5114
  });
5065
5115
  (0, import_invariant15.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
5066
- F: __dxlog_file17,
5067
- L: 272,
5116
+ F: __dxlog_file18,
5117
+ L: 282,
5068
5118
  S: this,
5069
5119
  A: [
5070
5120
  "!this._spaces.has(opts.spaceKey)",
@@ -5084,6 +5134,43 @@ var DataSpaceManager = class {
5084
5134
  this.updated.emit();
5085
5135
  return space;
5086
5136
  }
5137
+ async admitMember(options) {
5138
+ const space = this._spaceManager.spaces.get(options.spaceKey);
5139
+ (0, import_invariant15.invariant)(space, void 0, {
5140
+ F: __dxlog_file18,
5141
+ L: 302,
5142
+ S: this,
5143
+ A: [
5144
+ "space",
5145
+ ""
5146
+ ]
5147
+ });
5148
+ if (space.spaceState.getMemberRole(options.identityKey) !== import_credentials16.SpaceMember.Role.REMOVED) {
5149
+ throw new import_protocols11.AlreadyJoinedError();
5150
+ }
5151
+ 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);
5152
+ (0, import_invariant15.invariant)(credentials[0].credential, void 0, {
5153
+ F: __dxlog_file18,
5154
+ L: 321,
5155
+ S: this,
5156
+ A: [
5157
+ "credentials[0].credential",
5158
+ ""
5159
+ ]
5160
+ });
5161
+ const spaceMemberCredential = credentials[0].credential.credential;
5162
+ (0, import_invariant15.invariant)((0, import_credentials15.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5163
+ F: __dxlog_file18,
5164
+ L: 323,
5165
+ S: this,
5166
+ A: [
5167
+ "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5168
+ ""
5169
+ ]
5170
+ });
5171
+ await (0, import_feed_store4.writeMessages)(space.controlPipeline.writer, credentials);
5172
+ return spaceMemberCredential;
5173
+ }
5087
5174
  /**
5088
5175
  * Wait until the space data pipeline is fully initialized.
5089
5176
  * Used by invitation handler.
@@ -5095,12 +5182,24 @@ var DataSpaceManager = class {
5095
5182
  return !!space && space.state === import_services14.SpaceState.READY;
5096
5183
  }));
5097
5184
  }
5185
+ async requestSpaceAdmissionCredential(spaceKey) {
5186
+ return this._spaceManager.requestSpaceAdmissionCredential({
5187
+ spaceKey,
5188
+ identityKey: this._signingContext.identityKey,
5189
+ timeout: 15e3,
5190
+ swarmIdentity: {
5191
+ peerKey: this._signingContext.deviceKey,
5192
+ credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5193
+ credentialAuthenticator: async () => true
5194
+ }
5195
+ });
5196
+ }
5098
5197
  async _constructSpace(metadata) {
5099
5198
  (0, import_log15.log)("construct space", {
5100
5199
  metadata
5101
5200
  }, {
5102
- F: __dxlog_file17,
5103
- L: 306,
5201
+ F: __dxlog_file18,
5202
+ L: 358,
5104
5203
  S: this,
5105
5204
  C: (f, a) => f(...a)
5106
5205
  });
@@ -5128,6 +5227,7 @@ var DataSpaceManager = class {
5128
5227
  credentialAuthenticator: (0, import_util10.deferFunction)(() => dataSpace.authVerifier.verifier)
5129
5228
  },
5130
5229
  onAuthorizedConnection: (session) => {
5230
+ session.addExtension("dxos.mesh.teleport.admission-discovery", new import_echo_pipeline5.CredentialServerExtension(space));
5131
5231
  session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5132
5232
  remotePeerId: session.remotePeerId
5133
5233
  }));
@@ -5137,8 +5237,8 @@ var DataSpaceManager = class {
5137
5237
  },
5138
5238
  onAuthFailure: () => {
5139
5239
  import_log15.log.warn("auth failure", void 0, {
5140
- F: __dxlog_file17,
5141
- L: 343,
5240
+ F: __dxlog_file18,
5241
+ L: 396,
5142
5242
  S: this,
5143
5243
  C: (f, a) => f(...a)
5144
5244
  });
@@ -5170,8 +5270,8 @@ var DataSpaceManager = class {
5170
5270
  (0, import_log15.log)("before space ready", {
5171
5271
  space: space.key
5172
5272
  }, {
5173
- F: __dxlog_file17,
5174
- L: 370,
5273
+ F: __dxlog_file18,
5274
+ L: 423,
5175
5275
  S: this,
5176
5276
  C: (f, a) => f(...a)
5177
5277
  });
@@ -5181,8 +5281,8 @@ var DataSpaceManager = class {
5181
5281
  space: space.key,
5182
5282
  open: this._isOpen
5183
5283
  }, {
5184
- F: __dxlog_file17,
5185
- L: 373,
5284
+ F: __dxlog_file18,
5285
+ L: 426,
5186
5286
  S: this,
5187
5287
  C: (f, a) => f(...a)
5188
5288
  });
@@ -5200,8 +5300,8 @@ var DataSpaceManager = class {
5200
5300
  (0, import_log15.log)("before space close", {
5201
5301
  space: space.key
5202
5302
  }, {
5203
- F: __dxlog_file17,
5204
- L: 381,
5303
+ F: __dxlog_file18,
5304
+ L: 434,
5205
5305
  S: this,
5206
5306
  C: (f, a) => f(...a)
5207
5307
  });
@@ -5241,8 +5341,8 @@ var DataSpaceManager = class {
5241
5341
  peersOnline: presence.getPeersOnline().length,
5242
5342
  closedSessions
5243
5343
  }, {
5244
- F: __dxlog_file17,
5245
- L: 417,
5344
+ F: __dxlog_file18,
5345
+ L: 470,
5246
5346
  S: this,
5247
5347
  C: (f, a) => f(...a)
5248
5348
  });
@@ -5256,8 +5356,8 @@ var DataSpaceManager = class {
5256
5356
  (0, import_log15.log)("closing a session with a removed peer", {
5257
5357
  peerId: peerState.peerId
5258
5358
  }, {
5259
- F: __dxlog_file17,
5260
- L: 431,
5359
+ F: __dxlog_file18,
5360
+ L: 484,
5261
5361
  S: this,
5262
5362
  C: (f, a) => f(...a)
5263
5363
  });
@@ -5316,7 +5416,7 @@ _ts_decorate5([
5316
5416
  DataSpaceManager = _ts_decorate5([
5317
5417
  (0, import_async17.trackLeaks)("open", "close")
5318
5418
  ], DataSpaceManager);
5319
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5419
+ var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5320
5420
  var SpacesServiceImpl = class {
5321
5421
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
5322
5422
  this._identityManager = _identityManager;
@@ -5360,8 +5460,8 @@ var SpacesServiceImpl = class {
5360
5460
  }
5361
5461
  const credentials = await (0, import_credentials19.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
5362
5462
  (0, import_invariant16.invariant)(credentials[0].credential, void 0, {
5363
- F: __dxlog_file18,
5364
- L: 98,
5463
+ F: __dxlog_file19,
5464
+ L: 102,
5365
5465
  S: this,
5366
5466
  A: [
5367
5467
  "credentials[0].credential",
@@ -5370,15 +5470,15 @@ var SpacesServiceImpl = class {
5370
5470
  });
5371
5471
  const spaceMemberCredential = credentials[0].credential.credential;
5372
5472
  (0, import_invariant16.invariant)((0, import_credentials19.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5373
- F: __dxlog_file18,
5374
- L: 100,
5473
+ F: __dxlog_file19,
5474
+ L: 104,
5375
5475
  S: this,
5376
5476
  A: [
5377
5477
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5378
5478
  ""
5379
5479
  ]
5380
5480
  });
5381
- await (0, import_feed_store4.writeMessages)(space.controlPipeline.writer, credentials);
5481
+ await (0, import_feed_store5.writeMessages)(space.controlPipeline.writer, credentials);
5382
5482
  }
5383
5483
  querySpaces() {
5384
5484
  return new import_codec_protobuf11.Stream(({ next, ctx }) => {
@@ -5388,8 +5488,8 @@ var SpacesServiceImpl = class {
5388
5488
  (0, import_log16.log)("update", {
5389
5489
  spaces
5390
5490
  }, {
5391
- F: __dxlog_file18,
5392
- L: 111,
5491
+ F: __dxlog_file19,
5492
+ L: 115,
5393
5493
  S: this,
5394
5494
  C: (f, a) => f(...a)
5395
5495
  });
@@ -5407,7 +5507,15 @@ var SpacesServiceImpl = class {
5407
5507
  const subscribeSpaces = () => {
5408
5508
  subscriptions.clear();
5409
5509
  for (const space of dataSpaceManager.spaces.values()) {
5410
- subscriptions.add(space.stateUpdate.on(ctx, () => scheduler.forceTrigger()));
5510
+ let lastState;
5511
+ subscriptions.add(space.stateUpdate.on(ctx, () => {
5512
+ if (space.state !== lastState) {
5513
+ scheduler.forceTrigger();
5514
+ } else {
5515
+ scheduler.trigger();
5516
+ }
5517
+ lastState = space.state;
5518
+ }));
5411
5519
  subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
5412
5520
  subscriptions.add(space.automergeSpaceState.onNewEpoch.on(ctx, () => scheduler.trigger()));
5413
5521
  subscriptions.add(space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger()));
@@ -5472,8 +5580,8 @@ var SpacesServiceImpl = class {
5472
5580
  });
5473
5581
  } else {
5474
5582
  (0, import_invariant16.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
5475
- F: __dxlog_file18,
5476
- L: 199,
5583
+ F: __dxlog_file19,
5584
+ L: 213,
5477
5585
  S: this,
5478
5586
  A: [
5479
5587
  "!credential.id",
@@ -5481,8 +5589,8 @@ var SpacesServiceImpl = class {
5481
5589
  ]
5482
5590
  });
5483
5591
  (0, import_invariant16.invariant)(this._identityManager.identity, "Identity is not available", {
5484
- F: __dxlog_file18,
5485
- L: 200,
5592
+ F: __dxlog_file19,
5593
+ L: 214,
5486
5594
  S: this,
5487
5595
  A: [
5488
5596
  "this._identityManager.identity",
@@ -5491,8 +5599,8 @@ var SpacesServiceImpl = class {
5491
5599
  });
5492
5600
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
5493
5601
  (0, import_invariant16.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
5494
- F: __dxlog_file18,
5495
- L: 202,
5602
+ F: __dxlog_file19,
5603
+ L: 216,
5496
5604
  S: this,
5497
5605
  A: [
5498
5606
  "credential.issuer.equals(signer.getIssuer())",
@@ -5522,6 +5630,59 @@ var SpacesServiceImpl = class {
5522
5630
  epochCredential: credential ?? void 0
5523
5631
  };
5524
5632
  }
5633
+ async admitContact(request) {
5634
+ const dataSpaceManager = await this._getDataSpaceManager();
5635
+ await dataSpaceManager.admitMember({
5636
+ spaceKey: request.spaceKey,
5637
+ identityKey: request.contact.identityKey,
5638
+ role: request.role
5639
+ });
5640
+ }
5641
+ async joinBySpaceKey({ spaceKey }) {
5642
+ const dataSpaceManager = await this._getDataSpaceManager();
5643
+ const credential = await dataSpaceManager.requestSpaceAdmissionCredential(spaceKey);
5644
+ return this._joinByAdmission({
5645
+ credential
5646
+ });
5647
+ }
5648
+ async _joinByAdmission({ credential }) {
5649
+ const assertion = (0, import_credentials19.getCredentialAssertion)(credential);
5650
+ (0, import_invariant16.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
5651
+ F: __dxlog_file19,
5652
+ L: 250,
5653
+ S: this,
5654
+ A: [
5655
+ "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
5656
+ "'Invalid credential'"
5657
+ ]
5658
+ });
5659
+ const myIdentity = this._identityManager.identity;
5660
+ (0, import_invariant16.invariant)(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
5661
+ F: __dxlog_file19,
5662
+ L: 252,
5663
+ S: this,
5664
+ A: [
5665
+ "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
5666
+ ""
5667
+ ]
5668
+ });
5669
+ const dataSpaceManager = await this._getDataSpaceManager();
5670
+ let dataSpace = dataSpaceManager.spaces.get(assertion.spaceKey);
5671
+ if (!dataSpace) {
5672
+ dataSpace = await dataSpaceManager.acceptSpace({
5673
+ spaceKey: assertion.spaceKey,
5674
+ genesisFeedKey: assertion.genesisFeedKey
5675
+ });
5676
+ await myIdentity.controlPipeline.writer.write({
5677
+ credential: {
5678
+ credential
5679
+ }
5680
+ });
5681
+ }
5682
+ return {
5683
+ space: this._serializeSpace(dataSpace)
5684
+ };
5685
+ }
5525
5686
  _serializeSpace(space) {
5526
5687
  return {
5527
5688
  id: space.id,
@@ -5591,7 +5752,7 @@ function _ts_decorate6(decorators, target, key, desc) {
5591
5752
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5592
5753
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5593
5754
  }
5594
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5755
+ var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5595
5756
  var ServiceContext = class extends import_context15.Resource {
5596
5757
  constructor(storage, level, networkManager, signalManager, _runtimeParams) {
5597
5758
  super();
@@ -5603,21 +5764,21 @@ var ServiceContext = class extends import_context15.Resource {
5603
5764
  this.initialized = new import_async19.Trigger();
5604
5765
  this._handlerFactories = /* @__PURE__ */ new Map();
5605
5766
  this._instanceId = import_keys13.PublicKey.random().toHex();
5606
- this.metadataStore = new import_echo_pipeline5.MetadataStore(storage.createDirectory("metadata"));
5607
- this.snapshotStore = new import_echo_pipeline5.SnapshotStore(storage.createDirectory("snapshots"));
5767
+ this.metadataStore = new import_echo_pipeline6.MetadataStore(storage.createDirectory("metadata"));
5768
+ this.snapshotStore = new import_echo_pipeline6.SnapshotStore(storage.createDirectory("snapshots"));
5608
5769
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
5609
5770
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
5610
- this.feedStore = new import_feed_store5.FeedStore({
5611
- factory: new import_feed_store5.FeedFactory({
5771
+ this.feedStore = new import_feed_store6.FeedStore({
5772
+ factory: new import_feed_store6.FeedFactory({
5612
5773
  root: storage.createDirectory("feeds"),
5613
5774
  signer: this.keyring,
5614
5775
  hypercore: {
5615
- valueEncoding: import_echo_pipeline5.valueEncoding,
5776
+ valueEncoding: import_echo_pipeline6.valueEncoding,
5616
5777
  stats: true
5617
5778
  }
5618
5779
  })
5619
5780
  });
5620
- this.spaceManager = new import_echo_pipeline5.SpaceManager({
5781
+ this.spaceManager = new import_echo_pipeline6.SpaceManager({
5621
5782
  feedStore: this.feedStore,
5622
5783
  networkManager: this.networkManager,
5623
5784
  blobStore: this.blobStore,
@@ -5635,7 +5796,7 @@ var ServiceContext = class extends import_context15.Resource {
5635
5796
  async _open(ctx) {
5636
5797
  await this._checkStorageVersion();
5637
5798
  (0, import_log17.log)("opening...", void 0, {
5638
- F: __dxlog_file19,
5799
+ F: __dxlog_file20,
5639
5800
  L: 149,
5640
5801
  S: this,
5641
5802
  C: (f, a) => f(...a)
@@ -5643,7 +5804,7 @@ var ServiceContext = class extends import_context15.Resource {
5643
5804
  import_log17.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
5644
5805
  id: this._instanceId
5645
5806
  }), {
5646
- F: __dxlog_file19,
5807
+ F: __dxlog_file20,
5647
5808
  L: 150,
5648
5809
  S: this,
5649
5810
  C: (f, a) => f(...a)
@@ -5661,7 +5822,7 @@ var ServiceContext = class extends import_context15.Resource {
5661
5822
  (0, import_log17.log)("loaded persistent invitations", {
5662
5823
  count: loadedInvitations.invitations?.length
5663
5824
  }, {
5664
- F: __dxlog_file19,
5825
+ F: __dxlog_file20,
5665
5826
  L: 163,
5666
5827
  S: this,
5667
5828
  C: (f, a) => f(...a)
@@ -5669,13 +5830,13 @@ var ServiceContext = class extends import_context15.Resource {
5669
5830
  import_log17.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
5670
5831
  id: this._instanceId
5671
5832
  }), {
5672
- F: __dxlog_file19,
5833
+ F: __dxlog_file20,
5673
5834
  L: 165,
5674
5835
  S: this,
5675
5836
  C: (f, a) => f(...a)
5676
5837
  });
5677
5838
  (0, import_log17.log)("opened", void 0, {
5678
- F: __dxlog_file19,
5839
+ F: __dxlog_file20,
5679
5840
  L: 166,
5680
5841
  S: this,
5681
5842
  C: (f, a) => f(...a)
@@ -5683,7 +5844,7 @@ var ServiceContext = class extends import_context15.Resource {
5683
5844
  }
5684
5845
  async _close(ctx) {
5685
5846
  (0, import_log17.log)("closing...", void 0, {
5686
- F: __dxlog_file19,
5847
+ F: __dxlog_file20,
5687
5848
  L: 170,
5688
5849
  S: this,
5689
5850
  C: (f, a) => f(...a)
@@ -5700,7 +5861,7 @@ var ServiceContext = class extends import_context15.Resource {
5700
5861
  await this.networkManager.close();
5701
5862
  await this.signalManager.close();
5702
5863
  (0, import_log17.log)("closed", void 0, {
5703
- F: __dxlog_file19,
5864
+ F: __dxlog_file20,
5704
5865
  L: 182,
5705
5866
  S: this,
5706
5867
  C: (f, a) => f(...a)
@@ -5708,13 +5869,16 @@ var ServiceContext = class extends import_context15.Resource {
5708
5869
  }
5709
5870
  async createIdentity(params = {}) {
5710
5871
  const identity = await this.identityManager.createIdentity(params);
5711
- await this._initialize(new import_context15.Context());
5872
+ await this._initialize(new import_context15.Context(void 0, {
5873
+ F: __dxlog_file20,
5874
+ L: 187
5875
+ }));
5712
5876
  return identity;
5713
5877
  }
5714
5878
  getInvitationHandler(invitation) {
5715
5879
  const factory = this._handlerFactories.get(invitation.kind);
5716
5880
  (0, import_invariant17.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
5717
- F: __dxlog_file19,
5881
+ F: __dxlog_file20,
5718
5882
  L: 193,
5719
5883
  S: this,
5720
5884
  A: [
@@ -5734,7 +5898,10 @@ var ServiceContext = class extends import_context15.Resource {
5734
5898
  }
5735
5899
  async _acceptIdentity(params) {
5736
5900
  const identity = await this.identityManager.acceptIdentity(params);
5737
- await this._initialize(new import_context15.Context());
5901
+ await this._initialize(new import_context15.Context(void 0, {
5902
+ F: __dxlog_file20,
5903
+ L: 209
5904
+ }));
5738
5905
  return identity;
5739
5906
  }
5740
5907
  async _checkStorageVersion() {
@@ -5746,7 +5913,7 @@ var ServiceContext = class extends import_context15.Resource {
5746
5913
  // Called when identity is created.
5747
5914
  async _initialize(ctx) {
5748
5915
  (0, import_log17.log)("initializing spaces...", void 0, {
5749
- F: __dxlog_file19,
5916
+ F: __dxlog_file20,
5750
5917
  L: 224,
5751
5918
  S: this,
5752
5919
  C: (f, a) => f(...a)
@@ -5769,7 +5936,7 @@ var ServiceContext = class extends import_context15.Resource {
5769
5936
  await this.dataSpaceManager.open();
5770
5937
  this._handlerFactories.set(import_services16.Invitation.Kind.SPACE, (invitation) => {
5771
5938
  (0, import_invariant17.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
5772
- F: __dxlog_file19,
5939
+ F: __dxlog_file20,
5773
5940
  L: 249,
5774
5941
  S: this,
5775
5942
  A: [
@@ -5793,7 +5960,7 @@ var ServiceContext = class extends import_context15.Resource {
5793
5960
  (0, import_log17.log)("dataSpaceManager not initialized yet, ignoring space admission", {
5794
5961
  details: assertion
5795
5962
  }, {
5796
- F: __dxlog_file19,
5963
+ F: __dxlog_file20,
5797
5964
  L: 265,
5798
5965
  S: this,
5799
5966
  C: (f, a) => f(...a)
@@ -5804,7 +5971,7 @@ var ServiceContext = class extends import_context15.Resource {
5804
5971
  (0, import_log17.log)("space already exists, ignoring space admission", {
5805
5972
  details: assertion
5806
5973
  }, {
5807
- F: __dxlog_file19,
5974
+ F: __dxlog_file20,
5808
5975
  L: 269,
5809
5976
  S: this,
5810
5977
  C: (f, a) => f(...a)
@@ -5815,7 +5982,7 @@ var ServiceContext = class extends import_context15.Resource {
5815
5982
  (0, import_log17.log)("accepting space recorded in halo", {
5816
5983
  details: assertion
5817
5984
  }, {
5818
- F: __dxlog_file19,
5985
+ F: __dxlog_file20,
5819
5986
  L: 274,
5820
5987
  S: this,
5821
5988
  C: (f, a) => f(...a)
@@ -5826,7 +5993,7 @@ var ServiceContext = class extends import_context15.Resource {
5826
5993
  });
5827
5994
  } catch (err) {
5828
5995
  import_log17.log.catch(err, void 0, {
5829
- F: __dxlog_file19,
5996
+ F: __dxlog_file20,
5830
5997
  L: 280,
5831
5998
  S: this,
5832
5999
  C: (f, a) => f(...a)
@@ -5879,7 +6046,7 @@ function _ts_decorate7(decorators, target, key, desc) {
5879
6046
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5880
6047
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5881
6048
  }
5882
- var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
6049
+ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
5883
6050
  var Lock = class {
5884
6051
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
5885
6052
  this._lockPath = lockPath;
@@ -5891,7 +6058,7 @@ var Lock = class {
5891
6058
  }
5892
6059
  async acquire() {
5893
6060
  (0, import_log18.log)("acquiring lock...", void 0, {
5894
- F: __dxlog_file20,
6061
+ F: __dxlog_file21,
5895
6062
  L: 32,
5896
6063
  S: this,
5897
6064
  C: (f, a) => f(...a)
@@ -5899,7 +6066,7 @@ var Lock = class {
5899
6066
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
5900
6067
  await this._onAcquire?.();
5901
6068
  (0, import_log18.log)("acquired lock", void 0, {
5902
- F: __dxlog_file20,
6069
+ F: __dxlog_file21,
5903
6070
  L: 37,
5904
6071
  S: this,
5905
6072
  C: (f, a) => f(...a)
@@ -5908,7 +6075,7 @@ var Lock = class {
5908
6075
  async release() {
5909
6076
  await this._onRelease?.();
5910
6077
  (0, import_invariant18.invariant)(this._fileHandle, "Lock is not acquired", {
5911
- F: __dxlog_file20,
6078
+ F: __dxlog_file21,
5912
6079
  L: 42,
5913
6080
  S: this,
5914
6081
  A: [
@@ -5980,7 +6147,138 @@ var createLevel = async (config) => {
5980
6147
  await level.open();
5981
6148
  return level;
5982
6149
  };
5983
- var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
6150
+ var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
6151
+ var encodeProfileArchive = (profile) => import_automerge_repo.cbor.encode(profile);
6152
+ var decodeProfileArchive = (data) => import_automerge_repo.cbor.decode(data);
6153
+ var exportProfileData = async ({ storage, level }) => {
6154
+ const archive = {
6155
+ storage: [],
6156
+ meta: {
6157
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
6158
+ }
6159
+ };
6160
+ {
6161
+ const directory = await storage.createDirectory();
6162
+ const files = await directory.list();
6163
+ import_log19.log.info("begin exporting files", {
6164
+ count: files.length
6165
+ }, {
6166
+ F: __dxlog_file22,
6167
+ L: 30,
6168
+ S: void 0,
6169
+ C: (f, a) => f(...a)
6170
+ });
6171
+ for (const filename of files) {
6172
+ const file = await directory.getOrCreateFile(filename);
6173
+ const { size } = await file.stat();
6174
+ const data = await file.read(0, size);
6175
+ archive.storage.push({
6176
+ type: import_protocols15.ProfileArchiveEntryType.FILE,
6177
+ key: filename,
6178
+ value: data
6179
+ });
6180
+ }
6181
+ import_log19.log.info("done exporting files", {
6182
+ count: files.length
6183
+ }, {
6184
+ F: __dxlog_file22,
6185
+ L: 41,
6186
+ S: void 0,
6187
+ C: (f, a) => f(...a)
6188
+ });
6189
+ }
6190
+ {
6191
+ import_log19.log.info("begin exporting kv pairs", void 0, {
6192
+ F: __dxlog_file22,
6193
+ L: 45,
6194
+ S: void 0,
6195
+ C: (f, a) => f(...a)
6196
+ });
6197
+ const iter = await level.iterator({
6198
+ keyEncoding: "binary",
6199
+ valueEncoding: "binary"
6200
+ });
6201
+ let count = 0;
6202
+ for await (const [key, value] of iter) {
6203
+ archive.storage.push({
6204
+ type: import_protocols15.ProfileArchiveEntryType.KEY_VALUE,
6205
+ key,
6206
+ value
6207
+ });
6208
+ count++;
6209
+ }
6210
+ import_log19.log.info("done exporting kv pairs", {
6211
+ count
6212
+ }, {
6213
+ F: __dxlog_file22,
6214
+ L: 56,
6215
+ S: void 0,
6216
+ C: (f, a) => f(...a)
6217
+ });
6218
+ }
6219
+ return archive;
6220
+ };
6221
+ var importProfileData = async ({ storage, level }, archive) => {
6222
+ const batch = level.batch();
6223
+ for (const entry2 of archive.storage) {
6224
+ switch (entry2.type) {
6225
+ case import_protocols15.ProfileArchiveEntryType.FILE: {
6226
+ const directory = await storage.createDirectory();
6227
+ (0, import_invariant19.invariant)(typeof entry2.key === "string", "Invalid key type", {
6228
+ F: __dxlog_file22,
6229
+ L: 78,
6230
+ S: void 0,
6231
+ A: [
6232
+ "typeof entry.key === 'string'",
6233
+ "'Invalid key type'"
6234
+ ]
6235
+ });
6236
+ const file = await directory.getOrCreateFile(entry2.key);
6237
+ (0, import_invariant19.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
6238
+ F: __dxlog_file22,
6239
+ L: 80,
6240
+ S: void 0,
6241
+ A: [
6242
+ "entry.value instanceof Uint8Array",
6243
+ "'Invalid value type'"
6244
+ ]
6245
+ });
6246
+ await file.write(0, (0, import_util13.arrayToBuffer)(entry2.value));
6247
+ await file.close();
6248
+ break;
6249
+ }
6250
+ case import_protocols15.ProfileArchiveEntryType.KEY_VALUE: {
6251
+ (0, import_invariant19.invariant)(entry2.key instanceof Uint8Array, "Invalid key type", {
6252
+ F: __dxlog_file22,
6253
+ L: 86,
6254
+ S: void 0,
6255
+ A: [
6256
+ "entry.key instanceof Uint8Array",
6257
+ "'Invalid key type'"
6258
+ ]
6259
+ });
6260
+ (0, import_invariant19.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
6261
+ F: __dxlog_file22,
6262
+ L: 87,
6263
+ S: void 0,
6264
+ A: [
6265
+ "entry.value instanceof Uint8Array",
6266
+ "'Invalid value type'"
6267
+ ]
6268
+ });
6269
+ batch.put(entry2.key, entry2.value, {
6270
+ keyEncoding: "binary",
6271
+ valueEncoding: "binary"
6272
+ });
6273
+ break;
6274
+ }
6275
+ default:
6276
+ throw new Error(`Invalid entry type: ${entry2.type}`);
6277
+ }
6278
+ }
6279
+ await batch.write();
6280
+ };
6281
+ var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
5984
6282
  var DevicesServiceImpl = class {
5985
6283
  constructor(_identityManager) {
5986
6284
  this._identityManager = _identityManager;
@@ -5997,8 +6295,8 @@ var DevicesServiceImpl = class {
5997
6295
  devices: []
5998
6296
  });
5999
6297
  } else {
6000
- (0, import_invariant20.invariant)(this._identityManager.identity?.presence, "presence not present", {
6001
- F: __dxlog_file21,
6298
+ (0, import_invariant21.invariant)(this._identityManager.identity?.presence, "presence not present", {
6299
+ F: __dxlog_file23,
6002
6300
  L: 32,
6003
6301
  S: this,
6004
6302
  A: [
@@ -6079,7 +6377,7 @@ var DiagnosticsCollector = class {
6079
6377
  client: clientDiagnostics,
6080
6378
  broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
6081
6379
  };
6082
- return JSON.parse(JSON.stringify(diagnostics, (0, import_util13.jsonKeyReplacer)(options)));
6380
+ return JSON.parse(JSON.stringify(diagnostics, (0, import_util14.jsonKeyReplacer)(options)));
6083
6381
  }
6084
6382
  };
6085
6383
  var findSystemServiceProvider = () => {
@@ -6089,35 +6387,112 @@ var findSystemServiceProvider = () => {
6089
6387
  };
6090
6388
  var findConfigs = () => {
6091
6389
  const configs = import_tracing10.TRACE_PROCESSOR.findResourcesByAnnotation(import_config3.ConfigResource);
6092
- return configs.map((r) => r.instance.deref()).filter(import_util13.nonNullable);
6390
+ return configs.map((r) => r.instance.deref()).filter(import_util14.nonNullable);
6391
+ };
6392
+ var ContactsServiceImpl = class {
6393
+ constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
6394
+ this._identityManager = _identityManager;
6395
+ this._spaceManager = _spaceManager;
6396
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
6397
+ }
6398
+ async getContacts() {
6399
+ const identity = this._identityManager.identity;
6400
+ if (identity == null) {
6401
+ return {
6402
+ contacts: []
6403
+ };
6404
+ }
6405
+ const contacts = [
6406
+ ...this._spaceManager.spaces.values()
6407
+ ].flatMap((s) => [
6408
+ ...s.spaceState.members.values()
6409
+ ].map((m) => [
6410
+ s.key,
6411
+ m
6412
+ ])).reduce((acc, v) => {
6413
+ const [spaceKey, memberInfo] = v;
6414
+ if (memberInfo.key.equals(identity.identityKey)) {
6415
+ return acc;
6416
+ }
6417
+ const existing = acc.get(memberInfo.key);
6418
+ if (existing != null) {
6419
+ existing.profile ??= memberInfo.profile;
6420
+ existing.commonSpaces?.push(spaceKey);
6421
+ } else {
6422
+ acc.set(memberInfo.key, {
6423
+ identityKey: memberInfo.key,
6424
+ profile: memberInfo.profile,
6425
+ commonSpaces: [
6426
+ spaceKey
6427
+ ]
6428
+ });
6429
+ }
6430
+ return acc;
6431
+ }, new import_util16.ComplexMap(import_keys17.PublicKey.hash));
6432
+ return {
6433
+ contacts: [
6434
+ ...contacts.values()
6435
+ ]
6436
+ };
6437
+ }
6438
+ queryContacts() {
6439
+ const subscribedSpaceKeySet = new import_util16.ComplexSet(import_keys17.PublicKey.hash);
6440
+ return new import_codec_protobuf13.Stream(({ next, ctx }) => {
6441
+ const pushUpdateTask = new import_async22.UpdateScheduler(ctx, async () => {
6442
+ const contacts = await this.getContacts();
6443
+ next(contacts);
6444
+ }, {
6445
+ maxFrequency: 2
6446
+ });
6447
+ (0, import_async22.scheduleTask)(ctx, async () => {
6448
+ const subscriptions = new import_async22.EventSubscriptions();
6449
+ ctx.onDispose(() => subscriptions.clear());
6450
+ const subscribeToSpaceAndUpdate = () => {
6451
+ const oldSetSize = subscribedSpaceKeySet.size;
6452
+ for (const space of this._spaceManager.spaces.values()) {
6453
+ if (!subscribedSpaceKeySet.has(space.key)) {
6454
+ subscriptions.add(space.stateUpdate.on(ctx, () => pushUpdateTask.trigger()));
6455
+ subscribedSpaceKeySet.add(space.key);
6456
+ }
6457
+ }
6458
+ if (oldSetSize !== subscribedSpaceKeySet.size) {
6459
+ pushUpdateTask.trigger();
6460
+ }
6461
+ };
6462
+ const unsubscribe = (await this._dataSpaceManagerProvider()).updated.on(ctx, subscribeToSpaceAndUpdate);
6463
+ ctx.onDispose(unsubscribe);
6464
+ subscribeToSpaceAndUpdate();
6465
+ });
6466
+ });
6467
+ }
6093
6468
  };
6094
6469
  var LoggingServiceImpl = class {
6095
6470
  constructor() {
6096
- this._logs = new import_async22.Event();
6471
+ this._logs = new import_async23.Event();
6097
6472
  this._started = Date.now();
6098
- this._sessionId = import_keys17.PublicKey.random().toHex();
6473
+ this._sessionId = import_keys18.PublicKey.random().toHex();
6099
6474
  this._logProcessor = (_config, entry2) => {
6100
6475
  this._logs.emit(entry2);
6101
6476
  };
6102
6477
  }
6103
6478
  async open() {
6104
- import_log20.log.runtimeConfig.processors.push(this._logProcessor);
6479
+ import_log21.log.runtimeConfig.processors.push(this._logProcessor);
6105
6480
  }
6106
6481
  async close() {
6107
- const index = import_log20.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6108
- import_log20.log.runtimeConfig.processors.splice(index, 1);
6482
+ const index = import_log21.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6483
+ import_log21.log.runtimeConfig.processors.splice(index, 1);
6109
6484
  }
6110
6485
  async controlMetrics({ reset, record }) {
6111
6486
  if (reset) {
6112
- import_util15.tracer.clear();
6487
+ import_util17.tracer.clear();
6113
6488
  }
6114
6489
  if (record === true) {
6115
- import_util15.tracer.start();
6490
+ import_util17.tracer.start();
6116
6491
  } else if (record === false) {
6117
- import_util15.tracer.stop();
6492
+ import_util17.tracer.stop();
6118
6493
  }
6119
6494
  return {
6120
- recording: import_util15.tracer.recording
6495
+ recording: import_util17.tracer.recording
6121
6496
  };
6122
6497
  }
6123
6498
  /**
@@ -6125,13 +6500,13 @@ var LoggingServiceImpl = class {
6125
6500
  */
6126
6501
  queryMetrics({ interval = 5e3 }) {
6127
6502
  const getNumericalValues = (key) => {
6128
- const events = import_util15.tracer.get(key) ?? [];
6503
+ const events = import_util17.tracer.get(key) ?? [];
6129
6504
  return {
6130
6505
  key,
6131
- stats: (0, import_util15.numericalValues)(events, "duration")
6506
+ stats: (0, import_util17.numericalValues)(events, "duration")
6132
6507
  };
6133
6508
  };
6134
- return new import_codec_protobuf13.Stream(({ next }) => {
6509
+ return new import_codec_protobuf14.Stream(({ next }) => {
6135
6510
  const update = () => {
6136
6511
  const metrics = {
6137
6512
  timestamp: /* @__PURE__ */ new Date(),
@@ -6153,7 +6528,7 @@ var LoggingServiceImpl = class {
6153
6528
  });
6154
6529
  }
6155
6530
  queryLogs(request) {
6156
- return new import_codec_protobuf13.Stream(({ ctx, next }) => {
6531
+ return new import_codec_protobuf14.Stream(({ ctx, next }) => {
6157
6532
  const handler = (entry2) => {
6158
6533
  if (LOG_PROCESSING > 0) {
6159
6534
  return;
@@ -6166,7 +6541,7 @@ var LoggingServiceImpl = class {
6166
6541
  }
6167
6542
  const record = {
6168
6543
  ...entry2,
6169
- context: (0, import_util15.jsonify)((0, import_log20.getContextFromEntry)(entry2)),
6544
+ context: (0, import_util17.jsonify)((0, import_log21.getContextFromEntry)(entry2)),
6170
6545
  timestamp: /* @__PURE__ */ new Date(),
6171
6546
  meta: {
6172
6547
  // TODO(dmaretskyi): Fix proto.
@@ -6175,7 +6550,7 @@ var LoggingServiceImpl = class {
6175
6550
  scope: {
6176
6551
  hostSessionId: this._sessionId,
6177
6552
  uptimeSeconds: (Date.now() - this._started) / 1e3,
6178
- name: (0, import_util15.getDebugName)(entry2.meta?.S)
6553
+ name: (0, import_util17.getDebugName)(entry2.meta?.S)
6179
6554
  }
6180
6555
  }
6181
6556
  };
@@ -6213,7 +6588,7 @@ var NetworkServiceImpl = class {
6213
6588
  this.signalManager = signalManager;
6214
6589
  }
6215
6590
  queryStatus() {
6216
- return new import_codec_protobuf14.Stream(({ next }) => {
6591
+ return new import_codec_protobuf15.Stream(({ next }) => {
6217
6592
  const update = () => {
6218
6593
  next({
6219
6594
  swarm: this.networkManager.connectionState,
@@ -6256,7 +6631,7 @@ var SystemServiceImpl = class {
6256
6631
  const diagnostics = await this._getDiagnostics();
6257
6632
  return {
6258
6633
  timestamp: /* @__PURE__ */ new Date(),
6259
- diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util16.jsonKeyReplacer)({
6634
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util18.jsonKeyReplacer)({
6260
6635
  truncate: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
6261
6636
  humanize: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
6262
6637
  })))
@@ -6270,7 +6645,7 @@ var SystemServiceImpl = class {
6270
6645
  }
6271
6646
  // TODO(burdon): Standardize interval option in stream request?
6272
6647
  queryStatus({ interval = 3e3 } = {}) {
6273
- return new import_codec_protobuf15.Stream(({ next }) => {
6648
+ return new import_codec_protobuf16.Stream(({ next }) => {
6274
6649
  const update = () => {
6275
6650
  next({
6276
6651
  status: this._getCurrentStatus()
@@ -6299,7 +6674,7 @@ function _ts_decorate8(decorators, target, key, desc) {
6299
6674
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6300
6675
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6301
6676
  }
6302
- var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6677
+ var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6303
6678
  var ClientServicesHost = class {
6304
6679
  constructor({
6305
6680
  config,
@@ -6332,7 +6707,10 @@ var ClientServicesHost = class {
6332
6707
  lockKey,
6333
6708
  onAcquire: () => {
6334
6709
  if (!this._opening) {
6335
- void this.open(new import_context16.Context());
6710
+ void this.open(new import_context16.Context(void 0, {
6711
+ F: __dxlog_file24,
6712
+ L: 121
6713
+ }));
6336
6714
  }
6337
6715
  },
6338
6716
  onRelease: () => this.close()
@@ -6387,25 +6765,25 @@ var ClientServicesHost = class {
6387
6765
  * Can only be called once.
6388
6766
  */
6389
6767
  initialize({ config, ...options }) {
6390
- (0, import_invariant19.invariant)(!this._open, "service host is open", {
6391
- F: __dxlog_file22,
6392
- L: 186,
6768
+ (0, import_invariant20.invariant)(!this._open, "service host is open", {
6769
+ F: __dxlog_file24,
6770
+ L: 187,
6393
6771
  S: this,
6394
6772
  A: [
6395
6773
  "!this._open",
6396
6774
  "'service host is open'"
6397
6775
  ]
6398
6776
  });
6399
- (0, import_log19.log)("initializing...", void 0, {
6400
- F: __dxlog_file22,
6401
- L: 187,
6777
+ (0, import_log20.log)("initializing...", void 0, {
6778
+ F: __dxlog_file24,
6779
+ L: 188,
6402
6780
  S: this,
6403
6781
  C: (f, a) => f(...a)
6404
6782
  });
6405
6783
  if (config) {
6406
- (0, import_invariant19.invariant)(!this._config, "config already set", {
6407
- F: __dxlog_file22,
6408
- L: 190,
6784
+ (0, import_invariant20.invariant)(!this._config, "config already set", {
6785
+ F: __dxlog_file24,
6786
+ L: 191,
6409
6787
  S: this,
6410
6788
  A: [
6411
6789
  "!this._config",
@@ -6418,9 +6796,9 @@ var ClientServicesHost = class {
6418
6796
  }
6419
6797
  }
6420
6798
  if (!options.signalManager) {
6421
- import_log19.log.warn("running signaling without telemetry metadata.", void 0, {
6422
- F: __dxlog_file22,
6423
- L: 198,
6799
+ import_log20.log.warn("running signaling without telemetry metadata.", void 0, {
6800
+ F: __dxlog_file24,
6801
+ L: 199,
6424
6802
  S: this,
6425
6803
  C: (f, a) => f(...a)
6426
6804
  });
@@ -6429,9 +6807,9 @@ var ClientServicesHost = class {
6429
6807
  iceServers: this._config?.get("runtime.services.ice")
6430
6808
  }), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
6431
6809
  this._signalManager = signalManager;
6432
- (0, import_invariant19.invariant)(!this._networkManager, "network manager already set", {
6433
- F: __dxlog_file22,
6434
- L: 209,
6810
+ (0, import_invariant20.invariant)(!this._networkManager, "network manager already set", {
6811
+ F: __dxlog_file24,
6812
+ L: 210,
6435
6813
  S: this,
6436
6814
  A: [
6437
6815
  "!this._networkManager",
@@ -6443,9 +6821,9 @@ var ClientServicesHost = class {
6443
6821
  transportFactory,
6444
6822
  signalManager
6445
6823
  });
6446
- (0, import_log19.log)("initialized", void 0, {
6447
- F: __dxlog_file22,
6448
- L: 216,
6824
+ (0, import_log20.log)("initialized", void 0, {
6825
+ F: __dxlog_file24,
6826
+ L: 217,
6449
6827
  S: this,
6450
6828
  C: (f, a) => f(...a)
6451
6829
  });
@@ -6455,44 +6833,44 @@ var ClientServicesHost = class {
6455
6833
  return;
6456
6834
  }
6457
6835
  const traceId = import_keys15.PublicKey.random().toHex();
6458
- import_log19.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
6836
+ import_log20.log.trace("dxos.client-services.host.open", import_protocols16.trace.begin({
6459
6837
  id: traceId
6460
6838
  }), {
6461
- F: __dxlog_file22,
6462
- L: 227,
6839
+ F: __dxlog_file24,
6840
+ L: 228,
6463
6841
  S: this,
6464
6842
  C: (f, a) => f(...a)
6465
6843
  });
6466
- (0, import_invariant19.invariant)(this._config, "config not set", {
6467
- F: __dxlog_file22,
6468
- L: 229,
6844
+ (0, import_invariant20.invariant)(this._config, "config not set", {
6845
+ F: __dxlog_file24,
6846
+ L: 230,
6469
6847
  S: this,
6470
6848
  A: [
6471
6849
  "this._config",
6472
6850
  "'config not set'"
6473
6851
  ]
6474
6852
  });
6475
- (0, import_invariant19.invariant)(this._storage, "storage not set", {
6476
- F: __dxlog_file22,
6477
- L: 230,
6853
+ (0, import_invariant20.invariant)(this._storage, "storage not set", {
6854
+ F: __dxlog_file24,
6855
+ L: 231,
6478
6856
  S: this,
6479
6857
  A: [
6480
6858
  "this._storage",
6481
6859
  "'storage not set'"
6482
6860
  ]
6483
6861
  });
6484
- (0, import_invariant19.invariant)(this._signalManager, "signal manager not set", {
6485
- F: __dxlog_file22,
6486
- L: 231,
6862
+ (0, import_invariant20.invariant)(this._signalManager, "signal manager not set", {
6863
+ F: __dxlog_file24,
6864
+ L: 232,
6487
6865
  S: this,
6488
6866
  A: [
6489
6867
  "this._signalManager",
6490
6868
  "'signal manager not set'"
6491
6869
  ]
6492
6870
  });
6493
- (0, import_invariant19.invariant)(this._networkManager, "network manager not set", {
6494
- F: __dxlog_file22,
6495
- L: 232,
6871
+ (0, import_invariant20.invariant)(this._networkManager, "network manager not set", {
6872
+ F: __dxlog_file24,
6873
+ L: 233,
6496
6874
  S: this,
6497
6875
  A: [
6498
6876
  "this._networkManager",
@@ -6500,11 +6878,11 @@ var ClientServicesHost = class {
6500
6878
  ]
6501
6879
  });
6502
6880
  this._opening = true;
6503
- (0, import_log19.log)("opening...", {
6881
+ (0, import_log20.log)("opening...", {
6504
6882
  lockKey: this._resourceLock?.lockKey
6505
6883
  }, {
6506
- F: __dxlog_file22,
6507
- L: 235,
6884
+ F: __dxlog_file24,
6885
+ L: 236,
6508
6886
  S: this,
6509
6887
  C: (f, a) => f(...a)
6510
6888
  });
@@ -6515,16 +6893,18 @@ var ClientServicesHost = class {
6515
6893
  await this._level.open();
6516
6894
  await this._loggingService.open();
6517
6895
  this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
6896
+ const dataSpaceManagerProvider = async () => {
6897
+ await this._serviceContext.initialized.wait();
6898
+ return this._serviceContext.dataSpaceManager;
6899
+ };
6518
6900
  const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
6519
6901
  this._serviceRegistry.setServices({
6520
6902
  SystemService: this._systemService,
6521
6903
  IdentityService: identityService,
6904
+ ContactsService: new ContactsServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6522
6905
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
6523
6906
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
6524
- SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
6525
- await this._serviceContext.initialized.wait();
6526
- return this._serviceContext.dataSpaceManager;
6527
- }),
6907
+ SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6528
6908
  DataService: this._serviceContext.echoHost.dataService,
6529
6909
  QueryService: this._serviceContext.echoHost.queryService,
6530
6910
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
@@ -6554,19 +6934,19 @@ var ClientServicesHost = class {
6554
6934
  this._open = true;
6555
6935
  this._statusUpdate.emit();
6556
6936
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6557
- (0, import_log19.log)("opened", {
6937
+ (0, import_log20.log)("opened", {
6558
6938
  deviceKey
6559
6939
  }, {
6560
- F: __dxlog_file22,
6561
- L: 314,
6940
+ F: __dxlog_file24,
6941
+ L: 322,
6562
6942
  S: this,
6563
6943
  C: (f, a) => f(...a)
6564
6944
  });
6565
- import_log19.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
6945
+ import_log20.log.trace("dxos.client-services.host.open", import_protocols16.trace.end({
6566
6946
  id: traceId
6567
6947
  }), {
6568
- F: __dxlog_file22,
6569
- L: 315,
6948
+ F: __dxlog_file24,
6949
+ L: 323,
6570
6950
  S: this,
6571
6951
  C: (f, a) => f(...a)
6572
6952
  });
@@ -6576,11 +6956,11 @@ var ClientServicesHost = class {
6576
6956
  return;
6577
6957
  }
6578
6958
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6579
- (0, import_log19.log)("closing...", {
6959
+ (0, import_log20.log)("closing...", {
6580
6960
  deviceKey
6581
6961
  }, {
6582
- F: __dxlog_file22,
6583
- L: 326,
6962
+ F: __dxlog_file24,
6963
+ L: 334,
6584
6964
  S: this,
6585
6965
  C: (f, a) => f(...a)
6586
6966
  });
@@ -6594,44 +6974,44 @@ var ClientServicesHost = class {
6594
6974
  await this._level?.close();
6595
6975
  this._open = false;
6596
6976
  this._statusUpdate.emit();
6597
- (0, import_log19.log)("closed", {
6977
+ (0, import_log20.log)("closed", {
6598
6978
  deviceKey
6599
6979
  }, {
6600
- F: __dxlog_file22,
6601
- L: 335,
6980
+ F: __dxlog_file24,
6981
+ L: 343,
6602
6982
  S: this,
6603
6983
  C: (f, a) => f(...a)
6604
6984
  });
6605
6985
  }
6606
6986
  async reset() {
6607
6987
  const traceId = import_keys15.PublicKey.random().toHex();
6608
- import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
6988
+ import_log20.log.trace("dxos.sdk.client-services-host.reset", import_protocols16.trace.begin({
6609
6989
  id: traceId
6610
6990
  }), {
6611
- F: __dxlog_file22,
6612
- L: 340,
6991
+ F: __dxlog_file24,
6992
+ L: 348,
6613
6993
  S: this,
6614
6994
  C: (f, a) => f(...a)
6615
6995
  });
6616
- import_log19.log.info("resetting...", void 0, {
6617
- F: __dxlog_file22,
6618
- L: 342,
6996
+ import_log20.log.info("resetting...", void 0, {
6997
+ F: __dxlog_file24,
6998
+ L: 350,
6619
6999
  S: this,
6620
7000
  C: (f, a) => f(...a)
6621
7001
  });
6622
7002
  await this._serviceContext?.close();
6623
7003
  await this._storage.reset();
6624
- import_log19.log.info("reset", void 0, {
6625
- F: __dxlog_file22,
6626
- L: 345,
7004
+ import_log20.log.info("reset", void 0, {
7005
+ F: __dxlog_file24,
7006
+ L: 353,
6627
7007
  S: this,
6628
7008
  C: (f, a) => f(...a)
6629
7009
  });
6630
- import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
7010
+ import_log20.log.trace("dxos.sdk.client-services-host.reset", import_protocols16.trace.end({
6631
7011
  id: traceId
6632
7012
  }), {
6633
- F: __dxlog_file22,
6634
- L: 346,
7013
+ F: __dxlog_file24,
7014
+ L: 354,
6635
7015
  S: this,
6636
7016
  C: (f, a) => f(...a)
6637
7017
  });
@@ -6690,7 +7070,11 @@ ClientServicesHost = _ts_decorate8([
6690
7070
  createDiagnostics,
6691
7071
  createLevel,
6692
7072
  createStorageObjects,
7073
+ decodeProfileArchive,
7074
+ encodeProfileArchive,
7075
+ exportProfileData,
6693
7076
  getNetworkPeers,
7077
+ importProfileData,
6694
7078
  isLocked,
6695
7079
  subscribeToFeedBlocks,
6696
7080
  subscribeToFeeds,
@@ -6700,4 +7084,4 @@ ClientServicesHost = _ts_decorate8([
6700
7084
  subscribeToSpaces,
6701
7085
  subscribeToSwarmInfo
6702
7086
  });
6703
- //# sourceMappingURL=chunk-F2EIFQZH.cjs.map
7087
+ //# sourceMappingURL=chunk-4LN54Y73.cjs.map