@dxos/client-services 0.1.56-main.d9d1c3e → 0.1.56-main.da2eab1
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-P6TNW4K5.mjs → chunk-CXJ3H4F5.mjs} +278 -287
- package/dist/lib/browser/chunk-CXJ3H4F5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +8 -13
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +30 -45
- package/dist/lib/browser/packlets/testing/index.mjs.map +2 -2
- package/dist/lib/node/index.cjs +298 -312
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +310 -330
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts +5 -0
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +7 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- 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/version.d.ts +1 -1
- package/package.json +34 -34
- package/src/packlets/identity/identity-manager.test.ts +11 -0
- package/src/packlets/identity/identity-manager.ts +18 -1
- package/src/packlets/identity/identity-service.test.ts +15 -1
- package/src/packlets/identity/identity-service.ts +23 -14
- package/src/packlets/invitations/invitations-handler.ts +2 -0
- package/src/packlets/services/diagnostics.ts +2 -1
- package/src/packlets/services/service-context.test.ts +59 -0
- package/src/packlets/services/service-context.ts +7 -4
- package/src/packlets/services/service-host.test.ts +1 -1
- package/src/packlets/services/service-host.ts +11 -7
- package/src/packlets/spaces/data-space-manager.test.ts +80 -22
- package/src/packlets/spaces/data-space-manager.ts +5 -1
- package/src/packlets/spaces/data-space.ts +16 -4
- package/src/packlets/vault/worker-runtime.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-P6TNW4K5.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -75,7 +75,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
75
75
|
const feedMap = new import_util.ComplexMap(import_keys.PublicKey.hash);
|
|
76
76
|
const update = () => {
|
|
77
77
|
const { feeds } = feedStore;
|
|
78
|
-
feeds.filter((feed) => !
|
|
78
|
+
feeds.filter((feed) => !feedKeys?.length || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
|
|
79
79
|
if (!feedMap.has(feed.key)) {
|
|
80
80
|
feedMap.set(feed.key, feed);
|
|
81
81
|
feed.on("close", update);
|
|
@@ -83,15 +83,12 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
next({
|
|
86
|
-
feeds: Array.from(feedMap.values()).map((feed) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
downloaded: (_b = (_a = feed.core.bitfield) == null ? void 0 : _a.data.toBuffer()) != null ? _b : new Uint8Array()
|
|
93
|
-
};
|
|
94
|
-
})
|
|
86
|
+
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
87
|
+
feedKey: feed.key,
|
|
88
|
+
length: feed.properties.length,
|
|
89
|
+
bytes: feed.core.byteLength,
|
|
90
|
+
downloaded: feed.core.bitfield?.data.toBuffer() ?? new Uint8Array()
|
|
91
|
+
}))
|
|
95
92
|
});
|
|
96
93
|
};
|
|
97
94
|
subscriptions.add(feedStore.feedOpened.on(update));
|
|
@@ -191,13 +188,13 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf4.Stream
|
|
|
191
188
|
recipient: message.recipient.asUint8Array(),
|
|
192
189
|
payload: message.payload
|
|
193
190
|
},
|
|
194
|
-
receivedAt: new Date()
|
|
191
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
195
192
|
});
|
|
196
193
|
});
|
|
197
194
|
signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
198
195
|
next({
|
|
199
196
|
swarmEvent: swarmEvent.swarmEvent,
|
|
200
|
-
receivedAt: new Date()
|
|
197
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
201
198
|
});
|
|
202
199
|
});
|
|
203
200
|
return () => {
|
|
@@ -208,13 +205,10 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
|
|
|
208
205
|
const update = () => {
|
|
209
206
|
try {
|
|
210
207
|
const topics = networkManager.topics;
|
|
211
|
-
const labeledTopics = topics.map((topic) => {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
label: (_b = (_a = networkManager.getSwarm(topic)) == null ? void 0 : _a.label) != null ? _b : topic.toHex()
|
|
216
|
-
};
|
|
217
|
-
});
|
|
208
|
+
const labeledTopics = topics.map((topic) => ({
|
|
209
|
+
topic,
|
|
210
|
+
label: networkManager.getSwarm(topic)?.label ?? topic.toHex()
|
|
211
|
+
}));
|
|
218
212
|
next({
|
|
219
213
|
topics: labeledTopics
|
|
220
214
|
});
|
|
@@ -226,17 +220,15 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
|
|
|
226
220
|
update();
|
|
227
221
|
});
|
|
228
222
|
var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf4.Stream(({ next }) => {
|
|
229
|
-
var _a;
|
|
230
223
|
const update = () => {
|
|
231
|
-
|
|
232
|
-
const info = (_a2 = networkManager.connectionLog) == null ? void 0 : _a2.swarms;
|
|
224
|
+
const info = networkManager.connectionLog?.swarms;
|
|
233
225
|
if (info) {
|
|
234
226
|
next({
|
|
235
227
|
data: info
|
|
236
228
|
});
|
|
237
229
|
}
|
|
238
230
|
};
|
|
239
|
-
|
|
231
|
+
networkManager.connectionLog?.update.on(update);
|
|
240
232
|
update();
|
|
241
233
|
});
|
|
242
234
|
var getNetworkPeers = ({ networkManager }, request) => {
|
|
@@ -245,7 +237,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
|
|
|
245
237
|
}
|
|
246
238
|
const map = networkManager.getSwarmMap(import_keys2.PublicKey.from(request.topic));
|
|
247
239
|
return {
|
|
248
|
-
peers: map
|
|
240
|
+
peers: map?.peers.map((peer) => ({
|
|
249
241
|
...peer,
|
|
250
242
|
connections: peer.connections.map((connection) => connection.asUint8Array())
|
|
251
243
|
}))
|
|
@@ -261,14 +253,14 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
261
253
|
const spaces = [
|
|
262
254
|
...context.spaceManager.spaces.values()
|
|
263
255
|
];
|
|
264
|
-
const filteredSpaces = spaces.filter((space) => !
|
|
256
|
+
const filteredSpaces = spaces.filter((space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
|
|
265
257
|
next({
|
|
266
258
|
spaces: filteredSpaces.map((space) => {
|
|
267
259
|
const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata2) => spaceMetadata2.key.equals(space.key));
|
|
268
260
|
return {
|
|
269
261
|
key: space.key,
|
|
270
262
|
isOpen: space.isOpen,
|
|
271
|
-
timeframe: spaceMetadata
|
|
263
|
+
timeframe: spaceMetadata?.dataTimeframe,
|
|
272
264
|
genesisFeed: space.genesisFeedKey,
|
|
273
265
|
controlFeed: space.controlFeedKey,
|
|
274
266
|
dataFeed: space.dataFeedKey
|
|
@@ -282,7 +274,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
282
274
|
await update();
|
|
283
275
|
});
|
|
284
276
|
return () => {
|
|
285
|
-
unsubscribe
|
|
277
|
+
unsubscribe?.();
|
|
286
278
|
clearTimeout(timeout);
|
|
287
279
|
};
|
|
288
280
|
});
|
|
@@ -313,16 +305,15 @@ var DevtoolsServiceImpl = class {
|
|
|
313
305
|
};
|
|
314
306
|
}
|
|
315
307
|
async getStorageInfo() {
|
|
316
|
-
|
|
317
|
-
const storageUsage = (_c = await ((_b = (_a = this.params.context.storage).getDiskInfo) == null ? void 0 : _b.call(_a))) != null ? _c : {
|
|
308
|
+
const storageUsage = await this.params.context.storage.getDiskInfo?.() ?? {
|
|
318
309
|
used: 0
|
|
319
310
|
};
|
|
320
311
|
const navigatorInfo = typeof navigator === "object" ? await navigator.storage.estimate() : void 0;
|
|
321
312
|
return {
|
|
322
313
|
type: this.params.context.storage.type,
|
|
323
314
|
storageUsage: storageUsage.used,
|
|
324
|
-
originUsage:
|
|
325
|
-
usageQuota:
|
|
315
|
+
originUsage: navigatorInfo?.usage ?? 0,
|
|
316
|
+
usageQuota: navigatorInfo?.quota ?? 0
|
|
326
317
|
};
|
|
327
318
|
}
|
|
328
319
|
async getBlobs() {
|
|
@@ -508,7 +499,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
508
499
|
return await trigger.wait({
|
|
509
500
|
timeout: this._params.authTimeout
|
|
510
501
|
});
|
|
511
|
-
} catch
|
|
502
|
+
} catch {
|
|
512
503
|
return false;
|
|
513
504
|
} finally {
|
|
514
505
|
clear();
|
|
@@ -604,11 +595,10 @@ var Identity = class Identity2 {
|
|
|
604
595
|
return this._deviceStateMachine.deviceCredentialChain;
|
|
605
596
|
}
|
|
606
597
|
getAdmissionCredentials() {
|
|
607
|
-
var _a, _b;
|
|
608
598
|
return {
|
|
609
599
|
deviceKey: this.deviceKey,
|
|
610
|
-
controlFeedKey:
|
|
611
|
-
dataFeedKey:
|
|
600
|
+
controlFeedKey: this.space.controlFeedKey ?? (0, import_debug.failUndefined)(),
|
|
601
|
+
dataFeedKey: this.space.dataFeedKey ?? (0, import_debug.failUndefined)()
|
|
612
602
|
};
|
|
613
603
|
}
|
|
614
604
|
/**
|
|
@@ -702,6 +692,7 @@ var import_keys4 = require("@dxos/keys");
|
|
|
702
692
|
var import_log3 = require("@dxos/log");
|
|
703
693
|
var import_protocols2 = require("@dxos/protocols");
|
|
704
694
|
var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
695
|
+
var import_timeframe = require("@dxos/timeframe");
|
|
705
696
|
var import_tracing2 = require("@dxos/tracing");
|
|
706
697
|
var import_util2 = require("@dxos/util");
|
|
707
698
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
@@ -729,7 +720,6 @@ var IdentityManager = class IdentityManager2 {
|
|
|
729
720
|
return this._identity;
|
|
730
721
|
}
|
|
731
722
|
async open(ctx) {
|
|
732
|
-
var _a;
|
|
733
723
|
const traceId = import_keys4.PublicKey.random().toHex();
|
|
734
724
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
|
|
735
725
|
id: traceId
|
|
@@ -755,7 +745,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
755
745
|
await this._identity.ready();
|
|
756
746
|
import_log3.log.trace("dxos.halo.identity", {
|
|
757
747
|
identityKey: identityRecord.identityKey,
|
|
758
|
-
displayName:
|
|
748
|
+
displayName: this._identity.profileDocument?.displayName
|
|
759
749
|
}, {
|
|
760
750
|
F: __dxlog_file3,
|
|
761
751
|
L: 82,
|
|
@@ -774,11 +764,9 @@ var IdentityManager = class IdentityManager2 {
|
|
|
774
764
|
});
|
|
775
765
|
}
|
|
776
766
|
async close() {
|
|
777
|
-
|
|
778
|
-
await ((_a = this._identity) == null ? void 0 : _a.close(new import_context3.Context()));
|
|
767
|
+
await this._identity?.close(new import_context3.Context());
|
|
779
768
|
}
|
|
780
769
|
async createIdentity({ displayName } = {}) {
|
|
781
|
-
var _a;
|
|
782
770
|
(0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
|
|
783
771
|
F: __dxlog_file3,
|
|
784
772
|
L: 96,
|
|
@@ -852,7 +840,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
852
840
|
await this._identity.ready();
|
|
853
841
|
import_log3.log.trace("dxos.halo.identity", {
|
|
854
842
|
identityKey: identityRecord.identityKey,
|
|
855
|
-
displayName:
|
|
843
|
+
displayName: this._identity.profileDocument?.displayName
|
|
856
844
|
}, {
|
|
857
845
|
F: __dxlog_file3,
|
|
858
846
|
L: 152,
|
|
@@ -875,7 +863,6 @@ var IdentityManager = class IdentityManager2 {
|
|
|
875
863
|
* Accept an existing identity. Expects it's device key to be authorized (now or later).
|
|
876
864
|
*/
|
|
877
865
|
async acceptIdentity(params) {
|
|
878
|
-
var _a;
|
|
879
866
|
(0, import_log3.log)("accepting identity", {
|
|
880
867
|
params
|
|
881
868
|
}, {
|
|
@@ -911,7 +898,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
911
898
|
await this._identity.ready();
|
|
912
899
|
import_log3.log.trace("dxos.halo.identity", {
|
|
913
900
|
identityKey: identityRecord.identityKey,
|
|
914
|
-
displayName:
|
|
901
|
+
displayName: this._identity.profileDocument?.displayName
|
|
915
902
|
}, {
|
|
916
903
|
F: __dxlog_file3,
|
|
917
904
|
L: 186,
|
|
@@ -930,10 +917,42 @@ var IdentityManager = class IdentityManager2 {
|
|
|
930
917
|
});
|
|
931
918
|
return identity;
|
|
932
919
|
}
|
|
920
|
+
/**
|
|
921
|
+
* Update the profile document of an existing identity.
|
|
922
|
+
*/
|
|
923
|
+
async updateProfile(profile) {
|
|
924
|
+
(0, import_invariant2.invariant)(this._identity, "Identity not initialized.", {
|
|
925
|
+
F: __dxlog_file3,
|
|
926
|
+
L: 200,
|
|
927
|
+
S: this,
|
|
928
|
+
A: [
|
|
929
|
+
"this._identity",
|
|
930
|
+
"'Identity not initialized.'"
|
|
931
|
+
]
|
|
932
|
+
});
|
|
933
|
+
const credential = await this._identity.getIdentityCredentialSigner().createCredential({
|
|
934
|
+
subject: this._identity.identityKey,
|
|
935
|
+
assertion: {
|
|
936
|
+
"@type": "dxos.halo.credentials.IdentityProfile",
|
|
937
|
+
profile
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
const receipt = await this._identity.controlPipeline.writer.write({
|
|
941
|
+
credential: {
|
|
942
|
+
credential
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
await this._identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
|
|
946
|
+
[
|
|
947
|
+
receipt.feedKey,
|
|
948
|
+
receipt.seq
|
|
949
|
+
]
|
|
950
|
+
]));
|
|
951
|
+
}
|
|
933
952
|
async _constructIdentity(identityRecord) {
|
|
934
953
|
(0, import_invariant2.invariant)(!this._identity, void 0, {
|
|
935
954
|
F: __dxlog_file3,
|
|
936
|
-
L:
|
|
955
|
+
L: 214,
|
|
937
956
|
S: this,
|
|
938
957
|
A: [
|
|
939
958
|
"!this._identity",
|
|
@@ -944,13 +963,13 @@ var IdentityManager = class IdentityManager2 {
|
|
|
944
963
|
identityRecord
|
|
945
964
|
}, {
|
|
946
965
|
F: __dxlog_file3,
|
|
947
|
-
L:
|
|
966
|
+
L: 215,
|
|
948
967
|
S: this,
|
|
949
968
|
C: (f, a) => f(...a)
|
|
950
969
|
});
|
|
951
970
|
(0, import_invariant2.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
952
971
|
F: __dxlog_file3,
|
|
953
|
-
L:
|
|
972
|
+
L: 218,
|
|
954
973
|
S: this,
|
|
955
974
|
A: [
|
|
956
975
|
"identityRecord.haloSpace.controlFeedKey",
|
|
@@ -962,7 +981,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
962
981
|
});
|
|
963
982
|
(0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
964
983
|
F: __dxlog_file3,
|
|
965
|
-
L:
|
|
984
|
+
L: 222,
|
|
966
985
|
S: this,
|
|
967
986
|
A: [
|
|
968
987
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -994,7 +1013,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
994
1013
|
identityKey: identityRecord.identityKey
|
|
995
1014
|
}, {
|
|
996
1015
|
F: __dxlog_file3,
|
|
997
|
-
L:
|
|
1016
|
+
L: 246,
|
|
998
1017
|
S: this,
|
|
999
1018
|
C: (f, a) => f(...a)
|
|
1000
1019
|
});
|
|
@@ -1015,7 +1034,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
1015
1034
|
onAuthFailure: () => {
|
|
1016
1035
|
import_log3.log.warn("auth failure", void 0, {
|
|
1017
1036
|
F: __dxlog_file3,
|
|
1018
|
-
L:
|
|
1037
|
+
L: 265,
|
|
1019
1038
|
S: this,
|
|
1020
1039
|
C: (f, a) => f(...a)
|
|
1021
1040
|
});
|
|
@@ -1038,12 +1057,13 @@ var import_debug2 = require("@dxos/debug");
|
|
|
1038
1057
|
var import_invariant3 = require("@dxos/invariant");
|
|
1039
1058
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
1040
1059
|
var IdentityServiceImpl = class {
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
this.
|
|
1060
|
+
constructor(_createIdentity, _identityManager, _keyring) {
|
|
1061
|
+
this._createIdentity = _createIdentity;
|
|
1062
|
+
this._identityManager = _identityManager;
|
|
1063
|
+
this._keyring = _keyring;
|
|
1044
1064
|
}
|
|
1045
1065
|
async createIdentity(request) {
|
|
1046
|
-
await this.
|
|
1066
|
+
await this._createIdentity(request);
|
|
1047
1067
|
return this._getIdentity();
|
|
1048
1068
|
}
|
|
1049
1069
|
async recoverIdentity(request) {
|
|
@@ -1055,34 +1075,47 @@ var IdentityServiceImpl = class {
|
|
|
1055
1075
|
identity: this._getIdentity()
|
|
1056
1076
|
});
|
|
1057
1077
|
emitNext();
|
|
1058
|
-
return this.
|
|
1078
|
+
return this._identityManager.stateUpdate.on(emitNext);
|
|
1059
1079
|
});
|
|
1060
1080
|
}
|
|
1061
1081
|
_getIdentity() {
|
|
1062
|
-
if (!this.
|
|
1082
|
+
if (!this._identityManager.identity) {
|
|
1063
1083
|
return void 0;
|
|
1064
1084
|
}
|
|
1065
1085
|
return {
|
|
1066
|
-
identityKey: this.
|
|
1067
|
-
spaceKey: this.
|
|
1068
|
-
profile: this.
|
|
1086
|
+
identityKey: this._identityManager.identity.identityKey,
|
|
1087
|
+
spaceKey: this._identityManager.identity.space.key,
|
|
1088
|
+
profile: this._identityManager.identity.profileDocument
|
|
1069
1089
|
};
|
|
1070
1090
|
}
|
|
1091
|
+
async updateProfile(profile) {
|
|
1092
|
+
(0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1093
|
+
F: __dxlog_file4,
|
|
1094
|
+
L: 59,
|
|
1095
|
+
S: this,
|
|
1096
|
+
A: [
|
|
1097
|
+
"this._identityManager.identity",
|
|
1098
|
+
"'Identity not initialized.'"
|
|
1099
|
+
]
|
|
1100
|
+
});
|
|
1101
|
+
await this._identityManager.updateProfile(profile);
|
|
1102
|
+
return this._getIdentity();
|
|
1103
|
+
}
|
|
1071
1104
|
async signPresentation({ presentation, nonce }) {
|
|
1072
|
-
(0, import_invariant3.invariant)(this.
|
|
1105
|
+
(0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1073
1106
|
F: __dxlog_file4,
|
|
1074
|
-
L:
|
|
1107
|
+
L: 65,
|
|
1075
1108
|
S: this,
|
|
1076
1109
|
A: [
|
|
1077
|
-
"this.
|
|
1110
|
+
"this._identityManager.identity",
|
|
1078
1111
|
"'Identity not initialized.'"
|
|
1079
1112
|
]
|
|
1080
1113
|
});
|
|
1081
1114
|
return await (0, import_credentials6.signPresentation)({
|
|
1082
1115
|
presentation,
|
|
1083
|
-
signer: this.
|
|
1084
|
-
signerKey: this.
|
|
1085
|
-
chain: this.
|
|
1116
|
+
signer: this._keyring,
|
|
1117
|
+
signerKey: this._identityManager.identity.deviceKey,
|
|
1118
|
+
chain: this._identityManager.identity.deviceCredentialChain,
|
|
1086
1119
|
nonce
|
|
1087
1120
|
});
|
|
1088
1121
|
}
|
|
@@ -1418,7 +1451,6 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1418
1451
|
};
|
|
1419
1452
|
}
|
|
1420
1453
|
async onOpen(context) {
|
|
1421
|
-
var _a;
|
|
1422
1454
|
await super.onOpen(context);
|
|
1423
1455
|
try {
|
|
1424
1456
|
await this.rpc.InvitationHostService.options({
|
|
@@ -1427,7 +1459,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1427
1459
|
await (0, import_context4.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1428
1460
|
timeout: OPTIONS_TIMEOUT
|
|
1429
1461
|
}));
|
|
1430
|
-
if (
|
|
1462
|
+
if (this._remoteOptions?.role !== import_invitations.Options.Role.GUEST) {
|
|
1431
1463
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
1432
1464
|
expected: import_invitations.Options.Role.GUEST,
|
|
1433
1465
|
remoteOptions: this._remoteOptions
|
|
@@ -1485,7 +1517,6 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1485
1517
|
};
|
|
1486
1518
|
}
|
|
1487
1519
|
async onOpen(context) {
|
|
1488
|
-
var _a;
|
|
1489
1520
|
await super.onOpen(context);
|
|
1490
1521
|
try {
|
|
1491
1522
|
(0, import_log4.log)("begin options", void 0, {
|
|
@@ -1506,7 +1537,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1506
1537
|
S: this,
|
|
1507
1538
|
C: (f, a) => f(...a)
|
|
1508
1539
|
});
|
|
1509
|
-
if (
|
|
1540
|
+
if (this._remoteOptions?.role !== import_invitations.Options.Role.HOST) {
|
|
1510
1541
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
1511
1542
|
expected: import_invitations.Options.Role.HOST,
|
|
1512
1543
|
remoteOptions: this._remoteOptions
|
|
@@ -1545,9 +1576,8 @@ var InvitationsHandler = class {
|
|
|
1545
1576
|
this._networkManager = _networkManager;
|
|
1546
1577
|
}
|
|
1547
1578
|
createInvitation(protocol, options) {
|
|
1548
|
-
|
|
1549
|
-
const
|
|
1550
|
-
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1579
|
+
const { invitationId = import_keys6.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys6.PublicKey.random() } = options ?? {};
|
|
1580
|
+
const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1551
1581
|
(0, import_invariant6.invariant)(protocol, void 0, {
|
|
1552
1582
|
F: __dxlog_file7,
|
|
1553
1583
|
L: 76,
|
|
@@ -1600,9 +1630,8 @@ var InvitationsHandler = class {
|
|
|
1600
1630
|
return invitation;
|
|
1601
1631
|
},
|
|
1602
1632
|
admit: async (admissionRequest) => {
|
|
1603
|
-
var _a2, _b, _c;
|
|
1604
1633
|
try {
|
|
1605
|
-
const deviceKey =
|
|
1634
|
+
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1606
1635
|
(0, import_invariant6.invariant)(deviceKey, void 0, {
|
|
1607
1636
|
F: __dxlog_file7,
|
|
1608
1637
|
L: 119,
|
|
@@ -1747,7 +1776,8 @@ var InvitationsHandler = class {
|
|
|
1747
1776
|
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
1748
1777
|
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
1749
1778
|
}),
|
|
1750
|
-
topology: new import_network_manager.StarTopology(topic)
|
|
1779
|
+
topology: new import_network_manager.StarTopology(topic),
|
|
1780
|
+
label: "invitation host"
|
|
1751
1781
|
});
|
|
1752
1782
|
ctx.onDispose(() => swarmConnection.close());
|
|
1753
1783
|
stream.next({
|
|
@@ -1772,7 +1802,7 @@ var InvitationsHandler = class {
|
|
|
1772
1802
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1773
1803
|
(0, import_invariant6.invariant)(protocol, void 0, {
|
|
1774
1804
|
F: __dxlog_file7,
|
|
1775
|
-
L:
|
|
1805
|
+
L: 211,
|
|
1776
1806
|
S: this,
|
|
1777
1807
|
A: [
|
|
1778
1808
|
"protocol",
|
|
@@ -1786,7 +1816,7 @@ var InvitationsHandler = class {
|
|
|
1786
1816
|
const setState = (newData) => {
|
|
1787
1817
|
(0, import_invariant6.invariant)(newData.state !== void 0, void 0, {
|
|
1788
1818
|
F: __dxlog_file7,
|
|
1789
|
-
L:
|
|
1819
|
+
L: 222,
|
|
1790
1820
|
S: this,
|
|
1791
1821
|
A: [
|
|
1792
1822
|
"newData.state !== undefined",
|
|
@@ -1806,7 +1836,7 @@ var InvitationsHandler = class {
|
|
|
1806
1836
|
...protocol.toJSON()
|
|
1807
1837
|
}, {
|
|
1808
1838
|
F: __dxlog_file7,
|
|
1809
|
-
L:
|
|
1839
|
+
L: 230,
|
|
1810
1840
|
S: this,
|
|
1811
1841
|
C: (f, a) => f(...a)
|
|
1812
1842
|
});
|
|
@@ -1816,7 +1846,7 @@ var InvitationsHandler = class {
|
|
|
1816
1846
|
} else {
|
|
1817
1847
|
import_log5.log.warn("auth failed", err, {
|
|
1818
1848
|
F: __dxlog_file7,
|
|
1819
|
-
L:
|
|
1849
|
+
L: 233,
|
|
1820
1850
|
S: this,
|
|
1821
1851
|
C: (f, a) => f(...a)
|
|
1822
1852
|
});
|
|
@@ -1830,7 +1860,7 @@ var InvitationsHandler = class {
|
|
|
1830
1860
|
...protocol.toJSON()
|
|
1831
1861
|
}, {
|
|
1832
1862
|
F: __dxlog_file7,
|
|
1833
|
-
L:
|
|
1863
|
+
L: 241,
|
|
1834
1864
|
S: this,
|
|
1835
1865
|
C: (f, a) => f(...a)
|
|
1836
1866
|
});
|
|
@@ -1845,7 +1875,7 @@ var InvitationsHandler = class {
|
|
|
1845
1875
|
currentState
|
|
1846
1876
|
}, {
|
|
1847
1877
|
F: __dxlog_file7,
|
|
1848
|
-
L:
|
|
1878
|
+
L: 251,
|
|
1849
1879
|
S: this,
|
|
1850
1880
|
C: (f, a) => f(...a)
|
|
1851
1881
|
});
|
|
@@ -1860,7 +1890,7 @@ var InvitationsHandler = class {
|
|
|
1860
1890
|
id: traceId
|
|
1861
1891
|
}), {
|
|
1862
1892
|
F: __dxlog_file7,
|
|
1863
|
-
L:
|
|
1893
|
+
L: 260,
|
|
1864
1894
|
S: this,
|
|
1865
1895
|
C: (f, a) => f(...a)
|
|
1866
1896
|
});
|
|
@@ -1872,7 +1902,7 @@ var InvitationsHandler = class {
|
|
|
1872
1902
|
...protocol.toJSON()
|
|
1873
1903
|
}, {
|
|
1874
1904
|
F: __dxlog_file7,
|
|
1875
|
-
L:
|
|
1905
|
+
L: 268,
|
|
1876
1906
|
S: this,
|
|
1877
1907
|
C: (f, a) => f(...a)
|
|
1878
1908
|
});
|
|
@@ -1883,7 +1913,7 @@ var InvitationsHandler = class {
|
|
|
1883
1913
|
...protocol.toJSON()
|
|
1884
1914
|
}, {
|
|
1885
1915
|
F: __dxlog_file7,
|
|
1886
|
-
L:
|
|
1916
|
+
L: 272,
|
|
1887
1917
|
S: this,
|
|
1888
1918
|
C: (f, a) => f(...a)
|
|
1889
1919
|
});
|
|
@@ -1893,7 +1923,7 @@ var InvitationsHandler = class {
|
|
|
1893
1923
|
response: introductionResponse
|
|
1894
1924
|
}, {
|
|
1895
1925
|
F: __dxlog_file7,
|
|
1896
|
-
L:
|
|
1926
|
+
L: 276,
|
|
1897
1927
|
S: this,
|
|
1898
1928
|
C: (f, a) => f(...a)
|
|
1899
1929
|
});
|
|
@@ -1905,7 +1935,7 @@ var InvitationsHandler = class {
|
|
|
1905
1935
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1906
1936
|
(0, import_log5.log)("guest waiting for authentication code...", void 0, {
|
|
1907
1937
|
F: __dxlog_file7,
|
|
1908
|
-
L:
|
|
1938
|
+
L: 285,
|
|
1909
1939
|
S: this,
|
|
1910
1940
|
C: (f, a) => f(...a)
|
|
1911
1941
|
});
|
|
@@ -1917,7 +1947,7 @@ var InvitationsHandler = class {
|
|
|
1917
1947
|
});
|
|
1918
1948
|
(0, import_log5.log)("sending authentication request", void 0, {
|
|
1919
1949
|
F: __dxlog_file7,
|
|
1920
|
-
L:
|
|
1950
|
+
L: 289,
|
|
1921
1951
|
S: this,
|
|
1922
1952
|
C: (f, a) => f(...a)
|
|
1923
1953
|
});
|
|
@@ -1938,7 +1968,7 @@ var InvitationsHandler = class {
|
|
|
1938
1968
|
attempt
|
|
1939
1969
|
}, {
|
|
1940
1970
|
F: __dxlog_file7,
|
|
1941
|
-
L:
|
|
1971
|
+
L: 300,
|
|
1942
1972
|
S: this,
|
|
1943
1973
|
C: (f, a) => f(...a)
|
|
1944
1974
|
});
|
|
@@ -1955,7 +1985,7 @@ var InvitationsHandler = class {
|
|
|
1955
1985
|
...protocol.toJSON()
|
|
1956
1986
|
}, {
|
|
1957
1987
|
F: __dxlog_file7,
|
|
1958
|
-
L:
|
|
1988
|
+
L: 311,
|
|
1959
1989
|
S: this,
|
|
1960
1990
|
C: (f, a) => f(...a)
|
|
1961
1991
|
});
|
|
@@ -1967,7 +1997,7 @@ var InvitationsHandler = class {
|
|
|
1967
1997
|
...protocol.toJSON()
|
|
1968
1998
|
}, {
|
|
1969
1999
|
F: __dxlog_file7,
|
|
1970
|
-
L:
|
|
2000
|
+
L: 322,
|
|
1971
2001
|
S: this,
|
|
1972
2002
|
C: (f, a) => f(...a)
|
|
1973
2003
|
});
|
|
@@ -1979,7 +2009,7 @@ var InvitationsHandler = class {
|
|
|
1979
2009
|
id: traceId
|
|
1980
2010
|
}), {
|
|
1981
2011
|
F: __dxlog_file7,
|
|
1982
|
-
L:
|
|
2012
|
+
L: 324,
|
|
1983
2013
|
S: this,
|
|
1984
2014
|
C: (f, a) => f(...a)
|
|
1985
2015
|
});
|
|
@@ -1989,7 +2019,7 @@ var InvitationsHandler = class {
|
|
|
1989
2019
|
...protocol.toJSON()
|
|
1990
2020
|
}, {
|
|
1991
2021
|
F: __dxlog_file7,
|
|
1992
|
-
L:
|
|
2022
|
+
L: 327,
|
|
1993
2023
|
S: this,
|
|
1994
2024
|
C: (f, a) => f(...a)
|
|
1995
2025
|
});
|
|
@@ -1999,7 +2029,7 @@ var InvitationsHandler = class {
|
|
|
1999
2029
|
} else {
|
|
2000
2030
|
(0, import_log5.log)("auth failed", err, {
|
|
2001
2031
|
F: __dxlog_file7,
|
|
2002
|
-
L:
|
|
2032
|
+
L: 330,
|
|
2003
2033
|
S: this,
|
|
2004
2034
|
C: (f, a) => f(...a)
|
|
2005
2035
|
});
|
|
@@ -2010,7 +2040,7 @@ var InvitationsHandler = class {
|
|
|
2010
2040
|
error: err
|
|
2011
2041
|
}), {
|
|
2012
2042
|
F: __dxlog_file7,
|
|
2013
|
-
L:
|
|
2043
|
+
L: 333,
|
|
2014
2044
|
S: this,
|
|
2015
2045
|
C: (f, a) => f(...a)
|
|
2016
2046
|
});
|
|
@@ -2028,7 +2058,7 @@ var InvitationsHandler = class {
|
|
|
2028
2058
|
...protocol.toJSON()
|
|
2029
2059
|
}, {
|
|
2030
2060
|
F: __dxlog_file7,
|
|
2031
|
-
L:
|
|
2061
|
+
L: 344,
|
|
2032
2062
|
S: this,
|
|
2033
2063
|
C: (f, a) => f(...a)
|
|
2034
2064
|
});
|
|
@@ -2038,7 +2068,7 @@ var InvitationsHandler = class {
|
|
|
2038
2068
|
} else {
|
|
2039
2069
|
(0, import_log5.log)("auth failed", err, {
|
|
2040
2070
|
F: __dxlog_file7,
|
|
2041
|
-
L:
|
|
2071
|
+
L: 347,
|
|
2042
2072
|
S: this,
|
|
2043
2073
|
C: (f, a) => f(...a)
|
|
2044
2074
|
});
|
|
@@ -2051,7 +2081,7 @@ var InvitationsHandler = class {
|
|
|
2051
2081
|
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
2052
2082
|
(0, import_invariant6.invariant)(invitation.swarmKey, void 0, {
|
|
2053
2083
|
F: __dxlog_file7,
|
|
2054
|
-
L:
|
|
2084
|
+
L: 357,
|
|
2055
2085
|
S: this,
|
|
2056
2086
|
A: [
|
|
2057
2087
|
"invitation.swarmKey",
|
|
@@ -2065,7 +2095,8 @@ var InvitationsHandler = class {
|
|
|
2065
2095
|
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
2066
2096
|
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
2067
2097
|
}),
|
|
2068
|
-
topology: new import_network_manager.StarTopology(topic)
|
|
2098
|
+
topology: new import_network_manager.StarTopology(topic),
|
|
2099
|
+
label: "invitation guest"
|
|
2069
2100
|
});
|
|
2070
2101
|
ctx.onDispose(() => swarmConnection.close());
|
|
2071
2102
|
setState({
|
|
@@ -2301,7 +2332,6 @@ var SpaceInvitationProtocol = class {
|
|
|
2301
2332
|
};
|
|
2302
2333
|
}
|
|
2303
2334
|
async admit(request, guestProfile) {
|
|
2304
|
-
var _a;
|
|
2305
2335
|
(0, import_invariant8.invariant)(this._spaceKey, void 0, {
|
|
2306
2336
|
F: __dxlog_file9,
|
|
2307
2337
|
L: 42,
|
|
@@ -2365,7 +2395,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2365
2395
|
space: {
|
|
2366
2396
|
credential: spaceMemberCredential,
|
|
2367
2397
|
controlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2368
|
-
dataTimeframe:
|
|
2398
|
+
dataTimeframe: space.dataPipeline.pipelineState?.timeframe
|
|
2369
2399
|
}
|
|
2370
2400
|
};
|
|
2371
2401
|
}
|
|
@@ -2469,9 +2499,8 @@ var ClientRpcServer = class {
|
|
|
2469
2499
|
await this._rpcPeer.close();
|
|
2470
2500
|
}
|
|
2471
2501
|
_getServiceHandler(serviceName) {
|
|
2472
|
-
var _a;
|
|
2473
2502
|
if (!this._handlerCache.has(serviceName)) {
|
|
2474
|
-
const [key, descriptor] =
|
|
2503
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug3.raise)(new Error(`Service not available: ${serviceName}`));
|
|
2475
2504
|
const service = this._serviceRegistry.services[key];
|
|
2476
2505
|
if (!service) {
|
|
2477
2506
|
throw new Error(`Service not available: ${serviceName}`);
|
|
@@ -2486,13 +2515,14 @@ var ClientRpcServer = class {
|
|
|
2486
2515
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2487
2516
|
var import_credentials9 = require("@dxos/credentials");
|
|
2488
2517
|
var import_document_model = require("@dxos/document-model");
|
|
2518
|
+
var import_echo_db = require("@dxos/echo-db");
|
|
2489
2519
|
var import_invariant9 = require("@dxos/invariant");
|
|
2490
2520
|
var import_log8 = require("@dxos/log");
|
|
2491
2521
|
var import_protocols5 = require("@dxos/protocols");
|
|
2492
2522
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2493
2523
|
|
|
2494
2524
|
// packages/sdk/client-services/src/version.ts
|
|
2495
|
-
var DXOS_VERSION = "0.1.56-main.
|
|
2525
|
+
var DXOS_VERSION = "0.1.56-main.da2eab1";
|
|
2496
2526
|
|
|
2497
2527
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
2498
2528
|
var getPlatform = () => {
|
|
@@ -2526,9 +2556,8 @@ var getPlatform = () => {
|
|
|
2526
2556
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2527
2557
|
var DEFAULT_TIMEOUT = 1e3;
|
|
2528
2558
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2529
|
-
var _a, _b, _c;
|
|
2530
2559
|
const diagnostics = {
|
|
2531
|
-
created: new Date().toISOString(),
|
|
2560
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2532
2561
|
platform: getPlatform(),
|
|
2533
2562
|
client: {
|
|
2534
2563
|
version: DXOS_VERSION,
|
|
@@ -2540,7 +2569,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2540
2569
|
{
|
|
2541
2570
|
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2542
2571
|
F: __dxlog_file10,
|
|
2543
|
-
L:
|
|
2572
|
+
L: 88,
|
|
2544
2573
|
S: void 0,
|
|
2545
2574
|
A: [
|
|
2546
2575
|
"clientServices.LoggingService",
|
|
@@ -2558,16 +2587,16 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2558
2587
|
spaceKey: identity.space.key,
|
|
2559
2588
|
profile: identity.profileDocument
|
|
2560
2589
|
};
|
|
2561
|
-
const { devices } =
|
|
2590
|
+
const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
2562
2591
|
timeout: DEFAULT_TIMEOUT
|
|
2563
|
-
}).catch(() => void 0)
|
|
2592
|
+
}).catch(() => void 0) ?? {};
|
|
2564
2593
|
diagnostics.devices = devices;
|
|
2565
2594
|
if (serviceContext.dataSpaceManager) {
|
|
2566
|
-
diagnostics.spaces = await Promise.all(
|
|
2595
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2567
2596
|
}
|
|
2568
|
-
const { feeds = [] } =
|
|
2597
|
+
const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2569
2598
|
timeout: DEFAULT_TIMEOUT
|
|
2570
|
-
}).catch(() => void 0)
|
|
2599
|
+
}).catch(() => void 0) ?? {};
|
|
2571
2600
|
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2572
2601
|
feedKey,
|
|
2573
2602
|
bytes,
|
|
@@ -2580,16 +2609,13 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2580
2609
|
var getProperties = (space) => {
|
|
2581
2610
|
let properties = {};
|
|
2582
2611
|
try {
|
|
2583
|
-
const propertiesItem = space.dataPipeline.itemManager.items.find((item) =>
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
});
|
|
2587
|
-
const state = propertiesItem == null ? void 0 : propertiesItem.state;
|
|
2588
|
-
properties = state == null ? void 0 : state.data;
|
|
2612
|
+
const propertiesItem = space.dataPipeline.itemManager.items.find((item) => item.modelMeta?.type === import_document_model.DocumentModel.meta.type && item.state?.type === import_echo_db.TYPE_PROPERTIES);
|
|
2613
|
+
const state = propertiesItem?.state;
|
|
2614
|
+
properties = state?.data;
|
|
2589
2615
|
} catch (err) {
|
|
2590
2616
|
import_log8.log.warn(err.message, void 0, {
|
|
2591
2617
|
F: __dxlog_file10,
|
|
2592
|
-
L:
|
|
2618
|
+
L: 145,
|
|
2593
2619
|
S: void 0,
|
|
2594
2620
|
C: (f, a) => f(...a)
|
|
2595
2621
|
});
|
|
@@ -2597,7 +2623,6 @@ var getProperties = (space) => {
|
|
|
2597
2623
|
return properties;
|
|
2598
2624
|
};
|
|
2599
2625
|
var getSpaceStats = async (space) => {
|
|
2600
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2601
2626
|
const stats = {
|
|
2602
2627
|
key: space.key,
|
|
2603
2628
|
metrics: space.metrics,
|
|
@@ -2605,18 +2630,15 @@ var getSpaceStats = async (space) => {
|
|
|
2605
2630
|
...credential.subject.assertion,
|
|
2606
2631
|
id: credential.id
|
|
2607
2632
|
})),
|
|
2608
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services6.SpaceMember.PresenceState.ONLINE : import_services6.SpaceMember.PresenceState.OFFLINE
|
|
2618
|
-
};
|
|
2619
|
-
}),
|
|
2633
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2634
|
+
identity: {
|
|
2635
|
+
identityKey: member.key,
|
|
2636
|
+
profile: {
|
|
2637
|
+
displayName: member.assertion.profile?.displayName
|
|
2638
|
+
}
|
|
2639
|
+
},
|
|
2640
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services6.SpaceMember.PresenceState.ONLINE : import_services6.SpaceMember.PresenceState.OFFLINE
|
|
2641
|
+
})),
|
|
2620
2642
|
pipeline: {
|
|
2621
2643
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
2622
2644
|
// currentEpoch: space.dataPipeline.currentEpoch,
|
|
@@ -2626,11 +2648,11 @@ var getSpaceStats = async (space) => {
|
|
|
2626
2648
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2627
2649
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
2628
2650
|
// TODO(burdon): Empty?
|
|
2629
|
-
dataFeeds:
|
|
2630
|
-
startDataTimeframe:
|
|
2631
|
-
currentDataTimeframe:
|
|
2632
|
-
targetDataTimeframe:
|
|
2633
|
-
totalDataTimeframe:
|
|
2651
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
2652
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
2653
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
2654
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
2655
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
2634
2656
|
}
|
|
2635
2657
|
};
|
|
2636
2658
|
if (space.dataPipeline.itemManager) {
|
|
@@ -2663,6 +2685,7 @@ var import_protocols9 = require("@dxos/protocols");
|
|
|
2663
2685
|
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2664
2686
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
2665
2687
|
var import_tracing3 = require("@dxos/tracing");
|
|
2688
|
+
var import_util7 = require("@dxos/util");
|
|
2666
2689
|
|
|
2667
2690
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2668
2691
|
var import_async12 = require("@dxos/async");
|
|
@@ -2687,7 +2710,7 @@ var import_keys8 = require("@dxos/keys");
|
|
|
2687
2710
|
var import_log10 = require("@dxos/log");
|
|
2688
2711
|
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2689
2712
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2690
|
-
var
|
|
2713
|
+
var import_timeframe2 = require("@dxos/timeframe");
|
|
2691
2714
|
var import_util4 = require("@dxos/util");
|
|
2692
2715
|
|
|
2693
2716
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
@@ -2756,7 +2779,7 @@ var NotarizationPlugin = class {
|
|
|
2756
2779
|
errors.throw(err);
|
|
2757
2780
|
}
|
|
2758
2781
|
});
|
|
2759
|
-
opCtx
|
|
2782
|
+
opCtx?.onDispose(() => ctx.dispose());
|
|
2760
2783
|
if (timeout !== 0) {
|
|
2761
2784
|
(0, import_async10.scheduleTask)(ctx, () => {
|
|
2762
2785
|
import_log9.log.warn("Notarization timeout", {
|
|
@@ -2849,11 +2872,10 @@ var NotarizationPlugin = class {
|
|
|
2849
2872
|
* Called with credentials arriving from the control pipeline.
|
|
2850
2873
|
*/
|
|
2851
2874
|
async processCredential(credential) {
|
|
2852
|
-
var _a;
|
|
2853
2875
|
if (!credential.id) {
|
|
2854
2876
|
return;
|
|
2855
2877
|
}
|
|
2856
|
-
|
|
2878
|
+
this._processCredentialsTriggers.get(credential.id)?.wake();
|
|
2857
2879
|
this._processedCredentials.add(credential.id);
|
|
2858
2880
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2859
2881
|
}
|
|
@@ -2879,11 +2901,10 @@ var NotarizationPlugin = class {
|
|
|
2879
2901
|
* Requests from other peers to notarize credentials.
|
|
2880
2902
|
*/
|
|
2881
2903
|
async _onNotarize(request) {
|
|
2882
|
-
var _a;
|
|
2883
2904
|
if (!this._writer) {
|
|
2884
2905
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2885
2906
|
}
|
|
2886
|
-
for (const credential of
|
|
2907
|
+
for (const credential of request.credentials ?? []) {
|
|
2887
2908
|
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
2888
2909
|
F: __dxlog_file11,
|
|
2889
2910
|
L: 200,
|
|
@@ -2972,6 +2993,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
2972
2993
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2973
2994
|
}
|
|
2974
2995
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2996
|
+
var ENABLE_FEED_PURGE = false;
|
|
2975
2997
|
var DataSpace = class DataSpace2 {
|
|
2976
2998
|
constructor(params) {
|
|
2977
2999
|
this._ctx = new import_context7.Context();
|
|
@@ -2983,7 +3005,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2983
3005
|
this.error = void 0;
|
|
2984
3006
|
this.stateUpdate = new import_async11.Event();
|
|
2985
3007
|
this.metrics = {};
|
|
2986
|
-
var _a;
|
|
2987
3008
|
this._inner = params.inner;
|
|
2988
3009
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
2989
3010
|
this._gossip = params.gossip;
|
|
@@ -2992,7 +3013,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2992
3013
|
this._feedStore = params.feedStore;
|
|
2993
3014
|
this._metadataStore = params.metadataStore;
|
|
2994
3015
|
this._signingContext = params.signingContext;
|
|
2995
|
-
this._callbacks =
|
|
3016
|
+
this._callbacks = params.callbacks ?? {};
|
|
2996
3017
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2997
3018
|
trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2998
3019
|
update: this._inner.stateUpdate,
|
|
@@ -3036,14 +3057,13 @@ var DataSpace = class DataSpace2 {
|
|
|
3036
3057
|
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
3037
3058
|
this.stateUpdate.emit();
|
|
3038
3059
|
this.metrics = {};
|
|
3039
|
-
this.metrics.open = new Date();
|
|
3060
|
+
this.metrics.open = /* @__PURE__ */ new Date();
|
|
3040
3061
|
}
|
|
3041
3062
|
async close() {
|
|
3042
3063
|
await this._close();
|
|
3043
3064
|
}
|
|
3044
3065
|
async _close() {
|
|
3045
|
-
|
|
3046
|
-
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
3066
|
+
await this._callbacks.beforeClose?.();
|
|
3047
3067
|
this._state = import_services7.SpaceState.CLOSED;
|
|
3048
3068
|
await this._ctx.dispose();
|
|
3049
3069
|
this._ctx = new import_context7.Context();
|
|
@@ -3065,13 +3085,13 @@ var DataSpace = class DataSpace2 {
|
|
|
3065
3085
|
initializeDataPipelineAsync() {
|
|
3066
3086
|
(0, import_async11.scheduleTask)(this._ctx, async () => {
|
|
3067
3087
|
try {
|
|
3068
|
-
this.metrics.pipelineInitBegin = new Date();
|
|
3088
|
+
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3069
3089
|
await this.initializeDataPipeline();
|
|
3070
3090
|
} catch (err) {
|
|
3071
3091
|
if (err instanceof import_errors3.CancelledError) {
|
|
3072
3092
|
(0, import_log10.log)("data pipeline initialization cancelled", err, {
|
|
3073
3093
|
F: __dxlog_file12,
|
|
3074
|
-
L:
|
|
3094
|
+
L: 199,
|
|
3075
3095
|
S: this,
|
|
3076
3096
|
C: (f, a) => f(...a)
|
|
3077
3097
|
});
|
|
@@ -3079,7 +3099,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3079
3099
|
}
|
|
3080
3100
|
import_log10.log.error("Error initializing data pipeline", err, {
|
|
3081
3101
|
F: __dxlog_file12,
|
|
3082
|
-
L:
|
|
3102
|
+
L: 203,
|
|
3083
3103
|
S: this,
|
|
3084
3104
|
C: (f, a) => f(...a)
|
|
3085
3105
|
});
|
|
@@ -3087,12 +3107,11 @@ var DataSpace = class DataSpace2 {
|
|
|
3087
3107
|
this.error = err;
|
|
3088
3108
|
this.stateUpdate.emit();
|
|
3089
3109
|
} finally {
|
|
3090
|
-
this.metrics.ready = new Date();
|
|
3110
|
+
this.metrics.ready = /* @__PURE__ */ new Date();
|
|
3091
3111
|
}
|
|
3092
3112
|
});
|
|
3093
3113
|
}
|
|
3094
3114
|
async initializeDataPipeline() {
|
|
3095
|
-
var _a, _b, _c, _d;
|
|
3096
3115
|
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
3097
3116
|
throw new import_errors3.SystemError("Invalid operation");
|
|
3098
3117
|
}
|
|
@@ -3101,11 +3120,11 @@ var DataSpace = class DataSpace2 {
|
|
|
3101
3120
|
ctx: this._ctx,
|
|
3102
3121
|
breakOnStall: false
|
|
3103
3122
|
});
|
|
3104
|
-
this.metrics.controlPipelineReady = new Date();
|
|
3123
|
+
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3105
3124
|
await this._createWritableFeeds();
|
|
3106
3125
|
(0, import_log10.log)("writable feeds created", void 0, {
|
|
3107
3126
|
F: __dxlog_file12,
|
|
3108
|
-
L:
|
|
3127
|
+
L: 227,
|
|
3109
3128
|
S: this,
|
|
3110
3129
|
C: (f, a) => f(...a)
|
|
3111
3130
|
});
|
|
@@ -3118,11 +3137,11 @@ var DataSpace = class DataSpace2 {
|
|
|
3118
3137
|
}), this._inner.controlPipeline.writer));
|
|
3119
3138
|
}
|
|
3120
3139
|
await this._inner.initializeDataPipeline();
|
|
3121
|
-
this.metrics.dataPipelineOpen = new Date();
|
|
3140
|
+
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
3122
3141
|
await (0, import_context7.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3123
3142
|
(0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3124
3143
|
F: __dxlog_file12,
|
|
3125
|
-
L:
|
|
3144
|
+
L: 248,
|
|
3126
3145
|
S: this,
|
|
3127
3146
|
C: (f, a) => f(...a)
|
|
3128
3147
|
});
|
|
@@ -3130,17 +3149,17 @@ var DataSpace = class DataSpace2 {
|
|
|
3130
3149
|
ctx: this._ctx,
|
|
3131
3150
|
breakOnStall: false
|
|
3132
3151
|
});
|
|
3133
|
-
this.metrics.dataPipelineReady = new Date();
|
|
3152
|
+
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3134
3153
|
(0, import_log10.log)("data pipeline ready", void 0, {
|
|
3135
3154
|
F: __dxlog_file12,
|
|
3136
|
-
L:
|
|
3155
|
+
L: 257,
|
|
3137
3156
|
S: this,
|
|
3138
3157
|
C: (f, a) => f(...a)
|
|
3139
3158
|
});
|
|
3140
|
-
await
|
|
3159
|
+
await this._callbacks.beforeReady?.();
|
|
3141
3160
|
this._state = import_services7.SpaceState.READY;
|
|
3142
3161
|
this.stateUpdate.emit();
|
|
3143
|
-
await
|
|
3162
|
+
await this._callbacks.afterReady?.();
|
|
3144
3163
|
}
|
|
3145
3164
|
async _createWritableFeeds() {
|
|
3146
3165
|
const credentials = [];
|
|
@@ -3187,7 +3206,6 @@ var DataSpace = class DataSpace2 {
|
|
|
3187
3206
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
3188
3207
|
}
|
|
3189
3208
|
async createEpoch() {
|
|
3190
|
-
var _a, _b;
|
|
3191
3209
|
const epoch = await this.dataPipeline.createEpoch();
|
|
3192
3210
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
3193
3211
|
credential: {
|
|
@@ -3200,16 +3218,19 @@ var DataSpace = class DataSpace2 {
|
|
|
3200
3218
|
})
|
|
3201
3219
|
}
|
|
3202
3220
|
});
|
|
3203
|
-
await this.inner.controlPipeline.state.waitUntilTimeframe(new
|
|
3221
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
|
|
3204
3222
|
[
|
|
3205
3223
|
receipt.feedKey,
|
|
3206
3224
|
receipt.seq
|
|
3207
3225
|
]
|
|
3208
3226
|
]));
|
|
3209
|
-
|
|
3210
|
-
const
|
|
3211
|
-
|
|
3212
|
-
|
|
3227
|
+
if (ENABLE_FEED_PURGE) {
|
|
3228
|
+
for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
|
|
3229
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
3230
|
+
if (indexBeforeEpoch === void 0) {
|
|
3231
|
+
continue;
|
|
3232
|
+
}
|
|
3233
|
+
await feed.safeClear(0, indexBeforeEpoch + 1);
|
|
3213
3234
|
}
|
|
3214
3235
|
}
|
|
3215
3236
|
}
|
|
@@ -3254,9 +3275,8 @@ DataSpace = _ts_decorate3([
|
|
|
3254
3275
|
var import_credentials11 = require("@dxos/credentials");
|
|
3255
3276
|
var import_debug5 = require("@dxos/debug");
|
|
3256
3277
|
var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
3257
|
-
var
|
|
3278
|
+
var import_timeframe3 = require("@dxos/timeframe");
|
|
3258
3279
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
3259
|
-
var _a, _b, _c, _d;
|
|
3260
3280
|
const credentials = [
|
|
3261
3281
|
await (0, import_credentials11.createCredential)({
|
|
3262
3282
|
signer: keyring,
|
|
@@ -3276,11 +3296,11 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3276
3296
|
spaceKey: space.key,
|
|
3277
3297
|
role: import_credentials12.SpaceMember.Role.ADMIN,
|
|
3278
3298
|
profile: signingContext.profile,
|
|
3279
|
-
genesisFeedKey:
|
|
3299
|
+
genesisFeedKey: space.controlFeedKey ?? (0, import_debug5.failUndefined)()
|
|
3280
3300
|
}
|
|
3281
3301
|
}),
|
|
3282
3302
|
await signingContext.credentialSigner.createCredential({
|
|
3283
|
-
subject:
|
|
3303
|
+
subject: space.controlFeedKey ?? (0, import_debug5.failUndefined)(),
|
|
3284
3304
|
assertion: {
|
|
3285
3305
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
3286
3306
|
spaceKey: space.key,
|
|
@@ -3290,7 +3310,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3290
3310
|
}
|
|
3291
3311
|
}),
|
|
3292
3312
|
await signingContext.credentialSigner.createCredential({
|
|
3293
|
-
subject:
|
|
3313
|
+
subject: space.dataFeedKey ?? (0, import_debug5.failUndefined)(),
|
|
3294
3314
|
assertion: {
|
|
3295
3315
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
3296
3316
|
spaceKey: space.key,
|
|
@@ -3300,12 +3320,12 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3300
3320
|
}
|
|
3301
3321
|
}),
|
|
3302
3322
|
await signingContext.credentialSigner.createCredential({
|
|
3303
|
-
subject:
|
|
3323
|
+
subject: space.key ?? (0, import_debug5.failUndefined)(),
|
|
3304
3324
|
assertion: {
|
|
3305
3325
|
"@type": "dxos.halo.credentials.Epoch",
|
|
3306
3326
|
number: 0,
|
|
3307
3327
|
previousId: void 0,
|
|
3308
|
-
timeframe: new
|
|
3328
|
+
timeframe: new import_timeframe3.Timeframe(),
|
|
3309
3329
|
snapshotCid: void 0
|
|
3310
3330
|
}
|
|
3311
3331
|
})
|
|
@@ -3565,7 +3585,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3565
3585
|
onAuthFailure: () => {
|
|
3566
3586
|
import_log11.log.warn("auth failure", void 0, {
|
|
3567
3587
|
F: __dxlog_file13,
|
|
3568
|
-
L:
|
|
3588
|
+
L: 217,
|
|
3569
3589
|
S: this,
|
|
3570
3590
|
C: (f, a) => f(...a)
|
|
3571
3591
|
});
|
|
@@ -3589,7 +3609,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3589
3609
|
space: space.key
|
|
3590
3610
|
}, {
|
|
3591
3611
|
F: __dxlog_file13,
|
|
3592
|
-
L:
|
|
3612
|
+
L: 235,
|
|
3593
3613
|
S: this,
|
|
3594
3614
|
C: (f, a) => f(...a)
|
|
3595
3615
|
});
|
|
@@ -3601,7 +3621,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3601
3621
|
open: this._isOpen
|
|
3602
3622
|
}, {
|
|
3603
3623
|
F: __dxlog_file13,
|
|
3604
|
-
L:
|
|
3624
|
+
L: 242,
|
|
3605
3625
|
S: this,
|
|
3606
3626
|
C: (f, a) => f(...a)
|
|
3607
3627
|
});
|
|
@@ -3614,7 +3634,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3614
3634
|
space: space.key
|
|
3615
3635
|
}, {
|
|
3616
3636
|
F: __dxlog_file13,
|
|
3617
|
-
L:
|
|
3637
|
+
L: 248,
|
|
3618
3638
|
S: this,
|
|
3619
3639
|
C: (f, a) => f(...a)
|
|
3620
3640
|
});
|
|
@@ -3679,9 +3699,8 @@ var SpacesServiceImpl = class {
|
|
|
3679
3699
|
return this._serializeSpace(space);
|
|
3680
3700
|
}
|
|
3681
3701
|
async updateSpace({ spaceKey, state }) {
|
|
3682
|
-
var _a;
|
|
3683
3702
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3684
|
-
const space =
|
|
3703
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3685
3704
|
if (state) {
|
|
3686
3705
|
switch (state) {
|
|
3687
3706
|
case import_services9.SpaceState.ACTIVE:
|
|
@@ -3745,17 +3764,15 @@ var SpacesServiceImpl = class {
|
|
|
3745
3764
|
});
|
|
3746
3765
|
}
|
|
3747
3766
|
async postMessage({ spaceKey, channel, message }) {
|
|
3748
|
-
var _a;
|
|
3749
3767
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3750
|
-
const space =
|
|
3768
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3751
3769
|
await space.postMessage(getChannelId(channel), message);
|
|
3752
3770
|
}
|
|
3753
3771
|
subscribeMessages({ spaceKey, channel }) {
|
|
3754
3772
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3755
3773
|
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3756
|
-
var _a;
|
|
3757
3774
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3758
|
-
const space =
|
|
3775
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3759
3776
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3760
3777
|
next(message);
|
|
3761
3778
|
});
|
|
@@ -3765,8 +3782,7 @@ var SpacesServiceImpl = class {
|
|
|
3765
3782
|
}
|
|
3766
3783
|
queryCredentials({ spaceKey }) {
|
|
3767
3784
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3768
|
-
|
|
3769
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3785
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3770
3786
|
const processor = {
|
|
3771
3787
|
processCredential: async (credential) => {
|
|
3772
3788
|
next(credential);
|
|
@@ -3777,9 +3793,8 @@ var SpacesServiceImpl = class {
|
|
|
3777
3793
|
});
|
|
3778
3794
|
}
|
|
3779
3795
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
for (const credential of credentials != null ? credentials : []) {
|
|
3796
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3797
|
+
for (const credential of credentials ?? []) {
|
|
3783
3798
|
await space.controlPipeline.writer.write({
|
|
3784
3799
|
credential: {
|
|
3785
3800
|
credential
|
|
@@ -3788,13 +3803,11 @@ var SpacesServiceImpl = class {
|
|
|
3788
3803
|
}
|
|
3789
3804
|
}
|
|
3790
3805
|
async createEpoch({ spaceKey }) {
|
|
3791
|
-
var _a;
|
|
3792
3806
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3793
|
-
const space =
|
|
3807
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3794
3808
|
await space.createEpoch();
|
|
3795
3809
|
}
|
|
3796
3810
|
_serializeSpace(space) {
|
|
3797
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3798
3811
|
return {
|
|
3799
3812
|
spaceKey: space.key,
|
|
3800
3813
|
state: space.state,
|
|
@@ -3806,16 +3819,15 @@ var SpacesServiceImpl = class {
|
|
|
3806
3819
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
3807
3820
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
3808
3821
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
3809
|
-
dataFeeds:
|
|
3810
|
-
startDataTimeframe:
|
|
3811
|
-
currentDataTimeframe:
|
|
3812
|
-
targetDataTimeframe:
|
|
3813
|
-
totalDataTimeframe:
|
|
3822
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
3823
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
3824
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
3825
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
3826
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
3814
3827
|
},
|
|
3815
3828
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3816
|
-
var _a2, _b2, _c2;
|
|
3817
3829
|
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
3818
|
-
const isMe =
|
|
3830
|
+
const isMe = this._identityManager.identity?.identityKey.equals(member.key);
|
|
3819
3831
|
if (isMe) {
|
|
3820
3832
|
peers.push(space.presence.getLocalState());
|
|
3821
3833
|
}
|
|
@@ -3823,14 +3835,14 @@ var SpacesServiceImpl = class {
|
|
|
3823
3835
|
identity: {
|
|
3824
3836
|
identityKey: member.key,
|
|
3825
3837
|
profile: {
|
|
3826
|
-
displayName:
|
|
3838
|
+
displayName: member.assertion.profile?.displayName ?? (0, import_util6.humanize)(member.key)
|
|
3827
3839
|
}
|
|
3828
3840
|
},
|
|
3829
3841
|
presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
3830
3842
|
peerStates: peers
|
|
3831
3843
|
};
|
|
3832
3844
|
}),
|
|
3833
|
-
creator:
|
|
3845
|
+
creator: space.inner.spaceState.creator?.key,
|
|
3834
3846
|
cache: space.cache,
|
|
3835
3847
|
metrics: space.metrics
|
|
3836
3848
|
};
|
|
@@ -3870,7 +3882,8 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3870
3882
|
root: storage.createDirectory("feeds"),
|
|
3871
3883
|
signer: this.keyring,
|
|
3872
3884
|
hypercore: {
|
|
3873
|
-
valueEncoding: import_echo_pipeline3.valueEncoding
|
|
3885
|
+
valueEncoding: import_echo_pipeline3.valueEncoding,
|
|
3886
|
+
stats: true
|
|
3874
3887
|
}
|
|
3875
3888
|
})
|
|
3876
3889
|
});
|
|
@@ -3884,16 +3897,13 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3884
3897
|
});
|
|
3885
3898
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3886
3899
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3887
|
-
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () =>
|
|
3888
|
-
var _a;
|
|
3889
|
-
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
3890
|
-
}, this._acceptIdentity.bind(this)));
|
|
3900
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
3891
3901
|
}
|
|
3892
3902
|
async open(ctx) {
|
|
3893
3903
|
await this._checkStorageVersion();
|
|
3894
3904
|
(0, import_log13.log)("opening...", void 0, {
|
|
3895
3905
|
F: __dxlog_file15,
|
|
3896
|
-
L:
|
|
3906
|
+
L: 135,
|
|
3897
3907
|
S: this,
|
|
3898
3908
|
C: (f, a) => f(...a)
|
|
3899
3909
|
});
|
|
@@ -3901,7 +3911,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3901
3911
|
id: this._instanceId
|
|
3902
3912
|
}), {
|
|
3903
3913
|
F: __dxlog_file15,
|
|
3904
|
-
L:
|
|
3914
|
+
L: 136,
|
|
3905
3915
|
S: this,
|
|
3906
3916
|
C: (f, a) => f(...a)
|
|
3907
3917
|
});
|
|
@@ -3916,29 +3926,28 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3916
3926
|
id: this._instanceId
|
|
3917
3927
|
}), {
|
|
3918
3928
|
F: __dxlog_file15,
|
|
3919
|
-
L:
|
|
3929
|
+
L: 144,
|
|
3920
3930
|
S: this,
|
|
3921
3931
|
C: (f, a) => f(...a)
|
|
3922
3932
|
});
|
|
3923
3933
|
(0, import_log13.log)("opened", void 0, {
|
|
3924
3934
|
F: __dxlog_file15,
|
|
3925
|
-
L:
|
|
3935
|
+
L: 145,
|
|
3926
3936
|
S: this,
|
|
3927
3937
|
C: (f, a) => f(...a)
|
|
3928
3938
|
});
|
|
3929
3939
|
}
|
|
3930
3940
|
async close() {
|
|
3931
|
-
var _a;
|
|
3932
3941
|
(0, import_log13.log)("closing...", void 0, {
|
|
3933
3942
|
F: __dxlog_file15,
|
|
3934
|
-
L:
|
|
3943
|
+
L: 149,
|
|
3935
3944
|
S: this,
|
|
3936
3945
|
C: (f, a) => f(...a)
|
|
3937
3946
|
});
|
|
3938
3947
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3939
3948
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3940
3949
|
}
|
|
3941
|
-
await
|
|
3950
|
+
await this.dataSpaceManager?.close();
|
|
3942
3951
|
await this.identityManager.close();
|
|
3943
3952
|
await this.spaceManager.close();
|
|
3944
3953
|
await this.feedStore.close();
|
|
@@ -3947,7 +3956,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3947
3956
|
this.dataServiceSubscriptions.clear();
|
|
3948
3957
|
(0, import_log13.log)("closed", void 0, {
|
|
3949
3958
|
F: __dxlog_file15,
|
|
3950
|
-
L:
|
|
3959
|
+
L: 160,
|
|
3951
3960
|
S: this,
|
|
3952
3961
|
C: (f, a) => f(...a)
|
|
3953
3962
|
});
|
|
@@ -3961,7 +3970,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3961
3970
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3962
3971
|
(0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3963
3972
|
F: __dxlog_file15,
|
|
3964
|
-
L:
|
|
3973
|
+
L: 171,
|
|
3965
3974
|
S: this,
|
|
3966
3975
|
A: [
|
|
3967
3976
|
"factory",
|
|
@@ -3983,14 +3992,13 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3983
3992
|
}
|
|
3984
3993
|
// Called when identity is created.
|
|
3985
3994
|
async _initialize(ctx) {
|
|
3986
|
-
var _a;
|
|
3987
3995
|
(0, import_log13.log)("initializing spaces...", void 0, {
|
|
3988
3996
|
F: __dxlog_file15,
|
|
3989
|
-
L:
|
|
3997
|
+
L: 192,
|
|
3990
3998
|
S: this,
|
|
3991
3999
|
C: (f, a) => f(...a)
|
|
3992
4000
|
});
|
|
3993
|
-
const identity =
|
|
4001
|
+
const identity = this.identityManager.identity ?? (0, import_debug7.failUndefined)();
|
|
3994
4002
|
const signingContext = {
|
|
3995
4003
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3996
4004
|
identityKey: identity.identityKey,
|
|
@@ -4009,7 +4017,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4009
4017
|
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
4010
4018
|
(0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4011
4019
|
F: __dxlog_file15,
|
|
4012
|
-
L:
|
|
4020
|
+
L: 215,
|
|
4013
4021
|
S: this,
|
|
4014
4022
|
A: [
|
|
4015
4023
|
"this.dataSpaceManager",
|
|
@@ -4033,7 +4041,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4033
4041
|
details: assertion
|
|
4034
4042
|
}, {
|
|
4035
4043
|
F: __dxlog_file15,
|
|
4036
|
-
L:
|
|
4044
|
+
L: 231,
|
|
4037
4045
|
S: this,
|
|
4038
4046
|
C: (f, a) => f(...a)
|
|
4039
4047
|
});
|
|
@@ -4044,7 +4052,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4044
4052
|
details: assertion
|
|
4045
4053
|
}, {
|
|
4046
4054
|
F: __dxlog_file15,
|
|
4047
|
-
L:
|
|
4055
|
+
L: 235,
|
|
4048
4056
|
S: this,
|
|
4049
4057
|
C: (f, a) => f(...a)
|
|
4050
4058
|
});
|
|
@@ -4055,7 +4063,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4055
4063
|
details: assertion
|
|
4056
4064
|
}, {
|
|
4057
4065
|
F: __dxlog_file15,
|
|
4058
|
-
L:
|
|
4066
|
+
L: 240,
|
|
4059
4067
|
S: this,
|
|
4060
4068
|
C: (f, a) => f(...a)
|
|
4061
4069
|
});
|
|
@@ -4066,7 +4074,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4066
4074
|
} catch (err) {
|
|
4067
4075
|
import_log13.log.catch(err, void 0, {
|
|
4068
4076
|
F: __dxlog_file15,
|
|
4069
|
-
L:
|
|
4077
|
+
L: 246,
|
|
4070
4078
|
S: this,
|
|
4071
4079
|
C: (f, a) => f(...a)
|
|
4072
4080
|
});
|
|
@@ -4083,6 +4091,7 @@ _ts_decorate5([
|
|
|
4083
4091
|
import_tracing3.trace.span()
|
|
4084
4092
|
], ServiceContext.prototype, "_initialize", null);
|
|
4085
4093
|
ServiceContext = _ts_decorate5([
|
|
4094
|
+
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
4086
4095
|
import_tracing3.trace.resource()
|
|
4087
4096
|
], ServiceContext);
|
|
4088
4097
|
|
|
@@ -4117,21 +4126,17 @@ var DevicesServiceImpl = class {
|
|
|
4117
4126
|
queryDevices() {
|
|
4118
4127
|
return new import_codec_protobuf12.Stream(({ next }) => {
|
|
4119
4128
|
const update = () => {
|
|
4120
|
-
|
|
4121
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
4129
|
+
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
4122
4130
|
if (!deviceKeys) {
|
|
4123
4131
|
next({
|
|
4124
4132
|
devices: []
|
|
4125
4133
|
});
|
|
4126
4134
|
} else {
|
|
4127
4135
|
next({
|
|
4128
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
|
|
4133
|
-
};
|
|
4134
|
-
})
|
|
4136
|
+
devices: Array.from(deviceKeys.values()).map((key) => ({
|
|
4137
|
+
deviceKey: key,
|
|
4138
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
|
|
4139
|
+
}))
|
|
4135
4140
|
});
|
|
4136
4141
|
}
|
|
4137
4142
|
};
|
|
@@ -4175,7 +4180,6 @@ var Lock = class {
|
|
|
4175
4180
|
return this._lockPath;
|
|
4176
4181
|
}
|
|
4177
4182
|
async acquire() {
|
|
4178
|
-
var _a;
|
|
4179
4183
|
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
4180
4184
|
F: __dxlog_file16,
|
|
4181
4185
|
L: 32,
|
|
@@ -4183,7 +4187,7 @@ var Lock = class {
|
|
|
4183
4187
|
C: (f, a) => f(...a)
|
|
4184
4188
|
});
|
|
4185
4189
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
4186
|
-
await
|
|
4190
|
+
await this._onAcquire?.();
|
|
4187
4191
|
(0, import_log14.log)("acquired lock", void 0, {
|
|
4188
4192
|
F: __dxlog_file16,
|
|
4189
4193
|
L: 37,
|
|
@@ -4192,8 +4196,7 @@ var Lock = class {
|
|
|
4192
4196
|
});
|
|
4193
4197
|
}
|
|
4194
4198
|
async release() {
|
|
4195
|
-
|
|
4196
|
-
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
4199
|
+
await this._onRelease?.();
|
|
4197
4200
|
(0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4198
4201
|
F: __dxlog_file16,
|
|
4199
4202
|
L: 42,
|
|
@@ -4216,11 +4219,11 @@ var import_async16 = require("@dxos/async");
|
|
|
4216
4219
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
4217
4220
|
var import_log15 = require("@dxos/log");
|
|
4218
4221
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4219
|
-
var
|
|
4222
|
+
var import_util8 = require("@dxos/util");
|
|
4220
4223
|
var LoggingServiceImpl = class {
|
|
4221
4224
|
constructor() {
|
|
4222
4225
|
this._logs = new import_async16.Event();
|
|
4223
|
-
this._started = new Date();
|
|
4226
|
+
this._started = /* @__PURE__ */ new Date();
|
|
4224
4227
|
this._logProcessor = (_config, entry2) => {
|
|
4225
4228
|
this._logs.emit(entry2);
|
|
4226
4229
|
};
|
|
@@ -4234,15 +4237,15 @@ var LoggingServiceImpl = class {
|
|
|
4234
4237
|
}
|
|
4235
4238
|
async controlMetrics({ reset, record }) {
|
|
4236
4239
|
if (reset) {
|
|
4237
|
-
|
|
4240
|
+
import_util8.tracer.clear();
|
|
4238
4241
|
}
|
|
4239
4242
|
if (record === true) {
|
|
4240
|
-
|
|
4243
|
+
import_util8.tracer.start();
|
|
4241
4244
|
} else if (record === false) {
|
|
4242
|
-
|
|
4245
|
+
import_util8.tracer.stop();
|
|
4243
4246
|
}
|
|
4244
4247
|
return {
|
|
4245
|
-
recording:
|
|
4248
|
+
recording: import_util8.tracer.recording
|
|
4246
4249
|
};
|
|
4247
4250
|
}
|
|
4248
4251
|
/**
|
|
@@ -4250,24 +4253,23 @@ var LoggingServiceImpl = class {
|
|
|
4250
4253
|
*/
|
|
4251
4254
|
queryMetrics({ interval = 5e3 }) {
|
|
4252
4255
|
const getNumericalValues = (key) => {
|
|
4253
|
-
|
|
4254
|
-
const events = (_a = import_util7.tracer.get(key)) != null ? _a : [];
|
|
4256
|
+
const events = import_util8.tracer.get(key) ?? [];
|
|
4255
4257
|
return {
|
|
4256
4258
|
key,
|
|
4257
|
-
stats: (0,
|
|
4259
|
+
stats: (0, import_util8.numericalValues)(events, "duration")
|
|
4258
4260
|
};
|
|
4259
4261
|
};
|
|
4260
4262
|
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
4261
4263
|
const update = () => {
|
|
4262
4264
|
const metrics = {
|
|
4263
|
-
timestamp: new Date(),
|
|
4265
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4264
4266
|
values: [
|
|
4265
4267
|
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4266
4268
|
getNumericalValues("dxos.echo.pipeline.data")
|
|
4267
4269
|
].filter(Boolean)
|
|
4268
4270
|
};
|
|
4269
4271
|
next({
|
|
4270
|
-
timestamp: new Date(),
|
|
4272
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4271
4273
|
metrics
|
|
4272
4274
|
});
|
|
4273
4275
|
};
|
|
@@ -4281,11 +4283,10 @@ var LoggingServiceImpl = class {
|
|
|
4281
4283
|
queryLogs(request) {
|
|
4282
4284
|
return new import_codec_protobuf13.Stream(({ ctx, next }) => {
|
|
4283
4285
|
const handler = (entry2) => {
|
|
4284
|
-
var _a, _b, _c, _d, _e;
|
|
4285
4286
|
if (LOG_PROCESSING > 0) {
|
|
4286
4287
|
return;
|
|
4287
4288
|
}
|
|
4288
|
-
if (
|
|
4289
|
+
if (entry2.meta?.F.includes("logging-service") || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
4289
4290
|
return;
|
|
4290
4291
|
}
|
|
4291
4292
|
if (!shouldLog(entry2, request)) {
|
|
@@ -4293,12 +4294,12 @@ var LoggingServiceImpl = class {
|
|
|
4293
4294
|
}
|
|
4294
4295
|
const record = {
|
|
4295
4296
|
...entry2,
|
|
4296
|
-
context: (0,
|
|
4297
|
-
timestamp: new Date(),
|
|
4297
|
+
context: (0, import_util8.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
|
|
4298
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4298
4299
|
meta: {
|
|
4299
4300
|
// TODO(dmaretskyi): Fix proto.
|
|
4300
|
-
file:
|
|
4301
|
-
line:
|
|
4301
|
+
file: entry2.meta?.F ?? "",
|
|
4302
|
+
line: entry2.meta?.L ?? 0
|
|
4302
4303
|
}
|
|
4303
4304
|
};
|
|
4304
4305
|
try {
|
|
@@ -4321,15 +4322,11 @@ var matchFilter = (filter, level, path, options) => {
|
|
|
4321
4322
|
}
|
|
4322
4323
|
};
|
|
4323
4324
|
var shouldLog = (entry2, request) => {
|
|
4324
|
-
|
|
4325
|
-
const options = (_a = request.options) != null ? _a : import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4325
|
+
const options = request.options ?? import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4326
4326
|
if (request.filters === void 0) {
|
|
4327
4327
|
return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4328
4328
|
} else {
|
|
4329
|
-
return request.filters.some((filter) =>
|
|
4330
|
-
var _a2, _b;
|
|
4331
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
4332
|
-
});
|
|
4329
|
+
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
4333
4330
|
}
|
|
4334
4331
|
};
|
|
4335
4332
|
var LOG_PROCESSING = 0;
|
|
@@ -4371,10 +4368,10 @@ var import_client_protocol4 = require("@dxos/client-protocol");
|
|
|
4371
4368
|
var import_errors5 = require("@dxos/errors");
|
|
4372
4369
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
4373
4370
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
4374
|
-
var
|
|
4371
|
+
var import_util9 = require("@dxos/util");
|
|
4375
4372
|
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
4376
4373
|
var createStorageObjects = (config) => {
|
|
4377
|
-
const { path = (0,
|
|
4374
|
+
const { path = (0, import_util9.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config ?? {};
|
|
4378
4375
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
4379
4376
|
throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4380
4377
|
}
|
|
@@ -4418,7 +4415,7 @@ var toStorageType = (type) => {
|
|
|
4418
4415
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
4419
4416
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
4420
4417
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4421
|
-
var
|
|
4418
|
+
var import_util10 = require("@dxos/util");
|
|
4422
4419
|
var SystemServiceImpl = class {
|
|
4423
4420
|
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4424
4421
|
this._config = config;
|
|
@@ -4429,8 +4426,7 @@ var SystemServiceImpl = class {
|
|
|
4429
4426
|
this._onReset = onReset;
|
|
4430
4427
|
}
|
|
4431
4428
|
async getConfig() {
|
|
4432
|
-
|
|
4433
|
-
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
4429
|
+
return this._config?.values ?? {};
|
|
4434
4430
|
}
|
|
4435
4431
|
/**
|
|
4436
4432
|
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
@@ -4438,8 +4434,8 @@ var SystemServiceImpl = class {
|
|
|
4438
4434
|
async getDiagnostics({ keys } = {}) {
|
|
4439
4435
|
const diagnostics = await this._getDiagnostics();
|
|
4440
4436
|
return {
|
|
4441
|
-
timestamp: new Date(),
|
|
4442
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
4437
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4438
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util10.jsonKeyReplacer)({
|
|
4443
4439
|
truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4444
4440
|
humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
4445
4441
|
})))
|
|
@@ -4553,11 +4549,10 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4553
4549
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4554
4550
|
},
|
|
4555
4551
|
onUpdateStatus: async (status) => {
|
|
4556
|
-
var _a, _b;
|
|
4557
4552
|
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
4558
|
-
await
|
|
4553
|
+
await this._resourceLock?.acquire();
|
|
4559
4554
|
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
4560
|
-
await
|
|
4555
|
+
await this._resourceLock?.release();
|
|
4561
4556
|
}
|
|
4562
4557
|
},
|
|
4563
4558
|
onReset: async () => {
|
|
@@ -4594,7 +4589,6 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4594
4589
|
* Can only be called once.
|
|
4595
4590
|
*/
|
|
4596
4591
|
initialize({ config, ...options }) {
|
|
4597
|
-
var _a, _b, _c;
|
|
4598
4592
|
(0, import_invariant14.invariant)(!this._open, "service host is open", {
|
|
4599
4593
|
F: __dxlog_file17,
|
|
4600
4594
|
L: 181,
|
|
@@ -4604,7 +4598,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4604
4598
|
"'service host is open'"
|
|
4605
4599
|
]
|
|
4606
4600
|
});
|
|
4607
|
-
import_log16.log
|
|
4601
|
+
(0, import_log16.log)("initializing...", void 0, {
|
|
4608
4602
|
F: __dxlog_file17,
|
|
4609
4603
|
L: 182,
|
|
4610
4604
|
S: this,
|
|
@@ -4626,8 +4620,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4626
4620
|
}
|
|
4627
4621
|
}
|
|
4628
4622
|
const { connectionLog = true, transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
|
|
4629
|
-
iceServers:
|
|
4630
|
-
}), signalManager = new import_messaging.WebsocketSignalManager(
|
|
4623
|
+
iceServers: this._config?.get("runtime.services.ice")
|
|
4624
|
+
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4631
4625
|
this._signalManager = signalManager;
|
|
4632
4626
|
(0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
|
|
4633
4627
|
F: __dxlog_file17,
|
|
@@ -4643,7 +4637,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4643
4637
|
transportFactory,
|
|
4644
4638
|
signalManager
|
|
4645
4639
|
});
|
|
4646
|
-
import_log16.log
|
|
4640
|
+
(0, import_log16.log)("initialized", void 0, {
|
|
4647
4641
|
F: __dxlog_file17,
|
|
4648
4642
|
L: 208,
|
|
4649
4643
|
S: this,
|
|
@@ -4651,7 +4645,6 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4651
4645
|
});
|
|
4652
4646
|
}
|
|
4653
4647
|
async open(ctx) {
|
|
4654
|
-
var _a, _b, _c;
|
|
4655
4648
|
if (this._open) {
|
|
4656
4649
|
return;
|
|
4657
4650
|
}
|
|
@@ -4701,20 +4694,20 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4701
4694
|
]
|
|
4702
4695
|
});
|
|
4703
4696
|
this._opening = true;
|
|
4704
|
-
import_log16.log
|
|
4705
|
-
lockKey:
|
|
4697
|
+
(0, import_log16.log)("opening...", {
|
|
4698
|
+
lockKey: this._resourceLock?.lockKey
|
|
4706
4699
|
}, {
|
|
4707
4700
|
F: __dxlog_file17,
|
|
4708
4701
|
L: 227,
|
|
4709
4702
|
S: this,
|
|
4710
4703
|
C: (f, a) => f(...a)
|
|
4711
4704
|
});
|
|
4712
|
-
await
|
|
4705
|
+
await this._resourceLock?.acquire();
|
|
4713
4706
|
await this._loggingService.open();
|
|
4714
4707
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4715
4708
|
this._serviceRegistry.setServices({
|
|
4716
4709
|
SystemService: this._systemService,
|
|
4717
|
-
IdentityService: new IdentityServiceImpl(this._serviceContext),
|
|
4710
|
+
IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
|
|
4718
4711
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4719
4712
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4720
4713
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -4736,12 +4729,12 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4736
4729
|
this._opening = false;
|
|
4737
4730
|
this._open = true;
|
|
4738
4731
|
this._statusUpdate.emit();
|
|
4739
|
-
const deviceKey =
|
|
4740
|
-
import_log16.log
|
|
4732
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4733
|
+
(0, import_log16.log)("opened", {
|
|
4741
4734
|
deviceKey
|
|
4742
4735
|
}, {
|
|
4743
4736
|
F: __dxlog_file17,
|
|
4744
|
-
L:
|
|
4737
|
+
L: 284,
|
|
4745
4738
|
S: this,
|
|
4746
4739
|
C: (f, a) => f(...a)
|
|
4747
4740
|
});
|
|
@@ -4749,22 +4742,21 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4749
4742
|
id: traceId
|
|
4750
4743
|
}), {
|
|
4751
4744
|
F: __dxlog_file17,
|
|
4752
|
-
L:
|
|
4745
|
+
L: 285,
|
|
4753
4746
|
S: this,
|
|
4754
4747
|
C: (f, a) => f(...a)
|
|
4755
4748
|
});
|
|
4756
4749
|
}
|
|
4757
4750
|
async close() {
|
|
4758
|
-
var _a;
|
|
4759
4751
|
if (!this._open) {
|
|
4760
4752
|
return;
|
|
4761
4753
|
}
|
|
4762
|
-
const deviceKey =
|
|
4763
|
-
import_log16.log
|
|
4754
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4755
|
+
(0, import_log16.log)("closing...", {
|
|
4764
4756
|
deviceKey
|
|
4765
4757
|
}, {
|
|
4766
4758
|
F: __dxlog_file17,
|
|
4767
|
-
L:
|
|
4759
|
+
L: 296,
|
|
4768
4760
|
S: this,
|
|
4769
4761
|
C: (f, a) => f(...a)
|
|
4770
4762
|
});
|
|
@@ -4775,37 +4767,36 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4775
4767
|
await this._serviceContext.close();
|
|
4776
4768
|
this._open = false;
|
|
4777
4769
|
this._statusUpdate.emit();
|
|
4778
|
-
import_log16.log
|
|
4770
|
+
(0, import_log16.log)("closed", {
|
|
4779
4771
|
deviceKey
|
|
4780
4772
|
}, {
|
|
4781
4773
|
F: __dxlog_file17,
|
|
4782
|
-
L:
|
|
4774
|
+
L: 302,
|
|
4783
4775
|
S: this,
|
|
4784
4776
|
C: (f, a) => f(...a)
|
|
4785
4777
|
});
|
|
4786
4778
|
}
|
|
4787
4779
|
async reset() {
|
|
4788
|
-
var _a, _b, _c;
|
|
4789
4780
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4790
4781
|
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
|
|
4791
4782
|
id: traceId
|
|
4792
4783
|
}), {
|
|
4793
4784
|
F: __dxlog_file17,
|
|
4794
|
-
L:
|
|
4785
|
+
L: 307,
|
|
4795
4786
|
S: this,
|
|
4796
4787
|
C: (f, a) => f(...a)
|
|
4797
4788
|
});
|
|
4798
4789
|
(0, import_log16.log)("resetting...", void 0, {
|
|
4799
4790
|
F: __dxlog_file17,
|
|
4800
|
-
L:
|
|
4791
|
+
L: 309,
|
|
4801
4792
|
S: this,
|
|
4802
4793
|
C: (f, a) => f(...a)
|
|
4803
4794
|
});
|
|
4804
|
-
await
|
|
4795
|
+
await this._serviceContext?.close();
|
|
4805
4796
|
await this._storage.reset();
|
|
4806
4797
|
(0, import_log16.log)("reset", void 0, {
|
|
4807
4798
|
F: __dxlog_file17,
|
|
4808
|
-
L:
|
|
4799
|
+
L: 312,
|
|
4809
4800
|
S: this,
|
|
4810
4801
|
C: (f, a) => f(...a)
|
|
4811
4802
|
});
|
|
@@ -4813,11 +4804,11 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4813
4804
|
id: traceId
|
|
4814
4805
|
}), {
|
|
4815
4806
|
F: __dxlog_file17,
|
|
4816
|
-
L:
|
|
4807
|
+
L: 313,
|
|
4817
4808
|
S: this,
|
|
4818
4809
|
C: (f, a) => f(...a)
|
|
4819
4810
|
});
|
|
4820
|
-
await
|
|
4811
|
+
await this._callbacks?.onReset?.();
|
|
4821
4812
|
}
|
|
4822
4813
|
};
|
|
4823
4814
|
_ts_decorate7([
|
|
@@ -4845,7 +4836,7 @@ var import_context11 = require("@dxos/context");
|
|
|
4845
4836
|
var import_log17 = require("@dxos/log");
|
|
4846
4837
|
var import_messaging2 = require("@dxos/messaging");
|
|
4847
4838
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
4848
|
-
var
|
|
4839
|
+
var import_util11 = require("@dxos/util");
|
|
4849
4840
|
|
|
4850
4841
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
4851
4842
|
var import_async18 = require("@dxos/async");
|
|
@@ -4909,8 +4900,7 @@ var ShellRuntimeImpl = class {
|
|
|
4909
4900
|
await this._appRpc.open();
|
|
4910
4901
|
}
|
|
4911
4902
|
async close() {
|
|
4912
|
-
|
|
4913
|
-
await ((_a = this._appRpc) == null ? void 0 : _a.close());
|
|
4903
|
+
await this._appRpc?.close();
|
|
4914
4904
|
this._appRpc = void 0;
|
|
4915
4905
|
}
|
|
4916
4906
|
};
|
|
@@ -4946,7 +4936,6 @@ var IFrameHostRuntime = class {
|
|
|
4946
4936
|
return this._shellRuntime;
|
|
4947
4937
|
}
|
|
4948
4938
|
async start() {
|
|
4949
|
-
var _a;
|
|
4950
4939
|
(0, import_log17.log)("starting...", void 0, {
|
|
4951
4940
|
F: __dxlog_file19,
|
|
4952
4941
|
L: 71,
|
|
@@ -4954,7 +4943,7 @@ var IFrameHostRuntime = class {
|
|
|
4954
4943
|
C: (f, a) => f(...a)
|
|
4955
4944
|
});
|
|
4956
4945
|
try {
|
|
4957
|
-
this._config = await (0,
|
|
4946
|
+
this._config = await (0, import_util11.getAsyncValue)(this._configProvider);
|
|
4958
4947
|
this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)({
|
|
4959
4948
|
iceServers: this._config.get("runtime.services.ice")
|
|
4960
4949
|
});
|
|
@@ -4993,7 +4982,7 @@ var IFrameHostRuntime = class {
|
|
|
4993
4982
|
await Promise.all([
|
|
4994
4983
|
this._clientServices.open(new import_context11.Context()),
|
|
4995
4984
|
this._clientRpc.open(),
|
|
4996
|
-
|
|
4985
|
+
this._shellRuntime?.open()
|
|
4997
4986
|
]);
|
|
4998
4987
|
this._ready.wake(void 0);
|
|
4999
4988
|
(0, import_log17.log)("started", void 0, {
|
|
@@ -5013,7 +5002,6 @@ var IFrameHostRuntime = class {
|
|
|
5013
5002
|
}
|
|
5014
5003
|
}
|
|
5015
5004
|
async stop() {
|
|
5016
|
-
var _a;
|
|
5017
5005
|
(0, import_log17.log)("stopping...", void 0, {
|
|
5018
5006
|
F: __dxlog_file19,
|
|
5019
5007
|
L: 122,
|
|
@@ -5022,7 +5010,7 @@ var IFrameHostRuntime = class {
|
|
|
5022
5010
|
});
|
|
5023
5011
|
await this._clientRpc.close();
|
|
5024
5012
|
await this._clientServices.close();
|
|
5025
|
-
await
|
|
5013
|
+
await this._shellRuntime?.close();
|
|
5026
5014
|
(0, import_log17.log)("stopped", void 0, {
|
|
5027
5015
|
F: __dxlog_file19,
|
|
5028
5016
|
L: 126,
|
|
@@ -5042,7 +5030,7 @@ var import_errors6 = require("@dxos/errors");
|
|
|
5042
5030
|
var import_log18 = require("@dxos/log");
|
|
5043
5031
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
5044
5032
|
var import_rpc3 = require("@dxos/rpc");
|
|
5045
|
-
var
|
|
5033
|
+
var import_util12 = require("@dxos/util");
|
|
5046
5034
|
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts";
|
|
5047
5035
|
var IFrameProxyRuntime = class {
|
|
5048
5036
|
constructor({ config, systemPort, shellPort }) {
|
|
@@ -5059,8 +5047,7 @@ var IFrameProxyRuntime = class {
|
|
|
5059
5047
|
return this._shellRuntime;
|
|
5060
5048
|
}
|
|
5061
5049
|
async open(origin) {
|
|
5062
|
-
|
|
5063
|
-
this._config = await (0, import_util11.getAsyncValue)(this._configProvider);
|
|
5050
|
+
this._config = await (0, import_util12.getAsyncValue)(this._configProvider);
|
|
5064
5051
|
this._transportService = new import_network_manager4.WebRTCTransportService({
|
|
5065
5052
|
iceServers: this._config.get("runtime.services.ice")
|
|
5066
5053
|
});
|
|
@@ -5099,12 +5086,11 @@ var IFrameProxyRuntime = class {
|
|
|
5099
5086
|
});
|
|
5100
5087
|
throw new import_errors6.RemoteServiceConnectionError("Failed to connect to worker");
|
|
5101
5088
|
}
|
|
5102
|
-
await
|
|
5089
|
+
await this._shellRuntime?.open();
|
|
5103
5090
|
}
|
|
5104
5091
|
async close() {
|
|
5105
|
-
var _a;
|
|
5106
5092
|
this._release.wake();
|
|
5107
|
-
await
|
|
5093
|
+
await this._shellRuntime?.close();
|
|
5108
5094
|
await this._systemRpc.rpc.WorkerService.stop();
|
|
5109
5095
|
await this._systemRpc.close();
|
|
5110
5096
|
}
|
|
@@ -5126,7 +5112,7 @@ var import_client_protocol9 = require("@dxos/client-protocol");
|
|
|
5126
5112
|
var import_invariant16 = require("@dxos/invariant");
|
|
5127
5113
|
var import_log19 = require("@dxos/log");
|
|
5128
5114
|
var import_rpc4 = require("@dxos/rpc");
|
|
5129
|
-
var
|
|
5115
|
+
var import_util13 = require("@dxos/util");
|
|
5130
5116
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
5131
5117
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5132
5118
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -5141,7 +5127,7 @@ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
5141
5127
|
var WorkerSession = class {
|
|
5142
5128
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
5143
5129
|
this._startTrigger = new import_async21.Trigger();
|
|
5144
|
-
this.onClose = new
|
|
5130
|
+
this.onClose = new import_util13.Callback();
|
|
5145
5131
|
(0, import_invariant16.invariant)(serviceHost, void 0, {
|
|
5146
5132
|
F: __dxlog_file21,
|
|
5147
5133
|
L: 49,
|
|
@@ -5269,7 +5255,7 @@ var WorkerSession = class {
|
|
|
5269
5255
|
async _maybeOpenShell() {
|
|
5270
5256
|
try {
|
|
5271
5257
|
await (0, import_async21.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
5272
|
-
} catch
|
|
5258
|
+
} catch {
|
|
5273
5259
|
import_log19.log.info("No shell connected.", void 0, {
|
|
5274
5260
|
F: __dxlog_file21,
|
|
5275
5261
|
L: 143,
|
|
@@ -5335,7 +5321,7 @@ var WorkerRuntime = class {
|
|
|
5335
5321
|
});
|
|
5336
5322
|
} catch (err) {
|
|
5337
5323
|
this._ready.wake(err);
|
|
5338
|
-
import_log20.log.catch(
|
|
5324
|
+
import_log20.log.catch("starting", err, {
|
|
5339
5325
|
F: __dxlog_file22,
|
|
5340
5326
|
L: 66,
|
|
5341
5327
|
S: this,
|