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

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 (56) hide show
  1. package/dist/lib/browser/{chunk-XSFLJVDP.mjs → chunk-6UTFANWL.mjs} +686 -304
  2. package/dist/lib/browser/chunk-6UTFANWL.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-2UUETFZ2.cjs} +776 -394
  8. package/dist/lib/node/chunk-2UUETFZ2.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-EQAI46LQ.mjs} +686 -304
  14. package/dist/lib/node-esm/chunk-EQAI46LQ.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 +5 -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 +3 -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/packlets/spaces/spaces-service.d.ts +1 -1
  37. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  38. package/dist/types/src/version.d.ts +1 -1
  39. package/package.json +38 -38
  40. package/src/packlets/identity/authenticator.ts +5 -2
  41. package/src/packlets/identity/contacts-service.ts +1 -1
  42. package/src/packlets/identity/identity.ts +4 -0
  43. package/src/packlets/services/service-context.ts +41 -17
  44. package/src/packlets/services/service-host.ts +7 -5
  45. package/src/packlets/spaces/data-space-manager.ts +32 -4
  46. package/src/packlets/spaces/data-space.ts +27 -4
  47. package/src/packlets/spaces/edge-feed-replicator.test.ts +22 -15
  48. package/src/packlets/spaces/edge-feed-replicator.ts +45 -25
  49. package/src/packlets/spaces/notarization-plugin.test.ts +8 -4
  50. package/src/packlets/spaces/notarization-plugin.ts +169 -29
  51. package/src/packlets/spaces/spaces-service.ts +6 -1
  52. package/src/packlets/testing/test-builder.ts +1 -1
  53. package/src/version.ts +1 -1
  54. package/dist/lib/browser/chunk-XSFLJVDP.mjs.map +0 -7
  55. package/dist/lib/node/chunk-F3WGFGEN.cjs.map +0 -7
  56. 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_2UUETFZ2_exports = {};
30
+ __export(chunk_2UUETFZ2_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_2UUETFZ2_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,37 @@ 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_metadata = require("@dxos/protocols/proto/dxos/echo/metadata");
181
+ var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
179
182
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
180
183
  var import_tracing5 = require("@dxos/tracing");
181
184
  var import_util7 = require("@dxos/util");
182
- var import_credentials10 = require("@dxos/credentials");
185
+ var import_credentials11 = require("@dxos/credentials");
183
186
  var import_debug2 = require("@dxos/debug");
184
- var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
187
+ var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
185
188
  var import_timeframe3 = require("@dxos/timeframe");
186
189
  var import_async12 = require("@dxos/async");
187
190
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
188
- var import_credentials12 = require("@dxos/credentials");
191
+ var import_credentials13 = require("@dxos/credentials");
189
192
  var import_debug3 = require("@dxos/debug");
190
193
  var import_feed_store4 = require("@dxos/feed-store");
191
194
  var import_invariant8 = require("@dxos/invariant");
192
195
  var import_log10 = require("@dxos/log");
193
- var import_protocols5 = require("@dxos/protocols");
196
+ var import_protocols6 = require("@dxos/protocols");
194
197
  var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
195
198
  var import_tracing6 = require("@dxos/tracing");
196
199
  var import_platform = __toESM(require("platform"));
197
200
  var import_async13 = require("@dxos/async");
198
201
  var import_context8 = require("@dxos/context");
199
- var import_credentials13 = require("@dxos/credentials");
202
+ var import_credentials14 = require("@dxos/credentials");
200
203
  var import_invariant9 = require("@dxos/invariant");
201
204
  var import_keys9 = require("@dxos/keys");
202
205
  var import_log11 = require("@dxos/log");
203
- var import_protocols6 = require("@dxos/protocols");
206
+ var import_protocols7 = require("@dxos/protocols");
204
207
  var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
205
- var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
208
+ var import_credentials15 = require("@dxos/protocols/proto/dxos/halo/credentials");
206
209
  var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
207
210
  var import_timeframe4 = require("@dxos/timeframe");
208
211
  var import_tracing7 = require("@dxos/tracing");
@@ -210,14 +213,14 @@ var import_util8 = require("@dxos/util");
210
213
  var import_async14 = require("@dxos/async");
211
214
  var import_codec_protobuf9 = require("@dxos/codec-protobuf");
212
215
  var import_context9 = require("@dxos/context");
213
- var import_credentials15 = require("@dxos/credentials");
216
+ var import_credentials16 = require("@dxos/credentials");
214
217
  var import_debug4 = require("@dxos/debug");
215
218
  var import_invariant10 = require("@dxos/invariant");
216
219
  var import_log12 = require("@dxos/log");
217
220
  var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
218
221
  var import_util9 = require("@dxos/util");
219
222
  var import_invariant11 = require("@dxos/invariant");
220
- var import_protocols7 = require("@dxos/protocols");
223
+ var import_protocols8 = require("@dxos/protocols");
221
224
  var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
222
225
  var import_async15 = require("@dxos/async");
223
226
  var import_client_protocol5 = require("@dxos/client-protocol");
@@ -227,7 +230,7 @@ var import_invariant12 = require("@dxos/invariant");
227
230
  var import_keys10 = require("@dxos/keys");
228
231
  var import_log13 = require("@dxos/log");
229
232
  var import_network_manager = require("@dxos/network-manager");
230
- var import_protocols8 = require("@dxos/protocols");
233
+ var import_protocols9 = require("@dxos/protocols");
231
234
  var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
232
235
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
233
236
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
@@ -237,7 +240,7 @@ var import_async16 = require("@dxos/async");
237
240
  var import_context11 = require("@dxos/context");
238
241
  var import_invariant13 = require("@dxos/invariant");
239
242
  var import_log14 = require("@dxos/log");
240
- var import_protocols9 = require("@dxos/protocols");
243
+ var import_protocols10 = require("@dxos/protocols");
241
244
  var import_proto3 = require("@dxos/protocols/proto");
242
245
  var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
243
246
  var import_teleport2 = require("@dxos/teleport");
@@ -249,7 +252,7 @@ var import_crypto2 = require("@dxos/crypto");
249
252
  var import_invariant14 = require("@dxos/invariant");
250
253
  var import_keys11 = require("@dxos/keys");
251
254
  var import_log15 = require("@dxos/log");
252
- var import_protocols10 = require("@dxos/protocols");
255
+ var import_protocols11 = require("@dxos/protocols");
253
256
  var import_proto4 = require("@dxos/protocols/proto");
254
257
  var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
255
258
  var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
@@ -261,23 +264,23 @@ var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations")
261
264
  var import_util11 = require("@dxos/util");
262
265
  var import_codec_protobuf10 = require("@dxos/codec-protobuf");
263
266
  var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
264
- var import_credentials16 = require("@dxos/credentials");
267
+ var import_credentials17 = require("@dxos/credentials");
265
268
  var import_feed_store5 = require("@dxos/feed-store");
266
269
  var import_invariant16 = require("@dxos/invariant");
267
270
  var import_log17 = require("@dxos/log");
268
- var import_protocols11 = require("@dxos/protocols");
271
+ var import_protocols12 = require("@dxos/protocols");
269
272
  var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
270
- var import_credentials17 = require("@dxos/protocols/proto/dxos/halo/credentials");
273
+ var import_credentials18 = require("@dxos/protocols/proto/dxos/halo/credentials");
271
274
  var import_async18 = require("@dxos/async");
272
275
  var import_client_protocol6 = require("@dxos/client-protocol");
273
276
  var import_context14 = require("@dxos/context");
274
- var import_credentials18 = require("@dxos/credentials");
277
+ var import_credentials19 = require("@dxos/credentials");
275
278
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
276
279
  var import_invariant17 = require("@dxos/invariant");
277
280
  var import_keys13 = require("@dxos/keys");
278
281
  var import_log18 = require("@dxos/log");
279
282
  var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
280
- var import_credentials19 = require("@dxos/protocols/proto/dxos/halo/credentials");
283
+ var import_credentials20 = require("@dxos/protocols/proto/dxos/halo/credentials");
281
284
  var import_invariant18 = require("@dxos/invariant");
282
285
  var import_lock_file = require("@dxos/lock-file");
283
286
  var import_log19 = require("@dxos/log");
@@ -287,20 +290,21 @@ var import_rpc = require("@dxos/rpc");
287
290
  var import_tracing9 = require("@dxos/tracing");
288
291
  var import_async19 = require("@dxos/async");
289
292
  var import_context15 = require("@dxos/context");
290
- var import_credentials20 = require("@dxos/credentials");
293
+ var import_credentials21 = require("@dxos/credentials");
291
294
  var import_debug6 = require("@dxos/debug");
292
295
  var import_echo_pipeline5 = require("@dxos/echo-pipeline");
296
+ var import_edge_client2 = require("@dxos/edge-client");
293
297
  var import_feed_store6 = require("@dxos/feed-store");
294
298
  var import_invariant19 = require("@dxos/invariant");
295
299
  var import_keyring = require("@dxos/keyring");
296
300
  var import_keys14 = require("@dxos/keys");
297
301
  var import_log20 = require("@dxos/log");
298
- var import_protocols12 = require("@dxos/protocols");
302
+ var import_protocols13 = require("@dxos/protocols");
299
303
  var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
300
304
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
301
305
  var import_tracing10 = require("@dxos/tracing");
302
306
  var import_util12 = require("@dxos/util");
303
- var import_protocols13 = require("@dxos/protocols");
307
+ var import_protocols14 = require("@dxos/protocols");
304
308
  var import_config2 = require("@dxos/protocols/proto/dxos/config");
305
309
  var import_random_access_storage = require("@dxos/random-access-storage");
306
310
  var import_client_protocol7 = require("@dxos/client-protocol");
@@ -312,18 +316,18 @@ var import_kv_store = require("@dxos/kv-store");
312
316
  var import_automerge_repo = require("@dxos/automerge/automerge-repo");
313
317
  var import_invariant20 = require("@dxos/invariant");
314
318
  var import_log21 = require("@dxos/log");
315
- var import_protocols14 = require("@dxos/protocols");
319
+ var import_protocols15 = require("@dxos/protocols");
316
320
  var import_util14 = require("@dxos/util");
317
321
  var import_async20 = require("@dxos/async");
318
322
  var import_client_protocol8 = require("@dxos/client-protocol");
319
323
  var import_context16 = require("@dxos/context");
320
- var import_edge_client2 = require("@dxos/edge-client");
324
+ var import_edge_client3 = require("@dxos/edge-client");
321
325
  var import_invariant21 = require("@dxos/invariant");
322
326
  var import_keys16 = require("@dxos/keys");
323
327
  var import_log22 = require("@dxos/log");
324
328
  var import_messaging = require("@dxos/messaging");
325
329
  var import_network_manager2 = require("@dxos/network-manager");
326
- var import_protocols15 = require("@dxos/protocols");
330
+ var import_protocols16 = require("@dxos/protocols");
327
331
  var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
328
332
  var import_tracing11 = require("@dxos/tracing");
329
333
  var import_websocket_rpc = require("@dxos/websocket-rpc");
@@ -703,7 +707,7 @@ var DevtoolsServiceImpl = class {
703
707
  });
704
708
  }
705
709
  };
706
- var DXOS_VERSION = "0.6.12-main.78ddbdf";
710
+ var DXOS_VERSION = "0.6.12-main.7907542";
707
711
  var getPlatform = () => {
708
712
  if (process.browser) {
709
713
  if (typeof window !== "undefined") {
@@ -955,7 +959,7 @@ var TrustedKeySetAuthVerifier = class {
955
959
  return false;
956
960
  }
957
961
  if (this._isTrustedKey(credential.issuer)) {
958
- (0, import_log2.log)("key is not currently in trusted set, waiting...", {
962
+ (0, import_log2.log)("key is trusted -- auth success", {
959
963
  key: credential.issuer
960
964
  }, {
961
965
  F: __dxlog_file4,
@@ -982,7 +986,10 @@ var TrustedKeySetAuthVerifier = class {
982
986
  trigger.wake(true);
983
987
  } else {
984
988
  (0, import_log2.log)("key is not currently in trusted set, waiting...", {
985
- key: credential.issuer
989
+ key: credential.issuer,
990
+ trusted: [
991
+ ...this._params.trustedKeysProvider()
992
+ ]
986
993
  }, {
987
994
  F: __dxlog_file4,
988
995
  L: 84,
@@ -1007,6 +1014,12 @@ var TrustedKeySetAuthVerifier = class {
1007
1014
  return deviceSet.has(deviceKey);
1008
1015
  }
1009
1016
  };
1017
+ function _ts_decorate(decorators, target, key, desc) {
1018
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1019
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1020
+ 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;
1021
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1022
+ }
1010
1023
  function _using_ctx() {
1011
1024
  var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
1012
1025
  var err = new Error();
@@ -1082,6 +1095,12 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1082
1095
  this._spaceId = spaceId;
1083
1096
  }
1084
1097
  async _open() {
1098
+ (0, import_log3.log)("open", void 0, {
1099
+ F: __dxlog_file5,
1100
+ L: 56,
1101
+ S: this,
1102
+ C: (f, a) => f(...a)
1103
+ });
1085
1104
  this._ctx.onDispose(this._messenger.addListener((message) => {
1086
1105
  if (!message.serviceId) {
1087
1106
  return;
@@ -1097,20 +1116,20 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1097
1116
  _spaceId: this._spaceId
1098
1117
  }, {
1099
1118
  F: __dxlog_file5,
1100
- L: 66,
1119
+ L: 70,
1101
1120
  S: this,
1102
1121
  C: (f, a) => f(...a)
1103
1122
  });
1104
1123
  return;
1105
1124
  }
1106
1125
  const payload = (0, import_cbor_x.decode)(message.payload.value);
1107
- import_log3.log.info("receive", {
1126
+ (0, import_log3.log)("receive", {
1108
1127
  from: message.source,
1109
1128
  feedKey: payload.feedKey,
1110
1129
  type: payload.type
1111
1130
  }, {
1112
1131
  F: __dxlog_file5,
1113
- L: 71,
1132
+ L: 75,
1114
1133
  S: this,
1115
1134
  C: (f, a) => f(...a)
1116
1135
  });
@@ -1118,46 +1137,44 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1118
1137
  }));
1119
1138
  this._messenger.connected.on(this._ctx, async () => {
1120
1139
  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
- });
1140
+ this._startReplication();
1155
1141
  });
1142
+ if (this._messenger.isConnected) {
1143
+ this._startReplication();
1144
+ }
1156
1145
  }
1157
1146
  async _close() {
1147
+ (0, import_log3.log)("close", void 0, {
1148
+ F: __dxlog_file5,
1149
+ L: 91,
1150
+ S: this,
1151
+ C: (f, a) => f(...a)
1152
+ });
1158
1153
  await this._resetConnection();
1159
1154
  }
1155
+ _startReplication() {
1156
+ this._connected = true;
1157
+ const connectionCtx = this._createConnectionContext();
1158
+ this._connectionCtx = connectionCtx;
1159
+ (0, import_log3.log)("connection context created", void 0, {
1160
+ F: __dxlog_file5,
1161
+ L: 99,
1162
+ S: this,
1163
+ C: (f, a) => f(...a)
1164
+ });
1165
+ (0, import_async6.scheduleMicroTask)(connectionCtx, async () => {
1166
+ for (const feed of this._feeds.values()) {
1167
+ await this._replicateFeed(connectionCtx, feed);
1168
+ }
1169
+ });
1170
+ }
1160
1171
  async _resetConnection() {
1172
+ (0, import_log3.log)("resetConnection", void 0, {
1173
+ F: __dxlog_file5,
1174
+ L: 108,
1175
+ S: this,
1176
+ C: (f, a) => f(...a)
1177
+ });
1161
1178
  this._connected = false;
1162
1179
  await this._connectionCtx?.dispose();
1163
1180
  this._connectionCtx = void 0;
@@ -1165,10 +1182,12 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1165
1182
  }
1166
1183
  async addFeed(feed) {
1167
1184
  import_log3.log.info("addFeed", {
1168
- key: feed.key
1185
+ key: feed.key,
1186
+ connected: this._connected,
1187
+ hasConnectionCtx: !!this._connectionCtx
1169
1188
  }, {
1170
1189
  F: __dxlog_file5,
1171
- L: 115,
1190
+ L: 116,
1172
1191
  S: this,
1173
1192
  C: (f, a) => f(...a)
1174
1193
  });
@@ -1181,6 +1200,14 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1181
1200
  return (0, import_util3.defaultMap)(this._pushMutex, key, () => new import_async6.Mutex());
1182
1201
  }
1183
1202
  async _replicateFeed(ctx, feed) {
1203
+ (0, import_log3.log)("replicateFeed", {
1204
+ key: feed.key
1205
+ }, {
1206
+ F: __dxlog_file5,
1207
+ L: 129,
1208
+ S: this,
1209
+ C: (f, a) => f(...a)
1210
+ });
1184
1211
  await this._sendMessage({
1185
1212
  type: "get-metadata",
1186
1213
  feedKey: feed.key.toHex()
@@ -1193,7 +1220,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1193
1220
  if (!this._connectionCtx) {
1194
1221
  import_log3.log.info("message dropped because connection was disposed", void 0, {
1195
1222
  F: __dxlog_file5,
1196
- L: 140,
1223
+ L: 142,
1197
1224
  S: this,
1198
1225
  C: (f, a) => f(...a)
1199
1226
  });
@@ -1207,13 +1234,13 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1207
1234
  };
1208
1235
  import_log3.log.info("sending message", logPayload, {
1209
1236
  F: __dxlog_file5,
1210
- L: 146,
1237
+ L: 148,
1211
1238
  S: this,
1212
1239
  C: (f, a) => f(...a)
1213
1240
  });
1214
1241
  (0, import_invariant2.invariant)(message.feedKey, void 0, {
1215
1242
  F: __dxlog_file5,
1216
- L: 148,
1243
+ L: 150,
1217
1244
  S: this,
1218
1245
  A: [
1219
1246
  "message.feedKey",
@@ -1221,6 +1248,14 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1221
1248
  ]
1222
1249
  });
1223
1250
  const payloadValue = (0, import_util3.bufferToArray)((0, import_cbor_x.encode)(message));
1251
+ (0, import_log3.log)("send", {
1252
+ type: message.type
1253
+ }, {
1254
+ F: __dxlog_file5,
1255
+ L: 153,
1256
+ S: this,
1257
+ C: (f, a) => f(...a)
1258
+ });
1224
1259
  await this._messenger.send(import_buf.buf.create(import_messenger_pb.MessageSchema, {
1225
1260
  source: {
1226
1261
  identityKey: this._messenger.identityKey,
@@ -1236,7 +1271,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1236
1271
  if (!this._connectionCtx) {
1237
1272
  import_log3.log.warn("received message after connection context was disposed", void 0, {
1238
1273
  F: __dxlog_file5,
1239
- L: 165,
1274
+ L: 168,
1240
1275
  S: this,
1241
1276
  C: (f, a) => f(...a)
1242
1277
  });
@@ -1251,7 +1286,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1251
1286
  message
1252
1287
  }, {
1253
1288
  F: __dxlog_file5,
1254
- L: 171,
1289
+ L: 174,
1255
1290
  S: this,
1256
1291
  C: (f, a) => f(...a)
1257
1292
  });
@@ -1262,7 +1297,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1262
1297
  feedKey
1263
1298
  }, {
1264
1299
  F: __dxlog_file5,
1265
- L: 176,
1300
+ L: 179,
1266
1301
  S: this,
1267
1302
  C: (f, a) => f(...a)
1268
1303
  });
@@ -1295,7 +1330,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1295
1330
  blocks: message.blocks.map((b) => b.index)
1296
1331
  }, {
1297
1332
  F: __dxlog_file5,
1298
- L: 198,
1333
+ L: 201,
1299
1334
  S: this,
1300
1335
  C: (f, a) => f(...a)
1301
1336
  });
@@ -1306,7 +1341,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1306
1341
  feedKey
1307
1342
  }, {
1308
1343
  F: __dxlog_file5,
1309
- L: 203,
1344
+ L: 206,
1310
1345
  S: this,
1311
1346
  C: (f, a) => f(...a)
1312
1347
  });
@@ -1320,7 +1355,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1320
1355
  ...message
1321
1356
  }, {
1322
1357
  F: __dxlog_file5,
1323
- L: 212,
1358
+ L: 215,
1324
1359
  S: this,
1325
1360
  C: (f, a) => f(...a)
1326
1361
  });
@@ -1335,7 +1370,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1335
1370
  to
1336
1371
  }, {
1337
1372
  F: __dxlog_file5,
1338
- L: 219,
1373
+ L: 222,
1339
1374
  S: this,
1340
1375
  C: (f, a) => f(...a)
1341
1376
  });
@@ -1345,7 +1380,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1345
1380
  });
1346
1381
  (0, import_invariant2.invariant)(data instanceof Uint8Array, void 0, {
1347
1382
  F: __dxlog_file5,
1348
- L: 224,
1383
+ L: 227,
1349
1384
  S: this,
1350
1385
  A: [
1351
1386
  "data instanceof Uint8Array",
@@ -1373,7 +1408,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1373
1408
  blocks: blocks.length
1374
1409
  }, {
1375
1410
  F: __dxlog_file5,
1376
- L: 245,
1411
+ L: 248,
1377
1412
  S: this,
1378
1413
  C: (f, a) => f(...a)
1379
1414
  });
@@ -1395,7 +1430,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1395
1430
  if (!this._remoteLength.has(feed.key)) {
1396
1431
  (0, import_log3.log)("blocks not pushed because remote length is unknown", void 0, {
1397
1432
  F: __dxlog_file5,
1398
- L: 266,
1433
+ L: 269,
1399
1434
  S: this,
1400
1435
  C: (f, a) => f(...a)
1401
1436
  });
@@ -1411,7 +1446,34 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1411
1446
  _usingCtx.d();
1412
1447
  }
1413
1448
  }
1449
+ _createConnectionContext() {
1450
+ const connectionCtx = new import_context3.Context({
1451
+ onError: async (err) => {
1452
+ if (connectionCtx !== this._connectionCtx) {
1453
+ return;
1454
+ }
1455
+ if (err instanceof import_edge_client.EdgeIdentityChangedError || err instanceof import_edge_client.EdgeConnectionClosedError) {
1456
+ (0, import_log3.log)("resetting on reconnect", void 0, {
1457
+ F: __dxlog_file5,
1458
+ L: 286,
1459
+ S: this,
1460
+ C: (f, a) => f(...a)
1461
+ });
1462
+ await this._resetConnection();
1463
+ } else {
1464
+ this._ctx.raise(err);
1465
+ }
1466
+ }
1467
+ }, {
1468
+ F: __dxlog_file5,
1469
+ L: 280
1470
+ });
1471
+ return connectionCtx;
1472
+ }
1414
1473
  };
1474
+ _ts_decorate([
1475
+ import_log3.logInfo
1476
+ ], EdgeFeedReplicator.prototype, "_spaceId", void 0);
1415
1477
  var bufferizeBlock = (block) => ({
1416
1478
  index: block.index,
1417
1479
  data: (0, import_util3.arrayToBuffer)(block.data),
@@ -1628,45 +1690,57 @@ var runEpochMigration = async (ctx, context) => {
1628
1690
  }
1629
1691
  return {};
1630
1692
  };
1693
+ function _ts_decorate2(decorators, target, key, desc) {
1694
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1695
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1696
+ 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;
1697
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1698
+ }
1631
1699
  var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
1632
1700
  var DEFAULT_RETRY_TIMEOUT = 1e3;
1633
1701
  var DEFAULT_SUCCESS_DELAY = 1e3;
1634
1702
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
1703
+ var MAX_EDGE_RETRIES = 2;
1635
1704
  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
- });
1705
+ var credentialCodec = import_proto2.schema.getCodecForType("dxos.halo.credentials.Credential");
1706
+ var NotarizationPlugin = class extends import_context6.Resource {
1707
+ constructor(params) {
1708
+ super();
1642
1709
  this._extensionOpened = new import_async9.Event();
1643
1710
  this._extensions = /* @__PURE__ */ new Set();
1644
1711
  this._processedCredentials = new import_util5.ComplexSet(import_keys5.PublicKey.hash);
1645
1712
  this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys5.PublicKey.hash);
1713
+ this._spaceId = params.spaceId;
1714
+ if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
1715
+ this._edgeClient = params.edgeClient;
1716
+ }
1646
1717
  }
1647
1718
  get hasWriter() {
1648
1719
  return !!this._writer;
1649
1720
  }
1650
- async open() {
1721
+ async _open() {
1722
+ if (this._edgeClient && this._writer) {
1723
+ this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1724
+ }
1651
1725
  }
1652
- async close() {
1726
+ async _close() {
1653
1727
  await this._ctx.dispose();
1654
1728
  }
1655
1729
  /**
1656
1730
  * Request credentials to be notarized.
1657
1731
  */
1658
- async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
1732
+ async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY, edgeRetryJitter }) {
1659
1733
  (0, import_log6.log)("notarize", {
1660
1734
  credentials
1661
1735
  }, {
1662
1736
  F: __dxlog_file7,
1663
- L: 90,
1737
+ L: 126,
1664
1738
  S: this,
1665
1739
  C: (f, a) => f(...a)
1666
1740
  });
1667
1741
  (0, import_invariant5.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
1668
1742
  F: __dxlog_file7,
1669
- L: 91,
1743
+ L: 127,
1670
1744
  S: this,
1671
1745
  A: [
1672
1746
  "credentials.every((credential) => credential.id)",
@@ -1680,7 +1754,7 @@ var NotarizationPlugin = class {
1680
1754
  err
1681
1755
  }, {
1682
1756
  F: __dxlog_file7,
1683
- L: 99,
1757
+ L: 135,
1684
1758
  S: this,
1685
1759
  C: (f, a) => f(...a)
1686
1760
  });
@@ -1690,21 +1764,37 @@ var NotarizationPlugin = class {
1690
1764
  });
1691
1765
  opCtx?.onDispose(() => ctx.dispose());
1692
1766
  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);
1767
+ this._scheduleTimeout(ctx, errors, timeout);
1706
1768
  }
1707
1769
  const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
1770
+ this._tryNotarizeCredentialsWithPeers(ctx, credentials, {
1771
+ retryTimeout,
1772
+ successDelay
1773
+ });
1774
+ if (this._edgeClient) {
1775
+ this._tryNotarizeCredentialsWithEdge(ctx, this._edgeClient, credentials, {
1776
+ retryTimeout,
1777
+ successDelay,
1778
+ jitter: edgeRetryJitter
1779
+ });
1780
+ }
1781
+ try {
1782
+ await Promise.race([
1783
+ (0, import_context6.rejectOnDispose)(ctx),
1784
+ allNotarized,
1785
+ errors.wait()
1786
+ ]);
1787
+ (0, import_log6.log)("done", void 0, {
1788
+ F: __dxlog_file7,
1789
+ L: 160,
1790
+ S: this,
1791
+ C: (f, a) => f(...a)
1792
+ });
1793
+ } finally {
1794
+ await ctx.dispose();
1795
+ }
1796
+ }
1797
+ _tryNotarizeCredentialsWithPeers(ctx, credentials, { retryTimeout, successDelay }) {
1708
1798
  const peersTried = /* @__PURE__ */ new Set();
1709
1799
  const notarizeTask = new import_async9.DeferredTask(ctx, async () => {
1710
1800
  try {
@@ -1719,7 +1809,7 @@ var NotarizationPlugin = class {
1719
1809
  retryIn: retryTimeout
1720
1810
  }, {
1721
1811
  F: __dxlog_file7,
1722
- L: 136,
1812
+ L: 183,
1723
1813
  S: this,
1724
1814
  C: (f, a) => f(...a)
1725
1815
  });
@@ -1733,7 +1823,7 @@ var NotarizationPlugin = class {
1733
1823
  credentialId: credentials.map((credential) => credential.id)
1734
1824
  }, {
1735
1825
  F: __dxlog_file7,
1736
- L: 143,
1826
+ L: 190,
1737
1827
  S: this,
1738
1828
  C: (f, a) => f(...a)
1739
1829
  });
@@ -1742,7 +1832,7 @@ var NotarizationPlugin = class {
1742
1832
  });
1743
1833
  (0, import_log6.log)("success", void 0, {
1744
1834
  F: __dxlog_file7,
1745
- L: 147,
1835
+ L: 194,
1746
1836
  S: this,
1747
1837
  C: (f, a) => f(...a)
1748
1838
  });
@@ -1751,7 +1841,7 @@ var NotarizationPlugin = class {
1751
1841
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
1752
1842
  import_log6.log.info("error notarizing (recoverable)", err, {
1753
1843
  F: __dxlog_file7,
1754
- L: 151,
1844
+ L: 199,
1755
1845
  S: this,
1756
1846
  C: (f, a) => f(...a)
1757
1847
  });
@@ -1761,21 +1851,33 @@ var NotarizationPlugin = class {
1761
1851
  });
1762
1852
  notarizeTask.schedule();
1763
1853
  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
- }
1854
+ }
1855
+ _tryNotarizeCredentialsWithEdge(ctx, client, credentials, timeouts) {
1856
+ const encodedCredentials = credentials.map((credential) => {
1857
+ const binary = credentialCodec.encode(credential);
1858
+ return Buffer.from(binary).toString("base64");
1859
+ });
1860
+ (0, import_async9.scheduleTask)(ctx, async () => {
1861
+ try {
1862
+ await client.notarizeCredentials(this._spaceId, {
1863
+ credentials: encodedCredentials
1864
+ }, {
1865
+ retry: {
1866
+ count: MAX_EDGE_RETRIES,
1867
+ timeout: timeouts.retryTimeout,
1868
+ jitter: timeouts.jitter
1869
+ }
1870
+ });
1871
+ (0, import_log6.log)("edge notarization success", void 0, {
1872
+ F: __dxlog_file7,
1873
+ L: 227,
1874
+ S: this,
1875
+ C: (f, a) => f(...a)
1876
+ });
1877
+ } catch (error) {
1878
+ handleEdgeError(error);
1879
+ }
1880
+ });
1779
1881
  }
1780
1882
  /**
1781
1883
  * Called with credentials arriving from the control pipeline.
@@ -1791,7 +1893,7 @@ var NotarizationPlugin = class {
1791
1893
  setWriter(writer) {
1792
1894
  (0, import_invariant5.invariant)(!this._writer, "Writer already set.", {
1793
1895
  F: __dxlog_file7,
1794
- L: 181,
1896
+ L: 247,
1795
1897
  S: this,
1796
1898
  A: [
1797
1899
  "!this._writer",
@@ -1799,6 +1901,59 @@ var NotarizationPlugin = class {
1799
1901
  ]
1800
1902
  });
1801
1903
  this._writer = writer;
1904
+ if (this._edgeClient) {
1905
+ this._notarizePendingEdgeCredentials(this._edgeClient, writer);
1906
+ }
1907
+ }
1908
+ /**
1909
+ * The method is used only for adding agent feeds to spaces.
1910
+ * When an agent is created we can admit them into all the existing spaces. In case the operation fails
1911
+ * this method will fix it on the next space open.
1912
+ * Given how rarely this happens there's no need to poll the endpoint.
1913
+ */
1914
+ _notarizePendingEdgeCredentials(client, writer) {
1915
+ (0, import_async9.scheduleMicroTask)(this._ctx, async () => {
1916
+ try {
1917
+ const response = await client.getCredentialsForNotarization(this._spaceId, {
1918
+ retry: {
1919
+ count: MAX_EDGE_RETRIES
1920
+ }
1921
+ });
1922
+ const credentials = response.awaitingNotarization.credentials;
1923
+ if (!credentials.length) {
1924
+ (0, import_log6.log)("edge did not return credentials for notarization", void 0, {
1925
+ F: __dxlog_file7,
1926
+ L: 269,
1927
+ S: this,
1928
+ C: (f, a) => f(...a)
1929
+ });
1930
+ return;
1931
+ }
1932
+ (0, import_log6.log)("got edge credentials for notarization", {
1933
+ count: credentials.length
1934
+ }, {
1935
+ F: __dxlog_file7,
1936
+ L: 273,
1937
+ S: this,
1938
+ C: (f, a) => f(...a)
1939
+ });
1940
+ const decodedCredentials = credentials.map((credential) => {
1941
+ const binary = Buffer.from(credential, "base64");
1942
+ return credentialCodec.decode(binary);
1943
+ });
1944
+ await this._notarizeCredentials(writer, decodedCredentials);
1945
+ import_log6.log.info("notarized edge credentials", {
1946
+ count: decodedCredentials.length
1947
+ }, {
1948
+ F: __dxlog_file7,
1949
+ L: 282,
1950
+ S: this,
1951
+ C: (f, a) => f(...a)
1952
+ });
1953
+ } catch (error) {
1954
+ handleEdgeError(error);
1955
+ }
1956
+ });
1802
1957
  }
1803
1958
  async _waitUntilProcessed(id) {
1804
1959
  if (this._processedCredentials.has(id)) {
@@ -1813,10 +1968,13 @@ var NotarizationPlugin = class {
1813
1968
  if (!this._writer) {
1814
1969
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
1815
1970
  }
1816
- for (const credential of request.credentials ?? []) {
1971
+ await this._notarizeCredentials(this._writer, request.credentials ?? []);
1972
+ }
1973
+ async _notarizeCredentials(writer, credentials) {
1974
+ for (const credential of credentials) {
1817
1975
  (0, import_invariant5.invariant)(credential.id, "Credential must have an id", {
1818
1976
  F: __dxlog_file7,
1819
- L: 200,
1977
+ L: 308,
1820
1978
  S: this,
1821
1979
  A: [
1822
1980
  "credential.id",
@@ -1826,7 +1984,11 @@ var NotarizationPlugin = class {
1826
1984
  if (this._processedCredentials.has(credential.id)) {
1827
1985
  continue;
1828
1986
  }
1829
- await this._writer.write(credential);
1987
+ const verificationResult = await (0, import_credentials5.verifyCredential)(credential);
1988
+ if (verificationResult.kind === "fail") {
1989
+ throw new Error(`Credential verification failed: ${verificationResult.errors.join("\n")}.`);
1990
+ }
1991
+ await writer.write(credential);
1830
1992
  }
1831
1993
  }
1832
1994
  createExtension() {
@@ -1836,7 +1998,7 @@ var NotarizationPlugin = class {
1836
1998
  peer: extension.localPeerId
1837
1999
  }, {
1838
2000
  F: __dxlog_file7,
1839
- L: 211,
2001
+ L: 323,
1840
2002
  S: this,
1841
2003
  C: (f, a) => f(...a)
1842
2004
  });
@@ -1848,7 +2010,7 @@ var NotarizationPlugin = class {
1848
2010
  peer: extension.localPeerId
1849
2011
  }, {
1850
2012
  F: __dxlog_file7,
1851
- L: 216,
2013
+ L: 328,
1852
2014
  S: this,
1853
2015
  C: (f, a) => f(...a)
1854
2016
  });
@@ -1858,6 +2020,43 @@ var NotarizationPlugin = class {
1858
2020
  });
1859
2021
  return extension;
1860
2022
  }
2023
+ _scheduleTimeout(ctx, errors, timeout) {
2024
+ (0, import_async9.scheduleTask)(ctx, () => {
2025
+ import_log6.log.warn("Notarization timeout", {
2026
+ timeout,
2027
+ peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2028
+ }, {
2029
+ F: __dxlog_file7,
2030
+ L: 340,
2031
+ S: this,
2032
+ C: (f, a) => f(...a)
2033
+ });
2034
+ void ctx.dispose();
2035
+ errors.throw(new import_async9.TimeoutError(timeout, "Notarization timed out"));
2036
+ }, timeout);
2037
+ }
2038
+ };
2039
+ _ts_decorate2([
2040
+ import_log6.logInfo
2041
+ ], NotarizationPlugin.prototype, "_spaceId", void 0);
2042
+ var handleEdgeError = (error) => {
2043
+ if (!(error instanceof import_protocols4.EdgeCallFailedError) || error.errorData) {
2044
+ import_log6.log.catch(error, void 0, {
2045
+ F: __dxlog_file7,
2046
+ L: 354,
2047
+ S: void 0,
2048
+ C: (f, a) => f(...a)
2049
+ });
2050
+ } else {
2051
+ import_log6.log.info("Edge notarization failure", {
2052
+ reason: error.reason
2053
+ }, {
2054
+ F: __dxlog_file7,
2055
+ L: 356,
2056
+ S: void 0,
2057
+ C: (f, a) => f(...a)
2058
+ });
2059
+ }
1861
2060
  };
1862
2061
  var NotarizationTeleportExtension = class extends import_teleport.RpcExtension {
1863
2062
  constructor(_params) {
@@ -1898,7 +2097,7 @@ var DefaultSpaceStateMachine = class {
1898
2097
  return this._spaceId;
1899
2098
  }
1900
2099
  async processCredential(credential) {
1901
- const assertion = (0, import_credentials7.getCredentialAssertion)(credential);
2100
+ const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
1902
2101
  switch (assertion["@type"]) {
1903
2102
  case "dxos.halo.credentials.DefaultSpace": {
1904
2103
  if (!credential.subject.id.equals(this._params.identityKey)) {
@@ -1932,7 +2131,7 @@ var DefaultSpaceStateMachine = class {
1932
2131
  };
1933
2132
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1934
2133
  const credentials = [
1935
- await (0, import_credentials10.createCredential)({
2134
+ await (0, import_credentials11.createCredential)({
1936
2135
  signer: keyring,
1937
2136
  issuer: space.key,
1938
2137
  subject: space.key,
@@ -1941,14 +2140,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1941
2140
  spaceKey: space.key
1942
2141
  }
1943
2142
  }),
1944
- await (0, import_credentials10.createCredential)({
2143
+ await (0, import_credentials11.createCredential)({
1945
2144
  signer: keyring,
1946
2145
  issuer: space.key,
1947
2146
  subject: signingContext.identityKey,
1948
2147
  assertion: {
1949
2148
  "@type": "dxos.halo.credentials.SpaceMember",
1950
2149
  spaceKey: space.key,
1951
- role: import_credentials11.SpaceMember.Role.OWNER,
2150
+ role: import_credentials12.SpaceMember.Role.OWNER,
1952
2151
  profile: signingContext.getProfile(),
1953
2152
  genesisFeedKey: space.controlFeedKey ?? (0, import_debug2.failUndefined)()
1954
2153
  }
@@ -1960,7 +2159,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1960
2159
  spaceKey: space.key,
1961
2160
  identityKey: signingContext.identityKey,
1962
2161
  deviceKey: signingContext.deviceKey,
1963
- designation: import_credentials11.AdmittedFeed.Designation.CONTROL
2162
+ designation: import_credentials12.AdmittedFeed.Designation.CONTROL
1964
2163
  }
1965
2164
  }),
1966
2165
  await signingContext.credentialSigner.createCredential({
@@ -1970,7 +2169,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1970
2169
  spaceKey: space.key,
1971
2170
  identityKey: signingContext.identityKey,
1972
2171
  deviceKey: signingContext.deviceKey,
1973
- designation: import_credentials11.AdmittedFeed.Designation.DATA
2172
+ designation: import_credentials12.AdmittedFeed.Designation.DATA
1974
2173
  }
1975
2174
  }),
1976
2175
  await signingContext.credentialSigner.createCredential({
@@ -1994,7 +2193,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
1994
2193
  }
1995
2194
  return credentials;
1996
2195
  };
1997
- function _ts_decorate(decorators, target, key, desc) {
2196
+ function _ts_decorate3(decorators, target, key, desc) {
1998
2197
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1999
2198
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2000
2199
  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 +2210,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2011
2210
  this._spaces = new import_util7.ComplexMap(import_keys8.PublicKey.hash);
2012
2211
  this._instanceId = import_keys8.PublicKey.random().toHex();
2013
2212
  this._edgeConnection = void 0;
2213
+ this._edgeHttpClient = void 0;
2014
2214
  this._edgeFeatures = void 0;
2015
2215
  this._meshReplicator = void 0;
2016
2216
  this._echoEdgeReplicator = void 0;
@@ -2026,6 +2226,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2026
2226
  this._edgeConnection = params.edgeConnection;
2027
2227
  this._edgeFeatures = params.edgeFeatures;
2028
2228
  this._echoEdgeReplicator = params.echoEdgeReplicator;
2229
+ this._edgeHttpClient = params.edgeHttpClient;
2029
2230
  this._runtimeParams = params.runtimeParams;
2030
2231
  import_tracing5.trace.diagnostic({
2031
2232
  id: "spaces",
@@ -2057,15 +2258,15 @@ var DataSpaceManager = class extends import_context7.Resource {
2057
2258
  async _open() {
2058
2259
  (0, import_log9.log)("open", void 0, {
2059
2260
  F: __dxlog_file9,
2060
- L: 195,
2261
+ L: 198,
2061
2262
  S: this,
2062
2263
  C: (f, a) => f(...a)
2063
2264
  });
2064
- import_log9.log.trace("dxos.echo.data-space-manager.open", import_protocols4.trace.begin({
2265
+ import_log9.log.trace("dxos.echo.data-space-manager.open", import_protocols5.trace.begin({
2065
2266
  id: this._instanceId
2066
2267
  }), {
2067
2268
  F: __dxlog_file9,
2068
- L: 196,
2269
+ L: 199,
2069
2270
  S: this,
2070
2271
  C: (f, a) => f(...a)
2071
2272
  });
@@ -2073,7 +2274,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2073
2274
  spaces: this._metadataStore.spaces.length
2074
2275
  }, {
2075
2276
  F: __dxlog_file9,
2076
- L: 197,
2277
+ L: 200,
2077
2278
  S: this,
2078
2279
  C: (f, a) => f(...a)
2079
2280
  });
@@ -2083,7 +2284,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2083
2284
  spaceMetadata
2084
2285
  }, {
2085
2286
  F: __dxlog_file9,
2086
- L: 201,
2287
+ L: 204,
2087
2288
  S: this,
2088
2289
  C: (f, a) => f(...a)
2089
2290
  });
@@ -2094,18 +2295,18 @@ var DataSpaceManager = class extends import_context7.Resource {
2094
2295
  err
2095
2296
  }, {
2096
2297
  F: __dxlog_file9,
2097
- L: 204,
2298
+ L: 207,
2098
2299
  S: this,
2099
2300
  C: (f, a) => f(...a)
2100
2301
  });
2101
2302
  }
2102
2303
  });
2103
2304
  this.updated.emit();
2104
- import_log9.log.trace("dxos.echo.data-space-manager.open", import_protocols4.trace.end({
2305
+ import_log9.log.trace("dxos.echo.data-space-manager.open", import_protocols5.trace.end({
2105
2306
  id: this._instanceId
2106
2307
  }), {
2107
2308
  F: __dxlog_file9,
2108
- L: 210,
2309
+ L: 213,
2109
2310
  S: this,
2110
2311
  C: (f, a) => f(...a)
2111
2312
  });
@@ -2113,7 +2314,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2113
2314
  async _close() {
2114
2315
  (0, import_log9.log)("close", void 0, {
2115
2316
  F: __dxlog_file9,
2116
- L: 215,
2317
+ L: 218,
2117
2318
  S: this,
2118
2319
  C: (f, a) => f(...a)
2119
2320
  });
@@ -2128,7 +2329,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2128
2329
  async createSpace() {
2129
2330
  (0, import_invariant7.invariant)(this._lifecycleState === import_context7.LifecycleState.OPEN, "Not open.", {
2130
2331
  F: __dxlog_file9,
2131
- L: 227,
2332
+ L: 230,
2132
2333
  S: this,
2133
2334
  A: [
2134
2335
  "this._lifecycleState === LifecycleState.OPEN",
@@ -2149,7 +2350,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2149
2350
  spaceKey
2150
2351
  }, {
2151
2352
  F: __dxlog_file9,
2152
- L: 239,
2353
+ L: 242,
2153
2354
  S: this,
2154
2355
  C: (f, a) => f(...a)
2155
2356
  });
@@ -2159,9 +2360,9 @@ var DataSpaceManager = class extends import_context7.Resource {
2159
2360
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
2160
2361
  await this._metadataStore.addSpace(metadata);
2161
2362
  const memberCredential = credentials[1];
2162
- (0, import_invariant7.invariant)((0, import_credentials8.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2363
+ (0, import_invariant7.invariant)((0, import_credentials9.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2163
2364
  F: __dxlog_file9,
2164
- L: 249,
2365
+ L: 252,
2165
2366
  S: this,
2166
2367
  A: [
2167
2368
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2193,7 +2394,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2193
2394
  spaceId: space.id
2194
2395
  }, {
2195
2396
  F: __dxlog_file9,
2196
- L: 274,
2397
+ L: 277,
2197
2398
  S: this,
2198
2399
  C: (f, a) => f(...a)
2199
2400
  });
@@ -2228,7 +2429,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2228
2429
  const automergeIndex = space.automergeSpaceState.rootUrl;
2229
2430
  (0, import_invariant7.invariant)(automergeIndex, void 0, {
2230
2431
  F: __dxlog_file9,
2231
- L: 307,
2432
+ L: 310,
2232
2433
  S: this,
2233
2434
  A: [
2234
2435
  "automergeIndex",
@@ -2245,13 +2446,13 @@ var DataSpaceManager = class extends import_context7.Resource {
2245
2446
  opts
2246
2447
  }, {
2247
2448
  F: __dxlog_file9,
2248
- L: 316,
2449
+ L: 319,
2249
2450
  S: this,
2250
2451
  C: (f, a) => f(...a)
2251
2452
  });
2252
2453
  (0, import_invariant7.invariant)(this._lifecycleState === import_context7.LifecycleState.OPEN, "Not open.", {
2253
2454
  F: __dxlog_file9,
2254
- L: 317,
2455
+ L: 320,
2255
2456
  S: this,
2256
2457
  A: [
2257
2458
  "this._lifecycleState === LifecycleState.OPEN",
@@ -2260,7 +2461,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2260
2461
  });
2261
2462
  (0, import_invariant7.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
2262
2463
  F: __dxlog_file9,
2263
- L: 318,
2464
+ L: 321,
2264
2465
  S: this,
2265
2466
  A: [
2266
2467
  "!this._spaces.has(opts.spaceKey)",
@@ -2284,20 +2485,20 @@ var DataSpaceManager = class extends import_context7.Resource {
2284
2485
  const space = this._spaceManager.spaces.get(options.spaceKey);
2285
2486
  (0, import_invariant7.invariant)(space, void 0, {
2286
2487
  F: __dxlog_file9,
2287
- L: 338,
2488
+ L: 341,
2288
2489
  S: this,
2289
2490
  A: [
2290
2491
  "space",
2291
2492
  ""
2292
2493
  ]
2293
2494
  });
2294
- if (space.spaceState.getMemberRole(options.identityKey) !== import_credentials9.SpaceMember.Role.REMOVED) {
2295
- throw new import_protocols4.AlreadyJoinedError();
2495
+ if (space.spaceState.getMemberRole(options.identityKey) !== import_credentials10.SpaceMember.Role.REMOVED) {
2496
+ throw new import_protocols5.AlreadyJoinedError();
2296
2497
  }
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);
2498
+ 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
2499
  (0, import_invariant7.invariant)(credentials[0].credential, void 0, {
2299
2500
  F: __dxlog_file9,
2300
- L: 357,
2501
+ L: 360,
2301
2502
  S: this,
2302
2503
  A: [
2303
2504
  "credentials[0].credential",
@@ -2305,9 +2506,9 @@ var DataSpaceManager = class extends import_context7.Resource {
2305
2506
  ]
2306
2507
  });
2307
2508
  const spaceMemberCredential = credentials[0].credential.credential;
2308
- (0, import_invariant7.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2509
+ (0, import_invariant7.invariant)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2309
2510
  F: __dxlog_file9,
2310
- L: 359,
2511
+ L: 362,
2311
2512
  S: this,
2312
2513
  A: [
2313
2514
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2341,12 +2542,35 @@ var DataSpaceManager = class extends import_context7.Resource {
2341
2542
  }
2342
2543
  });
2343
2544
  }
2545
+ async setSpaceEdgeReplicationSetting(spaceKey, setting) {
2546
+ const space = this._spaces.get(spaceKey);
2547
+ (0, import_invariant7.invariant)(space, "Space not found.", {
2548
+ F: __dxlog_file9,
2549
+ L: 399,
2550
+ S: this,
2551
+ A: [
2552
+ "space",
2553
+ "'Space not found.'"
2554
+ ]
2555
+ });
2556
+ await this._metadataStore.setSpaceEdgeReplicationSetting(spaceKey, setting);
2557
+ if (space.isOpen) {
2558
+ switch (setting) {
2559
+ case import_metadata.EdgeReplicationSetting.DISABLED:
2560
+ await this._echoEdgeReplicator?.disconnectFromSpace(space.id);
2561
+ break;
2562
+ case import_metadata.EdgeReplicationSetting.ENABLED:
2563
+ await this._echoEdgeReplicator?.connectToSpace(space.id);
2564
+ break;
2565
+ }
2566
+ }
2567
+ }
2344
2568
  async _constructSpace(metadata) {
2345
2569
  (0, import_log9.log)("construct space", {
2346
2570
  metadata
2347
2571
  }, {
2348
2572
  F: __dxlog_file9,
2349
- L: 395,
2573
+ L: 416,
2350
2574
  S: this,
2351
2575
  C: (f, a) => f(...a)
2352
2576
  });
@@ -2390,7 +2614,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2390
2614
  err
2391
2615
  }, {
2392
2616
  F: __dxlog_file9,
2393
- L: 437,
2617
+ L: 458,
2394
2618
  S: this,
2395
2619
  C: (f, a) => f(...a)
2396
2620
  });
@@ -2400,7 +2624,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2400
2624
  onAuthFailure: () => {
2401
2625
  import_log9.log.warn("auth failure", void 0, {
2402
2626
  F: __dxlog_file9,
2403
- L: 442,
2627
+ L: 463,
2404
2628
  S: this,
2405
2629
  C: (f, a) => f(...a)
2406
2630
  });
@@ -2433,7 +2657,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2433
2657
  space: space.key
2434
2658
  }, {
2435
2659
  F: __dxlog_file9,
2436
- L: 469,
2660
+ L: 490,
2437
2661
  S: this,
2438
2662
  C: (f, a) => f(...a)
2439
2663
  });
@@ -2444,7 +2668,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2444
2668
  open: this._lifecycleState === import_context7.LifecycleState.OPEN
2445
2669
  }, {
2446
2670
  F: __dxlog_file9,
2447
- L: 472,
2671
+ L: 493,
2448
2672
  S: this,
2449
2673
  C: (f, a) => f(...a)
2450
2674
  });
@@ -2463,7 +2687,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2463
2687
  space: space.key
2464
2688
  }, {
2465
2689
  F: __dxlog_file9,
2466
- L: 480,
2690
+ L: 501,
2467
2691
  S: this,
2468
2692
  C: (f, a) => f(...a)
2469
2693
  });
@@ -2471,13 +2695,20 @@ var DataSpaceManager = class extends import_context7.Resource {
2471
2695
  },
2472
2696
  cache: metadata.cache,
2473
2697
  edgeConnection: this._edgeConnection,
2698
+ edgeHttpClient: this._edgeHttpClient,
2474
2699
  edgeFeatures: this._edgeFeatures
2475
2700
  });
2476
2701
  dataSpace.postOpen.append(async () => {
2477
- await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2702
+ const setting = dataSpace.getEdgeReplicationSetting();
2703
+ if (setting === import_metadata.EdgeReplicationSetting.ENABLED) {
2704
+ await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
2705
+ }
2478
2706
  });
2479
2707
  dataSpace.preClose.append(async () => {
2480
- await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2708
+ const setting = dataSpace.getEdgeReplicationSetting();
2709
+ if (setting === import_metadata.EdgeReplicationSetting.ENABLED) {
2710
+ await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
2711
+ }
2481
2712
  });
2482
2713
  presence.newPeer.on((peerState) => {
2483
2714
  if (dataSpace.state === import_services6.SpaceState.SPACE_READY) {
@@ -2497,7 +2728,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2497
2728
  space: space.key
2498
2729
  }, {
2499
2730
  F: __dxlog_file9,
2500
- L: 511,
2731
+ L: 539,
2501
2732
  S: this,
2502
2733
  C: (f, a) => f(...a)
2503
2734
  });
@@ -2517,7 +2748,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2517
2748
  const peers = presence.getPeersByIdentityKey(member.key);
2518
2749
  const sessions = peers.map((p) => p.peerId && spaceProtocol.sessions.get(p.peerId));
2519
2750
  const sessionsToClose = sessions.filter((s) => {
2520
- return (s && member.role === import_credentials9.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline3.AuthStatus.FAILURE)) ?? false;
2751
+ return (s && member.role === import_credentials10.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline3.AuthStatus.FAILURE)) ?? false;
2521
2752
  });
2522
2753
  sessionsToClose.forEach((session) => {
2523
2754
  void session.close().catch(import_log9.log.error);
@@ -2530,7 +2761,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2530
2761
  closedSessions
2531
2762
  }, {
2532
2763
  F: __dxlog_file9,
2533
- L: 537,
2764
+ L: 565,
2534
2765
  S: this,
2535
2766
  C: (f, a) => f(...a)
2536
2767
  });
@@ -2538,14 +2769,14 @@ var DataSpaceManager = class extends import_context7.Resource {
2538
2769
  }
2539
2770
  _handleNewPeerConnected(space, peerState) {
2540
2771
  const role = space.spaceState.getMemberRole(peerState.identityKey);
2541
- if (role === import_credentials9.SpaceMember.Role.REMOVED) {
2772
+ if (role === import_credentials10.SpaceMember.Role.REMOVED) {
2542
2773
  const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
2543
2774
  if (session != null) {
2544
2775
  (0, import_log9.log)("closing a session with a removed peer", {
2545
2776
  peerId: peerState.peerId
2546
2777
  }, {
2547
2778
  F: __dxlog_file9,
2548
- L: 551,
2779
+ L: 579,
2549
2780
  S: this,
2550
2781
  C: (f, a) => f(...a)
2551
2782
  });
@@ -2589,19 +2820,19 @@ var DataSpaceManager = class extends import_context7.Resource {
2589
2820
  await Promise.all(tasks);
2590
2821
  }
2591
2822
  };
2592
- _ts_decorate([
2823
+ _ts_decorate3([
2593
2824
  import_async11.synchronized
2594
2825
  ], DataSpaceManager.prototype, "_open", null);
2595
- _ts_decorate([
2826
+ _ts_decorate3([
2596
2827
  import_async11.synchronized
2597
2828
  ], DataSpaceManager.prototype, "_close", null);
2598
- _ts_decorate([
2829
+ _ts_decorate3([
2599
2830
  import_async11.synchronized
2600
2831
  ], DataSpaceManager.prototype, "createSpace", null);
2601
- _ts_decorate([
2832
+ _ts_decorate3([
2602
2833
  import_async11.synchronized
2603
2834
  ], DataSpaceManager.prototype, "acceptSpace", null);
2604
- DataSpaceManager = _ts_decorate([
2835
+ DataSpaceManager = _ts_decorate3([
2605
2836
  (0, import_async11.trackLeaks)("open", "close")
2606
2837
  ], DataSpaceManager);
2607
2838
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
@@ -2618,9 +2849,9 @@ var SpacesServiceImpl = class {
2618
2849
  await this._updateMetrics();
2619
2850
  return this._serializeSpace(space);
2620
2851
  }
2621
- async updateSpace({ spaceKey, state }) {
2852
+ async updateSpace({ spaceKey, state, edgeReplication }) {
2622
2853
  const dataSpaceManager = await this._getDataSpaceManager();
2623
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols5.SpaceNotFoundError(spaceKey));
2854
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2624
2855
  if (state) {
2625
2856
  switch (state) {
2626
2857
  case import_services7.SpaceState.SPACE_ACTIVE:
@@ -2630,26 +2861,29 @@ var SpacesServiceImpl = class {
2630
2861
  await space.deactivate();
2631
2862
  break;
2632
2863
  default:
2633
- throw new import_protocols5.ApiError("Invalid space state");
2864
+ throw new import_protocols6.ApiError("Invalid space state");
2634
2865
  }
2635
2866
  }
2867
+ if (edgeReplication !== void 0) {
2868
+ await dataSpaceManager.setSpaceEdgeReplicationSetting(spaceKey, edgeReplication);
2869
+ }
2636
2870
  }
2637
2871
  async updateMemberRole(request) {
2638
2872
  const identity = this._requireIdentity();
2639
2873
  const space = this._spaceManager.spaces.get(request.spaceKey);
2640
2874
  if (space == null) {
2641
- throw new import_protocols5.SpaceNotFoundError(request.spaceKey);
2875
+ throw new import_protocols6.SpaceNotFoundError(request.spaceKey);
2642
2876
  }
2643
2877
  if (!space.spaceState.hasMembershipManagementPermission(identity.identityKey)) {
2644
- throw new import_protocols5.AuthorizationError("No member management permission.", {
2878
+ throw new import_protocols6.AuthorizationError("No member management permission.", {
2645
2879
  spaceKey: space.key,
2646
2880
  role: space.spaceState.getMemberRole(identity.identityKey)
2647
2881
  });
2648
2882
  }
2649
- const credentials = await (0, import_credentials12.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2883
+ const credentials = await (0, import_credentials13.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2650
2884
  (0, import_invariant8.invariant)(credentials[0].credential, void 0, {
2651
2885
  F: __dxlog_file10,
2652
- L: 102,
2886
+ L: 106,
2653
2887
  S: this,
2654
2888
  A: [
2655
2889
  "credentials[0].credential",
@@ -2657,9 +2891,9 @@ var SpacesServiceImpl = class {
2657
2891
  ]
2658
2892
  });
2659
2893
  const spaceMemberCredential = credentials[0].credential.credential;
2660
- (0, import_invariant8.invariant)((0, import_credentials12.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2894
+ (0, import_invariant8.invariant)((0, import_credentials13.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2661
2895
  F: __dxlog_file10,
2662
- L: 104,
2896
+ L: 108,
2663
2897
  S: this,
2664
2898
  A: [
2665
2899
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2677,7 +2911,7 @@ var SpacesServiceImpl = class {
2677
2911
  ids: spaces.map((space) => space.id)
2678
2912
  }), {
2679
2913
  F: __dxlog_file10,
2680
- L: 115,
2914
+ L: 119,
2681
2915
  S: this,
2682
2916
  C: (f, a) => f(...a)
2683
2917
  });
@@ -2725,14 +2959,14 @@ var SpacesServiceImpl = class {
2725
2959
  }
2726
2960
  async postMessage({ spaceKey, channel, message }) {
2727
2961
  const dataSpaceManager = await this._getDataSpaceManager();
2728
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols5.SpaceNotFoundError(spaceKey));
2962
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2729
2963
  await space.postMessage(getChannelId(channel), message);
2730
2964
  }
2731
2965
  subscribeMessages({ spaceKey, channel }) {
2732
2966
  return new import_codec_protobuf8.Stream(({ ctx, next }) => {
2733
2967
  (0, import_async12.scheduleTask)(ctx, async () => {
2734
2968
  const dataSpaceManager = await this._getDataSpaceManager();
2735
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols5.SpaceNotFoundError(spaceKey));
2969
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2736
2970
  const handle = space.listen(getChannelId(channel), (message) => {
2737
2971
  next(message);
2738
2972
  });
@@ -2742,7 +2976,7 @@ var SpacesServiceImpl = class {
2742
2976
  }
2743
2977
  queryCredentials({ spaceKey, noTail }) {
2744
2978
  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));
2979
+ const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2746
2980
  const processor = {
2747
2981
  processCredential: async (credential) => {
2748
2982
  next(credential);
@@ -2758,7 +2992,7 @@ var SpacesServiceImpl = class {
2758
2992
  });
2759
2993
  }
2760
2994
  async writeCredentials({ spaceKey, credentials }) {
2761
- const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols5.SpaceNotFoundError(spaceKey));
2995
+ const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2762
2996
  for (const credential of credentials ?? []) {
2763
2997
  if (credential.proof) {
2764
2998
  await space.controlPipeline.writer.write({
@@ -2769,7 +3003,7 @@ var SpacesServiceImpl = class {
2769
3003
  } else {
2770
3004
  (0, import_invariant8.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
2771
3005
  F: __dxlog_file10,
2772
- L: 213,
3006
+ L: 217,
2773
3007
  S: this,
2774
3008
  A: [
2775
3009
  "!credential.id",
@@ -2778,7 +3012,7 @@ var SpacesServiceImpl = class {
2778
3012
  });
2779
3013
  (0, import_invariant8.invariant)(this._identityManager.identity, "Identity is not available", {
2780
3014
  F: __dxlog_file10,
2781
- L: 214,
3015
+ L: 218,
2782
3016
  S: this,
2783
3017
  A: [
2784
3018
  "this._identityManager.identity",
@@ -2788,7 +3022,7 @@ var SpacesServiceImpl = class {
2788
3022
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
2789
3023
  (0, import_invariant8.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
2790
3024
  F: __dxlog_file10,
2791
- L: 216,
3025
+ L: 220,
2792
3026
  S: this,
2793
3027
  A: [
2794
3028
  "credential.issuer.equals(signer.getIssuer())",
@@ -2809,7 +3043,7 @@ var SpacesServiceImpl = class {
2809
3043
  }
2810
3044
  async createEpoch({ spaceKey, migration, automergeRootUrl }) {
2811
3045
  const dataSpaceManager = await this._getDataSpaceManager();
2812
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols5.SpaceNotFoundError(spaceKey));
3046
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
2813
3047
  const result = await space.createEpoch({
2814
3048
  migration,
2815
3049
  newAutomergeRoot: automergeRootUrl
@@ -2835,10 +3069,10 @@ var SpacesServiceImpl = class {
2835
3069
  });
2836
3070
  }
2837
3071
  async _joinByAdmission({ credential }) {
2838
- const assertion = (0, import_credentials12.getCredentialAssertion)(credential);
3072
+ const assertion = (0, import_credentials13.getCredentialAssertion)(credential);
2839
3073
  (0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2840
3074
  F: __dxlog_file10,
2841
- L: 250,
3075
+ L: 254,
2842
3076
  S: this,
2843
3077
  A: [
2844
3078
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2848,7 +3082,7 @@ var SpacesServiceImpl = class {
2848
3082
  const myIdentity = this._identityManager.identity;
2849
3083
  (0, import_invariant8.invariant)(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
2850
3084
  F: __dxlog_file10,
2851
- L: 252,
3085
+ L: 256,
2852
3086
  S: this,
2853
3087
  A: [
2854
3088
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -2877,7 +3111,7 @@ var SpacesServiceImpl = class {
2877
3111
  id: space.id,
2878
3112
  spaceKey: space.key,
2879
3113
  state: space.state,
2880
- error: space.error ? (0, import_protocols5.encodeError)(space.error) : void 0,
3114
+ error: space.error ? (0, import_protocols6.encodeError)(space.error) : void 0,
2881
3115
  pipeline: {
2882
3116
  currentEpoch: space.automergeSpaceState.lastEpoch,
2883
3117
  appliedEpoch: space.automergeSpaceState.lastEpoch,
@@ -2910,12 +3144,13 @@ var SpacesServiceImpl = class {
2910
3144
  }),
2911
3145
  creator: space.inner.spaceState.creator?.key,
2912
3146
  cache: space.cache,
2913
- metrics: space.metrics
3147
+ metrics: space.metrics,
3148
+ edgeReplication: space.getEdgeReplicationSetting()
2914
3149
  };
2915
3150
  }
2916
3151
  _requireIdentity() {
2917
3152
  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");
3153
+ throw new import_protocols6.IdentityNotInitializedError("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
2919
3154
  }
2920
3155
  return this._identityManager.identity;
2921
3156
  }
@@ -2932,7 +3167,7 @@ var SpacesServiceImpl = class {
2932
3167
  }
2933
3168
  };
2934
3169
  var getChannelId = (channel) => `user-channel/${channel}`;
2935
- function _ts_decorate2(decorators, target, key, desc) {
3170
+ function _ts_decorate4(decorators, target, key, desc) {
2936
3171
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2937
3172
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2938
3173
  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 +3194,12 @@ var Identity = class {
2959
3194
  S: this,
2960
3195
  C: (f, a) => f(...a)
2961
3196
  });
2962
- this._deviceStateMachine = new import_credentials5.DeviceStateMachine({
3197
+ this._deviceStateMachine = new import_credentials6.DeviceStateMachine({
2963
3198
  identityKey: this.identityKey,
2964
3199
  deviceKey: this.deviceKey,
2965
3200
  onUpdate: () => this.stateUpdate.emit()
2966
3201
  });
2967
- this._profileStateMachine = new import_credentials5.ProfileStateMachine({
3202
+ this._profileStateMachine = new import_credentials6.ProfileStateMachine({
2968
3203
  identityKey: this.identityKey,
2969
3204
  onUpdate: () => this.stateUpdate.emit()
2970
3205
  });
@@ -3041,6 +3276,9 @@ var Identity = class {
3041
3276
  get presence() {
3042
3277
  return this._presence;
3043
3278
  }
3279
+ get signer() {
3280
+ return this._signer;
3281
+ }
3044
3282
  /**
3045
3283
  * Issues credentials as identity.
3046
3284
  * Requires identity to be ready.
@@ -3048,20 +3286,20 @@ var Identity = class {
3048
3286
  getIdentityCredentialSigner() {
3049
3287
  (0, import_invariant6.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
3050
3288
  F: __dxlog_file11,
3051
- L: 185,
3289
+ L: 189,
3052
3290
  S: this,
3053
3291
  A: [
3054
3292
  "this._deviceStateMachine.deviceCredentialChain",
3055
3293
  "'Device credential chain is not ready.'"
3056
3294
  ]
3057
3295
  });
3058
- return (0, import_credentials5.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
3296
+ return (0, import_credentials6.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
3059
3297
  }
3060
3298
  /**
3061
3299
  * Issues credentials as device.
3062
3300
  */
3063
3301
  getDeviceCredentialSigner() {
3064
- return (0, import_credentials5.createCredentialSignerWithKey)(this._signer, this.deviceKey);
3302
+ return (0, import_credentials6.createCredentialSignerWithKey)(this._signer, this.deviceKey);
3065
3303
  }
3066
3304
  async updateDefaultSpace(spaceId) {
3067
3305
  const credential = await this.getDeviceCredentialSigner().createCredential({
@@ -3092,7 +3330,7 @@ var Identity = class {
3092
3330
  dataFeedKey
3093
3331
  }, {
3094
3332
  F: __dxlog_file11,
3095
- L: 210,
3333
+ L: 214,
3096
3334
  S: this,
3097
3335
  C: (f, a) => f(...a)
3098
3336
  });
@@ -3113,7 +3351,7 @@ var Identity = class {
3113
3351
  spaceKey: this.haloSpaceKey,
3114
3352
  deviceKey,
3115
3353
  identityKey: this.identityKey,
3116
- designation: import_credentials6.AdmittedFeed.Designation.CONTROL
3354
+ designation: import_credentials7.AdmittedFeed.Designation.CONTROL
3117
3355
  }
3118
3356
  }),
3119
3357
  await signer.createCredential({
@@ -3123,7 +3361,7 @@ var Identity = class {
3123
3361
  spaceKey: this.haloSpaceKey,
3124
3362
  deviceKey,
3125
3363
  identityKey: this.identityKey,
3126
- designation: import_credentials6.AdmittedFeed.Designation.DATA
3364
+ designation: import_credentials7.AdmittedFeed.Designation.DATA
3127
3365
  }
3128
3366
  })
3129
3367
  ].map((credential) => ({
@@ -3133,16 +3371,16 @@ var Identity = class {
3133
3371
  })));
3134
3372
  }
3135
3373
  };
3136
- _ts_decorate2([
3374
+ _ts_decorate4([
3137
3375
  import_tracing4.trace.span()
3138
3376
  ], Identity.prototype, "open", null);
3139
- _ts_decorate2([
3377
+ _ts_decorate4([
3140
3378
  import_tracing4.trace.span()
3141
3379
  ], Identity.prototype, "close", null);
3142
- Identity = _ts_decorate2([
3380
+ Identity = _ts_decorate4([
3143
3381
  import_tracing4.trace.resource()
3144
3382
  ], Identity);
3145
- function _ts_decorate3(decorators, target, key, desc) {
3383
+ function _ts_decorate5(decorators, target, key, desc) {
3146
3384
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3147
3385
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3148
3386
  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 +3408,7 @@ var IdentityManager = class {
3170
3408
  }
3171
3409
  async open(ctx) {
3172
3410
  const traceId = import_keys9.PublicKey.random().toHex();
3173
- import_log11.log.trace("dxos.halo.identity-manager.open", import_protocols6.trace.begin({
3411
+ import_log11.log.trace("dxos.halo.identity-manager.open", import_protocols7.trace.begin({
3174
3412
  id: traceId
3175
3413
  }), {
3176
3414
  F: __dxlog_file12,
@@ -3202,7 +3440,7 @@ var IdentityManager = class {
3202
3440
  });
3203
3441
  this.stateUpdate.emit();
3204
3442
  }
3205
- import_log11.log.trace("dxos.halo.identity-manager.open", import_protocols6.trace.end({
3443
+ import_log11.log.trace("dxos.halo.identity-manager.open", import_protocols7.trace.end({
3206
3444
  id: traceId
3207
3445
  }), {
3208
3446
  F: __dxlog_file12,
@@ -3250,7 +3488,7 @@ var IdentityManager = class {
3250
3488
  L: 161
3251
3489
  }));
3252
3490
  {
3253
- const generator = new import_credentials13.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
3491
+ const generator = new import_credentials14.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
3254
3492
  (0, import_invariant9.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
3255
3493
  F: __dxlog_file12,
3256
3494
  L: 165,
@@ -3273,7 +3511,7 @@ var IdentityManager = class {
3273
3511
  // Space genesis.
3274
3512
  ...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
3275
3513
  // Feed admission.
3276
- await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials14.AdmittedFeed.Designation.DATA)
3514
+ await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials15.AdmittedFeed.Designation.DATA)
3277
3515
  ];
3278
3516
  if (displayName) {
3279
3517
  credentials.push(await generator.createProfileCredential({
@@ -3322,14 +3560,14 @@ var IdentityManager = class {
3322
3560
  createDefaultDeviceProfile() {
3323
3561
  let type;
3324
3562
  if ((0, import_util8.isNode)()) {
3325
- type = import_credentials14.DeviceType.AGENT;
3563
+ type = import_credentials15.DeviceType.AGENT;
3326
3564
  } else {
3327
3565
  if (import_platform.default.name?.startsWith("iOS") || import_platform.default.name?.startsWith("Android")) {
3328
- type = import_credentials14.DeviceType.MOBILE;
3566
+ type = import_credentials15.DeviceType.MOBILE;
3329
3567
  } else if (globalThis.__args) {
3330
- type = import_credentials14.DeviceType.NATIVE;
3568
+ type = import_credentials15.DeviceType.NATIVE;
3331
3569
  } else {
3332
- type = import_credentials14.DeviceType.BROWSER;
3570
+ type = import_credentials15.DeviceType.BROWSER;
3333
3571
  }
3334
3572
  }
3335
3573
  return {
@@ -3533,7 +3771,7 @@ var IdentityManager = class {
3533
3771
  swarmIdentity: {
3534
3772
  identityKey: identityRecord.identityKey,
3535
3773
  peerKey: identityRecord.deviceKey,
3536
- credentialProvider: createAuthProvider((0, import_credentials13.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
3774
+ credentialProvider: createAuthProvider((0, import_credentials14.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
3537
3775
  credentialAuthenticator: (0, import_util8.deferFunction)(() => identity.authVerifier.verifier)
3538
3776
  },
3539
3777
  gossip,
@@ -3593,12 +3831,12 @@ var IdentityManager = class {
3593
3831
  });
3594
3832
  }
3595
3833
  };
3596
- _ts_decorate3([
3834
+ _ts_decorate5([
3597
3835
  import_tracing7.trace.span({
3598
3836
  showInBrowserTimeline: true
3599
3837
  })
3600
3838
  ], IdentityManager.prototype, "open", null);
3601
- IdentityManager = _ts_decorate3([
3839
+ IdentityManager = _ts_decorate5([
3602
3840
  import_tracing7.trace.resource()
3603
3841
  ], IdentityManager);
3604
3842
  var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
@@ -3688,7 +3926,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3688
3926
  "'Identity not initialized.'"
3689
3927
  ]
3690
3928
  });
3691
- return await (0, import_credentials15.signPresentation)({
3929
+ return await (0, import_credentials16.signPresentation)({
3692
3930
  presentation,
3693
3931
  signer: this._keyring,
3694
3932
  signerKey: this._identityManager.identity.deviceKey,
@@ -3745,7 +3983,7 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3745
3983
  }
3746
3984
  }
3747
3985
  };
3748
- function _ts_decorate4(decorators, target, key, desc) {
3986
+ function _ts_decorate6(decorators, target, key, desc) {
3749
3987
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3750
3988
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3751
3989
  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 +4056,8 @@ var DataSpace = class {
3818
4056
  constructor(params) {
3819
4057
  this._ctx = new import_context4.Context(void 0, {
3820
4058
  F: __dxlog_file14,
3821
- L: 94
4059
+ L: 95
3822
4060
  });
3823
- this._notarizationPlugin = new NotarizationPlugin();
3824
4061
  this._cache = void 0;
3825
4062
  this._edgeFeedReplicator = void 0;
3826
4063
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
@@ -3845,6 +4082,11 @@ var DataSpace = class {
3845
4082
  this._signingContext = params.signingContext;
3846
4083
  this._callbacks = params.callbacks ?? {};
3847
4084
  this._echoHost = params.echoHost;
4085
+ this._notarizationPlugin = new NotarizationPlugin({
4086
+ spaceId: this._inner.id,
4087
+ edgeClient: params.edgeHttpClient,
4088
+ edgeFeatures: params.edgeFeatures
4089
+ });
3848
4090
  this.authVerifier = new TrustedKeySetAuthVerifier({
3849
4091
  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
4092
  update: this._inner.stateUpdate,
@@ -3862,7 +4104,7 @@ var DataSpace = class {
3862
4104
  state: import_services4.SpaceState[this._state]
3863
4105
  }, {
3864
4106
  F: __dxlog_file14,
3865
- L: 164,
4107
+ L: 170,
3866
4108
  S: this,
3867
4109
  C: (f, a) => f(...a)
3868
4110
  });
@@ -3921,7 +4163,7 @@ var DataSpace = class {
3921
4163
  }
3922
4164
  await this._inner.open(new import_context4.Context(void 0, {
3923
4165
  F: __dxlog_file14,
3924
- L: 238
4166
+ L: 244
3925
4167
  }));
3926
4168
  await this._edgeFeedReplicator?.open();
3927
4169
  this._state = import_services4.SpaceState.SPACE_CONTROL_ONLY;
@@ -3929,7 +4171,7 @@ var DataSpace = class {
3929
4171
  state: import_services4.SpaceState[this._state]
3930
4172
  }, {
3931
4173
  F: __dxlog_file14,
3932
- L: 243,
4174
+ L: 249,
3933
4175
  S: this,
3934
4176
  C: (f, a) => f(...a)
3935
4177
  });
@@ -3949,14 +4191,14 @@ var DataSpace = class {
3949
4191
  state: import_services4.SpaceState[this._state]
3950
4192
  }, {
3951
4193
  F: __dxlog_file14,
3952
- L: 262,
4194
+ L: 268,
3953
4195
  S: this,
3954
4196
  C: (f, a) => f(...a)
3955
4197
  });
3956
4198
  await this._ctx.dispose();
3957
4199
  this._ctx = new import_context4.Context(void 0, {
3958
4200
  F: __dxlog_file14,
3959
- L: 264
4201
+ L: 270
3960
4202
  });
3961
4203
  if (this._edgeFeedReplicator) {
3962
4204
  this.inner.protocol.feedAdded.remove(this._onFeedAdded);
@@ -3989,7 +4231,7 @@ var DataSpace = class {
3989
4231
  if (err instanceof import_protocols3.CancelledError || err instanceof import_context4.ContextDisposedError) {
3990
4232
  (0, import_log4.log)("data pipeline initialization cancelled", err, {
3991
4233
  F: __dxlog_file14,
3992
- L: 302,
4234
+ L: 308,
3993
4235
  S: this,
3994
4236
  C: (f, a) => f(...a)
3995
4237
  });
@@ -3997,7 +4239,7 @@ var DataSpace = class {
3997
4239
  }
3998
4240
  import_log4.log.error("Error initializing data pipeline", err, {
3999
4241
  F: __dxlog_file14,
4000
- L: 306,
4242
+ L: 312,
4001
4243
  S: this,
4002
4244
  C: (f, a) => f(...a)
4003
4245
  });
@@ -4006,7 +4248,7 @@ var DataSpace = class {
4006
4248
  state: import_services4.SpaceState[this._state]
4007
4249
  }, {
4008
4250
  F: __dxlog_file14,
4009
- L: 308,
4251
+ L: 314,
4010
4252
  S: this,
4011
4253
  C: (f, a) => f(...a)
4012
4254
  });
@@ -4026,15 +4268,39 @@ var DataSpace = class {
4026
4268
  state: import_services4.SpaceState[this._state]
4027
4269
  }, {
4028
4270
  F: __dxlog_file14,
4029
- L: 324,
4271
+ L: 330,
4272
+ S: this,
4273
+ C: (f, a) => f(...a)
4274
+ });
4275
+ (0, import_log4.log)("initializing control pipeline", void 0, {
4276
+ F: __dxlog_file14,
4277
+ L: 332,
4030
4278
  S: this,
4031
4279
  C: (f, a) => f(...a)
4032
4280
  });
4033
4281
  await this._initializeAndReadControlPipeline();
4034
4282
  await (0, import_async7.sleep)(1);
4035
4283
  const ready = this.stateUpdate.waitForCondition(() => this._state === import_services4.SpaceState.SPACE_READY);
4284
+ (0, import_log4.log)("initializing automerge root", void 0, {
4285
+ F: __dxlog_file14,
4286
+ L: 340,
4287
+ S: this,
4288
+ C: (f, a) => f(...a)
4289
+ });
4036
4290
  this._automergeSpaceState.startProcessingRootDocs();
4291
+ (0, import_log4.log)("waiting for space to be ready", void 0, {
4292
+ F: __dxlog_file14,
4293
+ L: 344,
4294
+ S: this,
4295
+ C: (f, a) => f(...a)
4296
+ });
4037
4297
  await ready;
4298
+ (0, import_log4.log)("space is ready", void 0, {
4299
+ F: __dxlog_file14,
4300
+ L: 346,
4301
+ S: this,
4302
+ C: (f, a) => f(...a)
4303
+ });
4038
4304
  }
4039
4305
  async _enterReadyState() {
4040
4306
  await this._callbacks.beforeReady?.();
@@ -4043,7 +4309,7 @@ var DataSpace = class {
4043
4309
  state: import_services4.SpaceState[this._state]
4044
4310
  }, {
4045
4311
  F: __dxlog_file14,
4046
- L: 343,
4312
+ L: 353,
4047
4313
  S: this,
4048
4314
  C: (f, a) => f(...a)
4049
4315
  });
@@ -4053,13 +4319,14 @@ var DataSpace = class {
4053
4319
  async _initializeAndReadControlPipeline() {
4054
4320
  await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
4055
4321
  ctx: this._ctx,
4322
+ timeout: 1e4,
4056
4323
  breakOnStall: false
4057
4324
  });
4058
4325
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
4059
4326
  await this._createWritableFeeds();
4060
4327
  (0, import_log4.log)("writable feeds created", void 0, {
4061
4328
  F: __dxlog_file14,
4062
- L: 359,
4329
+ L: 370,
4063
4330
  S: this,
4064
4331
  C: (f, a) => f(...a)
4065
4332
  });
@@ -4108,11 +4375,35 @@ var DataSpace = class {
4108
4375
  }));
4109
4376
  }
4110
4377
  if (credentials.length > 0) {
4111
- await this.notarizationPlugin.notarize({
4112
- ctx: this._ctx,
4113
- credentials,
4114
- timeout: 0
4115
- });
4378
+ try {
4379
+ (0, import_log4.log)("will notarize credentials for feed admission", {
4380
+ count: credentials.length
4381
+ }, {
4382
+ F: __dxlog_file14,
4383
+ L: 428,
4384
+ S: this,
4385
+ C: (f, a) => f(...a)
4386
+ });
4387
+ await this.notarizationPlugin.notarize({
4388
+ ctx: this._ctx,
4389
+ credentials,
4390
+ timeout: 0
4391
+ });
4392
+ (0, import_log4.log)("credentials notarized", void 0, {
4393
+ F: __dxlog_file14,
4394
+ L: 432,
4395
+ S: this,
4396
+ C: (f, a) => f(...a)
4397
+ });
4398
+ } catch (err) {
4399
+ import_log4.log.error("error notarizing credentials for feed admission", err, {
4400
+ F: __dxlog_file14,
4401
+ L: 434,
4402
+ S: this,
4403
+ C: (f, a) => f(...a)
4404
+ });
4405
+ throw err;
4406
+ }
4116
4407
  await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
4117
4408
  }
4118
4409
  }
@@ -4122,7 +4413,7 @@ var DataSpace = class {
4122
4413
  rootUrl
4123
4414
  }, {
4124
4415
  F: __dxlog_file14,
4125
- L: 425,
4416
+ L: 444,
4126
4417
  S: this,
4127
4418
  C: (f, a) => f(...a)
4128
4419
  });
@@ -4174,7 +4465,7 @@ var DataSpace = class {
4174
4465
  err
4175
4466
  }, {
4176
4467
  F: __dxlog_file14,
4177
- L: 468,
4468
+ L: 487,
4178
4469
  S: this,
4179
4470
  C: (f, a) => f(...a)
4180
4471
  });
@@ -4264,58 +4555,61 @@ var DataSpace = class {
4264
4555
  state: import_services4.SpaceState[this._state]
4265
4556
  }, {
4266
4557
  F: __dxlog_file14,
4267
- L: 550,
4558
+ L: 569,
4268
4559
  S: this,
4269
4560
  C: (f, a) => f(...a)
4270
4561
  });
4271
4562
  this.stateUpdate.emit();
4272
4563
  }
4564
+ getEdgeReplicationSetting() {
4565
+ return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
4566
+ }
4273
4567
  };
4274
- _ts_decorate4([
4568
+ _ts_decorate6([
4275
4569
  import_tracing3.trace.info()
4276
4570
  ], DataSpace.prototype, "_inner", void 0);
4277
- _ts_decorate4([
4571
+ _ts_decorate6([
4278
4572
  import_tracing3.trace.info()
4279
4573
  ], DataSpace.prototype, "id", null);
4280
- _ts_decorate4([
4574
+ _ts_decorate6([
4281
4575
  import_tracing3.trace.info()
4282
4576
  ], DataSpace.prototype, "key", null);
4283
- _ts_decorate4([
4577
+ _ts_decorate6([
4284
4578
  import_tracing3.trace.info({
4285
4579
  enum: import_services4.SpaceState
4286
4580
  })
4287
4581
  ], DataSpace.prototype, "state", null);
4288
- _ts_decorate4([
4582
+ _ts_decorate6([
4289
4583
  import_tracing3.trace.info({
4290
4584
  depth: null
4291
4585
  })
4292
4586
  ], DataSpace.prototype, "_automergeInfo", null);
4293
- _ts_decorate4([
4587
+ _ts_decorate6([
4294
4588
  import_async7.synchronized
4295
4589
  ], DataSpace.prototype, "open", null);
4296
- _ts_decorate4([
4590
+ _ts_decorate6([
4297
4591
  import_async7.synchronized
4298
4592
  ], DataSpace.prototype, "close", null);
4299
- _ts_decorate4([
4593
+ _ts_decorate6([
4300
4594
  import_tracing3.trace.span({
4301
4595
  showInBrowserTimeline: true
4302
4596
  })
4303
4597
  ], DataSpace.prototype, "initializeDataPipeline", null);
4304
- _ts_decorate4([
4598
+ _ts_decorate6([
4305
4599
  import_tracing3.trace.span({
4306
4600
  showInBrowserTimeline: true
4307
4601
  })
4308
4602
  ], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
4309
- _ts_decorate4([
4603
+ _ts_decorate6([
4310
4604
  (0, import_debug.timed)(1e4)
4311
4605
  ], DataSpace.prototype, "_createWritableFeeds", null);
4312
- _ts_decorate4([
4606
+ _ts_decorate6([
4313
4607
  import_async7.synchronized
4314
4608
  ], DataSpace.prototype, "activate", null);
4315
- _ts_decorate4([
4609
+ _ts_decorate6([
4316
4610
  import_async7.synchronized
4317
4611
  ], DataSpace.prototype, "deactivate", null);
4318
- DataSpace = _ts_decorate4([
4612
+ DataSpace = _ts_decorate6([
4319
4613
  (0, import_async7.trackLeaks)("open", "close"),
4320
4614
  import_tracing3.trace.resource()
4321
4615
  ], DataSpace);
@@ -4368,7 +4662,7 @@ var DeviceInvitationProtocol = class {
4368
4662
  try {
4369
4663
  const identity = this._getIdentity();
4370
4664
  if (identity) {
4371
- return new import_protocols7.AlreadyJoinedError("Currently only one identity per client is supported.");
4665
+ return new import_protocols8.AlreadyJoinedError("Currently only one identity per client is supported.");
4372
4666
  }
4373
4667
  } catch {
4374
4668
  }
@@ -4527,7 +4821,7 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
4527
4821
  C: (f, a) => f(...a)
4528
4822
  });
4529
4823
  if (this._remoteOptions?.role !== import_invitations3.InvitationOptions.Role.HOST) {
4530
- throw new import_protocols9.InvalidInvitationExtensionRoleError(void 0, {
4824
+ throw new import_protocols10.InvalidInvitationExtensionRoleError(void 0, {
4531
4825
  expected: import_invitations3.InvitationOptions.Role.HOST,
4532
4826
  remoteOptions: this._remoteOptions,
4533
4827
  remotePeerId: context.remotePeerId
@@ -4614,7 +4908,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4614
4908
  introduce: async (request) => {
4615
4909
  const { profile, invitationId } = request;
4616
4910
  const traceId = import_keys11.PublicKey.random().toHex();
4617
- import_log15.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols10.trace.begin({
4911
+ import_log15.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols11.trace.begin({
4618
4912
  id: traceId
4619
4913
  }), {
4620
4914
  F: __dxlog_file17,
@@ -4651,7 +4945,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4651
4945
  this.guestProfile = profile;
4652
4946
  this._callbacks.onStateUpdate(import_services13.Invitation.State.READY_FOR_AUTHENTICATION);
4653
4947
  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({
4948
+ import_log15.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols11.trace.end({
4655
4949
  id: traceId
4656
4950
  }), {
4657
4951
  F: __dxlog_file17,
@@ -4666,7 +4960,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4666
4960
  },
4667
4961
  authenticate: async ({ authCode: code, signedChallenge }) => {
4668
4962
  const traceId = import_keys11.PublicKey.random().toHex();
4669
- import_log15.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols10.trace.begin({
4963
+ import_log15.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols11.trace.begin({
4670
4964
  id: traceId
4671
4965
  }), {
4672
4966
  F: __dxlog_file17,
@@ -4749,7 +5043,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4749
5043
  status
4750
5044
  };
4751
5045
  }
4752
- import_log15.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols10.trace.end({
5046
+ import_log15.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols11.trace.end({
4753
5047
  id: traceId,
4754
5048
  data: {
4755
5049
  status
@@ -4766,7 +5060,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4766
5060
  },
4767
5061
  admit: async (request) => {
4768
5062
  const traceId = import_keys11.PublicKey.random().toHex();
4769
- import_log15.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols10.trace.begin({
5063
+ import_log15.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols11.trace.begin({
4770
5064
  id: traceId
4771
5065
  }), {
4772
5066
  F: __dxlog_file17,
@@ -4783,7 +5077,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4783
5077
  }
4784
5078
  }
4785
5079
  const response = await this._callbacks.admit(request);
4786
- import_log15.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols10.trace.end({
5080
+ import_log15.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols11.trace.end({
4787
5081
  id: traceId
4788
5082
  }), {
4789
5083
  F: __dxlog_file17,
@@ -4838,7 +5132,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
4838
5132
  });
4839
5133
  if (this._remoteOptions?.role !== import_invitations4.InvitationOptions.Role.GUEST) {
4840
5134
  this._callbacks.onStateUpdate(lastState);
4841
- throw new import_protocols10.InvalidInvitationExtensionRoleError(void 0, {
5135
+ throw new import_protocols11.InvalidInvitationExtensionRoleError(void 0, {
4842
5136
  expected: import_invitations4.InvitationOptions.Role.GUEST,
4843
5137
  remoteOptions: this._remoteOptions,
4844
5138
  remotePeerId: context.remotePeerId
@@ -5018,7 +5312,7 @@ var InvitationsHandler = class {
5018
5312
  (0, import_async15.scheduleTask)(connectionCtx, async () => {
5019
5313
  const traceId = import_keys10.PublicKey.random().toHex();
5020
5314
  try {
5021
- import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols8.trace.begin({
5315
+ import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.begin({
5022
5316
  id: traceId
5023
5317
  }), {
5024
5318
  F: __dxlog_file19,
@@ -5048,7 +5342,7 @@ var InvitationsHandler = class {
5048
5342
  });
5049
5343
  guardedState.set(extension, import_services11.Invitation.State.SUCCESS);
5050
5344
  metrics.increment("dxos.invitation.success");
5051
- import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols8.trace.end({
5345
+ import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.end({
5052
5346
  id: traceId
5053
5347
  }), {
5054
5348
  F: __dxlog_file19,
@@ -5084,7 +5378,7 @@ var InvitationsHandler = class {
5084
5378
  });
5085
5379
  }
5086
5380
  }
5087
- import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols8.trace.error({
5381
+ import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.error({
5088
5382
  id: traceId,
5089
5383
  error: err
5090
5384
  }), {
@@ -5098,7 +5392,7 @@ var InvitationsHandler = class {
5098
5392
  });
5099
5393
  },
5100
5394
  onError: (err) => {
5101
- if (err instanceof import_protocols8.InvalidInvitationExtensionRoleError) {
5395
+ if (err instanceof import_protocols9.InvalidInvitationExtensionRoleError) {
5102
5396
  (0, import_log13.log)("invalid role", {
5103
5397
  ...err.context
5104
5398
  }, {
@@ -5223,7 +5517,7 @@ var InvitationsHandler = class {
5223
5517
  (0, import_async15.scheduleTask)(connectionCtx, async () => {
5224
5518
  const traceId = import_keys10.PublicKey.random().toHex();
5225
5519
  try {
5226
- import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols8.trace.begin({
5520
+ import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.begin({
5227
5521
  id: traceId
5228
5522
  }), {
5229
5523
  F: __dxlog_file19,
@@ -5303,7 +5597,7 @@ var InvitationsHandler = class {
5303
5597
  ...result,
5304
5598
  state: import_services11.Invitation.State.SUCCESS
5305
5599
  });
5306
- import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols8.trace.end({
5600
+ import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.end({
5307
5601
  id: traceId
5308
5602
  }), {
5309
5603
  F: __dxlog_file19,
@@ -5332,7 +5626,7 @@ var InvitationsHandler = class {
5332
5626
  guardedState.error(extension, err);
5333
5627
  }
5334
5628
  extensionCtx.close(err);
5335
- import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols8.trace.error({
5629
+ import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.error({
5336
5630
  id: traceId,
5337
5631
  error: err
5338
5632
  }), {
@@ -5345,7 +5639,7 @@ var InvitationsHandler = class {
5345
5639
  });
5346
5640
  },
5347
5641
  onError: (err) => {
5348
- if (err instanceof import_protocols8.InvalidInvitationExtensionRoleError) {
5642
+ if (err instanceof import_protocols9.InvalidInvitationExtensionRoleError) {
5349
5643
  return;
5350
5644
  }
5351
5645
  if (err instanceof import_async15.TimeoutError) {
@@ -5691,14 +5985,14 @@ var SpaceInvitationProtocol = class {
5691
5985
  }
5692
5986
  checkCanInviteNewMembers() {
5693
5987
  if (this._spaceKey == null) {
5694
- return new import_protocols11.InvalidInvitationError("No spaceKey was provided for a space invitation.");
5988
+ return new import_protocols12.InvalidInvitationError("No spaceKey was provided for a space invitation.");
5695
5989
  }
5696
5990
  const space = this._spaceManager.spaces.get(this._spaceKey);
5697
5991
  if (space == null) {
5698
- return new import_protocols11.SpaceNotFoundError(this._spaceKey);
5992
+ return new import_protocols12.SpaceNotFoundError(this._spaceKey);
5699
5993
  }
5700
5994
  if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
5701
- return new import_protocols11.AuthorizationError("No member management permission.");
5995
+ return new import_protocols12.AuthorizationError("No member management permission.");
5702
5996
  }
5703
5997
  return void 0;
5704
5998
  }
@@ -5730,7 +6024,7 @@ var SpaceInvitationProtocol = class {
5730
6024
  const spaceMemberCredential = await this._spaceManager.admitMember({
5731
6025
  spaceKey: this._spaceKey,
5732
6026
  identityKey: request.space.identityKey,
5733
- role: invitation.role ?? import_credentials17.SpaceMember.Role.ADMIN,
6027
+ role: invitation.role ?? import_credentials18.SpaceMember.Role.ADMIN,
5734
6028
  profile: guestProfile,
5735
6029
  delegationCredentialId: invitation.delegationCredentialId
5736
6030
  });
@@ -5782,11 +6076,11 @@ var SpaceInvitationProtocol = class {
5782
6076
  S: this,
5783
6077
  C: (f, a) => f(...a)
5784
6078
  });
5785
- const credential = await (0, import_credentials16.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
6079
+ const credential = await (0, import_credentials17.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
5786
6080
  invitationId: invitation.invitationId,
5787
6081
  authMethod: invitation.authMethod,
5788
6082
  swarmKey: invitation.swarmKey,
5789
- role: invitation.role ?? import_credentials17.SpaceMember.Role.ADMIN,
6083
+ role: invitation.role ?? import_credentials18.SpaceMember.Role.ADMIN,
5790
6084
  expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
5791
6085
  multiUse: invitation.multiUse ?? false,
5792
6086
  guestKey: invitation.authMethod === import_services15.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
@@ -5843,7 +6137,7 @@ var SpaceInvitationProtocol = class {
5843
6137
  S: this,
5844
6138
  C: (f, a) => f(...a)
5845
6139
  });
5846
- const credential = await (0, import_credentials16.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
6140
+ const credential = await (0, import_credentials17.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
5847
6141
  (0, import_invariant16.invariant)(credential.credential, void 0, {
5848
6142
  F: __dxlog_file20,
5849
6143
  L: 140,
@@ -5859,10 +6153,10 @@ var SpaceInvitationProtocol = class {
5859
6153
  }
5860
6154
  checkInvitation(invitation) {
5861
6155
  if (invitation.spaceKey == null) {
5862
- return new import_protocols11.InvalidInvitationError("No spaceKey was provided for a space invitation.");
6156
+ return new import_protocols12.InvalidInvitationError("No spaceKey was provided for a space invitation.");
5863
6157
  }
5864
6158
  if (this._spaceManager.spaces.has(invitation.spaceKey)) {
5865
- return new import_protocols11.AlreadyJoinedError("Already joined space.");
6159
+ return new import_protocols12.AlreadyJoinedError("Already joined space.");
5866
6160
  }
5867
6161
  }
5868
6162
  createIntroduction() {
@@ -5893,7 +6187,7 @@ var SpaceInvitationProtocol = class {
5893
6187
  ]
5894
6188
  });
5895
6189
  const { credential, controlTimeframe, dataTimeframe } = response.space;
5896
- const assertion = (0, import_credentials16.getCredentialAssertion)(credential);
6190
+ const assertion = (0, import_credentials17.getCredentialAssertion)(credential);
5897
6191
  (0, import_invariant16.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
5898
6192
  F: __dxlog_file20,
5899
6193
  L: 178,
@@ -5913,7 +6207,7 @@ var SpaceInvitationProtocol = class {
5913
6207
  ]
5914
6208
  });
5915
6209
  if (this._spaceManager.spaces.has(assertion.spaceKey)) {
5916
- throw new import_protocols11.AlreadyJoinedError("Already joined space.");
6210
+ throw new import_protocols12.AlreadyJoinedError("Already joined space.");
5917
6211
  }
5918
6212
  await this._spaceManager.acceptSpace({
5919
6213
  spaceKey: assertion.spaceKey,
@@ -6129,8 +6423,8 @@ var InvitationsManager = class {
6129
6423
  }
6130
6424
  }
6131
6425
  _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);
6426
+ 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 ?? {};
6427
+ const authCode = options?.authCode ?? (authMethod === import_services16.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials19.generatePasscode)(import_client_protocol6.AUTHENTICATION_CODE_LENGTH) : void 0);
6134
6428
  return {
6135
6429
  invitationId,
6136
6430
  type,
@@ -6286,7 +6580,7 @@ var InvitationsManager = class {
6286
6580
  }, callback);
6287
6581
  }
6288
6582
  };
6289
- function _ts_decorate5(decorators, target, key, desc) {
6583
+ function _ts_decorate7(decorators, target, key, desc) {
6290
6584
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6291
6585
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6292
6586
  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 +6626,11 @@ var Lock = class {
6332
6626
  await import_lock_file.LockFile.release(this._fileHandle);
6333
6627
  }
6334
6628
  };
6335
- _ts_decorate5([
6629
+ _ts_decorate7([
6336
6630
  import_log19.logInfo
6337
6631
  ], Lock.prototype, "lockKey", null);
6338
6632
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
6339
- function _ts_decorate6(decorators, target, key, desc) {
6633
+ function _ts_decorate8(decorators, target, key, desc) {
6340
6634
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6341
6635
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6342
6636
  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 +6692,96 @@ var ClientRpcServer = class {
6398
6692
  return this._handlerCache.get(serviceName);
6399
6693
  }
6400
6694
  };
6401
- _ts_decorate6([
6695
+ _ts_decorate8([
6402
6696
  import_tracing9.trace.metricsCounter()
6403
6697
  ], ClientRpcServer.prototype, "_callMetrics", void 0);
6404
- _ts_decorate6([
6698
+ _ts_decorate8([
6405
6699
  import_tracing9.trace.info()
6406
6700
  ], ClientRpcServer.prototype, "_services", null);
6407
- ClientRpcServer = _ts_decorate6([
6701
+ ClientRpcServer = _ts_decorate8([
6408
6702
  import_tracing9.trace.resource()
6409
6703
  ], ClientRpcServer);
6410
- function _ts_decorate7(decorators, target, key, desc) {
6704
+ function _ts_decorate9(decorators, target, key, desc) {
6411
6705
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6412
6706
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6413
6707
  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
6708
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6415
6709
  }
6710
+ function _using_ctx3() {
6711
+ var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
6712
+ var err = new Error();
6713
+ err.name = "SuppressedError";
6714
+ err.suppressed = suppressed;
6715
+ err.error = error;
6716
+ return err;
6717
+ }, empty = {}, stack = [];
6718
+ function using(isAwait, value) {
6719
+ if (value != null) {
6720
+ if (Object(value) !== value) {
6721
+ throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
6722
+ }
6723
+ if (isAwait) {
6724
+ var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
6725
+ }
6726
+ if (dispose == null) {
6727
+ dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
6728
+ }
6729
+ if (typeof dispose !== "function") {
6730
+ throw new TypeError(`Property [Symbol.dispose] is not a function.`);
6731
+ }
6732
+ stack.push({
6733
+ v: value,
6734
+ d: dispose,
6735
+ a: isAwait
6736
+ });
6737
+ } else if (isAwait) {
6738
+ stack.push({
6739
+ d: value,
6740
+ a: isAwait
6741
+ });
6742
+ }
6743
+ return value;
6744
+ }
6745
+ return {
6746
+ e: empty,
6747
+ u: using.bind(null, false),
6748
+ a: using.bind(null, true),
6749
+ d: function() {
6750
+ var error = this.e;
6751
+ function next() {
6752
+ while (resource = stack.pop()) {
6753
+ try {
6754
+ var resource, disposalResult = resource.d && resource.d.call(resource.v);
6755
+ if (resource.a) {
6756
+ return Promise.resolve(disposalResult).then(next, err);
6757
+ }
6758
+ } catch (e) {
6759
+ return err(e);
6760
+ }
6761
+ }
6762
+ if (error !== empty) throw error;
6763
+ }
6764
+ function err(e) {
6765
+ error = error !== empty ? new _disposeSuppressedError(error, e) : e;
6766
+ return next();
6767
+ }
6768
+ return next();
6769
+ }
6770
+ };
6771
+ }
6416
6772
  var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
6417
6773
  var ServiceContext = class extends import_context15.Resource {
6418
- constructor(storage, level, networkManager, signalManager, _edgeConnection, _runtimeParams, _edgeFeatures) {
6774
+ constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
6419
6775
  super();
6420
6776
  this.storage = storage;
6421
6777
  this.level = level;
6422
6778
  this.networkManager = networkManager;
6423
6779
  this.signalManager = signalManager;
6424
6780
  this._edgeConnection = _edgeConnection;
6781
+ this._edgeHttpClient = _edgeHttpClient;
6425
6782
  this._runtimeParams = _runtimeParams;
6426
6783
  this._edgeFeatures = _edgeFeatures;
6784
+ this._edgeIdentityUpdateMutex = new import_async19.Mutex();
6427
6785
  this.initialized = new import_async19.Trigger();
6428
6786
  this._meshReplicator = void 0;
6429
6787
  this._echoEdgeReplicator = void 0;
@@ -6461,23 +6819,42 @@ var ServiceContext = class extends import_context15.Resource {
6461
6819
  callbacks: {
6462
6820
  onIdentityConstruction: (identity) => {
6463
6821
  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()
6822
+ (0, import_async19.scheduleMicroTask)(this._ctx, async () => {
6823
+ try {
6824
+ var _usingCtx = _using_ctx3();
6825
+ const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
6826
+ import_log20.log.info("Setting identity on edge connection", {
6827
+ identity: identity.identityKey.toHex(),
6828
+ oldIdentity: this._edgeConnection.identityKey,
6829
+ swarms: this.networkManager.topics
6830
+ }, {
6831
+ F: __dxlog_file23,
6832
+ L: 147,
6833
+ S: this,
6834
+ C: (f, a) => f(...a)
6835
+ });
6836
+ await (0, import_debug6.warnAfterTimeout)(1e4, "Waiting for identity to be ready for edge connection", async () => {
6837
+ await identity.ready();
6838
+ });
6839
+ (0, import_invariant19.invariant)(identity.deviceCredentialChain, void 0, {
6840
+ F: __dxlog_file23,
6841
+ L: 157,
6842
+ S: this,
6843
+ A: [
6844
+ "identity.deviceCredentialChain",
6845
+ ""
6846
+ ]
6847
+ });
6848
+ this._edgeConnection.setIdentity(await (0, import_edge_client2.createChainEdgeIdentity)(identity.signer, identity.identityKey, identity.deviceKey, identity.deviceCredentialChain, []));
6849
+ this.networkManager.setPeerInfo({
6850
+ identityKey: identity.identityKey.toHex(),
6851
+ peerKey: identity.deviceKey.toHex()
6852
+ });
6853
+ } catch (_) {
6854
+ _usingCtx.e = _;
6855
+ } finally {
6856
+ _usingCtx.d();
6857
+ }
6481
6858
  });
6482
6859
  }
6483
6860
  }
@@ -6503,19 +6880,22 @@ var ServiceContext = class extends import_context15.Resource {
6503
6880
  await this._checkStorageVersion();
6504
6881
  (0, import_log20.log)("opening...", void 0, {
6505
6882
  F: __dxlog_file23,
6506
- L: 198,
6883
+ L: 217,
6507
6884
  S: this,
6508
6885
  C: (f, a) => f(...a)
6509
6886
  });
6510
- import_log20.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.begin({
6887
+ import_log20.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
6511
6888
  id: this._instanceId
6512
6889
  }), {
6513
6890
  F: __dxlog_file23,
6514
- L: 199,
6891
+ L: 218,
6515
6892
  S: this,
6516
6893
  C: (f, a) => f(...a)
6517
6894
  });
6518
- await this._edgeConnection?.open();
6895
+ if (this._edgeConnection) {
6896
+ this._edgeConnection.setIdentity(await (0, import_edge_client2.createEphemeralEdgeIdentity)());
6897
+ await this._edgeConnection.open();
6898
+ }
6519
6899
  await this.signalManager.open();
6520
6900
  await this.networkManager.open();
6521
6901
  await this.echoHost.open(ctx);
@@ -6536,21 +6916,21 @@ var ServiceContext = class extends import_context15.Resource {
6536
6916
  count: loadedInvitations.invitations?.length
6537
6917
  }, {
6538
6918
  F: __dxlog_file23,
6539
- L: 222,
6919
+ L: 245,
6540
6920
  S: this,
6541
6921
  C: (f, a) => f(...a)
6542
6922
  });
6543
- import_log20.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.end({
6923
+ import_log20.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
6544
6924
  id: this._instanceId
6545
6925
  }), {
6546
6926
  F: __dxlog_file23,
6547
- L: 224,
6927
+ L: 247,
6548
6928
  S: this,
6549
6929
  C: (f, a) => f(...a)
6550
6930
  });
6551
6931
  (0, import_log20.log)("opened", void 0, {
6552
6932
  F: __dxlog_file23,
6553
- L: 225,
6933
+ L: 248,
6554
6934
  S: this,
6555
6935
  C: (f, a) => f(...a)
6556
6936
  });
@@ -6558,7 +6938,7 @@ var ServiceContext = class extends import_context15.Resource {
6558
6938
  async _close(ctx) {
6559
6939
  (0, import_log20.log)("closing...", void 0, {
6560
6940
  F: __dxlog_file23,
6561
- L: 229,
6941
+ L: 252,
6562
6942
  S: this,
6563
6943
  C: (f, a) => f(...a)
6564
6944
  });
@@ -6576,7 +6956,7 @@ var ServiceContext = class extends import_context15.Resource {
6576
6956
  await this._edgeConnection?.close();
6577
6957
  (0, import_log20.log)("closed", void 0, {
6578
6958
  F: __dxlog_file23,
6579
- L: 244,
6959
+ L: 267,
6580
6960
  S: this,
6581
6961
  C: (f, a) => f(...a)
6582
6962
  });
@@ -6585,7 +6965,7 @@ var ServiceContext = class extends import_context15.Resource {
6585
6965
  const identity = await this.identityManager.createIdentity(params);
6586
6966
  await this._initialize(new import_context15.Context(void 0, {
6587
6967
  F: __dxlog_file23,
6588
- L: 249
6968
+ L: 272
6589
6969
  }));
6590
6970
  return identity;
6591
6971
  }
@@ -6593,7 +6973,7 @@ var ServiceContext = class extends import_context15.Resource {
6593
6973
  const factory = this._handlerFactories.get(invitation.kind);
6594
6974
  (0, import_invariant19.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
6595
6975
  F: __dxlog_file23,
6596
- L: 255,
6976
+ L: 278,
6597
6977
  S: this,
6598
6978
  A: [
6599
6979
  "factory",
@@ -6614,21 +6994,21 @@ var ServiceContext = class extends import_context15.Resource {
6614
6994
  const identity = await this.identityManager.acceptIdentity(params);
6615
6995
  await this._initialize(new import_context15.Context(void 0, {
6616
6996
  F: __dxlog_file23,
6617
- L: 271
6997
+ L: 294
6618
6998
  }));
6619
6999
  return identity;
6620
7000
  }
6621
7001
  async _checkStorageVersion() {
6622
7002
  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);
7003
+ if (this.metadataStore.version !== import_protocols13.STORAGE_VERSION) {
7004
+ throw new import_protocols13.InvalidStorageVersionError(import_protocols13.STORAGE_VERSION, this.metadataStore.version);
6625
7005
  }
6626
7006
  }
6627
7007
  // Called when identity is created.
6628
7008
  async _initialize(ctx) {
6629
7009
  (0, import_log20.log)("initializing spaces...", void 0, {
6630
7010
  F: __dxlog_file23,
6631
- L: 286,
7011
+ L: 309,
6632
7012
  S: this,
6633
7013
  C: (f, a) => f(...a)
6634
7014
  });
@@ -6655,6 +7035,7 @@ var ServiceContext = class extends import_context15.Resource {
6655
7035
  echoHost: this.echoHost,
6656
7036
  invitationsManager: this.invitationsManager,
6657
7037
  edgeConnection: this._edgeConnection,
7038
+ edgeHttpClient: this._edgeHttpClient,
6658
7039
  echoEdgeReplicator: this._echoEdgeReplicator,
6659
7040
  meshReplicator: this._meshReplicator,
6660
7041
  runtimeParams: this._runtimeParams,
@@ -6664,7 +7045,7 @@ var ServiceContext = class extends import_context15.Resource {
6664
7045
  this._handlerFactories.set(import_services17.Invitation.Kind.SPACE, (invitation) => {
6665
7046
  (0, import_invariant19.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
6666
7047
  F: __dxlog_file23,
6667
- L: 315,
7048
+ L: 339,
6668
7049
  S: this,
6669
7050
  A: [
6670
7051
  "this.dataSpaceManager",
@@ -6676,7 +7057,7 @@ var ServiceContext = class extends import_context15.Resource {
6676
7057
  this.initialized.wake();
6677
7058
  this._deviceSpaceSync = {
6678
7059
  processCredential: async (credential) => {
6679
- const assertion = (0, import_credentials20.getCredentialAssertion)(credential);
7060
+ const assertion = (0, import_credentials21.getCredentialAssertion)(credential);
6680
7061
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
6681
7062
  return;
6682
7063
  }
@@ -6688,7 +7069,7 @@ var ServiceContext = class extends import_context15.Resource {
6688
7069
  details: assertion
6689
7070
  }, {
6690
7071
  F: __dxlog_file23,
6691
- L: 331,
7072
+ L: 355,
6692
7073
  S: this,
6693
7074
  C: (f, a) => f(...a)
6694
7075
  });
@@ -6699,7 +7080,7 @@ var ServiceContext = class extends import_context15.Resource {
6699
7080
  details: assertion
6700
7081
  }, {
6701
7082
  F: __dxlog_file23,
6702
- L: 335,
7083
+ L: 359,
6703
7084
  S: this,
6704
7085
  C: (f, a) => f(...a)
6705
7086
  });
@@ -6710,7 +7091,7 @@ var ServiceContext = class extends import_context15.Resource {
6710
7091
  details: assertion
6711
7092
  }, {
6712
7093
  F: __dxlog_file23,
6713
- L: 340,
7094
+ L: 364,
6714
7095
  S: this,
6715
7096
  C: (f, a) => f(...a)
6716
7097
  });
@@ -6721,7 +7102,7 @@ var ServiceContext = class extends import_context15.Resource {
6721
7102
  } catch (err) {
6722
7103
  import_log20.log.catch(err, void 0, {
6723
7104
  F: __dxlog_file23,
6724
- L: 346,
7105
+ L: 370,
6725
7106
  S: this,
6726
7107
  C: (f, a) => f(...a)
6727
7108
  });
@@ -6731,13 +7112,13 @@ var ServiceContext = class extends import_context15.Resource {
6731
7112
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
6732
7113
  }
6733
7114
  };
6734
- _ts_decorate7([
7115
+ _ts_decorate9([
6735
7116
  import_tracing10.trace.span()
6736
7117
  ], ServiceContext.prototype, "_open", null);
6737
- _ts_decorate7([
7118
+ _ts_decorate9([
6738
7119
  import_tracing10.trace.span()
6739
7120
  ], ServiceContext.prototype, "_initialize", null);
6740
- ServiceContext = _ts_decorate7([
7121
+ ServiceContext = _ts_decorate9([
6741
7122
  (0, import_util12.safeInstanceof)("dxos.client-services.ServiceContext"),
6742
7123
  import_tracing10.trace.resource()
6743
7124
  ], ServiceContext);
@@ -6775,16 +7156,16 @@ var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
6775
7156
  var createStorageObjects = (config) => {
6776
7157
  const { persistent = false, keyStore, dataStore } = config ?? {};
6777
7158
  if (persistent && dataStore === StorageDriver.RAM) {
6778
- throw new import_protocols13.InvalidConfigError("RAM storage cannot be used in persistent mode.");
7159
+ throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
6779
7160
  }
6780
7161
  if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
6781
- throw new import_protocols13.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
7162
+ throw new import_protocols14.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
6782
7163
  }
6783
7164
  if (persistent && keyStore === StorageDriver.RAM) {
6784
- throw new import_protocols13.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
7165
+ throw new import_protocols14.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
6785
7166
  }
6786
7167
  if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
6787
- throw new import_protocols13.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
7168
+ throw new import_protocols14.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
6788
7169
  }
6789
7170
  return {
6790
7171
  storage: (0, import_random_access_storage.createStorage)({
@@ -6846,7 +7227,7 @@ var exportProfileData = async ({ storage, level }) => {
6846
7227
  const { size } = await file.stat();
6847
7228
  const data = await file.read(0, size);
6848
7229
  archive.storage.push({
6849
- type: import_protocols14.ProfileArchiveEntryType.FILE,
7230
+ type: import_protocols15.ProfileArchiveEntryType.FILE,
6850
7231
  key: filename,
6851
7232
  value: data
6852
7233
  });
@@ -6874,7 +7255,7 @@ var exportProfileData = async ({ storage, level }) => {
6874
7255
  let count = 0;
6875
7256
  for await (const [key, value] of iter) {
6876
7257
  archive.storage.push({
6877
- type: import_protocols14.ProfileArchiveEntryType.KEY_VALUE,
7258
+ type: import_protocols15.ProfileArchiveEntryType.KEY_VALUE,
6878
7259
  key,
6879
7260
  value
6880
7261
  });
@@ -6896,7 +7277,7 @@ var importProfileData = async ({ storage, level }, archive) => {
6896
7277
  let count = 0;
6897
7278
  for (const entry2 of archive.storage) {
6898
7279
  switch (entry2.type) {
6899
- case import_protocols14.ProfileArchiveEntryType.FILE: {
7280
+ case import_protocols15.ProfileArchiveEntryType.FILE: {
6900
7281
  const directory = await storage.createDirectory();
6901
7282
  (0, import_invariant20.invariant)(typeof entry2.key === "string", "Invalid key type", {
6902
7283
  F: __dxlog_file24,
@@ -6921,7 +7302,7 @@ var importProfileData = async ({ storage, level }, archive) => {
6921
7302
  await file.close();
6922
7303
  break;
6923
7304
  }
6924
- case import_protocols14.ProfileArchiveEntryType.KEY_VALUE: {
7305
+ case import_protocols15.ProfileArchiveEntryType.KEY_VALUE: {
6925
7306
  (0, import_invariant20.invariant)(entry2.key instanceof Uint8Array, "Invalid key type", {
6926
7307
  F: __dxlog_file24,
6927
7308
  L: 87,
@@ -7323,7 +7704,7 @@ var SystemServiceImpl = class {
7323
7704
  await this._onReset();
7324
7705
  }
7325
7706
  };
7326
- function _ts_decorate8(decorators, target, key, desc) {
7707
+ function _ts_decorate10(decorators, target, key, desc) {
7327
7708
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7328
7709
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7329
7710
  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 +7726,7 @@ var ClientServicesHost = class {
7345
7726
  this._tracingService = import_tracing11.TRACE_PROCESSOR.createTraceSender();
7346
7727
  this._statusUpdate = new import_async20.Event();
7347
7728
  this._edgeConnection = void 0;
7729
+ this._edgeHttpClient = void 0;
7348
7730
  this._opening = false;
7349
7731
  this._open = false;
7350
7732
  this._storage = storage;
@@ -7368,7 +7750,7 @@ var ClientServicesHost = class {
7368
7750
  if (!this._opening) {
7369
7751
  void this.open(new import_context16.Context(void 0, {
7370
7752
  F: __dxlog_file26,
7371
- L: 132
7753
+ L: 133
7372
7754
  }));
7373
7755
  }
7374
7756
  },
@@ -7426,7 +7808,7 @@ var ClientServicesHost = class {
7426
7808
  initialize({ config, ...options }) {
7427
7809
  (0, import_invariant21.invariant)(!this._open, "service host is open", {
7428
7810
  F: __dxlog_file26,
7429
- L: 198,
7811
+ L: 199,
7430
7812
  S: this,
7431
7813
  A: [
7432
7814
  "!this._open",
@@ -7435,14 +7817,14 @@ var ClientServicesHost = class {
7435
7817
  });
7436
7818
  (0, import_log22.log)("initializing...", void 0, {
7437
7819
  F: __dxlog_file26,
7438
- L: 199,
7820
+ L: 200,
7439
7821
  S: this,
7440
7822
  C: (f, a) => f(...a)
7441
7823
  });
7442
7824
  if (config) {
7443
7825
  (0, import_invariant21.invariant)(!this._config, "config already set", {
7444
7826
  F: __dxlog_file26,
7445
- L: 202,
7827
+ L: 203,
7446
7828
  S: this,
7447
7829
  A: [
7448
7830
  "!this._config",
@@ -7457,17 +7839,17 @@ var ClientServicesHost = class {
7457
7839
  if (!options.signalManager) {
7458
7840
  import_log22.log.warn("running signaling without telemetry metadata.", void 0, {
7459
7841
  F: __dxlog_file26,
7460
- L: 210,
7842
+ L: 211,
7461
7843
  S: this,
7462
7844
  C: (f, a) => f(...a)
7463
7845
  });
7464
7846
  }
7465
7847
  const edgeEndpoint = config?.get("runtime.services.edge.url");
7466
7848
  if (edgeEndpoint) {
7467
- const randomKey = import_keys16.PublicKey.random().toHex();
7468
- this._edgeConnection = new import_edge_client2.EdgeClient(randomKey, randomKey, {
7849
+ this._edgeConnection = new import_edge_client3.EdgeClient((0, import_edge_client3.createStubEdgeIdentity)(), {
7469
7850
  socketEndpoint: edgeEndpoint
7470
7851
  });
7852
+ this._edgeHttpClient = new import_edge_client3.EdgeHttpClient(edgeEndpoint);
7471
7853
  }
7472
7854
  const { connectionLog = true, transportFactory = (0, import_network_manager2.createRtcTransportFactory)({
7473
7855
  iceServers: this._config?.get("runtime.services.ice")
@@ -7477,7 +7859,7 @@ var ClientServicesHost = class {
7477
7859
  this._signalManager = signalManager;
7478
7860
  (0, import_invariant21.invariant)(!this._networkManager, "network manager already set", {
7479
7861
  F: __dxlog_file26,
7480
- L: 232,
7862
+ L: 233,
7481
7863
  S: this,
7482
7864
  A: [
7483
7865
  "!this._networkManager",
@@ -7495,7 +7877,7 @@ var ClientServicesHost = class {
7495
7877
  });
7496
7878
  (0, import_log22.log)("initialized", void 0, {
7497
7879
  F: __dxlog_file26,
7498
- L: 245,
7880
+ L: 246,
7499
7881
  S: this,
7500
7882
  C: (f, a) => f(...a)
7501
7883
  });
@@ -7505,17 +7887,17 @@ var ClientServicesHost = class {
7505
7887
  return;
7506
7888
  }
7507
7889
  const traceId = import_keys16.PublicKey.random().toHex();
7508
- import_log22.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
7890
+ import_log22.log.trace("dxos.client-services.host.open", import_protocols16.trace.begin({
7509
7891
  id: traceId
7510
7892
  }), {
7511
7893
  F: __dxlog_file26,
7512
- L: 256,
7894
+ L: 257,
7513
7895
  S: this,
7514
7896
  C: (f, a) => f(...a)
7515
7897
  });
7516
7898
  (0, import_invariant21.invariant)(this._config, "config not set", {
7517
7899
  F: __dxlog_file26,
7518
- L: 258,
7900
+ L: 259,
7519
7901
  S: this,
7520
7902
  A: [
7521
7903
  "this._config",
@@ -7524,7 +7906,7 @@ var ClientServicesHost = class {
7524
7906
  });
7525
7907
  (0, import_invariant21.invariant)(this._storage, "storage not set", {
7526
7908
  F: __dxlog_file26,
7527
- L: 259,
7909
+ L: 260,
7528
7910
  S: this,
7529
7911
  A: [
7530
7912
  "this._storage",
@@ -7533,7 +7915,7 @@ var ClientServicesHost = class {
7533
7915
  });
7534
7916
  (0, import_invariant21.invariant)(this._signalManager, "signal manager not set", {
7535
7917
  F: __dxlog_file26,
7536
- L: 260,
7918
+ L: 261,
7537
7919
  S: this,
7538
7920
  A: [
7539
7921
  "this._signalManager",
@@ -7542,7 +7924,7 @@ var ClientServicesHost = class {
7542
7924
  });
7543
7925
  (0, import_invariant21.invariant)(this._networkManager, "network manager not set", {
7544
7926
  F: __dxlog_file26,
7545
- L: 261,
7927
+ L: 262,
7546
7928
  S: this,
7547
7929
  A: [
7548
7930
  "this._networkManager",
@@ -7554,7 +7936,7 @@ var ClientServicesHost = class {
7554
7936
  lockKey: this._resourceLock?.lockKey
7555
7937
  }, {
7556
7938
  F: __dxlog_file26,
7557
- L: 264,
7939
+ L: 265,
7558
7940
  S: this,
7559
7941
  C: (f, a) => f(...a)
7560
7942
  });
@@ -7564,7 +7946,7 @@ var ClientServicesHost = class {
7564
7946
  }
7565
7947
  await this._level.open();
7566
7948
  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"));
7949
+ 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
7950
  const dataSpaceManagerProvider = async () => {
7569
7951
  await this._serviceContext.initialized.wait();
7570
7952
  return this._serviceContext.dataSpaceManager;
@@ -7610,15 +7992,15 @@ var ClientServicesHost = class {
7610
7992
  deviceKey
7611
7993
  }, {
7612
7994
  F: __dxlog_file26,
7613
- L: 352,
7995
+ L: 354,
7614
7996
  S: this,
7615
7997
  C: (f, a) => f(...a)
7616
7998
  });
7617
- import_log22.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
7999
+ import_log22.log.trace("dxos.client-services.host.open", import_protocols16.trace.end({
7618
8000
  id: traceId
7619
8001
  }), {
7620
8002
  F: __dxlog_file26,
7621
- L: 353,
8003
+ L: 355,
7622
8004
  S: this,
7623
8005
  C: (f, a) => f(...a)
7624
8006
  });
@@ -7632,7 +8014,7 @@ var ClientServicesHost = class {
7632
8014
  deviceKey
7633
8015
  }, {
7634
8016
  F: __dxlog_file26,
7635
- L: 364,
8017
+ L: 366,
7636
8018
  S: this,
7637
8019
  C: (f, a) => f(...a)
7638
8020
  });
@@ -7650,24 +8032,24 @@ var ClientServicesHost = class {
7650
8032
  deviceKey
7651
8033
  }, {
7652
8034
  F: __dxlog_file26,
7653
- L: 373,
8035
+ L: 375,
7654
8036
  S: this,
7655
8037
  C: (f, a) => f(...a)
7656
8038
  });
7657
8039
  }
7658
8040
  async reset() {
7659
8041
  const traceId = import_keys16.PublicKey.random().toHex();
7660
- import_log22.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
8042
+ import_log22.log.trace("dxos.sdk.client-services-host.reset", import_protocols16.trace.begin({
7661
8043
  id: traceId
7662
8044
  }), {
7663
8045
  F: __dxlog_file26,
7664
- L: 378,
8046
+ L: 380,
7665
8047
  S: this,
7666
8048
  C: (f, a) => f(...a)
7667
8049
  });
7668
8050
  import_log22.log.info("resetting...", void 0, {
7669
8051
  F: __dxlog_file26,
7670
- L: 380,
8052
+ L: 382,
7671
8053
  S: this,
7672
8054
  C: (f, a) => f(...a)
7673
8055
  });
@@ -7675,15 +8057,15 @@ var ClientServicesHost = class {
7675
8057
  await this._storage.reset();
7676
8058
  import_log22.log.info("reset", void 0, {
7677
8059
  F: __dxlog_file26,
7678
- L: 383,
8060
+ L: 385,
7679
8061
  S: this,
7680
8062
  C: (f, a) => f(...a)
7681
8063
  });
7682
- import_log22.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
8064
+ import_log22.log.trace("dxos.sdk.client-services-host.reset", import_protocols16.trace.end({
7683
8065
  id: traceId
7684
8066
  }), {
7685
8067
  F: __dxlog_file26,
7686
- L: 384,
8068
+ L: 386,
7687
8069
  S: this,
7688
8070
  C: (f, a) => f(...a)
7689
8071
  });
@@ -7695,21 +8077,21 @@ var ClientServicesHost = class {
7695
8077
  return identity;
7696
8078
  }
7697
8079
  };
7698
- _ts_decorate8([
8080
+ _ts_decorate10([
7699
8081
  import_tracing11.trace.info()
7700
8082
  ], ClientServicesHost.prototype, "_opening", void 0);
7701
- _ts_decorate8([
8083
+ _ts_decorate10([
7702
8084
  import_tracing11.trace.info()
7703
8085
  ], ClientServicesHost.prototype, "_open", void 0);
7704
- _ts_decorate8([
8086
+ _ts_decorate10([
7705
8087
  import_async20.synchronized,
7706
8088
  import_tracing11.trace.span()
7707
8089
  ], ClientServicesHost.prototype, "open", null);
7708
- _ts_decorate8([
8090
+ _ts_decorate10([
7709
8091
  import_async20.synchronized,
7710
8092
  import_tracing11.trace.span()
7711
8093
  ], ClientServicesHost.prototype, "close", null);
7712
- ClientServicesHost = _ts_decorate8([
8094
+ ClientServicesHost = _ts_decorate10([
7713
8095
  import_tracing11.trace.resource()
7714
8096
  ], ClientServicesHost);
7715
8097
  // Annotate the CommonJS export names for ESM import in node:
@@ -7756,4 +8138,4 @@ ClientServicesHost = _ts_decorate8([
7756
8138
  subscribeToSpaces,
7757
8139
  subscribeToSwarmInfo
7758
8140
  });
7759
- //# sourceMappingURL=chunk-F3WGFGEN.cjs.map
8141
+ //# sourceMappingURL=chunk-2UUETFZ2.cjs.map