@dxos/client-services 0.4.6 → 0.4.7-main.2d03537
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-NVX5DORM.mjs → chunk-SG2O3ZVM.mjs} +205 -136
- package/dist/lib/browser/chunk-SG2O3ZVM.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/{chunk-JQTJTW5S.cjs → chunk-N6ZESGNQ.cjs} +196 -127
- package/dist/lib/node/chunk-N6ZESGNQ.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -37
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +8 -8
- package/dist/types/src/packlets/devices/devices-service.d.ts +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +8 -2
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +5 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +5 -3
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +4 -2
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +7 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +35 -35
- package/src/packlets/devices/devices-service.test.ts +8 -4
- package/src/packlets/devices/devices-service.ts +47 -11
- package/src/packlets/identity/identity-manager.ts +48 -6
- package/src/packlets/identity/identity.ts +9 -1
- package/src/packlets/services/service-context.ts +17 -3
- package/src/packlets/services/service-host.ts +8 -3
- package/src/packlets/spaces/data-space-manager.ts +18 -3
- package/src/version.ts +1 -5
- package/dist/lib/browser/chunk-NVX5DORM.mjs.map +0 -7
- package/dist/lib/node/chunk-JQTJTW5S.cjs.map +0 -7
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type ProfileDocument,
|
|
26
26
|
} from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
27
27
|
import { type DeviceAdmissionRequest } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
28
|
+
import { type Presence } from '@dxos/teleport-extension-gossip';
|
|
28
29
|
import { trace } from '@dxos/tracing';
|
|
29
30
|
import { type ComplexMap, ComplexSet } from '@dxos/util';
|
|
30
31
|
|
|
@@ -35,6 +36,7 @@ export type IdentityParams = {
|
|
|
35
36
|
deviceKey: PublicKey;
|
|
36
37
|
signer: Signer;
|
|
37
38
|
space: Space;
|
|
39
|
+
presence?: Presence;
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
/**
|
|
@@ -44,6 +46,7 @@ export type IdentityParams = {
|
|
|
44
46
|
export class Identity {
|
|
45
47
|
public readonly space: Space;
|
|
46
48
|
private readonly _signer: Signer;
|
|
49
|
+
private readonly _presence?: Presence;
|
|
47
50
|
private readonly _deviceStateMachine: DeviceStateMachine;
|
|
48
51
|
private readonly _profileStateMachine: ProfileStateMachine;
|
|
49
52
|
public readonly authVerifier: TrustedKeySetAuthVerifier;
|
|
@@ -53,9 +56,10 @@ export class Identity {
|
|
|
53
56
|
|
|
54
57
|
public readonly stateUpdate = new Event();
|
|
55
58
|
|
|
56
|
-
constructor({ space, signer, identityKey, deviceKey }: IdentityParams) {
|
|
59
|
+
constructor({ space, signer, identityKey, deviceKey, presence }: IdentityParams) {
|
|
57
60
|
this.space = space;
|
|
58
61
|
this._signer = signer;
|
|
62
|
+
this._presence = presence;
|
|
59
63
|
|
|
60
64
|
this.identityKey = identityKey;
|
|
61
65
|
this.deviceKey = deviceKey;
|
|
@@ -128,6 +132,10 @@ export class Identity {
|
|
|
128
132
|
return this._deviceStateMachine.deviceCredentialChain;
|
|
129
133
|
}
|
|
130
134
|
|
|
135
|
+
get presence() {
|
|
136
|
+
return this._presence;
|
|
137
|
+
}
|
|
138
|
+
|
|
131
139
|
/**
|
|
132
140
|
* Issues credentials as identity.
|
|
133
141
|
* Requires identity to be ready.
|
|
@@ -31,15 +31,21 @@ import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
|
31
31
|
import { trace as Trace } from '@dxos/tracing';
|
|
32
32
|
import { safeInstanceof } from '@dxos/util';
|
|
33
33
|
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
type CreateIdentityOptions,
|
|
36
|
+
IdentityManager,
|
|
37
|
+
type IdentityManagerRuntimeParams,
|
|
38
|
+
type JoinIdentityParams,
|
|
39
|
+
} from '../identity';
|
|
35
40
|
import {
|
|
36
41
|
DeviceInvitationProtocol,
|
|
37
42
|
InvitationsHandler,
|
|
38
43
|
type InvitationProtocol,
|
|
39
44
|
SpaceInvitationProtocol,
|
|
40
45
|
} from '../invitations';
|
|
41
|
-
import { DataSpaceManager, type SigningContext } from '../spaces';
|
|
46
|
+
import { DataSpaceManager, type DataSpaceManagerRuntimeParams, type SigningContext } from '../spaces';
|
|
42
47
|
|
|
48
|
+
export type ServiceContextRuntimeParams = IdentityManagerRuntimeParams & DataSpaceManagerRuntimeParams;
|
|
43
49
|
/**
|
|
44
50
|
* Shared backend for all client services.
|
|
45
51
|
*/
|
|
@@ -80,6 +86,7 @@ export class ServiceContext {
|
|
|
80
86
|
public readonly networkManager: NetworkManager,
|
|
81
87
|
public readonly signalManager: SignalManager,
|
|
82
88
|
public readonly modelFactory: ModelFactory,
|
|
89
|
+
public readonly _runtimeParams?: IdentityManagerRuntimeParams & DataSpaceManagerRuntimeParams,
|
|
83
90
|
) {
|
|
84
91
|
// TODO(burdon): Move strings to constants.
|
|
85
92
|
this.metadataStore = new MetadataStore(storage.createDirectory('metadata'));
|
|
@@ -107,7 +114,13 @@ export class ServiceContext {
|
|
|
107
114
|
snapshotStore: this.snapshotStore,
|
|
108
115
|
});
|
|
109
116
|
|
|
110
|
-
this.identityManager = new IdentityManager(
|
|
117
|
+
this.identityManager = new IdentityManager(
|
|
118
|
+
this.metadataStore,
|
|
119
|
+
this.keyring,
|
|
120
|
+
this.feedStore,
|
|
121
|
+
this.spaceManager,
|
|
122
|
+
this._runtimeParams as IdentityManagerRuntimeParams,
|
|
123
|
+
);
|
|
111
124
|
|
|
112
125
|
this.automergeHost = new AutomergeHost(storage.createDirectory('automerge'));
|
|
113
126
|
|
|
@@ -221,6 +234,7 @@ export class ServiceContext {
|
|
|
221
234
|
signingContext,
|
|
222
235
|
this.feedStore,
|
|
223
236
|
this.automergeHost,
|
|
237
|
+
this._runtimeParams as DataSpaceManagerRuntimeParams,
|
|
224
238
|
);
|
|
225
239
|
await this.dataSpaceManager.open();
|
|
226
240
|
|
|
@@ -8,7 +8,7 @@ import { type Config } from '@dxos/config';
|
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { DocumentModel } from '@dxos/document-model';
|
|
10
10
|
import { DataServiceImpl } from '@dxos/echo-pipeline';
|
|
11
|
-
import { type TypedObject,
|
|
11
|
+
import { type TypedObject, getRawDoc, type SpaceDoc, getAutomergeObjectCore } from '@dxos/echo-schema';
|
|
12
12
|
import { invariant } from '@dxos/invariant';
|
|
13
13
|
import { PublicKey } from '@dxos/keys';
|
|
14
14
|
import { log } from '@dxos/log';
|
|
@@ -24,7 +24,7 @@ import { assignDeep } from '@dxos/util';
|
|
|
24
24
|
import { WebsocketRpcClient } from '@dxos/websocket-rpc';
|
|
25
25
|
|
|
26
26
|
import { createDiagnostics } from './diagnostics';
|
|
27
|
-
import { ServiceContext } from './service-context';
|
|
27
|
+
import { ServiceContext, type ServiceContextRuntimeParams } from './service-context';
|
|
28
28
|
import { ServiceRegistry } from './service-registry';
|
|
29
29
|
import { DevicesServiceImpl } from '../devices';
|
|
30
30
|
import { DevtoolsServiceImpl, DevtoolsHostEvents } from '../devtools';
|
|
@@ -54,6 +54,7 @@ export type ClientServicesHostParams = {
|
|
|
54
54
|
storage?: Storage;
|
|
55
55
|
lockKey?: string;
|
|
56
56
|
callbacks?: ClientServicesHostCallbacks;
|
|
57
|
+
runtimeParams?: ServiceContextRuntimeParams;
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
export type ClientServicesHostCallbacks = {
|
|
@@ -88,6 +89,7 @@ export class ClientServicesHost {
|
|
|
88
89
|
private _devtoolsProxy?: WebsocketRpcClient<{}, ClientServices>;
|
|
89
90
|
|
|
90
91
|
private _serviceContext!: ServiceContext;
|
|
92
|
+
private readonly _runtimeParams?: ServiceContextRuntimeParams;
|
|
91
93
|
|
|
92
94
|
@Trace.info()
|
|
93
95
|
private _opening = false;
|
|
@@ -104,10 +106,12 @@ export class ClientServicesHost {
|
|
|
104
106
|
// TODO(wittjosiah): Turn this on by default.
|
|
105
107
|
lockKey,
|
|
106
108
|
callbacks,
|
|
109
|
+
runtimeParams,
|
|
107
110
|
}: ClientServicesHostParams = {}) {
|
|
108
111
|
this._storage = storage;
|
|
109
112
|
this._modelFactory = modelFactory;
|
|
110
113
|
this._callbacks = callbacks;
|
|
114
|
+
this._runtimeParams = runtimeParams;
|
|
111
115
|
|
|
112
116
|
if (config) {
|
|
113
117
|
this.initialize({ config, transportFactory, signalManager });
|
|
@@ -239,6 +243,7 @@ export class ClientServicesHost {
|
|
|
239
243
|
this._networkManager,
|
|
240
244
|
this._signalManager,
|
|
241
245
|
this._modelFactory,
|
|
246
|
+
this._runtimeParams,
|
|
242
247
|
);
|
|
243
248
|
|
|
244
249
|
this._serviceRegistry.setServices({
|
|
@@ -352,7 +357,7 @@ export class ClientServicesHost {
|
|
|
352
357
|
await document.whenReady();
|
|
353
358
|
|
|
354
359
|
document.change((doc: SpaceDoc) => {
|
|
355
|
-
assignDeep(doc, ['objects', obj
|
|
360
|
+
assignDeep(doc, ['objects', getAutomergeObjectCore(obj).id], getRawDoc(obj).handle.docSync());
|
|
356
361
|
});
|
|
357
362
|
|
|
358
363
|
return identity;
|
|
@@ -59,6 +59,11 @@ export type AcceptSpaceOptions = {
|
|
|
59
59
|
dataTimeframe?: Timeframe;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
+
export type DataSpaceManagerRuntimeParams = {
|
|
63
|
+
spaceMemberPresenceAnnounceInterval?: number;
|
|
64
|
+
spaceMemberPresenceOfflineTimeout?: number;
|
|
65
|
+
};
|
|
66
|
+
|
|
62
67
|
@trackLeaks('open', 'close')
|
|
63
68
|
export class DataSpaceManager {
|
|
64
69
|
private readonly _ctx = new Context();
|
|
@@ -69,6 +74,8 @@ export class DataSpaceManager {
|
|
|
69
74
|
|
|
70
75
|
private _isOpen = false;
|
|
71
76
|
private readonly _instanceId = PublicKey.random().toHex();
|
|
77
|
+
private readonly _spaceMemberPresenceAnnounceInterval: number;
|
|
78
|
+
private readonly _spaceMemberPresenceOfflineTimeout: number;
|
|
72
79
|
|
|
73
80
|
constructor(
|
|
74
81
|
private readonly _spaceManager: SpaceManager,
|
|
@@ -78,7 +85,15 @@ export class DataSpaceManager {
|
|
|
78
85
|
private readonly _signingContext: SigningContext,
|
|
79
86
|
private readonly _feedStore: FeedStore<FeedMessage>,
|
|
80
87
|
private readonly _automergeHost: AutomergeHost,
|
|
81
|
-
|
|
88
|
+
params?: DataSpaceManagerRuntimeParams,
|
|
89
|
+
) {
|
|
90
|
+
const {
|
|
91
|
+
spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL,
|
|
92
|
+
spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT,
|
|
93
|
+
} = params ?? {};
|
|
94
|
+
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
95
|
+
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
96
|
+
}
|
|
82
97
|
|
|
83
98
|
// TODO(burdon): Remove.
|
|
84
99
|
get spaces() {
|
|
@@ -204,8 +219,8 @@ export class DataSpaceManager {
|
|
|
204
219
|
localPeerId: this._signingContext.deviceKey,
|
|
205
220
|
});
|
|
206
221
|
const presence = new Presence({
|
|
207
|
-
announceInterval:
|
|
208
|
-
offlineTimeout:
|
|
222
|
+
announceInterval: this._spaceMemberPresenceAnnounceInterval,
|
|
223
|
+
offlineTimeout: this._spaceMemberPresenceOfflineTimeout,
|
|
209
224
|
identityKey: this._signingContext.identityKey,
|
|
210
225
|
gossip,
|
|
211
226
|
});
|
package/src/version.ts
CHANGED