@dxos/client 2.24.0 → 2.24.1-dev.49b9f420
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 +7 -7
- package/dist/src/api/echo-proxy.d.ts.map +1 -1
- package/dist/src/api/echo-proxy.js +1 -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 +7 -1
- package/dist/src/api/halo-proxy.js.map +1 -1
- package/dist/src/api/party-proxy.d.ts +1 -5
- package/dist/src/api/party-proxy.d.ts.map +1 -1
- package/dist/src/api/party-proxy.js +6 -3
- package/dist/src/api/party-proxy.js.map +1 -1
- package/dist/src/client/client.d.ts +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 +69 -0
- package/dist/src/client/service-host/services/halo.js.map +1 -0
- package/dist/src/client/service-host/services/party.d.ts.map +1 -1
- package/dist/src/client/service-host/services/party.js +4 -4
- package/dist/src/client/service-host/services/party.js.map +1 -1
- 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/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +12 -1
- package/dist/src/index.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/google/protobuf.d.ts +2 -2
- package/dist/src/proto/gen/google/protobuf.d.ts.map +1 -1
- package/dist/src/proto/gen/google/protobuf.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 +20 -17
- package/src/api/echo-proxy.ts +9 -9
- package/src/api/halo-proxy.ts +11 -2
- package/src/api/party-proxy.ts +7 -4
- package/src/client/service-host/services/halo.ts +75 -0
- package/src/client/service-host/services/party.ts +6 -6
- package/src/client/service-host/services/profile.ts +1 -32
- package/src/client/service-host/services/services.ts +2 -0
- package/src/index.ts +15 -0
- package/src/interfaces/client-service-provider.ts +3 -1
- package/src/proto/gen/dxos/client.ts +32 -15
- package/src/proto/gen/google/protobuf.ts +2 -2
- 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.24.
|
|
3
|
+
"version": "2.24.1-dev.49b9f420",
|
|
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.24.
|
|
14
|
-
"@dxos/codec-protobuf": "2.24.
|
|
15
|
-
"@dxos/config": "2.24.
|
|
16
|
-
"@dxos/credentials": "2.24.
|
|
17
|
-
"@dxos/crypto": "2.24.
|
|
18
|
-
"@dxos/debug": "2.24.
|
|
19
|
-
"@dxos/echo-db": "2.24.
|
|
20
|
-
"@dxos/echo-protocol": "2.24.
|
|
21
|
-
"@dxos/feed-store": "2.24.
|
|
22
|
-
"@dxos/model-factory": "2.24.
|
|
23
|
-
"@dxos/network-manager": "2.24.
|
|
24
|
-
"@dxos/object-model": "2.24.
|
|
25
|
-
"@dxos/proto": "2.24.
|
|
26
|
-
"@dxos/rpc": "2.24.
|
|
27
|
-
"@dxos/util": "2.24.
|
|
13
|
+
"@dxos/async": "2.24.1-dev.49b9f420",
|
|
14
|
+
"@dxos/codec-protobuf": "2.24.1-dev.49b9f420",
|
|
15
|
+
"@dxos/config": "2.24.1-dev.49b9f420",
|
|
16
|
+
"@dxos/credentials": "2.24.1-dev.49b9f420",
|
|
17
|
+
"@dxos/crypto": "2.24.1-dev.49b9f420",
|
|
18
|
+
"@dxos/debug": "2.24.1-dev.49b9f420",
|
|
19
|
+
"@dxos/echo-db": "2.24.1-dev.49b9f420",
|
|
20
|
+
"@dxos/echo-protocol": "2.24.1-dev.49b9f420",
|
|
21
|
+
"@dxos/feed-store": "2.24.1-dev.49b9f420",
|
|
22
|
+
"@dxos/model-factory": "2.24.1-dev.49b9f420",
|
|
23
|
+
"@dxos/network-manager": "2.24.1-dev.49b9f420",
|
|
24
|
+
"@dxos/object-model": "2.24.1-dev.49b9f420",
|
|
25
|
+
"@dxos/proto": "2.24.1-dev.49b9f420",
|
|
26
|
+
"@dxos/rpc": "2.24.1-dev.49b9f420",
|
|
27
|
+
"@dxos/util": "2.24.1-dev.49b9f420",
|
|
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,7 +41,7 @@
|
|
|
38
41
|
"uuid": "^8.3.2"
|
|
39
42
|
},
|
|
40
43
|
"devDependencies": {
|
|
41
|
-
"@dxos/random-access-multi-storage": "2.24.
|
|
44
|
+
"@dxos/random-access-multi-storage": "2.24.1-dev.49b9f420",
|
|
42
45
|
"@dxos/testutils": "2.24.0",
|
|
43
46
|
"@dxos/toolchain-node-library": "2.24.0",
|
|
44
47
|
"@types/debug": "^4.1.7",
|
package/src/api/echo-proxy.ts
CHANGED
|
@@ -16,20 +16,20 @@ import { ComplexMap, SubscriptionGroup } from '@dxos/util';
|
|
|
16
16
|
import { ClientServiceHost } from '../client/service-host';
|
|
17
17
|
import { ClientServiceProvider } from '../interfaces';
|
|
18
18
|
import { Invitation, InvitationProxy } from './invitations';
|
|
19
|
-
import {
|
|
19
|
+
import { Party } from './party-proxy';
|
|
20
20
|
|
|
21
|
-
export class PartyInvitation extends Invitation<
|
|
21
|
+
export class PartyInvitation extends Invitation<Party> {
|
|
22
22
|
/**
|
|
23
23
|
* Wait for the invitation flow to complete and return the target party.
|
|
24
24
|
*/
|
|
25
|
-
getParty (): Promise<
|
|
25
|
+
getParty (): Promise<Party> {
|
|
26
26
|
return this.wait();
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export class EchoProxy {
|
|
31
31
|
private readonly _modelFactory: ModelFactory;
|
|
32
|
-
private _parties = new ComplexMap<PublicKey,
|
|
32
|
+
private _parties = new ComplexMap<PublicKey, Party>(key => key.toHex());
|
|
33
33
|
private readonly _partiesChanged = new Event();
|
|
34
34
|
private readonly _subscriptions = new SubscriptionGroup();
|
|
35
35
|
|
|
@@ -68,7 +68,7 @@ export class EchoProxy {
|
|
|
68
68
|
partiesStream.subscribe(async data => {
|
|
69
69
|
for (const party of data.parties ?? []) {
|
|
70
70
|
if (!this._parties.has(party.publicKey)) {
|
|
71
|
-
const partyProxy = new
|
|
71
|
+
const partyProxy = new Party(this._serviceProvider, this._modelFactory, party);
|
|
72
72
|
await partyProxy.init();
|
|
73
73
|
this._parties.set(partyProxy.key, partyProxy);
|
|
74
74
|
|
|
@@ -114,7 +114,7 @@ export class EchoProxy {
|
|
|
114
114
|
/**
|
|
115
115
|
* Creates a new party.
|
|
116
116
|
*/
|
|
117
|
-
async createParty (): Promise<
|
|
117
|
+
async createParty (): Promise<Party> {
|
|
118
118
|
const [partyReceivedPromise, partyReceived] = latch();
|
|
119
119
|
|
|
120
120
|
const party = await this._serviceProvider.services.PartyService.CreateParty();
|
|
@@ -135,7 +135,7 @@ export class EchoProxy {
|
|
|
135
135
|
/**
|
|
136
136
|
* Clones the party from a snapshot.
|
|
137
137
|
*/
|
|
138
|
-
async cloneParty (snapshot: PartySnapshot): Promise<
|
|
138
|
+
async cloneParty (snapshot: PartySnapshot): Promise<Party> {
|
|
139
139
|
const [partyReceivedPromise, partyReceived] = latch();
|
|
140
140
|
|
|
141
141
|
const party = await this._serviceProvider.services.PartyService.CloneParty(snapshot);
|
|
@@ -156,11 +156,11 @@ export class EchoProxy {
|
|
|
156
156
|
/**
|
|
157
157
|
* Returns an individual party by its key.
|
|
158
158
|
*/
|
|
159
|
-
getParty (partyKey: PartyKey):
|
|
159
|
+
getParty (partyKey: PartyKey): Party | undefined {
|
|
160
160
|
return this._parties.get(partyKey);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
queryParties (): ResultSet<
|
|
163
|
+
queryParties (): ResultSet<Party> {
|
|
164
164
|
return new ResultSet(this._partiesChanged, () => Array.from(this._parties.values()));
|
|
165
165
|
}
|
|
166
166
|
|
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,6 +120,14 @@ 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
|
*
|
|
@@ -132,7 +141,7 @@ export class HaloProxy extends InvitationProxy {
|
|
|
132
141
|
}, () => {});
|
|
133
142
|
this._subscriptions.push(() => profileStream.close());
|
|
134
143
|
|
|
135
|
-
const contactsStream = this._serviceProvider.services.
|
|
144
|
+
const contactsStream = this._serviceProvider.services.HaloService.SubscribeContacts();
|
|
136
145
|
contactsStream.subscribe(data => {
|
|
137
146
|
this._contacts = data.contacts as PartyMember[];
|
|
138
147
|
this._contactsChanged.emit();
|
package/src/api/party-proxy.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { ModelFactory } from '@dxos/model-factory';
|
|
|
13
13
|
import { ClientServiceHost } from '../client/service-host';
|
|
14
14
|
import { ClientServiceProxy } from '../client/service-proxy';
|
|
15
15
|
import { ClientServiceProvider } from '../interfaces';
|
|
16
|
-
import { Party } from '../proto/gen/dxos/client';
|
|
16
|
+
import { Party as PartyProto } from '../proto/gen/dxos/client';
|
|
17
17
|
import { streamToResultSet } from '../util';
|
|
18
18
|
import { InvitationRequest, InvitationProxy } from './invitations';
|
|
19
19
|
|
|
@@ -21,17 +21,20 @@ export interface CreationInvitationOptions {
|
|
|
21
21
|
inviteeKey?: PublicKey
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export class
|
|
24
|
+
export class Party extends InvitationProxy {
|
|
25
25
|
private readonly _database?: Database;
|
|
26
26
|
|
|
27
27
|
private _key: PartyKey;
|
|
28
28
|
private _isOpen: boolean;
|
|
29
29
|
private _isActive: boolean;
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
31
34
|
constructor (
|
|
32
35
|
private _serviceProvider: ClientServiceProvider,
|
|
33
36
|
private _modelFactory: ModelFactory,
|
|
34
|
-
_party:
|
|
37
|
+
_party: PartyProto
|
|
35
38
|
) {
|
|
36
39
|
super();
|
|
37
40
|
this._key = _party.publicKey;
|
|
@@ -72,7 +75,7 @@ export class PartyProxy extends InvitationProxy {
|
|
|
72
75
|
* Called by EchoProxy to update this party instance.
|
|
73
76
|
* @internal
|
|
74
77
|
*/
|
|
75
|
-
_processPartyUpdate (party:
|
|
78
|
+
_processPartyUpdate (party: PartyProto) {
|
|
76
79
|
this._key = party.publicKey;
|
|
77
80
|
this._isOpen = party.isOpen;
|
|
78
81
|
this._isActive = party.isActive;
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
const subGroup = new SubscriptionGroup();
|
|
28
|
+
|
|
29
|
+
setImmediate(async () => {
|
|
30
|
+
await this.echo.halo.identityReady.waitForCondition(() => this.echo.halo.isInitialized);
|
|
31
|
+
|
|
32
|
+
const resultSet = this.echo.halo.queryContacts();
|
|
33
|
+
next({ contacts: resultSet.value });
|
|
34
|
+
subGroup.push(resultSet.update.on(() => next({ contacts: resultSet.value })));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return () => subGroup.unsubscribe();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async AddKeyRecord (request: AddKeyRecordRequest): Promise<void> {
|
|
43
|
+
assert(request.keyRecord && request.keyRecord.publicKey, 'Missing key record.');
|
|
44
|
+
await this.echo.halo.keyring.addKeyRecord(request.keyRecord);
|
|
45
|
+
assert(await this.echo.halo.keyring.getKey(request.keyRecord.publicKey), 'Key not inserted correctly.');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private async polkadotSign (key: KeyRecord, payload: SignRequest['payload']): Promise<SignResponse> {
|
|
49
|
+
await cryptoWaitReady();
|
|
50
|
+
|
|
51
|
+
assert(key.secretKey, 'Secret key is missing.');
|
|
52
|
+
|
|
53
|
+
const keyring = new PolkadotKeyring({ type: 'sr25519' });
|
|
54
|
+
const keypair = keyring.addFromUri(key.secretKey.toString());
|
|
55
|
+
|
|
56
|
+
const signature = u8aToHex(keypair.sign(hexToU8a(payload), { withType: true }));
|
|
57
|
+
return {
|
|
58
|
+
signed: signature
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async Sign (request: SignRequest): Promise<SignResponse> {
|
|
63
|
+
assert(request.publicKey, 'Provide a publicKey of the key that should be used for signing.');
|
|
64
|
+
const key = await this.echo.halo.keyring.getFullKey(request.publicKey);
|
|
65
|
+
assert(key, 'Key not found.');
|
|
66
|
+
if (key.type === KeyType.DXNS) {
|
|
67
|
+
return this.polkadotSign(key, request.payload);
|
|
68
|
+
}
|
|
69
|
+
throw new Error('Only DXNS key signing is supported.');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const createHaloService = ({ echo }: CreateServicesOpts): HaloService => {
|
|
74
|
+
return new HaloService(echo);
|
|
75
|
+
};
|
|
@@ -8,8 +8,8 @@ import { v4 } from 'uuid';
|
|
|
8
8
|
import { latch } from '@dxos/async';
|
|
9
9
|
import { Stream } from '@dxos/codec-protobuf';
|
|
10
10
|
import { defaultSecretValidator, generatePasscode, SecretProvider } from '@dxos/credentials';
|
|
11
|
-
import { raise } from '@dxos/debug';
|
|
12
|
-
import { ECHO,
|
|
11
|
+
import { InvalidStateError, raise } from '@dxos/debug';
|
|
12
|
+
import { ECHO, InvitationDescriptor, InvitationDescriptorType, PartyNotFoundError } from '@dxos/echo-db';
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
InvitationState,
|
|
@@ -50,7 +50,7 @@ class PartyService implements IPartyService {
|
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
} catch (error) {
|
|
53
|
-
if (error instanceof
|
|
53
|
+
if (error instanceof InvalidStateError) {
|
|
54
54
|
// Do nothing.
|
|
55
55
|
} else {
|
|
56
56
|
throw error;
|
|
@@ -156,7 +156,7 @@ class PartyService implements IPartyService {
|
|
|
156
156
|
next({ state: InvitationState.CONNECTED });
|
|
157
157
|
return Buffer.from(secret);
|
|
158
158
|
};
|
|
159
|
-
invitation = await party.createInvitation({
|
|
159
|
+
invitation = await party.invitationManager.createInvitation({
|
|
160
160
|
secretProvider,
|
|
161
161
|
secretValidator: defaultSecretValidator
|
|
162
162
|
}, {
|
|
@@ -169,7 +169,7 @@ class PartyService implements IPartyService {
|
|
|
169
169
|
assert(invitation.type === InvitationDescriptorType.INTERACTIVE);
|
|
170
170
|
invitation.secret = Buffer.from(secret);
|
|
171
171
|
} else {
|
|
172
|
-
invitation = await party.createOfflineInvitation(request.inviteeKey);
|
|
172
|
+
invitation = await party.invitationManager.createOfflineInvitation(request.inviteeKey);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
next({ state: InvitationState.WAITING_FOR_CONNECTION, descriptor: invitation.toProto() });
|
|
@@ -256,7 +256,7 @@ class PartyService implements IPartyService {
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
CreateSnapshot (request: CreateSnaspotRequest): Promise<PartySnapshot> {
|
|
259
|
+
async CreateSnapshot (request: CreateSnaspotRequest): Promise<PartySnapshot> {
|
|
260
260
|
assert(request.partyKey);
|
|
261
261
|
const party = this.echo.getParty(request.partyKey) ?? raise(new PartyNotFoundError(request.partyKey));
|
|
262
262
|
return party.createSnapshot();
|
|
@@ -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/index.ts
CHANGED
|
@@ -9,3 +9,18 @@ export * from './devtools/devtools-context';
|
|
|
9
9
|
export * from './devtools/devtools-host-events';
|
|
10
10
|
export * from './util';
|
|
11
11
|
export * as proto from './proto/gen';
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
Entity,
|
|
15
|
+
Item,
|
|
16
|
+
Link,
|
|
17
|
+
Database,
|
|
18
|
+
Selection,
|
|
19
|
+
SelectionResult,
|
|
20
|
+
InvitationDescriptor,
|
|
21
|
+
InvitationDescriptorType,
|
|
22
|
+
OpenProgress,
|
|
23
|
+
PartyMember,
|
|
24
|
+
ResultSet,
|
|
25
|
+
PARTY_ITEM_TYPE
|
|
26
|
+
} from '@dxos/echo-db';
|
|
@@ -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"]>;
|
|
@@ -10,6 +10,8 @@ import * as dxos_echo_service from "../dxos/echo/service";
|
|
|
10
10
|
import * as dxos_echo_snapshot from "../dxos/echo/snapshot";
|
|
11
11
|
import * as dxos_halo_keys from "../dxos/halo/keys";
|
|
12
12
|
import * as dxos_rpc from "../dxos/rpc";
|
|
13
|
+
export interface Empty {
|
|
14
|
+
}
|
|
13
15
|
export interface Timestamp {
|
|
14
16
|
seconds?: string;
|
|
15
17
|
nanos?: number;
|
|
@@ -255,8 +257,6 @@ export namespace GeneratedCodeInfo {
|
|
|
255
257
|
end?: number;
|
|
256
258
|
}
|
|
257
259
|
}
|
|
258
|
-
export interface Empty {
|
|
259
|
-
}
|
|
260
260
|
export interface Any {
|
|
261
261
|
type_url?: string;
|
|
262
262
|
value?: Uint8Array;
|