@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
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_VOYHS6QR_exports = {};
|
|
30
|
+
__export(chunk_VOYHS6QR_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
@@ -66,7 +66,7 @@ __export(chunk_TQQUIYBW_exports, {
|
|
|
66
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
67
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
68
68
|
});
|
|
69
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_VOYHS6QR_exports);
|
|
70
70
|
var import_async = require("@dxos/async");
|
|
71
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
72
72
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -207,32 +207,35 @@ var import_util7 = require("@dxos/util");
|
|
|
207
207
|
var import_async14 = require("@dxos/async");
|
|
208
208
|
var import_context11 = require("@dxos/context");
|
|
209
209
|
var import_credentials14 = require("@dxos/credentials");
|
|
210
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
210
211
|
var import_invariant13 = require("@dxos/invariant");
|
|
211
212
|
var import_keys11 = require("@dxos/keys");
|
|
212
213
|
var import_log12 = require("@dxos/log");
|
|
213
214
|
var import_protocols10 = require("@dxos/protocols");
|
|
214
215
|
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
216
|
+
var import_credentials15 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
215
217
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
216
218
|
var import_util8 = require("@dxos/util");
|
|
217
|
-
var
|
|
219
|
+
var import_credentials16 = require("@dxos/credentials");
|
|
218
220
|
var import_debug4 = require("@dxos/debug");
|
|
219
|
-
var
|
|
221
|
+
var import_credentials17 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
220
222
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
221
223
|
var import_async15 = require("@dxos/async");
|
|
222
224
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
225
|
+
var import_credentials18 = require("@dxos/credentials");
|
|
223
226
|
var import_debug5 = require("@dxos/debug");
|
|
227
|
+
var import_feed_store4 = require("@dxos/feed-store");
|
|
224
228
|
var import_invariant14 = require("@dxos/invariant");
|
|
225
229
|
var import_log13 = require("@dxos/log");
|
|
226
230
|
var import_protocols11 = require("@dxos/protocols");
|
|
227
231
|
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
228
|
-
var import_credentials17 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
229
232
|
var import_async16 = require("@dxos/async");
|
|
230
233
|
var import_context12 = require("@dxos/context");
|
|
231
|
-
var
|
|
234
|
+
var import_credentials19 = require("@dxos/credentials");
|
|
232
235
|
var import_debug6 = require("@dxos/debug");
|
|
233
236
|
var import_echo_db = require("@dxos/echo-db");
|
|
234
|
-
var
|
|
235
|
-
var
|
|
237
|
+
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
238
|
+
var import_feed_store5 = require("@dxos/feed-store");
|
|
236
239
|
var import_invariant15 = require("@dxos/invariant");
|
|
237
240
|
var import_keyring = require("@dxos/keyring");
|
|
238
241
|
var import_keys12 = require("@dxos/keys");
|
|
@@ -244,7 +247,7 @@ var import_tracing5 = require("@dxos/tracing");
|
|
|
244
247
|
var import_util9 = require("@dxos/util");
|
|
245
248
|
var import_async17 = require("@dxos/async");
|
|
246
249
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
247
|
-
var
|
|
250
|
+
var import_credentials20 = require("@dxos/credentials");
|
|
248
251
|
var import_invariant16 = require("@dxos/invariant");
|
|
249
252
|
var import_protocols13 = require("@dxos/protocols");
|
|
250
253
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -1316,6 +1319,8 @@ var IdentityManager = class {
|
|
|
1316
1319
|
},
|
|
1317
1320
|
memberKey: identityKey,
|
|
1318
1321
|
onDelegatedInvitationStatusChange: async () => {
|
|
1322
|
+
},
|
|
1323
|
+
onMemberRolesChanged: async () => {
|
|
1319
1324
|
}
|
|
1320
1325
|
});
|
|
1321
1326
|
}
|
|
@@ -1408,6 +1413,9 @@ var DeviceInvitationProtocol = class {
|
|
|
1408
1413
|
toJSON() {
|
|
1409
1414
|
return {};
|
|
1410
1415
|
}
|
|
1416
|
+
checkCanInviteNewMembers() {
|
|
1417
|
+
return void 0;
|
|
1418
|
+
}
|
|
1411
1419
|
getInvitationContext() {
|
|
1412
1420
|
return {
|
|
1413
1421
|
kind: import_services2.Invitation.Kind.DEVICE
|
|
@@ -1422,7 +1430,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1422
1430
|
async admit(_, request) {
|
|
1423
1431
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1424
1432
|
F: __dxlog_file5,
|
|
1425
|
-
L:
|
|
1433
|
+
L: 50,
|
|
1426
1434
|
S: this,
|
|
1427
1435
|
A: [
|
|
1428
1436
|
"request.device",
|
|
@@ -1468,7 +1476,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1468
1476
|
async accept(response, request) {
|
|
1469
1477
|
(0, import_invariant4.invariant)(response.device, void 0, {
|
|
1470
1478
|
F: __dxlog_file5,
|
|
1471
|
-
L:
|
|
1479
|
+
L: 95,
|
|
1472
1480
|
S: this,
|
|
1473
1481
|
A: [
|
|
1474
1482
|
"response.device",
|
|
@@ -1478,7 +1486,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1478
1486
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1479
1487
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1480
1488
|
F: __dxlog_file5,
|
|
1481
|
-
L:
|
|
1489
|
+
L: 98,
|
|
1482
1490
|
S: this,
|
|
1483
1491
|
A: [
|
|
1484
1492
|
"request.device",
|
|
@@ -2731,6 +2739,19 @@ var SpaceInvitationProtocol = class {
|
|
|
2731
2739
|
spaceKey: this._spaceKey
|
|
2732
2740
|
};
|
|
2733
2741
|
}
|
|
2742
|
+
checkCanInviteNewMembers() {
|
|
2743
|
+
if (this._spaceKey == null) {
|
|
2744
|
+
return new import_protocols7.InvalidInvitationError("No spaceKey was provided for a space invitation.");
|
|
2745
|
+
}
|
|
2746
|
+
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
2747
|
+
if (space == null) {
|
|
2748
|
+
return new import_protocols7.SpaceNotFoundError(this._spaceKey);
|
|
2749
|
+
}
|
|
2750
|
+
if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
|
|
2751
|
+
return new import_protocols7.AuthorizationError("No member management permission.");
|
|
2752
|
+
}
|
|
2753
|
+
return void 0;
|
|
2754
|
+
}
|
|
2734
2755
|
getInvitationContext() {
|
|
2735
2756
|
return {
|
|
2736
2757
|
kind: import_services7.Invitation.Kind.SPACE,
|
|
@@ -2740,7 +2761,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2740
2761
|
async admit(invitation, request, guestProfile) {
|
|
2741
2762
|
(0, import_invariant9.invariant)(this._spaceKey, void 0, {
|
|
2742
2763
|
F: __dxlog_file10,
|
|
2743
|
-
L:
|
|
2764
|
+
L: 76,
|
|
2744
2765
|
S: this,
|
|
2745
2766
|
A: [
|
|
2746
2767
|
"this._spaceKey",
|
|
@@ -2750,7 +2771,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2750
2771
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
2751
2772
|
(0, import_invariant9.invariant)(space, void 0, {
|
|
2752
2773
|
F: __dxlog_file10,
|
|
2753
|
-
L:
|
|
2774
|
+
L: 78,
|
|
2754
2775
|
S: this,
|
|
2755
2776
|
A: [
|
|
2756
2777
|
"space",
|
|
@@ -2759,7 +2780,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2759
2780
|
});
|
|
2760
2781
|
(0, import_invariant9.invariant)(request.space, void 0, {
|
|
2761
2782
|
F: __dxlog_file10,
|
|
2762
|
-
L:
|
|
2783
|
+
L: 80,
|
|
2763
2784
|
S: this,
|
|
2764
2785
|
A: [
|
|
2765
2786
|
"request.space",
|
|
@@ -2767,19 +2788,22 @@ var SpaceInvitationProtocol = class {
|
|
|
2767
2788
|
]
|
|
2768
2789
|
});
|
|
2769
2790
|
const { identityKey, deviceKey } = request.space;
|
|
2791
|
+
if (space.inner.spaceState.getMemberRole(identityKey) !== import_credentials8.SpaceMember.Role.REMOVED) {
|
|
2792
|
+
throw new import_protocols7.AlreadyJoinedError();
|
|
2793
|
+
}
|
|
2770
2794
|
(0, import_log8.log)("writing guest credentials", {
|
|
2771
2795
|
host: this._signingContext.deviceKey,
|
|
2772
2796
|
guest: deviceKey
|
|
2773
2797
|
}, {
|
|
2774
2798
|
F: __dxlog_file10,
|
|
2775
|
-
L:
|
|
2799
|
+
L: 87,
|
|
2776
2800
|
S: this,
|
|
2777
2801
|
C: (f, a) => f(...a)
|
|
2778
2802
|
});
|
|
2779
2803
|
const credentials = await (0, import_credentials7.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, invitation.role ?? import_credentials8.SpaceMember.Role.ADMIN, space.inner.spaceState.membershipChainHeads, guestProfile, invitation.delegationCredentialId);
|
|
2780
2804
|
(0, import_invariant9.invariant)(credentials[0].credential, void 0, {
|
|
2781
2805
|
F: __dxlog_file10,
|
|
2782
|
-
L:
|
|
2806
|
+
L: 101,
|
|
2783
2807
|
S: this,
|
|
2784
2808
|
A: [
|
|
2785
2809
|
"credentials[0].credential",
|
|
@@ -2789,7 +2813,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2789
2813
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2790
2814
|
(0, import_invariant9.invariant)((0, import_credentials7.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2791
2815
|
F: __dxlog_file10,
|
|
2792
|
-
L:
|
|
2816
|
+
L: 103,
|
|
2793
2817
|
S: this,
|
|
2794
2818
|
A: [
|
|
2795
2819
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2807,7 +2831,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2807
2831
|
async delegate(invitation) {
|
|
2808
2832
|
(0, import_invariant9.invariant)(this._spaceKey, void 0, {
|
|
2809
2833
|
F: __dxlog_file10,
|
|
2810
|
-
L:
|
|
2834
|
+
L: 116,
|
|
2811
2835
|
S: this,
|
|
2812
2836
|
A: [
|
|
2813
2837
|
"this._spaceKey",
|
|
@@ -2817,7 +2841,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2817
2841
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
2818
2842
|
(0, import_invariant9.invariant)(space, void 0, {
|
|
2819
2843
|
F: __dxlog_file10,
|
|
2820
|
-
L:
|
|
2844
|
+
L: 118,
|
|
2821
2845
|
S: this,
|
|
2822
2846
|
A: [
|
|
2823
2847
|
"space",
|
|
@@ -2827,7 +2851,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2827
2851
|
if (invitation.authMethod === import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
2828
2852
|
(0, import_invariant9.invariant)(invitation.guestKeypair?.publicKey, void 0, {
|
|
2829
2853
|
F: __dxlog_file10,
|
|
2830
|
-
L:
|
|
2854
|
+
L: 120,
|
|
2831
2855
|
S: this,
|
|
2832
2856
|
A: [
|
|
2833
2857
|
"invitation.guestKeypair?.publicKey",
|
|
@@ -2840,7 +2864,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2840
2864
|
id: invitation.invitationId
|
|
2841
2865
|
}, {
|
|
2842
2866
|
F: __dxlog_file10,
|
|
2843
|
-
L:
|
|
2867
|
+
L: 123,
|
|
2844
2868
|
S: this,
|
|
2845
2869
|
C: (f, a) => f(...a)
|
|
2846
2870
|
});
|
|
@@ -2855,7 +2879,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2855
2879
|
});
|
|
2856
2880
|
(0, import_invariant9.invariant)(credential.credential, void 0, {
|
|
2857
2881
|
F: __dxlog_file10,
|
|
2858
|
-
L:
|
|
2882
|
+
L: 143,
|
|
2859
2883
|
S: this,
|
|
2860
2884
|
A: [
|
|
2861
2885
|
"credential.credential",
|
|
@@ -2870,7 +2894,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2870
2894
|
async cancelDelegation(invitation) {
|
|
2871
2895
|
(0, import_invariant9.invariant)(this._spaceKey, void 0, {
|
|
2872
2896
|
F: __dxlog_file10,
|
|
2873
|
-
L:
|
|
2897
|
+
L: 149,
|
|
2874
2898
|
S: this,
|
|
2875
2899
|
A: [
|
|
2876
2900
|
"this._spaceKey",
|
|
@@ -2879,7 +2903,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2879
2903
|
});
|
|
2880
2904
|
(0, import_invariant9.invariant)(invitation.type === import_services7.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
2881
2905
|
F: __dxlog_file10,
|
|
2882
|
-
L:
|
|
2906
|
+
L: 150,
|
|
2883
2907
|
S: this,
|
|
2884
2908
|
A: [
|
|
2885
2909
|
"invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
|
|
@@ -2889,7 +2913,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2889
2913
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
2890
2914
|
(0, import_invariant9.invariant)(space, void 0, {
|
|
2891
2915
|
F: __dxlog_file10,
|
|
2892
|
-
L:
|
|
2916
|
+
L: 152,
|
|
2893
2917
|
S: this,
|
|
2894
2918
|
A: [
|
|
2895
2919
|
"space",
|
|
@@ -2901,14 +2925,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2901
2925
|
id: invitation.invitationId
|
|
2902
2926
|
}, {
|
|
2903
2927
|
F: __dxlog_file10,
|
|
2904
|
-
L:
|
|
2928
|
+
L: 154,
|
|
2905
2929
|
S: this,
|
|
2906
2930
|
C: (f, a) => f(...a)
|
|
2907
2931
|
});
|
|
2908
2932
|
const credential = await (0, import_credentials7.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
2909
2933
|
(0, import_invariant9.invariant)(credential.credential, void 0, {
|
|
2910
2934
|
F: __dxlog_file10,
|
|
2911
|
-
L:
|
|
2935
|
+
L: 161,
|
|
2912
2936
|
S: this,
|
|
2913
2937
|
A: [
|
|
2914
2938
|
"credential.credential",
|
|
@@ -2920,7 +2944,10 @@ var SpaceInvitationProtocol = class {
|
|
|
2920
2944
|
]);
|
|
2921
2945
|
}
|
|
2922
2946
|
checkInvitation(invitation) {
|
|
2923
|
-
if (invitation.spaceKey
|
|
2947
|
+
if (invitation.spaceKey == null) {
|
|
2948
|
+
return new import_protocols7.InvalidInvitationError("No spaceKey was provided for a space invitation.");
|
|
2949
|
+
}
|
|
2950
|
+
if (this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2924
2951
|
return new import_protocols7.AlreadyJoinedError("Already joined space.");
|
|
2925
2952
|
}
|
|
2926
2953
|
}
|
|
@@ -2944,7 +2971,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2944
2971
|
async accept(response) {
|
|
2945
2972
|
(0, import_invariant9.invariant)(response.space, void 0, {
|
|
2946
2973
|
F: __dxlog_file10,
|
|
2947
|
-
L:
|
|
2974
|
+
L: 196,
|
|
2948
2975
|
S: this,
|
|
2949
2976
|
A: [
|
|
2950
2977
|
"response.space",
|
|
@@ -2955,7 +2982,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2955
2982
|
const assertion = (0, import_credentials7.getCredentialAssertion)(credential);
|
|
2956
2983
|
(0, import_invariant9.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2957
2984
|
F: __dxlog_file10,
|
|
2958
|
-
L:
|
|
2985
|
+
L: 199,
|
|
2959
2986
|
S: this,
|
|
2960
2987
|
A: [
|
|
2961
2988
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2964,7 +2991,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2964
2991
|
});
|
|
2965
2992
|
(0, import_invariant9.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2966
2993
|
F: __dxlog_file10,
|
|
2967
|
-
L:
|
|
2994
|
+
L: 200,
|
|
2968
2995
|
S: this,
|
|
2969
2996
|
A: [
|
|
2970
2997
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -3010,6 +3037,10 @@ var InvitationsManager = class {
|
|
|
3010
3037
|
}
|
|
3011
3038
|
}
|
|
3012
3039
|
const handler = this._getHandler(options);
|
|
3040
|
+
const invitationError = handler.checkCanInviteNewMembers();
|
|
3041
|
+
if (invitationError != null) {
|
|
3042
|
+
throw invitationError;
|
|
3043
|
+
}
|
|
3013
3044
|
const invitation = this._createInvitation(handler, options);
|
|
3014
3045
|
const { ctx, stream, observableInvitation } = this._createObservableInvitation(handler, invitation);
|
|
3015
3046
|
this._createInvitations.set(invitation.invitationId, observableInvitation);
|
|
@@ -3026,7 +3057,7 @@ var InvitationsManager = class {
|
|
|
3026
3057
|
} catch (err) {
|
|
3027
3058
|
import_log9.log.catch(err, void 0, {
|
|
3028
3059
|
F: __dxlog_file11,
|
|
3029
|
-
L:
|
|
3060
|
+
L: 82,
|
|
3030
3061
|
S: this,
|
|
3031
3062
|
C: (f, a) => f(...a)
|
|
3032
3063
|
});
|
|
@@ -3049,7 +3080,7 @@ var InvitationsManager = class {
|
|
|
3049
3080
|
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
3050
3081
|
(0, import_invariant10.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
3051
3082
|
F: __dxlog_file11,
|
|
3052
|
-
L:
|
|
3083
|
+
L: 103,
|
|
3053
3084
|
S: this,
|
|
3054
3085
|
A: [
|
|
3055
3086
|
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
@@ -3068,7 +3099,7 @@ var InvitationsManager = class {
|
|
|
3068
3099
|
} catch (err) {
|
|
3069
3100
|
import_log9.log.catch(err, void 0, {
|
|
3070
3101
|
F: __dxlog_file11,
|
|
3071
|
-
L:
|
|
3102
|
+
L: 110,
|
|
3072
3103
|
S: this,
|
|
3073
3104
|
C: (f, a) => f(...a)
|
|
3074
3105
|
});
|
|
@@ -3100,13 +3131,13 @@ var InvitationsManager = class {
|
|
|
3100
3131
|
async authenticate({ invitationId, authCode }) {
|
|
3101
3132
|
(0, import_log9.log)("authenticating...", void 0, {
|
|
3102
3133
|
F: __dxlog_file11,
|
|
3103
|
-
L:
|
|
3134
|
+
L: 140,
|
|
3104
3135
|
S: this,
|
|
3105
3136
|
C: (f, a) => f(...a)
|
|
3106
3137
|
});
|
|
3107
3138
|
(0, import_invariant10.invariant)(invitationId, void 0, {
|
|
3108
3139
|
F: __dxlog_file11,
|
|
3109
|
-
L:
|
|
3140
|
+
L: 141,
|
|
3110
3141
|
S: this,
|
|
3111
3142
|
A: [
|
|
3112
3143
|
"invitationId",
|
|
@@ -3119,7 +3150,7 @@ var InvitationsManager = class {
|
|
|
3119
3150
|
invitationId
|
|
3120
3151
|
}, {
|
|
3121
3152
|
F: __dxlog_file11,
|
|
3122
|
-
L:
|
|
3153
|
+
L: 144,
|
|
3123
3154
|
S: this,
|
|
3124
3155
|
C: (f, a) => f(...a)
|
|
3125
3156
|
});
|
|
@@ -3132,13 +3163,13 @@ var InvitationsManager = class {
|
|
|
3132
3163
|
invitationId
|
|
3133
3164
|
}, {
|
|
3134
3165
|
F: __dxlog_file11,
|
|
3135
|
-
L:
|
|
3166
|
+
L: 151,
|
|
3136
3167
|
S: this,
|
|
3137
3168
|
C: (f, a) => f(...a)
|
|
3138
3169
|
});
|
|
3139
3170
|
(0, import_invariant10.invariant)(invitationId, void 0, {
|
|
3140
3171
|
F: __dxlog_file11,
|
|
3141
|
-
L:
|
|
3172
|
+
L: 152,
|
|
3142
3173
|
S: this,
|
|
3143
3174
|
A: [
|
|
3144
3175
|
"invitationId",
|
|
@@ -3217,7 +3248,7 @@ var InvitationsManager = class {
|
|
|
3217
3248
|
...handler.toJSON()
|
|
3218
3249
|
}, {
|
|
3219
3250
|
F: __dxlog_file11,
|
|
3220
|
-
L:
|
|
3251
|
+
L: 241,
|
|
3221
3252
|
S: this,
|
|
3222
3253
|
C: (f, a) => f(...a)
|
|
3223
3254
|
});
|
|
@@ -3250,7 +3281,7 @@ var InvitationsManager = class {
|
|
|
3250
3281
|
...handler.toJSON()
|
|
3251
3282
|
}, {
|
|
3252
3283
|
F: __dxlog_file11,
|
|
3253
|
-
L:
|
|
3284
|
+
L: 261,
|
|
3254
3285
|
S: this,
|
|
3255
3286
|
C: (f, a) => f(...a)
|
|
3256
3287
|
});
|
|
@@ -3261,7 +3292,7 @@ var InvitationsManager = class {
|
|
|
3261
3292
|
} else {
|
|
3262
3293
|
import_log9.log.warn("auth failed", err, {
|
|
3263
3294
|
F: __dxlog_file11,
|
|
3264
|
-
L:
|
|
3295
|
+
L: 264,
|
|
3265
3296
|
S: this,
|
|
3266
3297
|
C: (f, a) => f(...a)
|
|
3267
3298
|
});
|
|
@@ -3278,7 +3309,7 @@ var InvitationsManager = class {
|
|
|
3278
3309
|
...handler.toJSON()
|
|
3279
3310
|
}, {
|
|
3280
3311
|
F: __dxlog_file11,
|
|
3281
|
-
L:
|
|
3312
|
+
L: 271,
|
|
3282
3313
|
S: this,
|
|
3283
3314
|
C: (f, a) => f(...a)
|
|
3284
3315
|
});
|
|
@@ -3323,7 +3354,7 @@ var InvitationsManager = class {
|
|
|
3323
3354
|
} catch (err) {
|
|
3324
3355
|
import_log9.log.catch(err, void 0, {
|
|
3325
3356
|
F: __dxlog_file11,
|
|
3326
|
-
L:
|
|
3357
|
+
L: 307,
|
|
3327
3358
|
S: this,
|
|
3328
3359
|
C: (f, a) => f(...a)
|
|
3329
3360
|
});
|
|
@@ -4012,7 +4043,7 @@ var DataSpace = class {
|
|
|
4012
4043
|
err
|
|
4013
4044
|
}, {
|
|
4014
4045
|
F: __dxlog_file13,
|
|
4015
|
-
L:
|
|
4046
|
+
L: 387,
|
|
4016
4047
|
S: this,
|
|
4017
4048
|
C: (f, a) => f(...a)
|
|
4018
4049
|
});
|
|
@@ -4067,7 +4098,7 @@ var DataSpace = class {
|
|
|
4067
4098
|
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
4068
4099
|
(0, import_invariant11.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4069
4100
|
F: __dxlog_file13,
|
|
4070
|
-
L:
|
|
4101
|
+
L: 437,
|
|
4071
4102
|
S: this,
|
|
4072
4103
|
A: [
|
|
4073
4104
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -4086,7 +4117,7 @@ var DataSpace = class {
|
|
|
4086
4117
|
{
|
|
4087
4118
|
import_log10.log.info("Fragmenting", void 0, {
|
|
4088
4119
|
F: __dxlog_file13,
|
|
4089
|
-
L:
|
|
4120
|
+
L: 449,
|
|
4090
4121
|
S: this,
|
|
4091
4122
|
C: (f, a) => f(...a)
|
|
4092
4123
|
});
|
|
@@ -4098,7 +4129,7 @@ var DataSpace = class {
|
|
|
4098
4129
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4099
4130
|
(0, import_invariant11.invariant)(properties, "Properties not found", {
|
|
4100
4131
|
F: __dxlog_file13,
|
|
4101
|
-
L:
|
|
4132
|
+
L: 459,
|
|
4102
4133
|
S: this,
|
|
4103
4134
|
A: [
|
|
4104
4135
|
"properties",
|
|
@@ -4114,7 +4145,7 @@ var DataSpace = class {
|
|
|
4114
4145
|
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
4115
4146
|
(0, import_invariant11.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4116
4147
|
F: __dxlog_file13,
|
|
4117
|
-
L:
|
|
4148
|
+
L: 464,
|
|
4118
4149
|
S: this,
|
|
4119
4150
|
A: [
|
|
4120
4151
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -4183,7 +4214,7 @@ var DataSpace = class {
|
|
|
4183
4214
|
state: import_services9.SpaceState[this._state]
|
|
4184
4215
|
}, {
|
|
4185
4216
|
F: __dxlog_file13,
|
|
4186
|
-
L:
|
|
4217
|
+
L: 530,
|
|
4187
4218
|
S: this,
|
|
4188
4219
|
C: (f, a) => f(...a)
|
|
4189
4220
|
});
|
|
@@ -4237,7 +4268,7 @@ DataSpace = _ts_decorate4([
|
|
|
4237
4268
|
], DataSpace);
|
|
4238
4269
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
4239
4270
|
const credentials = [
|
|
4240
|
-
await (0,
|
|
4271
|
+
await (0, import_credentials16.createCredential)({
|
|
4241
4272
|
signer: keyring,
|
|
4242
4273
|
issuer: space.key,
|
|
4243
4274
|
subject: space.key,
|
|
@@ -4246,14 +4277,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4246
4277
|
spaceKey: space.key
|
|
4247
4278
|
}
|
|
4248
4279
|
}),
|
|
4249
|
-
await (0,
|
|
4280
|
+
await (0, import_credentials16.createCredential)({
|
|
4250
4281
|
signer: keyring,
|
|
4251
4282
|
issuer: space.key,
|
|
4252
4283
|
subject: signingContext.identityKey,
|
|
4253
4284
|
assertion: {
|
|
4254
4285
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
4255
4286
|
spaceKey: space.key,
|
|
4256
|
-
role:
|
|
4287
|
+
role: import_credentials17.SpaceMember.Role.OWNER,
|
|
4257
4288
|
profile: signingContext.getProfile(),
|
|
4258
4289
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
4259
4290
|
}
|
|
@@ -4265,7 +4296,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4265
4296
|
spaceKey: space.key,
|
|
4266
4297
|
identityKey: signingContext.identityKey,
|
|
4267
4298
|
deviceKey: signingContext.deviceKey,
|
|
4268
|
-
designation:
|
|
4299
|
+
designation: import_credentials17.AdmittedFeed.Designation.CONTROL
|
|
4269
4300
|
}
|
|
4270
4301
|
}),
|
|
4271
4302
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -4275,7 +4306,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4275
4306
|
spaceKey: space.key,
|
|
4276
4307
|
identityKey: signingContext.identityKey,
|
|
4277
4308
|
deviceKey: signingContext.deviceKey,
|
|
4278
|
-
designation:
|
|
4309
|
+
designation: import_credentials17.AdmittedFeed.Designation.DATA
|
|
4279
4310
|
}
|
|
4280
4311
|
}),
|
|
4281
4312
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -4337,7 +4368,7 @@ var DataSpaceManager = class {
|
|
|
4337
4368
|
async open() {
|
|
4338
4369
|
(0, import_log12.log)("open", void 0, {
|
|
4339
4370
|
F: __dxlog_file14,
|
|
4340
|
-
L:
|
|
4371
|
+
L: 115,
|
|
4341
4372
|
S: this,
|
|
4342
4373
|
C: (f, a) => f(...a)
|
|
4343
4374
|
});
|
|
@@ -4345,7 +4376,7 @@ var DataSpaceManager = class {
|
|
|
4345
4376
|
id: this._instanceId
|
|
4346
4377
|
}), {
|
|
4347
4378
|
F: __dxlog_file14,
|
|
4348
|
-
L:
|
|
4379
|
+
L: 116,
|
|
4349
4380
|
S: this,
|
|
4350
4381
|
C: (f, a) => f(...a)
|
|
4351
4382
|
});
|
|
@@ -4353,7 +4384,7 @@ var DataSpaceManager = class {
|
|
|
4353
4384
|
spaces: this._metadataStore.spaces.length
|
|
4354
4385
|
}, {
|
|
4355
4386
|
F: __dxlog_file14,
|
|
4356
|
-
L:
|
|
4387
|
+
L: 117,
|
|
4357
4388
|
S: this,
|
|
4358
4389
|
C: (f, a) => f(...a)
|
|
4359
4390
|
});
|
|
@@ -4363,7 +4394,7 @@ var DataSpaceManager = class {
|
|
|
4363
4394
|
spaceMetadata
|
|
4364
4395
|
}, {
|
|
4365
4396
|
F: __dxlog_file14,
|
|
4366
|
-
L:
|
|
4397
|
+
L: 121,
|
|
4367
4398
|
S: this,
|
|
4368
4399
|
C: (f, a) => f(...a)
|
|
4369
4400
|
});
|
|
@@ -4374,7 +4405,7 @@ var DataSpaceManager = class {
|
|
|
4374
4405
|
err
|
|
4375
4406
|
}, {
|
|
4376
4407
|
F: __dxlog_file14,
|
|
4377
|
-
L:
|
|
4408
|
+
L: 124,
|
|
4378
4409
|
S: this,
|
|
4379
4410
|
C: (f, a) => f(...a)
|
|
4380
4411
|
});
|
|
@@ -4391,7 +4422,7 @@ var DataSpaceManager = class {
|
|
|
4391
4422
|
id: this._instanceId
|
|
4392
4423
|
}), {
|
|
4393
4424
|
F: __dxlog_file14,
|
|
4394
|
-
L:
|
|
4425
|
+
L: 137,
|
|
4395
4426
|
S: this,
|
|
4396
4427
|
C: (f, a) => f(...a)
|
|
4397
4428
|
});
|
|
@@ -4399,7 +4430,7 @@ var DataSpaceManager = class {
|
|
|
4399
4430
|
async close() {
|
|
4400
4431
|
(0, import_log12.log)("close", void 0, {
|
|
4401
4432
|
F: __dxlog_file14,
|
|
4402
|
-
L:
|
|
4433
|
+
L: 142,
|
|
4403
4434
|
S: this,
|
|
4404
4435
|
C: (f, a) => f(...a)
|
|
4405
4436
|
});
|
|
@@ -4415,7 +4446,7 @@ var DataSpaceManager = class {
|
|
|
4415
4446
|
async createSpace() {
|
|
4416
4447
|
(0, import_invariant13.invariant)(this._isOpen, "Not open.", {
|
|
4417
4448
|
F: __dxlog_file14,
|
|
4418
|
-
L:
|
|
4449
|
+
L: 155,
|
|
4419
4450
|
S: this,
|
|
4420
4451
|
A: [
|
|
4421
4452
|
"this._isOpen",
|
|
@@ -4436,7 +4467,7 @@ var DataSpaceManager = class {
|
|
|
4436
4467
|
spaceKey
|
|
4437
4468
|
}, {
|
|
4438
4469
|
F: __dxlog_file14,
|
|
4439
|
-
L:
|
|
4470
|
+
L: 167,
|
|
4440
4471
|
S: this,
|
|
4441
4472
|
C: (f, a) => f(...a)
|
|
4442
4473
|
});
|
|
@@ -4447,7 +4478,7 @@ var DataSpaceManager = class {
|
|
|
4447
4478
|
const memberCredential = credentials[1];
|
|
4448
4479
|
(0, import_invariant13.invariant)((0, import_credentials14.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4449
4480
|
F: __dxlog_file14,
|
|
4450
|
-
L:
|
|
4481
|
+
L: 176,
|
|
4451
4482
|
S: this,
|
|
4452
4483
|
A: [
|
|
4453
4484
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4465,13 +4496,13 @@ var DataSpaceManager = class {
|
|
|
4465
4496
|
opts
|
|
4466
4497
|
}, {
|
|
4467
4498
|
F: __dxlog_file14,
|
|
4468
|
-
L:
|
|
4499
|
+
L: 188,
|
|
4469
4500
|
S: this,
|
|
4470
4501
|
C: (f, a) => f(...a)
|
|
4471
4502
|
});
|
|
4472
4503
|
(0, import_invariant13.invariant)(this._isOpen, "Not open.", {
|
|
4473
4504
|
F: __dxlog_file14,
|
|
4474
|
-
L:
|
|
4505
|
+
L: 189,
|
|
4475
4506
|
S: this,
|
|
4476
4507
|
A: [
|
|
4477
4508
|
"this._isOpen",
|
|
@@ -4480,7 +4511,7 @@ var DataSpaceManager = class {
|
|
|
4480
4511
|
});
|
|
4481
4512
|
(0, import_invariant13.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4482
4513
|
F: __dxlog_file14,
|
|
4483
|
-
L:
|
|
4514
|
+
L: 190,
|
|
4484
4515
|
S: this,
|
|
4485
4516
|
A: [
|
|
4486
4517
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4515,7 +4546,7 @@ var DataSpaceManager = class {
|
|
|
4515
4546
|
metadata
|
|
4516
4547
|
}, {
|
|
4517
4548
|
F: __dxlog_file14,
|
|
4518
|
-
L:
|
|
4549
|
+
L: 223,
|
|
4519
4550
|
S: this,
|
|
4520
4551
|
C: (f, a) => f(...a)
|
|
4521
4552
|
});
|
|
@@ -4553,11 +4584,16 @@ var DataSpaceManager = class {
|
|
|
4553
4584
|
onAuthFailure: () => {
|
|
4554
4585
|
import_log12.log.warn("auth failure", void 0, {
|
|
4555
4586
|
F: __dxlog_file14,
|
|
4556
|
-
L:
|
|
4587
|
+
L: 260,
|
|
4557
4588
|
S: this,
|
|
4558
4589
|
C: (f, a) => f(...a)
|
|
4559
4590
|
});
|
|
4560
4591
|
},
|
|
4592
|
+
onMemberRolesChanged: async (members) => {
|
|
4593
|
+
if (dataSpace?.state === import_services10.SpaceState.READY) {
|
|
4594
|
+
this._handleMemberRoleChanges(presence, space.protocol, members);
|
|
4595
|
+
}
|
|
4596
|
+
},
|
|
4561
4597
|
memberKey: this._signingContext.identityKey,
|
|
4562
4598
|
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
4563
4599
|
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
@@ -4581,7 +4617,7 @@ var DataSpaceManager = class {
|
|
|
4581
4617
|
space: space.key
|
|
4582
4618
|
}, {
|
|
4583
4619
|
F: __dxlog_file14,
|
|
4584
|
-
L:
|
|
4620
|
+
L: 287,
|
|
4585
4621
|
S: this,
|
|
4586
4622
|
C: (f, a) => f(...a)
|
|
4587
4623
|
});
|
|
@@ -4592,7 +4628,7 @@ var DataSpaceManager = class {
|
|
|
4592
4628
|
open: this._isOpen
|
|
4593
4629
|
}, {
|
|
4594
4630
|
F: __dxlog_file14,
|
|
4595
|
-
L:
|
|
4631
|
+
L: 290,
|
|
4596
4632
|
S: this,
|
|
4597
4633
|
C: (f, a) => f(...a)
|
|
4598
4634
|
});
|
|
@@ -4600,6 +4636,9 @@ var DataSpaceManager = class {
|
|
|
4600
4636
|
await this._createDelegatedInvitations(dataSpace, [
|
|
4601
4637
|
...space.spaceState.invitations.entries()
|
|
4602
4638
|
]);
|
|
4639
|
+
this._handleMemberRoleChanges(presence, space.protocol, [
|
|
4640
|
+
...space.spaceState.members.values()
|
|
4641
|
+
]);
|
|
4603
4642
|
this.updated.emit();
|
|
4604
4643
|
}
|
|
4605
4644
|
},
|
|
@@ -4608,7 +4647,7 @@ var DataSpaceManager = class {
|
|
|
4608
4647
|
space: space.key
|
|
4609
4648
|
}, {
|
|
4610
4649
|
F: __dxlog_file14,
|
|
4611
|
-
L:
|
|
4650
|
+
L: 298,
|
|
4612
4651
|
S: this,
|
|
4613
4652
|
C: (f, a) => f(...a)
|
|
4614
4653
|
});
|
|
@@ -4616,6 +4655,11 @@ var DataSpaceManager = class {
|
|
|
4616
4655
|
},
|
|
4617
4656
|
cache: metadata.cache
|
|
4618
4657
|
});
|
|
4658
|
+
presence.newPeer.on((peerState) => {
|
|
4659
|
+
if (dataSpace.state === import_services10.SpaceState.READY) {
|
|
4660
|
+
this._handleNewPeerConnected(space, peerState);
|
|
4661
|
+
}
|
|
4662
|
+
});
|
|
4619
4663
|
if (metadata.state !== import_services10.SpaceState.INACTIVE) {
|
|
4620
4664
|
await dataSpace.open();
|
|
4621
4665
|
}
|
|
@@ -4625,6 +4669,51 @@ var DataSpaceManager = class {
|
|
|
4625
4669
|
this._spaces.set(metadata.key, dataSpace);
|
|
4626
4670
|
return dataSpace;
|
|
4627
4671
|
}
|
|
4672
|
+
_handleMemberRoleChanges(presence, spaceProtocol, memberInfo) {
|
|
4673
|
+
let closedSessions = 0;
|
|
4674
|
+
for (const member of memberInfo) {
|
|
4675
|
+
if (member.key.equals(presence.getLocalState().identityKey)) {
|
|
4676
|
+
continue;
|
|
4677
|
+
}
|
|
4678
|
+
const peers = presence.getPeersByIdentityKey(member.key);
|
|
4679
|
+
const sessions = peers.map((p) => p.peerId && spaceProtocol.sessions.get(p.peerId));
|
|
4680
|
+
const sessionsToClose = sessions.filter((s) => {
|
|
4681
|
+
return (s && member.role === import_credentials15.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline4.AuthStatus.FAILURE)) ?? false;
|
|
4682
|
+
});
|
|
4683
|
+
sessionsToClose.forEach((session) => {
|
|
4684
|
+
void session.close().catch(import_log12.log.error);
|
|
4685
|
+
});
|
|
4686
|
+
closedSessions += sessionsToClose.length;
|
|
4687
|
+
}
|
|
4688
|
+
(0, import_log12.log)("processed member role changes", {
|
|
4689
|
+
roleChangeCount: memberInfo.length,
|
|
4690
|
+
peersOnline: presence.getPeersOnline().length,
|
|
4691
|
+
closedSessions
|
|
4692
|
+
}, {
|
|
4693
|
+
F: __dxlog_file14,
|
|
4694
|
+
L: 338,
|
|
4695
|
+
S: this,
|
|
4696
|
+
C: (f, a) => f(...a)
|
|
4697
|
+
});
|
|
4698
|
+
spaceProtocol.updateTopology();
|
|
4699
|
+
}
|
|
4700
|
+
_handleNewPeerConnected(space, peerState) {
|
|
4701
|
+
const role = space.spaceState.getMemberRole(peerState.identityKey);
|
|
4702
|
+
if (role === import_credentials15.SpaceMember.Role.REMOVED) {
|
|
4703
|
+
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
4704
|
+
if (session != null) {
|
|
4705
|
+
(0, import_log12.log)("closing a session with a removed peer", {
|
|
4706
|
+
peerId: peerState.peerId
|
|
4707
|
+
}, {
|
|
4708
|
+
F: __dxlog_file14,
|
|
4709
|
+
L: 352,
|
|
4710
|
+
S: this,
|
|
4711
|
+
C: (f, a) => f(...a)
|
|
4712
|
+
});
|
|
4713
|
+
void session.close().catch(import_log12.log.error);
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4716
|
+
}
|
|
4628
4717
|
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4629
4718
|
if (dataSpace?.state !== import_services10.SpaceState.READY) {
|
|
4630
4719
|
return;
|
|
@@ -4684,9 +4773,7 @@ var SpacesServiceImpl = class {
|
|
|
4684
4773
|
this._getDataSpaceManager = _getDataSpaceManager;
|
|
4685
4774
|
}
|
|
4686
4775
|
async createSpace() {
|
|
4687
|
-
|
|
4688
|
-
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
|
|
4689
|
-
}
|
|
4776
|
+
this._requireIdentity();
|
|
4690
4777
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4691
4778
|
const space = await dataSpaceManager.createSpace();
|
|
4692
4779
|
return this._serializeSpace(space);
|
|
@@ -4707,8 +4794,39 @@ var SpacesServiceImpl = class {
|
|
|
4707
4794
|
}
|
|
4708
4795
|
}
|
|
4709
4796
|
}
|
|
4710
|
-
async updateMemberRole(
|
|
4711
|
-
|
|
4797
|
+
async updateMemberRole(request) {
|
|
4798
|
+
const identity = this._requireIdentity();
|
|
4799
|
+
const space = this._spaceManager.spaces.get(request.spaceKey);
|
|
4800
|
+
if (space == null) {
|
|
4801
|
+
throw new import_protocols11.SpaceNotFoundError(request.spaceKey);
|
|
4802
|
+
}
|
|
4803
|
+
if (!space.spaceState.hasMembershipManagementPermission(identity.identityKey)) {
|
|
4804
|
+
throw new import_protocols11.AuthorizationError("No member management permission.", {
|
|
4805
|
+
spaceKey: space.key,
|
|
4806
|
+
role: space.spaceState.getMemberRole(identity.identityKey)
|
|
4807
|
+
});
|
|
4808
|
+
}
|
|
4809
|
+
const credentials = await (0, import_credentials18.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
4810
|
+
(0, import_invariant14.invariant)(credentials[0].credential, void 0, {
|
|
4811
|
+
F: __dxlog_file15,
|
|
4812
|
+
L: 95,
|
|
4813
|
+
S: this,
|
|
4814
|
+
A: [
|
|
4815
|
+
"credentials[0].credential",
|
|
4816
|
+
""
|
|
4817
|
+
]
|
|
4818
|
+
});
|
|
4819
|
+
const spaceMemberCredential = credentials[0].credential.credential;
|
|
4820
|
+
(0, import_invariant14.invariant)((0, import_credentials18.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4821
|
+
F: __dxlog_file15,
|
|
4822
|
+
L: 97,
|
|
4823
|
+
S: this,
|
|
4824
|
+
A: [
|
|
4825
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
4826
|
+
""
|
|
4827
|
+
]
|
|
4828
|
+
});
|
|
4829
|
+
await (0, import_feed_store4.writeMessages)(space.controlPipeline.writer, credentials);
|
|
4712
4830
|
}
|
|
4713
4831
|
querySpaces() {
|
|
4714
4832
|
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
@@ -4719,7 +4837,7 @@ var SpacesServiceImpl = class {
|
|
|
4719
4837
|
spaces
|
|
4720
4838
|
}, {
|
|
4721
4839
|
F: __dxlog_file15,
|
|
4722
|
-
L:
|
|
4840
|
+
L: 108,
|
|
4723
4841
|
S: this,
|
|
4724
4842
|
C: (f, a) => f(...a)
|
|
4725
4843
|
});
|
|
@@ -4802,7 +4920,7 @@ var SpacesServiceImpl = class {
|
|
|
4802
4920
|
} else {
|
|
4803
4921
|
(0, import_invariant14.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4804
4922
|
F: __dxlog_file15,
|
|
4805
|
-
L:
|
|
4923
|
+
L: 195,
|
|
4806
4924
|
S: this,
|
|
4807
4925
|
A: [
|
|
4808
4926
|
"!credential.id",
|
|
@@ -4811,7 +4929,7 @@ var SpacesServiceImpl = class {
|
|
|
4811
4929
|
});
|
|
4812
4930
|
(0, import_invariant14.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
4813
4931
|
F: __dxlog_file15,
|
|
4814
|
-
L:
|
|
4932
|
+
L: 196,
|
|
4815
4933
|
S: this,
|
|
4816
4934
|
A: [
|
|
4817
4935
|
"this._identityManager.identity",
|
|
@@ -4821,7 +4939,7 @@ var SpacesServiceImpl = class {
|
|
|
4821
4939
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4822
4940
|
(0, import_invariant14.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4823
4941
|
F: __dxlog_file15,
|
|
4824
|
-
L:
|
|
4942
|
+
L: 198,
|
|
4825
4943
|
S: this,
|
|
4826
4944
|
A: [
|
|
4827
4945
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -4876,7 +4994,8 @@ var SpacesServiceImpl = class {
|
|
|
4876
4994
|
identityKey: member.key,
|
|
4877
4995
|
profile: member.profile ?? {}
|
|
4878
4996
|
},
|
|
4879
|
-
|
|
4997
|
+
role: member.role,
|
|
4998
|
+
presence: peers.length > 0 ? import_services11.SpaceMember.PresenceState.ONLINE : import_services11.SpaceMember.PresenceState.OFFLINE,
|
|
4880
4999
|
peerStates: peers
|
|
4881
5000
|
};
|
|
4882
5001
|
}),
|
|
@@ -4885,6 +5004,12 @@ var SpacesServiceImpl = class {
|
|
|
4885
5004
|
metrics: space.metrics
|
|
4886
5005
|
};
|
|
4887
5006
|
}
|
|
5007
|
+
_requireIdentity() {
|
|
5008
|
+
if (!this._identityManager.identity) {
|
|
5009
|
+
throw new import_protocols11.IdentityNotInitializedError("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
|
|
5010
|
+
}
|
|
5011
|
+
return this._identityManager.identity;
|
|
5012
|
+
}
|
|
4888
5013
|
};
|
|
4889
5014
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
4890
5015
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
@@ -4909,21 +5034,21 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
4909
5034
|
this.initialized = new import_async16.Trigger();
|
|
4910
5035
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4911
5036
|
this._instanceId = import_keys12.PublicKey.random().toHex();
|
|
4912
|
-
this.metadataStore = new
|
|
4913
|
-
this.snapshotStore = new
|
|
5037
|
+
this.metadataStore = new import_echo_pipeline5.MetadataStore(storage.createDirectory("metadata"));
|
|
5038
|
+
this.snapshotStore = new import_echo_pipeline5.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4914
5039
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
4915
5040
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
4916
|
-
this.feedStore = new
|
|
4917
|
-
factory: new
|
|
5041
|
+
this.feedStore = new import_feed_store5.FeedStore({
|
|
5042
|
+
factory: new import_feed_store5.FeedFactory({
|
|
4918
5043
|
root: storage.createDirectory("feeds"),
|
|
4919
5044
|
signer: this.keyring,
|
|
4920
5045
|
hypercore: {
|
|
4921
|
-
valueEncoding:
|
|
5046
|
+
valueEncoding: import_echo_pipeline5.valueEncoding,
|
|
4922
5047
|
stats: true
|
|
4923
5048
|
}
|
|
4924
5049
|
})
|
|
4925
5050
|
});
|
|
4926
|
-
this.spaceManager = new
|
|
5051
|
+
this.spaceManager = new import_echo_pipeline5.SpaceManager({
|
|
4927
5052
|
feedStore: this.feedStore,
|
|
4928
5053
|
networkManager: this.networkManager,
|
|
4929
5054
|
blobStore: this.blobStore,
|
|
@@ -5089,7 +5214,7 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5089
5214
|
this.initialized.wake();
|
|
5090
5215
|
this._deviceSpaceSync = {
|
|
5091
5216
|
processCredential: async (credential) => {
|
|
5092
|
-
const assertion = (0,
|
|
5217
|
+
const assertion = (0, import_credentials19.getCredentialAssertion)(credential);
|
|
5093
5218
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
5094
5219
|
return;
|
|
5095
5220
|
}
|
|
@@ -5176,7 +5301,7 @@ var ServiceRegistry = class {
|
|
|
5176
5301
|
delete this._handlers[name];
|
|
5177
5302
|
}
|
|
5178
5303
|
};
|
|
5179
|
-
var DXOS_VERSION = "0.5.3-
|
|
5304
|
+
var DXOS_VERSION = "0.5.3-next.2c59258";
|
|
5180
5305
|
var getPlatform = () => {
|
|
5181
5306
|
if (process.browser) {
|
|
5182
5307
|
if (typeof window !== "undefined") {
|
|
@@ -5274,11 +5399,12 @@ var getSpaceStats = async (space) => {
|
|
|
5274
5399
|
const stats = {
|
|
5275
5400
|
key: space.key,
|
|
5276
5401
|
metrics: space.metrics,
|
|
5277
|
-
epochs: space.inner.spaceState.credentials.filter((0,
|
|
5402
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials20.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
5278
5403
|
...credential.subject.assertion,
|
|
5279
5404
|
id: credential.id
|
|
5280
5405
|
})),
|
|
5281
5406
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
5407
|
+
role: member.role,
|
|
5282
5408
|
identity: {
|
|
5283
5409
|
identityKey: member.key,
|
|
5284
5410
|
profile: {
|
|
@@ -6195,4 +6321,4 @@ var findConfigs = () => {
|
|
|
6195
6321
|
subscribeToSpaces,
|
|
6196
6322
|
subscribeToSwarmInfo
|
|
6197
6323
|
});
|
|
6198
|
-
//# sourceMappingURL=chunk-
|
|
6324
|
+
//# sourceMappingURL=chunk-VOYHS6QR.cjs.map
|