@dxos/client-services 0.6.11 → 0.6.12-main.15a606f
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-QYVLLBAA.mjs → chunk-BDGSOBZV.mjs} +5136 -5087
- package/dist/lib/browser/chunk-BDGSOBZV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3 -3
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +4 -5
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node/{chunk-F7G2TXVG.cjs → chunk-EBZ7KFXS.cjs} +4908 -4859
- package/dist/lib/node/chunk-EBZ7KFXS.cjs.map +7 -0
- package/dist/lib/node/index.cjs +46 -46
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +11 -12
- package/dist/lib/node/testing/index.cjs.map +2 -2
- package/dist/lib/node-esm/chunk-LDBJYNPL.mjs +7765 -0
- package/dist/lib/node-esm/chunk-LDBJYNPL.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +416 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/testing/index.mjs +418 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.node.test.d.ts +2 -0
- package/dist/types/src/packlets/identity/authenticator.node.test.d.ts.map +1 -0
- package/dist/types/src/packlets/identity/identity-manager.d.ts +19 -7
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +7 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +3 -4
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +1 -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 +1 -2
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +1 -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/testing/setup.d.ts +3 -0
- package/dist/types/src/testing/setup.d.ts.map +1 -0
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +42 -39
- package/src/packlets/devices/devices-service.test.ts +4 -5
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +1 -0
- package/src/packlets/identity/{authenticator.test.ts → authenticator.node.test.ts} +2 -3
- package/src/packlets/identity/identity-manager.test.ts +5 -6
- package/src/packlets/identity/identity-manager.ts +35 -19
- package/src/packlets/identity/identity-service.test.ts +4 -8
- package/src/packlets/identity/identity.test.ts +124 -239
- package/src/packlets/identity/identity.ts +38 -8
- package/src/packlets/invitations/device-invitation-protocol.test.ts +7 -4
- package/src/packlets/invitations/invitation-host-extension.ts +0 -3
- package/src/packlets/invitations/invitations-handler.test.ts +14 -7
- package/src/packlets/invitations/invitations-handler.ts +1 -1
- package/src/packlets/invitations/space-invitation-protocol.test.ts +4 -3
- package/src/packlets/logging/logging.test.ts +1 -2
- package/src/packlets/network/network-service.test.ts +2 -3
- package/src/packlets/services/service-context.test.ts +3 -1
- package/src/packlets/services/service-context.ts +24 -12
- package/src/packlets/services/service-host.test.ts +8 -12
- package/src/packlets/services/service-host.ts +2 -2
- package/src/packlets/services/service-registry.test.ts +1 -2
- package/src/packlets/spaces/data-space-manager.test.ts +2 -2
- package/src/packlets/spaces/data-space-manager.ts +4 -1
- package/src/packlets/spaces/data-space.ts +7 -2
- package/src/packlets/spaces/edge-feed-replicator.ts +9 -4
- package/src/packlets/spaces/epoch-migrations.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.test.ts +2 -3
- package/src/packlets/spaces/spaces-service.test.ts +5 -9
- package/src/packlets/storage/storage.ts +0 -1
- package/src/packlets/system/system-service.test.ts +1 -2
- package/src/packlets/testing/test-builder.ts +1 -2
- package/src/packlets/worker/worker-runtime.ts +2 -2
- package/src/testing/setup.ts +11 -0
- package/src/version.ts +1 -5
- package/dist/lib/browser/chunk-QYVLLBAA.mjs.map +0 -7
- package/dist/lib/node/chunk-F7G2TXVG.cjs.map +0 -7
- package/dist/types/src/packlets/identity/authenticator.test.d.ts +0 -2
- package/dist/types/src/packlets/identity/authenticator.test.d.ts.map +0 -1
- package/dist/types/src/packlets/services/automerge-host.test.d.ts +0 -2
- package/dist/types/src/packlets/services/automerge-host.test.d.ts.map +0 -1
- package/src/packlets/services/automerge-host.test.ts +0 -60
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { onTestFinished, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { asyncChain, Trigger } 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';
|
|
11
|
-
import { afterTest, describe, test } from '@dxos/test';
|
|
12
11
|
|
|
13
12
|
import { type ServiceContext } from '../services';
|
|
14
13
|
import { createIdentity, createPeers } from '../testing';
|
|
15
14
|
import { acceptInvitation, createInvitation, performInvitation } from '../testing/invitation-utils';
|
|
16
15
|
|
|
17
16
|
const closeAfterTest = async (peer: ServiceContext) => {
|
|
18
|
-
|
|
17
|
+
onTestFinished(async () => {
|
|
18
|
+
await peer.close();
|
|
19
|
+
});
|
|
19
20
|
return peer;
|
|
20
21
|
};
|
|
21
22
|
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { log, LogLevel } from '@dxos/log';
|
|
9
9
|
import { type LogEntry } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
|
-
import { beforeEach, describe, test } from '@dxos/test';
|
|
11
10
|
|
|
12
11
|
import { LoggingServiceImpl } from './logging-service';
|
|
13
12
|
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { afterEach, onTestFinished, beforeEach, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { type NetworkService, ConnectionState } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
|
-
import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
|
|
11
10
|
|
|
12
11
|
import { NetworkServiceImpl } from './network-service';
|
|
13
12
|
import { type ServiceContext } from '../services';
|
|
@@ -41,7 +40,7 @@ describe('NetworkService', () => {
|
|
|
41
40
|
query.subscribe(({ swarm }) => {
|
|
42
41
|
result.wake(swarm);
|
|
43
42
|
});
|
|
44
|
-
|
|
43
|
+
onTestFinished(() => query.close());
|
|
45
44
|
expect(await result.wait()).to.equal(ConnectionState.ONLINE);
|
|
46
45
|
|
|
47
46
|
result = new Trigger<ConnectionState | undefined>();
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
5
7
|
import { MemorySignalManagerContext, MemorySignalManager } from '@dxos/messaging';
|
|
6
8
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
7
|
-
import {
|
|
9
|
+
import { openAndClose } from '@dxos/test-utils';
|
|
8
10
|
|
|
9
11
|
import { createServiceContext, performInvitation } from '../testing';
|
|
10
12
|
|
|
@@ -6,8 +6,14 @@ import { Trigger } from '@dxos/async';
|
|
|
6
6
|
import { Context, Resource } from '@dxos/context';
|
|
7
7
|
import { getCredentialAssertion, type CredentialProcessor } from '@dxos/credentials';
|
|
8
8
|
import { failUndefined } from '@dxos/debug';
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import {
|
|
10
|
+
EchoEdgeReplicator,
|
|
11
|
+
EchoHost,
|
|
12
|
+
MeshEchoReplicator,
|
|
13
|
+
MetadataStore,
|
|
14
|
+
SpaceManager,
|
|
15
|
+
valueEncoding,
|
|
16
|
+
} from '@dxos/echo-pipeline';
|
|
11
17
|
import type { EdgeConnection } from '@dxos/edge-client';
|
|
12
18
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
13
19
|
import { invariant } from '@dxos/invariant';
|
|
@@ -31,8 +37,8 @@ import { safeInstanceof } from '@dxos/util';
|
|
|
31
37
|
import {
|
|
32
38
|
IdentityManager,
|
|
33
39
|
type CreateIdentityOptions,
|
|
34
|
-
type IdentityManagerRuntimeParams,
|
|
35
40
|
type JoinIdentityParams,
|
|
41
|
+
type IdentityManagerParams,
|
|
36
42
|
} from '../identity';
|
|
37
43
|
import {
|
|
38
44
|
DeviceInvitationProtocol,
|
|
@@ -43,7 +49,10 @@ import {
|
|
|
43
49
|
} from '../invitations';
|
|
44
50
|
import { DataSpaceManager, type DataSpaceManagerRuntimeParams, type SigningContext } from '../spaces';
|
|
45
51
|
|
|
46
|
-
export type ServiceContextRuntimeParams =
|
|
52
|
+
export type ServiceContextRuntimeParams = Pick<
|
|
53
|
+
IdentityManagerParams,
|
|
54
|
+
'devicePresenceOfflineTimeout' | 'devicePresenceAnnounceInterval'
|
|
55
|
+
> &
|
|
47
56
|
DataSpaceManagerRuntimeParams & {
|
|
48
57
|
invitationConnectionDefaultParams?: Partial<TeleportParams>;
|
|
49
58
|
disableP2pReplication?: boolean;
|
|
@@ -116,13 +125,16 @@ export class ServiceContext extends Resource {
|
|
|
116
125
|
disableP2pReplication: this._runtimeParams?.disableP2pReplication,
|
|
117
126
|
});
|
|
118
127
|
|
|
119
|
-
this.identityManager = new IdentityManager(
|
|
120
|
-
this.metadataStore,
|
|
121
|
-
this.keyring,
|
|
122
|
-
this.feedStore,
|
|
123
|
-
this.spaceManager,
|
|
124
|
-
this._runtimeParams
|
|
125
|
-
|
|
128
|
+
this.identityManager = new IdentityManager({
|
|
129
|
+
metadataStore: this.metadataStore,
|
|
130
|
+
keyring: this.keyring,
|
|
131
|
+
feedStore: this.feedStore,
|
|
132
|
+
spaceManager: this.spaceManager,
|
|
133
|
+
devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
|
|
134
|
+
devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
|
|
135
|
+
edgeConnection: this._edgeConnection,
|
|
136
|
+
edgeFeatures: this._edgeFeatures,
|
|
137
|
+
callbacks: {
|
|
126
138
|
onIdentityConstruction: (identity) => {
|
|
127
139
|
if (this._edgeConnection) {
|
|
128
140
|
log.info('Setting identity on edge connection', {
|
|
@@ -141,7 +153,7 @@ export class ServiceContext extends Resource {
|
|
|
141
153
|
}
|
|
142
154
|
},
|
|
143
155
|
},
|
|
144
|
-
);
|
|
156
|
+
});
|
|
145
157
|
|
|
146
158
|
this.echoHost = new EchoHost({ kv: this.level });
|
|
147
159
|
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import chai, { expect } from 'chai';
|
|
6
|
-
import chaiAsPromised from 'chai-as-promised';
|
|
7
5
|
import { rmSync } from 'node:fs';
|
|
6
|
+
import { afterEach, onTestFinished, describe, expect, test } from 'vitest';
|
|
8
7
|
|
|
9
8
|
import { asyncTimeout, latch, Trigger } from '@dxos/async';
|
|
10
9
|
import { Config } from '@dxos/config';
|
|
@@ -14,13 +13,10 @@ 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';
|
|
16
15
|
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
17
|
-
import { afterTest, describe, test } from '@dxos/test';
|
|
18
16
|
import { isNode } from '@dxos/util';
|
|
19
17
|
|
|
20
18
|
import { createMockCredential, createServiceHost } from '../testing';
|
|
21
19
|
|
|
22
|
-
chai.use(chaiAsPromised);
|
|
23
|
-
|
|
24
20
|
describe('ClientServicesHost', () => {
|
|
25
21
|
const dataRoot = '/tmp/dxos/client-services/service-host/storage';
|
|
26
22
|
|
|
@@ -38,7 +34,7 @@ describe('ClientServicesHost', () => {
|
|
|
38
34
|
test('queryCredentials', async () => {
|
|
39
35
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
40
36
|
await host.open(new Context());
|
|
41
|
-
|
|
37
|
+
onTestFinished(() => host.close());
|
|
42
38
|
|
|
43
39
|
await host.services.IdentityService!.createIdentity({});
|
|
44
40
|
const { spaceKey } = await host.services.SpacesService!.createSpace();
|
|
@@ -49,7 +45,7 @@ describe('ClientServicesHost', () => {
|
|
|
49
45
|
tick();
|
|
50
46
|
// console.log(credential);
|
|
51
47
|
});
|
|
52
|
-
|
|
48
|
+
onTestFinished(() => stream.close());
|
|
53
49
|
|
|
54
50
|
await done();
|
|
55
51
|
});
|
|
@@ -57,7 +53,7 @@ describe('ClientServicesHost', () => {
|
|
|
57
53
|
test('write and query credentials', async () => {
|
|
58
54
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
59
55
|
await host.open(new Context());
|
|
60
|
-
|
|
56
|
+
onTestFinished(() => host.close());
|
|
61
57
|
|
|
62
58
|
await host.services.IdentityService!.createIdentity({});
|
|
63
59
|
|
|
@@ -86,7 +82,7 @@ describe('ClientServicesHost', () => {
|
|
|
86
82
|
queriedCredential.wake(credential);
|
|
87
83
|
}
|
|
88
84
|
});
|
|
89
|
-
|
|
85
|
+
onTestFinished(() => credentials.close());
|
|
90
86
|
|
|
91
87
|
await queriedCredential.wait();
|
|
92
88
|
});
|
|
@@ -94,7 +90,7 @@ describe('ClientServicesHost', () => {
|
|
|
94
90
|
test('sign presentation', async () => {
|
|
95
91
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
96
92
|
await host.open(new Context());
|
|
97
|
-
|
|
93
|
+
onTestFinished(() => host.close());
|
|
98
94
|
|
|
99
95
|
await host.services.IdentityService!.createIdentity({});
|
|
100
96
|
|
|
@@ -147,9 +143,9 @@ describe('ClientServicesHost', () => {
|
|
|
147
143
|
trigger.wake(identity.identity);
|
|
148
144
|
}
|
|
149
145
|
});
|
|
150
|
-
await expect(asyncTimeout(trigger.wait(), 200)).
|
|
146
|
+
await expect(asyncTimeout(trigger.wait(), 200)).rejects.toBeInstanceOf(Error);
|
|
151
147
|
await stream?.close();
|
|
152
148
|
await host.close();
|
|
153
149
|
}
|
|
154
|
-
})
|
|
150
|
+
});
|
|
155
151
|
});
|
|
@@ -15,8 +15,8 @@ import { EdgeSignalManager, WebsocketSignalManager, type SignalManager } from '@
|
|
|
15
15
|
import {
|
|
16
16
|
SwarmNetworkManager,
|
|
17
17
|
createIceProvider,
|
|
18
|
-
createSimplePeerTransportFactory,
|
|
19
18
|
type TransportFactory,
|
|
19
|
+
createRtcTransportFactory,
|
|
20
20
|
} from '@dxos/network-manager';
|
|
21
21
|
import { trace } from '@dxos/protocols';
|
|
22
22
|
import { SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
@@ -218,7 +218,7 @@ export class ClientServicesHost {
|
|
|
218
218
|
|
|
219
219
|
const {
|
|
220
220
|
connectionLog = true,
|
|
221
|
-
transportFactory =
|
|
221
|
+
transportFactory = createRtcTransportFactory(
|
|
222
222
|
{ iceServers: this._config?.get('runtime.services.ice') },
|
|
223
223
|
this._config?.get('runtime.services.iceProviders') &&
|
|
224
224
|
createIceProvider(this._config!.get('runtime.services.iceProviders')!),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Event } from '@dxos/async';
|
|
8
8
|
import { type ClientServices } from '@dxos/client-protocol';
|
|
@@ -12,7 +12,6 @@ import { log } from '@dxos/log';
|
|
|
12
12
|
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
|
-
import { describe, test } from '@dxos/test';
|
|
16
15
|
|
|
17
16
|
import { ServiceRegistry } from './service-registry';
|
|
18
17
|
import { SystemServiceImpl } from '../system';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { asyncTimeout, latch } from '@dxos/async';
|
|
8
8
|
import { createAdmissionCredentials } from '@dxos/credentials';
|
|
@@ -10,7 +10,7 @@ import { AuthStatus } from '@dxos/echo-pipeline';
|
|
|
10
10
|
import { writeMessages } from '@dxos/feed-store';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
import { SpaceState } from '@dxos/protocols/proto/dxos/client/services';
|
|
13
|
-
import {
|
|
13
|
+
import { openAndClose } from '@dxos/test-utils';
|
|
14
14
|
|
|
15
15
|
import { TestBuilder, type TestPeer } from '../testing';
|
|
16
16
|
|
|
@@ -14,8 +14,11 @@ import {
|
|
|
14
14
|
type DelegateInvitationCredential,
|
|
15
15
|
type MemberInfo,
|
|
16
16
|
} from '@dxos/credentials';
|
|
17
|
-
import { convertLegacyReferences, findInlineObjectOfType, type EchoEdgeReplicator, type EchoHost } from '@dxos/echo-db';
|
|
18
17
|
import {
|
|
18
|
+
convertLegacyReferences,
|
|
19
|
+
findInlineObjectOfType,
|
|
20
|
+
type EchoEdgeReplicator,
|
|
21
|
+
type EchoHost,
|
|
19
22
|
AuthStatus,
|
|
20
23
|
CredentialServerExtension,
|
|
21
24
|
type MeshEchoReplicator,
|
|
@@ -7,8 +7,13 @@ import { AUTH_TIMEOUT } from '@dxos/client-protocol';
|
|
|
7
7
|
import { Context, ContextDisposedError, cancelWithContext } from '@dxos/context';
|
|
8
8
|
import type { SpecificCredential } from '@dxos/credentials';
|
|
9
9
|
import { timed, warnAfterTimeout } from '@dxos/debug';
|
|
10
|
-
import {
|
|
11
|
-
|
|
10
|
+
import {
|
|
11
|
+
type EchoHost,
|
|
12
|
+
type DatabaseRoot,
|
|
13
|
+
createMappedFeedWriter,
|
|
14
|
+
type MetadataStore,
|
|
15
|
+
type Space,
|
|
16
|
+
} from '@dxos/echo-pipeline';
|
|
12
17
|
import { SpaceDocVersion } from '@dxos/echo-protocol';
|
|
13
18
|
import type { EdgeConnection } from '@dxos/edge-client';
|
|
14
19
|
import { type FeedStore, type FeedWrapper } from '@dxos/feed-store';
|
|
@@ -64,7 +64,7 @@ export class EdgeFeedReplicator extends Resource {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const payload = decodeCbor(message.payload!.value) as ProtocolMessage;
|
|
67
|
-
log.info('
|
|
67
|
+
log.info('receive', { from: message.source, feedKey: payload.feedKey, type: payload.type });
|
|
68
68
|
this._onMessage(payload);
|
|
69
69
|
}),
|
|
70
70
|
);
|
|
@@ -112,7 +112,9 @@ export class EdgeFeedReplicator extends Resource {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
private async _sendMessage(message: ProtocolMessage) {
|
|
115
|
-
|
|
115
|
+
const logPayload =
|
|
116
|
+
message.type === 'data' ? { feedKey: message.feedKey, blocks: message.blocks.map((b) => b.index) } : { message };
|
|
117
|
+
log.info('sending message', logPayload);
|
|
116
118
|
|
|
117
119
|
invariant(message.feedKey);
|
|
118
120
|
const payloadValue = bufferToArray(encodeCbor(message));
|
|
@@ -130,11 +132,11 @@ export class EdgeFeedReplicator extends Resource {
|
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
private _onMessage(message: ProtocolMessage) {
|
|
133
|
-
log.info('received message', { message });
|
|
134
|
-
|
|
135
135
|
scheduleMicroTask(this._ctx, async () => {
|
|
136
136
|
switch (message.type) {
|
|
137
137
|
case 'metadata': {
|
|
138
|
+
log.info('received metadata', { message });
|
|
139
|
+
|
|
138
140
|
const feedKey = PublicKey.fromHex(message.feedKey);
|
|
139
141
|
const feed = this._feeds.get(feedKey);
|
|
140
142
|
if (!feed) {
|
|
@@ -160,6 +162,8 @@ export class EdgeFeedReplicator extends Resource {
|
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
case 'data': {
|
|
165
|
+
log.info('received data', { feed: message.feedKey, blocks: message.blocks.map((b) => b.index) });
|
|
166
|
+
|
|
163
167
|
const feedKey = PublicKey.fromHex(message.feedKey);
|
|
164
168
|
const feed = this._feeds.get(feedKey);
|
|
165
169
|
if (!feed) {
|
|
@@ -226,6 +230,7 @@ export class EdgeFeedReplicator extends Resource {
|
|
|
226
230
|
using _guard = await this._getPushMutex(feed.key).acquire();
|
|
227
231
|
|
|
228
232
|
if (!this._remoteLength.has(feed.key)) {
|
|
233
|
+
log('blocks not pushed because remote length is unknown');
|
|
229
234
|
return;
|
|
230
235
|
}
|
|
231
236
|
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import type { AutomergeUrl } from '@dxos/automerge/automerge-repo';
|
|
6
6
|
import { type Context } from '@dxos/context';
|
|
7
|
+
import { migrateDocument } from '@dxos/echo-db';
|
|
7
8
|
import {
|
|
8
9
|
convertLegacyReferences,
|
|
9
10
|
convertLegacySpaceRootDoc,
|
|
10
11
|
findInlineObjectOfType,
|
|
11
|
-
migrateDocument,
|
|
12
12
|
type EchoHost,
|
|
13
|
-
} from '@dxos/echo-
|
|
13
|
+
} from '@dxos/echo-pipeline';
|
|
14
14
|
import { SpaceDocVersion, type SpaceDoc } from '@dxos/echo-protocol';
|
|
15
15
|
import { TYPE_PROPERTIES } from '@dxos/echo-schema';
|
|
16
16
|
import { invariant } from '@dxos/invariant';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { onTestFinished, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Context } from '@dxos/context';
|
|
8
8
|
import { CredentialGenerator } from '@dxos/credentials';
|
|
@@ -11,7 +11,6 @@ import { Keyring } from '@dxos/keyring';
|
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
import { AdmittedFeed, type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
13
13
|
import { TestBuilder, type TestConnection, TestPeer } from '@dxos/teleport/testing';
|
|
14
|
-
import { afterTest, describe, test } from '@dxos/test';
|
|
15
14
|
|
|
16
15
|
import { NotarizationPlugin } from './notarization-plugin';
|
|
17
16
|
|
|
@@ -49,7 +48,7 @@ class TestAgent extends TestPeer {
|
|
|
49
48
|
describe('NotarizationPlugin', () => {
|
|
50
49
|
test('notarize single credential', async () => {
|
|
51
50
|
const testBuilder = new TestBuilder();
|
|
52
|
-
|
|
51
|
+
onTestFinished(() => testBuilder.destroy());
|
|
53
52
|
|
|
54
53
|
// peer0 is there to test retries.
|
|
55
54
|
const [_peer0, peer1, peer2] = await testBuilder.createPeers({ factory: () => new TestAgent() });
|
|
@@ -2,21 +2,17 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import chaiAsPromised from 'chai-as-promised';
|
|
5
|
+
import { afterEach, onTestFinished, beforeEach, describe, expect, test } from 'vitest';
|
|
7
6
|
|
|
8
7
|
import { Trigger } from '@dxos/async';
|
|
9
8
|
import { Context } from '@dxos/context';
|
|
10
9
|
import { PublicKey } from '@dxos/keys';
|
|
11
10
|
import { type Space, type SpacesService } from '@dxos/protocols/proto/dxos/client/services';
|
|
12
|
-
import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
|
|
13
11
|
|
|
14
12
|
import { SpacesServiceImpl } from './spaces-service';
|
|
15
13
|
import { type ServiceContext } from '../services';
|
|
16
14
|
import { createServiceContext } from '../testing';
|
|
17
15
|
|
|
18
|
-
chai.use(chaiAsPromised);
|
|
19
|
-
|
|
20
16
|
describe('SpacesService', () => {
|
|
21
17
|
let serviceContext: ServiceContext;
|
|
22
18
|
let spacesService: SpacesService;
|
|
@@ -36,7 +32,7 @@ describe('SpacesService', () => {
|
|
|
36
32
|
|
|
37
33
|
describe('createSpace', () => {
|
|
38
34
|
test('fails if no identity is available', async () => {
|
|
39
|
-
await expect(spacesService.createSpace()).
|
|
35
|
+
await expect(spacesService.createSpace()).rejects.toBeInstanceOf(Error);
|
|
40
36
|
});
|
|
41
37
|
|
|
42
38
|
test('creates a new space', async () => {
|
|
@@ -56,7 +52,7 @@ describe('SpacesService', () => {
|
|
|
56
52
|
query.subscribe(({ spaces }) => {
|
|
57
53
|
result.wake(spaces);
|
|
58
54
|
});
|
|
59
|
-
|
|
55
|
+
onTestFinished(() => query.close());
|
|
60
56
|
expect(await result.wait()).to.be.length(0);
|
|
61
57
|
});
|
|
62
58
|
|
|
@@ -73,7 +69,7 @@ describe('SpacesService', () => {
|
|
|
73
69
|
query.subscribe(({ spaces }) => {
|
|
74
70
|
result.wake(spaces);
|
|
75
71
|
});
|
|
76
|
-
|
|
72
|
+
onTestFinished(() => query.close());
|
|
77
73
|
|
|
78
74
|
const spaces = await result.wait();
|
|
79
75
|
expect(spaces).to.be.length(3);
|
|
@@ -87,7 +83,7 @@ describe('SpacesService', () => {
|
|
|
87
83
|
query.subscribe(({ spaces }) => {
|
|
88
84
|
result.wake(spaces);
|
|
89
85
|
});
|
|
90
|
-
|
|
86
|
+
onTestFinished(() => query.close());
|
|
91
87
|
expect(await result.wait()).to.be.length(0);
|
|
92
88
|
|
|
93
89
|
result.reset();
|
|
@@ -14,7 +14,6 @@ import { getRootPath } from './util';
|
|
|
14
14
|
// TODO(burdon): Factor out.
|
|
15
15
|
export const createStorageObjects = (config: Runtime.Client.Storage) => {
|
|
16
16
|
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
17
|
-
|
|
18
17
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
19
18
|
throw new InvalidConfigError('RAM storage cannot be used in persistent mode.');
|
|
20
19
|
}
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
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
9
|
import { type SystemService, SystemStatus, type QueryStatusResponse } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
|
-
import { beforeEach, describe, test } from '@dxos/test';
|
|
11
10
|
|
|
12
11
|
import { SystemServiceImpl } from './system-service';
|
|
13
12
|
|
|
@@ -6,8 +6,7 @@ import { type Config } from '@dxos/config';
|
|
|
6
6
|
import { Context } from '@dxos/context';
|
|
7
7
|
import { createCredentialSignerWithChain, CredentialGenerator } from '@dxos/credentials';
|
|
8
8
|
import { failUndefined } from '@dxos/debug';
|
|
9
|
-
import { EchoHost } from '@dxos/echo-
|
|
10
|
-
import { MetadataStore, SpaceManager, valueEncoding, MeshEchoReplicator } from '@dxos/echo-pipeline';
|
|
9
|
+
import { EchoHost, MetadataStore, SpaceManager, valueEncoding, MeshEchoReplicator } from '@dxos/echo-pipeline';
|
|
11
10
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
12
11
|
import { Keyring } from '@dxos/keyring';
|
|
13
12
|
import { type LevelDB } from '@dxos/kv-store';
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
WebsocketSignalManager,
|
|
15
15
|
setIdentityTags,
|
|
16
16
|
} from '@dxos/messaging';
|
|
17
|
-
import {
|
|
17
|
+
import { RtcTransportProxyFactory } from '@dxos/network-manager';
|
|
18
18
|
import { type RpcPort } from '@dxos/rpc';
|
|
19
19
|
import { type MaybePromise } from '@dxos/util';
|
|
20
20
|
|
|
@@ -46,7 +46,7 @@ export class WorkerRuntime {
|
|
|
46
46
|
private readonly _acquireLock: () => Promise<void>;
|
|
47
47
|
private readonly _releaseLock: () => void;
|
|
48
48
|
private readonly _onStop?: () => Promise<void>;
|
|
49
|
-
private readonly _transportFactory = new
|
|
49
|
+
private readonly _transportFactory = new RtcTransportProxyFactory();
|
|
50
50
|
private readonly _ready = new Trigger<Error | undefined>();
|
|
51
51
|
private readonly _sessions = new Set<WorkerSession>();
|
|
52
52
|
private readonly _clientServices!: ClientServicesHost;
|
package/src/version.ts
CHANGED