@dxos/client-services 0.4.10-main.e158b1a → 0.4.10-main.eedd150
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-VIHM6GWA.mjs → chunk-I6GQX7F3.mjs} +103 -66
- package/dist/lib/browser/{chunk-VIHM6GWA.mjs.map → chunk-I6GQX7F3.mjs.map} +4 -4
- package/dist/lib/browser/index.mjs +3 -1
- 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 +6 -4
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-52FE74JI.cjs → chunk-42TXJ32V.cjs} +96 -64
- package/dist/lib/node/chunk-42TXJ32V.cjs.map +7 -0
- package/dist/lib/node/index.cjs +39 -37
- 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 +10 -8
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/services/service-context.d.ts +3 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/index.d.ts +1 -0
- package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.d.ts +4 -0
- package/dist/types/src/packlets/storage/level.d.ts.map +1 -0
- package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/util.d.ts +4 -0
- package/dist/types/src/packlets/storage/util.d.ts.map +1 -0
- package/dist/types/src/packlets/testing/test-builder.d.ts +1 -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 -34
- package/src/packlets/devices/devices-service.test.ts +1 -1
- package/src/packlets/identity/identity-service.test.ts +1 -1
- package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
- package/src/packlets/network/network-service.test.ts +1 -1
- package/src/packlets/services/service-context.test.ts +5 -5
- package/src/packlets/services/service-context.ts +4 -1
- package/src/packlets/services/service-host.ts +29 -12
- package/src/packlets/services/service-registry.test.ts +1 -1
- package/src/packlets/spaces/spaces-service.test.ts +1 -1
- package/src/packlets/storage/index.ts +1 -0
- package/src/packlets/storage/level.ts +19 -0
- package/src/packlets/storage/storage.ts +3 -9
- package/src/packlets/storage/util.ts +19 -0
- package/src/packlets/testing/test-builder.ts +5 -3
- package/src/version.ts +1 -1
- package/dist/lib/node/chunk-52FE74JI.cjs.map +0 -7
|
@@ -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 { InvitationEncoder, type AuthenticatingInvitation, type CancellableInvitation } from '@dxos/client-protocol';\nimport { invariant } from '@dxos/invariant';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\nimport { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';\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 InvitationEncoder.decode(InvitationEncoder.encode(invitation));\n};\n\nexport type InvitationHost = {\n share(options?: Partial<Invitation>): CancellableInvitation;\n};\n\nexport type InvitationGuest = {\n join(invitation: Invitation | string, deviceProfile?: DeviceProfileDocument): 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 guestDeviceProfile?: DeviceProfileDocument;\n};\n\nexport type Result = { invitation?: Invitation; error?: Error };\n\nexport const performInvitation = ({\n host,\n guest,\n options,\n hooks,\n guestDeviceProfile,\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, guestDeviceProfile);\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 guestDeviceProfile?: DeviceProfileDocument,\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, guestDeviceProfile);\n }\n\n return guest.join(invitation, guestDeviceProfile);\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 { AutomergeHost, MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from '@dxos/echo-pipeline';\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, StorageType, type Storage } from '@dxos/random-access-storage';\nimport { BlobStore } from '@dxos/teleport-extension-object-sync';\n\nimport { ClientServicesHost, 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 return new ServiceContext(storage, networkManager, signalManager);\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\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 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({ directory: this.storage.createDirectory('automerge') }));\n }\n\n get dataSpaceManager() {\n return (this._props.dataSpaceManager ??= new DataSpaceManager(\n this.spaceManager,\n this.metadataStore,\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,SAASA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,MAAM6C,qBAAqB;MAAEC,MAAMpD,WAAWoD;IAAK,CAAA;AACxE,WAAO9C,MAAMiD,YAAY/B,iBAAiBiC,cAAczD,YAAYS,kBAAAA;EACtE;AAEA,SAAOH,MAAMoD,KAAK1D,YAAYS,kBAAAA;AAChC;;;ACvNA,SAASkD,eAAe;AACxB,SAASC,iCAAiCC,2BAA2B;AACrE,SAASC,qBAAqB;AAC9B,SAASC,eAAeC,eAAeC,eAAeC,cAAcC,qBAAqB;AACzF,SAASC,aAAaC,iBAAiB;AACvC,SAASC,eAAe;AACxB,SAASC,qBAAqBC,kCAAkC;AAChE,SAASC,wBAAwBC,sBAAsB;AACvD,SAASC,eAAeC,mBAAiC;AACzD,SAASC,iBAAiB;AASnB,IAAMC,oBAAoB,CAACC,QAAgBC,yBAAAA;AAChD,SAAO,IAAIC,mBAAmB;IAC5BF;IACAG,eAAe,IAAIC,oBAAoBH,oBAAAA;IACvCI,kBAAkBC;EACpB,CAAA;AACF;AAEO,IAAMC,uBAAuB,
|
|
6
|
-
"names": ["createCredential", "PublicKey", "createMockCredential", "signer", "issuer", "createCredential", "subject", "PublicKey", "Buffer", "from", "assertion", "payload", "value", "Trigger", "InvitationEncoder", "invariant", "Invitation", "sanitizeInvitation", "invitation", "InvitationEncoder", "decode", "encode", "performInvitation", "host", "guest", "options", "hooks", "guestDeviceProfile", "hostComplete", "Trigger", "guestComplete", "authCode", "hostObservable", "createInvitation", "subscribe", "hostInvitation", "state", "Invitation", "State", "CONNECTING", "onConnecting", "guestObservable", "acceptInvitation", "guestInvitation", "invariant", "swarmKey", "equals", "CONNECTED", "onConnected", "READY_FOR_AUTHENTICATION", "onReady", "authenticate", "wait", "AUTHENTICATING", "onAuthenticating", "SUCCESS", "onSuccess", "wake", "CANCELLED", "onCancelled", "TIMEOUT", "onTimeout", "error", "onError", "authMethod", "AuthMethod", "NONE", "ServiceContext", "hostHandler", "getInvitationHandler", "kind", "Kind", "SPACE", "invitations", "share", "guestHandler", "join", "Context", "createCredentialSignerWithChain", "CredentialGenerator", "failUndefined", "AutomergeHost", "MetadataStore", "SnapshotStore", "SpaceManager", "valueEncoding", "FeedFactory", "FeedStore", "Keyring", "MemorySignalManager", "MemorySignalManagerContext", "MemoryTransportFactory", "NetworkManager", "createStorage", "StorageType", "BlobStore", "createServiceHost", "config", "signalManagerContext", "ClientServicesHost", "signalManager", "MemorySignalManager", "transportFactory", "MemoryTransportFactory", "createServiceContext", "signalContext", "MemorySignalManagerContext", "storage", "createStorage", "type", "StorageType", "RAM", "networkManager", "NetworkManager", "ServiceContext", "createPeers", "numPeers", "Promise", "all", "Array", "from", "map", "peer", "open", "Context", "createIdentity", "TestBuilder", "_ctx", "createPeer", "peerOptions", "TestPeer", "onDispose", "destroy", "dispose", "constructor", "opts", "dataStore", "_props", "props", "keyring", "Keyring", "createDirectory", "feedStore", "FeedStore", "factory", "FeedFactory", "root", "signer", "hypercore", "valueEncoding", "metadataStore", "MetadataStore", "blobStore", "BlobStore", "snapshotStore", "SnapshotStore", "spaceManager", "SpaceManager", "identity", "signingContext", "failUndefined", "automergeHost", "AutomergeHost", "directory", "dataSpaceManager", "DataSpaceManager", "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 { InvitationEncoder, type AuthenticatingInvitation, type CancellableInvitation } from '@dxos/client-protocol';\nimport { invariant } from '@dxos/invariant';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\nimport { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';\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 InvitationEncoder.decode(InvitationEncoder.encode(invitation));\n};\n\nexport type InvitationHost = {\n share(options?: Partial<Invitation>): CancellableInvitation;\n};\n\nexport type InvitationGuest = {\n join(invitation: Invitation | string, deviceProfile?: DeviceProfileDocument): 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 guestDeviceProfile?: DeviceProfileDocument;\n};\n\nexport type Result = { invitation?: Invitation; error?: Error };\n\nexport const performInvitation = ({\n host,\n guest,\n options,\n hooks,\n guestDeviceProfile,\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, guestDeviceProfile);\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 guestDeviceProfile?: DeviceProfileDocument,\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, guestDeviceProfile);\n }\n\n return guest.join(invitation, guestDeviceProfile);\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 { AutomergeHost, MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from '@dxos/echo-pipeline';\nimport { FeedFactory, FeedStore } from '@dxos/feed-store';\nimport { createTestLevel } from '@dxos/indexing/testing';\nimport { Keyring } from '@dxos/keyring';\nimport { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';\nimport { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';\nimport { createStorage, StorageType, type Storage } from '@dxos/random-access-storage';\nimport { BlobStore } from '@dxos/teleport-extension-object-sync';\n\nimport { ClientServicesHost, 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 = async ({\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 const level = await createTestLevel();\n\n return new ServiceContext(storage, level, networkManager, signalManager);\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 = await 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\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 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({ directory: this.storage.createDirectory('automerge') }));\n }\n\n get dataSpaceManager() {\n return (this._props.dataSpaceManager ??= new DataSpaceManager(\n this.spaceManager,\n this.metadataStore,\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,SAASA,wBAAwB;AAEjC,SAASC,iBAAiB;AAGnB,IAAMC,uBAAuB,OAAO,EACzCC,QACAC,OAAM,MAKNC,iBAAiB;EACfF;EACAC;EACAE,SAAS,IAAIC,UAAUC,OAAOC,KAAK,MAAA,CAAA;EACnCC,WAAW;IACT,SAAS;IACTC,SAAS;MACP,SAAS;MACTC,OAAOJ,OAAOC,KAAK,MAAA;IACrB;EACF;AACF,CAAA;;;ACvBF,SAASI,eAAe;AACxB,SAASC,yBAAoF;AAC7F,SAASC,iBAAiB;AAC1B,SAASC,kBAAkB;;AAQpB,IAAMC,qBAAqB,CAACC,eAAAA;AACjC,SAAOC,kBAAkBC,OAAOD,kBAAkBE,OAAOH,UAAAA,CAAAA;AAC3D;AAkCO,IAAMI,oBAAoB,CAAC,EAChCC,MACAC,OACAC,SACAC,OACAC,mBAAkB,MACM;AACxB,QAAMC,eAAe,IAAIC,QAAAA;AACzB,QAAMC,gBAAgB,IAAID,QAAAA;AAC1B,QAAME,WAAW,IAAIF,QAAAA;AAErB,QAAMG,iBAAiBC,iBAAiBV,MAAME,OAAAA;AAC9CO,iBAAeE,UACb,OAAOC,mBAAAA;AACL,YAAQA,eAAeC,OAAK;MAC1B,KAAKC,WAAWC,MAAMC,YAAY;AAChC,YAAIb,OAAOH,MAAMiB,eAAeR,cAAAA,GAAiB;AAC/C;QACF;AACA,cAAMS,kBAAkBC,iBAAiBlB,OAAOW,gBAAgBR,kBAAAA;AAChEc,wBAAgBP,UACd,OAAOS,oBAAAA;AACL,kBAAQA,gBAAgBP,OAAK;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qBAAqB,KAAK3B,OAAO;EACxE;EAEA,MAAMP,UAAU;AACd,UAAM,KAAK3B,QAAQ8D,MAAK;EAC1B;AACF;AAEO,IAAMD,uBAAuB,OAAO3B,YAAAA;AACzC,QAAM6B,cAAc,MAAM7B,QAAQ8B,UAAS;AAC3C,QAAMC,YAAY,MAAM/B,QAAQ8B,UAAS;AAEzC,SAAO;IACLD;IACAE;IACAC,kBAAkBC,gCAChBjC,SACA;MACEkC,YAAY,MAAM,IAAIC,oBAAoBnC,SAAS6B,aAAaE,SAAAA,EAAWK,0BAA0BL,SAAAA;IACvG,GACAA,SAAAA;IAEFM,kBAAkB,YAAA;IAAa;IAC/BC,YAAY,MAAMC;EACpB;AACF;",
|
|
6
|
+
"names": ["createCredential", "PublicKey", "createMockCredential", "signer", "issuer", "createCredential", "subject", "PublicKey", "Buffer", "from", "assertion", "payload", "value", "Trigger", "InvitationEncoder", "invariant", "Invitation", "sanitizeInvitation", "invitation", "InvitationEncoder", "decode", "encode", "performInvitation", "host", "guest", "options", "hooks", "guestDeviceProfile", "hostComplete", "Trigger", "guestComplete", "authCode", "hostObservable", "createInvitation", "subscribe", "hostInvitation", "state", "Invitation", "State", "CONNECTING", "onConnecting", "guestObservable", "acceptInvitation", "guestInvitation", "invariant", "swarmKey", "equals", "CONNECTED", "onConnected", "READY_FOR_AUTHENTICATION", "onReady", "authenticate", "wait", "AUTHENTICATING", "onAuthenticating", "SUCCESS", "onSuccess", "wake", "CANCELLED", "onCancelled", "TIMEOUT", "onTimeout", "error", "onError", "authMethod", "AuthMethod", "NONE", "ServiceContext", "hostHandler", "getInvitationHandler", "kind", "Kind", "SPACE", "invitations", "share", "guestHandler", "join", "Context", "createCredentialSignerWithChain", "CredentialGenerator", "failUndefined", "AutomergeHost", "MetadataStore", "SnapshotStore", "SpaceManager", "valueEncoding", "FeedFactory", "FeedStore", "createTestLevel", "Keyring", "MemorySignalManager", "MemorySignalManagerContext", "MemoryTransportFactory", "NetworkManager", "createStorage", "StorageType", "BlobStore", "createServiceHost", "config", "signalManagerContext", "ClientServicesHost", "signalManager", "MemorySignalManager", "transportFactory", "MemoryTransportFactory", "createServiceContext", "signalContext", "MemorySignalManagerContext", "storage", "createStorage", "type", "StorageType", "RAM", "networkManager", "NetworkManager", "level", "createTestLevel", "ServiceContext", "createPeers", "numPeers", "Promise", "all", "Array", "from", "map", "peer", "open", "Context", "createIdentity", "TestBuilder", "_ctx", "createPeer", "peerOptions", "TestPeer", "onDispose", "destroy", "dispose", "constructor", "opts", "dataStore", "_props", "props", "keyring", "Keyring", "createDirectory", "feedStore", "FeedStore", "factory", "FeedFactory", "root", "signer", "hypercore", "valueEncoding", "metadataStore", "MetadataStore", "blobStore", "BlobStore", "snapshotStore", "SnapshotStore", "spaceManager", "SpaceManager", "identity", "signingContext", "failUndefined", "automergeHost", "AutomergeHost", "directory", "dataSpaceManager", "DataSpaceManager", "createSigningContext", "reset", "identityKey", "createKey", "deviceKey", "credentialSigner", "createCredentialSignerWithChain", "credential", "CredentialGenerator", "createDeviceAuthorization", "recordCredential", "getProfile", "undefined"]
|
|
7
7
|
}
|
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_42TXJ32V_exports = {};
|
|
30
|
+
__export(chunk_42TXJ32V_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
DataSpace: () => DataSpace,
|
|
@@ -48,6 +48,7 @@ __export(chunk_52FE74JI_exports, {
|
|
|
48
48
|
TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
|
|
49
49
|
createAuthProvider: () => createAuthProvider,
|
|
50
50
|
createDiagnostics: () => createDiagnostics,
|
|
51
|
+
createLevel: () => createLevel,
|
|
51
52
|
createStorageObjects: () => createStorageObjects,
|
|
52
53
|
getNetworkPeers: () => getNetworkPeers,
|
|
53
54
|
invitationExpired: () => invitationExpired,
|
|
@@ -60,7 +61,7 @@ __export(chunk_52FE74JI_exports, {
|
|
|
60
61
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
61
62
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
62
63
|
});
|
|
63
|
-
module.exports = __toCommonJS(
|
|
64
|
+
module.exports = __toCommonJS(chunk_42TXJ32V_exports);
|
|
64
65
|
var import_async = require("@dxos/async");
|
|
65
66
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
66
67
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -223,20 +224,23 @@ var import_protocols13 = require("@dxos/protocols");
|
|
|
223
224
|
var import_invariant15 = require("@dxos/invariant");
|
|
224
225
|
var import_lock_file = require("@dxos/lock-file");
|
|
225
226
|
var import_log13 = require("@dxos/log");
|
|
226
|
-
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
227
227
|
var import_protocols14 = require("@dxos/protocols");
|
|
228
228
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
229
229
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
230
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
231
|
+
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
230
232
|
var import_util8 = require("@dxos/util");
|
|
233
|
+
var import_level = require("level");
|
|
234
|
+
var import_node_path = __toESM(require("node:path"));
|
|
235
|
+
var import_keys11 = require("@dxos/keys");
|
|
231
236
|
var import_async16 = require("@dxos/async");
|
|
232
237
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
233
238
|
var import_context11 = require("@dxos/context");
|
|
234
239
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
235
240
|
var E = __toESM(require("@dxos/echo-schema"));
|
|
236
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
237
241
|
var import_indexing2 = require("@dxos/indexing");
|
|
238
242
|
var import_invariant16 = require("@dxos/invariant");
|
|
239
|
-
var
|
|
243
|
+
var import_keys12 = require("@dxos/keys");
|
|
240
244
|
var import_log14 = require("@dxos/log");
|
|
241
245
|
var import_messaging = require("@dxos/messaging");
|
|
242
246
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
@@ -251,7 +255,7 @@ var import_invariant17 = require("@dxos/invariant");
|
|
|
251
255
|
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
252
256
|
var import_async18 = require("@dxos/async");
|
|
253
257
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
254
|
-
var
|
|
258
|
+
var import_keys13 = require("@dxos/keys");
|
|
255
259
|
var import_log15 = require("@dxos/log");
|
|
256
260
|
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
257
261
|
var import_util10 = require("@dxos/util");
|
|
@@ -2887,7 +2891,7 @@ var getPlatform = () => {
|
|
|
2887
2891
|
};
|
|
2888
2892
|
}
|
|
2889
2893
|
};
|
|
2890
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
2894
|
+
var DXOS_VERSION = "0.4.10-main.eedd150";
|
|
2891
2895
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2892
2896
|
var DEFAULT_TIMEOUT = 1e3;
|
|
2893
2897
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
@@ -4518,8 +4522,9 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4518
4522
|
}
|
|
4519
4523
|
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4520
4524
|
var ServiceContext = class {
|
|
4521
|
-
constructor(storage, networkManager, signalManager, _runtimeParams) {
|
|
4525
|
+
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4522
4526
|
this.storage = storage;
|
|
4527
|
+
this.level = level;
|
|
4523
4528
|
this.networkManager = networkManager;
|
|
4524
4529
|
this.signalManager = signalManager;
|
|
4525
4530
|
this._runtimeParams = _runtimeParams;
|
|
@@ -4549,7 +4554,7 @@ var ServiceContext = class {
|
|
|
4549
4554
|
});
|
|
4550
4555
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4551
4556
|
this.indexMetadata = new import_indexing.IndexMetadataStore({
|
|
4552
|
-
|
|
4557
|
+
db: level.sublevel("index-metadata")
|
|
4553
4558
|
});
|
|
4554
4559
|
this.automergeHost = new import_echo_pipeline3.AutomergeHost({
|
|
4555
4560
|
directory: storage.createDirectory("automerge"),
|
|
@@ -4570,7 +4575,7 @@ var ServiceContext = class {
|
|
|
4570
4575
|
await this._checkStorageVersion();
|
|
4571
4576
|
(0, import_log12.log)("opening...", void 0, {
|
|
4572
4577
|
F: __dxlog_file15,
|
|
4573
|
-
L:
|
|
4578
|
+
L: 154,
|
|
4574
4579
|
S: this,
|
|
4575
4580
|
C: (f, a) => f(...a)
|
|
4576
4581
|
});
|
|
@@ -4578,7 +4583,7 @@ var ServiceContext = class {
|
|
|
4578
4583
|
id: this._instanceId
|
|
4579
4584
|
}), {
|
|
4580
4585
|
F: __dxlog_file15,
|
|
4581
|
-
L:
|
|
4586
|
+
L: 155,
|
|
4582
4587
|
S: this,
|
|
4583
4588
|
C: (f, a) => f(...a)
|
|
4584
4589
|
});
|
|
@@ -4594,13 +4599,13 @@ var ServiceContext = class {
|
|
|
4594
4599
|
id: this._instanceId
|
|
4595
4600
|
}), {
|
|
4596
4601
|
F: __dxlog_file15,
|
|
4597
|
-
L:
|
|
4602
|
+
L: 165,
|
|
4598
4603
|
S: this,
|
|
4599
4604
|
C: (f, a) => f(...a)
|
|
4600
4605
|
});
|
|
4601
4606
|
(0, import_log12.log)("opened", void 0, {
|
|
4602
4607
|
F: __dxlog_file15,
|
|
4603
|
-
L:
|
|
4608
|
+
L: 166,
|
|
4604
4609
|
S: this,
|
|
4605
4610
|
C: (f, a) => f(...a)
|
|
4606
4611
|
});
|
|
@@ -4608,7 +4613,7 @@ var ServiceContext = class {
|
|
|
4608
4613
|
async close() {
|
|
4609
4614
|
(0, import_log12.log)("closing...", void 0, {
|
|
4610
4615
|
F: __dxlog_file15,
|
|
4611
|
-
L:
|
|
4616
|
+
L: 170,
|
|
4612
4617
|
S: this,
|
|
4613
4618
|
C: (f, a) => f(...a)
|
|
4614
4619
|
});
|
|
@@ -4626,7 +4631,7 @@ var ServiceContext = class {
|
|
|
4626
4631
|
await this.indexer.destroy();
|
|
4627
4632
|
(0, import_log12.log)("closed", void 0, {
|
|
4628
4633
|
F: __dxlog_file15,
|
|
4629
|
-
L:
|
|
4634
|
+
L: 183,
|
|
4630
4635
|
S: this,
|
|
4631
4636
|
C: (f, a) => f(...a)
|
|
4632
4637
|
});
|
|
@@ -4640,7 +4645,7 @@ var ServiceContext = class {
|
|
|
4640
4645
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4641
4646
|
(0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4642
4647
|
F: __dxlog_file15,
|
|
4643
|
-
L:
|
|
4648
|
+
L: 194,
|
|
4644
4649
|
S: this,
|
|
4645
4650
|
A: [
|
|
4646
4651
|
"factory",
|
|
@@ -4672,7 +4677,7 @@ var ServiceContext = class {
|
|
|
4672
4677
|
async _initialize(ctx) {
|
|
4673
4678
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4674
4679
|
F: __dxlog_file15,
|
|
4675
|
-
L:
|
|
4680
|
+
L: 225,
|
|
4676
4681
|
S: this,
|
|
4677
4682
|
C: (f, a) => f(...a)
|
|
4678
4683
|
});
|
|
@@ -4695,7 +4700,7 @@ var ServiceContext = class {
|
|
|
4695
4700
|
this._handlerFactories.set(import_services12.Invitation.Kind.SPACE, (invitation) => {
|
|
4696
4701
|
(0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4697
4702
|
F: __dxlog_file15,
|
|
4698
|
-
L:
|
|
4703
|
+
L: 249,
|
|
4699
4704
|
S: this,
|
|
4700
4705
|
A: [
|
|
4701
4706
|
"this.dataSpaceManager",
|
|
@@ -4719,7 +4724,7 @@ var ServiceContext = class {
|
|
|
4719
4724
|
details: assertion
|
|
4720
4725
|
}, {
|
|
4721
4726
|
F: __dxlog_file15,
|
|
4722
|
-
L:
|
|
4727
|
+
L: 265,
|
|
4723
4728
|
S: this,
|
|
4724
4729
|
C: (f, a) => f(...a)
|
|
4725
4730
|
});
|
|
@@ -4730,7 +4735,7 @@ var ServiceContext = class {
|
|
|
4730
4735
|
details: assertion
|
|
4731
4736
|
}, {
|
|
4732
4737
|
F: __dxlog_file15,
|
|
4733
|
-
L:
|
|
4738
|
+
L: 269,
|
|
4734
4739
|
S: this,
|
|
4735
4740
|
C: (f, a) => f(...a)
|
|
4736
4741
|
});
|
|
@@ -4741,7 +4746,7 @@ var ServiceContext = class {
|
|
|
4741
4746
|
details: assertion
|
|
4742
4747
|
}, {
|
|
4743
4748
|
F: __dxlog_file15,
|
|
4744
|
-
L:
|
|
4749
|
+
L: 274,
|
|
4745
4750
|
S: this,
|
|
4746
4751
|
C: (f, a) => f(...a)
|
|
4747
4752
|
});
|
|
@@ -4752,7 +4757,7 @@ var ServiceContext = class {
|
|
|
4752
4757
|
} catch (err) {
|
|
4753
4758
|
import_log12.log.catch(err, void 0, {
|
|
4754
4759
|
F: __dxlog_file15,
|
|
4755
|
-
L:
|
|
4760
|
+
L: 280,
|
|
4756
4761
|
S: this,
|
|
4757
4762
|
C: (f, a) => f(...a)
|
|
4758
4763
|
});
|
|
@@ -4848,9 +4853,17 @@ _ts_decorate7([
|
|
|
4848
4853
|
import_log13.logInfo
|
|
4849
4854
|
], Lock.prototype, "lockKey", null);
|
|
4850
4855
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
4856
|
+
var getRootPath = (config) => {
|
|
4857
|
+
const { dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
|
|
4858
|
+
return `${dataRoot}/`;
|
|
4859
|
+
};
|
|
4860
|
+
var isPersistent = (config) => {
|
|
4861
|
+
const { persistent = false } = config ?? {};
|
|
4862
|
+
return config.dataStore !== void 0 && config.dataStore !== import_config2.Runtime.Client.Storage.StorageDriver.RAM || persistent;
|
|
4863
|
+
};
|
|
4851
4864
|
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
4852
4865
|
var createStorageObjects = (config) => {
|
|
4853
|
-
const { persistent = false, keyStore, dataStore
|
|
4866
|
+
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
4854
4867
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
4855
4868
|
throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4856
4869
|
}
|
|
@@ -4866,7 +4879,7 @@ var createStorageObjects = (config) => {
|
|
|
4866
4879
|
return {
|
|
4867
4880
|
storage: (0, import_random_access_storage.createStorage)({
|
|
4868
4881
|
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
4869
|
-
root:
|
|
4882
|
+
root: getRootPath(config)
|
|
4870
4883
|
})
|
|
4871
4884
|
};
|
|
4872
4885
|
};
|
|
@@ -4890,6 +4903,13 @@ var toStorageType = (type) => {
|
|
|
4890
4903
|
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
4891
4904
|
}
|
|
4892
4905
|
};
|
|
4906
|
+
var createLevel = async (config) => {
|
|
4907
|
+
const persistent = isPersistent(config);
|
|
4908
|
+
const storagePath = persistent ? getRootPath(config) : import_node_path.default.join("tmp", "level", import_keys11.PublicKey.random().toHex());
|
|
4909
|
+
const level = new import_level.Level(storagePath);
|
|
4910
|
+
await level.open();
|
|
4911
|
+
return level;
|
|
4912
|
+
};
|
|
4893
4913
|
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4894
4914
|
var DevicesServiceImpl = class {
|
|
4895
4915
|
constructor(_identityManager) {
|
|
@@ -4970,7 +4990,7 @@ var LoggingServiceImpl = class {
|
|
|
4970
4990
|
constructor() {
|
|
4971
4991
|
this._logs = new import_async18.Event();
|
|
4972
4992
|
this._started = Date.now();
|
|
4973
|
-
this._sessionId =
|
|
4993
|
+
this._sessionId = import_keys13.PublicKey.random().toHex();
|
|
4974
4994
|
this._logProcessor = (_config, entry2) => {
|
|
4975
4995
|
this._logs.emit(entry2);
|
|
4976
4996
|
};
|
|
@@ -5065,12 +5085,12 @@ var LoggingServiceImpl = class {
|
|
|
5065
5085
|
});
|
|
5066
5086
|
}
|
|
5067
5087
|
};
|
|
5068
|
-
var matchFilter = (filter, level,
|
|
5088
|
+
var matchFilter = (filter, level, path2, options) => {
|
|
5069
5089
|
switch (options) {
|
|
5070
5090
|
case import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5071
|
-
return level >= filter.level && (!filter.pattern ||
|
|
5091
|
+
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5072
5092
|
case import_services15.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5073
|
-
return level === filter.level && (!filter.pattern ||
|
|
5093
|
+
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5074
5094
|
}
|
|
5075
5095
|
};
|
|
5076
5096
|
var shouldLog = (entry2, request) => {
|
|
@@ -5261,7 +5281,7 @@ var ClientServicesHost = class {
|
|
|
5261
5281
|
initialize({ config, ...options }) {
|
|
5262
5282
|
(0, import_invariant16.invariant)(!this._open, "service host is open", {
|
|
5263
5283
|
F: __dxlog_file18,
|
|
5264
|
-
L:
|
|
5284
|
+
L: 182,
|
|
5265
5285
|
S: this,
|
|
5266
5286
|
A: [
|
|
5267
5287
|
"!this._open",
|
|
@@ -5270,14 +5290,14 @@ var ClientServicesHost = class {
|
|
|
5270
5290
|
});
|
|
5271
5291
|
(0, import_log14.log)("initializing...", void 0, {
|
|
5272
5292
|
F: __dxlog_file18,
|
|
5273
|
-
L:
|
|
5293
|
+
L: 183,
|
|
5274
5294
|
S: this,
|
|
5275
5295
|
C: (f, a) => f(...a)
|
|
5276
5296
|
});
|
|
5277
5297
|
if (config) {
|
|
5278
5298
|
(0, import_invariant16.invariant)(!this._config, "config already set", {
|
|
5279
5299
|
F: __dxlog_file18,
|
|
5280
|
-
L:
|
|
5300
|
+
L: 186,
|
|
5281
5301
|
S: this,
|
|
5282
5302
|
A: [
|
|
5283
5303
|
"!this._config",
|
|
@@ -5292,7 +5312,7 @@ var ClientServicesHost = class {
|
|
|
5292
5312
|
if (!options.signalManager) {
|
|
5293
5313
|
import_log14.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5294
5314
|
F: __dxlog_file18,
|
|
5295
|
-
L:
|
|
5315
|
+
L: 194,
|
|
5296
5316
|
S: this,
|
|
5297
5317
|
C: (f, a) => f(...a)
|
|
5298
5318
|
});
|
|
@@ -5303,7 +5323,7 @@ var ClientServicesHost = class {
|
|
|
5303
5323
|
this._signalManager = signalManager;
|
|
5304
5324
|
(0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
|
|
5305
5325
|
F: __dxlog_file18,
|
|
5306
|
-
L:
|
|
5326
|
+
L: 205,
|
|
5307
5327
|
S: this,
|
|
5308
5328
|
A: [
|
|
5309
5329
|
"!this._networkManager",
|
|
@@ -5317,7 +5337,7 @@ var ClientServicesHost = class {
|
|
|
5317
5337
|
});
|
|
5318
5338
|
(0, import_log14.log)("initialized", void 0, {
|
|
5319
5339
|
F: __dxlog_file18,
|
|
5320
|
-
L:
|
|
5340
|
+
L: 212,
|
|
5321
5341
|
S: this,
|
|
5322
5342
|
C: (f, a) => f(...a)
|
|
5323
5343
|
});
|
|
@@ -5326,18 +5346,18 @@ var ClientServicesHost = class {
|
|
|
5326
5346
|
if (this._open) {
|
|
5327
5347
|
return;
|
|
5328
5348
|
}
|
|
5329
|
-
const traceId =
|
|
5349
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5330
5350
|
import_log14.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
|
|
5331
5351
|
id: traceId
|
|
5332
5352
|
}), {
|
|
5333
5353
|
F: __dxlog_file18,
|
|
5334
|
-
L:
|
|
5354
|
+
L: 223,
|
|
5335
5355
|
S: this,
|
|
5336
5356
|
C: (f, a) => f(...a)
|
|
5337
5357
|
});
|
|
5338
5358
|
(0, import_invariant16.invariant)(this._config, "config not set", {
|
|
5339
5359
|
F: __dxlog_file18,
|
|
5340
|
-
L:
|
|
5360
|
+
L: 225,
|
|
5341
5361
|
S: this,
|
|
5342
5362
|
A: [
|
|
5343
5363
|
"this._config",
|
|
@@ -5346,7 +5366,7 @@ var ClientServicesHost = class {
|
|
|
5346
5366
|
});
|
|
5347
5367
|
(0, import_invariant16.invariant)(this._storage, "storage not set", {
|
|
5348
5368
|
F: __dxlog_file18,
|
|
5349
|
-
L:
|
|
5369
|
+
L: 226,
|
|
5350
5370
|
S: this,
|
|
5351
5371
|
A: [
|
|
5352
5372
|
"this._storage",
|
|
@@ -5355,7 +5375,7 @@ var ClientServicesHost = class {
|
|
|
5355
5375
|
});
|
|
5356
5376
|
(0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
|
|
5357
5377
|
F: __dxlog_file18,
|
|
5358
|
-
L:
|
|
5378
|
+
L: 227,
|
|
5359
5379
|
S: this,
|
|
5360
5380
|
A: [
|
|
5361
5381
|
"this._signalManager",
|
|
@@ -5364,7 +5384,7 @@ var ClientServicesHost = class {
|
|
|
5364
5384
|
});
|
|
5365
5385
|
(0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
|
|
5366
5386
|
F: __dxlog_file18,
|
|
5367
|
-
L:
|
|
5387
|
+
L: 228,
|
|
5368
5388
|
S: this,
|
|
5369
5389
|
A: [
|
|
5370
5390
|
"this._networkManager",
|
|
@@ -5376,13 +5396,16 @@ var ClientServicesHost = class {
|
|
|
5376
5396
|
lockKey: this._resourceLock?.lockKey
|
|
5377
5397
|
}, {
|
|
5378
5398
|
F: __dxlog_file18,
|
|
5379
|
-
L:
|
|
5399
|
+
L: 231,
|
|
5380
5400
|
S: this,
|
|
5381
5401
|
C: (f, a) => f(...a)
|
|
5382
5402
|
});
|
|
5403
|
+
if (!this._level) {
|
|
5404
|
+
this._level = await createLevel(this._config.get("runtime.client.storage", {}));
|
|
5405
|
+
}
|
|
5383
5406
|
await this._resourceLock?.acquire();
|
|
5384
5407
|
await this._loggingService.open();
|
|
5385
|
-
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5408
|
+
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5386
5409
|
this._serviceRegistry.setServices({
|
|
5387
5410
|
SystemService: this._systemService,
|
|
5388
5411
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
@@ -5410,7 +5433,7 @@ var ClientServicesHost = class {
|
|
|
5410
5433
|
await this._serviceContext.open(ctx);
|
|
5411
5434
|
(0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5412
5435
|
F: __dxlog_file18,
|
|
5413
|
-
L:
|
|
5436
|
+
L: 297,
|
|
5414
5437
|
S: this,
|
|
5415
5438
|
A: [
|
|
5416
5439
|
"this.serviceRegistry.services.InvitationsService",
|
|
@@ -5422,7 +5445,7 @@ var ClientServicesHost = class {
|
|
|
5422
5445
|
count: loadedInvitations.invitations?.length
|
|
5423
5446
|
}, {
|
|
5424
5447
|
F: __dxlog_file18,
|
|
5425
|
-
L:
|
|
5448
|
+
L: 300,
|
|
5426
5449
|
S: this,
|
|
5427
5450
|
C: (f, a) => f(...a)
|
|
5428
5451
|
});
|
|
@@ -5444,7 +5467,7 @@ var ClientServicesHost = class {
|
|
|
5444
5467
|
deviceKey
|
|
5445
5468
|
}, {
|
|
5446
5469
|
F: __dxlog_file18,
|
|
5447
|
-
L:
|
|
5470
|
+
L: 317,
|
|
5448
5471
|
S: this,
|
|
5449
5472
|
C: (f, a) => f(...a)
|
|
5450
5473
|
});
|
|
@@ -5452,7 +5475,7 @@ var ClientServicesHost = class {
|
|
|
5452
5475
|
id: traceId
|
|
5453
5476
|
}), {
|
|
5454
5477
|
F: __dxlog_file18,
|
|
5455
|
-
L:
|
|
5478
|
+
L: 318,
|
|
5456
5479
|
S: this,
|
|
5457
5480
|
C: (f, a) => f(...a)
|
|
5458
5481
|
});
|
|
@@ -5466,7 +5489,7 @@ var ClientServicesHost = class {
|
|
|
5466
5489
|
deviceKey
|
|
5467
5490
|
}, {
|
|
5468
5491
|
F: __dxlog_file18,
|
|
5469
|
-
L:
|
|
5492
|
+
L: 329,
|
|
5470
5493
|
S: this,
|
|
5471
5494
|
C: (f, a) => f(...a)
|
|
5472
5495
|
});
|
|
@@ -5476,30 +5499,31 @@ var ClientServicesHost = class {
|
|
|
5476
5499
|
});
|
|
5477
5500
|
await this._loggingService.close();
|
|
5478
5501
|
await this._serviceContext.close();
|
|
5502
|
+
await this._level?.close();
|
|
5479
5503
|
this._open = false;
|
|
5480
5504
|
this._statusUpdate.emit();
|
|
5481
5505
|
(0, import_log14.log)("closed", {
|
|
5482
5506
|
deviceKey
|
|
5483
5507
|
}, {
|
|
5484
5508
|
F: __dxlog_file18,
|
|
5485
|
-
L:
|
|
5509
|
+
L: 337,
|
|
5486
5510
|
S: this,
|
|
5487
5511
|
C: (f, a) => f(...a)
|
|
5488
5512
|
});
|
|
5489
5513
|
}
|
|
5490
5514
|
async reset() {
|
|
5491
|
-
const traceId =
|
|
5515
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5492
5516
|
import_log14.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
|
|
5493
5517
|
id: traceId
|
|
5494
5518
|
}), {
|
|
5495
5519
|
F: __dxlog_file18,
|
|
5496
|
-
L:
|
|
5520
|
+
L: 342,
|
|
5497
5521
|
S: this,
|
|
5498
5522
|
C: (f, a) => f(...a)
|
|
5499
5523
|
});
|
|
5500
5524
|
(0, import_log14.log)("resetting...", void 0, {
|
|
5501
5525
|
F: __dxlog_file18,
|
|
5502
|
-
L:
|
|
5526
|
+
L: 344,
|
|
5503
5527
|
S: this,
|
|
5504
5528
|
C: (f, a) => f(...a)
|
|
5505
5529
|
});
|
|
@@ -5507,7 +5531,7 @@ var ClientServicesHost = class {
|
|
|
5507
5531
|
await this._storage.reset();
|
|
5508
5532
|
(0, import_log14.log)("reset", void 0, {
|
|
5509
5533
|
F: __dxlog_file18,
|
|
5510
|
-
L:
|
|
5534
|
+
L: 347,
|
|
5511
5535
|
S: this,
|
|
5512
5536
|
C: (f, a) => f(...a)
|
|
5513
5537
|
});
|
|
@@ -5515,7 +5539,7 @@ var ClientServicesHost = class {
|
|
|
5515
5539
|
id: traceId
|
|
5516
5540
|
}), {
|
|
5517
5541
|
F: __dxlog_file18,
|
|
5518
|
-
L:
|
|
5542
|
+
L: 348,
|
|
5519
5543
|
S: this,
|
|
5520
5544
|
C: (f, a) => f(...a)
|
|
5521
5545
|
});
|
|
@@ -5528,7 +5552,7 @@ var ClientServicesHost = class {
|
|
|
5528
5552
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5529
5553
|
(0, import_invariant16.invariant)(automergeIndex, void 0, {
|
|
5530
5554
|
F: __dxlog_file18,
|
|
5531
|
-
L:
|
|
5555
|
+
L: 360,
|
|
5532
5556
|
S: this,
|
|
5533
5557
|
A: [
|
|
5534
5558
|
"automergeIndex",
|
|
@@ -5537,18 +5561,25 @@ var ClientServicesHost = class {
|
|
|
5537
5561
|
});
|
|
5538
5562
|
const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
|
|
5539
5563
|
await document.whenReady();
|
|
5540
|
-
const
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5564
|
+
const properties = {
|
|
5565
|
+
system: {
|
|
5566
|
+
type: (0, import_echo_pipeline4.encodeReference)(E.getTypeReference(import_client_protocol5.Properties))
|
|
5567
|
+
},
|
|
5568
|
+
data: {
|
|
5569
|
+
[import_client_protocol5.defaultKey]: identity.identityKey.toHex()
|
|
5570
|
+
},
|
|
5571
|
+
meta: {
|
|
5572
|
+
keys: []
|
|
5573
|
+
}
|
|
5574
|
+
};
|
|
5575
|
+
const propertiesId = import_keys12.PublicKey.random().toHex();
|
|
5545
5576
|
document.change((doc) => {
|
|
5546
5577
|
(0, import_util9.assignDeep)(doc, [
|
|
5547
5578
|
"objects",
|
|
5548
|
-
|
|
5549
|
-
],
|
|
5579
|
+
propertiesId
|
|
5580
|
+
], properties);
|
|
5550
5581
|
});
|
|
5551
|
-
await
|
|
5582
|
+
await this._serviceContext.automergeHost.repo.flush();
|
|
5552
5583
|
return identity;
|
|
5553
5584
|
}
|
|
5554
5585
|
};
|
|
@@ -5591,6 +5622,7 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5591
5622
|
TrustedKeySetAuthVerifier,
|
|
5592
5623
|
createAuthProvider,
|
|
5593
5624
|
createDiagnostics,
|
|
5625
|
+
createLevel,
|
|
5594
5626
|
createStorageObjects,
|
|
5595
5627
|
getNetworkPeers,
|
|
5596
5628
|
invitationExpired,
|
|
@@ -5603,4 +5635,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5603
5635
|
subscribeToSpaces,
|
|
5604
5636
|
subscribeToSwarmInfo
|
|
5605
5637
|
});
|
|
5606
|
-
//# sourceMappingURL=chunk-
|
|
5638
|
+
//# sourceMappingURL=chunk-42TXJ32V.cjs.map
|