@dxos/client-services 0.4.9 → 0.4.10-main.06ef97a
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.
- package/dist/lib/browser/{chunk-RQ33OGAG.mjs → chunk-XCFXYSCO.mjs} +788 -531
- package/dist/lib/browser/chunk-XCFXYSCO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +58 -20
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +6 -4
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-CBSM4HU4.cjs → chunk-ENGA4MHO.cjs} +726 -556
- package/dist/lib/node/chunk-ENGA4MHO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +95 -57
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +10 -8
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts +15 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -0
- package/dist/types/src/packlets/{services → diagnostics}/diagnostics.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts +4 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -0
- package/dist/types/src/packlets/indexing/util.d.ts +2 -2
- package/dist/types/src/packlets/indexing/util.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +1 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +7 -5
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +2 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +1 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/index.d.ts +1 -0
- package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.d.ts +4 -0
- package/dist/types/src/packlets/storage/level.d.ts.map +1 -0
- package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/util.d.ts +4 -0
- package/dist/types/src/packlets/storage/util.d.ts.map +1 -0
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shared-worker-connection.d.ts +5 -5
- package/dist/types/src/packlets/vault/shared-worker-connection.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts +2 -0
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts +2 -0
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +36 -34
- package/src/index.ts +1 -0
- package/src/packlets/devices/devices-service.test.ts +1 -1
- package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +94 -0
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +20 -0
- package/src/packlets/diagnostics/diagnostics-collector.ts +65 -0
- package/src/packlets/{services → diagnostics}/diagnostics.ts +2 -2
- package/src/packlets/diagnostics/index.ts +7 -0
- package/src/packlets/identity/identity-service.test.ts +1 -1
- package/src/packlets/indexing/util.ts +4 -4
- package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
- package/src/packlets/network/network-service.test.ts +1 -1
- package/src/packlets/services/index.ts +1 -1
- package/src/packlets/services/service-context.test.ts +5 -5
- package/src/packlets/services/service-context.ts +13 -8
- package/src/packlets/services/service-host.ts +41 -9
- package/src/packlets/services/service-registry.test.ts +1 -1
- package/src/packlets/services/util.ts +2 -0
- package/src/packlets/spaces/data-space.ts +51 -2
- package/src/packlets/spaces/spaces-service.test.ts +1 -1
- package/src/packlets/storage/index.ts +1 -0
- package/src/packlets/storage/level.ts +19 -0
- package/src/packlets/storage/storage.ts +3 -9
- package/src/packlets/storage/util.ts +19 -0
- package/src/packlets/system/system-service.ts +1 -1
- package/src/packlets/testing/test-builder.ts +5 -3
- package/src/packlets/vault/shared-worker-connection.ts +3 -8
- package/src/packlets/vault/worker-runtime.ts +27 -2
- package/src/packlets/vault/worker-session.ts +6 -0
- package/src/version.ts +1 -5
- package/dist/lib/browser/chunk-RQ33OGAG.mjs.map +0 -7
- package/dist/lib/node/chunk-CBSM4HU4.cjs.map +0 -7
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +0 -1
|
@@ -26,15 +26,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_ENGA4MHO_exports = {};
|
|
30
|
+
__export(chunk_ENGA4MHO_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,
|
|
@@ -47,7 +49,10 @@ __export(chunk_CBSM4HU4_exports, {
|
|
|
47
49
|
SpacesServiceImpl: () => SpacesServiceImpl,
|
|
48
50
|
TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
|
|
49
51
|
createAuthProvider: () => createAuthProvider,
|
|
52
|
+
createCollectDiagnosticsBroadcastHandler: () => createCollectDiagnosticsBroadcastHandler,
|
|
53
|
+
createCollectDiagnosticsBroadcastSender: () => createCollectDiagnosticsBroadcastSender,
|
|
50
54
|
createDiagnostics: () => createDiagnostics,
|
|
55
|
+
createLevel: () => createLevel,
|
|
51
56
|
createStorageObjects: () => createStorageObjects,
|
|
52
57
|
getNetworkPeers: () => getNetworkPeers,
|
|
53
58
|
invitationExpired: () => invitationExpired,
|
|
@@ -60,7 +65,7 @@ __export(chunk_CBSM4HU4_exports, {
|
|
|
60
65
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
61
66
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
62
67
|
});
|
|
63
|
-
module.exports = __toCommonJS(
|
|
68
|
+
module.exports = __toCommonJS(chunk_ENGA4MHO_exports);
|
|
64
69
|
var import_async = require("@dxos/async");
|
|
65
70
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
66
71
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -147,115 +152,127 @@ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
|
147
152
|
var import_debug2 = require("@dxos/debug");
|
|
148
153
|
var import_rpc = require("@dxos/rpc");
|
|
149
154
|
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
155
|
var import_async10 = require("@dxos/async");
|
|
158
156
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
159
157
|
var import_context7 = require("@dxos/context");
|
|
160
158
|
var import_debug3 = require("@dxos/debug");
|
|
159
|
+
var import_echo_db = require("@dxos/echo-db");
|
|
161
160
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
162
|
-
var
|
|
161
|
+
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
162
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
163
163
|
var import_keys7 = require("@dxos/keys");
|
|
164
164
|
var import_log8 = require("@dxos/log");
|
|
165
|
-
var
|
|
166
|
-
var
|
|
167
|
-
var
|
|
165
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
166
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
167
|
+
var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
168
168
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
169
|
-
var
|
|
169
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
170
170
|
var import_util4 = require("@dxos/util");
|
|
171
171
|
var import_async11 = require("@dxos/async");
|
|
172
|
-
var
|
|
172
|
+
var import_credentials10 = require("@dxos/credentials");
|
|
173
173
|
var import_async12 = require("@dxos/async");
|
|
174
174
|
var import_context8 = require("@dxos/context");
|
|
175
|
-
var
|
|
175
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
176
176
|
var import_keys8 = require("@dxos/keys");
|
|
177
177
|
var import_log9 = require("@dxos/log");
|
|
178
|
-
var
|
|
178
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
179
179
|
var import_teleport2 = require("@dxos/teleport");
|
|
180
180
|
var import_util5 = require("@dxos/util");
|
|
181
181
|
var import_async13 = require("@dxos/async");
|
|
182
182
|
var import_context9 = require("@dxos/context");
|
|
183
|
-
var
|
|
184
|
-
var
|
|
183
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
184
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
185
185
|
var import_keys9 = require("@dxos/keys");
|
|
186
186
|
var import_log10 = require("@dxos/log");
|
|
187
|
-
var
|
|
188
|
-
var
|
|
187
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
188
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
189
189
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
190
190
|
var import_util6 = require("@dxos/util");
|
|
191
|
-
var
|
|
191
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
192
192
|
var import_debug4 = require("@dxos/debug");
|
|
193
|
-
var
|
|
193
|
+
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
194
194
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
195
195
|
var import_async14 = require("@dxos/async");
|
|
196
|
-
var
|
|
196
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
197
197
|
var import_debug5 = require("@dxos/debug");
|
|
198
|
-
var
|
|
198
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
199
199
|
var import_log11 = require("@dxos/log");
|
|
200
|
-
var
|
|
201
|
-
var
|
|
200
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
201
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
202
202
|
var import_async15 = require("@dxos/async");
|
|
203
203
|
var import_context10 = require("@dxos/context");
|
|
204
|
-
var
|
|
204
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
205
205
|
var import_debug6 = require("@dxos/debug");
|
|
206
|
-
var
|
|
206
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
207
207
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
208
208
|
var import_indexing = require("@dxos/indexing");
|
|
209
|
-
var
|
|
209
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
210
210
|
var import_keyring = require("@dxos/keyring");
|
|
211
211
|
var import_keys10 = require("@dxos/keys");
|
|
212
212
|
var import_log12 = require("@dxos/log");
|
|
213
|
-
var
|
|
214
|
-
var
|
|
213
|
+
var import_protocols11 = require("@dxos/protocols");
|
|
214
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
215
215
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
216
|
-
var
|
|
216
|
+
var import_tracing5 = require("@dxos/tracing");
|
|
217
217
|
var import_util7 = require("@dxos/util");
|
|
218
218
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
219
219
|
var import_debug7 = require("@dxos/debug");
|
|
220
|
+
var import_protocols12 = require("@dxos/protocols");
|
|
221
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
222
|
+
var import_credentials15 = require("@dxos/credentials");
|
|
223
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
220
224
|
var import_protocols13 = require("@dxos/protocols");
|
|
221
|
-
var
|
|
222
|
-
var
|
|
223
|
-
var
|
|
224
|
-
var
|
|
225
|
-
var
|
|
226
|
-
var
|
|
227
|
-
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
225
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
226
|
+
var import_tracing6 = require("@dxos/tracing");
|
|
227
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
228
|
+
var import_config = require("@dxos/config");
|
|
229
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
230
|
+
var import_tracing7 = require("@dxos/tracing");
|
|
228
231
|
var import_util8 = require("@dxos/util");
|
|
229
232
|
var import_async16 = require("@dxos/async");
|
|
230
|
-
var
|
|
233
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
231
234
|
var import_context11 = require("@dxos/context");
|
|
232
|
-
var
|
|
233
|
-
var
|
|
235
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
236
|
+
var E = __toESM(require("@dxos/echo-schema"));
|
|
234
237
|
var import_indexing2 = require("@dxos/indexing");
|
|
235
|
-
var
|
|
238
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
236
239
|
var import_keys11 = require("@dxos/keys");
|
|
237
|
-
var
|
|
240
|
+
var import_log13 = require("@dxos/log");
|
|
238
241
|
var import_messaging = require("@dxos/messaging");
|
|
239
242
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
240
|
-
var
|
|
241
|
-
var
|
|
242
|
-
var
|
|
243
|
+
var import_protocols14 = require("@dxos/protocols");
|
|
244
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
245
|
+
var import_tracing8 = require("@dxos/tracing");
|
|
243
246
|
var import_util9 = require("@dxos/util");
|
|
244
247
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
245
248
|
var import_async17 = require("@dxos/async");
|
|
246
249
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
250
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
251
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
247
252
|
var import_invariant17 = require("@dxos/invariant");
|
|
248
|
-
var
|
|
253
|
+
var import_lock_file = require("@dxos/lock-file");
|
|
254
|
+
var import_log14 = require("@dxos/log");
|
|
249
255
|
var import_async18 = require("@dxos/async");
|
|
250
256
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
251
257
|
var import_keys12 = require("@dxos/keys");
|
|
252
258
|
var import_log15 = require("@dxos/log");
|
|
253
|
-
var
|
|
259
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
254
260
|
var import_util10 = require("@dxos/util");
|
|
255
261
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
256
|
-
var
|
|
257
|
-
var
|
|
262
|
+
var import_protocols15 = require("@dxos/protocols");
|
|
263
|
+
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
264
|
+
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
265
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
266
|
+
var import_config3 = require("@dxos/protocols/proto/dxos/config");
|
|
258
267
|
var import_util11 = require("@dxos/util");
|
|
268
|
+
var import_level = require("level");
|
|
269
|
+
var import_node_path = __toESM(require("node:path"));
|
|
270
|
+
var import_keys13 = require("@dxos/keys");
|
|
271
|
+
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
272
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
273
|
+
var import_util12 = require("@dxos/util");
|
|
274
|
+
var import_keys14 = require("@dxos/keys");
|
|
275
|
+
var import_util13 = require("@dxos/util");
|
|
259
276
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
260
277
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
261
278
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -2857,141 +2874,6 @@ _ts_decorate3([
|
|
|
2857
2874
|
ClientRpcServer = _ts_decorate3([
|
|
2858
2875
|
import_tracing3.trace.resource()
|
|
2859
2876
|
], 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.9";
|
|
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
|
|
2987
|
-
}
|
|
2988
|
-
};
|
|
2989
|
-
if (stats.metrics) {
|
|
2990
|
-
const { open, ready } = stats.metrics;
|
|
2991
|
-
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
2992
|
-
}
|
|
2993
|
-
return stats;
|
|
2994
|
-
};
|
|
2995
2877
|
var AutomergeSpaceState = class {
|
|
2996
2878
|
constructor(_onNewRoot) {
|
|
2997
2879
|
this._onNewRoot = _onNewRoot;
|
|
@@ -3001,7 +2883,7 @@ var AutomergeSpaceState = class {
|
|
|
3001
2883
|
this._isProcessingRootDocs = false;
|
|
3002
2884
|
}
|
|
3003
2885
|
async processCredential(credential) {
|
|
3004
|
-
if (!(0,
|
|
2886
|
+
if (!(0, import_credentials10.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
3005
2887
|
return;
|
|
3006
2888
|
}
|
|
3007
2889
|
this.lastEpoch = credential;
|
|
@@ -3026,7 +2908,7 @@ var AutomergeSpaceState = class {
|
|
|
3026
2908
|
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3027
2909
|
}
|
|
3028
2910
|
};
|
|
3029
|
-
var
|
|
2911
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3030
2912
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3031
2913
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3032
2914
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -3054,13 +2936,13 @@ var NotarizationPlugin = class {
|
|
|
3054
2936
|
(0, import_log9.log)("notarize", {
|
|
3055
2937
|
credentials
|
|
3056
2938
|
}, {
|
|
3057
|
-
F:
|
|
2939
|
+
F: __dxlog_file10,
|
|
3058
2940
|
L: 90,
|
|
3059
2941
|
S: this,
|
|
3060
2942
|
C: (f, a) => f(...a)
|
|
3061
2943
|
});
|
|
3062
|
-
(0,
|
|
3063
|
-
F:
|
|
2944
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2945
|
+
F: __dxlog_file10,
|
|
3064
2946
|
L: 91,
|
|
3065
2947
|
S: this,
|
|
3066
2948
|
A: [
|
|
@@ -3074,7 +2956,7 @@ var NotarizationPlugin = class {
|
|
|
3074
2956
|
import_log9.log.warn("Notarization error", {
|
|
3075
2957
|
err
|
|
3076
2958
|
}, {
|
|
3077
|
-
F:
|
|
2959
|
+
F: __dxlog_file10,
|
|
3078
2960
|
L: 99,
|
|
3079
2961
|
S: this,
|
|
3080
2962
|
C: (f, a) => f(...a)
|
|
@@ -3090,7 +2972,7 @@ var NotarizationPlugin = class {
|
|
|
3090
2972
|
timeout,
|
|
3091
2973
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3092
2974
|
}, {
|
|
3093
|
-
F:
|
|
2975
|
+
F: __dxlog_file10,
|
|
3094
2976
|
L: 111,
|
|
3095
2977
|
S: this,
|
|
3096
2978
|
C: (f, a) => f(...a)
|
|
@@ -3113,7 +2995,7 @@ var NotarizationPlugin = class {
|
|
|
3113
2995
|
import_log9.log.info("Exhausted all peers to notarize with", {
|
|
3114
2996
|
retryIn: retryTimeout
|
|
3115
2997
|
}, {
|
|
3116
|
-
F:
|
|
2998
|
+
F: __dxlog_file10,
|
|
3117
2999
|
L: 136,
|
|
3118
3000
|
S: this,
|
|
3119
3001
|
C: (f, a) => f(...a)
|
|
@@ -3127,7 +3009,7 @@ var NotarizationPlugin = class {
|
|
|
3127
3009
|
peer: peer.localPeerId,
|
|
3128
3010
|
credentialId: credentials.map((credential) => credential.id)
|
|
3129
3011
|
}, {
|
|
3130
|
-
F:
|
|
3012
|
+
F: __dxlog_file10,
|
|
3131
3013
|
L: 143,
|
|
3132
3014
|
S: this,
|
|
3133
3015
|
C: (f, a) => f(...a)
|
|
@@ -3136,7 +3018,7 @@ var NotarizationPlugin = class {
|
|
|
3136
3018
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3137
3019
|
});
|
|
3138
3020
|
(0, import_log9.log)("success", void 0, {
|
|
3139
|
-
F:
|
|
3021
|
+
F: __dxlog_file10,
|
|
3140
3022
|
L: 147,
|
|
3141
3023
|
S: this,
|
|
3142
3024
|
C: (f, a) => f(...a)
|
|
@@ -3145,7 +3027,7 @@ var NotarizationPlugin = class {
|
|
|
3145
3027
|
} catch (err) {
|
|
3146
3028
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3147
3029
|
import_log9.log.info("error notarizing (recoverable)", err, {
|
|
3148
|
-
F:
|
|
3030
|
+
F: __dxlog_file10,
|
|
3149
3031
|
L: 151,
|
|
3150
3032
|
S: this,
|
|
3151
3033
|
C: (f, a) => f(...a)
|
|
@@ -3163,7 +3045,7 @@ var NotarizationPlugin = class {
|
|
|
3163
3045
|
errors.wait()
|
|
3164
3046
|
]);
|
|
3165
3047
|
(0, import_log9.log)("done", void 0, {
|
|
3166
|
-
F:
|
|
3048
|
+
F: __dxlog_file10,
|
|
3167
3049
|
L: 162,
|
|
3168
3050
|
S: this,
|
|
3169
3051
|
C: (f, a) => f(...a)
|
|
@@ -3184,8 +3066,8 @@ var NotarizationPlugin = class {
|
|
|
3184
3066
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3185
3067
|
}
|
|
3186
3068
|
setWriter(writer) {
|
|
3187
|
-
(0,
|
|
3188
|
-
F:
|
|
3069
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
3070
|
+
F: __dxlog_file10,
|
|
3189
3071
|
L: 181,
|
|
3190
3072
|
S: this,
|
|
3191
3073
|
A: [
|
|
@@ -3209,8 +3091,8 @@ var NotarizationPlugin = class {
|
|
|
3209
3091
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3210
3092
|
}
|
|
3211
3093
|
for (const credential of request.credentials ?? []) {
|
|
3212
|
-
(0,
|
|
3213
|
-
F:
|
|
3094
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
3095
|
+
F: __dxlog_file10,
|
|
3214
3096
|
L: 200,
|
|
3215
3097
|
S: this,
|
|
3216
3098
|
A: [
|
|
@@ -3230,7 +3112,7 @@ var NotarizationPlugin = class {
|
|
|
3230
3112
|
(0, import_log9.log)("extension opened", {
|
|
3231
3113
|
peer: extension.localPeerId
|
|
3232
3114
|
}, {
|
|
3233
|
-
F:
|
|
3115
|
+
F: __dxlog_file10,
|
|
3234
3116
|
L: 211,
|
|
3235
3117
|
S: this,
|
|
3236
3118
|
C: (f, a) => f(...a)
|
|
@@ -3242,7 +3124,7 @@ var NotarizationPlugin = class {
|
|
|
3242
3124
|
(0, import_log9.log)("extension closed", {
|
|
3243
3125
|
peer: extension.localPeerId
|
|
3244
3126
|
}, {
|
|
3245
|
-
F:
|
|
3127
|
+
F: __dxlog_file10,
|
|
3246
3128
|
L: 216,
|
|
3247
3129
|
S: this,
|
|
3248
3130
|
C: (f, a) => f(...a)
|
|
@@ -3258,10 +3140,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
3258
3140
|
constructor(_params) {
|
|
3259
3141
|
super({
|
|
3260
3142
|
requested: {
|
|
3261
|
-
NotarizationService:
|
|
3143
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3262
3144
|
},
|
|
3263
3145
|
exposed: {
|
|
3264
|
-
NotarizationService:
|
|
3146
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3265
3147
|
}
|
|
3266
3148
|
});
|
|
3267
3149
|
this._params = _params;
|
|
@@ -3294,14 +3176,14 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3294
3176
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3295
3177
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3296
3178
|
}
|
|
3297
|
-
var
|
|
3179
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3298
3180
|
var DataSpace = class {
|
|
3299
3181
|
constructor(params) {
|
|
3300
3182
|
this._ctx = new import_context7.Context();
|
|
3301
3183
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3302
3184
|
this._cache = void 0;
|
|
3303
3185
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3304
|
-
this._state =
|
|
3186
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
3305
3187
|
this.error = void 0;
|
|
3306
3188
|
this.stateUpdate = new import_async10.Event();
|
|
3307
3189
|
this.metrics = {};
|
|
@@ -3323,10 +3205,10 @@ var DataSpace = class {
|
|
|
3323
3205
|
this._cache = params.cache;
|
|
3324
3206
|
this._state = params.initialState;
|
|
3325
3207
|
(0, import_log8.log)("new state", {
|
|
3326
|
-
state:
|
|
3208
|
+
state: import_services7.SpaceState[this._state]
|
|
3327
3209
|
}, {
|
|
3328
|
-
F:
|
|
3329
|
-
L:
|
|
3210
|
+
F: __dxlog_file11,
|
|
3211
|
+
L: 140,
|
|
3330
3212
|
S: this,
|
|
3331
3213
|
C: (f, a) => f(...a)
|
|
3332
3214
|
});
|
|
@@ -3371,12 +3253,12 @@ var DataSpace = class {
|
|
|
3371
3253
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3372
3254
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3373
3255
|
await this._inner.open(new import_context7.Context());
|
|
3374
|
-
this._state =
|
|
3256
|
+
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
3375
3257
|
(0, import_log8.log)("new state", {
|
|
3376
|
-
state:
|
|
3258
|
+
state: import_services7.SpaceState[this._state]
|
|
3377
3259
|
}, {
|
|
3378
|
-
F:
|
|
3379
|
-
L:
|
|
3260
|
+
F: __dxlog_file11,
|
|
3261
|
+
L: 198,
|
|
3380
3262
|
S: this,
|
|
3381
3263
|
C: (f, a) => f(...a)
|
|
3382
3264
|
});
|
|
@@ -3389,12 +3271,12 @@ var DataSpace = class {
|
|
|
3389
3271
|
}
|
|
3390
3272
|
async _close() {
|
|
3391
3273
|
await this._callbacks.beforeClose?.();
|
|
3392
|
-
this._state =
|
|
3274
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
3393
3275
|
(0, import_log8.log)("new state", {
|
|
3394
|
-
state:
|
|
3276
|
+
state: import_services7.SpaceState[this._state]
|
|
3395
3277
|
}, {
|
|
3396
|
-
F:
|
|
3397
|
-
L:
|
|
3278
|
+
F: __dxlog_file11,
|
|
3279
|
+
L: 212,
|
|
3398
3280
|
S: this,
|
|
3399
3281
|
C: (f, a) => f(...a)
|
|
3400
3282
|
});
|
|
@@ -3423,27 +3305,27 @@ var DataSpace = class {
|
|
|
3423
3305
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3424
3306
|
await this.initializeDataPipeline();
|
|
3425
3307
|
} catch (err) {
|
|
3426
|
-
if (err instanceof
|
|
3308
|
+
if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
|
|
3427
3309
|
(0, import_log8.log)("data pipeline initialization cancelled", err, {
|
|
3428
|
-
F:
|
|
3429
|
-
L:
|
|
3310
|
+
F: __dxlog_file11,
|
|
3311
|
+
L: 245,
|
|
3430
3312
|
S: this,
|
|
3431
3313
|
C: (f, a) => f(...a)
|
|
3432
3314
|
});
|
|
3433
3315
|
return;
|
|
3434
3316
|
}
|
|
3435
3317
|
import_log8.log.error("Error initializing data pipeline", err, {
|
|
3436
|
-
F:
|
|
3437
|
-
L:
|
|
3318
|
+
F: __dxlog_file11,
|
|
3319
|
+
L: 249,
|
|
3438
3320
|
S: this,
|
|
3439
3321
|
C: (f, a) => f(...a)
|
|
3440
3322
|
});
|
|
3441
|
-
this._state =
|
|
3323
|
+
this._state = import_services7.SpaceState.ERROR;
|
|
3442
3324
|
(0, import_log8.log)("new state", {
|
|
3443
|
-
state:
|
|
3325
|
+
state: import_services7.SpaceState[this._state]
|
|
3444
3326
|
}, {
|
|
3445
|
-
F:
|
|
3446
|
-
L:
|
|
3327
|
+
F: __dxlog_file11,
|
|
3328
|
+
L: 251,
|
|
3447
3329
|
S: this,
|
|
3448
3330
|
C: (f, a) => f(...a)
|
|
3449
3331
|
});
|
|
@@ -3455,15 +3337,15 @@ var DataSpace = class {
|
|
|
3455
3337
|
});
|
|
3456
3338
|
}
|
|
3457
3339
|
async initializeDataPipeline() {
|
|
3458
|
-
if (this._state !==
|
|
3459
|
-
throw new
|
|
3340
|
+
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
3341
|
+
throw new import_protocols7.SystemError("Invalid operation");
|
|
3460
3342
|
}
|
|
3461
|
-
this._state =
|
|
3343
|
+
this._state = import_services7.SpaceState.INITIALIZING;
|
|
3462
3344
|
(0, import_log8.log)("new state", {
|
|
3463
|
-
state:
|
|
3345
|
+
state: import_services7.SpaceState[this._state]
|
|
3464
3346
|
}, {
|
|
3465
|
-
F:
|
|
3466
|
-
L:
|
|
3347
|
+
F: __dxlog_file11,
|
|
3348
|
+
L: 267,
|
|
3467
3349
|
S: this,
|
|
3468
3350
|
C: (f, a) => f(...a)
|
|
3469
3351
|
});
|
|
@@ -3472,18 +3354,18 @@ var DataSpace = class {
|
|
|
3472
3354
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3473
3355
|
await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3474
3356
|
(0, import_log8.log)("data pipeline ready", void 0, {
|
|
3475
|
-
F:
|
|
3476
|
-
L:
|
|
3357
|
+
F: __dxlog_file11,
|
|
3358
|
+
L: 279,
|
|
3477
3359
|
S: this,
|
|
3478
3360
|
C: (f, a) => f(...a)
|
|
3479
3361
|
});
|
|
3480
3362
|
await this._callbacks.beforeReady?.();
|
|
3481
|
-
this._state =
|
|
3363
|
+
this._state = import_services7.SpaceState.READY;
|
|
3482
3364
|
(0, import_log8.log)("new state", {
|
|
3483
|
-
state:
|
|
3365
|
+
state: import_services7.SpaceState[this._state]
|
|
3484
3366
|
}, {
|
|
3485
|
-
F:
|
|
3486
|
-
L:
|
|
3367
|
+
F: __dxlog_file11,
|
|
3368
|
+
L: 283,
|
|
3487
3369
|
S: this,
|
|
3488
3370
|
C: (f, a) => f(...a)
|
|
3489
3371
|
});
|
|
@@ -3498,8 +3380,8 @@ var DataSpace = class {
|
|
|
3498
3380
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3499
3381
|
await this._createWritableFeeds();
|
|
3500
3382
|
(0, import_log8.log)("writable feeds created", void 0, {
|
|
3501
|
-
F:
|
|
3502
|
-
L:
|
|
3383
|
+
F: __dxlog_file11,
|
|
3384
|
+
L: 299,
|
|
3503
3385
|
S: this,
|
|
3504
3386
|
C: (f, a) => f(...a)
|
|
3505
3387
|
});
|
|
@@ -3526,7 +3408,7 @@ var DataSpace = class {
|
|
|
3526
3408
|
spaceKey: this.key,
|
|
3527
3409
|
deviceKey: this._signingContext.deviceKey,
|
|
3528
3410
|
identityKey: this._signingContext.identityKey,
|
|
3529
|
-
designation:
|
|
3411
|
+
designation: import_credentials9.AdmittedFeed.Designation.CONTROL
|
|
3530
3412
|
}
|
|
3531
3413
|
}));
|
|
3532
3414
|
}
|
|
@@ -3543,7 +3425,7 @@ var DataSpace = class {
|
|
|
3543
3425
|
spaceKey: this.key,
|
|
3544
3426
|
deviceKey: this._signingContext.deviceKey,
|
|
3545
3427
|
identityKey: this._signingContext.identityKey,
|
|
3546
|
-
designation:
|
|
3428
|
+
designation: import_credentials9.AdmittedFeed.Designation.DATA
|
|
3547
3429
|
}
|
|
3548
3430
|
}));
|
|
3549
3431
|
}
|
|
@@ -3561,8 +3443,8 @@ var DataSpace = class {
|
|
|
3561
3443
|
space: this.key,
|
|
3562
3444
|
rootUrl
|
|
3563
3445
|
}, {
|
|
3564
|
-
F:
|
|
3565
|
-
L:
|
|
3446
|
+
F: __dxlog_file11,
|
|
3447
|
+
L: 365,
|
|
3566
3448
|
S: this,
|
|
3567
3449
|
C: (f, a) => f(...a)
|
|
3568
3450
|
});
|
|
@@ -3576,7 +3458,7 @@ var DataSpace = class {
|
|
|
3576
3458
|
if (this._ctx.disposed) {
|
|
3577
3459
|
return;
|
|
3578
3460
|
}
|
|
3579
|
-
const doc = handle.docSync() ?? (0,
|
|
3461
|
+
const doc = handle.docSync() ?? (0, import_invariant9.failedInvariant)();
|
|
3580
3462
|
if (!doc.access?.spaceKey) {
|
|
3581
3463
|
handle.change((doc2) => {
|
|
3582
3464
|
doc2.access = {
|
|
@@ -3593,8 +3475,8 @@ var DataSpace = class {
|
|
|
3593
3475
|
rootUrl,
|
|
3594
3476
|
err
|
|
3595
3477
|
}, {
|
|
3596
|
-
F:
|
|
3597
|
-
L:
|
|
3478
|
+
F: __dxlog_file11,
|
|
3479
|
+
L: 388,
|
|
3598
3480
|
S: this,
|
|
3599
3481
|
C: (f, a) => f(...a)
|
|
3600
3482
|
});
|
|
@@ -3620,7 +3502,7 @@ var DataSpace = class {
|
|
|
3620
3502
|
let epoch;
|
|
3621
3503
|
switch (options?.migration) {
|
|
3622
3504
|
case void 0:
|
|
3623
|
-
case
|
|
3505
|
+
case import_services7.CreateEpochRequest.Migration.NONE:
|
|
3624
3506
|
{
|
|
3625
3507
|
epoch = {
|
|
3626
3508
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3630,7 +3512,7 @@ var DataSpace = class {
|
|
|
3630
3512
|
};
|
|
3631
3513
|
}
|
|
3632
3514
|
break;
|
|
3633
|
-
case
|
|
3515
|
+
case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3634
3516
|
{
|
|
3635
3517
|
const document = this._automergeHost.repo.create();
|
|
3636
3518
|
epoch = {
|
|
@@ -3641,15 +3523,15 @@ var DataSpace = class {
|
|
|
3641
3523
|
};
|
|
3642
3524
|
}
|
|
3643
3525
|
break;
|
|
3644
|
-
case
|
|
3526
|
+
case import_services7.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3645
3527
|
{
|
|
3646
3528
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3647
3529
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3648
3530
|
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3649
3531
|
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3650
|
-
(0,
|
|
3651
|
-
F:
|
|
3652
|
-
L:
|
|
3532
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3533
|
+
F: __dxlog_file11,
|
|
3534
|
+
L: 438,
|
|
3653
3535
|
S: this,
|
|
3654
3536
|
A: [
|
|
3655
3537
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -3664,12 +3546,72 @@ var DataSpace = class {
|
|
|
3664
3546
|
};
|
|
3665
3547
|
}
|
|
3666
3548
|
break;
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3549
|
+
case import_services7.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3550
|
+
{
|
|
3551
|
+
import_log8.log.info("Fragmenting", void 0, {
|
|
3552
|
+
F: __dxlog_file11,
|
|
3553
|
+
L: 450,
|
|
3554
|
+
S: this,
|
|
3555
|
+
C: (f, a) => f(...a)
|
|
3556
|
+
});
|
|
3557
|
+
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3558
|
+
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3559
|
+
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3560
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3561
|
+
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_db.TYPE_PROPERTIES);
|
|
3562
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3563
|
+
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3564
|
+
F: __dxlog_file11,
|
|
3565
|
+
L: 460,
|
|
3566
|
+
S: this,
|
|
3567
|
+
A: [
|
|
3568
|
+
"properties",
|
|
3569
|
+
"'Properties not found'"
|
|
3570
|
+
]
|
|
3571
|
+
});
|
|
3572
|
+
const newSpaceDoc = {
|
|
3573
|
+
...rootHandle.docSync(),
|
|
3574
|
+
objects: Object.fromEntries([
|
|
3575
|
+
properties
|
|
3576
|
+
])
|
|
3577
|
+
};
|
|
3578
|
+
const newRoot = this._automergeHost.repo.create(newSpaceDoc);
|
|
3579
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3580
|
+
F: __dxlog_file11,
|
|
3581
|
+
L: 465,
|
|
3582
|
+
S: this,
|
|
3583
|
+
A: [
|
|
3584
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3585
|
+
""
|
|
3586
|
+
]
|
|
3587
|
+
});
|
|
3588
|
+
const docLoader = new import_echo_pipeline2.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
|
|
3589
|
+
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3590
|
+
rootUrl: newRoot.url
|
|
3591
|
+
});
|
|
3592
|
+
otherObjects.forEach(([key, value]) => {
|
|
3593
|
+
const handle = docLoader.createDocumentForObject(key);
|
|
3594
|
+
handle.change((doc) => {
|
|
3595
|
+
(0, import_util4.assignDeep)(doc, [
|
|
3596
|
+
"objects",
|
|
3597
|
+
key
|
|
3598
|
+
], value);
|
|
3599
|
+
});
|
|
3600
|
+
});
|
|
3601
|
+
epoch = {
|
|
3602
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3603
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
3604
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
|
|
3605
|
+
automergeRoot: newRoot.url
|
|
3606
|
+
};
|
|
3607
|
+
}
|
|
3608
|
+
break;
|
|
3609
|
+
}
|
|
3610
|
+
if (!epoch) {
|
|
3611
|
+
return;
|
|
3612
|
+
}
|
|
3613
|
+
const receipt = await this.inner.controlPipeline.writer.write({
|
|
3614
|
+
credential: {
|
|
3673
3615
|
credential: await this._signingContext.credentialSigner.createCredential({
|
|
3674
3616
|
subject: this.key,
|
|
3675
3617
|
assertion: {
|
|
@@ -3687,25 +3629,25 @@ var DataSpace = class {
|
|
|
3687
3629
|
]));
|
|
3688
3630
|
}
|
|
3689
3631
|
async activate() {
|
|
3690
|
-
if (this._state !==
|
|
3632
|
+
if (this._state !== import_services7.SpaceState.INACTIVE) {
|
|
3691
3633
|
return;
|
|
3692
3634
|
}
|
|
3693
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3635
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
|
|
3694
3636
|
await this._open();
|
|
3695
3637
|
this.initializeDataPipelineAsync();
|
|
3696
3638
|
}
|
|
3697
3639
|
async deactivate() {
|
|
3698
|
-
if (this._state ===
|
|
3640
|
+
if (this._state === import_services7.SpaceState.INACTIVE) {
|
|
3699
3641
|
return;
|
|
3700
3642
|
}
|
|
3701
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3643
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
|
|
3702
3644
|
await this._close();
|
|
3703
|
-
this._state =
|
|
3645
|
+
this._state = import_services7.SpaceState.INACTIVE;
|
|
3704
3646
|
(0, import_log8.log)("new state", {
|
|
3705
|
-
state:
|
|
3647
|
+
state: import_services7.SpaceState[this._state]
|
|
3706
3648
|
}, {
|
|
3707
|
-
F:
|
|
3708
|
-
L:
|
|
3649
|
+
F: __dxlog_file11,
|
|
3650
|
+
L: 531,
|
|
3709
3651
|
S: this,
|
|
3710
3652
|
C: (f, a) => f(...a)
|
|
3711
3653
|
});
|
|
@@ -3713,18 +3655,18 @@ var DataSpace = class {
|
|
|
3713
3655
|
}
|
|
3714
3656
|
};
|
|
3715
3657
|
_ts_decorate4([
|
|
3716
|
-
|
|
3658
|
+
import_tracing4.trace.info()
|
|
3717
3659
|
], DataSpace.prototype, "_inner", void 0);
|
|
3718
3660
|
_ts_decorate4([
|
|
3719
|
-
|
|
3661
|
+
import_tracing4.trace.info()
|
|
3720
3662
|
], DataSpace.prototype, "key", null);
|
|
3721
3663
|
_ts_decorate4([
|
|
3722
|
-
|
|
3723
|
-
enum:
|
|
3664
|
+
import_tracing4.trace.info({
|
|
3665
|
+
enum: import_services7.SpaceState
|
|
3724
3666
|
})
|
|
3725
3667
|
], DataSpace.prototype, "state", null);
|
|
3726
3668
|
_ts_decorate4([
|
|
3727
|
-
|
|
3669
|
+
import_tracing4.trace.info({
|
|
3728
3670
|
depth: null
|
|
3729
3671
|
})
|
|
3730
3672
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
@@ -3735,12 +3677,12 @@ _ts_decorate4([
|
|
|
3735
3677
|
import_async10.synchronized
|
|
3736
3678
|
], DataSpace.prototype, "close", null);
|
|
3737
3679
|
_ts_decorate4([
|
|
3738
|
-
|
|
3680
|
+
import_tracing4.trace.span({
|
|
3739
3681
|
showInBrowserTimeline: true
|
|
3740
3682
|
})
|
|
3741
3683
|
], DataSpace.prototype, "initializeDataPipeline", null);
|
|
3742
3684
|
_ts_decorate4([
|
|
3743
|
-
|
|
3685
|
+
import_tracing4.trace.span({
|
|
3744
3686
|
showInBrowserTimeline: true
|
|
3745
3687
|
})
|
|
3746
3688
|
], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
|
|
@@ -3755,11 +3697,11 @@ _ts_decorate4([
|
|
|
3755
3697
|
], DataSpace.prototype, "deactivate", null);
|
|
3756
3698
|
DataSpace = _ts_decorate4([
|
|
3757
3699
|
(0, import_async10.trackLeaks)("open", "close"),
|
|
3758
|
-
|
|
3700
|
+
import_tracing4.trace.resource()
|
|
3759
3701
|
], DataSpace);
|
|
3760
3702
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3761
3703
|
const credentials = [
|
|
3762
|
-
await (0,
|
|
3704
|
+
await (0, import_credentials12.createCredential)({
|
|
3763
3705
|
signer: keyring,
|
|
3764
3706
|
issuer: space.key,
|
|
3765
3707
|
subject: space.key,
|
|
@@ -3768,14 +3710,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3768
3710
|
spaceKey: space.key
|
|
3769
3711
|
}
|
|
3770
3712
|
}),
|
|
3771
|
-
await (0,
|
|
3713
|
+
await (0, import_credentials12.createCredential)({
|
|
3772
3714
|
signer: keyring,
|
|
3773
3715
|
issuer: space.key,
|
|
3774
3716
|
subject: signingContext.identityKey,
|
|
3775
3717
|
assertion: {
|
|
3776
3718
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3777
3719
|
spaceKey: space.key,
|
|
3778
|
-
role:
|
|
3720
|
+
role: import_credentials13.SpaceMember.Role.ADMIN,
|
|
3779
3721
|
profile: signingContext.getProfile(),
|
|
3780
3722
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
3781
3723
|
}
|
|
@@ -3787,7 +3729,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3787
3729
|
spaceKey: space.key,
|
|
3788
3730
|
identityKey: signingContext.identityKey,
|
|
3789
3731
|
deviceKey: signingContext.deviceKey,
|
|
3790
|
-
designation:
|
|
3732
|
+
designation: import_credentials13.AdmittedFeed.Designation.CONTROL
|
|
3791
3733
|
}
|
|
3792
3734
|
}),
|
|
3793
3735
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3797,7 +3739,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3797
3739
|
spaceKey: space.key,
|
|
3798
3740
|
identityKey: signingContext.identityKey,
|
|
3799
3741
|
deviceKey: signingContext.deviceKey,
|
|
3800
|
-
designation:
|
|
3742
|
+
designation: import_credentials13.AdmittedFeed.Designation.DATA
|
|
3801
3743
|
}
|
|
3802
3744
|
}),
|
|
3803
3745
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3831,7 +3773,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3831
3773
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3832
3774
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3833
3775
|
}
|
|
3834
|
-
var
|
|
3776
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3835
3777
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3836
3778
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3837
3779
|
var DataSpaceManager = class {
|
|
@@ -3857,15 +3799,15 @@ var DataSpaceManager = class {
|
|
|
3857
3799
|
}
|
|
3858
3800
|
async open() {
|
|
3859
3801
|
(0, import_log10.log)("open", void 0, {
|
|
3860
|
-
F:
|
|
3802
|
+
F: __dxlog_file12,
|
|
3861
3803
|
L: 98,
|
|
3862
3804
|
S: this,
|
|
3863
3805
|
C: (f, a) => f(...a)
|
|
3864
3806
|
});
|
|
3865
|
-
import_log10.log.trace("dxos.echo.data-space-manager.open",
|
|
3807
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.begin({
|
|
3866
3808
|
id: this._instanceId
|
|
3867
3809
|
}), {
|
|
3868
|
-
F:
|
|
3810
|
+
F: __dxlog_file12,
|
|
3869
3811
|
L: 99,
|
|
3870
3812
|
S: this,
|
|
3871
3813
|
C: (f, a) => f(...a)
|
|
@@ -3873,7 +3815,7 @@ var DataSpaceManager = class {
|
|
|
3873
3815
|
(0, import_log10.log)("metadata loaded", {
|
|
3874
3816
|
spaces: this._metadataStore.spaces.length
|
|
3875
3817
|
}, {
|
|
3876
|
-
F:
|
|
3818
|
+
F: __dxlog_file12,
|
|
3877
3819
|
L: 100,
|
|
3878
3820
|
S: this,
|
|
3879
3821
|
C: (f, a) => f(...a)
|
|
@@ -3883,7 +3825,7 @@ var DataSpaceManager = class {
|
|
|
3883
3825
|
(0, import_log10.log)("load space", {
|
|
3884
3826
|
spaceMetadata
|
|
3885
3827
|
}, {
|
|
3886
|
-
F:
|
|
3828
|
+
F: __dxlog_file12,
|
|
3887
3829
|
L: 104,
|
|
3888
3830
|
S: this,
|
|
3889
3831
|
C: (f, a) => f(...a)
|
|
@@ -3894,7 +3836,7 @@ var DataSpaceManager = class {
|
|
|
3894
3836
|
spaceMetadata,
|
|
3895
3837
|
err
|
|
3896
3838
|
}, {
|
|
3897
|
-
F:
|
|
3839
|
+
F: __dxlog_file12,
|
|
3898
3840
|
L: 107,
|
|
3899
3841
|
S: this,
|
|
3900
3842
|
C: (f, a) => f(...a)
|
|
@@ -3904,14 +3846,14 @@ var DataSpaceManager = class {
|
|
|
3904
3846
|
this._isOpen = true;
|
|
3905
3847
|
this.updated.emit();
|
|
3906
3848
|
for (const space of this._spaces.values()) {
|
|
3907
|
-
if (space.state !==
|
|
3849
|
+
if (space.state !== import_services8.SpaceState.INACTIVE) {
|
|
3908
3850
|
space.initializeDataPipelineAsync();
|
|
3909
3851
|
}
|
|
3910
3852
|
}
|
|
3911
|
-
import_log10.log.trace("dxos.echo.data-space-manager.open",
|
|
3853
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.end({
|
|
3912
3854
|
id: this._instanceId
|
|
3913
3855
|
}), {
|
|
3914
|
-
F:
|
|
3856
|
+
F: __dxlog_file12,
|
|
3915
3857
|
L: 120,
|
|
3916
3858
|
S: this,
|
|
3917
3859
|
C: (f, a) => f(...a)
|
|
@@ -3919,7 +3861,7 @@ var DataSpaceManager = class {
|
|
|
3919
3861
|
}
|
|
3920
3862
|
async close() {
|
|
3921
3863
|
(0, import_log10.log)("close", void 0, {
|
|
3922
|
-
F:
|
|
3864
|
+
F: __dxlog_file12,
|
|
3923
3865
|
L: 125,
|
|
3924
3866
|
S: this,
|
|
3925
3867
|
C: (f, a) => f(...a)
|
|
@@ -3934,8 +3876,8 @@ var DataSpaceManager = class {
|
|
|
3934
3876
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3935
3877
|
*/
|
|
3936
3878
|
async createSpace() {
|
|
3937
|
-
(0,
|
|
3938
|
-
F:
|
|
3879
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3880
|
+
F: __dxlog_file12,
|
|
3939
3881
|
L: 138,
|
|
3940
3882
|
S: this,
|
|
3941
3883
|
A: [
|
|
@@ -3951,12 +3893,12 @@ var DataSpaceManager = class {
|
|
|
3951
3893
|
genesisFeedKey: controlFeedKey,
|
|
3952
3894
|
controlFeedKey,
|
|
3953
3895
|
dataFeedKey,
|
|
3954
|
-
state:
|
|
3896
|
+
state: import_services8.SpaceState.ACTIVE
|
|
3955
3897
|
};
|
|
3956
3898
|
(0, import_log10.log)("creating space...", {
|
|
3957
3899
|
spaceKey
|
|
3958
3900
|
}, {
|
|
3959
|
-
F:
|
|
3901
|
+
F: __dxlog_file12,
|
|
3960
3902
|
L: 150,
|
|
3961
3903
|
S: this,
|
|
3962
3904
|
C: (f, a) => f(...a)
|
|
@@ -3971,8 +3913,8 @@ var DataSpaceManager = class {
|
|
|
3971
3913
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3972
3914
|
await this._metadataStore.addSpace(metadata);
|
|
3973
3915
|
const memberCredential = credentials[1];
|
|
3974
|
-
(0,
|
|
3975
|
-
F:
|
|
3916
|
+
(0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3917
|
+
F: __dxlog_file12,
|
|
3976
3918
|
L: 163,
|
|
3977
3919
|
S: this,
|
|
3978
3920
|
A: [
|
|
@@ -3990,13 +3932,13 @@ var DataSpaceManager = class {
|
|
|
3990
3932
|
(0, import_log10.log)("accept space", {
|
|
3991
3933
|
opts
|
|
3992
3934
|
}, {
|
|
3993
|
-
F:
|
|
3935
|
+
F: __dxlog_file12,
|
|
3994
3936
|
L: 175,
|
|
3995
3937
|
S: this,
|
|
3996
3938
|
C: (f, a) => f(...a)
|
|
3997
3939
|
});
|
|
3998
|
-
(0,
|
|
3999
|
-
F:
|
|
3940
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3941
|
+
F: __dxlog_file12,
|
|
4000
3942
|
L: 176,
|
|
4001
3943
|
S: this,
|
|
4002
3944
|
A: [
|
|
@@ -4004,8 +3946,8 @@ var DataSpaceManager = class {
|
|
|
4004
3946
|
"'Not open.'"
|
|
4005
3947
|
]
|
|
4006
3948
|
});
|
|
4007
|
-
(0,
|
|
4008
|
-
F:
|
|
3949
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3950
|
+
F: __dxlog_file12,
|
|
4009
3951
|
L: 177,
|
|
4010
3952
|
S: this,
|
|
4011
3953
|
A: [
|
|
@@ -4033,14 +3975,14 @@ var DataSpaceManager = class {
|
|
|
4033
3975
|
async waitUntilSpaceReady(spaceKey) {
|
|
4034
3976
|
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4035
3977
|
const space = this._spaces.get(spaceKey);
|
|
4036
|
-
return !!space && space.state ===
|
|
3978
|
+
return !!space && space.state === import_services8.SpaceState.READY;
|
|
4037
3979
|
}));
|
|
4038
3980
|
}
|
|
4039
3981
|
async _constructSpace(metadata) {
|
|
4040
3982
|
(0, import_log10.log)("construct space", {
|
|
4041
3983
|
metadata
|
|
4042
3984
|
}, {
|
|
4043
|
-
F:
|
|
3985
|
+
F: __dxlog_file12,
|
|
4044
3986
|
L: 210,
|
|
4045
3987
|
S: this,
|
|
4046
3988
|
C: (f, a) => f(...a)
|
|
@@ -4078,7 +4020,7 @@ var DataSpaceManager = class {
|
|
|
4078
4020
|
},
|
|
4079
4021
|
onAuthFailure: () => {
|
|
4080
4022
|
import_log10.log.warn("auth failure", void 0, {
|
|
4081
|
-
F:
|
|
4023
|
+
F: __dxlog_file12,
|
|
4082
4024
|
L: 247,
|
|
4083
4025
|
S: this,
|
|
4084
4026
|
C: (f, a) => f(...a)
|
|
@@ -4090,7 +4032,7 @@ var DataSpaceManager = class {
|
|
|
4090
4032
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4091
4033
|
const dataSpace = new DataSpace({
|
|
4092
4034
|
inner: space,
|
|
4093
|
-
initialState: metadata.state ===
|
|
4035
|
+
initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
|
|
4094
4036
|
metadataStore: this._metadataStore,
|
|
4095
4037
|
gossip,
|
|
4096
4038
|
presence,
|
|
@@ -4102,7 +4044,7 @@ var DataSpaceManager = class {
|
|
|
4102
4044
|
(0, import_log10.log)("before space ready", {
|
|
4103
4045
|
space: space.key
|
|
4104
4046
|
}, {
|
|
4105
|
-
F:
|
|
4047
|
+
F: __dxlog_file12,
|
|
4106
4048
|
L: 265,
|
|
4107
4049
|
S: this,
|
|
4108
4050
|
C: (f, a) => f(...a)
|
|
@@ -4113,7 +4055,7 @@ var DataSpaceManager = class {
|
|
|
4113
4055
|
space: space.key,
|
|
4114
4056
|
open: this._isOpen
|
|
4115
4057
|
}, {
|
|
4116
|
-
F:
|
|
4058
|
+
F: __dxlog_file12,
|
|
4117
4059
|
L: 268,
|
|
4118
4060
|
S: this,
|
|
4119
4061
|
C: (f, a) => f(...a)
|
|
@@ -4126,7 +4068,7 @@ var DataSpaceManager = class {
|
|
|
4126
4068
|
(0, import_log10.log)("before space close", {
|
|
4127
4069
|
space: space.key
|
|
4128
4070
|
}, {
|
|
4129
|
-
F:
|
|
4071
|
+
F: __dxlog_file12,
|
|
4130
4072
|
L: 274,
|
|
4131
4073
|
S: this,
|
|
4132
4074
|
C: (f, a) => f(...a)
|
|
@@ -4136,7 +4078,7 @@ var DataSpaceManager = class {
|
|
|
4136
4078
|
cache: metadata.cache,
|
|
4137
4079
|
automergeHost: this._automergeHost
|
|
4138
4080
|
});
|
|
4139
|
-
if (metadata.state !==
|
|
4081
|
+
if (metadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
4140
4082
|
await dataSpace.open();
|
|
4141
4083
|
}
|
|
4142
4084
|
if (metadata.controlTimeframe) {
|
|
@@ -4161,7 +4103,7 @@ _ts_decorate5([
|
|
|
4161
4103
|
DataSpaceManager = _ts_decorate5([
|
|
4162
4104
|
(0, import_async13.trackLeaks)("open", "close")
|
|
4163
4105
|
], DataSpaceManager);
|
|
4164
|
-
var
|
|
4106
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4165
4107
|
var SpacesServiceImpl = class {
|
|
4166
4108
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4167
4109
|
this._identityManager = _identityManager;
|
|
@@ -4178,29 +4120,29 @@ var SpacesServiceImpl = class {
|
|
|
4178
4120
|
}
|
|
4179
4121
|
async updateSpace({ spaceKey, state }) {
|
|
4180
4122
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4181
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4123
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4182
4124
|
if (state) {
|
|
4183
4125
|
switch (state) {
|
|
4184
|
-
case
|
|
4126
|
+
case import_services9.SpaceState.ACTIVE:
|
|
4185
4127
|
await space.activate();
|
|
4186
4128
|
break;
|
|
4187
|
-
case
|
|
4129
|
+
case import_services9.SpaceState.INACTIVE:
|
|
4188
4130
|
await space.deactivate();
|
|
4189
4131
|
break;
|
|
4190
4132
|
default:
|
|
4191
|
-
throw new
|
|
4133
|
+
throw new import_protocols10.ApiError("Invalid space state");
|
|
4192
4134
|
}
|
|
4193
4135
|
}
|
|
4194
4136
|
}
|
|
4195
4137
|
querySpaces() {
|
|
4196
|
-
return new
|
|
4138
|
+
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
4197
4139
|
const scheduler = new import_async14.UpdateScheduler(ctx, async () => {
|
|
4198
4140
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4199
4141
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
4200
4142
|
(0, import_log11.log)("update", {
|
|
4201
4143
|
spaces
|
|
4202
4144
|
}, {
|
|
4203
|
-
F:
|
|
4145
|
+
F: __dxlog_file13,
|
|
4204
4146
|
L: 77,
|
|
4205
4147
|
S: this,
|
|
4206
4148
|
C: (f, a) => f(...a)
|
|
@@ -4240,14 +4182,14 @@ var SpacesServiceImpl = class {
|
|
|
4240
4182
|
}
|
|
4241
4183
|
async postMessage({ spaceKey, channel, message }) {
|
|
4242
4184
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4243
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4185
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4244
4186
|
await space.postMessage(getChannelId(channel), message);
|
|
4245
4187
|
}
|
|
4246
4188
|
subscribeMessages({ spaceKey, channel }) {
|
|
4247
|
-
return new
|
|
4189
|
+
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
4248
4190
|
(0, import_async14.scheduleTask)(ctx, async () => {
|
|
4249
4191
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4250
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4192
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4251
4193
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
4252
4194
|
next(message);
|
|
4253
4195
|
});
|
|
@@ -4256,8 +4198,8 @@ var SpacesServiceImpl = class {
|
|
|
4256
4198
|
});
|
|
4257
4199
|
}
|
|
4258
4200
|
queryCredentials({ spaceKey, noTail }) {
|
|
4259
|
-
return new
|
|
4260
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4201
|
+
return new import_codec_protobuf10.Stream(({ ctx, next, close }) => {
|
|
4202
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4261
4203
|
const processor = {
|
|
4262
4204
|
processCredential: async (credential) => {
|
|
4263
4205
|
next(credential);
|
|
@@ -4273,7 +4215,7 @@ var SpacesServiceImpl = class {
|
|
|
4273
4215
|
});
|
|
4274
4216
|
}
|
|
4275
4217
|
async writeCredentials({ spaceKey, credentials }) {
|
|
4276
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4218
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4277
4219
|
for (const credential of credentials ?? []) {
|
|
4278
4220
|
if (credential.proof) {
|
|
4279
4221
|
await space.controlPipeline.writer.write({
|
|
@@ -4282,8 +4224,8 @@ var SpacesServiceImpl = class {
|
|
|
4282
4224
|
}
|
|
4283
4225
|
});
|
|
4284
4226
|
} else {
|
|
4285
|
-
(0,
|
|
4286
|
-
F:
|
|
4227
|
+
(0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4228
|
+
F: __dxlog_file13,
|
|
4287
4229
|
L: 164,
|
|
4288
4230
|
S: this,
|
|
4289
4231
|
A: [
|
|
@@ -4291,8 +4233,8 @@ var SpacesServiceImpl = class {
|
|
|
4291
4233
|
"'Id on unsigned credentials is not allowed'"
|
|
4292
4234
|
]
|
|
4293
4235
|
});
|
|
4294
|
-
(0,
|
|
4295
|
-
F:
|
|
4236
|
+
(0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
4237
|
+
F: __dxlog_file13,
|
|
4296
4238
|
L: 165,
|
|
4297
4239
|
S: this,
|
|
4298
4240
|
A: [
|
|
@@ -4301,8 +4243,8 @@ var SpacesServiceImpl = class {
|
|
|
4301
4243
|
]
|
|
4302
4244
|
});
|
|
4303
4245
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4304
|
-
(0,
|
|
4305
|
-
F:
|
|
4246
|
+
(0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4247
|
+
F: __dxlog_file13,
|
|
4306
4248
|
L: 167,
|
|
4307
4249
|
S: this,
|
|
4308
4250
|
A: [
|
|
@@ -4324,7 +4266,7 @@ var SpacesServiceImpl = class {
|
|
|
4324
4266
|
}
|
|
4325
4267
|
async createEpoch({ spaceKey, migration }) {
|
|
4326
4268
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4327
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4269
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4328
4270
|
await space.createEpoch({
|
|
4329
4271
|
migration
|
|
4330
4272
|
});
|
|
@@ -4333,7 +4275,7 @@ var SpacesServiceImpl = class {
|
|
|
4333
4275
|
return {
|
|
4334
4276
|
spaceKey: space.key,
|
|
4335
4277
|
state: space.state,
|
|
4336
|
-
error: space.error ? (0,
|
|
4278
|
+
error: space.error ? (0, import_protocols10.encodeError)(space.error) : void 0,
|
|
4337
4279
|
pipeline: {
|
|
4338
4280
|
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4339
4281
|
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
@@ -4358,7 +4300,7 @@ var SpacesServiceImpl = class {
|
|
|
4358
4300
|
identityKey: member.key,
|
|
4359
4301
|
profile: member.profile ?? {}
|
|
4360
4302
|
},
|
|
4361
|
-
presence: member.removed ?
|
|
4303
|
+
presence: member.removed ? import_services9.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
4362
4304
|
peerStates: peers
|
|
4363
4305
|
};
|
|
4364
4306
|
}),
|
|
@@ -4369,7 +4311,7 @@ var SpacesServiceImpl = class {
|
|
|
4369
4311
|
}
|
|
4370
4312
|
};
|
|
4371
4313
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
4372
|
-
var
|
|
4314
|
+
var createSelectedDocumentsIterator = (automergeHost) => (
|
|
4373
4315
|
/**
|
|
4374
4316
|
* Get object data blobs from Automerge Repo by ids.
|
|
4375
4317
|
* @param ids
|
|
@@ -4377,22 +4319,22 @@ var createLoadDocuments = (automergeHost) => (
|
|
|
4377
4319
|
// TODO(mykola): Unload automerge handles after usage.
|
|
4378
4320
|
async function* loadDocuments(ids) {
|
|
4379
4321
|
for (const id of ids) {
|
|
4380
|
-
const { documentId, objectId } =
|
|
4322
|
+
const { documentId, objectId } = import_protocols12.idCodec.decode(id);
|
|
4381
4323
|
const handle = automergeHost.repo.find(documentId);
|
|
4382
4324
|
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4383
4325
|
const doc = handle.docSync();
|
|
4384
4326
|
const hash = (0, import_automerge.getHeads)(doc).join("");
|
|
4385
|
-
yield [
|
|
4327
|
+
yield doc.objects?.[objectId] ? [
|
|
4386
4328
|
{
|
|
4387
4329
|
id,
|
|
4388
4330
|
object: doc.objects[objectId],
|
|
4389
4331
|
currentHash: hash
|
|
4390
4332
|
}
|
|
4391
|
-
];
|
|
4333
|
+
] : [];
|
|
4392
4334
|
}
|
|
4393
4335
|
}
|
|
4394
4336
|
);
|
|
4395
|
-
var
|
|
4337
|
+
var createDocumentsIterator = (automergeHost) => (
|
|
4396
4338
|
/**
|
|
4397
4339
|
* Recursively get all object data blobs from Automerge Repo.
|
|
4398
4340
|
* @param ids
|
|
@@ -4410,12 +4352,12 @@ var createGetAllDocuments = (automergeHost) => (
|
|
|
4410
4352
|
if (doc.objects) {
|
|
4411
4353
|
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4412
4354
|
return {
|
|
4413
|
-
id:
|
|
4355
|
+
id: import_protocols12.idCodec.encode({
|
|
4414
4356
|
documentId: handle.documentId,
|
|
4415
4357
|
objectId
|
|
4416
4358
|
}),
|
|
4417
4359
|
object,
|
|
4418
|
-
currentHash: heads.
|
|
4360
|
+
currentHash: heads.join("")
|
|
4419
4361
|
};
|
|
4420
4362
|
});
|
|
4421
4363
|
}
|
|
@@ -4453,18 +4395,20 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4453
4395
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4454
4396
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4455
4397
|
}
|
|
4456
|
-
var
|
|
4457
|
-
var ServiceContext = class {
|
|
4458
|
-
constructor(storage, networkManager, signalManager, _runtimeParams) {
|
|
4398
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4399
|
+
var ServiceContext = class extends import_context10.Resource {
|
|
4400
|
+
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4401
|
+
super();
|
|
4459
4402
|
this.storage = storage;
|
|
4403
|
+
this.level = level;
|
|
4460
4404
|
this.networkManager = networkManager;
|
|
4461
4405
|
this.signalManager = signalManager;
|
|
4462
4406
|
this._runtimeParams = _runtimeParams;
|
|
4463
4407
|
this.initialized = new import_async15.Trigger();
|
|
4464
4408
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4465
4409
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
4466
|
-
this.metadataStore = new
|
|
4467
|
-
this.snapshotStore = new
|
|
4410
|
+
this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
|
|
4411
|
+
this.snapshotStore = new import_echo_pipeline3.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4468
4412
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
4469
4413
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
4470
4414
|
this.feedStore = new import_feed_store4.FeedStore({
|
|
@@ -4472,12 +4416,12 @@ var ServiceContext = class {
|
|
|
4472
4416
|
root: storage.createDirectory("feeds"),
|
|
4473
4417
|
signer: this.keyring,
|
|
4474
4418
|
hypercore: {
|
|
4475
|
-
valueEncoding:
|
|
4419
|
+
valueEncoding: import_echo_pipeline3.valueEncoding,
|
|
4476
4420
|
stats: true
|
|
4477
4421
|
}
|
|
4478
4422
|
})
|
|
4479
4423
|
});
|
|
4480
|
-
this.spaceManager = new
|
|
4424
|
+
this.spaceManager = new import_echo_pipeline3.SpaceManager({
|
|
4481
4425
|
feedStore: this.feedStore,
|
|
4482
4426
|
networkManager: this.networkManager,
|
|
4483
4427
|
blobStore: this.blobStore,
|
|
@@ -4486,9 +4430,9 @@ var ServiceContext = class {
|
|
|
4486
4430
|
});
|
|
4487
4431
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4488
4432
|
this.indexMetadata = new import_indexing.IndexMetadataStore({
|
|
4489
|
-
|
|
4433
|
+
db: level.sublevel("index-metadata")
|
|
4490
4434
|
});
|
|
4491
|
-
this.automergeHost = new
|
|
4435
|
+
this.automergeHost = new import_echo_pipeline3.AutomergeHost({
|
|
4492
4436
|
directory: storage.createDirectory("automerge"),
|
|
4493
4437
|
metadata: this.indexMetadata
|
|
4494
4438
|
});
|
|
@@ -4497,25 +4441,25 @@ var ServiceContext = class {
|
|
|
4497
4441
|
directory: storage.createDirectory("index-store")
|
|
4498
4442
|
}),
|
|
4499
4443
|
metadataStore: this.indexMetadata,
|
|
4500
|
-
loadDocuments:
|
|
4501
|
-
getAllDocuments:
|
|
4444
|
+
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4445
|
+
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4502
4446
|
});
|
|
4503
4447
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4504
|
-
this._handlerFactories.set(
|
|
4448
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4505
4449
|
}
|
|
4506
|
-
async
|
|
4450
|
+
async _open(ctx) {
|
|
4507
4451
|
await this._checkStorageVersion();
|
|
4508
4452
|
(0, import_log12.log)("opening...", void 0, {
|
|
4509
|
-
F:
|
|
4510
|
-
L:
|
|
4453
|
+
F: __dxlog_file14,
|
|
4454
|
+
L: 156,
|
|
4511
4455
|
S: this,
|
|
4512
4456
|
C: (f, a) => f(...a)
|
|
4513
4457
|
});
|
|
4514
|
-
import_log12.log.trace("dxos.sdk.service-context.open",
|
|
4458
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.begin({
|
|
4515
4459
|
id: this._instanceId
|
|
4516
4460
|
}), {
|
|
4517
|
-
F:
|
|
4518
|
-
L:
|
|
4461
|
+
F: __dxlog_file14,
|
|
4462
|
+
L: 157,
|
|
4519
4463
|
S: this,
|
|
4520
4464
|
C: (f, a) => f(...a)
|
|
4521
4465
|
});
|
|
@@ -4527,25 +4471,25 @@ var ServiceContext = class {
|
|
|
4527
4471
|
if (this.identityManager.identity) {
|
|
4528
4472
|
await this._initialize(ctx);
|
|
4529
4473
|
}
|
|
4530
|
-
import_log12.log.trace("dxos.sdk.service-context.open",
|
|
4474
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
|
|
4531
4475
|
id: this._instanceId
|
|
4532
4476
|
}), {
|
|
4533
|
-
F:
|
|
4534
|
-
L:
|
|
4477
|
+
F: __dxlog_file14,
|
|
4478
|
+
L: 167,
|
|
4535
4479
|
S: this,
|
|
4536
4480
|
C: (f, a) => f(...a)
|
|
4537
4481
|
});
|
|
4538
4482
|
(0, import_log12.log)("opened", void 0, {
|
|
4539
|
-
F:
|
|
4540
|
-
L:
|
|
4483
|
+
F: __dxlog_file14,
|
|
4484
|
+
L: 168,
|
|
4541
4485
|
S: this,
|
|
4542
4486
|
C: (f, a) => f(...a)
|
|
4543
4487
|
});
|
|
4544
4488
|
}
|
|
4545
|
-
async
|
|
4489
|
+
async _close() {
|
|
4546
4490
|
(0, import_log12.log)("closing...", void 0, {
|
|
4547
|
-
F:
|
|
4548
|
-
L:
|
|
4491
|
+
F: __dxlog_file14,
|
|
4492
|
+
L: 172,
|
|
4549
4493
|
S: this,
|
|
4550
4494
|
C: (f, a) => f(...a)
|
|
4551
4495
|
});
|
|
@@ -4562,8 +4506,8 @@ var ServiceContext = class {
|
|
|
4562
4506
|
await this.metadataStore.close();
|
|
4563
4507
|
await this.indexer.destroy();
|
|
4564
4508
|
(0, import_log12.log)("closed", void 0, {
|
|
4565
|
-
F:
|
|
4566
|
-
L:
|
|
4509
|
+
F: __dxlog_file14,
|
|
4510
|
+
L: 185,
|
|
4567
4511
|
S: this,
|
|
4568
4512
|
C: (f, a) => f(...a)
|
|
4569
4513
|
});
|
|
@@ -4575,9 +4519,9 @@ var ServiceContext = class {
|
|
|
4575
4519
|
}
|
|
4576
4520
|
getInvitationHandler(invitation) {
|
|
4577
4521
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4578
|
-
(0,
|
|
4579
|
-
F:
|
|
4580
|
-
L:
|
|
4522
|
+
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4523
|
+
F: __dxlog_file14,
|
|
4524
|
+
L: 196,
|
|
4581
4525
|
S: this,
|
|
4582
4526
|
A: [
|
|
4583
4527
|
"factory",
|
|
@@ -4601,15 +4545,15 @@ var ServiceContext = class {
|
|
|
4601
4545
|
}
|
|
4602
4546
|
async _checkStorageVersion() {
|
|
4603
4547
|
await this.metadataStore.load();
|
|
4604
|
-
if (this.metadataStore.version !==
|
|
4605
|
-
throw new
|
|
4548
|
+
if (this.metadataStore.version !== import_protocols11.STORAGE_VERSION) {
|
|
4549
|
+
throw new import_protocols11.InvalidStorageVersionError(import_protocols11.STORAGE_VERSION, this.metadataStore.version);
|
|
4606
4550
|
}
|
|
4607
4551
|
}
|
|
4608
4552
|
// Called when identity is created.
|
|
4609
4553
|
async _initialize(ctx) {
|
|
4610
4554
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4611
|
-
F:
|
|
4612
|
-
L:
|
|
4555
|
+
F: __dxlog_file14,
|
|
4556
|
+
L: 227,
|
|
4613
4557
|
S: this,
|
|
4614
4558
|
C: (f, a) => f(...a)
|
|
4615
4559
|
});
|
|
@@ -4629,10 +4573,10 @@ var ServiceContext = class {
|
|
|
4629
4573
|
};
|
|
4630
4574
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4631
4575
|
await this.dataSpaceManager.open();
|
|
4632
|
-
this._handlerFactories.set(
|
|
4633
|
-
(0,
|
|
4634
|
-
F:
|
|
4635
|
-
L:
|
|
4576
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
4577
|
+
(0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4578
|
+
F: __dxlog_file14,
|
|
4579
|
+
L: 251,
|
|
4636
4580
|
S: this,
|
|
4637
4581
|
A: [
|
|
4638
4582
|
"this.dataSpaceManager",
|
|
@@ -4644,7 +4588,7 @@ var ServiceContext = class {
|
|
|
4644
4588
|
this.initialized.wake();
|
|
4645
4589
|
this._deviceSpaceSync = {
|
|
4646
4590
|
processCredential: async (credential) => {
|
|
4647
|
-
const assertion = (0,
|
|
4591
|
+
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
4648
4592
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
4649
4593
|
return;
|
|
4650
4594
|
}
|
|
@@ -4655,8 +4599,8 @@ var ServiceContext = class {
|
|
|
4655
4599
|
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4656
4600
|
details: assertion
|
|
4657
4601
|
}, {
|
|
4658
|
-
F:
|
|
4659
|
-
L:
|
|
4602
|
+
F: __dxlog_file14,
|
|
4603
|
+
L: 267,
|
|
4660
4604
|
S: this,
|
|
4661
4605
|
C: (f, a) => f(...a)
|
|
4662
4606
|
});
|
|
@@ -4666,8 +4610,8 @@ var ServiceContext = class {
|
|
|
4666
4610
|
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
4667
4611
|
details: assertion
|
|
4668
4612
|
}, {
|
|
4669
|
-
F:
|
|
4670
|
-
L:
|
|
4613
|
+
F: __dxlog_file14,
|
|
4614
|
+
L: 271,
|
|
4671
4615
|
S: this,
|
|
4672
4616
|
C: (f, a) => f(...a)
|
|
4673
4617
|
});
|
|
@@ -4677,8 +4621,8 @@ var ServiceContext = class {
|
|
|
4677
4621
|
(0, import_log12.log)("accepting space recorded in halo", {
|
|
4678
4622
|
details: assertion
|
|
4679
4623
|
}, {
|
|
4680
|
-
F:
|
|
4681
|
-
L:
|
|
4624
|
+
F: __dxlog_file14,
|
|
4625
|
+
L: 276,
|
|
4682
4626
|
S: this,
|
|
4683
4627
|
C: (f, a) => f(...a)
|
|
4684
4628
|
});
|
|
@@ -4688,8 +4632,8 @@ var ServiceContext = class {
|
|
|
4688
4632
|
});
|
|
4689
4633
|
} catch (err) {
|
|
4690
4634
|
import_log12.log.catch(err, void 0, {
|
|
4691
|
-
F:
|
|
4692
|
-
L:
|
|
4635
|
+
F: __dxlog_file14,
|
|
4636
|
+
L: 282,
|
|
4693
4637
|
S: this,
|
|
4694
4638
|
C: (f, a) => f(...a)
|
|
4695
4639
|
});
|
|
@@ -4700,14 +4644,14 @@ var ServiceContext = class {
|
|
|
4700
4644
|
}
|
|
4701
4645
|
};
|
|
4702
4646
|
_ts_decorate6([
|
|
4703
|
-
|
|
4704
|
-
], ServiceContext.prototype, "
|
|
4647
|
+
import_tracing5.trace.span()
|
|
4648
|
+
], ServiceContext.prototype, "_open", null);
|
|
4705
4649
|
_ts_decorate6([
|
|
4706
|
-
|
|
4650
|
+
import_tracing5.trace.span()
|
|
4707
4651
|
], ServiceContext.prototype, "_initialize", null);
|
|
4708
4652
|
ServiceContext = _ts_decorate6([
|
|
4709
4653
|
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
4710
|
-
|
|
4654
|
+
import_tracing5.trace.resource()
|
|
4711
4655
|
], ServiceContext);
|
|
4712
4656
|
var ServiceRegistry = class {
|
|
4713
4657
|
// prettier-ignore
|
|
@@ -4731,103 +4675,155 @@ var ServiceRegistry = class {
|
|
|
4731
4675
|
delete this._handlers[name];
|
|
4732
4676
|
}
|
|
4733
4677
|
};
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
if (
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
}
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
}
|
|
4751
|
-
|
|
4752
|
-
return
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
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
|
-
});
|
|
4678
|
+
var DXOS_VERSION = "0.4.10-main.06ef97a";
|
|
4679
|
+
var getPlatform = () => {
|
|
4680
|
+
if (process.browser) {
|
|
4681
|
+
if (typeof window !== "undefined") {
|
|
4682
|
+
const { userAgent } = window.navigator;
|
|
4683
|
+
return {
|
|
4684
|
+
type: import_services12.Platform.PLATFORM_TYPE.BROWSER,
|
|
4685
|
+
userAgent,
|
|
4686
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4687
|
+
};
|
|
4688
|
+
} else {
|
|
4689
|
+
return {
|
|
4690
|
+
type: import_services12.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4691
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4692
|
+
};
|
|
4693
|
+
}
|
|
4694
|
+
} else {
|
|
4695
|
+
const { platform: platform2, version, arch } = process;
|
|
4696
|
+
return {
|
|
4697
|
+
type: import_services12.Platform.PLATFORM_TYPE.NODE,
|
|
4698
|
+
platform: platform2,
|
|
4699
|
+
arch,
|
|
4700
|
+
runtime: version,
|
|
4701
|
+
uptime: Math.floor(process.uptime()),
|
|
4702
|
+
memory: process.memoryUsage()
|
|
4703
|
+
};
|
|
4769
4704
|
}
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4705
|
+
};
|
|
4706
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
|
|
4707
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
4708
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
4709
|
+
const diagnostics = {
|
|
4710
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4711
|
+
platform: getPlatform(),
|
|
4712
|
+
client: {
|
|
4713
|
+
version: DXOS_VERSION,
|
|
4714
|
+
storage: {
|
|
4715
|
+
version: import_protocols13.STORAGE_VERSION
|
|
4716
|
+
}
|
|
4717
|
+
},
|
|
4718
|
+
trace: import_tracing6.TRACE_PROCESSOR.getDiagnostics()
|
|
4719
|
+
};
|
|
4720
|
+
{
|
|
4721
|
+
(0, import_invariant14.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
4722
|
+
F: __dxlog_file15,
|
|
4723
|
+
L: 108,
|
|
4724
|
+
S: void 0,
|
|
4776
4725
|
A: [
|
|
4777
|
-
"
|
|
4778
|
-
"'
|
|
4726
|
+
"clientServices.LoggingService",
|
|
4727
|
+
"'SystemService is not available.'"
|
|
4779
4728
|
]
|
|
4780
4729
|
});
|
|
4781
|
-
await
|
|
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.");
|
|
4730
|
+
diagnostics.metrics = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
4731
|
+
timeout: DEFAULT_TIMEOUT
|
|
4732
|
+
}).catch(() => void 0);
|
|
4793
4733
|
}
|
|
4794
|
-
if (
|
|
4795
|
-
|
|
4734
|
+
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
4735
|
+
const map = /* @__PURE__ */ new Map();
|
|
4736
|
+
const dir = await navigator.storage.getDirectory();
|
|
4737
|
+
for await (const filename of dir?.keys()) {
|
|
4738
|
+
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
4739
|
+
if (idx === -1) {
|
|
4740
|
+
continue;
|
|
4741
|
+
}
|
|
4742
|
+
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
4743
|
+
}
|
|
4744
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
4745
|
+
file,
|
|
4746
|
+
count
|
|
4747
|
+
}));
|
|
4796
4748
|
}
|
|
4797
|
-
|
|
4798
|
-
|
|
4749
|
+
const identity = serviceContext.identityManager.identity;
|
|
4750
|
+
if (identity) {
|
|
4751
|
+
diagnostics.identity = {
|
|
4752
|
+
identityKey: identity.identityKey,
|
|
4753
|
+
spaceKey: identity.space.key,
|
|
4754
|
+
profile: identity.profileDocument
|
|
4755
|
+
};
|
|
4756
|
+
const { devices } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
4757
|
+
timeout: DEFAULT_TIMEOUT
|
|
4758
|
+
}).catch(() => void 0) ?? {};
|
|
4759
|
+
diagnostics.devices = devices;
|
|
4760
|
+
if (serviceContext.dataSpaceManager) {
|
|
4761
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
4762
|
+
}
|
|
4763
|
+
const { feeds = [] } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
4764
|
+
timeout: DEFAULT_TIMEOUT
|
|
4765
|
+
}).catch(() => void 0) ?? {};
|
|
4766
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
4767
|
+
feedKey,
|
|
4768
|
+
bytes,
|
|
4769
|
+
length
|
|
4770
|
+
}));
|
|
4771
|
+
const status = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
|
|
4772
|
+
timeout: DEFAULT_TIMEOUT
|
|
4773
|
+
}).catch(() => void 0);
|
|
4774
|
+
diagnostics.networkStatus = status;
|
|
4775
|
+
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
4799
4776
|
}
|
|
4800
|
-
|
|
4801
|
-
|
|
4777
|
+
diagnostics.config = config.values;
|
|
4778
|
+
return diagnostics;
|
|
4779
|
+
};
|
|
4780
|
+
var getSpaceStats = async (space) => {
|
|
4781
|
+
const stats = {
|
|
4782
|
+
key: space.key,
|
|
4783
|
+
metrics: space.metrics,
|
|
4784
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials15.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4785
|
+
...credential.subject.assertion,
|
|
4786
|
+
id: credential.id
|
|
4787
|
+
})),
|
|
4788
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
4789
|
+
identity: {
|
|
4790
|
+
identityKey: member.key,
|
|
4791
|
+
profile: {
|
|
4792
|
+
displayName: member.assertion.profile?.displayName
|
|
4793
|
+
}
|
|
4794
|
+
},
|
|
4795
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services11.SpaceMember.PresenceState.ONLINE : import_services11.SpaceMember.PresenceState.OFFLINE
|
|
4796
|
+
})),
|
|
4797
|
+
pipeline: {
|
|
4798
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
4799
|
+
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4800
|
+
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
4801
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
4802
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
4803
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
4804
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
4805
|
+
}
|
|
4806
|
+
};
|
|
4807
|
+
if (stats.metrics) {
|
|
4808
|
+
const { open, ready } = stats.metrics;
|
|
4809
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
4802
4810
|
}
|
|
4811
|
+
return stats;
|
|
4812
|
+
};
|
|
4813
|
+
var createCollectDiagnosticsBroadcastSender = () => {
|
|
4803
4814
|
return {
|
|
4804
|
-
|
|
4805
|
-
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
4806
|
-
root: `${dataRoot}/`
|
|
4807
|
-
})
|
|
4815
|
+
broadcastDiagnosticsRequest: async () => void 0
|
|
4808
4816
|
};
|
|
4809
4817
|
};
|
|
4810
|
-
var
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
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
|
-
}
|
|
4818
|
+
var createCollectDiagnosticsBroadcastHandler = (_) => {
|
|
4819
|
+
return {
|
|
4820
|
+
start: () => {
|
|
4821
|
+
},
|
|
4822
|
+
stop: () => {
|
|
4823
|
+
}
|
|
4824
|
+
};
|
|
4829
4825
|
};
|
|
4830
|
-
var
|
|
4826
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4831
4827
|
var DevicesServiceImpl = class {
|
|
4832
4828
|
constructor(_identityManager) {
|
|
4833
4829
|
this._identityManager = _identityManager;
|
|
@@ -4844,8 +4840,8 @@ var DevicesServiceImpl = class {
|
|
|
4844
4840
|
devices: []
|
|
4845
4841
|
});
|
|
4846
4842
|
} else {
|
|
4847
|
-
(0,
|
|
4848
|
-
F:
|
|
4843
|
+
(0, import_invariant16.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
4844
|
+
F: __dxlog_file16,
|
|
4849
4845
|
L: 32,
|
|
4850
4846
|
S: this,
|
|
4851
4847
|
A: [
|
|
@@ -4860,9 +4856,9 @@ var DevicesServiceImpl = class {
|
|
|
4860
4856
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4861
4857
|
return {
|
|
4862
4858
|
deviceKey: key,
|
|
4863
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
4859
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services15.DeviceKind.CURRENT : import_services15.DeviceKind.TRUSTED,
|
|
4864
4860
|
profile,
|
|
4865
|
-
presence: isMe ?
|
|
4861
|
+
presence: isMe ? import_services15.Device.PresenceState.ONLINE : peerState ? import_services15.Device.PresenceState.ONLINE : import_services15.Device.PresenceState.OFFLINE
|
|
4866
4862
|
};
|
|
4867
4863
|
})
|
|
4868
4864
|
});
|
|
@@ -4903,6 +4899,60 @@ var DevicesServiceImpl = class {
|
|
|
4903
4899
|
});
|
|
4904
4900
|
}
|
|
4905
4901
|
};
|
|
4902
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
4903
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4904
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4905
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
4906
|
+
else
|
|
4907
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
4908
|
+
if (d = decorators[i])
|
|
4909
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4910
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4911
|
+
}
|
|
4912
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
4913
|
+
var Lock = class {
|
|
4914
|
+
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
4915
|
+
this._lockPath = lockPath;
|
|
4916
|
+
this._onAcquire = onAcquire;
|
|
4917
|
+
this._onRelease = onRelease;
|
|
4918
|
+
}
|
|
4919
|
+
get lockKey() {
|
|
4920
|
+
return this._lockPath;
|
|
4921
|
+
}
|
|
4922
|
+
async acquire() {
|
|
4923
|
+
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
4924
|
+
F: __dxlog_file17,
|
|
4925
|
+
L: 32,
|
|
4926
|
+
S: this,
|
|
4927
|
+
C: (f, a) => f(...a)
|
|
4928
|
+
});
|
|
4929
|
+
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
4930
|
+
await this._onAcquire?.();
|
|
4931
|
+
(0, import_log14.log)("acquired lock", void 0, {
|
|
4932
|
+
F: __dxlog_file17,
|
|
4933
|
+
L: 37,
|
|
4934
|
+
S: this,
|
|
4935
|
+
C: (f, a) => f(...a)
|
|
4936
|
+
});
|
|
4937
|
+
}
|
|
4938
|
+
async release() {
|
|
4939
|
+
await this._onRelease?.();
|
|
4940
|
+
(0, import_invariant17.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4941
|
+
F: __dxlog_file17,
|
|
4942
|
+
L: 42,
|
|
4943
|
+
S: this,
|
|
4944
|
+
A: [
|
|
4945
|
+
"this._fileHandle",
|
|
4946
|
+
"'Lock is not acquired'"
|
|
4947
|
+
]
|
|
4948
|
+
});
|
|
4949
|
+
await import_lock_file.LockFile.release(this._fileHandle);
|
|
4950
|
+
}
|
|
4951
|
+
};
|
|
4952
|
+
_ts_decorate7([
|
|
4953
|
+
import_log14.logInfo
|
|
4954
|
+
], Lock.prototype, "lockKey", null);
|
|
4955
|
+
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
4906
4956
|
var LoggingServiceImpl = class {
|
|
4907
4957
|
constructor() {
|
|
4908
4958
|
this._logs = new import_async18.Event();
|
|
@@ -5002,18 +5052,18 @@ var LoggingServiceImpl = class {
|
|
|
5002
5052
|
});
|
|
5003
5053
|
}
|
|
5004
5054
|
};
|
|
5005
|
-
var matchFilter = (filter, level,
|
|
5055
|
+
var matchFilter = (filter, level, path2, options) => {
|
|
5006
5056
|
switch (options) {
|
|
5007
|
-
case
|
|
5008
|
-
return level >= filter.level && (!filter.pattern ||
|
|
5009
|
-
case
|
|
5010
|
-
return level === filter.level && (!filter.pattern ||
|
|
5057
|
+
case import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5058
|
+
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5059
|
+
case import_services16.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5060
|
+
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5011
5061
|
}
|
|
5012
5062
|
};
|
|
5013
5063
|
var shouldLog = (entry2, request) => {
|
|
5014
|
-
const options = request.options ??
|
|
5064
|
+
const options = request.options ?? import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5015
5065
|
if (request.filters === void 0) {
|
|
5016
|
-
return options ===
|
|
5066
|
+
return options === import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5017
5067
|
} else {
|
|
5018
5068
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5019
5069
|
}
|
|
@@ -5049,6 +5099,63 @@ var NetworkServiceImpl = class {
|
|
|
5049
5099
|
await this.networkManager.setConnectionState(request.swarm);
|
|
5050
5100
|
}
|
|
5051
5101
|
};
|
|
5102
|
+
var getRootPath = (config) => {
|
|
5103
|
+
const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol5.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5104
|
+
return `${dataRoot}/`;
|
|
5105
|
+
};
|
|
5106
|
+
var isPersistent = (config) => {
|
|
5107
|
+
const { persistent = false } = config ?? {};
|
|
5108
|
+
return config.dataStore !== void 0 && config.dataStore !== import_config3.Runtime.Client.Storage.StorageDriver.RAM || persistent;
|
|
5109
|
+
};
|
|
5110
|
+
var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
|
|
5111
|
+
var createStorageObjects = (config) => {
|
|
5112
|
+
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
5113
|
+
if (persistent && dataStore === StorageDriver.RAM) {
|
|
5114
|
+
throw new import_protocols15.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
5115
|
+
}
|
|
5116
|
+
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
5117
|
+
throw new import_protocols15.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
5118
|
+
}
|
|
5119
|
+
if (persistent && keyStore === StorageDriver.RAM) {
|
|
5120
|
+
throw new import_protocols15.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
5121
|
+
}
|
|
5122
|
+
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
5123
|
+
throw new import_protocols15.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
5124
|
+
}
|
|
5125
|
+
return {
|
|
5126
|
+
storage: (0, import_random_access_storage.createStorage)({
|
|
5127
|
+
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
5128
|
+
root: getRootPath(config)
|
|
5129
|
+
})
|
|
5130
|
+
};
|
|
5131
|
+
};
|
|
5132
|
+
var toStorageType = (type) => {
|
|
5133
|
+
switch (type) {
|
|
5134
|
+
case void 0:
|
|
5135
|
+
return void 0;
|
|
5136
|
+
case StorageDriver.RAM:
|
|
5137
|
+
return import_random_access_storage.StorageType.RAM;
|
|
5138
|
+
case StorageDriver.CHROME:
|
|
5139
|
+
return import_random_access_storage.StorageType.CHROME;
|
|
5140
|
+
case StorageDriver.FIREFOX:
|
|
5141
|
+
return import_random_access_storage.StorageType.FIREFOX;
|
|
5142
|
+
case StorageDriver.IDB:
|
|
5143
|
+
return import_random_access_storage.StorageType.IDB;
|
|
5144
|
+
case StorageDriver.NODE:
|
|
5145
|
+
return import_random_access_storage.StorageType.NODE;
|
|
5146
|
+
case StorageDriver.WEBFS:
|
|
5147
|
+
return import_random_access_storage.StorageType.WEBFS;
|
|
5148
|
+
default:
|
|
5149
|
+
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
5150
|
+
}
|
|
5151
|
+
};
|
|
5152
|
+
var createLevel = async (config) => {
|
|
5153
|
+
const persistent = isPersistent(config);
|
|
5154
|
+
const storagePath = persistent ? getRootPath(config) : import_node_path.default.join("tmp", "level", import_keys13.PublicKey.random().toHex());
|
|
5155
|
+
const level = new import_level.Level(storagePath);
|
|
5156
|
+
await level.open();
|
|
5157
|
+
return level;
|
|
5158
|
+
};
|
|
5052
5159
|
var SystemServiceImpl = class {
|
|
5053
5160
|
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
5054
5161
|
this._config = config;
|
|
@@ -5068,9 +5175,9 @@ var SystemServiceImpl = class {
|
|
|
5068
5175
|
const diagnostics = await this._getDiagnostics();
|
|
5069
5176
|
return {
|
|
5070
5177
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5071
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5072
|
-
truncate: keys ===
|
|
5073
|
-
humanize: keys ===
|
|
5178
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
|
|
5179
|
+
truncate: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
5180
|
+
humanize: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
5074
5181
|
})))
|
|
5075
5182
|
};
|
|
5076
5183
|
}
|
|
@@ -5123,7 +5230,7 @@ var ClientServicesHost = class {
|
|
|
5123
5230
|
callbacks,
|
|
5124
5231
|
runtimeParams
|
|
5125
5232
|
} = {}) {
|
|
5126
|
-
this._tracingService =
|
|
5233
|
+
this._tracingService = import_tracing8.TRACE_PROCESSOR.createTraceSender();
|
|
5127
5234
|
this._statusUpdate = new import_async16.Event();
|
|
5128
5235
|
this._opening = false;
|
|
5129
5236
|
this._open = false;
|
|
@@ -5151,14 +5258,14 @@ var ClientServicesHost = class {
|
|
|
5151
5258
|
this._systemService = new SystemServiceImpl({
|
|
5152
5259
|
config: () => this._config,
|
|
5153
5260
|
statusUpdate: this._statusUpdate,
|
|
5154
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5261
|
+
getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
|
|
5155
5262
|
getDiagnostics: () => {
|
|
5156
5263
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5157
5264
|
},
|
|
5158
5265
|
onUpdateStatus: async (status) => {
|
|
5159
|
-
if (!this.isOpen && status ===
|
|
5266
|
+
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
5160
5267
|
await this._resourceLock?.acquire();
|
|
5161
|
-
} else if (this.isOpen && status ===
|
|
5268
|
+
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
5162
5269
|
await this._resourceLock?.release();
|
|
5163
5270
|
}
|
|
5164
5271
|
},
|
|
@@ -5166,8 +5273,9 @@ var ClientServicesHost = class {
|
|
|
5166
5273
|
await this.reset();
|
|
5167
5274
|
}
|
|
5168
5275
|
});
|
|
5276
|
+
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5169
5277
|
this._loggingService = new LoggingServiceImpl();
|
|
5170
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
5278
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol4.clientServiceBundle, {
|
|
5171
5279
|
SystemService: this._systemService,
|
|
5172
5280
|
TracingService: this._tracingService
|
|
5173
5281
|
});
|
|
@@ -5196,25 +5304,25 @@ var ClientServicesHost = class {
|
|
|
5196
5304
|
* Can only be called once.
|
|
5197
5305
|
*/
|
|
5198
5306
|
initialize({ config, ...options }) {
|
|
5199
|
-
(0,
|
|
5307
|
+
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5200
5308
|
F: __dxlog_file18,
|
|
5201
|
-
L:
|
|
5309
|
+
L: 188,
|
|
5202
5310
|
S: this,
|
|
5203
5311
|
A: [
|
|
5204
5312
|
"!this._open",
|
|
5205
5313
|
"'service host is open'"
|
|
5206
5314
|
]
|
|
5207
5315
|
});
|
|
5208
|
-
(0,
|
|
5316
|
+
(0, import_log13.log)("initializing...", void 0, {
|
|
5209
5317
|
F: __dxlog_file18,
|
|
5210
|
-
L:
|
|
5318
|
+
L: 189,
|
|
5211
5319
|
S: this,
|
|
5212
5320
|
C: (f, a) => f(...a)
|
|
5213
5321
|
});
|
|
5214
5322
|
if (config) {
|
|
5215
|
-
(0,
|
|
5323
|
+
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5216
5324
|
F: __dxlog_file18,
|
|
5217
|
-
L:
|
|
5325
|
+
L: 192,
|
|
5218
5326
|
S: this,
|
|
5219
5327
|
A: [
|
|
5220
5328
|
"!this._config",
|
|
@@ -5226,13 +5334,21 @@ var ClientServicesHost = class {
|
|
|
5226
5334
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
5227
5335
|
}
|
|
5228
5336
|
}
|
|
5337
|
+
if (!options.signalManager) {
|
|
5338
|
+
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5339
|
+
F: __dxlog_file18,
|
|
5340
|
+
L: 200,
|
|
5341
|
+
S: this,
|
|
5342
|
+
C: (f, a) => f(...a)
|
|
5343
|
+
});
|
|
5344
|
+
}
|
|
5229
5345
|
const { connectionLog = true, transportFactory = (0, import_network_manager2.createSimplePeerTransportFactory)({
|
|
5230
5346
|
iceServers: this._config?.get("runtime.services.ice")
|
|
5231
5347
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5232
5348
|
this._signalManager = signalManager;
|
|
5233
|
-
(0,
|
|
5349
|
+
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5234
5350
|
F: __dxlog_file18,
|
|
5235
|
-
L:
|
|
5351
|
+
L: 211,
|
|
5236
5352
|
S: this,
|
|
5237
5353
|
A: [
|
|
5238
5354
|
"!this._networkManager",
|
|
@@ -5244,9 +5360,9 @@ var ClientServicesHost = class {
|
|
|
5244
5360
|
transportFactory,
|
|
5245
5361
|
signalManager
|
|
5246
5362
|
});
|
|
5247
|
-
(0,
|
|
5363
|
+
(0, import_log13.log)("initialized", void 0, {
|
|
5248
5364
|
F: __dxlog_file18,
|
|
5249
|
-
L:
|
|
5365
|
+
L: 218,
|
|
5250
5366
|
S: this,
|
|
5251
5367
|
C: (f, a) => f(...a)
|
|
5252
5368
|
});
|
|
@@ -5256,44 +5372,44 @@ var ClientServicesHost = class {
|
|
|
5256
5372
|
return;
|
|
5257
5373
|
}
|
|
5258
5374
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5259
|
-
|
|
5375
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
|
|
5260
5376
|
id: traceId
|
|
5261
5377
|
}), {
|
|
5262
5378
|
F: __dxlog_file18,
|
|
5263
|
-
L:
|
|
5379
|
+
L: 229,
|
|
5264
5380
|
S: this,
|
|
5265
5381
|
C: (f, a) => f(...a)
|
|
5266
5382
|
});
|
|
5267
|
-
(0,
|
|
5383
|
+
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5268
5384
|
F: __dxlog_file18,
|
|
5269
|
-
L:
|
|
5385
|
+
L: 231,
|
|
5270
5386
|
S: this,
|
|
5271
5387
|
A: [
|
|
5272
5388
|
"this._config",
|
|
5273
5389
|
"'config not set'"
|
|
5274
5390
|
]
|
|
5275
5391
|
});
|
|
5276
|
-
(0,
|
|
5392
|
+
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5277
5393
|
F: __dxlog_file18,
|
|
5278
|
-
L:
|
|
5394
|
+
L: 232,
|
|
5279
5395
|
S: this,
|
|
5280
5396
|
A: [
|
|
5281
5397
|
"this._storage",
|
|
5282
5398
|
"'storage not set'"
|
|
5283
5399
|
]
|
|
5284
5400
|
});
|
|
5285
|
-
(0,
|
|
5401
|
+
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5286
5402
|
F: __dxlog_file18,
|
|
5287
|
-
L:
|
|
5403
|
+
L: 233,
|
|
5288
5404
|
S: this,
|
|
5289
5405
|
A: [
|
|
5290
5406
|
"this._signalManager",
|
|
5291
5407
|
"'signal manager not set'"
|
|
5292
5408
|
]
|
|
5293
5409
|
});
|
|
5294
|
-
(0,
|
|
5410
|
+
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5295
5411
|
F: __dxlog_file18,
|
|
5296
|
-
L:
|
|
5412
|
+
L: 234,
|
|
5297
5413
|
S: this,
|
|
5298
5414
|
A: [
|
|
5299
5415
|
"this._networkManager",
|
|
@@ -5301,17 +5417,20 @@ var ClientServicesHost = class {
|
|
|
5301
5417
|
]
|
|
5302
5418
|
});
|
|
5303
5419
|
this._opening = true;
|
|
5304
|
-
(0,
|
|
5420
|
+
(0, import_log13.log)("opening...", {
|
|
5305
5421
|
lockKey: this._resourceLock?.lockKey
|
|
5306
5422
|
}, {
|
|
5307
5423
|
F: __dxlog_file18,
|
|
5308
|
-
L:
|
|
5424
|
+
L: 237,
|
|
5309
5425
|
S: this,
|
|
5310
5426
|
C: (f, a) => f(...a)
|
|
5311
5427
|
});
|
|
5428
|
+
if (!this._level) {
|
|
5429
|
+
this._level = await createLevel(this._config.get("runtime.client.storage", {}));
|
|
5430
|
+
}
|
|
5312
5431
|
await this._resourceLock?.acquire();
|
|
5313
5432
|
await this._loggingService.open();
|
|
5314
|
-
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5433
|
+
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5315
5434
|
this._serviceRegistry.setServices({
|
|
5316
5435
|
SystemService: this._systemService,
|
|
5317
5436
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
@@ -5321,7 +5440,7 @@ var ClientServicesHost = class {
|
|
|
5321
5440
|
await this._serviceContext.initialized.wait();
|
|
5322
5441
|
return this._serviceContext.dataSpaceManager;
|
|
5323
5442
|
}),
|
|
5324
|
-
DataService: new
|
|
5443
|
+
DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.automergeHost),
|
|
5325
5444
|
IndexService: new import_indexing2.IndexServiceImpl({
|
|
5326
5445
|
indexer: this._serviceContext.indexer,
|
|
5327
5446
|
automergeHost: this._serviceContext.automergeHost
|
|
@@ -5337,9 +5456,9 @@ var ClientServicesHost = class {
|
|
|
5337
5456
|
})
|
|
5338
5457
|
});
|
|
5339
5458
|
await this._serviceContext.open(ctx);
|
|
5340
|
-
(0,
|
|
5459
|
+
(0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5341
5460
|
F: __dxlog_file18,
|
|
5342
|
-
L:
|
|
5461
|
+
L: 303,
|
|
5343
5462
|
S: this,
|
|
5344
5463
|
A: [
|
|
5345
5464
|
"this.serviceRegistry.services.InvitationsService",
|
|
@@ -5347,11 +5466,11 @@ var ClientServicesHost = class {
|
|
|
5347
5466
|
]
|
|
5348
5467
|
});
|
|
5349
5468
|
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5350
|
-
(0,
|
|
5469
|
+
(0, import_log13.log)("loaded persistent invitations", {
|
|
5351
5470
|
count: loadedInvitations.invitations?.length
|
|
5352
5471
|
}, {
|
|
5353
5472
|
F: __dxlog_file18,
|
|
5354
|
-
L:
|
|
5473
|
+
L: 306,
|
|
5355
5474
|
S: this,
|
|
5356
5475
|
C: (f, a) => f(...a)
|
|
5357
5476
|
});
|
|
@@ -5360,28 +5479,29 @@ var ClientServicesHost = class {
|
|
|
5360
5479
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
5361
5480
|
url: devtoolsProxy,
|
|
5362
5481
|
requested: {},
|
|
5363
|
-
exposed:
|
|
5482
|
+
exposed: import_client_protocol4.clientServiceBundle,
|
|
5364
5483
|
handlers: this.services
|
|
5365
5484
|
});
|
|
5366
5485
|
void this._devtoolsProxy.open();
|
|
5367
5486
|
}
|
|
5487
|
+
this.diagnosticsBroadcastHandler.start();
|
|
5368
5488
|
this._opening = false;
|
|
5369
5489
|
this._open = true;
|
|
5370
5490
|
this._statusUpdate.emit();
|
|
5371
5491
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5372
|
-
(0,
|
|
5492
|
+
(0, import_log13.log)("opened", {
|
|
5373
5493
|
deviceKey
|
|
5374
5494
|
}, {
|
|
5375
5495
|
F: __dxlog_file18,
|
|
5376
|
-
L:
|
|
5496
|
+
L: 324,
|
|
5377
5497
|
S: this,
|
|
5378
5498
|
C: (f, a) => f(...a)
|
|
5379
5499
|
});
|
|
5380
|
-
|
|
5500
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.end({
|
|
5381
5501
|
id: traceId
|
|
5382
5502
|
}), {
|
|
5383
5503
|
F: __dxlog_file18,
|
|
5384
|
-
L:
|
|
5504
|
+
L: 325,
|
|
5385
5505
|
S: this,
|
|
5386
5506
|
C: (f, a) => f(...a)
|
|
5387
5507
|
});
|
|
@@ -5391,60 +5511,62 @@ var ClientServicesHost = class {
|
|
|
5391
5511
|
return;
|
|
5392
5512
|
}
|
|
5393
5513
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5394
|
-
(0,
|
|
5514
|
+
(0, import_log13.log)("closing...", {
|
|
5395
5515
|
deviceKey
|
|
5396
5516
|
}, {
|
|
5397
5517
|
F: __dxlog_file18,
|
|
5398
|
-
L:
|
|
5518
|
+
L: 336,
|
|
5399
5519
|
S: this,
|
|
5400
5520
|
C: (f, a) => f(...a)
|
|
5401
5521
|
});
|
|
5522
|
+
this.diagnosticsBroadcastHandler.stop();
|
|
5402
5523
|
await this._devtoolsProxy?.close();
|
|
5403
5524
|
this._serviceRegistry.setServices({
|
|
5404
5525
|
SystemService: this._systemService
|
|
5405
5526
|
});
|
|
5406
5527
|
await this._loggingService.close();
|
|
5407
5528
|
await this._serviceContext.close();
|
|
5529
|
+
await this._level?.close();
|
|
5408
5530
|
this._open = false;
|
|
5409
5531
|
this._statusUpdate.emit();
|
|
5410
|
-
(0,
|
|
5532
|
+
(0, import_log13.log)("closed", {
|
|
5411
5533
|
deviceKey
|
|
5412
5534
|
}, {
|
|
5413
5535
|
F: __dxlog_file18,
|
|
5414
|
-
L:
|
|
5536
|
+
L: 345,
|
|
5415
5537
|
S: this,
|
|
5416
5538
|
C: (f, a) => f(...a)
|
|
5417
5539
|
});
|
|
5418
5540
|
}
|
|
5419
5541
|
async reset() {
|
|
5420
5542
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5421
|
-
|
|
5543
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
|
|
5422
5544
|
id: traceId
|
|
5423
5545
|
}), {
|
|
5424
5546
|
F: __dxlog_file18,
|
|
5425
|
-
L:
|
|
5547
|
+
L: 350,
|
|
5426
5548
|
S: this,
|
|
5427
5549
|
C: (f, a) => f(...a)
|
|
5428
5550
|
});
|
|
5429
|
-
(0,
|
|
5551
|
+
(0, import_log13.log)("resetting...", void 0, {
|
|
5430
5552
|
F: __dxlog_file18,
|
|
5431
|
-
L:
|
|
5553
|
+
L: 352,
|
|
5432
5554
|
S: this,
|
|
5433
5555
|
C: (f, a) => f(...a)
|
|
5434
5556
|
});
|
|
5435
5557
|
await this._serviceContext?.close();
|
|
5436
5558
|
await this._storage.reset();
|
|
5437
|
-
(0,
|
|
5559
|
+
(0, import_log13.log)("reset", void 0, {
|
|
5438
5560
|
F: __dxlog_file18,
|
|
5439
|
-
L:
|
|
5561
|
+
L: 355,
|
|
5440
5562
|
S: this,
|
|
5441
5563
|
C: (f, a) => f(...a)
|
|
5442
5564
|
});
|
|
5443
|
-
|
|
5565
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.end({
|
|
5444
5566
|
id: traceId
|
|
5445
5567
|
}), {
|
|
5446
5568
|
F: __dxlog_file18,
|
|
5447
|
-
L:
|
|
5569
|
+
L: 356,
|
|
5448
5570
|
S: this,
|
|
5449
5571
|
C: (f, a) => f(...a)
|
|
5450
5572
|
});
|
|
@@ -5454,12 +5576,10 @@ var ClientServicesHost = class {
|
|
|
5454
5576
|
const identity = await this._serviceContext.createIdentity(params);
|
|
5455
5577
|
await this._serviceContext.initialized.wait();
|
|
5456
5578
|
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
5579
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5460
|
-
(0,
|
|
5580
|
+
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5461
5581
|
F: __dxlog_file18,
|
|
5462
|
-
L:
|
|
5582
|
+
L: 368,
|
|
5463
5583
|
S: this,
|
|
5464
5584
|
A: [
|
|
5465
5585
|
"automergeIndex",
|
|
@@ -5468,41 +5588,88 @@ var ClientServicesHost = class {
|
|
|
5468
5588
|
});
|
|
5469
5589
|
const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
|
|
5470
5590
|
await document.whenReady();
|
|
5591
|
+
const properties = {
|
|
5592
|
+
system: {
|
|
5593
|
+
type: (0, import_echo_pipeline4.encodeReference)(E.getTypeReference(import_client_protocol4.Properties))
|
|
5594
|
+
},
|
|
5595
|
+
data: {
|
|
5596
|
+
[import_client_protocol4.defaultKey]: identity.identityKey.toHex()
|
|
5597
|
+
},
|
|
5598
|
+
meta: {
|
|
5599
|
+
keys: []
|
|
5600
|
+
}
|
|
5601
|
+
};
|
|
5602
|
+
const propertiesId = import_keys11.PublicKey.random().toHex();
|
|
5471
5603
|
document.change((doc) => {
|
|
5472
5604
|
(0, import_util9.assignDeep)(doc, [
|
|
5473
5605
|
"objects",
|
|
5474
|
-
|
|
5475
|
-
],
|
|
5606
|
+
propertiesId
|
|
5607
|
+
], properties);
|
|
5476
5608
|
});
|
|
5609
|
+
await this._serviceContext.automergeHost.repo.flush();
|
|
5477
5610
|
return identity;
|
|
5478
5611
|
}
|
|
5479
5612
|
};
|
|
5480
5613
|
_ts_decorate8([
|
|
5481
|
-
|
|
5614
|
+
import_tracing8.trace.info()
|
|
5482
5615
|
], ClientServicesHost.prototype, "_opening", void 0);
|
|
5483
5616
|
_ts_decorate8([
|
|
5484
|
-
|
|
5617
|
+
import_tracing8.trace.info()
|
|
5485
5618
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
5486
5619
|
_ts_decorate8([
|
|
5487
5620
|
import_async16.synchronized,
|
|
5488
|
-
|
|
5621
|
+
import_tracing8.trace.span()
|
|
5489
5622
|
], ClientServicesHost.prototype, "open", null);
|
|
5490
5623
|
_ts_decorate8([
|
|
5491
5624
|
import_async16.synchronized,
|
|
5492
|
-
|
|
5625
|
+
import_tracing8.trace.span()
|
|
5493
5626
|
], ClientServicesHost.prototype, "close", null);
|
|
5494
5627
|
ClientServicesHost = _ts_decorate8([
|
|
5495
|
-
|
|
5628
|
+
import_tracing8.trace.resource()
|
|
5496
5629
|
], ClientServicesHost);
|
|
5630
|
+
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
5631
|
+
var DiagnosticsCollector = class {
|
|
5632
|
+
static {
|
|
5633
|
+
this.broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
5634
|
+
}
|
|
5635
|
+
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5636
|
+
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5637
|
+
keys: options.humanize ? import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5638
|
+
});
|
|
5639
|
+
const clientDiagnostics = {
|
|
5640
|
+
config,
|
|
5641
|
+
trace: import_tracing7.TRACE_PROCESSOR.getDiagnostics()
|
|
5642
|
+
};
|
|
5643
|
+
const diagnostics = serviceDiagnostics != null ? {
|
|
5644
|
+
client: clientDiagnostics,
|
|
5645
|
+
services: serviceDiagnostics
|
|
5646
|
+
} : {
|
|
5647
|
+
client: clientDiagnostics,
|
|
5648
|
+
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
5649
|
+
};
|
|
5650
|
+
return JSON.parse(JSON.stringify(diagnostics, (0, import_util8.jsonKeyReplacer)(options)));
|
|
5651
|
+
}
|
|
5652
|
+
};
|
|
5653
|
+
var findSystemServiceProvider = () => {
|
|
5654
|
+
const serviceProviders = import_tracing7.TRACE_PROCESSOR.findByAnnotation(ClientServicesProviderResource);
|
|
5655
|
+
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
5656
|
+
return providerResource?.instance?.deref() ?? null;
|
|
5657
|
+
};
|
|
5658
|
+
var findConfigs = () => {
|
|
5659
|
+
const configs = import_tracing7.TRACE_PROCESSOR.findByAnnotation(import_config.ConfigResource);
|
|
5660
|
+
return configs.map((r) => r.instance.deref()).filter(import_util8.nonNullable);
|
|
5661
|
+
};
|
|
5497
5662
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5498
5663
|
0 && (module.exports = {
|
|
5499
5664
|
ClientRpcServer,
|
|
5500
5665
|
ClientServicesHost,
|
|
5666
|
+
ClientServicesProviderResource,
|
|
5501
5667
|
DataSpace,
|
|
5502
5668
|
DataSpaceManager,
|
|
5503
5669
|
DeviceInvitationProtocol,
|
|
5504
5670
|
DevtoolsHostEvents,
|
|
5505
5671
|
DevtoolsServiceImpl,
|
|
5672
|
+
DiagnosticsCollector,
|
|
5506
5673
|
Identity,
|
|
5507
5674
|
IdentityManager,
|
|
5508
5675
|
IdentityServiceImpl,
|
|
@@ -5515,7 +5682,10 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5515
5682
|
SpacesServiceImpl,
|
|
5516
5683
|
TrustedKeySetAuthVerifier,
|
|
5517
5684
|
createAuthProvider,
|
|
5685
|
+
createCollectDiagnosticsBroadcastHandler,
|
|
5686
|
+
createCollectDiagnosticsBroadcastSender,
|
|
5518
5687
|
createDiagnostics,
|
|
5688
|
+
createLevel,
|
|
5519
5689
|
createStorageObjects,
|
|
5520
5690
|
getNetworkPeers,
|
|
5521
5691
|
invitationExpired,
|
|
@@ -5528,4 +5698,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5528
5698
|
subscribeToSpaces,
|
|
5529
5699
|
subscribeToSwarmInfo
|
|
5530
5700
|
});
|
|
5531
|
-
//# sourceMappingURL=chunk-
|
|
5701
|
+
//# sourceMappingURL=chunk-ENGA4MHO.cjs.map
|