@dxos/client-services 0.5.9-main.a2de4fa → 0.5.9-main.aa46ff0

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 (40) hide show
  1. package/dist/lib/browser/{chunk-7ZORW75D.mjs → chunk-3CWG7YPJ.mjs} +805 -444
  2. package/dist/lib/browser/chunk-3CWG7YPJ.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-VQ7KZOFD.cjs → chunk-F4GQDNYS.cjs} +817 -456
  9. package/dist/lib/node/chunk-F4GQDNYS.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/spaces-service.d.ts +4 -1
  23. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  24. package/dist/types/src/packlets/storage/index.d.ts +1 -0
  25. package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
  26. package/dist/types/src/packlets/storage/profile-archive.d.ts +14 -0
  27. package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -0
  28. package/dist/types/src/version.d.ts +1 -1
  29. package/package.json +36 -36
  30. package/src/packlets/identity/contacts-service.ts +85 -0
  31. package/src/packlets/invitations/invitations-handler.ts +13 -5
  32. package/src/packlets/invitations/space-invitation-protocol.ts +11 -32
  33. package/src/packlets/services/service-host.ts +12 -4
  34. package/src/packlets/spaces/data-space-manager.ts +55 -2
  35. package/src/packlets/spaces/spaces-service.ts +38 -0
  36. package/src/packlets/storage/index.ts +1 -0
  37. package/src/packlets/storage/profile-archive.ts +97 -0
  38. package/src/version.ts +1 -1
  39. package/dist/lib/browser/chunk-7ZORW75D.mjs.map +0 -7
  40. package/dist/lib/node/chunk-VQ7KZOFD.cjs.map +0 -7
@@ -85,6 +85,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
85
85
  import { Stream as Stream2 } from "@dxos/codec-protobuf";
86
86
  import { Context } from "@dxos/context";
87
87
  import { PublicKey as PublicKey2 } from "@dxos/keys";
88
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/network.ts";
88
89
  var subscribeToNetworkStatus = ({ signalManager }) => new Stream2(({ next, close }) => {
89
90
  const update = () => {
90
91
  try {
@@ -100,7 +101,10 @@ var subscribeToNetworkStatus = ({ signalManager }) => new Stream2(({ next, close
100
101
  update();
101
102
  });
102
103
  var subscribeToSignal = ({ signalManager }) => new Stream2(({ next }) => {
103
- const ctx = new Context();
104
+ const ctx = new Context(void 0, {
105
+ F: __dxlog_file,
106
+ L: 36
107
+ });
104
108
  signalManager.onMessage.on(ctx, (message) => {
105
109
  next({
106
110
  message: {
@@ -355,7 +359,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
355
359
  import { TRACE_PROCESSOR } from "@dxos/tracing";
356
360
 
357
361
  // packages/sdk/client-services/src/version.ts
358
- var DXOS_VERSION = "0.5.9-main.a2de4fa";
362
+ var DXOS_VERSION = "0.5.9-main.aa46ff0";
359
363
 
360
364
  // packages/sdk/client-services/src/packlets/services/platform.ts
361
365
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -388,7 +392,7 @@ var getPlatform = () => {
388
392
  };
389
393
 
390
394
  // packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
391
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
395
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
392
396
  var DEFAULT_TIMEOUT = 1e3;
393
397
  var createDiagnostics = async (clientServices, serviceContext, config) => {
394
398
  const diagnostics = {
@@ -405,7 +409,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
405
409
  await Promise.all([
406
410
  (async () => {
407
411
  invariant(clientServices.LoggingService, "SystemService is not available.", {
408
- F: __dxlog_file,
412
+ F: __dxlog_file2,
409
413
  L: 110,
410
414
  S: void 0,
411
415
  A: [
@@ -510,7 +514,7 @@ var getStorageDiagnostics = async () => {
510
514
  // packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts
511
515
  import { Trigger } from "@dxos/async";
512
516
  import { log } from "@dxos/log";
513
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts";
517
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts";
514
518
  var CHANNEL_NAME = "dxos.diagnostics.broadcast";
515
519
  var MessageType;
516
520
  (function(MessageType2) {
@@ -579,7 +583,7 @@ var createCollectDiagnosticsBroadcastHandler = (systemService) => {
579
583
  }
580
584
  } catch (error) {
581
585
  log.catch(error, void 0, {
582
- F: __dxlog_file2,
586
+ F: __dxlog_file3,
583
587
  L: 77,
584
588
  S: void 0,
585
589
  C: (f, a) => f(...a)
@@ -687,7 +691,7 @@ import { Context as Context2 } from "@dxos/context";
687
691
  import { verifyCredential } from "@dxos/credentials";
688
692
  import { log as log2 } from "@dxos/log";
689
693
  import { schema } from "@dxos/protocols";
690
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
694
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
691
695
  var Credential = schema.getCodecForType("dxos.halo.credentials.Credential");
692
696
  var createAuthProvider = (signer) => async (nonce) => {
693
697
  const credential = await signer.createCredential({
@@ -702,7 +706,10 @@ var createAuthProvider = (signer) => async (nonce) => {
702
706
  var TrustedKeySetAuthVerifier = class {
703
707
  constructor(_params) {
704
708
  this._params = _params;
705
- this._ctx = new Context2();
709
+ this._ctx = new Context2(void 0, {
710
+ F: __dxlog_file4,
711
+ L: 45
712
+ });
706
713
  }
707
714
  async close() {
708
715
  await this._ctx.dispose();
@@ -713,7 +720,7 @@ var TrustedKeySetAuthVerifier = class {
713
720
  log2("authenticating...", {
714
721
  credential
715
722
  }, {
716
- F: __dxlog_file3,
723
+ F: __dxlog_file4,
717
724
  L: 56,
718
725
  S: this,
719
726
  C: (f, a) => f(...a)
@@ -723,7 +730,7 @@ var TrustedKeySetAuthVerifier = class {
723
730
  log2("Invalid credential", {
724
731
  result
725
732
  }, {
726
- F: __dxlog_file3,
733
+ F: __dxlog_file4,
727
734
  L: 60,
728
735
  S: this,
729
736
  C: (f, a) => f(...a)
@@ -735,7 +742,7 @@ var TrustedKeySetAuthVerifier = class {
735
742
  nonce,
736
743
  credential
737
744
  }, {
738
- F: __dxlog_file3,
745
+ F: __dxlog_file4,
739
746
  L: 65,
740
747
  S: this,
741
748
  C: (f, a) => f(...a)
@@ -746,7 +753,7 @@ var TrustedKeySetAuthVerifier = class {
746
753
  log2("key is not currently in trusted set, waiting...", {
747
754
  key: credential.issuer
748
755
  }, {
749
- F: __dxlog_file3,
756
+ F: __dxlog_file4,
750
757
  L: 70,
751
758
  S: this,
752
759
  C: (f, a) => f(...a)
@@ -762,7 +769,7 @@ var TrustedKeySetAuthVerifier = class {
762
769
  log2("auth success", {
763
770
  key: credential.issuer
764
771
  }, {
765
- F: __dxlog_file3,
772
+ F: __dxlog_file4,
766
773
  L: 81,
767
774
  S: this,
768
775
  C: (f, a) => f(...a)
@@ -772,7 +779,7 @@ var TrustedKeySetAuthVerifier = class {
772
779
  log2("key is not currently in trusted set, waiting...", {
773
780
  key: credential.issuer
774
781
  }, {
775
- F: __dxlog_file3,
782
+ F: __dxlog_file4,
776
783
  L: 84,
777
784
  S: this,
778
785
  C: (f, a) => f(...a)
@@ -813,7 +820,7 @@ import { ComplexSet } from "@dxos/util";
813
820
  import { getCredentialAssertion } from "@dxos/credentials";
814
821
  import { SpaceId } from "@dxos/keys";
815
822
  import { log as log3 } from "@dxos/log";
816
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
823
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
817
824
  var DefaultSpaceStateMachine = class {
818
825
  constructor(_params) {
819
826
  this._params = _params;
@@ -830,7 +837,7 @@ var DefaultSpaceStateMachine = class {
830
837
  expectedIdentity: this._params.identityKey,
831
838
  credential
832
839
  }, {
833
- F: __dxlog_file4,
840
+ F: __dxlog_file5,
834
841
  L: 32,
835
842
  S: this,
836
843
  C: (f, a) => f(...a)
@@ -841,7 +848,7 @@ var DefaultSpaceStateMachine = class {
841
848
  log3.warn("Invalid default space id", {
842
849
  id: assertion.spaceId
843
850
  }, {
844
- F: __dxlog_file4,
851
+ F: __dxlog_file5,
845
852
  L: 36,
846
853
  S: this,
847
854
  C: (f, a) => f(...a)
@@ -866,7 +873,7 @@ function _ts_decorate2(decorators, target, key, desc) {
866
873
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
867
874
  return c > 3 && r && Object.defineProperty(target, key, r), r;
868
875
  }
869
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
876
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
870
877
  var Identity = class {
871
878
  constructor({ space, signer, identityKey, deviceKey, presence }) {
872
879
  this.stateUpdate = new Event();
@@ -878,7 +885,7 @@ var Identity = class {
878
885
  log4.trace("dxos.halo.device", {
879
886
  deviceKey
880
887
  }, {
881
- F: __dxlog_file5,
888
+ F: __dxlog_file6,
882
889
  L: 70,
883
890
  S: this,
884
891
  C: (f, a) => f(...a)
@@ -957,7 +964,7 @@ var Identity = class {
957
964
  */
958
965
  getIdentityCredentialSigner() {
959
966
  invariant2(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
960
- F: __dxlog_file5,
967
+ F: __dxlog_file6,
961
968
  L: 159,
962
969
  S: this,
963
970
  A: [
@@ -1001,7 +1008,7 @@ var Identity = class {
1001
1008
  controlFeedKey,
1002
1009
  dataFeedKey
1003
1010
  }, {
1004
- F: __dxlog_file5,
1011
+ F: __dxlog_file6,
1005
1012
  L: 184,
1006
1013
  S: this,
1007
1014
  C: (f, a) => f(...a)
@@ -1078,7 +1085,7 @@ function _ts_decorate3(decorators, target, key, desc) {
1078
1085
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1079
1086
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1080
1087
  }
1081
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1088
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1082
1089
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
1083
1090
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
1084
1091
  var IdentityManager = class {
@@ -1102,7 +1109,7 @@ var IdentityManager = class {
1102
1109
  log5.trace("dxos.halo.identity-manager.open", trace3.begin({
1103
1110
  id: traceId
1104
1111
  }), {
1105
- F: __dxlog_file6,
1112
+ F: __dxlog_file7,
1106
1113
  L: 104,
1107
1114
  S: this,
1108
1115
  C: (f, a) => f(...a)
@@ -1111,7 +1118,7 @@ var IdentityManager = class {
1111
1118
  log5("identity record", {
1112
1119
  identityRecord
1113
1120
  }, {
1114
- F: __dxlog_file6,
1121
+ F: __dxlog_file7,
1115
1122
  L: 107,
1116
1123
  S: this,
1117
1124
  C: (f, a) => f(...a)
@@ -1124,7 +1131,7 @@ var IdentityManager = class {
1124
1131
  identityKey: identityRecord.identityKey,
1125
1132
  displayName: this._identity.profileDocument?.displayName
1126
1133
  }, {
1127
- F: __dxlog_file6,
1134
+ F: __dxlog_file7,
1128
1135
  L: 112,
1129
1136
  S: this,
1130
1137
  C: (f, a) => f(...a)
@@ -1134,18 +1141,21 @@ var IdentityManager = class {
1134
1141
  log5.trace("dxos.halo.identity-manager.open", trace3.end({
1135
1142
  id: traceId
1136
1143
  }), {
1137
- F: __dxlog_file6,
1144
+ F: __dxlog_file7,
1138
1145
  L: 119,
1139
1146
  S: this,
1140
1147
  C: (f, a) => f(...a)
1141
1148
  });
1142
1149
  }
1143
1150
  async close() {
1144
- await this._identity?.close(new Context3());
1151
+ await this._identity?.close(new Context3(void 0, {
1152
+ F: __dxlog_file7,
1153
+ L: 123
1154
+ }));
1145
1155
  }
1146
1156
  async createIdentity({ displayName, deviceProfile } = {}) {
1147
1157
  invariant3(!this._identity, "Identity already exists.", {
1148
- F: __dxlog_file6,
1158
+ F: __dxlog_file7,
1149
1159
  L: 128,
1150
1160
  S: this,
1151
1161
  A: [
@@ -1154,7 +1164,7 @@ var IdentityManager = class {
1154
1164
  ]
1155
1165
  });
1156
1166
  log5("creating identity...", void 0, {
1157
- F: __dxlog_file6,
1167
+ F: __dxlog_file7,
1158
1168
  L: 129,
1159
1169
  S: this,
1160
1170
  C: (f, a) => f(...a)
@@ -1171,11 +1181,14 @@ var IdentityManager = class {
1171
1181
  }
1172
1182
  };
1173
1183
  const identity = await this._constructIdentity(identityRecord);
1174
- await identity.open(new Context3());
1184
+ await identity.open(new Context3(void 0, {
1185
+ F: __dxlog_file7,
1186
+ L: 144
1187
+ }));
1175
1188
  {
1176
1189
  const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
1177
1190
  invariant3(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
1178
- F: __dxlog_file6,
1191
+ F: __dxlog_file7,
1179
1192
  L: 148,
1180
1193
  S: this,
1181
1194
  A: [
@@ -1184,7 +1197,7 @@ var IdentityManager = class {
1184
1197
  ]
1185
1198
  });
1186
1199
  invariant3(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
1187
- F: __dxlog_file6,
1200
+ F: __dxlog_file7,
1188
1201
  L: 149,
1189
1202
  S: this,
1190
1203
  A: [
@@ -1223,7 +1236,7 @@ var IdentityManager = class {
1223
1236
  identityKey: identityRecord.identityKey,
1224
1237
  displayName: this._identity.profileDocument?.displayName
1225
1238
  }, {
1226
- F: __dxlog_file6,
1239
+ F: __dxlog_file7,
1227
1240
  L: 191,
1228
1241
  S: this,
1229
1242
  C: (f, a) => f(...a)
@@ -1234,7 +1247,7 @@ var IdentityManager = class {
1234
1247
  deviceKey: identity.deviceKey,
1235
1248
  profile: identity.profileDocument
1236
1249
  }, {
1237
- F: __dxlog_file6,
1250
+ F: __dxlog_file7,
1238
1251
  L: 197,
1239
1252
  S: this,
1240
1253
  C: (f, a) => f(...a)
@@ -1271,13 +1284,13 @@ var IdentityManager = class {
1271
1284
  log5("accepting identity", {
1272
1285
  params
1273
1286
  }, {
1274
- F: __dxlog_file6,
1287
+ F: __dxlog_file7,
1275
1288
  L: 235,
1276
1289
  S: this,
1277
1290
  C: (f, a) => f(...a)
1278
1291
  });
1279
1292
  invariant3(!this._identity, "Identity already exists.", {
1280
- F: __dxlog_file6,
1293
+ F: __dxlog_file7,
1281
1294
  L: 236,
1282
1295
  S: this,
1283
1296
  A: [
@@ -1297,7 +1310,10 @@ var IdentityManager = class {
1297
1310
  }
1298
1311
  };
1299
1312
  const identity = await this._constructIdentity(identityRecord);
1300
- await identity.open(new Context3());
1313
+ await identity.open(new Context3(void 0, {
1314
+ F: __dxlog_file7,
1315
+ L: 251
1316
+ }));
1301
1317
  this._identity = identity;
1302
1318
  await this._metadataStore.setIdentityRecord(identityRecord);
1303
1319
  await this._identity.ready();
@@ -1305,7 +1321,7 @@ var IdentityManager = class {
1305
1321
  identityKey: identityRecord.identityKey,
1306
1322
  displayName: this._identity.profileDocument?.displayName
1307
1323
  }, {
1308
- F: __dxlog_file6,
1324
+ F: __dxlog_file7,
1309
1325
  L: 255,
1310
1326
  S: this,
1311
1327
  C: (f, a) => f(...a)
@@ -1319,7 +1335,7 @@ var IdentityManager = class {
1319
1335
  identityKey: identity.identityKey,
1320
1336
  deviceKey: identity.deviceKey
1321
1337
  }, {
1322
- F: __dxlog_file6,
1338
+ F: __dxlog_file7,
1323
1339
  L: 265,
1324
1340
  S: this,
1325
1341
  C: (f, a) => f(...a)
@@ -1331,7 +1347,7 @@ var IdentityManager = class {
1331
1347
  */
1332
1348
  async updateProfile(profile) {
1333
1349
  invariant3(this._identity, "Identity not initialized.", {
1334
- F: __dxlog_file6,
1350
+ F: __dxlog_file7,
1335
1351
  L: 273,
1336
1352
  S: this,
1337
1353
  A: [
@@ -1362,7 +1378,7 @@ var IdentityManager = class {
1362
1378
  }
1363
1379
  async updateDeviceProfile(profile) {
1364
1380
  invariant3(this._identity, "Identity not initialized.", {
1365
- F: __dxlog_file6,
1381
+ F: __dxlog_file7,
1366
1382
  L: 290,
1367
1383
  S: this,
1368
1384
  A: [
@@ -1398,7 +1414,7 @@ var IdentityManager = class {
1398
1414
  }
1399
1415
  async _constructIdentity(identityRecord) {
1400
1416
  invariant3(!this._identity, void 0, {
1401
- F: __dxlog_file6,
1417
+ F: __dxlog_file7,
1402
1418
  L: 316,
1403
1419
  S: this,
1404
1420
  A: [
@@ -1409,7 +1425,7 @@ var IdentityManager = class {
1409
1425
  log5("constructing identity", {
1410
1426
  identityRecord
1411
1427
  }, {
1412
- F: __dxlog_file6,
1428
+ F: __dxlog_file7,
1413
1429
  L: 317,
1414
1430
  S: this,
1415
1431
  C: (f, a) => f(...a)
@@ -1424,7 +1440,7 @@ var IdentityManager = class {
1424
1440
  gossip
1425
1441
  });
1426
1442
  invariant3(identityRecord.haloSpace.controlFeedKey, void 0, {
1427
- F: __dxlog_file6,
1443
+ F: __dxlog_file7,
1428
1444
  L: 330,
1429
1445
  S: this,
1430
1446
  A: [
@@ -1436,7 +1452,7 @@ var IdentityManager = class {
1436
1452
  writable: true
1437
1453
  });
1438
1454
  invariant3(identityRecord.haloSpace.dataFeedKey, void 0, {
1439
- F: __dxlog_file6,
1455
+ F: __dxlog_file7,
1440
1456
  L: 334,
1441
1457
  S: this,
1442
1458
  A: [
@@ -1470,7 +1486,7 @@ var IdentityManager = class {
1470
1486
  log5("done", {
1471
1487
  identityKey: identityRecord.identityKey
1472
1488
  }, {
1473
- F: __dxlog_file6,
1489
+ F: __dxlog_file7,
1474
1490
  L: 360,
1475
1491
  S: this,
1476
1492
  C: (f, a) => f(...a)
@@ -1495,7 +1511,7 @@ var IdentityManager = class {
1495
1511
  },
1496
1512
  onAuthFailure: () => {
1497
1513
  log5.warn("auth failure", void 0, {
1498
- F: __dxlog_file6,
1514
+ F: __dxlog_file7,
1499
1515
  L: 385,
1500
1516
  S: this,
1501
1517
  C: (f, a) => f(...a)
@@ -1528,7 +1544,7 @@ import { invariant as invariant4 } from "@dxos/invariant";
1528
1544
  import { log as log6 } from "@dxos/log";
1529
1545
  import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
1530
1546
  import { safeAwaitAll } from "@dxos/util";
1531
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1547
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1532
1548
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
1533
1549
  var IdentityServiceImpl = class extends Resource {
1534
1550
  constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
@@ -1558,7 +1574,7 @@ var IdentityServiceImpl = class extends Resource {
1558
1574
  const space = await dataSpaceManager.createDefaultSpace();
1559
1575
  const identity = this._identityManager.identity;
1560
1576
  invariant4(identity, void 0, {
1561
- F: __dxlog_file7,
1577
+ F: __dxlog_file8,
1562
1578
  L: 59,
1563
1579
  S: this,
1564
1580
  A: [
@@ -1592,7 +1608,7 @@ var IdentityServiceImpl = class extends Resource {
1592
1608
  }
1593
1609
  async updateProfile(profile) {
1594
1610
  invariant4(this._identityManager.identity, "Identity not initialized.", {
1595
- F: __dxlog_file7,
1611
+ F: __dxlog_file8,
1596
1612
  L: 89,
1597
1613
  S: this,
1598
1614
  A: [
@@ -1606,7 +1622,7 @@ var IdentityServiceImpl = class extends Resource {
1606
1622
  }
1607
1623
  async signPresentation({ presentation, nonce }) {
1608
1624
  invariant4(this._identityManager.identity, "Identity not initialized.", {
1609
- F: __dxlog_file7,
1625
+ F: __dxlog_file8,
1610
1626
  L: 96,
1611
1627
  S: this,
1612
1628
  A: [
@@ -1641,7 +1657,7 @@ var IdentityServiceImpl = class extends Resource {
1641
1657
  log6.warn("Multiple default spaces found. Using the first one.", {
1642
1658
  duplicate: space.id
1643
1659
  }, {
1644
- F: __dxlog_file7,
1660
+ F: __dxlog_file8,
1645
1661
  L: 127,
1646
1662
  S: this,
1647
1663
  C: (f, a) => f(...a)
@@ -1669,7 +1685,7 @@ var IdentityServiceImpl = class extends Resource {
1669
1685
  import { invariant as invariant5 } from "@dxos/invariant";
1670
1686
  import { AlreadyJoinedError } from "@dxos/protocols";
1671
1687
  import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
1672
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1688
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1673
1689
  var DeviceInvitationProtocol = class {
1674
1690
  constructor(_keyring, _getIdentity, _acceptIdentity) {
1675
1691
  this._keyring = _keyring;
@@ -1695,7 +1711,7 @@ var DeviceInvitationProtocol = class {
1695
1711
  }
1696
1712
  async admit(_, request) {
1697
1713
  invariant5(request.device, void 0, {
1698
- F: __dxlog_file8,
1714
+ F: __dxlog_file9,
1699
1715
  L: 50,
1700
1716
  S: this,
1701
1717
  A: [
@@ -1741,7 +1757,7 @@ var DeviceInvitationProtocol = class {
1741
1757
  }
1742
1758
  async accept(response, request) {
1743
1759
  invariant5(response.device, void 0, {
1744
- F: __dxlog_file8,
1760
+ F: __dxlog_file9,
1745
1761
  L: 95,
1746
1762
  S: this,
1747
1763
  A: [
@@ -1751,7 +1767,7 @@ var DeviceInvitationProtocol = class {
1751
1767
  });
1752
1768
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1753
1769
  invariant5(request.device, void 0, {
1754
- F: __dxlog_file8,
1770
+ F: __dxlog_file9,
1755
1771
  L: 98,
1756
1772
  S: this,
1757
1773
  A: [
@@ -1820,7 +1836,7 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
1820
1836
  };
1821
1837
 
1822
1838
  // packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
1823
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1839
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1824
1840
  var OPTIONS_TIMEOUT = 1e4;
1825
1841
  var InvitationGuestExtension = class extends RpcExtension {
1826
1842
  constructor(_invitationFlowMutex, _callbacks) {
@@ -1834,7 +1850,10 @@ var InvitationGuestExtension = class extends RpcExtension {
1834
1850
  });
1835
1851
  this._invitationFlowMutex = _invitationFlowMutex;
1836
1852
  this._callbacks = _callbacks;
1837
- this._ctx = new Context4();
1853
+ this._ctx = new Context4(void 0, {
1854
+ F: __dxlog_file10,
1855
+ L: 33
1856
+ });
1838
1857
  this._remoteOptionsTrigger = new Trigger4();
1839
1858
  this._invitationFlowLock = null;
1840
1859
  }
@@ -1846,7 +1865,7 @@ var InvitationGuestExtension = class extends RpcExtension {
1846
1865
  InvitationHostService: {
1847
1866
  options: async (options) => {
1848
1867
  invariant6(!this._remoteOptions, "Remote options already set.", {
1849
- F: __dxlog_file9,
1868
+ F: __dxlog_file10,
1850
1869
  L: 63,
1851
1870
  S: this,
1852
1871
  A: [
@@ -1873,14 +1892,14 @@ var InvitationGuestExtension = class extends RpcExtension {
1873
1892
  await super.onOpen(context);
1874
1893
  try {
1875
1894
  log7("guest acquire lock", void 0, {
1876
- F: __dxlog_file9,
1895
+ F: __dxlog_file10,
1877
1896
  L: 84,
1878
1897
  S: this,
1879
1898
  C: (f, a) => f(...a)
1880
1899
  });
1881
1900
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
1882
1901
  log7("guest lock acquired", void 0, {
1883
- F: __dxlog_file9,
1902
+ F: __dxlog_file10,
1884
1903
  L: 86,
1885
1904
  S: this,
1886
1905
  C: (f, a) => f(...a)
@@ -1889,7 +1908,7 @@ var InvitationGuestExtension = class extends RpcExtension {
1889
1908
  role: Options.Role.GUEST
1890
1909
  }));
1891
1910
  log7("options sent", void 0, {
1892
- F: __dxlog_file9,
1911
+ F: __dxlog_file10,
1893
1912
  L: 88,
1894
1913
  S: this,
1895
1914
  C: (f, a) => f(...a)
@@ -1898,7 +1917,7 @@ var InvitationGuestExtension = class extends RpcExtension {
1898
1917
  timeout: OPTIONS_TIMEOUT
1899
1918
  }));
1900
1919
  log7("options received", void 0, {
1901
- F: __dxlog_file9,
1920
+ F: __dxlog_file10,
1902
1921
  L: 90,
1903
1922
  S: this,
1904
1923
  C: (f, a) => f(...a)
@@ -1932,7 +1951,7 @@ var InvitationGuestExtension = class extends RpcExtension {
1932
1951
  this._invitationFlowLock.release();
1933
1952
  this._invitationFlowLock = null;
1934
1953
  log7("invitation flow lock released", void 0, {
1935
- F: __dxlog_file9,
1954
+ F: __dxlog_file10,
1936
1955
  L: 123,
1937
1956
  S: this,
1938
1957
  C: (f, a) => f(...a)
@@ -1952,7 +1971,7 @@ import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleEr
1952
1971
  import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
1953
1972
  import { AuthenticationResponse, Options as Options2 } from "@dxos/protocols/proto/dxos/halo/invitations";
1954
1973
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
1955
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
1974
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
1956
1975
  var OPTIONS_TIMEOUT2 = 1e4;
1957
1976
  var MAX_OTP_ATTEMPTS = 3;
1958
1977
  var InvitationHostExtension = class extends RpcExtension2 {
@@ -1967,7 +1986,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
1967
1986
  });
1968
1987
  this._invitationFlowMutex = _invitationFlowMutex;
1969
1988
  this._callbacks = _callbacks;
1970
- this._ctx = new Context5();
1989
+ this._ctx = new Context5(void 0, {
1990
+ F: __dxlog_file11,
1991
+ L: 52
1992
+ });
1971
1993
  this._remoteOptionsTrigger = new Trigger5();
1972
1994
  this._challenge = void 0;
1973
1995
  this.guestProfile = void 0;
@@ -1986,7 +2008,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
1986
2008
  InvitationHostService: {
1987
2009
  options: async (options) => {
1988
2010
  invariant7(!this._remoteOptions, "Remote options already set.", {
1989
- F: __dxlog_file10,
2011
+ F: __dxlog_file11,
1990
2012
  L: 101,
1991
2013
  S: this,
1992
2014
  A: [
@@ -2003,7 +2025,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2003
2025
  log8.trace("dxos.sdk.invitation-handler.host.introduce", trace4.begin({
2004
2026
  id: traceId
2005
2027
  }), {
2006
- F: __dxlog_file10,
2028
+ F: __dxlog_file11,
2007
2029
  L: 110,
2008
2030
  S: this,
2009
2031
  C: (f, a) => f(...a)
@@ -2015,7 +2037,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2015
2037
  expected: invitation.invitationId,
2016
2038
  actual: invitationId
2017
2039
  }, {
2018
- F: __dxlog_file10,
2040
+ F: __dxlog_file11,
2019
2041
  L: 116,
2020
2042
  S: this,
2021
2043
  C: (f, a) => f(...a)
@@ -2029,7 +2051,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2029
2051
  log8("guest introduced themselves", {
2030
2052
  guestProfile: profile
2031
2053
  }, {
2032
- F: __dxlog_file10,
2054
+ F: __dxlog_file11,
2033
2055
  L: 125,
2034
2056
  S: this,
2035
2057
  C: (f, a) => f(...a)
@@ -2040,7 +2062,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2040
2062
  log8.trace("dxos.sdk.invitation-handler.host.introduce", trace4.end({
2041
2063
  id: traceId
2042
2064
  }), {
2043
- F: __dxlog_file10,
2065
+ F: __dxlog_file11,
2044
2066
  L: 132,
2045
2067
  S: this,
2046
2068
  C: (f, a) => f(...a)
@@ -2055,7 +2077,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2055
2077
  log8.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.begin({
2056
2078
  id: traceId
2057
2079
  }), {
2058
- F: __dxlog_file10,
2080
+ F: __dxlog_file11,
2059
2081
  L: 141,
2060
2082
  S: this,
2061
2083
  C: (f, a) => f(...a)
@@ -2064,7 +2086,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2064
2086
  log8("received authentication request", {
2065
2087
  authCode: code
2066
2088
  }, {
2067
- F: __dxlog_file10,
2089
+ F: __dxlog_file11,
2068
2090
  L: 144,
2069
2091
  S: this,
2070
2092
  C: (f, a) => f(...a)
@@ -2078,7 +2100,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2078
2100
  switch (invitation.authMethod) {
2079
2101
  case Invitation3.AuthMethod.NONE: {
2080
2102
  log8("authentication not required", void 0, {
2081
- F: __dxlog_file10,
2103
+ F: __dxlog_file11,
2082
2104
  L: 152,
2083
2105
  S: this,
2084
2106
  C: (f, a) => f(...a)
@@ -2116,7 +2138,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2116
2138
  log8.error("invalid authentication method", {
2117
2139
  authMethod: invitation.authMethod
2118
2140
  }, {
2119
- F: __dxlog_file10,
2141
+ F: __dxlog_file11,
2120
2142
  L: 190,
2121
2143
  S: this,
2122
2144
  C: (f, a) => f(...a)
@@ -2141,7 +2163,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2141
2163
  status
2142
2164
  }
2143
2165
  }), {
2144
- F: __dxlog_file10,
2166
+ F: __dxlog_file11,
2145
2167
  L: 202,
2146
2168
  S: this,
2147
2169
  C: (f, a) => f(...a)
@@ -2155,7 +2177,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2155
2177
  log8.trace("dxos.sdk.invitation-handler.host.admit", trace4.begin({
2156
2178
  id: traceId
2157
2179
  }), {
2158
- F: __dxlog_file10,
2180
+ F: __dxlog_file11,
2159
2181
  L: 208,
2160
2182
  S: this,
2161
2183
  C: (f, a) => f(...a)
@@ -2172,7 +2194,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2172
2194
  log8.trace("dxos.sdk.invitation-handler.host.admit", trace4.end({
2173
2195
  id: traceId
2174
2196
  }), {
2175
- F: __dxlog_file10,
2197
+ F: __dxlog_file11,
2176
2198
  L: 222,
2177
2199
  S: this,
2178
2200
  C: (f, a) => f(...a)
@@ -2190,14 +2212,14 @@ var InvitationHostExtension = class extends RpcExtension2 {
2190
2212
  await super.onOpen(context);
2191
2213
  try {
2192
2214
  log8("host acquire lock", void 0, {
2193
- F: __dxlog_file10,
2215
+ F: __dxlog_file11,
2194
2216
  L: 237,
2195
2217
  S: this,
2196
2218
  C: (f, a) => f(...a)
2197
2219
  });
2198
2220
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
2199
2221
  log8("host lock acquired", void 0, {
2200
- F: __dxlog_file10,
2222
+ F: __dxlog_file11,
2201
2223
  L: 239,
2202
2224
  S: this,
2203
2225
  C: (f, a) => f(...a)
@@ -2208,7 +2230,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2208
2230
  role: Options2.Role.HOST
2209
2231
  });
2210
2232
  log8("options sent", void 0, {
2211
- F: __dxlog_file10,
2233
+ F: __dxlog_file11,
2212
2234
  L: 243,
2213
2235
  S: this,
2214
2236
  C: (f, a) => f(...a)
@@ -2217,7 +2239,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2217
2239
  timeout: OPTIONS_TIMEOUT2
2218
2240
  }));
2219
2241
  log8("options received", void 0, {
2220
- F: __dxlog_file10,
2242
+ F: __dxlog_file11,
2221
2243
  L: 245,
2222
2244
  S: this,
2223
2245
  C: (f, a) => f(...a)
@@ -2271,7 +2293,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
2271
2293
  this._invitationFlowLock?.release();
2272
2294
  this._invitationFlowLock = null;
2273
2295
  log8("invitation flow lock released", void 0, {
2274
- F: __dxlog_file10,
2296
+ F: __dxlog_file11,
2275
2297
  L: 300,
2276
2298
  S: this,
2277
2299
  C: (f, a) => f(...a)
@@ -2287,7 +2309,7 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
2287
2309
  import { log as log9 } from "@dxos/log";
2288
2310
  import { Options as Options3 } from "@dxos/protocols/proto/dxos/halo/invitations";
2289
2311
  import { ComplexSet as ComplexSet2 } from "@dxos/util";
2290
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2312
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2291
2313
  var InvitationTopology = class {
2292
2314
  constructor(_role) {
2293
2315
  this._role = _role;
@@ -2295,7 +2317,7 @@ var InvitationTopology = class {
2295
2317
  }
2296
2318
  init(controller) {
2297
2319
  invariant8(!this._controller, "Already initialized.", {
2298
- F: __dxlog_file11,
2320
+ F: __dxlog_file12,
2299
2321
  L: 42,
2300
2322
  S: this,
2301
2323
  A: [
@@ -2307,7 +2329,7 @@ var InvitationTopology = class {
2307
2329
  }
2308
2330
  update() {
2309
2331
  invariant8(this._controller, "Not initialized.", {
2310
- F: __dxlog_file11,
2332
+ F: __dxlog_file12,
2311
2333
  L: 47,
2312
2334
  S: this,
2313
2335
  A: [
@@ -2330,7 +2352,7 @@ var InvitationTopology = class {
2330
2352
  ownPeerId,
2331
2353
  remotePeerId: firstUnknownPeer
2332
2354
  }, {
2333
- F: __dxlog_file11,
2355
+ F: __dxlog_file12,
2334
2356
  L: 69,
2335
2357
  S: this,
2336
2358
  C: (f, a) => f(...a)
@@ -2341,7 +2363,7 @@ var InvitationTopology = class {
2341
2363
  }
2342
2364
  async onOffer(peer) {
2343
2365
  invariant8(this._controller, "Not initialized.", {
2344
- F: __dxlog_file11,
2366
+ F: __dxlog_file12,
2345
2367
  L: 76,
2346
2368
  S: this,
2347
2369
  A: [
@@ -2360,7 +2382,7 @@ var InvitationTopology = class {
2360
2382
  };
2361
2383
 
2362
2384
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
2363
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2385
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2364
2386
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
2365
2387
  var InvitationsHandler = class {
2366
2388
  /**
@@ -2385,7 +2407,7 @@ var InvitationsHandler = class {
2385
2407
  try {
2386
2408
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
2387
2409
  invariant9(deviceKey, void 0, {
2388
- F: __dxlog_file12,
2410
+ F: __dxlog_file13,
2389
2411
  L: 90,
2390
2412
  S: this,
2391
2413
  A: [
@@ -2414,7 +2436,7 @@ var InvitationsHandler = class {
2414
2436
  log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.begin({
2415
2437
  id: traceId
2416
2438
  }), {
2417
- F: __dxlog_file12,
2439
+ F: __dxlog_file13,
2418
2440
  L: 115,
2419
2441
  S: this,
2420
2442
  C: (f, a) => f(...a)
@@ -2422,7 +2444,7 @@ var InvitationsHandler = class {
2422
2444
  log10("connected", {
2423
2445
  ...protocol.toJSON()
2424
2446
  }, {
2425
- F: __dxlog_file12,
2447
+ F: __dxlog_file13,
2426
2448
  L: 116,
2427
2449
  S: this,
2428
2450
  C: (f, a) => f(...a)
@@ -2434,7 +2456,7 @@ var InvitationsHandler = class {
2434
2456
  guest: deviceKey,
2435
2457
  ...protocol.toJSON()
2436
2458
  }, {
2437
- F: __dxlog_file12,
2459
+ F: __dxlog_file13,
2438
2460
  L: 118,
2439
2461
  S: this,
2440
2462
  C: (f, a) => f(...a)
@@ -2443,7 +2465,7 @@ var InvitationsHandler = class {
2443
2465
  log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.end({
2444
2466
  id: traceId
2445
2467
  }), {
2446
- F: __dxlog_file12,
2468
+ F: __dxlog_file13,
2447
2469
  L: 120,
2448
2470
  S: this,
2449
2471
  C: (f, a) => f(...a)
@@ -2458,7 +2480,7 @@ var InvitationsHandler = class {
2458
2480
  log10("timeout", {
2459
2481
  ...protocol.toJSON()
2460
2482
  }, {
2461
- F: __dxlog_file12,
2483
+ F: __dxlog_file13,
2462
2484
  L: 129,
2463
2485
  S: this,
2464
2486
  C: (f, a) => f(...a)
@@ -2467,7 +2489,7 @@ var InvitationsHandler = class {
2467
2489
  } else {
2468
2490
  if (guardedState.error(extension, err)) {
2469
2491
  log10.error("failed", err, {
2470
- F: __dxlog_file12,
2492
+ F: __dxlog_file13,
2471
2493
  L: 133,
2472
2494
  S: this,
2473
2495
  C: (f, a) => f(...a)
@@ -2478,7 +2500,7 @@ var InvitationsHandler = class {
2478
2500
  id: traceId,
2479
2501
  error: err
2480
2502
  }), {
2481
- F: __dxlog_file12,
2503
+ F: __dxlog_file13,
2482
2504
  L: 136,
2483
2505
  S: this,
2484
2506
  C: (f, a) => f(...a)
@@ -2492,7 +2514,7 @@ var InvitationsHandler = class {
2492
2514
  log10("invalid role", {
2493
2515
  ...err.context
2494
2516
  }, {
2495
- F: __dxlog_file12,
2517
+ F: __dxlog_file13,
2496
2518
  L: 144,
2497
2519
  S: this,
2498
2520
  C: (f, a) => f(...a)
@@ -2504,7 +2526,7 @@ var InvitationsHandler = class {
2504
2526
  log10("timeout", {
2505
2527
  err
2506
2528
  }, {
2507
- F: __dxlog_file12,
2529
+ F: __dxlog_file13,
2508
2530
  L: 149,
2509
2531
  S: this,
2510
2532
  C: (f, a) => f(...a)
@@ -2513,7 +2535,7 @@ var InvitationsHandler = class {
2513
2535
  } else {
2514
2536
  if (guardedState.error(extension, err)) {
2515
2537
  log10.error("failed", err, {
2516
- F: __dxlog_file12,
2538
+ F: __dxlog_file13,
2517
2539
  L: 153,
2518
2540
  S: this,
2519
2541
  C: (f, a) => f(...a)
@@ -2527,7 +2549,7 @@ var InvitationsHandler = class {
2527
2549
  if (invitation.lifetime && invitation.created) {
2528
2550
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
2529
2551
  log10.warn("invitation has already expired", void 0, {
2530
- F: __dxlog_file12,
2552
+ F: __dxlog_file13,
2531
2553
  L: 164,
2532
2554
  S: this,
2533
2555
  C: (f, a) => f(...a)
@@ -2550,7 +2572,7 @@ var InvitationsHandler = class {
2550
2572
  const { timeout = INVITATION_TIMEOUT } = invitation;
2551
2573
  if (deviceProfile) {
2552
2574
  invariant9(invitation.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2553
- F: __dxlog_file12,
2575
+ F: __dxlog_file13,
2554
2576
  L: 197,
2555
2577
  S: this,
2556
2578
  A: [
@@ -2568,7 +2590,7 @@ var InvitationsHandler = class {
2568
2590
  invitationType: Invitation4.Type.DELEGATED,
2569
2591
  triedPeers: triedPeersIds.size
2570
2592
  }, {
2571
- F: __dxlog_file12,
2593
+ F: __dxlog_file13,
2572
2594
  L: 205,
2573
2595
  S: this,
2574
2596
  C: (f, a) => f(...a)
@@ -2595,7 +2617,7 @@ var InvitationsHandler = class {
2595
2617
  admitted,
2596
2618
  currentState: guardedState.current.state
2597
2619
  }, {
2598
- F: __dxlog_file12,
2620
+ F: __dxlog_file13,
2599
2621
  L: 233,
2600
2622
  S: this,
2601
2623
  C: (f, a) => f(...a)
@@ -2613,7 +2635,7 @@ var InvitationsHandler = class {
2613
2635
  log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.begin({
2614
2636
  id: traceId
2615
2637
  }), {
2616
- F: __dxlog_file12,
2638
+ F: __dxlog_file13,
2617
2639
  L: 245,
2618
2640
  S: this,
2619
2641
  C: (f, a) => f(...a)
@@ -2625,7 +2647,7 @@ var InvitationsHandler = class {
2625
2647
  log10("connected", {
2626
2648
  ...protocol.toJSON()
2627
2649
  }, {
2628
- F: __dxlog_file12,
2650
+ F: __dxlog_file13,
2629
2651
  L: 256,
2630
2652
  S: this,
2631
2653
  C: (f, a) => f(...a)
@@ -2634,7 +2656,7 @@ var InvitationsHandler = class {
2634
2656
  log10("introduce", {
2635
2657
  ...protocol.toJSON()
2636
2658
  }, {
2637
- F: __dxlog_file12,
2659
+ F: __dxlog_file13,
2638
2660
  L: 260,
2639
2661
  S: this,
2640
2662
  C: (f, a) => f(...a)
@@ -2647,7 +2669,7 @@ var InvitationsHandler = class {
2647
2669
  ...protocol.toJSON(),
2648
2670
  response: introductionResponse
2649
2671
  }, {
2650
- F: __dxlog_file12,
2672
+ F: __dxlog_file13,
2651
2673
  L: 265,
2652
2674
  S: this,
2653
2675
  C: (f, a) => f(...a)
@@ -2668,7 +2690,7 @@ var InvitationsHandler = class {
2668
2690
  log10("request admission", {
2669
2691
  ...protocol.toJSON()
2670
2692
  }, {
2671
- F: __dxlog_file12,
2693
+ F: __dxlog_file13,
2672
2694
  L: 291,
2673
2695
  S: this,
2674
2696
  C: (f, a) => f(...a)
@@ -2680,7 +2702,7 @@ var InvitationsHandler = class {
2680
2702
  log10("admitted by host", {
2681
2703
  ...protocol.toJSON()
2682
2704
  }, {
2683
- F: __dxlog_file12,
2705
+ F: __dxlog_file13,
2684
2706
  L: 302,
2685
2707
  S: this,
2686
2708
  C: (f, a) => f(...a)
@@ -2693,7 +2715,7 @@ var InvitationsHandler = class {
2693
2715
  log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.end({
2694
2716
  id: traceId
2695
2717
  }), {
2696
- F: __dxlog_file12,
2718
+ F: __dxlog_file13,
2697
2719
  L: 308,
2698
2720
  S: this,
2699
2721
  C: (f, a) => f(...a)
@@ -2703,7 +2725,7 @@ var InvitationsHandler = class {
2703
2725
  log10("timeout", {
2704
2726
  ...protocol.toJSON()
2705
2727
  }, {
2706
- F: __dxlog_file12,
2728
+ F: __dxlog_file13,
2707
2729
  L: 311,
2708
2730
  S: this,
2709
2731
  C: (f, a) => f(...a)
@@ -2711,7 +2733,7 @@ var InvitationsHandler = class {
2711
2733
  guardedState.set(extension, Invitation4.State.TIMEOUT);
2712
2734
  } else {
2713
2735
  log10("auth failed", err, {
2714
- F: __dxlog_file12,
2736
+ F: __dxlog_file13,
2715
2737
  L: 314,
2716
2738
  S: this,
2717
2739
  C: (f, a) => f(...a)
@@ -2723,7 +2745,7 @@ var InvitationsHandler = class {
2723
2745
  id: traceId,
2724
2746
  error: err
2725
2747
  }), {
2726
- F: __dxlog_file12,
2748
+ F: __dxlog_file13,
2727
2749
  L: 318,
2728
2750
  S: this,
2729
2751
  C: (f, a) => f(...a)
@@ -2739,7 +2761,7 @@ var InvitationsHandler = class {
2739
2761
  log10("timeout", {
2740
2762
  ...protocol.toJSON()
2741
2763
  }, {
2742
- F: __dxlog_file12,
2764
+ F: __dxlog_file13,
2743
2765
  L: 327,
2744
2766
  S: this,
2745
2767
  C: (f, a) => f(...a)
@@ -2747,7 +2769,7 @@ var InvitationsHandler = class {
2747
2769
  guardedState.set(extension, Invitation4.State.TIMEOUT);
2748
2770
  } else {
2749
2771
  log10("auth failed", err, {
2750
- F: __dxlog_file12,
2772
+ F: __dxlog_file13,
2751
2773
  L: 330,
2752
2774
  S: this,
2753
2775
  C: (f, a) => f(...a)
@@ -2765,7 +2787,7 @@ var InvitationsHandler = class {
2765
2787
  await ctx.dispose();
2766
2788
  } else {
2767
2789
  invariant9(invitation.swarmKey, void 0, {
2768
- F: __dxlog_file12,
2790
+ F: __dxlog_file13,
2769
2791
  L: 345,
2770
2792
  S: this,
2771
2793
  A: [
@@ -2859,16 +2881,29 @@ var InvitationsHandler = class {
2859
2881
  };
2860
2882
  }
2861
2883
  _logStateUpdate(invitation, actor, newState) {
2862
- log10("invitation state update", {
2863
- actor: actor?.constructor.name,
2864
- newState: stateToString(newState),
2865
- oldState: stateToString(invitation.state)
2866
- }, {
2867
- F: __dxlog_file12,
2868
- L: 438,
2869
- S: this,
2870
- C: (f, a) => f(...a)
2871
- });
2884
+ if (this._isNotTerminal(newState)) {
2885
+ log10("invitation state update", {
2886
+ actor: actor?.constructor.name,
2887
+ newState: stateToString(newState),
2888
+ oldState: stateToString(invitation.state)
2889
+ }, {
2890
+ F: __dxlog_file13,
2891
+ L: 439,
2892
+ S: this,
2893
+ C: (f, a) => f(...a)
2894
+ });
2895
+ } else {
2896
+ log10.info("invitation state update", {
2897
+ actor: actor?.constructor.name,
2898
+ newState: stateToString(newState),
2899
+ oldState: stateToString(invitation.state)
2900
+ }, {
2901
+ F: __dxlog_file13,
2902
+ L: 445,
2903
+ S: this,
2904
+ C: (f, a) => f(...a)
2905
+ });
2906
+ }
2872
2907
  }
2873
2908
  _isNotTerminal(currentState) {
2874
2909
  return ![
@@ -2882,16 +2917,16 @@ var InvitationsHandler = class {
2882
2917
  async _handleGuestOtpAuth(extension, setState, authenticated, options) {
2883
2918
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2884
2919
  log10("guest waiting for authentication code...", void 0, {
2885
- F: __dxlog_file12,
2886
- L: 462,
2920
+ F: __dxlog_file13,
2921
+ L: 470,
2887
2922
  S: this,
2888
2923
  C: (f, a) => f(...a)
2889
2924
  });
2890
2925
  setState(Invitation4.State.READY_FOR_AUTHENTICATION);
2891
2926
  const authCode = await authenticated.wait(options);
2892
2927
  log10("sending authentication request", void 0, {
2893
- F: __dxlog_file12,
2894
- L: 466,
2928
+ F: __dxlog_file13,
2929
+ L: 474,
2895
2930
  S: this,
2896
2931
  C: (f, a) => f(...a)
2897
2932
  });
@@ -2909,8 +2944,8 @@ var InvitationsHandler = class {
2909
2944
  log10("retrying invalid code", {
2910
2945
  attempt
2911
2946
  }, {
2912
- F: __dxlog_file12,
2913
- L: 477,
2947
+ F: __dxlog_file13,
2948
+ L: 485,
2914
2949
  S: this,
2915
2950
  C: (f, a) => f(...a)
2916
2951
  });
@@ -2927,8 +2962,8 @@ var InvitationsHandler = class {
2927
2962
  throw new Error("challenge missing in the introduction");
2928
2963
  }
2929
2964
  log10("sending authentication request", void 0, {
2930
- F: __dxlog_file12,
2931
- L: 496,
2965
+ F: __dxlog_file13,
2966
+ L: 504,
2932
2967
  S: this,
2933
2968
  C: (f, a) => f(...a)
2934
2969
  });
@@ -3048,14 +3083,14 @@ var InvitationsServiceImpl = class {
3048
3083
  };
3049
3084
 
3050
3085
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
3051
- import { createAdmissionCredentials, createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3086
+ import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3052
3087
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
3053
3088
  import { invariant as invariant10 } from "@dxos/invariant";
3054
3089
  import { log as log11 } from "@dxos/log";
3055
3090
  import { AlreadyJoinedError as AlreadyJoinedError2, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from "@dxos/protocols";
3056
3091
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
3057
3092
  import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
3058
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
3093
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
3059
3094
  var SpaceInvitationProtocol = class {
3060
3095
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
3061
3096
  this._spaceManager = _spaceManager;
@@ -3089,79 +3124,43 @@ var SpaceInvitationProtocol = class {
3089
3124
  };
3090
3125
  }
3091
3126
  async admit(invitation, request, guestProfile) {
3092
- invariant10(this._spaceKey, void 0, {
3093
- F: __dxlog_file13,
3094
- L: 76,
3095
- S: this,
3096
- A: [
3097
- "this._spaceKey",
3098
- ""
3099
- ]
3100
- });
3101
- const space = this._spaceManager.spaces.get(this._spaceKey);
3102
- invariant10(space, void 0, {
3103
- F: __dxlog_file13,
3104
- L: 78,
3105
- S: this,
3106
- A: [
3107
- "space",
3108
- ""
3109
- ]
3110
- });
3111
- invariant10(request.space, void 0, {
3112
- F: __dxlog_file13,
3113
- L: 80,
3127
+ invariant10(this._spaceKey && request.space, void 0, {
3128
+ F: __dxlog_file14,
3129
+ L: 74,
3114
3130
  S: this,
3115
3131
  A: [
3116
- "request.space",
3132
+ "this._spaceKey && request.space",
3117
3133
  ""
3118
3134
  ]
3119
3135
  });
3120
- const { identityKey, deviceKey } = request.space;
3121
- if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember2.Role.REMOVED) {
3122
- throw new AlreadyJoinedError2();
3123
- }
3124
3136
  log11("writing guest credentials", {
3125
3137
  host: this._signingContext.deviceKey,
3126
- guest: deviceKey
3138
+ guest: request.space.deviceKey
3127
3139
  }, {
3128
- F: __dxlog_file13,
3129
- L: 87,
3140
+ F: __dxlog_file14,
3141
+ L: 75,
3130
3142
  S: this,
3131
3143
  C: (f, a) => f(...a)
3132
3144
  });
3133
- const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, invitation.role ?? SpaceMember2.Role.ADMIN, space.inner.spaceState.membershipChainHeads, guestProfile, invitation.delegationCredentialId);
3134
- invariant10(credentials[0].credential, void 0, {
3135
- F: __dxlog_file13,
3136
- L: 101,
3137
- S: this,
3138
- A: [
3139
- "credentials[0].credential",
3140
- ""
3141
- ]
3142
- });
3143
- const spaceMemberCredential = credentials[0].credential.credential;
3144
- invariant10(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3145
- F: __dxlog_file13,
3146
- L: 103,
3147
- S: this,
3148
- A: [
3149
- "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
3150
- ""
3151
- ]
3145
+ const spaceMemberCredential = await this._spaceManager.admitMember({
3146
+ spaceKey: this._spaceKey,
3147
+ identityKey: request.space.identityKey,
3148
+ role: invitation.role ?? SpaceMember2.Role.ADMIN,
3149
+ profile: guestProfile,
3150
+ delegationCredentialId: invitation.delegationCredentialId
3152
3151
  });
3153
- await writeMessages2(space.inner.controlPipeline.writer, credentials);
3152
+ const space = this._spaceManager.spaces.get(this._spaceKey);
3154
3153
  return {
3155
3154
  space: {
3156
3155
  credential: spaceMemberCredential,
3157
- controlTimeframe: space.inner.controlPipeline.state.timeframe
3156
+ controlTimeframe: space?.inner.controlPipeline.state.timeframe
3158
3157
  }
3159
3158
  };
3160
3159
  }
3161
3160
  async delegate(invitation) {
3162
3161
  invariant10(this._spaceKey, void 0, {
3163
- F: __dxlog_file13,
3164
- L: 116,
3162
+ F: __dxlog_file14,
3163
+ L: 95,
3165
3164
  S: this,
3166
3165
  A: [
3167
3166
  "this._spaceKey",
@@ -3170,8 +3169,8 @@ var SpaceInvitationProtocol = class {
3170
3169
  });
3171
3170
  const space = this._spaceManager.spaces.get(this._spaceKey);
3172
3171
  invariant10(space, void 0, {
3173
- F: __dxlog_file13,
3174
- L: 118,
3172
+ F: __dxlog_file14,
3173
+ L: 97,
3175
3174
  S: this,
3176
3175
  A: [
3177
3176
  "space",
@@ -3180,8 +3179,8 @@ var SpaceInvitationProtocol = class {
3180
3179
  });
3181
3180
  if (invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY) {
3182
3181
  invariant10(invitation.guestKeypair?.publicKey, void 0, {
3183
- F: __dxlog_file13,
3184
- L: 120,
3182
+ F: __dxlog_file14,
3183
+ L: 99,
3185
3184
  S: this,
3186
3185
  A: [
3187
3186
  "invitation.guestKeypair?.publicKey",
@@ -3193,8 +3192,8 @@ var SpaceInvitationProtocol = class {
3193
3192
  host: this._signingContext.deviceKey,
3194
3193
  id: invitation.invitationId
3195
3194
  }, {
3196
- F: __dxlog_file13,
3197
- L: 123,
3195
+ F: __dxlog_file14,
3196
+ L: 102,
3198
3197
  S: this,
3199
3198
  C: (f, a) => f(...a)
3200
3199
  });
@@ -3208,8 +3207,8 @@ var SpaceInvitationProtocol = class {
3208
3207
  guestKey: invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
3209
3208
  });
3210
3209
  invariant10(credential.credential, void 0, {
3211
- F: __dxlog_file13,
3212
- L: 143,
3210
+ F: __dxlog_file14,
3211
+ L: 122,
3213
3212
  S: this,
3214
3213
  A: [
3215
3214
  "credential.credential",
@@ -3223,8 +3222,8 @@ var SpaceInvitationProtocol = class {
3223
3222
  }
3224
3223
  async cancelDelegation(invitation) {
3225
3224
  invariant10(this._spaceKey, void 0, {
3226
- F: __dxlog_file13,
3227
- L: 149,
3225
+ F: __dxlog_file14,
3226
+ L: 128,
3228
3227
  S: this,
3229
3228
  A: [
3230
3229
  "this._spaceKey",
@@ -3232,8 +3231,8 @@ var SpaceInvitationProtocol = class {
3232
3231
  ]
3233
3232
  });
3234
3233
  invariant10(invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
3235
- F: __dxlog_file13,
3236
- L: 150,
3234
+ F: __dxlog_file14,
3235
+ L: 129,
3237
3236
  S: this,
3238
3237
  A: [
3239
3238
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -3242,8 +3241,8 @@ var SpaceInvitationProtocol = class {
3242
3241
  });
3243
3242
  const space = this._spaceManager.spaces.get(this._spaceKey);
3244
3243
  invariant10(space, void 0, {
3245
- F: __dxlog_file13,
3246
- L: 152,
3244
+ F: __dxlog_file14,
3245
+ L: 131,
3247
3246
  S: this,
3248
3247
  A: [
3249
3248
  "space",
@@ -3254,15 +3253,15 @@ var SpaceInvitationProtocol = class {
3254
3253
  host: this._signingContext.deviceKey,
3255
3254
  id: invitation.invitationId
3256
3255
  }, {
3257
- F: __dxlog_file13,
3258
- L: 154,
3256
+ F: __dxlog_file14,
3257
+ L: 133,
3259
3258
  S: this,
3260
3259
  C: (f, a) => f(...a)
3261
3260
  });
3262
3261
  const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
3263
3262
  invariant10(credential.credential, void 0, {
3264
- F: __dxlog_file13,
3265
- L: 161,
3263
+ F: __dxlog_file14,
3264
+ L: 140,
3266
3265
  S: this,
3267
3266
  A: [
3268
3267
  "credential.credential",
@@ -3300,8 +3299,8 @@ var SpaceInvitationProtocol = class {
3300
3299
  }
3301
3300
  async accept(response) {
3302
3301
  invariant10(response.space, void 0, {
3303
- F: __dxlog_file13,
3304
- L: 196,
3302
+ F: __dxlog_file14,
3303
+ L: 175,
3305
3304
  S: this,
3306
3305
  A: [
3307
3306
  "response.space",
@@ -3311,8 +3310,8 @@ var SpaceInvitationProtocol = class {
3311
3310
  const { credential, controlTimeframe, dataTimeframe } = response.space;
3312
3311
  const assertion = getCredentialAssertion2(credential);
3313
3312
  invariant10(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3314
- F: __dxlog_file13,
3315
- L: 199,
3313
+ F: __dxlog_file14,
3314
+ L: 178,
3316
3315
  S: this,
3317
3316
  A: [
3318
3317
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3320,8 +3319,8 @@ var SpaceInvitationProtocol = class {
3320
3319
  ]
3321
3320
  });
3322
3321
  invariant10(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
3323
- F: __dxlog_file13,
3324
- L: 200,
3322
+ F: __dxlog_file14,
3323
+ L: 179,
3325
3324
  S: this,
3326
3325
  A: [
3327
3326
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -3355,7 +3354,7 @@ import { PublicKey as PublicKey8 } from "@dxos/keys";
3355
3354
  import { log as log12 } from "@dxos/log";
3356
3355
  import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
3357
3356
  import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
3358
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3357
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3359
3358
  var InvitationsManager = class {
3360
3359
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
3361
3360
  this._invitationsHandler = _invitationsHandler;
@@ -3398,7 +3397,7 @@ var InvitationsManager = class {
3398
3397
  await this._persistIfRequired(handler, stream, invitation);
3399
3398
  } catch (err) {
3400
3399
  log12.catch(err, void 0, {
3401
- F: __dxlog_file14,
3400
+ F: __dxlog_file15,
3402
3401
  L: 82,
3403
3402
  S: this,
3404
3403
  C: (f, a) => f(...a)
@@ -3421,7 +3420,7 @@ var InvitationsManager = class {
3421
3420
  const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
3422
3421
  const loadTasks = freshInvitations.map((persistentInvitation) => {
3423
3422
  invariant11(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
3424
- F: __dxlog_file14,
3423
+ F: __dxlog_file15,
3425
3424
  L: 103,
3426
3425
  S: this,
3427
3426
  A: [
@@ -3440,7 +3439,7 @@ var InvitationsManager = class {
3440
3439
  };
3441
3440
  } catch (err) {
3442
3441
  log12.catch(err, void 0, {
3443
- F: __dxlog_file14,
3442
+ F: __dxlog_file15,
3444
3443
  L: 110,
3445
3444
  S: this,
3446
3445
  C: (f, a) => f(...a)
@@ -3472,13 +3471,13 @@ var InvitationsManager = class {
3472
3471
  }
3473
3472
  async authenticate({ invitationId, authCode }) {
3474
3473
  log12("authenticating...", void 0, {
3475
- F: __dxlog_file14,
3474
+ F: __dxlog_file15,
3476
3475
  L: 140,
3477
3476
  S: this,
3478
3477
  C: (f, a) => f(...a)
3479
3478
  });
3480
3479
  invariant11(invitationId, void 0, {
3481
- F: __dxlog_file14,
3480
+ F: __dxlog_file15,
3482
3481
  L: 141,
3483
3482
  S: this,
3484
3483
  A: [
@@ -3491,7 +3490,7 @@ var InvitationsManager = class {
3491
3490
  log12.warn("invalid invitation", {
3492
3491
  invitationId
3493
3492
  }, {
3494
- F: __dxlog_file14,
3493
+ F: __dxlog_file15,
3495
3494
  L: 144,
3496
3495
  S: this,
3497
3496
  C: (f, a) => f(...a)
@@ -3504,13 +3503,13 @@ var InvitationsManager = class {
3504
3503
  log12("cancelInvitation...", {
3505
3504
  invitationId
3506
3505
  }, {
3507
- F: __dxlog_file14,
3506
+ F: __dxlog_file15,
3508
3507
  L: 151,
3509
3508
  S: this,
3510
3509
  C: (f, a) => f(...a)
3511
3510
  });
3512
3511
  invariant11(invitationId, void 0, {
3513
- F: __dxlog_file14,
3512
+ F: __dxlog_file15,
3514
3513
  L: 152,
3515
3514
  S: this,
3516
3515
  A: [
@@ -3584,12 +3583,15 @@ var InvitationsManager = class {
3584
3583
  stream.error(err);
3585
3584
  void ctx.dispose();
3586
3585
  }
3586
+ }, {
3587
+ F: __dxlog_file15,
3588
+ L: 234
3587
3589
  });
3588
3590
  ctx.onDispose(() => {
3589
3591
  log12("complete", {
3590
3592
  ...handler.toJSON()
3591
3593
  }, {
3592
- F: __dxlog_file14,
3594
+ F: __dxlog_file15,
3593
3595
  L: 241,
3594
3596
  S: this,
3595
3597
  C: (f, a) => f(...a)
@@ -3622,7 +3624,7 @@ var InvitationsManager = class {
3622
3624
  log12("timeout", {
3623
3625
  ...handler.toJSON()
3624
3626
  }, {
3625
- F: __dxlog_file14,
3627
+ F: __dxlog_file15,
3626
3628
  L: 261,
3627
3629
  S: this,
3628
3630
  C: (f, a) => f(...a)
@@ -3633,7 +3635,7 @@ var InvitationsManager = class {
3633
3635
  });
3634
3636
  } else {
3635
3637
  log12.warn("auth failed", err, {
3636
- F: __dxlog_file14,
3638
+ F: __dxlog_file15,
3637
3639
  L: 264,
3638
3640
  S: this,
3639
3641
  C: (f, a) => f(...a)
@@ -3645,12 +3647,15 @@ var InvitationsManager = class {
3645
3647
  }
3646
3648
  void ctx.dispose();
3647
3649
  }
3650
+ }, {
3651
+ F: __dxlog_file15,
3652
+ L: 258
3648
3653
  });
3649
3654
  ctx.onDispose(() => {
3650
3655
  log12("complete", {
3651
3656
  ...handler.toJSON()
3652
3657
  }, {
3653
- F: __dxlog_file14,
3658
+ F: __dxlog_file15,
3654
3659
  L: 271,
3655
3660
  S: this,
3656
3661
  C: (f, a) => f(...a)
@@ -3695,7 +3700,7 @@ var InvitationsManager = class {
3695
3700
  await this._metadataStore.removeInvitation(invitation.invitationId);
3696
3701
  } catch (err) {
3697
3702
  log12.catch(err, void 0, {
3698
- F: __dxlog_file14,
3703
+ F: __dxlog_file15,
3699
3704
  L: 307,
3700
3705
  S: this,
3701
3706
  C: (f, a) => f(...a)
@@ -3782,7 +3787,7 @@ import { invariant as invariant12 } from "@dxos/invariant";
3782
3787
  import { log as log13 } from "@dxos/log";
3783
3788
  import { CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
3784
3789
  import { assignDeep } from "@dxos/util";
3785
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
3790
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
3786
3791
  var runEpochMigration = async (ctx, context) => {
3787
3792
  switch (context.migration) {
3788
3793
  case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
@@ -3806,7 +3811,7 @@ var runEpochMigration = async (ctx, context) => {
3806
3811
  }
3807
3812
  case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
3808
3813
  log13.info("Fragmenting", void 0, {
3809
- F: __dxlog_file15,
3814
+ F: __dxlog_file16,
3810
3815
  L: 63,
3811
3816
  S: void 0,
3812
3817
  C: (f, a) => f(...a)
@@ -3818,7 +3823,7 @@ var runEpochMigration = async (ctx, context) => {
3818
3823
  const properties = findInlineObjectOfType(rootHandle.docSync(), TYPE_PROPERTIES);
3819
3824
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3820
3825
  invariant12(properties, "Properties not found", {
3821
- F: __dxlog_file15,
3826
+ F: __dxlog_file16,
3822
3827
  L: 73,
3823
3828
  S: void 0,
3824
3829
  A: [
@@ -3834,7 +3839,7 @@ var runEpochMigration = async (ctx, context) => {
3834
3839
  };
3835
3840
  const newRoot = context.repo.create(newSpaceDoc);
3836
3841
  invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3837
- F: __dxlog_file15,
3842
+ F: __dxlog_file16,
3838
3843
  L: 78,
3839
3844
  S: void 0,
3840
3845
  A: [
@@ -3865,7 +3870,7 @@ var runEpochMigration = async (ctx, context) => {
3865
3870
  const rootHandle = context.repo.find(currentRootUrl);
3866
3871
  await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
3867
3872
  invariant12(rootHandle.docSync(), "Root doc not found", {
3868
- F: __dxlog_file15,
3873
+ F: __dxlog_file16,
3869
3874
  L: 100,
3870
3875
  S: void 0,
3871
3876
  A: [
@@ -3878,7 +3883,7 @@ var runEpochMigration = async (ctx, context) => {
3878
3883
  const handle = context.repo.find(url);
3879
3884
  await cancelWithContext4(ctx, asyncTimeout2(handle.whenReady(), 1e4));
3880
3885
  invariant12(handle.docSync(), "Doc not found", {
3881
- F: __dxlog_file15,
3886
+ F: __dxlog_file16,
3882
3887
  L: 107,
3883
3888
  S: void 0,
3884
3889
  A: [
@@ -3900,7 +3905,7 @@ var runEpochMigration = async (ctx, context) => {
3900
3905
  }
3901
3906
  case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
3902
3907
  invariant12(context.newAutomergeRoot, void 0, {
3903
- F: __dxlog_file15,
3908
+ F: __dxlog_file16,
3904
3909
  L: 124,
3905
3910
  S: void 0,
3906
3911
  A: [
@@ -3926,14 +3931,17 @@ import { log as log14 } from "@dxos/log";
3926
3931
  import { schema as schema4 } from "@dxos/protocols";
3927
3932
  import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
3928
3933
  import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet4, entry } from "@dxos/util";
3929
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3934
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3930
3935
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3931
3936
  var DEFAULT_SUCCESS_DELAY = 1e3;
3932
3937
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
3933
3938
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3934
3939
  var NotarizationPlugin = class {
3935
3940
  constructor() {
3936
- this._ctx = new Context7();
3941
+ this._ctx = new Context7(void 0, {
3942
+ F: __dxlog_file17,
3943
+ L: 62
3944
+ });
3937
3945
  this._extensionOpened = new Event5();
3938
3946
  this._extensions = /* @__PURE__ */ new Set();
3939
3947
  this._processedCredentials = new ComplexSet4(PublicKey9.hash);
@@ -3954,13 +3962,13 @@ var NotarizationPlugin = class {
3954
3962
  log14("notarize", {
3955
3963
  credentials
3956
3964
  }, {
3957
- F: __dxlog_file16,
3965
+ F: __dxlog_file17,
3958
3966
  L: 90,
3959
3967
  S: this,
3960
3968
  C: (f, a) => f(...a)
3961
3969
  });
3962
3970
  invariant13(credentials.every((credential) => credential.id), "Credentials must have an id", {
3963
- F: __dxlog_file16,
3971
+ F: __dxlog_file17,
3964
3972
  L: 91,
3965
3973
  S: this,
3966
3974
  A: [
@@ -3974,7 +3982,7 @@ var NotarizationPlugin = class {
3974
3982
  log14.warn("Notarization error", {
3975
3983
  err
3976
3984
  }, {
3977
- F: __dxlog_file16,
3985
+ F: __dxlog_file17,
3978
3986
  L: 99,
3979
3987
  S: this,
3980
3988
  C: (f, a) => f(...a)
@@ -3990,7 +3998,7 @@ var NotarizationPlugin = class {
3990
3998
  timeout,
3991
3999
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
3992
4000
  }, {
3993
- F: __dxlog_file16,
4001
+ F: __dxlog_file17,
3994
4002
  L: 111,
3995
4003
  S: this,
3996
4004
  C: (f, a) => f(...a)
@@ -4013,7 +4021,7 @@ var NotarizationPlugin = class {
4013
4021
  log14.info("Exhausted all peers to notarize with", {
4014
4022
  retryIn: retryTimeout
4015
4023
  }, {
4016
- F: __dxlog_file16,
4024
+ F: __dxlog_file17,
4017
4025
  L: 136,
4018
4026
  S: this,
4019
4027
  C: (f, a) => f(...a)
@@ -4027,7 +4035,7 @@ var NotarizationPlugin = class {
4027
4035
  peer: peer.localPeerId,
4028
4036
  credentialId: credentials.map((credential) => credential.id)
4029
4037
  }, {
4030
- F: __dxlog_file16,
4038
+ F: __dxlog_file17,
4031
4039
  L: 143,
4032
4040
  S: this,
4033
4041
  C: (f, a) => f(...a)
@@ -4036,7 +4044,7 @@ var NotarizationPlugin = class {
4036
4044
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
4037
4045
  });
4038
4046
  log14("success", void 0, {
4039
- F: __dxlog_file16,
4047
+ F: __dxlog_file17,
4040
4048
  L: 147,
4041
4049
  S: this,
4042
4050
  C: (f, a) => f(...a)
@@ -4045,7 +4053,7 @@ var NotarizationPlugin = class {
4045
4053
  } catch (err) {
4046
4054
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
4047
4055
  log14.info("error notarizing (recoverable)", err, {
4048
- F: __dxlog_file16,
4056
+ F: __dxlog_file17,
4049
4057
  L: 151,
4050
4058
  S: this,
4051
4059
  C: (f, a) => f(...a)
@@ -4063,7 +4071,7 @@ var NotarizationPlugin = class {
4063
4071
  errors.wait()
4064
4072
  ]);
4065
4073
  log14("done", void 0, {
4066
- F: __dxlog_file16,
4074
+ F: __dxlog_file17,
4067
4075
  L: 162,
4068
4076
  S: this,
4069
4077
  C: (f, a) => f(...a)
@@ -4085,7 +4093,7 @@ var NotarizationPlugin = class {
4085
4093
  }
4086
4094
  setWriter(writer) {
4087
4095
  invariant13(!this._writer, "Writer already set.", {
4088
- F: __dxlog_file16,
4096
+ F: __dxlog_file17,
4089
4097
  L: 181,
4090
4098
  S: this,
4091
4099
  A: [
@@ -4110,7 +4118,7 @@ var NotarizationPlugin = class {
4110
4118
  }
4111
4119
  for (const credential of request.credentials ?? []) {
4112
4120
  invariant13(credential.id, "Credential must have an id", {
4113
- F: __dxlog_file16,
4121
+ F: __dxlog_file17,
4114
4122
  L: 200,
4115
4123
  S: this,
4116
4124
  A: [
@@ -4130,7 +4138,7 @@ var NotarizationPlugin = class {
4130
4138
  log14("extension opened", {
4131
4139
  peer: extension.localPeerId
4132
4140
  }, {
4133
- F: __dxlog_file16,
4141
+ F: __dxlog_file17,
4134
4142
  L: 211,
4135
4143
  S: this,
4136
4144
  C: (f, a) => f(...a)
@@ -4142,7 +4150,7 @@ var NotarizationPlugin = class {
4142
4150
  log14("extension closed", {
4143
4151
  peer: extension.localPeerId
4144
4152
  }, {
4145
- F: __dxlog_file16,
4153
+ F: __dxlog_file17,
4146
4154
  L: 216,
4147
4155
  S: this,
4148
4156
  C: (f, a) => f(...a)
@@ -4259,10 +4267,13 @@ function _using_ctx() {
4259
4267
  }
4260
4268
  };
4261
4269
  }
4262
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4270
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4263
4271
  var DataSpace = class {
4264
4272
  constructor(params) {
4265
- this._ctx = new Context8();
4273
+ this._ctx = new Context8(void 0, {
4274
+ F: __dxlog_file18,
4275
+ L: 84
4276
+ });
4266
4277
  this._notarizationPlugin = new NotarizationPlugin();
4267
4278
  this._cache = void 0;
4268
4279
  // TODO(dmaretskyi): Move into Space?
@@ -4296,7 +4307,7 @@ var DataSpace = class {
4296
4307
  log15("new state", {
4297
4308
  state: SpaceState2[this._state]
4298
4309
  }, {
4299
- F: __dxlog_file17,
4310
+ F: __dxlog_file18,
4300
4311
  L: 146,
4301
4312
  S: this,
4302
4313
  C: (f, a) => f(...a)
@@ -4351,12 +4362,15 @@ var DataSpace = class {
4351
4362
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
4352
4363
  await this._automergeSpaceState.open();
4353
4364
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
4354
- await this._inner.open(new Context8());
4365
+ await this._inner.open(new Context8(void 0, {
4366
+ F: __dxlog_file18,
4367
+ L: 215
4368
+ }));
4355
4369
  this._state = SpaceState2.CONTROL_ONLY;
4356
4370
  log15("new state", {
4357
4371
  state: SpaceState2[this._state]
4358
4372
  }, {
4359
- F: __dxlog_file17,
4373
+ F: __dxlog_file18,
4360
4374
  L: 217,
4361
4375
  S: this,
4362
4376
  C: (f, a) => f(...a)
@@ -4374,13 +4388,16 @@ var DataSpace = class {
4374
4388
  log15("new state", {
4375
4389
  state: SpaceState2[this._state]
4376
4390
  }, {
4377
- F: __dxlog_file17,
4391
+ F: __dxlog_file18,
4378
4392
  L: 231,
4379
4393
  S: this,
4380
4394
  C: (f, a) => f(...a)
4381
4395
  });
4382
4396
  await this._ctx.dispose();
4383
- this._ctx = new Context8();
4397
+ this._ctx = new Context8(void 0, {
4398
+ F: __dxlog_file18,
4399
+ L: 233
4400
+ });
4384
4401
  await this.authVerifier.close();
4385
4402
  await this._inner.close();
4386
4403
  await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
@@ -4407,7 +4424,7 @@ var DataSpace = class {
4407
4424
  } catch (err) {
4408
4425
  if (err instanceof CancelledError || err instanceof ContextDisposedError3) {
4409
4426
  log15("data pipeline initialization cancelled", err, {
4410
- F: __dxlog_file17,
4427
+ F: __dxlog_file18,
4411
4428
  L: 265,
4412
4429
  S: this,
4413
4430
  C: (f, a) => f(...a)
@@ -4415,7 +4432,7 @@ var DataSpace = class {
4415
4432
  return;
4416
4433
  }
4417
4434
  log15.error("Error initializing data pipeline", err, {
4418
- F: __dxlog_file17,
4435
+ F: __dxlog_file18,
4419
4436
  L: 269,
4420
4437
  S: this,
4421
4438
  C: (f, a) => f(...a)
@@ -4424,7 +4441,7 @@ var DataSpace = class {
4424
4441
  log15("new state", {
4425
4442
  state: SpaceState2[this._state]
4426
4443
  }, {
4427
- F: __dxlog_file17,
4444
+ F: __dxlog_file18,
4428
4445
  L: 271,
4429
4446
  S: this,
4430
4447
  C: (f, a) => f(...a)
@@ -4444,7 +4461,7 @@ var DataSpace = class {
4444
4461
  log15("new state", {
4445
4462
  state: SpaceState2[this._state]
4446
4463
  }, {
4447
- F: __dxlog_file17,
4464
+ F: __dxlog_file18,
4448
4465
  L: 287,
4449
4466
  S: this,
4450
4467
  C: (f, a) => f(...a)
@@ -4461,7 +4478,7 @@ var DataSpace = class {
4461
4478
  log15("new state", {
4462
4479
  state: SpaceState2[this._state]
4463
4480
  }, {
4464
- F: __dxlog_file17,
4481
+ F: __dxlog_file18,
4465
4482
  L: 306,
4466
4483
  S: this,
4467
4484
  C: (f, a) => f(...a)
@@ -4477,7 +4494,7 @@ var DataSpace = class {
4477
4494
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
4478
4495
  await this._createWritableFeeds();
4479
4496
  log15("writable feeds created", void 0, {
4480
- F: __dxlog_file17,
4497
+ F: __dxlog_file18,
4481
4498
  L: 322,
4482
4499
  S: this,
4483
4500
  C: (f, a) => f(...a)
@@ -4540,7 +4557,7 @@ var DataSpace = class {
4540
4557
  space: this.key,
4541
4558
  rootUrl
4542
4559
  }, {
4543
- F: __dxlog_file17,
4560
+ F: __dxlog_file18,
4544
4561
  L: 388,
4545
4562
  S: this,
4546
4563
  C: (f, a) => f(...a)
@@ -4594,7 +4611,7 @@ var DataSpace = class {
4594
4611
  rootUrl,
4595
4612
  err
4596
4613
  }, {
4597
- F: __dxlog_file17,
4614
+ F: __dxlog_file18,
4598
4615
  L: 431,
4599
4616
  S: this,
4600
4617
  C: (f, a) => f(...a)
@@ -4680,7 +4697,7 @@ var DataSpace = class {
4680
4697
  log15("new state", {
4681
4698
  state: SpaceState2[this._state]
4682
4699
  }, {
4683
- F: __dxlog_file17,
4700
+ F: __dxlog_file18,
4684
4701
  L: 512,
4685
4702
  S: this,
4686
4703
  C: (f, a) => f(...a)
@@ -4741,15 +4758,17 @@ DataSpace = _ts_decorate4([
4741
4758
  import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
4742
4759
  import { PropertiesType } from "@dxos/client-protocol";
4743
4760
  import { Context as Context9, cancelWithContext as cancelWithContext6 } from "@dxos/context";
4744
- import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
4761
+ import { getCredentialAssertion as getCredentialAssertion3, createAdmissionCredentials } from "@dxos/credentials";
4745
4762
  import { convertLegacyReferences as convertLegacyReferences2, findInlineObjectOfType as findInlineObjectOfType2 } from "@dxos/echo-db";
4746
4763
  import { AuthStatus } from "@dxos/echo-pipeline";
4764
+ import { CredentialServerExtension } from "@dxos/echo-pipeline";
4747
4765
  import { LEGACY_TYPE_PROPERTIES, SpaceDocVersion as SpaceDocVersion2, encodeReference } from "@dxos/echo-protocol";
4748
4766
  import { TYPE_PROPERTIES as TYPE_PROPERTIES2, generateEchoId, getTypeReference } from "@dxos/echo-schema";
4767
+ import { writeMessages as writeMessages3 } from "@dxos/feed-store";
4749
4768
  import { invariant as invariant14 } from "@dxos/invariant";
4750
4769
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4751
4770
  import { log as log16 } from "@dxos/log";
4752
- import { trace as Trace2 } from "@dxos/protocols";
4771
+ import { trace as Trace2, AlreadyJoinedError as AlreadyJoinedError3 } from "@dxos/protocols";
4753
4772
  import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
4754
4773
  import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
4755
4774
  import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
@@ -4837,7 +4856,7 @@ function _ts_decorate5(decorators, target, key, desc) {
4837
4856
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4838
4857
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4839
4858
  }
4840
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4859
+ var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4841
4860
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
4842
4861
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
4843
4862
  var DEFAULT_SPACE_KEY = "__DEFAULT__";
@@ -4851,7 +4870,10 @@ var DataSpaceManager = class {
4851
4870
  this._echoHost = _echoHost;
4852
4871
  this._invitationsManager = _invitationsManager;
4853
4872
  this._params = _params;
4854
- this._ctx = new Context9();
4873
+ this._ctx = new Context9(void 0, {
4874
+ F: __dxlog_file19,
4875
+ L: 104
4876
+ });
4855
4877
  this.updated = new Event7();
4856
4878
  this._spaces = new ComplexMap3(PublicKey11.hash);
4857
4879
  this._isOpen = false;
@@ -4885,24 +4907,24 @@ var DataSpaceManager = class {
4885
4907
  }
4886
4908
  async open() {
4887
4909
  log16("open", void 0, {
4888
- F: __dxlog_file18,
4889
- L: 146,
4910
+ F: __dxlog_file19,
4911
+ L: 156,
4890
4912
  S: this,
4891
4913
  C: (f, a) => f(...a)
4892
4914
  });
4893
4915
  log16.trace("dxos.echo.data-space-manager.open", Trace2.begin({
4894
4916
  id: this._instanceId
4895
4917
  }), {
4896
- F: __dxlog_file18,
4897
- L: 147,
4918
+ F: __dxlog_file19,
4919
+ L: 157,
4898
4920
  S: this,
4899
4921
  C: (f, a) => f(...a)
4900
4922
  });
4901
4923
  log16("metadata loaded", {
4902
4924
  spaces: this._metadataStore.spaces.length
4903
4925
  }, {
4904
- F: __dxlog_file18,
4905
- L: 148,
4926
+ F: __dxlog_file19,
4927
+ L: 158,
4906
4928
  S: this,
4907
4929
  C: (f, a) => f(...a)
4908
4930
  });
@@ -4911,8 +4933,8 @@ var DataSpaceManager = class {
4911
4933
  log16("load space", {
4912
4934
  spaceMetadata
4913
4935
  }, {
4914
- F: __dxlog_file18,
4915
- L: 152,
4936
+ F: __dxlog_file19,
4937
+ L: 162,
4916
4938
  S: this,
4917
4939
  C: (f, a) => f(...a)
4918
4940
  });
@@ -4922,8 +4944,8 @@ var DataSpaceManager = class {
4922
4944
  spaceMetadata,
4923
4945
  err
4924
4946
  }, {
4925
- F: __dxlog_file18,
4926
- L: 155,
4947
+ F: __dxlog_file19,
4948
+ L: 165,
4927
4949
  S: this,
4928
4950
  C: (f, a) => f(...a)
4929
4951
  });
@@ -4934,16 +4956,16 @@ var DataSpaceManager = class {
4934
4956
  log16.trace("dxos.echo.data-space-manager.open", Trace2.end({
4935
4957
  id: this._instanceId
4936
4958
  }), {
4937
- F: __dxlog_file18,
4938
- L: 162,
4959
+ F: __dxlog_file19,
4960
+ L: 172,
4939
4961
  S: this,
4940
4962
  C: (f, a) => f(...a)
4941
4963
  });
4942
4964
  }
4943
4965
  async close() {
4944
4966
  log16("close", void 0, {
4945
- F: __dxlog_file18,
4946
- L: 167,
4967
+ F: __dxlog_file19,
4968
+ L: 177,
4947
4969
  S: this,
4948
4970
  C: (f, a) => f(...a)
4949
4971
  });
@@ -4959,8 +4981,8 @@ var DataSpaceManager = class {
4959
4981
  */
4960
4982
  async createSpace() {
4961
4983
  invariant14(this._isOpen, "Not open.", {
4962
- F: __dxlog_file18,
4963
- L: 181,
4984
+ F: __dxlog_file19,
4985
+ L: 191,
4964
4986
  S: this,
4965
4987
  A: [
4966
4988
  "this._isOpen",
@@ -4980,8 +5002,8 @@ var DataSpaceManager = class {
4980
5002
  log16("creating space...", {
4981
5003
  spaceKey
4982
5004
  }, {
4983
- F: __dxlog_file18,
4984
- L: 193,
5005
+ F: __dxlog_file19,
5006
+ L: 203,
4985
5007
  S: this,
4986
5008
  C: (f, a) => f(...a)
4987
5009
  });
@@ -4992,8 +5014,8 @@ var DataSpaceManager = class {
4992
5014
  await this._metadataStore.addSpace(metadata);
4993
5015
  const memberCredential = credentials[1];
4994
5016
  invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4995
- F: __dxlog_file18,
4996
- L: 203,
5017
+ F: __dxlog_file19,
5018
+ L: 213,
4997
5019
  S: this,
4998
5020
  A: [
4999
5021
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -5024,8 +5046,8 @@ var DataSpaceManager = class {
5024
5046
  version: space.databaseRoot.getVersion(),
5025
5047
  spaceId: space.id
5026
5048
  }, {
5027
- F: __dxlog_file18,
5028
- L: 228,
5049
+ F: __dxlog_file19,
5050
+ L: 238,
5029
5051
  S: this,
5030
5052
  C: (f, a) => f(...a)
5031
5053
  });
@@ -5059,8 +5081,8 @@ var DataSpaceManager = class {
5059
5081
  async _getSpaceRootDocument(space) {
5060
5082
  const automergeIndex = space.automergeSpaceState.rootUrl;
5061
5083
  invariant14(automergeIndex, void 0, {
5062
- F: __dxlog_file18,
5063
- L: 261,
5084
+ F: __dxlog_file19,
5085
+ L: 271,
5064
5086
  S: this,
5065
5087
  A: [
5066
5088
  "automergeIndex",
@@ -5076,14 +5098,14 @@ var DataSpaceManager = class {
5076
5098
  log16("accept space", {
5077
5099
  opts
5078
5100
  }, {
5079
- F: __dxlog_file18,
5080
- L: 270,
5101
+ F: __dxlog_file19,
5102
+ L: 280,
5081
5103
  S: this,
5082
5104
  C: (f, a) => f(...a)
5083
5105
  });
5084
5106
  invariant14(this._isOpen, "Not open.", {
5085
- F: __dxlog_file18,
5086
- L: 271,
5107
+ F: __dxlog_file19,
5108
+ L: 281,
5087
5109
  S: this,
5088
5110
  A: [
5089
5111
  "this._isOpen",
@@ -5091,8 +5113,8 @@ var DataSpaceManager = class {
5091
5113
  ]
5092
5114
  });
5093
5115
  invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
5094
- F: __dxlog_file18,
5095
- L: 272,
5116
+ F: __dxlog_file19,
5117
+ L: 282,
5096
5118
  S: this,
5097
5119
  A: [
5098
5120
  "!this._spaces.has(opts.spaceKey)",
@@ -5112,6 +5134,43 @@ var DataSpaceManager = class {
5112
5134
  this.updated.emit();
5113
5135
  return space;
5114
5136
  }
5137
+ async admitMember(options) {
5138
+ const space = this._spaceManager.spaces.get(options.spaceKey);
5139
+ invariant14(space, void 0, {
5140
+ F: __dxlog_file19,
5141
+ L: 302,
5142
+ S: this,
5143
+ A: [
5144
+ "space",
5145
+ ""
5146
+ ]
5147
+ });
5148
+ if (space.spaceState.getMemberRole(options.identityKey) !== SpaceMember6.Role.REMOVED) {
5149
+ throw new AlreadyJoinedError3();
5150
+ }
5151
+ const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
5152
+ invariant14(credentials[0].credential, void 0, {
5153
+ F: __dxlog_file19,
5154
+ L: 321,
5155
+ S: this,
5156
+ A: [
5157
+ "credentials[0].credential",
5158
+ ""
5159
+ ]
5160
+ });
5161
+ const spaceMemberCredential = credentials[0].credential.credential;
5162
+ invariant14(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5163
+ F: __dxlog_file19,
5164
+ L: 323,
5165
+ S: this,
5166
+ A: [
5167
+ "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5168
+ ""
5169
+ ]
5170
+ });
5171
+ await writeMessages3(space.controlPipeline.writer, credentials);
5172
+ return spaceMemberCredential;
5173
+ }
5115
5174
  /**
5116
5175
  * Wait until the space data pipeline is fully initialized.
5117
5176
  * Used by invitation handler.
@@ -5123,12 +5182,24 @@ var DataSpaceManager = class {
5123
5182
  return !!space && space.state === SpaceState3.READY;
5124
5183
  }));
5125
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
+ }
5126
5197
  async _constructSpace(metadata) {
5127
5198
  log16("construct space", {
5128
5199
  metadata
5129
5200
  }, {
5130
- F: __dxlog_file18,
5131
- L: 306,
5201
+ F: __dxlog_file19,
5202
+ L: 358,
5132
5203
  S: this,
5133
5204
  C: (f, a) => f(...a)
5134
5205
  });
@@ -5156,6 +5227,7 @@ var DataSpaceManager = class {
5156
5227
  credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
5157
5228
  },
5158
5229
  onAuthorizedConnection: (session) => {
5230
+ session.addExtension("dxos.mesh.teleport.admission-discovery", new CredentialServerExtension(space));
5159
5231
  session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5160
5232
  remotePeerId: session.remotePeerId
5161
5233
  }));
@@ -5165,8 +5237,8 @@ var DataSpaceManager = class {
5165
5237
  },
5166
5238
  onAuthFailure: () => {
5167
5239
  log16.warn("auth failure", void 0, {
5168
- F: __dxlog_file18,
5169
- L: 343,
5240
+ F: __dxlog_file19,
5241
+ L: 396,
5170
5242
  S: this,
5171
5243
  C: (f, a) => f(...a)
5172
5244
  });
@@ -5198,8 +5270,8 @@ var DataSpaceManager = class {
5198
5270
  log16("before space ready", {
5199
5271
  space: space.key
5200
5272
  }, {
5201
- F: __dxlog_file18,
5202
- L: 370,
5273
+ F: __dxlog_file19,
5274
+ L: 423,
5203
5275
  S: this,
5204
5276
  C: (f, a) => f(...a)
5205
5277
  });
@@ -5209,8 +5281,8 @@ var DataSpaceManager = class {
5209
5281
  space: space.key,
5210
5282
  open: this._isOpen
5211
5283
  }, {
5212
- F: __dxlog_file18,
5213
- L: 373,
5284
+ F: __dxlog_file19,
5285
+ L: 426,
5214
5286
  S: this,
5215
5287
  C: (f, a) => f(...a)
5216
5288
  });
@@ -5228,8 +5300,8 @@ var DataSpaceManager = class {
5228
5300
  log16("before space close", {
5229
5301
  space: space.key
5230
5302
  }, {
5231
- F: __dxlog_file18,
5232
- L: 381,
5303
+ F: __dxlog_file19,
5304
+ L: 434,
5233
5305
  S: this,
5234
5306
  C: (f, a) => f(...a)
5235
5307
  });
@@ -5269,8 +5341,8 @@ var DataSpaceManager = class {
5269
5341
  peersOnline: presence.getPeersOnline().length,
5270
5342
  closedSessions
5271
5343
  }, {
5272
- F: __dxlog_file18,
5273
- L: 417,
5344
+ F: __dxlog_file19,
5345
+ L: 470,
5274
5346
  S: this,
5275
5347
  C: (f, a) => f(...a)
5276
5348
  });
@@ -5284,8 +5356,8 @@ var DataSpaceManager = class {
5284
5356
  log16("closing a session with a removed peer", {
5285
5357
  peerId: peerState.peerId
5286
5358
  }, {
5287
- F: __dxlog_file18,
5288
- L: 431,
5359
+ F: __dxlog_file19,
5360
+ L: 484,
5289
5361
  S: this,
5290
5362
  C: (f, a) => f(...a)
5291
5363
  });
@@ -5350,13 +5422,13 @@ import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTas
5350
5422
  import { Stream as Stream10 } from "@dxos/codec-protobuf";
5351
5423
  import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
5352
5424
  import { raise as raise2 } from "@dxos/debug";
5353
- import { writeMessages as writeMessages3 } from "@dxos/feed-store";
5425
+ import { writeMessages as writeMessages4 } from "@dxos/feed-store";
5354
5426
  import { invariant as invariant15 } from "@dxos/invariant";
5355
5427
  import { log as log17 } from "@dxos/log";
5356
5428
  import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
5357
5429
  import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
5358
5430
  import { trace as trace8 } from "@dxos/tracing";
5359
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5431
+ var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5360
5432
  var SpacesServiceImpl = class {
5361
5433
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
5362
5434
  this._identityManager = _identityManager;
@@ -5400,8 +5472,8 @@ var SpacesServiceImpl = class {
5400
5472
  }
5401
5473
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
5402
5474
  invariant15(credentials[0].credential, void 0, {
5403
- F: __dxlog_file19,
5404
- L: 98,
5475
+ F: __dxlog_file20,
5476
+ L: 102,
5405
5477
  S: this,
5406
5478
  A: [
5407
5479
  "credentials[0].credential",
@@ -5410,15 +5482,15 @@ var SpacesServiceImpl = class {
5410
5482
  });
5411
5483
  const spaceMemberCredential = credentials[0].credential.credential;
5412
5484
  invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5413
- F: __dxlog_file19,
5414
- L: 100,
5485
+ F: __dxlog_file20,
5486
+ L: 104,
5415
5487
  S: this,
5416
5488
  A: [
5417
5489
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5418
5490
  ""
5419
5491
  ]
5420
5492
  });
5421
- await writeMessages3(space.controlPipeline.writer, credentials);
5493
+ await writeMessages4(space.controlPipeline.writer, credentials);
5422
5494
  }
5423
5495
  querySpaces() {
5424
5496
  return new Stream10(({ next, ctx }) => {
@@ -5428,8 +5500,8 @@ var SpacesServiceImpl = class {
5428
5500
  log17("update", {
5429
5501
  spaces
5430
5502
  }, {
5431
- F: __dxlog_file19,
5432
- L: 111,
5503
+ F: __dxlog_file20,
5504
+ L: 115,
5433
5505
  S: this,
5434
5506
  C: (f, a) => f(...a)
5435
5507
  });
@@ -5520,8 +5592,8 @@ var SpacesServiceImpl = class {
5520
5592
  });
5521
5593
  } else {
5522
5594
  invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
5523
- F: __dxlog_file19,
5524
- L: 209,
5595
+ F: __dxlog_file20,
5596
+ L: 213,
5525
5597
  S: this,
5526
5598
  A: [
5527
5599
  "!credential.id",
@@ -5529,8 +5601,8 @@ var SpacesServiceImpl = class {
5529
5601
  ]
5530
5602
  });
5531
5603
  invariant15(this._identityManager.identity, "Identity is not available", {
5532
- F: __dxlog_file19,
5533
- L: 210,
5604
+ F: __dxlog_file20,
5605
+ L: 214,
5534
5606
  S: this,
5535
5607
  A: [
5536
5608
  "this._identityManager.identity",
@@ -5539,8 +5611,8 @@ var SpacesServiceImpl = class {
5539
5611
  });
5540
5612
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
5541
5613
  invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
5542
- F: __dxlog_file19,
5543
- L: 212,
5614
+ F: __dxlog_file20,
5615
+ L: 216,
5544
5616
  S: this,
5545
5617
  A: [
5546
5618
  "credential.issuer.equals(signer.getIssuer())",
@@ -5570,6 +5642,59 @@ var SpacesServiceImpl = class {
5570
5642
  epochCredential: credential ?? void 0
5571
5643
  };
5572
5644
  }
5645
+ async admitContact(request) {
5646
+ const dataSpaceManager = await this._getDataSpaceManager();
5647
+ await dataSpaceManager.admitMember({
5648
+ spaceKey: request.spaceKey,
5649
+ identityKey: request.contact.identityKey,
5650
+ role: request.role
5651
+ });
5652
+ }
5653
+ async joinBySpaceKey({ spaceKey }) {
5654
+ const dataSpaceManager = await this._getDataSpaceManager();
5655
+ const credential = await dataSpaceManager.requestSpaceAdmissionCredential(spaceKey);
5656
+ return this._joinByAdmission({
5657
+ credential
5658
+ });
5659
+ }
5660
+ async _joinByAdmission({ credential }) {
5661
+ const assertion = getCredentialAssertion4(credential);
5662
+ invariant15(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
5663
+ F: __dxlog_file20,
5664
+ L: 250,
5665
+ S: this,
5666
+ A: [
5667
+ "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
5668
+ "'Invalid credential'"
5669
+ ]
5670
+ });
5671
+ const myIdentity = this._identityManager.identity;
5672
+ invariant15(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
5673
+ F: __dxlog_file20,
5674
+ L: 252,
5675
+ S: this,
5676
+ A: [
5677
+ "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
5678
+ ""
5679
+ ]
5680
+ });
5681
+ const dataSpaceManager = await this._getDataSpaceManager();
5682
+ let dataSpace = dataSpaceManager.spaces.get(assertion.spaceKey);
5683
+ if (!dataSpace) {
5684
+ dataSpace = await dataSpaceManager.acceptSpace({
5685
+ spaceKey: assertion.spaceKey,
5686
+ genesisFeedKey: assertion.genesisFeedKey
5687
+ });
5688
+ await myIdentity.controlPipeline.writer.write({
5689
+ credential: {
5690
+ credential
5691
+ }
5692
+ });
5693
+ }
5694
+ return {
5695
+ space: this._serializeSpace(dataSpace)
5696
+ };
5697
+ }
5573
5698
  _serializeSpace(space) {
5574
5699
  return {
5575
5700
  id: space.id,
@@ -5657,7 +5782,7 @@ function _ts_decorate6(decorators, target, key, desc) {
5657
5782
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5658
5783
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5659
5784
  }
5660
- var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5785
+ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5661
5786
  var ServiceContext = class extends Resource3 {
5662
5787
  constructor(storage, level, networkManager, signalManager, _runtimeParams) {
5663
5788
  super();
@@ -5701,7 +5826,7 @@ var ServiceContext = class extends Resource3 {
5701
5826
  async _open(ctx) {
5702
5827
  await this._checkStorageVersion();
5703
5828
  log18("opening...", void 0, {
5704
- F: __dxlog_file20,
5829
+ F: __dxlog_file21,
5705
5830
  L: 149,
5706
5831
  S: this,
5707
5832
  C: (f, a) => f(...a)
@@ -5709,7 +5834,7 @@ var ServiceContext = class extends Resource3 {
5709
5834
  log18.trace("dxos.sdk.service-context.open", trace9.begin({
5710
5835
  id: this._instanceId
5711
5836
  }), {
5712
- F: __dxlog_file20,
5837
+ F: __dxlog_file21,
5713
5838
  L: 150,
5714
5839
  S: this,
5715
5840
  C: (f, a) => f(...a)
@@ -5727,7 +5852,7 @@ var ServiceContext = class extends Resource3 {
5727
5852
  log18("loaded persistent invitations", {
5728
5853
  count: loadedInvitations.invitations?.length
5729
5854
  }, {
5730
- F: __dxlog_file20,
5855
+ F: __dxlog_file21,
5731
5856
  L: 163,
5732
5857
  S: this,
5733
5858
  C: (f, a) => f(...a)
@@ -5735,13 +5860,13 @@ var ServiceContext = class extends Resource3 {
5735
5860
  log18.trace("dxos.sdk.service-context.open", trace9.end({
5736
5861
  id: this._instanceId
5737
5862
  }), {
5738
- F: __dxlog_file20,
5863
+ F: __dxlog_file21,
5739
5864
  L: 165,
5740
5865
  S: this,
5741
5866
  C: (f, a) => f(...a)
5742
5867
  });
5743
5868
  log18("opened", void 0, {
5744
- F: __dxlog_file20,
5869
+ F: __dxlog_file21,
5745
5870
  L: 166,
5746
5871
  S: this,
5747
5872
  C: (f, a) => f(...a)
@@ -5749,7 +5874,7 @@ var ServiceContext = class extends Resource3 {
5749
5874
  }
5750
5875
  async _close(ctx) {
5751
5876
  log18("closing...", void 0, {
5752
- F: __dxlog_file20,
5877
+ F: __dxlog_file21,
5753
5878
  L: 170,
5754
5879
  S: this,
5755
5880
  C: (f, a) => f(...a)
@@ -5766,7 +5891,7 @@ var ServiceContext = class extends Resource3 {
5766
5891
  await this.networkManager.close();
5767
5892
  await this.signalManager.close();
5768
5893
  log18("closed", void 0, {
5769
- F: __dxlog_file20,
5894
+ F: __dxlog_file21,
5770
5895
  L: 182,
5771
5896
  S: this,
5772
5897
  C: (f, a) => f(...a)
@@ -5774,13 +5899,16 @@ var ServiceContext = class extends Resource3 {
5774
5899
  }
5775
5900
  async createIdentity(params = {}) {
5776
5901
  const identity = await this.identityManager.createIdentity(params);
5777
- await this._initialize(new Context10());
5902
+ await this._initialize(new Context10(void 0, {
5903
+ F: __dxlog_file21,
5904
+ L: 187
5905
+ }));
5778
5906
  return identity;
5779
5907
  }
5780
5908
  getInvitationHandler(invitation) {
5781
5909
  const factory = this._handlerFactories.get(invitation.kind);
5782
5910
  invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
5783
- F: __dxlog_file20,
5911
+ F: __dxlog_file21,
5784
5912
  L: 193,
5785
5913
  S: this,
5786
5914
  A: [
@@ -5800,7 +5928,10 @@ var ServiceContext = class extends Resource3 {
5800
5928
  }
5801
5929
  async _acceptIdentity(params) {
5802
5930
  const identity = await this.identityManager.acceptIdentity(params);
5803
- await this._initialize(new Context10());
5931
+ await this._initialize(new Context10(void 0, {
5932
+ F: __dxlog_file21,
5933
+ L: 209
5934
+ }));
5804
5935
  return identity;
5805
5936
  }
5806
5937
  async _checkStorageVersion() {
@@ -5812,7 +5943,7 @@ var ServiceContext = class extends Resource3 {
5812
5943
  // Called when identity is created.
5813
5944
  async _initialize(ctx) {
5814
5945
  log18("initializing spaces...", void 0, {
5815
- F: __dxlog_file20,
5946
+ F: __dxlog_file21,
5816
5947
  L: 224,
5817
5948
  S: this,
5818
5949
  C: (f, a) => f(...a)
@@ -5835,7 +5966,7 @@ var ServiceContext = class extends Resource3 {
5835
5966
  await this.dataSpaceManager.open();
5836
5967
  this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
5837
5968
  invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
5838
- F: __dxlog_file20,
5969
+ F: __dxlog_file21,
5839
5970
  L: 249,
5840
5971
  S: this,
5841
5972
  A: [
@@ -5859,7 +5990,7 @@ var ServiceContext = class extends Resource3 {
5859
5990
  log18("dataSpaceManager not initialized yet, ignoring space admission", {
5860
5991
  details: assertion
5861
5992
  }, {
5862
- F: __dxlog_file20,
5993
+ F: __dxlog_file21,
5863
5994
  L: 265,
5864
5995
  S: this,
5865
5996
  C: (f, a) => f(...a)
@@ -5870,7 +6001,7 @@ var ServiceContext = class extends Resource3 {
5870
6001
  log18("space already exists, ignoring space admission", {
5871
6002
  details: assertion
5872
6003
  }, {
5873
- F: __dxlog_file20,
6004
+ F: __dxlog_file21,
5874
6005
  L: 269,
5875
6006
  S: this,
5876
6007
  C: (f, a) => f(...a)
@@ -5881,7 +6012,7 @@ var ServiceContext = class extends Resource3 {
5881
6012
  log18("accepting space recorded in halo", {
5882
6013
  details: assertion
5883
6014
  }, {
5884
- F: __dxlog_file20,
6015
+ F: __dxlog_file21,
5885
6016
  L: 274,
5886
6017
  S: this,
5887
6018
  C: (f, a) => f(...a)
@@ -5892,7 +6023,7 @@ var ServiceContext = class extends Resource3 {
5892
6023
  });
5893
6024
  } catch (err) {
5894
6025
  log18.catch(err, void 0, {
5895
- F: __dxlog_file20,
6026
+ F: __dxlog_file21,
5896
6027
  L: 280,
5897
6028
  S: this,
5898
6029
  C: (f, a) => f(...a)
@@ -5952,7 +6083,7 @@ function _ts_decorate7(decorators, target, key, desc) {
5952
6083
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5953
6084
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5954
6085
  }
5955
- var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
6086
+ var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
5956
6087
  var Message;
5957
6088
  (function(Message2) {
5958
6089
  Message2["ACQUIRING"] = "acquiring";
@@ -5975,28 +6106,28 @@ var Lock = class {
5975
6106
  });
5976
6107
  try {
5977
6108
  log19("aquiring lock...", void 0, {
5978
- F: __dxlog_file21,
6109
+ F: __dxlog_file22,
5979
6110
  L: 42,
5980
6111
  S: this,
5981
6112
  C: (f, a) => f(...a)
5982
6113
  });
5983
6114
  await asyncTimeout3(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
5984
6115
  log19("acquired lock", void 0, {
5985
- F: __dxlog_file21,
6116
+ F: __dxlog_file22,
5986
6117
  L: 44,
5987
6118
  S: this,
5988
6119
  C: (f, a) => f(...a)
5989
6120
  });
5990
6121
  } catch {
5991
6122
  log19("stealing lock...", void 0, {
5992
- F: __dxlog_file21,
6123
+ F: __dxlog_file22,
5993
6124
  L: 46,
5994
6125
  S: this,
5995
6126
  C: (f, a) => f(...a)
5996
6127
  });
5997
6128
  await this._requestLock(true);
5998
6129
  log19("stolen lock", void 0, {
5999
- F: __dxlog_file21,
6130
+ F: __dxlog_file22,
6000
6131
  L: 48,
6001
6132
  S: this,
6002
6133
  C: (f, a) => f(...a)
@@ -6015,7 +6146,7 @@ var Lock = class {
6015
6146
  log19("requesting lock...", {
6016
6147
  steal
6017
6148
  }, {
6018
- F: __dxlog_file21,
6149
+ F: __dxlog_file22,
6019
6150
  L: 63,
6020
6151
  S: this,
6021
6152
  C: (f, a) => f(...a)
@@ -6029,14 +6160,14 @@ var Lock = class {
6029
6160
  this._releaseTrigger = new Trigger9();
6030
6161
  await this._releaseTrigger.wait();
6031
6162
  log19("releasing lock...", void 0, {
6032
- F: __dxlog_file21,
6163
+ F: __dxlog_file22,
6033
6164
  L: 72,
6034
6165
  S: this,
6035
6166
  C: (f, a) => f(...a)
6036
6167
  });
6037
6168
  await this._onRelease?.();
6038
6169
  log19("released lock", void 0, {
6039
- F: __dxlog_file21,
6170
+ F: __dxlog_file22,
6040
6171
  L: 74,
6041
6172
  S: this,
6042
6173
  C: (f, a) => f(...a)
@@ -6048,7 +6179,7 @@ var Lock = class {
6048
6179
  log19("recieved lock", {
6049
6180
  steal
6050
6181
  }, {
6051
- F: __dxlog_file21,
6182
+ F: __dxlog_file22,
6052
6183
  L: 81,
6053
6184
  S: this,
6054
6185
  C: (f, a) => f(...a)
@@ -6136,13 +6267,151 @@ var createLevel = async (config) => {
6136
6267
  return level;
6137
6268
  };
6138
6269
 
6270
+ // packages/sdk/client-services/src/packlets/storage/profile-archive.ts
6271
+ import { cbor } from "@dxos/automerge/automerge-repo";
6272
+ import { invariant as invariant17 } from "@dxos/invariant";
6273
+ import { log as log20 } from "@dxos/log";
6274
+ import { ProfileArchiveEntryType } from "@dxos/protocols";
6275
+ import { arrayToBuffer } from "@dxos/util";
6276
+ var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
6277
+ var encodeProfileArchive = (profile) => cbor.encode(profile);
6278
+ var decodeProfileArchive = (data) => cbor.decode(data);
6279
+ var exportProfileData = async ({ storage, level }) => {
6280
+ const archive = {
6281
+ storage: [],
6282
+ meta: {
6283
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
6284
+ }
6285
+ };
6286
+ {
6287
+ const directory = await storage.createDirectory();
6288
+ const files = await directory.list();
6289
+ log20.info("begin exporting files", {
6290
+ count: files.length
6291
+ }, {
6292
+ F: __dxlog_file23,
6293
+ L: 30,
6294
+ S: void 0,
6295
+ C: (f, a) => f(...a)
6296
+ });
6297
+ for (const filename of files) {
6298
+ const file = await directory.getOrCreateFile(filename);
6299
+ const { size } = await file.stat();
6300
+ const data = await file.read(0, size);
6301
+ archive.storage.push({
6302
+ type: ProfileArchiveEntryType.FILE,
6303
+ key: filename,
6304
+ value: data
6305
+ });
6306
+ }
6307
+ log20.info("done exporting files", {
6308
+ count: files.length
6309
+ }, {
6310
+ F: __dxlog_file23,
6311
+ L: 41,
6312
+ S: void 0,
6313
+ C: (f, a) => f(...a)
6314
+ });
6315
+ }
6316
+ {
6317
+ log20.info("begin exporting kv pairs", void 0, {
6318
+ F: __dxlog_file23,
6319
+ L: 45,
6320
+ S: void 0,
6321
+ C: (f, a) => f(...a)
6322
+ });
6323
+ const iter = await level.iterator({
6324
+ keyEncoding: "binary",
6325
+ valueEncoding: "binary"
6326
+ });
6327
+ let count = 0;
6328
+ for await (const [key, value] of iter) {
6329
+ archive.storage.push({
6330
+ type: ProfileArchiveEntryType.KEY_VALUE,
6331
+ key,
6332
+ value
6333
+ });
6334
+ count++;
6335
+ }
6336
+ log20.info("done exporting kv pairs", {
6337
+ count
6338
+ }, {
6339
+ F: __dxlog_file23,
6340
+ L: 56,
6341
+ S: void 0,
6342
+ C: (f, a) => f(...a)
6343
+ });
6344
+ }
6345
+ return archive;
6346
+ };
6347
+ var importProfileData = async ({ storage, level }, archive) => {
6348
+ const batch = level.batch();
6349
+ for (const entry2 of archive.storage) {
6350
+ switch (entry2.type) {
6351
+ case ProfileArchiveEntryType.FILE: {
6352
+ const directory = await storage.createDirectory();
6353
+ invariant17(typeof entry2.key === "string", "Invalid key type", {
6354
+ F: __dxlog_file23,
6355
+ L: 78,
6356
+ S: void 0,
6357
+ A: [
6358
+ "typeof entry.key === 'string'",
6359
+ "'Invalid key type'"
6360
+ ]
6361
+ });
6362
+ const file = await directory.getOrCreateFile(entry2.key);
6363
+ invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
6364
+ F: __dxlog_file23,
6365
+ L: 80,
6366
+ S: void 0,
6367
+ A: [
6368
+ "entry.value instanceof Uint8Array",
6369
+ "'Invalid value type'"
6370
+ ]
6371
+ });
6372
+ await file.write(0, arrayToBuffer(entry2.value));
6373
+ await file.close();
6374
+ break;
6375
+ }
6376
+ case ProfileArchiveEntryType.KEY_VALUE: {
6377
+ invariant17(entry2.key instanceof Uint8Array, "Invalid key type", {
6378
+ F: __dxlog_file23,
6379
+ L: 86,
6380
+ S: void 0,
6381
+ A: [
6382
+ "entry.key instanceof Uint8Array",
6383
+ "'Invalid key type'"
6384
+ ]
6385
+ });
6386
+ invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
6387
+ F: __dxlog_file23,
6388
+ L: 87,
6389
+ S: void 0,
6390
+ A: [
6391
+ "entry.value instanceof Uint8Array",
6392
+ "'Invalid value type'"
6393
+ ]
6394
+ });
6395
+ batch.put(entry2.key, entry2.value, {
6396
+ keyEncoding: "binary",
6397
+ valueEncoding: "binary"
6398
+ });
6399
+ break;
6400
+ }
6401
+ default:
6402
+ throw new Error(`Invalid entry type: ${entry2.type}`);
6403
+ }
6404
+ }
6405
+ await batch.write();
6406
+ };
6407
+
6139
6408
  // packages/sdk/client-services/src/packlets/services/service-host.ts
6140
6409
  import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
6141
6410
  import { clientServiceBundle } from "@dxos/client-protocol";
6142
6411
  import { Context as Context11 } from "@dxos/context";
6143
- import { invariant as invariant18 } from "@dxos/invariant";
6144
- import { PublicKey as PublicKey16 } from "@dxos/keys";
6145
- import { log as log21 } from "@dxos/log";
6412
+ import { invariant as invariant19 } from "@dxos/invariant";
6413
+ import { PublicKey as PublicKey17 } from "@dxos/keys";
6414
+ import { log as log22 } from "@dxos/log";
6146
6415
  import { WebsocketSignalManager } from "@dxos/messaging";
6147
6416
  import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
6148
6417
  import { trace as trace10 } from "@dxos/protocols";
@@ -6153,9 +6422,9 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
6153
6422
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
6154
6423
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
6155
6424
  import { Stream as Stream11 } from "@dxos/codec-protobuf";
6156
- import { invariant as invariant17 } from "@dxos/invariant";
6425
+ import { invariant as invariant18 } from "@dxos/invariant";
6157
6426
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
6158
- var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
6427
+ var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
6159
6428
  var DevicesServiceImpl = class {
6160
6429
  constructor(_identityManager) {
6161
6430
  this._identityManager = _identityManager;
@@ -6172,8 +6441,8 @@ var DevicesServiceImpl = class {
6172
6441
  devices: []
6173
6442
  });
6174
6443
  } else {
6175
- invariant17(this._identityManager.identity?.presence, "presence not present", {
6176
- F: __dxlog_file22,
6444
+ invariant18(this._identityManager.identity?.presence, "presence not present", {
6445
+ F: __dxlog_file24,
6177
6446
  L: 32,
6178
6447
  S: this,
6179
6448
  A: [
@@ -6279,28 +6548,111 @@ var findConfigs = () => {
6279
6548
  return configs.map((r) => r.instance.deref()).filter(nonNullable);
6280
6549
  };
6281
6550
 
6282
- // packages/sdk/client-services/src/packlets/logging/logging-service.ts
6283
- import { Event as Event8 } from "@dxos/async";
6551
+ // packages/sdk/client-services/src/packlets/identity/contacts-service.ts
6552
+ import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask7, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
6284
6553
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
6285
6554
  import { PublicKey as PublicKey15 } from "@dxos/keys";
6286
- import { getContextFromEntry, log as log20 } from "@dxos/log";
6555
+ import { ComplexMap as ComplexMap4, ComplexSet as ComplexSet6 } from "@dxos/util";
6556
+ var ContactsServiceImpl = class {
6557
+ constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
6558
+ this._identityManager = _identityManager;
6559
+ this._spaceManager = _spaceManager;
6560
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
6561
+ }
6562
+ async getContacts() {
6563
+ const identity = this._identityManager.identity;
6564
+ if (identity == null) {
6565
+ return {
6566
+ contacts: []
6567
+ };
6568
+ }
6569
+ const contacts = [
6570
+ ...this._spaceManager.spaces.values()
6571
+ ].flatMap((s) => [
6572
+ ...s.spaceState.members.values()
6573
+ ].map((m) => [
6574
+ s.key,
6575
+ m
6576
+ ])).reduce((acc, v) => {
6577
+ const [spaceKey, memberInfo] = v;
6578
+ if (memberInfo.key.equals(identity.identityKey)) {
6579
+ return acc;
6580
+ }
6581
+ const existing = acc.get(memberInfo.key);
6582
+ if (existing != null) {
6583
+ existing.profile ??= memberInfo.profile;
6584
+ existing.commonSpaces?.push(spaceKey);
6585
+ } else {
6586
+ acc.set(memberInfo.key, {
6587
+ identityKey: memberInfo.key,
6588
+ profile: memberInfo.profile,
6589
+ commonSpaces: [
6590
+ spaceKey
6591
+ ]
6592
+ });
6593
+ }
6594
+ return acc;
6595
+ }, new ComplexMap4(PublicKey15.hash));
6596
+ return {
6597
+ contacts: [
6598
+ ...contacts.values()
6599
+ ]
6600
+ };
6601
+ }
6602
+ queryContacts() {
6603
+ const subscribedSpaceKeySet = new ComplexSet6(PublicKey15.hash);
6604
+ return new Stream12(({ next, ctx }) => {
6605
+ const pushUpdateTask = new UpdateScheduler2(ctx, async () => {
6606
+ const contacts = await this.getContacts();
6607
+ next(contacts);
6608
+ }, {
6609
+ maxFrequency: 2
6610
+ });
6611
+ scheduleTask7(ctx, async () => {
6612
+ const subscriptions = new EventSubscriptions4();
6613
+ ctx.onDispose(() => subscriptions.clear());
6614
+ const subscribeToSpaceAndUpdate = () => {
6615
+ const oldSetSize = subscribedSpaceKeySet.size;
6616
+ for (const space of this._spaceManager.spaces.values()) {
6617
+ if (!subscribedSpaceKeySet.has(space.key)) {
6618
+ subscriptions.add(space.stateUpdate.on(ctx, () => pushUpdateTask.trigger()));
6619
+ subscribedSpaceKeySet.add(space.key);
6620
+ }
6621
+ }
6622
+ if (oldSetSize !== subscribedSpaceKeySet.size) {
6623
+ pushUpdateTask.trigger();
6624
+ }
6625
+ };
6626
+ const unsubscribe = (await this._dataSpaceManagerProvider()).updated.on(ctx, subscribeToSpaceAndUpdate);
6627
+ ctx.onDispose(unsubscribe);
6628
+ subscribeToSpaceAndUpdate();
6629
+ });
6630
+ });
6631
+ }
6632
+ };
6633
+
6634
+ // packages/sdk/client-services/src/packlets/logging/logging-service.ts
6635
+ import { Event as Event8 } from "@dxos/async";
6636
+ import { Stream as Stream13 } from "@dxos/codec-protobuf";
6637
+ import { PublicKey as PublicKey16 } from "@dxos/keys";
6638
+ import { getContextFromEntry, log as log21 } from "@dxos/log";
6287
6639
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
6288
6640
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
6289
6641
  var LoggingServiceImpl = class {
6290
6642
  constructor() {
6291
6643
  this._logs = new Event8();
6292
6644
  this._started = Date.now();
6293
- this._sessionId = PublicKey15.random().toHex();
6645
+ this._sessionId = PublicKey16.random().toHex();
6294
6646
  this._logProcessor = (_config, entry2) => {
6295
6647
  this._logs.emit(entry2);
6296
6648
  };
6297
6649
  }
6298
6650
  async open() {
6299
- log20.runtimeConfig.processors.push(this._logProcessor);
6651
+ log21.runtimeConfig.processors.push(this._logProcessor);
6300
6652
  }
6301
6653
  async close() {
6302
- const index = log20.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6303
- log20.runtimeConfig.processors.splice(index, 1);
6654
+ const index = log21.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6655
+ log21.runtimeConfig.processors.splice(index, 1);
6304
6656
  }
6305
6657
  async controlMetrics({ reset, record }) {
6306
6658
  if (reset) {
@@ -6326,7 +6678,7 @@ var LoggingServiceImpl = class {
6326
6678
  stats: numericalValues(events, "duration")
6327
6679
  };
6328
6680
  };
6329
- return new Stream12(({ next }) => {
6681
+ return new Stream13(({ next }) => {
6330
6682
  const update = () => {
6331
6683
  const metrics = {
6332
6684
  timestamp: /* @__PURE__ */ new Date(),
@@ -6348,7 +6700,7 @@ var LoggingServiceImpl = class {
6348
6700
  });
6349
6701
  }
6350
6702
  queryLogs(request) {
6351
- return new Stream12(({ ctx, next }) => {
6703
+ return new Stream13(({ ctx, next }) => {
6352
6704
  const handler = (entry2) => {
6353
6705
  if (LOG_PROCESSING > 0) {
6354
6706
  return;
@@ -6404,14 +6756,14 @@ var shouldLog = (entry2, request) => {
6404
6756
  var LOG_PROCESSING = 0;
6405
6757
 
6406
6758
  // packages/sdk/client-services/src/packlets/network/network-service.ts
6407
- import { Stream as Stream13 } from "@dxos/codec-protobuf";
6759
+ import { Stream as Stream14 } from "@dxos/codec-protobuf";
6408
6760
  var NetworkServiceImpl = class {
6409
6761
  constructor(networkManager, signalManager) {
6410
6762
  this.networkManager = networkManager;
6411
6763
  this.signalManager = signalManager;
6412
6764
  }
6413
6765
  queryStatus() {
6414
- return new Stream13(({ next }) => {
6766
+ return new Stream14(({ next }) => {
6415
6767
  const update = () => {
6416
6768
  next({
6417
6769
  swarm: this.networkManager.connectionState,
@@ -6437,7 +6789,7 @@ var NetworkServiceImpl = class {
6437
6789
  };
6438
6790
 
6439
6791
  // packages/sdk/client-services/src/packlets/system/system-service.ts
6440
- import { Stream as Stream14 } from "@dxos/codec-protobuf";
6792
+ import { Stream as Stream15 } from "@dxos/codec-protobuf";
6441
6793
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
6442
6794
  import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
6443
6795
  var SystemServiceImpl = class {
@@ -6473,7 +6825,7 @@ var SystemServiceImpl = class {
6473
6825
  }
6474
6826
  // TODO(burdon): Standardize interval option in stream request?
6475
6827
  queryStatus({ interval = 3e3 } = {}) {
6476
- return new Stream14(({ next }) => {
6828
+ return new Stream15(({ next }) => {
6477
6829
  const update = () => {
6478
6830
  next({
6479
6831
  status: this._getCurrentStatus()
@@ -6504,7 +6856,7 @@ function _ts_decorate8(decorators, target, key, desc) {
6504
6856
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6505
6857
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6506
6858
  }
6507
- var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6859
+ var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6508
6860
  var ClientServicesHost = class {
6509
6861
  constructor({
6510
6862
  config,
@@ -6537,7 +6889,10 @@ var ClientServicesHost = class {
6537
6889
  lockKey,
6538
6890
  onAcquire: () => {
6539
6891
  if (!this._opening) {
6540
- void this.open(new Context11());
6892
+ void this.open(new Context11(void 0, {
6893
+ F: __dxlog_file25,
6894
+ L: 121
6895
+ }));
6541
6896
  }
6542
6897
  },
6543
6898
  onRelease: () => this.close()
@@ -6592,25 +6947,25 @@ var ClientServicesHost = class {
6592
6947
  * Can only be called once.
6593
6948
  */
6594
6949
  initialize({ config, ...options }) {
6595
- invariant18(!this._open, "service host is open", {
6596
- F: __dxlog_file23,
6597
- L: 186,
6950
+ invariant19(!this._open, "service host is open", {
6951
+ F: __dxlog_file25,
6952
+ L: 187,
6598
6953
  S: this,
6599
6954
  A: [
6600
6955
  "!this._open",
6601
6956
  "'service host is open'"
6602
6957
  ]
6603
6958
  });
6604
- log21("initializing...", void 0, {
6605
- F: __dxlog_file23,
6606
- L: 187,
6959
+ log22("initializing...", void 0, {
6960
+ F: __dxlog_file25,
6961
+ L: 188,
6607
6962
  S: this,
6608
6963
  C: (f, a) => f(...a)
6609
6964
  });
6610
6965
  if (config) {
6611
- invariant18(!this._config, "config already set", {
6612
- F: __dxlog_file23,
6613
- L: 190,
6966
+ invariant19(!this._config, "config already set", {
6967
+ F: __dxlog_file25,
6968
+ L: 191,
6614
6969
  S: this,
6615
6970
  A: [
6616
6971
  "!this._config",
@@ -6623,9 +6978,9 @@ var ClientServicesHost = class {
6623
6978
  }
6624
6979
  }
6625
6980
  if (!options.signalManager) {
6626
- log21.warn("running signaling without telemetry metadata.", void 0, {
6627
- F: __dxlog_file23,
6628
- L: 198,
6981
+ log22.warn("running signaling without telemetry metadata.", void 0, {
6982
+ F: __dxlog_file25,
6983
+ L: 199,
6629
6984
  S: this,
6630
6985
  C: (f, a) => f(...a)
6631
6986
  });
@@ -6634,9 +6989,9 @@ var ClientServicesHost = class {
6634
6989
  iceServers: this._config?.get("runtime.services.ice")
6635
6990
  }), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
6636
6991
  this._signalManager = signalManager;
6637
- invariant18(!this._networkManager, "network manager already set", {
6638
- F: __dxlog_file23,
6639
- L: 209,
6992
+ invariant19(!this._networkManager, "network manager already set", {
6993
+ F: __dxlog_file25,
6994
+ L: 210,
6640
6995
  S: this,
6641
6996
  A: [
6642
6997
  "!this._networkManager",
@@ -6648,9 +7003,9 @@ var ClientServicesHost = class {
6648
7003
  transportFactory,
6649
7004
  signalManager
6650
7005
  });
6651
- log21("initialized", void 0, {
6652
- F: __dxlog_file23,
6653
- L: 216,
7006
+ log22("initialized", void 0, {
7007
+ F: __dxlog_file25,
7008
+ L: 217,
6654
7009
  S: this,
6655
7010
  C: (f, a) => f(...a)
6656
7011
  });
@@ -6659,45 +7014,45 @@ var ClientServicesHost = class {
6659
7014
  if (this._open) {
6660
7015
  return;
6661
7016
  }
6662
- const traceId = PublicKey16.random().toHex();
6663
- log21.trace("dxos.client-services.host.open", trace10.begin({
7017
+ const traceId = PublicKey17.random().toHex();
7018
+ log22.trace("dxos.client-services.host.open", trace10.begin({
6664
7019
  id: traceId
6665
7020
  }), {
6666
- F: __dxlog_file23,
6667
- L: 227,
7021
+ F: __dxlog_file25,
7022
+ L: 228,
6668
7023
  S: this,
6669
7024
  C: (f, a) => f(...a)
6670
7025
  });
6671
- invariant18(this._config, "config not set", {
6672
- F: __dxlog_file23,
6673
- L: 229,
7026
+ invariant19(this._config, "config not set", {
7027
+ F: __dxlog_file25,
7028
+ L: 230,
6674
7029
  S: this,
6675
7030
  A: [
6676
7031
  "this._config",
6677
7032
  "'config not set'"
6678
7033
  ]
6679
7034
  });
6680
- invariant18(this._storage, "storage not set", {
6681
- F: __dxlog_file23,
6682
- L: 230,
7035
+ invariant19(this._storage, "storage not set", {
7036
+ F: __dxlog_file25,
7037
+ L: 231,
6683
7038
  S: this,
6684
7039
  A: [
6685
7040
  "this._storage",
6686
7041
  "'storage not set'"
6687
7042
  ]
6688
7043
  });
6689
- invariant18(this._signalManager, "signal manager not set", {
6690
- F: __dxlog_file23,
6691
- L: 231,
7044
+ invariant19(this._signalManager, "signal manager not set", {
7045
+ F: __dxlog_file25,
7046
+ L: 232,
6692
7047
  S: this,
6693
7048
  A: [
6694
7049
  "this._signalManager",
6695
7050
  "'signal manager not set'"
6696
7051
  ]
6697
7052
  });
6698
- invariant18(this._networkManager, "network manager not set", {
6699
- F: __dxlog_file23,
6700
- L: 232,
7053
+ invariant19(this._networkManager, "network manager not set", {
7054
+ F: __dxlog_file25,
7055
+ L: 233,
6701
7056
  S: this,
6702
7057
  A: [
6703
7058
  "this._networkManager",
@@ -6705,11 +7060,11 @@ var ClientServicesHost = class {
6705
7060
  ]
6706
7061
  });
6707
7062
  this._opening = true;
6708
- log21("opening...", {
7063
+ log22("opening...", {
6709
7064
  lockKey: this._resourceLock?.lockKey
6710
7065
  }, {
6711
- F: __dxlog_file23,
6712
- L: 235,
7066
+ F: __dxlog_file25,
7067
+ L: 236,
6713
7068
  S: this,
6714
7069
  C: (f, a) => f(...a)
6715
7070
  });
@@ -6720,16 +7075,18 @@ var ClientServicesHost = class {
6720
7075
  await this._level.open();
6721
7076
  await this._loggingService.open();
6722
7077
  this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
7078
+ const dataSpaceManagerProvider = async () => {
7079
+ await this._serviceContext.initialized.wait();
7080
+ return this._serviceContext.dataSpaceManager;
7081
+ };
6723
7082
  const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
6724
7083
  this._serviceRegistry.setServices({
6725
7084
  SystemService: this._systemService,
6726
7085
  IdentityService: identityService,
7086
+ ContactsService: new ContactsServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6727
7087
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
6728
7088
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
6729
- SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
6730
- await this._serviceContext.initialized.wait();
6731
- return this._serviceContext.dataSpaceManager;
6732
- }),
7089
+ SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6733
7090
  DataService: this._serviceContext.echoHost.dataService,
6734
7091
  QueryService: this._serviceContext.echoHost.queryService,
6735
7092
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
@@ -6759,19 +7116,19 @@ var ClientServicesHost = class {
6759
7116
  this._open = true;
6760
7117
  this._statusUpdate.emit();
6761
7118
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6762
- log21("opened", {
7119
+ log22("opened", {
6763
7120
  deviceKey
6764
7121
  }, {
6765
- F: __dxlog_file23,
6766
- L: 314,
7122
+ F: __dxlog_file25,
7123
+ L: 322,
6767
7124
  S: this,
6768
7125
  C: (f, a) => f(...a)
6769
7126
  });
6770
- log21.trace("dxos.client-services.host.open", trace10.end({
7127
+ log22.trace("dxos.client-services.host.open", trace10.end({
6771
7128
  id: traceId
6772
7129
  }), {
6773
- F: __dxlog_file23,
6774
- L: 315,
7130
+ F: __dxlog_file25,
7131
+ L: 323,
6775
7132
  S: this,
6776
7133
  C: (f, a) => f(...a)
6777
7134
  });
@@ -6781,11 +7138,11 @@ var ClientServicesHost = class {
6781
7138
  return;
6782
7139
  }
6783
7140
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6784
- log21("closing...", {
7141
+ log22("closing...", {
6785
7142
  deviceKey
6786
7143
  }, {
6787
- F: __dxlog_file23,
6788
- L: 326,
7144
+ F: __dxlog_file25,
7145
+ L: 334,
6789
7146
  S: this,
6790
7147
  C: (f, a) => f(...a)
6791
7148
  });
@@ -6799,44 +7156,44 @@ var ClientServicesHost = class {
6799
7156
  await this._level?.close();
6800
7157
  this._open = false;
6801
7158
  this._statusUpdate.emit();
6802
- log21("closed", {
7159
+ log22("closed", {
6803
7160
  deviceKey
6804
7161
  }, {
6805
- F: __dxlog_file23,
6806
- L: 335,
7162
+ F: __dxlog_file25,
7163
+ L: 343,
6807
7164
  S: this,
6808
7165
  C: (f, a) => f(...a)
6809
7166
  });
6810
7167
  }
6811
7168
  async reset() {
6812
- const traceId = PublicKey16.random().toHex();
6813
- log21.trace("dxos.sdk.client-services-host.reset", trace10.begin({
7169
+ const traceId = PublicKey17.random().toHex();
7170
+ log22.trace("dxos.sdk.client-services-host.reset", trace10.begin({
6814
7171
  id: traceId
6815
7172
  }), {
6816
- F: __dxlog_file23,
6817
- L: 340,
7173
+ F: __dxlog_file25,
7174
+ L: 348,
6818
7175
  S: this,
6819
7176
  C: (f, a) => f(...a)
6820
7177
  });
6821
- log21.info("resetting...", void 0, {
6822
- F: __dxlog_file23,
6823
- L: 342,
7178
+ log22.info("resetting...", void 0, {
7179
+ F: __dxlog_file25,
7180
+ L: 350,
6824
7181
  S: this,
6825
7182
  C: (f, a) => f(...a)
6826
7183
  });
6827
7184
  await this._serviceContext?.close();
6828
7185
  await this._storage.reset();
6829
- log21.info("reset", void 0, {
6830
- F: __dxlog_file23,
6831
- L: 345,
7186
+ log22.info("reset", void 0, {
7187
+ F: __dxlog_file25,
7188
+ L: 353,
6832
7189
  S: this,
6833
7190
  C: (f, a) => f(...a)
6834
7191
  });
6835
- log21.trace("dxos.sdk.client-services-host.reset", trace10.end({
7192
+ log22.trace("dxos.sdk.client-services-host.reset", trace10.end({
6836
7193
  id: traceId
6837
7194
  }), {
6838
- F: __dxlog_file23,
6839
- L: 346,
7195
+ F: __dxlog_file25,
7196
+ L: 354,
6840
7197
  S: this,
6841
7198
  C: (f, a) => f(...a)
6842
7199
  });
@@ -6902,8 +7259,12 @@ export {
6902
7259
  isLocked,
6903
7260
  createStorageObjects,
6904
7261
  createLevel,
7262
+ encodeProfileArchive,
7263
+ decodeProfileArchive,
7264
+ exportProfileData,
7265
+ importProfileData,
6905
7266
  ClientServicesHost,
6906
7267
  ClientServicesProviderResource,
6907
7268
  DiagnosticsCollector
6908
7269
  };
6909
- //# sourceMappingURL=chunk-7ZORW75D.mjs.map
7270
+ //# sourceMappingURL=chunk-3CWG7YPJ.mjs.map