@dxos/client 2.28.2-dev.5bd59700 → 2.28.2-dev.cc97ac04
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/src/api/echo-proxy.d.ts +8 -3
- package/dist/src/api/echo-proxy.d.ts.map +1 -1
- package/dist/src/api/echo-proxy.js +10 -4
- package/dist/src/api/echo-proxy.js.map +1 -1
- package/dist/src/api/halo-proxy.d.ts +7 -4
- package/dist/src/api/halo-proxy.d.ts.map +1 -1
- package/dist/src/api/halo-proxy.js +9 -1
- package/dist/src/api/halo-proxy.js.map +1 -1
- package/dist/src/api/party-proxy.d.ts +12 -3
- package/dist/src/api/party-proxy.d.ts.map +1 -1
- package/dist/src/api/party-proxy.js +15 -3
- package/dist/src/api/party-proxy.js.map +1 -1
- package/dist/src/client/client.d.ts +3 -1
- package/dist/src/client/client.d.ts.map +1 -1
- package/dist/src/client/client.js +1 -1
- package/dist/src/client/client.js.map +1 -1
- package/dist/src/client/service-host/service-host.d.ts +1 -1
- package/dist/src/client/service-host/service-host.d.ts.map +1 -1
- package/dist/src/client/service-host/service-host.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/api/echo-proxy.ts +15 -7
- package/src/api/halo-proxy.ts +11 -6
- package/src/api/party-proxy.ts +18 -6
- package/src/client/client.ts +3 -3
- package/src/client/service-host/service-host.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/client",
|
|
3
|
-
"version": "2.28.2-dev.
|
|
3
|
+
"version": "2.28.2-dev.cc97ac04",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "DXOS.org",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
"src"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dxos/async": "2.28.2-dev.
|
|
14
|
-
"@dxos/codec-protobuf": "2.28.2-dev.
|
|
15
|
-
"@dxos/config": "2.28.2-dev.
|
|
16
|
-
"@dxos/credentials": "2.28.2-dev.
|
|
17
|
-
"@dxos/crypto": "2.28.2-dev.
|
|
18
|
-
"@dxos/debug": "2.28.2-dev.
|
|
19
|
-
"@dxos/echo-db": "2.28.2-dev.
|
|
20
|
-
"@dxos/echo-protocol": "2.28.2-dev.
|
|
21
|
-
"@dxos/feed-store": "2.28.2-dev.
|
|
22
|
-
"@dxos/model-factory": "2.28.2-dev.
|
|
23
|
-
"@dxos/network-manager": "2.28.2-dev.
|
|
24
|
-
"@dxos/object-model": "2.28.2-dev.
|
|
25
|
-
"@dxos/protocols": "2.28.2-dev.
|
|
26
|
-
"@dxos/rpc": "2.28.2-dev.
|
|
27
|
-
"@dxos/util": "2.28.2-dev.
|
|
13
|
+
"@dxos/async": "2.28.2-dev.cc97ac04",
|
|
14
|
+
"@dxos/codec-protobuf": "2.28.2-dev.cc97ac04",
|
|
15
|
+
"@dxos/config": "2.28.2-dev.cc97ac04",
|
|
16
|
+
"@dxos/credentials": "2.28.2-dev.cc97ac04",
|
|
17
|
+
"@dxos/crypto": "2.28.2-dev.cc97ac04",
|
|
18
|
+
"@dxos/debug": "2.28.2-dev.cc97ac04",
|
|
19
|
+
"@dxos/echo-db": "2.28.2-dev.cc97ac04",
|
|
20
|
+
"@dxos/echo-protocol": "2.28.2-dev.cc97ac04",
|
|
21
|
+
"@dxos/feed-store": "2.28.2-dev.cc97ac04",
|
|
22
|
+
"@dxos/model-factory": "2.28.2-dev.cc97ac04",
|
|
23
|
+
"@dxos/network-manager": "2.28.2-dev.cc97ac04",
|
|
24
|
+
"@dxos/object-model": "2.28.2-dev.cc97ac04",
|
|
25
|
+
"@dxos/protocols": "2.28.2-dev.cc97ac04",
|
|
26
|
+
"@dxos/rpc": "2.28.2-dev.cc97ac04",
|
|
27
|
+
"@dxos/util": "2.28.2-dev.cc97ac04",
|
|
28
28
|
"@polkadot/keyring": "6.11.1",
|
|
29
29
|
"@polkadot/util": "6.11.1",
|
|
30
30
|
"@polkadot/util-crypto": "6.11.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"uuid": "^8.3.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@dxos/random-access-multi-storage": "2.28.2-dev.
|
|
44
|
+
"@dxos/random-access-multi-storage": "2.28.2-dev.cc97ac04",
|
|
45
45
|
"@dxos/testutils": "2.28.1",
|
|
46
46
|
"@dxos/toolchain-node-library": "2.28.1",
|
|
47
47
|
"@types/debug": "^4.1.7",
|
package/src/api/echo-proxy.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
62
|
+
return `EchoProxy(${JSON.stringify(this.info())})`;
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
info () {
|
|
62
|
-
return
|
|
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(
|
|
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,
|
package/src/api/halo-proxy.ts
CHANGED
|
@@ -4,17 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
import { Event } from '@dxos/async';
|
|
6
6
|
import { KeyRecord } from '@dxos/credentials';
|
|
7
|
-
import { Contact, CreateProfileOptions, InvitationDescriptor,
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Client proxy to local/remote HALO service.
|
|
16
|
+
*/
|
|
18
17
|
export class HaloProxy {
|
|
19
18
|
private readonly _invitationProxy = new InvitationProxy();
|
|
20
19
|
private readonly _subscriptions = new SubscriptionGroup();
|
|
@@ -30,7 +29,13 @@ export class HaloProxy {
|
|
|
30
29
|
) {}
|
|
31
30
|
|
|
32
31
|
toString () {
|
|
33
|
-
return `HaloProxy(${this.
|
|
32
|
+
return `HaloProxy(${JSON.stringify(this.info())})`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
info () {
|
|
36
|
+
return {
|
|
37
|
+
key: this._profile?.publicKey
|
|
38
|
+
};
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
get invitationProxy () {
|
package/src/api/party-proxy.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { PublicKey } from '@dxos/crypto';
|
|
6
6
|
import { failUndefined } from '@dxos/debug';
|
|
7
7
|
import {
|
|
8
|
-
PARTY_ITEM_TYPE, PARTY_TITLE_PROPERTY, ActivationOptions, Database, RemoteDatabaseBackend
|
|
8
|
+
PARTY_ITEM_TYPE, PARTY_TITLE_PROPERTY, ActivationOptions, Database, RemoteDatabaseBackend
|
|
9
9
|
} from '@dxos/echo-db';
|
|
10
10
|
import { PartyKey } from '@dxos/echo-protocol';
|
|
11
11
|
import { ModelFactory } from '@dxos/model-factory';
|
|
@@ -21,6 +21,10 @@ export interface CreationInvitationOptions {
|
|
|
21
21
|
inviteeKey?: PublicKey
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Main public Party API.
|
|
26
|
+
* Proxies requests to local/remove services.
|
|
27
|
+
*/
|
|
24
28
|
export class Party {
|
|
25
29
|
private readonly _database?: Database;
|
|
26
30
|
private readonly _invitationProxy = new InvitationProxy();
|
|
@@ -41,7 +45,6 @@ export class Party {
|
|
|
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
|
}
|
|
@@ -134,10 +137,17 @@ export class Party {
|
|
|
134
137
|
/**
|
|
135
138
|
* Returns a selection context, which can be used to traverse the object graph.
|
|
136
139
|
*/
|
|
137
|
-
get select ():
|
|
140
|
+
get select (): Database['select'] {
|
|
138
141
|
return this.database.select.bind(this.database);
|
|
139
142
|
}
|
|
140
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Returns a selection context, which can be used to traverse the object graph.
|
|
146
|
+
*/
|
|
147
|
+
get reduce (): Database['reduce'] {
|
|
148
|
+
return this.database.reduce.bind(this.database);
|
|
149
|
+
}
|
|
150
|
+
|
|
141
151
|
/**
|
|
142
152
|
* Creates an invitation to a given party.
|
|
143
153
|
* The Invitation flow requires the inviter and invitee to be online at the same time.
|
|
@@ -146,7 +156,8 @@ export class Party {
|
|
|
146
156
|
*
|
|
147
157
|
* To be used with `client.echo.acceptInvitation` on the invitee side.
|
|
148
158
|
*
|
|
149
|
-
* @param inviteeKey Public key of the invitee. In this case no secret exchange is required,
|
|
159
|
+
* @param inviteeKey Public key of the invitee. In this case no secret exchange is required,
|
|
160
|
+
* but only the specified recipient can accept the invitation.
|
|
150
161
|
*/
|
|
151
162
|
async createInvitation ({ inviteeKey }: CreationInvitationOptions = {}): Promise<InvitationRequest> {
|
|
152
163
|
const stream = this._serviceProvider.services.PartyService.createInvitation({ partyKey: this.key, inviteeKey });
|
|
@@ -160,8 +171,9 @@ export class Party {
|
|
|
160
171
|
);
|
|
161
172
|
}
|
|
162
173
|
|
|
163
|
-
setTitle (title: string) {
|
|
164
|
-
|
|
174
|
+
async setTitle (title: string) {
|
|
175
|
+
await this.setProperty(PARTY_TITLE_PROPERTY, title);
|
|
176
|
+
return this;
|
|
165
177
|
}
|
|
166
178
|
|
|
167
179
|
async setProperty (key: string, value?: any) {
|
package/src/client/client.ts
CHANGED
|
@@ -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');
|
|
@@ -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
|