@dxos/client 2.24.1-dev.656a99d5 → 2.25.1-dev.0ff9b5c9
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.map +1 -1
- package/dist/src/api/echo-proxy.js +3 -1
- package/dist/src/api/echo-proxy.js.map +1 -1
- package/dist/src/api/halo-proxy.d.ts +4 -1
- package/dist/src/api/halo-proxy.d.ts.map +1 -1
- package/dist/src/api/halo-proxy.js +11 -2
- package/dist/src/api/halo-proxy.js.map +1 -1
- package/dist/src/api/party-proxy.d.ts +5 -1
- package/dist/src/api/party-proxy.d.ts.map +1 -1
- package/dist/src/api/party-proxy.js +7 -1
- package/dist/src/api/party-proxy.js.map +1 -1
- package/dist/src/client/client.js +2 -2
- package/dist/src/client/client.js.map +1 -1
- package/dist/src/client/client.test.js +2 -2
- package/dist/src/client/client.test.js.map +1 -1
- package/dist/src/client/service-host/services/halo.d.ts +14 -0
- package/dist/src/client/service-host/services/halo.d.ts.map +1 -0
- package/dist/src/client/service-host/services/halo.js +73 -0
- package/dist/src/client/service-host/services/halo.js.map +1 -0
- package/dist/src/client/service-host/services/profile.d.ts +1 -2
- package/dist/src/client/service-host/services/profile.d.ts.map +1 -1
- package/dist/src/client/service-host/services/profile.js +0 -19
- package/dist/src/client/service-host/services/profile.js.map +1 -1
- package/dist/src/client/service-host/services/services.d.ts.map +1 -1
- package/dist/src/client/service-host/services/services.js +2 -0
- package/dist/src/client/service-host/services/services.js.map +1 -1
- package/dist/src/devtools/items.js +2 -2
- package/dist/src/devtools/items.js.map +1 -1
- package/dist/src/interfaces/client-service-provider.d.ts +2 -1
- package/dist/src/interfaces/client-service-provider.d.ts.map +1 -1
- package/dist/src/interfaces/client-service-provider.js +1 -0
- package/dist/src/interfaces/client-service-provider.js.map +1 -1
- package/dist/src/proto/gen/dxos/client.d.ts +33 -15
- package/dist/src/proto/gen/dxos/client.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/client.js.map +1 -1
- package/dist/src/proto/gen/index.d.ts +4 -0
- package/dist/src/proto/gen/index.d.ts.map +1 -1
- package/dist/src/proto/gen/index.js +1 -1
- package/dist/src/proto/gen/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -19
- package/src/api/echo-proxy.ts +5 -1
- package/src/api/halo-proxy.ts +17 -3
- package/src/api/party-proxy.ts +9 -2
- package/src/client/client.test.ts +2 -2
- package/src/client/client.ts +2 -2
- package/src/client/service-host/services/halo.ts +80 -0
- package/src/client/service-host/services/profile.ts +1 -32
- package/src/client/service-host/services/services.ts +2 -0
- package/src/devtools/items.ts +2 -2
- package/src/interfaces/client-service-provider.ts +3 -1
- package/src/proto/gen/dxos/client.ts +32 -15
- package/src/proto/gen/index.ts +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.1-dev.0ff9b5c9",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"author": "DXOS.org",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -10,21 +10,24 @@
|
|
|
10
10
|
"src"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dxos/async": "2.
|
|
14
|
-
"@dxos/codec-protobuf": "2.
|
|
15
|
-
"@dxos/config": "2.
|
|
16
|
-
"@dxos/credentials": "2.
|
|
17
|
-
"@dxos/crypto": "2.
|
|
18
|
-
"@dxos/debug": "2.
|
|
19
|
-
"@dxos/echo-db": "2.
|
|
20
|
-
"@dxos/echo-protocol": "2.
|
|
21
|
-
"@dxos/feed-store": "2.
|
|
22
|
-
"@dxos/model-factory": "2.
|
|
23
|
-
"@dxos/network-manager": "2.
|
|
24
|
-
"@dxos/object-model": "2.
|
|
25
|
-
"@dxos/proto": "2.
|
|
26
|
-
"@dxos/rpc": "2.
|
|
27
|
-
"@dxos/util": "2.
|
|
13
|
+
"@dxos/async": "2.25.1-dev.0ff9b5c9",
|
|
14
|
+
"@dxos/codec-protobuf": "2.25.1-dev.0ff9b5c9",
|
|
15
|
+
"@dxos/config": "2.25.1-dev.0ff9b5c9",
|
|
16
|
+
"@dxos/credentials": "2.25.1-dev.0ff9b5c9",
|
|
17
|
+
"@dxos/crypto": "2.25.1-dev.0ff9b5c9",
|
|
18
|
+
"@dxos/debug": "2.25.1-dev.0ff9b5c9",
|
|
19
|
+
"@dxos/echo-db": "2.25.1-dev.0ff9b5c9",
|
|
20
|
+
"@dxos/echo-protocol": "2.25.1-dev.0ff9b5c9",
|
|
21
|
+
"@dxos/feed-store": "2.25.1-dev.0ff9b5c9",
|
|
22
|
+
"@dxos/model-factory": "2.25.1-dev.0ff9b5c9",
|
|
23
|
+
"@dxos/network-manager": "2.25.1-dev.0ff9b5c9",
|
|
24
|
+
"@dxos/object-model": "2.25.1-dev.0ff9b5c9",
|
|
25
|
+
"@dxos/proto": "2.25.1-dev.0ff9b5c9",
|
|
26
|
+
"@dxos/rpc": "2.25.1-dev.0ff9b5c9",
|
|
27
|
+
"@dxos/util": "2.25.1-dev.0ff9b5c9",
|
|
28
|
+
"@polkadot/keyring": "6.11.1",
|
|
29
|
+
"@polkadot/util": "6.11.1",
|
|
30
|
+
"@polkadot/util-crypto": "6.11.1",
|
|
28
31
|
"@wirelineio/registry-client": "~1.1.0-beta.3",
|
|
29
32
|
"abstract-leveldown": "~7.0.0",
|
|
30
33
|
"assert": "^2.0.0",
|
|
@@ -38,9 +41,9 @@
|
|
|
38
41
|
"uuid": "^8.3.2"
|
|
39
42
|
},
|
|
40
43
|
"devDependencies": {
|
|
41
|
-
"@dxos/random-access-multi-storage": "2.
|
|
42
|
-
"@dxos/testutils": "2.
|
|
43
|
-
"@dxos/toolchain-node-library": "2.
|
|
44
|
+
"@dxos/random-access-multi-storage": "2.25.1-dev.0ff9b5c9",
|
|
45
|
+
"@dxos/testutils": "2.25.0",
|
|
46
|
+
"@dxos/toolchain-node-library": "2.25.0",
|
|
44
47
|
"@types/debug": "^4.1.7",
|
|
45
48
|
"@types/expect": "~24.3.0",
|
|
46
49
|
"@types/jest": "^26.0.7",
|
package/src/api/echo-proxy.ts
CHANGED
|
@@ -63,7 +63,9 @@ export class EchoProxy {
|
|
|
63
63
|
/**
|
|
64
64
|
* @internal
|
|
65
65
|
*/
|
|
66
|
-
_open () {
|
|
66
|
+
async _open () {
|
|
67
|
+
const gotParties = this._partiesChanged.waitForCount(1);
|
|
68
|
+
|
|
67
69
|
const partiesStream = this._serviceProvider.services.PartyService.SubscribeParties();
|
|
68
70
|
partiesStream.subscribe(async data => {
|
|
69
71
|
for (const party of data.parties ?? []) {
|
|
@@ -94,6 +96,8 @@ export class EchoProxy {
|
|
|
94
96
|
this._partiesChanged.emit();
|
|
95
97
|
}, () => {});
|
|
96
98
|
this._subscriptions.push(() => partiesStream.close());
|
|
99
|
+
|
|
100
|
+
await gotParties;
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
/**
|
package/src/api/halo-proxy.ts
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Event } from '@dxos/async';
|
|
6
|
+
import { KeyRecord } from '@dxos/credentials';
|
|
6
7
|
import { Contact, CreateProfileOptions, InvitationDescriptor, InvitationOptions, PartyMember, ResultSet } from '@dxos/echo-db';
|
|
7
8
|
import { SubscriptionGroup } from '@dxos/util';
|
|
8
9
|
|
|
9
10
|
import { ClientServiceProvider } from '../interfaces';
|
|
10
|
-
import { Profile } from '../proto/gen/dxos/client';
|
|
11
|
+
import { Profile, SignRequest } from '../proto/gen/dxos/client';
|
|
11
12
|
import { Invitation, InvitationProxy, InvitationRequest } from './invitations';
|
|
12
13
|
|
|
13
14
|
export interface CreateInvitationOptions extends InvitationOptions {
|
|
@@ -119,12 +120,23 @@ export class HaloProxy extends InvitationProxy {
|
|
|
119
120
|
);
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
async addKeyRecord (keyRecord: KeyRecord) {
|
|
124
|
+
await this._serviceProvider.services.HaloService.AddKeyRecord({ keyRecord });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async sign (request: SignRequest) {
|
|
128
|
+
return await this._serviceProvider.services.HaloService.Sign(request);
|
|
129
|
+
}
|
|
130
|
+
|
|
122
131
|
/**
|
|
123
132
|
* Allocate resources and set-up internal subscriptions.
|
|
124
133
|
*
|
|
125
134
|
* @internal
|
|
126
135
|
*/
|
|
127
|
-
_open () {
|
|
136
|
+
async _open () {
|
|
137
|
+
const gotProfile = this._profileChanged.waitForCount(1);
|
|
138
|
+
const gotContacts = this._contactsChanged.waitForCount(1);
|
|
139
|
+
|
|
128
140
|
const profileStream = this._serviceProvider.services.ProfileService.SubscribeProfile();
|
|
129
141
|
profileStream.subscribe(data => {
|
|
130
142
|
this._profile = data.profile;
|
|
@@ -132,12 +144,14 @@ export class HaloProxy extends InvitationProxy {
|
|
|
132
144
|
}, () => {});
|
|
133
145
|
this._subscriptions.push(() => profileStream.close());
|
|
134
146
|
|
|
135
|
-
const contactsStream = this._serviceProvider.services.
|
|
147
|
+
const contactsStream = this._serviceProvider.services.HaloService.SubscribeContacts();
|
|
136
148
|
contactsStream.subscribe(data => {
|
|
137
149
|
this._contacts = data.contacts as PartyMember[];
|
|
138
150
|
this._contactsChanged.emit();
|
|
139
151
|
}, () => {});
|
|
140
152
|
this._subscriptions.push(() => contactsStream.close());
|
|
153
|
+
|
|
154
|
+
await Promise.all([gotProfile, gotContacts]);
|
|
141
155
|
}
|
|
142
156
|
|
|
143
157
|
/**
|
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
|
-
ActivationOptions, Database, PARTY_ITEM_TYPE, PARTY_TITLE_PROPERTY, RemoteDatabaseBackend
|
|
8
|
+
ActivationOptions, Database, PARTY_ITEM_TYPE, PARTY_TITLE_PROPERTY, RemoteDatabaseBackend, RootSelector
|
|
9
9
|
} from '@dxos/echo-db';
|
|
10
10
|
import { PartyKey } from '@dxos/echo-protocol';
|
|
11
11
|
import { ModelFactory } from '@dxos/model-factory';
|
|
@@ -125,6 +125,13 @@ export class Party extends InvitationProxy {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Returns a selection context, which can be used to traverse the object graph.
|
|
130
|
+
*/
|
|
131
|
+
get select (): RootSelector {
|
|
132
|
+
return this.database.select.bind(this.database);
|
|
133
|
+
}
|
|
134
|
+
|
|
128
135
|
/**
|
|
129
136
|
* Creates an invitation to a given party.
|
|
130
137
|
* The Invitation flow requires the inviter and invitee to be online at the same time.
|
|
@@ -164,7 +171,7 @@ export class Party extends InvitationProxy {
|
|
|
164
171
|
}
|
|
165
172
|
|
|
166
173
|
private getPropertiesItem () {
|
|
167
|
-
const items = this.database.select(
|
|
174
|
+
const items = this.database.select({ type: PARTY_ITEM_TYPE }).query().result;
|
|
168
175
|
return items[0];
|
|
169
176
|
}
|
|
170
177
|
|
|
@@ -309,8 +309,8 @@ describe('Client', () => {
|
|
|
309
309
|
client.registerModel(TestModel);
|
|
310
310
|
|
|
311
311
|
const party = client.echo.queryParties().first;
|
|
312
|
-
const selection = party.database.select(
|
|
313
|
-
await selection.update.waitForCondition(() => selection.
|
|
312
|
+
const selection = party.database.select({ type: 'test' }).query();
|
|
313
|
+
await selection.update.waitForCondition(() => selection.result.length > 0);
|
|
314
314
|
|
|
315
315
|
const item = selection.expectOne();
|
|
316
316
|
|
package/src/client/client.ts
CHANGED
|
@@ -169,8 +169,8 @@ export class Client {
|
|
|
169
169
|
this._halo = new HaloProxy(this._serviceProvider);
|
|
170
170
|
this._echo = new EchoProxy(this._serviceProvider);
|
|
171
171
|
|
|
172
|
-
this._halo._open();
|
|
173
|
-
this._echo._open();
|
|
172
|
+
await this._halo._open();
|
|
173
|
+
await this._echo._open();
|
|
174
174
|
|
|
175
175
|
this._initialized = true; // TODO(burdon): Initialized === halo.initialized?
|
|
176
176
|
clearInterval(timeout);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import PolkadotKeyring from '@polkadot/keyring';
|
|
6
|
+
import { hexToU8a, u8aToHex } from '@polkadot/util';
|
|
7
|
+
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
|
8
|
+
import assert from 'assert';
|
|
9
|
+
|
|
10
|
+
import { Stream } from '@dxos/codec-protobuf';
|
|
11
|
+
import { KeyRecord, KeyType } from '@dxos/credentials';
|
|
12
|
+
import { ECHO } from '@dxos/echo-db';
|
|
13
|
+
import { SubscriptionGroup } from '@dxos/util';
|
|
14
|
+
|
|
15
|
+
import { AddKeyRecordRequest, Contacts, HaloService as IHaloService, SignRequest, SignResponse } from '../../../proto/gen/dxos/client';
|
|
16
|
+
import { resultSetToStream } from '../../../util';
|
|
17
|
+
import { CreateServicesOpts } from './interfaces';
|
|
18
|
+
|
|
19
|
+
export class HaloService implements IHaloService {
|
|
20
|
+
constructor (private echo: ECHO) {}
|
|
21
|
+
|
|
22
|
+
SubscribeContacts (): Stream<Contacts> {
|
|
23
|
+
if (this.echo.halo.isInitialized) {
|
|
24
|
+
return resultSetToStream(this.echo.halo.queryContacts(), (contacts): Contacts => ({ contacts }));
|
|
25
|
+
} else {
|
|
26
|
+
return new Stream(({ next }) => {
|
|
27
|
+
// If profile does not exist, send an empty array.
|
|
28
|
+
if (!this.echo.halo.isInitialized) {
|
|
29
|
+
next({ contacts: [] });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const subGroup = new SubscriptionGroup();
|
|
33
|
+
|
|
34
|
+
setImmediate(async () => {
|
|
35
|
+
await this.echo.halo.identityReady.waitForCondition(() => this.echo.halo.isInitialized);
|
|
36
|
+
|
|
37
|
+
const resultSet = this.echo.halo.queryContacts();
|
|
38
|
+
next({ contacts: resultSet.value });
|
|
39
|
+
subGroup.push(resultSet.update.on(() => next({ contacts: resultSet.value })));
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return () => subGroup.unsubscribe();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async AddKeyRecord (request: AddKeyRecordRequest): Promise<void> {
|
|
48
|
+
assert(request.keyRecord && request.keyRecord.publicKey, 'Missing key record.');
|
|
49
|
+
await this.echo.halo.keyring.addKeyRecord(request.keyRecord);
|
|
50
|
+
assert(await this.echo.halo.keyring.getKey(request.keyRecord.publicKey), 'Key not inserted correctly.');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private async polkadotSign (key: KeyRecord, payload: SignRequest['payload']): Promise<SignResponse> {
|
|
54
|
+
await cryptoWaitReady();
|
|
55
|
+
|
|
56
|
+
assert(key.secretKey, 'Secret key is missing.');
|
|
57
|
+
|
|
58
|
+
const keyring = new PolkadotKeyring({ type: 'sr25519' });
|
|
59
|
+
const keypair = keyring.addFromUri(key.secretKey.toString());
|
|
60
|
+
|
|
61
|
+
const signature = u8aToHex(keypair.sign(hexToU8a(payload), { withType: true }));
|
|
62
|
+
return {
|
|
63
|
+
signed: signature
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async Sign (request: SignRequest): Promise<SignResponse> {
|
|
68
|
+
assert(request.publicKey, 'Provide a publicKey of the key that should be used for signing.');
|
|
69
|
+
const key = await this.echo.halo.keyring.getFullKey(request.publicKey);
|
|
70
|
+
assert(key, 'Key not found.');
|
|
71
|
+
if (key.type === KeyType.DXNS) {
|
|
72
|
+
return this.polkadotSign(key, request.payload);
|
|
73
|
+
}
|
|
74
|
+
throw new Error('Only DXNS key signing is supported.');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const createHaloService = ({ echo }: CreateServicesOpts): HaloService => {
|
|
79
|
+
return new HaloService(echo);
|
|
80
|
+
};
|
|
@@ -9,22 +9,11 @@ import { latch } from '@dxos/async';
|
|
|
9
9
|
import { Stream } from '@dxos/codec-protobuf';
|
|
10
10
|
import { defaultSecretValidator, generatePasscode, SecretProvider } from '@dxos/credentials';
|
|
11
11
|
import { ECHO, InvitationDescriptor } from '@dxos/echo-db';
|
|
12
|
-
import { SubscriptionGroup } from '@dxos/util';
|
|
13
12
|
|
|
14
13
|
import {
|
|
15
|
-
InvitationState,
|
|
16
|
-
ProfileService as IProfileService,
|
|
17
|
-
AuthenticateInvitationRequest,
|
|
18
|
-
SubscribeProfileResponse,
|
|
19
|
-
InvitationRequest,
|
|
20
|
-
CreateProfileRequest,
|
|
21
|
-
Contacts,
|
|
22
|
-
RedeemedInvitation,
|
|
23
|
-
Profile
|
|
24
|
-
, RecoverProfileRequest
|
|
14
|
+
AuthenticateInvitationRequest, CreateProfileRequest, InvitationRequest, InvitationState, Profile, ProfileService as IProfileService, RecoverProfileRequest, RedeemedInvitation, SubscribeProfileResponse
|
|
25
15
|
} from '../../../proto/gen/dxos/client';
|
|
26
16
|
import { InvitationDescriptor as InvitationDescriptorProto } from '../../../proto/gen/dxos/echo/invitation';
|
|
27
|
-
import { resultSetToStream } from '../../../util';
|
|
28
17
|
import { CreateServicesOpts, InviteeInvitation, InviteeInvitations } from './interfaces';
|
|
29
18
|
|
|
30
19
|
export class ProfileService implements IProfileService {
|
|
@@ -122,26 +111,6 @@ export class ProfileService implements IProfileService {
|
|
|
122
111
|
invitation.secret = request.secret;
|
|
123
112
|
invitation.secretTrigger?.();
|
|
124
113
|
}
|
|
125
|
-
|
|
126
|
-
SubscribeContacts (): Stream<Contacts> {
|
|
127
|
-
if (this.echo.halo.isInitialized) {
|
|
128
|
-
return resultSetToStream(this.echo.halo.queryContacts(), (contacts): Contacts => ({ contacts }));
|
|
129
|
-
} else {
|
|
130
|
-
return new Stream(({ next }) => {
|
|
131
|
-
const subGroup = new SubscriptionGroup();
|
|
132
|
-
|
|
133
|
-
setImmediate(async () => {
|
|
134
|
-
await this.echo.halo.identityReady.waitForCondition(() => this.echo.halo.isInitialized);
|
|
135
|
-
|
|
136
|
-
const resultSet = this.echo.halo.queryContacts();
|
|
137
|
-
next({ contacts: resultSet.value });
|
|
138
|
-
subGroup.push(resultSet.update.on(() => next({ contacts: resultSet.value })));
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
return () => subGroup.unsubscribe();
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
114
|
}
|
|
146
115
|
|
|
147
116
|
export const createProfileService = ({ echo }: CreateServicesOpts): ProfileService => {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { ClientServices } from '../../../interfaces';
|
|
6
|
+
import { createHaloService } from './halo';
|
|
6
7
|
import { CreateServicesOpts } from './interfaces';
|
|
7
8
|
import { createPartyService } from './party';
|
|
8
9
|
import { createProfileService } from './profile';
|
|
@@ -12,6 +13,7 @@ export const createServices = (opts: CreateServicesOpts): Omit<ClientServices, '
|
|
|
12
13
|
return {
|
|
13
14
|
SystemService: createSystemService(opts),
|
|
14
15
|
ProfileService: createProfileService(opts),
|
|
16
|
+
HaloService: createHaloService(opts),
|
|
15
17
|
PartyService: createPartyService(opts),
|
|
16
18
|
DataService: opts.echo.dataService,
|
|
17
19
|
TracingService: {
|
package/src/devtools/items.ts
CHANGED
|
@@ -19,7 +19,7 @@ const getData = (echo: DevtoolsServiceDependencies['echo']): SubscribeToItemsRes
|
|
|
19
19
|
items: []
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const items = party.database.select(
|
|
22
|
+
const { result: items } = party.database.select().query();
|
|
23
23
|
for (const item of items) {
|
|
24
24
|
partyInfo.items.push({
|
|
25
25
|
id: item.id,
|
|
@@ -48,7 +48,7 @@ export const subscribeToItems = ({ echo }: DevtoolsServiceDependencies) => {
|
|
|
48
48
|
const unsubscribe = echo.queryParties().subscribe((parties) => {
|
|
49
49
|
parties.forEach(party => {
|
|
50
50
|
if (!partySubscriptions[party.key.toHex()]) {
|
|
51
|
-
const sub = party.database.select(
|
|
51
|
+
const sub = party.database.select().query().update.on(() => {
|
|
52
52
|
// Send updates on items changes.
|
|
53
53
|
update();
|
|
54
54
|
});
|
|
@@ -7,13 +7,14 @@ import { DataService, schema as schemaProtocol } from '@dxos/echo-protocol';
|
|
|
7
7
|
import { createServiceBundle } from '@dxos/rpc';
|
|
8
8
|
|
|
9
9
|
import { schema } from '../proto/gen';
|
|
10
|
-
import { PartyService, ProfileService, SystemService } from '../proto/gen/dxos/client';
|
|
10
|
+
import { PartyService, ProfileService, SystemService, HaloService } from '../proto/gen/dxos/client';
|
|
11
11
|
import { DevtoolsHost, TracingService } from '../proto/gen/dxos/devtools';
|
|
12
12
|
|
|
13
13
|
// TODO(burdon): Is there a way to mark TS (generics) so cast isn't required for result of stream?
|
|
14
14
|
export interface ClientServices {
|
|
15
15
|
SystemService: SystemService;
|
|
16
16
|
ProfileService: ProfileService;
|
|
17
|
+
HaloService: HaloService;
|
|
17
18
|
PartyService: PartyService;
|
|
18
19
|
DataService: DataService;
|
|
19
20
|
DevtoolsHost: DevtoolsHost;
|
|
@@ -24,6 +25,7 @@ export const clientServiceBundle = createServiceBundle<ClientServices>({
|
|
|
24
25
|
SystemService: schema.getService('dxos.client.SystemService'),
|
|
25
26
|
ProfileService: schema.getService('dxos.client.ProfileService'),
|
|
26
27
|
PartyService: schema.getService('dxos.client.PartyService'),
|
|
28
|
+
HaloService: schema.getService('dxos.client.HaloService'),
|
|
27
29
|
// DataService is provided and implemented internally in ECHO so we import it from there.
|
|
28
30
|
DataService: schemaProtocol.getService('dxos.echo.service.DataService'),
|
|
29
31
|
DevtoolsHost: schema.getService('dxos.devtools.DevtoolsHost'),
|
|
@@ -14,21 +14,6 @@ export interface SystemService {
|
|
|
14
14
|
GetConfig: (request: void) => Promise<dxos_config.Config>;
|
|
15
15
|
Reset: (request: void) => Promise<void>;
|
|
16
16
|
}
|
|
17
|
-
export interface Profile {
|
|
18
|
-
publicKey: ReturnType<typeof substitutions["dxos.halo.keys.PubKey"]["decode"]>;
|
|
19
|
-
username?: string;
|
|
20
|
-
}
|
|
21
|
-
export interface SubscribeProfileResponse {
|
|
22
|
-
profile?: Profile;
|
|
23
|
-
}
|
|
24
|
-
export interface CreateProfileRequest {
|
|
25
|
-
username?: string;
|
|
26
|
-
publicKey?: Uint8Array;
|
|
27
|
-
secretKey?: Uint8Array;
|
|
28
|
-
}
|
|
29
|
-
export interface RecoverProfileRequest {
|
|
30
|
-
seedPhrase?: string;
|
|
31
|
-
}
|
|
32
17
|
export enum InvitationState {
|
|
33
18
|
WAITING_FOR_CONNECTION = 1,
|
|
34
19
|
CONNECTED = 2,
|
|
@@ -68,6 +53,21 @@ export interface AuthenticateInvitationRequest {
|
|
|
68
53
|
processId?: string;
|
|
69
54
|
secret?: Uint8Array;
|
|
70
55
|
}
|
|
56
|
+
export interface Profile {
|
|
57
|
+
publicKey: ReturnType<typeof substitutions["dxos.halo.keys.PubKey"]["decode"]>;
|
|
58
|
+
username?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface SubscribeProfileResponse {
|
|
61
|
+
profile?: Profile;
|
|
62
|
+
}
|
|
63
|
+
export interface CreateProfileRequest {
|
|
64
|
+
username?: string;
|
|
65
|
+
publicKey?: Uint8Array;
|
|
66
|
+
secretKey?: Uint8Array;
|
|
67
|
+
}
|
|
68
|
+
export interface RecoverProfileRequest {
|
|
69
|
+
seedPhrase?: string;
|
|
70
|
+
}
|
|
71
71
|
export interface Contact {
|
|
72
72
|
publicKey?: ReturnType<typeof substitutions["dxos.halo.keys.PubKey"]["decode"]>;
|
|
73
73
|
displayName?: string;
|
|
@@ -82,7 +82,24 @@ export interface ProfileService {
|
|
|
82
82
|
CreateInvitation: (request: void) => Stream<InvitationRequest>;
|
|
83
83
|
AcceptInvitation: (request: dxos_echo_invitation.InvitationDescriptor) => Stream<RedeemedInvitation>;
|
|
84
84
|
AuthenticateInvitation: (request: AuthenticateInvitationRequest) => Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
export interface AddKeyRecordRequest {
|
|
87
|
+
keyRecord?: dxos_halo_keys.KeyRecord;
|
|
88
|
+
}
|
|
89
|
+
export interface SignRequest {
|
|
90
|
+
/**
|
|
91
|
+
* - The public key of the key that is supposed to be used for signing.
|
|
92
|
+
*/
|
|
93
|
+
publicKey?: ReturnType<typeof substitutions["dxos.halo.keys.PubKey"]["decode"]>;
|
|
94
|
+
payload?: ReturnType<typeof substitutions["google.protobuf.Any"]["decode"]>;
|
|
95
|
+
}
|
|
96
|
+
export interface SignResponse {
|
|
97
|
+
signed?: ReturnType<typeof substitutions["google.protobuf.Any"]["decode"]>;
|
|
98
|
+
}
|
|
99
|
+
export interface HaloService {
|
|
85
100
|
SubscribeContacts: (request: void) => Stream<Contacts>;
|
|
101
|
+
AddKeyRecord: (request: AddKeyRecordRequest) => Promise<void>;
|
|
102
|
+
Sign: (request: SignRequest) => Promise<SignResponse>;
|
|
86
103
|
}
|
|
87
104
|
export interface Party {
|
|
88
105
|
publicKey: ReturnType<typeof substitutions["dxos.halo.keys.PubKey"]["decode"]>;
|