@dxos/client-services 0.5.3-main.f752aaa → 0.5.3-next.2c59258
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-3ZUGGKNX.mjs → chunk-R3VORRTJ.mjs} +213 -87
- package/dist/lib/browser/chunk-R3VORRTJ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-TQQUIYBW.cjs → chunk-VOYHS6QR.cjs} +221 -95
- package/dist/lib/node/chunk-VOYHS6QR.cjs.map +7 -0
- package/dist/lib/node/index.cjs +43 -43
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +8 -8
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- 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-protocol.d.ts +1 -0
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -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 +3 -2
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +2 -0
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -36
- package/src/packlets/diagnostics/diagnostics.ts +1 -0
- package/src/packlets/identity/identity-manager.ts +1 -0
- package/src/packlets/identity/identity.test.ts +3 -0
- package/src/packlets/invitations/device-invitation-protocol.ts +5 -1
- package/src/packlets/invitations/invitation-protocol.ts +2 -0
- package/src/packlets/invitations/invitations-manager.ts +5 -0
- package/src/packlets/invitations/space-invitation-protocol.ts +29 -2
- package/src/packlets/spaces/data-space-manager.ts +65 -4
- package/src/packlets/spaces/data-space.ts +2 -0
- package/src/packlets/spaces/spaces-service.ts +46 -15
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-3ZUGGKNX.mjs.map +0 -7
- package/dist/lib/node/chunk-TQQUIYBW.cjs.map +0 -7
|
@@ -4,12 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
import { EventSubscriptions, UpdateScheduler, scheduleTask } from '@dxos/async';
|
|
6
6
|
import { Stream } from '@dxos/codec-protobuf';
|
|
7
|
-
import { type CredentialProcessor } from '@dxos/credentials';
|
|
7
|
+
import { createAdmissionCredentials, type CredentialProcessor, getCredentialAssertion } from '@dxos/credentials';
|
|
8
8
|
import { raise } from '@dxos/debug';
|
|
9
9
|
import { type SpaceManager } from '@dxos/echo-pipeline';
|
|
10
|
+
import { writeMessages } from '@dxos/feed-store';
|
|
10
11
|
import { invariant } from '@dxos/invariant';
|
|
11
12
|
import { log } from '@dxos/log';
|
|
12
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
ApiError,
|
|
15
|
+
SpaceNotFoundError,
|
|
16
|
+
encodeError,
|
|
17
|
+
IdentityNotInitializedError,
|
|
18
|
+
AuthorizationError,
|
|
19
|
+
} from '@dxos/protocols';
|
|
13
20
|
import {
|
|
14
21
|
SpaceMember,
|
|
15
22
|
SpaceState,
|
|
@@ -24,7 +31,7 @@ import {
|
|
|
24
31
|
type WriteCredentialsRequest,
|
|
25
32
|
type UpdateMemberRoleRequest,
|
|
26
33
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
27
|
-
import { type Credential
|
|
34
|
+
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
28
35
|
import { type GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gossip';
|
|
29
36
|
import { type Provider } from '@dxos/util';
|
|
30
37
|
|
|
@@ -40,10 +47,7 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
40
47
|
) {}
|
|
41
48
|
|
|
42
49
|
async createSpace(): Promise<Space> {
|
|
43
|
-
|
|
44
|
-
throw new Error('This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo');
|
|
45
|
-
}
|
|
46
|
-
|
|
50
|
+
this._requireIdentity();
|
|
47
51
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
48
52
|
const space = await dataSpaceManager.createSpace();
|
|
49
53
|
return this._serializeSpace(space);
|
|
@@ -68,8 +72,30 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
|
|
71
|
-
async updateMemberRole(
|
|
72
|
-
|
|
75
|
+
async updateMemberRole(request: UpdateMemberRoleRequest): Promise<void> {
|
|
76
|
+
const identity = this._requireIdentity();
|
|
77
|
+
const space = this._spaceManager.spaces.get(request.spaceKey);
|
|
78
|
+
if (space == null) {
|
|
79
|
+
throw new SpaceNotFoundError(request.spaceKey);
|
|
80
|
+
}
|
|
81
|
+
if (!space.spaceState.hasMembershipManagementPermission(identity.identityKey)) {
|
|
82
|
+
throw new AuthorizationError('No member management permission.', {
|
|
83
|
+
spaceKey: space.key,
|
|
84
|
+
role: space.spaceState.getMemberRole(identity.identityKey),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const credentials = await createAdmissionCredentials(
|
|
88
|
+
identity.getIdentityCredentialSigner(),
|
|
89
|
+
request.memberKey,
|
|
90
|
+
space.key,
|
|
91
|
+
space.genesisFeedKey,
|
|
92
|
+
request.newRole,
|
|
93
|
+
space.spaceState.membershipChainHeads,
|
|
94
|
+
);
|
|
95
|
+
invariant(credentials[0].credential);
|
|
96
|
+
const spaceMemberCredential = credentials[0].credential.credential;
|
|
97
|
+
invariant(getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember');
|
|
98
|
+
await writeMessages(space.controlPipeline.writer, credentials);
|
|
73
99
|
}
|
|
74
100
|
|
|
75
101
|
querySpaces(): Stream<QuerySpacesResponse> {
|
|
@@ -218,12 +244,8 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
218
244
|
identityKey: member.key,
|
|
219
245
|
profile: member.profile ?? {},
|
|
220
246
|
},
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
? SpaceMember.PresenceState.REMOVED
|
|
224
|
-
: isMe || peers.length > 0
|
|
225
|
-
? SpaceMember.PresenceState.ONLINE
|
|
226
|
-
: SpaceMember.PresenceState.OFFLINE,
|
|
247
|
+
role: member.role,
|
|
248
|
+
presence: peers.length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE,
|
|
227
249
|
peerStates: peers,
|
|
228
250
|
};
|
|
229
251
|
}),
|
|
@@ -232,6 +254,15 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
232
254
|
metrics: space.metrics,
|
|
233
255
|
};
|
|
234
256
|
}
|
|
257
|
+
|
|
258
|
+
private _requireIdentity() {
|
|
259
|
+
if (!this._identityManager.identity) {
|
|
260
|
+
throw new IdentityNotInitializedError(
|
|
261
|
+
'This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo',
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
return this._identityManager.identity;
|
|
265
|
+
}
|
|
235
266
|
}
|
|
236
267
|
|
|
237
268
|
// Add `user-channel` prefix to the channel name, so that it doesn't collide with the internal channels.
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DXOS_VERSION = "0.5.3-
|
|
1
|
+
export const DXOS_VERSION = "0.5.3-next.2c59258";
|