@dxos/client-services 0.5.9-main.bfee100 → 0.5.9-main.d63ef8d
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-TZL7PJDX.mjs → chunk-C2VXW65X.mjs} +691 -536
- package/dist/lib/browser/chunk-C2VXW65X.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -3
- package/dist/lib/browser/index.mjs.map +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-STUWVNPH.cjs → chunk-OD7BTUYY.cjs} +842 -690
- package/dist/lib/node/chunk-OD7BTUYY.cjs.map +7 -0
- package/dist/lib/node/index.cjs +41 -43
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +8 -8
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +4 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +9 -9
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +23 -0
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -36
- package/src/packlets/identity/identity-service.ts +33 -7
- package/src/packlets/spaces/automerge-space-state.ts +11 -2
- package/src/packlets/spaces/data-space-manager.ts +34 -13
- package/src/packlets/spaces/data-space.ts +73 -145
- package/src/packlets/spaces/epoch-migrations.ts +135 -0
- package/src/packlets/spaces/spaces-service.ts +4 -2
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-TZL7PJDX.mjs.map +0 -7
- package/dist/lib/node/chunk-STUWVNPH.cjs.map +0 -7
|
@@ -30,7 +30,7 @@ __export(testing_exports, {
|
|
|
30
30
|
sanitizeInvitation: () => sanitizeInvitation
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(testing_exports);
|
|
33
|
-
var
|
|
33
|
+
var import_chunk_OD7BTUYY = require("../../chunk-OD7BTUYY.cjs");
|
|
34
34
|
var import_credentials = require("@dxos/credentials");
|
|
35
35
|
var import_keys = require("@dxos/keys");
|
|
36
36
|
var import_async = require("@dxos/async");
|
|
@@ -227,7 +227,7 @@ var createInvitation = async (host, options) => {
|
|
|
227
227
|
authMethod: import_services.Invitation.AuthMethod.NONE,
|
|
228
228
|
...options ?? {}
|
|
229
229
|
};
|
|
230
|
-
if (host instanceof
|
|
230
|
+
if (host instanceof import_chunk_OD7BTUYY.ServiceContext) {
|
|
231
231
|
return host.invitationsManager.createInvitation({
|
|
232
232
|
kind: import_services.Invitation.Kind.SPACE,
|
|
233
233
|
...options
|
|
@@ -237,7 +237,7 @@ var createInvitation = async (host, options) => {
|
|
|
237
237
|
};
|
|
238
238
|
var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
|
|
239
239
|
invitation = sanitizeInvitation(invitation);
|
|
240
|
-
if (guest instanceof
|
|
240
|
+
if (guest instanceof import_chunk_OD7BTUYY.ServiceContext) {
|
|
241
241
|
return guest.invitationsManager.acceptInvitation({
|
|
242
242
|
invitation,
|
|
243
243
|
deviceProfile: guestDeviceProfile
|
|
@@ -246,7 +246,7 @@ var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
|
|
|
246
246
|
return guest.join(invitation, guestDeviceProfile);
|
|
247
247
|
};
|
|
248
248
|
var createServiceHost = (config, signalManagerContext) => {
|
|
249
|
-
return new
|
|
249
|
+
return new import_chunk_OD7BTUYY.ClientServicesHost({
|
|
250
250
|
config,
|
|
251
251
|
signalManager: new import_messaging.MemorySignalManager(signalManagerContext),
|
|
252
252
|
transportFactory: import_network_manager.MemoryTransportFactory
|
|
@@ -262,7 +262,7 @@ var createServiceContext = async ({ signalContext = new import_messaging.MemoryS
|
|
|
262
262
|
});
|
|
263
263
|
const level = (0, import_testing.createTestLevel)();
|
|
264
264
|
await level.open();
|
|
265
|
-
return new
|
|
265
|
+
return new import_chunk_OD7BTUYY.ServiceContext(storage, level, networkManager, signalManager, {
|
|
266
266
|
invitationConnectionDefaultParams: {
|
|
267
267
|
controlHeartbeatInterval: 200
|
|
268
268
|
},
|
|
@@ -363,12 +363,12 @@ var TestPeer = class {
|
|
|
363
363
|
});
|
|
364
364
|
}
|
|
365
365
|
get dataSpaceManager() {
|
|
366
|
-
return this._props.dataSpaceManager ??= new
|
|
366
|
+
return this._props.dataSpaceManager ??= new import_chunk_OD7BTUYY.DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, this.identity, this.feedStore, this.echoHost, this.invitationsManager, this._opts.dataSpaceParams);
|
|
367
367
|
}
|
|
368
368
|
get invitationsManager() {
|
|
369
|
-
return this._props.invitationsManager ??= new
|
|
369
|
+
return this._props.invitationsManager ??= new import_chunk_OD7BTUYY.InvitationsManager(new import_chunk_OD7BTUYY.InvitationsHandler(this.networkManager), (invitation) => {
|
|
370
370
|
if (invitation.kind === import_services2.Invitation.Kind.SPACE) {
|
|
371
|
-
return new
|
|
371
|
+
return new import_chunk_OD7BTUYY.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
|
|
372
372
|
} else {
|
|
373
373
|
throw new Error("not implemented");
|
|
374
374
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-service.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/identity/identity-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"identity-service.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/identity/identity-service.ts"],"names":[],"mappings":"AAKA,OAAO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C,aAAa,CAAC;IAI9E,aAAa,IAAI,MAAM,CAAC,qBAAqB,CAAC;IAS9C,OAAO,CAAC,YAAY;IAYd,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAO/D,gBAAgB,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,uBAAuB,GAAG,OAAO,CAAC,YAAY,CAAC;YAYjF,+BAA+B;CAuC9C"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Event } from '@dxos/async';
|
|
2
|
+
import { Resource, type Context } from '@dxos/context';
|
|
2
3
|
import { type CredentialProcessor, type SpecificCredential } from '@dxos/credentials';
|
|
3
4
|
import { type Credential, type Epoch } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
4
|
-
export declare class AutomergeSpaceState implements CredentialProcessor {
|
|
5
|
+
export declare class AutomergeSpaceState extends Resource implements CredentialProcessor {
|
|
5
6
|
private readonly _onNewRoot;
|
|
6
7
|
rootUrl: string | undefined;
|
|
7
8
|
lastEpoch: SpecificCredential<Epoch> | undefined;
|
|
8
9
|
readonly onNewEpoch: Event<SpecificCredential<Epoch>>;
|
|
9
10
|
private _isProcessingRootDocs;
|
|
10
11
|
constructor(_onNewRoot: (rootUrl: string) => void);
|
|
12
|
+
protected _open(ctx: Context): Promise<void>;
|
|
13
|
+
protected _close(ctx: Context): Promise<void>;
|
|
11
14
|
processCredential(credential: Credential): Promise<void>;
|
|
12
15
|
startProcessingRootDocs(): void;
|
|
13
16
|
ensureEpochInitialized(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automerge-space-state.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/automerge-space-state.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAuB,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,KAAK,EAAE,MAAM,6CAA6C,CAAC;AAE1F,qBAAa,mBAAoB,YAAW,mBAAmB;
|
|
1
|
+
{"version":3,"file":"automerge-space-state.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/automerge-space-state.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAuB,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,KAAK,EAAE,MAAM,6CAA6C,CAAC;AAE1F,qBAAa,mBAAoB,SAAQ,QAAS,YAAW,mBAAmB;IAQlE,OAAO,CAAC,QAAQ,CAAC,UAAU;IAPhC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAa;IACxC,SAAS,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG,SAAS,CAAa;IAEpE,SAAgB,UAAU,mCAA0C;IAEpE,OAAO,CAAC,qBAAqB,CAAS;gBAET,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI;cAIzC,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;cAElC,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,iBAAiB,CAAC,UAAU,EAAE,UAAU;IAiB9C,uBAAuB;IAWjB,sBAAsB;CAG7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-space-manager.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/data-space-manager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAA4B,MAAM,aAAa,CAAC;AAK9D,OAAO,
|
|
1
|
+
{"version":3,"file":"data-space-manager.d.ts","sourceRoot":"","sources":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eAAe;IAgG7B,OAAO,CAAC,wBAAwB;IAyBhC,OAAO,CAAC,uBAAuB;YAWjB,6BAA6B;YAiB7B,2BAA2B;CAqB1C"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Event } from '@dxos/async';
|
|
2
|
-
import {
|
|
2
|
+
import type { SpecificCredential } from '@dxos/credentials';
|
|
3
|
+
import { type EchoHost, type DatabaseRoot } from '@dxos/echo-db';
|
|
3
4
|
import { type MetadataStore, type Space } from '@dxos/echo-pipeline';
|
|
4
|
-
import { type ObjectStructure, type SpaceDoc } from '@dxos/echo-protocol';
|
|
5
5
|
import { type FeedStore } from '@dxos/feed-store';
|
|
6
6
|
import { type Keyring } from '@dxos/keyring';
|
|
7
7
|
import { PublicKey } from '@dxos/keys';
|
|
8
|
-
import { CreateEpochRequest, SpaceState, type Space as SpaceProto } from '@dxos/protocols/proto/dxos/client/services';
|
|
8
|
+
import { type CreateEpochRequest, SpaceState, type Space as SpaceProto } from '@dxos/protocols/proto/dxos/client/services';
|
|
9
9
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
10
10
|
import { type SpaceCache } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
11
|
-
import { type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
11
|
+
import { type Epoch, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
12
12
|
import { type GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gossip';
|
|
13
13
|
import { type Gossip, type Presence } from '@dxos/teleport-extension-gossip';
|
|
14
14
|
import { AutomergeSpaceState } from './automerge-space-state';
|
|
@@ -60,7 +60,9 @@ export declare class DataSpace {
|
|
|
60
60
|
private readonly _cache?;
|
|
61
61
|
private readonly _echoHost;
|
|
62
62
|
private readonly _automergeSpaceState;
|
|
63
|
+
private readonly _epochProcessingMutex;
|
|
63
64
|
private _state;
|
|
65
|
+
private _databaseRoot;
|
|
64
66
|
/**
|
|
65
67
|
* Error for _state === SpaceState.ERROR.
|
|
66
68
|
*/
|
|
@@ -78,6 +80,7 @@ export declare class DataSpace {
|
|
|
78
80
|
get notarizationPlugin(): NotarizationPlugin;
|
|
79
81
|
get cache(): SpaceCache | undefined;
|
|
80
82
|
get automergeSpaceState(): AutomergeSpaceState;
|
|
83
|
+
get databaseRoot(): DatabaseRoot | null;
|
|
81
84
|
private get _automergeInfo();
|
|
82
85
|
open(): Promise<void>;
|
|
83
86
|
private _open;
|
|
@@ -92,16 +95,13 @@ export declare class DataSpace {
|
|
|
92
95
|
*/
|
|
93
96
|
initializeDataPipelineAsync(): void;
|
|
94
97
|
initializeDataPipeline(): Promise<void>;
|
|
98
|
+
private _enterReadyState;
|
|
95
99
|
private _initializeAndReadControlPipeline;
|
|
96
100
|
private _createWritableFeeds;
|
|
97
101
|
private _onNewAutomergeRoot;
|
|
98
102
|
updateOwnProfile(profile: ProfileDocument): Promise<void>;
|
|
99
|
-
createEpoch(options?: CreateEpochOptions): Promise<
|
|
103
|
+
createEpoch(options?: CreateEpochOptions): Promise<SpecificCredential<Epoch> | null>;
|
|
100
104
|
activate(): Promise<void>;
|
|
101
105
|
deactivate(): Promise<void>;
|
|
102
106
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Assumes properties are at root.
|
|
105
|
-
*/
|
|
106
|
-
export declare const findPropertiesObject: (spaceDoc: SpaceDoc) => [string, ObjectStructure] | undefined;
|
|
107
107
|
//# sourceMappingURL=data-space.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-space.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/data-space.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"data-space.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/data-space.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAwD,MAAM,aAAa,CAAC;AAG1F,OAAO,KAAK,EAAE,kBAAkB,EAA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C,OAAO,CAAC,aAAa,CAA6B;IAElD;;OAEG;IACI,KAAK,EAAE,KAAK,GAAG,SAAS,CAAa;IAE5C,SAAgB,YAAY,EAAE,yBAAyB,CAAC;IACxD,SAAgB,WAAW,cAAe;IAEnC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAM;gBAE5B,MAAM,EAAE,eAAe;IA+BnC,IACI,EAAE,iCAEL;IAED,IACI,GAAG,cAEN;IAED,IAAI,MAAM,YAET;IAED,IACI,KAAK,IAAI,UAAU,CAEtB;IAGD,IAAI,KAAK,UAER;IAED,IAAI,QAAQ,aAEX;IAED,IAAI,kBAAkB,uBAErB;IAED,IAAI,KAAK,2BAER;IAED,IAAI,mBAAmB,wBAEtB;IAED,IAAI,YAAY,IAAI,YAAY,GAAG,IAAI,CAEtC;IAGD,OAAO,KAAK,cAAc,GAKzB;IAGK,IAAI;YAMI,KAAK;IAgBb,KAAK;YAIG,MAAM;IAmBd,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG;IAI/C,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI;;;IAIlE;;OAEG;IACH,2BAA2B;IAuBrB,sBAAsB;YAqBd,gBAAgB;YAWhB,iCAAiC;YAyBjC,oBAAoB;IAiDlC,OAAO,CAAC,mBAAmB;IAkDrB,gBAAgB,CAAC,OAAO,EAAE,eAAe;IAWzC,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IA2CpF,QAAQ;IAWR,UAAU;CAajB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Repo } from '@dxos/automerge/automerge-repo';
|
|
2
|
+
import { type Context } from '@dxos/context';
|
|
3
|
+
import type { PublicKey, SpaceId } from '@dxos/keys';
|
|
4
|
+
import { CreateEpochRequest } from '@dxos/protocols/proto/dxos/client/services';
|
|
5
|
+
export type MigrationContext = {
|
|
6
|
+
repo: Repo;
|
|
7
|
+
spaceId: SpaceId;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Remove.
|
|
10
|
+
*/
|
|
11
|
+
spaceKey: PublicKey;
|
|
12
|
+
migration: CreateEpochRequest.Migration;
|
|
13
|
+
currentRoot: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* For set automerge root migration type.
|
|
16
|
+
*/
|
|
17
|
+
newAutomergeRoot?: string;
|
|
18
|
+
};
|
|
19
|
+
export type MigrationResult = {
|
|
20
|
+
newRoot?: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const runEpochMigration: (ctx: Context, context: MigrationContext) => Promise<MigrationResult>;
|
|
23
|
+
//# sourceMappingURL=epoch-migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"epoch-migrations.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/epoch-migrations.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAgB,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAWhE,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAGhF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,EAAE,kBAAkB,CAAC,SAAS,CAAC;IACxC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAe,OAAO,WAAW,gBAAgB,KAAG,QAAQ,eAAe,CA2FxG,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Stream } from '@dxos/codec-protobuf';
|
|
2
2
|
import { type SpaceManager } from '@dxos/echo-pipeline';
|
|
3
|
-
import { type CreateEpochRequest, type PostMessageRequest, type QueryCredentialsRequest, type QuerySpacesResponse, type Space, type SpacesService, type SubscribeMessagesRequest, type UpdateSpaceRequest, type WriteCredentialsRequest, type UpdateMemberRoleRequest } from '@dxos/protocols/proto/dxos/client/services';
|
|
3
|
+
import { type CreateEpochRequest, type PostMessageRequest, type QueryCredentialsRequest, type QuerySpacesResponse, type Space, type SpacesService, type SubscribeMessagesRequest, type UpdateSpaceRequest, type WriteCredentialsRequest, type UpdateMemberRoleRequest, type CreateEpochResponse } from '@dxos/protocols/proto/dxos/client/services';
|
|
4
4
|
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
5
5
|
import { type GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gossip';
|
|
6
6
|
import { type Provider } from '@dxos/util';
|
|
@@ -19,7 +19,7 @@ export declare class SpacesServiceImpl implements SpacesService {
|
|
|
19
19
|
subscribeMessages({ spaceKey, channel }: SubscribeMessagesRequest): Stream<GossipMessage>;
|
|
20
20
|
queryCredentials({ spaceKey, noTail }: QueryCredentialsRequest): Stream<Credential>;
|
|
21
21
|
writeCredentials({ spaceKey, credentials }: WriteCredentialsRequest): Promise<void>;
|
|
22
|
-
createEpoch({ spaceKey, migration, automergeRootUrl }: CreateEpochRequest): Promise<
|
|
22
|
+
createEpoch({ spaceKey, migration, automergeRootUrl }: CreateEpochRequest): Promise<CreateEpochResponse>;
|
|
23
23
|
private _serializeSpace;
|
|
24
24
|
private _requireIdentity;
|
|
25
25
|
private _updateMetrics;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spaces-service.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/spaces-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAWxD,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,
|
|
1
|
+
{"version":3,"file":"spaces-service.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/spaces-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAWxD,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACzB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAErF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,qBAAa,iBAAkB,YAAW,aAAa;IAEnD,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,oBAAoB;gBAFpB,gBAAgB,EAAE,eAAe,EACjC,aAAa,EAAE,YAAY,EAC3B,oBAAoB,EAAE,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAGtE,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC;IAQ7B,WAAW,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,kBAAkB;IAmBnD,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BvE,WAAW,IAAI,MAAM,CAAC,mBAAmB,CAAC;IAmDpC,WAAW,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,kBAAkB;IAMpE,iBAAiB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,wBAAwB;IAajE,gBAAgB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC;IAmB7E,gBAAgB,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,uBAAuB;IAmBnE,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO9G,OAAO,CAAC,eAAe;IA6CvB,OAAO,CAAC,gBAAgB;YASV,cAAc;CAS7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const DXOS_VERSION = "0.5.9-main.
|
|
1
|
+
export declare const DXOS_VERSION = "0.5.9-main.d63ef8d";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/client-services",
|
|
3
|
-
"version": "0.5.9-main.
|
|
3
|
+
"version": "0.5.9-main.d63ef8d",
|
|
4
4
|
"description": "DXOS client services implementation",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -23,45 +23,45 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"platform": "^1.3.6",
|
|
26
|
-
"@dxos/async": "0.5.9-main.
|
|
27
|
-
"@dxos/
|
|
28
|
-
"@dxos/client-protocol": "0.5.9-main.
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/config": "0.5.9-main.
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/crypto": "0.5.9-main.
|
|
34
|
-
"@dxos/debug": "0.5.9-main.
|
|
35
|
-
"@dxos/echo-db": "0.5.9-main.
|
|
36
|
-
"@dxos/echo-pipeline": "0.5.9-main.
|
|
37
|
-
"@dxos/echo-protocol": "0.5.9-main.
|
|
38
|
-
"@dxos/echo-schema": "0.5.9-main.
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/node-std": "0.5.9-main.
|
|
50
|
-
"@dxos/protocols": "0.5.9-main.
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/teleport": "0.5.9-main.
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/tracing": "0.5.9-main.
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/util": "0.5.9-main.
|
|
59
|
-
"@dxos/websocket-rpc": "0.5.9-main.
|
|
26
|
+
"@dxos/async": "0.5.9-main.d63ef8d",
|
|
27
|
+
"@dxos/automerge": "0.5.9-main.d63ef8d",
|
|
28
|
+
"@dxos/client-protocol": "0.5.9-main.d63ef8d",
|
|
29
|
+
"@dxos/codec-protobuf": "0.5.9-main.d63ef8d",
|
|
30
|
+
"@dxos/config": "0.5.9-main.d63ef8d",
|
|
31
|
+
"@dxos/context": "0.5.9-main.d63ef8d",
|
|
32
|
+
"@dxos/credentials": "0.5.9-main.d63ef8d",
|
|
33
|
+
"@dxos/crypto": "0.5.9-main.d63ef8d",
|
|
34
|
+
"@dxos/debug": "0.5.9-main.d63ef8d",
|
|
35
|
+
"@dxos/echo-db": "0.5.9-main.d63ef8d",
|
|
36
|
+
"@dxos/echo-pipeline": "0.5.9-main.d63ef8d",
|
|
37
|
+
"@dxos/echo-protocol": "0.5.9-main.d63ef8d",
|
|
38
|
+
"@dxos/echo-schema": "0.5.9-main.d63ef8d",
|
|
39
|
+
"@dxos/invariant": "0.5.9-main.d63ef8d",
|
|
40
|
+
"@dxos/feed-store": "0.5.9-main.d63ef8d",
|
|
41
|
+
"@dxos/indexing": "0.5.9-main.d63ef8d",
|
|
42
|
+
"@dxos/keyring": "0.5.9-main.d63ef8d",
|
|
43
|
+
"@dxos/keys": "0.5.9-main.d63ef8d",
|
|
44
|
+
"@dxos/kv-store": "0.5.9-main.d63ef8d",
|
|
45
|
+
"@dxos/lock-file": "0.5.9-main.d63ef8d",
|
|
46
|
+
"@dxos/log": "0.5.9-main.d63ef8d",
|
|
47
|
+
"@dxos/network-manager": "0.5.9-main.d63ef8d",
|
|
48
|
+
"@dxos/messaging": "0.5.9-main.d63ef8d",
|
|
49
|
+
"@dxos/node-std": "0.5.9-main.d63ef8d",
|
|
50
|
+
"@dxos/protocols": "0.5.9-main.d63ef8d",
|
|
51
|
+
"@dxos/random-access-storage": "0.5.9-main.d63ef8d",
|
|
52
|
+
"@dxos/rpc": "0.5.9-main.d63ef8d",
|
|
53
|
+
"@dxos/teleport": "0.5.9-main.d63ef8d",
|
|
54
|
+
"@dxos/teleport-extension-object-sync": "0.5.9-main.d63ef8d",
|
|
55
|
+
"@dxos/teleport-extension-gossip": "0.5.9-main.d63ef8d",
|
|
56
|
+
"@dxos/tracing": "0.5.9-main.d63ef8d",
|
|
57
|
+
"@dxos/timeframe": "0.5.9-main.d63ef8d",
|
|
58
|
+
"@dxos/util": "0.5.9-main.d63ef8d",
|
|
59
|
+
"@dxos/websocket-rpc": "0.5.9-main.d63ef8d"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/platform": "^1.3.4",
|
|
63
63
|
"@types/readable-stream": "^2.3.9",
|
|
64
|
-
"@dxos/signal": "0.5.9-main.
|
|
64
|
+
"@dxos/signal": "0.5.9-main.d63ef8d"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Trigger, sleep } from '@dxos/async';
|
|
5
6
|
import { Stream } from '@dxos/codec-protobuf';
|
|
6
7
|
import { Resource } from '@dxos/context';
|
|
7
8
|
import { signPresentation } from '@dxos/credentials';
|
|
8
9
|
import { todo } from '@dxos/debug';
|
|
9
10
|
import { invariant } from '@dxos/invariant';
|
|
10
11
|
import { type Keyring } from '@dxos/keyring';
|
|
12
|
+
import { log } from '@dxos/log';
|
|
11
13
|
import {
|
|
12
14
|
type CreateIdentityRequest,
|
|
13
15
|
type Identity as IdentityProto,
|
|
@@ -18,11 +20,14 @@ import {
|
|
|
18
20
|
SpaceState,
|
|
19
21
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
20
22
|
import { type Presentation, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
23
|
+
import { safeAwaitAll } from '@dxos/util';
|
|
21
24
|
|
|
22
25
|
import { type Identity } from './identity';
|
|
23
26
|
import { type CreateIdentityOptions, type IdentityManager } from './identity-manager';
|
|
24
27
|
import { type DataSpaceManager } from '../spaces';
|
|
25
28
|
|
|
29
|
+
const DEFAULT_SPACE_SEARCH_TIMEOUT = 10_000;
|
|
30
|
+
|
|
26
31
|
export class IdentityServiceImpl extends Resource implements IdentityService {
|
|
27
32
|
constructor(
|
|
28
33
|
private readonly _identityManager: IdentityManager,
|
|
@@ -100,20 +105,41 @@ export class IdentityServiceImpl extends Resource implements IdentityService {
|
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
private async _fixIdentityWithoutDefaultSpace(identity: Identity) {
|
|
103
|
-
let
|
|
108
|
+
let recodedDefaultSpace = false;
|
|
109
|
+
let foundDefaultSpace = false;
|
|
104
110
|
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
105
|
-
|
|
111
|
+
|
|
112
|
+
const recordedDefaultSpaceTrigger = new Trigger();
|
|
113
|
+
|
|
114
|
+
const allProcessed = safeAwaitAll(dataSpaceManager.spaces.values(), async (space) => {
|
|
106
115
|
if (space.state === SpaceState.CLOSED) {
|
|
107
116
|
await space.open();
|
|
108
|
-
|
|
117
|
+
|
|
118
|
+
// Wait until the space is either READY or REQUIRES_MIGRATION.
|
|
119
|
+
// NOTE: Space could potentially never initialize if the space data is corrupted.
|
|
120
|
+
const requiresMigration = space.stateUpdate.waitForCondition(
|
|
121
|
+
() => space.state === SpaceState.REQUIRES_MIGRATION,
|
|
122
|
+
);
|
|
123
|
+
await Promise.race([space.initializeDataPipeline(), requiresMigration]);
|
|
109
124
|
}
|
|
110
125
|
if (await dataSpaceManager.isDefaultSpace(space)) {
|
|
126
|
+
if (foundDefaultSpace) {
|
|
127
|
+
log.warn('Multiple default spaces found. Using the first one.', { duplicate: space.id });
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
foundDefaultSpace = true;
|
|
111
132
|
await identity.updateDefaultSpace(space.id);
|
|
112
|
-
|
|
113
|
-
|
|
133
|
+
recodedDefaultSpace = true;
|
|
134
|
+
recordedDefaultSpaceTrigger.wake();
|
|
114
135
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Wait for all spaces to be processed or until the default space is recorded.
|
|
139
|
+
// If the timeout is reached, create a new default space.
|
|
140
|
+
await Promise.race([allProcessed, recordedDefaultSpaceTrigger.wait(), sleep(DEFAULT_SPACE_SEARCH_TIMEOUT)]);
|
|
141
|
+
|
|
142
|
+
if (!recodedDefaultSpace) {
|
|
117
143
|
await this._createDefaultSpace(dataSpaceManager);
|
|
118
144
|
}
|
|
119
145
|
}
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Event } from '@dxos/async';
|
|
6
|
+
import { Resource, type Context } from '@dxos/context';
|
|
6
7
|
import { type CredentialProcessor, type SpecificCredential, checkCredentialType } from '@dxos/credentials';
|
|
7
8
|
import { type Credential, type Epoch } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
8
9
|
|
|
9
|
-
export class AutomergeSpaceState implements CredentialProcessor {
|
|
10
|
+
export class AutomergeSpaceState extends Resource implements CredentialProcessor {
|
|
10
11
|
public rootUrl: string | undefined = undefined;
|
|
11
12
|
public lastEpoch: SpecificCredential<Epoch> | undefined = undefined;
|
|
12
13
|
|
|
@@ -14,7 +15,15 @@ export class AutomergeSpaceState implements CredentialProcessor {
|
|
|
14
15
|
|
|
15
16
|
private _isProcessingRootDocs = false;
|
|
16
17
|
|
|
17
|
-
constructor(private readonly _onNewRoot: (rootUrl: string) => void) {
|
|
18
|
+
constructor(private readonly _onNewRoot: (rootUrl: string) => void) {
|
|
19
|
+
super();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
protected override async _open(ctx: Context): Promise<void> {}
|
|
23
|
+
|
|
24
|
+
protected override async _close(ctx: Context): Promise<void> {
|
|
25
|
+
this._isProcessingRootDocs = false;
|
|
26
|
+
}
|
|
18
27
|
|
|
19
28
|
async processCredential(credential: Credential) {
|
|
20
29
|
if (!checkCredentialType(credential, 'dxos.halo.credentials.Epoch')) {
|
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
import { Event, synchronized, trackLeaks } from '@dxos/async';
|
|
6
6
|
import { type Doc } from '@dxos/automerge/automerge';
|
|
7
|
-
import { type
|
|
7
|
+
import { type AutomergeUrl, type DocHandle } from '@dxos/automerge/automerge-repo';
|
|
8
8
|
import { PropertiesType } from '@dxos/client-protocol';
|
|
9
|
-
import {
|
|
9
|
+
import { Context, cancelWithContext } from '@dxos/context';
|
|
10
10
|
import {
|
|
11
|
+
getCredentialAssertion,
|
|
11
12
|
type CredentialSigner,
|
|
12
13
|
type DelegateInvitationCredential,
|
|
13
|
-
getCredentialAssertion,
|
|
14
14
|
type MemberInfo,
|
|
15
15
|
} from '@dxos/credentials';
|
|
16
|
-
import { type EchoHost } from '@dxos/echo-db';
|
|
16
|
+
import { convertLegacyReferences, findInlineObjectOfType, type EchoHost } from '@dxos/echo-db';
|
|
17
17
|
import {
|
|
18
18
|
AuthStatus,
|
|
19
19
|
type MetadataStore,
|
|
@@ -22,8 +22,14 @@ import {
|
|
|
22
22
|
type SpaceProtocol,
|
|
23
23
|
type SpaceProtocolSession,
|
|
24
24
|
} from '@dxos/echo-pipeline';
|
|
25
|
-
import {
|
|
26
|
-
|
|
25
|
+
import {
|
|
26
|
+
LEGACY_TYPE_PROPERTIES,
|
|
27
|
+
SpaceDocVersion,
|
|
28
|
+
encodeReference,
|
|
29
|
+
type ObjectStructure,
|
|
30
|
+
type SpaceDoc,
|
|
31
|
+
} from '@dxos/echo-protocol';
|
|
32
|
+
import { TYPE_PROPERTIES, generateEchoId, getTypeReference } from '@dxos/echo-schema';
|
|
27
33
|
import { type FeedStore } from '@dxos/feed-store';
|
|
28
34
|
import { invariant } from '@dxos/invariant';
|
|
29
35
|
import { type Keyring } from '@dxos/keyring';
|
|
@@ -33,15 +39,15 @@ import { trace as Trace } from '@dxos/protocols';
|
|
|
33
39
|
import { Invitation, SpaceState } from '@dxos/protocols/proto/dxos/client/services';
|
|
34
40
|
import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
35
41
|
import { type SpaceMetadata } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
36
|
-
import { type Credential, type ProfileDocument
|
|
42
|
+
import { SpaceMember, type Credential, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
37
43
|
import { type DelegateSpaceInvitation } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
38
44
|
import { type PeerState } from '@dxos/protocols/proto/dxos/mesh/presence';
|
|
39
45
|
import { Gossip, Presence } from '@dxos/teleport-extension-gossip';
|
|
40
46
|
import { type Timeframe } from '@dxos/timeframe';
|
|
41
47
|
import { trace } from '@dxos/tracing';
|
|
42
|
-
import {
|
|
48
|
+
import { ComplexMap, assignDeep, deferFunction, forEachAsync } from '@dxos/util';
|
|
43
49
|
|
|
44
|
-
import { DataSpace
|
|
50
|
+
import { DataSpace } from './data-space';
|
|
45
51
|
import { spaceGenesis } from './genesis';
|
|
46
52
|
import { createAuthProvider } from '../identity';
|
|
47
53
|
import { type InvitationsManager } from '../invitations';
|
|
@@ -113,7 +119,7 @@ export class DataSpaceManager {
|
|
|
113
119
|
const rootHandle = rootUrl ? this._echoHost.automergeRepo.find(rootUrl as AutomergeUrl) : undefined;
|
|
114
120
|
const rootDoc = rootHandle?.docSync() as Doc<SpaceDoc> | undefined;
|
|
115
121
|
|
|
116
|
-
const properties = rootDoc &&
|
|
122
|
+
const properties = rootDoc && findInlineObjectOfType(rootDoc, TYPE_PROPERTIES);
|
|
117
123
|
|
|
118
124
|
return {
|
|
119
125
|
key: space.key.toHex(),
|
|
@@ -204,9 +210,24 @@ export class DataSpaceManager {
|
|
|
204
210
|
}
|
|
205
211
|
|
|
206
212
|
async isDefaultSpace(space: DataSpace): Promise<boolean> {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
213
|
+
if (!space.databaseRoot) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
switch (space.databaseRoot.getVersion()) {
|
|
217
|
+
case SpaceDocVersion.CURRENT: {
|
|
218
|
+
const [_, properties] = findInlineObjectOfType(space.databaseRoot.docSync()!, TYPE_PROPERTIES) ?? [];
|
|
219
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
220
|
+
}
|
|
221
|
+
case SpaceDocVersion.LEGACY: {
|
|
222
|
+
const convertedDoc = await convertLegacyReferences(space.databaseRoot.docSync()!);
|
|
223
|
+
const [_, properties] = findInlineObjectOfType(convertedDoc, LEGACY_TYPE_PROPERTIES) ?? [];
|
|
224
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
default:
|
|
228
|
+
log.warn('unknown space version', { version: space.databaseRoot.getVersion(), spaceId: space.id });
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
210
231
|
}
|
|
211
232
|
|
|
212
233
|
async createDefaultSpace() {
|