@dxos/client-services 0.6.12-main.f9d0246 → 0.6.12-staging.e11e696

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 (53) hide show
  1. package/dist/lib/browser/{chunk-7ONARHVD.mjs → chunk-67FEJJ6J.mjs} +596 -261
  2. package/dist/lib/browser/chunk-67FEJJ6J.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/testing/index.mjs +2 -2
  6. package/dist/lib/browser/testing/index.mjs.map +2 -2
  7. package/dist/lib/node/{chunk-UPLMIG6W.cjs → chunk-2KIDYJ7O.cjs} +686 -351
  8. package/dist/lib/node/chunk-2KIDYJ7O.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +45 -45
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/testing/index.cjs +8 -8
  12. package/dist/lib/node/testing/index.cjs.map +2 -2
  13. package/dist/lib/node-esm/{chunk-DSRREBQH.mjs → chunk-36ZRRDQI.mjs} +596 -261
  14. package/dist/lib/node-esm/chunk-36ZRRDQI.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +1 -1
  16. package/dist/lib/node-esm/meta.json +1 -1
  17. package/dist/lib/node-esm/testing/index.mjs +2 -2
  18. package/dist/lib/node-esm/testing/index.mjs.map +2 -2
  19. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  20. package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
  21. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
  22. package/dist/types/src/packlets/identity/identity.d.ts +1 -0
  23. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  24. package/dist/types/src/packlets/services/service-context.d.ts +4 -2
  25. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  26. package/dist/types/src/packlets/services/service-host.d.ts +1 -0
  27. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  28. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +3 -1
  29. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  30. package/dist/types/src/packlets/spaces/data-space.d.ts +2 -1
  31. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  32. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  33. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +31 -6
  34. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  35. package/dist/types/src/version.d.ts +1 -1
  36. package/dist/types/src/version.d.ts.map +1 -1
  37. package/package.json +38 -38
  38. package/src/packlets/identity/authenticator.ts +5 -2
  39. package/src/packlets/identity/contacts-service.ts +1 -1
  40. package/src/packlets/identity/identity.ts +4 -0
  41. package/src/packlets/services/service-context.ts +41 -17
  42. package/src/packlets/services/service-host.ts +7 -5
  43. package/src/packlets/spaces/data-space-manager.ts +5 -1
  44. package/src/packlets/spaces/data-space.ts +23 -4
  45. package/src/packlets/spaces/edge-feed-replicator.test.ts +12 -15
  46. package/src/packlets/spaces/edge-feed-replicator.ts +11 -3
  47. package/src/packlets/spaces/notarization-plugin.test.ts +8 -4
  48. package/src/packlets/spaces/notarization-plugin.ts +169 -29
  49. package/src/packlets/testing/test-builder.ts +1 -1
  50. package/src/version.ts +1 -1
  51. package/dist/lib/browser/chunk-7ONARHVD.mjs.map +0 -7
  52. package/dist/lib/node/chunk-UPLMIG6W.cjs.map +0 -7
  53. package/dist/lib/node-esm/chunk-DSRREBQH.mjs.map +0 -7
@@ -404,7 +404,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
404
404
  import { TRACE_PROCESSOR } from "@dxos/tracing";
405
405
 
406
406
  // packages/sdk/client-services/src/version.ts
407
- var DXOS_VERSION = "0.6.12-main.f9d0246";
407
+ var DXOS_VERSION = "0.6.12-staging.e11e696";
408
408
 
409
409
  // packages/sdk/client-services/src/packlets/services/platform.ts
410
410
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -755,7 +755,7 @@ var TrustedKeySetAuthVerifier = class {
755
755
  return false;
756
756
  }
757
757
  if (this._isTrustedKey(credential.issuer)) {
758
- log3("key is not currently in trusted set, waiting...", {
758
+ log3("key is trusted -- auth success", {
759
759
  key: credential.issuer
760
760
  }, {
761
761
  F: __dxlog_file5,
@@ -782,7 +782,10 @@ var TrustedKeySetAuthVerifier = class {
782
782
  trigger.wake(true);
783
783
  } else {
784
784
  log3("key is not currently in trusted set, waiting...", {
785
- key: credential.issuer
785
+ key: credential.issuer,
786
+ trusted: [
787
+ ...this._params.trustedKeysProvider()
788
+ ]
786
789
  }, {
787
790
  F: __dxlog_file5,
788
791
  L: 84,
@@ -815,11 +818,17 @@ import { Context as Context3, Resource } from "@dxos/context";
815
818
  import { EdgeConnectionClosedError, EdgeIdentityChangedError } from "@dxos/edge-client";
816
819
  import { invariant as invariant2 } from "@dxos/invariant";
817
820
  import { PublicKey as PublicKey3 } from "@dxos/keys";
818
- import { log as log4 } from "@dxos/log";
821
+ import { log as log4, logInfo } from "@dxos/log";
819
822
  import { EdgeService } from "@dxos/protocols";
820
823
  import { buf } from "@dxos/protocols/buf";
821
824
  import { MessageSchema as RouterMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
822
825
  import { ComplexMap as ComplexMap2, arrayToBuffer, bufferToArray, defaultMap, rangeFromTo } from "@dxos/util";
826
+ function _ts_decorate(decorators, target, key, desc) {
827
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
828
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
829
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
830
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
831
+ }
823
832
  function _using_ctx() {
824
833
  var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
825
834
  var err = new Error();
@@ -901,6 +910,12 @@ var EdgeFeedReplicator = class extends Resource {
901
910
  this._spaceId = spaceId;
902
911
  }
903
912
  async _open() {
913
+ log4("open", void 0, {
914
+ F: __dxlog_file6,
915
+ L: 56,
916
+ S: this,
917
+ C: (f, a) => f(...a)
918
+ });
904
919
  this._ctx.onDispose(this._messenger.addListener((message) => {
905
920
  if (!message.serviceId) {
906
921
  return;
@@ -916,20 +931,20 @@ var EdgeFeedReplicator = class extends Resource {
916
931
  _spaceId: this._spaceId
917
932
  }, {
918
933
  F: __dxlog_file6,
919
- L: 66,
934
+ L: 70,
920
935
  S: this,
921
936
  C: (f, a) => f(...a)
922
937
  });
923
938
  return;
924
939
  }
925
940
  const payload = decodeCbor(message.payload.value);
926
- log4.info("receive", {
941
+ log4("receive", {
927
942
  from: message.source,
928
943
  feedKey: payload.feedKey,
929
944
  type: payload.type
930
945
  }, {
931
946
  F: __dxlog_file6,
932
- L: 71,
947
+ L: 75,
933
948
  S: this,
934
949
  C: (f, a) => f(...a)
935
950
  });
@@ -944,6 +959,12 @@ var EdgeFeedReplicator = class extends Resource {
944
959
  }
945
960
  }
946
961
  async _close() {
962
+ log4("close", void 0, {
963
+ F: __dxlog_file6,
964
+ L: 91,
965
+ S: this,
966
+ C: (f, a) => f(...a)
967
+ });
947
968
  await this._resetConnection();
948
969
  }
949
970
  _startReplication() {
@@ -952,7 +973,7 @@ var EdgeFeedReplicator = class extends Resource {
952
973
  this._connectionCtx = connectionCtx;
953
974
  log4("connection context created", void 0, {
954
975
  F: __dxlog_file6,
955
- L: 94,
976
+ L: 99,
956
977
  S: this,
957
978
  C: (f, a) => f(...a)
958
979
  });
@@ -963,6 +984,12 @@ var EdgeFeedReplicator = class extends Resource {
963
984
  });
964
985
  }
965
986
  async _resetConnection() {
987
+ log4("resetConnection", void 0, {
988
+ F: __dxlog_file6,
989
+ L: 108,
990
+ S: this,
991
+ C: (f, a) => f(...a)
992
+ });
966
993
  this._connected = false;
967
994
  await this._connectionCtx?.dispose();
968
995
  this._connectionCtx = void 0;
@@ -970,10 +997,12 @@ var EdgeFeedReplicator = class extends Resource {
970
997
  }
971
998
  async addFeed(feed) {
972
999
  log4.info("addFeed", {
973
- key: feed.key
1000
+ key: feed.key,
1001
+ connected: this._connected,
1002
+ hasConnectionCtx: !!this._connectionCtx
974
1003
  }, {
975
1004
  F: __dxlog_file6,
976
- L: 110,
1005
+ L: 116,
977
1006
  S: this,
978
1007
  C: (f, a) => f(...a)
979
1008
  });
@@ -986,6 +1015,14 @@ var EdgeFeedReplicator = class extends Resource {
986
1015
  return defaultMap(this._pushMutex, key, () => new Mutex());
987
1016
  }
988
1017
  async _replicateFeed(ctx, feed) {
1018
+ log4("replicateFeed", {
1019
+ key: feed.key
1020
+ }, {
1021
+ F: __dxlog_file6,
1022
+ L: 129,
1023
+ S: this,
1024
+ C: (f, a) => f(...a)
1025
+ });
989
1026
  await this._sendMessage({
990
1027
  type: "get-metadata",
991
1028
  feedKey: feed.key.toHex()
@@ -998,7 +1035,7 @@ var EdgeFeedReplicator = class extends Resource {
998
1035
  if (!this._connectionCtx) {
999
1036
  log4.info("message dropped because connection was disposed", void 0, {
1000
1037
  F: __dxlog_file6,
1001
- L: 135,
1038
+ L: 142,
1002
1039
  S: this,
1003
1040
  C: (f, a) => f(...a)
1004
1041
  });
@@ -1012,13 +1049,13 @@ var EdgeFeedReplicator = class extends Resource {
1012
1049
  };
1013
1050
  log4.info("sending message", logPayload, {
1014
1051
  F: __dxlog_file6,
1015
- L: 141,
1052
+ L: 148,
1016
1053
  S: this,
1017
1054
  C: (f, a) => f(...a)
1018
1055
  });
1019
1056
  invariant2(message.feedKey, void 0, {
1020
1057
  F: __dxlog_file6,
1021
- L: 143,
1058
+ L: 150,
1022
1059
  S: this,
1023
1060
  A: [
1024
1061
  "message.feedKey",
@@ -1026,6 +1063,14 @@ var EdgeFeedReplicator = class extends Resource {
1026
1063
  ]
1027
1064
  });
1028
1065
  const payloadValue = bufferToArray(encodeCbor(message));
1066
+ log4("send", {
1067
+ type: message.type
1068
+ }, {
1069
+ F: __dxlog_file6,
1070
+ L: 153,
1071
+ S: this,
1072
+ C: (f, a) => f(...a)
1073
+ });
1029
1074
  await this._messenger.send(buf.create(RouterMessageSchema, {
1030
1075
  source: {
1031
1076
  identityKey: this._messenger.identityKey,
@@ -1041,7 +1086,7 @@ var EdgeFeedReplicator = class extends Resource {
1041
1086
  if (!this._connectionCtx) {
1042
1087
  log4.warn("received message after connection context was disposed", void 0, {
1043
1088
  F: __dxlog_file6,
1044
- L: 160,
1089
+ L: 168,
1045
1090
  S: this,
1046
1091
  C: (f, a) => f(...a)
1047
1092
  });
@@ -1056,7 +1101,7 @@ var EdgeFeedReplicator = class extends Resource {
1056
1101
  message
1057
1102
  }, {
1058
1103
  F: __dxlog_file6,
1059
- L: 166,
1104
+ L: 174,
1060
1105
  S: this,
1061
1106
  C: (f, a) => f(...a)
1062
1107
  });
@@ -1067,7 +1112,7 @@ var EdgeFeedReplicator = class extends Resource {
1067
1112
  feedKey
1068
1113
  }, {
1069
1114
  F: __dxlog_file6,
1070
- L: 171,
1115
+ L: 179,
1071
1116
  S: this,
1072
1117
  C: (f, a) => f(...a)
1073
1118
  });
@@ -1100,7 +1145,7 @@ var EdgeFeedReplicator = class extends Resource {
1100
1145
  blocks: message.blocks.map((b) => b.index)
1101
1146
  }, {
1102
1147
  F: __dxlog_file6,
1103
- L: 193,
1148
+ L: 201,
1104
1149
  S: this,
1105
1150
  C: (f, a) => f(...a)
1106
1151
  });
@@ -1111,7 +1156,7 @@ var EdgeFeedReplicator = class extends Resource {
1111
1156
  feedKey
1112
1157
  }, {
1113
1158
  F: __dxlog_file6,
1114
- L: 198,
1159
+ L: 206,
1115
1160
  S: this,
1116
1161
  C: (f, a) => f(...a)
1117
1162
  });
@@ -1125,7 +1170,7 @@ var EdgeFeedReplicator = class extends Resource {
1125
1170
  ...message
1126
1171
  }, {
1127
1172
  F: __dxlog_file6,
1128
- L: 207,
1173
+ L: 215,
1129
1174
  S: this,
1130
1175
  C: (f, a) => f(...a)
1131
1176
  });
@@ -1140,7 +1185,7 @@ var EdgeFeedReplicator = class extends Resource {
1140
1185
  to
1141
1186
  }, {
1142
1187
  F: __dxlog_file6,
1143
- L: 214,
1188
+ L: 222,
1144
1189
  S: this,
1145
1190
  C: (f, a) => f(...a)
1146
1191
  });
@@ -1150,7 +1195,7 @@ var EdgeFeedReplicator = class extends Resource {
1150
1195
  });
1151
1196
  invariant2(data instanceof Uint8Array, void 0, {
1152
1197
  F: __dxlog_file6,
1153
- L: 219,
1198
+ L: 227,
1154
1199
  S: this,
1155
1200
  A: [
1156
1201
  "data instanceof Uint8Array",
@@ -1178,7 +1223,7 @@ var EdgeFeedReplicator = class extends Resource {
1178
1223
  blocks: blocks.length
1179
1224
  }, {
1180
1225
  F: __dxlog_file6,
1181
- L: 240,
1226
+ L: 248,
1182
1227
  S: this,
1183
1228
  C: (f, a) => f(...a)
1184
1229
  });
@@ -1200,7 +1245,7 @@ var EdgeFeedReplicator = class extends Resource {
1200
1245
  if (!this._remoteLength.has(feed.key)) {
1201
1246
  log4("blocks not pushed because remote length is unknown", void 0, {
1202
1247
  F: __dxlog_file6,
1203
- L: 261,
1248
+ L: 269,
1204
1249
  S: this,
1205
1250
  C: (f, a) => f(...a)
1206
1251
  });
@@ -1225,7 +1270,7 @@ var EdgeFeedReplicator = class extends Resource {
1225
1270
  if (err instanceof EdgeIdentityChangedError || err instanceof EdgeConnectionClosedError) {
1226
1271
  log4("resetting on reconnect", void 0, {
1227
1272
  F: __dxlog_file6,
1228
- L: 278,
1273
+ L: 286,
1229
1274
  S: this,
1230
1275
  C: (f, a) => f(...a)
1231
1276
  });
@@ -1236,11 +1281,14 @@ var EdgeFeedReplicator = class extends Resource {
1236
1281
  }
1237
1282
  }, {
1238
1283
  F: __dxlog_file6,
1239
- L: 272
1284
+ L: 280
1240
1285
  });
1241
1286
  return connectionCtx;
1242
1287
  }
1243
1288
  };
1289
+ _ts_decorate([
1290
+ logInfo
1291
+ ], EdgeFeedReplicator.prototype, "_spaceId", void 0);
1244
1292
  var bufferizeBlock = (block) => ({
1245
1293
  index: block.index,
1246
1294
  data: arrayToBuffer(block.data),
@@ -1255,7 +1303,7 @@ var bufferizeBlock = (block) => ({
1255
1303
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
1256
1304
  import { Event as Event7, Mutex as Mutex2, scheduleTask as scheduleTask4, sleep as sleep3, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
1257
1305
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
1258
- import { Context as Context6, ContextDisposedError, cancelWithContext as cancelWithContext2 } from "@dxos/context";
1306
+ import { Context as Context5, ContextDisposedError, cancelWithContext as cancelWithContext2 } from "@dxos/context";
1259
1307
  import { timed, warnAfterTimeout } from "@dxos/debug";
1260
1308
  import { createMappedFeedWriter } from "@dxos/echo-pipeline";
1261
1309
  import { SpaceDocVersion as SpaceDocVersion3 } from "@dxos/echo-protocol";
@@ -1490,53 +1538,67 @@ var runEpochMigration = async (ctx, context) => {
1490
1538
  };
1491
1539
 
1492
1540
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
1493
- import { DeferredTask, Event as Event3, scheduleTask as scheduleTask2, sleep, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
1494
- import { Context as Context4, rejectOnDispose } from "@dxos/context";
1541
+ import { DeferredTask, Event as Event3, scheduleTask as scheduleTask2, sleep, TimeoutError, Trigger as Trigger3, scheduleMicroTask as scheduleMicroTask2 } from "@dxos/async";
1542
+ import { rejectOnDispose, Resource as Resource3 } from "@dxos/context";
1543
+ import { verifyCredential as verifyCredential2 } from "@dxos/credentials";
1495
1544
  import { invariant as invariant4 } from "@dxos/invariant";
1496
1545
  import { PublicKey as PublicKey4 } from "@dxos/keys";
1497
- import { log as log6 } from "@dxos/log";
1546
+ import { logInfo as logInfo2, log as log6 } from "@dxos/log";
1547
+ import { EdgeCallFailedError } from "@dxos/protocols";
1498
1548
  import { schema as schema2 } from "@dxos/protocols/proto";
1499
1549
  import { RpcExtension } from "@dxos/teleport";
1500
1550
  import { ComplexMap as ComplexMap3, ComplexSet, entry } from "@dxos/util";
1551
+ function _ts_decorate2(decorators, target, key, desc) {
1552
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1553
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1554
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1555
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1556
+ }
1501
1557
  var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
1502
1558
  var DEFAULT_RETRY_TIMEOUT = 1e3;
1503
1559
  var DEFAULT_SUCCESS_DELAY = 1e3;
1504
1560
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
1561
+ var MAX_EDGE_RETRIES = 2;
1505
1562
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
1506
- var NotarizationPlugin = class {
1507
- constructor() {
1508
- this._ctx = new Context4(void 0, {
1509
- F: __dxlog_file8,
1510
- L: 62
1511
- });
1563
+ var credentialCodec = schema2.getCodecForType("dxos.halo.credentials.Credential");
1564
+ var NotarizationPlugin = class extends Resource3 {
1565
+ constructor(params) {
1566
+ super();
1512
1567
  this._extensionOpened = new Event3();
1513
1568
  this._extensions = /* @__PURE__ */ new Set();
1514
1569
  this._processedCredentials = new ComplexSet(PublicKey4.hash);
1515
1570
  this._processCredentialsTriggers = new ComplexMap3(PublicKey4.hash);
1571
+ this._spaceId = params.spaceId;
1572
+ if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
1573
+ this._edgeClient = params.edgeClient;
1574
+ }
1516
1575
  }
1517
1576
  get hasWriter() {
1518
1577
  return !!this._writer;
1519
1578
  }
1520
- async open() {
1579
+ async _open() {
1580
+ if (this._edgeClient && this._writer) {
1581
+ this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1582
+ }
1521
1583
  }
1522
- async close() {
1584
+ async _close() {
1523
1585
  await this._ctx.dispose();
1524
1586
  }
1525
1587
  /**
1526
1588
  * Request credentials to be notarized.
1527
1589
  */
1528
- async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
1590
+ async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY, edgeRetryJitter }) {
1529
1591
  log6("notarize", {
1530
1592
  credentials
1531
1593
  }, {
1532
1594
  F: __dxlog_file8,
1533
- L: 90,
1595
+ L: 126,
1534
1596
  S: this,
1535
1597
  C: (f, a) => f(...a)
1536
1598
  });
1537
1599
  invariant4(credentials.every((credential) => credential.id), "Credentials must have an id", {
1538
1600
  F: __dxlog_file8,
1539
- L: 91,
1601
+ L: 127,
1540
1602
  S: this,
1541
1603
  A: [
1542
1604
  "credentials.every((credential) => credential.id)",
@@ -1550,7 +1612,7 @@ var NotarizationPlugin = class {
1550
1612
  err
1551
1613
  }, {
1552
1614
  F: __dxlog_file8,
1553
- L: 99,
1615
+ L: 135,
1554
1616
  S: this,
1555
1617
  C: (f, a) => f(...a)
1556
1618
  });
@@ -1560,21 +1622,37 @@ var NotarizationPlugin = class {
1560
1622
  });
1561
1623
  opCtx?.onDispose(() => ctx.dispose());
1562
1624
  if (timeout !== 0) {
1563
- scheduleTask2(ctx, () => {
1564
- log6.warn("Notarization timeout", {
1565
- timeout,
1566
- peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1567
- }, {
1568
- F: __dxlog_file8,
1569
- L: 111,
1570
- S: this,
1571
- C: (f, a) => f(...a)
1572
- });
1573
- void ctx.dispose();
1574
- errors.throw(new TimeoutError(timeout, "Notarization timed out"));
1575
- }, timeout);
1625
+ this._scheduleTimeout(ctx, errors, timeout);
1576
1626
  }
1577
1627
  const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
1628
+ this._tryNotarizeCredentialsWithPeers(ctx, credentials, {
1629
+ retryTimeout,
1630
+ successDelay
1631
+ });
1632
+ if (this._edgeClient) {
1633
+ this._tryNotarizeCredentialsWithEdge(ctx, this._edgeClient, credentials, {
1634
+ retryTimeout,
1635
+ successDelay,
1636
+ jitter: edgeRetryJitter
1637
+ });
1638
+ }
1639
+ try {
1640
+ await Promise.race([
1641
+ rejectOnDispose(ctx),
1642
+ allNotarized,
1643
+ errors.wait()
1644
+ ]);
1645
+ log6("done", void 0, {
1646
+ F: __dxlog_file8,
1647
+ L: 160,
1648
+ S: this,
1649
+ C: (f, a) => f(...a)
1650
+ });
1651
+ } finally {
1652
+ await ctx.dispose();
1653
+ }
1654
+ }
1655
+ _tryNotarizeCredentialsWithPeers(ctx, credentials, { retryTimeout, successDelay }) {
1578
1656
  const peersTried = /* @__PURE__ */ new Set();
1579
1657
  const notarizeTask = new DeferredTask(ctx, async () => {
1580
1658
  try {
@@ -1589,7 +1667,7 @@ var NotarizationPlugin = class {
1589
1667
  retryIn: retryTimeout
1590
1668
  }, {
1591
1669
  F: __dxlog_file8,
1592
- L: 136,
1670
+ L: 183,
1593
1671
  S: this,
1594
1672
  C: (f, a) => f(...a)
1595
1673
  });
@@ -1603,7 +1681,7 @@ var NotarizationPlugin = class {
1603
1681
  credentialId: credentials.map((credential) => credential.id)
1604
1682
  }, {
1605
1683
  F: __dxlog_file8,
1606
- L: 143,
1684
+ L: 190,
1607
1685
  S: this,
1608
1686
  C: (f, a) => f(...a)
1609
1687
  });
@@ -1612,7 +1690,7 @@ var NotarizationPlugin = class {
1612
1690
  });
1613
1691
  log6("success", void 0, {
1614
1692
  F: __dxlog_file8,
1615
- L: 147,
1693
+ L: 194,
1616
1694
  S: this,
1617
1695
  C: (f, a) => f(...a)
1618
1696
  });
@@ -1621,7 +1699,7 @@ var NotarizationPlugin = class {
1621
1699
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
1622
1700
  log6.info("error notarizing (recoverable)", err, {
1623
1701
  F: __dxlog_file8,
1624
- L: 151,
1702
+ L: 199,
1625
1703
  S: this,
1626
1704
  C: (f, a) => f(...a)
1627
1705
  });
@@ -1631,21 +1709,33 @@ var NotarizationPlugin = class {
1631
1709
  });
1632
1710
  notarizeTask.schedule();
1633
1711
  this._extensionOpened.on(ctx, () => notarizeTask.schedule());
1634
- try {
1635
- await Promise.race([
1636
- rejectOnDispose(ctx),
1637
- allNotarized,
1638
- errors.wait()
1639
- ]);
1640
- log6("done", void 0, {
1641
- F: __dxlog_file8,
1642
- L: 162,
1643
- S: this,
1644
- C: (f, a) => f(...a)
1645
- });
1646
- } finally {
1647
- await ctx.dispose();
1648
- }
1712
+ }
1713
+ _tryNotarizeCredentialsWithEdge(ctx, client, credentials, timeouts) {
1714
+ const encodedCredentials = credentials.map((credential) => {
1715
+ const binary = credentialCodec.encode(credential);
1716
+ return Buffer.from(binary).toString("base64");
1717
+ });
1718
+ scheduleTask2(ctx, async () => {
1719
+ try {
1720
+ await client.notarizeCredentials(this._spaceId, {
1721
+ credentials: encodedCredentials
1722
+ }, {
1723
+ retry: {
1724
+ count: MAX_EDGE_RETRIES,
1725
+ timeout: timeouts.retryTimeout,
1726
+ jitter: timeouts.jitter
1727
+ }
1728
+ });
1729
+ log6("edge notarization success", void 0, {
1730
+ F: __dxlog_file8,
1731
+ L: 227,
1732
+ S: this,
1733
+ C: (f, a) => f(...a)
1734
+ });
1735
+ } catch (error) {
1736
+ handleEdgeError(error);
1737
+ }
1738
+ });
1649
1739
  }
1650
1740
  /**
1651
1741
  * Called with credentials arriving from the control pipeline.
@@ -1661,7 +1751,7 @@ var NotarizationPlugin = class {
1661
1751
  setWriter(writer) {
1662
1752
  invariant4(!this._writer, "Writer already set.", {
1663
1753
  F: __dxlog_file8,
1664
- L: 181,
1754
+ L: 247,
1665
1755
  S: this,
1666
1756
  A: [
1667
1757
  "!this._writer",
@@ -1669,6 +1759,59 @@ var NotarizationPlugin = class {
1669
1759
  ]
1670
1760
  });
1671
1761
  this._writer = writer;
1762
+ if (this._edgeClient) {
1763
+ this._notarizePendingEdgeCredentials(this._edgeClient, writer);
1764
+ }
1765
+ }
1766
+ /**
1767
+ * The method is used only for adding agent feeds to spaces.
1768
+ * When an agent is created we can admit them into all the existing spaces. In case the operation fails
1769
+ * this method will fix it on the next space open.
1770
+ * Given how rarely this happens there's no need to poll the endpoint.
1771
+ */
1772
+ _notarizePendingEdgeCredentials(client, writer) {
1773
+ scheduleMicroTask2(this._ctx, async () => {
1774
+ try {
1775
+ const response = await client.getCredentialsForNotarization(this._spaceId, {
1776
+ retry: {
1777
+ count: MAX_EDGE_RETRIES
1778
+ }
1779
+ });
1780
+ const credentials = response.awaitingNotarization.credentials;
1781
+ if (!credentials.length) {
1782
+ log6("edge did not return credentials for notarization", void 0, {
1783
+ F: __dxlog_file8,
1784
+ L: 269,
1785
+ S: this,
1786
+ C: (f, a) => f(...a)
1787
+ });
1788
+ return;
1789
+ }
1790
+ log6("got edge credentials for notarization", {
1791
+ count: credentials.length
1792
+ }, {
1793
+ F: __dxlog_file8,
1794
+ L: 273,
1795
+ S: this,
1796
+ C: (f, a) => f(...a)
1797
+ });
1798
+ const decodedCredentials = credentials.map((credential) => {
1799
+ const binary = Buffer.from(credential, "base64");
1800
+ return credentialCodec.decode(binary);
1801
+ });
1802
+ await this._notarizeCredentials(writer, decodedCredentials);
1803
+ log6.info("notarized edge credentials", {
1804
+ count: decodedCredentials.length
1805
+ }, {
1806
+ F: __dxlog_file8,
1807
+ L: 282,
1808
+ S: this,
1809
+ C: (f, a) => f(...a)
1810
+ });
1811
+ } catch (error) {
1812
+ handleEdgeError(error);
1813
+ }
1814
+ });
1672
1815
  }
1673
1816
  async _waitUntilProcessed(id) {
1674
1817
  if (this._processedCredentials.has(id)) {
@@ -1683,10 +1826,13 @@ var NotarizationPlugin = class {
1683
1826
  if (!this._writer) {
1684
1827
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
1685
1828
  }
1686
- for (const credential of request.credentials ?? []) {
1829
+ await this._notarizeCredentials(this._writer, request.credentials ?? []);
1830
+ }
1831
+ async _notarizeCredentials(writer, credentials) {
1832
+ for (const credential of credentials) {
1687
1833
  invariant4(credential.id, "Credential must have an id", {
1688
1834
  F: __dxlog_file8,
1689
- L: 200,
1835
+ L: 308,
1690
1836
  S: this,
1691
1837
  A: [
1692
1838
  "credential.id",
@@ -1696,7 +1842,11 @@ var NotarizationPlugin = class {
1696
1842
  if (this._processedCredentials.has(credential.id)) {
1697
1843
  continue;
1698
1844
  }
1699
- await this._writer.write(credential);
1845
+ const verificationResult = await verifyCredential2(credential);
1846
+ if (verificationResult.kind === "fail") {
1847
+ throw new Error(`Credential verification failed: ${verificationResult.errors.join("\n")}.`);
1848
+ }
1849
+ await writer.write(credential);
1700
1850
  }
1701
1851
  }
1702
1852
  createExtension() {
@@ -1706,7 +1856,7 @@ var NotarizationPlugin = class {
1706
1856
  peer: extension.localPeerId
1707
1857
  }, {
1708
1858
  F: __dxlog_file8,
1709
- L: 211,
1859
+ L: 323,
1710
1860
  S: this,
1711
1861
  C: (f, a) => f(...a)
1712
1862
  });
@@ -1718,7 +1868,7 @@ var NotarizationPlugin = class {
1718
1868
  peer: extension.localPeerId
1719
1869
  }, {
1720
1870
  F: __dxlog_file8,
1721
- L: 216,
1871
+ L: 328,
1722
1872
  S: this,
1723
1873
  C: (f, a) => f(...a)
1724
1874
  });
@@ -1728,6 +1878,43 @@ var NotarizationPlugin = class {
1728
1878
  });
1729
1879
  return extension;
1730
1880
  }
1881
+ _scheduleTimeout(ctx, errors, timeout) {
1882
+ scheduleTask2(ctx, () => {
1883
+ log6.warn("Notarization timeout", {
1884
+ timeout,
1885
+ peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1886
+ }, {
1887
+ F: __dxlog_file8,
1888
+ L: 340,
1889
+ S: this,
1890
+ C: (f, a) => f(...a)
1891
+ });
1892
+ void ctx.dispose();
1893
+ errors.throw(new TimeoutError(timeout, "Notarization timed out"));
1894
+ }, timeout);
1895
+ }
1896
+ };
1897
+ _ts_decorate2([
1898
+ logInfo2
1899
+ ], NotarizationPlugin.prototype, "_spaceId", void 0);
1900
+ var handleEdgeError = (error) => {
1901
+ if (!(error instanceof EdgeCallFailedError) || error.errorData) {
1902
+ log6.catch(error, void 0, {
1903
+ F: __dxlog_file8,
1904
+ L: 354,
1905
+ S: void 0,
1906
+ C: (f, a) => f(...a)
1907
+ });
1908
+ } else {
1909
+ log6.info("Edge notarization failure", {
1910
+ reason: error.reason
1911
+ }, {
1912
+ F: __dxlog_file8,
1913
+ L: 356,
1914
+ S: void 0,
1915
+ C: (f, a) => f(...a)
1916
+ });
1917
+ }
1731
1918
  };
1732
1919
  var NotarizationTeleportExtension = class extends RpcExtension {
1733
1920
  constructor(_params) {
@@ -1822,7 +2009,7 @@ var DefaultSpaceStateMachine = class {
1822
2009
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
1823
2010
  import { Event as Event4, synchronized, trackLeaks } from "@dxos/async";
1824
2011
  import { PropertiesType } from "@dxos/client-protocol";
1825
- import { LifecycleState, Resource as Resource3, cancelWithContext } from "@dxos/context";
2012
+ import { LifecycleState, Resource as Resource4, cancelWithContext } from "@dxos/context";
1826
2013
  import { createAdmissionCredentials, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
1827
2014
  import { convertLegacyReferences as convertLegacyReferences2, findInlineObjectOfType as findInlineObjectOfType2, AuthStatus, CredentialServerExtension } from "@dxos/echo-pipeline";
1828
2015
  import { LEGACY_TYPE_PROPERTIES, SpaceDocVersion as SpaceDocVersion2, encodeReference } from "@dxos/echo-protocol";
@@ -1909,7 +2096,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1909
2096
  };
1910
2097
 
1911
2098
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
1912
- function _ts_decorate(decorators, target, key, desc) {
2099
+ function _ts_decorate3(decorators, target, key, desc) {
1913
2100
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1914
2101
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1915
2102
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -1919,13 +2106,14 @@ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
1919
2106
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
1920
2107
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
1921
2108
  var DEFAULT_SPACE_KEY = "__DEFAULT__";
1922
- var DataSpaceManager = class extends Resource3 {
2109
+ var DataSpaceManager = class extends Resource4 {
1923
2110
  constructor(params) {
1924
2111
  super();
1925
2112
  this.updated = new Event4();
1926
2113
  this._spaces = new ComplexMap4(PublicKey5.hash);
1927
2114
  this._instanceId = PublicKey5.random().toHex();
1928
2115
  this._edgeConnection = void 0;
2116
+ this._edgeHttpClient = void 0;
1929
2117
  this._edgeFeatures = void 0;
1930
2118
  this._meshReplicator = void 0;
1931
2119
  this._echoEdgeReplicator = void 0;
@@ -1941,6 +2129,7 @@ var DataSpaceManager = class extends Resource3 {
1941
2129
  this._edgeConnection = params.edgeConnection;
1942
2130
  this._edgeFeatures = params.edgeFeatures;
1943
2131
  this._echoEdgeReplicator = params.echoEdgeReplicator;
2132
+ this._edgeHttpClient = params.edgeHttpClient;
1944
2133
  this._runtimeParams = params.runtimeParams;
1945
2134
  trace.diagnostic({
1946
2135
  id: "spaces",
@@ -1972,7 +2161,7 @@ var DataSpaceManager = class extends Resource3 {
1972
2161
  async _open() {
1973
2162
  log8("open", void 0, {
1974
2163
  F: __dxlog_file10,
1975
- L: 195,
2164
+ L: 198,
1976
2165
  S: this,
1977
2166
  C: (f, a) => f(...a)
1978
2167
  });
@@ -1980,7 +2169,7 @@ var DataSpaceManager = class extends Resource3 {
1980
2169
  id: this._instanceId
1981
2170
  }), {
1982
2171
  F: __dxlog_file10,
1983
- L: 196,
2172
+ L: 199,
1984
2173
  S: this,
1985
2174
  C: (f, a) => f(...a)
1986
2175
  });
@@ -1988,7 +2177,7 @@ var DataSpaceManager = class extends Resource3 {
1988
2177
  spaces: this._metadataStore.spaces.length
1989
2178
  }, {
1990
2179
  F: __dxlog_file10,
1991
- L: 197,
2180
+ L: 200,
1992
2181
  S: this,
1993
2182
  C: (f, a) => f(...a)
1994
2183
  });
@@ -1998,7 +2187,7 @@ var DataSpaceManager = class extends Resource3 {
1998
2187
  spaceMetadata
1999
2188
  }, {
2000
2189
  F: __dxlog_file10,
2001
- L: 201,
2190
+ L: 204,
2002
2191
  S: this,
2003
2192
  C: (f, a) => f(...a)
2004
2193
  });
@@ -2009,7 +2198,7 @@ var DataSpaceManager = class extends Resource3 {
2009
2198
  err
2010
2199
  }, {
2011
2200
  F: __dxlog_file10,
2012
- L: 204,
2201
+ L: 207,
2013
2202
  S: this,
2014
2203
  C: (f, a) => f(...a)
2015
2204
  });
@@ -2020,7 +2209,7 @@ var DataSpaceManager = class extends Resource3 {
2020
2209
  id: this._instanceId
2021
2210
  }), {
2022
2211
  F: __dxlog_file10,
2023
- L: 210,
2212
+ L: 213,
2024
2213
  S: this,
2025
2214
  C: (f, a) => f(...a)
2026
2215
  });
@@ -2028,7 +2217,7 @@ var DataSpaceManager = class extends Resource3 {
2028
2217
  async _close() {
2029
2218
  log8("close", void 0, {
2030
2219
  F: __dxlog_file10,
2031
- L: 215,
2220
+ L: 218,
2032
2221
  S: this,
2033
2222
  C: (f, a) => f(...a)
2034
2223
  });
@@ -2043,7 +2232,7 @@ var DataSpaceManager = class extends Resource3 {
2043
2232
  async createSpace() {
2044
2233
  invariant5(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
2045
2234
  F: __dxlog_file10,
2046
- L: 227,
2235
+ L: 230,
2047
2236
  S: this,
2048
2237
  A: [
2049
2238
  "this._lifecycleState === LifecycleState.OPEN",
@@ -2064,7 +2253,7 @@ var DataSpaceManager = class extends Resource3 {
2064
2253
  spaceKey
2065
2254
  }, {
2066
2255
  F: __dxlog_file10,
2067
- L: 239,
2256
+ L: 242,
2068
2257
  S: this,
2069
2258
  C: (f, a) => f(...a)
2070
2259
  });
@@ -2076,7 +2265,7 @@ var DataSpaceManager = class extends Resource3 {
2076
2265
  const memberCredential = credentials[1];
2077
2266
  invariant5(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2078
2267
  F: __dxlog_file10,
2079
- L: 249,
2268
+ L: 252,
2080
2269
  S: this,
2081
2270
  A: [
2082
2271
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2108,7 +2297,7 @@ var DataSpaceManager = class extends Resource3 {
2108
2297
  spaceId: space.id
2109
2298
  }, {
2110
2299
  F: __dxlog_file10,
2111
- L: 274,
2300
+ L: 277,
2112
2301
  S: this,
2113
2302
  C: (f, a) => f(...a)
2114
2303
  });
@@ -2143,7 +2332,7 @@ var DataSpaceManager = class extends Resource3 {
2143
2332
  const automergeIndex = space.automergeSpaceState.rootUrl;
2144
2333
  invariant5(automergeIndex, void 0, {
2145
2334
  F: __dxlog_file10,
2146
- L: 307,
2335
+ L: 310,
2147
2336
  S: this,
2148
2337
  A: [
2149
2338
  "automergeIndex",
@@ -2160,13 +2349,13 @@ var DataSpaceManager = class extends Resource3 {
2160
2349
  opts
2161
2350
  }, {
2162
2351
  F: __dxlog_file10,
2163
- L: 316,
2352
+ L: 319,
2164
2353
  S: this,
2165
2354
  C: (f, a) => f(...a)
2166
2355
  });
2167
2356
  invariant5(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
2168
2357
  F: __dxlog_file10,
2169
- L: 317,
2358
+ L: 320,
2170
2359
  S: this,
2171
2360
  A: [
2172
2361
  "this._lifecycleState === LifecycleState.OPEN",
@@ -2175,7 +2364,7 @@ var DataSpaceManager = class extends Resource3 {
2175
2364
  });
2176
2365
  invariant5(!this._spaces.has(opts.spaceKey), "Space already exists.", {
2177
2366
  F: __dxlog_file10,
2178
- L: 318,
2367
+ L: 321,
2179
2368
  S: this,
2180
2369
  A: [
2181
2370
  "!this._spaces.has(opts.spaceKey)",
@@ -2199,7 +2388,7 @@ var DataSpaceManager = class extends Resource3 {
2199
2388
  const space = this._spaceManager.spaces.get(options.spaceKey);
2200
2389
  invariant5(space, void 0, {
2201
2390
  F: __dxlog_file10,
2202
- L: 338,
2391
+ L: 341,
2203
2392
  S: this,
2204
2393
  A: [
2205
2394
  "space",
@@ -2212,7 +2401,7 @@ var DataSpaceManager = class extends Resource3 {
2212
2401
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
2213
2402
  invariant5(credentials[0].credential, void 0, {
2214
2403
  F: __dxlog_file10,
2215
- L: 357,
2404
+ L: 360,
2216
2405
  S: this,
2217
2406
  A: [
2218
2407
  "credentials[0].credential",
@@ -2222,7 +2411,7 @@ var DataSpaceManager = class extends Resource3 {
2222
2411
  const spaceMemberCredential = credentials[0].credential.credential;
2223
2412
  invariant5(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2224
2413
  F: __dxlog_file10,
2225
- L: 359,
2414
+ L: 362,
2226
2415
  S: this,
2227
2416
  A: [
2228
2417
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2261,7 +2450,7 @@ var DataSpaceManager = class extends Resource3 {
2261
2450
  metadata
2262
2451
  }, {
2263
2452
  F: __dxlog_file10,
2264
- L: 395,
2453
+ L: 398,
2265
2454
  S: this,
2266
2455
  C: (f, a) => f(...a)
2267
2456
  });
@@ -2305,7 +2494,7 @@ var DataSpaceManager = class extends Resource3 {
2305
2494
  err
2306
2495
  }, {
2307
2496
  F: __dxlog_file10,
2308
- L: 437,
2497
+ L: 440,
2309
2498
  S: this,
2310
2499
  C: (f, a) => f(...a)
2311
2500
  });
@@ -2315,7 +2504,7 @@ var DataSpaceManager = class extends Resource3 {
2315
2504
  onAuthFailure: () => {
2316
2505
  log8.warn("auth failure", void 0, {
2317
2506
  F: __dxlog_file10,
2318
- L: 442,
2507
+ L: 445,
2319
2508
  S: this,
2320
2509
  C: (f, a) => f(...a)
2321
2510
  });
@@ -2348,7 +2537,7 @@ var DataSpaceManager = class extends Resource3 {
2348
2537
  space: space.key
2349
2538
  }, {
2350
2539
  F: __dxlog_file10,
2351
- L: 469,
2540
+ L: 472,
2352
2541
  S: this,
2353
2542
  C: (f, a) => f(...a)
2354
2543
  });
@@ -2359,7 +2548,7 @@ var DataSpaceManager = class extends Resource3 {
2359
2548
  open: this._lifecycleState === LifecycleState.OPEN
2360
2549
  }, {
2361
2550
  F: __dxlog_file10,
2362
- L: 472,
2551
+ L: 475,
2363
2552
  S: this,
2364
2553
  C: (f, a) => f(...a)
2365
2554
  });
@@ -2378,7 +2567,7 @@ var DataSpaceManager = class extends Resource3 {
2378
2567
  space: space.key
2379
2568
  }, {
2380
2569
  F: __dxlog_file10,
2381
- L: 480,
2570
+ L: 483,
2382
2571
  S: this,
2383
2572
  C: (f, a) => f(...a)
2384
2573
  });
@@ -2386,6 +2575,7 @@ var DataSpaceManager = class extends Resource3 {
2386
2575
  },
2387
2576
  cache: metadata.cache,
2388
2577
  edgeConnection: this._edgeConnection,
2578
+ edgeHttpClient: this._edgeHttpClient,
2389
2579
  edgeFeatures: this._edgeFeatures
2390
2580
  });
2391
2581
  dataSpace.postOpen.append(async () => {
@@ -2412,7 +2602,7 @@ var DataSpaceManager = class extends Resource3 {
2412
2602
  space: space.key
2413
2603
  }, {
2414
2604
  F: __dxlog_file10,
2415
- L: 511,
2605
+ L: 515,
2416
2606
  S: this,
2417
2607
  C: (f, a) => f(...a)
2418
2608
  });
@@ -2445,7 +2635,7 @@ var DataSpaceManager = class extends Resource3 {
2445
2635
  closedSessions
2446
2636
  }, {
2447
2637
  F: __dxlog_file10,
2448
- L: 537,
2638
+ L: 541,
2449
2639
  S: this,
2450
2640
  C: (f, a) => f(...a)
2451
2641
  });
@@ -2460,7 +2650,7 @@ var DataSpaceManager = class extends Resource3 {
2460
2650
  peerId: peerState.peerId
2461
2651
  }, {
2462
2652
  F: __dxlog_file10,
2463
- L: 551,
2653
+ L: 555,
2464
2654
  S: this,
2465
2655
  C: (f, a) => f(...a)
2466
2656
  });
@@ -2504,19 +2694,19 @@ var DataSpaceManager = class extends Resource3 {
2504
2694
  await Promise.all(tasks);
2505
2695
  }
2506
2696
  };
2507
- _ts_decorate([
2697
+ _ts_decorate3([
2508
2698
  synchronized
2509
2699
  ], DataSpaceManager.prototype, "_open", null);
2510
- _ts_decorate([
2700
+ _ts_decorate3([
2511
2701
  synchronized
2512
2702
  ], DataSpaceManager.prototype, "_close", null);
2513
- _ts_decorate([
2703
+ _ts_decorate3([
2514
2704
  synchronized
2515
2705
  ], DataSpaceManager.prototype, "createSpace", null);
2516
- _ts_decorate([
2706
+ _ts_decorate3([
2517
2707
  synchronized
2518
2708
  ], DataSpaceManager.prototype, "acceptSpace", null);
2519
- DataSpaceManager = _ts_decorate([
2709
+ DataSpaceManager = _ts_decorate3([
2520
2710
  trackLeaks("open", "close")
2521
2711
  ], DataSpaceManager);
2522
2712
 
@@ -2861,7 +3051,7 @@ var SpacesServiceImpl = class {
2861
3051
  var getChannelId = (channel) => `user-channel/${channel}`;
2862
3052
 
2863
3053
  // packages/sdk/client-services/src/packlets/identity/identity.ts
2864
- function _ts_decorate2(decorators, target, key, desc) {
3054
+ function _ts_decorate4(decorators, target, key, desc) {
2865
3055
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2866
3056
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2867
3057
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -2970,6 +3160,9 @@ var Identity = class {
2970
3160
  get presence() {
2971
3161
  return this._presence;
2972
3162
  }
3163
+ get signer() {
3164
+ return this._signer;
3165
+ }
2973
3166
  /**
2974
3167
  * Issues credentials as identity.
2975
3168
  * Requires identity to be ready.
@@ -2977,7 +3170,7 @@ var Identity = class {
2977
3170
  getIdentityCredentialSigner() {
2978
3171
  invariant7(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
2979
3172
  F: __dxlog_file12,
2980
- L: 185,
3173
+ L: 189,
2981
3174
  S: this,
2982
3175
  A: [
2983
3176
  "this._deviceStateMachine.deviceCredentialChain",
@@ -3021,7 +3214,7 @@ var Identity = class {
3021
3214
  dataFeedKey
3022
3215
  }, {
3023
3216
  F: __dxlog_file12,
3024
- L: 210,
3217
+ L: 214,
3025
3218
  S: this,
3026
3219
  C: (f, a) => f(...a)
3027
3220
  });
@@ -3062,20 +3255,20 @@ var Identity = class {
3062
3255
  })));
3063
3256
  }
3064
3257
  };
3065
- _ts_decorate2([
3258
+ _ts_decorate4([
3066
3259
  trace3.span()
3067
3260
  ], Identity.prototype, "open", null);
3068
- _ts_decorate2([
3261
+ _ts_decorate4([
3069
3262
  trace3.span()
3070
3263
  ], Identity.prototype, "close", null);
3071
- Identity = _ts_decorate2([
3264
+ Identity = _ts_decorate4([
3072
3265
  trace3.resource()
3073
3266
  ], Identity);
3074
3267
 
3075
3268
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
3076
3269
  import platform from "platform";
3077
3270
  import { Event as Event6 } from "@dxos/async";
3078
- import { Context as Context5 } from "@dxos/context";
3271
+ import { Context as Context4 } from "@dxos/context";
3079
3272
  import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
3080
3273
  import { invariant as invariant8 } from "@dxos/invariant";
3081
3274
  import { PublicKey as PublicKey7 } from "@dxos/keys";
@@ -3087,7 +3280,7 @@ import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extensi
3087
3280
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
3088
3281
  import { trace as Trace2 } from "@dxos/tracing";
3089
3282
  import { isNode, deferFunction as deferFunction2 } from "@dxos/util";
3090
- function _ts_decorate3(decorators, target, key, desc) {
3283
+ function _ts_decorate5(decorators, target, key, desc) {
3091
3284
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3092
3285
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3093
3286
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -3157,7 +3350,7 @@ var IdentityManager = class {
3157
3350
  });
3158
3351
  }
3159
3352
  async close() {
3160
- await this._identity?.close(new Context5(void 0, {
3353
+ await this._identity?.close(new Context4(void 0, {
3161
3354
  F: __dxlog_file13,
3162
3355
  L: 140
3163
3356
  }));
@@ -3190,7 +3383,7 @@ var IdentityManager = class {
3190
3383
  }
3191
3384
  };
3192
3385
  const identity = await this._constructIdentity(identityRecord);
3193
- await identity.open(new Context5(void 0, {
3386
+ await identity.open(new Context4(void 0, {
3194
3387
  F: __dxlog_file13,
3195
3388
  L: 161
3196
3389
  }));
@@ -3319,7 +3512,7 @@ var IdentityManager = class {
3319
3512
  }
3320
3513
  };
3321
3514
  const identity = await this._constructIdentity(identityRecord);
3322
- await identity.open(new Context5(void 0, {
3515
+ await identity.open(new Context4(void 0, {
3323
3516
  F: __dxlog_file13,
3324
3517
  L: 268
3325
3518
  }));
@@ -3538,19 +3731,19 @@ var IdentityManager = class {
3538
3731
  });
3539
3732
  }
3540
3733
  };
3541
- _ts_decorate3([
3734
+ _ts_decorate5([
3542
3735
  Trace2.span({
3543
3736
  showInBrowserTimeline: true
3544
3737
  })
3545
3738
  ], IdentityManager.prototype, "open", null);
3546
- IdentityManager = _ts_decorate3([
3739
+ IdentityManager = _ts_decorate5([
3547
3740
  Trace2.resource()
3548
3741
  ], IdentityManager);
3549
3742
 
3550
3743
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
3551
3744
  import { Trigger as Trigger4, sleep as sleep2 } from "@dxos/async";
3552
3745
  import { Stream as Stream8 } from "@dxos/codec-protobuf";
3553
- import { Resource as Resource4 } from "@dxos/context";
3746
+ import { Resource as Resource5 } from "@dxos/context";
3554
3747
  import { signPresentation } from "@dxos/credentials";
3555
3748
  import { todo } from "@dxos/debug";
3556
3749
  import { invariant as invariant9 } from "@dxos/invariant";
@@ -3559,7 +3752,7 @@ import { SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/ser
3559
3752
  import { safeAwaitAll } from "@dxos/util";
3560
3753
  var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
3561
3754
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
3562
- var IdentityServiceImpl = class extends Resource4 {
3755
+ var IdentityServiceImpl = class extends Resource5 {
3563
3756
  constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
3564
3757
  super();
3565
3758
  this._identityManager = _identityManager;
@@ -3703,7 +3896,7 @@ var IdentityServiceImpl = class extends Resource4 {
3703
3896
  };
3704
3897
 
3705
3898
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
3706
- function _ts_decorate4(decorators, target, key, desc) {
3899
+ function _ts_decorate6(decorators, target, key, desc) {
3707
3900
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3708
3901
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3709
3902
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -3774,11 +3967,10 @@ function _using_ctx2() {
3774
3967
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3775
3968
  var DataSpace = class {
3776
3969
  constructor(params) {
3777
- this._ctx = new Context6(void 0, {
3970
+ this._ctx = new Context5(void 0, {
3778
3971
  F: __dxlog_file15,
3779
- L: 94
3972
+ L: 95
3780
3973
  });
3781
- this._notarizationPlugin = new NotarizationPlugin();
3782
3974
  this._cache = void 0;
3783
3975
  this._edgeFeedReplicator = void 0;
3784
3976
  // TODO(dmaretskyi): Move into Space?
@@ -3807,6 +3999,11 @@ var DataSpace = class {
3807
3999
  this._signingContext = params.signingContext;
3808
4000
  this._callbacks = params.callbacks ?? {};
3809
4001
  this._echoHost = params.echoHost;
4002
+ this._notarizationPlugin = new NotarizationPlugin({
4003
+ spaceId: this._inner.id,
4004
+ edgeClient: params.edgeHttpClient,
4005
+ edgeFeatures: params.edgeFeatures
4006
+ });
3810
4007
  this.authVerifier = new TrustedKeySetAuthVerifier({
3811
4008
  trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
3812
4009
  update: this._inner.stateUpdate,
@@ -3824,7 +4021,7 @@ var DataSpace = class {
3824
4021
  state: SpaceState4[this._state]
3825
4022
  }, {
3826
4023
  F: __dxlog_file15,
3827
- L: 164,
4024
+ L: 170,
3828
4025
  S: this,
3829
4026
  C: (f, a) => f(...a)
3830
4027
  });
@@ -3881,9 +4078,9 @@ var DataSpace = class {
3881
4078
  if (this._edgeFeedReplicator) {
3882
4079
  this.inner.protocol.feedAdded.append(this._onFeedAdded);
3883
4080
  }
3884
- await this._inner.open(new Context6(void 0, {
4081
+ await this._inner.open(new Context5(void 0, {
3885
4082
  F: __dxlog_file15,
3886
- L: 238
4083
+ L: 244
3887
4084
  }));
3888
4085
  await this._edgeFeedReplicator?.open();
3889
4086
  this._state = SpaceState4.SPACE_CONTROL_ONLY;
@@ -3891,7 +4088,7 @@ var DataSpace = class {
3891
4088
  state: SpaceState4[this._state]
3892
4089
  }, {
3893
4090
  F: __dxlog_file15,
3894
- L: 243,
4091
+ L: 249,
3895
4092
  S: this,
3896
4093
  C: (f, a) => f(...a)
3897
4094
  });
@@ -3911,14 +4108,14 @@ var DataSpace = class {
3911
4108
  state: SpaceState4[this._state]
3912
4109
  }, {
3913
4110
  F: __dxlog_file15,
3914
- L: 262,
4111
+ L: 268,
3915
4112
  S: this,
3916
4113
  C: (f, a) => f(...a)
3917
4114
  });
3918
4115
  await this._ctx.dispose();
3919
- this._ctx = new Context6(void 0, {
4116
+ this._ctx = new Context5(void 0, {
3920
4117
  F: __dxlog_file15,
3921
- L: 264
4118
+ L: 270
3922
4119
  });
3923
4120
  if (this._edgeFeedReplicator) {
3924
4121
  this.inner.protocol.feedAdded.remove(this._onFeedAdded);
@@ -3951,7 +4148,7 @@ var DataSpace = class {
3951
4148
  if (err instanceof CancelledError || err instanceof ContextDisposedError) {
3952
4149
  log13("data pipeline initialization cancelled", err, {
3953
4150
  F: __dxlog_file15,
3954
- L: 302,
4151
+ L: 308,
3955
4152
  S: this,
3956
4153
  C: (f, a) => f(...a)
3957
4154
  });
@@ -3959,7 +4156,7 @@ var DataSpace = class {
3959
4156
  }
3960
4157
  log13.error("Error initializing data pipeline", err, {
3961
4158
  F: __dxlog_file15,
3962
- L: 306,
4159
+ L: 312,
3963
4160
  S: this,
3964
4161
  C: (f, a) => f(...a)
3965
4162
  });
@@ -3968,7 +4165,7 @@ var DataSpace = class {
3968
4165
  state: SpaceState4[this._state]
3969
4166
  }, {
3970
4167
  F: __dxlog_file15,
3971
- L: 308,
4168
+ L: 314,
3972
4169
  S: this,
3973
4170
  C: (f, a) => f(...a)
3974
4171
  });
@@ -3988,15 +4185,39 @@ var DataSpace = class {
3988
4185
  state: SpaceState4[this._state]
3989
4186
  }, {
3990
4187
  F: __dxlog_file15,
3991
- L: 324,
4188
+ L: 330,
4189
+ S: this,
4190
+ C: (f, a) => f(...a)
4191
+ });
4192
+ log13("initializing control pipeline", void 0, {
4193
+ F: __dxlog_file15,
4194
+ L: 332,
3992
4195
  S: this,
3993
4196
  C: (f, a) => f(...a)
3994
4197
  });
3995
4198
  await this._initializeAndReadControlPipeline();
3996
4199
  await sleep3(1);
3997
4200
  const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState4.SPACE_READY);
4201
+ log13("initializing automerge root", void 0, {
4202
+ F: __dxlog_file15,
4203
+ L: 340,
4204
+ S: this,
4205
+ C: (f, a) => f(...a)
4206
+ });
3998
4207
  this._automergeSpaceState.startProcessingRootDocs();
4208
+ log13("waiting for space to be ready", void 0, {
4209
+ F: __dxlog_file15,
4210
+ L: 344,
4211
+ S: this,
4212
+ C: (f, a) => f(...a)
4213
+ });
3999
4214
  await ready;
4215
+ log13("space is ready", void 0, {
4216
+ F: __dxlog_file15,
4217
+ L: 346,
4218
+ S: this,
4219
+ C: (f, a) => f(...a)
4220
+ });
4000
4221
  }
4001
4222
  async _enterReadyState() {
4002
4223
  await this._callbacks.beforeReady?.();
@@ -4005,7 +4226,7 @@ var DataSpace = class {
4005
4226
  state: SpaceState4[this._state]
4006
4227
  }, {
4007
4228
  F: __dxlog_file15,
4008
- L: 343,
4229
+ L: 353,
4009
4230
  S: this,
4010
4231
  C: (f, a) => f(...a)
4011
4232
  });
@@ -4015,13 +4236,14 @@ var DataSpace = class {
4015
4236
  async _initializeAndReadControlPipeline() {
4016
4237
  await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
4017
4238
  ctx: this._ctx,
4239
+ timeout: 1e4,
4018
4240
  breakOnStall: false
4019
4241
  });
4020
4242
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
4021
4243
  await this._createWritableFeeds();
4022
4244
  log13("writable feeds created", void 0, {
4023
4245
  F: __dxlog_file15,
4024
- L: 359,
4246
+ L: 370,
4025
4247
  S: this,
4026
4248
  C: (f, a) => f(...a)
4027
4249
  });
@@ -4070,11 +4292,35 @@ var DataSpace = class {
4070
4292
  }));
4071
4293
  }
4072
4294
  if (credentials.length > 0) {
4073
- await this.notarizationPlugin.notarize({
4074
- ctx: this._ctx,
4075
- credentials,
4076
- timeout: 0
4077
- });
4295
+ try {
4296
+ log13("will notarize credentials for feed admission", {
4297
+ count: credentials.length
4298
+ }, {
4299
+ F: __dxlog_file15,
4300
+ L: 428,
4301
+ S: this,
4302
+ C: (f, a) => f(...a)
4303
+ });
4304
+ await this.notarizationPlugin.notarize({
4305
+ ctx: this._ctx,
4306
+ credentials,
4307
+ timeout: 0
4308
+ });
4309
+ log13("credentials notarized", void 0, {
4310
+ F: __dxlog_file15,
4311
+ L: 432,
4312
+ S: this,
4313
+ C: (f, a) => f(...a)
4314
+ });
4315
+ } catch (err) {
4316
+ log13.error("error notarizing credentials for feed admission", err, {
4317
+ F: __dxlog_file15,
4318
+ L: 434,
4319
+ S: this,
4320
+ C: (f, a) => f(...a)
4321
+ });
4322
+ throw err;
4323
+ }
4078
4324
  await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
4079
4325
  }
4080
4326
  }
@@ -4084,7 +4330,7 @@ var DataSpace = class {
4084
4330
  rootUrl
4085
4331
  }, {
4086
4332
  F: __dxlog_file15,
4087
- L: 425,
4333
+ L: 444,
4088
4334
  S: this,
4089
4335
  C: (f, a) => f(...a)
4090
4336
  });
@@ -4136,7 +4382,7 @@ var DataSpace = class {
4136
4382
  err
4137
4383
  }, {
4138
4384
  F: __dxlog_file15,
4139
- L: 468,
4385
+ L: 487,
4140
4386
  S: this,
4141
4387
  C: (f, a) => f(...a)
4142
4388
  });
@@ -4226,58 +4472,58 @@ var DataSpace = class {
4226
4472
  state: SpaceState4[this._state]
4227
4473
  }, {
4228
4474
  F: __dxlog_file15,
4229
- L: 550,
4475
+ L: 569,
4230
4476
  S: this,
4231
4477
  C: (f, a) => f(...a)
4232
4478
  });
4233
4479
  this.stateUpdate.emit();
4234
4480
  }
4235
4481
  };
4236
- _ts_decorate4([
4482
+ _ts_decorate6([
4237
4483
  trace5.info()
4238
4484
  ], DataSpace.prototype, "_inner", void 0);
4239
- _ts_decorate4([
4485
+ _ts_decorate6([
4240
4486
  trace5.info()
4241
4487
  ], DataSpace.prototype, "id", null);
4242
- _ts_decorate4([
4488
+ _ts_decorate6([
4243
4489
  trace5.info()
4244
4490
  ], DataSpace.prototype, "key", null);
4245
- _ts_decorate4([
4491
+ _ts_decorate6([
4246
4492
  trace5.info({
4247
4493
  enum: SpaceState4
4248
4494
  })
4249
4495
  ], DataSpace.prototype, "state", null);
4250
- _ts_decorate4([
4496
+ _ts_decorate6([
4251
4497
  trace5.info({
4252
4498
  depth: null
4253
4499
  })
4254
4500
  ], DataSpace.prototype, "_automergeInfo", null);
4255
- _ts_decorate4([
4501
+ _ts_decorate6([
4256
4502
  synchronized2
4257
4503
  ], DataSpace.prototype, "open", null);
4258
- _ts_decorate4([
4504
+ _ts_decorate6([
4259
4505
  synchronized2
4260
4506
  ], DataSpace.prototype, "close", null);
4261
- _ts_decorate4([
4507
+ _ts_decorate6([
4262
4508
  trace5.span({
4263
4509
  showInBrowserTimeline: true
4264
4510
  })
4265
4511
  ], DataSpace.prototype, "initializeDataPipeline", null);
4266
- _ts_decorate4([
4512
+ _ts_decorate6([
4267
4513
  trace5.span({
4268
4514
  showInBrowserTimeline: true
4269
4515
  })
4270
4516
  ], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
4271
- _ts_decorate4([
4517
+ _ts_decorate6([
4272
4518
  timed(1e4)
4273
4519
  ], DataSpace.prototype, "_createWritableFeeds", null);
4274
- _ts_decorate4([
4520
+ _ts_decorate6([
4275
4521
  synchronized2
4276
4522
  ], DataSpace.prototype, "activate", null);
4277
- _ts_decorate4([
4523
+ _ts_decorate6([
4278
4524
  synchronized2
4279
4525
  ], DataSpace.prototype, "deactivate", null);
4280
- DataSpace = _ts_decorate4([
4526
+ DataSpace = _ts_decorate6([
4281
4527
  trackLeaks2("open", "close"),
4282
4528
  trace5.resource()
4283
4529
  ], DataSpace);
@@ -4411,7 +4657,7 @@ import { ComplexSet as ComplexSet5 } from "@dxos/util";
4411
4657
 
4412
4658
  // packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
4413
4659
  import { Trigger as Trigger5 } from "@dxos/async";
4414
- import { cancelWithContext as cancelWithContext4, Context as Context7 } from "@dxos/context";
4660
+ import { cancelWithContext as cancelWithContext4, Context as Context6 } from "@dxos/context";
4415
4661
  import { invariant as invariant11 } from "@dxos/invariant";
4416
4662
  import { log as log14 } from "@dxos/log";
4417
4663
  import { InvalidInvitationExtensionRoleError } from "@dxos/protocols";
@@ -4453,7 +4699,7 @@ var InvitationGuestExtension = class extends RpcExtension2 {
4453
4699
  });
4454
4700
  this._invitationFlowMutex = _invitationFlowMutex;
4455
4701
  this._callbacks = _callbacks;
4456
- this._ctx = new Context7(void 0, {
4702
+ this._ctx = new Context6(void 0, {
4457
4703
  F: __dxlog_file17,
4458
4704
  L: 34
4459
4705
  });
@@ -4565,7 +4811,7 @@ var InvitationGuestExtension = class extends RpcExtension2 {
4565
4811
 
4566
4812
  // packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts
4567
4813
  import { Trigger as Trigger6, scheduleTask as scheduleTask5 } from "@dxos/async";
4568
- import { cancelWithContext as cancelWithContext5, Context as Context8 } from "@dxos/context";
4814
+ import { cancelWithContext as cancelWithContext5, Context as Context7 } from "@dxos/context";
4569
4815
  import { randomBytes, verify } from "@dxos/crypto";
4570
4816
  import { invariant as invariant12, InvariantViolation } from "@dxos/invariant";
4571
4817
  import { PublicKey as PublicKey9 } from "@dxos/keys";
@@ -4590,7 +4836,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
4590
4836
  });
4591
4837
  this._invitationFlowMutex = _invitationFlowMutex;
4592
4838
  this._callbacks = _callbacks;
4593
- this._ctx = new Context8(void 0, {
4839
+ this._ctx = new Context7(void 0, {
4594
4840
  F: __dxlog_file18,
4595
4841
  L: 53
4596
4842
  });
@@ -5965,7 +6211,7 @@ var SpaceInvitationProtocol = class {
5965
6211
  // packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
5966
6212
  import { Event as Event8, PushStream, TimeoutError as TimeoutError3, Trigger as Trigger7 } from "@dxos/async";
5967
6213
  import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvitation, INVITATION_TIMEOUT as INVITATION_TIMEOUT2 } from "@dxos/client-protocol";
5968
- import { Context as Context9 } from "@dxos/context";
6214
+ import { Context as Context8 } from "@dxos/context";
5969
6215
  import { generatePasscode } from "@dxos/credentials";
5970
6216
  import { hasInvitationExpired } from "@dxos/echo-pipeline";
5971
6217
  import { invariant as invariant16 } from "@dxos/invariant";
@@ -6197,7 +6443,7 @@ var InvitationsManager = class {
6197
6443
  }
6198
6444
  _createObservableInvitation(handler, invitation) {
6199
6445
  const stream = new PushStream();
6200
- const ctx = new Context9({
6446
+ const ctx = new Context8({
6201
6447
  onError: (err) => {
6202
6448
  stream.error(err);
6203
6449
  void ctx.dispose();
@@ -6237,7 +6483,7 @@ var InvitationsManager = class {
6237
6483
  _createObservableAcceptingInvitation(handler, initialState) {
6238
6484
  const otpEnteredTrigger = new Trigger7();
6239
6485
  const stream = new PushStream();
6240
- const ctx = new Context9({
6486
+ const ctx = new Context8({
6241
6487
  onError: (err) => {
6242
6488
  if (err instanceof TimeoutError3) {
6243
6489
  log19("timeout", {
@@ -6336,8 +6582,8 @@ var InvitationsManager = class {
6336
6582
  // packages/sdk/client-services/src/packlets/locks/browser.ts
6337
6583
  import { asyncTimeout as asyncTimeout2, Trigger as Trigger8 } from "@dxos/async";
6338
6584
  import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
6339
- import { log as log20, logInfo } from "@dxos/log";
6340
- function _ts_decorate5(decorators, target, key, desc) {
6585
+ import { log as log20, logInfo as logInfo3 } from "@dxos/log";
6586
+ function _ts_decorate7(decorators, target, key, desc) {
6341
6587
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6342
6588
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6343
6589
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -6446,8 +6692,8 @@ var Lock = class {
6446
6692
  });
6447
6693
  }
6448
6694
  };
6449
- _ts_decorate5([
6450
- logInfo
6695
+ _ts_decorate7([
6696
+ logInfo3
6451
6697
  ], Lock.prototype, "lockKey", null);
6452
6698
  var isLocked = (lockPath) => {
6453
6699
  throw new Error("Not implemented");
@@ -6458,7 +6704,7 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
6458
6704
  import { raise as raise2 } from "@dxos/debug";
6459
6705
  import { parseMethodName, RpcPeer } from "@dxos/rpc";
6460
6706
  import { MapCounter, trace as trace8 } from "@dxos/tracing";
6461
- function _ts_decorate6(decorators, target, key, desc) {
6707
+ function _ts_decorate8(decorators, target, key, desc) {
6462
6708
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6463
6709
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6464
6710
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -6520,22 +6766,23 @@ var ClientRpcServer = class {
6520
6766
  return this._handlerCache.get(serviceName);
6521
6767
  }
6522
6768
  };
6523
- _ts_decorate6([
6769
+ _ts_decorate8([
6524
6770
  trace8.metricsCounter()
6525
6771
  ], ClientRpcServer.prototype, "_callMetrics", void 0);
6526
- _ts_decorate6([
6772
+ _ts_decorate8([
6527
6773
  trace8.info()
6528
6774
  ], ClientRpcServer.prototype, "_services", null);
6529
- ClientRpcServer = _ts_decorate6([
6775
+ ClientRpcServer = _ts_decorate8([
6530
6776
  trace8.resource()
6531
6777
  ], ClientRpcServer);
6532
6778
 
6533
6779
  // packages/sdk/client-services/src/packlets/services/service-context.ts
6534
- import { Trigger as Trigger9 } from "@dxos/async";
6535
- import { Context as Context10, Resource as Resource5 } from "@dxos/context";
6780
+ import { Mutex as Mutex4, scheduleMicroTask as scheduleMicroTask3, Trigger as Trigger9 } from "@dxos/async";
6781
+ import { Context as Context9, Resource as Resource6 } from "@dxos/context";
6536
6782
  import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
6537
- import { failUndefined as failUndefined2 } from "@dxos/debug";
6783
+ import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
6538
6784
  import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
6785
+ import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from "@dxos/edge-client";
6539
6786
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
6540
6787
  import { invariant as invariant17 } from "@dxos/invariant";
6541
6788
  import { Keyring } from "@dxos/keyring";
@@ -6546,23 +6793,87 @@ import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/ser
6546
6793
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
6547
6794
  import { trace as Trace3 } from "@dxos/tracing";
6548
6795
  import { safeInstanceof } from "@dxos/util";
6549
- function _ts_decorate7(decorators, target, key, desc) {
6796
+ function _ts_decorate9(decorators, target, key, desc) {
6550
6797
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6551
6798
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6552
6799
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6553
6800
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6554
6801
  }
6802
+ function _using_ctx3() {
6803
+ var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
6804
+ var err = new Error();
6805
+ err.name = "SuppressedError";
6806
+ err.suppressed = suppressed;
6807
+ err.error = error;
6808
+ return err;
6809
+ }, empty = {}, stack = [];
6810
+ function using(isAwait, value) {
6811
+ if (value != null) {
6812
+ if (Object(value) !== value) {
6813
+ throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
6814
+ }
6815
+ if (isAwait) {
6816
+ var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
6817
+ }
6818
+ if (dispose == null) {
6819
+ dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
6820
+ }
6821
+ if (typeof dispose !== "function") {
6822
+ throw new TypeError(`Property [Symbol.dispose] is not a function.`);
6823
+ }
6824
+ stack.push({
6825
+ v: value,
6826
+ d: dispose,
6827
+ a: isAwait
6828
+ });
6829
+ } else if (isAwait) {
6830
+ stack.push({
6831
+ d: value,
6832
+ a: isAwait
6833
+ });
6834
+ }
6835
+ return value;
6836
+ }
6837
+ return {
6838
+ e: empty,
6839
+ u: using.bind(null, false),
6840
+ a: using.bind(null, true),
6841
+ d: function() {
6842
+ var error = this.e;
6843
+ function next() {
6844
+ while (resource = stack.pop()) {
6845
+ try {
6846
+ var resource, disposalResult = resource.d && resource.d.call(resource.v);
6847
+ if (resource.a) {
6848
+ return Promise.resolve(disposalResult).then(next, err);
6849
+ }
6850
+ } catch (e) {
6851
+ return err(e);
6852
+ }
6853
+ }
6854
+ if (error !== empty) throw error;
6855
+ }
6856
+ function err(e) {
6857
+ error = error !== empty ? new _disposeSuppressedError(error, e) : e;
6858
+ return next();
6859
+ }
6860
+ return next();
6861
+ }
6862
+ };
6863
+ }
6555
6864
  var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
6556
- var ServiceContext = class extends Resource5 {
6557
- constructor(storage, level, networkManager, signalManager, _edgeConnection, _runtimeParams, _edgeFeatures) {
6865
+ var ServiceContext = class extends Resource6 {
6866
+ constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
6558
6867
  super();
6559
6868
  this.storage = storage;
6560
6869
  this.level = level;
6561
6870
  this.networkManager = networkManager;
6562
6871
  this.signalManager = signalManager;
6563
6872
  this._edgeConnection = _edgeConnection;
6873
+ this._edgeHttpClient = _edgeHttpClient;
6564
6874
  this._runtimeParams = _runtimeParams;
6565
6875
  this._edgeFeatures = _edgeFeatures;
6876
+ this._edgeIdentityUpdateMutex = new Mutex4();
6566
6877
  this.initialized = new Trigger9();
6567
6878
  this._meshReplicator = void 0;
6568
6879
  this._echoEdgeReplicator = void 0;
@@ -6600,23 +6911,42 @@ var ServiceContext = class extends Resource5 {
6600
6911
  callbacks: {
6601
6912
  onIdentityConstruction: (identity) => {
6602
6913
  if (this._edgeConnection) {
6603
- log21.info("Setting identity on edge connection", {
6604
- identity: identity.identityKey.toHex(),
6605
- oldIdentity: this._edgeConnection.identityKey,
6606
- swarms: this.networkManager.topics
6607
- }, {
6608
- F: __dxlog_file24,
6609
- L: 140,
6610
- S: this,
6611
- C: (f, a) => f(...a)
6612
- });
6613
- this._edgeConnection.setIdentity({
6614
- peerKey: identity.deviceKey.toHex(),
6615
- identityKey: identity.identityKey.toHex()
6616
- });
6617
- this.networkManager.setPeerInfo({
6618
- identityKey: identity.identityKey.toHex(),
6619
- peerKey: identity.deviceKey.toHex()
6914
+ scheduleMicroTask3(this._ctx, async () => {
6915
+ try {
6916
+ var _usingCtx = _using_ctx3();
6917
+ const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
6918
+ log21.info("Setting identity on edge connection", {
6919
+ identity: identity.identityKey.toHex(),
6920
+ oldIdentity: this._edgeConnection.identityKey,
6921
+ swarms: this.networkManager.topics
6922
+ }, {
6923
+ F: __dxlog_file24,
6924
+ L: 147,
6925
+ S: this,
6926
+ C: (f, a) => f(...a)
6927
+ });
6928
+ await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
6929
+ await identity.ready();
6930
+ });
6931
+ invariant17(identity.deviceCredentialChain, void 0, {
6932
+ F: __dxlog_file24,
6933
+ L: 157,
6934
+ S: this,
6935
+ A: [
6936
+ "identity.deviceCredentialChain",
6937
+ ""
6938
+ ]
6939
+ });
6940
+ this._edgeConnection.setIdentity(await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, identity.deviceCredentialChain, []));
6941
+ this.networkManager.setPeerInfo({
6942
+ identityKey: identity.identityKey.toHex(),
6943
+ peerKey: identity.deviceKey.toHex()
6944
+ });
6945
+ } catch (_) {
6946
+ _usingCtx.e = _;
6947
+ } finally {
6948
+ _usingCtx.d();
6949
+ }
6620
6950
  });
6621
6951
  }
6622
6952
  }
@@ -6642,7 +6972,7 @@ var ServiceContext = class extends Resource5 {
6642
6972
  await this._checkStorageVersion();
6643
6973
  log21("opening...", void 0, {
6644
6974
  F: __dxlog_file24,
6645
- L: 198,
6975
+ L: 217,
6646
6976
  S: this,
6647
6977
  C: (f, a) => f(...a)
6648
6978
  });
@@ -6650,11 +6980,14 @@ var ServiceContext = class extends Resource5 {
6650
6980
  id: this._instanceId
6651
6981
  }), {
6652
6982
  F: __dxlog_file24,
6653
- L: 199,
6983
+ L: 218,
6654
6984
  S: this,
6655
6985
  C: (f, a) => f(...a)
6656
6986
  });
6657
- await this._edgeConnection?.open();
6987
+ if (this._edgeConnection) {
6988
+ this._edgeConnection.setIdentity(await createEphemeralEdgeIdentity());
6989
+ await this._edgeConnection.open();
6990
+ }
6658
6991
  await this.signalManager.open();
6659
6992
  await this.networkManager.open();
6660
6993
  await this.echoHost.open(ctx);
@@ -6675,7 +7008,7 @@ var ServiceContext = class extends Resource5 {
6675
7008
  count: loadedInvitations.invitations?.length
6676
7009
  }, {
6677
7010
  F: __dxlog_file24,
6678
- L: 222,
7011
+ L: 245,
6679
7012
  S: this,
6680
7013
  C: (f, a) => f(...a)
6681
7014
  });
@@ -6683,13 +7016,13 @@ var ServiceContext = class extends Resource5 {
6683
7016
  id: this._instanceId
6684
7017
  }), {
6685
7018
  F: __dxlog_file24,
6686
- L: 224,
7019
+ L: 247,
6687
7020
  S: this,
6688
7021
  C: (f, a) => f(...a)
6689
7022
  });
6690
7023
  log21("opened", void 0, {
6691
7024
  F: __dxlog_file24,
6692
- L: 225,
7025
+ L: 248,
6693
7026
  S: this,
6694
7027
  C: (f, a) => f(...a)
6695
7028
  });
@@ -6697,7 +7030,7 @@ var ServiceContext = class extends Resource5 {
6697
7030
  async _close(ctx) {
6698
7031
  log21("closing...", void 0, {
6699
7032
  F: __dxlog_file24,
6700
- L: 229,
7033
+ L: 252,
6701
7034
  S: this,
6702
7035
  C: (f, a) => f(...a)
6703
7036
  });
@@ -6715,16 +7048,16 @@ var ServiceContext = class extends Resource5 {
6715
7048
  await this._edgeConnection?.close();
6716
7049
  log21("closed", void 0, {
6717
7050
  F: __dxlog_file24,
6718
- L: 244,
7051
+ L: 267,
6719
7052
  S: this,
6720
7053
  C: (f, a) => f(...a)
6721
7054
  });
6722
7055
  }
6723
7056
  async createIdentity(params = {}) {
6724
7057
  const identity = await this.identityManager.createIdentity(params);
6725
- await this._initialize(new Context10(void 0, {
7058
+ await this._initialize(new Context9(void 0, {
6726
7059
  F: __dxlog_file24,
6727
- L: 249
7060
+ L: 272
6728
7061
  }));
6729
7062
  return identity;
6730
7063
  }
@@ -6732,7 +7065,7 @@ var ServiceContext = class extends Resource5 {
6732
7065
  const factory = this._handlerFactories.get(invitation.kind);
6733
7066
  invariant17(factory, `Unknown invitation kind: ${invitation.kind}`, {
6734
7067
  F: __dxlog_file24,
6735
- L: 255,
7068
+ L: 278,
6736
7069
  S: this,
6737
7070
  A: [
6738
7071
  "factory",
@@ -6751,9 +7084,9 @@ var ServiceContext = class extends Resource5 {
6751
7084
  }
6752
7085
  async _acceptIdentity(params) {
6753
7086
  const identity = await this.identityManager.acceptIdentity(params);
6754
- await this._initialize(new Context10(void 0, {
7087
+ await this._initialize(new Context9(void 0, {
6755
7088
  F: __dxlog_file24,
6756
- L: 271
7089
+ L: 294
6757
7090
  }));
6758
7091
  return identity;
6759
7092
  }
@@ -6767,7 +7100,7 @@ var ServiceContext = class extends Resource5 {
6767
7100
  async _initialize(ctx) {
6768
7101
  log21("initializing spaces...", void 0, {
6769
7102
  F: __dxlog_file24,
6770
- L: 286,
7103
+ L: 309,
6771
7104
  S: this,
6772
7105
  C: (f, a) => f(...a)
6773
7106
  });
@@ -6794,6 +7127,7 @@ var ServiceContext = class extends Resource5 {
6794
7127
  echoHost: this.echoHost,
6795
7128
  invitationsManager: this.invitationsManager,
6796
7129
  edgeConnection: this._edgeConnection,
7130
+ edgeHttpClient: this._edgeHttpClient,
6797
7131
  echoEdgeReplicator: this._echoEdgeReplicator,
6798
7132
  meshReplicator: this._meshReplicator,
6799
7133
  runtimeParams: this._runtimeParams,
@@ -6803,7 +7137,7 @@ var ServiceContext = class extends Resource5 {
6803
7137
  this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
6804
7138
  invariant17(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
6805
7139
  F: __dxlog_file24,
6806
- L: 315,
7140
+ L: 339,
6807
7141
  S: this,
6808
7142
  A: [
6809
7143
  "this.dataSpaceManager",
@@ -6827,7 +7161,7 @@ var ServiceContext = class extends Resource5 {
6827
7161
  details: assertion
6828
7162
  }, {
6829
7163
  F: __dxlog_file24,
6830
- L: 331,
7164
+ L: 355,
6831
7165
  S: this,
6832
7166
  C: (f, a) => f(...a)
6833
7167
  });
@@ -6838,7 +7172,7 @@ var ServiceContext = class extends Resource5 {
6838
7172
  details: assertion
6839
7173
  }, {
6840
7174
  F: __dxlog_file24,
6841
- L: 335,
7175
+ L: 359,
6842
7176
  S: this,
6843
7177
  C: (f, a) => f(...a)
6844
7178
  });
@@ -6849,7 +7183,7 @@ var ServiceContext = class extends Resource5 {
6849
7183
  details: assertion
6850
7184
  }, {
6851
7185
  F: __dxlog_file24,
6852
- L: 340,
7186
+ L: 364,
6853
7187
  S: this,
6854
7188
  C: (f, a) => f(...a)
6855
7189
  });
@@ -6860,7 +7194,7 @@ var ServiceContext = class extends Resource5 {
6860
7194
  } catch (err) {
6861
7195
  log21.catch(err, void 0, {
6862
7196
  F: __dxlog_file24,
6863
- L: 346,
7197
+ L: 370,
6864
7198
  S: this,
6865
7199
  C: (f, a) => f(...a)
6866
7200
  });
@@ -6870,13 +7204,13 @@ var ServiceContext = class extends Resource5 {
6870
7204
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
6871
7205
  }
6872
7206
  };
6873
- _ts_decorate7([
7207
+ _ts_decorate9([
6874
7208
  Trace3.span()
6875
7209
  ], ServiceContext.prototype, "_open", null);
6876
- _ts_decorate7([
7210
+ _ts_decorate9([
6877
7211
  Trace3.span()
6878
7212
  ], ServiceContext.prototype, "_initialize", null);
6879
- ServiceContext = _ts_decorate7([
7213
+ ServiceContext = _ts_decorate9([
6880
7214
  safeInstanceof("dxos.client-services.ServiceContext"),
6881
7215
  Trace3.resource()
6882
7216
  ], ServiceContext);
@@ -7141,8 +7475,8 @@ var importProfileData = async ({ storage, level }, archive) => {
7141
7475
  // packages/sdk/client-services/src/packlets/services/service-host.ts
7142
7476
  import { Event as Event10, synchronized as synchronized3 } from "@dxos/async";
7143
7477
  import { clientServiceBundle } from "@dxos/client-protocol";
7144
- import { Context as Context11 } from "@dxos/context";
7145
- import { EdgeClient } from "@dxos/edge-client";
7478
+ import { Context as Context10 } from "@dxos/context";
7479
+ import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity } from "@dxos/edge-client";
7146
7480
  import { invariant as invariant20 } from "@dxos/invariant";
7147
7481
  import { PublicKey as PublicKey17 } from "@dxos/keys";
7148
7482
  import { log as log24 } from "@dxos/log";
@@ -7533,7 +7867,7 @@ var SystemServiceImpl = class {
7533
7867
  };
7534
7868
 
7535
7869
  // packages/sdk/client-services/src/packlets/services/service-host.ts
7536
- function _ts_decorate8(decorators, target, key, desc) {
7870
+ function _ts_decorate10(decorators, target, key, desc) {
7537
7871
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7538
7872
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7539
7873
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -7555,6 +7889,7 @@ var ClientServicesHost = class {
7555
7889
  this._tracingService = TRACE_PROCESSOR3.createTraceSender();
7556
7890
  this._statusUpdate = new Event10();
7557
7891
  this._edgeConnection = void 0;
7892
+ this._edgeHttpClient = void 0;
7558
7893
  this._opening = false;
7559
7894
  this._open = false;
7560
7895
  this._storage = storage;
@@ -7576,9 +7911,9 @@ var ClientServicesHost = class {
7576
7911
  lockKey,
7577
7912
  onAcquire: () => {
7578
7913
  if (!this._opening) {
7579
- void this.open(new Context11(void 0, {
7914
+ void this.open(new Context10(void 0, {
7580
7915
  F: __dxlog_file27,
7581
- L: 132
7916
+ L: 133
7582
7917
  }));
7583
7918
  }
7584
7919
  },
@@ -7636,7 +7971,7 @@ var ClientServicesHost = class {
7636
7971
  initialize({ config, ...options }) {
7637
7972
  invariant20(!this._open, "service host is open", {
7638
7973
  F: __dxlog_file27,
7639
- L: 198,
7974
+ L: 199,
7640
7975
  S: this,
7641
7976
  A: [
7642
7977
  "!this._open",
@@ -7645,14 +7980,14 @@ var ClientServicesHost = class {
7645
7980
  });
7646
7981
  log24("initializing...", void 0, {
7647
7982
  F: __dxlog_file27,
7648
- L: 199,
7983
+ L: 200,
7649
7984
  S: this,
7650
7985
  C: (f, a) => f(...a)
7651
7986
  });
7652
7987
  if (config) {
7653
7988
  invariant20(!this._config, "config already set", {
7654
7989
  F: __dxlog_file27,
7655
- L: 202,
7990
+ L: 203,
7656
7991
  S: this,
7657
7992
  A: [
7658
7993
  "!this._config",
@@ -7667,17 +8002,17 @@ var ClientServicesHost = class {
7667
8002
  if (!options.signalManager) {
7668
8003
  log24.warn("running signaling without telemetry metadata.", void 0, {
7669
8004
  F: __dxlog_file27,
7670
- L: 210,
8005
+ L: 211,
7671
8006
  S: this,
7672
8007
  C: (f, a) => f(...a)
7673
8008
  });
7674
8009
  }
7675
8010
  const edgeEndpoint = config?.get("runtime.services.edge.url");
7676
8011
  if (edgeEndpoint) {
7677
- const randomKey = PublicKey17.random().toHex();
7678
- this._edgeConnection = new EdgeClient(randomKey, randomKey, {
8012
+ this._edgeConnection = new EdgeClient(createStubEdgeIdentity(), {
7679
8013
  socketEndpoint: edgeEndpoint
7680
8014
  });
8015
+ this._edgeHttpClient = new EdgeHttpClient(edgeEndpoint);
7681
8016
  }
7682
8017
  const { connectionLog = true, transportFactory = createRtcTransportFactory({
7683
8018
  iceServers: this._config?.get("runtime.services.ice")
@@ -7687,7 +8022,7 @@ var ClientServicesHost = class {
7687
8022
  this._signalManager = signalManager;
7688
8023
  invariant20(!this._networkManager, "network manager already set", {
7689
8024
  F: __dxlog_file27,
7690
- L: 232,
8025
+ L: 233,
7691
8026
  S: this,
7692
8027
  A: [
7693
8028
  "!this._networkManager",
@@ -7705,7 +8040,7 @@ var ClientServicesHost = class {
7705
8040
  });
7706
8041
  log24("initialized", void 0, {
7707
8042
  F: __dxlog_file27,
7708
- L: 245,
8043
+ L: 246,
7709
8044
  S: this,
7710
8045
  C: (f, a) => f(...a)
7711
8046
  });
@@ -7719,13 +8054,13 @@ var ClientServicesHost = class {
7719
8054
  id: traceId
7720
8055
  }), {
7721
8056
  F: __dxlog_file27,
7722
- L: 256,
8057
+ L: 257,
7723
8058
  S: this,
7724
8059
  C: (f, a) => f(...a)
7725
8060
  });
7726
8061
  invariant20(this._config, "config not set", {
7727
8062
  F: __dxlog_file27,
7728
- L: 258,
8063
+ L: 259,
7729
8064
  S: this,
7730
8065
  A: [
7731
8066
  "this._config",
@@ -7734,7 +8069,7 @@ var ClientServicesHost = class {
7734
8069
  });
7735
8070
  invariant20(this._storage, "storage not set", {
7736
8071
  F: __dxlog_file27,
7737
- L: 259,
8072
+ L: 260,
7738
8073
  S: this,
7739
8074
  A: [
7740
8075
  "this._storage",
@@ -7743,7 +8078,7 @@ var ClientServicesHost = class {
7743
8078
  });
7744
8079
  invariant20(this._signalManager, "signal manager not set", {
7745
8080
  F: __dxlog_file27,
7746
- L: 260,
8081
+ L: 261,
7747
8082
  S: this,
7748
8083
  A: [
7749
8084
  "this._signalManager",
@@ -7752,7 +8087,7 @@ var ClientServicesHost = class {
7752
8087
  });
7753
8088
  invariant20(this._networkManager, "network manager not set", {
7754
8089
  F: __dxlog_file27,
7755
- L: 261,
8090
+ L: 262,
7756
8091
  S: this,
7757
8092
  A: [
7758
8093
  "this._networkManager",
@@ -7764,7 +8099,7 @@ var ClientServicesHost = class {
7764
8099
  lockKey: this._resourceLock?.lockKey
7765
8100
  }, {
7766
8101
  F: __dxlog_file27,
7767
- L: 264,
8102
+ L: 265,
7768
8103
  S: this,
7769
8104
  C: (f, a) => f(...a)
7770
8105
  });
@@ -7774,7 +8109,7 @@ var ClientServicesHost = class {
7774
8109
  }
7775
8110
  await this._level.open();
7776
8111
  await this._loggingService.open();
7777
- this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._runtimeParams, this._config.get("runtime.client.edgeFeatures"));
8112
+ this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._edgeHttpClient, this._runtimeParams, this._config.get("runtime.client.edgeFeatures"));
7778
8113
  const dataSpaceManagerProvider = async () => {
7779
8114
  await this._serviceContext.initialized.wait();
7780
8115
  return this._serviceContext.dataSpaceManager;
@@ -7820,7 +8155,7 @@ var ClientServicesHost = class {
7820
8155
  deviceKey
7821
8156
  }, {
7822
8157
  F: __dxlog_file27,
7823
- L: 352,
8158
+ L: 354,
7824
8159
  S: this,
7825
8160
  C: (f, a) => f(...a)
7826
8161
  });
@@ -7828,7 +8163,7 @@ var ClientServicesHost = class {
7828
8163
  id: traceId
7829
8164
  }), {
7830
8165
  F: __dxlog_file27,
7831
- L: 353,
8166
+ L: 355,
7832
8167
  S: this,
7833
8168
  C: (f, a) => f(...a)
7834
8169
  });
@@ -7842,7 +8177,7 @@ var ClientServicesHost = class {
7842
8177
  deviceKey
7843
8178
  }, {
7844
8179
  F: __dxlog_file27,
7845
- L: 364,
8180
+ L: 366,
7846
8181
  S: this,
7847
8182
  C: (f, a) => f(...a)
7848
8183
  });
@@ -7860,7 +8195,7 @@ var ClientServicesHost = class {
7860
8195
  deviceKey
7861
8196
  }, {
7862
8197
  F: __dxlog_file27,
7863
- L: 373,
8198
+ L: 375,
7864
8199
  S: this,
7865
8200
  C: (f, a) => f(...a)
7866
8201
  });
@@ -7871,13 +8206,13 @@ var ClientServicesHost = class {
7871
8206
  id: traceId
7872
8207
  }), {
7873
8208
  F: __dxlog_file27,
7874
- L: 378,
8209
+ L: 380,
7875
8210
  S: this,
7876
8211
  C: (f, a) => f(...a)
7877
8212
  });
7878
8213
  log24.info("resetting...", void 0, {
7879
8214
  F: __dxlog_file27,
7880
- L: 380,
8215
+ L: 382,
7881
8216
  S: this,
7882
8217
  C: (f, a) => f(...a)
7883
8218
  });
@@ -7885,7 +8220,7 @@ var ClientServicesHost = class {
7885
8220
  await this._storage.reset();
7886
8221
  log24.info("reset", void 0, {
7887
8222
  F: __dxlog_file27,
7888
- L: 383,
8223
+ L: 385,
7889
8224
  S: this,
7890
8225
  C: (f, a) => f(...a)
7891
8226
  });
@@ -7893,7 +8228,7 @@ var ClientServicesHost = class {
7893
8228
  id: traceId
7894
8229
  }), {
7895
8230
  F: __dxlog_file27,
7896
- L: 384,
8231
+ L: 386,
7897
8232
  S: this,
7898
8233
  C: (f, a) => f(...a)
7899
8234
  });
@@ -7905,21 +8240,21 @@ var ClientServicesHost = class {
7905
8240
  return identity;
7906
8241
  }
7907
8242
  };
7908
- _ts_decorate8([
8243
+ _ts_decorate10([
7909
8244
  Trace4.info()
7910
8245
  ], ClientServicesHost.prototype, "_opening", void 0);
7911
- _ts_decorate8([
8246
+ _ts_decorate10([
7912
8247
  Trace4.info()
7913
8248
  ], ClientServicesHost.prototype, "_open", void 0);
7914
- _ts_decorate8([
8249
+ _ts_decorate10([
7915
8250
  synchronized3,
7916
8251
  Trace4.span()
7917
8252
  ], ClientServicesHost.prototype, "open", null);
7918
- _ts_decorate8([
8253
+ _ts_decorate10([
7919
8254
  synchronized3,
7920
8255
  Trace4.span()
7921
8256
  ], ClientServicesHost.prototype, "close", null);
7922
- ClientServicesHost = _ts_decorate8([
8257
+ ClientServicesHost = _ts_decorate10([
7923
8258
  Trace4.resource()
7924
8259
  ], ClientServicesHost);
7925
8260
 
@@ -7967,4 +8302,4 @@ export {
7967
8302
  importProfileData,
7968
8303
  ClientServicesHost
7969
8304
  };
7970
- //# sourceMappingURL=chunk-7ONARHVD.mjs.map
8305
+ //# sourceMappingURL=chunk-67FEJJ6J.mjs.map