@dxos/client-services 0.8.1-main.ba2dec9 → 0.8.1-staging.31c3ee1

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 (52) hide show
  1. package/dist/lib/{node-esm/chunk-FLBMHVSB.mjs → browser/chunk-G4AZ6KHY.mjs} +1354 -869
  2. package/dist/lib/browser/chunk-G4AZ6KHY.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 +1 -1
  6. package/dist/lib/node/{chunk-K7LO776I.cjs → chunk-II76TP7N.cjs} +1058 -722
  7. package/dist/lib/node/chunk-II76TP7N.cjs.map +7 -0
  8. package/dist/lib/node/index.cjs +47 -47
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/testing/index.cjs +8 -8
  11. package/dist/lib/{browser/chunk-VJODS5QE.mjs → node-esm/chunk-2H5CIBX2.mjs} +769 -570
  12. package/dist/lib/node-esm/chunk-2H5CIBX2.mjs.map +7 -0
  13. package/dist/lib/node-esm/index.mjs +1 -1
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/testing/index.mjs +1 -1
  16. package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
  17. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +6 -0
  18. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  19. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  20. package/dist/types/src/packlets/space-export/index.d.ts +3 -0
  21. package/dist/types/src/packlets/space-export/index.d.ts.map +1 -0
  22. package/dist/types/src/packlets/space-export/space-archive-reader.d.ts +9 -0
  23. package/dist/types/src/packlets/space-export/space-archive-reader.d.ts.map +1 -0
  24. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts +23 -0
  25. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -0
  26. package/dist/types/src/packlets/space-export/tar.test.d.ts +2 -0
  27. package/dist/types/src/packlets/space-export/tar.test.d.ts.map +1 -0
  28. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +8 -2
  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 +1 -0
  31. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  32. package/dist/types/src/packlets/spaces/spaces-service.d.ts +3 -1
  33. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  34. package/dist/types/src/version.d.ts +1 -1
  35. package/dist/types/src/version.d.ts.map +1 -1
  36. package/package.json +39 -38
  37. package/src/packlets/devices/devices-service.ts +2 -2
  38. package/src/packlets/devtools/feeds.ts +4 -3
  39. package/src/packlets/identity/contacts-service.ts +2 -2
  40. package/src/packlets/identity/identity-recovery-manager.ts +27 -0
  41. package/src/packlets/identity/identity-service.ts +2 -0
  42. package/src/packlets/space-export/index.ts +6 -0
  43. package/src/packlets/space-export/space-archive-reader.ts +33 -0
  44. package/src/packlets/space-export/space-archive-writer.ts +83 -0
  45. package/src/packlets/space-export/tar.test.ts +25 -0
  46. package/src/packlets/spaces/data-space-manager.ts +70 -9
  47. package/src/packlets/spaces/data-space.ts +14 -1
  48. package/src/packlets/spaces/spaces-service.ts +45 -7
  49. package/src/version.ts +1 -1
  50. package/dist/lib/browser/chunk-VJODS5QE.mjs.map +0 -7
  51. package/dist/lib/node/chunk-K7LO776I.cjs.map +0 -7
  52. package/dist/lib/node-esm/chunk-FLBMHVSB.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_K7LO776I_exports = {};
30
- __export(chunk_K7LO776I_exports, {
29
+ var chunk_II76TP7N_exports = {};
30
+ __export(chunk_II76TP7N_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -72,7 +72,7 @@ __export(chunk_K7LO776I_exports, {
72
72
  subscribeToSpaces: () => subscribeToSpaces,
73
73
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
74
74
  });
75
- module.exports = __toCommonJS(chunk_K7LO776I_exports);
75
+ module.exports = __toCommonJS(chunk_II76TP7N_exports);
76
76
  var import_async = require("@dxos/async");
77
77
  var import_stream = require("@dxos/codec-protobuf/stream");
78
78
  var import_feed_store = require("@dxos/feed-store");
@@ -118,6 +118,7 @@ var import_buf = require("@dxos/protocols/buf");
118
118
  var import_messenger_pb = require("@dxos/protocols/buf/dxos/edge/messenger_pb");
119
119
  var import_util3 = require("@dxos/util");
120
120
  var import_async7 = require("@dxos/async");
121
+ var import_automerge = require("@dxos/automerge/automerge");
121
122
  var import_client_protocol2 = require("@dxos/client-protocol");
122
123
  var import_context4 = require("@dxos/context");
123
124
  var import_debug = require("@dxos/debug");
@@ -162,6 +163,7 @@ var import_credentials8 = require("@dxos/credentials");
162
163
  var import_keys7 = require("@dxos/keys");
163
164
  var import_log7 = require("@dxos/log");
164
165
  var import_async11 = require("@dxos/async");
166
+ var import_automerge_repo = require("@dxos/automerge/automerge-repo");
165
167
  var import_client_protocol4 = require("@dxos/client-protocol");
166
168
  var import_context7 = require("@dxos/context");
167
169
  var import_credentials9 = require("@dxos/credentials");
@@ -189,18 +191,25 @@ var import_credentials13 = require("@dxos/credentials");
189
191
  var import_debug3 = require("@dxos/debug");
190
192
  var import_feed_store4 = require("@dxos/feed-store");
191
193
  var import_invariant8 = require("@dxos/invariant");
194
+ var import_keys9 = require("@dxos/keys");
192
195
  var import_log9 = require("@dxos/log");
193
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
- var import_platform = __toESM(require("platform"));
197
- var import_async13 = require("@dxos/async");
198
199
  var import_context8 = require("@dxos/context");
199
- var import_credentials14 = require("@dxos/credentials");
200
200
  var import_invariant9 = require("@dxos/invariant");
201
- var import_keys9 = require("@dxos/keys");
202
- var import_log10 = require("@dxos/log");
203
201
  var import_protocols7 = require("@dxos/protocols");
202
+ var import_invariant10 = require("@dxos/invariant");
203
+ var import_log10 = require("@dxos/log");
204
+ var import_protocols8 = require("@dxos/protocols");
205
+ var import_platform = __toESM(require("platform"));
206
+ var import_async13 = require("@dxos/async");
207
+ var import_context9 = require("@dxos/context");
208
+ var import_credentials14 = require("@dxos/credentials");
209
+ var import_invariant11 = require("@dxos/invariant");
210
+ var import_keys10 = require("@dxos/keys");
211
+ var import_log11 = require("@dxos/log");
212
+ var import_protocols9 = require("@dxos/protocols");
204
213
  var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
205
214
  var import_credentials15 = require("@dxos/protocols/proto/dxos/halo/credentials");
206
215
  var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
@@ -209,25 +218,25 @@ var import_tracing7 = require("@dxos/tracing");
209
218
  var import_util8 = require("@dxos/util");
210
219
  var import_async14 = require("@dxos/async");
211
220
  var import_stream8 = require("@dxos/codec-protobuf/stream");
212
- var import_context9 = require("@dxos/context");
221
+ var import_context10 = require("@dxos/context");
213
222
  var import_credentials16 = require("@dxos/credentials");
214
- var import_invariant10 = require("@dxos/invariant");
215
- var import_log11 = require("@dxos/log");
223
+ var import_invariant12 = require("@dxos/invariant");
224
+ var import_log12 = require("@dxos/log");
216
225
  var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
217
226
  var import_util9 = require("@dxos/util");
218
227
  var import_credentials17 = require("@dxos/credentials");
219
- var import_invariant11 = require("@dxos/invariant");
220
- var import_protocols8 = require("@dxos/protocols");
228
+ var import_invariant13 = require("@dxos/invariant");
229
+ var import_protocols10 = require("@dxos/protocols");
221
230
  var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
222
231
  var import_async15 = require("@dxos/async");
223
232
  var import_client_protocol5 = require("@dxos/client-protocol");
224
- var import_context10 = require("@dxos/context");
233
+ var import_context11 = require("@dxos/context");
225
234
  var import_crypto = require("@dxos/crypto");
226
- var import_invariant12 = require("@dxos/invariant");
227
- var import_keys10 = require("@dxos/keys");
228
- var import_log12 = require("@dxos/log");
235
+ var import_invariant14 = require("@dxos/invariant");
236
+ var import_keys11 = require("@dxos/keys");
237
+ var import_log13 = require("@dxos/log");
229
238
  var import_network_manager = require("@dxos/network-manager");
230
- var import_protocols9 = require("@dxos/protocols");
239
+ var import_protocols11 = require("@dxos/protocols");
231
240
  var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
232
241
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
233
242
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
@@ -235,39 +244,39 @@ var import_tracing8 = require("@dxos/tracing");
235
244
  var import_util10 = require("@dxos/util");
236
245
  var import_async16 = require("@dxos/async");
237
246
  var import_crypto2 = require("@dxos/crypto");
238
- var import_invariant13 = require("@dxos/invariant");
239
- var import_keys11 = require("@dxos/keys");
240
- var import_log13 = require("@dxos/log");
241
- var import_protocols10 = require("@dxos/protocols");
247
+ var import_invariant15 = require("@dxos/invariant");
248
+ var import_keys12 = require("@dxos/keys");
249
+ var import_log14 = require("@dxos/log");
250
+ var import_protocols12 = require("@dxos/protocols");
242
251
  var import_proto3 = require("@dxos/protocols/proto");
243
252
  var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
244
- var import_context11 = require("@dxos/context");
253
+ var import_context12 = require("@dxos/context");
245
254
  var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
246
255
  var import_async17 = require("@dxos/async");
247
- var import_context12 = require("@dxos/context");
248
- var import_invariant14 = require("@dxos/invariant");
249
- var import_log14 = require("@dxos/log");
250
- var import_protocols11 = require("@dxos/protocols");
256
+ var import_context13 = require("@dxos/context");
257
+ var import_invariant16 = require("@dxos/invariant");
258
+ var import_log15 = require("@dxos/log");
259
+ var import_protocols13 = require("@dxos/protocols");
251
260
  var import_proto4 = require("@dxos/protocols/proto");
252
261
  var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
253
262
  var import_teleport2 = require("@dxos/teleport");
254
263
  var import_async18 = require("@dxos/async");
255
- var import_context13 = require("@dxos/context");
264
+ var import_context14 = require("@dxos/context");
256
265
  var import_crypto3 = require("@dxos/crypto");
257
- var import_invariant15 = require("@dxos/invariant");
258
- var import_keys12 = require("@dxos/keys");
259
- var import_log15 = require("@dxos/log");
260
- var import_protocols12 = require("@dxos/protocols");
266
+ var import_invariant17 = require("@dxos/invariant");
267
+ var import_keys13 = require("@dxos/keys");
268
+ var import_log16 = require("@dxos/log");
269
+ var import_protocols14 = require("@dxos/protocols");
261
270
  var import_proto5 = require("@dxos/protocols/proto");
262
271
  var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
263
272
  var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
264
273
  var import_teleport3 = require("@dxos/teleport");
265
274
  var import_async19 = require("@dxos/async");
266
- var import_log16 = require("@dxos/log");
267
- var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
268
- var import_invariant16 = require("@dxos/invariant");
269
- var import_keys13 = require("@dxos/keys");
270
275
  var import_log17 = require("@dxos/log");
276
+ var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
277
+ var import_invariant18 = require("@dxos/invariant");
278
+ var import_keys14 = require("@dxos/keys");
279
+ var import_log18 = require("@dxos/log");
271
280
  var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations");
272
281
  var import_util11 = require("@dxos/util");
273
282
  var import_stream9 = require("@dxos/codec-protobuf/stream");
@@ -275,102 +284,102 @@ var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
275
284
  var import_tracing9 = require("@dxos/tracing");
276
285
  var import_credentials18 = require("@dxos/credentials");
277
286
  var import_feed_store5 = require("@dxos/feed-store");
278
- var import_invariant17 = require("@dxos/invariant");
279
- var import_log18 = require("@dxos/log");
280
- var import_protocols13 = require("@dxos/protocols");
287
+ var import_invariant19 = require("@dxos/invariant");
288
+ var import_log19 = require("@dxos/log");
289
+ var import_protocols15 = require("@dxos/protocols");
281
290
  var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
282
291
  var import_credentials19 = require("@dxos/protocols/proto/dxos/halo/credentials");
283
292
  var import_async20 = require("@dxos/async");
284
293
  var import_client_protocol6 = require("@dxos/client-protocol");
285
- var import_context14 = require("@dxos/context");
294
+ var import_context15 = require("@dxos/context");
286
295
  var import_credentials20 = require("@dxos/credentials");
287
296
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
288
- var import_invariant18 = require("@dxos/invariant");
289
- var import_keys14 = require("@dxos/keys");
290
- var import_log19 = require("@dxos/log");
297
+ var import_invariant20 = require("@dxos/invariant");
298
+ var import_keys15 = require("@dxos/keys");
299
+ var import_log20 = require("@dxos/log");
291
300
  var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
292
301
  var import_credentials21 = require("@dxos/protocols/proto/dxos/halo/credentials");
293
- var import_invariant19 = require("@dxos/invariant");
302
+ var import_invariant21 = require("@dxos/invariant");
294
303
  var import_lock_file = require("@dxos/lock-file");
295
- var import_log20 = require("@dxos/log");
304
+ var import_log21 = require("@dxos/log");
296
305
  var import_codec_protobuf2 = require("@dxos/codec-protobuf");
297
306
  var import_debug4 = require("@dxos/debug");
298
307
  var import_rpc = require("@dxos/rpc");
299
308
  var import_tracing10 = require("@dxos/tracing");
300
309
  var import_async21 = require("@dxos/async");
301
- var import_context15 = require("@dxos/context");
302
- var import_invariant20 = require("@dxos/invariant");
303
- var import_keys15 = require("@dxos/keys");
304
- var import_log21 = require("@dxos/log");
305
- var import_protocols14 = require("@dxos/protocols");
310
+ var import_context16 = require("@dxos/context");
311
+ var import_invariant22 = require("@dxos/invariant");
312
+ var import_keys16 = require("@dxos/keys");
313
+ var import_log22 = require("@dxos/log");
314
+ var import_protocols16 = require("@dxos/protocols");
306
315
  var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
307
316
  var import_metadata2 = require("@dxos/protocols/proto/dxos/echo/metadata");
308
317
  var import_stream10 = require("@dxos/codec-protobuf/stream");
309
- var import_protocols15 = require("@dxos/protocols");
318
+ var import_protocols17 = require("@dxos/protocols");
310
319
  var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
311
320
  var import_async22 = require("@dxos/async");
312
- var import_context16 = require("@dxos/context");
321
+ var import_context17 = require("@dxos/context");
313
322
  var import_credentials22 = require("@dxos/credentials");
314
323
  var import_debug5 = require("@dxos/debug");
315
324
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
316
325
  var import_edge_client2 = require("@dxos/edge-client");
317
326
  var import_feed_store6 = require("@dxos/feed-store");
318
- var import_invariant21 = require("@dxos/invariant");
327
+ var import_invariant23 = require("@dxos/invariant");
319
328
  var import_keyring = require("@dxos/keyring");
320
- var import_keys16 = require("@dxos/keys");
321
- var import_log22 = require("@dxos/log");
322
- var import_protocols16 = require("@dxos/protocols");
329
+ var import_keys17 = require("@dxos/keys");
330
+ var import_log23 = require("@dxos/log");
331
+ var import_protocols18 = require("@dxos/protocols");
323
332
  var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
324
333
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
325
334
  var import_tracing11 = require("@dxos/tracing");
326
335
  var import_util12 = require("@dxos/util");
327
336
  var import_credentials23 = require("@dxos/credentials");
328
337
  var import_crypto4 = require("@dxos/crypto");
329
- var import_invariant22 = require("@dxos/invariant");
330
- var import_keys17 = require("@dxos/keys");
331
- var import_log23 = require("@dxos/log");
332
- var import_protocols17 = require("@dxos/protocols");
338
+ var import_invariant24 = require("@dxos/invariant");
339
+ var import_keys18 = require("@dxos/keys");
340
+ var import_log24 = require("@dxos/log");
341
+ var import_protocols19 = require("@dxos/protocols");
333
342
  var import_proto6 = require("@dxos/protocols/proto");
334
343
  var import_timeframe5 = require("@dxos/timeframe");
335
- var import_protocols18 = require("@dxos/protocols");
344
+ var import_protocols20 = require("@dxos/protocols");
336
345
  var import_config2 = require("@dxos/protocols/proto/dxos/config");
337
346
  var import_random_access_storage = require("@dxos/random-access-storage");
338
347
  var import_client_protocol7 = require("@dxos/client-protocol");
339
348
  var import_config3 = require("@dxos/protocols/proto/dxos/config");
340
349
  var import_util13 = require("@dxos/util");
341
350
  var import_node_path = __toESM(require("node:path"));
342
- var import_keys18 = require("@dxos/keys");
351
+ var import_keys19 = require("@dxos/keys");
343
352
  var import_kv_store = require("@dxos/kv-store");
344
- var import_automerge_repo = require("@dxos/automerge/automerge-repo");
345
- var import_invariant23 = require("@dxos/invariant");
346
- var import_log24 = require("@dxos/log");
347
- var import_protocols19 = require("@dxos/protocols");
353
+ var import_automerge_repo2 = require("@dxos/automerge/automerge-repo");
354
+ var import_invariant25 = require("@dxos/invariant");
355
+ var import_log25 = require("@dxos/log");
356
+ var import_protocols21 = require("@dxos/protocols");
348
357
  var import_util14 = require("@dxos/util");
349
358
  var import_async23 = require("@dxos/async");
350
359
  var import_client_protocol8 = require("@dxos/client-protocol");
351
- var import_context17 = require("@dxos/context");
360
+ var import_context18 = require("@dxos/context");
352
361
  var import_edge_client3 = require("@dxos/edge-client");
353
- var import_invariant24 = require("@dxos/invariant");
354
- var import_keys19 = require("@dxos/keys");
355
- var import_log25 = require("@dxos/log");
362
+ var import_invariant26 = require("@dxos/invariant");
363
+ var import_keys20 = require("@dxos/keys");
364
+ var import_log26 = require("@dxos/log");
356
365
  var import_messaging = require("@dxos/messaging");
357
366
  var import_network_manager2 = require("@dxos/network-manager");
358
- var import_protocols20 = require("@dxos/protocols");
367
+ var import_protocols22 = require("@dxos/protocols");
359
368
  var import_services22 = require("@dxos/protocols/proto/dxos/client/services");
360
369
  var import_tracing12 = require("@dxos/tracing");
361
370
  var import_websocket_rpc = require("@dxos/websocket-rpc");
362
371
  var import_async24 = require("@dxos/async");
363
372
  var import_stream11 = require("@dxos/codec-protobuf/stream");
364
- var import_invariant25 = require("@dxos/invariant");
373
+ var import_invariant27 = require("@dxos/invariant");
365
374
  var import_services23 = require("@dxos/protocols/proto/dxos/client/services");
366
375
  var import_async25 = require("@dxos/async");
367
376
  var import_stream12 = require("@dxos/codec-protobuf/stream");
368
- var import_keys20 = require("@dxos/keys");
377
+ var import_keys21 = require("@dxos/keys");
369
378
  var import_util15 = require("@dxos/util");
370
379
  var import_async26 = require("@dxos/async");
371
380
  var import_stream13 = require("@dxos/codec-protobuf/stream");
372
- var import_keys21 = require("@dxos/keys");
373
- var import_log26 = require("@dxos/log");
381
+ var import_keys22 = require("@dxos/keys");
382
+ var import_log27 = require("@dxos/log");
374
383
  var import_services24 = require("@dxos/protocols/proto/dxos/client/services");
375
384
  var import_util16 = require("@dxos/util");
376
385
  var import_stream14 = require("@dxos/codec-protobuf/stream");
@@ -380,7 +389,7 @@ var import_util17 = require("@dxos/util");
380
389
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/feeds.ts";
381
390
  var subscribeToFeeds = ({ feedStore, spaceManager }, { feedKeys }) => {
382
391
  return new import_stream.Stream(({ next }) => {
383
- const subscriptions = new import_async.EventSubscriptions();
392
+ const subscriptions = new import_async.SubscriptionList();
384
393
  const feedMap = new import_util.ComplexMap(import_keys.PublicKey.hash);
385
394
  const update = () => {
386
395
  const { feeds } = feedStore;
@@ -442,7 +451,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
442
451
  if (!feedKey) {
443
452
  return;
444
453
  }
445
- const subscriptions = new import_async.EventSubscriptions();
454
+ const subscriptions = new import_async.SubscriptionList();
446
455
  const timeout = setTimeout(async () => {
447
456
  const feed = feedStore.getFeed(feedKey);
448
457
  if (!feed) {
@@ -735,7 +744,7 @@ var DevtoolsServiceImpl = class {
735
744
  });
736
745
  }
737
746
  };
738
- var DXOS_VERSION = "0.8.1-main.ba2dec9";
747
+ var DXOS_VERSION = "0.8.1-staging.31c3ee1";
739
748
  var getPlatform = () => {
740
749
  if (process.browser) {
741
750
  if (typeof window !== "undefined") {
@@ -2221,10 +2230,15 @@ var DataSpaceManager = class extends import_context7.Resource {
2221
2230
  get spaces() {
2222
2231
  return this._spaces;
2223
2232
  }
2233
+ getSpaceById(spaceId) {
2234
+ return [
2235
+ ...this._spaces.values()
2236
+ ].find((space) => space.id === spaceId);
2237
+ }
2224
2238
  async _open() {
2225
2239
  (0, import_log8.log)("open", void 0, {
2226
2240
  F: __dxlog_file9,
2227
- L: 192,
2241
+ L: 213,
2228
2242
  S: this,
2229
2243
  C: (f, a) => f(...a)
2230
2244
  });
@@ -2232,7 +2246,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2232
2246
  id: this._instanceId
2233
2247
  }), {
2234
2248
  F: __dxlog_file9,
2235
- L: 193,
2249
+ L: 214,
2236
2250
  S: this,
2237
2251
  C: (f, a) => f(...a)
2238
2252
  });
@@ -2240,7 +2254,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2240
2254
  spaces: this._metadataStore.spaces.length
2241
2255
  }, {
2242
2256
  F: __dxlog_file9,
2243
- L: 194,
2257
+ L: 215,
2244
2258
  S: this,
2245
2259
  C: (f, a) => f(...a)
2246
2260
  });
@@ -2250,7 +2264,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2250
2264
  spaceMetadata
2251
2265
  }, {
2252
2266
  F: __dxlog_file9,
2253
- L: 198,
2267
+ L: 219,
2254
2268
  S: this,
2255
2269
  C: (f, a) => f(...a)
2256
2270
  });
@@ -2261,7 +2275,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2261
2275
  err
2262
2276
  }, {
2263
2277
  F: __dxlog_file9,
2264
- L: 201,
2278
+ L: 222,
2265
2279
  S: this,
2266
2280
  C: (f, a) => f(...a)
2267
2281
  });
@@ -2272,7 +2286,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2272
2286
  id: this._instanceId
2273
2287
  }), {
2274
2288
  F: __dxlog_file9,
2275
- L: 207,
2289
+ L: 228,
2276
2290
  S: this,
2277
2291
  C: (f, a) => f(...a)
2278
2292
  });
@@ -2280,7 +2294,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2280
2294
  async _close() {
2281
2295
  (0, import_log8.log)("close", void 0, {
2282
2296
  F: __dxlog_file9,
2283
- L: 212,
2297
+ L: 233,
2284
2298
  S: this,
2285
2299
  C: (f, a) => f(...a)
2286
2300
  });
@@ -2292,19 +2306,13 @@ var DataSpaceManager = class extends import_context7.Resource {
2292
2306
  /**
2293
2307
  * Creates a new space writing the genesis credentials to the control feed.
2294
2308
  */
2295
- async createSpace() {
2296
- (0, import_invariant7.invariant)(this._lifecycleState === import_context7.LifecycleState.OPEN, "Not open.", {
2297
- F: __dxlog_file9,
2298
- L: 224,
2299
- S: this,
2300
- A: [
2301
- "this._lifecycleState === LifecycleState.OPEN",
2302
- "'Not open.'"
2303
- ]
2304
- });
2309
+ async createSpace(options = {}) {
2310
+ (0, import_invariant7.assertArgument)(!!options.rootUrl === !!options.documents, "root url must be required when providing documents");
2311
+ (0, import_invariant7.assertState)(this._lifecycleState === import_context7.LifecycleState.OPEN, "Not open.");
2305
2312
  const spaceKey = await this._keyring.createKey();
2306
2313
  const controlFeedKey = await this._keyring.createKey();
2307
2314
  const dataFeedKey = await this._keyring.createKey();
2315
+ const spaceId = await (0, import_echo_protocol2.createIdFromSpaceKey)(spaceKey);
2308
2316
  const metadata = {
2309
2317
  key: spaceKey,
2310
2318
  genesisFeedKey: controlFeedKey,
@@ -2313,22 +2321,84 @@ var DataSpaceManager = class extends import_context7.Resource {
2313
2321
  state: import_services6.SpaceState.SPACE_ACTIVE
2314
2322
  };
2315
2323
  (0, import_log8.log)("creating space...", {
2324
+ spaceId,
2325
+ spaceKey
2326
+ }, {
2327
+ F: __dxlog_file9,
2328
+ L: 262,
2329
+ S: this,
2330
+ C: (f, a) => f(...a)
2331
+ });
2332
+ const documentIdMapping = {};
2333
+ if (options.documents) {
2334
+ (0, import_invariant7.invariant)(Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId)), "Invalid document IDs", {
2335
+ F: __dxlog_file9,
2336
+ L: 267,
2337
+ S: this,
2338
+ A: [
2339
+ "Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId))",
2340
+ "'Invalid document IDs'"
2341
+ ]
2342
+ });
2343
+ await Promise.all(Object.entries(options.documents).map(async ([documentId, data]) => {
2344
+ (0, import_log8.log)("creating document...", {
2345
+ documentId
2346
+ }, {
2347
+ F: __dxlog_file9,
2348
+ L: 274,
2349
+ S: this,
2350
+ C: (f, a) => f(...a)
2351
+ });
2352
+ const newDoc = await this._echoHost.createDoc(data, {
2353
+ preserveHistory: true
2354
+ });
2355
+ documentIdMapping[documentId] = newDoc.documentId;
2356
+ }));
2357
+ }
2358
+ (0, import_log8.log)("opening space...", {
2316
2359
  spaceKey
2317
2360
  }, {
2318
2361
  F: __dxlog_file9,
2319
- L: 236,
2362
+ L: 281,
2363
+ S: this,
2364
+ C: (f, a) => f(...a)
2365
+ });
2366
+ let root;
2367
+ if (options.rootUrl) {
2368
+ const newRootDocId = documentIdMapping[(0, import_automerge_repo.interpretAsDocumentId)(options.rootUrl)] ?? (0, import_invariant7.failedInvariant)();
2369
+ const rootDocHandle = await this._echoHost.loadDoc(import_context7.Context.default(void 0, {
2370
+ F: __dxlog_file9,
2371
+ L: 286
2372
+ }), newRootDocId);
2373
+ import_echo_pipeline2.DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
2374
+ root = await this._echoHost.openSpaceRoot(spaceId, `automerge:${newRootDocId}`);
2375
+ } else {
2376
+ root = await this._echoHost.createSpaceRoot(spaceKey);
2377
+ }
2378
+ (0, import_log8.log)("constructing space...", {
2379
+ spaceKey
2380
+ }, {
2381
+ F: __dxlog_file9,
2382
+ L: 294,
2320
2383
  S: this,
2321
2384
  C: (f, a) => f(...a)
2322
2385
  });
2323
- const root = await this._echoHost.createSpaceRoot(spaceKey);
2324
2386
  const space = await this._constructSpace(metadata);
2325
2387
  await space.open();
2388
+ (0, import_log8.log)("adding space...", {
2389
+ spaceKey
2390
+ }, {
2391
+ F: __dxlog_file9,
2392
+ L: 299,
2393
+ S: this,
2394
+ C: (f, a) => f(...a)
2395
+ });
2326
2396
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
2327
2397
  await this._metadataStore.addSpace(metadata);
2328
2398
  const memberCredential = credentials[1];
2329
2399
  (0, import_invariant7.invariant)((0, import_credentials9.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2330
2400
  F: __dxlog_file9,
2331
- L: 246,
2401
+ L: 305,
2332
2402
  S: this,
2333
2403
  A: [
2334
2404
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2337,6 +2407,15 @@ var DataSpaceManager = class extends import_context7.Resource {
2337
2407
  });
2338
2408
  await this._signingContext.recordCredential(memberCredential);
2339
2409
  await space.initializeDataPipeline();
2410
+ (0, import_log8.log)("space ready.", {
2411
+ spaceId,
2412
+ spaceKey
2413
+ }, {
2414
+ F: __dxlog_file9,
2415
+ L: 310,
2416
+ S: this,
2417
+ C: (f, a) => f(...a)
2418
+ });
2340
2419
  this.updated.emit();
2341
2420
  return space;
2342
2421
  }
@@ -2358,7 +2437,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2358
2437
  spaceId: space.id
2359
2438
  }, {
2360
2439
  F: __dxlog_file9,
2361
- L: 269,
2440
+ L: 330,
2362
2441
  S: this,
2363
2442
  C: (f, a) => f(...a)
2364
2443
  });
@@ -2393,7 +2472,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2393
2472
  const automergeIndex = space.automergeSpaceState.rootUrl;
2394
2473
  (0, import_invariant7.invariant)(automergeIndex, void 0, {
2395
2474
  F: __dxlog_file9,
2396
- L: 302,
2475
+ L: 363,
2397
2476
  S: this,
2398
2477
  A: [
2399
2478
  "automergeIndex",
@@ -2410,13 +2489,13 @@ var DataSpaceManager = class extends import_context7.Resource {
2410
2489
  opts
2411
2490
  }, {
2412
2491
  F: __dxlog_file9,
2413
- L: 311,
2492
+ L: 372,
2414
2493
  S: this,
2415
2494
  C: (f, a) => f(...a)
2416
2495
  });
2417
2496
  (0, import_invariant7.invariant)(this._lifecycleState === import_context7.LifecycleState.OPEN, "Not open.", {
2418
2497
  F: __dxlog_file9,
2419
- L: 312,
2498
+ L: 373,
2420
2499
  S: this,
2421
2500
  A: [
2422
2501
  "this._lifecycleState === LifecycleState.OPEN",
@@ -2425,7 +2504,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2425
2504
  });
2426
2505
  (0, import_invariant7.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
2427
2506
  F: __dxlog_file9,
2428
- L: 313,
2507
+ L: 374,
2429
2508
  S: this,
2430
2509
  A: [
2431
2510
  "!this._spaces.has(opts.spaceKey)",
@@ -2449,7 +2528,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2449
2528
  const space = this._spaceManager.spaces.get(options.spaceKey);
2450
2529
  (0, import_invariant7.invariant)(space, void 0, {
2451
2530
  F: __dxlog_file9,
2452
- L: 333,
2531
+ L: 394,
2453
2532
  S: this,
2454
2533
  A: [
2455
2534
  "space",
@@ -2462,7 +2541,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2462
2541
  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);
2463
2542
  (0, import_invariant7.invariant)(credentials[0].credential, void 0, {
2464
2543
  F: __dxlog_file9,
2465
- L: 352,
2544
+ L: 413,
2466
2545
  S: this,
2467
2546
  A: [
2468
2547
  "credentials[0].credential",
@@ -2472,7 +2551,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2472
2551
  const spaceMemberCredential = credentials[0].credential.credential;
2473
2552
  (0, import_invariant7.invariant)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2474
2553
  F: __dxlog_file9,
2475
- L: 354,
2554
+ L: 415,
2476
2555
  S: this,
2477
2556
  A: [
2478
2557
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2510,7 +2589,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2510
2589
  const space = this._spaces.get(spaceKey);
2511
2590
  (0, import_invariant7.invariant)(space, "Space not found.", {
2512
2591
  F: __dxlog_file9,
2513
- L: 391,
2592
+ L: 452,
2514
2593
  S: this,
2515
2594
  A: [
2516
2595
  "space",
@@ -2535,7 +2614,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2535
2614
  metadata
2536
2615
  }, {
2537
2616
  F: __dxlog_file9,
2538
- L: 410,
2617
+ L: 471,
2539
2618
  S: this,
2540
2619
  C: (f, a) => f(...a)
2541
2620
  });
@@ -2579,7 +2658,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2579
2658
  err
2580
2659
  }, {
2581
2660
  F: __dxlog_file9,
2582
- L: 452,
2661
+ L: 513,
2583
2662
  S: this,
2584
2663
  C: (f, a) => f(...a)
2585
2664
  });
@@ -2589,7 +2668,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2589
2668
  onAuthFailure: () => {
2590
2669
  import_log8.log.warn("auth failure", void 0, {
2591
2670
  F: __dxlog_file9,
2592
- L: 457,
2671
+ L: 518,
2593
2672
  S: this,
2594
2673
  C: (f, a) => f(...a)
2595
2674
  });
@@ -2622,7 +2701,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2622
2701
  space: space.key
2623
2702
  }, {
2624
2703
  F: __dxlog_file9,
2625
- L: 484,
2704
+ L: 545,
2626
2705
  S: this,
2627
2706
  C: (f, a) => f(...a)
2628
2707
  });
@@ -2633,7 +2712,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2633
2712
  open: this._lifecycleState === import_context7.LifecycleState.OPEN
2634
2713
  }, {
2635
2714
  F: __dxlog_file9,
2636
- L: 487,
2715
+ L: 548,
2637
2716
  S: this,
2638
2717
  C: (f, a) => f(...a)
2639
2718
  });
@@ -2652,7 +2731,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2652
2731
  space: space.key
2653
2732
  }, {
2654
2733
  F: __dxlog_file9,
2655
- L: 495,
2734
+ L: 556,
2656
2735
  S: this,
2657
2736
  C: (f, a) => f(...a)
2658
2737
  });
@@ -2673,7 +2752,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2673
2752
  spaceId: dataSpace.id
2674
2753
  }, {
2675
2754
  F: __dxlog_file9,
2676
- L: 509,
2755
+ L: 570,
2677
2756
  S: this,
2678
2757
  C: (f, a) => f(...a)
2679
2758
  });
@@ -2703,7 +2782,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2703
2782
  space: space.key
2704
2783
  }, {
2705
2784
  F: __dxlog_file9,
2706
- L: 536,
2785
+ L: 597,
2707
2786
  S: this,
2708
2787
  C: (f, a) => f(...a)
2709
2788
  });
@@ -2736,7 +2815,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2736
2815
  closedSessions
2737
2816
  }, {
2738
2817
  F: __dxlog_file9,
2739
- L: 562,
2818
+ L: 623,
2740
2819
  S: this,
2741
2820
  C: (f, a) => f(...a)
2742
2821
  });
@@ -2751,7 +2830,7 @@ var DataSpaceManager = class extends import_context7.Resource {
2751
2830
  peerId: peerState.peerId
2752
2831
  }, {
2753
2832
  F: __dxlog_file9,
2754
- L: 576,
2833
+ L: 637,
2755
2834
  S: this,
2756
2835
  C: (f, a) => f(...a)
2757
2836
  });
@@ -2810,7 +2889,155 @@ _ts_decorate3([
2810
2889
  DataSpaceManager = _ts_decorate3([
2811
2890
  (0, import_async11.trackLeaks)("open", "close")
2812
2891
  ], DataSpaceManager);
2813
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2892
+ var CURRENT_VERSION = import_protocols7.SpaceArchiveVersion.V1;
2893
+ var SpaceArchiveWriter = class extends import_context8.Resource {
2894
+ constructor() {
2895
+ super(...arguments);
2896
+ this._meta = void 0;
2897
+ this._currentRootUrl = void 0;
2898
+ }
2899
+ async _open(ctx) {
2900
+ this._tar = await import("@obsidize/tar-browserify");
2901
+ }
2902
+ async _close() {
2903
+ return Promise.resolve();
2904
+ }
2905
+ async begin(meta) {
2906
+ (0, import_invariant9.assertState)(this._tar, "Not open");
2907
+ (0, import_invariant9.assertState)(!this._meta, "Already started");
2908
+ this._meta = meta;
2909
+ this._archive = new this._tar.Archive();
2910
+ }
2911
+ async setCurrentRootUrl(url) {
2912
+ (0, import_invariant9.assertArgument)(url.startsWith("automerge:"), "Invalid root URL");
2913
+ (0, import_invariant9.assertState)(this._tar, "Not open");
2914
+ (0, import_invariant9.assertState)(this._meta, "Not started");
2915
+ this._currentRootUrl = url;
2916
+ }
2917
+ async writeDocument(documentId, data) {
2918
+ (0, import_invariant9.assertArgument)(!documentId.startsWith("automerge:"), "Invalid document ID");
2919
+ (0, import_invariant9.assertState)(this._archive, "Not open");
2920
+ this._archive.addBinaryFile(`${import_protocols7.SpaceArchiveFileStructure.documents}/${documentId}.bin`, data);
2921
+ }
2922
+ async finish() {
2923
+ (0, import_invariant9.assertState)(this._archive, "Not open");
2924
+ (0, import_invariant9.assertState)(this._meta, "Not started");
2925
+ (0, import_invariant9.assertState)(this._currentRootUrl, "No root URL set");
2926
+ const metadata = {
2927
+ version: CURRENT_VERSION,
2928
+ createdAt: Date.now(),
2929
+ exportedBy: this._meta.exportedBy,
2930
+ originalSpaceId: this._meta.spaceId,
2931
+ echo: {
2932
+ currentRootUrl: this._currentRootUrl
2933
+ }
2934
+ };
2935
+ this._archive.addTextFile(import_protocols7.SpaceArchiveFileStructure.metadata, JSON.stringify(metadata));
2936
+ const binary = this._archive.toUint8Array();
2937
+ return {
2938
+ filename: `${this._meta.spaceId}.tar`,
2939
+ contents: binary
2940
+ };
2941
+ }
2942
+ };
2943
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/space-export/space-archive-reader.ts";
2944
+ var extractSpaceArchive = async (archive) => {
2945
+ const { Archive } = await import("@obsidize/tar-browserify");
2946
+ const { entries } = await Archive.extract(archive.contents);
2947
+ const metadataEntry = entries.find((entry2) => entry2.fileName === import_protocols8.SpaceArchiveFileStructure.metadata);
2948
+ (0, import_invariant10.assertArgument)(metadataEntry, "Metadata entry not found");
2949
+ const metadata = JSON.parse(metadataEntry.getContentAsText());
2950
+ const documents = {};
2951
+ for (const entry2 of entries.filter((entry3) => entry3.fileName.startsWith(`${import_protocols8.SpaceArchiveFileStructure.documents}/`))) {
2952
+ const documentId = entry2.fileName.replace(`${import_protocols8.SpaceArchiveFileStructure.documents}/`, "").replace(/\.bin$/, "");
2953
+ (0, import_invariant10.invariant)(!documentId.includes("/"), void 0, {
2954
+ F: __dxlog_file10,
2955
+ L: 27,
2956
+ S: void 0,
2957
+ A: [
2958
+ "!documentId.includes('/')",
2959
+ ""
2960
+ ]
2961
+ });
2962
+ documents[documentId] = entry2.content ?? (0, import_invariant10.failedInvariant)();
2963
+ }
2964
+ import_log10.log.info("extracted space archive", {
2965
+ metadata,
2966
+ documents
2967
+ }, {
2968
+ F: __dxlog_file10,
2969
+ L: 31,
2970
+ S: void 0,
2971
+ C: (f, a) => f(...a)
2972
+ });
2973
+ return {
2974
+ metadata,
2975
+ documents
2976
+ };
2977
+ };
2978
+ function _using_ctx2() {
2979
+ var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
2980
+ var err = new Error();
2981
+ err.name = "SuppressedError";
2982
+ err.suppressed = suppressed;
2983
+ err.error = error;
2984
+ return err;
2985
+ }, empty = {}, stack = [];
2986
+ function using(isAwait, value) {
2987
+ if (value != null) {
2988
+ if (Object(value) !== value) {
2989
+ throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
2990
+ }
2991
+ if (isAwait) {
2992
+ var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
2993
+ }
2994
+ if (dispose == null) {
2995
+ dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
2996
+ }
2997
+ if (typeof dispose !== "function") {
2998
+ throw new TypeError(`Property [Symbol.dispose] is not a function.`);
2999
+ }
3000
+ stack.push({
3001
+ v: value,
3002
+ d: dispose,
3003
+ a: isAwait
3004
+ });
3005
+ } else if (isAwait) {
3006
+ stack.push({
3007
+ d: value,
3008
+ a: isAwait
3009
+ });
3010
+ }
3011
+ return value;
3012
+ }
3013
+ return {
3014
+ e: empty,
3015
+ u: using.bind(null, false),
3016
+ a: using.bind(null, true),
3017
+ d: function() {
3018
+ var error = this.e;
3019
+ function next() {
3020
+ while (resource = stack.pop()) {
3021
+ try {
3022
+ var resource, disposalResult = resource.d && resource.d.call(resource.v);
3023
+ if (resource.a) {
3024
+ return Promise.resolve(disposalResult).then(next, err);
3025
+ }
3026
+ } catch (e) {
3027
+ return err(e);
3028
+ }
3029
+ }
3030
+ if (error !== empty) throw error;
3031
+ }
3032
+ function err(e) {
3033
+ error = error !== empty ? new _disposeSuppressedError(error, e) : e;
3034
+ return next();
3035
+ }
3036
+ return next();
3037
+ }
3038
+ };
3039
+ }
3040
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2814
3041
  var SpacesServiceImpl = class {
2815
3042
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
2816
3043
  this._identityManager = _identityManager;
@@ -2857,8 +3084,8 @@ var SpacesServiceImpl = class {
2857
3084
  }
2858
3085
  const credentials = await (0, import_credentials13.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2859
3086
  (0, import_invariant8.invariant)(credentials[0].credential, void 0, {
2860
- F: __dxlog_file10,
2861
- L: 111,
3087
+ F: __dxlog_file11,
3088
+ L: 118,
2862
3089
  S: this,
2863
3090
  A: [
2864
3091
  "credentials[0].credential",
@@ -2867,8 +3094,8 @@ var SpacesServiceImpl = class {
2867
3094
  });
2868
3095
  const spaceMemberCredential = credentials[0].credential.credential;
2869
3096
  (0, import_invariant8.invariant)((0, import_credentials13.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2870
- F: __dxlog_file10,
2871
- L: 113,
3097
+ F: __dxlog_file11,
3098
+ L: 120,
2872
3099
  S: this,
2873
3100
  A: [
2874
3101
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2885,8 +3112,8 @@ var SpacesServiceImpl = class {
2885
3112
  (0, import_log9.log)("update", () => ({
2886
3113
  ids: spaces.map((space) => space.id)
2887
3114
  }), {
2888
- F: __dxlog_file10,
2889
- L: 126,
3115
+ F: __dxlog_file11,
3116
+ L: 133,
2890
3117
  S: this,
2891
3118
  C: (f, a) => f(...a)
2892
3119
  });
@@ -2899,7 +3126,7 @@ var SpacesServiceImpl = class {
2899
3126
  });
2900
3127
  (0, import_async12.scheduleTask)(ctx, async () => {
2901
3128
  const dataSpaceManager = await this._getDataSpaceManager();
2902
- const subscriptions = new import_async12.EventSubscriptions();
3129
+ const subscriptions = new import_async12.SubscriptionList();
2903
3130
  ctx.onDispose(() => subscriptions.clear());
2904
3131
  const subscribeSpaces = () => {
2905
3132
  subscriptions.clear();
@@ -2977,8 +3204,8 @@ var SpacesServiceImpl = class {
2977
3204
  });
2978
3205
  } else {
2979
3206
  (0, import_invariant8.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
2980
- F: __dxlog_file10,
2981
- L: 224,
3207
+ F: __dxlog_file11,
3208
+ L: 231,
2982
3209
  S: this,
2983
3210
  A: [
2984
3211
  "!credential.id",
@@ -2986,8 +3213,8 @@ var SpacesServiceImpl = class {
2986
3213
  ]
2987
3214
  });
2988
3215
  (0, import_invariant8.invariant)(this._identityManager.identity, "Identity is not available", {
2989
- F: __dxlog_file10,
2990
- L: 225,
3216
+ F: __dxlog_file11,
3217
+ L: 232,
2991
3218
  S: this,
2992
3219
  A: [
2993
3220
  "this._identityManager.identity",
@@ -2996,8 +3223,8 @@ var SpacesServiceImpl = class {
2996
3223
  });
2997
3224
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
2998
3225
  (0, import_invariant8.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
2999
- F: __dxlog_file10,
3000
- L: 227,
3226
+ F: __dxlog_file11,
3227
+ L: 234,
3001
3228
  S: this,
3002
3229
  A: [
3003
3230
  "credential.issuer.equals(signer.getIssuer())",
@@ -3043,11 +3270,58 @@ var SpacesServiceImpl = class {
3043
3270
  credential
3044
3271
  });
3045
3272
  }
3273
+ async exportSpace(request) {
3274
+ try {
3275
+ var _usingCtx = _using_ctx2();
3276
+ const writer = _usingCtx.a(await new SpaceArchiveWriter().open());
3277
+ (0, import_invariant8.assertArgument)(import_keys9.SpaceId.isValid(request.spaceId), "Invalid space ID");
3278
+ const dataSpaceManager = await this._getDataSpaceManager();
3279
+ const space = dataSpaceManager.getSpaceById(request.spaceId) ?? (0, import_debug3.raise)(new Error("Space not found"));
3280
+ await writer.begin({
3281
+ spaceId: space.id
3282
+ });
3283
+ const rootUrl = space.automergeSpaceState.lastEpoch?.subject.assertion.automergeRoot;
3284
+ (0, import_invariant8.assertState)(rootUrl, "Space does not have a root URL");
3285
+ await writer.setCurrentRootUrl(rootUrl);
3286
+ for await (const [documentId, data] of space.getAllDocuments()) {
3287
+ await writer.writeDocument(documentId, data);
3288
+ }
3289
+ const archive = await writer.finish();
3290
+ return {
3291
+ archive
3292
+ };
3293
+ } catch (_) {
3294
+ _usingCtx.e = _;
3295
+ } finally {
3296
+ await _usingCtx.d();
3297
+ }
3298
+ }
3299
+ async importSpace(request) {
3300
+ const dataSpaceManager = await this._getDataSpaceManager();
3301
+ const extracted = await extractSpaceArchive(request.archive);
3302
+ (0, import_invariant8.invariant)(extracted.metadata.echo?.currentRootUrl, "Space archive does not contain a root URL", {
3303
+ F: __dxlog_file11,
3304
+ L: 288,
3305
+ S: this,
3306
+ A: [
3307
+ "extracted.metadata.echo?.currentRootUrl",
3308
+ "'Space archive does not contain a root URL'"
3309
+ ]
3310
+ });
3311
+ const space = await dataSpaceManager.createSpace({
3312
+ documents: extracted.documents,
3313
+ rootUrl: extracted.metadata.echo?.currentRootUrl
3314
+ });
3315
+ await this._updateMetrics();
3316
+ return {
3317
+ newSpaceId: space.id
3318
+ };
3319
+ }
3046
3320
  async _joinByAdmission({ credential }) {
3047
3321
  const assertion = (0, import_credentials13.getCredentialAssertion)(credential);
3048
3322
  (0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3049
- F: __dxlog_file10,
3050
- L: 261,
3323
+ F: __dxlog_file11,
3324
+ L: 299,
3051
3325
  S: this,
3052
3326
  A: [
3053
3327
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3056,8 +3330,8 @@ var SpacesServiceImpl = class {
3056
3330
  });
3057
3331
  const myIdentity = this._identityManager.identity;
3058
3332
  (0, import_invariant8.invariant)(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
3059
- F: __dxlog_file10,
3060
- L: 263,
3333
+ F: __dxlog_file11,
3334
+ L: 301,
3061
3335
  S: this,
3062
3336
  A: [
3063
3337
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -3149,7 +3423,7 @@ function _ts_decorate4(decorators, target, key, desc) {
3149
3423
  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;
3150
3424
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3151
3425
  }
3152
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
3426
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
3153
3427
  var Identity = class {
3154
3428
  constructor(params) {
3155
3429
  this._edgeFeedReplicator = void 0;
@@ -3166,7 +3440,7 @@ var Identity = class {
3166
3440
  import_log6.log.trace("dxos.halo.device", {
3167
3441
  deviceKey: params.deviceKey
3168
3442
  }, {
3169
- F: __dxlog_file11,
3443
+ F: __dxlog_file12,
3170
3444
  L: 82,
3171
3445
  S: this,
3172
3446
  C: (f, a) => f(...a)
@@ -3268,7 +3542,7 @@ var Identity = class {
3268
3542
  */
3269
3543
  getIdentityCredentialSigner() {
3270
3544
  (0, import_invariant6.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
3271
- F: __dxlog_file11,
3545
+ F: __dxlog_file12,
3272
3546
  L: 198,
3273
3547
  S: this,
3274
3548
  A: [
@@ -3312,7 +3586,7 @@ var Identity = class {
3312
3586
  controlFeedKey,
3313
3587
  dataFeedKey
3314
3588
  }, {
3315
- F: __dxlog_file11,
3589
+ F: __dxlog_file12,
3316
3590
  L: 223,
3317
3591
  S: this,
3318
3592
  C: (f, a) => f(...a)
@@ -3371,7 +3645,7 @@ function _ts_decorate5(decorators, target, key, desc) {
3371
3645
  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;
3372
3646
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3373
3647
  }
3374
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
3648
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
3375
3649
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3376
3650
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
3377
3651
  var IdentityManager = class {
@@ -3391,20 +3665,20 @@ var IdentityManager = class {
3391
3665
  return this._identity;
3392
3666
  }
3393
3667
  async open(ctx) {
3394
- const traceId = import_keys9.PublicKey.random().toHex();
3395
- import_log10.log.trace("dxos.halo.identity-manager.open", import_protocols7.trace.begin({
3668
+ const traceId = import_keys10.PublicKey.random().toHex();
3669
+ import_log11.log.trace("dxos.halo.identity-manager.open", import_protocols9.trace.begin({
3396
3670
  id: traceId
3397
3671
  }), {
3398
- F: __dxlog_file12,
3672
+ F: __dxlog_file13,
3399
3673
  L: 116,
3400
3674
  S: this,
3401
3675
  C: (f, a) => f(...a)
3402
3676
  });
3403
3677
  const identityRecord = this._metadataStore.getIdentityRecord();
3404
- (0, import_log10.log)("identity record", {
3678
+ (0, import_log11.log)("identity record", {
3405
3679
  identityRecord
3406
3680
  }, {
3407
- F: __dxlog_file12,
3681
+ F: __dxlog_file13,
3408
3682
  L: 119,
3409
3683
  S: this,
3410
3684
  C: (f, a) => f(...a)
@@ -3413,35 +3687,35 @@ var IdentityManager = class {
3413
3687
  this._identity = await this._constructIdentity(identityRecord);
3414
3688
  await this._identity.open(ctx);
3415
3689
  await this._identity.ready();
3416
- import_log10.log.trace("dxos.halo.identity", {
3690
+ import_log11.log.trace("dxos.halo.identity", {
3417
3691
  identityKey: identityRecord.identityKey,
3418
3692
  displayName: this._identity.profileDocument?.displayName
3419
3693
  }, {
3420
- F: __dxlog_file12,
3694
+ F: __dxlog_file13,
3421
3695
  L: 124,
3422
3696
  S: this,
3423
3697
  C: (f, a) => f(...a)
3424
3698
  });
3425
3699
  this.stateUpdate.emit();
3426
3700
  }
3427
- import_log10.log.trace("dxos.halo.identity-manager.open", import_protocols7.trace.end({
3701
+ import_log11.log.trace("dxos.halo.identity-manager.open", import_protocols9.trace.end({
3428
3702
  id: traceId
3429
3703
  }), {
3430
- F: __dxlog_file12,
3704
+ F: __dxlog_file13,
3431
3705
  L: 131,
3432
3706
  S: this,
3433
3707
  C: (f, a) => f(...a)
3434
3708
  });
3435
3709
  }
3436
3710
  async close() {
3437
- await this._identity?.close(new import_context8.Context(void 0, {
3438
- F: __dxlog_file12,
3711
+ await this._identity?.close(new import_context9.Context(void 0, {
3712
+ F: __dxlog_file13,
3439
3713
  L: 135
3440
3714
  }));
3441
3715
  }
3442
3716
  async createIdentity({ displayName, deviceProfile } = {}) {
3443
- (0, import_invariant9.invariant)(!this._identity, "Identity already exists.", {
3444
- F: __dxlog_file12,
3717
+ (0, import_invariant11.invariant)(!this._identity, "Identity already exists.", {
3718
+ F: __dxlog_file13,
3445
3719
  L: 140,
3446
3720
  S: this,
3447
3721
  A: [
@@ -3449,8 +3723,8 @@ var IdentityManager = class {
3449
3723
  "'Identity already exists.'"
3450
3724
  ]
3451
3725
  });
3452
- (0, import_log10.log)("creating identity...", void 0, {
3453
- F: __dxlog_file12,
3726
+ (0, import_log11.log)("creating identity...", void 0, {
3727
+ F: __dxlog_file13,
3454
3728
  L: 141,
3455
3729
  S: this,
3456
3730
  C: (f, a) => f(...a)
@@ -3467,14 +3741,14 @@ var IdentityManager = class {
3467
3741
  }
3468
3742
  };
3469
3743
  const identity = await this._constructIdentity(identityRecord);
3470
- await identity.open(new import_context8.Context(void 0, {
3471
- F: __dxlog_file12,
3744
+ await identity.open(new import_context9.Context(void 0, {
3745
+ F: __dxlog_file13,
3472
3746
  L: 156
3473
3747
  }));
3474
3748
  {
3475
3749
  const generator = new import_credentials14.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
3476
- (0, import_invariant9.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
3477
- F: __dxlog_file12,
3750
+ (0, import_invariant11.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
3751
+ F: __dxlog_file13,
3478
3752
  L: 160,
3479
3753
  S: this,
3480
3754
  A: [
@@ -3482,8 +3756,8 @@ var IdentityManager = class {
3482
3756
  "'Genesis feed key is required.'"
3483
3757
  ]
3484
3758
  });
3485
- (0, import_invariant9.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
3486
- F: __dxlog_file12,
3759
+ (0, import_invariant11.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
3760
+ F: __dxlog_file13,
3487
3761
  L: 161,
3488
3762
  S: this,
3489
3763
  A: [
@@ -3518,22 +3792,22 @@ var IdentityManager = class {
3518
3792
  await this._metadataStore.setIdentityRecord(identityRecord);
3519
3793
  this._identity = identity;
3520
3794
  await this._identity.ready();
3521
- import_log10.log.trace("dxos.halo.identity", {
3795
+ import_log11.log.trace("dxos.halo.identity", {
3522
3796
  identityKey: identityRecord.identityKey,
3523
3797
  displayName: this._identity.profileDocument?.displayName
3524
3798
  }, {
3525
- F: __dxlog_file12,
3799
+ F: __dxlog_file13,
3526
3800
  L: 199,
3527
3801
  S: this,
3528
3802
  C: (f, a) => f(...a)
3529
3803
  });
3530
3804
  this.stateUpdate.emit();
3531
- (0, import_log10.log)("created identity", {
3805
+ (0, import_log11.log)("created identity", {
3532
3806
  identityKey: identity.identityKey,
3533
3807
  deviceKey: identity.deviceKey,
3534
3808
  profile: identity.profileDocument
3535
3809
  }, {
3536
- F: __dxlog_file12,
3810
+ F: __dxlog_file13,
3537
3811
  L: 205,
3538
3812
  S: this,
3539
3813
  C: (f, a) => f(...a)
@@ -3567,16 +3841,16 @@ var IdentityManager = class {
3567
3841
  * Prepare an identity object as the first step of acceptIdentity flow.
3568
3842
  */
3569
3843
  async prepareIdentity(params) {
3570
- (0, import_log10.log)("accepting identity", {
3844
+ (0, import_log11.log)("accepting identity", {
3571
3845
  params
3572
3846
  }, {
3573
- F: __dxlog_file12,
3847
+ F: __dxlog_file13,
3574
3848
  L: 244,
3575
3849
  S: this,
3576
3850
  C: (f, a) => f(...a)
3577
3851
  });
3578
- (0, import_invariant9.invariant)(!this._identity, "Identity already exists.", {
3579
- F: __dxlog_file12,
3852
+ (0, import_invariant11.invariant)(!this._identity, "Identity already exists.", {
3853
+ F: __dxlog_file13,
3580
3854
  L: 245,
3581
3855
  S: this,
3582
3856
  A: [
@@ -3596,8 +3870,8 @@ var IdentityManager = class {
3596
3870
  }
3597
3871
  };
3598
3872
  const identity = await this._constructIdentity(identityRecord);
3599
- await identity.open(new import_context8.Context(void 0, {
3600
- F: __dxlog_file12,
3873
+ await identity.open(new import_context9.Context(void 0, {
3874
+ F: __dxlog_file13,
3601
3875
  L: 259
3602
3876
  }));
3603
3877
  return {
@@ -3612,11 +3886,11 @@ var IdentityManager = class {
3612
3886
  this._identity = identity;
3613
3887
  await this._identity.ready();
3614
3888
  await this._metadataStore.setIdentityRecord(identityRecord);
3615
- import_log10.log.trace("dxos.halo.identity", {
3889
+ import_log11.log.trace("dxos.halo.identity", {
3616
3890
  identityKey: this._identity.identityKey,
3617
3891
  displayName: this._identity.profileDocument?.displayName
3618
3892
  }, {
3619
- F: __dxlog_file12,
3893
+ F: __dxlog_file13,
3620
3894
  L: 273,
3621
3895
  S: this,
3622
3896
  C: (f, a) => f(...a)
@@ -3626,11 +3900,11 @@ var IdentityManager = class {
3626
3900
  ...profile
3627
3901
  });
3628
3902
  this.stateUpdate.emit();
3629
- (0, import_log10.log)("accepted identity", {
3903
+ (0, import_log11.log)("accepted identity", {
3630
3904
  identityKey: identity.identityKey,
3631
3905
  deviceKey: identity.deviceKey
3632
3906
  }, {
3633
- F: __dxlog_file12,
3907
+ F: __dxlog_file13,
3634
3908
  L: 284,
3635
3909
  S: this,
3636
3910
  C: (f, a) => f(...a)
@@ -3640,8 +3914,8 @@ var IdentityManager = class {
3640
3914
  * Update the profile document of an existing identity.
3641
3915
  */
3642
3916
  async updateProfile(profile) {
3643
- (0, import_invariant9.invariant)(this._identity, "Identity not initialized.", {
3644
- F: __dxlog_file12,
3917
+ (0, import_invariant11.invariant)(this._identity, "Identity not initialized.", {
3918
+ F: __dxlog_file13,
3645
3919
  L: 291,
3646
3920
  S: this,
3647
3921
  A: [
@@ -3671,8 +3945,8 @@ var IdentityManager = class {
3671
3945
  return profile;
3672
3946
  }
3673
3947
  async updateDeviceProfile(profile) {
3674
- (0, import_invariant9.invariant)(this._identity, "Identity not initialized.", {
3675
- F: __dxlog_file12,
3948
+ (0, import_invariant11.invariant)(this._identity, "Identity not initialized.", {
3949
+ F: __dxlog_file13,
3676
3950
  L: 308,
3677
3951
  S: this,
3678
3952
  A: [
@@ -3707,8 +3981,8 @@ var IdentityManager = class {
3707
3981
  };
3708
3982
  }
3709
3983
  async _constructIdentity(identityRecord) {
3710
- (0, import_invariant9.invariant)(!this._identity, void 0, {
3711
- F: __dxlog_file12,
3984
+ (0, import_invariant11.invariant)(!this._identity, void 0, {
3985
+ F: __dxlog_file13,
3712
3986
  L: 334,
3713
3987
  S: this,
3714
3988
  A: [
@@ -3716,10 +3990,10 @@ var IdentityManager = class {
3716
3990
  ""
3717
3991
  ]
3718
3992
  });
3719
- (0, import_log10.log)("constructing identity", {
3993
+ (0, import_log11.log)("constructing identity", {
3720
3994
  identityRecord
3721
3995
  }, {
3722
- F: __dxlog_file12,
3996
+ F: __dxlog_file13,
3723
3997
  L: 335,
3724
3998
  S: this,
3725
3999
  C: (f, a) => f(...a)
@@ -3733,8 +4007,8 @@ var IdentityManager = class {
3733
4007
  identityKey: identityRecord.deviceKey,
3734
4008
  gossip
3735
4009
  });
3736
- (0, import_invariant9.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
3737
- F: __dxlog_file12,
4010
+ (0, import_invariant11.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
4011
+ F: __dxlog_file13,
3738
4012
  L: 348,
3739
4013
  S: this,
3740
4014
  A: [
@@ -3745,8 +4019,8 @@ var IdentityManager = class {
3745
4019
  const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
3746
4020
  writable: true
3747
4021
  });
3748
- (0, import_invariant9.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
3749
- F: __dxlog_file12,
4022
+ (0, import_invariant11.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
4023
+ F: __dxlog_file13,
3750
4024
  L: 352,
3751
4025
  S: this,
3752
4026
  A: [
@@ -3782,10 +4056,10 @@ var IdentityManager = class {
3782
4056
  edgeConnection: this._edgeConnection,
3783
4057
  edgeFeatures: this._edgeFeatures
3784
4058
  });
3785
- (0, import_log10.log)("done", {
4059
+ (0, import_log11.log)("done", {
3786
4060
  identityKey: identityRecord.identityKey
3787
4061
  }, {
3788
- F: __dxlog_file12,
4062
+ F: __dxlog_file13,
3789
4063
  L: 383,
3790
4064
  S: this,
3791
4065
  C: (f, a) => f(...a)
@@ -3809,8 +4083,8 @@ var IdentityManager = class {
3809
4083
  }));
3810
4084
  },
3811
4085
  onAuthFailure: () => {
3812
- import_log10.log.warn("auth failure", void 0, {
3813
- F: __dxlog_file12,
4086
+ import_log11.log.warn("auth failure", void 0, {
4087
+ F: __dxlog_file13,
3814
4088
  L: 408,
3815
4089
  S: this,
3816
4090
  C: (f, a) => f(...a)
@@ -3832,9 +4106,9 @@ _ts_decorate5([
3832
4106
  IdentityManager = _ts_decorate5([
3833
4107
  import_tracing7.trace.resource()
3834
4108
  ], IdentityManager);
3835
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
4109
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
3836
4110
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
3837
- var IdentityServiceImpl = class extends import_context9.Resource {
4111
+ var IdentityServiceImpl = class extends import_context10.Resource {
3838
4112
  constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
3839
4113
  super();
3840
4114
  this._identityManager = _identityManager;
@@ -3862,8 +4136,8 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3862
4136
  async _createDefaultSpace(dataSpaceManager) {
3863
4137
  const space = await dataSpaceManager.createDefaultSpace();
3864
4138
  const identity = this._identityManager.identity;
3865
- (0, import_invariant10.invariant)(identity, void 0, {
3866
- F: __dxlog_file13,
4139
+ (0, import_invariant12.invariant)(identity, void 0, {
4140
+ F: __dxlog_file14,
3867
4141
  L: 61,
3868
4142
  S: this,
3869
4143
  A: [
@@ -3894,8 +4168,8 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3894
4168
  };
3895
4169
  }
3896
4170
  async updateProfile(profile) {
3897
- (0, import_invariant10.invariant)(this._identityManager.identity, "Identity not initialized.", {
3898
- F: __dxlog_file13,
4171
+ (0, import_invariant12.invariant)(this._identityManager.identity, "Identity not initialized.", {
4172
+ F: __dxlog_file14,
3899
4173
  L: 88,
3900
4174
  S: this,
3901
4175
  A: [
@@ -3920,6 +4194,10 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3920
4194
  });
3921
4195
  } else if (request.external) {
3922
4196
  await this._recoveryManager.recoverIdentityWithExternalSignature(request.external);
4197
+ } else if (request.token) {
4198
+ await this._recoveryManager.recoverIdentityWithToken({
4199
+ token: request.token
4200
+ });
3923
4201
  } else {
3924
4202
  throw new Error("Invalid request.");
3925
4203
  }
@@ -3927,9 +4205,9 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3927
4205
  }
3928
4206
  // TODO(burdon): Rename createPresentation?
3929
4207
  async signPresentation({ presentation, nonce }) {
3930
- (0, import_invariant10.invariant)(this._identityManager.identity, "Identity not initialized.", {
3931
- F: __dxlog_file13,
3932
- L: 116,
4208
+ (0, import_invariant12.invariant)(this._identityManager.identity, "Identity not initialized.", {
4209
+ F: __dxlog_file14,
4210
+ L: 118,
3933
4211
  S: this,
3934
4212
  A: [
3935
4213
  "this._identityManager.identity",
@@ -3946,9 +4224,9 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3946
4224
  }
3947
4225
  async createAuthCredential() {
3948
4226
  const identity = this._identityManager.identity;
3949
- (0, import_invariant10.invariant)(identity, "Identity not initialized.", {
3950
- F: __dxlog_file13,
3951
- L: 130,
4227
+ (0, import_invariant12.invariant)(identity, "Identity not initialized.", {
4228
+ F: __dxlog_file14,
4229
+ L: 132,
3952
4230
  S: this,
3953
4231
  A: [
3954
4232
  "identity",
@@ -3982,11 +4260,11 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3982
4260
  }
3983
4261
  if (await dataSpaceManager.isDefaultSpace(space)) {
3984
4262
  if (foundDefaultSpace) {
3985
- import_log11.log.warn("Multiple default spaces found. Using the first one.", {
4263
+ import_log12.log.warn("Multiple default spaces found. Using the first one.", {
3986
4264
  duplicate: space.id
3987
4265
  }, {
3988
- F: __dxlog_file13,
3989
- L: 164,
4266
+ F: __dxlog_file14,
4267
+ L: 166,
3990
4268
  S: this,
3991
4269
  C: (f, a) => f(...a)
3992
4270
  });
@@ -3998,9 +4276,9 @@ var IdentityServiceImpl = class extends import_context9.Resource {
3998
4276
  recordedDefaultSpaceTrigger.wake();
3999
4277
  }
4000
4278
  }, (err) => {
4001
- import_log11.log.catch(err, void 0, {
4002
- F: __dxlog_file13,
4003
- L: 175,
4279
+ import_log12.log.catch(err, void 0, {
4280
+ F: __dxlog_file14,
4281
+ L: 177,
4004
4282
  S: this,
4005
4283
  C: (f, a) => f(...a)
4006
4284
  });
@@ -4021,7 +4299,7 @@ function _ts_decorate6(decorators, target, key, desc) {
4021
4299
  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;
4022
4300
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4023
4301
  }
4024
- function _using_ctx2() {
4302
+ function _using_ctx3() {
4025
4303
  var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
4026
4304
  var err = new Error();
4027
4305
  err.name = "SuppressedError";
@@ -4083,12 +4361,12 @@ function _using_ctx2() {
4083
4361
  }
4084
4362
  };
4085
4363
  }
4086
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4364
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4087
4365
  var DataSpace = class {
4088
4366
  constructor(params) {
4089
4367
  this._ctx = new import_context4.Context(void 0, {
4090
- F: __dxlog_file14,
4091
- L: 96
4368
+ F: __dxlog_file15,
4369
+ L: 97
4092
4370
  });
4093
4371
  this._cache = void 0;
4094
4372
  this._edgeFeedReplicator = void 0;
@@ -4136,8 +4414,8 @@ var DataSpace = class {
4136
4414
  (0, import_log4.log)("new state", {
4137
4415
  state: import_services4.SpaceState[this._state]
4138
4416
  }, {
4139
- F: __dxlog_file14,
4140
- L: 172,
4417
+ F: __dxlog_file15,
4418
+ L: 173,
4141
4419
  S: this,
4142
4420
  C: (f, a) => f(...a)
4143
4421
  });
@@ -4195,8 +4473,8 @@ var DataSpace = class {
4195
4473
  this.inner.protocol.feedAdded.append(this._onFeedAdded);
4196
4474
  }
4197
4475
  await this._inner.open(new import_context4.Context(void 0, {
4198
- F: __dxlog_file14,
4199
- L: 246
4476
+ F: __dxlog_file15,
4477
+ L: 247
4200
4478
  }));
4201
4479
  await this._inner.startProtocol();
4202
4480
  await this._edgeFeedReplicator?.open();
@@ -4204,8 +4482,8 @@ var DataSpace = class {
4204
4482
  (0, import_log4.log)("new state", {
4205
4483
  state: import_services4.SpaceState[this._state]
4206
4484
  }, {
4207
- F: __dxlog_file14,
4208
- L: 252,
4485
+ F: __dxlog_file15,
4486
+ L: 253,
4209
4487
  S: this,
4210
4488
  C: (f, a) => f(...a)
4211
4489
  });
@@ -4224,15 +4502,15 @@ var DataSpace = class {
4224
4502
  (0, import_log4.log)("new state", {
4225
4503
  state: import_services4.SpaceState[this._state]
4226
4504
  }, {
4227
- F: __dxlog_file14,
4228
- L: 271,
4505
+ F: __dxlog_file15,
4506
+ L: 272,
4229
4507
  S: this,
4230
4508
  C: (f, a) => f(...a)
4231
4509
  });
4232
4510
  await this._ctx.dispose();
4233
4511
  this._ctx = new import_context4.Context(void 0, {
4234
- F: __dxlog_file14,
4235
- L: 273
4512
+ F: __dxlog_file15,
4513
+ L: 274
4236
4514
  });
4237
4515
  if (this._edgeFeedReplicator) {
4238
4516
  this.inner.protocol.feedAdded.remove(this._onFeedAdded);
@@ -4264,16 +4542,16 @@ var DataSpace = class {
4264
4542
  } catch (err) {
4265
4543
  if (err instanceof import_protocols3.CancelledError || err instanceof import_context4.ContextDisposedError) {
4266
4544
  (0, import_log4.log)("data pipeline initialization cancelled", err, {
4267
- F: __dxlog_file14,
4268
- L: 311,
4545
+ F: __dxlog_file15,
4546
+ L: 312,
4269
4547
  S: this,
4270
4548
  C: (f, a) => f(...a)
4271
4549
  });
4272
4550
  return;
4273
4551
  }
4274
4552
  import_log4.log.error("Error initializing data pipeline", err, {
4275
- F: __dxlog_file14,
4276
- L: 315,
4553
+ F: __dxlog_file15,
4554
+ L: 316,
4277
4555
  S: this,
4278
4556
  C: (f, a) => f(...a)
4279
4557
  });
@@ -4281,8 +4559,8 @@ var DataSpace = class {
4281
4559
  (0, import_log4.log)("new state", {
4282
4560
  state: import_services4.SpaceState[this._state]
4283
4561
  }, {
4284
- F: __dxlog_file14,
4285
- L: 317,
4562
+ F: __dxlog_file15,
4563
+ L: 318,
4286
4564
  S: this,
4287
4565
  C: (f, a) => f(...a)
4288
4566
  });
@@ -4301,14 +4579,14 @@ var DataSpace = class {
4301
4579
  (0, import_log4.log)("new state", {
4302
4580
  state: import_services4.SpaceState[this._state]
4303
4581
  }, {
4304
- F: __dxlog_file14,
4305
- L: 333,
4582
+ F: __dxlog_file15,
4583
+ L: 334,
4306
4584
  S: this,
4307
4585
  C: (f, a) => f(...a)
4308
4586
  });
4309
4587
  (0, import_log4.log)("initializing control pipeline", void 0, {
4310
- F: __dxlog_file14,
4311
- L: 335,
4588
+ F: __dxlog_file15,
4589
+ L: 336,
4312
4590
  S: this,
4313
4591
  C: (f, a) => f(...a)
4314
4592
  });
@@ -4316,34 +4594,61 @@ var DataSpace = class {
4316
4594
  await (0, import_async7.sleep)(1);
4317
4595
  const ready = this.stateUpdate.waitForCondition(() => this._state === import_services4.SpaceState.SPACE_READY);
4318
4596
  (0, import_log4.log)("initializing automerge root", void 0, {
4319
- F: __dxlog_file14,
4320
- L: 343,
4597
+ F: __dxlog_file15,
4598
+ L: 344,
4321
4599
  S: this,
4322
4600
  C: (f, a) => f(...a)
4323
4601
  });
4324
4602
  this._automergeSpaceState.startProcessingRootDocs();
4325
4603
  (0, import_log4.log)("waiting for space to be ready", void 0, {
4326
- F: __dxlog_file14,
4327
- L: 347,
4604
+ F: __dxlog_file15,
4605
+ L: 348,
4328
4606
  S: this,
4329
4607
  C: (f, a) => f(...a)
4330
4608
  });
4331
4609
  await ready;
4332
4610
  (0, import_log4.log)("space is ready", void 0, {
4333
- F: __dxlog_file14,
4334
- L: 349,
4611
+ F: __dxlog_file15,
4612
+ L: 350,
4335
4613
  S: this,
4336
4614
  C: (f, a) => f(...a)
4337
4615
  });
4338
4616
  }
4617
+ async *getAllDocuments() {
4618
+ (0, import_invariant3.invariant)(this._databaseRoot, "Space is not ready", {
4619
+ F: __dxlog_file15,
4620
+ L: 354,
4621
+ S: this,
4622
+ A: [
4623
+ "this._databaseRoot",
4624
+ "'Space is not ready'"
4625
+ ]
4626
+ });
4627
+ const doc = this._databaseRoot.docSync() ?? (0, import_invariant3.failedInvariant)();
4628
+ const root = (0, import_automerge.save)(doc);
4629
+ yield [
4630
+ this._databaseRoot.documentId,
4631
+ root
4632
+ ];
4633
+ for (const documentUrl of this._databaseRoot.getAllLinkedDocuments()) {
4634
+ const data = await this._echoHost.exportDoc(import_context4.Context.default(void 0, {
4635
+ F: __dxlog_file15,
4636
+ L: 360
4637
+ }), documentUrl);
4638
+ yield [
4639
+ documentUrl.replace(/^automerge:/, ""),
4640
+ data
4641
+ ];
4642
+ }
4643
+ }
4339
4644
  async _enterReadyState() {
4340
4645
  await this._callbacks.beforeReady?.();
4341
4646
  this._state = import_services4.SpaceState.SPACE_READY;
4342
4647
  (0, import_log4.log)("new state", {
4343
4648
  state: import_services4.SpaceState[this._state]
4344
4649
  }, {
4345
- F: __dxlog_file14,
4346
- L: 356,
4650
+ F: __dxlog_file15,
4651
+ L: 369,
4347
4652
  S: this,
4348
4653
  C: (f, a) => f(...a)
4349
4654
  });
@@ -4359,8 +4664,8 @@ var DataSpace = class {
4359
4664
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
4360
4665
  await this._createWritableFeeds();
4361
4666
  (0, import_log4.log)("writable feeds created", void 0, {
4362
- F: __dxlog_file14,
4363
- L: 373,
4667
+ F: __dxlog_file15,
4668
+ L: 386,
4364
4669
  S: this,
4365
4670
  C: (f, a) => f(...a)
4366
4671
  });
@@ -4413,8 +4718,8 @@ var DataSpace = class {
4413
4718
  (0, import_log4.log)("will notarize credentials for feed admission", {
4414
4719
  count: credentials.length
4415
4720
  }, {
4416
- F: __dxlog_file14,
4417
- L: 431,
4721
+ F: __dxlog_file15,
4722
+ L: 444,
4418
4723
  S: this,
4419
4724
  C: (f, a) => f(...a)
4420
4725
  });
@@ -4424,15 +4729,15 @@ var DataSpace = class {
4424
4729
  timeout: 0
4425
4730
  });
4426
4731
  (0, import_log4.log)("credentials notarized", void 0, {
4427
- F: __dxlog_file14,
4428
- L: 435,
4732
+ F: __dxlog_file15,
4733
+ L: 448,
4429
4734
  S: this,
4430
4735
  C: (f, a) => f(...a)
4431
4736
  });
4432
4737
  } catch (err) {
4433
4738
  import_log4.log.error("error notarizing credentials for feed admission", err, {
4434
- F: __dxlog_file14,
4435
- L: 437,
4739
+ F: __dxlog_file15,
4740
+ L: 450,
4436
4741
  S: this,
4437
4742
  C: (f, a) => f(...a)
4438
4743
  });
@@ -4446,8 +4751,8 @@ var DataSpace = class {
4446
4751
  space: this.key,
4447
4752
  rootUrl
4448
4753
  }, {
4449
- F: __dxlog_file14,
4450
- L: 447,
4754
+ F: __dxlog_file15,
4755
+ L: 460,
4451
4756
  S: this,
4452
4757
  C: (f, a) => f(...a)
4453
4758
  });
@@ -4455,7 +4760,7 @@ var DataSpace = class {
4455
4760
  queueMicrotask(async () => {
4456
4761
  try {
4457
4762
  try {
4458
- var _usingCtx = _using_ctx2();
4763
+ var _usingCtx = _using_ctx3();
4459
4764
  await (0, import_debug.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
4460
4765
  await (0, import_context4.cancelWithContext)(this._ctx, handle.whenReady());
4461
4766
  });
@@ -4498,8 +4803,8 @@ var DataSpace = class {
4498
4803
  rootUrl,
4499
4804
  err
4500
4805
  }, {
4501
- F: __dxlog_file14,
4502
- L: 490,
4806
+ F: __dxlog_file15,
4807
+ L: 503,
4503
4808
  S: this,
4504
4809
  C: (f, a) => f(...a)
4505
4810
  });
@@ -4588,8 +4893,8 @@ var DataSpace = class {
4588
4893
  (0, import_log4.log)("new state", {
4589
4894
  state: import_services4.SpaceState[this._state]
4590
4895
  }, {
4591
- F: __dxlog_file14,
4592
- L: 572,
4896
+ F: __dxlog_file15,
4897
+ L: 585,
4593
4898
  S: this,
4594
4899
  C: (f, a) => f(...a)
4595
4900
  });
@@ -4647,7 +4952,7 @@ DataSpace = _ts_decorate6([
4647
4952
  (0, import_async7.trackLeaks)("open", "close"),
4648
4953
  import_tracing3.trace.resource()
4649
4954
  ], DataSpace);
4650
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
4955
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
4651
4956
  var DeviceInvitationProtocol = class {
4652
4957
  constructor(_keyring, _getIdentity, _acceptIdentity) {
4653
4958
  this._keyring = _keyring;
@@ -4674,8 +4979,8 @@ var DeviceInvitationProtocol = class {
4674
4979
  throw new Error("delegation not supported");
4675
4980
  }
4676
4981
  async admit(_, request) {
4677
- (0, import_invariant11.invariant)(request.device, void 0, {
4678
- F: __dxlog_file15,
4982
+ (0, import_invariant13.invariant)(request.device, void 0, {
4983
+ F: __dxlog_file16,
4679
4984
  L: 53,
4680
4985
  S: this,
4681
4986
  A: [
@@ -4685,8 +4990,8 @@ var DeviceInvitationProtocol = class {
4685
4990
  });
4686
4991
  const identity = this._getIdentity();
4687
4992
  const credential = await identity.admitDevice(request.device);
4688
- (0, import_invariant11.invariant)((0, import_credentials17.getCredentialAssertion)(credential)["@type"] === "dxos.halo.credentials.AuthorizedDevice", void 0, {
4689
- F: __dxlog_file15,
4993
+ (0, import_invariant13.invariant)((0, import_credentials17.getCredentialAssertion)(credential)["@type"] === "dxos.halo.credentials.AuthorizedDevice", void 0, {
4994
+ F: __dxlog_file16,
4690
4995
  L: 56,
4691
4996
  S: this,
4692
4997
  A: [
@@ -4708,7 +5013,7 @@ var DeviceInvitationProtocol = class {
4708
5013
  try {
4709
5014
  const identity = this._getIdentity();
4710
5015
  if (identity) {
4711
- return new import_protocols8.AlreadyJoinedError("Currently only one identity per client is supported.");
5016
+ return new import_protocols10.AlreadyJoinedError("Currently only one identity per client is supported.");
4712
5017
  }
4713
5018
  } catch {
4714
5019
  }
@@ -4730,8 +5035,8 @@ var DeviceInvitationProtocol = class {
4730
5035
  };
4731
5036
  }
4732
5037
  async accept(response, request) {
4733
- (0, import_invariant11.invariant)(response.device, void 0, {
4734
- F: __dxlog_file15,
5038
+ (0, import_invariant13.invariant)(response.device, void 0, {
5039
+ F: __dxlog_file16,
4735
5040
  L: 100,
4736
5041
  S: this,
4737
5042
  A: [
@@ -4740,8 +5045,8 @@ var DeviceInvitationProtocol = class {
4740
5045
  ]
4741
5046
  });
4742
5047
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
4743
- (0, import_invariant11.invariant)(request.device, void 0, {
4744
- F: __dxlog_file15,
5048
+ (0, import_invariant13.invariant)(request.device, void 0, {
5049
+ F: __dxlog_file16,
4745
5050
  L: 103,
4746
5051
  S: this,
4747
5052
  A: [
@@ -4777,17 +5082,17 @@ var computeExpirationTime = (invitation) => {
4777
5082
  };
4778
5083
  var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
4779
5084
  let guard;
4780
- return (0, import_context11.cancelWithContext)(ctx, (async () => {
5085
+ return (0, import_context12.cancelWithContext)(ctx, (async () => {
4781
5086
  guard = await mutex.acquire();
4782
5087
  if (ctx.disposed) {
4783
5088
  guard.release();
4784
5089
  guard = void 0;
4785
- throw new import_context11.ContextDisposedError();
5090
+ throw new import_context12.ContextDisposedError();
4786
5091
  }
4787
5092
  return guard;
4788
5093
  })());
4789
5094
  };
4790
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
5095
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
4791
5096
  var MAX_RETRIES_PER_INVITATION = 5;
4792
5097
  var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
4793
5098
  var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
@@ -4800,8 +5105,8 @@ var EdgeInvitationHandler = class {
4800
5105
  }
4801
5106
  handle(ctx, guardedState, protocol, deviceProfile) {
4802
5107
  if (!this._client) {
4803
- (0, import_log13.log)("edge disabled", void 0, {
4804
- F: __dxlog_file16,
5108
+ (0, import_log14.log)("edge disabled", void 0, {
5109
+ F: __dxlog_file17,
4805
5110
  L: 66,
4806
5111
  S: this,
4807
5112
  C: (f, a) => f(...a)
@@ -4810,12 +5115,12 @@ var EdgeInvitationHandler = class {
4810
5115
  }
4811
5116
  const invitation = guardedState.current;
4812
5117
  const spaceId = invitation.spaceId;
4813
- const canBeHandledByEdge = invitation.authMethod !== import_services12.Invitation.AuthMethod.SHARED_SECRET && invitation.type === import_services12.Invitation.Type.DELEGATED && invitation.kind === import_services12.Invitation.Kind.SPACE && spaceId != null && import_keys11.SpaceId.isValid(spaceId);
5118
+ const canBeHandledByEdge = invitation.authMethod !== import_services12.Invitation.AuthMethod.SHARED_SECRET && invitation.type === import_services12.Invitation.Type.DELEGATED && invitation.kind === import_services12.Invitation.Kind.SPACE && spaceId != null && import_keys12.SpaceId.isValid(spaceId);
4814
5119
  if (!canBeHandledByEdge) {
4815
- (0, import_log13.log)("invitation could not be handled by edge", {
5120
+ (0, import_log14.log)("invitation could not be handled by edge", {
4816
5121
  invitation
4817
5122
  }, {
4818
- F: __dxlog_file16,
5123
+ F: __dxlog_file17,
4819
5124
  L: 80,
4820
5125
  S: this,
4821
5126
  C: (f, a) => f(...a)
@@ -4834,13 +5139,13 @@ var EdgeInvitationHandler = class {
4834
5139
  try {
4835
5140
  await this._handleSpaceInvitationFlow(ctx, guardedState, admissionRequest.space, spaceId);
4836
5141
  } catch (error) {
4837
- if (error instanceof import_protocols10.EdgeCallFailedError) {
4838
- import_log13.log.info("join space with edge unsuccessful", {
5142
+ if (error instanceof import_protocols12.EdgeCallFailedError) {
5143
+ import_log14.log.info("join space with edge unsuccessful", {
4839
5144
  reason: error.message,
4840
5145
  retryable: error.isRetryable,
4841
5146
  after: error.retryAfterMs ?? this._calculateNextRetryMs()
4842
5147
  }, {
4843
- F: __dxlog_file16,
5148
+ F: __dxlog_file17,
4844
5149
  L: 98,
4845
5150
  S: this,
4846
5151
  C: (f, a) => f(...a)
@@ -4849,10 +5154,10 @@ var EdgeInvitationHandler = class {
4849
5154
  (0, import_async16.scheduleTask)(ctx, tryHandleInvitation, error.retryAfterMs ?? this._calculateNextRetryMs());
4850
5155
  }
4851
5156
  } else if (requestCount < MAX_RETRIES_PER_INVITATION) {
4852
- import_log13.log.info("failed to handle invitation with edge", {
5157
+ import_log14.log.info("failed to handle invitation with edge", {
4853
5158
  error
4854
5159
  }, {
4855
- F: __dxlog_file16,
5160
+ F: __dxlog_file17,
4856
5161
  L: 107,
4857
5162
  S: this,
4858
5163
  C: (f, a) => f(...a)
@@ -4866,15 +5171,15 @@ var EdgeInvitationHandler = class {
4866
5171
  }
4867
5172
  async _handleSpaceInvitationFlow(ctx, guardedState, admissionRequest, spaceId) {
4868
5173
  try {
4869
- (0, import_log13.log)("edge invitation flow", void 0, {
4870
- F: __dxlog_file16,
5174
+ (0, import_log14.log)("edge invitation flow", void 0, {
5175
+ F: __dxlog_file17,
4871
5176
  L: 123,
4872
5177
  S: this,
4873
5178
  C: (f, a) => f(...a)
4874
5179
  });
4875
5180
  this._flowLock = await tryAcquireBeforeContextDisposed(ctx, guardedState.mutex);
4876
- import_log13.log.verbose("edge invitation flow acquired the lock", void 0, {
4877
- F: __dxlog_file16,
5181
+ import_log14.log.verbose("edge invitation flow acquired the lock", void 0, {
5182
+ F: __dxlog_file17,
4878
5183
  L: 125,
4879
5184
  S: this,
4880
5185
  C: (f, a) => f(...a)
@@ -4906,8 +5211,8 @@ var EdgeInvitationHandler = class {
4906
5211
  };
4907
5212
  }
4908
5213
  async _joinSpaceByInvitation(guardedState, spaceId, request) {
4909
- (0, import_invariant13.invariant)(this._client, void 0, {
4910
- F: __dxlog_file16,
5214
+ (0, import_invariant15.invariant)(this._client, void 0, {
5215
+ F: __dxlog_file17,
4911
5216
  L: 160,
4912
5217
  S: this,
4913
5218
  A: [
@@ -4918,7 +5223,7 @@ var EdgeInvitationHandler = class {
4918
5223
  try {
4919
5224
  return await this._client.joinSpaceByInvitation(spaceId, request);
4920
5225
  } catch (error) {
4921
- if (error instanceof import_protocols10.EdgeAuthChallengeError) {
5226
+ if (error instanceof import_protocols12.EdgeAuthChallengeError) {
4922
5227
  const publicKey = guardedState.current.guestKeypair?.publicKey;
4923
5228
  const privateKey = guardedState.current.guestKeypair?.privateKey;
4924
5229
  if (!privateKey || !publicKey) {
@@ -4941,7 +5246,7 @@ var EdgeInvitationHandler = class {
4941
5246
  return this._retryInterval + Math.random() * this._retryJitter;
4942
5247
  }
4943
5248
  };
4944
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
5249
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
4945
5250
  var OPTIONS_TIMEOUT = 1e4;
4946
5251
  var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
4947
5252
  constructor(_invitationFlowMutex, _callbacks) {
@@ -4955,8 +5260,8 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
4955
5260
  });
4956
5261
  this._invitationFlowMutex = _invitationFlowMutex;
4957
5262
  this._callbacks = _callbacks;
4958
- this._ctx = new import_context12.Context(void 0, {
4959
- F: __dxlog_file17,
5263
+ this._ctx = new import_context13.Context(void 0, {
5264
+ F: __dxlog_file18,
4960
5265
  L: 38
4961
5266
  });
4962
5267
  this._remoteOptionsTrigger = new import_async17.Trigger();
@@ -4969,8 +5274,8 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
4969
5274
  return {
4970
5275
  InvitationHostService: {
4971
5276
  options: async (options) => {
4972
- (0, import_invariant14.invariant)(!this._remoteOptions, "Remote options already set.", {
4973
- F: __dxlog_file17,
5277
+ (0, import_invariant16.invariant)(!this._remoteOptions, "Remote options already set.", {
5278
+ F: __dxlog_file18,
4974
5279
  L: 68,
4975
5280
  S: this,
4976
5281
  A: [
@@ -4996,39 +5301,39 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
4996
5301
  async onOpen(context) {
4997
5302
  await super.onOpen(context);
4998
5303
  try {
4999
- import_log14.log.verbose("guest acquire lock", void 0, {
5000
- F: __dxlog_file17,
5304
+ import_log15.log.verbose("guest acquire lock", void 0, {
5305
+ F: __dxlog_file18,
5001
5306
  L: 89,
5002
5307
  S: this,
5003
5308
  C: (f, a) => f(...a)
5004
5309
  });
5005
5310
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
5006
- import_log14.log.verbose("guest lock acquired", void 0, {
5007
- F: __dxlog_file17,
5311
+ import_log15.log.verbose("guest lock acquired", void 0, {
5312
+ F: __dxlog_file18,
5008
5313
  L: 91,
5009
5314
  S: this,
5010
5315
  C: (f, a) => f(...a)
5011
5316
  });
5012
- await (0, import_context12.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
5317
+ await (0, import_context13.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
5013
5318
  role: import_invitations3.InvitationOptions.Role.GUEST
5014
5319
  }));
5015
- import_log14.log.verbose("options sent", void 0, {
5016
- F: __dxlog_file17,
5320
+ import_log15.log.verbose("options sent", void 0, {
5321
+ F: __dxlog_file18,
5017
5322
  L: 96,
5018
5323
  S: this,
5019
5324
  C: (f, a) => f(...a)
5020
5325
  });
5021
- await (0, import_context12.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
5326
+ await (0, import_context13.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
5022
5327
  timeout: OPTIONS_TIMEOUT
5023
5328
  }));
5024
- import_log14.log.verbose("options received", void 0, {
5025
- F: __dxlog_file17,
5329
+ import_log15.log.verbose("options received", void 0, {
5330
+ F: __dxlog_file18,
5026
5331
  L: 98,
5027
5332
  S: this,
5028
5333
  C: (f, a) => f(...a)
5029
5334
  });
5030
5335
  if (this._remoteOptions?.role !== import_invitations3.InvitationOptions.Role.HOST) {
5031
- throw new import_protocols11.InvalidInvitationExtensionRoleError(void 0, {
5336
+ throw new import_protocols13.InvalidInvitationExtensionRoleError(void 0, {
5032
5337
  expected: import_invitations3.InvitationOptions.Role.HOST,
5033
5338
  remoteOptions: this._remoteOptions,
5034
5339
  remotePeerId: context.remotePeerId
@@ -5055,8 +5360,8 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
5055
5360
  if (this._invitationFlowLock != null) {
5056
5361
  this._invitationFlowLock.release();
5057
5362
  this._invitationFlowLock = null;
5058
- import_log14.log.verbose("invitation flow lock released", void 0, {
5059
- F: __dxlog_file17,
5363
+ import_log15.log.verbose("invitation flow lock released", void 0, {
5364
+ F: __dxlog_file18,
5060
5365
  L: 131,
5061
5366
  S: this,
5062
5367
  C: (f, a) => f(...a)
@@ -5064,7 +5369,7 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
5064
5369
  }
5065
5370
  }
5066
5371
  };
5067
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
5372
+ var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
5068
5373
  var OPTIONS_TIMEOUT2 = 1e4;
5069
5374
  var MAX_OTP_ATTEMPTS = 3;
5070
5375
  var InvitationHostExtension = class extends import_teleport3.RpcExtension {
@@ -5079,8 +5384,8 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5079
5384
  });
5080
5385
  this._invitationFlowMutex = _invitationFlowMutex;
5081
5386
  this._callbacks = _callbacks;
5082
- this._ctx = new import_context13.Context(void 0, {
5083
- F: __dxlog_file18,
5387
+ this._ctx = new import_context14.Context(void 0, {
5388
+ F: __dxlog_file19,
5084
5389
  L: 57
5085
5390
  });
5086
5391
  this._remoteOptionsTrigger = new import_async18.Trigger();
@@ -5100,8 +5405,8 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5100
5405
  // Perhaps in the future we will have more complex logic here.
5101
5406
  InvitationHostService: {
5102
5407
  options: async (options) => {
5103
- (0, import_invariant15.invariant)(!this._remoteOptions, "Remote options already set.", {
5104
- F: __dxlog_file18,
5408
+ (0, import_invariant17.invariant)(!this._remoteOptions, "Remote options already set.", {
5409
+ F: __dxlog_file19,
5105
5410
  L: 106,
5106
5411
  S: this,
5107
5412
  A: [
@@ -5114,11 +5419,11 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5114
5419
  },
5115
5420
  introduce: async (request) => {
5116
5421
  const { profile, invitationId } = request;
5117
- const traceId = import_keys12.PublicKey.random().toHex();
5118
- import_log15.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols12.trace.begin({
5422
+ const traceId = import_keys13.PublicKey.random().toHex();
5423
+ import_log16.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols14.trace.begin({
5119
5424
  id: traceId
5120
5425
  }), {
5121
- F: __dxlog_file18,
5426
+ F: __dxlog_file19,
5122
5427
  L: 114,
5123
5428
  S: this,
5124
5429
  C: (f, a) => f(...a)
@@ -5126,11 +5431,11 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5126
5431
  const invitation = this._requireActiveInvitation();
5127
5432
  this._assertInvitationState(import_services14.Invitation.State.CONNECTED);
5128
5433
  if (invitationId !== invitation?.invitationId) {
5129
- import_log15.log.warn("incorrect invitationId", {
5434
+ import_log16.log.warn("incorrect invitationId", {
5130
5435
  expected: invitation.invitationId,
5131
5436
  actual: invitationId
5132
5437
  }, {
5133
- F: __dxlog_file18,
5438
+ F: __dxlog_file19,
5134
5439
  L: 119,
5135
5440
  S: this,
5136
5441
  C: (f, a) => f(...a)
@@ -5141,10 +5446,10 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5141
5446
  authMethod: import_services14.Invitation.AuthMethod.NONE
5142
5447
  };
5143
5448
  }
5144
- import_log15.log.verbose("guest introduced themselves", {
5449
+ import_log16.log.verbose("guest introduced themselves", {
5145
5450
  guestProfile: profile
5146
5451
  }, {
5147
- F: __dxlog_file18,
5452
+ F: __dxlog_file19,
5148
5453
  L: 128,
5149
5454
  S: this,
5150
5455
  C: (f, a) => f(...a)
@@ -5152,10 +5457,10 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5152
5457
  this.guestProfile = profile;
5153
5458
  this._callbacks.onStateUpdate(import_services14.Invitation.State.READY_FOR_AUTHENTICATION);
5154
5459
  this._challenge = invitation.authMethod === import_services14.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto3.randomBytes)(32) : void 0;
5155
- import_log15.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols12.trace.end({
5460
+ import_log16.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols14.trace.end({
5156
5461
  id: traceId
5157
5462
  }), {
5158
- F: __dxlog_file18,
5463
+ F: __dxlog_file19,
5159
5464
  L: 134,
5160
5465
  S: this,
5161
5466
  C: (f, a) => f(...a)
@@ -5166,20 +5471,20 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5166
5471
  };
5167
5472
  },
5168
5473
  authenticate: async ({ authCode: code, signedChallenge }) => {
5169
- const traceId = import_keys12.PublicKey.random().toHex();
5170
- import_log15.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols12.trace.begin({
5474
+ const traceId = import_keys13.PublicKey.random().toHex();
5475
+ import_log16.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols14.trace.begin({
5171
5476
  id: traceId
5172
5477
  }), {
5173
- F: __dxlog_file18,
5478
+ F: __dxlog_file19,
5174
5479
  L: 143,
5175
5480
  S: this,
5176
5481
  C: (f, a) => f(...a)
5177
5482
  });
5178
5483
  const invitation = this._requireActiveInvitation();
5179
- import_log15.log.verbose("received authentication request", {
5484
+ import_log16.log.verbose("received authentication request", {
5180
5485
  authCode: code
5181
5486
  }, {
5182
- F: __dxlog_file18,
5487
+ F: __dxlog_file19,
5183
5488
  L: 146,
5184
5489
  S: this,
5185
5490
  C: (f, a) => f(...a)
@@ -5192,8 +5497,8 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5192
5497
  this._callbacks.onStateUpdate(import_services14.Invitation.State.AUTHENTICATING);
5193
5498
  switch (invitation.authMethod) {
5194
5499
  case import_services14.Invitation.AuthMethod.NONE: {
5195
- (0, import_log15.log)("authentication not required", void 0, {
5196
- F: __dxlog_file18,
5500
+ (0, import_log16.log)("authentication not required", void 0, {
5501
+ F: __dxlog_file19,
5197
5502
  L: 154,
5198
5503
  S: this,
5199
5504
  C: (f, a) => f(...a)
@@ -5228,10 +5533,10 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5228
5533
  break;
5229
5534
  }
5230
5535
  default: {
5231
- import_log15.log.error("invalid authentication method", {
5536
+ import_log16.log.error("invalid authentication method", {
5232
5537
  authMethod: invitation.authMethod
5233
5538
  }, {
5234
- F: __dxlog_file18,
5539
+ F: __dxlog_file19,
5235
5540
  L: 192,
5236
5541
  S: this,
5237
5542
  C: (f, a) => f(...a)
@@ -5250,13 +5555,13 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5250
5555
  status
5251
5556
  };
5252
5557
  }
5253
- import_log15.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols12.trace.end({
5558
+ import_log16.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols14.trace.end({
5254
5559
  id: traceId,
5255
5560
  data: {
5256
5561
  status
5257
5562
  }
5258
5563
  }), {
5259
- F: __dxlog_file18,
5564
+ F: __dxlog_file19,
5260
5565
  L: 204,
5261
5566
  S: this,
5262
5567
  C: (f, a) => f(...a)
@@ -5266,11 +5571,11 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5266
5571
  };
5267
5572
  },
5268
5573
  admit: async (request) => {
5269
- const traceId = import_keys12.PublicKey.random().toHex();
5270
- import_log15.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols12.trace.begin({
5574
+ const traceId = import_keys13.PublicKey.random().toHex();
5575
+ import_log16.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols14.trace.begin({
5271
5576
  id: traceId
5272
5577
  }), {
5273
- F: __dxlog_file18,
5578
+ F: __dxlog_file19,
5274
5579
  L: 210,
5275
5580
  S: this,
5276
5581
  C: (f, a) => f(...a)
@@ -5284,10 +5589,10 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5284
5589
  }
5285
5590
  }
5286
5591
  const response = await this._callbacks.admit(request);
5287
- import_log15.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols12.trace.end({
5592
+ import_log16.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols14.trace.end({
5288
5593
  id: traceId
5289
5594
  }), {
5290
- F: __dxlog_file18,
5595
+ F: __dxlog_file19,
5291
5596
  L: 224,
5292
5597
  S: this,
5293
5598
  C: (f, a) => f(...a)
@@ -5304,15 +5609,15 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5304
5609
  async onOpen(context) {
5305
5610
  await super.onOpen(context);
5306
5611
  try {
5307
- import_log15.log.verbose("host acquire lock", void 0, {
5308
- F: __dxlog_file18,
5612
+ import_log16.log.verbose("host acquire lock", void 0, {
5613
+ F: __dxlog_file19,
5309
5614
  L: 239,
5310
5615
  S: this,
5311
5616
  C: (f, a) => f(...a)
5312
5617
  });
5313
5618
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
5314
- import_log15.log.verbose("host lock acquired", void 0, {
5315
- F: __dxlog_file18,
5619
+ import_log16.log.verbose("host lock acquired", void 0, {
5620
+ F: __dxlog_file19,
5316
5621
  L: 241,
5317
5622
  S: this,
5318
5623
  C: (f, a) => f(...a)
@@ -5321,23 +5626,23 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5321
5626
  await this.rpc.InvitationHostService.options({
5322
5627
  role: import_invitations4.InvitationOptions.Role.HOST
5323
5628
  });
5324
- import_log15.log.verbose("options sent", void 0, {
5325
- F: __dxlog_file18,
5629
+ import_log16.log.verbose("options sent", void 0, {
5630
+ F: __dxlog_file19,
5326
5631
  L: 244,
5327
5632
  S: this,
5328
5633
  C: (f, a) => f(...a)
5329
5634
  });
5330
- await (0, import_context13.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
5635
+ await (0, import_context14.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
5331
5636
  timeout: OPTIONS_TIMEOUT2
5332
5637
  }));
5333
- import_log15.log.verbose("options received", void 0, {
5334
- F: __dxlog_file18,
5638
+ import_log16.log.verbose("options received", void 0, {
5639
+ F: __dxlog_file19,
5335
5640
  L: 246,
5336
5641
  S: this,
5337
5642
  C: (f, a) => f(...a)
5338
5643
  });
5339
5644
  if (this._remoteOptions?.role !== import_invitations4.InvitationOptions.Role.GUEST) {
5340
- throw new import_protocols12.InvalidInvitationExtensionRoleError(void 0, {
5645
+ throw new import_protocols14.InvalidInvitationExtensionRoleError(void 0, {
5341
5646
  expected: import_invitations4.InvitationOptions.Role.GUEST,
5342
5647
  remoteOptions: this._remoteOptions,
5343
5648
  remotePeerId: context.remotePeerId
@@ -5369,7 +5674,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5369
5674
  ];
5370
5675
  if (!validStates.includes(invitation.state)) {
5371
5676
  (0, import_async18.scheduleTask)(this._ctx, () => this.close());
5372
- throw new import_invariant15.InvariantViolation(`Expected ${stateToString(invitation.state)} to be one of [${validStates.map(stateToString).join(", ")}]`);
5677
+ throw new import_invariant17.InvariantViolation(`Expected ${stateToString(invitation.state)} to be one of [${validStates.map(stateToString).join(", ")}]`);
5373
5678
  }
5374
5679
  }
5375
5680
  async onClose() {
@@ -5383,8 +5688,8 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5383
5688
  if (this._invitationFlowLock != null) {
5384
5689
  this._invitationFlowLock?.release();
5385
5690
  this._invitationFlowLock = null;
5386
- import_log15.log.verbose("invitation flow lock released", void 0, {
5387
- F: __dxlog_file18,
5691
+ import_log16.log.verbose("invitation flow lock released", void 0, {
5692
+ F: __dxlog_file19,
5388
5693
  L: 299,
5389
5694
  S: this,
5390
5695
  C: (f, a) => f(...a)
@@ -5393,7 +5698,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5393
5698
  }
5394
5699
  };
5395
5700
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services14.Invitation.AuthMethod.NONE;
5396
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-state.ts";
5701
+ var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-state.ts";
5397
5702
  var createGuardedInvitationState = (ctx, invitation, stream) => {
5398
5703
  const mutex = new import_async19.Mutex();
5399
5704
  let lastActiveLockHolder = null;
@@ -5460,15 +5765,15 @@ var logStateUpdate = (invitation, actor, newState, error) => {
5460
5765
  errorStack: error?.stack
5461
5766
  };
5462
5767
  if (isNonTerminalState(newState)) {
5463
- import_log16.log.verbose("dxos.sdk.invitations-handler.state.update", logContext, {
5464
- F: __dxlog_file19,
5768
+ import_log17.log.verbose("dxos.sdk.invitations-handler.state.update", logContext, {
5769
+ F: __dxlog_file20,
5465
5770
  L: 98,
5466
5771
  S: void 0,
5467
5772
  C: (f, a) => f(...a)
5468
5773
  });
5469
5774
  } else {
5470
- import_log16.log.info("dxos.sdk.invitations-handler.state.update", logContext, {
5471
- F: __dxlog_file19,
5775
+ import_log17.log.info("dxos.sdk.invitations-handler.state.update", logContext, {
5776
+ F: __dxlog_file20,
5472
5777
  L: 100,
5473
5778
  S: void 0,
5474
5779
  C: (f, a) => f(...a)
@@ -5484,15 +5789,15 @@ var isNonTerminalState = (currentState) => {
5484
5789
  import_services15.Invitation.State.EXPIRED
5485
5790
  ].includes(currentState);
5486
5791
  };
5487
- var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
5792
+ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
5488
5793
  var InvitationTopology = class {
5489
5794
  constructor(_role) {
5490
5795
  this._role = _role;
5491
- this._seenPeers = new import_util11.ComplexSet(import_keys13.PublicKey.hash);
5796
+ this._seenPeers = new import_util11.ComplexSet(import_keys14.PublicKey.hash);
5492
5797
  }
5493
5798
  init(controller) {
5494
- (0, import_invariant16.invariant)(!this._controller, "Already initialized.", {
5495
- F: __dxlog_file20,
5799
+ (0, import_invariant18.invariant)(!this._controller, "Already initialized.", {
5800
+ F: __dxlog_file21,
5496
5801
  L: 42,
5497
5802
  S: this,
5498
5803
  A: [
@@ -5503,8 +5808,8 @@ var InvitationTopology = class {
5503
5808
  this._controller = controller;
5504
5809
  }
5505
5810
  update() {
5506
- (0, import_invariant16.invariant)(this._controller, "Not initialized.", {
5507
- F: __dxlog_file20,
5811
+ (0, import_invariant18.invariant)(this._controller, "Not initialized.", {
5812
+ F: __dxlog_file21,
5508
5813
  L: 47,
5509
5814
  S: this,
5510
5815
  A: [
@@ -5521,13 +5826,13 @@ var InvitationTopology = class {
5521
5826
  return;
5522
5827
  }
5523
5828
  const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
5524
- this._seenPeers = new import_util11.ComplexSet(import_keys13.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
5829
+ this._seenPeers = new import_util11.ComplexSet(import_keys14.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
5525
5830
  if (firstUnknownPeer != null) {
5526
- (0, import_log17.log)("invitation connect", {
5831
+ (0, import_log18.log)("invitation connect", {
5527
5832
  ownPeerId,
5528
5833
  remotePeerId: firstUnknownPeer
5529
5834
  }, {
5530
- F: __dxlog_file20,
5835
+ F: __dxlog_file21,
5531
5836
  L: 69,
5532
5837
  S: this,
5533
5838
  C: (f, a) => f(...a)
@@ -5537,8 +5842,8 @@ var InvitationTopology = class {
5537
5842
  }
5538
5843
  }
5539
5844
  async onOffer(peer) {
5540
- (0, import_invariant16.invariant)(this._controller, "Not initialized.", {
5541
- F: __dxlog_file20,
5845
+ (0, import_invariant18.invariant)(this._controller, "Not initialized.", {
5846
+ F: __dxlog_file21,
5542
5847
  L: 76,
5543
5848
  S: this,
5544
5849
  A: [
@@ -5555,7 +5860,7 @@ var InvitationTopology = class {
5555
5860
  return `InvitationTopology(${this._role === import_invitations5.InvitationOptions.Role.GUEST ? "guest" : "host"})`;
5556
5861
  }
5557
5862
  };
5558
- var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
5863
+ var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
5559
5864
  var metrics = import_tracing8.trace.metrics;
5560
5865
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
5561
5866
  var InvitationsHandler = class {
@@ -5568,13 +5873,13 @@ var InvitationsHandler = class {
5568
5873
  this._connectionParams = _connectionParams;
5569
5874
  }
5570
5875
  handleInvitationFlow(ctx, stream, protocol, invitation) {
5571
- import_log12.log.verbose("dxos.sdk.invitations-handler.handleInvitationFlow", {
5876
+ import_log13.log.verbose("dxos.sdk.invitations-handler.handleInvitationFlow", {
5572
5877
  state: invitation.state,
5573
5878
  invitationId: invitation.invitationId,
5574
5879
  kind: invitation.kind,
5575
5880
  type: invitation.type
5576
5881
  }, {
5577
- F: __dxlog_file21,
5882
+ F: __dxlog_file22,
5578
5883
  L: 83,
5579
5884
  S: this,
5580
5885
  C: (f, a) => f(...a)
@@ -5594,18 +5899,18 @@ var InvitationsHandler = class {
5594
5899
  },
5595
5900
  admit: async (admissionRequest) => {
5596
5901
  try {
5597
- import_log12.log.verbose("dxos.sdk.invitations-handler.host.admit", {
5902
+ import_log13.log.verbose("dxos.sdk.invitations-handler.host.admit", {
5598
5903
  invitationId: invitation.invitationId,
5599
5904
  ...protocol.toJSON()
5600
5905
  }, {
5601
- F: __dxlog_file21,
5906
+ F: __dxlog_file22,
5602
5907
  L: 107,
5603
5908
  S: this,
5604
5909
  C: (f, a) => f(...a)
5605
5910
  });
5606
5911
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
5607
- (0, import_invariant12.invariant)(deviceKey, void 0, {
5608
- F: __dxlog_file21,
5912
+ (0, import_invariant14.invariant)(deviceKey, void 0, {
5913
+ F: __dxlog_file22,
5609
5914
  L: 112,
5610
5915
  S: this,
5611
5916
  A: [
@@ -5629,20 +5934,20 @@ var InvitationsHandler = class {
5629
5934
  }
5630
5935
  });
5631
5936
  (0, import_async15.scheduleTask)(connectionCtx, async () => {
5632
- const traceId = import_keys10.PublicKey.random().toHex();
5937
+ const traceId = import_keys11.PublicKey.random().toHex();
5633
5938
  try {
5634
- import_log12.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.begin({
5939
+ import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols11.trace.begin({
5635
5940
  id: traceId
5636
5941
  }), {
5637
- F: __dxlog_file21,
5942
+ F: __dxlog_file22,
5638
5943
  L: 137,
5639
5944
  S: this,
5640
5945
  C: (f, a) => f(...a)
5641
5946
  });
5642
- import_log12.log.verbose("connected", {
5947
+ import_log13.log.verbose("connected", {
5643
5948
  ...protocol.toJSON()
5644
5949
  }, {
5645
- F: __dxlog_file21,
5950
+ F: __dxlog_file22,
5646
5951
  L: 138,
5647
5952
  S: this,
5648
5953
  C: (f, a) => f(...a)
@@ -5650,21 +5955,21 @@ var InvitationsHandler = class {
5650
5955
  const deviceKey = await extension.completedTrigger.wait({
5651
5956
  timeout: invitation.timeout
5652
5957
  });
5653
- import_log12.log.verbose("admitted guest", {
5958
+ import_log13.log.verbose("admitted guest", {
5654
5959
  guest: deviceKey,
5655
5960
  ...protocol.toJSON()
5656
5961
  }, {
5657
- F: __dxlog_file21,
5962
+ F: __dxlog_file22,
5658
5963
  L: 140,
5659
5964
  S: this,
5660
5965
  C: (f, a) => f(...a)
5661
5966
  });
5662
5967
  guardedState.set(extension, import_services11.Invitation.State.SUCCESS);
5663
5968
  metrics.increment("dxos.invitation.success");
5664
- import_log12.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.end({
5969
+ import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols11.trace.end({
5665
5970
  id: traceId
5666
5971
  }), {
5667
- F: __dxlog_file21,
5972
+ F: __dxlog_file22,
5668
5973
  L: 143,
5669
5974
  S: this,
5670
5975
  C: (f, a) => f(...a)
@@ -5678,10 +5983,10 @@ var InvitationsHandler = class {
5678
5983
  if (err instanceof import_async15.TimeoutError) {
5679
5984
  if (stateChanged) {
5680
5985
  metrics.increment("dxos.invitation.timeout");
5681
- import_log12.log.verbose("timeout", {
5986
+ import_log13.log.verbose("timeout", {
5682
5987
  ...protocol.toJSON()
5683
5988
  }, {
5684
- F: __dxlog_file21,
5989
+ F: __dxlog_file22,
5685
5990
  L: 154,
5686
5991
  S: this,
5687
5992
  C: (f, a) => f(...a)
@@ -5690,19 +5995,19 @@ var InvitationsHandler = class {
5690
5995
  } else {
5691
5996
  if (stateChanged) {
5692
5997
  metrics.increment("dxos.invitation.failed");
5693
- import_log12.log.error("failed", err, {
5694
- F: __dxlog_file21,
5998
+ import_log13.log.error("failed", err, {
5999
+ F: __dxlog_file22,
5695
6000
  L: 159,
5696
6001
  S: this,
5697
6002
  C: (f, a) => f(...a)
5698
6003
  });
5699
6004
  }
5700
6005
  }
5701
- import_log12.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.error({
6006
+ import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols11.trace.error({
5702
6007
  id: traceId,
5703
6008
  error: err
5704
6009
  }), {
5705
- F: __dxlog_file21,
6010
+ F: __dxlog_file22,
5706
6011
  L: 162,
5707
6012
  S: this,
5708
6013
  C: (f, a) => f(...a)
@@ -5713,11 +6018,11 @@ var InvitationsHandler = class {
5713
6018
  },
5714
6019
  onError: (err) => {
5715
6020
  const stateChanged = guardedState.set(extension, import_services11.Invitation.State.CONNECTING);
5716
- if (err instanceof import_protocols9.InvalidInvitationExtensionRoleError) {
5717
- (0, import_log12.log)("invalid role", {
6021
+ if (err instanceof import_protocols11.InvalidInvitationExtensionRoleError) {
6022
+ (0, import_log13.log)("invalid role", {
5718
6023
  ...err.context
5719
6024
  }, {
5720
- F: __dxlog_file21,
6025
+ F: __dxlog_file22,
5721
6026
  L: 171,
5722
6027
  S: this,
5723
6028
  C: (f, a) => f(...a)
@@ -5727,10 +6032,10 @@ var InvitationsHandler = class {
5727
6032
  if (err instanceof import_async15.TimeoutError) {
5728
6033
  if (stateChanged) {
5729
6034
  metrics.increment("dxos.invitation.timeout");
5730
- import_log12.log.verbose("timeout", {
6035
+ import_log13.log.verbose("timeout", {
5731
6036
  err
5732
6037
  }, {
5733
- F: __dxlog_file21,
6038
+ F: __dxlog_file22,
5734
6039
  L: 177,
5735
6040
  S: this,
5736
6041
  C: (f, a) => f(...a)
@@ -5739,8 +6044,8 @@ var InvitationsHandler = class {
5739
6044
  } else {
5740
6045
  if (stateChanged) {
5741
6046
  metrics.increment("dxos.invitation.failed");
5742
- import_log12.log.error("failed", err, {
5743
- F: __dxlog_file21,
6047
+ import_log13.log.error("failed", err, {
6048
+ F: __dxlog_file22,
5744
6049
  L: 182,
5745
6050
  S: this,
5746
6051
  C: (f, a) => f(...a)
@@ -5754,15 +6059,15 @@ var InvitationsHandler = class {
5754
6059
  const expiresOn = (0, import_client_protocol5.getExpirationTime)(invitation);
5755
6060
  if (expiresOn) {
5756
6061
  if (expiresOn.getTime() < Date.now()) {
5757
- import_log12.log.warn("invitation has already expired", void 0, {
5758
- F: __dxlog_file21,
6062
+ import_log13.log.warn("invitation has already expired", void 0, {
6063
+ F: __dxlog_file22,
5759
6064
  L: 194,
5760
6065
  S: this,
5761
6066
  C: (f, a) => f(...a)
5762
6067
  });
5763
6068
  guardedState.set(null, import_services11.Invitation.State.EXPIRED);
5764
- void ctx.dispose().catch((err) => import_log12.log.catch(err, void 0, {
5765
- F: __dxlog_file21,
6069
+ void ctx.dispose().catch((err) => import_log13.log.catch(err, void 0, {
6070
+ F: __dxlog_file22,
5766
6071
  L: 196,
5767
6072
  S: this,
5768
6073
  C: (f, a) => f(...a)
@@ -5783,21 +6088,21 @@ var InvitationsHandler = class {
5783
6088
  });
5784
6089
  }
5785
6090
  acceptInvitation(ctx, stream, protocol, invitation, otpEnteredTrigger, deviceProfile) {
5786
- import_log12.log.verbose("dxos.sdk.invitations-handler.acceptInvitation", {
6091
+ import_log13.log.verbose("dxos.sdk.invitations-handler.acceptInvitation", {
5787
6092
  state: invitation.state,
5788
6093
  invitationId: invitation.invitationId,
5789
6094
  kind: invitation.kind,
5790
6095
  type: invitation.type
5791
6096
  }, {
5792
- F: __dxlog_file21,
6097
+ F: __dxlog_file22,
5793
6098
  L: 227,
5794
6099
  S: this,
5795
6100
  C: (f, a) => f(...a)
5796
6101
  });
5797
6102
  const { timeout = import_client_protocol5.INVITATION_TIMEOUT } = invitation;
5798
6103
  if (deviceProfile) {
5799
- (0, import_invariant12.invariant)(invitation.kind === import_services11.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
5800
- F: __dxlog_file21,
6104
+ (0, import_invariant14.invariant)(invitation.kind === import_services11.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
6105
+ F: __dxlog_file22,
5801
6106
  L: 236,
5802
6107
  S: this,
5803
6108
  A: [
@@ -5806,16 +6111,16 @@ var InvitationsHandler = class {
5806
6111
  ]
5807
6112
  });
5808
6113
  }
5809
- const triedPeersIds = new import_util10.ComplexSet(import_keys10.PublicKey.hash);
6114
+ const triedPeersIds = new import_util10.ComplexSet(import_keys11.PublicKey.hash);
5810
6115
  const guardedState = createGuardedInvitationState(ctx, invitation, stream);
5811
6116
  const shouldCancelInvitationFlow = (extension) => {
5812
6117
  const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
5813
- (0, import_log12.log)("should cancel invitation flow", {
6118
+ (0, import_log13.log)("should cancel invitation flow", {
5814
6119
  isLockedByAnotherConnection,
5815
6120
  invitationType: import_services11.Invitation.Type.DELEGATED,
5816
6121
  triedPeers: triedPeersIds.size
5817
6122
  }, {
5818
- F: __dxlog_file21,
6123
+ F: __dxlog_file22,
5819
6124
  L: 244,
5820
6125
  S: this,
5821
6126
  C: (f, a) => f(...a)
@@ -5838,29 +6143,29 @@ var InvitationsHandler = class {
5838
6143
  return;
5839
6144
  }
5840
6145
  connectionCtx.onDispose(async () => {
5841
- import_log12.log.verbose("extension disposed", {
6146
+ import_log13.log.verbose("extension disposed", {
5842
6147
  admitted,
5843
6148
  currentState: guardedState.current.state
5844
6149
  }, {
5845
- F: __dxlog_file21,
6150
+ F: __dxlog_file22,
5846
6151
  L: 272,
5847
6152
  S: this,
5848
6153
  C: (f, a) => f(...a)
5849
6154
  });
5850
6155
  if (!admitted) {
5851
- guardedState.error(extension, new import_context10.ContextDisposedError());
6156
+ guardedState.error(extension, new import_context11.ContextDisposedError());
5852
6157
  if (shouldCancelInvitationFlow(extension)) {
5853
6158
  await ctx.dispose();
5854
6159
  }
5855
6160
  }
5856
6161
  });
5857
6162
  (0, import_async15.scheduleTask)(connectionCtx, async () => {
5858
- const traceId = import_keys10.PublicKey.random().toHex();
6163
+ const traceId = import_keys11.PublicKey.random().toHex();
5859
6164
  try {
5860
- import_log12.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.begin({
6165
+ import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols11.trace.begin({
5861
6166
  id: traceId
5862
6167
  }), {
5863
- F: __dxlog_file21,
6168
+ F: __dxlog_file22,
5864
6169
  L: 284,
5865
6170
  S: this,
5866
6171
  C: (f, a) => f(...a)
@@ -5869,20 +6174,20 @@ var InvitationsHandler = class {
5869
6174
  guardedState.set(extension, import_services11.Invitation.State.TIMEOUT);
5870
6175
  extensionCtx.close();
5871
6176
  }, timeout);
5872
- import_log12.log.verbose("dxos.sdk.invitations-handler.guest.connected", {
6177
+ import_log13.log.verbose("dxos.sdk.invitations-handler.guest.connected", {
5873
6178
  ...protocol.toJSON()
5874
6179
  }, {
5875
- F: __dxlog_file21,
6180
+ F: __dxlog_file22,
5876
6181
  L: 295,
5877
6182
  S: this,
5878
6183
  C: (f, a) => f(...a)
5879
6184
  });
5880
6185
  guardedState.set(extension, import_services11.Invitation.State.CONNECTED);
5881
- import_log12.log.verbose("dxos.sdk.invitations-handler.guest.introduce", {
6186
+ import_log13.log.verbose("dxos.sdk.invitations-handler.guest.introduce", {
5882
6187
  invitationId: invitation.invitationId,
5883
6188
  ...protocol.toJSON()
5884
6189
  }, {
5885
- F: __dxlog_file21,
6190
+ F: __dxlog_file22,
5886
6191
  L: 299,
5887
6192
  S: this,
5888
6193
  C: (f, a) => f(...a)
@@ -5891,12 +6196,12 @@ var InvitationsHandler = class {
5891
6196
  invitationId: invitation.invitationId,
5892
6197
  ...protocol.createIntroduction()
5893
6198
  });
5894
- import_log12.log.verbose("dxos.sdk.invitations-handler.guest.introduce-response", {
6199
+ import_log13.log.verbose("dxos.sdk.invitations-handler.guest.introduce-response", {
5895
6200
  invitationId: invitation.invitationId,
5896
6201
  ...protocol.toJSON(),
5897
6202
  authMethod: introductionResponse.authMethod
5898
6203
  }, {
5899
- F: __dxlog_file21,
6204
+ F: __dxlog_file22,
5900
6205
  L: 307,
5901
6206
  S: this,
5902
6207
  C: (f, a) => f(...a)
@@ -5914,11 +6219,11 @@ var InvitationsHandler = class {
5914
6219
  break;
5915
6220
  }
5916
6221
  }
5917
- import_log12.log.verbose("dxos.sdk.invitations-handler.guest.request-admission", {
6222
+ import_log13.log.verbose("dxos.sdk.invitations-handler.guest.request-admission", {
5918
6223
  invitationId: invitation.invitationId,
5919
6224
  ...protocol.toJSON()
5920
6225
  }, {
5921
- F: __dxlog_file21,
6226
+ F: __dxlog_file22,
5922
6227
  L: 337,
5923
6228
  S: this,
5924
6229
  C: (f, a) => f(...a)
@@ -5927,11 +6232,11 @@ var InvitationsHandler = class {
5927
6232
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
5928
6233
  admitted = true;
5929
6234
  const result = await protocol.accept(admissionResponse, admissionRequest);
5930
- import_log12.log.verbose("dxos.sdk.invitations-handler.guest.admitted-by-host", {
6235
+ import_log13.log.verbose("dxos.sdk.invitations-handler.guest.admitted-by-host", {
5931
6236
  invitationId: invitation.invitationId,
5932
6237
  ...protocol.toJSON()
5933
6238
  }, {
5934
- F: __dxlog_file21,
6239
+ F: __dxlog_file22,
5935
6240
  L: 351,
5936
6241
  S: this,
5937
6242
  C: (f, a) => f(...a)
@@ -5941,28 +6246,28 @@ var InvitationsHandler = class {
5941
6246
  ...result,
5942
6247
  state: import_services11.Invitation.State.SUCCESS
5943
6248
  });
5944
- import_log12.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.end({
6249
+ import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols11.trace.end({
5945
6250
  id: traceId
5946
6251
  }), {
5947
- F: __dxlog_file21,
6252
+ F: __dxlog_file22,
5948
6253
  L: 360,
5949
6254
  S: this,
5950
6255
  C: (f, a) => f(...a)
5951
6256
  });
5952
6257
  } catch (err) {
5953
6258
  if (err instanceof import_async15.TimeoutError) {
5954
- import_log12.log.verbose("timeout", {
6259
+ import_log13.log.verbose("timeout", {
5955
6260
  ...protocol.toJSON()
5956
6261
  }, {
5957
- F: __dxlog_file21,
6262
+ F: __dxlog_file22,
5958
6263
  L: 363,
5959
6264
  S: this,
5960
6265
  C: (f, a) => f(...a)
5961
6266
  });
5962
6267
  guardedState.set(extension, import_services11.Invitation.State.TIMEOUT);
5963
6268
  } else {
5964
- import_log12.log.verbose("auth failed", err, {
5965
- F: __dxlog_file21,
6269
+ import_log13.log.verbose("auth failed", err, {
6270
+ F: __dxlog_file22,
5966
6271
  L: 366,
5967
6272
  S: this,
5968
6273
  C: (f, a) => f(...a)
@@ -5970,11 +6275,11 @@ var InvitationsHandler = class {
5970
6275
  guardedState.error(extension, err);
5971
6276
  }
5972
6277
  extensionCtx.close(err);
5973
- import_log12.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.error({
6278
+ import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols11.trace.error({
5974
6279
  id: traceId,
5975
6280
  error: err
5976
6281
  }), {
5977
- F: __dxlog_file21,
6282
+ F: __dxlog_file22,
5978
6283
  L: 370,
5979
6284
  S: this,
5980
6285
  C: (f, a) => f(...a)
@@ -5983,22 +6288,22 @@ var InvitationsHandler = class {
5983
6288
  });
5984
6289
  },
5985
6290
  onError: (err) => {
5986
- if (err instanceof import_protocols9.InvalidInvitationExtensionRoleError) {
6291
+ if (err instanceof import_protocols11.InvalidInvitationExtensionRoleError) {
5987
6292
  return;
5988
6293
  }
5989
6294
  if (err instanceof import_async15.TimeoutError) {
5990
- import_log12.log.verbose("timeout", {
6295
+ import_log13.log.verbose("timeout", {
5991
6296
  ...protocol.toJSON()
5992
6297
  }, {
5993
- F: __dxlog_file21,
6298
+ F: __dxlog_file22,
5994
6299
  L: 379,
5995
6300
  S: this,
5996
6301
  C: (f, a) => f(...a)
5997
6302
  });
5998
6303
  guardedState.set(extension, import_services11.Invitation.State.TIMEOUT);
5999
6304
  } else {
6000
- import_log12.log.verbose("auth failed", err, {
6001
- F: __dxlog_file21,
6305
+ import_log13.log.verbose("auth failed", err, {
6306
+ F: __dxlog_file22,
6002
6307
  L: 382,
6003
6308
  S: this,
6004
6309
  C: (f, a) => f(...a)
@@ -6012,10 +6317,10 @@ var InvitationsHandler = class {
6012
6317
  const edgeInvitationHandler = new EdgeInvitationHandler(this._connectionParams?.edgeInvitations, this._edgeClient, {
6013
6318
  onInvitationSuccess: async (admissionResponse, admissionRequest) => {
6014
6319
  const result = await protocol.accept(admissionResponse, admissionRequest);
6015
- import_log12.log.info("admitted by edge", {
6320
+ import_log13.log.info("admitted by edge", {
6016
6321
  ...protocol.toJSON()
6017
6322
  }, {
6018
- F: __dxlog_file21,
6323
+ F: __dxlog_file22,
6019
6324
  L: 394,
6020
6325
  S: this,
6021
6326
  C: (f, a) => f(...a)
@@ -6034,8 +6339,8 @@ var InvitationsHandler = class {
6034
6339
  stream.error(error);
6035
6340
  await ctx.dispose();
6036
6341
  } else {
6037
- (0, import_invariant12.invariant)(invitation.swarmKey, void 0, {
6038
- F: __dxlog_file21,
6342
+ (0, import_invariant14.invariant)(invitation.swarmKey, void 0, {
6343
+ F: __dxlog_file22,
6039
6344
  L: 406,
6040
6345
  S: this,
6041
6346
  A: [
@@ -6078,16 +6383,16 @@ var InvitationsHandler = class {
6078
6383
  }
6079
6384
  async _handleGuestOtpAuth(extension, setState, authenticated, options) {
6080
6385
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
6081
- (0, import_log12.log)("guest waiting for authentication code...", void 0, {
6082
- F: __dxlog_file21,
6386
+ (0, import_log13.log)("guest waiting for authentication code...", void 0, {
6387
+ F: __dxlog_file22,
6083
6388
  L: 458,
6084
6389
  S: this,
6085
6390
  C: (f, a) => f(...a)
6086
6391
  });
6087
6392
  setState(import_services11.Invitation.State.READY_FOR_AUTHENTICATION);
6088
6393
  const authCode = await authenticated.wait(options);
6089
- (0, import_log12.log)("sending authentication request", void 0, {
6090
- F: __dxlog_file21,
6394
+ (0, import_log13.log)("sending authentication request", void 0, {
6395
+ F: __dxlog_file22,
6091
6396
  L: 462,
6092
6397
  S: this,
6093
6398
  C: (f, a) => f(...a)
@@ -6103,10 +6408,10 @@ var InvitationsHandler = class {
6103
6408
  if (attempt === MAX_OTP_ATTEMPTS) {
6104
6409
  throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
6105
6410
  } else {
6106
- (0, import_log12.log)("retrying invalid code", {
6411
+ (0, import_log13.log)("retrying invalid code", {
6107
6412
  attempt
6108
6413
  }, {
6109
- F: __dxlog_file21,
6414
+ F: __dxlog_file22,
6110
6415
  L: 473,
6111
6416
  S: this,
6112
6417
  C: (f, a) => f(...a)
@@ -6123,8 +6428,8 @@ var InvitationsHandler = class {
6123
6428
  if (introductionResponse.challenge == null) {
6124
6429
  throw new Error("challenge missing in the introduction");
6125
6430
  }
6126
- (0, import_log12.log)("sending authentication request", void 0, {
6127
- F: __dxlog_file21,
6431
+ (0, import_log13.log)("sending authentication request", void 0, {
6432
+ F: __dxlog_file22,
6128
6433
  L: 492,
6129
6434
  S: this,
6130
6435
  C: (f, a) => f(...a)
@@ -6141,14 +6446,14 @@ var InvitationsHandler = class {
6141
6446
  var checkInvitation = (protocol, invitation) => {
6142
6447
  const expiresOn = (0, import_client_protocol5.getExpirationTime)(invitation);
6143
6448
  if (expiresOn && expiresOn.getTime() < Date.now()) {
6144
- return new import_protocols9.InvalidInvitationError("Invitation already expired.");
6449
+ return new import_protocols11.InvalidInvitationError("Invitation already expired.");
6145
6450
  }
6146
6451
  return protocol.checkInvitation(invitation);
6147
6452
  };
6148
6453
  var createAdmissionKeypair = () => {
6149
6454
  const keypair = (0, import_crypto.createKeyPair)();
6150
6455
  return {
6151
- publicKey: import_keys10.PublicKey.from(keypair.publicKey),
6456
+ publicKey: import_keys11.PublicKey.from(keypair.publicKey),
6152
6457
  privateKey: keypair.secretKey
6153
6458
  };
6154
6459
  };
@@ -6248,7 +6553,7 @@ var InvitationsServiceImpl = class {
6248
6553
  });
6249
6554
  }
6250
6555
  };
6251
- var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
6556
+ var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
6252
6557
  var SpaceInvitationProtocol = class {
6253
6558
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
6254
6559
  this._spaceManager = _spaceManager;
@@ -6265,20 +6570,20 @@ var SpaceInvitationProtocol = class {
6265
6570
  }
6266
6571
  checkCanInviteNewMembers() {
6267
6572
  if (this._spaceKey == null) {
6268
- return new import_protocols13.InvalidInvitationError("No spaceKey was provided for a space invitation.");
6573
+ return new import_protocols15.InvalidInvitationError("No spaceKey was provided for a space invitation.");
6269
6574
  }
6270
6575
  const space = this._spaceManager.spaces.get(this._spaceKey);
6271
6576
  if (space == null) {
6272
- return new import_protocols13.SpaceNotFoundError(this._spaceKey);
6577
+ return new import_protocols15.SpaceNotFoundError(this._spaceKey);
6273
6578
  }
6274
6579
  if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
6275
- return new import_protocols13.AuthorizationError("No member management permission.");
6580
+ return new import_protocols15.AuthorizationError("No member management permission.");
6276
6581
  }
6277
6582
  return void 0;
6278
6583
  }
6279
6584
  getInvitationContext() {
6280
- (0, import_invariant17.invariant)(this._spaceKey, void 0, {
6281
- F: __dxlog_file22,
6585
+ (0, import_invariant19.invariant)(this._spaceKey, void 0, {
6586
+ F: __dxlog_file23,
6282
6587
  L: 65,
6283
6588
  S: this,
6284
6589
  A: [
@@ -6287,8 +6592,8 @@ var SpaceInvitationProtocol = class {
6287
6592
  ]
6288
6593
  });
6289
6594
  const space = this._spaceManager.spaces.get(this._spaceKey);
6290
- (0, import_invariant17.invariant)(space, void 0, {
6291
- F: __dxlog_file22,
6595
+ (0, import_invariant19.invariant)(space, void 0, {
6596
+ F: __dxlog_file23,
6292
6597
  L: 67,
6293
6598
  S: this,
6294
6599
  A: [
@@ -6303,8 +6608,8 @@ var SpaceInvitationProtocol = class {
6303
6608
  };
6304
6609
  }
6305
6610
  async admit(invitation, request, guestProfile) {
6306
- (0, import_invariant17.invariant)(this._spaceKey && request.space, void 0, {
6307
- F: __dxlog_file22,
6611
+ (0, import_invariant19.invariant)(this._spaceKey && request.space, void 0, {
6612
+ F: __dxlog_file23,
6308
6613
  L: 80,
6309
6614
  S: this,
6310
6615
  A: [
@@ -6312,11 +6617,11 @@ var SpaceInvitationProtocol = class {
6312
6617
  ""
6313
6618
  ]
6314
6619
  });
6315
- (0, import_log18.log)("writing guest credentials", {
6620
+ (0, import_log19.log)("writing guest credentials", {
6316
6621
  host: this._signingContext.deviceKey,
6317
6622
  guest: request.space.deviceKey
6318
6623
  }, {
6319
- F: __dxlog_file22,
6624
+ F: __dxlog_file23,
6320
6625
  L: 81,
6321
6626
  S: this,
6322
6627
  C: (f, a) => f(...a)
@@ -6337,8 +6642,8 @@ var SpaceInvitationProtocol = class {
6337
6642
  };
6338
6643
  }
6339
6644
  async delegate(invitation) {
6340
- (0, import_invariant17.invariant)(this._spaceKey, void 0, {
6341
- F: __dxlog_file22,
6645
+ (0, import_invariant19.invariant)(this._spaceKey, void 0, {
6646
+ F: __dxlog_file23,
6342
6647
  L: 101,
6343
6648
  S: this,
6344
6649
  A: [
@@ -6347,8 +6652,8 @@ var SpaceInvitationProtocol = class {
6347
6652
  ]
6348
6653
  });
6349
6654
  const space = this._spaceManager.spaces.get(this._spaceKey);
6350
- (0, import_invariant17.invariant)(space, void 0, {
6351
- F: __dxlog_file22,
6655
+ (0, import_invariant19.invariant)(space, void 0, {
6656
+ F: __dxlog_file23,
6352
6657
  L: 103,
6353
6658
  S: this,
6354
6659
  A: [
@@ -6357,8 +6662,8 @@ var SpaceInvitationProtocol = class {
6357
6662
  ]
6358
6663
  });
6359
6664
  if (invitation.authMethod === import_services17.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
6360
- (0, import_invariant17.invariant)(invitation.guestKeypair?.publicKey, void 0, {
6361
- F: __dxlog_file22,
6665
+ (0, import_invariant19.invariant)(invitation.guestKeypair?.publicKey, void 0, {
6666
+ F: __dxlog_file23,
6362
6667
  L: 105,
6363
6668
  S: this,
6364
6669
  A: [
@@ -6367,11 +6672,11 @@ var SpaceInvitationProtocol = class {
6367
6672
  ]
6368
6673
  });
6369
6674
  }
6370
- (0, import_log18.log)("writing delegate space invitation", {
6675
+ (0, import_log19.log)("writing delegate space invitation", {
6371
6676
  host: this._signingContext.deviceKey,
6372
6677
  id: invitation.invitationId
6373
6678
  }, {
6374
- F: __dxlog_file22,
6679
+ F: __dxlog_file23,
6375
6680
  L: 108,
6376
6681
  S: this,
6377
6682
  C: (f, a) => f(...a)
@@ -6385,8 +6690,8 @@ var SpaceInvitationProtocol = class {
6385
6690
  multiUse: invitation.multiUse ?? false,
6386
6691
  guestKey: invitation.authMethod === import_services17.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
6387
6692
  });
6388
- (0, import_invariant17.invariant)(credential.credential, void 0, {
6389
- F: __dxlog_file22,
6693
+ (0, import_invariant19.invariant)(credential.credential, void 0, {
6694
+ F: __dxlog_file23,
6390
6695
  L: 126,
6391
6696
  S: this,
6392
6697
  A: [
@@ -6400,8 +6705,8 @@ var SpaceInvitationProtocol = class {
6400
6705
  return credential.credential.credential.id;
6401
6706
  }
6402
6707
  async cancelDelegation(invitation) {
6403
- (0, import_invariant17.invariant)(this._spaceKey, void 0, {
6404
- F: __dxlog_file22,
6708
+ (0, import_invariant19.invariant)(this._spaceKey, void 0, {
6709
+ F: __dxlog_file23,
6405
6710
  L: 132,
6406
6711
  S: this,
6407
6712
  A: [
@@ -6409,8 +6714,8 @@ var SpaceInvitationProtocol = class {
6409
6714
  ""
6410
6715
  ]
6411
6716
  });
6412
- (0, import_invariant17.invariant)(invitation.type === import_services17.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6413
- F: __dxlog_file22,
6717
+ (0, import_invariant19.invariant)(invitation.type === import_services17.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
6718
+ F: __dxlog_file23,
6414
6719
  L: 133,
6415
6720
  S: this,
6416
6721
  A: [
@@ -6419,8 +6724,8 @@ var SpaceInvitationProtocol = class {
6419
6724
  ]
6420
6725
  });
6421
6726
  const space = this._spaceManager.spaces.get(this._spaceKey);
6422
- (0, import_invariant17.invariant)(space, void 0, {
6423
- F: __dxlog_file22,
6727
+ (0, import_invariant19.invariant)(space, void 0, {
6728
+ F: __dxlog_file23,
6424
6729
  L: 135,
6425
6730
  S: this,
6426
6731
  A: [
@@ -6428,18 +6733,18 @@ var SpaceInvitationProtocol = class {
6428
6733
  ""
6429
6734
  ]
6430
6735
  });
6431
- (0, import_log18.log)("cancelling delegated space invitation", {
6736
+ (0, import_log19.log)("cancelling delegated space invitation", {
6432
6737
  host: this._signingContext.deviceKey,
6433
6738
  id: invitation.invitationId
6434
6739
  }, {
6435
- F: __dxlog_file22,
6740
+ F: __dxlog_file23,
6436
6741
  L: 137,
6437
6742
  S: this,
6438
6743
  C: (f, a) => f(...a)
6439
6744
  });
6440
6745
  const credential = await (0, import_credentials18.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
6441
- (0, import_invariant17.invariant)(credential.credential, void 0, {
6442
- F: __dxlog_file22,
6746
+ (0, import_invariant19.invariant)(credential.credential, void 0, {
6747
+ F: __dxlog_file23,
6443
6748
  L: 144,
6444
6749
  S: this,
6445
6750
  A: [
@@ -6453,10 +6758,10 @@ var SpaceInvitationProtocol = class {
6453
6758
  }
6454
6759
  checkInvitation(invitation) {
6455
6760
  if (invitation.spaceKey == null) {
6456
- return new import_protocols13.InvalidInvitationError("No spaceKey was provided for a space invitation.");
6761
+ return new import_protocols15.InvalidInvitationError("No spaceKey was provided for a space invitation.");
6457
6762
  }
6458
6763
  if (this._spaceManager.spaces.has(invitation.spaceKey)) {
6459
- return new import_protocols13.AlreadyJoinedError("Already joined space.");
6764
+ return new import_protocols15.AlreadyJoinedError("Already joined space.");
6460
6765
  }
6461
6766
  }
6462
6767
  createIntroduction() {
@@ -6477,8 +6782,8 @@ var SpaceInvitationProtocol = class {
6477
6782
  };
6478
6783
  }
6479
6784
  async accept(response) {
6480
- (0, import_invariant17.invariant)(response.space, void 0, {
6481
- F: __dxlog_file22,
6785
+ (0, import_invariant19.invariant)(response.space, void 0, {
6786
+ F: __dxlog_file23,
6482
6787
  L: 179,
6483
6788
  S: this,
6484
6789
  A: [
@@ -6488,8 +6793,8 @@ var SpaceInvitationProtocol = class {
6488
6793
  });
6489
6794
  const { credential, controlTimeframe, dataTimeframe } = response.space;
6490
6795
  const assertion = (0, import_credentials18.getCredentialAssertion)(credential);
6491
- (0, import_invariant17.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
6492
- F: __dxlog_file22,
6796
+ (0, import_invariant19.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
6797
+ F: __dxlog_file23,
6493
6798
  L: 182,
6494
6799
  S: this,
6495
6800
  A: [
@@ -6497,8 +6802,8 @@ var SpaceInvitationProtocol = class {
6497
6802
  "'Invalid credential'"
6498
6803
  ]
6499
6804
  });
6500
- (0, import_invariant17.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
6501
- F: __dxlog_file22,
6805
+ (0, import_invariant19.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
6806
+ F: __dxlog_file23,
6502
6807
  L: 183,
6503
6808
  S: this,
6504
6809
  A: [
@@ -6507,7 +6812,7 @@ var SpaceInvitationProtocol = class {
6507
6812
  ]
6508
6813
  });
6509
6814
  if (this._spaceManager.spaces.has(assertion.spaceKey)) {
6510
- throw new import_protocols13.AlreadyJoinedError("Already joined space.");
6815
+ throw new import_protocols15.AlreadyJoinedError("Already joined space.");
6511
6816
  }
6512
6817
  await this._spaceManager.acceptSpace({
6513
6818
  spaceKey: assertion.spaceKey,
@@ -6521,7 +6826,7 @@ var SpaceInvitationProtocol = class {
6521
6826
  };
6522
6827
  }
6523
6828
  };
6524
- var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
6829
+ var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
6525
6830
  var InvitationsManager = class {
6526
6831
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
6527
6832
  this._invitationsHandler = _invitationsHandler;
@@ -6563,8 +6868,8 @@ var InvitationsManager = class {
6563
6868
  try {
6564
6869
  await this._persistIfRequired(handler, stream, invitation);
6565
6870
  } catch (err) {
6566
- import_log19.log.catch(err, void 0, {
6567
- F: __dxlog_file23,
6871
+ import_log20.log.catch(err, void 0, {
6872
+ F: __dxlog_file24,
6568
6873
  L: 82,
6569
6874
  S: this,
6570
6875
  C: (f, a) => f(...a)
@@ -6586,8 +6891,8 @@ var InvitationsManager = class {
6586
6891
  const persistentInvitations = this._metadataStore.getInvitations();
6587
6892
  const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline3.hasInvitationExpired)(invitation));
6588
6893
  const loadTasks = freshInvitations.map((persistentInvitation) => {
6589
- (0, import_invariant18.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
6590
- F: __dxlog_file23,
6894
+ (0, import_invariant20.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
6895
+ F: __dxlog_file24,
6591
6896
  L: 103,
6592
6897
  S: this,
6593
6898
  A: [
@@ -6605,8 +6910,8 @@ var InvitationsManager = class {
6605
6910
  invitations: cInvitations.map((invitation) => invitation.get())
6606
6911
  };
6607
6912
  } catch (err) {
6608
- import_log19.log.catch(err, void 0, {
6609
- F: __dxlog_file23,
6913
+ import_log20.log.catch(err, void 0, {
6914
+ F: __dxlog_file24,
6610
6915
  L: 110,
6611
6916
  S: this,
6612
6917
  C: (f, a) => f(...a)
@@ -6637,14 +6942,14 @@ var InvitationsManager = class {
6637
6942
  return invitation;
6638
6943
  }
6639
6944
  async authenticate({ invitationId, authCode }) {
6640
- (0, import_log19.log)("authenticating...", void 0, {
6641
- F: __dxlog_file23,
6945
+ (0, import_log20.log)("authenticating...", void 0, {
6946
+ F: __dxlog_file24,
6642
6947
  L: 140,
6643
6948
  S: this,
6644
6949
  C: (f, a) => f(...a)
6645
6950
  });
6646
- (0, import_invariant18.invariant)(invitationId, void 0, {
6647
- F: __dxlog_file23,
6951
+ (0, import_invariant20.invariant)(invitationId, void 0, {
6952
+ F: __dxlog_file24,
6648
6953
  L: 141,
6649
6954
  S: this,
6650
6955
  A: [
@@ -6654,10 +6959,10 @@ var InvitationsManager = class {
6654
6959
  });
6655
6960
  const observable = this._acceptInvitations.get(invitationId);
6656
6961
  if (!observable) {
6657
- import_log19.log.warn("invalid invitation", {
6962
+ import_log20.log.warn("invalid invitation", {
6658
6963
  invitationId
6659
6964
  }, {
6660
- F: __dxlog_file23,
6965
+ F: __dxlog_file24,
6661
6966
  L: 144,
6662
6967
  S: this,
6663
6968
  C: (f, a) => f(...a)
@@ -6667,16 +6972,16 @@ var InvitationsManager = class {
6667
6972
  }
6668
6973
  }
6669
6974
  async cancelInvitation({ invitationId }) {
6670
- (0, import_log19.log)("cancelInvitation...", {
6975
+ (0, import_log20.log)("cancelInvitation...", {
6671
6976
  invitationId
6672
6977
  }, {
6673
- F: __dxlog_file23,
6978
+ F: __dxlog_file24,
6674
6979
  L: 151,
6675
6980
  S: this,
6676
6981
  C: (f, a) => f(...a)
6677
6982
  });
6678
- (0, import_invariant18.invariant)(invitationId, void 0, {
6679
- F: __dxlog_file23,
6983
+ (0, import_invariant20.invariant)(invitationId, void 0, {
6984
+ F: __dxlog_file24,
6680
6985
  L: 152,
6681
6986
  S: this,
6682
6987
  A: [
@@ -6723,7 +7028,7 @@ var InvitationsManager = class {
6723
7028
  }
6724
7029
  }
6725
7030
  _createInvitation(protocol, _options) {
6726
- const { invitationId = import_keys14.PublicKey.random().toHex(), type = import_services18.Invitation.Type.INTERACTIVE, authMethod = import_services18.Invitation.AuthMethod.SHARED_SECRET, state = import_services18.Invitation.State.INIT, timeout = import_client_protocol6.INVITATION_TIMEOUT, swarmKey = import_keys14.PublicKey.random(), persistent = _options?.authMethod !== import_services18.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials21.SpaceMember.Role.ADMIN, lifetime = 86400 * 7, multiUse = false, ...options } = _options ?? {};
7031
+ const { invitationId = import_keys15.PublicKey.random().toHex(), type = import_services18.Invitation.Type.INTERACTIVE, authMethod = import_services18.Invitation.AuthMethod.SHARED_SECRET, state = import_services18.Invitation.State.INIT, timeout = import_client_protocol6.INVITATION_TIMEOUT, swarmKey = import_keys15.PublicKey.random(), persistent = _options?.authMethod !== import_services18.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials21.SpaceMember.Role.ADMIN, lifetime = 86400 * 7, multiUse = false, ...options } = _options ?? {};
6727
7032
  const authCode = options?.authCode ?? (authMethod === import_services18.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials20.generatePasscode)(import_client_protocol6.AUTHENTICATION_CODE_LENGTH) : void 0);
6728
7033
  return {
6729
7034
  invitationId,
@@ -6746,20 +7051,20 @@ var InvitationsManager = class {
6746
7051
  }
6747
7052
  _createObservableInvitation(handler, invitation) {
6748
7053
  const stream = new import_async20.PushStream();
6749
- const ctx = new import_context14.Context({
7054
+ const ctx = new import_context15.Context({
6750
7055
  onError: (err) => {
6751
7056
  stream.error(err);
6752
7057
  void ctx.dispose();
6753
7058
  }
6754
7059
  }, {
6755
- F: __dxlog_file23,
7060
+ F: __dxlog_file24,
6756
7061
  L: 236
6757
7062
  });
6758
7063
  ctx.onDispose(() => {
6759
- (0, import_log19.log)("complete", {
7064
+ (0, import_log20.log)("complete", {
6760
7065
  ...handler.toJSON()
6761
7066
  }, {
6762
- F: __dxlog_file23,
7067
+ F: __dxlog_file24,
6763
7068
  L: 243,
6764
7069
  S: this,
6765
7070
  C: (f, a) => f(...a)
@@ -6786,13 +7091,13 @@ var InvitationsManager = class {
6786
7091
  _createObservableAcceptingInvitation(handler, initialState) {
6787
7092
  const otpEnteredTrigger = new import_async20.Trigger();
6788
7093
  const stream = new import_async20.PushStream();
6789
- const ctx = new import_context14.Context({
7094
+ const ctx = new import_context15.Context({
6790
7095
  onError: (err) => {
6791
7096
  if (err instanceof import_async20.TimeoutError) {
6792
- (0, import_log19.log)("timeout", {
7097
+ (0, import_log20.log)("timeout", {
6793
7098
  ...handler.toJSON()
6794
7099
  }, {
6795
- F: __dxlog_file23,
7100
+ F: __dxlog_file24,
6796
7101
  L: 263,
6797
7102
  S: this,
6798
7103
  C: (f, a) => f(...a)
@@ -6802,8 +7107,8 @@ var InvitationsManager = class {
6802
7107
  state: import_services18.Invitation.State.TIMEOUT
6803
7108
  });
6804
7109
  } else {
6805
- import_log19.log.warn("auth failed", err, {
6806
- F: __dxlog_file23,
7110
+ import_log20.log.warn("auth failed", err, {
7111
+ F: __dxlog_file24,
6807
7112
  L: 266,
6808
7113
  S: this,
6809
7114
  C: (f, a) => f(...a)
@@ -6816,14 +7121,14 @@ var InvitationsManager = class {
6816
7121
  void ctx.dispose();
6817
7122
  }
6818
7123
  }, {
6819
- F: __dxlog_file23,
7124
+ F: __dxlog_file24,
6820
7125
  L: 260
6821
7126
  });
6822
7127
  ctx.onDispose(() => {
6823
- (0, import_log19.log)("complete", {
7128
+ (0, import_log20.log)("complete", {
6824
7129
  ...handler.toJSON()
6825
7130
  }, {
6826
- F: __dxlog_file23,
7131
+ F: __dxlog_file24,
6827
7132
  L: 273,
6828
7133
  S: this,
6829
7134
  C: (f, a) => f(...a)
@@ -6867,8 +7172,8 @@ var InvitationsManager = class {
6867
7172
  try {
6868
7173
  await this._metadataStore.removeInvitation(invitation.invitationId);
6869
7174
  } catch (err) {
6870
- import_log19.log.catch(err, void 0, {
6871
- F: __dxlog_file23,
7175
+ import_log20.log.catch(err, void 0, {
7176
+ F: __dxlog_file24,
6872
7177
  L: 309,
6873
7178
  S: this,
6874
7179
  C: (f, a) => f(...a)
@@ -6887,7 +7192,7 @@ function _ts_decorate7(decorators, target, key, desc) {
6887
7192
  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;
6888
7193
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6889
7194
  }
6890
- var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
7195
+ var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
6891
7196
  var Lock = class {
6892
7197
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
6893
7198
  this._lockPath = lockPath;
@@ -6898,16 +7203,16 @@ var Lock = class {
6898
7203
  return this._lockPath;
6899
7204
  }
6900
7205
  async acquire() {
6901
- (0, import_log20.log)("acquiring lock...", void 0, {
6902
- F: __dxlog_file24,
7206
+ (0, import_log21.log)("acquiring lock...", void 0, {
7207
+ F: __dxlog_file25,
6903
7208
  L: 32,
6904
7209
  S: this,
6905
7210
  C: (f, a) => f(...a)
6906
7211
  });
6907
7212
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
6908
7213
  await this._onAcquire?.();
6909
- (0, import_log20.log)("acquired lock", void 0, {
6910
- F: __dxlog_file24,
7214
+ (0, import_log21.log)("acquired lock", void 0, {
7215
+ F: __dxlog_file25,
6911
7216
  L: 37,
6912
7217
  S: this,
6913
7218
  C: (f, a) => f(...a)
@@ -6915,8 +7220,8 @@ var Lock = class {
6915
7220
  }
6916
7221
  async release() {
6917
7222
  await this._onRelease?.();
6918
- (0, import_invariant19.invariant)(this._fileHandle, "Lock is not acquired", {
6919
- F: __dxlog_file24,
7223
+ (0, import_invariant21.invariant)(this._fileHandle, "Lock is not acquired", {
7224
+ F: __dxlog_file25,
6920
7225
  L: 42,
6921
7226
  S: this,
6922
7227
  A: [
@@ -6928,7 +7233,7 @@ var Lock = class {
6928
7233
  }
6929
7234
  };
6930
7235
  _ts_decorate7([
6931
- import_log20.logInfo
7236
+ import_log21.logInfo
6932
7237
  ], Lock.prototype, "lockKey", null);
6933
7238
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
6934
7239
  function _ts_decorate8(decorators, target, key, desc) {
@@ -7008,11 +7313,11 @@ function _ts_decorate9(decorators, target, key, desc) {
7008
7313
  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;
7009
7314
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7010
7315
  }
7011
- var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/agents/edge-agent-manager.ts";
7316
+ var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/agents/edge-agent-manager.ts";
7012
7317
  var AGENT_STATUS_QUERY_RETRY_INTERVAL = 5e3;
7013
7318
  var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
7014
7319
  var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
7015
- var EdgeAgentManager = class extends import_context15.Resource {
7320
+ var EdgeAgentManager = class extends import_context16.Resource {
7016
7321
  constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7017
7322
  super();
7018
7323
  this._edgeFeatures = _edgeFeatures;
@@ -7026,11 +7331,11 @@ var EdgeAgentManager = class extends import_context15.Resource {
7026
7331
  return this._agentStatus;
7027
7332
  }
7028
7333
  get agentExists() {
7029
- return this._agentStatus && this._agentStatus !== import_protocols14.EdgeAgentStatus.NOT_FOUND;
7334
+ return this._agentStatus && this._agentStatus !== import_protocols16.EdgeAgentStatus.NOT_FOUND;
7030
7335
  }
7031
7336
  async createAgent() {
7032
- (0, import_invariant20.invariant)(this.isOpen, void 0, {
7033
- F: __dxlog_file25,
7337
+ (0, import_invariant22.invariant)(this.isOpen, void 0, {
7338
+ F: __dxlog_file26,
7034
7339
  L: 54,
7035
7340
  S: this,
7036
7341
  A: [
@@ -7038,8 +7343,8 @@ var EdgeAgentManager = class extends import_context15.Resource {
7038
7343
  ""
7039
7344
  ]
7040
7345
  });
7041
- (0, import_invariant20.invariant)(this._edgeHttpClient, void 0, {
7042
- F: __dxlog_file25,
7346
+ (0, import_invariant22.invariant)(this._edgeHttpClient, void 0, {
7347
+ F: __dxlog_file26,
7043
7348
  L: 55,
7044
7349
  S: this,
7045
7350
  A: [
@@ -7047,8 +7352,8 @@ var EdgeAgentManager = class extends import_context15.Resource {
7047
7352
  ""
7048
7353
  ]
7049
7354
  });
7050
- (0, import_invariant20.invariant)(this._edgeFeatures?.agents, void 0, {
7051
- F: __dxlog_file25,
7355
+ (0, import_invariant22.invariant)(this._edgeFeatures?.agents, void 0, {
7356
+ F: __dxlog_file26,
7052
7357
  L: 56,
7053
7358
  S: this,
7054
7359
  A: [
@@ -7061,39 +7366,39 @@ var EdgeAgentManager = class extends import_context15.Resource {
7061
7366
  haloSpaceId: this._identity.haloSpaceId,
7062
7367
  haloSpaceKey: this._identity.haloSpaceKey.toHex()
7063
7368
  });
7064
- const deviceKey = import_keys15.PublicKey.fromHex(response.deviceKey);
7369
+ const deviceKey = import_keys16.PublicKey.fromHex(response.deviceKey);
7065
7370
  if (await this._identity.authorizedDeviceKeys.has(deviceKey)) {
7066
- import_log21.log.info("agent was already added to HALO, ignoring response", {
7371
+ import_log22.log.info("agent was already added to HALO, ignoring response", {
7067
7372
  response
7068
7373
  }, {
7069
- F: __dxlog_file25,
7374
+ F: __dxlog_file26,
7070
7375
  L: 67,
7071
7376
  S: this,
7072
7377
  C: (f, a) => f(...a)
7073
7378
  });
7074
- this._updateStatus(import_protocols14.EdgeAgentStatus.ACTIVE, deviceKey);
7379
+ this._updateStatus(import_protocols16.EdgeAgentStatus.ACTIVE, deviceKey);
7075
7380
  return;
7076
7381
  }
7077
7382
  await this._identity.admitDevice({
7078
7383
  deviceKey,
7079
- controlFeedKey: import_keys15.PublicKey.fromHex(response.feedKey),
7384
+ controlFeedKey: import_keys16.PublicKey.fromHex(response.feedKey),
7080
7385
  // TODO: agents don't have data feed, should be removed
7081
- dataFeedKey: import_keys15.PublicKey.random()
7386
+ dataFeedKey: import_keys16.PublicKey.random()
7082
7387
  });
7083
- (0, import_log21.log)("agent created", response, {
7084
- F: __dxlog_file25,
7388
+ (0, import_log22.log)("agent created", response, {
7389
+ F: __dxlog_file26,
7085
7390
  L: 79,
7086
7391
  S: this,
7087
7392
  C: (f, a) => f(...a)
7088
7393
  });
7089
- this._updateStatus(import_protocols14.EdgeAgentStatus.ACTIVE, deviceKey);
7394
+ this._updateStatus(import_protocols16.EdgeAgentStatus.ACTIVE, deviceKey);
7090
7395
  }
7091
7396
  async _open() {
7092
7397
  const isEnabled = this._edgeHttpClient && this._edgeFeatures?.agents;
7093
- (0, import_log21.log)("edge agent manager open", {
7398
+ (0, import_log22.log)("edge agent manager open", {
7094
7399
  isEnabled
7095
7400
  }, {
7096
- F: __dxlog_file25,
7401
+ F: __dxlog_file26,
7097
7402
  L: 87,
7098
7403
  S: this,
7099
7404
  C: (f, a) => f(...a)
@@ -7125,8 +7430,8 @@ var EdgeAgentManager = class extends import_context15.Resource {
7125
7430
  this._lastKnownDeviceCount = 0;
7126
7431
  }
7127
7432
  async _fetchAgentStatus() {
7128
- (0, import_invariant20.invariant)(this._edgeHttpClient, void 0, {
7129
- F: __dxlog_file25,
7433
+ (0, import_invariant22.invariant)(this._edgeHttpClient, void 0, {
7434
+ F: __dxlog_file26,
7130
7435
  L: 121,
7131
7436
  S: this,
7132
7437
  A: [
@@ -7135,8 +7440,8 @@ var EdgeAgentManager = class extends import_context15.Resource {
7135
7440
  ]
7136
7441
  });
7137
7442
  try {
7138
- (0, import_log21.log)("fetching agent status", void 0, {
7139
- F: __dxlog_file25,
7443
+ (0, import_log22.log)("fetching agent status", void 0, {
7444
+ F: __dxlog_file26,
7140
7445
  L: 123,
7141
7446
  S: this,
7142
7447
  C: (f, a) => f(...a)
@@ -7144,18 +7449,18 @@ var EdgeAgentManager = class extends import_context15.Resource {
7144
7449
  const { agent } = await this._edgeHttpClient.getAgentStatus({
7145
7450
  ownerIdentityKey: this._identity.identityKey
7146
7451
  });
7147
- const wasAgentCreatedDuringQuery = this._agentStatus === import_protocols14.EdgeAgentStatus.ACTIVE;
7452
+ const wasAgentCreatedDuringQuery = this._agentStatus === import_protocols16.EdgeAgentStatus.ACTIVE;
7148
7453
  if (!wasAgentCreatedDuringQuery) {
7149
- const deviceKey = agent.deviceKey ? import_keys15.PublicKey.fromHex(agent.deviceKey) : void 0;
7454
+ const deviceKey = agent.deviceKey ? import_keys16.PublicKey.fromHex(agent.deviceKey) : void 0;
7150
7455
  this._updateStatus(agent.status, deviceKey);
7151
7456
  }
7152
7457
  } catch (err) {
7153
- if (err instanceof import_protocols14.EdgeCallFailedError) {
7458
+ if (err instanceof import_protocols16.EdgeCallFailedError) {
7154
7459
  if (!err.isRetryable) {
7155
- import_log21.log.warn("non retryable error on agent status fetch attempt", {
7460
+ import_log22.log.warn("non retryable error on agent status fetch attempt", {
7156
7461
  err
7157
7462
  }, {
7158
- F: __dxlog_file25,
7463
+ F: __dxlog_file26,
7159
7464
  L: 133,
7160
7465
  S: this,
7161
7466
  C: (f, a) => f(...a)
@@ -7164,11 +7469,11 @@ var EdgeAgentManager = class extends import_context15.Resource {
7164
7469
  }
7165
7470
  }
7166
7471
  const retryAfterMs = AGENT_STATUS_QUERY_RETRY_INTERVAL + Math.random() * AGENT_STATUS_QUERY_RETRY_JITTER;
7167
- import_log21.log.info("agent status fetching failed", {
7472
+ import_log22.log.info("agent status fetching failed", {
7168
7473
  err,
7169
7474
  retryAfterMs
7170
7475
  }, {
7171
- F: __dxlog_file25,
7476
+ F: __dxlog_file26,
7172
7477
  L: 138,
7173
7478
  S: this,
7174
7479
  C: (f, a) => f(...a)
@@ -7200,11 +7505,11 @@ var EdgeAgentManager = class extends import_context15.Resource {
7200
7505
  ].some((feed) => feed.assertion.deviceKey.equals(agentDeviceKey));
7201
7506
  space.notarizationPlugin.setActiveEdgePollingEnabled(agentFeedNeedsNotarization);
7202
7507
  activePollingEnabled = activePollingEnabled || agentFeedNeedsNotarization;
7203
- import_log21.log.info("set active edge polling", {
7508
+ import_log22.log.info("set active edge polling", {
7204
7509
  enabled: agentFeedNeedsNotarization,
7205
7510
  spaceId: space.id
7206
7511
  }, {
7207
- F: __dxlog_file25,
7512
+ F: __dxlog_file26,
7208
7513
  L: 165,
7209
7514
  S: this,
7210
7515
  C: (f, a) => f(...a)
@@ -7221,10 +7526,10 @@ var EdgeAgentManager = class extends import_context15.Resource {
7221
7526
  if (deviceKey) {
7222
7527
  this._ensureAgentIsInSpaces(deviceKey);
7223
7528
  }
7224
- import_log21.log.info("agent status update", {
7529
+ import_log22.log.info("agent status update", {
7225
7530
  status
7226
7531
  }, {
7227
- F: __dxlog_file25,
7532
+ F: __dxlog_file26,
7228
7533
  L: 181,
7229
7534
  S: this,
7230
7535
  C: (f, a) => f(...a)
@@ -7280,17 +7585,17 @@ var EdgeAgentServiceImpl = class {
7280
7585
  };
7281
7586
  var mapStatus = (agentStatus) => {
7282
7587
  switch (agentStatus) {
7283
- case import_protocols15.EdgeAgentStatus.ACTIVE:
7588
+ case import_protocols17.EdgeAgentStatus.ACTIVE:
7284
7589
  return import_services20.QueryAgentStatusResponse.AgentStatus.ACTIVE;
7285
- case import_protocols15.EdgeAgentStatus.INACTIVE:
7590
+ case import_protocols17.EdgeAgentStatus.INACTIVE:
7286
7591
  return import_services20.QueryAgentStatusResponse.AgentStatus.INACTIVE;
7287
- case import_protocols15.EdgeAgentStatus.NOT_FOUND:
7592
+ case import_protocols17.EdgeAgentStatus.NOT_FOUND:
7288
7593
  return import_services20.QueryAgentStatusResponse.AgentStatus.NOT_FOUND;
7289
7594
  case void 0:
7290
7595
  return import_services20.QueryAgentStatusResponse.AgentStatus.UNKNOWN;
7291
7596
  }
7292
7597
  };
7293
- var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts";
7598
+ var __dxlog_file27 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts";
7294
7599
  var EdgeIdentityRecoveryManager = class {
7295
7600
  constructor(_keyring, _edgeClient, _identityProvider, _acceptRecoveredIdentity) {
7296
7601
  this._keyring = _keyring;
@@ -7300,8 +7605,8 @@ var EdgeIdentityRecoveryManager = class {
7300
7605
  }
7301
7606
  async createRecoveryCredential({ data }) {
7302
7607
  const identity = this._identityProvider();
7303
- (0, import_invariant22.invariant)(identity, void 0, {
7304
- F: __dxlog_file26,
7608
+ (0, import_invariant24.invariant)(identity, void 0, {
7609
+ F: __dxlog_file27,
7305
7610
  L: 37,
7306
7611
  S: this,
7307
7612
  A: [
@@ -7320,8 +7625,8 @@ var EdgeIdentityRecoveryManager = class {
7320
7625
  } else {
7321
7626
  recoveryCode = (0, import_credentials23.generateSeedPhrase)();
7322
7627
  const keypair = (0, import_credentials23.keyPairFromSeedPhrase)(recoveryCode);
7323
- recoveryKey = import_keys17.PublicKey.from(keypair.publicKey);
7324
- lookupKey = import_keys17.PublicKey.from(keypair.publicKey);
7628
+ recoveryKey = import_keys18.PublicKey.from(keypair.publicKey);
7629
+ lookupKey = import_keys18.PublicKey.from(keypair.publicKey);
7325
7630
  algorithm = "ED25519";
7326
7631
  }
7327
7632
  const identityKey = identity.identityKey;
@@ -7351,8 +7656,8 @@ var EdgeIdentityRecoveryManager = class {
7351
7656
  };
7352
7657
  }
7353
7658
  async requestRecoveryChallenge() {
7354
- (0, import_invariant22.invariant)(this._edgeClient, "Not connected to EDGE.", {
7355
- F: __dxlog_file26,
7659
+ (0, import_invariant24.invariant)(this._edgeClient, "Not connected to EDGE.", {
7660
+ F: __dxlog_file27,
7356
7661
  L: 74,
7357
7662
  S: this,
7358
7663
  A: [
@@ -7370,7 +7675,7 @@ var EdgeIdentityRecoveryManager = class {
7370
7675
  await this._edgeClient.recoverIdentity(request);
7371
7676
  throw new Error("No challenge received.");
7372
7677
  } catch (error) {
7373
- if (!(error instanceof import_protocols17.EdgeAuthChallengeError)) {
7678
+ if (!(error instanceof import_protocols19.EdgeAuthChallengeError)) {
7374
7679
  throw error;
7375
7680
  }
7376
7681
  return {
@@ -7381,8 +7686,8 @@ var EdgeIdentityRecoveryManager = class {
7381
7686
  }
7382
7687
  }
7383
7688
  async recoverIdentityWithExternalSignature({ lookupKey, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7384
- (0, import_invariant22.invariant)(this._edgeClient, "Not connected to EDGE.", {
7385
- F: __dxlog_file26,
7689
+ (0, import_invariant24.invariant)(this._edgeClient, "Not connected to EDGE.", {
7690
+ F: __dxlog_file27,
7386
7691
  L: 106,
7387
7692
  S: this,
7388
7693
  A: [
@@ -7403,18 +7708,49 @@ var EdgeIdentityRecoveryManager = class {
7403
7708
  const response = await this._edgeClient.recoverIdentity(request);
7404
7709
  await this._acceptRecoveredIdentity({
7405
7710
  authorizedDeviceCredential: decodeCredential(response.deviceAuthCredential),
7406
- haloGenesisFeedKey: import_keys17.PublicKey.fromHex(response.genesisFeedKey),
7407
- haloSpaceKey: import_keys17.PublicKey.fromHex(response.haloSpaceKey),
7408
- identityKey: import_keys17.PublicKey.fromHex(response.identityKey),
7711
+ haloGenesisFeedKey: import_keys18.PublicKey.fromHex(response.genesisFeedKey),
7712
+ haloSpaceKey: import_keys18.PublicKey.fromHex(response.haloSpaceKey),
7713
+ identityKey: import_keys18.PublicKey.fromHex(response.identityKey),
7714
+ deviceKey,
7715
+ controlFeedKey,
7716
+ dataFeedKey: await this._keyring.createKey()
7717
+ });
7718
+ }
7719
+ /**
7720
+ * Recovery identity using an opaque token sent to the user's email.
7721
+ */
7722
+ async recoverIdentityWithToken({ token }) {
7723
+ (0, import_invariant24.invariant)(this._edgeClient, "Not connected to EDGE.", {
7724
+ F: __dxlog_file27,
7725
+ L: 139,
7726
+ S: this,
7727
+ A: [
7728
+ "this._edgeClient",
7729
+ "'Not connected to EDGE.'"
7730
+ ]
7731
+ });
7732
+ const deviceKey = await this._keyring.createKey();
7733
+ const controlFeedKey = await this._keyring.createKey();
7734
+ const request = {
7735
+ deviceKey: deviceKey.toHex(),
7736
+ controlFeedKey: controlFeedKey.toHex(),
7737
+ token
7738
+ };
7739
+ const response = await this._edgeClient.recoverIdentity(request);
7740
+ await this._acceptRecoveredIdentity({
7741
+ authorizedDeviceCredential: decodeCredential(response.deviceAuthCredential),
7742
+ haloGenesisFeedKey: import_keys18.PublicKey.fromHex(response.genesisFeedKey),
7743
+ haloSpaceKey: import_keys18.PublicKey.fromHex(response.haloSpaceKey),
7744
+ identityKey: import_keys18.PublicKey.fromHex(response.identityKey),
7409
7745
  deviceKey,
7410
7746
  controlFeedKey,
7411
7747
  dataFeedKey: await this._keyring.createKey()
7412
7748
  });
7413
7749
  }
7414
7750
  async recoverIdentity({ recoveryCode }) {
7415
- (0, import_invariant22.invariant)(this._edgeClient, "Not connected to EDGE.", {
7416
- F: __dxlog_file26,
7417
- L: 136,
7751
+ (0, import_invariant24.invariant)(this._edgeClient, "Not connected to EDGE.", {
7752
+ F: __dxlog_file27,
7753
+ L: 163,
7418
7754
  S: this,
7419
7755
  A: [
7420
7756
  "this._edgeClient",
@@ -7422,7 +7758,7 @@ var EdgeIdentityRecoveryManager = class {
7422
7758
  ]
7423
7759
  });
7424
7760
  const recoveryKeypair = (0, import_credentials23.keyPairFromSeedPhrase)(recoveryCode);
7425
- const recoveryKey = import_keys17.PublicKey.from(recoveryKeypair.publicKey);
7761
+ const recoveryKey = import_keys18.PublicKey.from(recoveryKeypair.publicKey);
7426
7762
  const deviceKey = await this._keyring.createKey();
7427
7763
  const controlFeedKey = await this._keyring.createKey();
7428
7764
  const request = {
@@ -7434,7 +7770,7 @@ var EdgeIdentityRecoveryManager = class {
7434
7770
  try {
7435
7771
  response = await this._edgeClient.recoverIdentity(request);
7436
7772
  } catch (error) {
7437
- if (!(error instanceof import_protocols17.EdgeAuthChallengeError)) {
7773
+ if (!(error instanceof import_protocols19.EdgeAuthChallengeError)) {
7438
7774
  throw error;
7439
7775
  }
7440
7776
  const signature = (0, import_crypto4.sign)(Buffer.from(error.challenge, "base64"), recoveryKeypair.secretKey);
@@ -7443,17 +7779,17 @@ var EdgeIdentityRecoveryManager = class {
7443
7779
  signature: Buffer.from(signature).toString("base64")
7444
7780
  });
7445
7781
  }
7446
- import_log23.log.info("recovering identity", response, {
7447
- F: __dxlog_file26,
7448
- L: 162,
7782
+ import_log24.log.info("recovering identity", response, {
7783
+ F: __dxlog_file27,
7784
+ L: 189,
7449
7785
  S: this,
7450
7786
  C: (f, a) => f(...a)
7451
7787
  });
7452
7788
  await this._acceptRecoveredIdentity({
7453
7789
  authorizedDeviceCredential: decodeCredential(response.deviceAuthCredential),
7454
- haloGenesisFeedKey: import_keys17.PublicKey.fromHex(response.genesisFeedKey),
7455
- haloSpaceKey: import_keys17.PublicKey.fromHex(response.haloSpaceKey),
7456
- identityKey: import_keys17.PublicKey.fromHex(response.identityKey),
7790
+ haloGenesisFeedKey: import_keys18.PublicKey.fromHex(response.genesisFeedKey),
7791
+ haloSpaceKey: import_keys18.PublicKey.fromHex(response.haloSpaceKey),
7792
+ identityKey: import_keys18.PublicKey.fromHex(response.identityKey),
7457
7793
  deviceKey,
7458
7794
  controlFeedKey,
7459
7795
  dataFeedKey: await this._keyring.createKey()
@@ -7471,7 +7807,7 @@ function _ts_decorate10(decorators, target, key, desc) {
7471
7807
  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;
7472
7808
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7473
7809
  }
7474
- function _using_ctx3() {
7810
+ function _using_ctx4() {
7475
7811
  var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
7476
7812
  var err = new Error();
7477
7813
  err.name = "SuppressedError";
@@ -7533,8 +7869,8 @@ function _using_ctx3() {
7533
7869
  }
7534
7870
  };
7535
7871
  }
7536
- var __dxlog_file27 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
7537
- var ServiceContext = class extends import_context16.Resource {
7872
+ var __dxlog_file28 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
7873
+ var ServiceContext = class extends import_context17.Resource {
7538
7874
  constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
7539
7875
  super();
7540
7876
  this.storage = storage;
@@ -7550,7 +7886,7 @@ var ServiceContext = class extends import_context16.Resource {
7550
7886
  this._meshReplicator = void 0;
7551
7887
  this._echoEdgeReplicator = void 0;
7552
7888
  this._handlerFactories = /* @__PURE__ */ new Map();
7553
- this._instanceId = import_keys16.PublicKey.random().toHex();
7889
+ this._instanceId = import_keys17.PublicKey.random().toHex();
7554
7890
  this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
7555
7891
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
7556
7892
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
@@ -7602,16 +7938,16 @@ var ServiceContext = class extends import_context16.Resource {
7602
7938
  }
7603
7939
  async _open(ctx) {
7604
7940
  await this._checkStorageVersion();
7605
- (0, import_log22.log)("opening...", void 0, {
7606
- F: __dxlog_file27,
7941
+ (0, import_log23.log)("opening...", void 0, {
7942
+ F: __dxlog_file28,
7607
7943
  L: 199,
7608
7944
  S: this,
7609
7945
  C: (f, a) => f(...a)
7610
7946
  });
7611
- import_log22.log.trace("dxos.sdk.service-context.open", import_protocols16.trace.begin({
7947
+ import_log23.log.trace("dxos.sdk.service-context.open", import_protocols18.trace.begin({
7612
7948
  id: this._instanceId
7613
7949
  }), {
7614
- F: __dxlog_file27,
7950
+ F: __dxlog_file28,
7615
7951
  L: 200,
7616
7952
  S: this,
7617
7953
  C: (f, a) => f(...a)
@@ -7635,32 +7971,32 @@ var ServiceContext = class extends import_context16.Resource {
7635
7971
  await this._initialize(ctx);
7636
7972
  }
7637
7973
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
7638
- (0, import_log22.log)("loaded persistent invitations", {
7974
+ (0, import_log23.log)("loaded persistent invitations", {
7639
7975
  count: loadedInvitations.invitations?.length
7640
7976
  }, {
7641
- F: __dxlog_file27,
7977
+ F: __dxlog_file28,
7642
7978
  L: 228,
7643
7979
  S: this,
7644
7980
  C: (f, a) => f(...a)
7645
7981
  });
7646
- import_log22.log.trace("dxos.sdk.service-context.open", import_protocols16.trace.end({
7982
+ import_log23.log.trace("dxos.sdk.service-context.open", import_protocols18.trace.end({
7647
7983
  id: this._instanceId
7648
7984
  }), {
7649
- F: __dxlog_file27,
7985
+ F: __dxlog_file28,
7650
7986
  L: 230,
7651
7987
  S: this,
7652
7988
  C: (f, a) => f(...a)
7653
7989
  });
7654
- (0, import_log22.log)("opened", void 0, {
7655
- F: __dxlog_file27,
7990
+ (0, import_log23.log)("opened", void 0, {
7991
+ F: __dxlog_file28,
7656
7992
  L: 231,
7657
7993
  S: this,
7658
7994
  C: (f, a) => f(...a)
7659
7995
  });
7660
7996
  }
7661
7997
  async _close(ctx) {
7662
- (0, import_log22.log)("closing...", void 0, {
7663
- F: __dxlog_file27,
7998
+ (0, import_log23.log)("closing...", void 0, {
7999
+ F: __dxlog_file28,
7664
8000
  L: 235,
7665
8001
  S: this,
7666
8002
  C: (f, a) => f(...a)
@@ -7678,8 +8014,8 @@ var ServiceContext = class extends import_context16.Resource {
7678
8014
  await this.networkManager.close();
7679
8015
  await this.signalManager.close();
7680
8016
  await this._edgeConnection?.close();
7681
- (0, import_log22.log)("closed", void 0, {
7682
- F: __dxlog_file27,
8017
+ (0, import_log23.log)("closed", void 0, {
8018
+ F: __dxlog_file28,
7683
8019
  L: 251,
7684
8020
  S: this,
7685
8021
  C: (f, a) => f(...a)
@@ -7689,8 +8025,8 @@ var ServiceContext = class extends import_context16.Resource {
7689
8025
  const identity = await this.identityManager.createIdentity(params);
7690
8026
  await this._setNetworkIdentity();
7691
8027
  await identity.joinNetwork();
7692
- await this._initialize(new import_context16.Context(void 0, {
7693
- F: __dxlog_file27,
8028
+ await this._initialize(new import_context17.Context(void 0, {
8029
+ F: __dxlog_file28,
7694
8030
  L: 258
7695
8031
  }));
7696
8032
  return identity;
@@ -7700,8 +8036,8 @@ var ServiceContext = class extends import_context16.Resource {
7700
8036
  throw new Error("Identity must be created before joining a space.");
7701
8037
  }
7702
8038
  const factory = this._handlerFactories.get(invitation.kind);
7703
- (0, import_invariant21.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
7704
- F: __dxlog_file27,
8039
+ (0, import_invariant23.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
8040
+ F: __dxlog_file28,
7705
8041
  L: 267,
7706
8042
  S: this,
7707
8043
  A: [
@@ -7726,22 +8062,22 @@ var ServiceContext = class extends import_context16.Resource {
7726
8062
  });
7727
8063
  await identity.joinNetwork();
7728
8064
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
7729
- await this._initialize(new import_context16.Context(void 0, {
7730
- F: __dxlog_file27,
8065
+ await this._initialize(new import_context17.Context(void 0, {
8066
+ F: __dxlog_file28,
7731
8067
  L: 286
7732
8068
  }));
7733
8069
  return identity;
7734
8070
  }
7735
8071
  async _checkStorageVersion() {
7736
8072
  await this.metadataStore.load();
7737
- if (this.metadataStore.version !== import_protocols16.STORAGE_VERSION) {
7738
- throw new import_protocols16.InvalidStorageVersionError(import_protocols16.STORAGE_VERSION, this.metadataStore.version);
8073
+ if (this.metadataStore.version !== import_protocols18.STORAGE_VERSION) {
8074
+ throw new import_protocols18.InvalidStorageVersionError(import_protocols18.STORAGE_VERSION, this.metadataStore.version);
7739
8075
  }
7740
8076
  }
7741
8077
  // Called when identity is created.
7742
8078
  async _initialize(ctx) {
7743
- (0, import_log22.log)("initializing spaces...", void 0, {
7744
- F: __dxlog_file27,
8079
+ (0, import_log23.log)("initializing spaces...", void 0, {
8080
+ F: __dxlog_file28,
7745
8081
  L: 301,
7746
8082
  S: this,
7747
8083
  C: (f, a) => f(...a)
@@ -7779,8 +8115,8 @@ var ServiceContext = class extends import_context16.Resource {
7779
8115
  this.edgeAgentManager = new EdgeAgentManager(this._edgeFeatures, this._edgeHttpClient, this.dataSpaceManager, identity);
7780
8116
  await this.edgeAgentManager.open();
7781
8117
  this._handlerFactories.set(import_services21.Invitation.Kind.SPACE, (invitation) => {
7782
- (0, import_invariant21.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7783
- F: __dxlog_file27,
8118
+ (0, import_invariant23.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8119
+ F: __dxlog_file28,
7784
8120
  L: 339,
7785
8121
  S: this,
7786
8122
  A: [
@@ -7801,10 +8137,10 @@ var ServiceContext = class extends import_context16.Resource {
7801
8137
  return;
7802
8138
  }
7803
8139
  if (!this.dataSpaceManager) {
7804
- (0, import_log22.log)("dataSpaceManager not initialized yet, ignoring space admission", {
8140
+ (0, import_log23.log)("dataSpaceManager not initialized yet, ignoring space admission", {
7805
8141
  details: assertion
7806
8142
  }, {
7807
- F: __dxlog_file27,
8143
+ F: __dxlog_file28,
7808
8144
  L: 355,
7809
8145
  S: this,
7810
8146
  C: (f, a) => f(...a)
@@ -7812,10 +8148,10 @@ var ServiceContext = class extends import_context16.Resource {
7812
8148
  return;
7813
8149
  }
7814
8150
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
7815
- (0, import_log22.log)("space already exists, ignoring space admission", {
8151
+ (0, import_log23.log)("space already exists, ignoring space admission", {
7816
8152
  details: assertion
7817
8153
  }, {
7818
- F: __dxlog_file27,
8154
+ F: __dxlog_file28,
7819
8155
  L: 359,
7820
8156
  S: this,
7821
8157
  C: (f, a) => f(...a)
@@ -7823,10 +8159,10 @@ var ServiceContext = class extends import_context16.Resource {
7823
8159
  return;
7824
8160
  }
7825
8161
  try {
7826
- (0, import_log22.log)("accepting space recorded in halo", {
8162
+ (0, import_log23.log)("accepting space recorded in halo", {
7827
8163
  details: assertion
7828
8164
  }, {
7829
- F: __dxlog_file27,
8165
+ F: __dxlog_file28,
7830
8166
  L: 364,
7831
8167
  S: this,
7832
8168
  C: (f, a) => f(...a)
@@ -7836,8 +8172,8 @@ var ServiceContext = class extends import_context16.Resource {
7836
8172
  genesisFeedKey: assertion.genesisFeedKey
7837
8173
  });
7838
8174
  } catch (err) {
7839
- import_log22.log.catch(err, void 0, {
7840
- F: __dxlog_file27,
8175
+ import_log23.log.catch(err, void 0, {
8176
+ F: __dxlog_file28,
7841
8177
  L: 370,
7842
8178
  S: this,
7843
8179
  C: (f, a) => f(...a)
@@ -7849,16 +8185,16 @@ var ServiceContext = class extends import_context16.Resource {
7849
8185
  }
7850
8186
  async _setNetworkIdentity(params) {
7851
8187
  try {
7852
- var _usingCtx = _using_ctx3();
8188
+ var _usingCtx = _using_ctx4();
7853
8189
  const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
7854
8190
  let edgeIdentity;
7855
8191
  const identity = this.identityManager.identity;
7856
8192
  if (identity) {
7857
- (0, import_log22.log)("setting identity on edge connection", {
8193
+ (0, import_log23.log)("setting identity on edge connection", {
7858
8194
  identity: identity.identityKey.toHex(),
7859
8195
  swarms: this.networkManager.topics
7860
8196
  }, {
7861
- F: __dxlog_file27,
8197
+ F: __dxlog_file28,
7862
8198
  L: 384,
7863
8199
  S: this,
7864
8200
  C: (f, a) => f(...a)
@@ -7871,8 +8207,8 @@ var ServiceContext = class extends import_context16.Resource {
7871
8207
  await (0, import_debug5.warnAfterTimeout)(1e4, "Waiting for identity to be ready for edge connection", async () => {
7872
8208
  await identity.ready();
7873
8209
  });
7874
- (0, import_invariant21.invariant)(identity.deviceCredentialChain, void 0, {
7875
- F: __dxlog_file27,
8210
+ (0, import_invariant23.invariant)(identity.deviceCredentialChain, void 0, {
8211
+ F: __dxlog_file28,
7876
8212
  L: 403,
7877
8213
  S: this,
7878
8214
  A: [
@@ -7942,16 +8278,16 @@ var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
7942
8278
  var createStorageObjects = (config) => {
7943
8279
  const { persistent = false, keyStore, dataStore } = config ?? {};
7944
8280
  if (persistent && dataStore === StorageDriver.RAM) {
7945
- throw new import_protocols18.InvalidConfigError("RAM storage cannot be used in persistent mode.");
8281
+ throw new import_protocols20.InvalidConfigError("RAM storage cannot be used in persistent mode.");
7946
8282
  }
7947
8283
  if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
7948
- throw new import_protocols18.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
8284
+ throw new import_protocols20.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
7949
8285
  }
7950
8286
  if (persistent && keyStore === StorageDriver.RAM) {
7951
- throw new import_protocols18.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
8287
+ throw new import_protocols20.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
7952
8288
  }
7953
8289
  if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
7954
- throw new import_protocols18.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
8290
+ throw new import_protocols20.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
7955
8291
  }
7956
8292
  return {
7957
8293
  storage: (0, import_random_access_storage.createStorage)({
@@ -7982,14 +8318,14 @@ var toStorageType = (type) => {
7982
8318
  };
7983
8319
  var createLevel = async (config) => {
7984
8320
  const persistent = isPersistent(config);
7985
- const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys18.PublicKey.random().toHex()}`;
8321
+ const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys19.PublicKey.random().toHex()}`;
7986
8322
  const level = (0, import_kv_store.createLevel)(storagePath);
7987
8323
  await level.open();
7988
8324
  return level;
7989
8325
  };
7990
- var __dxlog_file28 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
7991
- var encodeProfileArchive = (profile) => import_automerge_repo.cbor.encode(profile);
7992
- var decodeProfileArchive = (data) => import_automerge_repo.cbor.decode(data);
8326
+ var __dxlog_file29 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
8327
+ var encodeProfileArchive = (profile) => import_automerge_repo2.cbor.encode(profile);
8328
+ var decodeProfileArchive = (data) => import_automerge_repo2.cbor.decode(data);
7993
8329
  var exportProfileData = async ({ storage, level }) => {
7994
8330
  const archive = {
7995
8331
  storage: [],
@@ -8000,10 +8336,10 @@ var exportProfileData = async ({ storage, level }) => {
8000
8336
  {
8001
8337
  const directory = await storage.createDirectory();
8002
8338
  const files = await directory.list();
8003
- import_log24.log.info("begin exporting files", {
8339
+ import_log25.log.info("begin exporting files", {
8004
8340
  count: files.length
8005
8341
  }, {
8006
- F: __dxlog_file28,
8342
+ F: __dxlog_file29,
8007
8343
  L: 30,
8008
8344
  S: void 0,
8009
8345
  C: (f, a) => f(...a)
@@ -8013,23 +8349,23 @@ var exportProfileData = async ({ storage, level }) => {
8013
8349
  const { size } = await file.stat();
8014
8350
  const data = await file.read(0, size);
8015
8351
  archive.storage.push({
8016
- type: import_protocols19.ProfileArchiveEntryType.FILE,
8352
+ type: import_protocols21.ProfileArchiveEntryType.FILE,
8017
8353
  key: filename,
8018
8354
  value: data
8019
8355
  });
8020
8356
  }
8021
- import_log24.log.info("done exporting files", {
8357
+ import_log25.log.info("done exporting files", {
8022
8358
  count: files.length
8023
8359
  }, {
8024
- F: __dxlog_file28,
8360
+ F: __dxlog_file29,
8025
8361
  L: 41,
8026
8362
  S: void 0,
8027
8363
  C: (f, a) => f(...a)
8028
8364
  });
8029
8365
  }
8030
8366
  {
8031
- import_log24.log.info("begin exporting kv pairs", void 0, {
8032
- F: __dxlog_file28,
8367
+ import_log25.log.info("begin exporting kv pairs", void 0, {
8368
+ F: __dxlog_file29,
8033
8369
  L: 45,
8034
8370
  S: void 0,
8035
8371
  C: (f, a) => f(...a)
@@ -8041,16 +8377,16 @@ var exportProfileData = async ({ storage, level }) => {
8041
8377
  let count = 0;
8042
8378
  for await (const [key, value] of iter) {
8043
8379
  archive.storage.push({
8044
- type: import_protocols19.ProfileArchiveEntryType.KEY_VALUE,
8380
+ type: import_protocols21.ProfileArchiveEntryType.KEY_VALUE,
8045
8381
  key,
8046
8382
  value
8047
8383
  });
8048
8384
  count++;
8049
8385
  }
8050
- import_log24.log.info("done exporting kv pairs", {
8386
+ import_log25.log.info("done exporting kv pairs", {
8051
8387
  count
8052
8388
  }, {
8053
- F: __dxlog_file28,
8389
+ F: __dxlog_file29,
8054
8390
  L: 56,
8055
8391
  S: void 0,
8056
8392
  C: (f, a) => f(...a)
@@ -8063,10 +8399,10 @@ var importProfileData = async ({ storage, level }, archive) => {
8063
8399
  let count = 0;
8064
8400
  for (const entry2 of archive.storage) {
8065
8401
  switch (entry2.type) {
8066
- case import_protocols19.ProfileArchiveEntryType.FILE: {
8402
+ case import_protocols21.ProfileArchiveEntryType.FILE: {
8067
8403
  const directory = await storage.createDirectory();
8068
- (0, import_invariant23.invariant)(typeof entry2.key === "string", "Invalid key type", {
8069
- F: __dxlog_file28,
8404
+ (0, import_invariant25.invariant)(typeof entry2.key === "string", "Invalid key type", {
8405
+ F: __dxlog_file29,
8070
8406
  L: 79,
8071
8407
  S: void 0,
8072
8408
  A: [
@@ -8075,8 +8411,8 @@ var importProfileData = async ({ storage, level }, archive) => {
8075
8411
  ]
8076
8412
  });
8077
8413
  const file = await directory.getOrCreateFile(entry2.key);
8078
- (0, import_invariant23.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
8079
- F: __dxlog_file28,
8414
+ (0, import_invariant25.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
8415
+ F: __dxlog_file29,
8080
8416
  L: 81,
8081
8417
  S: void 0,
8082
8418
  A: [
@@ -8088,9 +8424,9 @@ var importProfileData = async ({ storage, level }, archive) => {
8088
8424
  await file.close();
8089
8425
  break;
8090
8426
  }
8091
- case import_protocols19.ProfileArchiveEntryType.KEY_VALUE: {
8092
- (0, import_invariant23.invariant)(entry2.key instanceof Uint8Array, "Invalid key type", {
8093
- F: __dxlog_file28,
8427
+ case import_protocols21.ProfileArchiveEntryType.KEY_VALUE: {
8428
+ (0, import_invariant25.invariant)(entry2.key instanceof Uint8Array, "Invalid key type", {
8429
+ F: __dxlog_file29,
8094
8430
  L: 87,
8095
8431
  S: void 0,
8096
8432
  A: [
@@ -8098,8 +8434,8 @@ var importProfileData = async ({ storage, level }, archive) => {
8098
8434
  "'Invalid key type'"
8099
8435
  ]
8100
8436
  });
8101
- (0, import_invariant23.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
8102
- F: __dxlog_file28,
8437
+ (0, import_invariant25.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
8438
+ F: __dxlog_file29,
8103
8439
  L: 88,
8104
8440
  S: void 0,
8105
8441
  A: [
@@ -8119,27 +8455,27 @@ var importProfileData = async ({ storage, level }, archive) => {
8119
8455
  if (++count % 1e3 === 0) {
8120
8456
  await batch.write();
8121
8457
  batch = level.batch();
8122
- import_log24.log.info("importing", {
8458
+ import_log25.log.info("importing", {
8123
8459
  count,
8124
8460
  total: archive.storage.length,
8125
8461
  progress: `${(count / archive.storage.length * 100).toFixed()}%`
8126
8462
  }, {
8127
- F: __dxlog_file28,
8463
+ F: __dxlog_file29,
8128
8464
  L: 101,
8129
8465
  S: void 0,
8130
8466
  C: (f, a) => f(...a)
8131
8467
  });
8132
8468
  }
8133
8469
  }
8134
- import_log24.log.info("committing changes..", void 0, {
8135
- F: __dxlog_file28,
8470
+ import_log25.log.info("committing changes..", void 0, {
8471
+ F: __dxlog_file29,
8136
8472
  L: 109,
8137
8473
  S: void 0,
8138
8474
  C: (f, a) => f(...a)
8139
8475
  });
8140
8476
  await batch.write();
8141
8477
  };
8142
- var __dxlog_file29 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8478
+ var __dxlog_file30 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8143
8479
  var DevicesServiceImpl = class {
8144
8480
  constructor(_identityManager, _edgeConnection) {
8145
8481
  this._identityManager = _identityManager;
@@ -8157,8 +8493,8 @@ var DevicesServiceImpl = class {
8157
8493
  devices: []
8158
8494
  });
8159
8495
  } else {
8160
- (0, import_invariant25.invariant)(this._identityManager.identity?.presence, "presence not present", {
8161
- F: __dxlog_file29,
8496
+ (0, import_invariant27.invariant)(this._identityManager.identity?.presence, "presence not present", {
8497
+ F: __dxlog_file30,
8162
8498
  L: 36,
8163
8499
  S: this,
8164
8500
  A: [
@@ -8206,7 +8542,7 @@ var DevicesServiceImpl = class {
8206
8542
  presenceSubscribed = true;
8207
8543
  }
8208
8544
  };
8209
- const subscriptions = new import_async24.EventSubscriptions();
8545
+ const subscriptions = new import_async24.SubscriptionList();
8210
8546
  if (this._identityManager.identity) {
8211
8547
  subscribeIdentity();
8212
8548
  subscribePresence();
@@ -8262,7 +8598,7 @@ var ContactsServiceImpl = class {
8262
8598
  });
8263
8599
  }
8264
8600
  return acc;
8265
- }, new import_util15.ComplexMap(import_keys20.PublicKey.hash));
8601
+ }, new import_util15.ComplexMap(import_keys21.PublicKey.hash));
8266
8602
  return {
8267
8603
  contacts: [
8268
8604
  ...contacts.values()
@@ -8270,7 +8606,7 @@ var ContactsServiceImpl = class {
8270
8606
  };
8271
8607
  }
8272
8608
  queryContacts() {
8273
- const subscribedSpaceKeySet = new import_util15.ComplexSet(import_keys20.PublicKey.hash);
8609
+ const subscribedSpaceKeySet = new import_util15.ComplexSet(import_keys21.PublicKey.hash);
8274
8610
  return new import_stream12.Stream(({ next, ctx }) => {
8275
8611
  const pushUpdateTask = new import_async25.UpdateScheduler(ctx, async () => {
8276
8612
  const contacts = await this.getContacts();
@@ -8279,7 +8615,7 @@ var ContactsServiceImpl = class {
8279
8615
  maxFrequency: 2
8280
8616
  });
8281
8617
  (0, import_async25.scheduleTask)(ctx, async () => {
8282
- const subscriptions = new import_async25.EventSubscriptions();
8618
+ const subscriptions = new import_async25.SubscriptionList();
8283
8619
  ctx.onDispose(() => subscriptions.clear());
8284
8620
  const subscribeToSpaceAndUpdate = () => {
8285
8621
  const oldSetSize = subscribedSpaceKeySet.size;
@@ -8304,17 +8640,17 @@ var LoggingServiceImpl = class {
8304
8640
  constructor() {
8305
8641
  this._logs = new import_async26.Event();
8306
8642
  this._started = Date.now();
8307
- this._sessionId = import_keys21.PublicKey.random().toHex();
8643
+ this._sessionId = import_keys22.PublicKey.random().toHex();
8308
8644
  this._logProcessor = (_config, entry2) => {
8309
8645
  this._logs.emit(entry2);
8310
8646
  };
8311
8647
  }
8312
8648
  async open() {
8313
- import_log26.log.runtimeConfig.processors.push(this._logProcessor);
8649
+ import_log27.log.runtimeConfig.processors.push(this._logProcessor);
8314
8650
  }
8315
8651
  async close() {
8316
- const index = import_log26.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
8317
- import_log26.log.runtimeConfig.processors.splice(index, 1);
8652
+ const index = import_log27.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
8653
+ import_log27.log.runtimeConfig.processors.splice(index, 1);
8318
8654
  }
8319
8655
  async controlMetrics({ reset, record }) {
8320
8656
  if (reset) {
@@ -8375,7 +8711,7 @@ var LoggingServiceImpl = class {
8375
8711
  }
8376
8712
  const record = {
8377
8713
  ...entry2,
8378
- context: (0, import_util16.jsonify)((0, import_log26.getContextFromEntry)(entry2)),
8714
+ context: (0, import_util16.jsonify)((0, import_log27.getContextFromEntry)(entry2)),
8379
8715
  timestamp: /* @__PURE__ */ new Date(),
8380
8716
  meta: {
8381
8717
  // TODO(dmaretskyi): Fix proto.
@@ -8536,7 +8872,7 @@ function _ts_decorate11(decorators, target, key, desc) {
8536
8872
  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;
8537
8873
  return c > 3 && r && Object.defineProperty(target, key, r), r;
8538
8874
  }
8539
- var __dxlog_file30 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
8875
+ var __dxlog_file31 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
8540
8876
  var ClientServicesHost = class {
8541
8877
  constructor({
8542
8878
  config,
@@ -8575,8 +8911,8 @@ var ClientServicesHost = class {
8575
8911
  lockKey,
8576
8912
  onAcquire: () => {
8577
8913
  if (!this._opening) {
8578
- void this.open(new import_context17.Context(void 0, {
8579
- F: __dxlog_file30,
8914
+ void this.open(new import_context18.Context(void 0, {
8915
+ F: __dxlog_file31,
8580
8916
  L: 137
8581
8917
  }));
8582
8918
  }
@@ -8633,8 +8969,8 @@ var ClientServicesHost = class {
8633
8969
  * Can only be called once.
8634
8970
  */
8635
8971
  initialize({ config, ...options }) {
8636
- (0, import_invariant24.invariant)(!this._open, "service host is open", {
8637
- F: __dxlog_file30,
8972
+ (0, import_invariant26.invariant)(!this._open, "service host is open", {
8973
+ F: __dxlog_file31,
8638
8974
  L: 203,
8639
8975
  S: this,
8640
8976
  A: [
@@ -8642,15 +8978,15 @@ var ClientServicesHost = class {
8642
8978
  "'service host is open'"
8643
8979
  ]
8644
8980
  });
8645
- (0, import_log25.log)("initializing...", void 0, {
8646
- F: __dxlog_file30,
8981
+ (0, import_log26.log)("initializing...", void 0, {
8982
+ F: __dxlog_file31,
8647
8983
  L: 204,
8648
8984
  S: this,
8649
8985
  C: (f, a) => f(...a)
8650
8986
  });
8651
8987
  if (config) {
8652
- (0, import_invariant24.invariant)(!this._config, "config already set", {
8653
- F: __dxlog_file30,
8988
+ (0, import_invariant26.invariant)(!this._config, "config already set", {
8989
+ F: __dxlog_file31,
8654
8990
  L: 207,
8655
8991
  S: this,
8656
8992
  A: [
@@ -8664,8 +9000,8 @@ var ClientServicesHost = class {
8664
9000
  }
8665
9001
  }
8666
9002
  if (!options.signalManager) {
8667
- import_log25.log.warn("running signaling without telemetry metadata.", void 0, {
8668
- F: __dxlog_file30,
9003
+ import_log26.log.warn("running signaling without telemetry metadata.", void 0, {
9004
+ F: __dxlog_file31,
8669
9005
  L: 215,
8670
9006
  S: this,
8671
9007
  C: (f, a) => f(...a)
@@ -8684,8 +9020,8 @@ var ClientServicesHost = class {
8684
9020
  edgeConnection: this._edgeConnection
8685
9021
  }) : new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
8686
9022
  this._signalManager = signalManager;
8687
- (0, import_invariant24.invariant)(!this._networkManager, "network manager already set", {
8688
- F: __dxlog_file30,
9023
+ (0, import_invariant26.invariant)(!this._networkManager, "network manager already set", {
9024
+ F: __dxlog_file31,
8689
9025
  L: 237,
8690
9026
  S: this,
8691
9027
  A: [
@@ -8702,8 +9038,8 @@ var ClientServicesHost = class {
8702
9038
  peerKey: this._edgeConnection.peerKey
8703
9039
  } : void 0
8704
9040
  });
8705
- (0, import_log25.log)("initialized", void 0, {
8706
- F: __dxlog_file30,
9041
+ (0, import_log26.log)("initialized", void 0, {
9042
+ F: __dxlog_file31,
8707
9043
  L: 250,
8708
9044
  S: this,
8709
9045
  C: (f, a) => f(...a)
@@ -8713,17 +9049,17 @@ var ClientServicesHost = class {
8713
9049
  if (this._open) {
8714
9050
  return;
8715
9051
  }
8716
- const traceId = import_keys19.PublicKey.random().toHex();
8717
- import_log25.log.trace("dxos.client-services.host.open", import_protocols20.trace.begin({
9052
+ const traceId = import_keys20.PublicKey.random().toHex();
9053
+ import_log26.log.trace("dxos.client-services.host.open", import_protocols22.trace.begin({
8718
9054
  id: traceId
8719
9055
  }), {
8720
- F: __dxlog_file30,
9056
+ F: __dxlog_file31,
8721
9057
  L: 261,
8722
9058
  S: this,
8723
9059
  C: (f, a) => f(...a)
8724
9060
  });
8725
- (0, import_invariant24.invariant)(this._config, "config not set", {
8726
- F: __dxlog_file30,
9061
+ (0, import_invariant26.invariant)(this._config, "config not set", {
9062
+ F: __dxlog_file31,
8727
9063
  L: 263,
8728
9064
  S: this,
8729
9065
  A: [
@@ -8731,8 +9067,8 @@ var ClientServicesHost = class {
8731
9067
  "'config not set'"
8732
9068
  ]
8733
9069
  });
8734
- (0, import_invariant24.invariant)(this._storage, "storage not set", {
8735
- F: __dxlog_file30,
9070
+ (0, import_invariant26.invariant)(this._storage, "storage not set", {
9071
+ F: __dxlog_file31,
8736
9072
  L: 264,
8737
9073
  S: this,
8738
9074
  A: [
@@ -8740,8 +9076,8 @@ var ClientServicesHost = class {
8740
9076
  "'storage not set'"
8741
9077
  ]
8742
9078
  });
8743
- (0, import_invariant24.invariant)(this._signalManager, "signal manager not set", {
8744
- F: __dxlog_file30,
9079
+ (0, import_invariant26.invariant)(this._signalManager, "signal manager not set", {
9080
+ F: __dxlog_file31,
8745
9081
  L: 265,
8746
9082
  S: this,
8747
9083
  A: [
@@ -8749,8 +9085,8 @@ var ClientServicesHost = class {
8749
9085
  "'signal manager not set'"
8750
9086
  ]
8751
9087
  });
8752
- (0, import_invariant24.invariant)(this._networkManager, "network manager not set", {
8753
- F: __dxlog_file30,
9088
+ (0, import_invariant26.invariant)(this._networkManager, "network manager not set", {
9089
+ F: __dxlog_file31,
8754
9090
  L: 266,
8755
9091
  S: this,
8756
9092
  A: [
@@ -8759,10 +9095,10 @@ var ClientServicesHost = class {
8759
9095
  ]
8760
9096
  });
8761
9097
  this._opening = true;
8762
- (0, import_log25.log)("opening...", {
9098
+ (0, import_log26.log)("opening...", {
8763
9099
  lockKey: this._resourceLock?.lockKey
8764
9100
  }, {
8765
- F: __dxlog_file30,
9101
+ F: __dxlog_file31,
8766
9102
  L: 269,
8767
9103
  S: this,
8768
9104
  C: (f, a) => f(...a)
@@ -8820,18 +9156,18 @@ var ClientServicesHost = class {
8820
9156
  this._open = true;
8821
9157
  this._statusUpdate.emit();
8822
9158
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
8823
- (0, import_log25.log)("opened", {
9159
+ (0, import_log26.log)("opened", {
8824
9160
  deviceKey
8825
9161
  }, {
8826
- F: __dxlog_file30,
9162
+ F: __dxlog_file31,
8827
9163
  L: 366,
8828
9164
  S: this,
8829
9165
  C: (f, a) => f(...a)
8830
9166
  });
8831
- import_log25.log.trace("dxos.client-services.host.open", import_protocols20.trace.end({
9167
+ import_log26.log.trace("dxos.client-services.host.open", import_protocols22.trace.end({
8832
9168
  id: traceId
8833
9169
  }), {
8834
- F: __dxlog_file30,
9170
+ F: __dxlog_file31,
8835
9171
  L: 367,
8836
9172
  S: this,
8837
9173
  C: (f, a) => f(...a)
@@ -8842,10 +9178,10 @@ var ClientServicesHost = class {
8842
9178
  return;
8843
9179
  }
8844
9180
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
8845
- (0, import_log25.log)("closing...", {
9181
+ (0, import_log26.log)("closing...", {
8846
9182
  deviceKey
8847
9183
  }, {
8848
- F: __dxlog_file30,
9184
+ F: __dxlog_file31,
8849
9185
  L: 378,
8850
9186
  S: this,
8851
9187
  C: (f, a) => f(...a)
@@ -8860,27 +9196,27 @@ var ClientServicesHost = class {
8860
9196
  await this._level?.close();
8861
9197
  this._open = false;
8862
9198
  this._statusUpdate.emit();
8863
- (0, import_log25.log)("closed", {
9199
+ (0, import_log26.log)("closed", {
8864
9200
  deviceKey
8865
9201
  }, {
8866
- F: __dxlog_file30,
9202
+ F: __dxlog_file31,
8867
9203
  L: 387,
8868
9204
  S: this,
8869
9205
  C: (f, a) => f(...a)
8870
9206
  });
8871
9207
  }
8872
9208
  async reset() {
8873
- const traceId = import_keys19.PublicKey.random().toHex();
8874
- import_log25.log.trace("dxos.sdk.client-services-host.reset", import_protocols20.trace.begin({
9209
+ const traceId = import_keys20.PublicKey.random().toHex();
9210
+ import_log26.log.trace("dxos.sdk.client-services-host.reset", import_protocols22.trace.begin({
8875
9211
  id: traceId
8876
9212
  }), {
8877
- F: __dxlog_file30,
9213
+ F: __dxlog_file31,
8878
9214
  L: 392,
8879
9215
  S: this,
8880
9216
  C: (f, a) => f(...a)
8881
9217
  });
8882
- import_log25.log.info("resetting...", void 0, {
8883
- F: __dxlog_file30,
9218
+ import_log26.log.info("resetting...", void 0, {
9219
+ F: __dxlog_file31,
8884
9220
  L: 394,
8885
9221
  S: this,
8886
9222
  C: (f, a) => f(...a)
@@ -8889,16 +9225,16 @@ var ClientServicesHost = class {
8889
9225
  this._statusUpdate.emit();
8890
9226
  await this._serviceContext?.close();
8891
9227
  await this._storage.reset();
8892
- import_log25.log.info("reset", void 0, {
8893
- F: __dxlog_file30,
9228
+ import_log26.log.info("reset", void 0, {
9229
+ F: __dxlog_file31,
8894
9230
  L: 401,
8895
9231
  S: this,
8896
9232
  C: (f, a) => f(...a)
8897
9233
  });
8898
- import_log25.log.trace("dxos.sdk.client-services-host.reset", import_protocols20.trace.end({
9234
+ import_log26.log.trace("dxos.sdk.client-services-host.reset", import_protocols22.trace.end({
8899
9235
  id: traceId
8900
9236
  }), {
8901
- F: __dxlog_file30,
9237
+ F: __dxlog_file31,
8902
9238
  L: 402,
8903
9239
  S: this,
8904
9240
  C: (f, a) => f(...a)
@@ -8977,4 +9313,4 @@ ClientServicesHost = _ts_decorate11([
8977
9313
  subscribeToSpaces,
8978
9314
  subscribeToSwarmInfo
8979
9315
  });
8980
- //# sourceMappingURL=chunk-K7LO776I.cjs.map
9316
+ //# sourceMappingURL=chunk-II76TP7N.cjs.map