@dxos/client-services 0.5.9-main.5282b05 → 0.5.9-main.55e2125

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-24JXJ6S3.mjs → chunk-CXKIPEH7.mjs} +809 -447
  2. package/dist/lib/browser/chunk-CXKIPEH7.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-CECVX7DV.cjs → chunk-QN3UVJ5U.cjs} +821 -459
  9. package/dist/lib/node/chunk-QN3UVJ5U.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/space-invitation-protocol.d.ts.map +1 -1
  18. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  19. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +10 -1
  20. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  21. package/dist/types/src/packlets/spaces/epoch-migrations.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/space-invitation-protocol.ts +11 -32
  32. package/src/packlets/services/service-host.ts +12 -4
  33. package/src/packlets/spaces/data-space-manager.ts +55 -2
  34. package/src/packlets/spaces/epoch-migrations.ts +12 -7
  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-24JXJ6S3.mjs.map +0 -7
  40. package/dist/lib/node/chunk-CECVX7DV.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.5282b05";
362
+ var DXOS_VERSION = "0.5.9-main.55e2125";
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: [
@@ -2865,7 +2887,7 @@ var InvitationsHandler = class {
2865
2887
  newState: stateToString(newState),
2866
2888
  oldState: stateToString(invitation.state)
2867
2889
  }, {
2868
- F: __dxlog_file12,
2890
+ F: __dxlog_file13,
2869
2891
  L: 439,
2870
2892
  S: this,
2871
2893
  C: (f, a) => f(...a)
@@ -2876,7 +2898,7 @@ var InvitationsHandler = class {
2876
2898
  newState: stateToString(newState),
2877
2899
  oldState: stateToString(invitation.state)
2878
2900
  }, {
2879
- F: __dxlog_file12,
2901
+ F: __dxlog_file13,
2880
2902
  L: 445,
2881
2903
  S: this,
2882
2904
  C: (f, a) => f(...a)
@@ -2895,7 +2917,7 @@ var InvitationsHandler = class {
2895
2917
  async _handleGuestOtpAuth(extension, setState, authenticated, options) {
2896
2918
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2897
2919
  log10("guest waiting for authentication code...", void 0, {
2898
- F: __dxlog_file12,
2920
+ F: __dxlog_file13,
2899
2921
  L: 470,
2900
2922
  S: this,
2901
2923
  C: (f, a) => f(...a)
@@ -2903,7 +2925,7 @@ var InvitationsHandler = class {
2903
2925
  setState(Invitation4.State.READY_FOR_AUTHENTICATION);
2904
2926
  const authCode = await authenticated.wait(options);
2905
2927
  log10("sending authentication request", void 0, {
2906
- F: __dxlog_file12,
2928
+ F: __dxlog_file13,
2907
2929
  L: 474,
2908
2930
  S: this,
2909
2931
  C: (f, a) => f(...a)
@@ -2922,7 +2944,7 @@ var InvitationsHandler = class {
2922
2944
  log10("retrying invalid code", {
2923
2945
  attempt
2924
2946
  }, {
2925
- F: __dxlog_file12,
2947
+ F: __dxlog_file13,
2926
2948
  L: 485,
2927
2949
  S: this,
2928
2950
  C: (f, a) => f(...a)
@@ -2940,7 +2962,7 @@ var InvitationsHandler = class {
2940
2962
  throw new Error("challenge missing in the introduction");
2941
2963
  }
2942
2964
  log10("sending authentication request", void 0, {
2943
- F: __dxlog_file12,
2965
+ F: __dxlog_file13,
2944
2966
  L: 504,
2945
2967
  S: this,
2946
2968
  C: (f, a) => f(...a)
@@ -3061,14 +3083,14 @@ var InvitationsServiceImpl = class {
3061
3083
  };
3062
3084
 
3063
3085
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
3064
- import { createAdmissionCredentials, createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3086
+ import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3065
3087
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
3066
3088
  import { invariant as invariant10 } from "@dxos/invariant";
3067
3089
  import { log as log11 } from "@dxos/log";
3068
3090
  import { AlreadyJoinedError as AlreadyJoinedError2, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from "@dxos/protocols";
3069
3091
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
3070
3092
  import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
3071
- 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";
3072
3094
  var SpaceInvitationProtocol = class {
3073
3095
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
3074
3096
  this._spaceManager = _spaceManager;
@@ -3102,79 +3124,43 @@ var SpaceInvitationProtocol = class {
3102
3124
  };
3103
3125
  }
3104
3126
  async admit(invitation, request, guestProfile) {
3105
- invariant10(this._spaceKey, void 0, {
3106
- F: __dxlog_file13,
3107
- L: 76,
3108
- S: this,
3109
- A: [
3110
- "this._spaceKey",
3111
- ""
3112
- ]
3113
- });
3114
- const space = this._spaceManager.spaces.get(this._spaceKey);
3115
- invariant10(space, void 0, {
3116
- F: __dxlog_file13,
3117
- L: 78,
3118
- S: this,
3119
- A: [
3120
- "space",
3121
- ""
3122
- ]
3123
- });
3124
- invariant10(request.space, void 0, {
3125
- F: __dxlog_file13,
3126
- L: 80,
3127
+ invariant10(this._spaceKey && request.space, void 0, {
3128
+ F: __dxlog_file14,
3129
+ L: 74,
3127
3130
  S: this,
3128
3131
  A: [
3129
- "request.space",
3132
+ "this._spaceKey && request.space",
3130
3133
  ""
3131
3134
  ]
3132
3135
  });
3133
- const { identityKey, deviceKey } = request.space;
3134
- if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember2.Role.REMOVED) {
3135
- throw new AlreadyJoinedError2();
3136
- }
3137
3136
  log11("writing guest credentials", {
3138
3137
  host: this._signingContext.deviceKey,
3139
- guest: deviceKey
3138
+ guest: request.space.deviceKey
3140
3139
  }, {
3141
- F: __dxlog_file13,
3142
- L: 87,
3140
+ F: __dxlog_file14,
3141
+ L: 75,
3143
3142
  S: this,
3144
3143
  C: (f, a) => f(...a)
3145
3144
  });
3146
- 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);
3147
- invariant10(credentials[0].credential, void 0, {
3148
- F: __dxlog_file13,
3149
- L: 101,
3150
- S: this,
3151
- A: [
3152
- "credentials[0].credential",
3153
- ""
3154
- ]
3155
- });
3156
- const spaceMemberCredential = credentials[0].credential.credential;
3157
- invariant10(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3158
- F: __dxlog_file13,
3159
- L: 103,
3160
- S: this,
3161
- A: [
3162
- "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
3163
- ""
3164
- ]
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
3165
3151
  });
3166
- await writeMessages2(space.inner.controlPipeline.writer, credentials);
3152
+ const space = this._spaceManager.spaces.get(this._spaceKey);
3167
3153
  return {
3168
3154
  space: {
3169
3155
  credential: spaceMemberCredential,
3170
- controlTimeframe: space.inner.controlPipeline.state.timeframe
3156
+ controlTimeframe: space?.inner.controlPipeline.state.timeframe
3171
3157
  }
3172
3158
  };
3173
3159
  }
3174
3160
  async delegate(invitation) {
3175
3161
  invariant10(this._spaceKey, void 0, {
3176
- F: __dxlog_file13,
3177
- L: 116,
3162
+ F: __dxlog_file14,
3163
+ L: 95,
3178
3164
  S: this,
3179
3165
  A: [
3180
3166
  "this._spaceKey",
@@ -3183,8 +3169,8 @@ var SpaceInvitationProtocol = class {
3183
3169
  });
3184
3170
  const space = this._spaceManager.spaces.get(this._spaceKey);
3185
3171
  invariant10(space, void 0, {
3186
- F: __dxlog_file13,
3187
- L: 118,
3172
+ F: __dxlog_file14,
3173
+ L: 97,
3188
3174
  S: this,
3189
3175
  A: [
3190
3176
  "space",
@@ -3193,8 +3179,8 @@ var SpaceInvitationProtocol = class {
3193
3179
  });
3194
3180
  if (invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY) {
3195
3181
  invariant10(invitation.guestKeypair?.publicKey, void 0, {
3196
- F: __dxlog_file13,
3197
- L: 120,
3182
+ F: __dxlog_file14,
3183
+ L: 99,
3198
3184
  S: this,
3199
3185
  A: [
3200
3186
  "invitation.guestKeypair?.publicKey",
@@ -3206,8 +3192,8 @@ var SpaceInvitationProtocol = class {
3206
3192
  host: this._signingContext.deviceKey,
3207
3193
  id: invitation.invitationId
3208
3194
  }, {
3209
- F: __dxlog_file13,
3210
- L: 123,
3195
+ F: __dxlog_file14,
3196
+ L: 102,
3211
3197
  S: this,
3212
3198
  C: (f, a) => f(...a)
3213
3199
  });
@@ -3221,8 +3207,8 @@ var SpaceInvitationProtocol = class {
3221
3207
  guestKey: invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
3222
3208
  });
3223
3209
  invariant10(credential.credential, void 0, {
3224
- F: __dxlog_file13,
3225
- L: 143,
3210
+ F: __dxlog_file14,
3211
+ L: 122,
3226
3212
  S: this,
3227
3213
  A: [
3228
3214
  "credential.credential",
@@ -3236,8 +3222,8 @@ var SpaceInvitationProtocol = class {
3236
3222
  }
3237
3223
  async cancelDelegation(invitation) {
3238
3224
  invariant10(this._spaceKey, void 0, {
3239
- F: __dxlog_file13,
3240
- L: 149,
3225
+ F: __dxlog_file14,
3226
+ L: 128,
3241
3227
  S: this,
3242
3228
  A: [
3243
3229
  "this._spaceKey",
@@ -3245,8 +3231,8 @@ var SpaceInvitationProtocol = class {
3245
3231
  ]
3246
3232
  });
3247
3233
  invariant10(invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
3248
- F: __dxlog_file13,
3249
- L: 150,
3234
+ F: __dxlog_file14,
3235
+ L: 129,
3250
3236
  S: this,
3251
3237
  A: [
3252
3238
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -3255,8 +3241,8 @@ var SpaceInvitationProtocol = class {
3255
3241
  });
3256
3242
  const space = this._spaceManager.spaces.get(this._spaceKey);
3257
3243
  invariant10(space, void 0, {
3258
- F: __dxlog_file13,
3259
- L: 152,
3244
+ F: __dxlog_file14,
3245
+ L: 131,
3260
3246
  S: this,
3261
3247
  A: [
3262
3248
  "space",
@@ -3267,15 +3253,15 @@ var SpaceInvitationProtocol = class {
3267
3253
  host: this._signingContext.deviceKey,
3268
3254
  id: invitation.invitationId
3269
3255
  }, {
3270
- F: __dxlog_file13,
3271
- L: 154,
3256
+ F: __dxlog_file14,
3257
+ L: 133,
3272
3258
  S: this,
3273
3259
  C: (f, a) => f(...a)
3274
3260
  });
3275
3261
  const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
3276
3262
  invariant10(credential.credential, void 0, {
3277
- F: __dxlog_file13,
3278
- L: 161,
3263
+ F: __dxlog_file14,
3264
+ L: 140,
3279
3265
  S: this,
3280
3266
  A: [
3281
3267
  "credential.credential",
@@ -3313,8 +3299,8 @@ var SpaceInvitationProtocol = class {
3313
3299
  }
3314
3300
  async accept(response) {
3315
3301
  invariant10(response.space, void 0, {
3316
- F: __dxlog_file13,
3317
- L: 196,
3302
+ F: __dxlog_file14,
3303
+ L: 175,
3318
3304
  S: this,
3319
3305
  A: [
3320
3306
  "response.space",
@@ -3324,8 +3310,8 @@ var SpaceInvitationProtocol = class {
3324
3310
  const { credential, controlTimeframe, dataTimeframe } = response.space;
3325
3311
  const assertion = getCredentialAssertion2(credential);
3326
3312
  invariant10(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3327
- F: __dxlog_file13,
3328
- L: 199,
3313
+ F: __dxlog_file14,
3314
+ L: 178,
3329
3315
  S: this,
3330
3316
  A: [
3331
3317
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3333,8 +3319,8 @@ var SpaceInvitationProtocol = class {
3333
3319
  ]
3334
3320
  });
3335
3321
  invariant10(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
3336
- F: __dxlog_file13,
3337
- L: 200,
3322
+ F: __dxlog_file14,
3323
+ L: 179,
3338
3324
  S: this,
3339
3325
  A: [
3340
3326
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -3368,7 +3354,7 @@ import { PublicKey as PublicKey8 } from "@dxos/keys";
3368
3354
  import { log as log12 } from "@dxos/log";
3369
3355
  import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
3370
3356
  import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
3371
- 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";
3372
3358
  var InvitationsManager = class {
3373
3359
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
3374
3360
  this._invitationsHandler = _invitationsHandler;
@@ -3411,7 +3397,7 @@ var InvitationsManager = class {
3411
3397
  await this._persistIfRequired(handler, stream, invitation);
3412
3398
  } catch (err) {
3413
3399
  log12.catch(err, void 0, {
3414
- F: __dxlog_file14,
3400
+ F: __dxlog_file15,
3415
3401
  L: 82,
3416
3402
  S: this,
3417
3403
  C: (f, a) => f(...a)
@@ -3434,7 +3420,7 @@ var InvitationsManager = class {
3434
3420
  const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
3435
3421
  const loadTasks = freshInvitations.map((persistentInvitation) => {
3436
3422
  invariant11(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
3437
- F: __dxlog_file14,
3423
+ F: __dxlog_file15,
3438
3424
  L: 103,
3439
3425
  S: this,
3440
3426
  A: [
@@ -3453,7 +3439,7 @@ var InvitationsManager = class {
3453
3439
  };
3454
3440
  } catch (err) {
3455
3441
  log12.catch(err, void 0, {
3456
- F: __dxlog_file14,
3442
+ F: __dxlog_file15,
3457
3443
  L: 110,
3458
3444
  S: this,
3459
3445
  C: (f, a) => f(...a)
@@ -3485,13 +3471,13 @@ var InvitationsManager = class {
3485
3471
  }
3486
3472
  async authenticate({ invitationId, authCode }) {
3487
3473
  log12("authenticating...", void 0, {
3488
- F: __dxlog_file14,
3474
+ F: __dxlog_file15,
3489
3475
  L: 140,
3490
3476
  S: this,
3491
3477
  C: (f, a) => f(...a)
3492
3478
  });
3493
3479
  invariant11(invitationId, void 0, {
3494
- F: __dxlog_file14,
3480
+ F: __dxlog_file15,
3495
3481
  L: 141,
3496
3482
  S: this,
3497
3483
  A: [
@@ -3504,7 +3490,7 @@ var InvitationsManager = class {
3504
3490
  log12.warn("invalid invitation", {
3505
3491
  invitationId
3506
3492
  }, {
3507
- F: __dxlog_file14,
3493
+ F: __dxlog_file15,
3508
3494
  L: 144,
3509
3495
  S: this,
3510
3496
  C: (f, a) => f(...a)
@@ -3517,13 +3503,13 @@ var InvitationsManager = class {
3517
3503
  log12("cancelInvitation...", {
3518
3504
  invitationId
3519
3505
  }, {
3520
- F: __dxlog_file14,
3506
+ F: __dxlog_file15,
3521
3507
  L: 151,
3522
3508
  S: this,
3523
3509
  C: (f, a) => f(...a)
3524
3510
  });
3525
3511
  invariant11(invitationId, void 0, {
3526
- F: __dxlog_file14,
3512
+ F: __dxlog_file15,
3527
3513
  L: 152,
3528
3514
  S: this,
3529
3515
  A: [
@@ -3597,12 +3583,15 @@ var InvitationsManager = class {
3597
3583
  stream.error(err);
3598
3584
  void ctx.dispose();
3599
3585
  }
3586
+ }, {
3587
+ F: __dxlog_file15,
3588
+ L: 234
3600
3589
  });
3601
3590
  ctx.onDispose(() => {
3602
3591
  log12("complete", {
3603
3592
  ...handler.toJSON()
3604
3593
  }, {
3605
- F: __dxlog_file14,
3594
+ F: __dxlog_file15,
3606
3595
  L: 241,
3607
3596
  S: this,
3608
3597
  C: (f, a) => f(...a)
@@ -3635,7 +3624,7 @@ var InvitationsManager = class {
3635
3624
  log12("timeout", {
3636
3625
  ...handler.toJSON()
3637
3626
  }, {
3638
- F: __dxlog_file14,
3627
+ F: __dxlog_file15,
3639
3628
  L: 261,
3640
3629
  S: this,
3641
3630
  C: (f, a) => f(...a)
@@ -3646,7 +3635,7 @@ var InvitationsManager = class {
3646
3635
  });
3647
3636
  } else {
3648
3637
  log12.warn("auth failed", err, {
3649
- F: __dxlog_file14,
3638
+ F: __dxlog_file15,
3650
3639
  L: 264,
3651
3640
  S: this,
3652
3641
  C: (f, a) => f(...a)
@@ -3658,12 +3647,15 @@ var InvitationsManager = class {
3658
3647
  }
3659
3648
  void ctx.dispose();
3660
3649
  }
3650
+ }, {
3651
+ F: __dxlog_file15,
3652
+ L: 258
3661
3653
  });
3662
3654
  ctx.onDispose(() => {
3663
3655
  log12("complete", {
3664
3656
  ...handler.toJSON()
3665
3657
  }, {
3666
- F: __dxlog_file14,
3658
+ F: __dxlog_file15,
3667
3659
  L: 271,
3668
3660
  S: this,
3669
3661
  C: (f, a) => f(...a)
@@ -3708,7 +3700,7 @@ var InvitationsManager = class {
3708
3700
  await this._metadataStore.removeInvitation(invitation.invitationId);
3709
3701
  } catch (err) {
3710
3702
  log12.catch(err, void 0, {
3711
- F: __dxlog_file14,
3703
+ F: __dxlog_file15,
3712
3704
  L: 307,
3713
3705
  S: this,
3714
3706
  C: (f, a) => f(...a)
@@ -3795,7 +3787,7 @@ import { invariant as invariant12 } from "@dxos/invariant";
3795
3787
  import { log as log13 } from "@dxos/log";
3796
3788
  import { CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
3797
3789
  import { assignDeep } from "@dxos/util";
3798
- 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";
3799
3791
  var runEpochMigration = async (ctx, context) => {
3800
3792
  switch (context.migration) {
3801
3793
  case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
@@ -3819,7 +3811,7 @@ var runEpochMigration = async (ctx, context) => {
3819
3811
  }
3820
3812
  case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
3821
3813
  log13.info("Fragmenting", void 0, {
3822
- F: __dxlog_file15,
3814
+ F: __dxlog_file16,
3823
3815
  L: 63,
3824
3816
  S: void 0,
3825
3817
  C: (f, a) => f(...a)
@@ -3831,7 +3823,7 @@ var runEpochMigration = async (ctx, context) => {
3831
3823
  const properties = findInlineObjectOfType(rootHandle.docSync(), TYPE_PROPERTIES);
3832
3824
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3833
3825
  invariant12(properties, "Properties not found", {
3834
- F: __dxlog_file15,
3826
+ F: __dxlog_file16,
3835
3827
  L: 73,
3836
3828
  S: void 0,
3837
3829
  A: [
@@ -3847,7 +3839,7 @@ var runEpochMigration = async (ctx, context) => {
3847
3839
  };
3848
3840
  const newRoot = context.repo.create(newSpaceDoc);
3849
3841
  invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3850
- F: __dxlog_file15,
3842
+ F: __dxlog_file16,
3851
3843
  L: 78,
3852
3844
  S: void 0,
3853
3845
  A: [
@@ -3878,7 +3870,7 @@ var runEpochMigration = async (ctx, context) => {
3878
3870
  const rootHandle = context.repo.find(currentRootUrl);
3879
3871
  await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
3880
3872
  invariant12(rootHandle.docSync(), "Root doc not found", {
3881
- F: __dxlog_file15,
3873
+ F: __dxlog_file16,
3882
3874
  L: 100,
3883
3875
  S: void 0,
3884
3876
  A: [
@@ -3888,21 +3880,35 @@ var runEpochMigration = async (ctx, context) => {
3888
3880
  });
3889
3881
  const newRootContent = await convertLegacySpaceRootDoc(structuredClone(rootHandle.docSync()));
3890
3882
  for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
3891
- const handle = context.repo.find(url);
3892
- await cancelWithContext4(ctx, asyncTimeout2(handle.whenReady(), 1e4));
3893
- invariant12(handle.docSync(), "Doc not found", {
3894
- F: __dxlog_file15,
3895
- L: 107,
3896
- S: void 0,
3897
- A: [
3898
- "handle.docSync()",
3899
- "'Doc not found'"
3900
- ]
3901
- });
3902
- const newDoc = await convertLegacyReferences(structuredClone(handle.docSync()));
3903
- const migratedDoc = migrateDocument(handle.docSync(), newDoc);
3904
- const newHandle = context.repo.import(am.save(migratedDoc));
3905
- newRootContent.links[id] = newHandle.url;
3883
+ try {
3884
+ const handle = context.repo.find(url);
3885
+ await cancelWithContext4(ctx, asyncTimeout2(handle.whenReady(), 1e4));
3886
+ invariant12(handle.docSync(), "Doc not found", {
3887
+ F: __dxlog_file16,
3888
+ L: 108,
3889
+ S: void 0,
3890
+ A: [
3891
+ "handle.docSync()",
3892
+ "'Doc not found'"
3893
+ ]
3894
+ });
3895
+ const newDoc = await convertLegacyReferences(structuredClone(handle.docSync()));
3896
+ const migratedDoc = migrateDocument(handle.docSync(), newDoc);
3897
+ const newHandle = context.repo.import(am.save(migratedDoc));
3898
+ newRootContent.links[id] = newHandle.url;
3899
+ } catch (err) {
3900
+ log13.warn("Failed to migrate reference", {
3901
+ id,
3902
+ url,
3903
+ error: err
3904
+ }, {
3905
+ F: __dxlog_file16,
3906
+ L: 114,
3907
+ S: void 0,
3908
+ C: (f, a) => f(...a)
3909
+ });
3910
+ delete newRootContent.links[id];
3911
+ }
3906
3912
  }
3907
3913
  const migratedRoot = migrateDocument(rootHandle.docSync(), newRootContent);
3908
3914
  const newRoot = context.repo.import(am.save(migratedRoot));
@@ -3913,8 +3919,8 @@ var runEpochMigration = async (ctx, context) => {
3913
3919
  }
3914
3920
  case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
3915
3921
  invariant12(context.newAutomergeRoot, void 0, {
3916
- F: __dxlog_file15,
3917
- L: 124,
3922
+ F: __dxlog_file16,
3923
+ L: 129,
3918
3924
  S: void 0,
3919
3925
  A: [
3920
3926
  "context.newAutomergeRoot",
@@ -3939,14 +3945,17 @@ import { log as log14 } from "@dxos/log";
3939
3945
  import { schema as schema4 } from "@dxos/protocols";
3940
3946
  import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
3941
3947
  import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet4, entry } from "@dxos/util";
3942
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3948
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3943
3949
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3944
3950
  var DEFAULT_SUCCESS_DELAY = 1e3;
3945
3951
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
3946
3952
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3947
3953
  var NotarizationPlugin = class {
3948
3954
  constructor() {
3949
- this._ctx = new Context7();
3955
+ this._ctx = new Context7(void 0, {
3956
+ F: __dxlog_file17,
3957
+ L: 62
3958
+ });
3950
3959
  this._extensionOpened = new Event5();
3951
3960
  this._extensions = /* @__PURE__ */ new Set();
3952
3961
  this._processedCredentials = new ComplexSet4(PublicKey9.hash);
@@ -3967,13 +3976,13 @@ var NotarizationPlugin = class {
3967
3976
  log14("notarize", {
3968
3977
  credentials
3969
3978
  }, {
3970
- F: __dxlog_file16,
3979
+ F: __dxlog_file17,
3971
3980
  L: 90,
3972
3981
  S: this,
3973
3982
  C: (f, a) => f(...a)
3974
3983
  });
3975
3984
  invariant13(credentials.every((credential) => credential.id), "Credentials must have an id", {
3976
- F: __dxlog_file16,
3985
+ F: __dxlog_file17,
3977
3986
  L: 91,
3978
3987
  S: this,
3979
3988
  A: [
@@ -3987,7 +3996,7 @@ var NotarizationPlugin = class {
3987
3996
  log14.warn("Notarization error", {
3988
3997
  err
3989
3998
  }, {
3990
- F: __dxlog_file16,
3999
+ F: __dxlog_file17,
3991
4000
  L: 99,
3992
4001
  S: this,
3993
4002
  C: (f, a) => f(...a)
@@ -4003,7 +4012,7 @@ var NotarizationPlugin = class {
4003
4012
  timeout,
4004
4013
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
4005
4014
  }, {
4006
- F: __dxlog_file16,
4015
+ F: __dxlog_file17,
4007
4016
  L: 111,
4008
4017
  S: this,
4009
4018
  C: (f, a) => f(...a)
@@ -4026,7 +4035,7 @@ var NotarizationPlugin = class {
4026
4035
  log14.info("Exhausted all peers to notarize with", {
4027
4036
  retryIn: retryTimeout
4028
4037
  }, {
4029
- F: __dxlog_file16,
4038
+ F: __dxlog_file17,
4030
4039
  L: 136,
4031
4040
  S: this,
4032
4041
  C: (f, a) => f(...a)
@@ -4040,7 +4049,7 @@ var NotarizationPlugin = class {
4040
4049
  peer: peer.localPeerId,
4041
4050
  credentialId: credentials.map((credential) => credential.id)
4042
4051
  }, {
4043
- F: __dxlog_file16,
4052
+ F: __dxlog_file17,
4044
4053
  L: 143,
4045
4054
  S: this,
4046
4055
  C: (f, a) => f(...a)
@@ -4049,7 +4058,7 @@ var NotarizationPlugin = class {
4049
4058
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
4050
4059
  });
4051
4060
  log14("success", void 0, {
4052
- F: __dxlog_file16,
4061
+ F: __dxlog_file17,
4053
4062
  L: 147,
4054
4063
  S: this,
4055
4064
  C: (f, a) => f(...a)
@@ -4058,7 +4067,7 @@ var NotarizationPlugin = class {
4058
4067
  } catch (err) {
4059
4068
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
4060
4069
  log14.info("error notarizing (recoverable)", err, {
4061
- F: __dxlog_file16,
4070
+ F: __dxlog_file17,
4062
4071
  L: 151,
4063
4072
  S: this,
4064
4073
  C: (f, a) => f(...a)
@@ -4076,7 +4085,7 @@ var NotarizationPlugin = class {
4076
4085
  errors.wait()
4077
4086
  ]);
4078
4087
  log14("done", void 0, {
4079
- F: __dxlog_file16,
4088
+ F: __dxlog_file17,
4080
4089
  L: 162,
4081
4090
  S: this,
4082
4091
  C: (f, a) => f(...a)
@@ -4098,7 +4107,7 @@ var NotarizationPlugin = class {
4098
4107
  }
4099
4108
  setWriter(writer) {
4100
4109
  invariant13(!this._writer, "Writer already set.", {
4101
- F: __dxlog_file16,
4110
+ F: __dxlog_file17,
4102
4111
  L: 181,
4103
4112
  S: this,
4104
4113
  A: [
@@ -4123,7 +4132,7 @@ var NotarizationPlugin = class {
4123
4132
  }
4124
4133
  for (const credential of request.credentials ?? []) {
4125
4134
  invariant13(credential.id, "Credential must have an id", {
4126
- F: __dxlog_file16,
4135
+ F: __dxlog_file17,
4127
4136
  L: 200,
4128
4137
  S: this,
4129
4138
  A: [
@@ -4143,7 +4152,7 @@ var NotarizationPlugin = class {
4143
4152
  log14("extension opened", {
4144
4153
  peer: extension.localPeerId
4145
4154
  }, {
4146
- F: __dxlog_file16,
4155
+ F: __dxlog_file17,
4147
4156
  L: 211,
4148
4157
  S: this,
4149
4158
  C: (f, a) => f(...a)
@@ -4155,7 +4164,7 @@ var NotarizationPlugin = class {
4155
4164
  log14("extension closed", {
4156
4165
  peer: extension.localPeerId
4157
4166
  }, {
4158
- F: __dxlog_file16,
4167
+ F: __dxlog_file17,
4159
4168
  L: 216,
4160
4169
  S: this,
4161
4170
  C: (f, a) => f(...a)
@@ -4272,10 +4281,13 @@ function _using_ctx() {
4272
4281
  }
4273
4282
  };
4274
4283
  }
4275
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4284
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4276
4285
  var DataSpace = class {
4277
4286
  constructor(params) {
4278
- this._ctx = new Context8();
4287
+ this._ctx = new Context8(void 0, {
4288
+ F: __dxlog_file18,
4289
+ L: 84
4290
+ });
4279
4291
  this._notarizationPlugin = new NotarizationPlugin();
4280
4292
  this._cache = void 0;
4281
4293
  // TODO(dmaretskyi): Move into Space?
@@ -4309,7 +4321,7 @@ var DataSpace = class {
4309
4321
  log15("new state", {
4310
4322
  state: SpaceState2[this._state]
4311
4323
  }, {
4312
- F: __dxlog_file17,
4324
+ F: __dxlog_file18,
4313
4325
  L: 146,
4314
4326
  S: this,
4315
4327
  C: (f, a) => f(...a)
@@ -4364,12 +4376,15 @@ var DataSpace = class {
4364
4376
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
4365
4377
  await this._automergeSpaceState.open();
4366
4378
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
4367
- await this._inner.open(new Context8());
4379
+ await this._inner.open(new Context8(void 0, {
4380
+ F: __dxlog_file18,
4381
+ L: 215
4382
+ }));
4368
4383
  this._state = SpaceState2.CONTROL_ONLY;
4369
4384
  log15("new state", {
4370
4385
  state: SpaceState2[this._state]
4371
4386
  }, {
4372
- F: __dxlog_file17,
4387
+ F: __dxlog_file18,
4373
4388
  L: 217,
4374
4389
  S: this,
4375
4390
  C: (f, a) => f(...a)
@@ -4387,13 +4402,16 @@ var DataSpace = class {
4387
4402
  log15("new state", {
4388
4403
  state: SpaceState2[this._state]
4389
4404
  }, {
4390
- F: __dxlog_file17,
4405
+ F: __dxlog_file18,
4391
4406
  L: 231,
4392
4407
  S: this,
4393
4408
  C: (f, a) => f(...a)
4394
4409
  });
4395
4410
  await this._ctx.dispose();
4396
- this._ctx = new Context8();
4411
+ this._ctx = new Context8(void 0, {
4412
+ F: __dxlog_file18,
4413
+ L: 233
4414
+ });
4397
4415
  await this.authVerifier.close();
4398
4416
  await this._inner.close();
4399
4417
  await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
@@ -4420,7 +4438,7 @@ var DataSpace = class {
4420
4438
  } catch (err) {
4421
4439
  if (err instanceof CancelledError || err instanceof ContextDisposedError3) {
4422
4440
  log15("data pipeline initialization cancelled", err, {
4423
- F: __dxlog_file17,
4441
+ F: __dxlog_file18,
4424
4442
  L: 265,
4425
4443
  S: this,
4426
4444
  C: (f, a) => f(...a)
@@ -4428,7 +4446,7 @@ var DataSpace = class {
4428
4446
  return;
4429
4447
  }
4430
4448
  log15.error("Error initializing data pipeline", err, {
4431
- F: __dxlog_file17,
4449
+ F: __dxlog_file18,
4432
4450
  L: 269,
4433
4451
  S: this,
4434
4452
  C: (f, a) => f(...a)
@@ -4437,7 +4455,7 @@ var DataSpace = class {
4437
4455
  log15("new state", {
4438
4456
  state: SpaceState2[this._state]
4439
4457
  }, {
4440
- F: __dxlog_file17,
4458
+ F: __dxlog_file18,
4441
4459
  L: 271,
4442
4460
  S: this,
4443
4461
  C: (f, a) => f(...a)
@@ -4457,7 +4475,7 @@ var DataSpace = class {
4457
4475
  log15("new state", {
4458
4476
  state: SpaceState2[this._state]
4459
4477
  }, {
4460
- F: __dxlog_file17,
4478
+ F: __dxlog_file18,
4461
4479
  L: 287,
4462
4480
  S: this,
4463
4481
  C: (f, a) => f(...a)
@@ -4474,7 +4492,7 @@ var DataSpace = class {
4474
4492
  log15("new state", {
4475
4493
  state: SpaceState2[this._state]
4476
4494
  }, {
4477
- F: __dxlog_file17,
4495
+ F: __dxlog_file18,
4478
4496
  L: 306,
4479
4497
  S: this,
4480
4498
  C: (f, a) => f(...a)
@@ -4490,7 +4508,7 @@ var DataSpace = class {
4490
4508
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
4491
4509
  await this._createWritableFeeds();
4492
4510
  log15("writable feeds created", void 0, {
4493
- F: __dxlog_file17,
4511
+ F: __dxlog_file18,
4494
4512
  L: 322,
4495
4513
  S: this,
4496
4514
  C: (f, a) => f(...a)
@@ -4553,7 +4571,7 @@ var DataSpace = class {
4553
4571
  space: this.key,
4554
4572
  rootUrl
4555
4573
  }, {
4556
- F: __dxlog_file17,
4574
+ F: __dxlog_file18,
4557
4575
  L: 388,
4558
4576
  S: this,
4559
4577
  C: (f, a) => f(...a)
@@ -4607,7 +4625,7 @@ var DataSpace = class {
4607
4625
  rootUrl,
4608
4626
  err
4609
4627
  }, {
4610
- F: __dxlog_file17,
4628
+ F: __dxlog_file18,
4611
4629
  L: 431,
4612
4630
  S: this,
4613
4631
  C: (f, a) => f(...a)
@@ -4693,7 +4711,7 @@ var DataSpace = class {
4693
4711
  log15("new state", {
4694
4712
  state: SpaceState2[this._state]
4695
4713
  }, {
4696
- F: __dxlog_file17,
4714
+ F: __dxlog_file18,
4697
4715
  L: 512,
4698
4716
  S: this,
4699
4717
  C: (f, a) => f(...a)
@@ -4754,15 +4772,17 @@ DataSpace = _ts_decorate4([
4754
4772
  import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
4755
4773
  import { PropertiesType } from "@dxos/client-protocol";
4756
4774
  import { Context as Context9, cancelWithContext as cancelWithContext6 } from "@dxos/context";
4757
- import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
4775
+ import { getCredentialAssertion as getCredentialAssertion3, createAdmissionCredentials } from "@dxos/credentials";
4758
4776
  import { convertLegacyReferences as convertLegacyReferences2, findInlineObjectOfType as findInlineObjectOfType2 } from "@dxos/echo-db";
4759
4777
  import { AuthStatus } from "@dxos/echo-pipeline";
4778
+ import { CredentialServerExtension } from "@dxos/echo-pipeline";
4760
4779
  import { LEGACY_TYPE_PROPERTIES, SpaceDocVersion as SpaceDocVersion2, encodeReference } from "@dxos/echo-protocol";
4761
4780
  import { TYPE_PROPERTIES as TYPE_PROPERTIES2, generateEchoId, getTypeReference } from "@dxos/echo-schema";
4781
+ import { writeMessages as writeMessages3 } from "@dxos/feed-store";
4762
4782
  import { invariant as invariant14 } from "@dxos/invariant";
4763
4783
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4764
4784
  import { log as log16 } from "@dxos/log";
4765
- import { trace as Trace2 } from "@dxos/protocols";
4785
+ import { trace as Trace2, AlreadyJoinedError as AlreadyJoinedError3 } from "@dxos/protocols";
4766
4786
  import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
4767
4787
  import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
4768
4788
  import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
@@ -4850,7 +4870,7 @@ function _ts_decorate5(decorators, target, key, desc) {
4850
4870
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4851
4871
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4852
4872
  }
4853
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4873
+ var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4854
4874
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
4855
4875
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
4856
4876
  var DEFAULT_SPACE_KEY = "__DEFAULT__";
@@ -4864,7 +4884,10 @@ var DataSpaceManager = class {
4864
4884
  this._echoHost = _echoHost;
4865
4885
  this._invitationsManager = _invitationsManager;
4866
4886
  this._params = _params;
4867
- this._ctx = new Context9();
4887
+ this._ctx = new Context9(void 0, {
4888
+ F: __dxlog_file19,
4889
+ L: 104
4890
+ });
4868
4891
  this.updated = new Event7();
4869
4892
  this._spaces = new ComplexMap3(PublicKey11.hash);
4870
4893
  this._isOpen = false;
@@ -4898,24 +4921,24 @@ var DataSpaceManager = class {
4898
4921
  }
4899
4922
  async open() {
4900
4923
  log16("open", void 0, {
4901
- F: __dxlog_file18,
4902
- L: 146,
4924
+ F: __dxlog_file19,
4925
+ L: 156,
4903
4926
  S: this,
4904
4927
  C: (f, a) => f(...a)
4905
4928
  });
4906
4929
  log16.trace("dxos.echo.data-space-manager.open", Trace2.begin({
4907
4930
  id: this._instanceId
4908
4931
  }), {
4909
- F: __dxlog_file18,
4910
- L: 147,
4932
+ F: __dxlog_file19,
4933
+ L: 157,
4911
4934
  S: this,
4912
4935
  C: (f, a) => f(...a)
4913
4936
  });
4914
4937
  log16("metadata loaded", {
4915
4938
  spaces: this._metadataStore.spaces.length
4916
4939
  }, {
4917
- F: __dxlog_file18,
4918
- L: 148,
4940
+ F: __dxlog_file19,
4941
+ L: 158,
4919
4942
  S: this,
4920
4943
  C: (f, a) => f(...a)
4921
4944
  });
@@ -4924,8 +4947,8 @@ var DataSpaceManager = class {
4924
4947
  log16("load space", {
4925
4948
  spaceMetadata
4926
4949
  }, {
4927
- F: __dxlog_file18,
4928
- L: 152,
4950
+ F: __dxlog_file19,
4951
+ L: 162,
4929
4952
  S: this,
4930
4953
  C: (f, a) => f(...a)
4931
4954
  });
@@ -4935,8 +4958,8 @@ var DataSpaceManager = class {
4935
4958
  spaceMetadata,
4936
4959
  err
4937
4960
  }, {
4938
- F: __dxlog_file18,
4939
- L: 155,
4961
+ F: __dxlog_file19,
4962
+ L: 165,
4940
4963
  S: this,
4941
4964
  C: (f, a) => f(...a)
4942
4965
  });
@@ -4947,16 +4970,16 @@ var DataSpaceManager = class {
4947
4970
  log16.trace("dxos.echo.data-space-manager.open", Trace2.end({
4948
4971
  id: this._instanceId
4949
4972
  }), {
4950
- F: __dxlog_file18,
4951
- L: 162,
4973
+ F: __dxlog_file19,
4974
+ L: 172,
4952
4975
  S: this,
4953
4976
  C: (f, a) => f(...a)
4954
4977
  });
4955
4978
  }
4956
4979
  async close() {
4957
4980
  log16("close", void 0, {
4958
- F: __dxlog_file18,
4959
- L: 167,
4981
+ F: __dxlog_file19,
4982
+ L: 177,
4960
4983
  S: this,
4961
4984
  C: (f, a) => f(...a)
4962
4985
  });
@@ -4972,8 +4995,8 @@ var DataSpaceManager = class {
4972
4995
  */
4973
4996
  async createSpace() {
4974
4997
  invariant14(this._isOpen, "Not open.", {
4975
- F: __dxlog_file18,
4976
- L: 181,
4998
+ F: __dxlog_file19,
4999
+ L: 191,
4977
5000
  S: this,
4978
5001
  A: [
4979
5002
  "this._isOpen",
@@ -4993,8 +5016,8 @@ var DataSpaceManager = class {
4993
5016
  log16("creating space...", {
4994
5017
  spaceKey
4995
5018
  }, {
4996
- F: __dxlog_file18,
4997
- L: 193,
5019
+ F: __dxlog_file19,
5020
+ L: 203,
4998
5021
  S: this,
4999
5022
  C: (f, a) => f(...a)
5000
5023
  });
@@ -5005,8 +5028,8 @@ var DataSpaceManager = class {
5005
5028
  await this._metadataStore.addSpace(metadata);
5006
5029
  const memberCredential = credentials[1];
5007
5030
  invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5008
- F: __dxlog_file18,
5009
- L: 203,
5031
+ F: __dxlog_file19,
5032
+ L: 213,
5010
5033
  S: this,
5011
5034
  A: [
5012
5035
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -5037,8 +5060,8 @@ var DataSpaceManager = class {
5037
5060
  version: space.databaseRoot.getVersion(),
5038
5061
  spaceId: space.id
5039
5062
  }, {
5040
- F: __dxlog_file18,
5041
- L: 228,
5063
+ F: __dxlog_file19,
5064
+ L: 238,
5042
5065
  S: this,
5043
5066
  C: (f, a) => f(...a)
5044
5067
  });
@@ -5072,8 +5095,8 @@ var DataSpaceManager = class {
5072
5095
  async _getSpaceRootDocument(space) {
5073
5096
  const automergeIndex = space.automergeSpaceState.rootUrl;
5074
5097
  invariant14(automergeIndex, void 0, {
5075
- F: __dxlog_file18,
5076
- L: 261,
5098
+ F: __dxlog_file19,
5099
+ L: 271,
5077
5100
  S: this,
5078
5101
  A: [
5079
5102
  "automergeIndex",
@@ -5089,14 +5112,14 @@ var DataSpaceManager = class {
5089
5112
  log16("accept space", {
5090
5113
  opts
5091
5114
  }, {
5092
- F: __dxlog_file18,
5093
- L: 270,
5115
+ F: __dxlog_file19,
5116
+ L: 280,
5094
5117
  S: this,
5095
5118
  C: (f, a) => f(...a)
5096
5119
  });
5097
5120
  invariant14(this._isOpen, "Not open.", {
5098
- F: __dxlog_file18,
5099
- L: 271,
5121
+ F: __dxlog_file19,
5122
+ L: 281,
5100
5123
  S: this,
5101
5124
  A: [
5102
5125
  "this._isOpen",
@@ -5104,8 +5127,8 @@ var DataSpaceManager = class {
5104
5127
  ]
5105
5128
  });
5106
5129
  invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
5107
- F: __dxlog_file18,
5108
- L: 272,
5130
+ F: __dxlog_file19,
5131
+ L: 282,
5109
5132
  S: this,
5110
5133
  A: [
5111
5134
  "!this._spaces.has(opts.spaceKey)",
@@ -5125,6 +5148,43 @@ var DataSpaceManager = class {
5125
5148
  this.updated.emit();
5126
5149
  return space;
5127
5150
  }
5151
+ async admitMember(options) {
5152
+ const space = this._spaceManager.spaces.get(options.spaceKey);
5153
+ invariant14(space, void 0, {
5154
+ F: __dxlog_file19,
5155
+ L: 302,
5156
+ S: this,
5157
+ A: [
5158
+ "space",
5159
+ ""
5160
+ ]
5161
+ });
5162
+ if (space.spaceState.getMemberRole(options.identityKey) !== SpaceMember6.Role.REMOVED) {
5163
+ throw new AlreadyJoinedError3();
5164
+ }
5165
+ const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
5166
+ invariant14(credentials[0].credential, void 0, {
5167
+ F: __dxlog_file19,
5168
+ L: 321,
5169
+ S: this,
5170
+ A: [
5171
+ "credentials[0].credential",
5172
+ ""
5173
+ ]
5174
+ });
5175
+ const spaceMemberCredential = credentials[0].credential.credential;
5176
+ invariant14(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5177
+ F: __dxlog_file19,
5178
+ L: 323,
5179
+ S: this,
5180
+ A: [
5181
+ "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5182
+ ""
5183
+ ]
5184
+ });
5185
+ await writeMessages3(space.controlPipeline.writer, credentials);
5186
+ return spaceMemberCredential;
5187
+ }
5128
5188
  /**
5129
5189
  * Wait until the space data pipeline is fully initialized.
5130
5190
  * Used by invitation handler.
@@ -5136,12 +5196,24 @@ var DataSpaceManager = class {
5136
5196
  return !!space && space.state === SpaceState3.READY;
5137
5197
  }));
5138
5198
  }
5199
+ async requestSpaceAdmissionCredential(spaceKey) {
5200
+ return this._spaceManager.requestSpaceAdmissionCredential({
5201
+ spaceKey,
5202
+ identityKey: this._signingContext.identityKey,
5203
+ timeout: 15e3,
5204
+ swarmIdentity: {
5205
+ peerKey: this._signingContext.deviceKey,
5206
+ credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5207
+ credentialAuthenticator: async () => true
5208
+ }
5209
+ });
5210
+ }
5139
5211
  async _constructSpace(metadata) {
5140
5212
  log16("construct space", {
5141
5213
  metadata
5142
5214
  }, {
5143
- F: __dxlog_file18,
5144
- L: 306,
5215
+ F: __dxlog_file19,
5216
+ L: 358,
5145
5217
  S: this,
5146
5218
  C: (f, a) => f(...a)
5147
5219
  });
@@ -5169,6 +5241,7 @@ var DataSpaceManager = class {
5169
5241
  credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
5170
5242
  },
5171
5243
  onAuthorizedConnection: (session) => {
5244
+ session.addExtension("dxos.mesh.teleport.admission-discovery", new CredentialServerExtension(space));
5172
5245
  session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5173
5246
  remotePeerId: session.remotePeerId
5174
5247
  }));
@@ -5178,8 +5251,8 @@ var DataSpaceManager = class {
5178
5251
  },
5179
5252
  onAuthFailure: () => {
5180
5253
  log16.warn("auth failure", void 0, {
5181
- F: __dxlog_file18,
5182
- L: 343,
5254
+ F: __dxlog_file19,
5255
+ L: 396,
5183
5256
  S: this,
5184
5257
  C: (f, a) => f(...a)
5185
5258
  });
@@ -5211,8 +5284,8 @@ var DataSpaceManager = class {
5211
5284
  log16("before space ready", {
5212
5285
  space: space.key
5213
5286
  }, {
5214
- F: __dxlog_file18,
5215
- L: 370,
5287
+ F: __dxlog_file19,
5288
+ L: 423,
5216
5289
  S: this,
5217
5290
  C: (f, a) => f(...a)
5218
5291
  });
@@ -5222,8 +5295,8 @@ var DataSpaceManager = class {
5222
5295
  space: space.key,
5223
5296
  open: this._isOpen
5224
5297
  }, {
5225
- F: __dxlog_file18,
5226
- L: 373,
5298
+ F: __dxlog_file19,
5299
+ L: 426,
5227
5300
  S: this,
5228
5301
  C: (f, a) => f(...a)
5229
5302
  });
@@ -5241,8 +5314,8 @@ var DataSpaceManager = class {
5241
5314
  log16("before space close", {
5242
5315
  space: space.key
5243
5316
  }, {
5244
- F: __dxlog_file18,
5245
- L: 381,
5317
+ F: __dxlog_file19,
5318
+ L: 434,
5246
5319
  S: this,
5247
5320
  C: (f, a) => f(...a)
5248
5321
  });
@@ -5282,8 +5355,8 @@ var DataSpaceManager = class {
5282
5355
  peersOnline: presence.getPeersOnline().length,
5283
5356
  closedSessions
5284
5357
  }, {
5285
- F: __dxlog_file18,
5286
- L: 417,
5358
+ F: __dxlog_file19,
5359
+ L: 470,
5287
5360
  S: this,
5288
5361
  C: (f, a) => f(...a)
5289
5362
  });
@@ -5297,8 +5370,8 @@ var DataSpaceManager = class {
5297
5370
  log16("closing a session with a removed peer", {
5298
5371
  peerId: peerState.peerId
5299
5372
  }, {
5300
- F: __dxlog_file18,
5301
- L: 431,
5373
+ F: __dxlog_file19,
5374
+ L: 484,
5302
5375
  S: this,
5303
5376
  C: (f, a) => f(...a)
5304
5377
  });
@@ -5363,13 +5436,13 @@ import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTas
5363
5436
  import { Stream as Stream10 } from "@dxos/codec-protobuf";
5364
5437
  import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
5365
5438
  import { raise as raise2 } from "@dxos/debug";
5366
- import { writeMessages as writeMessages3 } from "@dxos/feed-store";
5439
+ import { writeMessages as writeMessages4 } from "@dxos/feed-store";
5367
5440
  import { invariant as invariant15 } from "@dxos/invariant";
5368
5441
  import { log as log17 } from "@dxos/log";
5369
5442
  import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
5370
5443
  import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
5371
5444
  import { trace as trace8 } from "@dxos/tracing";
5372
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5445
+ var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5373
5446
  var SpacesServiceImpl = class {
5374
5447
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
5375
5448
  this._identityManager = _identityManager;
@@ -5413,8 +5486,8 @@ var SpacesServiceImpl = class {
5413
5486
  }
5414
5487
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
5415
5488
  invariant15(credentials[0].credential, void 0, {
5416
- F: __dxlog_file19,
5417
- L: 98,
5489
+ F: __dxlog_file20,
5490
+ L: 102,
5418
5491
  S: this,
5419
5492
  A: [
5420
5493
  "credentials[0].credential",
@@ -5423,15 +5496,15 @@ var SpacesServiceImpl = class {
5423
5496
  });
5424
5497
  const spaceMemberCredential = credentials[0].credential.credential;
5425
5498
  invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5426
- F: __dxlog_file19,
5427
- L: 100,
5499
+ F: __dxlog_file20,
5500
+ L: 104,
5428
5501
  S: this,
5429
5502
  A: [
5430
5503
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5431
5504
  ""
5432
5505
  ]
5433
5506
  });
5434
- await writeMessages3(space.controlPipeline.writer, credentials);
5507
+ await writeMessages4(space.controlPipeline.writer, credentials);
5435
5508
  }
5436
5509
  querySpaces() {
5437
5510
  return new Stream10(({ next, ctx }) => {
@@ -5441,8 +5514,8 @@ var SpacesServiceImpl = class {
5441
5514
  log17("update", {
5442
5515
  spaces
5443
5516
  }, {
5444
- F: __dxlog_file19,
5445
- L: 111,
5517
+ F: __dxlog_file20,
5518
+ L: 115,
5446
5519
  S: this,
5447
5520
  C: (f, a) => f(...a)
5448
5521
  });
@@ -5533,8 +5606,8 @@ var SpacesServiceImpl = class {
5533
5606
  });
5534
5607
  } else {
5535
5608
  invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
5536
- F: __dxlog_file19,
5537
- L: 209,
5609
+ F: __dxlog_file20,
5610
+ L: 213,
5538
5611
  S: this,
5539
5612
  A: [
5540
5613
  "!credential.id",
@@ -5542,8 +5615,8 @@ var SpacesServiceImpl = class {
5542
5615
  ]
5543
5616
  });
5544
5617
  invariant15(this._identityManager.identity, "Identity is not available", {
5545
- F: __dxlog_file19,
5546
- L: 210,
5618
+ F: __dxlog_file20,
5619
+ L: 214,
5547
5620
  S: this,
5548
5621
  A: [
5549
5622
  "this._identityManager.identity",
@@ -5552,8 +5625,8 @@ var SpacesServiceImpl = class {
5552
5625
  });
5553
5626
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
5554
5627
  invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
5555
- F: __dxlog_file19,
5556
- L: 212,
5628
+ F: __dxlog_file20,
5629
+ L: 216,
5557
5630
  S: this,
5558
5631
  A: [
5559
5632
  "credential.issuer.equals(signer.getIssuer())",
@@ -5583,6 +5656,59 @@ var SpacesServiceImpl = class {
5583
5656
  epochCredential: credential ?? void 0
5584
5657
  };
5585
5658
  }
5659
+ async admitContact(request) {
5660
+ const dataSpaceManager = await this._getDataSpaceManager();
5661
+ await dataSpaceManager.admitMember({
5662
+ spaceKey: request.spaceKey,
5663
+ identityKey: request.contact.identityKey,
5664
+ role: request.role
5665
+ });
5666
+ }
5667
+ async joinBySpaceKey({ spaceKey }) {
5668
+ const dataSpaceManager = await this._getDataSpaceManager();
5669
+ const credential = await dataSpaceManager.requestSpaceAdmissionCredential(spaceKey);
5670
+ return this._joinByAdmission({
5671
+ credential
5672
+ });
5673
+ }
5674
+ async _joinByAdmission({ credential }) {
5675
+ const assertion = getCredentialAssertion4(credential);
5676
+ invariant15(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
5677
+ F: __dxlog_file20,
5678
+ L: 250,
5679
+ S: this,
5680
+ A: [
5681
+ "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
5682
+ "'Invalid credential'"
5683
+ ]
5684
+ });
5685
+ const myIdentity = this._identityManager.identity;
5686
+ invariant15(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
5687
+ F: __dxlog_file20,
5688
+ L: 252,
5689
+ S: this,
5690
+ A: [
5691
+ "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
5692
+ ""
5693
+ ]
5694
+ });
5695
+ const dataSpaceManager = await this._getDataSpaceManager();
5696
+ let dataSpace = dataSpaceManager.spaces.get(assertion.spaceKey);
5697
+ if (!dataSpace) {
5698
+ dataSpace = await dataSpaceManager.acceptSpace({
5699
+ spaceKey: assertion.spaceKey,
5700
+ genesisFeedKey: assertion.genesisFeedKey
5701
+ });
5702
+ await myIdentity.controlPipeline.writer.write({
5703
+ credential: {
5704
+ credential
5705
+ }
5706
+ });
5707
+ }
5708
+ return {
5709
+ space: this._serializeSpace(dataSpace)
5710
+ };
5711
+ }
5586
5712
  _serializeSpace(space) {
5587
5713
  return {
5588
5714
  id: space.id,
@@ -5670,7 +5796,7 @@ function _ts_decorate6(decorators, target, key, desc) {
5670
5796
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5671
5797
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5672
5798
  }
5673
- var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5799
+ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5674
5800
  var ServiceContext = class extends Resource3 {
5675
5801
  constructor(storage, level, networkManager, signalManager, _runtimeParams) {
5676
5802
  super();
@@ -5714,7 +5840,7 @@ var ServiceContext = class extends Resource3 {
5714
5840
  async _open(ctx) {
5715
5841
  await this._checkStorageVersion();
5716
5842
  log18("opening...", void 0, {
5717
- F: __dxlog_file20,
5843
+ F: __dxlog_file21,
5718
5844
  L: 149,
5719
5845
  S: this,
5720
5846
  C: (f, a) => f(...a)
@@ -5722,7 +5848,7 @@ var ServiceContext = class extends Resource3 {
5722
5848
  log18.trace("dxos.sdk.service-context.open", trace9.begin({
5723
5849
  id: this._instanceId
5724
5850
  }), {
5725
- F: __dxlog_file20,
5851
+ F: __dxlog_file21,
5726
5852
  L: 150,
5727
5853
  S: this,
5728
5854
  C: (f, a) => f(...a)
@@ -5740,7 +5866,7 @@ var ServiceContext = class extends Resource3 {
5740
5866
  log18("loaded persistent invitations", {
5741
5867
  count: loadedInvitations.invitations?.length
5742
5868
  }, {
5743
- F: __dxlog_file20,
5869
+ F: __dxlog_file21,
5744
5870
  L: 163,
5745
5871
  S: this,
5746
5872
  C: (f, a) => f(...a)
@@ -5748,13 +5874,13 @@ var ServiceContext = class extends Resource3 {
5748
5874
  log18.trace("dxos.sdk.service-context.open", trace9.end({
5749
5875
  id: this._instanceId
5750
5876
  }), {
5751
- F: __dxlog_file20,
5877
+ F: __dxlog_file21,
5752
5878
  L: 165,
5753
5879
  S: this,
5754
5880
  C: (f, a) => f(...a)
5755
5881
  });
5756
5882
  log18("opened", void 0, {
5757
- F: __dxlog_file20,
5883
+ F: __dxlog_file21,
5758
5884
  L: 166,
5759
5885
  S: this,
5760
5886
  C: (f, a) => f(...a)
@@ -5762,7 +5888,7 @@ var ServiceContext = class extends Resource3 {
5762
5888
  }
5763
5889
  async _close(ctx) {
5764
5890
  log18("closing...", void 0, {
5765
- F: __dxlog_file20,
5891
+ F: __dxlog_file21,
5766
5892
  L: 170,
5767
5893
  S: this,
5768
5894
  C: (f, a) => f(...a)
@@ -5779,7 +5905,7 @@ var ServiceContext = class extends Resource3 {
5779
5905
  await this.networkManager.close();
5780
5906
  await this.signalManager.close();
5781
5907
  log18("closed", void 0, {
5782
- F: __dxlog_file20,
5908
+ F: __dxlog_file21,
5783
5909
  L: 182,
5784
5910
  S: this,
5785
5911
  C: (f, a) => f(...a)
@@ -5787,13 +5913,16 @@ var ServiceContext = class extends Resource3 {
5787
5913
  }
5788
5914
  async createIdentity(params = {}) {
5789
5915
  const identity = await this.identityManager.createIdentity(params);
5790
- await this._initialize(new Context10());
5916
+ await this._initialize(new Context10(void 0, {
5917
+ F: __dxlog_file21,
5918
+ L: 187
5919
+ }));
5791
5920
  return identity;
5792
5921
  }
5793
5922
  getInvitationHandler(invitation) {
5794
5923
  const factory = this._handlerFactories.get(invitation.kind);
5795
5924
  invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
5796
- F: __dxlog_file20,
5925
+ F: __dxlog_file21,
5797
5926
  L: 193,
5798
5927
  S: this,
5799
5928
  A: [
@@ -5813,7 +5942,10 @@ var ServiceContext = class extends Resource3 {
5813
5942
  }
5814
5943
  async _acceptIdentity(params) {
5815
5944
  const identity = await this.identityManager.acceptIdentity(params);
5816
- await this._initialize(new Context10());
5945
+ await this._initialize(new Context10(void 0, {
5946
+ F: __dxlog_file21,
5947
+ L: 209
5948
+ }));
5817
5949
  return identity;
5818
5950
  }
5819
5951
  async _checkStorageVersion() {
@@ -5825,7 +5957,7 @@ var ServiceContext = class extends Resource3 {
5825
5957
  // Called when identity is created.
5826
5958
  async _initialize(ctx) {
5827
5959
  log18("initializing spaces...", void 0, {
5828
- F: __dxlog_file20,
5960
+ F: __dxlog_file21,
5829
5961
  L: 224,
5830
5962
  S: this,
5831
5963
  C: (f, a) => f(...a)
@@ -5848,7 +5980,7 @@ var ServiceContext = class extends Resource3 {
5848
5980
  await this.dataSpaceManager.open();
5849
5981
  this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
5850
5982
  invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
5851
- F: __dxlog_file20,
5983
+ F: __dxlog_file21,
5852
5984
  L: 249,
5853
5985
  S: this,
5854
5986
  A: [
@@ -5872,7 +6004,7 @@ var ServiceContext = class extends Resource3 {
5872
6004
  log18("dataSpaceManager not initialized yet, ignoring space admission", {
5873
6005
  details: assertion
5874
6006
  }, {
5875
- F: __dxlog_file20,
6007
+ F: __dxlog_file21,
5876
6008
  L: 265,
5877
6009
  S: this,
5878
6010
  C: (f, a) => f(...a)
@@ -5883,7 +6015,7 @@ var ServiceContext = class extends Resource3 {
5883
6015
  log18("space already exists, ignoring space admission", {
5884
6016
  details: assertion
5885
6017
  }, {
5886
- F: __dxlog_file20,
6018
+ F: __dxlog_file21,
5887
6019
  L: 269,
5888
6020
  S: this,
5889
6021
  C: (f, a) => f(...a)
@@ -5894,7 +6026,7 @@ var ServiceContext = class extends Resource3 {
5894
6026
  log18("accepting space recorded in halo", {
5895
6027
  details: assertion
5896
6028
  }, {
5897
- F: __dxlog_file20,
6029
+ F: __dxlog_file21,
5898
6030
  L: 274,
5899
6031
  S: this,
5900
6032
  C: (f, a) => f(...a)
@@ -5905,7 +6037,7 @@ var ServiceContext = class extends Resource3 {
5905
6037
  });
5906
6038
  } catch (err) {
5907
6039
  log18.catch(err, void 0, {
5908
- F: __dxlog_file20,
6040
+ F: __dxlog_file21,
5909
6041
  L: 280,
5910
6042
  S: this,
5911
6043
  C: (f, a) => f(...a)
@@ -5965,7 +6097,7 @@ function _ts_decorate7(decorators, target, key, desc) {
5965
6097
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5966
6098
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5967
6099
  }
5968
- var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
6100
+ var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
5969
6101
  var Message;
5970
6102
  (function(Message2) {
5971
6103
  Message2["ACQUIRING"] = "acquiring";
@@ -5988,28 +6120,28 @@ var Lock = class {
5988
6120
  });
5989
6121
  try {
5990
6122
  log19("aquiring lock...", void 0, {
5991
- F: __dxlog_file21,
6123
+ F: __dxlog_file22,
5992
6124
  L: 42,
5993
6125
  S: this,
5994
6126
  C: (f, a) => f(...a)
5995
6127
  });
5996
6128
  await asyncTimeout3(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
5997
6129
  log19("acquired lock", void 0, {
5998
- F: __dxlog_file21,
6130
+ F: __dxlog_file22,
5999
6131
  L: 44,
6000
6132
  S: this,
6001
6133
  C: (f, a) => f(...a)
6002
6134
  });
6003
6135
  } catch {
6004
6136
  log19("stealing lock...", void 0, {
6005
- F: __dxlog_file21,
6137
+ F: __dxlog_file22,
6006
6138
  L: 46,
6007
6139
  S: this,
6008
6140
  C: (f, a) => f(...a)
6009
6141
  });
6010
6142
  await this._requestLock(true);
6011
6143
  log19("stolen lock", void 0, {
6012
- F: __dxlog_file21,
6144
+ F: __dxlog_file22,
6013
6145
  L: 48,
6014
6146
  S: this,
6015
6147
  C: (f, a) => f(...a)
@@ -6028,7 +6160,7 @@ var Lock = class {
6028
6160
  log19("requesting lock...", {
6029
6161
  steal
6030
6162
  }, {
6031
- F: __dxlog_file21,
6163
+ F: __dxlog_file22,
6032
6164
  L: 63,
6033
6165
  S: this,
6034
6166
  C: (f, a) => f(...a)
@@ -6042,14 +6174,14 @@ var Lock = class {
6042
6174
  this._releaseTrigger = new Trigger9();
6043
6175
  await this._releaseTrigger.wait();
6044
6176
  log19("releasing lock...", void 0, {
6045
- F: __dxlog_file21,
6177
+ F: __dxlog_file22,
6046
6178
  L: 72,
6047
6179
  S: this,
6048
6180
  C: (f, a) => f(...a)
6049
6181
  });
6050
6182
  await this._onRelease?.();
6051
6183
  log19("released lock", void 0, {
6052
- F: __dxlog_file21,
6184
+ F: __dxlog_file22,
6053
6185
  L: 74,
6054
6186
  S: this,
6055
6187
  C: (f, a) => f(...a)
@@ -6061,7 +6193,7 @@ var Lock = class {
6061
6193
  log19("recieved lock", {
6062
6194
  steal
6063
6195
  }, {
6064
- F: __dxlog_file21,
6196
+ F: __dxlog_file22,
6065
6197
  L: 81,
6066
6198
  S: this,
6067
6199
  C: (f, a) => f(...a)
@@ -6149,13 +6281,151 @@ var createLevel = async (config) => {
6149
6281
  return level;
6150
6282
  };
6151
6283
 
6284
+ // packages/sdk/client-services/src/packlets/storage/profile-archive.ts
6285
+ import { cbor } from "@dxos/automerge/automerge-repo";
6286
+ import { invariant as invariant17 } from "@dxos/invariant";
6287
+ import { log as log20 } from "@dxos/log";
6288
+ import { ProfileArchiveEntryType } from "@dxos/protocols";
6289
+ import { arrayToBuffer } from "@dxos/util";
6290
+ var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
6291
+ var encodeProfileArchive = (profile) => cbor.encode(profile);
6292
+ var decodeProfileArchive = (data) => cbor.decode(data);
6293
+ var exportProfileData = async ({ storage, level }) => {
6294
+ const archive = {
6295
+ storage: [],
6296
+ meta: {
6297
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
6298
+ }
6299
+ };
6300
+ {
6301
+ const directory = await storage.createDirectory();
6302
+ const files = await directory.list();
6303
+ log20.info("begin exporting files", {
6304
+ count: files.length
6305
+ }, {
6306
+ F: __dxlog_file23,
6307
+ L: 30,
6308
+ S: void 0,
6309
+ C: (f, a) => f(...a)
6310
+ });
6311
+ for (const filename of files) {
6312
+ const file = await directory.getOrCreateFile(filename);
6313
+ const { size } = await file.stat();
6314
+ const data = await file.read(0, size);
6315
+ archive.storage.push({
6316
+ type: ProfileArchiveEntryType.FILE,
6317
+ key: filename,
6318
+ value: data
6319
+ });
6320
+ }
6321
+ log20.info("done exporting files", {
6322
+ count: files.length
6323
+ }, {
6324
+ F: __dxlog_file23,
6325
+ L: 41,
6326
+ S: void 0,
6327
+ C: (f, a) => f(...a)
6328
+ });
6329
+ }
6330
+ {
6331
+ log20.info("begin exporting kv pairs", void 0, {
6332
+ F: __dxlog_file23,
6333
+ L: 45,
6334
+ S: void 0,
6335
+ C: (f, a) => f(...a)
6336
+ });
6337
+ const iter = await level.iterator({
6338
+ keyEncoding: "binary",
6339
+ valueEncoding: "binary"
6340
+ });
6341
+ let count = 0;
6342
+ for await (const [key, value] of iter) {
6343
+ archive.storage.push({
6344
+ type: ProfileArchiveEntryType.KEY_VALUE,
6345
+ key,
6346
+ value
6347
+ });
6348
+ count++;
6349
+ }
6350
+ log20.info("done exporting kv pairs", {
6351
+ count
6352
+ }, {
6353
+ F: __dxlog_file23,
6354
+ L: 56,
6355
+ S: void 0,
6356
+ C: (f, a) => f(...a)
6357
+ });
6358
+ }
6359
+ return archive;
6360
+ };
6361
+ var importProfileData = async ({ storage, level }, archive) => {
6362
+ const batch = level.batch();
6363
+ for (const entry2 of archive.storage) {
6364
+ switch (entry2.type) {
6365
+ case ProfileArchiveEntryType.FILE: {
6366
+ const directory = await storage.createDirectory();
6367
+ invariant17(typeof entry2.key === "string", "Invalid key type", {
6368
+ F: __dxlog_file23,
6369
+ L: 78,
6370
+ S: void 0,
6371
+ A: [
6372
+ "typeof entry.key === 'string'",
6373
+ "'Invalid key type'"
6374
+ ]
6375
+ });
6376
+ const file = await directory.getOrCreateFile(entry2.key);
6377
+ invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
6378
+ F: __dxlog_file23,
6379
+ L: 80,
6380
+ S: void 0,
6381
+ A: [
6382
+ "entry.value instanceof Uint8Array",
6383
+ "'Invalid value type'"
6384
+ ]
6385
+ });
6386
+ await file.write(0, arrayToBuffer(entry2.value));
6387
+ await file.close();
6388
+ break;
6389
+ }
6390
+ case ProfileArchiveEntryType.KEY_VALUE: {
6391
+ invariant17(entry2.key instanceof Uint8Array, "Invalid key type", {
6392
+ F: __dxlog_file23,
6393
+ L: 86,
6394
+ S: void 0,
6395
+ A: [
6396
+ "entry.key instanceof Uint8Array",
6397
+ "'Invalid key type'"
6398
+ ]
6399
+ });
6400
+ invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
6401
+ F: __dxlog_file23,
6402
+ L: 87,
6403
+ S: void 0,
6404
+ A: [
6405
+ "entry.value instanceof Uint8Array",
6406
+ "'Invalid value type'"
6407
+ ]
6408
+ });
6409
+ batch.put(entry2.key, entry2.value, {
6410
+ keyEncoding: "binary",
6411
+ valueEncoding: "binary"
6412
+ });
6413
+ break;
6414
+ }
6415
+ default:
6416
+ throw new Error(`Invalid entry type: ${entry2.type}`);
6417
+ }
6418
+ }
6419
+ await batch.write();
6420
+ };
6421
+
6152
6422
  // packages/sdk/client-services/src/packlets/services/service-host.ts
6153
6423
  import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
6154
6424
  import { clientServiceBundle } from "@dxos/client-protocol";
6155
6425
  import { Context as Context11 } from "@dxos/context";
6156
- import { invariant as invariant18 } from "@dxos/invariant";
6157
- import { PublicKey as PublicKey16 } from "@dxos/keys";
6158
- import { log as log21 } from "@dxos/log";
6426
+ import { invariant as invariant19 } from "@dxos/invariant";
6427
+ import { PublicKey as PublicKey17 } from "@dxos/keys";
6428
+ import { log as log22 } from "@dxos/log";
6159
6429
  import { WebsocketSignalManager } from "@dxos/messaging";
6160
6430
  import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
6161
6431
  import { trace as trace10 } from "@dxos/protocols";
@@ -6166,9 +6436,9 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
6166
6436
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
6167
6437
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
6168
6438
  import { Stream as Stream11 } from "@dxos/codec-protobuf";
6169
- import { invariant as invariant17 } from "@dxos/invariant";
6439
+ import { invariant as invariant18 } from "@dxos/invariant";
6170
6440
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
6171
- var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
6441
+ var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
6172
6442
  var DevicesServiceImpl = class {
6173
6443
  constructor(_identityManager) {
6174
6444
  this._identityManager = _identityManager;
@@ -6185,8 +6455,8 @@ var DevicesServiceImpl = class {
6185
6455
  devices: []
6186
6456
  });
6187
6457
  } else {
6188
- invariant17(this._identityManager.identity?.presence, "presence not present", {
6189
- F: __dxlog_file22,
6458
+ invariant18(this._identityManager.identity?.presence, "presence not present", {
6459
+ F: __dxlog_file24,
6190
6460
  L: 32,
6191
6461
  S: this,
6192
6462
  A: [
@@ -6292,28 +6562,111 @@ var findConfigs = () => {
6292
6562
  return configs.map((r) => r.instance.deref()).filter(nonNullable);
6293
6563
  };
6294
6564
 
6295
- // packages/sdk/client-services/src/packlets/logging/logging-service.ts
6296
- import { Event as Event8 } from "@dxos/async";
6565
+ // packages/sdk/client-services/src/packlets/identity/contacts-service.ts
6566
+ import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask7, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
6297
6567
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
6298
6568
  import { PublicKey as PublicKey15 } from "@dxos/keys";
6299
- import { getContextFromEntry, log as log20 } from "@dxos/log";
6569
+ import { ComplexMap as ComplexMap4, ComplexSet as ComplexSet6 } from "@dxos/util";
6570
+ var ContactsServiceImpl = class {
6571
+ constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
6572
+ this._identityManager = _identityManager;
6573
+ this._spaceManager = _spaceManager;
6574
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
6575
+ }
6576
+ async getContacts() {
6577
+ const identity = this._identityManager.identity;
6578
+ if (identity == null) {
6579
+ return {
6580
+ contacts: []
6581
+ };
6582
+ }
6583
+ const contacts = [
6584
+ ...this._spaceManager.spaces.values()
6585
+ ].flatMap((s) => [
6586
+ ...s.spaceState.members.values()
6587
+ ].map((m) => [
6588
+ s.key,
6589
+ m
6590
+ ])).reduce((acc, v) => {
6591
+ const [spaceKey, memberInfo] = v;
6592
+ if (memberInfo.key.equals(identity.identityKey)) {
6593
+ return acc;
6594
+ }
6595
+ const existing = acc.get(memberInfo.key);
6596
+ if (existing != null) {
6597
+ existing.profile ??= memberInfo.profile;
6598
+ existing.commonSpaces?.push(spaceKey);
6599
+ } else {
6600
+ acc.set(memberInfo.key, {
6601
+ identityKey: memberInfo.key,
6602
+ profile: memberInfo.profile,
6603
+ commonSpaces: [
6604
+ spaceKey
6605
+ ]
6606
+ });
6607
+ }
6608
+ return acc;
6609
+ }, new ComplexMap4(PublicKey15.hash));
6610
+ return {
6611
+ contacts: [
6612
+ ...contacts.values()
6613
+ ]
6614
+ };
6615
+ }
6616
+ queryContacts() {
6617
+ const subscribedSpaceKeySet = new ComplexSet6(PublicKey15.hash);
6618
+ return new Stream12(({ next, ctx }) => {
6619
+ const pushUpdateTask = new UpdateScheduler2(ctx, async () => {
6620
+ const contacts = await this.getContacts();
6621
+ next(contacts);
6622
+ }, {
6623
+ maxFrequency: 2
6624
+ });
6625
+ scheduleTask7(ctx, async () => {
6626
+ const subscriptions = new EventSubscriptions4();
6627
+ ctx.onDispose(() => subscriptions.clear());
6628
+ const subscribeToSpaceAndUpdate = () => {
6629
+ const oldSetSize = subscribedSpaceKeySet.size;
6630
+ for (const space of this._spaceManager.spaces.values()) {
6631
+ if (!subscribedSpaceKeySet.has(space.key)) {
6632
+ subscriptions.add(space.stateUpdate.on(ctx, () => pushUpdateTask.trigger()));
6633
+ subscribedSpaceKeySet.add(space.key);
6634
+ }
6635
+ }
6636
+ if (oldSetSize !== subscribedSpaceKeySet.size) {
6637
+ pushUpdateTask.trigger();
6638
+ }
6639
+ };
6640
+ const unsubscribe = (await this._dataSpaceManagerProvider()).updated.on(ctx, subscribeToSpaceAndUpdate);
6641
+ ctx.onDispose(unsubscribe);
6642
+ subscribeToSpaceAndUpdate();
6643
+ });
6644
+ });
6645
+ }
6646
+ };
6647
+
6648
+ // packages/sdk/client-services/src/packlets/logging/logging-service.ts
6649
+ import { Event as Event8 } from "@dxos/async";
6650
+ import { Stream as Stream13 } from "@dxos/codec-protobuf";
6651
+ import { PublicKey as PublicKey16 } from "@dxos/keys";
6652
+ import { getContextFromEntry, log as log21 } from "@dxos/log";
6300
6653
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
6301
6654
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
6302
6655
  var LoggingServiceImpl = class {
6303
6656
  constructor() {
6304
6657
  this._logs = new Event8();
6305
6658
  this._started = Date.now();
6306
- this._sessionId = PublicKey15.random().toHex();
6659
+ this._sessionId = PublicKey16.random().toHex();
6307
6660
  this._logProcessor = (_config, entry2) => {
6308
6661
  this._logs.emit(entry2);
6309
6662
  };
6310
6663
  }
6311
6664
  async open() {
6312
- log20.runtimeConfig.processors.push(this._logProcessor);
6665
+ log21.runtimeConfig.processors.push(this._logProcessor);
6313
6666
  }
6314
6667
  async close() {
6315
- const index = log20.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6316
- log20.runtimeConfig.processors.splice(index, 1);
6668
+ const index = log21.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6669
+ log21.runtimeConfig.processors.splice(index, 1);
6317
6670
  }
6318
6671
  async controlMetrics({ reset, record }) {
6319
6672
  if (reset) {
@@ -6339,7 +6692,7 @@ var LoggingServiceImpl = class {
6339
6692
  stats: numericalValues(events, "duration")
6340
6693
  };
6341
6694
  };
6342
- return new Stream12(({ next }) => {
6695
+ return new Stream13(({ next }) => {
6343
6696
  const update = () => {
6344
6697
  const metrics = {
6345
6698
  timestamp: /* @__PURE__ */ new Date(),
@@ -6361,7 +6714,7 @@ var LoggingServiceImpl = class {
6361
6714
  });
6362
6715
  }
6363
6716
  queryLogs(request) {
6364
- return new Stream12(({ ctx, next }) => {
6717
+ return new Stream13(({ ctx, next }) => {
6365
6718
  const handler = (entry2) => {
6366
6719
  if (LOG_PROCESSING > 0) {
6367
6720
  return;
@@ -6417,14 +6770,14 @@ var shouldLog = (entry2, request) => {
6417
6770
  var LOG_PROCESSING = 0;
6418
6771
 
6419
6772
  // packages/sdk/client-services/src/packlets/network/network-service.ts
6420
- import { Stream as Stream13 } from "@dxos/codec-protobuf";
6773
+ import { Stream as Stream14 } from "@dxos/codec-protobuf";
6421
6774
  var NetworkServiceImpl = class {
6422
6775
  constructor(networkManager, signalManager) {
6423
6776
  this.networkManager = networkManager;
6424
6777
  this.signalManager = signalManager;
6425
6778
  }
6426
6779
  queryStatus() {
6427
- return new Stream13(({ next }) => {
6780
+ return new Stream14(({ next }) => {
6428
6781
  const update = () => {
6429
6782
  next({
6430
6783
  swarm: this.networkManager.connectionState,
@@ -6450,7 +6803,7 @@ var NetworkServiceImpl = class {
6450
6803
  };
6451
6804
 
6452
6805
  // packages/sdk/client-services/src/packlets/system/system-service.ts
6453
- import { Stream as Stream14 } from "@dxos/codec-protobuf";
6806
+ import { Stream as Stream15 } from "@dxos/codec-protobuf";
6454
6807
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
6455
6808
  import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
6456
6809
  var SystemServiceImpl = class {
@@ -6486,7 +6839,7 @@ var SystemServiceImpl = class {
6486
6839
  }
6487
6840
  // TODO(burdon): Standardize interval option in stream request?
6488
6841
  queryStatus({ interval = 3e3 } = {}) {
6489
- return new Stream14(({ next }) => {
6842
+ return new Stream15(({ next }) => {
6490
6843
  const update = () => {
6491
6844
  next({
6492
6845
  status: this._getCurrentStatus()
@@ -6517,7 +6870,7 @@ function _ts_decorate8(decorators, target, key, desc) {
6517
6870
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6518
6871
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6519
6872
  }
6520
- var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6873
+ var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6521
6874
  var ClientServicesHost = class {
6522
6875
  constructor({
6523
6876
  config,
@@ -6550,7 +6903,10 @@ var ClientServicesHost = class {
6550
6903
  lockKey,
6551
6904
  onAcquire: () => {
6552
6905
  if (!this._opening) {
6553
- void this.open(new Context11());
6906
+ void this.open(new Context11(void 0, {
6907
+ F: __dxlog_file25,
6908
+ L: 121
6909
+ }));
6554
6910
  }
6555
6911
  },
6556
6912
  onRelease: () => this.close()
@@ -6605,25 +6961,25 @@ var ClientServicesHost = class {
6605
6961
  * Can only be called once.
6606
6962
  */
6607
6963
  initialize({ config, ...options }) {
6608
- invariant18(!this._open, "service host is open", {
6609
- F: __dxlog_file23,
6610
- L: 186,
6964
+ invariant19(!this._open, "service host is open", {
6965
+ F: __dxlog_file25,
6966
+ L: 187,
6611
6967
  S: this,
6612
6968
  A: [
6613
6969
  "!this._open",
6614
6970
  "'service host is open'"
6615
6971
  ]
6616
6972
  });
6617
- log21("initializing...", void 0, {
6618
- F: __dxlog_file23,
6619
- L: 187,
6973
+ log22("initializing...", void 0, {
6974
+ F: __dxlog_file25,
6975
+ L: 188,
6620
6976
  S: this,
6621
6977
  C: (f, a) => f(...a)
6622
6978
  });
6623
6979
  if (config) {
6624
- invariant18(!this._config, "config already set", {
6625
- F: __dxlog_file23,
6626
- L: 190,
6980
+ invariant19(!this._config, "config already set", {
6981
+ F: __dxlog_file25,
6982
+ L: 191,
6627
6983
  S: this,
6628
6984
  A: [
6629
6985
  "!this._config",
@@ -6636,9 +6992,9 @@ var ClientServicesHost = class {
6636
6992
  }
6637
6993
  }
6638
6994
  if (!options.signalManager) {
6639
- log21.warn("running signaling without telemetry metadata.", void 0, {
6640
- F: __dxlog_file23,
6641
- L: 198,
6995
+ log22.warn("running signaling without telemetry metadata.", void 0, {
6996
+ F: __dxlog_file25,
6997
+ L: 199,
6642
6998
  S: this,
6643
6999
  C: (f, a) => f(...a)
6644
7000
  });
@@ -6647,9 +7003,9 @@ var ClientServicesHost = class {
6647
7003
  iceServers: this._config?.get("runtime.services.ice")
6648
7004
  }), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
6649
7005
  this._signalManager = signalManager;
6650
- invariant18(!this._networkManager, "network manager already set", {
6651
- F: __dxlog_file23,
6652
- L: 209,
7006
+ invariant19(!this._networkManager, "network manager already set", {
7007
+ F: __dxlog_file25,
7008
+ L: 210,
6653
7009
  S: this,
6654
7010
  A: [
6655
7011
  "!this._networkManager",
@@ -6661,9 +7017,9 @@ var ClientServicesHost = class {
6661
7017
  transportFactory,
6662
7018
  signalManager
6663
7019
  });
6664
- log21("initialized", void 0, {
6665
- F: __dxlog_file23,
6666
- L: 216,
7020
+ log22("initialized", void 0, {
7021
+ F: __dxlog_file25,
7022
+ L: 217,
6667
7023
  S: this,
6668
7024
  C: (f, a) => f(...a)
6669
7025
  });
@@ -6672,45 +7028,45 @@ var ClientServicesHost = class {
6672
7028
  if (this._open) {
6673
7029
  return;
6674
7030
  }
6675
- const traceId = PublicKey16.random().toHex();
6676
- log21.trace("dxos.client-services.host.open", trace10.begin({
7031
+ const traceId = PublicKey17.random().toHex();
7032
+ log22.trace("dxos.client-services.host.open", trace10.begin({
6677
7033
  id: traceId
6678
7034
  }), {
6679
- F: __dxlog_file23,
6680
- L: 227,
7035
+ F: __dxlog_file25,
7036
+ L: 228,
6681
7037
  S: this,
6682
7038
  C: (f, a) => f(...a)
6683
7039
  });
6684
- invariant18(this._config, "config not set", {
6685
- F: __dxlog_file23,
6686
- L: 229,
7040
+ invariant19(this._config, "config not set", {
7041
+ F: __dxlog_file25,
7042
+ L: 230,
6687
7043
  S: this,
6688
7044
  A: [
6689
7045
  "this._config",
6690
7046
  "'config not set'"
6691
7047
  ]
6692
7048
  });
6693
- invariant18(this._storage, "storage not set", {
6694
- F: __dxlog_file23,
6695
- L: 230,
7049
+ invariant19(this._storage, "storage not set", {
7050
+ F: __dxlog_file25,
7051
+ L: 231,
6696
7052
  S: this,
6697
7053
  A: [
6698
7054
  "this._storage",
6699
7055
  "'storage not set'"
6700
7056
  ]
6701
7057
  });
6702
- invariant18(this._signalManager, "signal manager not set", {
6703
- F: __dxlog_file23,
6704
- L: 231,
7058
+ invariant19(this._signalManager, "signal manager not set", {
7059
+ F: __dxlog_file25,
7060
+ L: 232,
6705
7061
  S: this,
6706
7062
  A: [
6707
7063
  "this._signalManager",
6708
7064
  "'signal manager not set'"
6709
7065
  ]
6710
7066
  });
6711
- invariant18(this._networkManager, "network manager not set", {
6712
- F: __dxlog_file23,
6713
- L: 232,
7067
+ invariant19(this._networkManager, "network manager not set", {
7068
+ F: __dxlog_file25,
7069
+ L: 233,
6714
7070
  S: this,
6715
7071
  A: [
6716
7072
  "this._networkManager",
@@ -6718,11 +7074,11 @@ var ClientServicesHost = class {
6718
7074
  ]
6719
7075
  });
6720
7076
  this._opening = true;
6721
- log21("opening...", {
7077
+ log22("opening...", {
6722
7078
  lockKey: this._resourceLock?.lockKey
6723
7079
  }, {
6724
- F: __dxlog_file23,
6725
- L: 235,
7080
+ F: __dxlog_file25,
7081
+ L: 236,
6726
7082
  S: this,
6727
7083
  C: (f, a) => f(...a)
6728
7084
  });
@@ -6733,16 +7089,18 @@ var ClientServicesHost = class {
6733
7089
  await this._level.open();
6734
7090
  await this._loggingService.open();
6735
7091
  this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
7092
+ const dataSpaceManagerProvider = async () => {
7093
+ await this._serviceContext.initialized.wait();
7094
+ return this._serviceContext.dataSpaceManager;
7095
+ };
6736
7096
  const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
6737
7097
  this._serviceRegistry.setServices({
6738
7098
  SystemService: this._systemService,
6739
7099
  IdentityService: identityService,
7100
+ ContactsService: new ContactsServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6740
7101
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
6741
7102
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
6742
- SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
6743
- await this._serviceContext.initialized.wait();
6744
- return this._serviceContext.dataSpaceManager;
6745
- }),
7103
+ SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6746
7104
  DataService: this._serviceContext.echoHost.dataService,
6747
7105
  QueryService: this._serviceContext.echoHost.queryService,
6748
7106
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
@@ -6772,19 +7130,19 @@ var ClientServicesHost = class {
6772
7130
  this._open = true;
6773
7131
  this._statusUpdate.emit();
6774
7132
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6775
- log21("opened", {
7133
+ log22("opened", {
6776
7134
  deviceKey
6777
7135
  }, {
6778
- F: __dxlog_file23,
6779
- L: 314,
7136
+ F: __dxlog_file25,
7137
+ L: 322,
6780
7138
  S: this,
6781
7139
  C: (f, a) => f(...a)
6782
7140
  });
6783
- log21.trace("dxos.client-services.host.open", trace10.end({
7141
+ log22.trace("dxos.client-services.host.open", trace10.end({
6784
7142
  id: traceId
6785
7143
  }), {
6786
- F: __dxlog_file23,
6787
- L: 315,
7144
+ F: __dxlog_file25,
7145
+ L: 323,
6788
7146
  S: this,
6789
7147
  C: (f, a) => f(...a)
6790
7148
  });
@@ -6794,11 +7152,11 @@ var ClientServicesHost = class {
6794
7152
  return;
6795
7153
  }
6796
7154
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6797
- log21("closing...", {
7155
+ log22("closing...", {
6798
7156
  deviceKey
6799
7157
  }, {
6800
- F: __dxlog_file23,
6801
- L: 326,
7158
+ F: __dxlog_file25,
7159
+ L: 334,
6802
7160
  S: this,
6803
7161
  C: (f, a) => f(...a)
6804
7162
  });
@@ -6812,44 +7170,44 @@ var ClientServicesHost = class {
6812
7170
  await this._level?.close();
6813
7171
  this._open = false;
6814
7172
  this._statusUpdate.emit();
6815
- log21("closed", {
7173
+ log22("closed", {
6816
7174
  deviceKey
6817
7175
  }, {
6818
- F: __dxlog_file23,
6819
- L: 335,
7176
+ F: __dxlog_file25,
7177
+ L: 343,
6820
7178
  S: this,
6821
7179
  C: (f, a) => f(...a)
6822
7180
  });
6823
7181
  }
6824
7182
  async reset() {
6825
- const traceId = PublicKey16.random().toHex();
6826
- log21.trace("dxos.sdk.client-services-host.reset", trace10.begin({
7183
+ const traceId = PublicKey17.random().toHex();
7184
+ log22.trace("dxos.sdk.client-services-host.reset", trace10.begin({
6827
7185
  id: traceId
6828
7186
  }), {
6829
- F: __dxlog_file23,
6830
- L: 340,
7187
+ F: __dxlog_file25,
7188
+ L: 348,
6831
7189
  S: this,
6832
7190
  C: (f, a) => f(...a)
6833
7191
  });
6834
- log21.info("resetting...", void 0, {
6835
- F: __dxlog_file23,
6836
- L: 342,
7192
+ log22.info("resetting...", void 0, {
7193
+ F: __dxlog_file25,
7194
+ L: 350,
6837
7195
  S: this,
6838
7196
  C: (f, a) => f(...a)
6839
7197
  });
6840
7198
  await this._serviceContext?.close();
6841
7199
  await this._storage.reset();
6842
- log21.info("reset", void 0, {
6843
- F: __dxlog_file23,
6844
- L: 345,
7200
+ log22.info("reset", void 0, {
7201
+ F: __dxlog_file25,
7202
+ L: 353,
6845
7203
  S: this,
6846
7204
  C: (f, a) => f(...a)
6847
7205
  });
6848
- log21.trace("dxos.sdk.client-services-host.reset", trace10.end({
7206
+ log22.trace("dxos.sdk.client-services-host.reset", trace10.end({
6849
7207
  id: traceId
6850
7208
  }), {
6851
- F: __dxlog_file23,
6852
- L: 346,
7209
+ F: __dxlog_file25,
7210
+ L: 354,
6853
7211
  S: this,
6854
7212
  C: (f, a) => f(...a)
6855
7213
  });
@@ -6915,8 +7273,12 @@ export {
6915
7273
  isLocked,
6916
7274
  createStorageObjects,
6917
7275
  createLevel,
7276
+ encodeProfileArchive,
7277
+ decodeProfileArchive,
7278
+ exportProfileData,
7279
+ importProfileData,
6918
7280
  ClientServicesHost,
6919
7281
  ClientServicesProviderResource,
6920
7282
  DiagnosticsCollector
6921
7283
  };
6922
- //# sourceMappingURL=chunk-24JXJ6S3.mjs.map
7284
+ //# sourceMappingURL=chunk-CXKIPEH7.mjs.map