@dxos/client-services 0.5.9-main.df0042a → 0.5.9-main.e9b9049

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 (45) hide show
  1. package/dist/lib/browser/{chunk-SLSPX47D.mjs → chunk-3DXQACFA.mjs} +1037 -630
  2. package/dist/lib/browser/chunk-3DXQACFA.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +13 -2
  4. package/dist/lib/browser/index.mjs.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +10 -3
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +1 -1
  8. package/dist/lib/node/{chunk-2K5VPBW6.cjs → chunk-4LN54Y73.cjs} +1128 -721
  9. package/dist/lib/node/chunk-4LN54Y73.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +53 -42
  11. package/dist/lib/node/index.cjs.map +1 -1
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/packlets/testing/index.cjs +17 -10
  14. package/dist/lib/node/packlets/testing/index.cjs.map +1 -1
  15. package/dist/types/src/packlets/identity/contacts-service.d.ts +14 -0
  16. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -0
  17. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  19. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  21. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +10 -1
  22. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  23. package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -1
  24. package/dist/types/src/packlets/spaces/spaces-service.d.ts +4 -1
  25. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  26. package/dist/types/src/packlets/storage/index.d.ts +1 -0
  27. package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
  28. package/dist/types/src/packlets/storage/profile-archive.d.ts +14 -0
  29. package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -0
  30. package/dist/types/src/version.d.ts +1 -1
  31. package/package.json +36 -36
  32. package/src/packlets/identity/contacts-service.ts +85 -0
  33. package/src/packlets/identity/identity-service.ts +27 -6
  34. package/src/packlets/invitations/invitations-handler.ts +13 -5
  35. package/src/packlets/invitations/space-invitation-protocol.ts +11 -32
  36. package/src/packlets/services/service-host.ts +12 -4
  37. package/src/packlets/spaces/data-space-manager.ts +55 -2
  38. package/src/packlets/spaces/data-space.ts +5 -5
  39. package/src/packlets/spaces/epoch-migrations.ts +12 -7
  40. package/src/packlets/spaces/spaces-service.ts +50 -2
  41. package/src/packlets/storage/index.ts +1 -0
  42. package/src/packlets/storage/profile-archive.ts +97 -0
  43. package/src/version.ts +1 -1
  44. package/dist/lib/browser/chunk-SLSPX47D.mjs.map +0 -7
  45. package/dist/lib/node/chunk-2K5VPBW6.cjs.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_2K5VPBW6_exports = {};
30
- __export(chunk_2K5VPBW6_exports, {
29
+ var chunk_4LN54Y73_exports = {};
30
+ __export(chunk_4LN54Y73_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  ClientServicesProviderResource: () => ClientServicesProviderResource,
@@ -56,7 +56,11 @@ __export(chunk_2K5VPBW6_exports, {
56
56
  createDiagnostics: () => createDiagnostics,
57
57
  createLevel: () => createLevel,
58
58
  createStorageObjects: () => createStorageObjects,
59
+ decodeProfileArchive: () => decodeProfileArchive,
60
+ encodeProfileArchive: () => encodeProfileArchive,
61
+ exportProfileData: () => exportProfileData,
59
62
  getNetworkPeers: () => getNetworkPeers,
63
+ importProfileData: () => importProfileData,
60
64
  isLocked: () => isLocked,
61
65
  subscribeToFeedBlocks: () => subscribeToFeedBlocks,
62
66
  subscribeToFeeds: () => subscribeToFeeds,
@@ -66,7 +70,7 @@ __export(chunk_2K5VPBW6_exports, {
66
70
  subscribeToSpaces: () => subscribeToSpaces,
67
71
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
68
72
  });
69
- module.exports = __toCommonJS(chunk_2K5VPBW6_exports);
73
+ module.exports = __toCommonJS(chunk_4LN54Y73_exports);
70
74
  var import_async = require("@dxos/async");
71
75
  var import_codec_protobuf = require("@dxos/codec-protobuf");
72
76
  var import_feed_store = require("@dxos/feed-store");
@@ -126,72 +130,75 @@ var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip"
126
130
  var import_timeframe2 = require("@dxos/timeframe");
127
131
  var import_tracing4 = require("@dxos/tracing");
128
132
  var import_util3 = require("@dxos/util");
133
+ var import_async8 = require("@dxos/async");
129
134
  var import_codec_protobuf9 = require("@dxos/codec-protobuf");
130
135
  var import_context4 = require("@dxos/context");
131
136
  var import_credentials8 = require("@dxos/credentials");
132
137
  var import_debug2 = require("@dxos/debug");
133
138
  var import_invariant4 = require("@dxos/invariant");
139
+ var import_log5 = require("@dxos/log");
134
140
  var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
141
+ var import_util4 = require("@dxos/util");
135
142
  var import_invariant5 = require("@dxos/invariant");
136
143
  var import_protocols4 = require("@dxos/protocols");
137
144
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
138
- var import_async8 = require("@dxos/async");
145
+ var import_async9 = require("@dxos/async");
139
146
  var import_client_protocol2 = require("@dxos/client-protocol");
140
147
  var import_context5 = require("@dxos/context");
141
148
  var import_crypto = require("@dxos/crypto");
142
149
  var import_invariant6 = require("@dxos/invariant");
143
150
  var import_keys6 = require("@dxos/keys");
144
- var import_log5 = require("@dxos/log");
151
+ var import_log6 = require("@dxos/log");
145
152
  var import_network_manager = require("@dxos/network-manager");
146
153
  var import_protocols5 = require("@dxos/protocols");
147
154
  var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
148
155
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
149
156
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
150
- var import_util4 = require("@dxos/util");
151
- var import_async9 = require("@dxos/async");
157
+ var import_util5 = require("@dxos/util");
158
+ var import_async10 = require("@dxos/async");
152
159
  var import_context6 = require("@dxos/context");
153
160
  var import_invariant7 = require("@dxos/invariant");
154
- var import_log6 = require("@dxos/log");
161
+ var import_log7 = require("@dxos/log");
155
162
  var import_protocols6 = require("@dxos/protocols");
156
163
  var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
157
164
  var import_teleport = require("@dxos/teleport");
158
165
  var import_context7 = require("@dxos/context");
159
166
  var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
160
- var import_async10 = require("@dxos/async");
167
+ var import_async11 = require("@dxos/async");
161
168
  var import_context8 = require("@dxos/context");
162
169
  var import_crypto2 = require("@dxos/crypto");
163
170
  var import_invariant8 = require("@dxos/invariant");
164
171
  var import_keys7 = require("@dxos/keys");
165
- var import_log7 = require("@dxos/log");
172
+ var import_log8 = require("@dxos/log");
166
173
  var import_protocols7 = require("@dxos/protocols");
167
174
  var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
168
175
  var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
169
176
  var import_teleport2 = require("@dxos/teleport");
170
177
  var import_invariant9 = require("@dxos/invariant");
171
178
  var import_keys8 = require("@dxos/keys");
172
- var import_log8 = require("@dxos/log");
179
+ var import_log9 = require("@dxos/log");
173
180
  var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations");
174
- var import_util5 = require("@dxos/util");
181
+ var import_util6 = require("@dxos/util");
175
182
  var import_codec_protobuf10 = require("@dxos/codec-protobuf");
176
183
  var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
177
184
  var import_credentials9 = require("@dxos/credentials");
178
185
  var import_feed_store3 = require("@dxos/feed-store");
179
186
  var import_invariant10 = require("@dxos/invariant");
180
- var import_log9 = require("@dxos/log");
187
+ var import_log10 = require("@dxos/log");
181
188
  var import_protocols8 = require("@dxos/protocols");
182
189
  var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
183
190
  var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
184
- var import_async11 = require("@dxos/async");
191
+ var import_async12 = require("@dxos/async");
185
192
  var import_client_protocol3 = require("@dxos/client-protocol");
186
193
  var import_context9 = require("@dxos/context");
187
194
  var import_credentials11 = require("@dxos/credentials");
188
195
  var import_echo_pipeline = require("@dxos/echo-pipeline");
189
196
  var import_invariant11 = require("@dxos/invariant");
190
197
  var import_keys9 = require("@dxos/keys");
191
- var import_log10 = require("@dxos/log");
198
+ var import_log11 = require("@dxos/log");
192
199
  var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
193
200
  var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
194
- var import_async12 = require("@dxos/async");
201
+ var import_async13 = require("@dxos/async");
195
202
  var import_client_protocol4 = require("@dxos/client-protocol");
196
203
  var import_context10 = require("@dxos/context");
197
204
  var import_debug3 = require("@dxos/debug");
@@ -199,125 +206,136 @@ var import_echo_pipeline2 = require("@dxos/echo-pipeline");
199
206
  var import_echo_protocol = require("@dxos/echo-protocol");
200
207
  var import_invariant12 = require("@dxos/invariant");
201
208
  var import_keys10 = require("@dxos/keys");
202
- var import_log11 = require("@dxos/log");
209
+ var import_log12 = require("@dxos/log");
203
210
  var import_protocols9 = require("@dxos/protocols");
204
211
  var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
205
212
  var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
206
213
  var import_timeframe3 = require("@dxos/timeframe");
207
214
  var import_tracing5 = require("@dxos/tracing");
208
- var import_util6 = require("@dxos/util");
209
- var import_async13 = require("@dxos/async");
215
+ var import_util7 = require("@dxos/util");
216
+ var import_async14 = require("@dxos/async");
210
217
  var import_context11 = require("@dxos/context");
211
218
  var import_credentials14 = require("@dxos/credentials");
212
- var import_async14 = require("@dxos/async");
219
+ var import_async15 = require("@dxos/async");
213
220
  var import_automerge = require("@dxos/automerge/automerge");
214
221
  var import_context12 = require("@dxos/context");
215
222
  var import_echo_db = require("@dxos/echo-db");
216
223
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
217
224
  var import_echo_schema = require("@dxos/echo-schema");
218
225
  var import_invariant13 = require("@dxos/invariant");
219
- var import_log12 = require("@dxos/log");
226
+ var import_log13 = require("@dxos/log");
220
227
  var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
221
- var import_util7 = require("@dxos/util");
222
- var import_async15 = require("@dxos/async");
228
+ var import_util8 = require("@dxos/util");
229
+ var import_async16 = require("@dxos/async");
223
230
  var import_context13 = require("@dxos/context");
224
231
  var import_invariant14 = require("@dxos/invariant");
225
232
  var import_keys11 = require("@dxos/keys");
226
- var import_log13 = require("@dxos/log");
233
+ var import_log14 = require("@dxos/log");
227
234
  var import_protocols10 = require("@dxos/protocols");
228
235
  var import_teleport3 = require("@dxos/teleport");
229
- var import_util8 = require("@dxos/util");
230
- var import_async16 = require("@dxos/async");
236
+ var import_util9 = require("@dxos/util");
237
+ var import_async17 = require("@dxos/async");
231
238
  var import_client_protocol5 = require("@dxos/client-protocol");
232
239
  var import_context14 = require("@dxos/context");
233
240
  var import_credentials15 = require("@dxos/credentials");
234
241
  var import_echo_db2 = require("@dxos/echo-db");
235
242
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
243
+ var import_echo_pipeline5 = require("@dxos/echo-pipeline");
236
244
  var import_echo_protocol2 = require("@dxos/echo-protocol");
237
245
  var import_echo_schema2 = require("@dxos/echo-schema");
246
+ var import_feed_store4 = require("@dxos/feed-store");
238
247
  var import_invariant15 = require("@dxos/invariant");
239
248
  var import_keys12 = require("@dxos/keys");
240
- var import_log14 = require("@dxos/log");
249
+ var import_log15 = require("@dxos/log");
241
250
  var import_protocols11 = require("@dxos/protocols");
242
251
  var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
243
252
  var import_credentials16 = require("@dxos/protocols/proto/dxos/halo/credentials");
244
253
  var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
245
254
  var import_tracing6 = require("@dxos/tracing");
246
- var import_util9 = require("@dxos/util");
255
+ var import_util10 = require("@dxos/util");
247
256
  var import_credentials17 = require("@dxos/credentials");
248
257
  var import_debug4 = require("@dxos/debug");
249
258
  var import_credentials18 = require("@dxos/protocols/proto/dxos/halo/credentials");
250
259
  var import_timeframe4 = require("@dxos/timeframe");
251
- var import_async17 = require("@dxos/async");
260
+ var import_async18 = require("@dxos/async");
252
261
  var import_codec_protobuf11 = require("@dxos/codec-protobuf");
253
262
  var import_credentials19 = require("@dxos/credentials");
254
263
  var import_debug5 = require("@dxos/debug");
255
- var import_feed_store4 = require("@dxos/feed-store");
264
+ var import_feed_store5 = require("@dxos/feed-store");
256
265
  var import_invariant16 = require("@dxos/invariant");
257
- var import_log15 = require("@dxos/log");
266
+ var import_log16 = require("@dxos/log");
258
267
  var import_protocols12 = require("@dxos/protocols");
259
268
  var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
260
269
  var import_tracing7 = require("@dxos/tracing");
261
- var import_async18 = require("@dxos/async");
270
+ var import_async19 = require("@dxos/async");
262
271
  var import_context15 = require("@dxos/context");
263
272
  var import_credentials20 = require("@dxos/credentials");
264
273
  var import_debug6 = require("@dxos/debug");
265
274
  var import_echo_db3 = require("@dxos/echo-db");
266
- var import_echo_pipeline5 = require("@dxos/echo-pipeline");
267
- var import_feed_store5 = require("@dxos/feed-store");
275
+ var import_echo_pipeline6 = require("@dxos/echo-pipeline");
276
+ var import_feed_store6 = require("@dxos/feed-store");
268
277
  var import_invariant17 = require("@dxos/invariant");
269
278
  var import_keyring = require("@dxos/keyring");
270
279
  var import_keys13 = require("@dxos/keys");
271
- var import_log16 = require("@dxos/log");
280
+ var import_log17 = require("@dxos/log");
272
281
  var import_protocols13 = require("@dxos/protocols");
273
282
  var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
274
283
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
275
284
  var import_tracing8 = require("@dxos/tracing");
276
- var import_util10 = require("@dxos/util");
285
+ var import_util11 = require("@dxos/util");
277
286
  var import_invariant18 = require("@dxos/invariant");
278
287
  var import_lock_file = require("@dxos/lock-file");
279
- var import_log17 = require("@dxos/log");
288
+ var import_log18 = require("@dxos/log");
280
289
  var import_protocols14 = require("@dxos/protocols");
281
290
  var import_config = require("@dxos/protocols/proto/dxos/config");
282
291
  var import_random_access_storage = require("@dxos/random-access-storage");
283
292
  var import_client_protocol6 = require("@dxos/client-protocol");
284
293
  var import_config2 = require("@dxos/protocols/proto/dxos/config");
285
- var import_util11 = require("@dxos/util");
294
+ var import_util12 = require("@dxos/util");
286
295
  var import_node_path = __toESM(require("node:path"));
287
296
  var import_keys14 = require("@dxos/keys");
288
297
  var import_kv_store = require("@dxos/kv-store");
289
- var import_async19 = require("@dxos/async");
298
+ var import_automerge_repo = require("@dxos/automerge/automerge-repo");
299
+ var import_invariant19 = require("@dxos/invariant");
300
+ var import_log19 = require("@dxos/log");
301
+ var import_protocols15 = require("@dxos/protocols");
302
+ var import_util13 = require("@dxos/util");
303
+ var import_async20 = require("@dxos/async");
290
304
  var import_client_protocol7 = require("@dxos/client-protocol");
291
305
  var import_context16 = require("@dxos/context");
292
- var import_invariant19 = require("@dxos/invariant");
306
+ var import_invariant20 = require("@dxos/invariant");
293
307
  var import_keys15 = require("@dxos/keys");
294
- var import_log18 = require("@dxos/log");
308
+ var import_log20 = require("@dxos/log");
295
309
  var import_messaging = require("@dxos/messaging");
296
310
  var import_network_manager2 = require("@dxos/network-manager");
297
- var import_protocols15 = require("@dxos/protocols");
311
+ var import_protocols16 = require("@dxos/protocols");
298
312
  var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
299
313
  var import_tracing9 = require("@dxos/tracing");
300
314
  var import_websocket_rpc = require("@dxos/websocket-rpc");
301
- var import_async20 = require("@dxos/async");
315
+ var import_async21 = require("@dxos/async");
302
316
  var import_codec_protobuf12 = require("@dxos/codec-protobuf");
303
- var import_invariant20 = require("@dxos/invariant");
317
+ var import_invariant21 = require("@dxos/invariant");
304
318
  var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
305
319
  var import_config3 = require("@dxos/config");
306
320
  var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
307
321
  var import_tracing10 = require("@dxos/tracing");
308
- var import_util12 = require("@dxos/util");
322
+ var import_util14 = require("@dxos/util");
309
323
  var import_keys16 = require("@dxos/keys");
310
- var import_util13 = require("@dxos/util");
311
- var import_async21 = require("@dxos/async");
324
+ var import_util15 = require("@dxos/util");
325
+ var import_async22 = require("@dxos/async");
312
326
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
313
327
  var import_keys17 = require("@dxos/keys");
314
- var import_log19 = require("@dxos/log");
315
- var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
316
- var import_util14 = require("@dxos/util");
328
+ var import_util16 = require("@dxos/util");
329
+ var import_async23 = require("@dxos/async");
317
330
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
331
+ var import_keys18 = require("@dxos/keys");
332
+ var import_log21 = require("@dxos/log");
333
+ var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
334
+ var import_util17 = require("@dxos/util");
318
335
  var import_codec_protobuf15 = require("@dxos/codec-protobuf");
336
+ var import_codec_protobuf16 = require("@dxos/codec-protobuf");
319
337
  var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
320
- var import_util15 = require("@dxos/util");
338
+ var import_util18 = require("@dxos/util");
321
339
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
322
340
  return new import_codec_protobuf.Stream(({ next }) => {
323
341
  const subscriptions = new import_async.EventSubscriptions();
@@ -385,6 +403,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
385
403
  };
386
404
  });
387
405
  };
406
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/network.ts";
388
407
  var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf2.Stream(({ next, close }) => {
389
408
  const update = () => {
390
409
  try {
@@ -400,7 +419,10 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf2
400
419
  update();
401
420
  });
402
421
  var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf2.Stream(({ next }) => {
403
- const ctx = new import_context.Context();
422
+ const ctx = new import_context.Context(void 0, {
423
+ F: __dxlog_file,
424
+ L: 36
425
+ });
404
426
  signalManager.onMessage.on(ctx, (message) => {
405
427
  next({
406
428
  message: {
@@ -628,7 +650,7 @@ var DevtoolsServiceImpl = class {
628
650
  });
629
651
  }
630
652
  };
631
- var DXOS_VERSION = "0.5.9-main.df0042a";
653
+ var DXOS_VERSION = "0.5.9-main.e9b9049";
632
654
  var getPlatform = () => {
633
655
  if (process.browser) {
634
656
  if (typeof window !== "undefined") {
@@ -656,7 +678,7 @@ var getPlatform = () => {
656
678
  };
657
679
  }
658
680
  };
659
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
681
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
660
682
  var DEFAULT_TIMEOUT = 1e3;
661
683
  var createDiagnostics = async (clientServices, serviceContext, config) => {
662
684
  const diagnostics = {
@@ -673,7 +695,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
673
695
  await Promise.all([
674
696
  (async () => {
675
697
  (0, import_invariant.invariant)(clientServices.LoggingService, "SystemService is not available.", {
676
- F: __dxlog_file,
698
+ F: __dxlog_file2,
677
699
  L: 110,
678
700
  S: void 0,
679
701
  A: [
@@ -862,7 +884,7 @@ _ts_decorate([
862
884
  ClientRpcServer = _ts_decorate([
863
885
  import_tracing2.trace.resource()
864
886
  ], ClientRpcServer);
865
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
887
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
866
888
  var Credential = import_protocols2.schema.getCodecForType("dxos.halo.credentials.Credential");
867
889
  var createAuthProvider = (signer) => async (nonce) => {
868
890
  const credential = await signer.createCredential({
@@ -877,7 +899,10 @@ var createAuthProvider = (signer) => async (nonce) => {
877
899
  var TrustedKeySetAuthVerifier = class {
878
900
  constructor(_params) {
879
901
  this._params = _params;
880
- this._ctx = new import_context2.Context();
902
+ this._ctx = new import_context2.Context(void 0, {
903
+ F: __dxlog_file3,
904
+ L: 45
905
+ });
881
906
  }
882
907
  async close() {
883
908
  await this._ctx.dispose();
@@ -888,7 +913,7 @@ var TrustedKeySetAuthVerifier = class {
888
913
  (0, import_log.log)("authenticating...", {
889
914
  credential
890
915
  }, {
891
- F: __dxlog_file2,
916
+ F: __dxlog_file3,
892
917
  L: 56,
893
918
  S: this,
894
919
  C: (f, a) => f(...a)
@@ -898,7 +923,7 @@ var TrustedKeySetAuthVerifier = class {
898
923
  (0, import_log.log)("Invalid credential", {
899
924
  result
900
925
  }, {
901
- F: __dxlog_file2,
926
+ F: __dxlog_file3,
902
927
  L: 60,
903
928
  S: this,
904
929
  C: (f, a) => f(...a)
@@ -910,7 +935,7 @@ var TrustedKeySetAuthVerifier = class {
910
935
  nonce,
911
936
  credential
912
937
  }, {
913
- F: __dxlog_file2,
938
+ F: __dxlog_file3,
914
939
  L: 65,
915
940
  S: this,
916
941
  C: (f, a) => f(...a)
@@ -921,7 +946,7 @@ var TrustedKeySetAuthVerifier = class {
921
946
  (0, import_log.log)("key is not currently in trusted set, waiting...", {
922
947
  key: credential.issuer
923
948
  }, {
924
- F: __dxlog_file2,
949
+ F: __dxlog_file3,
925
950
  L: 70,
926
951
  S: this,
927
952
  C: (f, a) => f(...a)
@@ -937,7 +962,7 @@ var TrustedKeySetAuthVerifier = class {
937
962
  (0, import_log.log)("auth success", {
938
963
  key: credential.issuer
939
964
  }, {
940
- F: __dxlog_file2,
965
+ F: __dxlog_file3,
941
966
  L: 81,
942
967
  S: this,
943
968
  C: (f, a) => f(...a)
@@ -947,7 +972,7 @@ var TrustedKeySetAuthVerifier = class {
947
972
  (0, import_log.log)("key is not currently in trusted set, waiting...", {
948
973
  key: credential.issuer
949
974
  }, {
950
- F: __dxlog_file2,
975
+ F: __dxlog_file3,
951
976
  L: 84,
952
977
  S: this,
953
978
  C: (f, a) => f(...a)
@@ -970,7 +995,7 @@ var TrustedKeySetAuthVerifier = class {
970
995
  return deviceSet.has(deviceKey);
971
996
  }
972
997
  };
973
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
998
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
974
999
  var DefaultSpaceStateMachine = class {
975
1000
  constructor(_params) {
976
1001
  this._params = _params;
@@ -987,7 +1012,7 @@ var DefaultSpaceStateMachine = class {
987
1012
  expectedIdentity: this._params.identityKey,
988
1013
  credential
989
1014
  }, {
990
- F: __dxlog_file3,
1015
+ F: __dxlog_file4,
991
1016
  L: 32,
992
1017
  S: this,
993
1018
  C: (f, a) => f(...a)
@@ -998,7 +1023,7 @@ var DefaultSpaceStateMachine = class {
998
1023
  import_log3.log.warn("Invalid default space id", {
999
1024
  id: assertion.spaceId
1000
1025
  }, {
1001
- F: __dxlog_file3,
1026
+ F: __dxlog_file4,
1002
1027
  L: 36,
1003
1028
  S: this,
1004
1029
  C: (f, a) => f(...a)
@@ -1021,7 +1046,7 @@ function _ts_decorate2(decorators, target, key, desc) {
1021
1046
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1022
1047
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1023
1048
  }
1024
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
1049
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
1025
1050
  var Identity = class {
1026
1051
  constructor({ space, signer, identityKey, deviceKey, presence }) {
1027
1052
  this.stateUpdate = new import_async6.Event();
@@ -1033,7 +1058,7 @@ var Identity = class {
1033
1058
  import_log2.log.trace("dxos.halo.device", {
1034
1059
  deviceKey
1035
1060
  }, {
1036
- F: __dxlog_file4,
1061
+ F: __dxlog_file5,
1037
1062
  L: 70,
1038
1063
  S: this,
1039
1064
  C: (f, a) => f(...a)
@@ -1112,7 +1137,7 @@ var Identity = class {
1112
1137
  */
1113
1138
  getIdentityCredentialSigner() {
1114
1139
  (0, import_invariant2.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
1115
- F: __dxlog_file4,
1140
+ F: __dxlog_file5,
1116
1141
  L: 159,
1117
1142
  S: this,
1118
1143
  A: [
@@ -1156,7 +1181,7 @@ var Identity = class {
1156
1181
  controlFeedKey,
1157
1182
  dataFeedKey
1158
1183
  }, {
1159
- F: __dxlog_file4,
1184
+ F: __dxlog_file5,
1160
1185
  L: 184,
1161
1186
  S: this,
1162
1187
  C: (f, a) => f(...a)
@@ -1217,7 +1242,7 @@ function _ts_decorate3(decorators, target, key, desc) {
1217
1242
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1218
1243
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1219
1244
  }
1220
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1245
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1221
1246
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
1222
1247
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
1223
1248
  var IdentityManager = class {
@@ -1241,7 +1266,7 @@ var IdentityManager = class {
1241
1266
  import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
1242
1267
  id: traceId
1243
1268
  }), {
1244
- F: __dxlog_file5,
1269
+ F: __dxlog_file6,
1245
1270
  L: 104,
1246
1271
  S: this,
1247
1272
  C: (f, a) => f(...a)
@@ -1250,7 +1275,7 @@ var IdentityManager = class {
1250
1275
  (0, import_log4.log)("identity record", {
1251
1276
  identityRecord
1252
1277
  }, {
1253
- F: __dxlog_file5,
1278
+ F: __dxlog_file6,
1254
1279
  L: 107,
1255
1280
  S: this,
1256
1281
  C: (f, a) => f(...a)
@@ -1263,7 +1288,7 @@ var IdentityManager = class {
1263
1288
  identityKey: identityRecord.identityKey,
1264
1289
  displayName: this._identity.profileDocument?.displayName
1265
1290
  }, {
1266
- F: __dxlog_file5,
1291
+ F: __dxlog_file6,
1267
1292
  L: 112,
1268
1293
  S: this,
1269
1294
  C: (f, a) => f(...a)
@@ -1273,18 +1298,21 @@ var IdentityManager = class {
1273
1298
  import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.end({
1274
1299
  id: traceId
1275
1300
  }), {
1276
- F: __dxlog_file5,
1301
+ F: __dxlog_file6,
1277
1302
  L: 119,
1278
1303
  S: this,
1279
1304
  C: (f, a) => f(...a)
1280
1305
  });
1281
1306
  }
1282
1307
  async close() {
1283
- await this._identity?.close(new import_context3.Context());
1308
+ await this._identity?.close(new import_context3.Context(void 0, {
1309
+ F: __dxlog_file6,
1310
+ L: 123
1311
+ }));
1284
1312
  }
1285
1313
  async createIdentity({ displayName, deviceProfile } = {}) {
1286
1314
  (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
1287
- F: __dxlog_file5,
1315
+ F: __dxlog_file6,
1288
1316
  L: 128,
1289
1317
  S: this,
1290
1318
  A: [
@@ -1293,7 +1321,7 @@ var IdentityManager = class {
1293
1321
  ]
1294
1322
  });
1295
1323
  (0, import_log4.log)("creating identity...", void 0, {
1296
- F: __dxlog_file5,
1324
+ F: __dxlog_file6,
1297
1325
  L: 129,
1298
1326
  S: this,
1299
1327
  C: (f, a) => f(...a)
@@ -1310,11 +1338,14 @@ var IdentityManager = class {
1310
1338
  }
1311
1339
  };
1312
1340
  const identity = await this._constructIdentity(identityRecord);
1313
- await identity.open(new import_context3.Context());
1341
+ await identity.open(new import_context3.Context(void 0, {
1342
+ F: __dxlog_file6,
1343
+ L: 144
1344
+ }));
1314
1345
  {
1315
1346
  const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
1316
1347
  (0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
1317
- F: __dxlog_file5,
1348
+ F: __dxlog_file6,
1318
1349
  L: 148,
1319
1350
  S: this,
1320
1351
  A: [
@@ -1323,7 +1354,7 @@ var IdentityManager = class {
1323
1354
  ]
1324
1355
  });
1325
1356
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
1326
- F: __dxlog_file5,
1357
+ F: __dxlog_file6,
1327
1358
  L: 149,
1328
1359
  S: this,
1329
1360
  A: [
@@ -1362,7 +1393,7 @@ var IdentityManager = class {
1362
1393
  identityKey: identityRecord.identityKey,
1363
1394
  displayName: this._identity.profileDocument?.displayName
1364
1395
  }, {
1365
- F: __dxlog_file5,
1396
+ F: __dxlog_file6,
1366
1397
  L: 191,
1367
1398
  S: this,
1368
1399
  C: (f, a) => f(...a)
@@ -1373,7 +1404,7 @@ var IdentityManager = class {
1373
1404
  deviceKey: identity.deviceKey,
1374
1405
  profile: identity.profileDocument
1375
1406
  }, {
1376
- F: __dxlog_file5,
1407
+ F: __dxlog_file6,
1377
1408
  L: 197,
1378
1409
  S: this,
1379
1410
  C: (f, a) => f(...a)
@@ -1410,13 +1441,13 @@ var IdentityManager = class {
1410
1441
  (0, import_log4.log)("accepting identity", {
1411
1442
  params
1412
1443
  }, {
1413
- F: __dxlog_file5,
1444
+ F: __dxlog_file6,
1414
1445
  L: 235,
1415
1446
  S: this,
1416
1447
  C: (f, a) => f(...a)
1417
1448
  });
1418
1449
  (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
1419
- F: __dxlog_file5,
1450
+ F: __dxlog_file6,
1420
1451
  L: 236,
1421
1452
  S: this,
1422
1453
  A: [
@@ -1436,7 +1467,10 @@ var IdentityManager = class {
1436
1467
  }
1437
1468
  };
1438
1469
  const identity = await this._constructIdentity(identityRecord);
1439
- await identity.open(new import_context3.Context());
1470
+ await identity.open(new import_context3.Context(void 0, {
1471
+ F: __dxlog_file6,
1472
+ L: 251
1473
+ }));
1440
1474
  this._identity = identity;
1441
1475
  await this._metadataStore.setIdentityRecord(identityRecord);
1442
1476
  await this._identity.ready();
@@ -1444,7 +1478,7 @@ var IdentityManager = class {
1444
1478
  identityKey: identityRecord.identityKey,
1445
1479
  displayName: this._identity.profileDocument?.displayName
1446
1480
  }, {
1447
- F: __dxlog_file5,
1481
+ F: __dxlog_file6,
1448
1482
  L: 255,
1449
1483
  S: this,
1450
1484
  C: (f, a) => f(...a)
@@ -1458,7 +1492,7 @@ var IdentityManager = class {
1458
1492
  identityKey: identity.identityKey,
1459
1493
  deviceKey: identity.deviceKey
1460
1494
  }, {
1461
- F: __dxlog_file5,
1495
+ F: __dxlog_file6,
1462
1496
  L: 265,
1463
1497
  S: this,
1464
1498
  C: (f, a) => f(...a)
@@ -1470,7 +1504,7 @@ var IdentityManager = class {
1470
1504
  */
1471
1505
  async updateProfile(profile) {
1472
1506
  (0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
1473
- F: __dxlog_file5,
1507
+ F: __dxlog_file6,
1474
1508
  L: 273,
1475
1509
  S: this,
1476
1510
  A: [
@@ -1501,7 +1535,7 @@ var IdentityManager = class {
1501
1535
  }
1502
1536
  async updateDeviceProfile(profile) {
1503
1537
  (0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
1504
- F: __dxlog_file5,
1538
+ F: __dxlog_file6,
1505
1539
  L: 290,
1506
1540
  S: this,
1507
1541
  A: [
@@ -1537,7 +1571,7 @@ var IdentityManager = class {
1537
1571
  }
1538
1572
  async _constructIdentity(identityRecord) {
1539
1573
  (0, import_invariant3.invariant)(!this._identity, void 0, {
1540
- F: __dxlog_file5,
1574
+ F: __dxlog_file6,
1541
1575
  L: 316,
1542
1576
  S: this,
1543
1577
  A: [
@@ -1548,7 +1582,7 @@ var IdentityManager = class {
1548
1582
  (0, import_log4.log)("constructing identity", {
1549
1583
  identityRecord
1550
1584
  }, {
1551
- F: __dxlog_file5,
1585
+ F: __dxlog_file6,
1552
1586
  L: 317,
1553
1587
  S: this,
1554
1588
  C: (f, a) => f(...a)
@@ -1563,7 +1597,7 @@ var IdentityManager = class {
1563
1597
  gossip
1564
1598
  });
1565
1599
  (0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
1566
- F: __dxlog_file5,
1600
+ F: __dxlog_file6,
1567
1601
  L: 330,
1568
1602
  S: this,
1569
1603
  A: [
@@ -1575,7 +1609,7 @@ var IdentityManager = class {
1575
1609
  writable: true
1576
1610
  });
1577
1611
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
1578
- F: __dxlog_file5,
1612
+ F: __dxlog_file6,
1579
1613
  L: 334,
1580
1614
  S: this,
1581
1615
  A: [
@@ -1609,7 +1643,7 @@ var IdentityManager = class {
1609
1643
  (0, import_log4.log)("done", {
1610
1644
  identityKey: identityRecord.identityKey
1611
1645
  }, {
1612
- F: __dxlog_file5,
1646
+ F: __dxlog_file6,
1613
1647
  L: 360,
1614
1648
  S: this,
1615
1649
  C: (f, a) => f(...a)
@@ -1634,7 +1668,7 @@ var IdentityManager = class {
1634
1668
  },
1635
1669
  onAuthFailure: () => {
1636
1670
  import_log4.log.warn("auth failure", void 0, {
1637
- F: __dxlog_file5,
1671
+ F: __dxlog_file6,
1638
1672
  L: 385,
1639
1673
  S: this,
1640
1674
  C: (f, a) => f(...a)
@@ -1656,7 +1690,8 @@ _ts_decorate3([
1656
1690
  IdentityManager = _ts_decorate3([
1657
1691
  import_tracing4.trace.resource()
1658
1692
  ], IdentityManager);
1659
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1693
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1694
+ var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
1660
1695
  var IdentityServiceImpl = class extends import_context4.Resource {
1661
1696
  constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
1662
1697
  super();
@@ -1685,8 +1720,8 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1685
1720
  const space = await dataSpaceManager.createDefaultSpace();
1686
1721
  const identity = this._identityManager.identity;
1687
1722
  (0, import_invariant4.invariant)(identity, void 0, {
1688
- F: __dxlog_file6,
1689
- L: 54,
1723
+ F: __dxlog_file7,
1724
+ L: 59,
1690
1725
  S: this,
1691
1726
  A: [
1692
1727
  "identity",
@@ -1719,8 +1754,8 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1719
1754
  }
1720
1755
  async updateProfile(profile) {
1721
1756
  (0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
1722
- F: __dxlog_file6,
1723
- L: 84,
1757
+ F: __dxlog_file7,
1758
+ L: 89,
1724
1759
  S: this,
1725
1760
  A: [
1726
1761
  "this._identityManager.identity",
@@ -1733,8 +1768,8 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1733
1768
  }
1734
1769
  async signPresentation({ presentation, nonce }) {
1735
1770
  (0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
1736
- F: __dxlog_file6,
1737
- L: 91,
1771
+ F: __dxlog_file7,
1772
+ L: 96,
1738
1773
  S: this,
1739
1774
  A: [
1740
1775
  "this._identityManager.identity",
@@ -1750,9 +1785,11 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1750
1785
  });
1751
1786
  }
1752
1787
  async _fixIdentityWithoutDefaultSpace(identity) {
1753
- let hasDefaultSpace = false;
1788
+ let recodedDefaultSpace = false;
1789
+ let foundDefaultSpace = false;
1754
1790
  const dataSpaceManager = this._dataSpaceManagerProvider();
1755
- for (const space of dataSpaceManager.spaces.values()) {
1791
+ const recordedDefaultSpaceTrigger = new import_async8.Trigger();
1792
+ const allProcessed = (0, import_util4.safeAwaitAll)(dataSpaceManager.spaces.values(), async (space) => {
1756
1793
  if (space.state === import_services4.SpaceState.CLOSED) {
1757
1794
  await space.open();
1758
1795
  const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === import_services4.SpaceState.REQUIRES_MIGRATION);
@@ -1762,17 +1799,34 @@ var IdentityServiceImpl = class extends import_context4.Resource {
1762
1799
  ]);
1763
1800
  }
1764
1801
  if (await dataSpaceManager.isDefaultSpace(space)) {
1802
+ if (foundDefaultSpace) {
1803
+ import_log5.log.warn("Multiple default spaces found. Using the first one.", {
1804
+ duplicate: space.id
1805
+ }, {
1806
+ F: __dxlog_file7,
1807
+ L: 127,
1808
+ S: this,
1809
+ C: (f, a) => f(...a)
1810
+ });
1811
+ return;
1812
+ }
1813
+ foundDefaultSpace = true;
1765
1814
  await identity.updateDefaultSpace(space.id);
1766
- hasDefaultSpace = true;
1767
- break;
1815
+ recodedDefaultSpace = true;
1816
+ recordedDefaultSpaceTrigger.wake();
1768
1817
  }
1769
- }
1770
- if (!hasDefaultSpace) {
1818
+ });
1819
+ await Promise.race([
1820
+ allProcessed,
1821
+ recordedDefaultSpaceTrigger.wait(),
1822
+ (0, import_async8.sleep)(DEFAULT_SPACE_SEARCH_TIMEOUT)
1823
+ ]);
1824
+ if (!recodedDefaultSpace) {
1771
1825
  await this._createDefaultSpace(dataSpaceManager);
1772
1826
  }
1773
1827
  }
1774
1828
  };
1775
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1829
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1776
1830
  var DeviceInvitationProtocol = class {
1777
1831
  constructor(_keyring, _getIdentity, _acceptIdentity) {
1778
1832
  this._keyring = _keyring;
@@ -1798,7 +1852,7 @@ var DeviceInvitationProtocol = class {
1798
1852
  }
1799
1853
  async admit(_, request) {
1800
1854
  (0, import_invariant5.invariant)(request.device, void 0, {
1801
- F: __dxlog_file7,
1855
+ F: __dxlog_file8,
1802
1856
  L: 50,
1803
1857
  S: this,
1804
1858
  A: [
@@ -1844,7 +1898,7 @@ var DeviceInvitationProtocol = class {
1844
1898
  }
1845
1899
  async accept(response, request) {
1846
1900
  (0, import_invariant5.invariant)(response.device, void 0, {
1847
- F: __dxlog_file7,
1901
+ F: __dxlog_file8,
1848
1902
  L: 95,
1849
1903
  S: this,
1850
1904
  A: [
@@ -1854,7 +1908,7 @@ var DeviceInvitationProtocol = class {
1854
1908
  });
1855
1909
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1856
1910
  (0, import_invariant5.invariant)(request.device, void 0, {
1857
- F: __dxlog_file7,
1911
+ F: __dxlog_file8,
1858
1912
  L: 98,
1859
1913
  S: this,
1860
1914
  A: [
@@ -1893,7 +1947,7 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
1893
1947
  return guard;
1894
1948
  })());
1895
1949
  };
1896
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1950
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1897
1951
  var OPTIONS_TIMEOUT = 1e4;
1898
1952
  var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1899
1953
  constructor(_invitationFlowMutex, _callbacks) {
@@ -1907,8 +1961,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1907
1961
  });
1908
1962
  this._invitationFlowMutex = _invitationFlowMutex;
1909
1963
  this._callbacks = _callbacks;
1910
- this._ctx = new import_context6.Context();
1911
- this._remoteOptionsTrigger = new import_async9.Trigger();
1964
+ this._ctx = new import_context6.Context(void 0, {
1965
+ F: __dxlog_file9,
1966
+ L: 33
1967
+ });
1968
+ this._remoteOptionsTrigger = new import_async10.Trigger();
1912
1969
  this._invitationFlowLock = null;
1913
1970
  }
1914
1971
  hasFlowLock() {
@@ -1919,7 +1976,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1919
1976
  InvitationHostService: {
1920
1977
  options: async (options) => {
1921
1978
  (0, import_invariant7.invariant)(!this._remoteOptions, "Remote options already set.", {
1922
- F: __dxlog_file8,
1979
+ F: __dxlog_file9,
1923
1980
  L: 63,
1924
1981
  S: this,
1925
1982
  A: [
@@ -1945,15 +2002,15 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1945
2002
  async onOpen(context) {
1946
2003
  await super.onOpen(context);
1947
2004
  try {
1948
- (0, import_log6.log)("guest acquire lock", void 0, {
1949
- F: __dxlog_file8,
2005
+ (0, import_log7.log)("guest acquire lock", void 0, {
2006
+ F: __dxlog_file9,
1950
2007
  L: 84,
1951
2008
  S: this,
1952
2009
  C: (f, a) => f(...a)
1953
2010
  });
1954
2011
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
1955
- (0, import_log6.log)("guest lock acquired", void 0, {
1956
- F: __dxlog_file8,
2012
+ (0, import_log7.log)("guest lock acquired", void 0, {
2013
+ F: __dxlog_file9,
1957
2014
  L: 86,
1958
2015
  S: this,
1959
2016
  C: (f, a) => f(...a)
@@ -1961,8 +2018,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1961
2018
  await (0, import_context6.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
1962
2019
  role: import_invitations3.Options.Role.GUEST
1963
2020
  }));
1964
- (0, import_log6.log)("options sent", void 0, {
1965
- F: __dxlog_file8,
2021
+ (0, import_log7.log)("options sent", void 0, {
2022
+ F: __dxlog_file9,
1966
2023
  L: 88,
1967
2024
  S: this,
1968
2025
  C: (f, a) => f(...a)
@@ -1970,8 +2027,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1970
2027
  await (0, import_context6.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1971
2028
  timeout: OPTIONS_TIMEOUT
1972
2029
  }));
1973
- (0, import_log6.log)("options received", void 0, {
1974
- F: __dxlog_file8,
2030
+ (0, import_log7.log)("options received", void 0, {
2031
+ F: __dxlog_file9,
1975
2032
  L: 90,
1976
2033
  S: this,
1977
2034
  C: (f, a) => f(...a)
@@ -2004,8 +2061,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
2004
2061
  if (this._invitationFlowLock != null) {
2005
2062
  this._invitationFlowLock.release();
2006
2063
  this._invitationFlowLock = null;
2007
- (0, import_log6.log)("invitation flow lock released", void 0, {
2008
- F: __dxlog_file8,
2064
+ (0, import_log7.log)("invitation flow lock released", void 0, {
2065
+ F: __dxlog_file9,
2009
2066
  L: 123,
2010
2067
  S: this,
2011
2068
  C: (f, a) => f(...a)
@@ -2013,7 +2070,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
2013
2070
  }
2014
2071
  }
2015
2072
  };
2016
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
2073
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
2017
2074
  var OPTIONS_TIMEOUT2 = 1e4;
2018
2075
  var MAX_OTP_ATTEMPTS = 3;
2019
2076
  var InvitationHostExtension = class extends import_teleport2.RpcExtension {
@@ -2028,13 +2085,16 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2028
2085
  });
2029
2086
  this._invitationFlowMutex = _invitationFlowMutex;
2030
2087
  this._callbacks = _callbacks;
2031
- this._ctx = new import_context8.Context();
2032
- this._remoteOptionsTrigger = new import_async10.Trigger();
2088
+ this._ctx = new import_context8.Context(void 0, {
2089
+ F: __dxlog_file10,
2090
+ L: 52
2091
+ });
2092
+ this._remoteOptionsTrigger = new import_async11.Trigger();
2033
2093
  this._challenge = void 0;
2034
2094
  this.guestProfile = void 0;
2035
2095
  this.authenticationPassed = false;
2036
2096
  this.authenticationRetry = 0;
2037
- this.completedTrigger = new import_async10.Trigger();
2097
+ this.completedTrigger = new import_async11.Trigger();
2038
2098
  this._invitationFlowLock = null;
2039
2099
  }
2040
2100
  hasFlowLock() {
@@ -2047,7 +2107,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2047
2107
  InvitationHostService: {
2048
2108
  options: async (options) => {
2049
2109
  (0, import_invariant8.invariant)(!this._remoteOptions, "Remote options already set.", {
2050
- F: __dxlog_file9,
2110
+ F: __dxlog_file10,
2051
2111
  L: 101,
2052
2112
  S: this,
2053
2113
  A: [
@@ -2061,10 +2121,10 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2061
2121
  introduce: async (request) => {
2062
2122
  const { profile, invitationId } = request;
2063
2123
  const traceId = import_keys7.PublicKey.random().toHex();
2064
- import_log7.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.begin({
2124
+ import_log8.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.begin({
2065
2125
  id: traceId
2066
2126
  }), {
2067
- F: __dxlog_file9,
2127
+ F: __dxlog_file10,
2068
2128
  L: 110,
2069
2129
  S: this,
2070
2130
  C: (f, a) => f(...a)
@@ -2072,25 +2132,25 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2072
2132
  const invitation = this._requireActiveInvitation();
2073
2133
  this._assertInvitationState(import_services8.Invitation.State.CONNECTED);
2074
2134
  if (invitationId !== invitation?.invitationId) {
2075
- import_log7.log.warn("incorrect invitationId", {
2135
+ import_log8.log.warn("incorrect invitationId", {
2076
2136
  expected: invitation.invitationId,
2077
2137
  actual: invitationId
2078
2138
  }, {
2079
- F: __dxlog_file9,
2139
+ F: __dxlog_file10,
2080
2140
  L: 116,
2081
2141
  S: this,
2082
2142
  C: (f, a) => f(...a)
2083
2143
  });
2084
2144
  this._callbacks.onError(new Error("Incorrect invitationId."));
2085
- (0, import_async10.scheduleTask)(this._ctx, () => this.close());
2145
+ (0, import_async11.scheduleTask)(this._ctx, () => this.close());
2086
2146
  return {
2087
2147
  authMethod: import_services8.Invitation.AuthMethod.NONE
2088
2148
  };
2089
2149
  }
2090
- (0, import_log7.log)("guest introduced themselves", {
2150
+ (0, import_log8.log)("guest introduced themselves", {
2091
2151
  guestProfile: profile
2092
2152
  }, {
2093
- F: __dxlog_file9,
2153
+ F: __dxlog_file10,
2094
2154
  L: 125,
2095
2155
  S: this,
2096
2156
  C: (f, a) => f(...a)
@@ -2098,10 +2158,10 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2098
2158
  this.guestProfile = profile;
2099
2159
  this._callbacks.onStateUpdate(import_services8.Invitation.State.READY_FOR_AUTHENTICATION);
2100
2160
  this._challenge = invitation.authMethod === import_services8.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
2101
- import_log7.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.end({
2161
+ import_log8.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.end({
2102
2162
  id: traceId
2103
2163
  }), {
2104
- F: __dxlog_file9,
2164
+ F: __dxlog_file10,
2105
2165
  L: 132,
2106
2166
  S: this,
2107
2167
  C: (f, a) => f(...a)
@@ -2113,19 +2173,19 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2113
2173
  },
2114
2174
  authenticate: async ({ authCode: code, signedChallenge }) => {
2115
2175
  const traceId = import_keys7.PublicKey.random().toHex();
2116
- import_log7.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.begin({
2176
+ import_log8.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.begin({
2117
2177
  id: traceId
2118
2178
  }), {
2119
- F: __dxlog_file9,
2179
+ F: __dxlog_file10,
2120
2180
  L: 141,
2121
2181
  S: this,
2122
2182
  C: (f, a) => f(...a)
2123
2183
  });
2124
2184
  const invitation = this._requireActiveInvitation();
2125
- (0, import_log7.log)("received authentication request", {
2185
+ (0, import_log8.log)("received authentication request", {
2126
2186
  authCode: code
2127
2187
  }, {
2128
- F: __dxlog_file9,
2188
+ F: __dxlog_file10,
2129
2189
  L: 144,
2130
2190
  S: this,
2131
2191
  C: (f, a) => f(...a)
@@ -2138,8 +2198,8 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2138
2198
  this._callbacks.onStateUpdate(import_services8.Invitation.State.AUTHENTICATING);
2139
2199
  switch (invitation.authMethod) {
2140
2200
  case import_services8.Invitation.AuthMethod.NONE: {
2141
- (0, import_log7.log)("authentication not required", void 0, {
2142
- F: __dxlog_file9,
2201
+ (0, import_log8.log)("authentication not required", void 0, {
2202
+ F: __dxlog_file10,
2143
2203
  L: 152,
2144
2204
  S: this,
2145
2205
  C: (f, a) => f(...a)
@@ -2174,10 +2234,10 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2174
2234
  break;
2175
2235
  }
2176
2236
  default: {
2177
- import_log7.log.error("invalid authentication method", {
2237
+ import_log8.log.error("invalid authentication method", {
2178
2238
  authMethod: invitation.authMethod
2179
2239
  }, {
2180
- F: __dxlog_file9,
2240
+ F: __dxlog_file10,
2181
2241
  L: 190,
2182
2242
  S: this,
2183
2243
  C: (f, a) => f(...a)
@@ -2191,18 +2251,18 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2191
2251
  import_invitations4.AuthenticationResponse.Status.INVALID_OTP
2192
2252
  ].includes(status)) {
2193
2253
  this._callbacks.onError(new Error(`Authentication failed, with status=${status}`));
2194
- (0, import_async10.scheduleTask)(this._ctx, () => this.close());
2254
+ (0, import_async11.scheduleTask)(this._ctx, () => this.close());
2195
2255
  return {
2196
2256
  status
2197
2257
  };
2198
2258
  }
2199
- import_log7.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.end({
2259
+ import_log8.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.end({
2200
2260
  id: traceId,
2201
2261
  data: {
2202
2262
  status
2203
2263
  }
2204
2264
  }), {
2205
- F: __dxlog_file9,
2265
+ F: __dxlog_file10,
2206
2266
  L: 202,
2207
2267
  S: this,
2208
2268
  C: (f, a) => f(...a)
@@ -2213,10 +2273,10 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2213
2273
  },
2214
2274
  admit: async (request) => {
2215
2275
  const traceId = import_keys7.PublicKey.random().toHex();
2216
- import_log7.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.begin({
2276
+ import_log8.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.begin({
2217
2277
  id: traceId
2218
2278
  }), {
2219
- F: __dxlog_file9,
2279
+ F: __dxlog_file10,
2220
2280
  L: 208,
2221
2281
  S: this,
2222
2282
  C: (f, a) => f(...a)
@@ -2230,10 +2290,10 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2230
2290
  }
2231
2291
  }
2232
2292
  const response = await this._callbacks.admit(request);
2233
- import_log7.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.end({
2293
+ import_log8.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.end({
2234
2294
  id: traceId
2235
2295
  }), {
2236
- F: __dxlog_file9,
2296
+ F: __dxlog_file10,
2237
2297
  L: 222,
2238
2298
  S: this,
2239
2299
  C: (f, a) => f(...a)
@@ -2250,15 +2310,15 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2250
2310
  async onOpen(context) {
2251
2311
  await super.onOpen(context);
2252
2312
  try {
2253
- (0, import_log7.log)("host acquire lock", void 0, {
2254
- F: __dxlog_file9,
2313
+ (0, import_log8.log)("host acquire lock", void 0, {
2314
+ F: __dxlog_file10,
2255
2315
  L: 237,
2256
2316
  S: this,
2257
2317
  C: (f, a) => f(...a)
2258
2318
  });
2259
2319
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
2260
- (0, import_log7.log)("host lock acquired", void 0, {
2261
- F: __dxlog_file9,
2320
+ (0, import_log8.log)("host lock acquired", void 0, {
2321
+ F: __dxlog_file10,
2262
2322
  L: 239,
2263
2323
  S: this,
2264
2324
  C: (f, a) => f(...a)
@@ -2268,8 +2328,8 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2268
2328
  await this.rpc.InvitationHostService.options({
2269
2329
  role: import_invitations4.Options.Role.HOST
2270
2330
  });
2271
- (0, import_log7.log)("options sent", void 0, {
2272
- F: __dxlog_file9,
2331
+ (0, import_log8.log)("options sent", void 0, {
2332
+ F: __dxlog_file10,
2273
2333
  L: 243,
2274
2334
  S: this,
2275
2335
  C: (f, a) => f(...a)
@@ -2277,8 +2337,8 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2277
2337
  await (0, import_context8.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
2278
2338
  timeout: OPTIONS_TIMEOUT2
2279
2339
  }));
2280
- (0, import_log7.log)("options received", void 0, {
2281
- F: __dxlog_file9,
2340
+ (0, import_log8.log)("options received", void 0, {
2341
+ F: __dxlog_file10,
2282
2342
  L: 245,
2283
2343
  S: this,
2284
2344
  C: (f, a) => f(...a)
@@ -2305,7 +2365,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2305
2365
  _requireActiveInvitation() {
2306
2366
  const invitation = this._callbacks.activeInvitation;
2307
2367
  if (invitation == null) {
2308
- (0, import_async10.scheduleTask)(this._ctx, () => this.close());
2368
+ (0, import_async11.scheduleTask)(this._ctx, () => this.close());
2309
2369
  throw new Error("Active invitation not found");
2310
2370
  }
2311
2371
  return invitation;
@@ -2316,7 +2376,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2316
2376
  stateOrMany
2317
2377
  ];
2318
2378
  if (!validStates.includes(invitation.state)) {
2319
- (0, import_async10.scheduleTask)(this._ctx, () => this.close());
2379
+ (0, import_async11.scheduleTask)(this._ctx, () => this.close());
2320
2380
  throw new import_invariant8.InvariantViolation(`Expected ${stateToString(invitation.state)} to be one of [${validStates.map(stateToString).join(", ")}]`);
2321
2381
  }
2322
2382
  }
@@ -2331,8 +2391,8 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2331
2391
  if (this._invitationFlowLock != null) {
2332
2392
  this._invitationFlowLock?.release();
2333
2393
  this._invitationFlowLock = null;
2334
- (0, import_log7.log)("invitation flow lock released", void 0, {
2335
- F: __dxlog_file9,
2394
+ (0, import_log8.log)("invitation flow lock released", void 0, {
2395
+ F: __dxlog_file10,
2336
2396
  L: 300,
2337
2397
  S: this,
2338
2398
  C: (f, a) => f(...a)
@@ -2341,15 +2401,15 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2341
2401
  }
2342
2402
  };
2343
2403
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services8.Invitation.AuthMethod.NONE;
2344
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2404
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2345
2405
  var InvitationTopology = class {
2346
2406
  constructor(_role) {
2347
2407
  this._role = _role;
2348
- this._seenPeers = new import_util5.ComplexSet(import_keys8.PublicKey.hash);
2408
+ this._seenPeers = new import_util6.ComplexSet(import_keys8.PublicKey.hash);
2349
2409
  }
2350
2410
  init(controller) {
2351
2411
  (0, import_invariant9.invariant)(!this._controller, "Already initialized.", {
2352
- F: __dxlog_file10,
2412
+ F: __dxlog_file11,
2353
2413
  L: 42,
2354
2414
  S: this,
2355
2415
  A: [
@@ -2361,7 +2421,7 @@ var InvitationTopology = class {
2361
2421
  }
2362
2422
  update() {
2363
2423
  (0, import_invariant9.invariant)(this._controller, "Not initialized.", {
2364
- F: __dxlog_file10,
2424
+ F: __dxlog_file11,
2365
2425
  L: 47,
2366
2426
  S: this,
2367
2427
  A: [
@@ -2378,13 +2438,13 @@ var InvitationTopology = class {
2378
2438
  return;
2379
2439
  }
2380
2440
  const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
2381
- this._seenPeers = new import_util5.ComplexSet(import_keys8.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
2441
+ this._seenPeers = new import_util6.ComplexSet(import_keys8.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
2382
2442
  if (firstUnknownPeer != null) {
2383
- (0, import_log8.log)("invitation connect", {
2443
+ (0, import_log9.log)("invitation connect", {
2384
2444
  ownPeerId,
2385
2445
  remotePeerId: firstUnknownPeer
2386
2446
  }, {
2387
- F: __dxlog_file10,
2447
+ F: __dxlog_file11,
2388
2448
  L: 69,
2389
2449
  S: this,
2390
2450
  C: (f, a) => f(...a)
@@ -2395,7 +2455,7 @@ var InvitationTopology = class {
2395
2455
  }
2396
2456
  async onOffer(peer) {
2397
2457
  (0, import_invariant9.invariant)(this._controller, "Not initialized.", {
2398
- F: __dxlog_file10,
2458
+ F: __dxlog_file11,
2399
2459
  L: 76,
2400
2460
  S: this,
2401
2461
  A: [
@@ -2412,7 +2472,7 @@ var InvitationTopology = class {
2412
2472
  return `InvitationTopology(${this._role === import_invitations5.Options.Role.GUEST ? "guest" : "host"})`;
2413
2473
  }
2414
2474
  };
2415
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2475
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2416
2476
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
2417
2477
  var InvitationsHandler = class {
2418
2478
  /**
@@ -2437,7 +2497,7 @@ var InvitationsHandler = class {
2437
2497
  try {
2438
2498
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
2439
2499
  (0, import_invariant6.invariant)(deviceKey, void 0, {
2440
- F: __dxlog_file11,
2500
+ F: __dxlog_file12,
2441
2501
  L: 90,
2442
2502
  S: this,
2443
2503
  A: [
@@ -2460,21 +2520,21 @@ var InvitationsHandler = class {
2460
2520
  guardedState.error(extension, new import_context5.ContextDisposedError());
2461
2521
  }
2462
2522
  });
2463
- (0, import_async8.scheduleTask)(connectionCtx, async () => {
2523
+ (0, import_async9.scheduleTask)(connectionCtx, async () => {
2464
2524
  const traceId = import_keys6.PublicKey.random().toHex();
2465
2525
  try {
2466
- import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
2526
+ import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
2467
2527
  id: traceId
2468
2528
  }), {
2469
- F: __dxlog_file11,
2529
+ F: __dxlog_file12,
2470
2530
  L: 115,
2471
2531
  S: this,
2472
2532
  C: (f, a) => f(...a)
2473
2533
  });
2474
- (0, import_log5.log)("connected", {
2534
+ (0, import_log6.log)("connected", {
2475
2535
  ...protocol.toJSON()
2476
2536
  }, {
2477
- F: __dxlog_file11,
2537
+ F: __dxlog_file12,
2478
2538
  L: 116,
2479
2539
  S: this,
2480
2540
  C: (f, a) => f(...a)
@@ -2482,20 +2542,20 @@ var InvitationsHandler = class {
2482
2542
  const deviceKey = await extension.completedTrigger.wait({
2483
2543
  timeout: invitation.timeout
2484
2544
  });
2485
- (0, import_log5.log)("admitted guest", {
2545
+ (0, import_log6.log)("admitted guest", {
2486
2546
  guest: deviceKey,
2487
2547
  ...protocol.toJSON()
2488
2548
  }, {
2489
- F: __dxlog_file11,
2549
+ F: __dxlog_file12,
2490
2550
  L: 118,
2491
2551
  S: this,
2492
2552
  C: (f, a) => f(...a)
2493
2553
  });
2494
2554
  guardedState.set(extension, import_services6.Invitation.State.SUCCESS);
2495
- import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
2555
+ import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
2496
2556
  id: traceId
2497
2557
  }), {
2498
- F: __dxlog_file11,
2558
+ F: __dxlog_file12,
2499
2559
  L: 120,
2500
2560
  S: this,
2501
2561
  C: (f, a) => f(...a)
@@ -2505,12 +2565,12 @@ var InvitationsHandler = class {
2505
2565
  await ctx.dispose();
2506
2566
  }
2507
2567
  } catch (err) {
2508
- if (err instanceof import_async8.TimeoutError) {
2568
+ if (err instanceof import_async9.TimeoutError) {
2509
2569
  if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
2510
- (0, import_log5.log)("timeout", {
2570
+ (0, import_log6.log)("timeout", {
2511
2571
  ...protocol.toJSON()
2512
2572
  }, {
2513
- F: __dxlog_file11,
2573
+ F: __dxlog_file12,
2514
2574
  L: 129,
2515
2575
  S: this,
2516
2576
  C: (f, a) => f(...a)
@@ -2518,19 +2578,19 @@ var InvitationsHandler = class {
2518
2578
  }
2519
2579
  } else {
2520
2580
  if (guardedState.error(extension, err)) {
2521
- import_log5.log.error("failed", err, {
2522
- F: __dxlog_file11,
2581
+ import_log6.log.error("failed", err, {
2582
+ F: __dxlog_file12,
2523
2583
  L: 133,
2524
2584
  S: this,
2525
2585
  C: (f, a) => f(...a)
2526
2586
  });
2527
2587
  }
2528
2588
  }
2529
- import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.error({
2589
+ import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.error({
2530
2590
  id: traceId,
2531
2591
  error: err
2532
2592
  }), {
2533
- F: __dxlog_file11,
2593
+ F: __dxlog_file12,
2534
2594
  L: 136,
2535
2595
  S: this,
2536
2596
  C: (f, a) => f(...a)
@@ -2541,22 +2601,22 @@ var InvitationsHandler = class {
2541
2601
  },
2542
2602
  onError: (err) => {
2543
2603
  if (err instanceof import_protocols5.InvalidInvitationExtensionRoleError) {
2544
- (0, import_log5.log)("invalid role", {
2604
+ (0, import_log6.log)("invalid role", {
2545
2605
  ...err.context
2546
2606
  }, {
2547
- F: __dxlog_file11,
2607
+ F: __dxlog_file12,
2548
2608
  L: 144,
2549
2609
  S: this,
2550
2610
  C: (f, a) => f(...a)
2551
2611
  });
2552
2612
  return;
2553
2613
  }
2554
- if (err instanceof import_async8.TimeoutError) {
2614
+ if (err instanceof import_async9.TimeoutError) {
2555
2615
  if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
2556
- (0, import_log5.log)("timeout", {
2616
+ (0, import_log6.log)("timeout", {
2557
2617
  err
2558
2618
  }, {
2559
- F: __dxlog_file11,
2619
+ F: __dxlog_file12,
2560
2620
  L: 149,
2561
2621
  S: this,
2562
2622
  C: (f, a) => f(...a)
@@ -2564,8 +2624,8 @@ var InvitationsHandler = class {
2564
2624
  }
2565
2625
  } else {
2566
2626
  if (guardedState.error(extension, err)) {
2567
- import_log5.log.error("failed", err, {
2568
- F: __dxlog_file11,
2627
+ import_log6.log.error("failed", err, {
2628
+ F: __dxlog_file12,
2569
2629
  L: 153,
2570
2630
  S: this,
2571
2631
  C: (f, a) => f(...a)
@@ -2578,14 +2638,14 @@ var InvitationsHandler = class {
2578
2638
  };
2579
2639
  if (invitation.lifetime && invitation.created) {
2580
2640
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
2581
- import_log5.log.warn("invitation has already expired", void 0, {
2582
- F: __dxlog_file11,
2641
+ import_log6.log.warn("invitation has already expired", void 0, {
2642
+ F: __dxlog_file12,
2583
2643
  L: 164,
2584
2644
  S: this,
2585
2645
  C: (f, a) => f(...a)
2586
2646
  });
2587
2647
  } else {
2588
- (0, import_async8.scheduleTask)(ctx, async () => {
2648
+ (0, import_async9.scheduleTask)(ctx, async () => {
2589
2649
  await swarmConnection.close();
2590
2650
  guardedState.set(null, import_services6.Invitation.State.EXPIRED);
2591
2651
  await ctx.dispose();
@@ -2593,7 +2653,7 @@ var InvitationsHandler = class {
2593
2653
  }
2594
2654
  }
2595
2655
  let swarmConnection;
2596
- (0, import_async8.scheduleTask)(ctx, async () => {
2656
+ (0, import_async9.scheduleTask)(ctx, async () => {
2597
2657
  swarmConnection = await this._joinSwarm(ctx, invitation, import_invitations2.Options.Role.HOST, createExtension);
2598
2658
  guardedState.set(null, import_services6.Invitation.State.CONNECTING);
2599
2659
  });
@@ -2602,7 +2662,7 @@ var InvitationsHandler = class {
2602
2662
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
2603
2663
  if (deviceProfile) {
2604
2664
  (0, import_invariant6.invariant)(invitation.kind === import_services6.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2605
- F: __dxlog_file11,
2665
+ F: __dxlog_file12,
2606
2666
  L: 197,
2607
2667
  S: this,
2608
2668
  A: [
@@ -2611,16 +2671,16 @@ var InvitationsHandler = class {
2611
2671
  ]
2612
2672
  });
2613
2673
  }
2614
- const triedPeersIds = new import_util4.ComplexSet(import_keys6.PublicKey.hash);
2674
+ const triedPeersIds = new import_util5.ComplexSet(import_keys6.PublicKey.hash);
2615
2675
  const guardedState = this._createGuardedState(ctx, invitation, stream);
2616
2676
  const shouldCancelInvitationFlow = (extension) => {
2617
2677
  const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
2618
- (0, import_log5.log)("should cancel invitation flow", {
2678
+ (0, import_log6.log)("should cancel invitation flow", {
2619
2679
  isLockedByAnotherConnection,
2620
2680
  invitationType: import_services6.Invitation.Type.DELEGATED,
2621
2681
  triedPeers: triedPeersIds.size
2622
2682
  }, {
2623
- F: __dxlog_file11,
2683
+ F: __dxlog_file12,
2624
2684
  L: 205,
2625
2685
  S: this,
2626
2686
  C: (f, a) => f(...a)
@@ -2643,11 +2703,11 @@ var InvitationsHandler = class {
2643
2703
  return;
2644
2704
  }
2645
2705
  connectionCtx.onDispose(async () => {
2646
- (0, import_log5.log)("extension disposed", {
2706
+ (0, import_log6.log)("extension disposed", {
2647
2707
  admitted,
2648
2708
  currentState: guardedState.current.state
2649
2709
  }, {
2650
- F: __dxlog_file11,
2710
+ F: __dxlog_file12,
2651
2711
  L: 233,
2652
2712
  S: this,
2653
2713
  C: (f, a) => f(...a)
@@ -2659,34 +2719,34 @@ var InvitationsHandler = class {
2659
2719
  }
2660
2720
  }
2661
2721
  });
2662
- (0, import_async8.scheduleTask)(connectionCtx, async () => {
2722
+ (0, import_async9.scheduleTask)(connectionCtx, async () => {
2663
2723
  const traceId = import_keys6.PublicKey.random().toHex();
2664
2724
  try {
2665
- import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
2725
+ import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
2666
2726
  id: traceId
2667
2727
  }), {
2668
- F: __dxlog_file11,
2728
+ F: __dxlog_file12,
2669
2729
  L: 245,
2670
2730
  S: this,
2671
2731
  C: (f, a) => f(...a)
2672
2732
  });
2673
- (0, import_async8.scheduleTask)(connectionCtx, () => {
2733
+ (0, import_async9.scheduleTask)(connectionCtx, () => {
2674
2734
  guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
2675
2735
  extensionCtx.close();
2676
2736
  }, timeout);
2677
- (0, import_log5.log)("connected", {
2737
+ (0, import_log6.log)("connected", {
2678
2738
  ...protocol.toJSON()
2679
2739
  }, {
2680
- F: __dxlog_file11,
2740
+ F: __dxlog_file12,
2681
2741
  L: 256,
2682
2742
  S: this,
2683
2743
  C: (f, a) => f(...a)
2684
2744
  });
2685
2745
  guardedState.set(extension, import_services6.Invitation.State.CONNECTED);
2686
- (0, import_log5.log)("introduce", {
2746
+ (0, import_log6.log)("introduce", {
2687
2747
  ...protocol.toJSON()
2688
2748
  }, {
2689
- F: __dxlog_file11,
2749
+ F: __dxlog_file12,
2690
2750
  L: 260,
2691
2751
  S: this,
2692
2752
  C: (f, a) => f(...a)
@@ -2695,11 +2755,11 @@ var InvitationsHandler = class {
2695
2755
  invitationId: invitation.invitationId,
2696
2756
  ...protocol.createIntroduction()
2697
2757
  });
2698
- (0, import_log5.log)("introduce response", {
2758
+ (0, import_log6.log)("introduce response", {
2699
2759
  ...protocol.toJSON(),
2700
2760
  response: introductionResponse
2701
2761
  }, {
2702
- F: __dxlog_file11,
2762
+ F: __dxlog_file12,
2703
2763
  L: 265,
2704
2764
  S: this,
2705
2765
  C: (f, a) => f(...a)
@@ -2717,10 +2777,10 @@ var InvitationsHandler = class {
2717
2777
  break;
2718
2778
  }
2719
2779
  }
2720
- (0, import_log5.log)("request admission", {
2780
+ (0, import_log6.log)("request admission", {
2721
2781
  ...protocol.toJSON()
2722
2782
  }, {
2723
- F: __dxlog_file11,
2783
+ F: __dxlog_file12,
2724
2784
  L: 291,
2725
2785
  S: this,
2726
2786
  C: (f, a) => f(...a)
@@ -2729,10 +2789,10 @@ var InvitationsHandler = class {
2729
2789
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
2730
2790
  admitted = true;
2731
2791
  const result = await protocol.accept(admissionResponse, admissionRequest);
2732
- (0, import_log5.log)("admitted by host", {
2792
+ (0, import_log6.log)("admitted by host", {
2733
2793
  ...protocol.toJSON()
2734
2794
  }, {
2735
- F: __dxlog_file11,
2795
+ F: __dxlog_file12,
2736
2796
  L: 302,
2737
2797
  S: this,
2738
2798
  C: (f, a) => f(...a)
@@ -2742,28 +2802,28 @@ var InvitationsHandler = class {
2742
2802
  ...result,
2743
2803
  state: import_services6.Invitation.State.SUCCESS
2744
2804
  });
2745
- import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
2805
+ import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
2746
2806
  id: traceId
2747
2807
  }), {
2748
- F: __dxlog_file11,
2808
+ F: __dxlog_file12,
2749
2809
  L: 308,
2750
2810
  S: this,
2751
2811
  C: (f, a) => f(...a)
2752
2812
  });
2753
2813
  } catch (err) {
2754
- if (err instanceof import_async8.TimeoutError) {
2755
- (0, import_log5.log)("timeout", {
2814
+ if (err instanceof import_async9.TimeoutError) {
2815
+ (0, import_log6.log)("timeout", {
2756
2816
  ...protocol.toJSON()
2757
2817
  }, {
2758
- F: __dxlog_file11,
2818
+ F: __dxlog_file12,
2759
2819
  L: 311,
2760
2820
  S: this,
2761
2821
  C: (f, a) => f(...a)
2762
2822
  });
2763
2823
  guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
2764
2824
  } else {
2765
- (0, import_log5.log)("auth failed", err, {
2766
- F: __dxlog_file11,
2825
+ (0, import_log6.log)("auth failed", err, {
2826
+ F: __dxlog_file12,
2767
2827
  L: 314,
2768
2828
  S: this,
2769
2829
  C: (f, a) => f(...a)
@@ -2771,11 +2831,11 @@ var InvitationsHandler = class {
2771
2831
  guardedState.error(extension, err);
2772
2832
  }
2773
2833
  extensionCtx.close(err);
2774
- import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.error({
2834
+ import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.error({
2775
2835
  id: traceId,
2776
2836
  error: err
2777
2837
  }), {
2778
- F: __dxlog_file11,
2838
+ F: __dxlog_file12,
2779
2839
  L: 318,
2780
2840
  S: this,
2781
2841
  C: (f, a) => f(...a)
@@ -2787,19 +2847,19 @@ var InvitationsHandler = class {
2787
2847
  if (err instanceof import_protocols5.InvalidInvitationExtensionRoleError) {
2788
2848
  return;
2789
2849
  }
2790
- if (err instanceof import_async8.TimeoutError) {
2791
- (0, import_log5.log)("timeout", {
2850
+ if (err instanceof import_async9.TimeoutError) {
2851
+ (0, import_log6.log)("timeout", {
2792
2852
  ...protocol.toJSON()
2793
2853
  }, {
2794
- F: __dxlog_file11,
2854
+ F: __dxlog_file12,
2795
2855
  L: 327,
2796
2856
  S: this,
2797
2857
  C: (f, a) => f(...a)
2798
2858
  });
2799
2859
  guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
2800
2860
  } else {
2801
- (0, import_log5.log)("auth failed", err, {
2802
- F: __dxlog_file11,
2861
+ (0, import_log6.log)("auth failed", err, {
2862
+ F: __dxlog_file12,
2803
2863
  L: 330,
2804
2864
  S: this,
2805
2865
  C: (f, a) => f(...a)
@@ -2810,14 +2870,14 @@ var InvitationsHandler = class {
2810
2870
  });
2811
2871
  return extension;
2812
2872
  };
2813
- (0, import_async8.scheduleTask)(ctx, async () => {
2873
+ (0, import_async9.scheduleTask)(ctx, async () => {
2814
2874
  const error = protocol.checkInvitation(invitation);
2815
2875
  if (error) {
2816
2876
  stream.error(error);
2817
2877
  await ctx.dispose();
2818
2878
  } else {
2819
2879
  (0, import_invariant6.invariant)(invitation.swarmKey, void 0, {
2820
- F: __dxlog_file11,
2880
+ F: __dxlog_file12,
2821
2881
  L: 345,
2822
2882
  S: this,
2823
2883
  A: [
@@ -2856,7 +2916,7 @@ var InvitationsHandler = class {
2856
2916
  * invitation flow connections.
2857
2917
  */
2858
2918
  _createGuardedState(ctx, invitation, stream) {
2859
- const mutex = new import_async8.Mutex();
2919
+ const mutex = new import_async9.Mutex();
2860
2920
  let lastActiveExtension = null;
2861
2921
  let currentInvitation = {
2862
2922
  ...invitation
@@ -2911,16 +2971,29 @@ var InvitationsHandler = class {
2911
2971
  };
2912
2972
  }
2913
2973
  _logStateUpdate(invitation, actor, newState) {
2914
- (0, import_log5.log)("invitation state update", {
2915
- actor: actor?.constructor.name,
2916
- newState: stateToString(newState),
2917
- oldState: stateToString(invitation.state)
2918
- }, {
2919
- F: __dxlog_file11,
2920
- L: 438,
2921
- S: this,
2922
- C: (f, a) => f(...a)
2923
- });
2974
+ if (this._isNotTerminal(newState)) {
2975
+ (0, import_log6.log)("invitation state update", {
2976
+ actor: actor?.constructor.name,
2977
+ newState: stateToString(newState),
2978
+ oldState: stateToString(invitation.state)
2979
+ }, {
2980
+ F: __dxlog_file12,
2981
+ L: 439,
2982
+ S: this,
2983
+ C: (f, a) => f(...a)
2984
+ });
2985
+ } else {
2986
+ import_log6.log.info("invitation state update", {
2987
+ actor: actor?.constructor.name,
2988
+ newState: stateToString(newState),
2989
+ oldState: stateToString(invitation.state)
2990
+ }, {
2991
+ F: __dxlog_file12,
2992
+ L: 445,
2993
+ S: this,
2994
+ C: (f, a) => f(...a)
2995
+ });
2996
+ }
2924
2997
  }
2925
2998
  _isNotTerminal(currentState) {
2926
2999
  return ![
@@ -2933,17 +3006,17 @@ var InvitationsHandler = class {
2933
3006
  }
2934
3007
  async _handleGuestOtpAuth(extension, setState, authenticated, options) {
2935
3008
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2936
- (0, import_log5.log)("guest waiting for authentication code...", void 0, {
2937
- F: __dxlog_file11,
2938
- L: 462,
3009
+ (0, import_log6.log)("guest waiting for authentication code...", void 0, {
3010
+ F: __dxlog_file12,
3011
+ L: 470,
2939
3012
  S: this,
2940
3013
  C: (f, a) => f(...a)
2941
3014
  });
2942
3015
  setState(import_services6.Invitation.State.READY_FOR_AUTHENTICATION);
2943
3016
  const authCode = await authenticated.wait(options);
2944
- (0, import_log5.log)("sending authentication request", void 0, {
2945
- F: __dxlog_file11,
2946
- L: 466,
3017
+ (0, import_log6.log)("sending authentication request", void 0, {
3018
+ F: __dxlog_file12,
3019
+ L: 474,
2947
3020
  S: this,
2948
3021
  C: (f, a) => f(...a)
2949
3022
  });
@@ -2958,11 +3031,11 @@ var InvitationsHandler = class {
2958
3031
  if (attempt === MAX_OTP_ATTEMPTS) {
2959
3032
  throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
2960
3033
  } else {
2961
- (0, import_log5.log)("retrying invalid code", {
3034
+ (0, import_log6.log)("retrying invalid code", {
2962
3035
  attempt
2963
3036
  }, {
2964
- F: __dxlog_file11,
2965
- L: 477,
3037
+ F: __dxlog_file12,
3038
+ L: 485,
2966
3039
  S: this,
2967
3040
  C: (f, a) => f(...a)
2968
3041
  });
@@ -2978,9 +3051,9 @@ var InvitationsHandler = class {
2978
3051
  if (introductionResponse.challenge == null) {
2979
3052
  throw new Error("challenge missing in the introduction");
2980
3053
  }
2981
- (0, import_log5.log)("sending authentication request", void 0, {
2982
- F: __dxlog_file11,
2983
- L: 496,
3054
+ (0, import_log6.log)("sending authentication request", void 0, {
3055
+ F: __dxlog_file12,
3056
+ L: 504,
2984
3057
  S: this,
2985
3058
  C: (f, a) => f(...a)
2986
3059
  });
@@ -3094,7 +3167,7 @@ var InvitationsServiceImpl = class {
3094
3167
  });
3095
3168
  }
3096
3169
  };
3097
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
3170
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
3098
3171
  var SpaceInvitationProtocol = class {
3099
3172
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
3100
3173
  this._spaceManager = _spaceManager;
@@ -3128,79 +3201,43 @@ var SpaceInvitationProtocol = class {
3128
3201
  };
3129
3202
  }
3130
3203
  async admit(invitation, request, guestProfile) {
3131
- (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3132
- F: __dxlog_file12,
3133
- L: 76,
3204
+ (0, import_invariant10.invariant)(this._spaceKey && request.space, void 0, {
3205
+ F: __dxlog_file13,
3206
+ L: 74,
3134
3207
  S: this,
3135
3208
  A: [
3136
- "this._spaceKey",
3209
+ "this._spaceKey && request.space",
3137
3210
  ""
3138
3211
  ]
3139
3212
  });
3140
- const space = this._spaceManager.spaces.get(this._spaceKey);
3141
- (0, import_invariant10.invariant)(space, void 0, {
3142
- F: __dxlog_file12,
3143
- L: 78,
3213
+ (0, import_log10.log)("writing guest credentials", {
3214
+ host: this._signingContext.deviceKey,
3215
+ guest: request.space.deviceKey
3216
+ }, {
3217
+ F: __dxlog_file13,
3218
+ L: 75,
3144
3219
  S: this,
3145
- A: [
3146
- "space",
3147
- ""
3148
- ]
3220
+ C: (f, a) => f(...a)
3149
3221
  });
3150
- (0, import_invariant10.invariant)(request.space, void 0, {
3151
- F: __dxlog_file12,
3152
- L: 80,
3153
- S: this,
3154
- A: [
3155
- "request.space",
3156
- ""
3157
- ]
3158
- });
3159
- const { identityKey, deviceKey } = request.space;
3160
- if (space.inner.spaceState.getMemberRole(identityKey) !== import_credentials10.SpaceMember.Role.REMOVED) {
3161
- throw new import_protocols8.AlreadyJoinedError();
3162
- }
3163
- (0, import_log9.log)("writing guest credentials", {
3164
- host: this._signingContext.deviceKey,
3165
- guest: deviceKey
3166
- }, {
3167
- F: __dxlog_file12,
3168
- L: 87,
3169
- S: this,
3170
- C: (f, a) => f(...a)
3171
- });
3172
- const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, invitation.role ?? import_credentials10.SpaceMember.Role.ADMIN, space.inner.spaceState.membershipChainHeads, guestProfile, invitation.delegationCredentialId);
3173
- (0, import_invariant10.invariant)(credentials[0].credential, void 0, {
3174
- F: __dxlog_file12,
3175
- L: 101,
3176
- S: this,
3177
- A: [
3178
- "credentials[0].credential",
3179
- ""
3180
- ]
3181
- });
3182
- const spaceMemberCredential = credentials[0].credential.credential;
3183
- (0, import_invariant10.invariant)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3184
- F: __dxlog_file12,
3185
- L: 103,
3186
- S: this,
3187
- A: [
3188
- "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
3189
- ""
3190
- ]
3222
+ const spaceMemberCredential = await this._spaceManager.admitMember({
3223
+ spaceKey: this._spaceKey,
3224
+ identityKey: request.space.identityKey,
3225
+ role: invitation.role ?? import_credentials10.SpaceMember.Role.ADMIN,
3226
+ profile: guestProfile,
3227
+ delegationCredentialId: invitation.delegationCredentialId
3191
3228
  });
3192
- await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
3229
+ const space = this._spaceManager.spaces.get(this._spaceKey);
3193
3230
  return {
3194
3231
  space: {
3195
3232
  credential: spaceMemberCredential,
3196
- controlTimeframe: space.inner.controlPipeline.state.timeframe
3233
+ controlTimeframe: space?.inner.controlPipeline.state.timeframe
3197
3234
  }
3198
3235
  };
3199
3236
  }
3200
3237
  async delegate(invitation) {
3201
3238
  (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3202
- F: __dxlog_file12,
3203
- L: 116,
3239
+ F: __dxlog_file13,
3240
+ L: 95,
3204
3241
  S: this,
3205
3242
  A: [
3206
3243
  "this._spaceKey",
@@ -3209,8 +3246,8 @@ var SpaceInvitationProtocol = class {
3209
3246
  });
3210
3247
  const space = this._spaceManager.spaces.get(this._spaceKey);
3211
3248
  (0, import_invariant10.invariant)(space, void 0, {
3212
- F: __dxlog_file12,
3213
- L: 118,
3249
+ F: __dxlog_file13,
3250
+ L: 97,
3214
3251
  S: this,
3215
3252
  A: [
3216
3253
  "space",
@@ -3219,8 +3256,8 @@ var SpaceInvitationProtocol = class {
3219
3256
  });
3220
3257
  if (invitation.authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
3221
3258
  (0, import_invariant10.invariant)(invitation.guestKeypair?.publicKey, void 0, {
3222
- F: __dxlog_file12,
3223
- L: 120,
3259
+ F: __dxlog_file13,
3260
+ L: 99,
3224
3261
  S: this,
3225
3262
  A: [
3226
3263
  "invitation.guestKeypair?.publicKey",
@@ -3228,12 +3265,12 @@ var SpaceInvitationProtocol = class {
3228
3265
  ]
3229
3266
  });
3230
3267
  }
3231
- (0, import_log9.log)("writing delegate space invitation", {
3268
+ (0, import_log10.log)("writing delegate space invitation", {
3232
3269
  host: this._signingContext.deviceKey,
3233
3270
  id: invitation.invitationId
3234
3271
  }, {
3235
- F: __dxlog_file12,
3236
- L: 123,
3272
+ F: __dxlog_file13,
3273
+ L: 102,
3237
3274
  S: this,
3238
3275
  C: (f, a) => f(...a)
3239
3276
  });
@@ -3247,8 +3284,8 @@ var SpaceInvitationProtocol = class {
3247
3284
  guestKey: invitation.authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
3248
3285
  });
3249
3286
  (0, import_invariant10.invariant)(credential.credential, void 0, {
3250
- F: __dxlog_file12,
3251
- L: 143,
3287
+ F: __dxlog_file13,
3288
+ L: 122,
3252
3289
  S: this,
3253
3290
  A: [
3254
3291
  "credential.credential",
@@ -3262,8 +3299,8 @@ var SpaceInvitationProtocol = class {
3262
3299
  }
3263
3300
  async cancelDelegation(invitation) {
3264
3301
  (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3265
- F: __dxlog_file12,
3266
- L: 149,
3302
+ F: __dxlog_file13,
3303
+ L: 128,
3267
3304
  S: this,
3268
3305
  A: [
3269
3306
  "this._spaceKey",
@@ -3271,8 +3308,8 @@ var SpaceInvitationProtocol = class {
3271
3308
  ]
3272
3309
  });
3273
3310
  (0, import_invariant10.invariant)(invitation.type === import_services10.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
3274
- F: __dxlog_file12,
3275
- L: 150,
3311
+ F: __dxlog_file13,
3312
+ L: 129,
3276
3313
  S: this,
3277
3314
  A: [
3278
3315
  "invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
@@ -3281,27 +3318,27 @@ var SpaceInvitationProtocol = class {
3281
3318
  });
3282
3319
  const space = this._spaceManager.spaces.get(this._spaceKey);
3283
3320
  (0, import_invariant10.invariant)(space, void 0, {
3284
- F: __dxlog_file12,
3285
- L: 152,
3321
+ F: __dxlog_file13,
3322
+ L: 131,
3286
3323
  S: this,
3287
3324
  A: [
3288
3325
  "space",
3289
3326
  ""
3290
3327
  ]
3291
3328
  });
3292
- (0, import_log9.log)("cancelling delegated space invitation", {
3329
+ (0, import_log10.log)("cancelling delegated space invitation", {
3293
3330
  host: this._signingContext.deviceKey,
3294
3331
  id: invitation.invitationId
3295
3332
  }, {
3296
- F: __dxlog_file12,
3297
- L: 154,
3333
+ F: __dxlog_file13,
3334
+ L: 133,
3298
3335
  S: this,
3299
3336
  C: (f, a) => f(...a)
3300
3337
  });
3301
3338
  const credential = await (0, import_credentials9.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
3302
3339
  (0, import_invariant10.invariant)(credential.credential, void 0, {
3303
- F: __dxlog_file12,
3304
- L: 161,
3340
+ F: __dxlog_file13,
3341
+ L: 140,
3305
3342
  S: this,
3306
3343
  A: [
3307
3344
  "credential.credential",
@@ -3339,8 +3376,8 @@ var SpaceInvitationProtocol = class {
3339
3376
  }
3340
3377
  async accept(response) {
3341
3378
  (0, import_invariant10.invariant)(response.space, void 0, {
3342
- F: __dxlog_file12,
3343
- L: 196,
3379
+ F: __dxlog_file13,
3380
+ L: 175,
3344
3381
  S: this,
3345
3382
  A: [
3346
3383
  "response.space",
@@ -3350,8 +3387,8 @@ var SpaceInvitationProtocol = class {
3350
3387
  const { credential, controlTimeframe, dataTimeframe } = response.space;
3351
3388
  const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
3352
3389
  (0, import_invariant10.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3353
- F: __dxlog_file12,
3354
- L: 199,
3390
+ F: __dxlog_file13,
3391
+ L: 178,
3355
3392
  S: this,
3356
3393
  A: [
3357
3394
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3359,8 +3396,8 @@ var SpaceInvitationProtocol = class {
3359
3396
  ]
3360
3397
  });
3361
3398
  (0, import_invariant10.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
3362
- F: __dxlog_file12,
3363
- L: 200,
3399
+ F: __dxlog_file13,
3400
+ L: 179,
3364
3401
  S: this,
3365
3402
  A: [
3366
3403
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -3382,7 +3419,7 @@ var SpaceInvitationProtocol = class {
3382
3419
  };
3383
3420
  }
3384
3421
  };
3385
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3422
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3386
3423
  var InvitationsManager = class {
3387
3424
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
3388
3425
  this._invitationsHandler = _invitationsHandler;
@@ -3390,12 +3427,12 @@ var InvitationsManager = class {
3390
3427
  this._metadataStore = _metadataStore;
3391
3428
  this._createInvitations = /* @__PURE__ */ new Map();
3392
3429
  this._acceptInvitations = /* @__PURE__ */ new Map();
3393
- this.invitationCreated = new import_async11.Event();
3394
- this.invitationAccepted = new import_async11.Event();
3395
- this.removedCreated = new import_async11.Event();
3396
- this.removedAccepted = new import_async11.Event();
3397
- this.saved = new import_async11.Event();
3398
- this._persistentInvitationsLoadedEvent = new import_async11.Event();
3430
+ this.invitationCreated = new import_async12.Event();
3431
+ this.invitationAccepted = new import_async12.Event();
3432
+ this.removedCreated = new import_async12.Event();
3433
+ this.removedAccepted = new import_async12.Event();
3434
+ this.saved = new import_async12.Event();
3435
+ this._persistentInvitationsLoadedEvent = new import_async12.Event();
3399
3436
  this._persistentInvitationsLoaded = false;
3400
3437
  }
3401
3438
  async createInvitation(options) {
@@ -3424,8 +3461,8 @@ var InvitationsManager = class {
3424
3461
  try {
3425
3462
  await this._persistIfRequired(handler, stream, invitation);
3426
3463
  } catch (err) {
3427
- import_log10.log.catch(err, void 0, {
3428
- F: __dxlog_file13,
3464
+ import_log11.log.catch(err, void 0, {
3465
+ F: __dxlog_file14,
3429
3466
  L: 82,
3430
3467
  S: this,
3431
3468
  C: (f, a) => f(...a)
@@ -3448,7 +3485,7 @@ var InvitationsManager = class {
3448
3485
  const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
3449
3486
  const loadTasks = freshInvitations.map((persistentInvitation) => {
3450
3487
  (0, import_invariant11.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
3451
- F: __dxlog_file13,
3488
+ F: __dxlog_file14,
3452
3489
  L: 103,
3453
3490
  S: this,
3454
3491
  A: [
@@ -3466,8 +3503,8 @@ var InvitationsManager = class {
3466
3503
  invitations: cInvitations.map((invitation) => invitation.get())
3467
3504
  };
3468
3505
  } catch (err) {
3469
- import_log10.log.catch(err, void 0, {
3470
- F: __dxlog_file13,
3506
+ import_log11.log.catch(err, void 0, {
3507
+ F: __dxlog_file14,
3471
3508
  L: 110,
3472
3509
  S: this,
3473
3510
  C: (f, a) => f(...a)
@@ -3498,14 +3535,14 @@ var InvitationsManager = class {
3498
3535
  return invitation;
3499
3536
  }
3500
3537
  async authenticate({ invitationId, authCode }) {
3501
- (0, import_log10.log)("authenticating...", void 0, {
3502
- F: __dxlog_file13,
3538
+ (0, import_log11.log)("authenticating...", void 0, {
3539
+ F: __dxlog_file14,
3503
3540
  L: 140,
3504
3541
  S: this,
3505
3542
  C: (f, a) => f(...a)
3506
3543
  });
3507
3544
  (0, import_invariant11.invariant)(invitationId, void 0, {
3508
- F: __dxlog_file13,
3545
+ F: __dxlog_file14,
3509
3546
  L: 141,
3510
3547
  S: this,
3511
3548
  A: [
@@ -3515,10 +3552,10 @@ var InvitationsManager = class {
3515
3552
  });
3516
3553
  const observable = this._acceptInvitations.get(invitationId);
3517
3554
  if (!observable) {
3518
- import_log10.log.warn("invalid invitation", {
3555
+ import_log11.log.warn("invalid invitation", {
3519
3556
  invitationId
3520
3557
  }, {
3521
- F: __dxlog_file13,
3558
+ F: __dxlog_file14,
3522
3559
  L: 144,
3523
3560
  S: this,
3524
3561
  C: (f, a) => f(...a)
@@ -3528,16 +3565,16 @@ var InvitationsManager = class {
3528
3565
  }
3529
3566
  }
3530
3567
  async cancelInvitation({ invitationId }) {
3531
- (0, import_log10.log)("cancelInvitation...", {
3568
+ (0, import_log11.log)("cancelInvitation...", {
3532
3569
  invitationId
3533
3570
  }, {
3534
- F: __dxlog_file13,
3571
+ F: __dxlog_file14,
3535
3572
  L: 151,
3536
3573
  S: this,
3537
3574
  C: (f, a) => f(...a)
3538
3575
  });
3539
3576
  (0, import_invariant11.invariant)(invitationId, void 0, {
3540
- F: __dxlog_file13,
3577
+ F: __dxlog_file14,
3541
3578
  L: 152,
3542
3579
  S: this,
3543
3580
  A: [
@@ -3605,18 +3642,21 @@ var InvitationsManager = class {
3605
3642
  };
3606
3643
  }
3607
3644
  _createObservableInvitation(handler, invitation) {
3608
- const stream = new import_async11.PushStream();
3645
+ const stream = new import_async12.PushStream();
3609
3646
  const ctx = new import_context9.Context({
3610
3647
  onError: (err) => {
3611
3648
  stream.error(err);
3612
3649
  void ctx.dispose();
3613
3650
  }
3651
+ }, {
3652
+ F: __dxlog_file14,
3653
+ L: 234
3614
3654
  });
3615
3655
  ctx.onDispose(() => {
3616
- (0, import_log10.log)("complete", {
3656
+ (0, import_log11.log)("complete", {
3617
3657
  ...handler.toJSON()
3618
3658
  }, {
3619
- F: __dxlog_file13,
3659
+ F: __dxlog_file14,
3620
3660
  L: 241,
3621
3661
  S: this,
3622
3662
  C: (f, a) => f(...a)
@@ -3641,15 +3681,15 @@ var InvitationsManager = class {
3641
3681
  };
3642
3682
  }
3643
3683
  _createObservableAcceptingInvitation(handler, initialState) {
3644
- const otpEnteredTrigger = new import_async11.Trigger();
3645
- const stream = new import_async11.PushStream();
3684
+ const otpEnteredTrigger = new import_async12.Trigger();
3685
+ const stream = new import_async12.PushStream();
3646
3686
  const ctx = new import_context9.Context({
3647
3687
  onError: (err) => {
3648
- if (err instanceof import_async11.TimeoutError) {
3649
- (0, import_log10.log)("timeout", {
3688
+ if (err instanceof import_async12.TimeoutError) {
3689
+ (0, import_log11.log)("timeout", {
3650
3690
  ...handler.toJSON()
3651
3691
  }, {
3652
- F: __dxlog_file13,
3692
+ F: __dxlog_file14,
3653
3693
  L: 261,
3654
3694
  S: this,
3655
3695
  C: (f, a) => f(...a)
@@ -3659,8 +3699,8 @@ var InvitationsManager = class {
3659
3699
  state: import_services11.Invitation.State.TIMEOUT
3660
3700
  });
3661
3701
  } else {
3662
- import_log10.log.warn("auth failed", err, {
3663
- F: __dxlog_file13,
3702
+ import_log11.log.warn("auth failed", err, {
3703
+ F: __dxlog_file14,
3664
3704
  L: 264,
3665
3705
  S: this,
3666
3706
  C: (f, a) => f(...a)
@@ -3672,12 +3712,15 @@ var InvitationsManager = class {
3672
3712
  }
3673
3713
  void ctx.dispose();
3674
3714
  }
3715
+ }, {
3716
+ F: __dxlog_file14,
3717
+ L: 258
3675
3718
  });
3676
3719
  ctx.onDispose(() => {
3677
- (0, import_log10.log)("complete", {
3720
+ (0, import_log11.log)("complete", {
3678
3721
  ...handler.toJSON()
3679
3722
  }, {
3680
- F: __dxlog_file13,
3723
+ F: __dxlog_file14,
3681
3724
  L: 271,
3682
3725
  S: this,
3683
3726
  C: (f, a) => f(...a)
@@ -3721,8 +3764,8 @@ var InvitationsManager = class {
3721
3764
  try {
3722
3765
  await this._metadataStore.removeInvitation(invitation.invitationId);
3723
3766
  } catch (err) {
3724
- import_log10.log.catch(err, void 0, {
3725
- F: __dxlog_file13,
3767
+ import_log11.log.catch(err, void 0, {
3768
+ F: __dxlog_file14,
3726
3769
  L: 307,
3727
3770
  S: this,
3728
3771
  C: (f, a) => f(...a)
@@ -3741,7 +3784,7 @@ var AutomergeSpaceState = class extends import_context11.Resource {
3741
3784
  this._onNewRoot = _onNewRoot;
3742
3785
  this.rootUrl = void 0;
3743
3786
  this.lastEpoch = void 0;
3744
- this.onNewEpoch = new import_async13.Event();
3787
+ this.onNewEpoch = new import_async14.Event();
3745
3788
  this._isProcessingRootDocs = false;
3746
3789
  }
3747
3790
  async _open(ctx) {
@@ -3775,7 +3818,7 @@ var AutomergeSpaceState = class extends import_context11.Resource {
3775
3818
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3776
3819
  }
3777
3820
  };
3778
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
3821
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
3779
3822
  var runEpochMigration = async (ctx, context) => {
3780
3823
  switch (context.migration) {
3781
3824
  case import_services13.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
@@ -3790,7 +3833,7 @@ var runEpochMigration = async (ctx, context) => {
3790
3833
  throw new Error("Space does not have an automerge root");
3791
3834
  }
3792
3835
  const rootHandle = context.repo.find(context.currentRoot);
3793
- await (0, import_context12.cancelWithContext)(ctx, (0, import_async14.asyncTimeout)(rootHandle.whenReady(), 1e4));
3836
+ await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
3794
3837
  const newRoot = context.repo.create(rootHandle.docSync());
3795
3838
  await context.repo.flush();
3796
3839
  return {
@@ -3798,20 +3841,20 @@ var runEpochMigration = async (ctx, context) => {
3798
3841
  };
3799
3842
  }
3800
3843
  case import_services13.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
3801
- import_log12.log.info("Fragmenting", void 0, {
3802
- F: __dxlog_file14,
3844
+ import_log13.log.info("Fragmenting", void 0, {
3845
+ F: __dxlog_file15,
3803
3846
  L: 63,
3804
3847
  S: void 0,
3805
3848
  C: (f, a) => f(...a)
3806
3849
  });
3807
3850
  const currentRootUrl = context.currentRoot;
3808
3851
  const rootHandle = context.repo.find(currentRootUrl);
3809
- await (0, import_context12.cancelWithContext)(ctx, (0, import_async14.asyncTimeout)(rootHandle.whenReady(), 1e4));
3852
+ await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
3810
3853
  const objects = Object.entries(rootHandle.docSync().objects);
3811
3854
  const properties = (0, import_echo_db.findInlineObjectOfType)(rootHandle.docSync(), import_echo_schema.TYPE_PROPERTIES);
3812
3855
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3813
3856
  (0, import_invariant13.invariant)(properties, "Properties not found", {
3814
- F: __dxlog_file14,
3857
+ F: __dxlog_file15,
3815
3858
  L: 73,
3816
3859
  S: void 0,
3817
3860
  A: [
@@ -3827,7 +3870,7 @@ var runEpochMigration = async (ctx, context) => {
3827
3870
  };
3828
3871
  const newRoot = context.repo.create(newSpaceDoc);
3829
3872
  (0, import_invariant13.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3830
- F: __dxlog_file14,
3873
+ F: __dxlog_file15,
3831
3874
  L: 78,
3832
3875
  S: void 0,
3833
3876
  A: [
@@ -3842,7 +3885,7 @@ var runEpochMigration = async (ctx, context) => {
3842
3885
  otherObjects.forEach(([key, value]) => {
3843
3886
  const handle = docLoader.createDocumentForObject(key);
3844
3887
  handle.change((doc) => {
3845
- (0, import_util7.assignDeep)(doc, [
3888
+ (0, import_util8.assignDeep)(doc, [
3846
3889
  "objects",
3847
3890
  key
3848
3891
  ], value);
@@ -3856,9 +3899,9 @@ var runEpochMigration = async (ctx, context) => {
3856
3899
  case import_services13.CreateEpochRequest.Migration.MIGRATE_REFERENCES_TO_DXN: {
3857
3900
  const currentRootUrl = context.currentRoot;
3858
3901
  const rootHandle = context.repo.find(currentRootUrl);
3859
- await (0, import_context12.cancelWithContext)(ctx, (0, import_async14.asyncTimeout)(rootHandle.whenReady(), 1e4));
3902
+ await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
3860
3903
  (0, import_invariant13.invariant)(rootHandle.docSync(), "Root doc not found", {
3861
- F: __dxlog_file14,
3904
+ F: __dxlog_file15,
3862
3905
  L: 100,
3863
3906
  S: void 0,
3864
3907
  A: [
@@ -3868,21 +3911,35 @@ var runEpochMigration = async (ctx, context) => {
3868
3911
  });
3869
3912
  const newRootContent = await (0, import_echo_db.convertLegacySpaceRootDoc)(structuredClone(rootHandle.docSync()));
3870
3913
  for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
3871
- const handle = context.repo.find(url);
3872
- await (0, import_context12.cancelWithContext)(ctx, (0, import_async14.asyncTimeout)(handle.whenReady(), 1e4));
3873
- (0, import_invariant13.invariant)(handle.docSync(), "Doc not found", {
3874
- F: __dxlog_file14,
3875
- L: 107,
3876
- S: void 0,
3877
- A: [
3878
- "handle.docSync()",
3879
- "'Doc not found'"
3880
- ]
3881
- });
3882
- const newDoc = await (0, import_echo_db.convertLegacyReferences)(structuredClone(handle.docSync()));
3883
- const migratedDoc = (0, import_echo_db.migrateDocument)(handle.docSync(), newDoc);
3884
- const newHandle = context.repo.import(import_automerge.next.save(migratedDoc));
3885
- newRootContent.links[id] = newHandle.url;
3914
+ try {
3915
+ const handle = context.repo.find(url);
3916
+ await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(handle.whenReady(), 1e4));
3917
+ (0, import_invariant13.invariant)(handle.docSync(), "Doc not found", {
3918
+ F: __dxlog_file15,
3919
+ L: 108,
3920
+ S: void 0,
3921
+ A: [
3922
+ "handle.docSync()",
3923
+ "'Doc not found'"
3924
+ ]
3925
+ });
3926
+ const newDoc = await (0, import_echo_db.convertLegacyReferences)(structuredClone(handle.docSync()));
3927
+ const migratedDoc = (0, import_echo_db.migrateDocument)(handle.docSync(), newDoc);
3928
+ const newHandle = context.repo.import(import_automerge.next.save(migratedDoc));
3929
+ newRootContent.links[id] = newHandle.url;
3930
+ } catch (err) {
3931
+ import_log13.log.warn("Failed to migrate reference", {
3932
+ id,
3933
+ url,
3934
+ error: err
3935
+ }, {
3936
+ F: __dxlog_file15,
3937
+ L: 114,
3938
+ S: void 0,
3939
+ C: (f, a) => f(...a)
3940
+ });
3941
+ delete newRootContent.links[id];
3942
+ }
3886
3943
  }
3887
3944
  const migratedRoot = (0, import_echo_db.migrateDocument)(rootHandle.docSync(), newRootContent);
3888
3945
  const newRoot = context.repo.import(import_automerge.next.save(migratedRoot));
@@ -3893,8 +3950,8 @@ var runEpochMigration = async (ctx, context) => {
3893
3950
  }
3894
3951
  case import_services13.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
3895
3952
  (0, import_invariant13.invariant)(context.newAutomergeRoot, void 0, {
3896
- F: __dxlog_file14,
3897
- L: 124,
3953
+ F: __dxlog_file15,
3954
+ L: 129,
3898
3955
  S: void 0,
3899
3956
  A: [
3900
3957
  "context.newAutomergeRoot",
@@ -3909,18 +3966,21 @@ var runEpochMigration = async (ctx, context) => {
3909
3966
  }
3910
3967
  return {};
3911
3968
  };
3912
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3969
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3913
3970
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3914
3971
  var DEFAULT_SUCCESS_DELAY = 1e3;
3915
3972
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
3916
3973
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3917
3974
  var NotarizationPlugin = class {
3918
3975
  constructor() {
3919
- this._ctx = new import_context13.Context();
3920
- this._extensionOpened = new import_async15.Event();
3976
+ this._ctx = new import_context13.Context(void 0, {
3977
+ F: __dxlog_file16,
3978
+ L: 62
3979
+ });
3980
+ this._extensionOpened = new import_async16.Event();
3921
3981
  this._extensions = /* @__PURE__ */ new Set();
3922
- this._processedCredentials = new import_util8.ComplexSet(import_keys11.PublicKey.hash);
3923
- this._processCredentialsTriggers = new import_util8.ComplexMap(import_keys11.PublicKey.hash);
3982
+ this._processedCredentials = new import_util9.ComplexSet(import_keys11.PublicKey.hash);
3983
+ this._processCredentialsTriggers = new import_util9.ComplexMap(import_keys11.PublicKey.hash);
3924
3984
  }
3925
3985
  get hasWriter() {
3926
3986
  return !!this._writer;
@@ -3934,16 +3994,16 @@ var NotarizationPlugin = class {
3934
3994
  * Request credentials to be notarized.
3935
3995
  */
3936
3996
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
3937
- (0, import_log13.log)("notarize", {
3997
+ (0, import_log14.log)("notarize", {
3938
3998
  credentials
3939
3999
  }, {
3940
- F: __dxlog_file15,
4000
+ F: __dxlog_file16,
3941
4001
  L: 90,
3942
4002
  S: this,
3943
4003
  C: (f, a) => f(...a)
3944
4004
  });
3945
4005
  (0, import_invariant14.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
3946
- F: __dxlog_file15,
4006
+ F: __dxlog_file16,
3947
4007
  L: 91,
3948
4008
  S: this,
3949
4009
  A: [
@@ -3951,13 +4011,13 @@ var NotarizationPlugin = class {
3951
4011
  "'Credentials must have an id'"
3952
4012
  ]
3953
4013
  });
3954
- const errors = new import_async15.Trigger();
4014
+ const errors = new import_async16.Trigger();
3955
4015
  const ctx = this._ctx.derive({
3956
4016
  onError: (err) => {
3957
- import_log13.log.warn("Notarization error", {
4017
+ import_log14.log.warn("Notarization error", {
3958
4018
  err
3959
4019
  }, {
3960
- F: __dxlog_file15,
4020
+ F: __dxlog_file16,
3961
4021
  L: 99,
3962
4022
  S: this,
3963
4023
  C: (f, a) => f(...a)
@@ -3968,23 +4028,23 @@ var NotarizationPlugin = class {
3968
4028
  });
3969
4029
  opCtx?.onDispose(() => ctx.dispose());
3970
4030
  if (timeout !== 0) {
3971
- (0, import_async15.scheduleTask)(ctx, () => {
3972
- import_log13.log.warn("Notarization timeout", {
4031
+ (0, import_async16.scheduleTask)(ctx, () => {
4032
+ import_log14.log.warn("Notarization timeout", {
3973
4033
  timeout,
3974
4034
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
3975
4035
  }, {
3976
- F: __dxlog_file15,
4036
+ F: __dxlog_file16,
3977
4037
  L: 111,
3978
4038
  S: this,
3979
4039
  C: (f, a) => f(...a)
3980
4040
  });
3981
4041
  void ctx.dispose();
3982
- errors.throw(new import_async15.TimeoutError(timeout, "Notarization timed out"));
4042
+ errors.throw(new import_async16.TimeoutError(timeout, "Notarization timed out"));
3983
4043
  }, timeout);
3984
4044
  }
3985
4045
  const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
3986
4046
  const peersTried = /* @__PURE__ */ new Set();
3987
- const notarizeTask = new import_async15.DeferredTask(ctx, async () => {
4047
+ const notarizeTask = new import_async16.DeferredTask(ctx, async () => {
3988
4048
  try {
3989
4049
  if (this._extensions.size === 0) {
3990
4050
  return;
@@ -3993,24 +4053,24 @@ var NotarizationPlugin = class {
3993
4053
  ...this._extensions
3994
4054
  ].find((peer2) => !peersTried.has(peer2));
3995
4055
  if (!peer) {
3996
- import_log13.log.info("Exhausted all peers to notarize with", {
4056
+ import_log14.log.info("Exhausted all peers to notarize with", {
3997
4057
  retryIn: retryTimeout
3998
4058
  }, {
3999
- F: __dxlog_file15,
4059
+ F: __dxlog_file16,
4000
4060
  L: 136,
4001
4061
  S: this,
4002
4062
  C: (f, a) => f(...a)
4003
4063
  });
4004
4064
  peersTried.clear();
4005
- (0, import_async15.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
4065
+ (0, import_async16.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
4006
4066
  return;
4007
4067
  }
4008
4068
  peersTried.add(peer);
4009
- (0, import_log13.log)("try notarizing", {
4069
+ (0, import_log14.log)("try notarizing", {
4010
4070
  peer: peer.localPeerId,
4011
4071
  credentialId: credentials.map((credential) => credential.id)
4012
4072
  }, {
4013
- F: __dxlog_file15,
4073
+ F: __dxlog_file16,
4014
4074
  L: 143,
4015
4075
  S: this,
4016
4076
  C: (f, a) => f(...a)
@@ -4018,17 +4078,17 @@ var NotarizationPlugin = class {
4018
4078
  await peer.rpc.NotarizationService.notarize({
4019
4079
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
4020
4080
  });
4021
- (0, import_log13.log)("success", void 0, {
4022
- F: __dxlog_file15,
4081
+ (0, import_log14.log)("success", void 0, {
4082
+ F: __dxlog_file16,
4023
4083
  L: 147,
4024
4084
  S: this,
4025
4085
  C: (f, a) => f(...a)
4026
4086
  });
4027
- await (0, import_async15.sleep)(successDelay);
4087
+ await (0, import_async16.sleep)(successDelay);
4028
4088
  } catch (err) {
4029
4089
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
4030
- import_log13.log.info("error notarizing (recoverable)", err, {
4031
- F: __dxlog_file15,
4090
+ import_log14.log.info("error notarizing (recoverable)", err, {
4091
+ F: __dxlog_file16,
4032
4092
  L: 151,
4033
4093
  S: this,
4034
4094
  C: (f, a) => f(...a)
@@ -4045,8 +4105,8 @@ var NotarizationPlugin = class {
4045
4105
  allNotarized,
4046
4106
  errors.wait()
4047
4107
  ]);
4048
- (0, import_log13.log)("done", void 0, {
4049
- F: __dxlog_file15,
4108
+ (0, import_log14.log)("done", void 0, {
4109
+ F: __dxlog_file16,
4050
4110
  L: 162,
4051
4111
  S: this,
4052
4112
  C: (f, a) => f(...a)
@@ -4068,7 +4128,7 @@ var NotarizationPlugin = class {
4068
4128
  }
4069
4129
  setWriter(writer) {
4070
4130
  (0, import_invariant14.invariant)(!this._writer, "Writer already set.", {
4071
- F: __dxlog_file15,
4131
+ F: __dxlog_file16,
4072
4132
  L: 181,
4073
4133
  S: this,
4074
4134
  A: [
@@ -4082,7 +4142,7 @@ var NotarizationPlugin = class {
4082
4142
  if (this._processedCredentials.has(id)) {
4083
4143
  return;
4084
4144
  }
4085
- await (0, import_util8.entry)(this._processCredentialsTriggers, id).orInsert(new import_async15.Trigger()).value.wait();
4145
+ await (0, import_util9.entry)(this._processCredentialsTriggers, id).orInsert(new import_async16.Trigger()).value.wait();
4086
4146
  }
4087
4147
  /**
4088
4148
  * Requests from other peers to notarize credentials.
@@ -4093,7 +4153,7 @@ var NotarizationPlugin = class {
4093
4153
  }
4094
4154
  for (const credential of request.credentials ?? []) {
4095
4155
  (0, import_invariant14.invariant)(credential.id, "Credential must have an id", {
4096
- F: __dxlog_file15,
4156
+ F: __dxlog_file16,
4097
4157
  L: 200,
4098
4158
  S: this,
4099
4159
  A: [
@@ -4110,10 +4170,10 @@ var NotarizationPlugin = class {
4110
4170
  createExtension() {
4111
4171
  const extension = new NotarizationTeleportExtension({
4112
4172
  onOpen: async () => {
4113
- (0, import_log13.log)("extension opened", {
4173
+ (0, import_log14.log)("extension opened", {
4114
4174
  peer: extension.localPeerId
4115
4175
  }, {
4116
- F: __dxlog_file15,
4176
+ F: __dxlog_file16,
4117
4177
  L: 211,
4118
4178
  S: this,
4119
4179
  C: (f, a) => f(...a)
@@ -4122,10 +4182,10 @@ var NotarizationPlugin = class {
4122
4182
  this._extensionOpened.emit();
4123
4183
  },
4124
4184
  onClose: async () => {
4125
- (0, import_log13.log)("extension closed", {
4185
+ (0, import_log14.log)("extension closed", {
4126
4186
  peer: extension.localPeerId
4127
4187
  }, {
4128
- F: __dxlog_file15,
4188
+ F: __dxlog_file16,
4129
4189
  L: 216,
4130
4190
  S: this,
4131
4191
  C: (f, a) => f(...a)
@@ -4240,18 +4300,21 @@ function _using_ctx() {
4240
4300
  }
4241
4301
  };
4242
4302
  }
4243
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4303
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4244
4304
  var DataSpace = class {
4245
4305
  constructor(params) {
4246
- this._ctx = new import_context10.Context();
4306
+ this._ctx = new import_context10.Context(void 0, {
4307
+ F: __dxlog_file17,
4308
+ L: 84
4309
+ });
4247
4310
  this._notarizationPlugin = new NotarizationPlugin();
4248
4311
  this._cache = void 0;
4249
4312
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
4250
- this._epochProcessingMutex = new import_async12.Mutex();
4313
+ this._epochProcessingMutex = new import_async13.Mutex();
4251
4314
  this._state = import_services12.SpaceState.CLOSED;
4252
4315
  this._databaseRoot = null;
4253
4316
  this.error = void 0;
4254
- this.stateUpdate = new import_async12.Event();
4317
+ this.stateUpdate = new import_async13.Event();
4255
4318
  this.metrics = {};
4256
4319
  this._inner = params.inner;
4257
4320
  this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
@@ -4264,16 +4327,16 @@ var DataSpace = class {
4264
4327
  this._callbacks = params.callbacks ?? {};
4265
4328
  this._echoHost = params.echoHost;
4266
4329
  this.authVerifier = new TrustedKeySetAuthVerifier({
4267
- trustedKeysProvider: () => new import_util6.ComplexSet(import_keys10.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== import_credentials13.SpaceMember.Role.REMOVED).map((member) => member.key)),
4330
+ trustedKeysProvider: () => new import_util7.ComplexSet(import_keys10.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== import_credentials13.SpaceMember.Role.REMOVED).map((member) => member.key)),
4268
4331
  update: this._inner.stateUpdate,
4269
4332
  authTimeout: import_client_protocol4.AUTH_TIMEOUT
4270
4333
  });
4271
4334
  this._cache = params.cache;
4272
4335
  this._state = params.initialState;
4273
- (0, import_log11.log)("new state", {
4336
+ (0, import_log12.log)("new state", {
4274
4337
  state: import_services12.SpaceState[this._state]
4275
4338
  }, {
4276
- F: __dxlog_file16,
4339
+ F: __dxlog_file17,
4277
4340
  L: 146,
4278
4341
  S: this,
4279
4342
  C: (f, a) => f(...a)
@@ -4328,12 +4391,15 @@ var DataSpace = class {
4328
4391
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
4329
4392
  await this._automergeSpaceState.open();
4330
4393
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
4331
- await this._inner.open(new import_context10.Context());
4394
+ await this._inner.open(new import_context10.Context(void 0, {
4395
+ F: __dxlog_file17,
4396
+ L: 215
4397
+ }));
4332
4398
  this._state = import_services12.SpaceState.CONTROL_ONLY;
4333
- (0, import_log11.log)("new state", {
4399
+ (0, import_log12.log)("new state", {
4334
4400
  state: import_services12.SpaceState[this._state]
4335
4401
  }, {
4336
- F: __dxlog_file16,
4402
+ F: __dxlog_file17,
4337
4403
  L: 217,
4338
4404
  S: this,
4339
4405
  C: (f, a) => f(...a)
@@ -4348,16 +4414,19 @@ var DataSpace = class {
4348
4414
  async _close() {
4349
4415
  await this._callbacks.beforeClose?.();
4350
4416
  this._state = import_services12.SpaceState.CLOSED;
4351
- (0, import_log11.log)("new state", {
4417
+ (0, import_log12.log)("new state", {
4352
4418
  state: import_services12.SpaceState[this._state]
4353
4419
  }, {
4354
- F: __dxlog_file16,
4420
+ F: __dxlog_file17,
4355
4421
  L: 231,
4356
4422
  S: this,
4357
4423
  C: (f, a) => f(...a)
4358
4424
  });
4359
4425
  await this._ctx.dispose();
4360
- this._ctx = new import_context10.Context();
4426
+ this._ctx = new import_context10.Context(void 0, {
4427
+ F: __dxlog_file17,
4428
+ L: 233
4429
+ });
4361
4430
  await this.authVerifier.close();
4362
4431
  await this._inner.close();
4363
4432
  await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
@@ -4377,31 +4446,31 @@ var DataSpace = class {
4377
4446
  * Initialize the data pipeline in a separate task.
4378
4447
  */
4379
4448
  initializeDataPipelineAsync() {
4380
- (0, import_async12.scheduleTask)(this._ctx, async () => {
4449
+ (0, import_async13.scheduleTask)(this._ctx, async () => {
4381
4450
  try {
4382
4451
  this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
4383
4452
  await this.initializeDataPipeline();
4384
4453
  } catch (err) {
4385
4454
  if (err instanceof import_protocols9.CancelledError || err instanceof import_context10.ContextDisposedError) {
4386
- (0, import_log11.log)("data pipeline initialization cancelled", err, {
4387
- F: __dxlog_file16,
4455
+ (0, import_log12.log)("data pipeline initialization cancelled", err, {
4456
+ F: __dxlog_file17,
4388
4457
  L: 265,
4389
4458
  S: this,
4390
4459
  C: (f, a) => f(...a)
4391
4460
  });
4392
4461
  return;
4393
4462
  }
4394
- import_log11.log.error("Error initializing data pipeline", err, {
4395
- F: __dxlog_file16,
4463
+ import_log12.log.error("Error initializing data pipeline", err, {
4464
+ F: __dxlog_file17,
4396
4465
  L: 269,
4397
4466
  S: this,
4398
4467
  C: (f, a) => f(...a)
4399
4468
  });
4400
4469
  this._state = import_services12.SpaceState.ERROR;
4401
- (0, import_log11.log)("new state", {
4470
+ (0, import_log12.log)("new state", {
4402
4471
  state: import_services12.SpaceState[this._state]
4403
4472
  }, {
4404
- F: __dxlog_file16,
4473
+ F: __dxlog_file17,
4405
4474
  L: 271,
4406
4475
  S: this,
4407
4476
  C: (f, a) => f(...a)
@@ -4418,16 +4487,16 @@ var DataSpace = class {
4418
4487
  throw new import_protocols9.SystemError("Invalid operation");
4419
4488
  }
4420
4489
  this._state = import_services12.SpaceState.INITIALIZING;
4421
- (0, import_log11.log)("new state", {
4490
+ (0, import_log12.log)("new state", {
4422
4491
  state: import_services12.SpaceState[this._state]
4423
4492
  }, {
4424
- F: __dxlog_file16,
4493
+ F: __dxlog_file17,
4425
4494
  L: 287,
4426
4495
  S: this,
4427
4496
  C: (f, a) => f(...a)
4428
4497
  });
4429
4498
  await this._initializeAndReadControlPipeline();
4430
- await (0, import_async12.sleep)(1);
4499
+ await (0, import_async13.sleep)(1);
4431
4500
  const ready = this.stateUpdate.waitForCondition(() => this._state === import_services12.SpaceState.READY);
4432
4501
  this._automergeSpaceState.startProcessingRootDocs();
4433
4502
  await ready;
@@ -4435,10 +4504,10 @@ var DataSpace = class {
4435
4504
  async _enterReadyState() {
4436
4505
  await this._callbacks.beforeReady?.();
4437
4506
  this._state = import_services12.SpaceState.READY;
4438
- (0, import_log11.log)("new state", {
4507
+ (0, import_log12.log)("new state", {
4439
4508
  state: import_services12.SpaceState[this._state]
4440
4509
  }, {
4441
- F: __dxlog_file16,
4510
+ F: __dxlog_file17,
4442
4511
  L: 306,
4443
4512
  S: this,
4444
4513
  C: (f, a) => f(...a)
@@ -4453,8 +4522,8 @@ var DataSpace = class {
4453
4522
  });
4454
4523
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
4455
4524
  await this._createWritableFeeds();
4456
- (0, import_log11.log)("writable feeds created", void 0, {
4457
- F: __dxlog_file16,
4525
+ (0, import_log12.log)("writable feeds created", void 0, {
4526
+ F: __dxlog_file17,
4458
4527
  L: 322,
4459
4528
  S: this,
4460
4529
  C: (f, a) => f(...a)
@@ -4513,16 +4582,15 @@ var DataSpace = class {
4513
4582
  }
4514
4583
  }
4515
4584
  _onNewAutomergeRoot(rootUrl) {
4516
- (0, import_log11.log)("loading automerge root doc for space", {
4585
+ (0, import_log12.log)("loading automerge root doc for space", {
4517
4586
  space: this.key,
4518
4587
  rootUrl
4519
4588
  }, {
4520
- F: __dxlog_file16,
4589
+ F: __dxlog_file17,
4521
4590
  L: 388,
4522
4591
  S: this,
4523
4592
  C: (f, a) => f(...a)
4524
4593
  });
4525
- this._echoHost.replicateDocument(rootUrl);
4526
4594
  const handle = this._echoHost.automergeRepo.find(rootUrl);
4527
4595
  queueMicrotask(async () => {
4528
4596
  try {
@@ -4549,8 +4617,10 @@ var DataSpace = class {
4549
4617
  const root = await this._echoHost.openSpaceRoot(handle.url);
4550
4618
  this._databaseRoot = root;
4551
4619
  if (root.getVersion() !== import_echo_protocol.SpaceDocVersion.CURRENT) {
4552
- this._state = import_services12.SpaceState.REQUIRES_MIGRATION;
4553
- this.stateUpdate.emit();
4620
+ if (this._state !== import_services12.SpaceState.REQUIRES_MIGRATION) {
4621
+ this._state = import_services12.SpaceState.REQUIRES_MIGRATION;
4622
+ this.stateUpdate.emit();
4623
+ }
4554
4624
  } else {
4555
4625
  if (this._state !== import_services12.SpaceState.READY) {
4556
4626
  await this._enterReadyState();
@@ -4565,12 +4635,12 @@ var DataSpace = class {
4565
4635
  if (err instanceof import_context10.ContextDisposedError) {
4566
4636
  return;
4567
4637
  }
4568
- import_log11.log.warn("error loading automerge root doc", {
4638
+ import_log12.log.warn("error loading automerge root doc", {
4569
4639
  space: this.key,
4570
4640
  rootUrl,
4571
4641
  err
4572
4642
  }, {
4573
- F: __dxlog_file16,
4643
+ F: __dxlog_file17,
4574
4644
  L: 431,
4575
4645
  S: this,
4576
4646
  C: (f, a) => f(...a)
@@ -4653,10 +4723,10 @@ var DataSpace = class {
4653
4723
  await this._close();
4654
4724
  }
4655
4725
  this._state = import_services12.SpaceState.INACTIVE;
4656
- (0, import_log11.log)("new state", {
4726
+ (0, import_log12.log)("new state", {
4657
4727
  state: import_services12.SpaceState[this._state]
4658
4728
  }, {
4659
- F: __dxlog_file16,
4729
+ F: __dxlog_file17,
4660
4730
  L: 512,
4661
4731
  S: this,
4662
4732
  C: (f, a) => f(...a)
@@ -4684,10 +4754,10 @@ _ts_decorate4([
4684
4754
  })
4685
4755
  ], DataSpace.prototype, "_automergeInfo", null);
4686
4756
  _ts_decorate4([
4687
- import_async12.synchronized
4757
+ import_async13.synchronized
4688
4758
  ], DataSpace.prototype, "open", null);
4689
4759
  _ts_decorate4([
4690
- import_async12.synchronized
4760
+ import_async13.synchronized
4691
4761
  ], DataSpace.prototype, "close", null);
4692
4762
  _ts_decorate4([
4693
4763
  import_tracing5.trace.span({
@@ -4703,13 +4773,13 @@ _ts_decorate4([
4703
4773
  (0, import_debug3.timed)(1e4)
4704
4774
  ], DataSpace.prototype, "_createWritableFeeds", null);
4705
4775
  _ts_decorate4([
4706
- import_async12.synchronized
4776
+ import_async13.synchronized
4707
4777
  ], DataSpace.prototype, "activate", null);
4708
4778
  _ts_decorate4([
4709
- import_async12.synchronized
4779
+ import_async13.synchronized
4710
4780
  ], DataSpace.prototype, "deactivate", null);
4711
4781
  DataSpace = _ts_decorate4([
4712
- (0, import_async12.trackLeaks)("open", "close"),
4782
+ (0, import_async13.trackLeaks)("open", "close"),
4713
4783
  import_tracing5.trace.resource()
4714
4784
  ], DataSpace);
4715
4785
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
@@ -4786,7 +4856,7 @@ function _ts_decorate5(decorators, target, key, desc) {
4786
4856
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4787
4857
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4788
4858
  }
4789
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4859
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4790
4860
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
4791
4861
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
4792
4862
  var DEFAULT_SPACE_KEY = "__DEFAULT__";
@@ -4800,9 +4870,12 @@ var DataSpaceManager = class {
4800
4870
  this._echoHost = _echoHost;
4801
4871
  this._invitationsManager = _invitationsManager;
4802
4872
  this._params = _params;
4803
- this._ctx = new import_context14.Context();
4804
- this.updated = new import_async16.Event();
4805
- this._spaces = new import_util9.ComplexMap(import_keys12.PublicKey.hash);
4873
+ this._ctx = new import_context14.Context(void 0, {
4874
+ F: __dxlog_file18,
4875
+ L: 104
4876
+ });
4877
+ this.updated = new import_async17.Event();
4878
+ this._spaces = new import_util10.ComplexMap(import_keys12.PublicKey.hash);
4806
4879
  this._isOpen = false;
4807
4880
  this._instanceId = import_keys12.PublicKey.random().toHex();
4808
4881
  import_tracing6.trace.diagnostic({
@@ -4833,46 +4906,46 @@ var DataSpaceManager = class {
4833
4906
  return this._spaces;
4834
4907
  }
4835
4908
  async open() {
4836
- (0, import_log14.log)("open", void 0, {
4837
- F: __dxlog_file17,
4838
- L: 146,
4909
+ (0, import_log15.log)("open", void 0, {
4910
+ F: __dxlog_file18,
4911
+ L: 156,
4839
4912
  S: this,
4840
4913
  C: (f, a) => f(...a)
4841
4914
  });
4842
- import_log14.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
4915
+ import_log15.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
4843
4916
  id: this._instanceId
4844
4917
  }), {
4845
- F: __dxlog_file17,
4846
- L: 147,
4918
+ F: __dxlog_file18,
4919
+ L: 157,
4847
4920
  S: this,
4848
4921
  C: (f, a) => f(...a)
4849
4922
  });
4850
- (0, import_log14.log)("metadata loaded", {
4923
+ (0, import_log15.log)("metadata loaded", {
4851
4924
  spaces: this._metadataStore.spaces.length
4852
4925
  }, {
4853
- F: __dxlog_file17,
4854
- L: 148,
4926
+ F: __dxlog_file18,
4927
+ L: 158,
4855
4928
  S: this,
4856
4929
  C: (f, a) => f(...a)
4857
4930
  });
4858
- await (0, import_util9.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
4931
+ await (0, import_util10.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
4859
4932
  try {
4860
- (0, import_log14.log)("load space", {
4933
+ (0, import_log15.log)("load space", {
4861
4934
  spaceMetadata
4862
4935
  }, {
4863
- F: __dxlog_file17,
4864
- L: 152,
4936
+ F: __dxlog_file18,
4937
+ L: 162,
4865
4938
  S: this,
4866
4939
  C: (f, a) => f(...a)
4867
4940
  });
4868
4941
  await this._constructSpace(spaceMetadata);
4869
4942
  } catch (err) {
4870
- import_log14.log.error("Error loading space", {
4943
+ import_log15.log.error("Error loading space", {
4871
4944
  spaceMetadata,
4872
4945
  err
4873
4946
  }, {
4874
- F: __dxlog_file17,
4875
- L: 155,
4947
+ F: __dxlog_file18,
4948
+ L: 165,
4876
4949
  S: this,
4877
4950
  C: (f, a) => f(...a)
4878
4951
  });
@@ -4880,19 +4953,19 @@ var DataSpaceManager = class {
4880
4953
  });
4881
4954
  this._isOpen = true;
4882
4955
  this.updated.emit();
4883
- import_log14.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
4956
+ import_log15.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
4884
4957
  id: this._instanceId
4885
4958
  }), {
4886
- F: __dxlog_file17,
4887
- L: 162,
4959
+ F: __dxlog_file18,
4960
+ L: 172,
4888
4961
  S: this,
4889
4962
  C: (f, a) => f(...a)
4890
4963
  });
4891
4964
  }
4892
4965
  async close() {
4893
- (0, import_log14.log)("close", void 0, {
4894
- F: __dxlog_file17,
4895
- L: 167,
4966
+ (0, import_log15.log)("close", void 0, {
4967
+ F: __dxlog_file18,
4968
+ L: 177,
4896
4969
  S: this,
4897
4970
  C: (f, a) => f(...a)
4898
4971
  });
@@ -4908,8 +4981,8 @@ var DataSpaceManager = class {
4908
4981
  */
4909
4982
  async createSpace() {
4910
4983
  (0, import_invariant15.invariant)(this._isOpen, "Not open.", {
4911
- F: __dxlog_file17,
4912
- L: 181,
4984
+ F: __dxlog_file18,
4985
+ L: 191,
4913
4986
  S: this,
4914
4987
  A: [
4915
4988
  "this._isOpen",
@@ -4926,11 +4999,11 @@ var DataSpaceManager = class {
4926
4999
  dataFeedKey,
4927
5000
  state: import_services14.SpaceState.ACTIVE
4928
5001
  };
4929
- (0, import_log14.log)("creating space...", {
5002
+ (0, import_log15.log)("creating space...", {
4930
5003
  spaceKey
4931
5004
  }, {
4932
- F: __dxlog_file17,
4933
- L: 193,
5005
+ F: __dxlog_file18,
5006
+ L: 203,
4934
5007
  S: this,
4935
5008
  C: (f, a) => f(...a)
4936
5009
  });
@@ -4941,8 +5014,8 @@ var DataSpaceManager = class {
4941
5014
  await this._metadataStore.addSpace(metadata);
4942
5015
  const memberCredential = credentials[1];
4943
5016
  (0, import_invariant15.invariant)((0, import_credentials15.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4944
- F: __dxlog_file17,
4945
- L: 203,
5017
+ F: __dxlog_file18,
5018
+ L: 213,
4946
5019
  S: this,
4947
5020
  A: [
4948
5021
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -4969,12 +5042,12 @@ var DataSpaceManager = class {
4969
5042
  return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
4970
5043
  }
4971
5044
  default:
4972
- import_log14.log.warn("unknown space version", {
5045
+ import_log15.log.warn("unknown space version", {
4973
5046
  version: space.databaseRoot.getVersion(),
4974
5047
  spaceId: space.id
4975
5048
  }, {
4976
- F: __dxlog_file17,
4977
- L: 228,
5049
+ F: __dxlog_file18,
5050
+ L: 238,
4978
5051
  S: this,
4979
5052
  C: (f, a) => f(...a)
4980
5053
  });
@@ -4997,7 +5070,7 @@ var DataSpaceManager = class {
4997
5070
  };
4998
5071
  const propertiesId = (0, import_echo_schema2.generateEchoId)();
4999
5072
  document.change((doc) => {
5000
- (0, import_util9.assignDeep)(doc, [
5073
+ (0, import_util10.assignDeep)(doc, [
5001
5074
  "objects",
5002
5075
  propertiesId
5003
5076
  ], properties);
@@ -5008,8 +5081,8 @@ var DataSpaceManager = class {
5008
5081
  async _getSpaceRootDocument(space) {
5009
5082
  const automergeIndex = space.automergeSpaceState.rootUrl;
5010
5083
  (0, import_invariant15.invariant)(automergeIndex, void 0, {
5011
- F: __dxlog_file17,
5012
- L: 261,
5084
+ F: __dxlog_file18,
5085
+ L: 271,
5013
5086
  S: this,
5014
5087
  A: [
5015
5088
  "automergeIndex",
@@ -5022,17 +5095,17 @@ var DataSpaceManager = class {
5022
5095
  }
5023
5096
  // TODO(burdon): Rename join space.
5024
5097
  async acceptSpace(opts) {
5025
- (0, import_log14.log)("accept space", {
5098
+ (0, import_log15.log)("accept space", {
5026
5099
  opts
5027
5100
  }, {
5028
- F: __dxlog_file17,
5029
- L: 270,
5101
+ F: __dxlog_file18,
5102
+ L: 280,
5030
5103
  S: this,
5031
5104
  C: (f, a) => f(...a)
5032
5105
  });
5033
5106
  (0, import_invariant15.invariant)(this._isOpen, "Not open.", {
5034
- F: __dxlog_file17,
5035
- L: 271,
5107
+ F: __dxlog_file18,
5108
+ L: 281,
5036
5109
  S: this,
5037
5110
  A: [
5038
5111
  "this._isOpen",
@@ -5040,8 +5113,8 @@ var DataSpaceManager = class {
5040
5113
  ]
5041
5114
  });
5042
5115
  (0, import_invariant15.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
5043
- F: __dxlog_file17,
5044
- L: 272,
5116
+ F: __dxlog_file18,
5117
+ L: 282,
5045
5118
  S: this,
5046
5119
  A: [
5047
5120
  "!this._spaces.has(opts.spaceKey)",
@@ -5061,6 +5134,43 @@ var DataSpaceManager = class {
5061
5134
  this.updated.emit();
5062
5135
  return space;
5063
5136
  }
5137
+ async admitMember(options) {
5138
+ const space = this._spaceManager.spaces.get(options.spaceKey);
5139
+ (0, import_invariant15.invariant)(space, void 0, {
5140
+ F: __dxlog_file18,
5141
+ L: 302,
5142
+ S: this,
5143
+ A: [
5144
+ "space",
5145
+ ""
5146
+ ]
5147
+ });
5148
+ if (space.spaceState.getMemberRole(options.identityKey) !== import_credentials16.SpaceMember.Role.REMOVED) {
5149
+ throw new import_protocols11.AlreadyJoinedError();
5150
+ }
5151
+ const credentials = await (0, import_credentials15.createAdmissionCredentials)(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
5152
+ (0, import_invariant15.invariant)(credentials[0].credential, void 0, {
5153
+ F: __dxlog_file18,
5154
+ L: 321,
5155
+ S: this,
5156
+ A: [
5157
+ "credentials[0].credential",
5158
+ ""
5159
+ ]
5160
+ });
5161
+ const spaceMemberCredential = credentials[0].credential.credential;
5162
+ (0, import_invariant15.invariant)((0, import_credentials15.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5163
+ F: __dxlog_file18,
5164
+ L: 323,
5165
+ S: this,
5166
+ A: [
5167
+ "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5168
+ ""
5169
+ ]
5170
+ });
5171
+ await (0, import_feed_store4.writeMessages)(space.controlPipeline.writer, credentials);
5172
+ return spaceMemberCredential;
5173
+ }
5064
5174
  /**
5065
5175
  * Wait until the space data pipeline is fully initialized.
5066
5176
  * Used by invitation handler.
@@ -5072,12 +5182,24 @@ var DataSpaceManager = class {
5072
5182
  return !!space && space.state === import_services14.SpaceState.READY;
5073
5183
  }));
5074
5184
  }
5185
+ async requestSpaceAdmissionCredential(spaceKey) {
5186
+ return this._spaceManager.requestSpaceAdmissionCredential({
5187
+ spaceKey,
5188
+ identityKey: this._signingContext.identityKey,
5189
+ timeout: 15e3,
5190
+ swarmIdentity: {
5191
+ peerKey: this._signingContext.deviceKey,
5192
+ credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5193
+ credentialAuthenticator: async () => true
5194
+ }
5195
+ });
5196
+ }
5075
5197
  async _constructSpace(metadata) {
5076
- (0, import_log14.log)("construct space", {
5198
+ (0, import_log15.log)("construct space", {
5077
5199
  metadata
5078
5200
  }, {
5079
- F: __dxlog_file17,
5080
- L: 306,
5201
+ F: __dxlog_file18,
5202
+ L: 358,
5081
5203
  S: this,
5082
5204
  C: (f, a) => f(...a)
5083
5205
  });
@@ -5102,9 +5224,10 @@ var DataSpaceManager = class {
5102
5224
  swarmIdentity: {
5103
5225
  peerKey: this._signingContext.deviceKey,
5104
5226
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
5105
- credentialAuthenticator: (0, import_util9.deferFunction)(() => dataSpace.authVerifier.verifier)
5227
+ credentialAuthenticator: (0, import_util10.deferFunction)(() => dataSpace.authVerifier.verifier)
5106
5228
  },
5107
5229
  onAuthorizedConnection: (session) => {
5230
+ session.addExtension("dxos.mesh.teleport.admission-discovery", new import_echo_pipeline5.CredentialServerExtension(space));
5108
5231
  session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
5109
5232
  remotePeerId: session.remotePeerId
5110
5233
  }));
@@ -5113,9 +5236,9 @@ var DataSpaceManager = class {
5113
5236
  session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
5114
5237
  },
5115
5238
  onAuthFailure: () => {
5116
- import_log14.log.warn("auth failure", void 0, {
5117
- F: __dxlog_file17,
5118
- L: 343,
5239
+ import_log15.log.warn("auth failure", void 0, {
5240
+ F: __dxlog_file18,
5241
+ L: 396,
5119
5242
  S: this,
5120
5243
  C: (f, a) => f(...a)
5121
5244
  });
@@ -5144,22 +5267,22 @@ var DataSpaceManager = class {
5144
5267
  signingContext: this._signingContext,
5145
5268
  callbacks: {
5146
5269
  beforeReady: async () => {
5147
- (0, import_log14.log)("before space ready", {
5270
+ (0, import_log15.log)("before space ready", {
5148
5271
  space: space.key
5149
5272
  }, {
5150
- F: __dxlog_file17,
5151
- L: 370,
5273
+ F: __dxlog_file18,
5274
+ L: 423,
5152
5275
  S: this,
5153
5276
  C: (f, a) => f(...a)
5154
5277
  });
5155
5278
  },
5156
5279
  afterReady: async () => {
5157
- (0, import_log14.log)("after space ready", {
5280
+ (0, import_log15.log)("after space ready", {
5158
5281
  space: space.key,
5159
5282
  open: this._isOpen
5160
5283
  }, {
5161
- F: __dxlog_file17,
5162
- L: 373,
5284
+ F: __dxlog_file18,
5285
+ L: 426,
5163
5286
  S: this,
5164
5287
  C: (f, a) => f(...a)
5165
5288
  });
@@ -5174,11 +5297,11 @@ var DataSpaceManager = class {
5174
5297
  }
5175
5298
  },
5176
5299
  beforeClose: async () => {
5177
- (0, import_log14.log)("before space close", {
5300
+ (0, import_log15.log)("before space close", {
5178
5301
  space: space.key
5179
5302
  }, {
5180
- F: __dxlog_file17,
5181
- L: 381,
5303
+ F: __dxlog_file18,
5304
+ L: 434,
5182
5305
  S: this,
5183
5306
  C: (f, a) => f(...a)
5184
5307
  });
@@ -5209,17 +5332,17 @@ var DataSpaceManager = class {
5209
5332
  return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline4.AuthStatus.FAILURE)) ?? false;
5210
5333
  });
5211
5334
  sessionsToClose.forEach((session) => {
5212
- void session.close().catch(import_log14.log.error);
5335
+ void session.close().catch(import_log15.log.error);
5213
5336
  });
5214
5337
  closedSessions += sessionsToClose.length;
5215
5338
  }
5216
- (0, import_log14.log)("processed member role changes", {
5339
+ (0, import_log15.log)("processed member role changes", {
5217
5340
  roleChangeCount: memberInfo.length,
5218
5341
  peersOnline: presence.getPeersOnline().length,
5219
5342
  closedSessions
5220
5343
  }, {
5221
- F: __dxlog_file17,
5222
- L: 417,
5344
+ F: __dxlog_file18,
5345
+ L: 470,
5223
5346
  S: this,
5224
5347
  C: (f, a) => f(...a)
5225
5348
  });
@@ -5230,15 +5353,15 @@ var DataSpaceManager = class {
5230
5353
  if (role === import_credentials16.SpaceMember.Role.REMOVED) {
5231
5354
  const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
5232
5355
  if (session != null) {
5233
- (0, import_log14.log)("closing a session with a removed peer", {
5356
+ (0, import_log15.log)("closing a session with a removed peer", {
5234
5357
  peerId: peerState.peerId
5235
5358
  }, {
5236
- F: __dxlog_file17,
5237
- L: 431,
5359
+ F: __dxlog_file18,
5360
+ L: 484,
5238
5361
  S: this,
5239
5362
  C: (f, a) => f(...a)
5240
5363
  });
5241
- void session.close().catch(import_log14.log.error);
5364
+ void session.close().catch(import_log15.log.error);
5242
5365
  }
5243
5366
  }
5244
5367
  }
@@ -5279,21 +5402,21 @@ var DataSpaceManager = class {
5279
5402
  }
5280
5403
  };
5281
5404
  _ts_decorate5([
5282
- import_async16.synchronized
5405
+ import_async17.synchronized
5283
5406
  ], DataSpaceManager.prototype, "open", null);
5284
5407
  _ts_decorate5([
5285
- import_async16.synchronized
5408
+ import_async17.synchronized
5286
5409
  ], DataSpaceManager.prototype, "close", null);
5287
5410
  _ts_decorate5([
5288
- import_async16.synchronized
5411
+ import_async17.synchronized
5289
5412
  ], DataSpaceManager.prototype, "createSpace", null);
5290
5413
  _ts_decorate5([
5291
- import_async16.synchronized
5414
+ import_async17.synchronized
5292
5415
  ], DataSpaceManager.prototype, "acceptSpace", null);
5293
5416
  DataSpaceManager = _ts_decorate5([
5294
- (0, import_async16.trackLeaks)("open", "close")
5417
+ (0, import_async17.trackLeaks)("open", "close")
5295
5418
  ], DataSpaceManager);
5296
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5419
+ var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5297
5420
  var SpacesServiceImpl = class {
5298
5421
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
5299
5422
  this._identityManager = _identityManager;
@@ -5337,8 +5460,8 @@ var SpacesServiceImpl = class {
5337
5460
  }
5338
5461
  const credentials = await (0, import_credentials19.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
5339
5462
  (0, import_invariant16.invariant)(credentials[0].credential, void 0, {
5340
- F: __dxlog_file18,
5341
- L: 98,
5463
+ F: __dxlog_file19,
5464
+ L: 102,
5342
5465
  S: this,
5343
5466
  A: [
5344
5467
  "credentials[0].credential",
@@ -5347,26 +5470,26 @@ var SpacesServiceImpl = class {
5347
5470
  });
5348
5471
  const spaceMemberCredential = credentials[0].credential.credential;
5349
5472
  (0, import_invariant16.invariant)((0, import_credentials19.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5350
- F: __dxlog_file18,
5351
- L: 100,
5473
+ F: __dxlog_file19,
5474
+ L: 104,
5352
5475
  S: this,
5353
5476
  A: [
5354
5477
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
5355
5478
  ""
5356
5479
  ]
5357
5480
  });
5358
- await (0, import_feed_store4.writeMessages)(space.controlPipeline.writer, credentials);
5481
+ await (0, import_feed_store5.writeMessages)(space.controlPipeline.writer, credentials);
5359
5482
  }
5360
5483
  querySpaces() {
5361
5484
  return new import_codec_protobuf11.Stream(({ next, ctx }) => {
5362
- const scheduler = new import_async17.UpdateScheduler(ctx, async () => {
5485
+ const scheduler = new import_async18.UpdateScheduler(ctx, async () => {
5363
5486
  const dataSpaceManager = await this._getDataSpaceManager();
5364
5487
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
5365
- (0, import_log15.log)("update", {
5488
+ (0, import_log16.log)("update", {
5366
5489
  spaces
5367
5490
  }, {
5368
- F: __dxlog_file18,
5369
- L: 111,
5491
+ F: __dxlog_file19,
5492
+ L: 115,
5370
5493
  S: this,
5371
5494
  C: (f, a) => f(...a)
5372
5495
  });
@@ -5377,14 +5500,22 @@ var SpacesServiceImpl = class {
5377
5500
  }, {
5378
5501
  maxFrequency: process.env.NODE_ENV === "test" ? void 0 : 2
5379
5502
  });
5380
- (0, import_async17.scheduleTask)(ctx, async () => {
5503
+ (0, import_async18.scheduleTask)(ctx, async () => {
5381
5504
  const dataSpaceManager = await this._getDataSpaceManager();
5382
- const subscriptions = new import_async17.EventSubscriptions();
5505
+ const subscriptions = new import_async18.EventSubscriptions();
5383
5506
  ctx.onDispose(() => subscriptions.clear());
5384
5507
  const subscribeSpaces = () => {
5385
5508
  subscriptions.clear();
5386
5509
  for (const space of dataSpaceManager.spaces.values()) {
5387
- subscriptions.add(space.stateUpdate.on(ctx, () => scheduler.forceTrigger()));
5510
+ let lastState;
5511
+ subscriptions.add(space.stateUpdate.on(ctx, () => {
5512
+ if (space.state !== lastState) {
5513
+ scheduler.forceTrigger();
5514
+ } else {
5515
+ scheduler.trigger();
5516
+ }
5517
+ lastState = space.state;
5518
+ }));
5388
5519
  subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
5389
5520
  subscriptions.add(space.automergeSpaceState.onNewEpoch.on(ctx, () => scheduler.trigger()));
5390
5521
  subscriptions.add(space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger()));
@@ -5411,7 +5542,7 @@ var SpacesServiceImpl = class {
5411
5542
  }
5412
5543
  subscribeMessages({ spaceKey, channel }) {
5413
5544
  return new import_codec_protobuf11.Stream(({ ctx, next }) => {
5414
- (0, import_async17.scheduleTask)(ctx, async () => {
5545
+ (0, import_async18.scheduleTask)(ctx, async () => {
5415
5546
  const dataSpaceManager = await this._getDataSpaceManager();
5416
5547
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
5417
5548
  const handle = space.listen(getChannelId(channel), (message) => {
@@ -5430,7 +5561,7 @@ var SpacesServiceImpl = class {
5430
5561
  }
5431
5562
  };
5432
5563
  ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
5433
- (0, import_async17.scheduleTask)(ctx, async () => {
5564
+ (0, import_async18.scheduleTask)(ctx, async () => {
5434
5565
  await space.spaceState.addCredentialProcessor(processor);
5435
5566
  if (noTail) {
5436
5567
  close();
@@ -5449,8 +5580,8 @@ var SpacesServiceImpl = class {
5449
5580
  });
5450
5581
  } else {
5451
5582
  (0, import_invariant16.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
5452
- F: __dxlog_file18,
5453
- L: 199,
5583
+ F: __dxlog_file19,
5584
+ L: 213,
5454
5585
  S: this,
5455
5586
  A: [
5456
5587
  "!credential.id",
@@ -5458,8 +5589,8 @@ var SpacesServiceImpl = class {
5458
5589
  ]
5459
5590
  });
5460
5591
  (0, import_invariant16.invariant)(this._identityManager.identity, "Identity is not available", {
5461
- F: __dxlog_file18,
5462
- L: 200,
5592
+ F: __dxlog_file19,
5593
+ L: 214,
5463
5594
  S: this,
5464
5595
  A: [
5465
5596
  "this._identityManager.identity",
@@ -5468,8 +5599,8 @@ var SpacesServiceImpl = class {
5468
5599
  });
5469
5600
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
5470
5601
  (0, import_invariant16.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
5471
- F: __dxlog_file18,
5472
- L: 202,
5602
+ F: __dxlog_file19,
5603
+ L: 216,
5473
5604
  S: this,
5474
5605
  A: [
5475
5606
  "credential.issuer.equals(signer.getIssuer())",
@@ -5499,6 +5630,59 @@ var SpacesServiceImpl = class {
5499
5630
  epochCredential: credential ?? void 0
5500
5631
  };
5501
5632
  }
5633
+ async admitContact(request) {
5634
+ const dataSpaceManager = await this._getDataSpaceManager();
5635
+ await dataSpaceManager.admitMember({
5636
+ spaceKey: request.spaceKey,
5637
+ identityKey: request.contact.identityKey,
5638
+ role: request.role
5639
+ });
5640
+ }
5641
+ async joinBySpaceKey({ spaceKey }) {
5642
+ const dataSpaceManager = await this._getDataSpaceManager();
5643
+ const credential = await dataSpaceManager.requestSpaceAdmissionCredential(spaceKey);
5644
+ return this._joinByAdmission({
5645
+ credential
5646
+ });
5647
+ }
5648
+ async _joinByAdmission({ credential }) {
5649
+ const assertion = (0, import_credentials19.getCredentialAssertion)(credential);
5650
+ (0, import_invariant16.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
5651
+ F: __dxlog_file19,
5652
+ L: 250,
5653
+ S: this,
5654
+ A: [
5655
+ "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
5656
+ "'Invalid credential'"
5657
+ ]
5658
+ });
5659
+ const myIdentity = this._identityManager.identity;
5660
+ (0, import_invariant16.invariant)(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
5661
+ F: __dxlog_file19,
5662
+ L: 252,
5663
+ S: this,
5664
+ A: [
5665
+ "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
5666
+ ""
5667
+ ]
5668
+ });
5669
+ const dataSpaceManager = await this._getDataSpaceManager();
5670
+ let dataSpace = dataSpaceManager.spaces.get(assertion.spaceKey);
5671
+ if (!dataSpace) {
5672
+ dataSpace = await dataSpaceManager.acceptSpace({
5673
+ spaceKey: assertion.spaceKey,
5674
+ genesisFeedKey: assertion.genesisFeedKey
5675
+ });
5676
+ await myIdentity.controlPipeline.writer.write({
5677
+ credential: {
5678
+ credential
5679
+ }
5680
+ });
5681
+ }
5682
+ return {
5683
+ space: this._serializeSpace(dataSpace)
5684
+ };
5685
+ }
5502
5686
  _serializeSpace(space) {
5503
5687
  return {
5504
5688
  id: space.id,
@@ -5568,7 +5752,7 @@ function _ts_decorate6(decorators, target, key, desc) {
5568
5752
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5569
5753
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5570
5754
  }
5571
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5755
+ var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5572
5756
  var ServiceContext = class extends import_context15.Resource {
5573
5757
  constructor(storage, level, networkManager, signalManager, _runtimeParams) {
5574
5758
  super();
@@ -5577,24 +5761,24 @@ var ServiceContext = class extends import_context15.Resource {
5577
5761
  this.networkManager = networkManager;
5578
5762
  this.signalManager = signalManager;
5579
5763
  this._runtimeParams = _runtimeParams;
5580
- this.initialized = new import_async18.Trigger();
5764
+ this.initialized = new import_async19.Trigger();
5581
5765
  this._handlerFactories = /* @__PURE__ */ new Map();
5582
5766
  this._instanceId = import_keys13.PublicKey.random().toHex();
5583
- this.metadataStore = new import_echo_pipeline5.MetadataStore(storage.createDirectory("metadata"));
5584
- this.snapshotStore = new import_echo_pipeline5.SnapshotStore(storage.createDirectory("snapshots"));
5767
+ this.metadataStore = new import_echo_pipeline6.MetadataStore(storage.createDirectory("metadata"));
5768
+ this.snapshotStore = new import_echo_pipeline6.SnapshotStore(storage.createDirectory("snapshots"));
5585
5769
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
5586
5770
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
5587
- this.feedStore = new import_feed_store5.FeedStore({
5588
- factory: new import_feed_store5.FeedFactory({
5771
+ this.feedStore = new import_feed_store6.FeedStore({
5772
+ factory: new import_feed_store6.FeedFactory({
5589
5773
  root: storage.createDirectory("feeds"),
5590
5774
  signer: this.keyring,
5591
5775
  hypercore: {
5592
- valueEncoding: import_echo_pipeline5.valueEncoding,
5776
+ valueEncoding: import_echo_pipeline6.valueEncoding,
5593
5777
  stats: true
5594
5778
  }
5595
5779
  })
5596
5780
  });
5597
- this.spaceManager = new import_echo_pipeline5.SpaceManager({
5781
+ this.spaceManager = new import_echo_pipeline6.SpaceManager({
5598
5782
  feedStore: this.feedStore,
5599
5783
  networkManager: this.networkManager,
5600
5784
  blobStore: this.blobStore,
@@ -5611,16 +5795,16 @@ var ServiceContext = class extends import_context15.Resource {
5611
5795
  }
5612
5796
  async _open(ctx) {
5613
5797
  await this._checkStorageVersion();
5614
- (0, import_log16.log)("opening...", void 0, {
5615
- F: __dxlog_file19,
5798
+ (0, import_log17.log)("opening...", void 0, {
5799
+ F: __dxlog_file20,
5616
5800
  L: 149,
5617
5801
  S: this,
5618
5802
  C: (f, a) => f(...a)
5619
5803
  });
5620
- import_log16.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
5804
+ import_log17.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
5621
5805
  id: this._instanceId
5622
5806
  }), {
5623
- F: __dxlog_file19,
5807
+ F: __dxlog_file20,
5624
5808
  L: 150,
5625
5809
  S: this,
5626
5810
  C: (f, a) => f(...a)
@@ -5635,32 +5819,32 @@ var ServiceContext = class extends import_context15.Resource {
5635
5819
  await this._initialize(ctx);
5636
5820
  }
5637
5821
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
5638
- (0, import_log16.log)("loaded persistent invitations", {
5822
+ (0, import_log17.log)("loaded persistent invitations", {
5639
5823
  count: loadedInvitations.invitations?.length
5640
5824
  }, {
5641
- F: __dxlog_file19,
5825
+ F: __dxlog_file20,
5642
5826
  L: 163,
5643
5827
  S: this,
5644
5828
  C: (f, a) => f(...a)
5645
5829
  });
5646
- import_log16.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
5830
+ import_log17.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
5647
5831
  id: this._instanceId
5648
5832
  }), {
5649
- F: __dxlog_file19,
5833
+ F: __dxlog_file20,
5650
5834
  L: 165,
5651
5835
  S: this,
5652
5836
  C: (f, a) => f(...a)
5653
5837
  });
5654
- (0, import_log16.log)("opened", void 0, {
5655
- F: __dxlog_file19,
5838
+ (0, import_log17.log)("opened", void 0, {
5839
+ F: __dxlog_file20,
5656
5840
  L: 166,
5657
5841
  S: this,
5658
5842
  C: (f, a) => f(...a)
5659
5843
  });
5660
5844
  }
5661
5845
  async _close(ctx) {
5662
- (0, import_log16.log)("closing...", void 0, {
5663
- F: __dxlog_file19,
5846
+ (0, import_log17.log)("closing...", void 0, {
5847
+ F: __dxlog_file20,
5664
5848
  L: 170,
5665
5849
  S: this,
5666
5850
  C: (f, a) => f(...a)
@@ -5676,8 +5860,8 @@ var ServiceContext = class extends import_context15.Resource {
5676
5860
  await this.echoHost.close(ctx);
5677
5861
  await this.networkManager.close();
5678
5862
  await this.signalManager.close();
5679
- (0, import_log16.log)("closed", void 0, {
5680
- F: __dxlog_file19,
5863
+ (0, import_log17.log)("closed", void 0, {
5864
+ F: __dxlog_file20,
5681
5865
  L: 182,
5682
5866
  S: this,
5683
5867
  C: (f, a) => f(...a)
@@ -5685,13 +5869,16 @@ var ServiceContext = class extends import_context15.Resource {
5685
5869
  }
5686
5870
  async createIdentity(params = {}) {
5687
5871
  const identity = await this.identityManager.createIdentity(params);
5688
- await this._initialize(new import_context15.Context());
5872
+ await this._initialize(new import_context15.Context(void 0, {
5873
+ F: __dxlog_file20,
5874
+ L: 187
5875
+ }));
5689
5876
  return identity;
5690
5877
  }
5691
5878
  getInvitationHandler(invitation) {
5692
5879
  const factory = this._handlerFactories.get(invitation.kind);
5693
5880
  (0, import_invariant17.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
5694
- F: __dxlog_file19,
5881
+ F: __dxlog_file20,
5695
5882
  L: 193,
5696
5883
  S: this,
5697
5884
  A: [
@@ -5711,7 +5898,10 @@ var ServiceContext = class extends import_context15.Resource {
5711
5898
  }
5712
5899
  async _acceptIdentity(params) {
5713
5900
  const identity = await this.identityManager.acceptIdentity(params);
5714
- await this._initialize(new import_context15.Context());
5901
+ await this._initialize(new import_context15.Context(void 0, {
5902
+ F: __dxlog_file20,
5903
+ L: 209
5904
+ }));
5715
5905
  return identity;
5716
5906
  }
5717
5907
  async _checkStorageVersion() {
@@ -5722,8 +5912,8 @@ var ServiceContext = class extends import_context15.Resource {
5722
5912
  }
5723
5913
  // Called when identity is created.
5724
5914
  async _initialize(ctx) {
5725
- (0, import_log16.log)("initializing spaces...", void 0, {
5726
- F: __dxlog_file19,
5915
+ (0, import_log17.log)("initializing spaces...", void 0, {
5916
+ F: __dxlog_file20,
5727
5917
  L: 224,
5728
5918
  S: this,
5729
5919
  C: (f, a) => f(...a)
@@ -5746,7 +5936,7 @@ var ServiceContext = class extends import_context15.Resource {
5746
5936
  await this.dataSpaceManager.open();
5747
5937
  this._handlerFactories.set(import_services16.Invitation.Kind.SPACE, (invitation) => {
5748
5938
  (0, import_invariant17.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
5749
- F: __dxlog_file19,
5939
+ F: __dxlog_file20,
5750
5940
  L: 249,
5751
5941
  S: this,
5752
5942
  A: [
@@ -5767,10 +5957,10 @@ var ServiceContext = class extends import_context15.Resource {
5767
5957
  return;
5768
5958
  }
5769
5959
  if (!this.dataSpaceManager) {
5770
- (0, import_log16.log)("dataSpaceManager not initialized yet, ignoring space admission", {
5960
+ (0, import_log17.log)("dataSpaceManager not initialized yet, ignoring space admission", {
5771
5961
  details: assertion
5772
5962
  }, {
5773
- F: __dxlog_file19,
5963
+ F: __dxlog_file20,
5774
5964
  L: 265,
5775
5965
  S: this,
5776
5966
  C: (f, a) => f(...a)
@@ -5778,10 +5968,10 @@ var ServiceContext = class extends import_context15.Resource {
5778
5968
  return;
5779
5969
  }
5780
5970
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
5781
- (0, import_log16.log)("space already exists, ignoring space admission", {
5971
+ (0, import_log17.log)("space already exists, ignoring space admission", {
5782
5972
  details: assertion
5783
5973
  }, {
5784
- F: __dxlog_file19,
5974
+ F: __dxlog_file20,
5785
5975
  L: 269,
5786
5976
  S: this,
5787
5977
  C: (f, a) => f(...a)
@@ -5789,10 +5979,10 @@ var ServiceContext = class extends import_context15.Resource {
5789
5979
  return;
5790
5980
  }
5791
5981
  try {
5792
- (0, import_log16.log)("accepting space recorded in halo", {
5982
+ (0, import_log17.log)("accepting space recorded in halo", {
5793
5983
  details: assertion
5794
5984
  }, {
5795
- F: __dxlog_file19,
5985
+ F: __dxlog_file20,
5796
5986
  L: 274,
5797
5987
  S: this,
5798
5988
  C: (f, a) => f(...a)
@@ -5802,8 +5992,8 @@ var ServiceContext = class extends import_context15.Resource {
5802
5992
  genesisFeedKey: assertion.genesisFeedKey
5803
5993
  });
5804
5994
  } catch (err) {
5805
- import_log16.log.catch(err, void 0, {
5806
- F: __dxlog_file19,
5995
+ import_log17.log.catch(err, void 0, {
5996
+ F: __dxlog_file20,
5807
5997
  L: 280,
5808
5998
  S: this,
5809
5999
  C: (f, a) => f(...a)
@@ -5821,7 +6011,7 @@ _ts_decorate6([
5821
6011
  import_tracing8.trace.span()
5822
6012
  ], ServiceContext.prototype, "_initialize", null);
5823
6013
  ServiceContext = _ts_decorate6([
5824
- (0, import_util10.safeInstanceof)("dxos.client-services.ServiceContext"),
6014
+ (0, import_util11.safeInstanceof)("dxos.client-services.ServiceContext"),
5825
6015
  import_tracing8.trace.resource()
5826
6016
  ], ServiceContext);
5827
6017
  var ServiceRegistry = class {
@@ -5856,7 +6046,7 @@ function _ts_decorate7(decorators, target, key, desc) {
5856
6046
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5857
6047
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5858
6048
  }
5859
- var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
6049
+ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
5860
6050
  var Lock = class {
5861
6051
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
5862
6052
  this._lockPath = lockPath;
@@ -5867,16 +6057,16 @@ var Lock = class {
5867
6057
  return this._lockPath;
5868
6058
  }
5869
6059
  async acquire() {
5870
- (0, import_log17.log)("acquiring lock...", void 0, {
5871
- F: __dxlog_file20,
6060
+ (0, import_log18.log)("acquiring lock...", void 0, {
6061
+ F: __dxlog_file21,
5872
6062
  L: 32,
5873
6063
  S: this,
5874
6064
  C: (f, a) => f(...a)
5875
6065
  });
5876
6066
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
5877
6067
  await this._onAcquire?.();
5878
- (0, import_log17.log)("acquired lock", void 0, {
5879
- F: __dxlog_file20,
6068
+ (0, import_log18.log)("acquired lock", void 0, {
6069
+ F: __dxlog_file21,
5880
6070
  L: 37,
5881
6071
  S: this,
5882
6072
  C: (f, a) => f(...a)
@@ -5885,7 +6075,7 @@ var Lock = class {
5885
6075
  async release() {
5886
6076
  await this._onRelease?.();
5887
6077
  (0, import_invariant18.invariant)(this._fileHandle, "Lock is not acquired", {
5888
- F: __dxlog_file20,
6078
+ F: __dxlog_file21,
5889
6079
  L: 42,
5890
6080
  S: this,
5891
6081
  A: [
@@ -5897,11 +6087,11 @@ var Lock = class {
5897
6087
  }
5898
6088
  };
5899
6089
  _ts_decorate7([
5900
- import_log17.logInfo
6090
+ import_log18.logInfo
5901
6091
  ], Lock.prototype, "lockKey", null);
5902
6092
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
5903
6093
  var getRootPath = (config) => {
5904
- const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
6094
+ const { dataRoot = (0, import_util12.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
5905
6095
  return `${dataRoot}/`;
5906
6096
  };
5907
6097
  var isPersistent = (config) => {
@@ -5957,7 +6147,138 @@ var createLevel = async (config) => {
5957
6147
  await level.open();
5958
6148
  return level;
5959
6149
  };
5960
- var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
6150
+ var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
6151
+ var encodeProfileArchive = (profile) => import_automerge_repo.cbor.encode(profile);
6152
+ var decodeProfileArchive = (data) => import_automerge_repo.cbor.decode(data);
6153
+ var exportProfileData = async ({ storage, level }) => {
6154
+ const archive = {
6155
+ storage: [],
6156
+ meta: {
6157
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
6158
+ }
6159
+ };
6160
+ {
6161
+ const directory = await storage.createDirectory();
6162
+ const files = await directory.list();
6163
+ import_log19.log.info("begin exporting files", {
6164
+ count: files.length
6165
+ }, {
6166
+ F: __dxlog_file22,
6167
+ L: 30,
6168
+ S: void 0,
6169
+ C: (f, a) => f(...a)
6170
+ });
6171
+ for (const filename of files) {
6172
+ const file = await directory.getOrCreateFile(filename);
6173
+ const { size } = await file.stat();
6174
+ const data = await file.read(0, size);
6175
+ archive.storage.push({
6176
+ type: import_protocols15.ProfileArchiveEntryType.FILE,
6177
+ key: filename,
6178
+ value: data
6179
+ });
6180
+ }
6181
+ import_log19.log.info("done exporting files", {
6182
+ count: files.length
6183
+ }, {
6184
+ F: __dxlog_file22,
6185
+ L: 41,
6186
+ S: void 0,
6187
+ C: (f, a) => f(...a)
6188
+ });
6189
+ }
6190
+ {
6191
+ import_log19.log.info("begin exporting kv pairs", void 0, {
6192
+ F: __dxlog_file22,
6193
+ L: 45,
6194
+ S: void 0,
6195
+ C: (f, a) => f(...a)
6196
+ });
6197
+ const iter = await level.iterator({
6198
+ keyEncoding: "binary",
6199
+ valueEncoding: "binary"
6200
+ });
6201
+ let count = 0;
6202
+ for await (const [key, value] of iter) {
6203
+ archive.storage.push({
6204
+ type: import_protocols15.ProfileArchiveEntryType.KEY_VALUE,
6205
+ key,
6206
+ value
6207
+ });
6208
+ count++;
6209
+ }
6210
+ import_log19.log.info("done exporting kv pairs", {
6211
+ count
6212
+ }, {
6213
+ F: __dxlog_file22,
6214
+ L: 56,
6215
+ S: void 0,
6216
+ C: (f, a) => f(...a)
6217
+ });
6218
+ }
6219
+ return archive;
6220
+ };
6221
+ var importProfileData = async ({ storage, level }, archive) => {
6222
+ const batch = level.batch();
6223
+ for (const entry2 of archive.storage) {
6224
+ switch (entry2.type) {
6225
+ case import_protocols15.ProfileArchiveEntryType.FILE: {
6226
+ const directory = await storage.createDirectory();
6227
+ (0, import_invariant19.invariant)(typeof entry2.key === "string", "Invalid key type", {
6228
+ F: __dxlog_file22,
6229
+ L: 78,
6230
+ S: void 0,
6231
+ A: [
6232
+ "typeof entry.key === 'string'",
6233
+ "'Invalid key type'"
6234
+ ]
6235
+ });
6236
+ const file = await directory.getOrCreateFile(entry2.key);
6237
+ (0, import_invariant19.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
6238
+ F: __dxlog_file22,
6239
+ L: 80,
6240
+ S: void 0,
6241
+ A: [
6242
+ "entry.value instanceof Uint8Array",
6243
+ "'Invalid value type'"
6244
+ ]
6245
+ });
6246
+ await file.write(0, (0, import_util13.arrayToBuffer)(entry2.value));
6247
+ await file.close();
6248
+ break;
6249
+ }
6250
+ case import_protocols15.ProfileArchiveEntryType.KEY_VALUE: {
6251
+ (0, import_invariant19.invariant)(entry2.key instanceof Uint8Array, "Invalid key type", {
6252
+ F: __dxlog_file22,
6253
+ L: 86,
6254
+ S: void 0,
6255
+ A: [
6256
+ "entry.key instanceof Uint8Array",
6257
+ "'Invalid key type'"
6258
+ ]
6259
+ });
6260
+ (0, import_invariant19.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
6261
+ F: __dxlog_file22,
6262
+ L: 87,
6263
+ S: void 0,
6264
+ A: [
6265
+ "entry.value instanceof Uint8Array",
6266
+ "'Invalid value type'"
6267
+ ]
6268
+ });
6269
+ batch.put(entry2.key, entry2.value, {
6270
+ keyEncoding: "binary",
6271
+ valueEncoding: "binary"
6272
+ });
6273
+ break;
6274
+ }
6275
+ default:
6276
+ throw new Error(`Invalid entry type: ${entry2.type}`);
6277
+ }
6278
+ }
6279
+ await batch.write();
6280
+ };
6281
+ var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
5961
6282
  var DevicesServiceImpl = class {
5962
6283
  constructor(_identityManager) {
5963
6284
  this._identityManager = _identityManager;
@@ -5974,8 +6295,8 @@ var DevicesServiceImpl = class {
5974
6295
  devices: []
5975
6296
  });
5976
6297
  } else {
5977
- (0, import_invariant20.invariant)(this._identityManager.identity?.presence, "presence not present", {
5978
- F: __dxlog_file21,
6298
+ (0, import_invariant21.invariant)(this._identityManager.identity?.presence, "presence not present", {
6299
+ F: __dxlog_file23,
5979
6300
  L: 32,
5980
6301
  S: this,
5981
6302
  A: [
@@ -6016,7 +6337,7 @@ var DevicesServiceImpl = class {
6016
6337
  presenceSubscribed = true;
6017
6338
  }
6018
6339
  };
6019
- const subscriptions = new import_async20.EventSubscriptions();
6340
+ const subscriptions = new import_async21.EventSubscriptions();
6020
6341
  if (this._identityManager.identity) {
6021
6342
  subscribeIdentity();
6022
6343
  subscribePresence();
@@ -6056,7 +6377,7 @@ var DiagnosticsCollector = class {
6056
6377
  client: clientDiagnostics,
6057
6378
  broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
6058
6379
  };
6059
- return JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)(options)));
6380
+ return JSON.parse(JSON.stringify(diagnostics, (0, import_util14.jsonKeyReplacer)(options)));
6060
6381
  }
6061
6382
  };
6062
6383
  var findSystemServiceProvider = () => {
@@ -6066,35 +6387,112 @@ var findSystemServiceProvider = () => {
6066
6387
  };
6067
6388
  var findConfigs = () => {
6068
6389
  const configs = import_tracing10.TRACE_PROCESSOR.findResourcesByAnnotation(import_config3.ConfigResource);
6069
- return configs.map((r) => r.instance.deref()).filter(import_util12.nonNullable);
6390
+ return configs.map((r) => r.instance.deref()).filter(import_util14.nonNullable);
6391
+ };
6392
+ var ContactsServiceImpl = class {
6393
+ constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
6394
+ this._identityManager = _identityManager;
6395
+ this._spaceManager = _spaceManager;
6396
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
6397
+ }
6398
+ async getContacts() {
6399
+ const identity = this._identityManager.identity;
6400
+ if (identity == null) {
6401
+ return {
6402
+ contacts: []
6403
+ };
6404
+ }
6405
+ const contacts = [
6406
+ ...this._spaceManager.spaces.values()
6407
+ ].flatMap((s) => [
6408
+ ...s.spaceState.members.values()
6409
+ ].map((m) => [
6410
+ s.key,
6411
+ m
6412
+ ])).reduce((acc, v) => {
6413
+ const [spaceKey, memberInfo] = v;
6414
+ if (memberInfo.key.equals(identity.identityKey)) {
6415
+ return acc;
6416
+ }
6417
+ const existing = acc.get(memberInfo.key);
6418
+ if (existing != null) {
6419
+ existing.profile ??= memberInfo.profile;
6420
+ existing.commonSpaces?.push(spaceKey);
6421
+ } else {
6422
+ acc.set(memberInfo.key, {
6423
+ identityKey: memberInfo.key,
6424
+ profile: memberInfo.profile,
6425
+ commonSpaces: [
6426
+ spaceKey
6427
+ ]
6428
+ });
6429
+ }
6430
+ return acc;
6431
+ }, new import_util16.ComplexMap(import_keys17.PublicKey.hash));
6432
+ return {
6433
+ contacts: [
6434
+ ...contacts.values()
6435
+ ]
6436
+ };
6437
+ }
6438
+ queryContacts() {
6439
+ const subscribedSpaceKeySet = new import_util16.ComplexSet(import_keys17.PublicKey.hash);
6440
+ return new import_codec_protobuf13.Stream(({ next, ctx }) => {
6441
+ const pushUpdateTask = new import_async22.UpdateScheduler(ctx, async () => {
6442
+ const contacts = await this.getContacts();
6443
+ next(contacts);
6444
+ }, {
6445
+ maxFrequency: 2
6446
+ });
6447
+ (0, import_async22.scheduleTask)(ctx, async () => {
6448
+ const subscriptions = new import_async22.EventSubscriptions();
6449
+ ctx.onDispose(() => subscriptions.clear());
6450
+ const subscribeToSpaceAndUpdate = () => {
6451
+ const oldSetSize = subscribedSpaceKeySet.size;
6452
+ for (const space of this._spaceManager.spaces.values()) {
6453
+ if (!subscribedSpaceKeySet.has(space.key)) {
6454
+ subscriptions.add(space.stateUpdate.on(ctx, () => pushUpdateTask.trigger()));
6455
+ subscribedSpaceKeySet.add(space.key);
6456
+ }
6457
+ }
6458
+ if (oldSetSize !== subscribedSpaceKeySet.size) {
6459
+ pushUpdateTask.trigger();
6460
+ }
6461
+ };
6462
+ const unsubscribe = (await this._dataSpaceManagerProvider()).updated.on(ctx, subscribeToSpaceAndUpdate);
6463
+ ctx.onDispose(unsubscribe);
6464
+ subscribeToSpaceAndUpdate();
6465
+ });
6466
+ });
6467
+ }
6070
6468
  };
6071
6469
  var LoggingServiceImpl = class {
6072
6470
  constructor() {
6073
- this._logs = new import_async21.Event();
6471
+ this._logs = new import_async23.Event();
6074
6472
  this._started = Date.now();
6075
- this._sessionId = import_keys17.PublicKey.random().toHex();
6473
+ this._sessionId = import_keys18.PublicKey.random().toHex();
6076
6474
  this._logProcessor = (_config, entry2) => {
6077
6475
  this._logs.emit(entry2);
6078
6476
  };
6079
6477
  }
6080
6478
  async open() {
6081
- import_log19.log.runtimeConfig.processors.push(this._logProcessor);
6479
+ import_log21.log.runtimeConfig.processors.push(this._logProcessor);
6082
6480
  }
6083
6481
  async close() {
6084
- const index = import_log19.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6085
- import_log19.log.runtimeConfig.processors.splice(index, 1);
6482
+ const index = import_log21.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6483
+ import_log21.log.runtimeConfig.processors.splice(index, 1);
6086
6484
  }
6087
6485
  async controlMetrics({ reset, record }) {
6088
6486
  if (reset) {
6089
- import_util14.tracer.clear();
6487
+ import_util17.tracer.clear();
6090
6488
  }
6091
6489
  if (record === true) {
6092
- import_util14.tracer.start();
6490
+ import_util17.tracer.start();
6093
6491
  } else if (record === false) {
6094
- import_util14.tracer.stop();
6492
+ import_util17.tracer.stop();
6095
6493
  }
6096
6494
  return {
6097
- recording: import_util14.tracer.recording
6495
+ recording: import_util17.tracer.recording
6098
6496
  };
6099
6497
  }
6100
6498
  /**
@@ -6102,13 +6500,13 @@ var LoggingServiceImpl = class {
6102
6500
  */
6103
6501
  queryMetrics({ interval = 5e3 }) {
6104
6502
  const getNumericalValues = (key) => {
6105
- const events = import_util14.tracer.get(key) ?? [];
6503
+ const events = import_util17.tracer.get(key) ?? [];
6106
6504
  return {
6107
6505
  key,
6108
- stats: (0, import_util14.numericalValues)(events, "duration")
6506
+ stats: (0, import_util17.numericalValues)(events, "duration")
6109
6507
  };
6110
6508
  };
6111
- return new import_codec_protobuf13.Stream(({ next }) => {
6509
+ return new import_codec_protobuf14.Stream(({ next }) => {
6112
6510
  const update = () => {
6113
6511
  const metrics = {
6114
6512
  timestamp: /* @__PURE__ */ new Date(),
@@ -6130,7 +6528,7 @@ var LoggingServiceImpl = class {
6130
6528
  });
6131
6529
  }
6132
6530
  queryLogs(request) {
6133
- return new import_codec_protobuf13.Stream(({ ctx, next }) => {
6531
+ return new import_codec_protobuf14.Stream(({ ctx, next }) => {
6134
6532
  const handler = (entry2) => {
6135
6533
  if (LOG_PROCESSING > 0) {
6136
6534
  return;
@@ -6143,7 +6541,7 @@ var LoggingServiceImpl = class {
6143
6541
  }
6144
6542
  const record = {
6145
6543
  ...entry2,
6146
- context: (0, import_util14.jsonify)((0, import_log19.getContextFromEntry)(entry2)),
6544
+ context: (0, import_util17.jsonify)((0, import_log21.getContextFromEntry)(entry2)),
6147
6545
  timestamp: /* @__PURE__ */ new Date(),
6148
6546
  meta: {
6149
6547
  // TODO(dmaretskyi): Fix proto.
@@ -6152,7 +6550,7 @@ var LoggingServiceImpl = class {
6152
6550
  scope: {
6153
6551
  hostSessionId: this._sessionId,
6154
6552
  uptimeSeconds: (Date.now() - this._started) / 1e3,
6155
- name: (0, import_util14.getDebugName)(entry2.meta?.S)
6553
+ name: (0, import_util17.getDebugName)(entry2.meta?.S)
6156
6554
  }
6157
6555
  }
6158
6556
  };
@@ -6190,7 +6588,7 @@ var NetworkServiceImpl = class {
6190
6588
  this.signalManager = signalManager;
6191
6589
  }
6192
6590
  queryStatus() {
6193
- return new import_codec_protobuf14.Stream(({ next }) => {
6591
+ return new import_codec_protobuf15.Stream(({ next }) => {
6194
6592
  const update = () => {
6195
6593
  next({
6196
6594
  swarm: this.networkManager.connectionState,
@@ -6233,7 +6631,7 @@ var SystemServiceImpl = class {
6233
6631
  const diagnostics = await this._getDiagnostics();
6234
6632
  return {
6235
6633
  timestamp: /* @__PURE__ */ new Date(),
6236
- diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util15.jsonKeyReplacer)({
6634
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util18.jsonKeyReplacer)({
6237
6635
  truncate: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
6238
6636
  humanize: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
6239
6637
  })))
@@ -6247,7 +6645,7 @@ var SystemServiceImpl = class {
6247
6645
  }
6248
6646
  // TODO(burdon): Standardize interval option in stream request?
6249
6647
  queryStatus({ interval = 3e3 } = {}) {
6250
- return new import_codec_protobuf15.Stream(({ next }) => {
6648
+ return new import_codec_protobuf16.Stream(({ next }) => {
6251
6649
  const update = () => {
6252
6650
  next({
6253
6651
  status: this._getCurrentStatus()
@@ -6276,7 +6674,7 @@ function _ts_decorate8(decorators, target, key, desc) {
6276
6674
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6277
6675
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6278
6676
  }
6279
- var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6677
+ var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6280
6678
  var ClientServicesHost = class {
6281
6679
  constructor({
6282
6680
  config,
@@ -6290,7 +6688,7 @@ var ClientServicesHost = class {
6290
6688
  runtimeParams
6291
6689
  } = {}) {
6292
6690
  this._tracingService = import_tracing9.TRACE_PROCESSOR.createTraceSender();
6293
- this._statusUpdate = new import_async19.Event();
6691
+ this._statusUpdate = new import_async20.Event();
6294
6692
  this._opening = false;
6295
6693
  this._open = false;
6296
6694
  this._storage = storage;
@@ -6309,7 +6707,10 @@ var ClientServicesHost = class {
6309
6707
  lockKey,
6310
6708
  onAcquire: () => {
6311
6709
  if (!this._opening) {
6312
- void this.open(new import_context16.Context());
6710
+ void this.open(new import_context16.Context(void 0, {
6711
+ F: __dxlog_file24,
6712
+ L: 121
6713
+ }));
6313
6714
  }
6314
6715
  },
6315
6716
  onRelease: () => this.close()
@@ -6364,25 +6765,25 @@ var ClientServicesHost = class {
6364
6765
  * Can only be called once.
6365
6766
  */
6366
6767
  initialize({ config, ...options }) {
6367
- (0, import_invariant19.invariant)(!this._open, "service host is open", {
6368
- F: __dxlog_file22,
6369
- L: 186,
6768
+ (0, import_invariant20.invariant)(!this._open, "service host is open", {
6769
+ F: __dxlog_file24,
6770
+ L: 187,
6370
6771
  S: this,
6371
6772
  A: [
6372
6773
  "!this._open",
6373
6774
  "'service host is open'"
6374
6775
  ]
6375
6776
  });
6376
- (0, import_log18.log)("initializing...", void 0, {
6377
- F: __dxlog_file22,
6378
- L: 187,
6777
+ (0, import_log20.log)("initializing...", void 0, {
6778
+ F: __dxlog_file24,
6779
+ L: 188,
6379
6780
  S: this,
6380
6781
  C: (f, a) => f(...a)
6381
6782
  });
6382
6783
  if (config) {
6383
- (0, import_invariant19.invariant)(!this._config, "config already set", {
6384
- F: __dxlog_file22,
6385
- L: 190,
6784
+ (0, import_invariant20.invariant)(!this._config, "config already set", {
6785
+ F: __dxlog_file24,
6786
+ L: 191,
6386
6787
  S: this,
6387
6788
  A: [
6388
6789
  "!this._config",
@@ -6395,9 +6796,9 @@ var ClientServicesHost = class {
6395
6796
  }
6396
6797
  }
6397
6798
  if (!options.signalManager) {
6398
- import_log18.log.warn("running signaling without telemetry metadata.", void 0, {
6399
- F: __dxlog_file22,
6400
- L: 198,
6799
+ import_log20.log.warn("running signaling without telemetry metadata.", void 0, {
6800
+ F: __dxlog_file24,
6801
+ L: 199,
6401
6802
  S: this,
6402
6803
  C: (f, a) => f(...a)
6403
6804
  });
@@ -6406,9 +6807,9 @@ var ClientServicesHost = class {
6406
6807
  iceServers: this._config?.get("runtime.services.ice")
6407
6808
  }), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
6408
6809
  this._signalManager = signalManager;
6409
- (0, import_invariant19.invariant)(!this._networkManager, "network manager already set", {
6410
- F: __dxlog_file22,
6411
- L: 209,
6810
+ (0, import_invariant20.invariant)(!this._networkManager, "network manager already set", {
6811
+ F: __dxlog_file24,
6812
+ L: 210,
6412
6813
  S: this,
6413
6814
  A: [
6414
6815
  "!this._networkManager",
@@ -6420,9 +6821,9 @@ var ClientServicesHost = class {
6420
6821
  transportFactory,
6421
6822
  signalManager
6422
6823
  });
6423
- (0, import_log18.log)("initialized", void 0, {
6424
- F: __dxlog_file22,
6425
- L: 216,
6824
+ (0, import_log20.log)("initialized", void 0, {
6825
+ F: __dxlog_file24,
6826
+ L: 217,
6426
6827
  S: this,
6427
6828
  C: (f, a) => f(...a)
6428
6829
  });
@@ -6432,44 +6833,44 @@ var ClientServicesHost = class {
6432
6833
  return;
6433
6834
  }
6434
6835
  const traceId = import_keys15.PublicKey.random().toHex();
6435
- import_log18.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
6836
+ import_log20.log.trace("dxos.client-services.host.open", import_protocols16.trace.begin({
6436
6837
  id: traceId
6437
6838
  }), {
6438
- F: __dxlog_file22,
6439
- L: 227,
6839
+ F: __dxlog_file24,
6840
+ L: 228,
6440
6841
  S: this,
6441
6842
  C: (f, a) => f(...a)
6442
6843
  });
6443
- (0, import_invariant19.invariant)(this._config, "config not set", {
6444
- F: __dxlog_file22,
6445
- L: 229,
6844
+ (0, import_invariant20.invariant)(this._config, "config not set", {
6845
+ F: __dxlog_file24,
6846
+ L: 230,
6446
6847
  S: this,
6447
6848
  A: [
6448
6849
  "this._config",
6449
6850
  "'config not set'"
6450
6851
  ]
6451
6852
  });
6452
- (0, import_invariant19.invariant)(this._storage, "storage not set", {
6453
- F: __dxlog_file22,
6454
- L: 230,
6853
+ (0, import_invariant20.invariant)(this._storage, "storage not set", {
6854
+ F: __dxlog_file24,
6855
+ L: 231,
6455
6856
  S: this,
6456
6857
  A: [
6457
6858
  "this._storage",
6458
6859
  "'storage not set'"
6459
6860
  ]
6460
6861
  });
6461
- (0, import_invariant19.invariant)(this._signalManager, "signal manager not set", {
6462
- F: __dxlog_file22,
6463
- L: 231,
6862
+ (0, import_invariant20.invariant)(this._signalManager, "signal manager not set", {
6863
+ F: __dxlog_file24,
6864
+ L: 232,
6464
6865
  S: this,
6465
6866
  A: [
6466
6867
  "this._signalManager",
6467
6868
  "'signal manager not set'"
6468
6869
  ]
6469
6870
  });
6470
- (0, import_invariant19.invariant)(this._networkManager, "network manager not set", {
6471
- F: __dxlog_file22,
6472
- L: 232,
6871
+ (0, import_invariant20.invariant)(this._networkManager, "network manager not set", {
6872
+ F: __dxlog_file24,
6873
+ L: 233,
6473
6874
  S: this,
6474
6875
  A: [
6475
6876
  "this._networkManager",
@@ -6477,11 +6878,11 @@ var ClientServicesHost = class {
6477
6878
  ]
6478
6879
  });
6479
6880
  this._opening = true;
6480
- (0, import_log18.log)("opening...", {
6881
+ (0, import_log20.log)("opening...", {
6481
6882
  lockKey: this._resourceLock?.lockKey
6482
6883
  }, {
6483
- F: __dxlog_file22,
6484
- L: 235,
6884
+ F: __dxlog_file24,
6885
+ L: 236,
6485
6886
  S: this,
6486
6887
  C: (f, a) => f(...a)
6487
6888
  });
@@ -6492,16 +6893,18 @@ var ClientServicesHost = class {
6492
6893
  await this._level.open();
6493
6894
  await this._loggingService.open();
6494
6895
  this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
6896
+ const dataSpaceManagerProvider = async () => {
6897
+ await this._serviceContext.initialized.wait();
6898
+ return this._serviceContext.dataSpaceManager;
6899
+ };
6495
6900
  const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
6496
6901
  this._serviceRegistry.setServices({
6497
6902
  SystemService: this._systemService,
6498
6903
  IdentityService: identityService,
6904
+ ContactsService: new ContactsServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6499
6905
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
6500
6906
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
6501
- SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
6502
- await this._serviceContext.initialized.wait();
6503
- return this._serviceContext.dataSpaceManager;
6504
- }),
6907
+ SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
6505
6908
  DataService: this._serviceContext.echoHost.dataService,
6506
6909
  QueryService: this._serviceContext.echoHost.queryService,
6507
6910
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
@@ -6531,19 +6934,19 @@ var ClientServicesHost = class {
6531
6934
  this._open = true;
6532
6935
  this._statusUpdate.emit();
6533
6936
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6534
- (0, import_log18.log)("opened", {
6937
+ (0, import_log20.log)("opened", {
6535
6938
  deviceKey
6536
6939
  }, {
6537
- F: __dxlog_file22,
6538
- L: 314,
6940
+ F: __dxlog_file24,
6941
+ L: 322,
6539
6942
  S: this,
6540
6943
  C: (f, a) => f(...a)
6541
6944
  });
6542
- import_log18.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
6945
+ import_log20.log.trace("dxos.client-services.host.open", import_protocols16.trace.end({
6543
6946
  id: traceId
6544
6947
  }), {
6545
- F: __dxlog_file22,
6546
- L: 315,
6948
+ F: __dxlog_file24,
6949
+ L: 323,
6547
6950
  S: this,
6548
6951
  C: (f, a) => f(...a)
6549
6952
  });
@@ -6553,11 +6956,11 @@ var ClientServicesHost = class {
6553
6956
  return;
6554
6957
  }
6555
6958
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6556
- (0, import_log18.log)("closing...", {
6959
+ (0, import_log20.log)("closing...", {
6557
6960
  deviceKey
6558
6961
  }, {
6559
- F: __dxlog_file22,
6560
- L: 326,
6962
+ F: __dxlog_file24,
6963
+ L: 334,
6561
6964
  S: this,
6562
6965
  C: (f, a) => f(...a)
6563
6966
  });
@@ -6571,44 +6974,44 @@ var ClientServicesHost = class {
6571
6974
  await this._level?.close();
6572
6975
  this._open = false;
6573
6976
  this._statusUpdate.emit();
6574
- (0, import_log18.log)("closed", {
6977
+ (0, import_log20.log)("closed", {
6575
6978
  deviceKey
6576
6979
  }, {
6577
- F: __dxlog_file22,
6578
- L: 335,
6980
+ F: __dxlog_file24,
6981
+ L: 343,
6579
6982
  S: this,
6580
6983
  C: (f, a) => f(...a)
6581
6984
  });
6582
6985
  }
6583
6986
  async reset() {
6584
6987
  const traceId = import_keys15.PublicKey.random().toHex();
6585
- import_log18.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
6988
+ import_log20.log.trace("dxos.sdk.client-services-host.reset", import_protocols16.trace.begin({
6586
6989
  id: traceId
6587
6990
  }), {
6588
- F: __dxlog_file22,
6589
- L: 340,
6991
+ F: __dxlog_file24,
6992
+ L: 348,
6590
6993
  S: this,
6591
6994
  C: (f, a) => f(...a)
6592
6995
  });
6593
- import_log18.log.info("resetting...", void 0, {
6594
- F: __dxlog_file22,
6595
- L: 342,
6996
+ import_log20.log.info("resetting...", void 0, {
6997
+ F: __dxlog_file24,
6998
+ L: 350,
6596
6999
  S: this,
6597
7000
  C: (f, a) => f(...a)
6598
7001
  });
6599
7002
  await this._serviceContext?.close();
6600
7003
  await this._storage.reset();
6601
- import_log18.log.info("reset", void 0, {
6602
- F: __dxlog_file22,
6603
- L: 345,
7004
+ import_log20.log.info("reset", void 0, {
7005
+ F: __dxlog_file24,
7006
+ L: 353,
6604
7007
  S: this,
6605
7008
  C: (f, a) => f(...a)
6606
7009
  });
6607
- import_log18.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
7010
+ import_log20.log.trace("dxos.sdk.client-services-host.reset", import_protocols16.trace.end({
6608
7011
  id: traceId
6609
7012
  }), {
6610
- F: __dxlog_file22,
6611
- L: 346,
7013
+ F: __dxlog_file24,
7014
+ L: 354,
6612
7015
  S: this,
6613
7016
  C: (f, a) => f(...a)
6614
7017
  });
@@ -6627,11 +7030,11 @@ _ts_decorate8([
6627
7030
  import_tracing9.trace.info()
6628
7031
  ], ClientServicesHost.prototype, "_open", void 0);
6629
7032
  _ts_decorate8([
6630
- import_async19.synchronized,
7033
+ import_async20.synchronized,
6631
7034
  import_tracing9.trace.span()
6632
7035
  ], ClientServicesHost.prototype, "open", null);
6633
7036
  _ts_decorate8([
6634
- import_async19.synchronized,
7037
+ import_async20.synchronized,
6635
7038
  import_tracing9.trace.span()
6636
7039
  ], ClientServicesHost.prototype, "close", null);
6637
7040
  ClientServicesHost = _ts_decorate8([
@@ -6667,7 +7070,11 @@ ClientServicesHost = _ts_decorate8([
6667
7070
  createDiagnostics,
6668
7071
  createLevel,
6669
7072
  createStorageObjects,
7073
+ decodeProfileArchive,
7074
+ encodeProfileArchive,
7075
+ exportProfileData,
6670
7076
  getNetworkPeers,
7077
+ importProfileData,
6671
7078
  isLocked,
6672
7079
  subscribeToFeedBlocks,
6673
7080
  subscribeToFeeds,
@@ -6677,4 +7084,4 @@ ClientServicesHost = _ts_decorate8([
6677
7084
  subscribeToSpaces,
6678
7085
  subscribeToSwarmInfo
6679
7086
  });
6680
- //# sourceMappingURL=chunk-2K5VPBW6.cjs.map
7087
+ //# sourceMappingURL=chunk-4LN54Y73.cjs.map