@dxos/client-services 0.6.8-main.3be982f → 0.6.8-staging.63bcb81

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.
Files changed (46) hide show
  1. package/dist/lib/browser/{chunk-I6MMWGWX.mjs → chunk-IOA57UTY.mjs} +183 -135
  2. package/dist/lib/browser/chunk-IOA57UTY.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +7 -7
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +17 -10
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-PAH5HN65.cjs → chunk-5ZXCTX74.cjs} +185 -137
  9. package/dist/lib/node/chunk-5ZXCTX74.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +51 -51
  11. package/dist/lib/node/index.cjs.map +3 -3
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +23 -16
  14. package/dist/lib/node/testing/index.cjs.map +3 -3
  15. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  16. package/dist/types/src/packlets/identity/identity-manager.d.ts +4 -1
  17. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  18. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/service-context.d.ts +3 -1
  20. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  21. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +4 -0
  23. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  24. package/dist/types/src/packlets/spaces/data-space.d.ts +2 -0
  25. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  26. package/dist/types/src/packlets/testing/test-builder.d.ts +6 -4
  27. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  28. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  29. package/dist/types/src/version.d.ts +1 -1
  30. package/dist/types/src/version.d.ts.map +1 -1
  31. package/package.json +37 -37
  32. package/src/packlets/devtools/network.ts +12 -5
  33. package/src/packlets/identity/identity-manager.ts +5 -0
  34. package/src/packlets/identity/identity.test.ts +3 -0
  35. package/src/packlets/invitations/invitations-handler.ts +0 -1
  36. package/src/packlets/network/network-service.ts +3 -3
  37. package/src/packlets/services/service-context.test.ts +4 -2
  38. package/src/packlets/services/service-context.ts +31 -3
  39. package/src/packlets/services/service-host.ts +20 -11
  40. package/src/packlets/spaces/data-space-manager.ts +8 -0
  41. package/src/packlets/spaces/data-space.ts +3 -1
  42. package/src/packlets/testing/test-builder.ts +21 -9
  43. package/src/packlets/worker/worker-runtime.ts +5 -3
  44. package/src/version.ts +1 -1
  45. package/dist/lib/browser/chunk-I6MMWGWX.mjs.map +0 -7
  46. package/dist/lib/node/chunk-PAH5HN65.cjs.map +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/client-services",
3
- "version": "0.6.8-main.3be982f",
3
+ "version": "0.6.8-staging.63bcb81",
4
4
  "description": "DXOS client services implementation",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -45,46 +45,46 @@
45
45
  "dependencies": {
46
46
  "cbor-x": "^1.5.4",
47
47
  "platform": "^1.3.6",
48
- "@dxos/automerge": "0.6.8-main.3be982f",
49
- "@dxos/client-protocol": "0.6.8-main.3be982f",
50
- "@dxos/codec-protobuf": "0.6.8-main.3be982f",
51
- "@dxos/context": "0.6.8-main.3be982f",
52
- "@dxos/config": "0.6.8-main.3be982f",
53
- "@dxos/credentials": "0.6.8-main.3be982f",
54
- "@dxos/crypto": "0.6.8-main.3be982f",
55
- "@dxos/debug": "0.6.8-main.3be982f",
56
- "@dxos/echo-pipeline": "0.6.8-main.3be982f",
57
- "@dxos/echo-db": "0.6.8-main.3be982f",
58
- "@dxos/echo-protocol": "0.6.8-main.3be982f",
59
- "@dxos/echo-schema": "0.6.8-main.3be982f",
60
- "@dxos/indexing": "0.6.8-main.3be982f",
61
- "@dxos/edge-client": "0.6.8-main.3be982f",
62
- "@dxos/feed-store": "0.6.8-main.3be982f",
63
- "@dxos/async": "0.6.8-main.3be982f",
64
- "@dxos/keyring": "0.6.8-main.3be982f",
65
- "@dxos/invariant": "0.6.8-main.3be982f",
66
- "@dxos/kv-store": "0.6.8-main.3be982f",
67
- "@dxos/keys": "0.6.8-main.3be982f",
68
- "@dxos/lock-file": "0.6.8-main.3be982f",
69
- "@dxos/log": "0.6.8-main.3be982f",
70
- "@dxos/network-manager": "0.6.8-main.3be982f",
71
- "@dxos/node-std": "0.6.8-main.3be982f",
72
- "@dxos/protocols": "0.6.8-main.3be982f",
73
- "@dxos/messaging": "0.6.8-main.3be982f",
74
- "@dxos/random-access-storage": "0.6.8-main.3be982f",
75
- "@dxos/rpc": "0.6.8-main.3be982f",
76
- "@dxos/teleport-extension-gossip": "0.6.8-main.3be982f",
77
- "@dxos/teleport": "0.6.8-main.3be982f",
78
- "@dxos/teleport-extension-object-sync": "0.6.8-main.3be982f",
79
- "@dxos/timeframe": "0.6.8-main.3be982f",
80
- "@dxos/tracing": "0.6.8-main.3be982f",
81
- "@dxos/util": "0.6.8-main.3be982f",
82
- "@dxos/websocket-rpc": "0.6.8-main.3be982f"
48
+ "@dxos/async": "0.6.8-staging.63bcb81",
49
+ "@dxos/automerge": "0.6.8-staging.63bcb81",
50
+ "@dxos/client-protocol": "0.6.8-staging.63bcb81",
51
+ "@dxos/codec-protobuf": "0.6.8-staging.63bcb81",
52
+ "@dxos/credentials": "0.6.8-staging.63bcb81",
53
+ "@dxos/config": "0.6.8-staging.63bcb81",
54
+ "@dxos/debug": "0.6.8-staging.63bcb81",
55
+ "@dxos/context": "0.6.8-staging.63bcb81",
56
+ "@dxos/crypto": "0.6.8-staging.63bcb81",
57
+ "@dxos/echo-pipeline": "0.6.8-staging.63bcb81",
58
+ "@dxos/echo-protocol": "0.6.8-staging.63bcb81",
59
+ "@dxos/echo-db": "0.6.8-staging.63bcb81",
60
+ "@dxos/echo-schema": "0.6.8-staging.63bcb81",
61
+ "@dxos/feed-store": "0.6.8-staging.63bcb81",
62
+ "@dxos/edge-client": "0.6.8-staging.63bcb81",
63
+ "@dxos/indexing": "0.6.8-staging.63bcb81",
64
+ "@dxos/invariant": "0.6.8-staging.63bcb81",
65
+ "@dxos/keyring": "0.6.8-staging.63bcb81",
66
+ "@dxos/keys": "0.6.8-staging.63bcb81",
67
+ "@dxos/lock-file": "0.6.8-staging.63bcb81",
68
+ "@dxos/kv-store": "0.6.8-staging.63bcb81",
69
+ "@dxos/log": "0.6.8-staging.63bcb81",
70
+ "@dxos/messaging": "0.6.8-staging.63bcb81",
71
+ "@dxos/network-manager": "0.6.8-staging.63bcb81",
72
+ "@dxos/node-std": "0.6.8-staging.63bcb81",
73
+ "@dxos/protocols": "0.6.8-staging.63bcb81",
74
+ "@dxos/random-access-storage": "0.6.8-staging.63bcb81",
75
+ "@dxos/teleport": "0.6.8-staging.63bcb81",
76
+ "@dxos/rpc": "0.6.8-staging.63bcb81",
77
+ "@dxos/teleport-extension-gossip": "0.6.8-staging.63bcb81",
78
+ "@dxos/teleport-extension-object-sync": "0.6.8-staging.63bcb81",
79
+ "@dxos/timeframe": "0.6.8-staging.63bcb81",
80
+ "@dxos/tracing": "0.6.8-staging.63bcb81",
81
+ "@dxos/util": "0.6.8-staging.63bcb81",
82
+ "@dxos/websocket-rpc": "0.6.8-staging.63bcb81"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@types/platform": "^1.3.4",
86
86
  "@types/readable-stream": "^2.3.9",
87
- "@dxos/signal": "0.6.8-main.3be982f"
87
+ "@dxos/signal": "0.6.8-staging.63bcb81"
88
88
  },
89
89
  "publishConfig": {
90
90
  "access": "public"
@@ -20,14 +20,14 @@ export const subscribeToNetworkStatus = ({ signalManager }: { signalManager: Sig
20
20
  new Stream<SubscribeToSignalStatusResponse>(({ next, close }) => {
21
21
  const update = () => {
22
22
  try {
23
- const status = signalManager.getStatus();
23
+ const status = signalManager.getStatus?.();
24
24
  next({ servers: status });
25
25
  } catch (err: any) {
26
26
  close(err);
27
27
  }
28
28
  };
29
29
 
30
- signalManager.statusChanged.on(() => update());
30
+ signalManager.statusChanged?.on(() => update());
31
31
  update();
32
32
  });
33
33
 
@@ -37,8 +37,8 @@ export const subscribeToSignal = ({ signalManager }: { signalManager: SignalMana
37
37
  signalManager.onMessage.on(ctx, (message) => {
38
38
  next({
39
39
  message: {
40
- author: message.author.asUint8Array(),
41
- recipient: message.recipient.asUint8Array(),
40
+ author: PublicKey.from(message.author.peerKey).asUint8Array(),
41
+ recipient: PublicKey.from(message.recipient.peerKey).asUint8Array(),
42
42
  payload: message.payload,
43
43
  },
44
44
  receivedAt: new Date(),
@@ -46,7 +46,14 @@ export const subscribeToSignal = ({ signalManager }: { signalManager: SignalMana
46
46
  });
47
47
  signalManager.swarmEvent.on(ctx, (swarmEvent) => {
48
48
  next({
49
- swarmEvent: swarmEvent.swarmEvent,
49
+ swarmEvent: swarmEvent.peerAvailable
50
+ ? {
51
+ peerAvailable: {
52
+ peer: PublicKey.from(swarmEvent.peerAvailable.peer.peerKey).asUint8Array(),
53
+ since: swarmEvent.peerAvailable.since,
54
+ },
55
+ }
56
+ : { peerLeft: { peer: PublicKey.from(swarmEvent.peerLeft!.peer.peerKey).asUint8Array() } },
50
57
  topic: swarmEvent.topic.asUint8Array(),
51
58
  receivedAt: new Date(),
52
59
  });
@@ -85,6 +85,9 @@ export class IdentityManager {
85
85
  private readonly _feedStore: FeedStore<FeedMessage>,
86
86
  private readonly _spaceManager: SpaceManager,
87
87
  params?: IdentityManagerRuntimeParams,
88
+ private readonly _callbacks?: {
89
+ onIdentityConstruction?: (identity: Identity) => void;
90
+ },
88
91
  ) {
89
92
  const {
90
93
  devicePresenceAnnounceInterval = DEVICE_PRESENCE_ANNOUNCE_INTERVAL,
@@ -340,6 +343,7 @@ export class IdentityManager {
340
343
  const space = await this._constructSpace({
341
344
  spaceRecord: identityRecord.haloSpace,
342
345
  swarmIdentity: {
346
+ identityKey: identityRecord.identityKey,
343
347
  peerKey: identityRecord.deviceKey,
344
348
  credentialProvider: createAuthProvider(createCredentialSignerWithKey(this._keyring, identityRecord.deviceKey)),
345
349
  credentialAuthenticator: deferFunction(() => identity.authVerifier.verifier),
@@ -358,6 +362,7 @@ export class IdentityManager {
358
362
  deviceKey: identityRecord.deviceKey,
359
363
  });
360
364
  log('done', { identityKey: identityRecord.identityKey });
365
+ this._callbacks?.onIdentityConstruction?.(identity);
361
366
 
362
367
  // TODO(mykola): Set new timeframe on a write to a feed.
363
368
  if (identityRecord.haloSpace.controlTimeframe) {
@@ -71,6 +71,7 @@ describe('identity/identity', () => {
71
71
  topic: spaceKey,
72
72
  swarmIdentity: {
73
73
  peerKey: deviceKey,
74
+ identityKey,
74
75
  credentialProvider: MOCK_AUTH_PROVIDER,
75
76
  credentialAuthenticator: MOCK_AUTH_VERIFIER,
76
77
  },
@@ -186,6 +187,7 @@ describe('identity/identity', () => {
186
187
  topic: spaceKey,
187
188
  swarmIdentity: {
188
189
  peerKey: deviceKey,
190
+ identityKey,
189
191
  credentialProvider: MOCK_AUTH_PROVIDER, // createHaloAuthProvider(createCredentialSignerWithKey(keyring, device_key)),
190
192
  credentialAuthenticator: MOCK_AUTH_VERIFIER, // createHaloAuthVerifier(() => identity.authorizedDeviceKeys),
191
193
  },
@@ -274,6 +276,7 @@ describe('identity/identity', () => {
274
276
  topic: spaceKey,
275
277
  swarmIdentity: {
276
278
  peerKey: deviceKey,
279
+ identityKey,
277
280
  credentialProvider: MOCK_AUTH_PROVIDER, // createHaloAuthProvider(createCredentialSignerWithKey(keyring, device_key)),
278
281
  credentialAuthenticator: MOCK_AUTH_VERIFIER, // createHaloAuthVerifier(() => identity.authorizedDeviceKeys),
279
282
  },
@@ -387,7 +387,6 @@ export class InvitationsHandler {
387
387
  }
388
388
  const swarmConnection = await this._networkManager.joinSwarm({
389
389
  topic: invitation.swarmKey,
390
- peerId: PublicKey.random(),
391
390
  protocolProvider: createTeleportProtocolFactory(async (teleport) => {
392
391
  teleport.addExtension('dxos.halo.invitations', extensionFactory());
393
392
  }, this._defaultTeleportParams),
@@ -23,17 +23,17 @@ export class NetworkServiceImpl implements NetworkService {
23
23
  next({
24
24
  swarm: this.networkManager.connectionState,
25
25
  connectionInfo: this.networkManager.connectionLog?.swarms,
26
- signaling: this.signalManager.getStatus().map(({ host, state }) => ({ server: host, state })),
26
+ signaling: this.signalManager.getStatus?.().map(({ host, state }) => ({ server: host, state })),
27
27
  });
28
28
  };
29
29
 
30
30
  const unsubscribeSwarm = this.networkManager.connectionStateChanged.on(() => update());
31
- const unsubscribeSignal = this.signalManager.statusChanged.on(() => update());
31
+ const unsubscribeSignal = this.signalManager.statusChanged?.on(() => update());
32
32
  update();
33
33
 
34
34
  return () => {
35
35
  unsubscribeSwarm();
36
- unsubscribeSignal();
36
+ unsubscribeSignal?.();
37
37
  };
38
38
  });
39
39
  }
@@ -2,7 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { MemorySignalManagerContext } from '@dxos/messaging';
5
+ import { MemorySignalManagerContext, MemorySignalManager } from '@dxos/messaging';
6
6
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
7
7
  import { describe, openAndClose, test } from '@dxos/test';
8
8
 
@@ -48,7 +48,9 @@ describe('services/ServiceContext', () => {
48
48
  });
49
49
 
50
50
  const createOpenServiceContext = async (networkContext: MemorySignalManagerContext) => {
51
- const serviceContext = await createServiceContext({ signalContext: networkContext });
51
+ const serviceContext = await createServiceContext({
52
+ signalManagerFactory: async () => new MemorySignalManager(networkContext),
53
+ });
52
54
  await openAndClose(serviceContext);
53
55
  return serviceContext;
54
56
  };
@@ -19,6 +19,7 @@ import { type SignalManager } from '@dxos/messaging';
19
19
  import { type SwarmNetworkManager } from '@dxos/network-manager';
20
20
  import { InvalidStorageVersionError, STORAGE_VERSION, trace } from '@dxos/protocols';
21
21
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
22
+ import { type Runtime } from '@dxos/protocols/proto/dxos/config';
22
23
  import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
23
24
  import { type Credential, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
24
25
  import { type Storage } from '@dxos/random-access-storage';
@@ -87,6 +88,7 @@ export class ServiceContext extends Resource {
87
88
  public readonly signalManager: SignalManager,
88
89
  private readonly _edgeConnection: EdgeConnection | undefined,
89
90
  public readonly _runtimeParams?: ServiceContextRuntimeParams,
91
+ private readonly _edgeFeatures?: Runtime.Client.EdgeFeatures,
90
92
  ) {
91
93
  super();
92
94
 
@@ -120,11 +122,35 @@ export class ServiceContext extends Resource {
120
122
  this.feedStore,
121
123
  this.spaceManager,
122
124
  this._runtimeParams as IdentityManagerRuntimeParams,
125
+ {
126
+ onIdentityConstruction: (identity) => {
127
+ if (this._edgeConnection) {
128
+ log.info('Setting identity on edge connection', {
129
+ identity: identity.identityKey.toHex(),
130
+ oldIdentity: this._edgeConnection.identityKey.toHex(),
131
+ swarms: this.networkManager.topics,
132
+ });
133
+ this._edgeConnection.setIdentity({
134
+ deviceKey: identity.deviceKey,
135
+ identityKey: identity.identityKey,
136
+ });
137
+ this.networkManager.setPeerInfo({
138
+ identityKey: identity.identityKey.toHex(),
139
+ peerKey: identity.deviceKey.toHex(),
140
+ });
141
+ }
142
+ },
143
+ },
123
144
  );
124
145
 
125
146
  this.echoHost = new EchoHost({ kv: this.level });
126
147
 
127
- this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
148
+ this._meshReplicator = new MeshEchoReplicator();
149
+
150
+ this.invitations = new InvitationsHandler(
151
+ this.networkManager, //
152
+ _runtimeParams?.invitationConnectionDefaultParams,
153
+ );
128
154
  this.invitationsManager = new InvitationsManager(
129
155
  this.invitations,
130
156
  (invitation) => this.getInvitationHandler(invitation),
@@ -146,7 +172,7 @@ export class ServiceContext extends Resource {
146
172
  if (!this._runtimeParams?.disableP2pReplication) {
147
173
  this._meshReplicator = new MeshEchoReplicator();
148
174
  }
149
- if (this._edgeConnection) {
175
+ if (this._edgeConnection && this._edgeFeatures?.echoReplicator) {
150
176
  this._echoEdgeReplicator = new EchoEdgeReplicator({
151
177
  edgeConnection: this._edgeConnection,
152
178
  });
@@ -159,9 +185,9 @@ export class ServiceContext extends Resource {
159
185
 
160
186
  log('opening...');
161
187
  log.trace('dxos.sdk.service-context.open', trace.begin({ id: this._instanceId }));
188
+ await this._edgeConnection?.open();
162
189
  await this.signalManager.open();
163
190
  await this.networkManager.open();
164
- await this._edgeConnection?.open();
165
191
 
166
192
  await this.echoHost.open(ctx);
167
193
 
@@ -175,6 +201,7 @@ export class ServiceContext extends Resource {
175
201
  await this.metadataStore.load();
176
202
  await this.spaceManager.open();
177
203
  await this.identityManager.open(ctx);
204
+
178
205
  if (this.identityManager.identity) {
179
206
  await this._initialize(ctx);
180
207
  }
@@ -268,6 +295,7 @@ export class ServiceContext extends Resource {
268
295
  echoEdgeReplicator: this._echoEdgeReplicator,
269
296
  meshReplicator: this._meshReplicator,
270
297
  runtimeParams: this._runtimeParams as DataSpaceManagerRuntimeParams,
298
+ edgeFeatures: this._edgeFeatures,
271
299
  });
272
300
  await this.dataSpaceManager.open();
273
301
 
@@ -11,7 +11,7 @@ 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 { WebsocketSignalManager, type SignalManager } from '@dxos/messaging';
14
+ import { EdgeSignalManager, WebsocketSignalManager, type SignalManager } from '@dxos/messaging';
15
15
  import {
16
16
  SwarmNetworkManager,
17
17
  createIceProvider,
@@ -209,6 +209,14 @@ export class ClientServicesHost {
209
209
  if (!options.signalManager) {
210
210
  log.warn('running signaling without telemetry metadata.');
211
211
  }
212
+
213
+ const edgeEndpoint = config?.get('runtime.services.edge.url');
214
+ if (edgeEndpoint) {
215
+ this._edgeConnection = new EdgeClient(PublicKey.random(), PublicKey.random(), {
216
+ socketEndpoint: edgeEndpoint,
217
+ });
218
+ }
219
+
212
220
  const {
213
221
  connectionLog = true,
214
222
  transportFactory = createSimplePeerTransportFactory(
@@ -216,25 +224,25 @@ export class ClientServicesHost {
216
224
  this._config?.get('runtime.services.iceProviders') &&
217
225
  createIceProvider(this._config!.get('runtime.services.iceProviders')!),
218
226
  ),
219
- signalManager = new WebsocketSignalManager(this._config?.get('runtime.services.signaling') ?? []),
227
+ signalManager = this._edgeConnection && this._config?.get('runtime.client.edgeFeatures')?.signaling
228
+ ? new EdgeSignalManager({ edgeConnection: this._edgeConnection })
229
+ : new WebsocketSignalManager(this._config?.get('runtime.services.signaling') ?? []),
220
230
  } = options;
221
231
  this._signalManager = signalManager;
222
232
 
223
233
  invariant(!this._networkManager, 'network manager already set');
224
234
  this._networkManager = new SwarmNetworkManager({
225
- log: connectionLog,
235
+ enableDevtoolsLogging: connectionLog,
226
236
  transportFactory,
227
237
  signalManager,
238
+ peerInfo: this._edgeConnection
239
+ ? {
240
+ identityKey: this._edgeConnection.identityKey.toHex(),
241
+ peerKey: this._edgeConnection.deviceKey.toHex(),
242
+ }
243
+ : undefined,
228
244
  });
229
245
 
230
- const edgeEndpoint = config?.get('runtime.services.edge.url');
231
- if (edgeEndpoint) {
232
- // TODO(dmaretskyi): Use actual identity instead of random keys.
233
- this._edgeConnection = new EdgeClient(PublicKey.random(), PublicKey.random(), {
234
- socketEndpoint: edgeEndpoint,
235
- });
236
- }
237
-
238
246
  log('initialized');
239
247
  }
240
248
 
@@ -272,6 +280,7 @@ export class ClientServicesHost {
272
280
  this._signalManager,
273
281
  this._edgeConnection,
274
282
  this._runtimeParams,
283
+ this._config.get('runtime.client.edgeFeatures'),
275
284
  );
276
285
 
277
286
  const dataSpaceManagerProvider = async () => {
@@ -41,6 +41,7 @@ import { PublicKey } from '@dxos/keys';
41
41
  import { log } from '@dxos/log';
42
42
  import { AlreadyJoinedError, trace as Trace } from '@dxos/protocols';
43
43
  import { Invitation, SpaceState } from '@dxos/protocols/proto/dxos/client/services';
44
+ import { type Runtime } from '@dxos/protocols/proto/dxos/config';
44
45
  import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
45
46
  import { type SpaceMetadata } from '@dxos/protocols/proto/dxos/echo/metadata';
46
47
  import { SpaceMember, type Credential, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
@@ -109,11 +110,13 @@ export type DataSpaceManagerParams = {
109
110
  meshReplicator?: MeshEchoReplicator;
110
111
  echoEdgeReplicator?: EchoEdgeReplicator;
111
112
  runtimeParams?: DataSpaceManagerRuntimeParams;
113
+ edgeFeatures?: Runtime.Client.EdgeFeatures;
112
114
  };
113
115
 
114
116
  export type DataSpaceManagerRuntimeParams = {
115
117
  spaceMemberPresenceAnnounceInterval?: number;
116
118
  spaceMemberPresenceOfflineTimeout?: number;
119
+ disableP2pReplication?: boolean;
117
120
  };
118
121
 
119
122
  @trackLeaks('open', 'close')
@@ -132,6 +135,7 @@ export class DataSpaceManager extends Resource {
132
135
  private readonly _echoHost: EchoHost;
133
136
  private readonly _invitationsManager: InvitationsManager;
134
137
  private readonly _edgeConnection?: EdgeConnection = undefined;
138
+ private readonly _edgeFeatures?: Runtime.Client.EdgeFeatures = undefined;
135
139
  private readonly _meshReplicator?: MeshEchoReplicator = undefined;
136
140
  private readonly _echoEdgeReplicator?: EchoEdgeReplicator = undefined;
137
141
  private readonly _runtimeParams?: DataSpaceManagerRuntimeParams = undefined;
@@ -148,6 +152,7 @@ export class DataSpaceManager extends Resource {
148
152
  this._meshReplicator = params.meshReplicator;
149
153
  this._invitationsManager = params.invitationsManager;
150
154
  this._edgeConnection = params.edgeConnection;
155
+ this._edgeFeatures = params.edgeFeatures;
151
156
  this._echoEdgeReplicator = params.echoEdgeReplicator;
152
157
  this._runtimeParams = params.runtimeParams;
153
158
 
@@ -375,6 +380,7 @@ export class DataSpaceManager extends Resource {
375
380
  identityKey: this._signingContext.identityKey,
376
381
  timeout: 15_000,
377
382
  swarmIdentity: {
383
+ identityKey: this._signingContext.identityKey,
378
384
  peerKey: this._signingContext.deviceKey,
379
385
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
380
386
  credentialAuthenticator: async () => true,
@@ -406,6 +412,7 @@ export class DataSpaceManager extends Resource {
406
412
  const space: Space = await this._spaceManager.constructSpace({
407
413
  metadata,
408
414
  swarmIdentity: {
415
+ identityKey: this._signingContext.identityKey,
409
416
  peerKey: this._signingContext.deviceKey,
410
417
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
411
418
  credentialAuthenticator: deferFunction(() => dataSpace.authVerifier.verifier),
@@ -472,6 +479,7 @@ export class DataSpaceManager extends Resource {
472
479
  },
473
480
  cache: metadata.cache,
474
481
  edgeConnection: this._edgeConnection,
482
+ edgeFeatures: this._edgeFeatures,
475
483
  });
476
484
  dataSpace.postOpen.append(async () => {
477
485
  await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
@@ -22,6 +22,7 @@ import {
22
22
  SpaceState,
23
23
  type Space as SpaceProto,
24
24
  } from '@dxos/protocols/proto/dxos/client/services';
25
+ import { type Runtime } from '@dxos/protocols/proto/dxos/config';
25
26
  import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
26
27
  import { type SpaceCache } from '@dxos/protocols/proto/dxos/echo/metadata';
27
28
  import {
@@ -74,6 +75,7 @@ export type DataSpaceParams = {
74
75
  callbacks?: DataSpaceCallbacks;
75
76
  cache?: SpaceCache;
76
77
  edgeConnection?: EdgeConnection;
78
+ edgeFeatures?: Runtime.Client.EdgeFeatures;
77
79
  };
78
80
 
79
81
  export type CreateEpochOptions = {
@@ -149,7 +151,7 @@ export class DataSpace {
149
151
 
150
152
  this._cache = params.cache;
151
153
 
152
- if (params.edgeConnection) {
154
+ if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
153
155
  this._edgeFeedReplicator = new EdgeFeedReplicator({ messenger: params.edgeConnection, spaceId: this.id });
154
156
  }
155
157
 
@@ -8,11 +8,12 @@ import { createCredentialSignerWithChain, CredentialGenerator } from '@dxos/cred
8
8
  import { failUndefined } from '@dxos/debug';
9
9
  import { EchoHost } from '@dxos/echo-db';
10
10
  import { MetadataStore, SpaceManager, valueEncoding, MeshEchoReplicator } from '@dxos/echo-pipeline';
11
+ import { type EdgeConnection } from '@dxos/edge-client';
11
12
  import { FeedFactory, FeedStore } from '@dxos/feed-store';
12
13
  import { Keyring } from '@dxos/keyring';
13
14
  import { type LevelDB } from '@dxos/kv-store';
14
15
  import { createTestLevel } from '@dxos/kv-store/testing';
15
- import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
16
+ import { MemorySignalManager, MemorySignalManagerContext, type SignalManager } from '@dxos/messaging';
16
17
  import { MemoryTransportFactory, SwarmNetworkManager } from '@dxos/network-manager';
17
18
  import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
18
19
  import { createStorage, StorageType, type Storage } from '@dxos/random-access-storage';
@@ -35,15 +36,20 @@ export const createServiceHost = (config: Config, signalManagerContext: MemorySi
35
36
  };
36
37
 
37
38
  export const createServiceContext = async ({
38
- signalContext = new MemorySignalManagerContext(),
39
+ signalManagerFactory = async () => {
40
+ const signalContext = new MemorySignalManagerContext();
41
+ return new MemorySignalManager(signalContext);
42
+ },
39
43
  storage = createStorage({ type: StorageType.RAM }),
40
44
  runtimeParams,
45
+ edgeConnection,
41
46
  }: {
42
- signalContext?: MemorySignalManagerContext;
47
+ signalManagerFactory?: () => Promise<SignalManager>;
43
48
  storage?: Storage;
44
49
  runtimeParams?: ServiceContextRuntimeParams;
50
+ edgeConnection?: EdgeConnection;
45
51
  } = {}) => {
46
- const signalManager = new MemorySignalManager(signalContext);
52
+ const signalManager = await signalManagerFactory();
47
53
  const networkManager = new SwarmNetworkManager({
48
54
  signalManager,
49
55
  transportFactory: MemoryTransportFactory,
@@ -51,18 +57,24 @@ export const createServiceContext = async ({
51
57
  const level = createTestLevel();
52
58
  await level.open();
53
59
 
54
- return new ServiceContext(storage, level, networkManager, signalManager, undefined, {
60
+ return new ServiceContext(storage, level, networkManager, signalManager, edgeConnection, {
55
61
  invitationConnectionDefaultParams: { controlHeartbeatInterval: 200 },
56
62
  ...runtimeParams,
57
63
  });
58
64
  };
59
65
 
60
- export const createPeers = async (numPeers: number) => {
61
- const signalContext = new MemorySignalManagerContext();
62
-
66
+ export const createPeers = async (
67
+ numPeers: number,
68
+ signalManagerFactory?: () => Promise<SignalManager>,
69
+ edgeConnection?: EdgeConnection,
70
+ ) => {
71
+ if (!signalManagerFactory) {
72
+ const signalContext = new MemorySignalManagerContext();
73
+ signalManagerFactory = async () => new MemorySignalManager(signalContext);
74
+ }
63
75
  return await Promise.all(
64
76
  Array.from(Array(numPeers)).map(async () => {
65
- const peer = await createServiceContext({ signalContext });
77
+ const peer = await createServiceContext({ signalManagerFactory, edgeConnection });
66
78
  await peer.open(new Context());
67
79
  return peer;
68
80
  }),
@@ -96,9 +96,11 @@ export class WorkerRuntime {
96
96
  const signals = this._config.get('runtime.services.signaling');
97
97
  this._clientServices.initialize({
98
98
  config: this._config,
99
- signalManager: signals
100
- ? new WebsocketSignalManager(signals, () => (this._signalTelemetryEnabled ? this._signalMetadataTags : {}))
101
- : new MemorySignalManager(new MemorySignalManagerContext()), // TODO(dmaretskyi): Inject this context.
99
+ signalManager: this._config.get('runtime.client.edgeFeatures')?.signaling
100
+ ? undefined
101
+ : signals
102
+ ? new WebsocketSignalManager(signals, () => (this._signalTelemetryEnabled ? this._signalMetadataTags : {}))
103
+ : new MemorySignalManager(new MemorySignalManagerContext()), // TODO(dmaretskyi): Inject this context.
102
104
  transportFactory: this._transportFactory,
103
105
  });
104
106
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const DXOS_VERSION = "0.6.8-main.3be982f";
1
+ export const DXOS_VERSION = "0.6.8-staging.63bcb81";