@dxos/client 2.28.1-dev.f858bec7 → 2.28.2-dev.3df58cd5

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 (35) hide show
  1. package/dist/src/api/echo-proxy.d.ts +8 -3
  2. package/dist/src/api/echo-proxy.d.ts.map +1 -1
  3. package/dist/src/api/echo-proxy.js +10 -4
  4. package/dist/src/api/echo-proxy.js.map +1 -1
  5. package/dist/src/api/halo-proxy.d.ts +12 -7
  6. package/dist/src/api/halo-proxy.d.ts.map +1 -1
  7. package/dist/src/api/halo-proxy.js +17 -6
  8. package/dist/src/api/halo-proxy.js.map +1 -1
  9. package/dist/src/api/invitations/invitation-proxy.d.ts +1 -1
  10. package/dist/src/api/invitations/invitation-proxy.d.ts.map +1 -1
  11. package/dist/src/api/invitations/invitation-proxy.js.map +1 -1
  12. package/dist/src/api/party-proxy.d.ts +9 -2
  13. package/dist/src/api/party-proxy.d.ts.map +1 -1
  14. package/dist/src/api/party-proxy.js +15 -6
  15. package/dist/src/api/party-proxy.js.map +1 -1
  16. package/dist/src/client/client.d.ts +3 -1
  17. package/dist/src/client/client.d.ts.map +1 -1
  18. package/dist/src/client/client.js +1 -1
  19. package/dist/src/client/client.js.map +1 -1
  20. package/dist/src/client/service-host/service-host.d.ts +1 -1
  21. package/dist/src/client/service-host/service-host.d.ts.map +1 -1
  22. package/dist/src/client/service-host/service-host.js +1 -1
  23. package/dist/src/client/service-host/service-host.js.map +1 -1
  24. package/dist/src/client/service-host/services/halo.d.ts.map +1 -1
  25. package/dist/src/client/service-host/services/halo.js.map +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +20 -20
  28. package/src/api/echo-proxy.ts +15 -7
  29. package/src/api/halo-proxy.ts +22 -12
  30. package/src/api/invitations/invitation-proxy.ts +1 -1
  31. package/src/api/party-proxy.ts +17 -8
  32. package/src/client/client.ts +3 -3
  33. package/src/client/service-host/service-host.ts +2 -2
  34. package/src/client/service-host/services/halo.ts +0 -1
  35. package/src/proto/imports.proto +4 -4
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dxos/client",
3
- "version": "2.28.1-dev.f858bec7",
4
- "license": "AGPL-3.0",
3
+ "version": "2.28.2-dev.3df58cd5",
4
+ "license": "MIT",
5
5
  "author": "DXOS.org",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -10,21 +10,21 @@
10
10
  "src"
11
11
  ],
12
12
  "dependencies": {
13
- "@dxos/async": "2.28.1-dev.f858bec7",
14
- "@dxos/codec-protobuf": "2.28.1-dev.f858bec7",
15
- "@dxos/config": "2.28.1-dev.f858bec7",
16
- "@dxos/credentials": "2.28.1-dev.f858bec7",
17
- "@dxos/crypto": "2.28.1-dev.f858bec7",
18
- "@dxos/debug": "2.28.1-dev.f858bec7",
19
- "@dxos/echo-db": "2.28.1-dev.f858bec7",
20
- "@dxos/echo-protocol": "2.28.1-dev.f858bec7",
21
- "@dxos/feed-store": "2.28.1-dev.f858bec7",
22
- "@dxos/model-factory": "2.28.1-dev.f858bec7",
23
- "@dxos/network-manager": "2.28.1-dev.f858bec7",
24
- "@dxos/object-model": "2.28.1-dev.f858bec7",
25
- "@dxos/protocol": "2.28.1-dev.f858bec7",
26
- "@dxos/rpc": "2.28.1-dev.f858bec7",
27
- "@dxos/util": "2.28.1-dev.f858bec7",
13
+ "@dxos/async": "2.28.2-dev.3df58cd5",
14
+ "@dxos/codec-protobuf": "2.28.2-dev.3df58cd5",
15
+ "@dxos/config": "2.28.2-dev.3df58cd5",
16
+ "@dxos/credentials": "2.28.2-dev.3df58cd5",
17
+ "@dxos/crypto": "2.28.2-dev.3df58cd5",
18
+ "@dxos/debug": "2.28.2-dev.3df58cd5",
19
+ "@dxos/echo-db": "2.28.2-dev.3df58cd5",
20
+ "@dxos/echo-protocol": "2.28.2-dev.3df58cd5",
21
+ "@dxos/feed-store": "2.28.2-dev.3df58cd5",
22
+ "@dxos/model-factory": "2.28.2-dev.3df58cd5",
23
+ "@dxos/network-manager": "2.28.2-dev.3df58cd5",
24
+ "@dxos/object-model": "2.28.2-dev.3df58cd5",
25
+ "@dxos/protocols": "2.28.2-dev.3df58cd5",
26
+ "@dxos/rpc": "2.28.2-dev.3df58cd5",
27
+ "@dxos/util": "2.28.2-dev.3df58cd5",
28
28
  "@polkadot/keyring": "6.11.1",
29
29
  "@polkadot/util": "6.11.1",
30
30
  "@polkadot/util-crypto": "6.11.1",
@@ -41,9 +41,9 @@
41
41
  "uuid": "^8.3.2"
42
42
  },
43
43
  "devDependencies": {
44
- "@dxos/random-access-multi-storage": "2.28.1-dev.f858bec7",
45
- "@dxos/testutils": "2.28.0",
46
- "@dxos/toolchain-node-library": "2.28.0",
44
+ "@dxos/random-access-multi-storage": "2.28.2-dev.3df58cd5",
45
+ "@dxos/testutils": "2.28.1",
46
+ "@dxos/toolchain-node-library": "2.28.1",
47
47
  "@types/debug": "^4.1.7",
48
48
  "@types/jest": "^26.0.7",
49
49
  "@types/level-js": "~4.0.1",
@@ -28,17 +28,21 @@ export class PartyInvitation extends Invitation<Party> {
28
28
  }
29
29
  }
30
30
 
31
+ /**
32
+ * Client proxy to local/remote ECHO service.
33
+ */
31
34
  export class EchoProxy {
32
- private readonly _modelFactory: ModelFactory;
33
- private _parties = new ComplexMap<PublicKey, Party>(key => key.toHex());
35
+ private readonly _parties = new ComplexMap<PublicKey, Party>(key => key.toHex());
34
36
  private readonly _partiesChanged = new Event();
35
37
  private readonly _subscriptions = new SubscriptionGroup();
38
+ private readonly _modelFactory: ModelFactory;
36
39
 
37
40
  constructor (
38
41
  private readonly _serviceProvider: ClientServiceProvider,
39
42
  private readonly _haloProxy: HaloProxy
40
43
  ) {
41
- this._modelFactory = _serviceProvider instanceof ClientServiceHost ? _serviceProvider.echo.modelFactory : new ModelFactory();
44
+ this._modelFactory = _serviceProvider instanceof ClientServiceHost
45
+ ? _serviceProvider.echo.modelFactory : new ModelFactory();
42
46
 
43
47
  this._modelFactory.registerModel(ObjectModel); // Register object-model by default.
44
48
  }
@@ -55,11 +59,13 @@ export class EchoProxy {
55
59
  }
56
60
 
57
61
  toString () {
58
- return 'EchoProxy';
62
+ return `EchoProxy(${JSON.stringify(this.info())})`;
59
63
  }
60
64
 
61
65
  info () {
62
- return this.toString();
66
+ return {
67
+ parties: this._parties.size
68
+ };
63
69
  }
64
70
 
65
71
  /**
@@ -99,6 +105,7 @@ export class EchoProxy {
99
105
  }
100
106
  this._partiesChanged.emit();
101
107
  }, () => {});
108
+
102
109
  this._subscriptions.push(() => partiesStream.close());
103
110
 
104
111
  await gotParties;
@@ -112,7 +119,7 @@ export class EchoProxy {
112
119
  await party.destroy();
113
120
  }
114
121
 
115
- this._subscriptions.unsubscribe();
122
+ await this._subscriptions.unsubscribe();
116
123
  }
117
124
 
118
125
  //
@@ -178,7 +185,8 @@ export class EchoProxy {
178
185
  * To be used with `party.createInvitation` on the inviter side.
179
186
  */
180
187
  acceptInvitation (invitationDescriptor: InvitationDescriptor): PartyInvitation {
181
- const invitationProcessStream = this._serviceProvider.services.PartyService.acceptInvitation(invitationDescriptor.toProto());
188
+ const invitationProcessStream = this._serviceProvider.services.PartyService.acceptInvitation(
189
+ invitationDescriptor.toProto());
182
190
  const { authenticate, waitForFinish } = InvitationProxy.handleInvitationRedemption({
183
191
  stream: invitationProcessStream,
184
192
  invitationDescriptor,
@@ -4,32 +4,42 @@
4
4
 
5
5
  import { Event } from '@dxos/async';
6
6
  import { KeyRecord } from '@dxos/credentials';
7
- import { Contact, CreateProfileOptions, InvitationDescriptor, InvitationOptions, PartyMember, ResultSet } from '@dxos/echo-db';
7
+ import { Contact, CreateProfileOptions, InvitationDescriptor, PartyMember, ResultSet } from '@dxos/echo-db';
8
8
  import { SubscriptionGroup } from '@dxos/util';
9
9
 
10
10
  import { ClientServiceProvider } from '../interfaces';
11
11
  import { Profile, SignRequest } from '../proto/gen/dxos/client';
12
12
  import { Invitation, InvitationProxy, InvitationRequest } from './invitations';
13
13
 
14
- export interface CreateInvitationOptions extends InvitationOptions {
15
- onPinGenerated?: (pin: string) => void
16
- }
14
+ /**
15
+ * Client proxy to local/remote HALO service.
16
+ */
17
+ export class HaloProxy {
18
+ private readonly _invitationProxy = new InvitationProxy();
19
+ private readonly _subscriptions = new SubscriptionGroup();
17
20
 
18
- export class HaloProxy extends InvitationProxy {
19
21
  private _profile?: Profile;
20
22
  private _contacts: PartyMember[] = [];
21
23
 
22
- public readonly profileChanged = new Event();
23
24
  private readonly _contactsChanged = new Event();
25
+ public readonly profileChanged = new Event();
24
26
 
25
- private readonly _subscriptions = new SubscriptionGroup();
27
+ constructor (
28
+ private readonly _serviceProvider: ClientServiceProvider
29
+ ) {}
30
+
31
+ toString () {
32
+ return `HaloProxy(${JSON.stringify(this.info())})`;
33
+ }
26
34
 
27
- constructor (private readonly _serviceProvider: ClientServiceProvider) {
28
- super();
35
+ info () {
36
+ return {
37
+ key: this._profile?.publicKey
38
+ };
29
39
  }
30
40
 
31
- override toString () {
32
- return `HaloProxy(${this._profile?.publicKey})`;
41
+ get invitationProxy () {
42
+ return this._invitationProxy;
33
43
  }
34
44
 
35
45
  /**
@@ -87,7 +97,7 @@ export class HaloProxy extends InvitationProxy {
87
97
  */
88
98
  async createInvitation (): Promise<InvitationRequest> {
89
99
  const stream = await this._serviceProvider.services.ProfileService.createInvitation();
90
- return this.createInvitationRequest({ stream });
100
+ return this._invitationProxy.createInvitationRequest({ stream });
91
101
  }
92
102
 
93
103
  /**
@@ -32,7 +32,7 @@ export class InvitationProxy {
32
32
  readonly activeInvitations: InvitationRequest[] = [];
33
33
  readonly invitationsUpdate = new Event();
34
34
 
35
- protected async createInvitationRequest ({ stream }: CreateInvitationRequestOpts): Promise<InvitationRequest> {
35
+ async createInvitationRequest ({ stream }: CreateInvitationRequestOpts): Promise<InvitationRequest> {
36
36
  return new Promise((resolve, reject) => {
37
37
  const connected = new Event();
38
38
  const finished = new Event();
@@ -5,7 +5,7 @@
5
5
  import { PublicKey } from '@dxos/crypto';
6
6
  import { failUndefined } from '@dxos/debug';
7
7
  import {
8
- ActivationOptions, Database, PARTY_ITEM_TYPE, PARTY_TITLE_PROPERTY, RemoteDatabaseBackend, RootSelector
8
+ PARTY_ITEM_TYPE, PARTY_TITLE_PROPERTY, ActivationOptions, Database, RemoteDatabaseBackend, RootSelector
9
9
  } from '@dxos/echo-db';
10
10
  import { PartyKey } from '@dxos/echo-protocol';
11
11
  import { ModelFactory } from '@dxos/model-factory';
@@ -21,8 +21,13 @@ export interface CreationInvitationOptions {
21
21
  inviteeKey?: PublicKey
22
22
  }
23
23
 
24
- export class Party extends InvitationProxy {
24
+ /**
25
+ * Main public Party API.
26
+ * Proxies requests to local/remove services.
27
+ */
28
+ export class Party {
25
29
  private readonly _database?: Database;
30
+ private readonly _invitationProxy = new InvitationProxy();
26
31
 
27
32
  private _key: PartyKey;
28
33
  private _isOpen: boolean;
@@ -37,11 +42,9 @@ export class Party extends InvitationProxy {
37
42
  party: PartyProto,
38
43
  memberKey: PublicKey
39
44
  ) {
40
- super();
41
45
  this._key = party.publicKey;
42
46
  this._isOpen = party.isOpen;
43
47
  this._isActive = party.isActive;
44
-
45
48
  if (!party.isOpen) {
46
49
  return;
47
50
  }
@@ -60,6 +63,10 @@ export class Party extends InvitationProxy {
60
63
  }
61
64
  }
62
65
 
66
+ get invitationProxy () {
67
+ return this._invitationProxy;
68
+ }
69
+
63
70
  async init () {
64
71
  if (this._database && this._serviceProvider instanceof ClientServiceProxy) {
65
72
  await this._database.init();
@@ -142,11 +149,12 @@ export class Party extends InvitationProxy {
142
149
  *
143
150
  * To be used with `client.echo.acceptInvitation` on the invitee side.
144
151
  *
145
- * @param inviteeKey Public key of the invitee. In this case no secret exchange is required, but only the specified recipient can accept the invitation.
152
+ * @param inviteeKey Public key of the invitee. In this case no secret exchange is required,
153
+ * but only the specified recipient can accept the invitation.
146
154
  */
147
155
  async createInvitation ({ inviteeKey }: CreationInvitationOptions = {}): Promise<InvitationRequest> {
148
156
  const stream = this._serviceProvider.services.PartyService.createInvitation({ partyKey: this.key, inviteeKey });
149
- return this.createInvitationRequest({ stream });
157
+ return this._invitationProxy.createInvitationRequest({ stream });
150
158
  }
151
159
 
152
160
  queryMembers () {
@@ -156,8 +164,9 @@ export class Party extends InvitationProxy {
156
164
  );
157
165
  }
158
166
 
159
- setTitle (title: string) {
160
- return this.setProperty(PARTY_TITLE_PROPERTY, title);
167
+ async setTitle (title: string) {
168
+ await this.setProperty(PARTY_TITLE_PROPERTY, title);
169
+ return this;
161
170
  }
162
171
 
163
172
  async setProperty (key: string, value?: any) {
@@ -55,9 +55,9 @@ export class Client {
55
55
 
56
56
  private readonly _config: Config;
57
57
  private readonly _options: ClientOptions;
58
+
58
59
  private readonly _mode: Runtime.Client.Mode;
59
60
  private _serviceProvider!: ClientServiceProvider;
60
-
61
61
  private _halo!: HaloProxy;
62
62
  private _echo!: EchoProxy;
63
63
 
@@ -71,14 +71,14 @@ export class Client {
71
71
  if (typeof config !== 'object' || config == null) {
72
72
  throw new InvalidParameterError('Invalid config.');
73
73
  }
74
+
74
75
  this._config = (config instanceof Config) ? config : new Config(config);
76
+ this._options = options;
75
77
 
76
78
  if (Object.keys(this._config.values).length > 0 && this._config.values.version !== EXPECTED_CONFIG_VERSION) {
77
79
  throw new InvalidConfigurationError(`Expected config version 1, got ${this._config.values.version}.`);
78
80
  }
79
81
 
80
- this._options = options;
81
-
82
82
  // TODO(burdon): Default error level: 'dxos:*:error'
83
83
  // TODO(burdon): config.getProperty('system.debug', process.env.DEBUG, '');
84
84
  debug.enable(this._config.values.runtime?.client?.debug ?? process.env.DEBUG ?? 'dxos:*:error');
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { Config } from '@dxos/config';
6
- import * as debug from '@dxos/debug'; // TODO(burdon): ???
6
+ import * as debug from '@dxos/debug'; // TODO(burdon): Why import *?
7
7
  import { ECHO, OpenProgress } from '@dxos/echo-db';
8
8
 
9
9
  import { createDevtoolsHost, DevtoolsHostEvents, DevtoolsServiceDependencies } from '../../devtools';
@@ -13,8 +13,8 @@ import { createServices } from './services';
13
13
  import { createStorageObjects } from './storage';
14
14
 
15
15
  export class ClientServiceHost implements ClientServiceProvider {
16
- private readonly _echo: ECHO;
17
16
  private readonly _devtoolsEvents = new DevtoolsHostEvents();
17
+ private readonly _echo: ECHO;
18
18
 
19
19
  constructor (
20
20
  private readonly _config: Config
@@ -21,7 +21,6 @@ import {
21
21
  SetPreferenceRequest,
22
22
  GetPreferenceRequest,
23
23
  GetPreferenceResponse
24
-
25
24
  } from '../../../proto/gen/dxos/client';
26
25
  import { resultSetToStream } from '../../../util';
27
26
  import { CreateServicesOpts } from './interfaces';
@@ -1,6 +1,6 @@
1
1
  syntax = "proto3";
2
2
 
3
- import "@dxos/protocol/src/proto/dxos/client.proto";
4
- import "@dxos/protocol/src/proto/dxos/devtools.proto";
5
- import "@dxos/protocol/src/proto/dxos/config.proto";
6
- import "@dxos/protocol/src/proto/dxos/echo/service.proto";
3
+ import "@dxos/protocols/src/proto/dxos/client.proto";
4
+ import "@dxos/protocols/src/proto/dxos/devtools.proto";
5
+ import "@dxos/protocols/src/proto/dxos/config.proto";
6
+ import "@dxos/protocols/src/proto/dxos/echo/service.proto";