@dxos/client-services 0.1.56-main.09ca29d → 0.1.56-main.0e9f69e
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-FD4L7N4K.mjs → chunk-II6TDINB.mjs} +782 -511
- package/dist/lib/browser/chunk-II6TDINB.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +30 -31
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +31 -46
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +918 -649
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +1198 -939
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts +7 -1
- 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/identity/identity.d.ts +3 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/services/index.d.ts +1 -0
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/platform.d.ts +16 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-context.d.ts +2 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +7 -3
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +6 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +12 -2
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +2 -0
- package/dist/types/src/version.d.ts.map +1 -0
- package/package.json +34 -33
- package/src/packlets/devices/devices-service.test.ts +2 -1
- package/src/packlets/identity/identity-manager.test.ts +15 -3
- package/src/packlets/identity/identity-manager.ts +27 -6
- package/src/packlets/identity/identity-service.test.ts +17 -2
- package/src/packlets/identity/identity-service.ts +23 -14
- package/src/packlets/identity/identity.test.ts +7 -6
- package/src/packlets/identity/identity.ts +8 -3
- package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
- package/src/packlets/logging/logging-service.ts +17 -9
- package/src/packlets/network/network-service.test.ts +2 -1
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/diagnostics.ts +211 -0
- package/src/packlets/services/index.ts +1 -0
- package/src/packlets/services/platform.ts +48 -0
- package/src/packlets/services/service-context.test.ts +59 -0
- package/src/packlets/services/service-context.ts +16 -9
- package/src/packlets/services/service-host.test.ts +11 -10
- package/src/packlets/services/service-host.ts +38 -18
- package/src/packlets/services/service-registry.test.ts +3 -1
- package/src/packlets/services/util.ts +33 -0
- package/src/packlets/spaces/data-space-manager.test.ts +80 -22
- package/src/packlets/spaces/data-space.ts +17 -5
- package/src/packlets/spaces/spaces-service.test.ts +2 -1
- package/src/packlets/system/system-service.test.ts +1 -0
- package/src/packlets/system/system-service.ts +34 -2
- package/src/packlets/testing/test-builder.ts +1 -1
- package/src/packlets/vault/iframe-host-runtime.ts +2 -1
- package/src/packlets/vault/worker-runtime.ts +3 -2
- package/src/packlets/vault/worker-session.ts +6 -1
- package/src/version.ts +1 -0
- package/dist/lib/browser/chunk-FD4L7N4K.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -45,6 +45,7 @@ __export(src_exports, {
|
|
|
45
45
|
WorkerSession: () => WorkerSession,
|
|
46
46
|
createAuthProvider: () => createAuthProvider,
|
|
47
47
|
createDefaultModelFactory: () => createDefaultModelFactory,
|
|
48
|
+
createDiagnostics: () => createDiagnostics,
|
|
48
49
|
createStorageObjects: () => createStorageObjects,
|
|
49
50
|
getNetworkPeers: () => getNetworkPeers,
|
|
50
51
|
isLocked: () => isLocked,
|
|
@@ -74,7 +75,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
74
75
|
const feedMap = new import_util.ComplexMap(import_keys.PublicKey.hash);
|
|
75
76
|
const update = () => {
|
|
76
77
|
const { feeds } = feedStore;
|
|
77
|
-
feeds.filter((feed) => !
|
|
78
|
+
feeds.filter((feed) => !feedKeys?.length || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
|
|
78
79
|
if (!feedMap.has(feed.key)) {
|
|
79
80
|
feedMap.set(feed.key, feed);
|
|
80
81
|
feed.on("close", update);
|
|
@@ -82,15 +83,12 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
82
83
|
}
|
|
83
84
|
});
|
|
84
85
|
next({
|
|
85
|
-
feeds: Array.from(feedMap.values()).map((feed) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
downloaded: (_b = (_a = feed.core.bitfield) == null ? void 0 : _a.data.toBuffer()) != null ? _b : new Uint8Array()
|
|
92
|
-
};
|
|
93
|
-
})
|
|
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
|
+
}))
|
|
94
92
|
});
|
|
95
93
|
};
|
|
96
94
|
subscriptions.add(feedStore.feedOpened.on(update));
|
|
@@ -190,13 +188,13 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf4.Stream
|
|
|
190
188
|
recipient: message.recipient.asUint8Array(),
|
|
191
189
|
payload: message.payload
|
|
192
190
|
},
|
|
193
|
-
receivedAt: new Date()
|
|
191
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
194
192
|
});
|
|
195
193
|
});
|
|
196
194
|
signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
197
195
|
next({
|
|
198
196
|
swarmEvent: swarmEvent.swarmEvent,
|
|
199
|
-
receivedAt: new Date()
|
|
197
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
200
198
|
});
|
|
201
199
|
});
|
|
202
200
|
return () => {
|
|
@@ -207,13 +205,10 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
|
|
|
207
205
|
const update = () => {
|
|
208
206
|
try {
|
|
209
207
|
const topics = networkManager.topics;
|
|
210
|
-
const labeledTopics = topics.map((topic) => {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
label: (_b = (_a = networkManager.getSwarm(topic)) == null ? void 0 : _a.label) != null ? _b : topic.toHex()
|
|
215
|
-
};
|
|
216
|
-
});
|
|
208
|
+
const labeledTopics = topics.map((topic) => ({
|
|
209
|
+
topic,
|
|
210
|
+
label: networkManager.getSwarm(topic)?.label ?? topic.toHex()
|
|
211
|
+
}));
|
|
217
212
|
next({
|
|
218
213
|
topics: labeledTopics
|
|
219
214
|
});
|
|
@@ -225,17 +220,15 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
|
|
|
225
220
|
update();
|
|
226
221
|
});
|
|
227
222
|
var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf4.Stream(({ next }) => {
|
|
228
|
-
var _a;
|
|
229
223
|
const update = () => {
|
|
230
|
-
|
|
231
|
-
const info = (_a2 = networkManager.connectionLog) == null ? void 0 : _a2.swarms;
|
|
224
|
+
const info = networkManager.connectionLog?.swarms;
|
|
232
225
|
if (info) {
|
|
233
226
|
next({
|
|
234
227
|
data: info
|
|
235
228
|
});
|
|
236
229
|
}
|
|
237
230
|
};
|
|
238
|
-
|
|
231
|
+
networkManager.connectionLog?.update.on(update);
|
|
239
232
|
update();
|
|
240
233
|
});
|
|
241
234
|
var getNetworkPeers = ({ networkManager }, request) => {
|
|
@@ -244,7 +237,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
|
|
|
244
237
|
}
|
|
245
238
|
const map = networkManager.getSwarmMap(import_keys2.PublicKey.from(request.topic));
|
|
246
239
|
return {
|
|
247
|
-
peers: map
|
|
240
|
+
peers: map?.peers.map((peer) => ({
|
|
248
241
|
...peer,
|
|
249
242
|
connections: peer.connections.map((connection) => connection.asUint8Array())
|
|
250
243
|
}))
|
|
@@ -260,14 +253,14 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
260
253
|
const spaces = [
|
|
261
254
|
...context.spaceManager.spaces.values()
|
|
262
255
|
];
|
|
263
|
-
const filteredSpaces = spaces.filter((space) => !
|
|
256
|
+
const filteredSpaces = spaces.filter((space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
|
|
264
257
|
next({
|
|
265
258
|
spaces: filteredSpaces.map((space) => {
|
|
266
259
|
const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata2) => spaceMetadata2.key.equals(space.key));
|
|
267
260
|
return {
|
|
268
261
|
key: space.key,
|
|
269
262
|
isOpen: space.isOpen,
|
|
270
|
-
timeframe: spaceMetadata
|
|
263
|
+
timeframe: spaceMetadata?.dataTimeframe,
|
|
271
264
|
genesisFeed: space.genesisFeedKey,
|
|
272
265
|
controlFeed: space.controlFeedKey,
|
|
273
266
|
dataFeed: space.dataFeedKey
|
|
@@ -281,7 +274,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
281
274
|
await update();
|
|
282
275
|
});
|
|
283
276
|
return () => {
|
|
284
|
-
unsubscribe
|
|
277
|
+
unsubscribe?.();
|
|
285
278
|
clearTimeout(timeout);
|
|
286
279
|
};
|
|
287
280
|
});
|
|
@@ -312,16 +305,15 @@ var DevtoolsServiceImpl = class {
|
|
|
312
305
|
};
|
|
313
306
|
}
|
|
314
307
|
async getStorageInfo() {
|
|
315
|
-
|
|
316
|
-
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?.() ?? {
|
|
317
309
|
used: 0
|
|
318
310
|
};
|
|
319
311
|
const navigatorInfo = typeof navigator === "object" ? await navigator.storage.estimate() : void 0;
|
|
320
312
|
return {
|
|
321
313
|
type: this.params.context.storage.type,
|
|
322
314
|
storageUsage: storageUsage.used,
|
|
323
|
-
originUsage:
|
|
324
|
-
usageQuota:
|
|
315
|
+
originUsage: navigatorInfo?.usage ?? 0,
|
|
316
|
+
usageQuota: navigatorInfo?.quota ?? 0
|
|
325
317
|
};
|
|
326
318
|
}
|
|
327
319
|
async getBlobs() {
|
|
@@ -507,7 +499,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
507
499
|
return await trigger.wait({
|
|
508
500
|
timeout: this._params.authTimeout
|
|
509
501
|
});
|
|
510
|
-
} catch
|
|
502
|
+
} catch {
|
|
511
503
|
return false;
|
|
512
504
|
} finally {
|
|
513
505
|
clear();
|
|
@@ -529,8 +521,19 @@ var import_feed_store2 = require("@dxos/feed-store");
|
|
|
529
521
|
var import_invariant = require("@dxos/invariant");
|
|
530
522
|
var import_log2 = require("@dxos/log");
|
|
531
523
|
var import_credentials3 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
524
|
+
var import_tracing = require("@dxos/tracing");
|
|
525
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
526
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
527
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
528
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
529
|
+
else
|
|
530
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
531
|
+
if (d = decorators[i])
|
|
532
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
533
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
534
|
+
}
|
|
532
535
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
533
|
-
var Identity = class {
|
|
536
|
+
var Identity = class Identity2 {
|
|
534
537
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
535
538
|
this.stateUpdate = new import_async5.Event();
|
|
536
539
|
this.space = space;
|
|
@@ -556,12 +559,12 @@ var Identity = class {
|
|
|
556
559
|
get authorizedDeviceKeys() {
|
|
557
560
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
558
561
|
}
|
|
559
|
-
async open() {
|
|
562
|
+
async open(ctx) {
|
|
560
563
|
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
561
564
|
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
562
|
-
await this.space.open();
|
|
565
|
+
await this.space.open(ctx);
|
|
563
566
|
}
|
|
564
|
-
async close() {
|
|
567
|
+
async close(ctx) {
|
|
565
568
|
await this.authVerifier.close();
|
|
566
569
|
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
567
570
|
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
@@ -592,11 +595,10 @@ var Identity = class {
|
|
|
592
595
|
return this._deviceStateMachine.deviceCredentialChain;
|
|
593
596
|
}
|
|
594
597
|
getAdmissionCredentials() {
|
|
595
|
-
var _a, _b;
|
|
596
598
|
return {
|
|
597
599
|
deviceKey: this.deviceKey,
|
|
598
|
-
controlFeedKey:
|
|
599
|
-
dataFeedKey:
|
|
600
|
+
controlFeedKey: this.space.controlFeedKey ?? (0, import_debug.failUndefined)(),
|
|
601
|
+
dataFeedKey: this.space.dataFeedKey ?? (0, import_debug.failUndefined)()
|
|
600
602
|
};
|
|
601
603
|
}
|
|
602
604
|
/**
|
|
@@ -606,7 +608,7 @@ var Identity = class {
|
|
|
606
608
|
getIdentityCredentialSigner() {
|
|
607
609
|
(0, import_invariant.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
608
610
|
F: __dxlog_file2,
|
|
609
|
-
L:
|
|
611
|
+
L: 139,
|
|
610
612
|
S: this,
|
|
611
613
|
A: [
|
|
612
614
|
"this._deviceStateMachine.deviceCredentialChain",
|
|
@@ -630,7 +632,7 @@ var Identity = class {
|
|
|
630
632
|
dataFeedKey
|
|
631
633
|
}, {
|
|
632
634
|
F: __dxlog_file2,
|
|
633
|
-
L:
|
|
635
|
+
L: 155,
|
|
634
636
|
S: this,
|
|
635
637
|
C: (f, a) => f(...a)
|
|
636
638
|
});
|
|
@@ -671,18 +673,40 @@ var Identity = class {
|
|
|
671
673
|
})));
|
|
672
674
|
}
|
|
673
675
|
};
|
|
676
|
+
_ts_decorate([
|
|
677
|
+
import_tracing.trace.span()
|
|
678
|
+
], Identity.prototype, "open", null);
|
|
679
|
+
_ts_decorate([
|
|
680
|
+
import_tracing.trace.span()
|
|
681
|
+
], Identity.prototype, "close", null);
|
|
682
|
+
Identity = _ts_decorate([
|
|
683
|
+
import_tracing.trace.resource()
|
|
684
|
+
], Identity);
|
|
674
685
|
|
|
675
686
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
676
687
|
var import_async6 = require("@dxos/async");
|
|
688
|
+
var import_context3 = require("@dxos/context");
|
|
677
689
|
var import_credentials4 = require("@dxos/credentials");
|
|
678
690
|
var import_invariant2 = require("@dxos/invariant");
|
|
679
691
|
var import_keys4 = require("@dxos/keys");
|
|
680
692
|
var import_log3 = require("@dxos/log");
|
|
681
693
|
var import_protocols2 = require("@dxos/protocols");
|
|
682
694
|
var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
695
|
+
var import_timeframe = require("@dxos/timeframe");
|
|
696
|
+
var import_tracing2 = require("@dxos/tracing");
|
|
683
697
|
var import_util2 = require("@dxos/util");
|
|
698
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
699
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
700
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
701
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
702
|
+
else
|
|
703
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
704
|
+
if (d = decorators[i])
|
|
705
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
706
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
707
|
+
}
|
|
684
708
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
685
|
-
var IdentityManager = class {
|
|
709
|
+
var IdentityManager = class IdentityManager2 {
|
|
686
710
|
// TODO(burdon): IdentityManagerParams.
|
|
687
711
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
688
712
|
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
@@ -695,14 +719,13 @@ var IdentityManager = class {
|
|
|
695
719
|
get identity() {
|
|
696
720
|
return this._identity;
|
|
697
721
|
}
|
|
698
|
-
async open() {
|
|
699
|
-
var _a;
|
|
722
|
+
async open(ctx) {
|
|
700
723
|
const traceId = import_keys4.PublicKey.random().toHex();
|
|
701
724
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
|
|
702
725
|
id: traceId
|
|
703
726
|
}), {
|
|
704
727
|
F: __dxlog_file3,
|
|
705
|
-
L:
|
|
728
|
+
L: 73,
|
|
706
729
|
S: this,
|
|
707
730
|
C: (f, a) => f(...a)
|
|
708
731
|
});
|
|
@@ -712,20 +735,20 @@ var IdentityManager = class {
|
|
|
712
735
|
identityRecord
|
|
713
736
|
}, {
|
|
714
737
|
F: __dxlog_file3,
|
|
715
|
-
L:
|
|
738
|
+
L: 77,
|
|
716
739
|
S: this,
|
|
717
740
|
C: (f, a) => f(...a)
|
|
718
741
|
});
|
|
719
742
|
if (identityRecord) {
|
|
720
743
|
this._identity = await this._constructIdentity(identityRecord);
|
|
721
|
-
await this._identity.open();
|
|
744
|
+
await this._identity.open(ctx);
|
|
722
745
|
await this._identity.ready();
|
|
723
746
|
import_log3.log.trace("dxos.halo.identity", {
|
|
724
747
|
identityKey: identityRecord.identityKey,
|
|
725
|
-
displayName:
|
|
748
|
+
displayName: this._identity.profileDocument?.displayName
|
|
726
749
|
}, {
|
|
727
750
|
F: __dxlog_file3,
|
|
728
|
-
L:
|
|
751
|
+
L: 82,
|
|
729
752
|
S: this,
|
|
730
753
|
C: (f, a) => f(...a)
|
|
731
754
|
});
|
|
@@ -735,20 +758,18 @@ var IdentityManager = class {
|
|
|
735
758
|
id: traceId
|
|
736
759
|
}), {
|
|
737
760
|
F: __dxlog_file3,
|
|
738
|
-
L:
|
|
761
|
+
L: 88,
|
|
739
762
|
S: this,
|
|
740
763
|
C: (f, a) => f(...a)
|
|
741
764
|
});
|
|
742
765
|
}
|
|
743
766
|
async close() {
|
|
744
|
-
|
|
745
|
-
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
767
|
+
await this._identity?.close(new import_context3.Context());
|
|
746
768
|
}
|
|
747
769
|
async createIdentity({ displayName } = {}) {
|
|
748
|
-
var _a;
|
|
749
770
|
(0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
|
|
750
771
|
F: __dxlog_file3,
|
|
751
|
-
L:
|
|
772
|
+
L: 96,
|
|
752
773
|
S: this,
|
|
753
774
|
A: [
|
|
754
775
|
"!this._identity",
|
|
@@ -757,7 +778,7 @@ var IdentityManager = class {
|
|
|
757
778
|
});
|
|
758
779
|
(0, import_log3.log)("creating identity...", void 0, {
|
|
759
780
|
F: __dxlog_file3,
|
|
760
|
-
L:
|
|
781
|
+
L: 97,
|
|
761
782
|
S: this,
|
|
762
783
|
C: (f, a) => f(...a)
|
|
763
784
|
});
|
|
@@ -773,12 +794,12 @@ var IdentityManager = class {
|
|
|
773
794
|
}
|
|
774
795
|
};
|
|
775
796
|
const identity = await this._constructIdentity(identityRecord);
|
|
776
|
-
await identity.open();
|
|
797
|
+
await identity.open(new import_context3.Context());
|
|
777
798
|
{
|
|
778
799
|
const generator = new import_credentials4.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
779
800
|
(0, import_invariant2.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
780
801
|
F: __dxlog_file3,
|
|
781
|
-
L:
|
|
802
|
+
L: 116,
|
|
782
803
|
S: this,
|
|
783
804
|
A: [
|
|
784
805
|
"identityRecord.haloSpace.genesisFeedKey",
|
|
@@ -787,7 +808,7 @@ var IdentityManager = class {
|
|
|
787
808
|
});
|
|
788
809
|
(0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
789
810
|
F: __dxlog_file3,
|
|
790
|
-
L:
|
|
811
|
+
L: 117,
|
|
791
812
|
S: this,
|
|
792
813
|
A: [
|
|
793
814
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -819,10 +840,10 @@ var IdentityManager = class {
|
|
|
819
840
|
await this._identity.ready();
|
|
820
841
|
import_log3.log.trace("dxos.halo.identity", {
|
|
821
842
|
identityKey: identityRecord.identityKey,
|
|
822
|
-
displayName:
|
|
843
|
+
displayName: this._identity.profileDocument?.displayName
|
|
823
844
|
}, {
|
|
824
845
|
F: __dxlog_file3,
|
|
825
|
-
L:
|
|
846
|
+
L: 152,
|
|
826
847
|
S: this,
|
|
827
848
|
C: (f, a) => f(...a)
|
|
828
849
|
});
|
|
@@ -832,7 +853,7 @@ var IdentityManager = class {
|
|
|
832
853
|
deviceKey: identity.deviceKey
|
|
833
854
|
}, {
|
|
834
855
|
F: __dxlog_file3,
|
|
835
|
-
L:
|
|
856
|
+
L: 158,
|
|
836
857
|
S: this,
|
|
837
858
|
C: (f, a) => f(...a)
|
|
838
859
|
});
|
|
@@ -842,18 +863,17 @@ var IdentityManager = class {
|
|
|
842
863
|
* Accept an existing identity. Expects it's device key to be authorized (now or later).
|
|
843
864
|
*/
|
|
844
865
|
async acceptIdentity(params) {
|
|
845
|
-
var _a;
|
|
846
866
|
(0, import_log3.log)("accepting identity", {
|
|
847
867
|
params
|
|
848
868
|
}, {
|
|
849
869
|
F: __dxlog_file3,
|
|
850
|
-
L:
|
|
870
|
+
L: 166,
|
|
851
871
|
S: this,
|
|
852
872
|
C: (f, a) => f(...a)
|
|
853
873
|
});
|
|
854
874
|
(0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
|
|
855
875
|
F: __dxlog_file3,
|
|
856
|
-
L:
|
|
876
|
+
L: 167,
|
|
857
877
|
S: this,
|
|
858
878
|
A: [
|
|
859
879
|
"!this._identity",
|
|
@@ -872,16 +892,16 @@ var IdentityManager = class {
|
|
|
872
892
|
}
|
|
873
893
|
};
|
|
874
894
|
const identity = await this._constructIdentity(identityRecord);
|
|
875
|
-
await identity.open();
|
|
895
|
+
await identity.open(new import_context3.Context());
|
|
876
896
|
this._identity = identity;
|
|
877
897
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
878
898
|
await this._identity.ready();
|
|
879
899
|
import_log3.log.trace("dxos.halo.identity", {
|
|
880
900
|
identityKey: identityRecord.identityKey,
|
|
881
|
-
displayName:
|
|
901
|
+
displayName: this._identity.profileDocument?.displayName
|
|
882
902
|
}, {
|
|
883
903
|
F: __dxlog_file3,
|
|
884
|
-
L:
|
|
904
|
+
L: 186,
|
|
885
905
|
S: this,
|
|
886
906
|
C: (f, a) => f(...a)
|
|
887
907
|
});
|
|
@@ -891,16 +911,48 @@ var IdentityManager = class {
|
|
|
891
911
|
deviceKey: identity.deviceKey
|
|
892
912
|
}, {
|
|
893
913
|
F: __dxlog_file3,
|
|
894
|
-
L:
|
|
914
|
+
L: 192,
|
|
895
915
|
S: this,
|
|
896
916
|
C: (f, a) => f(...a)
|
|
897
917
|
});
|
|
898
918
|
return identity;
|
|
899
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
|
+
}
|
|
900
952
|
async _constructIdentity(identityRecord) {
|
|
901
953
|
(0, import_invariant2.invariant)(!this._identity, void 0, {
|
|
902
954
|
F: __dxlog_file3,
|
|
903
|
-
L:
|
|
955
|
+
L: 214,
|
|
904
956
|
S: this,
|
|
905
957
|
A: [
|
|
906
958
|
"!this._identity",
|
|
@@ -911,13 +963,13 @@ var IdentityManager = class {
|
|
|
911
963
|
identityRecord
|
|
912
964
|
}, {
|
|
913
965
|
F: __dxlog_file3,
|
|
914
|
-
L:
|
|
966
|
+
L: 215,
|
|
915
967
|
S: this,
|
|
916
968
|
C: (f, a) => f(...a)
|
|
917
969
|
});
|
|
918
970
|
(0, import_invariant2.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
919
971
|
F: __dxlog_file3,
|
|
920
|
-
L:
|
|
972
|
+
L: 218,
|
|
921
973
|
S: this,
|
|
922
974
|
A: [
|
|
923
975
|
"identityRecord.haloSpace.controlFeedKey",
|
|
@@ -929,7 +981,7 @@ var IdentityManager = class {
|
|
|
929
981
|
});
|
|
930
982
|
(0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
931
983
|
F: __dxlog_file3,
|
|
932
|
-
L:
|
|
984
|
+
L: 222,
|
|
933
985
|
S: this,
|
|
934
986
|
A: [
|
|
935
987
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -961,7 +1013,7 @@ var IdentityManager = class {
|
|
|
961
1013
|
identityKey: identityRecord.identityKey
|
|
962
1014
|
}, {
|
|
963
1015
|
F: __dxlog_file3,
|
|
964
|
-
L:
|
|
1016
|
+
L: 246,
|
|
965
1017
|
S: this,
|
|
966
1018
|
C: (f, a) => f(...a)
|
|
967
1019
|
});
|
|
@@ -982,7 +1034,7 @@ var IdentityManager = class {
|
|
|
982
1034
|
onAuthFailure: () => {
|
|
983
1035
|
import_log3.log.warn("auth failure", void 0, {
|
|
984
1036
|
F: __dxlog_file3,
|
|
985
|
-
L:
|
|
1037
|
+
L: 265,
|
|
986
1038
|
S: this,
|
|
987
1039
|
C: (f, a) => f(...a)
|
|
988
1040
|
});
|
|
@@ -991,6 +1043,12 @@ var IdentityManager = class {
|
|
|
991
1043
|
});
|
|
992
1044
|
}
|
|
993
1045
|
};
|
|
1046
|
+
_ts_decorate2([
|
|
1047
|
+
import_tracing2.trace.span()
|
|
1048
|
+
], IdentityManager.prototype, "open", null);
|
|
1049
|
+
IdentityManager = _ts_decorate2([
|
|
1050
|
+
import_tracing2.trace.resource()
|
|
1051
|
+
], IdentityManager);
|
|
994
1052
|
|
|
995
1053
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
996
1054
|
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
@@ -999,12 +1057,13 @@ var import_debug2 = require("@dxos/debug");
|
|
|
999
1057
|
var import_invariant3 = require("@dxos/invariant");
|
|
1000
1058
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
1001
1059
|
var IdentityServiceImpl = class {
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
this.
|
|
1060
|
+
constructor(_createIdentity, _identityManager, _keyring) {
|
|
1061
|
+
this._createIdentity = _createIdentity;
|
|
1062
|
+
this._identityManager = _identityManager;
|
|
1063
|
+
this._keyring = _keyring;
|
|
1005
1064
|
}
|
|
1006
1065
|
async createIdentity(request) {
|
|
1007
|
-
await this.
|
|
1066
|
+
await this._createIdentity(request);
|
|
1008
1067
|
return this._getIdentity();
|
|
1009
1068
|
}
|
|
1010
1069
|
async recoverIdentity(request) {
|
|
@@ -1016,34 +1075,47 @@ var IdentityServiceImpl = class {
|
|
|
1016
1075
|
identity: this._getIdentity()
|
|
1017
1076
|
});
|
|
1018
1077
|
emitNext();
|
|
1019
|
-
return this.
|
|
1078
|
+
return this._identityManager.stateUpdate.on(emitNext);
|
|
1020
1079
|
});
|
|
1021
1080
|
}
|
|
1022
1081
|
_getIdentity() {
|
|
1023
|
-
if (!this.
|
|
1082
|
+
if (!this._identityManager.identity) {
|
|
1024
1083
|
return void 0;
|
|
1025
1084
|
}
|
|
1026
1085
|
return {
|
|
1027
|
-
identityKey: this.
|
|
1028
|
-
spaceKey: this.
|
|
1029
|
-
profile: this.
|
|
1086
|
+
identityKey: this._identityManager.identity.identityKey,
|
|
1087
|
+
spaceKey: this._identityManager.identity.space.key,
|
|
1088
|
+
profile: this._identityManager.identity.profileDocument
|
|
1030
1089
|
};
|
|
1031
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
|
+
}
|
|
1032
1104
|
async signPresentation({ presentation, nonce }) {
|
|
1033
|
-
(0, import_invariant3.invariant)(this.
|
|
1105
|
+
(0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1034
1106
|
F: __dxlog_file4,
|
|
1035
|
-
L:
|
|
1107
|
+
L: 65,
|
|
1036
1108
|
S: this,
|
|
1037
1109
|
A: [
|
|
1038
|
-
"this.
|
|
1110
|
+
"this._identityManager.identity",
|
|
1039
1111
|
"'Identity not initialized.'"
|
|
1040
1112
|
]
|
|
1041
1113
|
});
|
|
1042
1114
|
return await (0, import_credentials6.signPresentation)({
|
|
1043
1115
|
presentation,
|
|
1044
|
-
signer: this.
|
|
1045
|
-
signerKey: this.
|
|
1046
|
-
chain: this.
|
|
1116
|
+
signer: this._keyring,
|
|
1117
|
+
signerKey: this._identityManager.identity.deviceKey,
|
|
1118
|
+
chain: this._identityManager.identity.deviceCredentialChain,
|
|
1047
1119
|
nonce
|
|
1048
1120
|
});
|
|
1049
1121
|
}
|
|
@@ -1142,7 +1214,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1142
1214
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1143
1215
|
var import_async8 = require("@dxos/async");
|
|
1144
1216
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
1145
|
-
var
|
|
1217
|
+
var import_context5 = require("@dxos/context");
|
|
1146
1218
|
var import_credentials7 = require("@dxos/credentials");
|
|
1147
1219
|
var import_errors2 = require("@dxos/errors");
|
|
1148
1220
|
var import_invariant6 = require("@dxos/invariant");
|
|
@@ -1155,7 +1227,7 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
|
|
|
1155
1227
|
|
|
1156
1228
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
1157
1229
|
var import_async7 = require("@dxos/async");
|
|
1158
|
-
var
|
|
1230
|
+
var import_context4 = require("@dxos/context");
|
|
1159
1231
|
var import_errors = require("@dxos/errors");
|
|
1160
1232
|
var import_invariant5 = require("@dxos/invariant");
|
|
1161
1233
|
var import_keys5 = require("@dxos/keys");
|
|
@@ -1178,7 +1250,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1178
1250
|
}
|
|
1179
1251
|
});
|
|
1180
1252
|
this._callbacks = _callbacks;
|
|
1181
|
-
this._ctx = new
|
|
1253
|
+
this._ctx = new import_context4.Context();
|
|
1182
1254
|
this._remoteOptionsTrigger = new import_async7.Trigger();
|
|
1183
1255
|
this.invitation = void 0;
|
|
1184
1256
|
this.guestProfile = void 0;
|
|
@@ -1379,16 +1451,15 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1379
1451
|
};
|
|
1380
1452
|
}
|
|
1381
1453
|
async onOpen(context) {
|
|
1382
|
-
var _a;
|
|
1383
1454
|
await super.onOpen(context);
|
|
1384
1455
|
try {
|
|
1385
1456
|
await this.rpc.InvitationHostService.options({
|
|
1386
1457
|
role: import_invitations.Options.Role.HOST
|
|
1387
1458
|
});
|
|
1388
|
-
await (0,
|
|
1459
|
+
await (0, import_context4.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1389
1460
|
timeout: OPTIONS_TIMEOUT
|
|
1390
1461
|
}));
|
|
1391
|
-
if (
|
|
1462
|
+
if (this._remoteOptions?.role !== import_invitations.Options.Role.GUEST) {
|
|
1392
1463
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
1393
1464
|
expected: import_invitations.Options.Role.GUEST,
|
|
1394
1465
|
remoteOptions: this._remoteOptions
|
|
@@ -1414,7 +1485,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1414
1485
|
}
|
|
1415
1486
|
});
|
|
1416
1487
|
this._callbacks = _callbacks;
|
|
1417
|
-
this._ctx = new
|
|
1488
|
+
this._ctx = new import_context4.Context();
|
|
1418
1489
|
this._remoteOptionsTrigger = new import_async7.Trigger();
|
|
1419
1490
|
}
|
|
1420
1491
|
async getHandlers() {
|
|
@@ -1446,7 +1517,6 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1446
1517
|
};
|
|
1447
1518
|
}
|
|
1448
1519
|
async onOpen(context) {
|
|
1449
|
-
var _a;
|
|
1450
1520
|
await super.onOpen(context);
|
|
1451
1521
|
try {
|
|
1452
1522
|
(0, import_log4.log)("begin options", void 0, {
|
|
@@ -1455,10 +1525,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1455
1525
|
S: this,
|
|
1456
1526
|
C: (f, a) => f(...a)
|
|
1457
1527
|
});
|
|
1458
|
-
await (0,
|
|
1528
|
+
await (0, import_context4.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1459
1529
|
role: import_invitations.Options.Role.GUEST
|
|
1460
1530
|
}));
|
|
1461
|
-
await (0,
|
|
1531
|
+
await (0, import_context4.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1462
1532
|
timeout: OPTIONS_TIMEOUT
|
|
1463
1533
|
}));
|
|
1464
1534
|
(0, import_log4.log)("end options", void 0, {
|
|
@@ -1467,7 +1537,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1467
1537
|
S: this,
|
|
1468
1538
|
C: (f, a) => f(...a)
|
|
1469
1539
|
});
|
|
1470
|
-
if (
|
|
1540
|
+
if (this._remoteOptions?.role !== import_invitations.Options.Role.HOST) {
|
|
1471
1541
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
1472
1542
|
expected: import_invitations.Options.Role.HOST,
|
|
1473
1543
|
remoteOptions: this._remoteOptions
|
|
@@ -1506,9 +1576,8 @@ var InvitationsHandler = class {
|
|
|
1506
1576
|
this._networkManager = _networkManager;
|
|
1507
1577
|
}
|
|
1508
1578
|
createInvitation(protocol, options) {
|
|
1509
|
-
|
|
1510
|
-
const
|
|
1511
|
-
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);
|
|
1512
1581
|
(0, import_invariant6.invariant)(protocol, void 0, {
|
|
1513
1582
|
F: __dxlog_file7,
|
|
1514
1583
|
L: 76,
|
|
@@ -1529,7 +1598,7 @@ var InvitationsHandler = class {
|
|
|
1529
1598
|
...protocol.getInvitationContext()
|
|
1530
1599
|
};
|
|
1531
1600
|
const stream = new import_async8.PushStream();
|
|
1532
|
-
const ctx = new
|
|
1601
|
+
const ctx = new import_context5.Context({
|
|
1533
1602
|
onError: (err) => {
|
|
1534
1603
|
void ctx.dispose();
|
|
1535
1604
|
stream.error(err);
|
|
@@ -1561,9 +1630,8 @@ var InvitationsHandler = class {
|
|
|
1561
1630
|
return invitation;
|
|
1562
1631
|
},
|
|
1563
1632
|
admit: async (admissionRequest) => {
|
|
1564
|
-
var _a2, _b, _c;
|
|
1565
1633
|
try {
|
|
1566
|
-
const deviceKey =
|
|
1634
|
+
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1567
1635
|
(0, import_invariant6.invariant)(deviceKey, void 0, {
|
|
1568
1636
|
F: __dxlog_file7,
|
|
1569
1637
|
L: 119,
|
|
@@ -1760,7 +1828,7 @@ var InvitationsHandler = class {
|
|
|
1760
1828
|
...newData
|
|
1761
1829
|
});
|
|
1762
1830
|
};
|
|
1763
|
-
const ctx = new
|
|
1831
|
+
const ctx = new import_context5.Context({
|
|
1764
1832
|
onError: (err) => {
|
|
1765
1833
|
if (err instanceof import_async8.TimeoutError) {
|
|
1766
1834
|
(0, import_log5.log)("timeout", {
|
|
@@ -2262,7 +2330,6 @@ var SpaceInvitationProtocol = class {
|
|
|
2262
2330
|
};
|
|
2263
2331
|
}
|
|
2264
2332
|
async admit(request, guestProfile) {
|
|
2265
|
-
var _a;
|
|
2266
2333
|
(0, import_invariant8.invariant)(this._spaceKey, void 0, {
|
|
2267
2334
|
F: __dxlog_file9,
|
|
2268
2335
|
L: 42,
|
|
@@ -2326,7 +2393,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2326
2393
|
space: {
|
|
2327
2394
|
credential: spaceMemberCredential,
|
|
2328
2395
|
controlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2329
|
-
dataTimeframe:
|
|
2396
|
+
dataTimeframe: space.dataPipeline.pipelineState?.timeframe
|
|
2330
2397
|
}
|
|
2331
2398
|
};
|
|
2332
2399
|
}
|
|
@@ -2430,9 +2497,8 @@ var ClientRpcServer = class {
|
|
|
2430
2497
|
await this._rpcPeer.close();
|
|
2431
2498
|
}
|
|
2432
2499
|
_getServiceHandler(serviceName) {
|
|
2433
|
-
var _a;
|
|
2434
2500
|
if (!this._handlerCache.has(serviceName)) {
|
|
2435
|
-
const [key, descriptor] =
|
|
2501
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug3.raise)(new Error(`Service not available: ${serviceName}`));
|
|
2436
2502
|
const service = this._serviceRegistry.services[key];
|
|
2437
2503
|
if (!service) {
|
|
2438
2504
|
throw new Error(`Service not available: ${serviceName}`);
|
|
@@ -2443,63 +2509,224 @@ var ClientRpcServer = class {
|
|
|
2443
2509
|
}
|
|
2444
2510
|
};
|
|
2445
2511
|
|
|
2512
|
+
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2513
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2514
|
+
var import_credentials9 = require("@dxos/credentials");
|
|
2515
|
+
var import_document_model = require("@dxos/document-model");
|
|
2516
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
2517
|
+
var import_log8 = require("@dxos/log");
|
|
2518
|
+
var import_protocols5 = require("@dxos/protocols");
|
|
2519
|
+
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2520
|
+
|
|
2521
|
+
// packages/sdk/client-services/src/version.ts
|
|
2522
|
+
var DXOS_VERSION = "0.1.56-main.0e9f69e";
|
|
2523
|
+
|
|
2524
|
+
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
2525
|
+
var getPlatform = () => {
|
|
2526
|
+
if (process.browser) {
|
|
2527
|
+
if (typeof window !== "undefined") {
|
|
2528
|
+
const { userAgent } = window.navigator;
|
|
2529
|
+
return {
|
|
2530
|
+
type: "browser",
|
|
2531
|
+
userAgent,
|
|
2532
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2533
|
+
};
|
|
2534
|
+
} else {
|
|
2535
|
+
return {
|
|
2536
|
+
type: "shared-worker",
|
|
2537
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2538
|
+
};
|
|
2539
|
+
}
|
|
2540
|
+
} else {
|
|
2541
|
+
const { platform, version, arch } = process;
|
|
2542
|
+
return {
|
|
2543
|
+
type: "node",
|
|
2544
|
+
platform: `${platform} ${version} ${arch}`,
|
|
2545
|
+
runtime: process.version,
|
|
2546
|
+
uptime: Math.floor(process.uptime()),
|
|
2547
|
+
memory: process.memoryUsage()
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
};
|
|
2551
|
+
|
|
2552
|
+
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2553
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2554
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
2555
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2556
|
+
const diagnostics = {
|
|
2557
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2558
|
+
platform: getPlatform(),
|
|
2559
|
+
client: {
|
|
2560
|
+
version: DXOS_VERSION,
|
|
2561
|
+
storage: {
|
|
2562
|
+
version: import_protocols5.STORAGE_VERSION
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
};
|
|
2566
|
+
{
|
|
2567
|
+
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2568
|
+
F: __dxlog_file10,
|
|
2569
|
+
L: 87,
|
|
2570
|
+
S: void 0,
|
|
2571
|
+
A: [
|
|
2572
|
+
"clientServices.LoggingService",
|
|
2573
|
+
"'SystemService is not available.'"
|
|
2574
|
+
]
|
|
2575
|
+
});
|
|
2576
|
+
diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
2577
|
+
timeout: DEFAULT_TIMEOUT
|
|
2578
|
+
}).catch(() => void 0);
|
|
2579
|
+
}
|
|
2580
|
+
const identity = serviceContext.identityManager.identity;
|
|
2581
|
+
if (identity) {
|
|
2582
|
+
diagnostics.identity = {
|
|
2583
|
+
identityKey: identity.identityKey,
|
|
2584
|
+
spaceKey: identity.space.key,
|
|
2585
|
+
profile: identity.profileDocument
|
|
2586
|
+
};
|
|
2587
|
+
const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
2588
|
+
timeout: DEFAULT_TIMEOUT
|
|
2589
|
+
}).catch(() => void 0) ?? {};
|
|
2590
|
+
diagnostics.devices = devices;
|
|
2591
|
+
if (serviceContext.dataSpaceManager) {
|
|
2592
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2593
|
+
}
|
|
2594
|
+
const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2595
|
+
timeout: DEFAULT_TIMEOUT
|
|
2596
|
+
}).catch(() => void 0) ?? {};
|
|
2597
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2598
|
+
feedKey,
|
|
2599
|
+
bytes,
|
|
2600
|
+
length
|
|
2601
|
+
}));
|
|
2602
|
+
}
|
|
2603
|
+
diagnostics.config = config.values;
|
|
2604
|
+
return diagnostics;
|
|
2605
|
+
};
|
|
2606
|
+
var getProperties = (space) => {
|
|
2607
|
+
let properties = {};
|
|
2608
|
+
try {
|
|
2609
|
+
const propertiesItem = space.dataPipeline.itemManager.items.find((item) => item.modelMeta?.type === import_document_model.DocumentModel.meta.type && item.state?.type === "dxos.sdk.client.Properties");
|
|
2610
|
+
const state = propertiesItem?.state;
|
|
2611
|
+
properties = state?.data;
|
|
2612
|
+
} catch (err) {
|
|
2613
|
+
import_log8.log.warn(err.message, void 0, {
|
|
2614
|
+
F: __dxlog_file10,
|
|
2615
|
+
L: 144,
|
|
2616
|
+
S: void 0,
|
|
2617
|
+
C: (f, a) => f(...a)
|
|
2618
|
+
});
|
|
2619
|
+
}
|
|
2620
|
+
return properties;
|
|
2621
|
+
};
|
|
2622
|
+
var getSpaceStats = async (space) => {
|
|
2623
|
+
const stats = {
|
|
2624
|
+
key: space.key,
|
|
2625
|
+
metrics: space.metrics,
|
|
2626
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
2627
|
+
...credential.subject.assertion,
|
|
2628
|
+
id: credential.id
|
|
2629
|
+
})),
|
|
2630
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2631
|
+
identity: {
|
|
2632
|
+
identityKey: member.key,
|
|
2633
|
+
profile: {
|
|
2634
|
+
displayName: member.assertion.profile?.displayName
|
|
2635
|
+
}
|
|
2636
|
+
},
|
|
2637
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services6.SpaceMember.PresenceState.ONLINE : import_services6.SpaceMember.PresenceState.OFFLINE
|
|
2638
|
+
})),
|
|
2639
|
+
pipeline: {
|
|
2640
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
2641
|
+
// currentEpoch: space.dataPipeline.currentEpoch,
|
|
2642
|
+
// appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
2643
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2644
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2645
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2646
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
2647
|
+
// TODO(burdon): Empty?
|
|
2648
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
2649
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
2650
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
2651
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
2652
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
2653
|
+
}
|
|
2654
|
+
};
|
|
2655
|
+
if (space.dataPipeline.itemManager) {
|
|
2656
|
+
Object.assign(stats, {
|
|
2657
|
+
properties: getProperties(space),
|
|
2658
|
+
db: {
|
|
2659
|
+
objects: space.dataPipeline.itemManager.entities.size
|
|
2660
|
+
}
|
|
2661
|
+
});
|
|
2662
|
+
}
|
|
2663
|
+
if (stats.metrics) {
|
|
2664
|
+
const { open, ready } = stats.metrics;
|
|
2665
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
2666
|
+
}
|
|
2667
|
+
return stats;
|
|
2668
|
+
};
|
|
2669
|
+
|
|
2446
2670
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2447
2671
|
var import_async14 = require("@dxos/async");
|
|
2448
|
-
var
|
|
2672
|
+
var import_context9 = require("@dxos/context");
|
|
2673
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
2449
2674
|
var import_debug7 = require("@dxos/debug");
|
|
2450
2675
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
2451
2676
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
2452
|
-
var
|
|
2677
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
2453
2678
|
var import_keyring = require("@dxos/keyring");
|
|
2454
2679
|
var import_keys10 = require("@dxos/keys");
|
|
2455
|
-
var
|
|
2456
|
-
var
|
|
2457
|
-
var
|
|
2680
|
+
var import_log13 = require("@dxos/log");
|
|
2681
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
2682
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2458
2683
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
2684
|
+
var import_tracing3 = require("@dxos/tracing");
|
|
2685
|
+
var import_util7 = require("@dxos/util");
|
|
2459
2686
|
|
|
2460
2687
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2461
2688
|
var import_async12 = require("@dxos/async");
|
|
2462
|
-
var
|
|
2463
|
-
var
|
|
2464
|
-
var
|
|
2689
|
+
var import_context8 = require("@dxos/context");
|
|
2690
|
+
var import_credentials13 = require("@dxos/credentials");
|
|
2691
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
2465
2692
|
var import_keys9 = require("@dxos/keys");
|
|
2466
|
-
var
|
|
2467
|
-
var
|
|
2468
|
-
var
|
|
2693
|
+
var import_log11 = require("@dxos/log");
|
|
2694
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
2695
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2469
2696
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
2470
2697
|
var import_util5 = require("@dxos/util");
|
|
2471
2698
|
|
|
2472
2699
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2473
2700
|
var import_async11 = require("@dxos/async");
|
|
2474
2701
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
2475
|
-
var
|
|
2702
|
+
var import_context7 = require("@dxos/context");
|
|
2476
2703
|
var import_debug4 = require("@dxos/debug");
|
|
2477
2704
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
2478
2705
|
var import_errors3 = require("@dxos/errors");
|
|
2479
2706
|
var import_keys8 = require("@dxos/keys");
|
|
2480
|
-
var
|
|
2481
|
-
var
|
|
2482
|
-
var
|
|
2483
|
-
var
|
|
2707
|
+
var import_log10 = require("@dxos/log");
|
|
2708
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2709
|
+
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2710
|
+
var import_timeframe2 = require("@dxos/timeframe");
|
|
2484
2711
|
var import_util4 = require("@dxos/util");
|
|
2485
2712
|
|
|
2486
2713
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2487
2714
|
var import_async10 = require("@dxos/async");
|
|
2488
|
-
var
|
|
2489
|
-
var
|
|
2715
|
+
var import_context6 = require("@dxos/context");
|
|
2716
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
2490
2717
|
var import_keys7 = require("@dxos/keys");
|
|
2491
|
-
var
|
|
2492
|
-
var
|
|
2718
|
+
var import_log9 = require("@dxos/log");
|
|
2719
|
+
var import_protocols6 = require("@dxos/protocols");
|
|
2493
2720
|
var import_teleport2 = require("@dxos/teleport");
|
|
2494
2721
|
var import_util3 = require("@dxos/util");
|
|
2495
|
-
var
|
|
2722
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2496
2723
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2497
2724
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2498
2725
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
2499
2726
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2500
2727
|
var NotarizationPlugin = class {
|
|
2501
2728
|
constructor() {
|
|
2502
|
-
this._ctx = new
|
|
2729
|
+
this._ctx = new import_context6.Context();
|
|
2503
2730
|
this._extensionOpened = new import_async10.Event();
|
|
2504
2731
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2505
2732
|
this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
|
|
@@ -2517,16 +2744,16 @@ var NotarizationPlugin = class {
|
|
|
2517
2744
|
* Request credentials to be notarized.
|
|
2518
2745
|
*/
|
|
2519
2746
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
2520
|
-
(0,
|
|
2747
|
+
(0, import_log9.log)("notarize", {
|
|
2521
2748
|
credentials
|
|
2522
2749
|
}, {
|
|
2523
|
-
F:
|
|
2750
|
+
F: __dxlog_file11,
|
|
2524
2751
|
L: 90,
|
|
2525
2752
|
S: this,
|
|
2526
2753
|
C: (f, a) => f(...a)
|
|
2527
2754
|
});
|
|
2528
|
-
(0,
|
|
2529
|
-
F:
|
|
2755
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2756
|
+
F: __dxlog_file11,
|
|
2530
2757
|
L: 91,
|
|
2531
2758
|
S: this,
|
|
2532
2759
|
A: [
|
|
@@ -2537,10 +2764,10 @@ var NotarizationPlugin = class {
|
|
|
2537
2764
|
const errors = new import_async10.Trigger();
|
|
2538
2765
|
const ctx = this._ctx.derive({
|
|
2539
2766
|
onError: (err) => {
|
|
2540
|
-
|
|
2767
|
+
import_log9.log.warn("Notarization error", {
|
|
2541
2768
|
err
|
|
2542
2769
|
}, {
|
|
2543
|
-
F:
|
|
2770
|
+
F: __dxlog_file11,
|
|
2544
2771
|
L: 99,
|
|
2545
2772
|
S: this,
|
|
2546
2773
|
C: (f, a) => f(...a)
|
|
@@ -2549,14 +2776,14 @@ var NotarizationPlugin = class {
|
|
|
2549
2776
|
errors.throw(err);
|
|
2550
2777
|
}
|
|
2551
2778
|
});
|
|
2552
|
-
opCtx
|
|
2779
|
+
opCtx?.onDispose(() => ctx.dispose());
|
|
2553
2780
|
if (timeout !== 0) {
|
|
2554
2781
|
(0, import_async10.scheduleTask)(ctx, () => {
|
|
2555
|
-
|
|
2782
|
+
import_log9.log.warn("Notarization timeout", {
|
|
2556
2783
|
timeout,
|
|
2557
2784
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2558
2785
|
}, {
|
|
2559
|
-
F:
|
|
2786
|
+
F: __dxlog_file11,
|
|
2560
2787
|
L: 111,
|
|
2561
2788
|
S: this,
|
|
2562
2789
|
C: (f, a) => f(...a)
|
|
@@ -2576,10 +2803,10 @@ var NotarizationPlugin = class {
|
|
|
2576
2803
|
...this._extensions
|
|
2577
2804
|
].find((peer2) => !peersTried.has(peer2));
|
|
2578
2805
|
if (!peer) {
|
|
2579
|
-
|
|
2806
|
+
import_log9.log.warn("Exhausted all peers to notarize with", {
|
|
2580
2807
|
retryIn: retryTimeout
|
|
2581
2808
|
}, {
|
|
2582
|
-
F:
|
|
2809
|
+
F: __dxlog_file11,
|
|
2583
2810
|
L: 136,
|
|
2584
2811
|
S: this,
|
|
2585
2812
|
C: (f, a) => f(...a)
|
|
@@ -2589,11 +2816,11 @@ var NotarizationPlugin = class {
|
|
|
2589
2816
|
return;
|
|
2590
2817
|
}
|
|
2591
2818
|
peersTried.add(peer);
|
|
2592
|
-
(0,
|
|
2819
|
+
(0, import_log9.log)("try notarizing", {
|
|
2593
2820
|
peer: peer.localPeerId,
|
|
2594
2821
|
credentialId: credentials.map((credential) => credential.id)
|
|
2595
2822
|
}, {
|
|
2596
|
-
F:
|
|
2823
|
+
F: __dxlog_file11,
|
|
2597
2824
|
L: 143,
|
|
2598
2825
|
S: this,
|
|
2599
2826
|
C: (f, a) => f(...a)
|
|
@@ -2601,8 +2828,8 @@ var NotarizationPlugin = class {
|
|
|
2601
2828
|
await peer.rpc.NotarizationService.notarize({
|
|
2602
2829
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2603
2830
|
});
|
|
2604
|
-
(0,
|
|
2605
|
-
F:
|
|
2831
|
+
(0, import_log9.log)("success", void 0, {
|
|
2832
|
+
F: __dxlog_file11,
|
|
2606
2833
|
L: 147,
|
|
2607
2834
|
S: this,
|
|
2608
2835
|
C: (f, a) => f(...a)
|
|
@@ -2610,8 +2837,8 @@ var NotarizationPlugin = class {
|
|
|
2610
2837
|
await (0, import_async10.sleep)(successDelay);
|
|
2611
2838
|
} catch (err) {
|
|
2612
2839
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2613
|
-
|
|
2614
|
-
F:
|
|
2840
|
+
import_log9.log.warn("error notarizing (recoverable)", err, {
|
|
2841
|
+
F: __dxlog_file11,
|
|
2615
2842
|
L: 151,
|
|
2616
2843
|
S: this,
|
|
2617
2844
|
C: (f, a) => f(...a)
|
|
@@ -2624,12 +2851,12 @@ var NotarizationPlugin = class {
|
|
|
2624
2851
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
2625
2852
|
try {
|
|
2626
2853
|
await Promise.race([
|
|
2627
|
-
(0,
|
|
2854
|
+
(0, import_context6.rejectOnDispose)(ctx),
|
|
2628
2855
|
allNotarized,
|
|
2629
2856
|
errors.wait()
|
|
2630
2857
|
]);
|
|
2631
|
-
(0,
|
|
2632
|
-
F:
|
|
2858
|
+
(0, import_log9.log)("done", void 0, {
|
|
2859
|
+
F: __dxlog_file11,
|
|
2633
2860
|
L: 162,
|
|
2634
2861
|
S: this,
|
|
2635
2862
|
C: (f, a) => f(...a)
|
|
@@ -2642,17 +2869,16 @@ var NotarizationPlugin = class {
|
|
|
2642
2869
|
* Called with credentials arriving from the control pipeline.
|
|
2643
2870
|
*/
|
|
2644
2871
|
async processCredential(credential) {
|
|
2645
|
-
var _a;
|
|
2646
2872
|
if (!credential.id) {
|
|
2647
2873
|
return;
|
|
2648
2874
|
}
|
|
2649
|
-
|
|
2875
|
+
this._processCredentialsTriggers.get(credential.id)?.wake();
|
|
2650
2876
|
this._processedCredentials.add(credential.id);
|
|
2651
2877
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2652
2878
|
}
|
|
2653
2879
|
setWriter(writer) {
|
|
2654
|
-
(0,
|
|
2655
|
-
F:
|
|
2880
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
2881
|
+
F: __dxlog_file11,
|
|
2656
2882
|
L: 181,
|
|
2657
2883
|
S: this,
|
|
2658
2884
|
A: [
|
|
@@ -2672,13 +2898,12 @@ var NotarizationPlugin = class {
|
|
|
2672
2898
|
* Requests from other peers to notarize credentials.
|
|
2673
2899
|
*/
|
|
2674
2900
|
async _onNotarize(request) {
|
|
2675
|
-
var _a;
|
|
2676
2901
|
if (!this._writer) {
|
|
2677
2902
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2678
2903
|
}
|
|
2679
|
-
for (const credential of
|
|
2680
|
-
(0,
|
|
2681
|
-
F:
|
|
2904
|
+
for (const credential of request.credentials ?? []) {
|
|
2905
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
2906
|
+
F: __dxlog_file11,
|
|
2682
2907
|
L: 200,
|
|
2683
2908
|
S: this,
|
|
2684
2909
|
A: [
|
|
@@ -2695,10 +2920,10 @@ var NotarizationPlugin = class {
|
|
|
2695
2920
|
createExtension() {
|
|
2696
2921
|
const extension = new NotarizationTeleportExtension({
|
|
2697
2922
|
onOpen: async () => {
|
|
2698
|
-
(0,
|
|
2923
|
+
(0, import_log9.log)("extension opened", {
|
|
2699
2924
|
peer: extension.localPeerId
|
|
2700
2925
|
}, {
|
|
2701
|
-
F:
|
|
2926
|
+
F: __dxlog_file11,
|
|
2702
2927
|
L: 211,
|
|
2703
2928
|
S: this,
|
|
2704
2929
|
C: (f, a) => f(...a)
|
|
@@ -2707,10 +2932,10 @@ var NotarizationPlugin = class {
|
|
|
2707
2932
|
this._extensionOpened.emit();
|
|
2708
2933
|
},
|
|
2709
2934
|
onClose: async () => {
|
|
2710
|
-
(0,
|
|
2935
|
+
(0, import_log9.log)("extension closed", {
|
|
2711
2936
|
peer: extension.localPeerId
|
|
2712
2937
|
}, {
|
|
2713
|
-
F:
|
|
2938
|
+
F: __dxlog_file11,
|
|
2714
2939
|
L: 216,
|
|
2715
2940
|
S: this,
|
|
2716
2941
|
C: (f, a) => f(...a)
|
|
@@ -2726,10 +2951,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2726
2951
|
constructor(_params) {
|
|
2727
2952
|
super({
|
|
2728
2953
|
requested: {
|
|
2729
|
-
NotarizationService:
|
|
2954
|
+
NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2730
2955
|
},
|
|
2731
2956
|
exposed: {
|
|
2732
|
-
NotarizationService:
|
|
2957
|
+
NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2733
2958
|
}
|
|
2734
2959
|
});
|
|
2735
2960
|
this._params = _params;
|
|
@@ -2754,7 +2979,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2754
2979
|
};
|
|
2755
2980
|
|
|
2756
2981
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2757
|
-
function
|
|
2982
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
2758
2983
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2759
2984
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2760
2985
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2764,19 +2989,19 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
2764
2989
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2765
2990
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2766
2991
|
}
|
|
2767
|
-
var
|
|
2992
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2993
|
+
var ENABLE_FEED_PURGE = false;
|
|
2768
2994
|
var DataSpace = class DataSpace2 {
|
|
2769
2995
|
constructor(params) {
|
|
2770
|
-
this._ctx = new
|
|
2996
|
+
this._ctx = new import_context7.Context();
|
|
2771
2997
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2772
|
-
this._state =
|
|
2998
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
2773
2999
|
/**
|
|
2774
3000
|
* Error for _state === SpaceState.ERROR.
|
|
2775
3001
|
*/
|
|
2776
3002
|
this.error = void 0;
|
|
2777
3003
|
this.stateUpdate = new import_async11.Event();
|
|
2778
3004
|
this.metrics = {};
|
|
2779
|
-
var _a;
|
|
2780
3005
|
this._inner = params.inner;
|
|
2781
3006
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
2782
3007
|
this._gossip = params.gossip;
|
|
@@ -2785,7 +3010,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2785
3010
|
this._feedStore = params.feedStore;
|
|
2786
3011
|
this._metadataStore = params.metadataStore;
|
|
2787
3012
|
this._signingContext = params.signingContext;
|
|
2788
|
-
this._callbacks =
|
|
3013
|
+
this._callbacks = params.callbacks ?? {};
|
|
2789
3014
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2790
3015
|
trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2791
3016
|
update: this._inner.stateUpdate,
|
|
@@ -2825,21 +3050,20 @@ var DataSpace = class DataSpace2 {
|
|
|
2825
3050
|
async _open() {
|
|
2826
3051
|
await this._notarizationPlugin.open();
|
|
2827
3052
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2828
|
-
await this._inner.open();
|
|
2829
|
-
this._state =
|
|
3053
|
+
await this._inner.open(new import_context7.Context());
|
|
3054
|
+
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
2830
3055
|
this.stateUpdate.emit();
|
|
2831
3056
|
this.metrics = {};
|
|
2832
|
-
this.metrics.open = new Date();
|
|
3057
|
+
this.metrics.open = /* @__PURE__ */ new Date();
|
|
2833
3058
|
}
|
|
2834
3059
|
async close() {
|
|
2835
3060
|
await this._close();
|
|
2836
3061
|
}
|
|
2837
3062
|
async _close() {
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
this._state = import_services6.SpaceState.CLOSED;
|
|
3063
|
+
await this._callbacks.beforeClose?.();
|
|
3064
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
2841
3065
|
await this._ctx.dispose();
|
|
2842
|
-
this._ctx = new
|
|
3066
|
+
this._ctx = new import_context7.Context();
|
|
2843
3067
|
await this.authVerifier.close();
|
|
2844
3068
|
await this._inner.close();
|
|
2845
3069
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
@@ -2858,47 +3082,46 @@ var DataSpace = class DataSpace2 {
|
|
|
2858
3082
|
initializeDataPipelineAsync() {
|
|
2859
3083
|
(0, import_async11.scheduleTask)(this._ctx, async () => {
|
|
2860
3084
|
try {
|
|
2861
|
-
this.metrics.pipelineInitBegin = new Date();
|
|
3085
|
+
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
2862
3086
|
await this.initializeDataPipeline();
|
|
2863
3087
|
} catch (err) {
|
|
2864
3088
|
if (err instanceof import_errors3.CancelledError) {
|
|
2865
|
-
(0,
|
|
2866
|
-
F:
|
|
2867
|
-
L:
|
|
3089
|
+
(0, import_log10.log)("data pipeline initialization cancelled", err, {
|
|
3090
|
+
F: __dxlog_file12,
|
|
3091
|
+
L: 199,
|
|
2868
3092
|
S: this,
|
|
2869
3093
|
C: (f, a) => f(...a)
|
|
2870
3094
|
});
|
|
2871
3095
|
return;
|
|
2872
3096
|
}
|
|
2873
|
-
|
|
2874
|
-
F:
|
|
2875
|
-
L:
|
|
3097
|
+
import_log10.log.error("Error initializing data pipeline", err, {
|
|
3098
|
+
F: __dxlog_file12,
|
|
3099
|
+
L: 203,
|
|
2876
3100
|
S: this,
|
|
2877
3101
|
C: (f, a) => f(...a)
|
|
2878
3102
|
});
|
|
2879
|
-
this._state =
|
|
3103
|
+
this._state = import_services7.SpaceState.ERROR;
|
|
2880
3104
|
this.error = err;
|
|
2881
3105
|
this.stateUpdate.emit();
|
|
2882
3106
|
} finally {
|
|
2883
|
-
this.metrics.ready = new Date();
|
|
3107
|
+
this.metrics.ready = /* @__PURE__ */ new Date();
|
|
2884
3108
|
}
|
|
2885
3109
|
});
|
|
2886
3110
|
}
|
|
2887
3111
|
async initializeDataPipeline() {
|
|
2888
|
-
|
|
2889
|
-
if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
|
|
3112
|
+
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
2890
3113
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2891
3114
|
}
|
|
2892
|
-
this._state =
|
|
3115
|
+
this._state = import_services7.SpaceState.INITIALIZING;
|
|
2893
3116
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2894
3117
|
ctx: this._ctx,
|
|
2895
3118
|
breakOnStall: false
|
|
2896
3119
|
});
|
|
2897
|
-
this.metrics.controlPipelineReady = new Date();
|
|
3120
|
+
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
2898
3121
|
await this._createWritableFeeds();
|
|
2899
|
-
(0,
|
|
2900
|
-
F:
|
|
2901
|
-
L:
|
|
3122
|
+
(0, import_log10.log)("writable feeds created", void 0, {
|
|
3123
|
+
F: __dxlog_file12,
|
|
3124
|
+
L: 227,
|
|
2902
3125
|
S: this,
|
|
2903
3126
|
C: (f, a) => f(...a)
|
|
2904
3127
|
});
|
|
@@ -2911,11 +3134,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2911
3134
|
}), this._inner.controlPipeline.writer));
|
|
2912
3135
|
}
|
|
2913
3136
|
await this._inner.initializeDataPipeline();
|
|
2914
|
-
this.metrics.dataPipelineOpen = new Date();
|
|
2915
|
-
await (0,
|
|
2916
|
-
(0,
|
|
2917
|
-
F:
|
|
2918
|
-
L:
|
|
3137
|
+
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
3138
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3139
|
+
(0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3140
|
+
F: __dxlog_file12,
|
|
3141
|
+
L: 248,
|
|
2919
3142
|
S: this,
|
|
2920
3143
|
C: (f, a) => f(...a)
|
|
2921
3144
|
});
|
|
@@ -2923,17 +3146,17 @@ var DataSpace = class DataSpace2 {
|
|
|
2923
3146
|
ctx: this._ctx,
|
|
2924
3147
|
breakOnStall: false
|
|
2925
3148
|
});
|
|
2926
|
-
this.metrics.dataPipelineReady = new Date();
|
|
2927
|
-
(0,
|
|
2928
|
-
F:
|
|
2929
|
-
L:
|
|
3149
|
+
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3150
|
+
(0, import_log10.log)("data pipeline ready", void 0, {
|
|
3151
|
+
F: __dxlog_file12,
|
|
3152
|
+
L: 257,
|
|
2930
3153
|
S: this,
|
|
2931
3154
|
C: (f, a) => f(...a)
|
|
2932
3155
|
});
|
|
2933
|
-
await
|
|
2934
|
-
this._state =
|
|
3156
|
+
await this._callbacks.beforeReady?.();
|
|
3157
|
+
this._state = import_services7.SpaceState.READY;
|
|
2935
3158
|
this.stateUpdate.emit();
|
|
2936
|
-
await
|
|
3159
|
+
await this._callbacks.afterReady?.();
|
|
2937
3160
|
}
|
|
2938
3161
|
async _createWritableFeeds() {
|
|
2939
3162
|
const credentials = [];
|
|
@@ -2949,7 +3172,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2949
3172
|
spaceKey: this.key,
|
|
2950
3173
|
deviceKey: this._signingContext.deviceKey,
|
|
2951
3174
|
identityKey: this._signingContext.identityKey,
|
|
2952
|
-
designation:
|
|
3175
|
+
designation: import_credentials10.AdmittedFeed.Designation.CONTROL
|
|
2953
3176
|
}
|
|
2954
3177
|
}));
|
|
2955
3178
|
}
|
|
@@ -2966,7 +3189,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2966
3189
|
spaceKey: this.key,
|
|
2967
3190
|
deviceKey: this._signingContext.deviceKey,
|
|
2968
3191
|
identityKey: this._signingContext.identityKey,
|
|
2969
|
-
designation:
|
|
3192
|
+
designation: import_credentials10.AdmittedFeed.Designation.DATA
|
|
2970
3193
|
}
|
|
2971
3194
|
}));
|
|
2972
3195
|
}
|
|
@@ -2980,7 +3203,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2980
3203
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
2981
3204
|
}
|
|
2982
3205
|
async createEpoch() {
|
|
2983
|
-
var _a, _b;
|
|
2984
3206
|
const epoch = await this.dataPipeline.createEpoch();
|
|
2985
3207
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
2986
3208
|
credential: {
|
|
@@ -2993,65 +3215,67 @@ var DataSpace = class DataSpace2 {
|
|
|
2993
3215
|
})
|
|
2994
3216
|
}
|
|
2995
3217
|
});
|
|
2996
|
-
await this.inner.controlPipeline.state.waitUntilTimeframe(new
|
|
3218
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
|
|
2997
3219
|
[
|
|
2998
3220
|
receipt.feedKey,
|
|
2999
3221
|
receipt.seq
|
|
3000
3222
|
]
|
|
3001
3223
|
]));
|
|
3002
|
-
|
|
3003
|
-
const
|
|
3004
|
-
|
|
3005
|
-
|
|
3224
|
+
if (ENABLE_FEED_PURGE) {
|
|
3225
|
+
for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
|
|
3226
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
3227
|
+
if (indexBeforeEpoch === void 0) {
|
|
3228
|
+
continue;
|
|
3229
|
+
}
|
|
3230
|
+
await feed.safeClear(0, indexBeforeEpoch + 1);
|
|
3006
3231
|
}
|
|
3007
3232
|
}
|
|
3008
3233
|
}
|
|
3009
3234
|
async activate() {
|
|
3010
|
-
if (this._state !==
|
|
3235
|
+
if (this._state !== import_services7.SpaceState.INACTIVE) {
|
|
3011
3236
|
return;
|
|
3012
3237
|
}
|
|
3013
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3238
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
|
|
3014
3239
|
await this._open();
|
|
3015
3240
|
this.initializeDataPipelineAsync();
|
|
3016
3241
|
}
|
|
3017
3242
|
async deactivate() {
|
|
3018
|
-
if (this._state ===
|
|
3243
|
+
if (this._state === import_services7.SpaceState.INACTIVE) {
|
|
3019
3244
|
return;
|
|
3020
3245
|
}
|
|
3021
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3246
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
|
|
3022
3247
|
await this._close();
|
|
3023
|
-
this._state =
|
|
3248
|
+
this._state = import_services7.SpaceState.INACTIVE;
|
|
3024
3249
|
this.stateUpdate.emit();
|
|
3025
3250
|
}
|
|
3026
3251
|
};
|
|
3027
|
-
|
|
3252
|
+
_ts_decorate3([
|
|
3028
3253
|
import_async11.synchronized
|
|
3029
3254
|
], DataSpace.prototype, "open", null);
|
|
3030
|
-
|
|
3255
|
+
_ts_decorate3([
|
|
3031
3256
|
import_async11.synchronized
|
|
3032
3257
|
], DataSpace.prototype, "close", null);
|
|
3033
|
-
|
|
3258
|
+
_ts_decorate3([
|
|
3034
3259
|
(0, import_debug4.timed)(1e4)
|
|
3035
3260
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
3036
|
-
|
|
3261
|
+
_ts_decorate3([
|
|
3037
3262
|
import_async11.synchronized
|
|
3038
3263
|
], DataSpace.prototype, "activate", null);
|
|
3039
|
-
|
|
3264
|
+
_ts_decorate3([
|
|
3040
3265
|
import_async11.synchronized
|
|
3041
3266
|
], DataSpace.prototype, "deactivate", null);
|
|
3042
|
-
DataSpace =
|
|
3267
|
+
DataSpace = _ts_decorate3([
|
|
3043
3268
|
(0, import_async11.trackLeaks)("open", "close")
|
|
3044
3269
|
], DataSpace);
|
|
3045
3270
|
|
|
3046
3271
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
3047
|
-
var
|
|
3272
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
3048
3273
|
var import_debug5 = require("@dxos/debug");
|
|
3049
|
-
var
|
|
3050
|
-
var
|
|
3274
|
+
var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
3275
|
+
var import_timeframe3 = require("@dxos/timeframe");
|
|
3051
3276
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
3052
|
-
var _a, _b, _c, _d;
|
|
3053
3277
|
const credentials = [
|
|
3054
|
-
await (0,
|
|
3278
|
+
await (0, import_credentials11.createCredential)({
|
|
3055
3279
|
signer: keyring,
|
|
3056
3280
|
issuer: space.key,
|
|
3057
3281
|
subject: space.key,
|
|
@@ -3060,45 +3284,45 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3060
3284
|
spaceKey: space.key
|
|
3061
3285
|
}
|
|
3062
3286
|
}),
|
|
3063
|
-
await (0,
|
|
3287
|
+
await (0, import_credentials11.createCredential)({
|
|
3064
3288
|
signer: keyring,
|
|
3065
3289
|
issuer: space.key,
|
|
3066
3290
|
subject: signingContext.identityKey,
|
|
3067
3291
|
assertion: {
|
|
3068
3292
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3069
3293
|
spaceKey: space.key,
|
|
3070
|
-
role:
|
|
3294
|
+
role: import_credentials12.SpaceMember.Role.ADMIN,
|
|
3071
3295
|
profile: signingContext.profile,
|
|
3072
|
-
genesisFeedKey:
|
|
3296
|
+
genesisFeedKey: space.controlFeedKey ?? (0, import_debug5.failUndefined)()
|
|
3073
3297
|
}
|
|
3074
3298
|
}),
|
|
3075
3299
|
await signingContext.credentialSigner.createCredential({
|
|
3076
|
-
subject:
|
|
3300
|
+
subject: space.controlFeedKey ?? (0, import_debug5.failUndefined)(),
|
|
3077
3301
|
assertion: {
|
|
3078
3302
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
3079
3303
|
spaceKey: space.key,
|
|
3080
3304
|
identityKey: signingContext.identityKey,
|
|
3081
3305
|
deviceKey: signingContext.deviceKey,
|
|
3082
|
-
designation:
|
|
3306
|
+
designation: import_credentials12.AdmittedFeed.Designation.CONTROL
|
|
3083
3307
|
}
|
|
3084
3308
|
}),
|
|
3085
3309
|
await signingContext.credentialSigner.createCredential({
|
|
3086
|
-
subject:
|
|
3310
|
+
subject: space.dataFeedKey ?? (0, import_debug5.failUndefined)(),
|
|
3087
3311
|
assertion: {
|
|
3088
3312
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
3089
3313
|
spaceKey: space.key,
|
|
3090
3314
|
identityKey: signingContext.identityKey,
|
|
3091
3315
|
deviceKey: signingContext.deviceKey,
|
|
3092
|
-
designation:
|
|
3316
|
+
designation: import_credentials12.AdmittedFeed.Designation.DATA
|
|
3093
3317
|
}
|
|
3094
3318
|
}),
|
|
3095
3319
|
await signingContext.credentialSigner.createCredential({
|
|
3096
|
-
subject:
|
|
3320
|
+
subject: space.key ?? (0, import_debug5.failUndefined)(),
|
|
3097
3321
|
assertion: {
|
|
3098
3322
|
"@type": "dxos.halo.credentials.Epoch",
|
|
3099
3323
|
number: 0,
|
|
3100
3324
|
previousId: void 0,
|
|
3101
|
-
timeframe: new
|
|
3325
|
+
timeframe: new import_timeframe3.Timeframe(),
|
|
3102
3326
|
snapshotCid: void 0
|
|
3103
3327
|
}
|
|
3104
3328
|
})
|
|
@@ -3114,7 +3338,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3114
3338
|
};
|
|
3115
3339
|
|
|
3116
3340
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
3117
|
-
function
|
|
3341
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3118
3342
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3119
3343
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3120
3344
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3124,7 +3348,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
3124
3348
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3125
3349
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3126
3350
|
}
|
|
3127
|
-
var
|
|
3351
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3128
3352
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
3129
3353
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
3130
3354
|
this._spaceManager = _spaceManager;
|
|
@@ -3133,7 +3357,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3133
3357
|
this._keyring = _keyring;
|
|
3134
3358
|
this._signingContext = _signingContext;
|
|
3135
3359
|
this._feedStore = _feedStore;
|
|
3136
|
-
this._ctx = new
|
|
3360
|
+
this._ctx = new import_context8.Context();
|
|
3137
3361
|
this.updated = new import_async12.Event();
|
|
3138
3362
|
this._spaces = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
|
|
3139
3363
|
this._isOpen = false;
|
|
@@ -3144,49 +3368,49 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3144
3368
|
return this._spaces;
|
|
3145
3369
|
}
|
|
3146
3370
|
async open() {
|
|
3147
|
-
(0,
|
|
3148
|
-
F:
|
|
3371
|
+
(0, import_log11.log)("open", void 0, {
|
|
3372
|
+
F: __dxlog_file13,
|
|
3149
3373
|
L: 79,
|
|
3150
3374
|
S: this,
|
|
3151
3375
|
C: (f, a) => f(...a)
|
|
3152
3376
|
});
|
|
3153
|
-
|
|
3377
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.begin({
|
|
3154
3378
|
id: this._instanceId
|
|
3155
3379
|
}), {
|
|
3156
|
-
F:
|
|
3380
|
+
F: __dxlog_file13,
|
|
3157
3381
|
L: 80,
|
|
3158
3382
|
S: this,
|
|
3159
3383
|
C: (f, a) => f(...a)
|
|
3160
3384
|
});
|
|
3161
3385
|
await this._metadataStore.load();
|
|
3162
|
-
(0,
|
|
3386
|
+
(0, import_log11.log)("metadata loaded", {
|
|
3163
3387
|
spaces: this._metadataStore.spaces.length
|
|
3164
3388
|
}, {
|
|
3165
|
-
F:
|
|
3389
|
+
F: __dxlog_file13,
|
|
3166
3390
|
L: 82,
|
|
3167
3391
|
S: this,
|
|
3168
3392
|
C: (f, a) => f(...a)
|
|
3169
3393
|
});
|
|
3170
3394
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
3171
3395
|
try {
|
|
3172
|
-
(0,
|
|
3396
|
+
(0, import_log11.log)("load space", {
|
|
3173
3397
|
spaceMetadata
|
|
3174
3398
|
}, {
|
|
3175
|
-
F:
|
|
3399
|
+
F: __dxlog_file13,
|
|
3176
3400
|
L: 86,
|
|
3177
3401
|
S: this,
|
|
3178
3402
|
C: (f, a) => f(...a)
|
|
3179
3403
|
});
|
|
3180
3404
|
const space = await this._constructSpace(spaceMetadata);
|
|
3181
|
-
if (spaceMetadata.state !==
|
|
3405
|
+
if (spaceMetadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
3182
3406
|
space.initializeDataPipelineAsync();
|
|
3183
3407
|
}
|
|
3184
3408
|
} catch (err) {
|
|
3185
|
-
|
|
3409
|
+
import_log11.log.error("Error loading space", {
|
|
3186
3410
|
spaceMetadata,
|
|
3187
3411
|
err
|
|
3188
3412
|
}, {
|
|
3189
|
-
F:
|
|
3413
|
+
F: __dxlog_file13,
|
|
3190
3414
|
L: 92,
|
|
3191
3415
|
S: this,
|
|
3192
3416
|
C: (f, a) => f(...a)
|
|
@@ -3195,18 +3419,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3195
3419
|
}
|
|
3196
3420
|
this._isOpen = true;
|
|
3197
3421
|
this.updated.emit();
|
|
3198
|
-
|
|
3422
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.end({
|
|
3199
3423
|
id: this._instanceId
|
|
3200
3424
|
}), {
|
|
3201
|
-
F:
|
|
3425
|
+
F: __dxlog_file13,
|
|
3202
3426
|
L: 98,
|
|
3203
3427
|
S: this,
|
|
3204
3428
|
C: (f, a) => f(...a)
|
|
3205
3429
|
});
|
|
3206
3430
|
}
|
|
3207
3431
|
async close() {
|
|
3208
|
-
(0,
|
|
3209
|
-
F:
|
|
3432
|
+
(0, import_log11.log)("close", void 0, {
|
|
3433
|
+
F: __dxlog_file13,
|
|
3210
3434
|
L: 103,
|
|
3211
3435
|
S: this,
|
|
3212
3436
|
C: (f, a) => f(...a)
|
|
@@ -3221,8 +3445,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3221
3445
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3222
3446
|
*/
|
|
3223
3447
|
async createSpace() {
|
|
3224
|
-
(0,
|
|
3225
|
-
F:
|
|
3448
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3449
|
+
F: __dxlog_file13,
|
|
3226
3450
|
L: 116,
|
|
3227
3451
|
S: this,
|
|
3228
3452
|
A: [
|
|
@@ -3238,12 +3462,12 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3238
3462
|
genesisFeedKey: controlFeedKey,
|
|
3239
3463
|
controlFeedKey,
|
|
3240
3464
|
dataFeedKey,
|
|
3241
|
-
state:
|
|
3465
|
+
state: import_services8.SpaceState.ACTIVE
|
|
3242
3466
|
};
|
|
3243
|
-
(0,
|
|
3467
|
+
(0, import_log11.log)("creating space...", {
|
|
3244
3468
|
spaceKey
|
|
3245
3469
|
}, {
|
|
3246
|
-
F:
|
|
3470
|
+
F: __dxlog_file13,
|
|
3247
3471
|
L: 128,
|
|
3248
3472
|
S: this,
|
|
3249
3473
|
C: (f, a) => f(...a)
|
|
@@ -3252,8 +3476,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3252
3476
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
3253
3477
|
await this._metadataStore.addSpace(metadata);
|
|
3254
3478
|
const memberCredential = credentials[1];
|
|
3255
|
-
(0,
|
|
3256
|
-
F:
|
|
3479
|
+
(0, import_invariant11.invariant)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3480
|
+
F: __dxlog_file13,
|
|
3257
3481
|
L: 135,
|
|
3258
3482
|
S: this,
|
|
3259
3483
|
A: [
|
|
@@ -3268,16 +3492,16 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3268
3492
|
}
|
|
3269
3493
|
// TODO(burdon): Rename join space.
|
|
3270
3494
|
async acceptSpace(opts) {
|
|
3271
|
-
(0,
|
|
3495
|
+
(0, import_log11.log)("accept space", {
|
|
3272
3496
|
opts
|
|
3273
3497
|
}, {
|
|
3274
|
-
F:
|
|
3498
|
+
F: __dxlog_file13,
|
|
3275
3499
|
L: 147,
|
|
3276
3500
|
S: this,
|
|
3277
3501
|
C: (f, a) => f(...a)
|
|
3278
3502
|
});
|
|
3279
|
-
(0,
|
|
3280
|
-
F:
|
|
3503
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3504
|
+
F: __dxlog_file13,
|
|
3281
3505
|
L: 148,
|
|
3282
3506
|
S: this,
|
|
3283
3507
|
A: [
|
|
@@ -3285,8 +3509,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3285
3509
|
"'Not open.'"
|
|
3286
3510
|
]
|
|
3287
3511
|
});
|
|
3288
|
-
(0,
|
|
3289
|
-
F:
|
|
3512
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3513
|
+
F: __dxlog_file13,
|
|
3290
3514
|
L: 149,
|
|
3291
3515
|
S: this,
|
|
3292
3516
|
A: [
|
|
@@ -3312,16 +3536,16 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3312
3536
|
* TODO(dmaretskyi): Consider removing.
|
|
3313
3537
|
*/
|
|
3314
3538
|
async waitUntilSpaceReady(spaceKey) {
|
|
3315
|
-
await (0,
|
|
3539
|
+
await (0, import_context8.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
3316
3540
|
const space = this._spaces.get(spaceKey);
|
|
3317
|
-
return !!space && space.state ===
|
|
3541
|
+
return !!space && space.state === import_services8.SpaceState.READY;
|
|
3318
3542
|
}));
|
|
3319
3543
|
}
|
|
3320
3544
|
async _constructSpace(metadata) {
|
|
3321
|
-
(0,
|
|
3545
|
+
(0, import_log11.log)("construct space", {
|
|
3322
3546
|
metadata
|
|
3323
3547
|
}, {
|
|
3324
|
-
F:
|
|
3548
|
+
F: __dxlog_file13,
|
|
3325
3549
|
L: 182,
|
|
3326
3550
|
S: this,
|
|
3327
3551
|
C: (f, a) => f(...a)
|
|
@@ -3356,8 +3580,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3356
3580
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3357
3581
|
},
|
|
3358
3582
|
onAuthFailure: () => {
|
|
3359
|
-
|
|
3360
|
-
F:
|
|
3583
|
+
import_log11.log.warn("auth failure", void 0, {
|
|
3584
|
+
F: __dxlog_file13,
|
|
3361
3585
|
L: 213,
|
|
3362
3586
|
S: this,
|
|
3363
3587
|
C: (f, a) => f(...a)
|
|
@@ -3369,7 +3593,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3369
3593
|
dataFeed && space.setDataFeed(dataFeed);
|
|
3370
3594
|
const dataSpace = new DataSpace({
|
|
3371
3595
|
inner: space,
|
|
3372
|
-
initialState: metadata.state ===
|
|
3596
|
+
initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
|
|
3373
3597
|
metadataStore: this._metadataStore,
|
|
3374
3598
|
gossip,
|
|
3375
3599
|
presence,
|
|
@@ -3378,10 +3602,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3378
3602
|
signingContext: this._signingContext,
|
|
3379
3603
|
callbacks: {
|
|
3380
3604
|
beforeReady: async () => {
|
|
3381
|
-
(0,
|
|
3605
|
+
(0, import_log11.log)("before space ready", {
|
|
3382
3606
|
space: space.key
|
|
3383
3607
|
}, {
|
|
3384
|
-
F:
|
|
3608
|
+
F: __dxlog_file13,
|
|
3385
3609
|
L: 231,
|
|
3386
3610
|
S: this,
|
|
3387
3611
|
C: (f, a) => f(...a)
|
|
@@ -3389,11 +3613,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3389
3613
|
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
3390
3614
|
},
|
|
3391
3615
|
afterReady: async () => {
|
|
3392
|
-
(0,
|
|
3616
|
+
(0, import_log11.log)("after space ready", {
|
|
3393
3617
|
space: space.key,
|
|
3394
3618
|
open: this._isOpen
|
|
3395
3619
|
}, {
|
|
3396
|
-
F:
|
|
3620
|
+
F: __dxlog_file13,
|
|
3397
3621
|
L: 238,
|
|
3398
3622
|
S: this,
|
|
3399
3623
|
C: (f, a) => f(...a)
|
|
@@ -3403,10 +3627,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3403
3627
|
}
|
|
3404
3628
|
},
|
|
3405
3629
|
beforeClose: async () => {
|
|
3406
|
-
(0,
|
|
3630
|
+
(0, import_log11.log)("before space close", {
|
|
3407
3631
|
space: space.key
|
|
3408
3632
|
}, {
|
|
3409
|
-
F:
|
|
3633
|
+
F: __dxlog_file13,
|
|
3410
3634
|
L: 244,
|
|
3411
3635
|
S: this,
|
|
3412
3636
|
C: (f, a) => f(...a)
|
|
@@ -3416,7 +3640,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3416
3640
|
},
|
|
3417
3641
|
cache: metadata.cache
|
|
3418
3642
|
});
|
|
3419
|
-
if (metadata.state !==
|
|
3643
|
+
if (metadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
3420
3644
|
await dataSpace.open();
|
|
3421
3645
|
}
|
|
3422
3646
|
if (metadata.controlTimeframe) {
|
|
@@ -3429,33 +3653,33 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3429
3653
|
return dataSpace;
|
|
3430
3654
|
}
|
|
3431
3655
|
};
|
|
3432
|
-
|
|
3656
|
+
_ts_decorate4([
|
|
3433
3657
|
import_async12.synchronized
|
|
3434
3658
|
], DataSpaceManager.prototype, "open", null);
|
|
3435
|
-
|
|
3659
|
+
_ts_decorate4([
|
|
3436
3660
|
import_async12.synchronized
|
|
3437
3661
|
], DataSpaceManager.prototype, "close", null);
|
|
3438
|
-
|
|
3662
|
+
_ts_decorate4([
|
|
3439
3663
|
import_async12.synchronized
|
|
3440
3664
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3441
|
-
|
|
3665
|
+
_ts_decorate4([
|
|
3442
3666
|
import_async12.synchronized
|
|
3443
3667
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3444
|
-
DataSpaceManager =
|
|
3668
|
+
DataSpaceManager = _ts_decorate4([
|
|
3445
3669
|
(0, import_async12.trackLeaks)("open", "close")
|
|
3446
3670
|
], DataSpaceManager);
|
|
3447
3671
|
|
|
3448
3672
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
3449
3673
|
var import_async13 = require("@dxos/async");
|
|
3450
|
-
var
|
|
3674
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
3451
3675
|
var import_debug6 = require("@dxos/debug");
|
|
3452
3676
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
3453
3677
|
var import_errors4 = require("@dxos/errors");
|
|
3454
|
-
var
|
|
3455
|
-
var
|
|
3456
|
-
var
|
|
3678
|
+
var import_log12 = require("@dxos/log");
|
|
3679
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
3680
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3457
3681
|
var import_util6 = require("@dxos/util");
|
|
3458
|
-
var
|
|
3682
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
3459
3683
|
var SpacesServiceImpl = class {
|
|
3460
3684
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
3461
3685
|
this._identityManager = _identityManager;
|
|
@@ -3472,15 +3696,14 @@ var SpacesServiceImpl = class {
|
|
|
3472
3696
|
return this._serializeSpace(space);
|
|
3473
3697
|
}
|
|
3474
3698
|
async updateSpace({ spaceKey, state }) {
|
|
3475
|
-
var _a;
|
|
3476
3699
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3477
|
-
const space =
|
|
3700
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3478
3701
|
if (state) {
|
|
3479
3702
|
switch (state) {
|
|
3480
|
-
case
|
|
3703
|
+
case import_services9.SpaceState.ACTIVE:
|
|
3481
3704
|
await space.activate();
|
|
3482
3705
|
break;
|
|
3483
|
-
case
|
|
3706
|
+
case import_services9.SpaceState.INACTIVE:
|
|
3484
3707
|
await space.deactivate();
|
|
3485
3708
|
break;
|
|
3486
3709
|
default:
|
|
@@ -3489,14 +3712,14 @@ var SpacesServiceImpl = class {
|
|
|
3489
3712
|
}
|
|
3490
3713
|
}
|
|
3491
3714
|
querySpaces() {
|
|
3492
|
-
return new
|
|
3715
|
+
return new import_codec_protobuf11.Stream(({ next, ctx }) => {
|
|
3493
3716
|
const scheduler = new import_async13.UpdateScheduler(ctx, async () => {
|
|
3494
3717
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3495
3718
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
3496
|
-
(0,
|
|
3719
|
+
(0, import_log12.log)("update", {
|
|
3497
3720
|
spaces
|
|
3498
3721
|
}, {
|
|
3499
|
-
F:
|
|
3722
|
+
F: __dxlog_file14,
|
|
3500
3723
|
L: 78,
|
|
3501
3724
|
S: this,
|
|
3502
3725
|
C: (f, a) => f(...a)
|
|
@@ -3538,17 +3761,15 @@ var SpacesServiceImpl = class {
|
|
|
3538
3761
|
});
|
|
3539
3762
|
}
|
|
3540
3763
|
async postMessage({ spaceKey, channel, message }) {
|
|
3541
|
-
var _a;
|
|
3542
3764
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3543
|
-
const space =
|
|
3765
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3544
3766
|
await space.postMessage(getChannelId(channel), message);
|
|
3545
3767
|
}
|
|
3546
3768
|
subscribeMessages({ spaceKey, channel }) {
|
|
3547
|
-
return new
|
|
3769
|
+
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3548
3770
|
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3549
|
-
var _a;
|
|
3550
3771
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3551
|
-
const space =
|
|
3772
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3552
3773
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3553
3774
|
next(message);
|
|
3554
3775
|
});
|
|
@@ -3557,9 +3778,8 @@ var SpacesServiceImpl = class {
|
|
|
3557
3778
|
});
|
|
3558
3779
|
}
|
|
3559
3780
|
queryCredentials({ spaceKey }) {
|
|
3560
|
-
return new
|
|
3561
|
-
|
|
3562
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3781
|
+
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3782
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3563
3783
|
const processor = {
|
|
3564
3784
|
processCredential: async (credential) => {
|
|
3565
3785
|
next(credential);
|
|
@@ -3570,9 +3790,8 @@ var SpacesServiceImpl = class {
|
|
|
3570
3790
|
});
|
|
3571
3791
|
}
|
|
3572
3792
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
for (const credential of credentials != null ? credentials : []) {
|
|
3793
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3794
|
+
for (const credential of credentials ?? []) {
|
|
3576
3795
|
await space.controlPipeline.writer.write({
|
|
3577
3796
|
credential: {
|
|
3578
3797
|
credential
|
|
@@ -3581,17 +3800,15 @@ var SpacesServiceImpl = class {
|
|
|
3581
3800
|
}
|
|
3582
3801
|
}
|
|
3583
3802
|
async createEpoch({ spaceKey }) {
|
|
3584
|
-
var _a;
|
|
3585
3803
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3586
|
-
const space =
|
|
3804
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3587
3805
|
await space.createEpoch();
|
|
3588
3806
|
}
|
|
3589
3807
|
_serializeSpace(space) {
|
|
3590
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3591
3808
|
return {
|
|
3592
3809
|
spaceKey: space.key,
|
|
3593
3810
|
state: space.state,
|
|
3594
|
-
error: space.error ? (0,
|
|
3811
|
+
error: space.error ? (0, import_protocols8.encodeError)(space.error) : void 0,
|
|
3595
3812
|
pipeline: {
|
|
3596
3813
|
currentEpoch: space.dataPipeline.currentEpoch,
|
|
3597
3814
|
appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
@@ -3599,16 +3816,15 @@ var SpacesServiceImpl = class {
|
|
|
3599
3816
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
3600
3817
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
3601
3818
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
3602
|
-
dataFeeds:
|
|
3603
|
-
startDataTimeframe:
|
|
3604
|
-
currentDataTimeframe:
|
|
3605
|
-
targetDataTimeframe:
|
|
3606
|
-
totalDataTimeframe:
|
|
3819
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
3820
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
3821
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
3822
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
3823
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
3607
3824
|
},
|
|
3608
3825
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3609
|
-
var _a2, _b2, _c2;
|
|
3610
3826
|
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
3611
|
-
const isMe =
|
|
3827
|
+
const isMe = this._identityManager.identity?.identityKey.equals(member.key);
|
|
3612
3828
|
if (isMe) {
|
|
3613
3829
|
peers.push(space.presence.getLocalState());
|
|
3614
3830
|
}
|
|
@@ -3616,14 +3832,14 @@ var SpacesServiceImpl = class {
|
|
|
3616
3832
|
identity: {
|
|
3617
3833
|
identityKey: member.key,
|
|
3618
3834
|
profile: {
|
|
3619
|
-
displayName:
|
|
3835
|
+
displayName: member.assertion.profile?.displayName ?? (0, import_util6.humanize)(member.key)
|
|
3620
3836
|
}
|
|
3621
3837
|
},
|
|
3622
|
-
presence: isMe || peers.length > 0 ?
|
|
3838
|
+
presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
3623
3839
|
peerStates: peers
|
|
3624
3840
|
};
|
|
3625
3841
|
}),
|
|
3626
|
-
creator:
|
|
3842
|
+
creator: space.inner.spaceState.creator?.key,
|
|
3627
3843
|
cache: space.cache,
|
|
3628
3844
|
metrics: space.metrics
|
|
3629
3845
|
};
|
|
@@ -3632,8 +3848,18 @@ var SpacesServiceImpl = class {
|
|
|
3632
3848
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3633
3849
|
|
|
3634
3850
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3635
|
-
|
|
3636
|
-
var
|
|
3851
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
3852
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3853
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3854
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3855
|
+
else
|
|
3856
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3857
|
+
if (d = decorators[i])
|
|
3858
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3859
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3860
|
+
}
|
|
3861
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3862
|
+
var ServiceContext = class ServiceContext2 {
|
|
3637
3863
|
// prettier-ignore
|
|
3638
3864
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
3639
3865
|
this.storage = storage;
|
|
@@ -3667,84 +3893,80 @@ var ServiceContext = class {
|
|
|
3667
3893
|
});
|
|
3668
3894
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3669
3895
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3670
|
-
this._handlerFactories.set(
|
|
3671
|
-
var _a;
|
|
3672
|
-
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
3673
|
-
}, this._acceptIdentity.bind(this)));
|
|
3896
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
3674
3897
|
}
|
|
3675
|
-
async open() {
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
L: 125,
|
|
3898
|
+
async open(ctx) {
|
|
3899
|
+
await this._checkStorageVersion();
|
|
3900
|
+
(0, import_log13.log)("opening...", void 0, {
|
|
3901
|
+
F: __dxlog_file15,
|
|
3902
|
+
L: 134,
|
|
3681
3903
|
S: this,
|
|
3682
3904
|
C: (f, a) => f(...a)
|
|
3683
3905
|
});
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3906
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.begin({
|
|
3907
|
+
id: this._instanceId
|
|
3908
|
+
}), {
|
|
3909
|
+
F: __dxlog_file15,
|
|
3910
|
+
L: 135,
|
|
3688
3911
|
S: this,
|
|
3689
3912
|
C: (f, a) => f(...a)
|
|
3690
3913
|
});
|
|
3691
3914
|
await this.signalManager.open();
|
|
3692
3915
|
await this.networkManager.open();
|
|
3693
3916
|
await this.spaceManager.open();
|
|
3694
|
-
await this.identityManager.open();
|
|
3917
|
+
await this.identityManager.open(ctx);
|
|
3695
3918
|
if (this.identityManager.identity) {
|
|
3696
|
-
await this._initialize();
|
|
3919
|
+
await this._initialize(ctx);
|
|
3697
3920
|
}
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3921
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.end({
|
|
3922
|
+
id: this._instanceId
|
|
3923
|
+
}), {
|
|
3924
|
+
F: __dxlog_file15,
|
|
3925
|
+
L: 143,
|
|
3701
3926
|
S: this,
|
|
3702
3927
|
C: (f, a) => f(...a)
|
|
3703
3928
|
});
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
F: __dxlog_file14,
|
|
3708
|
-
L: 138,
|
|
3929
|
+
(0, import_log13.log)("opened", void 0, {
|
|
3930
|
+
F: __dxlog_file15,
|
|
3931
|
+
L: 144,
|
|
3709
3932
|
S: this,
|
|
3710
3933
|
C: (f, a) => f(...a)
|
|
3711
3934
|
});
|
|
3712
3935
|
}
|
|
3713
3936
|
async close() {
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
L: 142,
|
|
3937
|
+
(0, import_log13.log)("closing...", void 0, {
|
|
3938
|
+
F: __dxlog_file15,
|
|
3939
|
+
L: 148,
|
|
3718
3940
|
S: this,
|
|
3719
3941
|
C: (f, a) => f(...a)
|
|
3720
3942
|
});
|
|
3721
3943
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3722
3944
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3723
3945
|
}
|
|
3724
|
-
await
|
|
3946
|
+
await this.dataSpaceManager?.close();
|
|
3725
3947
|
await this.identityManager.close();
|
|
3726
3948
|
await this.spaceManager.close();
|
|
3727
3949
|
await this.feedStore.close();
|
|
3728
3950
|
await this.networkManager.close();
|
|
3729
3951
|
await this.signalManager.close();
|
|
3730
3952
|
this.dataServiceSubscriptions.clear();
|
|
3731
|
-
(0,
|
|
3732
|
-
F:
|
|
3733
|
-
L:
|
|
3953
|
+
(0, import_log13.log)("closed", void 0, {
|
|
3954
|
+
F: __dxlog_file15,
|
|
3955
|
+
L: 159,
|
|
3734
3956
|
S: this,
|
|
3735
3957
|
C: (f, a) => f(...a)
|
|
3736
3958
|
});
|
|
3737
3959
|
}
|
|
3738
3960
|
async createIdentity(params = {}) {
|
|
3739
3961
|
const identity = await this.identityManager.createIdentity(params);
|
|
3740
|
-
await this._initialize();
|
|
3962
|
+
await this._initialize(new import_context9.Context());
|
|
3741
3963
|
return identity;
|
|
3742
3964
|
}
|
|
3743
3965
|
getInvitationHandler(invitation) {
|
|
3744
3966
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3745
|
-
(0,
|
|
3746
|
-
F:
|
|
3747
|
-
L:
|
|
3967
|
+
(0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3968
|
+
F: __dxlog_file15,
|
|
3969
|
+
L: 171,
|
|
3748
3970
|
S: this,
|
|
3749
3971
|
A: [
|
|
3750
3972
|
"factory",
|
|
@@ -3755,25 +3977,24 @@ var ServiceContext = class {
|
|
|
3755
3977
|
}
|
|
3756
3978
|
async _acceptIdentity(params) {
|
|
3757
3979
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
3758
|
-
await this._initialize();
|
|
3980
|
+
await this._initialize(new import_context9.Context());
|
|
3759
3981
|
return identity;
|
|
3760
3982
|
}
|
|
3761
3983
|
async _checkStorageVersion() {
|
|
3762
3984
|
await this.metadataStore.load();
|
|
3763
|
-
if (this.metadataStore.version !==
|
|
3764
|
-
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${
|
|
3985
|
+
if (this.metadataStore.version !== import_protocols9.STORAGE_VERSION) {
|
|
3986
|
+
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols9.STORAGE_VERSION}`);
|
|
3765
3987
|
}
|
|
3766
3988
|
}
|
|
3767
3989
|
// Called when identity is created.
|
|
3768
|
-
async _initialize() {
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
L: 186,
|
|
3990
|
+
async _initialize(ctx) {
|
|
3991
|
+
(0, import_log13.log)("initializing spaces...", void 0, {
|
|
3992
|
+
F: __dxlog_file15,
|
|
3993
|
+
L: 193,
|
|
3773
3994
|
S: this,
|
|
3774
3995
|
C: (f, a) => f(...a)
|
|
3775
3996
|
});
|
|
3776
|
-
const identity =
|
|
3997
|
+
const identity = this.identityManager.identity ?? (0, import_debug7.failUndefined)();
|
|
3777
3998
|
const signingContext = {
|
|
3778
3999
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3779
4000
|
identityKey: identity.identityKey,
|
|
@@ -3789,10 +4010,10 @@ var ServiceContext = class {
|
|
|
3789
4010
|
};
|
|
3790
4011
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3791
4012
|
await this.dataSpaceManager.open();
|
|
3792
|
-
this._handlerFactories.set(
|
|
3793
|
-
(0,
|
|
3794
|
-
F:
|
|
3795
|
-
L:
|
|
4013
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
4014
|
+
(0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4015
|
+
F: __dxlog_file15,
|
|
4016
|
+
L: 216,
|
|
3796
4017
|
S: this,
|
|
3797
4018
|
A: [
|
|
3798
4019
|
"this.dataSpaceManager",
|
|
@@ -3804,7 +4025,7 @@ var ServiceContext = class {
|
|
|
3804
4025
|
this.initialized.wake();
|
|
3805
4026
|
this._deviceSpaceSync = {
|
|
3806
4027
|
processCredential: async (credential) => {
|
|
3807
|
-
const assertion = (0,
|
|
4028
|
+
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
3808
4029
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3809
4030
|
return;
|
|
3810
4031
|
}
|
|
@@ -3812,33 +4033,33 @@ var ServiceContext = class {
|
|
|
3812
4033
|
return;
|
|
3813
4034
|
}
|
|
3814
4035
|
if (!this.dataSpaceManager) {
|
|
3815
|
-
(0,
|
|
4036
|
+
(0, import_log13.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3816
4037
|
details: assertion
|
|
3817
4038
|
}, {
|
|
3818
|
-
F:
|
|
3819
|
-
L:
|
|
4039
|
+
F: __dxlog_file15,
|
|
4040
|
+
L: 232,
|
|
3820
4041
|
S: this,
|
|
3821
4042
|
C: (f, a) => f(...a)
|
|
3822
4043
|
});
|
|
3823
4044
|
return;
|
|
3824
4045
|
}
|
|
3825
4046
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3826
|
-
(0,
|
|
4047
|
+
(0, import_log13.log)("space already exists, ignoring space admission", {
|
|
3827
4048
|
details: assertion
|
|
3828
4049
|
}, {
|
|
3829
|
-
F:
|
|
3830
|
-
L:
|
|
4050
|
+
F: __dxlog_file15,
|
|
4051
|
+
L: 236,
|
|
3831
4052
|
S: this,
|
|
3832
4053
|
C: (f, a) => f(...a)
|
|
3833
4054
|
});
|
|
3834
4055
|
return;
|
|
3835
4056
|
}
|
|
3836
4057
|
try {
|
|
3837
|
-
(0,
|
|
4058
|
+
(0, import_log13.log)("accepting space recorded in halo", {
|
|
3838
4059
|
details: assertion
|
|
3839
4060
|
}, {
|
|
3840
|
-
F:
|
|
3841
|
-
L:
|
|
4061
|
+
F: __dxlog_file15,
|
|
4062
|
+
L: 241,
|
|
3842
4063
|
S: this,
|
|
3843
4064
|
C: (f, a) => f(...a)
|
|
3844
4065
|
});
|
|
@@ -3847,9 +4068,9 @@ var ServiceContext = class {
|
|
|
3847
4068
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3848
4069
|
});
|
|
3849
4070
|
} catch (err) {
|
|
3850
|
-
|
|
3851
|
-
F:
|
|
3852
|
-
L:
|
|
4071
|
+
import_log13.log.catch(err, void 0, {
|
|
4072
|
+
F: __dxlog_file15,
|
|
4073
|
+
L: 247,
|
|
3853
4074
|
S: this,
|
|
3854
4075
|
C: (f, a) => f(...a)
|
|
3855
4076
|
});
|
|
@@ -3859,26 +4080,38 @@ var ServiceContext = class {
|
|
|
3859
4080
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3860
4081
|
}
|
|
3861
4082
|
};
|
|
4083
|
+
_ts_decorate5([
|
|
4084
|
+
import_tracing3.trace.span()
|
|
4085
|
+
], ServiceContext.prototype, "open", null);
|
|
4086
|
+
_ts_decorate5([
|
|
4087
|
+
import_tracing3.trace.span()
|
|
4088
|
+
], ServiceContext.prototype, "_initialize", null);
|
|
4089
|
+
ServiceContext = _ts_decorate5([
|
|
4090
|
+
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
4091
|
+
import_tracing3.trace.resource()
|
|
4092
|
+
], ServiceContext);
|
|
3862
4093
|
|
|
3863
4094
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3864
4095
|
var import_async17 = require("@dxos/async");
|
|
3865
4096
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3866
|
-
var
|
|
4097
|
+
var import_context10 = require("@dxos/context");
|
|
4098
|
+
var import_document_model2 = require("@dxos/document-model");
|
|
3867
4099
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3868
|
-
var
|
|
4100
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
3869
4101
|
var import_keys11 = require("@dxos/keys");
|
|
3870
|
-
var
|
|
4102
|
+
var import_log16 = require("@dxos/log");
|
|
3871
4103
|
var import_messaging = require("@dxos/messaging");
|
|
3872
4104
|
var import_model_factory = require("@dxos/model-factory");
|
|
3873
4105
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
3874
|
-
var
|
|
3875
|
-
var
|
|
4106
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
4107
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3876
4108
|
var import_text_model = require("@dxos/text-model");
|
|
4109
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
3877
4110
|
|
|
3878
4111
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3879
4112
|
var import_async15 = require("@dxos/async");
|
|
3880
|
-
var
|
|
3881
|
-
var
|
|
4113
|
+
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
4114
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3882
4115
|
var DevicesServiceImpl = class {
|
|
3883
4116
|
constructor(_identityManager) {
|
|
3884
4117
|
this._identityManager = _identityManager;
|
|
@@ -3887,23 +4120,19 @@ var DevicesServiceImpl = class {
|
|
|
3887
4120
|
throw new Error("Method not implemented.");
|
|
3888
4121
|
}
|
|
3889
4122
|
queryDevices() {
|
|
3890
|
-
return new
|
|
4123
|
+
return new import_codec_protobuf12.Stream(({ next }) => {
|
|
3891
4124
|
const update = () => {
|
|
3892
|
-
|
|
3893
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
4125
|
+
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
3894
4126
|
if (!deviceKeys) {
|
|
3895
4127
|
next({
|
|
3896
4128
|
devices: []
|
|
3897
4129
|
});
|
|
3898
4130
|
} else {
|
|
3899
4131
|
next({
|
|
3900
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services10.DeviceKind.CURRENT : import_services10.DeviceKind.TRUSTED
|
|
3905
|
-
};
|
|
3906
|
-
})
|
|
4132
|
+
devices: Array.from(deviceKeys.values()).map((key) => ({
|
|
4133
|
+
deviceKey: key,
|
|
4134
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
|
|
4135
|
+
}))
|
|
3907
4136
|
});
|
|
3908
4137
|
}
|
|
3909
4138
|
};
|
|
@@ -3923,10 +4152,10 @@ var DevicesServiceImpl = class {
|
|
|
3923
4152
|
};
|
|
3924
4153
|
|
|
3925
4154
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
3926
|
-
var
|
|
4155
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
3927
4156
|
var import_lock_file = require("@dxos/lock-file");
|
|
3928
|
-
var
|
|
3929
|
-
function
|
|
4157
|
+
var import_log14 = require("@dxos/log");
|
|
4158
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
3930
4159
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3931
4160
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3932
4161
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3936,7 +4165,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
3936
4165
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3937
4166
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3938
4167
|
}
|
|
3939
|
-
var
|
|
4168
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
3940
4169
|
var Lock = class {
|
|
3941
4170
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
3942
4171
|
this._lockPath = lockPath;
|
|
@@ -3947,27 +4176,25 @@ var Lock = class {
|
|
|
3947
4176
|
return this._lockPath;
|
|
3948
4177
|
}
|
|
3949
4178
|
async acquire() {
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
F: __dxlog_file15,
|
|
4179
|
+
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
4180
|
+
F: __dxlog_file16,
|
|
3953
4181
|
L: 32,
|
|
3954
4182
|
S: this,
|
|
3955
4183
|
C: (f, a) => f(...a)
|
|
3956
4184
|
});
|
|
3957
4185
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
3958
|
-
await
|
|
3959
|
-
(0,
|
|
3960
|
-
F:
|
|
4186
|
+
await this._onAcquire?.();
|
|
4187
|
+
(0, import_log14.log)("acquired lock", void 0, {
|
|
4188
|
+
F: __dxlog_file16,
|
|
3961
4189
|
L: 37,
|
|
3962
4190
|
S: this,
|
|
3963
4191
|
C: (f, a) => f(...a)
|
|
3964
4192
|
});
|
|
3965
4193
|
}
|
|
3966
4194
|
async release() {
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
F: __dxlog_file15,
|
|
4195
|
+
await this._onRelease?.();
|
|
4196
|
+
(0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4197
|
+
F: __dxlog_file16,
|
|
3971
4198
|
L: 42,
|
|
3972
4199
|
S: this,
|
|
3973
4200
|
A: [
|
|
@@ -3978,79 +4205,84 @@ var Lock = class {
|
|
|
3978
4205
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3979
4206
|
}
|
|
3980
4207
|
};
|
|
3981
|
-
|
|
3982
|
-
|
|
4208
|
+
_ts_decorate6([
|
|
4209
|
+
import_log14.logInfo
|
|
3983
4210
|
], Lock.prototype, "lockKey", null);
|
|
3984
4211
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
3985
4212
|
|
|
3986
4213
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
3987
4214
|
var import_async16 = require("@dxos/async");
|
|
3988
|
-
var
|
|
3989
|
-
var
|
|
3990
|
-
var
|
|
3991
|
-
var
|
|
4215
|
+
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
4216
|
+
var import_log15 = require("@dxos/log");
|
|
4217
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4218
|
+
var import_util8 = require("@dxos/util");
|
|
3992
4219
|
var LoggingServiceImpl = class {
|
|
3993
4220
|
constructor() {
|
|
3994
4221
|
this._logs = new import_async16.Event();
|
|
4222
|
+
this._started = /* @__PURE__ */ new Date();
|
|
3995
4223
|
this._logProcessor = (_config, entry2) => {
|
|
3996
4224
|
this._logs.emit(entry2);
|
|
3997
4225
|
};
|
|
3998
4226
|
}
|
|
3999
4227
|
async open() {
|
|
4000
|
-
|
|
4228
|
+
import_log15.log.runtimeConfig.processors.push(this._logProcessor);
|
|
4001
4229
|
}
|
|
4002
4230
|
async close() {
|
|
4003
|
-
const index =
|
|
4004
|
-
|
|
4231
|
+
const index = import_log15.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
4232
|
+
import_log15.log.runtimeConfig.processors.splice(index, 1);
|
|
4005
4233
|
}
|
|
4006
4234
|
async controlMetrics({ reset, record }) {
|
|
4007
4235
|
if (reset) {
|
|
4008
|
-
|
|
4236
|
+
import_util8.tracer.clear();
|
|
4009
4237
|
}
|
|
4010
4238
|
if (record === true) {
|
|
4011
|
-
|
|
4239
|
+
import_util8.tracer.start();
|
|
4012
4240
|
} else if (record === false) {
|
|
4013
|
-
|
|
4241
|
+
import_util8.tracer.stop();
|
|
4014
4242
|
}
|
|
4015
4243
|
return {
|
|
4016
|
-
recording:
|
|
4244
|
+
recording: import_util8.tracer.recording
|
|
4017
4245
|
};
|
|
4018
4246
|
}
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4247
|
+
/**
|
|
4248
|
+
* @deprecated (Move to diagnostics).
|
|
4249
|
+
*/
|
|
4250
|
+
queryMetrics({ interval = 5e3 }) {
|
|
4251
|
+
const getNumericalValues = (key) => {
|
|
4252
|
+
const events = import_util8.tracer.get(key) ?? [];
|
|
4023
4253
|
return {
|
|
4024
4254
|
key,
|
|
4025
|
-
stats: (0,
|
|
4255
|
+
stats: (0, import_util8.numericalValues)(events, "duration")
|
|
4026
4256
|
};
|
|
4027
4257
|
};
|
|
4028
|
-
return new
|
|
4258
|
+
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
4029
4259
|
const update = () => {
|
|
4030
4260
|
const metrics = {
|
|
4031
|
-
timestamp: new Date(),
|
|
4261
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4032
4262
|
values: [
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
]
|
|
4263
|
+
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4264
|
+
getNumericalValues("dxos.echo.pipeline.data")
|
|
4265
|
+
].filter(Boolean)
|
|
4036
4266
|
};
|
|
4037
|
-
next(
|
|
4267
|
+
next({
|
|
4268
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4269
|
+
metrics
|
|
4270
|
+
});
|
|
4038
4271
|
};
|
|
4039
4272
|
update();
|
|
4040
|
-
const i = setInterval(update, interval);
|
|
4273
|
+
const i = setInterval(update, Math.max(interval, 1e3));
|
|
4041
4274
|
return () => {
|
|
4042
4275
|
clearInterval(i);
|
|
4043
4276
|
};
|
|
4044
4277
|
});
|
|
4045
4278
|
}
|
|
4046
4279
|
queryLogs(request) {
|
|
4047
|
-
return new
|
|
4280
|
+
return new import_codec_protobuf13.Stream(({ ctx, next }) => {
|
|
4048
4281
|
const handler = (entry2) => {
|
|
4049
|
-
var _a, _b, _c, _d, _e;
|
|
4050
4282
|
if (LOG_PROCESSING > 0) {
|
|
4051
4283
|
return;
|
|
4052
4284
|
}
|
|
4053
|
-
if (
|
|
4285
|
+
if (entry2.meta?.F.includes("logging-service") || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
4054
4286
|
return;
|
|
4055
4287
|
}
|
|
4056
4288
|
if (!shouldLog(entry2, request)) {
|
|
@@ -4058,12 +4290,12 @@ var LoggingServiceImpl = class {
|
|
|
4058
4290
|
}
|
|
4059
4291
|
const record = {
|
|
4060
4292
|
...entry2,
|
|
4061
|
-
context: (0,
|
|
4062
|
-
timestamp: new Date(),
|
|
4293
|
+
context: (0, import_util8.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
|
|
4294
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4063
4295
|
meta: {
|
|
4064
4296
|
// TODO(dmaretskyi): Fix proto.
|
|
4065
|
-
file:
|
|
4066
|
-
line:
|
|
4297
|
+
file: entry2.meta?.F ?? "",
|
|
4298
|
+
line: entry2.meta?.L ?? 0
|
|
4067
4299
|
}
|
|
4068
4300
|
};
|
|
4069
4301
|
try {
|
|
@@ -4079,35 +4311,31 @@ var LoggingServiceImpl = class {
|
|
|
4079
4311
|
};
|
|
4080
4312
|
var matchFilter = (filter, level, path, options) => {
|
|
4081
4313
|
switch (options) {
|
|
4082
|
-
case
|
|
4314
|
+
case import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
4083
4315
|
return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
4084
|
-
case
|
|
4316
|
+
case import_services12.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
4085
4317
|
return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
4086
4318
|
}
|
|
4087
4319
|
};
|
|
4088
4320
|
var shouldLog = (entry2, request) => {
|
|
4089
|
-
|
|
4090
|
-
const options = (_a = request.options) != null ? _a : import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4321
|
+
const options = request.options ?? import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4091
4322
|
if (request.filters === void 0) {
|
|
4092
|
-
return options ===
|
|
4323
|
+
return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4093
4324
|
} else {
|
|
4094
|
-
return request.filters.some((filter) =>
|
|
4095
|
-
var _a2, _b;
|
|
4096
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
4097
|
-
});
|
|
4325
|
+
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
4098
4326
|
}
|
|
4099
4327
|
};
|
|
4100
4328
|
var LOG_PROCESSING = 0;
|
|
4101
4329
|
|
|
4102
4330
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
4103
|
-
var
|
|
4331
|
+
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
4104
4332
|
var NetworkServiceImpl = class {
|
|
4105
4333
|
constructor(networkManager, signalManager) {
|
|
4106
4334
|
this.networkManager = networkManager;
|
|
4107
4335
|
this.signalManager = signalManager;
|
|
4108
4336
|
}
|
|
4109
4337
|
queryStatus() {
|
|
4110
|
-
return new
|
|
4338
|
+
return new import_codec_protobuf14.Stream(({ next }) => {
|
|
4111
4339
|
const update = () => {
|
|
4112
4340
|
next({
|
|
4113
4341
|
swarm: this.networkManager.connectionState,
|
|
@@ -4136,10 +4364,10 @@ var import_client_protocol4 = require("@dxos/client-protocol");
|
|
|
4136
4364
|
var import_errors5 = require("@dxos/errors");
|
|
4137
4365
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
4138
4366
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
4139
|
-
var
|
|
4367
|
+
var import_util9 = require("@dxos/util");
|
|
4140
4368
|
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
4141
4369
|
var createStorageObjects = (config) => {
|
|
4142
|
-
const { path = (0,
|
|
4370
|
+
const { path = (0, import_util9.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config ?? {};
|
|
4143
4371
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
4144
4372
|
throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4145
4373
|
}
|
|
@@ -4181,25 +4409,40 @@ var toStorageType = (type) => {
|
|
|
4181
4409
|
};
|
|
4182
4410
|
|
|
4183
4411
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
4184
|
-
var
|
|
4412
|
+
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
4413
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4414
|
+
var import_util10 = require("@dxos/util");
|
|
4185
4415
|
var SystemServiceImpl = class {
|
|
4186
|
-
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4416
|
+
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4187
4417
|
this._config = config;
|
|
4188
4418
|
this._statusUpdate = statusUpdate;
|
|
4189
4419
|
this._getCurrentStatus = getCurrentStatus;
|
|
4420
|
+
this._getDiagnostics = getDiagnostics;
|
|
4190
4421
|
this._onUpdateStatus = onUpdateStatus;
|
|
4191
4422
|
this._onReset = onReset;
|
|
4192
4423
|
}
|
|
4193
4424
|
async getConfig() {
|
|
4194
|
-
|
|
4195
|
-
|
|
4425
|
+
return this._config?.values ?? {};
|
|
4426
|
+
}
|
|
4427
|
+
/**
|
|
4428
|
+
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
4429
|
+
*/
|
|
4430
|
+
async getDiagnostics({ keys } = {}) {
|
|
4431
|
+
const diagnostics = await this._getDiagnostics();
|
|
4432
|
+
return {
|
|
4433
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4434
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util10.jsonKeyReplacer)({
|
|
4435
|
+
truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4436
|
+
humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
4437
|
+
})))
|
|
4438
|
+
};
|
|
4196
4439
|
}
|
|
4197
4440
|
async updateStatus({ status }) {
|
|
4198
4441
|
await this._onUpdateStatus(status);
|
|
4199
4442
|
}
|
|
4200
4443
|
// TODO(burdon): Standardize interval option in stream request?
|
|
4201
4444
|
queryStatus({ interval = 3e3 } = {}) {
|
|
4202
|
-
return new
|
|
4445
|
+
return new import_codec_protobuf15.Stream(({ next }) => {
|
|
4203
4446
|
const update = () => {
|
|
4204
4447
|
next({
|
|
4205
4448
|
status: this._getCurrentStatus()
|
|
@@ -4244,7 +4487,7 @@ var ServiceRegistry = class {
|
|
|
4244
4487
|
};
|
|
4245
4488
|
|
|
4246
4489
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4247
|
-
function
|
|
4490
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
4248
4491
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4249
4492
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4250
4493
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4254,23 +4497,22 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
4254
4497
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4255
4498
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4256
4499
|
}
|
|
4257
|
-
var
|
|
4500
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
4258
4501
|
var createDefaultModelFactory = () => {
|
|
4259
|
-
return new import_model_factory.ModelFactory().registerModel(
|
|
4502
|
+
return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
|
|
4260
4503
|
};
|
|
4261
|
-
var ClientServicesHost = class {
|
|
4504
|
+
var ClientServicesHost = class ClientServicesHost2 {
|
|
4262
4505
|
constructor({
|
|
4263
4506
|
config,
|
|
4264
4507
|
modelFactory = createDefaultModelFactory(),
|
|
4265
|
-
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
4266
4508
|
transportFactory,
|
|
4267
4509
|
signalManager,
|
|
4268
|
-
connectionLog,
|
|
4269
4510
|
storage,
|
|
4270
4511
|
// TODO(wittjosiah): Turn this on by default.
|
|
4271
4512
|
lockKey,
|
|
4272
4513
|
callbacks
|
|
4273
4514
|
} = {}) {
|
|
4515
|
+
this._tracingService = import_tracing4.TRACE_PROCESSOR.createTraceSender();
|
|
4274
4516
|
this._statusUpdate = new import_async17.Event();
|
|
4275
4517
|
this._opening = false;
|
|
4276
4518
|
this._open = false;
|
|
@@ -4289,7 +4531,7 @@ var ClientServicesHost = class {
|
|
|
4289
4531
|
lockKey,
|
|
4290
4532
|
onAcquire: () => {
|
|
4291
4533
|
if (!this._opening) {
|
|
4292
|
-
void this.open();
|
|
4534
|
+
void this.open(new import_context10.Context());
|
|
4293
4535
|
}
|
|
4294
4536
|
},
|
|
4295
4537
|
onRelease: () => this.close()
|
|
@@ -4298,13 +4540,15 @@ var ClientServicesHost = class {
|
|
|
4298
4540
|
this._systemService = new SystemServiceImpl({
|
|
4299
4541
|
config: this._config,
|
|
4300
4542
|
statusUpdate: this._statusUpdate,
|
|
4301
|
-
getCurrentStatus: () => this.isOpen ?
|
|
4543
|
+
getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
|
|
4544
|
+
getDiagnostics: () => {
|
|
4545
|
+
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4546
|
+
},
|
|
4302
4547
|
onUpdateStatus: async (status) => {
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
await ((_b = this._resourceLock) == null ? void 0 : _b.release());
|
|
4548
|
+
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
4549
|
+
await this._resourceLock?.acquire();
|
|
4550
|
+
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
4551
|
+
await this._resourceLock?.release();
|
|
4308
4552
|
}
|
|
4309
4553
|
},
|
|
4310
4554
|
onReset: async () => {
|
|
@@ -4313,12 +4557,19 @@ var ClientServicesHost = class {
|
|
|
4313
4557
|
});
|
|
4314
4558
|
this._loggingService = new LoggingServiceImpl();
|
|
4315
4559
|
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
4316
|
-
SystemService: this._systemService
|
|
4560
|
+
SystemService: this._systemService,
|
|
4561
|
+
TracingService: this._tracingService
|
|
4317
4562
|
});
|
|
4318
4563
|
}
|
|
4319
4564
|
get isOpen() {
|
|
4320
4565
|
return this._open;
|
|
4321
4566
|
}
|
|
4567
|
+
get config() {
|
|
4568
|
+
return this._config;
|
|
4569
|
+
}
|
|
4570
|
+
get context() {
|
|
4571
|
+
return this._serviceContext;
|
|
4572
|
+
}
|
|
4322
4573
|
get serviceRegistry() {
|
|
4323
4574
|
return this._serviceRegistry;
|
|
4324
4575
|
}
|
|
@@ -4334,20 +4585,25 @@ var ClientServicesHost = class {
|
|
|
4334
4585
|
* Can only be called once.
|
|
4335
4586
|
*/
|
|
4336
4587
|
initialize({ config, ...options }) {
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
L: 167,
|
|
4588
|
+
(0, import_invariant14.invariant)(!this._open, "service host is open", {
|
|
4589
|
+
F: __dxlog_file17,
|
|
4590
|
+
L: 181,
|
|
4341
4591
|
S: this,
|
|
4342
4592
|
A: [
|
|
4343
4593
|
"!this._open",
|
|
4344
4594
|
"'service host is open'"
|
|
4345
4595
|
]
|
|
4346
4596
|
});
|
|
4597
|
+
(0, import_log16.log)("initializing...", void 0, {
|
|
4598
|
+
F: __dxlog_file17,
|
|
4599
|
+
L: 182,
|
|
4600
|
+
S: this,
|
|
4601
|
+
C: (f, a) => f(...a)
|
|
4602
|
+
});
|
|
4347
4603
|
if (config) {
|
|
4348
|
-
(0,
|
|
4349
|
-
F:
|
|
4350
|
-
L:
|
|
4604
|
+
(0, import_invariant14.invariant)(!this._config, "config already set", {
|
|
4605
|
+
F: __dxlog_file17,
|
|
4606
|
+
L: 185,
|
|
4351
4607
|
S: this,
|
|
4352
4608
|
A: [
|
|
4353
4609
|
"!this._config",
|
|
@@ -4360,12 +4616,12 @@ var ClientServicesHost = class {
|
|
|
4360
4616
|
}
|
|
4361
4617
|
}
|
|
4362
4618
|
const { connectionLog = true, transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
|
|
4363
|
-
iceServers:
|
|
4364
|
-
}), signalManager = new import_messaging.WebsocketSignalManager(
|
|
4619
|
+
iceServers: this._config?.get("runtime.services.ice")
|
|
4620
|
+
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4365
4621
|
this._signalManager = signalManager;
|
|
4366
|
-
(0,
|
|
4367
|
-
F:
|
|
4368
|
-
L:
|
|
4622
|
+
(0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
|
|
4623
|
+
F: __dxlog_file17,
|
|
4624
|
+
L: 201,
|
|
4369
4625
|
S: this,
|
|
4370
4626
|
A: [
|
|
4371
4627
|
"!this._networkManager",
|
|
@@ -4377,51 +4633,56 @@ var ClientServicesHost = class {
|
|
|
4377
4633
|
transportFactory,
|
|
4378
4634
|
signalManager
|
|
4379
4635
|
});
|
|
4636
|
+
(0, import_log16.log)("initialized", void 0, {
|
|
4637
|
+
F: __dxlog_file17,
|
|
4638
|
+
L: 208,
|
|
4639
|
+
S: this,
|
|
4640
|
+
C: (f, a) => f(...a)
|
|
4641
|
+
});
|
|
4380
4642
|
}
|
|
4381
|
-
async open() {
|
|
4382
|
-
var _a, _b, _c;
|
|
4643
|
+
async open(ctx) {
|
|
4383
4644
|
if (this._open) {
|
|
4384
4645
|
return;
|
|
4385
4646
|
}
|
|
4386
4647
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4387
|
-
|
|
4648
|
+
import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.begin({
|
|
4388
4649
|
id: traceId
|
|
4389
4650
|
}), {
|
|
4390
|
-
F:
|
|
4391
|
-
L:
|
|
4651
|
+
F: __dxlog_file17,
|
|
4652
|
+
L: 219,
|
|
4392
4653
|
S: this,
|
|
4393
4654
|
C: (f, a) => f(...a)
|
|
4394
4655
|
});
|
|
4395
|
-
(0,
|
|
4396
|
-
F:
|
|
4397
|
-
L:
|
|
4656
|
+
(0, import_invariant14.invariant)(this._config, "config not set", {
|
|
4657
|
+
F: __dxlog_file17,
|
|
4658
|
+
L: 221,
|
|
4398
4659
|
S: this,
|
|
4399
4660
|
A: [
|
|
4400
4661
|
"this._config",
|
|
4401
4662
|
"'config not set'"
|
|
4402
4663
|
]
|
|
4403
4664
|
});
|
|
4404
|
-
(0,
|
|
4405
|
-
F:
|
|
4406
|
-
L:
|
|
4665
|
+
(0, import_invariant14.invariant)(this._storage, "storage not set", {
|
|
4666
|
+
F: __dxlog_file17,
|
|
4667
|
+
L: 222,
|
|
4407
4668
|
S: this,
|
|
4408
4669
|
A: [
|
|
4409
4670
|
"this._storage",
|
|
4410
4671
|
"'storage not set'"
|
|
4411
4672
|
]
|
|
4412
4673
|
});
|
|
4413
|
-
(0,
|
|
4414
|
-
F:
|
|
4415
|
-
L:
|
|
4674
|
+
(0, import_invariant14.invariant)(this._signalManager, "signal manager not set", {
|
|
4675
|
+
F: __dxlog_file17,
|
|
4676
|
+
L: 223,
|
|
4416
4677
|
S: this,
|
|
4417
4678
|
A: [
|
|
4418
4679
|
"this._signalManager",
|
|
4419
4680
|
"'signal manager not set'"
|
|
4420
4681
|
]
|
|
4421
4682
|
});
|
|
4422
|
-
(0,
|
|
4423
|
-
F:
|
|
4424
|
-
L:
|
|
4683
|
+
(0, import_invariant14.invariant)(this._networkManager, "network manager not set", {
|
|
4684
|
+
F: __dxlog_file17,
|
|
4685
|
+
L: 224,
|
|
4425
4686
|
S: this,
|
|
4426
4687
|
A: [
|
|
4427
4688
|
"this._networkManager",
|
|
@@ -4429,20 +4690,20 @@ var ClientServicesHost = class {
|
|
|
4429
4690
|
]
|
|
4430
4691
|
});
|
|
4431
4692
|
this._opening = true;
|
|
4432
|
-
(0,
|
|
4433
|
-
lockKey:
|
|
4693
|
+
(0, import_log16.log)("opening...", {
|
|
4694
|
+
lockKey: this._resourceLock?.lockKey
|
|
4434
4695
|
}, {
|
|
4435
|
-
F:
|
|
4436
|
-
L:
|
|
4696
|
+
F: __dxlog_file17,
|
|
4697
|
+
L: 227,
|
|
4437
4698
|
S: this,
|
|
4438
4699
|
C: (f, a) => f(...a)
|
|
4439
4700
|
});
|
|
4440
|
-
await
|
|
4701
|
+
await this._resourceLock?.acquire();
|
|
4441
4702
|
await this._loggingService.open();
|
|
4442
4703
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4443
4704
|
this._serviceRegistry.setServices({
|
|
4444
4705
|
SystemService: this._systemService,
|
|
4445
|
-
IdentityService: new IdentityServiceImpl(this._serviceContext),
|
|
4706
|
+
IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
|
|
4446
4707
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4447
4708
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4448
4709
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -4452,6 +4713,7 @@ var ClientServicesHost = class {
|
|
|
4452
4713
|
DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4453
4714
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
4454
4715
|
LoggingService: this._loggingService,
|
|
4716
|
+
TracingService: this._tracingService,
|
|
4455
4717
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4456
4718
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
4457
4719
|
events: new DevtoolsHostEvents(),
|
|
@@ -4459,39 +4721,38 @@ var ClientServicesHost = class {
|
|
|
4459
4721
|
context: this._serviceContext
|
|
4460
4722
|
})
|
|
4461
4723
|
});
|
|
4462
|
-
await this._serviceContext.open();
|
|
4724
|
+
await this._serviceContext.open(ctx);
|
|
4463
4725
|
this._opening = false;
|
|
4464
4726
|
this._open = true;
|
|
4465
4727
|
this._statusUpdate.emit();
|
|
4466
|
-
const deviceKey =
|
|
4467
|
-
(0,
|
|
4728
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4729
|
+
(0, import_log16.log)("opened", {
|
|
4468
4730
|
deviceKey
|
|
4469
4731
|
}, {
|
|
4470
|
-
F:
|
|
4471
|
-
L:
|
|
4732
|
+
F: __dxlog_file17,
|
|
4733
|
+
L: 284,
|
|
4472
4734
|
S: this,
|
|
4473
4735
|
C: (f, a) => f(...a)
|
|
4474
4736
|
});
|
|
4475
|
-
|
|
4737
|
+
import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.end({
|
|
4476
4738
|
id: traceId
|
|
4477
4739
|
}), {
|
|
4478
|
-
F:
|
|
4479
|
-
L:
|
|
4740
|
+
F: __dxlog_file17,
|
|
4741
|
+
L: 285,
|
|
4480
4742
|
S: this,
|
|
4481
4743
|
C: (f, a) => f(...a)
|
|
4482
4744
|
});
|
|
4483
4745
|
}
|
|
4484
4746
|
async close() {
|
|
4485
|
-
var _a;
|
|
4486
4747
|
if (!this._open) {
|
|
4487
4748
|
return;
|
|
4488
4749
|
}
|
|
4489
|
-
const deviceKey =
|
|
4490
|
-
(0,
|
|
4750
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4751
|
+
(0, import_log16.log)("closing...", {
|
|
4491
4752
|
deviceKey
|
|
4492
4753
|
}, {
|
|
4493
|
-
F:
|
|
4494
|
-
L:
|
|
4754
|
+
F: __dxlog_file17,
|
|
4755
|
+
L: 296,
|
|
4495
4756
|
S: this,
|
|
4496
4757
|
C: (f, a) => f(...a)
|
|
4497
4758
|
});
|
|
@@ -4502,73 +4763,84 @@ var ClientServicesHost = class {
|
|
|
4502
4763
|
await this._serviceContext.close();
|
|
4503
4764
|
this._open = false;
|
|
4504
4765
|
this._statusUpdate.emit();
|
|
4505
|
-
(0,
|
|
4766
|
+
(0, import_log16.log)("closed", {
|
|
4506
4767
|
deviceKey
|
|
4507
4768
|
}, {
|
|
4508
|
-
F:
|
|
4509
|
-
L:
|
|
4769
|
+
F: __dxlog_file17,
|
|
4770
|
+
L: 302,
|
|
4510
4771
|
S: this,
|
|
4511
4772
|
C: (f, a) => f(...a)
|
|
4512
4773
|
});
|
|
4513
4774
|
}
|
|
4514
4775
|
async reset() {
|
|
4515
|
-
var _a, _b, _c;
|
|
4516
4776
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4517
|
-
|
|
4777
|
+
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
|
|
4518
4778
|
id: traceId
|
|
4519
4779
|
}), {
|
|
4520
|
-
F:
|
|
4521
|
-
L:
|
|
4780
|
+
F: __dxlog_file17,
|
|
4781
|
+
L: 307,
|
|
4522
4782
|
S: this,
|
|
4523
4783
|
C: (f, a) => f(...a)
|
|
4524
4784
|
});
|
|
4525
|
-
(0,
|
|
4526
|
-
F:
|
|
4527
|
-
L:
|
|
4785
|
+
(0, import_log16.log)("resetting...", void 0, {
|
|
4786
|
+
F: __dxlog_file17,
|
|
4787
|
+
L: 309,
|
|
4528
4788
|
S: this,
|
|
4529
4789
|
C: (f, a) => f(...a)
|
|
4530
4790
|
});
|
|
4531
|
-
await
|
|
4791
|
+
await this._serviceContext?.close();
|
|
4532
4792
|
await this._storage.reset();
|
|
4533
|
-
(0,
|
|
4534
|
-
F:
|
|
4535
|
-
L:
|
|
4793
|
+
(0, import_log16.log)("reset", void 0, {
|
|
4794
|
+
F: __dxlog_file17,
|
|
4795
|
+
L: 312,
|
|
4536
4796
|
S: this,
|
|
4537
4797
|
C: (f, a) => f(...a)
|
|
4538
4798
|
});
|
|
4539
|
-
|
|
4799
|
+
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.end({
|
|
4540
4800
|
id: traceId
|
|
4541
4801
|
}), {
|
|
4542
|
-
F:
|
|
4543
|
-
L:
|
|
4802
|
+
F: __dxlog_file17,
|
|
4803
|
+
L: 313,
|
|
4544
4804
|
S: this,
|
|
4545
4805
|
C: (f, a) => f(...a)
|
|
4546
4806
|
});
|
|
4547
|
-
await
|
|
4807
|
+
await this._callbacks?.onReset?.();
|
|
4548
4808
|
}
|
|
4549
4809
|
};
|
|
4550
|
-
|
|
4551
|
-
|
|
4810
|
+
_ts_decorate7([
|
|
4811
|
+
import_tracing4.trace.info()
|
|
4812
|
+
], ClientServicesHost.prototype, "_opening", void 0);
|
|
4813
|
+
_ts_decorate7([
|
|
4814
|
+
import_tracing4.trace.info()
|
|
4815
|
+
], ClientServicesHost.prototype, "_open", void 0);
|
|
4816
|
+
_ts_decorate7([
|
|
4817
|
+
import_async17.synchronized,
|
|
4818
|
+
import_tracing4.trace.span()
|
|
4552
4819
|
], ClientServicesHost.prototype, "open", null);
|
|
4553
|
-
|
|
4554
|
-
import_async17.synchronized
|
|
4820
|
+
_ts_decorate7([
|
|
4821
|
+
import_async17.synchronized,
|
|
4822
|
+
import_tracing4.trace.span()
|
|
4555
4823
|
], ClientServicesHost.prototype, "close", null);
|
|
4824
|
+
ClientServicesHost = _ts_decorate7([
|
|
4825
|
+
import_tracing4.trace.resource()
|
|
4826
|
+
], ClientServicesHost);
|
|
4556
4827
|
|
|
4557
4828
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
4558
4829
|
var import_async19 = require("@dxos/async");
|
|
4559
4830
|
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
4560
|
-
var
|
|
4831
|
+
var import_context11 = require("@dxos/context");
|
|
4832
|
+
var import_log17 = require("@dxos/log");
|
|
4561
4833
|
var import_messaging2 = require("@dxos/messaging");
|
|
4562
4834
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
4563
|
-
var
|
|
4835
|
+
var import_util11 = require("@dxos/util");
|
|
4564
4836
|
|
|
4565
4837
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
4566
4838
|
var import_async18 = require("@dxos/async");
|
|
4567
4839
|
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
4568
|
-
var
|
|
4840
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
4569
4841
|
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
4570
4842
|
var import_rpc2 = require("@dxos/rpc");
|
|
4571
|
-
var
|
|
4843
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/shell-runtime.ts";
|
|
4572
4844
|
var ShellRuntimeImpl = class {
|
|
4573
4845
|
constructor(_port) {
|
|
4574
4846
|
this._port = _port;
|
|
@@ -4594,8 +4866,8 @@ var ShellRuntimeImpl = class {
|
|
|
4594
4866
|
});
|
|
4595
4867
|
}
|
|
4596
4868
|
async setAppContext(context) {
|
|
4597
|
-
(0,
|
|
4598
|
-
F:
|
|
4869
|
+
(0, import_invariant15.invariant)(this._appRpc, "runtime not open", {
|
|
4870
|
+
F: __dxlog_file18,
|
|
4599
4871
|
L: 44,
|
|
4600
4872
|
S: this,
|
|
4601
4873
|
A: [
|
|
@@ -4624,14 +4896,13 @@ var ShellRuntimeImpl = class {
|
|
|
4624
4896
|
await this._appRpc.open();
|
|
4625
4897
|
}
|
|
4626
4898
|
async close() {
|
|
4627
|
-
|
|
4628
|
-
await ((_a = this._appRpc) == null ? void 0 : _a.close());
|
|
4899
|
+
await this._appRpc?.close();
|
|
4629
4900
|
this._appRpc = void 0;
|
|
4630
4901
|
}
|
|
4631
4902
|
};
|
|
4632
4903
|
|
|
4633
4904
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
4634
|
-
function
|
|
4905
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
4635
4906
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4636
4907
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4637
4908
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4641,7 +4912,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4641
4912
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4642
4913
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4643
4914
|
}
|
|
4644
|
-
var
|
|
4915
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts";
|
|
4645
4916
|
var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
4646
4917
|
var IFrameHostRuntime = class {
|
|
4647
4918
|
constructor({ config, origin, appPort, shellPort }) {
|
|
@@ -4661,15 +4932,14 @@ var IFrameHostRuntime = class {
|
|
|
4661
4932
|
return this._shellRuntime;
|
|
4662
4933
|
}
|
|
4663
4934
|
async start() {
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
L: 70,
|
|
4935
|
+
(0, import_log17.log)("starting...", void 0, {
|
|
4936
|
+
F: __dxlog_file19,
|
|
4937
|
+
L: 71,
|
|
4668
4938
|
S: this,
|
|
4669
4939
|
C: (f, a) => f(...a)
|
|
4670
4940
|
});
|
|
4671
4941
|
try {
|
|
4672
|
-
this._config = await (0,
|
|
4942
|
+
this._config = await (0, import_util11.getAsyncValue)(this._configProvider);
|
|
4673
4943
|
this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)({
|
|
4674
4944
|
iceServers: this._config.get("runtime.services.ice")
|
|
4675
4945
|
});
|
|
@@ -4706,59 +4976,58 @@ var IFrameHostRuntime = class {
|
|
|
4706
4976
|
...middleware
|
|
4707
4977
|
});
|
|
4708
4978
|
await Promise.all([
|
|
4709
|
-
this._clientServices.open(),
|
|
4979
|
+
this._clientServices.open(new import_context11.Context()),
|
|
4710
4980
|
this._clientRpc.open(),
|
|
4711
|
-
|
|
4981
|
+
this._shellRuntime?.open()
|
|
4712
4982
|
]);
|
|
4713
4983
|
this._ready.wake(void 0);
|
|
4714
|
-
(0,
|
|
4715
|
-
F:
|
|
4716
|
-
L:
|
|
4984
|
+
(0, import_log17.log)("started", void 0, {
|
|
4985
|
+
F: __dxlog_file19,
|
|
4986
|
+
L: 114,
|
|
4717
4987
|
S: this,
|
|
4718
4988
|
C: (f, a) => f(...a)
|
|
4719
4989
|
});
|
|
4720
4990
|
} catch (err) {
|
|
4721
4991
|
this._ready.wake(err);
|
|
4722
|
-
|
|
4723
|
-
F:
|
|
4724
|
-
L:
|
|
4992
|
+
import_log17.log.catch(err, void 0, {
|
|
4993
|
+
F: __dxlog_file19,
|
|
4994
|
+
L: 117,
|
|
4725
4995
|
S: this,
|
|
4726
4996
|
C: (f, a) => f(...a)
|
|
4727
4997
|
});
|
|
4728
4998
|
}
|
|
4729
4999
|
}
|
|
4730
5000
|
async stop() {
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
L: 121,
|
|
5001
|
+
(0, import_log17.log)("stopping...", void 0, {
|
|
5002
|
+
F: __dxlog_file19,
|
|
5003
|
+
L: 122,
|
|
4735
5004
|
S: this,
|
|
4736
5005
|
C: (f, a) => f(...a)
|
|
4737
5006
|
});
|
|
4738
5007
|
await this._clientRpc.close();
|
|
4739
5008
|
await this._clientServices.close();
|
|
4740
|
-
await
|
|
4741
|
-
(0,
|
|
4742
|
-
F:
|
|
4743
|
-
L:
|
|
5009
|
+
await this._shellRuntime?.close();
|
|
5010
|
+
(0, import_log17.log)("stopped", void 0, {
|
|
5011
|
+
F: __dxlog_file19,
|
|
5012
|
+
L: 126,
|
|
4744
5013
|
S: this,
|
|
4745
5014
|
C: (f, a) => f(...a)
|
|
4746
5015
|
});
|
|
4747
5016
|
}
|
|
4748
5017
|
};
|
|
4749
|
-
|
|
4750
|
-
|
|
5018
|
+
_ts_decorate8([
|
|
5019
|
+
import_log17.logInfo
|
|
4751
5020
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
4752
5021
|
|
|
4753
5022
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
4754
5023
|
var import_async20 = require("@dxos/async");
|
|
4755
5024
|
var import_client_protocol8 = require("@dxos/client-protocol");
|
|
4756
5025
|
var import_errors6 = require("@dxos/errors");
|
|
4757
|
-
var
|
|
5026
|
+
var import_log18 = require("@dxos/log");
|
|
4758
5027
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
4759
5028
|
var import_rpc3 = require("@dxos/rpc");
|
|
4760
|
-
var
|
|
4761
|
-
var
|
|
5029
|
+
var import_util12 = require("@dxos/util");
|
|
5030
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts";
|
|
4762
5031
|
var IFrameProxyRuntime = class {
|
|
4763
5032
|
constructor({ config, systemPort, shellPort }) {
|
|
4764
5033
|
this._id = String(Math.floor(Math.random() * 1e6));
|
|
@@ -4774,8 +5043,7 @@ var IFrameProxyRuntime = class {
|
|
|
4774
5043
|
return this._shellRuntime;
|
|
4775
5044
|
}
|
|
4776
5045
|
async open(origin) {
|
|
4777
|
-
|
|
4778
|
-
this._config = await (0, import_util10.getAsyncValue)(this._configProvider);
|
|
5046
|
+
this._config = await (0, import_util12.getAsyncValue)(this._configProvider);
|
|
4779
5047
|
this._transportService = new import_network_manager4.WebRTCTransportService({
|
|
4780
5048
|
iceServers: this._config.get("runtime.services.ice")
|
|
4781
5049
|
});
|
|
@@ -4806,20 +5074,19 @@ var IFrameProxyRuntime = class {
|
|
|
4806
5074
|
lockKey
|
|
4807
5075
|
});
|
|
4808
5076
|
} catch (err) {
|
|
4809
|
-
|
|
4810
|
-
F:
|
|
5077
|
+
import_log18.log.catch(err, void 0, {
|
|
5078
|
+
F: __dxlog_file20,
|
|
4811
5079
|
L: 85,
|
|
4812
5080
|
S: this,
|
|
4813
5081
|
C: (f, a) => f(...a)
|
|
4814
5082
|
});
|
|
4815
5083
|
throw new import_errors6.RemoteServiceConnectionError("Failed to connect to worker");
|
|
4816
5084
|
}
|
|
4817
|
-
await
|
|
5085
|
+
await this._shellRuntime?.open();
|
|
4818
5086
|
}
|
|
4819
5087
|
async close() {
|
|
4820
|
-
var _a;
|
|
4821
5088
|
this._release.wake();
|
|
4822
|
-
await
|
|
5089
|
+
await this._shellRuntime?.close();
|
|
4823
5090
|
await this._systemRpc.rpc.WorkerService.stop();
|
|
4824
5091
|
await this._systemRpc.close();
|
|
4825
5092
|
}
|
|
@@ -4830,18 +5097,19 @@ var IFrameProxyRuntime = class {
|
|
|
4830
5097
|
|
|
4831
5098
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
4832
5099
|
var import_async22 = require("@dxos/async");
|
|
4833
|
-
var
|
|
5100
|
+
var import_context12 = require("@dxos/context");
|
|
5101
|
+
var import_log20 = require("@dxos/log");
|
|
4834
5102
|
var import_messaging3 = require("@dxos/messaging");
|
|
4835
5103
|
var import_network_manager5 = require("@dxos/network-manager");
|
|
4836
5104
|
|
|
4837
5105
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
4838
5106
|
var import_async21 = require("@dxos/async");
|
|
4839
5107
|
var import_client_protocol9 = require("@dxos/client-protocol");
|
|
4840
|
-
var
|
|
4841
|
-
var
|
|
5108
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
5109
|
+
var import_log19 = require("@dxos/log");
|
|
4842
5110
|
var import_rpc4 = require("@dxos/rpc");
|
|
4843
|
-
var
|
|
4844
|
-
function
|
|
5111
|
+
var import_util13 = require("@dxos/util");
|
|
5112
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
4845
5113
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4846
5114
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4847
5115
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4851,13 +5119,13 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4851
5119
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4852
5120
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4853
5121
|
}
|
|
4854
|
-
var
|
|
5122
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-session.ts";
|
|
4855
5123
|
var WorkerSession = class {
|
|
4856
5124
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
4857
5125
|
this._startTrigger = new import_async21.Trigger();
|
|
4858
|
-
this.onClose = new
|
|
4859
|
-
(0,
|
|
4860
|
-
F:
|
|
5126
|
+
this.onClose = new import_util13.Callback();
|
|
5127
|
+
(0, import_invariant16.invariant)(serviceHost, void 0, {
|
|
5128
|
+
F: __dxlog_file21,
|
|
4861
5129
|
L: 49,
|
|
4862
5130
|
S: this,
|
|
4863
5131
|
A: [
|
|
@@ -4911,9 +5179,9 @@ var WorkerSession = class {
|
|
|
4911
5179
|
try {
|
|
4912
5180
|
await this.close();
|
|
4913
5181
|
} catch (err) {
|
|
4914
|
-
|
|
4915
|
-
F:
|
|
4916
|
-
L:
|
|
5182
|
+
import_log19.log.catch(err, void 0, {
|
|
5183
|
+
F: __dxlog_file21,
|
|
5184
|
+
L: 99,
|
|
4917
5185
|
S: this,
|
|
4918
5186
|
C: (f, a) => f(...a)
|
|
4919
5187
|
});
|
|
@@ -4928,9 +5196,9 @@ var WorkerSession = class {
|
|
|
4928
5196
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
4929
5197
|
}
|
|
4930
5198
|
async open() {
|
|
4931
|
-
|
|
4932
|
-
F:
|
|
4933
|
-
L:
|
|
5199
|
+
import_log19.log.info("opening...", void 0, {
|
|
5200
|
+
F: __dxlog_file21,
|
|
5201
|
+
L: 113,
|
|
4934
5202
|
S: this,
|
|
4935
5203
|
C: (f, a) => f(...a)
|
|
4936
5204
|
});
|
|
@@ -4945,26 +5213,26 @@ var WorkerSession = class {
|
|
|
4945
5213
|
if (this.lockKey) {
|
|
4946
5214
|
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
4947
5215
|
}
|
|
4948
|
-
|
|
4949
|
-
F:
|
|
4950
|
-
L:
|
|
5216
|
+
import_log19.log.info("opened", void 0, {
|
|
5217
|
+
F: __dxlog_file21,
|
|
5218
|
+
L: 124,
|
|
4951
5219
|
S: this,
|
|
4952
5220
|
C: (f, a) => f(...a)
|
|
4953
5221
|
});
|
|
4954
5222
|
}
|
|
4955
5223
|
async close() {
|
|
4956
|
-
|
|
4957
|
-
F:
|
|
4958
|
-
L:
|
|
5224
|
+
import_log19.log.info("closing...", void 0, {
|
|
5225
|
+
F: __dxlog_file21,
|
|
5226
|
+
L: 128,
|
|
4959
5227
|
S: this,
|
|
4960
5228
|
C: (f, a) => f(...a)
|
|
4961
5229
|
});
|
|
4962
5230
|
try {
|
|
4963
5231
|
await this.onClose.callIfSet();
|
|
4964
5232
|
} catch (err) {
|
|
4965
|
-
|
|
4966
|
-
F:
|
|
4967
|
-
L:
|
|
5233
|
+
import_log19.log.catch(err, void 0, {
|
|
5234
|
+
F: __dxlog_file21,
|
|
5235
|
+
L: 132,
|
|
4968
5236
|
S: this,
|
|
4969
5237
|
C: (f, a) => f(...a)
|
|
4970
5238
|
});
|
|
@@ -4973,9 +5241,9 @@ var WorkerSession = class {
|
|
|
4973
5241
|
this._clientRpc.close(),
|
|
4974
5242
|
this._iframeRpc.close()
|
|
4975
5243
|
]);
|
|
4976
|
-
|
|
4977
|
-
F:
|
|
4978
|
-
L:
|
|
5244
|
+
import_log19.log.info("closed", void 0, {
|
|
5245
|
+
F: __dxlog_file21,
|
|
5246
|
+
L: 136,
|
|
4979
5247
|
S: this,
|
|
4980
5248
|
C: (f, a) => f(...a)
|
|
4981
5249
|
});
|
|
@@ -4983,10 +5251,10 @@ var WorkerSession = class {
|
|
|
4983
5251
|
async _maybeOpenShell() {
|
|
4984
5252
|
try {
|
|
4985
5253
|
await (0, import_async21.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
4986
|
-
} catch
|
|
4987
|
-
|
|
4988
|
-
F:
|
|
4989
|
-
L:
|
|
5254
|
+
} catch {
|
|
5255
|
+
import_log19.log.info("No shell connected.", void 0, {
|
|
5256
|
+
F: __dxlog_file21,
|
|
5257
|
+
L: 143,
|
|
4990
5258
|
S: this,
|
|
4991
5259
|
C: (f, a) => f(...a)
|
|
4992
5260
|
});
|
|
@@ -4997,15 +5265,15 @@ var WorkerSession = class {
|
|
|
4997
5265
|
}).then(callback);
|
|
4998
5266
|
}
|
|
4999
5267
|
};
|
|
5000
|
-
|
|
5001
|
-
|
|
5268
|
+
_ts_decorate9([
|
|
5269
|
+
import_log19.logInfo
|
|
5002
5270
|
], WorkerSession.prototype, "origin", void 0);
|
|
5003
|
-
|
|
5004
|
-
|
|
5271
|
+
_ts_decorate9([
|
|
5272
|
+
import_log19.logInfo
|
|
5005
5273
|
], WorkerSession.prototype, "lockKey", void 0);
|
|
5006
5274
|
|
|
5007
5275
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
5008
|
-
var
|
|
5276
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-runtime.ts";
|
|
5009
5277
|
var WorkerRuntime = class {
|
|
5010
5278
|
// prettier-ignore
|
|
5011
5279
|
constructor(_configProvider) {
|
|
@@ -5025,9 +5293,9 @@ var WorkerRuntime = class {
|
|
|
5025
5293
|
return this._clientServices;
|
|
5026
5294
|
}
|
|
5027
5295
|
async start() {
|
|
5028
|
-
(0,
|
|
5029
|
-
F:
|
|
5030
|
-
L:
|
|
5296
|
+
(0, import_log20.log)("starting...", void 0, {
|
|
5297
|
+
F: __dxlog_file22,
|
|
5298
|
+
L: 49,
|
|
5031
5299
|
S: this,
|
|
5032
5300
|
C: (f, a) => f(...a)
|
|
5033
5301
|
});
|
|
@@ -5039,19 +5307,19 @@ var WorkerRuntime = class {
|
|
|
5039
5307
|
signalManager: signals ? new import_messaging3.WebsocketSignalManager(signals) : new import_messaging3.MemorySignalManager(new import_messaging3.MemorySignalManagerContext()),
|
|
5040
5308
|
transportFactory: this._transportFactory
|
|
5041
5309
|
});
|
|
5042
|
-
await this._clientServices.open();
|
|
5310
|
+
await this._clientServices.open(new import_context12.Context());
|
|
5043
5311
|
this._ready.wake(void 0);
|
|
5044
|
-
(0,
|
|
5045
|
-
F:
|
|
5046
|
-
L:
|
|
5312
|
+
(0, import_log20.log)("started", void 0, {
|
|
5313
|
+
F: __dxlog_file22,
|
|
5314
|
+
L: 63,
|
|
5047
5315
|
S: this,
|
|
5048
5316
|
C: (f, a) => f(...a)
|
|
5049
5317
|
});
|
|
5050
5318
|
} catch (err) {
|
|
5051
5319
|
this._ready.wake(err);
|
|
5052
|
-
|
|
5053
|
-
F:
|
|
5054
|
-
L:
|
|
5320
|
+
import_log20.log.catch("starting", err, {
|
|
5321
|
+
F: __dxlog_file22,
|
|
5322
|
+
L: 66,
|
|
5055
5323
|
S: this,
|
|
5056
5324
|
C: (f, a) => f(...a)
|
|
5057
5325
|
});
|
|
@@ -5083,9 +5351,9 @@ var WorkerRuntime = class {
|
|
|
5083
5351
|
* Selects one of the existing session fro WebRTC networking.
|
|
5084
5352
|
*/
|
|
5085
5353
|
_reconnectWebrtc() {
|
|
5086
|
-
(0,
|
|
5087
|
-
F:
|
|
5088
|
-
L:
|
|
5354
|
+
(0, import_log20.log)("reconnecting webrtc...", void 0, {
|
|
5355
|
+
F: __dxlog_file22,
|
|
5356
|
+
L: 103,
|
|
5089
5357
|
S: this,
|
|
5090
5358
|
C: (f, a) => f(...a)
|
|
5091
5359
|
});
|
|
@@ -5132,6 +5400,7 @@ var WorkerRuntime = class {
|
|
|
5132
5400
|
WorkerSession,
|
|
5133
5401
|
createAuthProvider,
|
|
5134
5402
|
createDefaultModelFactory,
|
|
5403
|
+
createDiagnostics,
|
|
5135
5404
|
createStorageObjects,
|
|
5136
5405
|
getNetworkPeers,
|
|
5137
5406
|
isLocked,
|