@dxos/client-services 0.5.8 → 0.5.9-main.8359215
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-JECXTGZA.mjs → chunk-QNCZI356.mjs} +34 -27
- package/dist/lib/browser/chunk-QNCZI356.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +4 -4
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-OR7LRWDY.cjs → chunk-ELQ5XXZX.cjs} +34 -27
- package/dist/lib/node/chunk-ELQ5XXZX.cjs.map +7 -0
- package/dist/lib/node/index.cjs +44 -44
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +10 -10
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/devtools/network.d.ts +4 -4
- package/dist/types/src/packlets/devtools/network.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/service-context.d.ts +4 -5
- 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.d.ts +1 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +3 -3
- package/dist/types/src/packlets/testing/test-builder.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/package.json +36 -36
- package/src/packlets/devtools/network.ts +4 -4
- package/src/packlets/identity/identity-manager.test.ts +2 -2
- package/src/packlets/identity/identity.test.ts +8 -4
- package/src/packlets/invitations/invitations-handler.ts +2 -2
- package/src/packlets/network/network-service.ts +2 -2
- package/src/packlets/services/service-context.ts +3 -3
- package/src/packlets/services/service-host.ts +6 -7
- package/src/packlets/spaces/data-space.ts +11 -1
- package/src/packlets/spaces/spaces-service.ts +1 -0
- package/src/packlets/testing/test-builder.ts +4 -4
- package/src/version.ts +1 -5
- package/dist/lib/browser/chunk-JECXTGZA.mjs.map +0 -7
- package/dist/lib/node/chunk-OR7LRWDY.cjs.map +0 -7
|
@@ -7,6 +7,7 @@ import expect from 'expect';
|
|
|
7
7
|
import { Context } from '@dxos/context';
|
|
8
8
|
import { CredentialGenerator, verifyCredential } from '@dxos/credentials';
|
|
9
9
|
import {
|
|
10
|
+
createIdFromSpaceKey,
|
|
10
11
|
MetadataStore,
|
|
11
12
|
MOCK_AUTH_PROVIDER,
|
|
12
13
|
MOCK_AUTH_VERIFIER,
|
|
@@ -20,7 +21,7 @@ import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
|
20
21
|
import { Keyring } from '@dxos/keyring';
|
|
21
22
|
import { type PublicKey } from '@dxos/keys';
|
|
22
23
|
import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
|
|
23
|
-
import { MemoryTransportFactory,
|
|
24
|
+
import { MemoryTransportFactory, SwarmNetworkManager } from '@dxos/network-manager';
|
|
24
25
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
25
26
|
import { AdmittedFeed } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
26
27
|
import { createStorage, StorageType } from '@dxos/random-access-storage';
|
|
@@ -78,7 +79,7 @@ describe('identity/identity', () => {
|
|
|
78
79
|
credentialAuthenticator: MOCK_AUTH_VERIFIER,
|
|
79
80
|
},
|
|
80
81
|
blobStore,
|
|
81
|
-
networkManager: new
|
|
82
|
+
networkManager: new SwarmNetworkManager({
|
|
82
83
|
signalManager: new MemorySignalManager(new MemorySignalManagerContext()),
|
|
83
84
|
transportFactory: MemoryTransportFactory,
|
|
84
85
|
}),
|
|
@@ -86,6 +87,7 @@ describe('identity/identity', () => {
|
|
|
86
87
|
|
|
87
88
|
await metadataStore.setIdentityRecord({ haloSpace: { key: spaceKey }, identityKey, deviceKey });
|
|
88
89
|
const space: Space = new Space({
|
|
90
|
+
id: await createIdFromSpaceKey(spaceKey),
|
|
89
91
|
spaceKey,
|
|
90
92
|
protocol,
|
|
91
93
|
genesisFeed: controlFeed,
|
|
@@ -193,7 +195,7 @@ describe('identity/identity', () => {
|
|
|
193
195
|
credentialAuthenticator: MOCK_AUTH_VERIFIER, // createHaloAuthVerifier(() => identity.authorizedDeviceKeys),
|
|
194
196
|
},
|
|
195
197
|
blobStore,
|
|
196
|
-
networkManager: new
|
|
198
|
+
networkManager: new SwarmNetworkManager({
|
|
197
199
|
signalManager: new MemorySignalManager(signalContext),
|
|
198
200
|
transportFactory: MemoryTransportFactory,
|
|
199
201
|
}),
|
|
@@ -201,6 +203,7 @@ describe('identity/identity', () => {
|
|
|
201
203
|
|
|
202
204
|
await metadataStore.setIdentityRecord({ haloSpace: { key: spaceKey }, identityKey, deviceKey });
|
|
203
205
|
const space = new Space({
|
|
206
|
+
id: await createIdFromSpaceKey(spaceKey),
|
|
204
207
|
spaceKey,
|
|
205
208
|
protocol,
|
|
206
209
|
genesisFeed: controlFeed,
|
|
@@ -281,7 +284,7 @@ describe('identity/identity', () => {
|
|
|
281
284
|
credentialAuthenticator: MOCK_AUTH_VERIFIER, // createHaloAuthVerifier(() => identity.authorizedDeviceKeys),
|
|
282
285
|
},
|
|
283
286
|
blobStore,
|
|
284
|
-
networkManager: new
|
|
287
|
+
networkManager: new SwarmNetworkManager({
|
|
285
288
|
signalManager: new MemorySignalManager(signalContext),
|
|
286
289
|
transportFactory: MemoryTransportFactory,
|
|
287
290
|
}),
|
|
@@ -293,6 +296,7 @@ describe('identity/identity', () => {
|
|
|
293
296
|
deviceKey,
|
|
294
297
|
});
|
|
295
298
|
const space = new Space({
|
|
299
|
+
id: await createIdFromSpaceKey(spaceKey),
|
|
296
300
|
spaceKey,
|
|
297
301
|
protocol,
|
|
298
302
|
genesisFeed: await feedStore.openFeed(genesisFeedKey),
|
|
@@ -9,7 +9,7 @@ import { createKeyPair, sign } from '@dxos/crypto';
|
|
|
9
9
|
import { invariant } from '@dxos/invariant';
|
|
10
10
|
import { PublicKey } from '@dxos/keys';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
|
-
import { createTeleportProtocolFactory, type
|
|
12
|
+
import { createTeleportProtocolFactory, type SwarmNetworkManager, type SwarmConnection } from '@dxos/network-manager';
|
|
13
13
|
import { InvalidInvitationExtensionRoleError, trace } from '@dxos/protocols';
|
|
14
14
|
import { type AdmissionKeypair, Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
15
15
|
import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
@@ -61,7 +61,7 @@ export class InvitationsHandler {
|
|
|
61
61
|
* @internal
|
|
62
62
|
*/
|
|
63
63
|
constructor(
|
|
64
|
-
private readonly _networkManager:
|
|
64
|
+
private readonly _networkManager: SwarmNetworkManager,
|
|
65
65
|
private readonly _defaultTeleportParams?: Partial<TeleportParams>,
|
|
66
66
|
) {}
|
|
67
67
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Stream } from '@dxos/codec-protobuf';
|
|
6
6
|
import { type SignalManager } from '@dxos/messaging';
|
|
7
|
-
import { type
|
|
7
|
+
import { type SwarmNetworkManager } from '@dxos/network-manager';
|
|
8
8
|
import {
|
|
9
9
|
type NetworkService,
|
|
10
10
|
type NetworkStatus,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
|
|
14
14
|
export class NetworkServiceImpl implements NetworkService {
|
|
15
15
|
constructor(
|
|
16
|
-
private readonly networkManager:
|
|
16
|
+
private readonly networkManager: SwarmNetworkManager,
|
|
17
17
|
private readonly signalManager: SignalManager,
|
|
18
18
|
) {}
|
|
19
19
|
|
|
@@ -15,7 +15,7 @@ import { PublicKey } from '@dxos/keys';
|
|
|
15
15
|
import { type LevelDB } from '@dxos/kv-store';
|
|
16
16
|
import { log } from '@dxos/log';
|
|
17
17
|
import { type SignalManager } from '@dxos/messaging';
|
|
18
|
-
import { type
|
|
18
|
+
import { type SwarmNetworkManager } from '@dxos/network-manager';
|
|
19
19
|
import { InvalidStorageVersionError, STORAGE_VERSION, trace } from '@dxos/protocols';
|
|
20
20
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
21
21
|
import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
@@ -35,10 +35,10 @@ import {
|
|
|
35
35
|
import {
|
|
36
36
|
DeviceInvitationProtocol,
|
|
37
37
|
InvitationsHandler,
|
|
38
|
+
InvitationsManager,
|
|
38
39
|
SpaceInvitationProtocol,
|
|
39
40
|
type InvitationProtocol,
|
|
40
41
|
} from '../invitations';
|
|
41
|
-
import { InvitationsManager } from '../invitations/invitations-manager';
|
|
42
42
|
import { DataSpaceManager, type DataSpaceManagerRuntimeParams, type SigningContext } from '../spaces';
|
|
43
43
|
|
|
44
44
|
export type ServiceContextRuntimeParams = IdentityManagerRuntimeParams &
|
|
@@ -81,7 +81,7 @@ export class ServiceContext extends Resource {
|
|
|
81
81
|
constructor(
|
|
82
82
|
public readonly storage: Storage,
|
|
83
83
|
public readonly level: LevelDB,
|
|
84
|
-
public readonly networkManager:
|
|
84
|
+
public readonly networkManager: SwarmNetworkManager,
|
|
85
85
|
public readonly signalManager: SignalManager,
|
|
86
86
|
public readonly _runtimeParams?: ServiceContextRuntimeParams,
|
|
87
87
|
) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Event, synchronized } from '@dxos/async';
|
|
6
|
-
import { clientServiceBundle, defaultKey, type ClientServices,
|
|
6
|
+
import { clientServiceBundle, defaultKey, type ClientServices, PropertiesType } from '@dxos/client-protocol';
|
|
7
7
|
import { type Config } from '@dxos/config';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { type ObjectStructure, encodeReference, type SpaceDoc } from '@dxos/echo-protocol';
|
|
@@ -13,7 +13,7 @@ import { PublicKey } from '@dxos/keys';
|
|
|
13
13
|
import { type LevelDB } from '@dxos/kv-store';
|
|
14
14
|
import { log } from '@dxos/log';
|
|
15
15
|
import { WebsocketSignalManager, type SignalManager } from '@dxos/messaging';
|
|
16
|
-
import {
|
|
16
|
+
import { SwarmNetworkManager, createSimplePeerTransportFactory, type TransportFactory } from '@dxos/network-manager';
|
|
17
17
|
import { trace } from '@dxos/protocols';
|
|
18
18
|
import { SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
19
19
|
import { type Storage } from '@dxos/random-access-storage';
|
|
@@ -79,7 +79,7 @@ export class ClientServicesHost {
|
|
|
79
79
|
private _config?: Config;
|
|
80
80
|
private readonly _statusUpdate = new Event<void>();
|
|
81
81
|
private _signalManager?: SignalManager;
|
|
82
|
-
private _networkManager?:
|
|
82
|
+
private _networkManager?: SwarmNetworkManager;
|
|
83
83
|
private _storage?: Storage;
|
|
84
84
|
private _level?: LevelDB;
|
|
85
85
|
private _callbacks?: ClientServicesHostCallbacks;
|
|
@@ -210,7 +210,7 @@ export class ClientServicesHost {
|
|
|
210
210
|
this._signalManager = signalManager;
|
|
211
211
|
|
|
212
212
|
invariant(!this._networkManager, 'network manager already set');
|
|
213
|
-
this._networkManager = new
|
|
213
|
+
this._networkManager = new SwarmNetworkManager({
|
|
214
214
|
log: connectionLog,
|
|
215
215
|
transportFactory,
|
|
216
216
|
signalManager,
|
|
@@ -356,13 +356,13 @@ export class ClientServicesHost {
|
|
|
356
356
|
|
|
357
357
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
358
358
|
invariant(automergeIndex);
|
|
359
|
-
const document =
|
|
359
|
+
const document = this._serviceContext.echoHost.automergeRepo.find<SpaceDoc>(automergeIndex as any);
|
|
360
360
|
await document.whenReady();
|
|
361
361
|
|
|
362
362
|
// TODO(dmaretskyi): Better API for low-level data access.
|
|
363
363
|
const properties: ObjectStructure = {
|
|
364
364
|
system: {
|
|
365
|
-
type: encodeReference(getTypeReference(
|
|
365
|
+
type: encodeReference(getTypeReference(PropertiesType)!),
|
|
366
366
|
},
|
|
367
367
|
data: {
|
|
368
368
|
[defaultKey]: identity.identityKey.toHex(),
|
|
@@ -377,7 +377,6 @@ export class ClientServicesHost {
|
|
|
377
377
|
});
|
|
378
378
|
|
|
379
379
|
await this._serviceContext.echoHost.flush();
|
|
380
|
-
|
|
381
380
|
return identity;
|
|
382
381
|
}
|
|
383
382
|
}
|
|
@@ -9,6 +9,7 @@ import { timed, warnAfterTimeout } from '@dxos/debug';
|
|
|
9
9
|
import { type EchoHost } from '@dxos/echo-db';
|
|
10
10
|
import {
|
|
11
11
|
AutomergeDocumentLoaderImpl,
|
|
12
|
+
createIdFromSpaceKey,
|
|
12
13
|
createMappedFeedWriter,
|
|
13
14
|
type MetadataStore,
|
|
14
15
|
type Space,
|
|
@@ -141,6 +142,11 @@ export class DataSpace {
|
|
|
141
142
|
log('new state', { state: SpaceState[this._state] });
|
|
142
143
|
}
|
|
143
144
|
|
|
145
|
+
@trace.info()
|
|
146
|
+
get id() {
|
|
147
|
+
return this._inner.id;
|
|
148
|
+
}
|
|
149
|
+
|
|
144
150
|
@trace.info()
|
|
145
151
|
get key() {
|
|
146
152
|
return this._inner.key;
|
|
@@ -476,7 +482,11 @@ export class DataSpace {
|
|
|
476
482
|
invariant(typeof newRoot.url === 'string' && newRoot.url.length > 0);
|
|
477
483
|
|
|
478
484
|
// Create new automerge documents for all objects.
|
|
479
|
-
const docLoader = new AutomergeDocumentLoaderImpl(
|
|
485
|
+
const docLoader = new AutomergeDocumentLoaderImpl(
|
|
486
|
+
await createIdFromSpaceKey(this.key),
|
|
487
|
+
this._echoHost.automergeRepo,
|
|
488
|
+
this.key,
|
|
489
|
+
);
|
|
480
490
|
await docLoader.loadSpaceRootDocHandle(this._ctx, { rootUrl: newRoot.url });
|
|
481
491
|
|
|
482
492
|
otherObjects.forEach(([key, value]) => {
|
|
@@ -216,6 +216,7 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
216
216
|
|
|
217
217
|
private _serializeSpace(space: DataSpace): Space {
|
|
218
218
|
return {
|
|
219
|
+
id: space.id,
|
|
219
220
|
spaceKey: space.key,
|
|
220
221
|
state: space.state,
|
|
221
222
|
error: space.error ? encodeError(space.error) : undefined,
|
|
@@ -13,7 +13,7 @@ import { Keyring } from '@dxos/keyring';
|
|
|
13
13
|
import { type LevelDB } from '@dxos/kv-store';
|
|
14
14
|
import { createTestLevel } from '@dxos/kv-store/testing';
|
|
15
15
|
import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
|
|
16
|
-
import { MemoryTransportFactory,
|
|
16
|
+
import { MemoryTransportFactory, SwarmNetworkManager } from '@dxos/network-manager';
|
|
17
17
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
18
18
|
import { createStorage, StorageType, type Storage } from '@dxos/random-access-storage';
|
|
19
19
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
@@ -42,7 +42,7 @@ export const createServiceContext = async ({
|
|
|
42
42
|
storage?: Storage;
|
|
43
43
|
} = {}) => {
|
|
44
44
|
const signalManager = new MemorySignalManager(signalContext);
|
|
45
|
-
const networkManager = new
|
|
45
|
+
const networkManager = new SwarmNetworkManager({
|
|
46
46
|
signalManager,
|
|
47
47
|
transportFactory: MemoryTransportFactory,
|
|
48
48
|
});
|
|
@@ -96,7 +96,7 @@ export type TestPeerProps = {
|
|
|
96
96
|
feedStore?: FeedStore<any>;
|
|
97
97
|
metadataStore?: MetadataStore;
|
|
98
98
|
keyring?: Keyring;
|
|
99
|
-
networkManager?:
|
|
99
|
+
networkManager?: SwarmNetworkManager;
|
|
100
100
|
spaceManager?: SpaceManager;
|
|
101
101
|
dataSpaceManager?: DataSpaceManager;
|
|
102
102
|
snapshotStore?: SnapshotStore;
|
|
@@ -155,7 +155,7 @@ export class TestPeer {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
get networkManager() {
|
|
158
|
-
return (this._props.networkManager ??= new
|
|
158
|
+
return (this._props.networkManager ??= new SwarmNetworkManager({
|
|
159
159
|
signalManager: new MemorySignalManager(this.signalContext),
|
|
160
160
|
transportFactory: MemoryTransportFactory,
|
|
161
161
|
}));
|
package/src/version.ts
CHANGED