@dxos/client-services 0.3.11-main.d7d4c52 → 0.3.11-main.d8b8a39
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-CKB4252E.mjs → chunk-BF2EZUZV.mjs} +116 -75
- package/dist/lib/browser/chunk-BF2EZUZV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -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 +4 -11
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-5EUWM7NI.cjs → chunk-H5EXDUBC.cjs} +173 -132
- package/dist/lib/node/chunk-H5EXDUBC.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -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 +11 -18
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts +3 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +2 -0
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +28 -3
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -0
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +35 -35
- package/src/packlets/identity/identity-service.test.ts +1 -1
- package/src/packlets/identity/identity-service.ts +6 -3
- package/src/packlets/invitations/device-invitation-protocol.test.ts +14 -0
- package/src/packlets/invitations/device-invitation-protocol.ts +14 -0
- package/src/packlets/invitations/invitation-protocol.ts +44 -6
- package/src/packlets/invitations/invitations-handler.ts +20 -18
- package/src/packlets/invitations/space-invitation-protocol.test.ts +28 -0
- package/src/packlets/invitations/space-invitation-protocol.ts +11 -0
- package/src/packlets/services/service-host.ts +27 -12
- package/src/packlets/testing/invitation-utils.ts +2 -10
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-CKB4252E.mjs.map +0 -7
- package/dist/lib/node/chunk-5EUWM7NI.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 { 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;
|
|
6
|
-
"names": ["import_credentials", "createMockCredential", "signer", "issuer", "createCredential", "subject", "PublicKey", "Buffer", "from", "assertion", "payload", "value", "sanitizeInvitation", "invitation", "
|
|
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';\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): 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;AACxB,6BAA6F;AAC7F,uBAA0B;AAC1B,sBAA2B;ACF3B,qBAAwB;AACxB,IAAAA,sBAAq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,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", "InvitationEncoder", "decode", "encode", "performInvitation", "host", "guest", "options", "hooks", "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", "createServiceHost", "config", "signalManagerContext", "ClientServicesHost", "signalManager", "MemorySignalManager", "transportFactory", "MemoryTransportFactory", "createServiceContext", "signalContext", "MemorySignalManagerContext", "storage", "createStorage", "type", "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
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Stream } from '@dxos/codec-protobuf';
|
|
2
2
|
import { type Keyring } from '@dxos/keyring';
|
|
3
|
-
import { type Identity, type IdentityService, type QueryIdentityResponse, type RecoverIdentityRequest, type SignPresentationRequest } from '@dxos/protocols/proto/dxos/client/services';
|
|
3
|
+
import { type CreateIdentityRequest, type Identity, type IdentityService, type QueryIdentityResponse, type RecoverIdentityRequest, type SignPresentationRequest } from '@dxos/protocols/proto/dxos/client/services';
|
|
4
4
|
import { type Presentation, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
5
5
|
import { type CreateIdentityOptions, type IdentityManager } from './identity-manager';
|
|
6
6
|
export declare class IdentityServiceImpl implements IdentityService {
|
|
@@ -8,8 +8,8 @@ export declare class IdentityServiceImpl implements IdentityService {
|
|
|
8
8
|
private readonly _identityManager;
|
|
9
9
|
private readonly _keyring;
|
|
10
10
|
private readonly _onProfileUpdate?;
|
|
11
|
-
constructor(_createIdentity: (params
|
|
12
|
-
createIdentity(request:
|
|
11
|
+
constructor(_createIdentity: (params: CreateIdentityOptions, useAutomerge: boolean) => Promise<Identity>, _identityManager: IdentityManager, _keyring: Keyring, _onProfileUpdate?: ((profile: ProfileDocument | undefined) => Promise<void>) | undefined);
|
|
12
|
+
createIdentity(request: CreateIdentityRequest): Promise<Identity>;
|
|
13
13
|
recoverIdentity(request: RecoverIdentityRequest): Promise<Identity>;
|
|
14
14
|
queryIdentity(): Stream<QueryIdentityResponse>;
|
|
15
15
|
private _getIdentity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-service.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/identity/identity-service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,OAAO,EAAE,KAAK,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KAAK,QAAQ,IAAI,CAAC,aAAA;IAGvF,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKjE,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIzE,aAAa,IAAI,MAAM,CAAC,qBAAqB,CAAC;IAS9C,OAAO,CAAC,YAAY;IAYd,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAO1D,gBAAgB,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,uBAAuB,GAAG,OAAO,CAAC,YAAY,CAAC;CAWhG"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Keyring } from '@dxos/keyring';
|
|
2
|
+
import { AlreadyJoinedError } from '@dxos/protocols';
|
|
2
3
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
3
4
|
import { type AdmissionRequest, type AdmissionResponse, type IntroductionRequest } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
4
5
|
import { type InvitationProtocol } from './invitation-protocol';
|
|
@@ -11,6 +12,7 @@ export declare class DeviceInvitationProtocol implements InvitationProtocol {
|
|
|
11
12
|
toJSON(): object;
|
|
12
13
|
getInvitationContext(): Partial<Invitation> & Pick<Invitation, 'kind'>;
|
|
13
14
|
admit(request: AdmissionRequest): Promise<AdmissionResponse>;
|
|
15
|
+
checkInvitation(invitation: Partial<Invitation>): AlreadyJoinedError | undefined;
|
|
14
16
|
createIntroduction(): IntroductionRequest;
|
|
15
17
|
createAdmissionRequest(): Promise<AdmissionRequest>;
|
|
16
18
|
accept(response: AdmissionResponse, request: AdmissionRequest): Promise<Partial<Invitation>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/device-invitation-protocol.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EA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AAC;AACxE,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACzB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAErE,qBAAa,wBAAyB,YAAW,kBAAkB;IAE/D,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAFf,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,MAAM,QAAQ,EAC5B,eAAe,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAAC,QAAQ,CAAC;IAGvF,MAAM,IAAI,MAAM;IAIhB,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;IAMhE,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAelE,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;IAW/C,kBAAkB,IAAI,mBAAmB;IAInC,sBAAsB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAcnD,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;CAqBnG"}
|
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import type { ApiError } from '@dxos/protocols';
|
|
2
|
+
import type { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
3
|
+
import type { ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
4
|
+
import type { AdmissionRequest, AdmissionResponse, IntroductionRequest } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
4
5
|
export interface InvitationProtocol {
|
|
6
|
+
/**
|
|
7
|
+
* Protocol-specific debug info to include in logs.
|
|
8
|
+
*/
|
|
5
9
|
toJSON(): object;
|
|
10
|
+
/**
|
|
11
|
+
* Protocol-specific information to include in the invitation.
|
|
12
|
+
*/
|
|
6
13
|
getInvitationContext(): Partial<Invitation> & Pick<Invitation, 'kind'>;
|
|
14
|
+
/**
|
|
15
|
+
* Once authentication is successful, the host can admit the guest to the requested resource.
|
|
16
|
+
*/
|
|
7
17
|
admit(request: AdmissionRequest, guestProfile?: ProfileDocument): Promise<AdmissionResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if the invitation is valid.
|
|
20
|
+
*
|
|
21
|
+
* For example, the guest may already be a member of the space.
|
|
22
|
+
*/
|
|
23
|
+
checkInvitation(invitation: Partial<Invitation>): ApiError | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Get profile information to send to the host to identify the guest.
|
|
26
|
+
*/
|
|
8
27
|
createIntroduction(): IntroductionRequest;
|
|
28
|
+
/**
|
|
29
|
+
* Get key information to send to the host in order to create an admission credential for the guest.
|
|
30
|
+
*/
|
|
9
31
|
createAdmissionRequest(): Promise<AdmissionRequest>;
|
|
32
|
+
/**
|
|
33
|
+
* Redeem the admission credential.
|
|
34
|
+
*/
|
|
10
35
|
accept(response: AdmissionResponse, request: AdmissionRequest): Promise<Partial<Invitation>>;
|
|
11
36
|
}
|
|
12
37
|
//# sourceMappingURL=invitation-protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitation-protocol.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitation-protocol.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,6CAA6C,CAAC;AAErD,MAAM,WAAW,kBAAkB;IAKjC;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC;IAMjB;;OAEG;IACH,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAEvE;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,YAAY,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAM7F;;;;OAIG;IACH,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,SAAS,CAAC;IAEvE;;OAEG;IACH,kBAAkB,IAAI,mBAAmB,CAAC;IAE1C;;OAEG;IACH,sBAAsB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEpD;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;CAC9F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitations-handler.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitations-handler.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,wBAAwB,EAExB,qBAAqB,EAEtB,MAAM,uBAAuB,CAAC;AAa/B,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AASxE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,kBAAkB;IAIjB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAE5C,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,qBAAqB;IAiJpG,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,GAAG,wBAAwB;
|
|
1
|
+
{"version":3,"file":"invitations-handler.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitations-handler.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,wBAAwB,EAExB,qBAAqB,EAEtB,MAAM,uBAAuB,CAAC;AAa/B,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AASxE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,kBAAkB;IAIjB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAE5C,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,qBAAqB;IAiJpG,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,GAAG,wBAAwB;CAkLjG"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Keyring } from '@dxos/keyring';
|
|
2
2
|
import { type PublicKey } from '@dxos/keys';
|
|
3
|
+
import { AlreadyJoinedError } from '@dxos/protocols';
|
|
3
4
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
4
5
|
import { type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
5
6
|
import { type AdmissionRequest, type AdmissionResponse, type IntroductionRequest } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
@@ -14,6 +15,7 @@ export declare class SpaceInvitationProtocol implements InvitationProtocol {
|
|
|
14
15
|
toJSON(): object;
|
|
15
16
|
getInvitationContext(): Partial<Invitation> & Pick<Invitation, 'kind'>;
|
|
16
17
|
admit(request: AdmissionRequest, guestProfile?: ProfileDocument | undefined): Promise<AdmissionResponse>;
|
|
18
|
+
checkInvitation(invitation: Partial<Invitation>): AlreadyJoinedError | undefined;
|
|
17
19
|
createIntroduction(): IntroductionRequest;
|
|
18
20
|
createAdmissionRequest(): Promise<AdmissionRequest>;
|
|
19
21
|
accept(response: AdmissionResponse): Promise<Partial<Invitation>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space-invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/space-invitation-protocol.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAExE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACzB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAEvE,qBAAa,uBAAwB,YAAW,kBAAkB;IAE9D,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAHV,aAAa,EAAE,gBAAgB,EAC/B,eAAe,EAAE,cAAc,EAC/B,QAAQ,EAAE,OAAO,EACjB,SAAS,CAAC,uBAAW;IAGxC,MAAM,IAAI,MAAM;IAOhB,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;IAOhE,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,YAAY,CAAC,EAAE,eAAe,GAAG,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAkC9G,kBAAkB,IAAI,mBAAmB;IAMnC,sBAAsB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAenD,MAAM,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"space-invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/space-invitation-protocol.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAExE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACzB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAEvE,qBAAa,uBAAwB,YAAW,kBAAkB;IAE9D,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAHV,aAAa,EAAE,gBAA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AO,CAAC,QAAQ,CAAS;IAGzB,OAAO,CAAC,KAAK,CAAS;gBAEV,EACV,MAAM,EACN,YAA0C,EAC1C,gBAAgB,EAChB,aAAa,EACb,OAAO,EAEP,OAAO,EACP,SAAS,GACV,GAAE,wBAA6B;IAiDhC,IAAI,MAAM,YAET;IAED,IAAI,MAAM,uBAET;IAED,IAAI,OAAO,mBAEV;IAED,IAAI,eAAe,oCAElB;IAED,IAAI,WAAW,sDAEd;IAED,IAAI,QAAQ,4BAEX;IAED;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,EAAE,iBAAiB;IAiC9C,IAAI,CAAC,GAAG,EAAE,OAAO;IA6FjB,KAAK;IAgBL,KAAK;YAYG,eAAe;
|
|
1
|
+
{"version":3,"file":"service-host.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/services/service-host.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuB,KAAK,cAAc,EAA0B,MAAM,uBAAuB,CAAC;AACzG,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAOxC,OAAO,EAAE,KAAK,aAAa,EAA0B,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAoD,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIhH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAM3D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAarD,eAAO,MAAM,yBAAyB,oBAErC,CAAC;AAiBF,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,gBAAgB,CAAC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gBAAgB,EAChB,aAAa,EACb,OAAO,EAEP,OAAO,EACP,SAAS,GACV,GAAE,wBAA6B;IAiDhC,IAAI,MAAM,YAET;IAED,IAAI,MAAM,uBAET;IAED,IAAI,OAAO,mBAEV;IAED,IAAI,eAAe,oCAElB;IAED,IAAI,WAAW,sDAEd;IAED,IAAI,QAAQ,4BAEX;IAED;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,EAAE,iBAAiB;IAiC9C,IAAI,CAAC,GAAG,EAAE,OAAO;IA6FjB,KAAK;IAgBL,KAAK;YAYG,eAAe;CAiC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitation-utils.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/invitation-utils.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"invitation-utils.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/testing/invitation-utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,wBAAwB,EAAE,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAErH,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAAgB,UAAU,KAAG,UAE3D,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,qBAAqB,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,GAAG,wBAAwB,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,CAAC,IAAI;IAC1C,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,CAAC;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0.3.11-main.d8b8a39";
|
|
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.11-main.
|
|
3
|
+
"version": "0.3.11-main.d8b8a39",
|
|
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.11-main.
|
|
26
|
-
"@dxos/client-protocol": "0.3.11-main.
|
|
27
|
-
"@dxos/config": "0.3.11-main.
|
|
28
|
-
"@dxos/
|
|
29
|
-
"@dxos/context": "0.3.11-main.
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/echo-
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/echo-schema": "0.3.11-main.
|
|
37
|
-
"@dxos/feed-store": "0.3.11-main.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/node-std": "0.3.11-main.
|
|
47
|
-
"@dxos/protocols": "0.3.11-main.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/teleport-extension-
|
|
52
|
-
"@dxos/teleport-extension-
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/timeframe": "0.3.11-main.
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/util": "0.3.11-main.
|
|
57
|
-
"@dxos/websocket-rpc": "0.3.11-main.
|
|
25
|
+
"@dxos/async": "0.3.11-main.d8b8a39",
|
|
26
|
+
"@dxos/client-protocol": "0.3.11-main.d8b8a39",
|
|
27
|
+
"@dxos/config": "0.3.11-main.d8b8a39",
|
|
28
|
+
"@dxos/credentials": "0.3.11-main.d8b8a39",
|
|
29
|
+
"@dxos/context": "0.3.11-main.d8b8a39",
|
|
30
|
+
"@dxos/codec-protobuf": "0.3.11-main.d8b8a39",
|
|
31
|
+
"@dxos/crypto": "0.3.11-main.d8b8a39",
|
|
32
|
+
"@dxos/debug": "0.3.11-main.d8b8a39",
|
|
33
|
+
"@dxos/document-model": "0.3.11-main.d8b8a39",
|
|
34
|
+
"@dxos/echo-db": "0.3.11-main.d8b8a39",
|
|
35
|
+
"@dxos/echo-pipeline": "0.3.11-main.d8b8a39",
|
|
36
|
+
"@dxos/echo-schema": "0.3.11-main.d8b8a39",
|
|
37
|
+
"@dxos/feed-store": "0.3.11-main.d8b8a39",
|
|
38
|
+
"@dxos/invariant": "0.3.11-main.d8b8a39",
|
|
39
|
+
"@dxos/keyring": "0.3.11-main.d8b8a39",
|
|
40
|
+
"@dxos/lock-file": "0.3.11-main.d8b8a39",
|
|
41
|
+
"@dxos/log": "0.3.11-main.d8b8a39",
|
|
42
|
+
"@dxos/messaging": "0.3.11-main.d8b8a39",
|
|
43
|
+
"@dxos/model-factory": "0.3.11-main.d8b8a39",
|
|
44
|
+
"@dxos/keys": "0.3.11-main.d8b8a39",
|
|
45
|
+
"@dxos/network-manager": "0.3.11-main.d8b8a39",
|
|
46
|
+
"@dxos/node-std": "0.3.11-main.d8b8a39",
|
|
47
|
+
"@dxos/protocols": "0.3.11-main.d8b8a39",
|
|
48
|
+
"@dxos/rpc": "0.3.11-main.d8b8a39",
|
|
49
|
+
"@dxos/teleport": "0.3.11-main.d8b8a39",
|
|
50
|
+
"@dxos/random-access-storage": "0.3.11-main.d8b8a39",
|
|
51
|
+
"@dxos/teleport-extension-object-sync": "0.3.11-main.d8b8a39",
|
|
52
|
+
"@dxos/teleport-extension-gossip": "0.3.11-main.d8b8a39",
|
|
53
|
+
"@dxos/tracing": "0.3.11-main.d8b8a39",
|
|
54
|
+
"@dxos/timeframe": "0.3.11-main.d8b8a39",
|
|
55
|
+
"@dxos/text-model": "0.3.11-main.d8b8a39",
|
|
56
|
+
"@dxos/util": "0.3.11-main.d8b8a39",
|
|
57
|
+
"@dxos/websocket-rpc": "0.3.11-main.d8b8a39"
|
|
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.11-main.
|
|
62
|
+
"@dxos/signal": "0.3.11-main.d8b8a39"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
@@ -44,7 +44,7 @@ describe('IdentityService', () => {
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
test('creates a new identity with a display name', async () => {
|
|
47
|
-
const identity = await identityService.createIdentity({ displayName: 'Example' });
|
|
47
|
+
const identity = await identityService.createIdentity({ profile: { displayName: 'Example' } });
|
|
48
48
|
|
|
49
49
|
expect(identity.identityKey).to.be.instanceof(PublicKey);
|
|
50
50
|
expect(identity.spaceKey).to.be.instanceof(PublicKey);
|
|
@@ -8,6 +8,7 @@ import { todo } from '@dxos/debug';
|
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { type Keyring } from '@dxos/keyring';
|
|
10
10
|
import {
|
|
11
|
+
type CreateIdentityRequest,
|
|
11
12
|
type Identity,
|
|
12
13
|
type IdentityService,
|
|
13
14
|
type QueryIdentityResponse,
|
|
@@ -18,16 +19,18 @@ import { type Presentation, type ProfileDocument } from '@dxos/protocols/proto/d
|
|
|
18
19
|
|
|
19
20
|
import { type CreateIdentityOptions, type IdentityManager } from './identity-manager';
|
|
20
21
|
|
|
22
|
+
const CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT = true;
|
|
23
|
+
|
|
21
24
|
export class IdentityServiceImpl implements IdentityService {
|
|
22
25
|
constructor(
|
|
23
|
-
private readonly _createIdentity: (params
|
|
26
|
+
private readonly _createIdentity: (params: CreateIdentityOptions, useAutomerge: boolean) => Promise<Identity>,
|
|
24
27
|
private readonly _identityManager: IdentityManager,
|
|
25
28
|
private readonly _keyring: Keyring,
|
|
26
29
|
private readonly _onProfileUpdate?: (profile: ProfileDocument | undefined) => Promise<void>,
|
|
27
30
|
) {}
|
|
28
31
|
|
|
29
|
-
async createIdentity(request:
|
|
30
|
-
await this._createIdentity(request);
|
|
32
|
+
async createIdentity(request: CreateIdentityRequest): Promise<Identity> {
|
|
33
|
+
await this._createIdentity(request.profile ?? {}, request.useAutomerge ?? CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT);
|
|
31
34
|
return this._getIdentity()!;
|
|
32
35
|
}
|
|
33
36
|
|
|
@@ -6,6 +6,7 @@ import { expect } from 'chai';
|
|
|
6
6
|
|
|
7
7
|
import { asyncChain } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
|
+
import { AlreadyJoinedError } from '@dxos/protocols';
|
|
9
10
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
11
|
import { describe, test, afterTest } from '@dxos/test';
|
|
11
12
|
|
|
@@ -36,4 +37,17 @@ describe('services/device', () => {
|
|
|
36
37
|
await Promise.all(performInvitation({ host, guest, options: { kind: Invitation.Kind.DEVICE } }));
|
|
37
38
|
expect(guest.identityManager.identity?.identityKey).to.deep.eq(identity1.identityKey);
|
|
38
39
|
});
|
|
40
|
+
|
|
41
|
+
test('invitation when already joined', async () => {
|
|
42
|
+
const [host, guest] = await asyncChain<ServiceContext>([closeAfterTest])(createPeers(2));
|
|
43
|
+
|
|
44
|
+
const identity1 = await host.createIdentity();
|
|
45
|
+
expect(host.identityManager.identity).to.eq(identity1);
|
|
46
|
+
|
|
47
|
+
await Promise.all(performInvitation({ host, guest, options: { kind: Invitation.Kind.DEVICE } }));
|
|
48
|
+
expect(guest.identityManager.identity?.identityKey).to.deep.eq(identity1.identityKey);
|
|
49
|
+
|
|
50
|
+
const [_, result] = performInvitation({ host, guest, options: { kind: Invitation.Kind.DEVICE } });
|
|
51
|
+
expect((await result).error).to.be.instanceOf(AlreadyJoinedError);
|
|
52
|
+
});
|
|
39
53
|
});
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { invariant } from '@dxos/invariant';
|
|
6
6
|
import { type Keyring } from '@dxos/keyring';
|
|
7
|
+
import { AlreadyJoinedError } from '@dxos/protocols';
|
|
7
8
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
8
9
|
import {
|
|
9
10
|
type AdmissionRequest,
|
|
@@ -46,6 +47,17 @@ export class DeviceInvitationProtocol implements InvitationProtocol {
|
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
checkInvitation(invitation: Partial<Invitation>) {
|
|
51
|
+
try {
|
|
52
|
+
const identity = this._getIdentity();
|
|
53
|
+
if (identity) {
|
|
54
|
+
return new AlreadyJoinedError('Currently only one identity per client is supported.');
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
// No identity.
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
49
61
|
createIntroduction(): IntroductionRequest {
|
|
50
62
|
return {};
|
|
51
63
|
}
|
|
@@ -71,6 +83,8 @@ export class DeviceInvitationProtocol implements InvitationProtocol {
|
|
|
71
83
|
invariant(request.device);
|
|
72
84
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
73
85
|
|
|
86
|
+
// TODO(wittjosiah): When multiple identities are supported, verify identity doesn't already exist before accepting.
|
|
87
|
+
|
|
74
88
|
await this._acceptIdentity({
|
|
75
89
|
identityKey,
|
|
76
90
|
deviceKey,
|
|
@@ -2,24 +2,62 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
import type { ApiError } from '@dxos/protocols';
|
|
6
|
+
import type { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
7
|
+
import type { ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
8
|
+
import type {
|
|
9
|
+
AdmissionRequest,
|
|
10
|
+
AdmissionResponse,
|
|
11
|
+
IntroductionRequest,
|
|
11
12
|
} from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
12
13
|
|
|
13
14
|
export interface InvitationProtocol {
|
|
15
|
+
//
|
|
14
16
|
// Debugging
|
|
17
|
+
//
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Protocol-specific debug info to include in logs.
|
|
21
|
+
*/
|
|
15
22
|
toJSON(): object;
|
|
16
23
|
|
|
24
|
+
//
|
|
17
25
|
// Host
|
|
26
|
+
//
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Protocol-specific information to include in the invitation.
|
|
30
|
+
*/
|
|
18
31
|
getInvitationContext(): Partial<Invitation> & Pick<Invitation, 'kind'>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Once authentication is successful, the host can admit the guest to the requested resource.
|
|
35
|
+
*/
|
|
19
36
|
admit(request: AdmissionRequest, guestProfile?: ProfileDocument): Promise<AdmissionResponse>;
|
|
20
37
|
|
|
38
|
+
//
|
|
21
39
|
// Guest
|
|
40
|
+
//
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Check if the invitation is valid.
|
|
44
|
+
*
|
|
45
|
+
* For example, the guest may already be a member of the space.
|
|
46
|
+
*/
|
|
47
|
+
checkInvitation(invitation: Partial<Invitation>): ApiError | undefined;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get profile information to send to the host to identify the guest.
|
|
51
|
+
*/
|
|
22
52
|
createIntroduction(): IntroductionRequest;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Get key information to send to the host in order to create an admission credential for the guest.
|
|
56
|
+
*/
|
|
23
57
|
createAdmissionRequest(): Promise<AdmissionRequest>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Redeem the admission credential.
|
|
61
|
+
*/
|
|
24
62
|
accept(response: AdmissionResponse, request: AdmissionRequest): Promise<Partial<Invitation>>;
|
|
25
63
|
}
|