@dxos/client-services 0.7.5-main.e9bb01b → 0.7.5-staging.2ff1350
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-O46EJ5BJ.mjs → chunk-VWRYD6LV.mjs} +194 -127
- package/dist/lib/browser/chunk-VWRYD6LV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-WFDMSV4I.cjs → chunk-K6H3KWWB.cjs} +192 -125
- package/dist/lib/node/chunk-K6H3KWWB.cjs.map +7 -0
- package/dist/lib/node/index.cjs +47 -47
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +8 -8
- package/dist/lib/node-esm/{chunk-UWR5XM7L.mjs → chunk-6OZO2NH7.mjs} +194 -127
- package/dist/lib/node-esm/chunk-6OZO2NH7.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +0 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +12 -4
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +8 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.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 +39 -38
- package/src/packlets/agents/edge-agent-manager.ts +6 -0
- package/src/packlets/diagnostics/diagnostics-collector.ts +2 -2
- package/src/packlets/diagnostics/diagnostics.ts +17 -13
- package/src/packlets/identity/identity-manager.ts +3 -29
- package/src/packlets/identity/identity-recovery-manager.ts +86 -9
- package/src/packlets/identity/identity-service.ts +16 -3
- package/src/packlets/identity/identity.test.ts +2 -1
- package/src/packlets/identity/identity.ts +4 -1
- package/src/packlets/spaces/data-space-manager.ts +2 -2
- package/src/packlets/spaces/edge-feed-replicator.ts +8 -8
- package/src/packlets/spaces/spaces-service.ts +30 -20
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-O46EJ5BJ.mjs.map +0 -7
- package/dist/lib/node/chunk-WFDMSV4I.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-UWR5XM7L.mjs.map +0 -7
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { onTestFinished, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Context } from '@dxos/context';
|
|
8
|
-
import { CredentialGenerator, verifyCredential } from '@dxos/credentials';
|
|
8
|
+
import { createDidFromIdentityKey, CredentialGenerator, verifyCredential } from '@dxos/credentials';
|
|
9
9
|
import {
|
|
10
10
|
createIdFromSpaceKey,
|
|
11
11
|
MetadataStore,
|
|
@@ -206,6 +206,7 @@ describe('identity/identity', () => {
|
|
|
206
206
|
|
|
207
207
|
const identity = new Identity({
|
|
208
208
|
signer: keyring,
|
|
209
|
+
did: await createDidFromIdentityKey(identityKey),
|
|
209
210
|
identityKey,
|
|
210
211
|
deviceKey,
|
|
211
212
|
space,
|
|
@@ -17,7 +17,7 @@ import { type Space } from '@dxos/echo-pipeline';
|
|
|
17
17
|
import { type EdgeConnection } from '@dxos/edge-client';
|
|
18
18
|
import { writeMessages, type FeedWrapper } from '@dxos/feed-store';
|
|
19
19
|
import { invariant } from '@dxos/invariant';
|
|
20
|
-
import { PublicKey, type SpaceId } from '@dxos/keys';
|
|
20
|
+
import { type IdentityDid, PublicKey, type SpaceId } from '@dxos/keys';
|
|
21
21
|
import { log } from '@dxos/log';
|
|
22
22
|
import { type Runtime } from '@dxos/protocols/proto/dxos/config';
|
|
23
23
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
@@ -38,6 +38,7 @@ import { DefaultSpaceStateMachine } from './default-space-state-machine';
|
|
|
38
38
|
import { EdgeFeedReplicator } from '../spaces';
|
|
39
39
|
|
|
40
40
|
export type IdentityParams = {
|
|
41
|
+
did: IdentityDid;
|
|
41
42
|
identityKey: PublicKey;
|
|
42
43
|
deviceKey: PublicKey;
|
|
43
44
|
signer: Signer;
|
|
@@ -63,6 +64,7 @@ export class Identity {
|
|
|
63
64
|
|
|
64
65
|
public readonly authVerifier: TrustedKeySetAuthVerifier;
|
|
65
66
|
|
|
67
|
+
public readonly did: IdentityDid;
|
|
66
68
|
public readonly identityKey: PublicKey;
|
|
67
69
|
public readonly deviceKey: PublicKey;
|
|
68
70
|
|
|
@@ -73,6 +75,7 @@ export class Identity {
|
|
|
73
75
|
this._signer = params.signer;
|
|
74
76
|
this._presence = params.presence;
|
|
75
77
|
|
|
78
|
+
this.did = params.did;
|
|
76
79
|
this.identityKey = params.identityKey;
|
|
77
80
|
this.deviceKey = params.deviceKey;
|
|
78
81
|
|
|
@@ -503,7 +503,7 @@ export class DataSpaceManager extends Resource {
|
|
|
503
503
|
});
|
|
504
504
|
dataSpace.postOpen.append(async () => {
|
|
505
505
|
const setting = dataSpace.getEdgeReplicationSetting();
|
|
506
|
-
if (setting === EdgeReplicationSetting.ENABLED) {
|
|
506
|
+
if (!setting || setting === EdgeReplicationSetting.ENABLED) {
|
|
507
507
|
await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
|
|
508
508
|
} else if (this._echoEdgeReplicator) {
|
|
509
509
|
log('not connecting EchoEdgeReplicator because of EdgeReplicationSetting', { spaceId: dataSpace.id });
|
|
@@ -511,7 +511,7 @@ export class DataSpaceManager extends Resource {
|
|
|
511
511
|
});
|
|
512
512
|
dataSpace.preClose.append(async () => {
|
|
513
513
|
const setting = dataSpace.getEdgeReplicationSetting();
|
|
514
|
-
if (setting === EdgeReplicationSetting.ENABLED) {
|
|
514
|
+
if (!setting || setting === EdgeReplicationSetting.ENABLED) {
|
|
515
515
|
await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
|
|
516
516
|
}
|
|
517
517
|
});
|
|
@@ -117,7 +117,7 @@ export class EdgeFeedReplicator extends Resource {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
async addFeed(feed: FeedWrapper<any>) {
|
|
120
|
-
log
|
|
120
|
+
log('addFeed', { key: feed.key, connected: this._connected, hasConnectionCtx: !!this._connectionCtx });
|
|
121
121
|
this._feeds.set(feed.key, feed);
|
|
122
122
|
|
|
123
123
|
if (this._connected && this._connectionCtx) {
|
|
@@ -143,12 +143,12 @@ export class EdgeFeedReplicator extends Resource {
|
|
|
143
143
|
|
|
144
144
|
private async _sendMessage(message: ProtocolMessage) {
|
|
145
145
|
if (!this._connectionCtx) {
|
|
146
|
-
log
|
|
146
|
+
log('message dropped because connection was disposed');
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
if (message.type === 'data') {
|
|
151
|
-
log
|
|
151
|
+
log('sending blocks', {
|
|
152
152
|
feedKey: message.feedKey,
|
|
153
153
|
blocks: message.blocks.map((b) => b.index),
|
|
154
154
|
});
|
|
@@ -191,7 +191,7 @@ export class EdgeFeedReplicator extends Resource {
|
|
|
191
191
|
|
|
192
192
|
const logMeta = { localLength: feed.length, remoteLength: message.length, feedKey };
|
|
193
193
|
if (message.length > feed.length) {
|
|
194
|
-
log
|
|
194
|
+
log('requesting missing blocks', logMeta);
|
|
195
195
|
|
|
196
196
|
await this._sendMessage({
|
|
197
197
|
type: 'request',
|
|
@@ -199,7 +199,7 @@ export class EdgeFeedReplicator extends Resource {
|
|
|
199
199
|
range: { from: feed.length, to: message.length },
|
|
200
200
|
});
|
|
201
201
|
} else if (message.length < feed.length) {
|
|
202
|
-
log
|
|
202
|
+
log('pushing blocks to remote', logMeta);
|
|
203
203
|
|
|
204
204
|
await this._pushBlocks(feed, message.length, feed.length);
|
|
205
205
|
}
|
|
@@ -208,7 +208,7 @@ export class EdgeFeedReplicator extends Resource {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
case 'data': {
|
|
211
|
-
log
|
|
211
|
+
log('received data', { feed: message.feedKey, blocks: message.blocks.map((b) => b.index) });
|
|
212
212
|
|
|
213
213
|
const feedKey = PublicKey.fromHex(message.feedKey);
|
|
214
214
|
const feed = this._feeds.get(feedKey);
|
|
@@ -229,7 +229,7 @@ export class EdgeFeedReplicator extends Resource {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
private async _pushBlocks(feed: FeedWrapper<any>, from: number, to: number) {
|
|
232
|
-
log
|
|
232
|
+
log('pushing blocks', { feed: feed.key.toHex(), from, to });
|
|
233
233
|
|
|
234
234
|
const blocks: FeedBlock[] = await Promise.all(
|
|
235
235
|
rangeFromTo(from, to).map(async (index) => {
|
|
@@ -255,7 +255,7 @@ export class EdgeFeedReplicator extends Resource {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
private async _integrateBlocks(feed: FeedWrapper<any>, blocks: FeedBlock[]) {
|
|
258
|
-
log
|
|
258
|
+
log('integrating blocks', { feed: feed.key.toHex(), blocks: blocks.length });
|
|
259
259
|
|
|
260
260
|
for (const block of blocks) {
|
|
261
261
|
if (feed.has(block.index)) {
|
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import { EventSubscriptions, UpdateScheduler, scheduleTask } from '@dxos/async';
|
|
6
6
|
import { Stream } from '@dxos/codec-protobuf/stream';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
createAdmissionCredentials,
|
|
9
|
+
createDidFromIdentityKey,
|
|
10
|
+
type CredentialProcessor,
|
|
11
|
+
getCredentialAssertion,
|
|
12
|
+
} from '@dxos/credentials';
|
|
8
13
|
import { raise } from '@dxos/debug';
|
|
9
14
|
import { type SpaceManager } from '@dxos/echo-pipeline';
|
|
10
15
|
import { writeMessages } from '@dxos/feed-store';
|
|
@@ -115,7 +120,9 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
115
120
|
ctx,
|
|
116
121
|
async () => {
|
|
117
122
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
118
|
-
const spaces =
|
|
123
|
+
const spaces = await Promise.all(
|
|
124
|
+
Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space)),
|
|
125
|
+
);
|
|
119
126
|
log('update', () => ({ ids: spaces.map((space) => space.id) }));
|
|
120
127
|
await this._updateMetrics();
|
|
121
128
|
next({ spaces });
|
|
@@ -265,10 +272,10 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
265
272
|
await myIdentity.controlPipeline.writer.write({ credential: { credential } });
|
|
266
273
|
}
|
|
267
274
|
|
|
268
|
-
return { space: this._serializeSpace(dataSpace) };
|
|
275
|
+
return { space: await this._serializeSpace(dataSpace) };
|
|
269
276
|
}
|
|
270
277
|
|
|
271
|
-
private _serializeSpace(space: DataSpace): Space {
|
|
278
|
+
private async _serializeSpace(space: DataSpace): Promise<Space> {
|
|
272
279
|
return {
|
|
273
280
|
id: space.id,
|
|
274
281
|
spaceKey: space.key,
|
|
@@ -291,24 +298,27 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
291
298
|
|
|
292
299
|
spaceRootUrl: space.databaseRoot?.url,
|
|
293
300
|
},
|
|
294
|
-
members:
|
|
295
|
-
|
|
296
|
-
|
|
301
|
+
members: await Promise.all(
|
|
302
|
+
Array.from(space.inner.spaceState.members.values()).map(async (member) => {
|
|
303
|
+
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
304
|
+
const isMe = this._identityManager.identity?.identityKey.equals(member.key);
|
|
297
305
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
306
|
+
if (isMe) {
|
|
307
|
+
peers.push(space.presence.getLocalState());
|
|
308
|
+
}
|
|
301
309
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
310
|
+
return {
|
|
311
|
+
identity: {
|
|
312
|
+
did: await createDidFromIdentityKey(member.key),
|
|
313
|
+
identityKey: member.key,
|
|
314
|
+
profile: member.profile ?? {},
|
|
315
|
+
},
|
|
316
|
+
role: member.role,
|
|
317
|
+
presence: peers.length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE,
|
|
318
|
+
peerStates: peers,
|
|
319
|
+
};
|
|
320
|
+
}),
|
|
321
|
+
),
|
|
312
322
|
creator: space.inner.spaceState.creator?.key,
|
|
313
323
|
cache: space.cache,
|
|
314
324
|
metrics: space.metrics,
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DXOS_VERSION = "0.7.5-
|
|
1
|
+
export const DXOS_VERSION = "0.7.5-staging.2ff1350";
|