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