@dxos/client-services 0.1.9 → 0.1.10
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/packlets/deprecated/invitations.d.ts +4 -4
- package/dist/src/packlets/deprecated/invitations.d.ts.map +1 -1
- package/dist/src/packlets/deprecated/profile.d.ts.map +1 -1
- package/dist/src/packlets/deprecated/profile.js +21 -9
- package/dist/src/packlets/deprecated/profile.js.map +1 -1
- package/dist/src/packlets/deprecated/space.js +9 -6
- package/dist/src/packlets/deprecated/space.js.map +1 -1
- package/dist/src/packlets/deprecated/system.d.ts.map +1 -1
- package/dist/src/packlets/deprecated/system.js +2 -0
- package/dist/src/packlets/deprecated/system.js.map +1 -1
- package/dist/src/packlets/devtools/devtools.d.ts +1 -1
- package/dist/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/src/packlets/devtools/network.js +3 -3
- package/dist/src/packlets/devtools/network.js.map +1 -1
- package/dist/src/packlets/identity/authenticator.js +3 -3
- package/dist/src/packlets/identity/authenticator.js.map +1 -1
- package/dist/src/packlets/identity/identity-manager.d.ts +5 -2
- package/dist/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/src/packlets/identity/identity-manager.js +13 -9
- package/dist/src/packlets/identity/identity-manager.js.map +1 -1
- package/dist/src/packlets/identity/identity.d.ts +4 -1
- package/dist/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/src/packlets/identity/identity.js +8 -2
- package/dist/src/packlets/identity/identity.js.map +1 -1
- package/dist/src/packlets/invitations/halo-invitations-handler.js +17 -17
- package/dist/src/packlets/invitations/halo-invitations-handler.js.map +1 -1
- package/dist/src/packlets/invitations/invitations-handler.d.ts +3 -1
- package/dist/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/src/packlets/invitations/invitations-handler.js.map +1 -1
- package/dist/src/packlets/invitations/invitations-proxy.js +2 -2
- package/dist/src/packlets/invitations/invitations-proxy.js.map +1 -1
- package/dist/src/packlets/invitations/invitations-service.js +12 -12
- package/dist/src/packlets/invitations/invitations-service.js.map +1 -1
- package/dist/src/packlets/invitations/invitations.d.ts +1 -1
- package/dist/src/packlets/invitations/invitations.d.ts.map +1 -1
- package/dist/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -1
- package/dist/src/packlets/invitations/space-invitations-handler.js +26 -20
- package/dist/src/packlets/invitations/space-invitations-handler.js.map +1 -1
- package/dist/src/packlets/services/service-context.d.ts +3 -2
- package/dist/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/src/packlets/services/service-context.js +11 -8
- package/dist/src/packlets/services/service-context.js.map +1 -1
- package/dist/src/packlets/services/service-definitions.d.ts +1 -1
- package/dist/src/packlets/services/service-definitions.d.ts.map +1 -1
- package/dist/src/packlets/services/service-host.d.ts +2 -2
- package/dist/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/src/packlets/services/service-host.js +4 -5
- package/dist/src/packlets/services/service-host.js.map +1 -1
- package/dist/src/packlets/services/service-registry.test.js +3 -3
- package/dist/src/packlets/services/service-registry.test.js.map +1 -1
- package/dist/src/packlets/storage/storage.d.ts +1 -1
- package/dist/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/src/packlets/vault/iframe-runtime.d.ts +1 -1
- package/dist/src/packlets/vault/iframe-runtime.d.ts.map +1 -1
- package/dist/src/packlets/vault/services.d.ts +2 -2
- package/dist/src/packlets/vault/services.d.ts.map +1 -1
- package/dist/src/packlets/vault/worker-runtime.d.ts +1 -1
- package/dist/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/src/packlets/vault/worker-session.d.ts +1 -1
- package/dist/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/dist/src/packlets/vault/worker-session.js +3 -3
- package/dist/src/packlets/vault/worker-session.js.map +1 -1
- package/package.json +37 -27
- package/src/packlets/deprecated/profile.ts +11 -3
- package/src/packlets/deprecated/space.ts +1 -1
- package/src/packlets/deprecated/system.ts +2 -0
- package/src/packlets/devtools/network.ts +3 -3
- package/src/packlets/identity/identity-manager.ts +14 -5
- package/src/packlets/identity/identity.ts +12 -3
- package/src/packlets/invitations/halo-invitations-handler.ts +4 -4
- package/src/packlets/invitations/invitations-handler.ts +3 -0
- package/src/packlets/invitations/invitations-service.ts +2 -2
- package/src/packlets/invitations/space-invitations-handler.ts +17 -7
- package/src/packlets/services/service-context.ts +10 -5
- package/src/packlets/services/service-host.ts +6 -7
|
@@ -44,14 +44,14 @@ export class HaloInvitationsHandler extends AbstractInvitationsHandler {
|
|
|
44
44
|
*/
|
|
45
45
|
createInvitation(context: void, options?: InvitationsOptions): InvitationObservable {
|
|
46
46
|
let swarmConnection: SwarmConnection | undefined;
|
|
47
|
-
const { type, timeout = INVITATION_TIMEOUT } = options ?? {};
|
|
47
|
+
const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options ?? {};
|
|
48
48
|
assert(type !== Invitation.Type.OFFLINE);
|
|
49
49
|
const identity = this._identityManager.identity ?? failUndefined();
|
|
50
50
|
|
|
51
51
|
const invitation: Invitation = {
|
|
52
52
|
type,
|
|
53
53
|
invitationId: PublicKey.random().toHex(),
|
|
54
|
-
swarmKey: PublicKey.random(),
|
|
54
|
+
swarmKey: swarmKey ?? PublicKey.random(),
|
|
55
55
|
authenticationCode: generatePasscode(AUTHENTICATION_CODE_LENGTH)
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -140,7 +140,7 @@ export class HaloInvitationsHandler extends AbstractInvitationsHandler {
|
|
|
140
140
|
setTimeout(async () => {
|
|
141
141
|
const topic = invitation.swarmKey!;
|
|
142
142
|
const peerId = PublicKey.random(); // Use anonymous key.
|
|
143
|
-
swarmConnection = await this._networkManager.
|
|
143
|
+
swarmConnection = await this._networkManager.joinSwarm({
|
|
144
144
|
topic,
|
|
145
145
|
peerId: topic,
|
|
146
146
|
protocol: createProtocolFactory(topic, peerId, [plugin]),
|
|
@@ -237,7 +237,7 @@ export class HaloInvitationsHandler extends AbstractInvitationsHandler {
|
|
|
237
237
|
assert(invitation.swarmKey);
|
|
238
238
|
const topic = invitation.swarmKey;
|
|
239
239
|
const peerId = PublicKey.random(); // Use anonymous key.
|
|
240
|
-
swarmConnection = await this._networkManager.
|
|
240
|
+
swarmConnection = await this._networkManager.joinSwarm({
|
|
241
241
|
topic,
|
|
242
242
|
peerId: PublicKey.random(),
|
|
243
243
|
protocol: createProtocolFactory(topic, peerId, [plugin]),
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { PublicKey } from '@dxos/keys';
|
|
5
6
|
import { NetworkManager } from '@dxos/network-manager';
|
|
6
7
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
7
8
|
|
|
@@ -10,6 +11,8 @@ import { AuthenticatingInvitationObservable, InvitationObservable } from './invi
|
|
|
10
11
|
export type InvitationsOptions = {
|
|
11
12
|
type?: Invitation.Type;
|
|
12
13
|
timeout?: number;
|
|
14
|
+
// Used for debugging.
|
|
15
|
+
swarmKey?: PublicKey;
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
/**
|
|
@@ -43,8 +43,8 @@ export abstract class AbstractInvitationsService<T = void> implements Invitation
|
|
|
43
43
|
log('stream opened', this.getLoggingContext());
|
|
44
44
|
|
|
45
45
|
let invitationId: string;
|
|
46
|
-
const { type } = invitation;
|
|
47
|
-
const observable = invitationsHandler.createInvitation(context, { type });
|
|
46
|
+
const { type, swarmKey } = invitation;
|
|
47
|
+
const observable = invitationsHandler.createInvitation(context, { type, swarmKey });
|
|
48
48
|
observable.subscribe({
|
|
49
49
|
onConnecting: (invitation) => {
|
|
50
50
|
assert(invitation.invitationId);
|
|
@@ -14,6 +14,7 @@ import { createProtocolFactory, NetworkManager, StarTopology, SwarmConnection }
|
|
|
14
14
|
import { createRpcPlugin, RpcPlugin } from '@dxos/protocol-plugin-rpc';
|
|
15
15
|
import { schema } from '@dxos/protocols';
|
|
16
16
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
17
|
+
import { ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
17
18
|
import { createProtoRpcPeer } from '@dxos/rpc';
|
|
18
19
|
|
|
19
20
|
import {
|
|
@@ -44,14 +45,14 @@ export class SpaceInvitationsHandler extends AbstractInvitationsHandler<Space> {
|
|
|
44
45
|
*/
|
|
45
46
|
createInvitation(space: Space, options?: InvitationsOptions): InvitationObservable {
|
|
46
47
|
let swarmConnection: SwarmConnection | undefined;
|
|
47
|
-
const { type, timeout = INVITATION_TIMEOUT } = options ?? {};
|
|
48
|
+
const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options ?? {};
|
|
48
49
|
assert(type !== Invitation.Type.OFFLINE);
|
|
49
50
|
assert(space);
|
|
50
51
|
|
|
51
52
|
const invitation: Invitation = {
|
|
52
53
|
type,
|
|
53
54
|
invitationId: PublicKey.random().toHex(),
|
|
54
|
-
swarmKey: PublicKey.random(),
|
|
55
|
+
swarmKey: swarmKey ?? PublicKey.random(),
|
|
55
56
|
spaceKey: space.key,
|
|
56
57
|
authenticationCode: generatePasscode(AUTHENTICATION_CODE_LENGTH)
|
|
57
58
|
};
|
|
@@ -64,19 +65,25 @@ export class SpaceInvitationsHandler extends AbstractInvitationsHandler<Space> {
|
|
|
64
65
|
let authenticationCode: string;
|
|
65
66
|
const complete = new Trigger<PublicKey>();
|
|
66
67
|
const plugin = new RpcPlugin(async (port) => {
|
|
68
|
+
let guestProfile: ProfileDocument | undefined;
|
|
69
|
+
|
|
67
70
|
const peer = createProtoRpcPeer({
|
|
68
71
|
exposed: {
|
|
69
72
|
SpaceHostService: schema.getService('dxos.halo.invitations.SpaceHostService')
|
|
70
73
|
},
|
|
71
74
|
handlers: {
|
|
72
75
|
SpaceHostService: {
|
|
73
|
-
requestAdmission: async () => {
|
|
76
|
+
requestAdmission: async ({ profile }) => {
|
|
74
77
|
log('responding with admission offer', {
|
|
78
|
+
guestProfile: profile,
|
|
75
79
|
host: this._signingContext.deviceKey,
|
|
76
80
|
spaceKey: space.key
|
|
77
81
|
});
|
|
78
82
|
|
|
83
|
+
guestProfile = profile;
|
|
84
|
+
|
|
79
85
|
// TODO(burdon): Is this the right place to set this state?
|
|
86
|
+
// TODO(dmaretskyi): Should we expose guest's profile in this callback?
|
|
80
87
|
observable.callback.onAuthenticating?.(invitation);
|
|
81
88
|
return {
|
|
82
89
|
spaceKey: space.key,
|
|
@@ -111,7 +118,8 @@ export class SpaceInvitationsHandler extends AbstractInvitationsHandler<Space> {
|
|
|
111
118
|
deviceKey,
|
|
112
119
|
space.key,
|
|
113
120
|
controlFeedKey,
|
|
114
|
-
dataFeedKey
|
|
121
|
+
dataFeedKey,
|
|
122
|
+
guestProfile
|
|
115
123
|
)
|
|
116
124
|
);
|
|
117
125
|
|
|
@@ -150,7 +158,7 @@ export class SpaceInvitationsHandler extends AbstractInvitationsHandler<Space> {
|
|
|
150
158
|
setTimeout(async () => {
|
|
151
159
|
const topic = invitation.swarmKey!;
|
|
152
160
|
const peerId = PublicKey.random(); // Use anonymous key.
|
|
153
|
-
swarmConnection = await this._networkManager.
|
|
161
|
+
swarmConnection = await this._networkManager.joinSwarm({
|
|
154
162
|
topic,
|
|
155
163
|
peerId: topic,
|
|
156
164
|
protocol: createProtocolFactory(topic, peerId, [plugin]),
|
|
@@ -206,7 +214,9 @@ export class SpaceInvitationsHandler extends AbstractInvitationsHandler<Space> {
|
|
|
206
214
|
|
|
207
215
|
// 1. Send request.
|
|
208
216
|
log('sending admission request', { guest: this._signingContext.deviceKey });
|
|
209
|
-
const { spaceKey, genesisFeedKey } = await peer.rpc.SpaceHostService.requestAdmission(
|
|
217
|
+
const { spaceKey, genesisFeedKey } = await peer.rpc.SpaceHostService.requestAdmission({
|
|
218
|
+
profile: this._signingContext.profile
|
|
219
|
+
});
|
|
210
220
|
|
|
211
221
|
// 2. Get authentication code.
|
|
212
222
|
// TODO(burdon): Test timeout (options for timeouts at different steps).
|
|
@@ -248,7 +258,7 @@ export class SpaceInvitationsHandler extends AbstractInvitationsHandler<Space> {
|
|
|
248
258
|
assert(invitation.swarmKey);
|
|
249
259
|
const topic = invitation.swarmKey;
|
|
250
260
|
const peerId = PublicKey.random(); // Use anonymous key.
|
|
251
|
-
swarmConnection = await this._networkManager.
|
|
261
|
+
swarmConnection = await this._networkManager.joinSwarm({
|
|
252
262
|
topic,
|
|
253
263
|
peerId: PublicKey.random(),
|
|
254
264
|
protocol: createProtocolFactory(topic, peerId, [plugin]),
|
|
@@ -21,7 +21,7 @@ import { NetworkManager } from '@dxos/network-manager';
|
|
|
21
21
|
import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
22
22
|
import { Storage } from '@dxos/random-access-storage';
|
|
23
23
|
|
|
24
|
-
import { IdentityManager } from '../identity';
|
|
24
|
+
import { CreateIdentityOptions, IdentityManager } from '../identity';
|
|
25
25
|
import { HaloInvitationsHandler, SpaceInvitationsHandler } from '../invitations';
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -87,13 +87,17 @@ export class ServiceContext {
|
|
|
87
87
|
await this.identityManager.close();
|
|
88
88
|
await this.spaceManager?.close();
|
|
89
89
|
await this.feedStore.close();
|
|
90
|
-
await this.networkManager.
|
|
90
|
+
await this.networkManager.close();
|
|
91
91
|
this.dataServiceSubscriptions.clear();
|
|
92
92
|
log('closed');
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
// TODO(burdon): Rename.
|
|
96
|
+
async destroy() {}
|
|
97
|
+
|
|
98
|
+
async createIdentity(params: CreateIdentityOptions = {}) {
|
|
99
|
+
const identity = await this.identityManager.createIdentity(params);
|
|
100
|
+
|
|
97
101
|
this.dataServiceSubscriptions.registerSpace(identity.haloSpaceKey, identity.haloDatabase.createDataServiceHost());
|
|
98
102
|
await this._initialize();
|
|
99
103
|
return identity;
|
|
@@ -107,7 +111,8 @@ export class ServiceContext {
|
|
|
107
111
|
credentialAuthenticator: MOCK_AUTH_VERIFIER,
|
|
108
112
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
109
113
|
identityKey: identity.identityKey,
|
|
110
|
-
deviceKey: identity.deviceKey
|
|
114
|
+
deviceKey: identity.deviceKey,
|
|
115
|
+
profile: identity.profileDocument
|
|
111
116
|
};
|
|
112
117
|
|
|
113
118
|
// Create in constructor (avoid all of these private variables).
|
|
@@ -21,22 +21,21 @@ import { ServiceContext } from './service-context';
|
|
|
21
21
|
import { ClientServicesProvider, ClientServices, clientServiceBundle } from './service-definitions';
|
|
22
22
|
import { ServiceRegistry } from './service-registry';
|
|
23
23
|
|
|
24
|
-
type ClientServicesHostParams = {
|
|
25
|
-
config: Config;
|
|
26
|
-
modelFactory?: ModelFactory;
|
|
27
|
-
networkManager: NetworkManager;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
24
|
// TODO(burdon): Factor out to spaces.
|
|
31
25
|
// TODO(burdon): Defaults (with TextModel).
|
|
32
26
|
export const createDefaultModelFactory = () => {
|
|
33
27
|
return new ModelFactory().registerModel(ObjectModel).registerModel(TextModel);
|
|
34
28
|
};
|
|
35
29
|
|
|
30
|
+
type ClientServicesHostParams = {
|
|
31
|
+
config: Config;
|
|
32
|
+
modelFactory?: ModelFactory;
|
|
33
|
+
networkManager: NetworkManager;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
36
|
/**
|
|
37
37
|
* Remote service implementation.
|
|
38
38
|
*/
|
|
39
|
-
// TODO(burdon): Reconcile Host/Backend, etc.
|
|
40
39
|
export class ClientServicesHost implements ClientServicesProvider {
|
|
41
40
|
private readonly _serviceContext: ServiceContext;
|
|
42
41
|
private readonly _serviceRegistry: ServiceRegistry<ClientServices>;
|