@dxos/client-services 0.4.10-main.fa5a270 → 0.4.10-main.fd8ea31

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 (122) hide show
  1. package/dist/lib/browser/{chunk-7PYX6UUA.mjs → chunk-WLE7E36I.mjs} +1518 -1077
  2. package/dist/lib/browser/chunk-WLE7E36I.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +62 -22
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +136 -116
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-4TX623I7.cjs → chunk-YXZQQAQN.cjs} +1409 -1056
  9. package/dist/lib/node/chunk-YXZQQAQN.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +98 -58
  11. package/dist/lib/node/index.cjs.map +3 -3
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/packlets/testing/index.cjs +135 -118
  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/identity/identity-manager.d.ts.map +1 -1
  28. package/dist/types/src/packlets/indexing/util.d.ts +2 -6
  29. package/dist/types/src/packlets/indexing/util.d.ts.map +1 -1
  30. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +3 -1
  31. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  32. package/dist/types/src/packlets/invitations/index.d.ts +1 -0
  33. package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
  34. package/dist/types/src/packlets/invitations/invitation-extension.d.ts +1 -0
  35. package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
  36. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +6 -1
  37. package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
  38. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +8 -4
  39. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  40. package/dist/types/src/packlets/invitations/invitations-manager.d.ts +44 -0
  41. package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -0
  42. package/dist/types/src/packlets/invitations/invitations-service.d.ts +7 -23
  43. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  44. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -1
  45. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  46. package/dist/types/src/packlets/services/index.d.ts +1 -1
  47. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  48. package/dist/types/src/packlets/services/service-context.d.ts +9 -5
  49. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  50. package/dist/types/src/packlets/services/service-host.d.ts +6 -1
  51. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  52. package/dist/types/src/packlets/services/util.d.ts +1 -0
  53. package/dist/types/src/packlets/services/util.d.ts.map +1 -1
  54. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +5 -1
  55. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  56. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  57. package/dist/types/src/packlets/storage/index.d.ts +1 -0
  58. package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
  59. package/dist/types/src/packlets/storage/level.d.ts +4 -0
  60. package/dist/types/src/packlets/storage/level.d.ts.map +1 -0
  61. package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
  62. package/dist/types/src/packlets/storage/util.d.ts +4 -0
  63. package/dist/types/src/packlets/storage/util.d.ts.map +1 -0
  64. package/dist/types/src/packlets/system/system-service.d.ts +1 -1
  65. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  66. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  67. package/dist/types/src/packlets/testing/test-builder.d.ts +7 -2
  68. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  69. package/dist/types/src/packlets/vault/shared-worker-connection.d.ts +5 -5
  70. package/dist/types/src/packlets/vault/shared-worker-connection.d.ts.map +1 -1
  71. package/dist/types/src/packlets/vault/worker-runtime.d.ts +2 -0
  72. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  73. package/dist/types/src/packlets/vault/worker-session.d.ts +2 -0
  74. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  75. package/dist/types/src/version.d.ts +1 -1
  76. package/package.json +36 -34
  77. package/src/index.ts +1 -0
  78. package/src/packlets/devices/devices-service.test.ts +1 -1
  79. package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +94 -0
  80. package/src/packlets/diagnostics/diagnostics-broadcast.ts +20 -0
  81. package/src/packlets/diagnostics/diagnostics-collector.ts +65 -0
  82. package/src/packlets/{services → diagnostics}/diagnostics.ts +2 -2
  83. package/src/packlets/diagnostics/index.ts +7 -0
  84. package/src/packlets/identity/identity-manager.ts +1 -0
  85. package/src/packlets/identity/identity-service.test.ts +1 -1
  86. package/src/packlets/identity/identity.test.ts +3 -0
  87. package/src/packlets/indexing/util.ts +11 -68
  88. package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
  89. package/src/packlets/invitations/device-invitation-protocol.ts +6 -1
  90. package/src/packlets/invitations/index.ts +1 -0
  91. package/src/packlets/invitations/invitation-extension.ts +28 -1
  92. package/src/packlets/invitations/invitation-protocol.ts +7 -1
  93. package/src/packlets/invitations/invitations-handler.ts +75 -96
  94. package/src/packlets/invitations/invitations-manager.ts +271 -0
  95. package/src/packlets/invitations/invitations-service.ts +23 -168
  96. package/src/packlets/invitations/space-invitation-protocol.ts +45 -3
  97. package/src/packlets/network/network-service.test.ts +1 -1
  98. package/src/packlets/services/automerge-host.test.ts +10 -4
  99. package/src/packlets/services/index.ts +1 -1
  100. package/src/packlets/services/service-context.test.ts +9 -6
  101. package/src/packlets/services/service-context.ts +30 -11
  102. package/src/packlets/services/service-host.ts +63 -24
  103. package/src/packlets/services/service-registry.test.ts +1 -1
  104. package/src/packlets/services/util.ts +2 -0
  105. package/src/packlets/spaces/data-space-manager.test.ts +4 -4
  106. package/src/packlets/spaces/data-space-manager.ts +48 -2
  107. package/src/packlets/spaces/data-space.ts +51 -2
  108. package/src/packlets/spaces/spaces-service.test.ts +1 -1
  109. package/src/packlets/storage/index.ts +1 -0
  110. package/src/packlets/storage/level.ts +19 -0
  111. package/src/packlets/storage/storage.ts +3 -9
  112. package/src/packlets/storage/util.ts +19 -0
  113. package/src/packlets/system/system-service.ts +1 -1
  114. package/src/packlets/testing/invitation-utils.ts +100 -97
  115. package/src/packlets/testing/test-builder.ts +42 -6
  116. package/src/packlets/vault/shared-worker-connection.ts +3 -8
  117. package/src/packlets/vault/worker-runtime.ts +27 -2
  118. package/src/packlets/vault/worker-session.ts +6 -0
  119. package/src/version.ts +1 -1
  120. package/dist/lib/browser/chunk-7PYX6UUA.mjs.map +0 -7
  121. package/dist/lib/node/chunk-4TX623I7.cjs.map +0 -7
  122. package/dist/types/src/packlets/services/diagnostics.d.ts.map +0 -1
@@ -26,19 +26,22 @@ 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_4TX623I7_exports = {};
30
- __export(chunk_4TX623I7_exports, {
29
+ var chunk_YXZQQAQN_exports = {};
30
+ __export(chunk_YXZQQAQN_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,
41
43
  InvitationsHandler: () => InvitationsHandler,
44
+ InvitationsManager: () => InvitationsManager,
42
45
  InvitationsServiceImpl: () => InvitationsServiceImpl,
43
46
  Lock: () => Lock,
44
47
  ServiceContext: () => ServiceContext,
@@ -46,11 +49,14 @@ __export(chunk_4TX623I7_exports, {
46
49
  SpaceInvitationProtocol: () => SpaceInvitationProtocol,
47
50
  SpacesServiceImpl: () => SpacesServiceImpl,
48
51
  TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
52
+ createAdmissionKeypair: () => createAdmissionKeypair,
49
53
  createAuthProvider: () => createAuthProvider,
54
+ createCollectDiagnosticsBroadcastHandler: () => createCollectDiagnosticsBroadcastHandler,
55
+ createCollectDiagnosticsBroadcastSender: () => createCollectDiagnosticsBroadcastSender,
50
56
  createDiagnostics: () => createDiagnostics,
57
+ createLevel: () => createLevel,
51
58
  createStorageObjects: () => createStorageObjects,
52
59
  getNetworkPeers: () => getNetworkPeers,
53
- invitationExpired: () => invitationExpired,
54
60
  isLocked: () => isLocked,
55
61
  subscribeToFeedBlocks: () => subscribeToFeedBlocks,
56
62
  subscribeToFeeds: () => subscribeToFeeds,
@@ -60,7 +66,7 @@ __export(chunk_4TX623I7_exports, {
60
66
  subscribeToSpaces: () => subscribeToSpaces,
61
67
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
68
  });
63
- module.exports = __toCommonJS(chunk_4TX623I7_exports);
69
+ module.exports = __toCommonJS(chunk_YXZQQAQN_exports);
64
70
  var import_async = require("@dxos/async");
65
71
  var import_codec_protobuf = require("@dxos/codec-protobuf");
66
72
  var import_feed_store = require("@dxos/feed-store");
@@ -114,7 +120,7 @@ var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
114
120
  var import_async7 = require("@dxos/async");
115
121
  var import_client_protocol2 = require("@dxos/client-protocol");
116
122
  var import_context4 = require("@dxos/context");
117
- 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");
@@ -131,61 +138,62 @@ var import_protocols5 = require("@dxos/protocols");
131
138
  var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
132
139
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
133
140
  var import_teleport = require("@dxos/teleport");
134
- var import_async9 = require("@dxos/async");
135
141
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
136
- var import_context6 = require("@dxos/context");
137
- var import_invariant7 = require("@dxos/invariant");
138
- var import_log6 = require("@dxos/log");
139
142
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
140
- var import_credentials8 = require("@dxos/credentials");
143
+ var import_credentials7 = require("@dxos/credentials");
141
144
  var import_feed_store3 = require("@dxos/feed-store");
142
- var import_invariant8 = require("@dxos/invariant");
143
- var import_log7 = require("@dxos/log");
145
+ var import_invariant7 = require("@dxos/invariant");
146
+ var import_log6 = require("@dxos/log");
144
147
  var import_protocols6 = require("@dxos/protocols");
145
148
  var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
149
+ var import_credentials8 = require("@dxos/protocols/proto/dxos/halo/credentials");
150
+ var import_async9 = require("@dxos/async");
151
+ var import_client_protocol3 = require("@dxos/client-protocol");
152
+ var import_context6 = require("@dxos/context");
153
+ var import_credentials9 = require("@dxos/credentials");
154
+ var import_echo_pipeline = require("@dxos/echo-pipeline");
155
+ var import_invariant8 = require("@dxos/invariant");
156
+ var import_keys7 = require("@dxos/keys");
157
+ var import_log7 = require("@dxos/log");
158
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
146
159
  var import_codec_protobuf9 = require("@dxos/codec-protobuf");
147
160
  var import_debug2 = require("@dxos/debug");
148
161
  var import_rpc = require("@dxos/rpc");
149
162
  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
163
  var import_async10 = require("@dxos/async");
158
- var import_client_protocol3 = require("@dxos/client-protocol");
164
+ var import_client_protocol4 = require("@dxos/client-protocol");
159
165
  var import_context7 = require("@dxos/context");
160
166
  var import_debug3 = require("@dxos/debug");
161
- var import_echo_pipeline = require("@dxos/echo-pipeline");
162
- var import_invariant10 = require("@dxos/invariant");
163
- var import_keys7 = require("@dxos/keys");
167
+ var import_echo_pipeline2 = require("@dxos/echo-pipeline");
168
+ var import_echo_pipeline3 = require("@dxos/echo-pipeline");
169
+ var import_echo_schema = require("@dxos/echo-schema");
170
+ var import_invariant9 = require("@dxos/invariant");
171
+ var import_keys8 = require("@dxos/keys");
164
172
  var import_log8 = require("@dxos/log");
165
- var import_protocols8 = require("@dxos/protocols");
166
- var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
173
+ var import_protocols7 = require("@dxos/protocols");
174
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
167
175
  var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
168
176
  var import_timeframe2 = require("@dxos/timeframe");
169
- var import_tracing5 = require("@dxos/tracing");
177
+ var import_tracing4 = require("@dxos/tracing");
170
178
  var import_util4 = require("@dxos/util");
171
179
  var import_async11 = require("@dxos/async");
172
180
  var import_credentials11 = require("@dxos/credentials");
173
181
  var import_async12 = require("@dxos/async");
174
182
  var import_context8 = require("@dxos/context");
175
- var import_invariant11 = require("@dxos/invariant");
176
- var import_keys8 = require("@dxos/keys");
183
+ var import_invariant10 = require("@dxos/invariant");
184
+ var import_keys9 = require("@dxos/keys");
177
185
  var import_log9 = require("@dxos/log");
178
- var import_protocols9 = require("@dxos/protocols");
186
+ var import_protocols8 = require("@dxos/protocols");
179
187
  var import_teleport2 = require("@dxos/teleport");
180
188
  var import_util5 = require("@dxos/util");
181
189
  var import_async13 = require("@dxos/async");
182
190
  var import_context9 = require("@dxos/context");
183
191
  var import_credentials12 = require("@dxos/credentials");
184
- var import_invariant12 = require("@dxos/invariant");
185
- var import_keys9 = require("@dxos/keys");
192
+ var import_invariant11 = require("@dxos/invariant");
193
+ var import_keys10 = require("@dxos/keys");
186
194
  var import_log10 = require("@dxos/log");
187
- var import_protocols10 = require("@dxos/protocols");
188
- var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
195
+ var import_protocols9 = require("@dxos/protocols");
196
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
189
197
  var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
190
198
  var import_util6 = require("@dxos/util");
191
199
  var import_credentials13 = require("@dxos/credentials");
@@ -193,69 +201,85 @@ var import_debug4 = require("@dxos/debug");
193
201
  var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
194
202
  var import_timeframe3 = require("@dxos/timeframe");
195
203
  var import_async14 = require("@dxos/async");
196
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
204
+ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
197
205
  var import_debug5 = require("@dxos/debug");
198
- var import_invariant13 = require("@dxos/invariant");
206
+ var import_invariant12 = require("@dxos/invariant");
199
207
  var import_log11 = require("@dxos/log");
200
- var import_protocols11 = require("@dxos/protocols");
201
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
208
+ var import_protocols10 = require("@dxos/protocols");
209
+ var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
202
210
  var import_async15 = require("@dxos/async");
203
211
  var import_context10 = require("@dxos/context");
204
212
  var import_credentials15 = require("@dxos/credentials");
205
213
  var import_debug6 = require("@dxos/debug");
206
- var import_echo_pipeline2 = require("@dxos/echo-pipeline");
214
+ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
207
215
  var import_feed_store4 = require("@dxos/feed-store");
208
216
  var import_indexing = require("@dxos/indexing");
209
- var import_invariant14 = require("@dxos/invariant");
217
+ var import_invariant13 = require("@dxos/invariant");
210
218
  var import_keyring = require("@dxos/keyring");
211
- var import_keys10 = require("@dxos/keys");
219
+ var import_keys11 = require("@dxos/keys");
212
220
  var import_log12 = require("@dxos/log");
213
- var import_protocols12 = require("@dxos/protocols");
214
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
221
+ var import_protocols11 = require("@dxos/protocols");
222
+ var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
215
223
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
216
- var import_tracing6 = require("@dxos/tracing");
224
+ var import_tracing5 = require("@dxos/tracing");
217
225
  var import_util7 = require("@dxos/util");
218
226
  var import_automerge = require("@dxos/automerge/automerge");
219
- var import_debug7 = require("@dxos/debug");
227
+ var import_protocols12 = require("@dxos/protocols");
228
+ var import_codec_protobuf11 = require("@dxos/codec-protobuf");
229
+ var import_credentials16 = require("@dxos/credentials");
230
+ var import_invariant14 = require("@dxos/invariant");
220
231
  var import_protocols13 = require("@dxos/protocols");
221
- var import_invariant15 = require("@dxos/invariant");
222
- var import_lock_file = require("@dxos/lock-file");
223
- var import_log13 = require("@dxos/log");
224
- var import_client_protocol4 = require("@dxos/client-protocol");
225
- var import_protocols14 = require("@dxos/protocols");
226
- var import_config = require("@dxos/protocols/proto/dxos/config");
227
- var import_random_access_storage = require("@dxos/random-access-storage");
232
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
233
+ var import_tracing6 = require("@dxos/tracing");
234
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
235
+ var import_config = require("@dxos/config");
236
+ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
237
+ var import_tracing7 = require("@dxos/tracing");
228
238
  var import_util8 = require("@dxos/util");
229
239
  var import_async16 = require("@dxos/async");
230
240
  var import_client_protocol5 = require("@dxos/client-protocol");
231
241
  var import_context11 = require("@dxos/context");
232
- var import_echo_pipeline3 = require("@dxos/echo-pipeline");
233
- var import_echo_schema = require("@dxos/echo-schema");
242
+ var import_echo_pipeline5 = require("@dxos/echo-pipeline");
243
+ var import_echo_schema2 = require("@dxos/echo-schema");
234
244
  var import_indexing2 = require("@dxos/indexing");
235
- var import_invariant16 = require("@dxos/invariant");
236
- var import_keys11 = require("@dxos/keys");
237
- var import_log14 = require("@dxos/log");
245
+ var import_invariant15 = require("@dxos/invariant");
246
+ var import_keys12 = require("@dxos/keys");
247
+ var import_log13 = require("@dxos/log");
238
248
  var import_messaging = require("@dxos/messaging");
239
249
  var import_network_manager2 = require("@dxos/network-manager");
240
- var import_protocols15 = require("@dxos/protocols");
241
- var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
242
- var import_tracing7 = require("@dxos/tracing");
250
+ var import_protocols14 = require("@dxos/protocols");
251
+ var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
252
+ var import_tracing8 = require("@dxos/tracing");
243
253
  var import_util9 = require("@dxos/util");
244
254
  var import_websocket_rpc = require("@dxos/websocket-rpc");
245
255
  var import_async17 = require("@dxos/async");
246
256
  var import_codec_protobuf12 = require("@dxos/codec-protobuf");
257
+ var import_invariant16 = require("@dxos/invariant");
258
+ var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
247
259
  var import_invariant17 = require("@dxos/invariant");
248
- var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
260
+ var import_lock_file = require("@dxos/lock-file");
261
+ var import_log14 = require("@dxos/log");
249
262
  var import_async18 = require("@dxos/async");
250
263
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
251
- var import_keys12 = require("@dxos/keys");
264
+ var import_keys13 = require("@dxos/keys");
252
265
  var import_log15 = require("@dxos/log");
253
- var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
266
+ var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
254
267
  var import_util10 = require("@dxos/util");
255
268
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
256
- var import_codec_protobuf15 = require("@dxos/codec-protobuf");
257
- var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
269
+ var import_protocols15 = require("@dxos/protocols");
270
+ var import_config2 = require("@dxos/protocols/proto/dxos/config");
271
+ var import_random_access_storage = require("@dxos/random-access-storage");
272
+ var import_client_protocol6 = require("@dxos/client-protocol");
273
+ var import_config3 = require("@dxos/protocols/proto/dxos/config");
258
274
  var import_util11 = require("@dxos/util");
275
+ var import_level = require("level");
276
+ var import_node_path = __toESM(require("node:path"));
277
+ var import_keys14 = require("@dxos/keys");
278
+ var import_codec_protobuf15 = require("@dxos/codec-protobuf");
279
+ var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
280
+ var import_util12 = require("@dxos/util");
281
+ var import_keys15 = require("@dxos/keys");
282
+ var import_util13 = require("@dxos/util");
259
283
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
260
284
  return new import_codec_protobuf.Stream(({ next }) => {
261
285
  const subscriptions = new import_async.EventSubscriptions();
@@ -1273,7 +1297,9 @@ var IdentityManager = class {
1273
1297
  C: (f, a) => f(...a)
1274
1298
  });
1275
1299
  },
1276
- memberKey: identityKey
1300
+ memberKey: identityKey,
1301
+ onDelegatedInvitationStatusChange: async () => {
1302
+ }
1277
1303
  });
1278
1304
  }
1279
1305
  };
@@ -1370,10 +1396,13 @@ var DeviceInvitationProtocol = class {
1370
1396
  kind: import_services2.Invitation.Kind.DEVICE
1371
1397
  };
1372
1398
  }
1373
- async admit(request) {
1399
+ async delegate(invitation) {
1400
+ throw new Error("delegation not supported");
1401
+ }
1402
+ async admit(_, request) {
1374
1403
  (0, import_invariant4.invariant)(request.device, void 0, {
1375
1404
  F: __dxlog_file5,
1376
- L: 37,
1405
+ L: 42,
1377
1406
  S: this,
1378
1407
  A: [
1379
1408
  "request.device",
@@ -1419,7 +1448,7 @@ var DeviceInvitationProtocol = class {
1419
1448
  async accept(response, request) {
1420
1449
  (0, import_invariant4.invariant)(response.device, void 0, {
1421
1450
  F: __dxlog_file5,
1422
- L: 82,
1451
+ L: 87,
1423
1452
  S: this,
1424
1453
  A: [
1425
1454
  "response.device",
@@ -1429,7 +1458,7 @@ var DeviceInvitationProtocol = class {
1429
1458
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1430
1459
  (0, import_invariant4.invariant)(request.device, void 0, {
1431
1460
  F: __dxlog_file5,
1432
- L: 85,
1461
+ L: 90,
1433
1462
  S: this,
1434
1463
  A: [
1435
1464
  "request.device",
@@ -1468,6 +1497,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1468
1497
  this._callbacks = _callbacks;
1469
1498
  this._ctx = new import_context5.Context();
1470
1499
  this._remoteOptionsTrigger = new import_async8.Trigger();
1500
+ this._challenge = void 0;
1471
1501
  this.invitation = void 0;
1472
1502
  this.guestProfile = void 0;
1473
1503
  this.authenticationPassed = false;
@@ -1482,7 +1512,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1482
1512
  options: async (options) => {
1483
1513
  (0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
1484
1514
  F: __dxlog_file6,
1485
- L: 87,
1515
+ L: 90,
1486
1516
  S: this,
1487
1517
  A: [
1488
1518
  "!this._remoteOptions",
@@ -1499,7 +1529,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1499
1529
  id: traceId
1500
1530
  }), {
1501
1531
  F: __dxlog_file6,
1502
- L: 96,
1532
+ L: 99,
1503
1533
  S: this,
1504
1534
  C: (f, a) => f(...a)
1505
1535
  });
@@ -1509,7 +1539,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1509
1539
  invitationId
1510
1540
  }, {
1511
1541
  F: __dxlog_file6,
1512
- L: 100,
1542
+ L: 103,
1513
1543
  S: this,
1514
1544
  C: (f, a) => f(...a)
1515
1545
  });
@@ -1523,7 +1553,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1523
1553
  guestProfile: profile
1524
1554
  }, {
1525
1555
  F: __dxlog_file6,
1526
- L: 109,
1556
+ L: 112,
1527
1557
  S: this,
1528
1558
  C: (f, a) => f(...a)
1529
1559
  });
@@ -1532,25 +1562,27 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1532
1562
  ...this.invitation,
1533
1563
  state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
1534
1564
  });
1565
+ this._challenge = this.invitation.authMethod === import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
1535
1566
  import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.end({
1536
1567
  id: traceId
1537
1568
  }), {
1538
1569
  F: __dxlog_file6,
1539
- L: 116,
1570
+ L: 122,
1540
1571
  S: this,
1541
1572
  C: (f, a) => f(...a)
1542
1573
  });
1543
1574
  return {
1544
- authMethod: this.invitation.authMethod
1575
+ authMethod: this.invitation.authMethod,
1576
+ challenge: this._challenge
1545
1577
  };
1546
1578
  },
1547
- authenticate: async ({ authCode: code }) => {
1579
+ authenticate: async ({ authCode: code, signedChallenge }) => {
1548
1580
  const traceId = import_keys6.PublicKey.random().toHex();
1549
1581
  import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.begin({
1550
1582
  id: traceId
1551
1583
  }), {
1552
1584
  F: __dxlog_file6,
1553
- L: 124,
1585
+ L: 131,
1554
1586
  S: this,
1555
1587
  C: (f, a) => f(...a)
1556
1588
  });
@@ -1558,14 +1590,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1558
1590
  authCode: code
1559
1591
  }, {
1560
1592
  F: __dxlog_file6,
1561
- L: 125,
1593
+ L: 132,
1562
1594
  S: this,
1563
1595
  C: (f, a) => f(...a)
1564
1596
  });
1565
1597
  let status = import_invitations2.AuthenticationResponse.Status.OK;
1566
1598
  (0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
1567
1599
  F: __dxlog_file6,
1568
- L: 128,
1600
+ L: 135,
1569
1601
  S: this,
1570
1602
  A: [
1571
1603
  "this.invitation",
@@ -1576,7 +1608,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1576
1608
  case import_services4.Invitation.AuthMethod.NONE: {
1577
1609
  (0, import_log5.log)("authentication not required", void 0, {
1578
1610
  F: __dxlog_file6,
1579
- L: 131,
1611
+ L: 138,
1580
1612
  S: this,
1581
1613
  C: (f, a) => f(...a)
1582
1614
  });
@@ -1596,12 +1628,25 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1596
1628
  }
1597
1629
  break;
1598
1630
  }
1631
+ case import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
1632
+ if (!this.invitation.guestKeypair) {
1633
+ status = import_invitations2.AuthenticationResponse.Status.INTERNAL_ERROR;
1634
+ break;
1635
+ }
1636
+ const isSignatureValid = this._challenge && (0, import_crypto2.verify)(this._challenge, Buffer.from(signedChallenge ?? []), this.invitation.guestKeypair.publicKey.asBuffer());
1637
+ if (isSignatureValid) {
1638
+ this.authenticationPassed = true;
1639
+ } else {
1640
+ status = import_invitations2.AuthenticationResponse.Status.INVALID_SIGNATURE;
1641
+ }
1642
+ break;
1643
+ }
1599
1644
  default: {
1600
1645
  import_log5.log.error("invalid authentication method", {
1601
1646
  authMethod: this.invitation.authMethod
1602
1647
  }, {
1603
1648
  F: __dxlog_file6,
1604
- L: 149,
1649
+ L: 176,
1605
1650
  S: this,
1606
1651
  C: (f, a) => f(...a)
1607
1652
  });
@@ -1616,7 +1661,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1616
1661
  }
1617
1662
  }), {
1618
1663
  F: __dxlog_file6,
1619
- L: 155,
1664
+ L: 182,
1620
1665
  S: this,
1621
1666
  C: (f, a) => f(...a)
1622
1667
  });
@@ -1630,14 +1675,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1630
1675
  id: traceId
1631
1676
  }), {
1632
1677
  F: __dxlog_file6,
1633
- L: 161,
1678
+ L: 188,
1634
1679
  S: this,
1635
1680
  C: (f, a) => f(...a)
1636
1681
  });
1637
1682
  try {
1638
1683
  (0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
1639
1684
  F: __dxlog_file6,
1640
- L: 164,
1685
+ L: 191,
1641
1686
  S: this,
1642
1687
  A: [
1643
1688
  "this.invitation",
@@ -1652,7 +1697,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1652
1697
  id: traceId
1653
1698
  }), {
1654
1699
  F: __dxlog_file6,
1655
- L: 172,
1700
+ L: 199,
1656
1701
  S: this,
1657
1702
  C: (f, a) => f(...a)
1658
1703
  });
@@ -1709,7 +1754,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1709
1754
  options: async (options) => {
1710
1755
  (0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
1711
1756
  F: __dxlog_file6,
1712
- L: 239,
1757
+ L: 266,
1713
1758
  S: this,
1714
1759
  A: [
1715
1760
  "!this._remoteOptions",
@@ -1736,7 +1781,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1736
1781
  try {
1737
1782
  (0, import_log5.log)("begin options", void 0, {
1738
1783
  F: __dxlog_file6,
1739
- L: 260,
1784
+ L: 287,
1740
1785
  S: this,
1741
1786
  C: (f, a) => f(...a)
1742
1787
  });
@@ -1748,7 +1793,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1748
1793
  }));
1749
1794
  (0, import_log5.log)("end options", void 0, {
1750
1795
  F: __dxlog_file6,
1751
- L: 263,
1796
+ L: 290,
1752
1797
  S: this,
1753
1798
  C: (f, a) => f(...a)
1754
1799
  });
@@ -1762,7 +1807,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1762
1807
  } catch (err) {
1763
1808
  (0, import_log5.log)("openError", err, {
1764
1809
  F: __dxlog_file6,
1765
- L: 273,
1810
+ L: 300,
1766
1811
  S: this,
1767
1812
  C: (f, a) => f(...a)
1768
1813
  });
@@ -1772,7 +1817,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1772
1817
  async onClose() {
1773
1818
  (0, import_log5.log)("onClose", void 0, {
1774
1819
  F: __dxlog_file6,
1775
- L: 279,
1820
+ L: 306,
1776
1821
  S: this,
1777
1822
  C: (f, a) => f(...a)
1778
1823
  });
@@ -1788,49 +1833,7 @@ var InvitationsHandler = class {
1788
1833
  constructor(_networkManager) {
1789
1834
  this._networkManager = _networkManager;
1790
1835
  }
1791
- createInvitation(protocol, options) {
1792
- 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 ?? {};
1793
- const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
1794
- (0, import_invariant5.invariant)(protocol, void 0, {
1795
- F: __dxlog_file7,
1796
- L: 84,
1797
- S: this,
1798
- A: [
1799
- "protocol",
1800
- ""
1801
- ]
1802
- });
1803
- const invitation = {
1804
- invitationId,
1805
- type,
1806
- authMethod,
1807
- state,
1808
- swarmKey,
1809
- authCode,
1810
- timeout,
1811
- persistent,
1812
- created,
1813
- lifetime,
1814
- ...protocol.getInvitationContext()
1815
- };
1816
- const stream = new import_async7.PushStream();
1817
- const ctx = new import_context4.Context({
1818
- onError: (err) => {
1819
- stream.error(err);
1820
- void ctx.dispose();
1821
- }
1822
- });
1823
- ctx.onDispose(() => {
1824
- (0, import_log4.log)("complete", {
1825
- ...protocol.toJSON()
1826
- }, {
1827
- F: __dxlog_file7,
1828
- L: 109,
1829
- S: this,
1830
- C: (f, a) => f(...a)
1831
- });
1832
- stream.complete();
1833
- });
1836
+ handleInvitationFlow(ctx, stream, protocol, invitation) {
1834
1837
  const createExtension = () => {
1835
1838
  const extension = new InvitationHostExtension({
1836
1839
  onStateUpdate: (invitation2) => {
@@ -1839,8 +1842,8 @@ var InvitationsHandler = class {
1839
1842
  state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1840
1843
  });
1841
1844
  },
1842
- resolveInvitation: async ({ invitationId: invitationId2 }) => {
1843
- if (invitationId2 && invitationId2 !== invitation.invitationId) {
1845
+ resolveInvitation: async ({ invitationId }) => {
1846
+ if (invitationId && invitationId !== invitation.invitationId) {
1844
1847
  return void 0;
1845
1848
  }
1846
1849
  return invitation;
@@ -1850,14 +1853,14 @@ var InvitationsHandler = class {
1850
1853
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
1851
1854
  (0, import_invariant5.invariant)(deviceKey, void 0, {
1852
1855
  F: __dxlog_file7,
1853
- L: 130,
1856
+ L: 87,
1854
1857
  S: this,
1855
1858
  A: [
1856
1859
  "deviceKey",
1857
1860
  ""
1858
1861
  ]
1859
1862
  });
1860
- const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
1863
+ const admissionResponse = await protocol.admit(invitation, admissionRequest, extension.guestProfile);
1861
1864
  extension.completedTrigger.wake(deviceKey);
1862
1865
  return admissionResponse;
1863
1866
  } catch (err) {
@@ -1873,7 +1876,7 @@ var InvitationsHandler = class {
1873
1876
  id: traceId
1874
1877
  }), {
1875
1878
  F: __dxlog_file7,
1876
- L: 148,
1879
+ L: 105,
1877
1880
  S: this,
1878
1881
  C: (f, a) => f(...a)
1879
1882
  });
@@ -1881,7 +1884,7 @@ var InvitationsHandler = class {
1881
1884
  ...protocol.toJSON()
1882
1885
  }, {
1883
1886
  F: __dxlog_file7,
1884
- L: 149,
1887
+ L: 106,
1885
1888
  S: this,
1886
1889
  C: (f, a) => f(...a)
1887
1890
  });
@@ -1890,14 +1893,14 @@ var InvitationsHandler = class {
1890
1893
  state: import_services3.Invitation.State.CONNECTED
1891
1894
  });
1892
1895
  const deviceKey = await extension.completedTrigger.wait({
1893
- timeout
1896
+ timeout: invitation.timeout
1894
1897
  });
1895
1898
  (0, import_log4.log)("admitted guest", {
1896
1899
  guest: deviceKey,
1897
1900
  ...protocol.toJSON()
1898
1901
  }, {
1899
1902
  F: __dxlog_file7,
1900
- L: 152,
1903
+ L: 109,
1901
1904
  S: this,
1902
1905
  C: (f, a) => f(...a)
1903
1906
  });
@@ -1909,7 +1912,7 @@ var InvitationsHandler = class {
1909
1912
  id: traceId
1910
1913
  }), {
1911
1914
  F: __dxlog_file7,
1912
- L: 154,
1915
+ L: 111,
1913
1916
  S: this,
1914
1917
  C: (f, a) => f(...a)
1915
1918
  });
@@ -1919,7 +1922,7 @@ var InvitationsHandler = class {
1919
1922
  ...protocol.toJSON()
1920
1923
  }, {
1921
1924
  F: __dxlog_file7,
1922
- L: 157,
1925
+ L: 114,
1923
1926
  S: this,
1924
1927
  C: (f, a) => f(...a)
1925
1928
  });
@@ -1930,7 +1933,7 @@ var InvitationsHandler = class {
1930
1933
  } else {
1931
1934
  import_log4.log.error("failed", err, {
1932
1935
  F: __dxlog_file7,
1933
- L: 160,
1936
+ L: 117,
1934
1937
  S: this,
1935
1938
  C: (f, a) => f(...a)
1936
1939
  });
@@ -1941,12 +1944,12 @@ var InvitationsHandler = class {
1941
1944
  error: err
1942
1945
  }), {
1943
1946
  F: __dxlog_file7,
1944
- L: 163,
1947
+ L: 120,
1945
1948
  S: this,
1946
1949
  C: (f, a) => f(...a)
1947
1950
  });
1948
1951
  } finally {
1949
- if (type !== import_services3.Invitation.Type.MULTIUSE) {
1952
+ if (!invitation.multiUse) {
1950
1953
  await swarmConnection.close();
1951
1954
  await ctx.dispose();
1952
1955
  }
@@ -1962,7 +1965,7 @@ var InvitationsHandler = class {
1962
1965
  ...protocol.toJSON()
1963
1966
  }, {
1964
1967
  F: __dxlog_file7,
1965
- L: 178,
1968
+ L: 135,
1966
1969
  S: this,
1967
1970
  C: (f, a) => f(...a)
1968
1971
  });
@@ -1973,7 +1976,7 @@ var InvitationsHandler = class {
1973
1976
  } else {
1974
1977
  import_log4.log.error("failed", err, {
1975
1978
  F: __dxlog_file7,
1976
- L: 181,
1979
+ L: 138,
1977
1980
  S: this,
1978
1981
  C: (f, a) => f(...a)
1979
1982
  });
@@ -1983,11 +1986,11 @@ var InvitationsHandler = class {
1983
1986
  });
1984
1987
  return extension;
1985
1988
  };
1986
- if (invitation.lifetime && invitation.created && invitation.lifetime !== 0) {
1989
+ if (invitation.lifetime && invitation.created) {
1987
1990
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
1988
1991
  import_log4.log.warn("invitation has already expired", void 0, {
1989
1992
  F: __dxlog_file7,
1990
- L: 192,
1993
+ L: 149,
1991
1994
  S: this,
1992
1995
  C: (f, a) => f(...a)
1993
1996
  });
@@ -2021,24 +2024,12 @@ var InvitationsHandler = class {
2021
2024
  state: import_services3.Invitation.State.CONNECTING
2022
2025
  });
2023
2026
  });
2024
- const observable = new import_client_protocol2.CancellableInvitation({
2025
- initialInvitation: invitation,
2026
- subscriber: stream.observable,
2027
- onCancel: async () => {
2028
- stream.next({
2029
- ...invitation,
2030
- state: import_services3.Invitation.State.CANCELLED
2031
- });
2032
- await ctx.dispose();
2033
- }
2034
- });
2035
- return observable;
2036
2027
  }
2037
2028
  acceptInvitation(protocol, invitation, deviceProfile) {
2038
2029
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
2039
2030
  (0, import_invariant5.invariant)(protocol, void 0, {
2040
2031
  F: __dxlog_file7,
2041
- L: 246,
2032
+ L: 191,
2042
2033
  S: this,
2043
2034
  A: [
2044
2035
  "protocol",
@@ -2048,7 +2039,7 @@ var InvitationsHandler = class {
2048
2039
  if (deviceProfile) {
2049
2040
  (0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2050
2041
  F: __dxlog_file7,
2051
- L: 250,
2042
+ L: 194,
2052
2043
  S: this,
2053
2044
  A: [
2054
2045
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -2063,7 +2054,7 @@ var InvitationsHandler = class {
2063
2054
  const setState = (newData) => {
2064
2055
  (0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
2065
2056
  F: __dxlog_file7,
2066
- L: 261,
2057
+ L: 205,
2067
2058
  S: this,
2068
2059
  A: [
2069
2060
  "newData.state !== undefined",
@@ -2083,7 +2074,7 @@ var InvitationsHandler = class {
2083
2074
  ...protocol.toJSON()
2084
2075
  }, {
2085
2076
  F: __dxlog_file7,
2086
- L: 269,
2077
+ L: 213,
2087
2078
  S: this,
2088
2079
  C: (f, a) => f(...a)
2089
2080
  });
@@ -2093,7 +2084,7 @@ var InvitationsHandler = class {
2093
2084
  } else {
2094
2085
  import_log4.log.warn("auth failed", err, {
2095
2086
  F: __dxlog_file7,
2096
- L: 272,
2087
+ L: 216,
2097
2088
  S: this,
2098
2089
  C: (f, a) => f(...a)
2099
2090
  });
@@ -2107,7 +2098,7 @@ var InvitationsHandler = class {
2107
2098
  ...protocol.toJSON()
2108
2099
  }, {
2109
2100
  F: __dxlog_file7,
2110
- L: 280,
2101
+ L: 224,
2111
2102
  S: this,
2112
2103
  C: (f, a) => f(...a)
2113
2104
  });
@@ -2122,7 +2113,7 @@ var InvitationsHandler = class {
2122
2113
  currentState
2123
2114
  }, {
2124
2115
  F: __dxlog_file7,
2125
- L: 290,
2116
+ L: 234,
2126
2117
  S: this,
2127
2118
  C: (f, a) => f(...a)
2128
2119
  });
@@ -2137,7 +2128,7 @@ var InvitationsHandler = class {
2137
2128
  id: traceId
2138
2129
  }), {
2139
2130
  F: __dxlog_file7,
2140
- L: 299,
2131
+ L: 243,
2141
2132
  S: this,
2142
2133
  C: (f, a) => f(...a)
2143
2134
  });
@@ -2149,7 +2140,7 @@ var InvitationsHandler = class {
2149
2140
  ...protocol.toJSON()
2150
2141
  }, {
2151
2142
  F: __dxlog_file7,
2152
- L: 307,
2143
+ L: 251,
2153
2144
  S: this,
2154
2145
  C: (f, a) => f(...a)
2155
2146
  });
@@ -2160,7 +2151,7 @@ var InvitationsHandler = class {
2160
2151
  ...protocol.toJSON()
2161
2152
  }, {
2162
2153
  F: __dxlog_file7,
2163
- L: 311,
2154
+ L: 255,
2164
2155
  S: this,
2165
2156
  C: (f, a) => f(...a)
2166
2157
  });
@@ -2170,62 +2161,28 @@ var InvitationsHandler = class {
2170
2161
  response: introductionResponse
2171
2162
  }, {
2172
2163
  F: __dxlog_file7,
2173
- L: 315,
2164
+ L: 259,
2174
2165
  S: this,
2175
2166
  C: (f, a) => f(...a)
2176
2167
  });
2177
2168
  invitation.authMethod = introductionResponse.authMethod;
2178
2169
  if (isAuthenticationRequired(invitation)) {
2179
- for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2180
- (0, import_log4.log)("guest waiting for authentication code...", void 0, {
2181
- F: __dxlog_file7,
2182
- L: 321,
2183
- S: this,
2184
- C: (f, a) => f(...a)
2185
- });
2186
- setState({
2187
- state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
2188
- });
2189
- const authCode = await authenticated.wait({
2190
- timeout
2191
- });
2192
- (0, import_log4.log)("sending authentication request", void 0, {
2193
- F: __dxlog_file7,
2194
- L: 325,
2195
- S: this,
2196
- C: (f, a) => f(...a)
2197
- });
2198
- setState({
2199
- state: import_services3.Invitation.State.AUTHENTICATING
2200
- });
2201
- const response = await extension.rpc.InvitationHostService.authenticate({
2202
- authCode
2203
- });
2204
- if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
2170
+ switch (invitation.authMethod) {
2171
+ case import_services3.Invitation.AuthMethod.SHARED_SECRET:
2172
+ await this._handleGuestOtpAuth(extension, setState, authenticated, {
2173
+ timeout
2174
+ });
2175
+ break;
2176
+ case import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY:
2177
+ await this._handleGuestKpkAuth(extension, setState, invitation, introductionResponse);
2205
2178
  break;
2206
- }
2207
- if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
2208
- if (attempt === MAX_OTP_ATTEMPTS) {
2209
- throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
2210
- } else {
2211
- (0, import_log4.log)("retrying invalid code", {
2212
- attempt
2213
- }, {
2214
- F: __dxlog_file7,
2215
- L: 336,
2216
- S: this,
2217
- C: (f, a) => f(...a)
2218
- });
2219
- authenticated.reset();
2220
- }
2221
- }
2222
2179
  }
2223
2180
  }
2224
2181
  (0, import_log4.log)("request admission", {
2225
2182
  ...protocol.toJSON()
2226
2183
  }, {
2227
2184
  F: __dxlog_file7,
2228
- L: 344,
2185
+ L: 275,
2229
2186
  S: this,
2230
2187
  C: (f, a) => f(...a)
2231
2188
  });
@@ -2237,7 +2194,7 @@ var InvitationsHandler = class {
2237
2194
  ...protocol.toJSON()
2238
2195
  }, {
2239
2196
  F: __dxlog_file7,
2240
- L: 355,
2197
+ L: 286,
2241
2198
  S: this,
2242
2199
  C: (f, a) => f(...a)
2243
2200
  });
@@ -2250,7 +2207,7 @@ var InvitationsHandler = class {
2250
2207
  id: traceId
2251
2208
  }), {
2252
2209
  F: __dxlog_file7,
2253
- L: 357,
2210
+ L: 288,
2254
2211
  S: this,
2255
2212
  C: (f, a) => f(...a)
2256
2213
  });
@@ -2260,7 +2217,7 @@ var InvitationsHandler = class {
2260
2217
  ...protocol.toJSON()
2261
2218
  }, {
2262
2219
  F: __dxlog_file7,
2263
- L: 360,
2220
+ L: 291,
2264
2221
  S: this,
2265
2222
  C: (f, a) => f(...a)
2266
2223
  });
@@ -2270,7 +2227,7 @@ var InvitationsHandler = class {
2270
2227
  } else {
2271
2228
  (0, import_log4.log)("auth failed", err, {
2272
2229
  F: __dxlog_file7,
2273
- L: 363,
2230
+ L: 294,
2274
2231
  S: this,
2275
2232
  C: (f, a) => f(...a)
2276
2233
  });
@@ -2281,7 +2238,7 @@ var InvitationsHandler = class {
2281
2238
  error: err
2282
2239
  }), {
2283
2240
  F: __dxlog_file7,
2284
- L: 366,
2241
+ L: 297,
2285
2242
  S: this,
2286
2243
  C: (f, a) => f(...a)
2287
2244
  });
@@ -2299,7 +2256,7 @@ var InvitationsHandler = class {
2299
2256
  ...protocol.toJSON()
2300
2257
  }, {
2301
2258
  F: __dxlog_file7,
2302
- L: 377,
2259
+ L: 308,
2303
2260
  S: this,
2304
2261
  C: (f, a) => f(...a)
2305
2262
  });
@@ -2309,7 +2266,7 @@ var InvitationsHandler = class {
2309
2266
  } else {
2310
2267
  (0, import_log4.log)("auth failed", err, {
2311
2268
  F: __dxlog_file7,
2312
- L: 380,
2269
+ L: 311,
2313
2270
  S: this,
2314
2271
  C: (f, a) => f(...a)
2315
2272
  });
@@ -2326,7 +2283,7 @@ var InvitationsHandler = class {
2326
2283
  } else {
2327
2284
  (0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
2328
2285
  F: __dxlog_file7,
2329
- L: 394,
2286
+ L: 325,
2330
2287
  S: this,
2331
2288
  A: [
2332
2289
  "invitation.swarmKey",
@@ -2364,198 +2321,110 @@ var InvitationsHandler = class {
2364
2321
  });
2365
2322
  return observable;
2366
2323
  }
2324
+ async _handleGuestOtpAuth(extension, setState, authenticated, options) {
2325
+ for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2326
+ (0, import_log4.log)("guest waiting for authentication code...", void 0, {
2327
+ F: __dxlog_file7,
2328
+ L: 365,
2329
+ S: this,
2330
+ C: (f, a) => f(...a)
2331
+ });
2332
+ setState({
2333
+ state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
2334
+ });
2335
+ const authCode = await authenticated.wait(options);
2336
+ (0, import_log4.log)("sending authentication request", void 0, {
2337
+ F: __dxlog_file7,
2338
+ L: 369,
2339
+ S: this,
2340
+ C: (f, a) => f(...a)
2341
+ });
2342
+ setState({
2343
+ state: import_services3.Invitation.State.AUTHENTICATING
2344
+ });
2345
+ const response = await extension.rpc.InvitationHostService.authenticate({
2346
+ authCode
2347
+ });
2348
+ if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
2349
+ break;
2350
+ }
2351
+ if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
2352
+ if (attempt === MAX_OTP_ATTEMPTS) {
2353
+ throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
2354
+ } else {
2355
+ (0, import_log4.log)("retrying invalid code", {
2356
+ attempt
2357
+ }, {
2358
+ F: __dxlog_file7,
2359
+ L: 380,
2360
+ S: this,
2361
+ C: (f, a) => f(...a)
2362
+ });
2363
+ authenticated.reset();
2364
+ }
2365
+ }
2366
+ }
2367
+ }
2368
+ async _handleGuestKpkAuth(extension, setState, invitation, introductionResponse) {
2369
+ if (invitation.guestKeypair?.privateKey == null) {
2370
+ throw new Error("keypair missing in the invitation");
2371
+ }
2372
+ if (introductionResponse.challenge == null) {
2373
+ throw new Error("challenge missing in the introduction");
2374
+ }
2375
+ (0, import_log4.log)("sending authentication request", void 0, {
2376
+ F: __dxlog_file7,
2377
+ L: 399,
2378
+ S: this,
2379
+ C: (f, a) => f(...a)
2380
+ });
2381
+ setState({
2382
+ state: import_services3.Invitation.State.AUTHENTICATING
2383
+ });
2384
+ const signature = (0, import_crypto.sign)(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
2385
+ const response = await extension.rpc.InvitationHostService.authenticate({
2386
+ signedChallenge: signature
2387
+ });
2388
+ if (response.status !== import_invitations.AuthenticationResponse.Status.OK) {
2389
+ throw new Error(`Authentication failed with code: ${response.status}`);
2390
+ }
2391
+ }
2367
2392
  };
2368
- var invitationExpired = (invitation) => {
2369
- return invitation.created && invitation.lifetime && invitation.lifetime !== 0 && invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now();
2393
+ var createAdmissionKeypair = () => {
2394
+ const keypair = (0, import_crypto.createKeyPair)();
2395
+ return {
2396
+ publicKey: import_keys5.PublicKey.from(keypair.publicKey),
2397
+ privateKey: keypair.secretKey
2398
+ };
2370
2399
  };
2371
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
2372
2400
  var InvitationsServiceImpl = class {
2373
- constructor(_invitationsHandler, _getHandler, _metadataStore) {
2374
- this._invitationsHandler = _invitationsHandler;
2375
- this._getHandler = _getHandler;
2376
- this._metadataStore = _metadataStore;
2377
- this._createInvitations = /* @__PURE__ */ new Map();
2378
- this._acceptInvitations = /* @__PURE__ */ new Map();
2379
- this._invitationCreated = new import_async9.Event();
2380
- this._invitationAccepted = new import_async9.Event();
2381
- this._removedCreated = new import_async9.Event();
2382
- this._removedAccepted = new import_async9.Event();
2383
- this._saved = new import_async9.Event();
2384
- this._persistentInvitationsLoadedEvent = new import_async9.Event();
2385
- this._persistentInvitationsLoaded = false;
2401
+ constructor(_invitationsManager) {
2402
+ this._invitationsManager = _invitationsManager;
2386
2403
  }
2387
2404
  // TODO(burdon): Guest/host label.
2388
2405
  getLoggingContext() {
2389
2406
  return {};
2390
2407
  }
2391
2408
  createInvitation(options) {
2392
- let invitation;
2393
- const savePersistentInvitationCtx = new import_context6.Context();
2394
- const existingInvitation = this._createInvitations.get(options.invitationId);
2395
- if (existingInvitation) {
2396
- invitation = existingInvitation;
2397
- } else {
2398
- const handler = this._getHandler(options);
2399
- invitation = this._invitationsHandler.createInvitation(handler, options);
2400
- this._createInvitations.set(invitation.get().invitationId, invitation);
2401
- this._invitationCreated.emit(invitation.get());
2402
- }
2403
2409
  return new import_codec_protobuf8.Stream(({ next, close }) => {
2404
- if (invitation.get().persistent) {
2405
- (0, import_async9.scheduleTask)(savePersistentInvitationCtx, async () => {
2406
- try {
2407
- await this._metadataStore.addInvitation(invitation.get());
2408
- this._saved.emit(invitation.get());
2409
- } catch (err) {
2410
- close(err);
2411
- }
2412
- });
2413
- }
2414
- invitation.subscribe((invitation2) => {
2415
- next(invitation2);
2416
- }, async (err) => {
2417
- await savePersistentInvitationCtx.dispose();
2418
- close(err);
2419
- }, async () => {
2420
- close();
2421
- if (invitation.get().persistent) {
2422
- await savePersistentInvitationCtx.dispose();
2423
- await this._metadataStore.removeInvitation(invitation.get().invitationId);
2424
- }
2425
- this._createInvitations.delete(invitation.get().invitationId);
2426
- if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
2427
- this._removedCreated.emit(invitation.get());
2428
- }
2429
- });
2410
+ void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
2430
2411
  });
2431
2412
  }
2432
- async loadPersistentInvitations() {
2433
- const persistentInvitations = this._metadataStore.getInvitations();
2434
- const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
2435
- const cInvitations = freshInvitations.map((persistentInvitation) => {
2436
- (0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
2437
- F: __dxlog_file8,
2438
- L: 109,
2439
- S: this,
2440
- A: [
2441
- "!this._createInvitations.get(persistentInvitation.invitationId)",
2442
- "'invitation already exists'"
2443
- ]
2444
- });
2445
- const handler = this._getHandler(persistentInvitation);
2446
- const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
2447
- this._createInvitations.set(invitation.get().invitationId, invitation);
2448
- this._invitationCreated.emit(invitation.get());
2449
- return persistentInvitation;
2450
- });
2451
- this._persistentInvitationsLoadedEvent.emit();
2452
- this._persistentInvitationsLoaded = true;
2453
- return {
2454
- invitations: cInvitations
2455
- };
2456
- }
2457
- acceptInvitation({ invitation: options, deviceProfile }) {
2458
- let invitation;
2459
- if (deviceProfile) {
2460
- (0, import_invariant7.invariant)(options.kind === import_services5.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2461
- F: __dxlog_file8,
2462
- L: 127,
2463
- S: this,
2464
- A: [
2465
- "options.kind === Invitation.Kind.DEVICE",
2466
- "'deviceProfile provided for non-device invitation'"
2467
- ]
2468
- });
2469
- }
2470
- const existingInvitation = this._acceptInvitations.get(options.invitationId);
2471
- if (existingInvitation) {
2472
- invitation = existingInvitation;
2473
- } else {
2474
- const handler = this._getHandler(options);
2475
- invitation = this._invitationsHandler.acceptInvitation(handler, options, deviceProfile);
2476
- this._acceptInvitations.set(invitation.get().invitationId, invitation);
2477
- this._invitationAccepted.emit(invitation.get());
2478
- }
2413
+ acceptInvitation(request) {
2414
+ const invitation = this._invitationsManager.acceptInvitation(request);
2479
2415
  return new import_codec_protobuf8.Stream(({ next, close }) => {
2480
- invitation.subscribe((invitation2) => {
2481
- next(invitation2);
2482
- }, (err) => {
2483
- close(err);
2484
- }, () => {
2485
- close();
2486
- this._acceptInvitations.delete(invitation.get().invitationId);
2487
- if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
2488
- this._removedAccepted.emit(invitation.get());
2489
- }
2490
- });
2416
+ invitation.subscribe(next, close, close);
2491
2417
  });
2492
2418
  }
2493
- async authenticate({ invitationId, authCode }) {
2494
- (0, import_log6.log)("authenticating...", void 0, {
2495
- F: __dxlog_file8,
2496
- L: 160,
2497
- S: this,
2498
- C: (f, a) => f(...a)
2499
- });
2500
- (0, import_invariant7.invariant)(invitationId, void 0, {
2501
- F: __dxlog_file8,
2502
- L: 161,
2503
- S: this,
2504
- A: [
2505
- "invitationId",
2506
- ""
2507
- ]
2508
- });
2509
- const observable = this._acceptInvitations.get(invitationId);
2510
- if (!observable) {
2511
- import_log6.log.warn("invalid invitation", {
2512
- invitationId
2513
- }, {
2514
- F: __dxlog_file8,
2515
- L: 164,
2516
- S: this,
2517
- C: (f, a) => f(...a)
2518
- });
2519
- } else {
2520
- await observable.authenticate(authCode);
2521
- }
2419
+ async authenticate(request) {
2420
+ return this._invitationsManager.authenticate(request);
2522
2421
  }
2523
- async cancelInvitation({ invitationId }) {
2524
- (0, import_log6.log)("cancelInvitation...", {
2525
- invitationId
2526
- }, {
2527
- F: __dxlog_file8,
2528
- L: 171,
2529
- S: this,
2530
- C: (f, a) => f(...a)
2531
- });
2532
- (0, import_invariant7.invariant)(invitationId, void 0, {
2533
- F: __dxlog_file8,
2534
- L: 172,
2535
- S: this,
2536
- A: [
2537
- "invitationId",
2538
- ""
2539
- ]
2540
- });
2541
- const created = this._createInvitations.get(invitationId);
2542
- const accepted = this._acceptInvitations.get(invitationId);
2543
- if (created) {
2544
- await created.cancel();
2545
- this._createInvitations.delete(invitationId);
2546
- this._removedCreated.emit(created.get());
2547
- if (created.get().persistent) {
2548
- await this._metadataStore.removeInvitation(created.get().invitationId);
2549
- }
2550
- } else if (accepted) {
2551
- await accepted.cancel();
2552
- this._acceptInvitations.delete(invitationId);
2553
- this._removedAccepted.emit(accepted.get());
2554
- }
2422
+ async cancelInvitation(request) {
2423
+ return this._invitationsManager.cancelInvitation(request);
2555
2424
  }
2556
2425
  queryInvitations() {
2557
2426
  return new import_codec_protobuf8.Stream(({ next, ctx }) => {
2558
- this._invitationCreated.on(ctx, (invitation) => {
2427
+ this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
2559
2428
  next({
2560
2429
  action: import_services5.QueryInvitationsResponse.Action.ADDED,
2561
2430
  type: import_services5.QueryInvitationsResponse.Type.CREATED,
@@ -2564,7 +2433,7 @@ var InvitationsServiceImpl = class {
2564
2433
  ]
2565
2434
  });
2566
2435
  });
2567
- this._invitationAccepted.on(ctx, (invitation) => {
2436
+ this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
2568
2437
  next({
2569
2438
  action: import_services5.QueryInvitationsResponse.Action.ADDED,
2570
2439
  type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
@@ -2573,7 +2442,7 @@ var InvitationsServiceImpl = class {
2573
2442
  ]
2574
2443
  });
2575
2444
  });
2576
- this._removedCreated.on(ctx, (invitation) => {
2445
+ this._invitationsManager.removedCreated.on(ctx, (invitation) => {
2577
2446
  next({
2578
2447
  action: import_services5.QueryInvitationsResponse.Action.REMOVED,
2579
2448
  type: import_services5.QueryInvitationsResponse.Type.CREATED,
@@ -2582,7 +2451,7 @@ var InvitationsServiceImpl = class {
2582
2451
  ]
2583
2452
  });
2584
2453
  });
2585
- this._removedAccepted.on(ctx, (invitation) => {
2454
+ this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
2586
2455
  next({
2587
2456
  action: import_services5.QueryInvitationsResponse.Action.REMOVED,
2588
2457
  type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
@@ -2591,7 +2460,7 @@ var InvitationsServiceImpl = class {
2591
2460
  ]
2592
2461
  });
2593
2462
  });
2594
- this._saved.on(ctx, (invitation) => {
2463
+ this._invitationsManager.saved.on(ctx, (invitation) => {
2595
2464
  next({
2596
2465
  action: import_services5.QueryInvitationsResponse.Action.SAVED,
2597
2466
  type: import_services5.QueryInvitationsResponse.Type.CREATED,
@@ -2603,32 +2472,25 @@ var InvitationsServiceImpl = class {
2603
2472
  next({
2604
2473
  action: import_services5.QueryInvitationsResponse.Action.ADDED,
2605
2474
  type: import_services5.QueryInvitationsResponse.Type.CREATED,
2606
- invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get()),
2475
+ invitations: this._invitationsManager.getCreatedInvitations(),
2607
2476
  existing: true
2608
2477
  });
2609
2478
  next({
2610
2479
  action: import_services5.QueryInvitationsResponse.Action.ADDED,
2611
2480
  type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
2612
- invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get()),
2481
+ invitations: this._invitationsManager.getAcceptedInvitations(),
2613
2482
  existing: true
2614
2483
  });
2615
- if (this._persistentInvitationsLoaded) {
2484
+ this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
2616
2485
  next({
2617
2486
  action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
2618
2487
  type: import_services5.QueryInvitationsResponse.Type.CREATED
2619
2488
  });
2620
- } else {
2621
- this._persistentInvitationsLoadedEvent.on(ctx, () => {
2622
- next({
2623
- action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
2624
- type: import_services5.QueryInvitationsResponse.Type.CREATED
2625
- });
2626
- });
2627
- }
2489
+ });
2628
2490
  });
2629
2491
  }
2630
2492
  };
2631
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2493
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2632
2494
  var SpaceInvitationProtocol = class {
2633
2495
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
2634
2496
  this._spaceManager = _spaceManager;
@@ -2648,10 +2510,10 @@ var SpaceInvitationProtocol = class {
2648
2510
  spaceKey: this._spaceKey
2649
2511
  };
2650
2512
  }
2651
- async admit(request, guestProfile) {
2652
- (0, import_invariant8.invariant)(this._spaceKey, void 0, {
2653
- F: __dxlog_file9,
2654
- L: 47,
2513
+ async admit(invitation, request, guestProfile) {
2514
+ (0, import_invariant7.invariant)(this._spaceKey, void 0, {
2515
+ F: __dxlog_file8,
2516
+ L: 55,
2655
2517
  S: this,
2656
2518
  A: [
2657
2519
  "this._spaceKey",
@@ -2659,18 +2521,18 @@ var SpaceInvitationProtocol = class {
2659
2521
  ]
2660
2522
  });
2661
2523
  const space = await this._spaceManager.spaces.get(this._spaceKey);
2662
- (0, import_invariant8.invariant)(space, void 0, {
2663
- F: __dxlog_file9,
2664
- L: 49,
2524
+ (0, import_invariant7.invariant)(space, void 0, {
2525
+ F: __dxlog_file8,
2526
+ L: 57,
2665
2527
  S: this,
2666
2528
  A: [
2667
2529
  "space",
2668
2530
  ""
2669
2531
  ]
2670
2532
  });
2671
- (0, import_invariant8.invariant)(request.space, void 0, {
2672
- F: __dxlog_file9,
2673
- L: 51,
2533
+ (0, import_invariant7.invariant)(request.space, void 0, {
2534
+ F: __dxlog_file8,
2535
+ L: 59,
2674
2536
  S: this,
2675
2537
  A: [
2676
2538
  "request.space",
@@ -2678,19 +2540,19 @@ var SpaceInvitationProtocol = class {
2678
2540
  ]
2679
2541
  });
2680
2542
  const { identityKey, deviceKey } = request.space;
2681
- (0, import_log7.log)("writing guest credentials", {
2543
+ (0, import_log6.log)("writing guest credentials", {
2682
2544
  host: this._signingContext.deviceKey,
2683
2545
  guest: deviceKey
2684
2546
  }, {
2685
- F: __dxlog_file9,
2686
- L: 54,
2547
+ F: __dxlog_file8,
2548
+ L: 62,
2687
2549
  S: this,
2688
2550
  C: (f, a) => f(...a)
2689
2551
  });
2690
- const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
2691
- (0, import_invariant8.invariant)(credentials[0].credential, void 0, {
2692
- F: __dxlog_file9,
2693
- L: 65,
2552
+ const credentials = await (0, import_credentials7.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile, invitation.delegationCredentialId);
2553
+ (0, import_invariant7.invariant)(credentials[0].credential, void 0, {
2554
+ F: __dxlog_file8,
2555
+ L: 74,
2694
2556
  S: this,
2695
2557
  A: [
2696
2558
  "credentials[0].credential",
@@ -2698,9 +2560,9 @@ var SpaceInvitationProtocol = class {
2698
2560
  ]
2699
2561
  });
2700
2562
  const spaceMemberCredential = credentials[0].credential.credential;
2701
- (0, import_invariant8.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2702
- F: __dxlog_file9,
2703
- L: 67,
2563
+ (0, import_invariant7.invariant)((0, import_credentials7.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2564
+ F: __dxlog_file8,
2565
+ L: 76,
2704
2566
  S: this,
2705
2567
  A: [
2706
2568
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2715,6 +2577,69 @@ var SpaceInvitationProtocol = class {
2715
2577
  }
2716
2578
  };
2717
2579
  }
2580
+ async delegate(invitation) {
2581
+ (0, import_invariant7.invariant)(this._spaceKey, void 0, {
2582
+ F: __dxlog_file8,
2583
+ L: 89,
2584
+ S: this,
2585
+ A: [
2586
+ "this._spaceKey",
2587
+ ""
2588
+ ]
2589
+ });
2590
+ const space = await this._spaceManager.spaces.get(this._spaceKey);
2591
+ (0, import_invariant7.invariant)(space, void 0, {
2592
+ F: __dxlog_file8,
2593
+ L: 91,
2594
+ S: this,
2595
+ A: [
2596
+ "space",
2597
+ ""
2598
+ ]
2599
+ });
2600
+ if (invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
2601
+ (0, import_invariant7.invariant)(invitation.guestKeypair?.publicKey, void 0, {
2602
+ F: __dxlog_file8,
2603
+ L: 93,
2604
+ S: this,
2605
+ A: [
2606
+ "invitation.guestKeypair?.publicKey",
2607
+ ""
2608
+ ]
2609
+ });
2610
+ }
2611
+ (0, import_log6.log)("writing delegate space invitation", {
2612
+ host: this._signingContext.deviceKey,
2613
+ id: invitation.invitationId
2614
+ }, {
2615
+ F: __dxlog_file8,
2616
+ L: 96,
2617
+ S: this,
2618
+ C: (f, a) => f(...a)
2619
+ });
2620
+ const credential = await (0, import_credentials7.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
2621
+ invitationId: invitation.invitationId,
2622
+ authMethod: invitation.authMethod,
2623
+ swarmKey: invitation.swarmKey,
2624
+ role: import_credentials8.SpaceMember.Role.ADMIN,
2625
+ expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
2626
+ multiUse: invitation.multiUse ?? false,
2627
+ guestKey: invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
2628
+ });
2629
+ (0, import_invariant7.invariant)(credential.credential, void 0, {
2630
+ F: __dxlog_file8,
2631
+ L: 116,
2632
+ S: this,
2633
+ A: [
2634
+ "credential.credential",
2635
+ ""
2636
+ ]
2637
+ });
2638
+ await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, [
2639
+ credential
2640
+ ]);
2641
+ return credential.credential.credential.id;
2642
+ }
2718
2643
  checkInvitation(invitation) {
2719
2644
  if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
2720
2645
  return new import_protocols6.AlreadyJoinedError("Already joined space.");
@@ -2738,9 +2663,9 @@ var SpaceInvitationProtocol = class {
2738
2663
  };
2739
2664
  }
2740
2665
  async accept(response) {
2741
- (0, import_invariant8.invariant)(response.space, void 0, {
2742
- F: __dxlog_file9,
2743
- L: 107,
2666
+ (0, import_invariant7.invariant)(response.space, void 0, {
2667
+ F: __dxlog_file8,
2668
+ L: 149,
2744
2669
  S: this,
2745
2670
  A: [
2746
2671
  "response.space",
@@ -2748,19 +2673,19 @@ var SpaceInvitationProtocol = class {
2748
2673
  ]
2749
2674
  });
2750
2675
  const { credential, controlTimeframe, dataTimeframe } = response.space;
2751
- const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
2752
- (0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2753
- F: __dxlog_file9,
2754
- L: 110,
2676
+ const assertion = (0, import_credentials7.getCredentialAssertion)(credential);
2677
+ (0, import_invariant7.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2678
+ F: __dxlog_file8,
2679
+ L: 152,
2755
2680
  S: this,
2756
2681
  A: [
2757
2682
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
2758
2683
  "'Invalid credential'"
2759
2684
  ]
2760
2685
  });
2761
- (0, import_invariant8.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
2762
- F: __dxlog_file9,
2763
- L: 111,
2686
+ (0, import_invariant7.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
2687
+ F: __dxlog_file8,
2688
+ L: 153,
2764
2689
  S: this,
2765
2690
  A: [
2766
2691
  "credential.subject.id.equals(this._signingContext.identityKey)",
@@ -2782,6 +2707,284 @@ var SpaceInvitationProtocol = class {
2782
2707
  };
2783
2708
  }
2784
2709
  };
2710
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
2711
+ var InvitationsManager = class {
2712
+ constructor(_invitationsHandler, _getHandler, _metadataStore) {
2713
+ this._invitationsHandler = _invitationsHandler;
2714
+ this._getHandler = _getHandler;
2715
+ this._metadataStore = _metadataStore;
2716
+ this._createInvitations = /* @__PURE__ */ new Map();
2717
+ this._acceptInvitations = /* @__PURE__ */ new Map();
2718
+ this.invitationCreated = new import_async9.Event();
2719
+ this.invitationAccepted = new import_async9.Event();
2720
+ this.removedCreated = new import_async9.Event();
2721
+ this.removedAccepted = new import_async9.Event();
2722
+ this.saved = new import_async9.Event();
2723
+ this._persistentInvitationsLoadedEvent = new import_async9.Event();
2724
+ this._persistentInvitationsLoaded = false;
2725
+ }
2726
+ async createInvitation(options) {
2727
+ if (options.invitationId) {
2728
+ const existingInvitation = this._createInvitations.get(options.invitationId);
2729
+ if (existingInvitation) {
2730
+ return existingInvitation;
2731
+ }
2732
+ }
2733
+ const handler = this._getHandler(options);
2734
+ const invitation = this._createInvitation(handler, options);
2735
+ const { ctx, stream, observableInvitation } = this._createObservableInvitation(handler, invitation);
2736
+ this._createInvitations.set(invitation.invitationId, observableInvitation);
2737
+ this.invitationCreated.emit(invitation);
2738
+ this._onInvitationComplete(observableInvitation, async () => {
2739
+ this._createInvitations.delete(observableInvitation.get().invitationId);
2740
+ this.removedCreated.emit(observableInvitation.get());
2741
+ if (observableInvitation.get().persistent) {
2742
+ await this._safeDeleteInvitation(observableInvitation.get());
2743
+ }
2744
+ });
2745
+ try {
2746
+ await this._persistIfRequired(handler, stream, invitation);
2747
+ } catch (err) {
2748
+ import_log7.log.catch(err, void 0, {
2749
+ F: __dxlog_file9,
2750
+ L: 76,
2751
+ S: this,
2752
+ C: (f, a) => f(...a)
2753
+ });
2754
+ await observableInvitation.cancel();
2755
+ return observableInvitation;
2756
+ }
2757
+ this._invitationsHandler.handleInvitationFlow(ctx, stream, handler, observableInvitation.get());
2758
+ return observableInvitation;
2759
+ }
2760
+ async loadPersistentInvitations() {
2761
+ if (this._persistentInvitationsLoaded) {
2762
+ const invitations = this.getCreatedInvitations().filter((i) => i.persistent);
2763
+ return {
2764
+ invitations
2765
+ };
2766
+ }
2767
+ try {
2768
+ const persistentInvitations = this._metadataStore.getInvitations();
2769
+ const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
2770
+ const loadTasks = freshInvitations.map((persistentInvitation) => {
2771
+ (0, import_invariant8.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
2772
+ F: __dxlog_file9,
2773
+ L: 97,
2774
+ S: this,
2775
+ A: [
2776
+ "!this._createInvitations.get(persistentInvitation.invitationId)",
2777
+ "'invitation already exists'"
2778
+ ]
2779
+ });
2780
+ return this.createInvitation({
2781
+ ...persistentInvitation,
2782
+ persistent: false
2783
+ });
2784
+ });
2785
+ const cInvitations = await Promise.all(loadTasks);
2786
+ return {
2787
+ invitations: cInvitations.map((invitation) => invitation.get())
2788
+ };
2789
+ } catch (err) {
2790
+ import_log7.log.catch(err, void 0, {
2791
+ F: __dxlog_file9,
2792
+ L: 104,
2793
+ S: this,
2794
+ C: (f, a) => f(...a)
2795
+ });
2796
+ return {
2797
+ invitations: []
2798
+ };
2799
+ } finally {
2800
+ this._persistentInvitationsLoadedEvent.emit();
2801
+ this._persistentInvitationsLoaded = true;
2802
+ }
2803
+ }
2804
+ acceptInvitation(request) {
2805
+ const options = request.invitation;
2806
+ const existingInvitation = this._acceptInvitations.get(options.invitationId);
2807
+ if (existingInvitation) {
2808
+ return existingInvitation;
2809
+ }
2810
+ const handler = this._getHandler(options);
2811
+ const invitation = this._invitationsHandler.acceptInvitation(handler, options, request.deviceProfile);
2812
+ this._acceptInvitations.set(invitation.get().invitationId, invitation);
2813
+ this.invitationAccepted.emit(invitation.get());
2814
+ this._onInvitationComplete(invitation, () => {
2815
+ this._acceptInvitations.delete(invitation.get().invitationId);
2816
+ this.removedAccepted.emit(invitation.get());
2817
+ });
2818
+ return invitation;
2819
+ }
2820
+ async authenticate({ invitationId, authCode }) {
2821
+ (0, import_log7.log)("authenticating...", void 0, {
2822
+ F: __dxlog_file9,
2823
+ L: 133,
2824
+ S: this,
2825
+ C: (f, a) => f(...a)
2826
+ });
2827
+ (0, import_invariant8.invariant)(invitationId, void 0, {
2828
+ F: __dxlog_file9,
2829
+ L: 134,
2830
+ S: this,
2831
+ A: [
2832
+ "invitationId",
2833
+ ""
2834
+ ]
2835
+ });
2836
+ const observable = this._acceptInvitations.get(invitationId);
2837
+ if (!observable) {
2838
+ import_log7.log.warn("invalid invitation", {
2839
+ invitationId
2840
+ }, {
2841
+ F: __dxlog_file9,
2842
+ L: 137,
2843
+ S: this,
2844
+ C: (f, a) => f(...a)
2845
+ });
2846
+ } else {
2847
+ await observable.authenticate(authCode);
2848
+ }
2849
+ }
2850
+ async cancelInvitation({ invitationId }) {
2851
+ (0, import_log7.log)("cancelInvitation...", {
2852
+ invitationId
2853
+ }, {
2854
+ F: __dxlog_file9,
2855
+ L: 144,
2856
+ S: this,
2857
+ C: (f, a) => f(...a)
2858
+ });
2859
+ (0, import_invariant8.invariant)(invitationId, void 0, {
2860
+ F: __dxlog_file9,
2861
+ L: 145,
2862
+ S: this,
2863
+ A: [
2864
+ "invitationId",
2865
+ ""
2866
+ ]
2867
+ });
2868
+ const created = this._createInvitations.get(invitationId);
2869
+ if (created) {
2870
+ if (created.get().persistent) {
2871
+ await this._metadataStore.removeInvitation(invitationId);
2872
+ }
2873
+ await created.cancel();
2874
+ this._createInvitations.delete(invitationId);
2875
+ this.removedCreated.emit(created.get());
2876
+ return;
2877
+ }
2878
+ const accepted = this._acceptInvitations.get(invitationId);
2879
+ if (accepted) {
2880
+ await accepted.cancel();
2881
+ this._acceptInvitations.delete(invitationId);
2882
+ this.removedAccepted.emit(accepted.get());
2883
+ }
2884
+ }
2885
+ getCreatedInvitations() {
2886
+ return [
2887
+ ...this._createInvitations.values()
2888
+ ].map((i) => i.get());
2889
+ }
2890
+ getAcceptedInvitations() {
2891
+ return [
2892
+ ...this._acceptInvitations.values()
2893
+ ].map((i) => i.get());
2894
+ }
2895
+ onPersistentInvitationsLoaded(ctx, callback) {
2896
+ if (this._persistentInvitationsLoaded) {
2897
+ callback();
2898
+ } else {
2899
+ this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
2900
+ }
2901
+ }
2902
+ _createInvitation(protocol, options) {
2903
+ const { invitationId = import_keys7.PublicKey.random().toHex(), type = import_services7.Invitation.Type.INTERACTIVE, authMethod = import_services7.Invitation.AuthMethod.SHARED_SECRET, state = import_services7.Invitation.State.INIT, timeout = import_client_protocol3.INVITATION_TIMEOUT, swarmKey = import_keys7.PublicKey.random(), persistent = options?.authMethod !== import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
2904
+ const authCode = options?.authCode ?? (authMethod === import_services7.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol3.AUTHENTICATION_CODE_LENGTH) : void 0);
2905
+ return {
2906
+ invitationId,
2907
+ type,
2908
+ authMethod,
2909
+ state,
2910
+ swarmKey,
2911
+ authCode,
2912
+ timeout,
2913
+ persistent: persistent && type !== import_services7.Invitation.Type.DELEGATED,
2914
+ guestKeypair: guestKeypair ?? (authMethod === import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
2915
+ created,
2916
+ lifetime,
2917
+ multiUse,
2918
+ delegationCredentialId: options?.delegationCredentialId,
2919
+ ...protocol.getInvitationContext()
2920
+ };
2921
+ }
2922
+ _createObservableInvitation(handler, invitation) {
2923
+ const stream = new import_async9.PushStream();
2924
+ const ctx = new import_context6.Context({
2925
+ onError: (err) => {
2926
+ stream.error(err);
2927
+ void ctx.dispose();
2928
+ }
2929
+ });
2930
+ ctx.onDispose(() => {
2931
+ (0, import_log7.log)("complete", {
2932
+ ...handler.toJSON()
2933
+ }, {
2934
+ F: __dxlog_file9,
2935
+ L: 228,
2936
+ S: this,
2937
+ C: (f, a) => f(...a)
2938
+ });
2939
+ stream.complete();
2940
+ });
2941
+ const observableInvitation = new import_client_protocol3.CancellableInvitation({
2942
+ initialInvitation: invitation,
2943
+ subscriber: stream.observable,
2944
+ onCancel: async () => {
2945
+ stream.next({
2946
+ ...invitation,
2947
+ state: import_services7.Invitation.State.CANCELLED
2948
+ });
2949
+ await ctx.dispose();
2950
+ }
2951
+ });
2952
+ return {
2953
+ ctx,
2954
+ stream,
2955
+ observableInvitation
2956
+ };
2957
+ }
2958
+ async _persistIfRequired(handler, changeStream, invitation) {
2959
+ if (invitation.type === import_services7.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
2960
+ const delegationCredentialId = await handler.delegate(invitation);
2961
+ changeStream.next({
2962
+ ...invitation,
2963
+ delegationCredentialId
2964
+ });
2965
+ } else if (invitation.persistent) {
2966
+ await this._metadataStore.addInvitation(invitation);
2967
+ this.saved.emit(invitation);
2968
+ }
2969
+ }
2970
+ async _safeDeleteInvitation(invitation) {
2971
+ try {
2972
+ await this._metadataStore.removeInvitation(invitation.invitationId);
2973
+ } catch (err) {
2974
+ import_log7.log.catch(err, void 0, {
2975
+ F: __dxlog_file9,
2976
+ L: 260,
2977
+ S: this,
2978
+ C: (f, a) => f(...a)
2979
+ });
2980
+ }
2981
+ }
2982
+ _onInvitationComplete(invitation, callback) {
2983
+ invitation.subscribe(() => {
2984
+ }, () => {
2985
+ }, callback);
2986
+ }
2987
+ };
2785
2988
  function _ts_decorate3(decorators, target, key, desc) {
2786
2989
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2787
2990
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -2832,166 +3035,31 @@ var ClientRpcServer = class {
2832
3035
  }
2833
3036
  async open() {
2834
3037
  await this._rpcPeer.open();
2835
- }
2836
- async close() {
2837
- await this._rpcPeer.close();
2838
- }
2839
- _getServiceHandler(serviceName) {
2840
- if (!this._handlerCache.has(serviceName)) {
2841
- const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug2.raise)(new Error(`Service not available: ${serviceName}`));
2842
- const service = this._serviceRegistry.services[key];
2843
- if (!service) {
2844
- throw new Error(`Service not available: ${serviceName}`);
2845
- }
2846
- this._handlerCache.set(serviceName, descriptor.createServer(service));
2847
- }
2848
- return this._handlerCache.get(serviceName);
2849
- }
2850
- };
2851
- _ts_decorate3([
2852
- import_tracing3.trace.metricsCounter()
2853
- ], ClientRpcServer.prototype, "_callMetrics", void 0);
2854
- _ts_decorate3([
2855
- import_tracing3.trace.info()
2856
- ], ClientRpcServer.prototype, "_services", null);
2857
- ClientRpcServer = _ts_decorate3([
2858
- import_tracing3.trace.resource()
2859
- ], ClientRpcServer);
2860
- var getPlatform = () => {
2861
- if (process.browser) {
2862
- if (typeof window !== "undefined") {
2863
- const { userAgent } = window.navigator;
2864
- return {
2865
- type: import_services8.Platform.PLATFORM_TYPE.BROWSER,
2866
- userAgent,
2867
- uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
2868
- };
2869
- } else {
2870
- return {
2871
- type: import_services8.Platform.PLATFORM_TYPE.SHARED_WORKER,
2872
- uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
2873
- };
2874
- }
2875
- } else {
2876
- const { platform: platform2, version, arch } = process;
2877
- return {
2878
- type: import_services8.Platform.PLATFORM_TYPE.NODE,
2879
- platform: platform2,
2880
- arch,
2881
- runtime: version,
2882
- uptime: Math.floor(process.uptime()),
2883
- memory: process.memoryUsage()
2884
- };
2885
- }
2886
- };
2887
- var DXOS_VERSION = "0.4.10-main.fa5a270";
2888
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2889
- var DEFAULT_TIMEOUT = 1e3;
2890
- var createDiagnostics = async (clientServices, serviceContext, config) => {
2891
- const diagnostics = {
2892
- created: (/* @__PURE__ */ new Date()).toISOString(),
2893
- platform: getPlatform(),
2894
- client: {
2895
- version: DXOS_VERSION,
2896
- storage: {
2897
- version: import_protocols7.STORAGE_VERSION
2898
- }
2899
- },
2900
- trace: import_tracing4.TRACE_PROCESSOR.getDiagnostics()
2901
- };
2902
- {
2903
- (0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
2904
- F: __dxlog_file10,
2905
- L: 108,
2906
- S: void 0,
2907
- A: [
2908
- "clientServices.LoggingService",
2909
- "'SystemService is not available.'"
2910
- ]
2911
- });
2912
- diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
2913
- timeout: DEFAULT_TIMEOUT
2914
- }).catch(() => void 0);
2915
- }
2916
- if (typeof navigator !== "undefined" && navigator.storage) {
2917
- const map = /* @__PURE__ */ new Map();
2918
- const dir = await navigator.storage.getDirectory();
2919
- for await (const filename of dir?.keys()) {
2920
- const idx = filename.indexOf("-", filename.indexOf("-") + 1);
2921
- if (idx === -1) {
2922
- continue;
2923
- }
2924
- map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
2925
- }
2926
- diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
2927
- file,
2928
- count
2929
- }));
2930
- }
2931
- const identity = serviceContext.identityManager.identity;
2932
- if (identity) {
2933
- diagnostics.identity = {
2934
- identityKey: identity.identityKey,
2935
- spaceKey: identity.space.key,
2936
- profile: identity.profileDocument
2937
- };
2938
- const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
2939
- timeout: DEFAULT_TIMEOUT
2940
- }).catch(() => void 0) ?? {};
2941
- diagnostics.devices = devices;
2942
- if (serviceContext.dataSpaceManager) {
2943
- diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
2944
- }
2945
- const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2946
- timeout: DEFAULT_TIMEOUT
2947
- }).catch(() => void 0) ?? {};
2948
- diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
2949
- feedKey,
2950
- bytes,
2951
- length
2952
- }));
2953
- const status = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
2954
- timeout: DEFAULT_TIMEOUT
2955
- }).catch(() => void 0);
2956
- diagnostics.networkStatus = status;
2957
- diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
2958
- }
2959
- diagnostics.config = config.values;
2960
- return diagnostics;
2961
- };
2962
- var getSpaceStats = async (space) => {
2963
- const stats = {
2964
- key: space.key,
2965
- metrics: space.metrics,
2966
- epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
2967
- ...credential.subject.assertion,
2968
- id: credential.id
2969
- })),
2970
- members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
2971
- identity: {
2972
- identityKey: member.key,
2973
- profile: {
2974
- displayName: member.assertion.profile?.displayName
2975
- }
2976
- },
2977
- presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services7.SpaceMember.PresenceState.ONLINE : import_services7.SpaceMember.PresenceState.OFFLINE
2978
- })),
2979
- pipeline: {
2980
- // TODO(burdon): Pick properties from credentials if needed.
2981
- currentEpoch: space.automergeSpaceState.lastEpoch,
2982
- appliedEpoch: space.automergeSpaceState.lastEpoch,
2983
- controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
2984
- currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
2985
- targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
2986
- totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
3038
+ }
3039
+ async close() {
3040
+ await this._rpcPeer.close();
3041
+ }
3042
+ _getServiceHandler(serviceName) {
3043
+ if (!this._handlerCache.has(serviceName)) {
3044
+ const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug2.raise)(new Error(`Service not available: ${serviceName}`));
3045
+ const service = this._serviceRegistry.services[key];
3046
+ if (!service) {
3047
+ throw new Error(`Service not available: ${serviceName}`);
3048
+ }
3049
+ this._handlerCache.set(serviceName, descriptor.createServer(service));
2987
3050
  }
2988
- };
2989
- if (stats.metrics) {
2990
- const { open, ready } = stats.metrics;
2991
- stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
3051
+ return this._handlerCache.get(serviceName);
2992
3052
  }
2993
- return stats;
2994
3053
  };
3054
+ _ts_decorate3([
3055
+ import_tracing3.trace.metricsCounter()
3056
+ ], ClientRpcServer.prototype, "_callMetrics", void 0);
3057
+ _ts_decorate3([
3058
+ import_tracing3.trace.info()
3059
+ ], ClientRpcServer.prototype, "_services", null);
3060
+ ClientRpcServer = _ts_decorate3([
3061
+ import_tracing3.trace.resource()
3062
+ ], ClientRpcServer);
2995
3063
  var AutomergeSpaceState = class {
2996
3064
  constructor(_onNewRoot) {
2997
3065
  this._onNewRoot = _onNewRoot;
@@ -3026,7 +3094,7 @@ var AutomergeSpaceState = class {
3026
3094
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3027
3095
  }
3028
3096
  };
3029
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3097
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3030
3098
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3031
3099
  var DEFAULT_SUCCESS_DELAY = 1e3;
3032
3100
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -3036,8 +3104,8 @@ var NotarizationPlugin = class {
3036
3104
  this._ctx = new import_context8.Context();
3037
3105
  this._extensionOpened = new import_async12.Event();
3038
3106
  this._extensions = /* @__PURE__ */ new Set();
3039
- this._processedCredentials = new import_util5.ComplexSet(import_keys8.PublicKey.hash);
3040
- this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys8.PublicKey.hash);
3107
+ this._processedCredentials = new import_util5.ComplexSet(import_keys9.PublicKey.hash);
3108
+ this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
3041
3109
  }
3042
3110
  get hasWriter() {
3043
3111
  return !!this._writer;
@@ -3054,13 +3122,13 @@ var NotarizationPlugin = class {
3054
3122
  (0, import_log9.log)("notarize", {
3055
3123
  credentials
3056
3124
  }, {
3057
- F: __dxlog_file11,
3125
+ F: __dxlog_file10,
3058
3126
  L: 90,
3059
3127
  S: this,
3060
3128
  C: (f, a) => f(...a)
3061
3129
  });
3062
- (0, import_invariant11.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
3063
- F: __dxlog_file11,
3130
+ (0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
3131
+ F: __dxlog_file10,
3064
3132
  L: 91,
3065
3133
  S: this,
3066
3134
  A: [
@@ -3074,7 +3142,7 @@ var NotarizationPlugin = class {
3074
3142
  import_log9.log.warn("Notarization error", {
3075
3143
  err
3076
3144
  }, {
3077
- F: __dxlog_file11,
3145
+ F: __dxlog_file10,
3078
3146
  L: 99,
3079
3147
  S: this,
3080
3148
  C: (f, a) => f(...a)
@@ -3090,7 +3158,7 @@ var NotarizationPlugin = class {
3090
3158
  timeout,
3091
3159
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
3092
3160
  }, {
3093
- F: __dxlog_file11,
3161
+ F: __dxlog_file10,
3094
3162
  L: 111,
3095
3163
  S: this,
3096
3164
  C: (f, a) => f(...a)
@@ -3113,7 +3181,7 @@ var NotarizationPlugin = class {
3113
3181
  import_log9.log.info("Exhausted all peers to notarize with", {
3114
3182
  retryIn: retryTimeout
3115
3183
  }, {
3116
- F: __dxlog_file11,
3184
+ F: __dxlog_file10,
3117
3185
  L: 136,
3118
3186
  S: this,
3119
3187
  C: (f, a) => f(...a)
@@ -3127,7 +3195,7 @@ var NotarizationPlugin = class {
3127
3195
  peer: peer.localPeerId,
3128
3196
  credentialId: credentials.map((credential) => credential.id)
3129
3197
  }, {
3130
- F: __dxlog_file11,
3198
+ F: __dxlog_file10,
3131
3199
  L: 143,
3132
3200
  S: this,
3133
3201
  C: (f, a) => f(...a)
@@ -3136,7 +3204,7 @@ var NotarizationPlugin = class {
3136
3204
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
3137
3205
  });
3138
3206
  (0, import_log9.log)("success", void 0, {
3139
- F: __dxlog_file11,
3207
+ F: __dxlog_file10,
3140
3208
  L: 147,
3141
3209
  S: this,
3142
3210
  C: (f, a) => f(...a)
@@ -3145,7 +3213,7 @@ var NotarizationPlugin = class {
3145
3213
  } catch (err) {
3146
3214
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
3147
3215
  import_log9.log.info("error notarizing (recoverable)", err, {
3148
- F: __dxlog_file11,
3216
+ F: __dxlog_file10,
3149
3217
  L: 151,
3150
3218
  S: this,
3151
3219
  C: (f, a) => f(...a)
@@ -3163,7 +3231,7 @@ var NotarizationPlugin = class {
3163
3231
  errors.wait()
3164
3232
  ]);
3165
3233
  (0, import_log9.log)("done", void 0, {
3166
- F: __dxlog_file11,
3234
+ F: __dxlog_file10,
3167
3235
  L: 162,
3168
3236
  S: this,
3169
3237
  C: (f, a) => f(...a)
@@ -3184,8 +3252,8 @@ var NotarizationPlugin = class {
3184
3252
  this._processCredentialsTriggers.delete(credential.id);
3185
3253
  }
3186
3254
  setWriter(writer) {
3187
- (0, import_invariant11.invariant)(!this._writer, "Writer already set.", {
3188
- F: __dxlog_file11,
3255
+ (0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
3256
+ F: __dxlog_file10,
3189
3257
  L: 181,
3190
3258
  S: this,
3191
3259
  A: [
@@ -3209,8 +3277,8 @@ var NotarizationPlugin = class {
3209
3277
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
3210
3278
  }
3211
3279
  for (const credential of request.credentials ?? []) {
3212
- (0, import_invariant11.invariant)(credential.id, "Credential must have an id", {
3213
- F: __dxlog_file11,
3280
+ (0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
3281
+ F: __dxlog_file10,
3214
3282
  L: 200,
3215
3283
  S: this,
3216
3284
  A: [
@@ -3230,7 +3298,7 @@ var NotarizationPlugin = class {
3230
3298
  (0, import_log9.log)("extension opened", {
3231
3299
  peer: extension.localPeerId
3232
3300
  }, {
3233
- F: __dxlog_file11,
3301
+ F: __dxlog_file10,
3234
3302
  L: 211,
3235
3303
  S: this,
3236
3304
  C: (f, a) => f(...a)
@@ -3242,7 +3310,7 @@ var NotarizationPlugin = class {
3242
3310
  (0, import_log9.log)("extension closed", {
3243
3311
  peer: extension.localPeerId
3244
3312
  }, {
3245
- F: __dxlog_file11,
3313
+ F: __dxlog_file10,
3246
3314
  L: 216,
3247
3315
  S: this,
3248
3316
  C: (f, a) => f(...a)
@@ -3258,10 +3326,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
3258
3326
  constructor(_params) {
3259
3327
  super({
3260
3328
  requested: {
3261
- NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3329
+ NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3262
3330
  },
3263
3331
  exposed: {
3264
- NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3332
+ NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3265
3333
  }
3266
3334
  });
3267
3335
  this._params = _params;
@@ -3294,14 +3362,14 @@ function _ts_decorate4(decorators, target, key, desc) {
3294
3362
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3295
3363
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3296
3364
  }
3297
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3365
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3298
3366
  var DataSpace = class {
3299
3367
  constructor(params) {
3300
3368
  this._ctx = new import_context7.Context();
3301
3369
  this._notarizationPlugin = new NotarizationPlugin();
3302
3370
  this._cache = void 0;
3303
3371
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
3304
- this._state = import_services9.SpaceState.CLOSED;
3372
+ this._state = import_services8.SpaceState.CLOSED;
3305
3373
  this.error = void 0;
3306
3374
  this.stateUpdate = new import_async10.Event();
3307
3375
  this.metrics = {};
@@ -3316,17 +3384,17 @@ var DataSpace = class {
3316
3384
  this._callbacks = params.callbacks ?? {};
3317
3385
  this._automergeHost = params.automergeHost;
3318
3386
  this.authVerifier = new TrustedKeySetAuthVerifier({
3319
- trustedKeysProvider: () => new import_util4.ComplexSet(import_keys7.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
3387
+ trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
3320
3388
  update: this._inner.stateUpdate,
3321
- authTimeout: import_client_protocol3.AUTH_TIMEOUT
3389
+ authTimeout: import_client_protocol4.AUTH_TIMEOUT
3322
3390
  });
3323
3391
  this._cache = params.cache;
3324
3392
  this._state = params.initialState;
3325
3393
  (0, import_log8.log)("new state", {
3326
- state: import_services9.SpaceState[this._state]
3394
+ state: import_services8.SpaceState[this._state]
3327
3395
  }, {
3328
- F: __dxlog_file12,
3329
- L: 132,
3396
+ F: __dxlog_file11,
3397
+ L: 140,
3330
3398
  S: this,
3331
3399
  C: (f, a) => f(...a)
3332
3400
  });
@@ -3371,12 +3439,12 @@ var DataSpace = class {
3371
3439
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
3372
3440
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
3373
3441
  await this._inner.open(new import_context7.Context());
3374
- this._state = import_services9.SpaceState.CONTROL_ONLY;
3442
+ this._state = import_services8.SpaceState.CONTROL_ONLY;
3375
3443
  (0, import_log8.log)("new state", {
3376
- state: import_services9.SpaceState[this._state]
3444
+ state: import_services8.SpaceState[this._state]
3377
3445
  }, {
3378
- F: __dxlog_file12,
3379
- L: 190,
3446
+ F: __dxlog_file11,
3447
+ L: 198,
3380
3448
  S: this,
3381
3449
  C: (f, a) => f(...a)
3382
3450
  });
@@ -3389,12 +3457,12 @@ var DataSpace = class {
3389
3457
  }
3390
3458
  async _close() {
3391
3459
  await this._callbacks.beforeClose?.();
3392
- this._state = import_services9.SpaceState.CLOSED;
3460
+ this._state = import_services8.SpaceState.CLOSED;
3393
3461
  (0, import_log8.log)("new state", {
3394
- state: import_services9.SpaceState[this._state]
3462
+ state: import_services8.SpaceState[this._state]
3395
3463
  }, {
3396
- F: __dxlog_file12,
3397
- L: 204,
3464
+ F: __dxlog_file11,
3465
+ L: 212,
3398
3466
  S: this,
3399
3467
  C: (f, a) => f(...a)
3400
3468
  });
@@ -3423,27 +3491,27 @@ var DataSpace = class {
3423
3491
  this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
3424
3492
  await this.initializeDataPipeline();
3425
3493
  } catch (err) {
3426
- if (err instanceof import_protocols8.CancelledError || err instanceof import_context7.ContextDisposedError) {
3494
+ if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
3427
3495
  (0, import_log8.log)("data pipeline initialization cancelled", err, {
3428
- F: __dxlog_file12,
3429
- L: 237,
3496
+ F: __dxlog_file11,
3497
+ L: 245,
3430
3498
  S: this,
3431
3499
  C: (f, a) => f(...a)
3432
3500
  });
3433
3501
  return;
3434
3502
  }
3435
3503
  import_log8.log.error("Error initializing data pipeline", err, {
3436
- F: __dxlog_file12,
3437
- L: 241,
3504
+ F: __dxlog_file11,
3505
+ L: 249,
3438
3506
  S: this,
3439
3507
  C: (f, a) => f(...a)
3440
3508
  });
3441
- this._state = import_services9.SpaceState.ERROR;
3509
+ this._state = import_services8.SpaceState.ERROR;
3442
3510
  (0, import_log8.log)("new state", {
3443
- state: import_services9.SpaceState[this._state]
3511
+ state: import_services8.SpaceState[this._state]
3444
3512
  }, {
3445
- F: __dxlog_file12,
3446
- L: 243,
3513
+ F: __dxlog_file11,
3514
+ L: 251,
3447
3515
  S: this,
3448
3516
  C: (f, a) => f(...a)
3449
3517
  });
@@ -3455,15 +3523,15 @@ var DataSpace = class {
3455
3523
  });
3456
3524
  }
3457
3525
  async initializeDataPipeline() {
3458
- if (this._state !== import_services9.SpaceState.CONTROL_ONLY) {
3459
- throw new import_protocols8.SystemError("Invalid operation");
3526
+ if (this._state !== import_services8.SpaceState.CONTROL_ONLY) {
3527
+ throw new import_protocols7.SystemError("Invalid operation");
3460
3528
  }
3461
- this._state = import_services9.SpaceState.INITIALIZING;
3529
+ this._state = import_services8.SpaceState.INITIALIZING;
3462
3530
  (0, import_log8.log)("new state", {
3463
- state: import_services9.SpaceState[this._state]
3531
+ state: import_services8.SpaceState[this._state]
3464
3532
  }, {
3465
- F: __dxlog_file12,
3466
- L: 259,
3533
+ F: __dxlog_file11,
3534
+ L: 267,
3467
3535
  S: this,
3468
3536
  C: (f, a) => f(...a)
3469
3537
  });
@@ -3472,18 +3540,18 @@ var DataSpace = class {
3472
3540
  this._automergeSpaceState.startProcessingRootDocs();
3473
3541
  await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
3474
3542
  (0, import_log8.log)("data pipeline ready", void 0, {
3475
- F: __dxlog_file12,
3476
- L: 271,
3543
+ F: __dxlog_file11,
3544
+ L: 279,
3477
3545
  S: this,
3478
3546
  C: (f, a) => f(...a)
3479
3547
  });
3480
3548
  await this._callbacks.beforeReady?.();
3481
- this._state = import_services9.SpaceState.READY;
3549
+ this._state = import_services8.SpaceState.READY;
3482
3550
  (0, import_log8.log)("new state", {
3483
- state: import_services9.SpaceState[this._state]
3551
+ state: import_services8.SpaceState[this._state]
3484
3552
  }, {
3485
- F: __dxlog_file12,
3486
- L: 275,
3553
+ F: __dxlog_file11,
3554
+ L: 283,
3487
3555
  S: this,
3488
3556
  C: (f, a) => f(...a)
3489
3557
  });
@@ -3498,14 +3566,14 @@ var DataSpace = class {
3498
3566
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
3499
3567
  await this._createWritableFeeds();
3500
3568
  (0, import_log8.log)("writable feeds created", void 0, {
3501
- F: __dxlog_file12,
3502
- L: 291,
3569
+ F: __dxlog_file11,
3570
+ L: 299,
3503
3571
  S: this,
3504
3572
  C: (f, a) => f(...a)
3505
3573
  });
3506
3574
  this.stateUpdate.emit();
3507
3575
  if (!this.notarizationPlugin.hasWriter) {
3508
- this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
3576
+ this.notarizationPlugin.setWriter((0, import_echo_pipeline2.createMappedFeedWriter)((credential) => ({
3509
3577
  credential: {
3510
3578
  credential
3511
3579
  }
@@ -3561,8 +3629,8 @@ var DataSpace = class {
3561
3629
  space: this.key,
3562
3630
  rootUrl
3563
3631
  }, {
3564
- F: __dxlog_file12,
3565
- L: 357,
3632
+ F: __dxlog_file11,
3633
+ L: 365,
3566
3634
  S: this,
3567
3635
  C: (f, a) => f(...a)
3568
3636
  });
@@ -3576,7 +3644,7 @@ var DataSpace = class {
3576
3644
  if (this._ctx.disposed) {
3577
3645
  return;
3578
3646
  }
3579
- const doc = handle.docSync() ?? (0, import_invariant10.failedInvariant)();
3647
+ const doc = handle.docSync() ?? (0, import_invariant9.failedInvariant)();
3580
3648
  if (!doc.access?.spaceKey) {
3581
3649
  handle.change((doc2) => {
3582
3650
  doc2.access = {
@@ -3593,8 +3661,8 @@ var DataSpace = class {
3593
3661
  rootUrl,
3594
3662
  err
3595
3663
  }, {
3596
- F: __dxlog_file12,
3597
- L: 380,
3664
+ F: __dxlog_file11,
3665
+ L: 388,
3598
3666
  S: this,
3599
3667
  C: (f, a) => f(...a)
3600
3668
  });
@@ -3620,7 +3688,7 @@ var DataSpace = class {
3620
3688
  let epoch;
3621
3689
  switch (options?.migration) {
3622
3690
  case void 0:
3623
- case import_services9.CreateEpochRequest.Migration.NONE:
3691
+ case import_services8.CreateEpochRequest.Migration.NONE:
3624
3692
  {
3625
3693
  epoch = {
3626
3694
  previousId: this._automergeSpaceState.lastEpoch?.id,
@@ -3630,7 +3698,7 @@ var DataSpace = class {
3630
3698
  };
3631
3699
  }
3632
3700
  break;
3633
- case import_services9.CreateEpochRequest.Migration.INIT_AUTOMERGE:
3701
+ case import_services8.CreateEpochRequest.Migration.INIT_AUTOMERGE:
3634
3702
  {
3635
3703
  const document = this._automergeHost.repo.create();
3636
3704
  epoch = {
@@ -3641,21 +3709,81 @@ var DataSpace = class {
3641
3709
  };
3642
3710
  }
3643
3711
  break;
3644
- case import_services9.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
3712
+ case import_services8.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
3645
3713
  {
3646
3714
  const currentRootUrl = this._automergeSpaceState.rootUrl;
3647
3715
  const rootHandle = this._automergeHost.repo.find(currentRootUrl);
3648
3716
  await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
3649
3717
  const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
3650
- (0, import_invariant10.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3651
- F: __dxlog_file12,
3652
- L: 430,
3718
+ (0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3719
+ F: __dxlog_file11,
3720
+ L: 438,
3721
+ S: this,
3722
+ A: [
3723
+ "typeof newRoot.url === 'string' && newRoot.url.length > 0",
3724
+ ""
3725
+ ]
3726
+ });
3727
+ epoch = {
3728
+ previousId: this._automergeSpaceState.lastEpoch?.id,
3729
+ number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
3730
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
3731
+ automergeRoot: newRoot.url
3732
+ };
3733
+ }
3734
+ break;
3735
+ case import_services8.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
3736
+ {
3737
+ import_log8.log.info("Fragmenting", void 0, {
3738
+ F: __dxlog_file11,
3739
+ L: 450,
3740
+ S: this,
3741
+ C: (f, a) => f(...a)
3742
+ });
3743
+ const currentRootUrl = this._automergeSpaceState.rootUrl;
3744
+ const rootHandle = this._automergeHost.repo.find(currentRootUrl);
3745
+ await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
3746
+ const objects = Object.entries(rootHandle.docSync().objects);
3747
+ const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES);
3748
+ const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3749
+ (0, import_invariant9.invariant)(properties, "Properties not found", {
3750
+ F: __dxlog_file11,
3751
+ L: 460,
3752
+ S: this,
3753
+ A: [
3754
+ "properties",
3755
+ "'Properties not found'"
3756
+ ]
3757
+ });
3758
+ const newSpaceDoc = {
3759
+ ...rootHandle.docSync(),
3760
+ objects: Object.fromEntries([
3761
+ properties
3762
+ ])
3763
+ };
3764
+ const newRoot = this._automergeHost.repo.create(newSpaceDoc);
3765
+ (0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3766
+ F: __dxlog_file11,
3767
+ L: 465,
3653
3768
  S: this,
3654
3769
  A: [
3655
3770
  "typeof newRoot.url === 'string' && newRoot.url.length > 0",
3656
3771
  ""
3657
3772
  ]
3658
3773
  });
3774
+ const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
3775
+ await docLoader.loadSpaceRootDocHandle(this._ctx, {
3776
+ rootUrl: newRoot.url
3777
+ });
3778
+ otherObjects.forEach(([key, value]) => {
3779
+ const handle = docLoader.createDocumentForObject(key);
3780
+ handle.change((doc) => {
3781
+ (0, import_util4.assignDeep)(doc, [
3782
+ "objects",
3783
+ key
3784
+ ], value);
3785
+ });
3786
+ });
3659
3787
  epoch = {
3660
3788
  previousId: this._automergeSpaceState.lastEpoch?.id,
3661
3789
  number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
@@ -3687,25 +3815,25 @@ var DataSpace = class {
3687
3815
  ]));
3688
3816
  }
3689
3817
  async activate() {
3690
- if (this._state !== import_services9.SpaceState.INACTIVE) {
3818
+ if (this._state !== import_services8.SpaceState.INACTIVE) {
3691
3819
  return;
3692
3820
  }
3693
- await this._metadataStore.setSpaceState(this.key, import_services9.SpaceState.ACTIVE);
3821
+ await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.ACTIVE);
3694
3822
  await this._open();
3695
3823
  this.initializeDataPipelineAsync();
3696
3824
  }
3697
3825
  async deactivate() {
3698
- if (this._state === import_services9.SpaceState.INACTIVE) {
3826
+ if (this._state === import_services8.SpaceState.INACTIVE) {
3699
3827
  return;
3700
3828
  }
3701
- await this._metadataStore.setSpaceState(this.key, import_services9.SpaceState.INACTIVE);
3829
+ await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.INACTIVE);
3702
3830
  await this._close();
3703
- this._state = import_services9.SpaceState.INACTIVE;
3831
+ this._state = import_services8.SpaceState.INACTIVE;
3704
3832
  (0, import_log8.log)("new state", {
3705
- state: import_services9.SpaceState[this._state]
3833
+ state: import_services8.SpaceState[this._state]
3706
3834
  }, {
3707
- F: __dxlog_file12,
3708
- L: 482,
3835
+ F: __dxlog_file11,
3836
+ L: 531,
3709
3837
  S: this,
3710
3838
  C: (f, a) => f(...a)
3711
3839
  });
@@ -3713,18 +3841,18 @@ var DataSpace = class {
3713
3841
  }
3714
3842
  };
3715
3843
  _ts_decorate4([
3716
- import_tracing5.trace.info()
3844
+ import_tracing4.trace.info()
3717
3845
  ], DataSpace.prototype, "_inner", void 0);
3718
3846
  _ts_decorate4([
3719
- import_tracing5.trace.info()
3847
+ import_tracing4.trace.info()
3720
3848
  ], DataSpace.prototype, "key", null);
3721
3849
  _ts_decorate4([
3722
- import_tracing5.trace.info({
3723
- enum: import_services9.SpaceState
3850
+ import_tracing4.trace.info({
3851
+ enum: import_services8.SpaceState
3724
3852
  })
3725
3853
  ], DataSpace.prototype, "state", null);
3726
3854
  _ts_decorate4([
3727
- import_tracing5.trace.info({
3855
+ import_tracing4.trace.info({
3728
3856
  depth: null
3729
3857
  })
3730
3858
  ], DataSpace.prototype, "_automergeInfo", null);
@@ -3735,12 +3863,12 @@ _ts_decorate4([
3735
3863
  import_async10.synchronized
3736
3864
  ], DataSpace.prototype, "close", null);
3737
3865
  _ts_decorate4([
3738
- import_tracing5.trace.span({
3866
+ import_tracing4.trace.span({
3739
3867
  showInBrowserTimeline: true
3740
3868
  })
3741
3869
  ], DataSpace.prototype, "initializeDataPipeline", null);
3742
3870
  _ts_decorate4([
3743
- import_tracing5.trace.span({
3871
+ import_tracing4.trace.span({
3744
3872
  showInBrowserTimeline: true
3745
3873
  })
3746
3874
  ], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
@@ -3755,7 +3883,7 @@ _ts_decorate4([
3755
3883
  ], DataSpace.prototype, "deactivate", null);
3756
3884
  DataSpace = _ts_decorate4([
3757
3885
  (0, import_async10.trackLeaks)("open", "close"),
3758
- import_tracing5.trace.resource()
3886
+ import_tracing4.trace.resource()
3759
3887
  ], DataSpace);
3760
3888
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3761
3889
  const credentials = [
@@ -3831,22 +3959,23 @@ function _ts_decorate5(decorators, target, key, desc) {
3831
3959
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3832
3960
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3833
3961
  }
3834
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3962
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3835
3963
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3836
3964
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3837
3965
  var DataSpaceManager = class {
3838
- constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _automergeHost, params) {
3966
+ constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _automergeHost, _invitationsManager, params) {
3839
3967
  this._spaceManager = _spaceManager;
3840
3968
  this._metadataStore = _metadataStore;
3841
3969
  this._keyring = _keyring;
3842
3970
  this._signingContext = _signingContext;
3843
3971
  this._feedStore = _feedStore;
3844
3972
  this._automergeHost = _automergeHost;
3973
+ this._invitationsManager = _invitationsManager;
3845
3974
  this._ctx = new import_context9.Context();
3846
3975
  this.updated = new import_async13.Event();
3847
- this._spaces = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
3976
+ this._spaces = new import_util6.ComplexMap(import_keys10.PublicKey.hash);
3848
3977
  this._isOpen = false;
3849
- this._instanceId = import_keys9.PublicKey.random().toHex();
3978
+ this._instanceId = import_keys10.PublicKey.random().toHex();
3850
3979
  const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
3851
3980
  this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
3852
3981
  this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
@@ -3857,24 +3986,24 @@ var DataSpaceManager = class {
3857
3986
  }
3858
3987
  async open() {
3859
3988
  (0, import_log10.log)("open", void 0, {
3860
- F: __dxlog_file13,
3861
- L: 98,
3989
+ F: __dxlog_file12,
3990
+ L: 101,
3862
3991
  S: this,
3863
3992
  C: (f, a) => f(...a)
3864
3993
  });
3865
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols10.trace.begin({
3994
+ import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.begin({
3866
3995
  id: this._instanceId
3867
3996
  }), {
3868
- F: __dxlog_file13,
3869
- L: 99,
3997
+ F: __dxlog_file12,
3998
+ L: 102,
3870
3999
  S: this,
3871
4000
  C: (f, a) => f(...a)
3872
4001
  });
3873
4002
  (0, import_log10.log)("metadata loaded", {
3874
4003
  spaces: this._metadataStore.spaces.length
3875
4004
  }, {
3876
- F: __dxlog_file13,
3877
- L: 100,
4005
+ F: __dxlog_file12,
4006
+ L: 103,
3878
4007
  S: this,
3879
4008
  C: (f, a) => f(...a)
3880
4009
  });
@@ -3883,8 +4012,8 @@ var DataSpaceManager = class {
3883
4012
  (0, import_log10.log)("load space", {
3884
4013
  spaceMetadata
3885
4014
  }, {
3886
- F: __dxlog_file13,
3887
- L: 104,
4015
+ F: __dxlog_file12,
4016
+ L: 107,
3888
4017
  S: this,
3889
4018
  C: (f, a) => f(...a)
3890
4019
  });
@@ -3894,8 +4023,8 @@ var DataSpaceManager = class {
3894
4023
  spaceMetadata,
3895
4024
  err
3896
4025
  }, {
3897
- F: __dxlog_file13,
3898
- L: 107,
4026
+ F: __dxlog_file12,
4027
+ L: 110,
3899
4028
  S: this,
3900
4029
  C: (f, a) => f(...a)
3901
4030
  });
@@ -3904,23 +4033,23 @@ var DataSpaceManager = class {
3904
4033
  this._isOpen = true;
3905
4034
  this.updated.emit();
3906
4035
  for (const space of this._spaces.values()) {
3907
- if (space.state !== import_services10.SpaceState.INACTIVE) {
4036
+ if (space.state !== import_services9.SpaceState.INACTIVE) {
3908
4037
  space.initializeDataPipelineAsync();
3909
4038
  }
3910
4039
  }
3911
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols10.trace.end({
4040
+ import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.end({
3912
4041
  id: this._instanceId
3913
4042
  }), {
3914
- F: __dxlog_file13,
3915
- L: 120,
4043
+ F: __dxlog_file12,
4044
+ L: 123,
3916
4045
  S: this,
3917
4046
  C: (f, a) => f(...a)
3918
4047
  });
3919
4048
  }
3920
4049
  async close() {
3921
4050
  (0, import_log10.log)("close", void 0, {
3922
- F: __dxlog_file13,
3923
- L: 125,
4051
+ F: __dxlog_file12,
4052
+ L: 128,
3924
4053
  S: this,
3925
4054
  C: (f, a) => f(...a)
3926
4055
  });
@@ -3934,9 +4063,9 @@ var DataSpaceManager = class {
3934
4063
  * Creates a new space writing the genesis credentials to the control feed.
3935
4064
  */
3936
4065
  async createSpace() {
3937
- (0, import_invariant12.invariant)(this._isOpen, "Not open.", {
3938
- F: __dxlog_file13,
3939
- L: 138,
4066
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
4067
+ F: __dxlog_file12,
4068
+ L: 141,
3940
4069
  S: this,
3941
4070
  A: [
3942
4071
  "this._isOpen",
@@ -3951,13 +4080,13 @@ var DataSpaceManager = class {
3951
4080
  genesisFeedKey: controlFeedKey,
3952
4081
  controlFeedKey,
3953
4082
  dataFeedKey,
3954
- state: import_services10.SpaceState.ACTIVE
4083
+ state: import_services9.SpaceState.ACTIVE
3955
4084
  };
3956
4085
  (0, import_log10.log)("creating space...", {
3957
4086
  spaceKey
3958
4087
  }, {
3959
- F: __dxlog_file13,
3960
- L: 150,
4088
+ F: __dxlog_file12,
4089
+ L: 153,
3961
4090
  S: this,
3962
4091
  C: (f, a) => f(...a)
3963
4092
  });
@@ -3971,9 +4100,9 @@ var DataSpaceManager = class {
3971
4100
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
3972
4101
  await this._metadataStore.addSpace(metadata);
3973
4102
  const memberCredential = credentials[1];
3974
- (0, import_invariant12.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3975
- F: __dxlog_file13,
3976
- L: 163,
4103
+ (0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4104
+ F: __dxlog_file12,
4105
+ L: 166,
3977
4106
  S: this,
3978
4107
  A: [
3979
4108
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3990,23 +4119,23 @@ var DataSpaceManager = class {
3990
4119
  (0, import_log10.log)("accept space", {
3991
4120
  opts
3992
4121
  }, {
3993
- F: __dxlog_file13,
3994
- L: 175,
4122
+ F: __dxlog_file12,
4123
+ L: 178,
3995
4124
  S: this,
3996
4125
  C: (f, a) => f(...a)
3997
4126
  });
3998
- (0, import_invariant12.invariant)(this._isOpen, "Not open.", {
3999
- F: __dxlog_file13,
4000
- L: 176,
4127
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
4128
+ F: __dxlog_file12,
4129
+ L: 179,
4001
4130
  S: this,
4002
4131
  A: [
4003
4132
  "this._isOpen",
4004
4133
  "'Not open.'"
4005
4134
  ]
4006
4135
  });
4007
- (0, import_invariant12.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
4008
- F: __dxlog_file13,
4009
- L: 177,
4136
+ (0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
4137
+ F: __dxlog_file12,
4138
+ L: 180,
4010
4139
  S: this,
4011
4140
  A: [
4012
4141
  "!this._spaces.has(opts.spaceKey)",
@@ -4033,15 +4162,15 @@ var DataSpaceManager = class {
4033
4162
  async waitUntilSpaceReady(spaceKey) {
4034
4163
  await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
4035
4164
  const space = this._spaces.get(spaceKey);
4036
- return !!space && space.state === import_services10.SpaceState.READY;
4165
+ return !!space && space.state === import_services9.SpaceState.READY;
4037
4166
  }));
4038
4167
  }
4039
4168
  async _constructSpace(metadata) {
4040
4169
  (0, import_log10.log)("construct space", {
4041
4170
  metadata
4042
4171
  }, {
4043
- F: __dxlog_file13,
4044
- L: 210,
4172
+ F: __dxlog_file12,
4173
+ L: 213,
4045
4174
  S: this,
4046
4175
  C: (f, a) => f(...a)
4047
4176
  });
@@ -4078,19 +4207,22 @@ var DataSpaceManager = class {
4078
4207
  },
4079
4208
  onAuthFailure: () => {
4080
4209
  import_log10.log.warn("auth failure", void 0, {
4081
- F: __dxlog_file13,
4082
- L: 247,
4210
+ F: __dxlog_file12,
4211
+ L: 250,
4083
4212
  S: this,
4084
4213
  C: (f, a) => f(...a)
4085
4214
  });
4086
4215
  },
4087
- memberKey: this._signingContext.identityKey
4216
+ memberKey: this._signingContext.identityKey,
4217
+ onDelegatedInvitationStatusChange: (invitation, isActive) => {
4218
+ return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
4219
+ }
4088
4220
  });
4089
4221
  controlFeed && await space.setControlFeed(controlFeed);
4090
4222
  dataFeed && await space.setDataFeed(dataFeed);
4091
4223
  const dataSpace = new DataSpace({
4092
4224
  inner: space,
4093
- initialState: metadata.state === import_services10.SpaceState.INACTIVE ? import_services10.SpaceState.INACTIVE : import_services10.SpaceState.CLOSED,
4225
+ initialState: metadata.state === import_services9.SpaceState.INACTIVE ? import_services9.SpaceState.INACTIVE : import_services9.SpaceState.CLOSED,
4094
4226
  metadataStore: this._metadataStore,
4095
4227
  gossip,
4096
4228
  presence,
@@ -4102,8 +4234,8 @@ var DataSpaceManager = class {
4102
4234
  (0, import_log10.log)("before space ready", {
4103
4235
  space: space.key
4104
4236
  }, {
4105
- F: __dxlog_file13,
4106
- L: 265,
4237
+ F: __dxlog_file12,
4238
+ L: 271,
4107
4239
  S: this,
4108
4240
  C: (f, a) => f(...a)
4109
4241
  });
@@ -4113,12 +4245,15 @@ var DataSpaceManager = class {
4113
4245
  space: space.key,
4114
4246
  open: this._isOpen
4115
4247
  }, {
4116
- F: __dxlog_file13,
4117
- L: 268,
4248
+ F: __dxlog_file12,
4249
+ L: 274,
4118
4250
  S: this,
4119
4251
  C: (f, a) => f(...a)
4120
4252
  });
4121
4253
  if (this._isOpen) {
4254
+ await this._createDelegatedInvitations(dataSpace, [
4255
+ ...space.spaceState.invitations.entries()
4256
+ ]);
4122
4257
  this.updated.emit();
4123
4258
  }
4124
4259
  },
@@ -4126,8 +4261,8 @@ var DataSpaceManager = class {
4126
4261
  (0, import_log10.log)("before space close", {
4127
4262
  space: space.key
4128
4263
  }, {
4129
- F: __dxlog_file13,
4130
- L: 274,
4264
+ F: __dxlog_file12,
4265
+ L: 281,
4131
4266
  S: this,
4132
4267
  C: (f, a) => f(...a)
4133
4268
  });
@@ -4136,7 +4271,7 @@ var DataSpaceManager = class {
4136
4271
  cache: metadata.cache,
4137
4272
  automergeHost: this._automergeHost
4138
4273
  });
4139
- if (metadata.state !== import_services10.SpaceState.INACTIVE) {
4274
+ if (metadata.state !== import_services9.SpaceState.INACTIVE) {
4140
4275
  await dataSpace.open();
4141
4276
  }
4142
4277
  if (metadata.controlTimeframe) {
@@ -4145,6 +4280,41 @@ var DataSpaceManager = class {
4145
4280
  this._spaces.set(metadata.key, dataSpace);
4146
4281
  return dataSpace;
4147
4282
  }
4283
+ async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
4284
+ if (dataSpace?.state !== import_services9.SpaceState.READY) {
4285
+ return;
4286
+ }
4287
+ if (isActive) {
4288
+ await this._createDelegatedInvitations(dataSpace, [
4289
+ [
4290
+ delegatedInvitation.credentialId,
4291
+ delegatedInvitation.invitation
4292
+ ]
4293
+ ]);
4294
+ } else {
4295
+ await this._invitationsManager.cancelInvitation(delegatedInvitation.invitation);
4296
+ }
4297
+ }
4298
+ async _createDelegatedInvitations(space, invitations) {
4299
+ const tasks = invitations.map(([credentialId, invitation]) => {
4300
+ return this._invitationsManager.createInvitation({
4301
+ type: import_services9.Invitation.Type.DELEGATED,
4302
+ kind: import_services9.Invitation.Kind.SPACE,
4303
+ spaceKey: space.key,
4304
+ authMethod: invitation.authMethod,
4305
+ invitationId: invitation.invitationId,
4306
+ swarmKey: invitation.swarmKey,
4307
+ guestKeypair: invitation.guestKey ? {
4308
+ publicKey: invitation.guestKey
4309
+ } : void 0,
4310
+ lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
4311
+ multiUse: invitation.multiUse,
4312
+ delegationCredentialId: credentialId,
4313
+ persistent: false
4314
+ });
4315
+ });
4316
+ await Promise.all(tasks);
4317
+ }
4148
4318
  };
4149
4319
  _ts_decorate5([
4150
4320
  import_async13.synchronized
@@ -4161,7 +4331,7 @@ _ts_decorate5([
4161
4331
  DataSpaceManager = _ts_decorate5([
4162
4332
  (0, import_async13.trackLeaks)("open", "close")
4163
4333
  ], DataSpaceManager);
4164
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
4334
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
4165
4335
  var SpacesServiceImpl = class {
4166
4336
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
4167
4337
  this._identityManager = _identityManager;
@@ -4178,29 +4348,29 @@ var SpacesServiceImpl = class {
4178
4348
  }
4179
4349
  async updateSpace({ spaceKey, state }) {
4180
4350
  const dataSpaceManager = await this._getDataSpaceManager();
4181
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4351
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4182
4352
  if (state) {
4183
4353
  switch (state) {
4184
- case import_services11.SpaceState.ACTIVE:
4354
+ case import_services10.SpaceState.ACTIVE:
4185
4355
  await space.activate();
4186
4356
  break;
4187
- case import_services11.SpaceState.INACTIVE:
4357
+ case import_services10.SpaceState.INACTIVE:
4188
4358
  await space.deactivate();
4189
4359
  break;
4190
4360
  default:
4191
- throw new import_protocols11.ApiError("Invalid space state");
4361
+ throw new import_protocols10.ApiError("Invalid space state");
4192
4362
  }
4193
4363
  }
4194
4364
  }
4195
4365
  querySpaces() {
4196
- return new import_codec_protobuf11.Stream(({ next, ctx }) => {
4366
+ return new import_codec_protobuf10.Stream(({ next, ctx }) => {
4197
4367
  const scheduler = new import_async14.UpdateScheduler(ctx, async () => {
4198
4368
  const dataSpaceManager = await this._getDataSpaceManager();
4199
4369
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
4200
4370
  (0, import_log11.log)("update", {
4201
4371
  spaces
4202
4372
  }, {
4203
- F: __dxlog_file14,
4373
+ F: __dxlog_file13,
4204
4374
  L: 77,
4205
4375
  S: this,
4206
4376
  C: (f, a) => f(...a)
@@ -4240,14 +4410,14 @@ var SpacesServiceImpl = class {
4240
4410
  }
4241
4411
  async postMessage({ spaceKey, channel, message }) {
4242
4412
  const dataSpaceManager = await this._getDataSpaceManager();
4243
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4413
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4244
4414
  await space.postMessage(getChannelId(channel), message);
4245
4415
  }
4246
4416
  subscribeMessages({ spaceKey, channel }) {
4247
- return new import_codec_protobuf11.Stream(({ ctx, next }) => {
4417
+ return new import_codec_protobuf10.Stream(({ ctx, next }) => {
4248
4418
  (0, import_async14.scheduleTask)(ctx, async () => {
4249
4419
  const dataSpaceManager = await this._getDataSpaceManager();
4250
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4420
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4251
4421
  const handle = space.listen(getChannelId(channel), (message) => {
4252
4422
  next(message);
4253
4423
  });
@@ -4256,8 +4426,8 @@ var SpacesServiceImpl = class {
4256
4426
  });
4257
4427
  }
4258
4428
  queryCredentials({ spaceKey, noTail }) {
4259
- return new import_codec_protobuf11.Stream(({ ctx, next, close }) => {
4260
- const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4429
+ return new import_codec_protobuf10.Stream(({ ctx, next, close }) => {
4430
+ const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4261
4431
  const processor = {
4262
4432
  processCredential: async (credential) => {
4263
4433
  next(credential);
@@ -4273,7 +4443,7 @@ var SpacesServiceImpl = class {
4273
4443
  });
4274
4444
  }
4275
4445
  async writeCredentials({ spaceKey, credentials }) {
4276
- const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4446
+ const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4277
4447
  for (const credential of credentials ?? []) {
4278
4448
  if (credential.proof) {
4279
4449
  await space.controlPipeline.writer.write({
@@ -4282,8 +4452,8 @@ var SpacesServiceImpl = class {
4282
4452
  }
4283
4453
  });
4284
4454
  } else {
4285
- (0, import_invariant13.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
4286
- F: __dxlog_file14,
4455
+ (0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
4456
+ F: __dxlog_file13,
4287
4457
  L: 164,
4288
4458
  S: this,
4289
4459
  A: [
@@ -4291,8 +4461,8 @@ var SpacesServiceImpl = class {
4291
4461
  "'Id on unsigned credentials is not allowed'"
4292
4462
  ]
4293
4463
  });
4294
- (0, import_invariant13.invariant)(this._identityManager.identity, "Identity is not available", {
4295
- F: __dxlog_file14,
4464
+ (0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
4465
+ F: __dxlog_file13,
4296
4466
  L: 165,
4297
4467
  S: this,
4298
4468
  A: [
@@ -4301,8 +4471,8 @@ var SpacesServiceImpl = class {
4301
4471
  ]
4302
4472
  });
4303
4473
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
4304
- (0, import_invariant13.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
4305
- F: __dxlog_file14,
4474
+ (0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
4475
+ F: __dxlog_file13,
4306
4476
  L: 167,
4307
4477
  S: this,
4308
4478
  A: [
@@ -4324,7 +4494,7 @@ var SpacesServiceImpl = class {
4324
4494
  }
4325
4495
  async createEpoch({ spaceKey, migration }) {
4326
4496
  const dataSpaceManager = await this._getDataSpaceManager();
4327
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4497
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4328
4498
  await space.createEpoch({
4329
4499
  migration
4330
4500
  });
@@ -4333,7 +4503,7 @@ var SpacesServiceImpl = class {
4333
4503
  return {
4334
4504
  spaceKey: space.key,
4335
4505
  state: space.state,
4336
- error: space.error ? (0, import_protocols11.encodeError)(space.error) : void 0,
4506
+ error: space.error ? (0, import_protocols10.encodeError)(space.error) : void 0,
4337
4507
  pipeline: {
4338
4508
  currentEpoch: space.automergeSpaceState.lastEpoch,
4339
4509
  appliedEpoch: space.automergeSpaceState.lastEpoch,
@@ -4358,7 +4528,7 @@ var SpacesServiceImpl = class {
4358
4528
  identityKey: member.key,
4359
4529
  profile: member.profile ?? {}
4360
4530
  },
4361
- presence: member.removed ? import_services11.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services11.SpaceMember.PresenceState.ONLINE : import_services11.SpaceMember.PresenceState.OFFLINE,
4531
+ presence: member.removed ? import_services10.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services10.SpaceMember.PresenceState.ONLINE : import_services10.SpaceMember.PresenceState.OFFLINE,
4362
4532
  peerStates: peers
4363
4533
  };
4364
4534
  }),
@@ -4369,7 +4539,7 @@ var SpacesServiceImpl = class {
4369
4539
  }
4370
4540
  };
4371
4541
  var getChannelId = (channel) => `user-channel/${channel}`;
4372
- var createLoadDocuments = (automergeHost) => (
4542
+ var createSelectedDocumentsIterator = (automergeHost) => (
4373
4543
  /**
4374
4544
  * Get object data blobs from Automerge Repo by ids.
4375
4545
  * @param ids
@@ -4377,69 +4547,20 @@ var createLoadDocuments = (automergeHost) => (
4377
4547
  // TODO(mykola): Unload automerge handles after usage.
4378
4548
  async function* loadDocuments(ids) {
4379
4549
  for (const id of ids) {
4380
- const { documentId, objectId } = import_protocols13.idCodec.decode(id);
4381
- const handle = automergeHost.repo.find(documentId);
4382
- await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
4550
+ const { documentId, objectId } = import_protocols12.idCodec.decode(id);
4551
+ const handle = automergeHost.repo.handles[documentId] ?? automergeHost.repo.find(documentId);
4552
+ if (!handle.isReady()) {
4553
+ await handle.whenReady();
4554
+ }
4383
4555
  const doc = handle.docSync();
4384
4556
  const hash = (0, import_automerge.getHeads)(doc).join("");
4385
- yield [
4557
+ yield doc.objects?.[objectId] ? [
4386
4558
  {
4387
4559
  id,
4388
4560
  object: doc.objects[objectId],
4389
4561
  currentHash: hash
4390
4562
  }
4391
- ];
4392
- }
4393
- }
4394
- );
4395
- var createGetAllDocuments = (automergeHost) => (
4396
- /**
4397
- * Recursively get all object data blobs from Automerge Repo.
4398
- * @param ids
4399
- */
4400
- // TODO(mykola): Unload automerge handles after usage.
4401
- async function* getAllDocuments() {
4402
- const visited = /* @__PURE__ */ new Set();
4403
- async function* getObjectsFromHandle(handle) {
4404
- if (visited.has(handle.documentId)) {
4405
- return;
4406
- }
4407
- await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
4408
- const doc = handle.docSync();
4409
- const heads = (0, import_automerge.getHeads)(doc);
4410
- if (doc.objects) {
4411
- yield Object.entries(doc.objects).map(([objectId, object]) => {
4412
- return {
4413
- id: import_protocols13.idCodec.encode({
4414
- documentId: handle.documentId,
4415
- objectId
4416
- }),
4417
- object,
4418
- currentHash: heads.at(-1)
4419
- };
4420
- });
4421
- }
4422
- if (doc.links) {
4423
- for (const id of Object.values(doc.links)) {
4424
- if (visited.has(id)) {
4425
- continue;
4426
- }
4427
- const linkHandle = automergeHost.repo.find(id);
4428
- for await (const result of getObjectsFromHandle(linkHandle)) {
4429
- yield result;
4430
- }
4431
- }
4432
- }
4433
- visited.add(handle.documentId);
4434
- }
4435
- for (const handle of Object.values(automergeHost.repo.handles)) {
4436
- if (visited.has(handle.documentId)) {
4437
- continue;
4438
- }
4439
- for await (const result of getObjectsFromHandle(handle)) {
4440
- yield result;
4441
- }
4442
- visited.add(handle.documentId);
4563
+ ] : [];
4443
4564
  }
4444
4565
  }
4445
4566
  );
@@ -4453,18 +4574,20 @@ function _ts_decorate6(decorators, target, key, desc) {
4453
4574
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4454
4575
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4455
4576
  }
4456
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4457
- var ServiceContext = class {
4458
- constructor(storage, networkManager, signalManager, _runtimeParams) {
4577
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4578
+ var ServiceContext = class extends import_context10.Resource {
4579
+ constructor(storage, level, networkManager, signalManager, _runtimeParams) {
4580
+ super();
4459
4581
  this.storage = storage;
4582
+ this.level = level;
4460
4583
  this.networkManager = networkManager;
4461
4584
  this.signalManager = signalManager;
4462
4585
  this._runtimeParams = _runtimeParams;
4463
4586
  this.initialized = new import_async15.Trigger();
4464
4587
  this._handlerFactories = /* @__PURE__ */ new Map();
4465
- this._instanceId = import_keys10.PublicKey.random().toHex();
4466
- this.metadataStore = new import_echo_pipeline2.MetadataStore(storage.createDirectory("metadata"));
4467
- this.snapshotStore = new import_echo_pipeline2.SnapshotStore(storage.createDirectory("snapshots"));
4588
+ this._instanceId = import_keys11.PublicKey.random().toHex();
4589
+ this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
4590
+ this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
4468
4591
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
4469
4592
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
4470
4593
  this.feedStore = new import_feed_store4.FeedStore({
@@ -4472,12 +4595,12 @@ var ServiceContext = class {
4472
4595
  root: storage.createDirectory("feeds"),
4473
4596
  signer: this.keyring,
4474
4597
  hypercore: {
4475
- valueEncoding: import_echo_pipeline2.valueEncoding,
4598
+ valueEncoding: import_echo_pipeline4.valueEncoding,
4476
4599
  stats: true
4477
4600
  }
4478
4601
  })
4479
4602
  });
4480
- this.spaceManager = new import_echo_pipeline2.SpaceManager({
4603
+ this.spaceManager = new import_echo_pipeline4.SpaceManager({
4481
4604
  feedStore: this.feedStore,
4482
4605
  networkManager: this.networkManager,
4483
4606
  blobStore: this.blobStore,
@@ -4486,66 +4609,81 @@ var ServiceContext = class {
4486
4609
  });
4487
4610
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
4488
4611
  this.indexMetadata = new import_indexing.IndexMetadataStore({
4489
- directory: storage.createDirectory("index-metadata")
4612
+ db: level.sublevel("index-metadata")
4490
4613
  });
4491
- this.automergeHost = new import_echo_pipeline2.AutomergeHost({
4614
+ this.automergeHost = new import_echo_pipeline4.AutomergeHost({
4492
4615
  directory: storage.createDirectory("automerge"),
4493
- metadata: this.indexMetadata
4616
+ db: level.sublevel("automerge"),
4617
+ storageCallbacks: (0, import_indexing.createStorageCallbacks)({
4618
+ host: () => this.automergeHost,
4619
+ metadata: this.indexMetadata
4620
+ })
4494
4621
  });
4495
4622
  this.indexer = new import_indexing.Indexer({
4623
+ db: this.level,
4496
4624
  indexStore: new import_indexing.IndexStore({
4497
- directory: storage.createDirectory("index-store")
4625
+ db: level.sublevel("index-storage")
4498
4626
  }),
4499
4627
  metadataStore: this.indexMetadata,
4500
- loadDocuments: createLoadDocuments(this.automergeHost),
4501
- getAllDocuments: createGetAllDocuments(this.automergeHost)
4628
+ loadDocuments: createSelectedDocumentsIterator(this.automergeHost)
4502
4629
  });
4503
4630
  this.invitations = new InvitationsHandler(this.networkManager);
4504
- this._handlerFactories.set(import_services12.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
4631
+ this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
4632
+ this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
4505
4633
  }
4506
- async open(ctx) {
4634
+ async _open(ctx) {
4507
4635
  await this._checkStorageVersion();
4508
4636
  (0, import_log12.log)("opening...", void 0, {
4509
- F: __dxlog_file15,
4510
- L: 151,
4637
+ F: __dxlog_file14,
4638
+ L: 164,
4511
4639
  S: this,
4512
4640
  C: (f, a) => f(...a)
4513
4641
  });
4514
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.begin({
4642
+ import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.begin({
4515
4643
  id: this._instanceId
4516
4644
  }), {
4517
- F: __dxlog_file15,
4518
- L: 152,
4645
+ F: __dxlog_file14,
4646
+ L: 165,
4519
4647
  S: this,
4520
4648
  C: (f, a) => f(...a)
4521
4649
  });
4522
4650
  await this.signalManager.open();
4523
4651
  await this.networkManager.open();
4652
+ await this.automergeHost.open();
4524
4653
  await this.metadataStore.load();
4525
4654
  await this.spaceManager.open();
4526
4655
  await this.identityManager.open(ctx);
4527
4656
  if (this.identityManager.identity) {
4528
4657
  await this._initialize(ctx);
4529
4658
  }
4530
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.end({
4659
+ const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
4660
+ (0, import_log12.log)("loaded persistent invitations", {
4661
+ count: loadedInvitations.invitations?.length
4662
+ }, {
4663
+ F: __dxlog_file14,
4664
+ L: 178,
4665
+ S: this,
4666
+ C: (f, a) => f(...a)
4667
+ });
4668
+ import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
4531
4669
  id: this._instanceId
4532
4670
  }), {
4533
- F: __dxlog_file15,
4534
- L: 162,
4671
+ F: __dxlog_file14,
4672
+ L: 180,
4535
4673
  S: this,
4536
4674
  C: (f, a) => f(...a)
4537
4675
  });
4538
4676
  (0, import_log12.log)("opened", void 0, {
4539
- F: __dxlog_file15,
4540
- L: 163,
4677
+ F: __dxlog_file14,
4678
+ L: 181,
4541
4679
  S: this,
4542
4680
  C: (f, a) => f(...a)
4543
4681
  });
4544
4682
  }
4545
- async close() {
4683
+ async _close() {
4546
4684
  (0, import_log12.log)("closing...", void 0, {
4547
- F: __dxlog_file15,
4548
- L: 167,
4685
+ F: __dxlog_file14,
4686
+ L: 185,
4549
4687
  S: this,
4550
4688
  C: (f, a) => f(...a)
4551
4689
  });
@@ -4562,8 +4700,8 @@ var ServiceContext = class {
4562
4700
  await this.metadataStore.close();
4563
4701
  await this.indexer.destroy();
4564
4702
  (0, import_log12.log)("closed", void 0, {
4565
- F: __dxlog_file15,
4566
- L: 180,
4703
+ F: __dxlog_file14,
4704
+ L: 198,
4567
4705
  S: this,
4568
4706
  C: (f, a) => f(...a)
4569
4707
  });
@@ -4575,9 +4713,9 @@ var ServiceContext = class {
4575
4713
  }
4576
4714
  getInvitationHandler(invitation) {
4577
4715
  const factory = this._handlerFactories.get(invitation.kind);
4578
- (0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4579
- F: __dxlog_file15,
4580
- L: 191,
4716
+ (0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4717
+ F: __dxlog_file14,
4718
+ L: 209,
4581
4719
  S: this,
4582
4720
  A: [
4583
4721
  "factory",
@@ -4601,15 +4739,15 @@ var ServiceContext = class {
4601
4739
  }
4602
4740
  async _checkStorageVersion() {
4603
4741
  await this.metadataStore.load();
4604
- if (this.metadataStore.version !== import_protocols12.STORAGE_VERSION) {
4605
- throw new import_protocols12.InvalidStorageVersionError(import_protocols12.STORAGE_VERSION, this.metadataStore.version);
4742
+ if (this.metadataStore.version !== import_protocols11.STORAGE_VERSION) {
4743
+ throw new import_protocols11.InvalidStorageVersionError(import_protocols11.STORAGE_VERSION, this.metadataStore.version);
4606
4744
  }
4607
4745
  }
4608
4746
  // Called when identity is created.
4609
4747
  async _initialize(ctx) {
4610
4748
  (0, import_log12.log)("initializing spaces...", void 0, {
4611
- F: __dxlog_file15,
4612
- L: 222,
4749
+ F: __dxlog_file14,
4750
+ L: 240,
4613
4751
  S: this,
4614
4752
  C: (f, a) => f(...a)
4615
4753
  });
@@ -4627,12 +4765,12 @@ var ServiceContext = class {
4627
4765
  });
4628
4766
  }
4629
4767
  };
4630
- this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
4768
+ this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this.invitationsManager, this._runtimeParams);
4631
4769
  await this.dataSpaceManager.open();
4632
- this._handlerFactories.set(import_services12.Invitation.Kind.SPACE, (invitation) => {
4633
- (0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4634
- F: __dxlog_file15,
4635
- L: 246,
4770
+ this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
4771
+ (0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4772
+ F: __dxlog_file14,
4773
+ L: 265,
4636
4774
  S: this,
4637
4775
  A: [
4638
4776
  "this.dataSpaceManager",
@@ -4655,8 +4793,8 @@ var ServiceContext = class {
4655
4793
  (0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
4656
4794
  details: assertion
4657
4795
  }, {
4658
- F: __dxlog_file15,
4659
- L: 262,
4796
+ F: __dxlog_file14,
4797
+ L: 281,
4660
4798
  S: this,
4661
4799
  C: (f, a) => f(...a)
4662
4800
  });
@@ -4666,8 +4804,8 @@ var ServiceContext = class {
4666
4804
  (0, import_log12.log)("space already exists, ignoring space admission", {
4667
4805
  details: assertion
4668
4806
  }, {
4669
- F: __dxlog_file15,
4670
- L: 266,
4807
+ F: __dxlog_file14,
4808
+ L: 285,
4671
4809
  S: this,
4672
4810
  C: (f, a) => f(...a)
4673
4811
  });
@@ -4677,8 +4815,8 @@ var ServiceContext = class {
4677
4815
  (0, import_log12.log)("accepting space recorded in halo", {
4678
4816
  details: assertion
4679
4817
  }, {
4680
- F: __dxlog_file15,
4681
- L: 271,
4818
+ F: __dxlog_file14,
4819
+ L: 290,
4682
4820
  S: this,
4683
4821
  C: (f, a) => f(...a)
4684
4822
  });
@@ -4688,8 +4826,8 @@ var ServiceContext = class {
4688
4826
  });
4689
4827
  } catch (err) {
4690
4828
  import_log12.log.catch(err, void 0, {
4691
- F: __dxlog_file15,
4692
- L: 277,
4829
+ F: __dxlog_file14,
4830
+ L: 296,
4693
4831
  S: this,
4694
4832
  C: (f, a) => f(...a)
4695
4833
  });
@@ -4700,14 +4838,14 @@ var ServiceContext = class {
4700
4838
  }
4701
4839
  };
4702
4840
  _ts_decorate6([
4703
- import_tracing6.trace.span()
4704
- ], ServiceContext.prototype, "open", null);
4841
+ import_tracing5.trace.span()
4842
+ ], ServiceContext.prototype, "_open", null);
4705
4843
  _ts_decorate6([
4706
- import_tracing6.trace.span()
4844
+ import_tracing5.trace.span()
4707
4845
  ], ServiceContext.prototype, "_initialize", null);
4708
4846
  ServiceContext = _ts_decorate6([
4709
4847
  (0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
4710
- import_tracing6.trace.resource()
4848
+ import_tracing5.trace.resource()
4711
4849
  ], ServiceContext);
4712
4850
  var ServiceRegistry = class {
4713
4851
  // prettier-ignore
@@ -4731,103 +4869,155 @@ var ServiceRegistry = class {
4731
4869
  delete this._handlers[name];
4732
4870
  }
4733
4871
  };
4734
- function _ts_decorate7(decorators, target, key, desc) {
4735
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4736
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4737
- r = Reflect.decorate(decorators, target, key, desc);
4738
- else
4739
- for (var i = decorators.length - 1; i >= 0; i--)
4740
- if (d = decorators[i])
4741
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4742
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4743
- }
4744
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
4745
- var Lock = class {
4746
- constructor({ lockKey: lockPath, onAcquire, onRelease }) {
4747
- this._lockPath = lockPath;
4748
- this._onAcquire = onAcquire;
4749
- this._onRelease = onRelease;
4750
- }
4751
- get lockKey() {
4752
- return this._lockPath;
4753
- }
4754
- async acquire() {
4755
- (0, import_log13.log)("acquiring lock...", void 0, {
4756
- F: __dxlog_file16,
4757
- L: 32,
4758
- S: this,
4759
- C: (f, a) => f(...a)
4760
- });
4761
- this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
4762
- await this._onAcquire?.();
4763
- (0, import_log13.log)("acquired lock", void 0, {
4764
- F: __dxlog_file16,
4765
- L: 37,
4766
- S: this,
4767
- C: (f, a) => f(...a)
4768
- });
4769
- }
4770
- async release() {
4771
- await this._onRelease?.();
4772
- (0, import_invariant15.invariant)(this._fileHandle, "Lock is not acquired", {
4773
- F: __dxlog_file16,
4774
- L: 42,
4775
- S: this,
4872
+ var DXOS_VERSION = "0.4.10-main.fd8ea31";
4873
+ var getPlatform = () => {
4874
+ if (process.browser) {
4875
+ if (typeof window !== "undefined") {
4876
+ const { userAgent } = window.navigator;
4877
+ return {
4878
+ type: import_services13.Platform.PLATFORM_TYPE.BROWSER,
4879
+ userAgent,
4880
+ uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
4881
+ };
4882
+ } else {
4883
+ return {
4884
+ type: import_services13.Platform.PLATFORM_TYPE.SHARED_WORKER,
4885
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
4886
+ };
4887
+ }
4888
+ } else {
4889
+ const { platform: platform2, version, arch } = process;
4890
+ return {
4891
+ type: import_services13.Platform.PLATFORM_TYPE.NODE,
4892
+ platform: platform2,
4893
+ arch,
4894
+ runtime: version,
4895
+ uptime: Math.floor(process.uptime()),
4896
+ memory: process.memoryUsage()
4897
+ };
4898
+ }
4899
+ };
4900
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
4901
+ var DEFAULT_TIMEOUT = 1e3;
4902
+ var createDiagnostics = async (clientServices, serviceContext, config) => {
4903
+ const diagnostics = {
4904
+ created: (/* @__PURE__ */ new Date()).toISOString(),
4905
+ platform: getPlatform(),
4906
+ client: {
4907
+ version: DXOS_VERSION,
4908
+ storage: {
4909
+ version: import_protocols13.STORAGE_VERSION
4910
+ }
4911
+ },
4912
+ trace: import_tracing6.TRACE_PROCESSOR.getDiagnostics()
4913
+ };
4914
+ {
4915
+ (0, import_invariant14.invariant)(clientServices.LoggingService, "SystemService is not available.", {
4916
+ F: __dxlog_file15,
4917
+ L: 108,
4918
+ S: void 0,
4776
4919
  A: [
4777
- "this._fileHandle",
4778
- "'Lock is not acquired'"
4920
+ "clientServices.LoggingService",
4921
+ "'SystemService is not available.'"
4779
4922
  ]
4780
4923
  });
4781
- await import_lock_file.LockFile.release(this._fileHandle);
4782
- }
4783
- };
4784
- _ts_decorate7([
4785
- import_log13.logInfo
4786
- ], Lock.prototype, "lockKey", null);
4787
- var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
4788
- var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
4789
- var createStorageObjects = (config) => {
4790
- const { persistent = false, keyStore, dataStore, dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
4791
- if (persistent && dataStore === StorageDriver.RAM) {
4792
- throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
4924
+ diagnostics.metrics = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
4925
+ timeout: DEFAULT_TIMEOUT
4926
+ }).catch(() => void 0);
4793
4927
  }
4794
- if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
4795
- throw new import_protocols14.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
4928
+ if (typeof navigator !== "undefined" && navigator.storage) {
4929
+ const map = /* @__PURE__ */ new Map();
4930
+ const dir = await navigator.storage.getDirectory();
4931
+ for await (const filename of dir?.keys()) {
4932
+ const idx = filename.indexOf("-", filename.indexOf("-") + 1);
4933
+ if (idx === -1) {
4934
+ continue;
4935
+ }
4936
+ map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
4937
+ }
4938
+ diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
4939
+ file,
4940
+ count
4941
+ }));
4796
4942
  }
4797
- if (persistent && keyStore === StorageDriver.RAM) {
4798
- throw new import_protocols14.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
4943
+ const identity = serviceContext.identityManager.identity;
4944
+ if (identity) {
4945
+ diagnostics.identity = {
4946
+ identityKey: identity.identityKey,
4947
+ spaceKey: identity.space.key,
4948
+ profile: identity.profileDocument
4949
+ };
4950
+ const { devices } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
4951
+ timeout: DEFAULT_TIMEOUT
4952
+ }).catch(() => void 0) ?? {};
4953
+ diagnostics.devices = devices;
4954
+ if (serviceContext.dataSpaceManager) {
4955
+ diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
4956
+ }
4957
+ const { feeds = [] } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
4958
+ timeout: DEFAULT_TIMEOUT
4959
+ }).catch(() => void 0) ?? {};
4960
+ diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
4961
+ feedKey,
4962
+ bytes,
4963
+ length
4964
+ }));
4965
+ const status = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
4966
+ timeout: DEFAULT_TIMEOUT
4967
+ }).catch(() => void 0);
4968
+ diagnostics.networkStatus = status;
4969
+ diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
4799
4970
  }
4800
- if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
4801
- throw new import_protocols14.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
4971
+ diagnostics.config = config.values;
4972
+ return diagnostics;
4973
+ };
4974
+ var getSpaceStats = async (space) => {
4975
+ const stats = {
4976
+ key: space.key,
4977
+ metrics: space.metrics,
4978
+ epochs: space.inner.spaceState.credentials.filter((0, import_credentials16.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
4979
+ ...credential.subject.assertion,
4980
+ id: credential.id
4981
+ })),
4982
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
4983
+ identity: {
4984
+ identityKey: member.key,
4985
+ profile: {
4986
+ displayName: member.assertion.profile?.displayName
4987
+ }
4988
+ },
4989
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services12.SpaceMember.PresenceState.ONLINE : import_services12.SpaceMember.PresenceState.OFFLINE
4990
+ })),
4991
+ pipeline: {
4992
+ // TODO(burdon): Pick properties from credentials if needed.
4993
+ currentEpoch: space.automergeSpaceState.lastEpoch,
4994
+ appliedEpoch: space.automergeSpaceState.lastEpoch,
4995
+ controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
4996
+ currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
4997
+ targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
4998
+ totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
4999
+ }
5000
+ };
5001
+ if (stats.metrics) {
5002
+ const { open, ready } = stats.metrics;
5003
+ stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
4802
5004
  }
5005
+ return stats;
5006
+ };
5007
+ var createCollectDiagnosticsBroadcastSender = () => {
4803
5008
  return {
4804
- storage: (0, import_random_access_storage.createStorage)({
4805
- type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
4806
- root: `${dataRoot}/`
4807
- })
5009
+ broadcastDiagnosticsRequest: async () => void 0
4808
5010
  };
4809
5011
  };
4810
- var toStorageType = (type) => {
4811
- switch (type) {
4812
- case void 0:
4813
- return void 0;
4814
- case StorageDriver.RAM:
4815
- return import_random_access_storage.StorageType.RAM;
4816
- case StorageDriver.CHROME:
4817
- return import_random_access_storage.StorageType.CHROME;
4818
- case StorageDriver.FIREFOX:
4819
- return import_random_access_storage.StorageType.FIREFOX;
4820
- case StorageDriver.IDB:
4821
- return import_random_access_storage.StorageType.IDB;
4822
- case StorageDriver.NODE:
4823
- return import_random_access_storage.StorageType.NODE;
4824
- case StorageDriver.WEBFS:
4825
- return import_random_access_storage.StorageType.WEBFS;
4826
- default:
4827
- throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
4828
- }
5012
+ var createCollectDiagnosticsBroadcastHandler = (_) => {
5013
+ return {
5014
+ start: () => {
5015
+ },
5016
+ stop: () => {
5017
+ }
5018
+ };
4829
5019
  };
4830
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
5020
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
4831
5021
  var DevicesServiceImpl = class {
4832
5022
  constructor(_identityManager) {
4833
5023
  this._identityManager = _identityManager;
@@ -4844,8 +5034,8 @@ var DevicesServiceImpl = class {
4844
5034
  devices: []
4845
5035
  });
4846
5036
  } else {
4847
- (0, import_invariant17.invariant)(this._identityManager.identity?.presence, "presence not present", {
4848
- F: __dxlog_file17,
5037
+ (0, import_invariant16.invariant)(this._identityManager.identity?.presence, "presence not present", {
5038
+ F: __dxlog_file16,
4849
5039
  L: 32,
4850
5040
  S: this,
4851
5041
  A: [
@@ -4860,9 +5050,9 @@ var DevicesServiceImpl = class {
4860
5050
  const peerState = peers.find((peer) => peer.identityKey.equals(key));
4861
5051
  return {
4862
5052
  deviceKey: key,
4863
- kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services14.DeviceKind.CURRENT : import_services14.DeviceKind.TRUSTED,
5053
+ kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services16.DeviceKind.CURRENT : import_services16.DeviceKind.TRUSTED,
4864
5054
  profile,
4865
- presence: isMe ? import_services14.Device.PresenceState.ONLINE : peerState ? import_services14.Device.PresenceState.ONLINE : import_services14.Device.PresenceState.OFFLINE
5055
+ presence: isMe ? import_services16.Device.PresenceState.ONLINE : peerState ? import_services16.Device.PresenceState.ONLINE : import_services16.Device.PresenceState.OFFLINE
4866
5056
  };
4867
5057
  })
4868
5058
  });
@@ -4903,11 +5093,65 @@ var DevicesServiceImpl = class {
4903
5093
  });
4904
5094
  }
4905
5095
  };
5096
+ function _ts_decorate7(decorators, target, key, desc) {
5097
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5098
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
5099
+ r = Reflect.decorate(decorators, target, key, desc);
5100
+ else
5101
+ for (var i = decorators.length - 1; i >= 0; i--)
5102
+ if (d = decorators[i])
5103
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5104
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5105
+ }
5106
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
5107
+ var Lock = class {
5108
+ constructor({ lockKey: lockPath, onAcquire, onRelease }) {
5109
+ this._lockPath = lockPath;
5110
+ this._onAcquire = onAcquire;
5111
+ this._onRelease = onRelease;
5112
+ }
5113
+ get lockKey() {
5114
+ return this._lockPath;
5115
+ }
5116
+ async acquire() {
5117
+ (0, import_log14.log)("acquiring lock...", void 0, {
5118
+ F: __dxlog_file17,
5119
+ L: 32,
5120
+ S: this,
5121
+ C: (f, a) => f(...a)
5122
+ });
5123
+ this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
5124
+ await this._onAcquire?.();
5125
+ (0, import_log14.log)("acquired lock", void 0, {
5126
+ F: __dxlog_file17,
5127
+ L: 37,
5128
+ S: this,
5129
+ C: (f, a) => f(...a)
5130
+ });
5131
+ }
5132
+ async release() {
5133
+ await this._onRelease?.();
5134
+ (0, import_invariant17.invariant)(this._fileHandle, "Lock is not acquired", {
5135
+ F: __dxlog_file17,
5136
+ L: 42,
5137
+ S: this,
5138
+ A: [
5139
+ "this._fileHandle",
5140
+ "'Lock is not acquired'"
5141
+ ]
5142
+ });
5143
+ await import_lock_file.LockFile.release(this._fileHandle);
5144
+ }
5145
+ };
5146
+ _ts_decorate7([
5147
+ import_log14.logInfo
5148
+ ], Lock.prototype, "lockKey", null);
5149
+ var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
4906
5150
  var LoggingServiceImpl = class {
4907
5151
  constructor() {
4908
5152
  this._logs = new import_async18.Event();
4909
5153
  this._started = Date.now();
4910
- this._sessionId = import_keys12.PublicKey.random().toHex();
5154
+ this._sessionId = import_keys13.PublicKey.random().toHex();
4911
5155
  this._logProcessor = (_config, entry2) => {
4912
5156
  this._logs.emit(entry2);
4913
5157
  };
@@ -5002,18 +5246,18 @@ var LoggingServiceImpl = class {
5002
5246
  });
5003
5247
  }
5004
5248
  };
5005
- var matchFilter = (filter, level, path, options) => {
5249
+ var matchFilter = (filter, level, path2, options) => {
5006
5250
  switch (options) {
5007
- case import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5008
- return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
5009
- case import_services15.QueryLogsRequest.MatchingOptions.EXPLICIT:
5010
- return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
5251
+ case import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5252
+ return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
5253
+ case import_services17.QueryLogsRequest.MatchingOptions.EXPLICIT:
5254
+ return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
5011
5255
  }
5012
5256
  };
5013
5257
  var shouldLog = (entry2, request) => {
5014
- const options = request.options ?? import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5258
+ const options = request.options ?? import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5015
5259
  if (request.filters === void 0) {
5016
- return options === import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5260
+ return options === import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5017
5261
  } else {
5018
5262
  return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
5019
5263
  }
@@ -5049,6 +5293,63 @@ var NetworkServiceImpl = class {
5049
5293
  await this.networkManager.setConnectionState(request.swarm);
5050
5294
  }
5051
5295
  };
5296
+ var getRootPath = (config) => {
5297
+ const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
5298
+ return `${dataRoot}/`;
5299
+ };
5300
+ var isPersistent = (config) => {
5301
+ const { persistent = false } = config ?? {};
5302
+ return config.dataStore !== void 0 && config.dataStore !== import_config3.Runtime.Client.Storage.StorageDriver.RAM || persistent;
5303
+ };
5304
+ var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
5305
+ var createStorageObjects = (config) => {
5306
+ const { persistent = false, keyStore, dataStore } = config ?? {};
5307
+ if (persistent && dataStore === StorageDriver.RAM) {
5308
+ throw new import_protocols15.InvalidConfigError("RAM storage cannot be used in persistent mode.");
5309
+ }
5310
+ if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
5311
+ throw new import_protocols15.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
5312
+ }
5313
+ if (persistent && keyStore === StorageDriver.RAM) {
5314
+ throw new import_protocols15.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
5315
+ }
5316
+ if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
5317
+ throw new import_protocols15.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
5318
+ }
5319
+ return {
5320
+ storage: (0, import_random_access_storage.createStorage)({
5321
+ type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
5322
+ root: getRootPath(config)
5323
+ })
5324
+ };
5325
+ };
5326
+ var toStorageType = (type) => {
5327
+ switch (type) {
5328
+ case void 0:
5329
+ return void 0;
5330
+ case StorageDriver.RAM:
5331
+ return import_random_access_storage.StorageType.RAM;
5332
+ case StorageDriver.CHROME:
5333
+ return import_random_access_storage.StorageType.CHROME;
5334
+ case StorageDriver.FIREFOX:
5335
+ return import_random_access_storage.StorageType.FIREFOX;
5336
+ case StorageDriver.IDB:
5337
+ return import_random_access_storage.StorageType.IDB;
5338
+ case StorageDriver.NODE:
5339
+ return import_random_access_storage.StorageType.NODE;
5340
+ case StorageDriver.WEBFS:
5341
+ return import_random_access_storage.StorageType.WEBFS;
5342
+ default:
5343
+ throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
5344
+ }
5345
+ };
5346
+ var createLevel = async (config) => {
5347
+ const persistent = isPersistent(config);
5348
+ const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys14.PublicKey.random().toHex()}`;
5349
+ const level = new import_level.Level(storagePath);
5350
+ await level.open();
5351
+ return level;
5352
+ };
5052
5353
  var SystemServiceImpl = class {
5053
5354
  constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
5054
5355
  this._config = config;
@@ -5068,9 +5369,9 @@ var SystemServiceImpl = class {
5068
5369
  const diagnostics = await this._getDiagnostics();
5069
5370
  return {
5070
5371
  timestamp: /* @__PURE__ */ new Date(),
5071
- diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util11.jsonKeyReplacer)({
5072
- truncate: keys === import_services16.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
5073
- humanize: keys === import_services16.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
5372
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
5373
+ truncate: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
5374
+ humanize: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
5074
5375
  })))
5075
5376
  };
5076
5377
  }
@@ -5118,16 +5419,18 @@ var ClientServicesHost = class {
5118
5419
  transportFactory,
5119
5420
  signalManager,
5120
5421
  storage,
5422
+ level,
5121
5423
  // TODO(wittjosiah): Turn this on by default.
5122
5424
  lockKey,
5123
5425
  callbacks,
5124
5426
  runtimeParams
5125
5427
  } = {}) {
5126
- this._tracingService = import_tracing7.TRACE_PROCESSOR.createTraceSender();
5428
+ this._tracingService = import_tracing8.TRACE_PROCESSOR.createTraceSender();
5127
5429
  this._statusUpdate = new import_async16.Event();
5128
5430
  this._opening = false;
5129
5431
  this._open = false;
5130
5432
  this._storage = storage;
5433
+ this._level = level;
5131
5434
  this._callbacks = callbacks;
5132
5435
  this._runtimeParams = runtimeParams;
5133
5436
  if (config) {
@@ -5151,14 +5454,14 @@ var ClientServicesHost = class {
5151
5454
  this._systemService = new SystemServiceImpl({
5152
5455
  config: () => this._config,
5153
5456
  statusUpdate: this._statusUpdate,
5154
- getCurrentStatus: () => this.isOpen ? import_services13.SystemStatus.ACTIVE : import_services13.SystemStatus.INACTIVE,
5457
+ getCurrentStatus: () => this.isOpen ? import_services15.SystemStatus.ACTIVE : import_services15.SystemStatus.INACTIVE,
5155
5458
  getDiagnostics: () => {
5156
5459
  return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
5157
5460
  },
5158
5461
  onUpdateStatus: async (status) => {
5159
- if (!this.isOpen && status === import_services13.SystemStatus.ACTIVE) {
5462
+ if (!this.isOpen && status === import_services15.SystemStatus.ACTIVE) {
5160
5463
  await this._resourceLock?.acquire();
5161
- } else if (this.isOpen && status === import_services13.SystemStatus.INACTIVE) {
5464
+ } else if (this.isOpen && status === import_services15.SystemStatus.INACTIVE) {
5162
5465
  await this._resourceLock?.release();
5163
5466
  }
5164
5467
  },
@@ -5166,6 +5469,7 @@ var ClientServicesHost = class {
5166
5469
  await this.reset();
5167
5470
  }
5168
5471
  });
5472
+ this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
5169
5473
  this._loggingService = new LoggingServiceImpl();
5170
5474
  this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
5171
5475
  SystemService: this._systemService,
@@ -5196,25 +5500,25 @@ var ClientServicesHost = class {
5196
5500
  * Can only be called once.
5197
5501
  */
5198
5502
  initialize({ config, ...options }) {
5199
- (0, import_invariant16.invariant)(!this._open, "service host is open", {
5503
+ (0, import_invariant15.invariant)(!this._open, "service host is open", {
5200
5504
  F: __dxlog_file18,
5201
- L: 179,
5505
+ L: 198,
5202
5506
  S: this,
5203
5507
  A: [
5204
5508
  "!this._open",
5205
5509
  "'service host is open'"
5206
5510
  ]
5207
5511
  });
5208
- (0, import_log14.log)("initializing...", void 0, {
5512
+ (0, import_log13.log)("initializing...", void 0, {
5209
5513
  F: __dxlog_file18,
5210
- L: 180,
5514
+ L: 199,
5211
5515
  S: this,
5212
5516
  C: (f, a) => f(...a)
5213
5517
  });
5214
5518
  if (config) {
5215
- (0, import_invariant16.invariant)(!this._config, "config already set", {
5519
+ (0, import_invariant15.invariant)(!this._config, "config already set", {
5216
5520
  F: __dxlog_file18,
5217
- L: 183,
5521
+ L: 202,
5218
5522
  S: this,
5219
5523
  A: [
5220
5524
  "!this._config",
@@ -5226,13 +5530,21 @@ var ClientServicesHost = class {
5226
5530
  this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
5227
5531
  }
5228
5532
  }
5533
+ if (!options.signalManager) {
5534
+ import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
5535
+ F: __dxlog_file18,
5536
+ L: 210,
5537
+ S: this,
5538
+ C: (f, a) => f(...a)
5539
+ });
5540
+ }
5229
5541
  const { connectionLog = true, transportFactory = (0, import_network_manager2.createSimplePeerTransportFactory)({
5230
5542
  iceServers: this._config?.get("runtime.services.ice")
5231
5543
  }), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
5232
5544
  this._signalManager = signalManager;
5233
- (0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
5545
+ (0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
5234
5546
  F: __dxlog_file18,
5235
- L: 199,
5547
+ L: 221,
5236
5548
  S: this,
5237
5549
  A: [
5238
5550
  "!this._networkManager",
@@ -5244,9 +5556,9 @@ var ClientServicesHost = class {
5244
5556
  transportFactory,
5245
5557
  signalManager
5246
5558
  });
5247
- (0, import_log14.log)("initialized", void 0, {
5559
+ (0, import_log13.log)("initialized", void 0, {
5248
5560
  F: __dxlog_file18,
5249
- L: 206,
5561
+ L: 228,
5250
5562
  S: this,
5251
5563
  C: (f, a) => f(...a)
5252
5564
  });
@@ -5255,45 +5567,45 @@ var ClientServicesHost = class {
5255
5567
  if (this._open) {
5256
5568
  return;
5257
5569
  }
5258
- const traceId = import_keys11.PublicKey.random().toHex();
5259
- import_log14.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
5570
+ const traceId = import_keys12.PublicKey.random().toHex();
5571
+ import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
5260
5572
  id: traceId
5261
5573
  }), {
5262
5574
  F: __dxlog_file18,
5263
- L: 217,
5575
+ L: 239,
5264
5576
  S: this,
5265
5577
  C: (f, a) => f(...a)
5266
5578
  });
5267
- (0, import_invariant16.invariant)(this._config, "config not set", {
5579
+ (0, import_invariant15.invariant)(this._config, "config not set", {
5268
5580
  F: __dxlog_file18,
5269
- L: 219,
5581
+ L: 241,
5270
5582
  S: this,
5271
5583
  A: [
5272
5584
  "this._config",
5273
5585
  "'config not set'"
5274
5586
  ]
5275
5587
  });
5276
- (0, import_invariant16.invariant)(this._storage, "storage not set", {
5588
+ (0, import_invariant15.invariant)(this._storage, "storage not set", {
5277
5589
  F: __dxlog_file18,
5278
- L: 220,
5590
+ L: 242,
5279
5591
  S: this,
5280
5592
  A: [
5281
5593
  "this._storage",
5282
5594
  "'storage not set'"
5283
5595
  ]
5284
5596
  });
5285
- (0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
5597
+ (0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
5286
5598
  F: __dxlog_file18,
5287
- L: 221,
5599
+ L: 243,
5288
5600
  S: this,
5289
5601
  A: [
5290
5602
  "this._signalManager",
5291
5603
  "'signal manager not set'"
5292
5604
  ]
5293
5605
  });
5294
- (0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
5606
+ (0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
5295
5607
  F: __dxlog_file18,
5296
- L: 222,
5608
+ L: 244,
5297
5609
  S: this,
5298
5610
  A: [
5299
5611
  "this._networkManager",
@@ -5301,31 +5613,37 @@ var ClientServicesHost = class {
5301
5613
  ]
5302
5614
  });
5303
5615
  this._opening = true;
5304
- (0, import_log14.log)("opening...", {
5616
+ (0, import_log13.log)("opening...", {
5305
5617
  lockKey: this._resourceLock?.lockKey
5306
5618
  }, {
5307
5619
  F: __dxlog_file18,
5308
- L: 225,
5620
+ L: 247,
5309
5621
  S: this,
5310
5622
  C: (f, a) => f(...a)
5311
5623
  });
5624
+ if (!this._level) {
5625
+ this._level = await createLevel(this._config.get("runtime.client.storage", {}));
5626
+ }
5627
+ await this._level.open();
5312
5628
  await this._resourceLock?.acquire();
5313
5629
  await this._loggingService.open();
5314
- this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
5630
+ this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
5631
+ this._queryService = new import_indexing2.QueryServiceImpl({
5632
+ indexer: this._serviceContext.indexer,
5633
+ automergeHost: this._serviceContext.automergeHost
5634
+ });
5635
+ await this._queryService.open(ctx);
5315
5636
  this._serviceRegistry.setServices({
5316
5637
  SystemService: this._systemService,
5317
5638
  IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
5318
- InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation), this._serviceContext.metadataStore),
5639
+ InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
5319
5640
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
5320
5641
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
5321
5642
  await this._serviceContext.initialized.wait();
5322
5643
  return this._serviceContext.dataSpaceManager;
5323
5644
  }),
5324
- DataService: new import_echo_pipeline3.DataServiceImpl(this._serviceContext.automergeHost),
5325
- IndexService: new import_indexing2.IndexServiceImpl({
5326
- indexer: this._serviceContext.indexer,
5327
- automergeHost: this._serviceContext.automergeHost
5328
- }),
5645
+ DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
5646
+ QueryService: this._queryService,
5329
5647
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
5330
5648
  LoggingService: this._loggingService,
5331
5649
  TracingService: this._tracingService,
@@ -5337,24 +5655,6 @@ var ClientServicesHost = class {
5337
5655
  })
5338
5656
  });
5339
5657
  await this._serviceContext.open(ctx);
5340
- (0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
5341
- F: __dxlog_file18,
5342
- L: 286,
5343
- S: this,
5344
- A: [
5345
- "this.serviceRegistry.services.InvitationsService",
5346
- ""
5347
- ]
5348
- });
5349
- const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
5350
- (0, import_log14.log)("loaded persistent invitations", {
5351
- count: loadedInvitations.invitations?.length
5352
- }, {
5353
- F: __dxlog_file18,
5354
- L: 289,
5355
- S: this,
5356
- C: (f, a) => f(...a)
5357
- });
5358
5658
  const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
5359
5659
  if (devtoolsProxy) {
5360
5660
  this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
@@ -5365,23 +5665,24 @@ var ClientServicesHost = class {
5365
5665
  });
5366
5666
  void this._devtoolsProxy.open();
5367
5667
  }
5668
+ this.diagnosticsBroadcastHandler.start();
5368
5669
  this._opening = false;
5369
5670
  this._open = true;
5370
5671
  this._statusUpdate.emit();
5371
5672
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
5372
- (0, import_log14.log)("opened", {
5673
+ (0, import_log13.log)("opened", {
5373
5674
  deviceKey
5374
5675
  }, {
5375
5676
  F: __dxlog_file18,
5376
- L: 306,
5677
+ L: 330,
5377
5678
  S: this,
5378
5679
  C: (f, a) => f(...a)
5379
5680
  });
5380
- import_log14.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
5681
+ import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.end({
5381
5682
  id: traceId
5382
5683
  }), {
5383
5684
  F: __dxlog_file18,
5384
- L: 307,
5685
+ L: 331,
5385
5686
  S: this,
5386
5687
  C: (f, a) => f(...a)
5387
5688
  });
@@ -5391,60 +5692,63 @@ var ClientServicesHost = class {
5391
5692
  return;
5392
5693
  }
5393
5694
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
5394
- (0, import_log14.log)("closing...", {
5695
+ (0, import_log13.log)("closing...", {
5395
5696
  deviceKey
5396
5697
  }, {
5397
5698
  F: __dxlog_file18,
5398
- L: 318,
5699
+ L: 342,
5399
5700
  S: this,
5400
5701
  C: (f, a) => f(...a)
5401
5702
  });
5703
+ this.diagnosticsBroadcastHandler.stop();
5402
5704
  await this._devtoolsProxy?.close();
5403
5705
  this._serviceRegistry.setServices({
5404
5706
  SystemService: this._systemService
5405
5707
  });
5406
5708
  await this._loggingService.close();
5709
+ await this._queryService.close();
5407
5710
  await this._serviceContext.close();
5711
+ await this._level?.close();
5408
5712
  this._open = false;
5409
5713
  this._statusUpdate.emit();
5410
- (0, import_log14.log)("closed", {
5714
+ (0, import_log13.log)("closed", {
5411
5715
  deviceKey
5412
5716
  }, {
5413
5717
  F: __dxlog_file18,
5414
- L: 325,
5718
+ L: 352,
5415
5719
  S: this,
5416
5720
  C: (f, a) => f(...a)
5417
5721
  });
5418
5722
  }
5419
5723
  async reset() {
5420
- const traceId = import_keys11.PublicKey.random().toHex();
5421
- import_log14.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
5724
+ const traceId = import_keys12.PublicKey.random().toHex();
5725
+ import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
5422
5726
  id: traceId
5423
5727
  }), {
5424
5728
  F: __dxlog_file18,
5425
- L: 330,
5729
+ L: 357,
5426
5730
  S: this,
5427
5731
  C: (f, a) => f(...a)
5428
5732
  });
5429
- (0, import_log14.log)("resetting...", void 0, {
5733
+ (0, import_log13.log)("resetting...", void 0, {
5430
5734
  F: __dxlog_file18,
5431
- L: 332,
5735
+ L: 359,
5432
5736
  S: this,
5433
5737
  C: (f, a) => f(...a)
5434
5738
  });
5435
5739
  await this._serviceContext?.close();
5436
5740
  await this._storage.reset();
5437
- (0, import_log14.log)("reset", void 0, {
5741
+ (0, import_log13.log)("reset", void 0, {
5438
5742
  F: __dxlog_file18,
5439
- L: 335,
5743
+ L: 362,
5440
5744
  S: this,
5441
5745
  C: (f, a) => f(...a)
5442
5746
  });
5443
- import_log14.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
5747
+ import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.end({
5444
5748
  id: traceId
5445
5749
  }), {
5446
5750
  F: __dxlog_file18,
5447
- L: 336,
5751
+ L: 363,
5448
5752
  S: this,
5449
5753
  C: (f, a) => f(...a)
5450
5754
  });
@@ -5454,12 +5758,10 @@ var ClientServicesHost = class {
5454
5758
  const identity = await this._serviceContext.createIdentity(params);
5455
5759
  await this._serviceContext.initialized.wait();
5456
5760
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5457
- const obj = new import_client_protocol5.Properties(void 0);
5458
- obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
5459
5761
  const automergeIndex = space.automergeSpaceState.rootUrl;
5460
- (0, import_invariant16.invariant)(automergeIndex, void 0, {
5762
+ (0, import_invariant15.invariant)(automergeIndex, void 0, {
5461
5763
  F: __dxlog_file18,
5462
- L: 351,
5764
+ L: 375,
5463
5765
  S: this,
5464
5766
  A: [
5465
5767
  "automergeIndex",
@@ -5468,45 +5770,93 @@ var ClientServicesHost = class {
5468
5770
  });
5469
5771
  const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5470
5772
  await document.whenReady();
5773
+ const properties = {
5774
+ system: {
5775
+ type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.Properties))
5776
+ },
5777
+ data: {
5778
+ [import_client_protocol5.defaultKey]: identity.identityKey.toHex()
5779
+ },
5780
+ meta: {
5781
+ keys: []
5782
+ }
5783
+ };
5784
+ const propertiesId = import_keys12.PublicKey.random().toHex();
5471
5785
  document.change((doc) => {
5472
5786
  (0, import_util9.assignDeep)(doc, [
5473
5787
  "objects",
5474
- (0, import_echo_schema.getAutomergeObjectCore)(obj).id
5475
- ], (0, import_echo_schema.getRawDoc)(obj).handle.docSync());
5788
+ propertiesId
5789
+ ], properties);
5476
5790
  });
5791
+ await this._serviceContext.automergeHost.repo.flush();
5477
5792
  return identity;
5478
5793
  }
5479
5794
  };
5480
5795
  _ts_decorate8([
5481
- import_tracing7.trace.info()
5796
+ import_tracing8.trace.info()
5482
5797
  ], ClientServicesHost.prototype, "_opening", void 0);
5483
5798
  _ts_decorate8([
5484
- import_tracing7.trace.info()
5799
+ import_tracing8.trace.info()
5485
5800
  ], ClientServicesHost.prototype, "_open", void 0);
5486
5801
  _ts_decorate8([
5487
5802
  import_async16.synchronized,
5488
- import_tracing7.trace.span()
5803
+ import_tracing8.trace.span()
5489
5804
  ], ClientServicesHost.prototype, "open", null);
5490
5805
  _ts_decorate8([
5491
5806
  import_async16.synchronized,
5492
- import_tracing7.trace.span()
5807
+ import_tracing8.trace.span()
5493
5808
  ], ClientServicesHost.prototype, "close", null);
5494
5809
  ClientServicesHost = _ts_decorate8([
5495
- import_tracing7.trace.resource()
5810
+ import_tracing8.trace.resource()
5496
5811
  ], ClientServicesHost);
5812
+ var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
5813
+ var DiagnosticsCollector = class {
5814
+ static {
5815
+ this.broadcastSender = createCollectDiagnosticsBroadcastSender();
5816
+ }
5817
+ static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
5818
+ const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
5819
+ keys: options.humanize ? import_services14.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services14.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
5820
+ });
5821
+ const clientDiagnostics = {
5822
+ config,
5823
+ trace: import_tracing7.TRACE_PROCESSOR.getDiagnostics()
5824
+ };
5825
+ const diagnostics = serviceDiagnostics != null ? {
5826
+ client: clientDiagnostics,
5827
+ services: serviceDiagnostics
5828
+ } : {
5829
+ client: clientDiagnostics,
5830
+ broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
5831
+ };
5832
+ return JSON.parse(JSON.stringify(diagnostics, (0, import_util8.jsonKeyReplacer)(options)));
5833
+ }
5834
+ };
5835
+ var findSystemServiceProvider = () => {
5836
+ const serviceProviders = import_tracing7.TRACE_PROCESSOR.findByAnnotation(ClientServicesProviderResource);
5837
+ const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
5838
+ return providerResource?.instance?.deref() ?? null;
5839
+ };
5840
+ var findConfigs = () => {
5841
+ const configs = import_tracing7.TRACE_PROCESSOR.findByAnnotation(import_config.ConfigResource);
5842
+ return configs.map((r) => r.instance.deref()).filter(import_util8.nonNullable);
5843
+ };
5497
5844
  // Annotate the CommonJS export names for ESM import in node:
5498
5845
  0 && (module.exports = {
5499
5846
  ClientRpcServer,
5500
5847
  ClientServicesHost,
5848
+ ClientServicesProviderResource,
5501
5849
  DataSpace,
5502
5850
  DataSpaceManager,
5503
5851
  DeviceInvitationProtocol,
5504
5852
  DevtoolsHostEvents,
5505
5853
  DevtoolsServiceImpl,
5854
+ DiagnosticsCollector,
5506
5855
  Identity,
5507
5856
  IdentityManager,
5508
5857
  IdentityServiceImpl,
5509
5858
  InvitationsHandler,
5859
+ InvitationsManager,
5510
5860
  InvitationsServiceImpl,
5511
5861
  Lock,
5512
5862
  ServiceContext,
@@ -5514,11 +5864,14 @@ ClientServicesHost = _ts_decorate8([
5514
5864
  SpaceInvitationProtocol,
5515
5865
  SpacesServiceImpl,
5516
5866
  TrustedKeySetAuthVerifier,
5867
+ createAdmissionKeypair,
5517
5868
  createAuthProvider,
5869
+ createCollectDiagnosticsBroadcastHandler,
5870
+ createCollectDiagnosticsBroadcastSender,
5518
5871
  createDiagnostics,
5872
+ createLevel,
5519
5873
  createStorageObjects,
5520
5874
  getNetworkPeers,
5521
- invitationExpired,
5522
5875
  isLocked,
5523
5876
  subscribeToFeedBlocks,
5524
5877
  subscribeToFeeds,
@@ -5528,4 +5881,4 @@ ClientServicesHost = _ts_decorate8([
5528
5881
  subscribeToSpaces,
5529
5882
  subscribeToSwarmInfo
5530
5883
  });
5531
- //# sourceMappingURL=chunk-4TX623I7.cjs.map
5884
+ //# sourceMappingURL=chunk-YXZQQAQN.cjs.map