@dxos/client-services 0.5.9-main.2dbe289 → 0.5.9-main.4ed8273

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 (39) hide show
  1. package/dist/lib/browser/{chunk-QWL2M4EU.mjs → chunk-YJ5SPRLY.mjs} +728 -589
  2. package/dist/lib/browser/chunk-YJ5SPRLY.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +10 -9
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-NPYJIVOX.cjs → chunk-RQHBQWKH.cjs} +944 -809
  8. package/dist/lib/node/chunk-RQHBQWKH.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +42 -42
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +16 -15
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +19 -0
  14. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -0
  15. package/dist/types/src/packlets/identity/identity-service.d.ts +14 -7
  16. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  17. package/dist/types/src/packlets/identity/identity.d.ts +4 -1
  18. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/service-host.d.ts +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 +5 -3
  22. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  23. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  24. package/dist/types/src/packlets/testing/test-builder.d.ts +8 -6
  25. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  26. package/dist/types/src/version.d.ts +1 -1
  27. package/package.json +36 -36
  28. package/src/packlets/identity/default-space-state-machine.ts +44 -0
  29. package/src/packlets/identity/identity-service.test.ts +35 -5
  30. package/src/packlets/identity/identity-service.ts +50 -8
  31. package/src/packlets/identity/identity.ts +25 -2
  32. package/src/packlets/services/service-host.ts +13 -40
  33. package/src/packlets/spaces/data-space-manager.test.ts +46 -1
  34. package/src/packlets/spaces/data-space-manager.ts +54 -25
  35. package/src/packlets/spaces/data-space.ts +9 -5
  36. package/src/packlets/testing/test-builder.ts +11 -6
  37. package/src/version.ts +1 -1
  38. package/dist/lib/browser/chunk-QWL2M4EU.mjs.map +0 -7
  39. package/dist/lib/node/chunk-NPYJIVOX.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_NPYJIVOX_exports = {};
30
- __export(chunk_NPYJIVOX_exports, {
29
+ var chunk_RQHBQWKH_exports = {};
30
+ __export(chunk_RQHBQWKH_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  ClientServicesProviderResource: () => ClientServicesProviderResource,
@@ -67,7 +67,7 @@ __export(chunk_NPYJIVOX_exports, {
67
67
  subscribeToSpaces: () => subscribeToSpaces,
68
68
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
69
69
  });
70
- module.exports = __toCommonJS(chunk_NPYJIVOX_exports);
70
+ module.exports = __toCommonJS(chunk_RQHBQWKH_exports);
71
71
  var import_async = require("@dxos/async");
72
72
  var import_codec_protobuf = require("@dxos/codec-protobuf");
73
73
  var import_feed_store = require("@dxos/feed-store");
@@ -107,200 +107,206 @@ var import_invariant2 = require("@dxos/invariant");
107
107
  var import_keys3 = require("@dxos/keys");
108
108
  var import_log2 = require("@dxos/log");
109
109
  var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
110
+ var import_timeframe = require("@dxos/timeframe");
110
111
  var import_tracing3 = require("@dxos/tracing");
111
112
  var import_util2 = require("@dxos/util");
113
+ var import_credentials5 = require("@dxos/credentials");
114
+ var import_keys4 = require("@dxos/keys");
115
+ var import_log3 = require("@dxos/log");
112
116
  var import_platform = __toESM(require("platform"));
113
117
  var import_async7 = require("@dxos/async");
114
118
  var import_context3 = require("@dxos/context");
115
- var import_credentials5 = require("@dxos/credentials");
119
+ var import_credentials6 = require("@dxos/credentials");
116
120
  var import_invariant3 = require("@dxos/invariant");
117
- var import_keys4 = require("@dxos/keys");
118
- var import_log3 = require("@dxos/log");
121
+ var import_keys5 = require("@dxos/keys");
122
+ var import_log4 = require("@dxos/log");
119
123
  var import_protocols3 = require("@dxos/protocols");
120
124
  var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
121
- var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials");
125
+ var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
122
126
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
123
- var import_timeframe = require("@dxos/timeframe");
127
+ var import_timeframe2 = require("@dxos/timeframe");
124
128
  var import_tracing4 = require("@dxos/tracing");
125
129
  var import_util3 = require("@dxos/util");
126
130
  var import_codec_protobuf9 = require("@dxos/codec-protobuf");
127
- var import_credentials7 = require("@dxos/credentials");
131
+ var import_context4 = require("@dxos/context");
132
+ var import_credentials8 = require("@dxos/credentials");
128
133
  var import_debug2 = require("@dxos/debug");
129
134
  var import_invariant4 = require("@dxos/invariant");
135
+ var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
130
136
  var import_invariant5 = require("@dxos/invariant");
131
137
  var import_protocols4 = require("@dxos/protocols");
132
- var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
138
+ var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
133
139
  var import_async8 = require("@dxos/async");
134
140
  var import_client_protocol2 = require("@dxos/client-protocol");
135
- var import_context4 = require("@dxos/context");
141
+ var import_context5 = require("@dxos/context");
136
142
  var import_crypto = require("@dxos/crypto");
137
143
  var import_invariant6 = require("@dxos/invariant");
138
- var import_keys5 = require("@dxos/keys");
139
- var import_log4 = require("@dxos/log");
144
+ var import_keys6 = require("@dxos/keys");
145
+ var import_log5 = require("@dxos/log");
140
146
  var import_network_manager = require("@dxos/network-manager");
141
147
  var import_protocols5 = require("@dxos/protocols");
142
- var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
148
+ var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
143
149
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
144
150
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
145
151
  var import_util4 = require("@dxos/util");
146
152
  var import_async9 = require("@dxos/async");
147
- var import_context5 = require("@dxos/context");
153
+ var import_context6 = require("@dxos/context");
148
154
  var import_invariant7 = require("@dxos/invariant");
149
- var import_log5 = require("@dxos/log");
155
+ var import_log6 = require("@dxos/log");
150
156
  var import_protocols6 = require("@dxos/protocols");
151
157
  var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
152
158
  var import_teleport = require("@dxos/teleport");
153
- var import_context6 = require("@dxos/context");
154
- var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
155
- var import_async10 = require("@dxos/async");
156
159
  var import_context7 = require("@dxos/context");
160
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
161
+ var import_async10 = require("@dxos/async");
162
+ var import_context8 = require("@dxos/context");
157
163
  var import_crypto2 = require("@dxos/crypto");
158
164
  var import_invariant8 = require("@dxos/invariant");
159
- var import_keys6 = require("@dxos/keys");
160
- var import_log6 = require("@dxos/log");
165
+ var import_keys7 = require("@dxos/keys");
166
+ var import_log7 = require("@dxos/log");
161
167
  var import_protocols7 = require("@dxos/protocols");
162
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
168
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
163
169
  var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
164
170
  var import_teleport2 = require("@dxos/teleport");
165
171
  var import_invariant9 = require("@dxos/invariant");
166
- var import_keys7 = require("@dxos/keys");
167
- var import_log7 = require("@dxos/log");
172
+ var import_keys8 = require("@dxos/keys");
173
+ var import_log8 = require("@dxos/log");
168
174
  var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations");
169
175
  var import_util5 = require("@dxos/util");
170
176
  var import_codec_protobuf10 = require("@dxos/codec-protobuf");
171
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
172
- var import_credentials8 = require("@dxos/credentials");
177
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
178
+ var import_credentials9 = require("@dxos/credentials");
173
179
  var import_feed_store3 = require("@dxos/feed-store");
174
180
  var import_invariant10 = require("@dxos/invariant");
175
- var import_log8 = require("@dxos/log");
181
+ var import_log9 = require("@dxos/log");
176
182
  var import_protocols8 = require("@dxos/protocols");
177
- var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
178
- var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
183
+ var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
184
+ var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
179
185
  var import_async11 = require("@dxos/async");
180
186
  var import_client_protocol3 = require("@dxos/client-protocol");
181
- var import_context8 = require("@dxos/context");
182
- var import_credentials10 = require("@dxos/credentials");
187
+ var import_context9 = require("@dxos/context");
188
+ var import_credentials11 = require("@dxos/credentials");
183
189
  var import_echo_pipeline = require("@dxos/echo-pipeline");
184
190
  var import_invariant11 = require("@dxos/invariant");
185
- var import_keys8 = require("@dxos/keys");
186
- var import_log9 = require("@dxos/log");
187
- var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
188
- var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
191
+ var import_keys9 = require("@dxos/keys");
192
+ var import_log10 = require("@dxos/log");
193
+ var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
194
+ var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
189
195
  var import_async12 = require("@dxos/async");
190
196
  var import_client_protocol4 = require("@dxos/client-protocol");
191
- var import_context9 = require("@dxos/context");
197
+ var import_context10 = require("@dxos/context");
192
198
  var import_debug3 = require("@dxos/debug");
193
199
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
194
200
  var import_echo_schema = require("@dxos/echo-schema");
195
201
  var import_invariant12 = require("@dxos/invariant");
196
- var import_keys9 = require("@dxos/keys");
197
- var import_log10 = require("@dxos/log");
202
+ var import_keys10 = require("@dxos/keys");
203
+ var import_log11 = require("@dxos/log");
198
204
  var import_protocols9 = require("@dxos/protocols");
199
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
200
- var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
201
- var import_timeframe2 = require("@dxos/timeframe");
205
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
206
+ var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
207
+ var import_timeframe3 = require("@dxos/timeframe");
202
208
  var import_tracing5 = require("@dxos/tracing");
203
209
  var import_util6 = require("@dxos/util");
204
210
  var import_async13 = require("@dxos/async");
205
- var import_credentials13 = require("@dxos/credentials");
211
+ var import_credentials14 = require("@dxos/credentials");
206
212
  var import_async14 = require("@dxos/async");
207
- var import_context10 = require("@dxos/context");
213
+ var import_context11 = require("@dxos/context");
208
214
  var import_invariant13 = require("@dxos/invariant");
209
- var import_keys10 = require("@dxos/keys");
210
- var import_log11 = require("@dxos/log");
215
+ var import_keys11 = require("@dxos/keys");
216
+ var import_log12 = require("@dxos/log");
211
217
  var import_protocols10 = require("@dxos/protocols");
212
218
  var import_teleport3 = require("@dxos/teleport");
213
219
  var import_util7 = require("@dxos/util");
214
220
  var import_async15 = require("@dxos/async");
215
- var import_context11 = require("@dxos/context");
216
- var import_credentials14 = require("@dxos/credentials");
221
+ var import_client_protocol5 = require("@dxos/client-protocol");
222
+ var import_context12 = require("@dxos/context");
223
+ var import_credentials15 = require("@dxos/credentials");
217
224
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
225
+ var import_echo_protocol = require("@dxos/echo-protocol");
226
+ var import_echo_schema2 = require("@dxos/echo-schema");
218
227
  var import_invariant14 = require("@dxos/invariant");
219
- var import_keys11 = require("@dxos/keys");
220
- var import_log12 = require("@dxos/log");
228
+ var import_keys12 = require("@dxos/keys");
229
+ var import_log13 = require("@dxos/log");
221
230
  var import_protocols11 = require("@dxos/protocols");
222
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
223
- var import_credentials15 = require("@dxos/protocols/proto/dxos/halo/credentials");
231
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
232
+ var import_credentials16 = require("@dxos/protocols/proto/dxos/halo/credentials");
224
233
  var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
225
234
  var import_tracing6 = require("@dxos/tracing");
226
235
  var import_util8 = require("@dxos/util");
227
- var import_credentials16 = require("@dxos/credentials");
236
+ var import_credentials17 = require("@dxos/credentials");
228
237
  var import_debug4 = require("@dxos/debug");
229
- var import_credentials17 = require("@dxos/protocols/proto/dxos/halo/credentials");
230
- var import_timeframe3 = require("@dxos/timeframe");
238
+ var import_credentials18 = require("@dxos/protocols/proto/dxos/halo/credentials");
239
+ var import_timeframe4 = require("@dxos/timeframe");
231
240
  var import_async16 = require("@dxos/async");
232
241
  var import_codec_protobuf11 = require("@dxos/codec-protobuf");
233
- var import_credentials18 = require("@dxos/credentials");
242
+ var import_credentials19 = require("@dxos/credentials");
234
243
  var import_debug5 = require("@dxos/debug");
235
244
  var import_feed_store4 = require("@dxos/feed-store");
236
245
  var import_invariant15 = require("@dxos/invariant");
237
- var import_log13 = require("@dxos/log");
246
+ var import_log14 = require("@dxos/log");
238
247
  var import_protocols12 = require("@dxos/protocols");
239
- var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
248
+ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
240
249
  var import_tracing7 = require("@dxos/tracing");
241
250
  var import_async17 = require("@dxos/async");
242
- var import_context12 = require("@dxos/context");
243
- var import_credentials19 = require("@dxos/credentials");
251
+ var import_context13 = require("@dxos/context");
252
+ var import_credentials20 = require("@dxos/credentials");
244
253
  var import_debug6 = require("@dxos/debug");
245
254
  var import_echo_db = require("@dxos/echo-db");
246
255
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
247
256
  var import_feed_store5 = require("@dxos/feed-store");
248
257
  var import_invariant16 = require("@dxos/invariant");
249
258
  var import_keyring = require("@dxos/keyring");
250
- var import_keys12 = require("@dxos/keys");
251
- var import_log14 = require("@dxos/log");
259
+ var import_keys13 = require("@dxos/keys");
260
+ var import_log15 = require("@dxos/log");
252
261
  var import_protocols13 = require("@dxos/protocols");
253
- var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
262
+ var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
254
263
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
255
264
  var import_tracing8 = require("@dxos/tracing");
256
265
  var import_util9 = require("@dxos/util");
257
266
  var import_invariant17 = require("@dxos/invariant");
258
267
  var import_lock_file = require("@dxos/lock-file");
259
- var import_log15 = require("@dxos/log");
268
+ var import_log16 = require("@dxos/log");
260
269
  var import_protocols14 = require("@dxos/protocols");
261
270
  var import_config = require("@dxos/protocols/proto/dxos/config");
262
271
  var import_random_access_storage = require("@dxos/random-access-storage");
263
- var import_client_protocol5 = require("@dxos/client-protocol");
272
+ var import_client_protocol6 = require("@dxos/client-protocol");
264
273
  var import_config2 = require("@dxos/protocols/proto/dxos/config");
265
274
  var import_util10 = require("@dxos/util");
266
275
  var import_node_path = __toESM(require("node:path"));
267
- var import_keys13 = require("@dxos/keys");
276
+ var import_keys14 = require("@dxos/keys");
268
277
  var import_kv_store = require("@dxos/kv-store");
269
278
  var import_async18 = require("@dxos/async");
270
- var import_client_protocol6 = require("@dxos/client-protocol");
271
- var import_context13 = require("@dxos/context");
272
- var import_echo_protocol = require("@dxos/echo-protocol");
273
- var import_echo_schema2 = require("@dxos/echo-schema");
279
+ var import_client_protocol7 = require("@dxos/client-protocol");
280
+ var import_context14 = require("@dxos/context");
274
281
  var import_invariant18 = require("@dxos/invariant");
275
- var import_keys14 = require("@dxos/keys");
276
- var import_log16 = require("@dxos/log");
282
+ var import_keys15 = require("@dxos/keys");
283
+ var import_log17 = require("@dxos/log");
277
284
  var import_messaging = require("@dxos/messaging");
278
285
  var import_network_manager2 = require("@dxos/network-manager");
279
286
  var import_protocols15 = require("@dxos/protocols");
280
- var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
287
+ var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
281
288
  var import_tracing9 = require("@dxos/tracing");
282
- var import_util11 = require("@dxos/util");
283
289
  var import_websocket_rpc = require("@dxos/websocket-rpc");
284
290
  var import_async19 = require("@dxos/async");
285
291
  var import_codec_protobuf12 = require("@dxos/codec-protobuf");
286
292
  var import_invariant19 = require("@dxos/invariant");
287
- var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
288
- var import_config3 = require("@dxos/config");
289
293
  var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
294
+ var import_config3 = require("@dxos/config");
295
+ var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
290
296
  var import_tracing10 = require("@dxos/tracing");
297
+ var import_util11 = require("@dxos/util");
298
+ var import_keys16 = require("@dxos/keys");
291
299
  var import_util12 = require("@dxos/util");
292
- var import_keys15 = require("@dxos/keys");
293
- var import_util13 = require("@dxos/util");
294
300
  var import_async20 = require("@dxos/async");
295
301
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
296
- var import_keys16 = require("@dxos/keys");
297
- var import_log17 = require("@dxos/log");
298
- var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
299
- var import_util14 = require("@dxos/util");
302
+ var import_keys17 = require("@dxos/keys");
303
+ var import_log18 = require("@dxos/log");
304
+ var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
305
+ var import_util13 = require("@dxos/util");
300
306
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
301
307
  var import_codec_protobuf15 = require("@dxos/codec-protobuf");
302
- var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
303
- var import_util15 = require("@dxos/util");
308
+ var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
309
+ var import_util14 = require("@dxos/util");
304
310
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
305
311
  return new import_codec_protobuf.Stream(({ next }) => {
306
312
  const subscriptions = new import_async.EventSubscriptions();
@@ -611,7 +617,7 @@ var DevtoolsServiceImpl = class {
611
617
  });
612
618
  }
613
619
  };
614
- var DXOS_VERSION = "0.5.9-main.2dbe289";
620
+ var DXOS_VERSION = "0.5.9-main.4ed8273";
615
621
  var getPlatform = () => {
616
622
  if (process.browser) {
617
623
  if (typeof window !== "undefined") {
@@ -953,6 +959,47 @@ var TrustedKeySetAuthVerifier = class {
953
959
  return deviceSet.has(deviceKey);
954
960
  }
955
961
  };
962
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
963
+ var DefaultSpaceStateMachine = class {
964
+ constructor(_params) {
965
+ this._params = _params;
966
+ }
967
+ get spaceId() {
968
+ return this._spaceId;
969
+ }
970
+ async processCredential(credential) {
971
+ const assertion = (0, import_credentials5.getCredentialAssertion)(credential);
972
+ switch (assertion["@type"]) {
973
+ case "dxos.halo.credentials.DefaultSpace": {
974
+ if (!credential.subject.id.equals(this._params.identityKey)) {
975
+ import_log3.log.warn("Invalid default space credential", {
976
+ expectedIdentity: this._params.identityKey,
977
+ credential
978
+ }, {
979
+ F: __dxlog_file3,
980
+ L: 32,
981
+ S: this,
982
+ C: (f, a) => f(...a)
983
+ });
984
+ return;
985
+ }
986
+ if (!import_keys4.SpaceId.isValid(assertion.spaceId)) {
987
+ import_log3.log.warn("Invalid default space id", {
988
+ id: assertion.spaceId
989
+ }, {
990
+ F: __dxlog_file3,
991
+ L: 36,
992
+ S: this,
993
+ C: (f, a) => f(...a)
994
+ });
995
+ return;
996
+ }
997
+ this._spaceId = assertion.spaceId;
998
+ break;
999
+ }
1000
+ }
1001
+ }
1002
+ };
956
1003
  function _ts_decorate2(decorators, target, key, desc) {
957
1004
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
958
1005
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -963,7 +1010,7 @@ function _ts_decorate2(decorators, target, key, desc) {
963
1010
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
964
1011
  return c > 3 && r && Object.defineProperty(target, key, r), r;
965
1012
  }
966
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
1013
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
967
1014
  var Identity = class {
968
1015
  constructor({ space, signer, identityKey, deviceKey, presence }) {
969
1016
  this.stateUpdate = new import_async6.Event();
@@ -975,8 +1022,8 @@ var Identity = class {
975
1022
  import_log2.log.trace("dxos.halo.device", {
976
1023
  deviceKey
977
1024
  }, {
978
- F: __dxlog_file3,
979
- L: 67,
1025
+ F: __dxlog_file4,
1026
+ L: 70,
980
1027
  S: this,
981
1028
  C: (f, a) => f(...a)
982
1029
  });
@@ -989,6 +1036,10 @@ var Identity = class {
989
1036
  identityKey: this.identityKey,
990
1037
  onUpdate: () => this.stateUpdate.emit()
991
1038
  });
1039
+ this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
1040
+ identityKey: this.identityKey,
1041
+ onUpdate: () => this.stateUpdate.emit()
1042
+ });
992
1043
  this.authVerifier = new TrustedKeySetAuthVerifier({
993
1044
  trustedKeysProvider: () => new import_util2.ComplexSet(import_keys3.PublicKey.hash, this.authorizedDeviceKeys.keys()),
994
1045
  update: this.stateUpdate,
@@ -999,14 +1050,20 @@ var Identity = class {
999
1050
  get authorizedDeviceKeys() {
1000
1051
  return this._deviceStateMachine.authorizedDeviceKeys;
1001
1052
  }
1053
+ get defaultSpaceId() {
1054
+ return this._defaultSpaceStateMachine.spaceId;
1055
+ }
1002
1056
  async open(ctx) {
1057
+ await this._presence?.open();
1003
1058
  await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
1004
1059
  await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
1060
+ await this.space.spaceState.addCredentialProcessor(this._defaultSpaceStateMachine);
1005
1061
  await this.space.open(ctx);
1006
1062
  }
1007
1063
  async close(ctx) {
1008
- await this._presence?.destroy();
1064
+ await this._presence?.close();
1009
1065
  await this.authVerifier.close();
1066
+ await this.space.spaceState.removeCredentialProcessor(this._defaultSpaceStateMachine);
1010
1067
  await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
1011
1068
  await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
1012
1069
  await this.space.close();
@@ -1044,8 +1101,8 @@ var Identity = class {
1044
1101
  */
1045
1102
  getIdentityCredentialSigner() {
1046
1103
  (0, import_invariant2.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
1047
- F: __dxlog_file3,
1048
- L: 145,
1104
+ F: __dxlog_file4,
1105
+ L: 159,
1049
1106
  S: this,
1050
1107
  A: [
1051
1108
  "this._deviceStateMachine.deviceCredentialChain",
@@ -1060,6 +1117,26 @@ var Identity = class {
1060
1117
  getDeviceCredentialSigner() {
1061
1118
  return (0, import_credentials3.createCredentialSignerWithKey)(this._signer, this.deviceKey);
1062
1119
  }
1120
+ async updateDefaultSpace(spaceId) {
1121
+ const credential = await this.getDeviceCredentialSigner().createCredential({
1122
+ subject: this.identityKey,
1123
+ assertion: {
1124
+ "@type": "dxos.halo.credentials.DefaultSpace",
1125
+ spaceId
1126
+ }
1127
+ });
1128
+ const receipt = await this.controlPipeline.writer.write({
1129
+ credential: {
1130
+ credential
1131
+ }
1132
+ });
1133
+ await this.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
1134
+ [
1135
+ receipt.feedKey,
1136
+ receipt.seq
1137
+ ]
1138
+ ]));
1139
+ }
1063
1140
  async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
1064
1141
  (0, import_log2.log)("Admitting device:", {
1065
1142
  identityKey: this.identityKey,
@@ -1068,8 +1145,8 @@ var Identity = class {
1068
1145
  controlFeedKey,
1069
1146
  dataFeedKey
1070
1147
  }, {
1071
- F: __dxlog_file3,
1072
- L: 161,
1148
+ F: __dxlog_file4,
1149
+ L: 184,
1073
1150
  S: this,
1074
1151
  C: (f, a) => f(...a)
1075
1152
  });
@@ -1129,7 +1206,7 @@ function _ts_decorate3(decorators, target, key, desc) {
1129
1206
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1130
1207
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1131
1208
  }
1132
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1209
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1133
1210
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
1134
1211
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
1135
1212
  var IdentityManager = class {
@@ -1149,20 +1226,20 @@ var IdentityManager = class {
1149
1226
  return this._identity;
1150
1227
  }
1151
1228
  async open(ctx) {
1152
- const traceId = import_keys4.PublicKey.random().toHex();
1153
- import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
1229
+ const traceId = import_keys5.PublicKey.random().toHex();
1230
+ import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
1154
1231
  id: traceId
1155
1232
  }), {
1156
- F: __dxlog_file4,
1233
+ F: __dxlog_file5,
1157
1234
  L: 104,
1158
1235
  S: this,
1159
1236
  C: (f, a) => f(...a)
1160
1237
  });
1161
1238
  const identityRecord = this._metadataStore.getIdentityRecord();
1162
- (0, import_log3.log)("identity record", {
1239
+ (0, import_log4.log)("identity record", {
1163
1240
  identityRecord
1164
1241
  }, {
1165
- F: __dxlog_file4,
1242
+ F: __dxlog_file5,
1166
1243
  L: 107,
1167
1244
  S: this,
1168
1245
  C: (f, a) => f(...a)
@@ -1171,21 +1248,21 @@ var IdentityManager = class {
1171
1248
  this._identity = await this._constructIdentity(identityRecord);
1172
1249
  await this._identity.open(ctx);
1173
1250
  await this._identity.ready();
1174
- import_log3.log.trace("dxos.halo.identity", {
1251
+ import_log4.log.trace("dxos.halo.identity", {
1175
1252
  identityKey: identityRecord.identityKey,
1176
1253
  displayName: this._identity.profileDocument?.displayName
1177
1254
  }, {
1178
- F: __dxlog_file4,
1255
+ F: __dxlog_file5,
1179
1256
  L: 112,
1180
1257
  S: this,
1181
1258
  C: (f, a) => f(...a)
1182
1259
  });
1183
1260
  this.stateUpdate.emit();
1184
1261
  }
1185
- import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.end({
1262
+ import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.end({
1186
1263
  id: traceId
1187
1264
  }), {
1188
- F: __dxlog_file4,
1265
+ F: __dxlog_file5,
1189
1266
  L: 119,
1190
1267
  S: this,
1191
1268
  C: (f, a) => f(...a)
@@ -1196,7 +1273,7 @@ var IdentityManager = class {
1196
1273
  }
1197
1274
  async createIdentity({ displayName, deviceProfile } = {}) {
1198
1275
  (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
1199
- F: __dxlog_file4,
1276
+ F: __dxlog_file5,
1200
1277
  L: 128,
1201
1278
  S: this,
1202
1279
  A: [
@@ -1204,8 +1281,8 @@ var IdentityManager = class {
1204
1281
  "'Identity already exists.'"
1205
1282
  ]
1206
1283
  });
1207
- (0, import_log3.log)("creating identity...", void 0, {
1208
- F: __dxlog_file4,
1284
+ (0, import_log4.log)("creating identity...", void 0, {
1285
+ F: __dxlog_file5,
1209
1286
  L: 129,
1210
1287
  S: this,
1211
1288
  C: (f, a) => f(...a)
@@ -1224,9 +1301,9 @@ var IdentityManager = class {
1224
1301
  const identity = await this._constructIdentity(identityRecord);
1225
1302
  await identity.open(new import_context3.Context());
1226
1303
  {
1227
- const generator = new import_credentials5.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
1304
+ const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
1228
1305
  (0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
1229
- F: __dxlog_file4,
1306
+ F: __dxlog_file5,
1230
1307
  L: 148,
1231
1308
  S: this,
1232
1309
  A: [
@@ -1235,7 +1312,7 @@ var IdentityManager = class {
1235
1312
  ]
1236
1313
  });
1237
1314
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
1238
- F: __dxlog_file4,
1315
+ F: __dxlog_file5,
1239
1316
  L: 149,
1240
1317
  S: this,
1241
1318
  A: [
@@ -1247,7 +1324,7 @@ var IdentityManager = class {
1247
1324
  // Space genesis.
1248
1325
  ...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
1249
1326
  // Feed admission.
1250
- await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials6.AdmittedFeed.Designation.DATA)
1327
+ await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials7.AdmittedFeed.Designation.DATA)
1251
1328
  ];
1252
1329
  if (displayName) {
1253
1330
  credentials.push(await generator.createProfileCredential({
@@ -1270,22 +1347,22 @@ var IdentityManager = class {
1270
1347
  await this._metadataStore.setIdentityRecord(identityRecord);
1271
1348
  this._identity = identity;
1272
1349
  await this._identity.ready();
1273
- import_log3.log.trace("dxos.halo.identity", {
1350
+ import_log4.log.trace("dxos.halo.identity", {
1274
1351
  identityKey: identityRecord.identityKey,
1275
1352
  displayName: this._identity.profileDocument?.displayName
1276
1353
  }, {
1277
- F: __dxlog_file4,
1354
+ F: __dxlog_file5,
1278
1355
  L: 191,
1279
1356
  S: this,
1280
1357
  C: (f, a) => f(...a)
1281
1358
  });
1282
1359
  this.stateUpdate.emit();
1283
- (0, import_log3.log)("created identity", {
1360
+ (0, import_log4.log)("created identity", {
1284
1361
  identityKey: identity.identityKey,
1285
1362
  deviceKey: identity.deviceKey,
1286
1363
  profile: identity.profileDocument
1287
1364
  }, {
1288
- F: __dxlog_file4,
1365
+ F: __dxlog_file5,
1289
1366
  L: 197,
1290
1367
  S: this,
1291
1368
  C: (f, a) => f(...a)
@@ -1296,14 +1373,14 @@ var IdentityManager = class {
1296
1373
  createDefaultDeviceProfile() {
1297
1374
  let type;
1298
1375
  if ((0, import_util3.isNode)()) {
1299
- type = import_credentials6.DeviceType.AGENT;
1376
+ type = import_credentials7.DeviceType.AGENT;
1300
1377
  } else {
1301
1378
  if (import_platform.default.name?.startsWith("iOS") || import_platform.default.name?.startsWith("Android")) {
1302
- type = import_credentials6.DeviceType.MOBILE;
1379
+ type = import_credentials7.DeviceType.MOBILE;
1303
1380
  } else if (globalThis.__args) {
1304
- type = import_credentials6.DeviceType.NATIVE;
1381
+ type = import_credentials7.DeviceType.NATIVE;
1305
1382
  } else {
1306
- type = import_credentials6.DeviceType.BROWSER;
1383
+ type = import_credentials7.DeviceType.BROWSER;
1307
1384
  }
1308
1385
  }
1309
1386
  return {
@@ -1319,16 +1396,16 @@ var IdentityManager = class {
1319
1396
  * Accept an existing identity. Expects its device key to be authorized (now or later).
1320
1397
  */
1321
1398
  async acceptIdentity(params) {
1322
- (0, import_log3.log)("accepting identity", {
1399
+ (0, import_log4.log)("accepting identity", {
1323
1400
  params
1324
1401
  }, {
1325
- F: __dxlog_file4,
1402
+ F: __dxlog_file5,
1326
1403
  L: 235,
1327
1404
  S: this,
1328
1405
  C: (f, a) => f(...a)
1329
1406
  });
1330
1407
  (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
1331
- F: __dxlog_file4,
1408
+ F: __dxlog_file5,
1332
1409
  L: 236,
1333
1410
  S: this,
1334
1411
  A: [
@@ -1352,11 +1429,11 @@ var IdentityManager = class {
1352
1429
  this._identity = identity;
1353
1430
  await this._metadataStore.setIdentityRecord(identityRecord);
1354
1431
  await this._identity.ready();
1355
- import_log3.log.trace("dxos.halo.identity", {
1432
+ import_log4.log.trace("dxos.halo.identity", {
1356
1433
  identityKey: identityRecord.identityKey,
1357
1434
  displayName: this._identity.profileDocument?.displayName
1358
1435
  }, {
1359
- F: __dxlog_file4,
1436
+ F: __dxlog_file5,
1360
1437
  L: 255,
1361
1438
  S: this,
1362
1439
  C: (f, a) => f(...a)
@@ -1366,11 +1443,11 @@ var IdentityManager = class {
1366
1443
  ...params.deviceProfile
1367
1444
  });
1368
1445
  this.stateUpdate.emit();
1369
- (0, import_log3.log)("accepted identity", {
1446
+ (0, import_log4.log)("accepted identity", {
1370
1447
  identityKey: identity.identityKey,
1371
1448
  deviceKey: identity.deviceKey
1372
1449
  }, {
1373
- F: __dxlog_file4,
1450
+ F: __dxlog_file5,
1374
1451
  L: 265,
1375
1452
  S: this,
1376
1453
  C: (f, a) => f(...a)
@@ -1382,7 +1459,7 @@ var IdentityManager = class {
1382
1459
  */
1383
1460
  async updateProfile(profile) {
1384
1461
  (0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
1385
- F: __dxlog_file4,
1462
+ F: __dxlog_file5,
1386
1463
  L: 273,
1387
1464
  S: this,
1388
1465
  A: [
@@ -1402,7 +1479,7 @@ var IdentityManager = class {
1402
1479
  credential
1403
1480
  }
1404
1481
  });
1405
- await this._identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
1482
+ await this._identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
1406
1483
  [
1407
1484
  receipt.feedKey,
1408
1485
  receipt.seq
@@ -1413,7 +1490,7 @@ var IdentityManager = class {
1413
1490
  }
1414
1491
  async updateDeviceProfile(profile) {
1415
1492
  (0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
1416
- F: __dxlog_file4,
1493
+ F: __dxlog_file5,
1417
1494
  L: 290,
1418
1495
  S: this,
1419
1496
  A: [
@@ -1433,7 +1510,7 @@ var IdentityManager = class {
1433
1510
  credential
1434
1511
  }
1435
1512
  });
1436
- await this._identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
1513
+ await this._identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
1437
1514
  [
1438
1515
  receipt.feedKey,
1439
1516
  receipt.seq
@@ -1449,7 +1526,7 @@ var IdentityManager = class {
1449
1526
  }
1450
1527
  async _constructIdentity(identityRecord) {
1451
1528
  (0, import_invariant3.invariant)(!this._identity, void 0, {
1452
- F: __dxlog_file4,
1529
+ F: __dxlog_file5,
1453
1530
  L: 316,
1454
1531
  S: this,
1455
1532
  A: [
@@ -1457,10 +1534,10 @@ var IdentityManager = class {
1457
1534
  ""
1458
1535
  ]
1459
1536
  });
1460
- (0, import_log3.log)("constructing identity", {
1537
+ (0, import_log4.log)("constructing identity", {
1461
1538
  identityRecord
1462
1539
  }, {
1463
- F: __dxlog_file4,
1540
+ F: __dxlog_file5,
1464
1541
  L: 317,
1465
1542
  S: this,
1466
1543
  C: (f, a) => f(...a)
@@ -1475,7 +1552,7 @@ var IdentityManager = class {
1475
1552
  gossip
1476
1553
  });
1477
1554
  (0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
1478
- F: __dxlog_file4,
1555
+ F: __dxlog_file5,
1479
1556
  L: 330,
1480
1557
  S: this,
1481
1558
  A: [
@@ -1487,7 +1564,7 @@ var IdentityManager = class {
1487
1564
  writable: true
1488
1565
  });
1489
1566
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
1490
- F: __dxlog_file4,
1567
+ F: __dxlog_file5,
1491
1568
  L: 334,
1492
1569
  S: this,
1493
1570
  A: [
@@ -1503,7 +1580,7 @@ var IdentityManager = class {
1503
1580
  spaceRecord: identityRecord.haloSpace,
1504
1581
  swarmIdentity: {
1505
1582
  peerKey: identityRecord.deviceKey,
1506
- credentialProvider: createAuthProvider((0, import_credentials5.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
1583
+ credentialProvider: createAuthProvider((0, import_credentials6.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
1507
1584
  credentialAuthenticator: (0, import_util3.deferFunction)(() => identity.authVerifier.verifier)
1508
1585
  },
1509
1586
  gossip,
@@ -1518,10 +1595,10 @@ var IdentityManager = class {
1518
1595
  identityKey: identityRecord.identityKey,
1519
1596
  deviceKey: identityRecord.deviceKey
1520
1597
  });
1521
- (0, import_log3.log)("done", {
1598
+ (0, import_log4.log)("done", {
1522
1599
  identityKey: identityRecord.identityKey
1523
1600
  }, {
1524
- F: __dxlog_file4,
1601
+ F: __dxlog_file5,
1525
1602
  L: 360,
1526
1603
  S: this,
1527
1604
  C: (f, a) => f(...a)
@@ -1545,8 +1622,8 @@ var IdentityManager = class {
1545
1622
  }));
1546
1623
  },
1547
1624
  onAuthFailure: () => {
1548
- import_log3.log.warn("auth failure", void 0, {
1549
- F: __dxlog_file4,
1625
+ import_log4.log.warn("auth failure", void 0, {
1626
+ F: __dxlog_file5,
1550
1627
  L: 385,
1551
1628
  S: this,
1552
1629
  C: (f, a) => f(...a)
@@ -1568,21 +1645,45 @@ _ts_decorate3([
1568
1645
  IdentityManager = _ts_decorate3([
1569
1646
  import_tracing4.trace.resource()
1570
1647
  ], IdentityManager);
1571
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1572
- var IdentityServiceImpl = class {
1573
- constructor(_createIdentity, _identityManager, _keyring, _onProfileUpdate) {
1574
- this._createIdentity = _createIdentity;
1648
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1649
+ var IdentityServiceImpl = class extends import_context4.Resource {
1650
+ constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
1651
+ super();
1575
1652
  this._identityManager = _identityManager;
1576
1653
  this._keyring = _keyring;
1654
+ this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
1655
+ this._createIdentity = _createIdentity;
1577
1656
  this._onProfileUpdate = _onProfileUpdate;
1578
1657
  }
1658
+ async _open() {
1659
+ const identity = this._identityManager.identity;
1660
+ if (identity && !identity.defaultSpaceId) {
1661
+ await this._fixIdentityWithoutDefaultSpace(identity);
1662
+ }
1663
+ }
1579
1664
  async createIdentity(request) {
1580
1665
  await this._createIdentity({
1581
1666
  displayName: request.profile?.displayName,
1582
1667
  deviceProfile: request.deviceProfile
1583
1668
  });
1669
+ const dataSpaceManager = this._dataSpaceManagerProvider();
1670
+ await this._createDefaultSpace(dataSpaceManager);
1584
1671
  return this._getIdentity();
1585
1672
  }
1673
+ async _createDefaultSpace(dataSpaceManager) {
1674
+ const space = await dataSpaceManager.createDefaultSpace();
1675
+ const identity = this._identityManager.identity;
1676
+ (0, import_invariant4.invariant)(identity, void 0, {
1677
+ F: __dxlog_file6,
1678
+ L: 54,
1679
+ S: this,
1680
+ A: [
1681
+ "identity",
1682
+ ""
1683
+ ]
1684
+ });
1685
+ await identity.updateDefaultSpace(space.id);
1686
+ }
1586
1687
  async recoverIdentity(request) {
1587
1688
  return (0, import_debug2.todo)();
1588
1689
  }
@@ -1607,8 +1708,8 @@ var IdentityServiceImpl = class {
1607
1708
  }
1608
1709
  async updateProfile(profile) {
1609
1710
  (0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
1610
- F: __dxlog_file5,
1611
- L: 61,
1711
+ F: __dxlog_file6,
1712
+ L: 84,
1612
1713
  S: this,
1613
1714
  A: [
1614
1715
  "this._identityManager.identity",
@@ -1621,15 +1722,15 @@ var IdentityServiceImpl = class {
1621
1722
  }
1622
1723
  async signPresentation({ presentation, nonce }) {
1623
1724
  (0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
1624
- F: __dxlog_file5,
1625
- L: 68,
1725
+ F: __dxlog_file6,
1726
+ L: 91,
1626
1727
  S: this,
1627
1728
  A: [
1628
1729
  "this._identityManager.identity",
1629
1730
  "'Identity not initialized.'"
1630
1731
  ]
1631
1732
  });
1632
- return await (0, import_credentials7.signPresentation)({
1733
+ return await (0, import_credentials8.signPresentation)({
1633
1734
  presentation,
1634
1735
  signer: this._keyring,
1635
1736
  signerKey: this._identityManager.identity.deviceKey,
@@ -1637,8 +1738,26 @@ var IdentityServiceImpl = class {
1637
1738
  nonce
1638
1739
  });
1639
1740
  }
1741
+ async _fixIdentityWithoutDefaultSpace(identity) {
1742
+ let hasDefaultSpace = false;
1743
+ const dataSpaceManager = this._dataSpaceManagerProvider();
1744
+ for (const space of dataSpaceManager.spaces.values()) {
1745
+ if (space.state === import_services4.SpaceState.CLOSED) {
1746
+ await space.open();
1747
+ await space.initializeDataPipeline();
1748
+ }
1749
+ if (await dataSpaceManager.isDefaultSpace(space)) {
1750
+ await identity.updateDefaultSpace(space.id);
1751
+ hasDefaultSpace = true;
1752
+ break;
1753
+ }
1754
+ }
1755
+ if (!hasDefaultSpace) {
1756
+ await this._createDefaultSpace(dataSpaceManager);
1757
+ }
1758
+ }
1640
1759
  };
1641
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1760
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1642
1761
  var DeviceInvitationProtocol = class {
1643
1762
  constructor(_keyring, _getIdentity, _acceptIdentity) {
1644
1763
  this._keyring = _keyring;
@@ -1653,7 +1772,7 @@ var DeviceInvitationProtocol = class {
1653
1772
  }
1654
1773
  getInvitationContext() {
1655
1774
  return {
1656
- kind: import_services4.Invitation.Kind.DEVICE
1775
+ kind: import_services5.Invitation.Kind.DEVICE
1657
1776
  };
1658
1777
  }
1659
1778
  async delegate() {
@@ -1664,7 +1783,7 @@ var DeviceInvitationProtocol = class {
1664
1783
  }
1665
1784
  async admit(_, request) {
1666
1785
  (0, import_invariant5.invariant)(request.device, void 0, {
1667
- F: __dxlog_file6,
1786
+ F: __dxlog_file7,
1668
1787
  L: 50,
1669
1788
  S: this,
1670
1789
  A: [
@@ -1710,7 +1829,7 @@ var DeviceInvitationProtocol = class {
1710
1829
  }
1711
1830
  async accept(response, request) {
1712
1831
  (0, import_invariant5.invariant)(response.device, void 0, {
1713
- F: __dxlog_file6,
1832
+ F: __dxlog_file7,
1714
1833
  L: 95,
1715
1834
  S: this,
1716
1835
  A: [
@@ -1720,7 +1839,7 @@ var DeviceInvitationProtocol = class {
1720
1839
  });
1721
1840
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1722
1841
  (0, import_invariant5.invariant)(request.device, void 0, {
1723
- F: __dxlog_file6,
1842
+ F: __dxlog_file7,
1724
1843
  L: 98,
1725
1844
  S: this,
1726
1845
  A: [
@@ -1745,21 +1864,21 @@ var DeviceInvitationProtocol = class {
1745
1864
  }
1746
1865
  };
1747
1866
  var stateToString = (state) => {
1748
- return Object.entries(import_services6.Invitation.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
1867
+ return Object.entries(import_services7.Invitation.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
1749
1868
  };
1750
1869
  var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
1751
1870
  let guard;
1752
- return (0, import_context6.cancelWithContext)(ctx, (async () => {
1871
+ return (0, import_context7.cancelWithContext)(ctx, (async () => {
1753
1872
  guard = await mutex.acquire();
1754
1873
  if (ctx.disposed) {
1755
1874
  guard.release();
1756
1875
  guard = void 0;
1757
- throw new import_context6.ContextDisposedError();
1876
+ throw new import_context7.ContextDisposedError();
1758
1877
  }
1759
1878
  return guard;
1760
1879
  })());
1761
1880
  };
1762
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1881
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1763
1882
  var OPTIONS_TIMEOUT = 1e4;
1764
1883
  var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1765
1884
  constructor(_invitationFlowMutex, _callbacks) {
@@ -1773,7 +1892,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1773
1892
  });
1774
1893
  this._invitationFlowMutex = _invitationFlowMutex;
1775
1894
  this._callbacks = _callbacks;
1776
- this._ctx = new import_context5.Context();
1895
+ this._ctx = new import_context6.Context();
1777
1896
  this._remoteOptionsTrigger = new import_async9.Trigger();
1778
1897
  this._invitationFlowLock = null;
1779
1898
  }
@@ -1785,7 +1904,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1785
1904
  InvitationHostService: {
1786
1905
  options: async (options) => {
1787
1906
  (0, import_invariant7.invariant)(!this._remoteOptions, "Remote options already set.", {
1788
- F: __dxlog_file7,
1907
+ F: __dxlog_file8,
1789
1908
  L: 63,
1790
1909
  S: this,
1791
1910
  A: [
@@ -1811,33 +1930,33 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1811
1930
  async onOpen(context) {
1812
1931
  await super.onOpen(context);
1813
1932
  try {
1814
- (0, import_log5.log)("guest acquire lock", void 0, {
1815
- F: __dxlog_file7,
1933
+ (0, import_log6.log)("guest acquire lock", void 0, {
1934
+ F: __dxlog_file8,
1816
1935
  L: 84,
1817
1936
  S: this,
1818
1937
  C: (f, a) => f(...a)
1819
1938
  });
1820
1939
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
1821
- (0, import_log5.log)("guest lock acquired", void 0, {
1822
- F: __dxlog_file7,
1940
+ (0, import_log6.log)("guest lock acquired", void 0, {
1941
+ F: __dxlog_file8,
1823
1942
  L: 86,
1824
1943
  S: this,
1825
1944
  C: (f, a) => f(...a)
1826
1945
  });
1827
- await (0, import_context5.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
1946
+ await (0, import_context6.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
1828
1947
  role: import_invitations3.Options.Role.GUEST
1829
1948
  }));
1830
- (0, import_log5.log)("options sent", void 0, {
1831
- F: __dxlog_file7,
1949
+ (0, import_log6.log)("options sent", void 0, {
1950
+ F: __dxlog_file8,
1832
1951
  L: 88,
1833
1952
  S: this,
1834
1953
  C: (f, a) => f(...a)
1835
1954
  });
1836
- await (0, import_context5.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1955
+ await (0, import_context6.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1837
1956
  timeout: OPTIONS_TIMEOUT
1838
1957
  }));
1839
- (0, import_log5.log)("options received", void 0, {
1840
- F: __dxlog_file7,
1958
+ (0, import_log6.log)("options received", void 0, {
1959
+ F: __dxlog_file8,
1841
1960
  L: 90,
1842
1961
  S: this,
1843
1962
  C: (f, a) => f(...a)
@@ -1870,8 +1989,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1870
1989
  if (this._invitationFlowLock != null) {
1871
1990
  this._invitationFlowLock.release();
1872
1991
  this._invitationFlowLock = null;
1873
- (0, import_log5.log)("invitation flow lock released", void 0, {
1874
- F: __dxlog_file7,
1992
+ (0, import_log6.log)("invitation flow lock released", void 0, {
1993
+ F: __dxlog_file8,
1875
1994
  L: 123,
1876
1995
  S: this,
1877
1996
  C: (f, a) => f(...a)
@@ -1879,7 +1998,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1879
1998
  }
1880
1999
  }
1881
2000
  };
1882
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
2001
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
1883
2002
  var OPTIONS_TIMEOUT2 = 1e4;
1884
2003
  var MAX_OTP_ATTEMPTS = 3;
1885
2004
  var InvitationHostExtension = class extends import_teleport2.RpcExtension {
@@ -1894,7 +2013,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
1894
2013
  });
1895
2014
  this._invitationFlowMutex = _invitationFlowMutex;
1896
2015
  this._callbacks = _callbacks;
1897
- this._ctx = new import_context7.Context();
2016
+ this._ctx = new import_context8.Context();
1898
2017
  this._remoteOptionsTrigger = new import_async10.Trigger();
1899
2018
  this._challenge = void 0;
1900
2019
  this.guestProfile = void 0;
@@ -1913,7 +2032,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
1913
2032
  InvitationHostService: {
1914
2033
  options: async (options) => {
1915
2034
  (0, import_invariant8.invariant)(!this._remoteOptions, "Remote options already set.", {
1916
- F: __dxlog_file8,
2035
+ F: __dxlog_file9,
1917
2036
  L: 101,
1918
2037
  S: this,
1919
2038
  A: [
@@ -1926,23 +2045,23 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
1926
2045
  },
1927
2046
  introduce: async (request) => {
1928
2047
  const { profile, invitationId } = request;
1929
- const traceId = import_keys6.PublicKey.random().toHex();
1930
- import_log6.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.begin({
2048
+ const traceId = import_keys7.PublicKey.random().toHex();
2049
+ import_log7.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.begin({
1931
2050
  id: traceId
1932
2051
  }), {
1933
- F: __dxlog_file8,
2052
+ F: __dxlog_file9,
1934
2053
  L: 110,
1935
2054
  S: this,
1936
2055
  C: (f, a) => f(...a)
1937
2056
  });
1938
2057
  const invitation = this._requireActiveInvitation();
1939
- this._assertInvitationState(import_services7.Invitation.State.CONNECTED);
2058
+ this._assertInvitationState(import_services8.Invitation.State.CONNECTED);
1940
2059
  if (invitationId !== invitation?.invitationId) {
1941
- import_log6.log.warn("incorrect invitationId", {
2060
+ import_log7.log.warn("incorrect invitationId", {
1942
2061
  expected: invitation.invitationId,
1943
2062
  actual: invitationId
1944
2063
  }, {
1945
- F: __dxlog_file8,
2064
+ F: __dxlog_file9,
1946
2065
  L: 116,
1947
2066
  S: this,
1948
2067
  C: (f, a) => f(...a)
@@ -1950,24 +2069,24 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
1950
2069
  this._callbacks.onError(new Error("Incorrect invitationId."));
1951
2070
  (0, import_async10.scheduleTask)(this._ctx, () => this.close());
1952
2071
  return {
1953
- authMethod: import_services7.Invitation.AuthMethod.NONE
2072
+ authMethod: import_services8.Invitation.AuthMethod.NONE
1954
2073
  };
1955
2074
  }
1956
- (0, import_log6.log)("guest introduced themselves", {
2075
+ (0, import_log7.log)("guest introduced themselves", {
1957
2076
  guestProfile: profile
1958
2077
  }, {
1959
- F: __dxlog_file8,
2078
+ F: __dxlog_file9,
1960
2079
  L: 125,
1961
2080
  S: this,
1962
2081
  C: (f, a) => f(...a)
1963
2082
  });
1964
2083
  this.guestProfile = profile;
1965
- this._callbacks.onStateUpdate(import_services7.Invitation.State.READY_FOR_AUTHENTICATION);
1966
- this._challenge = invitation.authMethod === import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
1967
- import_log6.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.end({
2084
+ this._callbacks.onStateUpdate(import_services8.Invitation.State.READY_FOR_AUTHENTICATION);
2085
+ this._challenge = invitation.authMethod === import_services8.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
2086
+ import_log7.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.end({
1968
2087
  id: traceId
1969
2088
  }), {
1970
- F: __dxlog_file8,
2089
+ F: __dxlog_file9,
1971
2090
  L: 132,
1972
2091
  S: this,
1973
2092
  C: (f, a) => f(...a)
@@ -1978,34 +2097,34 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
1978
2097
  };
1979
2098
  },
1980
2099
  authenticate: async ({ authCode: code, signedChallenge }) => {
1981
- const traceId = import_keys6.PublicKey.random().toHex();
1982
- import_log6.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.begin({
2100
+ const traceId = import_keys7.PublicKey.random().toHex();
2101
+ import_log7.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.begin({
1983
2102
  id: traceId
1984
2103
  }), {
1985
- F: __dxlog_file8,
2104
+ F: __dxlog_file9,
1986
2105
  L: 141,
1987
2106
  S: this,
1988
2107
  C: (f, a) => f(...a)
1989
2108
  });
1990
2109
  const invitation = this._requireActiveInvitation();
1991
- (0, import_log6.log)("received authentication request", {
2110
+ (0, import_log7.log)("received authentication request", {
1992
2111
  authCode: code
1993
2112
  }, {
1994
- F: __dxlog_file8,
2113
+ F: __dxlog_file9,
1995
2114
  L: 144,
1996
2115
  S: this,
1997
2116
  C: (f, a) => f(...a)
1998
2117
  });
1999
2118
  let status = import_invitations4.AuthenticationResponse.Status.OK;
2000
2119
  this._assertInvitationState([
2001
- import_services7.Invitation.State.AUTHENTICATING,
2002
- import_services7.Invitation.State.READY_FOR_AUTHENTICATION
2120
+ import_services8.Invitation.State.AUTHENTICATING,
2121
+ import_services8.Invitation.State.READY_FOR_AUTHENTICATION
2003
2122
  ]);
2004
- this._callbacks.onStateUpdate(import_services7.Invitation.State.AUTHENTICATING);
2123
+ this._callbacks.onStateUpdate(import_services8.Invitation.State.AUTHENTICATING);
2005
2124
  switch (invitation.authMethod) {
2006
- case import_services7.Invitation.AuthMethod.NONE: {
2007
- (0, import_log6.log)("authentication not required", void 0, {
2008
- F: __dxlog_file8,
2125
+ case import_services8.Invitation.AuthMethod.NONE: {
2126
+ (0, import_log7.log)("authentication not required", void 0, {
2127
+ F: __dxlog_file9,
2009
2128
  L: 152,
2010
2129
  S: this,
2011
2130
  C: (f, a) => f(...a)
@@ -2014,7 +2133,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2014
2133
  status: import_invitations4.AuthenticationResponse.Status.OK
2015
2134
  };
2016
2135
  }
2017
- case import_services7.Invitation.AuthMethod.SHARED_SECRET: {
2136
+ case import_services8.Invitation.AuthMethod.SHARED_SECRET: {
2018
2137
  if (invitation.authCode) {
2019
2138
  if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
2020
2139
  status = import_invitations4.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
@@ -2026,7 +2145,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2026
2145
  }
2027
2146
  break;
2028
2147
  }
2029
- case import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
2148
+ case import_services8.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
2030
2149
  if (!invitation.guestKeypair) {
2031
2150
  status = import_invitations4.AuthenticationResponse.Status.INTERNAL_ERROR;
2032
2151
  break;
@@ -2040,10 +2159,10 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2040
2159
  break;
2041
2160
  }
2042
2161
  default: {
2043
- import_log6.log.error("invalid authentication method", {
2162
+ import_log7.log.error("invalid authentication method", {
2044
2163
  authMethod: invitation.authMethod
2045
2164
  }, {
2046
- F: __dxlog_file8,
2165
+ F: __dxlog_file9,
2047
2166
  L: 190,
2048
2167
  S: this,
2049
2168
  C: (f, a) => f(...a)
@@ -2062,13 +2181,13 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2062
2181
  status
2063
2182
  };
2064
2183
  }
2065
- import_log6.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.end({
2184
+ import_log7.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.end({
2066
2185
  id: traceId,
2067
2186
  data: {
2068
2187
  status
2069
2188
  }
2070
2189
  }), {
2071
- F: __dxlog_file8,
2190
+ F: __dxlog_file9,
2072
2191
  L: 202,
2073
2192
  S: this,
2074
2193
  C: (f, a) => f(...a)
@@ -2078,11 +2197,11 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2078
2197
  };
2079
2198
  },
2080
2199
  admit: async (request) => {
2081
- const traceId = import_keys6.PublicKey.random().toHex();
2082
- import_log6.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.begin({
2200
+ const traceId = import_keys7.PublicKey.random().toHex();
2201
+ import_log7.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.begin({
2083
2202
  id: traceId
2084
2203
  }), {
2085
- F: __dxlog_file8,
2204
+ F: __dxlog_file9,
2086
2205
  L: 208,
2087
2206
  S: this,
2088
2207
  C: (f, a) => f(...a)
@@ -2090,16 +2209,16 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2090
2209
  const invitation = this._requireActiveInvitation();
2091
2210
  try {
2092
2211
  if (isAuthenticationRequired(invitation)) {
2093
- this._assertInvitationState(import_services7.Invitation.State.AUTHENTICATING);
2212
+ this._assertInvitationState(import_services8.Invitation.State.AUTHENTICATING);
2094
2213
  if (!this.authenticationPassed) {
2095
2214
  throw new Error("Not authenticated");
2096
2215
  }
2097
2216
  }
2098
2217
  const response = await this._callbacks.admit(request);
2099
- import_log6.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.end({
2218
+ import_log7.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.end({
2100
2219
  id: traceId
2101
2220
  }), {
2102
- F: __dxlog_file8,
2221
+ F: __dxlog_file9,
2103
2222
  L: 222,
2104
2223
  S: this,
2105
2224
  C: (f, a) => f(...a)
@@ -2116,35 +2235,35 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2116
2235
  async onOpen(context) {
2117
2236
  await super.onOpen(context);
2118
2237
  try {
2119
- (0, import_log6.log)("host acquire lock", void 0, {
2120
- F: __dxlog_file8,
2238
+ (0, import_log7.log)("host acquire lock", void 0, {
2239
+ F: __dxlog_file9,
2121
2240
  L: 237,
2122
2241
  S: this,
2123
2242
  C: (f, a) => f(...a)
2124
2243
  });
2125
2244
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
2126
- (0, import_log6.log)("host lock acquired", void 0, {
2127
- F: __dxlog_file8,
2245
+ (0, import_log7.log)("host lock acquired", void 0, {
2246
+ F: __dxlog_file9,
2128
2247
  L: 239,
2129
2248
  S: this,
2130
2249
  C: (f, a) => f(...a)
2131
2250
  });
2132
2251
  const lastState = this._requireActiveInvitation().state;
2133
- this._callbacks.onStateUpdate(import_services7.Invitation.State.CONNECTING);
2252
+ this._callbacks.onStateUpdate(import_services8.Invitation.State.CONNECTING);
2134
2253
  await this.rpc.InvitationHostService.options({
2135
2254
  role: import_invitations4.Options.Role.HOST
2136
2255
  });
2137
- (0, import_log6.log)("options sent", void 0, {
2138
- F: __dxlog_file8,
2256
+ (0, import_log7.log)("options sent", void 0, {
2257
+ F: __dxlog_file9,
2139
2258
  L: 243,
2140
2259
  S: this,
2141
2260
  C: (f, a) => f(...a)
2142
2261
  });
2143
- await (0, import_context7.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
2262
+ await (0, import_context8.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
2144
2263
  timeout: OPTIONS_TIMEOUT2
2145
2264
  }));
2146
- (0, import_log6.log)("options received", void 0, {
2147
- F: __dxlog_file8,
2265
+ (0, import_log7.log)("options received", void 0, {
2266
+ F: __dxlog_file9,
2148
2267
  L: 245,
2149
2268
  S: this,
2150
2269
  C: (f, a) => f(...a)
@@ -2157,7 +2276,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2157
2276
  remotePeerId: context.remotePeerId
2158
2277
  });
2159
2278
  }
2160
- this._callbacks.onStateUpdate(import_services7.Invitation.State.CONNECTED);
2279
+ this._callbacks.onStateUpdate(import_services8.Invitation.State.CONNECTED);
2161
2280
  this._callbacks.onOpen(this._ctx, context);
2162
2281
  } catch (err) {
2163
2282
  if (this._invitationFlowLock != null) {
@@ -2197,8 +2316,8 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2197
2316
  if (this._invitationFlowLock != null) {
2198
2317
  this._invitationFlowLock?.release();
2199
2318
  this._invitationFlowLock = null;
2200
- (0, import_log6.log)("invitation flow lock released", void 0, {
2201
- F: __dxlog_file8,
2319
+ (0, import_log7.log)("invitation flow lock released", void 0, {
2320
+ F: __dxlog_file9,
2202
2321
  L: 300,
2203
2322
  S: this,
2204
2323
  C: (f, a) => f(...a)
@@ -2206,16 +2325,16 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
2206
2325
  }
2207
2326
  }
2208
2327
  };
2209
- var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services7.Invitation.AuthMethod.NONE;
2210
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2328
+ var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services8.Invitation.AuthMethod.NONE;
2329
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2211
2330
  var InvitationTopology = class {
2212
2331
  constructor(_role) {
2213
2332
  this._role = _role;
2214
- this._seenPeers = new import_util5.ComplexSet(import_keys7.PublicKey.hash);
2333
+ this._seenPeers = new import_util5.ComplexSet(import_keys8.PublicKey.hash);
2215
2334
  }
2216
2335
  init(controller) {
2217
2336
  (0, import_invariant9.invariant)(!this._controller, "Already initialized.", {
2218
- F: __dxlog_file9,
2337
+ F: __dxlog_file10,
2219
2338
  L: 42,
2220
2339
  S: this,
2221
2340
  A: [
@@ -2227,7 +2346,7 @@ var InvitationTopology = class {
2227
2346
  }
2228
2347
  update() {
2229
2348
  (0, import_invariant9.invariant)(this._controller, "Not initialized.", {
2230
- F: __dxlog_file9,
2349
+ F: __dxlog_file10,
2231
2350
  L: 47,
2232
2351
  S: this,
2233
2352
  A: [
@@ -2244,13 +2363,13 @@ var InvitationTopology = class {
2244
2363
  return;
2245
2364
  }
2246
2365
  const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
2247
- this._seenPeers = new import_util5.ComplexSet(import_keys7.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
2366
+ this._seenPeers = new import_util5.ComplexSet(import_keys8.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
2248
2367
  if (firstUnknownPeer != null) {
2249
- (0, import_log7.log)("invitation connect", {
2368
+ (0, import_log8.log)("invitation connect", {
2250
2369
  ownPeerId,
2251
2370
  remotePeerId: firstUnknownPeer
2252
2371
  }, {
2253
- F: __dxlog_file9,
2372
+ F: __dxlog_file10,
2254
2373
  L: 69,
2255
2374
  S: this,
2256
2375
  C: (f, a) => f(...a)
@@ -2261,7 +2380,7 @@ var InvitationTopology = class {
2261
2380
  }
2262
2381
  async onOffer(peer) {
2263
2382
  (0, import_invariant9.invariant)(this._controller, "Not initialized.", {
2264
- F: __dxlog_file9,
2383
+ F: __dxlog_file10,
2265
2384
  L: 76,
2266
2385
  S: this,
2267
2386
  A: [
@@ -2278,7 +2397,7 @@ var InvitationTopology = class {
2278
2397
  return `InvitationTopology(${this._role === import_invitations5.Options.Role.GUEST ? "guest" : "host"})`;
2279
2398
  }
2280
2399
  };
2281
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2400
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2282
2401
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
2283
2402
  var InvitationsHandler = class {
2284
2403
  /**
@@ -2303,7 +2422,7 @@ var InvitationsHandler = class {
2303
2422
  try {
2304
2423
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
2305
2424
  (0, import_invariant6.invariant)(deviceKey, void 0, {
2306
- F: __dxlog_file10,
2425
+ F: __dxlog_file11,
2307
2426
  L: 90,
2308
2427
  S: this,
2309
2428
  A: [
@@ -2323,24 +2442,24 @@ var InvitationsHandler = class {
2323
2442
  let admitted = false;
2324
2443
  connectionCtx.onDispose(() => {
2325
2444
  if (!admitted) {
2326
- guardedState.error(extension, new import_context4.ContextDisposedError());
2445
+ guardedState.error(extension, new import_context5.ContextDisposedError());
2327
2446
  }
2328
2447
  });
2329
2448
  (0, import_async8.scheduleTask)(connectionCtx, async () => {
2330
- const traceId = import_keys5.PublicKey.random().toHex();
2449
+ const traceId = import_keys6.PublicKey.random().toHex();
2331
2450
  try {
2332
- import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
2451
+ import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
2333
2452
  id: traceId
2334
2453
  }), {
2335
- F: __dxlog_file10,
2454
+ F: __dxlog_file11,
2336
2455
  L: 115,
2337
2456
  S: this,
2338
2457
  C: (f, a) => f(...a)
2339
2458
  });
2340
- (0, import_log4.log)("connected", {
2459
+ (0, import_log5.log)("connected", {
2341
2460
  ...protocol.toJSON()
2342
2461
  }, {
2343
- F: __dxlog_file10,
2462
+ F: __dxlog_file11,
2344
2463
  L: 116,
2345
2464
  S: this,
2346
2465
  C: (f, a) => f(...a)
@@ -2348,20 +2467,20 @@ var InvitationsHandler = class {
2348
2467
  const deviceKey = await extension.completedTrigger.wait({
2349
2468
  timeout: invitation.timeout
2350
2469
  });
2351
- (0, import_log4.log)("admitted guest", {
2470
+ (0, import_log5.log)("admitted guest", {
2352
2471
  guest: deviceKey,
2353
2472
  ...protocol.toJSON()
2354
2473
  }, {
2355
- F: __dxlog_file10,
2474
+ F: __dxlog_file11,
2356
2475
  L: 118,
2357
2476
  S: this,
2358
2477
  C: (f, a) => f(...a)
2359
2478
  });
2360
- guardedState.set(extension, import_services5.Invitation.State.SUCCESS);
2361
- import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
2479
+ guardedState.set(extension, import_services6.Invitation.State.SUCCESS);
2480
+ import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
2362
2481
  id: traceId
2363
2482
  }), {
2364
- F: __dxlog_file10,
2483
+ F: __dxlog_file11,
2365
2484
  L: 120,
2366
2485
  S: this,
2367
2486
  C: (f, a) => f(...a)
@@ -2372,11 +2491,11 @@ var InvitationsHandler = class {
2372
2491
  }
2373
2492
  } catch (err) {
2374
2493
  if (err instanceof import_async8.TimeoutError) {
2375
- if (guardedState.set(extension, import_services5.Invitation.State.TIMEOUT)) {
2376
- (0, import_log4.log)("timeout", {
2494
+ if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
2495
+ (0, import_log5.log)("timeout", {
2377
2496
  ...protocol.toJSON()
2378
2497
  }, {
2379
- F: __dxlog_file10,
2498
+ F: __dxlog_file11,
2380
2499
  L: 129,
2381
2500
  S: this,
2382
2501
  C: (f, a) => f(...a)
@@ -2384,19 +2503,19 @@ var InvitationsHandler = class {
2384
2503
  }
2385
2504
  } else {
2386
2505
  if (guardedState.error(extension, err)) {
2387
- import_log4.log.error("failed", err, {
2388
- F: __dxlog_file10,
2506
+ import_log5.log.error("failed", err, {
2507
+ F: __dxlog_file11,
2389
2508
  L: 133,
2390
2509
  S: this,
2391
2510
  C: (f, a) => f(...a)
2392
2511
  });
2393
2512
  }
2394
2513
  }
2395
- import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.error({
2514
+ import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.error({
2396
2515
  id: traceId,
2397
2516
  error: err
2398
2517
  }), {
2399
- F: __dxlog_file10,
2518
+ F: __dxlog_file11,
2400
2519
  L: 136,
2401
2520
  S: this,
2402
2521
  C: (f, a) => f(...a)
@@ -2407,10 +2526,10 @@ var InvitationsHandler = class {
2407
2526
  },
2408
2527
  onError: (err) => {
2409
2528
  if (err instanceof import_protocols5.InvalidInvitationExtensionRoleError) {
2410
- (0, import_log4.log)("invalid role", {
2529
+ (0, import_log5.log)("invalid role", {
2411
2530
  ...err.context
2412
2531
  }, {
2413
- F: __dxlog_file10,
2532
+ F: __dxlog_file11,
2414
2533
  L: 144,
2415
2534
  S: this,
2416
2535
  C: (f, a) => f(...a)
@@ -2418,11 +2537,11 @@ var InvitationsHandler = class {
2418
2537
  return;
2419
2538
  }
2420
2539
  if (err instanceof import_async8.TimeoutError) {
2421
- if (guardedState.set(extension, import_services5.Invitation.State.TIMEOUT)) {
2422
- (0, import_log4.log)("timeout", {
2540
+ if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
2541
+ (0, import_log5.log)("timeout", {
2423
2542
  err
2424
2543
  }, {
2425
- F: __dxlog_file10,
2544
+ F: __dxlog_file11,
2426
2545
  L: 149,
2427
2546
  S: this,
2428
2547
  C: (f, a) => f(...a)
@@ -2430,8 +2549,8 @@ var InvitationsHandler = class {
2430
2549
  }
2431
2550
  } else {
2432
2551
  if (guardedState.error(extension, err)) {
2433
- import_log4.log.error("failed", err, {
2434
- F: __dxlog_file10,
2552
+ import_log5.log.error("failed", err, {
2553
+ F: __dxlog_file11,
2435
2554
  L: 153,
2436
2555
  S: this,
2437
2556
  C: (f, a) => f(...a)
@@ -2444,8 +2563,8 @@ var InvitationsHandler = class {
2444
2563
  };
2445
2564
  if (invitation.lifetime && invitation.created) {
2446
2565
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
2447
- import_log4.log.warn("invitation has already expired", void 0, {
2448
- F: __dxlog_file10,
2566
+ import_log5.log.warn("invitation has already expired", void 0, {
2567
+ F: __dxlog_file11,
2449
2568
  L: 164,
2450
2569
  S: this,
2451
2570
  C: (f, a) => f(...a)
@@ -2453,7 +2572,7 @@ var InvitationsHandler = class {
2453
2572
  } else {
2454
2573
  (0, import_async8.scheduleTask)(ctx, async () => {
2455
2574
  await swarmConnection.close();
2456
- guardedState.set(null, import_services5.Invitation.State.EXPIRED);
2575
+ guardedState.set(null, import_services6.Invitation.State.EXPIRED);
2457
2576
  await ctx.dispose();
2458
2577
  }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
2459
2578
  }
@@ -2461,14 +2580,14 @@ var InvitationsHandler = class {
2461
2580
  let swarmConnection;
2462
2581
  (0, import_async8.scheduleTask)(ctx, async () => {
2463
2582
  swarmConnection = await this._joinSwarm(ctx, invitation, import_invitations2.Options.Role.HOST, createExtension);
2464
- guardedState.set(null, import_services5.Invitation.State.CONNECTING);
2583
+ guardedState.set(null, import_services6.Invitation.State.CONNECTING);
2465
2584
  });
2466
2585
  }
2467
2586
  acceptInvitation(ctx, stream, protocol, invitation, otpEnteredTrigger, deviceProfile) {
2468
2587
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
2469
2588
  if (deviceProfile) {
2470
- (0, import_invariant6.invariant)(invitation.kind === import_services5.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2471
- F: __dxlog_file10,
2589
+ (0, import_invariant6.invariant)(invitation.kind === import_services6.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2590
+ F: __dxlog_file11,
2472
2591
  L: 197,
2473
2592
  S: this,
2474
2593
  A: [
@@ -2477,16 +2596,16 @@ var InvitationsHandler = class {
2477
2596
  ]
2478
2597
  });
2479
2598
  }
2480
- const triedPeersIds = new import_util4.ComplexSet(import_keys5.PublicKey.hash);
2599
+ const triedPeersIds = new import_util4.ComplexSet(import_keys6.PublicKey.hash);
2481
2600
  const guardedState = this._createGuardedState(ctx, invitation, stream);
2482
2601
  const shouldCancelInvitationFlow = (extension) => {
2483
2602
  const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
2484
- (0, import_log4.log)("should cancel invitation flow", {
2603
+ (0, import_log5.log)("should cancel invitation flow", {
2485
2604
  isLockedByAnotherConnection,
2486
- invitationType: import_services5.Invitation.Type.DELEGATED,
2605
+ invitationType: import_services6.Invitation.Type.DELEGATED,
2487
2606
  triedPeers: triedPeersIds.size
2488
2607
  }, {
2489
- F: __dxlog_file10,
2608
+ F: __dxlog_file11,
2490
2609
  L: 205,
2491
2610
  S: this,
2492
2611
  C: (f, a) => f(...a)
@@ -2494,7 +2613,7 @@ var InvitationsHandler = class {
2494
2613
  if (isLockedByAnotherConnection) {
2495
2614
  return false;
2496
2615
  }
2497
- return invitation.type !== import_services5.Invitation.Type.DELEGATED || triedPeersIds.size >= MAX_DELEGATED_INVITATION_HOST_TRIES;
2616
+ return invitation.type !== import_services6.Invitation.Type.DELEGATED || triedPeersIds.size >= MAX_DELEGATED_INVITATION_HOST_TRIES;
2498
2617
  };
2499
2618
  let admitted = false;
2500
2619
  const createExtension = () => {
@@ -2509,50 +2628,50 @@ var InvitationsHandler = class {
2509
2628
  return;
2510
2629
  }
2511
2630
  connectionCtx.onDispose(async () => {
2512
- (0, import_log4.log)("extension disposed", {
2631
+ (0, import_log5.log)("extension disposed", {
2513
2632
  admitted,
2514
2633
  currentState: guardedState.current.state
2515
2634
  }, {
2516
- F: __dxlog_file10,
2635
+ F: __dxlog_file11,
2517
2636
  L: 233,
2518
2637
  S: this,
2519
2638
  C: (f, a) => f(...a)
2520
2639
  });
2521
2640
  if (!admitted) {
2522
- guardedState.error(extension, new import_context4.ContextDisposedError());
2641
+ guardedState.error(extension, new import_context5.ContextDisposedError());
2523
2642
  if (shouldCancelInvitationFlow(extension)) {
2524
2643
  await ctx.dispose();
2525
2644
  }
2526
2645
  }
2527
2646
  });
2528
2647
  (0, import_async8.scheduleTask)(connectionCtx, async () => {
2529
- const traceId = import_keys5.PublicKey.random().toHex();
2648
+ const traceId = import_keys6.PublicKey.random().toHex();
2530
2649
  try {
2531
- import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
2650
+ import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
2532
2651
  id: traceId
2533
2652
  }), {
2534
- F: __dxlog_file10,
2653
+ F: __dxlog_file11,
2535
2654
  L: 245,
2536
2655
  S: this,
2537
2656
  C: (f, a) => f(...a)
2538
2657
  });
2539
2658
  (0, import_async8.scheduleTask)(connectionCtx, () => {
2540
- guardedState.set(extension, import_services5.Invitation.State.TIMEOUT);
2659
+ guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
2541
2660
  extensionCtx.close();
2542
2661
  }, timeout);
2543
- (0, import_log4.log)("connected", {
2662
+ (0, import_log5.log)("connected", {
2544
2663
  ...protocol.toJSON()
2545
2664
  }, {
2546
- F: __dxlog_file10,
2665
+ F: __dxlog_file11,
2547
2666
  L: 256,
2548
2667
  S: this,
2549
2668
  C: (f, a) => f(...a)
2550
2669
  });
2551
- guardedState.set(extension, import_services5.Invitation.State.CONNECTED);
2552
- (0, import_log4.log)("introduce", {
2670
+ guardedState.set(extension, import_services6.Invitation.State.CONNECTED);
2671
+ (0, import_log5.log)("introduce", {
2553
2672
  ...protocol.toJSON()
2554
2673
  }, {
2555
- F: __dxlog_file10,
2674
+ F: __dxlog_file11,
2556
2675
  L: 260,
2557
2676
  S: this,
2558
2677
  C: (f, a) => f(...a)
@@ -2561,11 +2680,11 @@ var InvitationsHandler = class {
2561
2680
  invitationId: invitation.invitationId,
2562
2681
  ...protocol.createIntroduction()
2563
2682
  });
2564
- (0, import_log4.log)("introduce response", {
2683
+ (0, import_log5.log)("introduce response", {
2565
2684
  ...protocol.toJSON(),
2566
2685
  response: introductionResponse
2567
2686
  }, {
2568
- F: __dxlog_file10,
2687
+ F: __dxlog_file11,
2569
2688
  L: 265,
2570
2689
  S: this,
2571
2690
  C: (f, a) => f(...a)
@@ -2573,20 +2692,20 @@ var InvitationsHandler = class {
2573
2692
  invitation.authMethod = introductionResponse.authMethod;
2574
2693
  if (isAuthenticationRequired(invitation)) {
2575
2694
  switch (invitation.authMethod) {
2576
- case import_services5.Invitation.AuthMethod.SHARED_SECRET:
2695
+ case import_services6.Invitation.AuthMethod.SHARED_SECRET:
2577
2696
  await this._handleGuestOtpAuth(extension, (state) => guardedState.set(extension, state), otpEnteredTrigger, {
2578
2697
  timeout
2579
2698
  });
2580
2699
  break;
2581
- case import_services5.Invitation.AuthMethod.KNOWN_PUBLIC_KEY:
2700
+ case import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY:
2582
2701
  await this._handleGuestKpkAuth(extension, (state) => guardedState.set(extension, state), invitation, introductionResponse);
2583
2702
  break;
2584
2703
  }
2585
2704
  }
2586
- (0, import_log4.log)("request admission", {
2705
+ (0, import_log5.log)("request admission", {
2587
2706
  ...protocol.toJSON()
2588
2707
  }, {
2589
- F: __dxlog_file10,
2708
+ F: __dxlog_file11,
2590
2709
  L: 291,
2591
2710
  S: this,
2592
2711
  C: (f, a) => f(...a)
@@ -2595,10 +2714,10 @@ var InvitationsHandler = class {
2595
2714
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
2596
2715
  admitted = true;
2597
2716
  const result = await protocol.accept(admissionResponse, admissionRequest);
2598
- (0, import_log4.log)("admitted by host", {
2717
+ (0, import_log5.log)("admitted by host", {
2599
2718
  ...protocol.toJSON()
2600
2719
  }, {
2601
- F: __dxlog_file10,
2720
+ F: __dxlog_file11,
2602
2721
  L: 302,
2603
2722
  S: this,
2604
2723
  C: (f, a) => f(...a)
@@ -2606,30 +2725,30 @@ var InvitationsHandler = class {
2606
2725
  await guardedState.complete({
2607
2726
  ...guardedState.current,
2608
2727
  ...result,
2609
- state: import_services5.Invitation.State.SUCCESS
2728
+ state: import_services6.Invitation.State.SUCCESS
2610
2729
  });
2611
- import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
2730
+ import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
2612
2731
  id: traceId
2613
2732
  }), {
2614
- F: __dxlog_file10,
2733
+ F: __dxlog_file11,
2615
2734
  L: 308,
2616
2735
  S: this,
2617
2736
  C: (f, a) => f(...a)
2618
2737
  });
2619
2738
  } catch (err) {
2620
2739
  if (err instanceof import_async8.TimeoutError) {
2621
- (0, import_log4.log)("timeout", {
2740
+ (0, import_log5.log)("timeout", {
2622
2741
  ...protocol.toJSON()
2623
2742
  }, {
2624
- F: __dxlog_file10,
2743
+ F: __dxlog_file11,
2625
2744
  L: 311,
2626
2745
  S: this,
2627
2746
  C: (f, a) => f(...a)
2628
2747
  });
2629
- guardedState.set(extension, import_services5.Invitation.State.TIMEOUT);
2748
+ guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
2630
2749
  } else {
2631
- (0, import_log4.log)("auth failed", err, {
2632
- F: __dxlog_file10,
2750
+ (0, import_log5.log)("auth failed", err, {
2751
+ F: __dxlog_file11,
2633
2752
  L: 314,
2634
2753
  S: this,
2635
2754
  C: (f, a) => f(...a)
@@ -2637,11 +2756,11 @@ var InvitationsHandler = class {
2637
2756
  guardedState.error(extension, err);
2638
2757
  }
2639
2758
  extensionCtx.close(err);
2640
- import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.error({
2759
+ import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.error({
2641
2760
  id: traceId,
2642
2761
  error: err
2643
2762
  }), {
2644
- F: __dxlog_file10,
2763
+ F: __dxlog_file11,
2645
2764
  L: 318,
2646
2765
  S: this,
2647
2766
  C: (f, a) => f(...a)
@@ -2654,18 +2773,18 @@ var InvitationsHandler = class {
2654
2773
  return;
2655
2774
  }
2656
2775
  if (err instanceof import_async8.TimeoutError) {
2657
- (0, import_log4.log)("timeout", {
2776
+ (0, import_log5.log)("timeout", {
2658
2777
  ...protocol.toJSON()
2659
2778
  }, {
2660
- F: __dxlog_file10,
2779
+ F: __dxlog_file11,
2661
2780
  L: 327,
2662
2781
  S: this,
2663
2782
  C: (f, a) => f(...a)
2664
2783
  });
2665
- guardedState.set(extension, import_services5.Invitation.State.TIMEOUT);
2784
+ guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
2666
2785
  } else {
2667
- (0, import_log4.log)("auth failed", err, {
2668
- F: __dxlog_file10,
2786
+ (0, import_log5.log)("auth failed", err, {
2787
+ F: __dxlog_file11,
2669
2788
  L: 330,
2670
2789
  S: this,
2671
2790
  C: (f, a) => f(...a)
@@ -2683,7 +2802,7 @@ var InvitationsHandler = class {
2683
2802
  await ctx.dispose();
2684
2803
  } else {
2685
2804
  (0, import_invariant6.invariant)(invitation.swarmKey, void 0, {
2686
- F: __dxlog_file10,
2805
+ F: __dxlog_file11,
2687
2806
  L: 345,
2688
2807
  S: this,
2689
2808
  A: [
@@ -2692,7 +2811,7 @@ var InvitationsHandler = class {
2692
2811
  ]
2693
2812
  });
2694
2813
  await this._joinSwarm(ctx, invitation, import_invitations2.Options.Role.GUEST, createExtension);
2695
- guardedState.set(null, import_services5.Invitation.State.CONNECTING);
2814
+ guardedState.set(null, import_services6.Invitation.State.CONNECTING);
2696
2815
  }
2697
2816
  });
2698
2817
  }
@@ -2700,14 +2819,14 @@ var InvitationsHandler = class {
2700
2819
  let label;
2701
2820
  if (role === import_invitations2.Options.Role.GUEST) {
2702
2821
  label = "invitation guest";
2703
- } else if (invitation.kind === import_services5.Invitation.Kind.DEVICE) {
2822
+ } else if (invitation.kind === import_services6.Invitation.Kind.DEVICE) {
2704
2823
  label = "invitation host for device";
2705
2824
  } else {
2706
2825
  label = `invitation host for space ${invitation.spaceKey?.truncate()}`;
2707
2826
  }
2708
2827
  const swarmConnection = await this._networkManager.joinSwarm({
2709
2828
  topic: invitation.swarmKey,
2710
- peerId: import_keys5.PublicKey.random(),
2829
+ peerId: import_keys6.PublicKey.random(),
2711
2830
  protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
2712
2831
  teleport.addExtension("dxos.halo.invitations", extensionFactory());
2713
2832
  }, this._defaultTeleportParams),
@@ -2762,10 +2881,10 @@ var InvitationsHandler = class {
2762
2881
  },
2763
2882
  error: (extension, error) => {
2764
2883
  if (isStateChangeAllowed(extension)) {
2765
- this._logStateUpdate(currentInvitation, extension, import_services5.Invitation.State.ERROR);
2884
+ this._logStateUpdate(currentInvitation, extension, import_services6.Invitation.State.ERROR);
2766
2885
  currentInvitation = {
2767
2886
  ...currentInvitation,
2768
- state: import_services5.Invitation.State.ERROR
2887
+ state: import_services6.Invitation.State.ERROR
2769
2888
  };
2770
2889
  stream.next(currentInvitation);
2771
2890
  stream.error(error);
@@ -2777,12 +2896,12 @@ var InvitationsHandler = class {
2777
2896
  };
2778
2897
  }
2779
2898
  _logStateUpdate(invitation, actor, newState) {
2780
- (0, import_log4.log)("invitation state update", {
2899
+ (0, import_log5.log)("invitation state update", {
2781
2900
  actor: actor?.constructor.name,
2782
2901
  newState: stateToString(newState),
2783
2902
  oldState: stateToString(invitation.state)
2784
2903
  }, {
2785
- F: __dxlog_file10,
2904
+ F: __dxlog_file11,
2786
2905
  L: 438,
2787
2906
  S: this,
2788
2907
  C: (f, a) => f(...a)
@@ -2790,30 +2909,30 @@ var InvitationsHandler = class {
2790
2909
  }
2791
2910
  _isNotTerminal(currentState) {
2792
2911
  return ![
2793
- import_services5.Invitation.State.SUCCESS,
2794
- import_services5.Invitation.State.ERROR,
2795
- import_services5.Invitation.State.CANCELLED,
2796
- import_services5.Invitation.State.TIMEOUT,
2797
- import_services5.Invitation.State.EXPIRED
2912
+ import_services6.Invitation.State.SUCCESS,
2913
+ import_services6.Invitation.State.ERROR,
2914
+ import_services6.Invitation.State.CANCELLED,
2915
+ import_services6.Invitation.State.TIMEOUT,
2916
+ import_services6.Invitation.State.EXPIRED
2798
2917
  ].includes(currentState);
2799
2918
  }
2800
2919
  async _handleGuestOtpAuth(extension, setState, authenticated, options) {
2801
2920
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2802
- (0, import_log4.log)("guest waiting for authentication code...", void 0, {
2803
- F: __dxlog_file10,
2921
+ (0, import_log5.log)("guest waiting for authentication code...", void 0, {
2922
+ F: __dxlog_file11,
2804
2923
  L: 462,
2805
2924
  S: this,
2806
2925
  C: (f, a) => f(...a)
2807
2926
  });
2808
- setState(import_services5.Invitation.State.READY_FOR_AUTHENTICATION);
2927
+ setState(import_services6.Invitation.State.READY_FOR_AUTHENTICATION);
2809
2928
  const authCode = await authenticated.wait(options);
2810
- (0, import_log4.log)("sending authentication request", void 0, {
2811
- F: __dxlog_file10,
2929
+ (0, import_log5.log)("sending authentication request", void 0, {
2930
+ F: __dxlog_file11,
2812
2931
  L: 466,
2813
2932
  S: this,
2814
2933
  C: (f, a) => f(...a)
2815
2934
  });
2816
- setState(import_services5.Invitation.State.AUTHENTICATING);
2935
+ setState(import_services6.Invitation.State.AUTHENTICATING);
2817
2936
  const response = await extension.rpc.InvitationHostService.authenticate({
2818
2937
  authCode
2819
2938
  });
@@ -2824,10 +2943,10 @@ var InvitationsHandler = class {
2824
2943
  if (attempt === MAX_OTP_ATTEMPTS) {
2825
2944
  throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
2826
2945
  } else {
2827
- (0, import_log4.log)("retrying invalid code", {
2946
+ (0, import_log5.log)("retrying invalid code", {
2828
2947
  attempt
2829
2948
  }, {
2830
- F: __dxlog_file10,
2949
+ F: __dxlog_file11,
2831
2950
  L: 477,
2832
2951
  S: this,
2833
2952
  C: (f, a) => f(...a)
@@ -2844,13 +2963,13 @@ var InvitationsHandler = class {
2844
2963
  if (introductionResponse.challenge == null) {
2845
2964
  throw new Error("challenge missing in the introduction");
2846
2965
  }
2847
- (0, import_log4.log)("sending authentication request", void 0, {
2848
- F: __dxlog_file10,
2966
+ (0, import_log5.log)("sending authentication request", void 0, {
2967
+ F: __dxlog_file11,
2849
2968
  L: 496,
2850
2969
  S: this,
2851
2970
  C: (f, a) => f(...a)
2852
2971
  });
2853
- setState(import_services5.Invitation.State.AUTHENTICATING);
2972
+ setState(import_services6.Invitation.State.AUTHENTICATING);
2854
2973
  const signature = (0, import_crypto.sign)(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
2855
2974
  const response = await extension.rpc.InvitationHostService.authenticate({
2856
2975
  signedChallenge: signature
@@ -2863,7 +2982,7 @@ var InvitationsHandler = class {
2863
2982
  var createAdmissionKeypair = () => {
2864
2983
  const keypair = (0, import_crypto.createKeyPair)();
2865
2984
  return {
2866
- publicKey: import_keys5.PublicKey.from(keypair.publicKey),
2985
+ publicKey: import_keys6.PublicKey.from(keypair.publicKey),
2867
2986
  privateKey: keypair.secretKey
2868
2987
  };
2869
2988
  };
@@ -2896,8 +3015,8 @@ var InvitationsServiceImpl = class {
2896
3015
  return new import_codec_protobuf10.Stream(({ next, ctx }) => {
2897
3016
  this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
2898
3017
  next({
2899
- action: import_services8.QueryInvitationsResponse.Action.ADDED,
2900
- type: import_services8.QueryInvitationsResponse.Type.CREATED,
3018
+ action: import_services9.QueryInvitationsResponse.Action.ADDED,
3019
+ type: import_services9.QueryInvitationsResponse.Type.CREATED,
2901
3020
  invitations: [
2902
3021
  invitation
2903
3022
  ]
@@ -2905,8 +3024,8 @@ var InvitationsServiceImpl = class {
2905
3024
  });
2906
3025
  this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
2907
3026
  next({
2908
- action: import_services8.QueryInvitationsResponse.Action.ADDED,
2909
- type: import_services8.QueryInvitationsResponse.Type.ACCEPTED,
3027
+ action: import_services9.QueryInvitationsResponse.Action.ADDED,
3028
+ type: import_services9.QueryInvitationsResponse.Type.ACCEPTED,
2910
3029
  invitations: [
2911
3030
  invitation
2912
3031
  ]
@@ -2914,8 +3033,8 @@ var InvitationsServiceImpl = class {
2914
3033
  });
2915
3034
  this._invitationsManager.removedCreated.on(ctx, (invitation) => {
2916
3035
  next({
2917
- action: import_services8.QueryInvitationsResponse.Action.REMOVED,
2918
- type: import_services8.QueryInvitationsResponse.Type.CREATED,
3036
+ action: import_services9.QueryInvitationsResponse.Action.REMOVED,
3037
+ type: import_services9.QueryInvitationsResponse.Type.CREATED,
2919
3038
  invitations: [
2920
3039
  invitation
2921
3040
  ]
@@ -2923,8 +3042,8 @@ var InvitationsServiceImpl = class {
2923
3042
  });
2924
3043
  this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
2925
3044
  next({
2926
- action: import_services8.QueryInvitationsResponse.Action.REMOVED,
2927
- type: import_services8.QueryInvitationsResponse.Type.ACCEPTED,
3045
+ action: import_services9.QueryInvitationsResponse.Action.REMOVED,
3046
+ type: import_services9.QueryInvitationsResponse.Type.ACCEPTED,
2928
3047
  invitations: [
2929
3048
  invitation
2930
3049
  ]
@@ -2932,35 +3051,35 @@ var InvitationsServiceImpl = class {
2932
3051
  });
2933
3052
  this._invitationsManager.saved.on(ctx, (invitation) => {
2934
3053
  next({
2935
- action: import_services8.QueryInvitationsResponse.Action.SAVED,
2936
- type: import_services8.QueryInvitationsResponse.Type.CREATED,
3054
+ action: import_services9.QueryInvitationsResponse.Action.SAVED,
3055
+ type: import_services9.QueryInvitationsResponse.Type.CREATED,
2937
3056
  invitations: [
2938
3057
  invitation
2939
3058
  ]
2940
3059
  });
2941
3060
  });
2942
3061
  next({
2943
- action: import_services8.QueryInvitationsResponse.Action.ADDED,
2944
- type: import_services8.QueryInvitationsResponse.Type.CREATED,
3062
+ action: import_services9.QueryInvitationsResponse.Action.ADDED,
3063
+ type: import_services9.QueryInvitationsResponse.Type.CREATED,
2945
3064
  invitations: this._invitationsManager.getCreatedInvitations(),
2946
3065
  existing: true
2947
3066
  });
2948
3067
  next({
2949
- action: import_services8.QueryInvitationsResponse.Action.ADDED,
2950
- type: import_services8.QueryInvitationsResponse.Type.ACCEPTED,
3068
+ action: import_services9.QueryInvitationsResponse.Action.ADDED,
3069
+ type: import_services9.QueryInvitationsResponse.Type.ACCEPTED,
2951
3070
  invitations: this._invitationsManager.getAcceptedInvitations(),
2952
3071
  existing: true
2953
3072
  });
2954
3073
  this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
2955
3074
  next({
2956
- action: import_services8.QueryInvitationsResponse.Action.LOAD_COMPLETE,
2957
- type: import_services8.QueryInvitationsResponse.Type.CREATED
3075
+ action: import_services9.QueryInvitationsResponse.Action.LOAD_COMPLETE,
3076
+ type: import_services9.QueryInvitationsResponse.Type.CREATED
2958
3077
  });
2959
3078
  });
2960
3079
  });
2961
3080
  }
2962
3081
  };
2963
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
3082
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2964
3083
  var SpaceInvitationProtocol = class {
2965
3084
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
2966
3085
  this._spaceManager = _spaceManager;
@@ -2989,13 +3108,13 @@ var SpaceInvitationProtocol = class {
2989
3108
  }
2990
3109
  getInvitationContext() {
2991
3110
  return {
2992
- kind: import_services9.Invitation.Kind.SPACE,
3111
+ kind: import_services10.Invitation.Kind.SPACE,
2993
3112
  spaceKey: this._spaceKey
2994
3113
  };
2995
3114
  }
2996
3115
  async admit(invitation, request, guestProfile) {
2997
3116
  (0, import_invariant10.invariant)(this._spaceKey, void 0, {
2998
- F: __dxlog_file11,
3117
+ F: __dxlog_file12,
2999
3118
  L: 76,
3000
3119
  S: this,
3001
3120
  A: [
@@ -3005,7 +3124,7 @@ var SpaceInvitationProtocol = class {
3005
3124
  });
3006
3125
  const space = this._spaceManager.spaces.get(this._spaceKey);
3007
3126
  (0, import_invariant10.invariant)(space, void 0, {
3008
- F: __dxlog_file11,
3127
+ F: __dxlog_file12,
3009
3128
  L: 78,
3010
3129
  S: this,
3011
3130
  A: [
@@ -3014,7 +3133,7 @@ var SpaceInvitationProtocol = class {
3014
3133
  ]
3015
3134
  });
3016
3135
  (0, import_invariant10.invariant)(request.space, void 0, {
3017
- F: __dxlog_file11,
3136
+ F: __dxlog_file12,
3018
3137
  L: 80,
3019
3138
  S: this,
3020
3139
  A: [
@@ -3023,21 +3142,21 @@ var SpaceInvitationProtocol = class {
3023
3142
  ]
3024
3143
  });
3025
3144
  const { identityKey, deviceKey } = request.space;
3026
- if (space.inner.spaceState.getMemberRole(identityKey) !== import_credentials9.SpaceMember.Role.REMOVED) {
3145
+ if (space.inner.spaceState.getMemberRole(identityKey) !== import_credentials10.SpaceMember.Role.REMOVED) {
3027
3146
  throw new import_protocols8.AlreadyJoinedError();
3028
3147
  }
3029
- (0, import_log8.log)("writing guest credentials", {
3148
+ (0, import_log9.log)("writing guest credentials", {
3030
3149
  host: this._signingContext.deviceKey,
3031
3150
  guest: deviceKey
3032
3151
  }, {
3033
- F: __dxlog_file11,
3152
+ F: __dxlog_file12,
3034
3153
  L: 87,
3035
3154
  S: this,
3036
3155
  C: (f, a) => f(...a)
3037
3156
  });
3038
- const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, invitation.role ?? import_credentials9.SpaceMember.Role.ADMIN, space.inner.spaceState.membershipChainHeads, guestProfile, invitation.delegationCredentialId);
3157
+ 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);
3039
3158
  (0, import_invariant10.invariant)(credentials[0].credential, void 0, {
3040
- F: __dxlog_file11,
3159
+ F: __dxlog_file12,
3041
3160
  L: 101,
3042
3161
  S: this,
3043
3162
  A: [
@@ -3046,8 +3165,8 @@ var SpaceInvitationProtocol = class {
3046
3165
  ]
3047
3166
  });
3048
3167
  const spaceMemberCredential = credentials[0].credential.credential;
3049
- (0, import_invariant10.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3050
- F: __dxlog_file11,
3168
+ (0, import_invariant10.invariant)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3169
+ F: __dxlog_file12,
3051
3170
  L: 103,
3052
3171
  S: this,
3053
3172
  A: [
@@ -3065,7 +3184,7 @@ var SpaceInvitationProtocol = class {
3065
3184
  }
3066
3185
  async delegate(invitation) {
3067
3186
  (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3068
- F: __dxlog_file11,
3187
+ F: __dxlog_file12,
3069
3188
  L: 116,
3070
3189
  S: this,
3071
3190
  A: [
@@ -3075,7 +3194,7 @@ var SpaceInvitationProtocol = class {
3075
3194
  });
3076
3195
  const space = this._spaceManager.spaces.get(this._spaceKey);
3077
3196
  (0, import_invariant10.invariant)(space, void 0, {
3078
- F: __dxlog_file11,
3197
+ F: __dxlog_file12,
3079
3198
  L: 118,
3080
3199
  S: this,
3081
3200
  A: [
@@ -3083,9 +3202,9 @@ var SpaceInvitationProtocol = class {
3083
3202
  ""
3084
3203
  ]
3085
3204
  });
3086
- if (invitation.authMethod === import_services9.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
3205
+ if (invitation.authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
3087
3206
  (0, import_invariant10.invariant)(invitation.guestKeypair?.publicKey, void 0, {
3088
- F: __dxlog_file11,
3207
+ F: __dxlog_file12,
3089
3208
  L: 120,
3090
3209
  S: this,
3091
3210
  A: [
@@ -3094,26 +3213,26 @@ var SpaceInvitationProtocol = class {
3094
3213
  ]
3095
3214
  });
3096
3215
  }
3097
- (0, import_log8.log)("writing delegate space invitation", {
3216
+ (0, import_log9.log)("writing delegate space invitation", {
3098
3217
  host: this._signingContext.deviceKey,
3099
3218
  id: invitation.invitationId
3100
3219
  }, {
3101
- F: __dxlog_file11,
3220
+ F: __dxlog_file12,
3102
3221
  L: 123,
3103
3222
  S: this,
3104
3223
  C: (f, a) => f(...a)
3105
3224
  });
3106
- const credential = await (0, import_credentials8.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
3225
+ const credential = await (0, import_credentials9.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
3107
3226
  invitationId: invitation.invitationId,
3108
3227
  authMethod: invitation.authMethod,
3109
3228
  swarmKey: invitation.swarmKey,
3110
- role: invitation.role ?? import_credentials9.SpaceMember.Role.ADMIN,
3229
+ role: invitation.role ?? import_credentials10.SpaceMember.Role.ADMIN,
3111
3230
  expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
3112
3231
  multiUse: invitation.multiUse ?? false,
3113
- guestKey: invitation.authMethod === import_services9.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
3232
+ guestKey: invitation.authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
3114
3233
  });
3115
3234
  (0, import_invariant10.invariant)(credential.credential, void 0, {
3116
- F: __dxlog_file11,
3235
+ F: __dxlog_file12,
3117
3236
  L: 143,
3118
3237
  S: this,
3119
3238
  A: [
@@ -3128,7 +3247,7 @@ var SpaceInvitationProtocol = class {
3128
3247
  }
3129
3248
  async cancelDelegation(invitation) {
3130
3249
  (0, import_invariant10.invariant)(this._spaceKey, void 0, {
3131
- F: __dxlog_file11,
3250
+ F: __dxlog_file12,
3132
3251
  L: 149,
3133
3252
  S: this,
3134
3253
  A: [
@@ -3136,8 +3255,8 @@ var SpaceInvitationProtocol = class {
3136
3255
  ""
3137
3256
  ]
3138
3257
  });
3139
- (0, import_invariant10.invariant)(invitation.type === import_services9.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
3140
- F: __dxlog_file11,
3258
+ (0, import_invariant10.invariant)(invitation.type === import_services10.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
3259
+ F: __dxlog_file12,
3141
3260
  L: 150,
3142
3261
  S: this,
3143
3262
  A: [
@@ -3147,7 +3266,7 @@ var SpaceInvitationProtocol = class {
3147
3266
  });
3148
3267
  const space = this._spaceManager.spaces.get(this._spaceKey);
3149
3268
  (0, import_invariant10.invariant)(space, void 0, {
3150
- F: __dxlog_file11,
3269
+ F: __dxlog_file12,
3151
3270
  L: 152,
3152
3271
  S: this,
3153
3272
  A: [
@@ -3155,18 +3274,18 @@ var SpaceInvitationProtocol = class {
3155
3274
  ""
3156
3275
  ]
3157
3276
  });
3158
- (0, import_log8.log)("cancelling delegated space invitation", {
3277
+ (0, import_log9.log)("cancelling delegated space invitation", {
3159
3278
  host: this._signingContext.deviceKey,
3160
3279
  id: invitation.invitationId
3161
3280
  }, {
3162
- F: __dxlog_file11,
3281
+ F: __dxlog_file12,
3163
3282
  L: 154,
3164
3283
  S: this,
3165
3284
  C: (f, a) => f(...a)
3166
3285
  });
3167
- const credential = await (0, import_credentials8.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
3286
+ const credential = await (0, import_credentials9.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
3168
3287
  (0, import_invariant10.invariant)(credential.credential, void 0, {
3169
- F: __dxlog_file11,
3288
+ F: __dxlog_file12,
3170
3289
  L: 161,
3171
3290
  S: this,
3172
3291
  A: [
@@ -3205,7 +3324,7 @@ var SpaceInvitationProtocol = class {
3205
3324
  }
3206
3325
  async accept(response) {
3207
3326
  (0, import_invariant10.invariant)(response.space, void 0, {
3208
- F: __dxlog_file11,
3327
+ F: __dxlog_file12,
3209
3328
  L: 196,
3210
3329
  S: this,
3211
3330
  A: [
@@ -3214,9 +3333,9 @@ var SpaceInvitationProtocol = class {
3214
3333
  ]
3215
3334
  });
3216
3335
  const { credential, controlTimeframe, dataTimeframe } = response.space;
3217
- const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
3336
+ const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
3218
3337
  (0, import_invariant10.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3219
- F: __dxlog_file11,
3338
+ F: __dxlog_file12,
3220
3339
  L: 199,
3221
3340
  S: this,
3222
3341
  A: [
@@ -3225,7 +3344,7 @@ var SpaceInvitationProtocol = class {
3225
3344
  ]
3226
3345
  });
3227
3346
  (0, import_invariant10.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
3228
- F: __dxlog_file11,
3347
+ F: __dxlog_file12,
3229
3348
  L: 200,
3230
3349
  S: this,
3231
3350
  A: [
@@ -3248,7 +3367,7 @@ var SpaceInvitationProtocol = class {
3248
3367
  };
3249
3368
  }
3250
3369
  };
3251
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3370
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3252
3371
  var InvitationsManager = class {
3253
3372
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
3254
3373
  this._invitationsHandler = _invitationsHandler;
@@ -3290,8 +3409,8 @@ var InvitationsManager = class {
3290
3409
  try {
3291
3410
  await this._persistIfRequired(handler, stream, invitation);
3292
3411
  } catch (err) {
3293
- import_log9.log.catch(err, void 0, {
3294
- F: __dxlog_file12,
3412
+ import_log10.log.catch(err, void 0, {
3413
+ F: __dxlog_file13,
3295
3414
  L: 82,
3296
3415
  S: this,
3297
3416
  C: (f, a) => f(...a)
@@ -3314,7 +3433,7 @@ var InvitationsManager = class {
3314
3433
  const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
3315
3434
  const loadTasks = freshInvitations.map((persistentInvitation) => {
3316
3435
  (0, import_invariant11.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
3317
- F: __dxlog_file12,
3436
+ F: __dxlog_file13,
3318
3437
  L: 103,
3319
3438
  S: this,
3320
3439
  A: [
@@ -3332,8 +3451,8 @@ var InvitationsManager = class {
3332
3451
  invitations: cInvitations.map((invitation) => invitation.get())
3333
3452
  };
3334
3453
  } catch (err) {
3335
- import_log9.log.catch(err, void 0, {
3336
- F: __dxlog_file12,
3454
+ import_log10.log.catch(err, void 0, {
3455
+ F: __dxlog_file13,
3337
3456
  L: 110,
3338
3457
  S: this,
3339
3458
  C: (f, a) => f(...a)
@@ -3364,14 +3483,14 @@ var InvitationsManager = class {
3364
3483
  return invitation;
3365
3484
  }
3366
3485
  async authenticate({ invitationId, authCode }) {
3367
- (0, import_log9.log)("authenticating...", void 0, {
3368
- F: __dxlog_file12,
3486
+ (0, import_log10.log)("authenticating...", void 0, {
3487
+ F: __dxlog_file13,
3369
3488
  L: 140,
3370
3489
  S: this,
3371
3490
  C: (f, a) => f(...a)
3372
3491
  });
3373
3492
  (0, import_invariant11.invariant)(invitationId, void 0, {
3374
- F: __dxlog_file12,
3493
+ F: __dxlog_file13,
3375
3494
  L: 141,
3376
3495
  S: this,
3377
3496
  A: [
@@ -3381,10 +3500,10 @@ var InvitationsManager = class {
3381
3500
  });
3382
3501
  const observable = this._acceptInvitations.get(invitationId);
3383
3502
  if (!observable) {
3384
- import_log9.log.warn("invalid invitation", {
3503
+ import_log10.log.warn("invalid invitation", {
3385
3504
  invitationId
3386
3505
  }, {
3387
- F: __dxlog_file12,
3506
+ F: __dxlog_file13,
3388
3507
  L: 144,
3389
3508
  S: this,
3390
3509
  C: (f, a) => f(...a)
@@ -3394,16 +3513,16 @@ var InvitationsManager = class {
3394
3513
  }
3395
3514
  }
3396
3515
  async cancelInvitation({ invitationId }) {
3397
- (0, import_log9.log)("cancelInvitation...", {
3516
+ (0, import_log10.log)("cancelInvitation...", {
3398
3517
  invitationId
3399
3518
  }, {
3400
- F: __dxlog_file12,
3519
+ F: __dxlog_file13,
3401
3520
  L: 151,
3402
3521
  S: this,
3403
3522
  C: (f, a) => f(...a)
3404
3523
  });
3405
3524
  (0, import_invariant11.invariant)(invitationId, void 0, {
3406
- F: __dxlog_file12,
3525
+ F: __dxlog_file13,
3407
3526
  L: 152,
3408
3527
  S: this,
3409
3528
  A: [
@@ -3416,7 +3535,7 @@ var InvitationsManager = class {
3416
3535
  if (created.get().persistent) {
3417
3536
  await this._metadataStore.removeInvitation(invitationId);
3418
3537
  }
3419
- if (created.get().type === import_services10.Invitation.Type.DELEGATED) {
3538
+ if (created.get().type === import_services11.Invitation.Type.DELEGATED) {
3420
3539
  const handler = this._getHandler(created.get());
3421
3540
  await handler.cancelDelegation(created.get());
3422
3541
  }
@@ -3450,8 +3569,8 @@ var InvitationsManager = class {
3450
3569
  }
3451
3570
  }
3452
3571
  _createInvitation(protocol, options) {
3453
- const { invitationId = import_keys8.PublicKey.random().toHex(), type = import_services10.Invitation.Type.INTERACTIVE, authMethod = import_services10.Invitation.AuthMethod.SHARED_SECRET, state = import_services10.Invitation.State.INIT, timeout = import_client_protocol3.INVITATION_TIMEOUT, swarmKey = import_keys8.PublicKey.random(), persistent = options?.authMethod !== import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials11.SpaceMember.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
3454
- const authCode = options?.authCode ?? (authMethod === import_services10.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials10.generatePasscode)(import_client_protocol3.AUTHENTICATION_CODE_LENGTH) : void 0);
3572
+ const { invitationId = import_keys9.PublicKey.random().toHex(), type = import_services11.Invitation.Type.INTERACTIVE, authMethod = import_services11.Invitation.AuthMethod.SHARED_SECRET, state = import_services11.Invitation.State.INIT, timeout = import_client_protocol3.INVITATION_TIMEOUT, swarmKey = import_keys9.PublicKey.random(), persistent = options?.authMethod !== import_services11.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials12.SpaceMember.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
3573
+ const authCode = options?.authCode ?? (authMethod === import_services11.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials11.generatePasscode)(import_client_protocol3.AUTHENTICATION_CODE_LENGTH) : void 0);
3455
3574
  return {
3456
3575
  invitationId,
3457
3576
  type,
@@ -3460,8 +3579,8 @@ var InvitationsManager = class {
3460
3579
  swarmKey,
3461
3580
  authCode,
3462
3581
  timeout,
3463
- persistent: persistent && type !== import_services10.Invitation.Type.DELEGATED,
3464
- guestKeypair: guestKeypair ?? (authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
3582
+ persistent: persistent && type !== import_services11.Invitation.Type.DELEGATED,
3583
+ guestKeypair: guestKeypair ?? (authMethod === import_services11.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
3465
3584
  created,
3466
3585
  lifetime,
3467
3586
  role,
@@ -3472,17 +3591,17 @@ var InvitationsManager = class {
3472
3591
  }
3473
3592
  _createObservableInvitation(handler, invitation) {
3474
3593
  const stream = new import_async11.PushStream();
3475
- const ctx = new import_context8.Context({
3594
+ const ctx = new import_context9.Context({
3476
3595
  onError: (err) => {
3477
3596
  stream.error(err);
3478
3597
  void ctx.dispose();
3479
3598
  }
3480
3599
  });
3481
3600
  ctx.onDispose(() => {
3482
- (0, import_log9.log)("complete", {
3601
+ (0, import_log10.log)("complete", {
3483
3602
  ...handler.toJSON()
3484
3603
  }, {
3485
- F: __dxlog_file12,
3604
+ F: __dxlog_file13,
3486
3605
  L: 241,
3487
3606
  S: this,
3488
3607
  C: (f, a) => f(...a)
@@ -3495,7 +3614,7 @@ var InvitationsManager = class {
3495
3614
  onCancel: async () => {
3496
3615
  stream.next({
3497
3616
  ...invitation,
3498
- state: import_services10.Invitation.State.CANCELLED
3617
+ state: import_services11.Invitation.State.CANCELLED
3499
3618
  });
3500
3619
  await ctx.dispose();
3501
3620
  }
@@ -3509,41 +3628,41 @@ var InvitationsManager = class {
3509
3628
  _createObservableAcceptingInvitation(handler, initialState) {
3510
3629
  const otpEnteredTrigger = new import_async11.Trigger();
3511
3630
  const stream = new import_async11.PushStream();
3512
- const ctx = new import_context8.Context({
3631
+ const ctx = new import_context9.Context({
3513
3632
  onError: (err) => {
3514
3633
  if (err instanceof import_async11.TimeoutError) {
3515
- (0, import_log9.log)("timeout", {
3634
+ (0, import_log10.log)("timeout", {
3516
3635
  ...handler.toJSON()
3517
3636
  }, {
3518
- F: __dxlog_file12,
3637
+ F: __dxlog_file13,
3519
3638
  L: 261,
3520
3639
  S: this,
3521
3640
  C: (f, a) => f(...a)
3522
3641
  });
3523
3642
  stream.next({
3524
3643
  ...initialState,
3525
- state: import_services10.Invitation.State.TIMEOUT
3644
+ state: import_services11.Invitation.State.TIMEOUT
3526
3645
  });
3527
3646
  } else {
3528
- import_log9.log.warn("auth failed", err, {
3529
- F: __dxlog_file12,
3647
+ import_log10.log.warn("auth failed", err, {
3648
+ F: __dxlog_file13,
3530
3649
  L: 264,
3531
3650
  S: this,
3532
3651
  C: (f, a) => f(...a)
3533
3652
  });
3534
3653
  stream.next({
3535
3654
  ...initialState,
3536
- state: import_services10.Invitation.State.ERROR
3655
+ state: import_services11.Invitation.State.ERROR
3537
3656
  });
3538
3657
  }
3539
3658
  void ctx.dispose();
3540
3659
  }
3541
3660
  });
3542
3661
  ctx.onDispose(() => {
3543
- (0, import_log9.log)("complete", {
3662
+ (0, import_log10.log)("complete", {
3544
3663
  ...handler.toJSON()
3545
3664
  }, {
3546
- F: __dxlog_file12,
3665
+ F: __dxlog_file13,
3547
3666
  L: 271,
3548
3667
  S: this,
3549
3668
  C: (f, a) => f(...a)
@@ -3556,7 +3675,7 @@ var InvitationsManager = class {
3556
3675
  onCancel: async () => {
3557
3676
  stream.next({
3558
3677
  ...initialState,
3559
- state: import_services10.Invitation.State.CANCELLED
3678
+ state: import_services11.Invitation.State.CANCELLED
3560
3679
  });
3561
3680
  await ctx.dispose();
3562
3681
  },
@@ -3572,7 +3691,7 @@ var InvitationsManager = class {
3572
3691
  };
3573
3692
  }
3574
3693
  async _persistIfRequired(handler, changeStream, invitation) {
3575
- if (invitation.type === import_services10.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
3694
+ if (invitation.type === import_services11.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
3576
3695
  const delegationCredentialId = await handler.delegate(invitation);
3577
3696
  changeStream.next({
3578
3697
  ...invitation,
@@ -3587,8 +3706,8 @@ var InvitationsManager = class {
3587
3706
  try {
3588
3707
  await this._metadataStore.removeInvitation(invitation.invitationId);
3589
3708
  } catch (err) {
3590
- import_log9.log.catch(err, void 0, {
3591
- F: __dxlog_file12,
3709
+ import_log10.log.catch(err, void 0, {
3710
+ F: __dxlog_file13,
3592
3711
  L: 307,
3593
3712
  S: this,
3594
3713
  C: (f, a) => f(...a)
@@ -3610,7 +3729,7 @@ var AutomergeSpaceState = class {
3610
3729
  this._isProcessingRootDocs = false;
3611
3730
  }
3612
3731
  async processCredential(credential) {
3613
- if (!(0, import_credentials13.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
3732
+ if (!(0, import_credentials14.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
3614
3733
  return;
3615
3734
  }
3616
3735
  this.lastEpoch = credential;
@@ -3635,18 +3754,18 @@ var AutomergeSpaceState = class {
3635
3754
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3636
3755
  }
3637
3756
  };
3638
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3757
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3639
3758
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3640
3759
  var DEFAULT_SUCCESS_DELAY = 1e3;
3641
3760
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
3642
3761
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
3643
3762
  var NotarizationPlugin = class {
3644
3763
  constructor() {
3645
- this._ctx = new import_context10.Context();
3764
+ this._ctx = new import_context11.Context();
3646
3765
  this._extensionOpened = new import_async14.Event();
3647
3766
  this._extensions = /* @__PURE__ */ new Set();
3648
- this._processedCredentials = new import_util7.ComplexSet(import_keys10.PublicKey.hash);
3649
- this._processCredentialsTriggers = new import_util7.ComplexMap(import_keys10.PublicKey.hash);
3767
+ this._processedCredentials = new import_util7.ComplexSet(import_keys11.PublicKey.hash);
3768
+ this._processCredentialsTriggers = new import_util7.ComplexMap(import_keys11.PublicKey.hash);
3650
3769
  }
3651
3770
  get hasWriter() {
3652
3771
  return !!this._writer;
@@ -3660,16 +3779,16 @@ var NotarizationPlugin = class {
3660
3779
  * Request credentials to be notarized.
3661
3780
  */
3662
3781
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
3663
- (0, import_log11.log)("notarize", {
3782
+ (0, import_log12.log)("notarize", {
3664
3783
  credentials
3665
3784
  }, {
3666
- F: __dxlog_file13,
3785
+ F: __dxlog_file14,
3667
3786
  L: 90,
3668
3787
  S: this,
3669
3788
  C: (f, a) => f(...a)
3670
3789
  });
3671
3790
  (0, import_invariant13.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
3672
- F: __dxlog_file13,
3791
+ F: __dxlog_file14,
3673
3792
  L: 91,
3674
3793
  S: this,
3675
3794
  A: [
@@ -3680,10 +3799,10 @@ var NotarizationPlugin = class {
3680
3799
  const errors = new import_async14.Trigger();
3681
3800
  const ctx = this._ctx.derive({
3682
3801
  onError: (err) => {
3683
- import_log11.log.warn("Notarization error", {
3802
+ import_log12.log.warn("Notarization error", {
3684
3803
  err
3685
3804
  }, {
3686
- F: __dxlog_file13,
3805
+ F: __dxlog_file14,
3687
3806
  L: 99,
3688
3807
  S: this,
3689
3808
  C: (f, a) => f(...a)
@@ -3695,11 +3814,11 @@ var NotarizationPlugin = class {
3695
3814
  opCtx?.onDispose(() => ctx.dispose());
3696
3815
  if (timeout !== 0) {
3697
3816
  (0, import_async14.scheduleTask)(ctx, () => {
3698
- import_log11.log.warn("Notarization timeout", {
3817
+ import_log12.log.warn("Notarization timeout", {
3699
3818
  timeout,
3700
3819
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
3701
3820
  }, {
3702
- F: __dxlog_file13,
3821
+ F: __dxlog_file14,
3703
3822
  L: 111,
3704
3823
  S: this,
3705
3824
  C: (f, a) => f(...a)
@@ -3719,10 +3838,10 @@ var NotarizationPlugin = class {
3719
3838
  ...this._extensions
3720
3839
  ].find((peer2) => !peersTried.has(peer2));
3721
3840
  if (!peer) {
3722
- import_log11.log.info("Exhausted all peers to notarize with", {
3841
+ import_log12.log.info("Exhausted all peers to notarize with", {
3723
3842
  retryIn: retryTimeout
3724
3843
  }, {
3725
- F: __dxlog_file13,
3844
+ F: __dxlog_file14,
3726
3845
  L: 136,
3727
3846
  S: this,
3728
3847
  C: (f, a) => f(...a)
@@ -3732,11 +3851,11 @@ var NotarizationPlugin = class {
3732
3851
  return;
3733
3852
  }
3734
3853
  peersTried.add(peer);
3735
- (0, import_log11.log)("try notarizing", {
3854
+ (0, import_log12.log)("try notarizing", {
3736
3855
  peer: peer.localPeerId,
3737
3856
  credentialId: credentials.map((credential) => credential.id)
3738
3857
  }, {
3739
- F: __dxlog_file13,
3858
+ F: __dxlog_file14,
3740
3859
  L: 143,
3741
3860
  S: this,
3742
3861
  C: (f, a) => f(...a)
@@ -3744,8 +3863,8 @@ var NotarizationPlugin = class {
3744
3863
  await peer.rpc.NotarizationService.notarize({
3745
3864
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
3746
3865
  });
3747
- (0, import_log11.log)("success", void 0, {
3748
- F: __dxlog_file13,
3866
+ (0, import_log12.log)("success", void 0, {
3867
+ F: __dxlog_file14,
3749
3868
  L: 147,
3750
3869
  S: this,
3751
3870
  C: (f, a) => f(...a)
@@ -3753,8 +3872,8 @@ var NotarizationPlugin = class {
3753
3872
  await (0, import_async14.sleep)(successDelay);
3754
3873
  } catch (err) {
3755
3874
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
3756
- import_log11.log.info("error notarizing (recoverable)", err, {
3757
- F: __dxlog_file13,
3875
+ import_log12.log.info("error notarizing (recoverable)", err, {
3876
+ F: __dxlog_file14,
3758
3877
  L: 151,
3759
3878
  S: this,
3760
3879
  C: (f, a) => f(...a)
@@ -3767,12 +3886,12 @@ var NotarizationPlugin = class {
3767
3886
  this._extensionOpened.on(ctx, () => notarizeTask.schedule());
3768
3887
  try {
3769
3888
  await Promise.race([
3770
- (0, import_context10.rejectOnDispose)(ctx),
3889
+ (0, import_context11.rejectOnDispose)(ctx),
3771
3890
  allNotarized,
3772
3891
  errors.wait()
3773
3892
  ]);
3774
- (0, import_log11.log)("done", void 0, {
3775
- F: __dxlog_file13,
3893
+ (0, import_log12.log)("done", void 0, {
3894
+ F: __dxlog_file14,
3776
3895
  L: 162,
3777
3896
  S: this,
3778
3897
  C: (f, a) => f(...a)
@@ -3794,7 +3913,7 @@ var NotarizationPlugin = class {
3794
3913
  }
3795
3914
  setWriter(writer) {
3796
3915
  (0, import_invariant13.invariant)(!this._writer, "Writer already set.", {
3797
- F: __dxlog_file13,
3916
+ F: __dxlog_file14,
3798
3917
  L: 181,
3799
3918
  S: this,
3800
3919
  A: [
@@ -3819,7 +3938,7 @@ var NotarizationPlugin = class {
3819
3938
  }
3820
3939
  for (const credential of request.credentials ?? []) {
3821
3940
  (0, import_invariant13.invariant)(credential.id, "Credential must have an id", {
3822
- F: __dxlog_file13,
3941
+ F: __dxlog_file14,
3823
3942
  L: 200,
3824
3943
  S: this,
3825
3944
  A: [
@@ -3836,10 +3955,10 @@ var NotarizationPlugin = class {
3836
3955
  createExtension() {
3837
3956
  const extension = new NotarizationTeleportExtension({
3838
3957
  onOpen: async () => {
3839
- (0, import_log11.log)("extension opened", {
3958
+ (0, import_log12.log)("extension opened", {
3840
3959
  peer: extension.localPeerId
3841
3960
  }, {
3842
- F: __dxlog_file13,
3961
+ F: __dxlog_file14,
3843
3962
  L: 211,
3844
3963
  S: this,
3845
3964
  C: (f, a) => f(...a)
@@ -3848,10 +3967,10 @@ var NotarizationPlugin = class {
3848
3967
  this._extensionOpened.emit();
3849
3968
  },
3850
3969
  onClose: async () => {
3851
- (0, import_log11.log)("extension closed", {
3970
+ (0, import_log12.log)("extension closed", {
3852
3971
  peer: extension.localPeerId
3853
3972
  }, {
3854
- F: __dxlog_file13,
3973
+ F: __dxlog_file14,
3855
3974
  L: 216,
3856
3975
  S: this,
3857
3976
  C: (f, a) => f(...a)
@@ -3903,14 +4022,14 @@ function _ts_decorate4(decorators, target, key, desc) {
3903
4022
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3904
4023
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3905
4024
  }
3906
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4025
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3907
4026
  var DataSpace = class {
3908
4027
  constructor(params) {
3909
- this._ctx = new import_context9.Context();
4028
+ this._ctx = new import_context10.Context();
3910
4029
  this._notarizationPlugin = new NotarizationPlugin();
3911
4030
  this._cache = void 0;
3912
4031
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
3913
- this._state = import_services11.SpaceState.CLOSED;
4032
+ this._state = import_services12.SpaceState.CLOSED;
3914
4033
  this.error = void 0;
3915
4034
  this.stateUpdate = new import_async12.Event();
3916
4035
  this.metrics = {};
@@ -3925,16 +4044,16 @@ var DataSpace = class {
3925
4044
  this._callbacks = params.callbacks ?? {};
3926
4045
  this._echoHost = params.echoHost;
3927
4046
  this.authVerifier = new TrustedKeySetAuthVerifier({
3928
- trustedKeysProvider: () => new import_util6.ComplexSet(import_keys9.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== import_credentials12.SpaceMember.Role.REMOVED).map((member) => member.key)),
4047
+ 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)),
3929
4048
  update: this._inner.stateUpdate,
3930
4049
  authTimeout: import_client_protocol4.AUTH_TIMEOUT
3931
4050
  });
3932
4051
  this._cache = params.cache;
3933
4052
  this._state = params.initialState;
3934
- (0, import_log10.log)("new state", {
3935
- state: import_services11.SpaceState[this._state]
4053
+ (0, import_log11.log)("new state", {
4054
+ state: import_services12.SpaceState[this._state]
3936
4055
  }, {
3937
- F: __dxlog_file14,
4056
+ F: __dxlog_file15,
3938
4057
  L: 143,
3939
4058
  S: this,
3940
4059
  C: (f, a) => f(...a)
@@ -3975,20 +4094,23 @@ var DataSpace = class {
3975
4094
  };
3976
4095
  }
3977
4096
  async open() {
3978
- await this._open();
4097
+ if (this._state === import_services12.SpaceState.CLOSED) {
4098
+ await this._open();
4099
+ }
3979
4100
  }
3980
4101
  async _open() {
4102
+ await this._presence.open();
3981
4103
  await this._gossip.open();
3982
4104
  await this._notarizationPlugin.open();
3983
4105
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
3984
4106
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
3985
- await this._inner.open(new import_context9.Context());
3986
- this._state = import_services11.SpaceState.CONTROL_ONLY;
3987
- (0, import_log10.log)("new state", {
3988
- state: import_services11.SpaceState[this._state]
4107
+ await this._inner.open(new import_context10.Context());
4108
+ this._state = import_services12.SpaceState.CONTROL_ONLY;
4109
+ (0, import_log11.log)("new state", {
4110
+ state: import_services12.SpaceState[this._state]
3989
4111
  }, {
3990
- F: __dxlog_file14,
3991
- L: 206,
4112
+ F: __dxlog_file15,
4113
+ L: 209,
3992
4114
  S: this,
3993
4115
  C: (f, a) => f(...a)
3994
4116
  });
@@ -4001,23 +4123,23 @@ var DataSpace = class {
4001
4123
  }
4002
4124
  async _close() {
4003
4125
  await this._callbacks.beforeClose?.();
4004
- this._state = import_services11.SpaceState.CLOSED;
4005
- (0, import_log10.log)("new state", {
4006
- state: import_services11.SpaceState[this._state]
4126
+ this._state = import_services12.SpaceState.CLOSED;
4127
+ (0, import_log11.log)("new state", {
4128
+ state: import_services12.SpaceState[this._state]
4007
4129
  }, {
4008
- F: __dxlog_file14,
4009
- L: 220,
4130
+ F: __dxlog_file15,
4131
+ L: 223,
4010
4132
  S: this,
4011
4133
  C: (f, a) => f(...a)
4012
4134
  });
4013
4135
  await this._ctx.dispose();
4014
- this._ctx = new import_context9.Context();
4136
+ this._ctx = new import_context10.Context();
4015
4137
  await this.authVerifier.close();
4016
4138
  await this._inner.close();
4017
4139
  await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
4018
4140
  await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
4019
4141
  await this._notarizationPlugin.close();
4020
- await this._presence.destroy();
4142
+ await this._presence.close();
4021
4143
  await this._gossip.close();
4022
4144
  }
4023
4145
  async postMessage(channel, message) {
@@ -4035,27 +4157,27 @@ var DataSpace = class {
4035
4157
  this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
4036
4158
  await this.initializeDataPipeline();
4037
4159
  } catch (err) {
4038
- if (err instanceof import_protocols9.CancelledError || err instanceof import_context9.ContextDisposedError) {
4039
- (0, import_log10.log)("data pipeline initialization cancelled", err, {
4040
- F: __dxlog_file14,
4041
- L: 253,
4160
+ if (err instanceof import_protocols9.CancelledError || err instanceof import_context10.ContextDisposedError) {
4161
+ (0, import_log11.log)("data pipeline initialization cancelled", err, {
4162
+ F: __dxlog_file15,
4163
+ L: 256,
4042
4164
  S: this,
4043
4165
  C: (f, a) => f(...a)
4044
4166
  });
4045
4167
  return;
4046
4168
  }
4047
- import_log10.log.error("Error initializing data pipeline", err, {
4048
- F: __dxlog_file14,
4049
- L: 257,
4169
+ import_log11.log.error("Error initializing data pipeline", err, {
4170
+ F: __dxlog_file15,
4171
+ L: 260,
4050
4172
  S: this,
4051
4173
  C: (f, a) => f(...a)
4052
4174
  });
4053
- this._state = import_services11.SpaceState.ERROR;
4054
- (0, import_log10.log)("new state", {
4055
- state: import_services11.SpaceState[this._state]
4175
+ this._state = import_services12.SpaceState.ERROR;
4176
+ (0, import_log11.log)("new state", {
4177
+ state: import_services12.SpaceState[this._state]
4056
4178
  }, {
4057
- F: __dxlog_file14,
4058
- L: 259,
4179
+ F: __dxlog_file15,
4180
+ L: 262,
4059
4181
  S: this,
4060
4182
  C: (f, a) => f(...a)
4061
4183
  });
@@ -4067,35 +4189,35 @@ var DataSpace = class {
4067
4189
  });
4068
4190
  }
4069
4191
  async initializeDataPipeline() {
4070
- if (this._state !== import_services11.SpaceState.CONTROL_ONLY) {
4192
+ if (this._state !== import_services12.SpaceState.CONTROL_ONLY) {
4071
4193
  throw new import_protocols9.SystemError("Invalid operation");
4072
4194
  }
4073
- this._state = import_services11.SpaceState.INITIALIZING;
4074
- (0, import_log10.log)("new state", {
4075
- state: import_services11.SpaceState[this._state]
4195
+ this._state = import_services12.SpaceState.INITIALIZING;
4196
+ (0, import_log11.log)("new state", {
4197
+ state: import_services12.SpaceState[this._state]
4076
4198
  }, {
4077
- F: __dxlog_file14,
4078
- L: 275,
4199
+ F: __dxlog_file15,
4200
+ L: 278,
4079
4201
  S: this,
4080
4202
  C: (f, a) => f(...a)
4081
4203
  });
4082
4204
  await this._initializeAndReadControlPipeline();
4083
4205
  await (0, import_async12.sleep)(1);
4084
4206
  this._automergeSpaceState.startProcessingRootDocs();
4085
- await (0, import_context9.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
4086
- (0, import_log10.log)("data pipeline ready", void 0, {
4087
- F: __dxlog_file14,
4088
- L: 287,
4207
+ await (0, import_context10.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
4208
+ (0, import_log11.log)("data pipeline ready", void 0, {
4209
+ F: __dxlog_file15,
4210
+ L: 290,
4089
4211
  S: this,
4090
4212
  C: (f, a) => f(...a)
4091
4213
  });
4092
4214
  await this._callbacks.beforeReady?.();
4093
- this._state = import_services11.SpaceState.READY;
4094
- (0, import_log10.log)("new state", {
4095
- state: import_services11.SpaceState[this._state]
4215
+ this._state = import_services12.SpaceState.READY;
4216
+ (0, import_log11.log)("new state", {
4217
+ state: import_services12.SpaceState[this._state]
4096
4218
  }, {
4097
- F: __dxlog_file14,
4098
- L: 291,
4219
+ F: __dxlog_file15,
4220
+ L: 294,
4099
4221
  S: this,
4100
4222
  C: (f, a) => f(...a)
4101
4223
  });
@@ -4109,9 +4231,9 @@ var DataSpace = class {
4109
4231
  });
4110
4232
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
4111
4233
  await this._createWritableFeeds();
4112
- (0, import_log10.log)("writable feeds created", void 0, {
4113
- F: __dxlog_file14,
4114
- L: 307,
4234
+ (0, import_log11.log)("writable feeds created", void 0, {
4235
+ F: __dxlog_file15,
4236
+ L: 310,
4115
4237
  S: this,
4116
4238
  C: (f, a) => f(...a)
4117
4239
  });
@@ -4138,7 +4260,7 @@ var DataSpace = class {
4138
4260
  spaceKey: this.key,
4139
4261
  deviceKey: this._signingContext.deviceKey,
4140
4262
  identityKey: this._signingContext.identityKey,
4141
- designation: import_credentials12.AdmittedFeed.Designation.CONTROL
4263
+ designation: import_credentials13.AdmittedFeed.Designation.CONTROL
4142
4264
  }
4143
4265
  }));
4144
4266
  }
@@ -4155,7 +4277,7 @@ var DataSpace = class {
4155
4277
  spaceKey: this.key,
4156
4278
  deviceKey: this._signingContext.deviceKey,
4157
4279
  identityKey: this._signingContext.identityKey,
4158
- designation: import_credentials12.AdmittedFeed.Designation.DATA
4280
+ designation: import_credentials13.AdmittedFeed.Designation.DATA
4159
4281
  }
4160
4282
  }));
4161
4283
  }
@@ -4169,12 +4291,12 @@ var DataSpace = class {
4169
4291
  }
4170
4292
  }
4171
4293
  _onNewAutomergeRoot(rootUrl) {
4172
- (0, import_log10.log)("loading automerge root doc for space", {
4294
+ (0, import_log11.log)("loading automerge root doc for space", {
4173
4295
  space: this.key,
4174
4296
  rootUrl
4175
4297
  }, {
4176
- F: __dxlog_file14,
4177
- L: 373,
4298
+ F: __dxlog_file15,
4299
+ L: 376,
4178
4300
  S: this,
4179
4301
  C: (f, a) => f(...a)
4180
4302
  });
@@ -4183,7 +4305,7 @@ var DataSpace = class {
4183
4305
  queueMicrotask(async () => {
4184
4306
  try {
4185
4307
  await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
4186
- await (0, import_context9.cancelWithContext)(this._ctx, handle.whenReady());
4308
+ await (0, import_context10.cancelWithContext)(this._ctx, handle.whenReady());
4187
4309
  });
4188
4310
  if (this._ctx.disposed) {
4189
4311
  return;
@@ -4199,27 +4321,27 @@ var DataSpace = class {
4199
4321
  if (!this._echoHost.roots.has(handle.documentId)) {
4200
4322
  await this._echoHost.openSpaceRoot(handle.url);
4201
4323
  } else {
4202
- import_log10.log.warn("echo database root already exists", {
4324
+ import_log11.log.warn("echo database root already exists", {
4203
4325
  space: this.key,
4204
4326
  rootUrl
4205
4327
  }, {
4206
- F: __dxlog_file14,
4207
- L: 400,
4328
+ F: __dxlog_file15,
4329
+ L: 403,
4208
4330
  S: this,
4209
4331
  C: (f, a) => f(...a)
4210
4332
  });
4211
4333
  }
4212
4334
  } catch (err) {
4213
- if (err instanceof import_context9.ContextDisposedError) {
4335
+ if (err instanceof import_context10.ContextDisposedError) {
4214
4336
  return;
4215
4337
  }
4216
- import_log10.log.warn("error loading automerge root doc", {
4338
+ import_log11.log.warn("error loading automerge root doc", {
4217
4339
  space: this.key,
4218
4340
  rootUrl,
4219
4341
  err
4220
4342
  }, {
4221
- F: __dxlog_file14,
4222
- L: 406,
4343
+ F: __dxlog_file15,
4344
+ L: 409,
4223
4345
  S: this,
4224
4346
  C: (f, a) => f(...a)
4225
4347
  });
@@ -4245,39 +4367,39 @@ var DataSpace = class {
4245
4367
  let epoch;
4246
4368
  switch (options?.migration) {
4247
4369
  case void 0:
4248
- case import_services11.CreateEpochRequest.Migration.NONE:
4370
+ case import_services12.CreateEpochRequest.Migration.NONE:
4249
4371
  {
4250
4372
  epoch = {
4251
4373
  previousId: this._automergeSpaceState.lastEpoch?.id,
4252
4374
  number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
4253
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
4375
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
4254
4376
  automergeRoot: this._automergeSpaceState.lastEpoch?.subject.assertion?.automergeRoot
4255
4377
  };
4256
4378
  }
4257
4379
  break;
4258
- case import_services11.CreateEpochRequest.Migration.INIT_AUTOMERGE:
4380
+ case import_services12.CreateEpochRequest.Migration.INIT_AUTOMERGE:
4259
4381
  {
4260
4382
  const document = this._echoHost.automergeRepo.create();
4261
4383
  epoch = {
4262
4384
  previousId: this._automergeSpaceState.lastEpoch?.id,
4263
4385
  number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
4264
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
4386
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
4265
4387
  automergeRoot: document.url
4266
4388
  };
4267
4389
  }
4268
4390
  break;
4269
- case import_services11.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
4391
+ case import_services12.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
4270
4392
  {
4271
4393
  const currentRootUrl = this._automergeSpaceState.rootUrl;
4272
4394
  const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
4273
- await (0, import_context9.cancelWithContext)(this._ctx, (0, import_async12.asyncTimeout)(rootHandle.whenReady(), 1e4));
4395
+ await (0, import_context10.cancelWithContext)(this._ctx, (0, import_async12.asyncTimeout)(rootHandle.whenReady(), 1e4));
4274
4396
  const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
4275
4397
  await this._echoHost.automergeRepo.flush([
4276
4398
  newRoot.documentId
4277
4399
  ]);
4278
4400
  (0, import_invariant12.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
4279
- F: __dxlog_file14,
4280
- L: 457,
4401
+ F: __dxlog_file15,
4402
+ L: 460,
4281
4403
  S: this,
4282
4404
  A: [
4283
4405
  "typeof newRoot.url === 'string' && newRoot.url.length > 0",
@@ -4287,28 +4409,28 @@ var DataSpace = class {
4287
4409
  epoch = {
4288
4410
  previousId: this._automergeSpaceState.lastEpoch?.id,
4289
4411
  number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
4290
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
4412
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
4291
4413
  automergeRoot: newRoot.url
4292
4414
  };
4293
4415
  }
4294
4416
  break;
4295
- case import_services11.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
4417
+ case import_services12.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
4296
4418
  {
4297
- import_log10.log.info("Fragmenting", void 0, {
4298
- F: __dxlog_file14,
4299
- L: 469,
4419
+ import_log11.log.info("Fragmenting", void 0, {
4420
+ F: __dxlog_file15,
4421
+ L: 472,
4300
4422
  S: this,
4301
4423
  C: (f, a) => f(...a)
4302
4424
  });
4303
4425
  const currentRootUrl = this._automergeSpaceState.rootUrl;
4304
4426
  const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
4305
- await (0, import_context9.cancelWithContext)(this._ctx, (0, import_async12.asyncTimeout)(rootHandle.whenReady(), 1e4));
4427
+ await (0, import_context10.cancelWithContext)(this._ctx, (0, import_async12.asyncTimeout)(rootHandle.whenReady(), 1e4));
4306
4428
  const objects = Object.entries(rootHandle.docSync().objects);
4307
4429
  const properties = findPropertiesObject(rootHandle.docSync());
4308
4430
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
4309
4431
  (0, import_invariant12.invariant)(properties, "Properties not found", {
4310
- F: __dxlog_file14,
4311
- L: 479,
4432
+ F: __dxlog_file15,
4433
+ L: 482,
4312
4434
  S: this,
4313
4435
  A: [
4314
4436
  "properties",
@@ -4323,8 +4445,8 @@ var DataSpace = class {
4323
4445
  };
4324
4446
  const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
4325
4447
  (0, import_invariant12.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
4326
- F: __dxlog_file14,
4327
- L: 484,
4448
+ F: __dxlog_file15,
4449
+ L: 487,
4328
4450
  S: this,
4329
4451
  A: [
4330
4452
  "typeof newRoot.url === 'string' && newRoot.url.length > 0",
@@ -4347,16 +4469,16 @@ var DataSpace = class {
4347
4469
  epoch = {
4348
4470
  previousId: this._automergeSpaceState.lastEpoch?.id,
4349
4471
  number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
4350
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
4472
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
4351
4473
  automergeRoot: newRoot.url
4352
4474
  };
4353
4475
  }
4354
4476
  break;
4355
- case import_services11.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT:
4477
+ case import_services12.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT:
4356
4478
  {
4357
4479
  (0, import_invariant12.invariant)(options.newAutomergeRoot, void 0, {
4358
- F: __dxlog_file14,
4359
- L: 514,
4480
+ F: __dxlog_file15,
4481
+ L: 517,
4360
4482
  S: this,
4361
4483
  A: [
4362
4484
  "options.newAutomergeRoot",
@@ -4366,7 +4488,7 @@ var DataSpace = class {
4366
4488
  epoch = {
4367
4489
  previousId: this._automergeSpaceState.lastEpoch?.id,
4368
4490
  number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
4369
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
4491
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
4370
4492
  automergeRoot: options.newAutomergeRoot
4371
4493
  };
4372
4494
  }
@@ -4386,7 +4508,7 @@ var DataSpace = class {
4386
4508
  })
4387
4509
  }
4388
4510
  });
4389
- await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
4511
+ await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe3.Timeframe([
4390
4512
  [
4391
4513
  receipt.feedKey,
4392
4514
  receipt.seq
@@ -4395,25 +4517,30 @@ var DataSpace = class {
4395
4517
  await this._echoHost.updateIndexes();
4396
4518
  }
4397
4519
  async activate() {
4398
- if (this._state !== import_services11.SpaceState.INACTIVE) {
4520
+ if (![
4521
+ import_services12.SpaceState.CLOSED,
4522
+ import_services12.SpaceState.INACTIVE
4523
+ ].includes(this._state)) {
4399
4524
  return;
4400
4525
  }
4401
- await this._metadataStore.setSpaceState(this.key, import_services11.SpaceState.ACTIVE);
4526
+ await this._metadataStore.setSpaceState(this.key, import_services12.SpaceState.ACTIVE);
4402
4527
  await this._open();
4403
4528
  this.initializeDataPipelineAsync();
4404
4529
  }
4405
4530
  async deactivate() {
4406
- if (this._state === import_services11.SpaceState.INACTIVE) {
4531
+ if (this._state === import_services12.SpaceState.INACTIVE) {
4407
4532
  return;
4408
4533
  }
4409
- await this._metadataStore.setSpaceState(this.key, import_services11.SpaceState.INACTIVE);
4410
- await this._close();
4411
- this._state = import_services11.SpaceState.INACTIVE;
4412
- (0, import_log10.log)("new state", {
4413
- state: import_services11.SpaceState[this._state]
4534
+ await this._metadataStore.setSpaceState(this.key, import_services12.SpaceState.INACTIVE);
4535
+ if (this._state !== import_services12.SpaceState.CLOSED) {
4536
+ await this._close();
4537
+ }
4538
+ this._state = import_services12.SpaceState.INACTIVE;
4539
+ (0, import_log11.log)("new state", {
4540
+ state: import_services12.SpaceState[this._state]
4414
4541
  }, {
4415
- F: __dxlog_file14,
4416
- L: 567,
4542
+ F: __dxlog_file15,
4543
+ L: 571,
4417
4544
  S: this,
4418
4545
  C: (f, a) => f(...a)
4419
4546
  });
@@ -4431,7 +4558,7 @@ _ts_decorate4([
4431
4558
  ], DataSpace.prototype, "key", null);
4432
4559
  _ts_decorate4([
4433
4560
  import_tracing5.trace.info({
4434
- enum: import_services11.SpaceState
4561
+ enum: import_services12.SpaceState
4435
4562
  })
4436
4563
  ], DataSpace.prototype, "state", null);
4437
4564
  _ts_decorate4([
@@ -4482,7 +4609,7 @@ var findPropertiesObject = (spaceDoc) => {
4482
4609
  };
4483
4610
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
4484
4611
  const credentials = [
4485
- await (0, import_credentials16.createCredential)({
4612
+ await (0, import_credentials17.createCredential)({
4486
4613
  signer: keyring,
4487
4614
  issuer: space.key,
4488
4615
  subject: space.key,
@@ -4491,14 +4618,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
4491
4618
  spaceKey: space.key
4492
4619
  }
4493
4620
  }),
4494
- await (0, import_credentials16.createCredential)({
4621
+ await (0, import_credentials17.createCredential)({
4495
4622
  signer: keyring,
4496
4623
  issuer: space.key,
4497
4624
  subject: signingContext.identityKey,
4498
4625
  assertion: {
4499
4626
  "@type": "dxos.halo.credentials.SpaceMember",
4500
4627
  spaceKey: space.key,
4501
- role: import_credentials17.SpaceMember.Role.OWNER,
4628
+ role: import_credentials18.SpaceMember.Role.OWNER,
4502
4629
  profile: signingContext.getProfile(),
4503
4630
  genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
4504
4631
  }
@@ -4510,7 +4637,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
4510
4637
  spaceKey: space.key,
4511
4638
  identityKey: signingContext.identityKey,
4512
4639
  deviceKey: signingContext.deviceKey,
4513
- designation: import_credentials17.AdmittedFeed.Designation.CONTROL
4640
+ designation: import_credentials18.AdmittedFeed.Designation.CONTROL
4514
4641
  }
4515
4642
  }),
4516
4643
  await signingContext.credentialSigner.createCredential({
@@ -4520,7 +4647,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
4520
4647
  spaceKey: space.key,
4521
4648
  identityKey: signingContext.identityKey,
4522
4649
  deviceKey: signingContext.deviceKey,
4523
- designation: import_credentials17.AdmittedFeed.Designation.DATA
4650
+ designation: import_credentials18.AdmittedFeed.Designation.DATA
4524
4651
  }
4525
4652
  }),
4526
4653
  await signingContext.credentialSigner.createCredential({
@@ -4529,7 +4656,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
4529
4656
  "@type": "dxos.halo.credentials.Epoch",
4530
4657
  number: 0,
4531
4658
  previousId: void 0,
4532
- timeframe: new import_timeframe3.Timeframe(),
4659
+ timeframe: new import_timeframe4.Timeframe(),
4533
4660
  snapshotCid: void 0,
4534
4661
  automergeRoot
4535
4662
  }
@@ -4554,11 +4681,12 @@ function _ts_decorate5(decorators, target, key, desc) {
4554
4681
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4555
4682
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4556
4683
  }
4557
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4684
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4558
4685
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
4559
4686
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
4687
+ var DEFAULT_SPACE_KEY = "__DEFAULT__";
4560
4688
  var DataSpaceManager = class {
4561
- constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, params) {
4689
+ constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, _params) {
4562
4690
  this._spaceManager = _spaceManager;
4563
4691
  this._metadataStore = _metadataStore;
4564
4692
  this._keyring = _keyring;
@@ -4566,14 +4694,12 @@ var DataSpaceManager = class {
4566
4694
  this._feedStore = _feedStore;
4567
4695
  this._echoHost = _echoHost;
4568
4696
  this._invitationsManager = _invitationsManager;
4569
- this._ctx = new import_context11.Context();
4697
+ this._params = _params;
4698
+ this._ctx = new import_context12.Context();
4570
4699
  this.updated = new import_async15.Event();
4571
- this._spaces = new import_util8.ComplexMap(import_keys11.PublicKey.hash);
4700
+ this._spaces = new import_util8.ComplexMap(import_keys12.PublicKey.hash);
4572
4701
  this._isOpen = false;
4573
- this._instanceId = import_keys11.PublicKey.random().toHex();
4574
- const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
4575
- this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
4576
- this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
4702
+ this._instanceId = import_keys12.PublicKey.random().toHex();
4577
4703
  import_tracing6.trace.diagnostic({
4578
4704
  id: "spaces",
4579
4705
  name: "Spaces",
@@ -4585,7 +4711,7 @@ var DataSpaceManager = class {
4585
4711
  const properties = rootDoc && findPropertiesObject(rootDoc);
4586
4712
  return {
4587
4713
  key: space.key.toHex(),
4588
- state: import_services12.SpaceState[space.state],
4714
+ state: import_services13.SpaceState[space.state],
4589
4715
  name: properties?.[1].data.name ?? null,
4590
4716
  inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
4591
4717
  linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
@@ -4602,46 +4728,46 @@ var DataSpaceManager = class {
4602
4728
  return this._spaces;
4603
4729
  }
4604
4730
  async open() {
4605
- (0, import_log12.log)("open", void 0, {
4606
- F: __dxlog_file15,
4607
- L: 144,
4731
+ (0, import_log13.log)("open", void 0, {
4732
+ F: __dxlog_file16,
4733
+ L: 140,
4608
4734
  S: this,
4609
4735
  C: (f, a) => f(...a)
4610
4736
  });
4611
- import_log12.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
4737
+ import_log13.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
4612
4738
  id: this._instanceId
4613
4739
  }), {
4614
- F: __dxlog_file15,
4615
- L: 145,
4740
+ F: __dxlog_file16,
4741
+ L: 141,
4616
4742
  S: this,
4617
4743
  C: (f, a) => f(...a)
4618
4744
  });
4619
- (0, import_log12.log)("metadata loaded", {
4745
+ (0, import_log13.log)("metadata loaded", {
4620
4746
  spaces: this._metadataStore.spaces.length
4621
4747
  }, {
4622
- F: __dxlog_file15,
4623
- L: 146,
4748
+ F: __dxlog_file16,
4749
+ L: 142,
4624
4750
  S: this,
4625
4751
  C: (f, a) => f(...a)
4626
4752
  });
4627
4753
  await (0, import_util8.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
4628
4754
  try {
4629
- (0, import_log12.log)("load space", {
4755
+ (0, import_log13.log)("load space", {
4630
4756
  spaceMetadata
4631
4757
  }, {
4632
- F: __dxlog_file15,
4633
- L: 150,
4758
+ F: __dxlog_file16,
4759
+ L: 146,
4634
4760
  S: this,
4635
4761
  C: (f, a) => f(...a)
4636
4762
  });
4637
4763
  await this._constructSpace(spaceMetadata);
4638
4764
  } catch (err) {
4639
- import_log12.log.error("Error loading space", {
4765
+ import_log13.log.error("Error loading space", {
4640
4766
  spaceMetadata,
4641
4767
  err
4642
4768
  }, {
4643
- F: __dxlog_file15,
4644
- L: 153,
4769
+ F: __dxlog_file16,
4770
+ L: 149,
4645
4771
  S: this,
4646
4772
  C: (f, a) => f(...a)
4647
4773
  });
@@ -4649,24 +4775,19 @@ var DataSpaceManager = class {
4649
4775
  });
4650
4776
  this._isOpen = true;
4651
4777
  this.updated.emit();
4652
- for (const space of this._spaces.values()) {
4653
- if (space.state !== import_services12.SpaceState.INACTIVE) {
4654
- space.initializeDataPipelineAsync();
4655
- }
4656
- }
4657
- import_log12.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
4778
+ import_log13.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
4658
4779
  id: this._instanceId
4659
4780
  }), {
4660
- F: __dxlog_file15,
4661
- L: 166,
4781
+ F: __dxlog_file16,
4782
+ L: 156,
4662
4783
  S: this,
4663
4784
  C: (f, a) => f(...a)
4664
4785
  });
4665
4786
  }
4666
4787
  async close() {
4667
- (0, import_log12.log)("close", void 0, {
4668
- F: __dxlog_file15,
4669
- L: 171,
4788
+ (0, import_log13.log)("close", void 0, {
4789
+ F: __dxlog_file16,
4790
+ L: 161,
4670
4791
  S: this,
4671
4792
  C: (f, a) => f(...a)
4672
4793
  });
@@ -4675,14 +4796,15 @@ var DataSpaceManager = class {
4675
4796
  for (const space of this._spaces.values()) {
4676
4797
  await space.close();
4677
4798
  }
4799
+ this._spaces.clear();
4678
4800
  }
4679
4801
  /**
4680
4802
  * Creates a new space writing the genesis credentials to the control feed.
4681
4803
  */
4682
4804
  async createSpace() {
4683
4805
  (0, import_invariant14.invariant)(this._isOpen, "Not open.", {
4684
- F: __dxlog_file15,
4685
- L: 184,
4806
+ F: __dxlog_file16,
4807
+ L: 175,
4686
4808
  S: this,
4687
4809
  A: [
4688
4810
  "this._isOpen",
@@ -4697,24 +4819,25 @@ var DataSpaceManager = class {
4697
4819
  genesisFeedKey: controlFeedKey,
4698
4820
  controlFeedKey,
4699
4821
  dataFeedKey,
4700
- state: import_services12.SpaceState.ACTIVE
4822
+ state: import_services13.SpaceState.ACTIVE
4701
4823
  };
4702
- (0, import_log12.log)("creating space...", {
4824
+ (0, import_log13.log)("creating space...", {
4703
4825
  spaceKey
4704
4826
  }, {
4705
- F: __dxlog_file15,
4706
- L: 196,
4827
+ F: __dxlog_file16,
4828
+ L: 187,
4707
4829
  S: this,
4708
4830
  C: (f, a) => f(...a)
4709
4831
  });
4710
4832
  const root = await this._echoHost.createSpaceRoot(spaceKey);
4711
4833
  const space = await this._constructSpace(metadata);
4834
+ await space.open();
4712
4835
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
4713
4836
  await this._metadataStore.addSpace(metadata);
4714
4837
  const memberCredential = credentials[1];
4715
- (0, import_invariant14.invariant)((0, import_credentials14.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4716
- F: __dxlog_file15,
4717
- L: 205,
4838
+ (0, import_invariant14.invariant)((0, import_credentials15.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4839
+ F: __dxlog_file16,
4840
+ L: 197,
4718
4841
  S: this,
4719
4842
  A: [
4720
4843
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -4726,19 +4849,63 @@ var DataSpaceManager = class {
4726
4849
  this.updated.emit();
4727
4850
  return space;
4728
4851
  }
4852
+ async isDefaultSpace(space) {
4853
+ const rootDoc = await this._getSpaceRootDocument(space);
4854
+ const [_, properties] = findPropertiesObject(rootDoc.docSync()) ?? [];
4855
+ return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
4856
+ }
4857
+ async createDefaultSpace() {
4858
+ const space = await this.createSpace();
4859
+ const document = await this._getSpaceRootDocument(space);
4860
+ const properties = {
4861
+ system: {
4862
+ type: (0, import_echo_protocol.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.PropertiesType))
4863
+ },
4864
+ data: {
4865
+ [DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
4866
+ },
4867
+ meta: {
4868
+ keys: []
4869
+ }
4870
+ };
4871
+ const propertiesId = import_keys12.PublicKey.random().toHex();
4872
+ document.change((doc) => {
4873
+ (0, import_util8.assignDeep)(doc, [
4874
+ "objects",
4875
+ propertiesId
4876
+ ], properties);
4877
+ });
4878
+ await this._echoHost.flush();
4879
+ return space;
4880
+ }
4881
+ async _getSpaceRootDocument(space) {
4882
+ const automergeIndex = space.automergeSpaceState.rootUrl;
4883
+ (0, import_invariant14.invariant)(automergeIndex, void 0, {
4884
+ F: __dxlog_file16,
4885
+ L: 240,
4886
+ S: this,
4887
+ A: [
4888
+ "automergeIndex",
4889
+ ""
4890
+ ]
4891
+ });
4892
+ const document = this._echoHost.automergeRepo.find(automergeIndex);
4893
+ await document.whenReady();
4894
+ return document;
4895
+ }
4729
4896
  // TODO(burdon): Rename join space.
4730
4897
  async acceptSpace(opts) {
4731
- (0, import_log12.log)("accept space", {
4898
+ (0, import_log13.log)("accept space", {
4732
4899
  opts
4733
4900
  }, {
4734
- F: __dxlog_file15,
4735
- L: 217,
4901
+ F: __dxlog_file16,
4902
+ L: 249,
4736
4903
  S: this,
4737
4904
  C: (f, a) => f(...a)
4738
4905
  });
4739
4906
  (0, import_invariant14.invariant)(this._isOpen, "Not open.", {
4740
- F: __dxlog_file15,
4741
- L: 218,
4907
+ F: __dxlog_file16,
4908
+ L: 250,
4742
4909
  S: this,
4743
4910
  A: [
4744
4911
  "this._isOpen",
@@ -4746,8 +4913,8 @@ var DataSpaceManager = class {
4746
4913
  ]
4747
4914
  });
4748
4915
  (0, import_invariant14.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
4749
- F: __dxlog_file15,
4750
- L: 219,
4916
+ F: __dxlog_file16,
4917
+ L: 251,
4751
4918
  S: this,
4752
4919
  A: [
4753
4920
  "!this._spaces.has(opts.spaceKey)",
@@ -4761,6 +4928,7 @@ var DataSpaceManager = class {
4761
4928
  dataTimeframe: opts.dataTimeframe
4762
4929
  };
4763
4930
  const space = await this._constructSpace(metadata);
4931
+ await space.open();
4764
4932
  await this._metadataStore.addSpace(metadata);
4765
4933
  space.initializeDataPipelineAsync();
4766
4934
  this.updated.emit();
@@ -4772,17 +4940,17 @@ var DataSpaceManager = class {
4772
4940
  * TODO(dmaretskyi): Consider removing.
4773
4941
  */
4774
4942
  async waitUntilSpaceReady(spaceKey) {
4775
- await (0, import_context11.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
4943
+ await (0, import_context12.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
4776
4944
  const space = this._spaces.get(spaceKey);
4777
- return !!space && space.state === import_services12.SpaceState.READY;
4945
+ return !!space && space.state === import_services13.SpaceState.READY;
4778
4946
  }));
4779
4947
  }
4780
4948
  async _constructSpace(metadata) {
4781
- (0, import_log12.log)("construct space", {
4949
+ (0, import_log13.log)("construct space", {
4782
4950
  metadata
4783
4951
  }, {
4784
- F: __dxlog_file15,
4785
- L: 252,
4952
+ F: __dxlog_file16,
4953
+ L: 285,
4786
4954
  S: this,
4787
4955
  C: (f, a) => f(...a)
4788
4956
  });
@@ -4790,8 +4958,8 @@ var DataSpaceManager = class {
4790
4958
  localPeerId: this._signingContext.deviceKey
4791
4959
  });
4792
4960
  const presence = new import_teleport_extension_gossip2.Presence({
4793
- announceInterval: this._spaceMemberPresenceAnnounceInterval,
4794
- offlineTimeout: this._spaceMemberPresenceOfflineTimeout,
4961
+ announceInterval: this._params?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
4962
+ offlineTimeout: this._params?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
4795
4963
  identityKey: this._signingContext.identityKey,
4796
4964
  gossip
4797
4965
  });
@@ -4818,15 +4986,15 @@ var DataSpaceManager = class {
4818
4986
  session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
4819
4987
  },
4820
4988
  onAuthFailure: () => {
4821
- import_log12.log.warn("auth failure", void 0, {
4822
- F: __dxlog_file15,
4823
- L: 289,
4989
+ import_log13.log.warn("auth failure", void 0, {
4990
+ F: __dxlog_file16,
4991
+ L: 322,
4824
4992
  S: this,
4825
4993
  C: (f, a) => f(...a)
4826
4994
  });
4827
4995
  },
4828
4996
  onMemberRolesChanged: async (members) => {
4829
- if (dataSpace?.state === import_services12.SpaceState.READY) {
4997
+ if (dataSpace?.state === import_services13.SpaceState.READY) {
4830
4998
  this._handleMemberRoleChanges(presence, space.protocol, members);
4831
4999
  }
4832
5000
  },
@@ -4839,7 +5007,7 @@ var DataSpaceManager = class {
4839
5007
  dataFeed && await space.setDataFeed(dataFeed);
4840
5008
  const dataSpace = new DataSpace({
4841
5009
  inner: space,
4842
- initialState: metadata.state === import_services12.SpaceState.INACTIVE ? import_services12.SpaceState.INACTIVE : import_services12.SpaceState.CLOSED,
5010
+ initialState: metadata.state === import_services13.SpaceState.INACTIVE ? import_services13.SpaceState.INACTIVE : import_services13.SpaceState.CLOSED,
4843
5011
  metadataStore: this._metadataStore,
4844
5012
  gossip,
4845
5013
  presence,
@@ -4849,22 +5017,22 @@ var DataSpaceManager = class {
4849
5017
  signingContext: this._signingContext,
4850
5018
  callbacks: {
4851
5019
  beforeReady: async () => {
4852
- (0, import_log12.log)("before space ready", {
5020
+ (0, import_log13.log)("before space ready", {
4853
5021
  space: space.key
4854
5022
  }, {
4855
- F: __dxlog_file15,
4856
- L: 316,
5023
+ F: __dxlog_file16,
5024
+ L: 349,
4857
5025
  S: this,
4858
5026
  C: (f, a) => f(...a)
4859
5027
  });
4860
5028
  },
4861
5029
  afterReady: async () => {
4862
- (0, import_log12.log)("after space ready", {
5030
+ (0, import_log13.log)("after space ready", {
4863
5031
  space: space.key,
4864
5032
  open: this._isOpen
4865
5033
  }, {
4866
- F: __dxlog_file15,
4867
- L: 319,
5034
+ F: __dxlog_file16,
5035
+ L: 352,
4868
5036
  S: this,
4869
5037
  C: (f, a) => f(...a)
4870
5038
  });
@@ -4879,11 +5047,11 @@ var DataSpaceManager = class {
4879
5047
  }
4880
5048
  },
4881
5049
  beforeClose: async () => {
4882
- (0, import_log12.log)("before space close", {
5050
+ (0, import_log13.log)("before space close", {
4883
5051
  space: space.key
4884
5052
  }, {
4885
- F: __dxlog_file15,
4886
- L: 327,
5053
+ F: __dxlog_file16,
5054
+ L: 360,
4887
5055
  S: this,
4888
5056
  C: (f, a) => f(...a)
4889
5057
  });
@@ -4892,13 +5060,10 @@ var DataSpaceManager = class {
4892
5060
  cache: metadata.cache
4893
5061
  });
4894
5062
  presence.newPeer.on((peerState) => {
4895
- if (dataSpace.state === import_services12.SpaceState.READY) {
5063
+ if (dataSpace.state === import_services13.SpaceState.READY) {
4896
5064
  this._handleNewPeerConnected(space, peerState);
4897
5065
  }
4898
5066
  });
4899
- if (metadata.state !== import_services12.SpaceState.INACTIVE) {
4900
- await dataSpace.open();
4901
- }
4902
5067
  if (metadata.controlTimeframe) {
4903
5068
  dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
4904
5069
  }
@@ -4914,20 +5079,20 @@ var DataSpaceManager = class {
4914
5079
  const peers = presence.getPeersByIdentityKey(member.key);
4915
5080
  const sessions = peers.map((p) => p.peerId && spaceProtocol.sessions.get(p.peerId));
4916
5081
  const sessionsToClose = sessions.filter((s) => {
4917
- return (s && member.role === import_credentials15.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline3.AuthStatus.FAILURE)) ?? false;
5082
+ return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline3.AuthStatus.FAILURE)) ?? false;
4918
5083
  });
4919
5084
  sessionsToClose.forEach((session) => {
4920
- void session.close().catch(import_log12.log.error);
5085
+ void session.close().catch(import_log13.log.error);
4921
5086
  });
4922
5087
  closedSessions += sessionsToClose.length;
4923
5088
  }
4924
- (0, import_log12.log)("processed member role changes", {
5089
+ (0, import_log13.log)("processed member role changes", {
4925
5090
  roleChangeCount: memberInfo.length,
4926
5091
  peersOnline: presence.getPeersOnline().length,
4927
5092
  closedSessions
4928
5093
  }, {
4929
- F: __dxlog_file15,
4930
- L: 367,
5094
+ F: __dxlog_file16,
5095
+ L: 396,
4931
5096
  S: this,
4932
5097
  C: (f, a) => f(...a)
4933
5098
  });
@@ -4935,23 +5100,23 @@ var DataSpaceManager = class {
4935
5100
  }
4936
5101
  _handleNewPeerConnected(space, peerState) {
4937
5102
  const role = space.spaceState.getMemberRole(peerState.identityKey);
4938
- if (role === import_credentials15.SpaceMember.Role.REMOVED) {
5103
+ if (role === import_credentials16.SpaceMember.Role.REMOVED) {
4939
5104
  const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
4940
5105
  if (session != null) {
4941
- (0, import_log12.log)("closing a session with a removed peer", {
5106
+ (0, import_log13.log)("closing a session with a removed peer", {
4942
5107
  peerId: peerState.peerId
4943
5108
  }, {
4944
- F: __dxlog_file15,
4945
- L: 381,
5109
+ F: __dxlog_file16,
5110
+ L: 410,
4946
5111
  S: this,
4947
5112
  C: (f, a) => f(...a)
4948
5113
  });
4949
- void session.close().catch(import_log12.log.error);
5114
+ void session.close().catch(import_log13.log.error);
4950
5115
  }
4951
5116
  }
4952
5117
  }
4953
5118
  async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
4954
- if (dataSpace?.state !== import_services12.SpaceState.READY) {
5119
+ if (dataSpace?.state !== import_services13.SpaceState.READY) {
4955
5120
  return;
4956
5121
  }
4957
5122
  if (isActive) {
@@ -4968,8 +5133,8 @@ var DataSpaceManager = class {
4968
5133
  async _createDelegatedInvitations(space, invitations) {
4969
5134
  const tasks = invitations.map(([credentialId, invitation]) => {
4970
5135
  return this._invitationsManager.createInvitation({
4971
- type: import_services12.Invitation.Type.DELEGATED,
4972
- kind: import_services12.Invitation.Kind.SPACE,
5136
+ type: import_services13.Invitation.Type.DELEGATED,
5137
+ kind: import_services13.Invitation.Kind.SPACE,
4973
5138
  spaceKey: space.key,
4974
5139
  authMethod: invitation.authMethod,
4975
5140
  invitationId: invitation.invitationId,
@@ -5001,7 +5166,7 @@ _ts_decorate5([
5001
5166
  DataSpaceManager = _ts_decorate5([
5002
5167
  (0, import_async15.trackLeaks)("open", "close")
5003
5168
  ], DataSpaceManager);
5004
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5169
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5005
5170
  var SpacesServiceImpl = class {
5006
5171
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
5007
5172
  this._identityManager = _identityManager;
@@ -5020,10 +5185,10 @@ var SpacesServiceImpl = class {
5020
5185
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
5021
5186
  if (state) {
5022
5187
  switch (state) {
5023
- case import_services13.SpaceState.ACTIVE:
5188
+ case import_services14.SpaceState.ACTIVE:
5024
5189
  await space.activate();
5025
5190
  break;
5026
- case import_services13.SpaceState.INACTIVE:
5191
+ case import_services14.SpaceState.INACTIVE:
5027
5192
  await space.deactivate();
5028
5193
  break;
5029
5194
  default:
@@ -5043,9 +5208,9 @@ var SpacesServiceImpl = class {
5043
5208
  role: space.spaceState.getMemberRole(identity.identityKey)
5044
5209
  });
5045
5210
  }
5046
- const credentials = await (0, import_credentials18.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
5211
+ const credentials = await (0, import_credentials19.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
5047
5212
  (0, import_invariant15.invariant)(credentials[0].credential, void 0, {
5048
- F: __dxlog_file16,
5213
+ F: __dxlog_file17,
5049
5214
  L: 97,
5050
5215
  S: this,
5051
5216
  A: [
@@ -5054,8 +5219,8 @@ var SpacesServiceImpl = class {
5054
5219
  ]
5055
5220
  });
5056
5221
  const spaceMemberCredential = credentials[0].credential.credential;
5057
- (0, import_invariant15.invariant)((0, import_credentials18.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5058
- F: __dxlog_file16,
5222
+ (0, import_invariant15.invariant)((0, import_credentials19.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5223
+ F: __dxlog_file17,
5059
5224
  L: 99,
5060
5225
  S: this,
5061
5226
  A: [
@@ -5070,10 +5235,10 @@ var SpacesServiceImpl = class {
5070
5235
  const scheduler = new import_async16.UpdateScheduler(ctx, async () => {
5071
5236
  const dataSpaceManager = await this._getDataSpaceManager();
5072
5237
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
5073
- (0, import_log13.log)("update", {
5238
+ (0, import_log14.log)("update", {
5074
5239
  spaces
5075
5240
  }, {
5076
- F: __dxlog_file16,
5241
+ F: __dxlog_file17,
5077
5242
  L: 110,
5078
5243
  S: this,
5079
5244
  C: (f, a) => f(...a)
@@ -5157,7 +5322,7 @@ var SpacesServiceImpl = class {
5157
5322
  });
5158
5323
  } else {
5159
5324
  (0, import_invariant15.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
5160
- F: __dxlog_file16,
5325
+ F: __dxlog_file17,
5161
5326
  L: 198,
5162
5327
  S: this,
5163
5328
  A: [
@@ -5166,7 +5331,7 @@ var SpacesServiceImpl = class {
5166
5331
  ]
5167
5332
  });
5168
5333
  (0, import_invariant15.invariant)(this._identityManager.identity, "Identity is not available", {
5169
- F: __dxlog_file16,
5334
+ F: __dxlog_file17,
5170
5335
  L: 199,
5171
5336
  S: this,
5172
5337
  A: [
@@ -5176,7 +5341,7 @@ var SpacesServiceImpl = class {
5176
5341
  });
5177
5342
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
5178
5343
  (0, import_invariant15.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
5179
- F: __dxlog_file16,
5344
+ F: __dxlog_file17,
5180
5345
  L: 201,
5181
5346
  S: this,
5182
5347
  A: [
@@ -5235,7 +5400,7 @@ var SpacesServiceImpl = class {
5235
5400
  profile: member.profile ?? {}
5236
5401
  },
5237
5402
  role: member.role,
5238
- presence: peers.length > 0 ? import_services13.SpaceMember.PresenceState.ONLINE : import_services13.SpaceMember.PresenceState.OFFLINE,
5403
+ presence: peers.length > 0 ? import_services14.SpaceMember.PresenceState.ONLINE : import_services14.SpaceMember.PresenceState.OFFLINE,
5239
5404
  peerStates: peers
5240
5405
  };
5241
5406
  }),
@@ -5273,8 +5438,8 @@ function _ts_decorate6(decorators, target, key, desc) {
5273
5438
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5274
5439
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5275
5440
  }
5276
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5277
- var ServiceContext = class extends import_context12.Resource {
5441
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5442
+ var ServiceContext = class extends import_context13.Resource {
5278
5443
  constructor(storage, level, networkManager, signalManager, _runtimeParams) {
5279
5444
  super();
5280
5445
  this.storage = storage;
@@ -5284,7 +5449,7 @@ var ServiceContext = class extends import_context12.Resource {
5284
5449
  this._runtimeParams = _runtimeParams;
5285
5450
  this.initialized = new import_async17.Trigger();
5286
5451
  this._handlerFactories = /* @__PURE__ */ new Map();
5287
- this._instanceId = import_keys12.PublicKey.random().toHex();
5452
+ this._instanceId = import_keys13.PublicKey.random().toHex();
5288
5453
  this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
5289
5454
  this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
5290
5455
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
@@ -5313,20 +5478,20 @@ var ServiceContext = class extends import_context12.Resource {
5313
5478
  });
5314
5479
  this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
5315
5480
  this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
5316
- this._handlerFactories.set(import_services14.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
5481
+ this._handlerFactories.set(import_services15.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
5317
5482
  }
5318
5483
  async _open(ctx) {
5319
5484
  await this._checkStorageVersion();
5320
- (0, import_log14.log)("opening...", void 0, {
5321
- F: __dxlog_file17,
5485
+ (0, import_log15.log)("opening...", void 0, {
5486
+ F: __dxlog_file18,
5322
5487
  L: 152,
5323
5488
  S: this,
5324
5489
  C: (f, a) => f(...a)
5325
5490
  });
5326
- import_log14.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
5491
+ import_log15.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
5327
5492
  id: this._instanceId
5328
5493
  }), {
5329
- F: __dxlog_file17,
5494
+ F: __dxlog_file18,
5330
5495
  L: 153,
5331
5496
  S: this,
5332
5497
  C: (f, a) => f(...a)
@@ -5341,32 +5506,32 @@ var ServiceContext = class extends import_context12.Resource {
5341
5506
  await this._initialize(ctx);
5342
5507
  }
5343
5508
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
5344
- (0, import_log14.log)("loaded persistent invitations", {
5509
+ (0, import_log15.log)("loaded persistent invitations", {
5345
5510
  count: loadedInvitations.invitations?.length
5346
5511
  }, {
5347
- F: __dxlog_file17,
5512
+ F: __dxlog_file18,
5348
5513
  L: 166,
5349
5514
  S: this,
5350
5515
  C: (f, a) => f(...a)
5351
5516
  });
5352
- import_log14.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
5517
+ import_log15.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
5353
5518
  id: this._instanceId
5354
5519
  }), {
5355
- F: __dxlog_file17,
5520
+ F: __dxlog_file18,
5356
5521
  L: 168,
5357
5522
  S: this,
5358
5523
  C: (f, a) => f(...a)
5359
5524
  });
5360
- (0, import_log14.log)("opened", void 0, {
5361
- F: __dxlog_file17,
5525
+ (0, import_log15.log)("opened", void 0, {
5526
+ F: __dxlog_file18,
5362
5527
  L: 169,
5363
5528
  S: this,
5364
5529
  C: (f, a) => f(...a)
5365
5530
  });
5366
5531
  }
5367
5532
  async _close(ctx) {
5368
- (0, import_log14.log)("closing...", void 0, {
5369
- F: __dxlog_file17,
5533
+ (0, import_log15.log)("closing...", void 0, {
5534
+ F: __dxlog_file18,
5370
5535
  L: 173,
5371
5536
  S: this,
5372
5537
  C: (f, a) => f(...a)
@@ -5382,8 +5547,8 @@ var ServiceContext = class extends import_context12.Resource {
5382
5547
  await this.echoHost.close(ctx);
5383
5548
  await this.networkManager.close();
5384
5549
  await this.signalManager.close();
5385
- (0, import_log14.log)("closed", void 0, {
5386
- F: __dxlog_file17,
5550
+ (0, import_log15.log)("closed", void 0, {
5551
+ F: __dxlog_file18,
5387
5552
  L: 185,
5388
5553
  S: this,
5389
5554
  C: (f, a) => f(...a)
@@ -5391,13 +5556,13 @@ var ServiceContext = class extends import_context12.Resource {
5391
5556
  }
5392
5557
  async createIdentity(params = {}) {
5393
5558
  const identity = await this.identityManager.createIdentity(params);
5394
- await this._initialize(new import_context12.Context());
5559
+ await this._initialize(new import_context13.Context());
5395
5560
  return identity;
5396
5561
  }
5397
5562
  getInvitationHandler(invitation) {
5398
5563
  const factory = this._handlerFactories.get(invitation.kind);
5399
5564
  (0, import_invariant16.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
5400
- F: __dxlog_file17,
5565
+ F: __dxlog_file18,
5401
5566
  L: 196,
5402
5567
  S: this,
5403
5568
  A: [
@@ -5417,7 +5582,7 @@ var ServiceContext = class extends import_context12.Resource {
5417
5582
  }
5418
5583
  async _acceptIdentity(params) {
5419
5584
  const identity = await this.identityManager.acceptIdentity(params);
5420
- await this._initialize(new import_context12.Context());
5585
+ await this._initialize(new import_context13.Context());
5421
5586
  return identity;
5422
5587
  }
5423
5588
  async _checkStorageVersion() {
@@ -5428,8 +5593,8 @@ var ServiceContext = class extends import_context12.Resource {
5428
5593
  }
5429
5594
  // Called when identity is created.
5430
5595
  async _initialize(ctx) {
5431
- (0, import_log14.log)("initializing spaces...", void 0, {
5432
- F: __dxlog_file17,
5596
+ (0, import_log15.log)("initializing spaces...", void 0, {
5597
+ F: __dxlog_file18,
5433
5598
  L: 227,
5434
5599
  S: this,
5435
5600
  C: (f, a) => f(...a)
@@ -5450,9 +5615,9 @@ var ServiceContext = class extends import_context12.Resource {
5450
5615
  };
5451
5616
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.echoHost, this.invitationsManager, this._runtimeParams);
5452
5617
  await this.dataSpaceManager.open();
5453
- this._handlerFactories.set(import_services14.Invitation.Kind.SPACE, (invitation) => {
5618
+ this._handlerFactories.set(import_services15.Invitation.Kind.SPACE, (invitation) => {
5454
5619
  (0, import_invariant16.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
5455
- F: __dxlog_file17,
5620
+ F: __dxlog_file18,
5456
5621
  L: 252,
5457
5622
  S: this,
5458
5623
  A: [
@@ -5465,7 +5630,7 @@ var ServiceContext = class extends import_context12.Resource {
5465
5630
  this.initialized.wake();
5466
5631
  this._deviceSpaceSync = {
5467
5632
  processCredential: async (credential) => {
5468
- const assertion = (0, import_credentials19.getCredentialAssertion)(credential);
5633
+ const assertion = (0, import_credentials20.getCredentialAssertion)(credential);
5469
5634
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
5470
5635
  return;
5471
5636
  }
@@ -5473,10 +5638,10 @@ var ServiceContext = class extends import_context12.Resource {
5473
5638
  return;
5474
5639
  }
5475
5640
  if (!this.dataSpaceManager) {
5476
- (0, import_log14.log)("dataSpaceManager not initialized yet, ignoring space admission", {
5641
+ (0, import_log15.log)("dataSpaceManager not initialized yet, ignoring space admission", {
5477
5642
  details: assertion
5478
5643
  }, {
5479
- F: __dxlog_file17,
5644
+ F: __dxlog_file18,
5480
5645
  L: 268,
5481
5646
  S: this,
5482
5647
  C: (f, a) => f(...a)
@@ -5484,10 +5649,10 @@ var ServiceContext = class extends import_context12.Resource {
5484
5649
  return;
5485
5650
  }
5486
5651
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
5487
- (0, import_log14.log)("space already exists, ignoring space admission", {
5652
+ (0, import_log15.log)("space already exists, ignoring space admission", {
5488
5653
  details: assertion
5489
5654
  }, {
5490
- F: __dxlog_file17,
5655
+ F: __dxlog_file18,
5491
5656
  L: 272,
5492
5657
  S: this,
5493
5658
  C: (f, a) => f(...a)
@@ -5495,10 +5660,10 @@ var ServiceContext = class extends import_context12.Resource {
5495
5660
  return;
5496
5661
  }
5497
5662
  try {
5498
- (0, import_log14.log)("accepting space recorded in halo", {
5663
+ (0, import_log15.log)("accepting space recorded in halo", {
5499
5664
  details: assertion
5500
5665
  }, {
5501
- F: __dxlog_file17,
5666
+ F: __dxlog_file18,
5502
5667
  L: 277,
5503
5668
  S: this,
5504
5669
  C: (f, a) => f(...a)
@@ -5508,8 +5673,8 @@ var ServiceContext = class extends import_context12.Resource {
5508
5673
  genesisFeedKey: assertion.genesisFeedKey
5509
5674
  });
5510
5675
  } catch (err) {
5511
- import_log14.log.catch(err, void 0, {
5512
- F: __dxlog_file17,
5676
+ import_log15.log.catch(err, void 0, {
5677
+ F: __dxlog_file18,
5513
5678
  L: 283,
5514
5679
  S: this,
5515
5680
  C: (f, a) => f(...a)
@@ -5562,7 +5727,7 @@ function _ts_decorate7(decorators, target, key, desc) {
5562
5727
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5563
5728
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5564
5729
  }
5565
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
5730
+ var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
5566
5731
  var Lock = class {
5567
5732
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
5568
5733
  this._lockPath = lockPath;
@@ -5573,16 +5738,16 @@ var Lock = class {
5573
5738
  return this._lockPath;
5574
5739
  }
5575
5740
  async acquire() {
5576
- (0, import_log15.log)("acquiring lock...", void 0, {
5577
- F: __dxlog_file18,
5741
+ (0, import_log16.log)("acquiring lock...", void 0, {
5742
+ F: __dxlog_file19,
5578
5743
  L: 32,
5579
5744
  S: this,
5580
5745
  C: (f, a) => f(...a)
5581
5746
  });
5582
5747
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
5583
5748
  await this._onAcquire?.();
5584
- (0, import_log15.log)("acquired lock", void 0, {
5585
- F: __dxlog_file18,
5749
+ (0, import_log16.log)("acquired lock", void 0, {
5750
+ F: __dxlog_file19,
5586
5751
  L: 37,
5587
5752
  S: this,
5588
5753
  C: (f, a) => f(...a)
@@ -5591,7 +5756,7 @@ var Lock = class {
5591
5756
  async release() {
5592
5757
  await this._onRelease?.();
5593
5758
  (0, import_invariant17.invariant)(this._fileHandle, "Lock is not acquired", {
5594
- F: __dxlog_file18,
5759
+ F: __dxlog_file19,
5595
5760
  L: 42,
5596
5761
  S: this,
5597
5762
  A: [
@@ -5603,11 +5768,11 @@ var Lock = class {
5603
5768
  }
5604
5769
  };
5605
5770
  _ts_decorate7([
5606
- import_log15.logInfo
5771
+ import_log16.logInfo
5607
5772
  ], Lock.prototype, "lockKey", null);
5608
5773
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
5609
5774
  var getRootPath = (config) => {
5610
- const { dataRoot = (0, import_util10.isNode)() ? import_client_protocol5.DX_DATA : "dxos/storage" } = config ?? {};
5775
+ const { dataRoot = (0, import_util10.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
5611
5776
  return `${dataRoot}/`;
5612
5777
  };
5613
5778
  var isPersistent = (config) => {
@@ -5658,12 +5823,12 @@ var toStorageType = (type) => {
5658
5823
  };
5659
5824
  var createLevel = async (config) => {
5660
5825
  const persistent = isPersistent(config);
5661
- const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys13.PublicKey.random().toHex()}`;
5826
+ const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys14.PublicKey.random().toHex()}`;
5662
5827
  const level = (0, import_kv_store.createLevel)(storagePath);
5663
5828
  await level.open();
5664
5829
  return level;
5665
5830
  };
5666
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
5831
+ var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
5667
5832
  var DevicesServiceImpl = class {
5668
5833
  constructor(_identityManager) {
5669
5834
  this._identityManager = _identityManager;
@@ -5681,7 +5846,7 @@ var DevicesServiceImpl = class {
5681
5846
  });
5682
5847
  } else {
5683
5848
  (0, import_invariant19.invariant)(this._identityManager.identity?.presence, "presence not present", {
5684
- F: __dxlog_file19,
5849
+ F: __dxlog_file20,
5685
5850
  L: 32,
5686
5851
  S: this,
5687
5852
  A: [
@@ -5696,9 +5861,9 @@ var DevicesServiceImpl = class {
5696
5861
  const peerState = peers.find((peer) => peer.identityKey.equals(key));
5697
5862
  return {
5698
5863
  deviceKey: key,
5699
- kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services16.DeviceKind.CURRENT : import_services16.DeviceKind.TRUSTED,
5864
+ kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services17.DeviceKind.CURRENT : import_services17.DeviceKind.TRUSTED,
5700
5865
  profile,
5701
- presence: isMe ? import_services16.Device.PresenceState.ONLINE : peerState ? import_services16.Device.PresenceState.ONLINE : import_services16.Device.PresenceState.OFFLINE
5866
+ presence: isMe ? import_services17.Device.PresenceState.ONLINE : peerState ? import_services17.Device.PresenceState.ONLINE : import_services17.Device.PresenceState.OFFLINE
5702
5867
  };
5703
5868
  })
5704
5869
  });
@@ -5747,7 +5912,7 @@ var DiagnosticsCollector = class {
5747
5912
  }
5748
5913
  static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
5749
5914
  const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
5750
- keys: options.humanize ? import_services17.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services17.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
5915
+ keys: options.humanize ? import_services18.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services18.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
5751
5916
  }, {
5752
5917
  timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
5753
5918
  });
@@ -5762,7 +5927,7 @@ var DiagnosticsCollector = class {
5762
5927
  client: clientDiagnostics,
5763
5928
  broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
5764
5929
  };
5765
- return JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)(options)));
5930
+ return JSON.parse(JSON.stringify(diagnostics, (0, import_util11.jsonKeyReplacer)(options)));
5766
5931
  }
5767
5932
  };
5768
5933
  var findSystemServiceProvider = () => {
@@ -5772,35 +5937,35 @@ var findSystemServiceProvider = () => {
5772
5937
  };
5773
5938
  var findConfigs = () => {
5774
5939
  const configs = import_tracing10.TRACE_PROCESSOR.findResourcesByAnnotation(import_config3.ConfigResource);
5775
- return configs.map((r) => r.instance.deref()).filter(import_util12.nonNullable);
5940
+ return configs.map((r) => r.instance.deref()).filter(import_util11.nonNullable);
5776
5941
  };
5777
5942
  var LoggingServiceImpl = class {
5778
5943
  constructor() {
5779
5944
  this._logs = new import_async20.Event();
5780
5945
  this._started = Date.now();
5781
- this._sessionId = import_keys16.PublicKey.random().toHex();
5946
+ this._sessionId = import_keys17.PublicKey.random().toHex();
5782
5947
  this._logProcessor = (_config, entry2) => {
5783
5948
  this._logs.emit(entry2);
5784
5949
  };
5785
5950
  }
5786
5951
  async open() {
5787
- import_log17.log.runtimeConfig.processors.push(this._logProcessor);
5952
+ import_log18.log.runtimeConfig.processors.push(this._logProcessor);
5788
5953
  }
5789
5954
  async close() {
5790
- const index = import_log17.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
5791
- import_log17.log.runtimeConfig.processors.splice(index, 1);
5955
+ const index = import_log18.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
5956
+ import_log18.log.runtimeConfig.processors.splice(index, 1);
5792
5957
  }
5793
5958
  async controlMetrics({ reset, record }) {
5794
5959
  if (reset) {
5795
- import_util14.tracer.clear();
5960
+ import_util13.tracer.clear();
5796
5961
  }
5797
5962
  if (record === true) {
5798
- import_util14.tracer.start();
5963
+ import_util13.tracer.start();
5799
5964
  } else if (record === false) {
5800
- import_util14.tracer.stop();
5965
+ import_util13.tracer.stop();
5801
5966
  }
5802
5967
  return {
5803
- recording: import_util14.tracer.recording
5968
+ recording: import_util13.tracer.recording
5804
5969
  };
5805
5970
  }
5806
5971
  /**
@@ -5808,10 +5973,10 @@ var LoggingServiceImpl = class {
5808
5973
  */
5809
5974
  queryMetrics({ interval = 5e3 }) {
5810
5975
  const getNumericalValues = (key) => {
5811
- const events = import_util14.tracer.get(key) ?? [];
5976
+ const events = import_util13.tracer.get(key) ?? [];
5812
5977
  return {
5813
5978
  key,
5814
- stats: (0, import_util14.numericalValues)(events, "duration")
5979
+ stats: (0, import_util13.numericalValues)(events, "duration")
5815
5980
  };
5816
5981
  };
5817
5982
  return new import_codec_protobuf13.Stream(({ next }) => {
@@ -5849,7 +6014,7 @@ var LoggingServiceImpl = class {
5849
6014
  }
5850
6015
  const record = {
5851
6016
  ...entry2,
5852
- context: (0, import_util14.jsonify)((0, import_log17.getContextFromEntry)(entry2)),
6017
+ context: (0, import_util13.jsonify)((0, import_log18.getContextFromEntry)(entry2)),
5853
6018
  timestamp: /* @__PURE__ */ new Date(),
5854
6019
  meta: {
5855
6020
  // TODO(dmaretskyi): Fix proto.
@@ -5858,7 +6023,7 @@ var LoggingServiceImpl = class {
5858
6023
  scope: {
5859
6024
  hostSessionId: this._sessionId,
5860
6025
  uptimeSeconds: (Date.now() - this._started) / 1e3,
5861
- name: (0, import_util14.getDebugName)(entry2.meta?.S)
6026
+ name: (0, import_util13.getDebugName)(entry2.meta?.S)
5862
6027
  }
5863
6028
  }
5864
6029
  };
@@ -5875,16 +6040,16 @@ var LoggingServiceImpl = class {
5875
6040
  };
5876
6041
  var matchFilter = (filter, level, path2, options) => {
5877
6042
  switch (options) {
5878
- case import_services18.QueryLogsRequest.MatchingOptions.INCLUSIVE:
6043
+ case import_services19.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5879
6044
  return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
5880
- case import_services18.QueryLogsRequest.MatchingOptions.EXPLICIT:
6045
+ case import_services19.QueryLogsRequest.MatchingOptions.EXPLICIT:
5881
6046
  return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
5882
6047
  }
5883
6048
  };
5884
6049
  var shouldLog = (entry2, request) => {
5885
- const options = request.options ?? import_services18.QueryLogsRequest.MatchingOptions.INCLUSIVE;
6050
+ const options = request.options ?? import_services19.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5886
6051
  if (request.filters === void 0) {
5887
- return options === import_services18.QueryLogsRequest.MatchingOptions.INCLUSIVE;
6052
+ return options === import_services19.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5888
6053
  } else {
5889
6054
  return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
5890
6055
  }
@@ -5939,9 +6104,9 @@ var SystemServiceImpl = class {
5939
6104
  const diagnostics = await this._getDiagnostics();
5940
6105
  return {
5941
6106
  timestamp: /* @__PURE__ */ new Date(),
5942
- diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util15.jsonKeyReplacer)({
5943
- truncate: keys === import_services19.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
5944
- humanize: keys === import_services19.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
6107
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util14.jsonKeyReplacer)({
6108
+ truncate: keys === import_services20.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
6109
+ humanize: keys === import_services20.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
5945
6110
  })))
5946
6111
  };
5947
6112
  }
@@ -5982,7 +6147,7 @@ function _ts_decorate8(decorators, target, key, desc) {
5982
6147
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5983
6148
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5984
6149
  }
5985
- var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6150
+ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
5986
6151
  var ClientServicesHost = class {
5987
6152
  constructor({
5988
6153
  config,
@@ -6002,7 +6167,7 @@ var ClientServicesHost = class {
6002
6167
  this._storage = storage;
6003
6168
  this._level = level;
6004
6169
  this._callbacks = callbacks;
6005
- this._runtimeParams = runtimeParams;
6170
+ this._runtimeParams = runtimeParams ?? {};
6006
6171
  if (config) {
6007
6172
  this.initialize({
6008
6173
  config,
@@ -6015,7 +6180,7 @@ var ClientServicesHost = class {
6015
6180
  lockKey,
6016
6181
  onAcquire: () => {
6017
6182
  if (!this._opening) {
6018
- void this.open(new import_context13.Context());
6183
+ void this.open(new import_context14.Context());
6019
6184
  }
6020
6185
  },
6021
6186
  onRelease: () => this.close()
@@ -6024,14 +6189,14 @@ var ClientServicesHost = class {
6024
6189
  this._systemService = new SystemServiceImpl({
6025
6190
  config: () => this._config,
6026
6191
  statusUpdate: this._statusUpdate,
6027
- getCurrentStatus: () => this.isOpen ? import_services15.SystemStatus.ACTIVE : import_services15.SystemStatus.INACTIVE,
6192
+ getCurrentStatus: () => this.isOpen ? import_services16.SystemStatus.ACTIVE : import_services16.SystemStatus.INACTIVE,
6028
6193
  getDiagnostics: () => {
6029
6194
  return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
6030
6195
  },
6031
6196
  onUpdateStatus: async (status) => {
6032
- if (!this.isOpen && status === import_services15.SystemStatus.ACTIVE) {
6197
+ if (!this.isOpen && status === import_services16.SystemStatus.ACTIVE) {
6033
6198
  await this._resourceLock?.acquire();
6034
- } else if (this.isOpen && status === import_services15.SystemStatus.INACTIVE) {
6199
+ } else if (this.isOpen && status === import_services16.SystemStatus.INACTIVE) {
6035
6200
  await this._resourceLock?.release();
6036
6201
  }
6037
6202
  },
@@ -6041,7 +6206,7 @@ var ClientServicesHost = class {
6041
6206
  });
6042
6207
  this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
6043
6208
  this._loggingService = new LoggingServiceImpl();
6044
- this._serviceRegistry = new ServiceRegistry(import_client_protocol6.clientServiceBundle, {
6209
+ this._serviceRegistry = new ServiceRegistry(import_client_protocol7.clientServiceBundle, {
6045
6210
  SystemService: this._systemService,
6046
6211
  TracingService: this._tracingService
6047
6212
  });
@@ -6071,24 +6236,24 @@ var ClientServicesHost = class {
6071
6236
  */
6072
6237
  initialize({ config, ...options }) {
6073
6238
  (0, import_invariant18.invariant)(!this._open, "service host is open", {
6074
- F: __dxlog_file20,
6075
- L: 189,
6239
+ F: __dxlog_file21,
6240
+ L: 186,
6076
6241
  S: this,
6077
6242
  A: [
6078
6243
  "!this._open",
6079
6244
  "'service host is open'"
6080
6245
  ]
6081
6246
  });
6082
- (0, import_log16.log)("initializing...", void 0, {
6083
- F: __dxlog_file20,
6084
- L: 190,
6247
+ (0, import_log17.log)("initializing...", void 0, {
6248
+ F: __dxlog_file21,
6249
+ L: 187,
6085
6250
  S: this,
6086
6251
  C: (f, a) => f(...a)
6087
6252
  });
6088
6253
  if (config) {
6089
6254
  (0, import_invariant18.invariant)(!this._config, "config already set", {
6090
- F: __dxlog_file20,
6091
- L: 193,
6255
+ F: __dxlog_file21,
6256
+ L: 190,
6092
6257
  S: this,
6093
6258
  A: [
6094
6259
  "!this._config",
@@ -6101,9 +6266,9 @@ var ClientServicesHost = class {
6101
6266
  }
6102
6267
  }
6103
6268
  if (!options.signalManager) {
6104
- import_log16.log.warn("running signaling without telemetry metadata.", void 0, {
6105
- F: __dxlog_file20,
6106
- L: 201,
6269
+ import_log17.log.warn("running signaling without telemetry metadata.", void 0, {
6270
+ F: __dxlog_file21,
6271
+ L: 198,
6107
6272
  S: this,
6108
6273
  C: (f, a) => f(...a)
6109
6274
  });
@@ -6113,8 +6278,8 @@ var ClientServicesHost = class {
6113
6278
  }), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
6114
6279
  this._signalManager = signalManager;
6115
6280
  (0, import_invariant18.invariant)(!this._networkManager, "network manager already set", {
6116
- F: __dxlog_file20,
6117
- L: 212,
6281
+ F: __dxlog_file21,
6282
+ L: 209,
6118
6283
  S: this,
6119
6284
  A: [
6120
6285
  "!this._networkManager",
@@ -6126,9 +6291,9 @@ var ClientServicesHost = class {
6126
6291
  transportFactory,
6127
6292
  signalManager
6128
6293
  });
6129
- (0, import_log16.log)("initialized", void 0, {
6130
- F: __dxlog_file20,
6131
- L: 219,
6294
+ (0, import_log17.log)("initialized", void 0, {
6295
+ F: __dxlog_file21,
6296
+ L: 216,
6132
6297
  S: this,
6133
6298
  C: (f, a) => f(...a)
6134
6299
  });
@@ -6137,18 +6302,18 @@ var ClientServicesHost = class {
6137
6302
  if (this._open) {
6138
6303
  return;
6139
6304
  }
6140
- const traceId = import_keys14.PublicKey.random().toHex();
6141
- import_log16.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
6305
+ const traceId = import_keys15.PublicKey.random().toHex();
6306
+ import_log17.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
6142
6307
  id: traceId
6143
6308
  }), {
6144
- F: __dxlog_file20,
6145
- L: 230,
6309
+ F: __dxlog_file21,
6310
+ L: 227,
6146
6311
  S: this,
6147
6312
  C: (f, a) => f(...a)
6148
6313
  });
6149
6314
  (0, import_invariant18.invariant)(this._config, "config not set", {
6150
- F: __dxlog_file20,
6151
- L: 232,
6315
+ F: __dxlog_file21,
6316
+ L: 229,
6152
6317
  S: this,
6153
6318
  A: [
6154
6319
  "this._config",
@@ -6156,8 +6321,8 @@ var ClientServicesHost = class {
6156
6321
  ]
6157
6322
  });
6158
6323
  (0, import_invariant18.invariant)(this._storage, "storage not set", {
6159
- F: __dxlog_file20,
6160
- L: 233,
6324
+ F: __dxlog_file21,
6325
+ L: 230,
6161
6326
  S: this,
6162
6327
  A: [
6163
6328
  "this._storage",
@@ -6165,8 +6330,8 @@ var ClientServicesHost = class {
6165
6330
  ]
6166
6331
  });
6167
6332
  (0, import_invariant18.invariant)(this._signalManager, "signal manager not set", {
6168
- F: __dxlog_file20,
6169
- L: 234,
6333
+ F: __dxlog_file21,
6334
+ L: 231,
6170
6335
  S: this,
6171
6336
  A: [
6172
6337
  "this._signalManager",
@@ -6174,8 +6339,8 @@ var ClientServicesHost = class {
6174
6339
  ]
6175
6340
  });
6176
6341
  (0, import_invariant18.invariant)(this._networkManager, "network manager not set", {
6177
- F: __dxlog_file20,
6178
- L: 235,
6342
+ F: __dxlog_file21,
6343
+ L: 232,
6179
6344
  S: this,
6180
6345
  A: [
6181
6346
  "this._networkManager",
@@ -6183,11 +6348,11 @@ var ClientServicesHost = class {
6183
6348
  ]
6184
6349
  });
6185
6350
  this._opening = true;
6186
- (0, import_log16.log)("opening...", {
6351
+ (0, import_log17.log)("opening...", {
6187
6352
  lockKey: this._resourceLock?.lockKey
6188
6353
  }, {
6189
- F: __dxlog_file20,
6190
- L: 238,
6354
+ F: __dxlog_file21,
6355
+ L: 235,
6191
6356
  S: this,
6192
6357
  C: (f, a) => f(...a)
6193
6358
  });
@@ -6198,9 +6363,10 @@ var ClientServicesHost = class {
6198
6363
  await this._level.open();
6199
6364
  await this._loggingService.open();
6200
6365
  this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
6366
+ const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
6201
6367
  this._serviceRegistry.setServices({
6202
6368
  SystemService: this._systemService,
6203
- IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
6369
+ IdentityService: identityService,
6204
6370
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
6205
6371
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
6206
6372
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
@@ -6220,12 +6386,13 @@ var ClientServicesHost = class {
6220
6386
  })
6221
6387
  });
6222
6388
  await this._serviceContext.open(ctx);
6389
+ await identityService.open();
6223
6390
  const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
6224
6391
  if (devtoolsProxy) {
6225
6392
  this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
6226
6393
  url: devtoolsProxy,
6227
6394
  requested: {},
6228
- exposed: import_client_protocol6.clientServiceBundle,
6395
+ exposed: import_client_protocol7.clientServiceBundle,
6229
6396
  handlers: this.services
6230
6397
  });
6231
6398
  void this._devtoolsProxy.open();
@@ -6235,18 +6402,18 @@ var ClientServicesHost = class {
6235
6402
  this._open = true;
6236
6403
  this._statusUpdate.emit();
6237
6404
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6238
- (0, import_log16.log)("opened", {
6405
+ (0, import_log17.log)("opened", {
6239
6406
  deviceKey
6240
6407
  }, {
6241
- F: __dxlog_file20,
6408
+ F: __dxlog_file21,
6242
6409
  L: 314,
6243
6410
  S: this,
6244
6411
  C: (f, a) => f(...a)
6245
6412
  });
6246
- import_log16.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
6413
+ import_log17.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
6247
6414
  id: traceId
6248
6415
  }), {
6249
- F: __dxlog_file20,
6416
+ F: __dxlog_file21,
6250
6417
  L: 315,
6251
6418
  S: this,
6252
6419
  C: (f, a) => f(...a)
@@ -6257,10 +6424,10 @@ var ClientServicesHost = class {
6257
6424
  return;
6258
6425
  }
6259
6426
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6260
- (0, import_log16.log)("closing...", {
6427
+ (0, import_log17.log)("closing...", {
6261
6428
  deviceKey
6262
6429
  }, {
6263
- F: __dxlog_file20,
6430
+ F: __dxlog_file21,
6264
6431
  L: 326,
6265
6432
  S: this,
6266
6433
  C: (f, a) => f(...a)
@@ -6275,43 +6442,43 @@ var ClientServicesHost = class {
6275
6442
  await this._level?.close();
6276
6443
  this._open = false;
6277
6444
  this._statusUpdate.emit();
6278
- (0, import_log16.log)("closed", {
6445
+ (0, import_log17.log)("closed", {
6279
6446
  deviceKey
6280
6447
  }, {
6281
- F: __dxlog_file20,
6448
+ F: __dxlog_file21,
6282
6449
  L: 335,
6283
6450
  S: this,
6284
6451
  C: (f, a) => f(...a)
6285
6452
  });
6286
6453
  }
6287
6454
  async reset() {
6288
- const traceId = import_keys14.PublicKey.random().toHex();
6289
- import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
6455
+ const traceId = import_keys15.PublicKey.random().toHex();
6456
+ import_log17.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
6290
6457
  id: traceId
6291
6458
  }), {
6292
- F: __dxlog_file20,
6459
+ F: __dxlog_file21,
6293
6460
  L: 340,
6294
6461
  S: this,
6295
6462
  C: (f, a) => f(...a)
6296
6463
  });
6297
- import_log16.log.info("resetting...", void 0, {
6298
- F: __dxlog_file20,
6464
+ import_log17.log.info("resetting...", void 0, {
6465
+ F: __dxlog_file21,
6299
6466
  L: 342,
6300
6467
  S: this,
6301
6468
  C: (f, a) => f(...a)
6302
6469
  });
6303
6470
  await this._serviceContext?.close();
6304
6471
  await this._storage.reset();
6305
- import_log16.log.info("reset", void 0, {
6306
- F: __dxlog_file20,
6472
+ import_log17.log.info("reset", void 0, {
6473
+ F: __dxlog_file21,
6307
6474
  L: 345,
6308
6475
  S: this,
6309
6476
  C: (f, a) => f(...a)
6310
6477
  });
6311
- import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
6478
+ import_log17.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
6312
6479
  id: traceId
6313
6480
  }), {
6314
- F: __dxlog_file20,
6481
+ F: __dxlog_file21,
6315
6482
  L: 346,
6316
6483
  S: this,
6317
6484
  C: (f, a) => f(...a)
@@ -6321,38 +6488,6 @@ var ClientServicesHost = class {
6321
6488
  async _createIdentity(params) {
6322
6489
  const identity = await this._serviceContext.createIdentity(params);
6323
6490
  await this._serviceContext.initialized.wait();
6324
- const space = await this._serviceContext.dataSpaceManager.createSpace();
6325
- const automergeIndex = space.automergeSpaceState.rootUrl;
6326
- (0, import_invariant18.invariant)(automergeIndex, void 0, {
6327
- F: __dxlog_file20,
6328
- L: 358,
6329
- S: this,
6330
- A: [
6331
- "automergeIndex",
6332
- ""
6333
- ]
6334
- });
6335
- const document = this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
6336
- await document.whenReady();
6337
- const properties = {
6338
- system: {
6339
- type: (0, import_echo_protocol.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol6.PropertiesType))
6340
- },
6341
- data: {
6342
- [import_client_protocol6.defaultKey]: identity.identityKey.toHex()
6343
- },
6344
- meta: {
6345
- keys: []
6346
- }
6347
- };
6348
- const propertiesId = import_keys14.PublicKey.random().toHex();
6349
- document.change((doc) => {
6350
- (0, import_util11.assignDeep)(doc, [
6351
- "objects",
6352
- propertiesId
6353
- ], properties);
6354
- });
6355
- await this._serviceContext.echoHost.flush();
6356
6491
  return identity;
6357
6492
  }
6358
6493
  };
@@ -6414,4 +6549,4 @@ ClientServicesHost = _ts_decorate8([
6414
6549
  subscribeToSpaces,
6415
6550
  subscribeToSwarmInfo
6416
6551
  });
6417
- //# sourceMappingURL=chunk-NPYJIVOX.cjs.map
6552
+ //# sourceMappingURL=chunk-RQHBQWKH.cjs.map