@dxos/client-services 0.5.1-main.39e0ee2 → 0.5.1-main.3c7169d
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-S3SB2RSX.mjs → chunk-FRVAAUY2.mjs} +908 -1264
- package/dist/lib/browser/chunk-FRVAAUY2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +2 -31
- 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 +8 -28
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-TQ5236LO.cjs → chunk-Y2YAZWVU.cjs} +1037 -1385
- package/dist/lib/node/chunk-Y2YAZWVU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +44 -73
- 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 +14 -34
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +1 -2
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/{invitation-host-extension.d.ts → invitation-extension.d.ts} +31 -17
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +1 -6
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +10 -19
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +1 -2
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +0 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +3 -6
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +1 -2
- 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 +2 -10
- 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 +1 -5
- package/src/packlets/invitations/{invitation-host-extension.ts → invitation-extension.ts} +105 -99
- package/src/packlets/invitations/invitation-protocol.ts +1 -7
- package/src/packlets/invitations/invitations-handler.ts +149 -246
- package/src/packlets/invitations/invitations-manager.ts +3 -42
- package/src/packlets/invitations/space-invitation-protocol.ts +1 -19
- package/src/packlets/services/service-context.ts +3 -5
- package/src/packlets/testing/invitation-utils.ts +3 -23
- package/src/packlets/testing/test-builder.ts +1 -3
- package/src/packlets/vault/shell-runtime.ts +2 -40
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-S3SB2RSX.mjs.map +0 -7
- package/dist/lib/node/chunk-TQ5236LO.cjs.map +0 -7
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts +0 -39
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/invitation-topology.d.ts +0 -37
- package/dist/types/src/packlets/invitations/invitation-topology.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/invitations-handler.test.d.ts +0 -2
- package/dist/types/src/packlets/invitations/invitations-handler.test.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/utils.d.ts +0 -6
- package/dist/types/src/packlets/invitations/utils.d.ts.map +0 -1
- package/src/packlets/invitations/invitation-guest-extenstion.ts +0 -126
- package/src/packlets/invitations/invitation-topology.ts +0 -87
- package/src/packlets/invitations/invitations-handler.test.ts +0 -361
- package/src/packlets/invitations/utils.ts +0 -27
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
createAdmissionCredentials,
|
|
7
|
-
createCancelDelegatedSpaceInvitationCredential,
|
|
8
7
|
createDelegatedSpaceInvitationCredential,
|
|
9
8
|
getCredentialAssertion,
|
|
10
9
|
} from '@dxos/credentials';
|
|
@@ -88,7 +87,7 @@ export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
|
88
87
|
|
|
89
88
|
async delegate(invitation: Invitation): Promise<PublicKey> {
|
|
90
89
|
invariant(this._spaceKey);
|
|
91
|
-
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
90
|
+
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
92
91
|
invariant(space);
|
|
93
92
|
if (invitation.authMethod === Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
94
93
|
invariant(invitation.guestKeypair?.publicKey);
|
|
@@ -119,23 +118,6 @@ export class SpaceInvitationProtocol implements InvitationProtocol {
|
|
|
119
118
|
return credential.credential.credential.id!;
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
async cancelDelegation(invitation: Invitation): Promise<void> {
|
|
123
|
-
invariant(this._spaceKey);
|
|
124
|
-
invariant(invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId);
|
|
125
|
-
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
126
|
-
invariant(space);
|
|
127
|
-
|
|
128
|
-
log('cancelling delegated space invitation', { host: this._signingContext.deviceKey, id: invitation.invitationId });
|
|
129
|
-
const credential = await createCancelDelegatedSpaceInvitationCredential(
|
|
130
|
-
this._signingContext.credentialSigner,
|
|
131
|
-
space.key,
|
|
132
|
-
invitation.delegationCredentialId,
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
invariant(credential.credential);
|
|
136
|
-
await writeMessages(space.inner.controlPipeline.writer, [credential]);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
121
|
checkInvitation(invitation: Partial<Invitation>) {
|
|
140
122
|
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
141
123
|
return new AlreadyJoinedError('Already joined space.');
|
|
@@ -21,7 +21,6 @@ import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
|
21
21
|
import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
22
22
|
import { type Credential, type ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
23
23
|
import { type Storage } from '@dxos/random-access-storage';
|
|
24
|
-
import type { TeleportParams } from '@dxos/teleport';
|
|
25
24
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
26
25
|
import { trace as Trace } from '@dxos/tracing';
|
|
27
26
|
import { safeInstanceof } from '@dxos/util';
|
|
@@ -41,8 +40,7 @@ import {
|
|
|
41
40
|
import { InvitationsManager } from '../invitations/invitations-manager';
|
|
42
41
|
import { DataSpaceManager, type DataSpaceManagerRuntimeParams, type SigningContext } from '../spaces';
|
|
43
42
|
|
|
44
|
-
export type ServiceContextRuntimeParams = IdentityManagerRuntimeParams &
|
|
45
|
-
DataSpaceManagerRuntimeParams & { invitationConnectionDefaultParams?: Partial<TeleportParams> };
|
|
43
|
+
export type ServiceContextRuntimeParams = IdentityManagerRuntimeParams & DataSpaceManagerRuntimeParams;
|
|
46
44
|
/**
|
|
47
45
|
* Shared backend for all client services.
|
|
48
46
|
*/
|
|
@@ -83,7 +81,7 @@ export class ServiceContext extends Resource {
|
|
|
83
81
|
public readonly level: LevelDB,
|
|
84
82
|
public readonly networkManager: NetworkManager,
|
|
85
83
|
public readonly signalManager: SignalManager,
|
|
86
|
-
public readonly _runtimeParams?:
|
|
84
|
+
public readonly _runtimeParams?: IdentityManagerRuntimeParams & DataSpaceManagerRuntimeParams,
|
|
87
85
|
) {
|
|
88
86
|
super();
|
|
89
87
|
|
|
@@ -125,7 +123,7 @@ export class ServiceContext extends Resource {
|
|
|
125
123
|
storage: this.storage,
|
|
126
124
|
});
|
|
127
125
|
|
|
128
|
-
this.invitations = new InvitationsHandler(this.networkManager
|
|
126
|
+
this.invitations = new InvitationsHandler(this.networkManager);
|
|
129
127
|
this.invitationsManager = new InvitationsManager(
|
|
130
128
|
this.invitations,
|
|
131
129
|
(invitation) => this.getInvitationHandler(invitation),
|
|
@@ -45,7 +45,6 @@ export type PerformInvitationParams = {
|
|
|
45
45
|
guest?: PerformInvitationCallbacks<AuthenticatingInvitation>;
|
|
46
46
|
};
|
|
47
47
|
guestDeviceProfile?: DeviceProfileDocument;
|
|
48
|
-
codeInputDelay?: number;
|
|
49
48
|
};
|
|
50
49
|
|
|
51
50
|
export type Result = { invitation?: Invitation; error?: Error };
|
|
@@ -56,10 +55,7 @@ export const performInvitation = ({
|
|
|
56
55
|
options,
|
|
57
56
|
hooks,
|
|
58
57
|
guestDeviceProfile,
|
|
59
|
-
codeInputDelay,
|
|
60
58
|
}: PerformInvitationParams): [Promise<Result>, Promise<Result>] => {
|
|
61
|
-
let guestError = false;
|
|
62
|
-
let guestConnected = false;
|
|
63
59
|
const hostComplete = new Trigger<Result>();
|
|
64
60
|
const guestComplete = new Trigger<Result>();
|
|
65
61
|
const authCode = new Trigger<string>();
|
|
@@ -69,10 +65,6 @@ export const performInvitation = ({
|
|
|
69
65
|
async (hostInvitation: Invitation) => {
|
|
70
66
|
switch (hostInvitation.state) {
|
|
71
67
|
case Invitation.State.CONNECTING: {
|
|
72
|
-
if (guestConnected) {
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
guestConnected = true;
|
|
76
68
|
if (hooks?.host?.onConnecting?.(hostObservable)) {
|
|
77
69
|
break;
|
|
78
70
|
}
|
|
@@ -97,16 +89,7 @@ export const performInvitation = ({
|
|
|
97
89
|
if (hooks?.guest?.onReady?.(guestObservable)) {
|
|
98
90
|
break;
|
|
99
91
|
}
|
|
100
|
-
|
|
101
|
-
if (codeInputDelay == null) {
|
|
102
|
-
await guestObservable.authenticate(code);
|
|
103
|
-
} else {
|
|
104
|
-
setTimeout(async () => {
|
|
105
|
-
if (!guestError) {
|
|
106
|
-
await guestObservable.authenticate(code);
|
|
107
|
-
}
|
|
108
|
-
}, codeInputDelay);
|
|
109
|
-
}
|
|
92
|
+
await guestObservable.authenticate(await authCode.wait());
|
|
110
93
|
break;
|
|
111
94
|
}
|
|
112
95
|
|
|
@@ -140,7 +123,6 @@ export const performInvitation = ({
|
|
|
140
123
|
}
|
|
141
124
|
},
|
|
142
125
|
(error: Error) => {
|
|
143
|
-
guestError = true;
|
|
144
126
|
if (hooks?.guest?.onError?.(guestObservable)) {
|
|
145
127
|
return;
|
|
146
128
|
}
|
|
@@ -234,10 +216,8 @@ const acceptInvitation = (
|
|
|
234
216
|
invitation = sanitizeInvitation(invitation);
|
|
235
217
|
|
|
236
218
|
if (guest instanceof ServiceContext) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
deviceProfile: guestDeviceProfile,
|
|
240
|
-
});
|
|
219
|
+
const guestHandler = guest.getInvitationHandler({ kind: invitation.kind });
|
|
220
|
+
return guest.invitations.acceptInvitation(guestHandler, invitation, guestDeviceProfile);
|
|
241
221
|
}
|
|
242
222
|
|
|
243
223
|
return guest.join(invitation, guestDeviceProfile);
|
|
@@ -49,9 +49,7 @@ export const createServiceContext = async ({
|
|
|
49
49
|
const level = createTestLevel();
|
|
50
50
|
await level.open();
|
|
51
51
|
|
|
52
|
-
return new ServiceContext(storage, level, networkManager, signalManager
|
|
53
|
-
invitationConnectionDefaultParams: { controlHeartbeatInterval: 200 },
|
|
54
|
-
});
|
|
52
|
+
return new ServiceContext(storage, level, networkManager, signalManager);
|
|
55
53
|
};
|
|
56
54
|
|
|
57
55
|
export const createPeers = async (numPeers: number) => {
|
|
@@ -6,12 +6,7 @@ import { Event } from '@dxos/async';
|
|
|
6
6
|
import { appServiceBundle, type AppServiceBundle, type ShellRuntime, shellServiceBundle } from '@dxos/client-protocol';
|
|
7
7
|
import { invariant } from '@dxos/invariant';
|
|
8
8
|
import { type PublicKey } from '@dxos/keys';
|
|
9
|
-
import {
|
|
10
|
-
type AppContextRequest,
|
|
11
|
-
type LayoutRequest,
|
|
12
|
-
ShellLayout,
|
|
13
|
-
type InvitationUrlRequest,
|
|
14
|
-
} from '@dxos/protocols/proto/dxos/iframe';
|
|
9
|
+
import { type AppContextRequest, type LayoutRequest, ShellLayout } from '@dxos/protocols/proto/dxos/iframe';
|
|
15
10
|
import { createProtoRpcPeer, type ProtoRpcPeer, type RpcPort } from '@dxos/rpc';
|
|
16
11
|
|
|
17
12
|
/**
|
|
@@ -19,18 +14,10 @@ import { createProtoRpcPeer, type ProtoRpcPeer, type RpcPort } from '@dxos/rpc';
|
|
|
19
14
|
*/
|
|
20
15
|
export class ShellRuntimeImpl implements ShellRuntime {
|
|
21
16
|
readonly layoutUpdate = new Event<LayoutRequest>();
|
|
22
|
-
readonly invitationUrlUpdate = new Event<InvitationUrlRequest>();
|
|
23
|
-
|
|
24
17
|
private _appRpc?: ProtoRpcPeer<AppServiceBundle>;
|
|
25
18
|
private _layout = ShellLayout.DEFAULT;
|
|
26
|
-
private _spaceKey?: PublicKey;
|
|
27
|
-
|
|
28
19
|
private _invitationCode?: string;
|
|
29
|
-
private
|
|
30
|
-
|
|
31
|
-
// TODO(burdon): Change to using underscores (coordinate with @dxos/web-auth).
|
|
32
|
-
private _deviceInvitationParam = 'deviceInvitationCode'; // TODO(burdon): device_invitation_code
|
|
33
|
-
private _spaceInvitationParam = 'spaceInvitationCode'; // TODO(burdon): space_invitation_code
|
|
20
|
+
private _spaceKey?: PublicKey;
|
|
34
21
|
|
|
35
22
|
constructor(private readonly _port: RpcPort) {}
|
|
36
23
|
|
|
@@ -46,18 +33,6 @@ export class ShellRuntimeImpl implements ShellRuntime {
|
|
|
46
33
|
return this._spaceKey;
|
|
47
34
|
}
|
|
48
35
|
|
|
49
|
-
get invitationUrl() {
|
|
50
|
-
return this._invitationUrl!;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
get deviceInvitationParam() {
|
|
54
|
-
return this._deviceInvitationParam;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
get spaceInvitationParam() {
|
|
58
|
-
return this._spaceInvitationParam;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
36
|
setLayout({ layout, invitationCode, spaceKey }: LayoutRequest) {
|
|
62
37
|
this._layout = layout;
|
|
63
38
|
this._invitationCode = invitationCode;
|
|
@@ -65,13 +40,6 @@ export class ShellRuntimeImpl implements ShellRuntime {
|
|
|
65
40
|
this.layoutUpdate.emit({ layout, invitationCode, spaceKey });
|
|
66
41
|
}
|
|
67
42
|
|
|
68
|
-
setInvitationUrl({ invitationUrl, deviceInvitationParam, spaceInvitationParam }: InvitationUrlRequest) {
|
|
69
|
-
this._invitationUrl = invitationUrl;
|
|
70
|
-
this._deviceInvitationParam = deviceInvitationParam;
|
|
71
|
-
this._spaceInvitationParam = spaceInvitationParam;
|
|
72
|
-
this.invitationUrlUpdate.emit({ invitationUrl, deviceInvitationParam, spaceInvitationParam });
|
|
73
|
-
}
|
|
74
|
-
|
|
75
43
|
async setAppContext(context: AppContextRequest) {
|
|
76
44
|
invariant(this._appRpc, 'runtime not open');
|
|
77
45
|
|
|
@@ -90,12 +58,6 @@ export class ShellRuntimeImpl implements ShellRuntime {
|
|
|
90
58
|
this._spaceKey = request.spaceKey;
|
|
91
59
|
this.layoutUpdate.emit(request);
|
|
92
60
|
},
|
|
93
|
-
setInvitationUrl: async (request) => {
|
|
94
|
-
this._invitationUrl = request.invitationUrl;
|
|
95
|
-
this._deviceInvitationParam = request.deviceInvitationParam;
|
|
96
|
-
this._spaceInvitationParam = request.spaceInvitationParam;
|
|
97
|
-
this.invitationUrlUpdate.emit(request);
|
|
98
|
-
},
|
|
99
61
|
},
|
|
100
62
|
},
|
|
101
63
|
port: this._port,
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DXOS_VERSION = "0.5.1-main.
|
|
1
|
+
export const DXOS_VERSION = "0.5.1-main.3c7169d";
|