@dxos/client-services 0.5.9-main.b89a78b → 0.5.9-main.b8d8fee

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 (39) hide show
  1. package/dist/lib/browser/{chunk-SMW6LWWU.mjs → chunk-2EFXBSRZ.mjs} +731 -589
  2. package/dist/lib/browser/chunk-2EFXBSRZ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +10 -9
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-D6I2MQJI.cjs → chunk-2SS7JAIR.cjs} +947 -809
  8. package/dist/lib/node/chunk-2SS7JAIR.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +42 -42
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +16 -15
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +19 -0
  14. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -0
  15. package/dist/types/src/packlets/identity/identity-service.d.ts +14 -7
  16. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  17. package/dist/types/src/packlets/identity/identity.d.ts +4 -1
  18. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/service-host.d.ts +1 -1
  20. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  21. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +5 -3
  22. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  23. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  24. package/dist/types/src/packlets/testing/test-builder.d.ts +8 -6
  25. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  26. package/dist/types/src/version.d.ts +1 -1
  27. package/package.json +36 -36
  28. package/src/packlets/identity/default-space-state-machine.ts +44 -0
  29. package/src/packlets/identity/identity-service.test.ts +35 -5
  30. package/src/packlets/identity/identity-service.ts +50 -8
  31. package/src/packlets/identity/identity.ts +25 -2
  32. package/src/packlets/services/service-host.ts +13 -40
  33. package/src/packlets/spaces/data-space-manager.test.ts +46 -1
  34. package/src/packlets/spaces/data-space-manager.ts +54 -25
  35. package/src/packlets/spaces/data-space.ts +10 -5
  36. package/src/packlets/testing/test-builder.ts +11 -6
  37. package/src/version.ts +1 -1
  38. package/dist/lib/browser/chunk-SMW6LWWU.mjs.map +0 -7
  39. package/dist/lib/node/chunk-D6I2MQJI.cjs.map +0 -7
@@ -355,7 +355,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
355
355
  import { TRACE_PROCESSOR } from "@dxos/tracing";
356
356
 
357
357
  // packages/sdk/client-services/src/version.ts
358
- var DXOS_VERSION = "0.5.9-main.b89a78b";
358
+ var DXOS_VERSION = "0.5.9-main.b8d8fee";
359
359
 
360
360
  // packages/sdk/client-services/src/packlets/services/platform.ts
361
361
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -803,10 +803,59 @@ import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSign
803
803
  import { writeMessages } from "@dxos/feed-store";
804
804
  import { invariant as invariant2 } from "@dxos/invariant";
805
805
  import { PublicKey as PublicKey3 } from "@dxos/keys";
806
- import { log as log3 } from "@dxos/log";
806
+ import { log as log4 } from "@dxos/log";
807
807
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
808
+ import { Timeframe } from "@dxos/timeframe";
808
809
  import { trace as trace2 } from "@dxos/tracing";
809
810
  import { ComplexSet } from "@dxos/util";
811
+
812
+ // packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts
813
+ import { getCredentialAssertion } from "@dxos/credentials";
814
+ import { SpaceId } from "@dxos/keys";
815
+ 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";
817
+ var DefaultSpaceStateMachine = class {
818
+ constructor(_params) {
819
+ this._params = _params;
820
+ }
821
+ get spaceId() {
822
+ return this._spaceId;
823
+ }
824
+ async processCredential(credential) {
825
+ const assertion = getCredentialAssertion(credential);
826
+ switch (assertion["@type"]) {
827
+ case "dxos.halo.credentials.DefaultSpace": {
828
+ if (!credential.subject.id.equals(this._params.identityKey)) {
829
+ log3.warn("Invalid default space credential", {
830
+ expectedIdentity: this._params.identityKey,
831
+ credential
832
+ }, {
833
+ F: __dxlog_file4,
834
+ L: 32,
835
+ S: this,
836
+ C: (f, a) => f(...a)
837
+ });
838
+ return;
839
+ }
840
+ if (!SpaceId.isValid(assertion.spaceId)) {
841
+ log3.warn("Invalid default space id", {
842
+ id: assertion.spaceId
843
+ }, {
844
+ F: __dxlog_file4,
845
+ L: 36,
846
+ S: this,
847
+ C: (f, a) => f(...a)
848
+ });
849
+ return;
850
+ }
851
+ this._spaceId = assertion.spaceId;
852
+ break;
853
+ }
854
+ }
855
+ }
856
+ };
857
+
858
+ // packages/sdk/client-services/src/packlets/identity/identity.ts
810
859
  function _ts_decorate2(decorators, target, key, desc) {
811
860
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
812
861
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -817,7 +866,7 @@ function _ts_decorate2(decorators, target, key, desc) {
817
866
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
818
867
  return c > 3 && r && Object.defineProperty(target, key, r), r;
819
868
  }
820
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
869
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
821
870
  var Identity = class {
822
871
  constructor({ space, signer, identityKey, deviceKey, presence }) {
823
872
  this.stateUpdate = new Event();
@@ -826,11 +875,11 @@ var Identity = class {
826
875
  this._presence = presence;
827
876
  this.identityKey = identityKey;
828
877
  this.deviceKey = deviceKey;
829
- log3.trace("dxos.halo.device", {
878
+ log4.trace("dxos.halo.device", {
830
879
  deviceKey
831
880
  }, {
832
- F: __dxlog_file4,
833
- L: 67,
881
+ F: __dxlog_file5,
882
+ L: 70,
834
883
  S: this,
835
884
  C: (f, a) => f(...a)
836
885
  });
@@ -843,6 +892,10 @@ var Identity = class {
843
892
  identityKey: this.identityKey,
844
893
  onUpdate: () => this.stateUpdate.emit()
845
894
  });
895
+ this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
896
+ identityKey: this.identityKey,
897
+ onUpdate: () => this.stateUpdate.emit()
898
+ });
846
899
  this.authVerifier = new TrustedKeySetAuthVerifier({
847
900
  trustedKeysProvider: () => new ComplexSet(PublicKey3.hash, this.authorizedDeviceKeys.keys()),
848
901
  update: this.stateUpdate,
@@ -853,14 +906,20 @@ var Identity = class {
853
906
  get authorizedDeviceKeys() {
854
907
  return this._deviceStateMachine.authorizedDeviceKeys;
855
908
  }
909
+ get defaultSpaceId() {
910
+ return this._defaultSpaceStateMachine.spaceId;
911
+ }
856
912
  async open(ctx) {
913
+ await this._presence?.open();
857
914
  await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
858
915
  await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
916
+ await this.space.spaceState.addCredentialProcessor(this._defaultSpaceStateMachine);
859
917
  await this.space.open(ctx);
860
918
  }
861
919
  async close(ctx) {
862
- await this._presence?.destroy();
920
+ await this._presence?.close();
863
921
  await this.authVerifier.close();
922
+ await this.space.spaceState.removeCredentialProcessor(this._defaultSpaceStateMachine);
864
923
  await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
865
924
  await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
866
925
  await this.space.close();
@@ -898,8 +957,8 @@ var Identity = class {
898
957
  */
899
958
  getIdentityCredentialSigner() {
900
959
  invariant2(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
901
- F: __dxlog_file4,
902
- L: 145,
960
+ F: __dxlog_file5,
961
+ L: 159,
903
962
  S: this,
904
963
  A: [
905
964
  "this._deviceStateMachine.deviceCredentialChain",
@@ -914,16 +973,36 @@ var Identity = class {
914
973
  getDeviceCredentialSigner() {
915
974
  return createCredentialSignerWithKey(this._signer, this.deviceKey);
916
975
  }
976
+ async updateDefaultSpace(spaceId) {
977
+ const credential = await this.getDeviceCredentialSigner().createCredential({
978
+ subject: this.identityKey,
979
+ assertion: {
980
+ "@type": "dxos.halo.credentials.DefaultSpace",
981
+ spaceId
982
+ }
983
+ });
984
+ const receipt = await this.controlPipeline.writer.write({
985
+ credential: {
986
+ credential
987
+ }
988
+ });
989
+ await this.controlPipeline.state.waitUntilTimeframe(new Timeframe([
990
+ [
991
+ receipt.feedKey,
992
+ receipt.seq
993
+ ]
994
+ ]));
995
+ }
917
996
  async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
918
- log3("Admitting device:", {
997
+ log4("Admitting device:", {
919
998
  identityKey: this.identityKey,
920
999
  hostDevice: this.deviceKey,
921
1000
  deviceKey,
922
1001
  controlFeedKey,
923
1002
  dataFeedKey
924
1003
  }, {
925
- F: __dxlog_file4,
926
- L: 161,
1004
+ F: __dxlog_file5,
1005
+ L: 184,
927
1006
  S: this,
928
1007
  C: (f, a) => f(...a)
929
1008
  });
@@ -981,12 +1060,12 @@ import { Context as Context3 } from "@dxos/context";
981
1060
  import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
982
1061
  import { invariant as invariant3 } from "@dxos/invariant";
983
1062
  import { PublicKey as PublicKey4 } from "@dxos/keys";
984
- import { log as log4 } from "@dxos/log";
1063
+ import { log as log5 } from "@dxos/log";
985
1064
  import { trace as trace3 } from "@dxos/protocols";
986
1065
  import { Device, DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
987
1066
  import { AdmittedFeed as AdmittedFeed2, DeviceType } from "@dxos/protocols/proto/dxos/halo/credentials";
988
1067
  import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
989
- import { Timeframe } from "@dxos/timeframe";
1068
+ import { Timeframe as Timeframe2 } from "@dxos/timeframe";
990
1069
  import { trace as Trace } from "@dxos/tracing";
991
1070
  import { isNode, deferFunction } from "@dxos/util";
992
1071
  function _ts_decorate3(decorators, target, key, desc) {
@@ -999,7 +1078,7 @@ function _ts_decorate3(decorators, target, key, desc) {
999
1078
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1000
1079
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1001
1080
  }
1002
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1081
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1003
1082
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
1004
1083
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
1005
1084
  var IdentityManager = class {
@@ -1020,19 +1099,19 @@ var IdentityManager = class {
1020
1099
  }
1021
1100
  async open(ctx) {
1022
1101
  const traceId = PublicKey4.random().toHex();
1023
- log4.trace("dxos.halo.identity-manager.open", trace3.begin({
1102
+ log5.trace("dxos.halo.identity-manager.open", trace3.begin({
1024
1103
  id: traceId
1025
1104
  }), {
1026
- F: __dxlog_file5,
1105
+ F: __dxlog_file6,
1027
1106
  L: 104,
1028
1107
  S: this,
1029
1108
  C: (f, a) => f(...a)
1030
1109
  });
1031
1110
  const identityRecord = this._metadataStore.getIdentityRecord();
1032
- log4("identity record", {
1111
+ log5("identity record", {
1033
1112
  identityRecord
1034
1113
  }, {
1035
- F: __dxlog_file5,
1114
+ F: __dxlog_file6,
1036
1115
  L: 107,
1037
1116
  S: this,
1038
1117
  C: (f, a) => f(...a)
@@ -1041,21 +1120,21 @@ var IdentityManager = class {
1041
1120
  this._identity = await this._constructIdentity(identityRecord);
1042
1121
  await this._identity.open(ctx);
1043
1122
  await this._identity.ready();
1044
- log4.trace("dxos.halo.identity", {
1123
+ log5.trace("dxos.halo.identity", {
1045
1124
  identityKey: identityRecord.identityKey,
1046
1125
  displayName: this._identity.profileDocument?.displayName
1047
1126
  }, {
1048
- F: __dxlog_file5,
1127
+ F: __dxlog_file6,
1049
1128
  L: 112,
1050
1129
  S: this,
1051
1130
  C: (f, a) => f(...a)
1052
1131
  });
1053
1132
  this.stateUpdate.emit();
1054
1133
  }
1055
- log4.trace("dxos.halo.identity-manager.open", trace3.end({
1134
+ log5.trace("dxos.halo.identity-manager.open", trace3.end({
1056
1135
  id: traceId
1057
1136
  }), {
1058
- F: __dxlog_file5,
1137
+ F: __dxlog_file6,
1059
1138
  L: 119,
1060
1139
  S: this,
1061
1140
  C: (f, a) => f(...a)
@@ -1066,7 +1145,7 @@ var IdentityManager = class {
1066
1145
  }
1067
1146
  async createIdentity({ displayName, deviceProfile } = {}) {
1068
1147
  invariant3(!this._identity, "Identity already exists.", {
1069
- F: __dxlog_file5,
1148
+ F: __dxlog_file6,
1070
1149
  L: 128,
1071
1150
  S: this,
1072
1151
  A: [
@@ -1074,8 +1153,8 @@ var IdentityManager = class {
1074
1153
  "'Identity already exists.'"
1075
1154
  ]
1076
1155
  });
1077
- log4("creating identity...", void 0, {
1078
- F: __dxlog_file5,
1156
+ log5("creating identity...", void 0, {
1157
+ F: __dxlog_file6,
1079
1158
  L: 129,
1080
1159
  S: this,
1081
1160
  C: (f, a) => f(...a)
@@ -1096,7 +1175,7 @@ var IdentityManager = class {
1096
1175
  {
1097
1176
  const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
1098
1177
  invariant3(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
1099
- F: __dxlog_file5,
1178
+ F: __dxlog_file6,
1100
1179
  L: 148,
1101
1180
  S: this,
1102
1181
  A: [
@@ -1105,7 +1184,7 @@ var IdentityManager = class {
1105
1184
  ]
1106
1185
  });
1107
1186
  invariant3(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
1108
- F: __dxlog_file5,
1187
+ F: __dxlog_file6,
1109
1188
  L: 149,
1110
1189
  S: this,
1111
1190
  A: [
@@ -1140,22 +1219,22 @@ var IdentityManager = class {
1140
1219
  await this._metadataStore.setIdentityRecord(identityRecord);
1141
1220
  this._identity = identity;
1142
1221
  await this._identity.ready();
1143
- log4.trace("dxos.halo.identity", {
1222
+ log5.trace("dxos.halo.identity", {
1144
1223
  identityKey: identityRecord.identityKey,
1145
1224
  displayName: this._identity.profileDocument?.displayName
1146
1225
  }, {
1147
- F: __dxlog_file5,
1226
+ F: __dxlog_file6,
1148
1227
  L: 191,
1149
1228
  S: this,
1150
1229
  C: (f, a) => f(...a)
1151
1230
  });
1152
1231
  this.stateUpdate.emit();
1153
- log4("created identity", {
1232
+ log5("created identity", {
1154
1233
  identityKey: identity.identityKey,
1155
1234
  deviceKey: identity.deviceKey,
1156
1235
  profile: identity.profileDocument
1157
1236
  }, {
1158
- F: __dxlog_file5,
1237
+ F: __dxlog_file6,
1159
1238
  L: 197,
1160
1239
  S: this,
1161
1240
  C: (f, a) => f(...a)
@@ -1189,16 +1268,16 @@ var IdentityManager = class {
1189
1268
  * Accept an existing identity. Expects its device key to be authorized (now or later).
1190
1269
  */
1191
1270
  async acceptIdentity(params) {
1192
- log4("accepting identity", {
1271
+ log5("accepting identity", {
1193
1272
  params
1194
1273
  }, {
1195
- F: __dxlog_file5,
1274
+ F: __dxlog_file6,
1196
1275
  L: 235,
1197
1276
  S: this,
1198
1277
  C: (f, a) => f(...a)
1199
1278
  });
1200
1279
  invariant3(!this._identity, "Identity already exists.", {
1201
- F: __dxlog_file5,
1280
+ F: __dxlog_file6,
1202
1281
  L: 236,
1203
1282
  S: this,
1204
1283
  A: [
@@ -1222,11 +1301,11 @@ var IdentityManager = class {
1222
1301
  this._identity = identity;
1223
1302
  await this._metadataStore.setIdentityRecord(identityRecord);
1224
1303
  await this._identity.ready();
1225
- log4.trace("dxos.halo.identity", {
1304
+ log5.trace("dxos.halo.identity", {
1226
1305
  identityKey: identityRecord.identityKey,
1227
1306
  displayName: this._identity.profileDocument?.displayName
1228
1307
  }, {
1229
- F: __dxlog_file5,
1308
+ F: __dxlog_file6,
1230
1309
  L: 255,
1231
1310
  S: this,
1232
1311
  C: (f, a) => f(...a)
@@ -1236,11 +1315,11 @@ var IdentityManager = class {
1236
1315
  ...params.deviceProfile
1237
1316
  });
1238
1317
  this.stateUpdate.emit();
1239
- log4("accepted identity", {
1318
+ log5("accepted identity", {
1240
1319
  identityKey: identity.identityKey,
1241
1320
  deviceKey: identity.deviceKey
1242
1321
  }, {
1243
- F: __dxlog_file5,
1322
+ F: __dxlog_file6,
1244
1323
  L: 265,
1245
1324
  S: this,
1246
1325
  C: (f, a) => f(...a)
@@ -1252,7 +1331,7 @@ var IdentityManager = class {
1252
1331
  */
1253
1332
  async updateProfile(profile) {
1254
1333
  invariant3(this._identity, "Identity not initialized.", {
1255
- F: __dxlog_file5,
1334
+ F: __dxlog_file6,
1256
1335
  L: 273,
1257
1336
  S: this,
1258
1337
  A: [
@@ -1272,7 +1351,7 @@ var IdentityManager = class {
1272
1351
  credential
1273
1352
  }
1274
1353
  });
1275
- await this._identity.controlPipeline.state.waitUntilTimeframe(new Timeframe([
1354
+ await this._identity.controlPipeline.state.waitUntilTimeframe(new Timeframe2([
1276
1355
  [
1277
1356
  receipt.feedKey,
1278
1357
  receipt.seq
@@ -1283,7 +1362,7 @@ var IdentityManager = class {
1283
1362
  }
1284
1363
  async updateDeviceProfile(profile) {
1285
1364
  invariant3(this._identity, "Identity not initialized.", {
1286
- F: __dxlog_file5,
1365
+ F: __dxlog_file6,
1287
1366
  L: 290,
1288
1367
  S: this,
1289
1368
  A: [
@@ -1303,7 +1382,7 @@ var IdentityManager = class {
1303
1382
  credential
1304
1383
  }
1305
1384
  });
1306
- await this._identity.controlPipeline.state.waitUntilTimeframe(new Timeframe([
1385
+ await this._identity.controlPipeline.state.waitUntilTimeframe(new Timeframe2([
1307
1386
  [
1308
1387
  receipt.feedKey,
1309
1388
  receipt.seq
@@ -1319,7 +1398,7 @@ var IdentityManager = class {
1319
1398
  }
1320
1399
  async _constructIdentity(identityRecord) {
1321
1400
  invariant3(!this._identity, void 0, {
1322
- F: __dxlog_file5,
1401
+ F: __dxlog_file6,
1323
1402
  L: 316,
1324
1403
  S: this,
1325
1404
  A: [
@@ -1327,10 +1406,10 @@ var IdentityManager = class {
1327
1406
  ""
1328
1407
  ]
1329
1408
  });
1330
- log4("constructing identity", {
1409
+ log5("constructing identity", {
1331
1410
  identityRecord
1332
1411
  }, {
1333
- F: __dxlog_file5,
1412
+ F: __dxlog_file6,
1334
1413
  L: 317,
1335
1414
  S: this,
1336
1415
  C: (f, a) => f(...a)
@@ -1345,7 +1424,7 @@ var IdentityManager = class {
1345
1424
  gossip
1346
1425
  });
1347
1426
  invariant3(identityRecord.haloSpace.controlFeedKey, void 0, {
1348
- F: __dxlog_file5,
1427
+ F: __dxlog_file6,
1349
1428
  L: 330,
1350
1429
  S: this,
1351
1430
  A: [
@@ -1357,7 +1436,7 @@ var IdentityManager = class {
1357
1436
  writable: true
1358
1437
  });
1359
1438
  invariant3(identityRecord.haloSpace.dataFeedKey, void 0, {
1360
- F: __dxlog_file5,
1439
+ F: __dxlog_file6,
1361
1440
  L: 334,
1362
1441
  S: this,
1363
1442
  A: [
@@ -1388,10 +1467,10 @@ var IdentityManager = class {
1388
1467
  identityKey: identityRecord.identityKey,
1389
1468
  deviceKey: identityRecord.deviceKey
1390
1469
  });
1391
- log4("done", {
1470
+ log5("done", {
1392
1471
  identityKey: identityRecord.identityKey
1393
1472
  }, {
1394
- F: __dxlog_file5,
1473
+ F: __dxlog_file6,
1395
1474
  L: 360,
1396
1475
  S: this,
1397
1476
  C: (f, a) => f(...a)
@@ -1415,8 +1494,8 @@ var IdentityManager = class {
1415
1494
  }));
1416
1495
  },
1417
1496
  onAuthFailure: () => {
1418
- log4.warn("auth failure", void 0, {
1419
- F: __dxlog_file5,
1497
+ log5.warn("auth failure", void 0, {
1498
+ F: __dxlog_file6,
1420
1499
  L: 385,
1421
1500
  S: this,
1422
1501
  C: (f, a) => f(...a)
@@ -1441,24 +1520,50 @@ IdentityManager = _ts_decorate3([
1441
1520
 
1442
1521
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
1443
1522
  import { Stream as Stream8 } from "@dxos/codec-protobuf";
1523
+ import { Resource } from "@dxos/context";
1444
1524
  import { signPresentation } from "@dxos/credentials";
1445
1525
  import { todo } from "@dxos/debug";
1446
1526
  import { invariant as invariant4 } from "@dxos/invariant";
1447
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1448
- var IdentityServiceImpl = class {
1449
- constructor(_createIdentity, _identityManager, _keyring, _onProfileUpdate) {
1450
- this._createIdentity = _createIdentity;
1527
+ import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
1528
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1529
+ var IdentityServiceImpl = class extends Resource {
1530
+ constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
1531
+ super();
1451
1532
  this._identityManager = _identityManager;
1452
1533
  this._keyring = _keyring;
1534
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
1535
+ this._createIdentity = _createIdentity;
1453
1536
  this._onProfileUpdate = _onProfileUpdate;
1454
1537
  }
1538
+ async _open() {
1539
+ const identity = this._identityManager.identity;
1540
+ if (identity && !identity.defaultSpaceId) {
1541
+ await this._fixIdentityWithoutDefaultSpace(identity);
1542
+ }
1543
+ }
1455
1544
  async createIdentity(request) {
1456
1545
  await this._createIdentity({
1457
1546
  displayName: request.profile?.displayName,
1458
1547
  deviceProfile: request.deviceProfile
1459
1548
  });
1549
+ const dataSpaceManager = this._dataSpaceManagerProvider();
1550
+ await this._createDefaultSpace(dataSpaceManager);
1460
1551
  return this._getIdentity();
1461
1552
  }
1553
+ async _createDefaultSpace(dataSpaceManager) {
1554
+ const space = await dataSpaceManager.createDefaultSpace();
1555
+ const identity = this._identityManager.identity;
1556
+ invariant4(identity, void 0, {
1557
+ F: __dxlog_file7,
1558
+ L: 54,
1559
+ S: this,
1560
+ A: [
1561
+ "identity",
1562
+ ""
1563
+ ]
1564
+ });
1565
+ await identity.updateDefaultSpace(space.id);
1566
+ }
1462
1567
  async recoverIdentity(request) {
1463
1568
  return todo();
1464
1569
  }
@@ -1483,8 +1588,8 @@ var IdentityServiceImpl = class {
1483
1588
  }
1484
1589
  async updateProfile(profile) {
1485
1590
  invariant4(this._identityManager.identity, "Identity not initialized.", {
1486
- F: __dxlog_file6,
1487
- L: 61,
1591
+ F: __dxlog_file7,
1592
+ L: 84,
1488
1593
  S: this,
1489
1594
  A: [
1490
1595
  "this._identityManager.identity",
@@ -1497,8 +1602,8 @@ var IdentityServiceImpl = class {
1497
1602
  }
1498
1603
  async signPresentation({ presentation, nonce }) {
1499
1604
  invariant4(this._identityManager.identity, "Identity not initialized.", {
1500
- F: __dxlog_file6,
1501
- L: 68,
1605
+ F: __dxlog_file7,
1606
+ L: 91,
1502
1607
  S: this,
1503
1608
  A: [
1504
1609
  "this._identityManager.identity",
@@ -1513,13 +1618,31 @@ var IdentityServiceImpl = class {
1513
1618
  nonce
1514
1619
  });
1515
1620
  }
1621
+ async _fixIdentityWithoutDefaultSpace(identity) {
1622
+ let hasDefaultSpace = false;
1623
+ const dataSpaceManager = this._dataSpaceManagerProvider();
1624
+ for (const space of dataSpaceManager.spaces.values()) {
1625
+ if (space.state === SpaceState.CLOSED) {
1626
+ await space.open();
1627
+ await space.initializeDataPipeline();
1628
+ }
1629
+ if (await dataSpaceManager.isDefaultSpace(space)) {
1630
+ await identity.updateDefaultSpace(space.id);
1631
+ hasDefaultSpace = true;
1632
+ break;
1633
+ }
1634
+ }
1635
+ if (!hasDefaultSpace) {
1636
+ await this._createDefaultSpace(dataSpaceManager);
1637
+ }
1638
+ }
1516
1639
  };
1517
1640
 
1518
1641
  // packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
1519
1642
  import { invariant as invariant5 } from "@dxos/invariant";
1520
1643
  import { AlreadyJoinedError } from "@dxos/protocols";
1521
1644
  import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
1522
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1645
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1523
1646
  var DeviceInvitationProtocol = class {
1524
1647
  constructor(_keyring, _getIdentity, _acceptIdentity) {
1525
1648
  this._keyring = _keyring;
@@ -1545,7 +1668,7 @@ var DeviceInvitationProtocol = class {
1545
1668
  }
1546
1669
  async admit(_, request) {
1547
1670
  invariant5(request.device, void 0, {
1548
- F: __dxlog_file7,
1671
+ F: __dxlog_file8,
1549
1672
  L: 50,
1550
1673
  S: this,
1551
1674
  A: [
@@ -1591,7 +1714,7 @@ var DeviceInvitationProtocol = class {
1591
1714
  }
1592
1715
  async accept(response, request) {
1593
1716
  invariant5(response.device, void 0, {
1594
- F: __dxlog_file7,
1717
+ F: __dxlog_file8,
1595
1718
  L: 95,
1596
1719
  S: this,
1597
1720
  A: [
@@ -1601,7 +1724,7 @@ var DeviceInvitationProtocol = class {
1601
1724
  });
1602
1725
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1603
1726
  invariant5(request.device, void 0, {
1604
- F: __dxlog_file7,
1727
+ F: __dxlog_file8,
1605
1728
  L: 98,
1606
1729
  S: this,
1607
1730
  A: [
@@ -1633,7 +1756,7 @@ import { ContextDisposedError as ContextDisposedError2 } from "@dxos/context";
1633
1756
  import { createKeyPair, sign } from "@dxos/crypto";
1634
1757
  import { invariant as invariant9 } from "@dxos/invariant";
1635
1758
  import { PublicKey as PublicKey7 } from "@dxos/keys";
1636
- import { log as log8 } from "@dxos/log";
1759
+ import { log as log9 } from "@dxos/log";
1637
1760
  import { createTeleportProtocolFactory } from "@dxos/network-manager";
1638
1761
  import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace5 } from "@dxos/protocols";
1639
1762
  import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
@@ -1645,7 +1768,7 @@ import { ComplexSet as ComplexSet3 } from "@dxos/util";
1645
1768
  import { Trigger as Trigger3 } from "@dxos/async";
1646
1769
  import { cancelWithContext as cancelWithContext2, Context as Context4 } from "@dxos/context";
1647
1770
  import { invariant as invariant6 } from "@dxos/invariant";
1648
- import { log as log5 } from "@dxos/log";
1771
+ import { log as log6 } from "@dxos/log";
1649
1772
  import { InvalidInvitationExtensionRoleError, schema as schema2 } from "@dxos/protocols";
1650
1773
  import { Options } from "@dxos/protocols/proto/dxos/halo/invitations";
1651
1774
  import { RpcExtension } from "@dxos/teleport";
@@ -1670,7 +1793,7 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
1670
1793
  };
1671
1794
 
1672
1795
  // packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
1673
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1796
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1674
1797
  var OPTIONS_TIMEOUT = 1e4;
1675
1798
  var InvitationGuestExtension = class extends RpcExtension {
1676
1799
  constructor(_invitationFlowMutex, _callbacks) {
@@ -1696,7 +1819,7 @@ var InvitationGuestExtension = class extends RpcExtension {
1696
1819
  InvitationHostService: {
1697
1820
  options: async (options) => {
1698
1821
  invariant6(!this._remoteOptions, "Remote options already set.", {
1699
- F: __dxlog_file8,
1822
+ F: __dxlog_file9,
1700
1823
  L: 63,
1701
1824
  S: this,
1702
1825
  A: [
@@ -1722,15 +1845,15 @@ var InvitationGuestExtension = class extends RpcExtension {
1722
1845
  async onOpen(context) {
1723
1846
  await super.onOpen(context);
1724
1847
  try {
1725
- log5("guest acquire lock", void 0, {
1726
- F: __dxlog_file8,
1848
+ log6("guest acquire lock", void 0, {
1849
+ F: __dxlog_file9,
1727
1850
  L: 84,
1728
1851
  S: this,
1729
1852
  C: (f, a) => f(...a)
1730
1853
  });
1731
1854
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
1732
- log5("guest lock acquired", void 0, {
1733
- F: __dxlog_file8,
1855
+ log6("guest lock acquired", void 0, {
1856
+ F: __dxlog_file9,
1734
1857
  L: 86,
1735
1858
  S: this,
1736
1859
  C: (f, a) => f(...a)
@@ -1738,8 +1861,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1738
1861
  await cancelWithContext2(this._ctx, this.rpc.InvitationHostService.options({
1739
1862
  role: Options.Role.GUEST
1740
1863
  }));
1741
- log5("options sent", void 0, {
1742
- F: __dxlog_file8,
1864
+ log6("options sent", void 0, {
1865
+ F: __dxlog_file9,
1743
1866
  L: 88,
1744
1867
  S: this,
1745
1868
  C: (f, a) => f(...a)
@@ -1747,8 +1870,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1747
1870
  await cancelWithContext2(this._ctx, this._remoteOptionsTrigger.wait({
1748
1871
  timeout: OPTIONS_TIMEOUT
1749
1872
  }));
1750
- log5("options received", void 0, {
1751
- F: __dxlog_file8,
1873
+ log6("options received", void 0, {
1874
+ F: __dxlog_file9,
1752
1875
  L: 90,
1753
1876
  S: this,
1754
1877
  C: (f, a) => f(...a)
@@ -1781,8 +1904,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1781
1904
  if (this._invitationFlowLock != null) {
1782
1905
  this._invitationFlowLock.release();
1783
1906
  this._invitationFlowLock = null;
1784
- log5("invitation flow lock released", void 0, {
1785
- F: __dxlog_file8,
1907
+ log6("invitation flow lock released", void 0, {
1908
+ F: __dxlog_file9,
1786
1909
  L: 123,
1787
1910
  S: this,
1788
1911
  C: (f, a) => f(...a)
@@ -1797,12 +1920,12 @@ import { cancelWithContext as cancelWithContext3, Context as Context5 } from "@d
1797
1920
  import { randomBytes, verify } from "@dxos/crypto";
1798
1921
  import { invariant as invariant7, InvariantViolation } from "@dxos/invariant";
1799
1922
  import { PublicKey as PublicKey5 } from "@dxos/keys";
1800
- import { log as log6 } from "@dxos/log";
1923
+ import { log as log7 } from "@dxos/log";
1801
1924
  import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, schema as schema3, trace as trace4 } from "@dxos/protocols";
1802
1925
  import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
1803
1926
  import { AuthenticationResponse, Options as Options2 } from "@dxos/protocols/proto/dxos/halo/invitations";
1804
1927
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
1805
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
1928
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
1806
1929
  var OPTIONS_TIMEOUT2 = 1e4;
1807
1930
  var MAX_OTP_ATTEMPTS = 3;
1808
1931
  var InvitationHostExtension = class extends RpcExtension2 {
@@ -1836,7 +1959,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
1836
1959
  InvitationHostService: {
1837
1960
  options: async (options) => {
1838
1961
  invariant7(!this._remoteOptions, "Remote options already set.", {
1839
- F: __dxlog_file9,
1962
+ F: __dxlog_file10,
1840
1963
  L: 101,
1841
1964
  S: this,
1842
1965
  A: [
@@ -1850,10 +1973,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
1850
1973
  introduce: async (request) => {
1851
1974
  const { profile, invitationId } = request;
1852
1975
  const traceId = PublicKey5.random().toHex();
1853
- log6.trace("dxos.sdk.invitation-handler.host.introduce", trace4.begin({
1976
+ log7.trace("dxos.sdk.invitation-handler.host.introduce", trace4.begin({
1854
1977
  id: traceId
1855
1978
  }), {
1856
- F: __dxlog_file9,
1979
+ F: __dxlog_file10,
1857
1980
  L: 110,
1858
1981
  S: this,
1859
1982
  C: (f, a) => f(...a)
@@ -1861,11 +1984,11 @@ var InvitationHostExtension = class extends RpcExtension2 {
1861
1984
  const invitation = this._requireActiveInvitation();
1862
1985
  this._assertInvitationState(Invitation3.State.CONNECTED);
1863
1986
  if (invitationId !== invitation?.invitationId) {
1864
- log6.warn("incorrect invitationId", {
1987
+ log7.warn("incorrect invitationId", {
1865
1988
  expected: invitation.invitationId,
1866
1989
  actual: invitationId
1867
1990
  }, {
1868
- F: __dxlog_file9,
1991
+ F: __dxlog_file10,
1869
1992
  L: 116,
1870
1993
  S: this,
1871
1994
  C: (f, a) => f(...a)
@@ -1876,10 +1999,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
1876
1999
  authMethod: Invitation3.AuthMethod.NONE
1877
2000
  };
1878
2001
  }
1879
- log6("guest introduced themselves", {
2002
+ log7("guest introduced themselves", {
1880
2003
  guestProfile: profile
1881
2004
  }, {
1882
- F: __dxlog_file9,
2005
+ F: __dxlog_file10,
1883
2006
  L: 125,
1884
2007
  S: this,
1885
2008
  C: (f, a) => f(...a)
@@ -1887,10 +2010,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
1887
2010
  this.guestProfile = profile;
1888
2011
  this._callbacks.onStateUpdate(Invitation3.State.READY_FOR_AUTHENTICATION);
1889
2012
  this._challenge = invitation.authMethod === Invitation3.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
1890
- log6.trace("dxos.sdk.invitation-handler.host.introduce", trace4.end({
2013
+ log7.trace("dxos.sdk.invitation-handler.host.introduce", trace4.end({
1891
2014
  id: traceId
1892
2015
  }), {
1893
- F: __dxlog_file9,
2016
+ F: __dxlog_file10,
1894
2017
  L: 132,
1895
2018
  S: this,
1896
2019
  C: (f, a) => f(...a)
@@ -1902,19 +2025,19 @@ var InvitationHostExtension = class extends RpcExtension2 {
1902
2025
  },
1903
2026
  authenticate: async ({ authCode: code, signedChallenge }) => {
1904
2027
  const traceId = PublicKey5.random().toHex();
1905
- log6.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.begin({
2028
+ log7.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.begin({
1906
2029
  id: traceId
1907
2030
  }), {
1908
- F: __dxlog_file9,
2031
+ F: __dxlog_file10,
1909
2032
  L: 141,
1910
2033
  S: this,
1911
2034
  C: (f, a) => f(...a)
1912
2035
  });
1913
2036
  const invitation = this._requireActiveInvitation();
1914
- log6("received authentication request", {
2037
+ log7("received authentication request", {
1915
2038
  authCode: code
1916
2039
  }, {
1917
- F: __dxlog_file9,
2040
+ F: __dxlog_file10,
1918
2041
  L: 144,
1919
2042
  S: this,
1920
2043
  C: (f, a) => f(...a)
@@ -1927,8 +2050,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
1927
2050
  this._callbacks.onStateUpdate(Invitation3.State.AUTHENTICATING);
1928
2051
  switch (invitation.authMethod) {
1929
2052
  case Invitation3.AuthMethod.NONE: {
1930
- log6("authentication not required", void 0, {
1931
- F: __dxlog_file9,
2053
+ log7("authentication not required", void 0, {
2054
+ F: __dxlog_file10,
1932
2055
  L: 152,
1933
2056
  S: this,
1934
2057
  C: (f, a) => f(...a)
@@ -1963,10 +2086,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
1963
2086
  break;
1964
2087
  }
1965
2088
  default: {
1966
- log6.error("invalid authentication method", {
2089
+ log7.error("invalid authentication method", {
1967
2090
  authMethod: invitation.authMethod
1968
2091
  }, {
1969
- F: __dxlog_file9,
2092
+ F: __dxlog_file10,
1970
2093
  L: 190,
1971
2094
  S: this,
1972
2095
  C: (f, a) => f(...a)
@@ -1985,13 +2108,13 @@ var InvitationHostExtension = class extends RpcExtension2 {
1985
2108
  status
1986
2109
  };
1987
2110
  }
1988
- log6.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.end({
2111
+ log7.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.end({
1989
2112
  id: traceId,
1990
2113
  data: {
1991
2114
  status
1992
2115
  }
1993
2116
  }), {
1994
- F: __dxlog_file9,
2117
+ F: __dxlog_file10,
1995
2118
  L: 202,
1996
2119
  S: this,
1997
2120
  C: (f, a) => f(...a)
@@ -2002,10 +2125,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
2002
2125
  },
2003
2126
  admit: async (request) => {
2004
2127
  const traceId = PublicKey5.random().toHex();
2005
- log6.trace("dxos.sdk.invitation-handler.host.admit", trace4.begin({
2128
+ log7.trace("dxos.sdk.invitation-handler.host.admit", trace4.begin({
2006
2129
  id: traceId
2007
2130
  }), {
2008
- F: __dxlog_file9,
2131
+ F: __dxlog_file10,
2009
2132
  L: 208,
2010
2133
  S: this,
2011
2134
  C: (f, a) => f(...a)
@@ -2019,10 +2142,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
2019
2142
  }
2020
2143
  }
2021
2144
  const response = await this._callbacks.admit(request);
2022
- log6.trace("dxos.sdk.invitation-handler.host.admit", trace4.end({
2145
+ log7.trace("dxos.sdk.invitation-handler.host.admit", trace4.end({
2023
2146
  id: traceId
2024
2147
  }), {
2025
- F: __dxlog_file9,
2148
+ F: __dxlog_file10,
2026
2149
  L: 222,
2027
2150
  S: this,
2028
2151
  C: (f, a) => f(...a)
@@ -2039,15 +2162,15 @@ var InvitationHostExtension = class extends RpcExtension2 {
2039
2162
  async onOpen(context) {
2040
2163
  await super.onOpen(context);
2041
2164
  try {
2042
- log6("host acquire lock", void 0, {
2043
- F: __dxlog_file9,
2165
+ log7("host acquire lock", void 0, {
2166
+ F: __dxlog_file10,
2044
2167
  L: 237,
2045
2168
  S: this,
2046
2169
  C: (f, a) => f(...a)
2047
2170
  });
2048
2171
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
2049
- log6("host lock acquired", void 0, {
2050
- F: __dxlog_file9,
2172
+ log7("host lock acquired", void 0, {
2173
+ F: __dxlog_file10,
2051
2174
  L: 239,
2052
2175
  S: this,
2053
2176
  C: (f, a) => f(...a)
@@ -2057,8 +2180,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
2057
2180
  await this.rpc.InvitationHostService.options({
2058
2181
  role: Options2.Role.HOST
2059
2182
  });
2060
- log6("options sent", void 0, {
2061
- F: __dxlog_file9,
2183
+ log7("options sent", void 0, {
2184
+ F: __dxlog_file10,
2062
2185
  L: 243,
2063
2186
  S: this,
2064
2187
  C: (f, a) => f(...a)
@@ -2066,8 +2189,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
2066
2189
  await cancelWithContext3(this._ctx, this._remoteOptionsTrigger.wait({
2067
2190
  timeout: OPTIONS_TIMEOUT2
2068
2191
  }));
2069
- log6("options received", void 0, {
2070
- F: __dxlog_file9,
2192
+ log7("options received", void 0, {
2193
+ F: __dxlog_file10,
2071
2194
  L: 245,
2072
2195
  S: this,
2073
2196
  C: (f, a) => f(...a)
@@ -2120,8 +2243,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
2120
2243
  if (this._invitationFlowLock != null) {
2121
2244
  this._invitationFlowLock?.release();
2122
2245
  this._invitationFlowLock = null;
2123
- log6("invitation flow lock released", void 0, {
2124
- F: __dxlog_file9,
2246
+ log7("invitation flow lock released", void 0, {
2247
+ F: __dxlog_file10,
2125
2248
  L: 300,
2126
2249
  S: this,
2127
2250
  C: (f, a) => f(...a)
@@ -2134,10 +2257,10 @@ var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitat
2134
2257
  // packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts
2135
2258
  import { invariant as invariant8 } from "@dxos/invariant";
2136
2259
  import { PublicKey as PublicKey6 } from "@dxos/keys";
2137
- import { log as log7 } from "@dxos/log";
2260
+ import { log as log8 } from "@dxos/log";
2138
2261
  import { Options as Options3 } from "@dxos/protocols/proto/dxos/halo/invitations";
2139
2262
  import { ComplexSet as ComplexSet2 } from "@dxos/util";
2140
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2263
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2141
2264
  var InvitationTopology = class {
2142
2265
  constructor(_role) {
2143
2266
  this._role = _role;
@@ -2145,7 +2268,7 @@ var InvitationTopology = class {
2145
2268
  }
2146
2269
  init(controller) {
2147
2270
  invariant8(!this._controller, "Already initialized.", {
2148
- F: __dxlog_file10,
2271
+ F: __dxlog_file11,
2149
2272
  L: 42,
2150
2273
  S: this,
2151
2274
  A: [
@@ -2157,7 +2280,7 @@ var InvitationTopology = class {
2157
2280
  }
2158
2281
  update() {
2159
2282
  invariant8(this._controller, "Not initialized.", {
2160
- F: __dxlog_file10,
2283
+ F: __dxlog_file11,
2161
2284
  L: 47,
2162
2285
  S: this,
2163
2286
  A: [
@@ -2176,11 +2299,11 @@ var InvitationTopology = class {
2176
2299
  const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
2177
2300
  this._seenPeers = new ComplexSet2(PublicKey6.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
2178
2301
  if (firstUnknownPeer != null) {
2179
- log7("invitation connect", {
2302
+ log8("invitation connect", {
2180
2303
  ownPeerId,
2181
2304
  remotePeerId: firstUnknownPeer
2182
2305
  }, {
2183
- F: __dxlog_file10,
2306
+ F: __dxlog_file11,
2184
2307
  L: 69,
2185
2308
  S: this,
2186
2309
  C: (f, a) => f(...a)
@@ -2191,7 +2314,7 @@ var InvitationTopology = class {
2191
2314
  }
2192
2315
  async onOffer(peer) {
2193
2316
  invariant8(this._controller, "Not initialized.", {
2194
- F: __dxlog_file10,
2317
+ F: __dxlog_file11,
2195
2318
  L: 76,
2196
2319
  S: this,
2197
2320
  A: [
@@ -2210,7 +2333,7 @@ var InvitationTopology = class {
2210
2333
  };
2211
2334
 
2212
2335
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
2213
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2336
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2214
2337
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
2215
2338
  var InvitationsHandler = class {
2216
2339
  /**
@@ -2235,7 +2358,7 @@ var InvitationsHandler = class {
2235
2358
  try {
2236
2359
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
2237
2360
  invariant9(deviceKey, void 0, {
2238
- F: __dxlog_file11,
2361
+ F: __dxlog_file12,
2239
2362
  L: 90,
2240
2363
  S: this,
2241
2364
  A: [
@@ -2261,18 +2384,18 @@ var InvitationsHandler = class {
2261
2384
  scheduleTask3(connectionCtx, async () => {
2262
2385
  const traceId = PublicKey7.random().toHex();
2263
2386
  try {
2264
- log8.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.begin({
2387
+ log9.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.begin({
2265
2388
  id: traceId
2266
2389
  }), {
2267
- F: __dxlog_file11,
2390
+ F: __dxlog_file12,
2268
2391
  L: 115,
2269
2392
  S: this,
2270
2393
  C: (f, a) => f(...a)
2271
2394
  });
2272
- log8("connected", {
2395
+ log9("connected", {
2273
2396
  ...protocol.toJSON()
2274
2397
  }, {
2275
- F: __dxlog_file11,
2398
+ F: __dxlog_file12,
2276
2399
  L: 116,
2277
2400
  S: this,
2278
2401
  C: (f, a) => f(...a)
@@ -2280,20 +2403,20 @@ var InvitationsHandler = class {
2280
2403
  const deviceKey = await extension.completedTrigger.wait({
2281
2404
  timeout: invitation.timeout
2282
2405
  });
2283
- log8("admitted guest", {
2406
+ log9("admitted guest", {
2284
2407
  guest: deviceKey,
2285
2408
  ...protocol.toJSON()
2286
2409
  }, {
2287
- F: __dxlog_file11,
2410
+ F: __dxlog_file12,
2288
2411
  L: 118,
2289
2412
  S: this,
2290
2413
  C: (f, a) => f(...a)
2291
2414
  });
2292
2415
  guardedState.set(extension, Invitation4.State.SUCCESS);
2293
- log8.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.end({
2416
+ log9.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.end({
2294
2417
  id: traceId
2295
2418
  }), {
2296
- F: __dxlog_file11,
2419
+ F: __dxlog_file12,
2297
2420
  L: 120,
2298
2421
  S: this,
2299
2422
  C: (f, a) => f(...a)
@@ -2305,10 +2428,10 @@ var InvitationsHandler = class {
2305
2428
  } catch (err) {
2306
2429
  if (err instanceof TimeoutError) {
2307
2430
  if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
2308
- log8("timeout", {
2431
+ log9("timeout", {
2309
2432
  ...protocol.toJSON()
2310
2433
  }, {
2311
- F: __dxlog_file11,
2434
+ F: __dxlog_file12,
2312
2435
  L: 129,
2313
2436
  S: this,
2314
2437
  C: (f, a) => f(...a)
@@ -2316,19 +2439,19 @@ var InvitationsHandler = class {
2316
2439
  }
2317
2440
  } else {
2318
2441
  if (guardedState.error(extension, err)) {
2319
- log8.error("failed", err, {
2320
- F: __dxlog_file11,
2442
+ log9.error("failed", err, {
2443
+ F: __dxlog_file12,
2321
2444
  L: 133,
2322
2445
  S: this,
2323
2446
  C: (f, a) => f(...a)
2324
2447
  });
2325
2448
  }
2326
2449
  }
2327
- log8.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.error({
2450
+ log9.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.error({
2328
2451
  id: traceId,
2329
2452
  error: err
2330
2453
  }), {
2331
- F: __dxlog_file11,
2454
+ F: __dxlog_file12,
2332
2455
  L: 136,
2333
2456
  S: this,
2334
2457
  C: (f, a) => f(...a)
@@ -2339,10 +2462,10 @@ var InvitationsHandler = class {
2339
2462
  },
2340
2463
  onError: (err) => {
2341
2464
  if (err instanceof InvalidInvitationExtensionRoleError3) {
2342
- log8("invalid role", {
2465
+ log9("invalid role", {
2343
2466
  ...err.context
2344
2467
  }, {
2345
- F: __dxlog_file11,
2468
+ F: __dxlog_file12,
2346
2469
  L: 144,
2347
2470
  S: this,
2348
2471
  C: (f, a) => f(...a)
@@ -2351,10 +2474,10 @@ var InvitationsHandler = class {
2351
2474
  }
2352
2475
  if (err instanceof TimeoutError) {
2353
2476
  if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
2354
- log8("timeout", {
2477
+ log9("timeout", {
2355
2478
  err
2356
2479
  }, {
2357
- F: __dxlog_file11,
2480
+ F: __dxlog_file12,
2358
2481
  L: 149,
2359
2482
  S: this,
2360
2483
  C: (f, a) => f(...a)
@@ -2362,8 +2485,8 @@ var InvitationsHandler = class {
2362
2485
  }
2363
2486
  } else {
2364
2487
  if (guardedState.error(extension, err)) {
2365
- log8.error("failed", err, {
2366
- F: __dxlog_file11,
2488
+ log9.error("failed", err, {
2489
+ F: __dxlog_file12,
2367
2490
  L: 153,
2368
2491
  S: this,
2369
2492
  C: (f, a) => f(...a)
@@ -2376,8 +2499,8 @@ var InvitationsHandler = class {
2376
2499
  };
2377
2500
  if (invitation.lifetime && invitation.created) {
2378
2501
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
2379
- log8.warn("invitation has already expired", void 0, {
2380
- F: __dxlog_file11,
2502
+ log9.warn("invitation has already expired", void 0, {
2503
+ F: __dxlog_file12,
2381
2504
  L: 164,
2382
2505
  S: this,
2383
2506
  C: (f, a) => f(...a)
@@ -2400,7 +2523,7 @@ var InvitationsHandler = class {
2400
2523
  const { timeout = INVITATION_TIMEOUT } = invitation;
2401
2524
  if (deviceProfile) {
2402
2525
  invariant9(invitation.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2403
- F: __dxlog_file11,
2526
+ F: __dxlog_file12,
2404
2527
  L: 197,
2405
2528
  S: this,
2406
2529
  A: [
@@ -2413,12 +2536,12 @@ var InvitationsHandler = class {
2413
2536
  const guardedState = this._createGuardedState(ctx, invitation, stream);
2414
2537
  const shouldCancelInvitationFlow = (extension) => {
2415
2538
  const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
2416
- log8("should cancel invitation flow", {
2539
+ log9("should cancel invitation flow", {
2417
2540
  isLockedByAnotherConnection,
2418
2541
  invitationType: Invitation4.Type.DELEGATED,
2419
2542
  triedPeers: triedPeersIds.size
2420
2543
  }, {
2421
- F: __dxlog_file11,
2544
+ F: __dxlog_file12,
2422
2545
  L: 205,
2423
2546
  S: this,
2424
2547
  C: (f, a) => f(...a)
@@ -2441,11 +2564,11 @@ var InvitationsHandler = class {
2441
2564
  return;
2442
2565
  }
2443
2566
  connectionCtx.onDispose(async () => {
2444
- log8("extension disposed", {
2567
+ log9("extension disposed", {
2445
2568
  admitted,
2446
2569
  currentState: guardedState.current.state
2447
2570
  }, {
2448
- F: __dxlog_file11,
2571
+ F: __dxlog_file12,
2449
2572
  L: 233,
2450
2573
  S: this,
2451
2574
  C: (f, a) => f(...a)
@@ -2460,10 +2583,10 @@ var InvitationsHandler = class {
2460
2583
  scheduleTask3(connectionCtx, async () => {
2461
2584
  const traceId = PublicKey7.random().toHex();
2462
2585
  try {
2463
- log8.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.begin({
2586
+ log9.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.begin({
2464
2587
  id: traceId
2465
2588
  }), {
2466
- F: __dxlog_file11,
2589
+ F: __dxlog_file12,
2467
2590
  L: 245,
2468
2591
  S: this,
2469
2592
  C: (f, a) => f(...a)
@@ -2472,19 +2595,19 @@ var InvitationsHandler = class {
2472
2595
  guardedState.set(extension, Invitation4.State.TIMEOUT);
2473
2596
  extensionCtx.close();
2474
2597
  }, timeout);
2475
- log8("connected", {
2598
+ log9("connected", {
2476
2599
  ...protocol.toJSON()
2477
2600
  }, {
2478
- F: __dxlog_file11,
2601
+ F: __dxlog_file12,
2479
2602
  L: 256,
2480
2603
  S: this,
2481
2604
  C: (f, a) => f(...a)
2482
2605
  });
2483
2606
  guardedState.set(extension, Invitation4.State.CONNECTED);
2484
- log8("introduce", {
2607
+ log9("introduce", {
2485
2608
  ...protocol.toJSON()
2486
2609
  }, {
2487
- F: __dxlog_file11,
2610
+ F: __dxlog_file12,
2488
2611
  L: 260,
2489
2612
  S: this,
2490
2613
  C: (f, a) => f(...a)
@@ -2493,11 +2616,11 @@ var InvitationsHandler = class {
2493
2616
  invitationId: invitation.invitationId,
2494
2617
  ...protocol.createIntroduction()
2495
2618
  });
2496
- log8("introduce response", {
2619
+ log9("introduce response", {
2497
2620
  ...protocol.toJSON(),
2498
2621
  response: introductionResponse
2499
2622
  }, {
2500
- F: __dxlog_file11,
2623
+ F: __dxlog_file12,
2501
2624
  L: 265,
2502
2625
  S: this,
2503
2626
  C: (f, a) => f(...a)
@@ -2515,10 +2638,10 @@ var InvitationsHandler = class {
2515
2638
  break;
2516
2639
  }
2517
2640
  }
2518
- log8("request admission", {
2641
+ log9("request admission", {
2519
2642
  ...protocol.toJSON()
2520
2643
  }, {
2521
- F: __dxlog_file11,
2644
+ F: __dxlog_file12,
2522
2645
  L: 291,
2523
2646
  S: this,
2524
2647
  C: (f, a) => f(...a)
@@ -2527,10 +2650,10 @@ var InvitationsHandler = class {
2527
2650
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
2528
2651
  admitted = true;
2529
2652
  const result = await protocol.accept(admissionResponse, admissionRequest);
2530
- log8("admitted by host", {
2653
+ log9("admitted by host", {
2531
2654
  ...protocol.toJSON()
2532
2655
  }, {
2533
- F: __dxlog_file11,
2656
+ F: __dxlog_file12,
2534
2657
  L: 302,
2535
2658
  S: this,
2536
2659
  C: (f, a) => f(...a)
@@ -2540,28 +2663,28 @@ var InvitationsHandler = class {
2540
2663
  ...result,
2541
2664
  state: Invitation4.State.SUCCESS
2542
2665
  });
2543
- log8.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.end({
2666
+ log9.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.end({
2544
2667
  id: traceId
2545
2668
  }), {
2546
- F: __dxlog_file11,
2669
+ F: __dxlog_file12,
2547
2670
  L: 308,
2548
2671
  S: this,
2549
2672
  C: (f, a) => f(...a)
2550
2673
  });
2551
2674
  } catch (err) {
2552
2675
  if (err instanceof TimeoutError) {
2553
- log8("timeout", {
2676
+ log9("timeout", {
2554
2677
  ...protocol.toJSON()
2555
2678
  }, {
2556
- F: __dxlog_file11,
2679
+ F: __dxlog_file12,
2557
2680
  L: 311,
2558
2681
  S: this,
2559
2682
  C: (f, a) => f(...a)
2560
2683
  });
2561
2684
  guardedState.set(extension, Invitation4.State.TIMEOUT);
2562
2685
  } else {
2563
- log8("auth failed", err, {
2564
- F: __dxlog_file11,
2686
+ log9("auth failed", err, {
2687
+ F: __dxlog_file12,
2565
2688
  L: 314,
2566
2689
  S: this,
2567
2690
  C: (f, a) => f(...a)
@@ -2569,11 +2692,11 @@ var InvitationsHandler = class {
2569
2692
  guardedState.error(extension, err);
2570
2693
  }
2571
2694
  extensionCtx.close(err);
2572
- log8.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.error({
2695
+ log9.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.error({
2573
2696
  id: traceId,
2574
2697
  error: err
2575
2698
  }), {
2576
- F: __dxlog_file11,
2699
+ F: __dxlog_file12,
2577
2700
  L: 318,
2578
2701
  S: this,
2579
2702
  C: (f, a) => f(...a)
@@ -2586,18 +2709,18 @@ var InvitationsHandler = class {
2586
2709
  return;
2587
2710
  }
2588
2711
  if (err instanceof TimeoutError) {
2589
- log8("timeout", {
2712
+ log9("timeout", {
2590
2713
  ...protocol.toJSON()
2591
2714
  }, {
2592
- F: __dxlog_file11,
2715
+ F: __dxlog_file12,
2593
2716
  L: 327,
2594
2717
  S: this,
2595
2718
  C: (f, a) => f(...a)
2596
2719
  });
2597
2720
  guardedState.set(extension, Invitation4.State.TIMEOUT);
2598
2721
  } else {
2599
- log8("auth failed", err, {
2600
- F: __dxlog_file11,
2722
+ log9("auth failed", err, {
2723
+ F: __dxlog_file12,
2601
2724
  L: 330,
2602
2725
  S: this,
2603
2726
  C: (f, a) => f(...a)
@@ -2615,7 +2738,7 @@ var InvitationsHandler = class {
2615
2738
  await ctx.dispose();
2616
2739
  } else {
2617
2740
  invariant9(invitation.swarmKey, void 0, {
2618
- F: __dxlog_file11,
2741
+ F: __dxlog_file12,
2619
2742
  L: 345,
2620
2743
  S: this,
2621
2744
  A: [
@@ -2709,12 +2832,12 @@ var InvitationsHandler = class {
2709
2832
  };
2710
2833
  }
2711
2834
  _logStateUpdate(invitation, actor, newState) {
2712
- log8("invitation state update", {
2835
+ log9("invitation state update", {
2713
2836
  actor: actor?.constructor.name,
2714
2837
  newState: stateToString(newState),
2715
2838
  oldState: stateToString(invitation.state)
2716
2839
  }, {
2717
- F: __dxlog_file11,
2840
+ F: __dxlog_file12,
2718
2841
  L: 438,
2719
2842
  S: this,
2720
2843
  C: (f, a) => f(...a)
@@ -2731,16 +2854,16 @@ var InvitationsHandler = class {
2731
2854
  }
2732
2855
  async _handleGuestOtpAuth(extension, setState, authenticated, options) {
2733
2856
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2734
- log8("guest waiting for authentication code...", void 0, {
2735
- F: __dxlog_file11,
2857
+ log9("guest waiting for authentication code...", void 0, {
2858
+ F: __dxlog_file12,
2736
2859
  L: 462,
2737
2860
  S: this,
2738
2861
  C: (f, a) => f(...a)
2739
2862
  });
2740
2863
  setState(Invitation4.State.READY_FOR_AUTHENTICATION);
2741
2864
  const authCode = await authenticated.wait(options);
2742
- log8("sending authentication request", void 0, {
2743
- F: __dxlog_file11,
2865
+ log9("sending authentication request", void 0, {
2866
+ F: __dxlog_file12,
2744
2867
  L: 466,
2745
2868
  S: this,
2746
2869
  C: (f, a) => f(...a)
@@ -2756,10 +2879,10 @@ var InvitationsHandler = class {
2756
2879
  if (attempt === MAX_OTP_ATTEMPTS) {
2757
2880
  throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
2758
2881
  } else {
2759
- log8("retrying invalid code", {
2882
+ log9("retrying invalid code", {
2760
2883
  attempt
2761
2884
  }, {
2762
- F: __dxlog_file11,
2885
+ F: __dxlog_file12,
2763
2886
  L: 477,
2764
2887
  S: this,
2765
2888
  C: (f, a) => f(...a)
@@ -2776,8 +2899,8 @@ var InvitationsHandler = class {
2776
2899
  if (introductionResponse.challenge == null) {
2777
2900
  throw new Error("challenge missing in the introduction");
2778
2901
  }
2779
- log8("sending authentication request", void 0, {
2780
- F: __dxlog_file11,
2902
+ log9("sending authentication request", void 0, {
2903
+ F: __dxlog_file12,
2781
2904
  L: 496,
2782
2905
  S: this,
2783
2906
  C: (f, a) => f(...a)
@@ -2898,14 +3021,14 @@ var InvitationsServiceImpl = class {
2898
3021
  };
2899
3022
 
2900
3023
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
2901
- import { createAdmissionCredentials, createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion } from "@dxos/credentials";
3024
+ import { createAdmissionCredentials, createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
2902
3025
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
2903
3026
  import { invariant as invariant10 } from "@dxos/invariant";
2904
- import { log as log9 } from "@dxos/log";
3027
+ import { log as log10 } from "@dxos/log";
2905
3028
  import { AlreadyJoinedError as AlreadyJoinedError2, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from "@dxos/protocols";
2906
3029
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
2907
3030
  import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
2908
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
3031
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2909
3032
  var SpaceInvitationProtocol = class {
2910
3033
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
2911
3034
  this._spaceManager = _spaceManager;
@@ -2940,7 +3063,7 @@ var SpaceInvitationProtocol = class {
2940
3063
  }
2941
3064
  async admit(invitation, request, guestProfile) {
2942
3065
  invariant10(this._spaceKey, void 0, {
2943
- F: __dxlog_file12,
3066
+ F: __dxlog_file13,
2944
3067
  L: 76,
2945
3068
  S: this,
2946
3069
  A: [
@@ -2950,7 +3073,7 @@ var SpaceInvitationProtocol = class {
2950
3073
  });
2951
3074
  const space = this._spaceManager.spaces.get(this._spaceKey);
2952
3075
  invariant10(space, void 0, {
2953
- F: __dxlog_file12,
3076
+ F: __dxlog_file13,
2954
3077
  L: 78,
2955
3078
  S: this,
2956
3079
  A: [
@@ -2959,7 +3082,7 @@ var SpaceInvitationProtocol = class {
2959
3082
  ]
2960
3083
  });
2961
3084
  invariant10(request.space, void 0, {
2962
- F: __dxlog_file12,
3085
+ F: __dxlog_file13,
2963
3086
  L: 80,
2964
3087
  S: this,
2965
3088
  A: [
@@ -2971,18 +3094,18 @@ var SpaceInvitationProtocol = class {
2971
3094
  if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember2.Role.REMOVED) {
2972
3095
  throw new AlreadyJoinedError2();
2973
3096
  }
2974
- log9("writing guest credentials", {
3097
+ log10("writing guest credentials", {
2975
3098
  host: this._signingContext.deviceKey,
2976
3099
  guest: deviceKey
2977
3100
  }, {
2978
- F: __dxlog_file12,
3101
+ F: __dxlog_file13,
2979
3102
  L: 87,
2980
3103
  S: this,
2981
3104
  C: (f, a) => f(...a)
2982
3105
  });
2983
3106
  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);
2984
3107
  invariant10(credentials[0].credential, void 0, {
2985
- F: __dxlog_file12,
3108
+ F: __dxlog_file13,
2986
3109
  L: 101,
2987
3110
  S: this,
2988
3111
  A: [
@@ -2991,8 +3114,8 @@ var SpaceInvitationProtocol = class {
2991
3114
  ]
2992
3115
  });
2993
3116
  const spaceMemberCredential = credentials[0].credential.credential;
2994
- invariant10(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2995
- F: __dxlog_file12,
3117
+ invariant10(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3118
+ F: __dxlog_file13,
2996
3119
  L: 103,
2997
3120
  S: this,
2998
3121
  A: [
@@ -3010,7 +3133,7 @@ var SpaceInvitationProtocol = class {
3010
3133
  }
3011
3134
  async delegate(invitation) {
3012
3135
  invariant10(this._spaceKey, void 0, {
3013
- F: __dxlog_file12,
3136
+ F: __dxlog_file13,
3014
3137
  L: 116,
3015
3138
  S: this,
3016
3139
  A: [
@@ -3020,7 +3143,7 @@ var SpaceInvitationProtocol = class {
3020
3143
  });
3021
3144
  const space = this._spaceManager.spaces.get(this._spaceKey);
3022
3145
  invariant10(space, void 0, {
3023
- F: __dxlog_file12,
3146
+ F: __dxlog_file13,
3024
3147
  L: 118,
3025
3148
  S: this,
3026
3149
  A: [
@@ -3030,7 +3153,7 @@ var SpaceInvitationProtocol = class {
3030
3153
  });
3031
3154
  if (invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY) {
3032
3155
  invariant10(invitation.guestKeypair?.publicKey, void 0, {
3033
- F: __dxlog_file12,
3156
+ F: __dxlog_file13,
3034
3157
  L: 120,
3035
3158
  S: this,
3036
3159
  A: [
@@ -3039,11 +3162,11 @@ var SpaceInvitationProtocol = class {
3039
3162
  ]
3040
3163
  });
3041
3164
  }
3042
- log9("writing delegate space invitation", {
3165
+ log10("writing delegate space invitation", {
3043
3166
  host: this._signingContext.deviceKey,
3044
3167
  id: invitation.invitationId
3045
3168
  }, {
3046
- F: __dxlog_file12,
3169
+ F: __dxlog_file13,
3047
3170
  L: 123,
3048
3171
  S: this,
3049
3172
  C: (f, a) => f(...a)
@@ -3058,7 +3181,7 @@ var SpaceInvitationProtocol = class {
3058
3181
  guestKey: invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
3059
3182
  });
3060
3183
  invariant10(credential.credential, void 0, {
3061
- F: __dxlog_file12,
3184
+ F: __dxlog_file13,
3062
3185
  L: 143,
3063
3186
  S: this,
3064
3187
  A: [
@@ -3073,7 +3196,7 @@ var SpaceInvitationProtocol = class {
3073
3196
  }
3074
3197
  async cancelDelegation(invitation) {
3075
3198
  invariant10(this._spaceKey, void 0, {
3076
- F: __dxlog_file12,
3199
+ F: __dxlog_file13,
3077
3200
  L: 149,
3078
3201
  S: this,
3079
3202
  A: [
@@ -3082,7 +3205,7 @@ var SpaceInvitationProtocol = class {
3082
3205
  ]
3083
3206
  });
3084
3207
  invariant10(invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
3085
- F: __dxlog_file12,
3208
+ F: __dxlog_file13,
3086
3209
  L: 150,
3087
3210
  S: this,
3088
3211
  A: [
@@ -3092,7 +3215,7 @@ var SpaceInvitationProtocol = class {
3092
3215
  });
3093
3216
  const space = this._spaceManager.spaces.get(this._spaceKey);
3094
3217
  invariant10(space, void 0, {
3095
- F: __dxlog_file12,
3218
+ F: __dxlog_file13,
3096
3219
  L: 152,
3097
3220
  S: this,
3098
3221
  A: [
@@ -3100,18 +3223,18 @@ var SpaceInvitationProtocol = class {
3100
3223
  ""
3101
3224
  ]
3102
3225
  });
3103
- log9("cancelling delegated space invitation", {
3226
+ log10("cancelling delegated space invitation", {
3104
3227
  host: this._signingContext.deviceKey,
3105
3228
  id: invitation.invitationId
3106
3229
  }, {
3107
- F: __dxlog_file12,
3230
+ F: __dxlog_file13,
3108
3231
  L: 154,
3109
3232
  S: this,
3110
3233
  C: (f, a) => f(...a)
3111
3234
  });
3112
3235
  const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
3113
3236
  invariant10(credential.credential, void 0, {
3114
- F: __dxlog_file12,
3237
+ F: __dxlog_file13,
3115
3238
  L: 161,
3116
3239
  S: this,
3117
3240
  A: [
@@ -3150,7 +3273,7 @@ var SpaceInvitationProtocol = class {
3150
3273
  }
3151
3274
  async accept(response) {
3152
3275
  invariant10(response.space, void 0, {
3153
- F: __dxlog_file12,
3276
+ F: __dxlog_file13,
3154
3277
  L: 196,
3155
3278
  S: this,
3156
3279
  A: [
@@ -3159,9 +3282,9 @@ var SpaceInvitationProtocol = class {
3159
3282
  ]
3160
3283
  });
3161
3284
  const { credential, controlTimeframe, dataTimeframe } = response.space;
3162
- const assertion = getCredentialAssertion(credential);
3285
+ const assertion = getCredentialAssertion2(credential);
3163
3286
  invariant10(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3164
- F: __dxlog_file12,
3287
+ F: __dxlog_file13,
3165
3288
  L: 199,
3166
3289
  S: this,
3167
3290
  A: [
@@ -3170,7 +3293,7 @@ var SpaceInvitationProtocol = class {
3170
3293
  ]
3171
3294
  });
3172
3295
  invariant10(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
3173
- F: __dxlog_file12,
3296
+ F: __dxlog_file13,
3174
3297
  L: 200,
3175
3298
  S: this,
3176
3299
  A: [
@@ -3202,10 +3325,10 @@ import { generatePasscode } from "@dxos/credentials";
3202
3325
  import { hasInvitationExpired } from "@dxos/echo-pipeline";
3203
3326
  import { invariant as invariant11 } from "@dxos/invariant";
3204
3327
  import { PublicKey as PublicKey8 } from "@dxos/keys";
3205
- import { log as log10 } from "@dxos/log";
3328
+ import { log as log11 } from "@dxos/log";
3206
3329
  import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
3207
3330
  import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
3208
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3331
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3209
3332
  var InvitationsManager = class {
3210
3333
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
3211
3334
  this._invitationsHandler = _invitationsHandler;
@@ -3247,8 +3370,8 @@ var InvitationsManager = class {
3247
3370
  try {
3248
3371
  await this._persistIfRequired(handler, stream, invitation);
3249
3372
  } catch (err) {
3250
- log10.catch(err, void 0, {
3251
- F: __dxlog_file13,
3373
+ log11.catch(err, void 0, {
3374
+ F: __dxlog_file14,
3252
3375
  L: 82,
3253
3376
  S: this,
3254
3377
  C: (f, a) => f(...a)
@@ -3271,7 +3394,7 @@ var InvitationsManager = class {
3271
3394
  const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
3272
3395
  const loadTasks = freshInvitations.map((persistentInvitation) => {
3273
3396
  invariant11(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
3274
- F: __dxlog_file13,
3397
+ F: __dxlog_file14,
3275
3398
  L: 103,
3276
3399
  S: this,
3277
3400
  A: [
@@ -3289,8 +3412,8 @@ var InvitationsManager = class {
3289
3412
  invitations: cInvitations.map((invitation) => invitation.get())
3290
3413
  };
3291
3414
  } catch (err) {
3292
- log10.catch(err, void 0, {
3293
- F: __dxlog_file13,
3415
+ log11.catch(err, void 0, {
3416
+ F: __dxlog_file14,
3294
3417
  L: 110,
3295
3418
  S: this,
3296
3419
  C: (f, a) => f(...a)
@@ -3321,14 +3444,14 @@ var InvitationsManager = class {
3321
3444
  return invitation;
3322
3445
  }
3323
3446
  async authenticate({ invitationId, authCode }) {
3324
- log10("authenticating...", void 0, {
3325
- F: __dxlog_file13,
3447
+ log11("authenticating...", void 0, {
3448
+ F: __dxlog_file14,
3326
3449
  L: 140,
3327
3450
  S: this,
3328
3451
  C: (f, a) => f(...a)
3329
3452
  });
3330
3453
  invariant11(invitationId, void 0, {
3331
- F: __dxlog_file13,
3454
+ F: __dxlog_file14,
3332
3455
  L: 141,
3333
3456
  S: this,
3334
3457
  A: [
@@ -3338,10 +3461,10 @@ var InvitationsManager = class {
3338
3461
  });
3339
3462
  const observable = this._acceptInvitations.get(invitationId);
3340
3463
  if (!observable) {
3341
- log10.warn("invalid invitation", {
3464
+ log11.warn("invalid invitation", {
3342
3465
  invitationId
3343
3466
  }, {
3344
- F: __dxlog_file13,
3467
+ F: __dxlog_file14,
3345
3468
  L: 144,
3346
3469
  S: this,
3347
3470
  C: (f, a) => f(...a)
@@ -3351,16 +3474,16 @@ var InvitationsManager = class {
3351
3474
  }
3352
3475
  }
3353
3476
  async cancelInvitation({ invitationId }) {
3354
- log10("cancelInvitation...", {
3477
+ log11("cancelInvitation...", {
3355
3478
  invitationId
3356
3479
  }, {
3357
- F: __dxlog_file13,
3480
+ F: __dxlog_file14,
3358
3481
  L: 151,
3359
3482
  S: this,
3360
3483
  C: (f, a) => f(...a)
3361
3484
  });
3362
3485
  invariant11(invitationId, void 0, {
3363
- F: __dxlog_file13,
3486
+ F: __dxlog_file14,
3364
3487
  L: 152,
3365
3488
  S: this,
3366
3489
  A: [
@@ -3436,10 +3559,10 @@ var InvitationsManager = class {
3436
3559
  }
3437
3560
  });
3438
3561
  ctx.onDispose(() => {
3439
- log10("complete", {
3562
+ log11("complete", {
3440
3563
  ...handler.toJSON()
3441
3564
  }, {
3442
- F: __dxlog_file13,
3565
+ F: __dxlog_file14,
3443
3566
  L: 241,
3444
3567
  S: this,
3445
3568
  C: (f, a) => f(...a)
@@ -3469,10 +3592,10 @@ var InvitationsManager = class {
3469
3592
  const ctx = new Context6({
3470
3593
  onError: (err) => {
3471
3594
  if (err instanceof TimeoutError2) {
3472
- log10("timeout", {
3595
+ log11("timeout", {
3473
3596
  ...handler.toJSON()
3474
3597
  }, {
3475
- F: __dxlog_file13,
3598
+ F: __dxlog_file14,
3476
3599
  L: 261,
3477
3600
  S: this,
3478
3601
  C: (f, a) => f(...a)
@@ -3482,8 +3605,8 @@ var InvitationsManager = class {
3482
3605
  state: Invitation6.State.TIMEOUT
3483
3606
  });
3484
3607
  } else {
3485
- log10.warn("auth failed", err, {
3486
- F: __dxlog_file13,
3608
+ log11.warn("auth failed", err, {
3609
+ F: __dxlog_file14,
3487
3610
  L: 264,
3488
3611
  S: this,
3489
3612
  C: (f, a) => f(...a)
@@ -3497,10 +3620,10 @@ var InvitationsManager = class {
3497
3620
  }
3498
3621
  });
3499
3622
  ctx.onDispose(() => {
3500
- log10("complete", {
3623
+ log11("complete", {
3501
3624
  ...handler.toJSON()
3502
3625
  }, {
3503
- F: __dxlog_file13,
3626
+ F: __dxlog_file14,
3504
3627
  L: 271,
3505
3628
  S: this,
3506
3629
  C: (f, a) => f(...a)
@@ -3544,8 +3667,8 @@ var InvitationsManager = class {
3544
3667
  try {
3545
3668
  await this._metadataStore.removeInvitation(invitation.invitationId);
3546
3669
  } catch (err) {
3547
- log10.catch(err, void 0, {
3548
- F: __dxlog_file13,
3670
+ log11.catch(err, void 0, {
3671
+ F: __dxlog_file14,
3549
3672
  L: 307,
3550
3673
  S: this,
3551
3674
  C: (f, a) => f(...a)
@@ -3568,11 +3691,11 @@ import { AutomergeDocumentLoaderImpl, createIdFromSpaceKey, createMappedFeedWrit
3568
3691
  import { TYPE_PROPERTIES } from "@dxos/echo-schema";
3569
3692
  import { failedInvariant, invariant as invariant13 } from "@dxos/invariant";
3570
3693
  import { PublicKey as PublicKey10 } from "@dxos/keys";
3571
- import { log as log12 } from "@dxos/log";
3694
+ import { log as log13 } from "@dxos/log";
3572
3695
  import { CancelledError, SystemError } from "@dxos/protocols";
3573
- import { CreateEpochRequest, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
3696
+ import { CreateEpochRequest, SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
3574
3697
  import { AdmittedFeed as AdmittedFeed3, SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/halo/credentials";
3575
- import { Timeframe as Timeframe2 } from "@dxos/timeframe";
3698
+ import { Timeframe as Timeframe3 } from "@dxos/timeframe";
3576
3699
  import { trace as trace6 } from "@dxos/tracing";
3577
3700
  import { ComplexSet as ComplexSet5, assignDeep } from "@dxos/util";
3578
3701
 
@@ -3619,11 +3742,11 @@ import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep, Ti
3619
3742
  import { Context as Context7, rejectOnDispose } from "@dxos/context";
3620
3743
  import { invariant as invariant12 } from "@dxos/invariant";
3621
3744
  import { PublicKey as PublicKey9 } from "@dxos/keys";
3622
- import { log as log11 } from "@dxos/log";
3745
+ import { log as log12 } from "@dxos/log";
3623
3746
  import { schema as schema4 } from "@dxos/protocols";
3624
3747
  import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
3625
3748
  import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet4, entry } from "@dxos/util";
3626
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3749
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3627
3750
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3628
3751
  var DEFAULT_SUCCESS_DELAY = 1e3;
3629
3752
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -3648,16 +3771,16 @@ var NotarizationPlugin = class {
3648
3771
  * Request credentials to be notarized.
3649
3772
  */
3650
3773
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
3651
- log11("notarize", {
3774
+ log12("notarize", {
3652
3775
  credentials
3653
3776
  }, {
3654
- F: __dxlog_file14,
3777
+ F: __dxlog_file15,
3655
3778
  L: 90,
3656
3779
  S: this,
3657
3780
  C: (f, a) => f(...a)
3658
3781
  });
3659
3782
  invariant12(credentials.every((credential) => credential.id), "Credentials must have an id", {
3660
- F: __dxlog_file14,
3783
+ F: __dxlog_file15,
3661
3784
  L: 91,
3662
3785
  S: this,
3663
3786
  A: [
@@ -3668,10 +3791,10 @@ var NotarizationPlugin = class {
3668
3791
  const errors = new Trigger6();
3669
3792
  const ctx = this._ctx.derive({
3670
3793
  onError: (err) => {
3671
- log11.warn("Notarization error", {
3794
+ log12.warn("Notarization error", {
3672
3795
  err
3673
3796
  }, {
3674
- F: __dxlog_file14,
3797
+ F: __dxlog_file15,
3675
3798
  L: 99,
3676
3799
  S: this,
3677
3800
  C: (f, a) => f(...a)
@@ -3683,11 +3806,11 @@ var NotarizationPlugin = class {
3683
3806
  opCtx?.onDispose(() => ctx.dispose());
3684
3807
  if (timeout !== 0) {
3685
3808
  scheduleTask4(ctx, () => {
3686
- log11.warn("Notarization timeout", {
3809
+ log12.warn("Notarization timeout", {
3687
3810
  timeout,
3688
3811
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
3689
3812
  }, {
3690
- F: __dxlog_file14,
3813
+ F: __dxlog_file15,
3691
3814
  L: 111,
3692
3815
  S: this,
3693
3816
  C: (f, a) => f(...a)
@@ -3707,10 +3830,10 @@ var NotarizationPlugin = class {
3707
3830
  ...this._extensions
3708
3831
  ].find((peer2) => !peersTried.has(peer2));
3709
3832
  if (!peer) {
3710
- log11.info("Exhausted all peers to notarize with", {
3833
+ log12.info("Exhausted all peers to notarize with", {
3711
3834
  retryIn: retryTimeout
3712
3835
  }, {
3713
- F: __dxlog_file14,
3836
+ F: __dxlog_file15,
3714
3837
  L: 136,
3715
3838
  S: this,
3716
3839
  C: (f, a) => f(...a)
@@ -3720,11 +3843,11 @@ var NotarizationPlugin = class {
3720
3843
  return;
3721
3844
  }
3722
3845
  peersTried.add(peer);
3723
- log11("try notarizing", {
3846
+ log12("try notarizing", {
3724
3847
  peer: peer.localPeerId,
3725
3848
  credentialId: credentials.map((credential) => credential.id)
3726
3849
  }, {
3727
- F: __dxlog_file14,
3850
+ F: __dxlog_file15,
3728
3851
  L: 143,
3729
3852
  S: this,
3730
3853
  C: (f, a) => f(...a)
@@ -3732,8 +3855,8 @@ var NotarizationPlugin = class {
3732
3855
  await peer.rpc.NotarizationService.notarize({
3733
3856
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
3734
3857
  });
3735
- log11("success", void 0, {
3736
- F: __dxlog_file14,
3858
+ log12("success", void 0, {
3859
+ F: __dxlog_file15,
3737
3860
  L: 147,
3738
3861
  S: this,
3739
3862
  C: (f, a) => f(...a)
@@ -3741,8 +3864,8 @@ var NotarizationPlugin = class {
3741
3864
  await sleep(successDelay);
3742
3865
  } catch (err) {
3743
3866
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
3744
- log11.info("error notarizing (recoverable)", err, {
3745
- F: __dxlog_file14,
3867
+ log12.info("error notarizing (recoverable)", err, {
3868
+ F: __dxlog_file15,
3746
3869
  L: 151,
3747
3870
  S: this,
3748
3871
  C: (f, a) => f(...a)
@@ -3759,8 +3882,8 @@ var NotarizationPlugin = class {
3759
3882
  allNotarized,
3760
3883
  errors.wait()
3761
3884
  ]);
3762
- log11("done", void 0, {
3763
- F: __dxlog_file14,
3885
+ log12("done", void 0, {
3886
+ F: __dxlog_file15,
3764
3887
  L: 162,
3765
3888
  S: this,
3766
3889
  C: (f, a) => f(...a)
@@ -3782,7 +3905,7 @@ var NotarizationPlugin = class {
3782
3905
  }
3783
3906
  setWriter(writer) {
3784
3907
  invariant12(!this._writer, "Writer already set.", {
3785
- F: __dxlog_file14,
3908
+ F: __dxlog_file15,
3786
3909
  L: 181,
3787
3910
  S: this,
3788
3911
  A: [
@@ -3807,7 +3930,7 @@ var NotarizationPlugin = class {
3807
3930
  }
3808
3931
  for (const credential of request.credentials ?? []) {
3809
3932
  invariant12(credential.id, "Credential must have an id", {
3810
- F: __dxlog_file14,
3933
+ F: __dxlog_file15,
3811
3934
  L: 200,
3812
3935
  S: this,
3813
3936
  A: [
@@ -3824,10 +3947,10 @@ var NotarizationPlugin = class {
3824
3947
  createExtension() {
3825
3948
  const extension = new NotarizationTeleportExtension({
3826
3949
  onOpen: async () => {
3827
- log11("extension opened", {
3950
+ log12("extension opened", {
3828
3951
  peer: extension.localPeerId
3829
3952
  }, {
3830
- F: __dxlog_file14,
3953
+ F: __dxlog_file15,
3831
3954
  L: 211,
3832
3955
  S: this,
3833
3956
  C: (f, a) => f(...a)
@@ -3836,10 +3959,10 @@ var NotarizationPlugin = class {
3836
3959
  this._extensionOpened.emit();
3837
3960
  },
3838
3961
  onClose: async () => {
3839
- log11("extension closed", {
3962
+ log12("extension closed", {
3840
3963
  peer: extension.localPeerId
3841
3964
  }, {
3842
- F: __dxlog_file14,
3965
+ F: __dxlog_file15,
3843
3966
  L: 216,
3844
3967
  S: this,
3845
3968
  C: (f, a) => f(...a)
@@ -3893,7 +4016,7 @@ function _ts_decorate4(decorators, target, key, desc) {
3893
4016
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3894
4017
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3895
4018
  }
3896
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4019
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3897
4020
  var DataSpace = class {
3898
4021
  constructor(params) {
3899
4022
  this._ctx = new Context8();
@@ -3901,7 +4024,7 @@ var DataSpace = class {
3901
4024
  this._cache = void 0;
3902
4025
  // TODO(dmaretskyi): Move into Space?
3903
4026
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
3904
- this._state = SpaceState.CLOSED;
4027
+ this._state = SpaceState2.CLOSED;
3905
4028
  /**
3906
4029
  * Error for _state === SpaceState.ERROR.
3907
4030
  */
@@ -3925,10 +4048,10 @@ var DataSpace = class {
3925
4048
  });
3926
4049
  this._cache = params.cache;
3927
4050
  this._state = params.initialState;
3928
- log12("new state", {
3929
- state: SpaceState[this._state]
4051
+ log13("new state", {
4052
+ state: SpaceState2[this._state]
3930
4053
  }, {
3931
- F: __dxlog_file15,
4054
+ F: __dxlog_file16,
3932
4055
  L: 143,
3933
4056
  S: this,
3934
4057
  C: (f, a) => f(...a)
@@ -3969,20 +4092,23 @@ var DataSpace = class {
3969
4092
  };
3970
4093
  }
3971
4094
  async open() {
3972
- await this._open();
4095
+ if (this._state === SpaceState2.CLOSED) {
4096
+ await this._open();
4097
+ }
3973
4098
  }
3974
4099
  async _open() {
4100
+ await this._presence.open();
3975
4101
  await this._gossip.open();
3976
4102
  await this._notarizationPlugin.open();
3977
4103
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
3978
4104
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
3979
4105
  await this._inner.open(new Context8());
3980
- this._state = SpaceState.CONTROL_ONLY;
3981
- log12("new state", {
3982
- state: SpaceState[this._state]
4106
+ this._state = SpaceState2.CONTROL_ONLY;
4107
+ log13("new state", {
4108
+ state: SpaceState2[this._state]
3983
4109
  }, {
3984
- F: __dxlog_file15,
3985
- L: 206,
4110
+ F: __dxlog_file16,
4111
+ L: 209,
3986
4112
  S: this,
3987
4113
  C: (f, a) => f(...a)
3988
4114
  });
@@ -3995,12 +4121,12 @@ var DataSpace = class {
3995
4121
  }
3996
4122
  async _close() {
3997
4123
  await this._callbacks.beforeClose?.();
3998
- this._state = SpaceState.CLOSED;
3999
- log12("new state", {
4000
- state: SpaceState[this._state]
4124
+ this._state = SpaceState2.CLOSED;
4125
+ log13("new state", {
4126
+ state: SpaceState2[this._state]
4001
4127
  }, {
4002
- F: __dxlog_file15,
4003
- L: 220,
4128
+ F: __dxlog_file16,
4129
+ L: 223,
4004
4130
  S: this,
4005
4131
  C: (f, a) => f(...a)
4006
4132
  });
@@ -4011,7 +4137,7 @@ var DataSpace = class {
4011
4137
  await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
4012
4138
  await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
4013
4139
  await this._notarizationPlugin.close();
4014
- await this._presence.destroy();
4140
+ await this._presence.close();
4015
4141
  await this._gossip.close();
4016
4142
  }
4017
4143
  async postMessage(channel, message) {
@@ -4030,26 +4156,26 @@ var DataSpace = class {
4030
4156
  await this.initializeDataPipeline();
4031
4157
  } catch (err) {
4032
4158
  if (err instanceof CancelledError || err instanceof ContextDisposedError3) {
4033
- log12("data pipeline initialization cancelled", err, {
4034
- F: __dxlog_file15,
4035
- L: 253,
4159
+ log13("data pipeline initialization cancelled", err, {
4160
+ F: __dxlog_file16,
4161
+ L: 256,
4036
4162
  S: this,
4037
4163
  C: (f, a) => f(...a)
4038
4164
  });
4039
4165
  return;
4040
4166
  }
4041
- log12.error("Error initializing data pipeline", err, {
4042
- F: __dxlog_file15,
4043
- L: 257,
4167
+ log13.error("Error initializing data pipeline", err, {
4168
+ F: __dxlog_file16,
4169
+ L: 260,
4044
4170
  S: this,
4045
4171
  C: (f, a) => f(...a)
4046
4172
  });
4047
- this._state = SpaceState.ERROR;
4048
- log12("new state", {
4049
- state: SpaceState[this._state]
4173
+ this._state = SpaceState2.ERROR;
4174
+ log13("new state", {
4175
+ state: SpaceState2[this._state]
4050
4176
  }, {
4051
- F: __dxlog_file15,
4052
- L: 259,
4177
+ F: __dxlog_file16,
4178
+ L: 262,
4053
4179
  S: this,
4054
4180
  C: (f, a) => f(...a)
4055
4181
  });
@@ -4061,15 +4187,15 @@ var DataSpace = class {
4061
4187
  });
4062
4188
  }
4063
4189
  async initializeDataPipeline() {
4064
- if (this._state !== SpaceState.CONTROL_ONLY) {
4190
+ if (this._state !== SpaceState2.CONTROL_ONLY) {
4065
4191
  throw new SystemError("Invalid operation");
4066
4192
  }
4067
- this._state = SpaceState.INITIALIZING;
4068
- log12("new state", {
4069
- state: SpaceState[this._state]
4193
+ this._state = SpaceState2.INITIALIZING;
4194
+ log13("new state", {
4195
+ state: SpaceState2[this._state]
4070
4196
  }, {
4071
- F: __dxlog_file15,
4072
- L: 275,
4197
+ F: __dxlog_file16,
4198
+ L: 278,
4073
4199
  S: this,
4074
4200
  C: (f, a) => f(...a)
4075
4201
  });
@@ -4077,19 +4203,19 @@ var DataSpace = class {
4077
4203
  await sleep2(1);
4078
4204
  this._automergeSpaceState.startProcessingRootDocs();
4079
4205
  await cancelWithContext4(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
4080
- log12("data pipeline ready", void 0, {
4081
- F: __dxlog_file15,
4082
- L: 287,
4206
+ log13("data pipeline ready", void 0, {
4207
+ F: __dxlog_file16,
4208
+ L: 290,
4083
4209
  S: this,
4084
4210
  C: (f, a) => f(...a)
4085
4211
  });
4086
4212
  await this._callbacks.beforeReady?.();
4087
- this._state = SpaceState.READY;
4088
- log12("new state", {
4089
- state: SpaceState[this._state]
4213
+ this._state = SpaceState2.READY;
4214
+ log13("new state", {
4215
+ state: SpaceState2[this._state]
4090
4216
  }, {
4091
- F: __dxlog_file15,
4092
- L: 291,
4217
+ F: __dxlog_file16,
4218
+ L: 294,
4093
4219
  S: this,
4094
4220
  C: (f, a) => f(...a)
4095
4221
  });
@@ -4103,9 +4229,9 @@ var DataSpace = class {
4103
4229
  });
4104
4230
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
4105
4231
  await this._createWritableFeeds();
4106
- log12("writable feeds created", void 0, {
4107
- F: __dxlog_file15,
4108
- L: 307,
4232
+ log13("writable feeds created", void 0, {
4233
+ F: __dxlog_file16,
4234
+ L: 310,
4109
4235
  S: this,
4110
4236
  C: (f, a) => f(...a)
4111
4237
  });
@@ -4163,12 +4289,12 @@ var DataSpace = class {
4163
4289
  }
4164
4290
  }
4165
4291
  _onNewAutomergeRoot(rootUrl) {
4166
- log12("loading automerge root doc for space", {
4292
+ log13("loading automerge root doc for space", {
4167
4293
  space: this.key,
4168
4294
  rootUrl
4169
4295
  }, {
4170
- F: __dxlog_file15,
4171
- L: 373,
4296
+ F: __dxlog_file16,
4297
+ L: 376,
4172
4298
  S: this,
4173
4299
  C: (f, a) => f(...a)
4174
4300
  });
@@ -4193,12 +4319,12 @@ var DataSpace = class {
4193
4319
  if (!this._echoHost.roots.has(handle.documentId)) {
4194
4320
  await this._echoHost.openSpaceRoot(handle.url);
4195
4321
  } else {
4196
- log12.warn("echo database root already exists", {
4322
+ log13.warn("echo database root already exists", {
4197
4323
  space: this.key,
4198
4324
  rootUrl
4199
4325
  }, {
4200
- F: __dxlog_file15,
4201
- L: 400,
4326
+ F: __dxlog_file16,
4327
+ L: 403,
4202
4328
  S: this,
4203
4329
  C: (f, a) => f(...a)
4204
4330
  });
@@ -4207,13 +4333,13 @@ var DataSpace = class {
4207
4333
  if (err instanceof ContextDisposedError3) {
4208
4334
  return;
4209
4335
  }
4210
- log12.warn("error loading automerge root doc", {
4336
+ log13.warn("error loading automerge root doc", {
4211
4337
  space: this.key,
4212
4338
  rootUrl,
4213
4339
  err
4214
4340
  }, {
4215
- F: __dxlog_file15,
4216
- L: 406,
4341
+ F: __dxlog_file16,
4342
+ L: 409,
4217
4343
  S: this,
4218
4344
  C: (f, a) => f(...a)
4219
4345
  });
@@ -4244,7 +4370,7 @@ var DataSpace = class {
4244
4370
  epoch = {
4245
4371
  previousId: this._automergeSpaceState.lastEpoch?.id,
4246
4372
  number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
4247
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
4373
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
4248
4374
  automergeRoot: this._automergeSpaceState.lastEpoch?.subject.assertion?.automergeRoot
4249
4375
  };
4250
4376
  }
@@ -4255,7 +4381,7 @@ var DataSpace = class {
4255
4381
  epoch = {
4256
4382
  previousId: this._automergeSpaceState.lastEpoch?.id,
4257
4383
  number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
4258
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
4384
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
4259
4385
  automergeRoot: document.url
4260
4386
  };
4261
4387
  }
@@ -4266,9 +4392,12 @@ var DataSpace = class {
4266
4392
  const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
4267
4393
  await cancelWithContext4(this._ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
4268
4394
  const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
4395
+ await this._echoHost.automergeRepo.flush([
4396
+ newRoot.documentId
4397
+ ]);
4269
4398
  invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
4270
- F: __dxlog_file15,
4271
- L: 456,
4399
+ F: __dxlog_file16,
4400
+ L: 460,
4272
4401
  S: this,
4273
4402
  A: [
4274
4403
  "typeof newRoot.url === 'string' && newRoot.url.length > 0",
@@ -4278,16 +4407,16 @@ var DataSpace = class {
4278
4407
  epoch = {
4279
4408
  previousId: this._automergeSpaceState.lastEpoch?.id,
4280
4409
  number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
4281
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
4410
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
4282
4411
  automergeRoot: newRoot.url
4283
4412
  };
4284
4413
  }
4285
4414
  break;
4286
4415
  case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
4287
4416
  {
4288
- log12.info("Fragmenting", void 0, {
4289
- F: __dxlog_file15,
4290
- L: 468,
4417
+ log13.info("Fragmenting", void 0, {
4418
+ F: __dxlog_file16,
4419
+ L: 472,
4291
4420
  S: this,
4292
4421
  C: (f, a) => f(...a)
4293
4422
  });
@@ -4298,8 +4427,8 @@ var DataSpace = class {
4298
4427
  const properties = findPropertiesObject(rootHandle.docSync());
4299
4428
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
4300
4429
  invariant13(properties, "Properties not found", {
4301
- F: __dxlog_file15,
4302
- L: 478,
4430
+ F: __dxlog_file16,
4431
+ L: 482,
4303
4432
  S: this,
4304
4433
  A: [
4305
4434
  "properties",
@@ -4314,8 +4443,8 @@ var DataSpace = class {
4314
4443
  };
4315
4444
  const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
4316
4445
  invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
4317
- F: __dxlog_file15,
4318
- L: 483,
4446
+ F: __dxlog_file16,
4447
+ L: 487,
4319
4448
  S: this,
4320
4449
  A: [
4321
4450
  "typeof newRoot.url === 'string' && newRoot.url.length > 0",
@@ -4338,7 +4467,7 @@ var DataSpace = class {
4338
4467
  epoch = {
4339
4468
  previousId: this._automergeSpaceState.lastEpoch?.id,
4340
4469
  number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
4341
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
4470
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
4342
4471
  automergeRoot: newRoot.url
4343
4472
  };
4344
4473
  }
@@ -4346,8 +4475,8 @@ var DataSpace = class {
4346
4475
  case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT:
4347
4476
  {
4348
4477
  invariant13(options.newAutomergeRoot, void 0, {
4349
- F: __dxlog_file15,
4350
- L: 513,
4478
+ F: __dxlog_file16,
4479
+ L: 517,
4351
4480
  S: this,
4352
4481
  A: [
4353
4482
  "options.newAutomergeRoot",
@@ -4357,7 +4486,7 @@ var DataSpace = class {
4357
4486
  epoch = {
4358
4487
  previousId: this._automergeSpaceState.lastEpoch?.id,
4359
4488
  number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
4360
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
4489
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
4361
4490
  automergeRoot: options.newAutomergeRoot
4362
4491
  };
4363
4492
  }
@@ -4377,7 +4506,7 @@ var DataSpace = class {
4377
4506
  })
4378
4507
  }
4379
4508
  });
4380
- await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe2([
4509
+ await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe3([
4381
4510
  [
4382
4511
  receipt.feedKey,
4383
4512
  receipt.seq
@@ -4386,25 +4515,30 @@ var DataSpace = class {
4386
4515
  await this._echoHost.updateIndexes();
4387
4516
  }
4388
4517
  async activate() {
4389
- if (this._state !== SpaceState.INACTIVE) {
4518
+ if (![
4519
+ SpaceState2.CLOSED,
4520
+ SpaceState2.INACTIVE
4521
+ ].includes(this._state)) {
4390
4522
  return;
4391
4523
  }
4392
- await this._metadataStore.setSpaceState(this.key, SpaceState.ACTIVE);
4524
+ await this._metadataStore.setSpaceState(this.key, SpaceState2.ACTIVE);
4393
4525
  await this._open();
4394
4526
  this.initializeDataPipelineAsync();
4395
4527
  }
4396
4528
  async deactivate() {
4397
- if (this._state === SpaceState.INACTIVE) {
4529
+ if (this._state === SpaceState2.INACTIVE) {
4398
4530
  return;
4399
4531
  }
4400
- await this._metadataStore.setSpaceState(this.key, SpaceState.INACTIVE);
4401
- await this._close();
4402
- this._state = SpaceState.INACTIVE;
4403
- log12("new state", {
4404
- state: SpaceState[this._state]
4532
+ await this._metadataStore.setSpaceState(this.key, SpaceState2.INACTIVE);
4533
+ if (this._state !== SpaceState2.CLOSED) {
4534
+ await this._close();
4535
+ }
4536
+ this._state = SpaceState2.INACTIVE;
4537
+ log13("new state", {
4538
+ state: SpaceState2[this._state]
4405
4539
  }, {
4406
- F: __dxlog_file15,
4407
- L: 566,
4540
+ F: __dxlog_file16,
4541
+ L: 571,
4408
4542
  S: this,
4409
4543
  C: (f, a) => f(...a)
4410
4544
  });
@@ -4422,7 +4556,7 @@ _ts_decorate4([
4422
4556
  ], DataSpace.prototype, "key", null);
4423
4557
  _ts_decorate4([
4424
4558
  trace6.info({
4425
- enum: SpaceState
4559
+ enum: SpaceState2
4426
4560
  })
4427
4561
  ], DataSpace.prototype, "state", null);
4428
4562
  _ts_decorate4([
@@ -4474,24 +4608,27 @@ var findPropertiesObject = (spaceDoc) => {
4474
4608
 
4475
4609
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
4476
4610
  import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
4611
+ import { PropertiesType } from "@dxos/client-protocol";
4477
4612
  import { cancelWithContext as cancelWithContext5, Context as Context9 } from "@dxos/context";
4478
- import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
4613
+ import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
4479
4614
  import { AuthStatus } from "@dxos/echo-pipeline";
4615
+ import { encodeReference } from "@dxos/echo-protocol";
4616
+ import { getTypeReference } from "@dxos/echo-schema";
4480
4617
  import { invariant as invariant14 } from "@dxos/invariant";
4481
4618
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4482
- import { log as log13 } from "@dxos/log";
4619
+ import { log as log14 } from "@dxos/log";
4483
4620
  import { trace as Trace2 } from "@dxos/protocols";
4484
- import { Invitation as Invitation7, SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
4621
+ import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
4485
4622
  import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
4486
4623
  import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
4487
4624
  import { trace as trace7 } from "@dxos/tracing";
4488
- import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
4625
+ import { assignDeep as assignDeep2, ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
4489
4626
 
4490
4627
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
4491
4628
  import { createCredential } from "@dxos/credentials";
4492
4629
  import { failUndefined } from "@dxos/debug";
4493
4630
  import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember5 } from "@dxos/protocols/proto/dxos/halo/credentials";
4494
- import { Timeframe as Timeframe3 } from "@dxos/timeframe";
4631
+ import { Timeframe as Timeframe4 } from "@dxos/timeframe";
4495
4632
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
4496
4633
  const credentials = [
4497
4634
  await createCredential({
@@ -4541,7 +4678,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
4541
4678
  "@type": "dxos.halo.credentials.Epoch",
4542
4679
  number: 0,
4543
4680
  previousId: void 0,
4544
- timeframe: new Timeframe3(),
4681
+ timeframe: new Timeframe4(),
4545
4682
  snapshotCid: void 0,
4546
4683
  automergeRoot
4547
4684
  }
@@ -4568,11 +4705,12 @@ function _ts_decorate5(decorators, target, key, desc) {
4568
4705
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4569
4706
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4570
4707
  }
4571
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4708
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4572
4709
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
4573
4710
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
4711
+ var DEFAULT_SPACE_KEY = "__DEFAULT__";
4574
4712
  var DataSpaceManager = class {
4575
- constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, params) {
4713
+ constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, _params) {
4576
4714
  this._spaceManager = _spaceManager;
4577
4715
  this._metadataStore = _metadataStore;
4578
4716
  this._keyring = _keyring;
@@ -4580,14 +4718,12 @@ var DataSpaceManager = class {
4580
4718
  this._feedStore = _feedStore;
4581
4719
  this._echoHost = _echoHost;
4582
4720
  this._invitationsManager = _invitationsManager;
4721
+ this._params = _params;
4583
4722
  this._ctx = new Context9();
4584
4723
  this.updated = new Event7();
4585
4724
  this._spaces = new ComplexMap3(PublicKey11.hash);
4586
4725
  this._isOpen = false;
4587
4726
  this._instanceId = PublicKey11.random().toHex();
4588
- const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
4589
- this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
4590
- this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
4591
4727
  trace7.diagnostic({
4592
4728
  id: "spaces",
4593
4729
  name: "Spaces",
@@ -4599,7 +4735,7 @@ var DataSpaceManager = class {
4599
4735
  const properties = rootDoc && findPropertiesObject(rootDoc);
4600
4736
  return {
4601
4737
  key: space.key.toHex(),
4602
- state: SpaceState2[space.state],
4738
+ state: SpaceState3[space.state],
4603
4739
  name: properties?.[1].data.name ?? null,
4604
4740
  inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
4605
4741
  linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
@@ -4616,46 +4752,46 @@ var DataSpaceManager = class {
4616
4752
  return this._spaces;
4617
4753
  }
4618
4754
  async open() {
4619
- log13("open", void 0, {
4620
- F: __dxlog_file16,
4621
- L: 144,
4755
+ log14("open", void 0, {
4756
+ F: __dxlog_file17,
4757
+ L: 140,
4622
4758
  S: this,
4623
4759
  C: (f, a) => f(...a)
4624
4760
  });
4625
- log13.trace("dxos.echo.data-space-manager.open", Trace2.begin({
4761
+ log14.trace("dxos.echo.data-space-manager.open", Trace2.begin({
4626
4762
  id: this._instanceId
4627
4763
  }), {
4628
- F: __dxlog_file16,
4629
- L: 145,
4764
+ F: __dxlog_file17,
4765
+ L: 141,
4630
4766
  S: this,
4631
4767
  C: (f, a) => f(...a)
4632
4768
  });
4633
- log13("metadata loaded", {
4769
+ log14("metadata loaded", {
4634
4770
  spaces: this._metadataStore.spaces.length
4635
4771
  }, {
4636
- F: __dxlog_file16,
4637
- L: 146,
4772
+ F: __dxlog_file17,
4773
+ L: 142,
4638
4774
  S: this,
4639
4775
  C: (f, a) => f(...a)
4640
4776
  });
4641
4777
  await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
4642
4778
  try {
4643
- log13("load space", {
4779
+ log14("load space", {
4644
4780
  spaceMetadata
4645
4781
  }, {
4646
- F: __dxlog_file16,
4647
- L: 150,
4782
+ F: __dxlog_file17,
4783
+ L: 146,
4648
4784
  S: this,
4649
4785
  C: (f, a) => f(...a)
4650
4786
  });
4651
4787
  await this._constructSpace(spaceMetadata);
4652
4788
  } catch (err) {
4653
- log13.error("Error loading space", {
4789
+ log14.error("Error loading space", {
4654
4790
  spaceMetadata,
4655
4791
  err
4656
4792
  }, {
4657
- F: __dxlog_file16,
4658
- L: 153,
4793
+ F: __dxlog_file17,
4794
+ L: 149,
4659
4795
  S: this,
4660
4796
  C: (f, a) => f(...a)
4661
4797
  });
@@ -4663,24 +4799,19 @@ var DataSpaceManager = class {
4663
4799
  });
4664
4800
  this._isOpen = true;
4665
4801
  this.updated.emit();
4666
- for (const space of this._spaces.values()) {
4667
- if (space.state !== SpaceState2.INACTIVE) {
4668
- space.initializeDataPipelineAsync();
4669
- }
4670
- }
4671
- log13.trace("dxos.echo.data-space-manager.open", Trace2.end({
4802
+ log14.trace("dxos.echo.data-space-manager.open", Trace2.end({
4672
4803
  id: this._instanceId
4673
4804
  }), {
4674
- F: __dxlog_file16,
4675
- L: 166,
4805
+ F: __dxlog_file17,
4806
+ L: 156,
4676
4807
  S: this,
4677
4808
  C: (f, a) => f(...a)
4678
4809
  });
4679
4810
  }
4680
4811
  async close() {
4681
- log13("close", void 0, {
4682
- F: __dxlog_file16,
4683
- L: 171,
4812
+ log14("close", void 0, {
4813
+ F: __dxlog_file17,
4814
+ L: 161,
4684
4815
  S: this,
4685
4816
  C: (f, a) => f(...a)
4686
4817
  });
@@ -4689,14 +4820,15 @@ var DataSpaceManager = class {
4689
4820
  for (const space of this._spaces.values()) {
4690
4821
  await space.close();
4691
4822
  }
4823
+ this._spaces.clear();
4692
4824
  }
4693
4825
  /**
4694
4826
  * Creates a new space writing the genesis credentials to the control feed.
4695
4827
  */
4696
4828
  async createSpace() {
4697
4829
  invariant14(this._isOpen, "Not open.", {
4698
- F: __dxlog_file16,
4699
- L: 184,
4830
+ F: __dxlog_file17,
4831
+ L: 175,
4700
4832
  S: this,
4701
4833
  A: [
4702
4834
  "this._isOpen",
@@ -4711,24 +4843,25 @@ var DataSpaceManager = class {
4711
4843
  genesisFeedKey: controlFeedKey,
4712
4844
  controlFeedKey,
4713
4845
  dataFeedKey,
4714
- state: SpaceState2.ACTIVE
4846
+ state: SpaceState3.ACTIVE
4715
4847
  };
4716
- log13("creating space...", {
4848
+ log14("creating space...", {
4717
4849
  spaceKey
4718
4850
  }, {
4719
- F: __dxlog_file16,
4720
- L: 196,
4851
+ F: __dxlog_file17,
4852
+ L: 187,
4721
4853
  S: this,
4722
4854
  C: (f, a) => f(...a)
4723
4855
  });
4724
4856
  const root = await this._echoHost.createSpaceRoot(spaceKey);
4725
4857
  const space = await this._constructSpace(metadata);
4858
+ await space.open();
4726
4859
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
4727
4860
  await this._metadataStore.addSpace(metadata);
4728
4861
  const memberCredential = credentials[1];
4729
- invariant14(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4730
- F: __dxlog_file16,
4731
- L: 205,
4862
+ invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4863
+ F: __dxlog_file17,
4864
+ L: 197,
4732
4865
  S: this,
4733
4866
  A: [
4734
4867
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -4740,19 +4873,63 @@ var DataSpaceManager = class {
4740
4873
  this.updated.emit();
4741
4874
  return space;
4742
4875
  }
4876
+ async isDefaultSpace(space) {
4877
+ const rootDoc = await this._getSpaceRootDocument(space);
4878
+ const [_, properties] = findPropertiesObject(rootDoc.docSync()) ?? [];
4879
+ return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
4880
+ }
4881
+ async createDefaultSpace() {
4882
+ const space = await this.createSpace();
4883
+ const document = await this._getSpaceRootDocument(space);
4884
+ const properties = {
4885
+ system: {
4886
+ type: encodeReference(getTypeReference(PropertiesType))
4887
+ },
4888
+ data: {
4889
+ [DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
4890
+ },
4891
+ meta: {
4892
+ keys: []
4893
+ }
4894
+ };
4895
+ const propertiesId = PublicKey11.random().toHex();
4896
+ document.change((doc) => {
4897
+ assignDeep2(doc, [
4898
+ "objects",
4899
+ propertiesId
4900
+ ], properties);
4901
+ });
4902
+ await this._echoHost.flush();
4903
+ return space;
4904
+ }
4905
+ async _getSpaceRootDocument(space) {
4906
+ const automergeIndex = space.automergeSpaceState.rootUrl;
4907
+ invariant14(automergeIndex, void 0, {
4908
+ F: __dxlog_file17,
4909
+ L: 240,
4910
+ S: this,
4911
+ A: [
4912
+ "automergeIndex",
4913
+ ""
4914
+ ]
4915
+ });
4916
+ const document = this._echoHost.automergeRepo.find(automergeIndex);
4917
+ await document.whenReady();
4918
+ return document;
4919
+ }
4743
4920
  // TODO(burdon): Rename join space.
4744
4921
  async acceptSpace(opts) {
4745
- log13("accept space", {
4922
+ log14("accept space", {
4746
4923
  opts
4747
4924
  }, {
4748
- F: __dxlog_file16,
4749
- L: 217,
4925
+ F: __dxlog_file17,
4926
+ L: 249,
4750
4927
  S: this,
4751
4928
  C: (f, a) => f(...a)
4752
4929
  });
4753
4930
  invariant14(this._isOpen, "Not open.", {
4754
- F: __dxlog_file16,
4755
- L: 218,
4931
+ F: __dxlog_file17,
4932
+ L: 250,
4756
4933
  S: this,
4757
4934
  A: [
4758
4935
  "this._isOpen",
@@ -4760,8 +4937,8 @@ var DataSpaceManager = class {
4760
4937
  ]
4761
4938
  });
4762
4939
  invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
4763
- F: __dxlog_file16,
4764
- L: 219,
4940
+ F: __dxlog_file17,
4941
+ L: 251,
4765
4942
  S: this,
4766
4943
  A: [
4767
4944
  "!this._spaces.has(opts.spaceKey)",
@@ -4775,6 +4952,7 @@ var DataSpaceManager = class {
4775
4952
  dataTimeframe: opts.dataTimeframe
4776
4953
  };
4777
4954
  const space = await this._constructSpace(metadata);
4955
+ await space.open();
4778
4956
  await this._metadataStore.addSpace(metadata);
4779
4957
  space.initializeDataPipelineAsync();
4780
4958
  this.updated.emit();
@@ -4788,15 +4966,15 @@ var DataSpaceManager = class {
4788
4966
  async waitUntilSpaceReady(spaceKey) {
4789
4967
  await cancelWithContext5(this._ctx, this.updated.waitForCondition(() => {
4790
4968
  const space = this._spaces.get(spaceKey);
4791
- return !!space && space.state === SpaceState2.READY;
4969
+ return !!space && space.state === SpaceState3.READY;
4792
4970
  }));
4793
4971
  }
4794
4972
  async _constructSpace(metadata) {
4795
- log13("construct space", {
4973
+ log14("construct space", {
4796
4974
  metadata
4797
4975
  }, {
4798
- F: __dxlog_file16,
4799
- L: 252,
4976
+ F: __dxlog_file17,
4977
+ L: 285,
4800
4978
  S: this,
4801
4979
  C: (f, a) => f(...a)
4802
4980
  });
@@ -4804,8 +4982,8 @@ var DataSpaceManager = class {
4804
4982
  localPeerId: this._signingContext.deviceKey
4805
4983
  });
4806
4984
  const presence = new Presence2({
4807
- announceInterval: this._spaceMemberPresenceAnnounceInterval,
4808
- offlineTimeout: this._spaceMemberPresenceOfflineTimeout,
4985
+ announceInterval: this._params?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
4986
+ offlineTimeout: this._params?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
4809
4987
  identityKey: this._signingContext.identityKey,
4810
4988
  gossip
4811
4989
  });
@@ -4832,15 +5010,15 @@ var DataSpaceManager = class {
4832
5010
  session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
4833
5011
  },
4834
5012
  onAuthFailure: () => {
4835
- log13.warn("auth failure", void 0, {
4836
- F: __dxlog_file16,
4837
- L: 289,
5013
+ log14.warn("auth failure", void 0, {
5014
+ F: __dxlog_file17,
5015
+ L: 322,
4838
5016
  S: this,
4839
5017
  C: (f, a) => f(...a)
4840
5018
  });
4841
5019
  },
4842
5020
  onMemberRolesChanged: async (members) => {
4843
- if (dataSpace?.state === SpaceState2.READY) {
5021
+ if (dataSpace?.state === SpaceState3.READY) {
4844
5022
  this._handleMemberRoleChanges(presence, space.protocol, members);
4845
5023
  }
4846
5024
  },
@@ -4853,7 +5031,7 @@ var DataSpaceManager = class {
4853
5031
  dataFeed && await space.setDataFeed(dataFeed);
4854
5032
  const dataSpace = new DataSpace({
4855
5033
  inner: space,
4856
- initialState: metadata.state === SpaceState2.INACTIVE ? SpaceState2.INACTIVE : SpaceState2.CLOSED,
5034
+ initialState: metadata.state === SpaceState3.INACTIVE ? SpaceState3.INACTIVE : SpaceState3.CLOSED,
4857
5035
  metadataStore: this._metadataStore,
4858
5036
  gossip,
4859
5037
  presence,
@@ -4863,22 +5041,22 @@ var DataSpaceManager = class {
4863
5041
  signingContext: this._signingContext,
4864
5042
  callbacks: {
4865
5043
  beforeReady: async () => {
4866
- log13("before space ready", {
5044
+ log14("before space ready", {
4867
5045
  space: space.key
4868
5046
  }, {
4869
- F: __dxlog_file16,
4870
- L: 316,
5047
+ F: __dxlog_file17,
5048
+ L: 349,
4871
5049
  S: this,
4872
5050
  C: (f, a) => f(...a)
4873
5051
  });
4874
5052
  },
4875
5053
  afterReady: async () => {
4876
- log13("after space ready", {
5054
+ log14("after space ready", {
4877
5055
  space: space.key,
4878
5056
  open: this._isOpen
4879
5057
  }, {
4880
- F: __dxlog_file16,
4881
- L: 319,
5058
+ F: __dxlog_file17,
5059
+ L: 352,
4882
5060
  S: this,
4883
5061
  C: (f, a) => f(...a)
4884
5062
  });
@@ -4893,11 +5071,11 @@ var DataSpaceManager = class {
4893
5071
  }
4894
5072
  },
4895
5073
  beforeClose: async () => {
4896
- log13("before space close", {
5074
+ log14("before space close", {
4897
5075
  space: space.key
4898
5076
  }, {
4899
- F: __dxlog_file16,
4900
- L: 327,
5077
+ F: __dxlog_file17,
5078
+ L: 360,
4901
5079
  S: this,
4902
5080
  C: (f, a) => f(...a)
4903
5081
  });
@@ -4906,13 +5084,10 @@ var DataSpaceManager = class {
4906
5084
  cache: metadata.cache
4907
5085
  });
4908
5086
  presence.newPeer.on((peerState) => {
4909
- if (dataSpace.state === SpaceState2.READY) {
5087
+ if (dataSpace.state === SpaceState3.READY) {
4910
5088
  this._handleNewPeerConnected(space, peerState);
4911
5089
  }
4912
5090
  });
4913
- if (metadata.state !== SpaceState2.INACTIVE) {
4914
- await dataSpace.open();
4915
- }
4916
5091
  if (metadata.controlTimeframe) {
4917
5092
  dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
4918
5093
  }
@@ -4931,17 +5106,17 @@ var DataSpaceManager = class {
4931
5106
  return (s && member.role === SpaceMember6.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
4932
5107
  });
4933
5108
  sessionsToClose.forEach((session) => {
4934
- void session.close().catch(log13.error);
5109
+ void session.close().catch(log14.error);
4935
5110
  });
4936
5111
  closedSessions += sessionsToClose.length;
4937
5112
  }
4938
- log13("processed member role changes", {
5113
+ log14("processed member role changes", {
4939
5114
  roleChangeCount: memberInfo.length,
4940
5115
  peersOnline: presence.getPeersOnline().length,
4941
5116
  closedSessions
4942
5117
  }, {
4943
- F: __dxlog_file16,
4944
- L: 367,
5118
+ F: __dxlog_file17,
5119
+ L: 396,
4945
5120
  S: this,
4946
5121
  C: (f, a) => f(...a)
4947
5122
  });
@@ -4952,20 +5127,20 @@ var DataSpaceManager = class {
4952
5127
  if (role === SpaceMember6.Role.REMOVED) {
4953
5128
  const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
4954
5129
  if (session != null) {
4955
- log13("closing a session with a removed peer", {
5130
+ log14("closing a session with a removed peer", {
4956
5131
  peerId: peerState.peerId
4957
5132
  }, {
4958
- F: __dxlog_file16,
4959
- L: 381,
5133
+ F: __dxlog_file17,
5134
+ L: 410,
4960
5135
  S: this,
4961
5136
  C: (f, a) => f(...a)
4962
5137
  });
4963
- void session.close().catch(log13.error);
5138
+ void session.close().catch(log14.error);
4964
5139
  }
4965
5140
  }
4966
5141
  }
4967
5142
  async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
4968
- if (dataSpace?.state !== SpaceState2.READY) {
5143
+ if (dataSpace?.state !== SpaceState3.READY) {
4969
5144
  return;
4970
5145
  }
4971
5146
  if (isActive) {
@@ -5019,15 +5194,15 @@ DataSpaceManager = _ts_decorate5([
5019
5194
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
5020
5195
  import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask6 } from "@dxos/async";
5021
5196
  import { Stream as Stream10 } from "@dxos/codec-protobuf";
5022
- import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
5197
+ import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
5023
5198
  import { raise as raise2 } from "@dxos/debug";
5024
5199
  import { writeMessages as writeMessages3 } from "@dxos/feed-store";
5025
5200
  import { invariant as invariant15 } from "@dxos/invariant";
5026
- import { log as log14 } from "@dxos/log";
5201
+ import { log as log15 } from "@dxos/log";
5027
5202
  import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
5028
- import { SpaceMember as SpaceMember7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
5203
+ import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
5029
5204
  import { trace as trace8 } from "@dxos/tracing";
5030
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5205
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5031
5206
  var SpacesServiceImpl = class {
5032
5207
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
5033
5208
  this._identityManager = _identityManager;
@@ -5046,10 +5221,10 @@ var SpacesServiceImpl = class {
5046
5221
  const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
5047
5222
  if (state) {
5048
5223
  switch (state) {
5049
- case SpaceState3.ACTIVE:
5224
+ case SpaceState4.ACTIVE:
5050
5225
  await space.activate();
5051
5226
  break;
5052
- case SpaceState3.INACTIVE:
5227
+ case SpaceState4.INACTIVE:
5053
5228
  await space.deactivate();
5054
5229
  break;
5055
5230
  default:
@@ -5071,7 +5246,7 @@ var SpacesServiceImpl = class {
5071
5246
  }
5072
5247
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
5073
5248
  invariant15(credentials[0].credential, void 0, {
5074
- F: __dxlog_file17,
5249
+ F: __dxlog_file18,
5075
5250
  L: 97,
5076
5251
  S: this,
5077
5252
  A: [
@@ -5080,8 +5255,8 @@ var SpacesServiceImpl = class {
5080
5255
  ]
5081
5256
  });
5082
5257
  const spaceMemberCredential = credentials[0].credential.credential;
5083
- invariant15(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5084
- F: __dxlog_file17,
5258
+ invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5259
+ F: __dxlog_file18,
5085
5260
  L: 99,
5086
5261
  S: this,
5087
5262
  A: [
@@ -5096,10 +5271,10 @@ var SpacesServiceImpl = class {
5096
5271
  const scheduler = new UpdateScheduler(ctx, async () => {
5097
5272
  const dataSpaceManager = await this._getDataSpaceManager();
5098
5273
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
5099
- log14("update", {
5274
+ log15("update", {
5100
5275
  spaces
5101
5276
  }, {
5102
- F: __dxlog_file17,
5277
+ F: __dxlog_file18,
5103
5278
  L: 110,
5104
5279
  S: this,
5105
5280
  C: (f, a) => f(...a)
@@ -5183,7 +5358,7 @@ var SpacesServiceImpl = class {
5183
5358
  });
5184
5359
  } else {
5185
5360
  invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
5186
- F: __dxlog_file17,
5361
+ F: __dxlog_file18,
5187
5362
  L: 198,
5188
5363
  S: this,
5189
5364
  A: [
@@ -5192,7 +5367,7 @@ var SpacesServiceImpl = class {
5192
5367
  ]
5193
5368
  });
5194
5369
  invariant15(this._identityManager.identity, "Identity is not available", {
5195
- F: __dxlog_file17,
5370
+ F: __dxlog_file18,
5196
5371
  L: 199,
5197
5372
  S: this,
5198
5373
  A: [
@@ -5202,7 +5377,7 @@ var SpacesServiceImpl = class {
5202
5377
  });
5203
5378
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
5204
5379
  invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
5205
- F: __dxlog_file17,
5380
+ F: __dxlog_file18,
5206
5381
  L: 201,
5207
5382
  S: this,
5208
5383
  A: [
@@ -5292,8 +5467,8 @@ var getChannelId = (channel) => `user-channel/${channel}`;
5292
5467
 
5293
5468
  // packages/sdk/client-services/src/packlets/services/service-context.ts
5294
5469
  import { Trigger as Trigger7 } from "@dxos/async";
5295
- import { Context as Context10, Resource } from "@dxos/context";
5296
- import { getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
5470
+ import { Context as Context10, Resource as Resource2 } from "@dxos/context";
5471
+ import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
5297
5472
  import { failUndefined as failUndefined2 } from "@dxos/debug";
5298
5473
  import { EchoHost } from "@dxos/echo-db";
5299
5474
  import { MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
@@ -5301,7 +5476,7 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
5301
5476
  import { invariant as invariant16 } from "@dxos/invariant";
5302
5477
  import { Keyring } from "@dxos/keyring";
5303
5478
  import { PublicKey as PublicKey12 } from "@dxos/keys";
5304
- import { log as log15 } from "@dxos/log";
5479
+ import { log as log16 } from "@dxos/log";
5305
5480
  import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
5306
5481
  import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
5307
5482
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
@@ -5317,8 +5492,8 @@ function _ts_decorate6(decorators, target, key, desc) {
5317
5492
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5318
5493
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5319
5494
  }
5320
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5321
- var ServiceContext = class extends Resource {
5495
+ var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5496
+ var ServiceContext = class extends Resource2 {
5322
5497
  constructor(storage, level, networkManager, signalManager, _runtimeParams) {
5323
5498
  super();
5324
5499
  this.storage = storage;
@@ -5361,16 +5536,16 @@ var ServiceContext = class extends Resource {
5361
5536
  }
5362
5537
  async _open(ctx) {
5363
5538
  await this._checkStorageVersion();
5364
- log15("opening...", void 0, {
5365
- F: __dxlog_file18,
5539
+ log16("opening...", void 0, {
5540
+ F: __dxlog_file19,
5366
5541
  L: 152,
5367
5542
  S: this,
5368
5543
  C: (f, a) => f(...a)
5369
5544
  });
5370
- log15.trace("dxos.sdk.service-context.open", trace9.begin({
5545
+ log16.trace("dxos.sdk.service-context.open", trace9.begin({
5371
5546
  id: this._instanceId
5372
5547
  }), {
5373
- F: __dxlog_file18,
5548
+ F: __dxlog_file19,
5374
5549
  L: 153,
5375
5550
  S: this,
5376
5551
  C: (f, a) => f(...a)
@@ -5385,32 +5560,32 @@ var ServiceContext = class extends Resource {
5385
5560
  await this._initialize(ctx);
5386
5561
  }
5387
5562
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
5388
- log15("loaded persistent invitations", {
5563
+ log16("loaded persistent invitations", {
5389
5564
  count: loadedInvitations.invitations?.length
5390
5565
  }, {
5391
- F: __dxlog_file18,
5566
+ F: __dxlog_file19,
5392
5567
  L: 166,
5393
5568
  S: this,
5394
5569
  C: (f, a) => f(...a)
5395
5570
  });
5396
- log15.trace("dxos.sdk.service-context.open", trace9.end({
5571
+ log16.trace("dxos.sdk.service-context.open", trace9.end({
5397
5572
  id: this._instanceId
5398
5573
  }), {
5399
- F: __dxlog_file18,
5574
+ F: __dxlog_file19,
5400
5575
  L: 168,
5401
5576
  S: this,
5402
5577
  C: (f, a) => f(...a)
5403
5578
  });
5404
- log15("opened", void 0, {
5405
- F: __dxlog_file18,
5579
+ log16("opened", void 0, {
5580
+ F: __dxlog_file19,
5406
5581
  L: 169,
5407
5582
  S: this,
5408
5583
  C: (f, a) => f(...a)
5409
5584
  });
5410
5585
  }
5411
5586
  async _close(ctx) {
5412
- log15("closing...", void 0, {
5413
- F: __dxlog_file18,
5587
+ log16("closing...", void 0, {
5588
+ F: __dxlog_file19,
5414
5589
  L: 173,
5415
5590
  S: this,
5416
5591
  C: (f, a) => f(...a)
@@ -5426,8 +5601,8 @@ var ServiceContext = class extends Resource {
5426
5601
  await this.echoHost.close(ctx);
5427
5602
  await this.networkManager.close();
5428
5603
  await this.signalManager.close();
5429
- log15("closed", void 0, {
5430
- F: __dxlog_file18,
5604
+ log16("closed", void 0, {
5605
+ F: __dxlog_file19,
5431
5606
  L: 185,
5432
5607
  S: this,
5433
5608
  C: (f, a) => f(...a)
@@ -5441,7 +5616,7 @@ var ServiceContext = class extends Resource {
5441
5616
  getInvitationHandler(invitation) {
5442
5617
  const factory = this._handlerFactories.get(invitation.kind);
5443
5618
  invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
5444
- F: __dxlog_file18,
5619
+ F: __dxlog_file19,
5445
5620
  L: 196,
5446
5621
  S: this,
5447
5622
  A: [
@@ -5472,8 +5647,8 @@ var ServiceContext = class extends Resource {
5472
5647
  }
5473
5648
  // Called when identity is created.
5474
5649
  async _initialize(ctx) {
5475
- log15("initializing spaces...", void 0, {
5476
- F: __dxlog_file18,
5650
+ log16("initializing spaces...", void 0, {
5651
+ F: __dxlog_file19,
5477
5652
  L: 227,
5478
5653
  S: this,
5479
5654
  C: (f, a) => f(...a)
@@ -5496,7 +5671,7 @@ var ServiceContext = class extends Resource {
5496
5671
  await this.dataSpaceManager.open();
5497
5672
  this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
5498
5673
  invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
5499
- F: __dxlog_file18,
5674
+ F: __dxlog_file19,
5500
5675
  L: 252,
5501
5676
  S: this,
5502
5677
  A: [
@@ -5509,7 +5684,7 @@ var ServiceContext = class extends Resource {
5509
5684
  this.initialized.wake();
5510
5685
  this._deviceSpaceSync = {
5511
5686
  processCredential: async (credential) => {
5512
- const assertion = getCredentialAssertion4(credential);
5687
+ const assertion = getCredentialAssertion5(credential);
5513
5688
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
5514
5689
  return;
5515
5690
  }
@@ -5517,10 +5692,10 @@ var ServiceContext = class extends Resource {
5517
5692
  return;
5518
5693
  }
5519
5694
  if (!this.dataSpaceManager) {
5520
- log15("dataSpaceManager not initialized yet, ignoring space admission", {
5695
+ log16("dataSpaceManager not initialized yet, ignoring space admission", {
5521
5696
  details: assertion
5522
5697
  }, {
5523
- F: __dxlog_file18,
5698
+ F: __dxlog_file19,
5524
5699
  L: 268,
5525
5700
  S: this,
5526
5701
  C: (f, a) => f(...a)
@@ -5528,10 +5703,10 @@ var ServiceContext = class extends Resource {
5528
5703
  return;
5529
5704
  }
5530
5705
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
5531
- log15("space already exists, ignoring space admission", {
5706
+ log16("space already exists, ignoring space admission", {
5532
5707
  details: assertion
5533
5708
  }, {
5534
- F: __dxlog_file18,
5709
+ F: __dxlog_file19,
5535
5710
  L: 272,
5536
5711
  S: this,
5537
5712
  C: (f, a) => f(...a)
@@ -5539,10 +5714,10 @@ var ServiceContext = class extends Resource {
5539
5714
  return;
5540
5715
  }
5541
5716
  try {
5542
- log15("accepting space recorded in halo", {
5717
+ log16("accepting space recorded in halo", {
5543
5718
  details: assertion
5544
5719
  }, {
5545
- F: __dxlog_file18,
5720
+ F: __dxlog_file19,
5546
5721
  L: 277,
5547
5722
  S: this,
5548
5723
  C: (f, a) => f(...a)
@@ -5552,8 +5727,8 @@ var ServiceContext = class extends Resource {
5552
5727
  genesisFeedKey: assertion.genesisFeedKey
5553
5728
  });
5554
5729
  } catch (err) {
5555
- log15.catch(err, void 0, {
5556
- F: __dxlog_file18,
5730
+ log16.catch(err, void 0, {
5731
+ F: __dxlog_file19,
5557
5732
  L: 283,
5558
5733
  S: this,
5559
5734
  C: (f, a) => f(...a)
@@ -5602,7 +5777,7 @@ var ServiceRegistry = class {
5602
5777
  // packages/sdk/client-services/src/packlets/locks/browser.ts
5603
5778
  import { asyncTimeout as asyncTimeout3, Trigger as Trigger8 } from "@dxos/async";
5604
5779
  import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
5605
- import { log as log16, logInfo } from "@dxos/log";
5780
+ import { log as log17, logInfo } from "@dxos/log";
5606
5781
  function _ts_decorate7(decorators, target, key, desc) {
5607
5782
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5608
5783
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -5613,7 +5788,7 @@ function _ts_decorate7(decorators, target, key, desc) {
5613
5788
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5614
5789
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5615
5790
  }
5616
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
5791
+ var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
5617
5792
  var Message;
5618
5793
  (function(Message2) {
5619
5794
  Message2["ACQUIRING"] = "acquiring";
@@ -5635,29 +5810,29 @@ var Lock = class {
5635
5810
  message: "acquiring"
5636
5811
  });
5637
5812
  try {
5638
- log16("aquiring lock...", void 0, {
5639
- F: __dxlog_file19,
5813
+ log17("aquiring lock...", void 0, {
5814
+ F: __dxlog_file20,
5640
5815
  L: 42,
5641
5816
  S: this,
5642
5817
  C: (f, a) => f(...a)
5643
5818
  });
5644
5819
  await asyncTimeout3(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
5645
- log16("acquired lock", void 0, {
5646
- F: __dxlog_file19,
5820
+ log17("acquired lock", void 0, {
5821
+ F: __dxlog_file20,
5647
5822
  L: 44,
5648
5823
  S: this,
5649
5824
  C: (f, a) => f(...a)
5650
5825
  });
5651
5826
  } catch {
5652
- log16("stealing lock...", void 0, {
5653
- F: __dxlog_file19,
5827
+ log17("stealing lock...", void 0, {
5828
+ F: __dxlog_file20,
5654
5829
  L: 46,
5655
5830
  S: this,
5656
5831
  C: (f, a) => f(...a)
5657
5832
  });
5658
5833
  await this._requestLock(true);
5659
- log16("stolen lock", void 0, {
5660
- F: __dxlog_file19,
5834
+ log17("stolen lock", void 0, {
5835
+ F: __dxlog_file20,
5661
5836
  L: 48,
5662
5837
  S: this,
5663
5838
  C: (f, a) => f(...a)
@@ -5673,10 +5848,10 @@ var Lock = class {
5673
5848
  }
5674
5849
  }
5675
5850
  async _requestLock(steal = false) {
5676
- log16("requesting lock...", {
5851
+ log17("requesting lock...", {
5677
5852
  steal
5678
5853
  }, {
5679
- F: __dxlog_file19,
5854
+ F: __dxlog_file20,
5680
5855
  L: 63,
5681
5856
  S: this,
5682
5857
  C: (f, a) => f(...a)
@@ -5689,15 +5864,15 @@ var Lock = class {
5689
5864
  acquired.wake();
5690
5865
  this._releaseTrigger = new Trigger8();
5691
5866
  await this._releaseTrigger.wait();
5692
- log16("releasing lock...", void 0, {
5693
- F: __dxlog_file19,
5867
+ log17("releasing lock...", void 0, {
5868
+ F: __dxlog_file20,
5694
5869
  L: 72,
5695
5870
  S: this,
5696
5871
  C: (f, a) => f(...a)
5697
5872
  });
5698
5873
  await this._onRelease?.();
5699
- log16("released lock", void 0, {
5700
- F: __dxlog_file19,
5874
+ log17("released lock", void 0, {
5875
+ F: __dxlog_file20,
5701
5876
  L: 74,
5702
5877
  S: this,
5703
5878
  C: (f, a) => f(...a)
@@ -5706,10 +5881,10 @@ var Lock = class {
5706
5881
  await this._onRelease?.();
5707
5882
  });
5708
5883
  await acquired.wait();
5709
- log16("recieved lock", {
5884
+ log17("recieved lock", {
5710
5885
  steal
5711
5886
  }, {
5712
- F: __dxlog_file19,
5887
+ F: __dxlog_file20,
5713
5888
  L: 81,
5714
5889
  S: this,
5715
5890
  C: (f, a) => f(...a)
@@ -5799,19 +5974,16 @@ var createLevel = async (config) => {
5799
5974
 
5800
5975
  // packages/sdk/client-services/src/packlets/services/service-host.ts
5801
5976
  import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
5802
- import { clientServiceBundle, defaultKey, PropertiesType } from "@dxos/client-protocol";
5977
+ import { clientServiceBundle } from "@dxos/client-protocol";
5803
5978
  import { Context as Context11 } from "@dxos/context";
5804
- import { encodeReference } from "@dxos/echo-protocol";
5805
- import { getTypeReference } from "@dxos/echo-schema";
5806
5979
  import { invariant as invariant18 } from "@dxos/invariant";
5807
5980
  import { PublicKey as PublicKey16 } from "@dxos/keys";
5808
- import { log as log18 } from "@dxos/log";
5981
+ import { log as log19 } from "@dxos/log";
5809
5982
  import { WebsocketSignalManager } from "@dxos/messaging";
5810
5983
  import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
5811
5984
  import { trace as trace10 } from "@dxos/protocols";
5812
5985
  import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
5813
5986
  import { TRACE_PROCESSOR as TRACE_PROCESSOR3, trace as Trace4 } from "@dxos/tracing";
5814
- import { assignDeep as assignDeep2 } from "@dxos/util";
5815
5987
  import { WebsocketRpcClient } from "@dxos/websocket-rpc";
5816
5988
 
5817
5989
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
@@ -5819,7 +5991,7 @@ import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
5819
5991
  import { Stream as Stream11 } from "@dxos/codec-protobuf";
5820
5992
  import { invariant as invariant17 } from "@dxos/invariant";
5821
5993
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
5822
- var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
5994
+ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
5823
5995
  var DevicesServiceImpl = class {
5824
5996
  constructor(_identityManager) {
5825
5997
  this._identityManager = _identityManager;
@@ -5837,7 +6009,7 @@ var DevicesServiceImpl = class {
5837
6009
  });
5838
6010
  } else {
5839
6011
  invariant17(this._identityManager.identity?.presence, "presence not present", {
5840
- F: __dxlog_file20,
6012
+ F: __dxlog_file21,
5841
6013
  L: 32,
5842
6014
  S: this,
5843
6015
  A: [
@@ -5947,7 +6119,7 @@ var findConfigs = () => {
5947
6119
  import { Event as Event8 } from "@dxos/async";
5948
6120
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
5949
6121
  import { PublicKey as PublicKey15 } from "@dxos/keys";
5950
- import { getContextFromEntry, log as log17 } from "@dxos/log";
6122
+ import { getContextFromEntry, log as log18 } from "@dxos/log";
5951
6123
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
5952
6124
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
5953
6125
  var LoggingServiceImpl = class {
@@ -5960,11 +6132,11 @@ var LoggingServiceImpl = class {
5960
6132
  };
5961
6133
  }
5962
6134
  async open() {
5963
- log17.runtimeConfig.processors.push(this._logProcessor);
6135
+ log18.runtimeConfig.processors.push(this._logProcessor);
5964
6136
  }
5965
6137
  async close() {
5966
- const index = log17.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
5967
- log17.runtimeConfig.processors.splice(index, 1);
6138
+ const index = log18.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6139
+ log18.runtimeConfig.processors.splice(index, 1);
5968
6140
  }
5969
6141
  async controlMetrics({ reset, record }) {
5970
6142
  if (reset) {
@@ -6168,7 +6340,7 @@ function _ts_decorate8(decorators, target, key, desc) {
6168
6340
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6169
6341
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6170
6342
  }
6171
- var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6343
+ var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6172
6344
  var ClientServicesHost = class {
6173
6345
  constructor({
6174
6346
  config,
@@ -6188,7 +6360,7 @@ var ClientServicesHost = class {
6188
6360
  this._storage = storage;
6189
6361
  this._level = level;
6190
6362
  this._callbacks = callbacks;
6191
- this._runtimeParams = runtimeParams;
6363
+ this._runtimeParams = runtimeParams ?? {};
6192
6364
  if (config) {
6193
6365
  this.initialize({
6194
6366
  config,
@@ -6257,24 +6429,24 @@ var ClientServicesHost = class {
6257
6429
  */
6258
6430
  initialize({ config, ...options }) {
6259
6431
  invariant18(!this._open, "service host is open", {
6260
- F: __dxlog_file21,
6261
- L: 189,
6432
+ F: __dxlog_file22,
6433
+ L: 186,
6262
6434
  S: this,
6263
6435
  A: [
6264
6436
  "!this._open",
6265
6437
  "'service host is open'"
6266
6438
  ]
6267
6439
  });
6268
- log18("initializing...", void 0, {
6269
- F: __dxlog_file21,
6270
- L: 190,
6440
+ log19("initializing...", void 0, {
6441
+ F: __dxlog_file22,
6442
+ L: 187,
6271
6443
  S: this,
6272
6444
  C: (f, a) => f(...a)
6273
6445
  });
6274
6446
  if (config) {
6275
6447
  invariant18(!this._config, "config already set", {
6276
- F: __dxlog_file21,
6277
- L: 193,
6448
+ F: __dxlog_file22,
6449
+ L: 190,
6278
6450
  S: this,
6279
6451
  A: [
6280
6452
  "!this._config",
@@ -6287,9 +6459,9 @@ var ClientServicesHost = class {
6287
6459
  }
6288
6460
  }
6289
6461
  if (!options.signalManager) {
6290
- log18.warn("running signaling without telemetry metadata.", void 0, {
6291
- F: __dxlog_file21,
6292
- L: 201,
6462
+ log19.warn("running signaling without telemetry metadata.", void 0, {
6463
+ F: __dxlog_file22,
6464
+ L: 198,
6293
6465
  S: this,
6294
6466
  C: (f, a) => f(...a)
6295
6467
  });
@@ -6299,8 +6471,8 @@ var ClientServicesHost = class {
6299
6471
  }), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
6300
6472
  this._signalManager = signalManager;
6301
6473
  invariant18(!this._networkManager, "network manager already set", {
6302
- F: __dxlog_file21,
6303
- L: 212,
6474
+ F: __dxlog_file22,
6475
+ L: 209,
6304
6476
  S: this,
6305
6477
  A: [
6306
6478
  "!this._networkManager",
@@ -6312,9 +6484,9 @@ var ClientServicesHost = class {
6312
6484
  transportFactory,
6313
6485
  signalManager
6314
6486
  });
6315
- log18("initialized", void 0, {
6316
- F: __dxlog_file21,
6317
- L: 219,
6487
+ log19("initialized", void 0, {
6488
+ F: __dxlog_file22,
6489
+ L: 216,
6318
6490
  S: this,
6319
6491
  C: (f, a) => f(...a)
6320
6492
  });
@@ -6324,17 +6496,17 @@ var ClientServicesHost = class {
6324
6496
  return;
6325
6497
  }
6326
6498
  const traceId = PublicKey16.random().toHex();
6327
- log18.trace("dxos.client-services.host.open", trace10.begin({
6499
+ log19.trace("dxos.client-services.host.open", trace10.begin({
6328
6500
  id: traceId
6329
6501
  }), {
6330
- F: __dxlog_file21,
6331
- L: 230,
6502
+ F: __dxlog_file22,
6503
+ L: 227,
6332
6504
  S: this,
6333
6505
  C: (f, a) => f(...a)
6334
6506
  });
6335
6507
  invariant18(this._config, "config not set", {
6336
- F: __dxlog_file21,
6337
- L: 232,
6508
+ F: __dxlog_file22,
6509
+ L: 229,
6338
6510
  S: this,
6339
6511
  A: [
6340
6512
  "this._config",
@@ -6342,8 +6514,8 @@ var ClientServicesHost = class {
6342
6514
  ]
6343
6515
  });
6344
6516
  invariant18(this._storage, "storage not set", {
6345
- F: __dxlog_file21,
6346
- L: 233,
6517
+ F: __dxlog_file22,
6518
+ L: 230,
6347
6519
  S: this,
6348
6520
  A: [
6349
6521
  "this._storage",
@@ -6351,8 +6523,8 @@ var ClientServicesHost = class {
6351
6523
  ]
6352
6524
  });
6353
6525
  invariant18(this._signalManager, "signal manager not set", {
6354
- F: __dxlog_file21,
6355
- L: 234,
6526
+ F: __dxlog_file22,
6527
+ L: 231,
6356
6528
  S: this,
6357
6529
  A: [
6358
6530
  "this._signalManager",
@@ -6360,8 +6532,8 @@ var ClientServicesHost = class {
6360
6532
  ]
6361
6533
  });
6362
6534
  invariant18(this._networkManager, "network manager not set", {
6363
- F: __dxlog_file21,
6364
- L: 235,
6535
+ F: __dxlog_file22,
6536
+ L: 232,
6365
6537
  S: this,
6366
6538
  A: [
6367
6539
  "this._networkManager",
@@ -6369,11 +6541,11 @@ var ClientServicesHost = class {
6369
6541
  ]
6370
6542
  });
6371
6543
  this._opening = true;
6372
- log18("opening...", {
6544
+ log19("opening...", {
6373
6545
  lockKey: this._resourceLock?.lockKey
6374
6546
  }, {
6375
- F: __dxlog_file21,
6376
- L: 238,
6547
+ F: __dxlog_file22,
6548
+ L: 235,
6377
6549
  S: this,
6378
6550
  C: (f, a) => f(...a)
6379
6551
  });
@@ -6384,9 +6556,10 @@ var ClientServicesHost = class {
6384
6556
  await this._level.open();
6385
6557
  await this._loggingService.open();
6386
6558
  this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
6559
+ const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
6387
6560
  this._serviceRegistry.setServices({
6388
6561
  SystemService: this._systemService,
6389
- IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
6562
+ IdentityService: identityService,
6390
6563
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
6391
6564
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
6392
6565
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
@@ -6406,6 +6579,7 @@ var ClientServicesHost = class {
6406
6579
  })
6407
6580
  });
6408
6581
  await this._serviceContext.open(ctx);
6582
+ await identityService.open();
6409
6583
  const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
6410
6584
  if (devtoolsProxy) {
6411
6585
  this._devtoolsProxy = new WebsocketRpcClient({
@@ -6421,18 +6595,18 @@ var ClientServicesHost = class {
6421
6595
  this._open = true;
6422
6596
  this._statusUpdate.emit();
6423
6597
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6424
- log18("opened", {
6598
+ log19("opened", {
6425
6599
  deviceKey
6426
6600
  }, {
6427
- F: __dxlog_file21,
6601
+ F: __dxlog_file22,
6428
6602
  L: 314,
6429
6603
  S: this,
6430
6604
  C: (f, a) => f(...a)
6431
6605
  });
6432
- log18.trace("dxos.client-services.host.open", trace10.end({
6606
+ log19.trace("dxos.client-services.host.open", trace10.end({
6433
6607
  id: traceId
6434
6608
  }), {
6435
- F: __dxlog_file21,
6609
+ F: __dxlog_file22,
6436
6610
  L: 315,
6437
6611
  S: this,
6438
6612
  C: (f, a) => f(...a)
@@ -6443,10 +6617,10 @@ var ClientServicesHost = class {
6443
6617
  return;
6444
6618
  }
6445
6619
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6446
- log18("closing...", {
6620
+ log19("closing...", {
6447
6621
  deviceKey
6448
6622
  }, {
6449
- F: __dxlog_file21,
6623
+ F: __dxlog_file22,
6450
6624
  L: 326,
6451
6625
  S: this,
6452
6626
  C: (f, a) => f(...a)
@@ -6461,10 +6635,10 @@ var ClientServicesHost = class {
6461
6635
  await this._level?.close();
6462
6636
  this._open = false;
6463
6637
  this._statusUpdate.emit();
6464
- log18("closed", {
6638
+ log19("closed", {
6465
6639
  deviceKey
6466
6640
  }, {
6467
- F: __dxlog_file21,
6641
+ F: __dxlog_file22,
6468
6642
  L: 335,
6469
6643
  S: this,
6470
6644
  C: (f, a) => f(...a)
@@ -6472,32 +6646,32 @@ var ClientServicesHost = class {
6472
6646
  }
6473
6647
  async reset() {
6474
6648
  const traceId = PublicKey16.random().toHex();
6475
- log18.trace("dxos.sdk.client-services-host.reset", trace10.begin({
6649
+ log19.trace("dxos.sdk.client-services-host.reset", trace10.begin({
6476
6650
  id: traceId
6477
6651
  }), {
6478
- F: __dxlog_file21,
6652
+ F: __dxlog_file22,
6479
6653
  L: 340,
6480
6654
  S: this,
6481
6655
  C: (f, a) => f(...a)
6482
6656
  });
6483
- log18.info("resetting...", void 0, {
6484
- F: __dxlog_file21,
6657
+ log19.info("resetting...", void 0, {
6658
+ F: __dxlog_file22,
6485
6659
  L: 342,
6486
6660
  S: this,
6487
6661
  C: (f, a) => f(...a)
6488
6662
  });
6489
6663
  await this._serviceContext?.close();
6490
6664
  await this._storage.reset();
6491
- log18.info("reset", void 0, {
6492
- F: __dxlog_file21,
6665
+ log19.info("reset", void 0, {
6666
+ F: __dxlog_file22,
6493
6667
  L: 345,
6494
6668
  S: this,
6495
6669
  C: (f, a) => f(...a)
6496
6670
  });
6497
- log18.trace("dxos.sdk.client-services-host.reset", trace10.end({
6671
+ log19.trace("dxos.sdk.client-services-host.reset", trace10.end({
6498
6672
  id: traceId
6499
6673
  }), {
6500
- F: __dxlog_file21,
6674
+ F: __dxlog_file22,
6501
6675
  L: 346,
6502
6676
  S: this,
6503
6677
  C: (f, a) => f(...a)
@@ -6507,38 +6681,6 @@ var ClientServicesHost = class {
6507
6681
  async _createIdentity(params) {
6508
6682
  const identity = await this._serviceContext.createIdentity(params);
6509
6683
  await this._serviceContext.initialized.wait();
6510
- const space = await this._serviceContext.dataSpaceManager.createSpace();
6511
- const automergeIndex = space.automergeSpaceState.rootUrl;
6512
- invariant18(automergeIndex, void 0, {
6513
- F: __dxlog_file21,
6514
- L: 358,
6515
- S: this,
6516
- A: [
6517
- "automergeIndex",
6518
- ""
6519
- ]
6520
- });
6521
- const document = this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
6522
- await document.whenReady();
6523
- const properties = {
6524
- system: {
6525
- type: encodeReference(getTypeReference(PropertiesType))
6526
- },
6527
- data: {
6528
- [defaultKey]: identity.identityKey.toHex()
6529
- },
6530
- meta: {
6531
- keys: []
6532
- }
6533
- };
6534
- const propertiesId = PublicKey16.random().toHex();
6535
- document.change((doc) => {
6536
- assignDeep2(doc, [
6537
- "objects",
6538
- propertiesId
6539
- ], properties);
6540
- });
6541
- await this._serviceContext.echoHost.flush();
6542
6684
  return identity;
6543
6685
  }
6544
6686
  };
@@ -6601,4 +6743,4 @@ export {
6601
6743
  ClientServicesProviderResource,
6602
6744
  DiagnosticsCollector
6603
6745
  };
6604
- //# sourceMappingURL=chunk-SMW6LWWU.mjs.map
6746
+ //# sourceMappingURL=chunk-2EFXBSRZ.mjs.map