@dxos/client-services 0.4.10-main.e158b1a → 0.4.10-main.e2d2318

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 (84) hide show
  1. package/dist/lib/browser/{chunk-VIHM6GWA.mjs → chunk-HAFART26.mjs} +872 -626
  2. package/dist/lib/browser/chunk-HAFART26.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +13 -3
  4. package/dist/lib/browser/index.mjs.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +11 -5
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-52FE74JI.cjs → chunk-5YDVC6TU.cjs} +835 -676
  9. package/dist/lib/node/chunk-5YDVC6TU.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +48 -38
  11. package/dist/lib/node/index.cjs.map +1 -1
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/packlets/testing/index.cjs +15 -9
  14. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  15. package/dist/types/src/index.d.ts +1 -0
  16. package/dist/types/src/index.d.ts.map +1 -1
  17. package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +5 -0
  18. package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -0
  19. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +5 -0
  20. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -0
  21. package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts +15 -0
  22. package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -0
  23. package/dist/types/src/packlets/{services → diagnostics}/diagnostics.d.ts +1 -1
  24. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -0
  25. package/dist/types/src/packlets/diagnostics/index.d.ts +4 -0
  26. package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -0
  27. package/dist/types/src/packlets/invitations/invitation-extension.d.ts +1 -0
  28. package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
  29. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -2
  30. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  31. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  32. package/dist/types/src/packlets/services/index.d.ts +1 -1
  33. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  34. package/dist/types/src/packlets/services/service-context.d.ts +7 -5
  35. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  36. package/dist/types/src/packlets/services/service-host.d.ts +5 -1
  37. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  38. package/dist/types/src/packlets/services/util.d.ts +1 -0
  39. package/dist/types/src/packlets/services/util.d.ts.map +1 -1
  40. package/dist/types/src/packlets/storage/index.d.ts +1 -0
  41. package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
  42. package/dist/types/src/packlets/storage/level.d.ts +4 -0
  43. package/dist/types/src/packlets/storage/level.d.ts.map +1 -0
  44. package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
  45. package/dist/types/src/packlets/storage/util.d.ts +4 -0
  46. package/dist/types/src/packlets/storage/util.d.ts.map +1 -0
  47. package/dist/types/src/packlets/system/system-service.d.ts +1 -1
  48. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  49. package/dist/types/src/packlets/testing/test-builder.d.ts +5 -2
  50. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  51. package/dist/types/src/version.d.ts +1 -1
  52. package/package.json +36 -34
  53. package/src/index.ts +1 -0
  54. package/src/packlets/devices/devices-service.test.ts +1 -1
  55. package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +94 -0
  56. package/src/packlets/diagnostics/diagnostics-broadcast.ts +20 -0
  57. package/src/packlets/diagnostics/diagnostics-collector.ts +65 -0
  58. package/src/packlets/{services → diagnostics}/diagnostics.ts +2 -2
  59. package/src/packlets/diagnostics/index.ts +7 -0
  60. package/src/packlets/identity/identity-service.test.ts +1 -1
  61. package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
  62. package/src/packlets/invitations/invitation-extension.ts +28 -1
  63. package/src/packlets/invitations/invitations-handler.ts +73 -32
  64. package/src/packlets/invitations/invitations-service.ts +5 -5
  65. package/src/packlets/network/network-service.test.ts +1 -1
  66. package/src/packlets/services/automerge-host.test.ts +9 -3
  67. package/src/packlets/services/index.ts +1 -1
  68. package/src/packlets/services/service-context.test.ts +9 -6
  69. package/src/packlets/services/service-context.ts +12 -5
  70. package/src/packlets/services/service-host.ts +50 -14
  71. package/src/packlets/services/service-registry.test.ts +1 -1
  72. package/src/packlets/services/util.ts +2 -0
  73. package/src/packlets/spaces/data-space-manager.test.ts +4 -4
  74. package/src/packlets/spaces/spaces-service.test.ts +1 -1
  75. package/src/packlets/storage/index.ts +1 -0
  76. package/src/packlets/storage/level.ts +19 -0
  77. package/src/packlets/storage/storage.ts +3 -9
  78. package/src/packlets/storage/util.ts +19 -0
  79. package/src/packlets/system/system-service.ts +1 -1
  80. package/src/packlets/testing/test-builder.ts +23 -5
  81. package/src/version.ts +1 -1
  82. package/dist/lib/browser/chunk-VIHM6GWA.mjs.map +0 -7
  83. package/dist/lib/node/chunk-52FE74JI.cjs.map +0 -7
  84. package/dist/types/src/packlets/services/diagnostics.d.ts.map +0 -1
@@ -26,15 +26,17 @@ 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_52FE74JI_exports = {};
30
- __export(chunk_52FE74JI_exports, {
29
+ var chunk_5YDVC6TU_exports = {};
30
+ __export(chunk_5YDVC6TU_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
+ ClientServicesProviderResource: () => ClientServicesProviderResource,
33
34
  DataSpace: () => DataSpace,
34
35
  DataSpaceManager: () => DataSpaceManager,
35
36
  DeviceInvitationProtocol: () => DeviceInvitationProtocol,
36
37
  DevtoolsHostEvents: () => DevtoolsHostEvents,
37
38
  DevtoolsServiceImpl: () => DevtoolsServiceImpl,
39
+ DiagnosticsCollector: () => DiagnosticsCollector,
38
40
  Identity: () => Identity,
39
41
  IdentityManager: () => IdentityManager,
40
42
  IdentityServiceImpl: () => IdentityServiceImpl,
@@ -46,11 +48,14 @@ __export(chunk_52FE74JI_exports, {
46
48
  SpaceInvitationProtocol: () => SpaceInvitationProtocol,
47
49
  SpacesServiceImpl: () => SpacesServiceImpl,
48
50
  TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
51
+ createAdmissionKeypair: () => createAdmissionKeypair,
49
52
  createAuthProvider: () => createAuthProvider,
53
+ createCollectDiagnosticsBroadcastHandler: () => createCollectDiagnosticsBroadcastHandler,
54
+ createCollectDiagnosticsBroadcastSender: () => createCollectDiagnosticsBroadcastSender,
50
55
  createDiagnostics: () => createDiagnostics,
56
+ createLevel: () => createLevel,
51
57
  createStorageObjects: () => createStorageObjects,
52
58
  getNetworkPeers: () => getNetworkPeers,
53
- invitationExpired: () => invitationExpired,
54
59
  isLocked: () => isLocked,
55
60
  subscribeToFeedBlocks: () => subscribeToFeedBlocks,
56
61
  subscribeToFeeds: () => subscribeToFeeds,
@@ -60,7 +65,7 @@ __export(chunk_52FE74JI_exports, {
60
65
  subscribeToSpaces: () => subscribeToSpaces,
61
66
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
67
  });
63
- module.exports = __toCommonJS(chunk_52FE74JI_exports);
68
+ module.exports = __toCommonJS(chunk_5YDVC6TU_exports);
64
69
  var import_async = require("@dxos/async");
65
70
  var import_codec_protobuf = require("@dxos/codec-protobuf");
66
71
  var import_feed_store = require("@dxos/feed-store");
@@ -115,6 +120,7 @@ var import_async7 = require("@dxos/async");
115
120
  var import_client_protocol2 = require("@dxos/client-protocol");
116
121
  var import_context4 = require("@dxos/context");
117
122
  var import_credentials7 = require("@dxos/credentials");
123
+ var import_crypto = require("@dxos/crypto");
118
124
  var import_invariant5 = require("@dxos/invariant");
119
125
  var import_keys5 = require("@dxos/keys");
120
126
  var import_log4 = require("@dxos/log");
@@ -124,6 +130,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
124
130
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
125
131
  var import_async8 = require("@dxos/async");
126
132
  var import_context5 = require("@dxos/context");
133
+ var import_crypto2 = require("@dxos/crypto");
127
134
  var import_invariant6 = require("@dxos/invariant");
128
135
  var import_keys6 = require("@dxos/keys");
129
136
  var import_log5 = require("@dxos/log");
@@ -134,6 +141,7 @@ var import_teleport = require("@dxos/teleport");
134
141
  var import_async9 = require("@dxos/async");
135
142
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
136
143
  var import_context6 = require("@dxos/context");
144
+ var import_echo_pipeline = require("@dxos/echo-pipeline");
137
145
  var import_invariant7 = require("@dxos/invariant");
138
146
  var import_log6 = require("@dxos/log");
139
147
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
@@ -147,118 +155,127 @@ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
147
155
  var import_debug2 = require("@dxos/debug");
148
156
  var import_rpc = require("@dxos/rpc");
149
157
  var import_tracing3 = require("@dxos/tracing");
150
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
151
- var import_credentials9 = require("@dxos/credentials");
152
- var import_invariant9 = require("@dxos/invariant");
153
- var import_protocols7 = require("@dxos/protocols");
154
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
155
- var import_tracing4 = require("@dxos/tracing");
156
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
157
158
  var import_async10 = require("@dxos/async");
158
159
  var import_client_protocol3 = require("@dxos/client-protocol");
159
160
  var import_context7 = require("@dxos/context");
160
161
  var import_debug3 = require("@dxos/debug");
161
162
  var import_echo_db = require("@dxos/echo-db");
162
- var import_echo_pipeline = require("@dxos/echo-pipeline");
163
163
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
164
- var import_invariant10 = require("@dxos/invariant");
164
+ var import_echo_pipeline3 = require("@dxos/echo-pipeline");
165
+ var import_invariant9 = require("@dxos/invariant");
165
166
  var import_keys7 = require("@dxos/keys");
166
167
  var import_log8 = require("@dxos/log");
167
- var import_protocols8 = require("@dxos/protocols");
168
- var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
169
- var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
168
+ var import_protocols7 = require("@dxos/protocols");
169
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
170
+ var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
170
171
  var import_timeframe2 = require("@dxos/timeframe");
171
- var import_tracing5 = require("@dxos/tracing");
172
+ var import_tracing4 = require("@dxos/tracing");
172
173
  var import_util4 = require("@dxos/util");
173
174
  var import_async11 = require("@dxos/async");
174
- var import_credentials11 = require("@dxos/credentials");
175
+ var import_credentials10 = require("@dxos/credentials");
175
176
  var import_async12 = require("@dxos/async");
176
177
  var import_context8 = require("@dxos/context");
177
- var import_invariant11 = require("@dxos/invariant");
178
+ var import_invariant10 = require("@dxos/invariant");
178
179
  var import_keys8 = require("@dxos/keys");
179
180
  var import_log9 = require("@dxos/log");
180
- var import_protocols9 = require("@dxos/protocols");
181
+ var import_protocols8 = require("@dxos/protocols");
181
182
  var import_teleport2 = require("@dxos/teleport");
182
183
  var import_util5 = require("@dxos/util");
183
184
  var import_async13 = require("@dxos/async");
184
185
  var import_context9 = require("@dxos/context");
185
- var import_credentials12 = require("@dxos/credentials");
186
- var import_invariant12 = require("@dxos/invariant");
186
+ var import_credentials11 = require("@dxos/credentials");
187
+ var import_invariant11 = require("@dxos/invariant");
187
188
  var import_keys9 = require("@dxos/keys");
188
189
  var import_log10 = require("@dxos/log");
189
- var import_protocols10 = require("@dxos/protocols");
190
- var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
190
+ var import_protocols9 = require("@dxos/protocols");
191
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
191
192
  var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
192
193
  var import_util6 = require("@dxos/util");
193
- var import_credentials13 = require("@dxos/credentials");
194
+ var import_credentials12 = require("@dxos/credentials");
194
195
  var import_debug4 = require("@dxos/debug");
195
- var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
196
+ var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
196
197
  var import_timeframe3 = require("@dxos/timeframe");
197
198
  var import_async14 = require("@dxos/async");
198
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
199
+ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
199
200
  var import_debug5 = require("@dxos/debug");
200
- var import_invariant13 = require("@dxos/invariant");
201
+ var import_invariant12 = require("@dxos/invariant");
201
202
  var import_log11 = require("@dxos/log");
202
- var import_protocols11 = require("@dxos/protocols");
203
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
203
+ var import_protocols10 = require("@dxos/protocols");
204
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
204
205
  var import_async15 = require("@dxos/async");
205
206
  var import_context10 = require("@dxos/context");
206
- var import_credentials15 = require("@dxos/credentials");
207
+ var import_credentials14 = require("@dxos/credentials");
207
208
  var import_debug6 = require("@dxos/debug");
208
- var import_echo_pipeline3 = require("@dxos/echo-pipeline");
209
+ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
209
210
  var import_feed_store4 = require("@dxos/feed-store");
210
211
  var import_indexing = require("@dxos/indexing");
211
- var import_invariant14 = require("@dxos/invariant");
212
+ var import_invariant13 = require("@dxos/invariant");
212
213
  var import_keyring = require("@dxos/keyring");
213
214
  var import_keys10 = require("@dxos/keys");
214
215
  var import_log12 = require("@dxos/log");
215
- var import_protocols12 = require("@dxos/protocols");
216
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
216
+ var import_protocols11 = require("@dxos/protocols");
217
+ var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
217
218
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
218
- var import_tracing6 = require("@dxos/tracing");
219
+ var import_tracing5 = require("@dxos/tracing");
219
220
  var import_util7 = require("@dxos/util");
220
221
  var import_automerge = require("@dxos/automerge/automerge");
221
222
  var import_debug7 = require("@dxos/debug");
223
+ var import_protocols12 = require("@dxos/protocols");
224
+ var import_codec_protobuf11 = require("@dxos/codec-protobuf");
225
+ var import_credentials15 = require("@dxos/credentials");
226
+ var import_invariant14 = require("@dxos/invariant");
222
227
  var import_protocols13 = require("@dxos/protocols");
223
- var import_invariant15 = require("@dxos/invariant");
224
- var import_lock_file = require("@dxos/lock-file");
225
- var import_log13 = require("@dxos/log");
226
- var import_client_protocol4 = require("@dxos/client-protocol");
227
- var import_protocols14 = require("@dxos/protocols");
228
- var import_config = require("@dxos/protocols/proto/dxos/config");
229
- var import_random_access_storage = require("@dxos/random-access-storage");
228
+ var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
229
+ var import_tracing6 = require("@dxos/tracing");
230
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
231
+ var import_config = require("@dxos/config");
232
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
233
+ var import_tracing7 = require("@dxos/tracing");
230
234
  var import_util8 = require("@dxos/util");
231
235
  var import_async16 = require("@dxos/async");
232
- var import_client_protocol5 = require("@dxos/client-protocol");
236
+ var import_client_protocol4 = require("@dxos/client-protocol");
233
237
  var import_context11 = require("@dxos/context");
234
- var import_echo_pipeline4 = require("@dxos/echo-pipeline");
235
- var E = __toESM(require("@dxos/echo-schema"));
238
+ var import_echo_pipeline5 = require("@dxos/echo-pipeline");
236
239
  var import_echo_schema = require("@dxos/echo-schema");
237
240
  var import_indexing2 = require("@dxos/indexing");
238
- var import_invariant16 = require("@dxos/invariant");
241
+ var import_invariant15 = require("@dxos/invariant");
239
242
  var import_keys11 = require("@dxos/keys");
240
- var import_log14 = require("@dxos/log");
243
+ var import_log13 = require("@dxos/log");
241
244
  var import_messaging = require("@dxos/messaging");
242
245
  var import_network_manager2 = require("@dxos/network-manager");
243
- var import_protocols15 = require("@dxos/protocols");
244
- var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
245
- var import_tracing7 = require("@dxos/tracing");
246
+ var import_protocols14 = require("@dxos/protocols");
247
+ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
248
+ var import_tracing8 = require("@dxos/tracing");
246
249
  var import_util9 = require("@dxos/util");
247
250
  var import_websocket_rpc = require("@dxos/websocket-rpc");
248
251
  var import_async17 = require("@dxos/async");
249
252
  var import_codec_protobuf12 = require("@dxos/codec-protobuf");
253
+ var import_invariant16 = require("@dxos/invariant");
254
+ var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
250
255
  var import_invariant17 = require("@dxos/invariant");
251
- var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
256
+ var import_lock_file = require("@dxos/lock-file");
257
+ var import_log14 = require("@dxos/log");
252
258
  var import_async18 = require("@dxos/async");
253
259
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
254
260
  var import_keys12 = require("@dxos/keys");
255
261
  var import_log15 = require("@dxos/log");
256
- var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
262
+ var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
257
263
  var import_util10 = require("@dxos/util");
258
264
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
259
- var import_codec_protobuf15 = require("@dxos/codec-protobuf");
260
- var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
265
+ var import_protocols15 = require("@dxos/protocols");
266
+ var import_config2 = require("@dxos/protocols/proto/dxos/config");
267
+ var import_random_access_storage = require("@dxos/random-access-storage");
268
+ var import_client_protocol5 = require("@dxos/client-protocol");
269
+ var import_config3 = require("@dxos/protocols/proto/dxos/config");
261
270
  var import_util11 = require("@dxos/util");
271
+ var import_level = require("level");
272
+ var import_node_path = __toESM(require("node:path"));
273
+ var import_keys13 = require("@dxos/keys");
274
+ var import_codec_protobuf15 = require("@dxos/codec-protobuf");
275
+ var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
276
+ var import_util12 = require("@dxos/util");
277
+ var import_keys14 = require("@dxos/keys");
278
+ var import_util13 = require("@dxos/util");
262
279
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
263
280
  return new import_codec_protobuf.Stream(({ next }) => {
264
281
  const subscriptions = new import_async.EventSubscriptions();
@@ -1471,6 +1488,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1471
1488
  this._callbacks = _callbacks;
1472
1489
  this._ctx = new import_context5.Context();
1473
1490
  this._remoteOptionsTrigger = new import_async8.Trigger();
1491
+ this._challenge = void 0;
1474
1492
  this.invitation = void 0;
1475
1493
  this.guestProfile = void 0;
1476
1494
  this.authenticationPassed = false;
@@ -1485,7 +1503,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1485
1503
  options: async (options) => {
1486
1504
  (0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
1487
1505
  F: __dxlog_file6,
1488
- L: 87,
1506
+ L: 90,
1489
1507
  S: this,
1490
1508
  A: [
1491
1509
  "!this._remoteOptions",
@@ -1502,7 +1520,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1502
1520
  id: traceId
1503
1521
  }), {
1504
1522
  F: __dxlog_file6,
1505
- L: 96,
1523
+ L: 99,
1506
1524
  S: this,
1507
1525
  C: (f, a) => f(...a)
1508
1526
  });
@@ -1512,7 +1530,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1512
1530
  invitationId
1513
1531
  }, {
1514
1532
  F: __dxlog_file6,
1515
- L: 100,
1533
+ L: 103,
1516
1534
  S: this,
1517
1535
  C: (f, a) => f(...a)
1518
1536
  });
@@ -1526,7 +1544,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1526
1544
  guestProfile: profile
1527
1545
  }, {
1528
1546
  F: __dxlog_file6,
1529
- L: 109,
1547
+ L: 112,
1530
1548
  S: this,
1531
1549
  C: (f, a) => f(...a)
1532
1550
  });
@@ -1535,25 +1553,27 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1535
1553
  ...this.invitation,
1536
1554
  state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
1537
1555
  });
1556
+ this._challenge = this.invitation.authMethod === import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
1538
1557
  import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.end({
1539
1558
  id: traceId
1540
1559
  }), {
1541
1560
  F: __dxlog_file6,
1542
- L: 116,
1561
+ L: 122,
1543
1562
  S: this,
1544
1563
  C: (f, a) => f(...a)
1545
1564
  });
1546
1565
  return {
1547
- authMethod: this.invitation.authMethod
1566
+ authMethod: this.invitation.authMethod,
1567
+ challenge: this._challenge
1548
1568
  };
1549
1569
  },
1550
- authenticate: async ({ authCode: code }) => {
1570
+ authenticate: async ({ authCode: code, signedChallenge }) => {
1551
1571
  const traceId = import_keys6.PublicKey.random().toHex();
1552
1572
  import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.begin({
1553
1573
  id: traceId
1554
1574
  }), {
1555
1575
  F: __dxlog_file6,
1556
- L: 124,
1576
+ L: 131,
1557
1577
  S: this,
1558
1578
  C: (f, a) => f(...a)
1559
1579
  });
@@ -1561,14 +1581,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1561
1581
  authCode: code
1562
1582
  }, {
1563
1583
  F: __dxlog_file6,
1564
- L: 125,
1584
+ L: 132,
1565
1585
  S: this,
1566
1586
  C: (f, a) => f(...a)
1567
1587
  });
1568
1588
  let status = import_invitations2.AuthenticationResponse.Status.OK;
1569
1589
  (0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
1570
1590
  F: __dxlog_file6,
1571
- L: 128,
1591
+ L: 135,
1572
1592
  S: this,
1573
1593
  A: [
1574
1594
  "this.invitation",
@@ -1579,7 +1599,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1579
1599
  case import_services4.Invitation.AuthMethod.NONE: {
1580
1600
  (0, import_log5.log)("authentication not required", void 0, {
1581
1601
  F: __dxlog_file6,
1582
- L: 131,
1602
+ L: 138,
1583
1603
  S: this,
1584
1604
  C: (f, a) => f(...a)
1585
1605
  });
@@ -1599,12 +1619,25 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1599
1619
  }
1600
1620
  break;
1601
1621
  }
1622
+ case import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
1623
+ if (!this.invitation.guestKeypair) {
1624
+ status = import_invitations2.AuthenticationResponse.Status.INTERNAL_ERROR;
1625
+ break;
1626
+ }
1627
+ const isSignatureValid = this._challenge && (0, import_crypto2.verify)(this._challenge, Buffer.from(signedChallenge ?? []), this.invitation.guestKeypair.publicKey.asBuffer());
1628
+ if (isSignatureValid) {
1629
+ this.authenticationPassed = true;
1630
+ } else {
1631
+ status = import_invitations2.AuthenticationResponse.Status.INVALID_SIGNATURE;
1632
+ }
1633
+ break;
1634
+ }
1602
1635
  default: {
1603
1636
  import_log5.log.error("invalid authentication method", {
1604
1637
  authMethod: this.invitation.authMethod
1605
1638
  }, {
1606
1639
  F: __dxlog_file6,
1607
- L: 149,
1640
+ L: 176,
1608
1641
  S: this,
1609
1642
  C: (f, a) => f(...a)
1610
1643
  });
@@ -1619,7 +1652,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1619
1652
  }
1620
1653
  }), {
1621
1654
  F: __dxlog_file6,
1622
- L: 155,
1655
+ L: 182,
1623
1656
  S: this,
1624
1657
  C: (f, a) => f(...a)
1625
1658
  });
@@ -1633,14 +1666,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1633
1666
  id: traceId
1634
1667
  }), {
1635
1668
  F: __dxlog_file6,
1636
- L: 161,
1669
+ L: 188,
1637
1670
  S: this,
1638
1671
  C: (f, a) => f(...a)
1639
1672
  });
1640
1673
  try {
1641
1674
  (0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
1642
1675
  F: __dxlog_file6,
1643
- L: 164,
1676
+ L: 191,
1644
1677
  S: this,
1645
1678
  A: [
1646
1679
  "this.invitation",
@@ -1655,7 +1688,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1655
1688
  id: traceId
1656
1689
  }), {
1657
1690
  F: __dxlog_file6,
1658
- L: 172,
1691
+ L: 199,
1659
1692
  S: this,
1660
1693
  C: (f, a) => f(...a)
1661
1694
  });
@@ -1712,7 +1745,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1712
1745
  options: async (options) => {
1713
1746
  (0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
1714
1747
  F: __dxlog_file6,
1715
- L: 239,
1748
+ L: 266,
1716
1749
  S: this,
1717
1750
  A: [
1718
1751
  "!this._remoteOptions",
@@ -1739,7 +1772,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1739
1772
  try {
1740
1773
  (0, import_log5.log)("begin options", void 0, {
1741
1774
  F: __dxlog_file6,
1742
- L: 260,
1775
+ L: 287,
1743
1776
  S: this,
1744
1777
  C: (f, a) => f(...a)
1745
1778
  });
@@ -1751,7 +1784,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1751
1784
  }));
1752
1785
  (0, import_log5.log)("end options", void 0, {
1753
1786
  F: __dxlog_file6,
1754
- L: 263,
1787
+ L: 290,
1755
1788
  S: this,
1756
1789
  C: (f, a) => f(...a)
1757
1790
  });
@@ -1765,7 +1798,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1765
1798
  } catch (err) {
1766
1799
  (0, import_log5.log)("openError", err, {
1767
1800
  F: __dxlog_file6,
1768
- L: 273,
1801
+ L: 300,
1769
1802
  S: this,
1770
1803
  C: (f, a) => f(...a)
1771
1804
  });
@@ -1775,7 +1808,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1775
1808
  async onClose() {
1776
1809
  (0, import_log5.log)("onClose", void 0, {
1777
1810
  F: __dxlog_file6,
1778
- L: 279,
1811
+ L: 306,
1779
1812
  S: this,
1780
1813
  C: (f, a) => f(...a)
1781
1814
  });
@@ -1792,11 +1825,11 @@ var InvitationsHandler = class {
1792
1825
  this._networkManager = _networkManager;
1793
1826
  }
1794
1827
  createInvitation(protocol, options) {
1795
- const { invitationId = import_keys5.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys5.PublicKey.random(), persistent = true, created = /* @__PURE__ */ new Date(), lifetime = 86400 } = options ?? {};
1828
+ const { invitationId = import_keys5.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys5.PublicKey.random(), persistent = options?.authMethod !== import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
1796
1829
  const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
1797
1830
  (0, import_invariant5.invariant)(protocol, void 0, {
1798
1831
  F: __dxlog_file7,
1799
- L: 84,
1832
+ L: 87,
1800
1833
  S: this,
1801
1834
  A: [
1802
1835
  "protocol",
@@ -1811,9 +1844,11 @@ var InvitationsHandler = class {
1811
1844
  swarmKey,
1812
1845
  authCode,
1813
1846
  timeout,
1814
- persistent,
1847
+ persistent: persistent && type !== import_services3.Invitation.Type.DELEGATED,
1848
+ guestKeypair: guestKeypair ?? (authMethod === import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
1815
1849
  created,
1816
1850
  lifetime,
1851
+ multiUse,
1817
1852
  ...protocol.getInvitationContext()
1818
1853
  };
1819
1854
  const stream = new import_async7.PushStream();
@@ -1828,7 +1863,7 @@ var InvitationsHandler = class {
1828
1863
  ...protocol.toJSON()
1829
1864
  }, {
1830
1865
  F: __dxlog_file7,
1831
- L: 109,
1866
+ L: 115,
1832
1867
  S: this,
1833
1868
  C: (f, a) => f(...a)
1834
1869
  });
@@ -1853,7 +1888,7 @@ var InvitationsHandler = class {
1853
1888
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
1854
1889
  (0, import_invariant5.invariant)(deviceKey, void 0, {
1855
1890
  F: __dxlog_file7,
1856
- L: 130,
1891
+ L: 136,
1857
1892
  S: this,
1858
1893
  A: [
1859
1894
  "deviceKey",
@@ -1876,7 +1911,7 @@ var InvitationsHandler = class {
1876
1911
  id: traceId
1877
1912
  }), {
1878
1913
  F: __dxlog_file7,
1879
- L: 148,
1914
+ L: 154,
1880
1915
  S: this,
1881
1916
  C: (f, a) => f(...a)
1882
1917
  });
@@ -1884,7 +1919,7 @@ var InvitationsHandler = class {
1884
1919
  ...protocol.toJSON()
1885
1920
  }, {
1886
1921
  F: __dxlog_file7,
1887
- L: 149,
1922
+ L: 155,
1888
1923
  S: this,
1889
1924
  C: (f, a) => f(...a)
1890
1925
  });
@@ -1900,7 +1935,7 @@ var InvitationsHandler = class {
1900
1935
  ...protocol.toJSON()
1901
1936
  }, {
1902
1937
  F: __dxlog_file7,
1903
- L: 152,
1938
+ L: 158,
1904
1939
  S: this,
1905
1940
  C: (f, a) => f(...a)
1906
1941
  });
@@ -1912,7 +1947,7 @@ var InvitationsHandler = class {
1912
1947
  id: traceId
1913
1948
  }), {
1914
1949
  F: __dxlog_file7,
1915
- L: 154,
1950
+ L: 160,
1916
1951
  S: this,
1917
1952
  C: (f, a) => f(...a)
1918
1953
  });
@@ -1922,7 +1957,7 @@ var InvitationsHandler = class {
1922
1957
  ...protocol.toJSON()
1923
1958
  }, {
1924
1959
  F: __dxlog_file7,
1925
- L: 157,
1960
+ L: 163,
1926
1961
  S: this,
1927
1962
  C: (f, a) => f(...a)
1928
1963
  });
@@ -1933,7 +1968,7 @@ var InvitationsHandler = class {
1933
1968
  } else {
1934
1969
  import_log4.log.error("failed", err, {
1935
1970
  F: __dxlog_file7,
1936
- L: 160,
1971
+ L: 166,
1937
1972
  S: this,
1938
1973
  C: (f, a) => f(...a)
1939
1974
  });
@@ -1944,12 +1979,12 @@ var InvitationsHandler = class {
1944
1979
  error: err
1945
1980
  }), {
1946
1981
  F: __dxlog_file7,
1947
- L: 163,
1982
+ L: 169,
1948
1983
  S: this,
1949
1984
  C: (f, a) => f(...a)
1950
1985
  });
1951
1986
  } finally {
1952
- if (type !== import_services3.Invitation.Type.MULTIUSE) {
1987
+ if (!multiUse) {
1953
1988
  await swarmConnection.close();
1954
1989
  await ctx.dispose();
1955
1990
  }
@@ -1965,7 +2000,7 @@ var InvitationsHandler = class {
1965
2000
  ...protocol.toJSON()
1966
2001
  }, {
1967
2002
  F: __dxlog_file7,
1968
- L: 178,
2003
+ L: 184,
1969
2004
  S: this,
1970
2005
  C: (f, a) => f(...a)
1971
2006
  });
@@ -1976,7 +2011,7 @@ var InvitationsHandler = class {
1976
2011
  } else {
1977
2012
  import_log4.log.error("failed", err, {
1978
2013
  F: __dxlog_file7,
1979
- L: 181,
2014
+ L: 187,
1980
2015
  S: this,
1981
2016
  C: (f, a) => f(...a)
1982
2017
  });
@@ -1990,7 +2025,7 @@ var InvitationsHandler = class {
1990
2025
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
1991
2026
  import_log4.log.warn("invitation has already expired", void 0, {
1992
2027
  F: __dxlog_file7,
1993
- L: 192,
2028
+ L: 198,
1994
2029
  S: this,
1995
2030
  C: (f, a) => f(...a)
1996
2031
  });
@@ -2041,7 +2076,7 @@ var InvitationsHandler = class {
2041
2076
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
2042
2077
  (0, import_invariant5.invariant)(protocol, void 0, {
2043
2078
  F: __dxlog_file7,
2044
- L: 246,
2079
+ L: 252,
2045
2080
  S: this,
2046
2081
  A: [
2047
2082
  "protocol",
@@ -2051,7 +2086,7 @@ var InvitationsHandler = class {
2051
2086
  if (deviceProfile) {
2052
2087
  (0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2053
2088
  F: __dxlog_file7,
2054
- L: 250,
2089
+ L: 256,
2055
2090
  S: this,
2056
2091
  A: [
2057
2092
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -2066,7 +2101,7 @@ var InvitationsHandler = class {
2066
2101
  const setState = (newData) => {
2067
2102
  (0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
2068
2103
  F: __dxlog_file7,
2069
- L: 261,
2104
+ L: 267,
2070
2105
  S: this,
2071
2106
  A: [
2072
2107
  "newData.state !== undefined",
@@ -2086,7 +2121,7 @@ var InvitationsHandler = class {
2086
2121
  ...protocol.toJSON()
2087
2122
  }, {
2088
2123
  F: __dxlog_file7,
2089
- L: 269,
2124
+ L: 275,
2090
2125
  S: this,
2091
2126
  C: (f, a) => f(...a)
2092
2127
  });
@@ -2096,7 +2131,7 @@ var InvitationsHandler = class {
2096
2131
  } else {
2097
2132
  import_log4.log.warn("auth failed", err, {
2098
2133
  F: __dxlog_file7,
2099
- L: 272,
2134
+ L: 278,
2100
2135
  S: this,
2101
2136
  C: (f, a) => f(...a)
2102
2137
  });
@@ -2110,7 +2145,7 @@ var InvitationsHandler = class {
2110
2145
  ...protocol.toJSON()
2111
2146
  }, {
2112
2147
  F: __dxlog_file7,
2113
- L: 280,
2148
+ L: 286,
2114
2149
  S: this,
2115
2150
  C: (f, a) => f(...a)
2116
2151
  });
@@ -2125,7 +2160,7 @@ var InvitationsHandler = class {
2125
2160
  currentState
2126
2161
  }, {
2127
2162
  F: __dxlog_file7,
2128
- L: 290,
2163
+ L: 296,
2129
2164
  S: this,
2130
2165
  C: (f, a) => f(...a)
2131
2166
  });
@@ -2140,7 +2175,7 @@ var InvitationsHandler = class {
2140
2175
  id: traceId
2141
2176
  }), {
2142
2177
  F: __dxlog_file7,
2143
- L: 299,
2178
+ L: 305,
2144
2179
  S: this,
2145
2180
  C: (f, a) => f(...a)
2146
2181
  });
@@ -2152,7 +2187,7 @@ var InvitationsHandler = class {
2152
2187
  ...protocol.toJSON()
2153
2188
  }, {
2154
2189
  F: __dxlog_file7,
2155
- L: 307,
2190
+ L: 313,
2156
2191
  S: this,
2157
2192
  C: (f, a) => f(...a)
2158
2193
  });
@@ -2163,7 +2198,7 @@ var InvitationsHandler = class {
2163
2198
  ...protocol.toJSON()
2164
2199
  }, {
2165
2200
  F: __dxlog_file7,
2166
- L: 311,
2201
+ L: 317,
2167
2202
  S: this,
2168
2203
  C: (f, a) => f(...a)
2169
2204
  });
@@ -2173,62 +2208,28 @@ var InvitationsHandler = class {
2173
2208
  response: introductionResponse
2174
2209
  }, {
2175
2210
  F: __dxlog_file7,
2176
- L: 315,
2211
+ L: 321,
2177
2212
  S: this,
2178
2213
  C: (f, a) => f(...a)
2179
2214
  });
2180
2215
  invitation.authMethod = introductionResponse.authMethod;
2181
2216
  if (isAuthenticationRequired(invitation)) {
2182
- for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2183
- (0, import_log4.log)("guest waiting for authentication code...", void 0, {
2184
- F: __dxlog_file7,
2185
- L: 321,
2186
- S: this,
2187
- C: (f, a) => f(...a)
2188
- });
2189
- setState({
2190
- state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
2191
- });
2192
- const authCode = await authenticated.wait({
2193
- timeout
2194
- });
2195
- (0, import_log4.log)("sending authentication request", void 0, {
2196
- F: __dxlog_file7,
2197
- L: 325,
2198
- S: this,
2199
- C: (f, a) => f(...a)
2200
- });
2201
- setState({
2202
- state: import_services3.Invitation.State.AUTHENTICATING
2203
- });
2204
- const response = await extension.rpc.InvitationHostService.authenticate({
2205
- authCode
2206
- });
2207
- if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
2217
+ switch (invitation.authMethod) {
2218
+ case import_services3.Invitation.AuthMethod.SHARED_SECRET:
2219
+ await this._handleGuestOtpAuth(extension, setState, authenticated, {
2220
+ timeout
2221
+ });
2222
+ break;
2223
+ case import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY:
2224
+ await this._handleGuestKpkAuth(extension, setState, invitation, introductionResponse);
2208
2225
  break;
2209
- }
2210
- if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
2211
- if (attempt === MAX_OTP_ATTEMPTS) {
2212
- throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
2213
- } else {
2214
- (0, import_log4.log)("retrying invalid code", {
2215
- attempt
2216
- }, {
2217
- F: __dxlog_file7,
2218
- L: 336,
2219
- S: this,
2220
- C: (f, a) => f(...a)
2221
- });
2222
- authenticated.reset();
2223
- }
2224
- }
2225
2226
  }
2226
2227
  }
2227
2228
  (0, import_log4.log)("request admission", {
2228
2229
  ...protocol.toJSON()
2229
2230
  }, {
2230
2231
  F: __dxlog_file7,
2231
- L: 344,
2232
+ L: 337,
2232
2233
  S: this,
2233
2234
  C: (f, a) => f(...a)
2234
2235
  });
@@ -2240,7 +2241,7 @@ var InvitationsHandler = class {
2240
2241
  ...protocol.toJSON()
2241
2242
  }, {
2242
2243
  F: __dxlog_file7,
2243
- L: 355,
2244
+ L: 348,
2244
2245
  S: this,
2245
2246
  C: (f, a) => f(...a)
2246
2247
  });
@@ -2253,7 +2254,7 @@ var InvitationsHandler = class {
2253
2254
  id: traceId
2254
2255
  }), {
2255
2256
  F: __dxlog_file7,
2256
- L: 357,
2257
+ L: 350,
2257
2258
  S: this,
2258
2259
  C: (f, a) => f(...a)
2259
2260
  });
@@ -2263,7 +2264,7 @@ var InvitationsHandler = class {
2263
2264
  ...protocol.toJSON()
2264
2265
  }, {
2265
2266
  F: __dxlog_file7,
2266
- L: 360,
2267
+ L: 353,
2267
2268
  S: this,
2268
2269
  C: (f, a) => f(...a)
2269
2270
  });
@@ -2273,7 +2274,7 @@ var InvitationsHandler = class {
2273
2274
  } else {
2274
2275
  (0, import_log4.log)("auth failed", err, {
2275
2276
  F: __dxlog_file7,
2276
- L: 363,
2277
+ L: 356,
2277
2278
  S: this,
2278
2279
  C: (f, a) => f(...a)
2279
2280
  });
@@ -2284,7 +2285,7 @@ var InvitationsHandler = class {
2284
2285
  error: err
2285
2286
  }), {
2286
2287
  F: __dxlog_file7,
2287
- L: 366,
2288
+ L: 359,
2288
2289
  S: this,
2289
2290
  C: (f, a) => f(...a)
2290
2291
  });
@@ -2302,7 +2303,7 @@ var InvitationsHandler = class {
2302
2303
  ...protocol.toJSON()
2303
2304
  }, {
2304
2305
  F: __dxlog_file7,
2305
- L: 377,
2306
+ L: 370,
2306
2307
  S: this,
2307
2308
  C: (f, a) => f(...a)
2308
2309
  });
@@ -2312,7 +2313,7 @@ var InvitationsHandler = class {
2312
2313
  } else {
2313
2314
  (0, import_log4.log)("auth failed", err, {
2314
2315
  F: __dxlog_file7,
2315
- L: 380,
2316
+ L: 373,
2316
2317
  S: this,
2317
2318
  C: (f, a) => f(...a)
2318
2319
  });
@@ -2329,7 +2330,7 @@ var InvitationsHandler = class {
2329
2330
  } else {
2330
2331
  (0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
2331
2332
  F: __dxlog_file7,
2332
- L: 394,
2333
+ L: 387,
2333
2334
  S: this,
2334
2335
  A: [
2335
2336
  "invitation.swarmKey",
@@ -2367,9 +2368,81 @@ var InvitationsHandler = class {
2367
2368
  });
2368
2369
  return observable;
2369
2370
  }
2371
+ async _handleGuestOtpAuth(extension, setState, authenticated, options) {
2372
+ for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2373
+ (0, import_log4.log)("guest waiting for authentication code...", void 0, {
2374
+ F: __dxlog_file7,
2375
+ L: 427,
2376
+ S: this,
2377
+ C: (f, a) => f(...a)
2378
+ });
2379
+ setState({
2380
+ state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
2381
+ });
2382
+ const authCode = await authenticated.wait(options);
2383
+ (0, import_log4.log)("sending authentication request", void 0, {
2384
+ F: __dxlog_file7,
2385
+ L: 431,
2386
+ S: this,
2387
+ C: (f, a) => f(...a)
2388
+ });
2389
+ setState({
2390
+ state: import_services3.Invitation.State.AUTHENTICATING
2391
+ });
2392
+ const response = await extension.rpc.InvitationHostService.authenticate({
2393
+ authCode
2394
+ });
2395
+ if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
2396
+ break;
2397
+ }
2398
+ if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
2399
+ if (attempt === MAX_OTP_ATTEMPTS) {
2400
+ throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
2401
+ } else {
2402
+ (0, import_log4.log)("retrying invalid code", {
2403
+ attempt
2404
+ }, {
2405
+ F: __dxlog_file7,
2406
+ L: 442,
2407
+ S: this,
2408
+ C: (f, a) => f(...a)
2409
+ });
2410
+ authenticated.reset();
2411
+ }
2412
+ }
2413
+ }
2414
+ }
2415
+ async _handleGuestKpkAuth(extension, setState, invitation, introductionResponse) {
2416
+ if (invitation.guestKeypair?.privateKey == null) {
2417
+ throw new Error("keypair missing in the invitation");
2418
+ }
2419
+ if (introductionResponse.challenge == null) {
2420
+ throw new Error("challenge missing in the introduction");
2421
+ }
2422
+ (0, import_log4.log)("sending authentication request", void 0, {
2423
+ F: __dxlog_file7,
2424
+ L: 461,
2425
+ S: this,
2426
+ C: (f, a) => f(...a)
2427
+ });
2428
+ setState({
2429
+ state: import_services3.Invitation.State.AUTHENTICATING
2430
+ });
2431
+ const signature = (0, import_crypto.sign)(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
2432
+ const response = await extension.rpc.InvitationHostService.authenticate({
2433
+ signedChallenge: signature
2434
+ });
2435
+ if (response.status !== import_invitations.AuthenticationResponse.Status.OK) {
2436
+ throw new Error(`Authentication failed with code: ${response.status}`);
2437
+ }
2438
+ }
2370
2439
  };
2371
- var invitationExpired = (invitation) => {
2372
- return invitation.created && invitation.lifetime && invitation.lifetime !== 0 && invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now();
2440
+ var createAdmissionKeypair = () => {
2441
+ const keypair = (0, import_crypto.createKeyPair)();
2442
+ return {
2443
+ publicKey: import_keys5.PublicKey.from(keypair.publicKey),
2444
+ privateKey: keypair.secretKey
2445
+ };
2373
2446
  };
2374
2447
  var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
2375
2448
  var InvitationsServiceImpl = class {
@@ -2426,7 +2499,7 @@ var InvitationsServiceImpl = class {
2426
2499
  await this._metadataStore.removeInvitation(invitation.get().invitationId);
2427
2500
  }
2428
2501
  this._createInvitations.delete(invitation.get().invitationId);
2429
- if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
2502
+ if (!invitation.get().multiUse) {
2430
2503
  this._removedCreated.emit(invitation.get());
2431
2504
  }
2432
2505
  });
@@ -2434,7 +2507,7 @@ var InvitationsServiceImpl = class {
2434
2507
  }
2435
2508
  async loadPersistentInvitations() {
2436
2509
  const persistentInvitations = this._metadataStore.getInvitations();
2437
- const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
2510
+ const freshInvitations = persistentInvitations.filter(async (invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
2438
2511
  const cInvitations = freshInvitations.map((persistentInvitation) => {
2439
2512
  (0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
2440
2513
  F: __dxlog_file8,
@@ -2487,7 +2560,7 @@ var InvitationsServiceImpl = class {
2487
2560
  }, () => {
2488
2561
  close();
2489
2562
  this._acceptInvitations.delete(invitation.get().invitationId);
2490
- if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
2563
+ if (!invitation.get().multiUse) {
2491
2564
  this._removedAccepted.emit(invitation.get());
2492
2565
  }
2493
2566
  });
@@ -2860,176 +2933,41 @@ _ts_decorate3([
2860
2933
  ClientRpcServer = _ts_decorate3([
2861
2934
  import_tracing3.trace.resource()
2862
2935
  ], ClientRpcServer);
2863
- var getPlatform = () => {
2864
- if (process.browser) {
2865
- if (typeof window !== "undefined") {
2866
- const { userAgent } = window.navigator;
2867
- return {
2868
- type: import_services8.Platform.PLATFORM_TYPE.BROWSER,
2869
- userAgent,
2870
- uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
2871
- };
2872
- } else {
2873
- return {
2874
- type: import_services8.Platform.PLATFORM_TYPE.SHARED_WORKER,
2875
- uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
2876
- };
2877
- }
2878
- } else {
2879
- const { platform: platform2, version, arch } = process;
2880
- return {
2881
- type: import_services8.Platform.PLATFORM_TYPE.NODE,
2882
- platform: platform2,
2883
- arch,
2884
- runtime: version,
2885
- uptime: Math.floor(process.uptime()),
2886
- memory: process.memoryUsage()
2887
- };
2888
- }
2889
- };
2890
- var DXOS_VERSION = "0.4.10-main.e158b1a";
2891
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2892
- var DEFAULT_TIMEOUT = 1e3;
2893
- var createDiagnostics = async (clientServices, serviceContext, config) => {
2894
- const diagnostics = {
2895
- created: (/* @__PURE__ */ new Date()).toISOString(),
2896
- platform: getPlatform(),
2897
- client: {
2898
- version: DXOS_VERSION,
2899
- storage: {
2900
- version: import_protocols7.STORAGE_VERSION
2901
- }
2902
- },
2903
- trace: import_tracing4.TRACE_PROCESSOR.getDiagnostics()
2904
- };
2905
- {
2906
- (0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
2907
- F: __dxlog_file10,
2908
- L: 108,
2909
- S: void 0,
2910
- A: [
2911
- "clientServices.LoggingService",
2912
- "'SystemService is not available.'"
2913
- ]
2914
- });
2915
- diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
2916
- timeout: DEFAULT_TIMEOUT
2917
- }).catch(() => void 0);
2936
+ var AutomergeSpaceState = class {
2937
+ constructor(_onNewRoot) {
2938
+ this._onNewRoot = _onNewRoot;
2939
+ this.rootUrl = void 0;
2940
+ this.lastEpoch = void 0;
2941
+ this.onNewEpoch = new import_async11.Event();
2942
+ this._isProcessingRootDocs = false;
2918
2943
  }
2919
- if (typeof navigator !== "undefined" && navigator.storage) {
2920
- const map = /* @__PURE__ */ new Map();
2921
- const dir = await navigator.storage.getDirectory();
2922
- for await (const filename of dir?.keys()) {
2923
- const idx = filename.indexOf("-", filename.indexOf("-") + 1);
2924
- if (idx === -1) {
2925
- continue;
2944
+ async processCredential(credential) {
2945
+ if (!(0, import_credentials10.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
2946
+ return;
2947
+ }
2948
+ this.lastEpoch = credential;
2949
+ if (credential.subject.assertion.automergeRoot) {
2950
+ this.rootUrl = credential.subject.assertion.automergeRoot;
2951
+ if (this._isProcessingRootDocs) {
2952
+ this._onNewRoot(this.rootUrl);
2926
2953
  }
2927
- map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
2928
2954
  }
2929
- diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
2930
- file,
2931
- count
2932
- }));
2955
+ this.onNewEpoch.emit(credential);
2933
2956
  }
2934
- const identity = serviceContext.identityManager.identity;
2935
- if (identity) {
2936
- diagnostics.identity = {
2937
- identityKey: identity.identityKey,
2938
- spaceKey: identity.space.key,
2939
- profile: identity.profileDocument
2940
- };
2941
- const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
2942
- timeout: DEFAULT_TIMEOUT
2943
- }).catch(() => void 0) ?? {};
2944
- diagnostics.devices = devices;
2945
- if (serviceContext.dataSpaceManager) {
2946
- diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
2957
+ startProcessingRootDocs() {
2958
+ if (this._isProcessingRootDocs) {
2959
+ return;
2947
2960
  }
2948
- const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2949
- timeout: DEFAULT_TIMEOUT
2950
- }).catch(() => void 0) ?? {};
2951
- diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
2952
- feedKey,
2953
- bytes,
2954
- length
2955
- }));
2956
- const status = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
2957
- timeout: DEFAULT_TIMEOUT
2958
- }).catch(() => void 0);
2959
- diagnostics.networkStatus = status;
2960
- diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
2961
+ if (this.rootUrl) {
2962
+ this._onNewRoot(this.rootUrl);
2963
+ }
2964
+ this._isProcessingRootDocs = true;
2965
+ }
2966
+ async ensureEpochInitialized() {
2967
+ await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
2961
2968
  }
2962
- diagnostics.config = config.values;
2963
- return diagnostics;
2964
2969
  };
2965
- var getSpaceStats = async (space) => {
2966
- const stats = {
2967
- key: space.key,
2968
- metrics: space.metrics,
2969
- epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
2970
- ...credential.subject.assertion,
2971
- id: credential.id
2972
- })),
2973
- members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
2974
- identity: {
2975
- identityKey: member.key,
2976
- profile: {
2977
- displayName: member.assertion.profile?.displayName
2978
- }
2979
- },
2980
- presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services7.SpaceMember.PresenceState.ONLINE : import_services7.SpaceMember.PresenceState.OFFLINE
2981
- })),
2982
- pipeline: {
2983
- // TODO(burdon): Pick properties from credentials if needed.
2984
- currentEpoch: space.automergeSpaceState.lastEpoch,
2985
- appliedEpoch: space.automergeSpaceState.lastEpoch,
2986
- controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
2987
- currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
2988
- targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
2989
- totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
2990
- }
2991
- };
2992
- if (stats.metrics) {
2993
- const { open, ready } = stats.metrics;
2994
- stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
2995
- }
2996
- return stats;
2997
- };
2998
- var AutomergeSpaceState = class {
2999
- constructor(_onNewRoot) {
3000
- this._onNewRoot = _onNewRoot;
3001
- this.rootUrl = void 0;
3002
- this.lastEpoch = void 0;
3003
- this.onNewEpoch = new import_async11.Event();
3004
- this._isProcessingRootDocs = false;
3005
- }
3006
- async processCredential(credential) {
3007
- if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
3008
- return;
3009
- }
3010
- this.lastEpoch = credential;
3011
- if (credential.subject.assertion.automergeRoot) {
3012
- this.rootUrl = credential.subject.assertion.automergeRoot;
3013
- if (this._isProcessingRootDocs) {
3014
- this._onNewRoot(this.rootUrl);
3015
- }
3016
- }
3017
- this.onNewEpoch.emit(credential);
3018
- }
3019
- startProcessingRootDocs() {
3020
- if (this._isProcessingRootDocs) {
3021
- return;
3022
- }
3023
- if (this.rootUrl) {
3024
- this._onNewRoot(this.rootUrl);
3025
- }
3026
- this._isProcessingRootDocs = true;
3027
- }
3028
- async ensureEpochInitialized() {
3029
- await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3030
- }
3031
- };
3032
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2970
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3033
2971
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3034
2972
  var DEFAULT_SUCCESS_DELAY = 1e3;
3035
2973
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -3057,13 +2995,13 @@ var NotarizationPlugin = class {
3057
2995
  (0, import_log9.log)("notarize", {
3058
2996
  credentials
3059
2997
  }, {
3060
- F: __dxlog_file11,
2998
+ F: __dxlog_file10,
3061
2999
  L: 90,
3062
3000
  S: this,
3063
3001
  C: (f, a) => f(...a)
3064
3002
  });
3065
- (0, import_invariant11.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
3066
- F: __dxlog_file11,
3003
+ (0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
3004
+ F: __dxlog_file10,
3067
3005
  L: 91,
3068
3006
  S: this,
3069
3007
  A: [
@@ -3077,7 +3015,7 @@ var NotarizationPlugin = class {
3077
3015
  import_log9.log.warn("Notarization error", {
3078
3016
  err
3079
3017
  }, {
3080
- F: __dxlog_file11,
3018
+ F: __dxlog_file10,
3081
3019
  L: 99,
3082
3020
  S: this,
3083
3021
  C: (f, a) => f(...a)
@@ -3093,7 +3031,7 @@ var NotarizationPlugin = class {
3093
3031
  timeout,
3094
3032
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
3095
3033
  }, {
3096
- F: __dxlog_file11,
3034
+ F: __dxlog_file10,
3097
3035
  L: 111,
3098
3036
  S: this,
3099
3037
  C: (f, a) => f(...a)
@@ -3116,7 +3054,7 @@ var NotarizationPlugin = class {
3116
3054
  import_log9.log.info("Exhausted all peers to notarize with", {
3117
3055
  retryIn: retryTimeout
3118
3056
  }, {
3119
- F: __dxlog_file11,
3057
+ F: __dxlog_file10,
3120
3058
  L: 136,
3121
3059
  S: this,
3122
3060
  C: (f, a) => f(...a)
@@ -3130,7 +3068,7 @@ var NotarizationPlugin = class {
3130
3068
  peer: peer.localPeerId,
3131
3069
  credentialId: credentials.map((credential) => credential.id)
3132
3070
  }, {
3133
- F: __dxlog_file11,
3071
+ F: __dxlog_file10,
3134
3072
  L: 143,
3135
3073
  S: this,
3136
3074
  C: (f, a) => f(...a)
@@ -3139,7 +3077,7 @@ var NotarizationPlugin = class {
3139
3077
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
3140
3078
  });
3141
3079
  (0, import_log9.log)("success", void 0, {
3142
- F: __dxlog_file11,
3080
+ F: __dxlog_file10,
3143
3081
  L: 147,
3144
3082
  S: this,
3145
3083
  C: (f, a) => f(...a)
@@ -3148,7 +3086,7 @@ var NotarizationPlugin = class {
3148
3086
  } catch (err) {
3149
3087
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
3150
3088
  import_log9.log.info("error notarizing (recoverable)", err, {
3151
- F: __dxlog_file11,
3089
+ F: __dxlog_file10,
3152
3090
  L: 151,
3153
3091
  S: this,
3154
3092
  C: (f, a) => f(...a)
@@ -3166,7 +3104,7 @@ var NotarizationPlugin = class {
3166
3104
  errors.wait()
3167
3105
  ]);
3168
3106
  (0, import_log9.log)("done", void 0, {
3169
- F: __dxlog_file11,
3107
+ F: __dxlog_file10,
3170
3108
  L: 162,
3171
3109
  S: this,
3172
3110
  C: (f, a) => f(...a)
@@ -3187,8 +3125,8 @@ var NotarizationPlugin = class {
3187
3125
  this._processCredentialsTriggers.delete(credential.id);
3188
3126
  }
3189
3127
  setWriter(writer) {
3190
- (0, import_invariant11.invariant)(!this._writer, "Writer already set.", {
3191
- F: __dxlog_file11,
3128
+ (0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
3129
+ F: __dxlog_file10,
3192
3130
  L: 181,
3193
3131
  S: this,
3194
3132
  A: [
@@ -3212,8 +3150,8 @@ var NotarizationPlugin = class {
3212
3150
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
3213
3151
  }
3214
3152
  for (const credential of request.credentials ?? []) {
3215
- (0, import_invariant11.invariant)(credential.id, "Credential must have an id", {
3216
- F: __dxlog_file11,
3153
+ (0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
3154
+ F: __dxlog_file10,
3217
3155
  L: 200,
3218
3156
  S: this,
3219
3157
  A: [
@@ -3233,7 +3171,7 @@ var NotarizationPlugin = class {
3233
3171
  (0, import_log9.log)("extension opened", {
3234
3172
  peer: extension.localPeerId
3235
3173
  }, {
3236
- F: __dxlog_file11,
3174
+ F: __dxlog_file10,
3237
3175
  L: 211,
3238
3176
  S: this,
3239
3177
  C: (f, a) => f(...a)
@@ -3245,7 +3183,7 @@ var NotarizationPlugin = class {
3245
3183
  (0, import_log9.log)("extension closed", {
3246
3184
  peer: extension.localPeerId
3247
3185
  }, {
3248
- F: __dxlog_file11,
3186
+ F: __dxlog_file10,
3249
3187
  L: 216,
3250
3188
  S: this,
3251
3189
  C: (f, a) => f(...a)
@@ -3261,10 +3199,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
3261
3199
  constructor(_params) {
3262
3200
  super({
3263
3201
  requested: {
3264
- NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3202
+ NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3265
3203
  },
3266
3204
  exposed: {
3267
- NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3205
+ NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3268
3206
  }
3269
3207
  });
3270
3208
  this._params = _params;
@@ -3297,14 +3235,14 @@ function _ts_decorate4(decorators, target, key, desc) {
3297
3235
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3298
3236
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3299
3237
  }
3300
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3238
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3301
3239
  var DataSpace = class {
3302
3240
  constructor(params) {
3303
3241
  this._ctx = new import_context7.Context();
3304
3242
  this._notarizationPlugin = new NotarizationPlugin();
3305
3243
  this._cache = void 0;
3306
3244
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
3307
- this._state = import_services9.SpaceState.CLOSED;
3245
+ this._state = import_services7.SpaceState.CLOSED;
3308
3246
  this.error = void 0;
3309
3247
  this.stateUpdate = new import_async10.Event();
3310
3248
  this.metrics = {};
@@ -3326,9 +3264,9 @@ var DataSpace = class {
3326
3264
  this._cache = params.cache;
3327
3265
  this._state = params.initialState;
3328
3266
  (0, import_log8.log)("new state", {
3329
- state: import_services9.SpaceState[this._state]
3267
+ state: import_services7.SpaceState[this._state]
3330
3268
  }, {
3331
- F: __dxlog_file12,
3269
+ F: __dxlog_file11,
3332
3270
  L: 140,
3333
3271
  S: this,
3334
3272
  C: (f, a) => f(...a)
@@ -3374,11 +3312,11 @@ var DataSpace = class {
3374
3312
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
3375
3313
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
3376
3314
  await this._inner.open(new import_context7.Context());
3377
- this._state = import_services9.SpaceState.CONTROL_ONLY;
3315
+ this._state = import_services7.SpaceState.CONTROL_ONLY;
3378
3316
  (0, import_log8.log)("new state", {
3379
- state: import_services9.SpaceState[this._state]
3317
+ state: import_services7.SpaceState[this._state]
3380
3318
  }, {
3381
- F: __dxlog_file12,
3319
+ F: __dxlog_file11,
3382
3320
  L: 198,
3383
3321
  S: this,
3384
3322
  C: (f, a) => f(...a)
@@ -3392,11 +3330,11 @@ var DataSpace = class {
3392
3330
  }
3393
3331
  async _close() {
3394
3332
  await this._callbacks.beforeClose?.();
3395
- this._state = import_services9.SpaceState.CLOSED;
3333
+ this._state = import_services7.SpaceState.CLOSED;
3396
3334
  (0, import_log8.log)("new state", {
3397
- state: import_services9.SpaceState[this._state]
3335
+ state: import_services7.SpaceState[this._state]
3398
3336
  }, {
3399
- F: __dxlog_file12,
3337
+ F: __dxlog_file11,
3400
3338
  L: 212,
3401
3339
  S: this,
3402
3340
  C: (f, a) => f(...a)
@@ -3426,9 +3364,9 @@ var DataSpace = class {
3426
3364
  this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
3427
3365
  await this.initializeDataPipeline();
3428
3366
  } catch (err) {
3429
- if (err instanceof import_protocols8.CancelledError || err instanceof import_context7.ContextDisposedError) {
3367
+ if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
3430
3368
  (0, import_log8.log)("data pipeline initialization cancelled", err, {
3431
- F: __dxlog_file12,
3369
+ F: __dxlog_file11,
3432
3370
  L: 245,
3433
3371
  S: this,
3434
3372
  C: (f, a) => f(...a)
@@ -3436,16 +3374,16 @@ var DataSpace = class {
3436
3374
  return;
3437
3375
  }
3438
3376
  import_log8.log.error("Error initializing data pipeline", err, {
3439
- F: __dxlog_file12,
3377
+ F: __dxlog_file11,
3440
3378
  L: 249,
3441
3379
  S: this,
3442
3380
  C: (f, a) => f(...a)
3443
3381
  });
3444
- this._state = import_services9.SpaceState.ERROR;
3382
+ this._state = import_services7.SpaceState.ERROR;
3445
3383
  (0, import_log8.log)("new state", {
3446
- state: import_services9.SpaceState[this._state]
3384
+ state: import_services7.SpaceState[this._state]
3447
3385
  }, {
3448
- F: __dxlog_file12,
3386
+ F: __dxlog_file11,
3449
3387
  L: 251,
3450
3388
  S: this,
3451
3389
  C: (f, a) => f(...a)
@@ -3458,14 +3396,14 @@ var DataSpace = class {
3458
3396
  });
3459
3397
  }
3460
3398
  async initializeDataPipeline() {
3461
- if (this._state !== import_services9.SpaceState.CONTROL_ONLY) {
3462
- throw new import_protocols8.SystemError("Invalid operation");
3399
+ if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
3400
+ throw new import_protocols7.SystemError("Invalid operation");
3463
3401
  }
3464
- this._state = import_services9.SpaceState.INITIALIZING;
3402
+ this._state = import_services7.SpaceState.INITIALIZING;
3465
3403
  (0, import_log8.log)("new state", {
3466
- state: import_services9.SpaceState[this._state]
3404
+ state: import_services7.SpaceState[this._state]
3467
3405
  }, {
3468
- F: __dxlog_file12,
3406
+ F: __dxlog_file11,
3469
3407
  L: 267,
3470
3408
  S: this,
3471
3409
  C: (f, a) => f(...a)
@@ -3475,17 +3413,17 @@ var DataSpace = class {
3475
3413
  this._automergeSpaceState.startProcessingRootDocs();
3476
3414
  await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
3477
3415
  (0, import_log8.log)("data pipeline ready", void 0, {
3478
- F: __dxlog_file12,
3416
+ F: __dxlog_file11,
3479
3417
  L: 279,
3480
3418
  S: this,
3481
3419
  C: (f, a) => f(...a)
3482
3420
  });
3483
3421
  await this._callbacks.beforeReady?.();
3484
- this._state = import_services9.SpaceState.READY;
3422
+ this._state = import_services7.SpaceState.READY;
3485
3423
  (0, import_log8.log)("new state", {
3486
- state: import_services9.SpaceState[this._state]
3424
+ state: import_services7.SpaceState[this._state]
3487
3425
  }, {
3488
- F: __dxlog_file12,
3426
+ F: __dxlog_file11,
3489
3427
  L: 283,
3490
3428
  S: this,
3491
3429
  C: (f, a) => f(...a)
@@ -3501,14 +3439,14 @@ var DataSpace = class {
3501
3439
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
3502
3440
  await this._createWritableFeeds();
3503
3441
  (0, import_log8.log)("writable feeds created", void 0, {
3504
- F: __dxlog_file12,
3442
+ F: __dxlog_file11,
3505
3443
  L: 299,
3506
3444
  S: this,
3507
3445
  C: (f, a) => f(...a)
3508
3446
  });
3509
3447
  this.stateUpdate.emit();
3510
3448
  if (!this.notarizationPlugin.hasWriter) {
3511
- this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
3449
+ this.notarizationPlugin.setWriter((0, import_echo_pipeline2.createMappedFeedWriter)((credential) => ({
3512
3450
  credential: {
3513
3451
  credential
3514
3452
  }
@@ -3529,7 +3467,7 @@ var DataSpace = class {
3529
3467
  spaceKey: this.key,
3530
3468
  deviceKey: this._signingContext.deviceKey,
3531
3469
  identityKey: this._signingContext.identityKey,
3532
- designation: import_credentials10.AdmittedFeed.Designation.CONTROL
3470
+ designation: import_credentials9.AdmittedFeed.Designation.CONTROL
3533
3471
  }
3534
3472
  }));
3535
3473
  }
@@ -3546,7 +3484,7 @@ var DataSpace = class {
3546
3484
  spaceKey: this.key,
3547
3485
  deviceKey: this._signingContext.deviceKey,
3548
3486
  identityKey: this._signingContext.identityKey,
3549
- designation: import_credentials10.AdmittedFeed.Designation.DATA
3487
+ designation: import_credentials9.AdmittedFeed.Designation.DATA
3550
3488
  }
3551
3489
  }));
3552
3490
  }
@@ -3564,7 +3502,7 @@ var DataSpace = class {
3564
3502
  space: this.key,
3565
3503
  rootUrl
3566
3504
  }, {
3567
- F: __dxlog_file12,
3505
+ F: __dxlog_file11,
3568
3506
  L: 365,
3569
3507
  S: this,
3570
3508
  C: (f, a) => f(...a)
@@ -3579,7 +3517,7 @@ var DataSpace = class {
3579
3517
  if (this._ctx.disposed) {
3580
3518
  return;
3581
3519
  }
3582
- const doc = handle.docSync() ?? (0, import_invariant10.failedInvariant)();
3520
+ const doc = handle.docSync() ?? (0, import_invariant9.failedInvariant)();
3583
3521
  if (!doc.access?.spaceKey) {
3584
3522
  handle.change((doc2) => {
3585
3523
  doc2.access = {
@@ -3596,7 +3534,7 @@ var DataSpace = class {
3596
3534
  rootUrl,
3597
3535
  err
3598
3536
  }, {
3599
- F: __dxlog_file12,
3537
+ F: __dxlog_file11,
3600
3538
  L: 388,
3601
3539
  S: this,
3602
3540
  C: (f, a) => f(...a)
@@ -3623,7 +3561,7 @@ var DataSpace = class {
3623
3561
  let epoch;
3624
3562
  switch (options?.migration) {
3625
3563
  case void 0:
3626
- case import_services9.CreateEpochRequest.Migration.NONE:
3564
+ case import_services7.CreateEpochRequest.Migration.NONE:
3627
3565
  {
3628
3566
  epoch = {
3629
3567
  previousId: this._automergeSpaceState.lastEpoch?.id,
@@ -3633,7 +3571,7 @@ var DataSpace = class {
3633
3571
  };
3634
3572
  }
3635
3573
  break;
3636
- case import_services9.CreateEpochRequest.Migration.INIT_AUTOMERGE:
3574
+ case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE:
3637
3575
  {
3638
3576
  const document = this._automergeHost.repo.create();
3639
3577
  epoch = {
@@ -3644,14 +3582,14 @@ var DataSpace = class {
3644
3582
  };
3645
3583
  }
3646
3584
  break;
3647
- case import_services9.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
3585
+ case import_services7.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
3648
3586
  {
3649
3587
  const currentRootUrl = this._automergeSpaceState.rootUrl;
3650
3588
  const rootHandle = this._automergeHost.repo.find(currentRootUrl);
3651
3589
  await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
3652
3590
  const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
3653
- (0, import_invariant10.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3654
- F: __dxlog_file12,
3591
+ (0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3592
+ F: __dxlog_file11,
3655
3593
  L: 438,
3656
3594
  S: this,
3657
3595
  A: [
@@ -3667,10 +3605,10 @@ var DataSpace = class {
3667
3605
  };
3668
3606
  }
3669
3607
  break;
3670
- case import_services9.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
3608
+ case import_services7.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
3671
3609
  {
3672
3610
  import_log8.log.info("Fragmenting", void 0, {
3673
- F: __dxlog_file12,
3611
+ F: __dxlog_file11,
3674
3612
  L: 450,
3675
3613
  S: this,
3676
3614
  C: (f, a) => f(...a)
@@ -3681,8 +3619,8 @@ var DataSpace = class {
3681
3619
  const objects = Object.entries(rootHandle.docSync().objects);
3682
3620
  const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_db.TYPE_PROPERTIES);
3683
3621
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3684
- (0, import_invariant10.invariant)(properties, "Properties not found", {
3685
- F: __dxlog_file12,
3622
+ (0, import_invariant9.invariant)(properties, "Properties not found", {
3623
+ F: __dxlog_file11,
3686
3624
  L: 460,
3687
3625
  S: this,
3688
3626
  A: [
@@ -3697,8 +3635,8 @@ var DataSpace = class {
3697
3635
  ])
3698
3636
  };
3699
3637
  const newRoot = this._automergeHost.repo.create(newSpaceDoc);
3700
- (0, import_invariant10.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3701
- F: __dxlog_file12,
3638
+ (0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3639
+ F: __dxlog_file11,
3702
3640
  L: 465,
3703
3641
  S: this,
3704
3642
  A: [
@@ -3706,7 +3644,7 @@ var DataSpace = class {
3706
3644
  ""
3707
3645
  ]
3708
3646
  });
3709
- const docLoader = new import_echo_pipeline2.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
3647
+ const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
3710
3648
  await docLoader.loadSpaceRootDocHandle(this._ctx, {
3711
3649
  rootUrl: newRoot.url
3712
3650
  });
@@ -3750,24 +3688,24 @@ var DataSpace = class {
3750
3688
  ]));
3751
3689
  }
3752
3690
  async activate() {
3753
- if (this._state !== import_services9.SpaceState.INACTIVE) {
3691
+ if (this._state !== import_services7.SpaceState.INACTIVE) {
3754
3692
  return;
3755
3693
  }
3756
- await this._metadataStore.setSpaceState(this.key, import_services9.SpaceState.ACTIVE);
3694
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
3757
3695
  await this._open();
3758
3696
  this.initializeDataPipelineAsync();
3759
3697
  }
3760
3698
  async deactivate() {
3761
- if (this._state === import_services9.SpaceState.INACTIVE) {
3699
+ if (this._state === import_services7.SpaceState.INACTIVE) {
3762
3700
  return;
3763
3701
  }
3764
- await this._metadataStore.setSpaceState(this.key, import_services9.SpaceState.INACTIVE);
3702
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
3765
3703
  await this._close();
3766
- this._state = import_services9.SpaceState.INACTIVE;
3704
+ this._state = import_services7.SpaceState.INACTIVE;
3767
3705
  (0, import_log8.log)("new state", {
3768
- state: import_services9.SpaceState[this._state]
3706
+ state: import_services7.SpaceState[this._state]
3769
3707
  }, {
3770
- F: __dxlog_file12,
3708
+ F: __dxlog_file11,
3771
3709
  L: 531,
3772
3710
  S: this,
3773
3711
  C: (f, a) => f(...a)
@@ -3776,18 +3714,18 @@ var DataSpace = class {
3776
3714
  }
3777
3715
  };
3778
3716
  _ts_decorate4([
3779
- import_tracing5.trace.info()
3717
+ import_tracing4.trace.info()
3780
3718
  ], DataSpace.prototype, "_inner", void 0);
3781
3719
  _ts_decorate4([
3782
- import_tracing5.trace.info()
3720
+ import_tracing4.trace.info()
3783
3721
  ], DataSpace.prototype, "key", null);
3784
3722
  _ts_decorate4([
3785
- import_tracing5.trace.info({
3786
- enum: import_services9.SpaceState
3723
+ import_tracing4.trace.info({
3724
+ enum: import_services7.SpaceState
3787
3725
  })
3788
3726
  ], DataSpace.prototype, "state", null);
3789
3727
  _ts_decorate4([
3790
- import_tracing5.trace.info({
3728
+ import_tracing4.trace.info({
3791
3729
  depth: null
3792
3730
  })
3793
3731
  ], DataSpace.prototype, "_automergeInfo", null);
@@ -3798,12 +3736,12 @@ _ts_decorate4([
3798
3736
  import_async10.synchronized
3799
3737
  ], DataSpace.prototype, "close", null);
3800
3738
  _ts_decorate4([
3801
- import_tracing5.trace.span({
3739
+ import_tracing4.trace.span({
3802
3740
  showInBrowserTimeline: true
3803
3741
  })
3804
3742
  ], DataSpace.prototype, "initializeDataPipeline", null);
3805
3743
  _ts_decorate4([
3806
- import_tracing5.trace.span({
3744
+ import_tracing4.trace.span({
3807
3745
  showInBrowserTimeline: true
3808
3746
  })
3809
3747
  ], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
@@ -3818,11 +3756,11 @@ _ts_decorate4([
3818
3756
  ], DataSpace.prototype, "deactivate", null);
3819
3757
  DataSpace = _ts_decorate4([
3820
3758
  (0, import_async10.trackLeaks)("open", "close"),
3821
- import_tracing5.trace.resource()
3759
+ import_tracing4.trace.resource()
3822
3760
  ], DataSpace);
3823
3761
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3824
3762
  const credentials = [
3825
- await (0, import_credentials13.createCredential)({
3763
+ await (0, import_credentials12.createCredential)({
3826
3764
  signer: keyring,
3827
3765
  issuer: space.key,
3828
3766
  subject: space.key,
@@ -3831,14 +3769,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3831
3769
  spaceKey: space.key
3832
3770
  }
3833
3771
  }),
3834
- await (0, import_credentials13.createCredential)({
3772
+ await (0, import_credentials12.createCredential)({
3835
3773
  signer: keyring,
3836
3774
  issuer: space.key,
3837
3775
  subject: signingContext.identityKey,
3838
3776
  assertion: {
3839
3777
  "@type": "dxos.halo.credentials.SpaceMember",
3840
3778
  spaceKey: space.key,
3841
- role: import_credentials14.SpaceMember.Role.ADMIN,
3779
+ role: import_credentials13.SpaceMember.Role.ADMIN,
3842
3780
  profile: signingContext.getProfile(),
3843
3781
  genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
3844
3782
  }
@@ -3850,7 +3788,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3850
3788
  spaceKey: space.key,
3851
3789
  identityKey: signingContext.identityKey,
3852
3790
  deviceKey: signingContext.deviceKey,
3853
- designation: import_credentials14.AdmittedFeed.Designation.CONTROL
3791
+ designation: import_credentials13.AdmittedFeed.Designation.CONTROL
3854
3792
  }
3855
3793
  }),
3856
3794
  await signingContext.credentialSigner.createCredential({
@@ -3860,7 +3798,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3860
3798
  spaceKey: space.key,
3861
3799
  identityKey: signingContext.identityKey,
3862
3800
  deviceKey: signingContext.deviceKey,
3863
- designation: import_credentials14.AdmittedFeed.Designation.DATA
3801
+ designation: import_credentials13.AdmittedFeed.Designation.DATA
3864
3802
  }
3865
3803
  }),
3866
3804
  await signingContext.credentialSigner.createCredential({
@@ -3894,7 +3832,7 @@ function _ts_decorate5(decorators, target, key, desc) {
3894
3832
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3895
3833
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3896
3834
  }
3897
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3835
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3898
3836
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3899
3837
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3900
3838
  var DataSpaceManager = class {
@@ -3920,15 +3858,15 @@ var DataSpaceManager = class {
3920
3858
  }
3921
3859
  async open() {
3922
3860
  (0, import_log10.log)("open", void 0, {
3923
- F: __dxlog_file13,
3861
+ F: __dxlog_file12,
3924
3862
  L: 98,
3925
3863
  S: this,
3926
3864
  C: (f, a) => f(...a)
3927
3865
  });
3928
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols10.trace.begin({
3866
+ import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.begin({
3929
3867
  id: this._instanceId
3930
3868
  }), {
3931
- F: __dxlog_file13,
3869
+ F: __dxlog_file12,
3932
3870
  L: 99,
3933
3871
  S: this,
3934
3872
  C: (f, a) => f(...a)
@@ -3936,7 +3874,7 @@ var DataSpaceManager = class {
3936
3874
  (0, import_log10.log)("metadata loaded", {
3937
3875
  spaces: this._metadataStore.spaces.length
3938
3876
  }, {
3939
- F: __dxlog_file13,
3877
+ F: __dxlog_file12,
3940
3878
  L: 100,
3941
3879
  S: this,
3942
3880
  C: (f, a) => f(...a)
@@ -3946,7 +3884,7 @@ var DataSpaceManager = class {
3946
3884
  (0, import_log10.log)("load space", {
3947
3885
  spaceMetadata
3948
3886
  }, {
3949
- F: __dxlog_file13,
3887
+ F: __dxlog_file12,
3950
3888
  L: 104,
3951
3889
  S: this,
3952
3890
  C: (f, a) => f(...a)
@@ -3957,7 +3895,7 @@ var DataSpaceManager = class {
3957
3895
  spaceMetadata,
3958
3896
  err
3959
3897
  }, {
3960
- F: __dxlog_file13,
3898
+ F: __dxlog_file12,
3961
3899
  L: 107,
3962
3900
  S: this,
3963
3901
  C: (f, a) => f(...a)
@@ -3967,14 +3905,14 @@ var DataSpaceManager = class {
3967
3905
  this._isOpen = true;
3968
3906
  this.updated.emit();
3969
3907
  for (const space of this._spaces.values()) {
3970
- if (space.state !== import_services10.SpaceState.INACTIVE) {
3908
+ if (space.state !== import_services8.SpaceState.INACTIVE) {
3971
3909
  space.initializeDataPipelineAsync();
3972
3910
  }
3973
3911
  }
3974
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols10.trace.end({
3912
+ import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.end({
3975
3913
  id: this._instanceId
3976
3914
  }), {
3977
- F: __dxlog_file13,
3915
+ F: __dxlog_file12,
3978
3916
  L: 120,
3979
3917
  S: this,
3980
3918
  C: (f, a) => f(...a)
@@ -3982,7 +3920,7 @@ var DataSpaceManager = class {
3982
3920
  }
3983
3921
  async close() {
3984
3922
  (0, import_log10.log)("close", void 0, {
3985
- F: __dxlog_file13,
3923
+ F: __dxlog_file12,
3986
3924
  L: 125,
3987
3925
  S: this,
3988
3926
  C: (f, a) => f(...a)
@@ -3997,8 +3935,8 @@ var DataSpaceManager = class {
3997
3935
  * Creates a new space writing the genesis credentials to the control feed.
3998
3936
  */
3999
3937
  async createSpace() {
4000
- (0, import_invariant12.invariant)(this._isOpen, "Not open.", {
4001
- F: __dxlog_file13,
3938
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3939
+ F: __dxlog_file12,
4002
3940
  L: 138,
4003
3941
  S: this,
4004
3942
  A: [
@@ -4014,12 +3952,12 @@ var DataSpaceManager = class {
4014
3952
  genesisFeedKey: controlFeedKey,
4015
3953
  controlFeedKey,
4016
3954
  dataFeedKey,
4017
- state: import_services10.SpaceState.ACTIVE
3955
+ state: import_services8.SpaceState.ACTIVE
4018
3956
  };
4019
3957
  (0, import_log10.log)("creating space...", {
4020
3958
  spaceKey
4021
3959
  }, {
4022
- F: __dxlog_file13,
3960
+ F: __dxlog_file12,
4023
3961
  L: 150,
4024
3962
  S: this,
4025
3963
  C: (f, a) => f(...a)
@@ -4034,8 +3972,8 @@ var DataSpaceManager = class {
4034
3972
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
4035
3973
  await this._metadataStore.addSpace(metadata);
4036
3974
  const memberCredential = credentials[1];
4037
- (0, import_invariant12.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4038
- F: __dxlog_file13,
3975
+ (0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3976
+ F: __dxlog_file12,
4039
3977
  L: 163,
4040
3978
  S: this,
4041
3979
  A: [
@@ -4053,13 +3991,13 @@ var DataSpaceManager = class {
4053
3991
  (0, import_log10.log)("accept space", {
4054
3992
  opts
4055
3993
  }, {
4056
- F: __dxlog_file13,
3994
+ F: __dxlog_file12,
4057
3995
  L: 175,
4058
3996
  S: this,
4059
3997
  C: (f, a) => f(...a)
4060
3998
  });
4061
- (0, import_invariant12.invariant)(this._isOpen, "Not open.", {
4062
- F: __dxlog_file13,
3999
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
4000
+ F: __dxlog_file12,
4063
4001
  L: 176,
4064
4002
  S: this,
4065
4003
  A: [
@@ -4067,8 +4005,8 @@ var DataSpaceManager = class {
4067
4005
  "'Not open.'"
4068
4006
  ]
4069
4007
  });
4070
- (0, import_invariant12.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
4071
- F: __dxlog_file13,
4008
+ (0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
4009
+ F: __dxlog_file12,
4072
4010
  L: 177,
4073
4011
  S: this,
4074
4012
  A: [
@@ -4096,14 +4034,14 @@ var DataSpaceManager = class {
4096
4034
  async waitUntilSpaceReady(spaceKey) {
4097
4035
  await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
4098
4036
  const space = this._spaces.get(spaceKey);
4099
- return !!space && space.state === import_services10.SpaceState.READY;
4037
+ return !!space && space.state === import_services8.SpaceState.READY;
4100
4038
  }));
4101
4039
  }
4102
4040
  async _constructSpace(metadata) {
4103
4041
  (0, import_log10.log)("construct space", {
4104
4042
  metadata
4105
4043
  }, {
4106
- F: __dxlog_file13,
4044
+ F: __dxlog_file12,
4107
4045
  L: 210,
4108
4046
  S: this,
4109
4047
  C: (f, a) => f(...a)
@@ -4141,7 +4079,7 @@ var DataSpaceManager = class {
4141
4079
  },
4142
4080
  onAuthFailure: () => {
4143
4081
  import_log10.log.warn("auth failure", void 0, {
4144
- F: __dxlog_file13,
4082
+ F: __dxlog_file12,
4145
4083
  L: 247,
4146
4084
  S: this,
4147
4085
  C: (f, a) => f(...a)
@@ -4153,7 +4091,7 @@ var DataSpaceManager = class {
4153
4091
  dataFeed && await space.setDataFeed(dataFeed);
4154
4092
  const dataSpace = new DataSpace({
4155
4093
  inner: space,
4156
- initialState: metadata.state === import_services10.SpaceState.INACTIVE ? import_services10.SpaceState.INACTIVE : import_services10.SpaceState.CLOSED,
4094
+ initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
4157
4095
  metadataStore: this._metadataStore,
4158
4096
  gossip,
4159
4097
  presence,
@@ -4165,7 +4103,7 @@ var DataSpaceManager = class {
4165
4103
  (0, import_log10.log)("before space ready", {
4166
4104
  space: space.key
4167
4105
  }, {
4168
- F: __dxlog_file13,
4106
+ F: __dxlog_file12,
4169
4107
  L: 265,
4170
4108
  S: this,
4171
4109
  C: (f, a) => f(...a)
@@ -4176,7 +4114,7 @@ var DataSpaceManager = class {
4176
4114
  space: space.key,
4177
4115
  open: this._isOpen
4178
4116
  }, {
4179
- F: __dxlog_file13,
4117
+ F: __dxlog_file12,
4180
4118
  L: 268,
4181
4119
  S: this,
4182
4120
  C: (f, a) => f(...a)
@@ -4189,7 +4127,7 @@ var DataSpaceManager = class {
4189
4127
  (0, import_log10.log)("before space close", {
4190
4128
  space: space.key
4191
4129
  }, {
4192
- F: __dxlog_file13,
4130
+ F: __dxlog_file12,
4193
4131
  L: 274,
4194
4132
  S: this,
4195
4133
  C: (f, a) => f(...a)
@@ -4199,7 +4137,7 @@ var DataSpaceManager = class {
4199
4137
  cache: metadata.cache,
4200
4138
  automergeHost: this._automergeHost
4201
4139
  });
4202
- if (metadata.state !== import_services10.SpaceState.INACTIVE) {
4140
+ if (metadata.state !== import_services8.SpaceState.INACTIVE) {
4203
4141
  await dataSpace.open();
4204
4142
  }
4205
4143
  if (metadata.controlTimeframe) {
@@ -4224,7 +4162,7 @@ _ts_decorate5([
4224
4162
  DataSpaceManager = _ts_decorate5([
4225
4163
  (0, import_async13.trackLeaks)("open", "close")
4226
4164
  ], DataSpaceManager);
4227
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
4165
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
4228
4166
  var SpacesServiceImpl = class {
4229
4167
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
4230
4168
  this._identityManager = _identityManager;
@@ -4241,29 +4179,29 @@ var SpacesServiceImpl = class {
4241
4179
  }
4242
4180
  async updateSpace({ spaceKey, state }) {
4243
4181
  const dataSpaceManager = await this._getDataSpaceManager();
4244
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4182
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4245
4183
  if (state) {
4246
4184
  switch (state) {
4247
- case import_services11.SpaceState.ACTIVE:
4185
+ case import_services9.SpaceState.ACTIVE:
4248
4186
  await space.activate();
4249
4187
  break;
4250
- case import_services11.SpaceState.INACTIVE:
4188
+ case import_services9.SpaceState.INACTIVE:
4251
4189
  await space.deactivate();
4252
4190
  break;
4253
4191
  default:
4254
- throw new import_protocols11.ApiError("Invalid space state");
4192
+ throw new import_protocols10.ApiError("Invalid space state");
4255
4193
  }
4256
4194
  }
4257
4195
  }
4258
4196
  querySpaces() {
4259
- return new import_codec_protobuf11.Stream(({ next, ctx }) => {
4197
+ return new import_codec_protobuf10.Stream(({ next, ctx }) => {
4260
4198
  const scheduler = new import_async14.UpdateScheduler(ctx, async () => {
4261
4199
  const dataSpaceManager = await this._getDataSpaceManager();
4262
4200
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
4263
4201
  (0, import_log11.log)("update", {
4264
4202
  spaces
4265
4203
  }, {
4266
- F: __dxlog_file14,
4204
+ F: __dxlog_file13,
4267
4205
  L: 77,
4268
4206
  S: this,
4269
4207
  C: (f, a) => f(...a)
@@ -4303,14 +4241,14 @@ var SpacesServiceImpl = class {
4303
4241
  }
4304
4242
  async postMessage({ spaceKey, channel, message }) {
4305
4243
  const dataSpaceManager = await this._getDataSpaceManager();
4306
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4244
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4307
4245
  await space.postMessage(getChannelId(channel), message);
4308
4246
  }
4309
4247
  subscribeMessages({ spaceKey, channel }) {
4310
- return new import_codec_protobuf11.Stream(({ ctx, next }) => {
4248
+ return new import_codec_protobuf10.Stream(({ ctx, next }) => {
4311
4249
  (0, import_async14.scheduleTask)(ctx, async () => {
4312
4250
  const dataSpaceManager = await this._getDataSpaceManager();
4313
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4251
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4314
4252
  const handle = space.listen(getChannelId(channel), (message) => {
4315
4253
  next(message);
4316
4254
  });
@@ -4319,8 +4257,8 @@ var SpacesServiceImpl = class {
4319
4257
  });
4320
4258
  }
4321
4259
  queryCredentials({ spaceKey, noTail }) {
4322
- return new import_codec_protobuf11.Stream(({ ctx, next, close }) => {
4323
- const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4260
+ return new import_codec_protobuf10.Stream(({ ctx, next, close }) => {
4261
+ const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4324
4262
  const processor = {
4325
4263
  processCredential: async (credential) => {
4326
4264
  next(credential);
@@ -4336,7 +4274,7 @@ var SpacesServiceImpl = class {
4336
4274
  });
4337
4275
  }
4338
4276
  async writeCredentials({ spaceKey, credentials }) {
4339
- const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4277
+ const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4340
4278
  for (const credential of credentials ?? []) {
4341
4279
  if (credential.proof) {
4342
4280
  await space.controlPipeline.writer.write({
@@ -4345,8 +4283,8 @@ var SpacesServiceImpl = class {
4345
4283
  }
4346
4284
  });
4347
4285
  } else {
4348
- (0, import_invariant13.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
4349
- F: __dxlog_file14,
4286
+ (0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
4287
+ F: __dxlog_file13,
4350
4288
  L: 164,
4351
4289
  S: this,
4352
4290
  A: [
@@ -4354,8 +4292,8 @@ var SpacesServiceImpl = class {
4354
4292
  "'Id on unsigned credentials is not allowed'"
4355
4293
  ]
4356
4294
  });
4357
- (0, import_invariant13.invariant)(this._identityManager.identity, "Identity is not available", {
4358
- F: __dxlog_file14,
4295
+ (0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
4296
+ F: __dxlog_file13,
4359
4297
  L: 165,
4360
4298
  S: this,
4361
4299
  A: [
@@ -4364,8 +4302,8 @@ var SpacesServiceImpl = class {
4364
4302
  ]
4365
4303
  });
4366
4304
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
4367
- (0, import_invariant13.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
4368
- F: __dxlog_file14,
4305
+ (0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
4306
+ F: __dxlog_file13,
4369
4307
  L: 167,
4370
4308
  S: this,
4371
4309
  A: [
@@ -4387,7 +4325,7 @@ var SpacesServiceImpl = class {
4387
4325
  }
4388
4326
  async createEpoch({ spaceKey, migration }) {
4389
4327
  const dataSpaceManager = await this._getDataSpaceManager();
4390
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4328
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4391
4329
  await space.createEpoch({
4392
4330
  migration
4393
4331
  });
@@ -4396,7 +4334,7 @@ var SpacesServiceImpl = class {
4396
4334
  return {
4397
4335
  spaceKey: space.key,
4398
4336
  state: space.state,
4399
- error: space.error ? (0, import_protocols11.encodeError)(space.error) : void 0,
4337
+ error: space.error ? (0, import_protocols10.encodeError)(space.error) : void 0,
4400
4338
  pipeline: {
4401
4339
  currentEpoch: space.automergeSpaceState.lastEpoch,
4402
4340
  appliedEpoch: space.automergeSpaceState.lastEpoch,
@@ -4421,7 +4359,7 @@ var SpacesServiceImpl = class {
4421
4359
  identityKey: member.key,
4422
4360
  profile: member.profile ?? {}
4423
4361
  },
4424
- presence: member.removed ? import_services11.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services11.SpaceMember.PresenceState.ONLINE : import_services11.SpaceMember.PresenceState.OFFLINE,
4362
+ presence: member.removed ? import_services9.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
4425
4363
  peerStates: peers
4426
4364
  };
4427
4365
  }),
@@ -4440,7 +4378,7 @@ var createSelectedDocumentsIterator = (automergeHost) => (
4440
4378
  // TODO(mykola): Unload automerge handles after usage.
4441
4379
  async function* loadDocuments(ids) {
4442
4380
  for (const id of ids) {
4443
- const { documentId, objectId } = import_protocols13.idCodec.decode(id);
4381
+ const { documentId, objectId } = import_protocols12.idCodec.decode(id);
4444
4382
  const handle = automergeHost.repo.find(documentId);
4445
4383
  await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
4446
4384
  const doc = handle.docSync();
@@ -4473,7 +4411,7 @@ var createDocumentsIterator = (automergeHost) => (
4473
4411
  if (doc.objects) {
4474
4412
  yield Object.entries(doc.objects).map(([objectId, object]) => {
4475
4413
  return {
4476
- id: import_protocols13.idCodec.encode({
4414
+ id: import_protocols12.idCodec.encode({
4477
4415
  documentId: handle.documentId,
4478
4416
  objectId
4479
4417
  }),
@@ -4516,18 +4454,20 @@ function _ts_decorate6(decorators, target, key, desc) {
4516
4454
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4517
4455
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4518
4456
  }
4519
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4520
- var ServiceContext = class {
4521
- constructor(storage, networkManager, signalManager, _runtimeParams) {
4457
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4458
+ var ServiceContext = class extends import_context10.Resource {
4459
+ constructor(storage, level, networkManager, signalManager, _runtimeParams) {
4460
+ super();
4522
4461
  this.storage = storage;
4462
+ this.level = level;
4523
4463
  this.networkManager = networkManager;
4524
4464
  this.signalManager = signalManager;
4525
4465
  this._runtimeParams = _runtimeParams;
4526
4466
  this.initialized = new import_async15.Trigger();
4527
4467
  this._handlerFactories = /* @__PURE__ */ new Map();
4528
4468
  this._instanceId = import_keys10.PublicKey.random().toHex();
4529
- this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
4530
- this.snapshotStore = new import_echo_pipeline3.SnapshotStore(storage.createDirectory("snapshots"));
4469
+ this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
4470
+ this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
4531
4471
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
4532
4472
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
4533
4473
  this.feedStore = new import_feed_store4.FeedStore({
@@ -4535,12 +4475,12 @@ var ServiceContext = class {
4535
4475
  root: storage.createDirectory("feeds"),
4536
4476
  signer: this.keyring,
4537
4477
  hypercore: {
4538
- valueEncoding: import_echo_pipeline3.valueEncoding,
4478
+ valueEncoding: import_echo_pipeline4.valueEncoding,
4539
4479
  stats: true
4540
4480
  }
4541
4481
  })
4542
4482
  });
4543
- this.spaceManager = new import_echo_pipeline3.SpaceManager({
4483
+ this.spaceManager = new import_echo_pipeline4.SpaceManager({
4544
4484
  feedStore: this.feedStore,
4545
4485
  networkManager: this.networkManager,
4546
4486
  blobStore: this.blobStore,
@@ -4549,10 +4489,11 @@ var ServiceContext = class {
4549
4489
  });
4550
4490
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
4551
4491
  this.indexMetadata = new import_indexing.IndexMetadataStore({
4552
- directory: storage.createDirectory("index-metadata")
4492
+ db: level.sublevel("index-metadata")
4553
4493
  });
4554
- this.automergeHost = new import_echo_pipeline3.AutomergeHost({
4494
+ this.automergeHost = new import_echo_pipeline4.AutomergeHost({
4555
4495
  directory: storage.createDirectory("automerge"),
4496
+ db: level.sublevel("automerge"),
4556
4497
  metadata: this.indexMetadata
4557
4498
  });
4558
4499
  this.indexer = new import_indexing.Indexer({
@@ -4564,51 +4505,52 @@ var ServiceContext = class {
4564
4505
  getAllDocuments: createDocumentsIterator(this.automergeHost)
4565
4506
  });
4566
4507
  this.invitations = new InvitationsHandler(this.networkManager);
4567
- this._handlerFactories.set(import_services12.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
4508
+ this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
4568
4509
  }
4569
- async open(ctx) {
4510
+ async _open(ctx) {
4570
4511
  await this._checkStorageVersion();
4571
4512
  (0, import_log12.log)("opening...", void 0, {
4572
- F: __dxlog_file15,
4573
- L: 151,
4513
+ F: __dxlog_file14,
4514
+ L: 157,
4574
4515
  S: this,
4575
4516
  C: (f, a) => f(...a)
4576
4517
  });
4577
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.begin({
4518
+ import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.begin({
4578
4519
  id: this._instanceId
4579
4520
  }), {
4580
- F: __dxlog_file15,
4581
- L: 152,
4521
+ F: __dxlog_file14,
4522
+ L: 158,
4582
4523
  S: this,
4583
4524
  C: (f, a) => f(...a)
4584
4525
  });
4585
4526
  await this.signalManager.open();
4586
4527
  await this.networkManager.open();
4528
+ await this.automergeHost.open();
4587
4529
  await this.metadataStore.load();
4588
4530
  await this.spaceManager.open();
4589
4531
  await this.identityManager.open(ctx);
4590
4532
  if (this.identityManager.identity) {
4591
4533
  await this._initialize(ctx);
4592
4534
  }
4593
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.end({
4535
+ import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
4594
4536
  id: this._instanceId
4595
4537
  }), {
4596
- F: __dxlog_file15,
4597
- L: 162,
4538
+ F: __dxlog_file14,
4539
+ L: 169,
4598
4540
  S: this,
4599
4541
  C: (f, a) => f(...a)
4600
4542
  });
4601
4543
  (0, import_log12.log)("opened", void 0, {
4602
- F: __dxlog_file15,
4603
- L: 163,
4544
+ F: __dxlog_file14,
4545
+ L: 170,
4604
4546
  S: this,
4605
4547
  C: (f, a) => f(...a)
4606
4548
  });
4607
4549
  }
4608
- async close() {
4550
+ async _close() {
4609
4551
  (0, import_log12.log)("closing...", void 0, {
4610
- F: __dxlog_file15,
4611
- L: 167,
4552
+ F: __dxlog_file14,
4553
+ L: 174,
4612
4554
  S: this,
4613
4555
  C: (f, a) => f(...a)
4614
4556
  });
@@ -4625,8 +4567,8 @@ var ServiceContext = class {
4625
4567
  await this.metadataStore.close();
4626
4568
  await this.indexer.destroy();
4627
4569
  (0, import_log12.log)("closed", void 0, {
4628
- F: __dxlog_file15,
4629
- L: 180,
4570
+ F: __dxlog_file14,
4571
+ L: 187,
4630
4572
  S: this,
4631
4573
  C: (f, a) => f(...a)
4632
4574
  });
@@ -4638,9 +4580,9 @@ var ServiceContext = class {
4638
4580
  }
4639
4581
  getInvitationHandler(invitation) {
4640
4582
  const factory = this._handlerFactories.get(invitation.kind);
4641
- (0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4642
- F: __dxlog_file15,
4643
- L: 191,
4583
+ (0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4584
+ F: __dxlog_file14,
4585
+ L: 198,
4644
4586
  S: this,
4645
4587
  A: [
4646
4588
  "factory",
@@ -4664,15 +4606,15 @@ var ServiceContext = class {
4664
4606
  }
4665
4607
  async _checkStorageVersion() {
4666
4608
  await this.metadataStore.load();
4667
- if (this.metadataStore.version !== import_protocols12.STORAGE_VERSION) {
4668
- throw new import_protocols12.InvalidStorageVersionError(import_protocols12.STORAGE_VERSION, this.metadataStore.version);
4609
+ if (this.metadataStore.version !== import_protocols11.STORAGE_VERSION) {
4610
+ throw new import_protocols11.InvalidStorageVersionError(import_protocols11.STORAGE_VERSION, this.metadataStore.version);
4669
4611
  }
4670
4612
  }
4671
4613
  // Called when identity is created.
4672
4614
  async _initialize(ctx) {
4673
4615
  (0, import_log12.log)("initializing spaces...", void 0, {
4674
- F: __dxlog_file15,
4675
- L: 222,
4616
+ F: __dxlog_file14,
4617
+ L: 229,
4676
4618
  S: this,
4677
4619
  C: (f, a) => f(...a)
4678
4620
  });
@@ -4692,10 +4634,10 @@ var ServiceContext = class {
4692
4634
  };
4693
4635
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
4694
4636
  await this.dataSpaceManager.open();
4695
- this._handlerFactories.set(import_services12.Invitation.Kind.SPACE, (invitation) => {
4696
- (0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4697
- F: __dxlog_file15,
4698
- L: 246,
4637
+ this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
4638
+ (0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4639
+ F: __dxlog_file14,
4640
+ L: 253,
4699
4641
  S: this,
4700
4642
  A: [
4701
4643
  "this.dataSpaceManager",
@@ -4707,7 +4649,7 @@ var ServiceContext = class {
4707
4649
  this.initialized.wake();
4708
4650
  this._deviceSpaceSync = {
4709
4651
  processCredential: async (credential) => {
4710
- const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
4652
+ const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
4711
4653
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
4712
4654
  return;
4713
4655
  }
@@ -4718,8 +4660,8 @@ var ServiceContext = class {
4718
4660
  (0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
4719
4661
  details: assertion
4720
4662
  }, {
4721
- F: __dxlog_file15,
4722
- L: 262,
4663
+ F: __dxlog_file14,
4664
+ L: 269,
4723
4665
  S: this,
4724
4666
  C: (f, a) => f(...a)
4725
4667
  });
@@ -4729,8 +4671,8 @@ var ServiceContext = class {
4729
4671
  (0, import_log12.log)("space already exists, ignoring space admission", {
4730
4672
  details: assertion
4731
4673
  }, {
4732
- F: __dxlog_file15,
4733
- L: 266,
4674
+ F: __dxlog_file14,
4675
+ L: 273,
4734
4676
  S: this,
4735
4677
  C: (f, a) => f(...a)
4736
4678
  });
@@ -4740,8 +4682,8 @@ var ServiceContext = class {
4740
4682
  (0, import_log12.log)("accepting space recorded in halo", {
4741
4683
  details: assertion
4742
4684
  }, {
4743
- F: __dxlog_file15,
4744
- L: 271,
4685
+ F: __dxlog_file14,
4686
+ L: 278,
4745
4687
  S: this,
4746
4688
  C: (f, a) => f(...a)
4747
4689
  });
@@ -4751,8 +4693,8 @@ var ServiceContext = class {
4751
4693
  });
4752
4694
  } catch (err) {
4753
4695
  import_log12.log.catch(err, void 0, {
4754
- F: __dxlog_file15,
4755
- L: 277,
4696
+ F: __dxlog_file14,
4697
+ L: 284,
4756
4698
  S: this,
4757
4699
  C: (f, a) => f(...a)
4758
4700
  });
@@ -4763,14 +4705,14 @@ var ServiceContext = class {
4763
4705
  }
4764
4706
  };
4765
4707
  _ts_decorate6([
4766
- import_tracing6.trace.span()
4767
- ], ServiceContext.prototype, "open", null);
4708
+ import_tracing5.trace.span()
4709
+ ], ServiceContext.prototype, "_open", null);
4768
4710
  _ts_decorate6([
4769
- import_tracing6.trace.span()
4711
+ import_tracing5.trace.span()
4770
4712
  ], ServiceContext.prototype, "_initialize", null);
4771
4713
  ServiceContext = _ts_decorate6([
4772
4714
  (0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
4773
- import_tracing6.trace.resource()
4715
+ import_tracing5.trace.resource()
4774
4716
  ], ServiceContext);
4775
4717
  var ServiceRegistry = class {
4776
4718
  // prettier-ignore
@@ -4794,103 +4736,155 @@ var ServiceRegistry = class {
4794
4736
  delete this._handlers[name];
4795
4737
  }
4796
4738
  };
4797
- function _ts_decorate7(decorators, target, key, desc) {
4798
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4799
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4800
- r = Reflect.decorate(decorators, target, key, desc);
4801
- else
4802
- for (var i = decorators.length - 1; i >= 0; i--)
4803
- if (d = decorators[i])
4804
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4805
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4806
- }
4807
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
4808
- var Lock = class {
4809
- constructor({ lockKey: lockPath, onAcquire, onRelease }) {
4810
- this._lockPath = lockPath;
4811
- this._onAcquire = onAcquire;
4812
- this._onRelease = onRelease;
4813
- }
4814
- get lockKey() {
4815
- return this._lockPath;
4816
- }
4817
- async acquire() {
4818
- (0, import_log13.log)("acquiring lock...", void 0, {
4819
- F: __dxlog_file16,
4820
- L: 32,
4821
- S: this,
4822
- C: (f, a) => f(...a)
4823
- });
4824
- this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
4825
- await this._onAcquire?.();
4826
- (0, import_log13.log)("acquired lock", void 0, {
4827
- F: __dxlog_file16,
4828
- L: 37,
4829
- S: this,
4830
- C: (f, a) => f(...a)
4831
- });
4739
+ var DXOS_VERSION = "0.4.10-main.e2d2318";
4740
+ var getPlatform = () => {
4741
+ if (process.browser) {
4742
+ if (typeof window !== "undefined") {
4743
+ const { userAgent } = window.navigator;
4744
+ return {
4745
+ type: import_services12.Platform.PLATFORM_TYPE.BROWSER,
4746
+ userAgent,
4747
+ uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
4748
+ };
4749
+ } else {
4750
+ return {
4751
+ type: import_services12.Platform.PLATFORM_TYPE.SHARED_WORKER,
4752
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
4753
+ };
4754
+ }
4755
+ } else {
4756
+ const { platform: platform2, version, arch } = process;
4757
+ return {
4758
+ type: import_services12.Platform.PLATFORM_TYPE.NODE,
4759
+ platform: platform2,
4760
+ arch,
4761
+ runtime: version,
4762
+ uptime: Math.floor(process.uptime()),
4763
+ memory: process.memoryUsage()
4764
+ };
4832
4765
  }
4833
- async release() {
4834
- await this._onRelease?.();
4835
- (0, import_invariant15.invariant)(this._fileHandle, "Lock is not acquired", {
4836
- F: __dxlog_file16,
4837
- L: 42,
4838
- S: this,
4766
+ };
4767
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
4768
+ var DEFAULT_TIMEOUT = 1e3;
4769
+ var createDiagnostics = async (clientServices, serviceContext, config) => {
4770
+ const diagnostics = {
4771
+ created: (/* @__PURE__ */ new Date()).toISOString(),
4772
+ platform: getPlatform(),
4773
+ client: {
4774
+ version: DXOS_VERSION,
4775
+ storage: {
4776
+ version: import_protocols13.STORAGE_VERSION
4777
+ }
4778
+ },
4779
+ trace: import_tracing6.TRACE_PROCESSOR.getDiagnostics()
4780
+ };
4781
+ {
4782
+ (0, import_invariant14.invariant)(clientServices.LoggingService, "SystemService is not available.", {
4783
+ F: __dxlog_file15,
4784
+ L: 108,
4785
+ S: void 0,
4839
4786
  A: [
4840
- "this._fileHandle",
4841
- "'Lock is not acquired'"
4787
+ "clientServices.LoggingService",
4788
+ "'SystemService is not available.'"
4842
4789
  ]
4843
4790
  });
4844
- await import_lock_file.LockFile.release(this._fileHandle);
4845
- }
4846
- };
4847
- _ts_decorate7([
4848
- import_log13.logInfo
4849
- ], Lock.prototype, "lockKey", null);
4850
- var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
4851
- var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
4852
- var createStorageObjects = (config) => {
4853
- const { persistent = false, keyStore, dataStore, dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
4854
- if (persistent && dataStore === StorageDriver.RAM) {
4855
- throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
4791
+ diagnostics.metrics = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
4792
+ timeout: DEFAULT_TIMEOUT
4793
+ }).catch(() => void 0);
4856
4794
  }
4857
- if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
4858
- throw new import_protocols14.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
4795
+ if (typeof navigator !== "undefined" && navigator.storage) {
4796
+ const map = /* @__PURE__ */ new Map();
4797
+ const dir = await navigator.storage.getDirectory();
4798
+ for await (const filename of dir?.keys()) {
4799
+ const idx = filename.indexOf("-", filename.indexOf("-") + 1);
4800
+ if (idx === -1) {
4801
+ continue;
4802
+ }
4803
+ map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
4804
+ }
4805
+ diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
4806
+ file,
4807
+ count
4808
+ }));
4859
4809
  }
4860
- if (persistent && keyStore === StorageDriver.RAM) {
4861
- throw new import_protocols14.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
4810
+ const identity = serviceContext.identityManager.identity;
4811
+ if (identity) {
4812
+ diagnostics.identity = {
4813
+ identityKey: identity.identityKey,
4814
+ spaceKey: identity.space.key,
4815
+ profile: identity.profileDocument
4816
+ };
4817
+ const { devices } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
4818
+ timeout: DEFAULT_TIMEOUT
4819
+ }).catch(() => void 0) ?? {};
4820
+ diagnostics.devices = devices;
4821
+ if (serviceContext.dataSpaceManager) {
4822
+ diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
4823
+ }
4824
+ const { feeds = [] } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
4825
+ timeout: DEFAULT_TIMEOUT
4826
+ }).catch(() => void 0) ?? {};
4827
+ diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
4828
+ feedKey,
4829
+ bytes,
4830
+ length
4831
+ }));
4832
+ const status = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
4833
+ timeout: DEFAULT_TIMEOUT
4834
+ }).catch(() => void 0);
4835
+ diagnostics.networkStatus = status;
4836
+ diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
4862
4837
  }
4863
- if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
4864
- throw new import_protocols14.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
4838
+ diagnostics.config = config.values;
4839
+ return diagnostics;
4840
+ };
4841
+ var getSpaceStats = async (space) => {
4842
+ const stats = {
4843
+ key: space.key,
4844
+ metrics: space.metrics,
4845
+ epochs: space.inner.spaceState.credentials.filter((0, import_credentials15.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
4846
+ ...credential.subject.assertion,
4847
+ id: credential.id
4848
+ })),
4849
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
4850
+ identity: {
4851
+ identityKey: member.key,
4852
+ profile: {
4853
+ displayName: member.assertion.profile?.displayName
4854
+ }
4855
+ },
4856
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services11.SpaceMember.PresenceState.ONLINE : import_services11.SpaceMember.PresenceState.OFFLINE
4857
+ })),
4858
+ pipeline: {
4859
+ // TODO(burdon): Pick properties from credentials if needed.
4860
+ currentEpoch: space.automergeSpaceState.lastEpoch,
4861
+ appliedEpoch: space.automergeSpaceState.lastEpoch,
4862
+ controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
4863
+ currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
4864
+ targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
4865
+ totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
4866
+ }
4867
+ };
4868
+ if (stats.metrics) {
4869
+ const { open, ready } = stats.metrics;
4870
+ stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
4865
4871
  }
4872
+ return stats;
4873
+ };
4874
+ var createCollectDiagnosticsBroadcastSender = () => {
4866
4875
  return {
4867
- storage: (0, import_random_access_storage.createStorage)({
4868
- type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
4869
- root: `${dataRoot}/`
4870
- })
4876
+ broadcastDiagnosticsRequest: async () => void 0
4871
4877
  };
4872
4878
  };
4873
- var toStorageType = (type) => {
4874
- switch (type) {
4875
- case void 0:
4876
- return void 0;
4877
- case StorageDriver.RAM:
4878
- return import_random_access_storage.StorageType.RAM;
4879
- case StorageDriver.CHROME:
4880
- return import_random_access_storage.StorageType.CHROME;
4881
- case StorageDriver.FIREFOX:
4882
- return import_random_access_storage.StorageType.FIREFOX;
4883
- case StorageDriver.IDB:
4884
- return import_random_access_storage.StorageType.IDB;
4885
- case StorageDriver.NODE:
4886
- return import_random_access_storage.StorageType.NODE;
4887
- case StorageDriver.WEBFS:
4888
- return import_random_access_storage.StorageType.WEBFS;
4889
- default:
4890
- throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
4891
- }
4879
+ var createCollectDiagnosticsBroadcastHandler = (_) => {
4880
+ return {
4881
+ start: () => {
4882
+ },
4883
+ stop: () => {
4884
+ }
4885
+ };
4892
4886
  };
4893
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
4887
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
4894
4888
  var DevicesServiceImpl = class {
4895
4889
  constructor(_identityManager) {
4896
4890
  this._identityManager = _identityManager;
@@ -4907,8 +4901,8 @@ var DevicesServiceImpl = class {
4907
4901
  devices: []
4908
4902
  });
4909
4903
  } else {
4910
- (0, import_invariant17.invariant)(this._identityManager.identity?.presence, "presence not present", {
4911
- F: __dxlog_file17,
4904
+ (0, import_invariant16.invariant)(this._identityManager.identity?.presence, "presence not present", {
4905
+ F: __dxlog_file16,
4912
4906
  L: 32,
4913
4907
  S: this,
4914
4908
  A: [
@@ -4923,9 +4917,9 @@ var DevicesServiceImpl = class {
4923
4917
  const peerState = peers.find((peer) => peer.identityKey.equals(key));
4924
4918
  return {
4925
4919
  deviceKey: key,
4926
- kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services14.DeviceKind.CURRENT : import_services14.DeviceKind.TRUSTED,
4920
+ kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services15.DeviceKind.CURRENT : import_services15.DeviceKind.TRUSTED,
4927
4921
  profile,
4928
- presence: isMe ? import_services14.Device.PresenceState.ONLINE : peerState ? import_services14.Device.PresenceState.ONLINE : import_services14.Device.PresenceState.OFFLINE
4922
+ presence: isMe ? import_services15.Device.PresenceState.ONLINE : peerState ? import_services15.Device.PresenceState.ONLINE : import_services15.Device.PresenceState.OFFLINE
4929
4923
  };
4930
4924
  })
4931
4925
  });
@@ -4966,6 +4960,60 @@ var DevicesServiceImpl = class {
4966
4960
  });
4967
4961
  }
4968
4962
  };
4963
+ function _ts_decorate7(decorators, target, key, desc) {
4964
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4965
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4966
+ r = Reflect.decorate(decorators, target, key, desc);
4967
+ else
4968
+ for (var i = decorators.length - 1; i >= 0; i--)
4969
+ if (d = decorators[i])
4970
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4971
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4972
+ }
4973
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
4974
+ var Lock = class {
4975
+ constructor({ lockKey: lockPath, onAcquire, onRelease }) {
4976
+ this._lockPath = lockPath;
4977
+ this._onAcquire = onAcquire;
4978
+ this._onRelease = onRelease;
4979
+ }
4980
+ get lockKey() {
4981
+ return this._lockPath;
4982
+ }
4983
+ async acquire() {
4984
+ (0, import_log14.log)("acquiring lock...", void 0, {
4985
+ F: __dxlog_file17,
4986
+ L: 32,
4987
+ S: this,
4988
+ C: (f, a) => f(...a)
4989
+ });
4990
+ this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
4991
+ await this._onAcquire?.();
4992
+ (0, import_log14.log)("acquired lock", void 0, {
4993
+ F: __dxlog_file17,
4994
+ L: 37,
4995
+ S: this,
4996
+ C: (f, a) => f(...a)
4997
+ });
4998
+ }
4999
+ async release() {
5000
+ await this._onRelease?.();
5001
+ (0, import_invariant17.invariant)(this._fileHandle, "Lock is not acquired", {
5002
+ F: __dxlog_file17,
5003
+ L: 42,
5004
+ S: this,
5005
+ A: [
5006
+ "this._fileHandle",
5007
+ "'Lock is not acquired'"
5008
+ ]
5009
+ });
5010
+ await import_lock_file.LockFile.release(this._fileHandle);
5011
+ }
5012
+ };
5013
+ _ts_decorate7([
5014
+ import_log14.logInfo
5015
+ ], Lock.prototype, "lockKey", null);
5016
+ var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
4969
5017
  var LoggingServiceImpl = class {
4970
5018
  constructor() {
4971
5019
  this._logs = new import_async18.Event();
@@ -5065,18 +5113,18 @@ var LoggingServiceImpl = class {
5065
5113
  });
5066
5114
  }
5067
5115
  };
5068
- var matchFilter = (filter, level, path, options) => {
5116
+ var matchFilter = (filter, level, path2, options) => {
5069
5117
  switch (options) {
5070
- case import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5071
- return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
5072
- case import_services15.QueryLogsRequest.MatchingOptions.EXPLICIT:
5073
- return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
5118
+ case import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5119
+ return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
5120
+ case import_services16.QueryLogsRequest.MatchingOptions.EXPLICIT:
5121
+ return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
5074
5122
  }
5075
5123
  };
5076
5124
  var shouldLog = (entry2, request) => {
5077
- const options = request.options ?? import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5125
+ const options = request.options ?? import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5078
5126
  if (request.filters === void 0) {
5079
- return options === import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5127
+ return options === import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5080
5128
  } else {
5081
5129
  return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
5082
5130
  }
@@ -5112,6 +5160,63 @@ var NetworkServiceImpl = class {
5112
5160
  await this.networkManager.setConnectionState(request.swarm);
5113
5161
  }
5114
5162
  };
5163
+ var getRootPath = (config) => {
5164
+ const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol5.DX_DATA : "dxos/storage" } = config ?? {};
5165
+ return `${dataRoot}/`;
5166
+ };
5167
+ var isPersistent = (config) => {
5168
+ const { persistent = false } = config ?? {};
5169
+ return config.dataStore !== void 0 && config.dataStore !== import_config3.Runtime.Client.Storage.StorageDriver.RAM || persistent;
5170
+ };
5171
+ var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
5172
+ var createStorageObjects = (config) => {
5173
+ const { persistent = false, keyStore, dataStore } = config ?? {};
5174
+ if (persistent && dataStore === StorageDriver.RAM) {
5175
+ throw new import_protocols15.InvalidConfigError("RAM storage cannot be used in persistent mode.");
5176
+ }
5177
+ if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
5178
+ throw new import_protocols15.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
5179
+ }
5180
+ if (persistent && keyStore === StorageDriver.RAM) {
5181
+ throw new import_protocols15.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
5182
+ }
5183
+ if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
5184
+ throw new import_protocols15.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
5185
+ }
5186
+ return {
5187
+ storage: (0, import_random_access_storage.createStorage)({
5188
+ type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
5189
+ root: getRootPath(config)
5190
+ })
5191
+ };
5192
+ };
5193
+ var toStorageType = (type) => {
5194
+ switch (type) {
5195
+ case void 0:
5196
+ return void 0;
5197
+ case StorageDriver.RAM:
5198
+ return import_random_access_storage.StorageType.RAM;
5199
+ case StorageDriver.CHROME:
5200
+ return import_random_access_storage.StorageType.CHROME;
5201
+ case StorageDriver.FIREFOX:
5202
+ return import_random_access_storage.StorageType.FIREFOX;
5203
+ case StorageDriver.IDB:
5204
+ return import_random_access_storage.StorageType.IDB;
5205
+ case StorageDriver.NODE:
5206
+ return import_random_access_storage.StorageType.NODE;
5207
+ case StorageDriver.WEBFS:
5208
+ return import_random_access_storage.StorageType.WEBFS;
5209
+ default:
5210
+ throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
5211
+ }
5212
+ };
5213
+ var createLevel = async (config) => {
5214
+ const persistent = isPersistent(config);
5215
+ const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys13.PublicKey.random().toHex()}`;
5216
+ const level = new import_level.Level(storagePath);
5217
+ await level.open();
5218
+ return level;
5219
+ };
5115
5220
  var SystemServiceImpl = class {
5116
5221
  constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
5117
5222
  this._config = config;
@@ -5131,9 +5236,9 @@ var SystemServiceImpl = class {
5131
5236
  const diagnostics = await this._getDiagnostics();
5132
5237
  return {
5133
5238
  timestamp: /* @__PURE__ */ new Date(),
5134
- diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util11.jsonKeyReplacer)({
5135
- truncate: keys === import_services16.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
5136
- humanize: keys === import_services16.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
5239
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
5240
+ truncate: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
5241
+ humanize: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
5137
5242
  })))
5138
5243
  };
5139
5244
  }
@@ -5181,16 +5286,18 @@ var ClientServicesHost = class {
5181
5286
  transportFactory,
5182
5287
  signalManager,
5183
5288
  storage,
5289
+ level,
5184
5290
  // TODO(wittjosiah): Turn this on by default.
5185
5291
  lockKey,
5186
5292
  callbacks,
5187
5293
  runtimeParams
5188
5294
  } = {}) {
5189
- this._tracingService = import_tracing7.TRACE_PROCESSOR.createTraceSender();
5295
+ this._tracingService = import_tracing8.TRACE_PROCESSOR.createTraceSender();
5190
5296
  this._statusUpdate = new import_async16.Event();
5191
5297
  this._opening = false;
5192
5298
  this._open = false;
5193
5299
  this._storage = storage;
5300
+ this._level = level;
5194
5301
  this._callbacks = callbacks;
5195
5302
  this._runtimeParams = runtimeParams;
5196
5303
  if (config) {
@@ -5214,14 +5321,14 @@ var ClientServicesHost = class {
5214
5321
  this._systemService = new SystemServiceImpl({
5215
5322
  config: () => this._config,
5216
5323
  statusUpdate: this._statusUpdate,
5217
- getCurrentStatus: () => this.isOpen ? import_services13.SystemStatus.ACTIVE : import_services13.SystemStatus.INACTIVE,
5324
+ getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
5218
5325
  getDiagnostics: () => {
5219
5326
  return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
5220
5327
  },
5221
5328
  onUpdateStatus: async (status) => {
5222
- if (!this.isOpen && status === import_services13.SystemStatus.ACTIVE) {
5329
+ if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
5223
5330
  await this._resourceLock?.acquire();
5224
- } else if (this.isOpen && status === import_services13.SystemStatus.INACTIVE) {
5331
+ } else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
5225
5332
  await this._resourceLock?.release();
5226
5333
  }
5227
5334
  },
@@ -5229,8 +5336,9 @@ var ClientServicesHost = class {
5229
5336
  await this.reset();
5230
5337
  }
5231
5338
  });
5339
+ this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
5232
5340
  this._loggingService = new LoggingServiceImpl();
5233
- this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
5341
+ this._serviceRegistry = new ServiceRegistry(import_client_protocol4.clientServiceBundle, {
5234
5342
  SystemService: this._systemService,
5235
5343
  TracingService: this._tracingService
5236
5344
  });
@@ -5259,25 +5367,25 @@ var ClientServicesHost = class {
5259
5367
  * Can only be called once.
5260
5368
  */
5261
5369
  initialize({ config, ...options }) {
5262
- (0, import_invariant16.invariant)(!this._open, "service host is open", {
5370
+ (0, import_invariant15.invariant)(!this._open, "service host is open", {
5263
5371
  F: __dxlog_file18,
5264
- L: 180,
5372
+ L: 197,
5265
5373
  S: this,
5266
5374
  A: [
5267
5375
  "!this._open",
5268
5376
  "'service host is open'"
5269
5377
  ]
5270
5378
  });
5271
- (0, import_log14.log)("initializing...", void 0, {
5379
+ (0, import_log13.log)("initializing...", void 0, {
5272
5380
  F: __dxlog_file18,
5273
- L: 181,
5381
+ L: 198,
5274
5382
  S: this,
5275
5383
  C: (f, a) => f(...a)
5276
5384
  });
5277
5385
  if (config) {
5278
- (0, import_invariant16.invariant)(!this._config, "config already set", {
5386
+ (0, import_invariant15.invariant)(!this._config, "config already set", {
5279
5387
  F: __dxlog_file18,
5280
- L: 184,
5388
+ L: 201,
5281
5389
  S: this,
5282
5390
  A: [
5283
5391
  "!this._config",
@@ -5290,9 +5398,9 @@ var ClientServicesHost = class {
5290
5398
  }
5291
5399
  }
5292
5400
  if (!options.signalManager) {
5293
- import_log14.log.warn("running signaling without telemetry metadata.", void 0, {
5401
+ import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
5294
5402
  F: __dxlog_file18,
5295
- L: 192,
5403
+ L: 209,
5296
5404
  S: this,
5297
5405
  C: (f, a) => f(...a)
5298
5406
  });
@@ -5301,9 +5409,9 @@ var ClientServicesHost = class {
5301
5409
  iceServers: this._config?.get("runtime.services.ice")
5302
5410
  }), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
5303
5411
  this._signalManager = signalManager;
5304
- (0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
5412
+ (0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
5305
5413
  F: __dxlog_file18,
5306
- L: 203,
5414
+ L: 220,
5307
5415
  S: this,
5308
5416
  A: [
5309
5417
  "!this._networkManager",
@@ -5315,9 +5423,9 @@ var ClientServicesHost = class {
5315
5423
  transportFactory,
5316
5424
  signalManager
5317
5425
  });
5318
- (0, import_log14.log)("initialized", void 0, {
5426
+ (0, import_log13.log)("initialized", void 0, {
5319
5427
  F: __dxlog_file18,
5320
- L: 210,
5428
+ L: 227,
5321
5429
  S: this,
5322
5430
  C: (f, a) => f(...a)
5323
5431
  });
@@ -5327,44 +5435,44 @@ var ClientServicesHost = class {
5327
5435
  return;
5328
5436
  }
5329
5437
  const traceId = import_keys11.PublicKey.random().toHex();
5330
- import_log14.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
5438
+ import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
5331
5439
  id: traceId
5332
5440
  }), {
5333
5441
  F: __dxlog_file18,
5334
- L: 221,
5442
+ L: 238,
5335
5443
  S: this,
5336
5444
  C: (f, a) => f(...a)
5337
5445
  });
5338
- (0, import_invariant16.invariant)(this._config, "config not set", {
5446
+ (0, import_invariant15.invariant)(this._config, "config not set", {
5339
5447
  F: __dxlog_file18,
5340
- L: 223,
5448
+ L: 240,
5341
5449
  S: this,
5342
5450
  A: [
5343
5451
  "this._config",
5344
5452
  "'config not set'"
5345
5453
  ]
5346
5454
  });
5347
- (0, import_invariant16.invariant)(this._storage, "storage not set", {
5455
+ (0, import_invariant15.invariant)(this._storage, "storage not set", {
5348
5456
  F: __dxlog_file18,
5349
- L: 224,
5457
+ L: 241,
5350
5458
  S: this,
5351
5459
  A: [
5352
5460
  "this._storage",
5353
5461
  "'storage not set'"
5354
5462
  ]
5355
5463
  });
5356
- (0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
5464
+ (0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
5357
5465
  F: __dxlog_file18,
5358
- L: 225,
5466
+ L: 242,
5359
5467
  S: this,
5360
5468
  A: [
5361
5469
  "this._signalManager",
5362
5470
  "'signal manager not set'"
5363
5471
  ]
5364
5472
  });
5365
- (0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
5473
+ (0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
5366
5474
  F: __dxlog_file18,
5367
- L: 226,
5475
+ L: 243,
5368
5476
  S: this,
5369
5477
  A: [
5370
5478
  "this._networkManager",
@@ -5372,17 +5480,21 @@ var ClientServicesHost = class {
5372
5480
  ]
5373
5481
  });
5374
5482
  this._opening = true;
5375
- (0, import_log14.log)("opening...", {
5483
+ (0, import_log13.log)("opening...", {
5376
5484
  lockKey: this._resourceLock?.lockKey
5377
5485
  }, {
5378
5486
  F: __dxlog_file18,
5379
- L: 229,
5487
+ L: 246,
5380
5488
  S: this,
5381
5489
  C: (f, a) => f(...a)
5382
5490
  });
5491
+ if (!this._level) {
5492
+ this._level = await createLevel(this._config.get("runtime.client.storage", {}));
5493
+ }
5494
+ await this._level.open();
5383
5495
  await this._resourceLock?.acquire();
5384
5496
  await this._loggingService.open();
5385
- this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
5497
+ this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
5386
5498
  this._serviceRegistry.setServices({
5387
5499
  SystemService: this._systemService,
5388
5500
  IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
@@ -5392,7 +5504,7 @@ var ClientServicesHost = class {
5392
5504
  await this._serviceContext.initialized.wait();
5393
5505
  return this._serviceContext.dataSpaceManager;
5394
5506
  }),
5395
- DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.automergeHost),
5507
+ DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
5396
5508
  IndexService: new import_indexing2.IndexServiceImpl({
5397
5509
  indexer: this._serviceContext.indexer,
5398
5510
  automergeHost: this._serviceContext.automergeHost
@@ -5408,9 +5520,9 @@ var ClientServicesHost = class {
5408
5520
  })
5409
5521
  });
5410
5522
  await this._serviceContext.open(ctx);
5411
- (0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
5523
+ (0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
5412
5524
  F: __dxlog_file18,
5413
- L: 290,
5525
+ L: 314,
5414
5526
  S: this,
5415
5527
  A: [
5416
5528
  "this.serviceRegistry.services.InvitationsService",
@@ -5418,11 +5530,11 @@ var ClientServicesHost = class {
5418
5530
  ]
5419
5531
  });
5420
5532
  const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
5421
- (0, import_log14.log)("loaded persistent invitations", {
5533
+ (0, import_log13.log)("loaded persistent invitations", {
5422
5534
  count: loadedInvitations.invitations?.length
5423
5535
  }, {
5424
5536
  F: __dxlog_file18,
5425
- L: 293,
5537
+ L: 317,
5426
5538
  S: this,
5427
5539
  C: (f, a) => f(...a)
5428
5540
  });
@@ -5431,28 +5543,29 @@ var ClientServicesHost = class {
5431
5543
  this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
5432
5544
  url: devtoolsProxy,
5433
5545
  requested: {},
5434
- exposed: import_client_protocol5.clientServiceBundle,
5546
+ exposed: import_client_protocol4.clientServiceBundle,
5435
5547
  handlers: this.services
5436
5548
  });
5437
5549
  void this._devtoolsProxy.open();
5438
5550
  }
5551
+ this.diagnosticsBroadcastHandler.start();
5439
5552
  this._opening = false;
5440
5553
  this._open = true;
5441
5554
  this._statusUpdate.emit();
5442
5555
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
5443
- (0, import_log14.log)("opened", {
5556
+ (0, import_log13.log)("opened", {
5444
5557
  deviceKey
5445
5558
  }, {
5446
5559
  F: __dxlog_file18,
5447
- L: 310,
5560
+ L: 335,
5448
5561
  S: this,
5449
5562
  C: (f, a) => f(...a)
5450
5563
  });
5451
- import_log14.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
5564
+ import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.end({
5452
5565
  id: traceId
5453
5566
  }), {
5454
5567
  F: __dxlog_file18,
5455
- L: 311,
5568
+ L: 336,
5456
5569
  S: this,
5457
5570
  C: (f, a) => f(...a)
5458
5571
  });
@@ -5462,60 +5575,62 @@ var ClientServicesHost = class {
5462
5575
  return;
5463
5576
  }
5464
5577
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
5465
- (0, import_log14.log)("closing...", {
5578
+ (0, import_log13.log)("closing...", {
5466
5579
  deviceKey
5467
5580
  }, {
5468
5581
  F: __dxlog_file18,
5469
- L: 322,
5582
+ L: 347,
5470
5583
  S: this,
5471
5584
  C: (f, a) => f(...a)
5472
5585
  });
5586
+ this.diagnosticsBroadcastHandler.stop();
5473
5587
  await this._devtoolsProxy?.close();
5474
5588
  this._serviceRegistry.setServices({
5475
5589
  SystemService: this._systemService
5476
5590
  });
5477
5591
  await this._loggingService.close();
5478
5592
  await this._serviceContext.close();
5593
+ await this._level?.close();
5479
5594
  this._open = false;
5480
5595
  this._statusUpdate.emit();
5481
- (0, import_log14.log)("closed", {
5596
+ (0, import_log13.log)("closed", {
5482
5597
  deviceKey
5483
5598
  }, {
5484
5599
  F: __dxlog_file18,
5485
- L: 329,
5600
+ L: 356,
5486
5601
  S: this,
5487
5602
  C: (f, a) => f(...a)
5488
5603
  });
5489
5604
  }
5490
5605
  async reset() {
5491
5606
  const traceId = import_keys11.PublicKey.random().toHex();
5492
- import_log14.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
5607
+ import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
5493
5608
  id: traceId
5494
5609
  }), {
5495
5610
  F: __dxlog_file18,
5496
- L: 334,
5611
+ L: 361,
5497
5612
  S: this,
5498
5613
  C: (f, a) => f(...a)
5499
5614
  });
5500
- (0, import_log14.log)("resetting...", void 0, {
5615
+ (0, import_log13.log)("resetting...", void 0, {
5501
5616
  F: __dxlog_file18,
5502
- L: 336,
5617
+ L: 363,
5503
5618
  S: this,
5504
5619
  C: (f, a) => f(...a)
5505
5620
  });
5506
5621
  await this._serviceContext?.close();
5507
5622
  await this._storage.reset();
5508
- (0, import_log14.log)("reset", void 0, {
5623
+ (0, import_log13.log)("reset", void 0, {
5509
5624
  F: __dxlog_file18,
5510
- L: 339,
5625
+ L: 366,
5511
5626
  S: this,
5512
5627
  C: (f, a) => f(...a)
5513
5628
  });
5514
- import_log14.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
5629
+ import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.end({
5515
5630
  id: traceId
5516
5631
  }), {
5517
5632
  F: __dxlog_file18,
5518
- L: 340,
5633
+ L: 367,
5519
5634
  S: this,
5520
5635
  C: (f, a) => f(...a)
5521
5636
  });
@@ -5526,9 +5641,9 @@ var ClientServicesHost = class {
5526
5641
  await this._serviceContext.initialized.wait();
5527
5642
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5528
5643
  const automergeIndex = space.automergeSpaceState.rootUrl;
5529
- (0, import_invariant16.invariant)(automergeIndex, void 0, {
5644
+ (0, import_invariant15.invariant)(automergeIndex, void 0, {
5530
5645
  F: __dxlog_file18,
5531
- L: 352,
5646
+ L: 379,
5532
5647
  S: this,
5533
5648
  A: [
5534
5649
  "automergeIndex",
@@ -5537,47 +5652,88 @@ var ClientServicesHost = class {
5537
5652
  });
5538
5653
  const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5539
5654
  await document.whenReady();
5540
- const objectDocument = (0, import_echo_schema.createRawObjectDoc)({
5541
- [import_client_protocol5.defaultKey]: identity.identityKey.toHex()
5542
- }, {
5543
- type: E.getTypeReference(import_client_protocol5.PropertiesSchema)
5544
- });
5655
+ const properties = {
5656
+ system: {
5657
+ type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema.getTypeReference)(import_client_protocol4.Properties))
5658
+ },
5659
+ data: {
5660
+ [import_client_protocol4.defaultKey]: identity.identityKey.toHex()
5661
+ },
5662
+ meta: {
5663
+ keys: []
5664
+ }
5665
+ };
5666
+ const propertiesId = import_keys11.PublicKey.random().toHex();
5545
5667
  document.change((doc) => {
5546
5668
  (0, import_util9.assignDeep)(doc, [
5547
5669
  "objects",
5548
- objectDocument.id
5549
- ], objectDocument.handle.docSync());
5670
+ propertiesId
5671
+ ], properties);
5550
5672
  });
5551
- await (0, import_async16.sleep)(200);
5673
+ await this._serviceContext.automergeHost.repo.flush();
5552
5674
  return identity;
5553
5675
  }
5554
5676
  };
5555
5677
  _ts_decorate8([
5556
- import_tracing7.trace.info()
5678
+ import_tracing8.trace.info()
5557
5679
  ], ClientServicesHost.prototype, "_opening", void 0);
5558
5680
  _ts_decorate8([
5559
- import_tracing7.trace.info()
5681
+ import_tracing8.trace.info()
5560
5682
  ], ClientServicesHost.prototype, "_open", void 0);
5561
5683
  _ts_decorate8([
5562
5684
  import_async16.synchronized,
5563
- import_tracing7.trace.span()
5685
+ import_tracing8.trace.span()
5564
5686
  ], ClientServicesHost.prototype, "open", null);
5565
5687
  _ts_decorate8([
5566
5688
  import_async16.synchronized,
5567
- import_tracing7.trace.span()
5689
+ import_tracing8.trace.span()
5568
5690
  ], ClientServicesHost.prototype, "close", null);
5569
5691
  ClientServicesHost = _ts_decorate8([
5570
- import_tracing7.trace.resource()
5692
+ import_tracing8.trace.resource()
5571
5693
  ], ClientServicesHost);
5694
+ var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
5695
+ var DiagnosticsCollector = class {
5696
+ static {
5697
+ this.broadcastSender = createCollectDiagnosticsBroadcastSender();
5698
+ }
5699
+ static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
5700
+ const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
5701
+ keys: options.humanize ? import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
5702
+ });
5703
+ const clientDiagnostics = {
5704
+ config,
5705
+ trace: import_tracing7.TRACE_PROCESSOR.getDiagnostics()
5706
+ };
5707
+ const diagnostics = serviceDiagnostics != null ? {
5708
+ client: clientDiagnostics,
5709
+ services: serviceDiagnostics
5710
+ } : {
5711
+ client: clientDiagnostics,
5712
+ broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
5713
+ };
5714
+ return JSON.parse(JSON.stringify(diagnostics, (0, import_util8.jsonKeyReplacer)(options)));
5715
+ }
5716
+ };
5717
+ var findSystemServiceProvider = () => {
5718
+ const serviceProviders = import_tracing7.TRACE_PROCESSOR.findByAnnotation(ClientServicesProviderResource);
5719
+ const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
5720
+ return providerResource?.instance?.deref() ?? null;
5721
+ };
5722
+ var findConfigs = () => {
5723
+ const configs = import_tracing7.TRACE_PROCESSOR.findByAnnotation(import_config.ConfigResource);
5724
+ return configs.map((r) => r.instance.deref()).filter(import_util8.nonNullable);
5725
+ };
5572
5726
  // Annotate the CommonJS export names for ESM import in node:
5573
5727
  0 && (module.exports = {
5574
5728
  ClientRpcServer,
5575
5729
  ClientServicesHost,
5730
+ ClientServicesProviderResource,
5576
5731
  DataSpace,
5577
5732
  DataSpaceManager,
5578
5733
  DeviceInvitationProtocol,
5579
5734
  DevtoolsHostEvents,
5580
5735
  DevtoolsServiceImpl,
5736
+ DiagnosticsCollector,
5581
5737
  Identity,
5582
5738
  IdentityManager,
5583
5739
  IdentityServiceImpl,
@@ -5589,11 +5745,14 @@ ClientServicesHost = _ts_decorate8([
5589
5745
  SpaceInvitationProtocol,
5590
5746
  SpacesServiceImpl,
5591
5747
  TrustedKeySetAuthVerifier,
5748
+ createAdmissionKeypair,
5592
5749
  createAuthProvider,
5750
+ createCollectDiagnosticsBroadcastHandler,
5751
+ createCollectDiagnosticsBroadcastSender,
5593
5752
  createDiagnostics,
5753
+ createLevel,
5594
5754
  createStorageObjects,
5595
5755
  getNetworkPeers,
5596
- invitationExpired,
5597
5756
  isLocked,
5598
5757
  subscribeToFeedBlocks,
5599
5758
  subscribeToFeeds,
@@ -5603,4 +5762,4 @@ ClientServicesHost = _ts_decorate8([
5603
5762
  subscribeToSpaces,
5604
5763
  subscribeToSwarmInfo
5605
5764
  });
5606
- //# sourceMappingURL=chunk-52FE74JI.cjs.map
5765
+ //# sourceMappingURL=chunk-5YDVC6TU.cjs.map