@dxos/client-services 0.1.56-main.738e1fa → 0.1.56-main.76a8709
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-7TROD4O2.mjs → chunk-SYAA4V6R.mjs} +464 -398
- package/dist/lib/browser/chunk-SYAA4V6R.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +21 -24
- 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 +480 -417
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +479 -424
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- 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/invitations/invitations-handler.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.map +1 -1
- 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 +3 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/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/version.d.ts +1 -1
- 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/invitations/invitations-handler.ts +2 -0
- 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 +2 -1
- package/src/packlets/services/service-context.test.ts +59 -0
- package/src/packlets/services/service-context.ts +18 -10
- package/src/packlets/services/service-host.test.ts +7 -6
- package/src/packlets/services/service-host.ts +26 -10
- package/src/packlets/services/service-registry.test.ts +2 -1
- package/src/packlets/spaces/data-space-manager.test.ts +80 -22
- package/src/packlets/spaces/data-space-manager.ts +5 -1
- package/src/packlets/spaces/data-space.ts +17 -5
- package/src/packlets/spaces/spaces-service.test.ts +2 -1
- package/src/packlets/spaces/spaces-service.ts +1 -1
- 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/version.ts +1 -1
- package/dist/lib/browser/chunk-7TROD4O2.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -75,7 +75,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
75
75
|
const feedMap = new import_util.ComplexMap(import_keys.PublicKey.hash);
|
|
76
76
|
const update = () => {
|
|
77
77
|
const { feeds } = feedStore;
|
|
78
|
-
feeds.filter((feed) => !
|
|
78
|
+
feeds.filter((feed) => !feedKeys?.length || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
|
|
79
79
|
if (!feedMap.has(feed.key)) {
|
|
80
80
|
feedMap.set(feed.key, feed);
|
|
81
81
|
feed.on("close", update);
|
|
@@ -83,15 +83,12 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
next({
|
|
86
|
-
feeds: Array.from(feedMap.values()).map((feed) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
downloaded: (_b = (_a = feed.core.bitfield) == null ? void 0 : _a.data.toBuffer()) != null ? _b : new Uint8Array()
|
|
93
|
-
};
|
|
94
|
-
})
|
|
86
|
+
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
87
|
+
feedKey: feed.key,
|
|
88
|
+
length: feed.properties.length,
|
|
89
|
+
bytes: feed.core.byteLength,
|
|
90
|
+
downloaded: feed.core.bitfield?.data.toBuffer() ?? new Uint8Array()
|
|
91
|
+
}))
|
|
95
92
|
});
|
|
96
93
|
};
|
|
97
94
|
subscriptions.add(feedStore.feedOpened.on(update));
|
|
@@ -191,13 +188,13 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf4.Stream
|
|
|
191
188
|
recipient: message.recipient.asUint8Array(),
|
|
192
189
|
payload: message.payload
|
|
193
190
|
},
|
|
194
|
-
receivedAt: new Date()
|
|
191
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
195
192
|
});
|
|
196
193
|
});
|
|
197
194
|
signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
198
195
|
next({
|
|
199
196
|
swarmEvent: swarmEvent.swarmEvent,
|
|
200
|
-
receivedAt: new Date()
|
|
197
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
201
198
|
});
|
|
202
199
|
});
|
|
203
200
|
return () => {
|
|
@@ -208,13 +205,10 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
|
|
|
208
205
|
const update = () => {
|
|
209
206
|
try {
|
|
210
207
|
const topics = networkManager.topics;
|
|
211
|
-
const labeledTopics = topics.map((topic) => {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
label: (_b = (_a = networkManager.getSwarm(topic)) == null ? void 0 : _a.label) != null ? _b : topic.toHex()
|
|
216
|
-
};
|
|
217
|
-
});
|
|
208
|
+
const labeledTopics = topics.map((topic) => ({
|
|
209
|
+
topic,
|
|
210
|
+
label: networkManager.getSwarm(topic)?.label ?? topic.toHex()
|
|
211
|
+
}));
|
|
218
212
|
next({
|
|
219
213
|
topics: labeledTopics
|
|
220
214
|
});
|
|
@@ -226,17 +220,15 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
|
|
|
226
220
|
update();
|
|
227
221
|
});
|
|
228
222
|
var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf4.Stream(({ next }) => {
|
|
229
|
-
var _a;
|
|
230
223
|
const update = () => {
|
|
231
|
-
|
|
232
|
-
const info = (_a2 = networkManager.connectionLog) == null ? void 0 : _a2.swarms;
|
|
224
|
+
const info = networkManager.connectionLog?.swarms;
|
|
233
225
|
if (info) {
|
|
234
226
|
next({
|
|
235
227
|
data: info
|
|
236
228
|
});
|
|
237
229
|
}
|
|
238
230
|
};
|
|
239
|
-
|
|
231
|
+
networkManager.connectionLog?.update.on(update);
|
|
240
232
|
update();
|
|
241
233
|
});
|
|
242
234
|
var getNetworkPeers = ({ networkManager }, request) => {
|
|
@@ -245,7 +237,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
|
|
|
245
237
|
}
|
|
246
238
|
const map = networkManager.getSwarmMap(import_keys2.PublicKey.from(request.topic));
|
|
247
239
|
return {
|
|
248
|
-
peers: map
|
|
240
|
+
peers: map?.peers.map((peer) => ({
|
|
249
241
|
...peer,
|
|
250
242
|
connections: peer.connections.map((connection) => connection.asUint8Array())
|
|
251
243
|
}))
|
|
@@ -261,14 +253,14 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
261
253
|
const spaces = [
|
|
262
254
|
...context.spaceManager.spaces.values()
|
|
263
255
|
];
|
|
264
|
-
const filteredSpaces = spaces.filter((space) => !
|
|
256
|
+
const filteredSpaces = spaces.filter((space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
|
|
265
257
|
next({
|
|
266
258
|
spaces: filteredSpaces.map((space) => {
|
|
267
259
|
const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata2) => spaceMetadata2.key.equals(space.key));
|
|
268
260
|
return {
|
|
269
261
|
key: space.key,
|
|
270
262
|
isOpen: space.isOpen,
|
|
271
|
-
timeframe: spaceMetadata
|
|
263
|
+
timeframe: spaceMetadata?.dataTimeframe,
|
|
272
264
|
genesisFeed: space.genesisFeedKey,
|
|
273
265
|
controlFeed: space.controlFeedKey,
|
|
274
266
|
dataFeed: space.dataFeedKey
|
|
@@ -282,7 +274,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
282
274
|
await update();
|
|
283
275
|
});
|
|
284
276
|
return () => {
|
|
285
|
-
unsubscribe
|
|
277
|
+
unsubscribe?.();
|
|
286
278
|
clearTimeout(timeout);
|
|
287
279
|
};
|
|
288
280
|
});
|
|
@@ -313,16 +305,15 @@ var DevtoolsServiceImpl = class {
|
|
|
313
305
|
};
|
|
314
306
|
}
|
|
315
307
|
async getStorageInfo() {
|
|
316
|
-
|
|
317
|
-
const storageUsage = (_c = await ((_b = (_a = this.params.context.storage).getDiskInfo) == null ? void 0 : _b.call(_a))) != null ? _c : {
|
|
308
|
+
const storageUsage = await this.params.context.storage.getDiskInfo?.() ?? {
|
|
318
309
|
used: 0
|
|
319
310
|
};
|
|
320
311
|
const navigatorInfo = typeof navigator === "object" ? await navigator.storage.estimate() : void 0;
|
|
321
312
|
return {
|
|
322
313
|
type: this.params.context.storage.type,
|
|
323
314
|
storageUsage: storageUsage.used,
|
|
324
|
-
originUsage:
|
|
325
|
-
usageQuota:
|
|
315
|
+
originUsage: navigatorInfo?.usage ?? 0,
|
|
316
|
+
usageQuota: navigatorInfo?.quota ?? 0
|
|
326
317
|
};
|
|
327
318
|
}
|
|
328
319
|
async getBlobs() {
|
|
@@ -508,7 +499,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
508
499
|
return await trigger.wait({
|
|
509
500
|
timeout: this._params.authTimeout
|
|
510
501
|
});
|
|
511
|
-
} catch
|
|
502
|
+
} catch {
|
|
512
503
|
return false;
|
|
513
504
|
} finally {
|
|
514
505
|
clear();
|
|
@@ -530,8 +521,19 @@ var import_feed_store2 = require("@dxos/feed-store");
|
|
|
530
521
|
var import_invariant = require("@dxos/invariant");
|
|
531
522
|
var import_log2 = require("@dxos/log");
|
|
532
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
|
+
}
|
|
533
535
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
534
|
-
var Identity = class {
|
|
536
|
+
var Identity = class Identity2 {
|
|
535
537
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
536
538
|
this.stateUpdate = new import_async5.Event();
|
|
537
539
|
this.space = space;
|
|
@@ -557,12 +559,12 @@ var Identity = class {
|
|
|
557
559
|
get authorizedDeviceKeys() {
|
|
558
560
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
559
561
|
}
|
|
560
|
-
async open() {
|
|
562
|
+
async open(ctx) {
|
|
561
563
|
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
562
564
|
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
563
|
-
await this.space.open();
|
|
565
|
+
await this.space.open(ctx);
|
|
564
566
|
}
|
|
565
|
-
async close() {
|
|
567
|
+
async close(ctx) {
|
|
566
568
|
await this.authVerifier.close();
|
|
567
569
|
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
568
570
|
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
@@ -593,11 +595,10 @@ var Identity = class {
|
|
|
593
595
|
return this._deviceStateMachine.deviceCredentialChain;
|
|
594
596
|
}
|
|
595
597
|
getAdmissionCredentials() {
|
|
596
|
-
var _a, _b;
|
|
597
598
|
return {
|
|
598
599
|
deviceKey: this.deviceKey,
|
|
599
|
-
controlFeedKey:
|
|
600
|
-
dataFeedKey:
|
|
600
|
+
controlFeedKey: this.space.controlFeedKey ?? (0, import_debug.failUndefined)(),
|
|
601
|
+
dataFeedKey: this.space.dataFeedKey ?? (0, import_debug.failUndefined)()
|
|
601
602
|
};
|
|
602
603
|
}
|
|
603
604
|
/**
|
|
@@ -607,7 +608,7 @@ var Identity = class {
|
|
|
607
608
|
getIdentityCredentialSigner() {
|
|
608
609
|
(0, import_invariant.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
609
610
|
F: __dxlog_file2,
|
|
610
|
-
L:
|
|
611
|
+
L: 139,
|
|
611
612
|
S: this,
|
|
612
613
|
A: [
|
|
613
614
|
"this._deviceStateMachine.deviceCredentialChain",
|
|
@@ -631,7 +632,7 @@ var Identity = class {
|
|
|
631
632
|
dataFeedKey
|
|
632
633
|
}, {
|
|
633
634
|
F: __dxlog_file2,
|
|
634
|
-
L:
|
|
635
|
+
L: 155,
|
|
635
636
|
S: this,
|
|
636
637
|
C: (f, a) => f(...a)
|
|
637
638
|
});
|
|
@@ -672,18 +673,40 @@ var Identity = class {
|
|
|
672
673
|
})));
|
|
673
674
|
}
|
|
674
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);
|
|
675
685
|
|
|
676
686
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
677
687
|
var import_async6 = require("@dxos/async");
|
|
688
|
+
var import_context3 = require("@dxos/context");
|
|
678
689
|
var import_credentials4 = require("@dxos/credentials");
|
|
679
690
|
var import_invariant2 = require("@dxos/invariant");
|
|
680
691
|
var import_keys4 = require("@dxos/keys");
|
|
681
692
|
var import_log3 = require("@dxos/log");
|
|
682
693
|
var import_protocols2 = require("@dxos/protocols");
|
|
683
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");
|
|
684
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
|
+
}
|
|
685
708
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
686
|
-
var IdentityManager = class {
|
|
709
|
+
var IdentityManager = class IdentityManager2 {
|
|
687
710
|
// TODO(burdon): IdentityManagerParams.
|
|
688
711
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
689
712
|
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
@@ -696,14 +719,13 @@ var IdentityManager = class {
|
|
|
696
719
|
get identity() {
|
|
697
720
|
return this._identity;
|
|
698
721
|
}
|
|
699
|
-
async open() {
|
|
700
|
-
var _a;
|
|
722
|
+
async open(ctx) {
|
|
701
723
|
const traceId = import_keys4.PublicKey.random().toHex();
|
|
702
724
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
|
|
703
725
|
id: traceId
|
|
704
726
|
}), {
|
|
705
727
|
F: __dxlog_file3,
|
|
706
|
-
L:
|
|
728
|
+
L: 73,
|
|
707
729
|
S: this,
|
|
708
730
|
C: (f, a) => f(...a)
|
|
709
731
|
});
|
|
@@ -713,20 +735,20 @@ var IdentityManager = class {
|
|
|
713
735
|
identityRecord
|
|
714
736
|
}, {
|
|
715
737
|
F: __dxlog_file3,
|
|
716
|
-
L:
|
|
738
|
+
L: 77,
|
|
717
739
|
S: this,
|
|
718
740
|
C: (f, a) => f(...a)
|
|
719
741
|
});
|
|
720
742
|
if (identityRecord) {
|
|
721
743
|
this._identity = await this._constructIdentity(identityRecord);
|
|
722
|
-
await this._identity.open();
|
|
744
|
+
await this._identity.open(ctx);
|
|
723
745
|
await this._identity.ready();
|
|
724
746
|
import_log3.log.trace("dxos.halo.identity", {
|
|
725
747
|
identityKey: identityRecord.identityKey,
|
|
726
|
-
displayName:
|
|
748
|
+
displayName: this._identity.profileDocument?.displayName
|
|
727
749
|
}, {
|
|
728
750
|
F: __dxlog_file3,
|
|
729
|
-
L:
|
|
751
|
+
L: 82,
|
|
730
752
|
S: this,
|
|
731
753
|
C: (f, a) => f(...a)
|
|
732
754
|
});
|
|
@@ -736,20 +758,18 @@ var IdentityManager = class {
|
|
|
736
758
|
id: traceId
|
|
737
759
|
}), {
|
|
738
760
|
F: __dxlog_file3,
|
|
739
|
-
L:
|
|
761
|
+
L: 88,
|
|
740
762
|
S: this,
|
|
741
763
|
C: (f, a) => f(...a)
|
|
742
764
|
});
|
|
743
765
|
}
|
|
744
766
|
async close() {
|
|
745
|
-
|
|
746
|
-
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
767
|
+
await this._identity?.close(new import_context3.Context());
|
|
747
768
|
}
|
|
748
769
|
async createIdentity({ displayName } = {}) {
|
|
749
|
-
var _a;
|
|
750
770
|
(0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
|
|
751
771
|
F: __dxlog_file3,
|
|
752
|
-
L:
|
|
772
|
+
L: 96,
|
|
753
773
|
S: this,
|
|
754
774
|
A: [
|
|
755
775
|
"!this._identity",
|
|
@@ -758,7 +778,7 @@ var IdentityManager = class {
|
|
|
758
778
|
});
|
|
759
779
|
(0, import_log3.log)("creating identity...", void 0, {
|
|
760
780
|
F: __dxlog_file3,
|
|
761
|
-
L:
|
|
781
|
+
L: 97,
|
|
762
782
|
S: this,
|
|
763
783
|
C: (f, a) => f(...a)
|
|
764
784
|
});
|
|
@@ -774,12 +794,12 @@ var IdentityManager = class {
|
|
|
774
794
|
}
|
|
775
795
|
};
|
|
776
796
|
const identity = await this._constructIdentity(identityRecord);
|
|
777
|
-
await identity.open();
|
|
797
|
+
await identity.open(new import_context3.Context());
|
|
778
798
|
{
|
|
779
799
|
const generator = new import_credentials4.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
780
800
|
(0, import_invariant2.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
781
801
|
F: __dxlog_file3,
|
|
782
|
-
L:
|
|
802
|
+
L: 116,
|
|
783
803
|
S: this,
|
|
784
804
|
A: [
|
|
785
805
|
"identityRecord.haloSpace.genesisFeedKey",
|
|
@@ -788,7 +808,7 @@ var IdentityManager = class {
|
|
|
788
808
|
});
|
|
789
809
|
(0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
790
810
|
F: __dxlog_file3,
|
|
791
|
-
L:
|
|
811
|
+
L: 117,
|
|
792
812
|
S: this,
|
|
793
813
|
A: [
|
|
794
814
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -820,10 +840,10 @@ var IdentityManager = class {
|
|
|
820
840
|
await this._identity.ready();
|
|
821
841
|
import_log3.log.trace("dxos.halo.identity", {
|
|
822
842
|
identityKey: identityRecord.identityKey,
|
|
823
|
-
displayName:
|
|
843
|
+
displayName: this._identity.profileDocument?.displayName
|
|
824
844
|
}, {
|
|
825
845
|
F: __dxlog_file3,
|
|
826
|
-
L:
|
|
846
|
+
L: 152,
|
|
827
847
|
S: this,
|
|
828
848
|
C: (f, a) => f(...a)
|
|
829
849
|
});
|
|
@@ -833,7 +853,7 @@ var IdentityManager = class {
|
|
|
833
853
|
deviceKey: identity.deviceKey
|
|
834
854
|
}, {
|
|
835
855
|
F: __dxlog_file3,
|
|
836
|
-
L:
|
|
856
|
+
L: 158,
|
|
837
857
|
S: this,
|
|
838
858
|
C: (f, a) => f(...a)
|
|
839
859
|
});
|
|
@@ -843,18 +863,17 @@ var IdentityManager = class {
|
|
|
843
863
|
* Accept an existing identity. Expects it's device key to be authorized (now or later).
|
|
844
864
|
*/
|
|
845
865
|
async acceptIdentity(params) {
|
|
846
|
-
var _a;
|
|
847
866
|
(0, import_log3.log)("accepting identity", {
|
|
848
867
|
params
|
|
849
868
|
}, {
|
|
850
869
|
F: __dxlog_file3,
|
|
851
|
-
L:
|
|
870
|
+
L: 166,
|
|
852
871
|
S: this,
|
|
853
872
|
C: (f, a) => f(...a)
|
|
854
873
|
});
|
|
855
874
|
(0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
|
|
856
875
|
F: __dxlog_file3,
|
|
857
|
-
L:
|
|
876
|
+
L: 167,
|
|
858
877
|
S: this,
|
|
859
878
|
A: [
|
|
860
879
|
"!this._identity",
|
|
@@ -873,16 +892,16 @@ var IdentityManager = class {
|
|
|
873
892
|
}
|
|
874
893
|
};
|
|
875
894
|
const identity = await this._constructIdentity(identityRecord);
|
|
876
|
-
await identity.open();
|
|
895
|
+
await identity.open(new import_context3.Context());
|
|
877
896
|
this._identity = identity;
|
|
878
897
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
879
898
|
await this._identity.ready();
|
|
880
899
|
import_log3.log.trace("dxos.halo.identity", {
|
|
881
900
|
identityKey: identityRecord.identityKey,
|
|
882
|
-
displayName:
|
|
901
|
+
displayName: this._identity.profileDocument?.displayName
|
|
883
902
|
}, {
|
|
884
903
|
F: __dxlog_file3,
|
|
885
|
-
L:
|
|
904
|
+
L: 186,
|
|
886
905
|
S: this,
|
|
887
906
|
C: (f, a) => f(...a)
|
|
888
907
|
});
|
|
@@ -892,16 +911,48 @@ var IdentityManager = class {
|
|
|
892
911
|
deviceKey: identity.deviceKey
|
|
893
912
|
}, {
|
|
894
913
|
F: __dxlog_file3,
|
|
895
|
-
L:
|
|
914
|
+
L: 192,
|
|
896
915
|
S: this,
|
|
897
916
|
C: (f, a) => f(...a)
|
|
898
917
|
});
|
|
899
918
|
return identity;
|
|
900
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
|
+
}
|
|
901
952
|
async _constructIdentity(identityRecord) {
|
|
902
953
|
(0, import_invariant2.invariant)(!this._identity, void 0, {
|
|
903
954
|
F: __dxlog_file3,
|
|
904
|
-
L:
|
|
955
|
+
L: 214,
|
|
905
956
|
S: this,
|
|
906
957
|
A: [
|
|
907
958
|
"!this._identity",
|
|
@@ -912,13 +963,13 @@ var IdentityManager = class {
|
|
|
912
963
|
identityRecord
|
|
913
964
|
}, {
|
|
914
965
|
F: __dxlog_file3,
|
|
915
|
-
L:
|
|
966
|
+
L: 215,
|
|
916
967
|
S: this,
|
|
917
968
|
C: (f, a) => f(...a)
|
|
918
969
|
});
|
|
919
970
|
(0, import_invariant2.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
920
971
|
F: __dxlog_file3,
|
|
921
|
-
L:
|
|
972
|
+
L: 218,
|
|
922
973
|
S: this,
|
|
923
974
|
A: [
|
|
924
975
|
"identityRecord.haloSpace.controlFeedKey",
|
|
@@ -930,7 +981,7 @@ var IdentityManager = class {
|
|
|
930
981
|
});
|
|
931
982
|
(0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
932
983
|
F: __dxlog_file3,
|
|
933
|
-
L:
|
|
984
|
+
L: 222,
|
|
934
985
|
S: this,
|
|
935
986
|
A: [
|
|
936
987
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -962,7 +1013,7 @@ var IdentityManager = class {
|
|
|
962
1013
|
identityKey: identityRecord.identityKey
|
|
963
1014
|
}, {
|
|
964
1015
|
F: __dxlog_file3,
|
|
965
|
-
L:
|
|
1016
|
+
L: 246,
|
|
966
1017
|
S: this,
|
|
967
1018
|
C: (f, a) => f(...a)
|
|
968
1019
|
});
|
|
@@ -983,7 +1034,7 @@ var IdentityManager = class {
|
|
|
983
1034
|
onAuthFailure: () => {
|
|
984
1035
|
import_log3.log.warn("auth failure", void 0, {
|
|
985
1036
|
F: __dxlog_file3,
|
|
986
|
-
L:
|
|
1037
|
+
L: 265,
|
|
987
1038
|
S: this,
|
|
988
1039
|
C: (f, a) => f(...a)
|
|
989
1040
|
});
|
|
@@ -992,6 +1043,12 @@ var IdentityManager = class {
|
|
|
992
1043
|
});
|
|
993
1044
|
}
|
|
994
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);
|
|
995
1052
|
|
|
996
1053
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
997
1054
|
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
@@ -1000,12 +1057,13 @@ var import_debug2 = require("@dxos/debug");
|
|
|
1000
1057
|
var import_invariant3 = require("@dxos/invariant");
|
|
1001
1058
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
1002
1059
|
var IdentityServiceImpl = class {
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
this.
|
|
1060
|
+
constructor(_createIdentity, _identityManager, _keyring) {
|
|
1061
|
+
this._createIdentity = _createIdentity;
|
|
1062
|
+
this._identityManager = _identityManager;
|
|
1063
|
+
this._keyring = _keyring;
|
|
1006
1064
|
}
|
|
1007
1065
|
async createIdentity(request) {
|
|
1008
|
-
await this.
|
|
1066
|
+
await this._createIdentity(request);
|
|
1009
1067
|
return this._getIdentity();
|
|
1010
1068
|
}
|
|
1011
1069
|
async recoverIdentity(request) {
|
|
@@ -1017,34 +1075,47 @@ var IdentityServiceImpl = class {
|
|
|
1017
1075
|
identity: this._getIdentity()
|
|
1018
1076
|
});
|
|
1019
1077
|
emitNext();
|
|
1020
|
-
return this.
|
|
1078
|
+
return this._identityManager.stateUpdate.on(emitNext);
|
|
1021
1079
|
});
|
|
1022
1080
|
}
|
|
1023
1081
|
_getIdentity() {
|
|
1024
|
-
if (!this.
|
|
1082
|
+
if (!this._identityManager.identity) {
|
|
1025
1083
|
return void 0;
|
|
1026
1084
|
}
|
|
1027
1085
|
return {
|
|
1028
|
-
identityKey: this.
|
|
1029
|
-
spaceKey: this.
|
|
1030
|
-
profile: this.
|
|
1086
|
+
identityKey: this._identityManager.identity.identityKey,
|
|
1087
|
+
spaceKey: this._identityManager.identity.space.key,
|
|
1088
|
+
profile: this._identityManager.identity.profileDocument
|
|
1031
1089
|
};
|
|
1032
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
|
+
}
|
|
1033
1104
|
async signPresentation({ presentation, nonce }) {
|
|
1034
|
-
(0, import_invariant3.invariant)(this.
|
|
1105
|
+
(0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1035
1106
|
F: __dxlog_file4,
|
|
1036
|
-
L:
|
|
1107
|
+
L: 65,
|
|
1037
1108
|
S: this,
|
|
1038
1109
|
A: [
|
|
1039
|
-
"this.
|
|
1110
|
+
"this._identityManager.identity",
|
|
1040
1111
|
"'Identity not initialized.'"
|
|
1041
1112
|
]
|
|
1042
1113
|
});
|
|
1043
1114
|
return await (0, import_credentials6.signPresentation)({
|
|
1044
1115
|
presentation,
|
|
1045
|
-
signer: this.
|
|
1046
|
-
signerKey: this.
|
|
1047
|
-
chain: this.
|
|
1116
|
+
signer: this._keyring,
|
|
1117
|
+
signerKey: this._identityManager.identity.deviceKey,
|
|
1118
|
+
chain: this._identityManager.identity.deviceCredentialChain,
|
|
1048
1119
|
nonce
|
|
1049
1120
|
});
|
|
1050
1121
|
}
|
|
@@ -1143,7 +1214,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1143
1214
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1144
1215
|
var import_async8 = require("@dxos/async");
|
|
1145
1216
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
1146
|
-
var
|
|
1217
|
+
var import_context5 = require("@dxos/context");
|
|
1147
1218
|
var import_credentials7 = require("@dxos/credentials");
|
|
1148
1219
|
var import_errors2 = require("@dxos/errors");
|
|
1149
1220
|
var import_invariant6 = require("@dxos/invariant");
|
|
@@ -1156,7 +1227,7 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
|
|
|
1156
1227
|
|
|
1157
1228
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
1158
1229
|
var import_async7 = require("@dxos/async");
|
|
1159
|
-
var
|
|
1230
|
+
var import_context4 = require("@dxos/context");
|
|
1160
1231
|
var import_errors = require("@dxos/errors");
|
|
1161
1232
|
var import_invariant5 = require("@dxos/invariant");
|
|
1162
1233
|
var import_keys5 = require("@dxos/keys");
|
|
@@ -1179,7 +1250,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1179
1250
|
}
|
|
1180
1251
|
});
|
|
1181
1252
|
this._callbacks = _callbacks;
|
|
1182
|
-
this._ctx = new
|
|
1253
|
+
this._ctx = new import_context4.Context();
|
|
1183
1254
|
this._remoteOptionsTrigger = new import_async7.Trigger();
|
|
1184
1255
|
this.invitation = void 0;
|
|
1185
1256
|
this.guestProfile = void 0;
|
|
@@ -1380,16 +1451,15 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1380
1451
|
};
|
|
1381
1452
|
}
|
|
1382
1453
|
async onOpen(context) {
|
|
1383
|
-
var _a;
|
|
1384
1454
|
await super.onOpen(context);
|
|
1385
1455
|
try {
|
|
1386
1456
|
await this.rpc.InvitationHostService.options({
|
|
1387
1457
|
role: import_invitations.Options.Role.HOST
|
|
1388
1458
|
});
|
|
1389
|
-
await (0,
|
|
1459
|
+
await (0, import_context4.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1390
1460
|
timeout: OPTIONS_TIMEOUT
|
|
1391
1461
|
}));
|
|
1392
|
-
if (
|
|
1462
|
+
if (this._remoteOptions?.role !== import_invitations.Options.Role.GUEST) {
|
|
1393
1463
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
1394
1464
|
expected: import_invitations.Options.Role.GUEST,
|
|
1395
1465
|
remoteOptions: this._remoteOptions
|
|
@@ -1415,7 +1485,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1415
1485
|
}
|
|
1416
1486
|
});
|
|
1417
1487
|
this._callbacks = _callbacks;
|
|
1418
|
-
this._ctx = new
|
|
1488
|
+
this._ctx = new import_context4.Context();
|
|
1419
1489
|
this._remoteOptionsTrigger = new import_async7.Trigger();
|
|
1420
1490
|
}
|
|
1421
1491
|
async getHandlers() {
|
|
@@ -1447,7 +1517,6 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1447
1517
|
};
|
|
1448
1518
|
}
|
|
1449
1519
|
async onOpen(context) {
|
|
1450
|
-
var _a;
|
|
1451
1520
|
await super.onOpen(context);
|
|
1452
1521
|
try {
|
|
1453
1522
|
(0, import_log4.log)("begin options", void 0, {
|
|
@@ -1456,10 +1525,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1456
1525
|
S: this,
|
|
1457
1526
|
C: (f, a) => f(...a)
|
|
1458
1527
|
});
|
|
1459
|
-
await (0,
|
|
1528
|
+
await (0, import_context4.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1460
1529
|
role: import_invitations.Options.Role.GUEST
|
|
1461
1530
|
}));
|
|
1462
|
-
await (0,
|
|
1531
|
+
await (0, import_context4.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1463
1532
|
timeout: OPTIONS_TIMEOUT
|
|
1464
1533
|
}));
|
|
1465
1534
|
(0, import_log4.log)("end options", void 0, {
|
|
@@ -1468,7 +1537,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1468
1537
|
S: this,
|
|
1469
1538
|
C: (f, a) => f(...a)
|
|
1470
1539
|
});
|
|
1471
|
-
if (
|
|
1540
|
+
if (this._remoteOptions?.role !== import_invitations.Options.Role.HOST) {
|
|
1472
1541
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
1473
1542
|
expected: import_invitations.Options.Role.HOST,
|
|
1474
1543
|
remoteOptions: this._remoteOptions
|
|
@@ -1507,9 +1576,8 @@ var InvitationsHandler = class {
|
|
|
1507
1576
|
this._networkManager = _networkManager;
|
|
1508
1577
|
}
|
|
1509
1578
|
createInvitation(protocol, options) {
|
|
1510
|
-
|
|
1511
|
-
const
|
|
1512
|
-
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);
|
|
1513
1581
|
(0, import_invariant6.invariant)(protocol, void 0, {
|
|
1514
1582
|
F: __dxlog_file7,
|
|
1515
1583
|
L: 76,
|
|
@@ -1530,7 +1598,7 @@ var InvitationsHandler = class {
|
|
|
1530
1598
|
...protocol.getInvitationContext()
|
|
1531
1599
|
};
|
|
1532
1600
|
const stream = new import_async8.PushStream();
|
|
1533
|
-
const ctx = new
|
|
1601
|
+
const ctx = new import_context5.Context({
|
|
1534
1602
|
onError: (err) => {
|
|
1535
1603
|
void ctx.dispose();
|
|
1536
1604
|
stream.error(err);
|
|
@@ -1562,9 +1630,8 @@ var InvitationsHandler = class {
|
|
|
1562
1630
|
return invitation;
|
|
1563
1631
|
},
|
|
1564
1632
|
admit: async (admissionRequest) => {
|
|
1565
|
-
var _a2, _b, _c;
|
|
1566
1633
|
try {
|
|
1567
|
-
const deviceKey =
|
|
1634
|
+
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1568
1635
|
(0, import_invariant6.invariant)(deviceKey, void 0, {
|
|
1569
1636
|
F: __dxlog_file7,
|
|
1570
1637
|
L: 119,
|
|
@@ -1709,7 +1776,8 @@ var InvitationsHandler = class {
|
|
|
1709
1776
|
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
1710
1777
|
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
1711
1778
|
}),
|
|
1712
|
-
topology: new import_network_manager.StarTopology(topic)
|
|
1779
|
+
topology: new import_network_manager.StarTopology(topic),
|
|
1780
|
+
label: "invitation host"
|
|
1713
1781
|
});
|
|
1714
1782
|
ctx.onDispose(() => swarmConnection.close());
|
|
1715
1783
|
stream.next({
|
|
@@ -1734,7 +1802,7 @@ var InvitationsHandler = class {
|
|
|
1734
1802
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1735
1803
|
(0, import_invariant6.invariant)(protocol, void 0, {
|
|
1736
1804
|
F: __dxlog_file7,
|
|
1737
|
-
L:
|
|
1805
|
+
L: 211,
|
|
1738
1806
|
S: this,
|
|
1739
1807
|
A: [
|
|
1740
1808
|
"protocol",
|
|
@@ -1748,7 +1816,7 @@ var InvitationsHandler = class {
|
|
|
1748
1816
|
const setState = (newData) => {
|
|
1749
1817
|
(0, import_invariant6.invariant)(newData.state !== void 0, void 0, {
|
|
1750
1818
|
F: __dxlog_file7,
|
|
1751
|
-
L:
|
|
1819
|
+
L: 222,
|
|
1752
1820
|
S: this,
|
|
1753
1821
|
A: [
|
|
1754
1822
|
"newData.state !== undefined",
|
|
@@ -1761,14 +1829,14 @@ var InvitationsHandler = class {
|
|
|
1761
1829
|
...newData
|
|
1762
1830
|
});
|
|
1763
1831
|
};
|
|
1764
|
-
const ctx = new
|
|
1832
|
+
const ctx = new import_context5.Context({
|
|
1765
1833
|
onError: (err) => {
|
|
1766
1834
|
if (err instanceof import_async8.TimeoutError) {
|
|
1767
1835
|
(0, import_log5.log)("timeout", {
|
|
1768
1836
|
...protocol.toJSON()
|
|
1769
1837
|
}, {
|
|
1770
1838
|
F: __dxlog_file7,
|
|
1771
|
-
L:
|
|
1839
|
+
L: 230,
|
|
1772
1840
|
S: this,
|
|
1773
1841
|
C: (f, a) => f(...a)
|
|
1774
1842
|
});
|
|
@@ -1778,7 +1846,7 @@ var InvitationsHandler = class {
|
|
|
1778
1846
|
} else {
|
|
1779
1847
|
import_log5.log.warn("auth failed", err, {
|
|
1780
1848
|
F: __dxlog_file7,
|
|
1781
|
-
L:
|
|
1849
|
+
L: 233,
|
|
1782
1850
|
S: this,
|
|
1783
1851
|
C: (f, a) => f(...a)
|
|
1784
1852
|
});
|
|
@@ -1792,7 +1860,7 @@ var InvitationsHandler = class {
|
|
|
1792
1860
|
...protocol.toJSON()
|
|
1793
1861
|
}, {
|
|
1794
1862
|
F: __dxlog_file7,
|
|
1795
|
-
L:
|
|
1863
|
+
L: 241,
|
|
1796
1864
|
S: this,
|
|
1797
1865
|
C: (f, a) => f(...a)
|
|
1798
1866
|
});
|
|
@@ -1807,7 +1875,7 @@ var InvitationsHandler = class {
|
|
|
1807
1875
|
currentState
|
|
1808
1876
|
}, {
|
|
1809
1877
|
F: __dxlog_file7,
|
|
1810
|
-
L:
|
|
1878
|
+
L: 251,
|
|
1811
1879
|
S: this,
|
|
1812
1880
|
C: (f, a) => f(...a)
|
|
1813
1881
|
});
|
|
@@ -1822,7 +1890,7 @@ var InvitationsHandler = class {
|
|
|
1822
1890
|
id: traceId
|
|
1823
1891
|
}), {
|
|
1824
1892
|
F: __dxlog_file7,
|
|
1825
|
-
L:
|
|
1893
|
+
L: 260,
|
|
1826
1894
|
S: this,
|
|
1827
1895
|
C: (f, a) => f(...a)
|
|
1828
1896
|
});
|
|
@@ -1834,7 +1902,7 @@ var InvitationsHandler = class {
|
|
|
1834
1902
|
...protocol.toJSON()
|
|
1835
1903
|
}, {
|
|
1836
1904
|
F: __dxlog_file7,
|
|
1837
|
-
L:
|
|
1905
|
+
L: 268,
|
|
1838
1906
|
S: this,
|
|
1839
1907
|
C: (f, a) => f(...a)
|
|
1840
1908
|
});
|
|
@@ -1845,7 +1913,7 @@ var InvitationsHandler = class {
|
|
|
1845
1913
|
...protocol.toJSON()
|
|
1846
1914
|
}, {
|
|
1847
1915
|
F: __dxlog_file7,
|
|
1848
|
-
L:
|
|
1916
|
+
L: 272,
|
|
1849
1917
|
S: this,
|
|
1850
1918
|
C: (f, a) => f(...a)
|
|
1851
1919
|
});
|
|
@@ -1855,7 +1923,7 @@ var InvitationsHandler = class {
|
|
|
1855
1923
|
response: introductionResponse
|
|
1856
1924
|
}, {
|
|
1857
1925
|
F: __dxlog_file7,
|
|
1858
|
-
L:
|
|
1926
|
+
L: 276,
|
|
1859
1927
|
S: this,
|
|
1860
1928
|
C: (f, a) => f(...a)
|
|
1861
1929
|
});
|
|
@@ -1867,7 +1935,7 @@ var InvitationsHandler = class {
|
|
|
1867
1935
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1868
1936
|
(0, import_log5.log)("guest waiting for authentication code...", void 0, {
|
|
1869
1937
|
F: __dxlog_file7,
|
|
1870
|
-
L:
|
|
1938
|
+
L: 285,
|
|
1871
1939
|
S: this,
|
|
1872
1940
|
C: (f, a) => f(...a)
|
|
1873
1941
|
});
|
|
@@ -1879,7 +1947,7 @@ var InvitationsHandler = class {
|
|
|
1879
1947
|
});
|
|
1880
1948
|
(0, import_log5.log)("sending authentication request", void 0, {
|
|
1881
1949
|
F: __dxlog_file7,
|
|
1882
|
-
L:
|
|
1950
|
+
L: 289,
|
|
1883
1951
|
S: this,
|
|
1884
1952
|
C: (f, a) => f(...a)
|
|
1885
1953
|
});
|
|
@@ -1900,7 +1968,7 @@ var InvitationsHandler = class {
|
|
|
1900
1968
|
attempt
|
|
1901
1969
|
}, {
|
|
1902
1970
|
F: __dxlog_file7,
|
|
1903
|
-
L:
|
|
1971
|
+
L: 300,
|
|
1904
1972
|
S: this,
|
|
1905
1973
|
C: (f, a) => f(...a)
|
|
1906
1974
|
});
|
|
@@ -1917,7 +1985,7 @@ var InvitationsHandler = class {
|
|
|
1917
1985
|
...protocol.toJSON()
|
|
1918
1986
|
}, {
|
|
1919
1987
|
F: __dxlog_file7,
|
|
1920
|
-
L:
|
|
1988
|
+
L: 311,
|
|
1921
1989
|
S: this,
|
|
1922
1990
|
C: (f, a) => f(...a)
|
|
1923
1991
|
});
|
|
@@ -1929,7 +1997,7 @@ var InvitationsHandler = class {
|
|
|
1929
1997
|
...protocol.toJSON()
|
|
1930
1998
|
}, {
|
|
1931
1999
|
F: __dxlog_file7,
|
|
1932
|
-
L:
|
|
2000
|
+
L: 322,
|
|
1933
2001
|
S: this,
|
|
1934
2002
|
C: (f, a) => f(...a)
|
|
1935
2003
|
});
|
|
@@ -1941,7 +2009,7 @@ var InvitationsHandler = class {
|
|
|
1941
2009
|
id: traceId
|
|
1942
2010
|
}), {
|
|
1943
2011
|
F: __dxlog_file7,
|
|
1944
|
-
L:
|
|
2012
|
+
L: 324,
|
|
1945
2013
|
S: this,
|
|
1946
2014
|
C: (f, a) => f(...a)
|
|
1947
2015
|
});
|
|
@@ -1951,7 +2019,7 @@ var InvitationsHandler = class {
|
|
|
1951
2019
|
...protocol.toJSON()
|
|
1952
2020
|
}, {
|
|
1953
2021
|
F: __dxlog_file7,
|
|
1954
|
-
L:
|
|
2022
|
+
L: 327,
|
|
1955
2023
|
S: this,
|
|
1956
2024
|
C: (f, a) => f(...a)
|
|
1957
2025
|
});
|
|
@@ -1961,7 +2029,7 @@ var InvitationsHandler = class {
|
|
|
1961
2029
|
} else {
|
|
1962
2030
|
(0, import_log5.log)("auth failed", err, {
|
|
1963
2031
|
F: __dxlog_file7,
|
|
1964
|
-
L:
|
|
2032
|
+
L: 330,
|
|
1965
2033
|
S: this,
|
|
1966
2034
|
C: (f, a) => f(...a)
|
|
1967
2035
|
});
|
|
@@ -1972,7 +2040,7 @@ var InvitationsHandler = class {
|
|
|
1972
2040
|
error: err
|
|
1973
2041
|
}), {
|
|
1974
2042
|
F: __dxlog_file7,
|
|
1975
|
-
L:
|
|
2043
|
+
L: 333,
|
|
1976
2044
|
S: this,
|
|
1977
2045
|
C: (f, a) => f(...a)
|
|
1978
2046
|
});
|
|
@@ -1990,7 +2058,7 @@ var InvitationsHandler = class {
|
|
|
1990
2058
|
...protocol.toJSON()
|
|
1991
2059
|
}, {
|
|
1992
2060
|
F: __dxlog_file7,
|
|
1993
|
-
L:
|
|
2061
|
+
L: 344,
|
|
1994
2062
|
S: this,
|
|
1995
2063
|
C: (f, a) => f(...a)
|
|
1996
2064
|
});
|
|
@@ -2000,7 +2068,7 @@ var InvitationsHandler = class {
|
|
|
2000
2068
|
} else {
|
|
2001
2069
|
(0, import_log5.log)("auth failed", err, {
|
|
2002
2070
|
F: __dxlog_file7,
|
|
2003
|
-
L:
|
|
2071
|
+
L: 347,
|
|
2004
2072
|
S: this,
|
|
2005
2073
|
C: (f, a) => f(...a)
|
|
2006
2074
|
});
|
|
@@ -2013,7 +2081,7 @@ var InvitationsHandler = class {
|
|
|
2013
2081
|
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
2014
2082
|
(0, import_invariant6.invariant)(invitation.swarmKey, void 0, {
|
|
2015
2083
|
F: __dxlog_file7,
|
|
2016
|
-
L:
|
|
2084
|
+
L: 357,
|
|
2017
2085
|
S: this,
|
|
2018
2086
|
A: [
|
|
2019
2087
|
"invitation.swarmKey",
|
|
@@ -2027,7 +2095,8 @@ var InvitationsHandler = class {
|
|
|
2027
2095
|
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
2028
2096
|
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
2029
2097
|
}),
|
|
2030
|
-
topology: new import_network_manager.StarTopology(topic)
|
|
2098
|
+
topology: new import_network_manager.StarTopology(topic),
|
|
2099
|
+
label: "invitation guest"
|
|
2031
2100
|
});
|
|
2032
2101
|
ctx.onDispose(() => swarmConnection.close());
|
|
2033
2102
|
setState({
|
|
@@ -2263,7 +2332,6 @@ var SpaceInvitationProtocol = class {
|
|
|
2263
2332
|
};
|
|
2264
2333
|
}
|
|
2265
2334
|
async admit(request, guestProfile) {
|
|
2266
|
-
var _a;
|
|
2267
2335
|
(0, import_invariant8.invariant)(this._spaceKey, void 0, {
|
|
2268
2336
|
F: __dxlog_file9,
|
|
2269
2337
|
L: 42,
|
|
@@ -2327,7 +2395,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2327
2395
|
space: {
|
|
2328
2396
|
credential: spaceMemberCredential,
|
|
2329
2397
|
controlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2330
|
-
dataTimeframe:
|
|
2398
|
+
dataTimeframe: space.dataPipeline.pipelineState?.timeframe
|
|
2331
2399
|
}
|
|
2332
2400
|
};
|
|
2333
2401
|
}
|
|
@@ -2431,9 +2499,8 @@ var ClientRpcServer = class {
|
|
|
2431
2499
|
await this._rpcPeer.close();
|
|
2432
2500
|
}
|
|
2433
2501
|
_getServiceHandler(serviceName) {
|
|
2434
|
-
var _a;
|
|
2435
2502
|
if (!this._handlerCache.has(serviceName)) {
|
|
2436
|
-
const [key, descriptor] =
|
|
2503
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug3.raise)(new Error(`Service not available: ${serviceName}`));
|
|
2437
2504
|
const service = this._serviceRegistry.services[key];
|
|
2438
2505
|
if (!service) {
|
|
2439
2506
|
throw new Error(`Service not available: ${serviceName}`);
|
|
@@ -2448,13 +2515,14 @@ var ClientRpcServer = class {
|
|
|
2448
2515
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2449
2516
|
var import_credentials9 = require("@dxos/credentials");
|
|
2450
2517
|
var import_document_model = require("@dxos/document-model");
|
|
2518
|
+
var import_echo_db = require("@dxos/echo-db");
|
|
2451
2519
|
var import_invariant9 = require("@dxos/invariant");
|
|
2452
2520
|
var import_log8 = require("@dxos/log");
|
|
2453
2521
|
var import_protocols5 = require("@dxos/protocols");
|
|
2454
2522
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2455
2523
|
|
|
2456
2524
|
// packages/sdk/client-services/src/version.ts
|
|
2457
|
-
var DXOS_VERSION = "0.1.56-main.
|
|
2525
|
+
var DXOS_VERSION = "0.1.56-main.76a8709";
|
|
2458
2526
|
|
|
2459
2527
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
2460
2528
|
var getPlatform = () => {
|
|
@@ -2488,9 +2556,8 @@ var getPlatform = () => {
|
|
|
2488
2556
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2489
2557
|
var DEFAULT_TIMEOUT = 1e3;
|
|
2490
2558
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2491
|
-
var _a, _b, _c;
|
|
2492
2559
|
const diagnostics = {
|
|
2493
|
-
created: new Date().toISOString(),
|
|
2560
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2494
2561
|
platform: getPlatform(),
|
|
2495
2562
|
client: {
|
|
2496
2563
|
version: DXOS_VERSION,
|
|
@@ -2502,7 +2569,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2502
2569
|
{
|
|
2503
2570
|
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2504
2571
|
F: __dxlog_file10,
|
|
2505
|
-
L:
|
|
2572
|
+
L: 88,
|
|
2506
2573
|
S: void 0,
|
|
2507
2574
|
A: [
|
|
2508
2575
|
"clientServices.LoggingService",
|
|
@@ -2520,16 +2587,16 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2520
2587
|
spaceKey: identity.space.key,
|
|
2521
2588
|
profile: identity.profileDocument
|
|
2522
2589
|
};
|
|
2523
|
-
const { devices } =
|
|
2590
|
+
const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
2524
2591
|
timeout: DEFAULT_TIMEOUT
|
|
2525
|
-
}).catch(() => void 0)
|
|
2592
|
+
}).catch(() => void 0) ?? {};
|
|
2526
2593
|
diagnostics.devices = devices;
|
|
2527
2594
|
if (serviceContext.dataSpaceManager) {
|
|
2528
|
-
diagnostics.spaces = await Promise.all(
|
|
2595
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2529
2596
|
}
|
|
2530
|
-
const { feeds = [] } =
|
|
2597
|
+
const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2531
2598
|
timeout: DEFAULT_TIMEOUT
|
|
2532
|
-
}).catch(() => void 0)
|
|
2599
|
+
}).catch(() => void 0) ?? {};
|
|
2533
2600
|
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2534
2601
|
feedKey,
|
|
2535
2602
|
bytes,
|
|
@@ -2542,16 +2609,13 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2542
2609
|
var getProperties = (space) => {
|
|
2543
2610
|
let properties = {};
|
|
2544
2611
|
try {
|
|
2545
|
-
const propertiesItem = space.dataPipeline.itemManager.items.find((item) =>
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
});
|
|
2549
|
-
const state = propertiesItem == null ? void 0 : propertiesItem.state;
|
|
2550
|
-
properties = state == null ? void 0 : state.data;
|
|
2612
|
+
const propertiesItem = space.dataPipeline.itemManager.items.find((item) => item.modelMeta?.type === import_document_model.DocumentModel.meta.type && item.state?.type === import_echo_db.TYPE_PROPERTIES);
|
|
2613
|
+
const state = propertiesItem?.state;
|
|
2614
|
+
properties = state?.data;
|
|
2551
2615
|
} catch (err) {
|
|
2552
2616
|
import_log8.log.warn(err.message, void 0, {
|
|
2553
2617
|
F: __dxlog_file10,
|
|
2554
|
-
L:
|
|
2618
|
+
L: 145,
|
|
2555
2619
|
S: void 0,
|
|
2556
2620
|
C: (f, a) => f(...a)
|
|
2557
2621
|
});
|
|
@@ -2559,7 +2623,6 @@ var getProperties = (space) => {
|
|
|
2559
2623
|
return properties;
|
|
2560
2624
|
};
|
|
2561
2625
|
var getSpaceStats = async (space) => {
|
|
2562
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2563
2626
|
const stats = {
|
|
2564
2627
|
key: space.key,
|
|
2565
2628
|
metrics: space.metrics,
|
|
@@ -2567,18 +2630,15 @@ var getSpaceStats = async (space) => {
|
|
|
2567
2630
|
...credential.subject.assertion,
|
|
2568
2631
|
id: credential.id
|
|
2569
2632
|
})),
|
|
2570
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services6.SpaceMember.PresenceState.ONLINE : import_services6.SpaceMember.PresenceState.OFFLINE
|
|
2580
|
-
};
|
|
2581
|
-
}),
|
|
2633
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2634
|
+
identity: {
|
|
2635
|
+
identityKey: member.key,
|
|
2636
|
+
profile: {
|
|
2637
|
+
displayName: member.assertion.profile?.displayName
|
|
2638
|
+
}
|
|
2639
|
+
},
|
|
2640
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services6.SpaceMember.PresenceState.ONLINE : import_services6.SpaceMember.PresenceState.OFFLINE
|
|
2641
|
+
})),
|
|
2582
2642
|
pipeline: {
|
|
2583
2643
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
2584
2644
|
// currentEpoch: space.dataPipeline.currentEpoch,
|
|
@@ -2588,11 +2648,11 @@ var getSpaceStats = async (space) => {
|
|
|
2588
2648
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2589
2649
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
2590
2650
|
// TODO(burdon): Empty?
|
|
2591
|
-
dataFeeds:
|
|
2592
|
-
startDataTimeframe:
|
|
2593
|
-
currentDataTimeframe:
|
|
2594
|
-
targetDataTimeframe:
|
|
2595
|
-
totalDataTimeframe:
|
|
2651
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
2652
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
2653
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
2654
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
2655
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
2596
2656
|
}
|
|
2597
2657
|
};
|
|
2598
2658
|
if (space.dataPipeline.itemManager) {
|
|
@@ -2612,6 +2672,7 @@ var getSpaceStats = async (space) => {
|
|
|
2612
2672
|
|
|
2613
2673
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2614
2674
|
var import_async14 = require("@dxos/async");
|
|
2675
|
+
var import_context9 = require("@dxos/context");
|
|
2615
2676
|
var import_credentials14 = require("@dxos/credentials");
|
|
2616
2677
|
var import_debug7 = require("@dxos/debug");
|
|
2617
2678
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
@@ -2623,10 +2684,12 @@ var import_log13 = require("@dxos/log");
|
|
|
2623
2684
|
var import_protocols9 = require("@dxos/protocols");
|
|
2624
2685
|
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2625
2686
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
2687
|
+
var import_tracing3 = require("@dxos/tracing");
|
|
2688
|
+
var import_util7 = require("@dxos/util");
|
|
2626
2689
|
|
|
2627
2690
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2628
2691
|
var import_async12 = require("@dxos/async");
|
|
2629
|
-
var
|
|
2692
|
+
var import_context8 = require("@dxos/context");
|
|
2630
2693
|
var import_credentials13 = require("@dxos/credentials");
|
|
2631
2694
|
var import_invariant11 = require("@dxos/invariant");
|
|
2632
2695
|
var import_keys9 = require("@dxos/keys");
|
|
@@ -2639,7 +2702,7 @@ var import_util5 = require("@dxos/util");
|
|
|
2639
2702
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2640
2703
|
var import_async11 = require("@dxos/async");
|
|
2641
2704
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
2642
|
-
var
|
|
2705
|
+
var import_context7 = require("@dxos/context");
|
|
2643
2706
|
var import_debug4 = require("@dxos/debug");
|
|
2644
2707
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
2645
2708
|
var import_errors3 = require("@dxos/errors");
|
|
@@ -2647,12 +2710,12 @@ var import_keys8 = require("@dxos/keys");
|
|
|
2647
2710
|
var import_log10 = require("@dxos/log");
|
|
2648
2711
|
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2649
2712
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2650
|
-
var
|
|
2713
|
+
var import_timeframe2 = require("@dxos/timeframe");
|
|
2651
2714
|
var import_util4 = require("@dxos/util");
|
|
2652
2715
|
|
|
2653
2716
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2654
2717
|
var import_async10 = require("@dxos/async");
|
|
2655
|
-
var
|
|
2718
|
+
var import_context6 = require("@dxos/context");
|
|
2656
2719
|
var import_invariant10 = require("@dxos/invariant");
|
|
2657
2720
|
var import_keys7 = require("@dxos/keys");
|
|
2658
2721
|
var import_log9 = require("@dxos/log");
|
|
@@ -2666,7 +2729,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2666
2729
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2667
2730
|
var NotarizationPlugin = class {
|
|
2668
2731
|
constructor() {
|
|
2669
|
-
this._ctx = new
|
|
2732
|
+
this._ctx = new import_context6.Context();
|
|
2670
2733
|
this._extensionOpened = new import_async10.Event();
|
|
2671
2734
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2672
2735
|
this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
|
|
@@ -2716,7 +2779,7 @@ var NotarizationPlugin = class {
|
|
|
2716
2779
|
errors.throw(err);
|
|
2717
2780
|
}
|
|
2718
2781
|
});
|
|
2719
|
-
opCtx
|
|
2782
|
+
opCtx?.onDispose(() => ctx.dispose());
|
|
2720
2783
|
if (timeout !== 0) {
|
|
2721
2784
|
(0, import_async10.scheduleTask)(ctx, () => {
|
|
2722
2785
|
import_log9.log.warn("Notarization timeout", {
|
|
@@ -2791,7 +2854,7 @@ var NotarizationPlugin = class {
|
|
|
2791
2854
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
2792
2855
|
try {
|
|
2793
2856
|
await Promise.race([
|
|
2794
|
-
(0,
|
|
2857
|
+
(0, import_context6.rejectOnDispose)(ctx),
|
|
2795
2858
|
allNotarized,
|
|
2796
2859
|
errors.wait()
|
|
2797
2860
|
]);
|
|
@@ -2809,11 +2872,10 @@ var NotarizationPlugin = class {
|
|
|
2809
2872
|
* Called with credentials arriving from the control pipeline.
|
|
2810
2873
|
*/
|
|
2811
2874
|
async processCredential(credential) {
|
|
2812
|
-
var _a;
|
|
2813
2875
|
if (!credential.id) {
|
|
2814
2876
|
return;
|
|
2815
2877
|
}
|
|
2816
|
-
|
|
2878
|
+
this._processCredentialsTriggers.get(credential.id)?.wake();
|
|
2817
2879
|
this._processedCredentials.add(credential.id);
|
|
2818
2880
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2819
2881
|
}
|
|
@@ -2839,11 +2901,10 @@ var NotarizationPlugin = class {
|
|
|
2839
2901
|
* Requests from other peers to notarize credentials.
|
|
2840
2902
|
*/
|
|
2841
2903
|
async _onNotarize(request) {
|
|
2842
|
-
var _a;
|
|
2843
2904
|
if (!this._writer) {
|
|
2844
2905
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2845
2906
|
}
|
|
2846
|
-
for (const credential of
|
|
2907
|
+
for (const credential of request.credentials ?? []) {
|
|
2847
2908
|
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
2848
2909
|
F: __dxlog_file11,
|
|
2849
2910
|
L: 200,
|
|
@@ -2921,7 +2982,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2921
2982
|
};
|
|
2922
2983
|
|
|
2923
2984
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2924
|
-
function
|
|
2985
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
2925
2986
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2926
2987
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2927
2988
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2932,9 +2993,10 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
2932
2993
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2933
2994
|
}
|
|
2934
2995
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2996
|
+
var ENABLE_FEED_PURGE = false;
|
|
2935
2997
|
var DataSpace = class DataSpace2 {
|
|
2936
2998
|
constructor(params) {
|
|
2937
|
-
this._ctx = new
|
|
2999
|
+
this._ctx = new import_context7.Context();
|
|
2938
3000
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2939
3001
|
this._state = import_services7.SpaceState.CLOSED;
|
|
2940
3002
|
/**
|
|
@@ -2943,7 +3005,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2943
3005
|
this.error = void 0;
|
|
2944
3006
|
this.stateUpdate = new import_async11.Event();
|
|
2945
3007
|
this.metrics = {};
|
|
2946
|
-
var _a;
|
|
2947
3008
|
this._inner = params.inner;
|
|
2948
3009
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
2949
3010
|
this._gossip = params.gossip;
|
|
@@ -2952,7 +3013,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2952
3013
|
this._feedStore = params.feedStore;
|
|
2953
3014
|
this._metadataStore = params.metadataStore;
|
|
2954
3015
|
this._signingContext = params.signingContext;
|
|
2955
|
-
this._callbacks =
|
|
3016
|
+
this._callbacks = params.callbacks ?? {};
|
|
2956
3017
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2957
3018
|
trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2958
3019
|
update: this._inner.stateUpdate,
|
|
@@ -2992,21 +3053,20 @@ var DataSpace = class DataSpace2 {
|
|
|
2992
3053
|
async _open() {
|
|
2993
3054
|
await this._notarizationPlugin.open();
|
|
2994
3055
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2995
|
-
await this._inner.open();
|
|
3056
|
+
await this._inner.open(new import_context7.Context());
|
|
2996
3057
|
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
2997
3058
|
this.stateUpdate.emit();
|
|
2998
3059
|
this.metrics = {};
|
|
2999
|
-
this.metrics.open = new Date();
|
|
3060
|
+
this.metrics.open = /* @__PURE__ */ new Date();
|
|
3000
3061
|
}
|
|
3001
3062
|
async close() {
|
|
3002
3063
|
await this._close();
|
|
3003
3064
|
}
|
|
3004
3065
|
async _close() {
|
|
3005
|
-
|
|
3006
|
-
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
3066
|
+
await this._callbacks.beforeClose?.();
|
|
3007
3067
|
this._state = import_services7.SpaceState.CLOSED;
|
|
3008
3068
|
await this._ctx.dispose();
|
|
3009
|
-
this._ctx = new
|
|
3069
|
+
this._ctx = new import_context7.Context();
|
|
3010
3070
|
await this.authVerifier.close();
|
|
3011
3071
|
await this._inner.close();
|
|
3012
3072
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
@@ -3025,13 +3085,13 @@ var DataSpace = class DataSpace2 {
|
|
|
3025
3085
|
initializeDataPipelineAsync() {
|
|
3026
3086
|
(0, import_async11.scheduleTask)(this._ctx, async () => {
|
|
3027
3087
|
try {
|
|
3028
|
-
this.metrics.pipelineInitBegin = new Date();
|
|
3088
|
+
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3029
3089
|
await this.initializeDataPipeline();
|
|
3030
3090
|
} catch (err) {
|
|
3031
3091
|
if (err instanceof import_errors3.CancelledError) {
|
|
3032
3092
|
(0, import_log10.log)("data pipeline initialization cancelled", err, {
|
|
3033
3093
|
F: __dxlog_file12,
|
|
3034
|
-
L:
|
|
3094
|
+
L: 199,
|
|
3035
3095
|
S: this,
|
|
3036
3096
|
C: (f, a) => f(...a)
|
|
3037
3097
|
});
|
|
@@ -3039,7 +3099,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3039
3099
|
}
|
|
3040
3100
|
import_log10.log.error("Error initializing data pipeline", err, {
|
|
3041
3101
|
F: __dxlog_file12,
|
|
3042
|
-
L:
|
|
3102
|
+
L: 203,
|
|
3043
3103
|
S: this,
|
|
3044
3104
|
C: (f, a) => f(...a)
|
|
3045
3105
|
});
|
|
@@ -3047,12 +3107,11 @@ var DataSpace = class DataSpace2 {
|
|
|
3047
3107
|
this.error = err;
|
|
3048
3108
|
this.stateUpdate.emit();
|
|
3049
3109
|
} finally {
|
|
3050
|
-
this.metrics.ready = new Date();
|
|
3110
|
+
this.metrics.ready = /* @__PURE__ */ new Date();
|
|
3051
3111
|
}
|
|
3052
3112
|
});
|
|
3053
3113
|
}
|
|
3054
3114
|
async initializeDataPipeline() {
|
|
3055
|
-
var _a, _b, _c, _d;
|
|
3056
3115
|
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
3057
3116
|
throw new import_errors3.SystemError("Invalid operation");
|
|
3058
3117
|
}
|
|
@@ -3061,11 +3120,11 @@ var DataSpace = class DataSpace2 {
|
|
|
3061
3120
|
ctx: this._ctx,
|
|
3062
3121
|
breakOnStall: false
|
|
3063
3122
|
});
|
|
3064
|
-
this.metrics.controlPipelineReady = new Date();
|
|
3123
|
+
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3065
3124
|
await this._createWritableFeeds();
|
|
3066
3125
|
(0, import_log10.log)("writable feeds created", void 0, {
|
|
3067
3126
|
F: __dxlog_file12,
|
|
3068
|
-
L:
|
|
3127
|
+
L: 227,
|
|
3069
3128
|
S: this,
|
|
3070
3129
|
C: (f, a) => f(...a)
|
|
3071
3130
|
});
|
|
@@ -3078,11 +3137,11 @@ var DataSpace = class DataSpace2 {
|
|
|
3078
3137
|
}), this._inner.controlPipeline.writer));
|
|
3079
3138
|
}
|
|
3080
3139
|
await this._inner.initializeDataPipeline();
|
|
3081
|
-
this.metrics.dataPipelineOpen = new Date();
|
|
3082
|
-
await (0,
|
|
3140
|
+
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
3141
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3083
3142
|
(0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3084
3143
|
F: __dxlog_file12,
|
|
3085
|
-
L:
|
|
3144
|
+
L: 248,
|
|
3086
3145
|
S: this,
|
|
3087
3146
|
C: (f, a) => f(...a)
|
|
3088
3147
|
});
|
|
@@ -3090,17 +3149,17 @@ var DataSpace = class DataSpace2 {
|
|
|
3090
3149
|
ctx: this._ctx,
|
|
3091
3150
|
breakOnStall: false
|
|
3092
3151
|
});
|
|
3093
|
-
this.metrics.dataPipelineReady = new Date();
|
|
3152
|
+
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3094
3153
|
(0, import_log10.log)("data pipeline ready", void 0, {
|
|
3095
3154
|
F: __dxlog_file12,
|
|
3096
|
-
L:
|
|
3155
|
+
L: 257,
|
|
3097
3156
|
S: this,
|
|
3098
3157
|
C: (f, a) => f(...a)
|
|
3099
3158
|
});
|
|
3100
|
-
await
|
|
3159
|
+
await this._callbacks.beforeReady?.();
|
|
3101
3160
|
this._state = import_services7.SpaceState.READY;
|
|
3102
3161
|
this.stateUpdate.emit();
|
|
3103
|
-
await
|
|
3162
|
+
await this._callbacks.afterReady?.();
|
|
3104
3163
|
}
|
|
3105
3164
|
async _createWritableFeeds() {
|
|
3106
3165
|
const credentials = [];
|
|
@@ -3147,7 +3206,6 @@ var DataSpace = class DataSpace2 {
|
|
|
3147
3206
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
3148
3207
|
}
|
|
3149
3208
|
async createEpoch() {
|
|
3150
|
-
var _a, _b;
|
|
3151
3209
|
const epoch = await this.dataPipeline.createEpoch();
|
|
3152
3210
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
3153
3211
|
credential: {
|
|
@@ -3160,16 +3218,19 @@ var DataSpace = class DataSpace2 {
|
|
|
3160
3218
|
})
|
|
3161
3219
|
}
|
|
3162
3220
|
});
|
|
3163
|
-
await this.inner.controlPipeline.state.waitUntilTimeframe(new
|
|
3221
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
|
|
3164
3222
|
[
|
|
3165
3223
|
receipt.feedKey,
|
|
3166
3224
|
receipt.seq
|
|
3167
3225
|
]
|
|
3168
3226
|
]));
|
|
3169
|
-
|
|
3170
|
-
const
|
|
3171
|
-
|
|
3172
|
-
|
|
3227
|
+
if (ENABLE_FEED_PURGE) {
|
|
3228
|
+
for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
|
|
3229
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
3230
|
+
if (indexBeforeEpoch === void 0) {
|
|
3231
|
+
continue;
|
|
3232
|
+
}
|
|
3233
|
+
await feed.safeClear(0, indexBeforeEpoch + 1);
|
|
3173
3234
|
}
|
|
3174
3235
|
}
|
|
3175
3236
|
}
|
|
@@ -3191,22 +3252,22 @@ var DataSpace = class DataSpace2 {
|
|
|
3191
3252
|
this.stateUpdate.emit();
|
|
3192
3253
|
}
|
|
3193
3254
|
};
|
|
3194
|
-
|
|
3255
|
+
_ts_decorate3([
|
|
3195
3256
|
import_async11.synchronized
|
|
3196
3257
|
], DataSpace.prototype, "open", null);
|
|
3197
|
-
|
|
3258
|
+
_ts_decorate3([
|
|
3198
3259
|
import_async11.synchronized
|
|
3199
3260
|
], DataSpace.prototype, "close", null);
|
|
3200
|
-
|
|
3261
|
+
_ts_decorate3([
|
|
3201
3262
|
(0, import_debug4.timed)(1e4)
|
|
3202
3263
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
3203
|
-
|
|
3264
|
+
_ts_decorate3([
|
|
3204
3265
|
import_async11.synchronized
|
|
3205
3266
|
], DataSpace.prototype, "activate", null);
|
|
3206
|
-
|
|
3267
|
+
_ts_decorate3([
|
|
3207
3268
|
import_async11.synchronized
|
|
3208
3269
|
], DataSpace.prototype, "deactivate", null);
|
|
3209
|
-
DataSpace =
|
|
3270
|
+
DataSpace = _ts_decorate3([
|
|
3210
3271
|
(0, import_async11.trackLeaks)("open", "close")
|
|
3211
3272
|
], DataSpace);
|
|
3212
3273
|
|
|
@@ -3214,9 +3275,8 @@ DataSpace = _ts_decorate([
|
|
|
3214
3275
|
var import_credentials11 = require("@dxos/credentials");
|
|
3215
3276
|
var import_debug5 = require("@dxos/debug");
|
|
3216
3277
|
var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
3217
|
-
var
|
|
3278
|
+
var import_timeframe3 = require("@dxos/timeframe");
|
|
3218
3279
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
3219
|
-
var _a, _b, _c, _d;
|
|
3220
3280
|
const credentials = [
|
|
3221
3281
|
await (0, import_credentials11.createCredential)({
|
|
3222
3282
|
signer: keyring,
|
|
@@ -3236,11 +3296,11 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3236
3296
|
spaceKey: space.key,
|
|
3237
3297
|
role: import_credentials12.SpaceMember.Role.ADMIN,
|
|
3238
3298
|
profile: signingContext.profile,
|
|
3239
|
-
genesisFeedKey:
|
|
3299
|
+
genesisFeedKey: space.controlFeedKey ?? (0, import_debug5.failUndefined)()
|
|
3240
3300
|
}
|
|
3241
3301
|
}),
|
|
3242
3302
|
await signingContext.credentialSigner.createCredential({
|
|
3243
|
-
subject:
|
|
3303
|
+
subject: space.controlFeedKey ?? (0, import_debug5.failUndefined)(),
|
|
3244
3304
|
assertion: {
|
|
3245
3305
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
3246
3306
|
spaceKey: space.key,
|
|
@@ -3250,7 +3310,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3250
3310
|
}
|
|
3251
3311
|
}),
|
|
3252
3312
|
await signingContext.credentialSigner.createCredential({
|
|
3253
|
-
subject:
|
|
3313
|
+
subject: space.dataFeedKey ?? (0, import_debug5.failUndefined)(),
|
|
3254
3314
|
assertion: {
|
|
3255
3315
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
3256
3316
|
spaceKey: space.key,
|
|
@@ -3260,12 +3320,12 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3260
3320
|
}
|
|
3261
3321
|
}),
|
|
3262
3322
|
await signingContext.credentialSigner.createCredential({
|
|
3263
|
-
subject:
|
|
3323
|
+
subject: space.key ?? (0, import_debug5.failUndefined)(),
|
|
3264
3324
|
assertion: {
|
|
3265
3325
|
"@type": "dxos.halo.credentials.Epoch",
|
|
3266
3326
|
number: 0,
|
|
3267
3327
|
previousId: void 0,
|
|
3268
|
-
timeframe: new
|
|
3328
|
+
timeframe: new import_timeframe3.Timeframe(),
|
|
3269
3329
|
snapshotCid: void 0
|
|
3270
3330
|
}
|
|
3271
3331
|
})
|
|
@@ -3281,7 +3341,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3281
3341
|
};
|
|
3282
3342
|
|
|
3283
3343
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
3284
|
-
function
|
|
3344
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3285
3345
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3286
3346
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3287
3347
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3300,7 +3360,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3300
3360
|
this._keyring = _keyring;
|
|
3301
3361
|
this._signingContext = _signingContext;
|
|
3302
3362
|
this._feedStore = _feedStore;
|
|
3303
|
-
this._ctx = new
|
|
3363
|
+
this._ctx = new import_context8.Context();
|
|
3304
3364
|
this.updated = new import_async12.Event();
|
|
3305
3365
|
this._spaces = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
|
|
3306
3366
|
this._isOpen = false;
|
|
@@ -3479,7 +3539,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3479
3539
|
* TODO(dmaretskyi): Consider removing.
|
|
3480
3540
|
*/
|
|
3481
3541
|
async waitUntilSpaceReady(spaceKey) {
|
|
3482
|
-
await (0,
|
|
3542
|
+
await (0, import_context8.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
3483
3543
|
const space = this._spaces.get(spaceKey);
|
|
3484
3544
|
return !!space && space.state === import_services8.SpaceState.READY;
|
|
3485
3545
|
}));
|
|
@@ -3525,7 +3585,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3525
3585
|
onAuthFailure: () => {
|
|
3526
3586
|
import_log11.log.warn("auth failure", void 0, {
|
|
3527
3587
|
F: __dxlog_file13,
|
|
3528
|
-
L:
|
|
3588
|
+
L: 217,
|
|
3529
3589
|
S: this,
|
|
3530
3590
|
C: (f, a) => f(...a)
|
|
3531
3591
|
});
|
|
@@ -3549,7 +3609,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3549
3609
|
space: space.key
|
|
3550
3610
|
}, {
|
|
3551
3611
|
F: __dxlog_file13,
|
|
3552
|
-
L:
|
|
3612
|
+
L: 235,
|
|
3553
3613
|
S: this,
|
|
3554
3614
|
C: (f, a) => f(...a)
|
|
3555
3615
|
});
|
|
@@ -3561,7 +3621,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3561
3621
|
open: this._isOpen
|
|
3562
3622
|
}, {
|
|
3563
3623
|
F: __dxlog_file13,
|
|
3564
|
-
L:
|
|
3624
|
+
L: 242,
|
|
3565
3625
|
S: this,
|
|
3566
3626
|
C: (f, a) => f(...a)
|
|
3567
3627
|
});
|
|
@@ -3574,7 +3634,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3574
3634
|
space: space.key
|
|
3575
3635
|
}, {
|
|
3576
3636
|
F: __dxlog_file13,
|
|
3577
|
-
L:
|
|
3637
|
+
L: 248,
|
|
3578
3638
|
S: this,
|
|
3579
3639
|
C: (f, a) => f(...a)
|
|
3580
3640
|
});
|
|
@@ -3596,19 +3656,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3596
3656
|
return dataSpace;
|
|
3597
3657
|
}
|
|
3598
3658
|
};
|
|
3599
|
-
|
|
3659
|
+
_ts_decorate4([
|
|
3600
3660
|
import_async12.synchronized
|
|
3601
3661
|
], DataSpaceManager.prototype, "open", null);
|
|
3602
|
-
|
|
3662
|
+
_ts_decorate4([
|
|
3603
3663
|
import_async12.synchronized
|
|
3604
3664
|
], DataSpaceManager.prototype, "close", null);
|
|
3605
|
-
|
|
3665
|
+
_ts_decorate4([
|
|
3606
3666
|
import_async12.synchronized
|
|
3607
3667
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3608
|
-
|
|
3668
|
+
_ts_decorate4([
|
|
3609
3669
|
import_async12.synchronized
|
|
3610
3670
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3611
|
-
DataSpaceManager =
|
|
3671
|
+
DataSpaceManager = _ts_decorate4([
|
|
3612
3672
|
(0, import_async12.trackLeaks)("open", "close")
|
|
3613
3673
|
], DataSpaceManager);
|
|
3614
3674
|
|
|
@@ -3639,9 +3699,8 @@ var SpacesServiceImpl = class {
|
|
|
3639
3699
|
return this._serializeSpace(space);
|
|
3640
3700
|
}
|
|
3641
3701
|
async updateSpace({ spaceKey, state }) {
|
|
3642
|
-
var _a;
|
|
3643
3702
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3644
|
-
const space =
|
|
3703
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3645
3704
|
if (state) {
|
|
3646
3705
|
switch (state) {
|
|
3647
3706
|
case import_services9.SpaceState.ACTIVE:
|
|
@@ -3672,7 +3731,7 @@ var SpacesServiceImpl = class {
|
|
|
3672
3731
|
spaces
|
|
3673
3732
|
});
|
|
3674
3733
|
}, {
|
|
3675
|
-
maxFrequency: 2
|
|
3734
|
+
maxFrequency: process.env.NODE_ENV === "test" ? void 0 : 2
|
|
3676
3735
|
});
|
|
3677
3736
|
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3678
3737
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
@@ -3705,17 +3764,15 @@ var SpacesServiceImpl = class {
|
|
|
3705
3764
|
});
|
|
3706
3765
|
}
|
|
3707
3766
|
async postMessage({ spaceKey, channel, message }) {
|
|
3708
|
-
var _a;
|
|
3709
3767
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3710
|
-
const space =
|
|
3768
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3711
3769
|
await space.postMessage(getChannelId(channel), message);
|
|
3712
3770
|
}
|
|
3713
3771
|
subscribeMessages({ spaceKey, channel }) {
|
|
3714
3772
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3715
3773
|
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3716
|
-
var _a;
|
|
3717
3774
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3718
|
-
const space =
|
|
3775
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3719
3776
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3720
3777
|
next(message);
|
|
3721
3778
|
});
|
|
@@ -3725,8 +3782,7 @@ var SpacesServiceImpl = class {
|
|
|
3725
3782
|
}
|
|
3726
3783
|
queryCredentials({ spaceKey }) {
|
|
3727
3784
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3728
|
-
|
|
3729
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3785
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3730
3786
|
const processor = {
|
|
3731
3787
|
processCredential: async (credential) => {
|
|
3732
3788
|
next(credential);
|
|
@@ -3737,9 +3793,8 @@ var SpacesServiceImpl = class {
|
|
|
3737
3793
|
});
|
|
3738
3794
|
}
|
|
3739
3795
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
for (const credential of credentials != null ? credentials : []) {
|
|
3796
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3797
|
+
for (const credential of credentials ?? []) {
|
|
3743
3798
|
await space.controlPipeline.writer.write({
|
|
3744
3799
|
credential: {
|
|
3745
3800
|
credential
|
|
@@ -3748,13 +3803,11 @@ var SpacesServiceImpl = class {
|
|
|
3748
3803
|
}
|
|
3749
3804
|
}
|
|
3750
3805
|
async createEpoch({ spaceKey }) {
|
|
3751
|
-
var _a;
|
|
3752
3806
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3753
|
-
const space =
|
|
3807
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3754
3808
|
await space.createEpoch();
|
|
3755
3809
|
}
|
|
3756
3810
|
_serializeSpace(space) {
|
|
3757
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3758
3811
|
return {
|
|
3759
3812
|
spaceKey: space.key,
|
|
3760
3813
|
state: space.state,
|
|
@@ -3766,16 +3819,15 @@ var SpacesServiceImpl = class {
|
|
|
3766
3819
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
3767
3820
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
3768
3821
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
3769
|
-
dataFeeds:
|
|
3770
|
-
startDataTimeframe:
|
|
3771
|
-
currentDataTimeframe:
|
|
3772
|
-
targetDataTimeframe:
|
|
3773
|
-
totalDataTimeframe:
|
|
3822
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
3823
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
3824
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
3825
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
3826
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
3774
3827
|
},
|
|
3775
3828
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3776
|
-
var _a2, _b2, _c2;
|
|
3777
3829
|
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
3778
|
-
const isMe =
|
|
3830
|
+
const isMe = this._identityManager.identity?.identityKey.equals(member.key);
|
|
3779
3831
|
if (isMe) {
|
|
3780
3832
|
peers.push(space.presence.getLocalState());
|
|
3781
3833
|
}
|
|
@@ -3783,14 +3835,14 @@ var SpacesServiceImpl = class {
|
|
|
3783
3835
|
identity: {
|
|
3784
3836
|
identityKey: member.key,
|
|
3785
3837
|
profile: {
|
|
3786
|
-
displayName:
|
|
3838
|
+
displayName: member.assertion.profile?.displayName ?? (0, import_util6.humanize)(member.key)
|
|
3787
3839
|
}
|
|
3788
3840
|
},
|
|
3789
3841
|
presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
3790
3842
|
peerStates: peers
|
|
3791
3843
|
};
|
|
3792
3844
|
}),
|
|
3793
|
-
creator:
|
|
3845
|
+
creator: space.inner.spaceState.creator?.key,
|
|
3794
3846
|
cache: space.cache,
|
|
3795
3847
|
metrics: space.metrics
|
|
3796
3848
|
};
|
|
@@ -3799,8 +3851,18 @@ var SpacesServiceImpl = class {
|
|
|
3799
3851
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3800
3852
|
|
|
3801
3853
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3854
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
3855
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3856
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3857
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3858
|
+
else
|
|
3859
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3860
|
+
if (d = decorators[i])
|
|
3861
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3862
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3863
|
+
}
|
|
3802
3864
|
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3803
|
-
var ServiceContext = class {
|
|
3865
|
+
var ServiceContext = class ServiceContext2 {
|
|
3804
3866
|
// prettier-ignore
|
|
3805
3867
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
3806
3868
|
this.storage = storage;
|
|
@@ -3820,7 +3882,8 @@ var ServiceContext = class {
|
|
|
3820
3882
|
root: storage.createDirectory("feeds"),
|
|
3821
3883
|
signer: this.keyring,
|
|
3822
3884
|
hypercore: {
|
|
3823
|
-
valueEncoding: import_echo_pipeline3.valueEncoding
|
|
3885
|
+
valueEncoding: import_echo_pipeline3.valueEncoding,
|
|
3886
|
+
stats: true
|
|
3824
3887
|
}
|
|
3825
3888
|
})
|
|
3826
3889
|
});
|
|
@@ -3834,16 +3897,13 @@ var ServiceContext = class {
|
|
|
3834
3897
|
});
|
|
3835
3898
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3836
3899
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3837
|
-
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () =>
|
|
3838
|
-
var _a;
|
|
3839
|
-
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
3840
|
-
}, this._acceptIdentity.bind(this)));
|
|
3900
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
3841
3901
|
}
|
|
3842
|
-
async open() {
|
|
3902
|
+
async open(ctx) {
|
|
3843
3903
|
await this._checkStorageVersion();
|
|
3844
3904
|
(0, import_log13.log)("opening...", void 0, {
|
|
3845
3905
|
F: __dxlog_file15,
|
|
3846
|
-
L:
|
|
3906
|
+
L: 135,
|
|
3847
3907
|
S: this,
|
|
3848
3908
|
C: (f, a) => f(...a)
|
|
3849
3909
|
});
|
|
@@ -3851,44 +3911,43 @@ var ServiceContext = class {
|
|
|
3851
3911
|
id: this._instanceId
|
|
3852
3912
|
}), {
|
|
3853
3913
|
F: __dxlog_file15,
|
|
3854
|
-
L:
|
|
3914
|
+
L: 136,
|
|
3855
3915
|
S: this,
|
|
3856
3916
|
C: (f, a) => f(...a)
|
|
3857
3917
|
});
|
|
3858
3918
|
await this.signalManager.open();
|
|
3859
3919
|
await this.networkManager.open();
|
|
3860
3920
|
await this.spaceManager.open();
|
|
3861
|
-
await this.identityManager.open();
|
|
3921
|
+
await this.identityManager.open(ctx);
|
|
3862
3922
|
if (this.identityManager.identity) {
|
|
3863
|
-
await this._initialize();
|
|
3923
|
+
await this._initialize(ctx);
|
|
3864
3924
|
}
|
|
3865
3925
|
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.end({
|
|
3866
3926
|
id: this._instanceId
|
|
3867
3927
|
}), {
|
|
3868
3928
|
F: __dxlog_file15,
|
|
3869
|
-
L:
|
|
3929
|
+
L: 144,
|
|
3870
3930
|
S: this,
|
|
3871
3931
|
C: (f, a) => f(...a)
|
|
3872
3932
|
});
|
|
3873
3933
|
(0, import_log13.log)("opened", void 0, {
|
|
3874
3934
|
F: __dxlog_file15,
|
|
3875
|
-
L:
|
|
3935
|
+
L: 145,
|
|
3876
3936
|
S: this,
|
|
3877
3937
|
C: (f, a) => f(...a)
|
|
3878
3938
|
});
|
|
3879
3939
|
}
|
|
3880
3940
|
async close() {
|
|
3881
|
-
var _a;
|
|
3882
3941
|
(0, import_log13.log)("closing...", void 0, {
|
|
3883
3942
|
F: __dxlog_file15,
|
|
3884
|
-
L:
|
|
3943
|
+
L: 149,
|
|
3885
3944
|
S: this,
|
|
3886
3945
|
C: (f, a) => f(...a)
|
|
3887
3946
|
});
|
|
3888
3947
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3889
3948
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3890
3949
|
}
|
|
3891
|
-
await
|
|
3950
|
+
await this.dataSpaceManager?.close();
|
|
3892
3951
|
await this.identityManager.close();
|
|
3893
3952
|
await this.spaceManager.close();
|
|
3894
3953
|
await this.feedStore.close();
|
|
@@ -3897,21 +3956,21 @@ var ServiceContext = class {
|
|
|
3897
3956
|
this.dataServiceSubscriptions.clear();
|
|
3898
3957
|
(0, import_log13.log)("closed", void 0, {
|
|
3899
3958
|
F: __dxlog_file15,
|
|
3900
|
-
L:
|
|
3959
|
+
L: 160,
|
|
3901
3960
|
S: this,
|
|
3902
3961
|
C: (f, a) => f(...a)
|
|
3903
3962
|
});
|
|
3904
3963
|
}
|
|
3905
3964
|
async createIdentity(params = {}) {
|
|
3906
3965
|
const identity = await this.identityManager.createIdentity(params);
|
|
3907
|
-
await this._initialize();
|
|
3966
|
+
await this._initialize(new import_context9.Context());
|
|
3908
3967
|
return identity;
|
|
3909
3968
|
}
|
|
3910
3969
|
getInvitationHandler(invitation) {
|
|
3911
3970
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3912
3971
|
(0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3913
3972
|
F: __dxlog_file15,
|
|
3914
|
-
L:
|
|
3973
|
+
L: 171,
|
|
3915
3974
|
S: this,
|
|
3916
3975
|
A: [
|
|
3917
3976
|
"factory",
|
|
@@ -3922,7 +3981,7 @@ var ServiceContext = class {
|
|
|
3922
3981
|
}
|
|
3923
3982
|
async _acceptIdentity(params) {
|
|
3924
3983
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
3925
|
-
await this._initialize();
|
|
3984
|
+
await this._initialize(new import_context9.Context());
|
|
3926
3985
|
return identity;
|
|
3927
3986
|
}
|
|
3928
3987
|
async _checkStorageVersion() {
|
|
@@ -3932,15 +3991,14 @@ var ServiceContext = class {
|
|
|
3932
3991
|
}
|
|
3933
3992
|
}
|
|
3934
3993
|
// Called when identity is created.
|
|
3935
|
-
async _initialize() {
|
|
3936
|
-
var _a;
|
|
3994
|
+
async _initialize(ctx) {
|
|
3937
3995
|
(0, import_log13.log)("initializing spaces...", void 0, {
|
|
3938
3996
|
F: __dxlog_file15,
|
|
3939
|
-
L:
|
|
3997
|
+
L: 192,
|
|
3940
3998
|
S: this,
|
|
3941
3999
|
C: (f, a) => f(...a)
|
|
3942
4000
|
});
|
|
3943
|
-
const identity =
|
|
4001
|
+
const identity = this.identityManager.identity ?? (0, import_debug7.failUndefined)();
|
|
3944
4002
|
const signingContext = {
|
|
3945
4003
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3946
4004
|
identityKey: identity.identityKey,
|
|
@@ -3959,7 +4017,7 @@ var ServiceContext = class {
|
|
|
3959
4017
|
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
3960
4018
|
(0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
3961
4019
|
F: __dxlog_file15,
|
|
3962
|
-
L:
|
|
4020
|
+
L: 215,
|
|
3963
4021
|
S: this,
|
|
3964
4022
|
A: [
|
|
3965
4023
|
"this.dataSpaceManager",
|
|
@@ -3983,7 +4041,7 @@ var ServiceContext = class {
|
|
|
3983
4041
|
details: assertion
|
|
3984
4042
|
}, {
|
|
3985
4043
|
F: __dxlog_file15,
|
|
3986
|
-
L:
|
|
4044
|
+
L: 231,
|
|
3987
4045
|
S: this,
|
|
3988
4046
|
C: (f, a) => f(...a)
|
|
3989
4047
|
});
|
|
@@ -3994,7 +4052,7 @@ var ServiceContext = class {
|
|
|
3994
4052
|
details: assertion
|
|
3995
4053
|
}, {
|
|
3996
4054
|
F: __dxlog_file15,
|
|
3997
|
-
L:
|
|
4055
|
+
L: 235,
|
|
3998
4056
|
S: this,
|
|
3999
4057
|
C: (f, a) => f(...a)
|
|
4000
4058
|
});
|
|
@@ -4005,7 +4063,7 @@ var ServiceContext = class {
|
|
|
4005
4063
|
details: assertion
|
|
4006
4064
|
}, {
|
|
4007
4065
|
F: __dxlog_file15,
|
|
4008
|
-
L:
|
|
4066
|
+
L: 240,
|
|
4009
4067
|
S: this,
|
|
4010
4068
|
C: (f, a) => f(...a)
|
|
4011
4069
|
});
|
|
@@ -4016,7 +4074,7 @@ var ServiceContext = class {
|
|
|
4016
4074
|
} catch (err) {
|
|
4017
4075
|
import_log13.log.catch(err, void 0, {
|
|
4018
4076
|
F: __dxlog_file15,
|
|
4019
|
-
L:
|
|
4077
|
+
L: 246,
|
|
4020
4078
|
S: this,
|
|
4021
4079
|
C: (f, a) => f(...a)
|
|
4022
4080
|
});
|
|
@@ -4026,10 +4084,21 @@ var ServiceContext = class {
|
|
|
4026
4084
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
4027
4085
|
}
|
|
4028
4086
|
};
|
|
4087
|
+
_ts_decorate5([
|
|
4088
|
+
import_tracing3.trace.span()
|
|
4089
|
+
], ServiceContext.prototype, "open", null);
|
|
4090
|
+
_ts_decorate5([
|
|
4091
|
+
import_tracing3.trace.span()
|
|
4092
|
+
], ServiceContext.prototype, "_initialize", null);
|
|
4093
|
+
ServiceContext = _ts_decorate5([
|
|
4094
|
+
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
4095
|
+
import_tracing3.trace.resource()
|
|
4096
|
+
], ServiceContext);
|
|
4029
4097
|
|
|
4030
4098
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4031
4099
|
var import_async17 = require("@dxos/async");
|
|
4032
4100
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
4101
|
+
var import_context10 = require("@dxos/context");
|
|
4033
4102
|
var import_document_model2 = require("@dxos/document-model");
|
|
4034
4103
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
4035
4104
|
var import_invariant14 = require("@dxos/invariant");
|
|
@@ -4041,6 +4110,7 @@ var import_network_manager2 = require("@dxos/network-manager");
|
|
|
4041
4110
|
var import_protocols10 = require("@dxos/protocols");
|
|
4042
4111
|
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4043
4112
|
var import_text_model = require("@dxos/text-model");
|
|
4113
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
4044
4114
|
|
|
4045
4115
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
4046
4116
|
var import_async15 = require("@dxos/async");
|
|
@@ -4056,21 +4126,17 @@ var DevicesServiceImpl = class {
|
|
|
4056
4126
|
queryDevices() {
|
|
4057
4127
|
return new import_codec_protobuf12.Stream(({ next }) => {
|
|
4058
4128
|
const update = () => {
|
|
4059
|
-
|
|
4060
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
4129
|
+
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
4061
4130
|
if (!deviceKeys) {
|
|
4062
4131
|
next({
|
|
4063
4132
|
devices: []
|
|
4064
4133
|
});
|
|
4065
4134
|
} else {
|
|
4066
4135
|
next({
|
|
4067
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
|
|
4072
|
-
};
|
|
4073
|
-
})
|
|
4136
|
+
devices: Array.from(deviceKeys.values()).map((key) => ({
|
|
4137
|
+
deviceKey: key,
|
|
4138
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
|
|
4139
|
+
}))
|
|
4074
4140
|
});
|
|
4075
4141
|
}
|
|
4076
4142
|
};
|
|
@@ -4093,7 +4159,7 @@ var DevicesServiceImpl = class {
|
|
|
4093
4159
|
var import_invariant13 = require("@dxos/invariant");
|
|
4094
4160
|
var import_lock_file = require("@dxos/lock-file");
|
|
4095
4161
|
var import_log14 = require("@dxos/log");
|
|
4096
|
-
function
|
|
4162
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
4097
4163
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4098
4164
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4099
4165
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4114,7 +4180,6 @@ var Lock = class {
|
|
|
4114
4180
|
return this._lockPath;
|
|
4115
4181
|
}
|
|
4116
4182
|
async acquire() {
|
|
4117
|
-
var _a;
|
|
4118
4183
|
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
4119
4184
|
F: __dxlog_file16,
|
|
4120
4185
|
L: 32,
|
|
@@ -4122,7 +4187,7 @@ var Lock = class {
|
|
|
4122
4187
|
C: (f, a) => f(...a)
|
|
4123
4188
|
});
|
|
4124
4189
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
4125
|
-
await
|
|
4190
|
+
await this._onAcquire?.();
|
|
4126
4191
|
(0, import_log14.log)("acquired lock", void 0, {
|
|
4127
4192
|
F: __dxlog_file16,
|
|
4128
4193
|
L: 37,
|
|
@@ -4131,8 +4196,7 @@ var Lock = class {
|
|
|
4131
4196
|
});
|
|
4132
4197
|
}
|
|
4133
4198
|
async release() {
|
|
4134
|
-
|
|
4135
|
-
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
4199
|
+
await this._onRelease?.();
|
|
4136
4200
|
(0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4137
4201
|
F: __dxlog_file16,
|
|
4138
4202
|
L: 42,
|
|
@@ -4145,7 +4209,7 @@ var Lock = class {
|
|
|
4145
4209
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
4146
4210
|
}
|
|
4147
4211
|
};
|
|
4148
|
-
|
|
4212
|
+
_ts_decorate6([
|
|
4149
4213
|
import_log14.logInfo
|
|
4150
4214
|
], Lock.prototype, "lockKey", null);
|
|
4151
4215
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
@@ -4155,11 +4219,11 @@ var import_async16 = require("@dxos/async");
|
|
|
4155
4219
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
4156
4220
|
var import_log15 = require("@dxos/log");
|
|
4157
4221
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4158
|
-
var
|
|
4222
|
+
var import_util8 = require("@dxos/util");
|
|
4159
4223
|
var LoggingServiceImpl = class {
|
|
4160
4224
|
constructor() {
|
|
4161
4225
|
this._logs = new import_async16.Event();
|
|
4162
|
-
this._started = new Date();
|
|
4226
|
+
this._started = /* @__PURE__ */ new Date();
|
|
4163
4227
|
this._logProcessor = (_config, entry2) => {
|
|
4164
4228
|
this._logs.emit(entry2);
|
|
4165
4229
|
};
|
|
@@ -4173,15 +4237,15 @@ var LoggingServiceImpl = class {
|
|
|
4173
4237
|
}
|
|
4174
4238
|
async controlMetrics({ reset, record }) {
|
|
4175
4239
|
if (reset) {
|
|
4176
|
-
|
|
4240
|
+
import_util8.tracer.clear();
|
|
4177
4241
|
}
|
|
4178
4242
|
if (record === true) {
|
|
4179
|
-
|
|
4243
|
+
import_util8.tracer.start();
|
|
4180
4244
|
} else if (record === false) {
|
|
4181
|
-
|
|
4245
|
+
import_util8.tracer.stop();
|
|
4182
4246
|
}
|
|
4183
4247
|
return {
|
|
4184
|
-
recording:
|
|
4248
|
+
recording: import_util8.tracer.recording
|
|
4185
4249
|
};
|
|
4186
4250
|
}
|
|
4187
4251
|
/**
|
|
@@ -4189,24 +4253,23 @@ var LoggingServiceImpl = class {
|
|
|
4189
4253
|
*/
|
|
4190
4254
|
queryMetrics({ interval = 5e3 }) {
|
|
4191
4255
|
const getNumericalValues = (key) => {
|
|
4192
|
-
|
|
4193
|
-
const events = (_a = import_util7.tracer.get(key)) != null ? _a : [];
|
|
4256
|
+
const events = import_util8.tracer.get(key) ?? [];
|
|
4194
4257
|
return {
|
|
4195
4258
|
key,
|
|
4196
|
-
stats: (0,
|
|
4259
|
+
stats: (0, import_util8.numericalValues)(events, "duration")
|
|
4197
4260
|
};
|
|
4198
4261
|
};
|
|
4199
4262
|
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
4200
4263
|
const update = () => {
|
|
4201
4264
|
const metrics = {
|
|
4202
|
-
timestamp: new Date(),
|
|
4265
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4203
4266
|
values: [
|
|
4204
4267
|
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4205
4268
|
getNumericalValues("dxos.echo.pipeline.data")
|
|
4206
4269
|
].filter(Boolean)
|
|
4207
4270
|
};
|
|
4208
4271
|
next({
|
|
4209
|
-
timestamp: new Date(),
|
|
4272
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4210
4273
|
metrics
|
|
4211
4274
|
});
|
|
4212
4275
|
};
|
|
@@ -4220,11 +4283,10 @@ var LoggingServiceImpl = class {
|
|
|
4220
4283
|
queryLogs(request) {
|
|
4221
4284
|
return new import_codec_protobuf13.Stream(({ ctx, next }) => {
|
|
4222
4285
|
const handler = (entry2) => {
|
|
4223
|
-
var _a, _b, _c, _d, _e;
|
|
4224
4286
|
if (LOG_PROCESSING > 0) {
|
|
4225
4287
|
return;
|
|
4226
4288
|
}
|
|
4227
|
-
if (
|
|
4289
|
+
if (entry2.meta?.F.includes("logging-service") || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
4228
4290
|
return;
|
|
4229
4291
|
}
|
|
4230
4292
|
if (!shouldLog(entry2, request)) {
|
|
@@ -4232,12 +4294,12 @@ var LoggingServiceImpl = class {
|
|
|
4232
4294
|
}
|
|
4233
4295
|
const record = {
|
|
4234
4296
|
...entry2,
|
|
4235
|
-
context: (0,
|
|
4236
|
-
timestamp: new Date(),
|
|
4297
|
+
context: (0, import_util8.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
|
|
4298
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4237
4299
|
meta: {
|
|
4238
4300
|
// TODO(dmaretskyi): Fix proto.
|
|
4239
|
-
file:
|
|
4240
|
-
line:
|
|
4301
|
+
file: entry2.meta?.F ?? "",
|
|
4302
|
+
line: entry2.meta?.L ?? 0
|
|
4241
4303
|
}
|
|
4242
4304
|
};
|
|
4243
4305
|
try {
|
|
@@ -4260,15 +4322,11 @@ var matchFilter = (filter, level, path, options) => {
|
|
|
4260
4322
|
}
|
|
4261
4323
|
};
|
|
4262
4324
|
var shouldLog = (entry2, request) => {
|
|
4263
|
-
|
|
4264
|
-
const options = (_a = request.options) != null ? _a : import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4325
|
+
const options = request.options ?? import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4265
4326
|
if (request.filters === void 0) {
|
|
4266
4327
|
return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4267
4328
|
} else {
|
|
4268
|
-
return request.filters.some((filter) =>
|
|
4269
|
-
var _a2, _b;
|
|
4270
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
4271
|
-
});
|
|
4329
|
+
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
4272
4330
|
}
|
|
4273
4331
|
};
|
|
4274
4332
|
var LOG_PROCESSING = 0;
|
|
@@ -4310,10 +4368,10 @@ var import_client_protocol4 = require("@dxos/client-protocol");
|
|
|
4310
4368
|
var import_errors5 = require("@dxos/errors");
|
|
4311
4369
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
4312
4370
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
4313
|
-
var
|
|
4371
|
+
var import_util9 = require("@dxos/util");
|
|
4314
4372
|
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
4315
4373
|
var createStorageObjects = (config) => {
|
|
4316
|
-
const { path = (0,
|
|
4374
|
+
const { path = (0, import_util9.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config ?? {};
|
|
4317
4375
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
4318
4376
|
throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4319
4377
|
}
|
|
@@ -4357,7 +4415,7 @@ var toStorageType = (type) => {
|
|
|
4357
4415
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
4358
4416
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
4359
4417
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4360
|
-
var
|
|
4418
|
+
var import_util10 = require("@dxos/util");
|
|
4361
4419
|
var SystemServiceImpl = class {
|
|
4362
4420
|
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4363
4421
|
this._config = config;
|
|
@@ -4368,8 +4426,7 @@ var SystemServiceImpl = class {
|
|
|
4368
4426
|
this._onReset = onReset;
|
|
4369
4427
|
}
|
|
4370
4428
|
async getConfig() {
|
|
4371
|
-
|
|
4372
|
-
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
4429
|
+
return this._config?.values ?? {};
|
|
4373
4430
|
}
|
|
4374
4431
|
/**
|
|
4375
4432
|
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
@@ -4377,8 +4434,8 @@ var SystemServiceImpl = class {
|
|
|
4377
4434
|
async getDiagnostics({ keys } = {}) {
|
|
4378
4435
|
const diagnostics = await this._getDiagnostics();
|
|
4379
4436
|
return {
|
|
4380
|
-
timestamp: new Date(),
|
|
4381
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
4437
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4438
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util10.jsonKeyReplacer)({
|
|
4382
4439
|
truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4383
4440
|
humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
4384
4441
|
})))
|
|
@@ -4434,7 +4491,7 @@ var ServiceRegistry = class {
|
|
|
4434
4491
|
};
|
|
4435
4492
|
|
|
4436
4493
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4437
|
-
function
|
|
4494
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
4438
4495
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4439
4496
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4440
4497
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4448,7 +4505,7 @@ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
4448
4505
|
var createDefaultModelFactory = () => {
|
|
4449
4506
|
return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
|
|
4450
4507
|
};
|
|
4451
|
-
var ClientServicesHost = class {
|
|
4508
|
+
var ClientServicesHost = class ClientServicesHost2 {
|
|
4452
4509
|
constructor({
|
|
4453
4510
|
config,
|
|
4454
4511
|
modelFactory = createDefaultModelFactory(),
|
|
@@ -4459,6 +4516,7 @@ var ClientServicesHost = class {
|
|
|
4459
4516
|
lockKey,
|
|
4460
4517
|
callbacks
|
|
4461
4518
|
} = {}) {
|
|
4519
|
+
this._tracingService = import_tracing4.TRACE_PROCESSOR.createTraceSender();
|
|
4462
4520
|
this._statusUpdate = new import_async17.Event();
|
|
4463
4521
|
this._opening = false;
|
|
4464
4522
|
this._open = false;
|
|
@@ -4477,7 +4535,7 @@ var ClientServicesHost = class {
|
|
|
4477
4535
|
lockKey,
|
|
4478
4536
|
onAcquire: () => {
|
|
4479
4537
|
if (!this._opening) {
|
|
4480
|
-
void this.open();
|
|
4538
|
+
void this.open(new import_context10.Context());
|
|
4481
4539
|
}
|
|
4482
4540
|
},
|
|
4483
4541
|
onRelease: () => this.close()
|
|
@@ -4491,11 +4549,10 @@ var ClientServicesHost = class {
|
|
|
4491
4549
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4492
4550
|
},
|
|
4493
4551
|
onUpdateStatus: async (status) => {
|
|
4494
|
-
var _a, _b;
|
|
4495
4552
|
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
4496
|
-
await
|
|
4553
|
+
await this._resourceLock?.acquire();
|
|
4497
4554
|
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
4498
|
-
await
|
|
4555
|
+
await this._resourceLock?.release();
|
|
4499
4556
|
}
|
|
4500
4557
|
},
|
|
4501
4558
|
onReset: async () => {
|
|
@@ -4504,7 +4561,8 @@ var ClientServicesHost = class {
|
|
|
4504
4561
|
});
|
|
4505
4562
|
this._loggingService = new LoggingServiceImpl();
|
|
4506
4563
|
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
4507
|
-
SystemService: this._systemService
|
|
4564
|
+
SystemService: this._systemService,
|
|
4565
|
+
TracingService: this._tracingService
|
|
4508
4566
|
});
|
|
4509
4567
|
}
|
|
4510
4568
|
get isOpen() {
|
|
@@ -4531,26 +4589,25 @@ var ClientServicesHost = class {
|
|
|
4531
4589
|
* Can only be called once.
|
|
4532
4590
|
*/
|
|
4533
4591
|
initialize({ config, ...options }) {
|
|
4534
|
-
var _a, _b, _c;
|
|
4535
4592
|
(0, import_invariant14.invariant)(!this._open, "service host is open", {
|
|
4536
4593
|
F: __dxlog_file17,
|
|
4537
|
-
L:
|
|
4594
|
+
L: 181,
|
|
4538
4595
|
S: this,
|
|
4539
4596
|
A: [
|
|
4540
4597
|
"!this._open",
|
|
4541
4598
|
"'service host is open'"
|
|
4542
4599
|
]
|
|
4543
4600
|
});
|
|
4544
|
-
import_log16.log
|
|
4601
|
+
(0, import_log16.log)("initializing...", void 0, {
|
|
4545
4602
|
F: __dxlog_file17,
|
|
4546
|
-
L:
|
|
4603
|
+
L: 182,
|
|
4547
4604
|
S: this,
|
|
4548
4605
|
C: (f, a) => f(...a)
|
|
4549
4606
|
});
|
|
4550
4607
|
if (config) {
|
|
4551
4608
|
(0, import_invariant14.invariant)(!this._config, "config already set", {
|
|
4552
4609
|
F: __dxlog_file17,
|
|
4553
|
-
L:
|
|
4610
|
+
L: 185,
|
|
4554
4611
|
S: this,
|
|
4555
4612
|
A: [
|
|
4556
4613
|
"!this._config",
|
|
@@ -4563,12 +4620,12 @@ var ClientServicesHost = class {
|
|
|
4563
4620
|
}
|
|
4564
4621
|
}
|
|
4565
4622
|
const { connectionLog = true, transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
|
|
4566
|
-
iceServers:
|
|
4567
|
-
}), signalManager = new import_messaging.WebsocketSignalManager(
|
|
4623
|
+
iceServers: this._config?.get("runtime.services.ice")
|
|
4624
|
+
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4568
4625
|
this._signalManager = signalManager;
|
|
4569
4626
|
(0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
|
|
4570
4627
|
F: __dxlog_file17,
|
|
4571
|
-
L:
|
|
4628
|
+
L: 201,
|
|
4572
4629
|
S: this,
|
|
4573
4630
|
A: [
|
|
4574
4631
|
"!this._networkManager",
|
|
@@ -4580,15 +4637,14 @@ var ClientServicesHost = class {
|
|
|
4580
4637
|
transportFactory,
|
|
4581
4638
|
signalManager
|
|
4582
4639
|
});
|
|
4583
|
-
import_log16.log
|
|
4640
|
+
(0, import_log16.log)("initialized", void 0, {
|
|
4584
4641
|
F: __dxlog_file17,
|
|
4585
|
-
L:
|
|
4642
|
+
L: 208,
|
|
4586
4643
|
S: this,
|
|
4587
4644
|
C: (f, a) => f(...a)
|
|
4588
4645
|
});
|
|
4589
4646
|
}
|
|
4590
|
-
async open() {
|
|
4591
|
-
var _a, _b, _c;
|
|
4647
|
+
async open(ctx) {
|
|
4592
4648
|
if (this._open) {
|
|
4593
4649
|
return;
|
|
4594
4650
|
}
|
|
@@ -4597,13 +4653,13 @@ var ClientServicesHost = class {
|
|
|
4597
4653
|
id: traceId
|
|
4598
4654
|
}), {
|
|
4599
4655
|
F: __dxlog_file17,
|
|
4600
|
-
L:
|
|
4656
|
+
L: 219,
|
|
4601
4657
|
S: this,
|
|
4602
4658
|
C: (f, a) => f(...a)
|
|
4603
4659
|
});
|
|
4604
4660
|
(0, import_invariant14.invariant)(this._config, "config not set", {
|
|
4605
4661
|
F: __dxlog_file17,
|
|
4606
|
-
L:
|
|
4662
|
+
L: 221,
|
|
4607
4663
|
S: this,
|
|
4608
4664
|
A: [
|
|
4609
4665
|
"this._config",
|
|
@@ -4612,7 +4668,7 @@ var ClientServicesHost = class {
|
|
|
4612
4668
|
});
|
|
4613
4669
|
(0, import_invariant14.invariant)(this._storage, "storage not set", {
|
|
4614
4670
|
F: __dxlog_file17,
|
|
4615
|
-
L:
|
|
4671
|
+
L: 222,
|
|
4616
4672
|
S: this,
|
|
4617
4673
|
A: [
|
|
4618
4674
|
"this._storage",
|
|
@@ -4621,7 +4677,7 @@ var ClientServicesHost = class {
|
|
|
4621
4677
|
});
|
|
4622
4678
|
(0, import_invariant14.invariant)(this._signalManager, "signal manager not set", {
|
|
4623
4679
|
F: __dxlog_file17,
|
|
4624
|
-
L:
|
|
4680
|
+
L: 223,
|
|
4625
4681
|
S: this,
|
|
4626
4682
|
A: [
|
|
4627
4683
|
"this._signalManager",
|
|
@@ -4630,7 +4686,7 @@ var ClientServicesHost = class {
|
|
|
4630
4686
|
});
|
|
4631
4687
|
(0, import_invariant14.invariant)(this._networkManager, "network manager not set", {
|
|
4632
4688
|
F: __dxlog_file17,
|
|
4633
|
-
L:
|
|
4689
|
+
L: 224,
|
|
4634
4690
|
S: this,
|
|
4635
4691
|
A: [
|
|
4636
4692
|
"this._networkManager",
|
|
@@ -4638,20 +4694,20 @@ var ClientServicesHost = class {
|
|
|
4638
4694
|
]
|
|
4639
4695
|
});
|
|
4640
4696
|
this._opening = true;
|
|
4641
|
-
import_log16.log
|
|
4642
|
-
lockKey:
|
|
4697
|
+
(0, import_log16.log)("opening...", {
|
|
4698
|
+
lockKey: this._resourceLock?.lockKey
|
|
4643
4699
|
}, {
|
|
4644
4700
|
F: __dxlog_file17,
|
|
4645
|
-
L:
|
|
4701
|
+
L: 227,
|
|
4646
4702
|
S: this,
|
|
4647
4703
|
C: (f, a) => f(...a)
|
|
4648
4704
|
});
|
|
4649
|
-
await
|
|
4705
|
+
await this._resourceLock?.acquire();
|
|
4650
4706
|
await this._loggingService.open();
|
|
4651
4707
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4652
4708
|
this._serviceRegistry.setServices({
|
|
4653
4709
|
SystemService: this._systemService,
|
|
4654
|
-
IdentityService: new IdentityServiceImpl(this._serviceContext),
|
|
4710
|
+
IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
|
|
4655
4711
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4656
4712
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4657
4713
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -4661,6 +4717,7 @@ var ClientServicesHost = class {
|
|
|
4661
4717
|
DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4662
4718
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
4663
4719
|
LoggingService: this._loggingService,
|
|
4720
|
+
TracingService: this._tracingService,
|
|
4664
4721
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4665
4722
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
4666
4723
|
events: new DevtoolsHostEvents(),
|
|
@@ -4668,16 +4725,16 @@ var ClientServicesHost = class {
|
|
|
4668
4725
|
context: this._serviceContext
|
|
4669
4726
|
})
|
|
4670
4727
|
});
|
|
4671
|
-
await this._serviceContext.open();
|
|
4728
|
+
await this._serviceContext.open(ctx);
|
|
4672
4729
|
this._opening = false;
|
|
4673
4730
|
this._open = true;
|
|
4674
4731
|
this._statusUpdate.emit();
|
|
4675
|
-
const deviceKey =
|
|
4676
|
-
import_log16.log
|
|
4732
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4733
|
+
(0, import_log16.log)("opened", {
|
|
4677
4734
|
deviceKey
|
|
4678
4735
|
}, {
|
|
4679
4736
|
F: __dxlog_file17,
|
|
4680
|
-
L:
|
|
4737
|
+
L: 284,
|
|
4681
4738
|
S: this,
|
|
4682
4739
|
C: (f, a) => f(...a)
|
|
4683
4740
|
});
|
|
@@ -4685,22 +4742,21 @@ var ClientServicesHost = class {
|
|
|
4685
4742
|
id: traceId
|
|
4686
4743
|
}), {
|
|
4687
4744
|
F: __dxlog_file17,
|
|
4688
|
-
L:
|
|
4745
|
+
L: 285,
|
|
4689
4746
|
S: this,
|
|
4690
4747
|
C: (f, a) => f(...a)
|
|
4691
4748
|
});
|
|
4692
4749
|
}
|
|
4693
4750
|
async close() {
|
|
4694
|
-
var _a;
|
|
4695
4751
|
if (!this._open) {
|
|
4696
4752
|
return;
|
|
4697
4753
|
}
|
|
4698
|
-
const deviceKey =
|
|
4699
|
-
import_log16.log
|
|
4754
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4755
|
+
(0, import_log16.log)("closing...", {
|
|
4700
4756
|
deviceKey
|
|
4701
4757
|
}, {
|
|
4702
4758
|
F: __dxlog_file17,
|
|
4703
|
-
L:
|
|
4759
|
+
L: 296,
|
|
4704
4760
|
S: this,
|
|
4705
4761
|
C: (f, a) => f(...a)
|
|
4706
4762
|
});
|
|
@@ -4711,37 +4767,36 @@ var ClientServicesHost = class {
|
|
|
4711
4767
|
await this._serviceContext.close();
|
|
4712
4768
|
this._open = false;
|
|
4713
4769
|
this._statusUpdate.emit();
|
|
4714
|
-
import_log16.log
|
|
4770
|
+
(0, import_log16.log)("closed", {
|
|
4715
4771
|
deviceKey
|
|
4716
4772
|
}, {
|
|
4717
4773
|
F: __dxlog_file17,
|
|
4718
|
-
L:
|
|
4774
|
+
L: 302,
|
|
4719
4775
|
S: this,
|
|
4720
4776
|
C: (f, a) => f(...a)
|
|
4721
4777
|
});
|
|
4722
4778
|
}
|
|
4723
4779
|
async reset() {
|
|
4724
|
-
var _a, _b, _c;
|
|
4725
4780
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4726
4781
|
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
|
|
4727
4782
|
id: traceId
|
|
4728
4783
|
}), {
|
|
4729
4784
|
F: __dxlog_file17,
|
|
4730
|
-
L:
|
|
4785
|
+
L: 307,
|
|
4731
4786
|
S: this,
|
|
4732
4787
|
C: (f, a) => f(...a)
|
|
4733
4788
|
});
|
|
4734
4789
|
(0, import_log16.log)("resetting...", void 0, {
|
|
4735
4790
|
F: __dxlog_file17,
|
|
4736
|
-
L:
|
|
4791
|
+
L: 309,
|
|
4737
4792
|
S: this,
|
|
4738
4793
|
C: (f, a) => f(...a)
|
|
4739
4794
|
});
|
|
4740
|
-
await
|
|
4795
|
+
await this._serviceContext?.close();
|
|
4741
4796
|
await this._storage.reset();
|
|
4742
4797
|
(0, import_log16.log)("reset", void 0, {
|
|
4743
4798
|
F: __dxlog_file17,
|
|
4744
|
-
L:
|
|
4799
|
+
L: 312,
|
|
4745
4800
|
S: this,
|
|
4746
4801
|
C: (f, a) => f(...a)
|
|
4747
4802
|
});
|
|
@@ -4749,27 +4804,39 @@ var ClientServicesHost = class {
|
|
|
4749
4804
|
id: traceId
|
|
4750
4805
|
}), {
|
|
4751
4806
|
F: __dxlog_file17,
|
|
4752
|
-
L:
|
|
4807
|
+
L: 313,
|
|
4753
4808
|
S: this,
|
|
4754
4809
|
C: (f, a) => f(...a)
|
|
4755
4810
|
});
|
|
4756
|
-
await
|
|
4811
|
+
await this._callbacks?.onReset?.();
|
|
4757
4812
|
}
|
|
4758
4813
|
};
|
|
4759
|
-
|
|
4760
|
-
|
|
4814
|
+
_ts_decorate7([
|
|
4815
|
+
import_tracing4.trace.info()
|
|
4816
|
+
], ClientServicesHost.prototype, "_opening", void 0);
|
|
4817
|
+
_ts_decorate7([
|
|
4818
|
+
import_tracing4.trace.info()
|
|
4819
|
+
], ClientServicesHost.prototype, "_open", void 0);
|
|
4820
|
+
_ts_decorate7([
|
|
4821
|
+
import_async17.synchronized,
|
|
4822
|
+
import_tracing4.trace.span()
|
|
4761
4823
|
], ClientServicesHost.prototype, "open", null);
|
|
4762
|
-
|
|
4763
|
-
import_async17.synchronized
|
|
4824
|
+
_ts_decorate7([
|
|
4825
|
+
import_async17.synchronized,
|
|
4826
|
+
import_tracing4.trace.span()
|
|
4764
4827
|
], ClientServicesHost.prototype, "close", null);
|
|
4828
|
+
ClientServicesHost = _ts_decorate7([
|
|
4829
|
+
import_tracing4.trace.resource()
|
|
4830
|
+
], ClientServicesHost);
|
|
4765
4831
|
|
|
4766
4832
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
4767
4833
|
var import_async19 = require("@dxos/async");
|
|
4768
4834
|
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
4835
|
+
var import_context11 = require("@dxos/context");
|
|
4769
4836
|
var import_log17 = require("@dxos/log");
|
|
4770
4837
|
var import_messaging2 = require("@dxos/messaging");
|
|
4771
4838
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
4772
|
-
var
|
|
4839
|
+
var import_util11 = require("@dxos/util");
|
|
4773
4840
|
|
|
4774
4841
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
4775
4842
|
var import_async18 = require("@dxos/async");
|
|
@@ -4833,14 +4900,13 @@ var ShellRuntimeImpl = class {
|
|
|
4833
4900
|
await this._appRpc.open();
|
|
4834
4901
|
}
|
|
4835
4902
|
async close() {
|
|
4836
|
-
|
|
4837
|
-
await ((_a = this._appRpc) == null ? void 0 : _a.close());
|
|
4903
|
+
await this._appRpc?.close();
|
|
4838
4904
|
this._appRpc = void 0;
|
|
4839
4905
|
}
|
|
4840
4906
|
};
|
|
4841
4907
|
|
|
4842
4908
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
4843
|
-
function
|
|
4909
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
4844
4910
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4845
4911
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4846
4912
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4870,15 +4936,14 @@ var IFrameHostRuntime = class {
|
|
|
4870
4936
|
return this._shellRuntime;
|
|
4871
4937
|
}
|
|
4872
4938
|
async start() {
|
|
4873
|
-
var _a;
|
|
4874
4939
|
(0, import_log17.log)("starting...", void 0, {
|
|
4875
4940
|
F: __dxlog_file19,
|
|
4876
|
-
L:
|
|
4941
|
+
L: 71,
|
|
4877
4942
|
S: this,
|
|
4878
4943
|
C: (f, a) => f(...a)
|
|
4879
4944
|
});
|
|
4880
4945
|
try {
|
|
4881
|
-
this._config = await (0,
|
|
4946
|
+
this._config = await (0, import_util11.getAsyncValue)(this._configProvider);
|
|
4882
4947
|
this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)({
|
|
4883
4948
|
iceServers: this._config.get("runtime.services.ice")
|
|
4884
4949
|
});
|
|
@@ -4915,14 +4980,14 @@ var IFrameHostRuntime = class {
|
|
|
4915
4980
|
...middleware
|
|
4916
4981
|
});
|
|
4917
4982
|
await Promise.all([
|
|
4918
|
-
this._clientServices.open(),
|
|
4983
|
+
this._clientServices.open(new import_context11.Context()),
|
|
4919
4984
|
this._clientRpc.open(),
|
|
4920
|
-
|
|
4985
|
+
this._shellRuntime?.open()
|
|
4921
4986
|
]);
|
|
4922
4987
|
this._ready.wake(void 0);
|
|
4923
4988
|
(0, import_log17.log)("started", void 0, {
|
|
4924
4989
|
F: __dxlog_file19,
|
|
4925
|
-
L:
|
|
4990
|
+
L: 114,
|
|
4926
4991
|
S: this,
|
|
4927
4992
|
C: (f, a) => f(...a)
|
|
4928
4993
|
});
|
|
@@ -4930,32 +4995,31 @@ var IFrameHostRuntime = class {
|
|
|
4930
4995
|
this._ready.wake(err);
|
|
4931
4996
|
import_log17.log.catch(err, void 0, {
|
|
4932
4997
|
F: __dxlog_file19,
|
|
4933
|
-
L:
|
|
4998
|
+
L: 117,
|
|
4934
4999
|
S: this,
|
|
4935
5000
|
C: (f, a) => f(...a)
|
|
4936
5001
|
});
|
|
4937
5002
|
}
|
|
4938
5003
|
}
|
|
4939
5004
|
async stop() {
|
|
4940
|
-
var _a;
|
|
4941
5005
|
(0, import_log17.log)("stopping...", void 0, {
|
|
4942
5006
|
F: __dxlog_file19,
|
|
4943
|
-
L:
|
|
5007
|
+
L: 122,
|
|
4944
5008
|
S: this,
|
|
4945
5009
|
C: (f, a) => f(...a)
|
|
4946
5010
|
});
|
|
4947
5011
|
await this._clientRpc.close();
|
|
4948
5012
|
await this._clientServices.close();
|
|
4949
|
-
await
|
|
5013
|
+
await this._shellRuntime?.close();
|
|
4950
5014
|
(0, import_log17.log)("stopped", void 0, {
|
|
4951
5015
|
F: __dxlog_file19,
|
|
4952
|
-
L:
|
|
5016
|
+
L: 126,
|
|
4953
5017
|
S: this,
|
|
4954
5018
|
C: (f, a) => f(...a)
|
|
4955
5019
|
});
|
|
4956
5020
|
}
|
|
4957
5021
|
};
|
|
4958
|
-
|
|
5022
|
+
_ts_decorate8([
|
|
4959
5023
|
import_log17.logInfo
|
|
4960
5024
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
4961
5025
|
|
|
@@ -4966,7 +5030,7 @@ var import_errors6 = require("@dxos/errors");
|
|
|
4966
5030
|
var import_log18 = require("@dxos/log");
|
|
4967
5031
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
4968
5032
|
var import_rpc3 = require("@dxos/rpc");
|
|
4969
|
-
var
|
|
5033
|
+
var import_util12 = require("@dxos/util");
|
|
4970
5034
|
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts";
|
|
4971
5035
|
var IFrameProxyRuntime = class {
|
|
4972
5036
|
constructor({ config, systemPort, shellPort }) {
|
|
@@ -4983,8 +5047,7 @@ var IFrameProxyRuntime = class {
|
|
|
4983
5047
|
return this._shellRuntime;
|
|
4984
5048
|
}
|
|
4985
5049
|
async open(origin) {
|
|
4986
|
-
|
|
4987
|
-
this._config = await (0, import_util11.getAsyncValue)(this._configProvider);
|
|
5050
|
+
this._config = await (0, import_util12.getAsyncValue)(this._configProvider);
|
|
4988
5051
|
this._transportService = new import_network_manager4.WebRTCTransportService({
|
|
4989
5052
|
iceServers: this._config.get("runtime.services.ice")
|
|
4990
5053
|
});
|
|
@@ -5023,12 +5086,11 @@ var IFrameProxyRuntime = class {
|
|
|
5023
5086
|
});
|
|
5024
5087
|
throw new import_errors6.RemoteServiceConnectionError("Failed to connect to worker");
|
|
5025
5088
|
}
|
|
5026
|
-
await
|
|
5089
|
+
await this._shellRuntime?.open();
|
|
5027
5090
|
}
|
|
5028
5091
|
async close() {
|
|
5029
|
-
var _a;
|
|
5030
5092
|
this._release.wake();
|
|
5031
|
-
await
|
|
5093
|
+
await this._shellRuntime?.close();
|
|
5032
5094
|
await this._systemRpc.rpc.WorkerService.stop();
|
|
5033
5095
|
await this._systemRpc.close();
|
|
5034
5096
|
}
|
|
@@ -5039,6 +5101,7 @@ var IFrameProxyRuntime = class {
|
|
|
5039
5101
|
|
|
5040
5102
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
5041
5103
|
var import_async22 = require("@dxos/async");
|
|
5104
|
+
var import_context12 = require("@dxos/context");
|
|
5042
5105
|
var import_log20 = require("@dxos/log");
|
|
5043
5106
|
var import_messaging3 = require("@dxos/messaging");
|
|
5044
5107
|
var import_network_manager5 = require("@dxos/network-manager");
|
|
@@ -5049,8 +5112,8 @@ var import_client_protocol9 = require("@dxos/client-protocol");
|
|
|
5049
5112
|
var import_invariant16 = require("@dxos/invariant");
|
|
5050
5113
|
var import_log19 = require("@dxos/log");
|
|
5051
5114
|
var import_rpc4 = require("@dxos/rpc");
|
|
5052
|
-
var
|
|
5053
|
-
function
|
|
5115
|
+
var import_util13 = require("@dxos/util");
|
|
5116
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
5054
5117
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5055
5118
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
5056
5119
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5064,7 +5127,7 @@ var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
5064
5127
|
var WorkerSession = class {
|
|
5065
5128
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
5066
5129
|
this._startTrigger = new import_async21.Trigger();
|
|
5067
|
-
this.onClose = new
|
|
5130
|
+
this.onClose = new import_util13.Callback();
|
|
5068
5131
|
(0, import_invariant16.invariant)(serviceHost, void 0, {
|
|
5069
5132
|
F: __dxlog_file21,
|
|
5070
5133
|
L: 49,
|
|
@@ -5192,7 +5255,7 @@ var WorkerSession = class {
|
|
|
5192
5255
|
async _maybeOpenShell() {
|
|
5193
5256
|
try {
|
|
5194
5257
|
await (0, import_async21.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
5195
|
-
} catch
|
|
5258
|
+
} catch {
|
|
5196
5259
|
import_log19.log.info("No shell connected.", void 0, {
|
|
5197
5260
|
F: __dxlog_file21,
|
|
5198
5261
|
L: 143,
|
|
@@ -5206,10 +5269,10 @@ var WorkerSession = class {
|
|
|
5206
5269
|
}).then(callback);
|
|
5207
5270
|
}
|
|
5208
5271
|
};
|
|
5209
|
-
|
|
5272
|
+
_ts_decorate9([
|
|
5210
5273
|
import_log19.logInfo
|
|
5211
5274
|
], WorkerSession.prototype, "origin", void 0);
|
|
5212
|
-
|
|
5275
|
+
_ts_decorate9([
|
|
5213
5276
|
import_log19.logInfo
|
|
5214
5277
|
], WorkerSession.prototype, "lockKey", void 0);
|
|
5215
5278
|
|
|
@@ -5236,7 +5299,7 @@ var WorkerRuntime = class {
|
|
|
5236
5299
|
async start() {
|
|
5237
5300
|
(0, import_log20.log)("starting...", void 0, {
|
|
5238
5301
|
F: __dxlog_file22,
|
|
5239
|
-
L:
|
|
5302
|
+
L: 49,
|
|
5240
5303
|
S: this,
|
|
5241
5304
|
C: (f, a) => f(...a)
|
|
5242
5305
|
});
|
|
@@ -5248,19 +5311,19 @@ var WorkerRuntime = class {
|
|
|
5248
5311
|
signalManager: signals ? new import_messaging3.WebsocketSignalManager(signals) : new import_messaging3.MemorySignalManager(new import_messaging3.MemorySignalManagerContext()),
|
|
5249
5312
|
transportFactory: this._transportFactory
|
|
5250
5313
|
});
|
|
5251
|
-
await this._clientServices.open();
|
|
5314
|
+
await this._clientServices.open(new import_context12.Context());
|
|
5252
5315
|
this._ready.wake(void 0);
|
|
5253
5316
|
(0, import_log20.log)("started", void 0, {
|
|
5254
5317
|
F: __dxlog_file22,
|
|
5255
|
-
L:
|
|
5318
|
+
L: 63,
|
|
5256
5319
|
S: this,
|
|
5257
5320
|
C: (f, a) => f(...a)
|
|
5258
5321
|
});
|
|
5259
5322
|
} catch (err) {
|
|
5260
5323
|
this._ready.wake(err);
|
|
5261
|
-
import_log20.log.
|
|
5324
|
+
import_log20.log.error("starting", err, {
|
|
5262
5325
|
F: __dxlog_file22,
|
|
5263
|
-
L:
|
|
5326
|
+
L: 66,
|
|
5264
5327
|
S: this,
|
|
5265
5328
|
C: (f, a) => f(...a)
|
|
5266
5329
|
});
|
|
@@ -5294,7 +5357,7 @@ var WorkerRuntime = class {
|
|
|
5294
5357
|
_reconnectWebrtc() {
|
|
5295
5358
|
(0, import_log20.log)("reconnecting webrtc...", void 0, {
|
|
5296
5359
|
F: __dxlog_file22,
|
|
5297
|
-
L:
|
|
5360
|
+
L: 103,
|
|
5298
5361
|
S: this,
|
|
5299
5362
|
C: (f, a) => f(...a)
|
|
5300
5363
|
});
|