@dxos/client-services 0.1.56-main.09ca29d → 0.1.56-main.0e9f69e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-FD4L7N4K.mjs → chunk-II6TDINB.mjs} +782 -511
- package/dist/lib/browser/chunk-II6TDINB.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +30 -31
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +31 -46
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +918 -649
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +1198 -939
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts +7 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +7 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/services/index.d.ts +1 -0
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/platform.d.ts +16 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-context.d.ts +2 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +7 -3
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +6 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +12 -2
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +2 -0
- package/dist/types/src/version.d.ts.map +1 -0
- package/package.json +34 -33
- package/src/packlets/devices/devices-service.test.ts +2 -1
- package/src/packlets/identity/identity-manager.test.ts +15 -3
- package/src/packlets/identity/identity-manager.ts +27 -6
- package/src/packlets/identity/identity-service.test.ts +17 -2
- package/src/packlets/identity/identity-service.ts +23 -14
- package/src/packlets/identity/identity.test.ts +7 -6
- package/src/packlets/identity/identity.ts +8 -3
- package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
- package/src/packlets/logging/logging-service.ts +17 -9
- package/src/packlets/network/network-service.test.ts +2 -1
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/diagnostics.ts +211 -0
- package/src/packlets/services/index.ts +1 -0
- package/src/packlets/services/platform.ts +48 -0
- package/src/packlets/services/service-context.test.ts +59 -0
- package/src/packlets/services/service-context.ts +16 -9
- package/src/packlets/services/service-host.test.ts +11 -10
- package/src/packlets/services/service-host.ts +38 -18
- package/src/packlets/services/service-registry.test.ts +3 -1
- package/src/packlets/services/util.ts +33 -0
- package/src/packlets/spaces/data-space-manager.test.ts +80 -22
- package/src/packlets/spaces/data-space.ts +17 -5
- package/src/packlets/spaces/spaces-service.test.ts +2 -1
- package/src/packlets/system/system-service.test.ts +1 -0
- package/src/packlets/system/system-service.ts +34 -2
- package/src/packlets/testing/test-builder.ts +1 -1
- package/src/packlets/vault/iframe-host-runtime.ts +2 -1
- package/src/packlets/vault/worker-runtime.ts +3 -2
- package/src/packlets/vault/worker-session.ts +6 -1
- package/src/version.ts +1 -0
- package/dist/lib/browser/chunk-FD4L7N4K.mjs.map +0 -7
|
@@ -12,7 +12,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
12
12
|
const feedMap = new ComplexMap(PublicKey.hash);
|
|
13
13
|
const update = () => {
|
|
14
14
|
const { feeds } = feedStore;
|
|
15
|
-
feeds.filter((feed) => !
|
|
15
|
+
feeds.filter((feed) => !feedKeys?.length || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
|
|
16
16
|
if (!feedMap.has(feed.key)) {
|
|
17
17
|
feedMap.set(feed.key, feed);
|
|
18
18
|
feed.on("close", update);
|
|
@@ -20,15 +20,12 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
next({
|
|
23
|
-
feeds: Array.from(feedMap.values()).map((feed) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
downloaded: (_b = (_a = feed.core.bitfield) == null ? void 0 : _a.data.toBuffer()) != null ? _b : new Uint8Array()
|
|
30
|
-
};
|
|
31
|
-
})
|
|
23
|
+
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
24
|
+
feedKey: feed.key,
|
|
25
|
+
length: feed.properties.length,
|
|
26
|
+
bytes: feed.core.byteLength,
|
|
27
|
+
downloaded: feed.core.bitfield?.data.toBuffer() ?? new Uint8Array()
|
|
28
|
+
}))
|
|
32
29
|
});
|
|
33
30
|
};
|
|
34
31
|
subscriptions.add(feedStore.feedOpened.on(update));
|
|
@@ -104,13 +101,13 @@ var subscribeToSignal = ({ signalManager }) => new Stream2(({ next }) => {
|
|
|
104
101
|
recipient: message.recipient.asUint8Array(),
|
|
105
102
|
payload: message.payload
|
|
106
103
|
},
|
|
107
|
-
receivedAt: new Date()
|
|
104
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
108
105
|
});
|
|
109
106
|
});
|
|
110
107
|
signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
111
108
|
next({
|
|
112
109
|
swarmEvent: swarmEvent.swarmEvent,
|
|
113
|
-
receivedAt: new Date()
|
|
110
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
114
111
|
});
|
|
115
112
|
});
|
|
116
113
|
return () => {
|
|
@@ -121,13 +118,10 @@ var subscribeToNetworkTopics = ({ networkManager }) => new Stream2(({ next, clos
|
|
|
121
118
|
const update = () => {
|
|
122
119
|
try {
|
|
123
120
|
const topics = networkManager.topics;
|
|
124
|
-
const labeledTopics = topics.map((topic) => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
label: (_b = (_a = networkManager.getSwarm(topic)) == null ? void 0 : _a.label) != null ? _b : topic.toHex()
|
|
129
|
-
};
|
|
130
|
-
});
|
|
121
|
+
const labeledTopics = topics.map((topic) => ({
|
|
122
|
+
topic,
|
|
123
|
+
label: networkManager.getSwarm(topic)?.label ?? topic.toHex()
|
|
124
|
+
}));
|
|
131
125
|
next({
|
|
132
126
|
topics: labeledTopics
|
|
133
127
|
});
|
|
@@ -139,17 +133,15 @@ var subscribeToNetworkTopics = ({ networkManager }) => new Stream2(({ next, clos
|
|
|
139
133
|
update();
|
|
140
134
|
});
|
|
141
135
|
var subscribeToSwarmInfo = ({ networkManager }) => new Stream2(({ next }) => {
|
|
142
|
-
var _a;
|
|
143
136
|
const update = () => {
|
|
144
|
-
|
|
145
|
-
const info = (_a2 = networkManager.connectionLog) == null ? void 0 : _a2.swarms;
|
|
137
|
+
const info = networkManager.connectionLog?.swarms;
|
|
146
138
|
if (info) {
|
|
147
139
|
next({
|
|
148
140
|
data: info
|
|
149
141
|
});
|
|
150
142
|
}
|
|
151
143
|
};
|
|
152
|
-
|
|
144
|
+
networkManager.connectionLog?.update.on(update);
|
|
153
145
|
update();
|
|
154
146
|
});
|
|
155
147
|
var getNetworkPeers = ({ networkManager }, request) => {
|
|
@@ -158,7 +150,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
|
|
|
158
150
|
}
|
|
159
151
|
const map = networkManager.getSwarmMap(PublicKey2.from(request.topic));
|
|
160
152
|
return {
|
|
161
|
-
peers: map
|
|
153
|
+
peers: map?.peers.map((peer) => ({
|
|
162
154
|
...peer,
|
|
163
155
|
connections: peer.connections.map((connection) => connection.asUint8Array())
|
|
164
156
|
}))
|
|
@@ -174,14 +166,14 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
174
166
|
const spaces = [
|
|
175
167
|
...context.spaceManager.spaces.values()
|
|
176
168
|
];
|
|
177
|
-
const filteredSpaces = spaces.filter((space) => !
|
|
169
|
+
const filteredSpaces = spaces.filter((space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
|
|
178
170
|
next({
|
|
179
171
|
spaces: filteredSpaces.map((space) => {
|
|
180
172
|
const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata2) => spaceMetadata2.key.equals(space.key));
|
|
181
173
|
return {
|
|
182
174
|
key: space.key,
|
|
183
175
|
isOpen: space.isOpen,
|
|
184
|
-
timeframe: spaceMetadata
|
|
176
|
+
timeframe: spaceMetadata?.dataTimeframe,
|
|
185
177
|
genesisFeed: space.genesisFeedKey,
|
|
186
178
|
controlFeed: space.controlFeedKey,
|
|
187
179
|
dataFeed: space.dataFeedKey
|
|
@@ -195,7 +187,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
195
187
|
await update();
|
|
196
188
|
});
|
|
197
189
|
return () => {
|
|
198
|
-
unsubscribe
|
|
190
|
+
unsubscribe?.();
|
|
199
191
|
clearTimeout(timeout);
|
|
200
192
|
};
|
|
201
193
|
});
|
|
@@ -254,16 +246,15 @@ var DevtoolsServiceImpl = class {
|
|
|
254
246
|
};
|
|
255
247
|
}
|
|
256
248
|
async getStorageInfo() {
|
|
257
|
-
|
|
258
|
-
const storageUsage = (_c = await ((_b = (_a = this.params.context.storage).getDiskInfo) == null ? void 0 : _b.call(_a))) != null ? _c : {
|
|
249
|
+
const storageUsage = await this.params.context.storage.getDiskInfo?.() ?? {
|
|
259
250
|
used: 0
|
|
260
251
|
};
|
|
261
252
|
const navigatorInfo = typeof navigator === "object" ? await navigator.storage.estimate() : void 0;
|
|
262
253
|
return {
|
|
263
254
|
type: this.params.context.storage.type,
|
|
264
255
|
storageUsage: storageUsage.used,
|
|
265
|
-
originUsage:
|
|
266
|
-
usageQuota:
|
|
256
|
+
originUsage: navigatorInfo?.usage ?? 0,
|
|
257
|
+
usageQuota: navigatorInfo?.quota ?? 0
|
|
267
258
|
};
|
|
268
259
|
}
|
|
269
260
|
async getBlobs() {
|
|
@@ -449,7 +440,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
449
440
|
return await trigger.wait({
|
|
450
441
|
timeout: this._params.authTimeout
|
|
451
442
|
});
|
|
452
|
-
} catch
|
|
443
|
+
} catch {
|
|
453
444
|
return false;
|
|
454
445
|
} finally {
|
|
455
446
|
clear();
|
|
@@ -471,8 +462,19 @@ import { writeMessages } from "@dxos/feed-store";
|
|
|
471
462
|
import { invariant } from "@dxos/invariant";
|
|
472
463
|
import { log as log2 } from "@dxos/log";
|
|
473
464
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
465
|
+
import { trace } from "@dxos/tracing";
|
|
466
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
467
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
468
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
469
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
470
|
+
else
|
|
471
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
472
|
+
if (d = decorators[i])
|
|
473
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
474
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
475
|
+
}
|
|
474
476
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
475
|
-
var Identity = class {
|
|
477
|
+
var Identity = class Identity2 {
|
|
476
478
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
477
479
|
this.stateUpdate = new Event();
|
|
478
480
|
this.space = space;
|
|
@@ -498,12 +500,12 @@ var Identity = class {
|
|
|
498
500
|
get authorizedDeviceKeys() {
|
|
499
501
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
500
502
|
}
|
|
501
|
-
async open() {
|
|
503
|
+
async open(ctx) {
|
|
502
504
|
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
503
505
|
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
504
|
-
await this.space.open();
|
|
506
|
+
await this.space.open(ctx);
|
|
505
507
|
}
|
|
506
|
-
async close() {
|
|
508
|
+
async close(ctx) {
|
|
507
509
|
await this.authVerifier.close();
|
|
508
510
|
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
509
511
|
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
@@ -534,11 +536,10 @@ var Identity = class {
|
|
|
534
536
|
return this._deviceStateMachine.deviceCredentialChain;
|
|
535
537
|
}
|
|
536
538
|
getAdmissionCredentials() {
|
|
537
|
-
var _a, _b;
|
|
538
539
|
return {
|
|
539
540
|
deviceKey: this.deviceKey,
|
|
540
|
-
controlFeedKey:
|
|
541
|
-
dataFeedKey:
|
|
541
|
+
controlFeedKey: this.space.controlFeedKey ?? failUndefined(),
|
|
542
|
+
dataFeedKey: this.space.dataFeedKey ?? failUndefined()
|
|
542
543
|
};
|
|
543
544
|
}
|
|
544
545
|
/**
|
|
@@ -548,7 +549,7 @@ var Identity = class {
|
|
|
548
549
|
getIdentityCredentialSigner() {
|
|
549
550
|
invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
550
551
|
F: __dxlog_file2,
|
|
551
|
-
L:
|
|
552
|
+
L: 139,
|
|
552
553
|
S: this,
|
|
553
554
|
A: [
|
|
554
555
|
"this._deviceStateMachine.deviceCredentialChain",
|
|
@@ -572,7 +573,7 @@ var Identity = class {
|
|
|
572
573
|
dataFeedKey
|
|
573
574
|
}, {
|
|
574
575
|
F: __dxlog_file2,
|
|
575
|
-
L:
|
|
576
|
+
L: 155,
|
|
576
577
|
S: this,
|
|
577
578
|
C: (f, a) => f(...a)
|
|
578
579
|
});
|
|
@@ -613,18 +614,40 @@ var Identity = class {
|
|
|
613
614
|
})));
|
|
614
615
|
}
|
|
615
616
|
};
|
|
617
|
+
_ts_decorate([
|
|
618
|
+
trace.span()
|
|
619
|
+
], Identity.prototype, "open", null);
|
|
620
|
+
_ts_decorate([
|
|
621
|
+
trace.span()
|
|
622
|
+
], Identity.prototype, "close", null);
|
|
623
|
+
Identity = _ts_decorate([
|
|
624
|
+
trace.resource()
|
|
625
|
+
], Identity);
|
|
616
626
|
|
|
617
627
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
618
628
|
import { Event as Event2 } from "@dxos/async";
|
|
629
|
+
import { Context as Context3 } from "@dxos/context";
|
|
619
630
|
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
|
|
620
631
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
621
632
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
622
633
|
import { log as log3 } from "@dxos/log";
|
|
623
|
-
import { trace } from "@dxos/protocols";
|
|
634
|
+
import { trace as trace2 } from "@dxos/protocols";
|
|
624
635
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
636
|
+
import { Timeframe } from "@dxos/timeframe";
|
|
637
|
+
import { trace as Trace } from "@dxos/tracing";
|
|
625
638
|
import { deferFunction } from "@dxos/util";
|
|
639
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
640
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
641
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
642
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
643
|
+
else
|
|
644
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
645
|
+
if (d = decorators[i])
|
|
646
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
647
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
648
|
+
}
|
|
626
649
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
627
|
-
var IdentityManager = class {
|
|
650
|
+
var IdentityManager = class IdentityManager2 {
|
|
628
651
|
// TODO(burdon): IdentityManagerParams.
|
|
629
652
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
630
653
|
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
@@ -637,14 +660,13 @@ var IdentityManager = class {
|
|
|
637
660
|
get identity() {
|
|
638
661
|
return this._identity;
|
|
639
662
|
}
|
|
640
|
-
async open() {
|
|
641
|
-
var _a;
|
|
663
|
+
async open(ctx) {
|
|
642
664
|
const traceId = PublicKey3.random().toHex();
|
|
643
|
-
log3.trace("dxos.halo.identity-manager.open",
|
|
665
|
+
log3.trace("dxos.halo.identity-manager.open", trace2.begin({
|
|
644
666
|
id: traceId
|
|
645
667
|
}), {
|
|
646
668
|
F: __dxlog_file3,
|
|
647
|
-
L:
|
|
669
|
+
L: 73,
|
|
648
670
|
S: this,
|
|
649
671
|
C: (f, a) => f(...a)
|
|
650
672
|
});
|
|
@@ -654,43 +676,41 @@ var IdentityManager = class {
|
|
|
654
676
|
identityRecord
|
|
655
677
|
}, {
|
|
656
678
|
F: __dxlog_file3,
|
|
657
|
-
L:
|
|
679
|
+
L: 77,
|
|
658
680
|
S: this,
|
|
659
681
|
C: (f, a) => f(...a)
|
|
660
682
|
});
|
|
661
683
|
if (identityRecord) {
|
|
662
684
|
this._identity = await this._constructIdentity(identityRecord);
|
|
663
|
-
await this._identity.open();
|
|
685
|
+
await this._identity.open(ctx);
|
|
664
686
|
await this._identity.ready();
|
|
665
687
|
log3.trace("dxos.halo.identity", {
|
|
666
688
|
identityKey: identityRecord.identityKey,
|
|
667
|
-
displayName:
|
|
689
|
+
displayName: this._identity.profileDocument?.displayName
|
|
668
690
|
}, {
|
|
669
691
|
F: __dxlog_file3,
|
|
670
|
-
L:
|
|
692
|
+
L: 82,
|
|
671
693
|
S: this,
|
|
672
694
|
C: (f, a) => f(...a)
|
|
673
695
|
});
|
|
674
696
|
this.stateUpdate.emit();
|
|
675
697
|
}
|
|
676
|
-
log3.trace("dxos.halo.identity-manager.open",
|
|
698
|
+
log3.trace("dxos.halo.identity-manager.open", trace2.end({
|
|
677
699
|
id: traceId
|
|
678
700
|
}), {
|
|
679
701
|
F: __dxlog_file3,
|
|
680
|
-
L:
|
|
702
|
+
L: 88,
|
|
681
703
|
S: this,
|
|
682
704
|
C: (f, a) => f(...a)
|
|
683
705
|
});
|
|
684
706
|
}
|
|
685
707
|
async close() {
|
|
686
|
-
|
|
687
|
-
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
708
|
+
await this._identity?.close(new Context3());
|
|
688
709
|
}
|
|
689
710
|
async createIdentity({ displayName } = {}) {
|
|
690
|
-
var _a;
|
|
691
711
|
invariant2(!this._identity, "Identity already exists.", {
|
|
692
712
|
F: __dxlog_file3,
|
|
693
|
-
L:
|
|
713
|
+
L: 96,
|
|
694
714
|
S: this,
|
|
695
715
|
A: [
|
|
696
716
|
"!this._identity",
|
|
@@ -699,7 +719,7 @@ var IdentityManager = class {
|
|
|
699
719
|
});
|
|
700
720
|
log3("creating identity...", void 0, {
|
|
701
721
|
F: __dxlog_file3,
|
|
702
|
-
L:
|
|
722
|
+
L: 97,
|
|
703
723
|
S: this,
|
|
704
724
|
C: (f, a) => f(...a)
|
|
705
725
|
});
|
|
@@ -715,12 +735,12 @@ var IdentityManager = class {
|
|
|
715
735
|
}
|
|
716
736
|
};
|
|
717
737
|
const identity = await this._constructIdentity(identityRecord);
|
|
718
|
-
await identity.open();
|
|
738
|
+
await identity.open(new Context3());
|
|
719
739
|
{
|
|
720
740
|
const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
721
741
|
invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
722
742
|
F: __dxlog_file3,
|
|
723
|
-
L:
|
|
743
|
+
L: 116,
|
|
724
744
|
S: this,
|
|
725
745
|
A: [
|
|
726
746
|
"identityRecord.haloSpace.genesisFeedKey",
|
|
@@ -729,7 +749,7 @@ var IdentityManager = class {
|
|
|
729
749
|
});
|
|
730
750
|
invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
731
751
|
F: __dxlog_file3,
|
|
732
|
-
L:
|
|
752
|
+
L: 117,
|
|
733
753
|
S: this,
|
|
734
754
|
A: [
|
|
735
755
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -761,10 +781,10 @@ var IdentityManager = class {
|
|
|
761
781
|
await this._identity.ready();
|
|
762
782
|
log3.trace("dxos.halo.identity", {
|
|
763
783
|
identityKey: identityRecord.identityKey,
|
|
764
|
-
displayName:
|
|
784
|
+
displayName: this._identity.profileDocument?.displayName
|
|
765
785
|
}, {
|
|
766
786
|
F: __dxlog_file3,
|
|
767
|
-
L:
|
|
787
|
+
L: 152,
|
|
768
788
|
S: this,
|
|
769
789
|
C: (f, a) => f(...a)
|
|
770
790
|
});
|
|
@@ -774,7 +794,7 @@ var IdentityManager = class {
|
|
|
774
794
|
deviceKey: identity.deviceKey
|
|
775
795
|
}, {
|
|
776
796
|
F: __dxlog_file3,
|
|
777
|
-
L:
|
|
797
|
+
L: 158,
|
|
778
798
|
S: this,
|
|
779
799
|
C: (f, a) => f(...a)
|
|
780
800
|
});
|
|
@@ -784,18 +804,17 @@ var IdentityManager = class {
|
|
|
784
804
|
* Accept an existing identity. Expects it's device key to be authorized (now or later).
|
|
785
805
|
*/
|
|
786
806
|
async acceptIdentity(params) {
|
|
787
|
-
var _a;
|
|
788
807
|
log3("accepting identity", {
|
|
789
808
|
params
|
|
790
809
|
}, {
|
|
791
810
|
F: __dxlog_file3,
|
|
792
|
-
L:
|
|
811
|
+
L: 166,
|
|
793
812
|
S: this,
|
|
794
813
|
C: (f, a) => f(...a)
|
|
795
814
|
});
|
|
796
815
|
invariant2(!this._identity, "Identity already exists.", {
|
|
797
816
|
F: __dxlog_file3,
|
|
798
|
-
L:
|
|
817
|
+
L: 167,
|
|
799
818
|
S: this,
|
|
800
819
|
A: [
|
|
801
820
|
"!this._identity",
|
|
@@ -814,16 +833,16 @@ var IdentityManager = class {
|
|
|
814
833
|
}
|
|
815
834
|
};
|
|
816
835
|
const identity = await this._constructIdentity(identityRecord);
|
|
817
|
-
await identity.open();
|
|
836
|
+
await identity.open(new Context3());
|
|
818
837
|
this._identity = identity;
|
|
819
838
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
820
839
|
await this._identity.ready();
|
|
821
840
|
log3.trace("dxos.halo.identity", {
|
|
822
841
|
identityKey: identityRecord.identityKey,
|
|
823
|
-
displayName:
|
|
842
|
+
displayName: this._identity.profileDocument?.displayName
|
|
824
843
|
}, {
|
|
825
844
|
F: __dxlog_file3,
|
|
826
|
-
L:
|
|
845
|
+
L: 186,
|
|
827
846
|
S: this,
|
|
828
847
|
C: (f, a) => f(...a)
|
|
829
848
|
});
|
|
@@ -833,16 +852,48 @@ var IdentityManager = class {
|
|
|
833
852
|
deviceKey: identity.deviceKey
|
|
834
853
|
}, {
|
|
835
854
|
F: __dxlog_file3,
|
|
836
|
-
L:
|
|
855
|
+
L: 192,
|
|
837
856
|
S: this,
|
|
838
857
|
C: (f, a) => f(...a)
|
|
839
858
|
});
|
|
840
859
|
return identity;
|
|
841
860
|
}
|
|
861
|
+
/**
|
|
862
|
+
* Update the profile document of an existing identity.
|
|
863
|
+
*/
|
|
864
|
+
async updateProfile(profile) {
|
|
865
|
+
invariant2(this._identity, "Identity not initialized.", {
|
|
866
|
+
F: __dxlog_file3,
|
|
867
|
+
L: 200,
|
|
868
|
+
S: this,
|
|
869
|
+
A: [
|
|
870
|
+
"this._identity",
|
|
871
|
+
"'Identity not initialized.'"
|
|
872
|
+
]
|
|
873
|
+
});
|
|
874
|
+
const credential = await this._identity.getIdentityCredentialSigner().createCredential({
|
|
875
|
+
subject: this._identity.identityKey,
|
|
876
|
+
assertion: {
|
|
877
|
+
"@type": "dxos.halo.credentials.IdentityProfile",
|
|
878
|
+
profile
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
const receipt = await this._identity.controlPipeline.writer.write({
|
|
882
|
+
credential: {
|
|
883
|
+
credential
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
await this._identity.controlPipeline.state.waitUntilTimeframe(new Timeframe([
|
|
887
|
+
[
|
|
888
|
+
receipt.feedKey,
|
|
889
|
+
receipt.seq
|
|
890
|
+
]
|
|
891
|
+
]));
|
|
892
|
+
}
|
|
842
893
|
async _constructIdentity(identityRecord) {
|
|
843
894
|
invariant2(!this._identity, void 0, {
|
|
844
895
|
F: __dxlog_file3,
|
|
845
|
-
L:
|
|
896
|
+
L: 214,
|
|
846
897
|
S: this,
|
|
847
898
|
A: [
|
|
848
899
|
"!this._identity",
|
|
@@ -853,13 +904,13 @@ var IdentityManager = class {
|
|
|
853
904
|
identityRecord
|
|
854
905
|
}, {
|
|
855
906
|
F: __dxlog_file3,
|
|
856
|
-
L:
|
|
907
|
+
L: 215,
|
|
857
908
|
S: this,
|
|
858
909
|
C: (f, a) => f(...a)
|
|
859
910
|
});
|
|
860
911
|
invariant2(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
861
912
|
F: __dxlog_file3,
|
|
862
|
-
L:
|
|
913
|
+
L: 218,
|
|
863
914
|
S: this,
|
|
864
915
|
A: [
|
|
865
916
|
"identityRecord.haloSpace.controlFeedKey",
|
|
@@ -871,7 +922,7 @@ var IdentityManager = class {
|
|
|
871
922
|
});
|
|
872
923
|
invariant2(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
873
924
|
F: __dxlog_file3,
|
|
874
|
-
L:
|
|
925
|
+
L: 222,
|
|
875
926
|
S: this,
|
|
876
927
|
A: [
|
|
877
928
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -903,7 +954,7 @@ var IdentityManager = class {
|
|
|
903
954
|
identityKey: identityRecord.identityKey
|
|
904
955
|
}, {
|
|
905
956
|
F: __dxlog_file3,
|
|
906
|
-
L:
|
|
957
|
+
L: 246,
|
|
907
958
|
S: this,
|
|
908
959
|
C: (f, a) => f(...a)
|
|
909
960
|
});
|
|
@@ -924,7 +975,7 @@ var IdentityManager = class {
|
|
|
924
975
|
onAuthFailure: () => {
|
|
925
976
|
log3.warn("auth failure", void 0, {
|
|
926
977
|
F: __dxlog_file3,
|
|
927
|
-
L:
|
|
978
|
+
L: 265,
|
|
928
979
|
S: this,
|
|
929
980
|
C: (f, a) => f(...a)
|
|
930
981
|
});
|
|
@@ -933,6 +984,12 @@ var IdentityManager = class {
|
|
|
933
984
|
});
|
|
934
985
|
}
|
|
935
986
|
};
|
|
987
|
+
_ts_decorate2([
|
|
988
|
+
Trace.span()
|
|
989
|
+
], IdentityManager.prototype, "open", null);
|
|
990
|
+
IdentityManager = _ts_decorate2([
|
|
991
|
+
Trace.resource()
|
|
992
|
+
], IdentityManager);
|
|
936
993
|
|
|
937
994
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
938
995
|
import { Stream as Stream7 } from "@dxos/codec-protobuf";
|
|
@@ -941,12 +998,13 @@ import { todo } from "@dxos/debug";
|
|
|
941
998
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
942
999
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
943
1000
|
var IdentityServiceImpl = class {
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
this.
|
|
1001
|
+
constructor(_createIdentity, _identityManager, _keyring) {
|
|
1002
|
+
this._createIdentity = _createIdentity;
|
|
1003
|
+
this._identityManager = _identityManager;
|
|
1004
|
+
this._keyring = _keyring;
|
|
947
1005
|
}
|
|
948
1006
|
async createIdentity(request) {
|
|
949
|
-
await this.
|
|
1007
|
+
await this._createIdentity(request);
|
|
950
1008
|
return this._getIdentity();
|
|
951
1009
|
}
|
|
952
1010
|
async recoverIdentity(request) {
|
|
@@ -958,34 +1016,47 @@ var IdentityServiceImpl = class {
|
|
|
958
1016
|
identity: this._getIdentity()
|
|
959
1017
|
});
|
|
960
1018
|
emitNext();
|
|
961
|
-
return this.
|
|
1019
|
+
return this._identityManager.stateUpdate.on(emitNext);
|
|
962
1020
|
});
|
|
963
1021
|
}
|
|
964
1022
|
_getIdentity() {
|
|
965
|
-
if (!this.
|
|
1023
|
+
if (!this._identityManager.identity) {
|
|
966
1024
|
return void 0;
|
|
967
1025
|
}
|
|
968
1026
|
return {
|
|
969
|
-
identityKey: this.
|
|
970
|
-
spaceKey: this.
|
|
971
|
-
profile: this.
|
|
1027
|
+
identityKey: this._identityManager.identity.identityKey,
|
|
1028
|
+
spaceKey: this._identityManager.identity.space.key,
|
|
1029
|
+
profile: this._identityManager.identity.profileDocument
|
|
972
1030
|
};
|
|
973
1031
|
}
|
|
1032
|
+
async updateProfile(profile) {
|
|
1033
|
+
invariant3(this._identityManager.identity, "Identity not initialized.", {
|
|
1034
|
+
F: __dxlog_file4,
|
|
1035
|
+
L: 59,
|
|
1036
|
+
S: this,
|
|
1037
|
+
A: [
|
|
1038
|
+
"this._identityManager.identity",
|
|
1039
|
+
"'Identity not initialized.'"
|
|
1040
|
+
]
|
|
1041
|
+
});
|
|
1042
|
+
await this._identityManager.updateProfile(profile);
|
|
1043
|
+
return this._getIdentity();
|
|
1044
|
+
}
|
|
974
1045
|
async signPresentation({ presentation, nonce }) {
|
|
975
|
-
invariant3(this.
|
|
1046
|
+
invariant3(this._identityManager.identity, "Identity not initialized.", {
|
|
976
1047
|
F: __dxlog_file4,
|
|
977
|
-
L:
|
|
1048
|
+
L: 65,
|
|
978
1049
|
S: this,
|
|
979
1050
|
A: [
|
|
980
|
-
"this.
|
|
1051
|
+
"this._identityManager.identity",
|
|
981
1052
|
"'Identity not initialized.'"
|
|
982
1053
|
]
|
|
983
1054
|
});
|
|
984
1055
|
return await signPresentation({
|
|
985
1056
|
presentation,
|
|
986
|
-
signer: this.
|
|
987
|
-
signerKey: this.
|
|
988
|
-
chain: this.
|
|
1057
|
+
signer: this._keyring,
|
|
1058
|
+
signerKey: this._identityManager.identity.deviceKey,
|
|
1059
|
+
chain: this._identityManager.identity.deviceCredentialChain,
|
|
989
1060
|
nonce
|
|
990
1061
|
});
|
|
991
1062
|
}
|
|
@@ -1084,25 +1155,25 @@ var DeviceInvitationProtocol = class {
|
|
|
1084
1155
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1085
1156
|
import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
|
|
1086
1157
|
import { AuthenticatingInvitationObservable, AUTHENTICATION_CODE_LENGTH, CancellableInvitationObservable, INVITATION_TIMEOUT } from "@dxos/client-protocol";
|
|
1087
|
-
import { Context as
|
|
1158
|
+
import { Context as Context5 } from "@dxos/context";
|
|
1088
1159
|
import { generatePasscode } from "@dxos/credentials";
|
|
1089
1160
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2 } from "@dxos/errors";
|
|
1090
1161
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1091
1162
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1092
1163
|
import { log as log5 } from "@dxos/log";
|
|
1093
1164
|
import { createTeleportProtocolFactory, StarTopology } from "@dxos/network-manager";
|
|
1094
|
-
import { trace as
|
|
1165
|
+
import { trace as trace4 } from "@dxos/protocols";
|
|
1095
1166
|
import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1096
1167
|
import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1097
1168
|
|
|
1098
1169
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
1099
1170
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
1100
|
-
import { cancelWithContext, Context as
|
|
1171
|
+
import { cancelWithContext, Context as Context4 } from "@dxos/context";
|
|
1101
1172
|
import { InvalidInvitationExtensionRoleError } from "@dxos/errors";
|
|
1102
1173
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1103
1174
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1104
1175
|
import { log as log4 } from "@dxos/log";
|
|
1105
|
-
import { schema as schema2, trace as
|
|
1176
|
+
import { schema as schema2, trace as trace3 } from "@dxos/protocols";
|
|
1106
1177
|
import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1107
1178
|
import { AuthenticationResponse, Options } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1108
1179
|
import { RpcExtension } from "@dxos/teleport";
|
|
@@ -1120,7 +1191,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1120
1191
|
}
|
|
1121
1192
|
});
|
|
1122
1193
|
this._callbacks = _callbacks;
|
|
1123
|
-
this._ctx = new
|
|
1194
|
+
this._ctx = new Context4();
|
|
1124
1195
|
this._remoteOptionsTrigger = new Trigger2();
|
|
1125
1196
|
this.invitation = void 0;
|
|
1126
1197
|
this.guestProfile = void 0;
|
|
@@ -1149,7 +1220,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1149
1220
|
introduce: async (request) => {
|
|
1150
1221
|
const { profile, invitationId } = request;
|
|
1151
1222
|
const traceId = PublicKey4.random().toHex();
|
|
1152
|
-
log4.trace("dxos.sdk.invitation-handler.host.introduce",
|
|
1223
|
+
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.begin({
|
|
1153
1224
|
id: traceId
|
|
1154
1225
|
}), {
|
|
1155
1226
|
F: __dxlog_file6,
|
|
@@ -1186,7 +1257,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1186
1257
|
...this.invitation,
|
|
1187
1258
|
state: Invitation2.State.READY_FOR_AUTHENTICATION
|
|
1188
1259
|
});
|
|
1189
|
-
log4.trace("dxos.sdk.invitation-handler.host.introduce",
|
|
1260
|
+
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.end({
|
|
1190
1261
|
id: traceId
|
|
1191
1262
|
}), {
|
|
1192
1263
|
F: __dxlog_file6,
|
|
@@ -1201,7 +1272,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1201
1272
|
},
|
|
1202
1273
|
authenticate: async ({ authCode: code }) => {
|
|
1203
1274
|
const traceId = PublicKey4.random().toHex();
|
|
1204
|
-
log4.trace("dxos.sdk.invitation-handler.host.authenticate",
|
|
1275
|
+
log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.begin({
|
|
1205
1276
|
id: traceId
|
|
1206
1277
|
}), {
|
|
1207
1278
|
F: __dxlog_file6,
|
|
@@ -1264,7 +1335,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1264
1335
|
break;
|
|
1265
1336
|
}
|
|
1266
1337
|
}
|
|
1267
|
-
log4.trace("dxos.sdk.invitation-handler.host.authenticate",
|
|
1338
|
+
log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.end({
|
|
1268
1339
|
id: traceId,
|
|
1269
1340
|
data: {
|
|
1270
1341
|
status
|
|
@@ -1281,7 +1352,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1281
1352
|
},
|
|
1282
1353
|
admit: async (request) => {
|
|
1283
1354
|
const traceId = PublicKey4.random().toHex();
|
|
1284
|
-
log4.trace("dxos.sdk.invitation-handler.host.admit",
|
|
1355
|
+
log4.trace("dxos.sdk.invitation-handler.host.admit", trace3.begin({
|
|
1285
1356
|
id: traceId
|
|
1286
1357
|
}), {
|
|
1287
1358
|
F: __dxlog_file6,
|
|
@@ -1303,7 +1374,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1303
1374
|
throw new Error("Not authenticated");
|
|
1304
1375
|
}
|
|
1305
1376
|
const response = await this._callbacks.admit(request);
|
|
1306
|
-
log4.trace("dxos.sdk.invitation-handler.host.admit",
|
|
1377
|
+
log4.trace("dxos.sdk.invitation-handler.host.admit", trace3.end({
|
|
1307
1378
|
id: traceId
|
|
1308
1379
|
}), {
|
|
1309
1380
|
F: __dxlog_file6,
|
|
@@ -1321,7 +1392,6 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1321
1392
|
};
|
|
1322
1393
|
}
|
|
1323
1394
|
async onOpen(context) {
|
|
1324
|
-
var _a;
|
|
1325
1395
|
await super.onOpen(context);
|
|
1326
1396
|
try {
|
|
1327
1397
|
await this.rpc.InvitationHostService.options({
|
|
@@ -1330,7 +1400,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1330
1400
|
await cancelWithContext(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1331
1401
|
timeout: OPTIONS_TIMEOUT
|
|
1332
1402
|
}));
|
|
1333
|
-
if (
|
|
1403
|
+
if (this._remoteOptions?.role !== Options.Role.GUEST) {
|
|
1334
1404
|
throw new InvalidInvitationExtensionRoleError(void 0, {
|
|
1335
1405
|
expected: Options.Role.GUEST,
|
|
1336
1406
|
remoteOptions: this._remoteOptions
|
|
@@ -1356,7 +1426,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1356
1426
|
}
|
|
1357
1427
|
});
|
|
1358
1428
|
this._callbacks = _callbacks;
|
|
1359
|
-
this._ctx = new
|
|
1429
|
+
this._ctx = new Context4();
|
|
1360
1430
|
this._remoteOptionsTrigger = new Trigger2();
|
|
1361
1431
|
}
|
|
1362
1432
|
async getHandlers() {
|
|
@@ -1388,7 +1458,6 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1388
1458
|
};
|
|
1389
1459
|
}
|
|
1390
1460
|
async onOpen(context) {
|
|
1391
|
-
var _a;
|
|
1392
1461
|
await super.onOpen(context);
|
|
1393
1462
|
try {
|
|
1394
1463
|
log4("begin options", void 0, {
|
|
@@ -1409,7 +1478,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1409
1478
|
S: this,
|
|
1410
1479
|
C: (f, a) => f(...a)
|
|
1411
1480
|
});
|
|
1412
|
-
if (
|
|
1481
|
+
if (this._remoteOptions?.role !== Options.Role.HOST) {
|
|
1413
1482
|
throw new InvalidInvitationExtensionRoleError(void 0, {
|
|
1414
1483
|
expected: Options.Role.HOST,
|
|
1415
1484
|
remoteOptions: this._remoteOptions
|
|
@@ -1448,9 +1517,8 @@ var InvitationsHandler = class {
|
|
|
1448
1517
|
this._networkManager = _networkManager;
|
|
1449
1518
|
}
|
|
1450
1519
|
createInvitation(protocol, options) {
|
|
1451
|
-
|
|
1452
|
-
const
|
|
1453
|
-
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1520
|
+
const { invitationId = PublicKey5.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey5.random() } = options ?? {};
|
|
1521
|
+
const authCode = options?.authCode ?? (authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1454
1522
|
invariant6(protocol, void 0, {
|
|
1455
1523
|
F: __dxlog_file7,
|
|
1456
1524
|
L: 76,
|
|
@@ -1471,7 +1539,7 @@ var InvitationsHandler = class {
|
|
|
1471
1539
|
...protocol.getInvitationContext()
|
|
1472
1540
|
};
|
|
1473
1541
|
const stream = new PushStream();
|
|
1474
|
-
const ctx = new
|
|
1542
|
+
const ctx = new Context5({
|
|
1475
1543
|
onError: (err) => {
|
|
1476
1544
|
void ctx.dispose();
|
|
1477
1545
|
stream.error(err);
|
|
@@ -1503,9 +1571,8 @@ var InvitationsHandler = class {
|
|
|
1503
1571
|
return invitation;
|
|
1504
1572
|
},
|
|
1505
1573
|
admit: async (admissionRequest) => {
|
|
1506
|
-
var _a2, _b, _c;
|
|
1507
1574
|
try {
|
|
1508
|
-
const deviceKey =
|
|
1575
|
+
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1509
1576
|
invariant6(deviceKey, void 0, {
|
|
1510
1577
|
F: __dxlog_file7,
|
|
1511
1578
|
L: 119,
|
|
@@ -1527,7 +1594,7 @@ var InvitationsHandler = class {
|
|
|
1527
1594
|
scheduleTask2(ctx, async () => {
|
|
1528
1595
|
const traceId = PublicKey5.random().toHex();
|
|
1529
1596
|
try {
|
|
1530
|
-
log5.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
1597
|
+
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.begin({
|
|
1531
1598
|
id: traceId
|
|
1532
1599
|
}), {
|
|
1533
1600
|
F: __dxlog_file7,
|
|
@@ -1563,7 +1630,7 @@ var InvitationsHandler = class {
|
|
|
1563
1630
|
...invitation,
|
|
1564
1631
|
state: Invitation3.State.SUCCESS
|
|
1565
1632
|
});
|
|
1566
|
-
log5.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
1633
|
+
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.end({
|
|
1567
1634
|
id: traceId
|
|
1568
1635
|
}), {
|
|
1569
1636
|
F: __dxlog_file7,
|
|
@@ -1594,7 +1661,7 @@ var InvitationsHandler = class {
|
|
|
1594
1661
|
});
|
|
1595
1662
|
stream.error(err);
|
|
1596
1663
|
}
|
|
1597
|
-
log5.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
1664
|
+
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.error({
|
|
1598
1665
|
id: traceId,
|
|
1599
1666
|
error: err
|
|
1600
1667
|
}), {
|
|
@@ -1702,7 +1769,7 @@ var InvitationsHandler = class {
|
|
|
1702
1769
|
...newData
|
|
1703
1770
|
});
|
|
1704
1771
|
};
|
|
1705
|
-
const ctx = new
|
|
1772
|
+
const ctx = new Context5({
|
|
1706
1773
|
onError: (err) => {
|
|
1707
1774
|
if (err instanceof TimeoutError) {
|
|
1708
1775
|
log5("timeout", {
|
|
@@ -1759,7 +1826,7 @@ var InvitationsHandler = class {
|
|
|
1759
1826
|
scheduleTask2(ctx, async () => {
|
|
1760
1827
|
const traceId = PublicKey5.random().toHex();
|
|
1761
1828
|
try {
|
|
1762
|
-
log5.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
1829
|
+
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.begin({
|
|
1763
1830
|
id: traceId
|
|
1764
1831
|
}), {
|
|
1765
1832
|
F: __dxlog_file7,
|
|
@@ -1878,7 +1945,7 @@ var InvitationsHandler = class {
|
|
|
1878
1945
|
...result,
|
|
1879
1946
|
state: Invitation3.State.SUCCESS
|
|
1880
1947
|
});
|
|
1881
|
-
log5.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
1948
|
+
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.end({
|
|
1882
1949
|
id: traceId
|
|
1883
1950
|
}), {
|
|
1884
1951
|
F: __dxlog_file7,
|
|
@@ -1908,7 +1975,7 @@ var InvitationsHandler = class {
|
|
|
1908
1975
|
});
|
|
1909
1976
|
stream.error(err);
|
|
1910
1977
|
}
|
|
1911
|
-
log5.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
1978
|
+
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.error({
|
|
1912
1979
|
id: traceId,
|
|
1913
1980
|
error: err
|
|
1914
1981
|
}), {
|
|
@@ -2204,7 +2271,6 @@ var SpaceInvitationProtocol = class {
|
|
|
2204
2271
|
};
|
|
2205
2272
|
}
|
|
2206
2273
|
async admit(request, guestProfile) {
|
|
2207
|
-
var _a;
|
|
2208
2274
|
invariant8(this._spaceKey, void 0, {
|
|
2209
2275
|
F: __dxlog_file9,
|
|
2210
2276
|
L: 42,
|
|
@@ -2268,7 +2334,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2268
2334
|
space: {
|
|
2269
2335
|
credential: spaceMemberCredential,
|
|
2270
2336
|
controlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2271
|
-
dataTimeframe:
|
|
2337
|
+
dataTimeframe: space.dataPipeline.pipelineState?.timeframe
|
|
2272
2338
|
}
|
|
2273
2339
|
};
|
|
2274
2340
|
}
|
|
@@ -2372,9 +2438,8 @@ var ClientRpcServer = class {
|
|
|
2372
2438
|
await this._rpcPeer.close();
|
|
2373
2439
|
}
|
|
2374
2440
|
_getServiceHandler(serviceName) {
|
|
2375
|
-
var _a;
|
|
2376
2441
|
if (!this._handlerCache.has(serviceName)) {
|
|
2377
|
-
const [key, descriptor] =
|
|
2442
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise(new Error(`Service not available: ${serviceName}`));
|
|
2378
2443
|
const service = this._serviceRegistry.services[key];
|
|
2379
2444
|
if (!service) {
|
|
2380
2445
|
throw new Error(`Service not available: ${serviceName}`);
|
|
@@ -2385,37 +2450,195 @@ var ClientRpcServer = class {
|
|
|
2385
2450
|
}
|
|
2386
2451
|
};
|
|
2387
2452
|
|
|
2453
|
+
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2454
|
+
import { getFirstStreamValue } from "@dxos/codec-protobuf";
|
|
2455
|
+
import { credentialTypeFilter } from "@dxos/credentials";
|
|
2456
|
+
import { DocumentModel } from "@dxos/document-model";
|
|
2457
|
+
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2458
|
+
import { log as log8 } from "@dxos/log";
|
|
2459
|
+
import { STORAGE_VERSION } from "@dxos/protocols";
|
|
2460
|
+
import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
2461
|
+
|
|
2462
|
+
// packages/sdk/client-services/src/version.ts
|
|
2463
|
+
var DXOS_VERSION = "0.1.56-main.0e9f69e";
|
|
2464
|
+
|
|
2465
|
+
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
2466
|
+
var getPlatform = () => {
|
|
2467
|
+
if (process.browser) {
|
|
2468
|
+
if (typeof window !== "undefined") {
|
|
2469
|
+
const { userAgent } = window.navigator;
|
|
2470
|
+
return {
|
|
2471
|
+
type: "browser",
|
|
2472
|
+
userAgent,
|
|
2473
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2474
|
+
};
|
|
2475
|
+
} else {
|
|
2476
|
+
return {
|
|
2477
|
+
type: "shared-worker",
|
|
2478
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2479
|
+
};
|
|
2480
|
+
}
|
|
2481
|
+
} else {
|
|
2482
|
+
const { platform, version, arch } = process;
|
|
2483
|
+
return {
|
|
2484
|
+
type: "node",
|
|
2485
|
+
platform: `${platform} ${version} ${arch}`,
|
|
2486
|
+
runtime: process.version,
|
|
2487
|
+
uptime: Math.floor(process.uptime()),
|
|
2488
|
+
memory: process.memoryUsage()
|
|
2489
|
+
};
|
|
2490
|
+
}
|
|
2491
|
+
};
|
|
2492
|
+
|
|
2493
|
+
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2494
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2495
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
2496
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2497
|
+
const diagnostics = {
|
|
2498
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2499
|
+
platform: getPlatform(),
|
|
2500
|
+
client: {
|
|
2501
|
+
version: DXOS_VERSION,
|
|
2502
|
+
storage: {
|
|
2503
|
+
version: STORAGE_VERSION
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
};
|
|
2507
|
+
{
|
|
2508
|
+
invariant9(clientServices.LoggingService, "SystemService is not available.", {
|
|
2509
|
+
F: __dxlog_file10,
|
|
2510
|
+
L: 87,
|
|
2511
|
+
S: void 0,
|
|
2512
|
+
A: [
|
|
2513
|
+
"clientServices.LoggingService",
|
|
2514
|
+
"'SystemService is not available.'"
|
|
2515
|
+
]
|
|
2516
|
+
});
|
|
2517
|
+
diagnostics.metrics = await getFirstStreamValue(clientServices.LoggingService.queryMetrics({}), {
|
|
2518
|
+
timeout: DEFAULT_TIMEOUT
|
|
2519
|
+
}).catch(() => void 0);
|
|
2520
|
+
}
|
|
2521
|
+
const identity = serviceContext.identityManager.identity;
|
|
2522
|
+
if (identity) {
|
|
2523
|
+
diagnostics.identity = {
|
|
2524
|
+
identityKey: identity.identityKey,
|
|
2525
|
+
spaceKey: identity.space.key,
|
|
2526
|
+
profile: identity.profileDocument
|
|
2527
|
+
};
|
|
2528
|
+
const { devices } = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
|
|
2529
|
+
timeout: DEFAULT_TIMEOUT
|
|
2530
|
+
}).catch(() => void 0) ?? {};
|
|
2531
|
+
diagnostics.devices = devices;
|
|
2532
|
+
if (serviceContext.dataSpaceManager) {
|
|
2533
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2534
|
+
}
|
|
2535
|
+
const { feeds = [] } = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2536
|
+
timeout: DEFAULT_TIMEOUT
|
|
2537
|
+
}).catch(() => void 0) ?? {};
|
|
2538
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2539
|
+
feedKey,
|
|
2540
|
+
bytes,
|
|
2541
|
+
length
|
|
2542
|
+
}));
|
|
2543
|
+
}
|
|
2544
|
+
diagnostics.config = config.values;
|
|
2545
|
+
return diagnostics;
|
|
2546
|
+
};
|
|
2547
|
+
var getProperties = (space) => {
|
|
2548
|
+
let properties = {};
|
|
2549
|
+
try {
|
|
2550
|
+
const propertiesItem = space.dataPipeline.itemManager.items.find((item) => item.modelMeta?.type === DocumentModel.meta.type && item.state?.type === "dxos.sdk.client.Properties");
|
|
2551
|
+
const state = propertiesItem?.state;
|
|
2552
|
+
properties = state?.data;
|
|
2553
|
+
} catch (err) {
|
|
2554
|
+
log8.warn(err.message, void 0, {
|
|
2555
|
+
F: __dxlog_file10,
|
|
2556
|
+
L: 144,
|
|
2557
|
+
S: void 0,
|
|
2558
|
+
C: (f, a) => f(...a)
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2561
|
+
return properties;
|
|
2562
|
+
};
|
|
2563
|
+
var getSpaceStats = async (space) => {
|
|
2564
|
+
const stats = {
|
|
2565
|
+
key: space.key,
|
|
2566
|
+
metrics: space.metrics,
|
|
2567
|
+
epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
2568
|
+
...credential.subject.assertion,
|
|
2569
|
+
id: credential.id
|
|
2570
|
+
})),
|
|
2571
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2572
|
+
identity: {
|
|
2573
|
+
identityKey: member.key,
|
|
2574
|
+
profile: {
|
|
2575
|
+
displayName: member.assertion.profile?.displayName
|
|
2576
|
+
}
|
|
2577
|
+
},
|
|
2578
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
|
|
2579
|
+
})),
|
|
2580
|
+
pipeline: {
|
|
2581
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
2582
|
+
// currentEpoch: space.dataPipeline.currentEpoch,
|
|
2583
|
+
// appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
2584
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2585
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2586
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2587
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
2588
|
+
// TODO(burdon): Empty?
|
|
2589
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
2590
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
2591
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
2592
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
2593
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
2594
|
+
}
|
|
2595
|
+
};
|
|
2596
|
+
if (space.dataPipeline.itemManager) {
|
|
2597
|
+
Object.assign(stats, {
|
|
2598
|
+
properties: getProperties(space),
|
|
2599
|
+
db: {
|
|
2600
|
+
objects: space.dataPipeline.itemManager.entities.size
|
|
2601
|
+
}
|
|
2602
|
+
});
|
|
2603
|
+
}
|
|
2604
|
+
if (stats.metrics) {
|
|
2605
|
+
const { open, ready } = stats.metrics;
|
|
2606
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
2607
|
+
}
|
|
2608
|
+
return stats;
|
|
2609
|
+
};
|
|
2610
|
+
|
|
2388
2611
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2389
2612
|
import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
|
|
2390
2613
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2391
|
-
import { cancelWithContext as cancelWithContext2, Context as
|
|
2614
|
+
import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
|
|
2392
2615
|
import { timed } from "@dxos/debug";
|
|
2393
2616
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2394
2617
|
import { CancelledError, SystemError } from "@dxos/errors";
|
|
2395
2618
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2396
|
-
import { log as
|
|
2619
|
+
import { log as log10 } from "@dxos/log";
|
|
2397
2620
|
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
2398
2621
|
import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2399
|
-
import { Timeframe } from "@dxos/timeframe";
|
|
2622
|
+
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
2400
2623
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2401
2624
|
|
|
2402
2625
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2403
2626
|
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2404
|
-
import { Context as
|
|
2405
|
-
import { invariant as
|
|
2627
|
+
import { Context as Context6, rejectOnDispose } from "@dxos/context";
|
|
2628
|
+
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2406
2629
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2407
|
-
import { log as
|
|
2630
|
+
import { log as log9 } from "@dxos/log";
|
|
2408
2631
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2409
2632
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
2410
2633
|
import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
|
|
2411
|
-
var
|
|
2634
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2412
2635
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2413
2636
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2414
2637
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
2415
2638
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2416
2639
|
var NotarizationPlugin = class {
|
|
2417
2640
|
constructor() {
|
|
2418
|
-
this._ctx = new
|
|
2641
|
+
this._ctx = new Context6();
|
|
2419
2642
|
this._extensionOpened = new Event4();
|
|
2420
2643
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2421
2644
|
this._processedCredentials = new ComplexSet(PublicKey6.hash);
|
|
@@ -2433,16 +2656,16 @@ var NotarizationPlugin = class {
|
|
|
2433
2656
|
* Request credentials to be notarized.
|
|
2434
2657
|
*/
|
|
2435
2658
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
2436
|
-
|
|
2659
|
+
log9("notarize", {
|
|
2437
2660
|
credentials
|
|
2438
2661
|
}, {
|
|
2439
|
-
F:
|
|
2662
|
+
F: __dxlog_file11,
|
|
2440
2663
|
L: 90,
|
|
2441
2664
|
S: this,
|
|
2442
2665
|
C: (f, a) => f(...a)
|
|
2443
2666
|
});
|
|
2444
|
-
|
|
2445
|
-
F:
|
|
2667
|
+
invariant10(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2668
|
+
F: __dxlog_file11,
|
|
2446
2669
|
L: 91,
|
|
2447
2670
|
S: this,
|
|
2448
2671
|
A: [
|
|
@@ -2453,10 +2676,10 @@ var NotarizationPlugin = class {
|
|
|
2453
2676
|
const errors = new Trigger4();
|
|
2454
2677
|
const ctx = this._ctx.derive({
|
|
2455
2678
|
onError: (err) => {
|
|
2456
|
-
|
|
2679
|
+
log9.warn("Notarization error", {
|
|
2457
2680
|
err
|
|
2458
2681
|
}, {
|
|
2459
|
-
F:
|
|
2682
|
+
F: __dxlog_file11,
|
|
2460
2683
|
L: 99,
|
|
2461
2684
|
S: this,
|
|
2462
2685
|
C: (f, a) => f(...a)
|
|
@@ -2465,14 +2688,14 @@ var NotarizationPlugin = class {
|
|
|
2465
2688
|
errors.throw(err);
|
|
2466
2689
|
}
|
|
2467
2690
|
});
|
|
2468
|
-
opCtx
|
|
2691
|
+
opCtx?.onDispose(() => ctx.dispose());
|
|
2469
2692
|
if (timeout !== 0) {
|
|
2470
2693
|
scheduleTask3(ctx, () => {
|
|
2471
|
-
|
|
2694
|
+
log9.warn("Notarization timeout", {
|
|
2472
2695
|
timeout,
|
|
2473
2696
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2474
2697
|
}, {
|
|
2475
|
-
F:
|
|
2698
|
+
F: __dxlog_file11,
|
|
2476
2699
|
L: 111,
|
|
2477
2700
|
S: this,
|
|
2478
2701
|
C: (f, a) => f(...a)
|
|
@@ -2492,10 +2715,10 @@ var NotarizationPlugin = class {
|
|
|
2492
2715
|
...this._extensions
|
|
2493
2716
|
].find((peer2) => !peersTried.has(peer2));
|
|
2494
2717
|
if (!peer) {
|
|
2495
|
-
|
|
2718
|
+
log9.warn("Exhausted all peers to notarize with", {
|
|
2496
2719
|
retryIn: retryTimeout
|
|
2497
2720
|
}, {
|
|
2498
|
-
F:
|
|
2721
|
+
F: __dxlog_file11,
|
|
2499
2722
|
L: 136,
|
|
2500
2723
|
S: this,
|
|
2501
2724
|
C: (f, a) => f(...a)
|
|
@@ -2505,11 +2728,11 @@ var NotarizationPlugin = class {
|
|
|
2505
2728
|
return;
|
|
2506
2729
|
}
|
|
2507
2730
|
peersTried.add(peer);
|
|
2508
|
-
|
|
2731
|
+
log9("try notarizing", {
|
|
2509
2732
|
peer: peer.localPeerId,
|
|
2510
2733
|
credentialId: credentials.map((credential) => credential.id)
|
|
2511
2734
|
}, {
|
|
2512
|
-
F:
|
|
2735
|
+
F: __dxlog_file11,
|
|
2513
2736
|
L: 143,
|
|
2514
2737
|
S: this,
|
|
2515
2738
|
C: (f, a) => f(...a)
|
|
@@ -2517,8 +2740,8 @@ var NotarizationPlugin = class {
|
|
|
2517
2740
|
await peer.rpc.NotarizationService.notarize({
|
|
2518
2741
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2519
2742
|
});
|
|
2520
|
-
|
|
2521
|
-
F:
|
|
2743
|
+
log9("success", void 0, {
|
|
2744
|
+
F: __dxlog_file11,
|
|
2522
2745
|
L: 147,
|
|
2523
2746
|
S: this,
|
|
2524
2747
|
C: (f, a) => f(...a)
|
|
@@ -2526,8 +2749,8 @@ var NotarizationPlugin = class {
|
|
|
2526
2749
|
await sleep(successDelay);
|
|
2527
2750
|
} catch (err) {
|
|
2528
2751
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2529
|
-
|
|
2530
|
-
F:
|
|
2752
|
+
log9.warn("error notarizing (recoverable)", err, {
|
|
2753
|
+
F: __dxlog_file11,
|
|
2531
2754
|
L: 151,
|
|
2532
2755
|
S: this,
|
|
2533
2756
|
C: (f, a) => f(...a)
|
|
@@ -2544,8 +2767,8 @@ var NotarizationPlugin = class {
|
|
|
2544
2767
|
allNotarized,
|
|
2545
2768
|
errors.wait()
|
|
2546
2769
|
]);
|
|
2547
|
-
|
|
2548
|
-
F:
|
|
2770
|
+
log9("done", void 0, {
|
|
2771
|
+
F: __dxlog_file11,
|
|
2549
2772
|
L: 162,
|
|
2550
2773
|
S: this,
|
|
2551
2774
|
C: (f, a) => f(...a)
|
|
@@ -2558,17 +2781,16 @@ var NotarizationPlugin = class {
|
|
|
2558
2781
|
* Called with credentials arriving from the control pipeline.
|
|
2559
2782
|
*/
|
|
2560
2783
|
async processCredential(credential) {
|
|
2561
|
-
var _a;
|
|
2562
2784
|
if (!credential.id) {
|
|
2563
2785
|
return;
|
|
2564
2786
|
}
|
|
2565
|
-
|
|
2787
|
+
this._processCredentialsTriggers.get(credential.id)?.wake();
|
|
2566
2788
|
this._processedCredentials.add(credential.id);
|
|
2567
2789
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2568
2790
|
}
|
|
2569
2791
|
setWriter(writer) {
|
|
2570
|
-
|
|
2571
|
-
F:
|
|
2792
|
+
invariant10(!this._writer, "Writer already set.", {
|
|
2793
|
+
F: __dxlog_file11,
|
|
2572
2794
|
L: 181,
|
|
2573
2795
|
S: this,
|
|
2574
2796
|
A: [
|
|
@@ -2588,13 +2810,12 @@ var NotarizationPlugin = class {
|
|
|
2588
2810
|
* Requests from other peers to notarize credentials.
|
|
2589
2811
|
*/
|
|
2590
2812
|
async _onNotarize(request) {
|
|
2591
|
-
var _a;
|
|
2592
2813
|
if (!this._writer) {
|
|
2593
2814
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2594
2815
|
}
|
|
2595
|
-
for (const credential of
|
|
2596
|
-
|
|
2597
|
-
F:
|
|
2816
|
+
for (const credential of request.credentials ?? []) {
|
|
2817
|
+
invariant10(credential.id, "Credential must have an id", {
|
|
2818
|
+
F: __dxlog_file11,
|
|
2598
2819
|
L: 200,
|
|
2599
2820
|
S: this,
|
|
2600
2821
|
A: [
|
|
@@ -2611,10 +2832,10 @@ var NotarizationPlugin = class {
|
|
|
2611
2832
|
createExtension() {
|
|
2612
2833
|
const extension = new NotarizationTeleportExtension({
|
|
2613
2834
|
onOpen: async () => {
|
|
2614
|
-
|
|
2835
|
+
log9("extension opened", {
|
|
2615
2836
|
peer: extension.localPeerId
|
|
2616
2837
|
}, {
|
|
2617
|
-
F:
|
|
2838
|
+
F: __dxlog_file11,
|
|
2618
2839
|
L: 211,
|
|
2619
2840
|
S: this,
|
|
2620
2841
|
C: (f, a) => f(...a)
|
|
@@ -2623,10 +2844,10 @@ var NotarizationPlugin = class {
|
|
|
2623
2844
|
this._extensionOpened.emit();
|
|
2624
2845
|
},
|
|
2625
2846
|
onClose: async () => {
|
|
2626
|
-
|
|
2847
|
+
log9("extension closed", {
|
|
2627
2848
|
peer: extension.localPeerId
|
|
2628
2849
|
}, {
|
|
2629
|
-
F:
|
|
2850
|
+
F: __dxlog_file11,
|
|
2630
2851
|
L: 216,
|
|
2631
2852
|
S: this,
|
|
2632
2853
|
C: (f, a) => f(...a)
|
|
@@ -2670,7 +2891,7 @@ var NotarizationTeleportExtension = class extends RpcExtension2 {
|
|
|
2670
2891
|
};
|
|
2671
2892
|
|
|
2672
2893
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2673
|
-
function
|
|
2894
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
2674
2895
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2675
2896
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2676
2897
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2680,10 +2901,11 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
2680
2901
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2681
2902
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2682
2903
|
}
|
|
2683
|
-
var
|
|
2904
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2905
|
+
var ENABLE_FEED_PURGE = false;
|
|
2684
2906
|
var DataSpace = class DataSpace2 {
|
|
2685
2907
|
constructor(params) {
|
|
2686
|
-
this._ctx = new
|
|
2908
|
+
this._ctx = new Context7();
|
|
2687
2909
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2688
2910
|
this._state = SpaceState.CLOSED;
|
|
2689
2911
|
/**
|
|
@@ -2692,7 +2914,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2692
2914
|
this.error = void 0;
|
|
2693
2915
|
this.stateUpdate = new Event5();
|
|
2694
2916
|
this.metrics = {};
|
|
2695
|
-
var _a;
|
|
2696
2917
|
this._inner = params.inner;
|
|
2697
2918
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
2698
2919
|
this._gossip = params.gossip;
|
|
@@ -2701,7 +2922,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2701
2922
|
this._feedStore = params.feedStore;
|
|
2702
2923
|
this._metadataStore = params.metadataStore;
|
|
2703
2924
|
this._signingContext = params.signingContext;
|
|
2704
|
-
this._callbacks =
|
|
2925
|
+
this._callbacks = params.callbacks ?? {};
|
|
2705
2926
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2706
2927
|
trustedKeysProvider: () => new ComplexSet2(PublicKey7.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2707
2928
|
update: this._inner.stateUpdate,
|
|
@@ -2741,21 +2962,20 @@ var DataSpace = class DataSpace2 {
|
|
|
2741
2962
|
async _open() {
|
|
2742
2963
|
await this._notarizationPlugin.open();
|
|
2743
2964
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2744
|
-
await this._inner.open();
|
|
2965
|
+
await this._inner.open(new Context7());
|
|
2745
2966
|
this._state = SpaceState.CONTROL_ONLY;
|
|
2746
2967
|
this.stateUpdate.emit();
|
|
2747
2968
|
this.metrics = {};
|
|
2748
|
-
this.metrics.open = new Date();
|
|
2969
|
+
this.metrics.open = /* @__PURE__ */ new Date();
|
|
2749
2970
|
}
|
|
2750
2971
|
async close() {
|
|
2751
2972
|
await this._close();
|
|
2752
2973
|
}
|
|
2753
2974
|
async _close() {
|
|
2754
|
-
|
|
2755
|
-
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2975
|
+
await this._callbacks.beforeClose?.();
|
|
2756
2976
|
this._state = SpaceState.CLOSED;
|
|
2757
2977
|
await this._ctx.dispose();
|
|
2758
|
-
this._ctx = new
|
|
2978
|
+
this._ctx = new Context7();
|
|
2759
2979
|
await this.authVerifier.close();
|
|
2760
2980
|
await this._inner.close();
|
|
2761
2981
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
@@ -2774,21 +2994,21 @@ var DataSpace = class DataSpace2 {
|
|
|
2774
2994
|
initializeDataPipelineAsync() {
|
|
2775
2995
|
scheduleTask4(this._ctx, async () => {
|
|
2776
2996
|
try {
|
|
2777
|
-
this.metrics.pipelineInitBegin = new Date();
|
|
2997
|
+
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
2778
2998
|
await this.initializeDataPipeline();
|
|
2779
2999
|
} catch (err) {
|
|
2780
3000
|
if (err instanceof CancelledError) {
|
|
2781
|
-
|
|
2782
|
-
F:
|
|
2783
|
-
L:
|
|
3001
|
+
log10("data pipeline initialization cancelled", err, {
|
|
3002
|
+
F: __dxlog_file12,
|
|
3003
|
+
L: 199,
|
|
2784
3004
|
S: this,
|
|
2785
3005
|
C: (f, a) => f(...a)
|
|
2786
3006
|
});
|
|
2787
3007
|
return;
|
|
2788
3008
|
}
|
|
2789
|
-
|
|
2790
|
-
F:
|
|
2791
|
-
L:
|
|
3009
|
+
log10.error("Error initializing data pipeline", err, {
|
|
3010
|
+
F: __dxlog_file12,
|
|
3011
|
+
L: 203,
|
|
2792
3012
|
S: this,
|
|
2793
3013
|
C: (f, a) => f(...a)
|
|
2794
3014
|
});
|
|
@@ -2796,12 +3016,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2796
3016
|
this.error = err;
|
|
2797
3017
|
this.stateUpdate.emit();
|
|
2798
3018
|
} finally {
|
|
2799
|
-
this.metrics.ready = new Date();
|
|
3019
|
+
this.metrics.ready = /* @__PURE__ */ new Date();
|
|
2800
3020
|
}
|
|
2801
3021
|
});
|
|
2802
3022
|
}
|
|
2803
3023
|
async initializeDataPipeline() {
|
|
2804
|
-
var _a, _b, _c, _d;
|
|
2805
3024
|
if (this._state !== SpaceState.CONTROL_ONLY) {
|
|
2806
3025
|
throw new SystemError("Invalid operation");
|
|
2807
3026
|
}
|
|
@@ -2810,11 +3029,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2810
3029
|
ctx: this._ctx,
|
|
2811
3030
|
breakOnStall: false
|
|
2812
3031
|
});
|
|
2813
|
-
this.metrics.controlPipelineReady = new Date();
|
|
3032
|
+
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
2814
3033
|
await this._createWritableFeeds();
|
|
2815
|
-
|
|
2816
|
-
F:
|
|
2817
|
-
L:
|
|
3034
|
+
log10("writable feeds created", void 0, {
|
|
3035
|
+
F: __dxlog_file12,
|
|
3036
|
+
L: 227,
|
|
2818
3037
|
S: this,
|
|
2819
3038
|
C: (f, a) => f(...a)
|
|
2820
3039
|
});
|
|
@@ -2827,11 +3046,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2827
3046
|
}), this._inner.controlPipeline.writer));
|
|
2828
3047
|
}
|
|
2829
3048
|
await this._inner.initializeDataPipeline();
|
|
2830
|
-
this.metrics.dataPipelineOpen = new Date();
|
|
3049
|
+
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
2831
3050
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2832
|
-
|
|
2833
|
-
F:
|
|
2834
|
-
L:
|
|
3051
|
+
log10("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3052
|
+
F: __dxlog_file12,
|
|
3053
|
+
L: 248,
|
|
2835
3054
|
S: this,
|
|
2836
3055
|
C: (f, a) => f(...a)
|
|
2837
3056
|
});
|
|
@@ -2839,17 +3058,17 @@ var DataSpace = class DataSpace2 {
|
|
|
2839
3058
|
ctx: this._ctx,
|
|
2840
3059
|
breakOnStall: false
|
|
2841
3060
|
});
|
|
2842
|
-
this.metrics.dataPipelineReady = new Date();
|
|
2843
|
-
|
|
2844
|
-
F:
|
|
2845
|
-
L:
|
|
3061
|
+
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3062
|
+
log10("data pipeline ready", void 0, {
|
|
3063
|
+
F: __dxlog_file12,
|
|
3064
|
+
L: 257,
|
|
2846
3065
|
S: this,
|
|
2847
3066
|
C: (f, a) => f(...a)
|
|
2848
3067
|
});
|
|
2849
|
-
await
|
|
3068
|
+
await this._callbacks.beforeReady?.();
|
|
2850
3069
|
this._state = SpaceState.READY;
|
|
2851
3070
|
this.stateUpdate.emit();
|
|
2852
|
-
await
|
|
3071
|
+
await this._callbacks.afterReady?.();
|
|
2853
3072
|
}
|
|
2854
3073
|
async _createWritableFeeds() {
|
|
2855
3074
|
const credentials = [];
|
|
@@ -2896,7 +3115,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2896
3115
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
2897
3116
|
}
|
|
2898
3117
|
async createEpoch() {
|
|
2899
|
-
var _a, _b;
|
|
2900
3118
|
const epoch = await this.dataPipeline.createEpoch();
|
|
2901
3119
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
2902
3120
|
credential: {
|
|
@@ -2909,16 +3127,19 @@ var DataSpace = class DataSpace2 {
|
|
|
2909
3127
|
})
|
|
2910
3128
|
}
|
|
2911
3129
|
});
|
|
2912
|
-
await this.inner.controlPipeline.state.waitUntilTimeframe(new
|
|
3130
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe2([
|
|
2913
3131
|
[
|
|
2914
3132
|
receipt.feedKey,
|
|
2915
3133
|
receipt.seq
|
|
2916
3134
|
]
|
|
2917
3135
|
]));
|
|
2918
|
-
|
|
2919
|
-
const
|
|
2920
|
-
|
|
2921
|
-
|
|
3136
|
+
if (ENABLE_FEED_PURGE) {
|
|
3137
|
+
for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
|
|
3138
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
3139
|
+
if (indexBeforeEpoch === void 0) {
|
|
3140
|
+
continue;
|
|
3141
|
+
}
|
|
3142
|
+
await feed.safeClear(0, indexBeforeEpoch + 1);
|
|
2922
3143
|
}
|
|
2923
3144
|
}
|
|
2924
3145
|
}
|
|
@@ -2940,33 +3161,33 @@ var DataSpace = class DataSpace2 {
|
|
|
2940
3161
|
this.stateUpdate.emit();
|
|
2941
3162
|
}
|
|
2942
3163
|
};
|
|
2943
|
-
|
|
3164
|
+
_ts_decorate3([
|
|
2944
3165
|
synchronized
|
|
2945
3166
|
], DataSpace.prototype, "open", null);
|
|
2946
|
-
|
|
3167
|
+
_ts_decorate3([
|
|
2947
3168
|
synchronized
|
|
2948
3169
|
], DataSpace.prototype, "close", null);
|
|
2949
|
-
|
|
3170
|
+
_ts_decorate3([
|
|
2950
3171
|
timed(1e4)
|
|
2951
3172
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2952
|
-
|
|
3173
|
+
_ts_decorate3([
|
|
2953
3174
|
synchronized
|
|
2954
3175
|
], DataSpace.prototype, "activate", null);
|
|
2955
|
-
|
|
3176
|
+
_ts_decorate3([
|
|
2956
3177
|
synchronized
|
|
2957
3178
|
], DataSpace.prototype, "deactivate", null);
|
|
2958
|
-
DataSpace =
|
|
3179
|
+
DataSpace = _ts_decorate3([
|
|
2959
3180
|
trackLeaks("open", "close")
|
|
2960
3181
|
], DataSpace);
|
|
2961
3182
|
|
|
2962
3183
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2963
3184
|
import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
2964
|
-
import { cancelWithContext as cancelWithContext3, Context as
|
|
3185
|
+
import { cancelWithContext as cancelWithContext3, Context as Context8 } from "@dxos/context";
|
|
2965
3186
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
2966
|
-
import { invariant as
|
|
3187
|
+
import { invariant as invariant11 } from "@dxos/invariant";
|
|
2967
3188
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2968
|
-
import { log as
|
|
2969
|
-
import { trace as
|
|
3189
|
+
import { log as log11 } from "@dxos/log";
|
|
3190
|
+
import { trace as trace5 } from "@dxos/protocols";
|
|
2970
3191
|
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2971
3192
|
import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
|
|
2972
3193
|
import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxos/util";
|
|
@@ -2974,10 +3195,9 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxo
|
|
|
2974
3195
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
2975
3196
|
import { createCredential } from "@dxos/credentials";
|
|
2976
3197
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
2977
|
-
import { AdmittedFeed as AdmittedFeed4, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2978
|
-
import { Timeframe as
|
|
3198
|
+
import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3199
|
+
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
2979
3200
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
2980
|
-
var _a, _b, _c, _d;
|
|
2981
3201
|
const credentials = [
|
|
2982
3202
|
await createCredential({
|
|
2983
3203
|
signer: keyring,
|
|
@@ -2995,13 +3215,13 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2995
3215
|
assertion: {
|
|
2996
3216
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
2997
3217
|
spaceKey: space.key,
|
|
2998
|
-
role:
|
|
3218
|
+
role: SpaceMember2.Role.ADMIN,
|
|
2999
3219
|
profile: signingContext.profile,
|
|
3000
|
-
genesisFeedKey:
|
|
3220
|
+
genesisFeedKey: space.controlFeedKey ?? failUndefined2()
|
|
3001
3221
|
}
|
|
3002
3222
|
}),
|
|
3003
3223
|
await signingContext.credentialSigner.createCredential({
|
|
3004
|
-
subject:
|
|
3224
|
+
subject: space.controlFeedKey ?? failUndefined2(),
|
|
3005
3225
|
assertion: {
|
|
3006
3226
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
3007
3227
|
spaceKey: space.key,
|
|
@@ -3011,7 +3231,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3011
3231
|
}
|
|
3012
3232
|
}),
|
|
3013
3233
|
await signingContext.credentialSigner.createCredential({
|
|
3014
|
-
subject:
|
|
3234
|
+
subject: space.dataFeedKey ?? failUndefined2(),
|
|
3015
3235
|
assertion: {
|
|
3016
3236
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
3017
3237
|
spaceKey: space.key,
|
|
@@ -3021,12 +3241,12 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3021
3241
|
}
|
|
3022
3242
|
}),
|
|
3023
3243
|
await signingContext.credentialSigner.createCredential({
|
|
3024
|
-
subject:
|
|
3244
|
+
subject: space.key ?? failUndefined2(),
|
|
3025
3245
|
assertion: {
|
|
3026
3246
|
"@type": "dxos.halo.credentials.Epoch",
|
|
3027
3247
|
number: 0,
|
|
3028
3248
|
previousId: void 0,
|
|
3029
|
-
timeframe: new
|
|
3249
|
+
timeframe: new Timeframe3(),
|
|
3030
3250
|
snapshotCid: void 0
|
|
3031
3251
|
}
|
|
3032
3252
|
})
|
|
@@ -3042,7 +3262,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3042
3262
|
};
|
|
3043
3263
|
|
|
3044
3264
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
3045
|
-
function
|
|
3265
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3046
3266
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3047
3267
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3048
3268
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3052,7 +3272,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
3052
3272
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3053
3273
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3054
3274
|
}
|
|
3055
|
-
var
|
|
3275
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3056
3276
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
3057
3277
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
3058
3278
|
this._spaceManager = _spaceManager;
|
|
@@ -3061,7 +3281,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3061
3281
|
this._keyring = _keyring;
|
|
3062
3282
|
this._signingContext = _signingContext;
|
|
3063
3283
|
this._feedStore = _feedStore;
|
|
3064
|
-
this._ctx = new
|
|
3284
|
+
this._ctx = new Context8();
|
|
3065
3285
|
this.updated = new Event6();
|
|
3066
3286
|
this._spaces = new ComplexMap3(PublicKey8.hash);
|
|
3067
3287
|
this._isOpen = false;
|
|
@@ -3072,35 +3292,35 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3072
3292
|
return this._spaces;
|
|
3073
3293
|
}
|
|
3074
3294
|
async open() {
|
|
3075
|
-
|
|
3076
|
-
F:
|
|
3295
|
+
log11("open", void 0, {
|
|
3296
|
+
F: __dxlog_file13,
|
|
3077
3297
|
L: 79,
|
|
3078
3298
|
S: this,
|
|
3079
3299
|
C: (f, a) => f(...a)
|
|
3080
3300
|
});
|
|
3081
|
-
|
|
3301
|
+
log11.trace("dxos.echo.data-space-manager.open", trace5.begin({
|
|
3082
3302
|
id: this._instanceId
|
|
3083
3303
|
}), {
|
|
3084
|
-
F:
|
|
3304
|
+
F: __dxlog_file13,
|
|
3085
3305
|
L: 80,
|
|
3086
3306
|
S: this,
|
|
3087
3307
|
C: (f, a) => f(...a)
|
|
3088
3308
|
});
|
|
3089
3309
|
await this._metadataStore.load();
|
|
3090
|
-
|
|
3310
|
+
log11("metadata loaded", {
|
|
3091
3311
|
spaces: this._metadataStore.spaces.length
|
|
3092
3312
|
}, {
|
|
3093
|
-
F:
|
|
3313
|
+
F: __dxlog_file13,
|
|
3094
3314
|
L: 82,
|
|
3095
3315
|
S: this,
|
|
3096
3316
|
C: (f, a) => f(...a)
|
|
3097
3317
|
});
|
|
3098
3318
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
3099
3319
|
try {
|
|
3100
|
-
|
|
3320
|
+
log11("load space", {
|
|
3101
3321
|
spaceMetadata
|
|
3102
3322
|
}, {
|
|
3103
|
-
F:
|
|
3323
|
+
F: __dxlog_file13,
|
|
3104
3324
|
L: 86,
|
|
3105
3325
|
S: this,
|
|
3106
3326
|
C: (f, a) => f(...a)
|
|
@@ -3110,11 +3330,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3110
3330
|
space.initializeDataPipelineAsync();
|
|
3111
3331
|
}
|
|
3112
3332
|
} catch (err) {
|
|
3113
|
-
|
|
3333
|
+
log11.error("Error loading space", {
|
|
3114
3334
|
spaceMetadata,
|
|
3115
3335
|
err
|
|
3116
3336
|
}, {
|
|
3117
|
-
F:
|
|
3337
|
+
F: __dxlog_file13,
|
|
3118
3338
|
L: 92,
|
|
3119
3339
|
S: this,
|
|
3120
3340
|
C: (f, a) => f(...a)
|
|
@@ -3123,18 +3343,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3123
3343
|
}
|
|
3124
3344
|
this._isOpen = true;
|
|
3125
3345
|
this.updated.emit();
|
|
3126
|
-
|
|
3346
|
+
log11.trace("dxos.echo.data-space-manager.open", trace5.end({
|
|
3127
3347
|
id: this._instanceId
|
|
3128
3348
|
}), {
|
|
3129
|
-
F:
|
|
3349
|
+
F: __dxlog_file13,
|
|
3130
3350
|
L: 98,
|
|
3131
3351
|
S: this,
|
|
3132
3352
|
C: (f, a) => f(...a)
|
|
3133
3353
|
});
|
|
3134
3354
|
}
|
|
3135
3355
|
async close() {
|
|
3136
|
-
|
|
3137
|
-
F:
|
|
3356
|
+
log11("close", void 0, {
|
|
3357
|
+
F: __dxlog_file13,
|
|
3138
3358
|
L: 103,
|
|
3139
3359
|
S: this,
|
|
3140
3360
|
C: (f, a) => f(...a)
|
|
@@ -3149,8 +3369,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3149
3369
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3150
3370
|
*/
|
|
3151
3371
|
async createSpace() {
|
|
3152
|
-
|
|
3153
|
-
F:
|
|
3372
|
+
invariant11(this._isOpen, "Not open.", {
|
|
3373
|
+
F: __dxlog_file13,
|
|
3154
3374
|
L: 116,
|
|
3155
3375
|
S: this,
|
|
3156
3376
|
A: [
|
|
@@ -3168,10 +3388,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3168
3388
|
dataFeedKey,
|
|
3169
3389
|
state: SpaceState2.ACTIVE
|
|
3170
3390
|
};
|
|
3171
|
-
|
|
3391
|
+
log11("creating space...", {
|
|
3172
3392
|
spaceKey
|
|
3173
3393
|
}, {
|
|
3174
|
-
F:
|
|
3394
|
+
F: __dxlog_file13,
|
|
3175
3395
|
L: 128,
|
|
3176
3396
|
S: this,
|
|
3177
3397
|
C: (f, a) => f(...a)
|
|
@@ -3180,8 +3400,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3180
3400
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
3181
3401
|
await this._metadataStore.addSpace(metadata);
|
|
3182
3402
|
const memberCredential = credentials[1];
|
|
3183
|
-
|
|
3184
|
-
F:
|
|
3403
|
+
invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3404
|
+
F: __dxlog_file13,
|
|
3185
3405
|
L: 135,
|
|
3186
3406
|
S: this,
|
|
3187
3407
|
A: [
|
|
@@ -3196,16 +3416,16 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3196
3416
|
}
|
|
3197
3417
|
// TODO(burdon): Rename join space.
|
|
3198
3418
|
async acceptSpace(opts) {
|
|
3199
|
-
|
|
3419
|
+
log11("accept space", {
|
|
3200
3420
|
opts
|
|
3201
3421
|
}, {
|
|
3202
|
-
F:
|
|
3422
|
+
F: __dxlog_file13,
|
|
3203
3423
|
L: 147,
|
|
3204
3424
|
S: this,
|
|
3205
3425
|
C: (f, a) => f(...a)
|
|
3206
3426
|
});
|
|
3207
|
-
|
|
3208
|
-
F:
|
|
3427
|
+
invariant11(this._isOpen, "Not open.", {
|
|
3428
|
+
F: __dxlog_file13,
|
|
3209
3429
|
L: 148,
|
|
3210
3430
|
S: this,
|
|
3211
3431
|
A: [
|
|
@@ -3213,8 +3433,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3213
3433
|
"'Not open.'"
|
|
3214
3434
|
]
|
|
3215
3435
|
});
|
|
3216
|
-
|
|
3217
|
-
F:
|
|
3436
|
+
invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3437
|
+
F: __dxlog_file13,
|
|
3218
3438
|
L: 149,
|
|
3219
3439
|
S: this,
|
|
3220
3440
|
A: [
|
|
@@ -3246,10 +3466,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3246
3466
|
}));
|
|
3247
3467
|
}
|
|
3248
3468
|
async _constructSpace(metadata) {
|
|
3249
|
-
|
|
3469
|
+
log11("construct space", {
|
|
3250
3470
|
metadata
|
|
3251
3471
|
}, {
|
|
3252
|
-
F:
|
|
3472
|
+
F: __dxlog_file13,
|
|
3253
3473
|
L: 182,
|
|
3254
3474
|
S: this,
|
|
3255
3475
|
C: (f, a) => f(...a)
|
|
@@ -3284,8 +3504,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3284
3504
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3285
3505
|
},
|
|
3286
3506
|
onAuthFailure: () => {
|
|
3287
|
-
|
|
3288
|
-
F:
|
|
3507
|
+
log11.warn("auth failure", void 0, {
|
|
3508
|
+
F: __dxlog_file13,
|
|
3289
3509
|
L: 213,
|
|
3290
3510
|
S: this,
|
|
3291
3511
|
C: (f, a) => f(...a)
|
|
@@ -3306,10 +3526,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3306
3526
|
signingContext: this._signingContext,
|
|
3307
3527
|
callbacks: {
|
|
3308
3528
|
beforeReady: async () => {
|
|
3309
|
-
|
|
3529
|
+
log11("before space ready", {
|
|
3310
3530
|
space: space.key
|
|
3311
3531
|
}, {
|
|
3312
|
-
F:
|
|
3532
|
+
F: __dxlog_file13,
|
|
3313
3533
|
L: 231,
|
|
3314
3534
|
S: this,
|
|
3315
3535
|
C: (f, a) => f(...a)
|
|
@@ -3317,11 +3537,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3317
3537
|
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
3318
3538
|
},
|
|
3319
3539
|
afterReady: async () => {
|
|
3320
|
-
|
|
3540
|
+
log11("after space ready", {
|
|
3321
3541
|
space: space.key,
|
|
3322
3542
|
open: this._isOpen
|
|
3323
3543
|
}, {
|
|
3324
|
-
F:
|
|
3544
|
+
F: __dxlog_file13,
|
|
3325
3545
|
L: 238,
|
|
3326
3546
|
S: this,
|
|
3327
3547
|
C: (f, a) => f(...a)
|
|
@@ -3331,10 +3551,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3331
3551
|
}
|
|
3332
3552
|
},
|
|
3333
3553
|
beforeClose: async () => {
|
|
3334
|
-
|
|
3554
|
+
log11("before space close", {
|
|
3335
3555
|
space: space.key
|
|
3336
3556
|
}, {
|
|
3337
|
-
F:
|
|
3557
|
+
F: __dxlog_file13,
|
|
3338
3558
|
L: 244,
|
|
3339
3559
|
S: this,
|
|
3340
3560
|
C: (f, a) => f(...a)
|
|
@@ -3357,19 +3577,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3357
3577
|
return dataSpace;
|
|
3358
3578
|
}
|
|
3359
3579
|
};
|
|
3360
|
-
|
|
3580
|
+
_ts_decorate4([
|
|
3361
3581
|
synchronized2
|
|
3362
3582
|
], DataSpaceManager.prototype, "open", null);
|
|
3363
|
-
|
|
3583
|
+
_ts_decorate4([
|
|
3364
3584
|
synchronized2
|
|
3365
3585
|
], DataSpaceManager.prototype, "close", null);
|
|
3366
|
-
|
|
3586
|
+
_ts_decorate4([
|
|
3367
3587
|
synchronized2
|
|
3368
3588
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3369
|
-
|
|
3589
|
+
_ts_decorate4([
|
|
3370
3590
|
synchronized2
|
|
3371
3591
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3372
|
-
DataSpaceManager =
|
|
3592
|
+
DataSpaceManager = _ts_decorate4([
|
|
3373
3593
|
trackLeaks2("open", "close")
|
|
3374
3594
|
], DataSpaceManager);
|
|
3375
3595
|
|
|
@@ -3379,11 +3599,11 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
|
3379
3599
|
import { raise as raise2 } from "@dxos/debug";
|
|
3380
3600
|
import { SpaceNotFoundError } from "@dxos/echo-pipeline";
|
|
3381
3601
|
import { ApiError } from "@dxos/errors";
|
|
3382
|
-
import { log as
|
|
3602
|
+
import { log as log12 } from "@dxos/log";
|
|
3383
3603
|
import { encodeError } from "@dxos/protocols";
|
|
3384
|
-
import { SpaceMember as
|
|
3604
|
+
import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3385
3605
|
import { humanize } from "@dxos/util";
|
|
3386
|
-
var
|
|
3606
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
3387
3607
|
var SpacesServiceImpl = class {
|
|
3388
3608
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
3389
3609
|
this._identityManager = _identityManager;
|
|
@@ -3400,9 +3620,8 @@ var SpacesServiceImpl = class {
|
|
|
3400
3620
|
return this._serializeSpace(space);
|
|
3401
3621
|
}
|
|
3402
3622
|
async updateSpace({ spaceKey, state }) {
|
|
3403
|
-
var _a;
|
|
3404
3623
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3405
|
-
const space =
|
|
3624
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3406
3625
|
if (state) {
|
|
3407
3626
|
switch (state) {
|
|
3408
3627
|
case SpaceState3.ACTIVE:
|
|
@@ -3421,10 +3640,10 @@ var SpacesServiceImpl = class {
|
|
|
3421
3640
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
3422
3641
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3423
3642
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
3424
|
-
|
|
3643
|
+
log12("update", {
|
|
3425
3644
|
spaces
|
|
3426
3645
|
}, {
|
|
3427
|
-
F:
|
|
3646
|
+
F: __dxlog_file14,
|
|
3428
3647
|
L: 78,
|
|
3429
3648
|
S: this,
|
|
3430
3649
|
C: (f, a) => f(...a)
|
|
@@ -3466,17 +3685,15 @@ var SpacesServiceImpl = class {
|
|
|
3466
3685
|
});
|
|
3467
3686
|
}
|
|
3468
3687
|
async postMessage({ spaceKey, channel, message }) {
|
|
3469
|
-
var _a;
|
|
3470
3688
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3471
|
-
const space =
|
|
3689
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3472
3690
|
await space.postMessage(getChannelId(channel), message);
|
|
3473
3691
|
}
|
|
3474
3692
|
subscribeMessages({ spaceKey, channel }) {
|
|
3475
3693
|
return new Stream10(({ ctx, next }) => {
|
|
3476
3694
|
scheduleTask5(ctx, async () => {
|
|
3477
|
-
var _a;
|
|
3478
3695
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3479
|
-
const space =
|
|
3696
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3480
3697
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3481
3698
|
next(message);
|
|
3482
3699
|
});
|
|
@@ -3486,8 +3703,7 @@ var SpacesServiceImpl = class {
|
|
|
3486
3703
|
}
|
|
3487
3704
|
queryCredentials({ spaceKey }) {
|
|
3488
3705
|
return new Stream10(({ ctx, next }) => {
|
|
3489
|
-
|
|
3490
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3706
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3491
3707
|
const processor = {
|
|
3492
3708
|
processCredential: async (credential) => {
|
|
3493
3709
|
next(credential);
|
|
@@ -3498,9 +3714,8 @@ var SpacesServiceImpl = class {
|
|
|
3498
3714
|
});
|
|
3499
3715
|
}
|
|
3500
3716
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3501
|
-
|
|
3502
|
-
const
|
|
3503
|
-
for (const credential of credentials != null ? credentials : []) {
|
|
3717
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3718
|
+
for (const credential of credentials ?? []) {
|
|
3504
3719
|
await space.controlPipeline.writer.write({
|
|
3505
3720
|
credential: {
|
|
3506
3721
|
credential
|
|
@@ -3509,13 +3724,11 @@ var SpacesServiceImpl = class {
|
|
|
3509
3724
|
}
|
|
3510
3725
|
}
|
|
3511
3726
|
async createEpoch({ spaceKey }) {
|
|
3512
|
-
var _a;
|
|
3513
3727
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3514
|
-
const space =
|
|
3728
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3515
3729
|
await space.createEpoch();
|
|
3516
3730
|
}
|
|
3517
3731
|
_serializeSpace(space) {
|
|
3518
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3519
3732
|
return {
|
|
3520
3733
|
spaceKey: space.key,
|
|
3521
3734
|
state: space.state,
|
|
@@ -3527,16 +3740,15 @@ var SpacesServiceImpl = class {
|
|
|
3527
3740
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
3528
3741
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
3529
3742
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
3530
|
-
dataFeeds:
|
|
3531
|
-
startDataTimeframe:
|
|
3532
|
-
currentDataTimeframe:
|
|
3533
|
-
targetDataTimeframe:
|
|
3534
|
-
totalDataTimeframe:
|
|
3743
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
3744
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
3745
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
3746
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
3747
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
3535
3748
|
},
|
|
3536
3749
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3537
|
-
var _a2, _b2, _c2;
|
|
3538
3750
|
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
3539
|
-
const isMe =
|
|
3751
|
+
const isMe = this._identityManager.identity?.identityKey.equals(member.key);
|
|
3540
3752
|
if (isMe) {
|
|
3541
3753
|
peers.push(space.presence.getLocalState());
|
|
3542
3754
|
}
|
|
@@ -3544,14 +3756,14 @@ var SpacesServiceImpl = class {
|
|
|
3544
3756
|
identity: {
|
|
3545
3757
|
identityKey: member.key,
|
|
3546
3758
|
profile: {
|
|
3547
|
-
displayName:
|
|
3759
|
+
displayName: member.assertion.profile?.displayName ?? humanize(member.key)
|
|
3548
3760
|
}
|
|
3549
3761
|
},
|
|
3550
|
-
presence: isMe || peers.length > 0 ?
|
|
3762
|
+
presence: isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
|
|
3551
3763
|
peerStates: peers
|
|
3552
3764
|
};
|
|
3553
3765
|
}),
|
|
3554
|
-
creator:
|
|
3766
|
+
creator: space.inner.spaceState.creator?.key,
|
|
3555
3767
|
cache: space.cache,
|
|
3556
3768
|
metrics: space.metrics
|
|
3557
3769
|
};
|
|
@@ -3561,19 +3773,32 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
3561
3773
|
|
|
3562
3774
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3563
3775
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
3776
|
+
import { Context as Context9 } from "@dxos/context";
|
|
3564
3777
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
3565
3778
|
import { failUndefined as failUndefined3 } from "@dxos/debug";
|
|
3566
3779
|
import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
|
|
3567
3780
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
3568
|
-
import { invariant as
|
|
3781
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3569
3782
|
import { Keyring } from "@dxos/keyring";
|
|
3570
3783
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3571
|
-
import { log as
|
|
3572
|
-
import { STORAGE_VERSION, trace as
|
|
3784
|
+
import { log as log13 } from "@dxos/log";
|
|
3785
|
+
import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace6 } from "@dxos/protocols";
|
|
3573
3786
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3574
3787
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
3575
|
-
|
|
3576
|
-
|
|
3788
|
+
import { trace as Trace2 } from "@dxos/tracing";
|
|
3789
|
+
import { safeInstanceof } from "@dxos/util";
|
|
3790
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
3791
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3792
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3793
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3794
|
+
else
|
|
3795
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3796
|
+
if (d = decorators[i])
|
|
3797
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3798
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3799
|
+
}
|
|
3800
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3801
|
+
var ServiceContext = class ServiceContext2 {
|
|
3577
3802
|
// prettier-ignore
|
|
3578
3803
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
3579
3804
|
this.storage = storage;
|
|
@@ -3607,84 +3832,80 @@ var ServiceContext = class {
|
|
|
3607
3832
|
});
|
|
3608
3833
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3609
3834
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3610
|
-
this._handlerFactories.set(Invitation5.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () =>
|
|
3611
|
-
var _a;
|
|
3612
|
-
return (_a = this.identityManager.identity) != null ? _a : failUndefined3();
|
|
3613
|
-
}, this._acceptIdentity.bind(this)));
|
|
3835
|
+
this._handlerFactories.set(Invitation5.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined3(), this._acceptIdentity.bind(this)));
|
|
3614
3836
|
}
|
|
3615
|
-
async open() {
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
L: 125,
|
|
3837
|
+
async open(ctx) {
|
|
3838
|
+
await this._checkStorageVersion();
|
|
3839
|
+
log13("opening...", void 0, {
|
|
3840
|
+
F: __dxlog_file15,
|
|
3841
|
+
L: 134,
|
|
3621
3842
|
S: this,
|
|
3622
3843
|
C: (f, a) => f(...a)
|
|
3623
3844
|
});
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3845
|
+
log13.trace("dxos.sdk.service-context.open", trace6.begin({
|
|
3846
|
+
id: this._instanceId
|
|
3847
|
+
}), {
|
|
3848
|
+
F: __dxlog_file15,
|
|
3849
|
+
L: 135,
|
|
3628
3850
|
S: this,
|
|
3629
3851
|
C: (f, a) => f(...a)
|
|
3630
3852
|
});
|
|
3631
3853
|
await this.signalManager.open();
|
|
3632
3854
|
await this.networkManager.open();
|
|
3633
3855
|
await this.spaceManager.open();
|
|
3634
|
-
await this.identityManager.open();
|
|
3856
|
+
await this.identityManager.open(ctx);
|
|
3635
3857
|
if (this.identityManager.identity) {
|
|
3636
|
-
await this._initialize();
|
|
3858
|
+
await this._initialize(ctx);
|
|
3637
3859
|
}
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3860
|
+
log13.trace("dxos.sdk.service-context.open", trace6.end({
|
|
3861
|
+
id: this._instanceId
|
|
3862
|
+
}), {
|
|
3863
|
+
F: __dxlog_file15,
|
|
3864
|
+
L: 143,
|
|
3641
3865
|
S: this,
|
|
3642
3866
|
C: (f, a) => f(...a)
|
|
3643
3867
|
});
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
F: __dxlog_file14,
|
|
3648
|
-
L: 138,
|
|
3868
|
+
log13("opened", void 0, {
|
|
3869
|
+
F: __dxlog_file15,
|
|
3870
|
+
L: 144,
|
|
3649
3871
|
S: this,
|
|
3650
3872
|
C: (f, a) => f(...a)
|
|
3651
3873
|
});
|
|
3652
3874
|
}
|
|
3653
3875
|
async close() {
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
L: 142,
|
|
3876
|
+
log13("closing...", void 0, {
|
|
3877
|
+
F: __dxlog_file15,
|
|
3878
|
+
L: 148,
|
|
3658
3879
|
S: this,
|
|
3659
3880
|
C: (f, a) => f(...a)
|
|
3660
3881
|
});
|
|
3661
3882
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3662
3883
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3663
3884
|
}
|
|
3664
|
-
await
|
|
3885
|
+
await this.dataSpaceManager?.close();
|
|
3665
3886
|
await this.identityManager.close();
|
|
3666
3887
|
await this.spaceManager.close();
|
|
3667
3888
|
await this.feedStore.close();
|
|
3668
3889
|
await this.networkManager.close();
|
|
3669
3890
|
await this.signalManager.close();
|
|
3670
3891
|
this.dataServiceSubscriptions.clear();
|
|
3671
|
-
|
|
3672
|
-
F:
|
|
3673
|
-
L:
|
|
3892
|
+
log13("closed", void 0, {
|
|
3893
|
+
F: __dxlog_file15,
|
|
3894
|
+
L: 159,
|
|
3674
3895
|
S: this,
|
|
3675
3896
|
C: (f, a) => f(...a)
|
|
3676
3897
|
});
|
|
3677
3898
|
}
|
|
3678
3899
|
async createIdentity(params = {}) {
|
|
3679
3900
|
const identity = await this.identityManager.createIdentity(params);
|
|
3680
|
-
await this._initialize();
|
|
3901
|
+
await this._initialize(new Context9());
|
|
3681
3902
|
return identity;
|
|
3682
3903
|
}
|
|
3683
3904
|
getInvitationHandler(invitation) {
|
|
3684
3905
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3685
|
-
|
|
3686
|
-
F:
|
|
3687
|
-
L:
|
|
3906
|
+
invariant12(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3907
|
+
F: __dxlog_file15,
|
|
3908
|
+
L: 171,
|
|
3688
3909
|
S: this,
|
|
3689
3910
|
A: [
|
|
3690
3911
|
"factory",
|
|
@@ -3695,25 +3916,24 @@ var ServiceContext = class {
|
|
|
3695
3916
|
}
|
|
3696
3917
|
async _acceptIdentity(params) {
|
|
3697
3918
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
3698
|
-
await this._initialize();
|
|
3919
|
+
await this._initialize(new Context9());
|
|
3699
3920
|
return identity;
|
|
3700
3921
|
}
|
|
3701
3922
|
async _checkStorageVersion() {
|
|
3702
3923
|
await this.metadataStore.load();
|
|
3703
|
-
if (this.metadataStore.version !==
|
|
3704
|
-
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${
|
|
3924
|
+
if (this.metadataStore.version !== STORAGE_VERSION2) {
|
|
3925
|
+
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${STORAGE_VERSION2}`);
|
|
3705
3926
|
}
|
|
3706
3927
|
}
|
|
3707
3928
|
// Called when identity is created.
|
|
3708
|
-
async _initialize() {
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
L: 186,
|
|
3929
|
+
async _initialize(ctx) {
|
|
3930
|
+
log13("initializing spaces...", void 0, {
|
|
3931
|
+
F: __dxlog_file15,
|
|
3932
|
+
L: 193,
|
|
3713
3933
|
S: this,
|
|
3714
3934
|
C: (f, a) => f(...a)
|
|
3715
3935
|
});
|
|
3716
|
-
const identity =
|
|
3936
|
+
const identity = this.identityManager.identity ?? failUndefined3();
|
|
3717
3937
|
const signingContext = {
|
|
3718
3938
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3719
3939
|
identityKey: identity.identityKey,
|
|
@@ -3730,9 +3950,9 @@ var ServiceContext = class {
|
|
|
3730
3950
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3731
3951
|
await this.dataSpaceManager.open();
|
|
3732
3952
|
this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
|
|
3733
|
-
|
|
3734
|
-
F:
|
|
3735
|
-
L:
|
|
3953
|
+
invariant12(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
3954
|
+
F: __dxlog_file15,
|
|
3955
|
+
L: 216,
|
|
3736
3956
|
S: this,
|
|
3737
3957
|
A: [
|
|
3738
3958
|
"this.dataSpaceManager",
|
|
@@ -3752,33 +3972,33 @@ var ServiceContext = class {
|
|
|
3752
3972
|
return;
|
|
3753
3973
|
}
|
|
3754
3974
|
if (!this.dataSpaceManager) {
|
|
3755
|
-
|
|
3975
|
+
log13("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3756
3976
|
details: assertion
|
|
3757
3977
|
}, {
|
|
3758
|
-
F:
|
|
3759
|
-
L:
|
|
3978
|
+
F: __dxlog_file15,
|
|
3979
|
+
L: 232,
|
|
3760
3980
|
S: this,
|
|
3761
3981
|
C: (f, a) => f(...a)
|
|
3762
3982
|
});
|
|
3763
3983
|
return;
|
|
3764
3984
|
}
|
|
3765
3985
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3766
|
-
|
|
3986
|
+
log13("space already exists, ignoring space admission", {
|
|
3767
3987
|
details: assertion
|
|
3768
3988
|
}, {
|
|
3769
|
-
F:
|
|
3770
|
-
L:
|
|
3989
|
+
F: __dxlog_file15,
|
|
3990
|
+
L: 236,
|
|
3771
3991
|
S: this,
|
|
3772
3992
|
C: (f, a) => f(...a)
|
|
3773
3993
|
});
|
|
3774
3994
|
return;
|
|
3775
3995
|
}
|
|
3776
3996
|
try {
|
|
3777
|
-
|
|
3997
|
+
log13("accepting space recorded in halo", {
|
|
3778
3998
|
details: assertion
|
|
3779
3999
|
}, {
|
|
3780
|
-
F:
|
|
3781
|
-
L:
|
|
4000
|
+
F: __dxlog_file15,
|
|
4001
|
+
L: 241,
|
|
3782
4002
|
S: this,
|
|
3783
4003
|
C: (f, a) => f(...a)
|
|
3784
4004
|
});
|
|
@@ -3787,9 +4007,9 @@ var ServiceContext = class {
|
|
|
3787
4007
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3788
4008
|
});
|
|
3789
4009
|
} catch (err) {
|
|
3790
|
-
|
|
3791
|
-
F:
|
|
3792
|
-
L:
|
|
4010
|
+
log13.catch(err, void 0, {
|
|
4011
|
+
F: __dxlog_file15,
|
|
4012
|
+
L: 247,
|
|
3793
4013
|
S: this,
|
|
3794
4014
|
C: (f, a) => f(...a)
|
|
3795
4015
|
});
|
|
@@ -3799,12 +4019,22 @@ var ServiceContext = class {
|
|
|
3799
4019
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3800
4020
|
}
|
|
3801
4021
|
};
|
|
4022
|
+
_ts_decorate5([
|
|
4023
|
+
Trace2.span()
|
|
4024
|
+
], ServiceContext.prototype, "open", null);
|
|
4025
|
+
_ts_decorate5([
|
|
4026
|
+
Trace2.span()
|
|
4027
|
+
], ServiceContext.prototype, "_initialize", null);
|
|
4028
|
+
ServiceContext = _ts_decorate5([
|
|
4029
|
+
safeInstanceof("dxos.client-services.ServiceContext"),
|
|
4030
|
+
Trace2.resource()
|
|
4031
|
+
], ServiceContext);
|
|
3802
4032
|
|
|
3803
4033
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
3804
4034
|
import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
|
|
3805
4035
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
3806
|
-
import { log as
|
|
3807
|
-
function
|
|
4036
|
+
import { log as log14, logInfo } from "@dxos/log";
|
|
4037
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
3808
4038
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3809
4039
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3810
4040
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3814,7 +4044,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
3814
4044
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3815
4045
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3816
4046
|
}
|
|
3817
|
-
var
|
|
4047
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
3818
4048
|
var Message;
|
|
3819
4049
|
(function(Message2) {
|
|
3820
4050
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -3836,29 +4066,29 @@ var Lock = class {
|
|
|
3836
4066
|
message: Message.ACQUIRING
|
|
3837
4067
|
});
|
|
3838
4068
|
try {
|
|
3839
|
-
|
|
3840
|
-
F:
|
|
4069
|
+
log14("aquiring lock...", void 0, {
|
|
4070
|
+
F: __dxlog_file16,
|
|
3841
4071
|
L: 42,
|
|
3842
4072
|
S: this,
|
|
3843
4073
|
C: (f, a) => f(...a)
|
|
3844
4074
|
});
|
|
3845
4075
|
await asyncTimeout(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
3846
|
-
|
|
3847
|
-
F:
|
|
4076
|
+
log14("acquired lock", void 0, {
|
|
4077
|
+
F: __dxlog_file16,
|
|
3848
4078
|
L: 44,
|
|
3849
4079
|
S: this,
|
|
3850
4080
|
C: (f, a) => f(...a)
|
|
3851
4081
|
});
|
|
3852
|
-
} catch
|
|
3853
|
-
|
|
3854
|
-
F:
|
|
4082
|
+
} catch {
|
|
4083
|
+
log14("stealing lock...", void 0, {
|
|
4084
|
+
F: __dxlog_file16,
|
|
3855
4085
|
L: 46,
|
|
3856
4086
|
S: this,
|
|
3857
4087
|
C: (f, a) => f(...a)
|
|
3858
4088
|
});
|
|
3859
4089
|
await this._requestLock(true);
|
|
3860
|
-
|
|
3861
|
-
F:
|
|
4090
|
+
log14("stolen lock", void 0, {
|
|
4091
|
+
F: __dxlog_file16,
|
|
3862
4092
|
L: 48,
|
|
3863
4093
|
S: this,
|
|
3864
4094
|
C: (f, a) => f(...a)
|
|
@@ -3874,10 +4104,10 @@ var Lock = class {
|
|
|
3874
4104
|
}
|
|
3875
4105
|
}
|
|
3876
4106
|
async _requestLock(steal = false) {
|
|
3877
|
-
|
|
4107
|
+
log14("requesting lock...", {
|
|
3878
4108
|
steal
|
|
3879
4109
|
}, {
|
|
3880
|
-
F:
|
|
4110
|
+
F: __dxlog_file16,
|
|
3881
4111
|
L: 63,
|
|
3882
4112
|
S: this,
|
|
3883
4113
|
C: (f, a) => f(...a)
|
|
@@ -3886,40 +4116,38 @@ var Lock = class {
|
|
|
3886
4116
|
void navigator.locks.request(this._lockKey, {
|
|
3887
4117
|
steal
|
|
3888
4118
|
}, async () => {
|
|
3889
|
-
|
|
3890
|
-
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
4119
|
+
await this._onAcquire?.();
|
|
3891
4120
|
acquired.wake();
|
|
3892
4121
|
this._releaseTrigger = new Trigger6();
|
|
3893
4122
|
await this._releaseTrigger.wait();
|
|
3894
|
-
|
|
3895
|
-
F:
|
|
4123
|
+
log14("releasing lock...", void 0, {
|
|
4124
|
+
F: __dxlog_file16,
|
|
3896
4125
|
L: 72,
|
|
3897
4126
|
S: this,
|
|
3898
4127
|
C: (f, a) => f(...a)
|
|
3899
4128
|
});
|
|
3900
|
-
await
|
|
3901
|
-
|
|
3902
|
-
F:
|
|
4129
|
+
await this._onRelease?.();
|
|
4130
|
+
log14("released lock", void 0, {
|
|
4131
|
+
F: __dxlog_file16,
|
|
3903
4132
|
L: 74,
|
|
3904
4133
|
S: this,
|
|
3905
4134
|
C: (f, a) => f(...a)
|
|
3906
4135
|
});
|
|
3907
4136
|
}).catch(async () => {
|
|
3908
|
-
|
|
3909
|
-
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
4137
|
+
await this._onRelease?.();
|
|
3910
4138
|
});
|
|
3911
4139
|
await acquired.wait();
|
|
3912
|
-
|
|
4140
|
+
log14("recieved lock", {
|
|
3913
4141
|
steal
|
|
3914
4142
|
}, {
|
|
3915
|
-
F:
|
|
4143
|
+
F: __dxlog_file16,
|
|
3916
4144
|
L: 81,
|
|
3917
4145
|
S: this,
|
|
3918
4146
|
C: (f, a) => f(...a)
|
|
3919
4147
|
});
|
|
3920
4148
|
}
|
|
3921
4149
|
};
|
|
3922
|
-
|
|
4150
|
+
_ts_decorate6([
|
|
3923
4151
|
logInfo
|
|
3924
4152
|
], Lock.prototype, "lockKey", null);
|
|
3925
4153
|
var isLocked = (lockPath) => {
|
|
@@ -3934,7 +4162,7 @@ import { createStorage, StorageType } from "@dxos/random-access-storage";
|
|
|
3934
4162
|
import { isNode } from "@dxos/util";
|
|
3935
4163
|
var StorageDriver = Runtime.Client.Storage.StorageDriver;
|
|
3936
4164
|
var createStorageObjects = (config) => {
|
|
3937
|
-
const { path = isNode() ? DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config
|
|
4165
|
+
const { path = isNode() ? DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config ?? {};
|
|
3938
4166
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
3939
4167
|
throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
3940
4168
|
}
|
|
@@ -4002,17 +4230,19 @@ var ServiceRegistry = class {
|
|
|
4002
4230
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4003
4231
|
import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
|
|
4004
4232
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
4005
|
-
import {
|
|
4233
|
+
import { Context as Context10 } from "@dxos/context";
|
|
4234
|
+
import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
|
|
4006
4235
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4007
|
-
import { invariant as
|
|
4236
|
+
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4008
4237
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
4009
|
-
import { log as
|
|
4238
|
+
import { log as log16 } from "@dxos/log";
|
|
4010
4239
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4011
4240
|
import { ModelFactory } from "@dxos/model-factory";
|
|
4012
4241
|
import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
|
|
4013
|
-
import { trace as
|
|
4242
|
+
import { trace as trace7 } from "@dxos/protocols";
|
|
4014
4243
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
4015
4244
|
import { TextModel } from "@dxos/text-model";
|
|
4245
|
+
import { TRACE_PROCESSOR, trace as Trace3 } from "@dxos/tracing";
|
|
4016
4246
|
|
|
4017
4247
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
4018
4248
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
@@ -4028,21 +4258,17 @@ var DevicesServiceImpl = class {
|
|
|
4028
4258
|
queryDevices() {
|
|
4029
4259
|
return new Stream11(({ next }) => {
|
|
4030
4260
|
const update = () => {
|
|
4031
|
-
|
|
4032
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
4261
|
+
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
4033
4262
|
if (!deviceKeys) {
|
|
4034
4263
|
next({
|
|
4035
4264
|
devices: []
|
|
4036
4265
|
});
|
|
4037
4266
|
} else {
|
|
4038
4267
|
next({
|
|
4039
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
|
|
4044
|
-
};
|
|
4045
|
-
})
|
|
4268
|
+
devices: Array.from(deviceKeys.values()).map((key) => ({
|
|
4269
|
+
deviceKey: key,
|
|
4270
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
|
|
4271
|
+
}))
|
|
4046
4272
|
});
|
|
4047
4273
|
}
|
|
4048
4274
|
};
|
|
@@ -4064,22 +4290,23 @@ var DevicesServiceImpl = class {
|
|
|
4064
4290
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
4065
4291
|
import { Event as Event7 } from "@dxos/async";
|
|
4066
4292
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
4067
|
-
import { getContextFromEntry, log as
|
|
4293
|
+
import { getContextFromEntry, log as log15 } from "@dxos/log";
|
|
4068
4294
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
4069
4295
|
import { jsonify, numericalValues, tracer } from "@dxos/util";
|
|
4070
4296
|
var LoggingServiceImpl = class {
|
|
4071
4297
|
constructor() {
|
|
4072
4298
|
this._logs = new Event7();
|
|
4299
|
+
this._started = /* @__PURE__ */ new Date();
|
|
4073
4300
|
this._logProcessor = (_config, entry2) => {
|
|
4074
4301
|
this._logs.emit(entry2);
|
|
4075
4302
|
};
|
|
4076
4303
|
}
|
|
4077
4304
|
async open() {
|
|
4078
|
-
|
|
4305
|
+
log15.runtimeConfig.processors.push(this._logProcessor);
|
|
4079
4306
|
}
|
|
4080
4307
|
async close() {
|
|
4081
|
-
const index =
|
|
4082
|
-
|
|
4308
|
+
const index = log15.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
4309
|
+
log15.runtimeConfig.processors.splice(index, 1);
|
|
4083
4310
|
}
|
|
4084
4311
|
async controlMetrics({ reset, record }) {
|
|
4085
4312
|
if (reset) {
|
|
@@ -4094,28 +4321,33 @@ var LoggingServiceImpl = class {
|
|
|
4094
4321
|
recording: tracer.recording
|
|
4095
4322
|
};
|
|
4096
4323
|
}
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4324
|
+
/**
|
|
4325
|
+
* @deprecated (Move to diagnostics).
|
|
4326
|
+
*/
|
|
4327
|
+
queryMetrics({ interval = 5e3 }) {
|
|
4328
|
+
const getNumericalValues = (key) => {
|
|
4329
|
+
const events = tracer.get(key) ?? [];
|
|
4101
4330
|
return {
|
|
4102
4331
|
key,
|
|
4103
|
-
stats: numericalValues(
|
|
4332
|
+
stats: numericalValues(events, "duration")
|
|
4104
4333
|
};
|
|
4105
4334
|
};
|
|
4106
4335
|
return new Stream12(({ next }) => {
|
|
4107
4336
|
const update = () => {
|
|
4108
4337
|
const metrics = {
|
|
4109
|
-
timestamp: new Date(),
|
|
4338
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4110
4339
|
values: [
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
]
|
|
4340
|
+
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4341
|
+
getNumericalValues("dxos.echo.pipeline.data")
|
|
4342
|
+
].filter(Boolean)
|
|
4114
4343
|
};
|
|
4115
|
-
next(
|
|
4344
|
+
next({
|
|
4345
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4346
|
+
metrics
|
|
4347
|
+
});
|
|
4116
4348
|
};
|
|
4117
4349
|
update();
|
|
4118
|
-
const i = setInterval(update, interval);
|
|
4350
|
+
const i = setInterval(update, Math.max(interval, 1e3));
|
|
4119
4351
|
return () => {
|
|
4120
4352
|
clearInterval(i);
|
|
4121
4353
|
};
|
|
@@ -4124,11 +4356,10 @@ var LoggingServiceImpl = class {
|
|
|
4124
4356
|
queryLogs(request) {
|
|
4125
4357
|
return new Stream12(({ ctx, next }) => {
|
|
4126
4358
|
const handler = (entry2) => {
|
|
4127
|
-
var _a, _b, _c, _d, _e;
|
|
4128
4359
|
if (LOG_PROCESSING > 0) {
|
|
4129
4360
|
return;
|
|
4130
4361
|
}
|
|
4131
|
-
if (
|
|
4362
|
+
if (entry2.meta?.F.includes("logging-service") || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
4132
4363
|
return;
|
|
4133
4364
|
}
|
|
4134
4365
|
if (!shouldLog(entry2, request)) {
|
|
@@ -4137,11 +4368,11 @@ var LoggingServiceImpl = class {
|
|
|
4137
4368
|
const record = {
|
|
4138
4369
|
...entry2,
|
|
4139
4370
|
context: jsonify(getContextFromEntry(entry2)),
|
|
4140
|
-
timestamp: new Date(),
|
|
4371
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4141
4372
|
meta: {
|
|
4142
4373
|
// TODO(dmaretskyi): Fix proto.
|
|
4143
|
-
file:
|
|
4144
|
-
line:
|
|
4374
|
+
file: entry2.meta?.F ?? "",
|
|
4375
|
+
line: entry2.meta?.L ?? 0
|
|
4145
4376
|
}
|
|
4146
4377
|
};
|
|
4147
4378
|
try {
|
|
@@ -4164,15 +4395,11 @@ var matchFilter = (filter, level, path, options) => {
|
|
|
4164
4395
|
}
|
|
4165
4396
|
};
|
|
4166
4397
|
var shouldLog = (entry2, request) => {
|
|
4167
|
-
|
|
4168
|
-
const options = (_a = request.options) != null ? _a : QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4398
|
+
const options = request.options ?? QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4169
4399
|
if (request.filters === void 0) {
|
|
4170
4400
|
return options === QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4171
4401
|
} else {
|
|
4172
|
-
return request.filters.some((filter) =>
|
|
4173
|
-
var _a2, _b;
|
|
4174
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
4175
|
-
});
|
|
4402
|
+
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
4176
4403
|
}
|
|
4177
4404
|
};
|
|
4178
4405
|
var LOG_PROCESSING = 0;
|
|
@@ -4211,17 +4438,32 @@ var NetworkServiceImpl = class {
|
|
|
4211
4438
|
|
|
4212
4439
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
4213
4440
|
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
4441
|
+
import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
4442
|
+
import { jsonKeyReplacer } from "@dxos/util";
|
|
4214
4443
|
var SystemServiceImpl = class {
|
|
4215
|
-
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4444
|
+
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4216
4445
|
this._config = config;
|
|
4217
4446
|
this._statusUpdate = statusUpdate;
|
|
4218
4447
|
this._getCurrentStatus = getCurrentStatus;
|
|
4448
|
+
this._getDiagnostics = getDiagnostics;
|
|
4219
4449
|
this._onUpdateStatus = onUpdateStatus;
|
|
4220
4450
|
this._onReset = onReset;
|
|
4221
4451
|
}
|
|
4222
4452
|
async getConfig() {
|
|
4223
|
-
|
|
4224
|
-
|
|
4453
|
+
return this._config?.values ?? {};
|
|
4454
|
+
}
|
|
4455
|
+
/**
|
|
4456
|
+
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
4457
|
+
*/
|
|
4458
|
+
async getDiagnostics({ keys } = {}) {
|
|
4459
|
+
const diagnostics = await this._getDiagnostics();
|
|
4460
|
+
return {
|
|
4461
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4462
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer({
|
|
4463
|
+
truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4464
|
+
humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
4465
|
+
})))
|
|
4466
|
+
};
|
|
4225
4467
|
}
|
|
4226
4468
|
async updateStatus({ status }) {
|
|
4227
4469
|
await this._onUpdateStatus(status);
|
|
@@ -4249,7 +4491,7 @@ var SystemServiceImpl = class {
|
|
|
4249
4491
|
};
|
|
4250
4492
|
|
|
4251
4493
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4252
|
-
function
|
|
4494
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
4253
4495
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4254
4496
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4255
4497
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4259,23 +4501,22 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
4259
4501
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4260
4502
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4261
4503
|
}
|
|
4262
|
-
var
|
|
4504
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
4263
4505
|
var createDefaultModelFactory = () => {
|
|
4264
|
-
return new ModelFactory().registerModel(
|
|
4506
|
+
return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
|
|
4265
4507
|
};
|
|
4266
|
-
var ClientServicesHost = class {
|
|
4508
|
+
var ClientServicesHost = class ClientServicesHost2 {
|
|
4267
4509
|
constructor({
|
|
4268
4510
|
config,
|
|
4269
4511
|
modelFactory = createDefaultModelFactory(),
|
|
4270
|
-
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
4271
4512
|
transportFactory,
|
|
4272
4513
|
signalManager,
|
|
4273
|
-
connectionLog,
|
|
4274
4514
|
storage,
|
|
4275
4515
|
// TODO(wittjosiah): Turn this on by default.
|
|
4276
4516
|
lockKey,
|
|
4277
4517
|
callbacks
|
|
4278
4518
|
} = {}) {
|
|
4519
|
+
this._tracingService = TRACE_PROCESSOR.createTraceSender();
|
|
4279
4520
|
this._statusUpdate = new Event8();
|
|
4280
4521
|
this._opening = false;
|
|
4281
4522
|
this._open = false;
|
|
@@ -4294,7 +4535,7 @@ var ClientServicesHost = class {
|
|
|
4294
4535
|
lockKey,
|
|
4295
4536
|
onAcquire: () => {
|
|
4296
4537
|
if (!this._opening) {
|
|
4297
|
-
void this.open();
|
|
4538
|
+
void this.open(new Context10());
|
|
4298
4539
|
}
|
|
4299
4540
|
},
|
|
4300
4541
|
onRelease: () => this.close()
|
|
@@ -4304,12 +4545,14 @@ var ClientServicesHost = class {
|
|
|
4304
4545
|
config: this._config,
|
|
4305
4546
|
statusUpdate: this._statusUpdate,
|
|
4306
4547
|
getCurrentStatus: () => this.isOpen ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
|
|
4548
|
+
getDiagnostics: () => {
|
|
4549
|
+
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4550
|
+
},
|
|
4307
4551
|
onUpdateStatus: async (status) => {
|
|
4308
|
-
var _a, _b;
|
|
4309
4552
|
if (!this.isOpen && status === SystemStatus.ACTIVE) {
|
|
4310
|
-
await
|
|
4553
|
+
await this._resourceLock?.acquire();
|
|
4311
4554
|
} else if (this.isOpen && status === SystemStatus.INACTIVE) {
|
|
4312
|
-
await
|
|
4555
|
+
await this._resourceLock?.release();
|
|
4313
4556
|
}
|
|
4314
4557
|
},
|
|
4315
4558
|
onReset: async () => {
|
|
@@ -4318,12 +4561,19 @@ var ClientServicesHost = class {
|
|
|
4318
4561
|
});
|
|
4319
4562
|
this._loggingService = new LoggingServiceImpl();
|
|
4320
4563
|
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
4321
|
-
SystemService: this._systemService
|
|
4564
|
+
SystemService: this._systemService,
|
|
4565
|
+
TracingService: this._tracingService
|
|
4322
4566
|
});
|
|
4323
4567
|
}
|
|
4324
4568
|
get isOpen() {
|
|
4325
4569
|
return this._open;
|
|
4326
4570
|
}
|
|
4571
|
+
get config() {
|
|
4572
|
+
return this._config;
|
|
4573
|
+
}
|
|
4574
|
+
get context() {
|
|
4575
|
+
return this._serviceContext;
|
|
4576
|
+
}
|
|
4327
4577
|
get serviceRegistry() {
|
|
4328
4578
|
return this._serviceRegistry;
|
|
4329
4579
|
}
|
|
@@ -4339,20 +4589,25 @@ var ClientServicesHost = class {
|
|
|
4339
4589
|
* Can only be called once.
|
|
4340
4590
|
*/
|
|
4341
4591
|
initialize({ config, ...options }) {
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
L: 167,
|
|
4592
|
+
invariant13(!this._open, "service host is open", {
|
|
4593
|
+
F: __dxlog_file17,
|
|
4594
|
+
L: 181,
|
|
4346
4595
|
S: this,
|
|
4347
4596
|
A: [
|
|
4348
4597
|
"!this._open",
|
|
4349
4598
|
"'service host is open'"
|
|
4350
4599
|
]
|
|
4351
4600
|
});
|
|
4601
|
+
log16("initializing...", void 0, {
|
|
4602
|
+
F: __dxlog_file17,
|
|
4603
|
+
L: 182,
|
|
4604
|
+
S: this,
|
|
4605
|
+
C: (f, a) => f(...a)
|
|
4606
|
+
});
|
|
4352
4607
|
if (config) {
|
|
4353
|
-
|
|
4354
|
-
F:
|
|
4355
|
-
L:
|
|
4608
|
+
invariant13(!this._config, "config already set", {
|
|
4609
|
+
F: __dxlog_file17,
|
|
4610
|
+
L: 185,
|
|
4356
4611
|
S: this,
|
|
4357
4612
|
A: [
|
|
4358
4613
|
"!this._config",
|
|
@@ -4365,12 +4620,12 @@ var ClientServicesHost = class {
|
|
|
4365
4620
|
}
|
|
4366
4621
|
}
|
|
4367
4622
|
const { connectionLog = true, transportFactory = createWebRTCTransportFactory({
|
|
4368
|
-
iceServers:
|
|
4369
|
-
}), signalManager = new WebsocketSignalManager(
|
|
4623
|
+
iceServers: this._config?.get("runtime.services.ice")
|
|
4624
|
+
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4370
4625
|
this._signalManager = signalManager;
|
|
4371
|
-
|
|
4372
|
-
F:
|
|
4373
|
-
L:
|
|
4626
|
+
invariant13(!this._networkManager, "network manager already set", {
|
|
4627
|
+
F: __dxlog_file17,
|
|
4628
|
+
L: 201,
|
|
4374
4629
|
S: this,
|
|
4375
4630
|
A: [
|
|
4376
4631
|
"!this._networkManager",
|
|
@@ -4382,51 +4637,56 @@ var ClientServicesHost = class {
|
|
|
4382
4637
|
transportFactory,
|
|
4383
4638
|
signalManager
|
|
4384
4639
|
});
|
|
4640
|
+
log16("initialized", void 0, {
|
|
4641
|
+
F: __dxlog_file17,
|
|
4642
|
+
L: 208,
|
|
4643
|
+
S: this,
|
|
4644
|
+
C: (f, a) => f(...a)
|
|
4645
|
+
});
|
|
4385
4646
|
}
|
|
4386
|
-
async open() {
|
|
4387
|
-
var _a, _b, _c;
|
|
4647
|
+
async open(ctx) {
|
|
4388
4648
|
if (this._open) {
|
|
4389
4649
|
return;
|
|
4390
4650
|
}
|
|
4391
4651
|
const traceId = PublicKey10.random().toHex();
|
|
4392
|
-
|
|
4652
|
+
log16.trace("dxos.client-services.host.open", trace7.begin({
|
|
4393
4653
|
id: traceId
|
|
4394
4654
|
}), {
|
|
4395
|
-
F:
|
|
4396
|
-
L:
|
|
4655
|
+
F: __dxlog_file17,
|
|
4656
|
+
L: 219,
|
|
4397
4657
|
S: this,
|
|
4398
4658
|
C: (f, a) => f(...a)
|
|
4399
4659
|
});
|
|
4400
|
-
|
|
4401
|
-
F:
|
|
4402
|
-
L:
|
|
4660
|
+
invariant13(this._config, "config not set", {
|
|
4661
|
+
F: __dxlog_file17,
|
|
4662
|
+
L: 221,
|
|
4403
4663
|
S: this,
|
|
4404
4664
|
A: [
|
|
4405
4665
|
"this._config",
|
|
4406
4666
|
"'config not set'"
|
|
4407
4667
|
]
|
|
4408
4668
|
});
|
|
4409
|
-
|
|
4410
|
-
F:
|
|
4411
|
-
L:
|
|
4669
|
+
invariant13(this._storage, "storage not set", {
|
|
4670
|
+
F: __dxlog_file17,
|
|
4671
|
+
L: 222,
|
|
4412
4672
|
S: this,
|
|
4413
4673
|
A: [
|
|
4414
4674
|
"this._storage",
|
|
4415
4675
|
"'storage not set'"
|
|
4416
4676
|
]
|
|
4417
4677
|
});
|
|
4418
|
-
|
|
4419
|
-
F:
|
|
4420
|
-
L:
|
|
4678
|
+
invariant13(this._signalManager, "signal manager not set", {
|
|
4679
|
+
F: __dxlog_file17,
|
|
4680
|
+
L: 223,
|
|
4421
4681
|
S: this,
|
|
4422
4682
|
A: [
|
|
4423
4683
|
"this._signalManager",
|
|
4424
4684
|
"'signal manager not set'"
|
|
4425
4685
|
]
|
|
4426
4686
|
});
|
|
4427
|
-
|
|
4428
|
-
F:
|
|
4429
|
-
L:
|
|
4687
|
+
invariant13(this._networkManager, "network manager not set", {
|
|
4688
|
+
F: __dxlog_file17,
|
|
4689
|
+
L: 224,
|
|
4430
4690
|
S: this,
|
|
4431
4691
|
A: [
|
|
4432
4692
|
"this._networkManager",
|
|
@@ -4434,20 +4694,20 @@ var ClientServicesHost = class {
|
|
|
4434
4694
|
]
|
|
4435
4695
|
});
|
|
4436
4696
|
this._opening = true;
|
|
4437
|
-
|
|
4438
|
-
lockKey:
|
|
4697
|
+
log16("opening...", {
|
|
4698
|
+
lockKey: this._resourceLock?.lockKey
|
|
4439
4699
|
}, {
|
|
4440
|
-
F:
|
|
4441
|
-
L:
|
|
4700
|
+
F: __dxlog_file17,
|
|
4701
|
+
L: 227,
|
|
4442
4702
|
S: this,
|
|
4443
4703
|
C: (f, a) => f(...a)
|
|
4444
4704
|
});
|
|
4445
|
-
await
|
|
4705
|
+
await this._resourceLock?.acquire();
|
|
4446
4706
|
await this._loggingService.open();
|
|
4447
4707
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4448
4708
|
this._serviceRegistry.setServices({
|
|
4449
4709
|
SystemService: this._systemService,
|
|
4450
|
-
IdentityService: new IdentityServiceImpl(this._serviceContext),
|
|
4710
|
+
IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
|
|
4451
4711
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4452
4712
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4453
4713
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -4457,6 +4717,7 @@ var ClientServicesHost = class {
|
|
|
4457
4717
|
DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4458
4718
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
4459
4719
|
LoggingService: this._loggingService,
|
|
4720
|
+
TracingService: this._tracingService,
|
|
4460
4721
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4461
4722
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
4462
4723
|
events: new DevtoolsHostEvents(),
|
|
@@ -4464,39 +4725,38 @@ var ClientServicesHost = class {
|
|
|
4464
4725
|
context: this._serviceContext
|
|
4465
4726
|
})
|
|
4466
4727
|
});
|
|
4467
|
-
await this._serviceContext.open();
|
|
4728
|
+
await this._serviceContext.open(ctx);
|
|
4468
4729
|
this._opening = false;
|
|
4469
4730
|
this._open = true;
|
|
4470
4731
|
this._statusUpdate.emit();
|
|
4471
|
-
const deviceKey =
|
|
4472
|
-
|
|
4732
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4733
|
+
log16("opened", {
|
|
4473
4734
|
deviceKey
|
|
4474
4735
|
}, {
|
|
4475
|
-
F:
|
|
4476
|
-
L:
|
|
4736
|
+
F: __dxlog_file17,
|
|
4737
|
+
L: 284,
|
|
4477
4738
|
S: this,
|
|
4478
4739
|
C: (f, a) => f(...a)
|
|
4479
4740
|
});
|
|
4480
|
-
|
|
4741
|
+
log16.trace("dxos.client-services.host.open", trace7.end({
|
|
4481
4742
|
id: traceId
|
|
4482
4743
|
}), {
|
|
4483
|
-
F:
|
|
4484
|
-
L:
|
|
4744
|
+
F: __dxlog_file17,
|
|
4745
|
+
L: 285,
|
|
4485
4746
|
S: this,
|
|
4486
4747
|
C: (f, a) => f(...a)
|
|
4487
4748
|
});
|
|
4488
4749
|
}
|
|
4489
4750
|
async close() {
|
|
4490
|
-
var _a;
|
|
4491
4751
|
if (!this._open) {
|
|
4492
4752
|
return;
|
|
4493
4753
|
}
|
|
4494
|
-
const deviceKey =
|
|
4495
|
-
|
|
4754
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4755
|
+
log16("closing...", {
|
|
4496
4756
|
deviceKey
|
|
4497
4757
|
}, {
|
|
4498
|
-
F:
|
|
4499
|
-
L:
|
|
4758
|
+
F: __dxlog_file17,
|
|
4759
|
+
L: 296,
|
|
4500
4760
|
S: this,
|
|
4501
4761
|
C: (f, a) => f(...a)
|
|
4502
4762
|
});
|
|
@@ -4507,57 +4767,67 @@ var ClientServicesHost = class {
|
|
|
4507
4767
|
await this._serviceContext.close();
|
|
4508
4768
|
this._open = false;
|
|
4509
4769
|
this._statusUpdate.emit();
|
|
4510
|
-
|
|
4770
|
+
log16("closed", {
|
|
4511
4771
|
deviceKey
|
|
4512
4772
|
}, {
|
|
4513
|
-
F:
|
|
4514
|
-
L:
|
|
4773
|
+
F: __dxlog_file17,
|
|
4774
|
+
L: 302,
|
|
4515
4775
|
S: this,
|
|
4516
4776
|
C: (f, a) => f(...a)
|
|
4517
4777
|
});
|
|
4518
4778
|
}
|
|
4519
4779
|
async reset() {
|
|
4520
|
-
var _a, _b, _c;
|
|
4521
4780
|
const traceId = PublicKey10.random().toHex();
|
|
4522
|
-
|
|
4781
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace7.begin({
|
|
4523
4782
|
id: traceId
|
|
4524
4783
|
}), {
|
|
4525
|
-
F:
|
|
4526
|
-
L:
|
|
4784
|
+
F: __dxlog_file17,
|
|
4785
|
+
L: 307,
|
|
4527
4786
|
S: this,
|
|
4528
4787
|
C: (f, a) => f(...a)
|
|
4529
4788
|
});
|
|
4530
|
-
|
|
4531
|
-
F:
|
|
4532
|
-
L:
|
|
4789
|
+
log16("resetting...", void 0, {
|
|
4790
|
+
F: __dxlog_file17,
|
|
4791
|
+
L: 309,
|
|
4533
4792
|
S: this,
|
|
4534
4793
|
C: (f, a) => f(...a)
|
|
4535
4794
|
});
|
|
4536
|
-
await
|
|
4795
|
+
await this._serviceContext?.close();
|
|
4537
4796
|
await this._storage.reset();
|
|
4538
|
-
|
|
4539
|
-
F:
|
|
4540
|
-
L:
|
|
4797
|
+
log16("reset", void 0, {
|
|
4798
|
+
F: __dxlog_file17,
|
|
4799
|
+
L: 312,
|
|
4541
4800
|
S: this,
|
|
4542
4801
|
C: (f, a) => f(...a)
|
|
4543
4802
|
});
|
|
4544
|
-
|
|
4803
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace7.end({
|
|
4545
4804
|
id: traceId
|
|
4546
4805
|
}), {
|
|
4547
|
-
F:
|
|
4548
|
-
L:
|
|
4806
|
+
F: __dxlog_file17,
|
|
4807
|
+
L: 313,
|
|
4549
4808
|
S: this,
|
|
4550
4809
|
C: (f, a) => f(...a)
|
|
4551
4810
|
});
|
|
4552
|
-
await
|
|
4811
|
+
await this._callbacks?.onReset?.();
|
|
4553
4812
|
}
|
|
4554
4813
|
};
|
|
4555
|
-
|
|
4556
|
-
|
|
4814
|
+
_ts_decorate7([
|
|
4815
|
+
Trace3.info()
|
|
4816
|
+
], ClientServicesHost.prototype, "_opening", void 0);
|
|
4817
|
+
_ts_decorate7([
|
|
4818
|
+
Trace3.info()
|
|
4819
|
+
], ClientServicesHost.prototype, "_open", void 0);
|
|
4820
|
+
_ts_decorate7([
|
|
4821
|
+
synchronized3,
|
|
4822
|
+
Trace3.span()
|
|
4557
4823
|
], ClientServicesHost.prototype, "open", null);
|
|
4558
|
-
|
|
4559
|
-
synchronized3
|
|
4824
|
+
_ts_decorate7([
|
|
4825
|
+
synchronized3,
|
|
4826
|
+
Trace3.span()
|
|
4560
4827
|
], ClientServicesHost.prototype, "close", null);
|
|
4828
|
+
ClientServicesHost = _ts_decorate7([
|
|
4829
|
+
Trace3.resource()
|
|
4830
|
+
], ClientServicesHost);
|
|
4561
4831
|
|
|
4562
4832
|
export {
|
|
4563
4833
|
subscribeToFeeds,
|
|
@@ -4580,6 +4850,7 @@ export {
|
|
|
4580
4850
|
InvitationsServiceImpl,
|
|
4581
4851
|
SpaceInvitationProtocol,
|
|
4582
4852
|
ClientRpcServer,
|
|
4853
|
+
createDiagnostics,
|
|
4583
4854
|
DataSpace,
|
|
4584
4855
|
DataSpaceManager,
|
|
4585
4856
|
SpacesServiceImpl,
|
|
@@ -4591,4 +4862,4 @@ export {
|
|
|
4591
4862
|
createDefaultModelFactory,
|
|
4592
4863
|
ClientServicesHost
|
|
4593
4864
|
};
|
|
4594
|
-
//# sourceMappingURL=chunk-
|
|
4865
|
+
//# sourceMappingURL=chunk-II6TDINB.mjs.map
|