@dxos/client-services 0.5.9-main.44fe51d → 0.5.9-main.4c63b2f

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.
@@ -30,7 +30,7 @@ __export(testing_exports, {
30
30
  sanitizeInvitation: () => sanitizeInvitation
31
31
  });
32
32
  module.exports = __toCommonJS(testing_exports);
33
- var import_chunk_X2MLOLTD = require("../../chunk-X2MLOLTD.cjs");
33
+ var import_chunk_DG6DPGCI = require("../../chunk-DG6DPGCI.cjs");
34
34
  var import_credentials = require("@dxos/credentials");
35
35
  var import_keys = require("@dxos/keys");
36
36
  var import_async = require("@dxos/async");
@@ -227,7 +227,7 @@ var createInvitation = async (host, options) => {
227
227
  authMethod: import_services.Invitation.AuthMethod.NONE,
228
228
  ...options ?? {}
229
229
  };
230
- if (host instanceof import_chunk_X2MLOLTD.ServiceContext) {
230
+ if (host instanceof import_chunk_DG6DPGCI.ServiceContext) {
231
231
  return host.invitationsManager.createInvitation({
232
232
  kind: import_services.Invitation.Kind.SPACE,
233
233
  ...options
@@ -237,7 +237,7 @@ var createInvitation = async (host, options) => {
237
237
  };
238
238
  var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
239
239
  invitation = sanitizeInvitation(invitation);
240
- if (guest instanceof import_chunk_X2MLOLTD.ServiceContext) {
240
+ if (guest instanceof import_chunk_DG6DPGCI.ServiceContext) {
241
241
  return guest.invitationsManager.acceptInvitation({
242
242
  invitation,
243
243
  deviceProfile: guestDeviceProfile
@@ -246,7 +246,7 @@ var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
246
246
  return guest.join(invitation, guestDeviceProfile);
247
247
  };
248
248
  var createServiceHost = (config, signalManagerContext) => {
249
- return new import_chunk_X2MLOLTD.ClientServicesHost({
249
+ return new import_chunk_DG6DPGCI.ClientServicesHost({
250
250
  config,
251
251
  signalManager: new import_messaging.MemorySignalManager(signalManagerContext),
252
252
  transportFactory: import_network_manager.MemoryTransportFactory
@@ -262,7 +262,7 @@ var createServiceContext = async ({ signalContext = new import_messaging.MemoryS
262
262
  });
263
263
  const level = (0, import_testing.createTestLevel)();
264
264
  await level.open();
265
- return new import_chunk_X2MLOLTD.ServiceContext(storage, level, networkManager, signalManager, {
265
+ return new import_chunk_DG6DPGCI.ServiceContext(storage, level, networkManager, signalManager, {
266
266
  invitationConnectionDefaultParams: {
267
267
  controlHeartbeatInterval: 200
268
268
  },
@@ -363,12 +363,12 @@ var TestPeer = class {
363
363
  });
364
364
  }
365
365
  get dataSpaceManager() {
366
- return this._props.dataSpaceManager ??= new import_chunk_X2MLOLTD.DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, this.identity, this.feedStore, this.echoHost, this.invitationsManager, this._opts.dataSpaceParams);
366
+ return this._props.dataSpaceManager ??= new import_chunk_DG6DPGCI.DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, this.identity, this.feedStore, this.echoHost, this.invitationsManager, this._opts.dataSpaceParams);
367
367
  }
368
368
  get invitationsManager() {
369
- return this._props.invitationsManager ??= new import_chunk_X2MLOLTD.InvitationsManager(new import_chunk_X2MLOLTD.InvitationsHandler(this.networkManager), (invitation) => {
369
+ return this._props.invitationsManager ??= new import_chunk_DG6DPGCI.InvitationsManager(new import_chunk_DG6DPGCI.InvitationsHandler(this.networkManager), (invitation) => {
370
370
  if (invitation.kind === import_services2.Invitation.Kind.SPACE) {
371
- return new import_chunk_X2MLOLTD.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
371
+ return new import_chunk_DG6DPGCI.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
372
372
  } else {
373
373
  throw new Error("not implemented");
374
374
  }
@@ -1 +1 @@
1
- {"version":3,"file":"identity-service.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/identity/identity-service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,Q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AAE,QAAQ,EAAE,OAAO,EAAE,EAAE,wBAAwB;IAajE,gBAAgB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC;IAmB7E,gBAAgB,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,uBAAuB;IAmBnE,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO9G,OAAO,CAAC,eAAe;IA6CvB,OAAO,CAAC,gBAAgB;YASV,cAAc;CAS7B"}
@@ -1,2 +1,2 @@
1
- export declare const DXOS_VERSION = "0.5.9-main.44fe51d";
1
+ export declare const DXOS_VERSION = "0.5.9-main.4c63b2f";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/client-services",
3
- "version": "0.5.9-main.44fe51d",
3
+ "version": "0.5.9-main.4c63b2f",
4
4
  "description": "DXOS client services implementation",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -23,45 +23,45 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "platform": "^1.3.6",
26
- "@dxos/async": "0.5.9-main.44fe51d",
27
- "@dxos/automerge": "0.5.9-main.44fe51d",
28
- "@dxos/codec-protobuf": "0.5.9-main.44fe51d",
29
- "@dxos/client-protocol": "0.5.9-main.44fe51d",
30
- "@dxos/config": "0.5.9-main.44fe51d",
31
- "@dxos/context": "0.5.9-main.44fe51d",
32
- "@dxos/crypto": "0.5.9-main.44fe51d",
33
- "@dxos/credentials": "0.5.9-main.44fe51d",
34
- "@dxos/debug": "0.5.9-main.44fe51d",
35
- "@dxos/echo-db": "0.5.9-main.44fe51d",
36
- "@dxos/echo-pipeline": "0.5.9-main.44fe51d",
37
- "@dxos/echo-protocol": "0.5.9-main.44fe51d",
38
- "@dxos/feed-store": "0.5.9-main.44fe51d",
39
- "@dxos/echo-schema": "0.5.9-main.44fe51d",
40
- "@dxos/indexing": "0.5.9-main.44fe51d",
41
- "@dxos/invariant": "0.5.9-main.44fe51d",
42
- "@dxos/keyring": "0.5.9-main.44fe51d",
43
- "@dxos/keys": "0.5.9-main.44fe51d",
44
- "@dxos/lock-file": "0.5.9-main.44fe51d",
45
- "@dxos/kv-store": "0.5.9-main.44fe51d",
46
- "@dxos/log": "0.5.9-main.44fe51d",
47
- "@dxos/messaging": "0.5.9-main.44fe51d",
48
- "@dxos/node-std": "0.5.9-main.44fe51d",
49
- "@dxos/protocols": "0.5.9-main.44fe51d",
50
- "@dxos/network-manager": "0.5.9-main.44fe51d",
51
- "@dxos/random-access-storage": "0.5.9-main.44fe51d",
52
- "@dxos/rpc": "0.5.9-main.44fe51d",
53
- "@dxos/teleport": "0.5.9-main.44fe51d",
54
- "@dxos/teleport-extension-object-sync": "0.5.9-main.44fe51d",
55
- "@dxos/teleport-extension-gossip": "0.5.9-main.44fe51d",
56
- "@dxos/timeframe": "0.5.9-main.44fe51d",
57
- "@dxos/tracing": "0.5.9-main.44fe51d",
58
- "@dxos/util": "0.5.9-main.44fe51d",
59
- "@dxos/websocket-rpc": "0.5.9-main.44fe51d"
26
+ "@dxos/async": "0.5.9-main.4c63b2f",
27
+ "@dxos/client-protocol": "0.5.9-main.4c63b2f",
28
+ "@dxos/codec-protobuf": "0.5.9-main.4c63b2f",
29
+ "@dxos/automerge": "0.5.9-main.4c63b2f",
30
+ "@dxos/config": "0.5.9-main.4c63b2f",
31
+ "@dxos/context": "0.5.9-main.4c63b2f",
32
+ "@dxos/credentials": "0.5.9-main.4c63b2f",
33
+ "@dxos/debug": "0.5.9-main.4c63b2f",
34
+ "@dxos/crypto": "0.5.9-main.4c63b2f",
35
+ "@dxos/echo-db": "0.5.9-main.4c63b2f",
36
+ "@dxos/echo-protocol": "0.5.9-main.4c63b2f",
37
+ "@dxos/echo-pipeline": "0.5.9-main.4c63b2f",
38
+ "@dxos/feed-store": "0.5.9-main.4c63b2f",
39
+ "@dxos/indexing": "0.5.9-main.4c63b2f",
40
+ "@dxos/echo-schema": "0.5.9-main.4c63b2f",
41
+ "@dxos/invariant": "0.5.9-main.4c63b2f",
42
+ "@dxos/keys": "0.5.9-main.4c63b2f",
43
+ "@dxos/keyring": "0.5.9-main.4c63b2f",
44
+ "@dxos/kv-store": "0.5.9-main.4c63b2f",
45
+ "@dxos/lock-file": "0.5.9-main.4c63b2f",
46
+ "@dxos/log": "0.5.9-main.4c63b2f",
47
+ "@dxos/network-manager": "0.5.9-main.4c63b2f",
48
+ "@dxos/node-std": "0.5.9-main.4c63b2f",
49
+ "@dxos/protocols": "0.5.9-main.4c63b2f",
50
+ "@dxos/random-access-storage": "0.5.9-main.4c63b2f",
51
+ "@dxos/messaging": "0.5.9-main.4c63b2f",
52
+ "@dxos/rpc": "0.5.9-main.4c63b2f",
53
+ "@dxos/teleport": "0.5.9-main.4c63b2f",
54
+ "@dxos/tracing": "0.5.9-main.4c63b2f",
55
+ "@dxos/teleport-extension-object-sync": "0.5.9-main.4c63b2f",
56
+ "@dxos/teleport-extension-gossip": "0.5.9-main.4c63b2f",
57
+ "@dxos/timeframe": "0.5.9-main.4c63b2f",
58
+ "@dxos/util": "0.5.9-main.4c63b2f",
59
+ "@dxos/websocket-rpc": "0.5.9-main.4c63b2f"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/platform": "^1.3.4",
63
63
  "@types/readable-stream": "^2.3.9",
64
- "@dxos/signal": "0.5.9-main.44fe51d"
64
+ "@dxos/signal": "0.5.9-main.4c63b2f"
65
65
  },
66
66
  "publishConfig": {
67
67
  "access": "public"
@@ -2,12 +2,14 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ import { Trigger, sleep } from '@dxos/async';
5
6
  import { Stream } from '@dxos/codec-protobuf';
6
7
  import { Resource } from '@dxos/context';
7
8
  import { signPresentation } from '@dxos/credentials';
8
9
  import { todo } from '@dxos/debug';
9
10
  import { invariant } from '@dxos/invariant';
10
11
  import { type Keyring } from '@dxos/keyring';
12
+ import { log } from '@dxos/log';
11
13
  import {
12
14
  type CreateIdentityRequest,
13
15
  type Identity as IdentityProto,
@@ -18,11 +20,14 @@ import {
18
20
  SpaceState,
19
21
  } from '@dxos/protocols/proto/dxos/client/services';
20
22
  import { type Presentation, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
23
+ import { safeAwaitAll } from '@dxos/util';
21
24
 
22
25
  import { type Identity } from './identity';
23
26
  import { type CreateIdentityOptions, type IdentityManager } from './identity-manager';
24
27
  import { type DataSpaceManager } from '../spaces';
25
28
 
29
+ const DEFAULT_SPACE_SEARCH_TIMEOUT = 10_000;
30
+
26
31
  export class IdentityServiceImpl extends Resource implements IdentityService {
27
32
  constructor(
28
33
  private readonly _identityManager: IdentityManager,
@@ -100,25 +105,41 @@ export class IdentityServiceImpl extends Resource implements IdentityService {
100
105
  }
101
106
 
102
107
  private async _fixIdentityWithoutDefaultSpace(identity: Identity) {
103
- let hasDefaultSpace = false;
108
+ let recodedDefaultSpace = false;
109
+ let foundDefaultSpace = false;
104
110
  const dataSpaceManager = this._dataSpaceManagerProvider();
105
- for (const space of dataSpaceManager.spaces.values()) {
111
+
112
+ const recordedDefaultSpaceTrigger = new Trigger();
113
+
114
+ const allProcessed = safeAwaitAll(dataSpaceManager.spaces.values(), async (space) => {
106
115
  if (space.state === SpaceState.CLOSED) {
107
116
  await space.open();
108
117
 
109
118
  // Wait until the space is either READY or REQUIRES_MIGRATION.
119
+ // NOTE: Space could potentially never initialize if the space data is corrupted.
110
120
  const requiresMigration = space.stateUpdate.waitForCondition(
111
121
  () => space.state === SpaceState.REQUIRES_MIGRATION,
112
122
  );
113
123
  await Promise.race([space.initializeDataPipeline(), requiresMigration]);
114
124
  }
115
125
  if (await dataSpaceManager.isDefaultSpace(space)) {
126
+ if (foundDefaultSpace) {
127
+ log.warn('Multiple default spaces found. Using the first one.', { duplicate: space.id });
128
+ return;
129
+ }
130
+
131
+ foundDefaultSpace = true;
116
132
  await identity.updateDefaultSpace(space.id);
117
- hasDefaultSpace = true;
118
- break;
133
+ recodedDefaultSpace = true;
134
+ recordedDefaultSpaceTrigger.wake();
119
135
  }
120
- }
121
- if (!hasDefaultSpace) {
136
+ });
137
+
138
+ // Wait for all spaces to be processed or until the default space is recorded.
139
+ // If the timeout is reached, create a new default space.
140
+ await Promise.race([allProcessed, recordedDefaultSpaceTrigger.wait(), sleep(DEFAULT_SPACE_SEARCH_TIMEOUT)]);
141
+
142
+ if (!recodedDefaultSpace) {
122
143
  await this._createDefaultSpace(dataSpaceManager);
123
144
  }
124
145
  }
@@ -386,9 +386,7 @@ export class DataSpace {
386
386
 
387
387
  private _onNewAutomergeRoot(rootUrl: string) {
388
388
  log('loading automerge root doc for space', { space: this.key, rootUrl });
389
- // Override share policy = true for the root document.
390
- // Workaround for https://github.com/automerge/automerge-repo/pull/292
391
- this._echoHost.replicateDocument(rootUrl);
389
+
392
390
  const handle = this._echoHost.automergeRepo.find(rootUrl as any);
393
391
 
394
392
  // TODO(dmaretskyi): Make this single-threaded (but doc loading should still be parallel to not block epoch processing).
@@ -417,8 +415,10 @@ export class DataSpace {
417
415
  const root = await this._echoHost.openSpaceRoot(handle.url);
418
416
  this._databaseRoot = root;
419
417
  if (root.getVersion() !== SpaceDocVersion.CURRENT) {
420
- this._state = SpaceState.REQUIRES_MIGRATION;
421
- this.stateUpdate.emit();
418
+ if (this._state !== SpaceState.REQUIRES_MIGRATION) {
419
+ this._state = SpaceState.REQUIRES_MIGRATION;
420
+ this.stateUpdate.emit();
421
+ }
422
422
  } else {
423
423
  if (this._state !== SpaceState.READY) {
424
424
  await this._enterReadyState();
@@ -126,8 +126,18 @@ export class SpacesServiceImpl implements SpacesService {
126
126
  subscriptions.clear();
127
127
 
128
128
  for (const space of dataSpaceManager.spaces.values()) {
129
- // TODO(dmaretskyi): This can skip updates and not report intermediate states. Potential race condition here.
130
- subscriptions.add(space.stateUpdate.on(ctx, () => scheduler.forceTrigger()));
129
+ let lastState: SpaceState | undefined;
130
+ subscriptions.add(
131
+ space.stateUpdate.on(ctx, () => {
132
+ // Always send a separate update if the space state has changed.
133
+ if (space.state !== lastState) {
134
+ scheduler.forceTrigger();
135
+ } else {
136
+ scheduler.trigger();
137
+ }
138
+ lastState = space.state;
139
+ }),
140
+ );
131
141
 
132
142
  subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
133
143
  subscriptions.add(space.automergeSpaceState.onNewEpoch.on(ctx, () => scheduler.trigger()));
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const DXOS_VERSION = "0.5.9-main.44fe51d";
1
+ export const DXOS_VERSION = "0.5.9-main.4c63b2f";