@dxos/client-services 0.8.4-main.7ace549 → 0.8.4-main.8360d9e660
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-NXGWBEOK.mjs → chunk-FRMIC6UB.mjs} +1529 -1308
- package/dist/lib/browser/chunk-FRMIC6UB.mjs.map +7 -0
- package/dist/lib/browser/chunk-NQSC7HOE.mjs +22 -0
- package/dist/lib/browser/chunk-NQSC7HOE.mjs.map +7 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs +24 -0
- package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +441 -66
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/browser.mjs +126 -0
- package/dist/lib/browser/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/node.mjs +66 -0
- package/dist/lib/browser/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +24 -12
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +24 -0
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-AO4R6IID.mjs → chunk-6ONWVRY5.mjs} +972 -620
- package/dist/lib/node-esm/chunk-6ONWVRY5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs +22 -0
- package/dist/lib/node-esm/chunk-PKEGMOQ4.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +441 -66
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs +93 -0
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs +11 -0
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs +126 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs +66 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +24 -12
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/packlets/devtools/devtools.d.ts +2 -2
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +2 -2
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +2 -2
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +4 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +2 -2
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +2 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +2 -2
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -4
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/locks/index.d.ts +1 -1
- package/dist/types/src/packlets/locks/index.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +4 -0
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +2 -2
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/feed-syncer.d.ts +59 -0
- package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -0
- package/dist/types/src/packlets/services/feed-syncer.test.d.ts +2 -0
- package/dist/types/src/packlets/services/feed-syncer.test.d.ts.map +1 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +12 -7
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +19 -5
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +10 -5
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +2 -2
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +2 -2
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +6 -6
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +6 -3
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +6 -5
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-runtime.d.ts +31 -4
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-session.d.ts +2 -2
- package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +70 -48
- package/src/packlets/devtools/devtools.ts +2 -2
- package/src/packlets/diagnostics/index.ts +1 -1
- package/src/packlets/identity/authenticator.ts +2 -2
- package/src/packlets/identity/default-space-state-machine.ts +2 -2
- package/src/packlets/identity/identity-manager.ts +6 -6
- package/src/packlets/identity/identity-recovery-manager.ts +2 -2
- package/src/packlets/identity/identity.ts +2 -2
- package/src/packlets/invitations/device-invitation-protocol.ts +2 -2
- package/src/packlets/invitations/invitations-handler.ts +6 -6
- package/src/packlets/locks/index.ts +1 -1
- package/src/packlets/logging/logging-service.ts +4 -0
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/feed-syncer.test.ts +340 -0
- package/src/packlets/services/feed-syncer.ts +330 -0
- package/src/packlets/services/platform.ts +7 -1
- package/src/packlets/services/service-context.ts +108 -24
- package/src/packlets/services/service-host.ts +58 -16
- package/src/packlets/space-export/space-archive-writer.ts +3 -2
- package/src/packlets/spaces/data-space-manager.ts +35 -16
- package/src/packlets/spaces/data-space.ts +9 -5
- package/src/packlets/spaces/edge-feed-replicator.ts +2 -2
- package/src/packlets/spaces/epoch-migrations.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.test.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.ts +6 -6
- package/src/packlets/testing/invitation-utils.ts +7 -4
- package/src/packlets/testing/test-builder.ts +36 -10
- package/src/packlets/worker/worker-runtime.ts +149 -11
- package/src/packlets/worker/worker-session.ts +8 -8
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-NXGWBEOK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AO4R6IID.mjs.map +0 -7
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
createCollectDiagnosticsBroadcastSender
|
|
4
|
+
} from "./chunk-PKEGMOQ4.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__export,
|
|
7
|
+
__reExport
|
|
8
|
+
} from "./chunk-2SZHAWBN.mjs";
|
|
2
9
|
|
|
3
10
|
// src/packlets/devtools/feeds.ts
|
|
4
11
|
import { SubscriptionList } from "@dxos/async";
|
|
@@ -396,7 +403,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
|
396
403
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
397
404
|
|
|
398
405
|
// src/version.ts
|
|
399
|
-
var DXOS_VERSION = "0.8.4-main.
|
|
406
|
+
var DXOS_VERSION = "0.8.4-main.8360d9e660";
|
|
400
407
|
|
|
401
408
|
// src/packlets/services/platform.ts
|
|
402
409
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -409,11 +416,16 @@ var getPlatform = () => {
|
|
|
409
416
|
userAgent,
|
|
410
417
|
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
411
418
|
};
|
|
412
|
-
} else {
|
|
419
|
+
} else if (typeof SharedWorkerGlobalScope !== "undefined") {
|
|
413
420
|
return {
|
|
414
421
|
type: Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
415
422
|
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
416
423
|
};
|
|
424
|
+
} else {
|
|
425
|
+
return {
|
|
426
|
+
type: Platform.PLATFORM_TYPE.DEDICATED_WORKER,
|
|
427
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
428
|
+
};
|
|
417
429
|
}
|
|
418
430
|
} else {
|
|
419
431
|
const { platform: platform2, version, arch } = process;
|
|
@@ -550,21 +562,6 @@ var getStorageDiagnostics = async () => {
|
|
|
550
562
|
}));
|
|
551
563
|
};
|
|
552
564
|
|
|
553
|
-
// src/packlets/diagnostics/diagnostics-broadcast.ts
|
|
554
|
-
var createCollectDiagnosticsBroadcastSender = () => {
|
|
555
|
-
return {
|
|
556
|
-
broadcastDiagnosticsRequest: async () => void 0
|
|
557
|
-
};
|
|
558
|
-
};
|
|
559
|
-
var createCollectDiagnosticsBroadcastHandler = (_) => {
|
|
560
|
-
return {
|
|
561
|
-
start: () => {
|
|
562
|
-
},
|
|
563
|
-
stop: () => {
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
};
|
|
567
|
-
|
|
568
565
|
// src/packlets/diagnostics/diagnostics-collector.ts
|
|
569
566
|
import { ClientServicesProviderResource } from "@dxos/client-protocol";
|
|
570
567
|
import { ConfigResource } from "@dxos/config";
|
|
@@ -604,6 +601,15 @@ var findConfigs = () => {
|
|
|
604
601
|
return configs.map((r) => r.instance.deref()).filter(isNonNullable);
|
|
605
602
|
};
|
|
606
603
|
|
|
604
|
+
// src/packlets/diagnostics/index.ts
|
|
605
|
+
var diagnostics_exports = {};
|
|
606
|
+
__export(diagnostics_exports, {
|
|
607
|
+
DiagnosticsCollector: () => DiagnosticsCollector,
|
|
608
|
+
createDiagnostics: () => createDiagnostics
|
|
609
|
+
});
|
|
610
|
+
__reExport(diagnostics_exports, diagnostics_broadcast_star);
|
|
611
|
+
import * as diagnostics_broadcast_star from "#diagnostics-broadcast";
|
|
612
|
+
|
|
607
613
|
// src/packlets/identity/authenticator.ts
|
|
608
614
|
import { Trigger } from "@dxos/async";
|
|
609
615
|
import { Context as Context2 } from "@dxos/context";
|
|
@@ -1247,7 +1253,7 @@ import { Event as Event7, Mutex as Mutex2, scheduleTask as scheduleTask4, sleep
|
|
|
1247
1253
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
1248
1254
|
import { Context as Context6, ContextDisposedError, cancelWithContext as cancelWithContext2 } from "@dxos/context";
|
|
1249
1255
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
1250
|
-
import {
|
|
1256
|
+
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
1251
1257
|
import { SpaceDocVersion as SpaceDocVersion2 } from "@dxos/echo-protocol";
|
|
1252
1258
|
import { failedInvariant as failedInvariant3, invariant as invariant11 } from "@dxos/invariant";
|
|
1253
1259
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
@@ -1279,9 +1285,9 @@ import { SpaceProperties } from "@dxos/client-protocol";
|
|
|
1279
1285
|
import { Context as Context4, LifecycleState, Resource as Resource2, cancelWithContext } from "@dxos/context";
|
|
1280
1286
|
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
1281
1287
|
import { Type } from "@dxos/echo";
|
|
1282
|
-
import {
|
|
1283
|
-
import { AuthStatus, CredentialServerExtension, DatabaseRoot,
|
|
1284
|
-
import { SpaceDocVersion, createIdFromSpaceKey
|
|
1288
|
+
import { getSchemaDXN } from "@dxos/echo/internal";
|
|
1289
|
+
import { AuthStatus, CredentialServerExtension, DatabaseRoot, findInlineObjectOfType } from "@dxos/echo-pipeline";
|
|
1290
|
+
import { EncodedReference, SpaceDocVersion, createIdFromSpaceKey } from "@dxos/echo-protocol";
|
|
1285
1291
|
import { writeMessages } from "@dxos/feed-store";
|
|
1286
1292
|
import { assertArgument, assertState, failedInvariant, invariant as invariant3 } from "@dxos/invariant";
|
|
1287
1293
|
import { ObjectId, PublicKey as PublicKey4 } from "@dxos/keys";
|
|
@@ -1391,7 +1397,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1391
1397
|
_edgeFeatures = void 0;
|
|
1392
1398
|
_meshReplicator = void 0;
|
|
1393
1399
|
_echoEdgeReplicator = void 0;
|
|
1394
|
-
|
|
1400
|
+
_runtimeProps = void 0;
|
|
1395
1401
|
constructor(params) {
|
|
1396
1402
|
super();
|
|
1397
1403
|
this._spaceManager = params.spaceManager;
|
|
@@ -1406,14 +1412,17 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1406
1412
|
this._edgeFeatures = params.edgeFeatures;
|
|
1407
1413
|
this._echoEdgeReplicator = params.echoEdgeReplicator;
|
|
1408
1414
|
this._edgeHttpClient = params.edgeHttpClient;
|
|
1409
|
-
this.
|
|
1415
|
+
this._runtimeProps = params.runtimeProps;
|
|
1410
1416
|
trace.diagnostic({
|
|
1411
1417
|
id: "spaces",
|
|
1412
1418
|
name: "Spaces",
|
|
1413
1419
|
fetch: async () => {
|
|
1414
1420
|
return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
|
|
1415
1421
|
const rootUrl = space.automergeSpaceState.rootUrl;
|
|
1416
|
-
const rootHandle = rootUrl ? await this._echoHost.
|
|
1422
|
+
const rootHandle = rootUrl ? await this._echoHost.loadDoc(Context4.default(void 0, {
|
|
1423
|
+
F: __dxlog_file6,
|
|
1424
|
+
L: 187
|
|
1425
|
+
}), rootUrl) : void 0;
|
|
1417
1426
|
await rootHandle?.whenReady();
|
|
1418
1427
|
const rootDoc = rootHandle?.doc();
|
|
1419
1428
|
const properties = rootDoc && findInlineObjectOfType(rootDoc, Type.getTypename(SpaceProperties));
|
|
@@ -1443,7 +1452,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1443
1452
|
async _open() {
|
|
1444
1453
|
log4("open", void 0, {
|
|
1445
1454
|
F: __dxlog_file6,
|
|
1446
|
-
L:
|
|
1455
|
+
L: 221,
|
|
1447
1456
|
S: this,
|
|
1448
1457
|
C: (f, a) => f(...a)
|
|
1449
1458
|
});
|
|
@@ -1451,7 +1460,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1451
1460
|
id: this._instanceId
|
|
1452
1461
|
}), {
|
|
1453
1462
|
F: __dxlog_file6,
|
|
1454
|
-
L:
|
|
1463
|
+
L: 222,
|
|
1455
1464
|
S: this,
|
|
1456
1465
|
C: (f, a) => f(...a)
|
|
1457
1466
|
});
|
|
@@ -1459,39 +1468,64 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1459
1468
|
spaces: this._metadataStore.spaces.length
|
|
1460
1469
|
}, {
|
|
1461
1470
|
F: __dxlog_file6,
|
|
1462
|
-
L:
|
|
1471
|
+
L: 223,
|
|
1463
1472
|
S: this,
|
|
1464
1473
|
C: (f, a) => f(...a)
|
|
1465
1474
|
});
|
|
1475
|
+
const spacesToActivate = [];
|
|
1466
1476
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
1467
1477
|
try {
|
|
1468
1478
|
log4("load space", {
|
|
1469
1479
|
spaceMetadata
|
|
1470
1480
|
}, {
|
|
1471
1481
|
F: __dxlog_file6,
|
|
1472
|
-
L:
|
|
1482
|
+
L: 228,
|
|
1473
1483
|
S: this,
|
|
1474
1484
|
C: (f, a) => f(...a)
|
|
1475
1485
|
});
|
|
1476
|
-
await this._constructSpace(spaceMetadata);
|
|
1486
|
+
const space = await this._constructSpace(spaceMetadata);
|
|
1487
|
+
if (this._runtimeProps?.autoActivateSpaces && spaceMetadata.state === SpaceState.SPACE_ACTIVE) {
|
|
1488
|
+
spacesToActivate.push(space);
|
|
1489
|
+
}
|
|
1477
1490
|
} catch (err) {
|
|
1478
1491
|
log4.error("Error loading space", {
|
|
1479
1492
|
spaceMetadata,
|
|
1480
1493
|
err
|
|
1481
1494
|
}, {
|
|
1482
1495
|
F: __dxlog_file6,
|
|
1483
|
-
L:
|
|
1496
|
+
L: 235,
|
|
1484
1497
|
S: this,
|
|
1485
1498
|
C: (f, a) => f(...a)
|
|
1486
1499
|
});
|
|
1487
1500
|
}
|
|
1488
1501
|
});
|
|
1502
|
+
for (const space of spacesToActivate) {
|
|
1503
|
+
log4("auto-activating space", {
|
|
1504
|
+
spaceKey: space.key
|
|
1505
|
+
}, {
|
|
1506
|
+
F: __dxlog_file6,
|
|
1507
|
+
L: 241,
|
|
1508
|
+
S: this,
|
|
1509
|
+
C: (f, a) => f(...a)
|
|
1510
|
+
});
|
|
1511
|
+
space.activate().catch((err) => {
|
|
1512
|
+
log4.error("Error auto-activating space", {
|
|
1513
|
+
spaceKey: space.key,
|
|
1514
|
+
err
|
|
1515
|
+
}, {
|
|
1516
|
+
F: __dxlog_file6,
|
|
1517
|
+
L: 243,
|
|
1518
|
+
S: this,
|
|
1519
|
+
C: (f, a) => f(...a)
|
|
1520
|
+
});
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1489
1523
|
this.updated.emit();
|
|
1490
1524
|
log4.trace("dxos.echo.data-space-manager.open", Trace.end({
|
|
1491
1525
|
id: this._instanceId
|
|
1492
1526
|
}), {
|
|
1493
1527
|
F: __dxlog_file6,
|
|
1494
|
-
L:
|
|
1528
|
+
L: 249,
|
|
1495
1529
|
S: this,
|
|
1496
1530
|
C: (f, a) => f(...a)
|
|
1497
1531
|
});
|
|
@@ -1499,7 +1533,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1499
1533
|
async _close() {
|
|
1500
1534
|
log4("close", void 0, {
|
|
1501
1535
|
F: __dxlog_file6,
|
|
1502
|
-
L:
|
|
1536
|
+
L: 254,
|
|
1503
1537
|
S: this,
|
|
1504
1538
|
C: (f, a) => f(...a)
|
|
1505
1539
|
});
|
|
@@ -1530,7 +1564,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1530
1564
|
spaceKey
|
|
1531
1565
|
}, {
|
|
1532
1566
|
F: __dxlog_file6,
|
|
1533
|
-
L:
|
|
1567
|
+
L: 287,
|
|
1534
1568
|
S: this,
|
|
1535
1569
|
C: (f, a) => f(...a)
|
|
1536
1570
|
});
|
|
@@ -1538,7 +1572,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1538
1572
|
if (options.documents) {
|
|
1539
1573
|
invariant3(Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId)), "Invalid document IDs", {
|
|
1540
1574
|
F: __dxlog_file6,
|
|
1541
|
-
L:
|
|
1575
|
+
L: 292,
|
|
1542
1576
|
S: this,
|
|
1543
1577
|
A: [
|
|
1544
1578
|
"Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId))",
|
|
@@ -1550,7 +1584,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1550
1584
|
documentId
|
|
1551
1585
|
}, {
|
|
1552
1586
|
F: __dxlog_file6,
|
|
1553
|
-
L:
|
|
1587
|
+
L: 299,
|
|
1554
1588
|
S: this,
|
|
1555
1589
|
C: (f, a) => f(...a)
|
|
1556
1590
|
});
|
|
@@ -1569,7 +1603,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1569
1603
|
spaceKey
|
|
1570
1604
|
}, {
|
|
1571
1605
|
F: __dxlog_file6,
|
|
1572
|
-
L:
|
|
1606
|
+
L: 317,
|
|
1573
1607
|
S: this,
|
|
1574
1608
|
C: (f, a) => f(...a)
|
|
1575
1609
|
});
|
|
@@ -1578,7 +1612,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1578
1612
|
const newRootDocId = documentIdMapping[interpretAsDocumentId(options.rootUrl)] ?? failedInvariant();
|
|
1579
1613
|
const rootDocHandle = await this._echoHost.loadDoc(Context4.default(void 0, {
|
|
1580
1614
|
F: __dxlog_file6,
|
|
1581
|
-
L:
|
|
1615
|
+
L: 322
|
|
1582
1616
|
}), newRootDocId);
|
|
1583
1617
|
DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
|
|
1584
1618
|
root = await this._echoHost.openSpaceRoot(spaceId, `automerge:${newRootDocId}`);
|
|
@@ -1590,7 +1624,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1590
1624
|
spaceKey
|
|
1591
1625
|
}, {
|
|
1592
1626
|
F: __dxlog_file6,
|
|
1593
|
-
L:
|
|
1627
|
+
L: 331,
|
|
1594
1628
|
S: this,
|
|
1595
1629
|
C: (f, a) => f(...a)
|
|
1596
1630
|
});
|
|
@@ -1600,7 +1634,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1600
1634
|
spaceKey
|
|
1601
1635
|
}, {
|
|
1602
1636
|
F: __dxlog_file6,
|
|
1603
|
-
L:
|
|
1637
|
+
L: 336,
|
|
1604
1638
|
S: this,
|
|
1605
1639
|
C: (f, a) => f(...a)
|
|
1606
1640
|
});
|
|
@@ -1609,7 +1643,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1609
1643
|
const memberCredential = credentials[1];
|
|
1610
1644
|
invariant3(getCredentialAssertion(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
1611
1645
|
F: __dxlog_file6,
|
|
1612
|
-
L:
|
|
1646
|
+
L: 342,
|
|
1613
1647
|
S: this,
|
|
1614
1648
|
A: [
|
|
1615
1649
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -1623,7 +1657,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1623
1657
|
spaceKey
|
|
1624
1658
|
}, {
|
|
1625
1659
|
F: __dxlog_file6,
|
|
1626
|
-
L:
|
|
1660
|
+
L: 347,
|
|
1627
1661
|
S: this,
|
|
1628
1662
|
C: (f, a) => f(...a)
|
|
1629
1663
|
});
|
|
@@ -1641,7 +1675,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1641
1675
|
spaceId: space.id
|
|
1642
1676
|
}, {
|
|
1643
1677
|
F: __dxlog_file6,
|
|
1644
|
-
L:
|
|
1678
|
+
L: 360,
|
|
1645
1679
|
S: this,
|
|
1646
1680
|
C: (f, a) => f(...a)
|
|
1647
1681
|
});
|
|
@@ -1659,7 +1693,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1659
1693
|
spaceId: space.id
|
|
1660
1694
|
}, {
|
|
1661
1695
|
F: __dxlog_file6,
|
|
1662
|
-
L:
|
|
1696
|
+
L: 374,
|
|
1663
1697
|
S: this,
|
|
1664
1698
|
C: (f, a) => f(...a)
|
|
1665
1699
|
});
|
|
@@ -1671,7 +1705,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1671
1705
|
const document = await this._getSpaceRootDocument(space);
|
|
1672
1706
|
const properties = {
|
|
1673
1707
|
system: {
|
|
1674
|
-
type:
|
|
1708
|
+
type: EncodedReference.fromDXN(getSchemaDXN(SpaceProperties))
|
|
1675
1709
|
},
|
|
1676
1710
|
data: {
|
|
1677
1711
|
[DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
|
|
@@ -1694,14 +1728,19 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1694
1728
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
1695
1729
|
invariant3(automergeIndex, void 0, {
|
|
1696
1730
|
F: __dxlog_file6,
|
|
1697
|
-
L:
|
|
1731
|
+
L: 407,
|
|
1698
1732
|
S: this,
|
|
1699
1733
|
A: [
|
|
1700
1734
|
"automergeIndex",
|
|
1701
1735
|
""
|
|
1702
1736
|
]
|
|
1703
1737
|
});
|
|
1704
|
-
const document = await this._echoHost.
|
|
1738
|
+
const document = await this._echoHost.loadDoc(Context4.default(void 0, {
|
|
1739
|
+
F: __dxlog_file6,
|
|
1740
|
+
L: 408
|
|
1741
|
+
}), automergeIndex, {
|
|
1742
|
+
fetchFromNetwork: true
|
|
1743
|
+
});
|
|
1705
1744
|
await document.whenReady();
|
|
1706
1745
|
return document;
|
|
1707
1746
|
}
|
|
@@ -1711,13 +1750,13 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1711
1750
|
opts
|
|
1712
1751
|
}, {
|
|
1713
1752
|
F: __dxlog_file6,
|
|
1714
|
-
L:
|
|
1753
|
+
L: 418,
|
|
1715
1754
|
S: this,
|
|
1716
1755
|
C: (f, a) => f(...a)
|
|
1717
1756
|
});
|
|
1718
1757
|
invariant3(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
|
|
1719
1758
|
F: __dxlog_file6,
|
|
1720
|
-
L:
|
|
1759
|
+
L: 419,
|
|
1721
1760
|
S: this,
|
|
1722
1761
|
A: [
|
|
1723
1762
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -1726,7 +1765,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1726
1765
|
});
|
|
1727
1766
|
invariant3(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
1728
1767
|
F: __dxlog_file6,
|
|
1729
|
-
L:
|
|
1768
|
+
L: 420,
|
|
1730
1769
|
S: this,
|
|
1731
1770
|
A: [
|
|
1732
1771
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -1750,7 +1789,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1750
1789
|
const space = this._spaceManager.spaces.get(options.spaceKey);
|
|
1751
1790
|
invariant3(space, void 0, {
|
|
1752
1791
|
F: __dxlog_file6,
|
|
1753
|
-
L:
|
|
1792
|
+
L: 440,
|
|
1754
1793
|
S: this,
|
|
1755
1794
|
A: [
|
|
1756
1795
|
"space",
|
|
@@ -1763,7 +1802,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1763
1802
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
|
|
1764
1803
|
invariant3(credentials[0].credential, void 0, {
|
|
1765
1804
|
F: __dxlog_file6,
|
|
1766
|
-
L:
|
|
1805
|
+
L: 459,
|
|
1767
1806
|
S: this,
|
|
1768
1807
|
A: [
|
|
1769
1808
|
"credentials[0].credential",
|
|
@@ -1773,7 +1812,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1773
1812
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1774
1813
|
invariant3(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
1775
1814
|
F: __dxlog_file6,
|
|
1776
|
-
L:
|
|
1815
|
+
L: 461,
|
|
1777
1816
|
S: this,
|
|
1778
1817
|
A: [
|
|
1779
1818
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -1811,7 +1850,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1811
1850
|
const space = this._spaces.get(spaceKey);
|
|
1812
1851
|
invariant3(space, "Space not found.", {
|
|
1813
1852
|
F: __dxlog_file6,
|
|
1814
|
-
L:
|
|
1853
|
+
L: 498,
|
|
1815
1854
|
S: this,
|
|
1816
1855
|
A: [
|
|
1817
1856
|
"space",
|
|
@@ -1836,7 +1875,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1836
1875
|
metadata
|
|
1837
1876
|
}, {
|
|
1838
1877
|
F: __dxlog_file6,
|
|
1839
|
-
L:
|
|
1878
|
+
L: 517,
|
|
1840
1879
|
S: this,
|
|
1841
1880
|
C: (f, a) => f(...a)
|
|
1842
1881
|
});
|
|
@@ -1844,8 +1883,8 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1844
1883
|
localPeerId: this._signingContext.deviceKey
|
|
1845
1884
|
});
|
|
1846
1885
|
const presence = new Presence({
|
|
1847
|
-
announceInterval: this.
|
|
1848
|
-
offlineTimeout: this.
|
|
1886
|
+
announceInterval: this._runtimeProps?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
|
|
1887
|
+
offlineTimeout: this._runtimeProps?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
|
|
1849
1888
|
identityKey: this._signingContext.identityKey,
|
|
1850
1889
|
gossip
|
|
1851
1890
|
});
|
|
@@ -1880,7 +1919,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1880
1919
|
err
|
|
1881
1920
|
}, {
|
|
1882
1921
|
F: __dxlog_file6,
|
|
1883
|
-
L:
|
|
1922
|
+
L: 559,
|
|
1884
1923
|
S: this,
|
|
1885
1924
|
C: (f, a) => f(...a)
|
|
1886
1925
|
});
|
|
@@ -1890,7 +1929,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1890
1929
|
onAuthFailure: () => {
|
|
1891
1930
|
log4.warn("auth failure", void 0, {
|
|
1892
1931
|
F: __dxlog_file6,
|
|
1893
|
-
L:
|
|
1932
|
+
L: 564,
|
|
1894
1933
|
S: this,
|
|
1895
1934
|
C: (f, a) => f(...a)
|
|
1896
1935
|
});
|
|
@@ -1923,7 +1962,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1923
1962
|
space: space.key
|
|
1924
1963
|
}, {
|
|
1925
1964
|
F: __dxlog_file6,
|
|
1926
|
-
L:
|
|
1965
|
+
L: 591,
|
|
1927
1966
|
S: this,
|
|
1928
1967
|
C: (f, a) => f(...a)
|
|
1929
1968
|
});
|
|
@@ -1934,7 +1973,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1934
1973
|
open: this._lifecycleState === LifecycleState.OPEN
|
|
1935
1974
|
}, {
|
|
1936
1975
|
F: __dxlog_file6,
|
|
1937
|
-
L:
|
|
1976
|
+
L: 594,
|
|
1938
1977
|
S: this,
|
|
1939
1978
|
C: (f, a) => f(...a)
|
|
1940
1979
|
});
|
|
@@ -1953,7 +1992,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1953
1992
|
space: space.key
|
|
1954
1993
|
}, {
|
|
1955
1994
|
F: __dxlog_file6,
|
|
1956
|
-
L:
|
|
1995
|
+
L: 602,
|
|
1957
1996
|
S: this,
|
|
1958
1997
|
C: (f, a) => f(...a)
|
|
1959
1998
|
});
|
|
@@ -1963,7 +2002,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1963
2002
|
edgeConnection: this._edgeConnection,
|
|
1964
2003
|
edgeHttpClient: this._edgeHttpClient,
|
|
1965
2004
|
edgeFeatures: this._edgeFeatures,
|
|
1966
|
-
activeEdgeNotarizationPollingInterval: this.
|
|
2005
|
+
activeEdgeNotarizationPollingInterval: this._runtimeProps?.activeEdgeNotarizationPollingInterval
|
|
1967
2006
|
});
|
|
1968
2007
|
dataSpace.postOpen.append(async () => {
|
|
1969
2008
|
const setting = dataSpace.getEdgeReplicationSetting();
|
|
@@ -1974,7 +2013,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1974
2013
|
spaceId: dataSpace.id
|
|
1975
2014
|
}, {
|
|
1976
2015
|
F: __dxlog_file6,
|
|
1977
|
-
L:
|
|
2016
|
+
L: 616,
|
|
1978
2017
|
S: this,
|
|
1979
2018
|
C: (f, a) => f(...a)
|
|
1980
2019
|
});
|
|
@@ -2004,7 +2043,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
2004
2043
|
space: space.key
|
|
2005
2044
|
}, {
|
|
2006
2045
|
F: __dxlog_file6,
|
|
2007
|
-
L:
|
|
2046
|
+
L: 643,
|
|
2008
2047
|
S: this,
|
|
2009
2048
|
C: (f, a) => f(...a)
|
|
2010
2049
|
});
|
|
@@ -2037,7 +2076,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
2037
2076
|
closedSessions
|
|
2038
2077
|
}, {
|
|
2039
2078
|
F: __dxlog_file6,
|
|
2040
|
-
L:
|
|
2079
|
+
L: 669,
|
|
2041
2080
|
S: this,
|
|
2042
2081
|
C: (f, a) => f(...a)
|
|
2043
2082
|
});
|
|
@@ -2052,7 +2091,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
2052
2091
|
peerId: peerState.peerId
|
|
2053
2092
|
}, {
|
|
2054
2093
|
F: __dxlog_file6,
|
|
2055
|
-
L:
|
|
2094
|
+
L: 683,
|
|
2056
2095
|
S: this,
|
|
2057
2096
|
C: (f, a) => f(...a)
|
|
2058
2097
|
});
|
|
@@ -2129,6 +2168,7 @@ import { trace as trace2 } from "@dxos/tracing";
|
|
|
2129
2168
|
import { Resource as Resource3 } from "@dxos/context";
|
|
2130
2169
|
import { assertArgument as assertArgument2, assertState as assertState2 } from "@dxos/invariant";
|
|
2131
2170
|
import { SpaceArchiveFileStructure, SpaceArchiveVersion } from "@dxos/protocols";
|
|
2171
|
+
import { createFilename } from "@dxos/util";
|
|
2132
2172
|
var CURRENT_VERSION = SpaceArchiveVersion.V1;
|
|
2133
2173
|
var SpaceArchiveWriter = class extends Resource3 {
|
|
2134
2174
|
_tar;
|
|
@@ -2161,6 +2201,7 @@ var SpaceArchiveWriter = class extends Resource3 {
|
|
|
2161
2201
|
async finish() {
|
|
2162
2202
|
assertState2(this._archive, "Not open");
|
|
2163
2203
|
assertState2(this._meta, "Not started");
|
|
2204
|
+
assertState2(this._meta.spaceId, "No space ID set");
|
|
2164
2205
|
assertState2(this._currentRootUrl, "No root URL set");
|
|
2165
2206
|
const metadata = {
|
|
2166
2207
|
version: CURRENT_VERSION,
|
|
@@ -2174,8 +2215,12 @@ var SpaceArchiveWriter = class extends Resource3 {
|
|
|
2174
2215
|
this._archive.addTextFile(SpaceArchiveFileStructure.metadata, JSON.stringify(metadata));
|
|
2175
2216
|
const binary = this._archive.toUint8Array();
|
|
2176
2217
|
return {
|
|
2177
|
-
|
|
2178
|
-
|
|
2218
|
+
filename: createFilename({
|
|
2219
|
+
parts: [
|
|
2220
|
+
this._meta.spaceId
|
|
2221
|
+
],
|
|
2222
|
+
ext: "tar"
|
|
2223
|
+
}),
|
|
2179
2224
|
contents: binary
|
|
2180
2225
|
};
|
|
2181
2226
|
}
|
|
@@ -3706,7 +3751,7 @@ var LOAD_DOC_TIMEOUT = 1e4;
|
|
|
3706
3751
|
var runEpochMigration = async (ctx, context) => {
|
|
3707
3752
|
switch (context.migration) {
|
|
3708
3753
|
case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3709
|
-
const document = context.echoHost.createDoc();
|
|
3754
|
+
const document = await context.echoHost.createDoc();
|
|
3710
3755
|
await context.echoHost.flush();
|
|
3711
3756
|
return {
|
|
3712
3757
|
newRoot: document.url
|
|
@@ -3719,7 +3764,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3719
3764
|
const rootHandle = await context.echoHost.loadDoc(ctx, context.currentRoot, {
|
|
3720
3765
|
timeout: LOAD_DOC_TIMEOUT
|
|
3721
3766
|
});
|
|
3722
|
-
const newRoot = context.echoHost.createDoc(rootHandle.doc());
|
|
3767
|
+
const newRoot = await context.echoHost.createDoc(rootHandle.doc());
|
|
3723
3768
|
await context.echoHost.flush();
|
|
3724
3769
|
return {
|
|
3725
3770
|
newRoot: newRoot.url
|
|
@@ -4284,7 +4329,7 @@ var __dxlog_file15 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/s
|
|
|
4284
4329
|
var DataSpace = class {
|
|
4285
4330
|
_ctx = new Context6(void 0, {
|
|
4286
4331
|
F: __dxlog_file15,
|
|
4287
|
-
L:
|
|
4332
|
+
L: 100
|
|
4288
4333
|
});
|
|
4289
4334
|
_inner;
|
|
4290
4335
|
_gossip;
|
|
@@ -4346,7 +4391,7 @@ var DataSpace = class {
|
|
|
4346
4391
|
state: SpaceState4[this._state]
|
|
4347
4392
|
}, {
|
|
4348
4393
|
F: __dxlog_file15,
|
|
4349
|
-
L:
|
|
4394
|
+
L: 176,
|
|
4350
4395
|
S: this,
|
|
4351
4396
|
C: (f, a) => f(...a)
|
|
4352
4397
|
});
|
|
@@ -4405,7 +4450,7 @@ var DataSpace = class {
|
|
|
4405
4450
|
}
|
|
4406
4451
|
await this._inner.open(new Context6(void 0, {
|
|
4407
4452
|
F: __dxlog_file15,
|
|
4408
|
-
L:
|
|
4453
|
+
L: 250
|
|
4409
4454
|
}));
|
|
4410
4455
|
await this._inner.startProtocol();
|
|
4411
4456
|
await this._edgeFeedReplicator?.open();
|
|
@@ -4414,7 +4459,7 @@ var DataSpace = class {
|
|
|
4414
4459
|
state: SpaceState4[this._state]
|
|
4415
4460
|
}, {
|
|
4416
4461
|
F: __dxlog_file15,
|
|
4417
|
-
L:
|
|
4462
|
+
L: 256,
|
|
4418
4463
|
S: this,
|
|
4419
4464
|
C: (f, a) => f(...a)
|
|
4420
4465
|
});
|
|
@@ -4434,14 +4479,14 @@ var DataSpace = class {
|
|
|
4434
4479
|
state: SpaceState4[this._state]
|
|
4435
4480
|
}, {
|
|
4436
4481
|
F: __dxlog_file15,
|
|
4437
|
-
L:
|
|
4482
|
+
L: 275,
|
|
4438
4483
|
S: this,
|
|
4439
4484
|
C: (f, a) => f(...a)
|
|
4440
4485
|
});
|
|
4441
4486
|
await this._ctx.dispose();
|
|
4442
4487
|
this._ctx = new Context6(void 0, {
|
|
4443
4488
|
F: __dxlog_file15,
|
|
4444
|
-
L:
|
|
4489
|
+
L: 277
|
|
4445
4490
|
});
|
|
4446
4491
|
if (this._edgeFeedReplicator) {
|
|
4447
4492
|
this.inner.protocol.feedAdded.remove(this._onFeedAdded);
|
|
@@ -4474,7 +4519,7 @@ var DataSpace = class {
|
|
|
4474
4519
|
if (err instanceof CancelledError || err instanceof ContextDisposedError) {
|
|
4475
4520
|
log12("data pipeline initialization cancelled", err, {
|
|
4476
4521
|
F: __dxlog_file15,
|
|
4477
|
-
L:
|
|
4522
|
+
L: 315,
|
|
4478
4523
|
S: this,
|
|
4479
4524
|
C: (f, a) => f(...a)
|
|
4480
4525
|
});
|
|
@@ -4482,7 +4527,7 @@ var DataSpace = class {
|
|
|
4482
4527
|
}
|
|
4483
4528
|
log12.error("Error initializing data pipeline", err, {
|
|
4484
4529
|
F: __dxlog_file15,
|
|
4485
|
-
L:
|
|
4530
|
+
L: 319,
|
|
4486
4531
|
S: this,
|
|
4487
4532
|
C: (f, a) => f(...a)
|
|
4488
4533
|
});
|
|
@@ -4491,7 +4536,7 @@ var DataSpace = class {
|
|
|
4491
4536
|
state: SpaceState4[this._state]
|
|
4492
4537
|
}, {
|
|
4493
4538
|
F: __dxlog_file15,
|
|
4494
|
-
L:
|
|
4539
|
+
L: 321,
|
|
4495
4540
|
S: this,
|
|
4496
4541
|
C: (f, a) => f(...a)
|
|
4497
4542
|
});
|
|
@@ -4513,13 +4558,13 @@ var DataSpace = class {
|
|
|
4513
4558
|
state: SpaceState4[this._state]
|
|
4514
4559
|
}, {
|
|
4515
4560
|
F: __dxlog_file15,
|
|
4516
|
-
L:
|
|
4561
|
+
L: 337,
|
|
4517
4562
|
S: this,
|
|
4518
4563
|
C: (f, a) => f(...a)
|
|
4519
4564
|
});
|
|
4520
4565
|
log12("initializing control pipeline", void 0, {
|
|
4521
4566
|
F: __dxlog_file15,
|
|
4522
|
-
L:
|
|
4567
|
+
L: 339,
|
|
4523
4568
|
S: this,
|
|
4524
4569
|
C: (f, a) => f(...a)
|
|
4525
4570
|
});
|
|
@@ -4528,21 +4573,21 @@ var DataSpace = class {
|
|
|
4528
4573
|
const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState4.SPACE_READY);
|
|
4529
4574
|
log12("initializing automerge root", void 0, {
|
|
4530
4575
|
F: __dxlog_file15,
|
|
4531
|
-
L:
|
|
4576
|
+
L: 347,
|
|
4532
4577
|
S: this,
|
|
4533
4578
|
C: (f, a) => f(...a)
|
|
4534
4579
|
});
|
|
4535
4580
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4536
4581
|
log12("waiting for space to be ready", void 0, {
|
|
4537
4582
|
F: __dxlog_file15,
|
|
4538
|
-
L:
|
|
4583
|
+
L: 351,
|
|
4539
4584
|
S: this,
|
|
4540
4585
|
C: (f, a) => f(...a)
|
|
4541
4586
|
});
|
|
4542
4587
|
await ready;
|
|
4543
4588
|
log12("space is ready", void 0, {
|
|
4544
4589
|
F: __dxlog_file15,
|
|
4545
|
-
L:
|
|
4590
|
+
L: 353,
|
|
4546
4591
|
S: this,
|
|
4547
4592
|
C: (f, a) => f(...a)
|
|
4548
4593
|
});
|
|
@@ -4550,7 +4595,7 @@ var DataSpace = class {
|
|
|
4550
4595
|
async *getAllDocuments() {
|
|
4551
4596
|
invariant11(this._databaseRoot, "Space is not ready", {
|
|
4552
4597
|
F: __dxlog_file15,
|
|
4553
|
-
L:
|
|
4598
|
+
L: 357,
|
|
4554
4599
|
S: this,
|
|
4555
4600
|
A: [
|
|
4556
4601
|
"this._databaseRoot",
|
|
@@ -4566,7 +4611,7 @@ var DataSpace = class {
|
|
|
4566
4611
|
for (const documentUrl of this._databaseRoot.getAllLinkedDocuments()) {
|
|
4567
4612
|
const data = await this._echoHost.exportDoc(Context6.default(void 0, {
|
|
4568
4613
|
F: __dxlog_file15,
|
|
4569
|
-
L:
|
|
4614
|
+
L: 363
|
|
4570
4615
|
}), documentUrl);
|
|
4571
4616
|
yield [
|
|
4572
4617
|
documentUrl.replace(/^automerge:/, ""),
|
|
@@ -4581,7 +4626,7 @@ var DataSpace = class {
|
|
|
4581
4626
|
state: SpaceState4[this._state]
|
|
4582
4627
|
}, {
|
|
4583
4628
|
F: __dxlog_file15,
|
|
4584
|
-
L:
|
|
4629
|
+
L: 372,
|
|
4585
4630
|
S: this,
|
|
4586
4631
|
C: (f, a) => f(...a)
|
|
4587
4632
|
});
|
|
@@ -4598,7 +4643,7 @@ var DataSpace = class {
|
|
|
4598
4643
|
await this._createWritableFeeds();
|
|
4599
4644
|
log12("writable feeds created", void 0, {
|
|
4600
4645
|
F: __dxlog_file15,
|
|
4601
|
-
L:
|
|
4646
|
+
L: 389,
|
|
4602
4647
|
S: this,
|
|
4603
4648
|
C: (f, a) => f(...a)
|
|
4604
4649
|
});
|
|
@@ -4652,7 +4697,7 @@ var DataSpace = class {
|
|
|
4652
4697
|
count: credentials.length
|
|
4653
4698
|
}, {
|
|
4654
4699
|
F: __dxlog_file15,
|
|
4655
|
-
L:
|
|
4700
|
+
L: 447,
|
|
4656
4701
|
S: this,
|
|
4657
4702
|
C: (f, a) => f(...a)
|
|
4658
4703
|
});
|
|
@@ -4663,14 +4708,17 @@ var DataSpace = class {
|
|
|
4663
4708
|
});
|
|
4664
4709
|
log12("credentials notarized", void 0, {
|
|
4665
4710
|
F: __dxlog_file15,
|
|
4666
|
-
L:
|
|
4711
|
+
L: 451,
|
|
4667
4712
|
S: this,
|
|
4668
4713
|
C: (f, a) => f(...a)
|
|
4669
4714
|
});
|
|
4670
4715
|
} catch (err) {
|
|
4716
|
+
if (err instanceof ContextDisposedError) {
|
|
4717
|
+
return;
|
|
4718
|
+
}
|
|
4671
4719
|
log12.error("error notarizing credentials for feed admission", err, {
|
|
4672
4720
|
F: __dxlog_file15,
|
|
4673
|
-
L:
|
|
4721
|
+
L: 456,
|
|
4674
4722
|
S: this,
|
|
4675
4723
|
C: (f, a) => f(...a)
|
|
4676
4724
|
});
|
|
@@ -4685,7 +4733,7 @@ var DataSpace = class {
|
|
|
4685
4733
|
rootUrl
|
|
4686
4734
|
}, {
|
|
4687
4735
|
F: __dxlog_file15,
|
|
4688
|
-
L:
|
|
4736
|
+
L: 466,
|
|
4689
4737
|
S: this,
|
|
4690
4738
|
C: (f, a) => f(...a)
|
|
4691
4739
|
});
|
|
@@ -4699,7 +4747,12 @@ var DataSpace = class {
|
|
|
4699
4747
|
};
|
|
4700
4748
|
try {
|
|
4701
4749
|
await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
4702
|
-
handle = await cancelWithContext2(this._ctx, this._echoHost.
|
|
4750
|
+
handle = await cancelWithContext2(this._ctx, this._echoHost.loadDoc(Context6.default(void 0, {
|
|
4751
|
+
F: __dxlog_file15,
|
|
4752
|
+
L: 476
|
|
4753
|
+
}), rootUrl, {
|
|
4754
|
+
fetchFromNetwork: true
|
|
4755
|
+
}));
|
|
4703
4756
|
await cancelWithContext2(this._ctx, handle.whenReady());
|
|
4704
4757
|
});
|
|
4705
4758
|
if (this._ctx.disposed) {
|
|
@@ -4740,7 +4793,7 @@ var DataSpace = class {
|
|
|
4740
4793
|
err
|
|
4741
4794
|
}, {
|
|
4742
4795
|
F: __dxlog_file15,
|
|
4743
|
-
L:
|
|
4796
|
+
L: 515,
|
|
4744
4797
|
S: this,
|
|
4745
4798
|
C: (f, a) => f(...a)
|
|
4746
4799
|
});
|
|
@@ -4830,7 +4883,7 @@ var DataSpace = class {
|
|
|
4830
4883
|
state: SpaceState4[this._state]
|
|
4831
4884
|
}, {
|
|
4832
4885
|
F: __dxlog_file15,
|
|
4833
|
-
L:
|
|
4886
|
+
L: 597,
|
|
4834
4887
|
S: this,
|
|
4835
4888
|
C: (f, a) => f(...a)
|
|
4836
4889
|
});
|
|
@@ -5921,14 +5974,14 @@ var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
|
|
|
5921
5974
|
var InvitationsHandler = class {
|
|
5922
5975
|
_networkManager;
|
|
5923
5976
|
_edgeClient;
|
|
5924
|
-
|
|
5977
|
+
_connectionProps;
|
|
5925
5978
|
/**
|
|
5926
5979
|
* @internal
|
|
5927
5980
|
*/
|
|
5928
|
-
constructor(_networkManager, _edgeClient,
|
|
5981
|
+
constructor(_networkManager, _edgeClient, _connectionProps) {
|
|
5929
5982
|
this._networkManager = _networkManager;
|
|
5930
5983
|
this._edgeClient = _edgeClient;
|
|
5931
|
-
this.
|
|
5984
|
+
this._connectionProps = _connectionProps;
|
|
5932
5985
|
}
|
|
5933
5986
|
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
5934
5987
|
log18.verbose("dxos.sdk.invitations-handler.handleInvitationFlow", {
|
|
@@ -6372,7 +6425,7 @@ var InvitationsHandler = class {
|
|
|
6372
6425
|
});
|
|
6373
6426
|
return extension;
|
|
6374
6427
|
};
|
|
6375
|
-
const edgeInvitationHandler = new EdgeInvitationHandler(this.
|
|
6428
|
+
const edgeInvitationHandler = new EdgeInvitationHandler(this._connectionProps?.edgeInvitations, this._edgeClient, {
|
|
6376
6429
|
onInvitationSuccess: async (admissionResponse, admissionRequest) => {
|
|
6377
6430
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
6378
6431
|
log18.info("admitted by edge", {
|
|
@@ -6432,7 +6485,7 @@ var InvitationsHandler = class {
|
|
|
6432
6485
|
topic: invitation.swarmKey,
|
|
6433
6486
|
protocolProvider: createTeleportProtocolFactory(async (teleport) => {
|
|
6434
6487
|
teleport.addExtension("dxos.halo.invitations", extensionFactory());
|
|
6435
|
-
}, this.
|
|
6488
|
+
}, this._connectionProps?.teleport),
|
|
6436
6489
|
topology: new InvitationTopology(role),
|
|
6437
6490
|
label
|
|
6438
6491
|
});
|
|
@@ -7291,162 +7344,27 @@ var InvitationsManager = class {
|
|
|
7291
7344
|
}
|
|
7292
7345
|
};
|
|
7293
7346
|
|
|
7294
|
-
// src/packlets/locks/
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
import
|
|
7298
|
-
function _ts_decorate7(decorators, target, key, desc) {
|
|
7299
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7300
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7301
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7302
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7303
|
-
}
|
|
7304
|
-
var __dxlog_file25 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
7305
|
-
var Lock = class {
|
|
7306
|
-
_lockPath;
|
|
7307
|
-
_onAcquire;
|
|
7308
|
-
_onRelease;
|
|
7309
|
-
_fileHandle;
|
|
7310
|
-
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
7311
|
-
this._lockPath = lockPath;
|
|
7312
|
-
this._onAcquire = onAcquire;
|
|
7313
|
-
this._onRelease = onRelease;
|
|
7314
|
-
}
|
|
7315
|
-
get lockKey() {
|
|
7316
|
-
return this._lockPath;
|
|
7317
|
-
}
|
|
7318
|
-
async acquire() {
|
|
7319
|
-
log21("acquiring lock...", void 0, {
|
|
7320
|
-
F: __dxlog_file25,
|
|
7321
|
-
L: 32,
|
|
7322
|
-
S: this,
|
|
7323
|
-
C: (f, a) => f(...a)
|
|
7324
|
-
});
|
|
7325
|
-
this._fileHandle = await LockFile.acquire(this._lockPath);
|
|
7326
|
-
await this._onAcquire?.();
|
|
7327
|
-
log21("acquired lock", void 0, {
|
|
7328
|
-
F: __dxlog_file25,
|
|
7329
|
-
L: 37,
|
|
7330
|
-
S: this,
|
|
7331
|
-
C: (f, a) => f(...a)
|
|
7332
|
-
});
|
|
7333
|
-
}
|
|
7334
|
-
async release() {
|
|
7335
|
-
await this._onRelease?.();
|
|
7336
|
-
invariant20(this._fileHandle, "Lock is not acquired", {
|
|
7337
|
-
F: __dxlog_file25,
|
|
7338
|
-
L: 42,
|
|
7339
|
-
S: this,
|
|
7340
|
-
A: [
|
|
7341
|
-
"this._fileHandle",
|
|
7342
|
-
"'Lock is not acquired'"
|
|
7343
|
-
]
|
|
7344
|
-
});
|
|
7345
|
-
await LockFile.release(this._fileHandle);
|
|
7346
|
-
}
|
|
7347
|
-
};
|
|
7348
|
-
_ts_decorate7([
|
|
7349
|
-
logInfo3
|
|
7350
|
-
], Lock.prototype, "lockKey", null);
|
|
7351
|
-
var isLocked = (lockPath) => LockFile.isLocked(lockPath);
|
|
7352
|
-
|
|
7353
|
-
// src/packlets/services/client-rpc-server.ts
|
|
7354
|
-
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
7355
|
-
import { raise as raise2 } from "@dxos/debug";
|
|
7356
|
-
import { RpcPeer, parseMethodName } from "@dxos/rpc";
|
|
7357
|
-
import { MapCounter, trace as trace9 } from "@dxos/tracing";
|
|
7358
|
-
function _ts_decorate8(decorators, target, key, desc) {
|
|
7359
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7360
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7361
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7362
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7363
|
-
}
|
|
7364
|
-
var ClientRpcServer = class {
|
|
7365
|
-
_serviceRegistry;
|
|
7366
|
-
_rpcPeer;
|
|
7367
|
-
_handlerCache = /* @__PURE__ */ new Map();
|
|
7368
|
-
_handleCall;
|
|
7369
|
-
_handleStream;
|
|
7370
|
-
_callMetrics = new MapCounter();
|
|
7371
|
-
get _services() {
|
|
7372
|
-
return Object.keys(this._serviceRegistry.services);
|
|
7373
|
-
}
|
|
7374
|
-
constructor(params) {
|
|
7375
|
-
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
7376
|
-
this._handleCall = handleCall;
|
|
7377
|
-
this._handleStream = handleStream;
|
|
7378
|
-
this._serviceRegistry = serviceRegistry;
|
|
7379
|
-
this._rpcPeer = new RpcPeer({
|
|
7380
|
-
...rpcOptions,
|
|
7381
|
-
callHandler: (method, params2) => {
|
|
7382
|
-
const [serviceName, methodName] = parseMethodName(method);
|
|
7383
|
-
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
7384
|
-
this._callMetrics.inc(`${serviceName}.${methodName} request`);
|
|
7385
|
-
if (this._handleCall) {
|
|
7386
|
-
return this._handleCall(methodName, params2, handler);
|
|
7387
|
-
} else {
|
|
7388
|
-
return handler(methodName, params2);
|
|
7389
|
-
}
|
|
7390
|
-
},
|
|
7391
|
-
streamHandler: (method, params2) => {
|
|
7392
|
-
const [serviceName, methodName] = parseMethodName(method);
|
|
7393
|
-
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
7394
|
-
this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
|
|
7395
|
-
if (this._handleStream) {
|
|
7396
|
-
return Stream10.map(Stream10.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
|
|
7397
|
-
this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
|
|
7398
|
-
return data;
|
|
7399
|
-
});
|
|
7400
|
-
} else {
|
|
7401
|
-
return handler(methodName, params2);
|
|
7402
|
-
}
|
|
7403
|
-
}
|
|
7404
|
-
});
|
|
7405
|
-
}
|
|
7406
|
-
async open() {
|
|
7407
|
-
await this._rpcPeer.open();
|
|
7408
|
-
}
|
|
7409
|
-
async close() {
|
|
7410
|
-
await this._rpcPeer.close();
|
|
7411
|
-
}
|
|
7412
|
-
_getServiceHandler(serviceName) {
|
|
7413
|
-
if (!this._handlerCache.has(serviceName)) {
|
|
7414
|
-
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise2(new Error(`Service not available: ${serviceName}`));
|
|
7415
|
-
const service = this._serviceRegistry.services[key];
|
|
7416
|
-
if (!service) {
|
|
7417
|
-
throw new Error(`Service not available: ${serviceName}`);
|
|
7418
|
-
}
|
|
7419
|
-
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
7420
|
-
}
|
|
7421
|
-
return this._handlerCache.get(serviceName);
|
|
7422
|
-
}
|
|
7423
|
-
};
|
|
7424
|
-
_ts_decorate8([
|
|
7425
|
-
trace9.metricsCounter()
|
|
7426
|
-
], ClientRpcServer.prototype, "_callMetrics", void 0);
|
|
7427
|
-
_ts_decorate8([
|
|
7428
|
-
trace9.info()
|
|
7429
|
-
], ClientRpcServer.prototype, "_services", null);
|
|
7430
|
-
ClientRpcServer = _ts_decorate8([
|
|
7431
|
-
trace9.resource()
|
|
7432
|
-
], ClientRpcServer);
|
|
7347
|
+
// src/packlets/locks/index.ts
|
|
7348
|
+
var locks_exports = {};
|
|
7349
|
+
__reExport(locks_exports, locks_platform_star);
|
|
7350
|
+
import * as locks_platform_star from "#locks-platform";
|
|
7433
7351
|
|
|
7434
7352
|
// src/packlets/agents/edge-agent-manager.ts
|
|
7435
7353
|
import { DeferredTask as DeferredTask2, Event as Event9, scheduleTask as scheduleTask8, synchronized as synchronized3 } from "@dxos/async";
|
|
7436
7354
|
import { Resource as Resource7 } from "@dxos/context";
|
|
7437
|
-
import { invariant as
|
|
7355
|
+
import { invariant as invariant20 } from "@dxos/invariant";
|
|
7438
7356
|
import { PublicKey as PublicKey13 } from "@dxos/keys";
|
|
7439
|
-
import { log as
|
|
7357
|
+
import { log as log21 } from "@dxos/log";
|
|
7440
7358
|
import { EdgeAgentStatus, EdgeCallFailedError as EdgeCallFailedError3 } from "@dxos/protocols";
|
|
7441
7359
|
import { SpaceState as SpaceState5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
7442
7360
|
import { EdgeReplicationSetting as EdgeReplicationSetting2 } from "@dxos/protocols/proto/dxos/echo/metadata";
|
|
7443
|
-
function
|
|
7361
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
7444
7362
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7445
7363
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7446
7364
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7447
7365
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7448
7366
|
}
|
|
7449
|
-
var
|
|
7367
|
+
var __dxlog_file25 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/agents/edge-agent-manager.ts";
|
|
7450
7368
|
var AGENT_STATUS_QUERY_RETRY_INTERVAL = 5e3;
|
|
7451
7369
|
var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
|
|
7452
7370
|
var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
|
|
@@ -7470,8 +7388,8 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
7470
7388
|
return this._agentStatus && this._agentStatus !== EdgeAgentStatus.NOT_FOUND;
|
|
7471
7389
|
}
|
|
7472
7390
|
async createAgent() {
|
|
7473
|
-
|
|
7474
|
-
F:
|
|
7391
|
+
invariant20(this.isOpen, void 0, {
|
|
7392
|
+
F: __dxlog_file25,
|
|
7475
7393
|
L: 54,
|
|
7476
7394
|
S: this,
|
|
7477
7395
|
A: [
|
|
@@ -7479,8 +7397,8 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
7479
7397
|
""
|
|
7480
7398
|
]
|
|
7481
7399
|
});
|
|
7482
|
-
|
|
7483
|
-
F:
|
|
7400
|
+
invariant20(this._edgeHttpClient, void 0, {
|
|
7401
|
+
F: __dxlog_file25,
|
|
7484
7402
|
L: 55,
|
|
7485
7403
|
S: this,
|
|
7486
7404
|
A: [
|
|
@@ -7488,8 +7406,8 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
7488
7406
|
""
|
|
7489
7407
|
]
|
|
7490
7408
|
});
|
|
7491
|
-
|
|
7492
|
-
F:
|
|
7409
|
+
invariant20(this._edgeFeatures?.agents, void 0, {
|
|
7410
|
+
F: __dxlog_file25,
|
|
7493
7411
|
L: 56,
|
|
7494
7412
|
S: this,
|
|
7495
7413
|
A: [
|
|
@@ -7504,10 +7422,10 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
7504
7422
|
});
|
|
7505
7423
|
const deviceKey = PublicKey13.fromHex(response.deviceKey);
|
|
7506
7424
|
if (await this._identity.authorizedDeviceKeys.has(deviceKey)) {
|
|
7507
|
-
|
|
7425
|
+
log21.info("agent was already added to HALO, ignoring response", {
|
|
7508
7426
|
response
|
|
7509
7427
|
}, {
|
|
7510
|
-
F:
|
|
7428
|
+
F: __dxlog_file25,
|
|
7511
7429
|
L: 67,
|
|
7512
7430
|
S: this,
|
|
7513
7431
|
C: (f, a) => f(...a)
|
|
@@ -7521,8 +7439,8 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
7521
7439
|
// TODO: agents don't have data feed, should be removed
|
|
7522
7440
|
dataFeedKey: PublicKey13.random()
|
|
7523
7441
|
});
|
|
7524
|
-
|
|
7525
|
-
F:
|
|
7442
|
+
log21("agent created", response, {
|
|
7443
|
+
F: __dxlog_file25,
|
|
7526
7444
|
L: 79,
|
|
7527
7445
|
S: this,
|
|
7528
7446
|
C: (f, a) => f(...a)
|
|
@@ -7531,10 +7449,10 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
7531
7449
|
}
|
|
7532
7450
|
async _open() {
|
|
7533
7451
|
const isEnabled = this._edgeHttpClient && this._edgeFeatures?.agents;
|
|
7534
|
-
|
|
7452
|
+
log21("edge agent manager open", {
|
|
7535
7453
|
isEnabled
|
|
7536
7454
|
}, {
|
|
7537
|
-
F:
|
|
7455
|
+
F: __dxlog_file25,
|
|
7538
7456
|
L: 87,
|
|
7539
7457
|
S: this,
|
|
7540
7458
|
C: (f, a) => f(...a)
|
|
@@ -7566,8 +7484,8 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
7566
7484
|
this._lastKnownDeviceCount = 0;
|
|
7567
7485
|
}
|
|
7568
7486
|
async _fetchAgentStatus() {
|
|
7569
|
-
|
|
7570
|
-
F:
|
|
7487
|
+
invariant20(this._edgeHttpClient, void 0, {
|
|
7488
|
+
F: __dxlog_file25,
|
|
7571
7489
|
L: 121,
|
|
7572
7490
|
S: this,
|
|
7573
7491
|
A: [
|
|
@@ -7576,8 +7494,8 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
7576
7494
|
]
|
|
7577
7495
|
});
|
|
7578
7496
|
try {
|
|
7579
|
-
|
|
7580
|
-
F:
|
|
7497
|
+
log21("fetching agent status", void 0, {
|
|
7498
|
+
F: __dxlog_file25,
|
|
7581
7499
|
L: 123,
|
|
7582
7500
|
S: this,
|
|
7583
7501
|
C: (f, a) => f(...a)
|
|
@@ -7593,10 +7511,10 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
7593
7511
|
} catch (err) {
|
|
7594
7512
|
if (err instanceof EdgeCallFailedError3) {
|
|
7595
7513
|
if (!err.isRetryable) {
|
|
7596
|
-
|
|
7514
|
+
log21.warn("non retryable error on agent status fetch attempt", {
|
|
7597
7515
|
err
|
|
7598
7516
|
}, {
|
|
7599
|
-
F:
|
|
7517
|
+
F: __dxlog_file25,
|
|
7600
7518
|
L: 133,
|
|
7601
7519
|
S: this,
|
|
7602
7520
|
C: (f, a) => f(...a)
|
|
@@ -7605,11 +7523,11 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
7605
7523
|
}
|
|
7606
7524
|
}
|
|
7607
7525
|
const retryAfterMs = AGENT_STATUS_QUERY_RETRY_INTERVAL + Math.random() * AGENT_STATUS_QUERY_RETRY_JITTER;
|
|
7608
|
-
|
|
7526
|
+
log21.info("agent status fetching failed", {
|
|
7609
7527
|
err,
|
|
7610
7528
|
retryAfterMs
|
|
7611
7529
|
}, {
|
|
7612
|
-
F:
|
|
7530
|
+
F: __dxlog_file25,
|
|
7613
7531
|
L: 138,
|
|
7614
7532
|
S: this,
|
|
7615
7533
|
C: (f, a) => f(...a)
|
|
@@ -7641,11 +7559,11 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
7641
7559
|
].some((feed) => feed.assertion.deviceKey.equals(agentDeviceKey));
|
|
7642
7560
|
space.notarizationPlugin.setActiveEdgePollingEnabled(agentFeedNeedsNotarization);
|
|
7643
7561
|
activePollingEnabled = activePollingEnabled || agentFeedNeedsNotarization;
|
|
7644
|
-
|
|
7562
|
+
log21.verbose("set active edge polling", {
|
|
7645
7563
|
enabled: agentFeedNeedsNotarization,
|
|
7646
7564
|
spaceId: space.id
|
|
7647
7565
|
}, {
|
|
7648
|
-
F:
|
|
7566
|
+
F: __dxlog_file25,
|
|
7649
7567
|
L: 165,
|
|
7650
7568
|
S: this,
|
|
7651
7569
|
C: (f, a) => f(...a)
|
|
@@ -7662,22 +7580,22 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
7662
7580
|
if (deviceKey) {
|
|
7663
7581
|
this._ensureAgentIsInSpaces(deviceKey);
|
|
7664
7582
|
}
|
|
7665
|
-
|
|
7583
|
+
log21.verbose("agent status update", {
|
|
7666
7584
|
status
|
|
7667
7585
|
}, {
|
|
7668
|
-
F:
|
|
7586
|
+
F: __dxlog_file25,
|
|
7669
7587
|
L: 181,
|
|
7670
7588
|
S: this,
|
|
7671
7589
|
C: (f, a) => f(...a)
|
|
7672
7590
|
});
|
|
7673
7591
|
}
|
|
7674
7592
|
};
|
|
7675
|
-
|
|
7593
|
+
_ts_decorate7([
|
|
7676
7594
|
synchronized3
|
|
7677
7595
|
], EdgeAgentManager.prototype, "createAgent", null);
|
|
7678
7596
|
|
|
7679
7597
|
// src/packlets/agents/edge-agent-service.ts
|
|
7680
|
-
import { Stream as
|
|
7598
|
+
import { Stream as Stream10 } from "@dxos/codec-protobuf/stream";
|
|
7681
7599
|
import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
|
|
7682
7600
|
import { EdgeStatus as EdgeStatus2, QueryAgentStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
7683
7601
|
var EdgeAgentServiceImpl = class {
|
|
@@ -7689,7 +7607,7 @@ var EdgeAgentServiceImpl = class {
|
|
|
7689
7607
|
}
|
|
7690
7608
|
// TODO(mykola): Reconcile with NetworkService.queryStatus.
|
|
7691
7609
|
queryEdgeStatus() {
|
|
7692
|
-
return new
|
|
7610
|
+
return new Stream10(({ ctx, next }) => {
|
|
7693
7611
|
const update = () => {
|
|
7694
7612
|
next({
|
|
7695
7613
|
status: this._edgeConnection?.status ?? {
|
|
@@ -7711,7 +7629,7 @@ var EdgeAgentServiceImpl = class {
|
|
|
7711
7629
|
return (await this._agentManagerProvider()).createAgent();
|
|
7712
7630
|
}
|
|
7713
7631
|
queryAgentStatus() {
|
|
7714
|
-
return new
|
|
7632
|
+
return new Stream10(({ ctx, next }) => {
|
|
7715
7633
|
next({
|
|
7716
7634
|
status: QueryAgentStatusResponse.AgentStatus.UNKNOWN
|
|
7717
7635
|
});
|
|
@@ -7743,7 +7661,7 @@ var mapStatus = (agentStatus) => {
|
|
|
7743
7661
|
|
|
7744
7662
|
// src/packlets/services/service-context.ts
|
|
7745
7663
|
import { Mutex as Mutex4, Trigger as Trigger7 } from "@dxos/async";
|
|
7746
|
-
import { Context as Context10, Resource as
|
|
7664
|
+
import { Context as Context10, Resource as Resource9 } from "@dxos/context";
|
|
7747
7665
|
import { getCredentialAssertion as getCredentialAssertion6 } from "@dxos/credentials";
|
|
7748
7666
|
import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
|
|
7749
7667
|
import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
@@ -7752,8 +7670,9 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
|
7752
7670
|
import { invariant as invariant23 } from "@dxos/invariant";
|
|
7753
7671
|
import { Keyring } from "@dxos/keyring";
|
|
7754
7672
|
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
7755
|
-
import { log as
|
|
7756
|
-
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as
|
|
7673
|
+
import { log as log23 } from "@dxos/log";
|
|
7674
|
+
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
|
|
7675
|
+
import { FeedProtocol as FeedProtocol2 } from "@dxos/protocols";
|
|
7757
7676
|
import { Invitation as Invitation10 } from "@dxos/protocols/proto/dxos/client/services";
|
|
7758
7677
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
7759
7678
|
import { trace as Trace3 } from "@dxos/tracing";
|
|
@@ -7762,13 +7681,13 @@ import { safeInstanceof } from "@dxos/util";
|
|
|
7762
7681
|
// src/packlets/identity/identity-recovery-manager.ts
|
|
7763
7682
|
import { generateSeedPhrase, keyPairFromSeedPhrase } from "@dxos/credentials";
|
|
7764
7683
|
import { sign as sign3 } from "@dxos/crypto";
|
|
7765
|
-
import { invariant as
|
|
7684
|
+
import { invariant as invariant21 } from "@dxos/invariant";
|
|
7766
7685
|
import { PublicKey as PublicKey14 } from "@dxos/keys";
|
|
7767
|
-
import { log as
|
|
7686
|
+
import { log as log22 } from "@dxos/log";
|
|
7768
7687
|
import { EdgeAuthChallengeError as EdgeAuthChallengeError2 } from "@dxos/protocols";
|
|
7769
7688
|
import { schema as schema6 } from "@dxos/protocols/proto";
|
|
7770
7689
|
import { Timeframe as Timeframe5 } from "@dxos/timeframe";
|
|
7771
|
-
var
|
|
7690
|
+
var __dxlog_file26 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts";
|
|
7772
7691
|
var EdgeIdentityRecoveryManager = class {
|
|
7773
7692
|
_keyring;
|
|
7774
7693
|
_edgeClient;
|
|
@@ -7782,8 +7701,8 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7782
7701
|
}
|
|
7783
7702
|
async createRecoveryCredential({ data }) {
|
|
7784
7703
|
const identity = this._identityProvider();
|
|
7785
|
-
|
|
7786
|
-
F:
|
|
7704
|
+
invariant21(identity, void 0, {
|
|
7705
|
+
F: __dxlog_file26,
|
|
7787
7706
|
L: 39,
|
|
7788
7707
|
S: this,
|
|
7789
7708
|
A: [
|
|
@@ -7833,8 +7752,8 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7833
7752
|
};
|
|
7834
7753
|
}
|
|
7835
7754
|
async requestRecoveryChallenge() {
|
|
7836
|
-
|
|
7837
|
-
F:
|
|
7755
|
+
invariant21(this._edgeClient, "Not connected to EDGE.", {
|
|
7756
|
+
F: __dxlog_file26,
|
|
7838
7757
|
L: 76,
|
|
7839
7758
|
S: this,
|
|
7840
7759
|
A: [
|
|
@@ -7863,8 +7782,8 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7863
7782
|
}
|
|
7864
7783
|
}
|
|
7865
7784
|
async recoverIdentityWithExternalSignature({ lookupKey, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
|
|
7866
|
-
|
|
7867
|
-
F:
|
|
7785
|
+
invariant21(this._edgeClient, "Not connected to EDGE.", {
|
|
7786
|
+
F: __dxlog_file26,
|
|
7868
7787
|
L: 108,
|
|
7869
7788
|
S: this,
|
|
7870
7789
|
A: [
|
|
@@ -7897,8 +7816,8 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7897
7816
|
* Recovery identity using an opaque token sent to the user's email.
|
|
7898
7817
|
*/
|
|
7899
7818
|
async recoverIdentityWithToken({ token }) {
|
|
7900
|
-
|
|
7901
|
-
F:
|
|
7819
|
+
invariant21(this._edgeClient, "Not connected to EDGE.", {
|
|
7820
|
+
F: __dxlog_file26,
|
|
7902
7821
|
L: 141,
|
|
7903
7822
|
S: this,
|
|
7904
7823
|
A: [
|
|
@@ -7925,8 +7844,8 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7925
7844
|
});
|
|
7926
7845
|
}
|
|
7927
7846
|
async recoverIdentity({ recoveryCode }) {
|
|
7928
|
-
|
|
7929
|
-
F:
|
|
7847
|
+
invariant21(this._edgeClient, "Not connected to EDGE.", {
|
|
7848
|
+
F: __dxlog_file26,
|
|
7930
7849
|
L: 165,
|
|
7931
7850
|
S: this,
|
|
7932
7851
|
A: [
|
|
@@ -7956,8 +7875,8 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7956
7875
|
signature: Buffer.from(signature).toString("base64")
|
|
7957
7876
|
});
|
|
7958
7877
|
}
|
|
7959
|
-
|
|
7960
|
-
F:
|
|
7878
|
+
log22.info("recovering identity", response, {
|
|
7879
|
+
F: __dxlog_file26,
|
|
7961
7880
|
L: 191,
|
|
7962
7881
|
S: this,
|
|
7963
7882
|
C: (f, a) => f(...a)
|
|
@@ -7979,8 +7898,248 @@ var decodeCredential = (credentialBase64) => {
|
|
|
7979
7898
|
return codec.decode(credentialBytes);
|
|
7980
7899
|
};
|
|
7981
7900
|
|
|
7901
|
+
// src/packlets/services/feed-syncer.ts
|
|
7902
|
+
import { Encoder, decode as cborXdecode } from "cbor-x";
|
|
7903
|
+
import * as Effect from "effect/Effect";
|
|
7904
|
+
import * as Schema from "effect/Schema";
|
|
7905
|
+
import { AsyncTask, scheduleTask as scheduleTask9 } from "@dxos/async";
|
|
7906
|
+
import { Resource as Resource8 } from "@dxos/context";
|
|
7907
|
+
import { MessageSchema } from "@dxos/edge-client";
|
|
7908
|
+
import { RuntimeProvider } from "@dxos/effect";
|
|
7909
|
+
import { SyncClient } from "@dxos/feed";
|
|
7910
|
+
import { invariant as invariant22 } from "@dxos/invariant";
|
|
7911
|
+
import { SpaceId as SpaceId4 } from "@dxos/keys";
|
|
7912
|
+
import { FeedProtocol } from "@dxos/protocols";
|
|
7913
|
+
import { EdgeService as EdgeService2 } from "@dxos/protocols";
|
|
7914
|
+
import { createBuf } from "@dxos/protocols/buf";
|
|
7915
|
+
import { bufferToArray as bufferToArray2 } from "@dxos/util";
|
|
7916
|
+
var __dxlog_file27 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/feed-syncer.ts";
|
|
7917
|
+
var encoder = new Encoder({
|
|
7918
|
+
tagUint8Array: false,
|
|
7919
|
+
useRecords: false
|
|
7920
|
+
});
|
|
7921
|
+
var DEFAULT_MESSAGE_BLOCKS_LIMIT = 50;
|
|
7922
|
+
var DEFAULT_SYNC_CONCURRENCY = 5;
|
|
7923
|
+
var DEFAULT_POLLING_INTERVAL = 5e3;
|
|
7924
|
+
var DEFAULT_POLL_REQUEST_THROTTLE_MS = 250;
|
|
7925
|
+
var MAX_BLOCKING_SYNC_ITERATIONS = 100;
|
|
7926
|
+
var FeedSyncer = class extends Resource8 {
|
|
7927
|
+
#syncNamespaces;
|
|
7928
|
+
#messageBlocksLimit;
|
|
7929
|
+
#syncConcurrency;
|
|
7930
|
+
#pollingInterval;
|
|
7931
|
+
#pollRequestThrottleMs;
|
|
7932
|
+
#runtime;
|
|
7933
|
+
#feedStore;
|
|
7934
|
+
#edgeClient;
|
|
7935
|
+
#syncClient;
|
|
7936
|
+
#getSpaceIds;
|
|
7937
|
+
#spacesToPoll = /* @__PURE__ */ new Set();
|
|
7938
|
+
/** Last time full poll was completed. */
|
|
7939
|
+
#lastFullPoll = null;
|
|
7940
|
+
#throttledPollScheduled = false;
|
|
7941
|
+
#lastRequestedPollAt = null;
|
|
7942
|
+
constructor(options) {
|
|
7943
|
+
super();
|
|
7944
|
+
this.#runtime = options.runtime;
|
|
7945
|
+
this.#feedStore = options.feedStore;
|
|
7946
|
+
this.#edgeClient = options.edgeClient;
|
|
7947
|
+
this.#syncClient = new SyncClient({
|
|
7948
|
+
peerId: options.peerId,
|
|
7949
|
+
feedStore: options.feedStore,
|
|
7950
|
+
sendMessage: this.#sendMessage.bind(this)
|
|
7951
|
+
});
|
|
7952
|
+
this.#getSpaceIds = options.getSpaceIds;
|
|
7953
|
+
this.#syncNamespaces = options.syncNamespaces;
|
|
7954
|
+
this.#messageBlocksLimit = options.messageBlocksLimit ?? DEFAULT_MESSAGE_BLOCKS_LIMIT;
|
|
7955
|
+
this.#syncConcurrency = options.syncConcurrency ?? DEFAULT_SYNC_CONCURRENCY;
|
|
7956
|
+
this.#pollingInterval = options.pollingInterval ?? DEFAULT_POLLING_INTERVAL;
|
|
7957
|
+
this.#pollRequestThrottleMs = options.pollRequestThrottleMs ?? DEFAULT_POLL_REQUEST_THROTTLE_MS;
|
|
7958
|
+
}
|
|
7959
|
+
async _open() {
|
|
7960
|
+
this._ctx.onDispose(this.#edgeClient.onMessage((msg) => {
|
|
7961
|
+
if (!msg.serviceId) {
|
|
7962
|
+
return;
|
|
7963
|
+
}
|
|
7964
|
+
const service = msg.serviceId.split(":")[0];
|
|
7965
|
+
if (service !== EdgeService2.QUEUE_REPLICATOR) {
|
|
7966
|
+
return;
|
|
7967
|
+
}
|
|
7968
|
+
const handleMessageEffect = Effect.gen(this, function* () {
|
|
7969
|
+
const decoded = yield* Effect.try({
|
|
7970
|
+
try: () => cborXdecode(msg.payload.value),
|
|
7971
|
+
catch: (error) => new Error(`Failed to decode feed sync message: ${error}`)
|
|
7972
|
+
});
|
|
7973
|
+
const payload = yield* Schema.validate(FeedProtocol.ProtocolMessage)(decoded);
|
|
7974
|
+
yield* this.#syncClient.handleMessage(payload);
|
|
7975
|
+
});
|
|
7976
|
+
void RuntimeProvider.runPromise(this.#runtime)(handleMessageEffect);
|
|
7977
|
+
}));
|
|
7978
|
+
this._ctx.onDispose(
|
|
7979
|
+
// NOTE: This will fire immediately if the connection is already open.
|
|
7980
|
+
this.#edgeClient.onReconnected(async () => {
|
|
7981
|
+
})
|
|
7982
|
+
);
|
|
7983
|
+
this.#feedStore.onNewBlocks.on(this._ctx, () => {
|
|
7984
|
+
this.#pushTask.schedule();
|
|
7985
|
+
});
|
|
7986
|
+
await this.#pollTask.open();
|
|
7987
|
+
await this.#pushTask.open();
|
|
7988
|
+
this.#resetSpacesToPoll();
|
|
7989
|
+
this.#pollTask.schedule();
|
|
7990
|
+
}
|
|
7991
|
+
async _close() {
|
|
7992
|
+
await this.#pollTask.close();
|
|
7993
|
+
await this.#pushTask.close();
|
|
7994
|
+
}
|
|
7995
|
+
/**
|
|
7996
|
+
* Schedules a best-effort pull without blocking the caller.
|
|
7997
|
+
*/
|
|
7998
|
+
schedulePoll() {
|
|
7999
|
+
this.#resetSpacesToPoll();
|
|
8000
|
+
if (this.#throttledPollScheduled) {
|
|
8001
|
+
return;
|
|
8002
|
+
}
|
|
8003
|
+
const now = Date.now();
|
|
8004
|
+
const delay = this.#lastRequestedPollAt == null ? 0 : Math.max(this.#pollRequestThrottleMs - (now - this.#lastRequestedPollAt), 0);
|
|
8005
|
+
this.#throttledPollScheduled = true;
|
|
8006
|
+
scheduleTask9(this._ctx, () => {
|
|
8007
|
+
this.#throttledPollScheduled = false;
|
|
8008
|
+
this.#lastRequestedPollAt = Date.now();
|
|
8009
|
+
this.#pollTask.schedule();
|
|
8010
|
+
}, delay);
|
|
8011
|
+
}
|
|
8012
|
+
/**
|
|
8013
|
+
* Performs queue sync and blocks until there are no pending sync batches.
|
|
8014
|
+
*/
|
|
8015
|
+
async syncBlocking({ spaceId, subspaceTag, shouldPush = true, shouldPull = true }) {
|
|
8016
|
+
invariant22(SpaceId4.isValid(spaceId), void 0, {
|
|
8017
|
+
F: __dxlog_file27,
|
|
8018
|
+
L: 190,
|
|
8019
|
+
S: this,
|
|
8020
|
+
A: [
|
|
8021
|
+
"SpaceId.isValid(spaceId)",
|
|
8022
|
+
""
|
|
8023
|
+
]
|
|
8024
|
+
});
|
|
8025
|
+
invariant22(FeedProtocol.isWellKnownNamespace(subspaceTag), void 0, {
|
|
8026
|
+
F: __dxlog_file27,
|
|
8027
|
+
L: 191,
|
|
8028
|
+
S: this,
|
|
8029
|
+
A: [
|
|
8030
|
+
"FeedProtocol.isWellKnownNamespace(subspaceTag)",
|
|
8031
|
+
""
|
|
8032
|
+
]
|
|
8033
|
+
});
|
|
8034
|
+
if (!shouldPush && !shouldPull) {
|
|
8035
|
+
return;
|
|
8036
|
+
}
|
|
8037
|
+
await RuntimeProvider.runPromise(this.#runtime)(Effect.gen(this, function* () {
|
|
8038
|
+
let done = false;
|
|
8039
|
+
let iterations = 0;
|
|
8040
|
+
while (!done) {
|
|
8041
|
+
done = true;
|
|
8042
|
+
if (shouldPull) {
|
|
8043
|
+
const pullResult = yield* this.#syncClient.pull({
|
|
8044
|
+
spaceId,
|
|
8045
|
+
feedNamespace: subspaceTag,
|
|
8046
|
+
limit: this.#messageBlocksLimit
|
|
8047
|
+
});
|
|
8048
|
+
done &&= pullResult.done;
|
|
8049
|
+
}
|
|
8050
|
+
if (shouldPush) {
|
|
8051
|
+
const pushResult = yield* this.#syncClient.push({
|
|
8052
|
+
spaceId,
|
|
8053
|
+
feedNamespace: subspaceTag,
|
|
8054
|
+
limit: this.#messageBlocksLimit
|
|
8055
|
+
});
|
|
8056
|
+
done &&= pushResult.done;
|
|
8057
|
+
}
|
|
8058
|
+
iterations++;
|
|
8059
|
+
if (iterations > MAX_BLOCKING_SYNC_ITERATIONS) {
|
|
8060
|
+
throw new Error("Blocking sync exceeded max iterations.");
|
|
8061
|
+
}
|
|
8062
|
+
}
|
|
8063
|
+
}));
|
|
8064
|
+
}
|
|
8065
|
+
#resetSpacesToPoll() {
|
|
8066
|
+
this.#spacesToPoll.clear();
|
|
8067
|
+
this.#getSpaceIds().forEach((spaceId) => {
|
|
8068
|
+
this.#spacesToPoll.add(spaceId);
|
|
8069
|
+
});
|
|
8070
|
+
this.#lastFullPoll = Date.now();
|
|
8071
|
+
}
|
|
8072
|
+
#sendMessage(message) {
|
|
8073
|
+
return Effect.gen(this, function* () {
|
|
8074
|
+
const encoded = encoder.encode(message);
|
|
8075
|
+
yield* Effect.tryPromise(async () => this.#edgeClient.send(createBuf(MessageSchema, {
|
|
8076
|
+
source: {
|
|
8077
|
+
identityKey: this.#edgeClient.identityKey,
|
|
8078
|
+
peerKey: this.#edgeClient.peerKey
|
|
8079
|
+
},
|
|
8080
|
+
serviceId: this.#getTargetServiceId(message),
|
|
8081
|
+
payload: {
|
|
8082
|
+
value: bufferToArray2(encoded)
|
|
8083
|
+
}
|
|
8084
|
+
})));
|
|
8085
|
+
});
|
|
8086
|
+
}
|
|
8087
|
+
#getTargetServiceId(message) {
|
|
8088
|
+
return FeedProtocol.encodeServiceId(message.feedNamespace, message.spaceId);
|
|
8089
|
+
}
|
|
8090
|
+
#pollTask = new AsyncTask(async () => Effect.gen(this, function* () {
|
|
8091
|
+
yield* Effect.forEach(this.#spacesToPoll, (spaceId) => Effect.gen(this, function* () {
|
|
8092
|
+
let doneForAllNamespaces = true;
|
|
8093
|
+
for (const feedNamespace of this.#syncNamespaces) {
|
|
8094
|
+
const { done } = yield* this.#syncClient.pull({
|
|
8095
|
+
spaceId,
|
|
8096
|
+
feedNamespace,
|
|
8097
|
+
limit: this.#messageBlocksLimit
|
|
8098
|
+
});
|
|
8099
|
+
if (!done) {
|
|
8100
|
+
doneForAllNamespaces = false;
|
|
8101
|
+
}
|
|
8102
|
+
}
|
|
8103
|
+
if (doneForAllNamespaces) {
|
|
8104
|
+
this.#spacesToPoll.delete(spaceId);
|
|
8105
|
+
}
|
|
8106
|
+
}), {
|
|
8107
|
+
concurrency: this.#syncConcurrency
|
|
8108
|
+
});
|
|
8109
|
+
if (this.#lastFullPoll == null || Date.now() - this.#lastFullPoll > this.#pollingInterval) {
|
|
8110
|
+
this.#resetSpacesToPoll();
|
|
8111
|
+
this.#pollTask.schedule();
|
|
8112
|
+
} else if (this.#spacesToPoll.size > 0) {
|
|
8113
|
+
this.#pollTask.schedule();
|
|
8114
|
+
} else {
|
|
8115
|
+
this.#resetSpacesToPoll();
|
|
8116
|
+
scheduleTask9(this._ctx, () => this.#pollTask.schedule(), Math.max(this.#pollingInterval - (Date.now() - (this.#lastFullPoll ?? 0)), 0));
|
|
8117
|
+
}
|
|
8118
|
+
}).pipe(RuntimeProvider.runPromise(this.#runtime)));
|
|
8119
|
+
#pushTask = new AsyncTask(async () => Effect.gen(this, function* () {
|
|
8120
|
+
yield* Effect.forEach(this.#getSpaceIds(), (spaceId) => Effect.gen(this, function* () {
|
|
8121
|
+
let doneForAllNamespaces = true;
|
|
8122
|
+
for (const feedNamespace of this.#syncNamespaces) {
|
|
8123
|
+
const { done } = yield* this.#syncClient.push({
|
|
8124
|
+
spaceId,
|
|
8125
|
+
feedNamespace,
|
|
8126
|
+
limit: this.#messageBlocksLimit
|
|
8127
|
+
});
|
|
8128
|
+
if (!done) {
|
|
8129
|
+
doneForAllNamespaces = false;
|
|
8130
|
+
}
|
|
8131
|
+
}
|
|
8132
|
+
if (!doneForAllNamespaces) {
|
|
8133
|
+
this.#pushTask.schedule();
|
|
8134
|
+
}
|
|
8135
|
+
}), {
|
|
8136
|
+
concurrency: this.#syncConcurrency
|
|
8137
|
+
});
|
|
8138
|
+
}).pipe(RuntimeProvider.runPromise(this.#runtime)));
|
|
8139
|
+
};
|
|
8140
|
+
|
|
7982
8141
|
// src/packlets/services/service-context.ts
|
|
7983
|
-
function
|
|
8142
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
7984
8143
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7985
8144
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7986
8145
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -8052,14 +8211,15 @@ function _ts_dispose_resources4(env) {
|
|
|
8052
8211
|
})(env);
|
|
8053
8212
|
}
|
|
8054
8213
|
var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
8055
|
-
var ServiceContext = class extends
|
|
8214
|
+
var ServiceContext = class extends Resource9 {
|
|
8056
8215
|
storage;
|
|
8057
8216
|
level;
|
|
8058
8217
|
networkManager;
|
|
8059
8218
|
signalManager;
|
|
8060
8219
|
_edgeConnection;
|
|
8061
8220
|
_edgeHttpClient;
|
|
8062
|
-
|
|
8221
|
+
_runtime;
|
|
8222
|
+
_runtimeProps;
|
|
8063
8223
|
_edgeFeatures;
|
|
8064
8224
|
_edgeIdentityUpdateMutex = new Mutex4();
|
|
8065
8225
|
initialized = new Trigger7();
|
|
@@ -8075,14 +8235,27 @@ var ServiceContext = class extends Resource8 {
|
|
|
8075
8235
|
echoHost;
|
|
8076
8236
|
_meshReplicator = void 0;
|
|
8077
8237
|
_echoEdgeReplicator = void 0;
|
|
8238
|
+
_feedSyncer = void 0;
|
|
8078
8239
|
// Initialized after identity is initialized.
|
|
8079
8240
|
dataSpaceManager;
|
|
8080
8241
|
edgeAgentManager;
|
|
8081
8242
|
_handlerFactories = /* @__PURE__ */ new Map();
|
|
8082
8243
|
_deviceSpaceSync;
|
|
8083
8244
|
_instanceId = PublicKey15.random().toHex();
|
|
8084
|
-
constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient,
|
|
8085
|
-
super(), this.storage = storage, this.level = level, this.networkManager = networkManager, this.signalManager = signalManager, this._edgeConnection = _edgeConnection, this._edgeHttpClient = _edgeHttpClient, this.
|
|
8245
|
+
constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtime, _runtimeProps, _edgeFeatures) {
|
|
8246
|
+
super(), this.storage = storage, this.level = level, this.networkManager = networkManager, this.signalManager = signalManager, this._edgeConnection = _edgeConnection, this._edgeHttpClient = _edgeHttpClient, this._runtime = _runtime, this._runtimeProps = _runtimeProps, this._edgeFeatures = _edgeFeatures;
|
|
8247
|
+
log23("runtimeProps", this._runtimeProps, {
|
|
8248
|
+
F: __dxlog_file28,
|
|
8249
|
+
L: 122,
|
|
8250
|
+
S: this,
|
|
8251
|
+
C: (f, a) => f(...a)
|
|
8252
|
+
});
|
|
8253
|
+
log23("edgeFeatures", this._edgeFeatures, {
|
|
8254
|
+
F: __dxlog_file28,
|
|
8255
|
+
L: 123,
|
|
8256
|
+
S: this,
|
|
8257
|
+
C: (f, a) => f(...a)
|
|
8258
|
+
});
|
|
8086
8259
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
8087
8260
|
this.blobStore = new BlobStore(storage.createDirectory("blobs"));
|
|
8088
8261
|
this.keyring = new Keyring(storage.createDirectory("keyring"));
|
|
@@ -8101,15 +8274,15 @@ var ServiceContext = class extends Resource8 {
|
|
|
8101
8274
|
networkManager: this.networkManager,
|
|
8102
8275
|
blobStore: this.blobStore,
|
|
8103
8276
|
metadataStore: this.metadataStore,
|
|
8104
|
-
disableP2pReplication: this.
|
|
8277
|
+
disableP2pReplication: this._runtimeProps?.disableP2pReplication
|
|
8105
8278
|
});
|
|
8106
8279
|
this.identityManager = new IdentityManager({
|
|
8107
8280
|
metadataStore: this.metadataStore,
|
|
8108
8281
|
keyring: this.keyring,
|
|
8109
8282
|
feedStore: this.feedStore,
|
|
8110
8283
|
spaceManager: this.spaceManager,
|
|
8111
|
-
devicePresenceOfflineTimeout: this.
|
|
8112
|
-
devicePresenceAnnounceInterval: this.
|
|
8284
|
+
devicePresenceOfflineTimeout: this._runtimeProps?.devicePresenceOfflineTimeout,
|
|
8285
|
+
devicePresenceAnnounceInterval: this._runtimeProps?.devicePresenceAnnounceInterval,
|
|
8113
8286
|
edgeConnection: this._edgeConnection,
|
|
8114
8287
|
edgeFeatures: this._edgeFeatures
|
|
8115
8288
|
});
|
|
@@ -8118,15 +8291,20 @@ var ServiceContext = class extends Resource8 {
|
|
|
8118
8291
|
kv: this.level,
|
|
8119
8292
|
peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
|
|
8120
8293
|
getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
|
|
8121
|
-
|
|
8122
|
-
|
|
8294
|
+
runtime: this._runtime,
|
|
8295
|
+
syncQueue: async (request) => {
|
|
8296
|
+
return this._feedSyncer?.syncBlocking({
|
|
8297
|
+
spaceId: request.spaceId,
|
|
8298
|
+
subspaceTag: request.subspaceTag,
|
|
8299
|
+
shouldPush: request.shouldPush,
|
|
8300
|
+
shouldPull: request.shouldPull
|
|
8301
|
+
});
|
|
8123
8302
|
}
|
|
8124
8303
|
});
|
|
8125
|
-
this.
|
|
8126
|
-
this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
|
|
8304
|
+
this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeProps?.invitationConnectionDefaultProps);
|
|
8127
8305
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
8128
8306
|
this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
8129
|
-
if (!this.
|
|
8307
|
+
if (!this._runtimeProps?.disableP2pReplication) {
|
|
8130
8308
|
this._meshReplicator = new MeshEchoReplicator();
|
|
8131
8309
|
}
|
|
8132
8310
|
if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
|
|
@@ -8135,72 +8313,258 @@ var ServiceContext = class extends Resource8 {
|
|
|
8135
8313
|
edgeHttpClient: this._edgeHttpClient
|
|
8136
8314
|
});
|
|
8137
8315
|
}
|
|
8316
|
+
if (this.echoHost.feedStore && this._edgeConnection) {
|
|
8317
|
+
this._feedSyncer = new FeedSyncer({
|
|
8318
|
+
runtime: this._runtime,
|
|
8319
|
+
feedStore: this.echoHost.feedStore,
|
|
8320
|
+
edgeClient: this._edgeConnection,
|
|
8321
|
+
peerId: this.identityManager.identity?.deviceKey?.toHex() ?? "",
|
|
8322
|
+
getSpaceIds: () => this.echoHost.spaceIds,
|
|
8323
|
+
syncNamespaces: [
|
|
8324
|
+
FeedProtocol2.WellKnownNamespaces.data,
|
|
8325
|
+
FeedProtocol2.WellKnownNamespaces.trace
|
|
8326
|
+
]
|
|
8327
|
+
});
|
|
8328
|
+
}
|
|
8138
8329
|
}
|
|
8139
8330
|
async _open(ctx) {
|
|
8140
8331
|
await this._checkStorageVersion();
|
|
8141
|
-
|
|
8332
|
+
log23("opening...", void 0, {
|
|
8142
8333
|
F: __dxlog_file28,
|
|
8143
|
-
L:
|
|
8334
|
+
L: 231,
|
|
8144
8335
|
S: this,
|
|
8145
8336
|
C: (f, a) => f(...a)
|
|
8146
8337
|
});
|
|
8147
|
-
|
|
8338
|
+
log23.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
8148
8339
|
id: this._instanceId
|
|
8149
8340
|
}), {
|
|
8150
8341
|
F: __dxlog_file28,
|
|
8151
|
-
L:
|
|
8342
|
+
L: 232,
|
|
8343
|
+
S: this,
|
|
8344
|
+
C: (f, a) => f(...a)
|
|
8345
|
+
});
|
|
8346
|
+
log23("opening identityManager...", void 0, {
|
|
8347
|
+
F: __dxlog_file28,
|
|
8348
|
+
L: 234,
|
|
8152
8349
|
S: this,
|
|
8153
8350
|
C: (f, a) => f(...a)
|
|
8154
8351
|
});
|
|
8155
8352
|
await this.identityManager.open(ctx);
|
|
8353
|
+
log23("identityManager opened", {
|
|
8354
|
+
hasIdentity: !!this.identityManager.identity
|
|
8355
|
+
}, {
|
|
8356
|
+
F: __dxlog_file28,
|
|
8357
|
+
L: 236,
|
|
8358
|
+
S: this,
|
|
8359
|
+
C: (f, a) => f(...a)
|
|
8360
|
+
});
|
|
8361
|
+
log23("setting network identity...", void 0, {
|
|
8362
|
+
F: __dxlog_file28,
|
|
8363
|
+
L: 238,
|
|
8364
|
+
S: this,
|
|
8365
|
+
C: (f, a) => f(...a)
|
|
8366
|
+
});
|
|
8156
8367
|
await this._setNetworkIdentity();
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8368
|
+
log23("network identity set", void 0, {
|
|
8369
|
+
F: __dxlog_file28,
|
|
8370
|
+
L: 240,
|
|
8371
|
+
S: this,
|
|
8372
|
+
C: (f, a) => f(...a)
|
|
8373
|
+
});
|
|
8374
|
+
log23("opening edge connection...", void 0, {
|
|
8375
|
+
F: __dxlog_file28,
|
|
8376
|
+
L: 242,
|
|
8377
|
+
S: this,
|
|
8378
|
+
C: (f, a) => f(...a)
|
|
8379
|
+
});
|
|
8380
|
+
await this._edgeConnection?.open();
|
|
8381
|
+
log23("edge connection opened", void 0, {
|
|
8382
|
+
F: __dxlog_file28,
|
|
8383
|
+
L: 244,
|
|
8384
|
+
S: this,
|
|
8385
|
+
C: (f, a) => f(...a)
|
|
8386
|
+
});
|
|
8387
|
+
log23("opening signal manager...", void 0, {
|
|
8388
|
+
F: __dxlog_file28,
|
|
8389
|
+
L: 246,
|
|
8390
|
+
S: this,
|
|
8391
|
+
C: (f, a) => f(...a)
|
|
8392
|
+
});
|
|
8393
|
+
await this.signalManager.open();
|
|
8394
|
+
log23("signal manager opened", void 0, {
|
|
8395
|
+
F: __dxlog_file28,
|
|
8396
|
+
L: 248,
|
|
8397
|
+
S: this,
|
|
8398
|
+
C: (f, a) => f(...a)
|
|
8399
|
+
});
|
|
8400
|
+
log23("opening network manager...", void 0, {
|
|
8401
|
+
F: __dxlog_file28,
|
|
8402
|
+
L: 250,
|
|
8403
|
+
S: this,
|
|
8404
|
+
C: (f, a) => f(...a)
|
|
8405
|
+
});
|
|
8406
|
+
await this.networkManager.open();
|
|
8407
|
+
log23("network manager opened", void 0, {
|
|
8408
|
+
F: __dxlog_file28,
|
|
8409
|
+
L: 252,
|
|
8410
|
+
S: this,
|
|
8411
|
+
C: (f, a) => f(...a)
|
|
8412
|
+
});
|
|
8413
|
+
log23("opening echo host...", void 0, {
|
|
8414
|
+
F: __dxlog_file28,
|
|
8415
|
+
L: 254,
|
|
8416
|
+
S: this,
|
|
8417
|
+
C: (f, a) => f(...a)
|
|
8418
|
+
});
|
|
8419
|
+
await this.echoHost.open(ctx);
|
|
8420
|
+
log23("echo host opened", void 0, {
|
|
8421
|
+
F: __dxlog_file28,
|
|
8422
|
+
L: 256,
|
|
8423
|
+
S: this,
|
|
8424
|
+
C: (f, a) => f(...a)
|
|
8425
|
+
});
|
|
8161
8426
|
if (this._meshReplicator) {
|
|
8427
|
+
log23("adding mesh replicator...", void 0, {
|
|
8428
|
+
F: __dxlog_file28,
|
|
8429
|
+
L: 259,
|
|
8430
|
+
S: this,
|
|
8431
|
+
C: (f, a) => f(...a)
|
|
8432
|
+
});
|
|
8162
8433
|
await this.echoHost.addReplicator(this._meshReplicator);
|
|
8434
|
+
log23("mesh replicator added", void 0, {
|
|
8435
|
+
F: __dxlog_file28,
|
|
8436
|
+
L: 261,
|
|
8437
|
+
S: this,
|
|
8438
|
+
C: (f, a) => f(...a)
|
|
8439
|
+
});
|
|
8163
8440
|
}
|
|
8164
8441
|
if (this._echoEdgeReplicator) {
|
|
8442
|
+
log23("adding edge replicator...", void 0, {
|
|
8443
|
+
F: __dxlog_file28,
|
|
8444
|
+
L: 264,
|
|
8445
|
+
S: this,
|
|
8446
|
+
C: (f, a) => f(...a)
|
|
8447
|
+
});
|
|
8165
8448
|
await this.echoHost.addReplicator(this._echoEdgeReplicator);
|
|
8449
|
+
log23("edge replicator added", void 0, {
|
|
8450
|
+
F: __dxlog_file28,
|
|
8451
|
+
L: 266,
|
|
8452
|
+
S: this,
|
|
8453
|
+
C: (f, a) => f(...a)
|
|
8454
|
+
});
|
|
8166
8455
|
}
|
|
8456
|
+
log23("loading metadata store...", void 0, {
|
|
8457
|
+
F: __dxlog_file28,
|
|
8458
|
+
L: 269,
|
|
8459
|
+
S: this,
|
|
8460
|
+
C: (f, a) => f(...a)
|
|
8461
|
+
});
|
|
8167
8462
|
await this.metadataStore.load();
|
|
8463
|
+
log23("metadata store loaded", void 0, {
|
|
8464
|
+
F: __dxlog_file28,
|
|
8465
|
+
L: 271,
|
|
8466
|
+
S: this,
|
|
8467
|
+
C: (f, a) => f(...a)
|
|
8468
|
+
});
|
|
8469
|
+
log23("opening space manager...", void 0, {
|
|
8470
|
+
F: __dxlog_file28,
|
|
8471
|
+
L: 273,
|
|
8472
|
+
S: this,
|
|
8473
|
+
C: (f, a) => f(...a)
|
|
8474
|
+
});
|
|
8168
8475
|
await this.spaceManager.open();
|
|
8476
|
+
log23("space manager opened", void 0, {
|
|
8477
|
+
F: __dxlog_file28,
|
|
8478
|
+
L: 275,
|
|
8479
|
+
S: this,
|
|
8480
|
+
C: (f, a) => f(...a)
|
|
8481
|
+
});
|
|
8169
8482
|
if (this.identityManager.identity) {
|
|
8483
|
+
log23("joining network...", void 0, {
|
|
8484
|
+
F: __dxlog_file28,
|
|
8485
|
+
L: 278,
|
|
8486
|
+
S: this,
|
|
8487
|
+
C: (f, a) => f(...a)
|
|
8488
|
+
});
|
|
8170
8489
|
await this.identityManager.identity.joinNetwork();
|
|
8490
|
+
log23("network joined", void 0, {
|
|
8491
|
+
F: __dxlog_file28,
|
|
8492
|
+
L: 280,
|
|
8493
|
+
S: this,
|
|
8494
|
+
C: (f, a) => f(...a)
|
|
8495
|
+
});
|
|
8496
|
+
log23("initializing spaces...(calling _initialize)", void 0, {
|
|
8497
|
+
F: __dxlog_file28,
|
|
8498
|
+
L: 282,
|
|
8499
|
+
S: this,
|
|
8500
|
+
C: (f, a) => f(...a)
|
|
8501
|
+
});
|
|
8171
8502
|
await this._initialize(ctx);
|
|
8503
|
+
log23("spaces initialized", void 0, {
|
|
8504
|
+
F: __dxlog_file28,
|
|
8505
|
+
L: 284,
|
|
8506
|
+
S: this,
|
|
8507
|
+
C: (f, a) => f(...a)
|
|
8508
|
+
});
|
|
8509
|
+
} else {
|
|
8510
|
+
log23("no identity, skipping network join and space initialization", void 0, {
|
|
8511
|
+
F: __dxlog_file28,
|
|
8512
|
+
L: 286,
|
|
8513
|
+
S: this,
|
|
8514
|
+
C: (f, a) => f(...a)
|
|
8515
|
+
});
|
|
8172
8516
|
}
|
|
8517
|
+
log23("opening feed syncer...", void 0, {
|
|
8518
|
+
F: __dxlog_file28,
|
|
8519
|
+
L: 289,
|
|
8520
|
+
S: this,
|
|
8521
|
+
C: (f, a) => f(...a)
|
|
8522
|
+
});
|
|
8523
|
+
await this._feedSyncer?.open();
|
|
8524
|
+
log23("feed syncer opened", void 0, {
|
|
8525
|
+
F: __dxlog_file28,
|
|
8526
|
+
L: 291,
|
|
8527
|
+
S: this,
|
|
8528
|
+
C: (f, a) => f(...a)
|
|
8529
|
+
});
|
|
8530
|
+
log23("loading persistent invitations...", void 0, {
|
|
8531
|
+
F: __dxlog_file28,
|
|
8532
|
+
L: 293,
|
|
8533
|
+
S: this,
|
|
8534
|
+
C: (f, a) => f(...a)
|
|
8535
|
+
});
|
|
8173
8536
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
8174
|
-
|
|
8537
|
+
log23("loaded persistent invitations", {
|
|
8175
8538
|
count: loadedInvitations.invitations?.length
|
|
8176
8539
|
}, {
|
|
8177
8540
|
F: __dxlog_file28,
|
|
8178
|
-
L:
|
|
8541
|
+
L: 295,
|
|
8179
8542
|
S: this,
|
|
8180
8543
|
C: (f, a) => f(...a)
|
|
8181
8544
|
});
|
|
8182
|
-
|
|
8545
|
+
log23.trace("dxos.sdk.service-context.open", trace9.end({
|
|
8183
8546
|
id: this._instanceId
|
|
8184
8547
|
}), {
|
|
8185
8548
|
F: __dxlog_file28,
|
|
8186
|
-
L:
|
|
8549
|
+
L: 297,
|
|
8187
8550
|
S: this,
|
|
8188
8551
|
C: (f, a) => f(...a)
|
|
8189
8552
|
});
|
|
8190
|
-
|
|
8553
|
+
log23("opened", void 0, {
|
|
8191
8554
|
F: __dxlog_file28,
|
|
8192
|
-
L:
|
|
8555
|
+
L: 298,
|
|
8193
8556
|
S: this,
|
|
8194
8557
|
C: (f, a) => f(...a)
|
|
8195
8558
|
});
|
|
8196
8559
|
}
|
|
8197
8560
|
async _close(ctx) {
|
|
8198
|
-
|
|
8561
|
+
log23("closing...", void 0, {
|
|
8199
8562
|
F: __dxlog_file28,
|
|
8200
|
-
L:
|
|
8563
|
+
L: 302,
|
|
8201
8564
|
S: this,
|
|
8202
8565
|
C: (f, a) => f(...a)
|
|
8203
8566
|
});
|
|
8567
|
+
await this._feedSyncer?.close();
|
|
8204
8568
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
8205
8569
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
8206
8570
|
}
|
|
@@ -8214,9 +8578,9 @@ var ServiceContext = class extends Resource8 {
|
|
|
8214
8578
|
await this._edgeConnection?.close();
|
|
8215
8579
|
await this.feedStore.close();
|
|
8216
8580
|
await this.metadataStore.close();
|
|
8217
|
-
|
|
8581
|
+
log23("closed", void 0, {
|
|
8218
8582
|
F: __dxlog_file28,
|
|
8219
|
-
L:
|
|
8583
|
+
L: 321,
|
|
8220
8584
|
S: this,
|
|
8221
8585
|
C: (f, a) => f(...a)
|
|
8222
8586
|
});
|
|
@@ -8227,7 +8591,7 @@ var ServiceContext = class extends Resource8 {
|
|
|
8227
8591
|
await identity.joinNetwork();
|
|
8228
8592
|
await this._initialize(new Context10(void 0, {
|
|
8229
8593
|
F: __dxlog_file28,
|
|
8230
|
-
L:
|
|
8594
|
+
L: 328
|
|
8231
8595
|
}));
|
|
8232
8596
|
return identity;
|
|
8233
8597
|
}
|
|
@@ -8238,7 +8602,7 @@ var ServiceContext = class extends Resource8 {
|
|
|
8238
8602
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
8239
8603
|
invariant23(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
8240
8604
|
F: __dxlog_file28,
|
|
8241
|
-
L:
|
|
8605
|
+
L: 337,
|
|
8242
8606
|
S: this,
|
|
8243
8607
|
A: [
|
|
8244
8608
|
"factory",
|
|
@@ -8264,7 +8628,7 @@ var ServiceContext = class extends Resource8 {
|
|
|
8264
8628
|
await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
|
|
8265
8629
|
await this._initialize(new Context10(void 0, {
|
|
8266
8630
|
F: __dxlog_file28,
|
|
8267
|
-
L:
|
|
8631
|
+
L: 356
|
|
8268
8632
|
}));
|
|
8269
8633
|
return identity;
|
|
8270
8634
|
}
|
|
@@ -8276,9 +8640,9 @@ var ServiceContext = class extends Resource8 {
|
|
|
8276
8640
|
}
|
|
8277
8641
|
// Called when identity is created.
|
|
8278
8642
|
async _initialize(ctx) {
|
|
8279
|
-
|
|
8643
|
+
log23("_initialize: start", void 0, {
|
|
8280
8644
|
F: __dxlog_file28,
|
|
8281
|
-
L:
|
|
8645
|
+
L: 371,
|
|
8282
8646
|
S: this,
|
|
8283
8647
|
C: (f, a) => f(...a)
|
|
8284
8648
|
});
|
|
@@ -8296,6 +8660,12 @@ var ServiceContext = class extends Resource8 {
|
|
|
8296
8660
|
});
|
|
8297
8661
|
}
|
|
8298
8662
|
};
|
|
8663
|
+
log23("_initialize: creating DataSpaceManager", void 0, {
|
|
8664
|
+
F: __dxlog_file28,
|
|
8665
|
+
L: 383,
|
|
8666
|
+
S: this,
|
|
8667
|
+
C: (f, a) => f(...a)
|
|
8668
|
+
});
|
|
8299
8669
|
this.dataSpaceManager = new DataSpaceManager({
|
|
8300
8670
|
spaceManager: this.spaceManager,
|
|
8301
8671
|
metadataStore: this.metadataStore,
|
|
@@ -8308,16 +8678,40 @@ var ServiceContext = class extends Resource8 {
|
|
|
8308
8678
|
edgeHttpClient: this._edgeHttpClient,
|
|
8309
8679
|
echoEdgeReplicator: this._echoEdgeReplicator,
|
|
8310
8680
|
meshReplicator: this._meshReplicator,
|
|
8311
|
-
|
|
8681
|
+
runtimeProps: this._runtimeProps,
|
|
8312
8682
|
edgeFeatures: this._edgeFeatures
|
|
8313
8683
|
});
|
|
8684
|
+
log23("_initialize: opening DataSpaceManager...", void 0, {
|
|
8685
|
+
F: __dxlog_file28,
|
|
8686
|
+
L: 399,
|
|
8687
|
+
S: this,
|
|
8688
|
+
C: (f, a) => f(...a)
|
|
8689
|
+
});
|
|
8314
8690
|
await this.dataSpaceManager.open();
|
|
8691
|
+
log23("_initialize: DataSpaceManager opened", void 0, {
|
|
8692
|
+
F: __dxlog_file28,
|
|
8693
|
+
L: 401,
|
|
8694
|
+
S: this,
|
|
8695
|
+
C: (f, a) => f(...a)
|
|
8696
|
+
});
|
|
8315
8697
|
this.edgeAgentManager = new EdgeAgentManager(this._edgeFeatures, this._edgeHttpClient, this.dataSpaceManager, identity);
|
|
8698
|
+
log23("_initialize: opening EdgeAgentManager...", void 0, {
|
|
8699
|
+
F: __dxlog_file28,
|
|
8700
|
+
L: 409,
|
|
8701
|
+
S: this,
|
|
8702
|
+
C: (f, a) => f(...a)
|
|
8703
|
+
});
|
|
8316
8704
|
await this.edgeAgentManager.open();
|
|
8705
|
+
log23("_initialize: EdgeAgentManager opened", void 0, {
|
|
8706
|
+
F: __dxlog_file28,
|
|
8707
|
+
L: 411,
|
|
8708
|
+
S: this,
|
|
8709
|
+
C: (f, a) => f(...a)
|
|
8710
|
+
});
|
|
8317
8711
|
this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
|
|
8318
8712
|
invariant23(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
8319
8713
|
F: __dxlog_file28,
|
|
8320
|
-
L:
|
|
8714
|
+
L: 414,
|
|
8321
8715
|
S: this,
|
|
8322
8716
|
A: [
|
|
8323
8717
|
"this.dataSpaceManager",
|
|
@@ -8327,6 +8721,12 @@ var ServiceContext = class extends Resource8 {
|
|
|
8327
8721
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
8328
8722
|
});
|
|
8329
8723
|
this.initialized.wake();
|
|
8724
|
+
log23("_initialize: initialized.wake() called", void 0, {
|
|
8725
|
+
F: __dxlog_file28,
|
|
8726
|
+
L: 418,
|
|
8727
|
+
S: this,
|
|
8728
|
+
C: (f, a) => f(...a)
|
|
8729
|
+
});
|
|
8330
8730
|
this._deviceSpaceSync = {
|
|
8331
8731
|
processCredential: async (credential) => {
|
|
8332
8732
|
const assertion = getCredentialAssertion6(credential);
|
|
@@ -8337,33 +8737,33 @@ var ServiceContext = class extends Resource8 {
|
|
|
8337
8737
|
return;
|
|
8338
8738
|
}
|
|
8339
8739
|
if (!this.dataSpaceManager) {
|
|
8340
|
-
|
|
8740
|
+
log23("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
8341
8741
|
details: assertion
|
|
8342
8742
|
}, {
|
|
8343
8743
|
F: __dxlog_file28,
|
|
8344
|
-
L:
|
|
8744
|
+
L: 431,
|
|
8345
8745
|
S: this,
|
|
8346
8746
|
C: (f, a) => f(...a)
|
|
8347
8747
|
});
|
|
8348
8748
|
return;
|
|
8349
8749
|
}
|
|
8350
8750
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
8351
|
-
|
|
8751
|
+
log23("space already exists, ignoring space admission", {
|
|
8352
8752
|
details: assertion
|
|
8353
8753
|
}, {
|
|
8354
8754
|
F: __dxlog_file28,
|
|
8355
|
-
L:
|
|
8755
|
+
L: 435,
|
|
8356
8756
|
S: this,
|
|
8357
8757
|
C: (f, a) => f(...a)
|
|
8358
8758
|
});
|
|
8359
8759
|
return;
|
|
8360
8760
|
}
|
|
8361
8761
|
try {
|
|
8362
|
-
|
|
8762
|
+
log23("accepting space recorded in halo", {
|
|
8363
8763
|
details: assertion
|
|
8364
8764
|
}, {
|
|
8365
8765
|
F: __dxlog_file28,
|
|
8366
|
-
L:
|
|
8766
|
+
L: 440,
|
|
8367
8767
|
S: this,
|
|
8368
8768
|
C: (f, a) => f(...a)
|
|
8369
8769
|
});
|
|
@@ -8372,9 +8772,9 @@ var ServiceContext = class extends Resource8 {
|
|
|
8372
8772
|
genesisFeedKey: assertion.genesisFeedKey
|
|
8373
8773
|
});
|
|
8374
8774
|
} catch (err) {
|
|
8375
|
-
|
|
8775
|
+
log23.catch(err, void 0, {
|
|
8376
8776
|
F: __dxlog_file28,
|
|
8377
|
-
L:
|
|
8777
|
+
L: 446,
|
|
8378
8778
|
S: this,
|
|
8379
8779
|
C: (f, a) => f(...a)
|
|
8380
8780
|
});
|
|
@@ -8390,40 +8790,102 @@ var ServiceContext = class extends Resource8 {
|
|
|
8390
8790
|
hasError: false
|
|
8391
8791
|
};
|
|
8392
8792
|
try {
|
|
8793
|
+
log23("_setNetworkIdentity: acquiring mutex...", void 0, {
|
|
8794
|
+
F: __dxlog_file28,
|
|
8795
|
+
L: 455,
|
|
8796
|
+
S: this,
|
|
8797
|
+
C: (f, a) => f(...a)
|
|
8798
|
+
});
|
|
8393
8799
|
const _ = _ts_add_disposable_resource4(env, await this._edgeIdentityUpdateMutex.acquire(), false);
|
|
8800
|
+
log23("_setNetworkIdentity: mutex acquired", void 0, {
|
|
8801
|
+
F: __dxlog_file28,
|
|
8802
|
+
L: 457,
|
|
8803
|
+
S: this,
|
|
8804
|
+
C: (f, a) => f(...a)
|
|
8805
|
+
});
|
|
8394
8806
|
let edgeIdentity;
|
|
8395
8807
|
const identity = this.identityManager.identity;
|
|
8396
8808
|
if (identity) {
|
|
8397
|
-
|
|
8809
|
+
log23("_setNetworkIdentity: has identity", {
|
|
8398
8810
|
identity: identity.identityKey.toHex(),
|
|
8399
|
-
|
|
8811
|
+
hasDeviceCredential: !!params?.deviceCredential
|
|
8400
8812
|
}, {
|
|
8401
8813
|
F: __dxlog_file28,
|
|
8402
|
-
L:
|
|
8814
|
+
L: 462,
|
|
8403
8815
|
S: this,
|
|
8404
8816
|
C: (f, a) => f(...a)
|
|
8405
8817
|
});
|
|
8406
8818
|
if (params?.deviceCredential) {
|
|
8819
|
+
log23("_setNetworkIdentity: creating chain edge identity with device credential...", void 0, {
|
|
8820
|
+
F: __dxlog_file28,
|
|
8821
|
+
L: 468,
|
|
8822
|
+
S: this,
|
|
8823
|
+
C: (f, a) => f(...a)
|
|
8824
|
+
});
|
|
8407
8825
|
edgeIdentity = await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, params?.deviceCredential && {
|
|
8408
8826
|
credential: params.deviceCredential
|
|
8409
8827
|
}, []);
|
|
8828
|
+
log23("_setNetworkIdentity: chain edge identity created", void 0, {
|
|
8829
|
+
F: __dxlog_file28,
|
|
8830
|
+
L: 476,
|
|
8831
|
+
S: this,
|
|
8832
|
+
C: (f, a) => f(...a)
|
|
8833
|
+
});
|
|
8410
8834
|
} else {
|
|
8835
|
+
log23("_setNetworkIdentity: waiting for identity.ready()...", void 0, {
|
|
8836
|
+
F: __dxlog_file28,
|
|
8837
|
+
L: 478,
|
|
8838
|
+
S: this,
|
|
8839
|
+
C: (f, a) => f(...a)
|
|
8840
|
+
});
|
|
8411
8841
|
await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
|
|
8412
8842
|
await identity.ready();
|
|
8413
8843
|
});
|
|
8844
|
+
log23("_setNetworkIdentity: identity.ready() resolved", {
|
|
8845
|
+
hasDeviceCredentialChain: !!identity.deviceCredentialChain
|
|
8846
|
+
}, {
|
|
8847
|
+
F: __dxlog_file28,
|
|
8848
|
+
L: 483,
|
|
8849
|
+
S: this,
|
|
8850
|
+
C: (f, a) => f(...a)
|
|
8851
|
+
});
|
|
8414
8852
|
invariant23(identity.deviceCredentialChain, void 0, {
|
|
8415
8853
|
F: __dxlog_file28,
|
|
8416
|
-
L:
|
|
8854
|
+
L: 487,
|
|
8417
8855
|
S: this,
|
|
8418
8856
|
A: [
|
|
8419
8857
|
"identity.deviceCredentialChain",
|
|
8420
8858
|
""
|
|
8421
8859
|
]
|
|
8422
8860
|
});
|
|
8861
|
+
log23("_setNetworkIdentity: creating chain edge identity...", void 0, {
|
|
8862
|
+
F: __dxlog_file28,
|
|
8863
|
+
L: 489,
|
|
8864
|
+
S: this,
|
|
8865
|
+
C: (f, a) => f(...a)
|
|
8866
|
+
});
|
|
8423
8867
|
edgeIdentity = await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, identity.deviceCredentialChain, []);
|
|
8868
|
+
log23("_setNetworkIdentity: chain edge identity created", void 0, {
|
|
8869
|
+
F: __dxlog_file28,
|
|
8870
|
+
L: 497,
|
|
8871
|
+
S: this,
|
|
8872
|
+
C: (f, a) => f(...a)
|
|
8873
|
+
});
|
|
8424
8874
|
}
|
|
8425
8875
|
} else {
|
|
8876
|
+
log23("_setNetworkIdentity: no identity, creating ephemeral edge identity...", void 0, {
|
|
8877
|
+
F: __dxlog_file28,
|
|
8878
|
+
L: 500,
|
|
8879
|
+
S: this,
|
|
8880
|
+
C: (f, a) => f(...a)
|
|
8881
|
+
});
|
|
8426
8882
|
edgeIdentity = await createEphemeralEdgeIdentity();
|
|
8883
|
+
log23("_setNetworkIdentity: ephemeral edge identity created", void 0, {
|
|
8884
|
+
F: __dxlog_file28,
|
|
8885
|
+
L: 502,
|
|
8886
|
+
S: this,
|
|
8887
|
+
C: (f, a) => f(...a)
|
|
8888
|
+
});
|
|
8427
8889
|
}
|
|
8428
8890
|
this._edgeConnection?.setIdentity(edgeIdentity);
|
|
8429
8891
|
this._edgeHttpClient?.setIdentity(edgeIdentity);
|
|
@@ -8431,6 +8893,12 @@ var ServiceContext = class extends Resource8 {
|
|
|
8431
8893
|
identityKey: edgeIdentity.identityKey,
|
|
8432
8894
|
peerKey: edgeIdentity.peerKey
|
|
8433
8895
|
});
|
|
8896
|
+
log23("_setNetworkIdentity: done", void 0, {
|
|
8897
|
+
F: __dxlog_file28,
|
|
8898
|
+
L: 511,
|
|
8899
|
+
S: this,
|
|
8900
|
+
C: (f, a) => f(...a)
|
|
8901
|
+
});
|
|
8434
8902
|
} catch (e) {
|
|
8435
8903
|
env.error = e;
|
|
8436
8904
|
env.hasError = true;
|
|
@@ -8439,13 +8907,13 @@ var ServiceContext = class extends Resource8 {
|
|
|
8439
8907
|
}
|
|
8440
8908
|
}
|
|
8441
8909
|
};
|
|
8442
|
-
|
|
8910
|
+
_ts_decorate8([
|
|
8443
8911
|
Trace3.span()
|
|
8444
8912
|
], ServiceContext.prototype, "_open", null);
|
|
8445
|
-
|
|
8913
|
+
_ts_decorate8([
|
|
8446
8914
|
Trace3.span()
|
|
8447
8915
|
], ServiceContext.prototype, "_initialize", null);
|
|
8448
|
-
ServiceContext =
|
|
8916
|
+
ServiceContext = _ts_decorate8([
|
|
8449
8917
|
safeInstanceof("dxos.client-services.ServiceContext"),
|
|
8450
8918
|
Trace3.resource()
|
|
8451
8919
|
], ServiceContext);
|
|
@@ -8532,165 +9000,6 @@ var createLevel = async (config) => {
|
|
|
8532
9000
|
return level;
|
|
8533
9001
|
};
|
|
8534
9002
|
|
|
8535
|
-
// src/packlets/storage/profile-archive.ts
|
|
8536
|
-
import { cbor } from "@automerge/automerge-repo";
|
|
8537
|
-
import { invariant as invariant24 } from "@dxos/invariant";
|
|
8538
|
-
import { log as log25 } from "@dxos/log";
|
|
8539
|
-
import { ProfileArchiveEntryType } from "@dxos/protocols";
|
|
8540
|
-
import { arrayToBuffer as arrayToBuffer2 } from "@dxos/util";
|
|
8541
|
-
var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
|
|
8542
|
-
var encodeProfileArchive = (profile) => cbor.encode(profile);
|
|
8543
|
-
var decodeProfileArchive = (data) => cbor.decode(data);
|
|
8544
|
-
var exportProfileData = async ({ storage, level }) => {
|
|
8545
|
-
const archive = {
|
|
8546
|
-
storage: [],
|
|
8547
|
-
meta: {
|
|
8548
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8549
|
-
}
|
|
8550
|
-
};
|
|
8551
|
-
{
|
|
8552
|
-
const directory = await storage.createDirectory();
|
|
8553
|
-
const files = await directory.list();
|
|
8554
|
-
log25.info("begin exporting files", {
|
|
8555
|
-
count: files.length
|
|
8556
|
-
}, {
|
|
8557
|
-
F: __dxlog_file29,
|
|
8558
|
-
L: 31,
|
|
8559
|
-
S: void 0,
|
|
8560
|
-
C: (f, a) => f(...a)
|
|
8561
|
-
});
|
|
8562
|
-
for (const filename of files) {
|
|
8563
|
-
const file = await directory.getOrCreateFile(filename);
|
|
8564
|
-
const { size } = await file.stat();
|
|
8565
|
-
const data = await file.read(0, size);
|
|
8566
|
-
archive.storage.push({
|
|
8567
|
-
type: ProfileArchiveEntryType.FILE,
|
|
8568
|
-
key: filename,
|
|
8569
|
-
value: data
|
|
8570
|
-
});
|
|
8571
|
-
}
|
|
8572
|
-
log25.info("done exporting files", {
|
|
8573
|
-
count: files.length
|
|
8574
|
-
}, {
|
|
8575
|
-
F: __dxlog_file29,
|
|
8576
|
-
L: 42,
|
|
8577
|
-
S: void 0,
|
|
8578
|
-
C: (f, a) => f(...a)
|
|
8579
|
-
});
|
|
8580
|
-
}
|
|
8581
|
-
{
|
|
8582
|
-
log25.info("begin exporting kv pairs", void 0, {
|
|
8583
|
-
F: __dxlog_file29,
|
|
8584
|
-
L: 46,
|
|
8585
|
-
S: void 0,
|
|
8586
|
-
C: (f, a) => f(...a)
|
|
8587
|
-
});
|
|
8588
|
-
const iter = await level.iterator({
|
|
8589
|
-
keyEncoding: "binary",
|
|
8590
|
-
valueEncoding: "binary"
|
|
8591
|
-
});
|
|
8592
|
-
let count = 0;
|
|
8593
|
-
for await (const [key, value] of iter) {
|
|
8594
|
-
archive.storage.push({
|
|
8595
|
-
type: ProfileArchiveEntryType.KEY_VALUE,
|
|
8596
|
-
key,
|
|
8597
|
-
value
|
|
8598
|
-
});
|
|
8599
|
-
count++;
|
|
8600
|
-
}
|
|
8601
|
-
log25.info("done exporting kv pairs", {
|
|
8602
|
-
count
|
|
8603
|
-
}, {
|
|
8604
|
-
F: __dxlog_file29,
|
|
8605
|
-
L: 57,
|
|
8606
|
-
S: void 0,
|
|
8607
|
-
C: (f, a) => f(...a)
|
|
8608
|
-
});
|
|
8609
|
-
}
|
|
8610
|
-
return archive;
|
|
8611
|
-
};
|
|
8612
|
-
var importProfileData = async ({ storage, level }, archive) => {
|
|
8613
|
-
let batch = level.batch();
|
|
8614
|
-
let count = 0;
|
|
8615
|
-
for (const entry2 of archive.storage) {
|
|
8616
|
-
switch (entry2.type) {
|
|
8617
|
-
case ProfileArchiveEntryType.FILE: {
|
|
8618
|
-
const directory = await storage.createDirectory();
|
|
8619
|
-
invariant24(typeof entry2.key === "string", "Invalid key type", {
|
|
8620
|
-
F: __dxlog_file29,
|
|
8621
|
-
L: 80,
|
|
8622
|
-
S: void 0,
|
|
8623
|
-
A: [
|
|
8624
|
-
"typeof entry.key === 'string'",
|
|
8625
|
-
"'Invalid key type'"
|
|
8626
|
-
]
|
|
8627
|
-
});
|
|
8628
|
-
const file = await directory.getOrCreateFile(entry2.key);
|
|
8629
|
-
invariant24(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
8630
|
-
F: __dxlog_file29,
|
|
8631
|
-
L: 82,
|
|
8632
|
-
S: void 0,
|
|
8633
|
-
A: [
|
|
8634
|
-
"entry.value instanceof Uint8Array",
|
|
8635
|
-
"'Invalid value type'"
|
|
8636
|
-
]
|
|
8637
|
-
});
|
|
8638
|
-
await file.write(0, arrayToBuffer2(entry2.value));
|
|
8639
|
-
await file.close();
|
|
8640
|
-
break;
|
|
8641
|
-
}
|
|
8642
|
-
case ProfileArchiveEntryType.KEY_VALUE: {
|
|
8643
|
-
invariant24(entry2.key instanceof Uint8Array, "Invalid key type", {
|
|
8644
|
-
F: __dxlog_file29,
|
|
8645
|
-
L: 88,
|
|
8646
|
-
S: void 0,
|
|
8647
|
-
A: [
|
|
8648
|
-
"entry.key instanceof Uint8Array",
|
|
8649
|
-
"'Invalid key type'"
|
|
8650
|
-
]
|
|
8651
|
-
});
|
|
8652
|
-
invariant24(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
8653
|
-
F: __dxlog_file29,
|
|
8654
|
-
L: 89,
|
|
8655
|
-
S: void 0,
|
|
8656
|
-
A: [
|
|
8657
|
-
"entry.value instanceof Uint8Array",
|
|
8658
|
-
"'Invalid value type'"
|
|
8659
|
-
]
|
|
8660
|
-
});
|
|
8661
|
-
batch.put(entry2.key, entry2.value, {
|
|
8662
|
-
keyEncoding: "binary",
|
|
8663
|
-
valueEncoding: "binary"
|
|
8664
|
-
});
|
|
8665
|
-
break;
|
|
8666
|
-
}
|
|
8667
|
-
default:
|
|
8668
|
-
throw new Error(`Invalid entry type: ${entry2.type}`);
|
|
8669
|
-
}
|
|
8670
|
-
if (++count % 1e3 === 0) {
|
|
8671
|
-
await batch.write();
|
|
8672
|
-
batch = level.batch();
|
|
8673
|
-
log25.info("importing", {
|
|
8674
|
-
count,
|
|
8675
|
-
total: archive.storage.length,
|
|
8676
|
-
progress: `${(count / archive.storage.length * 100).toFixed()}%`
|
|
8677
|
-
}, {
|
|
8678
|
-
F: __dxlog_file29,
|
|
8679
|
-
L: 102,
|
|
8680
|
-
S: void 0,
|
|
8681
|
-
C: (f, a) => f(...a)
|
|
8682
|
-
});
|
|
8683
|
-
}
|
|
8684
|
-
}
|
|
8685
|
-
log25.info("committing changes..", void 0, {
|
|
8686
|
-
F: __dxlog_file29,
|
|
8687
|
-
L: 110,
|
|
8688
|
-
S: void 0,
|
|
8689
|
-
C: (f, a) => f(...a)
|
|
8690
|
-
});
|
|
8691
|
-
await batch.write();
|
|
8692
|
-
};
|
|
8693
|
-
|
|
8694
9003
|
// src/packlets/services/service-registry.ts
|
|
8695
9004
|
var ServiceRegistry = class {
|
|
8696
9005
|
_serviceBundle;
|
|
@@ -8718,26 +9027,30 @@ var ServiceRegistry = class {
|
|
|
8718
9027
|
};
|
|
8719
9028
|
|
|
8720
9029
|
// src/packlets/services/service-host.ts
|
|
9030
|
+
import * as SqlClient from "@effect/sql/SqlClient";
|
|
9031
|
+
import * as Effect2 from "effect/Effect";
|
|
8721
9032
|
import { Event as Event11, synchronized as synchronized4 } from "@dxos/async";
|
|
8722
9033
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
8723
9034
|
import { Context as Context11 } from "@dxos/context";
|
|
8724
9035
|
import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity } from "@dxos/edge-client";
|
|
8725
|
-
import {
|
|
9036
|
+
import { RuntimeProvider as RuntimeProvider2 } from "@dxos/effect";
|
|
9037
|
+
import { invariant as invariant25 } from "@dxos/invariant";
|
|
8726
9038
|
import { PublicKey as PublicKey19 } from "@dxos/keys";
|
|
8727
|
-
import { log as
|
|
9039
|
+
import { log as log25 } from "@dxos/log";
|
|
8728
9040
|
import { EdgeSignalManager, WebsocketSignalManager } from "@dxos/messaging";
|
|
8729
9041
|
import { SwarmNetworkManager, createIceProvider, createRtcTransportFactory } from "@dxos/network-manager";
|
|
8730
|
-
import { trace as
|
|
9042
|
+
import { trace as trace10 } from "@dxos/protocols";
|
|
8731
9043
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
9044
|
+
import * as SqlExport from "@dxos/sql-sqlite/SqlExport";
|
|
8732
9045
|
import { TRACE_PROCESSOR as TRACE_PROCESSOR3, trace as Trace4 } from "@dxos/tracing";
|
|
8733
9046
|
import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
8734
9047
|
|
|
8735
9048
|
// src/packlets/devices/devices-service.ts
|
|
8736
9049
|
import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
|
|
8737
|
-
import { Stream as
|
|
8738
|
-
import { invariant as
|
|
9050
|
+
import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
|
|
9051
|
+
import { invariant as invariant24 } from "@dxos/invariant";
|
|
8739
9052
|
import { Device as Device2, DeviceKind as DeviceKind2, EdgeStatus as EdgeStatus3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
8740
|
-
var
|
|
9053
|
+
var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
8741
9054
|
var DevicesServiceImpl = class {
|
|
8742
9055
|
_identityManager;
|
|
8743
9056
|
_edgeConnection;
|
|
@@ -8749,7 +9062,7 @@ var DevicesServiceImpl = class {
|
|
|
8749
9062
|
return this._identityManager.updateDeviceProfile(profile);
|
|
8750
9063
|
}
|
|
8751
9064
|
queryDevices() {
|
|
8752
|
-
return new
|
|
9065
|
+
return new Stream11(({ next }) => {
|
|
8753
9066
|
const update = () => {
|
|
8754
9067
|
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
8755
9068
|
if (!deviceKeys) {
|
|
@@ -8757,8 +9070,8 @@ var DevicesServiceImpl = class {
|
|
|
8757
9070
|
devices: []
|
|
8758
9071
|
});
|
|
8759
9072
|
} else {
|
|
8760
|
-
|
|
8761
|
-
F:
|
|
9073
|
+
invariant24(this._identityManager.identity?.presence, "presence not present", {
|
|
9074
|
+
F: __dxlog_file29,
|
|
8762
9075
|
L: 37,
|
|
8763
9076
|
S: this,
|
|
8764
9077
|
A: [
|
|
@@ -8825,8 +9138,8 @@ var DevicesServiceImpl = class {
|
|
|
8825
9138
|
};
|
|
8826
9139
|
|
|
8827
9140
|
// src/packlets/identity/contacts-service.ts
|
|
8828
|
-
import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateScheduler2, scheduleTask as
|
|
8829
|
-
import { Stream as
|
|
9141
|
+
import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateScheduler2, scheduleTask as scheduleTask10 } from "@dxos/async";
|
|
9142
|
+
import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
|
|
8830
9143
|
import { PublicKey as PublicKey17 } from "@dxos/keys";
|
|
8831
9144
|
import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
|
|
8832
9145
|
var ContactsServiceImpl = class {
|
|
@@ -8880,14 +9193,14 @@ var ContactsServiceImpl = class {
|
|
|
8880
9193
|
}
|
|
8881
9194
|
queryContacts() {
|
|
8882
9195
|
const subscribedSpaceKeySet = new ComplexSet6(PublicKey17.hash);
|
|
8883
|
-
return new
|
|
9196
|
+
return new Stream12(({ next, ctx }) => {
|
|
8884
9197
|
const pushUpdateTask = new UpdateScheduler2(ctx, async () => {
|
|
8885
9198
|
const contacts = await this.getContacts();
|
|
8886
9199
|
next(contacts);
|
|
8887
9200
|
}, {
|
|
8888
9201
|
maxFrequency: 2
|
|
8889
9202
|
});
|
|
8890
|
-
|
|
9203
|
+
scheduleTask10(ctx, async () => {
|
|
8891
9204
|
const subscriptions = new SubscriptionList4();
|
|
8892
9205
|
ctx.onDispose(() => subscriptions.clear());
|
|
8893
9206
|
const subscribeToSpaceAndUpdate = () => {
|
|
@@ -8912,9 +9225,9 @@ var ContactsServiceImpl = class {
|
|
|
8912
9225
|
|
|
8913
9226
|
// src/packlets/logging/logging-service.ts
|
|
8914
9227
|
import { Event as Event10 } from "@dxos/async";
|
|
8915
|
-
import { Stream as
|
|
9228
|
+
import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
|
|
8916
9229
|
import { PublicKey as PublicKey18 } from "@dxos/keys";
|
|
8917
|
-
import { getContextFromEntry, log as
|
|
9230
|
+
import { getContextFromEntry, log as log24 } from "@dxos/log";
|
|
8918
9231
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
8919
9232
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
8920
9233
|
var LoggingServiceImpl = class {
|
|
@@ -8922,11 +9235,11 @@ var LoggingServiceImpl = class {
|
|
|
8922
9235
|
_started = Date.now();
|
|
8923
9236
|
_sessionId = PublicKey18.random().toHex();
|
|
8924
9237
|
async open() {
|
|
8925
|
-
|
|
9238
|
+
log24.runtimeConfig.processors.push(this._logProcessor);
|
|
8926
9239
|
}
|
|
8927
9240
|
async close() {
|
|
8928
|
-
const index =
|
|
8929
|
-
|
|
9241
|
+
const index = log24.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
9242
|
+
log24.runtimeConfig.processors.splice(index, 1);
|
|
8930
9243
|
}
|
|
8931
9244
|
async controlMetrics({ reset, record }) {
|
|
8932
9245
|
if (reset) {
|
|
@@ -8952,7 +9265,7 @@ var LoggingServiceImpl = class {
|
|
|
8952
9265
|
stats: numericalValues(events, "duration")
|
|
8953
9266
|
};
|
|
8954
9267
|
};
|
|
8955
|
-
return new
|
|
9268
|
+
return new Stream13(({ next }) => {
|
|
8956
9269
|
const update = () => {
|
|
8957
9270
|
const metrics2 = {
|
|
8958
9271
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -8974,7 +9287,7 @@ var LoggingServiceImpl = class {
|
|
|
8974
9287
|
});
|
|
8975
9288
|
}
|
|
8976
9289
|
queryLogs(request) {
|
|
8977
|
-
return new
|
|
9290
|
+
return new Stream13(({ ctx, next }) => {
|
|
8978
9291
|
const handler = (entry2) => {
|
|
8979
9292
|
if (LOG_PROCESSING > 0) {
|
|
8980
9293
|
return;
|
|
@@ -9034,7 +9347,7 @@ var shouldLog = (entry2, request) => {
|
|
|
9034
9347
|
var LOG_PROCESSING = 0;
|
|
9035
9348
|
|
|
9036
9349
|
// src/packlets/network/network-service.ts
|
|
9037
|
-
import { Stream as
|
|
9350
|
+
import { Stream as Stream14 } from "@dxos/codec-protobuf/stream";
|
|
9038
9351
|
var NetworkServiceImpl = class {
|
|
9039
9352
|
networkManager;
|
|
9040
9353
|
signalManager;
|
|
@@ -9045,7 +9358,7 @@ var NetworkServiceImpl = class {
|
|
|
9045
9358
|
this.edgeConnection = edgeConnection;
|
|
9046
9359
|
}
|
|
9047
9360
|
queryStatus() {
|
|
9048
|
-
return new
|
|
9361
|
+
return new Stream14(({ ctx, next }) => {
|
|
9049
9362
|
const update = () => {
|
|
9050
9363
|
next({
|
|
9051
9364
|
swarm: this.networkManager.connectionState,
|
|
@@ -9074,7 +9387,7 @@ var NetworkServiceImpl = class {
|
|
|
9074
9387
|
return this.signalManager.query(request);
|
|
9075
9388
|
}
|
|
9076
9389
|
subscribeSwarmState(request) {
|
|
9077
|
-
return new
|
|
9390
|
+
return new Stream14(({ ctx, next }) => {
|
|
9078
9391
|
this.signalManager.swarmState?.on(ctx, (state) => {
|
|
9079
9392
|
if (request.topic.equals(state.swarmKey)) {
|
|
9080
9393
|
next(state);
|
|
@@ -9086,7 +9399,7 @@ var NetworkServiceImpl = class {
|
|
|
9086
9399
|
return this.signalManager.sendMessage(message);
|
|
9087
9400
|
}
|
|
9088
9401
|
subscribeMessages(peer) {
|
|
9089
|
-
return new
|
|
9402
|
+
return new Stream14(({ ctx, next }) => {
|
|
9090
9403
|
this.signalManager.onMessage.on(ctx, (message) => {
|
|
9091
9404
|
if (message.recipient.peerKey === peer.peerKey) {
|
|
9092
9405
|
next(message);
|
|
@@ -9097,7 +9410,7 @@ var NetworkServiceImpl = class {
|
|
|
9097
9410
|
};
|
|
9098
9411
|
|
|
9099
9412
|
// src/packlets/system/system-service.ts
|
|
9100
|
-
import { Stream as
|
|
9413
|
+
import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
|
|
9101
9414
|
import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
9102
9415
|
import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
|
|
9103
9416
|
var SystemServiceImpl = class {
|
|
@@ -9139,7 +9452,7 @@ var SystemServiceImpl = class {
|
|
|
9139
9452
|
}
|
|
9140
9453
|
// TODO(burdon): Standardize interval option in stream request?
|
|
9141
9454
|
queryStatus({ interval = 3e3 } = {}) {
|
|
9142
|
-
return new
|
|
9455
|
+
return new Stream15(({ next }) => {
|
|
9143
9456
|
const update = () => {
|
|
9144
9457
|
next({
|
|
9145
9458
|
status: this._getCurrentStatus()
|
|
@@ -9160,13 +9473,13 @@ var SystemServiceImpl = class {
|
|
|
9160
9473
|
};
|
|
9161
9474
|
|
|
9162
9475
|
// src/packlets/services/service-host.ts
|
|
9163
|
-
function
|
|
9476
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
9164
9477
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9165
9478
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9166
9479
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
9167
9480
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9168
9481
|
}
|
|
9169
|
-
var
|
|
9482
|
+
var __dxlog_file30 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
9170
9483
|
var ClientServicesHost = class {
|
|
9171
9484
|
_resourceLock;
|
|
9172
9485
|
_serviceRegistry;
|
|
@@ -9184,7 +9497,8 @@ var ClientServicesHost = class {
|
|
|
9184
9497
|
_edgeConnection = void 0;
|
|
9185
9498
|
_edgeHttpClient = void 0;
|
|
9186
9499
|
_serviceContext;
|
|
9187
|
-
|
|
9500
|
+
_runtime;
|
|
9501
|
+
_runtimeProps;
|
|
9188
9502
|
diagnosticsBroadcastHandler;
|
|
9189
9503
|
_opening = false;
|
|
9190
9504
|
_open = false;
|
|
@@ -9198,18 +9512,14 @@ var ClientServicesHost = class {
|
|
|
9198
9512
|
// TODO(wittjosiah): Turn this on by default.
|
|
9199
9513
|
lockKey,
|
|
9200
9514
|
callbacks,
|
|
9201
|
-
|
|
9202
|
-
|
|
9515
|
+
runtime,
|
|
9516
|
+
runtimeProps
|
|
9517
|
+
}) {
|
|
9203
9518
|
this._storage = storage;
|
|
9204
9519
|
this._level = level;
|
|
9205
9520
|
this._callbacks = callbacks;
|
|
9206
|
-
this.
|
|
9207
|
-
|
|
9208
|
-
this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
|
|
9209
|
-
}
|
|
9210
|
-
if (this._runtimeParams.enableVectorIndexing === void 0) {
|
|
9211
|
-
this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
|
|
9212
|
-
}
|
|
9521
|
+
this._runtime = runtime;
|
|
9522
|
+
this._runtimeProps = runtimeProps ?? {};
|
|
9213
9523
|
if (config) {
|
|
9214
9524
|
this.initialize({
|
|
9215
9525
|
config,
|
|
@@ -9218,13 +9528,13 @@ var ClientServicesHost = class {
|
|
|
9218
9528
|
});
|
|
9219
9529
|
}
|
|
9220
9530
|
if (lockKey) {
|
|
9221
|
-
this._resourceLock = new Lock({
|
|
9531
|
+
this._resourceLock = new locks_exports.Lock({
|
|
9222
9532
|
lockKey,
|
|
9223
9533
|
onAcquire: () => {
|
|
9224
9534
|
if (!this._opening) {
|
|
9225
9535
|
void this.open(new Context11(void 0, {
|
|
9226
|
-
F:
|
|
9227
|
-
L:
|
|
9536
|
+
F: __dxlog_file30,
|
|
9537
|
+
L: 147
|
|
9228
9538
|
}));
|
|
9229
9539
|
}
|
|
9230
9540
|
},
|
|
@@ -9249,7 +9559,7 @@ var ClientServicesHost = class {
|
|
|
9249
9559
|
await this.reset();
|
|
9250
9560
|
}
|
|
9251
9561
|
});
|
|
9252
|
-
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
9562
|
+
this.diagnosticsBroadcastHandler = (0, diagnostics_exports.createCollectDiagnosticsBroadcastHandler)(this._systemService);
|
|
9253
9563
|
this._loggingService = new LoggingServiceImpl();
|
|
9254
9564
|
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
9255
9565
|
SystemService: this._systemService,
|
|
@@ -9275,30 +9585,54 @@ var ClientServicesHost = class {
|
|
|
9275
9585
|
return this._serviceRegistry.services;
|
|
9276
9586
|
}
|
|
9277
9587
|
/**
|
|
9588
|
+
* Debugging util.
|
|
9589
|
+
*/
|
|
9590
|
+
async exportSqliteDatabase() {
|
|
9591
|
+
return await RuntimeProvider2.runPromise(this._runtime)(Effect2.gen(function* () {
|
|
9592
|
+
const sql = yield* SqlExport.SqlExport;
|
|
9593
|
+
return yield* sql.export;
|
|
9594
|
+
}));
|
|
9595
|
+
}
|
|
9596
|
+
/**
|
|
9597
|
+
* Debugging util.
|
|
9598
|
+
*/
|
|
9599
|
+
async runSqliteQuery(query, params) {
|
|
9600
|
+
return await RuntimeProvider2.runPromise(this._runtime)(Effect2.gen(function* () {
|
|
9601
|
+
const sql = yield* SqlClient.SqlClient;
|
|
9602
|
+
return yield* sql`${sql.unsafe(query, params)}`;
|
|
9603
|
+
}));
|
|
9604
|
+
}
|
|
9605
|
+
/**
|
|
9278
9606
|
* Initialize the service host with the config.
|
|
9279
9607
|
* Config can also be provided in the constructor.
|
|
9280
9608
|
* Can only be called once.
|
|
9281
9609
|
*/
|
|
9282
9610
|
initialize({ config, ...options }) {
|
|
9283
|
-
|
|
9284
|
-
F:
|
|
9285
|
-
L:
|
|
9611
|
+
invariant25(!this._open, "service host is open", {
|
|
9612
|
+
F: __dxlog_file30,
|
|
9613
|
+
L: 237,
|
|
9286
9614
|
S: this,
|
|
9287
9615
|
A: [
|
|
9288
9616
|
"!this._open",
|
|
9289
9617
|
"'service host is open'"
|
|
9290
9618
|
]
|
|
9291
9619
|
});
|
|
9292
|
-
|
|
9293
|
-
F:
|
|
9294
|
-
L:
|
|
9620
|
+
log25("initializing...", void 0, {
|
|
9621
|
+
F: __dxlog_file30,
|
|
9622
|
+
L: 238,
|
|
9295
9623
|
S: this,
|
|
9296
9624
|
C: (f, a) => f(...a)
|
|
9297
9625
|
});
|
|
9298
9626
|
if (config) {
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9627
|
+
if (this._runtimeProps.disableP2pReplication === void 0) {
|
|
9628
|
+
this._runtimeProps.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
|
|
9629
|
+
}
|
|
9630
|
+
if (this._runtimeProps.enableVectorIndexing === void 0) {
|
|
9631
|
+
this._runtimeProps.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
|
|
9632
|
+
}
|
|
9633
|
+
invariant25(!this._config, "config already set", {
|
|
9634
|
+
F: __dxlog_file30,
|
|
9635
|
+
L: 248,
|
|
9302
9636
|
S: this,
|
|
9303
9637
|
A: [
|
|
9304
9638
|
"!this._config",
|
|
@@ -9325,9 +9659,9 @@ var ClientServicesHost = class {
|
|
|
9325
9659
|
edgeConnection: this._edgeConnection
|
|
9326
9660
|
}) : new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
9327
9661
|
this._signalManager = signalManager;
|
|
9328
|
-
|
|
9329
|
-
F:
|
|
9330
|
-
L:
|
|
9662
|
+
invariant25(!this._networkManager, "network manager already set", {
|
|
9663
|
+
F: __dxlog_file30,
|
|
9664
|
+
L: 279,
|
|
9331
9665
|
S: this,
|
|
9332
9666
|
A: [
|
|
9333
9667
|
"!this._networkManager",
|
|
@@ -9343,9 +9677,9 @@ var ClientServicesHost = class {
|
|
|
9343
9677
|
peerKey: this._edgeConnection.peerKey
|
|
9344
9678
|
} : void 0
|
|
9345
9679
|
});
|
|
9346
|
-
|
|
9347
|
-
F:
|
|
9348
|
-
L:
|
|
9680
|
+
log25("initialized", void 0, {
|
|
9681
|
+
F: __dxlog_file30,
|
|
9682
|
+
L: 292,
|
|
9349
9683
|
S: this,
|
|
9350
9684
|
C: (f, a) => f(...a)
|
|
9351
9685
|
});
|
|
@@ -9355,44 +9689,44 @@ var ClientServicesHost = class {
|
|
|
9355
9689
|
return;
|
|
9356
9690
|
}
|
|
9357
9691
|
const traceId = PublicKey19.random().toHex();
|
|
9358
|
-
|
|
9692
|
+
log25.trace("dxos.client-services.host.open", trace10.begin({
|
|
9359
9693
|
id: traceId
|
|
9360
9694
|
}), {
|
|
9361
|
-
F:
|
|
9362
|
-
L:
|
|
9695
|
+
F: __dxlog_file30,
|
|
9696
|
+
L: 303,
|
|
9363
9697
|
S: this,
|
|
9364
9698
|
C: (f, a) => f(...a)
|
|
9365
9699
|
});
|
|
9366
|
-
|
|
9367
|
-
F:
|
|
9368
|
-
L:
|
|
9700
|
+
invariant25(this._config, "config not set", {
|
|
9701
|
+
F: __dxlog_file30,
|
|
9702
|
+
L: 305,
|
|
9369
9703
|
S: this,
|
|
9370
9704
|
A: [
|
|
9371
9705
|
"this._config",
|
|
9372
9706
|
"'config not set'"
|
|
9373
9707
|
]
|
|
9374
9708
|
});
|
|
9375
|
-
|
|
9376
|
-
F:
|
|
9377
|
-
L:
|
|
9709
|
+
invariant25(this._storage, "storage not set", {
|
|
9710
|
+
F: __dxlog_file30,
|
|
9711
|
+
L: 306,
|
|
9378
9712
|
S: this,
|
|
9379
9713
|
A: [
|
|
9380
9714
|
"this._storage",
|
|
9381
9715
|
"'storage not set'"
|
|
9382
9716
|
]
|
|
9383
9717
|
});
|
|
9384
|
-
|
|
9385
|
-
F:
|
|
9386
|
-
L:
|
|
9718
|
+
invariant25(this._signalManager, "signal manager not set", {
|
|
9719
|
+
F: __dxlog_file30,
|
|
9720
|
+
L: 307,
|
|
9387
9721
|
S: this,
|
|
9388
9722
|
A: [
|
|
9389
9723
|
"this._signalManager",
|
|
9390
9724
|
"'signal manager not set'"
|
|
9391
9725
|
]
|
|
9392
9726
|
});
|
|
9393
|
-
|
|
9394
|
-
F:
|
|
9395
|
-
L:
|
|
9727
|
+
invariant25(this._networkManager, "network manager not set", {
|
|
9728
|
+
F: __dxlog_file30,
|
|
9729
|
+
L: 308,
|
|
9396
9730
|
S: this,
|
|
9397
9731
|
A: [
|
|
9398
9732
|
"this._networkManager",
|
|
@@ -9400,11 +9734,11 @@ var ClientServicesHost = class {
|
|
|
9400
9734
|
]
|
|
9401
9735
|
});
|
|
9402
9736
|
this._opening = true;
|
|
9403
|
-
|
|
9737
|
+
log25("opening...", {
|
|
9404
9738
|
lockKey: this._resourceLock?.lockKey
|
|
9405
9739
|
}, {
|
|
9406
|
-
F:
|
|
9407
|
-
L:
|
|
9740
|
+
F: __dxlog_file30,
|
|
9741
|
+
L: 311,
|
|
9408
9742
|
S: this,
|
|
9409
9743
|
C: (f, a) => f(...a)
|
|
9410
9744
|
});
|
|
@@ -9414,7 +9748,7 @@ var ClientServicesHost = class {
|
|
|
9414
9748
|
}
|
|
9415
9749
|
await this._level.open();
|
|
9416
9750
|
await this._loggingService.open();
|
|
9417
|
-
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._edgeHttpClient, this.
|
|
9751
|
+
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._edgeHttpClient, this._runtime, this._runtimeProps, this._config.get("runtime.client.edgeFeatures"));
|
|
9418
9752
|
const dataSpaceManagerProvider = async () => {
|
|
9419
9753
|
await this._serviceContext.initialized.wait();
|
|
9420
9754
|
return this._serviceContext.dataSpaceManager;
|
|
@@ -9433,6 +9767,7 @@ var ClientServicesHost = class {
|
|
|
9433
9767
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
|
|
9434
9768
|
DataService: this._serviceContext.echoHost.dataService,
|
|
9435
9769
|
QueryService: this._serviceContext.echoHost.queryService,
|
|
9770
|
+
QueueService: this._serviceContext.echoHost.queuesService,
|
|
9436
9771
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager, this._edgeConnection),
|
|
9437
9772
|
LoggingService: this._loggingService,
|
|
9438
9773
|
TracingService: this._tracingService,
|
|
@@ -9444,8 +9779,32 @@ var ClientServicesHost = class {
|
|
|
9444
9779
|
}),
|
|
9445
9780
|
EdgeAgentService: new EdgeAgentServiceImpl(agentManagerProvider, this._edgeConnection)
|
|
9446
9781
|
});
|
|
9782
|
+
log25("service-host: opening service context...", void 0, {
|
|
9783
|
+
F: __dxlog_file30,
|
|
9784
|
+
L: 395,
|
|
9785
|
+
S: this,
|
|
9786
|
+
C: (f, a) => f(...a)
|
|
9787
|
+
});
|
|
9447
9788
|
await this._serviceContext.open(ctx);
|
|
9789
|
+
log25("service-host: service context opened", void 0, {
|
|
9790
|
+
F: __dxlog_file30,
|
|
9791
|
+
L: 397,
|
|
9792
|
+
S: this,
|
|
9793
|
+
C: (f, a) => f(...a)
|
|
9794
|
+
});
|
|
9795
|
+
log25("service-host: opening identity service...", void 0, {
|
|
9796
|
+
F: __dxlog_file30,
|
|
9797
|
+
L: 399,
|
|
9798
|
+
S: this,
|
|
9799
|
+
C: (f, a) => f(...a)
|
|
9800
|
+
});
|
|
9448
9801
|
await identityService.open();
|
|
9802
|
+
log25("service-host: identity service opened", void 0, {
|
|
9803
|
+
F: __dxlog_file30,
|
|
9804
|
+
L: 401,
|
|
9805
|
+
S: this,
|
|
9806
|
+
C: (f, a) => f(...a)
|
|
9807
|
+
});
|
|
9449
9808
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
9450
9809
|
if (devtoolsProxy) {
|
|
9451
9810
|
this._devtoolsProxy = new WebsocketRpcClient({
|
|
@@ -9461,19 +9820,19 @@ var ClientServicesHost = class {
|
|
|
9461
9820
|
this._open = true;
|
|
9462
9821
|
this._statusUpdate.emit();
|
|
9463
9822
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
9464
|
-
|
|
9823
|
+
log25("opened", {
|
|
9465
9824
|
deviceKey
|
|
9466
9825
|
}, {
|
|
9467
|
-
F:
|
|
9468
|
-
L:
|
|
9826
|
+
F: __dxlog_file30,
|
|
9827
|
+
L: 419,
|
|
9469
9828
|
S: this,
|
|
9470
9829
|
C: (f, a) => f(...a)
|
|
9471
9830
|
});
|
|
9472
|
-
|
|
9831
|
+
log25.trace("dxos.client-services.host.open", trace10.end({
|
|
9473
9832
|
id: traceId
|
|
9474
9833
|
}), {
|
|
9475
|
-
F:
|
|
9476
|
-
L:
|
|
9834
|
+
F: __dxlog_file30,
|
|
9835
|
+
L: 420,
|
|
9477
9836
|
S: this,
|
|
9478
9837
|
C: (f, a) => f(...a)
|
|
9479
9838
|
});
|
|
@@ -9483,11 +9842,11 @@ var ClientServicesHost = class {
|
|
|
9483
9842
|
return;
|
|
9484
9843
|
}
|
|
9485
9844
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
9486
|
-
|
|
9845
|
+
log25("closing...", {
|
|
9487
9846
|
deviceKey
|
|
9488
9847
|
}, {
|
|
9489
|
-
F:
|
|
9490
|
-
L:
|
|
9848
|
+
F: __dxlog_file30,
|
|
9849
|
+
L: 431,
|
|
9491
9850
|
S: this,
|
|
9492
9851
|
C: (f, a) => f(...a)
|
|
9493
9852
|
});
|
|
@@ -9501,28 +9860,28 @@ var ClientServicesHost = class {
|
|
|
9501
9860
|
await this._level?.close();
|
|
9502
9861
|
this._open = false;
|
|
9503
9862
|
this._statusUpdate.emit();
|
|
9504
|
-
|
|
9863
|
+
log25("closed", {
|
|
9505
9864
|
deviceKey
|
|
9506
9865
|
}, {
|
|
9507
|
-
F:
|
|
9508
|
-
L:
|
|
9866
|
+
F: __dxlog_file30,
|
|
9867
|
+
L: 440,
|
|
9509
9868
|
S: this,
|
|
9510
9869
|
C: (f, a) => f(...a)
|
|
9511
9870
|
});
|
|
9512
9871
|
}
|
|
9513
9872
|
async reset() {
|
|
9514
9873
|
const traceId = PublicKey19.random().toHex();
|
|
9515
|
-
|
|
9874
|
+
log25.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
9516
9875
|
id: traceId
|
|
9517
9876
|
}), {
|
|
9518
|
-
F:
|
|
9519
|
-
L:
|
|
9877
|
+
F: __dxlog_file30,
|
|
9878
|
+
L: 445,
|
|
9520
9879
|
S: this,
|
|
9521
9880
|
C: (f, a) => f(...a)
|
|
9522
9881
|
});
|
|
9523
|
-
|
|
9524
|
-
F:
|
|
9525
|
-
L:
|
|
9882
|
+
log25.info("resetting...", void 0, {
|
|
9883
|
+
F: __dxlog_file30,
|
|
9884
|
+
L: 447,
|
|
9526
9885
|
S: this,
|
|
9527
9886
|
C: (f, a) => f(...a)
|
|
9528
9887
|
});
|
|
@@ -9532,27 +9891,27 @@ var ClientServicesHost = class {
|
|
|
9532
9891
|
try {
|
|
9533
9892
|
await this._level.clear();
|
|
9534
9893
|
} catch (err) {
|
|
9535
|
-
|
|
9894
|
+
log25.warn("failed to clear leveldb during reset", {
|
|
9536
9895
|
err
|
|
9537
9896
|
}, {
|
|
9538
|
-
F:
|
|
9539
|
-
L:
|
|
9897
|
+
F: __dxlog_file30,
|
|
9898
|
+
L: 457,
|
|
9540
9899
|
S: this,
|
|
9541
9900
|
C: (f, a) => f(...a)
|
|
9542
9901
|
});
|
|
9543
9902
|
}
|
|
9544
9903
|
await this._storage.reset();
|
|
9545
|
-
|
|
9546
|
-
F:
|
|
9547
|
-
L:
|
|
9904
|
+
log25.info("reset", void 0, {
|
|
9905
|
+
F: __dxlog_file30,
|
|
9906
|
+
L: 460,
|
|
9548
9907
|
S: this,
|
|
9549
9908
|
C: (f, a) => f(...a)
|
|
9550
9909
|
});
|
|
9551
|
-
|
|
9910
|
+
log25.trace("dxos.sdk.client-services-host.reset", trace10.end({
|
|
9552
9911
|
id: traceId
|
|
9553
9912
|
}), {
|
|
9554
|
-
F:
|
|
9555
|
-
L:
|
|
9913
|
+
F: __dxlog_file30,
|
|
9914
|
+
L: 461,
|
|
9556
9915
|
S: this,
|
|
9557
9916
|
C: (f, a) => f(...a)
|
|
9558
9917
|
});
|
|
@@ -9564,24 +9923,24 @@ var ClientServicesHost = class {
|
|
|
9564
9923
|
return identity;
|
|
9565
9924
|
}
|
|
9566
9925
|
};
|
|
9567
|
-
|
|
9926
|
+
_ts_decorate9([
|
|
9568
9927
|
Trace4.info()
|
|
9569
9928
|
], ClientServicesHost.prototype, "_opening", void 0);
|
|
9570
|
-
|
|
9929
|
+
_ts_decorate9([
|
|
9571
9930
|
Trace4.info()
|
|
9572
9931
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
9573
|
-
|
|
9932
|
+
_ts_decorate9([
|
|
9574
9933
|
Trace4.info()
|
|
9575
9934
|
], ClientServicesHost.prototype, "_resetting", void 0);
|
|
9576
|
-
|
|
9935
|
+
_ts_decorate9([
|
|
9577
9936
|
synchronized4,
|
|
9578
9937
|
Trace4.span()
|
|
9579
9938
|
], ClientServicesHost.prototype, "open", null);
|
|
9580
|
-
|
|
9939
|
+
_ts_decorate9([
|
|
9581
9940
|
synchronized4,
|
|
9582
9941
|
Trace4.span()
|
|
9583
9942
|
], ClientServicesHost.prototype, "close", null);
|
|
9584
|
-
ClientServicesHost =
|
|
9943
|
+
ClientServicesHost = _ts_decorate9([
|
|
9585
9944
|
Trace4.resource()
|
|
9586
9945
|
], ClientServicesHost);
|
|
9587
9946
|
|
|
@@ -9597,9 +9956,8 @@ export {
|
|
|
9597
9956
|
DevtoolsHostEvents,
|
|
9598
9957
|
DevtoolsServiceImpl,
|
|
9599
9958
|
createDiagnostics,
|
|
9600
|
-
createCollectDiagnosticsBroadcastSender,
|
|
9601
|
-
createCollectDiagnosticsBroadcastHandler,
|
|
9602
9959
|
DiagnosticsCollector,
|
|
9960
|
+
diagnostics_exports,
|
|
9603
9961
|
createAuthProvider,
|
|
9604
9962
|
TrustedKeySetAuthVerifier,
|
|
9605
9963
|
EdgeFeedReplicator,
|
|
@@ -9615,19 +9973,13 @@ export {
|
|
|
9615
9973
|
InvitationsServiceImpl,
|
|
9616
9974
|
SpaceInvitationProtocol,
|
|
9617
9975
|
InvitationsManager,
|
|
9618
|
-
|
|
9619
|
-
isLocked,
|
|
9620
|
-
ClientRpcServer,
|
|
9976
|
+
locks_exports,
|
|
9621
9977
|
EdgeAgentManager,
|
|
9622
9978
|
EdgeAgentServiceImpl,
|
|
9623
9979
|
ServiceContext,
|
|
9624
9980
|
createStorageObjects,
|
|
9625
9981
|
createLevel,
|
|
9626
|
-
encodeProfileArchive,
|
|
9627
|
-
decodeProfileArchive,
|
|
9628
|
-
exportProfileData,
|
|
9629
|
-
importProfileData,
|
|
9630
9982
|
ServiceRegistry,
|
|
9631
9983
|
ClientServicesHost
|
|
9632
9984
|
};
|
|
9633
|
-
//# sourceMappingURL=chunk-
|
|
9985
|
+
//# sourceMappingURL=chunk-6ONWVRY5.mjs.map
|