@dxos/client-services 0.1.56-main.4b42f23 → 0.1.56-main.538bda2
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-CSJSC47N.mjs → chunk-Y4AYNWBO.mjs} +1231 -623
- package/dist/lib/browser/chunk-Y4AYNWBO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +69 -53
- 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 +42 -48
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +1386 -765
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +1537 -934
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/services/index.d.ts +1 -0
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/platform.d.ts +16 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-context.d.ts +2 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +7 -3
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +6 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +12 -2
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.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/shell-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +2 -0
- package/dist/types/src/version.d.ts.map +1 -0
- package/package.json +34 -33
- package/src/packlets/devices/devices-service.test.ts +2 -1
- package/src/packlets/identity/authenticator.test.ts +2 -2
- package/src/packlets/identity/identity-manager.test.ts +4 -3
- package/src/packlets/identity/identity-manager.ts +10 -7
- package/src/packlets/identity/identity-service.test.ts +2 -1
- package/src/packlets/identity/identity-service.ts +1 -2
- package/src/packlets/identity/identity.test.ts +7 -6
- package/src/packlets/identity/identity.ts +9 -5
- package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
- package/src/packlets/invitations/device-invitation-protocol.ts +1 -2
- package/src/packlets/invitations/invitation-extension.ts +1 -2
- package/src/packlets/invitations/invitations-handler.ts +1 -2
- package/src/packlets/invitations/invitations-service.ts +1 -2
- package/src/packlets/invitations/space-invitation-protocol.ts +1 -2
- package/src/packlets/locks/node.ts +1 -1
- package/src/packlets/logging/logging-service.ts +17 -9
- package/src/packlets/network/network-service.test.ts +2 -1
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/diagnostics.ts +211 -0
- package/src/packlets/services/index.ts +1 -0
- package/src/packlets/services/platform.ts +48 -0
- package/src/packlets/services/service-context.test.ts +59 -0
- package/src/packlets/services/service-context.ts +17 -11
- package/src/packlets/services/service-host.test.ts +11 -10
- package/src/packlets/services/service-host.ts +34 -19
- package/src/packlets/services/service-registry.test.ts +3 -1
- package/src/packlets/services/util.ts +33 -0
- package/src/packlets/spaces/data-space-manager.ts +2 -3
- package/src/packlets/spaces/data-space.ts +17 -5
- package/src/packlets/spaces/notarization-plugin.ts +1 -2
- package/src/packlets/spaces/spaces-service.test.ts +2 -1
- package/src/packlets/spaces/spaces-service.ts +18 -12
- package/src/packlets/system/system-service.test.ts +1 -0
- package/src/packlets/system/system-service.ts +34 -2
- package/src/packlets/testing/invitation-utils.ts +1 -2
- package/src/packlets/testing/test-builder.ts +1 -1
- package/src/packlets/vault/iframe-host-runtime.ts +2 -1
- package/src/packlets/vault/shell-runtime.ts +1 -2
- package/src/packlets/vault/worker-runtime.ts +2 -1
- package/src/packlets/vault/worker-session.ts +7 -3
- package/src/version.ts +1 -0
- package/dist/lib/browser/chunk-CSJSC47N.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();
|
|
@@ -463,16 +454,27 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
463
454
|
};
|
|
464
455
|
|
|
465
456
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
466
|
-
import invariant from "tiny-invariant";
|
|
467
457
|
import { Event } from "@dxos/async";
|
|
468
458
|
import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from "@dxos/client-protocol";
|
|
469
459
|
import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
|
|
470
460
|
import { failUndefined } from "@dxos/debug";
|
|
471
461
|
import { writeMessages } from "@dxos/feed-store";
|
|
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
|
/**
|
|
@@ -546,7 +547,15 @@ var Identity = class {
|
|
|
546
547
|
* Requires identity to be ready.
|
|
547
548
|
*/
|
|
548
549
|
getIdentityCredentialSigner() {
|
|
549
|
-
invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready."
|
|
550
|
+
invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
551
|
+
F: __dxlog_file2,
|
|
552
|
+
L: 139,
|
|
553
|
+
S: this,
|
|
554
|
+
A: [
|
|
555
|
+
"this._deviceStateMachine.deviceCredentialChain",
|
|
556
|
+
"'Device credential chain is not ready.'"
|
|
557
|
+
]
|
|
558
|
+
});
|
|
550
559
|
return createCredentialSignerWithChain(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
551
560
|
}
|
|
552
561
|
/**
|
|
@@ -564,7 +573,7 @@ var Identity = class {
|
|
|
564
573
|
dataFeedKey
|
|
565
574
|
}, {
|
|
566
575
|
F: __dxlog_file2,
|
|
567
|
-
L:
|
|
576
|
+
L: 155,
|
|
568
577
|
S: this,
|
|
569
578
|
C: (f, a) => f(...a)
|
|
570
579
|
});
|
|
@@ -605,18 +614,39 @@ var Identity = class {
|
|
|
605
614
|
})));
|
|
606
615
|
}
|
|
607
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);
|
|
608
626
|
|
|
609
627
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
610
|
-
import invariant2 from "tiny-invariant";
|
|
611
628
|
import { Event as Event2 } from "@dxos/async";
|
|
629
|
+
import { Context as Context3 } from "@dxos/context";
|
|
612
630
|
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
|
|
631
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
613
632
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
614
633
|
import { log as log3 } from "@dxos/log";
|
|
615
|
-
import { trace } from "@dxos/protocols";
|
|
634
|
+
import { trace as trace2 } from "@dxos/protocols";
|
|
616
635
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
636
|
+
import { trace as Trace } from "@dxos/tracing";
|
|
617
637
|
import { deferFunction } from "@dxos/util";
|
|
638
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
639
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
640
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
641
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
642
|
+
else
|
|
643
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
644
|
+
if (d = decorators[i])
|
|
645
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
646
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
647
|
+
}
|
|
618
648
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
619
|
-
var IdentityManager = class {
|
|
649
|
+
var IdentityManager = class IdentityManager2 {
|
|
620
650
|
// TODO(burdon): IdentityManagerParams.
|
|
621
651
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
622
652
|
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
@@ -629,14 +659,13 @@ var IdentityManager = class {
|
|
|
629
659
|
get identity() {
|
|
630
660
|
return this._identity;
|
|
631
661
|
}
|
|
632
|
-
async open() {
|
|
633
|
-
var _a;
|
|
662
|
+
async open(ctx) {
|
|
634
663
|
const traceId = PublicKey3.random().toHex();
|
|
635
|
-
log3.trace("dxos.halo.identity-manager.open",
|
|
664
|
+
log3.trace("dxos.halo.identity-manager.open", trace2.begin({
|
|
636
665
|
id: traceId
|
|
637
666
|
}), {
|
|
638
667
|
F: __dxlog_file3,
|
|
639
|
-
L:
|
|
668
|
+
L: 73,
|
|
640
669
|
S: this,
|
|
641
670
|
C: (f, a) => f(...a)
|
|
642
671
|
});
|
|
@@ -646,44 +675,50 @@ var IdentityManager = class {
|
|
|
646
675
|
identityRecord
|
|
647
676
|
}, {
|
|
648
677
|
F: __dxlog_file3,
|
|
649
|
-
L:
|
|
678
|
+
L: 77,
|
|
650
679
|
S: this,
|
|
651
680
|
C: (f, a) => f(...a)
|
|
652
681
|
});
|
|
653
682
|
if (identityRecord) {
|
|
654
683
|
this._identity = await this._constructIdentity(identityRecord);
|
|
655
|
-
await this._identity.open();
|
|
684
|
+
await this._identity.open(ctx);
|
|
656
685
|
await this._identity.ready();
|
|
657
686
|
log3.trace("dxos.halo.identity", {
|
|
658
687
|
identityKey: identityRecord.identityKey,
|
|
659
|
-
displayName:
|
|
688
|
+
displayName: this._identity.profileDocument?.displayName
|
|
660
689
|
}, {
|
|
661
690
|
F: __dxlog_file3,
|
|
662
|
-
L:
|
|
691
|
+
L: 82,
|
|
663
692
|
S: this,
|
|
664
693
|
C: (f, a) => f(...a)
|
|
665
694
|
});
|
|
666
695
|
this.stateUpdate.emit();
|
|
667
696
|
}
|
|
668
|
-
log3.trace("dxos.halo.identity-manager.open",
|
|
697
|
+
log3.trace("dxos.halo.identity-manager.open", trace2.end({
|
|
669
698
|
id: traceId
|
|
670
699
|
}), {
|
|
671
700
|
F: __dxlog_file3,
|
|
672
|
-
L:
|
|
701
|
+
L: 88,
|
|
673
702
|
S: this,
|
|
674
703
|
C: (f, a) => f(...a)
|
|
675
704
|
});
|
|
676
705
|
}
|
|
677
706
|
async close() {
|
|
678
|
-
|
|
679
|
-
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
707
|
+
await this._identity?.close(new Context3());
|
|
680
708
|
}
|
|
681
709
|
async createIdentity({ displayName } = {}) {
|
|
682
|
-
|
|
683
|
-
|
|
710
|
+
invariant2(!this._identity, "Identity already exists.", {
|
|
711
|
+
F: __dxlog_file3,
|
|
712
|
+
L: 96,
|
|
713
|
+
S: this,
|
|
714
|
+
A: [
|
|
715
|
+
"!this._identity",
|
|
716
|
+
"'Identity already exists.'"
|
|
717
|
+
]
|
|
718
|
+
});
|
|
684
719
|
log3("creating identity...", void 0, {
|
|
685
720
|
F: __dxlog_file3,
|
|
686
|
-
L:
|
|
721
|
+
L: 97,
|
|
687
722
|
S: this,
|
|
688
723
|
C: (f, a) => f(...a)
|
|
689
724
|
});
|
|
@@ -699,11 +734,27 @@ var IdentityManager = class {
|
|
|
699
734
|
}
|
|
700
735
|
};
|
|
701
736
|
const identity = await this._constructIdentity(identityRecord);
|
|
702
|
-
await identity.open();
|
|
737
|
+
await identity.open(new Context3());
|
|
703
738
|
{
|
|
704
739
|
const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
705
|
-
invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required."
|
|
706
|
-
|
|
740
|
+
invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
741
|
+
F: __dxlog_file3,
|
|
742
|
+
L: 116,
|
|
743
|
+
S: this,
|
|
744
|
+
A: [
|
|
745
|
+
"identityRecord.haloSpace.genesisFeedKey",
|
|
746
|
+
"'Genesis feed key is required.'"
|
|
747
|
+
]
|
|
748
|
+
});
|
|
749
|
+
invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
750
|
+
F: __dxlog_file3,
|
|
751
|
+
L: 117,
|
|
752
|
+
S: this,
|
|
753
|
+
A: [
|
|
754
|
+
"identityRecord.haloSpace.dataFeedKey",
|
|
755
|
+
"'Data feed key is required.'"
|
|
756
|
+
]
|
|
757
|
+
});
|
|
707
758
|
const credentials = [
|
|
708
759
|
// Space genesis.
|
|
709
760
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
@@ -729,10 +780,10 @@ var IdentityManager = class {
|
|
|
729
780
|
await this._identity.ready();
|
|
730
781
|
log3.trace("dxos.halo.identity", {
|
|
731
782
|
identityKey: identityRecord.identityKey,
|
|
732
|
-
displayName:
|
|
783
|
+
displayName: this._identity.profileDocument?.displayName
|
|
733
784
|
}, {
|
|
734
785
|
F: __dxlog_file3,
|
|
735
|
-
L:
|
|
786
|
+
L: 152,
|
|
736
787
|
S: this,
|
|
737
788
|
C: (f, a) => f(...a)
|
|
738
789
|
});
|
|
@@ -742,7 +793,7 @@ var IdentityManager = class {
|
|
|
742
793
|
deviceKey: identity.deviceKey
|
|
743
794
|
}, {
|
|
744
795
|
F: __dxlog_file3,
|
|
745
|
-
L:
|
|
796
|
+
L: 158,
|
|
746
797
|
S: this,
|
|
747
798
|
C: (f, a) => f(...a)
|
|
748
799
|
});
|
|
@@ -752,16 +803,23 @@ var IdentityManager = class {
|
|
|
752
803
|
* Accept an existing identity. Expects it's device key to be authorized (now or later).
|
|
753
804
|
*/
|
|
754
805
|
async acceptIdentity(params) {
|
|
755
|
-
var _a;
|
|
756
806
|
log3("accepting identity", {
|
|
757
807
|
params
|
|
758
808
|
}, {
|
|
759
809
|
F: __dxlog_file3,
|
|
760
|
-
L:
|
|
810
|
+
L: 166,
|
|
761
811
|
S: this,
|
|
762
812
|
C: (f, a) => f(...a)
|
|
763
813
|
});
|
|
764
|
-
invariant2(!this._identity, "Identity already exists."
|
|
814
|
+
invariant2(!this._identity, "Identity already exists.", {
|
|
815
|
+
F: __dxlog_file3,
|
|
816
|
+
L: 167,
|
|
817
|
+
S: this,
|
|
818
|
+
A: [
|
|
819
|
+
"!this._identity",
|
|
820
|
+
"'Identity already exists.'"
|
|
821
|
+
]
|
|
822
|
+
});
|
|
765
823
|
const identityRecord = {
|
|
766
824
|
identityKey: params.identityKey,
|
|
767
825
|
deviceKey: params.deviceKey,
|
|
@@ -774,16 +832,16 @@ var IdentityManager = class {
|
|
|
774
832
|
}
|
|
775
833
|
};
|
|
776
834
|
const identity = await this._constructIdentity(identityRecord);
|
|
777
|
-
await identity.open();
|
|
835
|
+
await identity.open(new Context3());
|
|
778
836
|
this._identity = identity;
|
|
779
837
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
780
838
|
await this._identity.ready();
|
|
781
839
|
log3.trace("dxos.halo.identity", {
|
|
782
840
|
identityKey: identityRecord.identityKey,
|
|
783
|
-
displayName:
|
|
841
|
+
displayName: this._identity.profileDocument?.displayName
|
|
784
842
|
}, {
|
|
785
843
|
F: __dxlog_file3,
|
|
786
|
-
L:
|
|
844
|
+
L: 186,
|
|
787
845
|
S: this,
|
|
788
846
|
C: (f, a) => f(...a)
|
|
789
847
|
});
|
|
@@ -793,27 +851,51 @@ var IdentityManager = class {
|
|
|
793
851
|
deviceKey: identity.deviceKey
|
|
794
852
|
}, {
|
|
795
853
|
F: __dxlog_file3,
|
|
796
|
-
L:
|
|
854
|
+
L: 192,
|
|
797
855
|
S: this,
|
|
798
856
|
C: (f, a) => f(...a)
|
|
799
857
|
});
|
|
800
858
|
return identity;
|
|
801
859
|
}
|
|
802
860
|
async _constructIdentity(identityRecord) {
|
|
803
|
-
invariant2(!this._identity
|
|
861
|
+
invariant2(!this._identity, void 0, {
|
|
862
|
+
F: __dxlog_file3,
|
|
863
|
+
L: 197,
|
|
864
|
+
S: this,
|
|
865
|
+
A: [
|
|
866
|
+
"!this._identity",
|
|
867
|
+
""
|
|
868
|
+
]
|
|
869
|
+
});
|
|
804
870
|
log3("constructing identity", {
|
|
805
871
|
identityRecord
|
|
806
872
|
}, {
|
|
807
873
|
F: __dxlog_file3,
|
|
808
|
-
L:
|
|
874
|
+
L: 198,
|
|
809
875
|
S: this,
|
|
810
876
|
C: (f, a) => f(...a)
|
|
811
877
|
});
|
|
812
|
-
invariant2(identityRecord.haloSpace.controlFeedKey
|
|
878
|
+
invariant2(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
879
|
+
F: __dxlog_file3,
|
|
880
|
+
L: 201,
|
|
881
|
+
S: this,
|
|
882
|
+
A: [
|
|
883
|
+
"identityRecord.haloSpace.controlFeedKey",
|
|
884
|
+
""
|
|
885
|
+
]
|
|
886
|
+
});
|
|
813
887
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
814
888
|
writable: true
|
|
815
889
|
});
|
|
816
|
-
invariant2(identityRecord.haloSpace.dataFeedKey
|
|
890
|
+
invariant2(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
891
|
+
F: __dxlog_file3,
|
|
892
|
+
L: 205,
|
|
893
|
+
S: this,
|
|
894
|
+
A: [
|
|
895
|
+
"identityRecord.haloSpace.dataFeedKey",
|
|
896
|
+
""
|
|
897
|
+
]
|
|
898
|
+
});
|
|
817
899
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
818
900
|
writable: true,
|
|
819
901
|
sparse: true
|
|
@@ -839,7 +921,7 @@ var IdentityManager = class {
|
|
|
839
921
|
identityKey: identityRecord.identityKey
|
|
840
922
|
}, {
|
|
841
923
|
F: __dxlog_file3,
|
|
842
|
-
L:
|
|
924
|
+
L: 229,
|
|
843
925
|
S: this,
|
|
844
926
|
C: (f, a) => f(...a)
|
|
845
927
|
});
|
|
@@ -860,7 +942,7 @@ var IdentityManager = class {
|
|
|
860
942
|
onAuthFailure: () => {
|
|
861
943
|
log3.warn("auth failure", void 0, {
|
|
862
944
|
F: __dxlog_file3,
|
|
863
|
-
L:
|
|
945
|
+
L: 248,
|
|
864
946
|
S: this,
|
|
865
947
|
C: (f, a) => f(...a)
|
|
866
948
|
});
|
|
@@ -869,12 +951,19 @@ var IdentityManager = class {
|
|
|
869
951
|
});
|
|
870
952
|
}
|
|
871
953
|
};
|
|
954
|
+
_ts_decorate2([
|
|
955
|
+
Trace.span()
|
|
956
|
+
], IdentityManager.prototype, "open", null);
|
|
957
|
+
IdentityManager = _ts_decorate2([
|
|
958
|
+
Trace.resource()
|
|
959
|
+
], IdentityManager);
|
|
872
960
|
|
|
873
961
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
874
|
-
import invariant3 from "tiny-invariant";
|
|
875
962
|
import { Stream as Stream7 } from "@dxos/codec-protobuf";
|
|
876
963
|
import { signPresentation } from "@dxos/credentials";
|
|
877
964
|
import { todo } from "@dxos/debug";
|
|
965
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
966
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
878
967
|
var IdentityServiceImpl = class {
|
|
879
968
|
// TODO(wittjosiah): Remove dependency on service context.
|
|
880
969
|
constructor(_serviceContext) {
|
|
@@ -907,7 +996,15 @@ var IdentityServiceImpl = class {
|
|
|
907
996
|
};
|
|
908
997
|
}
|
|
909
998
|
async signPresentation({ presentation, nonce }) {
|
|
910
|
-
invariant3(this._serviceContext.identityManager.identity, "Identity not initialized."
|
|
999
|
+
invariant3(this._serviceContext.identityManager.identity, "Identity not initialized.", {
|
|
1000
|
+
F: __dxlog_file4,
|
|
1001
|
+
L: 56,
|
|
1002
|
+
S: this,
|
|
1003
|
+
A: [
|
|
1004
|
+
"this._serviceContext.identityManager.identity",
|
|
1005
|
+
"'Identity not initialized.'"
|
|
1006
|
+
]
|
|
1007
|
+
});
|
|
911
1008
|
return await signPresentation({
|
|
912
1009
|
presentation,
|
|
913
1010
|
signer: this._serviceContext.keyring,
|
|
@@ -919,8 +1016,9 @@ var IdentityServiceImpl = class {
|
|
|
919
1016
|
};
|
|
920
1017
|
|
|
921
1018
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
922
|
-
import invariant4 from "
|
|
1019
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
923
1020
|
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
1021
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
924
1022
|
var DeviceInvitationProtocol = class {
|
|
925
1023
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
926
1024
|
this._keyring = _keyring;
|
|
@@ -936,7 +1034,15 @@ var DeviceInvitationProtocol = class {
|
|
|
936
1034
|
};
|
|
937
1035
|
}
|
|
938
1036
|
async admit(request) {
|
|
939
|
-
invariant4(request.device
|
|
1037
|
+
invariant4(request.device, void 0, {
|
|
1038
|
+
F: __dxlog_file5,
|
|
1039
|
+
L: 31,
|
|
1040
|
+
S: this,
|
|
1041
|
+
A: [
|
|
1042
|
+
"request.device",
|
|
1043
|
+
""
|
|
1044
|
+
]
|
|
1045
|
+
});
|
|
940
1046
|
const identity = this._getIdentity();
|
|
941
1047
|
await identity.admitDevice(request.device);
|
|
942
1048
|
return {
|
|
@@ -964,9 +1070,25 @@ var DeviceInvitationProtocol = class {
|
|
|
964
1070
|
};
|
|
965
1071
|
}
|
|
966
1072
|
async accept(response, request) {
|
|
967
|
-
invariant4(response.device
|
|
1073
|
+
invariant4(response.device, void 0, {
|
|
1074
|
+
F: __dxlog_file5,
|
|
1075
|
+
L: 64,
|
|
1076
|
+
S: this,
|
|
1077
|
+
A: [
|
|
1078
|
+
"response.device",
|
|
1079
|
+
""
|
|
1080
|
+
]
|
|
1081
|
+
});
|
|
968
1082
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
969
|
-
invariant4(request.device
|
|
1083
|
+
invariant4(request.device, void 0, {
|
|
1084
|
+
F: __dxlog_file5,
|
|
1085
|
+
L: 67,
|
|
1086
|
+
S: this,
|
|
1087
|
+
A: [
|
|
1088
|
+
"request.device",
|
|
1089
|
+
""
|
|
1090
|
+
]
|
|
1091
|
+
});
|
|
970
1092
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
971
1093
|
await this._acceptIdentity({
|
|
972
1094
|
identityKey,
|
|
@@ -984,31 +1106,31 @@ var DeviceInvitationProtocol = class {
|
|
|
984
1106
|
};
|
|
985
1107
|
|
|
986
1108
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
987
|
-
import invariant6 from "tiny-invariant";
|
|
988
1109
|
import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
|
|
989
1110
|
import { AuthenticatingInvitationObservable, AUTHENTICATION_CODE_LENGTH, CancellableInvitationObservable, INVITATION_TIMEOUT } from "@dxos/client-protocol";
|
|
990
|
-
import { Context as
|
|
1111
|
+
import { Context as Context5 } from "@dxos/context";
|
|
991
1112
|
import { generatePasscode } from "@dxos/credentials";
|
|
992
1113
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2 } from "@dxos/errors";
|
|
1114
|
+
import { invariant as invariant6 } from "@dxos/invariant";
|
|
993
1115
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
994
1116
|
import { log as log5 } from "@dxos/log";
|
|
995
1117
|
import { createTeleportProtocolFactory, StarTopology } from "@dxos/network-manager";
|
|
996
|
-
import { trace as
|
|
1118
|
+
import { trace as trace4 } from "@dxos/protocols";
|
|
997
1119
|
import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
998
1120
|
import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
999
1121
|
|
|
1000
1122
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
1001
|
-
import invariant5 from "tiny-invariant";
|
|
1002
1123
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
1003
|
-
import { cancelWithContext, Context as
|
|
1124
|
+
import { cancelWithContext, Context as Context4 } from "@dxos/context";
|
|
1004
1125
|
import { InvalidInvitationExtensionRoleError } from "@dxos/errors";
|
|
1126
|
+
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1005
1127
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1006
1128
|
import { log as log4 } from "@dxos/log";
|
|
1007
|
-
import { schema as schema2, trace as
|
|
1129
|
+
import { schema as schema2, trace as trace3 } from "@dxos/protocols";
|
|
1008
1130
|
import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1009
1131
|
import { AuthenticationResponse, Options } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1010
1132
|
import { RpcExtension } from "@dxos/teleport";
|
|
1011
|
-
var
|
|
1133
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
1012
1134
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1013
1135
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1014
1136
|
var InvitationHostExtension = class extends RpcExtension {
|
|
@@ -1022,7 +1144,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1022
1144
|
}
|
|
1023
1145
|
});
|
|
1024
1146
|
this._callbacks = _callbacks;
|
|
1025
|
-
this._ctx = new
|
|
1147
|
+
this._ctx = new Context4();
|
|
1026
1148
|
this._remoteOptionsTrigger = new Trigger2();
|
|
1027
1149
|
this.invitation = void 0;
|
|
1028
1150
|
this.guestProfile = void 0;
|
|
@@ -1036,18 +1158,26 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1036
1158
|
// Perhaps in the future we will have more complex logic here.
|
|
1037
1159
|
InvitationHostService: {
|
|
1038
1160
|
options: async (options) => {
|
|
1039
|
-
invariant5(!this._remoteOptions, "Remote options already set."
|
|
1161
|
+
invariant5(!this._remoteOptions, "Remote options already set.", {
|
|
1162
|
+
F: __dxlog_file6,
|
|
1163
|
+
L: 88,
|
|
1164
|
+
S: this,
|
|
1165
|
+
A: [
|
|
1166
|
+
"!this._remoteOptions",
|
|
1167
|
+
"'Remote options already set.'"
|
|
1168
|
+
]
|
|
1169
|
+
});
|
|
1040
1170
|
this._remoteOptions = options;
|
|
1041
1171
|
this._remoteOptionsTrigger.wake();
|
|
1042
1172
|
},
|
|
1043
1173
|
introduce: async (request) => {
|
|
1044
1174
|
const { profile, invitationId } = request;
|
|
1045
1175
|
const traceId = PublicKey4.random().toHex();
|
|
1046
|
-
log4.trace("dxos.sdk.invitation-handler.host.introduce",
|
|
1176
|
+
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.begin({
|
|
1047
1177
|
id: traceId
|
|
1048
1178
|
}), {
|
|
1049
|
-
F:
|
|
1050
|
-
L:
|
|
1179
|
+
F: __dxlog_file6,
|
|
1180
|
+
L: 97,
|
|
1051
1181
|
S: this,
|
|
1052
1182
|
C: (f, a) => f(...a)
|
|
1053
1183
|
});
|
|
@@ -1056,8 +1186,8 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1056
1186
|
log4.warn("invitation not found", {
|
|
1057
1187
|
invitationId
|
|
1058
1188
|
}, {
|
|
1059
|
-
F:
|
|
1060
|
-
L:
|
|
1189
|
+
F: __dxlog_file6,
|
|
1190
|
+
L: 101,
|
|
1061
1191
|
S: this,
|
|
1062
1192
|
C: (f, a) => f(...a)
|
|
1063
1193
|
});
|
|
@@ -1070,8 +1200,8 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1070
1200
|
log4("guest introduced itself", {
|
|
1071
1201
|
guestProfile: profile
|
|
1072
1202
|
}, {
|
|
1073
|
-
F:
|
|
1074
|
-
L:
|
|
1203
|
+
F: __dxlog_file6,
|
|
1204
|
+
L: 110,
|
|
1075
1205
|
S: this,
|
|
1076
1206
|
C: (f, a) => f(...a)
|
|
1077
1207
|
});
|
|
@@ -1080,11 +1210,11 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1080
1210
|
...this.invitation,
|
|
1081
1211
|
state: Invitation2.State.READY_FOR_AUTHENTICATION
|
|
1082
1212
|
});
|
|
1083
|
-
log4.trace("dxos.sdk.invitation-handler.host.introduce",
|
|
1213
|
+
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.end({
|
|
1084
1214
|
id: traceId
|
|
1085
1215
|
}), {
|
|
1086
|
-
F:
|
|
1087
|
-
L:
|
|
1216
|
+
F: __dxlog_file6,
|
|
1217
|
+
L: 117,
|
|
1088
1218
|
S: this,
|
|
1089
1219
|
C: (f, a) => f(...a)
|
|
1090
1220
|
});
|
|
@@ -1095,29 +1225,37 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1095
1225
|
},
|
|
1096
1226
|
authenticate: async ({ authCode: code }) => {
|
|
1097
1227
|
const traceId = PublicKey4.random().toHex();
|
|
1098
|
-
log4.trace("dxos.sdk.invitation-handler.host.authenticate",
|
|
1228
|
+
log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.begin({
|
|
1099
1229
|
id: traceId
|
|
1100
1230
|
}), {
|
|
1101
|
-
F:
|
|
1102
|
-
L:
|
|
1231
|
+
F: __dxlog_file6,
|
|
1232
|
+
L: 126,
|
|
1103
1233
|
S: this,
|
|
1104
1234
|
C: (f, a) => f(...a)
|
|
1105
1235
|
});
|
|
1106
1236
|
log4("received authentication request", {
|
|
1107
1237
|
authCode: code
|
|
1108
1238
|
}, {
|
|
1109
|
-
F:
|
|
1110
|
-
L:
|
|
1239
|
+
F: __dxlog_file6,
|
|
1240
|
+
L: 127,
|
|
1111
1241
|
S: this,
|
|
1112
1242
|
C: (f, a) => f(...a)
|
|
1113
1243
|
});
|
|
1114
1244
|
let status = AuthenticationResponse.Status.OK;
|
|
1115
|
-
invariant5(this.invitation, "Invitation is not set."
|
|
1245
|
+
invariant5(this.invitation, "Invitation is not set.", {
|
|
1246
|
+
F: __dxlog_file6,
|
|
1247
|
+
L: 130,
|
|
1248
|
+
S: this,
|
|
1249
|
+
A: [
|
|
1250
|
+
"this.invitation",
|
|
1251
|
+
"'Invitation is not set.'"
|
|
1252
|
+
]
|
|
1253
|
+
});
|
|
1116
1254
|
switch (this.invitation.authMethod) {
|
|
1117
1255
|
case Invitation2.AuthMethod.NONE: {
|
|
1118
1256
|
log4("authentication not required", void 0, {
|
|
1119
|
-
F:
|
|
1120
|
-
L:
|
|
1257
|
+
F: __dxlog_file6,
|
|
1258
|
+
L: 133,
|
|
1121
1259
|
S: this,
|
|
1122
1260
|
C: (f, a) => f(...a)
|
|
1123
1261
|
});
|
|
@@ -1141,8 +1279,8 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1141
1279
|
log4.error("invalid authentication method", {
|
|
1142
1280
|
authMethod: this.invitation.authMethod
|
|
1143
1281
|
}, {
|
|
1144
|
-
F:
|
|
1145
|
-
L:
|
|
1282
|
+
F: __dxlog_file6,
|
|
1283
|
+
L: 151,
|
|
1146
1284
|
S: this,
|
|
1147
1285
|
C: (f, a) => f(...a)
|
|
1148
1286
|
});
|
|
@@ -1150,14 +1288,14 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1150
1288
|
break;
|
|
1151
1289
|
}
|
|
1152
1290
|
}
|
|
1153
|
-
log4.trace("dxos.sdk.invitation-handler.host.authenticate",
|
|
1291
|
+
log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.end({
|
|
1154
1292
|
id: traceId,
|
|
1155
1293
|
data: {
|
|
1156
1294
|
status
|
|
1157
1295
|
}
|
|
1158
1296
|
}), {
|
|
1159
|
-
F:
|
|
1160
|
-
L:
|
|
1297
|
+
F: __dxlog_file6,
|
|
1298
|
+
L: 157,
|
|
1161
1299
|
S: this,
|
|
1162
1300
|
C: (f, a) => f(...a)
|
|
1163
1301
|
});
|
|
@@ -1167,25 +1305,33 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1167
1305
|
},
|
|
1168
1306
|
admit: async (request) => {
|
|
1169
1307
|
const traceId = PublicKey4.random().toHex();
|
|
1170
|
-
log4.trace("dxos.sdk.invitation-handler.host.admit",
|
|
1308
|
+
log4.trace("dxos.sdk.invitation-handler.host.admit", trace3.begin({
|
|
1171
1309
|
id: traceId
|
|
1172
1310
|
}), {
|
|
1173
|
-
F:
|
|
1174
|
-
L:
|
|
1311
|
+
F: __dxlog_file6,
|
|
1312
|
+
L: 163,
|
|
1175
1313
|
S: this,
|
|
1176
1314
|
C: (f, a) => f(...a)
|
|
1177
1315
|
});
|
|
1178
1316
|
try {
|
|
1179
|
-
invariant5(this.invitation, "Invitation is not set."
|
|
1317
|
+
invariant5(this.invitation, "Invitation is not set.", {
|
|
1318
|
+
F: __dxlog_file6,
|
|
1319
|
+
L: 166,
|
|
1320
|
+
S: this,
|
|
1321
|
+
A: [
|
|
1322
|
+
"this.invitation",
|
|
1323
|
+
"'Invitation is not set.'"
|
|
1324
|
+
]
|
|
1325
|
+
});
|
|
1180
1326
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
1181
1327
|
throw new Error("Not authenticated");
|
|
1182
1328
|
}
|
|
1183
1329
|
const response = await this._callbacks.admit(request);
|
|
1184
|
-
log4.trace("dxos.sdk.invitation-handler.host.admit",
|
|
1330
|
+
log4.trace("dxos.sdk.invitation-handler.host.admit", trace3.end({
|
|
1185
1331
|
id: traceId
|
|
1186
1332
|
}), {
|
|
1187
|
-
F:
|
|
1188
|
-
L:
|
|
1333
|
+
F: __dxlog_file6,
|
|
1334
|
+
L: 174,
|
|
1189
1335
|
S: this,
|
|
1190
1336
|
C: (f, a) => f(...a)
|
|
1191
1337
|
});
|
|
@@ -1199,7 +1345,6 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1199
1345
|
};
|
|
1200
1346
|
}
|
|
1201
1347
|
async onOpen(context) {
|
|
1202
|
-
var _a;
|
|
1203
1348
|
await super.onOpen(context);
|
|
1204
1349
|
try {
|
|
1205
1350
|
await this.rpc.InvitationHostService.options({
|
|
@@ -1208,7 +1353,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1208
1353
|
await cancelWithContext(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1209
1354
|
timeout: OPTIONS_TIMEOUT
|
|
1210
1355
|
}));
|
|
1211
|
-
if (
|
|
1356
|
+
if (this._remoteOptions?.role !== Options.Role.GUEST) {
|
|
1212
1357
|
throw new InvalidInvitationExtensionRoleError(void 0, {
|
|
1213
1358
|
expected: Options.Role.GUEST,
|
|
1214
1359
|
remoteOptions: this._remoteOptions
|
|
@@ -1234,14 +1379,22 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1234
1379
|
}
|
|
1235
1380
|
});
|
|
1236
1381
|
this._callbacks = _callbacks;
|
|
1237
|
-
this._ctx = new
|
|
1382
|
+
this._ctx = new Context4();
|
|
1238
1383
|
this._remoteOptionsTrigger = new Trigger2();
|
|
1239
1384
|
}
|
|
1240
1385
|
async getHandlers() {
|
|
1241
1386
|
return {
|
|
1242
1387
|
InvitationHostService: {
|
|
1243
1388
|
options: async (options) => {
|
|
1244
|
-
invariant5(!this._remoteOptions, "Remote options already set."
|
|
1389
|
+
invariant5(!this._remoteOptions, "Remote options already set.", {
|
|
1390
|
+
F: __dxlog_file6,
|
|
1391
|
+
L: 241,
|
|
1392
|
+
S: this,
|
|
1393
|
+
A: [
|
|
1394
|
+
"!this._remoteOptions",
|
|
1395
|
+
"'Remote options already set.'"
|
|
1396
|
+
]
|
|
1397
|
+
});
|
|
1245
1398
|
this._remoteOptions = options;
|
|
1246
1399
|
this._remoteOptionsTrigger.wake();
|
|
1247
1400
|
},
|
|
@@ -1258,12 +1411,11 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1258
1411
|
};
|
|
1259
1412
|
}
|
|
1260
1413
|
async onOpen(context) {
|
|
1261
|
-
var _a;
|
|
1262
1414
|
await super.onOpen(context);
|
|
1263
1415
|
try {
|
|
1264
1416
|
log4("begin options", void 0, {
|
|
1265
|
-
F:
|
|
1266
|
-
L:
|
|
1417
|
+
F: __dxlog_file6,
|
|
1418
|
+
L: 262,
|
|
1267
1419
|
S: this,
|
|
1268
1420
|
C: (f, a) => f(...a)
|
|
1269
1421
|
});
|
|
@@ -1274,12 +1426,12 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1274
1426
|
timeout: OPTIONS_TIMEOUT
|
|
1275
1427
|
}));
|
|
1276
1428
|
log4("end options", void 0, {
|
|
1277
|
-
F:
|
|
1278
|
-
L:
|
|
1429
|
+
F: __dxlog_file6,
|
|
1430
|
+
L: 265,
|
|
1279
1431
|
S: this,
|
|
1280
1432
|
C: (f, a) => f(...a)
|
|
1281
1433
|
});
|
|
1282
|
-
if (
|
|
1434
|
+
if (this._remoteOptions?.role !== Options.Role.HOST) {
|
|
1283
1435
|
throw new InvalidInvitationExtensionRoleError(void 0, {
|
|
1284
1436
|
expected: Options.Role.HOST,
|
|
1285
1437
|
remoteOptions: this._remoteOptions
|
|
@@ -1288,8 +1440,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1288
1440
|
this._callbacks.onOpen(this._ctx);
|
|
1289
1441
|
} catch (err) {
|
|
1290
1442
|
log4("openError", err, {
|
|
1291
|
-
F:
|
|
1292
|
-
L:
|
|
1443
|
+
F: __dxlog_file6,
|
|
1444
|
+
L: 275,
|
|
1293
1445
|
S: this,
|
|
1294
1446
|
C: (f, a) => f(...a)
|
|
1295
1447
|
});
|
|
@@ -1298,8 +1450,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1298
1450
|
}
|
|
1299
1451
|
async onClose() {
|
|
1300
1452
|
log4("onClose", void 0, {
|
|
1301
|
-
F:
|
|
1302
|
-
L:
|
|
1453
|
+
F: __dxlog_file6,
|
|
1454
|
+
L: 281,
|
|
1303
1455
|
S: this,
|
|
1304
1456
|
C: (f, a) => f(...a)
|
|
1305
1457
|
});
|
|
@@ -1309,7 +1461,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1309
1461
|
var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation2.AuthMethod.NONE;
|
|
1310
1462
|
|
|
1311
1463
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1312
|
-
var
|
|
1464
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1313
1465
|
var InvitationsHandler = class {
|
|
1314
1466
|
/**
|
|
1315
1467
|
* @internal
|
|
@@ -1318,10 +1470,17 @@ var InvitationsHandler = class {
|
|
|
1318
1470
|
this._networkManager = _networkManager;
|
|
1319
1471
|
}
|
|
1320
1472
|
createInvitation(protocol, options) {
|
|
1321
|
-
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1324
|
-
|
|
1473
|
+
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 ?? {};
|
|
1474
|
+
const authCode = options?.authCode ?? (authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1475
|
+
invariant6(protocol, void 0, {
|
|
1476
|
+
F: __dxlog_file7,
|
|
1477
|
+
L: 76,
|
|
1478
|
+
S: this,
|
|
1479
|
+
A: [
|
|
1480
|
+
"protocol",
|
|
1481
|
+
""
|
|
1482
|
+
]
|
|
1483
|
+
});
|
|
1325
1484
|
const invitation = {
|
|
1326
1485
|
invitationId,
|
|
1327
1486
|
type,
|
|
@@ -1333,7 +1492,7 @@ var InvitationsHandler = class {
|
|
|
1333
1492
|
...protocol.getInvitationContext()
|
|
1334
1493
|
};
|
|
1335
1494
|
const stream = new PushStream();
|
|
1336
|
-
const ctx = new
|
|
1495
|
+
const ctx = new Context5({
|
|
1337
1496
|
onError: (err) => {
|
|
1338
1497
|
void ctx.dispose();
|
|
1339
1498
|
stream.error(err);
|
|
@@ -1343,8 +1502,8 @@ var InvitationsHandler = class {
|
|
|
1343
1502
|
log5("complete", {
|
|
1344
1503
|
...protocol.toJSON()
|
|
1345
1504
|
}, {
|
|
1346
|
-
F:
|
|
1347
|
-
L:
|
|
1505
|
+
F: __dxlog_file7,
|
|
1506
|
+
L: 98,
|
|
1348
1507
|
S: this,
|
|
1349
1508
|
C: (f, a) => f(...a)
|
|
1350
1509
|
});
|
|
@@ -1365,10 +1524,17 @@ var InvitationsHandler = class {
|
|
|
1365
1524
|
return invitation;
|
|
1366
1525
|
},
|
|
1367
1526
|
admit: async (admissionRequest) => {
|
|
1368
|
-
var _a2, _b, _c;
|
|
1369
1527
|
try {
|
|
1370
|
-
const deviceKey =
|
|
1371
|
-
invariant6(deviceKey
|
|
1528
|
+
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1529
|
+
invariant6(deviceKey, void 0, {
|
|
1530
|
+
F: __dxlog_file7,
|
|
1531
|
+
L: 119,
|
|
1532
|
+
S: this,
|
|
1533
|
+
A: [
|
|
1534
|
+
"deviceKey",
|
|
1535
|
+
""
|
|
1536
|
+
]
|
|
1537
|
+
});
|
|
1372
1538
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1373
1539
|
extension.completedTrigger.wake(deviceKey);
|
|
1374
1540
|
return admissionResponse;
|
|
@@ -1381,19 +1547,19 @@ var InvitationsHandler = class {
|
|
|
1381
1547
|
scheduleTask2(ctx, async () => {
|
|
1382
1548
|
const traceId = PublicKey5.random().toHex();
|
|
1383
1549
|
try {
|
|
1384
|
-
log5.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
1550
|
+
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.begin({
|
|
1385
1551
|
id: traceId
|
|
1386
1552
|
}), {
|
|
1387
|
-
F:
|
|
1388
|
-
L:
|
|
1553
|
+
F: __dxlog_file7,
|
|
1554
|
+
L: 137,
|
|
1389
1555
|
S: this,
|
|
1390
1556
|
C: (f, a) => f(...a)
|
|
1391
1557
|
});
|
|
1392
1558
|
log5("connected", {
|
|
1393
1559
|
...protocol.toJSON()
|
|
1394
1560
|
}, {
|
|
1395
|
-
F:
|
|
1396
|
-
L:
|
|
1561
|
+
F: __dxlog_file7,
|
|
1562
|
+
L: 138,
|
|
1397
1563
|
S: this,
|
|
1398
1564
|
C: (f, a) => f(...a)
|
|
1399
1565
|
});
|
|
@@ -1408,8 +1574,8 @@ var InvitationsHandler = class {
|
|
|
1408
1574
|
guest: deviceKey,
|
|
1409
1575
|
...protocol.toJSON()
|
|
1410
1576
|
}, {
|
|
1411
|
-
F:
|
|
1412
|
-
L:
|
|
1577
|
+
F: __dxlog_file7,
|
|
1578
|
+
L: 141,
|
|
1413
1579
|
S: this,
|
|
1414
1580
|
C: (f, a) => f(...a)
|
|
1415
1581
|
});
|
|
@@ -1417,11 +1583,11 @@ var InvitationsHandler = class {
|
|
|
1417
1583
|
...invitation,
|
|
1418
1584
|
state: Invitation3.State.SUCCESS
|
|
1419
1585
|
});
|
|
1420
|
-
log5.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
1586
|
+
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.end({
|
|
1421
1587
|
id: traceId
|
|
1422
1588
|
}), {
|
|
1423
|
-
F:
|
|
1424
|
-
L:
|
|
1589
|
+
F: __dxlog_file7,
|
|
1590
|
+
L: 143,
|
|
1425
1591
|
S: this,
|
|
1426
1592
|
C: (f, a) => f(...a)
|
|
1427
1593
|
});
|
|
@@ -1430,8 +1596,8 @@ var InvitationsHandler = class {
|
|
|
1430
1596
|
log5("timeout", {
|
|
1431
1597
|
...protocol.toJSON()
|
|
1432
1598
|
}, {
|
|
1433
|
-
F:
|
|
1434
|
-
L:
|
|
1599
|
+
F: __dxlog_file7,
|
|
1600
|
+
L: 146,
|
|
1435
1601
|
S: this,
|
|
1436
1602
|
C: (f, a) => f(...a)
|
|
1437
1603
|
});
|
|
@@ -1441,19 +1607,19 @@ var InvitationsHandler = class {
|
|
|
1441
1607
|
});
|
|
1442
1608
|
} else {
|
|
1443
1609
|
log5.error("failed", err, {
|
|
1444
|
-
F:
|
|
1445
|
-
L:
|
|
1610
|
+
F: __dxlog_file7,
|
|
1611
|
+
L: 149,
|
|
1446
1612
|
S: this,
|
|
1447
1613
|
C: (f, a) => f(...a)
|
|
1448
1614
|
});
|
|
1449
1615
|
stream.error(err);
|
|
1450
1616
|
}
|
|
1451
|
-
log5.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
1617
|
+
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.error({
|
|
1452
1618
|
id: traceId,
|
|
1453
1619
|
error: err
|
|
1454
1620
|
}), {
|
|
1455
|
-
F:
|
|
1456
|
-
L:
|
|
1621
|
+
F: __dxlog_file7,
|
|
1622
|
+
L: 152,
|
|
1457
1623
|
S: this,
|
|
1458
1624
|
C: (f, a) => f(...a)
|
|
1459
1625
|
});
|
|
@@ -1473,8 +1639,8 @@ var InvitationsHandler = class {
|
|
|
1473
1639
|
log5("timeout", {
|
|
1474
1640
|
...protocol.toJSON()
|
|
1475
1641
|
}, {
|
|
1476
|
-
F:
|
|
1477
|
-
L:
|
|
1642
|
+
F: __dxlog_file7,
|
|
1643
|
+
L: 167,
|
|
1478
1644
|
S: this,
|
|
1479
1645
|
C: (f, a) => f(...a)
|
|
1480
1646
|
});
|
|
@@ -1484,8 +1650,8 @@ var InvitationsHandler = class {
|
|
|
1484
1650
|
});
|
|
1485
1651
|
} else {
|
|
1486
1652
|
log5.error("failed", err, {
|
|
1487
|
-
F:
|
|
1488
|
-
L:
|
|
1653
|
+
F: __dxlog_file7,
|
|
1654
|
+
L: 170,
|
|
1489
1655
|
S: this,
|
|
1490
1656
|
C: (f, a) => f(...a)
|
|
1491
1657
|
});
|
|
@@ -1527,27 +1693,43 @@ var InvitationsHandler = class {
|
|
|
1527
1693
|
}
|
|
1528
1694
|
acceptInvitation(protocol, invitation) {
|
|
1529
1695
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
1530
|
-
invariant6(protocol
|
|
1696
|
+
invariant6(protocol, void 0, {
|
|
1697
|
+
F: __dxlog_file7,
|
|
1698
|
+
L: 210,
|
|
1699
|
+
S: this,
|
|
1700
|
+
A: [
|
|
1701
|
+
"protocol",
|
|
1702
|
+
""
|
|
1703
|
+
]
|
|
1704
|
+
});
|
|
1531
1705
|
const authenticated = new Trigger3();
|
|
1532
1706
|
let admitted = false;
|
|
1533
1707
|
let currentState;
|
|
1534
1708
|
const stream = new PushStream();
|
|
1535
1709
|
const setState = (newData) => {
|
|
1536
|
-
invariant6(newData.state !== void 0
|
|
1710
|
+
invariant6(newData.state !== void 0, void 0, {
|
|
1711
|
+
F: __dxlog_file7,
|
|
1712
|
+
L: 221,
|
|
1713
|
+
S: this,
|
|
1714
|
+
A: [
|
|
1715
|
+
"newData.state !== undefined",
|
|
1716
|
+
""
|
|
1717
|
+
]
|
|
1718
|
+
});
|
|
1537
1719
|
currentState = newData.state;
|
|
1538
1720
|
stream.next({
|
|
1539
1721
|
...invitation,
|
|
1540
1722
|
...newData
|
|
1541
1723
|
});
|
|
1542
1724
|
};
|
|
1543
|
-
const ctx = new
|
|
1725
|
+
const ctx = new Context5({
|
|
1544
1726
|
onError: (err) => {
|
|
1545
1727
|
if (err instanceof TimeoutError) {
|
|
1546
1728
|
log5("timeout", {
|
|
1547
1729
|
...protocol.toJSON()
|
|
1548
1730
|
}, {
|
|
1549
|
-
F:
|
|
1550
|
-
L:
|
|
1731
|
+
F: __dxlog_file7,
|
|
1732
|
+
L: 229,
|
|
1551
1733
|
S: this,
|
|
1552
1734
|
C: (f, a) => f(...a)
|
|
1553
1735
|
});
|
|
@@ -1556,8 +1738,8 @@ var InvitationsHandler = class {
|
|
|
1556
1738
|
});
|
|
1557
1739
|
} else {
|
|
1558
1740
|
log5.warn("auth failed", err, {
|
|
1559
|
-
F:
|
|
1560
|
-
L:
|
|
1741
|
+
F: __dxlog_file7,
|
|
1742
|
+
L: 232,
|
|
1561
1743
|
S: this,
|
|
1562
1744
|
C: (f, a) => f(...a)
|
|
1563
1745
|
});
|
|
@@ -1570,8 +1752,8 @@ var InvitationsHandler = class {
|
|
|
1570
1752
|
log5("complete", {
|
|
1571
1753
|
...protocol.toJSON()
|
|
1572
1754
|
}, {
|
|
1573
|
-
F:
|
|
1574
|
-
L:
|
|
1755
|
+
F: __dxlog_file7,
|
|
1756
|
+
L: 240,
|
|
1575
1757
|
S: this,
|
|
1576
1758
|
C: (f, a) => f(...a)
|
|
1577
1759
|
});
|
|
@@ -1585,8 +1767,8 @@ var InvitationsHandler = class {
|
|
|
1585
1767
|
log5("extension disposed", {
|
|
1586
1768
|
currentState
|
|
1587
1769
|
}, {
|
|
1588
|
-
F:
|
|
1589
|
-
L:
|
|
1770
|
+
F: __dxlog_file7,
|
|
1771
|
+
L: 250,
|
|
1590
1772
|
S: this,
|
|
1591
1773
|
C: (f, a) => f(...a)
|
|
1592
1774
|
});
|
|
@@ -1597,11 +1779,11 @@ var InvitationsHandler = class {
|
|
|
1597
1779
|
scheduleTask2(ctx, async () => {
|
|
1598
1780
|
const traceId = PublicKey5.random().toHex();
|
|
1599
1781
|
try {
|
|
1600
|
-
log5.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
1782
|
+
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.begin({
|
|
1601
1783
|
id: traceId
|
|
1602
1784
|
}), {
|
|
1603
|
-
F:
|
|
1604
|
-
L:
|
|
1785
|
+
F: __dxlog_file7,
|
|
1786
|
+
L: 259,
|
|
1605
1787
|
S: this,
|
|
1606
1788
|
C: (f, a) => f(...a)
|
|
1607
1789
|
});
|
|
@@ -1612,8 +1794,8 @@ var InvitationsHandler = class {
|
|
|
1612
1794
|
log5("connected", {
|
|
1613
1795
|
...protocol.toJSON()
|
|
1614
1796
|
}, {
|
|
1615
|
-
F:
|
|
1616
|
-
L:
|
|
1797
|
+
F: __dxlog_file7,
|
|
1798
|
+
L: 267,
|
|
1617
1799
|
S: this,
|
|
1618
1800
|
C: (f, a) => f(...a)
|
|
1619
1801
|
});
|
|
@@ -1623,8 +1805,8 @@ var InvitationsHandler = class {
|
|
|
1623
1805
|
log5("introduce", {
|
|
1624
1806
|
...protocol.toJSON()
|
|
1625
1807
|
}, {
|
|
1626
|
-
F:
|
|
1627
|
-
L:
|
|
1808
|
+
F: __dxlog_file7,
|
|
1809
|
+
L: 271,
|
|
1628
1810
|
S: this,
|
|
1629
1811
|
C: (f, a) => f(...a)
|
|
1630
1812
|
});
|
|
@@ -1633,8 +1815,8 @@ var InvitationsHandler = class {
|
|
|
1633
1815
|
...protocol.toJSON(),
|
|
1634
1816
|
response: introductionResponse
|
|
1635
1817
|
}, {
|
|
1636
|
-
F:
|
|
1637
|
-
L:
|
|
1818
|
+
F: __dxlog_file7,
|
|
1819
|
+
L: 275,
|
|
1638
1820
|
S: this,
|
|
1639
1821
|
C: (f, a) => f(...a)
|
|
1640
1822
|
});
|
|
@@ -1645,8 +1827,8 @@ var InvitationsHandler = class {
|
|
|
1645
1827
|
if (isAuthenticationRequired(invitation)) {
|
|
1646
1828
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1647
1829
|
log5("guest waiting for authentication code...", void 0, {
|
|
1648
|
-
F:
|
|
1649
|
-
L:
|
|
1830
|
+
F: __dxlog_file7,
|
|
1831
|
+
L: 284,
|
|
1650
1832
|
S: this,
|
|
1651
1833
|
C: (f, a) => f(...a)
|
|
1652
1834
|
});
|
|
@@ -1657,8 +1839,8 @@ var InvitationsHandler = class {
|
|
|
1657
1839
|
timeout
|
|
1658
1840
|
});
|
|
1659
1841
|
log5("sending authentication request", void 0, {
|
|
1660
|
-
F:
|
|
1661
|
-
L:
|
|
1842
|
+
F: __dxlog_file7,
|
|
1843
|
+
L: 288,
|
|
1662
1844
|
S: this,
|
|
1663
1845
|
C: (f, a) => f(...a)
|
|
1664
1846
|
});
|
|
@@ -1678,8 +1860,8 @@ var InvitationsHandler = class {
|
|
|
1678
1860
|
log5("retrying invalid code", {
|
|
1679
1861
|
attempt
|
|
1680
1862
|
}, {
|
|
1681
|
-
F:
|
|
1682
|
-
L:
|
|
1863
|
+
F: __dxlog_file7,
|
|
1864
|
+
L: 299,
|
|
1683
1865
|
S: this,
|
|
1684
1866
|
C: (f, a) => f(...a)
|
|
1685
1867
|
});
|
|
@@ -1695,8 +1877,8 @@ var InvitationsHandler = class {
|
|
|
1695
1877
|
log5("request admission", {
|
|
1696
1878
|
...protocol.toJSON()
|
|
1697
1879
|
}, {
|
|
1698
|
-
F:
|
|
1699
|
-
L:
|
|
1880
|
+
F: __dxlog_file7,
|
|
1881
|
+
L: 310,
|
|
1700
1882
|
S: this,
|
|
1701
1883
|
C: (f, a) => f(...a)
|
|
1702
1884
|
});
|
|
@@ -1707,8 +1889,8 @@ var InvitationsHandler = class {
|
|
|
1707
1889
|
log5("admitted by host", {
|
|
1708
1890
|
...protocol.toJSON()
|
|
1709
1891
|
}, {
|
|
1710
|
-
F:
|
|
1711
|
-
L:
|
|
1892
|
+
F: __dxlog_file7,
|
|
1893
|
+
L: 321,
|
|
1712
1894
|
S: this,
|
|
1713
1895
|
C: (f, a) => f(...a)
|
|
1714
1896
|
});
|
|
@@ -1716,11 +1898,11 @@ var InvitationsHandler = class {
|
|
|
1716
1898
|
...result,
|
|
1717
1899
|
state: Invitation3.State.SUCCESS
|
|
1718
1900
|
});
|
|
1719
|
-
log5.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
1901
|
+
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.end({
|
|
1720
1902
|
id: traceId
|
|
1721
1903
|
}), {
|
|
1722
|
-
F:
|
|
1723
|
-
L:
|
|
1904
|
+
F: __dxlog_file7,
|
|
1905
|
+
L: 323,
|
|
1724
1906
|
S: this,
|
|
1725
1907
|
C: (f, a) => f(...a)
|
|
1726
1908
|
});
|
|
@@ -1729,8 +1911,8 @@ var InvitationsHandler = class {
|
|
|
1729
1911
|
log5("timeout", {
|
|
1730
1912
|
...protocol.toJSON()
|
|
1731
1913
|
}, {
|
|
1732
|
-
F:
|
|
1733
|
-
L:
|
|
1914
|
+
F: __dxlog_file7,
|
|
1915
|
+
L: 326,
|
|
1734
1916
|
S: this,
|
|
1735
1917
|
C: (f, a) => f(...a)
|
|
1736
1918
|
});
|
|
@@ -1739,19 +1921,19 @@ var InvitationsHandler = class {
|
|
|
1739
1921
|
});
|
|
1740
1922
|
} else {
|
|
1741
1923
|
log5("auth failed", err, {
|
|
1742
|
-
F:
|
|
1743
|
-
L:
|
|
1924
|
+
F: __dxlog_file7,
|
|
1925
|
+
L: 329,
|
|
1744
1926
|
S: this,
|
|
1745
1927
|
C: (f, a) => f(...a)
|
|
1746
1928
|
});
|
|
1747
1929
|
stream.error(err);
|
|
1748
1930
|
}
|
|
1749
|
-
log5.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
1931
|
+
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.error({
|
|
1750
1932
|
id: traceId,
|
|
1751
1933
|
error: err
|
|
1752
1934
|
}), {
|
|
1753
|
-
F:
|
|
1754
|
-
L:
|
|
1935
|
+
F: __dxlog_file7,
|
|
1936
|
+
L: 332,
|
|
1755
1937
|
S: this,
|
|
1756
1938
|
C: (f, a) => f(...a)
|
|
1757
1939
|
});
|
|
@@ -1768,8 +1950,8 @@ var InvitationsHandler = class {
|
|
|
1768
1950
|
log5("timeout", {
|
|
1769
1951
|
...protocol.toJSON()
|
|
1770
1952
|
}, {
|
|
1771
|
-
F:
|
|
1772
|
-
L:
|
|
1953
|
+
F: __dxlog_file7,
|
|
1954
|
+
L: 343,
|
|
1773
1955
|
S: this,
|
|
1774
1956
|
C: (f, a) => f(...a)
|
|
1775
1957
|
});
|
|
@@ -1778,8 +1960,8 @@ var InvitationsHandler = class {
|
|
|
1778
1960
|
});
|
|
1779
1961
|
} else {
|
|
1780
1962
|
log5("auth failed", err, {
|
|
1781
|
-
F:
|
|
1782
|
-
L:
|
|
1963
|
+
F: __dxlog_file7,
|
|
1964
|
+
L: 346,
|
|
1783
1965
|
S: this,
|
|
1784
1966
|
C: (f, a) => f(...a)
|
|
1785
1967
|
});
|
|
@@ -1790,7 +1972,15 @@ var InvitationsHandler = class {
|
|
|
1790
1972
|
return extension;
|
|
1791
1973
|
};
|
|
1792
1974
|
scheduleTask2(ctx, async () => {
|
|
1793
|
-
invariant6(invitation.swarmKey
|
|
1975
|
+
invariant6(invitation.swarmKey, void 0, {
|
|
1976
|
+
F: __dxlog_file7,
|
|
1977
|
+
L: 356,
|
|
1978
|
+
S: this,
|
|
1979
|
+
A: [
|
|
1980
|
+
"invitation.swarmKey",
|
|
1981
|
+
""
|
|
1982
|
+
]
|
|
1983
|
+
});
|
|
1794
1984
|
const topic = invitation.swarmKey;
|
|
1795
1985
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1796
1986
|
topic,
|
|
@@ -1823,12 +2013,12 @@ var InvitationsHandler = class {
|
|
|
1823
2013
|
};
|
|
1824
2014
|
|
|
1825
2015
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1826
|
-
import invariant7 from "tiny-invariant";
|
|
1827
2016
|
import { Event as Event3 } from "@dxos/async";
|
|
1828
2017
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
2018
|
+
import { invariant as invariant7 } from "@dxos/invariant";
|
|
1829
2019
|
import { log as log6 } from "@dxos/log";
|
|
1830
2020
|
import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
1831
|
-
var
|
|
2021
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1832
2022
|
var InvitationsServiceImpl = class {
|
|
1833
2023
|
constructor(_invitationsHandler, _getHandler) {
|
|
1834
2024
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1890,19 +2080,27 @@ var InvitationsServiceImpl = class {
|
|
|
1890
2080
|
}
|
|
1891
2081
|
async authenticate({ invitationId, authCode }) {
|
|
1892
2082
|
log6("authenticating...", void 0, {
|
|
1893
|
-
F:
|
|
1894
|
-
L:
|
|
2083
|
+
F: __dxlog_file8,
|
|
2084
|
+
L: 102,
|
|
1895
2085
|
S: this,
|
|
1896
2086
|
C: (f, a) => f(...a)
|
|
1897
2087
|
});
|
|
1898
|
-
invariant7(invitationId
|
|
2088
|
+
invariant7(invitationId, void 0, {
|
|
2089
|
+
F: __dxlog_file8,
|
|
2090
|
+
L: 103,
|
|
2091
|
+
S: this,
|
|
2092
|
+
A: [
|
|
2093
|
+
"invitationId",
|
|
2094
|
+
""
|
|
2095
|
+
]
|
|
2096
|
+
});
|
|
1899
2097
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1900
2098
|
if (!observable) {
|
|
1901
2099
|
log6.warn("invalid invitation", {
|
|
1902
2100
|
invitationId
|
|
1903
2101
|
}, {
|
|
1904
|
-
F:
|
|
1905
|
-
L:
|
|
2102
|
+
F: __dxlog_file8,
|
|
2103
|
+
L: 106,
|
|
1906
2104
|
S: this,
|
|
1907
2105
|
C: (f, a) => f(...a)
|
|
1908
2106
|
});
|
|
@@ -1912,12 +2110,20 @@ var InvitationsServiceImpl = class {
|
|
|
1912
2110
|
}
|
|
1913
2111
|
async cancelInvitation({ invitationId }) {
|
|
1914
2112
|
log6("deleting...", void 0, {
|
|
1915
|
-
F:
|
|
1916
|
-
L:
|
|
2113
|
+
F: __dxlog_file8,
|
|
2114
|
+
L: 113,
|
|
1917
2115
|
S: this,
|
|
1918
2116
|
C: (f, a) => f(...a)
|
|
1919
2117
|
});
|
|
1920
|
-
invariant7(invitationId
|
|
2118
|
+
invariant7(invitationId, void 0, {
|
|
2119
|
+
F: __dxlog_file8,
|
|
2120
|
+
L: 114,
|
|
2121
|
+
S: this,
|
|
2122
|
+
A: [
|
|
2123
|
+
"invitationId",
|
|
2124
|
+
""
|
|
2125
|
+
]
|
|
2126
|
+
});
|
|
1921
2127
|
const created = this._createInvitations.get(invitationId);
|
|
1922
2128
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1923
2129
|
if (created) {
|
|
@@ -1932,8 +2138,8 @@ var InvitationsServiceImpl = class {
|
|
|
1932
2138
|
log6.warn("invalid invitation", {
|
|
1933
2139
|
invitationId
|
|
1934
2140
|
}, {
|
|
1935
|
-
F:
|
|
1936
|
-
L:
|
|
2141
|
+
F: __dxlog_file8,
|
|
2142
|
+
L: 126,
|
|
1937
2143
|
S: this,
|
|
1938
2144
|
C: (f, a) => f(...a)
|
|
1939
2145
|
});
|
|
@@ -1992,12 +2198,12 @@ var InvitationsServiceImpl = class {
|
|
|
1992
2198
|
};
|
|
1993
2199
|
|
|
1994
2200
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
1995
|
-
import invariant8 from "tiny-invariant";
|
|
1996
2201
|
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
1997
2202
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2203
|
+
import { invariant as invariant8 } from "@dxos/invariant";
|
|
1998
2204
|
import { log as log7 } from "@dxos/log";
|
|
1999
2205
|
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2000
|
-
var
|
|
2206
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2001
2207
|
var SpaceInvitationProtocol = class {
|
|
2002
2208
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2003
2209
|
this._spaceManager = _spaceManager;
|
|
@@ -2018,31 +2224,70 @@ var SpaceInvitationProtocol = class {
|
|
|
2018
2224
|
};
|
|
2019
2225
|
}
|
|
2020
2226
|
async admit(request, guestProfile) {
|
|
2021
|
-
|
|
2022
|
-
|
|
2227
|
+
invariant8(this._spaceKey, void 0, {
|
|
2228
|
+
F: __dxlog_file9,
|
|
2229
|
+
L: 42,
|
|
2230
|
+
S: this,
|
|
2231
|
+
A: [
|
|
2232
|
+
"this._spaceKey",
|
|
2233
|
+
""
|
|
2234
|
+
]
|
|
2235
|
+
});
|
|
2023
2236
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2024
|
-
invariant8(space
|
|
2025
|
-
|
|
2237
|
+
invariant8(space, void 0, {
|
|
2238
|
+
F: __dxlog_file9,
|
|
2239
|
+
L: 44,
|
|
2240
|
+
S: this,
|
|
2241
|
+
A: [
|
|
2242
|
+
"space",
|
|
2243
|
+
""
|
|
2244
|
+
]
|
|
2245
|
+
});
|
|
2246
|
+
invariant8(request.space, void 0, {
|
|
2247
|
+
F: __dxlog_file9,
|
|
2248
|
+
L: 46,
|
|
2249
|
+
S: this,
|
|
2250
|
+
A: [
|
|
2251
|
+
"request.space",
|
|
2252
|
+
""
|
|
2253
|
+
]
|
|
2254
|
+
});
|
|
2026
2255
|
const { identityKey, deviceKey } = request.space;
|
|
2027
2256
|
log7("writing guest credentials", {
|
|
2028
2257
|
host: this._signingContext.deviceKey,
|
|
2029
2258
|
guest: deviceKey
|
|
2030
2259
|
}, {
|
|
2031
|
-
F:
|
|
2032
|
-
L:
|
|
2260
|
+
F: __dxlog_file9,
|
|
2261
|
+
L: 49,
|
|
2033
2262
|
S: this,
|
|
2034
2263
|
C: (f, a) => f(...a)
|
|
2035
2264
|
});
|
|
2036
2265
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2037
|
-
invariant8(credentials[0].credential
|
|
2266
|
+
invariant8(credentials[0].credential, void 0, {
|
|
2267
|
+
F: __dxlog_file9,
|
|
2268
|
+
L: 60,
|
|
2269
|
+
S: this,
|
|
2270
|
+
A: [
|
|
2271
|
+
"credentials[0].credential",
|
|
2272
|
+
""
|
|
2273
|
+
]
|
|
2274
|
+
});
|
|
2038
2275
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2039
|
-
invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember"
|
|
2276
|
+
invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2277
|
+
F: __dxlog_file9,
|
|
2278
|
+
L: 62,
|
|
2279
|
+
S: this,
|
|
2280
|
+
A: [
|
|
2281
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2282
|
+
""
|
|
2283
|
+
]
|
|
2284
|
+
});
|
|
2040
2285
|
await writeMessages2(space.inner.controlPipeline.writer, credentials);
|
|
2041
2286
|
return {
|
|
2042
2287
|
space: {
|
|
2043
2288
|
credential: spaceMemberCredential,
|
|
2044
2289
|
controlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2045
|
-
dataTimeframe:
|
|
2290
|
+
dataTimeframe: space.dataPipeline.pipelineState?.timeframe
|
|
2046
2291
|
}
|
|
2047
2292
|
};
|
|
2048
2293
|
}
|
|
@@ -2064,11 +2309,35 @@ var SpaceInvitationProtocol = class {
|
|
|
2064
2309
|
};
|
|
2065
2310
|
}
|
|
2066
2311
|
async accept(response) {
|
|
2067
|
-
invariant8(response.space
|
|
2312
|
+
invariant8(response.space, void 0, {
|
|
2313
|
+
F: __dxlog_file9,
|
|
2314
|
+
L: 97,
|
|
2315
|
+
S: this,
|
|
2316
|
+
A: [
|
|
2317
|
+
"response.space",
|
|
2318
|
+
""
|
|
2319
|
+
]
|
|
2320
|
+
});
|
|
2068
2321
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2069
2322
|
const assertion = getCredentialAssertion(credential);
|
|
2070
|
-
invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential"
|
|
2071
|
-
|
|
2323
|
+
invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2324
|
+
F: __dxlog_file9,
|
|
2325
|
+
L: 100,
|
|
2326
|
+
S: this,
|
|
2327
|
+
A: [
|
|
2328
|
+
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2329
|
+
"'Invalid credential'"
|
|
2330
|
+
]
|
|
2331
|
+
});
|
|
2332
|
+
invariant8(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2333
|
+
F: __dxlog_file9,
|
|
2334
|
+
L: 101,
|
|
2335
|
+
S: this,
|
|
2336
|
+
A: [
|
|
2337
|
+
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
2338
|
+
""
|
|
2339
|
+
]
|
|
2340
|
+
});
|
|
2072
2341
|
await this._spaceManager.acceptSpace({
|
|
2073
2342
|
spaceKey: assertion.spaceKey,
|
|
2074
2343
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2122,9 +2391,8 @@ var ClientRpcServer = class {
|
|
|
2122
2391
|
await this._rpcPeer.close();
|
|
2123
2392
|
}
|
|
2124
2393
|
_getServiceHandler(serviceName) {
|
|
2125
|
-
var _a;
|
|
2126
2394
|
if (!this._handlerCache.has(serviceName)) {
|
|
2127
|
-
const [key, descriptor] =
|
|
2395
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise(new Error(`Service not available: ${serviceName}`));
|
|
2128
2396
|
const service = this._serviceRegistry.services[key];
|
|
2129
2397
|
if (!service) {
|
|
2130
2398
|
throw new Error(`Service not available: ${serviceName}`);
|
|
@@ -2135,37 +2403,195 @@ var ClientRpcServer = class {
|
|
|
2135
2403
|
}
|
|
2136
2404
|
};
|
|
2137
2405
|
|
|
2406
|
+
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2407
|
+
import { getFirstStreamValue } from "@dxos/codec-protobuf";
|
|
2408
|
+
import { credentialTypeFilter } from "@dxos/credentials";
|
|
2409
|
+
import { DocumentModel } from "@dxos/document-model";
|
|
2410
|
+
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2411
|
+
import { log as log8 } from "@dxos/log";
|
|
2412
|
+
import { STORAGE_VERSION } from "@dxos/protocols";
|
|
2413
|
+
import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
2414
|
+
|
|
2415
|
+
// packages/sdk/client-services/src/version.ts
|
|
2416
|
+
var DXOS_VERSION = "0.1.56-main.538bda2";
|
|
2417
|
+
|
|
2418
|
+
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
2419
|
+
var getPlatform = () => {
|
|
2420
|
+
if (process.browser) {
|
|
2421
|
+
if (typeof window !== "undefined") {
|
|
2422
|
+
const { userAgent } = window.navigator;
|
|
2423
|
+
return {
|
|
2424
|
+
type: "browser",
|
|
2425
|
+
userAgent,
|
|
2426
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2427
|
+
};
|
|
2428
|
+
} else {
|
|
2429
|
+
return {
|
|
2430
|
+
type: "shared-worker",
|
|
2431
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2432
|
+
};
|
|
2433
|
+
}
|
|
2434
|
+
} else {
|
|
2435
|
+
const { platform, version, arch } = process;
|
|
2436
|
+
return {
|
|
2437
|
+
type: "node",
|
|
2438
|
+
platform: `${platform} ${version} ${arch}`,
|
|
2439
|
+
runtime: process.version,
|
|
2440
|
+
uptime: Math.floor(process.uptime()),
|
|
2441
|
+
memory: process.memoryUsage()
|
|
2442
|
+
};
|
|
2443
|
+
}
|
|
2444
|
+
};
|
|
2445
|
+
|
|
2446
|
+
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2447
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2448
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
2449
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2450
|
+
const diagnostics = {
|
|
2451
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2452
|
+
platform: getPlatform(),
|
|
2453
|
+
client: {
|
|
2454
|
+
version: DXOS_VERSION,
|
|
2455
|
+
storage: {
|
|
2456
|
+
version: STORAGE_VERSION
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
};
|
|
2460
|
+
{
|
|
2461
|
+
invariant9(clientServices.LoggingService, "SystemService is not available.", {
|
|
2462
|
+
F: __dxlog_file10,
|
|
2463
|
+
L: 87,
|
|
2464
|
+
S: void 0,
|
|
2465
|
+
A: [
|
|
2466
|
+
"clientServices.LoggingService",
|
|
2467
|
+
"'SystemService is not available.'"
|
|
2468
|
+
]
|
|
2469
|
+
});
|
|
2470
|
+
diagnostics.metrics = await getFirstStreamValue(clientServices.LoggingService.queryMetrics({}), {
|
|
2471
|
+
timeout: DEFAULT_TIMEOUT
|
|
2472
|
+
}).catch(() => void 0);
|
|
2473
|
+
}
|
|
2474
|
+
const identity = serviceContext.identityManager.identity;
|
|
2475
|
+
if (identity) {
|
|
2476
|
+
diagnostics.identity = {
|
|
2477
|
+
identityKey: identity.identityKey,
|
|
2478
|
+
spaceKey: identity.space.key,
|
|
2479
|
+
profile: identity.profileDocument
|
|
2480
|
+
};
|
|
2481
|
+
const { devices } = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
|
|
2482
|
+
timeout: DEFAULT_TIMEOUT
|
|
2483
|
+
}).catch(() => void 0) ?? {};
|
|
2484
|
+
diagnostics.devices = devices;
|
|
2485
|
+
if (serviceContext.dataSpaceManager) {
|
|
2486
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2487
|
+
}
|
|
2488
|
+
const { feeds = [] } = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2489
|
+
timeout: DEFAULT_TIMEOUT
|
|
2490
|
+
}).catch(() => void 0) ?? {};
|
|
2491
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2492
|
+
feedKey,
|
|
2493
|
+
bytes,
|
|
2494
|
+
length
|
|
2495
|
+
}));
|
|
2496
|
+
}
|
|
2497
|
+
diagnostics.config = config.values;
|
|
2498
|
+
return diagnostics;
|
|
2499
|
+
};
|
|
2500
|
+
var getProperties = (space) => {
|
|
2501
|
+
let properties = {};
|
|
2502
|
+
try {
|
|
2503
|
+
const propertiesItem = space.dataPipeline.itemManager.items.find((item) => item.modelMeta?.type === DocumentModel.meta.type && item.state?.type === "dxos.sdk.client.Properties");
|
|
2504
|
+
const state = propertiesItem?.state;
|
|
2505
|
+
properties = state?.data;
|
|
2506
|
+
} catch (err) {
|
|
2507
|
+
log8.warn(err.message, void 0, {
|
|
2508
|
+
F: __dxlog_file10,
|
|
2509
|
+
L: 144,
|
|
2510
|
+
S: void 0,
|
|
2511
|
+
C: (f, a) => f(...a)
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
return properties;
|
|
2515
|
+
};
|
|
2516
|
+
var getSpaceStats = async (space) => {
|
|
2517
|
+
const stats = {
|
|
2518
|
+
key: space.key,
|
|
2519
|
+
metrics: space.metrics,
|
|
2520
|
+
epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
2521
|
+
...credential.subject.assertion,
|
|
2522
|
+
id: credential.id
|
|
2523
|
+
})),
|
|
2524
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2525
|
+
identity: {
|
|
2526
|
+
identityKey: member.key,
|
|
2527
|
+
profile: {
|
|
2528
|
+
displayName: member.assertion.profile?.displayName
|
|
2529
|
+
}
|
|
2530
|
+
},
|
|
2531
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
|
|
2532
|
+
})),
|
|
2533
|
+
pipeline: {
|
|
2534
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
2535
|
+
// currentEpoch: space.dataPipeline.currentEpoch,
|
|
2536
|
+
// appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
2537
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2538
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2539
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2540
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
2541
|
+
// TODO(burdon): Empty?
|
|
2542
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
2543
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
2544
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
2545
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
2546
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
2547
|
+
}
|
|
2548
|
+
};
|
|
2549
|
+
if (space.dataPipeline.itemManager) {
|
|
2550
|
+
Object.assign(stats, {
|
|
2551
|
+
properties: getProperties(space),
|
|
2552
|
+
db: {
|
|
2553
|
+
objects: space.dataPipeline.itemManager.entities.size
|
|
2554
|
+
}
|
|
2555
|
+
});
|
|
2556
|
+
}
|
|
2557
|
+
if (stats.metrics) {
|
|
2558
|
+
const { open, ready } = stats.metrics;
|
|
2559
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
2560
|
+
}
|
|
2561
|
+
return stats;
|
|
2562
|
+
};
|
|
2563
|
+
|
|
2138
2564
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2139
2565
|
import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
|
|
2140
2566
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2141
|
-
import { cancelWithContext as cancelWithContext2, Context as
|
|
2567
|
+
import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
|
|
2142
2568
|
import { timed } from "@dxos/debug";
|
|
2143
2569
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2144
2570
|
import { CancelledError, SystemError } from "@dxos/errors";
|
|
2145
2571
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2146
|
-
import { log as
|
|
2572
|
+
import { log as log10 } from "@dxos/log";
|
|
2147
2573
|
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
2148
2574
|
import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2149
2575
|
import { Timeframe } from "@dxos/timeframe";
|
|
2150
2576
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2151
2577
|
|
|
2152
2578
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2153
|
-
import invariant9 from "tiny-invariant";
|
|
2154
2579
|
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2155
|
-
import { Context as
|
|
2580
|
+
import { Context as Context6, rejectOnDispose } from "@dxos/context";
|
|
2581
|
+
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2156
2582
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2157
|
-
import { log as
|
|
2583
|
+
import { log as log9 } from "@dxos/log";
|
|
2158
2584
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2159
2585
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
2160
2586
|
import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
|
|
2161
|
-
var
|
|
2587
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2162
2588
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2163
2589
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2164
2590
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
2165
2591
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2166
2592
|
var NotarizationPlugin = class {
|
|
2167
2593
|
constructor() {
|
|
2168
|
-
this._ctx = new
|
|
2594
|
+
this._ctx = new Context6();
|
|
2169
2595
|
this._extensionOpened = new Event4();
|
|
2170
2596
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2171
2597
|
this._processedCredentials = new ComplexSet(PublicKey6.hash);
|
|
@@ -2183,23 +2609,31 @@ var NotarizationPlugin = class {
|
|
|
2183
2609
|
* Request credentials to be notarized.
|
|
2184
2610
|
*/
|
|
2185
2611
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
2186
|
-
|
|
2612
|
+
log9("notarize", {
|
|
2187
2613
|
credentials
|
|
2188
2614
|
}, {
|
|
2189
|
-
F:
|
|
2190
|
-
L:
|
|
2615
|
+
F: __dxlog_file11,
|
|
2616
|
+
L: 90,
|
|
2191
2617
|
S: this,
|
|
2192
2618
|
C: (f, a) => f(...a)
|
|
2193
2619
|
});
|
|
2194
|
-
|
|
2620
|
+
invariant10(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2621
|
+
F: __dxlog_file11,
|
|
2622
|
+
L: 91,
|
|
2623
|
+
S: this,
|
|
2624
|
+
A: [
|
|
2625
|
+
"credentials.every((credential) => credential.id)",
|
|
2626
|
+
"'Credentials must have an id'"
|
|
2627
|
+
]
|
|
2628
|
+
});
|
|
2195
2629
|
const errors = new Trigger4();
|
|
2196
2630
|
const ctx = this._ctx.derive({
|
|
2197
2631
|
onError: (err) => {
|
|
2198
|
-
|
|
2632
|
+
log9.warn("Notarization error", {
|
|
2199
2633
|
err
|
|
2200
2634
|
}, {
|
|
2201
|
-
F:
|
|
2202
|
-
L:
|
|
2635
|
+
F: __dxlog_file11,
|
|
2636
|
+
L: 99,
|
|
2203
2637
|
S: this,
|
|
2204
2638
|
C: (f, a) => f(...a)
|
|
2205
2639
|
});
|
|
@@ -2207,15 +2641,15 @@ var NotarizationPlugin = class {
|
|
|
2207
2641
|
errors.throw(err);
|
|
2208
2642
|
}
|
|
2209
2643
|
});
|
|
2210
|
-
opCtx
|
|
2644
|
+
opCtx?.onDispose(() => ctx.dispose());
|
|
2211
2645
|
if (timeout !== 0) {
|
|
2212
2646
|
scheduleTask3(ctx, () => {
|
|
2213
|
-
|
|
2647
|
+
log9.warn("Notarization timeout", {
|
|
2214
2648
|
timeout,
|
|
2215
2649
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2216
2650
|
}, {
|
|
2217
|
-
F:
|
|
2218
|
-
L:
|
|
2651
|
+
F: __dxlog_file11,
|
|
2652
|
+
L: 111,
|
|
2219
2653
|
S: this,
|
|
2220
2654
|
C: (f, a) => f(...a)
|
|
2221
2655
|
});
|
|
@@ -2234,11 +2668,11 @@ var NotarizationPlugin = class {
|
|
|
2234
2668
|
...this._extensions
|
|
2235
2669
|
].find((peer2) => !peersTried.has(peer2));
|
|
2236
2670
|
if (!peer) {
|
|
2237
|
-
|
|
2671
|
+
log9.warn("Exhausted all peers to notarize with", {
|
|
2238
2672
|
retryIn: retryTimeout
|
|
2239
2673
|
}, {
|
|
2240
|
-
F:
|
|
2241
|
-
L:
|
|
2674
|
+
F: __dxlog_file11,
|
|
2675
|
+
L: 136,
|
|
2242
2676
|
S: this,
|
|
2243
2677
|
C: (f, a) => f(...a)
|
|
2244
2678
|
});
|
|
@@ -2247,30 +2681,30 @@ var NotarizationPlugin = class {
|
|
|
2247
2681
|
return;
|
|
2248
2682
|
}
|
|
2249
2683
|
peersTried.add(peer);
|
|
2250
|
-
|
|
2684
|
+
log9("try notarizing", {
|
|
2251
2685
|
peer: peer.localPeerId,
|
|
2252
2686
|
credentialId: credentials.map((credential) => credential.id)
|
|
2253
2687
|
}, {
|
|
2254
|
-
F:
|
|
2255
|
-
L:
|
|
2688
|
+
F: __dxlog_file11,
|
|
2689
|
+
L: 143,
|
|
2256
2690
|
S: this,
|
|
2257
2691
|
C: (f, a) => f(...a)
|
|
2258
2692
|
});
|
|
2259
2693
|
await peer.rpc.NotarizationService.notarize({
|
|
2260
2694
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2261
2695
|
});
|
|
2262
|
-
|
|
2263
|
-
F:
|
|
2264
|
-
L:
|
|
2696
|
+
log9("success", void 0, {
|
|
2697
|
+
F: __dxlog_file11,
|
|
2698
|
+
L: 147,
|
|
2265
2699
|
S: this,
|
|
2266
2700
|
C: (f, a) => f(...a)
|
|
2267
2701
|
});
|
|
2268
2702
|
await sleep(successDelay);
|
|
2269
2703
|
} catch (err) {
|
|
2270
2704
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2271
|
-
|
|
2272
|
-
F:
|
|
2273
|
-
L:
|
|
2705
|
+
log9.warn("error notarizing (recoverable)", err, {
|
|
2706
|
+
F: __dxlog_file11,
|
|
2707
|
+
L: 151,
|
|
2274
2708
|
S: this,
|
|
2275
2709
|
C: (f, a) => f(...a)
|
|
2276
2710
|
});
|
|
@@ -2286,9 +2720,9 @@ var NotarizationPlugin = class {
|
|
|
2286
2720
|
allNotarized,
|
|
2287
2721
|
errors.wait()
|
|
2288
2722
|
]);
|
|
2289
|
-
|
|
2290
|
-
F:
|
|
2291
|
-
L:
|
|
2723
|
+
log9("done", void 0, {
|
|
2724
|
+
F: __dxlog_file11,
|
|
2725
|
+
L: 162,
|
|
2292
2726
|
S: this,
|
|
2293
2727
|
C: (f, a) => f(...a)
|
|
2294
2728
|
});
|
|
@@ -2300,16 +2734,23 @@ var NotarizationPlugin = class {
|
|
|
2300
2734
|
* Called with credentials arriving from the control pipeline.
|
|
2301
2735
|
*/
|
|
2302
2736
|
async processCredential(credential) {
|
|
2303
|
-
var _a;
|
|
2304
2737
|
if (!credential.id) {
|
|
2305
2738
|
return;
|
|
2306
2739
|
}
|
|
2307
|
-
|
|
2740
|
+
this._processCredentialsTriggers.get(credential.id)?.wake();
|
|
2308
2741
|
this._processedCredentials.add(credential.id);
|
|
2309
2742
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2310
2743
|
}
|
|
2311
2744
|
setWriter(writer) {
|
|
2312
|
-
|
|
2745
|
+
invariant10(!this._writer, "Writer already set.", {
|
|
2746
|
+
F: __dxlog_file11,
|
|
2747
|
+
L: 181,
|
|
2748
|
+
S: this,
|
|
2749
|
+
A: [
|
|
2750
|
+
"!this._writer",
|
|
2751
|
+
"'Writer already set.'"
|
|
2752
|
+
]
|
|
2753
|
+
});
|
|
2313
2754
|
this._writer = writer;
|
|
2314
2755
|
}
|
|
2315
2756
|
async _waitUntilProcessed(id) {
|
|
@@ -2322,12 +2763,19 @@ var NotarizationPlugin = class {
|
|
|
2322
2763
|
* Requests from other peers to notarize credentials.
|
|
2323
2764
|
*/
|
|
2324
2765
|
async _onNotarize(request) {
|
|
2325
|
-
var _a;
|
|
2326
2766
|
if (!this._writer) {
|
|
2327
2767
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2328
2768
|
}
|
|
2329
|
-
for (const credential of
|
|
2330
|
-
|
|
2769
|
+
for (const credential of request.credentials ?? []) {
|
|
2770
|
+
invariant10(credential.id, "Credential must have an id", {
|
|
2771
|
+
F: __dxlog_file11,
|
|
2772
|
+
L: 200,
|
|
2773
|
+
S: this,
|
|
2774
|
+
A: [
|
|
2775
|
+
"credential.id",
|
|
2776
|
+
"'Credential must have an id'"
|
|
2777
|
+
]
|
|
2778
|
+
});
|
|
2331
2779
|
if (this._processedCredentials.has(credential.id)) {
|
|
2332
2780
|
continue;
|
|
2333
2781
|
}
|
|
@@ -2337,11 +2785,11 @@ var NotarizationPlugin = class {
|
|
|
2337
2785
|
createExtension() {
|
|
2338
2786
|
const extension = new NotarizationTeleportExtension({
|
|
2339
2787
|
onOpen: async () => {
|
|
2340
|
-
|
|
2788
|
+
log9("extension opened", {
|
|
2341
2789
|
peer: extension.localPeerId
|
|
2342
2790
|
}, {
|
|
2343
|
-
F:
|
|
2344
|
-
L:
|
|
2791
|
+
F: __dxlog_file11,
|
|
2792
|
+
L: 211,
|
|
2345
2793
|
S: this,
|
|
2346
2794
|
C: (f, a) => f(...a)
|
|
2347
2795
|
});
|
|
@@ -2349,11 +2797,11 @@ var NotarizationPlugin = class {
|
|
|
2349
2797
|
this._extensionOpened.emit();
|
|
2350
2798
|
},
|
|
2351
2799
|
onClose: async () => {
|
|
2352
|
-
|
|
2800
|
+
log9("extension closed", {
|
|
2353
2801
|
peer: extension.localPeerId
|
|
2354
2802
|
}, {
|
|
2355
|
-
F:
|
|
2356
|
-
L:
|
|
2803
|
+
F: __dxlog_file11,
|
|
2804
|
+
L: 216,
|
|
2357
2805
|
S: this,
|
|
2358
2806
|
C: (f, a) => f(...a)
|
|
2359
2807
|
});
|
|
@@ -2396,7 +2844,7 @@ var NotarizationTeleportExtension = class extends RpcExtension2 {
|
|
|
2396
2844
|
};
|
|
2397
2845
|
|
|
2398
2846
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2399
|
-
function
|
|
2847
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
2400
2848
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2401
2849
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2402
2850
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2406,10 +2854,11 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
2406
2854
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2407
2855
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2408
2856
|
}
|
|
2409
|
-
var
|
|
2857
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2858
|
+
var ENABLE_FEED_PURGE = false;
|
|
2410
2859
|
var DataSpace = class DataSpace2 {
|
|
2411
2860
|
constructor(params) {
|
|
2412
|
-
this._ctx = new
|
|
2861
|
+
this._ctx = new Context7();
|
|
2413
2862
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2414
2863
|
this._state = SpaceState.CLOSED;
|
|
2415
2864
|
/**
|
|
@@ -2418,7 +2867,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2418
2867
|
this.error = void 0;
|
|
2419
2868
|
this.stateUpdate = new Event5();
|
|
2420
2869
|
this.metrics = {};
|
|
2421
|
-
var _a;
|
|
2422
2870
|
this._inner = params.inner;
|
|
2423
2871
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
2424
2872
|
this._gossip = params.gossip;
|
|
@@ -2427,7 +2875,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2427
2875
|
this._feedStore = params.feedStore;
|
|
2428
2876
|
this._metadataStore = params.metadataStore;
|
|
2429
2877
|
this._signingContext = params.signingContext;
|
|
2430
|
-
this._callbacks =
|
|
2878
|
+
this._callbacks = params.callbacks ?? {};
|
|
2431
2879
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2432
2880
|
trustedKeysProvider: () => new ComplexSet2(PublicKey7.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2433
2881
|
update: this._inner.stateUpdate,
|
|
@@ -2467,21 +2915,20 @@ var DataSpace = class DataSpace2 {
|
|
|
2467
2915
|
async _open() {
|
|
2468
2916
|
await this._notarizationPlugin.open();
|
|
2469
2917
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2470
|
-
await this._inner.open();
|
|
2918
|
+
await this._inner.open(new Context7());
|
|
2471
2919
|
this._state = SpaceState.CONTROL_ONLY;
|
|
2472
2920
|
this.stateUpdate.emit();
|
|
2473
2921
|
this.metrics = {};
|
|
2474
|
-
this.metrics.open = new Date();
|
|
2922
|
+
this.metrics.open = /* @__PURE__ */ new Date();
|
|
2475
2923
|
}
|
|
2476
2924
|
async close() {
|
|
2477
2925
|
await this._close();
|
|
2478
2926
|
}
|
|
2479
2927
|
async _close() {
|
|
2480
|
-
|
|
2481
|
-
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2928
|
+
await this._callbacks.beforeClose?.();
|
|
2482
2929
|
this._state = SpaceState.CLOSED;
|
|
2483
2930
|
await this._ctx.dispose();
|
|
2484
|
-
this._ctx = new
|
|
2931
|
+
this._ctx = new Context7();
|
|
2485
2932
|
await this.authVerifier.close();
|
|
2486
2933
|
await this._inner.close();
|
|
2487
2934
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
@@ -2500,21 +2947,21 @@ var DataSpace = class DataSpace2 {
|
|
|
2500
2947
|
initializeDataPipelineAsync() {
|
|
2501
2948
|
scheduleTask4(this._ctx, async () => {
|
|
2502
2949
|
try {
|
|
2503
|
-
this.metrics.pipelineInitBegin = new Date();
|
|
2950
|
+
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
2504
2951
|
await this.initializeDataPipeline();
|
|
2505
2952
|
} catch (err) {
|
|
2506
2953
|
if (err instanceof CancelledError) {
|
|
2507
|
-
|
|
2508
|
-
F:
|
|
2509
|
-
L:
|
|
2954
|
+
log10("data pipeline initialization cancelled", err, {
|
|
2955
|
+
F: __dxlog_file12,
|
|
2956
|
+
L: 199,
|
|
2510
2957
|
S: this,
|
|
2511
2958
|
C: (f, a) => f(...a)
|
|
2512
2959
|
});
|
|
2513
2960
|
return;
|
|
2514
2961
|
}
|
|
2515
|
-
|
|
2516
|
-
F:
|
|
2517
|
-
L:
|
|
2962
|
+
log10.error("Error initializing data pipeline", err, {
|
|
2963
|
+
F: __dxlog_file12,
|
|
2964
|
+
L: 203,
|
|
2518
2965
|
S: this,
|
|
2519
2966
|
C: (f, a) => f(...a)
|
|
2520
2967
|
});
|
|
@@ -2522,12 +2969,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2522
2969
|
this.error = err;
|
|
2523
2970
|
this.stateUpdate.emit();
|
|
2524
2971
|
} finally {
|
|
2525
|
-
this.metrics.ready = new Date();
|
|
2972
|
+
this.metrics.ready = /* @__PURE__ */ new Date();
|
|
2526
2973
|
}
|
|
2527
2974
|
});
|
|
2528
2975
|
}
|
|
2529
2976
|
async initializeDataPipeline() {
|
|
2530
|
-
var _a, _b, _c, _d;
|
|
2531
2977
|
if (this._state !== SpaceState.CONTROL_ONLY) {
|
|
2532
2978
|
throw new SystemError("Invalid operation");
|
|
2533
2979
|
}
|
|
@@ -2536,11 +2982,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2536
2982
|
ctx: this._ctx,
|
|
2537
2983
|
breakOnStall: false
|
|
2538
2984
|
});
|
|
2539
|
-
this.metrics.controlPipelineReady = new Date();
|
|
2985
|
+
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
2540
2986
|
await this._createWritableFeeds();
|
|
2541
|
-
|
|
2542
|
-
F:
|
|
2543
|
-
L:
|
|
2987
|
+
log10("writable feeds created", void 0, {
|
|
2988
|
+
F: __dxlog_file12,
|
|
2989
|
+
L: 227,
|
|
2544
2990
|
S: this,
|
|
2545
2991
|
C: (f, a) => f(...a)
|
|
2546
2992
|
});
|
|
@@ -2553,11 +2999,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2553
2999
|
}), this._inner.controlPipeline.writer));
|
|
2554
3000
|
}
|
|
2555
3001
|
await this._inner.initializeDataPipeline();
|
|
2556
|
-
this.metrics.dataPipelineOpen = new Date();
|
|
3002
|
+
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
2557
3003
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2558
|
-
|
|
2559
|
-
F:
|
|
2560
|
-
L:
|
|
3004
|
+
log10("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3005
|
+
F: __dxlog_file12,
|
|
3006
|
+
L: 248,
|
|
2561
3007
|
S: this,
|
|
2562
3008
|
C: (f, a) => f(...a)
|
|
2563
3009
|
});
|
|
@@ -2565,17 +3011,17 @@ var DataSpace = class DataSpace2 {
|
|
|
2565
3011
|
ctx: this._ctx,
|
|
2566
3012
|
breakOnStall: false
|
|
2567
3013
|
});
|
|
2568
|
-
this.metrics.dataPipelineReady = new Date();
|
|
2569
|
-
|
|
2570
|
-
F:
|
|
2571
|
-
L:
|
|
3014
|
+
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3015
|
+
log10("data pipeline ready", void 0, {
|
|
3016
|
+
F: __dxlog_file12,
|
|
3017
|
+
L: 257,
|
|
2572
3018
|
S: this,
|
|
2573
3019
|
C: (f, a) => f(...a)
|
|
2574
3020
|
});
|
|
2575
|
-
await
|
|
3021
|
+
await this._callbacks.beforeReady?.();
|
|
2576
3022
|
this._state = SpaceState.READY;
|
|
2577
3023
|
this.stateUpdate.emit();
|
|
2578
|
-
await
|
|
3024
|
+
await this._callbacks.afterReady?.();
|
|
2579
3025
|
}
|
|
2580
3026
|
async _createWritableFeeds() {
|
|
2581
3027
|
const credentials = [];
|
|
@@ -2622,7 +3068,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2622
3068
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
2623
3069
|
}
|
|
2624
3070
|
async createEpoch() {
|
|
2625
|
-
var _a, _b;
|
|
2626
3071
|
const epoch = await this.dataPipeline.createEpoch();
|
|
2627
3072
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
2628
3073
|
credential: {
|
|
@@ -2641,10 +3086,13 @@ var DataSpace = class DataSpace2 {
|
|
|
2641
3086
|
receipt.seq
|
|
2642
3087
|
]
|
|
2643
3088
|
]));
|
|
2644
|
-
|
|
2645
|
-
const
|
|
2646
|
-
|
|
2647
|
-
|
|
3089
|
+
if (ENABLE_FEED_PURGE) {
|
|
3090
|
+
for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
|
|
3091
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
3092
|
+
if (indexBeforeEpoch === void 0) {
|
|
3093
|
+
continue;
|
|
3094
|
+
}
|
|
3095
|
+
await feed.safeClear(0, indexBeforeEpoch + 1);
|
|
2648
3096
|
}
|
|
2649
3097
|
}
|
|
2650
3098
|
}
|
|
@@ -2666,33 +3114,33 @@ var DataSpace = class DataSpace2 {
|
|
|
2666
3114
|
this.stateUpdate.emit();
|
|
2667
3115
|
}
|
|
2668
3116
|
};
|
|
2669
|
-
|
|
3117
|
+
_ts_decorate3([
|
|
2670
3118
|
synchronized
|
|
2671
3119
|
], DataSpace.prototype, "open", null);
|
|
2672
|
-
|
|
3120
|
+
_ts_decorate3([
|
|
2673
3121
|
synchronized
|
|
2674
3122
|
], DataSpace.prototype, "close", null);
|
|
2675
|
-
|
|
3123
|
+
_ts_decorate3([
|
|
2676
3124
|
timed(1e4)
|
|
2677
3125
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2678
|
-
|
|
3126
|
+
_ts_decorate3([
|
|
2679
3127
|
synchronized
|
|
2680
3128
|
], DataSpace.prototype, "activate", null);
|
|
2681
|
-
|
|
3129
|
+
_ts_decorate3([
|
|
2682
3130
|
synchronized
|
|
2683
3131
|
], DataSpace.prototype, "deactivate", null);
|
|
2684
|
-
DataSpace =
|
|
3132
|
+
DataSpace = _ts_decorate3([
|
|
2685
3133
|
trackLeaks("open", "close")
|
|
2686
3134
|
], DataSpace);
|
|
2687
3135
|
|
|
2688
3136
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2689
|
-
import invariant10 from "tiny-invariant";
|
|
2690
3137
|
import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
2691
|
-
import { cancelWithContext as cancelWithContext3, Context as
|
|
3138
|
+
import { cancelWithContext as cancelWithContext3, Context as Context8 } from "@dxos/context";
|
|
2692
3139
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3140
|
+
import { invariant as invariant11 } from "@dxos/invariant";
|
|
2693
3141
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2694
|
-
import { log as
|
|
2695
|
-
import { trace as
|
|
3142
|
+
import { log as log11 } from "@dxos/log";
|
|
3143
|
+
import { trace as trace5 } from "@dxos/protocols";
|
|
2696
3144
|
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2697
3145
|
import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
|
|
2698
3146
|
import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxos/util";
|
|
@@ -2700,10 +3148,9 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxo
|
|
|
2700
3148
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
2701
3149
|
import { createCredential } from "@dxos/credentials";
|
|
2702
3150
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
2703
|
-
import { AdmittedFeed as AdmittedFeed4, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3151
|
+
import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2704
3152
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
2705
3153
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
2706
|
-
var _a, _b, _c, _d;
|
|
2707
3154
|
const credentials = [
|
|
2708
3155
|
await createCredential({
|
|
2709
3156
|
signer: keyring,
|
|
@@ -2721,13 +3168,13 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2721
3168
|
assertion: {
|
|
2722
3169
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
2723
3170
|
spaceKey: space.key,
|
|
2724
|
-
role:
|
|
3171
|
+
role: SpaceMember2.Role.ADMIN,
|
|
2725
3172
|
profile: signingContext.profile,
|
|
2726
|
-
genesisFeedKey:
|
|
3173
|
+
genesisFeedKey: space.controlFeedKey ?? failUndefined2()
|
|
2727
3174
|
}
|
|
2728
3175
|
}),
|
|
2729
3176
|
await signingContext.credentialSigner.createCredential({
|
|
2730
|
-
subject:
|
|
3177
|
+
subject: space.controlFeedKey ?? failUndefined2(),
|
|
2731
3178
|
assertion: {
|
|
2732
3179
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2733
3180
|
spaceKey: space.key,
|
|
@@ -2737,7 +3184,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2737
3184
|
}
|
|
2738
3185
|
}),
|
|
2739
3186
|
await signingContext.credentialSigner.createCredential({
|
|
2740
|
-
subject:
|
|
3187
|
+
subject: space.dataFeedKey ?? failUndefined2(),
|
|
2741
3188
|
assertion: {
|
|
2742
3189
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2743
3190
|
spaceKey: space.key,
|
|
@@ -2747,7 +3194,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2747
3194
|
}
|
|
2748
3195
|
}),
|
|
2749
3196
|
await signingContext.credentialSigner.createCredential({
|
|
2750
|
-
subject:
|
|
3197
|
+
subject: space.key ?? failUndefined2(),
|
|
2751
3198
|
assertion: {
|
|
2752
3199
|
"@type": "dxos.halo.credentials.Epoch",
|
|
2753
3200
|
number: 0,
|
|
@@ -2768,7 +3215,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2768
3215
|
};
|
|
2769
3216
|
|
|
2770
3217
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2771
|
-
function
|
|
3218
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
2772
3219
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2773
3220
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2774
3221
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2778,7 +3225,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
2778
3225
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2779
3226
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2780
3227
|
}
|
|
2781
|
-
var
|
|
3228
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2782
3229
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2783
3230
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2784
3231
|
this._spaceManager = _spaceManager;
|
|
@@ -2787,7 +3234,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2787
3234
|
this._keyring = _keyring;
|
|
2788
3235
|
this._signingContext = _signingContext;
|
|
2789
3236
|
this._feedStore = _feedStore;
|
|
2790
|
-
this._ctx = new
|
|
3237
|
+
this._ctx = new Context8();
|
|
2791
3238
|
this.updated = new Event6();
|
|
2792
3239
|
this._spaces = new ComplexMap3(PublicKey8.hash);
|
|
2793
3240
|
this._isOpen = false;
|
|
@@ -2798,36 +3245,36 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2798
3245
|
return this._spaces;
|
|
2799
3246
|
}
|
|
2800
3247
|
async open() {
|
|
2801
|
-
|
|
2802
|
-
F:
|
|
2803
|
-
L:
|
|
3248
|
+
log11("open", void 0, {
|
|
3249
|
+
F: __dxlog_file13,
|
|
3250
|
+
L: 79,
|
|
2804
3251
|
S: this,
|
|
2805
3252
|
C: (f, a) => f(...a)
|
|
2806
3253
|
});
|
|
2807
|
-
|
|
3254
|
+
log11.trace("dxos.echo.data-space-manager.open", trace5.begin({
|
|
2808
3255
|
id: this._instanceId
|
|
2809
3256
|
}), {
|
|
2810
|
-
F:
|
|
2811
|
-
L:
|
|
3257
|
+
F: __dxlog_file13,
|
|
3258
|
+
L: 80,
|
|
2812
3259
|
S: this,
|
|
2813
3260
|
C: (f, a) => f(...a)
|
|
2814
3261
|
});
|
|
2815
3262
|
await this._metadataStore.load();
|
|
2816
|
-
|
|
3263
|
+
log11("metadata loaded", {
|
|
2817
3264
|
spaces: this._metadataStore.spaces.length
|
|
2818
3265
|
}, {
|
|
2819
|
-
F:
|
|
2820
|
-
L:
|
|
3266
|
+
F: __dxlog_file13,
|
|
3267
|
+
L: 82,
|
|
2821
3268
|
S: this,
|
|
2822
3269
|
C: (f, a) => f(...a)
|
|
2823
3270
|
});
|
|
2824
3271
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2825
3272
|
try {
|
|
2826
|
-
|
|
3273
|
+
log11("load space", {
|
|
2827
3274
|
spaceMetadata
|
|
2828
3275
|
}, {
|
|
2829
|
-
F:
|
|
2830
|
-
L:
|
|
3276
|
+
F: __dxlog_file13,
|
|
3277
|
+
L: 86,
|
|
2831
3278
|
S: this,
|
|
2832
3279
|
C: (f, a) => f(...a)
|
|
2833
3280
|
});
|
|
@@ -2836,12 +3283,12 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2836
3283
|
space.initializeDataPipelineAsync();
|
|
2837
3284
|
}
|
|
2838
3285
|
} catch (err) {
|
|
2839
|
-
|
|
3286
|
+
log11.error("Error loading space", {
|
|
2840
3287
|
spaceMetadata,
|
|
2841
3288
|
err
|
|
2842
3289
|
}, {
|
|
2843
|
-
F:
|
|
2844
|
-
L:
|
|
3290
|
+
F: __dxlog_file13,
|
|
3291
|
+
L: 92,
|
|
2845
3292
|
S: this,
|
|
2846
3293
|
C: (f, a) => f(...a)
|
|
2847
3294
|
});
|
|
@@ -2849,19 +3296,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2849
3296
|
}
|
|
2850
3297
|
this._isOpen = true;
|
|
2851
3298
|
this.updated.emit();
|
|
2852
|
-
|
|
3299
|
+
log11.trace("dxos.echo.data-space-manager.open", trace5.end({
|
|
2853
3300
|
id: this._instanceId
|
|
2854
3301
|
}), {
|
|
2855
|
-
F:
|
|
2856
|
-
L:
|
|
3302
|
+
F: __dxlog_file13,
|
|
3303
|
+
L: 98,
|
|
2857
3304
|
S: this,
|
|
2858
3305
|
C: (f, a) => f(...a)
|
|
2859
3306
|
});
|
|
2860
3307
|
}
|
|
2861
3308
|
async close() {
|
|
2862
|
-
|
|
2863
|
-
F:
|
|
2864
|
-
L:
|
|
3309
|
+
log11("close", void 0, {
|
|
3310
|
+
F: __dxlog_file13,
|
|
3311
|
+
L: 103,
|
|
2865
3312
|
S: this,
|
|
2866
3313
|
C: (f, a) => f(...a)
|
|
2867
3314
|
});
|
|
@@ -2875,7 +3322,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2875
3322
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2876
3323
|
*/
|
|
2877
3324
|
async createSpace() {
|
|
2878
|
-
|
|
3325
|
+
invariant11(this._isOpen, "Not open.", {
|
|
3326
|
+
F: __dxlog_file13,
|
|
3327
|
+
L: 116,
|
|
3328
|
+
S: this,
|
|
3329
|
+
A: [
|
|
3330
|
+
"this._isOpen",
|
|
3331
|
+
"'Not open.'"
|
|
3332
|
+
]
|
|
3333
|
+
});
|
|
2879
3334
|
const spaceKey = await this._keyring.createKey();
|
|
2880
3335
|
const controlFeedKey = await this._keyring.createKey();
|
|
2881
3336
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2886,11 +3341,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2886
3341
|
dataFeedKey,
|
|
2887
3342
|
state: SpaceState2.ACTIVE
|
|
2888
3343
|
};
|
|
2889
|
-
|
|
3344
|
+
log11("creating space...", {
|
|
2890
3345
|
spaceKey
|
|
2891
3346
|
}, {
|
|
2892
|
-
F:
|
|
2893
|
-
L:
|
|
3347
|
+
F: __dxlog_file13,
|
|
3348
|
+
L: 128,
|
|
2894
3349
|
S: this,
|
|
2895
3350
|
C: (f, a) => f(...a)
|
|
2896
3351
|
});
|
|
@@ -2898,7 +3353,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2898
3353
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2899
3354
|
await this._metadataStore.addSpace(metadata);
|
|
2900
3355
|
const memberCredential = credentials[1];
|
|
2901
|
-
|
|
3356
|
+
invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3357
|
+
F: __dxlog_file13,
|
|
3358
|
+
L: 135,
|
|
3359
|
+
S: this,
|
|
3360
|
+
A: [
|
|
3361
|
+
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
3362
|
+
""
|
|
3363
|
+
]
|
|
3364
|
+
});
|
|
2902
3365
|
await this._signingContext.recordCredential(memberCredential);
|
|
2903
3366
|
await space.initializeDataPipeline();
|
|
2904
3367
|
this.updated.emit();
|
|
@@ -2906,16 +3369,32 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2906
3369
|
}
|
|
2907
3370
|
// TODO(burdon): Rename join space.
|
|
2908
3371
|
async acceptSpace(opts) {
|
|
2909
|
-
|
|
3372
|
+
log11("accept space", {
|
|
2910
3373
|
opts
|
|
2911
3374
|
}, {
|
|
2912
|
-
F:
|
|
2913
|
-
L:
|
|
3375
|
+
F: __dxlog_file13,
|
|
3376
|
+
L: 147,
|
|
2914
3377
|
S: this,
|
|
2915
3378
|
C: (f, a) => f(...a)
|
|
2916
3379
|
});
|
|
2917
|
-
|
|
2918
|
-
|
|
3380
|
+
invariant11(this._isOpen, "Not open.", {
|
|
3381
|
+
F: __dxlog_file13,
|
|
3382
|
+
L: 148,
|
|
3383
|
+
S: this,
|
|
3384
|
+
A: [
|
|
3385
|
+
"this._isOpen",
|
|
3386
|
+
"'Not open.'"
|
|
3387
|
+
]
|
|
3388
|
+
});
|
|
3389
|
+
invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3390
|
+
F: __dxlog_file13,
|
|
3391
|
+
L: 149,
|
|
3392
|
+
S: this,
|
|
3393
|
+
A: [
|
|
3394
|
+
"!this._spaces.has(opts.spaceKey)",
|
|
3395
|
+
"'Space already exists.'"
|
|
3396
|
+
]
|
|
3397
|
+
});
|
|
2919
3398
|
const metadata = {
|
|
2920
3399
|
key: opts.spaceKey,
|
|
2921
3400
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2940,11 +3419,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2940
3419
|
}));
|
|
2941
3420
|
}
|
|
2942
3421
|
async _constructSpace(metadata) {
|
|
2943
|
-
|
|
3422
|
+
log11("construct space", {
|
|
2944
3423
|
metadata
|
|
2945
3424
|
}, {
|
|
2946
|
-
F:
|
|
2947
|
-
L:
|
|
3425
|
+
F: __dxlog_file13,
|
|
3426
|
+
L: 182,
|
|
2948
3427
|
S: this,
|
|
2949
3428
|
C: (f, a) => f(...a)
|
|
2950
3429
|
});
|
|
@@ -2952,7 +3431,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2952
3431
|
localPeerId: this._signingContext.deviceKey
|
|
2953
3432
|
});
|
|
2954
3433
|
const presence = new Presence({
|
|
2955
|
-
announceInterval:
|
|
3434
|
+
announceInterval: 1e3,
|
|
2956
3435
|
offlineTimeout: 5e3,
|
|
2957
3436
|
identityKey: this._signingContext.identityKey,
|
|
2958
3437
|
gossip
|
|
@@ -2978,9 +3457,9 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2978
3457
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2979
3458
|
},
|
|
2980
3459
|
onAuthFailure: () => {
|
|
2981
|
-
|
|
2982
|
-
F:
|
|
2983
|
-
L:
|
|
3460
|
+
log11.warn("auth failure", void 0, {
|
|
3461
|
+
F: __dxlog_file13,
|
|
3462
|
+
L: 213,
|
|
2984
3463
|
S: this,
|
|
2985
3464
|
C: (f, a) => f(...a)
|
|
2986
3465
|
});
|
|
@@ -3000,23 +3479,23 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3000
3479
|
signingContext: this._signingContext,
|
|
3001
3480
|
callbacks: {
|
|
3002
3481
|
beforeReady: async () => {
|
|
3003
|
-
|
|
3482
|
+
log11("before space ready", {
|
|
3004
3483
|
space: space.key
|
|
3005
3484
|
}, {
|
|
3006
|
-
F:
|
|
3007
|
-
L:
|
|
3485
|
+
F: __dxlog_file13,
|
|
3486
|
+
L: 231,
|
|
3008
3487
|
S: this,
|
|
3009
3488
|
C: (f, a) => f(...a)
|
|
3010
3489
|
});
|
|
3011
3490
|
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
3012
3491
|
},
|
|
3013
3492
|
afterReady: async () => {
|
|
3014
|
-
|
|
3493
|
+
log11("after space ready", {
|
|
3015
3494
|
space: space.key,
|
|
3016
3495
|
open: this._isOpen
|
|
3017
3496
|
}, {
|
|
3018
|
-
F:
|
|
3019
|
-
L:
|
|
3497
|
+
F: __dxlog_file13,
|
|
3498
|
+
L: 238,
|
|
3020
3499
|
S: this,
|
|
3021
3500
|
C: (f, a) => f(...a)
|
|
3022
3501
|
});
|
|
@@ -3025,11 +3504,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3025
3504
|
}
|
|
3026
3505
|
},
|
|
3027
3506
|
beforeClose: async () => {
|
|
3028
|
-
|
|
3507
|
+
log11("before space close", {
|
|
3029
3508
|
space: space.key
|
|
3030
3509
|
}, {
|
|
3031
|
-
F:
|
|
3032
|
-
L:
|
|
3510
|
+
F: __dxlog_file13,
|
|
3511
|
+
L: 244,
|
|
3033
3512
|
S: this,
|
|
3034
3513
|
C: (f, a) => f(...a)
|
|
3035
3514
|
});
|
|
@@ -3051,19 +3530,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3051
3530
|
return dataSpace;
|
|
3052
3531
|
}
|
|
3053
3532
|
};
|
|
3054
|
-
|
|
3533
|
+
_ts_decorate4([
|
|
3055
3534
|
synchronized2
|
|
3056
3535
|
], DataSpaceManager.prototype, "open", null);
|
|
3057
|
-
|
|
3536
|
+
_ts_decorate4([
|
|
3058
3537
|
synchronized2
|
|
3059
3538
|
], DataSpaceManager.prototype, "close", null);
|
|
3060
|
-
|
|
3539
|
+
_ts_decorate4([
|
|
3061
3540
|
synchronized2
|
|
3062
3541
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3063
|
-
|
|
3542
|
+
_ts_decorate4([
|
|
3064
3543
|
synchronized2
|
|
3065
3544
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3066
|
-
DataSpaceManager =
|
|
3545
|
+
DataSpaceManager = _ts_decorate4([
|
|
3067
3546
|
trackLeaks2("open", "close")
|
|
3068
3547
|
], DataSpaceManager);
|
|
3069
3548
|
|
|
@@ -3073,11 +3552,11 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
|
3073
3552
|
import { raise as raise2 } from "@dxos/debug";
|
|
3074
3553
|
import { SpaceNotFoundError } from "@dxos/echo-pipeline";
|
|
3075
3554
|
import { ApiError } from "@dxos/errors";
|
|
3076
|
-
import { log as
|
|
3555
|
+
import { log as log12 } from "@dxos/log";
|
|
3077
3556
|
import { encodeError } from "@dxos/protocols";
|
|
3078
|
-
import { SpaceMember as
|
|
3557
|
+
import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3079
3558
|
import { humanize } from "@dxos/util";
|
|
3080
|
-
var
|
|
3559
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
3081
3560
|
var SpacesServiceImpl = class {
|
|
3082
3561
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
3083
3562
|
this._identityManager = _identityManager;
|
|
@@ -3094,9 +3573,8 @@ var SpacesServiceImpl = class {
|
|
|
3094
3573
|
return this._serializeSpace(space);
|
|
3095
3574
|
}
|
|
3096
3575
|
async updateSpace({ spaceKey, state }) {
|
|
3097
|
-
var _a;
|
|
3098
3576
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3099
|
-
const space =
|
|
3577
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3100
3578
|
if (state) {
|
|
3101
3579
|
switch (state) {
|
|
3102
3580
|
case SpaceState3.ACTIVE:
|
|
@@ -3115,10 +3593,10 @@ var SpacesServiceImpl = class {
|
|
|
3115
3593
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
3116
3594
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3117
3595
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
3118
|
-
|
|
3596
|
+
log12("update", {
|
|
3119
3597
|
spaces
|
|
3120
3598
|
}, {
|
|
3121
|
-
F:
|
|
3599
|
+
F: __dxlog_file14,
|
|
3122
3600
|
L: 78,
|
|
3123
3601
|
S: this,
|
|
3124
3602
|
C: (f, a) => f(...a)
|
|
@@ -3160,17 +3638,15 @@ var SpacesServiceImpl = class {
|
|
|
3160
3638
|
});
|
|
3161
3639
|
}
|
|
3162
3640
|
async postMessage({ spaceKey, channel, message }) {
|
|
3163
|
-
var _a;
|
|
3164
3641
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3165
|
-
const space =
|
|
3642
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3166
3643
|
await space.postMessage(getChannelId(channel), message);
|
|
3167
3644
|
}
|
|
3168
3645
|
subscribeMessages({ spaceKey, channel }) {
|
|
3169
3646
|
return new Stream10(({ ctx, next }) => {
|
|
3170
3647
|
scheduleTask5(ctx, async () => {
|
|
3171
|
-
var _a;
|
|
3172
3648
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3173
|
-
const space =
|
|
3649
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3174
3650
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3175
3651
|
next(message);
|
|
3176
3652
|
});
|
|
@@ -3180,8 +3656,7 @@ var SpacesServiceImpl = class {
|
|
|
3180
3656
|
}
|
|
3181
3657
|
queryCredentials({ spaceKey }) {
|
|
3182
3658
|
return new Stream10(({ ctx, next }) => {
|
|
3183
|
-
|
|
3184
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3659
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3185
3660
|
const processor = {
|
|
3186
3661
|
processCredential: async (credential) => {
|
|
3187
3662
|
next(credential);
|
|
@@ -3192,9 +3667,8 @@ var SpacesServiceImpl = class {
|
|
|
3192
3667
|
});
|
|
3193
3668
|
}
|
|
3194
3669
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3195
|
-
|
|
3196
|
-
const
|
|
3197
|
-
for (const credential of credentials != null ? credentials : []) {
|
|
3670
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3671
|
+
for (const credential of credentials ?? []) {
|
|
3198
3672
|
await space.controlPipeline.writer.write({
|
|
3199
3673
|
credential: {
|
|
3200
3674
|
credential
|
|
@@ -3203,13 +3677,11 @@ var SpacesServiceImpl = class {
|
|
|
3203
3677
|
}
|
|
3204
3678
|
}
|
|
3205
3679
|
async createEpoch({ spaceKey }) {
|
|
3206
|
-
var _a;
|
|
3207
3680
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3208
|
-
const space =
|
|
3681
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3209
3682
|
await space.createEpoch();
|
|
3210
3683
|
}
|
|
3211
3684
|
_serializeSpace(space) {
|
|
3212
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3213
3685
|
return {
|
|
3214
3686
|
spaceKey: space.key,
|
|
3215
3687
|
state: space.state,
|
|
@@ -3221,25 +3693,30 @@ var SpacesServiceImpl = class {
|
|
|
3221
3693
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
3222
3694
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
3223
3695
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
3224
|
-
dataFeeds:
|
|
3225
|
-
startDataTimeframe:
|
|
3226
|
-
currentDataTimeframe:
|
|
3227
|
-
targetDataTimeframe:
|
|
3228
|
-
totalDataTimeframe:
|
|
3696
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
3697
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
3698
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
3699
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
3700
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
3229
3701
|
},
|
|
3230
3702
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3231
|
-
|
|
3703
|
+
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
3704
|
+
const isMe = this._identityManager.identity?.identityKey.equals(member.key);
|
|
3705
|
+
if (isMe) {
|
|
3706
|
+
peers.push(space.presence.getLocalState());
|
|
3707
|
+
}
|
|
3232
3708
|
return {
|
|
3233
3709
|
identity: {
|
|
3234
3710
|
identityKey: member.key,
|
|
3235
3711
|
profile: {
|
|
3236
|
-
displayName:
|
|
3712
|
+
displayName: member.assertion.profile?.displayName ?? humanize(member.key)
|
|
3237
3713
|
}
|
|
3238
3714
|
},
|
|
3239
|
-
presence:
|
|
3715
|
+
presence: isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
|
|
3716
|
+
peerStates: peers
|
|
3240
3717
|
};
|
|
3241
3718
|
}),
|
|
3242
|
-
creator:
|
|
3719
|
+
creator: space.inner.spaceState.creator?.key,
|
|
3243
3720
|
cache: space.cache,
|
|
3244
3721
|
metrics: space.metrics
|
|
3245
3722
|
};
|
|
@@ -3248,20 +3725,33 @@ var SpacesServiceImpl = class {
|
|
|
3248
3725
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3249
3726
|
|
|
3250
3727
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3251
|
-
import invariant11 from "tiny-invariant";
|
|
3252
3728
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
3729
|
+
import { Context as Context9 } from "@dxos/context";
|
|
3253
3730
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
3254
3731
|
import { failUndefined as failUndefined3 } from "@dxos/debug";
|
|
3255
3732
|
import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
|
|
3256
3733
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
3734
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3257
3735
|
import { Keyring } from "@dxos/keyring";
|
|
3258
3736
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3259
|
-
import { log as
|
|
3260
|
-
import { STORAGE_VERSION, trace as
|
|
3737
|
+
import { log as log13 } from "@dxos/log";
|
|
3738
|
+
import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace6 } from "@dxos/protocols";
|
|
3261
3739
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3262
3740
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
3263
|
-
|
|
3264
|
-
|
|
3741
|
+
import { trace as Trace2 } from "@dxos/tracing";
|
|
3742
|
+
import { safeInstanceof } from "@dxos/util";
|
|
3743
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
3744
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3745
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3746
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3747
|
+
else
|
|
3748
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3749
|
+
if (d = decorators[i])
|
|
3750
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3751
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3752
|
+
}
|
|
3753
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3754
|
+
var ServiceContext = class ServiceContext2 {
|
|
3265
3755
|
// prettier-ignore
|
|
3266
3756
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
3267
3757
|
this.storage = storage;
|
|
@@ -3295,105 +3785,108 @@ var ServiceContext = class {
|
|
|
3295
3785
|
});
|
|
3296
3786
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3297
3787
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3298
|
-
this._handlerFactories.set(Invitation5.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () =>
|
|
3299
|
-
var _a;
|
|
3300
|
-
return (_a = this.identityManager.identity) != null ? _a : failUndefined3();
|
|
3301
|
-
}, this._acceptIdentity.bind(this)));
|
|
3788
|
+
this._handlerFactories.set(Invitation5.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined3(), this._acceptIdentity.bind(this)));
|
|
3302
3789
|
}
|
|
3303
|
-
async open() {
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
L: 126,
|
|
3790
|
+
async open(ctx) {
|
|
3791
|
+
await this._checkStorageVersion();
|
|
3792
|
+
log13("opening...", void 0, {
|
|
3793
|
+
F: __dxlog_file15,
|
|
3794
|
+
L: 134,
|
|
3309
3795
|
S: this,
|
|
3310
3796
|
C: (f, a) => f(...a)
|
|
3311
3797
|
});
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3798
|
+
log13.trace("dxos.sdk.service-context.open", trace6.begin({
|
|
3799
|
+
id: this._instanceId
|
|
3800
|
+
}), {
|
|
3801
|
+
F: __dxlog_file15,
|
|
3802
|
+
L: 135,
|
|
3316
3803
|
S: this,
|
|
3317
3804
|
C: (f, a) => f(...a)
|
|
3318
3805
|
});
|
|
3319
3806
|
await this.signalManager.open();
|
|
3320
3807
|
await this.networkManager.open();
|
|
3321
3808
|
await this.spaceManager.open();
|
|
3322
|
-
await this.identityManager.open();
|
|
3809
|
+
await this.identityManager.open(ctx);
|
|
3323
3810
|
if (this.identityManager.identity) {
|
|
3324
|
-
await this._initialize();
|
|
3811
|
+
await this._initialize(ctx);
|
|
3325
3812
|
}
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3813
|
+
log13.trace("dxos.sdk.service-context.open", trace6.end({
|
|
3814
|
+
id: this._instanceId
|
|
3815
|
+
}), {
|
|
3816
|
+
F: __dxlog_file15,
|
|
3817
|
+
L: 143,
|
|
3329
3818
|
S: this,
|
|
3330
3819
|
C: (f, a) => f(...a)
|
|
3331
3820
|
});
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
F: __dxlog_file12,
|
|
3336
|
-
L: 139,
|
|
3821
|
+
log13("opened", void 0, {
|
|
3822
|
+
F: __dxlog_file15,
|
|
3823
|
+
L: 144,
|
|
3337
3824
|
S: this,
|
|
3338
3825
|
C: (f, a) => f(...a)
|
|
3339
3826
|
});
|
|
3340
3827
|
}
|
|
3341
3828
|
async close() {
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
L: 143,
|
|
3829
|
+
log13("closing...", void 0, {
|
|
3830
|
+
F: __dxlog_file15,
|
|
3831
|
+
L: 148,
|
|
3346
3832
|
S: this,
|
|
3347
3833
|
C: (f, a) => f(...a)
|
|
3348
3834
|
});
|
|
3349
3835
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3350
3836
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3351
3837
|
}
|
|
3352
|
-
await
|
|
3838
|
+
await this.dataSpaceManager?.close();
|
|
3353
3839
|
await this.identityManager.close();
|
|
3354
3840
|
await this.spaceManager.close();
|
|
3355
3841
|
await this.feedStore.close();
|
|
3356
3842
|
await this.networkManager.close();
|
|
3357
3843
|
await this.signalManager.close();
|
|
3358
3844
|
this.dataServiceSubscriptions.clear();
|
|
3359
|
-
|
|
3360
|
-
F:
|
|
3361
|
-
L:
|
|
3845
|
+
log13("closed", void 0, {
|
|
3846
|
+
F: __dxlog_file15,
|
|
3847
|
+
L: 159,
|
|
3362
3848
|
S: this,
|
|
3363
3849
|
C: (f, a) => f(...a)
|
|
3364
3850
|
});
|
|
3365
3851
|
}
|
|
3366
3852
|
async createIdentity(params = {}) {
|
|
3367
3853
|
const identity = await this.identityManager.createIdentity(params);
|
|
3368
|
-
await this._initialize();
|
|
3854
|
+
await this._initialize(new Context9());
|
|
3369
3855
|
return identity;
|
|
3370
3856
|
}
|
|
3371
3857
|
getInvitationHandler(invitation) {
|
|
3372
3858
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3373
|
-
|
|
3859
|
+
invariant12(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3860
|
+
F: __dxlog_file15,
|
|
3861
|
+
L: 171,
|
|
3862
|
+
S: this,
|
|
3863
|
+
A: [
|
|
3864
|
+
"factory",
|
|
3865
|
+
"`Unknown invitation kind: ${invitation.kind}`"
|
|
3866
|
+
]
|
|
3867
|
+
});
|
|
3374
3868
|
return factory(invitation);
|
|
3375
3869
|
}
|
|
3376
3870
|
async _acceptIdentity(params) {
|
|
3377
3871
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
3378
|
-
await this._initialize();
|
|
3872
|
+
await this._initialize(new Context9());
|
|
3379
3873
|
return identity;
|
|
3380
3874
|
}
|
|
3381
3875
|
async _checkStorageVersion() {
|
|
3382
3876
|
await this.metadataStore.load();
|
|
3383
|
-
if (this.metadataStore.version !==
|
|
3384
|
-
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${
|
|
3877
|
+
if (this.metadataStore.version !== STORAGE_VERSION2) {
|
|
3878
|
+
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${STORAGE_VERSION2}`);
|
|
3385
3879
|
}
|
|
3386
3880
|
}
|
|
3387
3881
|
// Called when identity is created.
|
|
3388
|
-
async _initialize() {
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
L: 187,
|
|
3882
|
+
async _initialize(ctx) {
|
|
3883
|
+
log13("initializing spaces...", void 0, {
|
|
3884
|
+
F: __dxlog_file15,
|
|
3885
|
+
L: 193,
|
|
3393
3886
|
S: this,
|
|
3394
3887
|
C: (f, a) => f(...a)
|
|
3395
3888
|
});
|
|
3396
|
-
const identity =
|
|
3889
|
+
const identity = this.identityManager.identity ?? failUndefined3();
|
|
3397
3890
|
const signingContext = {
|
|
3398
3891
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3399
3892
|
identityKey: identity.identityKey,
|
|
@@ -3410,7 +3903,15 @@ var ServiceContext = class {
|
|
|
3410
3903
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3411
3904
|
await this.dataSpaceManager.open();
|
|
3412
3905
|
this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
|
|
3413
|
-
|
|
3906
|
+
invariant12(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
3907
|
+
F: __dxlog_file15,
|
|
3908
|
+
L: 216,
|
|
3909
|
+
S: this,
|
|
3910
|
+
A: [
|
|
3911
|
+
"this.dataSpaceManager",
|
|
3912
|
+
"'dataSpaceManager not initialized yet'"
|
|
3913
|
+
]
|
|
3914
|
+
});
|
|
3414
3915
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3415
3916
|
});
|
|
3416
3917
|
this.initialized.wake();
|
|
@@ -3424,33 +3925,33 @@ var ServiceContext = class {
|
|
|
3424
3925
|
return;
|
|
3425
3926
|
}
|
|
3426
3927
|
if (!this.dataSpaceManager) {
|
|
3427
|
-
|
|
3928
|
+
log13("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3428
3929
|
details: assertion
|
|
3429
3930
|
}, {
|
|
3430
|
-
F:
|
|
3431
|
-
L:
|
|
3931
|
+
F: __dxlog_file15,
|
|
3932
|
+
L: 232,
|
|
3432
3933
|
S: this,
|
|
3433
3934
|
C: (f, a) => f(...a)
|
|
3434
3935
|
});
|
|
3435
3936
|
return;
|
|
3436
3937
|
}
|
|
3437
3938
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3438
|
-
|
|
3939
|
+
log13("space already exists, ignoring space admission", {
|
|
3439
3940
|
details: assertion
|
|
3440
3941
|
}, {
|
|
3441
|
-
F:
|
|
3442
|
-
L:
|
|
3942
|
+
F: __dxlog_file15,
|
|
3943
|
+
L: 236,
|
|
3443
3944
|
S: this,
|
|
3444
3945
|
C: (f, a) => f(...a)
|
|
3445
3946
|
});
|
|
3446
3947
|
return;
|
|
3447
3948
|
}
|
|
3448
3949
|
try {
|
|
3449
|
-
|
|
3950
|
+
log13("accepting space recorded in halo", {
|
|
3450
3951
|
details: assertion
|
|
3451
3952
|
}, {
|
|
3452
|
-
F:
|
|
3453
|
-
L:
|
|
3953
|
+
F: __dxlog_file15,
|
|
3954
|
+
L: 241,
|
|
3454
3955
|
S: this,
|
|
3455
3956
|
C: (f, a) => f(...a)
|
|
3456
3957
|
});
|
|
@@ -3459,9 +3960,9 @@ var ServiceContext = class {
|
|
|
3459
3960
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3460
3961
|
});
|
|
3461
3962
|
} catch (err) {
|
|
3462
|
-
|
|
3463
|
-
F:
|
|
3464
|
-
L:
|
|
3963
|
+
log13.catch(err, void 0, {
|
|
3964
|
+
F: __dxlog_file15,
|
|
3965
|
+
L: 247,
|
|
3465
3966
|
S: this,
|
|
3466
3967
|
C: (f, a) => f(...a)
|
|
3467
3968
|
});
|
|
@@ -3471,12 +3972,22 @@ var ServiceContext = class {
|
|
|
3471
3972
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3472
3973
|
}
|
|
3473
3974
|
};
|
|
3975
|
+
_ts_decorate5([
|
|
3976
|
+
Trace2.span()
|
|
3977
|
+
], ServiceContext.prototype, "open", null);
|
|
3978
|
+
_ts_decorate5([
|
|
3979
|
+
Trace2.span()
|
|
3980
|
+
], ServiceContext.prototype, "_initialize", null);
|
|
3981
|
+
ServiceContext = _ts_decorate5([
|
|
3982
|
+
safeInstanceof("dxos.client-services.ServiceContext"),
|
|
3983
|
+
Trace2.resource()
|
|
3984
|
+
], ServiceContext);
|
|
3474
3985
|
|
|
3475
3986
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
3476
3987
|
import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
|
|
3477
3988
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
3478
|
-
import { log as
|
|
3479
|
-
function
|
|
3989
|
+
import { log as log14, logInfo } from "@dxos/log";
|
|
3990
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
3480
3991
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3481
3992
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3482
3993
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3486,7 +3997,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
3486
3997
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3487
3998
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3488
3999
|
}
|
|
3489
|
-
var
|
|
4000
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
3490
4001
|
var Message;
|
|
3491
4002
|
(function(Message2) {
|
|
3492
4003
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -3508,29 +4019,29 @@ var Lock = class {
|
|
|
3508
4019
|
message: Message.ACQUIRING
|
|
3509
4020
|
});
|
|
3510
4021
|
try {
|
|
3511
|
-
|
|
3512
|
-
F:
|
|
4022
|
+
log14("aquiring lock...", void 0, {
|
|
4023
|
+
F: __dxlog_file16,
|
|
3513
4024
|
L: 42,
|
|
3514
4025
|
S: this,
|
|
3515
4026
|
C: (f, a) => f(...a)
|
|
3516
4027
|
});
|
|
3517
4028
|
await asyncTimeout(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
3518
|
-
|
|
3519
|
-
F:
|
|
4029
|
+
log14("acquired lock", void 0, {
|
|
4030
|
+
F: __dxlog_file16,
|
|
3520
4031
|
L: 44,
|
|
3521
4032
|
S: this,
|
|
3522
4033
|
C: (f, a) => f(...a)
|
|
3523
4034
|
});
|
|
3524
|
-
} catch
|
|
3525
|
-
|
|
3526
|
-
F:
|
|
4035
|
+
} catch {
|
|
4036
|
+
log14("stealing lock...", void 0, {
|
|
4037
|
+
F: __dxlog_file16,
|
|
3527
4038
|
L: 46,
|
|
3528
4039
|
S: this,
|
|
3529
4040
|
C: (f, a) => f(...a)
|
|
3530
4041
|
});
|
|
3531
4042
|
await this._requestLock(true);
|
|
3532
|
-
|
|
3533
|
-
F:
|
|
4043
|
+
log14("stolen lock", void 0, {
|
|
4044
|
+
F: __dxlog_file16,
|
|
3534
4045
|
L: 48,
|
|
3535
4046
|
S: this,
|
|
3536
4047
|
C: (f, a) => f(...a)
|
|
@@ -3546,10 +4057,10 @@ var Lock = class {
|
|
|
3546
4057
|
}
|
|
3547
4058
|
}
|
|
3548
4059
|
async _requestLock(steal = false) {
|
|
3549
|
-
|
|
4060
|
+
log14("requesting lock...", {
|
|
3550
4061
|
steal
|
|
3551
4062
|
}, {
|
|
3552
|
-
F:
|
|
4063
|
+
F: __dxlog_file16,
|
|
3553
4064
|
L: 63,
|
|
3554
4065
|
S: this,
|
|
3555
4066
|
C: (f, a) => f(...a)
|
|
@@ -3558,40 +4069,38 @@ var Lock = class {
|
|
|
3558
4069
|
void navigator.locks.request(this._lockKey, {
|
|
3559
4070
|
steal
|
|
3560
4071
|
}, async () => {
|
|
3561
|
-
|
|
3562
|
-
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
4072
|
+
await this._onAcquire?.();
|
|
3563
4073
|
acquired.wake();
|
|
3564
4074
|
this._releaseTrigger = new Trigger6();
|
|
3565
4075
|
await this._releaseTrigger.wait();
|
|
3566
|
-
|
|
3567
|
-
F:
|
|
4076
|
+
log14("releasing lock...", void 0, {
|
|
4077
|
+
F: __dxlog_file16,
|
|
3568
4078
|
L: 72,
|
|
3569
4079
|
S: this,
|
|
3570
4080
|
C: (f, a) => f(...a)
|
|
3571
4081
|
});
|
|
3572
|
-
await
|
|
3573
|
-
|
|
3574
|
-
F:
|
|
4082
|
+
await this._onRelease?.();
|
|
4083
|
+
log14("released lock", void 0, {
|
|
4084
|
+
F: __dxlog_file16,
|
|
3575
4085
|
L: 74,
|
|
3576
4086
|
S: this,
|
|
3577
4087
|
C: (f, a) => f(...a)
|
|
3578
4088
|
});
|
|
3579
4089
|
}).catch(async () => {
|
|
3580
|
-
|
|
3581
|
-
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
4090
|
+
await this._onRelease?.();
|
|
3582
4091
|
});
|
|
3583
4092
|
await acquired.wait();
|
|
3584
|
-
|
|
4093
|
+
log14("recieved lock", {
|
|
3585
4094
|
steal
|
|
3586
4095
|
}, {
|
|
3587
|
-
F:
|
|
4096
|
+
F: __dxlog_file16,
|
|
3588
4097
|
L: 81,
|
|
3589
4098
|
S: this,
|
|
3590
4099
|
C: (f, a) => f(...a)
|
|
3591
4100
|
});
|
|
3592
4101
|
}
|
|
3593
4102
|
};
|
|
3594
|
-
|
|
4103
|
+
_ts_decorate6([
|
|
3595
4104
|
logInfo
|
|
3596
4105
|
], Lock.prototype, "lockKey", null);
|
|
3597
4106
|
var isLocked = (lockPath) => {
|
|
@@ -3606,7 +4115,7 @@ import { createStorage, StorageType } from "@dxos/random-access-storage";
|
|
|
3606
4115
|
import { isNode } from "@dxos/util";
|
|
3607
4116
|
var StorageDriver = Runtime.Client.Storage.StorageDriver;
|
|
3608
4117
|
var createStorageObjects = (config) => {
|
|
3609
|
-
const { path = isNode() ? DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config
|
|
4118
|
+
const { path = isNode() ? DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config ?? {};
|
|
3610
4119
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
3611
4120
|
throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
3612
4121
|
}
|
|
@@ -3672,19 +4181,21 @@ var ServiceRegistry = class {
|
|
|
3672
4181
|
};
|
|
3673
4182
|
|
|
3674
4183
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3675
|
-
import invariant12 from "tiny-invariant";
|
|
3676
4184
|
import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
|
|
3677
4185
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
3678
|
-
import {
|
|
4186
|
+
import { Context as Context10 } from "@dxos/context";
|
|
4187
|
+
import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
|
|
3679
4188
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4189
|
+
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3680
4190
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3681
|
-
import { log as
|
|
4191
|
+
import { log as log16 } from "@dxos/log";
|
|
3682
4192
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
3683
4193
|
import { ModelFactory } from "@dxos/model-factory";
|
|
3684
4194
|
import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
|
|
3685
|
-
import { trace as
|
|
4195
|
+
import { trace as trace7 } from "@dxos/protocols";
|
|
3686
4196
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
3687
4197
|
import { TextModel } from "@dxos/text-model";
|
|
4198
|
+
import { TRACE_PROCESSOR, trace as Trace3 } from "@dxos/tracing";
|
|
3688
4199
|
|
|
3689
4200
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3690
4201
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
@@ -3700,21 +4211,17 @@ var DevicesServiceImpl = class {
|
|
|
3700
4211
|
queryDevices() {
|
|
3701
4212
|
return new Stream11(({ next }) => {
|
|
3702
4213
|
const update = () => {
|
|
3703
|
-
|
|
3704
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
4214
|
+
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
3705
4215
|
if (!deviceKeys) {
|
|
3706
4216
|
next({
|
|
3707
4217
|
devices: []
|
|
3708
4218
|
});
|
|
3709
4219
|
} else {
|
|
3710
4220
|
next({
|
|
3711
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
|
|
3716
|
-
};
|
|
3717
|
-
})
|
|
4221
|
+
devices: Array.from(deviceKeys.values()).map((key) => ({
|
|
4222
|
+
deviceKey: key,
|
|
4223
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
|
|
4224
|
+
}))
|
|
3718
4225
|
});
|
|
3719
4226
|
}
|
|
3720
4227
|
};
|
|
@@ -3736,22 +4243,23 @@ var DevicesServiceImpl = class {
|
|
|
3736
4243
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
3737
4244
|
import { Event as Event7 } from "@dxos/async";
|
|
3738
4245
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
3739
|
-
import { getContextFromEntry, log as
|
|
4246
|
+
import { getContextFromEntry, log as log15 } from "@dxos/log";
|
|
3740
4247
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
3741
4248
|
import { jsonify, numericalValues, tracer } from "@dxos/util";
|
|
3742
4249
|
var LoggingServiceImpl = class {
|
|
3743
4250
|
constructor() {
|
|
3744
4251
|
this._logs = new Event7();
|
|
4252
|
+
this._started = /* @__PURE__ */ new Date();
|
|
3745
4253
|
this._logProcessor = (_config, entry2) => {
|
|
3746
4254
|
this._logs.emit(entry2);
|
|
3747
4255
|
};
|
|
3748
4256
|
}
|
|
3749
4257
|
async open() {
|
|
3750
|
-
|
|
4258
|
+
log15.runtimeConfig.processors.push(this._logProcessor);
|
|
3751
4259
|
}
|
|
3752
4260
|
async close() {
|
|
3753
|
-
const index =
|
|
3754
|
-
|
|
4261
|
+
const index = log15.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
4262
|
+
log15.runtimeConfig.processors.splice(index, 1);
|
|
3755
4263
|
}
|
|
3756
4264
|
async controlMetrics({ reset, record }) {
|
|
3757
4265
|
if (reset) {
|
|
@@ -3766,28 +4274,33 @@ var LoggingServiceImpl = class {
|
|
|
3766
4274
|
recording: tracer.recording
|
|
3767
4275
|
};
|
|
3768
4276
|
}
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
4277
|
+
/**
|
|
4278
|
+
* @deprecated (Move to diagnostics).
|
|
4279
|
+
*/
|
|
4280
|
+
queryMetrics({ interval = 5e3 }) {
|
|
4281
|
+
const getNumericalValues = (key) => {
|
|
4282
|
+
const events = tracer.get(key) ?? [];
|
|
3773
4283
|
return {
|
|
3774
4284
|
key,
|
|
3775
|
-
stats: numericalValues(
|
|
4285
|
+
stats: numericalValues(events, "duration")
|
|
3776
4286
|
};
|
|
3777
4287
|
};
|
|
3778
4288
|
return new Stream12(({ next }) => {
|
|
3779
4289
|
const update = () => {
|
|
3780
4290
|
const metrics = {
|
|
3781
|
-
timestamp: new Date(),
|
|
4291
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
3782
4292
|
values: [
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
]
|
|
4293
|
+
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4294
|
+
getNumericalValues("dxos.echo.pipeline.data")
|
|
4295
|
+
].filter(Boolean)
|
|
3786
4296
|
};
|
|
3787
|
-
next(
|
|
4297
|
+
next({
|
|
4298
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4299
|
+
metrics
|
|
4300
|
+
});
|
|
3788
4301
|
};
|
|
3789
4302
|
update();
|
|
3790
|
-
const i = setInterval(update, interval);
|
|
4303
|
+
const i = setInterval(update, Math.max(interval, 1e3));
|
|
3791
4304
|
return () => {
|
|
3792
4305
|
clearInterval(i);
|
|
3793
4306
|
};
|
|
@@ -3796,11 +4309,10 @@ var LoggingServiceImpl = class {
|
|
|
3796
4309
|
queryLogs(request) {
|
|
3797
4310
|
return new Stream12(({ ctx, next }) => {
|
|
3798
4311
|
const handler = (entry2) => {
|
|
3799
|
-
var _a, _b, _c, _d, _e;
|
|
3800
4312
|
if (LOG_PROCESSING > 0) {
|
|
3801
4313
|
return;
|
|
3802
4314
|
}
|
|
3803
|
-
if (
|
|
4315
|
+
if (entry2.meta?.F.includes("logging-service") || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
3804
4316
|
return;
|
|
3805
4317
|
}
|
|
3806
4318
|
if (!shouldLog(entry2, request)) {
|
|
@@ -3809,11 +4321,11 @@ var LoggingServiceImpl = class {
|
|
|
3809
4321
|
const record = {
|
|
3810
4322
|
...entry2,
|
|
3811
4323
|
context: jsonify(getContextFromEntry(entry2)),
|
|
3812
|
-
timestamp: new Date(),
|
|
4324
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
3813
4325
|
meta: {
|
|
3814
4326
|
// TODO(dmaretskyi): Fix proto.
|
|
3815
|
-
file:
|
|
3816
|
-
line:
|
|
4327
|
+
file: entry2.meta?.F ?? "",
|
|
4328
|
+
line: entry2.meta?.L ?? 0
|
|
3817
4329
|
}
|
|
3818
4330
|
};
|
|
3819
4331
|
try {
|
|
@@ -3836,15 +4348,11 @@ var matchFilter = (filter, level, path, options) => {
|
|
|
3836
4348
|
}
|
|
3837
4349
|
};
|
|
3838
4350
|
var shouldLog = (entry2, request) => {
|
|
3839
|
-
|
|
3840
|
-
const options = (_a = request.options) != null ? _a : QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4351
|
+
const options = request.options ?? QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
3841
4352
|
if (request.filters === void 0) {
|
|
3842
4353
|
return options === QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
3843
4354
|
} else {
|
|
3844
|
-
return request.filters.some((filter) =>
|
|
3845
|
-
var _a2, _b;
|
|
3846
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
3847
|
-
});
|
|
4355
|
+
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
3848
4356
|
}
|
|
3849
4357
|
};
|
|
3850
4358
|
var LOG_PROCESSING = 0;
|
|
@@ -3883,17 +4391,32 @@ var NetworkServiceImpl = class {
|
|
|
3883
4391
|
|
|
3884
4392
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3885
4393
|
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
4394
|
+
import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
4395
|
+
import { jsonKeyReplacer } from "@dxos/util";
|
|
3886
4396
|
var SystemServiceImpl = class {
|
|
3887
|
-
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4397
|
+
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3888
4398
|
this._config = config;
|
|
3889
4399
|
this._statusUpdate = statusUpdate;
|
|
3890
4400
|
this._getCurrentStatus = getCurrentStatus;
|
|
4401
|
+
this._getDiagnostics = getDiagnostics;
|
|
3891
4402
|
this._onUpdateStatus = onUpdateStatus;
|
|
3892
4403
|
this._onReset = onReset;
|
|
3893
4404
|
}
|
|
3894
4405
|
async getConfig() {
|
|
3895
|
-
|
|
3896
|
-
|
|
4406
|
+
return this._config?.values ?? {};
|
|
4407
|
+
}
|
|
4408
|
+
/**
|
|
4409
|
+
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
4410
|
+
*/
|
|
4411
|
+
async getDiagnostics({ keys } = {}) {
|
|
4412
|
+
const diagnostics = await this._getDiagnostics();
|
|
4413
|
+
return {
|
|
4414
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4415
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer({
|
|
4416
|
+
truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4417
|
+
humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
4418
|
+
})))
|
|
4419
|
+
};
|
|
3897
4420
|
}
|
|
3898
4421
|
async updateStatus({ status }) {
|
|
3899
4422
|
await this._onUpdateStatus(status);
|
|
@@ -3921,7 +4444,7 @@ var SystemServiceImpl = class {
|
|
|
3921
4444
|
};
|
|
3922
4445
|
|
|
3923
4446
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3924
|
-
function
|
|
4447
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
3925
4448
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3926
4449
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3927
4450
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3931,23 +4454,22 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3931
4454
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3932
4455
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3933
4456
|
}
|
|
3934
|
-
var
|
|
4457
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3935
4458
|
var createDefaultModelFactory = () => {
|
|
3936
|
-
return new ModelFactory().registerModel(
|
|
4459
|
+
return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
|
|
3937
4460
|
};
|
|
3938
|
-
var ClientServicesHost = class {
|
|
4461
|
+
var ClientServicesHost = class ClientServicesHost2 {
|
|
3939
4462
|
constructor({
|
|
3940
4463
|
config,
|
|
3941
4464
|
modelFactory = createDefaultModelFactory(),
|
|
3942
|
-
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3943
4465
|
transportFactory,
|
|
3944
4466
|
signalManager,
|
|
3945
|
-
connectionLog,
|
|
3946
4467
|
storage,
|
|
3947
4468
|
// TODO(wittjosiah): Turn this on by default.
|
|
3948
4469
|
lockKey,
|
|
3949
4470
|
callbacks
|
|
3950
4471
|
} = {}) {
|
|
4472
|
+
this._tracingService = TRACE_PROCESSOR.createTraceSender();
|
|
3951
4473
|
this._statusUpdate = new Event8();
|
|
3952
4474
|
this._opening = false;
|
|
3953
4475
|
this._open = false;
|
|
@@ -3966,7 +4488,7 @@ var ClientServicesHost = class {
|
|
|
3966
4488
|
lockKey,
|
|
3967
4489
|
onAcquire: () => {
|
|
3968
4490
|
if (!this._opening) {
|
|
3969
|
-
void this.open();
|
|
4491
|
+
void this.open(new Context10());
|
|
3970
4492
|
}
|
|
3971
4493
|
},
|
|
3972
4494
|
onRelease: () => this.close()
|
|
@@ -3976,12 +4498,14 @@ var ClientServicesHost = class {
|
|
|
3976
4498
|
config: this._config,
|
|
3977
4499
|
statusUpdate: this._statusUpdate,
|
|
3978
4500
|
getCurrentStatus: () => this.isOpen ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
|
|
4501
|
+
getDiagnostics: () => {
|
|
4502
|
+
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4503
|
+
},
|
|
3979
4504
|
onUpdateStatus: async (status) => {
|
|
3980
|
-
var _a, _b;
|
|
3981
4505
|
if (!this.isOpen && status === SystemStatus.ACTIVE) {
|
|
3982
|
-
await
|
|
4506
|
+
await this._resourceLock?.acquire();
|
|
3983
4507
|
} else if (this.isOpen && status === SystemStatus.INACTIVE) {
|
|
3984
|
-
await
|
|
4508
|
+
await this._resourceLock?.release();
|
|
3985
4509
|
}
|
|
3986
4510
|
},
|
|
3987
4511
|
onReset: async () => {
|
|
@@ -3990,12 +4514,19 @@ var ClientServicesHost = class {
|
|
|
3990
4514
|
});
|
|
3991
4515
|
this._loggingService = new LoggingServiceImpl();
|
|
3992
4516
|
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
3993
|
-
SystemService: this._systemService
|
|
4517
|
+
SystemService: this._systemService,
|
|
4518
|
+
TracingService: this._tracingService
|
|
3994
4519
|
});
|
|
3995
4520
|
}
|
|
3996
4521
|
get isOpen() {
|
|
3997
4522
|
return this._open;
|
|
3998
4523
|
}
|
|
4524
|
+
get config() {
|
|
4525
|
+
return this._config;
|
|
4526
|
+
}
|
|
4527
|
+
get context() {
|
|
4528
|
+
return this._serviceContext;
|
|
4529
|
+
}
|
|
3999
4530
|
get serviceRegistry() {
|
|
4000
4531
|
return this._serviceRegistry;
|
|
4001
4532
|
}
|
|
@@ -4011,54 +4542,120 @@ var ClientServicesHost = class {
|
|
|
4011
4542
|
* Can only be called once.
|
|
4012
4543
|
*/
|
|
4013
4544
|
initialize({ config, ...options }) {
|
|
4014
|
-
|
|
4015
|
-
|
|
4545
|
+
invariant13(!this._open, "service host is open", {
|
|
4546
|
+
F: __dxlog_file17,
|
|
4547
|
+
L: 181,
|
|
4548
|
+
S: this,
|
|
4549
|
+
A: [
|
|
4550
|
+
"!this._open",
|
|
4551
|
+
"'service host is open'"
|
|
4552
|
+
]
|
|
4553
|
+
});
|
|
4554
|
+
log16("initializing...", void 0, {
|
|
4555
|
+
F: __dxlog_file17,
|
|
4556
|
+
L: 182,
|
|
4557
|
+
S: this,
|
|
4558
|
+
C: (f, a) => f(...a)
|
|
4559
|
+
});
|
|
4016
4560
|
if (config) {
|
|
4017
|
-
|
|
4561
|
+
invariant13(!this._config, "config already set", {
|
|
4562
|
+
F: __dxlog_file17,
|
|
4563
|
+
L: 185,
|
|
4564
|
+
S: this,
|
|
4565
|
+
A: [
|
|
4566
|
+
"!this._config",
|
|
4567
|
+
"'config already set'"
|
|
4568
|
+
]
|
|
4569
|
+
});
|
|
4018
4570
|
this._config = config;
|
|
4019
4571
|
if (!this._storage) {
|
|
4020
4572
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
4021
4573
|
}
|
|
4022
4574
|
}
|
|
4023
4575
|
const { connectionLog = true, transportFactory = createWebRTCTransportFactory({
|
|
4024
|
-
iceServers:
|
|
4025
|
-
}), signalManager = new WebsocketSignalManager(
|
|
4576
|
+
iceServers: this._config?.get("runtime.services.ice")
|
|
4577
|
+
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4026
4578
|
this._signalManager = signalManager;
|
|
4027
|
-
|
|
4579
|
+
invariant13(!this._networkManager, "network manager already set", {
|
|
4580
|
+
F: __dxlog_file17,
|
|
4581
|
+
L: 201,
|
|
4582
|
+
S: this,
|
|
4583
|
+
A: [
|
|
4584
|
+
"!this._networkManager",
|
|
4585
|
+
"'network manager already set'"
|
|
4586
|
+
]
|
|
4587
|
+
});
|
|
4028
4588
|
this._networkManager = new NetworkManager({
|
|
4029
4589
|
log: connectionLog,
|
|
4030
4590
|
transportFactory,
|
|
4031
4591
|
signalManager
|
|
4032
4592
|
});
|
|
4593
|
+
log16("initialized", void 0, {
|
|
4594
|
+
F: __dxlog_file17,
|
|
4595
|
+
L: 208,
|
|
4596
|
+
S: this,
|
|
4597
|
+
C: (f, a) => f(...a)
|
|
4598
|
+
});
|
|
4033
4599
|
}
|
|
4034
|
-
async open() {
|
|
4035
|
-
var _a, _b, _c;
|
|
4600
|
+
async open(ctx) {
|
|
4036
4601
|
if (this._open) {
|
|
4037
4602
|
return;
|
|
4038
4603
|
}
|
|
4039
4604
|
const traceId = PublicKey10.random().toHex();
|
|
4040
|
-
|
|
4605
|
+
log16.trace("dxos.client-services.host.open", trace7.begin({
|
|
4041
4606
|
id: traceId
|
|
4042
4607
|
}), {
|
|
4043
|
-
F:
|
|
4044
|
-
L:
|
|
4608
|
+
F: __dxlog_file17,
|
|
4609
|
+
L: 219,
|
|
4045
4610
|
S: this,
|
|
4046
4611
|
C: (f, a) => f(...a)
|
|
4047
4612
|
});
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4613
|
+
invariant13(this._config, "config not set", {
|
|
4614
|
+
F: __dxlog_file17,
|
|
4615
|
+
L: 221,
|
|
4616
|
+
S: this,
|
|
4617
|
+
A: [
|
|
4618
|
+
"this._config",
|
|
4619
|
+
"'config not set'"
|
|
4620
|
+
]
|
|
4621
|
+
});
|
|
4622
|
+
invariant13(this._storage, "storage not set", {
|
|
4623
|
+
F: __dxlog_file17,
|
|
4624
|
+
L: 222,
|
|
4625
|
+
S: this,
|
|
4626
|
+
A: [
|
|
4627
|
+
"this._storage",
|
|
4628
|
+
"'storage not set'"
|
|
4629
|
+
]
|
|
4630
|
+
});
|
|
4631
|
+
invariant13(this._signalManager, "signal manager not set", {
|
|
4632
|
+
F: __dxlog_file17,
|
|
4633
|
+
L: 223,
|
|
4634
|
+
S: this,
|
|
4635
|
+
A: [
|
|
4636
|
+
"this._signalManager",
|
|
4637
|
+
"'signal manager not set'"
|
|
4638
|
+
]
|
|
4639
|
+
});
|
|
4640
|
+
invariant13(this._networkManager, "network manager not set", {
|
|
4641
|
+
F: __dxlog_file17,
|
|
4642
|
+
L: 224,
|
|
4643
|
+
S: this,
|
|
4644
|
+
A: [
|
|
4645
|
+
"this._networkManager",
|
|
4646
|
+
"'network manager not set'"
|
|
4647
|
+
]
|
|
4648
|
+
});
|
|
4052
4649
|
this._opening = true;
|
|
4053
|
-
|
|
4054
|
-
lockKey:
|
|
4650
|
+
log16("opening...", {
|
|
4651
|
+
lockKey: this._resourceLock?.lockKey
|
|
4055
4652
|
}, {
|
|
4056
|
-
F:
|
|
4057
|
-
L:
|
|
4653
|
+
F: __dxlog_file17,
|
|
4654
|
+
L: 227,
|
|
4058
4655
|
S: this,
|
|
4059
4656
|
C: (f, a) => f(...a)
|
|
4060
4657
|
});
|
|
4061
|
-
await
|
|
4658
|
+
await this._resourceLock?.acquire();
|
|
4062
4659
|
await this._loggingService.open();
|
|
4063
4660
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4064
4661
|
this._serviceRegistry.setServices({
|
|
@@ -4073,6 +4670,7 @@ var ClientServicesHost = class {
|
|
|
4073
4670
|
DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4074
4671
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
4075
4672
|
LoggingService: this._loggingService,
|
|
4673
|
+
TracingService: this._tracingService,
|
|
4076
4674
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4077
4675
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
4078
4676
|
events: new DevtoolsHostEvents(),
|
|
@@ -4080,39 +4678,38 @@ var ClientServicesHost = class {
|
|
|
4080
4678
|
context: this._serviceContext
|
|
4081
4679
|
})
|
|
4082
4680
|
});
|
|
4083
|
-
await this._serviceContext.open();
|
|
4681
|
+
await this._serviceContext.open(ctx);
|
|
4084
4682
|
this._opening = false;
|
|
4085
4683
|
this._open = true;
|
|
4086
4684
|
this._statusUpdate.emit();
|
|
4087
|
-
const deviceKey =
|
|
4088
|
-
|
|
4685
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4686
|
+
log16("opened", {
|
|
4089
4687
|
deviceKey
|
|
4090
4688
|
}, {
|
|
4091
|
-
F:
|
|
4092
|
-
L:
|
|
4689
|
+
F: __dxlog_file17,
|
|
4690
|
+
L: 280,
|
|
4093
4691
|
S: this,
|
|
4094
4692
|
C: (f, a) => f(...a)
|
|
4095
4693
|
});
|
|
4096
|
-
|
|
4694
|
+
log16.trace("dxos.client-services.host.open", trace7.end({
|
|
4097
4695
|
id: traceId
|
|
4098
4696
|
}), {
|
|
4099
|
-
F:
|
|
4100
|
-
L:
|
|
4697
|
+
F: __dxlog_file17,
|
|
4698
|
+
L: 281,
|
|
4101
4699
|
S: this,
|
|
4102
4700
|
C: (f, a) => f(...a)
|
|
4103
4701
|
});
|
|
4104
4702
|
}
|
|
4105
4703
|
async close() {
|
|
4106
|
-
var _a;
|
|
4107
4704
|
if (!this._open) {
|
|
4108
4705
|
return;
|
|
4109
4706
|
}
|
|
4110
|
-
const deviceKey =
|
|
4111
|
-
|
|
4707
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4708
|
+
log16("closing...", {
|
|
4112
4709
|
deviceKey
|
|
4113
4710
|
}, {
|
|
4114
|
-
F:
|
|
4115
|
-
L:
|
|
4711
|
+
F: __dxlog_file17,
|
|
4712
|
+
L: 292,
|
|
4116
4713
|
S: this,
|
|
4117
4714
|
C: (f, a) => f(...a)
|
|
4118
4715
|
});
|
|
@@ -4123,57 +4720,67 @@ var ClientServicesHost = class {
|
|
|
4123
4720
|
await this._serviceContext.close();
|
|
4124
4721
|
this._open = false;
|
|
4125
4722
|
this._statusUpdate.emit();
|
|
4126
|
-
|
|
4723
|
+
log16("closed", {
|
|
4127
4724
|
deviceKey
|
|
4128
4725
|
}, {
|
|
4129
|
-
F:
|
|
4130
|
-
L:
|
|
4726
|
+
F: __dxlog_file17,
|
|
4727
|
+
L: 298,
|
|
4131
4728
|
S: this,
|
|
4132
4729
|
C: (f, a) => f(...a)
|
|
4133
4730
|
});
|
|
4134
4731
|
}
|
|
4135
4732
|
async reset() {
|
|
4136
|
-
var _a, _b, _c;
|
|
4137
4733
|
const traceId = PublicKey10.random().toHex();
|
|
4138
|
-
|
|
4734
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace7.begin({
|
|
4139
4735
|
id: traceId
|
|
4140
4736
|
}), {
|
|
4141
|
-
F:
|
|
4142
|
-
L:
|
|
4737
|
+
F: __dxlog_file17,
|
|
4738
|
+
L: 303,
|
|
4143
4739
|
S: this,
|
|
4144
4740
|
C: (f, a) => f(...a)
|
|
4145
4741
|
});
|
|
4146
|
-
|
|
4147
|
-
F:
|
|
4148
|
-
L:
|
|
4742
|
+
log16("resetting...", void 0, {
|
|
4743
|
+
F: __dxlog_file17,
|
|
4744
|
+
L: 305,
|
|
4149
4745
|
S: this,
|
|
4150
4746
|
C: (f, a) => f(...a)
|
|
4151
4747
|
});
|
|
4152
|
-
await
|
|
4748
|
+
await this._serviceContext?.close();
|
|
4153
4749
|
await this._storage.reset();
|
|
4154
|
-
|
|
4155
|
-
F:
|
|
4156
|
-
L:
|
|
4750
|
+
log16("reset", void 0, {
|
|
4751
|
+
F: __dxlog_file17,
|
|
4752
|
+
L: 308,
|
|
4157
4753
|
S: this,
|
|
4158
4754
|
C: (f, a) => f(...a)
|
|
4159
4755
|
});
|
|
4160
|
-
|
|
4756
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace7.end({
|
|
4161
4757
|
id: traceId
|
|
4162
4758
|
}), {
|
|
4163
|
-
F:
|
|
4164
|
-
L:
|
|
4759
|
+
F: __dxlog_file17,
|
|
4760
|
+
L: 309,
|
|
4165
4761
|
S: this,
|
|
4166
4762
|
C: (f, a) => f(...a)
|
|
4167
4763
|
});
|
|
4168
|
-
await
|
|
4764
|
+
await this._callbacks?.onReset?.();
|
|
4169
4765
|
}
|
|
4170
4766
|
};
|
|
4171
|
-
|
|
4172
|
-
|
|
4767
|
+
_ts_decorate7([
|
|
4768
|
+
Trace3.info()
|
|
4769
|
+
], ClientServicesHost.prototype, "_opening", void 0);
|
|
4770
|
+
_ts_decorate7([
|
|
4771
|
+
Trace3.info()
|
|
4772
|
+
], ClientServicesHost.prototype, "_open", void 0);
|
|
4773
|
+
_ts_decorate7([
|
|
4774
|
+
synchronized3,
|
|
4775
|
+
Trace3.span()
|
|
4173
4776
|
], ClientServicesHost.prototype, "open", null);
|
|
4174
|
-
|
|
4175
|
-
synchronized3
|
|
4777
|
+
_ts_decorate7([
|
|
4778
|
+
synchronized3,
|
|
4779
|
+
Trace3.span()
|
|
4176
4780
|
], ClientServicesHost.prototype, "close", null);
|
|
4781
|
+
ClientServicesHost = _ts_decorate7([
|
|
4782
|
+
Trace3.resource()
|
|
4783
|
+
], ClientServicesHost);
|
|
4177
4784
|
|
|
4178
4785
|
export {
|
|
4179
4786
|
subscribeToFeeds,
|
|
@@ -4196,6 +4803,7 @@ export {
|
|
|
4196
4803
|
InvitationsServiceImpl,
|
|
4197
4804
|
SpaceInvitationProtocol,
|
|
4198
4805
|
ClientRpcServer,
|
|
4806
|
+
createDiagnostics,
|
|
4199
4807
|
DataSpace,
|
|
4200
4808
|
DataSpaceManager,
|
|
4201
4809
|
SpacesServiceImpl,
|
|
@@ -4207,4 +4815,4 @@ export {
|
|
|
4207
4815
|
createDefaultModelFactory,
|
|
4208
4816
|
ClientServicesHost
|
|
4209
4817
|
};
|
|
4210
|
-
//# sourceMappingURL=chunk-
|
|
4818
|
+
//# sourceMappingURL=chunk-Y4AYNWBO.mjs.map
|