@dxos/client-services 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29
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-LZ5JMQR7.mjs → chunk-DPJ5AYTT.mjs} +2729 -4593
- package/dist/lib/browser/chunk-DPJ5AYTT.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/chunk-XJRPB3GA.mjs +22 -0
- package/dist/lib/browser/chunk-XJRPB3GA.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +490 -228
- 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 +88 -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 +86 -0
- package/dist/lib/browser/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/browser/packlets/locks/node.mjs +48 -0
- package/dist/lib/browser/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +60 -90
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-2DT3MZRL.mjs +22 -0
- package/dist/lib/node-esm/chunk-2DT3MZRL.mjs.map +7 -0
- 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-JXUVAXX5.mjs → chunk-NAPGGOMT.mjs} +2652 -4385
- package/dist/lib/node-esm/chunk-NAPGGOMT.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +490 -228
- 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 +88 -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 +86 -0
- package/dist/lib/node-esm/packlets/locks/browser.mjs.map +7 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs +48 -0
- package/dist/lib/node-esm/packlets/locks/node.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +60 -90
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts +3 -2
- 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 +2 -1
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
- 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/devtools/feeds.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/metadata.d.ts.map +1 -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/browser-diagnostics-broadcast.d.ts.map +1 -1
- 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 +2 -3
- package/dist/types/src/packlets/diagnostics/diagnostics.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/contacts-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +6 -6
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +8 -7
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +6 -10
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +8 -11
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +6 -5
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts +1 -1
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +7 -4
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-state.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-topology.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/invitations/invitations-manager.d.ts +3 -3
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +3 -3
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +4 -3
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
- package/dist/types/src/packlets/locks/browser.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/locks/node.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/network/network-service.d.ts +5 -4
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +5 -5
- 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 +13 -9
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +20 -7
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-registry.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/archive-format.d.ts +9 -0
- package/dist/types/src/packlets/space-export/archive-format.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/index.d.ts +4 -1
- package/dist/types/src/packlets/space-export/index.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts +23 -0
- package/dist/types/src/packlets/space-export/serialized-space-reader.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/serialized-space-writer.d.ts +36 -0
- package/dist/types/src/packlets/space-export/serialized-space-writer.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/space-archive-reader.d.ts +9 -1
- package/dist/types/src/packlets/space-export/space-archive-reader.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts +7 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive.test.d.ts +2 -0
- package/dist/types/src/packlets/space-export/space-archive.test.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +28 -17
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +26 -9
- 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/epoch-migrations.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +2 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +6 -9
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +10 -7
- 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/storage/profile-archive.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/util.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/credential-utils.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 +41 -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 -4
- package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
- package/dist/types/src/testing/setup.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 -55
- package/src/index.ts +1 -0
- package/src/packlets/agents/edge-agent-manager.ts +8 -5
- package/src/packlets/agents/edge-agent-service.ts +15 -3
- package/src/packlets/devices/devices-service.test.ts +0 -1
- package/src/packlets/devices/devices-service.ts +1 -1
- package/src/packlets/devtools/devtools.ts +2 -3
- package/src/packlets/diagnostics/diagnostics.ts +1 -2
- package/src/packlets/diagnostics/index.ts +1 -1
- package/src/packlets/identity/authenticator.ts +2 -2
- package/src/packlets/identity/contacts-service.ts +0 -1
- package/src/packlets/identity/identity-manager.test.ts +5 -5
- package/src/packlets/identity/identity-manager.ts +23 -22
- package/src/packlets/identity/identity-recovery-manager.ts +22 -18
- package/src/packlets/identity/identity-service.test.ts +6 -27
- package/src/packlets/identity/identity-service.ts +13 -81
- package/src/packlets/identity/identity.test.ts +6 -6
- package/src/packlets/identity/identity.ts +11 -34
- package/src/packlets/invitations/device-invitation-protocol.ts +8 -7
- package/src/packlets/invitations/edge-invitation-handler.ts +9 -5
- package/src/packlets/invitations/invitation-guest-extenstion.ts +6 -4
- package/src/packlets/invitations/invitation-host-extension.ts +13 -14
- package/src/packlets/invitations/invitation-protocol.ts +7 -4
- package/src/packlets/invitations/invitation-state.ts +1 -15
- package/src/packlets/invitations/invitations-handler.test.ts +4 -5
- package/src/packlets/invitations/invitations-handler.ts +74 -22
- package/src/packlets/invitations/invitations-manager.ts +40 -15
- package/src/packlets/invitations/invitations-service.ts +9 -9
- package/src/packlets/invitations/space-invitation-protocol.test.ts +17 -16
- package/src/packlets/invitations/space-invitation-protocol.ts +11 -16
- package/src/packlets/locks/index.ts +1 -1
- package/src/packlets/logging/logging-service.ts +20 -16
- package/src/packlets/network/network-service.test.ts +0 -1
- package/src/packlets/network/network-service.ts +10 -8
- package/src/packlets/services/client-rpc-server.ts +19 -16
- package/src/packlets/services/feed-syncer.test.ts +340 -0
- package/src/packlets/services/feed-syncer.ts +377 -0
- package/src/packlets/services/platform.ts +7 -1
- package/src/packlets/services/service-context.test.ts +3 -2
- package/src/packlets/services/service-context.ts +139 -56
- package/src/packlets/services/service-host.test.ts +8 -8
- package/src/packlets/services/service-host.ts +76 -40
- package/src/packlets/services/service-registry.test.ts +0 -1
- package/src/packlets/space-export/archive-format.ts +42 -0
- package/src/packlets/space-export/index.ts +4 -1
- package/src/packlets/space-export/serialized-space-reader.ts +111 -0
- package/src/packlets/space-export/serialized-space-writer.ts +252 -0
- package/src/packlets/space-export/space-archive-reader.ts +64 -3
- package/src/packlets/space-export/space-archive-writer.ts +41 -3
- package/src/packlets/space-export/space-archive.test.ts +461 -0
- package/src/packlets/spaces/data-space-manager.test.ts +79 -13
- package/src/packlets/spaces/data-space-manager.ts +115 -116
- package/src/packlets/spaces/data-space.ts +58 -34
- package/src/packlets/spaces/edge-feed-replicator.test.ts +2 -2
- package/src/packlets/spaces/edge-feed-replicator.ts +12 -10
- package/src/packlets/spaces/epoch-migrations.ts +5 -5
- package/src/packlets/spaces/genesis.ts +6 -1
- package/src/packlets/spaces/notarization-plugin.test.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.ts +10 -9
- package/src/packlets/spaces/spaces-service.test.ts +18 -11
- package/src/packlets/spaces/spaces-service.ts +123 -24
- package/src/packlets/storage/storage.ts +4 -4
- package/src/packlets/testing/invitation-utils.ts +10 -6
- package/src/packlets/testing/test-builder.ts +36 -10
- package/src/packlets/worker/worker-runtime.ts +188 -17
- package/src/packlets/worker/worker-session.ts +12 -18
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-LZ5JMQR7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JXUVAXX5.mjs.map +0 -7
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +0 -19
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +0 -1
- package/src/packlets/identity/default-space-state-machine.ts +0 -44
|
@@ -14,12 +14,18 @@ export const getPlatform = (): Platform => {
|
|
|
14
14
|
userAgent,
|
|
15
15
|
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1_000),
|
|
16
16
|
};
|
|
17
|
-
} else {
|
|
17
|
+
} else if (typeof SharedWorkerGlobalScope !== 'undefined') {
|
|
18
18
|
// Shared worker.
|
|
19
19
|
return {
|
|
20
20
|
type: Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
21
21
|
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1_000),
|
|
22
22
|
};
|
|
23
|
+
} else {
|
|
24
|
+
// Dedicated worker.
|
|
25
|
+
return {
|
|
26
|
+
type: Platform.PLATFORM_TYPE.DEDICATED_WORKER,
|
|
27
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1_000),
|
|
28
|
+
};
|
|
23
29
|
}
|
|
24
30
|
} else {
|
|
25
31
|
// Node.
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, test } from 'vitest';
|
|
6
6
|
|
|
7
|
+
import { Context } from '@dxos/context';
|
|
7
8
|
import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
|
|
8
9
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
9
10
|
import { openAndClose } from '@dxos/test-utils';
|
|
@@ -19,7 +20,7 @@ describe('services/ServiceContext', () => {
|
|
|
19
20
|
const device2 = await createOpenServiceContext(networkContext);
|
|
20
21
|
await Promise.all(performInvitation({ host: device1, guest: device2, options: { kind: Invitation.Kind.DEVICE } }));
|
|
21
22
|
|
|
22
|
-
const space1 = await device1.dataSpaceManager!.createSpace();
|
|
23
|
+
const space1 = await device1.dataSpaceManager!.createSpace(new Context());
|
|
23
24
|
await device2.dataSpaceManager!.waitUntilSpaceReady(space1!.key);
|
|
24
25
|
const space2 = await device2.dataSpaceManager!.spaces.get(space1.key);
|
|
25
26
|
await space2!.inner.controlPipeline.state.waitUntilTimeframe(space1.inner.controlPipeline.state.timeframe);
|
|
@@ -35,7 +36,7 @@ describe('services/ServiceContext', () => {
|
|
|
35
36
|
|
|
36
37
|
const identity2 = await createOpenServiceContext(networkContext);
|
|
37
38
|
await identity2.createIdentity();
|
|
38
|
-
const space1 = await identity2.dataSpaceManager!.createSpace();
|
|
39
|
+
const space1 = await identity2.dataSpaceManager!.createSpace(new Context());
|
|
39
40
|
await Promise.all(
|
|
40
41
|
performInvitation({
|
|
41
42
|
host: identity2,
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import type * as SqlClient from '@effect/sql/SqlClient';
|
|
6
|
+
|
|
5
7
|
import { Mutex, Trigger } from '@dxos/async';
|
|
6
8
|
import { Context, Resource } from '@dxos/context';
|
|
7
9
|
import { type CredentialProcessor, getCredentialAssertion } from '@dxos/credentials';
|
|
@@ -16,20 +18,23 @@ import {
|
|
|
16
18
|
} from '@dxos/echo-pipeline';
|
|
17
19
|
import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from '@dxos/edge-client';
|
|
18
20
|
import type { EdgeConnection, EdgeHttpClient, EdgeIdentity } from '@dxos/edge-client';
|
|
21
|
+
import { type RuntimeProvider } from '@dxos/effect';
|
|
19
22
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
20
23
|
import { invariant } from '@dxos/invariant';
|
|
21
24
|
import { Keyring } from '@dxos/keyring';
|
|
22
|
-
import {
|
|
25
|
+
import { type SpaceId } from '@dxos/keys';
|
|
23
26
|
import { type LevelDB } from '@dxos/kv-store';
|
|
24
27
|
import { log } from '@dxos/log';
|
|
25
28
|
import { type SignalManager } from '@dxos/messaging';
|
|
26
29
|
import { type SwarmNetworkManager } from '@dxos/network-manager';
|
|
27
|
-
import { InvalidStorageVersionError, STORAGE_VERSION
|
|
30
|
+
import { InvalidStorageVersionError, STORAGE_VERSION } from '@dxos/protocols';
|
|
31
|
+
import { FeedProtocol } from '@dxos/protocols';
|
|
28
32
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
29
33
|
import { type Runtime } from '@dxos/protocols/proto/dxos/config';
|
|
30
34
|
import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
31
35
|
import { type Credential, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
32
36
|
import { type Storage } from '@dxos/random-access-storage';
|
|
37
|
+
import type * as SqlTransaction from '@dxos/sql-sqlite/SqlTransaction';
|
|
33
38
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
34
39
|
import { trace as Trace } from '@dxos/tracing';
|
|
35
40
|
import { safeInstanceof } from '@dxos/util';
|
|
@@ -37,27 +42,29 @@ import { safeInstanceof } from '@dxos/util';
|
|
|
37
42
|
import { EdgeAgentManager } from '../agents';
|
|
38
43
|
import {
|
|
39
44
|
type CreateIdentityOptions,
|
|
45
|
+
type Identity,
|
|
40
46
|
IdentityManager,
|
|
41
|
-
type
|
|
42
|
-
type
|
|
47
|
+
type IdentityManagerProps,
|
|
48
|
+
type JoinIdentityProps,
|
|
43
49
|
} from '../identity';
|
|
44
50
|
import { EdgeIdentityRecoveryManager } from '../identity/identity-recovery-manager';
|
|
45
51
|
import {
|
|
46
52
|
DeviceInvitationProtocol,
|
|
47
|
-
type
|
|
53
|
+
type InvitationConnectionProps,
|
|
48
54
|
type InvitationProtocol,
|
|
49
55
|
InvitationsHandler,
|
|
50
56
|
InvitationsManager,
|
|
51
57
|
SpaceInvitationProtocol,
|
|
52
58
|
} from '../invitations';
|
|
53
|
-
import { DataSpaceManager, type
|
|
59
|
+
import { DataSpaceManager, type DataSpaceManagerRuntimeProps, type SigningContext } from '../spaces';
|
|
60
|
+
import { FeedSyncer } from './feed-syncer';
|
|
54
61
|
|
|
55
|
-
export type
|
|
56
|
-
|
|
62
|
+
export type ServiceContextRuntimeProps = Pick<
|
|
63
|
+
IdentityManagerProps,
|
|
57
64
|
'devicePresenceOfflineTimeout' | 'devicePresenceAnnounceInterval'
|
|
58
65
|
> &
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
DataSpaceManagerRuntimeProps & {
|
|
67
|
+
invitationConnectionDefaultProps?: InvitationConnectionProps;
|
|
61
68
|
disableP2pReplication?: boolean;
|
|
62
69
|
enableVectorIndexing?: boolean;
|
|
63
70
|
};
|
|
@@ -67,7 +74,7 @@ export type ServiceContextRuntimeParams = Pick<
|
|
|
67
74
|
// TODO(burdon): Rename/break-up into smaller components. And/or make members private.
|
|
68
75
|
// TODO(dmaretskyi): Gets duplicated in CJS build between normal and testing bundles.
|
|
69
76
|
@safeInstanceof('dxos.client-services.ServiceContext')
|
|
70
|
-
@Trace.resource()
|
|
77
|
+
@Trace.resource({ lifecycle: true })
|
|
71
78
|
export class ServiceContext extends Resource {
|
|
72
79
|
private readonly _edgeIdentityUpdateMutex = new Mutex();
|
|
73
80
|
|
|
@@ -84,6 +91,7 @@ export class ServiceContext extends Resource {
|
|
|
84
91
|
public readonly echoHost: EchoHost;
|
|
85
92
|
private readonly _meshReplicator?: MeshEchoReplicator = undefined;
|
|
86
93
|
private readonly _echoEdgeReplicator?: EchoEdgeReplicator = undefined;
|
|
94
|
+
private readonly _feedSyncer?: FeedSyncer = undefined;
|
|
87
95
|
|
|
88
96
|
// Initialized after identity is initialized.
|
|
89
97
|
public dataSpaceManager?: DataSpaceManager;
|
|
@@ -96,8 +104,6 @@ export class ServiceContext extends Resource {
|
|
|
96
104
|
|
|
97
105
|
private _deviceSpaceSync?: CredentialProcessor;
|
|
98
106
|
|
|
99
|
-
private readonly _instanceId = PublicKey.random().toHex();
|
|
100
|
-
|
|
101
107
|
constructor(
|
|
102
108
|
public readonly storage: Storage,
|
|
103
109
|
public readonly level: LevelDB,
|
|
@@ -105,11 +111,15 @@ export class ServiceContext extends Resource {
|
|
|
105
111
|
public readonly signalManager: SignalManager,
|
|
106
112
|
private readonly _edgeConnection: EdgeConnection | undefined,
|
|
107
113
|
private readonly _edgeHttpClient: EdgeHttpClient | undefined,
|
|
108
|
-
|
|
114
|
+
private readonly _runtime: RuntimeProvider.RuntimeProvider<SqlClient.SqlClient | SqlTransaction.SqlTransaction>,
|
|
115
|
+
public readonly _runtimeProps?: ServiceContextRuntimeProps,
|
|
109
116
|
private readonly _edgeFeatures?: Runtime.Client.EdgeFeatures,
|
|
110
117
|
) {
|
|
111
118
|
super();
|
|
112
119
|
|
|
120
|
+
log('runtimeProps', this._runtimeProps);
|
|
121
|
+
log('edgeFeatures', this._edgeFeatures);
|
|
122
|
+
|
|
113
123
|
// TODO(burdon): Move strings to constants.
|
|
114
124
|
this.metadataStore = new MetadataStore(storage.createDirectory('metadata'));
|
|
115
125
|
this.blobStore = new BlobStore(storage.createDirectory('blobs'));
|
|
@@ -131,7 +141,7 @@ export class ServiceContext extends Resource {
|
|
|
131
141
|
networkManager: this.networkManager,
|
|
132
142
|
blobStore: this.blobStore,
|
|
133
143
|
metadataStore: this.metadataStore,
|
|
134
|
-
disableP2pReplication: this.
|
|
144
|
+
disableP2pReplication: this._runtimeProps?.disableP2pReplication,
|
|
135
145
|
});
|
|
136
146
|
|
|
137
147
|
this.identityManager = new IdentityManager({
|
|
@@ -139,8 +149,8 @@ export class ServiceContext extends Resource {
|
|
|
139
149
|
keyring: this.keyring,
|
|
140
150
|
feedStore: this.feedStore,
|
|
141
151
|
spaceManager: this.spaceManager,
|
|
142
|
-
devicePresenceOfflineTimeout: this.
|
|
143
|
-
devicePresenceAnnounceInterval: this.
|
|
152
|
+
devicePresenceOfflineTimeout: this._runtimeProps?.devicePresenceOfflineTimeout,
|
|
153
|
+
devicePresenceAnnounceInterval: this._runtimeProps?.devicePresenceAnnounceInterval,
|
|
144
154
|
edgeConnection: this._edgeConnection,
|
|
145
155
|
edgeFeatures: this._edgeFeatures,
|
|
146
156
|
});
|
|
@@ -156,17 +166,22 @@ export class ServiceContext extends Resource {
|
|
|
156
166
|
kv: this.level,
|
|
157
167
|
peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
|
|
158
168
|
getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
|
|
159
|
-
|
|
160
|
-
|
|
169
|
+
runtime: this._runtime,
|
|
170
|
+
useSubduction: this._edgeFeatures?.subductionReplicator,
|
|
171
|
+
syncQueue: async (ctx, request) => {
|
|
172
|
+
return this._feedSyncer?.syncBlocking(ctx, {
|
|
173
|
+
spaceId: request.spaceId as SpaceId,
|
|
174
|
+
subspaceTag: request.subspaceTag,
|
|
175
|
+
shouldPush: request.shouldPush,
|
|
176
|
+
shouldPull: request.shouldPull,
|
|
177
|
+
});
|
|
161
178
|
},
|
|
162
179
|
});
|
|
163
180
|
|
|
164
|
-
this._meshReplicator = new MeshEchoReplicator();
|
|
165
|
-
|
|
166
181
|
this.invitations = new InvitationsHandler(
|
|
167
182
|
this.networkManager, //
|
|
168
183
|
this._edgeHttpClient,
|
|
169
|
-
|
|
184
|
+
_runtimeProps?.invitationConnectionDefaultProps,
|
|
170
185
|
);
|
|
171
186
|
this.invitationsManager = new InvitationsManager(
|
|
172
187
|
this.invitations,
|
|
@@ -186,7 +201,7 @@ export class ServiceContext extends Resource {
|
|
|
186
201
|
),
|
|
187
202
|
);
|
|
188
203
|
|
|
189
|
-
if (!this.
|
|
204
|
+
if (!this._runtimeProps?.disableP2pReplication) {
|
|
190
205
|
this._meshReplicator = new MeshEchoReplicator();
|
|
191
206
|
}
|
|
192
207
|
if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
|
|
@@ -195,59 +210,106 @@ export class ServiceContext extends Resource {
|
|
|
195
210
|
edgeHttpClient: this._edgeHttpClient,
|
|
196
211
|
});
|
|
197
212
|
}
|
|
213
|
+
|
|
214
|
+
if (this.echoHost.feedStore && this._edgeConnection) {
|
|
215
|
+
this._feedSyncer = new FeedSyncer({
|
|
216
|
+
runtime: this._runtime,
|
|
217
|
+
feedStore: this.echoHost.feedStore,
|
|
218
|
+
edgeClient: this._edgeConnection,
|
|
219
|
+
peerId: this.identityManager.identity?.deviceKey?.toHex() ?? '',
|
|
220
|
+
getSpaceIds: () => this.echoHost!.spaceIds,
|
|
221
|
+
syncNamespaces: [FeedProtocol.WellKnownNamespaces.data, FeedProtocol.WellKnownNamespaces.trace],
|
|
222
|
+
});
|
|
223
|
+
}
|
|
198
224
|
}
|
|
199
225
|
|
|
200
|
-
@Trace.span()
|
|
226
|
+
@Trace.span({ op: 'lifecycle' })
|
|
201
227
|
protected override async _open(ctx: Context): Promise<void> {
|
|
202
228
|
await this._checkStorageVersion();
|
|
203
229
|
|
|
204
230
|
log('opening...');
|
|
205
|
-
log.trace('dxos.sdk.service-context.open', trace.begin({ id: this._instanceId }));
|
|
206
231
|
|
|
232
|
+
log('opening identityManager...');
|
|
207
233
|
await this.identityManager.open(ctx);
|
|
234
|
+
log('identityManager opened', { hasIdentity: !!this.identityManager.identity });
|
|
208
235
|
|
|
209
|
-
|
|
236
|
+
log('setting network identity...');
|
|
237
|
+
await this._setNetworkIdentity({ identity: this.identityManager.identity });
|
|
238
|
+
log('network identity set');
|
|
210
239
|
|
|
211
|
-
|
|
212
|
-
await this.
|
|
240
|
+
log('opening edge connection...');
|
|
241
|
+
await this._edgeConnection?.open(ctx);
|
|
242
|
+
log('edge connection opened');
|
|
243
|
+
|
|
244
|
+
log('opening signal manager...');
|
|
245
|
+
await this.signalManager.open(ctx);
|
|
246
|
+
log('signal manager opened');
|
|
247
|
+
|
|
248
|
+
log('opening network manager...');
|
|
213
249
|
await this.networkManager.open();
|
|
250
|
+
log('network manager opened');
|
|
214
251
|
|
|
252
|
+
log('opening echo host...');
|
|
215
253
|
await this.echoHost.open(ctx);
|
|
254
|
+
log('echo host opened');
|
|
216
255
|
|
|
217
256
|
if (this._meshReplicator) {
|
|
218
|
-
|
|
257
|
+
log('adding mesh replicator...');
|
|
258
|
+
await this.echoHost.addReplicator(ctx, this._meshReplicator);
|
|
259
|
+
log('mesh replicator added');
|
|
219
260
|
}
|
|
220
261
|
if (this._echoEdgeReplicator) {
|
|
221
|
-
|
|
262
|
+
log('adding edge replicator...');
|
|
263
|
+
await this.echoHost.addReplicator(ctx, this._echoEdgeReplicator);
|
|
264
|
+
log('edge replicator added');
|
|
222
265
|
}
|
|
223
266
|
|
|
267
|
+
log('loading metadata store...');
|
|
224
268
|
await this.metadataStore.load();
|
|
269
|
+
log('metadata store loaded');
|
|
270
|
+
|
|
271
|
+
log('opening space manager...');
|
|
225
272
|
await this.spaceManager.open();
|
|
273
|
+
log('space manager opened');
|
|
226
274
|
|
|
227
275
|
if (this.identityManager.identity) {
|
|
228
|
-
|
|
276
|
+
log('joining network...');
|
|
277
|
+
await this.identityManager.identity.joinNetwork(ctx);
|
|
278
|
+
log('network joined');
|
|
279
|
+
|
|
280
|
+
log('initializing spaces...(calling _initialize)');
|
|
229
281
|
await this._initialize(ctx);
|
|
282
|
+
log('spaces initialized');
|
|
283
|
+
} else {
|
|
284
|
+
log('no identity, skipping network join and space initialization');
|
|
230
285
|
}
|
|
231
286
|
|
|
232
|
-
|
|
287
|
+
log('opening feed syncer...');
|
|
288
|
+
await this._feedSyncer?.open(ctx);
|
|
289
|
+
log('feed syncer opened');
|
|
290
|
+
|
|
291
|
+
log('loading persistent invitations...');
|
|
292
|
+
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations(ctx);
|
|
233
293
|
log('loaded persistent invitations', { count: loadedInvitations.invitations?.length });
|
|
234
294
|
|
|
235
|
-
log.trace('dxos.sdk.service-context.open', trace.end({ id: this._instanceId }));
|
|
236
295
|
log('opened');
|
|
237
296
|
}
|
|
238
297
|
|
|
239
298
|
protected override async _close(ctx: Context): Promise<void> {
|
|
240
299
|
log('closing...');
|
|
300
|
+
|
|
301
|
+
await this._feedSyncer?.close();
|
|
302
|
+
|
|
241
303
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
242
304
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
243
305
|
}
|
|
244
|
-
await this.dataSpaceManager?.close();
|
|
306
|
+
await this.dataSpaceManager?.close(ctx);
|
|
245
307
|
await this.edgeAgentManager?.close();
|
|
246
|
-
await this.identityManager.close();
|
|
308
|
+
await this.identityManager.close(ctx);
|
|
247
309
|
await this.spaceManager.close();
|
|
248
310
|
await this.echoHost.close(ctx);
|
|
249
311
|
|
|
250
|
-
await this.networkManager.close();
|
|
312
|
+
await this.networkManager.close(ctx);
|
|
251
313
|
await this.signalManager.close();
|
|
252
314
|
await this._edgeConnection?.close();
|
|
253
315
|
await this.feedStore.close();
|
|
@@ -256,11 +318,12 @@ export class ServiceContext extends Resource {
|
|
|
256
318
|
log('closed');
|
|
257
319
|
}
|
|
258
320
|
|
|
259
|
-
async createIdentity(params: CreateIdentityOptions = {}) {
|
|
260
|
-
|
|
261
|
-
await this.
|
|
262
|
-
await
|
|
263
|
-
await
|
|
321
|
+
async createIdentity(params: CreateIdentityOptions = {}, ctx?: Context) {
|
|
322
|
+
ctx ??= this._ctx;
|
|
323
|
+
const identity = await this.identityManager.createIdentity(params, ctx);
|
|
324
|
+
await this._setNetworkIdentity({ identity });
|
|
325
|
+
await identity.joinNetwork(ctx);
|
|
326
|
+
await this._initialize(ctx);
|
|
264
327
|
return identity;
|
|
265
328
|
}
|
|
266
329
|
|
|
@@ -283,12 +346,12 @@ export class ServiceContext extends Resource {
|
|
|
283
346
|
}
|
|
284
347
|
}
|
|
285
348
|
|
|
286
|
-
private async _acceptIdentity(params:
|
|
287
|
-
const { identity, identityRecord } = await this.identityManager.prepareIdentity(params);
|
|
288
|
-
await this._setNetworkIdentity({ deviceCredential: params.authorizedDeviceCredential
|
|
289
|
-
await identity.joinNetwork();
|
|
349
|
+
private async _acceptIdentity(params: JoinIdentityProps) {
|
|
350
|
+
const { identity, identityRecord } = await this.identityManager.prepareIdentity(params, this._ctx);
|
|
351
|
+
await this._setNetworkIdentity({ deviceCredential: params.authorizedDeviceCredential!, identity });
|
|
352
|
+
await identity.joinNetwork(this._ctx);
|
|
290
353
|
await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
|
|
291
|
-
await this._initialize(
|
|
354
|
+
await this._initialize(this._ctx);
|
|
292
355
|
return identity;
|
|
293
356
|
}
|
|
294
357
|
|
|
@@ -303,7 +366,7 @@ export class ServiceContext extends Resource {
|
|
|
303
366
|
// Called when identity is created.
|
|
304
367
|
@Trace.span()
|
|
305
368
|
private async _initialize(ctx: Context): Promise<void> {
|
|
306
|
-
log('
|
|
369
|
+
log('_initialize: start');
|
|
307
370
|
const identity = this.identityManager.identity ?? failUndefined();
|
|
308
371
|
const signingContext: SigningContext = {
|
|
309
372
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
@@ -315,6 +378,7 @@ export class ServiceContext extends Resource {
|
|
|
315
378
|
},
|
|
316
379
|
};
|
|
317
380
|
|
|
381
|
+
log('_initialize: creating DataSpaceManager');
|
|
318
382
|
this.dataSpaceManager = new DataSpaceManager({
|
|
319
383
|
spaceManager: this.spaceManager,
|
|
320
384
|
metadataStore: this.metadataStore,
|
|
@@ -327,10 +391,12 @@ export class ServiceContext extends Resource {
|
|
|
327
391
|
edgeHttpClient: this._edgeHttpClient,
|
|
328
392
|
echoEdgeReplicator: this._echoEdgeReplicator,
|
|
329
393
|
meshReplicator: this._meshReplicator,
|
|
330
|
-
|
|
394
|
+
runtimeProps: this._runtimeProps as DataSpaceManagerRuntimeProps,
|
|
331
395
|
edgeFeatures: this._edgeFeatures,
|
|
332
396
|
});
|
|
333
|
-
|
|
397
|
+
log('_initialize: opening DataSpaceManager...');
|
|
398
|
+
await this.dataSpaceManager.open(ctx);
|
|
399
|
+
log('_initialize: DataSpaceManager opened');
|
|
334
400
|
|
|
335
401
|
this.edgeAgentManager = new EdgeAgentManager(
|
|
336
402
|
this._edgeFeatures,
|
|
@@ -338,13 +404,16 @@ export class ServiceContext extends Resource {
|
|
|
338
404
|
this.dataSpaceManager,
|
|
339
405
|
identity,
|
|
340
406
|
);
|
|
341
|
-
|
|
407
|
+
log('_initialize: opening EdgeAgentManager...');
|
|
408
|
+
await this.edgeAgentManager.open(ctx);
|
|
409
|
+
log('_initialize: EdgeAgentManager opened');
|
|
342
410
|
|
|
343
411
|
this._handlerFactories.set(Invitation.Kind.SPACE, (invitation) => {
|
|
344
412
|
invariant(this.dataSpaceManager, 'dataSpaceManager not initialized yet');
|
|
345
413
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
346
414
|
});
|
|
347
415
|
this.initialized.wake();
|
|
416
|
+
log('_initialize: initialized.wake() called');
|
|
348
417
|
|
|
349
418
|
this._deviceSpaceSync = {
|
|
350
419
|
processCredential: async (credential: Credential) => {
|
|
@@ -367,9 +436,10 @@ export class ServiceContext extends Resource {
|
|
|
367
436
|
|
|
368
437
|
try {
|
|
369
438
|
log('accepting space recorded in halo', { details: assertion });
|
|
370
|
-
await this.dataSpaceManager.acceptSpace({
|
|
439
|
+
await this.dataSpaceManager.acceptSpace(this._ctx, {
|
|
371
440
|
spaceKey: assertion.spaceKey,
|
|
372
441
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
442
|
+
tags: assertion.tags,
|
|
373
443
|
});
|
|
374
444
|
} catch (err) {
|
|
375
445
|
log.catch(err);
|
|
@@ -380,33 +450,42 @@ export class ServiceContext extends Resource {
|
|
|
380
450
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
381
451
|
}
|
|
382
452
|
|
|
383
|
-
private async _setNetworkIdentity(params?: { deviceCredential
|
|
453
|
+
private async _setNetworkIdentity(params?: { deviceCredential?: Credential; identity?: Identity }): Promise<void> {
|
|
454
|
+
log('_setNetworkIdentity: acquiring mutex...');
|
|
384
455
|
using _ = await this._edgeIdentityUpdateMutex.acquire();
|
|
456
|
+
log('_setNetworkIdentity: mutex acquired');
|
|
385
457
|
|
|
386
458
|
let edgeIdentity: EdgeIdentity;
|
|
387
|
-
const identity =
|
|
459
|
+
const identity = params?.identity;
|
|
388
460
|
if (identity) {
|
|
389
|
-
log('
|
|
461
|
+
log('_setNetworkIdentity: has identity', {
|
|
390
462
|
identity: identity.identityKey.toHex(),
|
|
391
|
-
|
|
463
|
+
hasDeviceCredential: !!params?.deviceCredential,
|
|
392
464
|
});
|
|
393
465
|
|
|
394
466
|
if (params?.deviceCredential) {
|
|
467
|
+
log('_setNetworkIdentity: creating chain edge identity with device credential...');
|
|
395
468
|
edgeIdentity = await createChainEdgeIdentity(
|
|
396
469
|
identity.signer,
|
|
397
470
|
identity.identityKey,
|
|
398
471
|
identity.deviceKey,
|
|
399
|
-
|
|
472
|
+
{ credential: params.deviceCredential },
|
|
400
473
|
[], // TODO(dmaretskyi): Service access credentials.
|
|
401
474
|
);
|
|
475
|
+
log('_setNetworkIdentity: chain edge identity created');
|
|
402
476
|
} else {
|
|
477
|
+
log('_setNetworkIdentity: waiting for identity.ready()...');
|
|
403
478
|
// TODO: throw here or from identity if device chain can't be loaded, to avoid indefinite hangup
|
|
404
479
|
await warnAfterTimeout(10_000, 'Waiting for identity to be ready for edge connection', async () => {
|
|
405
480
|
await identity.ready();
|
|
406
481
|
});
|
|
482
|
+
log('_setNetworkIdentity: identity.ready() resolved', {
|
|
483
|
+
hasDeviceCredentialChain: !!identity.deviceCredentialChain,
|
|
484
|
+
});
|
|
407
485
|
|
|
408
486
|
invariant(identity.deviceCredentialChain);
|
|
409
487
|
|
|
488
|
+
log('_setNetworkIdentity: creating chain edge identity...');
|
|
410
489
|
edgeIdentity = await createChainEdgeIdentity(
|
|
411
490
|
identity.signer,
|
|
412
491
|
identity.identityKey,
|
|
@@ -414,9 +493,12 @@ export class ServiceContext extends Resource {
|
|
|
414
493
|
identity.deviceCredentialChain,
|
|
415
494
|
[], // TODO(dmaretskyi): Service access credentials.
|
|
416
495
|
);
|
|
496
|
+
log('_setNetworkIdentity: chain edge identity created');
|
|
417
497
|
}
|
|
418
498
|
} else {
|
|
499
|
+
log('_setNetworkIdentity: no identity, creating ephemeral edge identity...');
|
|
419
500
|
edgeIdentity = await createEphemeralEdgeIdentity();
|
|
501
|
+
log('_setNetworkIdentity: ephemeral edge identity created');
|
|
420
502
|
}
|
|
421
503
|
|
|
422
504
|
this._edgeConnection?.setIdentity(edgeIdentity);
|
|
@@ -425,5 +507,6 @@ export class ServiceContext extends Resource {
|
|
|
425
507
|
identityKey: edgeIdentity.identityKey,
|
|
426
508
|
peerKey: edgeIdentity.peerKey,
|
|
427
509
|
});
|
|
510
|
+
log('_setNetworkIdentity: done');
|
|
428
511
|
}
|
|
429
512
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { rmSync } from 'node:fs';
|
|
6
|
-
|
|
7
6
|
import { afterEach, describe, expect, onTestFinished, test } from 'vitest';
|
|
8
7
|
|
|
9
8
|
import { Trigger, asyncTimeout, latch } from '@dxos/async';
|
|
@@ -13,6 +12,7 @@ import { verifyPresentation } from '@dxos/credentials';
|
|
|
13
12
|
import { type PublicKey } from '@dxos/keys';
|
|
14
13
|
import { MemorySignalManagerContext } from '@dxos/messaging';
|
|
15
14
|
import { type Identity } from '@dxos/protocols/proto/dxos/client/services';
|
|
15
|
+
import { MembershipPolicy } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
16
16
|
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
17
17
|
import { isNode } from '@dxos/util';
|
|
18
18
|
|
|
@@ -29,16 +29,16 @@ describe('ClientServicesHost', () => {
|
|
|
29
29
|
test('open and close', async () => {
|
|
30
30
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
31
31
|
await host.open(new Context());
|
|
32
|
-
await host.close();
|
|
32
|
+
await host.close(Context.default());
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
test('queryCredentials', async () => {
|
|
36
36
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
37
37
|
await host.open(new Context());
|
|
38
|
-
onTestFinished(() => host.close());
|
|
38
|
+
onTestFinished(() => host.close(Context.default()));
|
|
39
39
|
|
|
40
40
|
await host.services.IdentityService!.createIdentity({});
|
|
41
|
-
const { spaceKey } = await host.services.SpacesService!.createSpace();
|
|
41
|
+
const { spaceKey } = await host.services.SpacesService!.createSpace({ membershipPolicy: MembershipPolicy.INVITE });
|
|
42
42
|
|
|
43
43
|
const stream = host.services.SpacesService!.queryCredentials({ spaceKey });
|
|
44
44
|
const [done, tick] = latch({ count: 3 });
|
|
@@ -54,7 +54,7 @@ describe('ClientServicesHost', () => {
|
|
|
54
54
|
test('write and query credentials', async () => {
|
|
55
55
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
56
56
|
await host.open(new Context());
|
|
57
|
-
onTestFinished(() => host.close());
|
|
57
|
+
onTestFinished(() => host.close(Context.default()));
|
|
58
58
|
|
|
59
59
|
await host.services.IdentityService!.createIdentity({});
|
|
60
60
|
|
|
@@ -91,7 +91,7 @@ describe('ClientServicesHost', () => {
|
|
|
91
91
|
test('sign presentation', async () => {
|
|
92
92
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
93
93
|
await host.open(new Context());
|
|
94
|
-
onTestFinished(() => host.close());
|
|
94
|
+
onTestFinished(() => host.close(Context.default()));
|
|
95
95
|
|
|
96
96
|
await host.services.IdentityService!.createIdentity({});
|
|
97
97
|
|
|
@@ -128,7 +128,7 @@ describe('ClientServicesHost', () => {
|
|
|
128
128
|
expect(host.context.storage.size).to.exist;
|
|
129
129
|
|
|
130
130
|
await asyncTimeout(host.reset(), 1000);
|
|
131
|
-
await host.close();
|
|
131
|
+
await host.close(Context.default());
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
{
|
|
@@ -146,7 +146,7 @@ describe('ClientServicesHost', () => {
|
|
|
146
146
|
});
|
|
147
147
|
await expect(asyncTimeout(trigger.wait(), 200)).rejects.toBeInstanceOf(Error);
|
|
148
148
|
await stream?.close();
|
|
149
|
-
await host.close();
|
|
149
|
+
await host.close(Context.default());
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
152
|
});
|