@dxos/client-services 0.5.1-next.5e6b3f6 → 0.5.1-next.65aaa36
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-5AW3X677.mjs → chunk-2MPSJHTS.mjs} +1263 -907
- package/dist/lib/browser/chunk-2MPSJHTS.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +31 -2
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +28 -8
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-6ABI276Y.cjs → chunk-ITFB7UCR.cjs} +1417 -1069
- package/dist/lib/node/chunk-ITFB7UCR.cjs.map +7 -0
- package/dist/lib/node/index.cjs +73 -44
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +34 -14
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +2 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts +39 -0
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/{invitation-extension.d.ts → invitation-host-extension.d.ts} +17 -31
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +6 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-topology.d.ts +37 -0
- package/dist/types/src/packlets/invitations/invitation-topology.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +19 -10
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.test.d.ts +2 -0
- package/dist/types/src/packlets/invitations/invitations-handler.test.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +2 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +1 -0
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/utils.d.ts +6 -0
- package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-context.d.ts +6 -3
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +2 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shell-runtime.d.ts +10 -2
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -36
- package/src/packlets/invitations/device-invitation-protocol.ts +5 -1
- package/src/packlets/invitations/invitation-guest-extenstion.ts +126 -0
- package/src/packlets/invitations/{invitation-extension.ts → invitation-host-extension.ts} +99 -105
- package/src/packlets/invitations/invitation-protocol.ts +7 -1
- package/src/packlets/invitations/invitation-topology.ts +87 -0
- package/src/packlets/invitations/invitations-handler.test.ts +361 -0
- package/src/packlets/invitations/invitations-handler.ts +246 -149
- package/src/packlets/invitations/invitations-manager.ts +42 -3
- package/src/packlets/invitations/space-invitation-protocol.ts +19 -1
- package/src/packlets/invitations/utils.ts +27 -0
- package/src/packlets/services/service-context.ts +5 -3
- package/src/packlets/testing/invitation-utils.ts +23 -3
- package/src/packlets/testing/test-builder.ts +3 -1
- package/src/packlets/vault/shell-runtime.ts +40 -2
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-5AW3X677.mjs.map +0 -7
- package/dist/lib/node/chunk-6ABI276Y.cjs.map +0 -7
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +0 -1
|
@@ -30,7 +30,7 @@ __export(testing_exports, {
|
|
|
30
30
|
sanitizeInvitation: () => sanitizeInvitation
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(testing_exports);
|
|
33
|
-
var
|
|
33
|
+
var import_chunk_ITFB7UCR = require("../../chunk-ITFB7UCR.cjs");
|
|
34
34
|
var import_credentials = require("@dxos/credentials");
|
|
35
35
|
var import_keys = require("@dxos/keys");
|
|
36
36
|
var import_async = require("@dxos/async");
|
|
@@ -66,7 +66,9 @@ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src
|
|
|
66
66
|
var sanitizeInvitation = (invitation) => {
|
|
67
67
|
return import_client_protocol.InvitationEncoder.decode(import_client_protocol.InvitationEncoder.encode(invitation));
|
|
68
68
|
};
|
|
69
|
-
var performInvitation = ({ host, guest, options, hooks, guestDeviceProfile }) => {
|
|
69
|
+
var performInvitation = ({ host, guest, options, hooks, guestDeviceProfile, codeInputDelay }) => {
|
|
70
|
+
let guestError = false;
|
|
71
|
+
let guestConnected = false;
|
|
70
72
|
const hostComplete = new import_async.Trigger();
|
|
71
73
|
const guestComplete = new import_async.Trigger();
|
|
72
74
|
const authCode = new import_async.Trigger();
|
|
@@ -74,6 +76,10 @@ var performInvitation = ({ host, guest, options, hooks, guestDeviceProfile }) =>
|
|
|
74
76
|
hostObservable.subscribe(async (hostInvitation) => {
|
|
75
77
|
switch (hostInvitation.state) {
|
|
76
78
|
case import_services.Invitation.State.CONNECTING: {
|
|
79
|
+
if (guestConnected) {
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
guestConnected = true;
|
|
77
83
|
if (hooks?.host?.onConnecting?.(hostObservable)) {
|
|
78
84
|
break;
|
|
79
85
|
}
|
|
@@ -86,7 +92,7 @@ var performInvitation = ({ host, guest, options, hooks, guestDeviceProfile }) =>
|
|
|
86
92
|
}
|
|
87
93
|
(0, import_invariant.invariant)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey), void 0, {
|
|
88
94
|
F: __dxlog_file,
|
|
89
|
-
L:
|
|
95
|
+
L: 87,
|
|
90
96
|
S: void 0,
|
|
91
97
|
A: [
|
|
92
98
|
"hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!)",
|
|
@@ -103,7 +109,16 @@ var performInvitation = ({ host, guest, options, hooks, guestDeviceProfile }) =>
|
|
|
103
109
|
if (hooks?.guest?.onReady?.(guestObservable)) {
|
|
104
110
|
break;
|
|
105
111
|
}
|
|
106
|
-
|
|
112
|
+
const code = await authCode.wait();
|
|
113
|
+
if (codeInputDelay == null) {
|
|
114
|
+
await guestObservable.authenticate(code);
|
|
115
|
+
} else {
|
|
116
|
+
setTimeout(async () => {
|
|
117
|
+
if (!guestError) {
|
|
118
|
+
await guestObservable.authenticate(code);
|
|
119
|
+
}
|
|
120
|
+
}, codeInputDelay);
|
|
121
|
+
}
|
|
107
122
|
break;
|
|
108
123
|
}
|
|
109
124
|
case import_services.Invitation.State.AUTHENTICATING: {
|
|
@@ -138,6 +153,7 @@ var performInvitation = ({ host, guest, options, hooks, guestDeviceProfile }) =>
|
|
|
138
153
|
}
|
|
139
154
|
}
|
|
140
155
|
}, (error) => {
|
|
156
|
+
guestError = true;
|
|
141
157
|
if (hooks?.guest?.onError?.(guestObservable)) {
|
|
142
158
|
return;
|
|
143
159
|
}
|
|
@@ -211,7 +227,7 @@ var createInvitation = async (host, options) => {
|
|
|
211
227
|
authMethod: import_services.Invitation.AuthMethod.NONE,
|
|
212
228
|
...options ?? {}
|
|
213
229
|
};
|
|
214
|
-
if (host instanceof
|
|
230
|
+
if (host instanceof import_chunk_ITFB7UCR.ServiceContext) {
|
|
215
231
|
return host.invitationsManager.createInvitation({
|
|
216
232
|
kind: import_services.Invitation.Kind.SPACE,
|
|
217
233
|
...options
|
|
@@ -221,16 +237,16 @@ var createInvitation = async (host, options) => {
|
|
|
221
237
|
};
|
|
222
238
|
var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
|
|
223
239
|
invitation = sanitizeInvitation(invitation);
|
|
224
|
-
if (guest instanceof
|
|
225
|
-
|
|
226
|
-
|
|
240
|
+
if (guest instanceof import_chunk_ITFB7UCR.ServiceContext) {
|
|
241
|
+
return guest.invitationsManager.acceptInvitation({
|
|
242
|
+
invitation,
|
|
243
|
+
deviceProfile: guestDeviceProfile
|
|
227
244
|
});
|
|
228
|
-
return guest.invitations.acceptInvitation(guestHandler, invitation, guestDeviceProfile);
|
|
229
245
|
}
|
|
230
246
|
return guest.join(invitation, guestDeviceProfile);
|
|
231
247
|
};
|
|
232
248
|
var createServiceHost = (config, signalManagerContext) => {
|
|
233
|
-
return new
|
|
249
|
+
return new import_chunk_ITFB7UCR.ClientServicesHost({
|
|
234
250
|
config,
|
|
235
251
|
signalManager: new import_messaging.MemorySignalManager(signalManagerContext),
|
|
236
252
|
transportFactory: import_network_manager.MemoryTransportFactory
|
|
@@ -246,7 +262,11 @@ var createServiceContext = async ({ signalContext = new import_messaging.MemoryS
|
|
|
246
262
|
});
|
|
247
263
|
const level = (0, import_testing.createTestLevel)();
|
|
248
264
|
await level.open();
|
|
249
|
-
return new
|
|
265
|
+
return new import_chunk_ITFB7UCR.ServiceContext(storage, level, networkManager, signalManager, {
|
|
266
|
+
invitationConnectionDefaultParams: {
|
|
267
|
+
controlHeartbeatInterval: 200
|
|
268
|
+
}
|
|
269
|
+
});
|
|
250
270
|
};
|
|
251
271
|
var createPeers = async (numPeers) => {
|
|
252
272
|
const signalContext = new import_messaging.MemorySignalManagerContext();
|
|
@@ -343,12 +363,12 @@ var TestPeer = class {
|
|
|
343
363
|
});
|
|
344
364
|
}
|
|
345
365
|
get dataSpaceManager() {
|
|
346
|
-
return this._props.dataSpaceManager ??= new
|
|
366
|
+
return this._props.dataSpaceManager ??= new import_chunk_ITFB7UCR.DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, this.identity, this.feedStore, this.echoHost, this.invitationsManager);
|
|
347
367
|
}
|
|
348
368
|
get invitationsManager() {
|
|
349
|
-
return this._props.invitationsManager ??= new
|
|
369
|
+
return this._props.invitationsManager ??= new import_chunk_ITFB7UCR.InvitationsManager(new import_chunk_ITFB7UCR.InvitationsHandler(this.networkManager), (invitation) => {
|
|
350
370
|
if (invitation.kind === import_services2.Invitation.Kind.SPACE) {
|
|
351
|
-
return new
|
|
371
|
+
return new import_chunk_ITFB7UCR.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
|
|
352
372
|
} else {
|
|
353
373
|
throw new Error("not implemented");
|
|
354
374
|
}
|
|
@@ -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 void createInvitation(host, options).then((hostObservable) => {\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\n return [hostComplete.wait(), guestComplete.wait()];\n};\n\nconst createInvitation = async (\n host: ServiceContext | InvitationHost,\n options?: Partial<Invitation>,\n): Promise<CancellableInvitation> => {\n options ??= {\n authMethod: Invitation.AuthMethod.NONE,\n ...(options ?? {}),\n };\n\n if (host instanceof ServiceContext) {\n return host.invitationsManager.createInvitation({\n kind: Invitation.Kind.SPACE,\n ...options,\n });\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 { EchoHost } from '@dxos/echo-db';\nimport { MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from '@dxos/echo-pipeline';\nimport { FeedFactory, FeedStore } from '@dxos/feed-store';\nimport { Keyring } from '@dxos/keyring';\nimport { type LevelDB } from '@dxos/kv-store';\nimport { createTestLevel } from '@dxos/kv-store/testing';\nimport { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';\nimport { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\nimport { createStorage, StorageType, type Storage } from '@dxos/random-access-storage';\nimport { BlobStore } from '@dxos/teleport-extension-object-sync';\n\nimport { InvitationsHandler, InvitationsManager, SpaceInvitationProtocol } from '../invitations';\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 = createTestLevel();\n await level.open();\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 level?: LevelDB;\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 echoHost?: EchoHost;\n invitationsManager?: InvitationsManager;\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 level() {\n return (this._props.level ??= createTestLevel());\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 echoHost() {\n return (this._props.echoHost ??= new EchoHost({\n kv: this.level,\n storage: this.storage,\n }));\n }\n\n get dataSpaceManager(): 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.echoHost,\n this.invitationsManager,\n ));\n }\n\n get invitationsManager() {\n return (this._props.invitationsManager ??= new InvitationsManager(\n new InvitationsHandler(this.networkManager),\n (invitation) => {\n if (invitation.kind === Invitation.Kind.SPACE) {\n return new SpaceInvitationProtocol(this.dataSpaceManager, this.identity!, this.keyring, invitation.spaceKey!);\n } else {\n throw new Error('not implemented');\n }\n },\n this.metadataStore,\n ));\n }\n\n async createIdentity() {\n this._props.signingContext ??= await createSigningContext(this.keyring);\n }\n\n async destroy() {\n await this.level.close();\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,sBAAqE;AACrE,mBAA8B;AAC9B,qBAAyB;AACzB,2BAA0E;AAC1E,wBAAuC;AACvC,qBAAwB;AAExB,qBAAgC;AAChC,uBAAgE;AAChE,6BAAuD;AACvD,IAAAC,mBAA2B;AAC3B,mCAAyD;AACzD,4CAA0B;AFTnB,IAAMC,uBAAuB,OAAO,EACzCC,QACAC,OAAM,UAKNC,qCAAiB;EACfF;EACAC;EACAE,SAAS,IAAIC,sBAAUC,OAAOC,KAAK,MAAA,CAAA;EACnCC,WAAW;IACT,SAAS;IACTC,SAAS;MACP,SAAS;MACTC,OAAOJ,OAAOC,KAAK,MAAA;IACrB;EACF;AACF,CAAA;;ACZK,IAAMI,qBAAqB,CAACC,eAAAA;AACjC,SAAOC,yCAAkBC,OAAOD,yCAAkBE,OAAOH,UAAAA,CAAAA;AAC3D;
|
|
6
|
-
"names": ["import_credentials", "import_services", "createMockCredential", "signer", "issuer", "createCredential", "subject", "PublicKey", "Buffer", "from", "assertion", "payload", "value", "sanitizeInvitation", "invitation", "InvitationEncoder", "decode", "encode", "performInvitation", "host", "guest", "options", "hooks", "guestDeviceProfile", "hostComplete", "Trigger", "guestComplete", "authCode", "createInvitation", "then", "hostObservable", "subscribe", "hostInvitation", "state", "Invitation", "State", "CONNECTING", "onConnecting", "guestObservable", "acceptInvitation", "guestInvitation", "invariant", "swarmKey", "equals", "CONNECTED", "onConnected", "READY_FOR_AUTHENTICATION", "onReady", "
|
|
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 codeInputDelay?: number;\n};\n\nexport type Result = { invitation?: Invitation; error?: Error };\n\nexport const performInvitation = ({\n host,\n guest,\n options,\n hooks,\n guestDeviceProfile,\n codeInputDelay,\n}: PerformInvitationParams): [Promise<Result>, Promise<Result>] => {\n let guestError = false;\n let guestConnected = false;\n const hostComplete = new Trigger<Result>();\n const guestComplete = new Trigger<Result>();\n const authCode = new Trigger<string>();\n\n void createInvitation(host, options).then((hostObservable) => {\n hostObservable.subscribe(\n async (hostInvitation: Invitation) => {\n switch (hostInvitation.state) {\n case Invitation.State.CONNECTING: {\n if (guestConnected) {\n break;\n }\n guestConnected = true;\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 const code = await authCode.wait();\n if (codeInputDelay == null) {\n await guestObservable.authenticate(code);\n } else {\n setTimeout(async () => {\n if (!guestError) {\n await guestObservable.authenticate(code);\n }\n }, codeInputDelay);\n }\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 guestError = true;\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\n return [hostComplete.wait(), guestComplete.wait()];\n};\n\nconst createInvitation = async (\n host: ServiceContext | InvitationHost,\n options?: Partial<Invitation>,\n): Promise<CancellableInvitation> => {\n options ??= {\n authMethod: Invitation.AuthMethod.NONE,\n ...(options ?? {}),\n };\n\n if (host instanceof ServiceContext) {\n return host.invitationsManager.createInvitation({\n kind: Invitation.Kind.SPACE,\n ...options,\n });\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 return guest.invitationsManager.acceptInvitation({\n invitation,\n deviceProfile: guestDeviceProfile,\n });\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 { EchoHost } from '@dxos/echo-db';\nimport { MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from '@dxos/echo-pipeline';\nimport { FeedFactory, FeedStore } from '@dxos/feed-store';\nimport { Keyring } from '@dxos/keyring';\nimport { type LevelDB } from '@dxos/kv-store';\nimport { createTestLevel } from '@dxos/kv-store/testing';\nimport { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';\nimport { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\nimport { createStorage, StorageType, type Storage } from '@dxos/random-access-storage';\nimport { BlobStore } from '@dxos/teleport-extension-object-sync';\n\nimport { InvitationsHandler, InvitationsManager, SpaceInvitationProtocol } from '../invitations';\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 = createTestLevel();\n await level.open();\n\n return new ServiceContext(storage, level, networkManager, signalManager, {\n invitationConnectionDefaultParams: { controlHeartbeatInterval: 200 },\n });\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 level?: LevelDB;\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 echoHost?: EchoHost;\n invitationsManager?: InvitationsManager;\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 level() {\n return (this._props.level ??= createTestLevel());\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 echoHost() {\n return (this._props.echoHost ??= new EchoHost({\n kv: this.level,\n storage: this.storage,\n }));\n }\n\n get dataSpaceManager(): 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.echoHost,\n this.invitationsManager,\n ));\n }\n\n get invitationsManager() {\n return (this._props.invitationsManager ??= new InvitationsManager(\n new InvitationsHandler(this.networkManager),\n (invitation) => {\n if (invitation.kind === Invitation.Kind.SPACE) {\n return new SpaceInvitationProtocol(this.dataSpaceManager, this.identity!, this.keyring, invitation.spaceKey!);\n } else {\n throw new Error('not implemented');\n }\n },\n this.metadataStore,\n ));\n }\n\n async createIdentity() {\n this._props.signingContext ??= await createSigningContext(this.keyring);\n }\n\n async destroy() {\n await this.level.close();\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,sBAAqE;AACrE,mBAA8B;AAC9B,qBAAyB;AACzB,2BAA0E;AAC1E,wBAAuC;AACvC,qBAAwB;AAExB,qBAAgC;AAChC,uBAAgE;AAChE,6BAAuD;AACvD,IAAAC,mBAA2B;AAC3B,mCAAyD;AACzD,4CAA0B;AFTnB,IAAMC,uBAAuB,OAAO,EACzCC,QACAC,OAAM,UAKNC,qCAAiB;EACfF;EACAC;EACAE,SAAS,IAAIC,sBAAUC,OAAOC,KAAK,MAAA,CAAA;EACnCC,WAAW;IACT,SAAS;IACTC,SAAS;MACP,SAAS;MACTC,OAAOJ,OAAOC,KAAK,MAAA;IACrB;EACF;AACF,CAAA;;ACZK,IAAMI,qBAAqB,CAACC,eAAAA;AACjC,SAAOC,yCAAkBC,OAAOD,yCAAkBE,OAAOH,UAAAA,CAAAA;AAC3D;AAmCO,IAAMI,oBAAoB,CAAC,EAChCC,MACAC,OACAC,SACAC,OACAC,oBACAC,eAAc,MACU;AACxB,MAAIC,aAAa;AACjB,MAAIC,iBAAiB;AACrB,QAAMC,eAAe,IAAIC,qBAAAA;AACzB,QAAMC,gBAAgB,IAAID,qBAAAA;AAC1B,QAAME,WAAW,IAAIF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BC,YAAY,MAAMC;EACpB;AACF;",
|
|
6
|
+
"names": ["import_credentials", "import_services", "createMockCredential", "signer", "issuer", "createCredential", "subject", "PublicKey", "Buffer", "from", "assertion", "payload", "value", "sanitizeInvitation", "invitation", "InvitationEncoder", "decode", "encode", "performInvitation", "host", "guest", "options", "hooks", "guestDeviceProfile", "codeInputDelay", "guestError", "guestConnected", "hostComplete", "Trigger", "guestComplete", "authCode", "createInvitation", "then", "hostObservable", "subscribe", "hostInvitation", "state", "Invitation", "State", "CONNECTING", "onConnecting", "guestObservable", "acceptInvitation", "guestInvitation", "invariant", "swarmKey", "equals", "CONNECTED", "onConnected", "READY_FOR_AUTHENTICATION", "onReady", "code", "wait", "authenticate", "setTimeout", "AUTHENTICATING", "onAuthenticating", "SUCCESS", "onSuccess", "wake", "CANCELLED", "onCancelled", "TIMEOUT", "onTimeout", "error", "onError", "authMethod", "AuthMethod", "NONE", "ServiceContext", "invitationsManager", "kind", "Kind", "SPACE", "share", "deviceProfile", "join", "createServiceHost", "config", "signalManagerContext", "ClientServicesHost", "signalManager", "MemorySignalManager", "transportFactory", "MemoryTransportFactory", "createServiceContext", "signalContext", "MemorySignalManagerContext", "storage", "createStorage", "type", "StorageType", "RAM", "networkManager", "NetworkManager", "level", "createTestLevel", "open", "invitationConnectionDefaultParams", "controlHeartbeatInterval", "createPeers", "numPeers", "Promise", "all", "Array", "map", "peer", "Context", "createIdentity", "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", "echoHost", "EchoHost", "kv", "dataSpaceManager", "DataSpaceManager", "InvitationsManager", "InvitationsHandler", "SpaceInvitationProtocol", "spaceKey", "Error", "createSigningContext", "close", "reset", "identityKey", "createKey", "deviceKey", "credentialSigner", "createCredentialSignerWithChain", "credential", "CredentialGenerator", "createDeviceAuthorization", "recordCredential", "getProfile", "undefined"]
|
|
7
7
|
}
|
|
@@ -13,7 +13,8 @@ export declare class DeviceInvitationProtocol implements InvitationProtocol {
|
|
|
13
13
|
constructor(_keyring: Keyring, _getIdentity: () => Identity, _acceptIdentity: (identity: JoinIdentityParams) => Promise<Identity>);
|
|
14
14
|
toJSON(): object;
|
|
15
15
|
getInvitationContext(): Partial<Invitation> & Pick<Invitation, 'kind'>;
|
|
16
|
-
delegate(
|
|
16
|
+
delegate(): Promise<PublicKey>;
|
|
17
|
+
cancelDelegation(): Promise<void>;
|
|
17
18
|
admit(_: Invitation, request: AdmissionRequest): Promise<AdmissionResponse>;
|
|
18
19
|
checkInvitation(invitation: Partial<Invitation>): AlreadyJoinedError | undefined;
|
|
19
20
|
createIntroduction(): IntroductionRequest;
|
|
@@ -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,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACzF,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,wB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5B,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,QAAQ,IAAI,OAAO,CAAC,SAAS,CAAC;IAI9B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAejF,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;IAW/C,kBAAkB,IAAI,mBAAmB;IAInC,sBAAsB,CAAC,aAAa,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAexF,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;CAsBnG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Mutex } from '@dxos/async';
|
|
2
|
+
import { Context } from '@dxos/context';
|
|
3
|
+
import { type Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
4
|
+
import { type InvitationHostService } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
5
|
+
import { type ExtensionContext, RpcExtension } from '@dxos/teleport';
|
|
6
|
+
type InvitationGuestExtensionCallbacks = {
|
|
7
|
+
onOpen: (ctx: Context, extensionCtx: ExtensionContext) => void;
|
|
8
|
+
onError: (error: Error) => void;
|
|
9
|
+
onStateUpdate: (newState: Invitation.State) => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Guest's side for a connection to a concrete peer in p2p network during invitation.
|
|
13
|
+
*/
|
|
14
|
+
export declare class InvitationGuestExtension extends RpcExtension<{
|
|
15
|
+
InvitationHostService: InvitationHostService;
|
|
16
|
+
}, {
|
|
17
|
+
InvitationHostService: InvitationHostService;
|
|
18
|
+
}> {
|
|
19
|
+
private readonly _invitationFlowMutex;
|
|
20
|
+
private readonly _callbacks;
|
|
21
|
+
private _ctx;
|
|
22
|
+
private _remoteOptions?;
|
|
23
|
+
private _remoteOptionsTrigger;
|
|
24
|
+
/**
|
|
25
|
+
* Held to allow only one invitation flow at a time to be active.
|
|
26
|
+
*/
|
|
27
|
+
private _invitationFlowLock;
|
|
28
|
+
constructor(_invitationFlowMutex: Mutex, _callbacks: InvitationGuestExtensionCallbacks);
|
|
29
|
+
hasFlowLock(): boolean;
|
|
30
|
+
protected getHandlers(): Promise<{
|
|
31
|
+
InvitationHostService: InvitationHostService;
|
|
32
|
+
}>;
|
|
33
|
+
onOpen(context: ExtensionContext): Promise<void>;
|
|
34
|
+
onClose(): Promise<void>;
|
|
35
|
+
onAbort(): Promise<void>;
|
|
36
|
+
private _destroy;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=invitation-guest-extenstion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invitation-guest-extenstion.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitation-guest-extenstion.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAA4B,MAAM,aAAa,CAAC;AACnE,OAAO,EAAqB,OAAO,EAAE,MAAM,eAAe,CAAC;AAI3D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,KAAK,qBAAqB,EAAW,MAAM,6CAA6C,CAAC;AAClG,OAAO,EAAE,KAAK,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAMrE,KAAK,iCAAiC,GAAG;IAEvC,MAAM,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC/D,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEhC,aAAa,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC,KAAK,KAAK,IAAI,CAAC;CACrD,CAAC;AAEF;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,YAAY,CACxD;IAAE,qBAAqB,EAAE,qBAAqB,CAAA;CAAE,EAChD;IAAE,qBAAqB,EAAE,qBAAqB,CAAA;CAAE,CACjD;IAUG,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAV7B,OAAO,CAAC,IAAI,CAAiB;IAC7B,OAAO,CAAC,cAAc,CAAC,CAAU;IACjC,OAAO,CAAC,qBAAqB,CAAiB;IAC9C;;OAEG;IACH,OAAO,CAAC,mBAAmB,CAA2B;gBAGnC,oBAAoB,EAAE,KAAK,EAC3B,UAAU,EAAE,iCAAiC;IAYzD,WAAW,IAAI,OAAO;cAIJ,WAAW,IAAI,OAAO,CAAC;QAAE,qBAAqB,EAAE,qBAAqB,CAAA;KAAE,CAAC;IAqBlF,MAAM,CAAC,OAAO,EAAE,gBAAgB;IA8BhC,OAAO;IAIP,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAIzB,QAAQ;CAQvB"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Trigger } from '@dxos/async';
|
|
1
|
+
import { type Mutex, Trigger } from '@dxos/async';
|
|
2
2
|
import { Context } from '@dxos/context';
|
|
3
3
|
import { PublicKey } from '@dxos/keys';
|
|
4
4
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
5
5
|
import { type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
6
|
-
import { type AdmissionRequest, type AdmissionResponse, type
|
|
6
|
+
import { type AdmissionRequest, type AdmissionResponse, type InvitationHostService } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
7
7
|
import { type ExtensionContext, RpcExtension } from '@dxos/teleport';
|
|
8
8
|
export declare const MAX_OTP_ATTEMPTS = 3;
|
|
9
9
|
type InvitationHostExtensionCallbacks = {
|
|
10
|
-
|
|
10
|
+
activeInvitation: Invitation | null;
|
|
11
|
+
onOpen: (ctx: Context, extensionCtx: ExtensionContext) => void;
|
|
11
12
|
onError: (error: Error) => void;
|
|
12
|
-
onStateUpdate: (
|
|
13
|
-
resolveInvitation: (request: IntroductionRequest) => Promise<Invitation | undefined>;
|
|
13
|
+
onStateUpdate: (newState: Invitation.State) => void;
|
|
14
14
|
admit: (request: AdmissionRequest) => Promise<AdmissionResponse>;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
@@ -21,11 +21,11 @@ export declare class InvitationHostExtension extends RpcExtension<{
|
|
|
21
21
|
}, {
|
|
22
22
|
InvitationHostService: InvitationHostService;
|
|
23
23
|
}> {
|
|
24
|
+
private readonly _invitationFlowMutex;
|
|
24
25
|
private readonly _callbacks;
|
|
25
26
|
private _remoteOptions?;
|
|
26
27
|
private _remoteOptionsTrigger;
|
|
27
28
|
private _challenge?;
|
|
28
|
-
invitation?: Invitation;
|
|
29
29
|
guestProfile?: ProfileDocument;
|
|
30
30
|
authenticationPassed: boolean;
|
|
31
31
|
/**
|
|
@@ -36,36 +36,22 @@ export declare class InvitationHostExtension extends RpcExtension<{
|
|
|
36
36
|
* Resolved when admission is completed.
|
|
37
37
|
*/
|
|
38
38
|
completedTrigger: Trigger<PublicKey>;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
type InvitationGuestExtensionCallbacks = {
|
|
47
|
-
onOpen: (ctx: Context) => void;
|
|
48
|
-
onError: (error: Error) => void;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Guest's side for a connection to a concrete peer in p2p network during invitation.
|
|
52
|
-
*/
|
|
53
|
-
export declare class InvitationGuestExtension extends RpcExtension<{
|
|
54
|
-
InvitationHostService: InvitationHostService;
|
|
55
|
-
}, {
|
|
56
|
-
InvitationHostService: InvitationHostService;
|
|
57
|
-
}> {
|
|
58
|
-
private readonly _callbacks;
|
|
59
|
-
private _ctx;
|
|
60
|
-
private _remoteOptions?;
|
|
61
|
-
private _remoteOptionsTrigger;
|
|
62
|
-
constructor(_callbacks: InvitationGuestExtensionCallbacks);
|
|
39
|
+
/**
|
|
40
|
+
* Held to allow only one invitation flow at a time to be active.
|
|
41
|
+
*/
|
|
42
|
+
private _invitationFlowLock;
|
|
43
|
+
constructor(_invitationFlowMutex: Mutex, _callbacks: InvitationHostExtensionCallbacks);
|
|
44
|
+
hasFlowLock(): boolean;
|
|
63
45
|
protected getHandlers(): Promise<{
|
|
64
46
|
InvitationHostService: InvitationHostService;
|
|
65
47
|
}>;
|
|
66
48
|
onOpen(context: ExtensionContext): Promise<void>;
|
|
49
|
+
private _requireActiveInvitation;
|
|
50
|
+
private _assertInvitationState;
|
|
67
51
|
onClose(): Promise<void>;
|
|
52
|
+
onAbort(): Promise<void>;
|
|
53
|
+
private _destroy;
|
|
68
54
|
}
|
|
69
55
|
export declare const isAuthenticationRequired: (invitation: Invitation) => boolean;
|
|
70
56
|
export {};
|
|
71
|
-
//# sourceMappingURL=invitation-extension.d.ts.map
|
|
57
|
+
//# sourceMappingURL=invitation-host-extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invitation-host-extension.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitation-host-extension.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAmB,OAAO,EAAgB,MAAM,aAAa,CAAC;AACjF,OAAO,EAAqB,OAAO,EAAE,MAAM,eAAe,CAAC;AAG3D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EACL,KAAK,gBAAgB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KAAE,CAAC;IA0IlF,MAAM,CAAC,OAAO,EAAE,gBAAgB;IAkC/C,OAAO,CAAC,wBAAwB;IAShC,OAAO,CAAC,sBAAsB;IAWf,OAAO;IAIP,OAAO;YAIR,QAAQ;CAQvB;AAED,eAAO,MAAM,wBAAwB,eAAgB,UAAU,YACT,CAAC"}
|
|
@@ -13,9 +13,14 @@ export interface InvitationProtocol {
|
|
|
13
13
|
*/
|
|
14
14
|
getInvitationContext(): Partial<Invitation> & Pick<Invitation, 'kind'>;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Allow authorized peers to handle this invitation behalf of invitation creator.
|
|
17
|
+
* @return id of the delegation credential written to subject control-feed.
|
|
17
18
|
*/
|
|
18
19
|
delegate(invitation: Invitation): Promise<PublicKey>;
|
|
20
|
+
/**
|
|
21
|
+
* Notify other peers that a delegated invitation was cancelled;
|
|
22
|
+
*/
|
|
23
|
+
cancelDelegation(invitation: Invitation): Promise<void>;
|
|
19
24
|
/**
|
|
20
25
|
* Once authentication is successful, the host can admit the guest to the requested resource.
|
|
21
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitation-protocol.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAC1G,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,OA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AgB,CAAC,CAAC;IAEzF;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;CAC9F"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PublicKey } from '@dxos/keys';
|
|
2
|
+
import type { SwarmController, Topology } from '@dxos/network-manager';
|
|
3
|
+
import { Options } from '@dxos/protocols/proto/dxos/halo/invitations';
|
|
4
|
+
/**
|
|
5
|
+
* Hosts are listening on an invitation topic.
|
|
6
|
+
* They initiate a connection with any new peer if they are not currently in the invitation flow
|
|
7
|
+
* with another peer (connected.length > 0).
|
|
8
|
+
* When the invitation flow ends guest leaves the swarm and topology is updated once again,
|
|
9
|
+
* so we can connect to the next peer we haven't tried yet.
|
|
10
|
+
* If the peer turns out to be a host or a malicious guest their ID is remembered so that we don't try
|
|
11
|
+
* to establish a connection with them again.
|
|
12
|
+
*
|
|
13
|
+
* Guests don't initiate connections. They accept all connections because if we reject,
|
|
14
|
+
* the host won't retry their offer.
|
|
15
|
+
* Even if we started an invitation flow with one host we might want to try other hosts in case
|
|
16
|
+
* the first one failed due to a network error, so multiple connections are accepted.
|
|
17
|
+
*/
|
|
18
|
+
export declare class InvitationTopology implements Topology {
|
|
19
|
+
private readonly _role;
|
|
20
|
+
private _controller?;
|
|
21
|
+
/**
|
|
22
|
+
* Peers we tried to establish a connection with.
|
|
23
|
+
* In invitation flow peers are assigned random ids when they join the swarm, so we'll retry
|
|
24
|
+
* a peer if they reload an invitation.
|
|
25
|
+
*
|
|
26
|
+
* Consider keeping a separate set for peers we know are hosts and have some retry timeout
|
|
27
|
+
* for guests we failed an invitation flow with (potentially due to a network error).
|
|
28
|
+
*/
|
|
29
|
+
private _seenPeers;
|
|
30
|
+
constructor(_role: Options.Role);
|
|
31
|
+
init(controller: SwarmController): void;
|
|
32
|
+
update(): void;
|
|
33
|
+
onOffer(peer: PublicKey): Promise<boolean>;
|
|
34
|
+
destroy(): Promise<void>;
|
|
35
|
+
toString(): string;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=invitation-topology.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invitation-topology.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitation-topology.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,6CAA6C,CAAC;AAGtE;;;;;;;;;;;;;GAaG;AACH,qBAAa,kBAAmB,YAAW,QAAQ;IAarC,OAAO,CAAC,QAAQ,CAAC,KAAK;IAZlC,OAAO,CAAC,WAAW,CAAC,CAAkB;IAEtC;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU,CAA6C;gBAElC,KAAK,EAAE,OAAO,CAAC,IAAI;IAEhD,IAAI,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI;IAKvC,MAAM,IAAI,IAAI;IA6BR,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IAK1C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,QAAQ;CAGT"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { PushStream } from '@dxos/async';
|
|
2
|
-
import {
|
|
3
|
-
import { Context } from '@dxos/context';
|
|
1
|
+
import { type PushStream, type Trigger } from '@dxos/async';
|
|
2
|
+
import { type Context } from '@dxos/context';
|
|
4
3
|
import { type AdmissionKeypair, Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
5
4
|
import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
6
5
|
import { type InvitationProtocol } from './invitation-protocol';
|
|
@@ -11,30 +10,40 @@ import { type InvitationProtocol } from './invitation-protocol';
|
|
|
11
10
|
* Host
|
|
12
11
|
* - Creates an invitation containing a swarm topic (which can be shared via a URL, QR code, or direct message).
|
|
13
12
|
* - Joins the swarm with the topic and waits for guest's introduction.
|
|
14
|
-
* - Wait for guest to authenticate with
|
|
13
|
+
* - Wait for guest to authenticate with challenge specified in the invitation.
|
|
15
14
|
* - Waits for guest to present credentials (containing local device and feed keys).
|
|
16
|
-
* - Writes credentials to control feed then exits.
|
|
15
|
+
* - Writes credentials to control feed then exits or waits for more guests (multi use invitations).
|
|
17
16
|
*
|
|
18
17
|
* Guest
|
|
19
18
|
* - Joins the swarm with the topic.
|
|
20
19
|
* - Sends an introduction.
|
|
21
|
-
* -
|
|
20
|
+
* - Submits the challenge.
|
|
22
21
|
* - If Space handler then creates a local cloned space (with genesis block).
|
|
23
22
|
* - Sends admission credentials.
|
|
24
|
-
*
|
|
25
|
-
* TODO(burdon): Show proxy/service relationship and reference design doc/diagram.
|
|
26
|
-
*
|
|
27
23
|
* ```
|
|
28
24
|
* [Guest] [Host]
|
|
29
25
|
* |------------------------------------Introduce-->|
|
|
30
26
|
* |-------------------------------[Authenticate]-->|
|
|
31
27
|
* |----------------------------------------Admit-->|
|
|
32
28
|
* ```
|
|
29
|
+
*
|
|
30
|
+
* TODO: consider refactoring using xstate making the logic separation more explicit:
|
|
31
|
+
* TODO: the flow logic should either be contained in invitations-handler or in extensions, not be split across
|
|
32
|
+
* TODO: potentially re-evaluate host-side API to allow multiple concurrent connection, so that mutex can be removed
|
|
33
33
|
*/
|
|
34
34
|
export declare class InvitationsHandler {
|
|
35
35
|
private readonly _networkManager;
|
|
36
|
+
private readonly _defaultTeleportParams?;
|
|
36
37
|
handleInvitationFlow(ctx: Context, stream: PushStream<Invitation>, protocol: InvitationProtocol, invitation: Invitation): void;
|
|
37
|
-
acceptInvitation(protocol: InvitationProtocol, invitation: Invitation, deviceProfile?: DeviceProfileDocument):
|
|
38
|
+
acceptInvitation(ctx: Context, stream: PushStream<Invitation>, protocol: InvitationProtocol, invitation: Invitation, otpEnteredTrigger: Trigger<string>, deviceProfile?: DeviceProfileDocument): void;
|
|
39
|
+
private _joinSwarm;
|
|
40
|
+
/**
|
|
41
|
+
* A utility object for serializing invitation state changes by multiple concurrent
|
|
42
|
+
* invitation flow connections.
|
|
43
|
+
*/
|
|
44
|
+
private _createGuardedState;
|
|
45
|
+
private _logStateUpdate;
|
|
46
|
+
private _isNotTerminal;
|
|
38
47
|
private _handleGuestOtpAuth;
|
|
39
48
|
private _handleGuestKpkAuth;
|
|
40
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitations-handler.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitations-handler.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"invitations-handler.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitations-handler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAS,KAAK,UAAU,EAA8B,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAE/F,OAAO,EAAE,KAAK,OAAO,EAAwB,MAAM,eAAe,CAAC;AAOnE,OAAO,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAQzF,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAQhE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,kBAAkB;IAK3B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC;IAG1C,oBAAoB,CAClB,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,EAC9B,QAAQ,EAAE,kBAAkB,EAC5B,UAAU,EAAE,UAAU,GACrB,IAAI;IAiHP,gBAAgB,CACd,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,EAC9B,QAAQ,EAAE,kBAAkB,EAC5B,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,EAClC,aAAa,CAAC,EAAE,qBAAqB,GACpC,IAAI;YA+JO,UAAU;IA2BxB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAsD3B,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,cAAc;YAUR,mBAAmB;YA6BnB,mBAAmB;CAsBlC;AAED,eAAO,MAAM,sBAAsB,QAAO,gBAGzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invitations-handler.test.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitations-handler.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Event } from '@dxos/async';
|
|
2
|
-
import {
|
|
2
|
+
import { AuthenticatingInvitation, CancellableInvitation } from '@dxos/client-protocol';
|
|
3
3
|
import { Context } from '@dxos/context';
|
|
4
4
|
import { type MetadataStore } from '@dxos/echo-pipeline';
|
|
5
5
|
import { type AcceptInvitationRequest, type AuthenticationRequest, Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
@@ -37,6 +37,7 @@ export declare class InvitationsManager {
|
|
|
37
37
|
onPersistentInvitationsLoaded(ctx: Context, callback: () => void): void;
|
|
38
38
|
private _createInvitation;
|
|
39
39
|
private _createObservableInvitation;
|
|
40
|
+
private _createObservableAcceptingInvitation;
|
|
40
41
|
private _persistIfRequired;
|
|
41
42
|
private _safeDeleteInvitation;
|
|
42
43
|
private _onInvitationComplete;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitations-manager.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/invitations-manager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"invitations-manager.d.ts","sourceRoot":"","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,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAoCzG,yBAAyB,IAAI,OAAO,CAAC;QAAE,WAAW,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC;IA0BzE,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,wBAAwB;IAqBtE,YAAY,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAW9E,gBAAgB,CAAC,EAAE,YAAY,EAAE,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BjF,qBAAqB,IAAI,UAAU,EAAE;IAIrC,sBAAsB,IAAI,UAAU,EAAE;IAItC,6BAA6B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI;IAQhE,OAAO,CAAC,iBAAiB;IAqCzB,OAAO,CAAC,2BAA2B;IAuBnC,OAAO,CAAC,oCAAoC;YAkC9B,kBAAkB;YAclB,qBAAqB;IAQnC,OAAO,CAAC,qBAAqB;CAO9B"}
|
|
@@ -16,6 +16,7 @@ export declare class SpaceInvitationProtocol implements InvitationProtocol {
|
|
|
16
16
|
getInvitationContext(): Partial<Invitation> & Pick<Invitation, 'kind'>;
|
|
17
17
|
admit(invitation: Invitation, request: AdmissionRequest, guestProfile?: ProfileDocument | undefined): Promise<AdmissionResponse>;
|
|
18
18
|
delegate(invitation: Invitation): Promise<PublicKey>;
|
|
19
|
+
cancelDelegation(invitation: Invitation): Promise<void>;
|
|
19
20
|
checkInvitation(invitation: Partial<Invitation>): AlreadyJoinedError | undefined;
|
|
20
21
|
createIntroduction(): IntroductionRequest;
|
|
21
22
|
createAdmissionRequest(): Promise<AdmissionRequest>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space-invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/space-invitation-protocol.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"space-invitation-protocol.d.ts","sourceRoot":"","sources":["../../../../../src/packlets/invitations/space-invitation-protocol.ts"],"names":[],"mappings":"AAYA,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;AAChG,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,CACT,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,gBAAgB,EACzB,YAAY,CAAC,EAAE,eAAe,GAAG,SAAS,GACzC,OAAO,CAAC,iBAAiB,CAAC;IAkCvB,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;IAiCpD,gBAAgB,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