@dxos/client-services 0.1.36 → 0.1.37-next.41339e7
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/lib/browser/{chunk-2AYYVPWN.mjs → chunk-6PNXHM7C.mjs} +188 -72
- package/dist/lib/browser/chunk-6PNXHM7C.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/index.cjs +177 -61
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +177 -61
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +0 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/package.json +30 -30
- package/src/packlets/invitations/invitations-handler.ts +50 -5
- package/src/packlets/services/service-context.ts +1 -7
- package/src/packlets/services/service-host.ts +8 -2
- package/dist/lib/browser/chunk-2AYYVPWN.mjs.map +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitations-handler.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitations-handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,+BAA+B,EAG/B,kCAAkC,EACnC,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAiC,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAEpG,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAaxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAI3D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,kBAAkB;
|
|
1
|
+
{"version":3,"file":"invitations-handler.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitations-handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,+BAA+B,EAG/B,kCAAkC,EACnC,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAiC,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAEpG,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAaxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAI3D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,kBAAkB;IAKjB,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAAf,eAAe,EAAE,cAAc;IAE5D,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,+BAA+B;IAyL9G,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,GAAG,kCAAkC;CAoJ3G"}
|
|
@@ -33,7 +33,6 @@ export declare class ServiceContext {
|
|
|
33
33
|
constructor(storage: Storage, networkManager: NetworkManager, modelFactory: ModelFactory);
|
|
34
34
|
open(): Promise<void>;
|
|
35
35
|
close(): Promise<void>;
|
|
36
|
-
reset(): Promise<void>;
|
|
37
36
|
createIdentity(params?: CreateIdentityOptions): Promise<import("../identity").Identity>;
|
|
38
37
|
getInvitationHandler(invitation: Partial<Invitation> & Pick<Invitation, 'kind'>): InvitationProtocol;
|
|
39
38
|
private _acceptIdentity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-context.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/services/service-context.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAEL,aAAa,EACb,YAAY,EAEZ,wBAAwB,EACxB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MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAoB;IACnD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkC;IACnE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAoB;IAEnD,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqB;IACnD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAC7C,OAAO,CAAC,eAAe,CAAC,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,CAAU;IAM3B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;gBAE9C,EACV,MAAM,EACN,YAA0C,EAE1C,cAAc,EACd,OAAO,EAEP,OAAO,EACR,GAAE,wBAA6B;IA4ChC,IAAI,MAAM,YAET;IAED,IAAI,eAAe,oCAElB;IAED,IAAI,WAAW,sDAEd;IAED,IAAI,QAAQ,4BAEX;IAED;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,iBAAiB;IAkBlD,IAAI;IA8DJ,KAAK;IAgBL,KAAK;CAMZ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/client-services",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37-next.41339e7",
|
|
4
4
|
"description": "DXOS client services implementation",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -20,39 +20,39 @@
|
|
|
20
20
|
"src"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dxos/async": "0.1.
|
|
24
|
-
"@dxos/client": "0.1.
|
|
25
|
-
"@dxos/codec-protobuf": "0.1.
|
|
26
|
-
"@dxos/config": "0.1.
|
|
27
|
-
"@dxos/context": "0.1.
|
|
28
|
-
"@dxos/credentials": "0.1.
|
|
29
|
-
"@dxos/crypto": "0.1.
|
|
30
|
-
"@dxos/debug": "0.1.
|
|
31
|
-
"@dxos/document-model": "0.1.
|
|
32
|
-
"@dxos/echo-db": "0.1.
|
|
33
|
-
"@dxos/echo-pipeline": "0.1.
|
|
34
|
-
"@dxos/errors": "0.1.
|
|
35
|
-
"@dxos/feed-store": "0.1.
|
|
36
|
-
"@dxos/keyring": "0.1.
|
|
37
|
-
"@dxos/keys": "0.1.
|
|
38
|
-
"@dxos/log": "0.1.
|
|
39
|
-
"@dxos/messaging": "0.1.
|
|
40
|
-
"@dxos/model-factory": "0.1.
|
|
41
|
-
"@dxos/network-manager": "0.1.
|
|
42
|
-
"@dxos/node-std": "0.1.
|
|
43
|
-
"@dxos/protocols": "0.1.
|
|
44
|
-
"@dxos/random-access-storage": "0.1.
|
|
45
|
-
"@dxos/rpc": "0.1.
|
|
46
|
-
"@dxos/teleport": "0.1.
|
|
47
|
-
"@dxos/teleport-extension-gossip": "0.1.
|
|
48
|
-
"@dxos/text-model": "0.1.
|
|
49
|
-
"@dxos/timeframe": "0.1.
|
|
50
|
-
"@dxos/util": "0.1.
|
|
23
|
+
"@dxos/async": "0.1.37-next.41339e7",
|
|
24
|
+
"@dxos/client": "0.1.37-next.41339e7",
|
|
25
|
+
"@dxos/codec-protobuf": "0.1.37-next.41339e7",
|
|
26
|
+
"@dxos/config": "0.1.37-next.41339e7",
|
|
27
|
+
"@dxos/context": "0.1.37-next.41339e7",
|
|
28
|
+
"@dxos/credentials": "0.1.37-next.41339e7",
|
|
29
|
+
"@dxos/crypto": "0.1.37-next.41339e7",
|
|
30
|
+
"@dxos/debug": "0.1.37-next.41339e7",
|
|
31
|
+
"@dxos/document-model": "0.1.37-next.41339e7",
|
|
32
|
+
"@dxos/echo-db": "0.1.37-next.41339e7",
|
|
33
|
+
"@dxos/echo-pipeline": "0.1.37-next.41339e7",
|
|
34
|
+
"@dxos/errors": "0.1.37-next.41339e7",
|
|
35
|
+
"@dxos/feed-store": "0.1.37-next.41339e7",
|
|
36
|
+
"@dxos/keyring": "0.1.37-next.41339e7",
|
|
37
|
+
"@dxos/keys": "0.1.37-next.41339e7",
|
|
38
|
+
"@dxos/log": "0.1.37-next.41339e7",
|
|
39
|
+
"@dxos/messaging": "0.1.37-next.41339e7",
|
|
40
|
+
"@dxos/model-factory": "0.1.37-next.41339e7",
|
|
41
|
+
"@dxos/network-manager": "0.1.37-next.41339e7",
|
|
42
|
+
"@dxos/node-std": "0.1.37-next.41339e7",
|
|
43
|
+
"@dxos/protocols": "0.1.37-next.41339e7",
|
|
44
|
+
"@dxos/random-access-storage": "0.1.37-next.41339e7",
|
|
45
|
+
"@dxos/rpc": "0.1.37-next.41339e7",
|
|
46
|
+
"@dxos/teleport": "0.1.37-next.41339e7",
|
|
47
|
+
"@dxos/teleport-extension-gossip": "0.1.37-next.41339e7",
|
|
48
|
+
"@dxos/text-model": "0.1.37-next.41339e7",
|
|
49
|
+
"@dxos/timeframe": "0.1.37-next.41339e7",
|
|
50
|
+
"@dxos/util": "0.1.37-next.41339e7"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/readable-stream": "^2.3.9",
|
|
54
54
|
"fast-check": "~3.3.0",
|
|
55
|
-
"@dxos/signal": "0.1.
|
|
55
|
+
"@dxos/signal": "0.1.37-next.41339e7"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
@@ -17,7 +17,7 @@ import { generatePasscode } from '@dxos/credentials';
|
|
|
17
17
|
import { PublicKey } from '@dxos/keys';
|
|
18
18
|
import { log } from '@dxos/log';
|
|
19
19
|
import { createTeleportProtocolFactory, NetworkManager, StarTopology } from '@dxos/network-manager';
|
|
20
|
-
import { schema } from '@dxos/protocols';
|
|
20
|
+
import { schema, trace } from '@dxos/protocols';
|
|
21
21
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
22
22
|
import { ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
23
23
|
import {
|
|
@@ -63,6 +63,10 @@ const MAX_OTP_ATTEMPTS = 3;
|
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
65
|
export class InvitationsHandler {
|
|
66
|
+
/**
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
public _traceParent?: string;
|
|
66
70
|
constructor(private readonly _networkManager: NetworkManager) {}
|
|
67
71
|
|
|
68
72
|
createInvitation(protocol: InvitationProtocol, options?: Partial<Invitation>): CancellableInvitationObservable {
|
|
@@ -187,12 +191,18 @@ export class InvitationsHandler {
|
|
|
187
191
|
|
|
188
192
|
onOpen: () => {
|
|
189
193
|
scheduleTask(ctx, async () => {
|
|
194
|
+
const traceId = PublicKey.random().toHex();
|
|
190
195
|
try {
|
|
196
|
+
log.trace(
|
|
197
|
+
'dxos.sdk.invitations-handler.host.onOpen',
|
|
198
|
+
trace.begin({ id: traceId, parentId: this._traceParent })
|
|
199
|
+
);
|
|
191
200
|
log('connected', { ...protocol.toJSON() });
|
|
192
201
|
stream.next({ ...invitation, state: Invitation.State.CONNECTED });
|
|
193
202
|
const deviceKey = await success.wait({ timeout });
|
|
194
203
|
log('admitted guest', { guest: deviceKey, ...protocol.toJSON() });
|
|
195
204
|
stream.next({ ...invitation, state: Invitation.State.SUCCESS });
|
|
205
|
+
log.trace('dxos.sdk.invitations-handler.host.onOpen', trace.end({ id: traceId }));
|
|
196
206
|
} catch (err: any) {
|
|
197
207
|
if (err instanceof TimeoutError) {
|
|
198
208
|
log('timeout', { ...protocol.toJSON() });
|
|
@@ -201,6 +211,7 @@ export class InvitationsHandler {
|
|
|
201
211
|
log.error('failed', err);
|
|
202
212
|
stream.error(err);
|
|
203
213
|
}
|
|
214
|
+
log.trace('dxos.sdk.invitations-handler.host.onOpen', trace.error({ id: traceId, error: err }));
|
|
204
215
|
} finally {
|
|
205
216
|
if (type !== Invitation.Type.MULTIUSE) {
|
|
206
217
|
await sleep(ON_CLOSE_DELAY);
|
|
@@ -210,6 +221,7 @@ export class InvitationsHandler {
|
|
|
210
221
|
});
|
|
211
222
|
}
|
|
212
223
|
});
|
|
224
|
+
extension._traceParent = this._traceParent;
|
|
213
225
|
|
|
214
226
|
return extension;
|
|
215
227
|
};
|
|
@@ -273,7 +285,12 @@ export class InvitationsHandler {
|
|
|
273
285
|
const extension = new InvitationGuestExtension({
|
|
274
286
|
onOpen: () => {
|
|
275
287
|
scheduleTask(ctx, async () => {
|
|
288
|
+
const traceId = PublicKey.random().toHex();
|
|
276
289
|
try {
|
|
290
|
+
log.trace(
|
|
291
|
+
'dxos.sdk.invitations-handler.guest.onOpen',
|
|
292
|
+
trace.begin({ id: traceId, parentId: this._traceParent })
|
|
293
|
+
);
|
|
277
294
|
// TODO(burdon): Bug where guest may create multiple connections.
|
|
278
295
|
if (++connectionCount > 1) {
|
|
279
296
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
@@ -334,14 +351,16 @@ export class InvitationsHandler {
|
|
|
334
351
|
// 5. Success.
|
|
335
352
|
log('admitted by host', { ...protocol.toJSON() });
|
|
336
353
|
stream.next({ ...invitation, ...result, state: Invitation.State.SUCCESS });
|
|
354
|
+
log.trace('dxos.sdk.invitations-handler.guest.onOpen', trace.end({ id: traceId }));
|
|
337
355
|
} catch (err: any) {
|
|
338
356
|
if (err instanceof TimeoutError) {
|
|
339
357
|
log('timeout', { ...protocol.toJSON() });
|
|
340
358
|
stream.next({ ...invitation, state: Invitation.State.TIMEOUT });
|
|
341
359
|
} else {
|
|
342
|
-
log
|
|
360
|
+
log('auth failed', err);
|
|
343
361
|
stream.error(err);
|
|
344
362
|
}
|
|
363
|
+
log.trace('dxos.sdk.invitations-handler.guest.onOpen', trace.error({ id: traceId, error: err }));
|
|
345
364
|
} finally {
|
|
346
365
|
await ctx.dispose();
|
|
347
366
|
}
|
|
@@ -400,6 +419,11 @@ type InvitationHostExtensionCallbacks = {
|
|
|
400
419
|
* Host's side for a connection to a concrete peer in p2p network during invitation.
|
|
401
420
|
*/
|
|
402
421
|
class InvitationHostExtension extends RpcExtension<{}, { InvitationHostService: InvitationHostService }> {
|
|
422
|
+
/**
|
|
423
|
+
* @internal
|
|
424
|
+
*/
|
|
425
|
+
public _traceParent?: string;
|
|
426
|
+
|
|
403
427
|
constructor(private readonly _callbacks: InvitationHostExtensionCallbacks) {
|
|
404
428
|
super({
|
|
405
429
|
exposed: {
|
|
@@ -414,15 +438,36 @@ class InvitationHostExtension extends RpcExtension<{}, { InvitationHostService:
|
|
|
414
438
|
// Perhaps in the future we will have more complex logic here.
|
|
415
439
|
InvitationHostService: {
|
|
416
440
|
introduce: async (request) => {
|
|
417
|
-
|
|
441
|
+
const traceId = PublicKey.random().toHex();
|
|
442
|
+
log.trace(
|
|
443
|
+
'dxos.sdk.invitation-handler.host.introduce',
|
|
444
|
+
trace.begin({ id: traceId, parentId: this._traceParent })
|
|
445
|
+
);
|
|
446
|
+
const response = await this._callbacks.introduce(request);
|
|
447
|
+
log.trace('dxos.sdk.invitation-handler.host.introduce', trace.end({ id: traceId }));
|
|
448
|
+
return response;
|
|
418
449
|
},
|
|
419
450
|
|
|
420
451
|
authenticate: async (request) => {
|
|
421
|
-
|
|
452
|
+
const traceId = PublicKey.random().toHex();
|
|
453
|
+
log.trace(
|
|
454
|
+
'dxos.sdk.invitation-handler.host.authenticate',
|
|
455
|
+
trace.begin({ id: traceId, parentId: this._traceParent })
|
|
456
|
+
);
|
|
457
|
+
const response = await this._callbacks.authenticate(request);
|
|
458
|
+
log.trace('dxos.sdk.invitation-handler.host.authenticate', trace.end({ id: traceId, data: { ...response } }));
|
|
459
|
+
return response;
|
|
422
460
|
},
|
|
423
461
|
|
|
424
462
|
admit: async (request) => {
|
|
425
|
-
|
|
463
|
+
const traceId = PublicKey.random().toHex();
|
|
464
|
+
log.trace(
|
|
465
|
+
'dxos.sdk.invitation-handler.host.admit',
|
|
466
|
+
trace.begin({ id: traceId, parentId: this._traceParent })
|
|
467
|
+
);
|
|
468
|
+
const response = await this._callbacks.admit(request);
|
|
469
|
+
log.trace('dxos.sdk.invitation-handler.host.admit', trace.end({ id: traceId }));
|
|
470
|
+
return response;
|
|
426
471
|
}
|
|
427
472
|
}
|
|
428
473
|
};
|
|
@@ -100,6 +100,7 @@ export class ServiceContext {
|
|
|
100
100
|
this.identityManager._traceParent = this._instanceId;
|
|
101
101
|
|
|
102
102
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
103
|
+
this.invitations._traceParent = this._instanceId;
|
|
103
104
|
|
|
104
105
|
// TODO(burdon): _initialize called in multiple places.
|
|
105
106
|
// TODO(burdon): Call _initialize on success.
|
|
@@ -137,13 +138,6 @@ export class ServiceContext {
|
|
|
137
138
|
log.trace('dxos.sdk.service-context', trace.end({ id: this._instanceId }));
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
async reset() {
|
|
141
|
-
log('resetting...');
|
|
142
|
-
await this.close();
|
|
143
|
-
await this.storage.reset();
|
|
144
|
-
log('reset');
|
|
145
|
-
}
|
|
146
|
-
|
|
147
141
|
async createIdentity(params: CreateIdentityOptions = {}) {
|
|
148
142
|
const identity = await this.identityManager.createIdentity(params);
|
|
149
143
|
|
|
@@ -109,8 +109,7 @@ export class ClientServicesHost {
|
|
|
109
109
|
},
|
|
110
110
|
|
|
111
111
|
onReset: async () => {
|
|
112
|
-
|
|
113
|
-
await this._serviceContext.reset();
|
|
112
|
+
await this.reset();
|
|
114
113
|
}
|
|
115
114
|
});
|
|
116
115
|
|
|
@@ -236,4 +235,11 @@ export class ClientServicesHost {
|
|
|
236
235
|
|
|
237
236
|
log.trace('dxos.sdk.client-services-host', trace.end({ id: this._instanceId }));
|
|
238
237
|
}
|
|
238
|
+
|
|
239
|
+
async reset() {
|
|
240
|
+
log('resetting...');
|
|
241
|
+
await this._serviceContext?.close();
|
|
242
|
+
await this._storage!.reset();
|
|
243
|
+
log('reset');
|
|
244
|
+
}
|
|
239
245
|
}
|