@dxos/client-services 0.10.0 → 0.11.0
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/chunk-client-services-layer.mjs +11425 -0
- package/dist/lib/chunk-client-services-layer.mjs.map +1 -0
- package/dist/lib/chunk-decorate.mjs +9 -0
- package/dist/lib/index.mjs +731 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/packlets/diagnostics/browser-diagnostics-broadcast.mjs +72 -0
- package/dist/lib/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +1 -0
- package/dist/lib/packlets/diagnostics/diagnostics-broadcast.mjs +14 -0
- package/dist/lib/packlets/diagnostics/diagnostics-broadcast.mjs.map +1 -0
- package/dist/lib/packlets/locks/browser.mjs +105 -0
- package/dist/lib/packlets/locks/browser.mjs.map +1 -0
- package/dist/lib/packlets/locks/node.mjs +53 -0
- package/dist/lib/packlets/locks/node.mjs.map +1 -0
- package/dist/lib/testing.mjs +570 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts +21 -4
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts +8 -7
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts +7 -5
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +30 -29
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
- package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts +2 -1
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/spaces.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +2 -2
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts +1 -8
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts +9 -6
- package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +32 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +23 -4
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +15 -20
- package/dist/types/src/packlets/identity/identity-service.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/edge-invitation-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +17 -0
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +25 -4
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +11 -11
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +14 -12
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/metadata/index.d.ts +3 -0
- package/dist/types/src/packlets/metadata/index.d.ts.map +1 -0
- package/dist/types/src/packlets/metadata/metadata-store.d.ts +107 -0
- package/dist/types/src/packlets/metadata/metadata-store.d.ts.map +1 -0
- package/dist/types/src/packlets/metadata/metadata-store.test.d.ts +2 -0
- package/dist/types/src/packlets/metadata/metadata-store.test.d.ts.map +1 -0
- package/dist/types/src/packlets/metadata/sqlite-metadata-store.d.ts +65 -0
- package/dist/types/src/packlets/metadata/sqlite-metadata-store.d.ts.map +1 -0
- package/dist/types/src/packlets/network/network-service.d.ts +15 -14
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/pipeline/codec.d.ts +11 -0
- package/dist/types/src/packlets/pipeline/codec.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/feeds.d.ts +7 -0
- package/dist/types/src/packlets/pipeline/feeds.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/index.d.ts +5 -0
- package/dist/types/src/packlets/pipeline/index.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/message-selector.d.ts +11 -0
- package/dist/types/src/packlets/pipeline/message-selector.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/pipeline-stress.test.d.ts +2 -0
- package/dist/types/src/packlets/pipeline/pipeline-stress.test.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/pipeline.d.ts +131 -0
- package/dist/types/src/packlets/pipeline/pipeline.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/pipeline.test.d.ts +2 -0
- package/dist/types/src/packlets/pipeline/pipeline.test.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/testing/index.d.ts +2 -0
- package/dist/types/src/packlets/pipeline/testing/index.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/testing/test-feed-builder.d.ts +9 -0
- package/dist/types/src/packlets/pipeline/testing/test-feed-builder.d.ts.map +1 -0
- package/dist/types/src/packlets/pipeline/timeframe-clock.d.ts +31 -0
- package/dist/types/src/packlets/pipeline/timeframe-clock.d.ts.map +1 -0
- package/dist/types/src/packlets/services/client-services-layer.d.ts +21 -0
- package/dist/types/src/packlets/services/client-services-layer.d.ts.map +1 -0
- package/dist/types/src/packlets/services/cross-device-space-synchronizer.d.ts +28 -0
- package/dist/types/src/packlets/services/cross-device-space-synchronizer.d.ts.map +1 -0
- package/dist/types/src/packlets/services/effect-rpc.test.d.ts +2 -0
- package/dist/types/src/packlets/services/effect-rpc.test.d.ts.map +1 -0
- package/dist/types/src/packlets/services/feed-syncer.d.ts +22 -2
- package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +2 -2
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +38 -57
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +82 -31
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/sqlite-storage.d.ts +29 -0
- package/dist/types/src/packlets/services/sqlite-storage.d.ts.map +1 -1
- package/dist/types/src/packlets/services/sqlite-storage.test.d.ts +2 -0
- package/dist/types/src/packlets/services/sqlite-storage.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/admission-discovery-extension.d.ts +30 -0
- package/dist/types/src/packlets/space/admission-discovery-extension.d.ts.map +1 -0
- package/dist/types/src/packlets/space/auth.d.ts +24 -0
- package/dist/types/src/packlets/space/auth.d.ts.map +1 -0
- package/dist/types/src/packlets/space/control-pipeline.d.ts +46 -0
- package/dist/types/src/packlets/space/control-pipeline.d.ts.map +1 -0
- package/dist/types/src/packlets/space/control-pipeline.test.d.ts +2 -0
- package/dist/types/src/packlets/space/control-pipeline.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/index.d.ts +6 -0
- package/dist/types/src/packlets/space/index.d.ts.map +1 -0
- package/dist/types/src/packlets/space/replication.browser.test.d.ts +2 -0
- package/dist/types/src/packlets/space/replication.browser.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space-manager.browser.test.d.ts +2 -0
- package/dist/types/src/packlets/space/space-manager.browser.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space-manager.d.ts +72 -0
- package/dist/types/src/packlets/space/space-manager.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space-protocol.browser.test.d.ts +2 -0
- package/dist/types/src/packlets/space/space-protocol.browser.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space-protocol.d.ts +99 -0
- package/dist/types/src/packlets/space/space-protocol.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space-protocol.test.d.ts +2 -0
- package/dist/types/src/packlets/space/space-protocol.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space.d.ts +65 -0
- package/dist/types/src/packlets/space/space.d.ts.map +1 -0
- package/dist/types/src/packlets/space/space.test.d.ts +2 -0
- package/dist/types/src/packlets/space/space.test.d.ts.map +1 -0
- package/dist/types/src/packlets/space/testing/change-metadata.d.ts +8 -0
- package/dist/types/src/packlets/space/testing/change-metadata.d.ts.map +1 -0
- package/dist/types/src/packlets/space/testing/index.d.ts +4 -0
- package/dist/types/src/packlets/space/testing/index.d.ts.map +1 -0
- package/dist/types/src/packlets/space/testing/test-agent-builder.d.ts +62 -0
- package/dist/types/src/packlets/space/testing/test-agent-builder.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts +1 -1
- package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/serialized-space-writer.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +40 -7
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +3 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +25 -23
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +18 -18
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +7 -6
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-runtime.d.ts +41 -58
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-session.d.ts +21 -8
- package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +52 -48
- package/src/index.ts +2 -0
- package/src/packlets/agents/edge-agent-manager.ts +56 -15
- package/src/packlets/agents/edge-agent-service.ts +25 -15
- package/src/packlets/devices/devices-service.test.ts +20 -19
- package/src/packlets/devices/devices-service.ts +17 -17
- package/src/packlets/devtools/devtools.ts +133 -75
- package/src/packlets/devtools/feeds.ts +2 -1
- package/src/packlets/devtools/network.ts +42 -12
- package/src/packlets/devtools/spaces.ts +1 -1
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +4 -2
- package/src/packlets/diagnostics/diagnostics-collector.ts +5 -18
- package/src/packlets/diagnostics/diagnostics.ts +0 -11
- package/src/packlets/identity/authenticator.ts +2 -1
- package/src/packlets/identity/contacts-service.ts +46 -37
- package/src/packlets/identity/identity-manager.test.ts +3 -1
- package/src/packlets/identity/identity-manager.ts +73 -5
- package/src/packlets/identity/identity-recovery-manager.ts +56 -7
- package/src/packlets/identity/identity-service.test.ts +27 -18
- package/src/packlets/identity/identity-service.ts +114 -71
- package/src/packlets/identity/identity.test.ts +4 -9
- package/src/packlets/identity/identity.ts +1 -2
- package/src/packlets/invitations/edge-invitation-handler.ts +0 -1
- package/src/packlets/invitations/invitations-handler.ts +39 -3
- package/src/packlets/invitations/invitations-manager.ts +52 -4
- package/src/packlets/invitations/invitations-service.ts +54 -28
- package/src/packlets/logging/logging-service.ts +41 -29
- package/src/packlets/logging/logging.test.ts +28 -15
- package/src/packlets/metadata/index.ts +6 -0
- package/src/packlets/metadata/metadata-store.test.ts +49 -0
- package/src/packlets/metadata/metadata-store.ts +446 -0
- package/src/packlets/metadata/sqlite-metadata-store.ts +409 -0
- package/src/packlets/network/network-service.test.ts +19 -12
- package/src/packlets/network/network-service.ts +96 -29
- package/src/packlets/pipeline/codec.ts +18 -0
- package/src/packlets/pipeline/feeds.ts +22 -0
- package/src/packlets/pipeline/index.ts +8 -0
- package/src/packlets/pipeline/message-selector.ts +35 -0
- package/src/packlets/pipeline/pipeline-stress.test.ts +230 -0
- package/src/packlets/pipeline/pipeline.test.ts +140 -0
- package/src/packlets/pipeline/pipeline.ts +439 -0
- package/src/packlets/pipeline/testing/index.ts +5 -0
- package/src/packlets/pipeline/testing/test-feed-builder.ts +19 -0
- package/src/packlets/pipeline/timeframe-clock.ts +81 -0
- package/src/packlets/services/client-services-layer.ts +186 -0
- package/src/packlets/services/cross-device-space-synchronizer.ts +132 -0
- package/src/packlets/services/effect-rpc.test.ts +314 -0
- package/src/packlets/services/feed-syncer.ts +57 -3
- package/src/packlets/services/index.ts +2 -2
- package/src/packlets/services/platform.ts +0 -6
- package/src/packlets/services/service-context.ts +219 -522
- package/src/packlets/services/service-host.test.ts +34 -11
- package/src/packlets/services/service-host.ts +693 -213
- package/src/packlets/services/spec.md +106 -0
- package/src/packlets/services/sqlite-storage.test.ts +48 -0
- package/src/packlets/services/sqlite-storage.ts +117 -20
- package/src/packlets/space/admission-discovery-extension.ts +91 -0
- package/src/packlets/space/auth.ts +92 -0
- package/src/packlets/space/control-pipeline.test.ts +165 -0
- package/src/packlets/space/control-pipeline.ts +229 -0
- package/src/packlets/space/index.ts +9 -0
- package/src/packlets/space/replication.browser.test.ts +58 -0
- package/src/packlets/space/space-manager.browser.test.ts +40 -0
- package/src/packlets/space/space-manager.ts +224 -0
- package/src/packlets/space/space-protocol.browser.test.ts +129 -0
- package/src/packlets/space/space-protocol.test.ts +158 -0
- package/src/packlets/space/space-protocol.ts +308 -0
- package/src/packlets/space/space.test.ts +181 -0
- package/src/packlets/space/space.ts +196 -0
- package/src/packlets/space/testing/change-metadata.ts +27 -0
- package/src/packlets/space/testing/index.ts +7 -0
- package/src/packlets/space/testing/test-agent-builder.ts +252 -0
- package/src/packlets/space-export/serialized-space-reader.ts +3 -1
- package/src/packlets/space-export/serialized-space-writer.ts +53 -30
- package/src/packlets/space-export/space-archive.test.ts +30 -0
- package/src/packlets/spaces/data-space-manager.test.ts +1 -1
- package/src/packlets/spaces/data-space-manager.ts +148 -33
- package/src/packlets/spaces/data-space.ts +29 -18
- package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
- package/src/packlets/spaces/genesis.ts +1 -1
- package/src/packlets/spaces/spaces-service.test.ts +35 -22
- package/src/packlets/spaces/spaces-service.ts +259 -180
- package/src/packlets/storage/level.ts +3 -1
- package/src/packlets/system/system-service.test.ts +31 -13
- package/src/packlets/system/system-service.ts +65 -37
- package/src/packlets/testing/invitation-utils.ts +3 -3
- package/src/packlets/testing/test-builder.ts +35 -20
- package/src/packlets/worker/worker-runtime.ts +222 -260
- package/src/packlets/worker/worker-session.ts +108 -91
- package/src/testing/index.ts +1 -0
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-QCWEHHJW.mjs +0 -24
- package/dist/lib/browser/chunk-QCWEHHJW.mjs.map +0 -7
- package/dist/lib/browser/chunk-XJRPB3GA.mjs +0 -22
- package/dist/lib/browser/chunk-XJRPB3GA.mjs.map +0 -7
- package/dist/lib/browser/chunk-XU5R2BMF.mjs +0 -8837
- package/dist/lib/browser/chunk-XU5R2BMF.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -876
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs +0 -88
- package/dist/lib/browser/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +0 -7
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs +0 -11
- package/dist/lib/browser/packlets/diagnostics/diagnostics-broadcast.mjs.map +0 -7
- package/dist/lib/browser/packlets/locks/browser.mjs +0 -86
- package/dist/lib/browser/packlets/locks/browser.mjs.map +0 -7
- package/dist/lib/browser/packlets/locks/node.mjs +0 -48
- package/dist/lib/browser/packlets/locks/node.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -436
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2DT3MZRL.mjs +0 -22
- package/dist/lib/node-esm/chunk-2DT3MZRL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +0 -24
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-H5YTUD35.mjs +0 -8837
- package/dist/lib/node-esm/chunk-H5YTUD35.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -876
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs +0 -88
- package/dist/lib/node-esm/packlets/diagnostics/browser-diagnostics-broadcast.mjs.map +0 -7
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs +0 -11
- package/dist/lib/node-esm/packlets/diagnostics/diagnostics-broadcast.mjs.map +0 -7
- package/dist/lib/node-esm/packlets/locks/browser.mjs +0 -86
- package/dist/lib/node-esm/packlets/locks/browser.mjs.map +0 -7
- package/dist/lib/node-esm/packlets/locks/node.mjs +0 -48
- package/dist/lib/node-esm/packlets/locks/node.mjs.map +0 -7
- package/dist/lib/node-esm/testing/index.mjs +0 -436
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +0 -24
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +0 -1
- package/dist/types/src/packlets/services/service-registry.d.ts +0 -15
- package/dist/types/src/packlets/services/service-registry.d.ts.map +0 -1
- package/dist/types/src/packlets/services/service-registry.test.d.ts +0 -2
- package/dist/types/src/packlets/services/service-registry.test.d.ts.map +0 -1
- package/dist/types/src/testing/setup.d.ts +0 -3
- package/dist/types/src/testing/setup.d.ts.map +0 -1
- package/src/packlets/services/client-rpc-server.ts +0 -111
- package/src/packlets/services/service-registry.test.ts +0 -78
- package/src/packlets/services/service-registry.ts +0 -36
- package/src/testing/setup.ts +0 -11
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Doc } from '@automerge/automerge';
|
|
6
6
|
import { type AutomergeUrl, type DocumentId, interpretAsDocumentId } from '@automerge/automerge-repo';
|
|
7
|
+
import * as EffectContext from 'effect/Context';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Layer from 'effect/Layer';
|
|
10
|
+
import * as Option from 'effect/Option';
|
|
7
11
|
|
|
8
12
|
import { Event, synchronized, trackLeaks } from '@dxos/async';
|
|
9
13
|
import { SpaceProperties } from '@dxos/client-protocol';
|
|
@@ -17,24 +21,25 @@ import {
|
|
|
17
21
|
} from '@dxos/credentials';
|
|
18
22
|
import { Type } from '@dxos/echo';
|
|
19
23
|
import {
|
|
20
|
-
AuthStatus,
|
|
21
|
-
CredentialServerExtension,
|
|
22
24
|
DatabaseRoot,
|
|
23
25
|
type EchoHost,
|
|
26
|
+
EchoHostService,
|
|
24
27
|
type EdgeAutomergeReplicator,
|
|
25
|
-
|
|
28
|
+
EdgeAutomergeReplicatorService,
|
|
26
29
|
type MeshEchoReplicator,
|
|
27
|
-
|
|
28
|
-
type SpaceManager,
|
|
29
|
-
type SpaceProtocol,
|
|
30
|
-
type SpaceProtocolSession,
|
|
30
|
+
MeshEchoReplicatorService,
|
|
31
31
|
findInlineObjectOfType,
|
|
32
32
|
} from '@dxos/echo-host';
|
|
33
33
|
import { type DatabaseDirectory, createIdFromSpaceKey } from '@dxos/echo-protocol';
|
|
34
|
-
import
|
|
35
|
-
|
|
34
|
+
import {
|
|
35
|
+
type EdgeConnection,
|
|
36
|
+
EdgeConnectionService,
|
|
37
|
+
type EdgeHttpClient,
|
|
38
|
+
EdgeHttpClientService,
|
|
39
|
+
} from '@dxos/edge-client';
|
|
40
|
+
import { type FeedStore, FeedStoreService, writeMessages } from '@dxos/feed-store';
|
|
36
41
|
import { assertArgument, assertState, failedInvariant, invariant } from '@dxos/invariant';
|
|
37
|
-
import { type KeyringApi } from '@dxos/keyring';
|
|
42
|
+
import { type KeyringApi, KeyringApiService } from '@dxos/keyring';
|
|
38
43
|
import { PublicKey, type SpaceId } from '@dxos/keys';
|
|
39
44
|
import { log } from '@dxos/log';
|
|
40
45
|
import { AlreadyJoinedError } from '@dxos/protocols';
|
|
@@ -56,8 +61,18 @@ import { type Timeframe } from '@dxos/timeframe';
|
|
|
56
61
|
import { trace } from '@dxos/tracing';
|
|
57
62
|
import { ComplexMap, deferFunction, forEachAsync } from '@dxos/util';
|
|
58
63
|
|
|
59
|
-
import { createAuthProvider } from '../identity';
|
|
60
|
-
import { type InvitationsManager } from '../invitations';
|
|
64
|
+
import { type Identity, IdentityProviderService, createAuthProvider } from '../identity';
|
|
65
|
+
import { type InvitationsManager, InvitationsManagerService } from '../invitations';
|
|
66
|
+
import { type IMetadataStore, IMetadataStoreService } from '../metadata';
|
|
67
|
+
import {
|
|
68
|
+
AuthStatus,
|
|
69
|
+
CredentialServerExtension,
|
|
70
|
+
type Space,
|
|
71
|
+
type SpaceManager,
|
|
72
|
+
SpaceManagerService,
|
|
73
|
+
type SpaceProtocol,
|
|
74
|
+
type SpaceProtocolSession,
|
|
75
|
+
} from '../space';
|
|
61
76
|
import { DataSpace } from './data-space';
|
|
62
77
|
import { spaceGenesis } from './genesis';
|
|
63
78
|
|
|
@@ -73,6 +88,48 @@ export interface SigningContext {
|
|
|
73
88
|
getProfile: () => ProfileDocument | undefined;
|
|
74
89
|
}
|
|
75
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Resolves signing context when identity becomes available.
|
|
93
|
+
*/
|
|
94
|
+
export type SigningContextProvider = () => SigningContext;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Effect service tag for {@link SigningContextProvider}.
|
|
98
|
+
*/
|
|
99
|
+
export class SigningContextProviderService extends EffectContext.Tag('@dxos/client-services/SigningContextProvider')<
|
|
100
|
+
SigningContextProviderService,
|
|
101
|
+
SigningContextProvider
|
|
102
|
+
>() {}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Builds a {@link SigningContextProvider} from an identity resolver.
|
|
106
|
+
*/
|
|
107
|
+
export const createSigningContextProvider =
|
|
108
|
+
(getIdentity: () => Identity): SigningContextProvider =>
|
|
109
|
+
() => {
|
|
110
|
+
const identity = getIdentity();
|
|
111
|
+
return {
|
|
112
|
+
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
113
|
+
identityKey: identity.identityKey,
|
|
114
|
+
deviceKey: identity.deviceKey,
|
|
115
|
+
getProfile: () => identity.profileDocument,
|
|
116
|
+
recordCredential: async (credential) => {
|
|
117
|
+
await identity.controlPipeline.writer.write({ credential: { credential } });
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Effect Layer providing {@link SigningContextProvider} from {@link IdentityProviderService}.
|
|
124
|
+
*/
|
|
125
|
+
export const SigningContextProviderLayer = Layer.effect(
|
|
126
|
+
SigningContextProviderService,
|
|
127
|
+
Effect.gen(function* () {
|
|
128
|
+
const identityProvider = yield* IdentityProviderService;
|
|
129
|
+
return createSigningContextProvider(identityProvider);
|
|
130
|
+
}),
|
|
131
|
+
);
|
|
132
|
+
|
|
76
133
|
export type AcceptSpaceOptions = {
|
|
77
134
|
spaceKey: PublicKey;
|
|
78
135
|
genesisFeedKey: PublicKey;
|
|
@@ -106,7 +163,7 @@ export type DataSpaceManagerProps = {
|
|
|
106
163
|
spaceManager: SpaceManager;
|
|
107
164
|
metadataStore: IMetadataStore;
|
|
108
165
|
keyring: KeyringApi;
|
|
109
|
-
|
|
166
|
+
signingContextProvider: SigningContextProvider;
|
|
110
167
|
feedStore: FeedStore<FeedMessage>;
|
|
111
168
|
echoHost: EchoHost;
|
|
112
169
|
invitationsManager: InvitationsManager;
|
|
@@ -138,7 +195,6 @@ export type CreateSpaceOptions = {
|
|
|
138
195
|
};
|
|
139
196
|
|
|
140
197
|
@trackLeaks('open', 'close')
|
|
141
|
-
@trace.resource({ lifecycle: true })
|
|
142
198
|
export class DataSpaceManager extends Resource {
|
|
143
199
|
public readonly updated = new Event();
|
|
144
200
|
|
|
@@ -147,7 +203,7 @@ export class DataSpaceManager extends Resource {
|
|
|
147
203
|
private readonly _spaceManager: SpaceManager;
|
|
148
204
|
private readonly _metadataStore: IMetadataStore;
|
|
149
205
|
private readonly _keyring: KeyringApi;
|
|
150
|
-
private readonly
|
|
206
|
+
private readonly _signingContextProvider: SigningContextProvider;
|
|
151
207
|
private readonly _feedStore: FeedStore<FeedMessage>;
|
|
152
208
|
private readonly _echoHost: EchoHost;
|
|
153
209
|
private readonly _invitationsManager: InvitationsManager;
|
|
@@ -164,7 +220,7 @@ export class DataSpaceManager extends Resource {
|
|
|
164
220
|
this._spaceManager = params.spaceManager;
|
|
165
221
|
this._metadataStore = params.metadataStore;
|
|
166
222
|
this._keyring = params.keyring;
|
|
167
|
-
this.
|
|
223
|
+
this._signingContextProvider = params.signingContextProvider;
|
|
168
224
|
this._feedStore = params.feedStore;
|
|
169
225
|
this._echoHost = params.echoHost;
|
|
170
226
|
this._meshReplicator = params.meshReplicator;
|
|
@@ -205,6 +261,10 @@ export class DataSpaceManager extends Resource {
|
|
|
205
261
|
});
|
|
206
262
|
}
|
|
207
263
|
|
|
264
|
+
private get signingContext(): SigningContext {
|
|
265
|
+
return this._signingContextProvider();
|
|
266
|
+
}
|
|
267
|
+
|
|
208
268
|
// TODO(burdon): Remove.
|
|
209
269
|
get spaces() {
|
|
210
270
|
return this._spaces;
|
|
@@ -328,7 +388,7 @@ export class DataSpaceManager extends Resource {
|
|
|
328
388
|
invariant(rootDocHandle, 'Root document must be available after import.');
|
|
329
389
|
DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
|
|
330
390
|
|
|
331
|
-
root = await this._echoHost.
|
|
391
|
+
root = await this._echoHost.updateSpaceRoot(ctx, spaceId, `automerge:${newRootDocId}` as AutomergeUrl);
|
|
332
392
|
} else {
|
|
333
393
|
root = await this._echoHost.createSpaceRoot(ctx, spaceKey);
|
|
334
394
|
}
|
|
@@ -343,7 +403,7 @@ export class DataSpaceManager extends Resource {
|
|
|
343
403
|
|
|
344
404
|
const credentials = await spaceGenesis(
|
|
345
405
|
this._keyring,
|
|
346
|
-
this.
|
|
406
|
+
this.signingContext,
|
|
347
407
|
space.inner,
|
|
348
408
|
root.url,
|
|
349
409
|
tags,
|
|
@@ -353,7 +413,7 @@ export class DataSpaceManager extends Resource {
|
|
|
353
413
|
|
|
354
414
|
const memberCredential = credentials[1];
|
|
355
415
|
invariant(getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember');
|
|
356
|
-
await this.
|
|
416
|
+
await this.signingContext.recordCredential(memberCredential);
|
|
357
417
|
|
|
358
418
|
await space.initializeDataPipeline(ctx);
|
|
359
419
|
|
|
@@ -424,7 +484,7 @@ export class DataSpaceManager extends Resource {
|
|
|
424
484
|
}
|
|
425
485
|
|
|
426
486
|
// Replicates to the user's other devices via the HALO control feed.
|
|
427
|
-
const credential = await this.
|
|
487
|
+
const credential = await this.signingContext.credentialSigner.createCredential({
|
|
428
488
|
subject: spaceKey,
|
|
429
489
|
assertion: {
|
|
430
490
|
'@type': 'dxos.halo.credentials.SpaceDeleted',
|
|
@@ -432,7 +492,7 @@ export class DataSpaceManager extends Resource {
|
|
|
432
492
|
'deletedAt': new Date(),
|
|
433
493
|
},
|
|
434
494
|
});
|
|
435
|
-
await this.
|
|
495
|
+
await this.signingContext.recordCredential(credential);
|
|
436
496
|
|
|
437
497
|
await this._tombstoneSpace(ctx, spaceKey);
|
|
438
498
|
}
|
|
@@ -480,7 +540,7 @@ export class DataSpaceManager extends Resource {
|
|
|
480
540
|
|
|
481
541
|
// TODO(burdon): Check if already admitted.
|
|
482
542
|
const credentials: FeedMessage.Payload[] = await createAdmissionCredentials(
|
|
483
|
-
this.
|
|
543
|
+
this.signingContext.credentialSigner,
|
|
484
544
|
options.identityKey,
|
|
485
545
|
space.key,
|
|
486
546
|
space.genesisFeedKey,
|
|
@@ -518,12 +578,12 @@ export class DataSpaceManager extends Resource {
|
|
|
518
578
|
public async requestSpaceAdmissionCredential(ctx: Context, spaceKey: PublicKey): Promise<Credential> {
|
|
519
579
|
return this._spaceManager.requestSpaceAdmissionCredential(ctx, {
|
|
520
580
|
spaceKey,
|
|
521
|
-
identityKey: this.
|
|
581
|
+
identityKey: this.signingContext.identityKey,
|
|
522
582
|
timeout: 15_000,
|
|
523
583
|
swarmIdentity: {
|
|
524
|
-
identityKey: this.
|
|
525
|
-
peerKey: this.
|
|
526
|
-
credentialProvider: createAuthProvider(this.
|
|
584
|
+
identityKey: this.signingContext.identityKey,
|
|
585
|
+
peerKey: this.signingContext.deviceKey,
|
|
586
|
+
credentialProvider: createAuthProvider(this.signingContext.credentialSigner),
|
|
527
587
|
credentialAuthenticator: async () => true,
|
|
528
588
|
},
|
|
529
589
|
});
|
|
@@ -556,12 +616,12 @@ export class DataSpaceManager extends Resource {
|
|
|
556
616
|
private async _constructSpace(ctx: Context, metadata: SpaceMetadata): Promise<DataSpace> {
|
|
557
617
|
log('construct space', { metadata });
|
|
558
618
|
const gossip = new Gossip({
|
|
559
|
-
localPeerId: this.
|
|
619
|
+
localPeerId: this.signingContext.deviceKey,
|
|
560
620
|
});
|
|
561
621
|
const presence = new Presence({
|
|
562
622
|
announceInterval: this._runtimeProps?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
|
|
563
623
|
offlineTimeout: this._runtimeProps?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
|
|
564
|
-
identityKey: this.
|
|
624
|
+
identityKey: this.signingContext.identityKey,
|
|
565
625
|
gossip,
|
|
566
626
|
});
|
|
567
627
|
|
|
@@ -577,9 +637,9 @@ export class DataSpaceManager extends Resource {
|
|
|
577
637
|
const space: Space = await this._spaceManager.constructSpace({
|
|
578
638
|
metadata,
|
|
579
639
|
swarmIdentity: {
|
|
580
|
-
identityKey: this.
|
|
581
|
-
peerKey: this.
|
|
582
|
-
credentialProvider: createAuthProvider(this.
|
|
640
|
+
identityKey: this.signingContext.identityKey,
|
|
641
|
+
peerKey: this.signingContext.deviceKey,
|
|
642
|
+
credentialProvider: createAuthProvider(this.signingContext.credentialSigner),
|
|
583
643
|
credentialAuthenticator: deferFunction(() => dataSpace.authVerifier.verifier),
|
|
584
644
|
},
|
|
585
645
|
onAuthorizedConnection: (session) =>
|
|
@@ -608,7 +668,7 @@ export class DataSpaceManager extends Resource {
|
|
|
608
668
|
this._handleMemberRoleChanges(presence, space.protocol, members);
|
|
609
669
|
}
|
|
610
670
|
},
|
|
611
|
-
memberKey: this.
|
|
671
|
+
memberKey: this.signingContext.identityKey,
|
|
612
672
|
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
613
673
|
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
614
674
|
},
|
|
@@ -625,7 +685,7 @@ export class DataSpaceManager extends Resource {
|
|
|
625
685
|
keyring: this._keyring,
|
|
626
686
|
feedStore: this._feedStore,
|
|
627
687
|
echoHost: this._echoHost,
|
|
628
|
-
signingContext: this.
|
|
688
|
+
signingContext: this.signingContext,
|
|
629
689
|
callbacks: {
|
|
630
690
|
beforeReady: async () => {
|
|
631
691
|
log('before space ready', { space: space.key });
|
|
@@ -767,3 +827,58 @@ export class DataSpaceManager extends Resource {
|
|
|
767
827
|
await Promise.all(tasks);
|
|
768
828
|
}
|
|
769
829
|
}
|
|
830
|
+
|
|
831
|
+
export class DataSpaceManagerService extends EffectContext.Tag('@dxos/client-services/DataSpaceManager')<
|
|
832
|
+
DataSpaceManagerService,
|
|
833
|
+
DataSpaceManager
|
|
834
|
+
>() {}
|
|
835
|
+
|
|
836
|
+
export type DataSpaceManagerLayerOptions = Pick<DataSpaceManagerProps, 'runtimeProps' | 'edgeFeatures'>;
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Effect Layer constructing a dormant {@link DataSpaceManager}.
|
|
840
|
+
*/
|
|
841
|
+
export const DataSpaceManagerLayer = (
|
|
842
|
+
options: DataSpaceManagerLayerOptions = {},
|
|
843
|
+
): Layer.Layer<
|
|
844
|
+
DataSpaceManagerService,
|
|
845
|
+
never,
|
|
846
|
+
| SpaceManagerService
|
|
847
|
+
| IMetadataStoreService
|
|
848
|
+
| KeyringApiService
|
|
849
|
+
| SigningContextProviderService
|
|
850
|
+
| FeedStoreService
|
|
851
|
+
| EchoHostService
|
|
852
|
+
| InvitationsManagerService
|
|
853
|
+
> =>
|
|
854
|
+
Layer.effect(
|
|
855
|
+
DataSpaceManagerService,
|
|
856
|
+
Effect.gen(function* () {
|
|
857
|
+
const spaceManager = yield* SpaceManagerService;
|
|
858
|
+
const metadataStore = yield* IMetadataStoreService;
|
|
859
|
+
const keyring = yield* KeyringApiService;
|
|
860
|
+
const signingContextProvider = yield* SigningContextProviderService;
|
|
861
|
+
const feedStore = yield* FeedStoreService;
|
|
862
|
+
const echoHost = yield* EchoHostService;
|
|
863
|
+
const invitationsManager = yield* InvitationsManagerService;
|
|
864
|
+
const edgeConnection = yield* Effect.serviceOption(EdgeConnectionService);
|
|
865
|
+
const edgeHttpClient = yield* Effect.serviceOption(EdgeHttpClientService);
|
|
866
|
+
const meshReplicator = yield* Effect.serviceOption(MeshEchoReplicatorService);
|
|
867
|
+
const echoEdgeReplicator = yield* Effect.serviceOption(EdgeAutomergeReplicatorService);
|
|
868
|
+
|
|
869
|
+
return new DataSpaceManager({
|
|
870
|
+
spaceManager,
|
|
871
|
+
metadataStore,
|
|
872
|
+
keyring,
|
|
873
|
+
signingContextProvider,
|
|
874
|
+
feedStore,
|
|
875
|
+
echoHost,
|
|
876
|
+
invitationsManager,
|
|
877
|
+
edgeConnection: Option.getOrUndefined(edgeConnection),
|
|
878
|
+
edgeHttpClient: Option.getOrUndefined(edgeHttpClient),
|
|
879
|
+
meshReplicator: Option.getOrUndefined(meshReplicator),
|
|
880
|
+
echoEdgeReplicator: Option.getOrUndefined(echoEdgeReplicator),
|
|
881
|
+
...options,
|
|
882
|
+
});
|
|
883
|
+
}),
|
|
884
|
+
);
|
|
@@ -10,13 +10,7 @@ import { AUTH_TIMEOUT } from '@dxos/client-protocol';
|
|
|
10
10
|
import { Context, ContextDisposedError, cancelWithContext } from '@dxos/context';
|
|
11
11
|
import type { SpecificCredential } from '@dxos/credentials';
|
|
12
12
|
import { timed, warnAfterTimeout } from '@dxos/debug';
|
|
13
|
-
import {
|
|
14
|
-
type DatabaseRoot,
|
|
15
|
-
type EchoHost,
|
|
16
|
-
type IMetadataStore,
|
|
17
|
-
type Space,
|
|
18
|
-
createMappedFeedWriter,
|
|
19
|
-
} from '@dxos/echo-host';
|
|
13
|
+
import { type DatabaseRoot, type EchoHost } from '@dxos/echo-host';
|
|
20
14
|
import { type DatabaseDirectory, SpaceDocVersion } from '@dxos/echo-protocol';
|
|
21
15
|
import type { EdgeConnection, EdgeHttpClient } from '@dxos/edge-client';
|
|
22
16
|
import { type FeedStore, type FeedWrapper } from '@dxos/feed-store';
|
|
@@ -48,6 +42,9 @@ import { trace } from '@dxos/tracing';
|
|
|
48
42
|
import { type AsyncCallback, CallbackCollection, ComplexSet } from '@dxos/util';
|
|
49
43
|
|
|
50
44
|
import { TrustedKeySetAuthVerifier } from '../identity';
|
|
45
|
+
import { type IMetadataStore } from '../metadata';
|
|
46
|
+
import { createMappedFeedWriter } from '../pipeline';
|
|
47
|
+
import { type Space } from '../space';
|
|
51
48
|
import { AutomergeSpaceState } from './automerge-space-state';
|
|
52
49
|
import { type SigningContext } from './data-space-manager';
|
|
53
50
|
import { EdgeFeedReplicator } from './edge-feed-replicator';
|
|
@@ -96,10 +93,8 @@ export type CreateEpochOptions = {
|
|
|
96
93
|
};
|
|
97
94
|
|
|
98
95
|
@trackLeaks('open', 'close')
|
|
99
|
-
@trace.resource()
|
|
100
96
|
export class DataSpace {
|
|
101
97
|
private _ctx = new Context();
|
|
102
|
-
@trace.info()
|
|
103
98
|
private readonly _inner: Space;
|
|
104
99
|
|
|
105
100
|
private readonly _gossip: Gossip;
|
|
@@ -181,12 +176,10 @@ export class DataSpace {
|
|
|
181
176
|
log('new state', { state: SpaceState[this._state] });
|
|
182
177
|
}
|
|
183
178
|
|
|
184
|
-
@trace.info()
|
|
185
179
|
get id() {
|
|
186
180
|
return this._inner.id;
|
|
187
181
|
}
|
|
188
182
|
|
|
189
|
-
@trace.info()
|
|
190
183
|
get key() {
|
|
191
184
|
return this._inner.key;
|
|
192
185
|
}
|
|
@@ -195,7 +188,6 @@ export class DataSpace {
|
|
|
195
188
|
return this._inner.isOpen;
|
|
196
189
|
}
|
|
197
190
|
|
|
198
|
-
@trace.info({ enum: SpaceState })
|
|
199
191
|
get state(): SpaceState {
|
|
200
192
|
return this._state;
|
|
201
193
|
}
|
|
@@ -230,7 +222,6 @@ export class DataSpace {
|
|
|
230
222
|
return this._databaseRoot;
|
|
231
223
|
}
|
|
232
224
|
|
|
233
|
-
@trace.info({ depth: null })
|
|
234
225
|
private get _automergeInfo() {
|
|
235
226
|
return {
|
|
236
227
|
rootUrl: this._automergeSpaceState.rootUrl,
|
|
@@ -359,6 +350,23 @@ export class DataSpace {
|
|
|
359
350
|
const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState.SPACE_READY);
|
|
360
351
|
|
|
361
352
|
log('initializing automerge root');
|
|
353
|
+
const isPersisted = this._echoHost.spaces.some((s) => s.spaceId === this.id);
|
|
354
|
+
if (isPersisted) {
|
|
355
|
+
try {
|
|
356
|
+
log('opening persisted space root', { spaceId: this.id });
|
|
357
|
+
const root = await this._echoHost.openSpaceRoot(ctx, this.id);
|
|
358
|
+
this._databaseRoot = root;
|
|
359
|
+
if (root.getVersion() !== SpaceDocVersion.CURRENT) {
|
|
360
|
+
this._state = SpaceState.SPACE_REQUIRES_MIGRATION;
|
|
361
|
+
this.stateUpdate.emit();
|
|
362
|
+
} else {
|
|
363
|
+
await this._enterReadyState();
|
|
364
|
+
}
|
|
365
|
+
} catch (err) {
|
|
366
|
+
log.warn('failed to open persisted space root, will wait for credentials', { spaceId: this.id, err });
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
362
370
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
363
371
|
|
|
364
372
|
// TODO(dmaretskyi): Change so `initializeDataPipeline` doesn't wait for the space to be READY, but rather any state with a valid root.
|
|
@@ -511,17 +519,20 @@ export class DataSpace {
|
|
|
511
519
|
// Ensure only one root is processed at a time.
|
|
512
520
|
using _guard = await this._epochProcessingMutex.acquire();
|
|
513
521
|
|
|
514
|
-
// Attaching space
|
|
522
|
+
// Attaching space identifiers to legacy documents.
|
|
515
523
|
const doc = handle.doc();
|
|
516
|
-
if (!doc.access?.spaceKey) {
|
|
517
|
-
handle.change((doc:
|
|
518
|
-
doc.access
|
|
524
|
+
if (!doc.access?.spaceId || !doc.access?.spaceKey) {
|
|
525
|
+
handle.change((doc: DatabaseDirectory) => {
|
|
526
|
+
doc.access ??= {};
|
|
527
|
+
doc.access.spaceId ??= this.id;
|
|
528
|
+
// spaceKey is deprecated but still written so older clients can resolve the owning space.
|
|
529
|
+
doc.access.spaceKey ??= this.key.toHex();
|
|
519
530
|
});
|
|
520
531
|
}
|
|
521
532
|
|
|
522
533
|
// TODO(dmaretskyi): Close roots.
|
|
523
534
|
// TODO(dmaretskyi): How do we handle changing to the next EPOCH?
|
|
524
|
-
const root = await this._echoHost.
|
|
535
|
+
const root = await this._echoHost.updateSpaceRoot(this._ctx, this.id, handle.url);
|
|
525
536
|
|
|
526
537
|
// NOTE: Make sure this assignment happens synchronously together with the state change.
|
|
527
538
|
this._databaseRoot = root;
|
|
@@ -8,7 +8,6 @@ import { describe, expect, onTestFinished, test, vi } from 'vitest';
|
|
|
8
8
|
|
|
9
9
|
import { Trigger, sleep } from '@dxos/async';
|
|
10
10
|
import { Context } from '@dxos/context';
|
|
11
|
-
import { valueEncoding } from '@dxos/echo-host';
|
|
12
11
|
import { EdgeClient, EdgeIdentityChangedError, createEphemeralEdgeIdentity } from '@dxos/edge-client';
|
|
13
12
|
import { createTestEdgeWsServer } from '@dxos/edge-client/testing';
|
|
14
13
|
import { FeedFactory, FeedStore, type FeedWrapper } from '@dxos/feed-store';
|
|
@@ -21,6 +20,7 @@ import { openAndClose } from '@dxos/test-utils';
|
|
|
21
20
|
import { Timeframe } from '@dxos/timeframe';
|
|
22
21
|
import { range } from '@dxos/util';
|
|
23
22
|
|
|
23
|
+
import { valueEncoding } from '../pipeline';
|
|
24
24
|
import { EdgeFeedReplicator } from './edge-feed-replicator';
|
|
25
25
|
|
|
26
26
|
describe('EdgeFeedReplicator', () => {
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import { createCredential } from '@dxos/credentials';
|
|
6
6
|
import { failUndefined } from '@dxos/debug';
|
|
7
|
-
import { type Space } from '@dxos/echo-host';
|
|
8
7
|
import { type KeyringApi } from '@dxos/keyring';
|
|
9
8
|
import { AdmittedFeed, MembershipPolicy, SpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
10
9
|
import { Timeframe } from '@dxos/timeframe';
|
|
11
10
|
|
|
11
|
+
import { type Space } from '../space';
|
|
12
12
|
import { type SigningContext } from './data-space-manager';
|
|
13
13
|
|
|
14
14
|
export const spaceGenesis = async (
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Runtime from 'effect/Runtime';
|
|
5
6
|
import { afterEach, beforeEach, describe, expect, onTestFinished, test } from 'vitest';
|
|
6
7
|
|
|
7
8
|
import { Trigger } from '@dxos/async';
|
|
8
9
|
import { Context } from '@dxos/context';
|
|
10
|
+
import { EffectEx } from '@dxos/effect';
|
|
9
11
|
import { PublicKey } from '@dxos/keys';
|
|
10
|
-
import {
|
|
12
|
+
import { subscribeStream } from '@dxos/protocols';
|
|
13
|
+
import { type Space } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
14
|
import { MembershipPolicy } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
12
15
|
|
|
13
16
|
import { type ServiceContext } from '../services';
|
|
@@ -16,7 +19,7 @@ import { SpacesServiceImpl } from './spaces-service';
|
|
|
16
19
|
|
|
17
20
|
describe('SpacesService', () => {
|
|
18
21
|
let serviceContext: ServiceContext;
|
|
19
|
-
let spacesService:
|
|
22
|
+
let spacesService: SpacesServiceImpl;
|
|
20
23
|
|
|
21
24
|
beforeEach(async () => {
|
|
22
25
|
serviceContext = await createServiceContext();
|
|
@@ -38,14 +41,16 @@ describe('SpacesService', () => {
|
|
|
38
41
|
|
|
39
42
|
describe('createSpace', () => {
|
|
40
43
|
test('fails if no identity is available', async () => {
|
|
41
|
-
await expect(
|
|
42
|
-
|
|
43
|
-
);
|
|
44
|
+
await expect(
|
|
45
|
+
EffectEx.runPromise(spacesService['SpacesService.createSpace']({ membershipPolicy: MembershipPolicy.INVITE })),
|
|
46
|
+
).rejects.toBeInstanceOf(Error);
|
|
44
47
|
});
|
|
45
48
|
|
|
46
49
|
test('creates a new space', async () => {
|
|
47
50
|
await serviceContext.createIdentity();
|
|
48
|
-
const space = await
|
|
51
|
+
const space = await EffectEx.runPromise(
|
|
52
|
+
spacesService['SpacesService.createSpace']({ membershipPolicy: MembershipPolicy.INVITE }),
|
|
53
|
+
);
|
|
49
54
|
expect(space).to.exist;
|
|
50
55
|
expect(space.spaceKey).to.be.instanceof(PublicKey);
|
|
51
56
|
});
|
|
@@ -55,29 +60,35 @@ describe('SpacesService', () => {
|
|
|
55
60
|
|
|
56
61
|
describe('querySpaces', () => {
|
|
57
62
|
test('returns empty list if no identity is available', async () => {
|
|
58
|
-
const query = spacesService.querySpaces();
|
|
63
|
+
const query = spacesService['SpacesService.querySpaces']();
|
|
59
64
|
const result = new Trigger<Space[] | undefined>();
|
|
60
|
-
|
|
61
|
-
result.wake(spaces)
|
|
65
|
+
const unsubscribe = subscribeStream(Runtime.defaultRuntime, query, {
|
|
66
|
+
onData: ({ spaces }) => result.wake(spaces),
|
|
62
67
|
});
|
|
63
|
-
onTestFinished(() =>
|
|
68
|
+
onTestFinished(() => unsubscribe());
|
|
64
69
|
expect(await result.wait()).to.be.length(0);
|
|
65
70
|
});
|
|
66
71
|
|
|
67
72
|
test('returns list of existing spaces', async () => {
|
|
68
73
|
await serviceContext.createIdentity();
|
|
69
74
|
const existingSpaces = [
|
|
70
|
-
await
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
await EffectEx.runPromise(
|
|
76
|
+
spacesService['SpacesService.createSpace']({ membershipPolicy: MembershipPolicy.INVITE }),
|
|
77
|
+
),
|
|
78
|
+
await EffectEx.runPromise(
|
|
79
|
+
spacesService['SpacesService.createSpace']({ membershipPolicy: MembershipPolicy.INVITE }),
|
|
80
|
+
),
|
|
81
|
+
await EffectEx.runPromise(
|
|
82
|
+
spacesService['SpacesService.createSpace']({ membershipPolicy: MembershipPolicy.INVITE }),
|
|
83
|
+
),
|
|
73
84
|
];
|
|
74
85
|
|
|
75
|
-
const query = spacesService.querySpaces();
|
|
86
|
+
const query = spacesService['SpacesService.querySpaces']();
|
|
76
87
|
const result = new Trigger<Space[] | undefined>();
|
|
77
|
-
|
|
78
|
-
result.wake(spaces)
|
|
88
|
+
const unsubscribe = subscribeStream(Runtime.defaultRuntime, query, {
|
|
89
|
+
onData: ({ spaces }) => result.wake(spaces),
|
|
79
90
|
});
|
|
80
|
-
onTestFinished(() =>
|
|
91
|
+
onTestFinished(() => unsubscribe());
|
|
81
92
|
|
|
82
93
|
const spaces = await result.wait();
|
|
83
94
|
expect(spaces).to.be.length(3);
|
|
@@ -86,16 +97,18 @@ describe('SpacesService', () => {
|
|
|
86
97
|
|
|
87
98
|
test('updates when new space is added', async () => {
|
|
88
99
|
await serviceContext.createIdentity();
|
|
89
|
-
const query = spacesService.querySpaces();
|
|
100
|
+
const query = spacesService['SpacesService.querySpaces']();
|
|
90
101
|
const result = new Trigger<Space[] | undefined>();
|
|
91
|
-
|
|
92
|
-
result.wake(spaces)
|
|
102
|
+
const unsubscribe = subscribeStream(Runtime.defaultRuntime, query, {
|
|
103
|
+
onData: ({ spaces }) => result.wake(spaces),
|
|
93
104
|
});
|
|
94
|
-
onTestFinished(() =>
|
|
105
|
+
onTestFinished(() => unsubscribe());
|
|
95
106
|
expect(await result.wait()).to.be.length(0);
|
|
96
107
|
|
|
97
108
|
result.reset();
|
|
98
|
-
const space = await
|
|
109
|
+
const space = await EffectEx.runPromise(
|
|
110
|
+
spacesService['SpacesService.createSpace']({ membershipPolicy: MembershipPolicy.INVITE }),
|
|
111
|
+
);
|
|
99
112
|
const spaces = await result.wait();
|
|
100
113
|
expect(spaces).to.be.length(1);
|
|
101
114
|
expect(spaces?.[0].spaceKey.equals(space.spaceKey)).to.be.true;
|