@dxos/client-services 0.8.4-main.b97322e → 0.8.4-main.bcb3aa67d6
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-WKKP35EC.mjs → chunk-5A3KX2RY.mjs} +4406 -3958
- package/dist/lib/browser/chunk-5A3KX2RY.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 +481 -78
- 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 +45 -26
- 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-ZE2HYS56.mjs → chunk-FNPO5UMU.mjs} +4302 -3722
- package/dist/lib/node-esm/chunk-FNPO5UMU.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 +481 -78
- 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 +45 -26
- 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 +1 -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 +20 -20
- 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 +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +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 +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts +1 -1
- 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 +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 +7 -7
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +7 -6
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +1 -6
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +9 -12
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +4 -4
- 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 +3 -4
- package/dist/types/src/packlets/invitations/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/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 +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +3 -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/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 +5 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts +2 -2
- package/dist/types/src/packlets/network/network-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 +14 -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 -6
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- 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 +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +28 -16
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +28 -12
- 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/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 -6
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +3 -3
- package/dist/types/src/packlets/spaces/spaces-service.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/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/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 +8 -7
- 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 +72 -48
- package/src/index.ts +1 -0
- package/src/packlets/agents/edge-agent-manager.ts +10 -7
- package/src/packlets/agents/edge-agent-service.ts +15 -5
- package/src/packlets/devices/devices-service.test.ts +4 -3
- package/src/packlets/devices/devices-service.ts +2 -2
- package/src/packlets/devtools/devtools.ts +30 -29
- package/src/packlets/devtools/feeds.ts +2 -2
- package/src/packlets/devtools/network.ts +1 -1
- package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +1 -1
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +1 -1
- package/src/packlets/diagnostics/diagnostics-collector.ts +1 -1
- package/src/packlets/diagnostics/diagnostics.ts +1 -1
- package/src/packlets/diagnostics/index.ts +1 -1
- package/src/packlets/identity/authenticator.node.test.ts +1 -1
- package/src/packlets/identity/authenticator.ts +3 -3
- package/src/packlets/identity/contacts-service.ts +3 -2
- package/src/packlets/identity/identity-manager.test.ts +8 -8
- package/src/packlets/identity/identity-manager.ts +23 -20
- package/src/packlets/identity/identity-recovery-manager.ts +22 -18
- package/src/packlets/identity/identity-service.test.ts +9 -28
- package/src/packlets/identity/identity-service.ts +5 -75
- package/src/packlets/identity/identity.test.ts +11 -11
- package/src/packlets/identity/identity.ts +16 -37
- package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -5
- package/src/packlets/invitations/edge-invitation-handler.ts +5 -4
- package/src/packlets/invitations/invitation-guest-extenstion.ts +7 -5
- package/src/packlets/invitations/invitation-host-extension.ts +8 -6
- package/src/packlets/invitations/invitation-protocol.ts +3 -4
- package/src/packlets/invitations/invitations-handler.test.ts +8 -7
- package/src/packlets/invitations/invitations-handler.ts +13 -13
- package/src/packlets/invitations/invitations-manager.ts +40 -17
- package/src/packlets/invitations/invitations-service.ts +5 -5
- package/src/packlets/invitations/space-invitation-protocol.test.ts +19 -18
- package/src/packlets/invitations/space-invitation-protocol.ts +13 -16
- package/src/packlets/invitations/utils.ts +1 -1
- package/src/packlets/locks/browser.ts +1 -1
- package/src/packlets/locks/index.ts +1 -1
- package/src/packlets/logging/logging-service.ts +7 -3
- package/src/packlets/logging/logging.test.ts +1 -1
- package/src/packlets/network/network-service.test.ts +4 -3
- package/src/packlets/network/network-service.ts +7 -6
- package/src/packlets/services/client-rpc-server.ts +5 -5
- package/src/packlets/services/feed-syncer.test.ts +340 -0
- package/src/packlets/services/feed-syncer.ts +337 -0
- package/src/packlets/services/platform.ts +7 -1
- package/src/packlets/services/service-context.test.ts +4 -3
- package/src/packlets/services/service-context.ts +139 -52
- package/src/packlets/services/service-host.test.ts +11 -9
- package/src/packlets/services/service-host.ts +78 -28
- package/src/packlets/services/service-registry.test.ts +2 -1
- package/src/packlets/space-export/space-archive-reader.ts +65 -4
- package/src/packlets/space-export/space-archive-writer.ts +42 -5
- package/src/packlets/space-export/space-archive.test.ts +287 -0
- package/src/packlets/space-export/tar.test.ts +1 -1
- package/src/packlets/spaces/automerge-space-state.ts +1 -1
- package/src/packlets/spaces/data-space-manager.test.ts +79 -13
- package/src/packlets/spaces/data-space-manager.ts +124 -116
- package/src/packlets/spaces/data-space.ts +60 -35
- package/src/packlets/spaces/edge-feed-replicator.test.ts +4 -4
- package/src/packlets/spaces/edge-feed-replicator.ts +12 -11
- 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 +3 -3
- package/src/packlets/spaces/notarization-plugin.ts +13 -12
- package/src/packlets/spaces/spaces-service.test.ts +12 -8
- package/src/packlets/spaces/spaces-service.ts +57 -31
- package/src/packlets/storage/profile-archive.ts +1 -1
- package/src/packlets/storage/storage.ts +7 -8
- package/src/packlets/system/system-service.test.ts +1 -1
- package/src/packlets/system/system-service.ts +4 -4
- package/src/packlets/testing/invitation-utils.ts +11 -7
- package/src/packlets/testing/test-builder.ts +39 -13
- package/src/packlets/worker/worker-runtime.ts +152 -13
- package/src/packlets/worker/worker-session.ts +11 -11
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-WKKP35EC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZE2HYS56.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
|
@@ -6,6 +6,7 @@ import type { AutomergeUrl } from '@automerge/automerge-repo';
|
|
|
6
6
|
|
|
7
7
|
import { SubscriptionList, UpdateScheduler, scheduleTask } from '@dxos/async';
|
|
8
8
|
import { Stream } from '@dxos/codec-protobuf/stream';
|
|
9
|
+
import { Context } from '@dxos/context';
|
|
9
10
|
import {
|
|
10
11
|
type CredentialProcessor,
|
|
11
12
|
createAdmissionCredentials,
|
|
@@ -19,44 +20,46 @@ import { assertArgument, assertState, invariant } from '@dxos/invariant';
|
|
|
19
20
|
import { SpaceId } from '@dxos/keys';
|
|
20
21
|
import { log } from '@dxos/log';
|
|
21
22
|
import {
|
|
22
|
-
encodeError,
|
|
23
23
|
ApiError,
|
|
24
24
|
AuthorizationError,
|
|
25
25
|
IdentityNotInitializedError,
|
|
26
26
|
SpaceNotFoundError,
|
|
27
|
+
encodeError,
|
|
27
28
|
} from '@dxos/protocols';
|
|
28
29
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
type AdmitContactRequest,
|
|
31
|
+
type ContactAdmission,
|
|
31
32
|
type CreateEpochRequest,
|
|
33
|
+
type CreateEpochResponse,
|
|
34
|
+
type ExportSpaceRequest,
|
|
35
|
+
type ExportSpaceResponse,
|
|
36
|
+
type ImportSpaceRequest,
|
|
37
|
+
type ImportSpaceResponse,
|
|
38
|
+
type JoinBySpaceKeyRequest,
|
|
39
|
+
type JoinSpaceResponse,
|
|
32
40
|
type PostMessageRequest,
|
|
33
41
|
type QueryCredentialsRequest,
|
|
34
42
|
type QuerySpacesResponse,
|
|
35
43
|
type Space,
|
|
44
|
+
SpaceMember,
|
|
45
|
+
SpaceState,
|
|
36
46
|
type SpacesService,
|
|
37
47
|
type SubscribeMessagesRequest,
|
|
48
|
+
type UpdateMemberRoleRequest,
|
|
49
|
+
type CreateSpaceRequest,
|
|
38
50
|
type UpdateSpaceRequest,
|
|
39
51
|
type WriteCredentialsRequest,
|
|
40
|
-
type UpdateMemberRoleRequest,
|
|
41
|
-
type AdmitContactRequest,
|
|
42
|
-
type ContactAdmission,
|
|
43
|
-
type JoinSpaceResponse,
|
|
44
|
-
type JoinBySpaceKeyRequest,
|
|
45
|
-
type CreateEpochResponse,
|
|
46
|
-
type ExportSpaceResponse,
|
|
47
|
-
type ExportSpaceRequest,
|
|
48
|
-
type ImportSpaceRequest,
|
|
49
|
-
type ImportSpaceResponse,
|
|
50
52
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
51
53
|
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
52
54
|
import { type GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gossip';
|
|
53
55
|
import { trace } from '@dxos/tracing';
|
|
54
56
|
import { type Provider } from '@dxos/util';
|
|
55
57
|
|
|
58
|
+
import { type IdentityManager } from '../identity';
|
|
59
|
+
import { SpaceArchiveWriter, extractSpaceArchive } from '../space-export';
|
|
60
|
+
|
|
56
61
|
import { type DataSpace } from './data-space';
|
|
57
62
|
import { type DataSpaceManager } from './data-space-manager';
|
|
58
|
-
import { type IdentityManager } from '../identity';
|
|
59
|
-
import { extractSpaceArchive, SpaceArchiveWriter } from '../space-export';
|
|
60
63
|
|
|
61
64
|
export class SpacesServiceImpl implements SpacesService {
|
|
62
65
|
constructor(
|
|
@@ -65,10 +68,13 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
65
68
|
private readonly _getDataSpaceManager: Provider<Promise<DataSpaceManager>>,
|
|
66
69
|
) {}
|
|
67
70
|
|
|
68
|
-
async createSpace(): Promise<Space> {
|
|
71
|
+
async createSpace(request: CreateSpaceRequest): Promise<Space> {
|
|
69
72
|
this._requireIdentity();
|
|
70
73
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
71
|
-
const space = await dataSpaceManager.createSpace()
|
|
74
|
+
const space = await dataSpaceManager.createSpace(new Context(), {
|
|
75
|
+
tags: request?.tags,
|
|
76
|
+
membershipPolicy: request?.membershipPolicy,
|
|
77
|
+
});
|
|
72
78
|
await this._updateMetrics();
|
|
73
79
|
return this._serializeSpace(space);
|
|
74
80
|
}
|
|
@@ -80,19 +86,19 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
80
86
|
if (state) {
|
|
81
87
|
switch (state) {
|
|
82
88
|
case SpaceState.SPACE_ACTIVE:
|
|
83
|
-
await space.activate();
|
|
89
|
+
await space.activate(Context.default());
|
|
84
90
|
break;
|
|
85
91
|
|
|
86
92
|
case SpaceState.SPACE_INACTIVE:
|
|
87
|
-
await space.deactivate();
|
|
93
|
+
await space.deactivate(Context.default());
|
|
88
94
|
break;
|
|
89
95
|
default:
|
|
90
|
-
throw new ApiError('Invalid space state');
|
|
96
|
+
throw new ApiError({ message: 'Invalid space state' });
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
if (edgeReplication !== undefined) {
|
|
95
|
-
await dataSpaceManager.setSpaceEdgeReplicationSetting(spaceKey, edgeReplication);
|
|
101
|
+
await dataSpaceManager.setSpaceEdgeReplicationSetting(Context.default(), spaceKey, edgeReplication);
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
104
|
|
|
@@ -103,9 +109,12 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
103
109
|
throw new SpaceNotFoundError(request.spaceKey);
|
|
104
110
|
}
|
|
105
111
|
if (!space.spaceState.hasMembershipManagementPermission(identity.identityKey)) {
|
|
106
|
-
throw new AuthorizationError(
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
throw new AuthorizationError({
|
|
113
|
+
message: 'No member management permission.',
|
|
114
|
+
context: {
|
|
115
|
+
spaceKey: space.key,
|
|
116
|
+
role: space.spaceState.getMemberRole(identity.identityKey),
|
|
117
|
+
},
|
|
109
118
|
});
|
|
110
119
|
}
|
|
111
120
|
const credentials = await createAdmissionCredentials(
|
|
@@ -260,13 +269,13 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
260
269
|
|
|
261
270
|
async joinBySpaceKey({ spaceKey }: JoinBySpaceKeyRequest): Promise<JoinSpaceResponse> {
|
|
262
271
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
263
|
-
const credential = await dataSpaceManager.requestSpaceAdmissionCredential(spaceKey);
|
|
272
|
+
const credential = await dataSpaceManager.requestSpaceAdmissionCredential(Context.default(), spaceKey);
|
|
264
273
|
return this._joinByAdmission({ credential });
|
|
265
274
|
}
|
|
266
275
|
|
|
267
276
|
async exportSpace(request: ExportSpaceRequest): Promise<ExportSpaceResponse> {
|
|
268
277
|
await using writer = await new SpaceArchiveWriter().open();
|
|
269
|
-
assertArgument(SpaceId.isValid(request.spaceId), 'Invalid space ID');
|
|
278
|
+
assertArgument(SpaceId.isValid(request.spaceId), 'spaceId', 'Invalid space ID');
|
|
270
279
|
|
|
271
280
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
272
281
|
const space = dataSpaceManager.getSpaceById(request.spaceId) ?? raise(new Error('Space not found'));
|
|
@@ -279,6 +288,20 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
279
288
|
await writer.writeDocument(documentId, data);
|
|
280
289
|
}
|
|
281
290
|
|
|
291
|
+
const feeds = await space.getAllFeeds();
|
|
292
|
+
for (const feed of feeds) {
|
|
293
|
+
const archiveBlocks = feed.blocks.map((block) => ({
|
|
294
|
+
actorId: block.actorId,
|
|
295
|
+
sequence: block.sequence,
|
|
296
|
+
prevActorId: block.prevActorId,
|
|
297
|
+
prevSequence: block.prevSequence,
|
|
298
|
+
position: block.position,
|
|
299
|
+
timestamp: block.timestamp,
|
|
300
|
+
data: Buffer.from(block.data).toString('base64'),
|
|
301
|
+
}));
|
|
302
|
+
await writer.writeFeed(feed.feedId, feed.feedNamespace, archiveBlocks);
|
|
303
|
+
}
|
|
304
|
+
|
|
282
305
|
const archive = await writer.finish();
|
|
283
306
|
return { archive };
|
|
284
307
|
}
|
|
@@ -287,7 +310,7 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
287
310
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
288
311
|
const extracted = await extractSpaceArchive(request.archive);
|
|
289
312
|
invariant(extracted.metadata.echo?.currentRootUrl, 'Space archive does not contain a root URL');
|
|
290
|
-
const space = await dataSpaceManager.createSpace({
|
|
313
|
+
const space = await dataSpaceManager.createSpace(Context.default(), {
|
|
291
314
|
documents: extracted.documents,
|
|
292
315
|
rootUrl: extracted.metadata.echo?.currentRootUrl as AutomergeUrl,
|
|
293
316
|
});
|
|
@@ -304,9 +327,10 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
304
327
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
305
328
|
let dataSpace = dataSpaceManager.spaces.get(assertion.spaceKey);
|
|
306
329
|
if (!dataSpace) {
|
|
307
|
-
dataSpace = await dataSpaceManager.acceptSpace({
|
|
330
|
+
dataSpace = await dataSpaceManager.acceptSpace(Context.default(), {
|
|
308
331
|
spaceKey: assertion.spaceKey,
|
|
309
332
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
333
|
+
tags: assertion.tags,
|
|
310
334
|
});
|
|
311
335
|
await myIdentity.controlPipeline.writer.write({ credential: { credential } });
|
|
312
336
|
}
|
|
@@ -359,6 +383,8 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
359
383
|
}),
|
|
360
384
|
),
|
|
361
385
|
creator: space.inner.spaceState.creator?.key,
|
|
386
|
+
tags: space.tags,
|
|
387
|
+
membershipPolicy: space.membershipPolicy,
|
|
362
388
|
cache: space.cache,
|
|
363
389
|
metrics: space.metrics,
|
|
364
390
|
edgeReplication: space.getEdgeReplicationSetting(),
|
|
@@ -367,9 +393,9 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
367
393
|
|
|
368
394
|
private _requireIdentity() {
|
|
369
395
|
if (!this._identityManager.identity) {
|
|
370
|
-
throw new IdentityNotInitializedError(
|
|
371
|
-
'This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo',
|
|
372
|
-
);
|
|
396
|
+
throw new IdentityNotInitializedError({
|
|
397
|
+
message: 'This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo',
|
|
398
|
+
});
|
|
373
399
|
}
|
|
374
400
|
return this._identityManager.identity;
|
|
375
401
|
}
|
|
@@ -7,7 +7,7 @@ import { cbor } from '@automerge/automerge-repo';
|
|
|
7
7
|
import { invariant } from '@dxos/invariant';
|
|
8
8
|
import type { LevelDB } from '@dxos/kv-store';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
|
-
import {
|
|
10
|
+
import { type ProfileArchive, ProfileArchiveEntryType } from '@dxos/protocols';
|
|
11
11
|
import type { Storage } from '@dxos/random-access-storage';
|
|
12
12
|
import { arrayToBuffer } from '@dxos/util';
|
|
13
13
|
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
1
|
//
|
|
4
2
|
// Copyright 2023 DXOS.org
|
|
5
3
|
//
|
|
6
4
|
|
|
7
5
|
import { InvalidConfigError } from '@dxos/protocols';
|
|
8
6
|
import { Runtime } from '@dxos/protocols/proto/dxos/config';
|
|
9
|
-
import {
|
|
7
|
+
import { StorageType, createStorage } from '@dxos/random-access-storage';
|
|
10
8
|
|
|
11
|
-
import StorageDriver = Runtime.Client.Storage.StorageDriver;
|
|
12
9
|
import { getRootPath } from './util';
|
|
13
10
|
|
|
11
|
+
import StorageDriver = Runtime.Client.Storage.StorageDriver;
|
|
12
|
+
|
|
14
13
|
// TODO(burdon): Factor out.
|
|
15
14
|
export const createStorageObjects = (config: Runtime.Client.Storage) => {
|
|
16
15
|
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
17
16
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
18
|
-
throw new InvalidConfigError('RAM storage cannot be used in persistent mode.');
|
|
17
|
+
throw new InvalidConfigError({ message: 'RAM storage cannot be used in persistent mode.' });
|
|
19
18
|
}
|
|
20
19
|
if (!persistent && dataStore !== undefined && dataStore !== StorageDriver.RAM) {
|
|
21
|
-
throw new InvalidConfigError('Cannot use a persistent storage in not persistent mode.');
|
|
20
|
+
throw new InvalidConfigError({ message: 'Cannot use a persistent storage in not persistent mode.' });
|
|
22
21
|
}
|
|
23
22
|
if (persistent && keyStore === StorageDriver.RAM) {
|
|
24
|
-
throw new InvalidConfigError('RAM key storage cannot be used in persistent mode.');
|
|
23
|
+
throw new InvalidConfigError({ message: 'RAM key storage cannot be used in persistent mode.' });
|
|
25
24
|
}
|
|
26
25
|
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== undefined) {
|
|
27
|
-
throw new InvalidConfigError('Cannot use a persistent key storage in not persistent mode.');
|
|
26
|
+
throw new InvalidConfigError({ message: 'Cannot use a persistent key storage in not persistent mode.' });
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
return {
|
|
@@ -6,7 +6,7 @@ import { beforeEach, describe, expect, test } from 'vitest';
|
|
|
6
6
|
|
|
7
7
|
import { Event, Trigger } from '@dxos/async';
|
|
8
8
|
import { Config } from '@dxos/config';
|
|
9
|
-
import { type SystemService, SystemStatus
|
|
9
|
+
import { type QueryStatusResponse, type SystemService, SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
10
|
|
|
11
11
|
import { SystemServiceImpl } from './system-service';
|
|
12
12
|
|
|
@@ -7,14 +7,14 @@ import { Stream } from '@dxos/codec-protobuf/stream';
|
|
|
7
7
|
import { type Config } from '@dxos/config';
|
|
8
8
|
import {
|
|
9
9
|
GetDiagnosticsRequest,
|
|
10
|
+
type Platform,
|
|
11
|
+
type QueryStatusRequest,
|
|
12
|
+
type QueryStatusResponse,
|
|
10
13
|
type SystemService,
|
|
11
14
|
type SystemStatus,
|
|
12
15
|
type UpdateStatusRequest,
|
|
13
|
-
type QueryStatusRequest,
|
|
14
|
-
type QueryStatusResponse,
|
|
15
|
-
type Platform,
|
|
16
16
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
17
|
-
import {
|
|
17
|
+
import { type MaybePromise, jsonKeyReplacer } from '@dxos/util';
|
|
18
18
|
|
|
19
19
|
import { type Diagnostics } from '../diagnostics';
|
|
20
20
|
import { getPlatform } from '../services/platform';
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Trigger } from '@dxos/async';
|
|
6
|
-
import {
|
|
6
|
+
import { type AuthenticatingInvitation, type CancellableInvitation, InvitationEncoder } from '@dxos/client-protocol';
|
|
7
|
+
import { Context } from '@dxos/context';
|
|
7
8
|
import { invariant } from '@dxos/invariant';
|
|
8
9
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
9
10
|
import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
@@ -36,15 +37,15 @@ export type PerformInvitationCallbacks<T> = {
|
|
|
36
37
|
onError?: (value: T) => boolean | void;
|
|
37
38
|
};
|
|
38
39
|
|
|
39
|
-
export type
|
|
40
|
+
export type PerformInvitationProps = {
|
|
40
41
|
host: ServiceContext | InvitationHost;
|
|
41
42
|
guest: ServiceContext | InvitationGuest;
|
|
43
|
+
guestDeviceProfile?: DeviceProfileDocument;
|
|
42
44
|
options?: Partial<Invitation>;
|
|
43
45
|
hooks?: {
|
|
44
46
|
host?: PerformInvitationCallbacks<CancellableInvitation>;
|
|
45
47
|
guest?: PerformInvitationCallbacks<AuthenticatingInvitation>;
|
|
46
48
|
};
|
|
47
|
-
guestDeviceProfile?: DeviceProfileDocument;
|
|
48
49
|
codeInputDelay?: number;
|
|
49
50
|
};
|
|
50
51
|
|
|
@@ -52,14 +53,17 @@ export type Result = { invitation?: Invitation; error?: Error };
|
|
|
52
53
|
|
|
53
54
|
// TODO(burdon): Make async.
|
|
54
55
|
// TODO(burdon): Rename startInvitation.
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
55
59
|
export const performInvitation = ({
|
|
56
60
|
host,
|
|
57
61
|
guest,
|
|
62
|
+
guestDeviceProfile,
|
|
58
63
|
options,
|
|
59
64
|
hooks,
|
|
60
|
-
guestDeviceProfile,
|
|
61
65
|
codeInputDelay,
|
|
62
|
-
}:
|
|
66
|
+
}: PerformInvitationProps): [Promise<Result>, Promise<Result>] => {
|
|
63
67
|
let guestError = false;
|
|
64
68
|
let guestConnected = false;
|
|
65
69
|
let wereConnected = false;
|
|
@@ -226,7 +230,7 @@ export const createInvitation = async (
|
|
|
226
230
|
};
|
|
227
231
|
|
|
228
232
|
if (host instanceof ServiceContext) {
|
|
229
|
-
return host.invitationsManager.createInvitation({
|
|
233
|
+
return host.invitationsManager.createInvitation(new Context(), {
|
|
230
234
|
kind: Invitation.Kind.SPACE,
|
|
231
235
|
...options,
|
|
232
236
|
});
|
|
@@ -243,7 +247,7 @@ export const acceptInvitation = (
|
|
|
243
247
|
invitation = sanitizeInvitation(invitation);
|
|
244
248
|
|
|
245
249
|
if (guest instanceof ServiceContext) {
|
|
246
|
-
return guest.invitationsManager.acceptInvitation({
|
|
250
|
+
return guest.invitationsManager.acceptInvitation(new Context(), {
|
|
247
251
|
invitation,
|
|
248
252
|
deviceProfile: guestDeviceProfile,
|
|
249
253
|
});
|
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Reactivity from '@effect/experimental/Reactivity';
|
|
6
|
+
import * as Layer from 'effect/Layer';
|
|
7
|
+
import * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
8
|
+
|
|
5
9
|
import { type Config } from '@dxos/config';
|
|
6
10
|
import { Context } from '@dxos/context';
|
|
7
|
-
import {
|
|
11
|
+
import { CredentialGenerator, createCredentialSignerWithChain } from '@dxos/credentials';
|
|
8
12
|
import { failUndefined } from '@dxos/debug';
|
|
9
|
-
import { EchoHost, MetadataStore, SpaceManager, valueEncoding
|
|
13
|
+
import { EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from '@dxos/echo-pipeline';
|
|
10
14
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
11
15
|
import { Keyring } from '@dxos/keyring';
|
|
12
16
|
import { type LevelDB } from '@dxos/kv-store';
|
|
@@ -14,12 +18,14 @@ import { createTestLevel } from '@dxos/kv-store/testing';
|
|
|
14
18
|
import { MemorySignalManager, MemorySignalManagerContext, type SignalManager } from '@dxos/messaging';
|
|
15
19
|
import { MemoryTransportFactory, SwarmNetworkManager } from '@dxos/network-manager';
|
|
16
20
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
17
|
-
import {
|
|
21
|
+
import { type Storage, StorageType, createStorage } from '@dxos/random-access-storage';
|
|
22
|
+
import { layerMemory as sqliteLayerMemory } from '@dxos/sql-sqlite/platform';
|
|
23
|
+
import * as SqlTransaction from '@dxos/sql-sqlite/SqlTransaction';
|
|
18
24
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
19
25
|
|
|
20
26
|
import { InvitationsHandler, InvitationsManager, SpaceInvitationProtocol } from '../invitations';
|
|
21
|
-
import { ClientServicesHost, ServiceContext, type
|
|
22
|
-
import { DataSpaceManager, type
|
|
27
|
+
import { ClientServicesHost, ServiceContext, type ServiceContextRuntimeProps } from '../services';
|
|
28
|
+
import { DataSpaceManager, type DataSpaceManagerRuntimeProps, type SigningContext } from '../spaces';
|
|
23
29
|
|
|
24
30
|
//
|
|
25
31
|
// TODO(burdon): Replace with test builder.
|
|
@@ -30,6 +36,11 @@ export const createServiceHost = (config: Config, signalManagerContext: MemorySi
|
|
|
30
36
|
config,
|
|
31
37
|
signalManager: new MemorySignalManager(signalManagerContext),
|
|
32
38
|
transportFactory: MemoryTransportFactory,
|
|
39
|
+
runtime: ManagedRuntime.make(
|
|
40
|
+
SqlTransaction.layer
|
|
41
|
+
.pipe(Layer.provideMerge(sqliteLayerMemory), Layer.provideMerge(Reactivity.layer))
|
|
42
|
+
.pipe(Layer.orDie),
|
|
43
|
+
).runtimeEffect,
|
|
33
44
|
});
|
|
34
45
|
};
|
|
35
46
|
|
|
@@ -39,11 +50,11 @@ export const createServiceContext = async ({
|
|
|
39
50
|
return new MemorySignalManager(signalContext);
|
|
40
51
|
},
|
|
41
52
|
storage = createStorage({ type: StorageType.RAM }),
|
|
42
|
-
|
|
53
|
+
runtimeProps,
|
|
43
54
|
}: {
|
|
44
55
|
signalManagerFactory?: () => Promise<SignalManager>;
|
|
45
56
|
storage?: Storage;
|
|
46
|
-
|
|
57
|
+
runtimeProps?: ServiceContextRuntimeProps;
|
|
47
58
|
} = {}) => {
|
|
48
59
|
const signalManager = await signalManagerFactory();
|
|
49
60
|
const networkManager = new SwarmNetworkManager({
|
|
@@ -53,9 +64,15 @@ export const createServiceContext = async ({
|
|
|
53
64
|
const level = createTestLevel();
|
|
54
65
|
await level.open();
|
|
55
66
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
const runtime = ManagedRuntime.make(
|
|
68
|
+
SqlTransaction.layer
|
|
69
|
+
.pipe(Layer.provideMerge(sqliteLayerMemory), Layer.provideMerge(Reactivity.layer))
|
|
70
|
+
.pipe(Layer.orDie),
|
|
71
|
+
).runtimeEffect;
|
|
72
|
+
|
|
73
|
+
return new ServiceContext(storage, level, networkManager, signalManager, undefined, undefined, runtime, {
|
|
74
|
+
invitationConnectionDefaultProps: { teleport: { controlHeartbeatInterval: 200 } },
|
|
75
|
+
...runtimeProps,
|
|
59
76
|
});
|
|
60
77
|
};
|
|
61
78
|
|
|
@@ -95,7 +112,7 @@ export class TestBuilder {
|
|
|
95
112
|
|
|
96
113
|
export type TestPeerOpts = {
|
|
97
114
|
dataStore?: StorageType;
|
|
98
|
-
|
|
115
|
+
dataSpaceProps?: DataSpaceManagerRuntimeProps;
|
|
99
116
|
};
|
|
100
117
|
|
|
101
118
|
export type TestPeerProps = {
|
|
@@ -116,6 +133,11 @@ export type TestPeerProps = {
|
|
|
116
133
|
|
|
117
134
|
export class TestPeer {
|
|
118
135
|
private _props: TestPeerProps = {};
|
|
136
|
+
private readonly _runtime = ManagedRuntime.make(
|
|
137
|
+
SqlTransaction.layer
|
|
138
|
+
.pipe(Layer.provideMerge(sqliteLayerMemory), Layer.provideMerge(Reactivity.layer))
|
|
139
|
+
.pipe(Layer.orDie),
|
|
140
|
+
);
|
|
119
141
|
|
|
120
142
|
constructor(
|
|
121
143
|
private readonly _signalContext: MemorySignalManagerContext,
|
|
@@ -179,7 +201,10 @@ export class TestPeer {
|
|
|
179
201
|
}
|
|
180
202
|
|
|
181
203
|
get echoHost() {
|
|
182
|
-
return (this._props.echoHost ??= new EchoHost({
|
|
204
|
+
return (this._props.echoHost ??= new EchoHost({
|
|
205
|
+
kv: this.level,
|
|
206
|
+
runtime: this._runtime.runtimeEffect,
|
|
207
|
+
}));
|
|
183
208
|
}
|
|
184
209
|
|
|
185
210
|
get meshEchoReplicator() {
|
|
@@ -198,7 +223,7 @@ export class TestPeer {
|
|
|
198
223
|
edgeConnection: undefined,
|
|
199
224
|
meshReplicator: this.meshEchoReplicator,
|
|
200
225
|
echoEdgeReplicator: undefined,
|
|
201
|
-
|
|
226
|
+
runtimeProps: this._opts.dataSpaceProps,
|
|
202
227
|
}));
|
|
203
228
|
}
|
|
204
229
|
|
|
@@ -227,6 +252,7 @@ export class TestPeer {
|
|
|
227
252
|
async destroy(): Promise<void> {
|
|
228
253
|
await this.level.close();
|
|
229
254
|
await this.storage.reset();
|
|
255
|
+
await this._runtime.dispose();
|
|
230
256
|
}
|
|
231
257
|
}
|
|
232
258
|
|