@dxos/client-services 0.8.3 → 0.8.4-main.1da679c
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-LBG3C332.mjs → chunk-XT2YQZXS.mjs} +2792 -2227
- package/dist/lib/browser/chunk-XT2YQZXS.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +147 -103
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +74 -45
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{chunk-SKGQLRKS.mjs → chunk-MDSLKO5V.mjs} +2788 -2222
- package/dist/lib/node-esm/chunk-MDSLKO5V.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +147 -103
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +74 -45
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- 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 +18 -18
- 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/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/default-space-state-machine.d.ts +1 -1
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +1 -1
- 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/index.d.ts +1 -1
- package/dist/types/src/packlets/invitations/index.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 +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- 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 +1 -1
- 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 +1 -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.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +3 -3
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
- 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 +2 -2
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +4 -4
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/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.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +2 -2
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
- 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 +41 -39
- package/src/packlets/agents/edge-agent-manager.ts +2 -2
- package/src/packlets/agents/edge-agent-service.ts +2 -2
- package/src/packlets/devices/devices-service.test.ts +4 -3
- package/src/packlets/devices/devices-service.ts +1 -1
- package/src/packlets/devtools/devtools.ts +28 -27
- 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/identity/authenticator.node.test.ts +1 -1
- package/src/packlets/identity/authenticator.ts +1 -1
- package/src/packlets/identity/contacts-service.ts +3 -2
- package/src/packlets/identity/default-space-state-machine.ts +1 -1
- package/src/packlets/identity/identity-manager.test.ts +3 -3
- package/src/packlets/identity/identity-manager.ts +3 -3
- package/src/packlets/identity/identity-service.test.ts +3 -2
- package/src/packlets/identity/identity-service.ts +2 -1
- package/src/packlets/identity/identity.test.ts +5 -5
- package/src/packlets/identity/identity.ts +7 -6
- package/src/packlets/invitations/device-invitation-protocol.test.ts +4 -4
- package/src/packlets/invitations/device-invitation-protocol.ts +2 -1
- package/src/packlets/invitations/edge-invitation-handler.ts +1 -1
- package/src/packlets/invitations/index.ts +1 -1
- package/src/packlets/invitations/invitation-guest-extenstion.ts +1 -1
- package/src/packlets/invitations/invitation-host-extension.ts +2 -2
- package/src/packlets/invitations/invitation-protocol.ts +1 -1
- package/src/packlets/invitations/invitations-handler.test.ts +302 -292
- package/src/packlets/invitations/invitations-handler.ts +3 -3
- package/src/packlets/invitations/invitations-manager.ts +3 -3
- package/src/packlets/invitations/invitations-service.ts +1 -1
- package/src/packlets/invitations/space-invitation-protocol.test.ts +9 -9
- package/src/packlets/invitations/space-invitation-protocol.ts +3 -2
- 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 +3 -2
- 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 +2 -2
- package/src/packlets/services/client-rpc-server.ts +1 -1
- package/src/packlets/services/service-context.test.ts +1 -1
- package/src/packlets/services/service-context.ts +9 -8
- package/src/packlets/services/service-host.test.ts +3 -2
- package/src/packlets/services/service-host.ts +17 -14
- package/src/packlets/services/service-registry.test.ts +2 -1
- package/src/packlets/space-export/space-archive-reader.ts +1 -1
- package/src/packlets/space-export/space-archive-writer.ts +4 -4
- 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.ts +21 -16
- package/src/packlets/spaces/data-space.ts +9 -8
- package/src/packlets/spaces/edge-feed-replicator.test.ts +2 -2
- package/src/packlets/spaces/edge-feed-replicator.ts +1 -1
- package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
- package/src/packlets/spaces/notarization-plugin.ts +3 -3
- package/src/packlets/spaces/spaces-service.test.ts +3 -2
- package/src/packlets/spaces/spaces-service.ts +17 -16
- package/src/packlets/storage/profile-archive.ts +1 -1
- package/src/packlets/storage/storage.ts +3 -4
- 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 +1 -1
- package/src/packlets/testing/test-builder.ts +3 -3
- package/src/packlets/worker/worker-runtime.ts +2 -1
- package/src/packlets/worker/worker-session.ts +4 -4
- package/src/version.ts +1 -5
- package/README.yml +0 -5
- package/dist/lib/browser/chunk-LBG3C332.mjs.map +0 -7
- package/dist/lib/node/chunk-LMGLGOUU.cjs +0 -9311
- package/dist/lib/node/chunk-LMGLGOUU.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -437
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/testing/index.cjs +0 -452
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-SKGQLRKS.mjs.map +0 -7
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type PushStream,
|
|
5
|
+
import { type PushStream, TimeoutError, type Trigger, scheduleTask } from '@dxos/async';
|
|
6
6
|
import { INVITATION_TIMEOUT, getExpirationTime } from '@dxos/client-protocol';
|
|
7
7
|
import { type Context, ContextDisposedError } from '@dxos/context';
|
|
8
8
|
import { createKeyPair, sign } from '@dxos/crypto';
|
|
@@ -10,7 +10,7 @@ import { type EdgeHttpClient } from '@dxos/edge-client';
|
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import { PublicKey } from '@dxos/keys';
|
|
12
12
|
import { log } from '@dxos/log';
|
|
13
|
-
import {
|
|
13
|
+
import { type SwarmConnection, type SwarmNetworkManager, createTeleportProtocolFactory } from '@dxos/network-manager';
|
|
14
14
|
import { InvalidInvitationError, InvalidInvitationExtensionRoleError, trace } from '@dxos/protocols';
|
|
15
15
|
import { type AdmissionKeypair, Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
16
16
|
import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
@@ -22,7 +22,7 @@ import { ComplexSet } from '@dxos/util';
|
|
|
22
22
|
|
|
23
23
|
import { type EdgeInvitationConfig, EdgeInvitationHandler } from './edge-invitation-handler';
|
|
24
24
|
import { InvitationGuestExtension } from './invitation-guest-extenstion';
|
|
25
|
-
import { InvitationHostExtension,
|
|
25
|
+
import { InvitationHostExtension, MAX_OTP_ATTEMPTS, isAuthenticationRequired } from './invitation-host-extension';
|
|
26
26
|
import { type InvitationProtocol } from './invitation-protocol';
|
|
27
27
|
import { createGuardedInvitationState } from './invitation-state';
|
|
28
28
|
import { InvitationTopology } from './invitation-topology';
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import { Event, PushStream, TimeoutError, Trigger } from '@dxos/async';
|
|
6
6
|
import {
|
|
7
|
-
AuthenticatingInvitation,
|
|
8
7
|
AUTHENTICATION_CODE_LENGTH,
|
|
8
|
+
AuthenticatingInvitation,
|
|
9
9
|
CancellableInvitation,
|
|
10
10
|
INVITATION_TIMEOUT,
|
|
11
11
|
} from '@dxos/client-protocol';
|
|
12
12
|
import { Context } from '@dxos/context';
|
|
13
13
|
import { generatePasscode } from '@dxos/credentials';
|
|
14
|
-
import {
|
|
14
|
+
import { type MetadataStore, hasInvitationExpired } from '@dxos/echo-pipeline';
|
|
15
15
|
import { invariant } from '@dxos/invariant';
|
|
16
16
|
import { PublicKey } from '@dxos/keys';
|
|
17
17
|
import { log } from '@dxos/log';
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import { SpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
24
24
|
|
|
25
25
|
import type { InvitationProtocol } from './invitation-protocol';
|
|
26
|
-
import {
|
|
26
|
+
import { type InvitationsHandler, createAdmissionKeypair } from './invitations-handler';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Entry point for creating and accepting invitations, keeps track of existing invitation set and
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Trigger, chain } from '@dxos/async';
|
|
8
8
|
import { raise } from '@dxos/debug';
|
|
9
9
|
import { AlreadyJoinedError } from '@dxos/protocols';
|
|
10
10
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
@@ -22,7 +22,7 @@ const closeAfterTest = async (peer: ServiceContext) => {
|
|
|
22
22
|
|
|
23
23
|
describe('services/space-invitations-protocol', () => {
|
|
24
24
|
test('genesis', async () => {
|
|
25
|
-
const [peer] = await
|
|
25
|
+
const [peer] = await chain<ServiceContext>([createIdentity, closeAfterTest])(createPeers(1));
|
|
26
26
|
|
|
27
27
|
const space = await peer.dataSpaceManager!.createSpace();
|
|
28
28
|
expect(peer.dataSpaceManager!.spaces.has(space.key)).to.be.true;
|
|
@@ -31,7 +31,7 @@ describe('services/space-invitations-protocol', () => {
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
test('genesis & ready', async () => {
|
|
34
|
-
const [peer] = await
|
|
34
|
+
const [peer] = await chain<ServiceContext>([createIdentity, closeAfterTest])(createPeers(1));
|
|
35
35
|
|
|
36
36
|
const space = await peer.dataSpaceManager!.createSpace();
|
|
37
37
|
expect(peer.dataSpaceManager!.spaces.has(space.key)).to.be.true;
|
|
@@ -41,7 +41,7 @@ describe('services/space-invitations-protocol', () => {
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
test('invitation with no auth', async () => {
|
|
44
|
-
const [host, guest] = await
|
|
44
|
+
const [host, guest] = await chain<ServiceContext>([createIdentity, closeAfterTest])(createPeers(2));
|
|
45
45
|
|
|
46
46
|
const space1 = await host.dataSpaceManager!.createSpace();
|
|
47
47
|
const spaceKey = space1.key;
|
|
@@ -65,7 +65,7 @@ describe('services/space-invitations-protocol', () => {
|
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
test('invitation when already joined', async () => {
|
|
68
|
-
const [host, guest] = await
|
|
68
|
+
const [host, guest] = await chain<ServiceContext>([createIdentity, closeAfterTest])(createPeers(2));
|
|
69
69
|
|
|
70
70
|
const space1 = await host.dataSpaceManager!.createSpace();
|
|
71
71
|
const spaceKey = space1.key;
|
|
@@ -92,7 +92,7 @@ describe('services/space-invitations-protocol', () => {
|
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
test('creates and accepts invitation with retry', async () => {
|
|
95
|
-
const [host, guest] = await
|
|
95
|
+
const [host, guest] = await chain<ServiceContext>([createIdentity, closeAfterTest])(createPeers(2));
|
|
96
96
|
|
|
97
97
|
let attempt = 0;
|
|
98
98
|
|
|
@@ -153,7 +153,7 @@ describe('services/space-invitations-protocol', () => {
|
|
|
153
153
|
});
|
|
154
154
|
|
|
155
155
|
test('timeout', async () => {
|
|
156
|
-
const [host, guest] = await
|
|
156
|
+
const [host, guest] = await chain<ServiceContext>([createIdentity, closeAfterTest])(createPeers(2));
|
|
157
157
|
const space = await host.dataSpaceManager!.createSpace();
|
|
158
158
|
const hostInvitation = await createInvitation(host, {
|
|
159
159
|
kind: Invitation.Kind.SPACE,
|
|
@@ -175,7 +175,7 @@ describe('services/space-invitations-protocol', () => {
|
|
|
175
175
|
});
|
|
176
176
|
|
|
177
177
|
test('cancels invitation', async () => {
|
|
178
|
-
const [host, guest] = await
|
|
178
|
+
const [host, guest] = await chain<ServiceContext>([createIdentity, closeAfterTest])(createPeers(2));
|
|
179
179
|
|
|
180
180
|
const hostConnected = new Trigger<Invitation>();
|
|
181
181
|
const guestConnected = new Trigger<Invitation>();
|
|
@@ -20,16 +20,17 @@ import {
|
|
|
20
20
|
SpaceNotFoundError,
|
|
21
21
|
} from '@dxos/protocols';
|
|
22
22
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
23
|
-
import {
|
|
23
|
+
import { type ProfileDocument, SpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
24
24
|
import {
|
|
25
25
|
type AdmissionRequest,
|
|
26
26
|
type AdmissionResponse,
|
|
27
27
|
type IntroductionRequest,
|
|
28
28
|
} from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
29
29
|
|
|
30
|
+
import { type DataSpaceManager, type SigningContext } from '../spaces';
|
|
31
|
+
|
|
30
32
|
import { type InvitationProtocol } from './invitation-protocol';
|
|
31
33
|
import { computeExpirationTime } from './utils';
|
|
32
|
-
import { type DataSpaceManager, type SigningContext } from '../spaces';
|
|
33
34
|
|
|
34
35
|
export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
35
36
|
constructor(
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Mutex, type MutexGuard } from '@dxos/async';
|
|
6
|
-
import {
|
|
6
|
+
import { type Context, ContextDisposedError, cancelWithContext } from '@dxos/context';
|
|
7
7
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
8
8
|
|
|
9
9
|
export const stateToString = (state: Invitation.State): string => {
|
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
log,
|
|
14
14
|
} from '@dxos/log';
|
|
15
15
|
import {
|
|
16
|
+
type ControlMetricsRequest,
|
|
17
|
+
type ControlMetricsResponse,
|
|
16
18
|
type LogEntry,
|
|
17
19
|
type LoggingService,
|
|
18
20
|
type Metrics,
|
|
19
21
|
QueryLogsRequest,
|
|
20
|
-
type ControlMetricsRequest,
|
|
21
|
-
type ControlMetricsResponse,
|
|
22
22
|
type QueryMetricsRequest,
|
|
23
23
|
type QueryMetricsResponse,
|
|
24
24
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
@@ -112,6 +112,7 @@ export class LoggingServiceImpl implements LoggingService {
|
|
|
112
112
|
|
|
113
113
|
const record: LogEntry = {
|
|
114
114
|
...entry,
|
|
115
|
+
message: entry.message ?? (entry.error ? (entry.error.message ?? String(entry.error)) : ''),
|
|
115
116
|
context: jsonify(getContextFromEntry(entry)),
|
|
116
117
|
timestamp: new Date(),
|
|
117
118
|
meta: {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { afterEach, beforeEach, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
|
-
import {
|
|
8
|
+
import { LogLevel, log } from '@dxos/log';
|
|
9
9
|
import { type LogEntry } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
10
|
|
|
11
11
|
import { LoggingServiceImpl } from './logging-service';
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { afterEach,
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
|
-
import { type NetworkService
|
|
9
|
+
import { ConnectionState, type NetworkService } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
10
|
|
|
11
|
-
import { NetworkServiceImpl } from './network-service';
|
|
12
11
|
import { type ServiceContext } from '../services';
|
|
13
12
|
import { createServiceContext } from '../testing';
|
|
14
13
|
|
|
14
|
+
import { NetworkServiceImpl } from './network-service';
|
|
15
|
+
|
|
15
16
|
describe('NetworkService', () => {
|
|
16
17
|
let serviceContext: ServiceContext;
|
|
17
18
|
let networkService: NetworkService;
|
|
@@ -7,15 +7,15 @@ import { type EdgeConnection } from '@dxos/edge-client';
|
|
|
7
7
|
import { type SignalManager } from '@dxos/messaging';
|
|
8
8
|
import { type SwarmNetworkManager } from '@dxos/network-manager';
|
|
9
9
|
import {
|
|
10
|
-
type SubscribeSwarmStateRequest,
|
|
11
10
|
type NetworkService,
|
|
12
11
|
type NetworkStatus,
|
|
12
|
+
type SubscribeSwarmStateRequest,
|
|
13
13
|
type UpdateConfigRequest,
|
|
14
14
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
15
15
|
import { type Peer, type SwarmResponse } from '@dxos/protocols/proto/dxos/edge/messenger';
|
|
16
16
|
import {
|
|
17
|
-
type LeaveRequest,
|
|
18
17
|
type JoinRequest,
|
|
18
|
+
type LeaveRequest,
|
|
19
19
|
type Message,
|
|
20
20
|
type QueryRequest,
|
|
21
21
|
} from '@dxos/protocols/proto/dxos/edge/signal';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type ClientServices } from '@dxos/client-protocol';
|
|
6
6
|
import { type Any, type ServiceHandler, Stream } from '@dxos/codec-protobuf';
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
|
-
import {
|
|
8
|
+
import { RpcPeer, type RpcPeerOptions, type ServiceBundle, parseMethodName } from '@dxos/rpc';
|
|
9
9
|
import { MapCounter, trace } from '@dxos/tracing';
|
|
10
10
|
import { type MaybePromise } from '@dxos/util';
|
|
11
11
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
|
|
8
8
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
9
9
|
import { openAndClose } from '@dxos/test-utils';
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Mutex, Trigger } from '@dxos/async';
|
|
6
6
|
import { Context, Resource } from '@dxos/context';
|
|
7
|
-
import {
|
|
7
|
+
import { type CredentialProcessor, getCredentialAssertion } from '@dxos/credentials';
|
|
8
8
|
import { failUndefined, warnAfterTimeout } from '@dxos/debug';
|
|
9
9
|
import {
|
|
10
10
|
EchoEdgeReplicator,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
valueEncoding,
|
|
16
16
|
} from '@dxos/echo-pipeline';
|
|
17
17
|
import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from '@dxos/edge-client';
|
|
18
|
-
import type {
|
|
18
|
+
import type { EdgeConnection, EdgeHttpClient, EdgeIdentity } from '@dxos/edge-client';
|
|
19
19
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
20
20
|
import { invariant } from '@dxos/invariant';
|
|
21
21
|
import { Keyring } from '@dxos/keyring';
|
|
@@ -36,8 +36,8 @@ import { safeInstanceof } from '@dxos/util';
|
|
|
36
36
|
|
|
37
37
|
import { EdgeAgentManager } from '../agents';
|
|
38
38
|
import {
|
|
39
|
-
IdentityManager,
|
|
40
39
|
type CreateIdentityOptions,
|
|
40
|
+
IdentityManager,
|
|
41
41
|
type IdentityManagerParams,
|
|
42
42
|
type JoinIdentityParams,
|
|
43
43
|
} from '../identity';
|
|
@@ -45,10 +45,10 @@ import { EdgeIdentityRecoveryManager } from '../identity/identity-recovery-manag
|
|
|
45
45
|
import {
|
|
46
46
|
DeviceInvitationProtocol,
|
|
47
47
|
type InvitationConnectionParams,
|
|
48
|
+
type InvitationProtocol,
|
|
48
49
|
InvitationsHandler,
|
|
49
50
|
InvitationsManager,
|
|
50
51
|
SpaceInvitationProtocol,
|
|
51
|
-
type InvitationProtocol,
|
|
52
52
|
} from '../invitations';
|
|
53
53
|
import { DataSpaceManager, type DataSpaceManagerRuntimeParams, type SigningContext } from '../spaces';
|
|
54
54
|
|
|
@@ -189,9 +189,10 @@ export class ServiceContext extends Resource {
|
|
|
189
189
|
if (!this._runtimeParams?.disableP2pReplication) {
|
|
190
190
|
this._meshReplicator = new MeshEchoReplicator();
|
|
191
191
|
}
|
|
192
|
-
if (this._edgeConnection && this._edgeFeatures?.echoReplicator) {
|
|
192
|
+
if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
|
|
193
193
|
this._echoEdgeReplicator = new EchoEdgeReplicator({
|
|
194
194
|
edgeConnection: this._edgeConnection,
|
|
195
|
+
edgeHttpClient: this._edgeHttpClient,
|
|
195
196
|
});
|
|
196
197
|
}
|
|
197
198
|
}
|
|
@@ -244,13 +245,13 @@ export class ServiceContext extends Resource {
|
|
|
244
245
|
await this.edgeAgentManager?.close();
|
|
245
246
|
await this.identityManager.close();
|
|
246
247
|
await this.spaceManager.close();
|
|
247
|
-
await this.feedStore.close();
|
|
248
|
-
await this.metadataStore.close();
|
|
249
|
-
|
|
250
248
|
await this.echoHost.close(ctx);
|
|
249
|
+
|
|
251
250
|
await this.networkManager.close();
|
|
252
251
|
await this.signalManager.close();
|
|
253
252
|
await this._edgeConnection?.close();
|
|
253
|
+
await this.feedStore.close();
|
|
254
|
+
await this.metadataStore.close();
|
|
254
255
|
|
|
255
256
|
log('closed');
|
|
256
257
|
}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { rmSync } from 'node:fs';
|
|
6
|
-
import { afterEach, onTestFinished, describe, expect, test } from 'vitest';
|
|
7
6
|
|
|
8
|
-
import {
|
|
7
|
+
import { afterEach, describe, expect, onTestFinished, test } from 'vitest';
|
|
8
|
+
|
|
9
|
+
import { Trigger, asyncTimeout, latch } from '@dxos/async';
|
|
9
10
|
import { Config } from '@dxos/config';
|
|
10
11
|
import { Context } from '@dxos/context';
|
|
11
12
|
import { verifyPresentation } from '@dxos/credentials';
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Event, synchronized } from '@dxos/async';
|
|
6
|
-
import {
|
|
6
|
+
import { type ClientServices, clientServiceBundle } from '@dxos/client-protocol';
|
|
7
7
|
import { type Config } from '@dxos/config';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
|
-
import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity
|
|
9
|
+
import { EdgeClient, type EdgeConnection, EdgeHttpClient, createStubEdgeIdentity } from '@dxos/edge-client';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import { PublicKey } from '@dxos/keys';
|
|
12
12
|
import { type LevelDB } from '@dxos/kv-store';
|
|
13
13
|
import { log } from '@dxos/log';
|
|
14
|
-
import { EdgeSignalManager,
|
|
14
|
+
import { EdgeSignalManager, type SignalManager, WebsocketSignalManager } from '@dxos/messaging';
|
|
15
15
|
import {
|
|
16
16
|
SwarmNetworkManager,
|
|
17
|
+
type TransportFactory,
|
|
17
18
|
createIceProvider,
|
|
18
19
|
createRtcTransportFactory,
|
|
19
|
-
type TransportFactory,
|
|
20
20
|
} from '@dxos/network-manager';
|
|
21
21
|
import { trace } from '@dxos/protocols';
|
|
22
22
|
import { SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
@@ -24,17 +24,15 @@ import { type Storage } from '@dxos/random-access-storage';
|
|
|
24
24
|
import { TRACE_PROCESSOR, trace as Trace } from '@dxos/tracing';
|
|
25
25
|
import { WebsocketRpcClient } from '@dxos/websocket-rpc';
|
|
26
26
|
|
|
27
|
-
import { ServiceContext, type ServiceContextRuntimeParams } from './service-context';
|
|
28
|
-
import { ServiceRegistry } from './service-registry';
|
|
29
27
|
import { EdgeAgentServiceImpl } from '../agents';
|
|
30
28
|
import { DevicesServiceImpl } from '../devices';
|
|
31
29
|
import { DevtoolsHostEvents, DevtoolsServiceImpl } from '../devtools';
|
|
32
30
|
import {
|
|
31
|
+
type CollectDiagnosticsBroadcastHandler,
|
|
33
32
|
createCollectDiagnosticsBroadcastHandler,
|
|
34
33
|
createDiagnostics,
|
|
35
|
-
type CollectDiagnosticsBroadcastHandler,
|
|
36
34
|
} from '../diagnostics';
|
|
37
|
-
import {
|
|
35
|
+
import { type CreateIdentityOptions, IdentityServiceImpl } from '../identity';
|
|
38
36
|
import { ContactsServiceImpl } from '../identity/contacts-service';
|
|
39
37
|
import { InvitationsServiceImpl } from '../invitations';
|
|
40
38
|
import { Lock, type ResourceLock } from '../locks';
|
|
@@ -44,6 +42,9 @@ import { SpacesServiceImpl } from '../spaces';
|
|
|
44
42
|
import { createLevel, createStorageObjects } from '../storage';
|
|
45
43
|
import { SystemServiceImpl } from '../system';
|
|
46
44
|
|
|
45
|
+
import { ServiceContext, type ServiceContextRuntimeParams } from './service-context';
|
|
46
|
+
import { ServiceRegistry } from './service-registry';
|
|
47
|
+
|
|
47
48
|
export type ClientServicesHostParams = {
|
|
48
49
|
/**
|
|
49
50
|
* Can be omitted if `initialize` is later called.
|
|
@@ -81,8 +82,9 @@ export class ClientServicesHost {
|
|
|
81
82
|
private readonly _loggingService: LoggingServiceImpl;
|
|
82
83
|
private readonly _tracingService = TRACE_PROCESSOR.createTraceSender();
|
|
83
84
|
|
|
84
|
-
private _config?: Config;
|
|
85
85
|
private readonly _statusUpdate = new Event<void>();
|
|
86
|
+
|
|
87
|
+
private _config?: Config;
|
|
86
88
|
private _signalManager?: SignalManager;
|
|
87
89
|
private _networkManager?: SwarmNetworkManager;
|
|
88
90
|
private _storage?: Storage;
|
|
@@ -215,14 +217,15 @@ export class ClientServicesHost {
|
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
219
|
|
|
220
|
+
// TODO(wittjosiah): This is quite noisy during tests. Make configurable? Remove?
|
|
218
221
|
if (!options.signalManager) {
|
|
219
|
-
log.warn('running signaling without telemetry metadata.');
|
|
222
|
+
// log.warn('running signaling without telemetry metadata.');
|
|
220
223
|
}
|
|
221
224
|
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
this._edgeConnection = new EdgeClient(createStubEdgeIdentity(), { socketEndpoint:
|
|
225
|
-
this._edgeHttpClient = new EdgeHttpClient(
|
|
225
|
+
const endpoint = config?.get('runtime.services.edge.url');
|
|
226
|
+
if (endpoint) {
|
|
227
|
+
this._edgeConnection = new EdgeClient(createStubEdgeIdentity(), { socketEndpoint: endpoint });
|
|
228
|
+
this._edgeHttpClient = new EdgeHttpClient(endpoint);
|
|
226
229
|
}
|
|
227
230
|
|
|
228
231
|
const {
|
|
@@ -13,10 +13,11 @@ import { schema } from '@dxos/protocols/proto';
|
|
|
13
13
|
import { type SystemService, SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
14
14
|
import { createLinkedPorts, createProtoRpcPeer, createServiceBundle } from '@dxos/rpc';
|
|
15
15
|
|
|
16
|
-
import { ServiceRegistry } from './service-registry';
|
|
17
16
|
import { SystemServiceImpl } from '../system';
|
|
18
17
|
import { createServiceContext } from '../testing';
|
|
19
18
|
|
|
19
|
+
import { ServiceRegistry } from './service-registry';
|
|
20
|
+
|
|
20
21
|
// TODO(burdon): Create TestService (that doesn't require peers).
|
|
21
22
|
|
|
22
23
|
type TestServices = {
|
|
@@ -18,7 +18,7 @@ export const extractSpaceArchive = async (archive: SpaceArchive): Promise<Extrac
|
|
|
18
18
|
const { Archive } = await import('@obsidize/tar-browserify');
|
|
19
19
|
const { entries } = await Archive.extract(archive.contents);
|
|
20
20
|
const metadataEntry = entries.find((entry) => entry.fileName === SpaceArchiveFileStructure.metadata);
|
|
21
|
-
assertArgument(metadataEntry, 'Metadata entry not found');
|
|
21
|
+
assertArgument(metadataEntry, 'metadataEntry', 'Metadata entry not found');
|
|
22
22
|
const metadata = JSON.parse(metadataEntry.getContentAsText());
|
|
23
23
|
const documents: Record<DocumentId, Uint8Array> = {};
|
|
24
24
|
for (const entry of entries.filter((entry) => entry.fileName.startsWith(`${SpaceArchiveFileStructure.documents}/`))) {
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import type * as tar from '@obsidize/tar-browserify';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { type Context, Resource } from '@dxos/context';
|
|
8
8
|
import { assertArgument, assertState } from '@dxos/invariant';
|
|
9
9
|
import type { IdentityDid, SpaceId } from '@dxos/keys';
|
|
10
|
-
import { SpaceArchiveFileStructure,
|
|
10
|
+
import { SpaceArchiveFileStructure, type SpaceArchiveMetadata, SpaceArchiveVersion } from '@dxos/protocols';
|
|
11
11
|
import type { SpaceArchive } from '@dxos/protocols/proto/dxos/client/services';
|
|
12
12
|
|
|
13
13
|
export type SpaceArchiveBeginProps = {
|
|
@@ -44,14 +44,14 @@ export class SpaceArchiveWriter extends Resource {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
async setCurrentRootUrl(url: string): Promise<void> {
|
|
47
|
-
assertArgument(url.startsWith('automerge:'), 'Invalid root URL');
|
|
47
|
+
assertArgument(url.startsWith('automerge:'), 'url', 'Invalid root URL');
|
|
48
48
|
assertState(this._tar, 'Not open');
|
|
49
49
|
assertState(this._meta, 'Not started');
|
|
50
50
|
this._currentRootUrl = url;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
async writeDocument(documentId: string, data: Uint8Array): Promise<void> {
|
|
54
|
-
assertArgument(!documentId.startsWith('automerge:'), 'Invalid document ID');
|
|
54
|
+
assertArgument(!documentId.startsWith('automerge:'), 'documentId', 'Invalid document ID');
|
|
55
55
|
assertState(this._archive, 'Not open');
|
|
56
56
|
this._archive.addBinaryFile(`${SpaceArchiveFileStructure.documents}/${documentId}.bin`, data);
|
|
57
57
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Event } from '@dxos/async';
|
|
6
|
-
import {
|
|
6
|
+
import { type Context, Resource } from '@dxos/context';
|
|
7
7
|
import { type CredentialProcessor, type SpecificCredential, checkCredentialType } from '@dxos/credentials';
|
|
8
8
|
import { type Credential, type Epoch } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
9
9
|
|
|
@@ -3,43 +3,43 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Doc } from '@automerge/automerge';
|
|
6
|
-
import {
|
|
6
|
+
import { type AutomergeUrl, type DocHandle, type DocumentId, interpretAsDocumentId } from '@automerge/automerge-repo';
|
|
7
7
|
|
|
8
8
|
import { Event, synchronized, trackLeaks } from '@dxos/async';
|
|
9
9
|
import { PropertiesType, TYPE_PROPERTIES } from '@dxos/client-protocol';
|
|
10
10
|
import { Context, LifecycleState, Resource, cancelWithContext } from '@dxos/context';
|
|
11
11
|
import {
|
|
12
|
-
createAdmissionCredentials,
|
|
13
|
-
getCredentialAssertion,
|
|
14
12
|
type CredentialSigner,
|
|
15
13
|
type DelegateInvitationCredential,
|
|
16
14
|
type MemberInfo,
|
|
15
|
+
createAdmissionCredentials,
|
|
16
|
+
getCredentialAssertion,
|
|
17
17
|
} from '@dxos/credentials';
|
|
18
18
|
import {
|
|
19
|
+
AuthStatus,
|
|
20
|
+
CredentialServerExtension,
|
|
19
21
|
DatabaseRoot,
|
|
20
|
-
findInlineObjectOfType,
|
|
21
22
|
type EchoEdgeReplicator,
|
|
22
23
|
type EchoHost,
|
|
23
|
-
|
|
24
|
-
CredentialServerExtension,
|
|
24
|
+
FIND_PARAMS,
|
|
25
25
|
type MeshEchoReplicator,
|
|
26
26
|
type MetadataStore,
|
|
27
27
|
type Space,
|
|
28
28
|
type SpaceManager,
|
|
29
29
|
type SpaceProtocol,
|
|
30
30
|
type SpaceProtocolSession,
|
|
31
|
-
|
|
31
|
+
findInlineObjectOfType,
|
|
32
32
|
} from '@dxos/echo-pipeline';
|
|
33
33
|
import {
|
|
34
|
+
type DatabaseDirectory,
|
|
35
|
+
type ObjectStructure,
|
|
34
36
|
SpaceDocVersion,
|
|
35
37
|
createIdFromSpaceKey,
|
|
36
38
|
encodeReference,
|
|
37
|
-
type ObjectStructure,
|
|
38
|
-
type DatabaseDirectory,
|
|
39
39
|
} from '@dxos/echo-protocol';
|
|
40
40
|
import { ObjectId, getTypeReference } from '@dxos/echo-schema';
|
|
41
41
|
import type { EdgeConnection, EdgeHttpClient } from '@dxos/edge-client';
|
|
42
|
-
import {
|
|
42
|
+
import { type FeedStore, writeMessages } from '@dxos/feed-store';
|
|
43
43
|
import { assertArgument, assertState, failedInvariant, invariant } from '@dxos/invariant';
|
|
44
44
|
import { type Keyring } from '@dxos/keyring';
|
|
45
45
|
import { PublicKey, type SpaceId } from '@dxos/keys';
|
|
@@ -48,21 +48,22 @@ import { AlreadyJoinedError, trace as Trace } from '@dxos/protocols';
|
|
|
48
48
|
import { Invitation, SpaceState } from '@dxos/protocols/proto/dxos/client/services';
|
|
49
49
|
import { type Runtime } from '@dxos/protocols/proto/dxos/config';
|
|
50
50
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
51
|
-
import { type SpaceMetadata
|
|
52
|
-
import {
|
|
51
|
+
import { EdgeReplicationSetting, type SpaceMetadata } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
52
|
+
import { type Credential, type ProfileDocument, SpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
53
53
|
import { type DelegateSpaceInvitation } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
54
54
|
import { type PeerState } from '@dxos/protocols/proto/dxos/mesh/presence';
|
|
55
55
|
import { type Teleport } from '@dxos/teleport';
|
|
56
56
|
import { Gossip, Presence } from '@dxos/teleport-extension-gossip';
|
|
57
57
|
import { type Timeframe } from '@dxos/timeframe';
|
|
58
58
|
import { trace } from '@dxos/tracing';
|
|
59
|
-
import { ComplexMap,
|
|
59
|
+
import { ComplexMap, deferFunction, forEachAsync, setDeep } from '@dxos/util';
|
|
60
60
|
|
|
61
|
-
import { DataSpace } from './data-space';
|
|
62
|
-
import { spaceGenesis } from './genesis';
|
|
63
61
|
import { createAuthProvider } from '../identity';
|
|
64
62
|
import { type InvitationsManager } from '../invitations';
|
|
65
63
|
|
|
64
|
+
import { DataSpace } from './data-space';
|
|
65
|
+
import { spaceGenesis } from './genesis';
|
|
66
|
+
|
|
66
67
|
const PRESENCE_ANNOUNCE_INTERVAL = 10_000;
|
|
67
68
|
const PRESENCE_OFFLINE_TIMEOUT = 20_000;
|
|
68
69
|
|
|
@@ -244,7 +245,11 @@ export class DataSpaceManager extends Resource {
|
|
|
244
245
|
*/
|
|
245
246
|
@synchronized
|
|
246
247
|
async createSpace(options: CreateSpaceOptions = {}): Promise<DataSpace> {
|
|
247
|
-
assertArgument(
|
|
248
|
+
assertArgument(
|
|
249
|
+
!!options.rootUrl === !!options.documents,
|
|
250
|
+
'options',
|
|
251
|
+
'root url must be required when providing documents',
|
|
252
|
+
);
|
|
248
253
|
|
|
249
254
|
assertState(this._lifecycleState === LifecycleState.OPEN, 'Not open.');
|
|
250
255
|
const spaceKey = await this._keyring.createKey();
|