@dxos/client-services 0.1.56-main.be59a09 → 0.1.56-main.c19b7cd
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-K67JOICT.mjs → chunk-ZOTHWLK5.mjs} +228 -149
- package/dist/lib/browser/chunk-ZOTHWLK5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +14 -12
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +2 -2
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +223 -142
- 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 +210 -131
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +2 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +3 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -33
- package/src/packlets/devices/devices-service.test.ts +2 -1
- package/src/packlets/identity/identity-manager.test.ts +4 -3
- package/src/packlets/identity/identity-manager.ts +9 -5
- package/src/packlets/identity/identity-service.test.ts +2 -1
- package/src/packlets/identity/identity.test.ts +7 -6
- package/src/packlets/identity/identity.ts +8 -3
- package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
- package/src/packlets/network/network-service.test.ts +2 -1
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/service-context.test.ts +59 -0
- package/src/packlets/services/service-context.ts +11 -6
- package/src/packlets/services/service-host.test.ts +6 -5
- package/src/packlets/services/service-host.ts +15 -3
- package/src/packlets/services/service-registry.test.ts +2 -1
- package/src/packlets/spaces/data-space.ts +17 -5
- package/src/packlets/spaces/spaces-service.test.ts +2 -1
- package/src/packlets/testing/test-builder.ts +1 -1
- package/src/packlets/vault/iframe-host-runtime.ts +2 -1
- package/src/packlets/vault/worker-runtime.ts +2 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-K67JOICT.mjs.map +0 -7
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Trigger } from '@dxos/async';
|
|
6
|
+
import { Context } from '@dxos/context';
|
|
6
7
|
import { CredentialProcessor, getCredentialAssertion } from '@dxos/credentials';
|
|
7
8
|
import { failUndefined } from '@dxos/debug';
|
|
8
9
|
import {
|
|
@@ -26,6 +27,7 @@ import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
|
26
27
|
import { Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
27
28
|
import { Storage } from '@dxos/random-access-storage';
|
|
28
29
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
30
|
+
import { trace as Trace } from '@dxos/tracing';
|
|
29
31
|
|
|
30
32
|
import { CreateIdentityOptions, IdentityManager, JoinIdentityParams } from '../identity';
|
|
31
33
|
import {
|
|
@@ -40,6 +42,7 @@ import { DataSpaceManager, SigningContext } from '../spaces';
|
|
|
40
42
|
* Shared backend for all client services.
|
|
41
43
|
*/
|
|
42
44
|
// TODO(burdon): Rename/break-up into smaller components. And/or make members private.
|
|
45
|
+
@Trace.resource()
|
|
43
46
|
export class ServiceContext {
|
|
44
47
|
public readonly initialized = new Trigger();
|
|
45
48
|
public readonly dataServiceSubscriptions = new DataServiceSubscriptions();
|
|
@@ -121,7 +124,8 @@ export class ServiceContext {
|
|
|
121
124
|
);
|
|
122
125
|
}
|
|
123
126
|
|
|
124
|
-
|
|
127
|
+
@Trace.span()
|
|
128
|
+
async open(ctx: Context) {
|
|
125
129
|
await this._checkStorageVersion();
|
|
126
130
|
|
|
127
131
|
log('opening...');
|
|
@@ -129,9 +133,9 @@ export class ServiceContext {
|
|
|
129
133
|
await this.signalManager.open();
|
|
130
134
|
await this.networkManager.open();
|
|
131
135
|
await this.spaceManager.open();
|
|
132
|
-
await this.identityManager.open();
|
|
136
|
+
await this.identityManager.open(ctx);
|
|
133
137
|
if (this.identityManager.identity) {
|
|
134
|
-
await this._initialize();
|
|
138
|
+
await this._initialize(ctx);
|
|
135
139
|
}
|
|
136
140
|
log.trace('dxos.sdk.service-context.open', trace.end({ id: this._instanceId }));
|
|
137
141
|
log('opened');
|
|
@@ -155,7 +159,7 @@ export class ServiceContext {
|
|
|
155
159
|
async createIdentity(params: CreateIdentityOptions = {}) {
|
|
156
160
|
const identity = await this.identityManager.createIdentity(params);
|
|
157
161
|
|
|
158
|
-
await this._initialize();
|
|
162
|
+
await this._initialize(new Context());
|
|
159
163
|
return identity;
|
|
160
164
|
}
|
|
161
165
|
|
|
@@ -168,7 +172,7 @@ export class ServiceContext {
|
|
|
168
172
|
private async _acceptIdentity(params: JoinIdentityParams) {
|
|
169
173
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
170
174
|
|
|
171
|
-
await this._initialize();
|
|
175
|
+
await this._initialize(new Context());
|
|
172
176
|
return identity;
|
|
173
177
|
}
|
|
174
178
|
|
|
@@ -181,7 +185,8 @@ export class ServiceContext {
|
|
|
181
185
|
}
|
|
182
186
|
|
|
183
187
|
// Called when identity is created.
|
|
184
|
-
|
|
188
|
+
@Trace.span()
|
|
189
|
+
private async _initialize(ctx: Context) {
|
|
185
190
|
log('initializing spaces...');
|
|
186
191
|
const identity = this.identityManager.identity ?? failUndefined();
|
|
187
192
|
const signingContext: SigningContext = {
|
|
@@ -8,6 +8,7 @@ import { rmSync } from 'node:fs';
|
|
|
8
8
|
|
|
9
9
|
import { asyncTimeout, latch, Trigger } from '@dxos/async';
|
|
10
10
|
import { Config } from '@dxos/config';
|
|
11
|
+
import { Context } from '@dxos/context';
|
|
11
12
|
import { verifyPresentation } from '@dxos/credentials';
|
|
12
13
|
import { PublicKey } from '@dxos/keys';
|
|
13
14
|
import { MemorySignalManagerContext } from '@dxos/messaging';
|
|
@@ -30,7 +31,7 @@ describe('ClientServicesHost', () => {
|
|
|
30
31
|
|
|
31
32
|
test('queryCredentials', async () => {
|
|
32
33
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
33
|
-
await host.open();
|
|
34
|
+
await host.open(new Context());
|
|
34
35
|
afterTest(() => host.close());
|
|
35
36
|
|
|
36
37
|
await host.services.IdentityService!.createIdentity({});
|
|
@@ -49,7 +50,7 @@ describe('ClientServicesHost', () => {
|
|
|
49
50
|
|
|
50
51
|
test('write and query credentials', async () => {
|
|
51
52
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
52
|
-
await host.open();
|
|
53
|
+
await host.open(new Context());
|
|
53
54
|
afterTest(() => host.close());
|
|
54
55
|
|
|
55
56
|
await host.services.IdentityService!.createIdentity({});
|
|
@@ -86,7 +87,7 @@ describe('ClientServicesHost', () => {
|
|
|
86
87
|
|
|
87
88
|
test('sign presentation', async () => {
|
|
88
89
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
89
|
-
await host.open();
|
|
90
|
+
await host.open(new Context());
|
|
90
91
|
afterTest(() => host.close());
|
|
91
92
|
|
|
92
93
|
await host.services.IdentityService!.createIdentity({});
|
|
@@ -117,7 +118,7 @@ describe('ClientServicesHost', () => {
|
|
|
117
118
|
});
|
|
118
119
|
{
|
|
119
120
|
const host = createServiceHost(config, new MemorySignalManagerContext());
|
|
120
|
-
await host.open();
|
|
121
|
+
await host.open(new Context());
|
|
121
122
|
|
|
122
123
|
await host.services.IdentityService?.createIdentity({});
|
|
123
124
|
|
|
@@ -129,7 +130,7 @@ describe('ClientServicesHost', () => {
|
|
|
129
130
|
|
|
130
131
|
{
|
|
131
132
|
const host = createServiceHost(config, new MemorySignalManagerContext());
|
|
132
|
-
await host.open();
|
|
133
|
+
await host.open(new Context());
|
|
133
134
|
const trigger = new Trigger<Identity>();
|
|
134
135
|
|
|
135
136
|
const stream = host.services.IdentityService?.queryIdentity();
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { Event, synchronized } from '@dxos/async';
|
|
6
6
|
import { clientServiceBundle, ClientServices } from '@dxos/client-protocol';
|
|
7
7
|
import { Config } from '@dxos/config';
|
|
8
|
+
import { Context } from '@dxos/context';
|
|
8
9
|
import { DocumentModel } from '@dxos/document-model';
|
|
9
10
|
import { DataServiceImpl } from '@dxos/echo-pipeline';
|
|
10
11
|
import { invariant } from '@dxos/invariant';
|
|
@@ -17,6 +18,7 @@ import { trace } from '@dxos/protocols';
|
|
|
17
18
|
import { SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
18
19
|
import { Storage } from '@dxos/random-access-storage';
|
|
19
20
|
import { TextModel } from '@dxos/text-model';
|
|
21
|
+
import { TRACE_PROCESSOR, trace as Trace } from '@dxos/tracing';
|
|
20
22
|
|
|
21
23
|
import { DevicesServiceImpl } from '../devices';
|
|
22
24
|
import { DevtoolsServiceImpl, DevtoolsHostEvents } from '../devtools';
|
|
@@ -65,11 +67,13 @@ export type InitializeOptions = {
|
|
|
65
67
|
/**
|
|
66
68
|
* Remote service implementation.
|
|
67
69
|
*/
|
|
70
|
+
@Trace.resource()
|
|
68
71
|
export class ClientServicesHost {
|
|
69
72
|
private readonly _resourceLock?: ResourceLock;
|
|
70
73
|
private readonly _serviceRegistry: ServiceRegistry<ClientServices>;
|
|
71
74
|
private readonly _systemService: SystemServiceImpl;
|
|
72
75
|
private readonly _loggingService: LoggingServiceImpl;
|
|
76
|
+
private readonly _tracingService = TRACE_PROCESSOR.createTraceSender();
|
|
73
77
|
|
|
74
78
|
private _config?: Config;
|
|
75
79
|
private readonly _statusUpdate = new Event<void>();
|
|
@@ -80,7 +84,11 @@ export class ClientServicesHost {
|
|
|
80
84
|
private _callbacks?: ClientServicesHostCallbacks;
|
|
81
85
|
|
|
82
86
|
private _serviceContext!: ServiceContext;
|
|
87
|
+
|
|
88
|
+
@Trace.info()
|
|
83
89
|
private _opening = false;
|
|
90
|
+
|
|
91
|
+
@Trace.info()
|
|
84
92
|
private _open = false;
|
|
85
93
|
|
|
86
94
|
constructor({
|
|
@@ -106,7 +114,7 @@ export class ClientServicesHost {
|
|
|
106
114
|
lockKey,
|
|
107
115
|
onAcquire: () => {
|
|
108
116
|
if (!this._opening) {
|
|
109
|
-
void this.open();
|
|
117
|
+
void this.open(new Context());
|
|
110
118
|
}
|
|
111
119
|
},
|
|
112
120
|
onRelease: () => this.close(),
|
|
@@ -136,6 +144,7 @@ export class ClientServicesHost {
|
|
|
136
144
|
|
|
137
145
|
this._serviceRegistry = new ServiceRegistry<ClientServices>(clientServiceBundle, {
|
|
138
146
|
SystemService: this._systemService,
|
|
147
|
+
TracingService: this._tracingService,
|
|
139
148
|
});
|
|
140
149
|
}
|
|
141
150
|
|
|
@@ -200,7 +209,8 @@ export class ClientServicesHost {
|
|
|
200
209
|
}
|
|
201
210
|
|
|
202
211
|
@synchronized
|
|
203
|
-
|
|
212
|
+
@Trace.span()
|
|
213
|
+
async open(ctx: Context) {
|
|
204
214
|
if (this._open) {
|
|
205
215
|
return;
|
|
206
216
|
}
|
|
@@ -252,6 +262,7 @@ export class ClientServicesHost {
|
|
|
252
262
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
253
263
|
|
|
254
264
|
LoggingService: this._loggingService,
|
|
265
|
+
TracingService: this._tracingService,
|
|
255
266
|
|
|
256
267
|
// TODO(burdon): Move to new protobuf definitions.
|
|
257
268
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
@@ -261,7 +272,7 @@ export class ClientServicesHost {
|
|
|
261
272
|
}),
|
|
262
273
|
});
|
|
263
274
|
|
|
264
|
-
await this._serviceContext.open();
|
|
275
|
+
await this._serviceContext.open(ctx);
|
|
265
276
|
this._opening = false;
|
|
266
277
|
this._open = true;
|
|
267
278
|
this._statusUpdate.emit();
|
|
@@ -271,6 +282,7 @@ export class ClientServicesHost {
|
|
|
271
282
|
}
|
|
272
283
|
|
|
273
284
|
@synchronized
|
|
285
|
+
@Trace.span()
|
|
274
286
|
async close() {
|
|
275
287
|
if (!this._open) {
|
|
276
288
|
return;
|
|
@@ -7,6 +7,7 @@ import { expect } from 'chai';
|
|
|
7
7
|
import { Event } from '@dxos/async';
|
|
8
8
|
import { ClientServices } from '@dxos/client-protocol';
|
|
9
9
|
import { Config } from '@dxos/config';
|
|
10
|
+
import { Context } from '@dxos/context';
|
|
10
11
|
import { log } from '@dxos/log';
|
|
11
12
|
import { schema } from '@dxos/protocols';
|
|
12
13
|
import { SystemService, SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
@@ -31,7 +32,7 @@ describe('service registry', () => {
|
|
|
31
32
|
test('builds a service registry', async () => {
|
|
32
33
|
const remoteSource = 'https://remote.source';
|
|
33
34
|
const serviceContext = createServiceContext();
|
|
34
|
-
await serviceContext.open();
|
|
35
|
+
await serviceContext.open(new Context());
|
|
35
36
|
|
|
36
37
|
const serviceRegistry = new ServiceRegistry(serviceBundle, {
|
|
37
38
|
SystemService: new SystemServiceImpl({
|
|
@@ -55,6 +55,12 @@ export type DataSpaceParams = {
|
|
|
55
55
|
cache?: SpaceCache;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Delete feed blocks after an epoch is created.
|
|
60
|
+
*/
|
|
61
|
+
// TODO(dmaretskyi): Disabled till better times https://github.com/dxos/dxos/issues/3949.
|
|
62
|
+
const ENABLE_FEED_PURGE = false;
|
|
63
|
+
|
|
58
64
|
@trackLeaks('open', 'close')
|
|
59
65
|
export class DataSpace {
|
|
60
66
|
private _ctx = new Context();
|
|
@@ -145,7 +151,7 @@ export class DataSpace {
|
|
|
145
151
|
private async _open() {
|
|
146
152
|
await this._notarizationPlugin.open();
|
|
147
153
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
148
|
-
await this._inner.open();
|
|
154
|
+
await this._inner.open(new Context());
|
|
149
155
|
this._state = SpaceState.CONTROL_ONLY;
|
|
150
156
|
this.stateUpdate.emit();
|
|
151
157
|
this.metrics = {};
|
|
@@ -323,10 +329,16 @@ export class DataSpace {
|
|
|
323
329
|
});
|
|
324
330
|
|
|
325
331
|
await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe([[receipt.feedKey, receipt.seq]]));
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
332
|
+
|
|
333
|
+
// Clear feed blocks before epoch.
|
|
334
|
+
if (ENABLE_FEED_PURGE) {
|
|
335
|
+
for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
|
|
336
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
337
|
+
if (indexBeforeEpoch === undefined) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
await feed.safeClear(0, indexBeforeEpoch + 1);
|
|
330
342
|
}
|
|
331
343
|
}
|
|
332
344
|
}
|
|
@@ -6,6 +6,7 @@ import chai, { expect } from 'chai';
|
|
|
6
6
|
import chaiAsPromised from 'chai-as-promised';
|
|
7
7
|
|
|
8
8
|
import { Trigger } from '@dxos/async';
|
|
9
|
+
import { Context } from '@dxos/context';
|
|
9
10
|
import { PublicKey } from '@dxos/keys';
|
|
10
11
|
import { Space, SpacesService } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
12
|
import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
|
|
@@ -22,7 +23,7 @@ describe('SpacesService', () => {
|
|
|
22
23
|
|
|
23
24
|
beforeEach(async () => {
|
|
24
25
|
serviceContext = createServiceContext();
|
|
25
|
-
await serviceContext.open();
|
|
26
|
+
await serviceContext.open(new Context());
|
|
26
27
|
spacesService = new SpacesServiceImpl(
|
|
27
28
|
serviceContext.identityManager,
|
|
28
29
|
serviceContext.spaceManager,
|
|
@@ -60,7 +60,7 @@ export const createPeers = async (numPeers: number) => {
|
|
|
60
60
|
return await Promise.all(
|
|
61
61
|
Array.from(Array(numPeers)).map(async () => {
|
|
62
62
|
const peer = createServiceContext({ signalContext });
|
|
63
|
-
await peer.open();
|
|
63
|
+
await peer.open(new Context());
|
|
64
64
|
return peer;
|
|
65
65
|
}),
|
|
66
66
|
);
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { Trigger } from '@dxos/async';
|
|
6
6
|
import { PROXY_CONNECTION_TIMEOUT, ShellRuntime } from '@dxos/client-protocol';
|
|
7
7
|
import { Config } from '@dxos/config';
|
|
8
|
+
import { Context } from '@dxos/context';
|
|
8
9
|
import { log, logInfo } from '@dxos/log';
|
|
9
10
|
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from '@dxos/messaging';
|
|
10
11
|
import { createWebRTCTransportFactory, TransportFactory } from '@dxos/network-manager';
|
|
@@ -108,7 +109,7 @@ export class IFrameHostRuntime {
|
|
|
108
109
|
...middleware,
|
|
109
110
|
});
|
|
110
111
|
|
|
111
|
-
await Promise.all([this._clientServices.open(), this._clientRpc.open(), this._shellRuntime?.open()]);
|
|
112
|
+
await Promise.all([this._clientServices.open(new Context()), this._clientRpc.open(), this._shellRuntime?.open()]);
|
|
112
113
|
this._ready.wake(undefined);
|
|
113
114
|
log('started');
|
|
114
115
|
} catch (err: any) {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Trigger } from '@dxos/async';
|
|
6
6
|
import { Config } from '@dxos/config';
|
|
7
|
+
import { Context } from '@dxos/context';
|
|
7
8
|
import { log } from '@dxos/log';
|
|
8
9
|
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from '@dxos/messaging';
|
|
9
10
|
import { WebRTCTransportProxyFactory } from '@dxos/network-manager';
|
|
@@ -57,7 +58,7 @@ export class WorkerRuntime {
|
|
|
57
58
|
transportFactory: this._transportFactory,
|
|
58
59
|
});
|
|
59
60
|
|
|
60
|
-
await this._clientServices.open();
|
|
61
|
+
await this._clientServices.open(new Context());
|
|
61
62
|
this._ready.wake(undefined);
|
|
62
63
|
log('started');
|
|
63
64
|
} catch (err: any) {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DXOS_VERSION = "0.1.56-main.
|
|
1
|
+
export const DXOS_VERSION = "0.1.56-main.c19b7cd";
|