@dxos/client-services 0.5.9-main.df0042a → 0.5.9-main.e183eeb

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_2K5VPBW6 = require("../../chunk-2K5VPBW6.cjs");
33
+ var import_chunk_F2EIFQZH = require("../../chunk-F2EIFQZH.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_2K5VPBW6.ServiceContext) {
230
+ if (host instanceof import_chunk_F2EIFQZH.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_2K5VPBW6.ServiceContext) {
240
+ if (guest instanceof import_chunk_F2EIFQZH.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_2K5VPBW6.ClientServicesHost({
249
+ return new import_chunk_F2EIFQZH.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_2K5VPBW6.ServiceContext(storage, level, networkManager, signalManager, {
265
+ return new import_chunk_F2EIFQZH.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_2K5VPBW6.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_F2EIFQZH.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_2K5VPBW6.InvitationsManager(new import_chunk_2K5VPBW6.InvitationsHandler(this.networkManager), (invitation) => {
369
+ return this._props.invitationsManager ??= new import_chunk_F2EIFQZH.InvitationsManager(new import_chunk_F2EIFQZH.InvitationsHandler(this.networkManager), (invitation) => {
370
370
  if (invitation.kind === import_services2.Invitation.Kind.SPACE) {
371
- return new import_chunk_2K5VPBW6.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
371
+ return new import_chunk_F2EIFQZH.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,QA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B,EACjD,eAAe,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,QAAQ,CAAC,EACrE,gBAAgB,CAAC,aAAY,eAAe,GAAG,SAAS,KAAK,QAAQ,IAAI,CAAC,aAAA;cAKpE,KAAK;IAOxB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC;YAO9D,mBAAmB;IAO3B,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC;IAI9E,aAAa,IAAI,MAAM,CAAC,qBAAqB,CAAC;IAS9C,OAAO,CAAC,YAAY;IAYd,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAO/D,gBAAgB,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,uBAAuB,GAAG,OAAO,CAAC,YAAY,CAAC;YAYjF,+BAA+B;CAuC9C"}
@@ -1,2 +1,2 @@
1
- export declare const DXOS_VERSION = "0.5.9-main.df0042a";
1
+ export declare const DXOS_VERSION = "0.5.9-main.e183eeb";
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.df0042a",
3
+ "version": "0.5.9-main.e183eeb",
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.df0042a",
27
- "@dxos/automerge": "0.5.9-main.df0042a",
28
- "@dxos/client-protocol": "0.5.9-main.df0042a",
29
- "@dxos/codec-protobuf": "0.5.9-main.df0042a",
30
- "@dxos/config": "0.5.9-main.df0042a",
31
- "@dxos/context": "0.5.9-main.df0042a",
32
- "@dxos/crypto": "0.5.9-main.df0042a",
33
- "@dxos/credentials": "0.5.9-main.df0042a",
34
- "@dxos/debug": "0.5.9-main.df0042a",
35
- "@dxos/echo-db": "0.5.9-main.df0042a",
36
- "@dxos/echo-protocol": "0.5.9-main.df0042a",
37
- "@dxos/echo-pipeline": "0.5.9-main.df0042a",
38
- "@dxos/echo-schema": "0.5.9-main.df0042a",
39
- "@dxos/feed-store": "0.5.9-main.df0042a",
40
- "@dxos/indexing": "0.5.9-main.df0042a",
41
- "@dxos/keyring": "0.5.9-main.df0042a",
42
- "@dxos/invariant": "0.5.9-main.df0042a",
43
- "@dxos/keys": "0.5.9-main.df0042a",
44
- "@dxos/kv-store": "0.5.9-main.df0042a",
45
- "@dxos/lock-file": "0.5.9-main.df0042a",
46
- "@dxos/messaging": "0.5.9-main.df0042a",
47
- "@dxos/log": "0.5.9-main.df0042a",
48
- "@dxos/network-manager": "0.5.9-main.df0042a",
49
- "@dxos/node-std": "0.5.9-main.df0042a",
50
- "@dxos/protocols": "0.5.9-main.df0042a",
51
- "@dxos/random-access-storage": "0.5.9-main.df0042a",
52
- "@dxos/rpc": "0.5.9-main.df0042a",
53
- "@dxos/teleport-extension-object-sync": "0.5.9-main.df0042a",
54
- "@dxos/teleport-extension-gossip": "0.5.9-main.df0042a",
55
- "@dxos/teleport": "0.5.9-main.df0042a",
56
- "@dxos/timeframe": "0.5.9-main.df0042a",
57
- "@dxos/tracing": "0.5.9-main.df0042a",
58
- "@dxos/websocket-rpc": "0.5.9-main.df0042a",
59
- "@dxos/util": "0.5.9-main.df0042a"
26
+ "@dxos/async": "0.5.9-main.e183eeb",
27
+ "@dxos/automerge": "0.5.9-main.e183eeb",
28
+ "@dxos/client-protocol": "0.5.9-main.e183eeb",
29
+ "@dxos/codec-protobuf": "0.5.9-main.e183eeb",
30
+ "@dxos/config": "0.5.9-main.e183eeb",
31
+ "@dxos/context": "0.5.9-main.e183eeb",
32
+ "@dxos/credentials": "0.5.9-main.e183eeb",
33
+ "@dxos/crypto": "0.5.9-main.e183eeb",
34
+ "@dxos/debug": "0.5.9-main.e183eeb",
35
+ "@dxos/echo-db": "0.5.9-main.e183eeb",
36
+ "@dxos/echo-protocol": "0.5.9-main.e183eeb",
37
+ "@dxos/echo-schema": "0.5.9-main.e183eeb",
38
+ "@dxos/echo-pipeline": "0.5.9-main.e183eeb",
39
+ "@dxos/feed-store": "0.5.9-main.e183eeb",
40
+ "@dxos/invariant": "0.5.9-main.e183eeb",
41
+ "@dxos/indexing": "0.5.9-main.e183eeb",
42
+ "@dxos/keys": "0.5.9-main.e183eeb",
43
+ "@dxos/keyring": "0.5.9-main.e183eeb",
44
+ "@dxos/lock-file": "0.5.9-main.e183eeb",
45
+ "@dxos/kv-store": "0.5.9-main.e183eeb",
46
+ "@dxos/log": "0.5.9-main.e183eeb",
47
+ "@dxos/messaging": "0.5.9-main.e183eeb",
48
+ "@dxos/network-manager": "0.5.9-main.e183eeb",
49
+ "@dxos/protocols": "0.5.9-main.e183eeb",
50
+ "@dxos/node-std": "0.5.9-main.e183eeb",
51
+ "@dxos/rpc": "0.5.9-main.e183eeb",
52
+ "@dxos/teleport": "0.5.9-main.e183eeb",
53
+ "@dxos/random-access-storage": "0.5.9-main.e183eeb",
54
+ "@dxos/teleport-extension-object-sync": "0.5.9-main.e183eeb",
55
+ "@dxos/timeframe": "0.5.9-main.e183eeb",
56
+ "@dxos/teleport-extension-gossip": "0.5.9-main.e183eeb",
57
+ "@dxos/tracing": "0.5.9-main.e183eeb",
58
+ "@dxos/util": "0.5.9-main.e183eeb",
59
+ "@dxos/websocket-rpc": "0.5.9-main.e183eeb"
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.df0042a"
64
+ "@dxos/signal": "0.5.9-main.e183eeb"
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
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const DXOS_VERSION = "0.5.9-main.df0042a";
1
+ export const DXOS_VERSION = "0.5.9-main.e183eeb";