@dxos/client-services 0.1.56-main.5ff23aa → 0.1.56-main.6293c6e
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-MM7EFAUT.mjs → chunk-BD23GURE.mjs} +428 -366
- package/dist/lib/browser/chunk-BD23GURE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -23
- 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 +443 -384
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +443 -392
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts +7 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +7 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +2 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +3 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -33
- package/src/packlets/devices/devices-service.test.ts +2 -1
- package/src/packlets/identity/identity-manager.test.ts +15 -3
- package/src/packlets/identity/identity-manager.ts +27 -6
- package/src/packlets/identity/identity-service.test.ts +17 -2
- package/src/packlets/identity/identity-service.ts +23 -14
- package/src/packlets/identity/identity.test.ts +7 -6
- package/src/packlets/identity/identity.ts +8 -3
- package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
- package/src/packlets/network/network-service.test.ts +2 -1
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/service-context.test.ts +59 -0
- package/src/packlets/services/service-context.ts +14 -6
- package/src/packlets/services/service-host.test.ts +6 -5
- package/src/packlets/services/service-host.ts +26 -10
- package/src/packlets/services/service-registry.test.ts +2 -1
- package/src/packlets/spaces/data-space.ts +17 -5
- package/src/packlets/spaces/spaces-service.test.ts +2 -1
- package/src/packlets/testing/test-builder.ts +1 -1
- package/src/packlets/vault/iframe-host-runtime.ts +2 -1
- package/src/packlets/vault/worker-runtime.ts +2 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-MM7EFAUT.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}`);
|
|
@@ -2395,7 +2460,7 @@ import { STORAGE_VERSION } from "@dxos/protocols";
|
|
|
2395
2460
|
import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
2396
2461
|
|
|
2397
2462
|
// packages/sdk/client-services/src/version.ts
|
|
2398
|
-
var DXOS_VERSION = "0.1.56-main.
|
|
2463
|
+
var DXOS_VERSION = "0.1.56-main.6293c6e";
|
|
2399
2464
|
|
|
2400
2465
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
2401
2466
|
var getPlatform = () => {
|
|
@@ -2429,9 +2494,8 @@ var getPlatform = () => {
|
|
|
2429
2494
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2430
2495
|
var DEFAULT_TIMEOUT = 1e3;
|
|
2431
2496
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2432
|
-
var _a, _b, _c;
|
|
2433
2497
|
const diagnostics = {
|
|
2434
|
-
created: new Date().toISOString(),
|
|
2498
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2435
2499
|
platform: getPlatform(),
|
|
2436
2500
|
client: {
|
|
2437
2501
|
version: DXOS_VERSION,
|
|
@@ -2461,16 +2525,16 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2461
2525
|
spaceKey: identity.space.key,
|
|
2462
2526
|
profile: identity.profileDocument
|
|
2463
2527
|
};
|
|
2464
|
-
const { devices } =
|
|
2528
|
+
const { devices } = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
|
|
2465
2529
|
timeout: DEFAULT_TIMEOUT
|
|
2466
|
-
}).catch(() => void 0)
|
|
2530
|
+
}).catch(() => void 0) ?? {};
|
|
2467
2531
|
diagnostics.devices = devices;
|
|
2468
2532
|
if (serviceContext.dataSpaceManager) {
|
|
2469
|
-
diagnostics.spaces = await Promise.all(
|
|
2533
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2470
2534
|
}
|
|
2471
|
-
const { feeds = [] } =
|
|
2535
|
+
const { feeds = [] } = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2472
2536
|
timeout: DEFAULT_TIMEOUT
|
|
2473
|
-
}).catch(() => void 0)
|
|
2537
|
+
}).catch(() => void 0) ?? {};
|
|
2474
2538
|
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2475
2539
|
feedKey,
|
|
2476
2540
|
bytes,
|
|
@@ -2483,12 +2547,9 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2483
2547
|
var getProperties = (space) => {
|
|
2484
2548
|
let properties = {};
|
|
2485
2549
|
try {
|
|
2486
|
-
const propertiesItem = space.dataPipeline.itemManager.items.find((item) =>
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
});
|
|
2490
|
-
const state = propertiesItem == null ? void 0 : propertiesItem.state;
|
|
2491
|
-
properties = state == null ? void 0 : state.data;
|
|
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;
|
|
2492
2553
|
} catch (err) {
|
|
2493
2554
|
log8.warn(err.message, void 0, {
|
|
2494
2555
|
F: __dxlog_file10,
|
|
@@ -2500,7 +2561,6 @@ var getProperties = (space) => {
|
|
|
2500
2561
|
return properties;
|
|
2501
2562
|
};
|
|
2502
2563
|
var getSpaceStats = async (space) => {
|
|
2503
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2504
2564
|
const stats = {
|
|
2505
2565
|
key: space.key,
|
|
2506
2566
|
metrics: space.metrics,
|
|
@@ -2508,18 +2568,15 @@ var getSpaceStats = async (space) => {
|
|
|
2508
2568
|
...credential.subject.assertion,
|
|
2509
2569
|
id: credential.id
|
|
2510
2570
|
})),
|
|
2511
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
|
|
2521
|
-
};
|
|
2522
|
-
}),
|
|
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
|
+
})),
|
|
2523
2580
|
pipeline: {
|
|
2524
2581
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
2525
2582
|
// currentEpoch: space.dataPipeline.currentEpoch,
|
|
@@ -2529,11 +2586,11 @@ var getSpaceStats = async (space) => {
|
|
|
2529
2586
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2530
2587
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
2531
2588
|
// TODO(burdon): Empty?
|
|
2532
|
-
dataFeeds:
|
|
2533
|
-
startDataTimeframe:
|
|
2534
|
-
currentDataTimeframe:
|
|
2535
|
-
targetDataTimeframe:
|
|
2536
|
-
totalDataTimeframe:
|
|
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
|
|
2537
2594
|
}
|
|
2538
2595
|
};
|
|
2539
2596
|
if (space.dataPipeline.itemManager) {
|
|
@@ -2554,7 +2611,7 @@ var getSpaceStats = async (space) => {
|
|
|
2554
2611
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2555
2612
|
import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
|
|
2556
2613
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2557
|
-
import { cancelWithContext as cancelWithContext2, Context as
|
|
2614
|
+
import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
|
|
2558
2615
|
import { timed } from "@dxos/debug";
|
|
2559
2616
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2560
2617
|
import { CancelledError, SystemError } from "@dxos/errors";
|
|
@@ -2562,12 +2619,12 @@ import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
|
2562
2619
|
import { log as log10 } from "@dxos/log";
|
|
2563
2620
|
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
2564
2621
|
import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2565
|
-
import { Timeframe } from "@dxos/timeframe";
|
|
2622
|
+
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
2566
2623
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2567
2624
|
|
|
2568
2625
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2569
2626
|
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2570
|
-
import { Context as
|
|
2627
|
+
import { Context as Context6, rejectOnDispose } from "@dxos/context";
|
|
2571
2628
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2572
2629
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2573
2630
|
import { log as log9 } from "@dxos/log";
|
|
@@ -2581,7 +2638,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2581
2638
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2582
2639
|
var NotarizationPlugin = class {
|
|
2583
2640
|
constructor() {
|
|
2584
|
-
this._ctx = new
|
|
2641
|
+
this._ctx = new Context6();
|
|
2585
2642
|
this._extensionOpened = new Event4();
|
|
2586
2643
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2587
2644
|
this._processedCredentials = new ComplexSet(PublicKey6.hash);
|
|
@@ -2631,7 +2688,7 @@ var NotarizationPlugin = class {
|
|
|
2631
2688
|
errors.throw(err);
|
|
2632
2689
|
}
|
|
2633
2690
|
});
|
|
2634
|
-
opCtx
|
|
2691
|
+
opCtx?.onDispose(() => ctx.dispose());
|
|
2635
2692
|
if (timeout !== 0) {
|
|
2636
2693
|
scheduleTask3(ctx, () => {
|
|
2637
2694
|
log9.warn("Notarization timeout", {
|
|
@@ -2724,11 +2781,10 @@ var NotarizationPlugin = class {
|
|
|
2724
2781
|
* Called with credentials arriving from the control pipeline.
|
|
2725
2782
|
*/
|
|
2726
2783
|
async processCredential(credential) {
|
|
2727
|
-
var _a;
|
|
2728
2784
|
if (!credential.id) {
|
|
2729
2785
|
return;
|
|
2730
2786
|
}
|
|
2731
|
-
|
|
2787
|
+
this._processCredentialsTriggers.get(credential.id)?.wake();
|
|
2732
2788
|
this._processedCredentials.add(credential.id);
|
|
2733
2789
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2734
2790
|
}
|
|
@@ -2754,11 +2810,10 @@ var NotarizationPlugin = class {
|
|
|
2754
2810
|
* Requests from other peers to notarize credentials.
|
|
2755
2811
|
*/
|
|
2756
2812
|
async _onNotarize(request) {
|
|
2757
|
-
var _a;
|
|
2758
2813
|
if (!this._writer) {
|
|
2759
2814
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2760
2815
|
}
|
|
2761
|
-
for (const credential of
|
|
2816
|
+
for (const credential of request.credentials ?? []) {
|
|
2762
2817
|
invariant10(credential.id, "Credential must have an id", {
|
|
2763
2818
|
F: __dxlog_file11,
|
|
2764
2819
|
L: 200,
|
|
@@ -2836,7 +2891,7 @@ var NotarizationTeleportExtension = class extends RpcExtension2 {
|
|
|
2836
2891
|
};
|
|
2837
2892
|
|
|
2838
2893
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2839
|
-
function
|
|
2894
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
2840
2895
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2841
2896
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2842
2897
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2847,9 +2902,10 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
2847
2902
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2848
2903
|
}
|
|
2849
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;
|
|
2850
2906
|
var DataSpace = class DataSpace2 {
|
|
2851
2907
|
constructor(params) {
|
|
2852
|
-
this._ctx = new
|
|
2908
|
+
this._ctx = new Context7();
|
|
2853
2909
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2854
2910
|
this._state = SpaceState.CLOSED;
|
|
2855
2911
|
/**
|
|
@@ -2858,7 +2914,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2858
2914
|
this.error = void 0;
|
|
2859
2915
|
this.stateUpdate = new Event5();
|
|
2860
2916
|
this.metrics = {};
|
|
2861
|
-
var _a;
|
|
2862
2917
|
this._inner = params.inner;
|
|
2863
2918
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
2864
2919
|
this._gossip = params.gossip;
|
|
@@ -2867,7 +2922,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2867
2922
|
this._feedStore = params.feedStore;
|
|
2868
2923
|
this._metadataStore = params.metadataStore;
|
|
2869
2924
|
this._signingContext = params.signingContext;
|
|
2870
|
-
this._callbacks =
|
|
2925
|
+
this._callbacks = params.callbacks ?? {};
|
|
2871
2926
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2872
2927
|
trustedKeysProvider: () => new ComplexSet2(PublicKey7.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2873
2928
|
update: this._inner.stateUpdate,
|
|
@@ -2907,21 +2962,20 @@ var DataSpace = class DataSpace2 {
|
|
|
2907
2962
|
async _open() {
|
|
2908
2963
|
await this._notarizationPlugin.open();
|
|
2909
2964
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2910
|
-
await this._inner.open();
|
|
2965
|
+
await this._inner.open(new Context7());
|
|
2911
2966
|
this._state = SpaceState.CONTROL_ONLY;
|
|
2912
2967
|
this.stateUpdate.emit();
|
|
2913
2968
|
this.metrics = {};
|
|
2914
|
-
this.metrics.open = new Date();
|
|
2969
|
+
this.metrics.open = /* @__PURE__ */ new Date();
|
|
2915
2970
|
}
|
|
2916
2971
|
async close() {
|
|
2917
2972
|
await this._close();
|
|
2918
2973
|
}
|
|
2919
2974
|
async _close() {
|
|
2920
|
-
|
|
2921
|
-
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2975
|
+
await this._callbacks.beforeClose?.();
|
|
2922
2976
|
this._state = SpaceState.CLOSED;
|
|
2923
2977
|
await this._ctx.dispose();
|
|
2924
|
-
this._ctx = new
|
|
2978
|
+
this._ctx = new Context7();
|
|
2925
2979
|
await this.authVerifier.close();
|
|
2926
2980
|
await this._inner.close();
|
|
2927
2981
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
@@ -2940,13 +2994,13 @@ var DataSpace = class DataSpace2 {
|
|
|
2940
2994
|
initializeDataPipelineAsync() {
|
|
2941
2995
|
scheduleTask4(this._ctx, async () => {
|
|
2942
2996
|
try {
|
|
2943
|
-
this.metrics.pipelineInitBegin = new Date();
|
|
2997
|
+
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
2944
2998
|
await this.initializeDataPipeline();
|
|
2945
2999
|
} catch (err) {
|
|
2946
3000
|
if (err instanceof CancelledError) {
|
|
2947
3001
|
log10("data pipeline initialization cancelled", err, {
|
|
2948
3002
|
F: __dxlog_file12,
|
|
2949
|
-
L:
|
|
3003
|
+
L: 199,
|
|
2950
3004
|
S: this,
|
|
2951
3005
|
C: (f, a) => f(...a)
|
|
2952
3006
|
});
|
|
@@ -2954,7 +3008,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2954
3008
|
}
|
|
2955
3009
|
log10.error("Error initializing data pipeline", err, {
|
|
2956
3010
|
F: __dxlog_file12,
|
|
2957
|
-
L:
|
|
3011
|
+
L: 203,
|
|
2958
3012
|
S: this,
|
|
2959
3013
|
C: (f, a) => f(...a)
|
|
2960
3014
|
});
|
|
@@ -2962,12 +3016,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2962
3016
|
this.error = err;
|
|
2963
3017
|
this.stateUpdate.emit();
|
|
2964
3018
|
} finally {
|
|
2965
|
-
this.metrics.ready = new Date();
|
|
3019
|
+
this.metrics.ready = /* @__PURE__ */ new Date();
|
|
2966
3020
|
}
|
|
2967
3021
|
});
|
|
2968
3022
|
}
|
|
2969
3023
|
async initializeDataPipeline() {
|
|
2970
|
-
var _a, _b, _c, _d;
|
|
2971
3024
|
if (this._state !== SpaceState.CONTROL_ONLY) {
|
|
2972
3025
|
throw new SystemError("Invalid operation");
|
|
2973
3026
|
}
|
|
@@ -2976,11 +3029,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2976
3029
|
ctx: this._ctx,
|
|
2977
3030
|
breakOnStall: false
|
|
2978
3031
|
});
|
|
2979
|
-
this.metrics.controlPipelineReady = new Date();
|
|
3032
|
+
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
2980
3033
|
await this._createWritableFeeds();
|
|
2981
3034
|
log10("writable feeds created", void 0, {
|
|
2982
3035
|
F: __dxlog_file12,
|
|
2983
|
-
L:
|
|
3036
|
+
L: 227,
|
|
2984
3037
|
S: this,
|
|
2985
3038
|
C: (f, a) => f(...a)
|
|
2986
3039
|
});
|
|
@@ -2993,11 +3046,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2993
3046
|
}), this._inner.controlPipeline.writer));
|
|
2994
3047
|
}
|
|
2995
3048
|
await this._inner.initializeDataPipeline();
|
|
2996
|
-
this.metrics.dataPipelineOpen = new Date();
|
|
3049
|
+
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
2997
3050
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2998
3051
|
log10("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2999
3052
|
F: __dxlog_file12,
|
|
3000
|
-
L:
|
|
3053
|
+
L: 248,
|
|
3001
3054
|
S: this,
|
|
3002
3055
|
C: (f, a) => f(...a)
|
|
3003
3056
|
});
|
|
@@ -3005,17 +3058,17 @@ var DataSpace = class DataSpace2 {
|
|
|
3005
3058
|
ctx: this._ctx,
|
|
3006
3059
|
breakOnStall: false
|
|
3007
3060
|
});
|
|
3008
|
-
this.metrics.dataPipelineReady = new Date();
|
|
3061
|
+
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3009
3062
|
log10("data pipeline ready", void 0, {
|
|
3010
3063
|
F: __dxlog_file12,
|
|
3011
|
-
L:
|
|
3064
|
+
L: 257,
|
|
3012
3065
|
S: this,
|
|
3013
3066
|
C: (f, a) => f(...a)
|
|
3014
3067
|
});
|
|
3015
|
-
await
|
|
3068
|
+
await this._callbacks.beforeReady?.();
|
|
3016
3069
|
this._state = SpaceState.READY;
|
|
3017
3070
|
this.stateUpdate.emit();
|
|
3018
|
-
await
|
|
3071
|
+
await this._callbacks.afterReady?.();
|
|
3019
3072
|
}
|
|
3020
3073
|
async _createWritableFeeds() {
|
|
3021
3074
|
const credentials = [];
|
|
@@ -3062,7 +3115,6 @@ var DataSpace = class DataSpace2 {
|
|
|
3062
3115
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
3063
3116
|
}
|
|
3064
3117
|
async createEpoch() {
|
|
3065
|
-
var _a, _b;
|
|
3066
3118
|
const epoch = await this.dataPipeline.createEpoch();
|
|
3067
3119
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
3068
3120
|
credential: {
|
|
@@ -3075,16 +3127,19 @@ var DataSpace = class DataSpace2 {
|
|
|
3075
3127
|
})
|
|
3076
3128
|
}
|
|
3077
3129
|
});
|
|
3078
|
-
await this.inner.controlPipeline.state.waitUntilTimeframe(new
|
|
3130
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe2([
|
|
3079
3131
|
[
|
|
3080
3132
|
receipt.feedKey,
|
|
3081
3133
|
receipt.seq
|
|
3082
3134
|
]
|
|
3083
3135
|
]));
|
|
3084
|
-
|
|
3085
|
-
const
|
|
3086
|
-
|
|
3087
|
-
|
|
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);
|
|
3088
3143
|
}
|
|
3089
3144
|
}
|
|
3090
3145
|
}
|
|
@@ -3106,33 +3161,33 @@ var DataSpace = class DataSpace2 {
|
|
|
3106
3161
|
this.stateUpdate.emit();
|
|
3107
3162
|
}
|
|
3108
3163
|
};
|
|
3109
|
-
|
|
3164
|
+
_ts_decorate3([
|
|
3110
3165
|
synchronized
|
|
3111
3166
|
], DataSpace.prototype, "open", null);
|
|
3112
|
-
|
|
3167
|
+
_ts_decorate3([
|
|
3113
3168
|
synchronized
|
|
3114
3169
|
], DataSpace.prototype, "close", null);
|
|
3115
|
-
|
|
3170
|
+
_ts_decorate3([
|
|
3116
3171
|
timed(1e4)
|
|
3117
3172
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
3118
|
-
|
|
3173
|
+
_ts_decorate3([
|
|
3119
3174
|
synchronized
|
|
3120
3175
|
], DataSpace.prototype, "activate", null);
|
|
3121
|
-
|
|
3176
|
+
_ts_decorate3([
|
|
3122
3177
|
synchronized
|
|
3123
3178
|
], DataSpace.prototype, "deactivate", null);
|
|
3124
|
-
DataSpace =
|
|
3179
|
+
DataSpace = _ts_decorate3([
|
|
3125
3180
|
trackLeaks("open", "close")
|
|
3126
3181
|
], DataSpace);
|
|
3127
3182
|
|
|
3128
3183
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
3129
3184
|
import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
3130
|
-
import { cancelWithContext as cancelWithContext3, Context as
|
|
3185
|
+
import { cancelWithContext as cancelWithContext3, Context as Context8 } from "@dxos/context";
|
|
3131
3186
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3132
3187
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3133
3188
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
3134
3189
|
import { log as log11 } from "@dxos/log";
|
|
3135
|
-
import { trace as
|
|
3190
|
+
import { trace as trace5 } from "@dxos/protocols";
|
|
3136
3191
|
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3137
3192
|
import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
|
|
3138
3193
|
import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxos/util";
|
|
@@ -3141,9 +3196,8 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxo
|
|
|
3141
3196
|
import { createCredential } from "@dxos/credentials";
|
|
3142
3197
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
3143
3198
|
import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3144
|
-
import { Timeframe as
|
|
3199
|
+
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3145
3200
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
3146
|
-
var _a, _b, _c, _d;
|
|
3147
3201
|
const credentials = [
|
|
3148
3202
|
await createCredential({
|
|
3149
3203
|
signer: keyring,
|
|
@@ -3163,11 +3217,11 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3163
3217
|
spaceKey: space.key,
|
|
3164
3218
|
role: SpaceMember2.Role.ADMIN,
|
|
3165
3219
|
profile: signingContext.profile,
|
|
3166
|
-
genesisFeedKey:
|
|
3220
|
+
genesisFeedKey: space.controlFeedKey ?? failUndefined2()
|
|
3167
3221
|
}
|
|
3168
3222
|
}),
|
|
3169
3223
|
await signingContext.credentialSigner.createCredential({
|
|
3170
|
-
subject:
|
|
3224
|
+
subject: space.controlFeedKey ?? failUndefined2(),
|
|
3171
3225
|
assertion: {
|
|
3172
3226
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
3173
3227
|
spaceKey: space.key,
|
|
@@ -3177,7 +3231,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3177
3231
|
}
|
|
3178
3232
|
}),
|
|
3179
3233
|
await signingContext.credentialSigner.createCredential({
|
|
3180
|
-
subject:
|
|
3234
|
+
subject: space.dataFeedKey ?? failUndefined2(),
|
|
3181
3235
|
assertion: {
|
|
3182
3236
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
3183
3237
|
spaceKey: space.key,
|
|
@@ -3187,12 +3241,12 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3187
3241
|
}
|
|
3188
3242
|
}),
|
|
3189
3243
|
await signingContext.credentialSigner.createCredential({
|
|
3190
|
-
subject:
|
|
3244
|
+
subject: space.key ?? failUndefined2(),
|
|
3191
3245
|
assertion: {
|
|
3192
3246
|
"@type": "dxos.halo.credentials.Epoch",
|
|
3193
3247
|
number: 0,
|
|
3194
3248
|
previousId: void 0,
|
|
3195
|
-
timeframe: new
|
|
3249
|
+
timeframe: new Timeframe3(),
|
|
3196
3250
|
snapshotCid: void 0
|
|
3197
3251
|
}
|
|
3198
3252
|
})
|
|
@@ -3208,7 +3262,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3208
3262
|
};
|
|
3209
3263
|
|
|
3210
3264
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
3211
|
-
function
|
|
3265
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3212
3266
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3213
3267
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3214
3268
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3227,7 +3281,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3227
3281
|
this._keyring = _keyring;
|
|
3228
3282
|
this._signingContext = _signingContext;
|
|
3229
3283
|
this._feedStore = _feedStore;
|
|
3230
|
-
this._ctx = new
|
|
3284
|
+
this._ctx = new Context8();
|
|
3231
3285
|
this.updated = new Event6();
|
|
3232
3286
|
this._spaces = new ComplexMap3(PublicKey8.hash);
|
|
3233
3287
|
this._isOpen = false;
|
|
@@ -3244,7 +3298,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3244
3298
|
S: this,
|
|
3245
3299
|
C: (f, a) => f(...a)
|
|
3246
3300
|
});
|
|
3247
|
-
log11.trace("dxos.echo.data-space-manager.open",
|
|
3301
|
+
log11.trace("dxos.echo.data-space-manager.open", trace5.begin({
|
|
3248
3302
|
id: this._instanceId
|
|
3249
3303
|
}), {
|
|
3250
3304
|
F: __dxlog_file13,
|
|
@@ -3289,7 +3343,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3289
3343
|
}
|
|
3290
3344
|
this._isOpen = true;
|
|
3291
3345
|
this.updated.emit();
|
|
3292
|
-
log11.trace("dxos.echo.data-space-manager.open",
|
|
3346
|
+
log11.trace("dxos.echo.data-space-manager.open", trace5.end({
|
|
3293
3347
|
id: this._instanceId
|
|
3294
3348
|
}), {
|
|
3295
3349
|
F: __dxlog_file13,
|
|
@@ -3523,19 +3577,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3523
3577
|
return dataSpace;
|
|
3524
3578
|
}
|
|
3525
3579
|
};
|
|
3526
|
-
|
|
3580
|
+
_ts_decorate4([
|
|
3527
3581
|
synchronized2
|
|
3528
3582
|
], DataSpaceManager.prototype, "open", null);
|
|
3529
|
-
|
|
3583
|
+
_ts_decorate4([
|
|
3530
3584
|
synchronized2
|
|
3531
3585
|
], DataSpaceManager.prototype, "close", null);
|
|
3532
|
-
|
|
3586
|
+
_ts_decorate4([
|
|
3533
3587
|
synchronized2
|
|
3534
3588
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3535
|
-
|
|
3589
|
+
_ts_decorate4([
|
|
3536
3590
|
synchronized2
|
|
3537
3591
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3538
|
-
DataSpaceManager =
|
|
3592
|
+
DataSpaceManager = _ts_decorate4([
|
|
3539
3593
|
trackLeaks2("open", "close")
|
|
3540
3594
|
], DataSpaceManager);
|
|
3541
3595
|
|
|
@@ -3566,9 +3620,8 @@ var SpacesServiceImpl = class {
|
|
|
3566
3620
|
return this._serializeSpace(space);
|
|
3567
3621
|
}
|
|
3568
3622
|
async updateSpace({ spaceKey, state }) {
|
|
3569
|
-
var _a;
|
|
3570
3623
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3571
|
-
const space =
|
|
3624
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3572
3625
|
if (state) {
|
|
3573
3626
|
switch (state) {
|
|
3574
3627
|
case SpaceState3.ACTIVE:
|
|
@@ -3632,17 +3685,15 @@ var SpacesServiceImpl = class {
|
|
|
3632
3685
|
});
|
|
3633
3686
|
}
|
|
3634
3687
|
async postMessage({ spaceKey, channel, message }) {
|
|
3635
|
-
var _a;
|
|
3636
3688
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3637
|
-
const space =
|
|
3689
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3638
3690
|
await space.postMessage(getChannelId(channel), message);
|
|
3639
3691
|
}
|
|
3640
3692
|
subscribeMessages({ spaceKey, channel }) {
|
|
3641
3693
|
return new Stream10(({ ctx, next }) => {
|
|
3642
3694
|
scheduleTask5(ctx, async () => {
|
|
3643
|
-
var _a;
|
|
3644
3695
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3645
|
-
const space =
|
|
3696
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3646
3697
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3647
3698
|
next(message);
|
|
3648
3699
|
});
|
|
@@ -3652,8 +3703,7 @@ var SpacesServiceImpl = class {
|
|
|
3652
3703
|
}
|
|
3653
3704
|
queryCredentials({ spaceKey }) {
|
|
3654
3705
|
return new Stream10(({ ctx, next }) => {
|
|
3655
|
-
|
|
3656
|
-
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));
|
|
3657
3707
|
const processor = {
|
|
3658
3708
|
processCredential: async (credential) => {
|
|
3659
3709
|
next(credential);
|
|
@@ -3664,9 +3714,8 @@ var SpacesServiceImpl = class {
|
|
|
3664
3714
|
});
|
|
3665
3715
|
}
|
|
3666
3716
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3667
|
-
|
|
3668
|
-
const
|
|
3669
|
-
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 ?? []) {
|
|
3670
3719
|
await space.controlPipeline.writer.write({
|
|
3671
3720
|
credential: {
|
|
3672
3721
|
credential
|
|
@@ -3675,13 +3724,11 @@ var SpacesServiceImpl = class {
|
|
|
3675
3724
|
}
|
|
3676
3725
|
}
|
|
3677
3726
|
async createEpoch({ spaceKey }) {
|
|
3678
|
-
var _a;
|
|
3679
3727
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3680
|
-
const space =
|
|
3728
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3681
3729
|
await space.createEpoch();
|
|
3682
3730
|
}
|
|
3683
3731
|
_serializeSpace(space) {
|
|
3684
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3685
3732
|
return {
|
|
3686
3733
|
spaceKey: space.key,
|
|
3687
3734
|
state: space.state,
|
|
@@ -3693,16 +3740,15 @@ var SpacesServiceImpl = class {
|
|
|
3693
3740
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
3694
3741
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
3695
3742
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
3696
|
-
dataFeeds:
|
|
3697
|
-
startDataTimeframe:
|
|
3698
|
-
currentDataTimeframe:
|
|
3699
|
-
targetDataTimeframe:
|
|
3700
|
-
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
|
|
3701
3748
|
},
|
|
3702
3749
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3703
|
-
var _a2, _b2, _c2;
|
|
3704
3750
|
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
3705
|
-
const isMe =
|
|
3751
|
+
const isMe = this._identityManager.identity?.identityKey.equals(member.key);
|
|
3706
3752
|
if (isMe) {
|
|
3707
3753
|
peers.push(space.presence.getLocalState());
|
|
3708
3754
|
}
|
|
@@ -3710,14 +3756,14 @@ var SpacesServiceImpl = class {
|
|
|
3710
3756
|
identity: {
|
|
3711
3757
|
identityKey: member.key,
|
|
3712
3758
|
profile: {
|
|
3713
|
-
displayName:
|
|
3759
|
+
displayName: member.assertion.profile?.displayName ?? humanize(member.key)
|
|
3714
3760
|
}
|
|
3715
3761
|
},
|
|
3716
3762
|
presence: isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
|
|
3717
3763
|
peerStates: peers
|
|
3718
3764
|
};
|
|
3719
3765
|
}),
|
|
3720
|
-
creator:
|
|
3766
|
+
creator: space.inner.spaceState.creator?.key,
|
|
3721
3767
|
cache: space.cache,
|
|
3722
3768
|
metrics: space.metrics
|
|
3723
3769
|
};
|
|
@@ -3727,6 +3773,7 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
3727
3773
|
|
|
3728
3774
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3729
3775
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
3776
|
+
import { Context as Context9 } from "@dxos/context";
|
|
3730
3777
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
3731
3778
|
import { failUndefined as failUndefined3 } from "@dxos/debug";
|
|
3732
3779
|
import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
|
|
@@ -3735,11 +3782,23 @@ import { invariant as invariant12 } from "@dxos/invariant";
|
|
|
3735
3782
|
import { Keyring } from "@dxos/keyring";
|
|
3736
3783
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3737
3784
|
import { log as log13 } from "@dxos/log";
|
|
3738
|
-
import { STORAGE_VERSION as STORAGE_VERSION2, trace as
|
|
3785
|
+
import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace6 } from "@dxos/protocols";
|
|
3739
3786
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3740
3787
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
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
|
+
}
|
|
3741
3800
|
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3742
|
-
var ServiceContext = class {
|
|
3801
|
+
var ServiceContext = class ServiceContext2 {
|
|
3743
3802
|
// prettier-ignore
|
|
3744
3803
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
3745
3804
|
this.storage = storage;
|
|
@@ -3773,61 +3832,57 @@ var ServiceContext = class {
|
|
|
3773
3832
|
});
|
|
3774
3833
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3775
3834
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3776
|
-
this._handlerFactories.set(Invitation5.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () =>
|
|
3777
|
-
var _a;
|
|
3778
|
-
return (_a = this.identityManager.identity) != null ? _a : failUndefined3();
|
|
3779
|
-
}, this._acceptIdentity.bind(this)));
|
|
3835
|
+
this._handlerFactories.set(Invitation5.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined3(), this._acceptIdentity.bind(this)));
|
|
3780
3836
|
}
|
|
3781
|
-
async open() {
|
|
3837
|
+
async open(ctx) {
|
|
3782
3838
|
await this._checkStorageVersion();
|
|
3783
3839
|
log13("opening...", void 0, {
|
|
3784
3840
|
F: __dxlog_file15,
|
|
3785
|
-
L:
|
|
3841
|
+
L: 134,
|
|
3786
3842
|
S: this,
|
|
3787
3843
|
C: (f, a) => f(...a)
|
|
3788
3844
|
});
|
|
3789
|
-
log13.trace("dxos.sdk.service-context.open",
|
|
3845
|
+
log13.trace("dxos.sdk.service-context.open", trace6.begin({
|
|
3790
3846
|
id: this._instanceId
|
|
3791
3847
|
}), {
|
|
3792
3848
|
F: __dxlog_file15,
|
|
3793
|
-
L:
|
|
3849
|
+
L: 135,
|
|
3794
3850
|
S: this,
|
|
3795
3851
|
C: (f, a) => f(...a)
|
|
3796
3852
|
});
|
|
3797
3853
|
await this.signalManager.open();
|
|
3798
3854
|
await this.networkManager.open();
|
|
3799
3855
|
await this.spaceManager.open();
|
|
3800
|
-
await this.identityManager.open();
|
|
3856
|
+
await this.identityManager.open(ctx);
|
|
3801
3857
|
if (this.identityManager.identity) {
|
|
3802
|
-
await this._initialize();
|
|
3858
|
+
await this._initialize(ctx);
|
|
3803
3859
|
}
|
|
3804
|
-
log13.trace("dxos.sdk.service-context.open",
|
|
3860
|
+
log13.trace("dxos.sdk.service-context.open", trace6.end({
|
|
3805
3861
|
id: this._instanceId
|
|
3806
3862
|
}), {
|
|
3807
3863
|
F: __dxlog_file15,
|
|
3808
|
-
L:
|
|
3864
|
+
L: 143,
|
|
3809
3865
|
S: this,
|
|
3810
3866
|
C: (f, a) => f(...a)
|
|
3811
3867
|
});
|
|
3812
3868
|
log13("opened", void 0, {
|
|
3813
3869
|
F: __dxlog_file15,
|
|
3814
|
-
L:
|
|
3870
|
+
L: 144,
|
|
3815
3871
|
S: this,
|
|
3816
3872
|
C: (f, a) => f(...a)
|
|
3817
3873
|
});
|
|
3818
3874
|
}
|
|
3819
3875
|
async close() {
|
|
3820
|
-
var _a;
|
|
3821
3876
|
log13("closing...", void 0, {
|
|
3822
3877
|
F: __dxlog_file15,
|
|
3823
|
-
L:
|
|
3878
|
+
L: 148,
|
|
3824
3879
|
S: this,
|
|
3825
3880
|
C: (f, a) => f(...a)
|
|
3826
3881
|
});
|
|
3827
3882
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3828
3883
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3829
3884
|
}
|
|
3830
|
-
await
|
|
3885
|
+
await this.dataSpaceManager?.close();
|
|
3831
3886
|
await this.identityManager.close();
|
|
3832
3887
|
await this.spaceManager.close();
|
|
3833
3888
|
await this.feedStore.close();
|
|
@@ -3836,21 +3891,21 @@ var ServiceContext = class {
|
|
|
3836
3891
|
this.dataServiceSubscriptions.clear();
|
|
3837
3892
|
log13("closed", void 0, {
|
|
3838
3893
|
F: __dxlog_file15,
|
|
3839
|
-
L:
|
|
3894
|
+
L: 159,
|
|
3840
3895
|
S: this,
|
|
3841
3896
|
C: (f, a) => f(...a)
|
|
3842
3897
|
});
|
|
3843
3898
|
}
|
|
3844
3899
|
async createIdentity(params = {}) {
|
|
3845
3900
|
const identity = await this.identityManager.createIdentity(params);
|
|
3846
|
-
await this._initialize();
|
|
3901
|
+
await this._initialize(new Context9());
|
|
3847
3902
|
return identity;
|
|
3848
3903
|
}
|
|
3849
3904
|
getInvitationHandler(invitation) {
|
|
3850
3905
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3851
3906
|
invariant12(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3852
3907
|
F: __dxlog_file15,
|
|
3853
|
-
L:
|
|
3908
|
+
L: 171,
|
|
3854
3909
|
S: this,
|
|
3855
3910
|
A: [
|
|
3856
3911
|
"factory",
|
|
@@ -3861,7 +3916,7 @@ var ServiceContext = class {
|
|
|
3861
3916
|
}
|
|
3862
3917
|
async _acceptIdentity(params) {
|
|
3863
3918
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
3864
|
-
await this._initialize();
|
|
3919
|
+
await this._initialize(new Context9());
|
|
3865
3920
|
return identity;
|
|
3866
3921
|
}
|
|
3867
3922
|
async _checkStorageVersion() {
|
|
@@ -3871,15 +3926,14 @@ var ServiceContext = class {
|
|
|
3871
3926
|
}
|
|
3872
3927
|
}
|
|
3873
3928
|
// Called when identity is created.
|
|
3874
|
-
async _initialize() {
|
|
3875
|
-
var _a;
|
|
3929
|
+
async _initialize(ctx) {
|
|
3876
3930
|
log13("initializing spaces...", void 0, {
|
|
3877
3931
|
F: __dxlog_file15,
|
|
3878
|
-
L:
|
|
3932
|
+
L: 193,
|
|
3879
3933
|
S: this,
|
|
3880
3934
|
C: (f, a) => f(...a)
|
|
3881
3935
|
});
|
|
3882
|
-
const identity =
|
|
3936
|
+
const identity = this.identityManager.identity ?? failUndefined3();
|
|
3883
3937
|
const signingContext = {
|
|
3884
3938
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3885
3939
|
identityKey: identity.identityKey,
|
|
@@ -3898,7 +3952,7 @@ var ServiceContext = class {
|
|
|
3898
3952
|
this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
|
|
3899
3953
|
invariant12(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
3900
3954
|
F: __dxlog_file15,
|
|
3901
|
-
L:
|
|
3955
|
+
L: 216,
|
|
3902
3956
|
S: this,
|
|
3903
3957
|
A: [
|
|
3904
3958
|
"this.dataSpaceManager",
|
|
@@ -3922,7 +3976,7 @@ var ServiceContext = class {
|
|
|
3922
3976
|
details: assertion
|
|
3923
3977
|
}, {
|
|
3924
3978
|
F: __dxlog_file15,
|
|
3925
|
-
L:
|
|
3979
|
+
L: 232,
|
|
3926
3980
|
S: this,
|
|
3927
3981
|
C: (f, a) => f(...a)
|
|
3928
3982
|
});
|
|
@@ -3933,7 +3987,7 @@ var ServiceContext = class {
|
|
|
3933
3987
|
details: assertion
|
|
3934
3988
|
}, {
|
|
3935
3989
|
F: __dxlog_file15,
|
|
3936
|
-
L:
|
|
3990
|
+
L: 236,
|
|
3937
3991
|
S: this,
|
|
3938
3992
|
C: (f, a) => f(...a)
|
|
3939
3993
|
});
|
|
@@ -3944,7 +3998,7 @@ var ServiceContext = class {
|
|
|
3944
3998
|
details: assertion
|
|
3945
3999
|
}, {
|
|
3946
4000
|
F: __dxlog_file15,
|
|
3947
|
-
L:
|
|
4001
|
+
L: 241,
|
|
3948
4002
|
S: this,
|
|
3949
4003
|
C: (f, a) => f(...a)
|
|
3950
4004
|
});
|
|
@@ -3955,7 +4009,7 @@ var ServiceContext = class {
|
|
|
3955
4009
|
} catch (err) {
|
|
3956
4010
|
log13.catch(err, void 0, {
|
|
3957
4011
|
F: __dxlog_file15,
|
|
3958
|
-
L:
|
|
4012
|
+
L: 247,
|
|
3959
4013
|
S: this,
|
|
3960
4014
|
C: (f, a) => f(...a)
|
|
3961
4015
|
});
|
|
@@ -3965,12 +4019,22 @@ var ServiceContext = class {
|
|
|
3965
4019
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3966
4020
|
}
|
|
3967
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);
|
|
3968
4032
|
|
|
3969
4033
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
3970
4034
|
import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
|
|
3971
4035
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
3972
4036
|
import { log as log14, logInfo } from "@dxos/log";
|
|
3973
|
-
function
|
|
4037
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
3974
4038
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3975
4039
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3976
4040
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4015,7 +4079,7 @@ var Lock = class {
|
|
|
4015
4079
|
S: this,
|
|
4016
4080
|
C: (f, a) => f(...a)
|
|
4017
4081
|
});
|
|
4018
|
-
} catch
|
|
4082
|
+
} catch {
|
|
4019
4083
|
log14("stealing lock...", void 0, {
|
|
4020
4084
|
F: __dxlog_file16,
|
|
4021
4085
|
L: 46,
|
|
@@ -4052,8 +4116,7 @@ var Lock = class {
|
|
|
4052
4116
|
void navigator.locks.request(this._lockKey, {
|
|
4053
4117
|
steal
|
|
4054
4118
|
}, async () => {
|
|
4055
|
-
|
|
4056
|
-
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
4119
|
+
await this._onAcquire?.();
|
|
4057
4120
|
acquired.wake();
|
|
4058
4121
|
this._releaseTrigger = new Trigger6();
|
|
4059
4122
|
await this._releaseTrigger.wait();
|
|
@@ -4063,7 +4126,7 @@ var Lock = class {
|
|
|
4063
4126
|
S: this,
|
|
4064
4127
|
C: (f, a) => f(...a)
|
|
4065
4128
|
});
|
|
4066
|
-
await
|
|
4129
|
+
await this._onRelease?.();
|
|
4067
4130
|
log14("released lock", void 0, {
|
|
4068
4131
|
F: __dxlog_file16,
|
|
4069
4132
|
L: 74,
|
|
@@ -4071,8 +4134,7 @@ var Lock = class {
|
|
|
4071
4134
|
C: (f, a) => f(...a)
|
|
4072
4135
|
});
|
|
4073
4136
|
}).catch(async () => {
|
|
4074
|
-
|
|
4075
|
-
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
4137
|
+
await this._onRelease?.();
|
|
4076
4138
|
});
|
|
4077
4139
|
await acquired.wait();
|
|
4078
4140
|
log14("recieved lock", {
|
|
@@ -4085,7 +4147,7 @@ var Lock = class {
|
|
|
4085
4147
|
});
|
|
4086
4148
|
}
|
|
4087
4149
|
};
|
|
4088
|
-
|
|
4150
|
+
_ts_decorate6([
|
|
4089
4151
|
logInfo
|
|
4090
4152
|
], Lock.prototype, "lockKey", null);
|
|
4091
4153
|
var isLocked = (lockPath) => {
|
|
@@ -4100,7 +4162,7 @@ import { createStorage, StorageType } from "@dxos/random-access-storage";
|
|
|
4100
4162
|
import { isNode } from "@dxos/util";
|
|
4101
4163
|
var StorageDriver = Runtime.Client.Storage.StorageDriver;
|
|
4102
4164
|
var createStorageObjects = (config) => {
|
|
4103
|
-
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 ?? {};
|
|
4104
4166
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
4105
4167
|
throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4106
4168
|
}
|
|
@@ -4168,6 +4230,7 @@ var ServiceRegistry = class {
|
|
|
4168
4230
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4169
4231
|
import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
|
|
4170
4232
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
4233
|
+
import { Context as Context10 } from "@dxos/context";
|
|
4171
4234
|
import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
|
|
4172
4235
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4173
4236
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
@@ -4176,9 +4239,10 @@ import { log as log16 } from "@dxos/log";
|
|
|
4176
4239
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4177
4240
|
import { ModelFactory } from "@dxos/model-factory";
|
|
4178
4241
|
import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
|
|
4179
|
-
import { trace as
|
|
4242
|
+
import { trace as trace7 } from "@dxos/protocols";
|
|
4180
4243
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
4181
4244
|
import { TextModel } from "@dxos/text-model";
|
|
4245
|
+
import { TRACE_PROCESSOR, trace as Trace3 } from "@dxos/tracing";
|
|
4182
4246
|
|
|
4183
4247
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
4184
4248
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
@@ -4194,21 +4258,17 @@ var DevicesServiceImpl = class {
|
|
|
4194
4258
|
queryDevices() {
|
|
4195
4259
|
return new Stream11(({ next }) => {
|
|
4196
4260
|
const update = () => {
|
|
4197
|
-
|
|
4198
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
4261
|
+
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
4199
4262
|
if (!deviceKeys) {
|
|
4200
4263
|
next({
|
|
4201
4264
|
devices: []
|
|
4202
4265
|
});
|
|
4203
4266
|
} else {
|
|
4204
4267
|
next({
|
|
4205
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
|
|
4210
|
-
};
|
|
4211
|
-
})
|
|
4268
|
+
devices: Array.from(deviceKeys.values()).map((key) => ({
|
|
4269
|
+
deviceKey: key,
|
|
4270
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
|
|
4271
|
+
}))
|
|
4212
4272
|
});
|
|
4213
4273
|
}
|
|
4214
4274
|
};
|
|
@@ -4236,7 +4296,7 @@ import { jsonify, numericalValues, tracer } from "@dxos/util";
|
|
|
4236
4296
|
var LoggingServiceImpl = class {
|
|
4237
4297
|
constructor() {
|
|
4238
4298
|
this._logs = new Event7();
|
|
4239
|
-
this._started = new Date();
|
|
4299
|
+
this._started = /* @__PURE__ */ new Date();
|
|
4240
4300
|
this._logProcessor = (_config, entry2) => {
|
|
4241
4301
|
this._logs.emit(entry2);
|
|
4242
4302
|
};
|
|
@@ -4266,8 +4326,7 @@ var LoggingServiceImpl = class {
|
|
|
4266
4326
|
*/
|
|
4267
4327
|
queryMetrics({ interval = 5e3 }) {
|
|
4268
4328
|
const getNumericalValues = (key) => {
|
|
4269
|
-
|
|
4270
|
-
const events = (_a = tracer.get(key)) != null ? _a : [];
|
|
4329
|
+
const events = tracer.get(key) ?? [];
|
|
4271
4330
|
return {
|
|
4272
4331
|
key,
|
|
4273
4332
|
stats: numericalValues(events, "duration")
|
|
@@ -4276,14 +4335,14 @@ var LoggingServiceImpl = class {
|
|
|
4276
4335
|
return new Stream12(({ next }) => {
|
|
4277
4336
|
const update = () => {
|
|
4278
4337
|
const metrics = {
|
|
4279
|
-
timestamp: new Date(),
|
|
4338
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4280
4339
|
values: [
|
|
4281
4340
|
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4282
4341
|
getNumericalValues("dxos.echo.pipeline.data")
|
|
4283
4342
|
].filter(Boolean)
|
|
4284
4343
|
};
|
|
4285
4344
|
next({
|
|
4286
|
-
timestamp: new Date(),
|
|
4345
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4287
4346
|
metrics
|
|
4288
4347
|
});
|
|
4289
4348
|
};
|
|
@@ -4297,11 +4356,10 @@ var LoggingServiceImpl = class {
|
|
|
4297
4356
|
queryLogs(request) {
|
|
4298
4357
|
return new Stream12(({ ctx, next }) => {
|
|
4299
4358
|
const handler = (entry2) => {
|
|
4300
|
-
var _a, _b, _c, _d, _e;
|
|
4301
4359
|
if (LOG_PROCESSING > 0) {
|
|
4302
4360
|
return;
|
|
4303
4361
|
}
|
|
4304
|
-
if (
|
|
4362
|
+
if (entry2.meta?.F.includes("logging-service") || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
4305
4363
|
return;
|
|
4306
4364
|
}
|
|
4307
4365
|
if (!shouldLog(entry2, request)) {
|
|
@@ -4310,11 +4368,11 @@ var LoggingServiceImpl = class {
|
|
|
4310
4368
|
const record = {
|
|
4311
4369
|
...entry2,
|
|
4312
4370
|
context: jsonify(getContextFromEntry(entry2)),
|
|
4313
|
-
timestamp: new Date(),
|
|
4371
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4314
4372
|
meta: {
|
|
4315
4373
|
// TODO(dmaretskyi): Fix proto.
|
|
4316
|
-
file:
|
|
4317
|
-
line:
|
|
4374
|
+
file: entry2.meta?.F ?? "",
|
|
4375
|
+
line: entry2.meta?.L ?? 0
|
|
4318
4376
|
}
|
|
4319
4377
|
};
|
|
4320
4378
|
try {
|
|
@@ -4337,15 +4395,11 @@ var matchFilter = (filter, level, path, options) => {
|
|
|
4337
4395
|
}
|
|
4338
4396
|
};
|
|
4339
4397
|
var shouldLog = (entry2, request) => {
|
|
4340
|
-
|
|
4341
|
-
const options = (_a = request.options) != null ? _a : QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4398
|
+
const options = request.options ?? QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4342
4399
|
if (request.filters === void 0) {
|
|
4343
4400
|
return options === QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4344
4401
|
} else {
|
|
4345
|
-
return request.filters.some((filter) =>
|
|
4346
|
-
var _a2, _b;
|
|
4347
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
4348
|
-
});
|
|
4402
|
+
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
4349
4403
|
}
|
|
4350
4404
|
};
|
|
4351
4405
|
var LOG_PROCESSING = 0;
|
|
@@ -4396,8 +4450,7 @@ var SystemServiceImpl = class {
|
|
|
4396
4450
|
this._onReset = onReset;
|
|
4397
4451
|
}
|
|
4398
4452
|
async getConfig() {
|
|
4399
|
-
|
|
4400
|
-
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
4453
|
+
return this._config?.values ?? {};
|
|
4401
4454
|
}
|
|
4402
4455
|
/**
|
|
4403
4456
|
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
@@ -4405,7 +4458,7 @@ var SystemServiceImpl = class {
|
|
|
4405
4458
|
async getDiagnostics({ keys } = {}) {
|
|
4406
4459
|
const diagnostics = await this._getDiagnostics();
|
|
4407
4460
|
return {
|
|
4408
|
-
timestamp: new Date(),
|
|
4461
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4409
4462
|
diagnostics: JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer({
|
|
4410
4463
|
truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4411
4464
|
humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
@@ -4438,7 +4491,7 @@ var SystemServiceImpl = class {
|
|
|
4438
4491
|
};
|
|
4439
4492
|
|
|
4440
4493
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4441
|
-
function
|
|
4494
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
4442
4495
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4443
4496
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4444
4497
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4452,7 +4505,7 @@ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
4452
4505
|
var createDefaultModelFactory = () => {
|
|
4453
4506
|
return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
|
|
4454
4507
|
};
|
|
4455
|
-
var ClientServicesHost = class {
|
|
4508
|
+
var ClientServicesHost = class ClientServicesHost2 {
|
|
4456
4509
|
constructor({
|
|
4457
4510
|
config,
|
|
4458
4511
|
modelFactory = createDefaultModelFactory(),
|
|
@@ -4463,6 +4516,7 @@ var ClientServicesHost = class {
|
|
|
4463
4516
|
lockKey,
|
|
4464
4517
|
callbacks
|
|
4465
4518
|
} = {}) {
|
|
4519
|
+
this._tracingService = TRACE_PROCESSOR.createTraceSender();
|
|
4466
4520
|
this._statusUpdate = new Event8();
|
|
4467
4521
|
this._opening = false;
|
|
4468
4522
|
this._open = false;
|
|
@@ -4481,7 +4535,7 @@ var ClientServicesHost = class {
|
|
|
4481
4535
|
lockKey,
|
|
4482
4536
|
onAcquire: () => {
|
|
4483
4537
|
if (!this._opening) {
|
|
4484
|
-
void this.open();
|
|
4538
|
+
void this.open(new Context10());
|
|
4485
4539
|
}
|
|
4486
4540
|
},
|
|
4487
4541
|
onRelease: () => this.close()
|
|
@@ -4495,11 +4549,10 @@ var ClientServicesHost = class {
|
|
|
4495
4549
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4496
4550
|
},
|
|
4497
4551
|
onUpdateStatus: async (status) => {
|
|
4498
|
-
var _a, _b;
|
|
4499
4552
|
if (!this.isOpen && status === SystemStatus.ACTIVE) {
|
|
4500
|
-
await
|
|
4553
|
+
await this._resourceLock?.acquire();
|
|
4501
4554
|
} else if (this.isOpen && status === SystemStatus.INACTIVE) {
|
|
4502
|
-
await
|
|
4555
|
+
await this._resourceLock?.release();
|
|
4503
4556
|
}
|
|
4504
4557
|
},
|
|
4505
4558
|
onReset: async () => {
|
|
@@ -4508,7 +4561,8 @@ var ClientServicesHost = class {
|
|
|
4508
4561
|
});
|
|
4509
4562
|
this._loggingService = new LoggingServiceImpl();
|
|
4510
4563
|
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
4511
|
-
SystemService: this._systemService
|
|
4564
|
+
SystemService: this._systemService,
|
|
4565
|
+
TracingService: this._tracingService
|
|
4512
4566
|
});
|
|
4513
4567
|
}
|
|
4514
4568
|
get isOpen() {
|
|
@@ -4535,26 +4589,25 @@ var ClientServicesHost = class {
|
|
|
4535
4589
|
* Can only be called once.
|
|
4536
4590
|
*/
|
|
4537
4591
|
initialize({ config, ...options }) {
|
|
4538
|
-
var _a, _b, _c;
|
|
4539
4592
|
invariant13(!this._open, "service host is open", {
|
|
4540
4593
|
F: __dxlog_file17,
|
|
4541
|
-
L:
|
|
4594
|
+
L: 181,
|
|
4542
4595
|
S: this,
|
|
4543
4596
|
A: [
|
|
4544
4597
|
"!this._open",
|
|
4545
4598
|
"'service host is open'"
|
|
4546
4599
|
]
|
|
4547
4600
|
});
|
|
4548
|
-
log16
|
|
4601
|
+
log16("initializing...", void 0, {
|
|
4549
4602
|
F: __dxlog_file17,
|
|
4550
|
-
L:
|
|
4603
|
+
L: 182,
|
|
4551
4604
|
S: this,
|
|
4552
4605
|
C: (f, a) => f(...a)
|
|
4553
4606
|
});
|
|
4554
4607
|
if (config) {
|
|
4555
4608
|
invariant13(!this._config, "config already set", {
|
|
4556
4609
|
F: __dxlog_file17,
|
|
4557
|
-
L:
|
|
4610
|
+
L: 185,
|
|
4558
4611
|
S: this,
|
|
4559
4612
|
A: [
|
|
4560
4613
|
"!this._config",
|
|
@@ -4567,12 +4620,12 @@ var ClientServicesHost = class {
|
|
|
4567
4620
|
}
|
|
4568
4621
|
}
|
|
4569
4622
|
const { connectionLog = true, transportFactory = createWebRTCTransportFactory({
|
|
4570
|
-
iceServers:
|
|
4571
|
-
}), signalManager = new WebsocketSignalManager(
|
|
4623
|
+
iceServers: this._config?.get("runtime.services.ice")
|
|
4624
|
+
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4572
4625
|
this._signalManager = signalManager;
|
|
4573
4626
|
invariant13(!this._networkManager, "network manager already set", {
|
|
4574
4627
|
F: __dxlog_file17,
|
|
4575
|
-
L:
|
|
4628
|
+
L: 201,
|
|
4576
4629
|
S: this,
|
|
4577
4630
|
A: [
|
|
4578
4631
|
"!this._networkManager",
|
|
@@ -4584,30 +4637,29 @@ var ClientServicesHost = class {
|
|
|
4584
4637
|
transportFactory,
|
|
4585
4638
|
signalManager
|
|
4586
4639
|
});
|
|
4587
|
-
log16
|
|
4640
|
+
log16("initialized", void 0, {
|
|
4588
4641
|
F: __dxlog_file17,
|
|
4589
|
-
L:
|
|
4642
|
+
L: 208,
|
|
4590
4643
|
S: this,
|
|
4591
4644
|
C: (f, a) => f(...a)
|
|
4592
4645
|
});
|
|
4593
4646
|
}
|
|
4594
|
-
async open() {
|
|
4595
|
-
var _a, _b, _c;
|
|
4647
|
+
async open(ctx) {
|
|
4596
4648
|
if (this._open) {
|
|
4597
4649
|
return;
|
|
4598
4650
|
}
|
|
4599
4651
|
const traceId = PublicKey10.random().toHex();
|
|
4600
|
-
log16.trace("dxos.client-services.host.open",
|
|
4652
|
+
log16.trace("dxos.client-services.host.open", trace7.begin({
|
|
4601
4653
|
id: traceId
|
|
4602
4654
|
}), {
|
|
4603
4655
|
F: __dxlog_file17,
|
|
4604
|
-
L:
|
|
4656
|
+
L: 219,
|
|
4605
4657
|
S: this,
|
|
4606
4658
|
C: (f, a) => f(...a)
|
|
4607
4659
|
});
|
|
4608
4660
|
invariant13(this._config, "config not set", {
|
|
4609
4661
|
F: __dxlog_file17,
|
|
4610
|
-
L:
|
|
4662
|
+
L: 221,
|
|
4611
4663
|
S: this,
|
|
4612
4664
|
A: [
|
|
4613
4665
|
"this._config",
|
|
@@ -4616,7 +4668,7 @@ var ClientServicesHost = class {
|
|
|
4616
4668
|
});
|
|
4617
4669
|
invariant13(this._storage, "storage not set", {
|
|
4618
4670
|
F: __dxlog_file17,
|
|
4619
|
-
L:
|
|
4671
|
+
L: 222,
|
|
4620
4672
|
S: this,
|
|
4621
4673
|
A: [
|
|
4622
4674
|
"this._storage",
|
|
@@ -4625,7 +4677,7 @@ var ClientServicesHost = class {
|
|
|
4625
4677
|
});
|
|
4626
4678
|
invariant13(this._signalManager, "signal manager not set", {
|
|
4627
4679
|
F: __dxlog_file17,
|
|
4628
|
-
L:
|
|
4680
|
+
L: 223,
|
|
4629
4681
|
S: this,
|
|
4630
4682
|
A: [
|
|
4631
4683
|
"this._signalManager",
|
|
@@ -4634,7 +4686,7 @@ var ClientServicesHost = class {
|
|
|
4634
4686
|
});
|
|
4635
4687
|
invariant13(this._networkManager, "network manager not set", {
|
|
4636
4688
|
F: __dxlog_file17,
|
|
4637
|
-
L:
|
|
4689
|
+
L: 224,
|
|
4638
4690
|
S: this,
|
|
4639
4691
|
A: [
|
|
4640
4692
|
"this._networkManager",
|
|
@@ -4642,20 +4694,20 @@ var ClientServicesHost = class {
|
|
|
4642
4694
|
]
|
|
4643
4695
|
});
|
|
4644
4696
|
this._opening = true;
|
|
4645
|
-
log16
|
|
4646
|
-
lockKey:
|
|
4697
|
+
log16("opening...", {
|
|
4698
|
+
lockKey: this._resourceLock?.lockKey
|
|
4647
4699
|
}, {
|
|
4648
4700
|
F: __dxlog_file17,
|
|
4649
|
-
L:
|
|
4701
|
+
L: 227,
|
|
4650
4702
|
S: this,
|
|
4651
4703
|
C: (f, a) => f(...a)
|
|
4652
4704
|
});
|
|
4653
|
-
await
|
|
4705
|
+
await this._resourceLock?.acquire();
|
|
4654
4706
|
await this._loggingService.open();
|
|
4655
4707
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4656
4708
|
this._serviceRegistry.setServices({
|
|
4657
4709
|
SystemService: this._systemService,
|
|
4658
|
-
IdentityService: new IdentityServiceImpl(this._serviceContext),
|
|
4710
|
+
IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
|
|
4659
4711
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4660
4712
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4661
4713
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -4665,6 +4717,7 @@ var ClientServicesHost = class {
|
|
|
4665
4717
|
DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4666
4718
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
4667
4719
|
LoggingService: this._loggingService,
|
|
4720
|
+
TracingService: this._tracingService,
|
|
4668
4721
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4669
4722
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
4670
4723
|
events: new DevtoolsHostEvents(),
|
|
@@ -4672,39 +4725,38 @@ var ClientServicesHost = class {
|
|
|
4672
4725
|
context: this._serviceContext
|
|
4673
4726
|
})
|
|
4674
4727
|
});
|
|
4675
|
-
await this._serviceContext.open();
|
|
4728
|
+
await this._serviceContext.open(ctx);
|
|
4676
4729
|
this._opening = false;
|
|
4677
4730
|
this._open = true;
|
|
4678
4731
|
this._statusUpdate.emit();
|
|
4679
|
-
const deviceKey =
|
|
4680
|
-
log16
|
|
4732
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4733
|
+
log16("opened", {
|
|
4681
4734
|
deviceKey
|
|
4682
4735
|
}, {
|
|
4683
4736
|
F: __dxlog_file17,
|
|
4684
|
-
L:
|
|
4737
|
+
L: 284,
|
|
4685
4738
|
S: this,
|
|
4686
4739
|
C: (f, a) => f(...a)
|
|
4687
4740
|
});
|
|
4688
|
-
log16.trace("dxos.client-services.host.open",
|
|
4741
|
+
log16.trace("dxos.client-services.host.open", trace7.end({
|
|
4689
4742
|
id: traceId
|
|
4690
4743
|
}), {
|
|
4691
4744
|
F: __dxlog_file17,
|
|
4692
|
-
L:
|
|
4745
|
+
L: 285,
|
|
4693
4746
|
S: this,
|
|
4694
4747
|
C: (f, a) => f(...a)
|
|
4695
4748
|
});
|
|
4696
4749
|
}
|
|
4697
4750
|
async close() {
|
|
4698
|
-
var _a;
|
|
4699
4751
|
if (!this._open) {
|
|
4700
4752
|
return;
|
|
4701
4753
|
}
|
|
4702
|
-
const deviceKey =
|
|
4703
|
-
log16
|
|
4754
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4755
|
+
log16("closing...", {
|
|
4704
4756
|
deviceKey
|
|
4705
4757
|
}, {
|
|
4706
4758
|
F: __dxlog_file17,
|
|
4707
|
-
L:
|
|
4759
|
+
L: 296,
|
|
4708
4760
|
S: this,
|
|
4709
4761
|
C: (f, a) => f(...a)
|
|
4710
4762
|
});
|
|
@@ -4715,57 +4767,67 @@ var ClientServicesHost = class {
|
|
|
4715
4767
|
await this._serviceContext.close();
|
|
4716
4768
|
this._open = false;
|
|
4717
4769
|
this._statusUpdate.emit();
|
|
4718
|
-
log16
|
|
4770
|
+
log16("closed", {
|
|
4719
4771
|
deviceKey
|
|
4720
4772
|
}, {
|
|
4721
4773
|
F: __dxlog_file17,
|
|
4722
|
-
L:
|
|
4774
|
+
L: 302,
|
|
4723
4775
|
S: this,
|
|
4724
4776
|
C: (f, a) => f(...a)
|
|
4725
4777
|
});
|
|
4726
4778
|
}
|
|
4727
4779
|
async reset() {
|
|
4728
|
-
var _a, _b, _c;
|
|
4729
4780
|
const traceId = PublicKey10.random().toHex();
|
|
4730
|
-
log16.trace("dxos.sdk.client-services-host.reset",
|
|
4781
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace7.begin({
|
|
4731
4782
|
id: traceId
|
|
4732
4783
|
}), {
|
|
4733
4784
|
F: __dxlog_file17,
|
|
4734
|
-
L:
|
|
4785
|
+
L: 307,
|
|
4735
4786
|
S: this,
|
|
4736
4787
|
C: (f, a) => f(...a)
|
|
4737
4788
|
});
|
|
4738
4789
|
log16("resetting...", void 0, {
|
|
4739
4790
|
F: __dxlog_file17,
|
|
4740
|
-
L:
|
|
4791
|
+
L: 309,
|
|
4741
4792
|
S: this,
|
|
4742
4793
|
C: (f, a) => f(...a)
|
|
4743
4794
|
});
|
|
4744
|
-
await
|
|
4795
|
+
await this._serviceContext?.close();
|
|
4745
4796
|
await this._storage.reset();
|
|
4746
4797
|
log16("reset", void 0, {
|
|
4747
4798
|
F: __dxlog_file17,
|
|
4748
|
-
L:
|
|
4799
|
+
L: 312,
|
|
4749
4800
|
S: this,
|
|
4750
4801
|
C: (f, a) => f(...a)
|
|
4751
4802
|
});
|
|
4752
|
-
log16.trace("dxos.sdk.client-services-host.reset",
|
|
4803
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace7.end({
|
|
4753
4804
|
id: traceId
|
|
4754
4805
|
}), {
|
|
4755
4806
|
F: __dxlog_file17,
|
|
4756
|
-
L:
|
|
4807
|
+
L: 313,
|
|
4757
4808
|
S: this,
|
|
4758
4809
|
C: (f, a) => f(...a)
|
|
4759
4810
|
});
|
|
4760
|
-
await
|
|
4811
|
+
await this._callbacks?.onReset?.();
|
|
4761
4812
|
}
|
|
4762
4813
|
};
|
|
4763
|
-
|
|
4764
|
-
|
|
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()
|
|
4765
4823
|
], ClientServicesHost.prototype, "open", null);
|
|
4766
|
-
|
|
4767
|
-
synchronized3
|
|
4824
|
+
_ts_decorate7([
|
|
4825
|
+
synchronized3,
|
|
4826
|
+
Trace3.span()
|
|
4768
4827
|
], ClientServicesHost.prototype, "close", null);
|
|
4828
|
+
ClientServicesHost = _ts_decorate7([
|
|
4829
|
+
Trace3.resource()
|
|
4830
|
+
], ClientServicesHost);
|
|
4769
4831
|
|
|
4770
4832
|
export {
|
|
4771
4833
|
subscribeToFeeds,
|
|
@@ -4800,4 +4862,4 @@ export {
|
|
|
4800
4862
|
createDefaultModelFactory,
|
|
4801
4863
|
ClientServicesHost
|
|
4802
4864
|
};
|
|
4803
|
-
//# sourceMappingURL=chunk-
|
|
4865
|
+
//# sourceMappingURL=chunk-BD23GURE.mjs.map
|