@dxos/client-services 0.5.9-main.4ed8273 → 0.5.9-main.59deb28
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-YJ5SPRLY.mjs → chunk-GCU4DHSQ.mjs} +586 -455
- package/dist/lib/browser/chunk-GCU4DHSQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -3
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +2 -3
- package/dist/lib/browser/packlets/testing/index.mjs.map +2 -2
- package/dist/lib/node/{chunk-RQHBQWKH.cjs → chunk-MHRJ6WZU.cjs} +692 -564
- package/dist/lib/node/chunk-MHRJ6WZU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +41 -43
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +9 -10
- package/dist/lib/node/packlets/testing/index.cjs.map +2 -2
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +4 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +9 -9
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +23 -0
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -36
- package/src/packlets/identity/identity-service.ts +6 -1
- package/src/packlets/services/service-context.ts +1 -4
- package/src/packlets/spaces/automerge-space-state.ts +11 -2
- package/src/packlets/spaces/data-space-manager.ts +35 -14
- package/src/packlets/spaces/data-space.ts +73 -145
- package/src/packlets/spaces/epoch-migrations.ts +135 -0
- package/src/packlets/spaces/spaces-service.ts +4 -2
- package/src/packlets/testing/test-builder.ts +1 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-YJ5SPRLY.mjs.map +0 -7
- package/dist/lib/node/chunk-RQHBQWKH.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_MHRJ6WZU_exports = {};
|
|
30
|
+
__export(chunk_MHRJ6WZU_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
@@ -56,7 +56,6 @@ __export(chunk_RQHBQWKH_exports, {
|
|
|
56
56
|
createDiagnostics: () => createDiagnostics,
|
|
57
57
|
createLevel: () => createLevel,
|
|
58
58
|
createStorageObjects: () => createStorageObjects,
|
|
59
|
-
findPropertiesObject: () => findPropertiesObject,
|
|
60
59
|
getNetworkPeers: () => getNetworkPeers,
|
|
61
60
|
isLocked: () => isLocked,
|
|
62
61
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
@@ -67,7 +66,7 @@ __export(chunk_RQHBQWKH_exports, {
|
|
|
67
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
68
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
69
68
|
});
|
|
70
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_MHRJ6WZU_exports);
|
|
71
70
|
var import_async = require("@dxos/async");
|
|
72
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
73
72
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -197,7 +196,7 @@ var import_client_protocol4 = require("@dxos/client-protocol");
|
|
|
197
196
|
var import_context10 = require("@dxos/context");
|
|
198
197
|
var import_debug3 = require("@dxos/debug");
|
|
199
198
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
200
|
-
var
|
|
199
|
+
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
201
200
|
var import_invariant12 = require("@dxos/invariant");
|
|
202
201
|
var import_keys10 = require("@dxos/keys");
|
|
203
202
|
var import_log11 = require("@dxos/log");
|
|
@@ -208,105 +207,117 @@ var import_timeframe3 = require("@dxos/timeframe");
|
|
|
208
207
|
var import_tracing5 = require("@dxos/tracing");
|
|
209
208
|
var import_util6 = require("@dxos/util");
|
|
210
209
|
var import_async13 = require("@dxos/async");
|
|
210
|
+
var import_context11 = require("@dxos/context");
|
|
211
211
|
var import_credentials14 = require("@dxos/credentials");
|
|
212
212
|
var import_async14 = require("@dxos/async");
|
|
213
|
-
var
|
|
213
|
+
var import_automerge = require("@dxos/automerge/automerge");
|
|
214
|
+
var import_context12 = require("@dxos/context");
|
|
215
|
+
var import_echo_db = require("@dxos/echo-db");
|
|
216
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
217
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
214
218
|
var import_invariant13 = require("@dxos/invariant");
|
|
215
|
-
var import_keys11 = require("@dxos/keys");
|
|
216
219
|
var import_log12 = require("@dxos/log");
|
|
217
|
-
var
|
|
218
|
-
var import_teleport3 = require("@dxos/teleport");
|
|
220
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
219
221
|
var import_util7 = require("@dxos/util");
|
|
220
222
|
var import_async15 = require("@dxos/async");
|
|
223
|
+
var import_context13 = require("@dxos/context");
|
|
224
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
225
|
+
var import_keys11 = require("@dxos/keys");
|
|
226
|
+
var import_log13 = require("@dxos/log");
|
|
227
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
228
|
+
var import_teleport3 = require("@dxos/teleport");
|
|
229
|
+
var import_util8 = require("@dxos/util");
|
|
230
|
+
var import_async16 = require("@dxos/async");
|
|
221
231
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
222
|
-
var
|
|
232
|
+
var import_context14 = require("@dxos/context");
|
|
223
233
|
var import_credentials15 = require("@dxos/credentials");
|
|
224
|
-
var
|
|
225
|
-
var
|
|
234
|
+
var import_echo_db2 = require("@dxos/echo-db");
|
|
235
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
236
|
+
var import_echo_protocol2 = require("@dxos/echo-protocol");
|
|
226
237
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
227
|
-
var
|
|
238
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
228
239
|
var import_keys12 = require("@dxos/keys");
|
|
229
|
-
var
|
|
240
|
+
var import_log14 = require("@dxos/log");
|
|
230
241
|
var import_protocols11 = require("@dxos/protocols");
|
|
231
|
-
var
|
|
242
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
232
243
|
var import_credentials16 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
233
244
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
234
245
|
var import_tracing6 = require("@dxos/tracing");
|
|
235
|
-
var
|
|
246
|
+
var import_util9 = require("@dxos/util");
|
|
236
247
|
var import_credentials17 = require("@dxos/credentials");
|
|
237
248
|
var import_debug4 = require("@dxos/debug");
|
|
238
249
|
var import_credentials18 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
239
250
|
var import_timeframe4 = require("@dxos/timeframe");
|
|
240
|
-
var
|
|
251
|
+
var import_async17 = require("@dxos/async");
|
|
241
252
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
242
253
|
var import_credentials19 = require("@dxos/credentials");
|
|
243
254
|
var import_debug5 = require("@dxos/debug");
|
|
244
255
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
245
|
-
var
|
|
246
|
-
var
|
|
256
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
257
|
+
var import_log15 = require("@dxos/log");
|
|
247
258
|
var import_protocols12 = require("@dxos/protocols");
|
|
248
|
-
var
|
|
259
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
249
260
|
var import_tracing7 = require("@dxos/tracing");
|
|
250
|
-
var
|
|
251
|
-
var
|
|
261
|
+
var import_async18 = require("@dxos/async");
|
|
262
|
+
var import_context15 = require("@dxos/context");
|
|
252
263
|
var import_credentials20 = require("@dxos/credentials");
|
|
253
264
|
var import_debug6 = require("@dxos/debug");
|
|
254
|
-
var
|
|
255
|
-
var
|
|
265
|
+
var import_echo_db3 = require("@dxos/echo-db");
|
|
266
|
+
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
256
267
|
var import_feed_store5 = require("@dxos/feed-store");
|
|
257
|
-
var
|
|
268
|
+
var import_invariant17 = require("@dxos/invariant");
|
|
258
269
|
var import_keyring = require("@dxos/keyring");
|
|
259
270
|
var import_keys13 = require("@dxos/keys");
|
|
260
|
-
var
|
|
271
|
+
var import_log16 = require("@dxos/log");
|
|
261
272
|
var import_protocols13 = require("@dxos/protocols");
|
|
262
|
-
var
|
|
273
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
263
274
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
264
275
|
var import_tracing8 = require("@dxos/tracing");
|
|
265
|
-
var
|
|
266
|
-
var
|
|
276
|
+
var import_util10 = require("@dxos/util");
|
|
277
|
+
var import_invariant18 = require("@dxos/invariant");
|
|
267
278
|
var import_lock_file = require("@dxos/lock-file");
|
|
268
|
-
var
|
|
279
|
+
var import_log17 = require("@dxos/log");
|
|
269
280
|
var import_protocols14 = require("@dxos/protocols");
|
|
270
281
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
271
282
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
272
283
|
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
273
284
|
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
274
|
-
var
|
|
285
|
+
var import_util11 = require("@dxos/util");
|
|
275
286
|
var import_node_path = __toESM(require("node:path"));
|
|
276
287
|
var import_keys14 = require("@dxos/keys");
|
|
277
288
|
var import_kv_store = require("@dxos/kv-store");
|
|
278
|
-
var
|
|
289
|
+
var import_async19 = require("@dxos/async");
|
|
279
290
|
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
280
|
-
var
|
|
281
|
-
var
|
|
291
|
+
var import_context16 = require("@dxos/context");
|
|
292
|
+
var import_invariant19 = require("@dxos/invariant");
|
|
282
293
|
var import_keys15 = require("@dxos/keys");
|
|
283
|
-
var
|
|
294
|
+
var import_log18 = require("@dxos/log");
|
|
284
295
|
var import_messaging = require("@dxos/messaging");
|
|
285
296
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
286
297
|
var import_protocols15 = require("@dxos/protocols");
|
|
287
|
-
var
|
|
298
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
288
299
|
var import_tracing9 = require("@dxos/tracing");
|
|
289
300
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
290
|
-
var
|
|
301
|
+
var import_async20 = require("@dxos/async");
|
|
291
302
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
292
|
-
var
|
|
293
|
-
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
294
|
-
var import_config3 = require("@dxos/config");
|
|
303
|
+
var import_invariant20 = require("@dxos/invariant");
|
|
295
304
|
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
305
|
+
var import_config3 = require("@dxos/config");
|
|
306
|
+
var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
|
|
296
307
|
var import_tracing10 = require("@dxos/tracing");
|
|
297
|
-
var import_util11 = require("@dxos/util");
|
|
298
|
-
var import_keys16 = require("@dxos/keys");
|
|
299
308
|
var import_util12 = require("@dxos/util");
|
|
300
|
-
var
|
|
309
|
+
var import_keys16 = require("@dxos/keys");
|
|
310
|
+
var import_util13 = require("@dxos/util");
|
|
311
|
+
var import_async21 = require("@dxos/async");
|
|
301
312
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
302
313
|
var import_keys17 = require("@dxos/keys");
|
|
303
|
-
var
|
|
304
|
-
var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
|
|
305
|
-
var import_util13 = require("@dxos/util");
|
|
306
|
-
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
307
|
-
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
314
|
+
var import_log19 = require("@dxos/log");
|
|
308
315
|
var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
|
|
309
316
|
var import_util14 = require("@dxos/util");
|
|
317
|
+
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
318
|
+
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
319
|
+
var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
|
|
320
|
+
var import_util15 = require("@dxos/util");
|
|
310
321
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
311
322
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
312
323
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -617,7 +628,7 @@ var DevtoolsServiceImpl = class {
|
|
|
617
628
|
});
|
|
618
629
|
}
|
|
619
630
|
};
|
|
620
|
-
var DXOS_VERSION = "0.5.9-main.
|
|
631
|
+
var DXOS_VERSION = "0.5.9-main.59deb28";
|
|
621
632
|
var getPlatform = () => {
|
|
622
633
|
if (process.browser) {
|
|
623
634
|
if (typeof window !== "undefined") {
|
|
@@ -1744,7 +1755,11 @@ var IdentityServiceImpl = class extends import_context4.Resource {
|
|
|
1744
1755
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
1745
1756
|
if (space.state === import_services4.SpaceState.CLOSED) {
|
|
1746
1757
|
await space.open();
|
|
1747
|
-
|
|
1758
|
+
const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === import_services4.SpaceState.REQUIRES_MIGRATION);
|
|
1759
|
+
await Promise.race([
|
|
1760
|
+
space.initializeDataPipeline(),
|
|
1761
|
+
requiresMigration
|
|
1762
|
+
]);
|
|
1748
1763
|
}
|
|
1749
1764
|
if (await dataSpaceManager.isDefaultSpace(space)) {
|
|
1750
1765
|
await identity.updateDefaultSpace(space.id);
|
|
@@ -3720,14 +3735,20 @@ var InvitationsManager = class {
|
|
|
3720
3735
|
}, callback);
|
|
3721
3736
|
}
|
|
3722
3737
|
};
|
|
3723
|
-
var AutomergeSpaceState = class {
|
|
3738
|
+
var AutomergeSpaceState = class extends import_context11.Resource {
|
|
3724
3739
|
constructor(_onNewRoot) {
|
|
3740
|
+
super();
|
|
3725
3741
|
this._onNewRoot = _onNewRoot;
|
|
3726
3742
|
this.rootUrl = void 0;
|
|
3727
3743
|
this.lastEpoch = void 0;
|
|
3728
3744
|
this.onNewEpoch = new import_async13.Event();
|
|
3729
3745
|
this._isProcessingRootDocs = false;
|
|
3730
3746
|
}
|
|
3747
|
+
async _open(ctx) {
|
|
3748
|
+
}
|
|
3749
|
+
async _close(ctx) {
|
|
3750
|
+
this._isProcessingRootDocs = false;
|
|
3751
|
+
}
|
|
3731
3752
|
async processCredential(credential) {
|
|
3732
3753
|
if (!(0, import_credentials14.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
3733
3754
|
return;
|
|
@@ -3754,18 +3775,152 @@ var AutomergeSpaceState = class {
|
|
|
3754
3775
|
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3755
3776
|
}
|
|
3756
3777
|
};
|
|
3757
|
-
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/
|
|
3778
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
3779
|
+
var runEpochMigration = async (ctx, context) => {
|
|
3780
|
+
switch (context.migration) {
|
|
3781
|
+
case import_services13.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3782
|
+
const document = context.repo.create();
|
|
3783
|
+
await context.repo.flush();
|
|
3784
|
+
return {
|
|
3785
|
+
newRoot: document.url
|
|
3786
|
+
};
|
|
3787
|
+
}
|
|
3788
|
+
case import_services13.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
3789
|
+
if (!context.currentRoot) {
|
|
3790
|
+
throw new Error("Space does not have an automerge root");
|
|
3791
|
+
}
|
|
3792
|
+
const rootHandle = context.repo.find(context.currentRoot);
|
|
3793
|
+
await (0, import_context12.cancelWithContext)(ctx, (0, import_async14.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3794
|
+
const newRoot = context.repo.create(rootHandle.docSync());
|
|
3795
|
+
await context.repo.flush();
|
|
3796
|
+
return {
|
|
3797
|
+
newRoot: newRoot.url
|
|
3798
|
+
};
|
|
3799
|
+
}
|
|
3800
|
+
case import_services13.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3801
|
+
import_log12.log.info("Fragmenting", void 0, {
|
|
3802
|
+
F: __dxlog_file14,
|
|
3803
|
+
L: 63,
|
|
3804
|
+
S: void 0,
|
|
3805
|
+
C: (f, a) => f(...a)
|
|
3806
|
+
});
|
|
3807
|
+
const currentRootUrl = context.currentRoot;
|
|
3808
|
+
const rootHandle = context.repo.find(currentRootUrl);
|
|
3809
|
+
await (0, import_context12.cancelWithContext)(ctx, (0, import_async14.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3810
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3811
|
+
const properties = (0, import_echo_db.findInlineObjectOfType)(rootHandle.docSync(), import_echo_schema.TYPE_PROPERTIES);
|
|
3812
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3813
|
+
(0, import_invariant13.invariant)(properties, "Properties not found", {
|
|
3814
|
+
F: __dxlog_file14,
|
|
3815
|
+
L: 73,
|
|
3816
|
+
S: void 0,
|
|
3817
|
+
A: [
|
|
3818
|
+
"properties",
|
|
3819
|
+
"'Properties not found'"
|
|
3820
|
+
]
|
|
3821
|
+
});
|
|
3822
|
+
const newSpaceDoc = {
|
|
3823
|
+
...rootHandle.docSync(),
|
|
3824
|
+
objects: Object.fromEntries([
|
|
3825
|
+
properties
|
|
3826
|
+
])
|
|
3827
|
+
};
|
|
3828
|
+
const newRoot = context.repo.create(newSpaceDoc);
|
|
3829
|
+
(0, import_invariant13.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3830
|
+
F: __dxlog_file14,
|
|
3831
|
+
L: 78,
|
|
3832
|
+
S: void 0,
|
|
3833
|
+
A: [
|
|
3834
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3835
|
+
""
|
|
3836
|
+
]
|
|
3837
|
+
});
|
|
3838
|
+
const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(context.spaceId, context.repo, context.spaceKey);
|
|
3839
|
+
await docLoader.loadSpaceRootDocHandle(ctx, {
|
|
3840
|
+
rootUrl: newRoot.url
|
|
3841
|
+
});
|
|
3842
|
+
otherObjects.forEach(([key, value]) => {
|
|
3843
|
+
const handle = docLoader.createDocumentForObject(key);
|
|
3844
|
+
handle.change((doc) => {
|
|
3845
|
+
(0, import_util7.assignDeep)(doc, [
|
|
3846
|
+
"objects",
|
|
3847
|
+
key
|
|
3848
|
+
], value);
|
|
3849
|
+
});
|
|
3850
|
+
});
|
|
3851
|
+
await context.repo.flush();
|
|
3852
|
+
return {
|
|
3853
|
+
newRoot: newRoot.url
|
|
3854
|
+
};
|
|
3855
|
+
}
|
|
3856
|
+
case import_services13.CreateEpochRequest.Migration.MIGRATE_REFERENCES_TO_DXN: {
|
|
3857
|
+
const currentRootUrl = context.currentRoot;
|
|
3858
|
+
const rootHandle = context.repo.find(currentRootUrl);
|
|
3859
|
+
await (0, import_context12.cancelWithContext)(ctx, (0, import_async14.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3860
|
+
(0, import_invariant13.invariant)(rootHandle.docSync(), "Root doc not found", {
|
|
3861
|
+
F: __dxlog_file14,
|
|
3862
|
+
L: 100,
|
|
3863
|
+
S: void 0,
|
|
3864
|
+
A: [
|
|
3865
|
+
"rootHandle.docSync()",
|
|
3866
|
+
"'Root doc not found'"
|
|
3867
|
+
]
|
|
3868
|
+
});
|
|
3869
|
+
const newRootContent = await (0, import_echo_db.convertLegacySpaceRootDoc)(structuredClone(rootHandle.docSync()));
|
|
3870
|
+
for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
|
|
3871
|
+
const handle = context.repo.find(url);
|
|
3872
|
+
await (0, import_context12.cancelWithContext)(ctx, (0, import_async14.asyncTimeout)(handle.whenReady(), 1e4));
|
|
3873
|
+
(0, import_invariant13.invariant)(handle.docSync(), "Doc not found", {
|
|
3874
|
+
F: __dxlog_file14,
|
|
3875
|
+
L: 107,
|
|
3876
|
+
S: void 0,
|
|
3877
|
+
A: [
|
|
3878
|
+
"handle.docSync()",
|
|
3879
|
+
"'Doc not found'"
|
|
3880
|
+
]
|
|
3881
|
+
});
|
|
3882
|
+
const newDoc = await (0, import_echo_db.convertLegacyReferences)(structuredClone(handle.docSync()));
|
|
3883
|
+
const migratedDoc = (0, import_echo_db.migrateDocument)(handle.docSync(), newDoc);
|
|
3884
|
+
const newHandle = context.repo.import(import_automerge.next.save(migratedDoc));
|
|
3885
|
+
newRootContent.links[id] = newHandle.url;
|
|
3886
|
+
}
|
|
3887
|
+
const migratedRoot = (0, import_echo_db.migrateDocument)(rootHandle.docSync(), newRootContent);
|
|
3888
|
+
const newRoot = context.repo.import(import_automerge.next.save(migratedRoot));
|
|
3889
|
+
await context.repo.flush();
|
|
3890
|
+
return {
|
|
3891
|
+
newRoot: newRoot.url
|
|
3892
|
+
};
|
|
3893
|
+
}
|
|
3894
|
+
case import_services13.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
|
|
3895
|
+
(0, import_invariant13.invariant)(context.newAutomergeRoot, void 0, {
|
|
3896
|
+
F: __dxlog_file14,
|
|
3897
|
+
L: 124,
|
|
3898
|
+
S: void 0,
|
|
3899
|
+
A: [
|
|
3900
|
+
"context.newAutomergeRoot",
|
|
3901
|
+
""
|
|
3902
|
+
]
|
|
3903
|
+
});
|
|
3904
|
+
await context.repo.flush();
|
|
3905
|
+
return {
|
|
3906
|
+
newRoot: context.newAutomergeRoot
|
|
3907
|
+
};
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3910
|
+
return {};
|
|
3911
|
+
};
|
|
3912
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3758
3913
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3759
3914
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3760
3915
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
3761
3916
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3762
3917
|
var NotarizationPlugin = class {
|
|
3763
3918
|
constructor() {
|
|
3764
|
-
this._ctx = new
|
|
3765
|
-
this._extensionOpened = new
|
|
3919
|
+
this._ctx = new import_context13.Context();
|
|
3920
|
+
this._extensionOpened = new import_async15.Event();
|
|
3766
3921
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3767
|
-
this._processedCredentials = new
|
|
3768
|
-
this._processCredentialsTriggers = new
|
|
3922
|
+
this._processedCredentials = new import_util8.ComplexSet(import_keys11.PublicKey.hash);
|
|
3923
|
+
this._processCredentialsTriggers = new import_util8.ComplexMap(import_keys11.PublicKey.hash);
|
|
3769
3924
|
}
|
|
3770
3925
|
get hasWriter() {
|
|
3771
3926
|
return !!this._writer;
|
|
@@ -3779,16 +3934,16 @@ var NotarizationPlugin = class {
|
|
|
3779
3934
|
* Request credentials to be notarized.
|
|
3780
3935
|
*/
|
|
3781
3936
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3782
|
-
(0,
|
|
3937
|
+
(0, import_log13.log)("notarize", {
|
|
3783
3938
|
credentials
|
|
3784
3939
|
}, {
|
|
3785
|
-
F:
|
|
3940
|
+
F: __dxlog_file15,
|
|
3786
3941
|
L: 90,
|
|
3787
3942
|
S: this,
|
|
3788
3943
|
C: (f, a) => f(...a)
|
|
3789
3944
|
});
|
|
3790
|
-
(0,
|
|
3791
|
-
F:
|
|
3945
|
+
(0, import_invariant14.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3946
|
+
F: __dxlog_file15,
|
|
3792
3947
|
L: 91,
|
|
3793
3948
|
S: this,
|
|
3794
3949
|
A: [
|
|
@@ -3796,13 +3951,13 @@ var NotarizationPlugin = class {
|
|
|
3796
3951
|
"'Credentials must have an id'"
|
|
3797
3952
|
]
|
|
3798
3953
|
});
|
|
3799
|
-
const errors = new
|
|
3954
|
+
const errors = new import_async15.Trigger();
|
|
3800
3955
|
const ctx = this._ctx.derive({
|
|
3801
3956
|
onError: (err) => {
|
|
3802
|
-
|
|
3957
|
+
import_log13.log.warn("Notarization error", {
|
|
3803
3958
|
err
|
|
3804
3959
|
}, {
|
|
3805
|
-
F:
|
|
3960
|
+
F: __dxlog_file15,
|
|
3806
3961
|
L: 99,
|
|
3807
3962
|
S: this,
|
|
3808
3963
|
C: (f, a) => f(...a)
|
|
@@ -3813,23 +3968,23 @@ var NotarizationPlugin = class {
|
|
|
3813
3968
|
});
|
|
3814
3969
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3815
3970
|
if (timeout !== 0) {
|
|
3816
|
-
(0,
|
|
3817
|
-
|
|
3971
|
+
(0, import_async15.scheduleTask)(ctx, () => {
|
|
3972
|
+
import_log13.log.warn("Notarization timeout", {
|
|
3818
3973
|
timeout,
|
|
3819
3974
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3820
3975
|
}, {
|
|
3821
|
-
F:
|
|
3976
|
+
F: __dxlog_file15,
|
|
3822
3977
|
L: 111,
|
|
3823
3978
|
S: this,
|
|
3824
3979
|
C: (f, a) => f(...a)
|
|
3825
3980
|
});
|
|
3826
3981
|
void ctx.dispose();
|
|
3827
|
-
errors.throw(new
|
|
3982
|
+
errors.throw(new import_async15.TimeoutError(timeout, "Notarization timed out"));
|
|
3828
3983
|
}, timeout);
|
|
3829
3984
|
}
|
|
3830
3985
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
3831
3986
|
const peersTried = /* @__PURE__ */ new Set();
|
|
3832
|
-
const notarizeTask = new
|
|
3987
|
+
const notarizeTask = new import_async15.DeferredTask(ctx, async () => {
|
|
3833
3988
|
try {
|
|
3834
3989
|
if (this._extensions.size === 0) {
|
|
3835
3990
|
return;
|
|
@@ -3838,24 +3993,24 @@ var NotarizationPlugin = class {
|
|
|
3838
3993
|
...this._extensions
|
|
3839
3994
|
].find((peer2) => !peersTried.has(peer2));
|
|
3840
3995
|
if (!peer) {
|
|
3841
|
-
|
|
3996
|
+
import_log13.log.info("Exhausted all peers to notarize with", {
|
|
3842
3997
|
retryIn: retryTimeout
|
|
3843
3998
|
}, {
|
|
3844
|
-
F:
|
|
3999
|
+
F: __dxlog_file15,
|
|
3845
4000
|
L: 136,
|
|
3846
4001
|
S: this,
|
|
3847
4002
|
C: (f, a) => f(...a)
|
|
3848
4003
|
});
|
|
3849
4004
|
peersTried.clear();
|
|
3850
|
-
(0,
|
|
4005
|
+
(0, import_async15.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
3851
4006
|
return;
|
|
3852
4007
|
}
|
|
3853
4008
|
peersTried.add(peer);
|
|
3854
|
-
(0,
|
|
4009
|
+
(0, import_log13.log)("try notarizing", {
|
|
3855
4010
|
peer: peer.localPeerId,
|
|
3856
4011
|
credentialId: credentials.map((credential) => credential.id)
|
|
3857
4012
|
}, {
|
|
3858
|
-
F:
|
|
4013
|
+
F: __dxlog_file15,
|
|
3859
4014
|
L: 143,
|
|
3860
4015
|
S: this,
|
|
3861
4016
|
C: (f, a) => f(...a)
|
|
@@ -3863,17 +4018,17 @@ var NotarizationPlugin = class {
|
|
|
3863
4018
|
await peer.rpc.NotarizationService.notarize({
|
|
3864
4019
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3865
4020
|
});
|
|
3866
|
-
(0,
|
|
3867
|
-
F:
|
|
4021
|
+
(0, import_log13.log)("success", void 0, {
|
|
4022
|
+
F: __dxlog_file15,
|
|
3868
4023
|
L: 147,
|
|
3869
4024
|
S: this,
|
|
3870
4025
|
C: (f, a) => f(...a)
|
|
3871
4026
|
});
|
|
3872
|
-
await (0,
|
|
4027
|
+
await (0, import_async15.sleep)(successDelay);
|
|
3873
4028
|
} catch (err) {
|
|
3874
4029
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3875
|
-
|
|
3876
|
-
F:
|
|
4030
|
+
import_log13.log.info("error notarizing (recoverable)", err, {
|
|
4031
|
+
F: __dxlog_file15,
|
|
3877
4032
|
L: 151,
|
|
3878
4033
|
S: this,
|
|
3879
4034
|
C: (f, a) => f(...a)
|
|
@@ -3886,12 +4041,12 @@ var NotarizationPlugin = class {
|
|
|
3886
4041
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
3887
4042
|
try {
|
|
3888
4043
|
await Promise.race([
|
|
3889
|
-
(0,
|
|
4044
|
+
(0, import_context13.rejectOnDispose)(ctx),
|
|
3890
4045
|
allNotarized,
|
|
3891
4046
|
errors.wait()
|
|
3892
4047
|
]);
|
|
3893
|
-
(0,
|
|
3894
|
-
F:
|
|
4048
|
+
(0, import_log13.log)("done", void 0, {
|
|
4049
|
+
F: __dxlog_file15,
|
|
3895
4050
|
L: 162,
|
|
3896
4051
|
S: this,
|
|
3897
4052
|
C: (f, a) => f(...a)
|
|
@@ -3912,8 +4067,8 @@ var NotarizationPlugin = class {
|
|
|
3912
4067
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3913
4068
|
}
|
|
3914
4069
|
setWriter(writer) {
|
|
3915
|
-
(0,
|
|
3916
|
-
F:
|
|
4070
|
+
(0, import_invariant14.invariant)(!this._writer, "Writer already set.", {
|
|
4071
|
+
F: __dxlog_file15,
|
|
3917
4072
|
L: 181,
|
|
3918
4073
|
S: this,
|
|
3919
4074
|
A: [
|
|
@@ -3927,7 +4082,7 @@ var NotarizationPlugin = class {
|
|
|
3927
4082
|
if (this._processedCredentials.has(id)) {
|
|
3928
4083
|
return;
|
|
3929
4084
|
}
|
|
3930
|
-
await (0,
|
|
4085
|
+
await (0, import_util8.entry)(this._processCredentialsTriggers, id).orInsert(new import_async15.Trigger()).value.wait();
|
|
3931
4086
|
}
|
|
3932
4087
|
/**
|
|
3933
4088
|
* Requests from other peers to notarize credentials.
|
|
@@ -3937,8 +4092,8 @@ var NotarizationPlugin = class {
|
|
|
3937
4092
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3938
4093
|
}
|
|
3939
4094
|
for (const credential of request.credentials ?? []) {
|
|
3940
|
-
(0,
|
|
3941
|
-
F:
|
|
4095
|
+
(0, import_invariant14.invariant)(credential.id, "Credential must have an id", {
|
|
4096
|
+
F: __dxlog_file15,
|
|
3942
4097
|
L: 200,
|
|
3943
4098
|
S: this,
|
|
3944
4099
|
A: [
|
|
@@ -3955,10 +4110,10 @@ var NotarizationPlugin = class {
|
|
|
3955
4110
|
createExtension() {
|
|
3956
4111
|
const extension = new NotarizationTeleportExtension({
|
|
3957
4112
|
onOpen: async () => {
|
|
3958
|
-
(0,
|
|
4113
|
+
(0, import_log13.log)("extension opened", {
|
|
3959
4114
|
peer: extension.localPeerId
|
|
3960
4115
|
}, {
|
|
3961
|
-
F:
|
|
4116
|
+
F: __dxlog_file15,
|
|
3962
4117
|
L: 211,
|
|
3963
4118
|
S: this,
|
|
3964
4119
|
C: (f, a) => f(...a)
|
|
@@ -3967,10 +4122,10 @@ var NotarizationPlugin = class {
|
|
|
3967
4122
|
this._extensionOpened.emit();
|
|
3968
4123
|
},
|
|
3969
4124
|
onClose: async () => {
|
|
3970
|
-
(0,
|
|
4125
|
+
(0, import_log13.log)("extension closed", {
|
|
3971
4126
|
peer: extension.localPeerId
|
|
3972
4127
|
}, {
|
|
3973
|
-
F:
|
|
4128
|
+
F: __dxlog_file15,
|
|
3974
4129
|
L: 216,
|
|
3975
4130
|
S: this,
|
|
3976
4131
|
C: (f, a) => f(...a)
|
|
@@ -4022,14 +4177,79 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
4022
4177
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4023
4178
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4024
4179
|
}
|
|
4025
|
-
|
|
4180
|
+
function _using_ctx() {
|
|
4181
|
+
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
4182
|
+
var err = new Error();
|
|
4183
|
+
err.name = "SuppressedError";
|
|
4184
|
+
err.suppressed = suppressed;
|
|
4185
|
+
err.error = error;
|
|
4186
|
+
return err;
|
|
4187
|
+
}, empty = {}, stack = [];
|
|
4188
|
+
function using(isAwait, value) {
|
|
4189
|
+
if (value != null) {
|
|
4190
|
+
if (Object(value) !== value) {
|
|
4191
|
+
throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
4192
|
+
}
|
|
4193
|
+
if (isAwait) {
|
|
4194
|
+
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
4195
|
+
}
|
|
4196
|
+
if (dispose == null) {
|
|
4197
|
+
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
4198
|
+
}
|
|
4199
|
+
if (typeof dispose !== "function") {
|
|
4200
|
+
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
4201
|
+
}
|
|
4202
|
+
stack.push({
|
|
4203
|
+
v: value,
|
|
4204
|
+
d: dispose,
|
|
4205
|
+
a: isAwait
|
|
4206
|
+
});
|
|
4207
|
+
} else if (isAwait) {
|
|
4208
|
+
stack.push({
|
|
4209
|
+
d: value,
|
|
4210
|
+
a: isAwait
|
|
4211
|
+
});
|
|
4212
|
+
}
|
|
4213
|
+
return value;
|
|
4214
|
+
}
|
|
4215
|
+
return {
|
|
4216
|
+
e: empty,
|
|
4217
|
+
u: using.bind(null, false),
|
|
4218
|
+
a: using.bind(null, true),
|
|
4219
|
+
d: function() {
|
|
4220
|
+
var error = this.e;
|
|
4221
|
+
function next() {
|
|
4222
|
+
while (resource = stack.pop()) {
|
|
4223
|
+
try {
|
|
4224
|
+
var resource, disposalResult = resource.d && resource.d.call(resource.v);
|
|
4225
|
+
if (resource.a) {
|
|
4226
|
+
return Promise.resolve(disposalResult).then(next, err);
|
|
4227
|
+
}
|
|
4228
|
+
} catch (e) {
|
|
4229
|
+
return err(e);
|
|
4230
|
+
}
|
|
4231
|
+
}
|
|
4232
|
+
if (error !== empty)
|
|
4233
|
+
throw error;
|
|
4234
|
+
}
|
|
4235
|
+
function err(e) {
|
|
4236
|
+
error = error !== empty ? new _disposeSuppressedError(error, e) : e;
|
|
4237
|
+
return next();
|
|
4238
|
+
}
|
|
4239
|
+
return next();
|
|
4240
|
+
}
|
|
4241
|
+
};
|
|
4242
|
+
}
|
|
4243
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
4026
4244
|
var DataSpace = class {
|
|
4027
4245
|
constructor(params) {
|
|
4028
4246
|
this._ctx = new import_context10.Context();
|
|
4029
4247
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
4030
4248
|
this._cache = void 0;
|
|
4031
4249
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
4250
|
+
this._epochProcessingMutex = new import_async12.Mutex();
|
|
4032
4251
|
this._state = import_services12.SpaceState.CLOSED;
|
|
4252
|
+
this._databaseRoot = null;
|
|
4033
4253
|
this.error = void 0;
|
|
4034
4254
|
this.stateUpdate = new import_async12.Event();
|
|
4035
4255
|
this.metrics = {};
|
|
@@ -4053,8 +4273,8 @@ var DataSpace = class {
|
|
|
4053
4273
|
(0, import_log11.log)("new state", {
|
|
4054
4274
|
state: import_services12.SpaceState[this._state]
|
|
4055
4275
|
}, {
|
|
4056
|
-
F:
|
|
4057
|
-
L:
|
|
4276
|
+
F: __dxlog_file16,
|
|
4277
|
+
L: 146,
|
|
4058
4278
|
S: this,
|
|
4059
4279
|
C: (f, a) => f(...a)
|
|
4060
4280
|
});
|
|
@@ -4087,6 +4307,9 @@ var DataSpace = class {
|
|
|
4087
4307
|
get automergeSpaceState() {
|
|
4088
4308
|
return this._automergeSpaceState;
|
|
4089
4309
|
}
|
|
4310
|
+
get databaseRoot() {
|
|
4311
|
+
return this._databaseRoot;
|
|
4312
|
+
}
|
|
4090
4313
|
get _automergeInfo() {
|
|
4091
4314
|
return {
|
|
4092
4315
|
rootUrl: this._automergeSpaceState.rootUrl,
|
|
@@ -4103,14 +4326,15 @@ var DataSpace = class {
|
|
|
4103
4326
|
await this._gossip.open();
|
|
4104
4327
|
await this._notarizationPlugin.open();
|
|
4105
4328
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
4329
|
+
await this._automergeSpaceState.open();
|
|
4106
4330
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
4107
4331
|
await this._inner.open(new import_context10.Context());
|
|
4108
4332
|
this._state = import_services12.SpaceState.CONTROL_ONLY;
|
|
4109
4333
|
(0, import_log11.log)("new state", {
|
|
4110
4334
|
state: import_services12.SpaceState[this._state]
|
|
4111
4335
|
}, {
|
|
4112
|
-
F:
|
|
4113
|
-
L:
|
|
4336
|
+
F: __dxlog_file16,
|
|
4337
|
+
L: 217,
|
|
4114
4338
|
S: this,
|
|
4115
4339
|
C: (f, a) => f(...a)
|
|
4116
4340
|
});
|
|
@@ -4127,8 +4351,8 @@ var DataSpace = class {
|
|
|
4127
4351
|
(0, import_log11.log)("new state", {
|
|
4128
4352
|
state: import_services12.SpaceState[this._state]
|
|
4129
4353
|
}, {
|
|
4130
|
-
F:
|
|
4131
|
-
L:
|
|
4354
|
+
F: __dxlog_file16,
|
|
4355
|
+
L: 231,
|
|
4132
4356
|
S: this,
|
|
4133
4357
|
C: (f, a) => f(...a)
|
|
4134
4358
|
});
|
|
@@ -4137,6 +4361,7 @@ var DataSpace = class {
|
|
|
4137
4361
|
await this.authVerifier.close();
|
|
4138
4362
|
await this._inner.close();
|
|
4139
4363
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
4364
|
+
await this._automergeSpaceState.close();
|
|
4140
4365
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
4141
4366
|
await this._notarizationPlugin.close();
|
|
4142
4367
|
await this._presence.close();
|
|
@@ -4159,16 +4384,16 @@ var DataSpace = class {
|
|
|
4159
4384
|
} catch (err) {
|
|
4160
4385
|
if (err instanceof import_protocols9.CancelledError || err instanceof import_context10.ContextDisposedError) {
|
|
4161
4386
|
(0, import_log11.log)("data pipeline initialization cancelled", err, {
|
|
4162
|
-
F:
|
|
4163
|
-
L:
|
|
4387
|
+
F: __dxlog_file16,
|
|
4388
|
+
L: 265,
|
|
4164
4389
|
S: this,
|
|
4165
4390
|
C: (f, a) => f(...a)
|
|
4166
4391
|
});
|
|
4167
4392
|
return;
|
|
4168
4393
|
}
|
|
4169
4394
|
import_log11.log.error("Error initializing data pipeline", err, {
|
|
4170
|
-
F:
|
|
4171
|
-
L:
|
|
4395
|
+
F: __dxlog_file16,
|
|
4396
|
+
L: 269,
|
|
4172
4397
|
S: this,
|
|
4173
4398
|
C: (f, a) => f(...a)
|
|
4174
4399
|
});
|
|
@@ -4176,8 +4401,8 @@ var DataSpace = class {
|
|
|
4176
4401
|
(0, import_log11.log)("new state", {
|
|
4177
4402
|
state: import_services12.SpaceState[this._state]
|
|
4178
4403
|
}, {
|
|
4179
|
-
F:
|
|
4180
|
-
L:
|
|
4404
|
+
F: __dxlog_file16,
|
|
4405
|
+
L: 271,
|
|
4181
4406
|
S: this,
|
|
4182
4407
|
C: (f, a) => f(...a)
|
|
4183
4408
|
});
|
|
@@ -4196,28 +4421,25 @@ var DataSpace = class {
|
|
|
4196
4421
|
(0, import_log11.log)("new state", {
|
|
4197
4422
|
state: import_services12.SpaceState[this._state]
|
|
4198
4423
|
}, {
|
|
4199
|
-
F:
|
|
4200
|
-
L:
|
|
4424
|
+
F: __dxlog_file16,
|
|
4425
|
+
L: 287,
|
|
4201
4426
|
S: this,
|
|
4202
4427
|
C: (f, a) => f(...a)
|
|
4203
4428
|
});
|
|
4204
4429
|
await this._initializeAndReadControlPipeline();
|
|
4205
4430
|
await (0, import_async12.sleep)(1);
|
|
4431
|
+
const ready = this.stateUpdate.waitForCondition(() => this._state === import_services12.SpaceState.READY);
|
|
4206
4432
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4207
|
-
await
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
L: 290,
|
|
4211
|
-
S: this,
|
|
4212
|
-
C: (f, a) => f(...a)
|
|
4213
|
-
});
|
|
4433
|
+
await ready;
|
|
4434
|
+
}
|
|
4435
|
+
async _enterReadyState() {
|
|
4214
4436
|
await this._callbacks.beforeReady?.();
|
|
4215
4437
|
this._state = import_services12.SpaceState.READY;
|
|
4216
4438
|
(0, import_log11.log)("new state", {
|
|
4217
4439
|
state: import_services12.SpaceState[this._state]
|
|
4218
4440
|
}, {
|
|
4219
|
-
F:
|
|
4220
|
-
L:
|
|
4441
|
+
F: __dxlog_file16,
|
|
4442
|
+
L: 306,
|
|
4221
4443
|
S: this,
|
|
4222
4444
|
C: (f, a) => f(...a)
|
|
4223
4445
|
});
|
|
@@ -4232,8 +4454,8 @@ var DataSpace = class {
|
|
|
4232
4454
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4233
4455
|
await this._createWritableFeeds();
|
|
4234
4456
|
(0, import_log11.log)("writable feeds created", void 0, {
|
|
4235
|
-
F:
|
|
4236
|
-
L:
|
|
4457
|
+
F: __dxlog_file16,
|
|
4458
|
+
L: 322,
|
|
4237
4459
|
S: this,
|
|
4238
4460
|
C: (f, a) => f(...a)
|
|
4239
4461
|
});
|
|
@@ -4295,8 +4517,8 @@ var DataSpace = class {
|
|
|
4295
4517
|
space: this.key,
|
|
4296
4518
|
rootUrl
|
|
4297
4519
|
}, {
|
|
4298
|
-
F:
|
|
4299
|
-
L:
|
|
4520
|
+
F: __dxlog_file16,
|
|
4521
|
+
L: 388,
|
|
4300
4522
|
S: this,
|
|
4301
4523
|
C: (f, a) => f(...a)
|
|
4302
4524
|
});
|
|
@@ -4304,32 +4526,40 @@ var DataSpace = class {
|
|
|
4304
4526
|
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
4305
4527
|
queueMicrotask(async () => {
|
|
4306
4528
|
try {
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
return;
|
|
4312
|
-
}
|
|
4313
|
-
const doc = handle.docSync() ?? (0, import_invariant12.failedInvariant)();
|
|
4314
|
-
if (!doc.access?.spaceKey) {
|
|
4315
|
-
handle.change((doc2) => {
|
|
4316
|
-
doc2.access = {
|
|
4317
|
-
spaceKey: this.key.toHex()
|
|
4318
|
-
};
|
|
4319
|
-
});
|
|
4320
|
-
}
|
|
4321
|
-
if (!this._echoHost.roots.has(handle.documentId)) {
|
|
4322
|
-
await this._echoHost.openSpaceRoot(handle.url);
|
|
4323
|
-
} else {
|
|
4324
|
-
import_log11.log.warn("echo database root already exists", {
|
|
4325
|
-
space: this.key,
|
|
4326
|
-
rootUrl
|
|
4327
|
-
}, {
|
|
4328
|
-
F: __dxlog_file15,
|
|
4329
|
-
L: 403,
|
|
4330
|
-
S: this,
|
|
4331
|
-
C: (f, a) => f(...a)
|
|
4529
|
+
try {
|
|
4530
|
+
var _usingCtx = _using_ctx();
|
|
4531
|
+
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
4532
|
+
await (0, import_context10.cancelWithContext)(this._ctx, handle.whenReady());
|
|
4332
4533
|
});
|
|
4534
|
+
if (this._ctx.disposed) {
|
|
4535
|
+
return;
|
|
4536
|
+
}
|
|
4537
|
+
const _guard = (
|
|
4538
|
+
// Ensure only one root is processed at a time.
|
|
4539
|
+
_usingCtx.u(await this._epochProcessingMutex.acquire())
|
|
4540
|
+
);
|
|
4541
|
+
const doc = handle.docSync() ?? (0, import_invariant12.failedInvariant)();
|
|
4542
|
+
if (!doc.access?.spaceKey) {
|
|
4543
|
+
handle.change((doc2) => {
|
|
4544
|
+
doc2.access = {
|
|
4545
|
+
spaceKey: this.key.toHex()
|
|
4546
|
+
};
|
|
4547
|
+
});
|
|
4548
|
+
}
|
|
4549
|
+
const root = await this._echoHost.openSpaceRoot(handle.url);
|
|
4550
|
+
this._databaseRoot = root;
|
|
4551
|
+
if (root.getVersion() !== import_echo_protocol.SpaceDocVersion.CURRENT) {
|
|
4552
|
+
this._state = import_services12.SpaceState.REQUIRES_MIGRATION;
|
|
4553
|
+
this.stateUpdate.emit();
|
|
4554
|
+
} else {
|
|
4555
|
+
if (this._state !== import_services12.SpaceState.READY) {
|
|
4556
|
+
await this._enterReadyState();
|
|
4557
|
+
}
|
|
4558
|
+
}
|
|
4559
|
+
} catch (_) {
|
|
4560
|
+
_usingCtx.e = _;
|
|
4561
|
+
} finally {
|
|
4562
|
+
_usingCtx.d();
|
|
4333
4563
|
}
|
|
4334
4564
|
} catch (err) {
|
|
4335
4565
|
if (err instanceof import_context10.ContextDisposedError) {
|
|
@@ -4340,8 +4570,8 @@ var DataSpace = class {
|
|
|
4340
4570
|
rootUrl,
|
|
4341
4571
|
err
|
|
4342
4572
|
}, {
|
|
4343
|
-
F:
|
|
4344
|
-
L:
|
|
4573
|
+
F: __dxlog_file16,
|
|
4574
|
+
L: 431,
|
|
4345
4575
|
S: this,
|
|
4346
4576
|
C: (f, a) => f(...a)
|
|
4347
4577
|
});
|
|
@@ -4364,148 +4594,34 @@ var DataSpace = class {
|
|
|
4364
4594
|
});
|
|
4365
4595
|
}
|
|
4366
4596
|
async createEpoch(options) {
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
case import_services12.CreateEpochRequest.Migration.NONE:
|
|
4371
|
-
{
|
|
4372
|
-
epoch = {
|
|
4373
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4374
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4375
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4376
|
-
automergeRoot: this._automergeSpaceState.lastEpoch?.subject.assertion?.automergeRoot
|
|
4377
|
-
};
|
|
4378
|
-
}
|
|
4379
|
-
break;
|
|
4380
|
-
case import_services12.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
4381
|
-
{
|
|
4382
|
-
const document = this._echoHost.automergeRepo.create();
|
|
4383
|
-
epoch = {
|
|
4384
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4385
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4386
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4387
|
-
automergeRoot: document.url
|
|
4388
|
-
};
|
|
4389
|
-
}
|
|
4390
|
-
break;
|
|
4391
|
-
case import_services12.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
4392
|
-
{
|
|
4393
|
-
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4394
|
-
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4395
|
-
await (0, import_context10.cancelWithContext)(this._ctx, (0, import_async12.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
4396
|
-
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
4397
|
-
await this._echoHost.automergeRepo.flush([
|
|
4398
|
-
newRoot.documentId
|
|
4399
|
-
]);
|
|
4400
|
-
(0, import_invariant12.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4401
|
-
F: __dxlog_file15,
|
|
4402
|
-
L: 460,
|
|
4403
|
-
S: this,
|
|
4404
|
-
A: [
|
|
4405
|
-
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
4406
|
-
""
|
|
4407
|
-
]
|
|
4408
|
-
});
|
|
4409
|
-
epoch = {
|
|
4410
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4411
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4412
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4413
|
-
automergeRoot: newRoot.url
|
|
4414
|
-
};
|
|
4415
|
-
}
|
|
4416
|
-
break;
|
|
4417
|
-
case import_services12.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
4418
|
-
{
|
|
4419
|
-
import_log11.log.info("Fragmenting", void 0, {
|
|
4420
|
-
F: __dxlog_file15,
|
|
4421
|
-
L: 472,
|
|
4422
|
-
S: this,
|
|
4423
|
-
C: (f, a) => f(...a)
|
|
4424
|
-
});
|
|
4425
|
-
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4426
|
-
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4427
|
-
await (0, import_context10.cancelWithContext)(this._ctx, (0, import_async12.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
4428
|
-
const objects = Object.entries(rootHandle.docSync().objects);
|
|
4429
|
-
const properties = findPropertiesObject(rootHandle.docSync());
|
|
4430
|
-
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4431
|
-
(0, import_invariant12.invariant)(properties, "Properties not found", {
|
|
4432
|
-
F: __dxlog_file15,
|
|
4433
|
-
L: 482,
|
|
4434
|
-
S: this,
|
|
4435
|
-
A: [
|
|
4436
|
-
"properties",
|
|
4437
|
-
"'Properties not found'"
|
|
4438
|
-
]
|
|
4439
|
-
});
|
|
4440
|
-
const newSpaceDoc = {
|
|
4441
|
-
...rootHandle.docSync(),
|
|
4442
|
-
objects: Object.fromEntries([
|
|
4443
|
-
properties
|
|
4444
|
-
])
|
|
4445
|
-
};
|
|
4446
|
-
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
4447
|
-
(0, import_invariant12.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4448
|
-
F: __dxlog_file15,
|
|
4449
|
-
L: 487,
|
|
4450
|
-
S: this,
|
|
4451
|
-
A: [
|
|
4452
|
-
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
4453
|
-
""
|
|
4454
|
-
]
|
|
4455
|
-
});
|
|
4456
|
-
const docLoader = new import_echo_pipeline2.AutomergeDocumentLoaderImpl(await (0, import_echo_pipeline2.createIdFromSpaceKey)(this.key), this._echoHost.automergeRepo, this.key);
|
|
4457
|
-
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
4458
|
-
rootUrl: newRoot.url
|
|
4459
|
-
});
|
|
4460
|
-
otherObjects.forEach(([key, value]) => {
|
|
4461
|
-
const handle = docLoader.createDocumentForObject(key);
|
|
4462
|
-
handle.change((doc) => {
|
|
4463
|
-
(0, import_util6.assignDeep)(doc, [
|
|
4464
|
-
"objects",
|
|
4465
|
-
key
|
|
4466
|
-
], value);
|
|
4467
|
-
});
|
|
4468
|
-
});
|
|
4469
|
-
epoch = {
|
|
4470
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4471
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4472
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4473
|
-
automergeRoot: newRoot.url
|
|
4474
|
-
};
|
|
4475
|
-
}
|
|
4476
|
-
break;
|
|
4477
|
-
case import_services12.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT:
|
|
4478
|
-
{
|
|
4479
|
-
(0, import_invariant12.invariant)(options.newAutomergeRoot, void 0, {
|
|
4480
|
-
F: __dxlog_file15,
|
|
4481
|
-
L: 517,
|
|
4482
|
-
S: this,
|
|
4483
|
-
A: [
|
|
4484
|
-
"options.newAutomergeRoot",
|
|
4485
|
-
""
|
|
4486
|
-
]
|
|
4487
|
-
});
|
|
4488
|
-
epoch = {
|
|
4489
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4490
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4491
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4492
|
-
automergeRoot: options.newAutomergeRoot
|
|
4493
|
-
};
|
|
4494
|
-
}
|
|
4495
|
-
break;
|
|
4496
|
-
}
|
|
4497
|
-
if (!epoch) {
|
|
4498
|
-
return;
|
|
4597
|
+
const ctx = this._ctx.derive();
|
|
4598
|
+
if (!options?.migration) {
|
|
4599
|
+
return null;
|
|
4499
4600
|
}
|
|
4601
|
+
const { newRoot } = await runEpochMigration(ctx, {
|
|
4602
|
+
repo: this._echoHost.automergeRepo,
|
|
4603
|
+
spaceId: this.id,
|
|
4604
|
+
spaceKey: this.key,
|
|
4605
|
+
migration: options.migration,
|
|
4606
|
+
currentRoot: this._automergeSpaceState.rootUrl ?? null,
|
|
4607
|
+
newAutomergeRoot: options.newAutomergeRoot
|
|
4608
|
+
});
|
|
4609
|
+
const epoch = {
|
|
4610
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4611
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4612
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4613
|
+
automergeRoot: newRoot ?? this._automergeSpaceState.rootUrl
|
|
4614
|
+
};
|
|
4615
|
+
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
4616
|
+
subject: this.key,
|
|
4617
|
+
assertion: {
|
|
4618
|
+
"@type": "dxos.halo.credentials.Epoch",
|
|
4619
|
+
...epoch
|
|
4620
|
+
}
|
|
4621
|
+
});
|
|
4500
4622
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
4501
4623
|
credential: {
|
|
4502
|
-
credential
|
|
4503
|
-
subject: this.key,
|
|
4504
|
-
assertion: {
|
|
4505
|
-
"@type": "dxos.halo.credentials.Epoch",
|
|
4506
|
-
...epoch
|
|
4507
|
-
}
|
|
4508
|
-
})
|
|
4624
|
+
credential
|
|
4509
4625
|
}
|
|
4510
4626
|
});
|
|
4511
4627
|
await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe3.Timeframe([
|
|
@@ -4515,6 +4631,7 @@ var DataSpace = class {
|
|
|
4515
4631
|
]
|
|
4516
4632
|
]));
|
|
4517
4633
|
await this._echoHost.updateIndexes();
|
|
4634
|
+
return credential;
|
|
4518
4635
|
}
|
|
4519
4636
|
async activate() {
|
|
4520
4637
|
if (![
|
|
@@ -4539,8 +4656,8 @@ var DataSpace = class {
|
|
|
4539
4656
|
(0, import_log11.log)("new state", {
|
|
4540
4657
|
state: import_services12.SpaceState[this._state]
|
|
4541
4658
|
}, {
|
|
4542
|
-
F:
|
|
4543
|
-
L:
|
|
4659
|
+
F: __dxlog_file16,
|
|
4660
|
+
L: 512,
|
|
4544
4661
|
S: this,
|
|
4545
4662
|
C: (f, a) => f(...a)
|
|
4546
4663
|
});
|
|
@@ -4595,18 +4712,6 @@ DataSpace = _ts_decorate4([
|
|
|
4595
4712
|
(0, import_async12.trackLeaks)("open", "close"),
|
|
4596
4713
|
import_tracing5.trace.resource()
|
|
4597
4714
|
], DataSpace);
|
|
4598
|
-
var findPropertiesObject = (spaceDoc) => {
|
|
4599
|
-
for (const id in spaceDoc.objects ?? {}) {
|
|
4600
|
-
const obj = spaceDoc.objects[id];
|
|
4601
|
-
if (obj.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES) {
|
|
4602
|
-
return [
|
|
4603
|
-
id,
|
|
4604
|
-
obj
|
|
4605
|
-
];
|
|
4606
|
-
}
|
|
4607
|
-
}
|
|
4608
|
-
return void 0;
|
|
4609
|
-
};
|
|
4610
4715
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
4611
4716
|
const credentials = [
|
|
4612
4717
|
await (0, import_credentials17.createCredential)({
|
|
@@ -4681,7 +4786,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4681
4786
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4682
4787
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4683
4788
|
}
|
|
4684
|
-
var
|
|
4789
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4685
4790
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4686
4791
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4687
4792
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
@@ -4695,9 +4800,9 @@ var DataSpaceManager = class {
|
|
|
4695
4800
|
this._echoHost = _echoHost;
|
|
4696
4801
|
this._invitationsManager = _invitationsManager;
|
|
4697
4802
|
this._params = _params;
|
|
4698
|
-
this._ctx = new
|
|
4699
|
-
this.updated = new
|
|
4700
|
-
this._spaces = new
|
|
4803
|
+
this._ctx = new import_context14.Context();
|
|
4804
|
+
this.updated = new import_async16.Event();
|
|
4805
|
+
this._spaces = new import_util9.ComplexMap(import_keys12.PublicKey.hash);
|
|
4701
4806
|
this._isOpen = false;
|
|
4702
4807
|
this._instanceId = import_keys12.PublicKey.random().toHex();
|
|
4703
4808
|
import_tracing6.trace.diagnostic({
|
|
@@ -4708,10 +4813,10 @@ var DataSpaceManager = class {
|
|
|
4708
4813
|
const rootUrl = space.automergeSpaceState.rootUrl;
|
|
4709
4814
|
const rootHandle = rootUrl ? this._echoHost.automergeRepo.find(rootUrl) : void 0;
|
|
4710
4815
|
const rootDoc = rootHandle?.docSync();
|
|
4711
|
-
const properties = rootDoc &&
|
|
4816
|
+
const properties = rootDoc && (0, import_echo_db2.findInlineObjectOfType)(rootDoc, import_echo_schema2.TYPE_PROPERTIES);
|
|
4712
4817
|
return {
|
|
4713
4818
|
key: space.key.toHex(),
|
|
4714
|
-
state:
|
|
4819
|
+
state: import_services14.SpaceState[space.state],
|
|
4715
4820
|
name: properties?.[1].data.name ?? null,
|
|
4716
4821
|
inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
|
|
4717
4822
|
linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
|
|
@@ -4728,46 +4833,46 @@ var DataSpaceManager = class {
|
|
|
4728
4833
|
return this._spaces;
|
|
4729
4834
|
}
|
|
4730
4835
|
async open() {
|
|
4731
|
-
(0,
|
|
4732
|
-
F:
|
|
4733
|
-
L:
|
|
4836
|
+
(0, import_log14.log)("open", void 0, {
|
|
4837
|
+
F: __dxlog_file17,
|
|
4838
|
+
L: 146,
|
|
4734
4839
|
S: this,
|
|
4735
4840
|
C: (f, a) => f(...a)
|
|
4736
4841
|
});
|
|
4737
|
-
|
|
4842
|
+
import_log14.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
|
|
4738
4843
|
id: this._instanceId
|
|
4739
4844
|
}), {
|
|
4740
|
-
F:
|
|
4741
|
-
L:
|
|
4845
|
+
F: __dxlog_file17,
|
|
4846
|
+
L: 147,
|
|
4742
4847
|
S: this,
|
|
4743
4848
|
C: (f, a) => f(...a)
|
|
4744
4849
|
});
|
|
4745
|
-
(0,
|
|
4850
|
+
(0, import_log14.log)("metadata loaded", {
|
|
4746
4851
|
spaces: this._metadataStore.spaces.length
|
|
4747
4852
|
}, {
|
|
4748
|
-
F:
|
|
4749
|
-
L:
|
|
4853
|
+
F: __dxlog_file17,
|
|
4854
|
+
L: 148,
|
|
4750
4855
|
S: this,
|
|
4751
4856
|
C: (f, a) => f(...a)
|
|
4752
4857
|
});
|
|
4753
|
-
await (0,
|
|
4858
|
+
await (0, import_util9.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4754
4859
|
try {
|
|
4755
|
-
(0,
|
|
4860
|
+
(0, import_log14.log)("load space", {
|
|
4756
4861
|
spaceMetadata
|
|
4757
4862
|
}, {
|
|
4758
|
-
F:
|
|
4759
|
-
L:
|
|
4863
|
+
F: __dxlog_file17,
|
|
4864
|
+
L: 152,
|
|
4760
4865
|
S: this,
|
|
4761
4866
|
C: (f, a) => f(...a)
|
|
4762
4867
|
});
|
|
4763
4868
|
await this._constructSpace(spaceMetadata);
|
|
4764
4869
|
} catch (err) {
|
|
4765
|
-
|
|
4870
|
+
import_log14.log.error("Error loading space", {
|
|
4766
4871
|
spaceMetadata,
|
|
4767
4872
|
err
|
|
4768
4873
|
}, {
|
|
4769
|
-
F:
|
|
4770
|
-
L:
|
|
4874
|
+
F: __dxlog_file17,
|
|
4875
|
+
L: 155,
|
|
4771
4876
|
S: this,
|
|
4772
4877
|
C: (f, a) => f(...a)
|
|
4773
4878
|
});
|
|
@@ -4775,19 +4880,19 @@ var DataSpaceManager = class {
|
|
|
4775
4880
|
});
|
|
4776
4881
|
this._isOpen = true;
|
|
4777
4882
|
this.updated.emit();
|
|
4778
|
-
|
|
4883
|
+
import_log14.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
|
|
4779
4884
|
id: this._instanceId
|
|
4780
4885
|
}), {
|
|
4781
|
-
F:
|
|
4782
|
-
L:
|
|
4886
|
+
F: __dxlog_file17,
|
|
4887
|
+
L: 162,
|
|
4783
4888
|
S: this,
|
|
4784
4889
|
C: (f, a) => f(...a)
|
|
4785
4890
|
});
|
|
4786
4891
|
}
|
|
4787
4892
|
async close() {
|
|
4788
|
-
(0,
|
|
4789
|
-
F:
|
|
4790
|
-
L:
|
|
4893
|
+
(0, import_log14.log)("close", void 0, {
|
|
4894
|
+
F: __dxlog_file17,
|
|
4895
|
+
L: 167,
|
|
4791
4896
|
S: this,
|
|
4792
4897
|
C: (f, a) => f(...a)
|
|
4793
4898
|
});
|
|
@@ -4802,9 +4907,9 @@ var DataSpaceManager = class {
|
|
|
4802
4907
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
4803
4908
|
*/
|
|
4804
4909
|
async createSpace() {
|
|
4805
|
-
(0,
|
|
4806
|
-
F:
|
|
4807
|
-
L:
|
|
4910
|
+
(0, import_invariant15.invariant)(this._isOpen, "Not open.", {
|
|
4911
|
+
F: __dxlog_file17,
|
|
4912
|
+
L: 181,
|
|
4808
4913
|
S: this,
|
|
4809
4914
|
A: [
|
|
4810
4915
|
"this._isOpen",
|
|
@@ -4819,13 +4924,13 @@ var DataSpaceManager = class {
|
|
|
4819
4924
|
genesisFeedKey: controlFeedKey,
|
|
4820
4925
|
controlFeedKey,
|
|
4821
4926
|
dataFeedKey,
|
|
4822
|
-
state:
|
|
4927
|
+
state: import_services14.SpaceState.ACTIVE
|
|
4823
4928
|
};
|
|
4824
|
-
(0,
|
|
4929
|
+
(0, import_log14.log)("creating space...", {
|
|
4825
4930
|
spaceKey
|
|
4826
4931
|
}, {
|
|
4827
|
-
F:
|
|
4828
|
-
L:
|
|
4932
|
+
F: __dxlog_file17,
|
|
4933
|
+
L: 193,
|
|
4829
4934
|
S: this,
|
|
4830
4935
|
C: (f, a) => f(...a)
|
|
4831
4936
|
});
|
|
@@ -4835,9 +4940,9 @@ var DataSpaceManager = class {
|
|
|
4835
4940
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
|
|
4836
4941
|
await this._metadataStore.addSpace(metadata);
|
|
4837
4942
|
const memberCredential = credentials[1];
|
|
4838
|
-
(0,
|
|
4839
|
-
F:
|
|
4840
|
-
L:
|
|
4943
|
+
(0, import_invariant15.invariant)((0, import_credentials15.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4944
|
+
F: __dxlog_file17,
|
|
4945
|
+
L: 203,
|
|
4841
4946
|
S: this,
|
|
4842
4947
|
A: [
|
|
4843
4948
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4850,16 +4955,38 @@ var DataSpaceManager = class {
|
|
|
4850
4955
|
return space;
|
|
4851
4956
|
}
|
|
4852
4957
|
async isDefaultSpace(space) {
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4958
|
+
if (!space.databaseRoot) {
|
|
4959
|
+
return false;
|
|
4960
|
+
}
|
|
4961
|
+
switch (space.databaseRoot.getVersion()) {
|
|
4962
|
+
case import_echo_protocol2.SpaceDocVersion.CURRENT: {
|
|
4963
|
+
const [_, properties] = (0, import_echo_db2.findInlineObjectOfType)(space.databaseRoot.docSync(), import_echo_schema2.TYPE_PROPERTIES) ?? [];
|
|
4964
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
4965
|
+
}
|
|
4966
|
+
case import_echo_protocol2.SpaceDocVersion.LEGACY: {
|
|
4967
|
+
const convertedDoc = await (0, import_echo_db2.convertLegacyReferences)(space.databaseRoot.docSync());
|
|
4968
|
+
const [_, properties] = (0, import_echo_db2.findInlineObjectOfType)(convertedDoc, import_echo_protocol2.LEGACY_TYPE_PROPERTIES) ?? [];
|
|
4969
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
4970
|
+
}
|
|
4971
|
+
default:
|
|
4972
|
+
import_log14.log.warn("unknown space version", {
|
|
4973
|
+
version: space.databaseRoot.getVersion(),
|
|
4974
|
+
spaceId: space.id
|
|
4975
|
+
}, {
|
|
4976
|
+
F: __dxlog_file17,
|
|
4977
|
+
L: 228,
|
|
4978
|
+
S: this,
|
|
4979
|
+
C: (f, a) => f(...a)
|
|
4980
|
+
});
|
|
4981
|
+
return false;
|
|
4982
|
+
}
|
|
4856
4983
|
}
|
|
4857
4984
|
async createDefaultSpace() {
|
|
4858
4985
|
const space = await this.createSpace();
|
|
4859
4986
|
const document = await this._getSpaceRootDocument(space);
|
|
4860
4987
|
const properties = {
|
|
4861
4988
|
system: {
|
|
4862
|
-
type: (0,
|
|
4989
|
+
type: (0, import_echo_protocol2.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.PropertiesType))
|
|
4863
4990
|
},
|
|
4864
4991
|
data: {
|
|
4865
4992
|
[DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
|
|
@@ -4868,9 +4995,9 @@ var DataSpaceManager = class {
|
|
|
4868
4995
|
keys: []
|
|
4869
4996
|
}
|
|
4870
4997
|
};
|
|
4871
|
-
const propertiesId =
|
|
4998
|
+
const propertiesId = (0, import_echo_schema2.generateEchoId)();
|
|
4872
4999
|
document.change((doc) => {
|
|
4873
|
-
(0,
|
|
5000
|
+
(0, import_util9.assignDeep)(doc, [
|
|
4874
5001
|
"objects",
|
|
4875
5002
|
propertiesId
|
|
4876
5003
|
], properties);
|
|
@@ -4880,9 +5007,9 @@ var DataSpaceManager = class {
|
|
|
4880
5007
|
}
|
|
4881
5008
|
async _getSpaceRootDocument(space) {
|
|
4882
5009
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
4883
|
-
(0,
|
|
4884
|
-
F:
|
|
4885
|
-
L:
|
|
5010
|
+
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5011
|
+
F: __dxlog_file17,
|
|
5012
|
+
L: 261,
|
|
4886
5013
|
S: this,
|
|
4887
5014
|
A: [
|
|
4888
5015
|
"automergeIndex",
|
|
@@ -4895,26 +5022,26 @@ var DataSpaceManager = class {
|
|
|
4895
5022
|
}
|
|
4896
5023
|
// TODO(burdon): Rename join space.
|
|
4897
5024
|
async acceptSpace(opts) {
|
|
4898
|
-
(0,
|
|
5025
|
+
(0, import_log14.log)("accept space", {
|
|
4899
5026
|
opts
|
|
4900
5027
|
}, {
|
|
4901
|
-
F:
|
|
4902
|
-
L:
|
|
5028
|
+
F: __dxlog_file17,
|
|
5029
|
+
L: 270,
|
|
4903
5030
|
S: this,
|
|
4904
5031
|
C: (f, a) => f(...a)
|
|
4905
5032
|
});
|
|
4906
|
-
(0,
|
|
4907
|
-
F:
|
|
4908
|
-
L:
|
|
5033
|
+
(0, import_invariant15.invariant)(this._isOpen, "Not open.", {
|
|
5034
|
+
F: __dxlog_file17,
|
|
5035
|
+
L: 271,
|
|
4909
5036
|
S: this,
|
|
4910
5037
|
A: [
|
|
4911
5038
|
"this._isOpen",
|
|
4912
5039
|
"'Not open.'"
|
|
4913
5040
|
]
|
|
4914
5041
|
});
|
|
4915
|
-
(0,
|
|
4916
|
-
F:
|
|
4917
|
-
L:
|
|
5042
|
+
(0, import_invariant15.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
5043
|
+
F: __dxlog_file17,
|
|
5044
|
+
L: 272,
|
|
4918
5045
|
S: this,
|
|
4919
5046
|
A: [
|
|
4920
5047
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4940,17 +5067,17 @@ var DataSpaceManager = class {
|
|
|
4940
5067
|
* TODO(dmaretskyi): Consider removing.
|
|
4941
5068
|
*/
|
|
4942
5069
|
async waitUntilSpaceReady(spaceKey) {
|
|
4943
|
-
await (0,
|
|
5070
|
+
await (0, import_context14.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4944
5071
|
const space = this._spaces.get(spaceKey);
|
|
4945
|
-
return !!space && space.state ===
|
|
5072
|
+
return !!space && space.state === import_services14.SpaceState.READY;
|
|
4946
5073
|
}));
|
|
4947
5074
|
}
|
|
4948
5075
|
async _constructSpace(metadata) {
|
|
4949
|
-
(0,
|
|
5076
|
+
(0, import_log14.log)("construct space", {
|
|
4950
5077
|
metadata
|
|
4951
5078
|
}, {
|
|
4952
|
-
F:
|
|
4953
|
-
L:
|
|
5079
|
+
F: __dxlog_file17,
|
|
5080
|
+
L: 306,
|
|
4954
5081
|
S: this,
|
|
4955
5082
|
C: (f, a) => f(...a)
|
|
4956
5083
|
});
|
|
@@ -4975,7 +5102,7 @@ var DataSpaceManager = class {
|
|
|
4975
5102
|
swarmIdentity: {
|
|
4976
5103
|
peerKey: this._signingContext.deviceKey,
|
|
4977
5104
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
4978
|
-
credentialAuthenticator: (0,
|
|
5105
|
+
credentialAuthenticator: (0, import_util9.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
4979
5106
|
},
|
|
4980
5107
|
onAuthorizedConnection: (session) => {
|
|
4981
5108
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
@@ -4986,15 +5113,15 @@ var DataSpaceManager = class {
|
|
|
4986
5113
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
4987
5114
|
},
|
|
4988
5115
|
onAuthFailure: () => {
|
|
4989
|
-
|
|
4990
|
-
F:
|
|
4991
|
-
L:
|
|
5116
|
+
import_log14.log.warn("auth failure", void 0, {
|
|
5117
|
+
F: __dxlog_file17,
|
|
5118
|
+
L: 343,
|
|
4992
5119
|
S: this,
|
|
4993
5120
|
C: (f, a) => f(...a)
|
|
4994
5121
|
});
|
|
4995
5122
|
},
|
|
4996
5123
|
onMemberRolesChanged: async (members) => {
|
|
4997
|
-
if (dataSpace?.state ===
|
|
5124
|
+
if (dataSpace?.state === import_services14.SpaceState.READY) {
|
|
4998
5125
|
this._handleMemberRoleChanges(presence, space.protocol, members);
|
|
4999
5126
|
}
|
|
5000
5127
|
},
|
|
@@ -5007,7 +5134,7 @@ var DataSpaceManager = class {
|
|
|
5007
5134
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
5008
5135
|
const dataSpace = new DataSpace({
|
|
5009
5136
|
inner: space,
|
|
5010
|
-
initialState: metadata.state ===
|
|
5137
|
+
initialState: metadata.state === import_services14.SpaceState.INACTIVE ? import_services14.SpaceState.INACTIVE : import_services14.SpaceState.CLOSED,
|
|
5011
5138
|
metadataStore: this._metadataStore,
|
|
5012
5139
|
gossip,
|
|
5013
5140
|
presence,
|
|
@@ -5017,22 +5144,22 @@ var DataSpaceManager = class {
|
|
|
5017
5144
|
signingContext: this._signingContext,
|
|
5018
5145
|
callbacks: {
|
|
5019
5146
|
beforeReady: async () => {
|
|
5020
|
-
(0,
|
|
5147
|
+
(0, import_log14.log)("before space ready", {
|
|
5021
5148
|
space: space.key
|
|
5022
5149
|
}, {
|
|
5023
|
-
F:
|
|
5024
|
-
L:
|
|
5150
|
+
F: __dxlog_file17,
|
|
5151
|
+
L: 370,
|
|
5025
5152
|
S: this,
|
|
5026
5153
|
C: (f, a) => f(...a)
|
|
5027
5154
|
});
|
|
5028
5155
|
},
|
|
5029
5156
|
afterReady: async () => {
|
|
5030
|
-
(0,
|
|
5157
|
+
(0, import_log14.log)("after space ready", {
|
|
5031
5158
|
space: space.key,
|
|
5032
5159
|
open: this._isOpen
|
|
5033
5160
|
}, {
|
|
5034
|
-
F:
|
|
5035
|
-
L:
|
|
5161
|
+
F: __dxlog_file17,
|
|
5162
|
+
L: 373,
|
|
5036
5163
|
S: this,
|
|
5037
5164
|
C: (f, a) => f(...a)
|
|
5038
5165
|
});
|
|
@@ -5047,11 +5174,11 @@ var DataSpaceManager = class {
|
|
|
5047
5174
|
}
|
|
5048
5175
|
},
|
|
5049
5176
|
beforeClose: async () => {
|
|
5050
|
-
(0,
|
|
5177
|
+
(0, import_log14.log)("before space close", {
|
|
5051
5178
|
space: space.key
|
|
5052
5179
|
}, {
|
|
5053
|
-
F:
|
|
5054
|
-
L:
|
|
5180
|
+
F: __dxlog_file17,
|
|
5181
|
+
L: 381,
|
|
5055
5182
|
S: this,
|
|
5056
5183
|
C: (f, a) => f(...a)
|
|
5057
5184
|
});
|
|
@@ -5060,7 +5187,7 @@ var DataSpaceManager = class {
|
|
|
5060
5187
|
cache: metadata.cache
|
|
5061
5188
|
});
|
|
5062
5189
|
presence.newPeer.on((peerState) => {
|
|
5063
|
-
if (dataSpace.state ===
|
|
5190
|
+
if (dataSpace.state === import_services14.SpaceState.READY) {
|
|
5064
5191
|
this._handleNewPeerConnected(space, peerState);
|
|
5065
5192
|
}
|
|
5066
5193
|
});
|
|
@@ -5079,20 +5206,20 @@ var DataSpaceManager = class {
|
|
|
5079
5206
|
const peers = presence.getPeersByIdentityKey(member.key);
|
|
5080
5207
|
const sessions = peers.map((p) => p.peerId && spaceProtocol.sessions.get(p.peerId));
|
|
5081
5208
|
const sessionsToClose = sessions.filter((s) => {
|
|
5082
|
-
return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus ===
|
|
5209
|
+
return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline4.AuthStatus.FAILURE)) ?? false;
|
|
5083
5210
|
});
|
|
5084
5211
|
sessionsToClose.forEach((session) => {
|
|
5085
|
-
void session.close().catch(
|
|
5212
|
+
void session.close().catch(import_log14.log.error);
|
|
5086
5213
|
});
|
|
5087
5214
|
closedSessions += sessionsToClose.length;
|
|
5088
5215
|
}
|
|
5089
|
-
(0,
|
|
5216
|
+
(0, import_log14.log)("processed member role changes", {
|
|
5090
5217
|
roleChangeCount: memberInfo.length,
|
|
5091
5218
|
peersOnline: presence.getPeersOnline().length,
|
|
5092
5219
|
closedSessions
|
|
5093
5220
|
}, {
|
|
5094
|
-
F:
|
|
5095
|
-
L:
|
|
5221
|
+
F: __dxlog_file17,
|
|
5222
|
+
L: 417,
|
|
5096
5223
|
S: this,
|
|
5097
5224
|
C: (f, a) => f(...a)
|
|
5098
5225
|
});
|
|
@@ -5103,20 +5230,20 @@ var DataSpaceManager = class {
|
|
|
5103
5230
|
if (role === import_credentials16.SpaceMember.Role.REMOVED) {
|
|
5104
5231
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5105
5232
|
if (session != null) {
|
|
5106
|
-
(0,
|
|
5233
|
+
(0, import_log14.log)("closing a session with a removed peer", {
|
|
5107
5234
|
peerId: peerState.peerId
|
|
5108
5235
|
}, {
|
|
5109
|
-
F:
|
|
5110
|
-
L:
|
|
5236
|
+
F: __dxlog_file17,
|
|
5237
|
+
L: 431,
|
|
5111
5238
|
S: this,
|
|
5112
5239
|
C: (f, a) => f(...a)
|
|
5113
5240
|
});
|
|
5114
|
-
void session.close().catch(
|
|
5241
|
+
void session.close().catch(import_log14.log.error);
|
|
5115
5242
|
}
|
|
5116
5243
|
}
|
|
5117
5244
|
}
|
|
5118
5245
|
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
5119
|
-
if (dataSpace?.state !==
|
|
5246
|
+
if (dataSpace?.state !== import_services14.SpaceState.READY) {
|
|
5120
5247
|
return;
|
|
5121
5248
|
}
|
|
5122
5249
|
if (isActive) {
|
|
@@ -5133,8 +5260,8 @@ var DataSpaceManager = class {
|
|
|
5133
5260
|
async _createDelegatedInvitations(space, invitations) {
|
|
5134
5261
|
const tasks = invitations.map(([credentialId, invitation]) => {
|
|
5135
5262
|
return this._invitationsManager.createInvitation({
|
|
5136
|
-
type:
|
|
5137
|
-
kind:
|
|
5263
|
+
type: import_services14.Invitation.Type.DELEGATED,
|
|
5264
|
+
kind: import_services14.Invitation.Kind.SPACE,
|
|
5138
5265
|
spaceKey: space.key,
|
|
5139
5266
|
authMethod: invitation.authMethod,
|
|
5140
5267
|
invitationId: invitation.invitationId,
|
|
@@ -5152,21 +5279,21 @@ var DataSpaceManager = class {
|
|
|
5152
5279
|
}
|
|
5153
5280
|
};
|
|
5154
5281
|
_ts_decorate5([
|
|
5155
|
-
|
|
5282
|
+
import_async16.synchronized
|
|
5156
5283
|
], DataSpaceManager.prototype, "open", null);
|
|
5157
5284
|
_ts_decorate5([
|
|
5158
|
-
|
|
5285
|
+
import_async16.synchronized
|
|
5159
5286
|
], DataSpaceManager.prototype, "close", null);
|
|
5160
5287
|
_ts_decorate5([
|
|
5161
|
-
|
|
5288
|
+
import_async16.synchronized
|
|
5162
5289
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
5163
5290
|
_ts_decorate5([
|
|
5164
|
-
|
|
5291
|
+
import_async16.synchronized
|
|
5165
5292
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
5166
5293
|
DataSpaceManager = _ts_decorate5([
|
|
5167
|
-
(0,
|
|
5294
|
+
(0, import_async16.trackLeaks)("open", "close")
|
|
5168
5295
|
], DataSpaceManager);
|
|
5169
|
-
var
|
|
5296
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5170
5297
|
var SpacesServiceImpl = class {
|
|
5171
5298
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5172
5299
|
this._identityManager = _identityManager;
|
|
@@ -5185,10 +5312,10 @@ var SpacesServiceImpl = class {
|
|
|
5185
5312
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
|
|
5186
5313
|
if (state) {
|
|
5187
5314
|
switch (state) {
|
|
5188
|
-
case
|
|
5315
|
+
case import_services15.SpaceState.ACTIVE:
|
|
5189
5316
|
await space.activate();
|
|
5190
5317
|
break;
|
|
5191
|
-
case
|
|
5318
|
+
case import_services15.SpaceState.INACTIVE:
|
|
5192
5319
|
await space.deactivate();
|
|
5193
5320
|
break;
|
|
5194
5321
|
default:
|
|
@@ -5209,9 +5336,9 @@ var SpacesServiceImpl = class {
|
|
|
5209
5336
|
});
|
|
5210
5337
|
}
|
|
5211
5338
|
const credentials = await (0, import_credentials19.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5212
|
-
(0,
|
|
5213
|
-
F:
|
|
5214
|
-
L:
|
|
5339
|
+
(0, import_invariant16.invariant)(credentials[0].credential, void 0, {
|
|
5340
|
+
F: __dxlog_file18,
|
|
5341
|
+
L: 98,
|
|
5215
5342
|
S: this,
|
|
5216
5343
|
A: [
|
|
5217
5344
|
"credentials[0].credential",
|
|
@@ -5219,9 +5346,9 @@ var SpacesServiceImpl = class {
|
|
|
5219
5346
|
]
|
|
5220
5347
|
});
|
|
5221
5348
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5222
|
-
(0,
|
|
5223
|
-
F:
|
|
5224
|
-
L:
|
|
5349
|
+
(0, import_invariant16.invariant)((0, import_credentials19.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5350
|
+
F: __dxlog_file18,
|
|
5351
|
+
L: 100,
|
|
5225
5352
|
S: this,
|
|
5226
5353
|
A: [
|
|
5227
5354
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -5232,14 +5359,14 @@ var SpacesServiceImpl = class {
|
|
|
5232
5359
|
}
|
|
5233
5360
|
querySpaces() {
|
|
5234
5361
|
return new import_codec_protobuf11.Stream(({ next, ctx }) => {
|
|
5235
|
-
const scheduler = new
|
|
5362
|
+
const scheduler = new import_async17.UpdateScheduler(ctx, async () => {
|
|
5236
5363
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5237
5364
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5238
|
-
(0,
|
|
5365
|
+
(0, import_log15.log)("update", {
|
|
5239
5366
|
spaces
|
|
5240
5367
|
}, {
|
|
5241
|
-
F:
|
|
5242
|
-
L:
|
|
5368
|
+
F: __dxlog_file18,
|
|
5369
|
+
L: 111,
|
|
5243
5370
|
S: this,
|
|
5244
5371
|
C: (f, a) => f(...a)
|
|
5245
5372
|
});
|
|
@@ -5250,9 +5377,9 @@ var SpacesServiceImpl = class {
|
|
|
5250
5377
|
}, {
|
|
5251
5378
|
maxFrequency: process.env.NODE_ENV === "test" ? void 0 : 2
|
|
5252
5379
|
});
|
|
5253
|
-
(0,
|
|
5380
|
+
(0, import_async17.scheduleTask)(ctx, async () => {
|
|
5254
5381
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5255
|
-
const subscriptions = new
|
|
5382
|
+
const subscriptions = new import_async17.EventSubscriptions();
|
|
5256
5383
|
ctx.onDispose(() => subscriptions.clear());
|
|
5257
5384
|
const subscribeSpaces = () => {
|
|
5258
5385
|
subscriptions.clear();
|
|
@@ -5284,7 +5411,7 @@ var SpacesServiceImpl = class {
|
|
|
5284
5411
|
}
|
|
5285
5412
|
subscribeMessages({ spaceKey, channel }) {
|
|
5286
5413
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
5287
|
-
(0,
|
|
5414
|
+
(0, import_async17.scheduleTask)(ctx, async () => {
|
|
5288
5415
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5289
5416
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
|
|
5290
5417
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
@@ -5303,7 +5430,7 @@ var SpacesServiceImpl = class {
|
|
|
5303
5430
|
}
|
|
5304
5431
|
};
|
|
5305
5432
|
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
5306
|
-
(0,
|
|
5433
|
+
(0, import_async17.scheduleTask)(ctx, async () => {
|
|
5307
5434
|
await space.spaceState.addCredentialProcessor(processor);
|
|
5308
5435
|
if (noTail) {
|
|
5309
5436
|
close();
|
|
@@ -5321,18 +5448,18 @@ var SpacesServiceImpl = class {
|
|
|
5321
5448
|
}
|
|
5322
5449
|
});
|
|
5323
5450
|
} else {
|
|
5324
|
-
(0,
|
|
5325
|
-
F:
|
|
5326
|
-
L:
|
|
5451
|
+
(0, import_invariant16.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5452
|
+
F: __dxlog_file18,
|
|
5453
|
+
L: 199,
|
|
5327
5454
|
S: this,
|
|
5328
5455
|
A: [
|
|
5329
5456
|
"!credential.id",
|
|
5330
5457
|
"'Id on unsigned credentials is not allowed'"
|
|
5331
5458
|
]
|
|
5332
5459
|
});
|
|
5333
|
-
(0,
|
|
5334
|
-
F:
|
|
5335
|
-
L:
|
|
5460
|
+
(0, import_invariant16.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
5461
|
+
F: __dxlog_file18,
|
|
5462
|
+
L: 200,
|
|
5336
5463
|
S: this,
|
|
5337
5464
|
A: [
|
|
5338
5465
|
"this._identityManager.identity",
|
|
@@ -5340,9 +5467,9 @@ var SpacesServiceImpl = class {
|
|
|
5340
5467
|
]
|
|
5341
5468
|
});
|
|
5342
5469
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5343
|
-
(0,
|
|
5344
|
-
F:
|
|
5345
|
-
L:
|
|
5470
|
+
(0, import_invariant16.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5471
|
+
F: __dxlog_file18,
|
|
5472
|
+
L: 202,
|
|
5346
5473
|
S: this,
|
|
5347
5474
|
A: [
|
|
5348
5475
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -5364,10 +5491,13 @@ var SpacesServiceImpl = class {
|
|
|
5364
5491
|
async createEpoch({ spaceKey, migration, automergeRootUrl }) {
|
|
5365
5492
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5366
5493
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
|
|
5367
|
-
await space.createEpoch({
|
|
5494
|
+
const credential = await space.createEpoch({
|
|
5368
5495
|
migration,
|
|
5369
5496
|
newAutomergeRoot: automergeRootUrl
|
|
5370
5497
|
});
|
|
5498
|
+
return {
|
|
5499
|
+
epochCredential: credential ?? void 0
|
|
5500
|
+
};
|
|
5371
5501
|
}
|
|
5372
5502
|
_serializeSpace(space) {
|
|
5373
5503
|
return {
|
|
@@ -5400,7 +5530,7 @@ var SpacesServiceImpl = class {
|
|
|
5400
5530
|
profile: member.profile ?? {}
|
|
5401
5531
|
},
|
|
5402
5532
|
role: member.role,
|
|
5403
|
-
presence: peers.length > 0 ?
|
|
5533
|
+
presence: peers.length > 0 ? import_services15.SpaceMember.PresenceState.ONLINE : import_services15.SpaceMember.PresenceState.OFFLINE,
|
|
5404
5534
|
peerStates: peers
|
|
5405
5535
|
};
|
|
5406
5536
|
}),
|
|
@@ -5438,8 +5568,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5438
5568
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5439
5569
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5440
5570
|
}
|
|
5441
|
-
var
|
|
5442
|
-
var ServiceContext = class extends
|
|
5571
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5572
|
+
var ServiceContext = class extends import_context15.Resource {
|
|
5443
5573
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5444
5574
|
super();
|
|
5445
5575
|
this.storage = storage;
|
|
@@ -5447,11 +5577,11 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5447
5577
|
this.networkManager = networkManager;
|
|
5448
5578
|
this.signalManager = signalManager;
|
|
5449
5579
|
this._runtimeParams = _runtimeParams;
|
|
5450
|
-
this.initialized = new
|
|
5580
|
+
this.initialized = new import_async18.Trigger();
|
|
5451
5581
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5452
5582
|
this._instanceId = import_keys13.PublicKey.random().toHex();
|
|
5453
|
-
this.metadataStore = new
|
|
5454
|
-
this.snapshotStore = new
|
|
5583
|
+
this.metadataStore = new import_echo_pipeline5.MetadataStore(storage.createDirectory("metadata"));
|
|
5584
|
+
this.snapshotStore = new import_echo_pipeline5.SnapshotStore(storage.createDirectory("snapshots"));
|
|
5455
5585
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
5456
5586
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
5457
5587
|
this.feedStore = new import_feed_store5.FeedStore({
|
|
@@ -5459,12 +5589,12 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5459
5589
|
root: storage.createDirectory("feeds"),
|
|
5460
5590
|
signer: this.keyring,
|
|
5461
5591
|
hypercore: {
|
|
5462
|
-
valueEncoding:
|
|
5592
|
+
valueEncoding: import_echo_pipeline5.valueEncoding,
|
|
5463
5593
|
stats: true
|
|
5464
5594
|
}
|
|
5465
5595
|
})
|
|
5466
5596
|
});
|
|
5467
|
-
this.spaceManager = new
|
|
5597
|
+
this.spaceManager = new import_echo_pipeline5.SpaceManager({
|
|
5468
5598
|
feedStore: this.feedStore,
|
|
5469
5599
|
networkManager: this.networkManager,
|
|
5470
5600
|
blobStore: this.blobStore,
|
|
@@ -5472,27 +5602,26 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5472
5602
|
snapshotStore: this.snapshotStore
|
|
5473
5603
|
});
|
|
5474
5604
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
5475
|
-
this.echoHost = new
|
|
5476
|
-
kv: this.level
|
|
5477
|
-
storage: this.storage
|
|
5605
|
+
this.echoHost = new import_echo_db3.EchoHost({
|
|
5606
|
+
kv: this.level
|
|
5478
5607
|
});
|
|
5479
5608
|
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
5480
5609
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
5481
|
-
this._handlerFactories.set(
|
|
5610
|
+
this._handlerFactories.set(import_services16.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
5482
5611
|
}
|
|
5483
5612
|
async _open(ctx) {
|
|
5484
5613
|
await this._checkStorageVersion();
|
|
5485
|
-
(0,
|
|
5486
|
-
F:
|
|
5487
|
-
L:
|
|
5614
|
+
(0, import_log16.log)("opening...", void 0, {
|
|
5615
|
+
F: __dxlog_file19,
|
|
5616
|
+
L: 149,
|
|
5488
5617
|
S: this,
|
|
5489
5618
|
C: (f, a) => f(...a)
|
|
5490
5619
|
});
|
|
5491
|
-
|
|
5620
|
+
import_log16.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
|
|
5492
5621
|
id: this._instanceId
|
|
5493
5622
|
}), {
|
|
5494
|
-
F:
|
|
5495
|
-
L:
|
|
5623
|
+
F: __dxlog_file19,
|
|
5624
|
+
L: 150,
|
|
5496
5625
|
S: this,
|
|
5497
5626
|
C: (f, a) => f(...a)
|
|
5498
5627
|
});
|
|
@@ -5506,33 +5635,33 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5506
5635
|
await this._initialize(ctx);
|
|
5507
5636
|
}
|
|
5508
5637
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5509
|
-
(0,
|
|
5638
|
+
(0, import_log16.log)("loaded persistent invitations", {
|
|
5510
5639
|
count: loadedInvitations.invitations?.length
|
|
5511
5640
|
}, {
|
|
5512
|
-
F:
|
|
5513
|
-
L:
|
|
5641
|
+
F: __dxlog_file19,
|
|
5642
|
+
L: 163,
|
|
5514
5643
|
S: this,
|
|
5515
5644
|
C: (f, a) => f(...a)
|
|
5516
5645
|
});
|
|
5517
|
-
|
|
5646
|
+
import_log16.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
|
|
5518
5647
|
id: this._instanceId
|
|
5519
5648
|
}), {
|
|
5520
|
-
F:
|
|
5521
|
-
L:
|
|
5649
|
+
F: __dxlog_file19,
|
|
5650
|
+
L: 165,
|
|
5522
5651
|
S: this,
|
|
5523
5652
|
C: (f, a) => f(...a)
|
|
5524
5653
|
});
|
|
5525
|
-
(0,
|
|
5526
|
-
F:
|
|
5527
|
-
L:
|
|
5654
|
+
(0, import_log16.log)("opened", void 0, {
|
|
5655
|
+
F: __dxlog_file19,
|
|
5656
|
+
L: 166,
|
|
5528
5657
|
S: this,
|
|
5529
5658
|
C: (f, a) => f(...a)
|
|
5530
5659
|
});
|
|
5531
5660
|
}
|
|
5532
5661
|
async _close(ctx) {
|
|
5533
|
-
(0,
|
|
5534
|
-
F:
|
|
5535
|
-
L:
|
|
5662
|
+
(0, import_log16.log)("closing...", void 0, {
|
|
5663
|
+
F: __dxlog_file19,
|
|
5664
|
+
L: 170,
|
|
5536
5665
|
S: this,
|
|
5537
5666
|
C: (f, a) => f(...a)
|
|
5538
5667
|
});
|
|
@@ -5547,23 +5676,23 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5547
5676
|
await this.echoHost.close(ctx);
|
|
5548
5677
|
await this.networkManager.close();
|
|
5549
5678
|
await this.signalManager.close();
|
|
5550
|
-
(0,
|
|
5551
|
-
F:
|
|
5552
|
-
L:
|
|
5679
|
+
(0, import_log16.log)("closed", void 0, {
|
|
5680
|
+
F: __dxlog_file19,
|
|
5681
|
+
L: 182,
|
|
5553
5682
|
S: this,
|
|
5554
5683
|
C: (f, a) => f(...a)
|
|
5555
5684
|
});
|
|
5556
5685
|
}
|
|
5557
5686
|
async createIdentity(params = {}) {
|
|
5558
5687
|
const identity = await this.identityManager.createIdentity(params);
|
|
5559
|
-
await this._initialize(new
|
|
5688
|
+
await this._initialize(new import_context15.Context());
|
|
5560
5689
|
return identity;
|
|
5561
5690
|
}
|
|
5562
5691
|
getInvitationHandler(invitation) {
|
|
5563
5692
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5564
|
-
(0,
|
|
5565
|
-
F:
|
|
5566
|
-
L:
|
|
5693
|
+
(0, import_invariant17.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5694
|
+
F: __dxlog_file19,
|
|
5695
|
+
L: 193,
|
|
5567
5696
|
S: this,
|
|
5568
5697
|
A: [
|
|
5569
5698
|
"factory",
|
|
@@ -5582,7 +5711,7 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5582
5711
|
}
|
|
5583
5712
|
async _acceptIdentity(params) {
|
|
5584
5713
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
5585
|
-
await this._initialize(new
|
|
5714
|
+
await this._initialize(new import_context15.Context());
|
|
5586
5715
|
return identity;
|
|
5587
5716
|
}
|
|
5588
5717
|
async _checkStorageVersion() {
|
|
@@ -5593,9 +5722,9 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5593
5722
|
}
|
|
5594
5723
|
// Called when identity is created.
|
|
5595
5724
|
async _initialize(ctx) {
|
|
5596
|
-
(0,
|
|
5597
|
-
F:
|
|
5598
|
-
L:
|
|
5725
|
+
(0, import_log16.log)("initializing spaces...", void 0, {
|
|
5726
|
+
F: __dxlog_file19,
|
|
5727
|
+
L: 224,
|
|
5599
5728
|
S: this,
|
|
5600
5729
|
C: (f, a) => f(...a)
|
|
5601
5730
|
});
|
|
@@ -5615,10 +5744,10 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5615
5744
|
};
|
|
5616
5745
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.echoHost, this.invitationsManager, this._runtimeParams);
|
|
5617
5746
|
await this.dataSpaceManager.open();
|
|
5618
|
-
this._handlerFactories.set(
|
|
5619
|
-
(0,
|
|
5620
|
-
F:
|
|
5621
|
-
L:
|
|
5747
|
+
this._handlerFactories.set(import_services16.Invitation.Kind.SPACE, (invitation) => {
|
|
5748
|
+
(0, import_invariant17.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
5749
|
+
F: __dxlog_file19,
|
|
5750
|
+
L: 249,
|
|
5622
5751
|
S: this,
|
|
5623
5752
|
A: [
|
|
5624
5753
|
"this.dataSpaceManager",
|
|
@@ -5638,33 +5767,33 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5638
5767
|
return;
|
|
5639
5768
|
}
|
|
5640
5769
|
if (!this.dataSpaceManager) {
|
|
5641
|
-
(0,
|
|
5770
|
+
(0, import_log16.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5642
5771
|
details: assertion
|
|
5643
5772
|
}, {
|
|
5644
|
-
F:
|
|
5645
|
-
L:
|
|
5773
|
+
F: __dxlog_file19,
|
|
5774
|
+
L: 265,
|
|
5646
5775
|
S: this,
|
|
5647
5776
|
C: (f, a) => f(...a)
|
|
5648
5777
|
});
|
|
5649
5778
|
return;
|
|
5650
5779
|
}
|
|
5651
5780
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5652
|
-
(0,
|
|
5781
|
+
(0, import_log16.log)("space already exists, ignoring space admission", {
|
|
5653
5782
|
details: assertion
|
|
5654
5783
|
}, {
|
|
5655
|
-
F:
|
|
5656
|
-
L:
|
|
5784
|
+
F: __dxlog_file19,
|
|
5785
|
+
L: 269,
|
|
5657
5786
|
S: this,
|
|
5658
5787
|
C: (f, a) => f(...a)
|
|
5659
5788
|
});
|
|
5660
5789
|
return;
|
|
5661
5790
|
}
|
|
5662
5791
|
try {
|
|
5663
|
-
(0,
|
|
5792
|
+
(0, import_log16.log)("accepting space recorded in halo", {
|
|
5664
5793
|
details: assertion
|
|
5665
5794
|
}, {
|
|
5666
|
-
F:
|
|
5667
|
-
L:
|
|
5795
|
+
F: __dxlog_file19,
|
|
5796
|
+
L: 274,
|
|
5668
5797
|
S: this,
|
|
5669
5798
|
C: (f, a) => f(...a)
|
|
5670
5799
|
});
|
|
@@ -5673,9 +5802,9 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5673
5802
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5674
5803
|
});
|
|
5675
5804
|
} catch (err) {
|
|
5676
|
-
|
|
5677
|
-
F:
|
|
5678
|
-
L:
|
|
5805
|
+
import_log16.log.catch(err, void 0, {
|
|
5806
|
+
F: __dxlog_file19,
|
|
5807
|
+
L: 280,
|
|
5679
5808
|
S: this,
|
|
5680
5809
|
C: (f, a) => f(...a)
|
|
5681
5810
|
});
|
|
@@ -5692,7 +5821,7 @@ _ts_decorate6([
|
|
|
5692
5821
|
import_tracing8.trace.span()
|
|
5693
5822
|
], ServiceContext.prototype, "_initialize", null);
|
|
5694
5823
|
ServiceContext = _ts_decorate6([
|
|
5695
|
-
(0,
|
|
5824
|
+
(0, import_util10.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
5696
5825
|
import_tracing8.trace.resource()
|
|
5697
5826
|
], ServiceContext);
|
|
5698
5827
|
var ServiceRegistry = class {
|
|
@@ -5727,7 +5856,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5727
5856
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5728
5857
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5729
5858
|
}
|
|
5730
|
-
var
|
|
5859
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
5731
5860
|
var Lock = class {
|
|
5732
5861
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
5733
5862
|
this._lockPath = lockPath;
|
|
@@ -5738,16 +5867,16 @@ var Lock = class {
|
|
|
5738
5867
|
return this._lockPath;
|
|
5739
5868
|
}
|
|
5740
5869
|
async acquire() {
|
|
5741
|
-
(0,
|
|
5742
|
-
F:
|
|
5870
|
+
(0, import_log17.log)("acquiring lock...", void 0, {
|
|
5871
|
+
F: __dxlog_file20,
|
|
5743
5872
|
L: 32,
|
|
5744
5873
|
S: this,
|
|
5745
5874
|
C: (f, a) => f(...a)
|
|
5746
5875
|
});
|
|
5747
5876
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
5748
5877
|
await this._onAcquire?.();
|
|
5749
|
-
(0,
|
|
5750
|
-
F:
|
|
5878
|
+
(0, import_log17.log)("acquired lock", void 0, {
|
|
5879
|
+
F: __dxlog_file20,
|
|
5751
5880
|
L: 37,
|
|
5752
5881
|
S: this,
|
|
5753
5882
|
C: (f, a) => f(...a)
|
|
@@ -5755,8 +5884,8 @@ var Lock = class {
|
|
|
5755
5884
|
}
|
|
5756
5885
|
async release() {
|
|
5757
5886
|
await this._onRelease?.();
|
|
5758
|
-
(0,
|
|
5759
|
-
F:
|
|
5887
|
+
(0, import_invariant18.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
5888
|
+
F: __dxlog_file20,
|
|
5760
5889
|
L: 42,
|
|
5761
5890
|
S: this,
|
|
5762
5891
|
A: [
|
|
@@ -5768,11 +5897,11 @@ var Lock = class {
|
|
|
5768
5897
|
}
|
|
5769
5898
|
};
|
|
5770
5899
|
_ts_decorate7([
|
|
5771
|
-
|
|
5900
|
+
import_log17.logInfo
|
|
5772
5901
|
], Lock.prototype, "lockKey", null);
|
|
5773
5902
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
5774
5903
|
var getRootPath = (config) => {
|
|
5775
|
-
const { dataRoot = (0,
|
|
5904
|
+
const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5776
5905
|
return `${dataRoot}/`;
|
|
5777
5906
|
};
|
|
5778
5907
|
var isPersistent = (config) => {
|
|
@@ -5828,7 +5957,7 @@ var createLevel = async (config) => {
|
|
|
5828
5957
|
await level.open();
|
|
5829
5958
|
return level;
|
|
5830
5959
|
};
|
|
5831
|
-
var
|
|
5960
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
5832
5961
|
var DevicesServiceImpl = class {
|
|
5833
5962
|
constructor(_identityManager) {
|
|
5834
5963
|
this._identityManager = _identityManager;
|
|
@@ -5845,8 +5974,8 @@ var DevicesServiceImpl = class {
|
|
|
5845
5974
|
devices: []
|
|
5846
5975
|
});
|
|
5847
5976
|
} else {
|
|
5848
|
-
(0,
|
|
5849
|
-
F:
|
|
5977
|
+
(0, import_invariant20.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
5978
|
+
F: __dxlog_file21,
|
|
5850
5979
|
L: 32,
|
|
5851
5980
|
S: this,
|
|
5852
5981
|
A: [
|
|
@@ -5861,9 +5990,9 @@ var DevicesServiceImpl = class {
|
|
|
5861
5990
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
5862
5991
|
return {
|
|
5863
5992
|
deviceKey: key,
|
|
5864
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
5993
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services18.DeviceKind.CURRENT : import_services18.DeviceKind.TRUSTED,
|
|
5865
5994
|
profile,
|
|
5866
|
-
presence: isMe ?
|
|
5995
|
+
presence: isMe ? import_services18.Device.PresenceState.ONLINE : peerState ? import_services18.Device.PresenceState.ONLINE : import_services18.Device.PresenceState.OFFLINE
|
|
5867
5996
|
};
|
|
5868
5997
|
})
|
|
5869
5998
|
});
|
|
@@ -5887,7 +6016,7 @@ var DevicesServiceImpl = class {
|
|
|
5887
6016
|
presenceSubscribed = true;
|
|
5888
6017
|
}
|
|
5889
6018
|
};
|
|
5890
|
-
const subscriptions = new
|
|
6019
|
+
const subscriptions = new import_async20.EventSubscriptions();
|
|
5891
6020
|
if (this._identityManager.identity) {
|
|
5892
6021
|
subscribeIdentity();
|
|
5893
6022
|
subscribePresence();
|
|
@@ -5912,7 +6041,7 @@ var DiagnosticsCollector = class {
|
|
|
5912
6041
|
}
|
|
5913
6042
|
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5914
6043
|
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5915
|
-
keys: options.humanize ?
|
|
6044
|
+
keys: options.humanize ? import_services19.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services19.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5916
6045
|
}, {
|
|
5917
6046
|
timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
|
|
5918
6047
|
});
|
|
@@ -5927,7 +6056,7 @@ var DiagnosticsCollector = class {
|
|
|
5927
6056
|
client: clientDiagnostics,
|
|
5928
6057
|
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
5929
6058
|
};
|
|
5930
|
-
return JSON.parse(JSON.stringify(diagnostics, (0,
|
|
6059
|
+
return JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)(options)));
|
|
5931
6060
|
}
|
|
5932
6061
|
};
|
|
5933
6062
|
var findSystemServiceProvider = () => {
|
|
@@ -5937,11 +6066,11 @@ var findSystemServiceProvider = () => {
|
|
|
5937
6066
|
};
|
|
5938
6067
|
var findConfigs = () => {
|
|
5939
6068
|
const configs = import_tracing10.TRACE_PROCESSOR.findResourcesByAnnotation(import_config3.ConfigResource);
|
|
5940
|
-
return configs.map((r) => r.instance.deref()).filter(
|
|
6069
|
+
return configs.map((r) => r.instance.deref()).filter(import_util12.nonNullable);
|
|
5941
6070
|
};
|
|
5942
6071
|
var LoggingServiceImpl = class {
|
|
5943
6072
|
constructor() {
|
|
5944
|
-
this._logs = new
|
|
6073
|
+
this._logs = new import_async21.Event();
|
|
5945
6074
|
this._started = Date.now();
|
|
5946
6075
|
this._sessionId = import_keys17.PublicKey.random().toHex();
|
|
5947
6076
|
this._logProcessor = (_config, entry2) => {
|
|
@@ -5949,23 +6078,23 @@ var LoggingServiceImpl = class {
|
|
|
5949
6078
|
};
|
|
5950
6079
|
}
|
|
5951
6080
|
async open() {
|
|
5952
|
-
|
|
6081
|
+
import_log19.log.runtimeConfig.processors.push(this._logProcessor);
|
|
5953
6082
|
}
|
|
5954
6083
|
async close() {
|
|
5955
|
-
const index =
|
|
5956
|
-
|
|
6084
|
+
const index = import_log19.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
6085
|
+
import_log19.log.runtimeConfig.processors.splice(index, 1);
|
|
5957
6086
|
}
|
|
5958
6087
|
async controlMetrics({ reset, record }) {
|
|
5959
6088
|
if (reset) {
|
|
5960
|
-
|
|
6089
|
+
import_util14.tracer.clear();
|
|
5961
6090
|
}
|
|
5962
6091
|
if (record === true) {
|
|
5963
|
-
|
|
6092
|
+
import_util14.tracer.start();
|
|
5964
6093
|
} else if (record === false) {
|
|
5965
|
-
|
|
6094
|
+
import_util14.tracer.stop();
|
|
5966
6095
|
}
|
|
5967
6096
|
return {
|
|
5968
|
-
recording:
|
|
6097
|
+
recording: import_util14.tracer.recording
|
|
5969
6098
|
};
|
|
5970
6099
|
}
|
|
5971
6100
|
/**
|
|
@@ -5973,10 +6102,10 @@ var LoggingServiceImpl = class {
|
|
|
5973
6102
|
*/
|
|
5974
6103
|
queryMetrics({ interval = 5e3 }) {
|
|
5975
6104
|
const getNumericalValues = (key) => {
|
|
5976
|
-
const events =
|
|
6105
|
+
const events = import_util14.tracer.get(key) ?? [];
|
|
5977
6106
|
return {
|
|
5978
6107
|
key,
|
|
5979
|
-
stats: (0,
|
|
6108
|
+
stats: (0, import_util14.numericalValues)(events, "duration")
|
|
5980
6109
|
};
|
|
5981
6110
|
};
|
|
5982
6111
|
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
@@ -6014,7 +6143,7 @@ var LoggingServiceImpl = class {
|
|
|
6014
6143
|
}
|
|
6015
6144
|
const record = {
|
|
6016
6145
|
...entry2,
|
|
6017
|
-
context: (0,
|
|
6146
|
+
context: (0, import_util14.jsonify)((0, import_log19.getContextFromEntry)(entry2)),
|
|
6018
6147
|
timestamp: /* @__PURE__ */ new Date(),
|
|
6019
6148
|
meta: {
|
|
6020
6149
|
// TODO(dmaretskyi): Fix proto.
|
|
@@ -6023,7 +6152,7 @@ var LoggingServiceImpl = class {
|
|
|
6023
6152
|
scope: {
|
|
6024
6153
|
hostSessionId: this._sessionId,
|
|
6025
6154
|
uptimeSeconds: (Date.now() - this._started) / 1e3,
|
|
6026
|
-
name: (0,
|
|
6155
|
+
name: (0, import_util14.getDebugName)(entry2.meta?.S)
|
|
6027
6156
|
}
|
|
6028
6157
|
}
|
|
6029
6158
|
};
|
|
@@ -6040,16 +6169,16 @@ var LoggingServiceImpl = class {
|
|
|
6040
6169
|
};
|
|
6041
6170
|
var matchFilter = (filter, level, path2, options) => {
|
|
6042
6171
|
switch (options) {
|
|
6043
|
-
case
|
|
6172
|
+
case import_services20.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
6044
6173
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
6045
|
-
case
|
|
6174
|
+
case import_services20.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
6046
6175
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
6047
6176
|
}
|
|
6048
6177
|
};
|
|
6049
6178
|
var shouldLog = (entry2, request) => {
|
|
6050
|
-
const options = request.options ??
|
|
6179
|
+
const options = request.options ?? import_services20.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
6051
6180
|
if (request.filters === void 0) {
|
|
6052
|
-
return options ===
|
|
6181
|
+
return options === import_services20.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
6053
6182
|
} else {
|
|
6054
6183
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
6055
6184
|
}
|
|
@@ -6104,9 +6233,9 @@ var SystemServiceImpl = class {
|
|
|
6104
6233
|
const diagnostics = await this._getDiagnostics();
|
|
6105
6234
|
return {
|
|
6106
6235
|
timestamp: /* @__PURE__ */ new Date(),
|
|
6107
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
6108
|
-
truncate: keys ===
|
|
6109
|
-
humanize: keys ===
|
|
6236
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util15.jsonKeyReplacer)({
|
|
6237
|
+
truncate: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
6238
|
+
humanize: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
6110
6239
|
})))
|
|
6111
6240
|
};
|
|
6112
6241
|
}
|
|
@@ -6147,7 +6276,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
6147
6276
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6148
6277
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6149
6278
|
}
|
|
6150
|
-
var
|
|
6279
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
6151
6280
|
var ClientServicesHost = class {
|
|
6152
6281
|
constructor({
|
|
6153
6282
|
config,
|
|
@@ -6161,7 +6290,7 @@ var ClientServicesHost = class {
|
|
|
6161
6290
|
runtimeParams
|
|
6162
6291
|
} = {}) {
|
|
6163
6292
|
this._tracingService = import_tracing9.TRACE_PROCESSOR.createTraceSender();
|
|
6164
|
-
this._statusUpdate = new
|
|
6293
|
+
this._statusUpdate = new import_async19.Event();
|
|
6165
6294
|
this._opening = false;
|
|
6166
6295
|
this._open = false;
|
|
6167
6296
|
this._storage = storage;
|
|
@@ -6180,7 +6309,7 @@ var ClientServicesHost = class {
|
|
|
6180
6309
|
lockKey,
|
|
6181
6310
|
onAcquire: () => {
|
|
6182
6311
|
if (!this._opening) {
|
|
6183
|
-
void this.open(new
|
|
6312
|
+
void this.open(new import_context16.Context());
|
|
6184
6313
|
}
|
|
6185
6314
|
},
|
|
6186
6315
|
onRelease: () => this.close()
|
|
@@ -6189,14 +6318,14 @@ var ClientServicesHost = class {
|
|
|
6189
6318
|
this._systemService = new SystemServiceImpl({
|
|
6190
6319
|
config: () => this._config,
|
|
6191
6320
|
statusUpdate: this._statusUpdate,
|
|
6192
|
-
getCurrentStatus: () => this.isOpen ?
|
|
6321
|
+
getCurrentStatus: () => this.isOpen ? import_services17.SystemStatus.ACTIVE : import_services17.SystemStatus.INACTIVE,
|
|
6193
6322
|
getDiagnostics: () => {
|
|
6194
6323
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
6195
6324
|
},
|
|
6196
6325
|
onUpdateStatus: async (status) => {
|
|
6197
|
-
if (!this.isOpen && status ===
|
|
6326
|
+
if (!this.isOpen && status === import_services17.SystemStatus.ACTIVE) {
|
|
6198
6327
|
await this._resourceLock?.acquire();
|
|
6199
|
-
} else if (this.isOpen && status ===
|
|
6328
|
+
} else if (this.isOpen && status === import_services17.SystemStatus.INACTIVE) {
|
|
6200
6329
|
await this._resourceLock?.release();
|
|
6201
6330
|
}
|
|
6202
6331
|
},
|
|
@@ -6235,8 +6364,8 @@ var ClientServicesHost = class {
|
|
|
6235
6364
|
* Can only be called once.
|
|
6236
6365
|
*/
|
|
6237
6366
|
initialize({ config, ...options }) {
|
|
6238
|
-
(0,
|
|
6239
|
-
F:
|
|
6367
|
+
(0, import_invariant19.invariant)(!this._open, "service host is open", {
|
|
6368
|
+
F: __dxlog_file22,
|
|
6240
6369
|
L: 186,
|
|
6241
6370
|
S: this,
|
|
6242
6371
|
A: [
|
|
@@ -6244,15 +6373,15 @@ var ClientServicesHost = class {
|
|
|
6244
6373
|
"'service host is open'"
|
|
6245
6374
|
]
|
|
6246
6375
|
});
|
|
6247
|
-
(0,
|
|
6248
|
-
F:
|
|
6376
|
+
(0, import_log18.log)("initializing...", void 0, {
|
|
6377
|
+
F: __dxlog_file22,
|
|
6249
6378
|
L: 187,
|
|
6250
6379
|
S: this,
|
|
6251
6380
|
C: (f, a) => f(...a)
|
|
6252
6381
|
});
|
|
6253
6382
|
if (config) {
|
|
6254
|
-
(0,
|
|
6255
|
-
F:
|
|
6383
|
+
(0, import_invariant19.invariant)(!this._config, "config already set", {
|
|
6384
|
+
F: __dxlog_file22,
|
|
6256
6385
|
L: 190,
|
|
6257
6386
|
S: this,
|
|
6258
6387
|
A: [
|
|
@@ -6266,8 +6395,8 @@ var ClientServicesHost = class {
|
|
|
6266
6395
|
}
|
|
6267
6396
|
}
|
|
6268
6397
|
if (!options.signalManager) {
|
|
6269
|
-
|
|
6270
|
-
F:
|
|
6398
|
+
import_log18.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
6399
|
+
F: __dxlog_file22,
|
|
6271
6400
|
L: 198,
|
|
6272
6401
|
S: this,
|
|
6273
6402
|
C: (f, a) => f(...a)
|
|
@@ -6277,8 +6406,8 @@ var ClientServicesHost = class {
|
|
|
6277
6406
|
iceServers: this._config?.get("runtime.services.ice")
|
|
6278
6407
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6279
6408
|
this._signalManager = signalManager;
|
|
6280
|
-
(0,
|
|
6281
|
-
F:
|
|
6409
|
+
(0, import_invariant19.invariant)(!this._networkManager, "network manager already set", {
|
|
6410
|
+
F: __dxlog_file22,
|
|
6282
6411
|
L: 209,
|
|
6283
6412
|
S: this,
|
|
6284
6413
|
A: [
|
|
@@ -6291,8 +6420,8 @@ var ClientServicesHost = class {
|
|
|
6291
6420
|
transportFactory,
|
|
6292
6421
|
signalManager
|
|
6293
6422
|
});
|
|
6294
|
-
(0,
|
|
6295
|
-
F:
|
|
6423
|
+
(0, import_log18.log)("initialized", void 0, {
|
|
6424
|
+
F: __dxlog_file22,
|
|
6296
6425
|
L: 216,
|
|
6297
6426
|
S: this,
|
|
6298
6427
|
C: (f, a) => f(...a)
|
|
@@ -6303,16 +6432,16 @@ var ClientServicesHost = class {
|
|
|
6303
6432
|
return;
|
|
6304
6433
|
}
|
|
6305
6434
|
const traceId = import_keys15.PublicKey.random().toHex();
|
|
6306
|
-
|
|
6435
|
+
import_log18.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
|
|
6307
6436
|
id: traceId
|
|
6308
6437
|
}), {
|
|
6309
|
-
F:
|
|
6438
|
+
F: __dxlog_file22,
|
|
6310
6439
|
L: 227,
|
|
6311
6440
|
S: this,
|
|
6312
6441
|
C: (f, a) => f(...a)
|
|
6313
6442
|
});
|
|
6314
|
-
(0,
|
|
6315
|
-
F:
|
|
6443
|
+
(0, import_invariant19.invariant)(this._config, "config not set", {
|
|
6444
|
+
F: __dxlog_file22,
|
|
6316
6445
|
L: 229,
|
|
6317
6446
|
S: this,
|
|
6318
6447
|
A: [
|
|
@@ -6320,8 +6449,8 @@ var ClientServicesHost = class {
|
|
|
6320
6449
|
"'config not set'"
|
|
6321
6450
|
]
|
|
6322
6451
|
});
|
|
6323
|
-
(0,
|
|
6324
|
-
F:
|
|
6452
|
+
(0, import_invariant19.invariant)(this._storage, "storage not set", {
|
|
6453
|
+
F: __dxlog_file22,
|
|
6325
6454
|
L: 230,
|
|
6326
6455
|
S: this,
|
|
6327
6456
|
A: [
|
|
@@ -6329,8 +6458,8 @@ var ClientServicesHost = class {
|
|
|
6329
6458
|
"'storage not set'"
|
|
6330
6459
|
]
|
|
6331
6460
|
});
|
|
6332
|
-
(0,
|
|
6333
|
-
F:
|
|
6461
|
+
(0, import_invariant19.invariant)(this._signalManager, "signal manager not set", {
|
|
6462
|
+
F: __dxlog_file22,
|
|
6334
6463
|
L: 231,
|
|
6335
6464
|
S: this,
|
|
6336
6465
|
A: [
|
|
@@ -6338,8 +6467,8 @@ var ClientServicesHost = class {
|
|
|
6338
6467
|
"'signal manager not set'"
|
|
6339
6468
|
]
|
|
6340
6469
|
});
|
|
6341
|
-
(0,
|
|
6342
|
-
F:
|
|
6470
|
+
(0, import_invariant19.invariant)(this._networkManager, "network manager not set", {
|
|
6471
|
+
F: __dxlog_file22,
|
|
6343
6472
|
L: 232,
|
|
6344
6473
|
S: this,
|
|
6345
6474
|
A: [
|
|
@@ -6348,10 +6477,10 @@ var ClientServicesHost = class {
|
|
|
6348
6477
|
]
|
|
6349
6478
|
});
|
|
6350
6479
|
this._opening = true;
|
|
6351
|
-
(0,
|
|
6480
|
+
(0, import_log18.log)("opening...", {
|
|
6352
6481
|
lockKey: this._resourceLock?.lockKey
|
|
6353
6482
|
}, {
|
|
6354
|
-
F:
|
|
6483
|
+
F: __dxlog_file22,
|
|
6355
6484
|
L: 235,
|
|
6356
6485
|
S: this,
|
|
6357
6486
|
C: (f, a) => f(...a)
|
|
@@ -6402,18 +6531,18 @@ var ClientServicesHost = class {
|
|
|
6402
6531
|
this._open = true;
|
|
6403
6532
|
this._statusUpdate.emit();
|
|
6404
6533
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6405
|
-
(0,
|
|
6534
|
+
(0, import_log18.log)("opened", {
|
|
6406
6535
|
deviceKey
|
|
6407
6536
|
}, {
|
|
6408
|
-
F:
|
|
6537
|
+
F: __dxlog_file22,
|
|
6409
6538
|
L: 314,
|
|
6410
6539
|
S: this,
|
|
6411
6540
|
C: (f, a) => f(...a)
|
|
6412
6541
|
});
|
|
6413
|
-
|
|
6542
|
+
import_log18.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
|
|
6414
6543
|
id: traceId
|
|
6415
6544
|
}), {
|
|
6416
|
-
F:
|
|
6545
|
+
F: __dxlog_file22,
|
|
6417
6546
|
L: 315,
|
|
6418
6547
|
S: this,
|
|
6419
6548
|
C: (f, a) => f(...a)
|
|
@@ -6424,10 +6553,10 @@ var ClientServicesHost = class {
|
|
|
6424
6553
|
return;
|
|
6425
6554
|
}
|
|
6426
6555
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6427
|
-
(0,
|
|
6556
|
+
(0, import_log18.log)("closing...", {
|
|
6428
6557
|
deviceKey
|
|
6429
6558
|
}, {
|
|
6430
|
-
F:
|
|
6559
|
+
F: __dxlog_file22,
|
|
6431
6560
|
L: 326,
|
|
6432
6561
|
S: this,
|
|
6433
6562
|
C: (f, a) => f(...a)
|
|
@@ -6442,10 +6571,10 @@ var ClientServicesHost = class {
|
|
|
6442
6571
|
await this._level?.close();
|
|
6443
6572
|
this._open = false;
|
|
6444
6573
|
this._statusUpdate.emit();
|
|
6445
|
-
(0,
|
|
6574
|
+
(0, import_log18.log)("closed", {
|
|
6446
6575
|
deviceKey
|
|
6447
6576
|
}, {
|
|
6448
|
-
F:
|
|
6577
|
+
F: __dxlog_file22,
|
|
6449
6578
|
L: 335,
|
|
6450
6579
|
S: this,
|
|
6451
6580
|
C: (f, a) => f(...a)
|
|
@@ -6453,32 +6582,32 @@ var ClientServicesHost = class {
|
|
|
6453
6582
|
}
|
|
6454
6583
|
async reset() {
|
|
6455
6584
|
const traceId = import_keys15.PublicKey.random().toHex();
|
|
6456
|
-
|
|
6585
|
+
import_log18.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
|
|
6457
6586
|
id: traceId
|
|
6458
6587
|
}), {
|
|
6459
|
-
F:
|
|
6588
|
+
F: __dxlog_file22,
|
|
6460
6589
|
L: 340,
|
|
6461
6590
|
S: this,
|
|
6462
6591
|
C: (f, a) => f(...a)
|
|
6463
6592
|
});
|
|
6464
|
-
|
|
6465
|
-
F:
|
|
6593
|
+
import_log18.log.info("resetting...", void 0, {
|
|
6594
|
+
F: __dxlog_file22,
|
|
6466
6595
|
L: 342,
|
|
6467
6596
|
S: this,
|
|
6468
6597
|
C: (f, a) => f(...a)
|
|
6469
6598
|
});
|
|
6470
6599
|
await this._serviceContext?.close();
|
|
6471
6600
|
await this._storage.reset();
|
|
6472
|
-
|
|
6473
|
-
F:
|
|
6601
|
+
import_log18.log.info("reset", void 0, {
|
|
6602
|
+
F: __dxlog_file22,
|
|
6474
6603
|
L: 345,
|
|
6475
6604
|
S: this,
|
|
6476
6605
|
C: (f, a) => f(...a)
|
|
6477
6606
|
});
|
|
6478
|
-
|
|
6607
|
+
import_log18.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
|
|
6479
6608
|
id: traceId
|
|
6480
6609
|
}), {
|
|
6481
|
-
F:
|
|
6610
|
+
F: __dxlog_file22,
|
|
6482
6611
|
L: 346,
|
|
6483
6612
|
S: this,
|
|
6484
6613
|
C: (f, a) => f(...a)
|
|
@@ -6498,11 +6627,11 @@ _ts_decorate8([
|
|
|
6498
6627
|
import_tracing9.trace.info()
|
|
6499
6628
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
6500
6629
|
_ts_decorate8([
|
|
6501
|
-
|
|
6630
|
+
import_async19.synchronized,
|
|
6502
6631
|
import_tracing9.trace.span()
|
|
6503
6632
|
], ClientServicesHost.prototype, "open", null);
|
|
6504
6633
|
_ts_decorate8([
|
|
6505
|
-
|
|
6634
|
+
import_async19.synchronized,
|
|
6506
6635
|
import_tracing9.trace.span()
|
|
6507
6636
|
], ClientServicesHost.prototype, "close", null);
|
|
6508
6637
|
ClientServicesHost = _ts_decorate8([
|
|
@@ -6538,7 +6667,6 @@ ClientServicesHost = _ts_decorate8([
|
|
|
6538
6667
|
createDiagnostics,
|
|
6539
6668
|
createLevel,
|
|
6540
6669
|
createStorageObjects,
|
|
6541
|
-
findPropertiesObject,
|
|
6542
6670
|
getNetworkPeers,
|
|
6543
6671
|
isLocked,
|
|
6544
6672
|
subscribeToFeedBlocks,
|
|
@@ -6549,4 +6677,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
6549
6677
|
subscribeToSpaces,
|
|
6550
6678
|
subscribeToSwarmInfo
|
|
6551
6679
|
});
|
|
6552
|
-
//# sourceMappingURL=chunk-
|
|
6680
|
+
//# sourceMappingURL=chunk-MHRJ6WZU.cjs.map
|