@dxos/client-services 0.6.5 → 0.6.6-main.e1a6e1f
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-GIAH3RXX.mjs → chunk-DR3GOD3O.mjs} +907 -442
- package/dist/lib/browser/chunk-DR3GOD3O.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +28 -13
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +21 -4
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-NDXK2NIM.cjs → chunk-DRNEKKQP.cjs} +1065 -607
- package/dist/lib/node/chunk-DRNEKKQP.cjs.map +7 -0
- package/dist/lib/node/index.cjs +77 -62
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +27 -8
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +6 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +29 -12
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +7 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +35 -0
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/index.d.ts +1 -0
- package/dist/types/src/packlets/spaces/index.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +2 -0
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +3 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-runtime.d.ts +8 -3
- package/dist/types/src/packlets/worker/worker-runtime.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 +38 -36
- package/src/packlets/invitations/invitations-handler.test.ts +1 -0
- package/src/packlets/invitations/invitations-handler.ts +12 -0
- package/src/packlets/invitations/space-invitation-protocol.test.ts +23 -1
- package/src/packlets/services/service-context.ts +44 -12
- package/src/packlets/services/service-host.ts +26 -4
- package/src/packlets/spaces/data-space-manager.test.ts +6 -0
- package/src/packlets/spaces/data-space-manager.ts +80 -36
- package/src/packlets/spaces/data-space.ts +36 -2
- package/src/packlets/spaces/edge-feed-replicator.ts +249 -0
- package/src/packlets/spaces/index.ts +1 -0
- package/src/packlets/testing/invitation-utils.ts +2 -2
- package/src/packlets/testing/test-builder.ts +20 -12
- package/src/packlets/worker/worker-runtime.ts +32 -10
- package/src/version.ts +1 -5
- package/dist/lib/browser/chunk-GIAH3RXX.mjs.map +0 -7
- package/dist/lib/node/chunk-NDXK2NIM.cjs.map +0 -7
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_DRNEKKQP_exports = {};
|
|
30
|
+
__export(chunk_DRNEKKQP_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
DataSpace: () => DataSpace,
|
|
@@ -36,6 +36,7 @@ __export(chunk_NDXK2NIM_exports, {
|
|
|
36
36
|
DevtoolsHostEvents: () => DevtoolsHostEvents,
|
|
37
37
|
DevtoolsServiceImpl: () => DevtoolsServiceImpl,
|
|
38
38
|
DiagnosticsCollector: () => DiagnosticsCollector,
|
|
39
|
+
EdgeFeedReplicator: () => EdgeFeedReplicator,
|
|
39
40
|
Identity: () => Identity,
|
|
40
41
|
IdentityManager: () => IdentityManager,
|
|
41
42
|
IdentityServiceImpl: () => IdentityServiceImpl,
|
|
@@ -69,7 +70,7 @@ __export(chunk_NDXK2NIM_exports, {
|
|
|
69
70
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
70
71
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
71
72
|
});
|
|
72
|
-
module.exports = __toCommonJS(
|
|
73
|
+
module.exports = __toCommonJS(chunk_DRNEKKQP_exports);
|
|
73
74
|
var import_async = require("@dxos/async");
|
|
74
75
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
75
76
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -206,131 +207,141 @@ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
|
206
207
|
var import_debug2 = require("@dxos/debug");
|
|
207
208
|
var import_rpc = require("@dxos/rpc");
|
|
208
209
|
var import_tracing6 = require("@dxos/tracing");
|
|
210
|
+
var import_cbor_x = require("cbor-x");
|
|
209
211
|
var import_async13 = require("@dxos/async");
|
|
210
|
-
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
211
212
|
var import_context10 = require("@dxos/context");
|
|
212
|
-
var import_debug3 = require("@dxos/debug");
|
|
213
|
-
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
214
|
-
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
215
213
|
var import_invariant13 = require("@dxos/invariant");
|
|
216
214
|
var import_keys10 = require("@dxos/keys");
|
|
217
215
|
var import_log13 = require("@dxos/log");
|
|
218
216
|
var import_protocols9 = require("@dxos/protocols");
|
|
217
|
+
var import_buf = require("@dxos/protocols/buf");
|
|
218
|
+
var import_messenger_pb = require("@dxos/protocols/buf/dxos/edge/messenger_pb");
|
|
219
|
+
var import_util8 = require("@dxos/util");
|
|
220
|
+
var import_async14 = require("@dxos/async");
|
|
221
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
222
|
+
var import_context11 = require("@dxos/context");
|
|
223
|
+
var import_debug3 = require("@dxos/debug");
|
|
224
|
+
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
225
|
+
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
226
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
227
|
+
var import_keys11 = require("@dxos/keys");
|
|
228
|
+
var import_log14 = require("@dxos/log");
|
|
229
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
219
230
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
220
231
|
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
221
232
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
222
233
|
var import_tracing7 = require("@dxos/tracing");
|
|
223
|
-
var
|
|
224
|
-
var
|
|
225
|
-
var
|
|
234
|
+
var import_util9 = require("@dxos/util");
|
|
235
|
+
var import_async15 = require("@dxos/async");
|
|
236
|
+
var import_context12 = require("@dxos/context");
|
|
226
237
|
var import_credentials14 = require("@dxos/credentials");
|
|
227
238
|
var import_echo_db = require("@dxos/echo-db");
|
|
228
239
|
var import_echo_protocol2 = require("@dxos/echo-protocol");
|
|
229
240
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
230
|
-
var import_invariant14 = require("@dxos/invariant");
|
|
231
|
-
var import_log14 = require("@dxos/log");
|
|
232
|
-
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
233
|
-
var import_async15 = require("@dxos/async");
|
|
234
|
-
var import_context12 = require("@dxos/context");
|
|
235
241
|
var import_invariant15 = require("@dxos/invariant");
|
|
236
|
-
var import_keys11 = require("@dxos/keys");
|
|
237
242
|
var import_log15 = require("@dxos/log");
|
|
238
|
-
var
|
|
239
|
-
var import_teleport3 = require("@dxos/teleport");
|
|
240
|
-
var import_util9 = require("@dxos/util");
|
|
243
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
241
244
|
var import_async16 = require("@dxos/async");
|
|
242
|
-
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
243
245
|
var import_context13 = require("@dxos/context");
|
|
246
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
247
|
+
var import_keys12 = require("@dxos/keys");
|
|
248
|
+
var import_log16 = require("@dxos/log");
|
|
249
|
+
var import_protocols11 = require("@dxos/protocols");
|
|
250
|
+
var import_teleport3 = require("@dxos/teleport");
|
|
251
|
+
var import_util10 = require("@dxos/util");
|
|
252
|
+
var import_async17 = require("@dxos/async");
|
|
253
|
+
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
254
|
+
var import_context14 = require("@dxos/context");
|
|
244
255
|
var import_credentials15 = require("@dxos/credentials");
|
|
245
256
|
var import_echo_db2 = require("@dxos/echo-db");
|
|
246
257
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
247
|
-
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
248
258
|
var import_echo_protocol3 = require("@dxos/echo-protocol");
|
|
249
259
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
250
260
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
251
|
-
var
|
|
252
|
-
var
|
|
253
|
-
var
|
|
254
|
-
var
|
|
261
|
+
var import_invariant17 = require("@dxos/invariant");
|
|
262
|
+
var import_keys13 = require("@dxos/keys");
|
|
263
|
+
var import_log17 = require("@dxos/log");
|
|
264
|
+
var import_protocols12 = require("@dxos/protocols");
|
|
255
265
|
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
256
266
|
var import_credentials16 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
257
267
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
258
268
|
var import_tracing8 = require("@dxos/tracing");
|
|
259
|
-
var
|
|
269
|
+
var import_util11 = require("@dxos/util");
|
|
260
270
|
var import_credentials17 = require("@dxos/credentials");
|
|
261
271
|
var import_debug4 = require("@dxos/debug");
|
|
262
272
|
var import_credentials18 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
263
273
|
var import_timeframe4 = require("@dxos/timeframe");
|
|
264
|
-
var
|
|
274
|
+
var import_async18 = require("@dxos/async");
|
|
265
275
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
266
276
|
var import_credentials19 = require("@dxos/credentials");
|
|
267
277
|
var import_debug5 = require("@dxos/debug");
|
|
268
278
|
var import_feed_store5 = require("@dxos/feed-store");
|
|
269
|
-
var
|
|
270
|
-
var
|
|
271
|
-
var
|
|
279
|
+
var import_invariant18 = require("@dxos/invariant");
|
|
280
|
+
var import_log18 = require("@dxos/log");
|
|
281
|
+
var import_protocols13 = require("@dxos/protocols");
|
|
272
282
|
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
273
283
|
var import_tracing9 = require("@dxos/tracing");
|
|
274
|
-
var
|
|
275
|
-
var
|
|
284
|
+
var import_async19 = require("@dxos/async");
|
|
285
|
+
var import_context15 = require("@dxos/context");
|
|
276
286
|
var import_credentials20 = require("@dxos/credentials");
|
|
277
287
|
var import_debug6 = require("@dxos/debug");
|
|
278
288
|
var import_echo_db3 = require("@dxos/echo-db");
|
|
279
|
-
var
|
|
289
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
280
290
|
var import_feed_store6 = require("@dxos/feed-store");
|
|
281
|
-
var
|
|
291
|
+
var import_invariant19 = require("@dxos/invariant");
|
|
282
292
|
var import_keyring = require("@dxos/keyring");
|
|
283
|
-
var
|
|
284
|
-
var
|
|
285
|
-
var
|
|
293
|
+
var import_keys14 = require("@dxos/keys");
|
|
294
|
+
var import_log19 = require("@dxos/log");
|
|
295
|
+
var import_protocols14 = require("@dxos/protocols");
|
|
286
296
|
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
287
297
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
288
298
|
var import_tracing10 = require("@dxos/tracing");
|
|
289
|
-
var
|
|
290
|
-
var
|
|
299
|
+
var import_util12 = require("@dxos/util");
|
|
300
|
+
var import_protocols15 = require("@dxos/protocols");
|
|
291
301
|
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
292
302
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
293
303
|
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
294
304
|
var import_config3 = require("@dxos/protocols/proto/dxos/config");
|
|
295
|
-
var
|
|
305
|
+
var import_util13 = require("@dxos/util");
|
|
296
306
|
var import_node_path = __toESM(require("node:path"));
|
|
297
|
-
var
|
|
307
|
+
var import_keys15 = require("@dxos/keys");
|
|
298
308
|
var import_kv_store = require("@dxos/kv-store");
|
|
299
309
|
var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
300
|
-
var import_invariant19 = require("@dxos/invariant");
|
|
301
|
-
var import_log19 = require("@dxos/log");
|
|
302
|
-
var import_protocols15 = require("@dxos/protocols");
|
|
303
|
-
var import_util13 = require("@dxos/util");
|
|
304
|
-
var import_async19 = require("@dxos/async");
|
|
305
|
-
var import_client_protocol8 = require("@dxos/client-protocol");
|
|
306
|
-
var import_context15 = require("@dxos/context");
|
|
307
310
|
var import_invariant20 = require("@dxos/invariant");
|
|
308
|
-
var import_keys15 = require("@dxos/keys");
|
|
309
311
|
var import_log20 = require("@dxos/log");
|
|
312
|
+
var import_protocols16 = require("@dxos/protocols");
|
|
313
|
+
var import_util14 = require("@dxos/util");
|
|
314
|
+
var import_async20 = require("@dxos/async");
|
|
315
|
+
var import_client_protocol8 = require("@dxos/client-protocol");
|
|
316
|
+
var import_context16 = require("@dxos/context");
|
|
317
|
+
var import_edge_client = require("@dxos/edge-client");
|
|
318
|
+
var import_invariant21 = require("@dxos/invariant");
|
|
319
|
+
var import_keys16 = require("@dxos/keys");
|
|
320
|
+
var import_log21 = require("@dxos/log");
|
|
310
321
|
var import_messaging = require("@dxos/messaging");
|
|
311
322
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
312
|
-
var
|
|
323
|
+
var import_protocols17 = require("@dxos/protocols");
|
|
313
324
|
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
314
325
|
var import_tracing11 = require("@dxos/tracing");
|
|
315
326
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
316
|
-
var
|
|
327
|
+
var import_async21 = require("@dxos/async");
|
|
317
328
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
318
|
-
var
|
|
329
|
+
var import_invariant22 = require("@dxos/invariant");
|
|
319
330
|
var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
|
|
320
|
-
var import_async21 = require("@dxos/async");
|
|
321
|
-
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
322
|
-
var import_keys16 = require("@dxos/keys");
|
|
323
|
-
var import_util14 = require("@dxos/util");
|
|
324
331
|
var import_async22 = require("@dxos/async");
|
|
325
|
-
var
|
|
332
|
+
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
326
333
|
var import_keys17 = require("@dxos/keys");
|
|
327
|
-
var import_log21 = require("@dxos/log");
|
|
328
|
-
var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
|
|
329
334
|
var import_util15 = require("@dxos/util");
|
|
335
|
+
var import_async23 = require("@dxos/async");
|
|
336
|
+
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
337
|
+
var import_keys18 = require("@dxos/keys");
|
|
338
|
+
var import_log22 = require("@dxos/log");
|
|
339
|
+
var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
|
|
340
|
+
var import_util16 = require("@dxos/util");
|
|
330
341
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
331
342
|
var import_codec_protobuf16 = require("@dxos/codec-protobuf");
|
|
332
343
|
var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
|
|
333
|
-
var
|
|
344
|
+
var import_util17 = require("@dxos/util");
|
|
334
345
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
335
346
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
336
347
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -645,7 +656,7 @@ var DevtoolsServiceImpl = class {
|
|
|
645
656
|
});
|
|
646
657
|
}
|
|
647
658
|
};
|
|
648
|
-
var DXOS_VERSION = "0.6.
|
|
659
|
+
var DXOS_VERSION = "0.6.6-main.e1a6e1f";
|
|
649
660
|
var getPlatform = () => {
|
|
650
661
|
if (process.browser) {
|
|
651
662
|
if (typeof window !== "undefined") {
|
|
@@ -2855,6 +2866,14 @@ var InvitationsHandler = class {
|
|
|
2855
2866
|
""
|
|
2856
2867
|
]
|
|
2857
2868
|
});
|
|
2869
|
+
const timeoutInactive = () => {
|
|
2870
|
+
if (guardedState.mutex.isLocked()) {
|
|
2871
|
+
(0, import_async9.scheduleTask)(ctx, timeoutInactive, timeout);
|
|
2872
|
+
} else {
|
|
2873
|
+
guardedState.set(null, import_services7.Invitation.State.TIMEOUT);
|
|
2874
|
+
}
|
|
2875
|
+
};
|
|
2876
|
+
(0, import_async9.scheduleTask)(ctx, timeoutInactive, timeout);
|
|
2858
2877
|
await this._joinSwarm(ctx, invitation, import_invitations2.InvitationOptions.Role.GUEST, createExtension);
|
|
2859
2878
|
guardedState.set(null, import_services7.Invitation.State.CONNECTING);
|
|
2860
2879
|
}
|
|
@@ -2948,7 +2967,7 @@ var InvitationsHandler = class {
|
|
|
2948
2967
|
oldState: stateToString(invitation.state)
|
|
2949
2968
|
}, {
|
|
2950
2969
|
F: __dxlog_file12,
|
|
2951
|
-
L:
|
|
2970
|
+
L: 461,
|
|
2952
2971
|
S: this,
|
|
2953
2972
|
C: (f, a) => f(...a)
|
|
2954
2973
|
});
|
|
@@ -2959,7 +2978,7 @@ var InvitationsHandler = class {
|
|
|
2959
2978
|
oldState: stateToString(invitation.state)
|
|
2960
2979
|
}, {
|
|
2961
2980
|
F: __dxlog_file12,
|
|
2962
|
-
L:
|
|
2981
|
+
L: 467,
|
|
2963
2982
|
S: this,
|
|
2964
2983
|
C: (f, a) => f(...a)
|
|
2965
2984
|
});
|
|
@@ -2978,7 +2997,7 @@ var InvitationsHandler = class {
|
|
|
2978
2997
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2979
2998
|
(0, import_log6.log)("guest waiting for authentication code...", void 0, {
|
|
2980
2999
|
F: __dxlog_file12,
|
|
2981
|
-
L:
|
|
3000
|
+
L: 492,
|
|
2982
3001
|
S: this,
|
|
2983
3002
|
C: (f, a) => f(...a)
|
|
2984
3003
|
});
|
|
@@ -2986,7 +3005,7 @@ var InvitationsHandler = class {
|
|
|
2986
3005
|
const authCode = await authenticated.wait(options);
|
|
2987
3006
|
(0, import_log6.log)("sending authentication request", void 0, {
|
|
2988
3007
|
F: __dxlog_file12,
|
|
2989
|
-
L:
|
|
3008
|
+
L: 496,
|
|
2990
3009
|
S: this,
|
|
2991
3010
|
C: (f, a) => f(...a)
|
|
2992
3011
|
});
|
|
@@ -3005,7 +3024,7 @@ var InvitationsHandler = class {
|
|
|
3005
3024
|
attempt
|
|
3006
3025
|
}, {
|
|
3007
3026
|
F: __dxlog_file12,
|
|
3008
|
-
L:
|
|
3027
|
+
L: 507,
|
|
3009
3028
|
S: this,
|
|
3010
3029
|
C: (f, a) => f(...a)
|
|
3011
3030
|
});
|
|
@@ -3023,7 +3042,7 @@ var InvitationsHandler = class {
|
|
|
3023
3042
|
}
|
|
3024
3043
|
(0, import_log6.log)("sending authentication request", void 0, {
|
|
3025
3044
|
F: __dxlog_file12,
|
|
3026
|
-
L:
|
|
3045
|
+
L: 526,
|
|
3027
3046
|
S: this,
|
|
3028
3047
|
C: (f, a) => f(...a)
|
|
3029
3048
|
});
|
|
@@ -3877,89 +3896,442 @@ _ts_decorate4([
|
|
|
3877
3896
|
ClientRpcServer = _ts_decorate4([
|
|
3878
3897
|
import_tracing6.trace.resource()
|
|
3879
3898
|
], ClientRpcServer);
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
if (this._isProcessingRootDocs) {
|
|
3902
|
-
this._onNewRoot(this.rootUrl);
|
|
3899
|
+
function _using_ctx() {
|
|
3900
|
+
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
3901
|
+
var err = new Error();
|
|
3902
|
+
err.name = "SuppressedError";
|
|
3903
|
+
err.suppressed = suppressed;
|
|
3904
|
+
err.error = error;
|
|
3905
|
+
return err;
|
|
3906
|
+
}, empty = {}, stack = [];
|
|
3907
|
+
function using(isAwait, value) {
|
|
3908
|
+
if (value != null) {
|
|
3909
|
+
if (Object(value) !== value) {
|
|
3910
|
+
throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
3911
|
+
}
|
|
3912
|
+
if (isAwait) {
|
|
3913
|
+
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
3914
|
+
}
|
|
3915
|
+
if (dispose == null) {
|
|
3916
|
+
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
3917
|
+
}
|
|
3918
|
+
if (typeof dispose !== "function") {
|
|
3919
|
+
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
3903
3920
|
}
|
|
3921
|
+
stack.push({
|
|
3922
|
+
v: value,
|
|
3923
|
+
d: dispose,
|
|
3924
|
+
a: isAwait
|
|
3925
|
+
});
|
|
3926
|
+
} else if (isAwait) {
|
|
3927
|
+
stack.push({
|
|
3928
|
+
d: value,
|
|
3929
|
+
a: isAwait
|
|
3930
|
+
});
|
|
3904
3931
|
}
|
|
3905
|
-
|
|
3932
|
+
return value;
|
|
3906
3933
|
}
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
this.
|
|
3934
|
+
return {
|
|
3935
|
+
e: empty,
|
|
3936
|
+
u: using.bind(null, false),
|
|
3937
|
+
a: using.bind(null, true),
|
|
3938
|
+
d: function() {
|
|
3939
|
+
var error = this.e;
|
|
3940
|
+
function next() {
|
|
3941
|
+
while (resource = stack.pop()) {
|
|
3942
|
+
try {
|
|
3943
|
+
var resource, disposalResult = resource.d && resource.d.call(resource.v);
|
|
3944
|
+
if (resource.a) {
|
|
3945
|
+
return Promise.resolve(disposalResult).then(next, err);
|
|
3946
|
+
}
|
|
3947
|
+
} catch (e) {
|
|
3948
|
+
return err(e);
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
if (error !== empty)
|
|
3952
|
+
throw error;
|
|
3953
|
+
}
|
|
3954
|
+
function err(e) {
|
|
3955
|
+
error = error !== empty ? new _disposeSuppressedError(error, e) : e;
|
|
3956
|
+
return next();
|
|
3957
|
+
}
|
|
3958
|
+
return next();
|
|
3913
3959
|
}
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3960
|
+
};
|
|
3961
|
+
}
|
|
3962
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/edge-feed-replicator.ts";
|
|
3963
|
+
var EdgeFeedReplicator = class extends import_context10.Resource {
|
|
3964
|
+
constructor({ messenger, spaceId }) {
|
|
3965
|
+
super();
|
|
3966
|
+
this._feeds = new import_util8.ComplexMap(import_keys10.PublicKey.hash);
|
|
3967
|
+
this._connectionCtx = void 0;
|
|
3968
|
+
this._connected = false;
|
|
3969
|
+
this._remoteLength = new import_util8.ComplexMap(import_keys10.PublicKey.hash);
|
|
3970
|
+
this._pushMutex = new import_util8.ComplexMap(import_keys10.PublicKey.hash);
|
|
3971
|
+
this._messenger = messenger;
|
|
3972
|
+
this._spaceId = spaceId;
|
|
3918
3973
|
}
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
switch (context.migration) {
|
|
3924
|
-
case import_services14.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3925
|
-
const document = context.echoHost.createDoc();
|
|
3926
|
-
await context.echoHost.flush();
|
|
3927
|
-
return {
|
|
3928
|
-
newRoot: document.url
|
|
3929
|
-
};
|
|
3930
|
-
}
|
|
3931
|
-
case import_services14.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
3932
|
-
if (!context.currentRoot) {
|
|
3933
|
-
throw new Error("Space does not have an automerge root");
|
|
3974
|
+
async _open() {
|
|
3975
|
+
this._ctx.onDispose(this._messenger.addListener(async (message) => {
|
|
3976
|
+
if (!message.serviceId) {
|
|
3977
|
+
return;
|
|
3934
3978
|
}
|
|
3935
|
-
const
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3979
|
+
const [service, ...rest] = message.serviceId.split(":");
|
|
3980
|
+
if (service !== "hypercore-replicator") {
|
|
3981
|
+
return;
|
|
3982
|
+
}
|
|
3983
|
+
const [spaceId] = rest;
|
|
3984
|
+
if (spaceId !== this._spaceId) {
|
|
3985
|
+
(0, import_log13.log)("spaceID mismatch", {
|
|
3986
|
+
spaceId,
|
|
3987
|
+
_spaceId: this._spaceId
|
|
3988
|
+
}, {
|
|
3989
|
+
F: __dxlog_file16,
|
|
3990
|
+
L: 62,
|
|
3991
|
+
S: this,
|
|
3992
|
+
C: (f, a) => f(...a)
|
|
3993
|
+
});
|
|
3994
|
+
return;
|
|
3995
|
+
}
|
|
3996
|
+
const payload = (0, import_cbor_x.decode)(message.payload.value);
|
|
3997
|
+
import_log13.log.info("recv", {
|
|
3998
|
+
from: message.source,
|
|
3999
|
+
payload
|
|
4000
|
+
}, {
|
|
3946
4001
|
F: __dxlog_file16,
|
|
3947
|
-
L:
|
|
3948
|
-
S:
|
|
4002
|
+
L: 67,
|
|
4003
|
+
S: this,
|
|
3949
4004
|
C: (f, a) => f(...a)
|
|
3950
4005
|
});
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
4006
|
+
this._onMessage(payload);
|
|
4007
|
+
}));
|
|
4008
|
+
this._connected = true;
|
|
4009
|
+
this._connectionCtx = this._ctx.derive();
|
|
4010
|
+
for (const feed of this._feeds.values()) {
|
|
4011
|
+
await this._replicateFeed(feed);
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
async _close() {
|
|
4015
|
+
this._connected = false;
|
|
4016
|
+
this._connected = false;
|
|
4017
|
+
await this._connectionCtx?.dispose();
|
|
4018
|
+
this._connectionCtx = void 0;
|
|
4019
|
+
this._remoteLength.clear();
|
|
4020
|
+
}
|
|
4021
|
+
async addFeed(feed) {
|
|
4022
|
+
import_log13.log.info("addFeed", {
|
|
4023
|
+
key: feed.key
|
|
4024
|
+
}, {
|
|
4025
|
+
F: __dxlog_file16,
|
|
4026
|
+
L: 89,
|
|
4027
|
+
S: this,
|
|
4028
|
+
C: (f, a) => f(...a)
|
|
4029
|
+
});
|
|
4030
|
+
this._feeds.set(feed.key, feed);
|
|
4031
|
+
if (this._connected) {
|
|
4032
|
+
await this._replicateFeed(feed);
|
|
4033
|
+
}
|
|
4034
|
+
}
|
|
4035
|
+
_getPushMutex(key) {
|
|
4036
|
+
return (0, import_util8.defaultMap)(this._pushMutex, key, () => new import_async13.Mutex());
|
|
4037
|
+
}
|
|
4038
|
+
async _replicateFeed(feed) {
|
|
4039
|
+
(0, import_invariant13.invariant)(this._connectionCtx, void 0, {
|
|
4040
|
+
F: __dxlog_file16,
|
|
4041
|
+
L: 102,
|
|
4042
|
+
S: this,
|
|
4043
|
+
A: [
|
|
4044
|
+
"this._connectionCtx",
|
|
4045
|
+
""
|
|
4046
|
+
]
|
|
4047
|
+
});
|
|
4048
|
+
await this._sendMessage({
|
|
4049
|
+
type: "get-metadata",
|
|
4050
|
+
feedKey: feed.key.toHex()
|
|
4051
|
+
});
|
|
4052
|
+
import_async13.Event.wrap(feed.core, "append").on(this._connectionCtx, async () => {
|
|
4053
|
+
await this._pushBlocksIfNeeded(feed);
|
|
4054
|
+
});
|
|
4055
|
+
}
|
|
4056
|
+
async _sendMessage(message) {
|
|
4057
|
+
import_log13.log.info("sending message", {
|
|
4058
|
+
message
|
|
4059
|
+
}, {
|
|
4060
|
+
F: __dxlog_file16,
|
|
4061
|
+
L: 115,
|
|
4062
|
+
S: this,
|
|
4063
|
+
C: (f, a) => f(...a)
|
|
4064
|
+
});
|
|
4065
|
+
(0, import_invariant13.invariant)(message.feedKey, void 0, {
|
|
4066
|
+
F: __dxlog_file16,
|
|
4067
|
+
L: 117,
|
|
4068
|
+
S: this,
|
|
4069
|
+
A: [
|
|
4070
|
+
"message.feedKey",
|
|
4071
|
+
""
|
|
4072
|
+
]
|
|
4073
|
+
});
|
|
4074
|
+
const payloadValue = (0, import_util8.bufferToArray)((0, import_cbor_x.encode)(message));
|
|
4075
|
+
await this._messenger.send(import_buf.buf.create(import_messenger_pb.MessageSchema, {
|
|
4076
|
+
source: {
|
|
4077
|
+
identityKey: this._messenger.identityKey.toHex(),
|
|
4078
|
+
peerKey: this._messenger.deviceKey.toHex()
|
|
4079
|
+
},
|
|
4080
|
+
serviceId: `${import_protocols9.EdgeService.FEED_REPLICATOR}:${this._spaceId}`,
|
|
4081
|
+
payload: {
|
|
4082
|
+
value: payloadValue
|
|
4083
|
+
}
|
|
4084
|
+
}));
|
|
4085
|
+
}
|
|
4086
|
+
_onMessage(message) {
|
|
4087
|
+
import_log13.log.info("received message", {
|
|
4088
|
+
message
|
|
4089
|
+
}, {
|
|
4090
|
+
F: __dxlog_file16,
|
|
4091
|
+
L: 133,
|
|
4092
|
+
S: this,
|
|
4093
|
+
C: (f, a) => f(...a)
|
|
4094
|
+
});
|
|
4095
|
+
(0, import_async13.scheduleMicroTask)(this._ctx, async () => {
|
|
4096
|
+
switch (message.type) {
|
|
4097
|
+
case "metadata": {
|
|
4098
|
+
try {
|
|
4099
|
+
var _usingCtx = _using_ctx();
|
|
4100
|
+
const feedKey = import_keys10.PublicKey.fromHex(message.feedKey);
|
|
4101
|
+
const feed = this._feeds.get(feedKey);
|
|
4102
|
+
if (!feed) {
|
|
4103
|
+
import_log13.log.warn("Feed not found", {
|
|
4104
|
+
feedKey
|
|
4105
|
+
}, {
|
|
4106
|
+
F: __dxlog_file16,
|
|
4107
|
+
L: 141,
|
|
4108
|
+
S: this,
|
|
4109
|
+
C: (f, a) => f(...a)
|
|
4110
|
+
});
|
|
4111
|
+
return;
|
|
4112
|
+
}
|
|
4113
|
+
const _guard = _usingCtx.u(await this._getPushMutex(feed.key).acquire());
|
|
4114
|
+
this._remoteLength.set(feedKey, message.length);
|
|
4115
|
+
if (message.length > feed.length) {
|
|
4116
|
+
await this._sendMessage({
|
|
4117
|
+
type: "request",
|
|
4118
|
+
feedKey: feedKey.toHex(),
|
|
4119
|
+
range: {
|
|
4120
|
+
from: feed.length,
|
|
4121
|
+
to: message.length
|
|
4122
|
+
}
|
|
4123
|
+
});
|
|
4124
|
+
} else if (message.length < feed.length) {
|
|
4125
|
+
await this._pushBlocks(feed, message.length, feed.length);
|
|
4126
|
+
}
|
|
4127
|
+
break;
|
|
4128
|
+
} catch (_) {
|
|
4129
|
+
_usingCtx.e = _;
|
|
4130
|
+
} finally {
|
|
4131
|
+
_usingCtx.d();
|
|
4132
|
+
}
|
|
4133
|
+
}
|
|
4134
|
+
case "data": {
|
|
4135
|
+
const feedKey = import_keys10.PublicKey.fromHex(message.feedKey);
|
|
4136
|
+
const feed = this._feeds.get(feedKey);
|
|
4137
|
+
if (!feed) {
|
|
4138
|
+
import_log13.log.warn("Feed not found", {
|
|
4139
|
+
feedKey
|
|
4140
|
+
}, {
|
|
4141
|
+
F: __dxlog_file16,
|
|
4142
|
+
L: 166,
|
|
4143
|
+
S: this,
|
|
4144
|
+
C: (f, a) => f(...a)
|
|
4145
|
+
});
|
|
4146
|
+
return;
|
|
4147
|
+
}
|
|
4148
|
+
await this._integrateBlocks(feed, message.blocks);
|
|
4149
|
+
break;
|
|
4150
|
+
}
|
|
4151
|
+
default: {
|
|
4152
|
+
import_log13.log.warn("Unknown message", {
|
|
4153
|
+
...message
|
|
4154
|
+
}, {
|
|
4155
|
+
F: __dxlog_file16,
|
|
4156
|
+
L: 175,
|
|
4157
|
+
S: this,
|
|
4158
|
+
C: (f, a) => f(...a)
|
|
4159
|
+
});
|
|
4160
|
+
}
|
|
4161
|
+
}
|
|
4162
|
+
});
|
|
4163
|
+
}
|
|
4164
|
+
async _pushBlocks(feed, from, to) {
|
|
4165
|
+
import_log13.log.info("pushing blocks", {
|
|
4166
|
+
feed: feed.key.toHex(),
|
|
4167
|
+
from,
|
|
4168
|
+
to
|
|
4169
|
+
}, {
|
|
4170
|
+
F: __dxlog_file16,
|
|
4171
|
+
L: 182,
|
|
4172
|
+
S: this,
|
|
4173
|
+
C: (f, a) => f(...a)
|
|
4174
|
+
});
|
|
4175
|
+
const blocks = await Promise.all((0, import_util8.rangeFromTo)(from, to).map(async (index) => {
|
|
4176
|
+
const data = await feed.get(index, {
|
|
4177
|
+
valueEncoding: "binary"
|
|
4178
|
+
});
|
|
4179
|
+
(0, import_invariant13.invariant)(data instanceof Uint8Array, void 0, {
|
|
4180
|
+
F: __dxlog_file16,
|
|
4181
|
+
L: 187,
|
|
4182
|
+
S: this,
|
|
4183
|
+
A: [
|
|
4184
|
+
"data instanceof Uint8Array",
|
|
4185
|
+
""
|
|
4186
|
+
]
|
|
4187
|
+
});
|
|
4188
|
+
const proof = await feed.proof(index);
|
|
4189
|
+
return {
|
|
4190
|
+
index,
|
|
4191
|
+
data,
|
|
4192
|
+
nodes: proof.nodes,
|
|
4193
|
+
signature: proof.signature
|
|
4194
|
+
};
|
|
4195
|
+
}));
|
|
4196
|
+
await this._sendMessage({
|
|
4197
|
+
type: "data",
|
|
4198
|
+
feedKey: feed.key.toHex(),
|
|
4199
|
+
blocks
|
|
4200
|
+
});
|
|
4201
|
+
this._remoteLength.set(feed.key, to);
|
|
4202
|
+
}
|
|
4203
|
+
async _integrateBlocks(feed, blocks) {
|
|
4204
|
+
import_log13.log.info("integrating blocks", {
|
|
4205
|
+
feed: feed.key.toHex(),
|
|
4206
|
+
blocks: blocks.length
|
|
4207
|
+
}, {
|
|
4208
|
+
F: __dxlog_file16,
|
|
4209
|
+
L: 208,
|
|
4210
|
+
S: this,
|
|
4211
|
+
C: (f, a) => f(...a)
|
|
4212
|
+
});
|
|
4213
|
+
for (const block of blocks) {
|
|
4214
|
+
if (feed.has(block.index)) {
|
|
4215
|
+
continue;
|
|
4216
|
+
}
|
|
4217
|
+
const blockBuffer = bufferizeBlock(block);
|
|
4218
|
+
await feed.putBuffer(block.index, blockBuffer.data, {
|
|
4219
|
+
nodes: blockBuffer.nodes,
|
|
4220
|
+
signature: blockBuffer.signature
|
|
4221
|
+
}, null);
|
|
4222
|
+
}
|
|
4223
|
+
}
|
|
4224
|
+
async _pushBlocksIfNeeded(feed) {
|
|
4225
|
+
try {
|
|
4226
|
+
var _usingCtx = _using_ctx();
|
|
4227
|
+
const _guard = _usingCtx.u(await this._getPushMutex(feed.key).acquire());
|
|
4228
|
+
if (!this._remoteLength.has(feed.key)) {
|
|
4229
|
+
return;
|
|
4230
|
+
}
|
|
4231
|
+
const remoteLength = this._remoteLength.get(feed.key);
|
|
4232
|
+
if (remoteLength < feed.length) {
|
|
4233
|
+
await this._pushBlocks(feed, remoteLength, feed.length);
|
|
4234
|
+
}
|
|
4235
|
+
} catch (_) {
|
|
4236
|
+
_usingCtx.e = _;
|
|
4237
|
+
} finally {
|
|
4238
|
+
_usingCtx.d();
|
|
4239
|
+
}
|
|
4240
|
+
}
|
|
4241
|
+
};
|
|
4242
|
+
var bufferizeBlock = (block) => ({
|
|
4243
|
+
index: block.index,
|
|
4244
|
+
data: (0, import_util8.arrayToBuffer)(block.data),
|
|
4245
|
+
nodes: block.nodes.map((node) => ({
|
|
4246
|
+
index: node.index,
|
|
4247
|
+
hash: (0, import_util8.arrayToBuffer)(node.hash),
|
|
4248
|
+
size: node.size
|
|
4249
|
+
})),
|
|
4250
|
+
signature: (0, import_util8.arrayToBuffer)(block.signature)
|
|
4251
|
+
});
|
|
4252
|
+
var AutomergeSpaceState = class extends import_context12.Resource {
|
|
4253
|
+
constructor(_onNewRoot) {
|
|
4254
|
+
super();
|
|
4255
|
+
this._onNewRoot = _onNewRoot;
|
|
4256
|
+
this.rootUrl = void 0;
|
|
4257
|
+
this.lastEpoch = void 0;
|
|
4258
|
+
this.onNewEpoch = new import_async15.Event();
|
|
4259
|
+
this._isProcessingRootDocs = false;
|
|
4260
|
+
}
|
|
4261
|
+
async _open(ctx) {
|
|
4262
|
+
}
|
|
4263
|
+
async _close(ctx) {
|
|
4264
|
+
this._isProcessingRootDocs = false;
|
|
4265
|
+
}
|
|
4266
|
+
async processCredential(credential) {
|
|
4267
|
+
if (!(0, import_credentials14.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
4268
|
+
return;
|
|
4269
|
+
}
|
|
4270
|
+
this.lastEpoch = credential;
|
|
4271
|
+
if (credential.subject.assertion.automergeRoot) {
|
|
4272
|
+
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
4273
|
+
if (this._isProcessingRootDocs) {
|
|
4274
|
+
this._onNewRoot(this.rootUrl);
|
|
4275
|
+
}
|
|
4276
|
+
}
|
|
4277
|
+
this.onNewEpoch.emit(credential);
|
|
4278
|
+
}
|
|
4279
|
+
startProcessingRootDocs() {
|
|
4280
|
+
if (this._isProcessingRootDocs) {
|
|
4281
|
+
return;
|
|
4282
|
+
}
|
|
4283
|
+
if (this.rootUrl) {
|
|
4284
|
+
this._onNewRoot(this.rootUrl);
|
|
4285
|
+
}
|
|
4286
|
+
this._isProcessingRootDocs = true;
|
|
4287
|
+
}
|
|
4288
|
+
async ensureEpochInitialized() {
|
|
4289
|
+
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
4290
|
+
}
|
|
4291
|
+
};
|
|
4292
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
4293
|
+
var LOAD_DOC_TIMEOUT = 1e4;
|
|
4294
|
+
var runEpochMigration = async (ctx, context) => {
|
|
4295
|
+
switch (context.migration) {
|
|
4296
|
+
case import_services14.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
4297
|
+
const document = context.echoHost.createDoc();
|
|
4298
|
+
await context.echoHost.flush();
|
|
4299
|
+
return {
|
|
4300
|
+
newRoot: document.url
|
|
4301
|
+
};
|
|
4302
|
+
}
|
|
4303
|
+
case import_services14.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
4304
|
+
if (!context.currentRoot) {
|
|
4305
|
+
throw new Error("Space does not have an automerge root");
|
|
4306
|
+
}
|
|
4307
|
+
const rootHandle = await context.echoHost.loadDoc(ctx, context.currentRoot, {
|
|
4308
|
+
timeout: LOAD_DOC_TIMEOUT
|
|
4309
|
+
});
|
|
4310
|
+
const newRoot = context.echoHost.createDoc(rootHandle.docSync());
|
|
4311
|
+
await context.echoHost.flush();
|
|
4312
|
+
return {
|
|
4313
|
+
newRoot: newRoot.url
|
|
4314
|
+
};
|
|
4315
|
+
}
|
|
4316
|
+
case import_services14.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
4317
|
+
import_log15.log.info("Fragmenting", void 0, {
|
|
4318
|
+
F: __dxlog_file17,
|
|
4319
|
+
L: 64,
|
|
4320
|
+
S: void 0,
|
|
4321
|
+
C: (f, a) => f(...a)
|
|
4322
|
+
});
|
|
4323
|
+
const currentRootUrl = context.currentRoot;
|
|
4324
|
+
const rootHandle = await context.echoHost.loadDoc(ctx, currentRootUrl, {
|
|
4325
|
+
timeout: LOAD_DOC_TIMEOUT
|
|
4326
|
+
});
|
|
4327
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
4328
|
+
const properties = (0, import_echo_db.findInlineObjectOfType)(rootHandle.docSync(), import_echo_schema.TYPE_PROPERTIES);
|
|
4329
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4330
|
+
(0, import_invariant15.invariant)(properties, "Properties not found", {
|
|
4331
|
+
F: __dxlog_file17,
|
|
4332
|
+
L: 75,
|
|
4333
|
+
S: void 0,
|
|
4334
|
+
A: [
|
|
3963
4335
|
"properties",
|
|
3964
4336
|
"'Properties not found'"
|
|
3965
4337
|
]
|
|
@@ -3970,8 +4342,8 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3970
4342
|
properties
|
|
3971
4343
|
])
|
|
3972
4344
|
});
|
|
3973
|
-
(0,
|
|
3974
|
-
F:
|
|
4345
|
+
(0, import_invariant15.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4346
|
+
F: __dxlog_file17,
|
|
3975
4347
|
L: 82,
|
|
3976
4348
|
S: void 0,
|
|
3977
4349
|
A: [
|
|
@@ -4011,8 +4383,8 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
4011
4383
|
const rootHandle = await context.echoHost.loadDoc(ctx, currentRootUrl, {
|
|
4012
4384
|
timeout: LOAD_DOC_TIMEOUT
|
|
4013
4385
|
});
|
|
4014
|
-
(0,
|
|
4015
|
-
F:
|
|
4386
|
+
(0, import_invariant15.invariant)(rootHandle.docSync(), "Root doc not found", {
|
|
4387
|
+
F: __dxlog_file17,
|
|
4016
4388
|
L: 115,
|
|
4017
4389
|
S: void 0,
|
|
4018
4390
|
A: [
|
|
@@ -4026,8 +4398,8 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
4026
4398
|
const handle = await context.echoHost.loadDoc(ctx, url, {
|
|
4027
4399
|
timeout: LOAD_DOC_TIMEOUT
|
|
4028
4400
|
});
|
|
4029
|
-
(0,
|
|
4030
|
-
F:
|
|
4401
|
+
(0, import_invariant15.invariant)(handle.docSync(), void 0, {
|
|
4402
|
+
F: __dxlog_file17,
|
|
4031
4403
|
L: 122,
|
|
4032
4404
|
S: void 0,
|
|
4033
4405
|
A: [
|
|
@@ -4042,12 +4414,12 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
4042
4414
|
});
|
|
4043
4415
|
newRootContent.links[id] = newHandle.url;
|
|
4044
4416
|
} catch (err) {
|
|
4045
|
-
|
|
4417
|
+
import_log15.log.warn("Failed to migrate reference", {
|
|
4046
4418
|
id,
|
|
4047
4419
|
url,
|
|
4048
4420
|
error: err
|
|
4049
4421
|
}, {
|
|
4050
|
-
F:
|
|
4422
|
+
F: __dxlog_file17,
|
|
4051
4423
|
L: 128,
|
|
4052
4424
|
S: void 0,
|
|
4053
4425
|
C: (f, a) => f(...a)
|
|
@@ -4065,8 +4437,8 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
4065
4437
|
};
|
|
4066
4438
|
}
|
|
4067
4439
|
case import_services14.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
|
|
4068
|
-
(0,
|
|
4069
|
-
F:
|
|
4440
|
+
(0, import_invariant15.invariant)(context.newAutomergeRoot, void 0, {
|
|
4441
|
+
F: __dxlog_file17,
|
|
4070
4442
|
L: 143,
|
|
4071
4443
|
S: void 0,
|
|
4072
4444
|
A: [
|
|
@@ -4082,21 +4454,21 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
4082
4454
|
}
|
|
4083
4455
|
return {};
|
|
4084
4456
|
};
|
|
4085
|
-
var
|
|
4457
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
4086
4458
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
4087
4459
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
4088
4460
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
4089
4461
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
4090
4462
|
var NotarizationPlugin = class {
|
|
4091
4463
|
constructor() {
|
|
4092
|
-
this._ctx = new
|
|
4093
|
-
F:
|
|
4464
|
+
this._ctx = new import_context13.Context(void 0, {
|
|
4465
|
+
F: __dxlog_file18,
|
|
4094
4466
|
L: 62
|
|
4095
4467
|
});
|
|
4096
|
-
this._extensionOpened = new
|
|
4468
|
+
this._extensionOpened = new import_async16.Event();
|
|
4097
4469
|
this._extensions = /* @__PURE__ */ new Set();
|
|
4098
|
-
this._processedCredentials = new
|
|
4099
|
-
this._processCredentialsTriggers = new
|
|
4470
|
+
this._processedCredentials = new import_util10.ComplexSet(import_keys12.PublicKey.hash);
|
|
4471
|
+
this._processCredentialsTriggers = new import_util10.ComplexMap(import_keys12.PublicKey.hash);
|
|
4100
4472
|
}
|
|
4101
4473
|
get hasWriter() {
|
|
4102
4474
|
return !!this._writer;
|
|
@@ -4110,16 +4482,16 @@ var NotarizationPlugin = class {
|
|
|
4110
4482
|
* Request credentials to be notarized.
|
|
4111
4483
|
*/
|
|
4112
4484
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
4113
|
-
(0,
|
|
4485
|
+
(0, import_log16.log)("notarize", {
|
|
4114
4486
|
credentials
|
|
4115
4487
|
}, {
|
|
4116
|
-
F:
|
|
4488
|
+
F: __dxlog_file18,
|
|
4117
4489
|
L: 90,
|
|
4118
4490
|
S: this,
|
|
4119
4491
|
C: (f, a) => f(...a)
|
|
4120
4492
|
});
|
|
4121
|
-
(0,
|
|
4122
|
-
F:
|
|
4493
|
+
(0, import_invariant16.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
4494
|
+
F: __dxlog_file18,
|
|
4123
4495
|
L: 91,
|
|
4124
4496
|
S: this,
|
|
4125
4497
|
A: [
|
|
@@ -4127,13 +4499,13 @@ var NotarizationPlugin = class {
|
|
|
4127
4499
|
"'Credentials must have an id'"
|
|
4128
4500
|
]
|
|
4129
4501
|
});
|
|
4130
|
-
const errors = new
|
|
4502
|
+
const errors = new import_async16.Trigger();
|
|
4131
4503
|
const ctx = this._ctx.derive({
|
|
4132
4504
|
onError: (err) => {
|
|
4133
|
-
|
|
4505
|
+
import_log16.log.warn("Notarization error", {
|
|
4134
4506
|
err
|
|
4135
4507
|
}, {
|
|
4136
|
-
F:
|
|
4508
|
+
F: __dxlog_file18,
|
|
4137
4509
|
L: 99,
|
|
4138
4510
|
S: this,
|
|
4139
4511
|
C: (f, a) => f(...a)
|
|
@@ -4144,23 +4516,23 @@ var NotarizationPlugin = class {
|
|
|
4144
4516
|
});
|
|
4145
4517
|
opCtx?.onDispose(() => ctx.dispose());
|
|
4146
4518
|
if (timeout !== 0) {
|
|
4147
|
-
(0,
|
|
4148
|
-
|
|
4519
|
+
(0, import_async16.scheduleTask)(ctx, () => {
|
|
4520
|
+
import_log16.log.warn("Notarization timeout", {
|
|
4149
4521
|
timeout,
|
|
4150
4522
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
4151
4523
|
}, {
|
|
4152
|
-
F:
|
|
4524
|
+
F: __dxlog_file18,
|
|
4153
4525
|
L: 111,
|
|
4154
4526
|
S: this,
|
|
4155
4527
|
C: (f, a) => f(...a)
|
|
4156
4528
|
});
|
|
4157
4529
|
void ctx.dispose();
|
|
4158
|
-
errors.throw(new
|
|
4530
|
+
errors.throw(new import_async16.TimeoutError(timeout, "Notarization timed out"));
|
|
4159
4531
|
}, timeout);
|
|
4160
4532
|
}
|
|
4161
4533
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
4162
4534
|
const peersTried = /* @__PURE__ */ new Set();
|
|
4163
|
-
const notarizeTask = new
|
|
4535
|
+
const notarizeTask = new import_async16.DeferredTask(ctx, async () => {
|
|
4164
4536
|
try {
|
|
4165
4537
|
if (this._extensions.size === 0) {
|
|
4166
4538
|
return;
|
|
@@ -4169,24 +4541,24 @@ var NotarizationPlugin = class {
|
|
|
4169
4541
|
...this._extensions
|
|
4170
4542
|
].find((peer2) => !peersTried.has(peer2));
|
|
4171
4543
|
if (!peer) {
|
|
4172
|
-
|
|
4544
|
+
import_log16.log.info("Exhausted all peers to notarize with", {
|
|
4173
4545
|
retryIn: retryTimeout
|
|
4174
4546
|
}, {
|
|
4175
|
-
F:
|
|
4547
|
+
F: __dxlog_file18,
|
|
4176
4548
|
L: 136,
|
|
4177
4549
|
S: this,
|
|
4178
4550
|
C: (f, a) => f(...a)
|
|
4179
4551
|
});
|
|
4180
4552
|
peersTried.clear();
|
|
4181
|
-
(0,
|
|
4553
|
+
(0, import_async16.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
4182
4554
|
return;
|
|
4183
4555
|
}
|
|
4184
4556
|
peersTried.add(peer);
|
|
4185
|
-
(0,
|
|
4557
|
+
(0, import_log16.log)("try notarizing", {
|
|
4186
4558
|
peer: peer.localPeerId,
|
|
4187
4559
|
credentialId: credentials.map((credential) => credential.id)
|
|
4188
4560
|
}, {
|
|
4189
|
-
F:
|
|
4561
|
+
F: __dxlog_file18,
|
|
4190
4562
|
L: 143,
|
|
4191
4563
|
S: this,
|
|
4192
4564
|
C: (f, a) => f(...a)
|
|
@@ -4194,17 +4566,17 @@ var NotarizationPlugin = class {
|
|
|
4194
4566
|
await peer.rpc.NotarizationService.notarize({
|
|
4195
4567
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
4196
4568
|
});
|
|
4197
|
-
(0,
|
|
4198
|
-
F:
|
|
4569
|
+
(0, import_log16.log)("success", void 0, {
|
|
4570
|
+
F: __dxlog_file18,
|
|
4199
4571
|
L: 147,
|
|
4200
4572
|
S: this,
|
|
4201
4573
|
C: (f, a) => f(...a)
|
|
4202
4574
|
});
|
|
4203
|
-
await (0,
|
|
4575
|
+
await (0, import_async16.sleep)(successDelay);
|
|
4204
4576
|
} catch (err) {
|
|
4205
4577
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
4206
|
-
|
|
4207
|
-
F:
|
|
4578
|
+
import_log16.log.info("error notarizing (recoverable)", err, {
|
|
4579
|
+
F: __dxlog_file18,
|
|
4208
4580
|
L: 151,
|
|
4209
4581
|
S: this,
|
|
4210
4582
|
C: (f, a) => f(...a)
|
|
@@ -4217,12 +4589,12 @@ var NotarizationPlugin = class {
|
|
|
4217
4589
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
4218
4590
|
try {
|
|
4219
4591
|
await Promise.race([
|
|
4220
|
-
(0,
|
|
4592
|
+
(0, import_context13.rejectOnDispose)(ctx),
|
|
4221
4593
|
allNotarized,
|
|
4222
4594
|
errors.wait()
|
|
4223
4595
|
]);
|
|
4224
|
-
(0,
|
|
4225
|
-
F:
|
|
4596
|
+
(0, import_log16.log)("done", void 0, {
|
|
4597
|
+
F: __dxlog_file18,
|
|
4226
4598
|
L: 162,
|
|
4227
4599
|
S: this,
|
|
4228
4600
|
C: (f, a) => f(...a)
|
|
@@ -4243,8 +4615,8 @@ var NotarizationPlugin = class {
|
|
|
4243
4615
|
this._processCredentialsTriggers.delete(credential.id);
|
|
4244
4616
|
}
|
|
4245
4617
|
setWriter(writer) {
|
|
4246
|
-
(0,
|
|
4247
|
-
F:
|
|
4618
|
+
(0, import_invariant16.invariant)(!this._writer, "Writer already set.", {
|
|
4619
|
+
F: __dxlog_file18,
|
|
4248
4620
|
L: 181,
|
|
4249
4621
|
S: this,
|
|
4250
4622
|
A: [
|
|
@@ -4258,7 +4630,7 @@ var NotarizationPlugin = class {
|
|
|
4258
4630
|
if (this._processedCredentials.has(id)) {
|
|
4259
4631
|
return;
|
|
4260
4632
|
}
|
|
4261
|
-
await (0,
|
|
4633
|
+
await (0, import_util10.entry)(this._processCredentialsTriggers, id).orInsert(new import_async16.Trigger()).value.wait();
|
|
4262
4634
|
}
|
|
4263
4635
|
/**
|
|
4264
4636
|
* Requests from other peers to notarize credentials.
|
|
@@ -4268,8 +4640,8 @@ var NotarizationPlugin = class {
|
|
|
4268
4640
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
4269
4641
|
}
|
|
4270
4642
|
for (const credential of request.credentials ?? []) {
|
|
4271
|
-
(0,
|
|
4272
|
-
F:
|
|
4643
|
+
(0, import_invariant16.invariant)(credential.id, "Credential must have an id", {
|
|
4644
|
+
F: __dxlog_file18,
|
|
4273
4645
|
L: 200,
|
|
4274
4646
|
S: this,
|
|
4275
4647
|
A: [
|
|
@@ -4286,10 +4658,10 @@ var NotarizationPlugin = class {
|
|
|
4286
4658
|
createExtension() {
|
|
4287
4659
|
const extension = new NotarizationTeleportExtension({
|
|
4288
4660
|
onOpen: async () => {
|
|
4289
|
-
(0,
|
|
4661
|
+
(0, import_log16.log)("extension opened", {
|
|
4290
4662
|
peer: extension.localPeerId
|
|
4291
4663
|
}, {
|
|
4292
|
-
F:
|
|
4664
|
+
F: __dxlog_file18,
|
|
4293
4665
|
L: 211,
|
|
4294
4666
|
S: this,
|
|
4295
4667
|
C: (f, a) => f(...a)
|
|
@@ -4298,10 +4670,10 @@ var NotarizationPlugin = class {
|
|
|
4298
4670
|
this._extensionOpened.emit();
|
|
4299
4671
|
},
|
|
4300
4672
|
onClose: async () => {
|
|
4301
|
-
(0,
|
|
4673
|
+
(0, import_log16.log)("extension closed", {
|
|
4302
4674
|
peer: extension.localPeerId
|
|
4303
4675
|
}, {
|
|
4304
|
-
F:
|
|
4676
|
+
F: __dxlog_file18,
|
|
4305
4677
|
L: 216,
|
|
4306
4678
|
S: this,
|
|
4307
4679
|
C: (f, a) => f(...a)
|
|
@@ -4317,10 +4689,10 @@ var NotarizationTeleportExtension = class extends import_teleport3.RpcExtension
|
|
|
4317
4689
|
constructor(_params) {
|
|
4318
4690
|
super({
|
|
4319
4691
|
requested: {
|
|
4320
|
-
NotarizationService:
|
|
4692
|
+
NotarizationService: import_protocols11.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
4321
4693
|
},
|
|
4322
4694
|
exposed: {
|
|
4323
|
-
NotarizationService:
|
|
4695
|
+
NotarizationService: import_protocols11.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
4324
4696
|
}
|
|
4325
4697
|
});
|
|
4326
4698
|
this._params = _params;
|
|
@@ -4353,7 +4725,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4353
4725
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4354
4726
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4355
4727
|
}
|
|
4356
|
-
function
|
|
4728
|
+
function _using_ctx2() {
|
|
4357
4729
|
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
4358
4730
|
var err = new Error();
|
|
4359
4731
|
err.name = "SuppressedError";
|
|
@@ -4416,22 +4788,28 @@ function _using_ctx() {
|
|
|
4416
4788
|
}
|
|
4417
4789
|
};
|
|
4418
4790
|
}
|
|
4419
|
-
var
|
|
4791
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
4420
4792
|
var DataSpace = class {
|
|
4421
4793
|
constructor(params) {
|
|
4422
|
-
this._ctx = new
|
|
4423
|
-
F:
|
|
4424
|
-
L:
|
|
4794
|
+
this._ctx = new import_context11.Context(void 0, {
|
|
4795
|
+
F: __dxlog_file19,
|
|
4796
|
+
L: 87
|
|
4425
4797
|
});
|
|
4426
4798
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
4427
4799
|
this._cache = void 0;
|
|
4800
|
+
this._edgeFeedReplicator = void 0;
|
|
4428
4801
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
4429
|
-
this._epochProcessingMutex = new
|
|
4802
|
+
this._epochProcessingMutex = new import_async14.Mutex();
|
|
4430
4803
|
this._state = import_services13.SpaceState.SPACE_CLOSED;
|
|
4431
4804
|
this._databaseRoot = null;
|
|
4432
4805
|
this.error = void 0;
|
|
4433
|
-
this.stateUpdate = new
|
|
4806
|
+
this.stateUpdate = new import_async14.Event();
|
|
4807
|
+
this.postOpen = new import_util9.CallbackCollection();
|
|
4808
|
+
this.preClose = new import_util9.CallbackCollection();
|
|
4434
4809
|
this.metrics = {};
|
|
4810
|
+
this._onFeedAdded = async (feed) => {
|
|
4811
|
+
await this._edgeFeedReplicator.addFeed(feed);
|
|
4812
|
+
};
|
|
4435
4813
|
this._inner = params.inner;
|
|
4436
4814
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
4437
4815
|
this._gossip = params.gossip;
|
|
@@ -4443,17 +4821,23 @@ var DataSpace = class {
|
|
|
4443
4821
|
this._callbacks = params.callbacks ?? {};
|
|
4444
4822
|
this._echoHost = params.echoHost;
|
|
4445
4823
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
4446
|
-
trustedKeysProvider: () => new
|
|
4824
|
+
trustedKeysProvider: () => new import_util9.ComplexSet(import_keys11.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== import_credentials13.SpaceMember.Role.REMOVED).map((member) => member.key)),
|
|
4447
4825
|
update: this._inner.stateUpdate,
|
|
4448
4826
|
authTimeout: import_client_protocol5.AUTH_TIMEOUT
|
|
4449
4827
|
});
|
|
4450
4828
|
this._cache = params.cache;
|
|
4829
|
+
if (params.edgeConnection) {
|
|
4830
|
+
this._edgeFeedReplicator = new EdgeFeedReplicator({
|
|
4831
|
+
messenger: params.edgeConnection,
|
|
4832
|
+
spaceId: this.id
|
|
4833
|
+
});
|
|
4834
|
+
}
|
|
4451
4835
|
this._state = params.initialState;
|
|
4452
|
-
(0,
|
|
4836
|
+
(0, import_log14.log)("new state", {
|
|
4453
4837
|
state: import_services13.SpaceState[this._state]
|
|
4454
4838
|
}, {
|
|
4455
|
-
F:
|
|
4456
|
-
L:
|
|
4839
|
+
F: __dxlog_file19,
|
|
4840
|
+
L: 157,
|
|
4457
4841
|
S: this,
|
|
4458
4842
|
C: (f, a) => f(...a)
|
|
4459
4843
|
});
|
|
@@ -4507,42 +4891,52 @@ var DataSpace = class {
|
|
|
4507
4891
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
4508
4892
|
await this._automergeSpaceState.open();
|
|
4509
4893
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4894
|
+
if (this._edgeFeedReplicator) {
|
|
4895
|
+
this.inner.protocol.feedAdded.append(this._onFeedAdded);
|
|
4896
|
+
}
|
|
4897
|
+
await this._inner.open(new import_context11.Context(void 0, {
|
|
4898
|
+
F: __dxlog_file19,
|
|
4899
|
+
L: 231
|
|
4513
4900
|
}));
|
|
4901
|
+
await this._edgeFeedReplicator?.open();
|
|
4514
4902
|
this._state = import_services13.SpaceState.SPACE_CONTROL_ONLY;
|
|
4515
|
-
(0,
|
|
4903
|
+
(0, import_log14.log)("new state", {
|
|
4516
4904
|
state: import_services13.SpaceState[this._state]
|
|
4517
4905
|
}, {
|
|
4518
|
-
F:
|
|
4519
|
-
L:
|
|
4906
|
+
F: __dxlog_file19,
|
|
4907
|
+
L: 236,
|
|
4520
4908
|
S: this,
|
|
4521
4909
|
C: (f, a) => f(...a)
|
|
4522
4910
|
});
|
|
4523
4911
|
this.stateUpdate.emit();
|
|
4524
4912
|
this.metrics = {};
|
|
4525
4913
|
this.metrics.open = /* @__PURE__ */ new Date();
|
|
4914
|
+
await this.postOpen.callSerial();
|
|
4526
4915
|
}
|
|
4527
4916
|
async close() {
|
|
4528
4917
|
await this._close();
|
|
4529
4918
|
}
|
|
4530
4919
|
async _close() {
|
|
4531
4920
|
await this._callbacks.beforeClose?.();
|
|
4921
|
+
await this.preClose.callSerial();
|
|
4532
4922
|
this._state = import_services13.SpaceState.SPACE_CLOSED;
|
|
4533
|
-
(0,
|
|
4923
|
+
(0, import_log14.log)("new state", {
|
|
4534
4924
|
state: import_services13.SpaceState[this._state]
|
|
4535
4925
|
}, {
|
|
4536
|
-
F:
|
|
4537
|
-
L:
|
|
4926
|
+
F: __dxlog_file19,
|
|
4927
|
+
L: 255,
|
|
4538
4928
|
S: this,
|
|
4539
4929
|
C: (f, a) => f(...a)
|
|
4540
4930
|
});
|
|
4541
4931
|
await this._ctx.dispose();
|
|
4542
|
-
this._ctx = new
|
|
4543
|
-
F:
|
|
4544
|
-
L:
|
|
4932
|
+
this._ctx = new import_context11.Context(void 0, {
|
|
4933
|
+
F: __dxlog_file19,
|
|
4934
|
+
L: 257
|
|
4545
4935
|
});
|
|
4936
|
+
if (this._edgeFeedReplicator) {
|
|
4937
|
+
this.inner.protocol.feedAdded.remove(this._onFeedAdded);
|
|
4938
|
+
}
|
|
4939
|
+
await this._edgeFeedReplicator?.close();
|
|
4546
4940
|
await this.authVerifier.close();
|
|
4547
4941
|
await this._inner.close();
|
|
4548
4942
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -4562,32 +4956,32 @@ var DataSpace = class {
|
|
|
4562
4956
|
* Initialize the data pipeline in a separate task.
|
|
4563
4957
|
*/
|
|
4564
4958
|
initializeDataPipelineAsync() {
|
|
4565
|
-
(0,
|
|
4959
|
+
(0, import_async14.scheduleTask)(this._ctx, async () => {
|
|
4566
4960
|
try {
|
|
4567
4961
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
4568
4962
|
await this.initializeDataPipeline();
|
|
4569
4963
|
} catch (err) {
|
|
4570
|
-
if (err instanceof
|
|
4571
|
-
(0,
|
|
4572
|
-
F:
|
|
4573
|
-
L:
|
|
4964
|
+
if (err instanceof import_protocols10.CancelledError || err instanceof import_context11.ContextDisposedError) {
|
|
4965
|
+
(0, import_log14.log)("data pipeline initialization cancelled", err, {
|
|
4966
|
+
F: __dxlog_file19,
|
|
4967
|
+
L: 295,
|
|
4574
4968
|
S: this,
|
|
4575
4969
|
C: (f, a) => f(...a)
|
|
4576
4970
|
});
|
|
4577
4971
|
return;
|
|
4578
4972
|
}
|
|
4579
|
-
|
|
4580
|
-
F:
|
|
4581
|
-
L:
|
|
4973
|
+
import_log14.log.error("Error initializing data pipeline", err, {
|
|
4974
|
+
F: __dxlog_file19,
|
|
4975
|
+
L: 299,
|
|
4582
4976
|
S: this,
|
|
4583
4977
|
C: (f, a) => f(...a)
|
|
4584
4978
|
});
|
|
4585
4979
|
this._state = import_services13.SpaceState.SPACE_ERROR;
|
|
4586
|
-
(0,
|
|
4980
|
+
(0, import_log14.log)("new state", {
|
|
4587
4981
|
state: import_services13.SpaceState[this._state]
|
|
4588
4982
|
}, {
|
|
4589
|
-
F:
|
|
4590
|
-
L:
|
|
4983
|
+
F: __dxlog_file19,
|
|
4984
|
+
L: 301,
|
|
4591
4985
|
S: this,
|
|
4592
4986
|
C: (f, a) => f(...a)
|
|
4593
4987
|
});
|
|
@@ -4600,19 +4994,19 @@ var DataSpace = class {
|
|
|
4600
4994
|
}
|
|
4601
4995
|
async initializeDataPipeline() {
|
|
4602
4996
|
if (this._state !== import_services13.SpaceState.SPACE_CONTROL_ONLY) {
|
|
4603
|
-
throw new
|
|
4997
|
+
throw new import_protocols10.SystemError("Invalid operation");
|
|
4604
4998
|
}
|
|
4605
4999
|
this._state = import_services13.SpaceState.SPACE_INITIALIZING;
|
|
4606
|
-
(0,
|
|
5000
|
+
(0, import_log14.log)("new state", {
|
|
4607
5001
|
state: import_services13.SpaceState[this._state]
|
|
4608
5002
|
}, {
|
|
4609
|
-
F:
|
|
4610
|
-
L:
|
|
5003
|
+
F: __dxlog_file19,
|
|
5004
|
+
L: 317,
|
|
4611
5005
|
S: this,
|
|
4612
5006
|
C: (f, a) => f(...a)
|
|
4613
5007
|
});
|
|
4614
5008
|
await this._initializeAndReadControlPipeline();
|
|
4615
|
-
await (0,
|
|
5009
|
+
await (0, import_async14.sleep)(1);
|
|
4616
5010
|
const ready = this.stateUpdate.waitForCondition(() => this._state === import_services13.SpaceState.SPACE_READY);
|
|
4617
5011
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4618
5012
|
await ready;
|
|
@@ -4620,11 +5014,11 @@ var DataSpace = class {
|
|
|
4620
5014
|
async _enterReadyState() {
|
|
4621
5015
|
await this._callbacks.beforeReady?.();
|
|
4622
5016
|
this._state = import_services13.SpaceState.SPACE_READY;
|
|
4623
|
-
(0,
|
|
5017
|
+
(0, import_log14.log)("new state", {
|
|
4624
5018
|
state: import_services13.SpaceState[this._state]
|
|
4625
5019
|
}, {
|
|
4626
|
-
F:
|
|
4627
|
-
L:
|
|
5020
|
+
F: __dxlog_file19,
|
|
5021
|
+
L: 336,
|
|
4628
5022
|
S: this,
|
|
4629
5023
|
C: (f, a) => f(...a)
|
|
4630
5024
|
});
|
|
@@ -4638,9 +5032,9 @@ var DataSpace = class {
|
|
|
4638
5032
|
});
|
|
4639
5033
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4640
5034
|
await this._createWritableFeeds();
|
|
4641
|
-
(0,
|
|
4642
|
-
F:
|
|
4643
|
-
L:
|
|
5035
|
+
(0, import_log14.log)("writable feeds created", void 0, {
|
|
5036
|
+
F: __dxlog_file19,
|
|
5037
|
+
L: 352,
|
|
4644
5038
|
S: this,
|
|
4645
5039
|
C: (f, a) => f(...a)
|
|
4646
5040
|
});
|
|
@@ -4698,12 +5092,12 @@ var DataSpace = class {
|
|
|
4698
5092
|
}
|
|
4699
5093
|
}
|
|
4700
5094
|
_onNewAutomergeRoot(rootUrl) {
|
|
4701
|
-
(0,
|
|
5095
|
+
(0, import_log14.log)("loading automerge root doc for space", {
|
|
4702
5096
|
space: this.key,
|
|
4703
5097
|
rootUrl
|
|
4704
5098
|
}, {
|
|
4705
|
-
F:
|
|
4706
|
-
L:
|
|
5099
|
+
F: __dxlog_file19,
|
|
5100
|
+
L: 418,
|
|
4707
5101
|
S: this,
|
|
4708
5102
|
C: (f, a) => f(...a)
|
|
4709
5103
|
});
|
|
@@ -4711,9 +5105,9 @@ var DataSpace = class {
|
|
|
4711
5105
|
queueMicrotask(async () => {
|
|
4712
5106
|
try {
|
|
4713
5107
|
try {
|
|
4714
|
-
var _usingCtx =
|
|
5108
|
+
var _usingCtx = _using_ctx2();
|
|
4715
5109
|
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
4716
|
-
await (0,
|
|
5110
|
+
await (0, import_context11.cancelWithContext)(this._ctx, handle.whenReady());
|
|
4717
5111
|
});
|
|
4718
5112
|
if (this._ctx.disposed) {
|
|
4719
5113
|
return;
|
|
@@ -4722,7 +5116,7 @@ var DataSpace = class {
|
|
|
4722
5116
|
// Ensure only one root is processed at a time.
|
|
4723
5117
|
_usingCtx.u(await this._epochProcessingMutex.acquire())
|
|
4724
5118
|
);
|
|
4725
|
-
const doc = handle.docSync() ?? (0,
|
|
5119
|
+
const doc = handle.docSync() ?? (0, import_invariant14.failedInvariant)();
|
|
4726
5120
|
if (!doc.access?.spaceKey) {
|
|
4727
5121
|
handle.change((doc2) => {
|
|
4728
5122
|
doc2.access = {
|
|
@@ -4746,16 +5140,16 @@ var DataSpace = class {
|
|
|
4746
5140
|
_usingCtx.d();
|
|
4747
5141
|
}
|
|
4748
5142
|
} catch (err) {
|
|
4749
|
-
if (err instanceof
|
|
5143
|
+
if (err instanceof import_context11.ContextDisposedError) {
|
|
4750
5144
|
return;
|
|
4751
5145
|
}
|
|
4752
|
-
|
|
5146
|
+
import_log14.log.warn("error loading automerge root doc", {
|
|
4753
5147
|
space: this.key,
|
|
4754
5148
|
rootUrl,
|
|
4755
5149
|
err
|
|
4756
5150
|
}, {
|
|
4757
|
-
F:
|
|
4758
|
-
L:
|
|
5151
|
+
F: __dxlog_file19,
|
|
5152
|
+
L: 461,
|
|
4759
5153
|
S: this,
|
|
4760
5154
|
C: (f, a) => f(...a)
|
|
4761
5155
|
});
|
|
@@ -4841,11 +5235,11 @@ var DataSpace = class {
|
|
|
4841
5235
|
await this._close();
|
|
4842
5236
|
}
|
|
4843
5237
|
this._state = import_services13.SpaceState.SPACE_INACTIVE;
|
|
4844
|
-
(0,
|
|
5238
|
+
(0, import_log14.log)("new state", {
|
|
4845
5239
|
state: import_services13.SpaceState[this._state]
|
|
4846
5240
|
}, {
|
|
4847
|
-
F:
|
|
4848
|
-
L:
|
|
5241
|
+
F: __dxlog_file19,
|
|
5242
|
+
L: 543,
|
|
4849
5243
|
S: this,
|
|
4850
5244
|
C: (f, a) => f(...a)
|
|
4851
5245
|
});
|
|
@@ -4872,10 +5266,10 @@ _ts_decorate5([
|
|
|
4872
5266
|
})
|
|
4873
5267
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
4874
5268
|
_ts_decorate5([
|
|
4875
|
-
|
|
5269
|
+
import_async14.synchronized
|
|
4876
5270
|
], DataSpace.prototype, "open", null);
|
|
4877
5271
|
_ts_decorate5([
|
|
4878
|
-
|
|
5272
|
+
import_async14.synchronized
|
|
4879
5273
|
], DataSpace.prototype, "close", null);
|
|
4880
5274
|
_ts_decorate5([
|
|
4881
5275
|
import_tracing7.trace.span({
|
|
@@ -4891,13 +5285,13 @@ _ts_decorate5([
|
|
|
4891
5285
|
(0, import_debug3.timed)(1e4)
|
|
4892
5286
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
4893
5287
|
_ts_decorate5([
|
|
4894
|
-
|
|
5288
|
+
import_async14.synchronized
|
|
4895
5289
|
], DataSpace.prototype, "activate", null);
|
|
4896
5290
|
_ts_decorate5([
|
|
4897
|
-
|
|
5291
|
+
import_async14.synchronized
|
|
4898
5292
|
], DataSpace.prototype, "deactivate", null);
|
|
4899
5293
|
DataSpace = _ts_decorate5([
|
|
4900
|
-
(0,
|
|
5294
|
+
(0, import_async14.trackLeaks)("open", "close"),
|
|
4901
5295
|
import_tracing7.trace.resource()
|
|
4902
5296
|
], DataSpace);
|
|
4903
5297
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
@@ -4974,28 +5368,31 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4974
5368
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4975
5369
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4976
5370
|
}
|
|
4977
|
-
var
|
|
5371
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4978
5372
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4979
5373
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4980
5374
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
4981
|
-
var DataSpaceManager = class {
|
|
4982
|
-
constructor(
|
|
4983
|
-
|
|
4984
|
-
this.
|
|
4985
|
-
this.
|
|
4986
|
-
this.
|
|
4987
|
-
this.
|
|
4988
|
-
this.
|
|
4989
|
-
this.
|
|
4990
|
-
this.
|
|
4991
|
-
this.
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
this.
|
|
4996
|
-
this.
|
|
4997
|
-
this.
|
|
4998
|
-
this.
|
|
5375
|
+
var DataSpaceManager = class extends import_context14.Resource {
|
|
5376
|
+
constructor(params) {
|
|
5377
|
+
super();
|
|
5378
|
+
this.updated = new import_async17.Event();
|
|
5379
|
+
this._spaces = new import_util11.ComplexMap(import_keys13.PublicKey.hash);
|
|
5380
|
+
this._instanceId = import_keys13.PublicKey.random().toHex();
|
|
5381
|
+
this._edgeConnection = void 0;
|
|
5382
|
+
this._meshReplicator = void 0;
|
|
5383
|
+
this._echoEdgeReplicator = void 0;
|
|
5384
|
+
this._runtimeParams = void 0;
|
|
5385
|
+
this._spaceManager = params.spaceManager;
|
|
5386
|
+
this._metadataStore = params.metadataStore;
|
|
5387
|
+
this._keyring = params.keyring;
|
|
5388
|
+
this._signingContext = params.signingContext;
|
|
5389
|
+
this._feedStore = params.feedStore;
|
|
5390
|
+
this._echoHost = params.echoHost;
|
|
5391
|
+
this._meshReplicator = params.meshReplicator;
|
|
5392
|
+
this._invitationsManager = params.invitationsManager;
|
|
5393
|
+
this._edgeConnection = params.edgeConnection;
|
|
5394
|
+
this._echoEdgeReplicator = params.echoEdgeReplicator;
|
|
5395
|
+
this._runtimeParams = params.runtimeParams;
|
|
4999
5396
|
import_tracing8.trace.diagnostic({
|
|
5000
5397
|
id: "spaces",
|
|
5001
5398
|
name: "Spaces",
|
|
@@ -5023,72 +5420,69 @@ var DataSpaceManager = class {
|
|
|
5023
5420
|
get spaces() {
|
|
5024
5421
|
return this._spaces;
|
|
5025
5422
|
}
|
|
5026
|
-
async
|
|
5027
|
-
(0,
|
|
5028
|
-
F:
|
|
5029
|
-
L:
|
|
5423
|
+
async _open() {
|
|
5424
|
+
(0, import_log17.log)("open", void 0, {
|
|
5425
|
+
F: __dxlog_file20,
|
|
5426
|
+
L: 187,
|
|
5030
5427
|
S: this,
|
|
5031
5428
|
C: (f, a) => f(...a)
|
|
5032
5429
|
});
|
|
5033
|
-
|
|
5430
|
+
import_log17.log.trace("dxos.echo.data-space-manager.open", import_protocols12.trace.begin({
|
|
5034
5431
|
id: this._instanceId
|
|
5035
5432
|
}), {
|
|
5036
|
-
F:
|
|
5037
|
-
L:
|
|
5433
|
+
F: __dxlog_file20,
|
|
5434
|
+
L: 188,
|
|
5038
5435
|
S: this,
|
|
5039
5436
|
C: (f, a) => f(...a)
|
|
5040
5437
|
});
|
|
5041
|
-
(0,
|
|
5438
|
+
(0, import_log17.log)("metadata loaded", {
|
|
5042
5439
|
spaces: this._metadataStore.spaces.length
|
|
5043
5440
|
}, {
|
|
5044
|
-
F:
|
|
5045
|
-
L:
|
|
5441
|
+
F: __dxlog_file20,
|
|
5442
|
+
L: 189,
|
|
5046
5443
|
S: this,
|
|
5047
5444
|
C: (f, a) => f(...a)
|
|
5048
5445
|
});
|
|
5049
|
-
await (0,
|
|
5446
|
+
await (0, import_util11.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
5050
5447
|
try {
|
|
5051
|
-
(0,
|
|
5448
|
+
(0, import_log17.log)("load space", {
|
|
5052
5449
|
spaceMetadata
|
|
5053
5450
|
}, {
|
|
5054
|
-
F:
|
|
5055
|
-
L:
|
|
5451
|
+
F: __dxlog_file20,
|
|
5452
|
+
L: 193,
|
|
5056
5453
|
S: this,
|
|
5057
5454
|
C: (f, a) => f(...a)
|
|
5058
5455
|
});
|
|
5059
5456
|
await this._constructSpace(spaceMetadata);
|
|
5060
5457
|
} catch (err) {
|
|
5061
|
-
|
|
5458
|
+
import_log17.log.error("Error loading space", {
|
|
5062
5459
|
spaceMetadata,
|
|
5063
5460
|
err
|
|
5064
5461
|
}, {
|
|
5065
|
-
F:
|
|
5066
|
-
L:
|
|
5462
|
+
F: __dxlog_file20,
|
|
5463
|
+
L: 196,
|
|
5067
5464
|
S: this,
|
|
5068
5465
|
C: (f, a) => f(...a)
|
|
5069
5466
|
});
|
|
5070
5467
|
}
|
|
5071
5468
|
});
|
|
5072
|
-
this._isOpen = true;
|
|
5073
5469
|
this.updated.emit();
|
|
5074
|
-
|
|
5470
|
+
import_log17.log.trace("dxos.echo.data-space-manager.open", import_protocols12.trace.end({
|
|
5075
5471
|
id: this._instanceId
|
|
5076
5472
|
}), {
|
|
5077
|
-
F:
|
|
5078
|
-
L:
|
|
5473
|
+
F: __dxlog_file20,
|
|
5474
|
+
L: 202,
|
|
5079
5475
|
S: this,
|
|
5080
5476
|
C: (f, a) => f(...a)
|
|
5081
5477
|
});
|
|
5082
5478
|
}
|
|
5083
|
-
async
|
|
5084
|
-
(0,
|
|
5085
|
-
F:
|
|
5086
|
-
L:
|
|
5479
|
+
async _close() {
|
|
5480
|
+
(0, import_log17.log)("close", void 0, {
|
|
5481
|
+
F: __dxlog_file20,
|
|
5482
|
+
L: 207,
|
|
5087
5483
|
S: this,
|
|
5088
5484
|
C: (f, a) => f(...a)
|
|
5089
5485
|
});
|
|
5090
|
-
this._isOpen = false;
|
|
5091
|
-
await this._ctx.dispose();
|
|
5092
5486
|
for (const space of this._spaces.values()) {
|
|
5093
5487
|
await space.close();
|
|
5094
5488
|
}
|
|
@@ -5098,12 +5492,12 @@ var DataSpaceManager = class {
|
|
|
5098
5492
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
5099
5493
|
*/
|
|
5100
5494
|
async createSpace() {
|
|
5101
|
-
(0,
|
|
5102
|
-
F:
|
|
5103
|
-
L:
|
|
5495
|
+
(0, import_invariant17.invariant)(this._lifecycleState === import_context14.LifecycleState.OPEN, "Not open.", {
|
|
5496
|
+
F: __dxlog_file20,
|
|
5497
|
+
L: 219,
|
|
5104
5498
|
S: this,
|
|
5105
5499
|
A: [
|
|
5106
|
-
"this.
|
|
5500
|
+
"this._lifecycleState === LifecycleState.OPEN",
|
|
5107
5501
|
"'Not open.'"
|
|
5108
5502
|
]
|
|
5109
5503
|
});
|
|
@@ -5117,11 +5511,11 @@ var DataSpaceManager = class {
|
|
|
5117
5511
|
dataFeedKey,
|
|
5118
5512
|
state: import_services15.SpaceState.SPACE_ACTIVE
|
|
5119
5513
|
};
|
|
5120
|
-
(0,
|
|
5514
|
+
(0, import_log17.log)("creating space...", {
|
|
5121
5515
|
spaceKey
|
|
5122
5516
|
}, {
|
|
5123
|
-
F:
|
|
5124
|
-
L:
|
|
5517
|
+
F: __dxlog_file20,
|
|
5518
|
+
L: 231,
|
|
5125
5519
|
S: this,
|
|
5126
5520
|
C: (f, a) => f(...a)
|
|
5127
5521
|
});
|
|
@@ -5131,9 +5525,9 @@ var DataSpaceManager = class {
|
|
|
5131
5525
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
|
|
5132
5526
|
await this._metadataStore.addSpace(metadata);
|
|
5133
5527
|
const memberCredential = credentials[1];
|
|
5134
|
-
(0,
|
|
5135
|
-
F:
|
|
5136
|
-
L:
|
|
5528
|
+
(0, import_invariant17.invariant)((0, import_credentials15.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5529
|
+
F: __dxlog_file20,
|
|
5530
|
+
L: 241,
|
|
5137
5531
|
S: this,
|
|
5138
5532
|
A: [
|
|
5139
5533
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -5160,12 +5554,12 @@ var DataSpaceManager = class {
|
|
|
5160
5554
|
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
5161
5555
|
}
|
|
5162
5556
|
default:
|
|
5163
|
-
|
|
5557
|
+
import_log17.log.warn("unknown space version", {
|
|
5164
5558
|
version: space.databaseRoot.getVersion(),
|
|
5165
5559
|
spaceId: space.id
|
|
5166
5560
|
}, {
|
|
5167
|
-
F:
|
|
5168
|
-
L:
|
|
5561
|
+
F: __dxlog_file20,
|
|
5562
|
+
L: 266,
|
|
5169
5563
|
S: this,
|
|
5170
5564
|
C: (f, a) => f(...a)
|
|
5171
5565
|
});
|
|
@@ -5188,7 +5582,7 @@ var DataSpaceManager = class {
|
|
|
5188
5582
|
};
|
|
5189
5583
|
const propertiesId = (0, import_echo_schema2.generateEchoId)();
|
|
5190
5584
|
document.change((doc) => {
|
|
5191
|
-
(0,
|
|
5585
|
+
(0, import_util11.assignDeep)(doc, [
|
|
5192
5586
|
"objects",
|
|
5193
5587
|
propertiesId
|
|
5194
5588
|
], properties);
|
|
@@ -5198,9 +5592,9 @@ var DataSpaceManager = class {
|
|
|
5198
5592
|
}
|
|
5199
5593
|
async _getSpaceRootDocument(space) {
|
|
5200
5594
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5201
|
-
(0,
|
|
5202
|
-
F:
|
|
5203
|
-
L:
|
|
5595
|
+
(0, import_invariant17.invariant)(automergeIndex, void 0, {
|
|
5596
|
+
F: __dxlog_file20,
|
|
5597
|
+
L: 299,
|
|
5204
5598
|
S: this,
|
|
5205
5599
|
A: [
|
|
5206
5600
|
"automergeIndex",
|
|
@@ -5213,26 +5607,26 @@ var DataSpaceManager = class {
|
|
|
5213
5607
|
}
|
|
5214
5608
|
// TODO(burdon): Rename join space.
|
|
5215
5609
|
async acceptSpace(opts) {
|
|
5216
|
-
(0,
|
|
5610
|
+
(0, import_log17.log)("accept space", {
|
|
5217
5611
|
opts
|
|
5218
5612
|
}, {
|
|
5219
|
-
F:
|
|
5220
|
-
L:
|
|
5613
|
+
F: __dxlog_file20,
|
|
5614
|
+
L: 308,
|
|
5221
5615
|
S: this,
|
|
5222
5616
|
C: (f, a) => f(...a)
|
|
5223
5617
|
});
|
|
5224
|
-
(0,
|
|
5225
|
-
F:
|
|
5226
|
-
L:
|
|
5618
|
+
(0, import_invariant17.invariant)(this._lifecycleState === import_context14.LifecycleState.OPEN, "Not open.", {
|
|
5619
|
+
F: __dxlog_file20,
|
|
5620
|
+
L: 309,
|
|
5227
5621
|
S: this,
|
|
5228
5622
|
A: [
|
|
5229
|
-
"this.
|
|
5623
|
+
"this._lifecycleState === LifecycleState.OPEN",
|
|
5230
5624
|
"'Not open.'"
|
|
5231
5625
|
]
|
|
5232
5626
|
});
|
|
5233
|
-
(0,
|
|
5234
|
-
F:
|
|
5235
|
-
L:
|
|
5627
|
+
(0, import_invariant17.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
5628
|
+
F: __dxlog_file20,
|
|
5629
|
+
L: 310,
|
|
5236
5630
|
S: this,
|
|
5237
5631
|
A: [
|
|
5238
5632
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -5254,9 +5648,9 @@ var DataSpaceManager = class {
|
|
|
5254
5648
|
}
|
|
5255
5649
|
async admitMember(options) {
|
|
5256
5650
|
const space = this._spaceManager.spaces.get(options.spaceKey);
|
|
5257
|
-
(0,
|
|
5258
|
-
F:
|
|
5259
|
-
L:
|
|
5651
|
+
(0, import_invariant17.invariant)(space, void 0, {
|
|
5652
|
+
F: __dxlog_file20,
|
|
5653
|
+
L: 330,
|
|
5260
5654
|
S: this,
|
|
5261
5655
|
A: [
|
|
5262
5656
|
"space",
|
|
@@ -5264,12 +5658,12 @@ var DataSpaceManager = class {
|
|
|
5264
5658
|
]
|
|
5265
5659
|
});
|
|
5266
5660
|
if (space.spaceState.getMemberRole(options.identityKey) !== import_credentials16.SpaceMember.Role.REMOVED) {
|
|
5267
|
-
throw new
|
|
5661
|
+
throw new import_protocols12.AlreadyJoinedError();
|
|
5268
5662
|
}
|
|
5269
5663
|
const credentials = await (0, import_credentials15.createAdmissionCredentials)(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
|
|
5270
|
-
(0,
|
|
5271
|
-
F:
|
|
5272
|
-
L:
|
|
5664
|
+
(0, import_invariant17.invariant)(credentials[0].credential, void 0, {
|
|
5665
|
+
F: __dxlog_file20,
|
|
5666
|
+
L: 349,
|
|
5273
5667
|
S: this,
|
|
5274
5668
|
A: [
|
|
5275
5669
|
"credentials[0].credential",
|
|
@@ -5277,9 +5671,9 @@ var DataSpaceManager = class {
|
|
|
5277
5671
|
]
|
|
5278
5672
|
});
|
|
5279
5673
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5280
|
-
(0,
|
|
5281
|
-
F:
|
|
5282
|
-
L:
|
|
5674
|
+
(0, import_invariant17.invariant)((0, import_credentials15.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5675
|
+
F: __dxlog_file20,
|
|
5676
|
+
L: 351,
|
|
5283
5677
|
S: this,
|
|
5284
5678
|
A: [
|
|
5285
5679
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -5295,7 +5689,7 @@ var DataSpaceManager = class {
|
|
|
5295
5689
|
* TODO(dmaretskyi): Consider removing.
|
|
5296
5690
|
*/
|
|
5297
5691
|
async waitUntilSpaceReady(spaceKey) {
|
|
5298
|
-
await (0,
|
|
5692
|
+
await (0, import_context14.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
5299
5693
|
const space = this._spaces.get(spaceKey);
|
|
5300
5694
|
return !!space && space.state === import_services15.SpaceState.SPACE_READY;
|
|
5301
5695
|
}));
|
|
@@ -5313,11 +5707,11 @@ var DataSpaceManager = class {
|
|
|
5313
5707
|
});
|
|
5314
5708
|
}
|
|
5315
5709
|
async _constructSpace(metadata) {
|
|
5316
|
-
(0,
|
|
5710
|
+
(0, import_log17.log)("construct space", {
|
|
5317
5711
|
metadata
|
|
5318
5712
|
}, {
|
|
5319
|
-
F:
|
|
5320
|
-
L:
|
|
5713
|
+
F: __dxlog_file20,
|
|
5714
|
+
L: 386,
|
|
5321
5715
|
S: this,
|
|
5322
5716
|
C: (f, a) => f(...a)
|
|
5323
5717
|
});
|
|
@@ -5325,8 +5719,8 @@ var DataSpaceManager = class {
|
|
|
5325
5719
|
localPeerId: this._signingContext.deviceKey
|
|
5326
5720
|
});
|
|
5327
5721
|
const presence = new import_teleport_extension_gossip2.Presence({
|
|
5328
|
-
announceInterval: this.
|
|
5329
|
-
offlineTimeout: this.
|
|
5722
|
+
announceInterval: this._runtimeParams?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
|
|
5723
|
+
offlineTimeout: this._runtimeParams?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
|
|
5330
5724
|
identityKey: this._signingContext.identityKey,
|
|
5331
5725
|
gossip
|
|
5332
5726
|
});
|
|
@@ -5342,29 +5736,25 @@ var DataSpaceManager = class {
|
|
|
5342
5736
|
swarmIdentity: {
|
|
5343
5737
|
peerKey: this._signingContext.deviceKey,
|
|
5344
5738
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
5345
|
-
credentialAuthenticator: (0,
|
|
5739
|
+
credentialAuthenticator: (0, import_util11.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
5346
5740
|
},
|
|
5347
5741
|
onAuthorizedConnection: (session) => queueMicrotask(async () => {
|
|
5348
5742
|
try {
|
|
5349
5743
|
if (!session.isOpen) {
|
|
5350
5744
|
return;
|
|
5351
5745
|
}
|
|
5352
|
-
session.addExtension("dxos.mesh.teleport.admission-discovery", new
|
|
5746
|
+
session.addExtension("dxos.mesh.teleport.admission-discovery", new import_echo_pipeline3.CredentialServerExtension(space));
|
|
5353
5747
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
5354
5748
|
remotePeerId: session.remotePeerId
|
|
5355
5749
|
}));
|
|
5356
5750
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
5357
|
-
await this.
|
|
5358
|
-
if (!session.isOpen) {
|
|
5359
|
-
return;
|
|
5360
|
-
}
|
|
5361
|
-
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
5751
|
+
await this._connectEchoMeshReplicator(space, session);
|
|
5362
5752
|
} catch (err) {
|
|
5363
|
-
|
|
5753
|
+
import_log17.log.warn("error on authorized connection", {
|
|
5364
5754
|
err
|
|
5365
5755
|
}, {
|
|
5366
|
-
F:
|
|
5367
|
-
L:
|
|
5756
|
+
F: __dxlog_file20,
|
|
5757
|
+
L: 427,
|
|
5368
5758
|
S: this,
|
|
5369
5759
|
C: (f, a) => f(...a)
|
|
5370
5760
|
});
|
|
@@ -5372,9 +5762,9 @@ var DataSpaceManager = class {
|
|
|
5372
5762
|
}
|
|
5373
5763
|
}),
|
|
5374
5764
|
onAuthFailure: () => {
|
|
5375
|
-
|
|
5376
|
-
F:
|
|
5377
|
-
L:
|
|
5765
|
+
import_log17.log.warn("auth failure", void 0, {
|
|
5766
|
+
F: __dxlog_file20,
|
|
5767
|
+
L: 432,
|
|
5378
5768
|
S: this,
|
|
5379
5769
|
C: (f, a) => f(...a)
|
|
5380
5770
|
});
|
|
@@ -5403,26 +5793,26 @@ var DataSpaceManager = class {
|
|
|
5403
5793
|
signingContext: this._signingContext,
|
|
5404
5794
|
callbacks: {
|
|
5405
5795
|
beforeReady: async () => {
|
|
5406
|
-
(0,
|
|
5796
|
+
(0, import_log17.log)("before space ready", {
|
|
5407
5797
|
space: space.key
|
|
5408
5798
|
}, {
|
|
5409
|
-
F:
|
|
5410
|
-
L:
|
|
5799
|
+
F: __dxlog_file20,
|
|
5800
|
+
L: 459,
|
|
5411
5801
|
S: this,
|
|
5412
5802
|
C: (f, a) => f(...a)
|
|
5413
5803
|
});
|
|
5414
5804
|
},
|
|
5415
5805
|
afterReady: async () => {
|
|
5416
|
-
(0,
|
|
5806
|
+
(0, import_log17.log)("after space ready", {
|
|
5417
5807
|
space: space.key,
|
|
5418
|
-
open: this.
|
|
5808
|
+
open: this._lifecycleState === import_context14.LifecycleState.OPEN
|
|
5419
5809
|
}, {
|
|
5420
|
-
F:
|
|
5421
|
-
L:
|
|
5810
|
+
F: __dxlog_file20,
|
|
5811
|
+
L: 462,
|
|
5422
5812
|
S: this,
|
|
5423
5813
|
C: (f, a) => f(...a)
|
|
5424
5814
|
});
|
|
5425
|
-
if (this.
|
|
5815
|
+
if (this._lifecycleState === import_context14.LifecycleState.OPEN) {
|
|
5426
5816
|
await this._createDelegatedInvitations(dataSpace, [
|
|
5427
5817
|
...space.spaceState.invitations.entries()
|
|
5428
5818
|
]);
|
|
@@ -5433,17 +5823,24 @@ var DataSpaceManager = class {
|
|
|
5433
5823
|
}
|
|
5434
5824
|
},
|
|
5435
5825
|
beforeClose: async () => {
|
|
5436
|
-
(0,
|
|
5826
|
+
(0, import_log17.log)("before space close", {
|
|
5437
5827
|
space: space.key
|
|
5438
5828
|
}, {
|
|
5439
|
-
F:
|
|
5440
|
-
L:
|
|
5829
|
+
F: __dxlog_file20,
|
|
5830
|
+
L: 470,
|
|
5441
5831
|
S: this,
|
|
5442
5832
|
C: (f, a) => f(...a)
|
|
5443
5833
|
});
|
|
5444
5834
|
}
|
|
5445
5835
|
},
|
|
5446
|
-
cache: metadata.cache
|
|
5836
|
+
cache: metadata.cache,
|
|
5837
|
+
edgeConnection: this._edgeConnection
|
|
5838
|
+
});
|
|
5839
|
+
dataSpace.postOpen.append(async () => {
|
|
5840
|
+
await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
|
|
5841
|
+
});
|
|
5842
|
+
dataSpace.preClose.append(async () => {
|
|
5843
|
+
await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
|
|
5447
5844
|
});
|
|
5448
5845
|
presence.newPeer.on((peerState) => {
|
|
5449
5846
|
if (dataSpace.state === import_services15.SpaceState.SPACE_READY) {
|
|
@@ -5456,6 +5853,24 @@ var DataSpaceManager = class {
|
|
|
5456
5853
|
this._spaces.set(metadata.key, dataSpace);
|
|
5457
5854
|
return dataSpace;
|
|
5458
5855
|
}
|
|
5856
|
+
async _connectEchoMeshReplicator(space, session) {
|
|
5857
|
+
const replicator = this._meshReplicator;
|
|
5858
|
+
if (!replicator) {
|
|
5859
|
+
import_log17.log.warn("p2p automerge replication disabled", {
|
|
5860
|
+
space: space.key
|
|
5861
|
+
}, {
|
|
5862
|
+
F: __dxlog_file20,
|
|
5863
|
+
L: 500,
|
|
5864
|
+
S: this,
|
|
5865
|
+
C: (f, a) => f(...a)
|
|
5866
|
+
});
|
|
5867
|
+
return;
|
|
5868
|
+
}
|
|
5869
|
+
await replicator.authorizeDevice(space.key, session.remotePeerId);
|
|
5870
|
+
if (session.isOpen) {
|
|
5871
|
+
session.addExtension("dxos.mesh.teleport.automerge", replicator.createExtension());
|
|
5872
|
+
}
|
|
5873
|
+
}
|
|
5459
5874
|
_handleMemberRoleChanges(presence, spaceProtocol, memberInfo) {
|
|
5460
5875
|
let closedSessions = 0;
|
|
5461
5876
|
for (const member of memberInfo) {
|
|
@@ -5468,17 +5883,17 @@ var DataSpaceManager = class {
|
|
|
5468
5883
|
return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline3.AuthStatus.FAILURE)) ?? false;
|
|
5469
5884
|
});
|
|
5470
5885
|
sessionsToClose.forEach((session) => {
|
|
5471
|
-
void session.close().catch(
|
|
5886
|
+
void session.close().catch(import_log17.log.error);
|
|
5472
5887
|
});
|
|
5473
5888
|
closedSessions += sessionsToClose.length;
|
|
5474
5889
|
}
|
|
5475
|
-
(0,
|
|
5890
|
+
(0, import_log17.log)("processed member role changes", {
|
|
5476
5891
|
roleChangeCount: memberInfo.length,
|
|
5477
5892
|
peersOnline: presence.getPeersOnline().length,
|
|
5478
5893
|
closedSessions
|
|
5479
5894
|
}, {
|
|
5480
|
-
F:
|
|
5481
|
-
L:
|
|
5895
|
+
F: __dxlog_file20,
|
|
5896
|
+
L: 526,
|
|
5482
5897
|
S: this,
|
|
5483
5898
|
C: (f, a) => f(...a)
|
|
5484
5899
|
});
|
|
@@ -5489,15 +5904,15 @@ var DataSpaceManager = class {
|
|
|
5489
5904
|
if (role === import_credentials16.SpaceMember.Role.REMOVED) {
|
|
5490
5905
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5491
5906
|
if (session != null) {
|
|
5492
|
-
(0,
|
|
5907
|
+
(0, import_log17.log)("closing a session with a removed peer", {
|
|
5493
5908
|
peerId: peerState.peerId
|
|
5494
5909
|
}, {
|
|
5495
|
-
F:
|
|
5496
|
-
L:
|
|
5910
|
+
F: __dxlog_file20,
|
|
5911
|
+
L: 540,
|
|
5497
5912
|
S: this,
|
|
5498
5913
|
C: (f, a) => f(...a)
|
|
5499
5914
|
});
|
|
5500
|
-
void session.close().catch(
|
|
5915
|
+
void session.close().catch(import_log17.log.error);
|
|
5501
5916
|
}
|
|
5502
5917
|
}
|
|
5503
5918
|
}
|
|
@@ -5538,21 +5953,21 @@ var DataSpaceManager = class {
|
|
|
5538
5953
|
}
|
|
5539
5954
|
};
|
|
5540
5955
|
_ts_decorate6([
|
|
5541
|
-
|
|
5542
|
-
], DataSpaceManager.prototype, "
|
|
5956
|
+
import_async17.synchronized
|
|
5957
|
+
], DataSpaceManager.prototype, "_open", null);
|
|
5543
5958
|
_ts_decorate6([
|
|
5544
|
-
|
|
5545
|
-
], DataSpaceManager.prototype, "
|
|
5959
|
+
import_async17.synchronized
|
|
5960
|
+
], DataSpaceManager.prototype, "_close", null);
|
|
5546
5961
|
_ts_decorate6([
|
|
5547
|
-
|
|
5962
|
+
import_async17.synchronized
|
|
5548
5963
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
5549
5964
|
_ts_decorate6([
|
|
5550
|
-
|
|
5965
|
+
import_async17.synchronized
|
|
5551
5966
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
5552
5967
|
DataSpaceManager = _ts_decorate6([
|
|
5553
|
-
(0,
|
|
5968
|
+
(0, import_async17.trackLeaks)("open", "close")
|
|
5554
5969
|
], DataSpaceManager);
|
|
5555
|
-
var
|
|
5970
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5556
5971
|
var SpacesServiceImpl = class {
|
|
5557
5972
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5558
5973
|
this._identityManager = _identityManager;
|
|
@@ -5568,7 +5983,7 @@ var SpacesServiceImpl = class {
|
|
|
5568
5983
|
}
|
|
5569
5984
|
async updateSpace({ spaceKey, state }) {
|
|
5570
5985
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5571
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
5986
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols13.SpaceNotFoundError(spaceKey));
|
|
5572
5987
|
if (state) {
|
|
5573
5988
|
switch (state) {
|
|
5574
5989
|
case import_services16.SpaceState.SPACE_ACTIVE:
|
|
@@ -5578,7 +5993,7 @@ var SpacesServiceImpl = class {
|
|
|
5578
5993
|
await space.deactivate();
|
|
5579
5994
|
break;
|
|
5580
5995
|
default:
|
|
5581
|
-
throw new
|
|
5996
|
+
throw new import_protocols13.ApiError("Invalid space state");
|
|
5582
5997
|
}
|
|
5583
5998
|
}
|
|
5584
5999
|
}
|
|
@@ -5586,17 +6001,17 @@ var SpacesServiceImpl = class {
|
|
|
5586
6001
|
const identity = this._requireIdentity();
|
|
5587
6002
|
const space = this._spaceManager.spaces.get(request.spaceKey);
|
|
5588
6003
|
if (space == null) {
|
|
5589
|
-
throw new
|
|
6004
|
+
throw new import_protocols13.SpaceNotFoundError(request.spaceKey);
|
|
5590
6005
|
}
|
|
5591
6006
|
if (!space.spaceState.hasMembershipManagementPermission(identity.identityKey)) {
|
|
5592
|
-
throw new
|
|
6007
|
+
throw new import_protocols13.AuthorizationError("No member management permission.", {
|
|
5593
6008
|
spaceKey: space.key,
|
|
5594
6009
|
role: space.spaceState.getMemberRole(identity.identityKey)
|
|
5595
6010
|
});
|
|
5596
6011
|
}
|
|
5597
6012
|
const credentials = await (0, import_credentials19.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5598
|
-
(0,
|
|
5599
|
-
F:
|
|
6013
|
+
(0, import_invariant18.invariant)(credentials[0].credential, void 0, {
|
|
6014
|
+
F: __dxlog_file21,
|
|
5600
6015
|
L: 102,
|
|
5601
6016
|
S: this,
|
|
5602
6017
|
A: [
|
|
@@ -5605,8 +6020,8 @@ var SpacesServiceImpl = class {
|
|
|
5605
6020
|
]
|
|
5606
6021
|
});
|
|
5607
6022
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5608
|
-
(0,
|
|
5609
|
-
F:
|
|
6023
|
+
(0, import_invariant18.invariant)((0, import_credentials19.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
6024
|
+
F: __dxlog_file21,
|
|
5610
6025
|
L: 104,
|
|
5611
6026
|
S: this,
|
|
5612
6027
|
A: [
|
|
@@ -5618,13 +6033,13 @@ var SpacesServiceImpl = class {
|
|
|
5618
6033
|
}
|
|
5619
6034
|
querySpaces() {
|
|
5620
6035
|
return new import_codec_protobuf11.Stream(({ next, ctx }) => {
|
|
5621
|
-
const scheduler = new
|
|
6036
|
+
const scheduler = new import_async18.UpdateScheduler(ctx, async () => {
|
|
5622
6037
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5623
6038
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5624
|
-
(0,
|
|
6039
|
+
(0, import_log18.log)("update", () => ({
|
|
5625
6040
|
ids: spaces.map((space) => space.id)
|
|
5626
6041
|
}), {
|
|
5627
|
-
F:
|
|
6042
|
+
F: __dxlog_file21,
|
|
5628
6043
|
L: 115,
|
|
5629
6044
|
S: this,
|
|
5630
6045
|
C: (f, a) => f(...a)
|
|
@@ -5636,9 +6051,9 @@ var SpacesServiceImpl = class {
|
|
|
5636
6051
|
}, {
|
|
5637
6052
|
maxFrequency: process.env.NODE_ENV === "test" ? void 0 : 2
|
|
5638
6053
|
});
|
|
5639
|
-
(0,
|
|
6054
|
+
(0, import_async18.scheduleTask)(ctx, async () => {
|
|
5640
6055
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5641
|
-
const subscriptions = new
|
|
6056
|
+
const subscriptions = new import_async18.EventSubscriptions();
|
|
5642
6057
|
ctx.onDispose(() => subscriptions.clear());
|
|
5643
6058
|
const subscribeSpaces = () => {
|
|
5644
6059
|
subscriptions.clear();
|
|
@@ -5673,14 +6088,14 @@ var SpacesServiceImpl = class {
|
|
|
5673
6088
|
}
|
|
5674
6089
|
async postMessage({ spaceKey, channel, message }) {
|
|
5675
6090
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5676
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
6091
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols13.SpaceNotFoundError(spaceKey));
|
|
5677
6092
|
await space.postMessage(getChannelId(channel), message);
|
|
5678
6093
|
}
|
|
5679
6094
|
subscribeMessages({ spaceKey, channel }) {
|
|
5680
6095
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
5681
|
-
(0,
|
|
6096
|
+
(0, import_async18.scheduleTask)(ctx, async () => {
|
|
5682
6097
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5683
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
6098
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols13.SpaceNotFoundError(spaceKey));
|
|
5684
6099
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
5685
6100
|
next(message);
|
|
5686
6101
|
});
|
|
@@ -5690,14 +6105,14 @@ var SpacesServiceImpl = class {
|
|
|
5690
6105
|
}
|
|
5691
6106
|
queryCredentials({ spaceKey, noTail }) {
|
|
5692
6107
|
return new import_codec_protobuf11.Stream(({ ctx, next, close }) => {
|
|
5693
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
6108
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols13.SpaceNotFoundError(spaceKey));
|
|
5694
6109
|
const processor = {
|
|
5695
6110
|
processCredential: async (credential) => {
|
|
5696
6111
|
next(credential);
|
|
5697
6112
|
}
|
|
5698
6113
|
};
|
|
5699
6114
|
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
5700
|
-
(0,
|
|
6115
|
+
(0, import_async18.scheduleTask)(ctx, async () => {
|
|
5701
6116
|
await space.spaceState.addCredentialProcessor(processor);
|
|
5702
6117
|
if (noTail) {
|
|
5703
6118
|
close();
|
|
@@ -5706,7 +6121,7 @@ var SpacesServiceImpl = class {
|
|
|
5706
6121
|
});
|
|
5707
6122
|
}
|
|
5708
6123
|
async writeCredentials({ spaceKey, credentials }) {
|
|
5709
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
6124
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols13.SpaceNotFoundError(spaceKey));
|
|
5710
6125
|
for (const credential of credentials ?? []) {
|
|
5711
6126
|
if (credential.proof) {
|
|
5712
6127
|
await space.controlPipeline.writer.write({
|
|
@@ -5715,8 +6130,8 @@ var SpacesServiceImpl = class {
|
|
|
5715
6130
|
}
|
|
5716
6131
|
});
|
|
5717
6132
|
} else {
|
|
5718
|
-
(0,
|
|
5719
|
-
F:
|
|
6133
|
+
(0, import_invariant18.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
6134
|
+
F: __dxlog_file21,
|
|
5720
6135
|
L: 213,
|
|
5721
6136
|
S: this,
|
|
5722
6137
|
A: [
|
|
@@ -5724,8 +6139,8 @@ var SpacesServiceImpl = class {
|
|
|
5724
6139
|
"'Id on unsigned credentials is not allowed'"
|
|
5725
6140
|
]
|
|
5726
6141
|
});
|
|
5727
|
-
(0,
|
|
5728
|
-
F:
|
|
6142
|
+
(0, import_invariant18.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
6143
|
+
F: __dxlog_file21,
|
|
5729
6144
|
L: 214,
|
|
5730
6145
|
S: this,
|
|
5731
6146
|
A: [
|
|
@@ -5734,8 +6149,8 @@ var SpacesServiceImpl = class {
|
|
|
5734
6149
|
]
|
|
5735
6150
|
});
|
|
5736
6151
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5737
|
-
(0,
|
|
5738
|
-
F:
|
|
6152
|
+
(0, import_invariant18.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
6153
|
+
F: __dxlog_file21,
|
|
5739
6154
|
L: 216,
|
|
5740
6155
|
S: this,
|
|
5741
6156
|
A: [
|
|
@@ -5757,7 +6172,7 @@ var SpacesServiceImpl = class {
|
|
|
5757
6172
|
}
|
|
5758
6173
|
async createEpoch({ spaceKey, migration, automergeRootUrl }) {
|
|
5759
6174
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5760
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
6175
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols13.SpaceNotFoundError(spaceKey));
|
|
5761
6176
|
const result = await space.createEpoch({
|
|
5762
6177
|
migration,
|
|
5763
6178
|
newAutomergeRoot: automergeRootUrl
|
|
@@ -5784,8 +6199,8 @@ var SpacesServiceImpl = class {
|
|
|
5784
6199
|
}
|
|
5785
6200
|
async _joinByAdmission({ credential }) {
|
|
5786
6201
|
const assertion = (0, import_credentials19.getCredentialAssertion)(credential);
|
|
5787
|
-
(0,
|
|
5788
|
-
F:
|
|
6202
|
+
(0, import_invariant18.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
6203
|
+
F: __dxlog_file21,
|
|
5789
6204
|
L: 250,
|
|
5790
6205
|
S: this,
|
|
5791
6206
|
A: [
|
|
@@ -5794,8 +6209,8 @@ var SpacesServiceImpl = class {
|
|
|
5794
6209
|
]
|
|
5795
6210
|
});
|
|
5796
6211
|
const myIdentity = this._identityManager.identity;
|
|
5797
|
-
(0,
|
|
5798
|
-
F:
|
|
6212
|
+
(0, import_invariant18.invariant)(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
6213
|
+
F: __dxlog_file21,
|
|
5799
6214
|
L: 252,
|
|
5800
6215
|
S: this,
|
|
5801
6216
|
A: [
|
|
@@ -5825,7 +6240,7 @@ var SpacesServiceImpl = class {
|
|
|
5825
6240
|
id: space.id,
|
|
5826
6241
|
spaceKey: space.key,
|
|
5827
6242
|
state: space.state,
|
|
5828
|
-
error: space.error ? (0,
|
|
6243
|
+
error: space.error ? (0, import_protocols13.encodeError)(space.error) : void 0,
|
|
5829
6244
|
pipeline: {
|
|
5830
6245
|
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
5831
6246
|
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
@@ -5863,7 +6278,7 @@ var SpacesServiceImpl = class {
|
|
|
5863
6278
|
}
|
|
5864
6279
|
_requireIdentity() {
|
|
5865
6280
|
if (!this._identityManager.identity) {
|
|
5866
|
-
throw new
|
|
6281
|
+
throw new import_protocols13.IdentityNotInitializedError("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
|
|
5867
6282
|
}
|
|
5868
6283
|
return this._identityManager.identity;
|
|
5869
6284
|
}
|
|
@@ -5890,20 +6305,23 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5890
6305
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5891
6306
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5892
6307
|
}
|
|
5893
|
-
var
|
|
5894
|
-
var ServiceContext = class extends
|
|
5895
|
-
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
6308
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
6309
|
+
var ServiceContext = class extends import_context15.Resource {
|
|
6310
|
+
constructor(storage, level, networkManager, signalManager, _edgeConnection, _runtimeParams) {
|
|
5896
6311
|
super();
|
|
5897
6312
|
this.storage = storage;
|
|
5898
6313
|
this.level = level;
|
|
5899
6314
|
this.networkManager = networkManager;
|
|
5900
6315
|
this.signalManager = signalManager;
|
|
6316
|
+
this._edgeConnection = _edgeConnection;
|
|
5901
6317
|
this._runtimeParams = _runtimeParams;
|
|
5902
|
-
this.initialized = new
|
|
6318
|
+
this.initialized = new import_async19.Trigger();
|
|
6319
|
+
this._meshReplicator = void 0;
|
|
6320
|
+
this._echoEdgeReplicator = void 0;
|
|
5903
6321
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5904
|
-
this._instanceId =
|
|
5905
|
-
this.metadataStore = new
|
|
5906
|
-
this.snapshotStore = new
|
|
6322
|
+
this._instanceId = import_keys14.PublicKey.random().toHex();
|
|
6323
|
+
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
6324
|
+
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
5907
6325
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
5908
6326
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
5909
6327
|
this.feedStore = new import_feed_store6.FeedStore({
|
|
@@ -5911,17 +6329,18 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
5911
6329
|
root: storage.createDirectory("feeds"),
|
|
5912
6330
|
signer: this.keyring,
|
|
5913
6331
|
hypercore: {
|
|
5914
|
-
valueEncoding:
|
|
6332
|
+
valueEncoding: import_echo_pipeline4.valueEncoding,
|
|
5915
6333
|
stats: true
|
|
5916
6334
|
}
|
|
5917
6335
|
})
|
|
5918
6336
|
});
|
|
5919
|
-
this.spaceManager = new
|
|
6337
|
+
this.spaceManager = new import_echo_pipeline4.SpaceManager({
|
|
5920
6338
|
feedStore: this.feedStore,
|
|
5921
6339
|
networkManager: this.networkManager,
|
|
5922
6340
|
blobStore: this.blobStore,
|
|
5923
6341
|
metadataStore: this.metadataStore,
|
|
5924
|
-
snapshotStore: this.snapshotStore
|
|
6342
|
+
snapshotStore: this.snapshotStore,
|
|
6343
|
+
disableP2pReplication: this._runtimeParams?.disableP2pReplication
|
|
5925
6344
|
});
|
|
5926
6345
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
5927
6346
|
this.echoHost = new import_echo_db3.EchoHost({
|
|
@@ -5930,26 +6349,41 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
5930
6349
|
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
5931
6350
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
5932
6351
|
this._handlerFactories.set(import_services17.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
6352
|
+
if (!this._runtimeParams?.disableP2pReplication) {
|
|
6353
|
+
this._meshReplicator = new import_echo_pipeline4.MeshEchoReplicator();
|
|
6354
|
+
}
|
|
6355
|
+
if (this._edgeConnection) {
|
|
6356
|
+
this._echoEdgeReplicator = new import_echo_db3.EchoEdgeReplicator({
|
|
6357
|
+
edgeConnection: this._edgeConnection
|
|
6358
|
+
});
|
|
6359
|
+
}
|
|
5933
6360
|
}
|
|
5934
6361
|
async _open(ctx) {
|
|
5935
6362
|
await this._checkStorageVersion();
|
|
5936
|
-
(0,
|
|
5937
|
-
F:
|
|
5938
|
-
L:
|
|
6363
|
+
(0, import_log19.log)("opening...", void 0, {
|
|
6364
|
+
F: __dxlog_file22,
|
|
6365
|
+
L: 166,
|
|
5939
6366
|
S: this,
|
|
5940
6367
|
C: (f, a) => f(...a)
|
|
5941
6368
|
});
|
|
5942
|
-
|
|
6369
|
+
import_log19.log.trace("dxos.sdk.service-context.open", import_protocols14.trace.begin({
|
|
5943
6370
|
id: this._instanceId
|
|
5944
6371
|
}), {
|
|
5945
|
-
F:
|
|
5946
|
-
L:
|
|
6372
|
+
F: __dxlog_file22,
|
|
6373
|
+
L: 167,
|
|
5947
6374
|
S: this,
|
|
5948
6375
|
C: (f, a) => f(...a)
|
|
5949
6376
|
});
|
|
5950
6377
|
await this.signalManager.open();
|
|
5951
6378
|
await this.networkManager.open();
|
|
6379
|
+
await this._edgeConnection?.open();
|
|
5952
6380
|
await this.echoHost.open(ctx);
|
|
6381
|
+
if (this._meshReplicator) {
|
|
6382
|
+
await this.echoHost.addReplicator(this._meshReplicator);
|
|
6383
|
+
}
|
|
6384
|
+
if (this._echoEdgeReplicator) {
|
|
6385
|
+
await this.echoHost.addReplicator(this._echoEdgeReplicator);
|
|
6386
|
+
}
|
|
5953
6387
|
await this.metadataStore.load();
|
|
5954
6388
|
await this.spaceManager.open();
|
|
5955
6389
|
await this.identityManager.open(ctx);
|
|
@@ -5957,33 +6391,33 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
5957
6391
|
await this._initialize(ctx);
|
|
5958
6392
|
}
|
|
5959
6393
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5960
|
-
(0,
|
|
6394
|
+
(0, import_log19.log)("loaded persistent invitations", {
|
|
5961
6395
|
count: loadedInvitations.invitations?.length
|
|
5962
6396
|
}, {
|
|
5963
|
-
F:
|
|
5964
|
-
L:
|
|
6397
|
+
F: __dxlog_file22,
|
|
6398
|
+
L: 189,
|
|
5965
6399
|
S: this,
|
|
5966
6400
|
C: (f, a) => f(...a)
|
|
5967
6401
|
});
|
|
5968
|
-
|
|
6402
|
+
import_log19.log.trace("dxos.sdk.service-context.open", import_protocols14.trace.end({
|
|
5969
6403
|
id: this._instanceId
|
|
5970
6404
|
}), {
|
|
5971
|
-
F:
|
|
5972
|
-
L:
|
|
6405
|
+
F: __dxlog_file22,
|
|
6406
|
+
L: 191,
|
|
5973
6407
|
S: this,
|
|
5974
6408
|
C: (f, a) => f(...a)
|
|
5975
6409
|
});
|
|
5976
|
-
(0,
|
|
5977
|
-
F:
|
|
5978
|
-
L:
|
|
6410
|
+
(0, import_log19.log)("opened", void 0, {
|
|
6411
|
+
F: __dxlog_file22,
|
|
6412
|
+
L: 192,
|
|
5979
6413
|
S: this,
|
|
5980
6414
|
C: (f, a) => f(...a)
|
|
5981
6415
|
});
|
|
5982
6416
|
}
|
|
5983
6417
|
async _close(ctx) {
|
|
5984
|
-
(0,
|
|
5985
|
-
F:
|
|
5986
|
-
L:
|
|
6418
|
+
(0, import_log19.log)("closing...", void 0, {
|
|
6419
|
+
F: __dxlog_file22,
|
|
6420
|
+
L: 196,
|
|
5987
6421
|
S: this,
|
|
5988
6422
|
C: (f, a) => f(...a)
|
|
5989
6423
|
});
|
|
@@ -5998,26 +6432,27 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
5998
6432
|
await this.echoHost.close(ctx);
|
|
5999
6433
|
await this.networkManager.close();
|
|
6000
6434
|
await this.signalManager.close();
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6435
|
+
await this._edgeConnection?.close();
|
|
6436
|
+
(0, import_log19.log)("closed", void 0, {
|
|
6437
|
+
F: __dxlog_file22,
|
|
6438
|
+
L: 211,
|
|
6004
6439
|
S: this,
|
|
6005
6440
|
C: (f, a) => f(...a)
|
|
6006
6441
|
});
|
|
6007
6442
|
}
|
|
6008
6443
|
async createIdentity(params = {}) {
|
|
6009
6444
|
const identity = await this.identityManager.createIdentity(params);
|
|
6010
|
-
await this._initialize(new
|
|
6011
|
-
F:
|
|
6012
|
-
L:
|
|
6445
|
+
await this._initialize(new import_context15.Context(void 0, {
|
|
6446
|
+
F: __dxlog_file22,
|
|
6447
|
+
L: 216
|
|
6013
6448
|
}));
|
|
6014
6449
|
return identity;
|
|
6015
6450
|
}
|
|
6016
6451
|
getInvitationHandler(invitation) {
|
|
6017
6452
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
6018
|
-
(0,
|
|
6019
|
-
F:
|
|
6020
|
-
L:
|
|
6453
|
+
(0, import_invariant19.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
6454
|
+
F: __dxlog_file22,
|
|
6455
|
+
L: 222,
|
|
6021
6456
|
S: this,
|
|
6022
6457
|
A: [
|
|
6023
6458
|
"factory",
|
|
@@ -6036,23 +6471,23 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
6036
6471
|
}
|
|
6037
6472
|
async _acceptIdentity(params) {
|
|
6038
6473
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
6039
|
-
await this._initialize(new
|
|
6040
|
-
F:
|
|
6041
|
-
L:
|
|
6474
|
+
await this._initialize(new import_context15.Context(void 0, {
|
|
6475
|
+
F: __dxlog_file22,
|
|
6476
|
+
L: 238
|
|
6042
6477
|
}));
|
|
6043
6478
|
return identity;
|
|
6044
6479
|
}
|
|
6045
6480
|
async _checkStorageVersion() {
|
|
6046
6481
|
await this.metadataStore.load();
|
|
6047
|
-
if (this.metadataStore.version !==
|
|
6048
|
-
throw new
|
|
6482
|
+
if (this.metadataStore.version !== import_protocols14.STORAGE_VERSION) {
|
|
6483
|
+
throw new import_protocols14.InvalidStorageVersionError(import_protocols14.STORAGE_VERSION, this.metadataStore.version);
|
|
6049
6484
|
}
|
|
6050
6485
|
}
|
|
6051
6486
|
// Called when identity is created.
|
|
6052
6487
|
async _initialize(ctx) {
|
|
6053
|
-
(0,
|
|
6054
|
-
F:
|
|
6055
|
-
L:
|
|
6488
|
+
(0, import_log19.log)("initializing spaces...", void 0, {
|
|
6489
|
+
F: __dxlog_file22,
|
|
6490
|
+
L: 253,
|
|
6056
6491
|
S: this,
|
|
6057
6492
|
C: (f, a) => f(...a)
|
|
6058
6493
|
});
|
|
@@ -6070,12 +6505,24 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
6070
6505
|
});
|
|
6071
6506
|
}
|
|
6072
6507
|
};
|
|
6073
|
-
this.dataSpaceManager = new DataSpaceManager(
|
|
6508
|
+
this.dataSpaceManager = new DataSpaceManager({
|
|
6509
|
+
spaceManager: this.spaceManager,
|
|
6510
|
+
metadataStore: this.metadataStore,
|
|
6511
|
+
keyring: this.keyring,
|
|
6512
|
+
signingContext,
|
|
6513
|
+
feedStore: this.feedStore,
|
|
6514
|
+
echoHost: this.echoHost,
|
|
6515
|
+
invitationsManager: this.invitationsManager,
|
|
6516
|
+
edgeConnection: this._edgeConnection,
|
|
6517
|
+
echoEdgeReplicator: this._echoEdgeReplicator,
|
|
6518
|
+
meshReplicator: this._meshReplicator,
|
|
6519
|
+
runtimeParams: this._runtimeParams
|
|
6520
|
+
});
|
|
6074
6521
|
await this.dataSpaceManager.open();
|
|
6075
6522
|
this._handlerFactories.set(import_services17.Invitation.Kind.SPACE, (invitation) => {
|
|
6076
|
-
(0,
|
|
6077
|
-
F:
|
|
6078
|
-
L:
|
|
6523
|
+
(0, import_invariant19.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
6524
|
+
F: __dxlog_file22,
|
|
6525
|
+
L: 281,
|
|
6079
6526
|
S: this,
|
|
6080
6527
|
A: [
|
|
6081
6528
|
"this.dataSpaceManager",
|
|
@@ -6095,33 +6542,33 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
6095
6542
|
return;
|
|
6096
6543
|
}
|
|
6097
6544
|
if (!this.dataSpaceManager) {
|
|
6098
|
-
(0,
|
|
6545
|
+
(0, import_log19.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
6099
6546
|
details: assertion
|
|
6100
6547
|
}, {
|
|
6101
|
-
F:
|
|
6102
|
-
L:
|
|
6548
|
+
F: __dxlog_file22,
|
|
6549
|
+
L: 297,
|
|
6103
6550
|
S: this,
|
|
6104
6551
|
C: (f, a) => f(...a)
|
|
6105
6552
|
});
|
|
6106
6553
|
return;
|
|
6107
6554
|
}
|
|
6108
6555
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
6109
|
-
(0,
|
|
6556
|
+
(0, import_log19.log)("space already exists, ignoring space admission", {
|
|
6110
6557
|
details: assertion
|
|
6111
6558
|
}, {
|
|
6112
|
-
F:
|
|
6113
|
-
L:
|
|
6559
|
+
F: __dxlog_file22,
|
|
6560
|
+
L: 301,
|
|
6114
6561
|
S: this,
|
|
6115
6562
|
C: (f, a) => f(...a)
|
|
6116
6563
|
});
|
|
6117
6564
|
return;
|
|
6118
6565
|
}
|
|
6119
6566
|
try {
|
|
6120
|
-
(0,
|
|
6567
|
+
(0, import_log19.log)("accepting space recorded in halo", {
|
|
6121
6568
|
details: assertion
|
|
6122
6569
|
}, {
|
|
6123
|
-
F:
|
|
6124
|
-
L:
|
|
6570
|
+
F: __dxlog_file22,
|
|
6571
|
+
L: 306,
|
|
6125
6572
|
S: this,
|
|
6126
6573
|
C: (f, a) => f(...a)
|
|
6127
6574
|
});
|
|
@@ -6130,9 +6577,9 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
6130
6577
|
genesisFeedKey: assertion.genesisFeedKey
|
|
6131
6578
|
});
|
|
6132
6579
|
} catch (err) {
|
|
6133
|
-
|
|
6134
|
-
F:
|
|
6135
|
-
L:
|
|
6580
|
+
import_log19.log.catch(err, void 0, {
|
|
6581
|
+
F: __dxlog_file22,
|
|
6582
|
+
L: 312,
|
|
6136
6583
|
S: this,
|
|
6137
6584
|
C: (f, a) => f(...a)
|
|
6138
6585
|
});
|
|
@@ -6149,7 +6596,7 @@ _ts_decorate7([
|
|
|
6149
6596
|
import_tracing10.trace.span()
|
|
6150
6597
|
], ServiceContext.prototype, "_initialize", null);
|
|
6151
6598
|
ServiceContext = _ts_decorate7([
|
|
6152
|
-
(0,
|
|
6599
|
+
(0, import_util12.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
6153
6600
|
import_tracing10.trace.resource()
|
|
6154
6601
|
], ServiceContext);
|
|
6155
6602
|
var ServiceRegistry = class {
|
|
@@ -6175,7 +6622,7 @@ var ServiceRegistry = class {
|
|
|
6175
6622
|
}
|
|
6176
6623
|
};
|
|
6177
6624
|
var getRootPath = (config) => {
|
|
6178
|
-
const { dataRoot = (0,
|
|
6625
|
+
const { dataRoot = (0, import_util13.isNode)() ? import_client_protocol7.DX_DATA : "dxos/storage" } = config ?? {};
|
|
6179
6626
|
return `${dataRoot}/`;
|
|
6180
6627
|
};
|
|
6181
6628
|
var isPersistent = (config) => {
|
|
@@ -6186,16 +6633,16 @@ var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
|
|
|
6186
6633
|
var createStorageObjects = (config) => {
|
|
6187
6634
|
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
6188
6635
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
6189
|
-
throw new
|
|
6636
|
+
throw new import_protocols15.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
6190
6637
|
}
|
|
6191
6638
|
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
6192
|
-
throw new
|
|
6639
|
+
throw new import_protocols15.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
6193
6640
|
}
|
|
6194
6641
|
if (persistent && keyStore === StorageDriver.RAM) {
|
|
6195
|
-
throw new
|
|
6642
|
+
throw new import_protocols15.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
6196
6643
|
}
|
|
6197
6644
|
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
6198
|
-
throw new
|
|
6645
|
+
throw new import_protocols15.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
6199
6646
|
}
|
|
6200
6647
|
return {
|
|
6201
6648
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -6226,12 +6673,12 @@ var toStorageType = (type) => {
|
|
|
6226
6673
|
};
|
|
6227
6674
|
var createLevel = async (config) => {
|
|
6228
6675
|
const persistent = isPersistent(config);
|
|
6229
|
-
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${
|
|
6676
|
+
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys15.PublicKey.random().toHex()}`;
|
|
6230
6677
|
const level = (0, import_kv_store.createLevel)(storagePath);
|
|
6231
6678
|
await level.open();
|
|
6232
6679
|
return level;
|
|
6233
6680
|
};
|
|
6234
|
-
var
|
|
6681
|
+
var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
|
|
6235
6682
|
var encodeProfileArchive = (profile) => import_automerge_repo.cbor.encode(profile);
|
|
6236
6683
|
var decodeProfileArchive = (data) => import_automerge_repo.cbor.decode(data);
|
|
6237
6684
|
var exportProfileData = async ({ storage, level }) => {
|
|
@@ -6244,10 +6691,10 @@ var exportProfileData = async ({ storage, level }) => {
|
|
|
6244
6691
|
{
|
|
6245
6692
|
const directory = await storage.createDirectory();
|
|
6246
6693
|
const files = await directory.list();
|
|
6247
|
-
|
|
6694
|
+
import_log20.log.info("begin exporting files", {
|
|
6248
6695
|
count: files.length
|
|
6249
6696
|
}, {
|
|
6250
|
-
F:
|
|
6697
|
+
F: __dxlog_file23,
|
|
6251
6698
|
L: 30,
|
|
6252
6699
|
S: void 0,
|
|
6253
6700
|
C: (f, a) => f(...a)
|
|
@@ -6257,23 +6704,23 @@ var exportProfileData = async ({ storage, level }) => {
|
|
|
6257
6704
|
const { size } = await file.stat();
|
|
6258
6705
|
const data = await file.read(0, size);
|
|
6259
6706
|
archive.storage.push({
|
|
6260
|
-
type:
|
|
6707
|
+
type: import_protocols16.ProfileArchiveEntryType.FILE,
|
|
6261
6708
|
key: filename,
|
|
6262
6709
|
value: data
|
|
6263
6710
|
});
|
|
6264
6711
|
}
|
|
6265
|
-
|
|
6712
|
+
import_log20.log.info("done exporting files", {
|
|
6266
6713
|
count: files.length
|
|
6267
6714
|
}, {
|
|
6268
|
-
F:
|
|
6715
|
+
F: __dxlog_file23,
|
|
6269
6716
|
L: 41,
|
|
6270
6717
|
S: void 0,
|
|
6271
6718
|
C: (f, a) => f(...a)
|
|
6272
6719
|
});
|
|
6273
6720
|
}
|
|
6274
6721
|
{
|
|
6275
|
-
|
|
6276
|
-
F:
|
|
6722
|
+
import_log20.log.info("begin exporting kv pairs", void 0, {
|
|
6723
|
+
F: __dxlog_file23,
|
|
6277
6724
|
L: 45,
|
|
6278
6725
|
S: void 0,
|
|
6279
6726
|
C: (f, a) => f(...a)
|
|
@@ -6285,16 +6732,16 @@ var exportProfileData = async ({ storage, level }) => {
|
|
|
6285
6732
|
let count = 0;
|
|
6286
6733
|
for await (const [key, value] of iter) {
|
|
6287
6734
|
archive.storage.push({
|
|
6288
|
-
type:
|
|
6735
|
+
type: import_protocols16.ProfileArchiveEntryType.KEY_VALUE,
|
|
6289
6736
|
key,
|
|
6290
6737
|
value
|
|
6291
6738
|
});
|
|
6292
6739
|
count++;
|
|
6293
6740
|
}
|
|
6294
|
-
|
|
6741
|
+
import_log20.log.info("done exporting kv pairs", {
|
|
6295
6742
|
count
|
|
6296
6743
|
}, {
|
|
6297
|
-
F:
|
|
6744
|
+
F: __dxlog_file23,
|
|
6298
6745
|
L: 56,
|
|
6299
6746
|
S: void 0,
|
|
6300
6747
|
C: (f, a) => f(...a)
|
|
@@ -6307,10 +6754,10 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
6307
6754
|
let count = 0;
|
|
6308
6755
|
for (const entry2 of archive.storage) {
|
|
6309
6756
|
switch (entry2.type) {
|
|
6310
|
-
case
|
|
6757
|
+
case import_protocols16.ProfileArchiveEntryType.FILE: {
|
|
6311
6758
|
const directory = await storage.createDirectory();
|
|
6312
|
-
(0,
|
|
6313
|
-
F:
|
|
6759
|
+
(0, import_invariant20.invariant)(typeof entry2.key === "string", "Invalid key type", {
|
|
6760
|
+
F: __dxlog_file23,
|
|
6314
6761
|
L: 79,
|
|
6315
6762
|
S: void 0,
|
|
6316
6763
|
A: [
|
|
@@ -6319,8 +6766,8 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
6319
6766
|
]
|
|
6320
6767
|
});
|
|
6321
6768
|
const file = await directory.getOrCreateFile(entry2.key);
|
|
6322
|
-
(0,
|
|
6323
|
-
F:
|
|
6769
|
+
(0, import_invariant20.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
6770
|
+
F: __dxlog_file23,
|
|
6324
6771
|
L: 81,
|
|
6325
6772
|
S: void 0,
|
|
6326
6773
|
A: [
|
|
@@ -6328,13 +6775,13 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
6328
6775
|
"'Invalid value type'"
|
|
6329
6776
|
]
|
|
6330
6777
|
});
|
|
6331
|
-
await file.write(0, (0,
|
|
6778
|
+
await file.write(0, (0, import_util14.arrayToBuffer)(entry2.value));
|
|
6332
6779
|
await file.close();
|
|
6333
6780
|
break;
|
|
6334
6781
|
}
|
|
6335
|
-
case
|
|
6336
|
-
(0,
|
|
6337
|
-
F:
|
|
6782
|
+
case import_protocols16.ProfileArchiveEntryType.KEY_VALUE: {
|
|
6783
|
+
(0, import_invariant20.invariant)(entry2.key instanceof Uint8Array, "Invalid key type", {
|
|
6784
|
+
F: __dxlog_file23,
|
|
6338
6785
|
L: 87,
|
|
6339
6786
|
S: void 0,
|
|
6340
6787
|
A: [
|
|
@@ -6342,8 +6789,8 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
6342
6789
|
"'Invalid key type'"
|
|
6343
6790
|
]
|
|
6344
6791
|
});
|
|
6345
|
-
(0,
|
|
6346
|
-
F:
|
|
6792
|
+
(0, import_invariant20.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
6793
|
+
F: __dxlog_file23,
|
|
6347
6794
|
L: 88,
|
|
6348
6795
|
S: void 0,
|
|
6349
6796
|
A: [
|
|
@@ -6363,27 +6810,27 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
6363
6810
|
if (++count % 1e3 === 0) {
|
|
6364
6811
|
await batch.write();
|
|
6365
6812
|
batch = level.batch();
|
|
6366
|
-
|
|
6813
|
+
import_log20.log.info("importing", {
|
|
6367
6814
|
count,
|
|
6368
6815
|
total: archive.storage.length,
|
|
6369
6816
|
progress: `${(count / archive.storage.length * 100).toFixed()}%`
|
|
6370
6817
|
}, {
|
|
6371
|
-
F:
|
|
6818
|
+
F: __dxlog_file23,
|
|
6372
6819
|
L: 101,
|
|
6373
6820
|
S: void 0,
|
|
6374
6821
|
C: (f, a) => f(...a)
|
|
6375
6822
|
});
|
|
6376
6823
|
}
|
|
6377
6824
|
}
|
|
6378
|
-
|
|
6379
|
-
F:
|
|
6825
|
+
import_log20.log.info("committing changes..", void 0, {
|
|
6826
|
+
F: __dxlog_file23,
|
|
6380
6827
|
L: 109,
|
|
6381
6828
|
S: void 0,
|
|
6382
6829
|
C: (f, a) => f(...a)
|
|
6383
6830
|
});
|
|
6384
6831
|
await batch.write();
|
|
6385
6832
|
};
|
|
6386
|
-
var
|
|
6833
|
+
var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
6387
6834
|
var DevicesServiceImpl = class {
|
|
6388
6835
|
constructor(_identityManager) {
|
|
6389
6836
|
this._identityManager = _identityManager;
|
|
@@ -6400,8 +6847,8 @@ var DevicesServiceImpl = class {
|
|
|
6400
6847
|
devices: []
|
|
6401
6848
|
});
|
|
6402
6849
|
} else {
|
|
6403
|
-
(0,
|
|
6404
|
-
F:
|
|
6850
|
+
(0, import_invariant22.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
6851
|
+
F: __dxlog_file24,
|
|
6405
6852
|
L: 32,
|
|
6406
6853
|
S: this,
|
|
6407
6854
|
A: [
|
|
@@ -6442,7 +6889,7 @@ var DevicesServiceImpl = class {
|
|
|
6442
6889
|
presenceSubscribed = true;
|
|
6443
6890
|
}
|
|
6444
6891
|
};
|
|
6445
|
-
const subscriptions = new
|
|
6892
|
+
const subscriptions = new import_async21.EventSubscriptions();
|
|
6446
6893
|
if (this._identityManager.identity) {
|
|
6447
6894
|
subscribeIdentity();
|
|
6448
6895
|
subscribePresence();
|
|
@@ -6498,7 +6945,7 @@ var ContactsServiceImpl = class {
|
|
|
6498
6945
|
});
|
|
6499
6946
|
}
|
|
6500
6947
|
return acc;
|
|
6501
|
-
}, new
|
|
6948
|
+
}, new import_util15.ComplexMap(import_keys17.PublicKey.hash));
|
|
6502
6949
|
return {
|
|
6503
6950
|
contacts: [
|
|
6504
6951
|
...contacts.values()
|
|
@@ -6506,16 +6953,16 @@ var ContactsServiceImpl = class {
|
|
|
6506
6953
|
};
|
|
6507
6954
|
}
|
|
6508
6955
|
queryContacts() {
|
|
6509
|
-
const subscribedSpaceKeySet = new
|
|
6956
|
+
const subscribedSpaceKeySet = new import_util15.ComplexSet(import_keys17.PublicKey.hash);
|
|
6510
6957
|
return new import_codec_protobuf13.Stream(({ next, ctx }) => {
|
|
6511
|
-
const pushUpdateTask = new
|
|
6958
|
+
const pushUpdateTask = new import_async22.UpdateScheduler(ctx, async () => {
|
|
6512
6959
|
const contacts = await this.getContacts();
|
|
6513
6960
|
next(contacts);
|
|
6514
6961
|
}, {
|
|
6515
6962
|
maxFrequency: 2
|
|
6516
6963
|
});
|
|
6517
|
-
(0,
|
|
6518
|
-
const subscriptions = new
|
|
6964
|
+
(0, import_async22.scheduleTask)(ctx, async () => {
|
|
6965
|
+
const subscriptions = new import_async22.EventSubscriptions();
|
|
6519
6966
|
ctx.onDispose(() => subscriptions.clear());
|
|
6520
6967
|
const subscribeToSpaceAndUpdate = () => {
|
|
6521
6968
|
const oldSetSize = subscribedSpaceKeySet.size;
|
|
@@ -6538,31 +6985,31 @@ var ContactsServiceImpl = class {
|
|
|
6538
6985
|
};
|
|
6539
6986
|
var LoggingServiceImpl = class {
|
|
6540
6987
|
constructor() {
|
|
6541
|
-
this._logs = new
|
|
6988
|
+
this._logs = new import_async23.Event();
|
|
6542
6989
|
this._started = Date.now();
|
|
6543
|
-
this._sessionId =
|
|
6990
|
+
this._sessionId = import_keys18.PublicKey.random().toHex();
|
|
6544
6991
|
this._logProcessor = (_config, entry2) => {
|
|
6545
6992
|
this._logs.emit(entry2);
|
|
6546
6993
|
};
|
|
6547
6994
|
}
|
|
6548
6995
|
async open() {
|
|
6549
|
-
|
|
6996
|
+
import_log22.log.runtimeConfig.processors.push(this._logProcessor);
|
|
6550
6997
|
}
|
|
6551
6998
|
async close() {
|
|
6552
|
-
const index =
|
|
6553
|
-
|
|
6999
|
+
const index = import_log22.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
7000
|
+
import_log22.log.runtimeConfig.processors.splice(index, 1);
|
|
6554
7001
|
}
|
|
6555
7002
|
async controlMetrics({ reset, record }) {
|
|
6556
7003
|
if (reset) {
|
|
6557
|
-
|
|
7004
|
+
import_util16.tracer.clear();
|
|
6558
7005
|
}
|
|
6559
7006
|
if (record === true) {
|
|
6560
|
-
|
|
7007
|
+
import_util16.tracer.start();
|
|
6561
7008
|
} else if (record === false) {
|
|
6562
|
-
|
|
7009
|
+
import_util16.tracer.stop();
|
|
6563
7010
|
}
|
|
6564
7011
|
return {
|
|
6565
|
-
recording:
|
|
7012
|
+
recording: import_util16.tracer.recording
|
|
6566
7013
|
};
|
|
6567
7014
|
}
|
|
6568
7015
|
/**
|
|
@@ -6570,10 +7017,10 @@ var LoggingServiceImpl = class {
|
|
|
6570
7017
|
*/
|
|
6571
7018
|
queryMetrics({ interval = 5e3 }) {
|
|
6572
7019
|
const getNumericalValues = (key) => {
|
|
6573
|
-
const events =
|
|
7020
|
+
const events = import_util16.tracer.get(key) ?? [];
|
|
6574
7021
|
return {
|
|
6575
7022
|
key,
|
|
6576
|
-
stats: (0,
|
|
7023
|
+
stats: (0, import_util16.numericalValues)(events, "duration")
|
|
6577
7024
|
};
|
|
6578
7025
|
};
|
|
6579
7026
|
return new import_codec_protobuf14.Stream(({ next }) => {
|
|
@@ -6611,7 +7058,7 @@ var LoggingServiceImpl = class {
|
|
|
6611
7058
|
}
|
|
6612
7059
|
const record = {
|
|
6613
7060
|
...entry2,
|
|
6614
|
-
context: (0,
|
|
7061
|
+
context: (0, import_util16.jsonify)((0, import_log22.getContextFromEntry)(entry2)),
|
|
6615
7062
|
timestamp: /* @__PURE__ */ new Date(),
|
|
6616
7063
|
meta: {
|
|
6617
7064
|
// TODO(dmaretskyi): Fix proto.
|
|
@@ -6620,7 +7067,7 @@ var LoggingServiceImpl = class {
|
|
|
6620
7067
|
scope: {
|
|
6621
7068
|
hostSessionId: this._sessionId,
|
|
6622
7069
|
uptimeSeconds: (Date.now() - this._started) / 1e3,
|
|
6623
|
-
name: (0,
|
|
7070
|
+
name: (0, import_util16.getDebugName)(entry2.meta?.S)
|
|
6624
7071
|
}
|
|
6625
7072
|
}
|
|
6626
7073
|
};
|
|
@@ -6701,7 +7148,7 @@ var SystemServiceImpl = class {
|
|
|
6701
7148
|
const diagnostics = await this._getDiagnostics();
|
|
6702
7149
|
return {
|
|
6703
7150
|
timestamp: /* @__PURE__ */ new Date(),
|
|
6704
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
7151
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util17.jsonKeyReplacer)({
|
|
6705
7152
|
truncate: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
6706
7153
|
humanize: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
6707
7154
|
})))
|
|
@@ -6744,7 +7191,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
6744
7191
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6745
7192
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6746
7193
|
}
|
|
6747
|
-
var
|
|
7194
|
+
var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
6748
7195
|
var ClientServicesHost = class {
|
|
6749
7196
|
constructor({
|
|
6750
7197
|
config,
|
|
@@ -6758,13 +7205,17 @@ var ClientServicesHost = class {
|
|
|
6758
7205
|
runtimeParams
|
|
6759
7206
|
} = {}) {
|
|
6760
7207
|
this._tracingService = import_tracing11.TRACE_PROCESSOR.createTraceSender();
|
|
6761
|
-
this._statusUpdate = new
|
|
7208
|
+
this._statusUpdate = new import_async20.Event();
|
|
7209
|
+
this._edgeConnection = void 0;
|
|
6762
7210
|
this._opening = false;
|
|
6763
7211
|
this._open = false;
|
|
6764
7212
|
this._storage = storage;
|
|
6765
7213
|
this._level = level;
|
|
6766
7214
|
this._callbacks = callbacks;
|
|
6767
7215
|
this._runtimeParams = runtimeParams ?? {};
|
|
7216
|
+
if (this._runtimeParams.disableP2pReplication === void 0) {
|
|
7217
|
+
this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
|
|
7218
|
+
}
|
|
6768
7219
|
if (config) {
|
|
6769
7220
|
this.initialize({
|
|
6770
7221
|
config,
|
|
@@ -6777,9 +7228,9 @@ var ClientServicesHost = class {
|
|
|
6777
7228
|
lockKey,
|
|
6778
7229
|
onAcquire: () => {
|
|
6779
7230
|
if (!this._opening) {
|
|
6780
|
-
void this.open(new
|
|
6781
|
-
F:
|
|
6782
|
-
L:
|
|
7231
|
+
void this.open(new import_context16.Context(void 0, {
|
|
7232
|
+
F: __dxlog_file25,
|
|
7233
|
+
L: 132
|
|
6783
7234
|
}));
|
|
6784
7235
|
}
|
|
6785
7236
|
},
|
|
@@ -6835,25 +7286,25 @@ var ClientServicesHost = class {
|
|
|
6835
7286
|
* Can only be called once.
|
|
6836
7287
|
*/
|
|
6837
7288
|
initialize({ config, ...options }) {
|
|
6838
|
-
(0,
|
|
6839
|
-
F:
|
|
6840
|
-
L:
|
|
7289
|
+
(0, import_invariant21.invariant)(!this._open, "service host is open", {
|
|
7290
|
+
F: __dxlog_file25,
|
|
7291
|
+
L: 198,
|
|
6841
7292
|
S: this,
|
|
6842
7293
|
A: [
|
|
6843
7294
|
"!this._open",
|
|
6844
7295
|
"'service host is open'"
|
|
6845
7296
|
]
|
|
6846
7297
|
});
|
|
6847
|
-
(0,
|
|
6848
|
-
F:
|
|
6849
|
-
L:
|
|
7298
|
+
(0, import_log21.log)("initializing...", void 0, {
|
|
7299
|
+
F: __dxlog_file25,
|
|
7300
|
+
L: 199,
|
|
6850
7301
|
S: this,
|
|
6851
7302
|
C: (f, a) => f(...a)
|
|
6852
7303
|
});
|
|
6853
7304
|
if (config) {
|
|
6854
|
-
(0,
|
|
6855
|
-
F:
|
|
6856
|
-
L:
|
|
7305
|
+
(0, import_invariant21.invariant)(!this._config, "config already set", {
|
|
7306
|
+
F: __dxlog_file25,
|
|
7307
|
+
L: 202,
|
|
6857
7308
|
S: this,
|
|
6858
7309
|
A: [
|
|
6859
7310
|
"!this._config",
|
|
@@ -6866,20 +7317,20 @@ var ClientServicesHost = class {
|
|
|
6866
7317
|
}
|
|
6867
7318
|
}
|
|
6868
7319
|
if (!options.signalManager) {
|
|
6869
|
-
|
|
6870
|
-
F:
|
|
6871
|
-
L:
|
|
7320
|
+
import_log21.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
7321
|
+
F: __dxlog_file25,
|
|
7322
|
+
L: 210,
|
|
6872
7323
|
S: this,
|
|
6873
7324
|
C: (f, a) => f(...a)
|
|
6874
7325
|
});
|
|
6875
7326
|
}
|
|
6876
7327
|
const { connectionLog = true, transportFactory = (0, import_network_manager2.createSimplePeerTransportFactory)({
|
|
6877
7328
|
iceServers: this._config?.get("runtime.services.ice")
|
|
6878
|
-
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
7329
|
+
}, this._config?.get("runtime.services.iceProviders") && (0, import_network_manager2.createIceProvider)(this._config.get("runtime.services.iceProviders"))), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6879
7330
|
this._signalManager = signalManager;
|
|
6880
|
-
(0,
|
|
6881
|
-
F:
|
|
6882
|
-
L:
|
|
7331
|
+
(0, import_invariant21.invariant)(!this._networkManager, "network manager already set", {
|
|
7332
|
+
F: __dxlog_file25,
|
|
7333
|
+
L: 223,
|
|
6883
7334
|
S: this,
|
|
6884
7335
|
A: [
|
|
6885
7336
|
"!this._networkManager",
|
|
@@ -6891,9 +7342,15 @@ var ClientServicesHost = class {
|
|
|
6891
7342
|
transportFactory,
|
|
6892
7343
|
signalManager
|
|
6893
7344
|
});
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
7345
|
+
const edgeEndpoint = config?.get("runtime.services.edge.url");
|
|
7346
|
+
if (edgeEndpoint) {
|
|
7347
|
+
this._edgeConnection = new import_edge_client.EdgeClient(import_keys16.PublicKey.random(), import_keys16.PublicKey.random(), {
|
|
7348
|
+
socketEndpoint: edgeEndpoint
|
|
7349
|
+
});
|
|
7350
|
+
}
|
|
7351
|
+
(0, import_log21.log)("initialized", void 0, {
|
|
7352
|
+
F: __dxlog_file25,
|
|
7353
|
+
L: 238,
|
|
6897
7354
|
S: this,
|
|
6898
7355
|
C: (f, a) => f(...a)
|
|
6899
7356
|
});
|
|
@@ -6902,45 +7359,45 @@ var ClientServicesHost = class {
|
|
|
6902
7359
|
if (this._open) {
|
|
6903
7360
|
return;
|
|
6904
7361
|
}
|
|
6905
|
-
const traceId =
|
|
6906
|
-
|
|
7362
|
+
const traceId = import_keys16.PublicKey.random().toHex();
|
|
7363
|
+
import_log21.log.trace("dxos.client-services.host.open", import_protocols17.trace.begin({
|
|
6907
7364
|
id: traceId
|
|
6908
7365
|
}), {
|
|
6909
|
-
F:
|
|
6910
|
-
L:
|
|
7366
|
+
F: __dxlog_file25,
|
|
7367
|
+
L: 249,
|
|
6911
7368
|
S: this,
|
|
6912
7369
|
C: (f, a) => f(...a)
|
|
6913
7370
|
});
|
|
6914
|
-
(0,
|
|
6915
|
-
F:
|
|
6916
|
-
L:
|
|
7371
|
+
(0, import_invariant21.invariant)(this._config, "config not set", {
|
|
7372
|
+
F: __dxlog_file25,
|
|
7373
|
+
L: 251,
|
|
6917
7374
|
S: this,
|
|
6918
7375
|
A: [
|
|
6919
7376
|
"this._config",
|
|
6920
7377
|
"'config not set'"
|
|
6921
7378
|
]
|
|
6922
7379
|
});
|
|
6923
|
-
(0,
|
|
6924
|
-
F:
|
|
6925
|
-
L:
|
|
7380
|
+
(0, import_invariant21.invariant)(this._storage, "storage not set", {
|
|
7381
|
+
F: __dxlog_file25,
|
|
7382
|
+
L: 252,
|
|
6926
7383
|
S: this,
|
|
6927
7384
|
A: [
|
|
6928
7385
|
"this._storage",
|
|
6929
7386
|
"'storage not set'"
|
|
6930
7387
|
]
|
|
6931
7388
|
});
|
|
6932
|
-
(0,
|
|
6933
|
-
F:
|
|
6934
|
-
L:
|
|
7389
|
+
(0, import_invariant21.invariant)(this._signalManager, "signal manager not set", {
|
|
7390
|
+
F: __dxlog_file25,
|
|
7391
|
+
L: 253,
|
|
6935
7392
|
S: this,
|
|
6936
7393
|
A: [
|
|
6937
7394
|
"this._signalManager",
|
|
6938
7395
|
"'signal manager not set'"
|
|
6939
7396
|
]
|
|
6940
7397
|
});
|
|
6941
|
-
(0,
|
|
6942
|
-
F:
|
|
6943
|
-
L:
|
|
7398
|
+
(0, import_invariant21.invariant)(this._networkManager, "network manager not set", {
|
|
7399
|
+
F: __dxlog_file25,
|
|
7400
|
+
L: 254,
|
|
6944
7401
|
S: this,
|
|
6945
7402
|
A: [
|
|
6946
7403
|
"this._networkManager",
|
|
@@ -6948,11 +7405,11 @@ var ClientServicesHost = class {
|
|
|
6948
7405
|
]
|
|
6949
7406
|
});
|
|
6950
7407
|
this._opening = true;
|
|
6951
|
-
(0,
|
|
7408
|
+
(0, import_log21.log)("opening...", {
|
|
6952
7409
|
lockKey: this._resourceLock?.lockKey
|
|
6953
7410
|
}, {
|
|
6954
|
-
F:
|
|
6955
|
-
L:
|
|
7411
|
+
F: __dxlog_file25,
|
|
7412
|
+
L: 257,
|
|
6956
7413
|
S: this,
|
|
6957
7414
|
C: (f, a) => f(...a)
|
|
6958
7415
|
});
|
|
@@ -6962,7 +7419,7 @@ var ClientServicesHost = class {
|
|
|
6962
7419
|
}
|
|
6963
7420
|
await this._level.open();
|
|
6964
7421
|
await this._loggingService.open();
|
|
6965
|
-
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
7422
|
+
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._runtimeParams);
|
|
6966
7423
|
const dataSpaceManagerProvider = async () => {
|
|
6967
7424
|
await this._serviceContext.initialized.wait();
|
|
6968
7425
|
return this._serviceContext.dataSpaceManager;
|
|
@@ -7004,19 +7461,19 @@ var ClientServicesHost = class {
|
|
|
7004
7461
|
this._open = true;
|
|
7005
7462
|
this._statusUpdate.emit();
|
|
7006
7463
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
7007
|
-
(0,
|
|
7464
|
+
(0, import_log21.log)("opened", {
|
|
7008
7465
|
deviceKey
|
|
7009
7466
|
}, {
|
|
7010
|
-
F:
|
|
7011
|
-
L:
|
|
7467
|
+
F: __dxlog_file25,
|
|
7468
|
+
L: 344,
|
|
7012
7469
|
S: this,
|
|
7013
7470
|
C: (f, a) => f(...a)
|
|
7014
7471
|
});
|
|
7015
|
-
|
|
7472
|
+
import_log21.log.trace("dxos.client-services.host.open", import_protocols17.trace.end({
|
|
7016
7473
|
id: traceId
|
|
7017
7474
|
}), {
|
|
7018
|
-
F:
|
|
7019
|
-
L:
|
|
7475
|
+
F: __dxlog_file25,
|
|
7476
|
+
L: 345,
|
|
7020
7477
|
S: this,
|
|
7021
7478
|
C: (f, a) => f(...a)
|
|
7022
7479
|
});
|
|
@@ -7026,11 +7483,11 @@ var ClientServicesHost = class {
|
|
|
7026
7483
|
return;
|
|
7027
7484
|
}
|
|
7028
7485
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
7029
|
-
(0,
|
|
7486
|
+
(0, import_log21.log)("closing...", {
|
|
7030
7487
|
deviceKey
|
|
7031
7488
|
}, {
|
|
7032
|
-
F:
|
|
7033
|
-
L:
|
|
7489
|
+
F: __dxlog_file25,
|
|
7490
|
+
L: 356,
|
|
7034
7491
|
S: this,
|
|
7035
7492
|
C: (f, a) => f(...a)
|
|
7036
7493
|
});
|
|
@@ -7044,44 +7501,44 @@ var ClientServicesHost = class {
|
|
|
7044
7501
|
await this._level?.close();
|
|
7045
7502
|
this._open = false;
|
|
7046
7503
|
this._statusUpdate.emit();
|
|
7047
|
-
(0,
|
|
7504
|
+
(0, import_log21.log)("closed", {
|
|
7048
7505
|
deviceKey
|
|
7049
7506
|
}, {
|
|
7050
|
-
F:
|
|
7051
|
-
L:
|
|
7507
|
+
F: __dxlog_file25,
|
|
7508
|
+
L: 365,
|
|
7052
7509
|
S: this,
|
|
7053
7510
|
C: (f, a) => f(...a)
|
|
7054
7511
|
});
|
|
7055
7512
|
}
|
|
7056
7513
|
async reset() {
|
|
7057
|
-
const traceId =
|
|
7058
|
-
|
|
7514
|
+
const traceId = import_keys16.PublicKey.random().toHex();
|
|
7515
|
+
import_log21.log.trace("dxos.sdk.client-services-host.reset", import_protocols17.trace.begin({
|
|
7059
7516
|
id: traceId
|
|
7060
7517
|
}), {
|
|
7061
|
-
F:
|
|
7062
|
-
L:
|
|
7518
|
+
F: __dxlog_file25,
|
|
7519
|
+
L: 370,
|
|
7063
7520
|
S: this,
|
|
7064
7521
|
C: (f, a) => f(...a)
|
|
7065
7522
|
});
|
|
7066
|
-
|
|
7067
|
-
F:
|
|
7068
|
-
L:
|
|
7523
|
+
import_log21.log.info("resetting...", void 0, {
|
|
7524
|
+
F: __dxlog_file25,
|
|
7525
|
+
L: 372,
|
|
7069
7526
|
S: this,
|
|
7070
7527
|
C: (f, a) => f(...a)
|
|
7071
7528
|
});
|
|
7072
7529
|
await this._serviceContext?.close();
|
|
7073
7530
|
await this._storage.reset();
|
|
7074
|
-
|
|
7075
|
-
F:
|
|
7076
|
-
L:
|
|
7531
|
+
import_log21.log.info("reset", void 0, {
|
|
7532
|
+
F: __dxlog_file25,
|
|
7533
|
+
L: 375,
|
|
7077
7534
|
S: this,
|
|
7078
7535
|
C: (f, a) => f(...a)
|
|
7079
7536
|
});
|
|
7080
|
-
|
|
7537
|
+
import_log21.log.trace("dxos.sdk.client-services-host.reset", import_protocols17.trace.end({
|
|
7081
7538
|
id: traceId
|
|
7082
7539
|
}), {
|
|
7083
|
-
F:
|
|
7084
|
-
L:
|
|
7540
|
+
F: __dxlog_file25,
|
|
7541
|
+
L: 376,
|
|
7085
7542
|
S: this,
|
|
7086
7543
|
C: (f, a) => f(...a)
|
|
7087
7544
|
});
|
|
@@ -7100,11 +7557,11 @@ _ts_decorate8([
|
|
|
7100
7557
|
import_tracing11.trace.info()
|
|
7101
7558
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
7102
7559
|
_ts_decorate8([
|
|
7103
|
-
|
|
7560
|
+
import_async20.synchronized,
|
|
7104
7561
|
import_tracing11.trace.span()
|
|
7105
7562
|
], ClientServicesHost.prototype, "open", null);
|
|
7106
7563
|
_ts_decorate8([
|
|
7107
|
-
|
|
7564
|
+
import_async20.synchronized,
|
|
7108
7565
|
import_tracing11.trace.span()
|
|
7109
7566
|
], ClientServicesHost.prototype, "close", null);
|
|
7110
7567
|
ClientServicesHost = _ts_decorate8([
|
|
@@ -7120,6 +7577,7 @@ ClientServicesHost = _ts_decorate8([
|
|
|
7120
7577
|
DevtoolsHostEvents,
|
|
7121
7578
|
DevtoolsServiceImpl,
|
|
7122
7579
|
DiagnosticsCollector,
|
|
7580
|
+
EdgeFeedReplicator,
|
|
7123
7581
|
Identity,
|
|
7124
7582
|
IdentityManager,
|
|
7125
7583
|
IdentityServiceImpl,
|
|
@@ -7153,4 +7611,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
7153
7611
|
subscribeToSpaces,
|
|
7154
7612
|
subscribeToSwarmInfo
|
|
7155
7613
|
});
|
|
7156
|
-
//# sourceMappingURL=chunk-
|
|
7614
|
+
//# sourceMappingURL=chunk-DRNEKKQP.cjs.map
|