@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
|
@@ -1088,6 +1088,8 @@ var IdentityManager = class {
|
|
|
1088
1088
|
},
|
|
1089
1089
|
memberKey: identityKey,
|
|
1090
1090
|
onDelegatedInvitationStatusChange: async () => {
|
|
1091
|
+
},
|
|
1092
|
+
onMemberRolesChanged: async () => {
|
|
1091
1093
|
}
|
|
1092
1094
|
});
|
|
1093
1095
|
}
|
|
@@ -1191,6 +1193,9 @@ var DeviceInvitationProtocol = class {
|
|
|
1191
1193
|
toJSON() {
|
|
1192
1194
|
return {};
|
|
1193
1195
|
}
|
|
1196
|
+
checkCanInviteNewMembers() {
|
|
1197
|
+
return void 0;
|
|
1198
|
+
}
|
|
1194
1199
|
getInvitationContext() {
|
|
1195
1200
|
return {
|
|
1196
1201
|
kind: Invitation.Kind.DEVICE
|
|
@@ -1205,7 +1210,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1205
1210
|
async admit(_, request) {
|
|
1206
1211
|
invariant4(request.device, void 0, {
|
|
1207
1212
|
F: __dxlog_file5,
|
|
1208
|
-
L:
|
|
1213
|
+
L: 50,
|
|
1209
1214
|
S: this,
|
|
1210
1215
|
A: [
|
|
1211
1216
|
"request.device",
|
|
@@ -1251,7 +1256,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1251
1256
|
async accept(response, request) {
|
|
1252
1257
|
invariant4(response.device, void 0, {
|
|
1253
1258
|
F: __dxlog_file5,
|
|
1254
|
-
L:
|
|
1259
|
+
L: 95,
|
|
1255
1260
|
S: this,
|
|
1256
1261
|
A: [
|
|
1257
1262
|
"response.device",
|
|
@@ -1261,7 +1266,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1261
1266
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1262
1267
|
invariant4(request.device, void 0, {
|
|
1263
1268
|
F: __dxlog_file5,
|
|
1264
|
-
L:
|
|
1269
|
+
L: 98,
|
|
1265
1270
|
S: this,
|
|
1266
1271
|
A: [
|
|
1267
1272
|
"request.device",
|
|
@@ -2561,7 +2566,7 @@ import { createAdmissionCredentials, createCancelDelegatedSpaceInvitationCredent
|
|
|
2561
2566
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2562
2567
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2563
2568
|
import { log as log8 } from "@dxos/log";
|
|
2564
|
-
import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
|
|
2569
|
+
import { AlreadyJoinedError as AlreadyJoinedError2, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from "@dxos/protocols";
|
|
2565
2570
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2566
2571
|
import { SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2567
2572
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
@@ -2578,6 +2583,19 @@ var SpaceInvitationProtocol = class {
|
|
|
2578
2583
|
spaceKey: this._spaceKey
|
|
2579
2584
|
};
|
|
2580
2585
|
}
|
|
2586
|
+
checkCanInviteNewMembers() {
|
|
2587
|
+
if (this._spaceKey == null) {
|
|
2588
|
+
return new InvalidInvitationError("No spaceKey was provided for a space invitation.");
|
|
2589
|
+
}
|
|
2590
|
+
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
2591
|
+
if (space == null) {
|
|
2592
|
+
return new SpaceNotFoundError(this._spaceKey);
|
|
2593
|
+
}
|
|
2594
|
+
if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
|
|
2595
|
+
return new AuthorizationError("No member management permission.");
|
|
2596
|
+
}
|
|
2597
|
+
return void 0;
|
|
2598
|
+
}
|
|
2581
2599
|
getInvitationContext() {
|
|
2582
2600
|
return {
|
|
2583
2601
|
kind: Invitation5.Kind.SPACE,
|
|
@@ -2587,7 +2605,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2587
2605
|
async admit(invitation, request, guestProfile) {
|
|
2588
2606
|
invariant9(this._spaceKey, void 0, {
|
|
2589
2607
|
F: __dxlog_file10,
|
|
2590
|
-
L:
|
|
2608
|
+
L: 76,
|
|
2591
2609
|
S: this,
|
|
2592
2610
|
A: [
|
|
2593
2611
|
"this._spaceKey",
|
|
@@ -2597,7 +2615,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2597
2615
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
2598
2616
|
invariant9(space, void 0, {
|
|
2599
2617
|
F: __dxlog_file10,
|
|
2600
|
-
L:
|
|
2618
|
+
L: 78,
|
|
2601
2619
|
S: this,
|
|
2602
2620
|
A: [
|
|
2603
2621
|
"space",
|
|
@@ -2606,7 +2624,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2606
2624
|
});
|
|
2607
2625
|
invariant9(request.space, void 0, {
|
|
2608
2626
|
F: __dxlog_file10,
|
|
2609
|
-
L:
|
|
2627
|
+
L: 80,
|
|
2610
2628
|
S: this,
|
|
2611
2629
|
A: [
|
|
2612
2630
|
"request.space",
|
|
@@ -2614,19 +2632,22 @@ var SpaceInvitationProtocol = class {
|
|
|
2614
2632
|
]
|
|
2615
2633
|
});
|
|
2616
2634
|
const { identityKey, deviceKey } = request.space;
|
|
2635
|
+
if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember.Role.REMOVED) {
|
|
2636
|
+
throw new AlreadyJoinedError2();
|
|
2637
|
+
}
|
|
2617
2638
|
log8("writing guest credentials", {
|
|
2618
2639
|
host: this._signingContext.deviceKey,
|
|
2619
2640
|
guest: deviceKey
|
|
2620
2641
|
}, {
|
|
2621
2642
|
F: __dxlog_file10,
|
|
2622
|
-
L:
|
|
2643
|
+
L: 87,
|
|
2623
2644
|
S: this,
|
|
2624
2645
|
C: (f, a) => f(...a)
|
|
2625
2646
|
});
|
|
2626
2647
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, invitation.role ?? SpaceMember.Role.ADMIN, space.inner.spaceState.membershipChainHeads, guestProfile, invitation.delegationCredentialId);
|
|
2627
2648
|
invariant9(credentials[0].credential, void 0, {
|
|
2628
2649
|
F: __dxlog_file10,
|
|
2629
|
-
L:
|
|
2650
|
+
L: 101,
|
|
2630
2651
|
S: this,
|
|
2631
2652
|
A: [
|
|
2632
2653
|
"credentials[0].credential",
|
|
@@ -2636,7 +2657,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2636
2657
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2637
2658
|
invariant9(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2638
2659
|
F: __dxlog_file10,
|
|
2639
|
-
L:
|
|
2660
|
+
L: 103,
|
|
2640
2661
|
S: this,
|
|
2641
2662
|
A: [
|
|
2642
2663
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2654,7 +2675,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2654
2675
|
async delegate(invitation) {
|
|
2655
2676
|
invariant9(this._spaceKey, void 0, {
|
|
2656
2677
|
F: __dxlog_file10,
|
|
2657
|
-
L:
|
|
2678
|
+
L: 116,
|
|
2658
2679
|
S: this,
|
|
2659
2680
|
A: [
|
|
2660
2681
|
"this._spaceKey",
|
|
@@ -2664,7 +2685,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2664
2685
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
2665
2686
|
invariant9(space, void 0, {
|
|
2666
2687
|
F: __dxlog_file10,
|
|
2667
|
-
L:
|
|
2688
|
+
L: 118,
|
|
2668
2689
|
S: this,
|
|
2669
2690
|
A: [
|
|
2670
2691
|
"space",
|
|
@@ -2674,7 +2695,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2674
2695
|
if (invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
2675
2696
|
invariant9(invitation.guestKeypair?.publicKey, void 0, {
|
|
2676
2697
|
F: __dxlog_file10,
|
|
2677
|
-
L:
|
|
2698
|
+
L: 120,
|
|
2678
2699
|
S: this,
|
|
2679
2700
|
A: [
|
|
2680
2701
|
"invitation.guestKeypair?.publicKey",
|
|
@@ -2687,7 +2708,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2687
2708
|
id: invitation.invitationId
|
|
2688
2709
|
}, {
|
|
2689
2710
|
F: __dxlog_file10,
|
|
2690
|
-
L:
|
|
2711
|
+
L: 123,
|
|
2691
2712
|
S: this,
|
|
2692
2713
|
C: (f, a) => f(...a)
|
|
2693
2714
|
});
|
|
@@ -2702,7 +2723,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2702
2723
|
});
|
|
2703
2724
|
invariant9(credential.credential, void 0, {
|
|
2704
2725
|
F: __dxlog_file10,
|
|
2705
|
-
L:
|
|
2726
|
+
L: 143,
|
|
2706
2727
|
S: this,
|
|
2707
2728
|
A: [
|
|
2708
2729
|
"credential.credential",
|
|
@@ -2717,7 +2738,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2717
2738
|
async cancelDelegation(invitation) {
|
|
2718
2739
|
invariant9(this._spaceKey, void 0, {
|
|
2719
2740
|
F: __dxlog_file10,
|
|
2720
|
-
L:
|
|
2741
|
+
L: 149,
|
|
2721
2742
|
S: this,
|
|
2722
2743
|
A: [
|
|
2723
2744
|
"this._spaceKey",
|
|
@@ -2726,7 +2747,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2726
2747
|
});
|
|
2727
2748
|
invariant9(invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
2728
2749
|
F: __dxlog_file10,
|
|
2729
|
-
L:
|
|
2750
|
+
L: 150,
|
|
2730
2751
|
S: this,
|
|
2731
2752
|
A: [
|
|
2732
2753
|
"invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
|
|
@@ -2736,7 +2757,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2736
2757
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
2737
2758
|
invariant9(space, void 0, {
|
|
2738
2759
|
F: __dxlog_file10,
|
|
2739
|
-
L:
|
|
2760
|
+
L: 152,
|
|
2740
2761
|
S: this,
|
|
2741
2762
|
A: [
|
|
2742
2763
|
"space",
|
|
@@ -2748,14 +2769,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2748
2769
|
id: invitation.invitationId
|
|
2749
2770
|
}, {
|
|
2750
2771
|
F: __dxlog_file10,
|
|
2751
|
-
L:
|
|
2772
|
+
L: 154,
|
|
2752
2773
|
S: this,
|
|
2753
2774
|
C: (f, a) => f(...a)
|
|
2754
2775
|
});
|
|
2755
2776
|
const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
2756
2777
|
invariant9(credential.credential, void 0, {
|
|
2757
2778
|
F: __dxlog_file10,
|
|
2758
|
-
L:
|
|
2779
|
+
L: 161,
|
|
2759
2780
|
S: this,
|
|
2760
2781
|
A: [
|
|
2761
2782
|
"credential.credential",
|
|
@@ -2767,7 +2788,10 @@ var SpaceInvitationProtocol = class {
|
|
|
2767
2788
|
]);
|
|
2768
2789
|
}
|
|
2769
2790
|
checkInvitation(invitation) {
|
|
2770
|
-
if (invitation.spaceKey
|
|
2791
|
+
if (invitation.spaceKey == null) {
|
|
2792
|
+
return new InvalidInvitationError("No spaceKey was provided for a space invitation.");
|
|
2793
|
+
}
|
|
2794
|
+
if (this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2771
2795
|
return new AlreadyJoinedError2("Already joined space.");
|
|
2772
2796
|
}
|
|
2773
2797
|
}
|
|
@@ -2791,7 +2815,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2791
2815
|
async accept(response) {
|
|
2792
2816
|
invariant9(response.space, void 0, {
|
|
2793
2817
|
F: __dxlog_file10,
|
|
2794
|
-
L:
|
|
2818
|
+
L: 196,
|
|
2795
2819
|
S: this,
|
|
2796
2820
|
A: [
|
|
2797
2821
|
"response.space",
|
|
@@ -2802,7 +2826,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2802
2826
|
const assertion = getCredentialAssertion(credential);
|
|
2803
2827
|
invariant9(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2804
2828
|
F: __dxlog_file10,
|
|
2805
|
-
L:
|
|
2829
|
+
L: 199,
|
|
2806
2830
|
S: this,
|
|
2807
2831
|
A: [
|
|
2808
2832
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2811,7 +2835,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2811
2835
|
});
|
|
2812
2836
|
invariant9(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2813
2837
|
F: __dxlog_file10,
|
|
2814
|
-
L:
|
|
2838
|
+
L: 200,
|
|
2815
2839
|
S: this,
|
|
2816
2840
|
A: [
|
|
2817
2841
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -2869,6 +2893,10 @@ var InvitationsManager = class {
|
|
|
2869
2893
|
}
|
|
2870
2894
|
}
|
|
2871
2895
|
const handler = this._getHandler(options);
|
|
2896
|
+
const invitationError = handler.checkCanInviteNewMembers();
|
|
2897
|
+
if (invitationError != null) {
|
|
2898
|
+
throw invitationError;
|
|
2899
|
+
}
|
|
2872
2900
|
const invitation = this._createInvitation(handler, options);
|
|
2873
2901
|
const { ctx, stream, observableInvitation } = this._createObservableInvitation(handler, invitation);
|
|
2874
2902
|
this._createInvitations.set(invitation.invitationId, observableInvitation);
|
|
@@ -2885,7 +2913,7 @@ var InvitationsManager = class {
|
|
|
2885
2913
|
} catch (err) {
|
|
2886
2914
|
log9.catch(err, void 0, {
|
|
2887
2915
|
F: __dxlog_file11,
|
|
2888
|
-
L:
|
|
2916
|
+
L: 82,
|
|
2889
2917
|
S: this,
|
|
2890
2918
|
C: (f, a) => f(...a)
|
|
2891
2919
|
});
|
|
@@ -2908,7 +2936,7 @@ var InvitationsManager = class {
|
|
|
2908
2936
|
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
2909
2937
|
invariant10(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2910
2938
|
F: __dxlog_file11,
|
|
2911
|
-
L:
|
|
2939
|
+
L: 103,
|
|
2912
2940
|
S: this,
|
|
2913
2941
|
A: [
|
|
2914
2942
|
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
@@ -2927,7 +2955,7 @@ var InvitationsManager = class {
|
|
|
2927
2955
|
} catch (err) {
|
|
2928
2956
|
log9.catch(err, void 0, {
|
|
2929
2957
|
F: __dxlog_file11,
|
|
2930
|
-
L:
|
|
2958
|
+
L: 110,
|
|
2931
2959
|
S: this,
|
|
2932
2960
|
C: (f, a) => f(...a)
|
|
2933
2961
|
});
|
|
@@ -2959,13 +2987,13 @@ var InvitationsManager = class {
|
|
|
2959
2987
|
async authenticate({ invitationId, authCode }) {
|
|
2960
2988
|
log9("authenticating...", void 0, {
|
|
2961
2989
|
F: __dxlog_file11,
|
|
2962
|
-
L:
|
|
2990
|
+
L: 140,
|
|
2963
2991
|
S: this,
|
|
2964
2992
|
C: (f, a) => f(...a)
|
|
2965
2993
|
});
|
|
2966
2994
|
invariant10(invitationId, void 0, {
|
|
2967
2995
|
F: __dxlog_file11,
|
|
2968
|
-
L:
|
|
2996
|
+
L: 141,
|
|
2969
2997
|
S: this,
|
|
2970
2998
|
A: [
|
|
2971
2999
|
"invitationId",
|
|
@@ -2978,7 +3006,7 @@ var InvitationsManager = class {
|
|
|
2978
3006
|
invitationId
|
|
2979
3007
|
}, {
|
|
2980
3008
|
F: __dxlog_file11,
|
|
2981
|
-
L:
|
|
3009
|
+
L: 144,
|
|
2982
3010
|
S: this,
|
|
2983
3011
|
C: (f, a) => f(...a)
|
|
2984
3012
|
});
|
|
@@ -2991,13 +3019,13 @@ var InvitationsManager = class {
|
|
|
2991
3019
|
invitationId
|
|
2992
3020
|
}, {
|
|
2993
3021
|
F: __dxlog_file11,
|
|
2994
|
-
L:
|
|
3022
|
+
L: 151,
|
|
2995
3023
|
S: this,
|
|
2996
3024
|
C: (f, a) => f(...a)
|
|
2997
3025
|
});
|
|
2998
3026
|
invariant10(invitationId, void 0, {
|
|
2999
3027
|
F: __dxlog_file11,
|
|
3000
|
-
L:
|
|
3028
|
+
L: 152,
|
|
3001
3029
|
S: this,
|
|
3002
3030
|
A: [
|
|
3003
3031
|
"invitationId",
|
|
@@ -3076,7 +3104,7 @@ var InvitationsManager = class {
|
|
|
3076
3104
|
...handler.toJSON()
|
|
3077
3105
|
}, {
|
|
3078
3106
|
F: __dxlog_file11,
|
|
3079
|
-
L:
|
|
3107
|
+
L: 241,
|
|
3080
3108
|
S: this,
|
|
3081
3109
|
C: (f, a) => f(...a)
|
|
3082
3110
|
});
|
|
@@ -3109,7 +3137,7 @@ var InvitationsManager = class {
|
|
|
3109
3137
|
...handler.toJSON()
|
|
3110
3138
|
}, {
|
|
3111
3139
|
F: __dxlog_file11,
|
|
3112
|
-
L:
|
|
3140
|
+
L: 261,
|
|
3113
3141
|
S: this,
|
|
3114
3142
|
C: (f, a) => f(...a)
|
|
3115
3143
|
});
|
|
@@ -3120,7 +3148,7 @@ var InvitationsManager = class {
|
|
|
3120
3148
|
} else {
|
|
3121
3149
|
log9.warn("auth failed", err, {
|
|
3122
3150
|
F: __dxlog_file11,
|
|
3123
|
-
L:
|
|
3151
|
+
L: 264,
|
|
3124
3152
|
S: this,
|
|
3125
3153
|
C: (f, a) => f(...a)
|
|
3126
3154
|
});
|
|
@@ -3137,7 +3165,7 @@ var InvitationsManager = class {
|
|
|
3137
3165
|
...handler.toJSON()
|
|
3138
3166
|
}, {
|
|
3139
3167
|
F: __dxlog_file11,
|
|
3140
|
-
L:
|
|
3168
|
+
L: 271,
|
|
3141
3169
|
S: this,
|
|
3142
3170
|
C: (f, a) => f(...a)
|
|
3143
3171
|
});
|
|
@@ -3182,7 +3210,7 @@ var InvitationsManager = class {
|
|
|
3182
3210
|
} catch (err) {
|
|
3183
3211
|
log9.catch(err, void 0, {
|
|
3184
3212
|
F: __dxlog_file11,
|
|
3185
|
-
L:
|
|
3213
|
+
L: 307,
|
|
3186
3214
|
S: this,
|
|
3187
3215
|
C: (f, a) => f(...a)
|
|
3188
3216
|
});
|
|
@@ -3916,7 +3944,7 @@ var DataSpace = class {
|
|
|
3916
3944
|
err
|
|
3917
3945
|
}, {
|
|
3918
3946
|
F: __dxlog_file13,
|
|
3919
|
-
L:
|
|
3947
|
+
L: 387,
|
|
3920
3948
|
S: this,
|
|
3921
3949
|
C: (f, a) => f(...a)
|
|
3922
3950
|
});
|
|
@@ -3971,7 +3999,7 @@ var DataSpace = class {
|
|
|
3971
3999
|
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
3972
4000
|
invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3973
4001
|
F: __dxlog_file13,
|
|
3974
|
-
L:
|
|
4002
|
+
L: 437,
|
|
3975
4003
|
S: this,
|
|
3976
4004
|
A: [
|
|
3977
4005
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -3990,7 +4018,7 @@ var DataSpace = class {
|
|
|
3990
4018
|
{
|
|
3991
4019
|
log11.info("Fragmenting", void 0, {
|
|
3992
4020
|
F: __dxlog_file13,
|
|
3993
|
-
L:
|
|
4021
|
+
L: 449,
|
|
3994
4022
|
S: this,
|
|
3995
4023
|
C: (f, a) => f(...a)
|
|
3996
4024
|
});
|
|
@@ -4002,7 +4030,7 @@ var DataSpace = class {
|
|
|
4002
4030
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4003
4031
|
invariant12(properties, "Properties not found", {
|
|
4004
4032
|
F: __dxlog_file13,
|
|
4005
|
-
L:
|
|
4033
|
+
L: 459,
|
|
4006
4034
|
S: this,
|
|
4007
4035
|
A: [
|
|
4008
4036
|
"properties",
|
|
@@ -4018,7 +4046,7 @@ var DataSpace = class {
|
|
|
4018
4046
|
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
4019
4047
|
invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4020
4048
|
F: __dxlog_file13,
|
|
4021
|
-
L:
|
|
4049
|
+
L: 464,
|
|
4022
4050
|
S: this,
|
|
4023
4051
|
A: [
|
|
4024
4052
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -4087,7 +4115,7 @@ var DataSpace = class {
|
|
|
4087
4115
|
state: SpaceState[this._state]
|
|
4088
4116
|
}, {
|
|
4089
4117
|
F: __dxlog_file13,
|
|
4090
|
-
L:
|
|
4118
|
+
L: 530,
|
|
4091
4119
|
S: this,
|
|
4092
4120
|
C: (f, a) => f(...a)
|
|
4093
4121
|
});
|
|
@@ -4142,13 +4170,15 @@ DataSpace = _ts_decorate4([
|
|
|
4142
4170
|
|
|
4143
4171
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
4144
4172
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
4145
|
-
import {
|
|
4173
|
+
import { cancelWithContext as cancelWithContext5, Context as Context9 } from "@dxos/context";
|
|
4146
4174
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
4175
|
+
import { AuthStatus } from "@dxos/echo-pipeline";
|
|
4147
4176
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4148
4177
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4149
4178
|
import { log as log12 } from "@dxos/log";
|
|
4150
4179
|
import { trace as trace7 } from "@dxos/protocols";
|
|
4151
4180
|
import { Invitation as Invitation7, SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4181
|
+
import { SpaceMember as SpaceMember5 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
4152
4182
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
4153
4183
|
import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
|
|
4154
4184
|
|
|
@@ -4261,7 +4291,7 @@ var DataSpaceManager = class {
|
|
|
4261
4291
|
async open() {
|
|
4262
4292
|
log12("open", void 0, {
|
|
4263
4293
|
F: __dxlog_file14,
|
|
4264
|
-
L:
|
|
4294
|
+
L: 115,
|
|
4265
4295
|
S: this,
|
|
4266
4296
|
C: (f, a) => f(...a)
|
|
4267
4297
|
});
|
|
@@ -4269,7 +4299,7 @@ var DataSpaceManager = class {
|
|
|
4269
4299
|
id: this._instanceId
|
|
4270
4300
|
}), {
|
|
4271
4301
|
F: __dxlog_file14,
|
|
4272
|
-
L:
|
|
4302
|
+
L: 116,
|
|
4273
4303
|
S: this,
|
|
4274
4304
|
C: (f, a) => f(...a)
|
|
4275
4305
|
});
|
|
@@ -4277,7 +4307,7 @@ var DataSpaceManager = class {
|
|
|
4277
4307
|
spaces: this._metadataStore.spaces.length
|
|
4278
4308
|
}, {
|
|
4279
4309
|
F: __dxlog_file14,
|
|
4280
|
-
L:
|
|
4310
|
+
L: 117,
|
|
4281
4311
|
S: this,
|
|
4282
4312
|
C: (f, a) => f(...a)
|
|
4283
4313
|
});
|
|
@@ -4287,7 +4317,7 @@ var DataSpaceManager = class {
|
|
|
4287
4317
|
spaceMetadata
|
|
4288
4318
|
}, {
|
|
4289
4319
|
F: __dxlog_file14,
|
|
4290
|
-
L:
|
|
4320
|
+
L: 121,
|
|
4291
4321
|
S: this,
|
|
4292
4322
|
C: (f, a) => f(...a)
|
|
4293
4323
|
});
|
|
@@ -4298,7 +4328,7 @@ var DataSpaceManager = class {
|
|
|
4298
4328
|
err
|
|
4299
4329
|
}, {
|
|
4300
4330
|
F: __dxlog_file14,
|
|
4301
|
-
L:
|
|
4331
|
+
L: 124,
|
|
4302
4332
|
S: this,
|
|
4303
4333
|
C: (f, a) => f(...a)
|
|
4304
4334
|
});
|
|
@@ -4315,7 +4345,7 @@ var DataSpaceManager = class {
|
|
|
4315
4345
|
id: this._instanceId
|
|
4316
4346
|
}), {
|
|
4317
4347
|
F: __dxlog_file14,
|
|
4318
|
-
L:
|
|
4348
|
+
L: 137,
|
|
4319
4349
|
S: this,
|
|
4320
4350
|
C: (f, a) => f(...a)
|
|
4321
4351
|
});
|
|
@@ -4323,7 +4353,7 @@ var DataSpaceManager = class {
|
|
|
4323
4353
|
async close() {
|
|
4324
4354
|
log12("close", void 0, {
|
|
4325
4355
|
F: __dxlog_file14,
|
|
4326
|
-
L:
|
|
4356
|
+
L: 142,
|
|
4327
4357
|
S: this,
|
|
4328
4358
|
C: (f, a) => f(...a)
|
|
4329
4359
|
});
|
|
@@ -4339,7 +4369,7 @@ var DataSpaceManager = class {
|
|
|
4339
4369
|
async createSpace() {
|
|
4340
4370
|
invariant13(this._isOpen, "Not open.", {
|
|
4341
4371
|
F: __dxlog_file14,
|
|
4342
|
-
L:
|
|
4372
|
+
L: 155,
|
|
4343
4373
|
S: this,
|
|
4344
4374
|
A: [
|
|
4345
4375
|
"this._isOpen",
|
|
@@ -4360,7 +4390,7 @@ var DataSpaceManager = class {
|
|
|
4360
4390
|
spaceKey
|
|
4361
4391
|
}, {
|
|
4362
4392
|
F: __dxlog_file14,
|
|
4363
|
-
L:
|
|
4393
|
+
L: 167,
|
|
4364
4394
|
S: this,
|
|
4365
4395
|
C: (f, a) => f(...a)
|
|
4366
4396
|
});
|
|
@@ -4371,7 +4401,7 @@ var DataSpaceManager = class {
|
|
|
4371
4401
|
const memberCredential = credentials[1];
|
|
4372
4402
|
invariant13(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4373
4403
|
F: __dxlog_file14,
|
|
4374
|
-
L:
|
|
4404
|
+
L: 176,
|
|
4375
4405
|
S: this,
|
|
4376
4406
|
A: [
|
|
4377
4407
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4389,13 +4419,13 @@ var DataSpaceManager = class {
|
|
|
4389
4419
|
opts
|
|
4390
4420
|
}, {
|
|
4391
4421
|
F: __dxlog_file14,
|
|
4392
|
-
L:
|
|
4422
|
+
L: 188,
|
|
4393
4423
|
S: this,
|
|
4394
4424
|
C: (f, a) => f(...a)
|
|
4395
4425
|
});
|
|
4396
4426
|
invariant13(this._isOpen, "Not open.", {
|
|
4397
4427
|
F: __dxlog_file14,
|
|
4398
|
-
L:
|
|
4428
|
+
L: 189,
|
|
4399
4429
|
S: this,
|
|
4400
4430
|
A: [
|
|
4401
4431
|
"this._isOpen",
|
|
@@ -4404,7 +4434,7 @@ var DataSpaceManager = class {
|
|
|
4404
4434
|
});
|
|
4405
4435
|
invariant13(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4406
4436
|
F: __dxlog_file14,
|
|
4407
|
-
L:
|
|
4437
|
+
L: 190,
|
|
4408
4438
|
S: this,
|
|
4409
4439
|
A: [
|
|
4410
4440
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4439,7 +4469,7 @@ var DataSpaceManager = class {
|
|
|
4439
4469
|
metadata
|
|
4440
4470
|
}, {
|
|
4441
4471
|
F: __dxlog_file14,
|
|
4442
|
-
L:
|
|
4472
|
+
L: 223,
|
|
4443
4473
|
S: this,
|
|
4444
4474
|
C: (f, a) => f(...a)
|
|
4445
4475
|
});
|
|
@@ -4477,11 +4507,16 @@ var DataSpaceManager = class {
|
|
|
4477
4507
|
onAuthFailure: () => {
|
|
4478
4508
|
log12.warn("auth failure", void 0, {
|
|
4479
4509
|
F: __dxlog_file14,
|
|
4480
|
-
L:
|
|
4510
|
+
L: 260,
|
|
4481
4511
|
S: this,
|
|
4482
4512
|
C: (f, a) => f(...a)
|
|
4483
4513
|
});
|
|
4484
4514
|
},
|
|
4515
|
+
onMemberRolesChanged: async (members) => {
|
|
4516
|
+
if (dataSpace?.state === SpaceState2.READY) {
|
|
4517
|
+
this._handleMemberRoleChanges(presence, space.protocol, members);
|
|
4518
|
+
}
|
|
4519
|
+
},
|
|
4485
4520
|
memberKey: this._signingContext.identityKey,
|
|
4486
4521
|
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
4487
4522
|
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
@@ -4505,7 +4540,7 @@ var DataSpaceManager = class {
|
|
|
4505
4540
|
space: space.key
|
|
4506
4541
|
}, {
|
|
4507
4542
|
F: __dxlog_file14,
|
|
4508
|
-
L:
|
|
4543
|
+
L: 287,
|
|
4509
4544
|
S: this,
|
|
4510
4545
|
C: (f, a) => f(...a)
|
|
4511
4546
|
});
|
|
@@ -4516,7 +4551,7 @@ var DataSpaceManager = class {
|
|
|
4516
4551
|
open: this._isOpen
|
|
4517
4552
|
}, {
|
|
4518
4553
|
F: __dxlog_file14,
|
|
4519
|
-
L:
|
|
4554
|
+
L: 290,
|
|
4520
4555
|
S: this,
|
|
4521
4556
|
C: (f, a) => f(...a)
|
|
4522
4557
|
});
|
|
@@ -4524,6 +4559,9 @@ var DataSpaceManager = class {
|
|
|
4524
4559
|
await this._createDelegatedInvitations(dataSpace, [
|
|
4525
4560
|
...space.spaceState.invitations.entries()
|
|
4526
4561
|
]);
|
|
4562
|
+
this._handleMemberRoleChanges(presence, space.protocol, [
|
|
4563
|
+
...space.spaceState.members.values()
|
|
4564
|
+
]);
|
|
4527
4565
|
this.updated.emit();
|
|
4528
4566
|
}
|
|
4529
4567
|
},
|
|
@@ -4532,7 +4570,7 @@ var DataSpaceManager = class {
|
|
|
4532
4570
|
space: space.key
|
|
4533
4571
|
}, {
|
|
4534
4572
|
F: __dxlog_file14,
|
|
4535
|
-
L:
|
|
4573
|
+
L: 298,
|
|
4536
4574
|
S: this,
|
|
4537
4575
|
C: (f, a) => f(...a)
|
|
4538
4576
|
});
|
|
@@ -4540,6 +4578,11 @@ var DataSpaceManager = class {
|
|
|
4540
4578
|
},
|
|
4541
4579
|
cache: metadata.cache
|
|
4542
4580
|
});
|
|
4581
|
+
presence.newPeer.on((peerState) => {
|
|
4582
|
+
if (dataSpace.state === SpaceState2.READY) {
|
|
4583
|
+
this._handleNewPeerConnected(space, peerState);
|
|
4584
|
+
}
|
|
4585
|
+
});
|
|
4543
4586
|
if (metadata.state !== SpaceState2.INACTIVE) {
|
|
4544
4587
|
await dataSpace.open();
|
|
4545
4588
|
}
|
|
@@ -4549,6 +4592,51 @@ var DataSpaceManager = class {
|
|
|
4549
4592
|
this._spaces.set(metadata.key, dataSpace);
|
|
4550
4593
|
return dataSpace;
|
|
4551
4594
|
}
|
|
4595
|
+
_handleMemberRoleChanges(presence, spaceProtocol, memberInfo) {
|
|
4596
|
+
let closedSessions = 0;
|
|
4597
|
+
for (const member of memberInfo) {
|
|
4598
|
+
if (member.key.equals(presence.getLocalState().identityKey)) {
|
|
4599
|
+
continue;
|
|
4600
|
+
}
|
|
4601
|
+
const peers = presence.getPeersByIdentityKey(member.key);
|
|
4602
|
+
const sessions = peers.map((p) => p.peerId && spaceProtocol.sessions.get(p.peerId));
|
|
4603
|
+
const sessionsToClose = sessions.filter((s) => {
|
|
4604
|
+
return (s && member.role === SpaceMember5.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
|
|
4605
|
+
});
|
|
4606
|
+
sessionsToClose.forEach((session) => {
|
|
4607
|
+
void session.close().catch(log12.error);
|
|
4608
|
+
});
|
|
4609
|
+
closedSessions += sessionsToClose.length;
|
|
4610
|
+
}
|
|
4611
|
+
log12("processed member role changes", {
|
|
4612
|
+
roleChangeCount: memberInfo.length,
|
|
4613
|
+
peersOnline: presence.getPeersOnline().length,
|
|
4614
|
+
closedSessions
|
|
4615
|
+
}, {
|
|
4616
|
+
F: __dxlog_file14,
|
|
4617
|
+
L: 338,
|
|
4618
|
+
S: this,
|
|
4619
|
+
C: (f, a) => f(...a)
|
|
4620
|
+
});
|
|
4621
|
+
spaceProtocol.updateTopology();
|
|
4622
|
+
}
|
|
4623
|
+
_handleNewPeerConnected(space, peerState) {
|
|
4624
|
+
const role = space.spaceState.getMemberRole(peerState.identityKey);
|
|
4625
|
+
if (role === SpaceMember5.Role.REMOVED) {
|
|
4626
|
+
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
4627
|
+
if (session != null) {
|
|
4628
|
+
log12("closing a session with a removed peer", {
|
|
4629
|
+
peerId: peerState.peerId
|
|
4630
|
+
}, {
|
|
4631
|
+
F: __dxlog_file14,
|
|
4632
|
+
L: 352,
|
|
4633
|
+
S: this,
|
|
4634
|
+
C: (f, a) => f(...a)
|
|
4635
|
+
});
|
|
4636
|
+
void session.close().catch(log12.error);
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4639
|
+
}
|
|
4552
4640
|
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4553
4641
|
if (dataSpace?.state !== SpaceState2.READY) {
|
|
4554
4642
|
return;
|
|
@@ -4604,12 +4692,13 @@ DataSpaceManager = _ts_decorate5([
|
|
|
4604
4692
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
4605
4693
|
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask6 } from "@dxos/async";
|
|
4606
4694
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
4695
|
+
import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4607
4696
|
import { raise as raise2 } from "@dxos/debug";
|
|
4697
|
+
import { writeMessages as writeMessages3 } from "@dxos/feed-store";
|
|
4608
4698
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4609
4699
|
import { log as log13 } from "@dxos/log";
|
|
4610
|
-
import { ApiError, SpaceNotFoundError, encodeError } from "@dxos/protocols";
|
|
4611
|
-
import { SpaceMember as
|
|
4612
|
-
import { SpaceMember as HaloSpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
4700
|
+
import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
|
|
4701
|
+
import { SpaceMember as SpaceMember6, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4613
4702
|
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4614
4703
|
var SpacesServiceImpl = class {
|
|
4615
4704
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
@@ -4618,16 +4707,14 @@ var SpacesServiceImpl = class {
|
|
|
4618
4707
|
this._getDataSpaceManager = _getDataSpaceManager;
|
|
4619
4708
|
}
|
|
4620
4709
|
async createSpace() {
|
|
4621
|
-
|
|
4622
|
-
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
|
|
4623
|
-
}
|
|
4710
|
+
this._requireIdentity();
|
|
4624
4711
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4625
4712
|
const space = await dataSpaceManager.createSpace();
|
|
4626
4713
|
return this._serializeSpace(space);
|
|
4627
4714
|
}
|
|
4628
4715
|
async updateSpace({ spaceKey, state }) {
|
|
4629
4716
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4630
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new
|
|
4717
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
4631
4718
|
if (state) {
|
|
4632
4719
|
switch (state) {
|
|
4633
4720
|
case SpaceState3.ACTIVE:
|
|
@@ -4641,8 +4728,39 @@ var SpacesServiceImpl = class {
|
|
|
4641
4728
|
}
|
|
4642
4729
|
}
|
|
4643
4730
|
}
|
|
4644
|
-
async updateMemberRole(
|
|
4645
|
-
|
|
4731
|
+
async updateMemberRole(request) {
|
|
4732
|
+
const identity = this._requireIdentity();
|
|
4733
|
+
const space = this._spaceManager.spaces.get(request.spaceKey);
|
|
4734
|
+
if (space == null) {
|
|
4735
|
+
throw new SpaceNotFoundError2(request.spaceKey);
|
|
4736
|
+
}
|
|
4737
|
+
if (!space.spaceState.hasMembershipManagementPermission(identity.identityKey)) {
|
|
4738
|
+
throw new AuthorizationError2("No member management permission.", {
|
|
4739
|
+
spaceKey: space.key,
|
|
4740
|
+
role: space.spaceState.getMemberRole(identity.identityKey)
|
|
4741
|
+
});
|
|
4742
|
+
}
|
|
4743
|
+
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
4744
|
+
invariant14(credentials[0].credential, void 0, {
|
|
4745
|
+
F: __dxlog_file15,
|
|
4746
|
+
L: 95,
|
|
4747
|
+
S: this,
|
|
4748
|
+
A: [
|
|
4749
|
+
"credentials[0].credential",
|
|
4750
|
+
""
|
|
4751
|
+
]
|
|
4752
|
+
});
|
|
4753
|
+
const spaceMemberCredential = credentials[0].credential.credential;
|
|
4754
|
+
invariant14(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4755
|
+
F: __dxlog_file15,
|
|
4756
|
+
L: 97,
|
|
4757
|
+
S: this,
|
|
4758
|
+
A: [
|
|
4759
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
4760
|
+
""
|
|
4761
|
+
]
|
|
4762
|
+
});
|
|
4763
|
+
await writeMessages3(space.controlPipeline.writer, credentials);
|
|
4646
4764
|
}
|
|
4647
4765
|
querySpaces() {
|
|
4648
4766
|
return new Stream10(({ next, ctx }) => {
|
|
@@ -4653,7 +4771,7 @@ var SpacesServiceImpl = class {
|
|
|
4653
4771
|
spaces
|
|
4654
4772
|
}, {
|
|
4655
4773
|
F: __dxlog_file15,
|
|
4656
|
-
L:
|
|
4774
|
+
L: 108,
|
|
4657
4775
|
S: this,
|
|
4658
4776
|
C: (f, a) => f(...a)
|
|
4659
4777
|
});
|
|
@@ -4692,14 +4810,14 @@ var SpacesServiceImpl = class {
|
|
|
4692
4810
|
}
|
|
4693
4811
|
async postMessage({ spaceKey, channel, message }) {
|
|
4694
4812
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4695
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new
|
|
4813
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
4696
4814
|
await space.postMessage(getChannelId(channel), message);
|
|
4697
4815
|
}
|
|
4698
4816
|
subscribeMessages({ spaceKey, channel }) {
|
|
4699
4817
|
return new Stream10(({ ctx, next }) => {
|
|
4700
4818
|
scheduleTask6(ctx, async () => {
|
|
4701
4819
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4702
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new
|
|
4820
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
4703
4821
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
4704
4822
|
next(message);
|
|
4705
4823
|
});
|
|
@@ -4709,7 +4827,7 @@ var SpacesServiceImpl = class {
|
|
|
4709
4827
|
}
|
|
4710
4828
|
queryCredentials({ spaceKey, noTail }) {
|
|
4711
4829
|
return new Stream10(({ ctx, next, close }) => {
|
|
4712
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? raise2(new
|
|
4830
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
4713
4831
|
const processor = {
|
|
4714
4832
|
processCredential: async (credential) => {
|
|
4715
4833
|
next(credential);
|
|
@@ -4725,7 +4843,7 @@ var SpacesServiceImpl = class {
|
|
|
4725
4843
|
});
|
|
4726
4844
|
}
|
|
4727
4845
|
async writeCredentials({ spaceKey, credentials }) {
|
|
4728
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? raise2(new
|
|
4846
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
4729
4847
|
for (const credential of credentials ?? []) {
|
|
4730
4848
|
if (credential.proof) {
|
|
4731
4849
|
await space.controlPipeline.writer.write({
|
|
@@ -4736,7 +4854,7 @@ var SpacesServiceImpl = class {
|
|
|
4736
4854
|
} else {
|
|
4737
4855
|
invariant14(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4738
4856
|
F: __dxlog_file15,
|
|
4739
|
-
L:
|
|
4857
|
+
L: 195,
|
|
4740
4858
|
S: this,
|
|
4741
4859
|
A: [
|
|
4742
4860
|
"!credential.id",
|
|
@@ -4745,7 +4863,7 @@ var SpacesServiceImpl = class {
|
|
|
4745
4863
|
});
|
|
4746
4864
|
invariant14(this._identityManager.identity, "Identity is not available", {
|
|
4747
4865
|
F: __dxlog_file15,
|
|
4748
|
-
L:
|
|
4866
|
+
L: 196,
|
|
4749
4867
|
S: this,
|
|
4750
4868
|
A: [
|
|
4751
4869
|
"this._identityManager.identity",
|
|
@@ -4755,7 +4873,7 @@ var SpacesServiceImpl = class {
|
|
|
4755
4873
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4756
4874
|
invariant14(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4757
4875
|
F: __dxlog_file15,
|
|
4758
|
-
L:
|
|
4876
|
+
L: 198,
|
|
4759
4877
|
S: this,
|
|
4760
4878
|
A: [
|
|
4761
4879
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -4776,7 +4894,7 @@ var SpacesServiceImpl = class {
|
|
|
4776
4894
|
}
|
|
4777
4895
|
async createEpoch({ spaceKey, migration }) {
|
|
4778
4896
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4779
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new
|
|
4897
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
4780
4898
|
await space.createEpoch({
|
|
4781
4899
|
migration
|
|
4782
4900
|
});
|
|
@@ -4810,7 +4928,8 @@ var SpacesServiceImpl = class {
|
|
|
4810
4928
|
identityKey: member.key,
|
|
4811
4929
|
profile: member.profile ?? {}
|
|
4812
4930
|
},
|
|
4813
|
-
|
|
4931
|
+
role: member.role,
|
|
4932
|
+
presence: peers.length > 0 ? SpaceMember6.PresenceState.ONLINE : SpaceMember6.PresenceState.OFFLINE,
|
|
4814
4933
|
peerStates: peers
|
|
4815
4934
|
};
|
|
4816
4935
|
}),
|
|
@@ -4819,13 +4938,19 @@ var SpacesServiceImpl = class {
|
|
|
4819
4938
|
metrics: space.metrics
|
|
4820
4939
|
};
|
|
4821
4940
|
}
|
|
4941
|
+
_requireIdentity() {
|
|
4942
|
+
if (!this._identityManager.identity) {
|
|
4943
|
+
throw new IdentityNotInitializedError("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
|
|
4944
|
+
}
|
|
4945
|
+
return this._identityManager.identity;
|
|
4946
|
+
}
|
|
4822
4947
|
};
|
|
4823
4948
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
4824
4949
|
|
|
4825
4950
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
4826
4951
|
import { Trigger as Trigger6 } from "@dxos/async";
|
|
4827
4952
|
import { Context as Context10, Resource } from "@dxos/context";
|
|
4828
|
-
import { getCredentialAssertion as
|
|
4953
|
+
import { getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
|
|
4829
4954
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
4830
4955
|
import { EchoHost } from "@dxos/echo-db";
|
|
4831
4956
|
import { MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
@@ -5041,7 +5166,7 @@ var ServiceContext = class extends Resource {
|
|
|
5041
5166
|
this.initialized.wake();
|
|
5042
5167
|
this._deviceSpaceSync = {
|
|
5043
5168
|
processCredential: async (credential) => {
|
|
5044
|
-
const assertion =
|
|
5169
|
+
const assertion = getCredentialAssertion4(credential);
|
|
5045
5170
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
5046
5171
|
return;
|
|
5047
5172
|
}
|
|
@@ -5137,11 +5262,11 @@ import { getFirstStreamValue } from "@dxos/codec-protobuf";
|
|
|
5137
5262
|
import { credentialTypeFilter } from "@dxos/credentials";
|
|
5138
5263
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5139
5264
|
import { STORAGE_VERSION as STORAGE_VERSION2 } from "@dxos/protocols";
|
|
5140
|
-
import { SpaceMember as
|
|
5265
|
+
import { SpaceMember as SpaceMember7 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5141
5266
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
5142
5267
|
|
|
5143
5268
|
// packages/sdk/client-services/src/version.ts
|
|
5144
|
-
var DXOS_VERSION = "0.5.3-
|
|
5269
|
+
var DXOS_VERSION = "0.5.3-next.2c59258";
|
|
5145
5270
|
|
|
5146
5271
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
5147
5272
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -5249,13 +5374,14 @@ var getSpaceStats = async (space) => {
|
|
|
5249
5374
|
id: credential.id
|
|
5250
5375
|
})),
|
|
5251
5376
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
5377
|
+
role: member.role,
|
|
5252
5378
|
identity: {
|
|
5253
5379
|
identityKey: member.key,
|
|
5254
5380
|
profile: {
|
|
5255
5381
|
displayName: member.assertion.profile?.displayName
|
|
5256
5382
|
}
|
|
5257
5383
|
},
|
|
5258
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ?
|
|
5384
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember7.PresenceState.ONLINE : SpaceMember7.PresenceState.OFFLINE
|
|
5259
5385
|
})),
|
|
5260
5386
|
pipeline: {
|
|
5261
5387
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
@@ -6386,4 +6512,4 @@ export {
|
|
|
6386
6512
|
ClientServicesHost,
|
|
6387
6513
|
ClientServicesProviderResource
|
|
6388
6514
|
};
|
|
6389
|
-
//# sourceMappingURL=chunk-
|
|
6515
|
+
//# sourceMappingURL=chunk-R3VORRTJ.mjs.map
|