@dxos/client-services 0.3.9-main.f27ec14 → 0.3.9-main.f8fc6b9
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-RXLILE6E.mjs → chunk-F2XXOT7U.mjs} +127 -65
- package/dist/lib/browser/chunk-F2XXOT7U.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 +7 -3
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-U3CT7ITF.cjs → chunk-ZZBDK4AA.cjs} +128 -77
- package/dist/lib/node/chunk-ZZBDK4AA.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 +11 -8
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- 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.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +8 -0
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +3 -2
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +7 -2
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +3 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +35 -35
- package/src/packlets/services/service-context.ts +5 -0
- package/src/packlets/services/service-host.ts +5 -2
- package/src/packlets/spaces/automerge-space-state.ts +22 -0
- package/src/packlets/spaces/data-space-manager.ts +12 -2
- package/src/packlets/spaces/data-space.ts +53 -6
- package/src/packlets/spaces/genesis.ts +7 -1
- package/src/packlets/testing/test-builder.ts +7 -0
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-RXLILE6E.mjs.map +0 -7
- package/dist/lib/node/chunk-U3CT7ITF.cjs.map +0 -7
|
@@ -6,22 +6,35 @@ import { Event, scheduleTask, sleep, synchronized, trackLeaks } from '@dxos/asyn
|
|
|
6
6
|
import { AUTH_TIMEOUT } from '@dxos/client-protocol';
|
|
7
7
|
import { cancelWithContext, Context } from '@dxos/context';
|
|
8
8
|
import { timed } from '@dxos/debug';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
type MetadataStore,
|
|
11
|
+
type Space,
|
|
12
|
+
createMappedFeedWriter,
|
|
13
|
+
type DataPipeline,
|
|
14
|
+
type CreateEpochOptions,
|
|
15
|
+
type AutomergeHost,
|
|
16
|
+
} from '@dxos/echo-pipeline';
|
|
10
17
|
import { type FeedStore } from '@dxos/feed-store';
|
|
11
18
|
import { type Keyring } from '@dxos/keyring';
|
|
12
19
|
import { PublicKey } from '@dxos/keys';
|
|
13
20
|
import { log } from '@dxos/log';
|
|
14
21
|
import { CancelledError, SystemError } from '@dxos/protocols';
|
|
15
|
-
import { SpaceState, type Space as SpaceProto } from '@dxos/protocols/proto/dxos/client/services';
|
|
22
|
+
import { SpaceState, type Space as SpaceProto, CreateEpochRequest } from '@dxos/protocols/proto/dxos/client/services';
|
|
16
23
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
17
24
|
import { type SpaceCache } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
18
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
AdmittedFeed,
|
|
27
|
+
type ProfileDocument,
|
|
28
|
+
type Credential,
|
|
29
|
+
type Epoch,
|
|
30
|
+
} from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
19
31
|
import { type GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gossip';
|
|
20
32
|
import { type Gossip, type Presence } from '@dxos/teleport-extension-gossip';
|
|
21
33
|
import { Timeframe } from '@dxos/timeframe';
|
|
22
34
|
import { trace } from '@dxos/tracing';
|
|
23
35
|
import { ComplexSet } from '@dxos/util';
|
|
24
36
|
|
|
37
|
+
import { AutomergeSpaceState } from './automerge-space-state';
|
|
25
38
|
import { type SigningContext } from './data-space-manager';
|
|
26
39
|
import { NotarizationPlugin } from './notarization-plugin';
|
|
27
40
|
import { TrustedKeySetAuthVerifier } from '../identity';
|
|
@@ -54,6 +67,9 @@ export type DataSpaceParams = {
|
|
|
54
67
|
signingContext: SigningContext;
|
|
55
68
|
callbacks?: DataSpaceCallbacks;
|
|
56
69
|
cache?: SpaceCache;
|
|
70
|
+
|
|
71
|
+
// TODO(dmaretskyi): Make required.
|
|
72
|
+
automergeHost?: AutomergeHost;
|
|
57
73
|
};
|
|
58
74
|
|
|
59
75
|
/**
|
|
@@ -74,7 +90,11 @@ export class DataSpace {
|
|
|
74
90
|
private readonly _signingContext: SigningContext;
|
|
75
91
|
private readonly _notarizationPlugin = new NotarizationPlugin();
|
|
76
92
|
private readonly _callbacks: DataSpaceCallbacks;
|
|
77
|
-
private readonly _cache?: SpaceCache;
|
|
93
|
+
private readonly _cache?: SpaceCache = undefined;
|
|
94
|
+
private readonly _automergeHost?: AutomergeHost = undefined;
|
|
95
|
+
|
|
96
|
+
// TODO(dmaretskyi): Move into Space?
|
|
97
|
+
private readonly _automergeSpaceState = new AutomergeSpaceState();
|
|
78
98
|
|
|
79
99
|
private _state = SpaceState.CLOSED;
|
|
80
100
|
|
|
@@ -151,6 +171,10 @@ export class DataSpace {
|
|
|
151
171
|
return this._cache;
|
|
152
172
|
}
|
|
153
173
|
|
|
174
|
+
get automergeSpaceState() {
|
|
175
|
+
return this._automergeSpaceState;
|
|
176
|
+
}
|
|
177
|
+
|
|
154
178
|
@synchronized
|
|
155
179
|
async open() {
|
|
156
180
|
await this._open();
|
|
@@ -160,6 +184,7 @@ export class DataSpace {
|
|
|
160
184
|
await this._gossip.open();
|
|
161
185
|
await this._notarizationPlugin.open();
|
|
162
186
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
187
|
+
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
163
188
|
await this._inner.open(new Context());
|
|
164
189
|
this._state = SpaceState.CONTROL_ONLY;
|
|
165
190
|
log('new state', { state: SpaceState[this._state] });
|
|
@@ -183,6 +208,7 @@ export class DataSpace {
|
|
|
183
208
|
await this.authVerifier.close();
|
|
184
209
|
|
|
185
210
|
await this._inner.close();
|
|
211
|
+
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
186
212
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
187
213
|
await this._notarizationPlugin.close();
|
|
188
214
|
|
|
@@ -350,8 +376,29 @@ export class DataSpace {
|
|
|
350
376
|
await this.inner.controlPipeline.writer.write({ credential: { credential } });
|
|
351
377
|
}
|
|
352
378
|
|
|
353
|
-
async createEpoch() {
|
|
354
|
-
|
|
379
|
+
async createEpoch(options?: CreateEpochOptions) {
|
|
380
|
+
let epoch: Epoch | undefined;
|
|
381
|
+
switch (options?.migration) {
|
|
382
|
+
case undefined:
|
|
383
|
+
case CreateEpochRequest.Migration.NONE:
|
|
384
|
+
{
|
|
385
|
+
epoch = await this.dataPipeline.createEpoch();
|
|
386
|
+
}
|
|
387
|
+
break;
|
|
388
|
+
case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
389
|
+
const document = this._automergeHost?.repo.create();
|
|
390
|
+
epoch = {
|
|
391
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
392
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
393
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe(),
|
|
394
|
+
automergeRoot: document?.url,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (!epoch) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
355
402
|
|
|
356
403
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
357
404
|
credential: {
|
|
@@ -11,7 +11,12 @@ import { Timeframe } from '@dxos/timeframe';
|
|
|
11
11
|
|
|
12
12
|
import { type SigningContext } from './data-space-manager';
|
|
13
13
|
|
|
14
|
-
export const spaceGenesis = async (
|
|
14
|
+
export const spaceGenesis = async (
|
|
15
|
+
keyring: Keyring,
|
|
16
|
+
signingContext: SigningContext,
|
|
17
|
+
space: Space,
|
|
18
|
+
automergeRoot?: string,
|
|
19
|
+
) => {
|
|
15
20
|
// TODO(dmaretskyi): Find a way to reconcile with credential generator.
|
|
16
21
|
const credentials = [
|
|
17
22
|
await createCredential({
|
|
@@ -67,6 +72,7 @@ export const spaceGenesis = async (keyring: Keyring, signingContext: SigningCont
|
|
|
67
72
|
previousId: undefined,
|
|
68
73
|
timeframe: new Timeframe(),
|
|
69
74
|
snapshotCid: undefined,
|
|
75
|
+
automergeRoot,
|
|
70
76
|
},
|
|
71
77
|
}),
|
|
72
78
|
];
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
SpaceManager,
|
|
14
14
|
valueEncoding,
|
|
15
15
|
DataServiceSubscriptions,
|
|
16
|
+
AutomergeHost,
|
|
16
17
|
} from '@dxos/echo-pipeline';
|
|
17
18
|
import { testLocalDatabase } from '@dxos/echo-pipeline/testing';
|
|
18
19
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
@@ -108,6 +109,7 @@ export type TestPeerProps = {
|
|
|
108
109
|
snapshotStore?: SnapshotStore;
|
|
109
110
|
signingContext?: SigningContext;
|
|
110
111
|
blobStore?: BlobStore;
|
|
112
|
+
automergeHost?: AutomergeHost;
|
|
111
113
|
};
|
|
112
114
|
|
|
113
115
|
export class TestPeer {
|
|
@@ -176,6 +178,10 @@ export class TestPeer {
|
|
|
176
178
|
return this._props.signingContext ?? failUndefined();
|
|
177
179
|
}
|
|
178
180
|
|
|
181
|
+
get automergeHost() {
|
|
182
|
+
return (this._props.automergeHost ??= new AutomergeHost(this.storage.createDirectory('automerge')));
|
|
183
|
+
}
|
|
184
|
+
|
|
179
185
|
get dataSpaceManager() {
|
|
180
186
|
return (this._props.dataSpaceManager ??= new DataSpaceManager(
|
|
181
187
|
this.spaceManager,
|
|
@@ -184,6 +190,7 @@ export class TestPeer {
|
|
|
184
190
|
this.keyring,
|
|
185
191
|
this.identity,
|
|
186
192
|
this.feedStore,
|
|
193
|
+
this.automergeHost,
|
|
187
194
|
));
|
|
188
195
|
}
|
|
189
196
|
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DXOS_VERSION = "0.3.9-main.
|
|
1
|
+
export const DXOS_VERSION = "0.3.9-main.f8fc6b9";
|