@dxos/client-services 0.3.9-main.a33ec16 → 0.3.9-main.a9b2756
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-ONFEUZUN.mjs → chunk-E2U322GY.mjs} +19 -15
- package/dist/lib/browser/{chunk-ONFEUZUN.mjs.map → chunk-E2U322GY.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +6 -3
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-K4OJVXAV.cjs → chunk-YBTVHNJA.cjs} +22 -18
- package/dist/lib/node/{chunk-K4OJVXAV.cjs.map → chunk-YBTVHNJA.cjs.map} +3 -3
- 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/spaces/data-space-manager.d.ts +2 -2
- package/dist/types/src/packlets/spaces/data-space-manager.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-host.ts +1 -1
- package/src/packlets/spaces/data-space-manager.ts +4 -4
- package/src/packlets/spaces/genesis.ts +7 -1
- package/src/packlets/testing/test-builder.ts +7 -0
- package/src/version.ts +1 -1
|
@@ -31,7 +31,7 @@ __export(testing_exports, {
|
|
|
31
31
|
syncItemsLocal: () => syncItemsLocal
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(testing_exports);
|
|
34
|
-
var
|
|
34
|
+
var import_chunk_YBTVHNJA = require("../../chunk-YBTVHNJA.cjs");
|
|
35
35
|
var import_credentials = require("@dxos/credentials");
|
|
36
36
|
var import_keys = require("@dxos/keys");
|
|
37
37
|
var import_async = require("@dxos/async");
|
|
@@ -216,7 +216,7 @@ var createInvitation = (host, options) => {
|
|
|
216
216
|
authMethod: import_services.Invitation.AuthMethod.NONE,
|
|
217
217
|
...options ?? {}
|
|
218
218
|
};
|
|
219
|
-
if (host instanceof
|
|
219
|
+
if (host instanceof import_chunk_YBTVHNJA.ServiceContext) {
|
|
220
220
|
const hostHandler = host.getInvitationHandler({
|
|
221
221
|
kind: import_services.Invitation.Kind.SPACE,
|
|
222
222
|
...options
|
|
@@ -227,7 +227,7 @@ var createInvitation = (host, options) => {
|
|
|
227
227
|
};
|
|
228
228
|
var acceptInvitation = (guest, invitation) => {
|
|
229
229
|
invitation = sanitizeInvitation(invitation);
|
|
230
|
-
if (guest instanceof
|
|
230
|
+
if (guest instanceof import_chunk_YBTVHNJA.ServiceContext) {
|
|
231
231
|
const guestHandler = guest.getInvitationHandler({
|
|
232
232
|
kind: invitation.kind
|
|
233
233
|
});
|
|
@@ -236,7 +236,7 @@ var acceptInvitation = (guest, invitation) => {
|
|
|
236
236
|
return guest.join(invitation);
|
|
237
237
|
};
|
|
238
238
|
var createServiceHost = (config, signalManagerContext) => {
|
|
239
|
-
return new
|
|
239
|
+
return new import_chunk_YBTVHNJA.ClientServicesHost({
|
|
240
240
|
config,
|
|
241
241
|
signalManager: new import_messaging.MemorySignalManager(signalManagerContext),
|
|
242
242
|
transportFactory: import_network_manager.MemoryTransportFactory
|
|
@@ -250,8 +250,8 @@ var createServiceContext = ({ signalContext = new import_messaging.MemorySignalM
|
|
|
250
250
|
signalManager,
|
|
251
251
|
transportFactory: import_network_manager.MemoryTransportFactory
|
|
252
252
|
});
|
|
253
|
-
const modelFactory = (0,
|
|
254
|
-
return new
|
|
253
|
+
const modelFactory = (0, import_chunk_YBTVHNJA.createDefaultModelFactory)();
|
|
254
|
+
return new import_chunk_YBTVHNJA.ServiceContext(storage, networkManager, signalManager, modelFactory);
|
|
255
255
|
};
|
|
256
256
|
var createPeers = async (numPeers) => {
|
|
257
257
|
const signalContext = new import_messaging.MemorySignalManagerContext();
|
|
@@ -335,7 +335,7 @@ var TestPeer = class {
|
|
|
335
335
|
feedStore: this.feedStore,
|
|
336
336
|
networkManager: this.networkManager,
|
|
337
337
|
metadataStore: this.metadataStore,
|
|
338
|
-
modelFactory: (0,
|
|
338
|
+
modelFactory: (0, import_chunk_YBTVHNJA.createDefaultModelFactory)(),
|
|
339
339
|
snapshotStore: this.snapshotStore,
|
|
340
340
|
blobStore: this.blobStore
|
|
341
341
|
});
|
|
@@ -343,8 +343,11 @@ var TestPeer = class {
|
|
|
343
343
|
get identity() {
|
|
344
344
|
return this._props.signingContext ?? (0, import_debug.failUndefined)();
|
|
345
345
|
}
|
|
346
|
+
get automergeHost() {
|
|
347
|
+
return this._props.automergeHost ??= new import_echo_pipeline.AutomergeHost(this.storage.createDirectory("automerge"));
|
|
348
|
+
}
|
|
346
349
|
get dataSpaceManager() {
|
|
347
|
-
return this._props.dataSpaceManager ??= new
|
|
350
|
+
return this._props.dataSpaceManager ??= new import_chunk_YBTVHNJA.DataSpaceManager(this.spaceManager, this.metadataStore, new import_echo_pipeline.DataServiceSubscriptions(), this.keyring, this.identity, this.feedStore, this.automergeHost);
|
|
348
351
|
}
|
|
349
352
|
async createIdentity() {
|
|
350
353
|
this._props.signingContext ??= await createSigningContext(this.keyring);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/packlets/testing/credential-utils.ts", "../../../../../src/packlets/testing/invitation-utils.ts", "../../../../../src/packlets/testing/test-builder.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { createCredential } from '@dxos/credentials';\nimport { type Signer } from '@dxos/crypto';\nimport { PublicKey } from '@dxos/keys';\nimport { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\n\nexport const createMockCredential = async ({\n signer,\n issuer,\n}: {\n signer: Signer;\n issuer: PublicKey;\n}): Promise<Credential> =>\n createCredential({\n signer,\n issuer,\n subject: new PublicKey(Buffer.from('test')),\n assertion: {\n '@type': 'example.testing.rpc.MessageWithAny',\n payload: {\n '@type': 'google.protobuf.Any',\n value: Buffer.from('test'),\n },\n },\n });\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Trigger } from '@dxos/async';\nimport { type AuthenticatingInvitation, type CancellableInvitation } from '@dxos/client-protocol';\nimport { invariant } from '@dxos/invariant';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\nimport { ServiceContext } from '../services';\n\n/**\n * Strip secrets from invitation before giving it to the peer.\n */\nexport const sanitizeInvitation = (invitation: Invitation): Invitation => {\n return {\n invitationId: invitation.invitationId,\n type: invitation.type,\n kind: invitation.kind,\n authMethod: invitation.authMethod,\n swarmKey: invitation.swarmKey,\n state: invitation.state,\n timeout: invitation.timeout,\n };\n};\n\nexport type InvitationHost = {\n share(options?: Partial<Invitation>): CancellableInvitation;\n};\n\nexport type InvitationGuest = {\n join(invitation: Invitation | string): AuthenticatingInvitation;\n};\n\nexport type PerformInvitationCallbacks<T> = {\n onConnecting?: (value: T) => boolean | void;\n onConnected?: (value: T) => boolean | void;\n onReady?: (value: T) => boolean | void;\n onAuthenticating?: (value: T) => boolean | void;\n onSuccess?: (value: T) => boolean | void;\n onCancelled?: (value: T) => boolean | void;\n onTimeout?: (value: T) => boolean | void;\n onError?: (value: T) => boolean | void;\n};\n\nexport type PerformInvitationParams = {\n host: ServiceContext | InvitationHost;\n guest: ServiceContext | InvitationGuest;\n options?: Partial<Invitation>;\n hooks?: {\n host?: PerformInvitationCallbacks<CancellableInvitation>;\n guest?: PerformInvitationCallbacks<AuthenticatingInvitation>;\n };\n};\n\nexport type Result = { invitation?: Invitation; error?: Error };\n\nexport const performInvitation = ({\n host,\n guest,\n options,\n hooks,\n}: PerformInvitationParams): [Promise<Result>, Promise<Result>] => {\n const hostComplete = new Trigger<Result>();\n const guestComplete = new Trigger<Result>();\n const authCode = new Trigger<string>();\n\n const hostObservable = createInvitation(host, options);\n hostObservable.subscribe(\n async (hostInvitation: Invitation) => {\n switch (hostInvitation.state) {\n case Invitation.State.CONNECTING: {\n if (hooks?.host?.onConnecting?.(hostObservable)) {\n break;\n }\n const guestObservable = acceptInvitation(guest, hostInvitation);\n guestObservable.subscribe(\n async (guestInvitation: Invitation) => {\n switch (guestInvitation.state) {\n case Invitation.State.CONNECTING: {\n if (hooks?.guest?.onConnecting?.(guestObservable)) {\n break;\n }\n invariant(hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!));\n break;\n }\n\n case Invitation.State.CONNECTED: {\n hooks?.guest?.onConnected?.(guestObservable);\n break;\n }\n\n case Invitation.State.READY_FOR_AUTHENTICATION: {\n if (hooks?.guest?.onReady?.(guestObservable)) {\n break;\n }\n await guestObservable.authenticate(await authCode.wait());\n break;\n }\n\n case Invitation.State.AUTHENTICATING: {\n hooks?.guest?.onAuthenticating?.(guestObservable);\n break;\n }\n\n case Invitation.State.SUCCESS: {\n if (hooks?.guest?.onSuccess?.(guestObservable)) {\n break;\n }\n guestComplete.wake({ invitation: guestInvitation });\n break;\n }\n\n case Invitation.State.CANCELLED: {\n if (hooks?.guest?.onCancelled?.(guestObservable)) {\n break;\n }\n guestComplete.wake({ invitation: guestInvitation });\n break;\n }\n\n case Invitation.State.TIMEOUT: {\n if (hooks?.guest?.onTimeout?.(guestObservable)) {\n return;\n }\n guestComplete.wake({ invitation: guestInvitation });\n }\n }\n },\n (error: Error) => {\n if (hooks?.guest?.onError?.(guestObservable)) {\n return;\n }\n guestComplete.wake({ error });\n },\n );\n break;\n }\n\n case Invitation.State.CONNECTED: {\n hooks?.host?.onConnected?.(hostObservable);\n break;\n }\n\n case Invitation.State.READY_FOR_AUTHENTICATION: {\n if (hooks?.host?.onReady?.(hostObservable)) {\n break;\n }\n if (hostInvitation.authCode) {\n authCode.wake(hostInvitation.authCode);\n }\n break;\n }\n\n case Invitation.State.AUTHENTICATING: {\n hooks?.host?.onAuthenticating?.(hostObservable);\n break;\n }\n\n case Invitation.State.SUCCESS: {\n if (hooks?.host?.onSuccess?.(hostObservable)) {\n break;\n }\n hostComplete.wake({ invitation: hostInvitation });\n break;\n }\n\n case Invitation.State.CANCELLED: {\n if (hooks?.host?.onCancelled?.(hostObservable)) {\n break;\n }\n hostComplete.wake({ invitation: hostInvitation });\n break;\n }\n\n case Invitation.State.TIMEOUT: {\n if (hooks?.host?.onTimeout?.(hostObservable)) {\n break;\n }\n hostComplete.wake({ invitation: hostInvitation });\n break;\n }\n }\n },\n (error: Error) => {\n if (hooks?.host?.onError?.(hostObservable)) {\n return;\n }\n hostComplete.wake({ error });\n },\n );\n\n return [hostComplete.wait(), guestComplete.wait()];\n};\n\nconst createInvitation = (\n host: ServiceContext | InvitationHost,\n options?: Partial<Invitation>,\n): CancellableInvitation => {\n options ??= {\n authMethod: Invitation.AuthMethod.NONE,\n ...(options ?? {}),\n };\n\n if (host instanceof ServiceContext) {\n const hostHandler = host.getInvitationHandler({ kind: Invitation.Kind.SPACE, ...options });\n return host.invitations.createInvitation(hostHandler, options);\n }\n\n return host.share(options);\n};\n\nconst acceptInvitation = (\n guest: ServiceContext | InvitationGuest,\n invitation: Invitation,\n): AuthenticatingInvitation => {\n invitation = sanitizeInvitation(invitation);\n\n if (guest instanceof ServiceContext) {\n const guestHandler = guest.getInvitationHandler({ kind: invitation.kind });\n return guest.invitations.acceptInvitation(guestHandler, invitation);\n }\n\n return guest.join(invitation);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Config } from '@dxos/config';\nimport { Context } from '@dxos/context';\nimport { createCredentialSignerWithChain, CredentialGenerator } from '@dxos/credentials';\nimport { failUndefined } from '@dxos/debug';\nimport {\n SnapshotStore,\n type DataPipeline,\n MetadataStore,\n SpaceManager,\n valueEncoding,\n DataServiceSubscriptions,\n} from '@dxos/echo-pipeline';\nimport { testLocalDatabase } from '@dxos/echo-pipeline/testing';\nimport { FeedFactory, FeedStore } from '@dxos/feed-store';\nimport { Keyring } from '@dxos/keyring';\nimport { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';\nimport { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';\nimport { createStorage, type Storage, StorageType } from '@dxos/random-access-storage';\nimport { BlobStore } from '@dxos/teleport-extension-object-sync';\n\nimport { ClientServicesHost, createDefaultModelFactory, ServiceContext } from '../services';\nimport { DataSpaceManager, type SigningContext } from '../spaces';\n\n//\n// TODO(burdon): Replace with test builder.\n//\n\nexport const createServiceHost = (config: Config, signalManagerContext: MemorySignalManagerContext) => {\n return new ClientServicesHost({\n config,\n signalManager: new MemorySignalManager(signalManagerContext),\n transportFactory: MemoryTransportFactory,\n });\n};\n\nexport const createServiceContext = ({\n signalContext = new MemorySignalManagerContext(),\n storage = createStorage({ type: StorageType.RAM }),\n}: {\n signalContext?: MemorySignalManagerContext;\n storage?: Storage;\n} = {}) => {\n const signalManager = new MemorySignalManager(signalContext);\n const networkManager = new NetworkManager({\n signalManager,\n transportFactory: MemoryTransportFactory,\n });\n\n const modelFactory = createDefaultModelFactory();\n return new ServiceContext(storage, networkManager, signalManager, modelFactory);\n};\n\nexport const createPeers = async (numPeers: number) => {\n const signalContext = new MemorySignalManagerContext();\n\n return await Promise.all(\n Array.from(Array(numPeers)).map(async () => {\n const peer = createServiceContext({ signalContext });\n await peer.open(new Context());\n return peer;\n }),\n );\n};\n\nexport const createIdentity = async (peer: ServiceContext) => {\n await peer.createIdentity();\n return peer;\n};\n\n// TODO(burdon): Remove @dxos/client-testing.\n// TODO(burdon): Create builder and make configurable.\nexport const syncItemsLocal = async (db1: DataPipeline, db2: DataPipeline) => {\n await testLocalDatabase(db1, db2);\n await testLocalDatabase(db2, db1);\n};\n\nexport class TestBuilder {\n public readonly signalContext = new MemorySignalManagerContext();\n private readonly _ctx = new Context();\n\n createPeer(peerOptions?: TestPeerOpts): TestPeer {\n const peer = new TestPeer(this.signalContext, peerOptions);\n this._ctx.onDispose(async () => peer.destroy());\n return peer;\n }\n\n async destroy() {\n await this._ctx.dispose();\n }\n}\n\nexport type TestPeerOpts = {\n dataStore?: StorageType;\n};\n\nexport type TestPeerProps = {\n storage?: Storage;\n feedStore?: FeedStore<any>;\n metadataStore?: MetadataStore;\n keyring?: Keyring;\n networkManager?: NetworkManager;\n spaceManager?: SpaceManager;\n dataSpaceManager?: DataSpaceManager;\n snapshotStore?: SnapshotStore;\n signingContext?: SigningContext;\n blobStore?: BlobStore;\n};\n\nexport class TestPeer {\n private _props: TestPeerProps = {};\n\n constructor(\n private readonly signalContext: MemorySignalManagerContext,\n private readonly opts: TestPeerOpts = { dataStore: StorageType.RAM },\n ) {}\n\n get props() {\n return this._props;\n }\n\n get storage() {\n return (this._props.storage ??= createStorage({ type: this.opts.dataStore }));\n }\n\n get keyring() {\n return (this._props.keyring ??= new Keyring(this.storage.createDirectory('keyring')));\n }\n\n get feedStore() {\n return (this._props.feedStore ??= new FeedStore({\n factory: new FeedFactory({\n root: this.storage.createDirectory('feeds'),\n signer: this.keyring,\n hypercore: {\n valueEncoding,\n },\n }),\n }));\n }\n\n get metadataStore() {\n return (this._props.metadataStore ??= new MetadataStore(this.storage.createDirectory('metadata')));\n }\n\n get blobStore() {\n return (this._props.blobStore ??= new BlobStore(this.storage.createDirectory('blobs')));\n }\n\n get snapshotStore() {\n return (this._props.snapshotStore ??= new SnapshotStore(this.storage.createDirectory('snapshots')));\n }\n\n get networkManager() {\n return (this._props.networkManager ??= new NetworkManager({\n signalManager: new MemorySignalManager(this.signalContext),\n transportFactory: MemoryTransportFactory,\n }));\n }\n\n get spaceManager() {\n return (this._props.spaceManager ??= new SpaceManager({\n feedStore: this.feedStore,\n networkManager: this.networkManager,\n metadataStore: this.metadataStore,\n modelFactory: createDefaultModelFactory(),\n snapshotStore: this.snapshotStore,\n blobStore: this.blobStore,\n }));\n }\n\n get identity() {\n return this._props.signingContext ?? failUndefined();\n }\n\n get dataSpaceManager() {\n return (this._props.dataSpaceManager ??= new DataSpaceManager(\n this.spaceManager,\n this.metadataStore,\n new DataServiceSubscriptions(),\n this.keyring,\n this.identity,\n this.feedStore,\n ));\n }\n\n async createIdentity() {\n this._props.signingContext ??= await createSigningContext(this.keyring);\n }\n\n async destroy() {\n await this.storage.reset();\n }\n}\n\nexport const createSigningContext = async (keyring: Keyring): Promise<SigningContext> => {\n const identityKey = await keyring.createKey();\n const deviceKey = await keyring.createKey();\n\n return {\n identityKey,\n deviceKey,\n credentialSigner: createCredentialSignerWithChain(\n keyring,\n {\n credential: await new CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey),\n },\n deviceKey,\n ),\n recordCredential: async () => {}, // No-op.\n getProfile: () => undefined,\n };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAiC;AAEjC,kBAA0B;ACF1B,mBAAwB;AAExB,uBAA0B;AAC1B,sBAA2B;ACF3B,qBAAwB;AACxB,IAAAA,sBAAqE;AACrE,mBAA8B;AAC9B,
|
|
6
|
-
"names": ["import_credentials", "createMockCredential", "signer", "issuer", "createCredential", "subject", "PublicKey", "Buffer", "from", "assertion", "payload", "value", "sanitizeInvitation", "invitation", "invitationId", "type", "kind", "authMethod", "swarmKey", "state", "timeout", "performInvitation", "host", "guest", "options", "hooks", "hostComplete", "Trigger", "guestComplete", "authCode", "hostObservable", "createInvitation", "subscribe", "hostInvitation", "Invitation", "State", "CONNECTING", "onConnecting", "guestObservable", "acceptInvitation", "guestInvitation", "invariant", "equals", "CONNECTED", "onConnected", "READY_FOR_AUTHENTICATION", "onReady", "authenticate", "wait", "AUTHENTICATING", "onAuthenticating", "SUCCESS", "onSuccess", "wake", "CANCELLED", "onCancelled", "TIMEOUT", "onTimeout", "error", "onError", "AuthMethod", "NONE", "ServiceContext", "hostHandler", "getInvitationHandler", "Kind", "SPACE", "invitations", "share", "guestHandler", "join", "createServiceHost", "config", "signalManagerContext", "ClientServicesHost", "signalManager", "MemorySignalManager", "transportFactory", "MemoryTransportFactory", "createServiceContext", "signalContext", "MemorySignalManagerContext", "storage", "createStorage", "StorageType", "RAM", "networkManager", "NetworkManager", "modelFactory", "createDefaultModelFactory", "createPeers", "numPeers", "Promise", "all", "Array", "map", "peer", "open", "Context", "createIdentity", "syncItemsLocal", "db1", "db2", "testLocalDatabase", "TestBuilder", "_ctx", "createPeer", "peerOptions", "TestPeer", "onDispose", "destroy", "dispose", "constructor", "opts", "dataStore", "_props", "props", "keyring", "Keyring", "createDirectory", "feedStore", "FeedStore", "factory", "FeedFactory", "root", "hypercore", "valueEncoding", "metadataStore", "MetadataStore", "blobStore", "BlobStore", "snapshotStore", "SnapshotStore", "spaceManager", "SpaceManager", "identity", "signingContext", "failUndefined", "dataSpaceManager", "DataSpaceManager", "DataServiceSubscriptions", "createSigningContext", "reset", "identityKey", "createKey", "deviceKey", "credentialSigner", "createCredentialSignerWithChain", "credential", "CredentialGenerator", "createDeviceAuthorization", "recordCredential", "getProfile", "undefined"]
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { createCredential } from '@dxos/credentials';\nimport { type Signer } from '@dxos/crypto';\nimport { PublicKey } from '@dxos/keys';\nimport { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\n\nexport const createMockCredential = async ({\n signer,\n issuer,\n}: {\n signer: Signer;\n issuer: PublicKey;\n}): Promise<Credential> =>\n createCredential({\n signer,\n issuer,\n subject: new PublicKey(Buffer.from('test')),\n assertion: {\n '@type': 'example.testing.rpc.MessageWithAny',\n payload: {\n '@type': 'google.protobuf.Any',\n value: Buffer.from('test'),\n },\n },\n });\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Trigger } from '@dxos/async';\nimport { type AuthenticatingInvitation, type CancellableInvitation } from '@dxos/client-protocol';\nimport { invariant } from '@dxos/invariant';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\nimport { ServiceContext } from '../services';\n\n/**\n * Strip secrets from invitation before giving it to the peer.\n */\nexport const sanitizeInvitation = (invitation: Invitation): Invitation => {\n return {\n invitationId: invitation.invitationId,\n type: invitation.type,\n kind: invitation.kind,\n authMethod: invitation.authMethod,\n swarmKey: invitation.swarmKey,\n state: invitation.state,\n timeout: invitation.timeout,\n };\n};\n\nexport type InvitationHost = {\n share(options?: Partial<Invitation>): CancellableInvitation;\n};\n\nexport type InvitationGuest = {\n join(invitation: Invitation | string): AuthenticatingInvitation;\n};\n\nexport type PerformInvitationCallbacks<T> = {\n onConnecting?: (value: T) => boolean | void;\n onConnected?: (value: T) => boolean | void;\n onReady?: (value: T) => boolean | void;\n onAuthenticating?: (value: T) => boolean | void;\n onSuccess?: (value: T) => boolean | void;\n onCancelled?: (value: T) => boolean | void;\n onTimeout?: (value: T) => boolean | void;\n onError?: (value: T) => boolean | void;\n};\n\nexport type PerformInvitationParams = {\n host: ServiceContext | InvitationHost;\n guest: ServiceContext | InvitationGuest;\n options?: Partial<Invitation>;\n hooks?: {\n host?: PerformInvitationCallbacks<CancellableInvitation>;\n guest?: PerformInvitationCallbacks<AuthenticatingInvitation>;\n };\n};\n\nexport type Result = { invitation?: Invitation; error?: Error };\n\nexport const performInvitation = ({\n host,\n guest,\n options,\n hooks,\n}: PerformInvitationParams): [Promise<Result>, Promise<Result>] => {\n const hostComplete = new Trigger<Result>();\n const guestComplete = new Trigger<Result>();\n const authCode = new Trigger<string>();\n\n const hostObservable = createInvitation(host, options);\n hostObservable.subscribe(\n async (hostInvitation: Invitation) => {\n switch (hostInvitation.state) {\n case Invitation.State.CONNECTING: {\n if (hooks?.host?.onConnecting?.(hostObservable)) {\n break;\n }\n const guestObservable = acceptInvitation(guest, hostInvitation);\n guestObservable.subscribe(\n async (guestInvitation: Invitation) => {\n switch (guestInvitation.state) {\n case Invitation.State.CONNECTING: {\n if (hooks?.guest?.onConnecting?.(guestObservable)) {\n break;\n }\n invariant(hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!));\n break;\n }\n\n case Invitation.State.CONNECTED: {\n hooks?.guest?.onConnected?.(guestObservable);\n break;\n }\n\n case Invitation.State.READY_FOR_AUTHENTICATION: {\n if (hooks?.guest?.onReady?.(guestObservable)) {\n break;\n }\n await guestObservable.authenticate(await authCode.wait());\n break;\n }\n\n case Invitation.State.AUTHENTICATING: {\n hooks?.guest?.onAuthenticating?.(guestObservable);\n break;\n }\n\n case Invitation.State.SUCCESS: {\n if (hooks?.guest?.onSuccess?.(guestObservable)) {\n break;\n }\n guestComplete.wake({ invitation: guestInvitation });\n break;\n }\n\n case Invitation.State.CANCELLED: {\n if (hooks?.guest?.onCancelled?.(guestObservable)) {\n break;\n }\n guestComplete.wake({ invitation: guestInvitation });\n break;\n }\n\n case Invitation.State.TIMEOUT: {\n if (hooks?.guest?.onTimeout?.(guestObservable)) {\n return;\n }\n guestComplete.wake({ invitation: guestInvitation });\n }\n }\n },\n (error: Error) => {\n if (hooks?.guest?.onError?.(guestObservable)) {\n return;\n }\n guestComplete.wake({ error });\n },\n );\n break;\n }\n\n case Invitation.State.CONNECTED: {\n hooks?.host?.onConnected?.(hostObservable);\n break;\n }\n\n case Invitation.State.READY_FOR_AUTHENTICATION: {\n if (hooks?.host?.onReady?.(hostObservable)) {\n break;\n }\n if (hostInvitation.authCode) {\n authCode.wake(hostInvitation.authCode);\n }\n break;\n }\n\n case Invitation.State.AUTHENTICATING: {\n hooks?.host?.onAuthenticating?.(hostObservable);\n break;\n }\n\n case Invitation.State.SUCCESS: {\n if (hooks?.host?.onSuccess?.(hostObservable)) {\n break;\n }\n hostComplete.wake({ invitation: hostInvitation });\n break;\n }\n\n case Invitation.State.CANCELLED: {\n if (hooks?.host?.onCancelled?.(hostObservable)) {\n break;\n }\n hostComplete.wake({ invitation: hostInvitation });\n break;\n }\n\n case Invitation.State.TIMEOUT: {\n if (hooks?.host?.onTimeout?.(hostObservable)) {\n break;\n }\n hostComplete.wake({ invitation: hostInvitation });\n break;\n }\n }\n },\n (error: Error) => {\n if (hooks?.host?.onError?.(hostObservable)) {\n return;\n }\n hostComplete.wake({ error });\n },\n );\n\n return [hostComplete.wait(), guestComplete.wait()];\n};\n\nconst createInvitation = (\n host: ServiceContext | InvitationHost,\n options?: Partial<Invitation>,\n): CancellableInvitation => {\n options ??= {\n authMethod: Invitation.AuthMethod.NONE,\n ...(options ?? {}),\n };\n\n if (host instanceof ServiceContext) {\n const hostHandler = host.getInvitationHandler({ kind: Invitation.Kind.SPACE, ...options });\n return host.invitations.createInvitation(hostHandler, options);\n }\n\n return host.share(options);\n};\n\nconst acceptInvitation = (\n guest: ServiceContext | InvitationGuest,\n invitation: Invitation,\n): AuthenticatingInvitation => {\n invitation = sanitizeInvitation(invitation);\n\n if (guest instanceof ServiceContext) {\n const guestHandler = guest.getInvitationHandler({ kind: invitation.kind });\n return guest.invitations.acceptInvitation(guestHandler, invitation);\n }\n\n return guest.join(invitation);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Config } from '@dxos/config';\nimport { Context } from '@dxos/context';\nimport { createCredentialSignerWithChain, CredentialGenerator } from '@dxos/credentials';\nimport { failUndefined } from '@dxos/debug';\nimport {\n SnapshotStore,\n type DataPipeline,\n MetadataStore,\n SpaceManager,\n valueEncoding,\n DataServiceSubscriptions,\n AutomergeHost,\n} from '@dxos/echo-pipeline';\nimport { testLocalDatabase } from '@dxos/echo-pipeline/testing';\nimport { FeedFactory, FeedStore } from '@dxos/feed-store';\nimport { Keyring } from '@dxos/keyring';\nimport { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';\nimport { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';\nimport { createStorage, type Storage, StorageType } from '@dxos/random-access-storage';\nimport { BlobStore } from '@dxos/teleport-extension-object-sync';\n\nimport { ClientServicesHost, createDefaultModelFactory, ServiceContext } from '../services';\nimport { DataSpaceManager, type SigningContext } from '../spaces';\n\n//\n// TODO(burdon): Replace with test builder.\n//\n\nexport const createServiceHost = (config: Config, signalManagerContext: MemorySignalManagerContext) => {\n return new ClientServicesHost({\n config,\n signalManager: new MemorySignalManager(signalManagerContext),\n transportFactory: MemoryTransportFactory,\n });\n};\n\nexport const createServiceContext = ({\n signalContext = new MemorySignalManagerContext(),\n storage = createStorage({ type: StorageType.RAM }),\n}: {\n signalContext?: MemorySignalManagerContext;\n storage?: Storage;\n} = {}) => {\n const signalManager = new MemorySignalManager(signalContext);\n const networkManager = new NetworkManager({\n signalManager,\n transportFactory: MemoryTransportFactory,\n });\n\n const modelFactory = createDefaultModelFactory();\n return new ServiceContext(storage, networkManager, signalManager, modelFactory);\n};\n\nexport const createPeers = async (numPeers: number) => {\n const signalContext = new MemorySignalManagerContext();\n\n return await Promise.all(\n Array.from(Array(numPeers)).map(async () => {\n const peer = createServiceContext({ signalContext });\n await peer.open(new Context());\n return peer;\n }),\n );\n};\n\nexport const createIdentity = async (peer: ServiceContext) => {\n await peer.createIdentity();\n return peer;\n};\n\n// TODO(burdon): Remove @dxos/client-testing.\n// TODO(burdon): Create builder and make configurable.\nexport const syncItemsLocal = async (db1: DataPipeline, db2: DataPipeline) => {\n await testLocalDatabase(db1, db2);\n await testLocalDatabase(db2, db1);\n};\n\nexport class TestBuilder {\n public readonly signalContext = new MemorySignalManagerContext();\n private readonly _ctx = new Context();\n\n createPeer(peerOptions?: TestPeerOpts): TestPeer {\n const peer = new TestPeer(this.signalContext, peerOptions);\n this._ctx.onDispose(async () => peer.destroy());\n return peer;\n }\n\n async destroy() {\n await this._ctx.dispose();\n }\n}\n\nexport type TestPeerOpts = {\n dataStore?: StorageType;\n};\n\nexport type TestPeerProps = {\n storage?: Storage;\n feedStore?: FeedStore<any>;\n metadataStore?: MetadataStore;\n keyring?: Keyring;\n networkManager?: NetworkManager;\n spaceManager?: SpaceManager;\n dataSpaceManager?: DataSpaceManager;\n snapshotStore?: SnapshotStore;\n signingContext?: SigningContext;\n blobStore?: BlobStore;\n automergeHost?: AutomergeHost;\n};\n\nexport class TestPeer {\n private _props: TestPeerProps = {};\n\n constructor(\n private readonly signalContext: MemorySignalManagerContext,\n private readonly opts: TestPeerOpts = { dataStore: StorageType.RAM },\n ) {}\n\n get props() {\n return this._props;\n }\n\n get storage() {\n return (this._props.storage ??= createStorage({ type: this.opts.dataStore }));\n }\n\n get keyring() {\n return (this._props.keyring ??= new Keyring(this.storage.createDirectory('keyring')));\n }\n\n get feedStore() {\n return (this._props.feedStore ??= new FeedStore({\n factory: new FeedFactory({\n root: this.storage.createDirectory('feeds'),\n signer: this.keyring,\n hypercore: {\n valueEncoding,\n },\n }),\n }));\n }\n\n get metadataStore() {\n return (this._props.metadataStore ??= new MetadataStore(this.storage.createDirectory('metadata')));\n }\n\n get blobStore() {\n return (this._props.blobStore ??= new BlobStore(this.storage.createDirectory('blobs')));\n }\n\n get snapshotStore() {\n return (this._props.snapshotStore ??= new SnapshotStore(this.storage.createDirectory('snapshots')));\n }\n\n get networkManager() {\n return (this._props.networkManager ??= new NetworkManager({\n signalManager: new MemorySignalManager(this.signalContext),\n transportFactory: MemoryTransportFactory,\n }));\n }\n\n get spaceManager() {\n return (this._props.spaceManager ??= new SpaceManager({\n feedStore: this.feedStore,\n networkManager: this.networkManager,\n metadataStore: this.metadataStore,\n modelFactory: createDefaultModelFactory(),\n snapshotStore: this.snapshotStore,\n blobStore: this.blobStore,\n }));\n }\n\n get identity() {\n return this._props.signingContext ?? failUndefined();\n }\n\n get automergeHost() {\n return (this._props.automergeHost ??= new AutomergeHost(this.storage.createDirectory('automerge')));\n }\n\n get dataSpaceManager() {\n return (this._props.dataSpaceManager ??= new DataSpaceManager(\n this.spaceManager,\n this.metadataStore,\n new DataServiceSubscriptions(),\n this.keyring,\n this.identity,\n this.feedStore,\n this.automergeHost,\n ));\n }\n\n async createIdentity() {\n this._props.signingContext ??= await createSigningContext(this.keyring);\n }\n\n async destroy() {\n await this.storage.reset();\n }\n}\n\nexport const createSigningContext = async (keyring: Keyring): Promise<SigningContext> => {\n const identityKey = await keyring.createKey();\n const deviceKey = await keyring.createKey();\n\n return {\n identityKey,\n deviceKey,\n credentialSigner: createCredentialSignerWithChain(\n keyring,\n {\n credential: await new CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey),\n },\n deviceKey,\n ),\n recordCredential: async () => {}, // No-op.\n getProfile: () => undefined,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAiC;AAEjC,kBAA0B;ACF1B,mBAAwB;AAExB,uBAA0B;AAC1B,sBAA2B;ACF3B,qBAAwB;AACxB,IAAAA,sBAAqE;AACrE,mBAA8B;AAC9B,2BAQO;AACP,qBAAkC;AAClC,wBAAuC;AACvC,qBAAwB;AACxB,uBAAgE;AAChE,6BAAuD;AACvD,mCAAyD;AACzD,4CAA0B;AFdnB,IAAMC,uBAAuB,OAAO,EACzCC,QACAC,OAAM,UAKNC,qCAAiB;EACfF;EACAC;EACAE,SAAS,IAAIC,sBAAUC,OAAOC,KAAK,MAAA,CAAA;EACnCC,WAAW;IACT,SAAS;IACTC,SAAS;MACP,SAAS;MACTC,OAAOJ,OAAOC,KAAK,MAAA;IACrB;EACF;AACF,CAAA;;ACbK,IAAMI,qBAAqB,CAACC,eAAAA;AACjC,SAAO;IACLC,cAAcD,WAAWC;IACzBC,MAAMF,WAAWE;IACjBC,MAAMH,WAAWG;IACjBC,YAAYJ,WAAWI;IACvBC,UAAUL,WAAWK;IACrBC,OAAON,WAAWM;IAClBC,SAASP,WAAWO;EACtB;AACF;AAiCO,IAAMC,oBAAoB,CAAC,EAChCC,MACAC,OACAC,SACAC,MAAK,MACmB;AACxB,QAAMC,eAAe,IAAIC,qBAAAA;AACzB,QAAMC,gBAAgB,IAAID,qBAAAA;AAC1B,QAAME,WAAW,IAAIF,qBAAAA;AAErB,QAAMG,iBAAiBC,iBAAiBT,MAAME,OAAA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,eACL,IAAIe,8CAAAA,GACJ,KAAKzB,SACL,KAAKkB,UACL,KAAKf,WACL,KAAKkB,aAAa;EAEtB;EAEA,MAAMvC,iBAAiB;AACrB,SAAKgB,OAAOqB,mBAAmB,MAAMO,qBAAqB,KAAK1B,OAAO;EACxE;EAEA,MAAMP,UAAU;AACd,UAAM,KAAK5B,QAAQ8D,MAAK;EAC1B;AACF;AAEO,IAAMD,uBAAuB,OAAO1B,YAAAA;AACzC,QAAM4B,cAAc,MAAM5B,QAAQ6B,UAAS;AAC3C,QAAMC,YAAY,MAAM9B,QAAQ6B,UAAS;AAEzC,SAAO;IACLD;IACAE;IACAC,sBAAkBC,qDAChBhC,SACA;MACEiC,YAAY,MAAM,IAAIC,wCAAoBlC,SAAS4B,aAAaE,SAAAA,EAAWK,0BAA0BL,SAAAA;IACvG,GACAA,SAAAA;IAEFM,kBAAkB,YAAA;IAAa;IAC/BC,YAAY,MAAMC;EACpB;AACF;",
|
|
6
|
+
"names": ["import_credentials", "createMockCredential", "signer", "issuer", "createCredential", "subject", "PublicKey", "Buffer", "from", "assertion", "payload", "value", "sanitizeInvitation", "invitation", "invitationId", "type", "kind", "authMethod", "swarmKey", "state", "timeout", "performInvitation", "host", "guest", "options", "hooks", "hostComplete", "Trigger", "guestComplete", "authCode", "hostObservable", "createInvitation", "subscribe", "hostInvitation", "Invitation", "State", "CONNECTING", "onConnecting", "guestObservable", "acceptInvitation", "guestInvitation", "invariant", "equals", "CONNECTED", "onConnected", "READY_FOR_AUTHENTICATION", "onReady", "authenticate", "wait", "AUTHENTICATING", "onAuthenticating", "SUCCESS", "onSuccess", "wake", "CANCELLED", "onCancelled", "TIMEOUT", "onTimeout", "error", "onError", "AuthMethod", "NONE", "ServiceContext", "hostHandler", "getInvitationHandler", "Kind", "SPACE", "invitations", "share", "guestHandler", "join", "createServiceHost", "config", "signalManagerContext", "ClientServicesHost", "signalManager", "MemorySignalManager", "transportFactory", "MemoryTransportFactory", "createServiceContext", "signalContext", "MemorySignalManagerContext", "storage", "createStorage", "StorageType", "RAM", "networkManager", "NetworkManager", "modelFactory", "createDefaultModelFactory", "createPeers", "numPeers", "Promise", "all", "Array", "map", "peer", "open", "Context", "createIdentity", "syncItemsLocal", "db1", "db2", "testLocalDatabase", "TestBuilder", "_ctx", "createPeer", "peerOptions", "TestPeer", "onDispose", "destroy", "dispose", "constructor", "opts", "dataStore", "_props", "props", "keyring", "Keyring", "createDirectory", "feedStore", "FeedStore", "factory", "FeedFactory", "root", "hypercore", "valueEncoding", "metadataStore", "MetadataStore", "blobStore", "BlobStore", "snapshotStore", "SnapshotStore", "spaceManager", "SpaceManager", "identity", "signingContext", "failUndefined", "automergeHost", "AutomergeHost", "dataSpaceManager", "DataSpaceManager", "DataServiceSubscriptions", "createSigningContext", "reset", "identityKey", "createKey", "deviceKey", "credentialSigner", "createCredentialSignerWithChain", "credential", "CredentialGenerator", "createDeviceAuthorization", "recordCredential", "getProfile", "undefined"]
|
|
7
7
|
}
|
|
@@ -37,13 +37,13 @@ export declare class DataSpaceManager {
|
|
|
37
37
|
private readonly _keyring;
|
|
38
38
|
private readonly _signingContext;
|
|
39
39
|
private readonly _feedStore;
|
|
40
|
-
private readonly _automergeHost
|
|
40
|
+
private readonly _automergeHost;
|
|
41
41
|
private readonly _ctx;
|
|
42
42
|
readonly updated: Event<void>;
|
|
43
43
|
private readonly _spaces;
|
|
44
44
|
private _isOpen;
|
|
45
45
|
private readonly _instanceId;
|
|
46
|
-
constructor(_spaceManager: SpaceManager, _metadataStore: MetadataStore, _dataServiceSubscriptions: DataServiceSubscriptions, _keyring: Keyring, _signingContext: SigningContext, _feedStore: FeedStore<FeedMessage>, _automergeHost
|
|
46
|
+
constructor(_spaceManager: SpaceManager, _metadataStore: MetadataStore, _dataServiceSubscriptions: DataServiceSubscriptions, _keyring: Keyring, _signingContext: SigningContext, _feedStore: FeedStore<FeedMessage>, _automergeHost: AutomergeHost);
|
|
47
47
|
get spaces(): ComplexMap<PublicKey, DataSpace>;
|
|
48
48
|
open(): Promise<void>;
|
|
49
49
|
close(): Promise<void>;
|
|
@@ -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;AAE9D,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,mBAAmB,CAAC;AAClF,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAElB,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAEpG,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,UAAU,EAA+B,MAAM,YAAY,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAOzC,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,SAAS,CAAC;IACvB,SAAS,EAAE,SAAS,CAAC;IACrB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,gBAAgB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5D,UAAU,EAAE,MAAM,eAAe,GAAG,SAAS,CAAC;CAC/C;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB,cAAc,EAAE,SAAS,CAAC;IAE1B;;;OAGG;IACH,gBAAgB,CAAC,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AU/B,eAAe;CAyF9B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Space } from '@dxos/echo-pipeline';
|
|
2
2
|
import { type Keyring } from '@dxos/keyring';
|
|
3
3
|
import { type SigningContext } from './data-space-manager';
|
|
4
|
-
export declare const spaceGenesis: (keyring: Keyring, signingContext: SigningContext, space: Space) => Promise<import("@dxos/protocols/proto/dxos/halo/credentials").Credential[]>;
|
|
4
|
+
export declare const spaceGenesis: (keyring: Keyring, signingContext: SigningContext, space: Space, automergeRoot?: string) => Promise<import("@dxos/protocols/proto/dxos/halo/credentials").Credential[]>;
|
|
5
5
|
//# sourceMappingURL=genesis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genesis.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/genesis.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAI7C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"genesis.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/spaces/genesis.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAI7C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,eAAO,MAAM,YAAY,YACd,OAAO,kBACA,cAAc,SACvB,KAAK,kBACI,MAAM,gFAqEvB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Config } from '@dxos/config';
|
|
2
|
-
import { SnapshotStore, type DataPipeline, MetadataStore, SpaceManager } from '@dxos/echo-pipeline';
|
|
2
|
+
import { SnapshotStore, type DataPipeline, MetadataStore, SpaceManager, AutomergeHost } from '@dxos/echo-pipeline';
|
|
3
3
|
import { FeedStore } from '@dxos/feed-store';
|
|
4
4
|
import { Keyring } from '@dxos/keyring';
|
|
5
5
|
import { MemorySignalManagerContext } from '@dxos/messaging';
|
|
@@ -36,6 +36,7 @@ export type TestPeerProps = {
|
|
|
36
36
|
snapshotStore?: SnapshotStore;
|
|
37
37
|
signingContext?: SigningContext;
|
|
38
38
|
blobStore?: BlobStore;
|
|
39
|
+
automergeHost?: AutomergeHost;
|
|
39
40
|
};
|
|
40
41
|
export declare class TestPeer {
|
|
41
42
|
private readonly signalContext;
|
|
@@ -52,6 +53,7 @@ export declare class TestPeer {
|
|
|
52
53
|
get networkManager(): NetworkManager;
|
|
53
54
|
get spaceManager(): SpaceManager;
|
|
54
55
|
get identity(): SigningContext;
|
|
56
|
+
get automergeHost(): AutomergeHost;
|
|
55
57
|
get dataSpaceManager(): DataSpaceManager;
|
|
56
58
|
createIdentity(): Promise<void>;
|
|
57
59
|
destroy(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-builder.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/test-builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EACL,aAAa,EACb,KAAK,YAAY,EACjB,aAAa,EACb,YAAY,
|
|
1
|
+
{"version":3,"file":"test-builder.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/test-builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EACL,aAAa,EACb,KAAK,YAAY,EACjB,aAAa,EACb,YAAY,EAGZ,aAAa,EACd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAe,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC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B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,qBAAa,QAAQ;IAIjB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJvB,OAAO,CAAC,MAAM,CAAqB;gBAGhB,aAAa,EAAE,0BAA0B,EACzC,IAAI,GAAE,YAA6C;IAGtE,IAAI,KAAK,kBAER;IAED,IAAI,OAAO,YAEV;IAED,IAAI,OAAO,YAEV;IAED,IAAI,SAAS,mBAUZ;IAED,IAAI,aAAa,kBAEhB;IAED,IAAI,SAAS,cAEZ;IAED,IAAI,aAAa,kBAEhB;IAED,IAAI,cAAc,mBAKjB;IAED,IAAI,YAAY,iBASf;IAED,IAAI,QAAQ,mBAEX;IAED,IAAI,aAAa,kBAEhB;IAED,IAAI,gBAAgB,qBAUnB;IAEK,cAAc;IAId,OAAO;CAGd;AAED,eAAO,MAAM,oBAAoB,YAAmB,OAAO,KAAG,QAAQ,cAAc,CAiBnF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const DXOS_VERSION = "0.3.9-main.
|
|
1
|
+
export declare const DXOS_VERSION = "0.3.9-main.a9b2756";
|
|
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.3.9-main.
|
|
3
|
+
"version": "0.3.9-main.a9b2756",
|
|
4
4
|
"description": "DXOS client services implementation",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -22,44 +22,44 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"platform": "^1.3.6",
|
|
25
|
-
"@dxos/async": "0.3.9-main.
|
|
26
|
-
"@dxos/client-protocol": "0.3.9-main.
|
|
27
|
-
"@dxos/
|
|
28
|
-
"@dxos/
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/crypto": "0.3.9-main.
|
|
32
|
-
"@dxos/debug": "0.3.9-main.
|
|
33
|
-
"@dxos/document-model": "0.3.9-main.
|
|
34
|
-
"@dxos/echo-db": "0.3.9-main.
|
|
35
|
-
"@dxos/echo-pipeline": "0.3.9-main.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/feed-store": "0.3.9-main.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/keyring": "0.3.9-main.
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/teleport
|
|
51
|
-
"@dxos/teleport": "0.3.9-main.
|
|
52
|
-
"@dxos/teleport-extension-
|
|
53
|
-
"@dxos/text-model": "0.3.9-main.
|
|
54
|
-
"@dxos/timeframe": "0.3.9-main.
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
25
|
+
"@dxos/async": "0.3.9-main.a9b2756",
|
|
26
|
+
"@dxos/client-protocol": "0.3.9-main.a9b2756",
|
|
27
|
+
"@dxos/codec-protobuf": "0.3.9-main.a9b2756",
|
|
28
|
+
"@dxos/config": "0.3.9-main.a9b2756",
|
|
29
|
+
"@dxos/credentials": "0.3.9-main.a9b2756",
|
|
30
|
+
"@dxos/context": "0.3.9-main.a9b2756",
|
|
31
|
+
"@dxos/crypto": "0.3.9-main.a9b2756",
|
|
32
|
+
"@dxos/debug": "0.3.9-main.a9b2756",
|
|
33
|
+
"@dxos/document-model": "0.3.9-main.a9b2756",
|
|
34
|
+
"@dxos/echo-db": "0.3.9-main.a9b2756",
|
|
35
|
+
"@dxos/echo-pipeline": "0.3.9-main.a9b2756",
|
|
36
|
+
"@dxos/invariant": "0.3.9-main.a9b2756",
|
|
37
|
+
"@dxos/feed-store": "0.3.9-main.a9b2756",
|
|
38
|
+
"@dxos/echo-schema": "0.3.9-main.a9b2756",
|
|
39
|
+
"@dxos/keyring": "0.3.9-main.a9b2756",
|
|
40
|
+
"@dxos/keys": "0.3.9-main.a9b2756",
|
|
41
|
+
"@dxos/lock-file": "0.3.9-main.a9b2756",
|
|
42
|
+
"@dxos/messaging": "0.3.9-main.a9b2756",
|
|
43
|
+
"@dxos/network-manager": "0.3.9-main.a9b2756",
|
|
44
|
+
"@dxos/node-std": "0.3.9-main.a9b2756",
|
|
45
|
+
"@dxos/log": "0.3.9-main.a9b2756",
|
|
46
|
+
"@dxos/model-factory": "0.3.9-main.a9b2756",
|
|
47
|
+
"@dxos/protocols": "0.3.9-main.a9b2756",
|
|
48
|
+
"@dxos/random-access-storage": "0.3.9-main.a9b2756",
|
|
49
|
+
"@dxos/rpc": "0.3.9-main.a9b2756",
|
|
50
|
+
"@dxos/teleport": "0.3.9-main.a9b2756",
|
|
51
|
+
"@dxos/teleport-extension-object-sync": "0.3.9-main.a9b2756",
|
|
52
|
+
"@dxos/teleport-extension-gossip": "0.3.9-main.a9b2756",
|
|
53
|
+
"@dxos/text-model": "0.3.9-main.a9b2756",
|
|
54
|
+
"@dxos/timeframe": "0.3.9-main.a9b2756",
|
|
55
|
+
"@dxos/util": "0.3.9-main.a9b2756",
|
|
56
|
+
"@dxos/websocket-rpc": "0.3.9-main.a9b2756",
|
|
57
|
+
"@dxos/tracing": "0.3.9-main.a9b2756"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/platform": "^1.3.4",
|
|
61
61
|
"@types/readable-stream": "^2.3.9",
|
|
62
|
-
"@dxos/signal": "0.3.9-main.
|
|
62
|
+
"@dxos/signal": "0.3.9-main.a9b2756"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
@@ -357,7 +357,7 @@ export class ClientServicesHost {
|
|
|
357
357
|
// Setup default space.
|
|
358
358
|
await this._serviceContext.initialized.wait();
|
|
359
359
|
const space = await this._serviceContext.dataSpaceManager!.createSpace();
|
|
360
|
-
const obj: TypedObject = new Properties();
|
|
360
|
+
const obj: TypedObject = new Properties(undefined, { useAutomergeBackend: false });
|
|
361
361
|
obj[defaultKey] = identity.identityKey.toHex();
|
|
362
362
|
await this._serviceRegistry.services.DataService!.write({
|
|
363
363
|
spaceKey: space.key,
|
|
@@ -77,9 +77,7 @@ export class DataSpaceManager {
|
|
|
77
77
|
private readonly _keyring: Keyring,
|
|
78
78
|
private readonly _signingContext: SigningContext,
|
|
79
79
|
private readonly _feedStore: FeedStore<FeedMessage>,
|
|
80
|
-
|
|
81
|
-
// TODO(dmaretskyi): Make required.
|
|
82
|
-
private readonly _automergeHost?: AutomergeHost,
|
|
80
|
+
private readonly _automergeHost: AutomergeHost,
|
|
83
81
|
) {}
|
|
84
82
|
|
|
85
83
|
// TODO(burdon): Remove.
|
|
@@ -144,7 +142,9 @@ export class DataSpaceManager {
|
|
|
144
142
|
log('creating space...', { spaceKey });
|
|
145
143
|
const space = await this._constructSpace(metadata);
|
|
146
144
|
|
|
147
|
-
const
|
|
145
|
+
const automergeRoot = this._automergeHost!.repo.create();
|
|
146
|
+
|
|
147
|
+
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
148
148
|
await this._metadataStore.addSpace(metadata);
|
|
149
149
|
|
|
150
150
|
const memberCredential = credentials[1];
|
|
@@ -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.a9b2756";
|