@dxos/client-services 0.6.12-main.78ddbdf → 0.6.12-main.89e9959

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-XSFLJVDP.mjs → chunk-XVI3VSJT.mjs} +637 -292
  2. package/dist/lib/browser/chunk-XVI3VSJT.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-F3WGFGEN.cjs → chunk-NZL66D6K.cjs} +727 -382
  8. package/dist/lib/node/chunk-NZL66D6K.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-3HDLTAT2.mjs → chunk-6747X7GN.mjs} +637 -292
  14. package/dist/lib/node-esm/chunk-6747X7GN.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 +2 -0
  33. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  34. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +31 -6
  35. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  36. package/dist/types/src/version.d.ts +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 +22 -15
  46. package/src/packlets/spaces/edge-feed-replicator.ts +45 -25
  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-XSFLJVDP.mjs.map +0 -7
  52. package/dist/lib/node/chunk-F3WGFGEN.cjs.map +0 -7
  53. package/dist/lib/node-esm/chunk-3HDLTAT2.mjs.map +0 -7
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_F3WGFGEN_exports = {};
30
- __export(chunk_F3WGFGEN_exports, {
29
+ var chunk_NZL66D6K_exports = {};
30
+ __export(chunk_NZL66D6K_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -70,7 +70,7 @@ __export(chunk_F3WGFGEN_exports, {
70
70
  subscribeToSpaces: () => subscribeToSpaces,
71
71
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
72
72
  });
73
- module.exports = __toCommonJS(chunk_F3WGFGEN_exports);
73
+ module.exports = __toCommonJS(chunk_NZL66D6K_exports);
74
74
  var import_async = require("@dxos/async");
75
75
  var import_codec_protobuf = require("@dxos/codec-protobuf");
76
76
  var import_feed_store = require("@dxos/feed-store");
@@ -142,30 +142,32 @@ var import_log5 = require("@dxos/log");
142
142
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
143
143
  var import_async9 = require("@dxos/async");
144
144
  var import_context6 = require("@dxos/context");
145
+ var import_credentials5 = require("@dxos/credentials");
145
146
  var import_invariant5 = require("@dxos/invariant");
146
147
  var import_keys5 = require("@dxos/keys");
147
148
  var import_log6 = require("@dxos/log");
149
+ var import_protocols4 = require("@dxos/protocols");
148
150
  var import_proto2 = require("@dxos/protocols/proto");
149
151
  var import_teleport = require("@dxos/teleport");
150
152
  var import_util5 = require("@dxos/util");
151
153
  var import_async10 = require("@dxos/async");
152
154
  var import_client_protocol3 = require("@dxos/client-protocol");
153
- var import_credentials5 = require("@dxos/credentials");
155
+ var import_credentials6 = require("@dxos/credentials");
154
156
  var import_feed_store2 = require("@dxos/feed-store");
155
157
  var import_invariant6 = require("@dxos/invariant");
156
158
  var import_keys6 = require("@dxos/keys");
157
159
  var import_log7 = require("@dxos/log");
158
- var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials");
160
+ var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
159
161
  var import_timeframe2 = require("@dxos/timeframe");
160
162
  var import_tracing4 = require("@dxos/tracing");
161
163
  var import_util6 = require("@dxos/util");
162
- var import_credentials7 = require("@dxos/credentials");
164
+ var import_credentials8 = require("@dxos/credentials");
163
165
  var import_keys7 = require("@dxos/keys");
164
166
  var import_log8 = require("@dxos/log");
165
167
  var import_async11 = require("@dxos/async");
166
168
  var import_client_protocol4 = require("@dxos/client-protocol");
167
169
  var import_context7 = require("@dxos/context");
168
- var import_credentials8 = require("@dxos/credentials");
170
+ var import_credentials9 = require("@dxos/credentials");
169
171
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
170
172
  var import_echo_protocol3 = require("@dxos/echo-protocol");
171
173
  var import_echo_schema2 = require("@dxos/echo-schema");
@@ -173,36 +175,36 @@ var import_feed_store3 = require("@dxos/feed-store");
173
175
  var import_invariant7 = require("@dxos/invariant");
174
176
  var import_keys8 = require("@dxos/keys");
175
177
  var import_log9 = require("@dxos/log");
176
- var import_protocols4 = require("@dxos/protocols");
178
+ var import_protocols5 = require("@dxos/protocols");
177
179
  var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
178
- var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
180
+ var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
179
181
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
180
182
  var import_tracing5 = require("@dxos/tracing");
181
183
  var import_util7 = require("@dxos/util");
182
- var import_credentials10 = require("@dxos/credentials");
184
+ var import_credentials11 = require("@dxos/credentials");
183
185
  var import_debug2 = require("@dxos/debug");
184
- var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
186
+ var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
185
187
  var import_timeframe3 = require("@dxos/timeframe");
186
188
  var import_async12 = require("@dxos/async");
187
189
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
188
- var import_credentials12 = require("@dxos/credentials");
190
+ var import_credentials13 = require("@dxos/credentials");
189
191
  var import_debug3 = require("@dxos/debug");
190
192
  var import_feed_store4 = require("@dxos/feed-store");
191
193
  var import_invariant8 = require("@dxos/invariant");
192
194
  var import_log10 = require("@dxos/log");
193
- var import_protocols5 = require("@dxos/protocols");
195
+ var import_protocols6 = require("@dxos/protocols");
194
196
  var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
195
197
  var import_tracing6 = require("@dxos/tracing");
196
198
  var import_platform = __toESM(require("platform"));
197
199
  var import_async13 = require("@dxos/async");
198
200
  var import_context8 = require("@dxos/context");
199
- var import_credentials13 = require("@dxos/credentials");
201
+ var import_credentials14 = require("@dxos/credentials");
200
202
  var import_invariant9 = require("@dxos/invariant");
201
203
  var import_keys9 = require("@dxos/keys");
202
204
  var import_log11 = require("@dxos/log");
203
- var import_protocols6 = require("@dxos/protocols");
205
+ var import_protocols7 = require("@dxos/protocols");
204
206
  var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
205
- var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
207
+ var import_credentials15 = require("@dxos/protocols/proto/dxos/halo/credentials");
206
208
  var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
207
209
  var import_timeframe4 = require("@dxos/timeframe");
208
210
  var import_tracing7 = require("@dxos/tracing");
@@ -210,14 +212,14 @@ var import_util8 = require("@dxos/util");
210
212
  var import_async14 = require("@dxos/async");
211
213
  var import_codec_protobuf9 = require("@dxos/codec-protobuf");
212
214
  var import_context9 = require("@dxos/context");
213
- var import_credentials15 = require("@dxos/credentials");
215
+ var import_credentials16 = require("@dxos/credentials");
214
216
  var import_debug4 = require("@dxos/debug");
215
217
  var import_invariant10 = require("@dxos/invariant");
216
218
  var import_log12 = require("@dxos/log");
217
219
  var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
218
220
  var import_util9 = require("@dxos/util");
219
221
  var import_invariant11 = require("@dxos/invariant");
220
- var import_protocols7 = require("@dxos/protocols");
222
+ var import_protocols8 = require("@dxos/protocols");
221
223
  var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
222
224
  var import_async15 = require("@dxos/async");
223
225
  var import_client_protocol5 = require("@dxos/client-protocol");
@@ -227,7 +229,7 @@ var import_invariant12 = require("@dxos/invariant");
227
229
  var import_keys10 = require("@dxos/keys");
228
230
  var import_log13 = require("@dxos/log");
229
231
  var import_network_manager = require("@dxos/network-manager");
230
- var import_protocols8 = require("@dxos/protocols");
232
+ var import_protocols9 = require("@dxos/protocols");
231
233
  var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
232
234
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
233
235
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
@@ -237,7 +239,7 @@ var import_async16 = require("@dxos/async");
237
239
  var import_context11 = require("@dxos/context");
238
240
  var import_invariant13 = require("@dxos/invariant");
239
241
  var import_log14 = require("@dxos/log");
240
- var import_protocols9 = require("@dxos/protocols");
242
+ var import_protocols10 = require("@dxos/protocols");
241
243
  var import_proto3 = require("@dxos/protocols/proto");
242
244
  var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
243
245
  var import_teleport2 = require("@dxos/teleport");
@@ -249,7 +251,7 @@ var import_crypto2 = require("@dxos/crypto");
249
251
  var import_invariant14 = require("@dxos/invariant");
250
252
  var import_keys11 = require("@dxos/keys");
251
253
  var import_log15 = require("@dxos/log");
252
- var import_protocols10 = require("@dxos/protocols");
254
+ var import_protocols11 = require("@dxos/protocols");
253
255
  var import_proto4 = require("@dxos/protocols/proto");
254
256
  var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
255
257
  var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
@@ -261,23 +263,23 @@ var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations")
261
263
  var import_util11 = require("@dxos/util");
262
264
  var import_codec_protobuf10 = require("@dxos/codec-protobuf");
263
265
  var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
264
- var import_credentials16 = require("@dxos/credentials");
266
+ var import_credentials17 = require("@dxos/credentials");
265
267
  var import_feed_store5 = require("@dxos/feed-store");
266
268
  var import_invariant16 = require("@dxos/invariant");
267
269
  var import_log17 = require("@dxos/log");
268
- var import_protocols11 = require("@dxos/protocols");
270
+ var import_protocols12 = require("@dxos/protocols");
269
271
  var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
270
- var import_credentials17 = require("@dxos/protocols/proto/dxos/halo/credentials");
272
+ var import_credentials18 = require("@dxos/protocols/proto/dxos/halo/credentials");
271
273
  var import_async18 = require("@dxos/async");
272
274
  var import_client_protocol6 = require("@dxos/client-protocol");
273
275
  var import_context14 = require("@dxos/context");
274
- var import_credentials18 = require("@dxos/credentials");
276
+ var import_credentials19 = require("@dxos/credentials");
275
277
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
276
278
  var import_invariant17 = require("@dxos/invariant");
277
279
  var import_keys13 = require("@dxos/keys");
278
280
  var import_log18 = require("@dxos/log");
279
281
  var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
280
- var import_credentials19 = require("@dxos/protocols/proto/dxos/halo/credentials");
282
+ var import_credentials20 = require("@dxos/protocols/proto/dxos/halo/credentials");
281
283
  var import_invariant18 = require("@dxos/invariant");
282
284
  var import_lock_file = require("@dxos/lock-file");
283
285
  var import_log19 = require("@dxos/log");
@@ -287,20 +289,21 @@ var import_rpc = require("@dxos/rpc");
287
289
  var import_tracing9 = require("@dxos/tracing");
288
290
  var import_async19 = require("@dxos/async");
289
291
  var import_context15 = require("@dxos/context");
290
- var import_credentials20 = require("@dxos/credentials");
292
+ var import_credentials21 = require("@dxos/credentials");
291
293
  var import_debug6 = require("@dxos/debug");
292
294
  var import_echo_pipeline5 = require("@dxos/echo-pipeline");
295
+ var import_edge_client2 = require("@dxos/edge-client");
293
296
  var import_feed_store6 = require("@dxos/feed-store");
294
297
  var import_invariant19 = require("@dxos/invariant");
295
298
  var import_keyring = require("@dxos/keyring");
296
299
  var import_keys14 = require("@dxos/keys");
297
300
  var import_log20 = require("@dxos/log");
298
- var import_protocols12 = require("@dxos/protocols");
301
+ var import_protocols13 = require("@dxos/protocols");
299
302
  var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
300
303
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
301
304
  var import_tracing10 = require("@dxos/tracing");
302
305
  var import_util12 = require("@dxos/util");
303
- var import_protocols13 = require("@dxos/protocols");
306
+ var import_protocols14 = require("@dxos/protocols");
304
307
  var import_config2 = require("@dxos/protocols/proto/dxos/config");
305
308
  var import_random_access_storage = require("@dxos/random-access-storage");
306
309
  var import_client_protocol7 = require("@dxos/client-protocol");
@@ -312,18 +315,18 @@ var import_kv_store = require("@dxos/kv-store");
312
315
  var import_automerge_repo = require("@dxos/automerge/automerge-repo");
313
316
  var import_invariant20 = require("@dxos/invariant");
314
317
  var import_log21 = require("@dxos/log");
315
- var import_protocols14 = require("@dxos/protocols");
318
+ var import_protocols15 = require("@dxos/protocols");
316
319
  var import_util14 = require("@dxos/util");
317
320
  var import_async20 = require("@dxos/async");
318
321
  var import_client_protocol8 = require("@dxos/client-protocol");
319
322
  var import_context16 = require("@dxos/context");
320
- var import_edge_client2 = require("@dxos/edge-client");
323
+ var import_edge_client3 = require("@dxos/edge-client");
321
324
  var import_invariant21 = require("@dxos/invariant");
322
325
  var import_keys16 = require("@dxos/keys");
323
326
  var import_log22 = require("@dxos/log");
324
327
  var import_messaging = require("@dxos/messaging");
325
328
  var import_network_manager2 = require("@dxos/network-manager");
326
- var import_protocols15 = require("@dxos/protocols");
329
+ var import_protocols16 = require("@dxos/protocols");
327
330
  var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
328
331
  var import_tracing11 = require("@dxos/tracing");
329
332
  var import_websocket_rpc = require("@dxos/websocket-rpc");
@@ -703,7 +706,7 @@ var DevtoolsServiceImpl = class {
703
706
  });
704
707
  }
705
708
  };
706
- var DXOS_VERSION = "0.6.12-main.78ddbdf";
709
+ var DXOS_VERSION = "0.6.12-main.89e9959";
707
710
  var getPlatform = () => {
708
711
  if (process.browser) {
709
712
  if (typeof window !== "undefined") {
@@ -955,7 +958,7 @@ var TrustedKeySetAuthVerifier = class {
955
958
  return false;
956
959
  }
957
960
  if (this._isTrustedKey(credential.issuer)) {
958
- (0, import_log2.log)("key is not currently in trusted set, waiting...", {
961
+ (0, import_log2.log)("key is trusted -- auth success", {
959
962
  key: credential.issuer
960
963
  }, {
961
964
  F: __dxlog_file4,
@@ -982,7 +985,10 @@ var TrustedKeySetAuthVerifier = class {
982
985
  trigger.wake(true);
983
986
  } else {
984
987
  (0, import_log2.log)("key is not currently in trusted set, waiting...", {
985
- key: credential.issuer
988
+ key: credential.issuer,
989
+ trusted: [
990
+ ...this._params.trustedKeysProvider()
991
+ ]
986
992
  }, {
987
993
  F: __dxlog_file4,
988
994
  L: 84,
@@ -1007,6 +1013,12 @@ var TrustedKeySetAuthVerifier = class {
1007
1013
  return deviceSet.has(deviceKey);
1008
1014
  }
1009
1015
  };
1016
+ function _ts_decorate(decorators, target, key, desc) {
1017
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1018
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1019
+ 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;
1020
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1021
+ }
1010
1022
  function _using_ctx() {
1011
1023
  var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
1012
1024
  var err = new Error();
@@ -1082,6 +1094,12 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1082
1094
  this._spaceId = spaceId;
1083
1095
  }
1084
1096
  async _open() {
1097
+ (0, import_log3.log)("open", void 0, {
1098
+ F: __dxlog_file5,
1099
+ L: 56,
1100
+ S: this,
1101
+ C: (f, a) => f(...a)
1102
+ });
1085
1103
  this._ctx.onDispose(this._messenger.addListener((message) => {
1086
1104
  if (!message.serviceId) {
1087
1105
  return;
@@ -1097,20 +1115,20 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1097
1115
  _spaceId: this._spaceId
1098
1116
  }, {
1099
1117
  F: __dxlog_file5,
1100
- L: 66,
1118
+ L: 70,
1101
1119
  S: this,
1102
1120
  C: (f, a) => f(...a)
1103
1121
  });
1104
1122
  return;
1105
1123
  }
1106
1124
  const payload = (0, import_cbor_x.decode)(message.payload.value);
1107
- import_log3.log.info("receive", {
1125
+ (0, import_log3.log)("receive", {
1108
1126
  from: message.source,
1109
1127
  feedKey: payload.feedKey,
1110
1128
  type: payload.type
1111
1129
  }, {
1112
1130
  F: __dxlog_file5,
1113
- L: 71,
1131
+ L: 75,
1114
1132
  S: this,
1115
1133
  C: (f, a) => f(...a)
1116
1134
  });
@@ -1118,46 +1136,44 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1118
1136
  }));
1119
1137
  this._messenger.connected.on(this._ctx, async () => {
1120
1138
  await this._resetConnection();
1121
- this._connected = true;
1122
- const connectionCtx = new import_context3.Context({
1123
- onError: async (err) => {
1124
- if (connectionCtx !== this._connectionCtx) {
1125
- return;
1126
- }
1127
- if (err instanceof import_edge_client.EdgeIdentityChangedError || err instanceof import_edge_client.EdgeConnectionClosedError) {
1128
- (0, import_log3.log)("resetting on reconnect", void 0, {
1129
- F: __dxlog_file5,
1130
- L: 86,
1131
- S: this,
1132
- C: (f, a) => f(...a)
1133
- });
1134
- await this._resetConnection();
1135
- } else {
1136
- this._ctx.raise(err);
1137
- }
1138
- }
1139
- }, {
1140
- F: __dxlog_file5,
1141
- L: 80
1142
- });
1143
- this._connectionCtx = connectionCtx;
1144
- (0, import_log3.log)("connection context created", void 0, {
1145
- F: __dxlog_file5,
1146
- L: 94,
1147
- S: this,
1148
- C: (f, a) => f(...a)
1149
- });
1150
- (0, import_async6.scheduleMicroTask)(connectionCtx, async () => {
1151
- for (const feed of this._feeds.values()) {
1152
- await this._replicateFeed(connectionCtx, feed);
1153
- }
1154
- });
1139
+ this._startReplication();
1155
1140
  });
1141
+ if (this._messenger.isConnected) {
1142
+ this._startReplication();
1143
+ }
1156
1144
  }
1157
1145
  async _close() {
1146
+ (0, import_log3.log)("close", void 0, {
1147
+ F: __dxlog_file5,
1148
+ L: 91,
1149
+ S: this,
1150
+ C: (f, a) => f(...a)
1151
+ });
1158
1152
  await this._resetConnection();
1159
1153
  }
1154
+ _startReplication() {
1155
+ this._connected = true;
1156
+ const connectionCtx = this._createConnectionContext();
1157
+ this._connectionCtx = connectionCtx;
1158
+ (0, import_log3.log)("connection context created", void 0, {
1159
+ F: __dxlog_file5,
1160
+ L: 99,
1161
+ S: this,
1162
+ C: (f, a) => f(...a)
1163
+ });
1164
+ (0, import_async6.scheduleMicroTask)(connectionCtx, async () => {
1165
+ for (const feed of this._feeds.values()) {
1166
+ await this._replicateFeed(connectionCtx, feed);
1167
+ }
1168
+ });
1169
+ }
1160
1170
  async _resetConnection() {
1171
+ (0, import_log3.log)("resetConnection", void 0, {
1172
+ F: __dxlog_file5,
1173
+ L: 108,
1174
+ S: this,
1175
+ C: (f, a) => f(...a)
1176
+ });
1161
1177
  this._connected = false;
1162
1178
  await this._connectionCtx?.dispose();
1163
1179
  this._connectionCtx = void 0;
@@ -1165,10 +1181,12 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1165
1181
  }
1166
1182
  async addFeed(feed) {
1167
1183
  import_log3.log.info("addFeed", {
1168
- key: feed.key
1184
+ key: feed.key,
1185
+ connected: this._connected,
1186
+ hasConnectionCtx: !!this._connectionCtx
1169
1187
  }, {
1170
1188
  F: __dxlog_file5,
1171
- L: 115,
1189
+ L: 116,
1172
1190
  S: this,
1173
1191
  C: (f, a) => f(...a)
1174
1192
  });
@@ -1181,6 +1199,14 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1181
1199
  return (0, import_util3.defaultMap)(this._pushMutex, key, () => new import_async6.Mutex());
1182
1200
  }
1183
1201
  async _replicateFeed(ctx, feed) {
1202
+ (0, import_log3.log)("replicateFeed", {
1203
+ key: feed.key
1204
+ }, {
1205
+ F: __dxlog_file5,
1206
+ L: 129,
1207
+ S: this,
1208
+ C: (f, a) => f(...a)
1209
+ });
1184
1210
  await this._sendMessage({
1185
1211
  type: "get-metadata",
1186
1212
  feedKey: feed.key.toHex()
@@ -1193,7 +1219,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1193
1219
  if (!this._connectionCtx) {
1194
1220
  import_log3.log.info("message dropped because connection was disposed", void 0, {
1195
1221
  F: __dxlog_file5,
1196
- L: 140,
1222
+ L: 142,
1197
1223
  S: this,
1198
1224
  C: (f, a) => f(...a)
1199
1225
  });
@@ -1207,13 +1233,13 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1207
1233
  };
1208
1234
  import_log3.log.info("sending message", logPayload, {
1209
1235
  F: __dxlog_file5,
1210
- L: 146,
1236
+ L: 148,
1211
1237
  S: this,
1212
1238
  C: (f, a) => f(...a)
1213
1239
  });
1214
1240
  (0, import_invariant2.invariant)(message.feedKey, void 0, {
1215
1241
  F: __dxlog_file5,
1216
- L: 148,
1242
+ L: 150,
1217
1243
  S: this,
1218
1244
  A: [
1219
1245
  "message.feedKey",
@@ -1221,6 +1247,14 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1221
1247
  ]
1222
1248
  });
1223
1249
  const payloadValue = (0, import_util3.bufferToArray)((0, import_cbor_x.encode)(message));
1250
+ (0, import_log3.log)("send", {
1251
+ type: message.type
1252
+ }, {
1253
+ F: __dxlog_file5,
1254
+ L: 153,
1255
+ S: this,
1256
+ C: (f, a) => f(...a)
1257
+ });
1224
1258
  await this._messenger.send(import_buf.buf.create(import_messenger_pb.MessageSchema, {
1225
1259
  source: {
1226
1260
  identityKey: this._messenger.identityKey,
@@ -1236,7 +1270,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1236
1270
  if (!this._connectionCtx) {
1237
1271
  import_log3.log.warn("received message after connection context was disposed", void 0, {
1238
1272
  F: __dxlog_file5,
1239
- L: 165,
1273
+ L: 168,
1240
1274
  S: this,
1241
1275
  C: (f, a) => f(...a)
1242
1276
  });
@@ -1251,7 +1285,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1251
1285
  message
1252
1286
  }, {
1253
1287
  F: __dxlog_file5,
1254
- L: 171,
1288
+ L: 174,
1255
1289
  S: this,
1256
1290
  C: (f, a) => f(...a)
1257
1291
  });
@@ -1262,7 +1296,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1262
1296
  feedKey
1263
1297
  }, {
1264
1298
  F: __dxlog_file5,
1265
- L: 176,
1299
+ L: 179,
1266
1300
  S: this,
1267
1301
  C: (f, a) => f(...a)
1268
1302
  });
@@ -1295,7 +1329,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1295
1329
  blocks: message.blocks.map((b) => b.index)
1296
1330
  }, {
1297
1331
  F: __dxlog_file5,
1298
- L: 198,
1332
+ L: 201,
1299
1333
  S: this,
1300
1334
  C: (f, a) => f(...a)
1301
1335
  });
@@ -1306,7 +1340,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1306
1340
  feedKey
1307
1341
  }, {
1308
1342
  F: __dxlog_file5,
1309
- L: 203,
1343
+ L: 206,
1310
1344
  S: this,
1311
1345
  C: (f, a) => f(...a)
1312
1346
  });
@@ -1320,7 +1354,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1320
1354
  ...message
1321
1355
  }, {
1322
1356
  F: __dxlog_file5,
1323
- L: 212,
1357
+ L: 215,
1324
1358
  S: this,
1325
1359
  C: (f, a) => f(...a)
1326
1360
  });
@@ -1335,7 +1369,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1335
1369
  to
1336
1370
  }, {
1337
1371
  F: __dxlog_file5,
1338
- L: 219,
1372
+ L: 222,
1339
1373
  S: this,
1340
1374
  C: (f, a) => f(...a)
1341
1375
  });
@@ -1345,7 +1379,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1345
1379
  });
1346
1380
  (0, import_invariant2.invariant)(data instanceof Uint8Array, void 0, {
1347
1381
  F: __dxlog_file5,
1348
- L: 224,
1382
+ L: 227,
1349
1383
  S: this,
1350
1384
  A: [
1351
1385
  "data instanceof Uint8Array",
@@ -1373,7 +1407,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1373
1407
  blocks: blocks.length
1374
1408
  }, {
1375
1409
  F: __dxlog_file5,
1376
- L: 245,
1410
+ L: 248,
1377
1411
  S: this,
1378
1412
  C: (f, a) => f(...a)
1379
1413
  });
@@ -1395,7 +1429,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1395
1429
  if (!this._remoteLength.has(feed.key)) {
1396
1430
  (0, import_log3.log)("blocks not pushed because remote length is unknown", void 0, {
1397
1431
  F: __dxlog_file5,
1398
- L: 266,
1432
+ L: 269,
1399
1433
  S: this,
1400
1434
  C: (f, a) => f(...a)
1401
1435
  });
@@ -1411,7 +1445,34 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1411
1445
  _usingCtx.d();
1412
1446
  }
1413
1447
  }
1448
+ _createConnectionContext() {
1449
+ const connectionCtx = new import_context3.Context({
1450
+ onError: async (err) => {
1451
+ if (connectionCtx !== this._connectionCtx) {
1452
+ return;
1453
+ }
1454
+ if (err instanceof import_edge_client.EdgeIdentityChangedError || err instanceof import_edge_client.EdgeConnectionClosedError) {
1455
+ (0, import_log3.log)("resetting on reconnect", void 0, {
1456
+ F: __dxlog_file5,
1457
+ L: 286,
1458
+ S: this,
1459
+ C: (f, a) => f(...a)
1460
+ });
1461
+ await this._resetConnection();
1462
+ } else {
1463
+ this._ctx.raise(err);
1464
+ }
1465
+ }
1466
+ }, {
1467
+ F: __dxlog_file5,
1468
+ L: 280
1469
+ });
1470
+ return connectionCtx;
1471
+ }
1414
1472
  };
1473
+ _ts_decorate([
1474
+ import_log3.logInfo
1475
+ ], EdgeFeedReplicator.prototype, "_spaceId", void 0);
1415
1476
  var bufferizeBlock = (block) => ({
1416
1477
  index: block.index,
1417
1478
  data: (0, import_util3.arrayToBuffer)(block.data),
@@ -1628,45 +1689,57 @@ var runEpochMigration = async (ctx, context) => {
1628
1689
  }
1629
1690
  return {};
1630
1691
  };
1692
+ function _ts_decorate2(decorators, target, key, desc) {
1693
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1694
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1695
+ 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;
1696
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1697
+ }
1631
1698
  var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
1632
1699
  var DEFAULT_RETRY_TIMEOUT = 1e3;
1633
1700
  var DEFAULT_SUCCESS_DELAY = 1e3;
1634
1701
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
1702
+ var MAX_EDGE_RETRIES = 2;
1635
1703
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
1636
- var NotarizationPlugin = class {
1637
- constructor() {
1638
- this._ctx = new import_context6.Context(void 0, {
1639
- F: __dxlog_file7,
1640
- L: 62
1641
- });
1704
+ var credentialCodec = import_proto2.schema.getCodecForType("dxos.halo.credentials.Credential");
1705
+ var NotarizationPlugin = class extends import_context6.Resource {
1706
+ constructor(params) {
1707
+ super();
1642
1708
  this._extensionOpened = new import_async9.Event();
1643
1709
  this._extensions = /* @__PURE__ */ new Set();
1644
1710
  this._processedCredentials = new import_util5.ComplexSet(import_keys5.PublicKey.hash);
1645
1711
  this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys5.PublicKey.hash);
1712
+ this._spaceId = params.spaceId;
1713
+ if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
1714
+ this._edgeClient = params.edgeClient;
1715
+ }
1646
1716
  }
1647
1717
  get hasWriter() {
1648
1718
  return !!this._writer;
1649
1719
  }
1650
- async open() {
1720
+ async _open() {
1721
+ if (this._edgeClient && this._writer) {
1722
+ this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1723
+ }
1651
1724
  }
1652
- async close() {
1725
+ async _close() {
1653
1726
  await this._ctx.dispose();
1654
1727
  }
1655
1728
  /**
1656
1729
  * Request credentials to be notarized.
1657
1730
  */
1658
- async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
1731
+ async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY, edgeRetryJitter }) {
1659
1732
  (0, import_log6.log)("notarize", {
1660
1733
  credentials
1661
1734
  }, {
1662
1735
  F: __dxlog_file7,
1663
- L: 90,
1736
+ L: 126,
1664
1737
  S: this,
1665
1738
  C: (f, a) => f(...a)
1666
1739
  });
1667
1740
  (0, import_invariant5.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
1668
1741
  F: __dxlog_file7,
1669
- L: 91,
1742
+ L: 127,
1670
1743
  S: this,
1671
1744
  A: [
1672
1745
  "credentials.every((credential) => credential.id)",
@@ -1680,7 +1753,7 @@ var NotarizationPlugin = class {
1680
1753
  err
1681
1754
  }, {
1682
1755
  F: __dxlog_file7,
1683
- L: 99,
1756
+ L: 135,
1684
1757
  S: this,
1685
1758
  C: (f, a) => f(...a)
1686
1759
  });
@@ -1690,21 +1763,37 @@ var NotarizationPlugin = class {
1690
1763
  });
1691
1764
  opCtx?.onDispose(() => ctx.dispose());
1692
1765
  if (timeout !== 0) {
1693
- (0, import_async9.scheduleTask)(ctx, () => {
1694
- import_log6.log.warn("Notarization timeout", {
1695
- timeout,
1696
- peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1697
- }, {
1698
- F: __dxlog_file7,
1699
- L: 111,
1700
- S: this,
1701
- C: (f, a) => f(...a)
1702
- });
1703
- void ctx.dispose();
1704
- errors.throw(new import_async9.TimeoutError(timeout, "Notarization timed out"));
1705
- }, timeout);
1766
+ this._scheduleTimeout(ctx, errors, timeout);
1706
1767
  }
1707
1768
  const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
1769
+ this._tryNotarizeCredentialsWithPeers(ctx, credentials, {
1770
+ retryTimeout,
1771
+ successDelay
1772
+ });
1773
+ if (this._edgeClient) {
1774
+ this._tryNotarizeCredentialsWithEdge(ctx, this._edgeClient, credentials, {
1775
+ retryTimeout,
1776
+ successDelay,
1777
+ jitter: edgeRetryJitter
1778
+ });
1779
+ }
1780
+ try {
1781
+ await Promise.race([
1782
+ (0, import_context6.rejectOnDispose)(ctx),
1783
+ allNotarized,
1784
+ errors.wait()
1785
+ ]);
1786
+ (0, import_log6.log)("done", void 0, {
1787
+ F: __dxlog_file7,
1788
+ L: 160,
1789
+ S: this,
1790
+ C: (f, a) => f(...a)
1791
+ });
1792
+ } finally {
1793
+ await ctx.dispose();
1794
+ }
1795
+ }
1796
+ _tryNotarizeCredentialsWithPeers(ctx, credentials, { retryTimeout, successDelay }) {
1708
1797
  const peersTried = /* @__PURE__ */ new Set();
1709
1798
  const notarizeTask = new import_async9.DeferredTask(ctx, async () => {
1710
1799
  try {
@@ -1719,7 +1808,7 @@ var NotarizationPlugin = class {
1719
1808
  retryIn: retryTimeout
1720
1809
  }, {
1721
1810
  F: __dxlog_file7,
1722
- L: 136,
1811
+ L: 183,
1723
1812
  S: this,
1724
1813
  C: (f, a) => f(...a)
1725
1814
  });
@@ -1733,7 +1822,7 @@ var NotarizationPlugin = class {
1733
1822
  credentialId: credentials.map((credential) => credential.id)
1734
1823
  }, {
1735
1824
  F: __dxlog_file7,
1736
- L: 143,
1825
+ L: 190,
1737
1826
  S: this,
1738
1827
  C: (f, a) => f(...a)
1739
1828
  });
@@ -1742,7 +1831,7 @@ var NotarizationPlugin = class {
1742
1831
  });
1743
1832
  (0, import_log6.log)("success", void 0, {
1744
1833
  F: __dxlog_file7,
1745
- L: 147,
1834
+ L: 194,
1746
1835
  S: this,
1747
1836
  C: (f, a) => f(...a)
1748
1837
  });
@@ -1751,7 +1840,7 @@ var NotarizationPlugin = class {
1751
1840
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
1752
1841
  import_log6.log.info("error notarizing (recoverable)", err, {
1753
1842
  F: __dxlog_file7,
1754
- L: 151,
1843
+ L: 199,
1755
1844
  S: this,
1756
1845
  C: (f, a) => f(...a)
1757
1846
  });
@@ -1761,21 +1850,33 @@ var NotarizationPlugin = class {
1761
1850
  });
1762
1851
  notarizeTask.schedule();
1763
1852
  this._extensionOpened.on(ctx, () => notarizeTask.schedule());
1764
- try {
1765
- await Promise.race([
1766
- (0, import_context6.rejectOnDispose)(ctx),
1767
- allNotarized,
1768
- errors.wait()
1769
- ]);
1770
- (0, import_log6.log)("done", void 0, {
1771
- F: __dxlog_file7,
1772
- L: 162,
1773
- S: this,
1774
- C: (f, a) => f(...a)
1775
- });
1776
- } finally {
1777
- await ctx.dispose();
1778
- }
1853
+ }
1854
+ _tryNotarizeCredentialsWithEdge(ctx, client, credentials, timeouts) {
1855
+ const encodedCredentials = credentials.map((credential) => {
1856
+ const binary = credentialCodec.encode(credential);
1857
+ return Buffer.from(binary).toString("base64");
1858
+ });
1859
+ (0, import_async9.scheduleTask)(ctx, async () => {
1860
+ try {
1861
+ await client.notarizeCredentials(this._spaceId, {
1862
+ credentials: encodedCredentials
1863
+ }, {
1864
+ retry: {
1865
+ count: MAX_EDGE_RETRIES,
1866
+ timeout: timeouts.retryTimeout,
1867
+ jitter: timeouts.jitter
1868
+ }
1869
+ });
1870
+ (0, import_log6.log)("edge notarization success", void 0, {
1871
+ F: __dxlog_file7,
1872
+ L: 227,
1873
+ S: this,
1874
+ C: (f, a) => f(...a)
1875
+ });
1876
+ } catch (error) {
1877
+ handleEdgeError(error);
1878
+ }
1879
+ });
1779
1880
  }
1780
1881
  /**
1781
1882
  * Called with credentials arriving from the control pipeline.
@@ -1791,7 +1892,7 @@ var NotarizationPlugin = class {
1791
1892
  setWriter(writer) {
1792
1893
  (0, import_invariant5.invariant)(!this._writer, "Writer already set.", {
1793
1894
  F: __dxlog_file7,
1794
- L: 181,
1895
+ L: 247,
1795
1896
  S: this,
1796
1897
  A: [
1797
1898
  "!this._writer",
@@ -1799,6 +1900,59 @@ var NotarizationPlugin = class {
1799
1900
  ]
1800
1901
  });
1801
1902
  this._writer = writer;
1903
+ if (this._edgeClient) {
1904
+ this._notarizePendingEdgeCredentials(this._edgeClient, writer);
1905
+ }
1906
+ }
1907
+ /**
1908
+ * The method is used only for adding agent feeds to spaces.
1909
+ * When an agent is created we can admit them into all the existing spaces. In case the operation fails
1910
+ * this method will fix it on the next space open.
1911
+ * Given how rarely this happens there's no need to poll the endpoint.
1912
+ */
1913
+ _notarizePendingEdgeCredentials(client, writer) {
1914
+ (0, import_async9.scheduleMicroTask)(this._ctx, async () => {
1915
+ try {
1916
+ const response = await client.getCredentialsForNotarization(this._spaceId, {
1917
+ retry: {
1918
+ count: MAX_EDGE_RETRIES
1919
+ }
1920
+ });
1921
+ const credentials = response.awaitingNotarization.credentials;
1922
+ if (!credentials.length) {
1923
+ (0, import_log6.log)("edge did not return credentials for notarization", void 0, {
1924
+ F: __dxlog_file7,
1925
+ L: 269,
1926
+ S: this,
1927
+ C: (f, a) => f(...a)
1928
+ });
1929
+ return;
1930
+ }
1931
+ (0, import_log6.log)("got edge credentials for notarization", {
1932
+ count: credentials.length
1933
+ }, {
1934
+ F: __dxlog_file7,
1935
+ L: 273,
1936
+ S: this,
1937
+ C: (f, a) => f(...a)
1938
+ });
1939
+ const decodedCredentials = credentials.map((credential) => {
1940
+ const binary = Buffer.from(credential, "base64");
1941
+ return credentialCodec.decode(binary);
1942
+ });
1943
+ await this._notarizeCredentials(writer, decodedCredentials);
1944
+ import_log6.log.info("notarized edge credentials", {
1945
+ count: decodedCredentials.length
1946
+ }, {
1947
+ F: __dxlog_file7,
1948
+ L: 282,
1949
+ S: this,
1950
+ C: (f, a) => f(...a)
1951
+ });
1952
+ } catch (error) {
1953
+ handleEdgeError(error);
1954
+ }
1955
+ });
1802
1956
  }
1803
1957
  async _waitUntilProcessed(id) {
1804
1958
  if (this._processedCredentials.has(id)) {
@@ -1813,10 +1967,13 @@ var NotarizationPlugin = class {
1813
1967
  if (!this._writer) {
1814
1968
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
1815
1969
  }
1816
- for (const credential of request.credentials ?? []) {
1970
+ await this._notarizeCredentials(this._writer, request.credentials ?? []);
1971
+ }
1972
+ async _notarizeCredentials(writer, credentials) {
1973
+ for (const credential of credentials) {
1817
1974
  (0, import_invariant5.invariant)(credential.id, "Credential must have an id", {
1818
1975
  F: __dxlog_file7,
1819
- L: 200,
1976
+ L: 308,
1820
1977
  S: this,
1821
1978
  A: [
1822
1979
  "credential.id",
@@ -1826,7 +1983,11 @@ var NotarizationPlugin = class {
1826
1983
  if (this._processedCredentials.has(credential.id)) {
1827
1984
  continue;
1828
1985
  }
1829
- await this._writer.write(credential);
1986
+ const verificationResult = await (0, import_credentials5.verifyCredential)(credential);
1987
+ if (verificationResult.kind === "fail") {
1988
+ throw new Error(`Credential verification failed: ${verificationResult.errors.join("\n")}.`);
1989
+ }
1990
+ await writer.write(credential);
1830
1991
  }
1831
1992
  }
1832
1993
  createExtension() {
@@ -1836,7 +1997,7 @@ var NotarizationPlugin = class {
1836
1997
  peer: extension.localPeerId
1837
1998
  }, {
1838
1999
  F: __dxlog_file7,
1839
- L: 211,
2000
+ L: 323,
1840
2001
  S: this,
1841
2002
  C: (f, a) => f(...a)
1842
2003
  });
@@ -1848,7 +2009,7 @@ var NotarizationPlugin = class {
1848
2009
  peer: extension.localPeerId
1849
2010
  }, {
1850
2011
  F: __dxlog_file7,
1851
- L: 216,
2012
+ L: 328,
1852
2013
  S: this,
1853
2014
  C: (f, a) => f(...a)
1854
2015
  });
@@ -1858,6 +2019,43 @@ var NotarizationPlugin = class {
1858
2019
  });
1859
2020
  return extension;
1860
2021
  }
2022
+ _scheduleTimeout(ctx, errors, timeout) {
2023
+ (0, import_async9.scheduleTask)(ctx, () => {
2024
+ import_log6.log.warn("Notarization timeout", {
2025
+ timeout,
2026
+ peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2027
+ }, {
2028
+ F: __dxlog_file7,
2029
+ L: 340,
2030
+ S: this,
2031
+ C: (f, a) => f(...a)
2032
+ });
2033
+ void ctx.dispose();
2034
+ errors.throw(new import_async9.TimeoutError(timeout, "Notarization timed out"));
2035
+ }, timeout);
2036
+ }
2037
+ };
2038
+ _ts_decorate2([
2039
+ import_log6.logInfo
2040
+ ], NotarizationPlugin.prototype, "_spaceId", void 0);
2041
+ var handleEdgeError = (error) => {
2042
+ if (!(error instanceof import_protocols4.EdgeCallFailedError) || error.errorData) {
2043
+ import_log6.log.catch(error, void 0, {
2044
+ F: __dxlog_file7,
2045
+ L: 354,
2046
+ S: void 0,
2047
+ C: (f, a) => f(...a)
2048
+ });
2049
+ } else {
2050
+ import_log6.log.info("Edge notarization failure", {
2051
+ reason: error.reason
2052
+ }, {
2053
+ F: __dxlog_file7,
2054
+ L: 356,
2055
+ S: void 0,
2056
+ C: (f, a) => f(...a)
2057
+ });
2058
+ }
1861
2059
  };
1862
2060
  var NotarizationTeleportExtension = class extends import_teleport.RpcExtension {
1863
2061
  constructor(_params) {
@@ -1898,7 +2096,7 @@ var DefaultSpaceStateMachine = class {
1898
2096
  return this._spaceId;
1899
2097
  }
1900
2098
  async processCredential(credential) {
1901
- const assertion = (0, import_credentials7.getCredentialAssertion)(credential);
2099
+ const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
1902
2100
  switch (assertion["@type"]) {
1903
2101
  case "dxos.halo.credentials.DefaultSpace": {
1904
2102
  if (!credential.subject.id.equals(this._params.identityKey)) {
@@ -1932,7 +2130,7 @@ var DefaultSpaceStateMachine = class {
1932
2130
  };
1933
2131
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1934
2132
  const credentials = [
1935
- await (0, import_credentials10.createCredential)({
2133
+ await (0, import_credentials11.createCredential)({
1936
2134
  signer: keyring,
1937
2135
  issuer: space.key,
1938
2136
  subject: space.key,
@@ -1941,14 +2139,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1941
2139
  spaceKey: space.key
1942
2140
  }
1943
2141
  }),
1944
- await (0, import_credentials10.createCredential)({
2142
+ await (0, import_credentials11.createCredential)({
1945
2143
  signer: keyring,
1946
2144
  issuer: space.key,
1947
2145
  subject: signingContext.identityKey,
1948
2146
  assertion: {
1949
2147
  "@type": "dxos.halo.credentials.SpaceMember",
1950
2148
  spaceKey: space.key,
1951
- role: import_credentials11.SpaceMember.Role.OWNER,
2149
+ role: import_credentials12.SpaceMember.Role.OWNER,
1952
2150
  profile: signingContext.getProfile(),
1953
2151
  genesisFeedKey: space.controlFeedKey ?? (0, import_debug2.failUndefined)()
1954
2152
  }
@@ -1960,7 +2158,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1960
2158
  spaceKey: space.key,
1961
2159
  identityKey: signingContext.identityKey,
1962
2160
  deviceKey: signingContext.deviceKey,
1963
- designation: import_credentials11.AdmittedFeed.Designation.CONTROL
2161
+ designation: import_credentials12.AdmittedFeed.Designation.CONTROL
1964
2162
  }
1965
2163
  }),
1966
2164
  await signingContext.credentialSigner.createCredential({
@@ -1970,7 +2168,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1970
2168
  spaceKey: space.key,
1971
2169
  identityKey: signingContext.identityKey,
1972
2170
  deviceKey: signingContext.deviceKey,
1973
- designation: import_credentials11.AdmittedFeed.Designation.DATA
2171
+ designation: import_credentials12.AdmittedFeed.Designation.DATA
1974
2172
  }
1975
2173
  }),
1976
2174
  await signingContext.credentialSigner.createCredential({
@@ -1994,7 +2192,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1994
2192
  }
1995
2193
  return credentials;
1996
2194
  };
1997
- function _ts_decorate(decorators, target, key, desc) {
2195
+ function _ts_decorate3(decorators, target, key, desc) {
1998
2196
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1999
2197
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2000
2198
  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;
@@ -2011,6 +2209,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2011
2209
  this._spaces = new import_util7.ComplexMap(import_keys8.PublicKey.hash);
2012
2210
  this._instanceId = import_keys8.PublicKey.random().toHex();
2013
2211
  this._edgeConnection = void 0;
2212
+ this._edgeHttpClient = void 0;
2014
2213
  this._edgeFeatures = void 0;
2015
2214
  this._meshReplicator = void 0;
2016
2215
  this._echoEdgeReplicator = void 0;
@@ -2026,6 +2225,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2026
2225
  this._edgeConnection = params.edgeConnection;
2027
2226
  this._edgeFeatures = params.edgeFeatures;
2028
2227
  this._echoEdgeReplicator = params.echoEdgeReplicator;
2228
+ this._edgeHttpClient = params.edgeHttpClient;
2029
2229
  this._runtimeParams = params.runtimeParams;
2030
2230
  import_tracing5.trace.diagnostic({
2031
2231
  id: "spaces",
@@ -2057,15 +2257,15 @@ var DataSpaceManager = class extends import_context7.Resource {
2057
2257
  async _open() {
2058
2258
  (0, import_log9.log)("open", void 0, {
2059
2259
  F: __dxlog_file9,
2060
- L: 195,
2260
+ L: 198,
2061
2261
  S: this,
2062
2262
  C: (f, a) => f(...a)
2063
2263
  });
2064
- import_log9.log.trace("dxos.echo.data-space-manager.open", import_protocols4.trace.begin({
2264
+ import_log9.log.trace("dxos.echo.data-space-manager.open", import_protocols5.trace.begin({
2065
2265
  id: this._instanceId
2066
2266
  }), {
2067
2267
  F: __dxlog_file9,
2068
- L: 196,
2268
+ L: 199,
2069
2269
  S: this,
2070
2270
  C: (f, a) => f(...a)
2071
2271
  });
@@ -2073,7 +2273,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2073
2273
  spaces: this._metadataStore.spaces.length
2074
2274
  }, {
2075
2275
  F: __dxlog_file9,
2076
- L: 197,
2276
+ L: 200,
2077
2277
  S: this,
2078
2278
  C: (f, a) => f(...a)
2079
2279
  });
@@ -2083,7 +2283,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2083
2283
  spaceMetadata
2084
2284
  }, {
2085
2285
  F: __dxlog_file9,
2086
- L: 201,
2286
+ L: 204,
2087
2287
  S: this,
2088
2288
  C: (f, a) => f(...a)
2089
2289
  });
@@ -2094,18 +2294,18 @@ var DataSpaceManager = class extends import_context7.Resource {
2094
2294
  err
2095
2295
  }, {
2096
2296
  F: __dxlog_file9,
2097
- L: 204,
2297
+ L: 207,
2098
2298
  S: this,
2099
2299
  C: (f, a) => f(...a)
2100
2300
  });
2101
2301
  }
2102
2302
  });
2103
2303
  this.updated.emit();
2104
- import_log9.log.trace("dxos.echo.data-space-manager.open", import_protocols4.trace.end({
2304
+ import_log9.log.trace("dxos.echo.data-space-manager.open", import_protocols5.trace.end({
2105
2305
  id: this._instanceId
2106
2306
  }), {
2107
2307
  F: __dxlog_file9,
2108
- L: 210,
2308
+ L: 213,
2109
2309
  S: this,
2110
2310
  C: (f, a) => f(...a)
2111
2311
  });
@@ -2113,7 +2313,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2113
2313
  async _close() {
2114
2314
  (0, import_log9.log)("close", void 0, {
2115
2315
  F: __dxlog_file9,
2116
- L: 215,
2316
+ L: 218,
2117
2317
  S: this,
2118
2318
  C: (f, a) => f(...a)
2119
2319
  });
@@ -2128,7 +2328,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2128
2328
  async createSpace() {
2129
2329
  (0, import_invariant7.invariant)(this._lifecycleState === import_context7.LifecycleState.OPEN, "Not open.", {
2130
2330
  F: __dxlog_file9,
2131
- L: 227,
2331
+ L: 230,
2132
2332
  S: this,
2133
2333
  A: [
2134
2334
  "this._lifecycleState === LifecycleState.OPEN",
@@ -2149,7 +2349,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2149
2349
  spaceKey
2150
2350
  }, {
2151
2351
  F: __dxlog_file9,
2152
- L: 239,
2352
+ L: 242,
2153
2353
  S: this,
2154
2354
  C: (f, a) => f(...a)
2155
2355
  });
@@ -2159,9 +2359,9 @@ var DataSpaceManager = class extends import_context7.Resource {
2159
2359
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
2160
2360
  await this._metadataStore.addSpace(metadata);
2161
2361
  const memberCredential = credentials[1];
2162
- (0, import_invariant7.invariant)((0, import_credentials8.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2362
+ (0, import_invariant7.invariant)((0, import_credentials9.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2163
2363
  F: __dxlog_file9,
2164
- L: 249,
2364
+ L: 252,
2165
2365
  S: this,
2166
2366
  A: [
2167
2367
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2193,7 +2393,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2193
2393
  spaceId: space.id
2194
2394
  }, {
2195
2395
  F: __dxlog_file9,
2196
- L: 274,
2396
+ L: 277,
2197
2397
  S: this,
2198
2398
  C: (f, a) => f(...a)
2199
2399
  });
@@ -2228,7 +2428,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2228
2428
  const automergeIndex = space.automergeSpaceState.rootUrl;
2229
2429
  (0, import_invariant7.invariant)(automergeIndex, void 0, {
2230
2430
  F: __dxlog_file9,
2231
- L: 307,
2431
+ L: 310,
2232
2432
  S: this,
2233
2433
  A: [
2234
2434
  "automergeIndex",
@@ -2245,13 +2445,13 @@ var DataSpaceManager = class extends import_context7.Resource {
2245
2445
  opts
2246
2446
  }, {
2247
2447
  F: __dxlog_file9,
2248
- L: 316,
2448
+ L: 319,
2249
2449
  S: this,
2250
2450
  C: (f, a) => f(...a)
2251
2451
  });
2252
2452
  (0, import_invariant7.invariant)(this._lifecycleState === import_context7.LifecycleState.OPEN, "Not open.", {
2253
2453
  F: __dxlog_file9,
2254
- L: 317,
2454
+ L: 320,
2255
2455
  S: this,
2256
2456
  A: [
2257
2457
  "this._lifecycleState === LifecycleState.OPEN",
@@ -2260,7 +2460,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2260
2460
  });
2261
2461
  (0, import_invariant7.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
2262
2462
  F: __dxlog_file9,
2263
- L: 318,
2463
+ L: 321,
2264
2464
  S: this,
2265
2465
  A: [
2266
2466
  "!this._spaces.has(opts.spaceKey)",
@@ -2284,20 +2484,20 @@ var DataSpaceManager = class extends import_context7.Resource {
2284
2484
  const space = this._spaceManager.spaces.get(options.spaceKey);
2285
2485
  (0, import_invariant7.invariant)(space, void 0, {
2286
2486
  F: __dxlog_file9,
2287
- L: 338,
2487
+ L: 341,
2288
2488
  S: this,
2289
2489
  A: [
2290
2490
  "space",
2291
2491
  ""
2292
2492
  ]
2293
2493
  });
2294
- if (space.spaceState.getMemberRole(options.identityKey) !== import_credentials9.SpaceMember.Role.REMOVED) {
2295
- throw new import_protocols4.AlreadyJoinedError();
2494
+ if (space.spaceState.getMemberRole(options.identityKey) !== import_credentials10.SpaceMember.Role.REMOVED) {
2495
+ throw new import_protocols5.AlreadyJoinedError();
2296
2496
  }
2297
- const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
2497
+ const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
2298
2498
  (0, import_invariant7.invariant)(credentials[0].credential, void 0, {
2299
2499
  F: __dxlog_file9,
2300
- L: 357,
2500
+ L: 360,
2301
2501
  S: this,
2302
2502
  A: [
2303
2503
  "credentials[0].credential",
@@ -2305,9 +2505,9 @@ var DataSpaceManager = class extends import_context7.Resource {
2305
2505
  ]
2306
2506
  });
2307
2507
  const spaceMemberCredential = credentials[0].credential.credential;
2308
- (0, import_invariant7.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2508
+ (0, import_invariant7.invariant)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2309
2509
  F: __dxlog_file9,
2310
- L: 359,
2510
+ L: 362,
2311
2511
  S: this,
2312
2512
  A: [
2313
2513
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2346,7 +2546,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2346
2546
  metadata
2347
2547
  }, {
2348
2548
  F: __dxlog_file9,
2349
- L: 395,
2549
+ L: 398,
2350
2550
  S: this,
2351
2551
  C: (f, a) => f(...a)
2352
2552
  });
@@ -2390,7 +2590,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2390
2590
  err
2391
2591
  }, {
2392
2592
  F: __dxlog_file9,
2393
- L: 437,
2593
+ L: 440,
2394
2594
  S: this,
2395
2595
  C: (f, a) => f(...a)
2396
2596
  });
@@ -2400,7 +2600,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2400
2600
  onAuthFailure: () => {
2401
2601
  import_log9.log.warn("auth failure", void 0, {
2402
2602
  F: __dxlog_file9,
2403
- L: 442,
2603
+ L: 445,
2404
2604
  S: this,
2405
2605
  C: (f, a) => f(...a)
2406
2606
  });
@@ -2433,7 +2633,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2433
2633
  space: space.key
2434
2634
  }, {
2435
2635
  F: __dxlog_file9,
2436
- L: 469,
2636
+ L: 472,
2437
2637
  S: this,
2438
2638
  C: (f, a) => f(...a)
2439
2639
  });
@@ -2444,7 +2644,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2444
2644
  open: this._lifecycleState === import_context7.LifecycleState.OPEN
2445
2645
  }, {
2446
2646
  F: __dxlog_file9,
2447
- L: 472,
2647
+ L: 475,
2448
2648
  S: this,
2449
2649
  C: (f, a) => f(...a)
2450
2650
  });
@@ -2463,7 +2663,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2463
2663
  space: space.key
2464
2664
  }, {
2465
2665
  F: __dxlog_file9,
2466
- L: 480,
2666
+ L: 483,
2467
2667
  S: this,
2468
2668
  C: (f, a) => f(...a)
2469
2669
  });
@@ -2471,6 +2671,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2471
2671
  },
2472
2672
  cache: metadata.cache,
2473
2673
  edgeConnection: this._edgeConnection,
2674
+ edgeHttpClient: this._edgeHttpClient,
2474
2675
  edgeFeatures: this._edgeFeatures
2475
2676
  });
2476
2677
  dataSpace.postOpen.append(async () => {
@@ -2497,7 +2698,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2497
2698
  space: space.key
2498
2699
  }, {
2499
2700
  F: __dxlog_file9,
2500
- L: 511,
2701
+ L: 515,
2501
2702
  S: this,
2502
2703
  C: (f, a) => f(...a)
2503
2704
  });
@@ -2517,7 +2718,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2517
2718
  const peers = presence.getPeersByIdentityKey(member.key);
2518
2719
  const sessions = peers.map((p) => p.peerId && spaceProtocol.sessions.get(p.peerId));
2519
2720
  const sessionsToClose = sessions.filter((s) => {
2520
- return (s && member.role === import_credentials9.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline3.AuthStatus.FAILURE)) ?? false;
2721
+ return (s && member.role === import_credentials10.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline3.AuthStatus.FAILURE)) ?? false;
2521
2722
  });
2522
2723
  sessionsToClose.forEach((session) => {
2523
2724
  void session.close().catch(import_log9.log.error);
@@ -2530,7 +2731,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2530
2731
  closedSessions
2531
2732
  }, {
2532
2733
  F: __dxlog_file9,
2533
- L: 537,
2734
+ L: 541,
2534
2735
  S: this,
2535
2736
  C: (f, a) => f(...a)
2536
2737
  });
@@ -2538,14 +2739,14 @@ var DataSpaceManager = class extends import_context7.Resource {
2538
2739
  }
2539
2740
  _handleNewPeerConnected(space, peerState) {
2540
2741
  const role = space.spaceState.getMemberRole(peerState.identityKey);
2541
- if (role === import_credentials9.SpaceMember.Role.REMOVED) {
2742
+ if (role === import_credentials10.SpaceMember.Role.REMOVED) {
2542
2743
  const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
2543
2744
  if (session != null) {
2544
2745
  (0, import_log9.log)("closing a session with a removed peer", {
2545
2746
  peerId: peerState.peerId
2546
2747
  }, {
2547
2748
  F: __dxlog_file9,
2548
- L: 551,
2749
+ L: 555,
2549
2750
  S: this,
2550
2751
  C: (f, a) => f(...a)
2551
2752
  });
@@ -2589,19 +2790,19 @@ var DataSpaceManager = class extends import_context7.Resource {
2589
2790
  await Promise.all(tasks);
2590
2791
  }
2591
2792
  };
2592
- _ts_decorate([
2793
+ _ts_decorate3([
2593
2794
  import_async11.synchronized
2594
2795
  ], DataSpaceManager.prototype, "_open", null);
2595
- _ts_decorate([
2796
+ _ts_decorate3([
2596
2797
  import_async11.synchronized
2597
2798
  ], DataSpaceManager.prototype, "_close", null);
2598
- _ts_decorate([
2799
+ _ts_decorate3([
2599
2800
  import_async11.synchronized
2600
2801
  ], DataSpaceManager.prototype, "createSpace", null);
2601
- _ts_decorate([
2802
+ _ts_decorate3([
2602
2803
  import_async11.synchronized
2603
2804
  ], DataSpaceManager.prototype, "acceptSpace", null);
2604
- DataSpaceManager = _ts_decorate([
2805
+ DataSpaceManager = _ts_decorate3([
2605
2806
  (0, import_async11.trackLeaks)("open", "close")
2606
2807
  ], DataSpaceManager);
2607
2808
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
@@ -2620,7 +2821,7 @@ var SpacesServiceImpl = class {
2620
2821
  }
2621
2822
  async updateSpace({ spaceKey, state }) {
2622
2823
  const dataSpaceManager = await this._getDataSpaceManager();
2623
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols5.SpaceNotFoundError(spaceKey));
2824
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2624
2825
  if (state) {
2625
2826
  switch (state) {
2626
2827
  case import_services7.SpaceState.SPACE_ACTIVE:
@@ -2630,7 +2831,7 @@ var SpacesServiceImpl = class {
2630
2831
  await space.deactivate();
2631
2832
  break;
2632
2833
  default:
2633
- throw new import_protocols5.ApiError("Invalid space state");
2834
+ throw new import_protocols6.ApiError("Invalid space state");
2634
2835
  }
2635
2836
  }
2636
2837
  }
@@ -2638,15 +2839,15 @@ var SpacesServiceImpl = class {
2638
2839
  const identity = this._requireIdentity();
2639
2840
  const space = this._spaceManager.spaces.get(request.spaceKey);
2640
2841
  if (space == null) {
2641
- throw new import_protocols5.SpaceNotFoundError(request.spaceKey);
2842
+ throw new import_protocols6.SpaceNotFoundError(request.spaceKey);
2642
2843
  }
2643
2844
  if (!space.spaceState.hasMembershipManagementPermission(identity.identityKey)) {
2644
- throw new import_protocols5.AuthorizationError("No member management permission.", {
2845
+ throw new import_protocols6.AuthorizationError("No member management permission.", {
2645
2846
  spaceKey: space.key,
2646
2847
  role: space.spaceState.getMemberRole(identity.identityKey)
2647
2848
  });
2648
2849
  }
2649
- const credentials = await (0, import_credentials12.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2850
+ const credentials = await (0, import_credentials13.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2650
2851
  (0, import_invariant8.invariant)(credentials[0].credential, void 0, {
2651
2852
  F: __dxlog_file10,
2652
2853
  L: 102,
@@ -2657,7 +2858,7 @@ var SpacesServiceImpl = class {
2657
2858
  ]
2658
2859
  });
2659
2860
  const spaceMemberCredential = credentials[0].credential.credential;
2660
- (0, import_invariant8.invariant)((0, import_credentials12.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2861
+ (0, import_invariant8.invariant)((0, import_credentials13.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2661
2862
  F: __dxlog_file10,
2662
2863
  L: 104,
2663
2864
  S: this,
@@ -2725,14 +2926,14 @@ var SpacesServiceImpl = class {
2725
2926
  }
2726
2927
  async postMessage({ spaceKey, channel, message }) {
2727
2928
  const dataSpaceManager = await this._getDataSpaceManager();
2728
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols5.SpaceNotFoundError(spaceKey));
2929
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2729
2930
  await space.postMessage(getChannelId(channel), message);
2730
2931
  }
2731
2932
  subscribeMessages({ spaceKey, channel }) {
2732
2933
  return new import_codec_protobuf8.Stream(({ ctx, next }) => {
2733
2934
  (0, import_async12.scheduleTask)(ctx, async () => {
2734
2935
  const dataSpaceManager = await this._getDataSpaceManager();
2735
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols5.SpaceNotFoundError(spaceKey));
2936
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2736
2937
  const handle = space.listen(getChannelId(channel), (message) => {
2737
2938
  next(message);
2738
2939
  });
@@ -2742,7 +2943,7 @@ var SpacesServiceImpl = class {
2742
2943
  }
2743
2944
  queryCredentials({ spaceKey, noTail }) {
2744
2945
  return new import_codec_protobuf8.Stream(({ ctx, next, close }) => {
2745
- const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols5.SpaceNotFoundError(spaceKey));
2946
+ const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2746
2947
  const processor = {
2747
2948
  processCredential: async (credential) => {
2748
2949
  next(credential);
@@ -2758,7 +2959,7 @@ var SpacesServiceImpl = class {
2758
2959
  });
2759
2960
  }
2760
2961
  async writeCredentials({ spaceKey, credentials }) {
2761
- const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols5.SpaceNotFoundError(spaceKey));
2962
+ const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2762
2963
  for (const credential of credentials ?? []) {
2763
2964
  if (credential.proof) {
2764
2965
  await space.controlPipeline.writer.write({
@@ -2809,7 +3010,7 @@ var SpacesServiceImpl = class {
2809
3010
  }
2810
3011
  async createEpoch({ spaceKey, migration, automergeRootUrl }) {
2811
3012
  const dataSpaceManager = await this._getDataSpaceManager();
2812
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols5.SpaceNotFoundError(spaceKey));
3013
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2813
3014
  const result = await space.createEpoch({
2814
3015
  migration,
2815
3016
  newAutomergeRoot: automergeRootUrl
@@ -2835,7 +3036,7 @@ var SpacesServiceImpl = class {
2835
3036
  });
2836
3037
  }
2837
3038
  async _joinByAdmission({ credential }) {
2838
- const assertion = (0, import_credentials12.getCredentialAssertion)(credential);
3039
+ const assertion = (0, import_credentials13.getCredentialAssertion)(credential);
2839
3040
  (0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2840
3041
  F: __dxlog_file10,
2841
3042
  L: 250,
@@ -2877,7 +3078,7 @@ var SpacesServiceImpl = class {
2877
3078
  id: space.id,
2878
3079
  spaceKey: space.key,
2879
3080
  state: space.state,
2880
- error: space.error ? (0, import_protocols5.encodeError)(space.error) : void 0,
3081
+ error: space.error ? (0, import_protocols6.encodeError)(space.error) : void 0,
2881
3082
  pipeline: {
2882
3083
  currentEpoch: space.automergeSpaceState.lastEpoch,
2883
3084
  appliedEpoch: space.automergeSpaceState.lastEpoch,
@@ -2915,7 +3116,7 @@ var SpacesServiceImpl = class {
2915
3116
  }
2916
3117
  _requireIdentity() {
2917
3118
  if (!this._identityManager.identity) {
2918
- throw new import_protocols5.IdentityNotInitializedError("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
3119
+ throw new import_protocols6.IdentityNotInitializedError("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
2919
3120
  }
2920
3121
  return this._identityManager.identity;
2921
3122
  }
@@ -2932,7 +3133,7 @@ var SpacesServiceImpl = class {
2932
3133
  }
2933
3134
  };
2934
3135
  var getChannelId = (channel) => `user-channel/${channel}`;
2935
- function _ts_decorate2(decorators, target, key, desc) {
3136
+ function _ts_decorate4(decorators, target, key, desc) {
2936
3137
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2937
3138
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2938
3139
  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;
@@ -2959,12 +3160,12 @@ var Identity = class {
2959
3160
  S: this,
2960
3161
  C: (f, a) => f(...a)
2961
3162
  });
2962
- this._deviceStateMachine = new import_credentials5.DeviceStateMachine({
3163
+ this._deviceStateMachine = new import_credentials6.DeviceStateMachine({
2963
3164
  identityKey: this.identityKey,
2964
3165
  deviceKey: this.deviceKey,
2965
3166
  onUpdate: () => this.stateUpdate.emit()
2966
3167
  });
2967
- this._profileStateMachine = new import_credentials5.ProfileStateMachine({
3168
+ this._profileStateMachine = new import_credentials6.ProfileStateMachine({
2968
3169
  identityKey: this.identityKey,
2969
3170
  onUpdate: () => this.stateUpdate.emit()
2970
3171
  });
@@ -3041,6 +3242,9 @@ var Identity = class {
3041
3242
  get presence() {
3042
3243
  return this._presence;
3043
3244
  }
3245
+ get signer() {
3246
+ return this._signer;
3247
+ }
3044
3248
  /**
3045
3249
  * Issues credentials as identity.
3046
3250
  * Requires identity to be ready.
@@ -3048,20 +3252,20 @@ var Identity = class {
3048
3252
  getIdentityCredentialSigner() {
3049
3253
  (0, import_invariant6.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
3050
3254
  F: __dxlog_file11,
3051
- L: 185,
3255
+ L: 189,
3052
3256
  S: this,
3053
3257
  A: [
3054
3258
  "this._deviceStateMachine.deviceCredentialChain",
3055
3259
  "'Device credential chain is not ready.'"
3056
3260
  ]
3057
3261
  });
3058
- return (0, import_credentials5.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
3262
+ return (0, import_credentials6.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
3059
3263
  }
3060
3264
  /**
3061
3265
  * Issues credentials as device.
3062
3266
  */
3063
3267
  getDeviceCredentialSigner() {
3064
- return (0, import_credentials5.createCredentialSignerWithKey)(this._signer, this.deviceKey);
3268
+ return (0, import_credentials6.createCredentialSignerWithKey)(this._signer, this.deviceKey);
3065
3269
  }
3066
3270
  async updateDefaultSpace(spaceId) {
3067
3271
  const credential = await this.getDeviceCredentialSigner().createCredential({
@@ -3092,7 +3296,7 @@ var Identity = class {
3092
3296
  dataFeedKey
3093
3297
  }, {
3094
3298
  F: __dxlog_file11,
3095
- L: 210,
3299
+ L: 214,
3096
3300
  S: this,
3097
3301
  C: (f, a) => f(...a)
3098
3302
  });
@@ -3113,7 +3317,7 @@ var Identity = class {
3113
3317
  spaceKey: this.haloSpaceKey,
3114
3318
  deviceKey,
3115
3319
  identityKey: this.identityKey,
3116
- designation: import_credentials6.AdmittedFeed.Designation.CONTROL
3320
+ designation: import_credentials7.AdmittedFeed.Designation.CONTROL
3117
3321
  }
3118
3322
  }),
3119
3323
  await signer.createCredential({
@@ -3123,7 +3327,7 @@ var Identity = class {
3123
3327
  spaceKey: this.haloSpaceKey,
3124
3328
  deviceKey,
3125
3329
  identityKey: this.identityKey,
3126
- designation: import_credentials6.AdmittedFeed.Designation.DATA
3330
+ designation: import_credentials7.AdmittedFeed.Designation.DATA
3127
3331
  }
3128
3332
  })
3129
3333
  ].map((credential) => ({
@@ -3133,16 +3337,16 @@ var Identity = class {
3133
3337
  })));
3134
3338
  }
3135
3339
  };
3136
- _ts_decorate2([
3340
+ _ts_decorate4([
3137
3341
  import_tracing4.trace.span()
3138
3342
  ], Identity.prototype, "open", null);
3139
- _ts_decorate2([
3343
+ _ts_decorate4([
3140
3344
  import_tracing4.trace.span()
3141
3345
  ], Identity.prototype, "close", null);
3142
- Identity = _ts_decorate2([
3346
+ Identity = _ts_decorate4([
3143
3347
  import_tracing4.trace.resource()
3144
3348
  ], Identity);
3145
- function _ts_decorate3(decorators, target, key, desc) {
3349
+ function _ts_decorate5(decorators, target, key, desc) {
3146
3350
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3147
3351
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3148
3352
  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;
@@ -3170,7 +3374,7 @@ var IdentityManager = class {
3170
3374
  }
3171
3375
  async open(ctx) {
3172
3376
  const traceId = import_keys9.PublicKey.random().toHex();
3173
- import_log11.log.trace("dxos.halo.identity-manager.open", import_protocols6.trace.begin({
3377
+ import_log11.log.trace("dxos.halo.identity-manager.open", import_protocols7.trace.begin({
3174
3378
  id: traceId
3175
3379
  }), {
3176
3380
  F: __dxlog_file12,
@@ -3202,7 +3406,7 @@ var IdentityManager = class {
3202
3406
  });
3203
3407
  this.stateUpdate.emit();
3204
3408
  }
3205
- import_log11.log.trace("dxos.halo.identity-manager.open", import_protocols6.trace.end({
3409
+ import_log11.log.trace("dxos.halo.identity-manager.open", import_protocols7.trace.end({
3206
3410
  id: traceId
3207
3411
  }), {
3208
3412
  F: __dxlog_file12,
@@ -3250,7 +3454,7 @@ var IdentityManager = class {
3250
3454
  L: 161
3251
3455
  }));
3252
3456
  {
3253
- const generator = new import_credentials13.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
3457
+ const generator = new import_credentials14.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
3254
3458
  (0, import_invariant9.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
3255
3459
  F: __dxlog_file12,
3256
3460
  L: 165,
@@ -3273,7 +3477,7 @@ var IdentityManager = class {
3273
3477
  // Space genesis.
3274
3478
  ...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
3275
3479
  // Feed admission.
3276
- await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials14.AdmittedFeed.Designation.DATA)
3480
+ await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials15.AdmittedFeed.Designation.DATA)
3277
3481
  ];
3278
3482
  if (displayName) {
3279
3483
  credentials.push(await generator.createProfileCredential({
@@ -3322,14 +3526,14 @@ var IdentityManager = class {
3322
3526
  createDefaultDeviceProfile() {
3323
3527
  let type;
3324
3528
  if ((0, import_util8.isNode)()) {
3325
- type = import_credentials14.DeviceType.AGENT;
3529
+ type = import_credentials15.DeviceType.AGENT;
3326
3530
  } else {
3327
3531
  if (import_platform.default.name?.startsWith("iOS") || import_platform.default.name?.startsWith("Android")) {
3328
- type = import_credentials14.DeviceType.MOBILE;
3532
+ type = import_credentials15.DeviceType.MOBILE;
3329
3533
  } else if (globalThis.__args) {
3330
- type = import_credentials14.DeviceType.NATIVE;
3534
+ type = import_credentials15.DeviceType.NATIVE;
3331
3535
  } else {
3332
- type = import_credentials14.DeviceType.BROWSER;
3536
+ type = import_credentials15.DeviceType.BROWSER;
3333
3537
  }
3334
3538
  }
3335
3539
  return {
@@ -3533,7 +3737,7 @@ var IdentityManager = class {
3533
3737
  swarmIdentity: {
3534
3738
  identityKey: identityRecord.identityKey,
3535
3739
  peerKey: identityRecord.deviceKey,
3536
- credentialProvider: createAuthProvider((0, import_credentials13.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
3740
+ credentialProvider: createAuthProvider((0, import_credentials14.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
3537
3741
  credentialAuthenticator: (0, import_util8.deferFunction)(() => identity.authVerifier.verifier)
3538
3742
  },
3539
3743
  gossip,
@@ -3593,12 +3797,12 @@ var IdentityManager = class {
3593
3797
  });
3594
3798
  }
3595
3799
  };
3596
- _ts_decorate3([
3800
+ _ts_decorate5([
3597
3801
  import_tracing7.trace.span({
3598
3802
  showInBrowserTimeline: true
3599
3803
  })
3600
3804
  ], IdentityManager.prototype, "open", null);
3601
- IdentityManager = _ts_decorate3([
3805
+ IdentityManager = _ts_decorate5([
3602
3806
  import_tracing7.trace.resource()
3603
3807
  ], IdentityManager);
3604
3808
  var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
@@ -3688,7 +3892,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3688
3892
  "'Identity not initialized.'"
3689
3893
  ]
3690
3894
  });
3691
- return await (0, import_credentials15.signPresentation)({
3895
+ return await (0, import_credentials16.signPresentation)({
3692
3896
  presentation,
3693
3897
  signer: this._keyring,
3694
3898
  signerKey: this._identityManager.identity.deviceKey,
@@ -3745,7 +3949,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3745
3949
  }
3746
3950
  }
3747
3951
  };
3748
- function _ts_decorate4(decorators, target, key, desc) {
3952
+ function _ts_decorate6(decorators, target, key, desc) {
3749
3953
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3750
3954
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3751
3955
  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;
@@ -3818,9 +4022,8 @@ var DataSpace = class {
3818
4022
  constructor(params) {
3819
4023
  this._ctx = new import_context4.Context(void 0, {
3820
4024
  F: __dxlog_file14,
3821
- L: 94
4025
+ L: 95
3822
4026
  });
3823
- this._notarizationPlugin = new NotarizationPlugin();
3824
4027
  this._cache = void 0;
3825
4028
  this._edgeFeedReplicator = void 0;
3826
4029
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
@@ -3845,6 +4048,11 @@ var DataSpace = class {
3845
4048
  this._signingContext = params.signingContext;
3846
4049
  this._callbacks = params.callbacks ?? {};
3847
4050
  this._echoHost = params.echoHost;
4051
+ this._notarizationPlugin = new NotarizationPlugin({
4052
+ spaceId: this._inner.id,
4053
+ edgeClient: params.edgeHttpClient,
4054
+ edgeFeatures: params.edgeFeatures
4055
+ });
3848
4056
  this.authVerifier = new TrustedKeySetAuthVerifier({
3849
4057
  trustedKeysProvider: () => new import_util4.ComplexSet(import_keys4.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== import_credentials3.SpaceMember.Role.REMOVED).map((member) => member.key)),
3850
4058
  update: this._inner.stateUpdate,
@@ -3862,7 +4070,7 @@ var DataSpace = class {
3862
4070
  state: import_services4.SpaceState[this._state]
3863
4071
  }, {
3864
4072
  F: __dxlog_file14,
3865
- L: 164,
4073
+ L: 170,
3866
4074
  S: this,
3867
4075
  C: (f, a) => f(...a)
3868
4076
  });
@@ -3921,7 +4129,7 @@ var DataSpace = class {
3921
4129
  }
3922
4130
  await this._inner.open(new import_context4.Context(void 0, {
3923
4131
  F: __dxlog_file14,
3924
- L: 238
4132
+ L: 244
3925
4133
  }));
3926
4134
  await this._edgeFeedReplicator?.open();
3927
4135
  this._state = import_services4.SpaceState.SPACE_CONTROL_ONLY;
@@ -3929,7 +4137,7 @@ var DataSpace = class {
3929
4137
  state: import_services4.SpaceState[this._state]
3930
4138
  }, {
3931
4139
  F: __dxlog_file14,
3932
- L: 243,
4140
+ L: 249,
3933
4141
  S: this,
3934
4142
  C: (f, a) => f(...a)
3935
4143
  });
@@ -3949,14 +4157,14 @@ var DataSpace = class {
3949
4157
  state: import_services4.SpaceState[this._state]
3950
4158
  }, {
3951
4159
  F: __dxlog_file14,
3952
- L: 262,
4160
+ L: 268,
3953
4161
  S: this,
3954
4162
  C: (f, a) => f(...a)
3955
4163
  });
3956
4164
  await this._ctx.dispose();
3957
4165
  this._ctx = new import_context4.Context(void 0, {
3958
4166
  F: __dxlog_file14,
3959
- L: 264
4167
+ L: 270
3960
4168
  });
3961
4169
  if (this._edgeFeedReplicator) {
3962
4170
  this.inner.protocol.feedAdded.remove(this._onFeedAdded);
@@ -3989,7 +4197,7 @@ var DataSpace = class {
3989
4197
  if (err instanceof import_protocols3.CancelledError || err instanceof import_context4.ContextDisposedError) {
3990
4198
  (0, import_log4.log)("data pipeline initialization cancelled", err, {
3991
4199
  F: __dxlog_file14,
3992
- L: 302,
4200
+ L: 308,
3993
4201
  S: this,
3994
4202
  C: (f, a) => f(...a)
3995
4203
  });
@@ -3997,7 +4205,7 @@ var DataSpace = class {
3997
4205
  }
3998
4206
  import_log4.log.error("Error initializing data pipeline", err, {
3999
4207
  F: __dxlog_file14,
4000
- L: 306,
4208
+ L: 312,
4001
4209
  S: this,
4002
4210
  C: (f, a) => f(...a)
4003
4211
  });
@@ -4006,7 +4214,7 @@ var DataSpace = class {
4006
4214
  state: import_services4.SpaceState[this._state]
4007
4215
  }, {
4008
4216
  F: __dxlog_file14,
4009
- L: 308,
4217
+ L: 314,
4010
4218
  S: this,
4011
4219
  C: (f, a) => f(...a)
4012
4220
  });
@@ -4026,15 +4234,39 @@ var DataSpace = class {
4026
4234
  state: import_services4.SpaceState[this._state]
4027
4235
  }, {
4028
4236
  F: __dxlog_file14,
4029
- L: 324,
4237
+ L: 330,
4238
+ S: this,
4239
+ C: (f, a) => f(...a)
4240
+ });
4241
+ (0, import_log4.log)("initializing control pipeline", void 0, {
4242
+ F: __dxlog_file14,
4243
+ L: 332,
4030
4244
  S: this,
4031
4245
  C: (f, a) => f(...a)
4032
4246
  });
4033
4247
  await this._initializeAndReadControlPipeline();
4034
4248
  await (0, import_async7.sleep)(1);
4035
4249
  const ready = this.stateUpdate.waitForCondition(() => this._state === import_services4.SpaceState.SPACE_READY);
4250
+ (0, import_log4.log)("initializing automerge root", void 0, {
4251
+ F: __dxlog_file14,
4252
+ L: 340,
4253
+ S: this,
4254
+ C: (f, a) => f(...a)
4255
+ });
4036
4256
  this._automergeSpaceState.startProcessingRootDocs();
4257
+ (0, import_log4.log)("waiting for space to be ready", void 0, {
4258
+ F: __dxlog_file14,
4259
+ L: 344,
4260
+ S: this,
4261
+ C: (f, a) => f(...a)
4262
+ });
4037
4263
  await ready;
4264
+ (0, import_log4.log)("space is ready", void 0, {
4265
+ F: __dxlog_file14,
4266
+ L: 346,
4267
+ S: this,
4268
+ C: (f, a) => f(...a)
4269
+ });
4038
4270
  }
4039
4271
  async _enterReadyState() {
4040
4272
  await this._callbacks.beforeReady?.();
@@ -4043,7 +4275,7 @@ var DataSpace = class {
4043
4275
  state: import_services4.SpaceState[this._state]
4044
4276
  }, {
4045
4277
  F: __dxlog_file14,
4046
- L: 343,
4278
+ L: 353,
4047
4279
  S: this,
4048
4280
  C: (f, a) => f(...a)
4049
4281
  });
@@ -4053,13 +4285,14 @@ var DataSpace = class {
4053
4285
  async _initializeAndReadControlPipeline() {
4054
4286
  await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
4055
4287
  ctx: this._ctx,
4288
+ timeout: 1e4,
4056
4289
  breakOnStall: false
4057
4290
  });
4058
4291
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
4059
4292
  await this._createWritableFeeds();
4060
4293
  (0, import_log4.log)("writable feeds created", void 0, {
4061
4294
  F: __dxlog_file14,
4062
- L: 359,
4295
+ L: 370,
4063
4296
  S: this,
4064
4297
  C: (f, a) => f(...a)
4065
4298
  });
@@ -4108,11 +4341,35 @@ var DataSpace = class {
4108
4341
  }));
4109
4342
  }
4110
4343
  if (credentials.length > 0) {
4111
- await this.notarizationPlugin.notarize({
4112
- ctx: this._ctx,
4113
- credentials,
4114
- timeout: 0
4115
- });
4344
+ try {
4345
+ (0, import_log4.log)("will notarize credentials for feed admission", {
4346
+ count: credentials.length
4347
+ }, {
4348
+ F: __dxlog_file14,
4349
+ L: 428,
4350
+ S: this,
4351
+ C: (f, a) => f(...a)
4352
+ });
4353
+ await this.notarizationPlugin.notarize({
4354
+ ctx: this._ctx,
4355
+ credentials,
4356
+ timeout: 0
4357
+ });
4358
+ (0, import_log4.log)("credentials notarized", void 0, {
4359
+ F: __dxlog_file14,
4360
+ L: 432,
4361
+ S: this,
4362
+ C: (f, a) => f(...a)
4363
+ });
4364
+ } catch (err) {
4365
+ import_log4.log.error("error notarizing credentials for feed admission", err, {
4366
+ F: __dxlog_file14,
4367
+ L: 434,
4368
+ S: this,
4369
+ C: (f, a) => f(...a)
4370
+ });
4371
+ throw err;
4372
+ }
4116
4373
  await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
4117
4374
  }
4118
4375
  }
@@ -4122,7 +4379,7 @@ var DataSpace = class {
4122
4379
  rootUrl
4123
4380
  }, {
4124
4381
  F: __dxlog_file14,
4125
- L: 425,
4382
+ L: 444,
4126
4383
  S: this,
4127
4384
  C: (f, a) => f(...a)
4128
4385
  });
@@ -4174,7 +4431,7 @@ var DataSpace = class {
4174
4431
  err
4175
4432
  }, {
4176
4433
  F: __dxlog_file14,
4177
- L: 468,
4434
+ L: 487,
4178
4435
  S: this,
4179
4436
  C: (f, a) => f(...a)
4180
4437
  });
@@ -4264,58 +4521,58 @@ var DataSpace = class {
4264
4521
  state: import_services4.SpaceState[this._state]
4265
4522
  }, {
4266
4523
  F: __dxlog_file14,
4267
- L: 550,
4524
+ L: 569,
4268
4525
  S: this,
4269
4526
  C: (f, a) => f(...a)
4270
4527
  });
4271
4528
  this.stateUpdate.emit();
4272
4529
  }
4273
4530
  };
4274
- _ts_decorate4([
4531
+ _ts_decorate6([
4275
4532
  import_tracing3.trace.info()
4276
4533
  ], DataSpace.prototype, "_inner", void 0);
4277
- _ts_decorate4([
4534
+ _ts_decorate6([
4278
4535
  import_tracing3.trace.info()
4279
4536
  ], DataSpace.prototype, "id", null);
4280
- _ts_decorate4([
4537
+ _ts_decorate6([
4281
4538
  import_tracing3.trace.info()
4282
4539
  ], DataSpace.prototype, "key", null);
4283
- _ts_decorate4([
4540
+ _ts_decorate6([
4284
4541
  import_tracing3.trace.info({
4285
4542
  enum: import_services4.SpaceState
4286
4543
  })
4287
4544
  ], DataSpace.prototype, "state", null);
4288
- _ts_decorate4([
4545
+ _ts_decorate6([
4289
4546
  import_tracing3.trace.info({
4290
4547
  depth: null
4291
4548
  })
4292
4549
  ], DataSpace.prototype, "_automergeInfo", null);
4293
- _ts_decorate4([
4550
+ _ts_decorate6([
4294
4551
  import_async7.synchronized
4295
4552
  ], DataSpace.prototype, "open", null);
4296
- _ts_decorate4([
4553
+ _ts_decorate6([
4297
4554
  import_async7.synchronized
4298
4555
  ], DataSpace.prototype, "close", null);
4299
- _ts_decorate4([
4556
+ _ts_decorate6([
4300
4557
  import_tracing3.trace.span({
4301
4558
  showInBrowserTimeline: true
4302
4559
  })
4303
4560
  ], DataSpace.prototype, "initializeDataPipeline", null);
4304
- _ts_decorate4([
4561
+ _ts_decorate6([
4305
4562
  import_tracing3.trace.span({
4306
4563
  showInBrowserTimeline: true
4307
4564
  })
4308
4565
  ], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
4309
- _ts_decorate4([
4566
+ _ts_decorate6([
4310
4567
  (0, import_debug.timed)(1e4)
4311
4568
  ], DataSpace.prototype, "_createWritableFeeds", null);
4312
- _ts_decorate4([
4569
+ _ts_decorate6([
4313
4570
  import_async7.synchronized
4314
4571
  ], DataSpace.prototype, "activate", null);
4315
- _ts_decorate4([
4572
+ _ts_decorate6([
4316
4573
  import_async7.synchronized
4317
4574
  ], DataSpace.prototype, "deactivate", null);
4318
- DataSpace = _ts_decorate4([
4575
+ DataSpace = _ts_decorate6([
4319
4576
  (0, import_async7.trackLeaks)("open", "close"),
4320
4577
  import_tracing3.trace.resource()
4321
4578
  ], DataSpace);
@@ -4368,7 +4625,7 @@ var DeviceInvitationProtocol = class {
4368
4625
  try {
4369
4626
  const identity = this._getIdentity();
4370
4627
  if (identity) {
4371
- return new import_protocols7.AlreadyJoinedError("Currently only one identity per client is supported.");
4628
+ return new import_protocols8.AlreadyJoinedError("Currently only one identity per client is supported.");
4372
4629
  }
4373
4630
  } catch {
4374
4631
  }
@@ -4527,7 +4784,7 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
4527
4784
  C: (f, a) => f(...a)
4528
4785
  });
4529
4786
  if (this._remoteOptions?.role !== import_invitations3.InvitationOptions.Role.HOST) {
4530
- throw new import_protocols9.InvalidInvitationExtensionRoleError(void 0, {
4787
+ throw new import_protocols10.InvalidInvitationExtensionRoleError(void 0, {
4531
4788
  expected: import_invitations3.InvitationOptions.Role.HOST,
4532
4789
  remoteOptions: this._remoteOptions,
4533
4790
  remotePeerId: context.remotePeerId
@@ -4614,7 +4871,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4614
4871
  introduce: async (request) => {
4615
4872
  const { profile, invitationId } = request;
4616
4873
  const traceId = import_keys11.PublicKey.random().toHex();
4617
- import_log15.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols10.trace.begin({
4874
+ import_log15.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols11.trace.begin({
4618
4875
  id: traceId
4619
4876
  }), {
4620
4877
  F: __dxlog_file17,
@@ -4651,7 +4908,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4651
4908
  this.guestProfile = profile;
4652
4909
  this._callbacks.onStateUpdate(import_services13.Invitation.State.READY_FOR_AUTHENTICATION);
4653
4910
  this._challenge = invitation.authMethod === import_services13.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
4654
- import_log15.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols10.trace.end({
4911
+ import_log15.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols11.trace.end({
4655
4912
  id: traceId
4656
4913
  }), {
4657
4914
  F: __dxlog_file17,
@@ -4666,7 +4923,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4666
4923
  },
4667
4924
  authenticate: async ({ authCode: code, signedChallenge }) => {
4668
4925
  const traceId = import_keys11.PublicKey.random().toHex();
4669
- import_log15.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols10.trace.begin({
4926
+ import_log15.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols11.trace.begin({
4670
4927
  id: traceId
4671
4928
  }), {
4672
4929
  F: __dxlog_file17,
@@ -4749,7 +5006,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4749
5006
  status
4750
5007
  };
4751
5008
  }
4752
- import_log15.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols10.trace.end({
5009
+ import_log15.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols11.trace.end({
4753
5010
  id: traceId,
4754
5011
  data: {
4755
5012
  status
@@ -4766,7 +5023,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4766
5023
  },
4767
5024
  admit: async (request) => {
4768
5025
  const traceId = import_keys11.PublicKey.random().toHex();
4769
- import_log15.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols10.trace.begin({
5026
+ import_log15.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols11.trace.begin({
4770
5027
  id: traceId
4771
5028
  }), {
4772
5029
  F: __dxlog_file17,
@@ -4783,7 +5040,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4783
5040
  }
4784
5041
  }
4785
5042
  const response = await this._callbacks.admit(request);
4786
- import_log15.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols10.trace.end({
5043
+ import_log15.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols11.trace.end({
4787
5044
  id: traceId
4788
5045
  }), {
4789
5046
  F: __dxlog_file17,
@@ -4838,7 +5095,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4838
5095
  });
4839
5096
  if (this._remoteOptions?.role !== import_invitations4.InvitationOptions.Role.GUEST) {
4840
5097
  this._callbacks.onStateUpdate(lastState);
4841
- throw new import_protocols10.InvalidInvitationExtensionRoleError(void 0, {
5098
+ throw new import_protocols11.InvalidInvitationExtensionRoleError(void 0, {
4842
5099
  expected: import_invitations4.InvitationOptions.Role.GUEST,
4843
5100
  remoteOptions: this._remoteOptions,
4844
5101
  remotePeerId: context.remotePeerId
@@ -5018,7 +5275,7 @@ var InvitationsHandler = class {
5018
5275
  (0, import_async15.scheduleTask)(connectionCtx, async () => {
5019
5276
  const traceId = import_keys10.PublicKey.random().toHex();
5020
5277
  try {
5021
- import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols8.trace.begin({
5278
+ import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.begin({
5022
5279
  id: traceId
5023
5280
  }), {
5024
5281
  F: __dxlog_file19,
@@ -5048,7 +5305,7 @@ var InvitationsHandler = class {
5048
5305
  });
5049
5306
  guardedState.set(extension, import_services11.Invitation.State.SUCCESS);
5050
5307
  metrics.increment("dxos.invitation.success");
5051
- import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols8.trace.end({
5308
+ import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.end({
5052
5309
  id: traceId
5053
5310
  }), {
5054
5311
  F: __dxlog_file19,
@@ -5084,7 +5341,7 @@ var InvitationsHandler = class {
5084
5341
  });
5085
5342
  }
5086
5343
  }
5087
- import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols8.trace.error({
5344
+ import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.error({
5088
5345
  id: traceId,
5089
5346
  error: err
5090
5347
  }), {
@@ -5098,7 +5355,7 @@ var InvitationsHandler = class {
5098
5355
  });
5099
5356
  },
5100
5357
  onError: (err) => {
5101
- if (err instanceof import_protocols8.InvalidInvitationExtensionRoleError) {
5358
+ if (err instanceof import_protocols9.InvalidInvitationExtensionRoleError) {
5102
5359
  (0, import_log13.log)("invalid role", {
5103
5360
  ...err.context
5104
5361
  }, {
@@ -5223,7 +5480,7 @@ var InvitationsHandler = class {
5223
5480
  (0, import_async15.scheduleTask)(connectionCtx, async () => {
5224
5481
  const traceId = import_keys10.PublicKey.random().toHex();
5225
5482
  try {
5226
- import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols8.trace.begin({
5483
+ import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.begin({
5227
5484
  id: traceId
5228
5485
  }), {
5229
5486
  F: __dxlog_file19,
@@ -5303,7 +5560,7 @@ var InvitationsHandler = class {
5303
5560
  ...result,
5304
5561
  state: import_services11.Invitation.State.SUCCESS
5305
5562
  });
5306
- import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols8.trace.end({
5563
+ import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.end({
5307
5564
  id: traceId
5308
5565
  }), {
5309
5566
  F: __dxlog_file19,
@@ -5332,7 +5589,7 @@ var InvitationsHandler = class {
5332
5589
  guardedState.error(extension, err);
5333
5590
  }
5334
5591
  extensionCtx.close(err);
5335
- import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols8.trace.error({
5592
+ import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.error({
5336
5593
  id: traceId,
5337
5594
  error: err
5338
5595
  }), {
@@ -5345,7 +5602,7 @@ var InvitationsHandler = class {
5345
5602
  });
5346
5603
  },
5347
5604
  onError: (err) => {
5348
- if (err instanceof import_protocols8.InvalidInvitationExtensionRoleError) {
5605
+ if (err instanceof import_protocols9.InvalidInvitationExtensionRoleError) {
5349
5606
  return;
5350
5607
  }
5351
5608
  if (err instanceof import_async15.TimeoutError) {
@@ -5691,14 +5948,14 @@ var SpaceInvitationProtocol = class {
5691
5948
  }
5692
5949
  checkCanInviteNewMembers() {
5693
5950
  if (this._spaceKey == null) {
5694
- return new import_protocols11.InvalidInvitationError("No spaceKey was provided for a space invitation.");
5951
+ return new import_protocols12.InvalidInvitationError("No spaceKey was provided for a space invitation.");
5695
5952
  }
5696
5953
  const space = this._spaceManager.spaces.get(this._spaceKey);
5697
5954
  if (space == null) {
5698
- return new import_protocols11.SpaceNotFoundError(this._spaceKey);
5955
+ return new import_protocols12.SpaceNotFoundError(this._spaceKey);
5699
5956
  }
5700
5957
  if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
5701
- return new import_protocols11.AuthorizationError("No member management permission.");
5958
+ return new import_protocols12.AuthorizationError("No member management permission.");
5702
5959
  }
5703
5960
  return void 0;
5704
5961
  }
@@ -5730,7 +5987,7 @@ var SpaceInvitationProtocol = class {
5730
5987
  const spaceMemberCredential = await this._spaceManager.admitMember({
5731
5988
  spaceKey: this._spaceKey,
5732
5989
  identityKey: request.space.identityKey,
5733
- role: invitation.role ?? import_credentials17.SpaceMember.Role.ADMIN,
5990
+ role: invitation.role ?? import_credentials18.SpaceMember.Role.ADMIN,
5734
5991
  profile: guestProfile,
5735
5992
  delegationCredentialId: invitation.delegationCredentialId
5736
5993
  });
@@ -5782,11 +6039,11 @@ var SpaceInvitationProtocol = class {
5782
6039
  S: this,
5783
6040
  C: (f, a) => f(...a)
5784
6041
  });
5785
- const credential = await (0, import_credentials16.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
6042
+ const credential = await (0, import_credentials17.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
5786
6043
  invitationId: invitation.invitationId,
5787
6044
  authMethod: invitation.authMethod,
5788
6045
  swarmKey: invitation.swarmKey,
5789
- role: invitation.role ?? import_credentials17.SpaceMember.Role.ADMIN,
6046
+ role: invitation.role ?? import_credentials18.SpaceMember.Role.ADMIN,
5790
6047
  expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
5791
6048
  multiUse: invitation.multiUse ?? false,
5792
6049
  guestKey: invitation.authMethod === import_services15.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
@@ -5843,7 +6100,7 @@ var SpaceInvitationProtocol = class {
5843
6100
  S: this,
5844
6101
  C: (f, a) => f(...a)
5845
6102
  });
5846
- const credential = await (0, import_credentials16.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
6103
+ const credential = await (0, import_credentials17.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
5847
6104
  (0, import_invariant16.invariant)(credential.credential, void 0, {
5848
6105
  F: __dxlog_file20,
5849
6106
  L: 140,
@@ -5859,10 +6116,10 @@ var SpaceInvitationProtocol = class {
5859
6116
  }
5860
6117
  checkInvitation(invitation) {
5861
6118
  if (invitation.spaceKey == null) {
5862
- return new import_protocols11.InvalidInvitationError("No spaceKey was provided for a space invitation.");
6119
+ return new import_protocols12.InvalidInvitationError("No spaceKey was provided for a space invitation.");
5863
6120
  }
5864
6121
  if (this._spaceManager.spaces.has(invitation.spaceKey)) {
5865
- return new import_protocols11.AlreadyJoinedError("Already joined space.");
6122
+ return new import_protocols12.AlreadyJoinedError("Already joined space.");
5866
6123
  }
5867
6124
  }
5868
6125
  createIntroduction() {
@@ -5893,7 +6150,7 @@ var SpaceInvitationProtocol = class {
5893
6150
  ]
5894
6151
  });
5895
6152
  const { credential, controlTimeframe, dataTimeframe } = response.space;
5896
- const assertion = (0, import_credentials16.getCredentialAssertion)(credential);
6153
+ const assertion = (0, import_credentials17.getCredentialAssertion)(credential);
5897
6154
  (0, import_invariant16.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
5898
6155
  F: __dxlog_file20,
5899
6156
  L: 178,
@@ -5913,7 +6170,7 @@ var SpaceInvitationProtocol = class {
5913
6170
  ]
5914
6171
  });
5915
6172
  if (this._spaceManager.spaces.has(assertion.spaceKey)) {
5916
- throw new import_protocols11.AlreadyJoinedError("Already joined space.");
6173
+ throw new import_protocols12.AlreadyJoinedError("Already joined space.");
5917
6174
  }
5918
6175
  await this._spaceManager.acceptSpace({
5919
6176
  spaceKey: assertion.spaceKey,
@@ -6129,8 +6386,8 @@ var InvitationsManager = class {
6129
6386
  }
6130
6387
  }
6131
6388
  _createInvitation(protocol, options) {
6132
- const { invitationId = import_keys13.PublicKey.random().toHex(), type = import_services16.Invitation.Type.INTERACTIVE, authMethod = import_services16.Invitation.AuthMethod.SHARED_SECRET, state = import_services16.Invitation.State.INIT, timeout = import_client_protocol6.INVITATION_TIMEOUT, swarmKey = import_keys13.PublicKey.random(), persistent = options?.authMethod !== import_services16.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials19.SpaceMember.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
6133
- const authCode = options?.authCode ?? (authMethod === import_services16.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials18.generatePasscode)(import_client_protocol6.AUTHENTICATION_CODE_LENGTH) : void 0);
6389
+ const { invitationId = import_keys13.PublicKey.random().toHex(), type = import_services16.Invitation.Type.INTERACTIVE, authMethod = import_services16.Invitation.AuthMethod.SHARED_SECRET, state = import_services16.Invitation.State.INIT, timeout = import_client_protocol6.INVITATION_TIMEOUT, swarmKey = import_keys13.PublicKey.random(), persistent = options?.authMethod !== import_services16.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials20.SpaceMember.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
6390
+ const authCode = options?.authCode ?? (authMethod === import_services16.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials19.generatePasscode)(import_client_protocol6.AUTHENTICATION_CODE_LENGTH) : void 0);
6134
6391
  return {
6135
6392
  invitationId,
6136
6393
  type,
@@ -6286,7 +6543,7 @@ var InvitationsManager = class {
6286
6543
  }, callback);
6287
6544
  }
6288
6545
  };
6289
- function _ts_decorate5(decorators, target, key, desc) {
6546
+ function _ts_decorate7(decorators, target, key, desc) {
6290
6547
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6291
6548
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6292
6549
  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;
@@ -6332,11 +6589,11 @@ var Lock = class {
6332
6589
  await import_lock_file.LockFile.release(this._fileHandle);
6333
6590
  }
6334
6591
  };
6335
- _ts_decorate5([
6592
+ _ts_decorate7([
6336
6593
  import_log19.logInfo
6337
6594
  ], Lock.prototype, "lockKey", null);
6338
6595
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
6339
- function _ts_decorate6(decorators, target, key, desc) {
6596
+ function _ts_decorate8(decorators, target, key, desc) {
6340
6597
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6341
6598
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6342
6599
  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;
@@ -6398,32 +6655,96 @@ var ClientRpcServer = class {
6398
6655
  return this._handlerCache.get(serviceName);
6399
6656
  }
6400
6657
  };
6401
- _ts_decorate6([
6658
+ _ts_decorate8([
6402
6659
  import_tracing9.trace.metricsCounter()
6403
6660
  ], ClientRpcServer.prototype, "_callMetrics", void 0);
6404
- _ts_decorate6([
6661
+ _ts_decorate8([
6405
6662
  import_tracing9.trace.info()
6406
6663
  ], ClientRpcServer.prototype, "_services", null);
6407
- ClientRpcServer = _ts_decorate6([
6664
+ ClientRpcServer = _ts_decorate8([
6408
6665
  import_tracing9.trace.resource()
6409
6666
  ], ClientRpcServer);
6410
- function _ts_decorate7(decorators, target, key, desc) {
6667
+ function _ts_decorate9(decorators, target, key, desc) {
6411
6668
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6412
6669
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6413
6670
  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;
6414
6671
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6415
6672
  }
6673
+ function _using_ctx3() {
6674
+ var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
6675
+ var err = new Error();
6676
+ err.name = "SuppressedError";
6677
+ err.suppressed = suppressed;
6678
+ err.error = error;
6679
+ return err;
6680
+ }, empty = {}, stack = [];
6681
+ function using(isAwait, value) {
6682
+ if (value != null) {
6683
+ if (Object(value) !== value) {
6684
+ throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
6685
+ }
6686
+ if (isAwait) {
6687
+ var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
6688
+ }
6689
+ if (dispose == null) {
6690
+ dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
6691
+ }
6692
+ if (typeof dispose !== "function") {
6693
+ throw new TypeError(`Property [Symbol.dispose] is not a function.`);
6694
+ }
6695
+ stack.push({
6696
+ v: value,
6697
+ d: dispose,
6698
+ a: isAwait
6699
+ });
6700
+ } else if (isAwait) {
6701
+ stack.push({
6702
+ d: value,
6703
+ a: isAwait
6704
+ });
6705
+ }
6706
+ return value;
6707
+ }
6708
+ return {
6709
+ e: empty,
6710
+ u: using.bind(null, false),
6711
+ a: using.bind(null, true),
6712
+ d: function() {
6713
+ var error = this.e;
6714
+ function next() {
6715
+ while (resource = stack.pop()) {
6716
+ try {
6717
+ var resource, disposalResult = resource.d && resource.d.call(resource.v);
6718
+ if (resource.a) {
6719
+ return Promise.resolve(disposalResult).then(next, err);
6720
+ }
6721
+ } catch (e) {
6722
+ return err(e);
6723
+ }
6724
+ }
6725
+ if (error !== empty) throw error;
6726
+ }
6727
+ function err(e) {
6728
+ error = error !== empty ? new _disposeSuppressedError(error, e) : e;
6729
+ return next();
6730
+ }
6731
+ return next();
6732
+ }
6733
+ };
6734
+ }
6416
6735
  var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
6417
6736
  var ServiceContext = class extends import_context15.Resource {
6418
- constructor(storage, level, networkManager, signalManager, _edgeConnection, _runtimeParams, _edgeFeatures) {
6737
+ constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
6419
6738
  super();
6420
6739
  this.storage = storage;
6421
6740
  this.level = level;
6422
6741
  this.networkManager = networkManager;
6423
6742
  this.signalManager = signalManager;
6424
6743
  this._edgeConnection = _edgeConnection;
6744
+ this._edgeHttpClient = _edgeHttpClient;
6425
6745
  this._runtimeParams = _runtimeParams;
6426
6746
  this._edgeFeatures = _edgeFeatures;
6747
+ this._edgeIdentityUpdateMutex = new import_async19.Mutex();
6427
6748
  this.initialized = new import_async19.Trigger();
6428
6749
  this._meshReplicator = void 0;
6429
6750
  this._echoEdgeReplicator = void 0;
@@ -6461,23 +6782,42 @@ var ServiceContext = class extends import_context15.Resource {
6461
6782
  callbacks: {
6462
6783
  onIdentityConstruction: (identity) => {
6463
6784
  if (this._edgeConnection) {
6464
- import_log20.log.info("Setting identity on edge connection", {
6465
- identity: identity.identityKey.toHex(),
6466
- oldIdentity: this._edgeConnection.identityKey,
6467
- swarms: this.networkManager.topics
6468
- }, {
6469
- F: __dxlog_file23,
6470
- L: 140,
6471
- S: this,
6472
- C: (f, a) => f(...a)
6473
- });
6474
- this._edgeConnection.setIdentity({
6475
- peerKey: identity.deviceKey.toHex(),
6476
- identityKey: identity.identityKey.toHex()
6477
- });
6478
- this.networkManager.setPeerInfo({
6479
- identityKey: identity.identityKey.toHex(),
6480
- peerKey: identity.deviceKey.toHex()
6785
+ (0, import_async19.scheduleMicroTask)(this._ctx, async () => {
6786
+ try {
6787
+ var _usingCtx = _using_ctx3();
6788
+ const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
6789
+ import_log20.log.info("Setting identity on edge connection", {
6790
+ identity: identity.identityKey.toHex(),
6791
+ oldIdentity: this._edgeConnection.identityKey,
6792
+ swarms: this.networkManager.topics
6793
+ }, {
6794
+ F: __dxlog_file23,
6795
+ L: 147,
6796
+ S: this,
6797
+ C: (f, a) => f(...a)
6798
+ });
6799
+ await (0, import_debug6.warnAfterTimeout)(1e4, "Waiting for identity to be ready for edge connection", async () => {
6800
+ await identity.ready();
6801
+ });
6802
+ (0, import_invariant19.invariant)(identity.deviceCredentialChain, void 0, {
6803
+ F: __dxlog_file23,
6804
+ L: 157,
6805
+ S: this,
6806
+ A: [
6807
+ "identity.deviceCredentialChain",
6808
+ ""
6809
+ ]
6810
+ });
6811
+ this._edgeConnection.setIdentity(await (0, import_edge_client2.createChainEdgeIdentity)(identity.signer, identity.identityKey, identity.deviceKey, identity.deviceCredentialChain, []));
6812
+ this.networkManager.setPeerInfo({
6813
+ identityKey: identity.identityKey.toHex(),
6814
+ peerKey: identity.deviceKey.toHex()
6815
+ });
6816
+ } catch (_) {
6817
+ _usingCtx.e = _;
6818
+ } finally {
6819
+ _usingCtx.d();
6820
+ }
6481
6821
  });
6482
6822
  }
6483
6823
  }
@@ -6503,19 +6843,22 @@ var ServiceContext = class extends import_context15.Resource {
6503
6843
  await this._checkStorageVersion();
6504
6844
  (0, import_log20.log)("opening...", void 0, {
6505
6845
  F: __dxlog_file23,
6506
- L: 198,
6846
+ L: 217,
6507
6847
  S: this,
6508
6848
  C: (f, a) => f(...a)
6509
6849
  });
6510
- import_log20.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.begin({
6850
+ import_log20.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
6511
6851
  id: this._instanceId
6512
6852
  }), {
6513
6853
  F: __dxlog_file23,
6514
- L: 199,
6854
+ L: 218,
6515
6855
  S: this,
6516
6856
  C: (f, a) => f(...a)
6517
6857
  });
6518
- await this._edgeConnection?.open();
6858
+ if (this._edgeConnection) {
6859
+ this._edgeConnection.setIdentity(await (0, import_edge_client2.createEphemeralEdgeIdentity)());
6860
+ await this._edgeConnection.open();
6861
+ }
6519
6862
  await this.signalManager.open();
6520
6863
  await this.networkManager.open();
6521
6864
  await this.echoHost.open(ctx);
@@ -6536,21 +6879,21 @@ var ServiceContext = class extends import_context15.Resource {
6536
6879
  count: loadedInvitations.invitations?.length
6537
6880
  }, {
6538
6881
  F: __dxlog_file23,
6539
- L: 222,
6882
+ L: 245,
6540
6883
  S: this,
6541
6884
  C: (f, a) => f(...a)
6542
6885
  });
6543
- import_log20.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.end({
6886
+ import_log20.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
6544
6887
  id: this._instanceId
6545
6888
  }), {
6546
6889
  F: __dxlog_file23,
6547
- L: 224,
6890
+ L: 247,
6548
6891
  S: this,
6549
6892
  C: (f, a) => f(...a)
6550
6893
  });
6551
6894
  (0, import_log20.log)("opened", void 0, {
6552
6895
  F: __dxlog_file23,
6553
- L: 225,
6896
+ L: 248,
6554
6897
  S: this,
6555
6898
  C: (f, a) => f(...a)
6556
6899
  });
@@ -6558,7 +6901,7 @@ var ServiceContext = class extends import_context15.Resource {
6558
6901
  async _close(ctx) {
6559
6902
  (0, import_log20.log)("closing...", void 0, {
6560
6903
  F: __dxlog_file23,
6561
- L: 229,
6904
+ L: 252,
6562
6905
  S: this,
6563
6906
  C: (f, a) => f(...a)
6564
6907
  });
@@ -6576,7 +6919,7 @@ var ServiceContext = class extends import_context15.Resource {
6576
6919
  await this._edgeConnection?.close();
6577
6920
  (0, import_log20.log)("closed", void 0, {
6578
6921
  F: __dxlog_file23,
6579
- L: 244,
6922
+ L: 267,
6580
6923
  S: this,
6581
6924
  C: (f, a) => f(...a)
6582
6925
  });
@@ -6585,7 +6928,7 @@ var ServiceContext = class extends import_context15.Resource {
6585
6928
  const identity = await this.identityManager.createIdentity(params);
6586
6929
  await this._initialize(new import_context15.Context(void 0, {
6587
6930
  F: __dxlog_file23,
6588
- L: 249
6931
+ L: 272
6589
6932
  }));
6590
6933
  return identity;
6591
6934
  }
@@ -6593,7 +6936,7 @@ var ServiceContext = class extends import_context15.Resource {
6593
6936
  const factory = this._handlerFactories.get(invitation.kind);
6594
6937
  (0, import_invariant19.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
6595
6938
  F: __dxlog_file23,
6596
- L: 255,
6939
+ L: 278,
6597
6940
  S: this,
6598
6941
  A: [
6599
6942
  "factory",
@@ -6614,21 +6957,21 @@ var ServiceContext = class extends import_context15.Resource {
6614
6957
  const identity = await this.identityManager.acceptIdentity(params);
6615
6958
  await this._initialize(new import_context15.Context(void 0, {
6616
6959
  F: __dxlog_file23,
6617
- L: 271
6960
+ L: 294
6618
6961
  }));
6619
6962
  return identity;
6620
6963
  }
6621
6964
  async _checkStorageVersion() {
6622
6965
  await this.metadataStore.load();
6623
- if (this.metadataStore.version !== import_protocols12.STORAGE_VERSION) {
6624
- throw new import_protocols12.InvalidStorageVersionError(import_protocols12.STORAGE_VERSION, this.metadataStore.version);
6966
+ if (this.metadataStore.version !== import_protocols13.STORAGE_VERSION) {
6967
+ throw new import_protocols13.InvalidStorageVersionError(import_protocols13.STORAGE_VERSION, this.metadataStore.version);
6625
6968
  }
6626
6969
  }
6627
6970
  // Called when identity is created.
6628
6971
  async _initialize(ctx) {
6629
6972
  (0, import_log20.log)("initializing spaces...", void 0, {
6630
6973
  F: __dxlog_file23,
6631
- L: 286,
6974
+ L: 309,
6632
6975
  S: this,
6633
6976
  C: (f, a) => f(...a)
6634
6977
  });
@@ -6655,6 +6998,7 @@ var ServiceContext = class extends import_context15.Resource {
6655
6998
  echoHost: this.echoHost,
6656
6999
  invitationsManager: this.invitationsManager,
6657
7000
  edgeConnection: this._edgeConnection,
7001
+ edgeHttpClient: this._edgeHttpClient,
6658
7002
  echoEdgeReplicator: this._echoEdgeReplicator,
6659
7003
  meshReplicator: this._meshReplicator,
6660
7004
  runtimeParams: this._runtimeParams,
@@ -6664,7 +7008,7 @@ var ServiceContext = class extends import_context15.Resource {
6664
7008
  this._handlerFactories.set(import_services17.Invitation.Kind.SPACE, (invitation) => {
6665
7009
  (0, import_invariant19.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
6666
7010
  F: __dxlog_file23,
6667
- L: 315,
7011
+ L: 339,
6668
7012
  S: this,
6669
7013
  A: [
6670
7014
  "this.dataSpaceManager",
@@ -6676,7 +7020,7 @@ var ServiceContext = class extends import_context15.Resource {
6676
7020
  this.initialized.wake();
6677
7021
  this._deviceSpaceSync = {
6678
7022
  processCredential: async (credential) => {
6679
- const assertion = (0, import_credentials20.getCredentialAssertion)(credential);
7023
+ const assertion = (0, import_credentials21.getCredentialAssertion)(credential);
6680
7024
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
6681
7025
  return;
6682
7026
  }
@@ -6688,7 +7032,7 @@ var ServiceContext = class extends import_context15.Resource {
6688
7032
  details: assertion
6689
7033
  }, {
6690
7034
  F: __dxlog_file23,
6691
- L: 331,
7035
+ L: 355,
6692
7036
  S: this,
6693
7037
  C: (f, a) => f(...a)
6694
7038
  });
@@ -6699,7 +7043,7 @@ var ServiceContext = class extends import_context15.Resource {
6699
7043
  details: assertion
6700
7044
  }, {
6701
7045
  F: __dxlog_file23,
6702
- L: 335,
7046
+ L: 359,
6703
7047
  S: this,
6704
7048
  C: (f, a) => f(...a)
6705
7049
  });
@@ -6710,7 +7054,7 @@ var ServiceContext = class extends import_context15.Resource {
6710
7054
  details: assertion
6711
7055
  }, {
6712
7056
  F: __dxlog_file23,
6713
- L: 340,
7057
+ L: 364,
6714
7058
  S: this,
6715
7059
  C: (f, a) => f(...a)
6716
7060
  });
@@ -6721,7 +7065,7 @@ var ServiceContext = class extends import_context15.Resource {
6721
7065
  } catch (err) {
6722
7066
  import_log20.log.catch(err, void 0, {
6723
7067
  F: __dxlog_file23,
6724
- L: 346,
7068
+ L: 370,
6725
7069
  S: this,
6726
7070
  C: (f, a) => f(...a)
6727
7071
  });
@@ -6731,13 +7075,13 @@ var ServiceContext = class extends import_context15.Resource {
6731
7075
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
6732
7076
  }
6733
7077
  };
6734
- _ts_decorate7([
7078
+ _ts_decorate9([
6735
7079
  import_tracing10.trace.span()
6736
7080
  ], ServiceContext.prototype, "_open", null);
6737
- _ts_decorate7([
7081
+ _ts_decorate9([
6738
7082
  import_tracing10.trace.span()
6739
7083
  ], ServiceContext.prototype, "_initialize", null);
6740
- ServiceContext = _ts_decorate7([
7084
+ ServiceContext = _ts_decorate9([
6741
7085
  (0, import_util12.safeInstanceof)("dxos.client-services.ServiceContext"),
6742
7086
  import_tracing10.trace.resource()
6743
7087
  ], ServiceContext);
@@ -6775,16 +7119,16 @@ var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
6775
7119
  var createStorageObjects = (config) => {
6776
7120
  const { persistent = false, keyStore, dataStore } = config ?? {};
6777
7121
  if (persistent && dataStore === StorageDriver.RAM) {
6778
- throw new import_protocols13.InvalidConfigError("RAM storage cannot be used in persistent mode.");
7122
+ throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
6779
7123
  }
6780
7124
  if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
6781
- throw new import_protocols13.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
7125
+ throw new import_protocols14.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
6782
7126
  }
6783
7127
  if (persistent && keyStore === StorageDriver.RAM) {
6784
- throw new import_protocols13.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
7128
+ throw new import_protocols14.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
6785
7129
  }
6786
7130
  if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
6787
- throw new import_protocols13.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
7131
+ throw new import_protocols14.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
6788
7132
  }
6789
7133
  return {
6790
7134
  storage: (0, import_random_access_storage.createStorage)({
@@ -6846,7 +7190,7 @@ var exportProfileData = async ({ storage, level }) => {
6846
7190
  const { size } = await file.stat();
6847
7191
  const data = await file.read(0, size);
6848
7192
  archive.storage.push({
6849
- type: import_protocols14.ProfileArchiveEntryType.FILE,
7193
+ type: import_protocols15.ProfileArchiveEntryType.FILE,
6850
7194
  key: filename,
6851
7195
  value: data
6852
7196
  });
@@ -6874,7 +7218,7 @@ var exportProfileData = async ({ storage, level }) => {
6874
7218
  let count = 0;
6875
7219
  for await (const [key, value] of iter) {
6876
7220
  archive.storage.push({
6877
- type: import_protocols14.ProfileArchiveEntryType.KEY_VALUE,
7221
+ type: import_protocols15.ProfileArchiveEntryType.KEY_VALUE,
6878
7222
  key,
6879
7223
  value
6880
7224
  });
@@ -6896,7 +7240,7 @@ var importProfileData = async ({ storage, level }, archive) => {
6896
7240
  let count = 0;
6897
7241
  for (const entry2 of archive.storage) {
6898
7242
  switch (entry2.type) {
6899
- case import_protocols14.ProfileArchiveEntryType.FILE: {
7243
+ case import_protocols15.ProfileArchiveEntryType.FILE: {
6900
7244
  const directory = await storage.createDirectory();
6901
7245
  (0, import_invariant20.invariant)(typeof entry2.key === "string", "Invalid key type", {
6902
7246
  F: __dxlog_file24,
@@ -6921,7 +7265,7 @@ var importProfileData = async ({ storage, level }, archive) => {
6921
7265
  await file.close();
6922
7266
  break;
6923
7267
  }
6924
- case import_protocols14.ProfileArchiveEntryType.KEY_VALUE: {
7268
+ case import_protocols15.ProfileArchiveEntryType.KEY_VALUE: {
6925
7269
  (0, import_invariant20.invariant)(entry2.key instanceof Uint8Array, "Invalid key type", {
6926
7270
  F: __dxlog_file24,
6927
7271
  L: 87,
@@ -7323,7 +7667,7 @@ var SystemServiceImpl = class {
7323
7667
  await this._onReset();
7324
7668
  }
7325
7669
  };
7326
- function _ts_decorate8(decorators, target, key, desc) {
7670
+ function _ts_decorate10(decorators, target, key, desc) {
7327
7671
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7328
7672
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7329
7673
  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;
@@ -7345,6 +7689,7 @@ var ClientServicesHost = class {
7345
7689
  this._tracingService = import_tracing11.TRACE_PROCESSOR.createTraceSender();
7346
7690
  this._statusUpdate = new import_async20.Event();
7347
7691
  this._edgeConnection = void 0;
7692
+ this._edgeHttpClient = void 0;
7348
7693
  this._opening = false;
7349
7694
  this._open = false;
7350
7695
  this._storage = storage;
@@ -7368,7 +7713,7 @@ var ClientServicesHost = class {
7368
7713
  if (!this._opening) {
7369
7714
  void this.open(new import_context16.Context(void 0, {
7370
7715
  F: __dxlog_file26,
7371
- L: 132
7716
+ L: 133
7372
7717
  }));
7373
7718
  }
7374
7719
  },
@@ -7426,7 +7771,7 @@ var ClientServicesHost = class {
7426
7771
  initialize({ config, ...options }) {
7427
7772
  (0, import_invariant21.invariant)(!this._open, "service host is open", {
7428
7773
  F: __dxlog_file26,
7429
- L: 198,
7774
+ L: 199,
7430
7775
  S: this,
7431
7776
  A: [
7432
7777
  "!this._open",
@@ -7435,14 +7780,14 @@ var ClientServicesHost = class {
7435
7780
  });
7436
7781
  (0, import_log22.log)("initializing...", void 0, {
7437
7782
  F: __dxlog_file26,
7438
- L: 199,
7783
+ L: 200,
7439
7784
  S: this,
7440
7785
  C: (f, a) => f(...a)
7441
7786
  });
7442
7787
  if (config) {
7443
7788
  (0, import_invariant21.invariant)(!this._config, "config already set", {
7444
7789
  F: __dxlog_file26,
7445
- L: 202,
7790
+ L: 203,
7446
7791
  S: this,
7447
7792
  A: [
7448
7793
  "!this._config",
@@ -7457,17 +7802,17 @@ var ClientServicesHost = class {
7457
7802
  if (!options.signalManager) {
7458
7803
  import_log22.log.warn("running signaling without telemetry metadata.", void 0, {
7459
7804
  F: __dxlog_file26,
7460
- L: 210,
7805
+ L: 211,
7461
7806
  S: this,
7462
7807
  C: (f, a) => f(...a)
7463
7808
  });
7464
7809
  }
7465
7810
  const edgeEndpoint = config?.get("runtime.services.edge.url");
7466
7811
  if (edgeEndpoint) {
7467
- const randomKey = import_keys16.PublicKey.random().toHex();
7468
- this._edgeConnection = new import_edge_client2.EdgeClient(randomKey, randomKey, {
7812
+ this._edgeConnection = new import_edge_client3.EdgeClient((0, import_edge_client3.createStubEdgeIdentity)(), {
7469
7813
  socketEndpoint: edgeEndpoint
7470
7814
  });
7815
+ this._edgeHttpClient = new import_edge_client3.EdgeHttpClient(edgeEndpoint);
7471
7816
  }
7472
7817
  const { connectionLog = true, transportFactory = (0, import_network_manager2.createRtcTransportFactory)({
7473
7818
  iceServers: this._config?.get("runtime.services.ice")
@@ -7477,7 +7822,7 @@ var ClientServicesHost = class {
7477
7822
  this._signalManager = signalManager;
7478
7823
  (0, import_invariant21.invariant)(!this._networkManager, "network manager already set", {
7479
7824
  F: __dxlog_file26,
7480
- L: 232,
7825
+ L: 233,
7481
7826
  S: this,
7482
7827
  A: [
7483
7828
  "!this._networkManager",
@@ -7495,7 +7840,7 @@ var ClientServicesHost = class {
7495
7840
  });
7496
7841
  (0, import_log22.log)("initialized", void 0, {
7497
7842
  F: __dxlog_file26,
7498
- L: 245,
7843
+ L: 246,
7499
7844
  S: this,
7500
7845
  C: (f, a) => f(...a)
7501
7846
  });
@@ -7505,17 +7850,17 @@ var ClientServicesHost = class {
7505
7850
  return;
7506
7851
  }
7507
7852
  const traceId = import_keys16.PublicKey.random().toHex();
7508
- import_log22.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
7853
+ import_log22.log.trace("dxos.client-services.host.open", import_protocols16.trace.begin({
7509
7854
  id: traceId
7510
7855
  }), {
7511
7856
  F: __dxlog_file26,
7512
- L: 256,
7857
+ L: 257,
7513
7858
  S: this,
7514
7859
  C: (f, a) => f(...a)
7515
7860
  });
7516
7861
  (0, import_invariant21.invariant)(this._config, "config not set", {
7517
7862
  F: __dxlog_file26,
7518
- L: 258,
7863
+ L: 259,
7519
7864
  S: this,
7520
7865
  A: [
7521
7866
  "this._config",
@@ -7524,7 +7869,7 @@ var ClientServicesHost = class {
7524
7869
  });
7525
7870
  (0, import_invariant21.invariant)(this._storage, "storage not set", {
7526
7871
  F: __dxlog_file26,
7527
- L: 259,
7872
+ L: 260,
7528
7873
  S: this,
7529
7874
  A: [
7530
7875
  "this._storage",
@@ -7533,7 +7878,7 @@ var ClientServicesHost = class {
7533
7878
  });
7534
7879
  (0, import_invariant21.invariant)(this._signalManager, "signal manager not set", {
7535
7880
  F: __dxlog_file26,
7536
- L: 260,
7881
+ L: 261,
7537
7882
  S: this,
7538
7883
  A: [
7539
7884
  "this._signalManager",
@@ -7542,7 +7887,7 @@ var ClientServicesHost = class {
7542
7887
  });
7543
7888
  (0, import_invariant21.invariant)(this._networkManager, "network manager not set", {
7544
7889
  F: __dxlog_file26,
7545
- L: 261,
7890
+ L: 262,
7546
7891
  S: this,
7547
7892
  A: [
7548
7893
  "this._networkManager",
@@ -7554,7 +7899,7 @@ var ClientServicesHost = class {
7554
7899
  lockKey: this._resourceLock?.lockKey
7555
7900
  }, {
7556
7901
  F: __dxlog_file26,
7557
- L: 264,
7902
+ L: 265,
7558
7903
  S: this,
7559
7904
  C: (f, a) => f(...a)
7560
7905
  });
@@ -7564,7 +7909,7 @@ var ClientServicesHost = class {
7564
7909
  }
7565
7910
  await this._level.open();
7566
7911
  await this._loggingService.open();
7567
- this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._runtimeParams, this._config.get("runtime.client.edgeFeatures"));
7912
+ this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._edgeHttpClient, this._runtimeParams, this._config.get("runtime.client.edgeFeatures"));
7568
7913
  const dataSpaceManagerProvider = async () => {
7569
7914
  await this._serviceContext.initialized.wait();
7570
7915
  return this._serviceContext.dataSpaceManager;
@@ -7610,15 +7955,15 @@ var ClientServicesHost = class {
7610
7955
  deviceKey
7611
7956
  }, {
7612
7957
  F: __dxlog_file26,
7613
- L: 352,
7958
+ L: 354,
7614
7959
  S: this,
7615
7960
  C: (f, a) => f(...a)
7616
7961
  });
7617
- import_log22.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
7962
+ import_log22.log.trace("dxos.client-services.host.open", import_protocols16.trace.end({
7618
7963
  id: traceId
7619
7964
  }), {
7620
7965
  F: __dxlog_file26,
7621
- L: 353,
7966
+ L: 355,
7622
7967
  S: this,
7623
7968
  C: (f, a) => f(...a)
7624
7969
  });
@@ -7632,7 +7977,7 @@ var ClientServicesHost = class {
7632
7977
  deviceKey
7633
7978
  }, {
7634
7979
  F: __dxlog_file26,
7635
- L: 364,
7980
+ L: 366,
7636
7981
  S: this,
7637
7982
  C: (f, a) => f(...a)
7638
7983
  });
@@ -7650,24 +7995,24 @@ var ClientServicesHost = class {
7650
7995
  deviceKey
7651
7996
  }, {
7652
7997
  F: __dxlog_file26,
7653
- L: 373,
7998
+ L: 375,
7654
7999
  S: this,
7655
8000
  C: (f, a) => f(...a)
7656
8001
  });
7657
8002
  }
7658
8003
  async reset() {
7659
8004
  const traceId = import_keys16.PublicKey.random().toHex();
7660
- import_log22.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
8005
+ import_log22.log.trace("dxos.sdk.client-services-host.reset", import_protocols16.trace.begin({
7661
8006
  id: traceId
7662
8007
  }), {
7663
8008
  F: __dxlog_file26,
7664
- L: 378,
8009
+ L: 380,
7665
8010
  S: this,
7666
8011
  C: (f, a) => f(...a)
7667
8012
  });
7668
8013
  import_log22.log.info("resetting...", void 0, {
7669
8014
  F: __dxlog_file26,
7670
- L: 380,
8015
+ L: 382,
7671
8016
  S: this,
7672
8017
  C: (f, a) => f(...a)
7673
8018
  });
@@ -7675,15 +8020,15 @@ var ClientServicesHost = class {
7675
8020
  await this._storage.reset();
7676
8021
  import_log22.log.info("reset", void 0, {
7677
8022
  F: __dxlog_file26,
7678
- L: 383,
8023
+ L: 385,
7679
8024
  S: this,
7680
8025
  C: (f, a) => f(...a)
7681
8026
  });
7682
- import_log22.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
8027
+ import_log22.log.trace("dxos.sdk.client-services-host.reset", import_protocols16.trace.end({
7683
8028
  id: traceId
7684
8029
  }), {
7685
8030
  F: __dxlog_file26,
7686
- L: 384,
8031
+ L: 386,
7687
8032
  S: this,
7688
8033
  C: (f, a) => f(...a)
7689
8034
  });
@@ -7695,21 +8040,21 @@ var ClientServicesHost = class {
7695
8040
  return identity;
7696
8041
  }
7697
8042
  };
7698
- _ts_decorate8([
8043
+ _ts_decorate10([
7699
8044
  import_tracing11.trace.info()
7700
8045
  ], ClientServicesHost.prototype, "_opening", void 0);
7701
- _ts_decorate8([
8046
+ _ts_decorate10([
7702
8047
  import_tracing11.trace.info()
7703
8048
  ], ClientServicesHost.prototype, "_open", void 0);
7704
- _ts_decorate8([
8049
+ _ts_decorate10([
7705
8050
  import_async20.synchronized,
7706
8051
  import_tracing11.trace.span()
7707
8052
  ], ClientServicesHost.prototype, "open", null);
7708
- _ts_decorate8([
8053
+ _ts_decorate10([
7709
8054
  import_async20.synchronized,
7710
8055
  import_tracing11.trace.span()
7711
8056
  ], ClientServicesHost.prototype, "close", null);
7712
- ClientServicesHost = _ts_decorate8([
8057
+ ClientServicesHost = _ts_decorate10([
7713
8058
  import_tracing11.trace.resource()
7714
8059
  ], ClientServicesHost);
7715
8060
  // Annotate the CommonJS export names for ESM import in node:
@@ -7756,4 +8101,4 @@ ClientServicesHost = _ts_decorate8([
7756
8101
  subscribeToSpaces,
7757
8102
  subscribeToSwarmInfo
7758
8103
  });
7759
- //# sourceMappingURL=chunk-F3WGFGEN.cjs.map
8104
+ //# sourceMappingURL=chunk-NZL66D6K.cjs.map