@dxos/client-services 0.1.56-main.e47dfd1 → 0.1.56-main.e79d64a
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-T32PP5QD.mjs} +1284 -625
- package/dist/lib/browser/chunk-T32PP5QD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +70 -54
- 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 +1439 -767
- 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 +1590 -936
- 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 +3 -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 +212 -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 +21 -15
- package/src/packlets/services/service-host.test.ts +12 -11
- 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.test.ts +80 -22
- package/src/packlets/spaces/data-space-manager.ts +7 -4
- 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 +19 -13
- 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 +3 -2
- 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
package/dist/lib/node/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// packages/sdk/client-services/src/index.ts
|
|
@@ -55,6 +45,7 @@ __export(src_exports, {
|
|
|
55
45
|
WorkerSession: () => WorkerSession,
|
|
56
46
|
createAuthProvider: () => createAuthProvider,
|
|
57
47
|
createDefaultModelFactory: () => createDefaultModelFactory,
|
|
48
|
+
createDiagnostics: () => createDiagnostics,
|
|
58
49
|
createStorageObjects: () => createStorageObjects,
|
|
59
50
|
getNetworkPeers: () => getNetworkPeers,
|
|
60
51
|
isLocked: () => isLocked,
|
|
@@ -84,7 +75,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
84
75
|
const feedMap = new import_util.ComplexMap(import_keys.PublicKey.hash);
|
|
85
76
|
const update = () => {
|
|
86
77
|
const { feeds } = feedStore;
|
|
87
|
-
feeds.filter((feed) => !
|
|
78
|
+
feeds.filter((feed) => !feedKeys?.length || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
|
|
88
79
|
if (!feedMap.has(feed.key)) {
|
|
89
80
|
feedMap.set(feed.key, feed);
|
|
90
81
|
feed.on("close", update);
|
|
@@ -92,15 +83,12 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
92
83
|
}
|
|
93
84
|
});
|
|
94
85
|
next({
|
|
95
|
-
feeds: Array.from(feedMap.values()).map((feed) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
downloaded: (_b = (_a = feed.core.bitfield) == null ? void 0 : _a.data.toBuffer()) != null ? _b : new Uint8Array()
|
|
102
|
-
};
|
|
103
|
-
})
|
|
86
|
+
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
87
|
+
feedKey: feed.key,
|
|
88
|
+
length: feed.properties.length,
|
|
89
|
+
bytes: feed.core.byteLength,
|
|
90
|
+
downloaded: feed.core.bitfield?.data.toBuffer() ?? new Uint8Array()
|
|
91
|
+
}))
|
|
104
92
|
});
|
|
105
93
|
};
|
|
106
94
|
subscriptions.add(feedStore.feedOpened.on(update));
|
|
@@ -200,13 +188,13 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf4.Stream
|
|
|
200
188
|
recipient: message.recipient.asUint8Array(),
|
|
201
189
|
payload: message.payload
|
|
202
190
|
},
|
|
203
|
-
receivedAt: new Date()
|
|
191
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
204
192
|
});
|
|
205
193
|
});
|
|
206
194
|
signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
207
195
|
next({
|
|
208
196
|
swarmEvent: swarmEvent.swarmEvent,
|
|
209
|
-
receivedAt: new Date()
|
|
197
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
210
198
|
});
|
|
211
199
|
});
|
|
212
200
|
return () => {
|
|
@@ -217,13 +205,10 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
|
|
|
217
205
|
const update = () => {
|
|
218
206
|
try {
|
|
219
207
|
const topics = networkManager.topics;
|
|
220
|
-
const labeledTopics = topics.map((topic) => {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
label: (_b = (_a = networkManager.getSwarm(topic)) == null ? void 0 : _a.label) != null ? _b : topic.toHex()
|
|
225
|
-
};
|
|
226
|
-
});
|
|
208
|
+
const labeledTopics = topics.map((topic) => ({
|
|
209
|
+
topic,
|
|
210
|
+
label: networkManager.getSwarm(topic)?.label ?? topic.toHex()
|
|
211
|
+
}));
|
|
227
212
|
next({
|
|
228
213
|
topics: labeledTopics
|
|
229
214
|
});
|
|
@@ -235,17 +220,15 @@ var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf
|
|
|
235
220
|
update();
|
|
236
221
|
});
|
|
237
222
|
var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf4.Stream(({ next }) => {
|
|
238
|
-
var _a;
|
|
239
223
|
const update = () => {
|
|
240
|
-
|
|
241
|
-
const info = (_a2 = networkManager.connectionLog) == null ? void 0 : _a2.swarms;
|
|
224
|
+
const info = networkManager.connectionLog?.swarms;
|
|
242
225
|
if (info) {
|
|
243
226
|
next({
|
|
244
227
|
data: info
|
|
245
228
|
});
|
|
246
229
|
}
|
|
247
230
|
};
|
|
248
|
-
|
|
231
|
+
networkManager.connectionLog?.update.on(update);
|
|
249
232
|
update();
|
|
250
233
|
});
|
|
251
234
|
var getNetworkPeers = ({ networkManager }, request) => {
|
|
@@ -254,7 +237,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
|
|
|
254
237
|
}
|
|
255
238
|
const map = networkManager.getSwarmMap(import_keys2.PublicKey.from(request.topic));
|
|
256
239
|
return {
|
|
257
|
-
peers: map
|
|
240
|
+
peers: map?.peers.map((peer) => ({
|
|
258
241
|
...peer,
|
|
259
242
|
connections: peer.connections.map((connection) => connection.asUint8Array())
|
|
260
243
|
}))
|
|
@@ -270,14 +253,14 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
270
253
|
const spaces = [
|
|
271
254
|
...context.spaceManager.spaces.values()
|
|
272
255
|
];
|
|
273
|
-
const filteredSpaces = spaces.filter((space) => !
|
|
256
|
+
const filteredSpaces = spaces.filter((space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
|
|
274
257
|
next({
|
|
275
258
|
spaces: filteredSpaces.map((space) => {
|
|
276
259
|
const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata2) => spaceMetadata2.key.equals(space.key));
|
|
277
260
|
return {
|
|
278
261
|
key: space.key,
|
|
279
262
|
isOpen: space.isOpen,
|
|
280
|
-
timeframe: spaceMetadata
|
|
263
|
+
timeframe: spaceMetadata?.dataTimeframe,
|
|
281
264
|
genesisFeed: space.genesisFeedKey,
|
|
282
265
|
controlFeed: space.controlFeedKey,
|
|
283
266
|
dataFeed: space.dataFeedKey
|
|
@@ -291,7 +274,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
291
274
|
await update();
|
|
292
275
|
});
|
|
293
276
|
return () => {
|
|
294
|
-
unsubscribe
|
|
277
|
+
unsubscribe?.();
|
|
295
278
|
clearTimeout(timeout);
|
|
296
279
|
};
|
|
297
280
|
});
|
|
@@ -322,16 +305,15 @@ var DevtoolsServiceImpl = class {
|
|
|
322
305
|
};
|
|
323
306
|
}
|
|
324
307
|
async getStorageInfo() {
|
|
325
|
-
|
|
326
|
-
const storageUsage = (_c = await ((_b = (_a = this.params.context.storage).getDiskInfo) == null ? void 0 : _b.call(_a))) != null ? _c : {
|
|
308
|
+
const storageUsage = await this.params.context.storage.getDiskInfo?.() ?? {
|
|
327
309
|
used: 0
|
|
328
310
|
};
|
|
329
311
|
const navigatorInfo = typeof navigator === "object" ? await navigator.storage.estimate() : void 0;
|
|
330
312
|
return {
|
|
331
313
|
type: this.params.context.storage.type,
|
|
332
314
|
storageUsage: storageUsage.used,
|
|
333
|
-
originUsage:
|
|
334
|
-
usageQuota:
|
|
315
|
+
originUsage: navigatorInfo?.usage ?? 0,
|
|
316
|
+
usageQuota: navigatorInfo?.quota ?? 0
|
|
335
317
|
};
|
|
336
318
|
}
|
|
337
319
|
async getBlobs() {
|
|
@@ -517,7 +499,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
517
499
|
return await trigger.wait({
|
|
518
500
|
timeout: this._params.authTimeout
|
|
519
501
|
});
|
|
520
|
-
} catch
|
|
502
|
+
} catch {
|
|
521
503
|
return false;
|
|
522
504
|
} finally {
|
|
523
505
|
clear();
|
|
@@ -531,16 +513,27 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
531
513
|
};
|
|
532
514
|
|
|
533
515
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
534
|
-
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
535
516
|
var import_async5 = require("@dxos/async");
|
|
536
517
|
var import_client_protocol = require("@dxos/client-protocol");
|
|
537
518
|
var import_credentials2 = require("@dxos/credentials");
|
|
538
519
|
var import_debug = require("@dxos/debug");
|
|
539
520
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
521
|
+
var import_invariant = require("@dxos/invariant");
|
|
540
522
|
var import_log2 = require("@dxos/log");
|
|
541
523
|
var import_credentials3 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
524
|
+
var import_tracing = require("@dxos/tracing");
|
|
525
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
526
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
527
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
528
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
529
|
+
else
|
|
530
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
531
|
+
if (d = decorators[i])
|
|
532
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
533
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
534
|
+
}
|
|
542
535
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
543
|
-
var Identity = class {
|
|
536
|
+
var Identity = class Identity2 {
|
|
544
537
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
545
538
|
this.stateUpdate = new import_async5.Event();
|
|
546
539
|
this.space = space;
|
|
@@ -566,12 +559,12 @@ var Identity = class {
|
|
|
566
559
|
get authorizedDeviceKeys() {
|
|
567
560
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
568
561
|
}
|
|
569
|
-
async open() {
|
|
562
|
+
async open(ctx) {
|
|
570
563
|
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
571
564
|
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
572
|
-
await this.space.open();
|
|
565
|
+
await this.space.open(ctx);
|
|
573
566
|
}
|
|
574
|
-
async close() {
|
|
567
|
+
async close(ctx) {
|
|
575
568
|
await this.authVerifier.close();
|
|
576
569
|
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
577
570
|
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
@@ -602,11 +595,10 @@ var Identity = class {
|
|
|
602
595
|
return this._deviceStateMachine.deviceCredentialChain;
|
|
603
596
|
}
|
|
604
597
|
getAdmissionCredentials() {
|
|
605
|
-
var _a, _b;
|
|
606
598
|
return {
|
|
607
599
|
deviceKey: this.deviceKey,
|
|
608
|
-
controlFeedKey:
|
|
609
|
-
dataFeedKey:
|
|
600
|
+
controlFeedKey: this.space.controlFeedKey ?? (0, import_debug.failUndefined)(),
|
|
601
|
+
dataFeedKey: this.space.dataFeedKey ?? (0, import_debug.failUndefined)()
|
|
610
602
|
};
|
|
611
603
|
}
|
|
612
604
|
/**
|
|
@@ -614,7 +606,15 @@ var Identity = class {
|
|
|
614
606
|
* Requires identity to be ready.
|
|
615
607
|
*/
|
|
616
608
|
getIdentityCredentialSigner() {
|
|
617
|
-
(0,
|
|
609
|
+
(0, import_invariant.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
610
|
+
F: __dxlog_file2,
|
|
611
|
+
L: 139,
|
|
612
|
+
S: this,
|
|
613
|
+
A: [
|
|
614
|
+
"this._deviceStateMachine.deviceCredentialChain",
|
|
615
|
+
"'Device credential chain is not ready.'"
|
|
616
|
+
]
|
|
617
|
+
});
|
|
618
618
|
return (0, import_credentials2.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
619
619
|
}
|
|
620
620
|
/**
|
|
@@ -632,7 +632,7 @@ var Identity = class {
|
|
|
632
632
|
dataFeedKey
|
|
633
633
|
}, {
|
|
634
634
|
F: __dxlog_file2,
|
|
635
|
-
L:
|
|
635
|
+
L: 155,
|
|
636
636
|
S: this,
|
|
637
637
|
C: (f, a) => f(...a)
|
|
638
638
|
});
|
|
@@ -673,18 +673,40 @@ var Identity = class {
|
|
|
673
673
|
})));
|
|
674
674
|
}
|
|
675
675
|
};
|
|
676
|
+
_ts_decorate([
|
|
677
|
+
import_tracing.trace.span()
|
|
678
|
+
], Identity.prototype, "open", null);
|
|
679
|
+
_ts_decorate([
|
|
680
|
+
import_tracing.trace.span()
|
|
681
|
+
], Identity.prototype, "close", null);
|
|
682
|
+
Identity = _ts_decorate([
|
|
683
|
+
import_tracing.trace.resource()
|
|
684
|
+
], Identity);
|
|
676
685
|
|
|
677
686
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
678
|
-
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
679
687
|
var import_async6 = require("@dxos/async");
|
|
688
|
+
var import_context3 = require("@dxos/context");
|
|
680
689
|
var import_credentials4 = require("@dxos/credentials");
|
|
690
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
681
691
|
var import_keys4 = require("@dxos/keys");
|
|
682
692
|
var import_log3 = require("@dxos/log");
|
|
683
693
|
var import_protocols2 = require("@dxos/protocols");
|
|
684
694
|
var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
695
|
+
var import_timeframe = require("@dxos/timeframe");
|
|
696
|
+
var import_tracing2 = require("@dxos/tracing");
|
|
685
697
|
var import_util2 = require("@dxos/util");
|
|
698
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
699
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
700
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
701
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
702
|
+
else
|
|
703
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
704
|
+
if (d = decorators[i])
|
|
705
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
706
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
707
|
+
}
|
|
686
708
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
687
|
-
var IdentityManager = class {
|
|
709
|
+
var IdentityManager = class IdentityManager2 {
|
|
688
710
|
// TODO(burdon): IdentityManagerParams.
|
|
689
711
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
690
712
|
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
@@ -697,14 +719,13 @@ var IdentityManager = class {
|
|
|
697
719
|
get identity() {
|
|
698
720
|
return this._identity;
|
|
699
721
|
}
|
|
700
|
-
async open() {
|
|
701
|
-
var _a;
|
|
722
|
+
async open(ctx) {
|
|
702
723
|
const traceId = import_keys4.PublicKey.random().toHex();
|
|
703
724
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
|
|
704
725
|
id: traceId
|
|
705
726
|
}), {
|
|
706
727
|
F: __dxlog_file3,
|
|
707
|
-
L:
|
|
728
|
+
L: 73,
|
|
708
729
|
S: this,
|
|
709
730
|
C: (f, a) => f(...a)
|
|
710
731
|
});
|
|
@@ -714,20 +735,20 @@ var IdentityManager = class {
|
|
|
714
735
|
identityRecord
|
|
715
736
|
}, {
|
|
716
737
|
F: __dxlog_file3,
|
|
717
|
-
L:
|
|
738
|
+
L: 77,
|
|
718
739
|
S: this,
|
|
719
740
|
C: (f, a) => f(...a)
|
|
720
741
|
});
|
|
721
742
|
if (identityRecord) {
|
|
722
743
|
this._identity = await this._constructIdentity(identityRecord);
|
|
723
|
-
await this._identity.open();
|
|
744
|
+
await this._identity.open(ctx);
|
|
724
745
|
await this._identity.ready();
|
|
725
746
|
import_log3.log.trace("dxos.halo.identity", {
|
|
726
747
|
identityKey: identityRecord.identityKey,
|
|
727
|
-
displayName:
|
|
748
|
+
displayName: this._identity.profileDocument?.displayName
|
|
728
749
|
}, {
|
|
729
750
|
F: __dxlog_file3,
|
|
730
|
-
L:
|
|
751
|
+
L: 82,
|
|
731
752
|
S: this,
|
|
732
753
|
C: (f, a) => f(...a)
|
|
733
754
|
});
|
|
@@ -737,21 +758,27 @@ var IdentityManager = class {
|
|
|
737
758
|
id: traceId
|
|
738
759
|
}), {
|
|
739
760
|
F: __dxlog_file3,
|
|
740
|
-
L:
|
|
761
|
+
L: 88,
|
|
741
762
|
S: this,
|
|
742
763
|
C: (f, a) => f(...a)
|
|
743
764
|
});
|
|
744
765
|
}
|
|
745
766
|
async close() {
|
|
746
|
-
|
|
747
|
-
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
767
|
+
await this._identity?.close(new import_context3.Context());
|
|
748
768
|
}
|
|
749
769
|
async createIdentity({ displayName } = {}) {
|
|
750
|
-
|
|
751
|
-
|
|
770
|
+
(0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
|
|
771
|
+
F: __dxlog_file3,
|
|
772
|
+
L: 96,
|
|
773
|
+
S: this,
|
|
774
|
+
A: [
|
|
775
|
+
"!this._identity",
|
|
776
|
+
"'Identity already exists.'"
|
|
777
|
+
]
|
|
778
|
+
});
|
|
752
779
|
(0, import_log3.log)("creating identity...", void 0, {
|
|
753
780
|
F: __dxlog_file3,
|
|
754
|
-
L:
|
|
781
|
+
L: 97,
|
|
755
782
|
S: this,
|
|
756
783
|
C: (f, a) => f(...a)
|
|
757
784
|
});
|
|
@@ -767,11 +794,27 @@ var IdentityManager = class {
|
|
|
767
794
|
}
|
|
768
795
|
};
|
|
769
796
|
const identity = await this._constructIdentity(identityRecord);
|
|
770
|
-
await identity.open();
|
|
797
|
+
await identity.open(new import_context3.Context());
|
|
771
798
|
{
|
|
772
799
|
const generator = new import_credentials4.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
773
|
-
(0,
|
|
774
|
-
|
|
800
|
+
(0, import_invariant2.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
801
|
+
F: __dxlog_file3,
|
|
802
|
+
L: 116,
|
|
803
|
+
S: this,
|
|
804
|
+
A: [
|
|
805
|
+
"identityRecord.haloSpace.genesisFeedKey",
|
|
806
|
+
"'Genesis feed key is required.'"
|
|
807
|
+
]
|
|
808
|
+
});
|
|
809
|
+
(0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
810
|
+
F: __dxlog_file3,
|
|
811
|
+
L: 117,
|
|
812
|
+
S: this,
|
|
813
|
+
A: [
|
|
814
|
+
"identityRecord.haloSpace.dataFeedKey",
|
|
815
|
+
"'Data feed key is required.'"
|
|
816
|
+
]
|
|
817
|
+
});
|
|
775
818
|
const credentials = [
|
|
776
819
|
// Space genesis.
|
|
777
820
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
@@ -797,10 +840,10 @@ var IdentityManager = class {
|
|
|
797
840
|
await this._identity.ready();
|
|
798
841
|
import_log3.log.trace("dxos.halo.identity", {
|
|
799
842
|
identityKey: identityRecord.identityKey,
|
|
800
|
-
displayName:
|
|
843
|
+
displayName: this._identity.profileDocument?.displayName
|
|
801
844
|
}, {
|
|
802
845
|
F: __dxlog_file3,
|
|
803
|
-
L:
|
|
846
|
+
L: 152,
|
|
804
847
|
S: this,
|
|
805
848
|
C: (f, a) => f(...a)
|
|
806
849
|
});
|
|
@@ -810,7 +853,7 @@ var IdentityManager = class {
|
|
|
810
853
|
deviceKey: identity.deviceKey
|
|
811
854
|
}, {
|
|
812
855
|
F: __dxlog_file3,
|
|
813
|
-
L:
|
|
856
|
+
L: 158,
|
|
814
857
|
S: this,
|
|
815
858
|
C: (f, a) => f(...a)
|
|
816
859
|
});
|
|
@@ -820,16 +863,23 @@ var IdentityManager = class {
|
|
|
820
863
|
* Accept an existing identity. Expects it's device key to be authorized (now or later).
|
|
821
864
|
*/
|
|
822
865
|
async acceptIdentity(params) {
|
|
823
|
-
var _a;
|
|
824
866
|
(0, import_log3.log)("accepting identity", {
|
|
825
867
|
params
|
|
826
868
|
}, {
|
|
827
869
|
F: __dxlog_file3,
|
|
828
|
-
L:
|
|
870
|
+
L: 166,
|
|
829
871
|
S: this,
|
|
830
872
|
C: (f, a) => f(...a)
|
|
831
873
|
});
|
|
832
|
-
(0,
|
|
874
|
+
(0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
|
|
875
|
+
F: __dxlog_file3,
|
|
876
|
+
L: 167,
|
|
877
|
+
S: this,
|
|
878
|
+
A: [
|
|
879
|
+
"!this._identity",
|
|
880
|
+
"'Identity already exists.'"
|
|
881
|
+
]
|
|
882
|
+
});
|
|
833
883
|
const identityRecord = {
|
|
834
884
|
identityKey: params.identityKey,
|
|
835
885
|
deviceKey: params.deviceKey,
|
|
@@ -842,16 +892,16 @@ var IdentityManager = class {
|
|
|
842
892
|
}
|
|
843
893
|
};
|
|
844
894
|
const identity = await this._constructIdentity(identityRecord);
|
|
845
|
-
await identity.open();
|
|
895
|
+
await identity.open(new import_context3.Context());
|
|
846
896
|
this._identity = identity;
|
|
847
897
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
848
898
|
await this._identity.ready();
|
|
849
899
|
import_log3.log.trace("dxos.halo.identity", {
|
|
850
900
|
identityKey: identityRecord.identityKey,
|
|
851
|
-
displayName:
|
|
901
|
+
displayName: this._identity.profileDocument?.displayName
|
|
852
902
|
}, {
|
|
853
903
|
F: __dxlog_file3,
|
|
854
|
-
L:
|
|
904
|
+
L: 186,
|
|
855
905
|
S: this,
|
|
856
906
|
C: (f, a) => f(...a)
|
|
857
907
|
});
|
|
@@ -861,27 +911,83 @@ var IdentityManager = class {
|
|
|
861
911
|
deviceKey: identity.deviceKey
|
|
862
912
|
}, {
|
|
863
913
|
F: __dxlog_file3,
|
|
864
|
-
L:
|
|
914
|
+
L: 192,
|
|
865
915
|
S: this,
|
|
866
916
|
C: (f, a) => f(...a)
|
|
867
917
|
});
|
|
868
918
|
return identity;
|
|
869
919
|
}
|
|
920
|
+
/**
|
|
921
|
+
* Update the profile document of an existing identity.
|
|
922
|
+
*/
|
|
923
|
+
async updateProfile(profile) {
|
|
924
|
+
(0, import_invariant2.invariant)(this._identity, "Identity not initialized.", {
|
|
925
|
+
F: __dxlog_file3,
|
|
926
|
+
L: 200,
|
|
927
|
+
S: this,
|
|
928
|
+
A: [
|
|
929
|
+
"this._identity",
|
|
930
|
+
"'Identity not initialized.'"
|
|
931
|
+
]
|
|
932
|
+
});
|
|
933
|
+
const credential = await this._identity.getIdentityCredentialSigner().createCredential({
|
|
934
|
+
subject: this._identity.identityKey,
|
|
935
|
+
assertion: {
|
|
936
|
+
"@type": "dxos.halo.credentials.IdentityProfile",
|
|
937
|
+
profile
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
const receipt = await this._identity.controlPipeline.writer.write({
|
|
941
|
+
credential: {
|
|
942
|
+
credential
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
await this._identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
|
|
946
|
+
[
|
|
947
|
+
receipt.feedKey,
|
|
948
|
+
receipt.seq
|
|
949
|
+
]
|
|
950
|
+
]));
|
|
951
|
+
}
|
|
870
952
|
async _constructIdentity(identityRecord) {
|
|
871
|
-
(0,
|
|
953
|
+
(0, import_invariant2.invariant)(!this._identity, void 0, {
|
|
954
|
+
F: __dxlog_file3,
|
|
955
|
+
L: 214,
|
|
956
|
+
S: this,
|
|
957
|
+
A: [
|
|
958
|
+
"!this._identity",
|
|
959
|
+
""
|
|
960
|
+
]
|
|
961
|
+
});
|
|
872
962
|
(0, import_log3.log)("constructing identity", {
|
|
873
963
|
identityRecord
|
|
874
964
|
}, {
|
|
875
965
|
F: __dxlog_file3,
|
|
876
|
-
L:
|
|
966
|
+
L: 215,
|
|
877
967
|
S: this,
|
|
878
968
|
C: (f, a) => f(...a)
|
|
879
969
|
});
|
|
880
|
-
(0,
|
|
970
|
+
(0, import_invariant2.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
971
|
+
F: __dxlog_file3,
|
|
972
|
+
L: 218,
|
|
973
|
+
S: this,
|
|
974
|
+
A: [
|
|
975
|
+
"identityRecord.haloSpace.controlFeedKey",
|
|
976
|
+
""
|
|
977
|
+
]
|
|
978
|
+
});
|
|
881
979
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
882
980
|
writable: true
|
|
883
981
|
});
|
|
884
|
-
(0,
|
|
982
|
+
(0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
983
|
+
F: __dxlog_file3,
|
|
984
|
+
L: 222,
|
|
985
|
+
S: this,
|
|
986
|
+
A: [
|
|
987
|
+
"identityRecord.haloSpace.dataFeedKey",
|
|
988
|
+
""
|
|
989
|
+
]
|
|
990
|
+
});
|
|
885
991
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
886
992
|
writable: true,
|
|
887
993
|
sparse: true
|
|
@@ -907,7 +1013,7 @@ var IdentityManager = class {
|
|
|
907
1013
|
identityKey: identityRecord.identityKey
|
|
908
1014
|
}, {
|
|
909
1015
|
F: __dxlog_file3,
|
|
910
|
-
L:
|
|
1016
|
+
L: 246,
|
|
911
1017
|
S: this,
|
|
912
1018
|
C: (f, a) => f(...a)
|
|
913
1019
|
});
|
|
@@ -928,7 +1034,7 @@ var IdentityManager = class {
|
|
|
928
1034
|
onAuthFailure: () => {
|
|
929
1035
|
import_log3.log.warn("auth failure", void 0, {
|
|
930
1036
|
F: __dxlog_file3,
|
|
931
|
-
L:
|
|
1037
|
+
L: 265,
|
|
932
1038
|
S: this,
|
|
933
1039
|
C: (f, a) => f(...a)
|
|
934
1040
|
});
|
|
@@ -937,19 +1043,27 @@ var IdentityManager = class {
|
|
|
937
1043
|
});
|
|
938
1044
|
}
|
|
939
1045
|
};
|
|
1046
|
+
_ts_decorate2([
|
|
1047
|
+
import_tracing2.trace.span()
|
|
1048
|
+
], IdentityManager.prototype, "open", null);
|
|
1049
|
+
IdentityManager = _ts_decorate2([
|
|
1050
|
+
import_tracing2.trace.resource()
|
|
1051
|
+
], IdentityManager);
|
|
940
1052
|
|
|
941
1053
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
942
|
-
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
943
1054
|
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
944
1055
|
var import_credentials6 = require("@dxos/credentials");
|
|
945
1056
|
var import_debug2 = require("@dxos/debug");
|
|
1057
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
1058
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
946
1059
|
var IdentityServiceImpl = class {
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
this.
|
|
1060
|
+
constructor(_createIdentity, _identityManager, _keyring) {
|
|
1061
|
+
this._createIdentity = _createIdentity;
|
|
1062
|
+
this._identityManager = _identityManager;
|
|
1063
|
+
this._keyring = _keyring;
|
|
950
1064
|
}
|
|
951
1065
|
async createIdentity(request) {
|
|
952
|
-
await this.
|
|
1066
|
+
await this._createIdentity(request);
|
|
953
1067
|
return this._getIdentity();
|
|
954
1068
|
}
|
|
955
1069
|
async recoverIdentity(request) {
|
|
@@ -961,34 +1075,56 @@ var IdentityServiceImpl = class {
|
|
|
961
1075
|
identity: this._getIdentity()
|
|
962
1076
|
});
|
|
963
1077
|
emitNext();
|
|
964
|
-
return this.
|
|
1078
|
+
return this._identityManager.stateUpdate.on(emitNext);
|
|
965
1079
|
});
|
|
966
1080
|
}
|
|
967
1081
|
_getIdentity() {
|
|
968
|
-
if (!this.
|
|
1082
|
+
if (!this._identityManager.identity) {
|
|
969
1083
|
return void 0;
|
|
970
1084
|
}
|
|
971
1085
|
return {
|
|
972
|
-
identityKey: this.
|
|
973
|
-
spaceKey: this.
|
|
974
|
-
profile: this.
|
|
1086
|
+
identityKey: this._identityManager.identity.identityKey,
|
|
1087
|
+
spaceKey: this._identityManager.identity.space.key,
|
|
1088
|
+
profile: this._identityManager.identity.profileDocument
|
|
975
1089
|
};
|
|
976
1090
|
}
|
|
1091
|
+
async updateProfile(profile) {
|
|
1092
|
+
(0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1093
|
+
F: __dxlog_file4,
|
|
1094
|
+
L: 59,
|
|
1095
|
+
S: this,
|
|
1096
|
+
A: [
|
|
1097
|
+
"this._identityManager.identity",
|
|
1098
|
+
"'Identity not initialized.'"
|
|
1099
|
+
]
|
|
1100
|
+
});
|
|
1101
|
+
await this._identityManager.updateProfile(profile);
|
|
1102
|
+
return this._getIdentity();
|
|
1103
|
+
}
|
|
977
1104
|
async signPresentation({ presentation, nonce }) {
|
|
978
|
-
(0,
|
|
1105
|
+
(0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1106
|
+
F: __dxlog_file4,
|
|
1107
|
+
L: 65,
|
|
1108
|
+
S: this,
|
|
1109
|
+
A: [
|
|
1110
|
+
"this._identityManager.identity",
|
|
1111
|
+
"'Identity not initialized.'"
|
|
1112
|
+
]
|
|
1113
|
+
});
|
|
979
1114
|
return await (0, import_credentials6.signPresentation)({
|
|
980
1115
|
presentation,
|
|
981
|
-
signer: this.
|
|
982
|
-
signerKey: this.
|
|
983
|
-
chain: this.
|
|
1116
|
+
signer: this._keyring,
|
|
1117
|
+
signerKey: this._identityManager.identity.deviceKey,
|
|
1118
|
+
chain: this._identityManager.identity.deviceCredentialChain,
|
|
984
1119
|
nonce
|
|
985
1120
|
});
|
|
986
1121
|
}
|
|
987
1122
|
};
|
|
988
1123
|
|
|
989
1124
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
990
|
-
var
|
|
1125
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
991
1126
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
1127
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
992
1128
|
var DeviceInvitationProtocol = class {
|
|
993
1129
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
994
1130
|
this._keyring = _keyring;
|
|
@@ -1004,7 +1140,15 @@ var DeviceInvitationProtocol = class {
|
|
|
1004
1140
|
};
|
|
1005
1141
|
}
|
|
1006
1142
|
async admit(request) {
|
|
1007
|
-
(0,
|
|
1143
|
+
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1144
|
+
F: __dxlog_file5,
|
|
1145
|
+
L: 31,
|
|
1146
|
+
S: this,
|
|
1147
|
+
A: [
|
|
1148
|
+
"request.device",
|
|
1149
|
+
""
|
|
1150
|
+
]
|
|
1151
|
+
});
|
|
1008
1152
|
const identity = this._getIdentity();
|
|
1009
1153
|
await identity.admitDevice(request.device);
|
|
1010
1154
|
return {
|
|
@@ -1032,9 +1176,25 @@ var DeviceInvitationProtocol = class {
|
|
|
1032
1176
|
};
|
|
1033
1177
|
}
|
|
1034
1178
|
async accept(response, request) {
|
|
1035
|
-
(0,
|
|
1179
|
+
(0, import_invariant4.invariant)(response.device, void 0, {
|
|
1180
|
+
F: __dxlog_file5,
|
|
1181
|
+
L: 64,
|
|
1182
|
+
S: this,
|
|
1183
|
+
A: [
|
|
1184
|
+
"response.device",
|
|
1185
|
+
""
|
|
1186
|
+
]
|
|
1187
|
+
});
|
|
1036
1188
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1037
|
-
(0,
|
|
1189
|
+
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1190
|
+
F: __dxlog_file5,
|
|
1191
|
+
L: 67,
|
|
1192
|
+
S: this,
|
|
1193
|
+
A: [
|
|
1194
|
+
"request.device",
|
|
1195
|
+
""
|
|
1196
|
+
]
|
|
1197
|
+
});
|
|
1038
1198
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
1039
1199
|
await this._acceptIdentity({
|
|
1040
1200
|
identityKey,
|
|
@@ -1052,12 +1212,12 @@ var DeviceInvitationProtocol = class {
|
|
|
1052
1212
|
};
|
|
1053
1213
|
|
|
1054
1214
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1055
|
-
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
1056
1215
|
var import_async8 = require("@dxos/async");
|
|
1057
1216
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
1058
|
-
var
|
|
1217
|
+
var import_context5 = require("@dxos/context");
|
|
1059
1218
|
var import_credentials7 = require("@dxos/credentials");
|
|
1060
1219
|
var import_errors2 = require("@dxos/errors");
|
|
1220
|
+
var import_invariant6 = require("@dxos/invariant");
|
|
1061
1221
|
var import_keys6 = require("@dxos/keys");
|
|
1062
1222
|
var import_log5 = require("@dxos/log");
|
|
1063
1223
|
var import_network_manager = require("@dxos/network-manager");
|
|
@@ -1066,17 +1226,17 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
1066
1226
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
1067
1227
|
|
|
1068
1228
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
1069
|
-
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
1070
1229
|
var import_async7 = require("@dxos/async");
|
|
1071
|
-
var
|
|
1230
|
+
var import_context4 = require("@dxos/context");
|
|
1072
1231
|
var import_errors = require("@dxos/errors");
|
|
1232
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
1073
1233
|
var import_keys5 = require("@dxos/keys");
|
|
1074
1234
|
var import_log4 = require("@dxos/log");
|
|
1075
1235
|
var import_protocols3 = require("@dxos/protocols");
|
|
1076
1236
|
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1077
1237
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
1078
1238
|
var import_teleport = require("@dxos/teleport");
|
|
1079
|
-
var
|
|
1239
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
1080
1240
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1081
1241
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1082
1242
|
var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
@@ -1090,7 +1250,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1090
1250
|
}
|
|
1091
1251
|
});
|
|
1092
1252
|
this._callbacks = _callbacks;
|
|
1093
|
-
this._ctx = new
|
|
1253
|
+
this._ctx = new import_context4.Context();
|
|
1094
1254
|
this._remoteOptionsTrigger = new import_async7.Trigger();
|
|
1095
1255
|
this.invitation = void 0;
|
|
1096
1256
|
this.guestProfile = void 0;
|
|
@@ -1104,7 +1264,15 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1104
1264
|
// Perhaps in the future we will have more complex logic here.
|
|
1105
1265
|
InvitationHostService: {
|
|
1106
1266
|
options: async (options) => {
|
|
1107
|
-
(0,
|
|
1267
|
+
(0, import_invariant5.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1268
|
+
F: __dxlog_file6,
|
|
1269
|
+
L: 88,
|
|
1270
|
+
S: this,
|
|
1271
|
+
A: [
|
|
1272
|
+
"!this._remoteOptions",
|
|
1273
|
+
"'Remote options already set.'"
|
|
1274
|
+
]
|
|
1275
|
+
});
|
|
1108
1276
|
this._remoteOptions = options;
|
|
1109
1277
|
this._remoteOptionsTrigger.wake();
|
|
1110
1278
|
},
|
|
@@ -1114,8 +1282,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1114
1282
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
|
|
1115
1283
|
id: traceId
|
|
1116
1284
|
}), {
|
|
1117
|
-
F:
|
|
1118
|
-
L:
|
|
1285
|
+
F: __dxlog_file6,
|
|
1286
|
+
L: 97,
|
|
1119
1287
|
S: this,
|
|
1120
1288
|
C: (f, a) => f(...a)
|
|
1121
1289
|
});
|
|
@@ -1124,8 +1292,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1124
1292
|
import_log4.log.warn("invitation not found", {
|
|
1125
1293
|
invitationId
|
|
1126
1294
|
}, {
|
|
1127
|
-
F:
|
|
1128
|
-
L:
|
|
1295
|
+
F: __dxlog_file6,
|
|
1296
|
+
L: 101,
|
|
1129
1297
|
S: this,
|
|
1130
1298
|
C: (f, a) => f(...a)
|
|
1131
1299
|
});
|
|
@@ -1138,8 +1306,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1138
1306
|
(0, import_log4.log)("guest introduced itself", {
|
|
1139
1307
|
guestProfile: profile
|
|
1140
1308
|
}, {
|
|
1141
|
-
F:
|
|
1142
|
-
L:
|
|
1309
|
+
F: __dxlog_file6,
|
|
1310
|
+
L: 110,
|
|
1143
1311
|
S: this,
|
|
1144
1312
|
C: (f, a) => f(...a)
|
|
1145
1313
|
});
|
|
@@ -1151,8 +1319,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1151
1319
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
|
|
1152
1320
|
id: traceId
|
|
1153
1321
|
}), {
|
|
1154
|
-
F:
|
|
1155
|
-
L:
|
|
1322
|
+
F: __dxlog_file6,
|
|
1323
|
+
L: 117,
|
|
1156
1324
|
S: this,
|
|
1157
1325
|
C: (f, a) => f(...a)
|
|
1158
1326
|
});
|
|
@@ -1166,26 +1334,34 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1166
1334
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
|
|
1167
1335
|
id: traceId
|
|
1168
1336
|
}), {
|
|
1169
|
-
F:
|
|
1170
|
-
L:
|
|
1337
|
+
F: __dxlog_file6,
|
|
1338
|
+
L: 126,
|
|
1171
1339
|
S: this,
|
|
1172
1340
|
C: (f, a) => f(...a)
|
|
1173
1341
|
});
|
|
1174
1342
|
(0, import_log4.log)("received authentication request", {
|
|
1175
1343
|
authCode: code
|
|
1176
1344
|
}, {
|
|
1177
|
-
F:
|
|
1178
|
-
L:
|
|
1345
|
+
F: __dxlog_file6,
|
|
1346
|
+
L: 127,
|
|
1179
1347
|
S: this,
|
|
1180
1348
|
C: (f, a) => f(...a)
|
|
1181
1349
|
});
|
|
1182
1350
|
let status = import_invitations.AuthenticationResponse.Status.OK;
|
|
1183
|
-
(0,
|
|
1351
|
+
(0, import_invariant5.invariant)(this.invitation, "Invitation is not set.", {
|
|
1352
|
+
F: __dxlog_file6,
|
|
1353
|
+
L: 130,
|
|
1354
|
+
S: this,
|
|
1355
|
+
A: [
|
|
1356
|
+
"this.invitation",
|
|
1357
|
+
"'Invitation is not set.'"
|
|
1358
|
+
]
|
|
1359
|
+
});
|
|
1184
1360
|
switch (this.invitation.authMethod) {
|
|
1185
1361
|
case import_services2.Invitation.AuthMethod.NONE: {
|
|
1186
1362
|
(0, import_log4.log)("authentication not required", void 0, {
|
|
1187
|
-
F:
|
|
1188
|
-
L:
|
|
1363
|
+
F: __dxlog_file6,
|
|
1364
|
+
L: 133,
|
|
1189
1365
|
S: this,
|
|
1190
1366
|
C: (f, a) => f(...a)
|
|
1191
1367
|
});
|
|
@@ -1209,8 +1385,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1209
1385
|
import_log4.log.error("invalid authentication method", {
|
|
1210
1386
|
authMethod: this.invitation.authMethod
|
|
1211
1387
|
}, {
|
|
1212
|
-
F:
|
|
1213
|
-
L:
|
|
1388
|
+
F: __dxlog_file6,
|
|
1389
|
+
L: 151,
|
|
1214
1390
|
S: this,
|
|
1215
1391
|
C: (f, a) => f(...a)
|
|
1216
1392
|
});
|
|
@@ -1224,8 +1400,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1224
1400
|
status
|
|
1225
1401
|
}
|
|
1226
1402
|
}), {
|
|
1227
|
-
F:
|
|
1228
|
-
L:
|
|
1403
|
+
F: __dxlog_file6,
|
|
1404
|
+
L: 157,
|
|
1229
1405
|
S: this,
|
|
1230
1406
|
C: (f, a) => f(...a)
|
|
1231
1407
|
});
|
|
@@ -1238,13 +1414,21 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1238
1414
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
|
|
1239
1415
|
id: traceId
|
|
1240
1416
|
}), {
|
|
1241
|
-
F:
|
|
1242
|
-
L:
|
|
1417
|
+
F: __dxlog_file6,
|
|
1418
|
+
L: 163,
|
|
1243
1419
|
S: this,
|
|
1244
1420
|
C: (f, a) => f(...a)
|
|
1245
1421
|
});
|
|
1246
1422
|
try {
|
|
1247
|
-
(0,
|
|
1423
|
+
(0, import_invariant5.invariant)(this.invitation, "Invitation is not set.", {
|
|
1424
|
+
F: __dxlog_file6,
|
|
1425
|
+
L: 166,
|
|
1426
|
+
S: this,
|
|
1427
|
+
A: [
|
|
1428
|
+
"this.invitation",
|
|
1429
|
+
"'Invitation is not set.'"
|
|
1430
|
+
]
|
|
1431
|
+
});
|
|
1248
1432
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
1249
1433
|
throw new Error("Not authenticated");
|
|
1250
1434
|
}
|
|
@@ -1252,8 +1436,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1252
1436
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
|
|
1253
1437
|
id: traceId
|
|
1254
1438
|
}), {
|
|
1255
|
-
F:
|
|
1256
|
-
L:
|
|
1439
|
+
F: __dxlog_file6,
|
|
1440
|
+
L: 174,
|
|
1257
1441
|
S: this,
|
|
1258
1442
|
C: (f, a) => f(...a)
|
|
1259
1443
|
});
|
|
@@ -1267,16 +1451,15 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1267
1451
|
};
|
|
1268
1452
|
}
|
|
1269
1453
|
async onOpen(context) {
|
|
1270
|
-
var _a;
|
|
1271
1454
|
await super.onOpen(context);
|
|
1272
1455
|
try {
|
|
1273
1456
|
await this.rpc.InvitationHostService.options({
|
|
1274
1457
|
role: import_invitations.Options.Role.HOST
|
|
1275
1458
|
});
|
|
1276
|
-
await (0,
|
|
1459
|
+
await (0, import_context4.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1277
1460
|
timeout: OPTIONS_TIMEOUT
|
|
1278
1461
|
}));
|
|
1279
|
-
if (
|
|
1462
|
+
if (this._remoteOptions?.role !== import_invitations.Options.Role.GUEST) {
|
|
1280
1463
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
1281
1464
|
expected: import_invitations.Options.Role.GUEST,
|
|
1282
1465
|
remoteOptions: this._remoteOptions
|
|
@@ -1302,14 +1485,22 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1302
1485
|
}
|
|
1303
1486
|
});
|
|
1304
1487
|
this._callbacks = _callbacks;
|
|
1305
|
-
this._ctx = new
|
|
1488
|
+
this._ctx = new import_context4.Context();
|
|
1306
1489
|
this._remoteOptionsTrigger = new import_async7.Trigger();
|
|
1307
1490
|
}
|
|
1308
1491
|
async getHandlers() {
|
|
1309
1492
|
return {
|
|
1310
1493
|
InvitationHostService: {
|
|
1311
1494
|
options: async (options) => {
|
|
1312
|
-
(0,
|
|
1495
|
+
(0, import_invariant5.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1496
|
+
F: __dxlog_file6,
|
|
1497
|
+
L: 241,
|
|
1498
|
+
S: this,
|
|
1499
|
+
A: [
|
|
1500
|
+
"!this._remoteOptions",
|
|
1501
|
+
"'Remote options already set.'"
|
|
1502
|
+
]
|
|
1503
|
+
});
|
|
1313
1504
|
this._remoteOptions = options;
|
|
1314
1505
|
this._remoteOptionsTrigger.wake();
|
|
1315
1506
|
},
|
|
@@ -1326,28 +1517,27 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1326
1517
|
};
|
|
1327
1518
|
}
|
|
1328
1519
|
async onOpen(context) {
|
|
1329
|
-
var _a;
|
|
1330
1520
|
await super.onOpen(context);
|
|
1331
1521
|
try {
|
|
1332
1522
|
(0, import_log4.log)("begin options", void 0, {
|
|
1333
|
-
F:
|
|
1334
|
-
L:
|
|
1523
|
+
F: __dxlog_file6,
|
|
1524
|
+
L: 262,
|
|
1335
1525
|
S: this,
|
|
1336
1526
|
C: (f, a) => f(...a)
|
|
1337
1527
|
});
|
|
1338
|
-
await (0,
|
|
1528
|
+
await (0, import_context4.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1339
1529
|
role: import_invitations.Options.Role.GUEST
|
|
1340
1530
|
}));
|
|
1341
|
-
await (0,
|
|
1531
|
+
await (0, import_context4.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1342
1532
|
timeout: OPTIONS_TIMEOUT
|
|
1343
1533
|
}));
|
|
1344
1534
|
(0, import_log4.log)("end options", void 0, {
|
|
1345
|
-
F:
|
|
1346
|
-
L:
|
|
1535
|
+
F: __dxlog_file6,
|
|
1536
|
+
L: 265,
|
|
1347
1537
|
S: this,
|
|
1348
1538
|
C: (f, a) => f(...a)
|
|
1349
1539
|
});
|
|
1350
|
-
if (
|
|
1540
|
+
if (this._remoteOptions?.role !== import_invitations.Options.Role.HOST) {
|
|
1351
1541
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
1352
1542
|
expected: import_invitations.Options.Role.HOST,
|
|
1353
1543
|
remoteOptions: this._remoteOptions
|
|
@@ -1356,8 +1546,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1356
1546
|
this._callbacks.onOpen(this._ctx);
|
|
1357
1547
|
} catch (err) {
|
|
1358
1548
|
(0, import_log4.log)("openError", err, {
|
|
1359
|
-
F:
|
|
1360
|
-
L:
|
|
1549
|
+
F: __dxlog_file6,
|
|
1550
|
+
L: 275,
|
|
1361
1551
|
S: this,
|
|
1362
1552
|
C: (f, a) => f(...a)
|
|
1363
1553
|
});
|
|
@@ -1366,8 +1556,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1366
1556
|
}
|
|
1367
1557
|
async onClose() {
|
|
1368
1558
|
(0, import_log4.log)("onClose", void 0, {
|
|
1369
|
-
F:
|
|
1370
|
-
L:
|
|
1559
|
+
F: __dxlog_file6,
|
|
1560
|
+
L: 281,
|
|
1371
1561
|
S: this,
|
|
1372
1562
|
C: (f, a) => f(...a)
|
|
1373
1563
|
});
|
|
@@ -1377,7 +1567,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1377
1567
|
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
|
|
1378
1568
|
|
|
1379
1569
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1380
|
-
var
|
|
1570
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1381
1571
|
var InvitationsHandler = class {
|
|
1382
1572
|
/**
|
|
1383
1573
|
* @internal
|
|
@@ -1386,10 +1576,17 @@ var InvitationsHandler = class {
|
|
|
1386
1576
|
this._networkManager = _networkManager;
|
|
1387
1577
|
}
|
|
1388
1578
|
createInvitation(protocol, options) {
|
|
1389
|
-
|
|
1390
|
-
const
|
|
1391
|
-
|
|
1392
|
-
|
|
1579
|
+
const { invitationId = import_keys6.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys6.PublicKey.random() } = options ?? {};
|
|
1580
|
+
const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1581
|
+
(0, import_invariant6.invariant)(protocol, void 0, {
|
|
1582
|
+
F: __dxlog_file7,
|
|
1583
|
+
L: 76,
|
|
1584
|
+
S: this,
|
|
1585
|
+
A: [
|
|
1586
|
+
"protocol",
|
|
1587
|
+
""
|
|
1588
|
+
]
|
|
1589
|
+
});
|
|
1393
1590
|
const invitation = {
|
|
1394
1591
|
invitationId,
|
|
1395
1592
|
type,
|
|
@@ -1401,7 +1598,7 @@ var InvitationsHandler = class {
|
|
|
1401
1598
|
...protocol.getInvitationContext()
|
|
1402
1599
|
};
|
|
1403
1600
|
const stream = new import_async8.PushStream();
|
|
1404
|
-
const ctx = new
|
|
1601
|
+
const ctx = new import_context5.Context({
|
|
1405
1602
|
onError: (err) => {
|
|
1406
1603
|
void ctx.dispose();
|
|
1407
1604
|
stream.error(err);
|
|
@@ -1411,8 +1608,8 @@ var InvitationsHandler = class {
|
|
|
1411
1608
|
(0, import_log5.log)("complete", {
|
|
1412
1609
|
...protocol.toJSON()
|
|
1413
1610
|
}, {
|
|
1414
|
-
F:
|
|
1415
|
-
L:
|
|
1611
|
+
F: __dxlog_file7,
|
|
1612
|
+
L: 98,
|
|
1416
1613
|
S: this,
|
|
1417
1614
|
C: (f, a) => f(...a)
|
|
1418
1615
|
});
|
|
@@ -1433,10 +1630,17 @@ var InvitationsHandler = class {
|
|
|
1433
1630
|
return invitation;
|
|
1434
1631
|
},
|
|
1435
1632
|
admit: async (admissionRequest) => {
|
|
1436
|
-
var _a2, _b, _c;
|
|
1437
1633
|
try {
|
|
1438
|
-
const deviceKey =
|
|
1439
|
-
(0,
|
|
1634
|
+
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1635
|
+
(0, import_invariant6.invariant)(deviceKey, void 0, {
|
|
1636
|
+
F: __dxlog_file7,
|
|
1637
|
+
L: 119,
|
|
1638
|
+
S: this,
|
|
1639
|
+
A: [
|
|
1640
|
+
"deviceKey",
|
|
1641
|
+
""
|
|
1642
|
+
]
|
|
1643
|
+
});
|
|
1440
1644
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1441
1645
|
extension.completedTrigger.wake(deviceKey);
|
|
1442
1646
|
return admissionResponse;
|
|
@@ -1452,16 +1656,16 @@ var InvitationsHandler = class {
|
|
|
1452
1656
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
|
|
1453
1657
|
id: traceId
|
|
1454
1658
|
}), {
|
|
1455
|
-
F:
|
|
1456
|
-
L:
|
|
1659
|
+
F: __dxlog_file7,
|
|
1660
|
+
L: 137,
|
|
1457
1661
|
S: this,
|
|
1458
1662
|
C: (f, a) => f(...a)
|
|
1459
1663
|
});
|
|
1460
1664
|
(0, import_log5.log)("connected", {
|
|
1461
1665
|
...protocol.toJSON()
|
|
1462
1666
|
}, {
|
|
1463
|
-
F:
|
|
1464
|
-
L:
|
|
1667
|
+
F: __dxlog_file7,
|
|
1668
|
+
L: 138,
|
|
1465
1669
|
S: this,
|
|
1466
1670
|
C: (f, a) => f(...a)
|
|
1467
1671
|
});
|
|
@@ -1476,8 +1680,8 @@ var InvitationsHandler = class {
|
|
|
1476
1680
|
guest: deviceKey,
|
|
1477
1681
|
...protocol.toJSON()
|
|
1478
1682
|
}, {
|
|
1479
|
-
F:
|
|
1480
|
-
L:
|
|
1683
|
+
F: __dxlog_file7,
|
|
1684
|
+
L: 141,
|
|
1481
1685
|
S: this,
|
|
1482
1686
|
C: (f, a) => f(...a)
|
|
1483
1687
|
});
|
|
@@ -1488,8 +1692,8 @@ var InvitationsHandler = class {
|
|
|
1488
1692
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
|
|
1489
1693
|
id: traceId
|
|
1490
1694
|
}), {
|
|
1491
|
-
F:
|
|
1492
|
-
L:
|
|
1695
|
+
F: __dxlog_file7,
|
|
1696
|
+
L: 143,
|
|
1493
1697
|
S: this,
|
|
1494
1698
|
C: (f, a) => f(...a)
|
|
1495
1699
|
});
|
|
@@ -1498,8 +1702,8 @@ var InvitationsHandler = class {
|
|
|
1498
1702
|
(0, import_log5.log)("timeout", {
|
|
1499
1703
|
...protocol.toJSON()
|
|
1500
1704
|
}, {
|
|
1501
|
-
F:
|
|
1502
|
-
L:
|
|
1705
|
+
F: __dxlog_file7,
|
|
1706
|
+
L: 146,
|
|
1503
1707
|
S: this,
|
|
1504
1708
|
C: (f, a) => f(...a)
|
|
1505
1709
|
});
|
|
@@ -1509,8 +1713,8 @@ var InvitationsHandler = class {
|
|
|
1509
1713
|
});
|
|
1510
1714
|
} else {
|
|
1511
1715
|
import_log5.log.error("failed", err, {
|
|
1512
|
-
F:
|
|
1513
|
-
L:
|
|
1716
|
+
F: __dxlog_file7,
|
|
1717
|
+
L: 149,
|
|
1514
1718
|
S: this,
|
|
1515
1719
|
C: (f, a) => f(...a)
|
|
1516
1720
|
});
|
|
@@ -1520,8 +1724,8 @@ var InvitationsHandler = class {
|
|
|
1520
1724
|
id: traceId,
|
|
1521
1725
|
error: err
|
|
1522
1726
|
}), {
|
|
1523
|
-
F:
|
|
1524
|
-
L:
|
|
1727
|
+
F: __dxlog_file7,
|
|
1728
|
+
L: 152,
|
|
1525
1729
|
S: this,
|
|
1526
1730
|
C: (f, a) => f(...a)
|
|
1527
1731
|
});
|
|
@@ -1541,8 +1745,8 @@ var InvitationsHandler = class {
|
|
|
1541
1745
|
(0, import_log5.log)("timeout", {
|
|
1542
1746
|
...protocol.toJSON()
|
|
1543
1747
|
}, {
|
|
1544
|
-
F:
|
|
1545
|
-
L:
|
|
1748
|
+
F: __dxlog_file7,
|
|
1749
|
+
L: 167,
|
|
1546
1750
|
S: this,
|
|
1547
1751
|
C: (f, a) => f(...a)
|
|
1548
1752
|
});
|
|
@@ -1552,8 +1756,8 @@ var InvitationsHandler = class {
|
|
|
1552
1756
|
});
|
|
1553
1757
|
} else {
|
|
1554
1758
|
import_log5.log.error("failed", err, {
|
|
1555
|
-
F:
|
|
1556
|
-
L:
|
|
1759
|
+
F: __dxlog_file7,
|
|
1760
|
+
L: 170,
|
|
1557
1761
|
S: this,
|
|
1558
1762
|
C: (f, a) => f(...a)
|
|
1559
1763
|
});
|
|
@@ -1572,7 +1776,8 @@ var InvitationsHandler = class {
|
|
|
1572
1776
|
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
1573
1777
|
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
1574
1778
|
}),
|
|
1575
|
-
topology: new import_network_manager.StarTopology(topic)
|
|
1779
|
+
topology: new import_network_manager.StarTopology(topic),
|
|
1780
|
+
label: "invitation host"
|
|
1576
1781
|
});
|
|
1577
1782
|
ctx.onDispose(() => swarmConnection.close());
|
|
1578
1783
|
stream.next({
|
|
@@ -1595,26 +1800,42 @@ var InvitationsHandler = class {
|
|
|
1595
1800
|
}
|
|
1596
1801
|
acceptInvitation(protocol, invitation) {
|
|
1597
1802
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1598
|
-
(0,
|
|
1803
|
+
(0, import_invariant6.invariant)(protocol, void 0, {
|
|
1804
|
+
F: __dxlog_file7,
|
|
1805
|
+
L: 211,
|
|
1806
|
+
S: this,
|
|
1807
|
+
A: [
|
|
1808
|
+
"protocol",
|
|
1809
|
+
""
|
|
1810
|
+
]
|
|
1811
|
+
});
|
|
1599
1812
|
const authenticated = new import_async8.Trigger();
|
|
1600
1813
|
let admitted = false;
|
|
1601
1814
|
let currentState;
|
|
1602
1815
|
const stream = new import_async8.PushStream();
|
|
1603
1816
|
const setState = (newData) => {
|
|
1604
|
-
(0,
|
|
1817
|
+
(0, import_invariant6.invariant)(newData.state !== void 0, void 0, {
|
|
1818
|
+
F: __dxlog_file7,
|
|
1819
|
+
L: 222,
|
|
1820
|
+
S: this,
|
|
1821
|
+
A: [
|
|
1822
|
+
"newData.state !== undefined",
|
|
1823
|
+
""
|
|
1824
|
+
]
|
|
1825
|
+
});
|
|
1605
1826
|
currentState = newData.state;
|
|
1606
1827
|
stream.next({
|
|
1607
1828
|
...invitation,
|
|
1608
1829
|
...newData
|
|
1609
1830
|
});
|
|
1610
1831
|
};
|
|
1611
|
-
const ctx = new
|
|
1832
|
+
const ctx = new import_context5.Context({
|
|
1612
1833
|
onError: (err) => {
|
|
1613
1834
|
if (err instanceof import_async8.TimeoutError) {
|
|
1614
1835
|
(0, import_log5.log)("timeout", {
|
|
1615
1836
|
...protocol.toJSON()
|
|
1616
1837
|
}, {
|
|
1617
|
-
F:
|
|
1838
|
+
F: __dxlog_file7,
|
|
1618
1839
|
L: 230,
|
|
1619
1840
|
S: this,
|
|
1620
1841
|
C: (f, a) => f(...a)
|
|
@@ -1624,7 +1845,7 @@ var InvitationsHandler = class {
|
|
|
1624
1845
|
});
|
|
1625
1846
|
} else {
|
|
1626
1847
|
import_log5.log.warn("auth failed", err, {
|
|
1627
|
-
F:
|
|
1848
|
+
F: __dxlog_file7,
|
|
1628
1849
|
L: 233,
|
|
1629
1850
|
S: this,
|
|
1630
1851
|
C: (f, a) => f(...a)
|
|
@@ -1638,7 +1859,7 @@ var InvitationsHandler = class {
|
|
|
1638
1859
|
(0, import_log5.log)("complete", {
|
|
1639
1860
|
...protocol.toJSON()
|
|
1640
1861
|
}, {
|
|
1641
|
-
F:
|
|
1862
|
+
F: __dxlog_file7,
|
|
1642
1863
|
L: 241,
|
|
1643
1864
|
S: this,
|
|
1644
1865
|
C: (f, a) => f(...a)
|
|
@@ -1653,7 +1874,7 @@ var InvitationsHandler = class {
|
|
|
1653
1874
|
(0, import_log5.log)("extension disposed", {
|
|
1654
1875
|
currentState
|
|
1655
1876
|
}, {
|
|
1656
|
-
F:
|
|
1877
|
+
F: __dxlog_file7,
|
|
1657
1878
|
L: 251,
|
|
1658
1879
|
S: this,
|
|
1659
1880
|
C: (f, a) => f(...a)
|
|
@@ -1668,7 +1889,7 @@ var InvitationsHandler = class {
|
|
|
1668
1889
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
|
|
1669
1890
|
id: traceId
|
|
1670
1891
|
}), {
|
|
1671
|
-
F:
|
|
1892
|
+
F: __dxlog_file7,
|
|
1672
1893
|
L: 260,
|
|
1673
1894
|
S: this,
|
|
1674
1895
|
C: (f, a) => f(...a)
|
|
@@ -1680,7 +1901,7 @@ var InvitationsHandler = class {
|
|
|
1680
1901
|
(0, import_log5.log)("connected", {
|
|
1681
1902
|
...protocol.toJSON()
|
|
1682
1903
|
}, {
|
|
1683
|
-
F:
|
|
1904
|
+
F: __dxlog_file7,
|
|
1684
1905
|
L: 268,
|
|
1685
1906
|
S: this,
|
|
1686
1907
|
C: (f, a) => f(...a)
|
|
@@ -1691,7 +1912,7 @@ var InvitationsHandler = class {
|
|
|
1691
1912
|
(0, import_log5.log)("introduce", {
|
|
1692
1913
|
...protocol.toJSON()
|
|
1693
1914
|
}, {
|
|
1694
|
-
F:
|
|
1915
|
+
F: __dxlog_file7,
|
|
1695
1916
|
L: 272,
|
|
1696
1917
|
S: this,
|
|
1697
1918
|
C: (f, a) => f(...a)
|
|
@@ -1701,7 +1922,7 @@ var InvitationsHandler = class {
|
|
|
1701
1922
|
...protocol.toJSON(),
|
|
1702
1923
|
response: introductionResponse
|
|
1703
1924
|
}, {
|
|
1704
|
-
F:
|
|
1925
|
+
F: __dxlog_file7,
|
|
1705
1926
|
L: 276,
|
|
1706
1927
|
S: this,
|
|
1707
1928
|
C: (f, a) => f(...a)
|
|
@@ -1713,7 +1934,7 @@ var InvitationsHandler = class {
|
|
|
1713
1934
|
if (isAuthenticationRequired(invitation)) {
|
|
1714
1935
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1715
1936
|
(0, import_log5.log)("guest waiting for authentication code...", void 0, {
|
|
1716
|
-
F:
|
|
1937
|
+
F: __dxlog_file7,
|
|
1717
1938
|
L: 285,
|
|
1718
1939
|
S: this,
|
|
1719
1940
|
C: (f, a) => f(...a)
|
|
@@ -1725,7 +1946,7 @@ var InvitationsHandler = class {
|
|
|
1725
1946
|
timeout
|
|
1726
1947
|
});
|
|
1727
1948
|
(0, import_log5.log)("sending authentication request", void 0, {
|
|
1728
|
-
F:
|
|
1949
|
+
F: __dxlog_file7,
|
|
1729
1950
|
L: 289,
|
|
1730
1951
|
S: this,
|
|
1731
1952
|
C: (f, a) => f(...a)
|
|
@@ -1746,7 +1967,7 @@ var InvitationsHandler = class {
|
|
|
1746
1967
|
(0, import_log5.log)("retrying invalid code", {
|
|
1747
1968
|
attempt
|
|
1748
1969
|
}, {
|
|
1749
|
-
F:
|
|
1970
|
+
F: __dxlog_file7,
|
|
1750
1971
|
L: 300,
|
|
1751
1972
|
S: this,
|
|
1752
1973
|
C: (f, a) => f(...a)
|
|
@@ -1763,7 +1984,7 @@ var InvitationsHandler = class {
|
|
|
1763
1984
|
(0, import_log5.log)("request admission", {
|
|
1764
1985
|
...protocol.toJSON()
|
|
1765
1986
|
}, {
|
|
1766
|
-
F:
|
|
1987
|
+
F: __dxlog_file7,
|
|
1767
1988
|
L: 311,
|
|
1768
1989
|
S: this,
|
|
1769
1990
|
C: (f, a) => f(...a)
|
|
@@ -1775,7 +1996,7 @@ var InvitationsHandler = class {
|
|
|
1775
1996
|
(0, import_log5.log)("admitted by host", {
|
|
1776
1997
|
...protocol.toJSON()
|
|
1777
1998
|
}, {
|
|
1778
|
-
F:
|
|
1999
|
+
F: __dxlog_file7,
|
|
1779
2000
|
L: 322,
|
|
1780
2001
|
S: this,
|
|
1781
2002
|
C: (f, a) => f(...a)
|
|
@@ -1787,7 +2008,7 @@ var InvitationsHandler = class {
|
|
|
1787
2008
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
|
|
1788
2009
|
id: traceId
|
|
1789
2010
|
}), {
|
|
1790
|
-
F:
|
|
2011
|
+
F: __dxlog_file7,
|
|
1791
2012
|
L: 324,
|
|
1792
2013
|
S: this,
|
|
1793
2014
|
C: (f, a) => f(...a)
|
|
@@ -1797,7 +2018,7 @@ var InvitationsHandler = class {
|
|
|
1797
2018
|
(0, import_log5.log)("timeout", {
|
|
1798
2019
|
...protocol.toJSON()
|
|
1799
2020
|
}, {
|
|
1800
|
-
F:
|
|
2021
|
+
F: __dxlog_file7,
|
|
1801
2022
|
L: 327,
|
|
1802
2023
|
S: this,
|
|
1803
2024
|
C: (f, a) => f(...a)
|
|
@@ -1807,7 +2028,7 @@ var InvitationsHandler = class {
|
|
|
1807
2028
|
});
|
|
1808
2029
|
} else {
|
|
1809
2030
|
(0, import_log5.log)("auth failed", err, {
|
|
1810
|
-
F:
|
|
2031
|
+
F: __dxlog_file7,
|
|
1811
2032
|
L: 330,
|
|
1812
2033
|
S: this,
|
|
1813
2034
|
C: (f, a) => f(...a)
|
|
@@ -1818,7 +2039,7 @@ var InvitationsHandler = class {
|
|
|
1818
2039
|
id: traceId,
|
|
1819
2040
|
error: err
|
|
1820
2041
|
}), {
|
|
1821
|
-
F:
|
|
2042
|
+
F: __dxlog_file7,
|
|
1822
2043
|
L: 333,
|
|
1823
2044
|
S: this,
|
|
1824
2045
|
C: (f, a) => f(...a)
|
|
@@ -1836,7 +2057,7 @@ var InvitationsHandler = class {
|
|
|
1836
2057
|
(0, import_log5.log)("timeout", {
|
|
1837
2058
|
...protocol.toJSON()
|
|
1838
2059
|
}, {
|
|
1839
|
-
F:
|
|
2060
|
+
F: __dxlog_file7,
|
|
1840
2061
|
L: 344,
|
|
1841
2062
|
S: this,
|
|
1842
2063
|
C: (f, a) => f(...a)
|
|
@@ -1846,7 +2067,7 @@ var InvitationsHandler = class {
|
|
|
1846
2067
|
});
|
|
1847
2068
|
} else {
|
|
1848
2069
|
(0, import_log5.log)("auth failed", err, {
|
|
1849
|
-
F:
|
|
2070
|
+
F: __dxlog_file7,
|
|
1850
2071
|
L: 347,
|
|
1851
2072
|
S: this,
|
|
1852
2073
|
C: (f, a) => f(...a)
|
|
@@ -1858,7 +2079,15 @@ var InvitationsHandler = class {
|
|
|
1858
2079
|
return extension;
|
|
1859
2080
|
};
|
|
1860
2081
|
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1861
|
-
(0,
|
|
2082
|
+
(0, import_invariant6.invariant)(invitation.swarmKey, void 0, {
|
|
2083
|
+
F: __dxlog_file7,
|
|
2084
|
+
L: 357,
|
|
2085
|
+
S: this,
|
|
2086
|
+
A: [
|
|
2087
|
+
"invitation.swarmKey",
|
|
2088
|
+
""
|
|
2089
|
+
]
|
|
2090
|
+
});
|
|
1862
2091
|
const topic = invitation.swarmKey;
|
|
1863
2092
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1864
2093
|
topic,
|
|
@@ -1866,7 +2095,8 @@ var InvitationsHandler = class {
|
|
|
1866
2095
|
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
1867
2096
|
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
1868
2097
|
}),
|
|
1869
|
-
topology: new import_network_manager.StarTopology(topic)
|
|
2098
|
+
topology: new import_network_manager.StarTopology(topic),
|
|
2099
|
+
label: "invitation guest"
|
|
1870
2100
|
});
|
|
1871
2101
|
ctx.onDispose(() => swarmConnection.close());
|
|
1872
2102
|
setState({
|
|
@@ -1891,12 +2121,12 @@ var InvitationsHandler = class {
|
|
|
1891
2121
|
};
|
|
1892
2122
|
|
|
1893
2123
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1894
|
-
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1895
2124
|
var import_async9 = require("@dxos/async");
|
|
1896
2125
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
2126
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
1897
2127
|
var import_log6 = require("@dxos/log");
|
|
1898
2128
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1899
|
-
var
|
|
2129
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1900
2130
|
var InvitationsServiceImpl = class {
|
|
1901
2131
|
constructor(_invitationsHandler, _getHandler) {
|
|
1902
2132
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1958,19 +2188,27 @@ var InvitationsServiceImpl = class {
|
|
|
1958
2188
|
}
|
|
1959
2189
|
async authenticate({ invitationId, authCode }) {
|
|
1960
2190
|
(0, import_log6.log)("authenticating...", void 0, {
|
|
1961
|
-
F:
|
|
1962
|
-
L:
|
|
2191
|
+
F: __dxlog_file8,
|
|
2192
|
+
L: 102,
|
|
1963
2193
|
S: this,
|
|
1964
2194
|
C: (f, a) => f(...a)
|
|
1965
2195
|
});
|
|
1966
|
-
(0,
|
|
2196
|
+
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2197
|
+
F: __dxlog_file8,
|
|
2198
|
+
L: 103,
|
|
2199
|
+
S: this,
|
|
2200
|
+
A: [
|
|
2201
|
+
"invitationId",
|
|
2202
|
+
""
|
|
2203
|
+
]
|
|
2204
|
+
});
|
|
1967
2205
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1968
2206
|
if (!observable) {
|
|
1969
2207
|
import_log6.log.warn("invalid invitation", {
|
|
1970
2208
|
invitationId
|
|
1971
2209
|
}, {
|
|
1972
|
-
F:
|
|
1973
|
-
L:
|
|
2210
|
+
F: __dxlog_file8,
|
|
2211
|
+
L: 106,
|
|
1974
2212
|
S: this,
|
|
1975
2213
|
C: (f, a) => f(...a)
|
|
1976
2214
|
});
|
|
@@ -1980,12 +2218,20 @@ var InvitationsServiceImpl = class {
|
|
|
1980
2218
|
}
|
|
1981
2219
|
async cancelInvitation({ invitationId }) {
|
|
1982
2220
|
(0, import_log6.log)("deleting...", void 0, {
|
|
1983
|
-
F:
|
|
1984
|
-
L:
|
|
2221
|
+
F: __dxlog_file8,
|
|
2222
|
+
L: 113,
|
|
1985
2223
|
S: this,
|
|
1986
2224
|
C: (f, a) => f(...a)
|
|
1987
2225
|
});
|
|
1988
|
-
(0,
|
|
2226
|
+
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2227
|
+
F: __dxlog_file8,
|
|
2228
|
+
L: 114,
|
|
2229
|
+
S: this,
|
|
2230
|
+
A: [
|
|
2231
|
+
"invitationId",
|
|
2232
|
+
""
|
|
2233
|
+
]
|
|
2234
|
+
});
|
|
1989
2235
|
const created = this._createInvitations.get(invitationId);
|
|
1990
2236
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1991
2237
|
if (created) {
|
|
@@ -2000,8 +2246,8 @@ var InvitationsServiceImpl = class {
|
|
|
2000
2246
|
import_log6.log.warn("invalid invitation", {
|
|
2001
2247
|
invitationId
|
|
2002
2248
|
}, {
|
|
2003
|
-
F:
|
|
2004
|
-
L:
|
|
2249
|
+
F: __dxlog_file8,
|
|
2250
|
+
L: 126,
|
|
2005
2251
|
S: this,
|
|
2006
2252
|
C: (f, a) => f(...a)
|
|
2007
2253
|
});
|
|
@@ -2060,12 +2306,12 @@ var InvitationsServiceImpl = class {
|
|
|
2060
2306
|
};
|
|
2061
2307
|
|
|
2062
2308
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
2063
|
-
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
2064
2309
|
var import_credentials8 = require("@dxos/credentials");
|
|
2065
2310
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
2311
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
2066
2312
|
var import_log7 = require("@dxos/log");
|
|
2067
2313
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2068
|
-
var
|
|
2314
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2069
2315
|
var SpaceInvitationProtocol = class {
|
|
2070
2316
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2071
2317
|
this._spaceManager = _spaceManager;
|
|
@@ -2086,31 +2332,70 @@ var SpaceInvitationProtocol = class {
|
|
|
2086
2332
|
};
|
|
2087
2333
|
}
|
|
2088
2334
|
async admit(request, guestProfile) {
|
|
2089
|
-
|
|
2090
|
-
|
|
2335
|
+
(0, import_invariant8.invariant)(this._spaceKey, void 0, {
|
|
2336
|
+
F: __dxlog_file9,
|
|
2337
|
+
L: 42,
|
|
2338
|
+
S: this,
|
|
2339
|
+
A: [
|
|
2340
|
+
"this._spaceKey",
|
|
2341
|
+
""
|
|
2342
|
+
]
|
|
2343
|
+
});
|
|
2091
2344
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2092
|
-
(0,
|
|
2093
|
-
|
|
2345
|
+
(0, import_invariant8.invariant)(space, void 0, {
|
|
2346
|
+
F: __dxlog_file9,
|
|
2347
|
+
L: 44,
|
|
2348
|
+
S: this,
|
|
2349
|
+
A: [
|
|
2350
|
+
"space",
|
|
2351
|
+
""
|
|
2352
|
+
]
|
|
2353
|
+
});
|
|
2354
|
+
(0, import_invariant8.invariant)(request.space, void 0, {
|
|
2355
|
+
F: __dxlog_file9,
|
|
2356
|
+
L: 46,
|
|
2357
|
+
S: this,
|
|
2358
|
+
A: [
|
|
2359
|
+
"request.space",
|
|
2360
|
+
""
|
|
2361
|
+
]
|
|
2362
|
+
});
|
|
2094
2363
|
const { identityKey, deviceKey } = request.space;
|
|
2095
2364
|
(0, import_log7.log)("writing guest credentials", {
|
|
2096
2365
|
host: this._signingContext.deviceKey,
|
|
2097
2366
|
guest: deviceKey
|
|
2098
2367
|
}, {
|
|
2099
|
-
F:
|
|
2100
|
-
L:
|
|
2368
|
+
F: __dxlog_file9,
|
|
2369
|
+
L: 49,
|
|
2101
2370
|
S: this,
|
|
2102
2371
|
C: (f, a) => f(...a)
|
|
2103
2372
|
});
|
|
2104
2373
|
const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2105
|
-
(0,
|
|
2374
|
+
(0, import_invariant8.invariant)(credentials[0].credential, void 0, {
|
|
2375
|
+
F: __dxlog_file9,
|
|
2376
|
+
L: 60,
|
|
2377
|
+
S: this,
|
|
2378
|
+
A: [
|
|
2379
|
+
"credentials[0].credential",
|
|
2380
|
+
""
|
|
2381
|
+
]
|
|
2382
|
+
});
|
|
2106
2383
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2107
|
-
(0,
|
|
2384
|
+
(0, import_invariant8.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2385
|
+
F: __dxlog_file9,
|
|
2386
|
+
L: 62,
|
|
2387
|
+
S: this,
|
|
2388
|
+
A: [
|
|
2389
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2390
|
+
""
|
|
2391
|
+
]
|
|
2392
|
+
});
|
|
2108
2393
|
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
2109
2394
|
return {
|
|
2110
2395
|
space: {
|
|
2111
2396
|
credential: spaceMemberCredential,
|
|
2112
2397
|
controlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2113
|
-
dataTimeframe:
|
|
2398
|
+
dataTimeframe: space.dataPipeline.pipelineState?.timeframe
|
|
2114
2399
|
}
|
|
2115
2400
|
};
|
|
2116
2401
|
}
|
|
@@ -2132,11 +2417,35 @@ var SpaceInvitationProtocol = class {
|
|
|
2132
2417
|
};
|
|
2133
2418
|
}
|
|
2134
2419
|
async accept(response) {
|
|
2135
|
-
(0,
|
|
2420
|
+
(0, import_invariant8.invariant)(response.space, void 0, {
|
|
2421
|
+
F: __dxlog_file9,
|
|
2422
|
+
L: 97,
|
|
2423
|
+
S: this,
|
|
2424
|
+
A: [
|
|
2425
|
+
"response.space",
|
|
2426
|
+
""
|
|
2427
|
+
]
|
|
2428
|
+
});
|
|
2136
2429
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2137
2430
|
const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
|
|
2138
|
-
(0,
|
|
2139
|
-
|
|
2431
|
+
(0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2432
|
+
F: __dxlog_file9,
|
|
2433
|
+
L: 100,
|
|
2434
|
+
S: this,
|
|
2435
|
+
A: [
|
|
2436
|
+
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2437
|
+
"'Invalid credential'"
|
|
2438
|
+
]
|
|
2439
|
+
});
|
|
2440
|
+
(0, import_invariant8.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2441
|
+
F: __dxlog_file9,
|
|
2442
|
+
L: 101,
|
|
2443
|
+
S: this,
|
|
2444
|
+
A: [
|
|
2445
|
+
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
2446
|
+
""
|
|
2447
|
+
]
|
|
2448
|
+
});
|
|
2140
2449
|
await this._spaceManager.acceptSpace({
|
|
2141
2450
|
spaceKey: assertion.spaceKey,
|
|
2142
2451
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2190,9 +2499,8 @@ var ClientRpcServer = class {
|
|
|
2190
2499
|
await this._rpcPeer.close();
|
|
2191
2500
|
}
|
|
2192
2501
|
_getServiceHandler(serviceName) {
|
|
2193
|
-
var _a;
|
|
2194
2502
|
if (!this._handlerCache.has(serviceName)) {
|
|
2195
|
-
const [key, descriptor] =
|
|
2503
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug3.raise)(new Error(`Service not available: ${serviceName}`));
|
|
2196
2504
|
const service = this._serviceRegistry.services[key];
|
|
2197
2505
|
if (!service) {
|
|
2198
2506
|
throw new Error(`Service not available: ${serviceName}`);
|
|
@@ -2203,63 +2511,225 @@ var ClientRpcServer = class {
|
|
|
2203
2511
|
}
|
|
2204
2512
|
};
|
|
2205
2513
|
|
|
2514
|
+
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2515
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2516
|
+
var import_credentials9 = require("@dxos/credentials");
|
|
2517
|
+
var import_document_model = require("@dxos/document-model");
|
|
2518
|
+
var import_echo_db = require("@dxos/echo-db");
|
|
2519
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
2520
|
+
var import_log8 = require("@dxos/log");
|
|
2521
|
+
var import_protocols5 = require("@dxos/protocols");
|
|
2522
|
+
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2523
|
+
|
|
2524
|
+
// packages/sdk/client-services/src/version.ts
|
|
2525
|
+
var DXOS_VERSION = "0.1.56-main.e79d64a";
|
|
2526
|
+
|
|
2527
|
+
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
2528
|
+
var getPlatform = () => {
|
|
2529
|
+
if (process.browser) {
|
|
2530
|
+
if (typeof window !== "undefined") {
|
|
2531
|
+
const { userAgent } = window.navigator;
|
|
2532
|
+
return {
|
|
2533
|
+
type: "browser",
|
|
2534
|
+
userAgent,
|
|
2535
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2536
|
+
};
|
|
2537
|
+
} else {
|
|
2538
|
+
return {
|
|
2539
|
+
type: "shared-worker",
|
|
2540
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
} else {
|
|
2544
|
+
const { platform, version, arch } = process;
|
|
2545
|
+
return {
|
|
2546
|
+
type: "node",
|
|
2547
|
+
platform: `${platform} ${version} ${arch}`,
|
|
2548
|
+
runtime: process.version,
|
|
2549
|
+
uptime: Math.floor(process.uptime()),
|
|
2550
|
+
memory: process.memoryUsage()
|
|
2551
|
+
};
|
|
2552
|
+
}
|
|
2553
|
+
};
|
|
2554
|
+
|
|
2555
|
+
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2556
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2557
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
2558
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2559
|
+
const diagnostics = {
|
|
2560
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2561
|
+
platform: getPlatform(),
|
|
2562
|
+
client: {
|
|
2563
|
+
version: DXOS_VERSION,
|
|
2564
|
+
storage: {
|
|
2565
|
+
version: import_protocols5.STORAGE_VERSION
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
};
|
|
2569
|
+
{
|
|
2570
|
+
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2571
|
+
F: __dxlog_file10,
|
|
2572
|
+
L: 88,
|
|
2573
|
+
S: void 0,
|
|
2574
|
+
A: [
|
|
2575
|
+
"clientServices.LoggingService",
|
|
2576
|
+
"'SystemService is not available.'"
|
|
2577
|
+
]
|
|
2578
|
+
});
|
|
2579
|
+
diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
2580
|
+
timeout: DEFAULT_TIMEOUT
|
|
2581
|
+
}).catch(() => void 0);
|
|
2582
|
+
}
|
|
2583
|
+
const identity = serviceContext.identityManager.identity;
|
|
2584
|
+
if (identity) {
|
|
2585
|
+
diagnostics.identity = {
|
|
2586
|
+
identityKey: identity.identityKey,
|
|
2587
|
+
spaceKey: identity.space.key,
|
|
2588
|
+
profile: identity.profileDocument
|
|
2589
|
+
};
|
|
2590
|
+
const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
2591
|
+
timeout: DEFAULT_TIMEOUT
|
|
2592
|
+
}).catch(() => void 0) ?? {};
|
|
2593
|
+
diagnostics.devices = devices;
|
|
2594
|
+
if (serviceContext.dataSpaceManager) {
|
|
2595
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2596
|
+
}
|
|
2597
|
+
const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2598
|
+
timeout: DEFAULT_TIMEOUT
|
|
2599
|
+
}).catch(() => void 0) ?? {};
|
|
2600
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2601
|
+
feedKey,
|
|
2602
|
+
bytes,
|
|
2603
|
+
length
|
|
2604
|
+
}));
|
|
2605
|
+
}
|
|
2606
|
+
diagnostics.config = config.values;
|
|
2607
|
+
return diagnostics;
|
|
2608
|
+
};
|
|
2609
|
+
var getProperties = (space) => {
|
|
2610
|
+
let properties = {};
|
|
2611
|
+
try {
|
|
2612
|
+
const propertiesItem = space.dataPipeline.itemManager.items.find((item) => item.modelMeta?.type === import_document_model.DocumentModel.meta.type && item.state?.type === import_echo_db.TYPE_PROPERTIES);
|
|
2613
|
+
const state = propertiesItem?.state;
|
|
2614
|
+
properties = state?.data;
|
|
2615
|
+
} catch (err) {
|
|
2616
|
+
import_log8.log.warn(err.message, void 0, {
|
|
2617
|
+
F: __dxlog_file10,
|
|
2618
|
+
L: 145,
|
|
2619
|
+
S: void 0,
|
|
2620
|
+
C: (f, a) => f(...a)
|
|
2621
|
+
});
|
|
2622
|
+
}
|
|
2623
|
+
return properties;
|
|
2624
|
+
};
|
|
2625
|
+
var getSpaceStats = async (space) => {
|
|
2626
|
+
const stats = {
|
|
2627
|
+
key: space.key,
|
|
2628
|
+
metrics: space.metrics,
|
|
2629
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
2630
|
+
...credential.subject.assertion,
|
|
2631
|
+
id: credential.id
|
|
2632
|
+
})),
|
|
2633
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2634
|
+
identity: {
|
|
2635
|
+
identityKey: member.key,
|
|
2636
|
+
profile: {
|
|
2637
|
+
displayName: member.assertion.profile?.displayName
|
|
2638
|
+
}
|
|
2639
|
+
},
|
|
2640
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services6.SpaceMember.PresenceState.ONLINE : import_services6.SpaceMember.PresenceState.OFFLINE
|
|
2641
|
+
})),
|
|
2642
|
+
pipeline: {
|
|
2643
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
2644
|
+
// currentEpoch: space.dataPipeline.currentEpoch,
|
|
2645
|
+
// appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
2646
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2647
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2648
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2649
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
2650
|
+
// TODO(burdon): Empty?
|
|
2651
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
2652
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
2653
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
2654
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
2655
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
2656
|
+
}
|
|
2657
|
+
};
|
|
2658
|
+
if (space.dataPipeline.itemManager) {
|
|
2659
|
+
Object.assign(stats, {
|
|
2660
|
+
properties: getProperties(space),
|
|
2661
|
+
db: {
|
|
2662
|
+
objects: space.dataPipeline.itemManager.entities.size
|
|
2663
|
+
}
|
|
2664
|
+
});
|
|
2665
|
+
}
|
|
2666
|
+
if (stats.metrics) {
|
|
2667
|
+
const { open, ready } = stats.metrics;
|
|
2668
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
2669
|
+
}
|
|
2670
|
+
return stats;
|
|
2671
|
+
};
|
|
2672
|
+
|
|
2206
2673
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2207
|
-
var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
|
|
2208
2674
|
var import_async14 = require("@dxos/async");
|
|
2209
|
-
var
|
|
2675
|
+
var import_context9 = require("@dxos/context");
|
|
2676
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
2210
2677
|
var import_debug7 = require("@dxos/debug");
|
|
2211
2678
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
2212
2679
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
2680
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
2213
2681
|
var import_keyring = require("@dxos/keyring");
|
|
2214
2682
|
var import_keys10 = require("@dxos/keys");
|
|
2215
|
-
var
|
|
2216
|
-
var
|
|
2217
|
-
var
|
|
2683
|
+
var import_log13 = require("@dxos/log");
|
|
2684
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
2685
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2218
2686
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
2687
|
+
var import_tracing3 = require("@dxos/tracing");
|
|
2688
|
+
var import_util7 = require("@dxos/util");
|
|
2219
2689
|
|
|
2220
2690
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2221
|
-
var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
|
|
2222
2691
|
var import_async12 = require("@dxos/async");
|
|
2223
|
-
var
|
|
2224
|
-
var
|
|
2692
|
+
var import_context8 = require("@dxos/context");
|
|
2693
|
+
var import_credentials13 = require("@dxos/credentials");
|
|
2694
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
2225
2695
|
var import_keys9 = require("@dxos/keys");
|
|
2226
|
-
var
|
|
2227
|
-
var
|
|
2228
|
-
var
|
|
2696
|
+
var import_log11 = require("@dxos/log");
|
|
2697
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
2698
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2229
2699
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
2230
2700
|
var import_util5 = require("@dxos/util");
|
|
2231
2701
|
|
|
2232
2702
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2233
2703
|
var import_async11 = require("@dxos/async");
|
|
2234
2704
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
2235
|
-
var
|
|
2705
|
+
var import_context7 = require("@dxos/context");
|
|
2236
2706
|
var import_debug4 = require("@dxos/debug");
|
|
2237
2707
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
2238
2708
|
var import_errors3 = require("@dxos/errors");
|
|
2239
2709
|
var import_keys8 = require("@dxos/keys");
|
|
2240
|
-
var
|
|
2241
|
-
var
|
|
2242
|
-
var
|
|
2243
|
-
var
|
|
2710
|
+
var import_log10 = require("@dxos/log");
|
|
2711
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2712
|
+
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2713
|
+
var import_timeframe2 = require("@dxos/timeframe");
|
|
2244
2714
|
var import_util4 = require("@dxos/util");
|
|
2245
2715
|
|
|
2246
2716
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2247
|
-
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
2248
2717
|
var import_async10 = require("@dxos/async");
|
|
2249
|
-
var
|
|
2718
|
+
var import_context6 = require("@dxos/context");
|
|
2719
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
2250
2720
|
var import_keys7 = require("@dxos/keys");
|
|
2251
|
-
var
|
|
2252
|
-
var
|
|
2721
|
+
var import_log9 = require("@dxos/log");
|
|
2722
|
+
var import_protocols6 = require("@dxos/protocols");
|
|
2253
2723
|
var import_teleport2 = require("@dxos/teleport");
|
|
2254
2724
|
var import_util3 = require("@dxos/util");
|
|
2255
|
-
var
|
|
2725
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2256
2726
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2257
2727
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2258
2728
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
2259
2729
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2260
2730
|
var NotarizationPlugin = class {
|
|
2261
2731
|
constructor() {
|
|
2262
|
-
this._ctx = new
|
|
2732
|
+
this._ctx = new import_context6.Context();
|
|
2263
2733
|
this._extensionOpened = new import_async10.Event();
|
|
2264
2734
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2265
2735
|
this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
|
|
@@ -2277,23 +2747,31 @@ var NotarizationPlugin = class {
|
|
|
2277
2747
|
* Request credentials to be notarized.
|
|
2278
2748
|
*/
|
|
2279
2749
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
2280
|
-
(0,
|
|
2750
|
+
(0, import_log9.log)("notarize", {
|
|
2281
2751
|
credentials
|
|
2282
2752
|
}, {
|
|
2283
|
-
F:
|
|
2284
|
-
L:
|
|
2753
|
+
F: __dxlog_file11,
|
|
2754
|
+
L: 90,
|
|
2285
2755
|
S: this,
|
|
2286
2756
|
C: (f, a) => f(...a)
|
|
2287
2757
|
});
|
|
2288
|
-
(0,
|
|
2758
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2759
|
+
F: __dxlog_file11,
|
|
2760
|
+
L: 91,
|
|
2761
|
+
S: this,
|
|
2762
|
+
A: [
|
|
2763
|
+
"credentials.every((credential) => credential.id)",
|
|
2764
|
+
"'Credentials must have an id'"
|
|
2765
|
+
]
|
|
2766
|
+
});
|
|
2289
2767
|
const errors = new import_async10.Trigger();
|
|
2290
2768
|
const ctx = this._ctx.derive({
|
|
2291
2769
|
onError: (err) => {
|
|
2292
|
-
|
|
2770
|
+
import_log9.log.warn("Notarization error", {
|
|
2293
2771
|
err
|
|
2294
2772
|
}, {
|
|
2295
|
-
F:
|
|
2296
|
-
L:
|
|
2773
|
+
F: __dxlog_file11,
|
|
2774
|
+
L: 99,
|
|
2297
2775
|
S: this,
|
|
2298
2776
|
C: (f, a) => f(...a)
|
|
2299
2777
|
});
|
|
@@ -2301,15 +2779,15 @@ var NotarizationPlugin = class {
|
|
|
2301
2779
|
errors.throw(err);
|
|
2302
2780
|
}
|
|
2303
2781
|
});
|
|
2304
|
-
opCtx
|
|
2782
|
+
opCtx?.onDispose(() => ctx.dispose());
|
|
2305
2783
|
if (timeout !== 0) {
|
|
2306
2784
|
(0, import_async10.scheduleTask)(ctx, () => {
|
|
2307
|
-
|
|
2785
|
+
import_log9.log.warn("Notarization timeout", {
|
|
2308
2786
|
timeout,
|
|
2309
2787
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2310
2788
|
}, {
|
|
2311
|
-
F:
|
|
2312
|
-
L:
|
|
2789
|
+
F: __dxlog_file11,
|
|
2790
|
+
L: 111,
|
|
2313
2791
|
S: this,
|
|
2314
2792
|
C: (f, a) => f(...a)
|
|
2315
2793
|
});
|
|
@@ -2328,11 +2806,11 @@ var NotarizationPlugin = class {
|
|
|
2328
2806
|
...this._extensions
|
|
2329
2807
|
].find((peer2) => !peersTried.has(peer2));
|
|
2330
2808
|
if (!peer) {
|
|
2331
|
-
|
|
2809
|
+
import_log9.log.warn("Exhausted all peers to notarize with", {
|
|
2332
2810
|
retryIn: retryTimeout
|
|
2333
2811
|
}, {
|
|
2334
|
-
F:
|
|
2335
|
-
L:
|
|
2812
|
+
F: __dxlog_file11,
|
|
2813
|
+
L: 136,
|
|
2336
2814
|
S: this,
|
|
2337
2815
|
C: (f, a) => f(...a)
|
|
2338
2816
|
});
|
|
@@ -2341,30 +2819,30 @@ var NotarizationPlugin = class {
|
|
|
2341
2819
|
return;
|
|
2342
2820
|
}
|
|
2343
2821
|
peersTried.add(peer);
|
|
2344
|
-
(0,
|
|
2822
|
+
(0, import_log9.log)("try notarizing", {
|
|
2345
2823
|
peer: peer.localPeerId,
|
|
2346
2824
|
credentialId: credentials.map((credential) => credential.id)
|
|
2347
2825
|
}, {
|
|
2348
|
-
F:
|
|
2349
|
-
L:
|
|
2826
|
+
F: __dxlog_file11,
|
|
2827
|
+
L: 143,
|
|
2350
2828
|
S: this,
|
|
2351
2829
|
C: (f, a) => f(...a)
|
|
2352
2830
|
});
|
|
2353
2831
|
await peer.rpc.NotarizationService.notarize({
|
|
2354
2832
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2355
2833
|
});
|
|
2356
|
-
(0,
|
|
2357
|
-
F:
|
|
2358
|
-
L:
|
|
2834
|
+
(0, import_log9.log)("success", void 0, {
|
|
2835
|
+
F: __dxlog_file11,
|
|
2836
|
+
L: 147,
|
|
2359
2837
|
S: this,
|
|
2360
2838
|
C: (f, a) => f(...a)
|
|
2361
2839
|
});
|
|
2362
2840
|
await (0, import_async10.sleep)(successDelay);
|
|
2363
2841
|
} catch (err) {
|
|
2364
2842
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2365
|
-
|
|
2366
|
-
F:
|
|
2367
|
-
L:
|
|
2843
|
+
import_log9.log.warn("error notarizing (recoverable)", err, {
|
|
2844
|
+
F: __dxlog_file11,
|
|
2845
|
+
L: 151,
|
|
2368
2846
|
S: this,
|
|
2369
2847
|
C: (f, a) => f(...a)
|
|
2370
2848
|
});
|
|
@@ -2376,13 +2854,13 @@ var NotarizationPlugin = class {
|
|
|
2376
2854
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
2377
2855
|
try {
|
|
2378
2856
|
await Promise.race([
|
|
2379
|
-
(0,
|
|
2857
|
+
(0, import_context6.rejectOnDispose)(ctx),
|
|
2380
2858
|
allNotarized,
|
|
2381
2859
|
errors.wait()
|
|
2382
2860
|
]);
|
|
2383
|
-
(0,
|
|
2384
|
-
F:
|
|
2385
|
-
L:
|
|
2861
|
+
(0, import_log9.log)("done", void 0, {
|
|
2862
|
+
F: __dxlog_file11,
|
|
2863
|
+
L: 162,
|
|
2386
2864
|
S: this,
|
|
2387
2865
|
C: (f, a) => f(...a)
|
|
2388
2866
|
});
|
|
@@ -2394,16 +2872,23 @@ var NotarizationPlugin = class {
|
|
|
2394
2872
|
* Called with credentials arriving from the control pipeline.
|
|
2395
2873
|
*/
|
|
2396
2874
|
async processCredential(credential) {
|
|
2397
|
-
var _a;
|
|
2398
2875
|
if (!credential.id) {
|
|
2399
2876
|
return;
|
|
2400
2877
|
}
|
|
2401
|
-
|
|
2878
|
+
this._processCredentialsTriggers.get(credential.id)?.wake();
|
|
2402
2879
|
this._processedCredentials.add(credential.id);
|
|
2403
2880
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2404
2881
|
}
|
|
2405
2882
|
setWriter(writer) {
|
|
2406
|
-
(0,
|
|
2883
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
2884
|
+
F: __dxlog_file11,
|
|
2885
|
+
L: 181,
|
|
2886
|
+
S: this,
|
|
2887
|
+
A: [
|
|
2888
|
+
"!this._writer",
|
|
2889
|
+
"'Writer already set.'"
|
|
2890
|
+
]
|
|
2891
|
+
});
|
|
2407
2892
|
this._writer = writer;
|
|
2408
2893
|
}
|
|
2409
2894
|
async _waitUntilProcessed(id) {
|
|
@@ -2416,12 +2901,19 @@ var NotarizationPlugin = class {
|
|
|
2416
2901
|
* Requests from other peers to notarize credentials.
|
|
2417
2902
|
*/
|
|
2418
2903
|
async _onNotarize(request) {
|
|
2419
|
-
var _a;
|
|
2420
2904
|
if (!this._writer) {
|
|
2421
2905
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2422
2906
|
}
|
|
2423
|
-
for (const credential of
|
|
2424
|
-
(0,
|
|
2907
|
+
for (const credential of request.credentials ?? []) {
|
|
2908
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
2909
|
+
F: __dxlog_file11,
|
|
2910
|
+
L: 200,
|
|
2911
|
+
S: this,
|
|
2912
|
+
A: [
|
|
2913
|
+
"credential.id",
|
|
2914
|
+
"'Credential must have an id'"
|
|
2915
|
+
]
|
|
2916
|
+
});
|
|
2425
2917
|
if (this._processedCredentials.has(credential.id)) {
|
|
2426
2918
|
continue;
|
|
2427
2919
|
}
|
|
@@ -2431,11 +2923,11 @@ var NotarizationPlugin = class {
|
|
|
2431
2923
|
createExtension() {
|
|
2432
2924
|
const extension = new NotarizationTeleportExtension({
|
|
2433
2925
|
onOpen: async () => {
|
|
2434
|
-
(0,
|
|
2926
|
+
(0, import_log9.log)("extension opened", {
|
|
2435
2927
|
peer: extension.localPeerId
|
|
2436
2928
|
}, {
|
|
2437
|
-
F:
|
|
2438
|
-
L:
|
|
2929
|
+
F: __dxlog_file11,
|
|
2930
|
+
L: 211,
|
|
2439
2931
|
S: this,
|
|
2440
2932
|
C: (f, a) => f(...a)
|
|
2441
2933
|
});
|
|
@@ -2443,11 +2935,11 @@ var NotarizationPlugin = class {
|
|
|
2443
2935
|
this._extensionOpened.emit();
|
|
2444
2936
|
},
|
|
2445
2937
|
onClose: async () => {
|
|
2446
|
-
(0,
|
|
2938
|
+
(0, import_log9.log)("extension closed", {
|
|
2447
2939
|
peer: extension.localPeerId
|
|
2448
2940
|
}, {
|
|
2449
|
-
F:
|
|
2450
|
-
L:
|
|
2941
|
+
F: __dxlog_file11,
|
|
2942
|
+
L: 216,
|
|
2451
2943
|
S: this,
|
|
2452
2944
|
C: (f, a) => f(...a)
|
|
2453
2945
|
});
|
|
@@ -2462,10 +2954,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2462
2954
|
constructor(_params) {
|
|
2463
2955
|
super({
|
|
2464
2956
|
requested: {
|
|
2465
|
-
NotarizationService:
|
|
2957
|
+
NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2466
2958
|
},
|
|
2467
2959
|
exposed: {
|
|
2468
|
-
NotarizationService:
|
|
2960
|
+
NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2469
2961
|
}
|
|
2470
2962
|
});
|
|
2471
2963
|
this._params = _params;
|
|
@@ -2490,7 +2982,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2490
2982
|
};
|
|
2491
2983
|
|
|
2492
2984
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2493
|
-
function
|
|
2985
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
2494
2986
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2495
2987
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2496
2988
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2500,19 +2992,19 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
2500
2992
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2501
2993
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2502
2994
|
}
|
|
2503
|
-
var
|
|
2995
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2996
|
+
var ENABLE_FEED_PURGE = false;
|
|
2504
2997
|
var DataSpace = class DataSpace2 {
|
|
2505
2998
|
constructor(params) {
|
|
2506
|
-
this._ctx = new
|
|
2999
|
+
this._ctx = new import_context7.Context();
|
|
2507
3000
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2508
|
-
this._state =
|
|
3001
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
2509
3002
|
/**
|
|
2510
3003
|
* Error for _state === SpaceState.ERROR.
|
|
2511
3004
|
*/
|
|
2512
3005
|
this.error = void 0;
|
|
2513
3006
|
this.stateUpdate = new import_async11.Event();
|
|
2514
3007
|
this.metrics = {};
|
|
2515
|
-
var _a;
|
|
2516
3008
|
this._inner = params.inner;
|
|
2517
3009
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
2518
3010
|
this._gossip = params.gossip;
|
|
@@ -2521,7 +3013,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2521
3013
|
this._feedStore = params.feedStore;
|
|
2522
3014
|
this._metadataStore = params.metadataStore;
|
|
2523
3015
|
this._signingContext = params.signingContext;
|
|
2524
|
-
this._callbacks =
|
|
3016
|
+
this._callbacks = params.callbacks ?? {};
|
|
2525
3017
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2526
3018
|
trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2527
3019
|
update: this._inner.stateUpdate,
|
|
@@ -2561,21 +3053,20 @@ var DataSpace = class DataSpace2 {
|
|
|
2561
3053
|
async _open() {
|
|
2562
3054
|
await this._notarizationPlugin.open();
|
|
2563
3055
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2564
|
-
await this._inner.open();
|
|
2565
|
-
this._state =
|
|
3056
|
+
await this._inner.open(new import_context7.Context());
|
|
3057
|
+
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
2566
3058
|
this.stateUpdate.emit();
|
|
2567
3059
|
this.metrics = {};
|
|
2568
|
-
this.metrics.open = new Date();
|
|
3060
|
+
this.metrics.open = /* @__PURE__ */ new Date();
|
|
2569
3061
|
}
|
|
2570
3062
|
async close() {
|
|
2571
3063
|
await this._close();
|
|
2572
3064
|
}
|
|
2573
3065
|
async _close() {
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
this._state = import_services6.SpaceState.CLOSED;
|
|
3066
|
+
await this._callbacks.beforeClose?.();
|
|
3067
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
2577
3068
|
await this._ctx.dispose();
|
|
2578
|
-
this._ctx = new
|
|
3069
|
+
this._ctx = new import_context7.Context();
|
|
2579
3070
|
await this.authVerifier.close();
|
|
2580
3071
|
await this._inner.close();
|
|
2581
3072
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
@@ -2594,47 +3085,46 @@ var DataSpace = class DataSpace2 {
|
|
|
2594
3085
|
initializeDataPipelineAsync() {
|
|
2595
3086
|
(0, import_async11.scheduleTask)(this._ctx, async () => {
|
|
2596
3087
|
try {
|
|
2597
|
-
this.metrics.pipelineInitBegin = new Date();
|
|
3088
|
+
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
2598
3089
|
await this.initializeDataPipeline();
|
|
2599
3090
|
} catch (err) {
|
|
2600
3091
|
if (err instanceof import_errors3.CancelledError) {
|
|
2601
|
-
(0,
|
|
2602
|
-
F:
|
|
2603
|
-
L:
|
|
3092
|
+
(0, import_log10.log)("data pipeline initialization cancelled", err, {
|
|
3093
|
+
F: __dxlog_file12,
|
|
3094
|
+
L: 199,
|
|
2604
3095
|
S: this,
|
|
2605
3096
|
C: (f, a) => f(...a)
|
|
2606
3097
|
});
|
|
2607
3098
|
return;
|
|
2608
3099
|
}
|
|
2609
|
-
|
|
2610
|
-
F:
|
|
2611
|
-
L:
|
|
3100
|
+
import_log10.log.error("Error initializing data pipeline", err, {
|
|
3101
|
+
F: __dxlog_file12,
|
|
3102
|
+
L: 203,
|
|
2612
3103
|
S: this,
|
|
2613
3104
|
C: (f, a) => f(...a)
|
|
2614
3105
|
});
|
|
2615
|
-
this._state =
|
|
3106
|
+
this._state = import_services7.SpaceState.ERROR;
|
|
2616
3107
|
this.error = err;
|
|
2617
3108
|
this.stateUpdate.emit();
|
|
2618
3109
|
} finally {
|
|
2619
|
-
this.metrics.ready = new Date();
|
|
3110
|
+
this.metrics.ready = /* @__PURE__ */ new Date();
|
|
2620
3111
|
}
|
|
2621
3112
|
});
|
|
2622
3113
|
}
|
|
2623
3114
|
async initializeDataPipeline() {
|
|
2624
|
-
|
|
2625
|
-
if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
|
|
3115
|
+
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
2626
3116
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2627
3117
|
}
|
|
2628
|
-
this._state =
|
|
3118
|
+
this._state = import_services7.SpaceState.INITIALIZING;
|
|
2629
3119
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2630
3120
|
ctx: this._ctx,
|
|
2631
3121
|
breakOnStall: false
|
|
2632
3122
|
});
|
|
2633
|
-
this.metrics.controlPipelineReady = new Date();
|
|
3123
|
+
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
2634
3124
|
await this._createWritableFeeds();
|
|
2635
|
-
(0,
|
|
2636
|
-
F:
|
|
2637
|
-
L:
|
|
3125
|
+
(0, import_log10.log)("writable feeds created", void 0, {
|
|
3126
|
+
F: __dxlog_file12,
|
|
3127
|
+
L: 227,
|
|
2638
3128
|
S: this,
|
|
2639
3129
|
C: (f, a) => f(...a)
|
|
2640
3130
|
});
|
|
@@ -2647,11 +3137,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2647
3137
|
}), this._inner.controlPipeline.writer));
|
|
2648
3138
|
}
|
|
2649
3139
|
await this._inner.initializeDataPipeline();
|
|
2650
|
-
this.metrics.dataPipelineOpen = new Date();
|
|
2651
|
-
await (0,
|
|
2652
|
-
(0,
|
|
2653
|
-
F:
|
|
2654
|
-
L:
|
|
3140
|
+
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
3141
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3142
|
+
(0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3143
|
+
F: __dxlog_file12,
|
|
3144
|
+
L: 248,
|
|
2655
3145
|
S: this,
|
|
2656
3146
|
C: (f, a) => f(...a)
|
|
2657
3147
|
});
|
|
@@ -2659,17 +3149,17 @@ var DataSpace = class DataSpace2 {
|
|
|
2659
3149
|
ctx: this._ctx,
|
|
2660
3150
|
breakOnStall: false
|
|
2661
3151
|
});
|
|
2662
|
-
this.metrics.dataPipelineReady = new Date();
|
|
2663
|
-
(0,
|
|
2664
|
-
F:
|
|
2665
|
-
L:
|
|
3152
|
+
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3153
|
+
(0, import_log10.log)("data pipeline ready", void 0, {
|
|
3154
|
+
F: __dxlog_file12,
|
|
3155
|
+
L: 257,
|
|
2666
3156
|
S: this,
|
|
2667
3157
|
C: (f, a) => f(...a)
|
|
2668
3158
|
});
|
|
2669
|
-
await
|
|
2670
|
-
this._state =
|
|
3159
|
+
await this._callbacks.beforeReady?.();
|
|
3160
|
+
this._state = import_services7.SpaceState.READY;
|
|
2671
3161
|
this.stateUpdate.emit();
|
|
2672
|
-
await
|
|
3162
|
+
await this._callbacks.afterReady?.();
|
|
2673
3163
|
}
|
|
2674
3164
|
async _createWritableFeeds() {
|
|
2675
3165
|
const credentials = [];
|
|
@@ -2685,7 +3175,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2685
3175
|
spaceKey: this.key,
|
|
2686
3176
|
deviceKey: this._signingContext.deviceKey,
|
|
2687
3177
|
identityKey: this._signingContext.identityKey,
|
|
2688
|
-
designation:
|
|
3178
|
+
designation: import_credentials10.AdmittedFeed.Designation.CONTROL
|
|
2689
3179
|
}
|
|
2690
3180
|
}));
|
|
2691
3181
|
}
|
|
@@ -2702,7 +3192,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2702
3192
|
spaceKey: this.key,
|
|
2703
3193
|
deviceKey: this._signingContext.deviceKey,
|
|
2704
3194
|
identityKey: this._signingContext.identityKey,
|
|
2705
|
-
designation:
|
|
3195
|
+
designation: import_credentials10.AdmittedFeed.Designation.DATA
|
|
2706
3196
|
}
|
|
2707
3197
|
}));
|
|
2708
3198
|
}
|
|
@@ -2716,7 +3206,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2716
3206
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
2717
3207
|
}
|
|
2718
3208
|
async createEpoch() {
|
|
2719
|
-
var _a, _b;
|
|
2720
3209
|
const epoch = await this.dataPipeline.createEpoch();
|
|
2721
3210
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
2722
3211
|
credential: {
|
|
@@ -2729,65 +3218,67 @@ var DataSpace = class DataSpace2 {
|
|
|
2729
3218
|
})
|
|
2730
3219
|
}
|
|
2731
3220
|
});
|
|
2732
|
-
await this.inner.controlPipeline.state.waitUntilTimeframe(new
|
|
3221
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
|
|
2733
3222
|
[
|
|
2734
3223
|
receipt.feedKey,
|
|
2735
3224
|
receipt.seq
|
|
2736
3225
|
]
|
|
2737
3226
|
]));
|
|
2738
|
-
|
|
2739
|
-
const
|
|
2740
|
-
|
|
2741
|
-
|
|
3227
|
+
if (ENABLE_FEED_PURGE) {
|
|
3228
|
+
for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
|
|
3229
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
3230
|
+
if (indexBeforeEpoch === void 0) {
|
|
3231
|
+
continue;
|
|
3232
|
+
}
|
|
3233
|
+
await feed.safeClear(0, indexBeforeEpoch + 1);
|
|
2742
3234
|
}
|
|
2743
3235
|
}
|
|
2744
3236
|
}
|
|
2745
3237
|
async activate() {
|
|
2746
|
-
if (this._state !==
|
|
3238
|
+
if (this._state !== import_services7.SpaceState.INACTIVE) {
|
|
2747
3239
|
return;
|
|
2748
3240
|
}
|
|
2749
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3241
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
|
|
2750
3242
|
await this._open();
|
|
2751
3243
|
this.initializeDataPipelineAsync();
|
|
2752
3244
|
}
|
|
2753
3245
|
async deactivate() {
|
|
2754
|
-
if (this._state ===
|
|
3246
|
+
if (this._state === import_services7.SpaceState.INACTIVE) {
|
|
2755
3247
|
return;
|
|
2756
3248
|
}
|
|
2757
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3249
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
|
|
2758
3250
|
await this._close();
|
|
2759
|
-
this._state =
|
|
3251
|
+
this._state = import_services7.SpaceState.INACTIVE;
|
|
2760
3252
|
this.stateUpdate.emit();
|
|
2761
3253
|
}
|
|
2762
3254
|
};
|
|
2763
|
-
|
|
3255
|
+
_ts_decorate3([
|
|
2764
3256
|
import_async11.synchronized
|
|
2765
3257
|
], DataSpace.prototype, "open", null);
|
|
2766
|
-
|
|
3258
|
+
_ts_decorate3([
|
|
2767
3259
|
import_async11.synchronized
|
|
2768
3260
|
], DataSpace.prototype, "close", null);
|
|
2769
|
-
|
|
3261
|
+
_ts_decorate3([
|
|
2770
3262
|
(0, import_debug4.timed)(1e4)
|
|
2771
3263
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2772
|
-
|
|
3264
|
+
_ts_decorate3([
|
|
2773
3265
|
import_async11.synchronized
|
|
2774
3266
|
], DataSpace.prototype, "activate", null);
|
|
2775
|
-
|
|
3267
|
+
_ts_decorate3([
|
|
2776
3268
|
import_async11.synchronized
|
|
2777
3269
|
], DataSpace.prototype, "deactivate", null);
|
|
2778
|
-
DataSpace =
|
|
3270
|
+
DataSpace = _ts_decorate3([
|
|
2779
3271
|
(0, import_async11.trackLeaks)("open", "close")
|
|
2780
3272
|
], DataSpace);
|
|
2781
3273
|
|
|
2782
3274
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
2783
|
-
var
|
|
3275
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
2784
3276
|
var import_debug5 = require("@dxos/debug");
|
|
2785
|
-
var
|
|
2786
|
-
var
|
|
3277
|
+
var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
3278
|
+
var import_timeframe3 = require("@dxos/timeframe");
|
|
2787
3279
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
2788
|
-
var _a, _b, _c, _d;
|
|
2789
3280
|
const credentials = [
|
|
2790
|
-
await (0,
|
|
3281
|
+
await (0, import_credentials11.createCredential)({
|
|
2791
3282
|
signer: keyring,
|
|
2792
3283
|
issuer: space.key,
|
|
2793
3284
|
subject: space.key,
|
|
@@ -2796,45 +3287,45 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2796
3287
|
spaceKey: space.key
|
|
2797
3288
|
}
|
|
2798
3289
|
}),
|
|
2799
|
-
await (0,
|
|
3290
|
+
await (0, import_credentials11.createCredential)({
|
|
2800
3291
|
signer: keyring,
|
|
2801
3292
|
issuer: space.key,
|
|
2802
3293
|
subject: signingContext.identityKey,
|
|
2803
3294
|
assertion: {
|
|
2804
3295
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
2805
3296
|
spaceKey: space.key,
|
|
2806
|
-
role:
|
|
3297
|
+
role: import_credentials12.SpaceMember.Role.ADMIN,
|
|
2807
3298
|
profile: signingContext.profile,
|
|
2808
|
-
genesisFeedKey:
|
|
3299
|
+
genesisFeedKey: space.controlFeedKey ?? (0, import_debug5.failUndefined)()
|
|
2809
3300
|
}
|
|
2810
3301
|
}),
|
|
2811
3302
|
await signingContext.credentialSigner.createCredential({
|
|
2812
|
-
subject:
|
|
3303
|
+
subject: space.controlFeedKey ?? (0, import_debug5.failUndefined)(),
|
|
2813
3304
|
assertion: {
|
|
2814
3305
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2815
3306
|
spaceKey: space.key,
|
|
2816
3307
|
identityKey: signingContext.identityKey,
|
|
2817
3308
|
deviceKey: signingContext.deviceKey,
|
|
2818
|
-
designation:
|
|
3309
|
+
designation: import_credentials12.AdmittedFeed.Designation.CONTROL
|
|
2819
3310
|
}
|
|
2820
3311
|
}),
|
|
2821
3312
|
await signingContext.credentialSigner.createCredential({
|
|
2822
|
-
subject:
|
|
3313
|
+
subject: space.dataFeedKey ?? (0, import_debug5.failUndefined)(),
|
|
2823
3314
|
assertion: {
|
|
2824
3315
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2825
3316
|
spaceKey: space.key,
|
|
2826
3317
|
identityKey: signingContext.identityKey,
|
|
2827
3318
|
deviceKey: signingContext.deviceKey,
|
|
2828
|
-
designation:
|
|
3319
|
+
designation: import_credentials12.AdmittedFeed.Designation.DATA
|
|
2829
3320
|
}
|
|
2830
3321
|
}),
|
|
2831
3322
|
await signingContext.credentialSigner.createCredential({
|
|
2832
|
-
subject:
|
|
3323
|
+
subject: space.key ?? (0, import_debug5.failUndefined)(),
|
|
2833
3324
|
assertion: {
|
|
2834
3325
|
"@type": "dxos.halo.credentials.Epoch",
|
|
2835
3326
|
number: 0,
|
|
2836
3327
|
previousId: void 0,
|
|
2837
|
-
timeframe: new
|
|
3328
|
+
timeframe: new import_timeframe3.Timeframe(),
|
|
2838
3329
|
snapshotCid: void 0
|
|
2839
3330
|
}
|
|
2840
3331
|
})
|
|
@@ -2850,7 +3341,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2850
3341
|
};
|
|
2851
3342
|
|
|
2852
3343
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2853
|
-
function
|
|
3344
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
2854
3345
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2855
3346
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2856
3347
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2860,7 +3351,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
2860
3351
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2861
3352
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2862
3353
|
}
|
|
2863
|
-
var
|
|
3354
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2864
3355
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2865
3356
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2866
3357
|
this._spaceManager = _spaceManager;
|
|
@@ -2869,7 +3360,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2869
3360
|
this._keyring = _keyring;
|
|
2870
3361
|
this._signingContext = _signingContext;
|
|
2871
3362
|
this._feedStore = _feedStore;
|
|
2872
|
-
this._ctx = new
|
|
3363
|
+
this._ctx = new import_context8.Context();
|
|
2873
3364
|
this.updated = new import_async12.Event();
|
|
2874
3365
|
this._spaces = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
|
|
2875
3366
|
this._isOpen = false;
|
|
@@ -2880,50 +3371,50 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2880
3371
|
return this._spaces;
|
|
2881
3372
|
}
|
|
2882
3373
|
async open() {
|
|
2883
|
-
(0,
|
|
2884
|
-
F:
|
|
2885
|
-
L:
|
|
3374
|
+
(0, import_log11.log)("open", void 0, {
|
|
3375
|
+
F: __dxlog_file13,
|
|
3376
|
+
L: 79,
|
|
2886
3377
|
S: this,
|
|
2887
3378
|
C: (f, a) => f(...a)
|
|
2888
3379
|
});
|
|
2889
|
-
|
|
3380
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.begin({
|
|
2890
3381
|
id: this._instanceId
|
|
2891
3382
|
}), {
|
|
2892
|
-
F:
|
|
2893
|
-
L:
|
|
3383
|
+
F: __dxlog_file13,
|
|
3384
|
+
L: 80,
|
|
2894
3385
|
S: this,
|
|
2895
3386
|
C: (f, a) => f(...a)
|
|
2896
3387
|
});
|
|
2897
3388
|
await this._metadataStore.load();
|
|
2898
|
-
(0,
|
|
3389
|
+
(0, import_log11.log)("metadata loaded", {
|
|
2899
3390
|
spaces: this._metadataStore.spaces.length
|
|
2900
3391
|
}, {
|
|
2901
|
-
F:
|
|
2902
|
-
L:
|
|
3392
|
+
F: __dxlog_file13,
|
|
3393
|
+
L: 82,
|
|
2903
3394
|
S: this,
|
|
2904
3395
|
C: (f, a) => f(...a)
|
|
2905
3396
|
});
|
|
2906
3397
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2907
3398
|
try {
|
|
2908
|
-
(0,
|
|
3399
|
+
(0, import_log11.log)("load space", {
|
|
2909
3400
|
spaceMetadata
|
|
2910
3401
|
}, {
|
|
2911
|
-
F:
|
|
2912
|
-
L:
|
|
3402
|
+
F: __dxlog_file13,
|
|
3403
|
+
L: 86,
|
|
2913
3404
|
S: this,
|
|
2914
3405
|
C: (f, a) => f(...a)
|
|
2915
3406
|
});
|
|
2916
3407
|
const space = await this._constructSpace(spaceMetadata);
|
|
2917
|
-
if (spaceMetadata.state !==
|
|
3408
|
+
if (spaceMetadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
2918
3409
|
space.initializeDataPipelineAsync();
|
|
2919
3410
|
}
|
|
2920
3411
|
} catch (err) {
|
|
2921
|
-
|
|
3412
|
+
import_log11.log.error("Error loading space", {
|
|
2922
3413
|
spaceMetadata,
|
|
2923
3414
|
err
|
|
2924
3415
|
}, {
|
|
2925
|
-
F:
|
|
2926
|
-
L:
|
|
3416
|
+
F: __dxlog_file13,
|
|
3417
|
+
L: 92,
|
|
2927
3418
|
S: this,
|
|
2928
3419
|
C: (f, a) => f(...a)
|
|
2929
3420
|
});
|
|
@@ -2931,19 +3422,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2931
3422
|
}
|
|
2932
3423
|
this._isOpen = true;
|
|
2933
3424
|
this.updated.emit();
|
|
2934
|
-
|
|
3425
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.end({
|
|
2935
3426
|
id: this._instanceId
|
|
2936
3427
|
}), {
|
|
2937
|
-
F:
|
|
2938
|
-
L:
|
|
3428
|
+
F: __dxlog_file13,
|
|
3429
|
+
L: 98,
|
|
2939
3430
|
S: this,
|
|
2940
3431
|
C: (f, a) => f(...a)
|
|
2941
3432
|
});
|
|
2942
3433
|
}
|
|
2943
3434
|
async close() {
|
|
2944
|
-
(0,
|
|
2945
|
-
F:
|
|
2946
|
-
L:
|
|
3435
|
+
(0, import_log11.log)("close", void 0, {
|
|
3436
|
+
F: __dxlog_file13,
|
|
3437
|
+
L: 103,
|
|
2947
3438
|
S: this,
|
|
2948
3439
|
C: (f, a) => f(...a)
|
|
2949
3440
|
});
|
|
@@ -2957,7 +3448,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2957
3448
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2958
3449
|
*/
|
|
2959
3450
|
async createSpace() {
|
|
2960
|
-
(0,
|
|
3451
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3452
|
+
F: __dxlog_file13,
|
|
3453
|
+
L: 116,
|
|
3454
|
+
S: this,
|
|
3455
|
+
A: [
|
|
3456
|
+
"this._isOpen",
|
|
3457
|
+
"'Not open.'"
|
|
3458
|
+
]
|
|
3459
|
+
});
|
|
2961
3460
|
const spaceKey = await this._keyring.createKey();
|
|
2962
3461
|
const controlFeedKey = await this._keyring.createKey();
|
|
2963
3462
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2966,13 +3465,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2966
3465
|
genesisFeedKey: controlFeedKey,
|
|
2967
3466
|
controlFeedKey,
|
|
2968
3467
|
dataFeedKey,
|
|
2969
|
-
state:
|
|
3468
|
+
state: import_services8.SpaceState.ACTIVE
|
|
2970
3469
|
};
|
|
2971
|
-
(0,
|
|
3470
|
+
(0, import_log11.log)("creating space...", {
|
|
2972
3471
|
spaceKey
|
|
2973
3472
|
}, {
|
|
2974
|
-
F:
|
|
2975
|
-
L:
|
|
3473
|
+
F: __dxlog_file13,
|
|
3474
|
+
L: 128,
|
|
2976
3475
|
S: this,
|
|
2977
3476
|
C: (f, a) => f(...a)
|
|
2978
3477
|
});
|
|
@@ -2980,7 +3479,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2980
3479
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2981
3480
|
await this._metadataStore.addSpace(metadata);
|
|
2982
3481
|
const memberCredential = credentials[1];
|
|
2983
|
-
(0,
|
|
3482
|
+
(0, import_invariant11.invariant)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3483
|
+
F: __dxlog_file13,
|
|
3484
|
+
L: 135,
|
|
3485
|
+
S: this,
|
|
3486
|
+
A: [
|
|
3487
|
+
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
3488
|
+
""
|
|
3489
|
+
]
|
|
3490
|
+
});
|
|
2984
3491
|
await this._signingContext.recordCredential(memberCredential);
|
|
2985
3492
|
await space.initializeDataPipeline();
|
|
2986
3493
|
this.updated.emit();
|
|
@@ -2988,16 +3495,32 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2988
3495
|
}
|
|
2989
3496
|
// TODO(burdon): Rename join space.
|
|
2990
3497
|
async acceptSpace(opts) {
|
|
2991
|
-
(0,
|
|
3498
|
+
(0, import_log11.log)("accept space", {
|
|
2992
3499
|
opts
|
|
2993
3500
|
}, {
|
|
2994
|
-
F:
|
|
2995
|
-
L:
|
|
3501
|
+
F: __dxlog_file13,
|
|
3502
|
+
L: 147,
|
|
2996
3503
|
S: this,
|
|
2997
3504
|
C: (f, a) => f(...a)
|
|
2998
3505
|
});
|
|
2999
|
-
(0,
|
|
3000
|
-
|
|
3506
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3507
|
+
F: __dxlog_file13,
|
|
3508
|
+
L: 148,
|
|
3509
|
+
S: this,
|
|
3510
|
+
A: [
|
|
3511
|
+
"this._isOpen",
|
|
3512
|
+
"'Not open.'"
|
|
3513
|
+
]
|
|
3514
|
+
});
|
|
3515
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3516
|
+
F: __dxlog_file13,
|
|
3517
|
+
L: 149,
|
|
3518
|
+
S: this,
|
|
3519
|
+
A: [
|
|
3520
|
+
"!this._spaces.has(opts.spaceKey)",
|
|
3521
|
+
"'Space already exists.'"
|
|
3522
|
+
]
|
|
3523
|
+
});
|
|
3001
3524
|
const metadata = {
|
|
3002
3525
|
key: opts.spaceKey,
|
|
3003
3526
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -3016,17 +3539,17 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3016
3539
|
* TODO(dmaretskyi): Consider removing.
|
|
3017
3540
|
*/
|
|
3018
3541
|
async waitUntilSpaceReady(spaceKey) {
|
|
3019
|
-
await (0,
|
|
3542
|
+
await (0, import_context8.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
3020
3543
|
const space = this._spaces.get(spaceKey);
|
|
3021
|
-
return !!space && space.state ===
|
|
3544
|
+
return !!space && space.state === import_services8.SpaceState.READY;
|
|
3022
3545
|
}));
|
|
3023
3546
|
}
|
|
3024
3547
|
async _constructSpace(metadata) {
|
|
3025
|
-
(0,
|
|
3548
|
+
(0, import_log11.log)("construct space", {
|
|
3026
3549
|
metadata
|
|
3027
3550
|
}, {
|
|
3028
|
-
F:
|
|
3029
|
-
L:
|
|
3551
|
+
F: __dxlog_file13,
|
|
3552
|
+
L: 182,
|
|
3030
3553
|
S: this,
|
|
3031
3554
|
C: (f, a) => f(...a)
|
|
3032
3555
|
});
|
|
@@ -3034,7 +3557,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3034
3557
|
localPeerId: this._signingContext.deviceKey
|
|
3035
3558
|
});
|
|
3036
3559
|
const presence = new import_teleport_extension_gossip.Presence({
|
|
3037
|
-
announceInterval:
|
|
3560
|
+
announceInterval: 1e3,
|
|
3038
3561
|
offlineTimeout: 5e3,
|
|
3039
3562
|
identityKey: this._signingContext.identityKey,
|
|
3040
3563
|
gossip
|
|
@@ -3060,9 +3583,9 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3060
3583
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3061
3584
|
},
|
|
3062
3585
|
onAuthFailure: () => {
|
|
3063
|
-
|
|
3064
|
-
F:
|
|
3065
|
-
L:
|
|
3586
|
+
import_log11.log.warn("auth failure", void 0, {
|
|
3587
|
+
F: __dxlog_file13,
|
|
3588
|
+
L: 217,
|
|
3066
3589
|
S: this,
|
|
3067
3590
|
C: (f, a) => f(...a)
|
|
3068
3591
|
});
|
|
@@ -3073,7 +3596,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3073
3596
|
dataFeed && space.setDataFeed(dataFeed);
|
|
3074
3597
|
const dataSpace = new DataSpace({
|
|
3075
3598
|
inner: space,
|
|
3076
|
-
initialState: metadata.state ===
|
|
3599
|
+
initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
|
|
3077
3600
|
metadataStore: this._metadataStore,
|
|
3078
3601
|
gossip,
|
|
3079
3602
|
presence,
|
|
@@ -3082,23 +3605,23 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3082
3605
|
signingContext: this._signingContext,
|
|
3083
3606
|
callbacks: {
|
|
3084
3607
|
beforeReady: async () => {
|
|
3085
|
-
(0,
|
|
3608
|
+
(0, import_log11.log)("before space ready", {
|
|
3086
3609
|
space: space.key
|
|
3087
3610
|
}, {
|
|
3088
|
-
F:
|
|
3089
|
-
L:
|
|
3611
|
+
F: __dxlog_file13,
|
|
3612
|
+
L: 235,
|
|
3090
3613
|
S: this,
|
|
3091
3614
|
C: (f, a) => f(...a)
|
|
3092
3615
|
});
|
|
3093
3616
|
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
3094
3617
|
},
|
|
3095
3618
|
afterReady: async () => {
|
|
3096
|
-
(0,
|
|
3619
|
+
(0, import_log11.log)("after space ready", {
|
|
3097
3620
|
space: space.key,
|
|
3098
3621
|
open: this._isOpen
|
|
3099
3622
|
}, {
|
|
3100
|
-
F:
|
|
3101
|
-
L:
|
|
3623
|
+
F: __dxlog_file13,
|
|
3624
|
+
L: 242,
|
|
3102
3625
|
S: this,
|
|
3103
3626
|
C: (f, a) => f(...a)
|
|
3104
3627
|
});
|
|
@@ -3107,11 +3630,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3107
3630
|
}
|
|
3108
3631
|
},
|
|
3109
3632
|
beforeClose: async () => {
|
|
3110
|
-
(0,
|
|
3633
|
+
(0, import_log11.log)("before space close", {
|
|
3111
3634
|
space: space.key
|
|
3112
3635
|
}, {
|
|
3113
|
-
F:
|
|
3114
|
-
L:
|
|
3636
|
+
F: __dxlog_file13,
|
|
3637
|
+
L: 248,
|
|
3115
3638
|
S: this,
|
|
3116
3639
|
C: (f, a) => f(...a)
|
|
3117
3640
|
});
|
|
@@ -3120,7 +3643,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3120
3643
|
},
|
|
3121
3644
|
cache: metadata.cache
|
|
3122
3645
|
});
|
|
3123
|
-
if (metadata.state !==
|
|
3646
|
+
if (metadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
3124
3647
|
await dataSpace.open();
|
|
3125
3648
|
}
|
|
3126
3649
|
if (metadata.controlTimeframe) {
|
|
@@ -3133,33 +3656,33 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3133
3656
|
return dataSpace;
|
|
3134
3657
|
}
|
|
3135
3658
|
};
|
|
3136
|
-
|
|
3659
|
+
_ts_decorate4([
|
|
3137
3660
|
import_async12.synchronized
|
|
3138
3661
|
], DataSpaceManager.prototype, "open", null);
|
|
3139
|
-
|
|
3662
|
+
_ts_decorate4([
|
|
3140
3663
|
import_async12.synchronized
|
|
3141
3664
|
], DataSpaceManager.prototype, "close", null);
|
|
3142
|
-
|
|
3665
|
+
_ts_decorate4([
|
|
3143
3666
|
import_async12.synchronized
|
|
3144
3667
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3145
|
-
|
|
3668
|
+
_ts_decorate4([
|
|
3146
3669
|
import_async12.synchronized
|
|
3147
3670
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3148
|
-
DataSpaceManager =
|
|
3671
|
+
DataSpaceManager = _ts_decorate4([
|
|
3149
3672
|
(0, import_async12.trackLeaks)("open", "close")
|
|
3150
3673
|
], DataSpaceManager);
|
|
3151
3674
|
|
|
3152
3675
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
3153
3676
|
var import_async13 = require("@dxos/async");
|
|
3154
|
-
var
|
|
3677
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
3155
3678
|
var import_debug6 = require("@dxos/debug");
|
|
3156
3679
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
3157
3680
|
var import_errors4 = require("@dxos/errors");
|
|
3158
|
-
var
|
|
3159
|
-
var
|
|
3160
|
-
var
|
|
3681
|
+
var import_log12 = require("@dxos/log");
|
|
3682
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
3683
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3161
3684
|
var import_util6 = require("@dxos/util");
|
|
3162
|
-
var
|
|
3685
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
3163
3686
|
var SpacesServiceImpl = class {
|
|
3164
3687
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
3165
3688
|
this._identityManager = _identityManager;
|
|
@@ -3176,15 +3699,14 @@ var SpacesServiceImpl = class {
|
|
|
3176
3699
|
return this._serializeSpace(space);
|
|
3177
3700
|
}
|
|
3178
3701
|
async updateSpace({ spaceKey, state }) {
|
|
3179
|
-
var _a;
|
|
3180
3702
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3181
|
-
const space =
|
|
3703
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3182
3704
|
if (state) {
|
|
3183
3705
|
switch (state) {
|
|
3184
|
-
case
|
|
3706
|
+
case import_services9.SpaceState.ACTIVE:
|
|
3185
3707
|
await space.activate();
|
|
3186
3708
|
break;
|
|
3187
|
-
case
|
|
3709
|
+
case import_services9.SpaceState.INACTIVE:
|
|
3188
3710
|
await space.deactivate();
|
|
3189
3711
|
break;
|
|
3190
3712
|
default:
|
|
@@ -3193,14 +3715,14 @@ var SpacesServiceImpl = class {
|
|
|
3193
3715
|
}
|
|
3194
3716
|
}
|
|
3195
3717
|
querySpaces() {
|
|
3196
|
-
return new
|
|
3718
|
+
return new import_codec_protobuf11.Stream(({ next, ctx }) => {
|
|
3197
3719
|
const scheduler = new import_async13.UpdateScheduler(ctx, async () => {
|
|
3198
3720
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3199
3721
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
3200
|
-
(0,
|
|
3722
|
+
(0, import_log12.log)("update", {
|
|
3201
3723
|
spaces
|
|
3202
3724
|
}, {
|
|
3203
|
-
F:
|
|
3725
|
+
F: __dxlog_file14,
|
|
3204
3726
|
L: 78,
|
|
3205
3727
|
S: this,
|
|
3206
3728
|
C: (f, a) => f(...a)
|
|
@@ -3209,7 +3731,7 @@ var SpacesServiceImpl = class {
|
|
|
3209
3731
|
spaces
|
|
3210
3732
|
});
|
|
3211
3733
|
}, {
|
|
3212
|
-
maxFrequency: 2
|
|
3734
|
+
maxFrequency: process.env.NODE_ENV === "test" ? void 0 : 2
|
|
3213
3735
|
});
|
|
3214
3736
|
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3215
3737
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
@@ -3242,17 +3764,15 @@ var SpacesServiceImpl = class {
|
|
|
3242
3764
|
});
|
|
3243
3765
|
}
|
|
3244
3766
|
async postMessage({ spaceKey, channel, message }) {
|
|
3245
|
-
var _a;
|
|
3246
3767
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3247
|
-
const space =
|
|
3768
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3248
3769
|
await space.postMessage(getChannelId(channel), message);
|
|
3249
3770
|
}
|
|
3250
3771
|
subscribeMessages({ spaceKey, channel }) {
|
|
3251
|
-
return new
|
|
3772
|
+
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3252
3773
|
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3253
|
-
var _a;
|
|
3254
3774
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3255
|
-
const space =
|
|
3775
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3256
3776
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3257
3777
|
next(message);
|
|
3258
3778
|
});
|
|
@@ -3261,9 +3781,8 @@ var SpacesServiceImpl = class {
|
|
|
3261
3781
|
});
|
|
3262
3782
|
}
|
|
3263
3783
|
queryCredentials({ spaceKey }) {
|
|
3264
|
-
return new
|
|
3265
|
-
|
|
3266
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3784
|
+
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3785
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3267
3786
|
const processor = {
|
|
3268
3787
|
processCredential: async (credential) => {
|
|
3269
3788
|
next(credential);
|
|
@@ -3274,9 +3793,8 @@ var SpacesServiceImpl = class {
|
|
|
3274
3793
|
});
|
|
3275
3794
|
}
|
|
3276
3795
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
for (const credential of credentials != null ? credentials : []) {
|
|
3796
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3797
|
+
for (const credential of credentials ?? []) {
|
|
3280
3798
|
await space.controlPipeline.writer.write({
|
|
3281
3799
|
credential: {
|
|
3282
3800
|
credential
|
|
@@ -3285,17 +3803,15 @@ var SpacesServiceImpl = class {
|
|
|
3285
3803
|
}
|
|
3286
3804
|
}
|
|
3287
3805
|
async createEpoch({ spaceKey }) {
|
|
3288
|
-
var _a;
|
|
3289
3806
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3290
|
-
const space =
|
|
3807
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3291
3808
|
await space.createEpoch();
|
|
3292
3809
|
}
|
|
3293
3810
|
_serializeSpace(space) {
|
|
3294
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3295
3811
|
return {
|
|
3296
3812
|
spaceKey: space.key,
|
|
3297
3813
|
state: space.state,
|
|
3298
|
-
error: space.error ? (0,
|
|
3814
|
+
error: space.error ? (0, import_protocols8.encodeError)(space.error) : void 0,
|
|
3299
3815
|
pipeline: {
|
|
3300
3816
|
currentEpoch: space.dataPipeline.currentEpoch,
|
|
3301
3817
|
appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
@@ -3303,25 +3819,30 @@ var SpacesServiceImpl = class {
|
|
|
3303
3819
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
3304
3820
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
3305
3821
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
3306
|
-
dataFeeds:
|
|
3307
|
-
startDataTimeframe:
|
|
3308
|
-
currentDataTimeframe:
|
|
3309
|
-
targetDataTimeframe:
|
|
3310
|
-
totalDataTimeframe:
|
|
3822
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
3823
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
3824
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
3825
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
3826
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
3311
3827
|
},
|
|
3312
3828
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3313
|
-
|
|
3829
|
+
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
3830
|
+
const isMe = this._identityManager.identity?.identityKey.equals(member.key);
|
|
3831
|
+
if (isMe) {
|
|
3832
|
+
peers.push(space.presence.getLocalState());
|
|
3833
|
+
}
|
|
3314
3834
|
return {
|
|
3315
3835
|
identity: {
|
|
3316
3836
|
identityKey: member.key,
|
|
3317
3837
|
profile: {
|
|
3318
|
-
displayName:
|
|
3838
|
+
displayName: member.assertion.profile?.displayName ?? (0, import_util6.humanize)(member.key)
|
|
3319
3839
|
}
|
|
3320
3840
|
},
|
|
3321
|
-
presence:
|
|
3841
|
+
presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
3842
|
+
peerStates: peers
|
|
3322
3843
|
};
|
|
3323
3844
|
}),
|
|
3324
|
-
creator:
|
|
3845
|
+
creator: space.inner.spaceState.creator?.key,
|
|
3325
3846
|
cache: space.cache,
|
|
3326
3847
|
metrics: space.metrics
|
|
3327
3848
|
};
|
|
@@ -3330,8 +3851,18 @@ var SpacesServiceImpl = class {
|
|
|
3330
3851
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3331
3852
|
|
|
3332
3853
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3333
|
-
|
|
3334
|
-
var
|
|
3854
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
3855
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3856
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3857
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3858
|
+
else
|
|
3859
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3860
|
+
if (d = decorators[i])
|
|
3861
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3862
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3863
|
+
}
|
|
3864
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3865
|
+
var ServiceContext = class ServiceContext2 {
|
|
3335
3866
|
// prettier-ignore
|
|
3336
3867
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
3337
3868
|
this.storage = storage;
|
|
@@ -3351,7 +3882,8 @@ var ServiceContext = class {
|
|
|
3351
3882
|
root: storage.createDirectory("feeds"),
|
|
3352
3883
|
signer: this.keyring,
|
|
3353
3884
|
hypercore: {
|
|
3354
|
-
valueEncoding: import_echo_pipeline3.valueEncoding
|
|
3885
|
+
valueEncoding: import_echo_pipeline3.valueEncoding,
|
|
3886
|
+
stats: true
|
|
3355
3887
|
}
|
|
3356
3888
|
})
|
|
3357
3889
|
});
|
|
@@ -3365,105 +3897,108 @@ var ServiceContext = class {
|
|
|
3365
3897
|
});
|
|
3366
3898
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3367
3899
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3368
|
-
this._handlerFactories.set(
|
|
3369
|
-
var _a;
|
|
3370
|
-
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
3371
|
-
}, this._acceptIdentity.bind(this)));
|
|
3900
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
3372
3901
|
}
|
|
3373
|
-
async open() {
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
L: 126,
|
|
3902
|
+
async open(ctx) {
|
|
3903
|
+
await this._checkStorageVersion();
|
|
3904
|
+
(0, import_log13.log)("opening...", void 0, {
|
|
3905
|
+
F: __dxlog_file15,
|
|
3906
|
+
L: 135,
|
|
3379
3907
|
S: this,
|
|
3380
3908
|
C: (f, a) => f(...a)
|
|
3381
3909
|
});
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3910
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.begin({
|
|
3911
|
+
id: this._instanceId
|
|
3912
|
+
}), {
|
|
3913
|
+
F: __dxlog_file15,
|
|
3914
|
+
L: 136,
|
|
3386
3915
|
S: this,
|
|
3387
3916
|
C: (f, a) => f(...a)
|
|
3388
3917
|
});
|
|
3389
3918
|
await this.signalManager.open();
|
|
3390
3919
|
await this.networkManager.open();
|
|
3391
3920
|
await this.spaceManager.open();
|
|
3392
|
-
await this.identityManager.open();
|
|
3921
|
+
await this.identityManager.open(ctx);
|
|
3393
3922
|
if (this.identityManager.identity) {
|
|
3394
|
-
await this._initialize();
|
|
3923
|
+
await this._initialize(ctx);
|
|
3395
3924
|
}
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3925
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.end({
|
|
3926
|
+
id: this._instanceId
|
|
3927
|
+
}), {
|
|
3928
|
+
F: __dxlog_file15,
|
|
3929
|
+
L: 144,
|
|
3399
3930
|
S: this,
|
|
3400
3931
|
C: (f, a) => f(...a)
|
|
3401
3932
|
});
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
F: __dxlog_file12,
|
|
3406
|
-
L: 139,
|
|
3933
|
+
(0, import_log13.log)("opened", void 0, {
|
|
3934
|
+
F: __dxlog_file15,
|
|
3935
|
+
L: 145,
|
|
3407
3936
|
S: this,
|
|
3408
3937
|
C: (f, a) => f(...a)
|
|
3409
3938
|
});
|
|
3410
3939
|
}
|
|
3411
3940
|
async close() {
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
L: 143,
|
|
3941
|
+
(0, import_log13.log)("closing...", void 0, {
|
|
3942
|
+
F: __dxlog_file15,
|
|
3943
|
+
L: 149,
|
|
3416
3944
|
S: this,
|
|
3417
3945
|
C: (f, a) => f(...a)
|
|
3418
3946
|
});
|
|
3419
3947
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3420
3948
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3421
3949
|
}
|
|
3422
|
-
await
|
|
3950
|
+
await this.dataSpaceManager?.close();
|
|
3423
3951
|
await this.identityManager.close();
|
|
3424
3952
|
await this.spaceManager.close();
|
|
3425
3953
|
await this.feedStore.close();
|
|
3426
3954
|
await this.networkManager.close();
|
|
3427
3955
|
await this.signalManager.close();
|
|
3428
3956
|
this.dataServiceSubscriptions.clear();
|
|
3429
|
-
(0,
|
|
3430
|
-
F:
|
|
3431
|
-
L:
|
|
3957
|
+
(0, import_log13.log)("closed", void 0, {
|
|
3958
|
+
F: __dxlog_file15,
|
|
3959
|
+
L: 160,
|
|
3432
3960
|
S: this,
|
|
3433
3961
|
C: (f, a) => f(...a)
|
|
3434
3962
|
});
|
|
3435
3963
|
}
|
|
3436
3964
|
async createIdentity(params = {}) {
|
|
3437
3965
|
const identity = await this.identityManager.createIdentity(params);
|
|
3438
|
-
await this._initialize();
|
|
3966
|
+
await this._initialize(new import_context9.Context());
|
|
3439
3967
|
return identity;
|
|
3440
3968
|
}
|
|
3441
3969
|
getInvitationHandler(invitation) {
|
|
3442
3970
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3443
|
-
(0,
|
|
3971
|
+
(0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3972
|
+
F: __dxlog_file15,
|
|
3973
|
+
L: 171,
|
|
3974
|
+
S: this,
|
|
3975
|
+
A: [
|
|
3976
|
+
"factory",
|
|
3977
|
+
"`Unknown invitation kind: ${invitation.kind}`"
|
|
3978
|
+
]
|
|
3979
|
+
});
|
|
3444
3980
|
return factory(invitation);
|
|
3445
3981
|
}
|
|
3446
3982
|
async _acceptIdentity(params) {
|
|
3447
3983
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
3448
|
-
await this._initialize();
|
|
3984
|
+
await this._initialize(new import_context9.Context());
|
|
3449
3985
|
return identity;
|
|
3450
3986
|
}
|
|
3451
3987
|
async _checkStorageVersion() {
|
|
3452
3988
|
await this.metadataStore.load();
|
|
3453
|
-
if (this.metadataStore.version !==
|
|
3454
|
-
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${
|
|
3989
|
+
if (this.metadataStore.version !== import_protocols9.STORAGE_VERSION) {
|
|
3990
|
+
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols9.STORAGE_VERSION}`);
|
|
3455
3991
|
}
|
|
3456
3992
|
}
|
|
3457
3993
|
// Called when identity is created.
|
|
3458
|
-
async _initialize() {
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
L: 187,
|
|
3994
|
+
async _initialize(ctx) {
|
|
3995
|
+
(0, import_log13.log)("initializing spaces...", void 0, {
|
|
3996
|
+
F: __dxlog_file15,
|
|
3997
|
+
L: 192,
|
|
3463
3998
|
S: this,
|
|
3464
3999
|
C: (f, a) => f(...a)
|
|
3465
4000
|
});
|
|
3466
|
-
const identity =
|
|
4001
|
+
const identity = this.identityManager.identity ?? (0, import_debug7.failUndefined)();
|
|
3467
4002
|
const signingContext = {
|
|
3468
4003
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3469
4004
|
identityKey: identity.identityKey,
|
|
@@ -3479,14 +4014,22 @@ var ServiceContext = class {
|
|
|
3479
4014
|
};
|
|
3480
4015
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3481
4016
|
await this.dataSpaceManager.open();
|
|
3482
|
-
this._handlerFactories.set(
|
|
3483
|
-
(0,
|
|
4017
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
4018
|
+
(0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4019
|
+
F: __dxlog_file15,
|
|
4020
|
+
L: 215,
|
|
4021
|
+
S: this,
|
|
4022
|
+
A: [
|
|
4023
|
+
"this.dataSpaceManager",
|
|
4024
|
+
"'dataSpaceManager not initialized yet'"
|
|
4025
|
+
]
|
|
4026
|
+
});
|
|
3484
4027
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3485
4028
|
});
|
|
3486
4029
|
this.initialized.wake();
|
|
3487
4030
|
this._deviceSpaceSync = {
|
|
3488
4031
|
processCredential: async (credential) => {
|
|
3489
|
-
const assertion = (0,
|
|
4032
|
+
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
3490
4033
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3491
4034
|
return;
|
|
3492
4035
|
}
|
|
@@ -3494,33 +4037,33 @@ var ServiceContext = class {
|
|
|
3494
4037
|
return;
|
|
3495
4038
|
}
|
|
3496
4039
|
if (!this.dataSpaceManager) {
|
|
3497
|
-
(0,
|
|
4040
|
+
(0, import_log13.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3498
4041
|
details: assertion
|
|
3499
4042
|
}, {
|
|
3500
|
-
F:
|
|
3501
|
-
L:
|
|
4043
|
+
F: __dxlog_file15,
|
|
4044
|
+
L: 231,
|
|
3502
4045
|
S: this,
|
|
3503
4046
|
C: (f, a) => f(...a)
|
|
3504
4047
|
});
|
|
3505
4048
|
return;
|
|
3506
4049
|
}
|
|
3507
4050
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3508
|
-
(0,
|
|
4051
|
+
(0, import_log13.log)("space already exists, ignoring space admission", {
|
|
3509
4052
|
details: assertion
|
|
3510
4053
|
}, {
|
|
3511
|
-
F:
|
|
3512
|
-
L:
|
|
4054
|
+
F: __dxlog_file15,
|
|
4055
|
+
L: 235,
|
|
3513
4056
|
S: this,
|
|
3514
4057
|
C: (f, a) => f(...a)
|
|
3515
4058
|
});
|
|
3516
4059
|
return;
|
|
3517
4060
|
}
|
|
3518
4061
|
try {
|
|
3519
|
-
(0,
|
|
4062
|
+
(0, import_log13.log)("accepting space recorded in halo", {
|
|
3520
4063
|
details: assertion
|
|
3521
4064
|
}, {
|
|
3522
|
-
F:
|
|
3523
|
-
L:
|
|
4065
|
+
F: __dxlog_file15,
|
|
4066
|
+
L: 240,
|
|
3524
4067
|
S: this,
|
|
3525
4068
|
C: (f, a) => f(...a)
|
|
3526
4069
|
});
|
|
@@ -3529,9 +4072,9 @@ var ServiceContext = class {
|
|
|
3529
4072
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3530
4073
|
});
|
|
3531
4074
|
} catch (err) {
|
|
3532
|
-
|
|
3533
|
-
F:
|
|
3534
|
-
L:
|
|
4075
|
+
import_log13.log.catch(err, void 0, {
|
|
4076
|
+
F: __dxlog_file15,
|
|
4077
|
+
L: 246,
|
|
3535
4078
|
S: this,
|
|
3536
4079
|
C: (f, a) => f(...a)
|
|
3537
4080
|
});
|
|
@@ -3541,26 +4084,38 @@ var ServiceContext = class {
|
|
|
3541
4084
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3542
4085
|
}
|
|
3543
4086
|
};
|
|
4087
|
+
_ts_decorate5([
|
|
4088
|
+
import_tracing3.trace.span()
|
|
4089
|
+
], ServiceContext.prototype, "open", null);
|
|
4090
|
+
_ts_decorate5([
|
|
4091
|
+
import_tracing3.trace.span()
|
|
4092
|
+
], ServiceContext.prototype, "_initialize", null);
|
|
4093
|
+
ServiceContext = _ts_decorate5([
|
|
4094
|
+
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
4095
|
+
import_tracing3.trace.resource()
|
|
4096
|
+
], ServiceContext);
|
|
3544
4097
|
|
|
3545
4098
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3546
|
-
var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
|
|
3547
4099
|
var import_async17 = require("@dxos/async");
|
|
3548
4100
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3549
|
-
var
|
|
4101
|
+
var import_context10 = require("@dxos/context");
|
|
4102
|
+
var import_document_model2 = require("@dxos/document-model");
|
|
3550
4103
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
4104
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
3551
4105
|
var import_keys11 = require("@dxos/keys");
|
|
3552
|
-
var
|
|
4106
|
+
var import_log16 = require("@dxos/log");
|
|
3553
4107
|
var import_messaging = require("@dxos/messaging");
|
|
3554
4108
|
var import_model_factory = require("@dxos/model-factory");
|
|
3555
4109
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
3556
|
-
var
|
|
3557
|
-
var
|
|
4110
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
4111
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3558
4112
|
var import_text_model = require("@dxos/text-model");
|
|
4113
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
3559
4114
|
|
|
3560
4115
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3561
4116
|
var import_async15 = require("@dxos/async");
|
|
3562
|
-
var
|
|
3563
|
-
var
|
|
4117
|
+
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
4118
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3564
4119
|
var DevicesServiceImpl = class {
|
|
3565
4120
|
constructor(_identityManager) {
|
|
3566
4121
|
this._identityManager = _identityManager;
|
|
@@ -3569,23 +4124,19 @@ var DevicesServiceImpl = class {
|
|
|
3569
4124
|
throw new Error("Method not implemented.");
|
|
3570
4125
|
}
|
|
3571
4126
|
queryDevices() {
|
|
3572
|
-
return new
|
|
4127
|
+
return new import_codec_protobuf12.Stream(({ next }) => {
|
|
3573
4128
|
const update = () => {
|
|
3574
|
-
|
|
3575
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
4129
|
+
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
3576
4130
|
if (!deviceKeys) {
|
|
3577
4131
|
next({
|
|
3578
4132
|
devices: []
|
|
3579
4133
|
});
|
|
3580
4134
|
} else {
|
|
3581
4135
|
next({
|
|
3582
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services10.DeviceKind.CURRENT : import_services10.DeviceKind.TRUSTED
|
|
3587
|
-
};
|
|
3588
|
-
})
|
|
4136
|
+
devices: Array.from(deviceKeys.values()).map((key) => ({
|
|
4137
|
+
deviceKey: key,
|
|
4138
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
|
|
4139
|
+
}))
|
|
3589
4140
|
});
|
|
3590
4141
|
}
|
|
3591
4142
|
};
|
|
@@ -3605,10 +4156,10 @@ var DevicesServiceImpl = class {
|
|
|
3605
4156
|
};
|
|
3606
4157
|
|
|
3607
4158
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
3608
|
-
var
|
|
4159
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
3609
4160
|
var import_lock_file = require("@dxos/lock-file");
|
|
3610
|
-
var
|
|
3611
|
-
function
|
|
4161
|
+
var import_log14 = require("@dxos/log");
|
|
4162
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
3612
4163
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3613
4164
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3614
4165
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3618,7 +4169,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
3618
4169
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3619
4170
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3620
4171
|
}
|
|
3621
|
-
var
|
|
4172
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
3622
4173
|
var Lock = class {
|
|
3623
4174
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
3624
4175
|
this._lockPath = lockPath;
|
|
@@ -3629,102 +4180,113 @@ var Lock = class {
|
|
|
3629
4180
|
return this._lockPath;
|
|
3630
4181
|
}
|
|
3631
4182
|
async acquire() {
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
F: __dxlog_file13,
|
|
4183
|
+
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
4184
|
+
F: __dxlog_file16,
|
|
3635
4185
|
L: 32,
|
|
3636
4186
|
S: this,
|
|
3637
4187
|
C: (f, a) => f(...a)
|
|
3638
4188
|
});
|
|
3639
4189
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
3640
|
-
await
|
|
3641
|
-
(0,
|
|
3642
|
-
F:
|
|
4190
|
+
await this._onAcquire?.();
|
|
4191
|
+
(0, import_log14.log)("acquired lock", void 0, {
|
|
4192
|
+
F: __dxlog_file16,
|
|
3643
4193
|
L: 37,
|
|
3644
4194
|
S: this,
|
|
3645
4195
|
C: (f, a) => f(...a)
|
|
3646
4196
|
});
|
|
3647
4197
|
}
|
|
3648
4198
|
async release() {
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
4199
|
+
await this._onRelease?.();
|
|
4200
|
+
(0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4201
|
+
F: __dxlog_file16,
|
|
4202
|
+
L: 42,
|
|
4203
|
+
S: this,
|
|
4204
|
+
A: [
|
|
4205
|
+
"this._fileHandle",
|
|
4206
|
+
"'Lock is not acquired'"
|
|
4207
|
+
]
|
|
4208
|
+
});
|
|
3652
4209
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3653
4210
|
}
|
|
3654
4211
|
};
|
|
3655
|
-
|
|
3656
|
-
|
|
4212
|
+
_ts_decorate6([
|
|
4213
|
+
import_log14.logInfo
|
|
3657
4214
|
], Lock.prototype, "lockKey", null);
|
|
3658
4215
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
3659
4216
|
|
|
3660
4217
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
3661
4218
|
var import_async16 = require("@dxos/async");
|
|
3662
|
-
var
|
|
3663
|
-
var
|
|
3664
|
-
var
|
|
3665
|
-
var
|
|
4219
|
+
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
4220
|
+
var import_log15 = require("@dxos/log");
|
|
4221
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4222
|
+
var import_util8 = require("@dxos/util");
|
|
3666
4223
|
var LoggingServiceImpl = class {
|
|
3667
4224
|
constructor() {
|
|
3668
4225
|
this._logs = new import_async16.Event();
|
|
4226
|
+
this._started = /* @__PURE__ */ new Date();
|
|
3669
4227
|
this._logProcessor = (_config, entry2) => {
|
|
3670
4228
|
this._logs.emit(entry2);
|
|
3671
4229
|
};
|
|
3672
4230
|
}
|
|
3673
4231
|
async open() {
|
|
3674
|
-
|
|
4232
|
+
import_log15.log.runtimeConfig.processors.push(this._logProcessor);
|
|
3675
4233
|
}
|
|
3676
4234
|
async close() {
|
|
3677
|
-
const index =
|
|
3678
|
-
|
|
4235
|
+
const index = import_log15.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
4236
|
+
import_log15.log.runtimeConfig.processors.splice(index, 1);
|
|
3679
4237
|
}
|
|
3680
4238
|
async controlMetrics({ reset, record }) {
|
|
3681
4239
|
if (reset) {
|
|
3682
|
-
|
|
4240
|
+
import_util8.tracer.clear();
|
|
3683
4241
|
}
|
|
3684
4242
|
if (record === true) {
|
|
3685
|
-
|
|
4243
|
+
import_util8.tracer.start();
|
|
3686
4244
|
} else if (record === false) {
|
|
3687
|
-
|
|
4245
|
+
import_util8.tracer.stop();
|
|
3688
4246
|
}
|
|
3689
4247
|
return {
|
|
3690
|
-
recording:
|
|
4248
|
+
recording: import_util8.tracer.recording
|
|
3691
4249
|
};
|
|
3692
4250
|
}
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
4251
|
+
/**
|
|
4252
|
+
* @deprecated (Move to diagnostics).
|
|
4253
|
+
*/
|
|
4254
|
+
queryMetrics({ interval = 5e3 }) {
|
|
4255
|
+
const getNumericalValues = (key) => {
|
|
4256
|
+
const events = import_util8.tracer.get(key) ?? [];
|
|
3697
4257
|
return {
|
|
3698
4258
|
key,
|
|
3699
|
-
stats: (0,
|
|
4259
|
+
stats: (0, import_util8.numericalValues)(events, "duration")
|
|
3700
4260
|
};
|
|
3701
4261
|
};
|
|
3702
|
-
return new
|
|
4262
|
+
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
3703
4263
|
const update = () => {
|
|
3704
4264
|
const metrics = {
|
|
3705
|
-
timestamp: new Date(),
|
|
4265
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
3706
4266
|
values: [
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
]
|
|
4267
|
+
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4268
|
+
getNumericalValues("dxos.echo.pipeline.data")
|
|
4269
|
+
].filter(Boolean)
|
|
3710
4270
|
};
|
|
3711
|
-
next(
|
|
4271
|
+
next({
|
|
4272
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4273
|
+
metrics
|
|
4274
|
+
});
|
|
3712
4275
|
};
|
|
3713
4276
|
update();
|
|
3714
|
-
const i = setInterval(update, interval);
|
|
4277
|
+
const i = setInterval(update, Math.max(interval, 1e3));
|
|
3715
4278
|
return () => {
|
|
3716
4279
|
clearInterval(i);
|
|
3717
4280
|
};
|
|
3718
4281
|
});
|
|
3719
4282
|
}
|
|
3720
4283
|
queryLogs(request) {
|
|
3721
|
-
return new
|
|
4284
|
+
return new import_codec_protobuf13.Stream(({ ctx, next }) => {
|
|
3722
4285
|
const handler = (entry2) => {
|
|
3723
|
-
var _a, _b, _c, _d, _e;
|
|
3724
4286
|
if (LOG_PROCESSING > 0) {
|
|
3725
4287
|
return;
|
|
3726
4288
|
}
|
|
3727
|
-
if (
|
|
4289
|
+
if (entry2.meta?.F.includes("logging-service") || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
3728
4290
|
return;
|
|
3729
4291
|
}
|
|
3730
4292
|
if (!shouldLog(entry2, request)) {
|
|
@@ -3732,12 +4294,12 @@ var LoggingServiceImpl = class {
|
|
|
3732
4294
|
}
|
|
3733
4295
|
const record = {
|
|
3734
4296
|
...entry2,
|
|
3735
|
-
context: (0,
|
|
3736
|
-
timestamp: new Date(),
|
|
4297
|
+
context: (0, import_util8.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
|
|
4298
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
3737
4299
|
meta: {
|
|
3738
4300
|
// TODO(dmaretskyi): Fix proto.
|
|
3739
|
-
file:
|
|
3740
|
-
line:
|
|
4301
|
+
file: entry2.meta?.F ?? "",
|
|
4302
|
+
line: entry2.meta?.L ?? 0
|
|
3741
4303
|
}
|
|
3742
4304
|
};
|
|
3743
4305
|
try {
|
|
@@ -3753,35 +4315,31 @@ var LoggingServiceImpl = class {
|
|
|
3753
4315
|
};
|
|
3754
4316
|
var matchFilter = (filter, level, path, options) => {
|
|
3755
4317
|
switch (options) {
|
|
3756
|
-
case
|
|
4318
|
+
case import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
3757
4319
|
return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
3758
|
-
case
|
|
4320
|
+
case import_services12.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
3759
4321
|
return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
3760
4322
|
}
|
|
3761
4323
|
};
|
|
3762
4324
|
var shouldLog = (entry2, request) => {
|
|
3763
|
-
|
|
3764
|
-
const options = (_a = request.options) != null ? _a : import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4325
|
+
const options = request.options ?? import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
3765
4326
|
if (request.filters === void 0) {
|
|
3766
|
-
return options ===
|
|
4327
|
+
return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
3767
4328
|
} else {
|
|
3768
|
-
return request.filters.some((filter) =>
|
|
3769
|
-
var _a2, _b;
|
|
3770
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
3771
|
-
});
|
|
4329
|
+
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
3772
4330
|
}
|
|
3773
4331
|
};
|
|
3774
4332
|
var LOG_PROCESSING = 0;
|
|
3775
4333
|
|
|
3776
4334
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
3777
|
-
var
|
|
4335
|
+
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
3778
4336
|
var NetworkServiceImpl = class {
|
|
3779
4337
|
constructor(networkManager, signalManager) {
|
|
3780
4338
|
this.networkManager = networkManager;
|
|
3781
4339
|
this.signalManager = signalManager;
|
|
3782
4340
|
}
|
|
3783
4341
|
queryStatus() {
|
|
3784
|
-
return new
|
|
4342
|
+
return new import_codec_protobuf14.Stream(({ next }) => {
|
|
3785
4343
|
const update = () => {
|
|
3786
4344
|
next({
|
|
3787
4345
|
swarm: this.networkManager.connectionState,
|
|
@@ -3810,10 +4368,10 @@ var import_client_protocol4 = require("@dxos/client-protocol");
|
|
|
3810
4368
|
var import_errors5 = require("@dxos/errors");
|
|
3811
4369
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
3812
4370
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
3813
|
-
var
|
|
4371
|
+
var import_util9 = require("@dxos/util");
|
|
3814
4372
|
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
3815
4373
|
var createStorageObjects = (config) => {
|
|
3816
|
-
const { path = (0,
|
|
4374
|
+
const { path = (0, import_util9.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config ?? {};
|
|
3817
4375
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
3818
4376
|
throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
3819
4377
|
}
|
|
@@ -3855,25 +4413,40 @@ var toStorageType = (type) => {
|
|
|
3855
4413
|
};
|
|
3856
4414
|
|
|
3857
4415
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3858
|
-
var
|
|
4416
|
+
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
4417
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4418
|
+
var import_util10 = require("@dxos/util");
|
|
3859
4419
|
var SystemServiceImpl = class {
|
|
3860
|
-
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4420
|
+
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3861
4421
|
this._config = config;
|
|
3862
4422
|
this._statusUpdate = statusUpdate;
|
|
3863
4423
|
this._getCurrentStatus = getCurrentStatus;
|
|
4424
|
+
this._getDiagnostics = getDiagnostics;
|
|
3864
4425
|
this._onUpdateStatus = onUpdateStatus;
|
|
3865
4426
|
this._onReset = onReset;
|
|
3866
4427
|
}
|
|
3867
4428
|
async getConfig() {
|
|
3868
|
-
|
|
3869
|
-
|
|
4429
|
+
return this._config?.values ?? {};
|
|
4430
|
+
}
|
|
4431
|
+
/**
|
|
4432
|
+
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
4433
|
+
*/
|
|
4434
|
+
async getDiagnostics({ keys } = {}) {
|
|
4435
|
+
const diagnostics = await this._getDiagnostics();
|
|
4436
|
+
return {
|
|
4437
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4438
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util10.jsonKeyReplacer)({
|
|
4439
|
+
truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4440
|
+
humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
4441
|
+
})))
|
|
4442
|
+
};
|
|
3870
4443
|
}
|
|
3871
4444
|
async updateStatus({ status }) {
|
|
3872
4445
|
await this._onUpdateStatus(status);
|
|
3873
4446
|
}
|
|
3874
4447
|
// TODO(burdon): Standardize interval option in stream request?
|
|
3875
4448
|
queryStatus({ interval = 3e3 } = {}) {
|
|
3876
|
-
return new
|
|
4449
|
+
return new import_codec_protobuf15.Stream(({ next }) => {
|
|
3877
4450
|
const update = () => {
|
|
3878
4451
|
next({
|
|
3879
4452
|
status: this._getCurrentStatus()
|
|
@@ -3918,7 +4491,7 @@ var ServiceRegistry = class {
|
|
|
3918
4491
|
};
|
|
3919
4492
|
|
|
3920
4493
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3921
|
-
function
|
|
4494
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
3922
4495
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3923
4496
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3924
4497
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3928,23 +4501,22 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3928
4501
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3929
4502
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3930
4503
|
}
|
|
3931
|
-
var
|
|
4504
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3932
4505
|
var createDefaultModelFactory = () => {
|
|
3933
|
-
return new import_model_factory.ModelFactory().registerModel(
|
|
4506
|
+
return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
|
|
3934
4507
|
};
|
|
3935
|
-
var ClientServicesHost = class {
|
|
4508
|
+
var ClientServicesHost = class ClientServicesHost2 {
|
|
3936
4509
|
constructor({
|
|
3937
4510
|
config,
|
|
3938
4511
|
modelFactory = createDefaultModelFactory(),
|
|
3939
|
-
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3940
4512
|
transportFactory,
|
|
3941
4513
|
signalManager,
|
|
3942
|
-
connectionLog,
|
|
3943
4514
|
storage,
|
|
3944
4515
|
// TODO(wittjosiah): Turn this on by default.
|
|
3945
4516
|
lockKey,
|
|
3946
4517
|
callbacks
|
|
3947
4518
|
} = {}) {
|
|
4519
|
+
this._tracingService = import_tracing4.TRACE_PROCESSOR.createTraceSender();
|
|
3948
4520
|
this._statusUpdate = new import_async17.Event();
|
|
3949
4521
|
this._opening = false;
|
|
3950
4522
|
this._open = false;
|
|
@@ -3963,7 +4535,7 @@ var ClientServicesHost = class {
|
|
|
3963
4535
|
lockKey,
|
|
3964
4536
|
onAcquire: () => {
|
|
3965
4537
|
if (!this._opening) {
|
|
3966
|
-
void this.open();
|
|
4538
|
+
void this.open(new import_context10.Context());
|
|
3967
4539
|
}
|
|
3968
4540
|
},
|
|
3969
4541
|
onRelease: () => this.close()
|
|
@@ -3972,13 +4544,15 @@ var ClientServicesHost = class {
|
|
|
3972
4544
|
this._systemService = new SystemServiceImpl({
|
|
3973
4545
|
config: this._config,
|
|
3974
4546
|
statusUpdate: this._statusUpdate,
|
|
3975
|
-
getCurrentStatus: () => this.isOpen ?
|
|
4547
|
+
getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
|
|
4548
|
+
getDiagnostics: () => {
|
|
4549
|
+
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4550
|
+
},
|
|
3976
4551
|
onUpdateStatus: async (status) => {
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
await ((_b = this._resourceLock) == null ? void 0 : _b.release());
|
|
4552
|
+
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
4553
|
+
await this._resourceLock?.acquire();
|
|
4554
|
+
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
4555
|
+
await this._resourceLock?.release();
|
|
3982
4556
|
}
|
|
3983
4557
|
},
|
|
3984
4558
|
onReset: async () => {
|
|
@@ -3987,12 +4561,19 @@ var ClientServicesHost = class {
|
|
|
3987
4561
|
});
|
|
3988
4562
|
this._loggingService = new LoggingServiceImpl();
|
|
3989
4563
|
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
3990
|
-
SystemService: this._systemService
|
|
4564
|
+
SystemService: this._systemService,
|
|
4565
|
+
TracingService: this._tracingService
|
|
3991
4566
|
});
|
|
3992
4567
|
}
|
|
3993
4568
|
get isOpen() {
|
|
3994
4569
|
return this._open;
|
|
3995
4570
|
}
|
|
4571
|
+
get config() {
|
|
4572
|
+
return this._config;
|
|
4573
|
+
}
|
|
4574
|
+
get context() {
|
|
4575
|
+
return this._serviceContext;
|
|
4576
|
+
}
|
|
3996
4577
|
get serviceRegistry() {
|
|
3997
4578
|
return this._serviceRegistry;
|
|
3998
4579
|
}
|
|
@@ -4008,59 +4589,125 @@ var ClientServicesHost = class {
|
|
|
4008
4589
|
* Can only be called once.
|
|
4009
4590
|
*/
|
|
4010
4591
|
initialize({ config, ...options }) {
|
|
4011
|
-
|
|
4012
|
-
|
|
4592
|
+
(0, import_invariant14.invariant)(!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
|
+
(0, import_log16.log)("initializing...", void 0, {
|
|
4602
|
+
F: __dxlog_file17,
|
|
4603
|
+
L: 182,
|
|
4604
|
+
S: this,
|
|
4605
|
+
C: (f, a) => f(...a)
|
|
4606
|
+
});
|
|
4013
4607
|
if (config) {
|
|
4014
|
-
(0,
|
|
4608
|
+
(0, import_invariant14.invariant)(!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
|
+
});
|
|
4015
4617
|
this._config = config;
|
|
4016
4618
|
if (!this._storage) {
|
|
4017
4619
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
4018
4620
|
}
|
|
4019
4621
|
}
|
|
4020
4622
|
const { connectionLog = true, transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
|
|
4021
|
-
iceServers:
|
|
4022
|
-
}), signalManager = new import_messaging.WebsocketSignalManager(
|
|
4623
|
+
iceServers: this._config?.get("runtime.services.ice")
|
|
4624
|
+
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4023
4625
|
this._signalManager = signalManager;
|
|
4024
|
-
(0,
|
|
4626
|
+
(0, import_invariant14.invariant)(!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
|
+
});
|
|
4025
4635
|
this._networkManager = new import_network_manager2.NetworkManager({
|
|
4026
4636
|
log: connectionLog,
|
|
4027
4637
|
transportFactory,
|
|
4028
4638
|
signalManager
|
|
4029
4639
|
});
|
|
4640
|
+
(0, import_log16.log)("initialized", void 0, {
|
|
4641
|
+
F: __dxlog_file17,
|
|
4642
|
+
L: 208,
|
|
4643
|
+
S: this,
|
|
4644
|
+
C: (f, a) => f(...a)
|
|
4645
|
+
});
|
|
4030
4646
|
}
|
|
4031
|
-
async open() {
|
|
4032
|
-
var _a, _b, _c;
|
|
4647
|
+
async open(ctx) {
|
|
4033
4648
|
if (this._open) {
|
|
4034
4649
|
return;
|
|
4035
4650
|
}
|
|
4036
4651
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4037
|
-
|
|
4652
|
+
import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.begin({
|
|
4038
4653
|
id: traceId
|
|
4039
4654
|
}), {
|
|
4040
|
-
F:
|
|
4041
|
-
L:
|
|
4655
|
+
F: __dxlog_file17,
|
|
4656
|
+
L: 219,
|
|
4042
4657
|
S: this,
|
|
4043
4658
|
C: (f, a) => f(...a)
|
|
4044
4659
|
});
|
|
4045
|
-
(0,
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4660
|
+
(0, import_invariant14.invariant)(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
|
+
(0, import_invariant14.invariant)(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
|
+
(0, import_invariant14.invariant)(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
|
+
(0, import_invariant14.invariant)(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
|
+
});
|
|
4049
4696
|
this._opening = true;
|
|
4050
|
-
(0,
|
|
4051
|
-
lockKey:
|
|
4697
|
+
(0, import_log16.log)("opening...", {
|
|
4698
|
+
lockKey: this._resourceLock?.lockKey
|
|
4052
4699
|
}, {
|
|
4053
|
-
F:
|
|
4054
|
-
L:
|
|
4700
|
+
F: __dxlog_file17,
|
|
4701
|
+
L: 227,
|
|
4055
4702
|
S: this,
|
|
4056
4703
|
C: (f, a) => f(...a)
|
|
4057
4704
|
});
|
|
4058
|
-
await
|
|
4705
|
+
await this._resourceLock?.acquire();
|
|
4059
4706
|
await this._loggingService.open();
|
|
4060
4707
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4061
4708
|
this._serviceRegistry.setServices({
|
|
4062
4709
|
SystemService: this._systemService,
|
|
4063
|
-
IdentityService: new IdentityServiceImpl(this._serviceContext),
|
|
4710
|
+
IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
|
|
4064
4711
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4065
4712
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4066
4713
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -4070,6 +4717,7 @@ var ClientServicesHost = class {
|
|
|
4070
4717
|
DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4071
4718
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
4072
4719
|
LoggingService: this._loggingService,
|
|
4720
|
+
TracingService: this._tracingService,
|
|
4073
4721
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4074
4722
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
4075
4723
|
events: new DevtoolsHostEvents(),
|
|
@@ -4077,39 +4725,38 @@ var ClientServicesHost = class {
|
|
|
4077
4725
|
context: this._serviceContext
|
|
4078
4726
|
})
|
|
4079
4727
|
});
|
|
4080
|
-
await this._serviceContext.open();
|
|
4728
|
+
await this._serviceContext.open(ctx);
|
|
4081
4729
|
this._opening = false;
|
|
4082
4730
|
this._open = true;
|
|
4083
4731
|
this._statusUpdate.emit();
|
|
4084
|
-
const deviceKey =
|
|
4085
|
-
(0,
|
|
4732
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4733
|
+
(0, import_log16.log)("opened", {
|
|
4086
4734
|
deviceKey
|
|
4087
4735
|
}, {
|
|
4088
|
-
F:
|
|
4089
|
-
L:
|
|
4736
|
+
F: __dxlog_file17,
|
|
4737
|
+
L: 284,
|
|
4090
4738
|
S: this,
|
|
4091
4739
|
C: (f, a) => f(...a)
|
|
4092
4740
|
});
|
|
4093
|
-
|
|
4741
|
+
import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.end({
|
|
4094
4742
|
id: traceId
|
|
4095
4743
|
}), {
|
|
4096
|
-
F:
|
|
4097
|
-
L:
|
|
4744
|
+
F: __dxlog_file17,
|
|
4745
|
+
L: 285,
|
|
4098
4746
|
S: this,
|
|
4099
4747
|
C: (f, a) => f(...a)
|
|
4100
4748
|
});
|
|
4101
4749
|
}
|
|
4102
4750
|
async close() {
|
|
4103
|
-
var _a;
|
|
4104
4751
|
if (!this._open) {
|
|
4105
4752
|
return;
|
|
4106
4753
|
}
|
|
4107
|
-
const deviceKey =
|
|
4108
|
-
(0,
|
|
4754
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4755
|
+
(0, import_log16.log)("closing...", {
|
|
4109
4756
|
deviceKey
|
|
4110
4757
|
}, {
|
|
4111
|
-
F:
|
|
4112
|
-
L:
|
|
4758
|
+
F: __dxlog_file17,
|
|
4759
|
+
L: 296,
|
|
4113
4760
|
S: this,
|
|
4114
4761
|
C: (f, a) => f(...a)
|
|
4115
4762
|
});
|
|
@@ -4120,72 +4767,84 @@ var ClientServicesHost = class {
|
|
|
4120
4767
|
await this._serviceContext.close();
|
|
4121
4768
|
this._open = false;
|
|
4122
4769
|
this._statusUpdate.emit();
|
|
4123
|
-
(0,
|
|
4770
|
+
(0, import_log16.log)("closed", {
|
|
4124
4771
|
deviceKey
|
|
4125
4772
|
}, {
|
|
4126
|
-
F:
|
|
4127
|
-
L:
|
|
4773
|
+
F: __dxlog_file17,
|
|
4774
|
+
L: 302,
|
|
4128
4775
|
S: this,
|
|
4129
4776
|
C: (f, a) => f(...a)
|
|
4130
4777
|
});
|
|
4131
4778
|
}
|
|
4132
4779
|
async reset() {
|
|
4133
|
-
var _a, _b, _c;
|
|
4134
4780
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4135
|
-
|
|
4781
|
+
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
|
|
4136
4782
|
id: traceId
|
|
4137
4783
|
}), {
|
|
4138
|
-
F:
|
|
4139
|
-
L:
|
|
4784
|
+
F: __dxlog_file17,
|
|
4785
|
+
L: 307,
|
|
4140
4786
|
S: this,
|
|
4141
4787
|
C: (f, a) => f(...a)
|
|
4142
4788
|
});
|
|
4143
|
-
(0,
|
|
4144
|
-
F:
|
|
4145
|
-
L:
|
|
4789
|
+
(0, import_log16.log)("resetting...", void 0, {
|
|
4790
|
+
F: __dxlog_file17,
|
|
4791
|
+
L: 309,
|
|
4146
4792
|
S: this,
|
|
4147
4793
|
C: (f, a) => f(...a)
|
|
4148
4794
|
});
|
|
4149
|
-
await
|
|
4795
|
+
await this._serviceContext?.close();
|
|
4150
4796
|
await this._storage.reset();
|
|
4151
|
-
(0,
|
|
4152
|
-
F:
|
|
4153
|
-
L:
|
|
4797
|
+
(0, import_log16.log)("reset", void 0, {
|
|
4798
|
+
F: __dxlog_file17,
|
|
4799
|
+
L: 312,
|
|
4154
4800
|
S: this,
|
|
4155
4801
|
C: (f, a) => f(...a)
|
|
4156
4802
|
});
|
|
4157
|
-
|
|
4803
|
+
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.end({
|
|
4158
4804
|
id: traceId
|
|
4159
4805
|
}), {
|
|
4160
|
-
F:
|
|
4161
|
-
L:
|
|
4806
|
+
F: __dxlog_file17,
|
|
4807
|
+
L: 313,
|
|
4162
4808
|
S: this,
|
|
4163
4809
|
C: (f, a) => f(...a)
|
|
4164
4810
|
});
|
|
4165
|
-
await
|
|
4811
|
+
await this._callbacks?.onReset?.();
|
|
4166
4812
|
}
|
|
4167
4813
|
};
|
|
4168
|
-
|
|
4169
|
-
|
|
4814
|
+
_ts_decorate7([
|
|
4815
|
+
import_tracing4.trace.info()
|
|
4816
|
+
], ClientServicesHost.prototype, "_opening", void 0);
|
|
4817
|
+
_ts_decorate7([
|
|
4818
|
+
import_tracing4.trace.info()
|
|
4819
|
+
], ClientServicesHost.prototype, "_open", void 0);
|
|
4820
|
+
_ts_decorate7([
|
|
4821
|
+
import_async17.synchronized,
|
|
4822
|
+
import_tracing4.trace.span()
|
|
4170
4823
|
], ClientServicesHost.prototype, "open", null);
|
|
4171
|
-
|
|
4172
|
-
import_async17.synchronized
|
|
4824
|
+
_ts_decorate7([
|
|
4825
|
+
import_async17.synchronized,
|
|
4826
|
+
import_tracing4.trace.span()
|
|
4173
4827
|
], ClientServicesHost.prototype, "close", null);
|
|
4828
|
+
ClientServicesHost = _ts_decorate7([
|
|
4829
|
+
import_tracing4.trace.resource()
|
|
4830
|
+
], ClientServicesHost);
|
|
4174
4831
|
|
|
4175
4832
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
4176
4833
|
var import_async19 = require("@dxos/async");
|
|
4177
4834
|
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
4178
|
-
var
|
|
4835
|
+
var import_context11 = require("@dxos/context");
|
|
4836
|
+
var import_log17 = require("@dxos/log");
|
|
4179
4837
|
var import_messaging2 = require("@dxos/messaging");
|
|
4180
4838
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
4181
|
-
var
|
|
4839
|
+
var import_util11 = require("@dxos/util");
|
|
4182
4840
|
|
|
4183
4841
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
4184
|
-
var import_tiny_invariant14 = __toESM(require("tiny-invariant"));
|
|
4185
4842
|
var import_async18 = require("@dxos/async");
|
|
4186
4843
|
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
4844
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
4187
4845
|
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
4188
4846
|
var import_rpc2 = require("@dxos/rpc");
|
|
4847
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/shell-runtime.ts";
|
|
4189
4848
|
var ShellRuntimeImpl = class {
|
|
4190
4849
|
constructor(_port) {
|
|
4191
4850
|
this._port = _port;
|
|
@@ -4211,7 +4870,15 @@ var ShellRuntimeImpl = class {
|
|
|
4211
4870
|
});
|
|
4212
4871
|
}
|
|
4213
4872
|
async setAppContext(context) {
|
|
4214
|
-
(0,
|
|
4873
|
+
(0, import_invariant15.invariant)(this._appRpc, "runtime not open", {
|
|
4874
|
+
F: __dxlog_file18,
|
|
4875
|
+
L: 44,
|
|
4876
|
+
S: this,
|
|
4877
|
+
A: [
|
|
4878
|
+
"this._appRpc",
|
|
4879
|
+
"'runtime not open'"
|
|
4880
|
+
]
|
|
4881
|
+
});
|
|
4215
4882
|
await this._appRpc.rpc.AppService.setContext(context);
|
|
4216
4883
|
}
|
|
4217
4884
|
async open() {
|
|
@@ -4233,14 +4900,13 @@ var ShellRuntimeImpl = class {
|
|
|
4233
4900
|
await this._appRpc.open();
|
|
4234
4901
|
}
|
|
4235
4902
|
async close() {
|
|
4236
|
-
|
|
4237
|
-
await ((_a = this._appRpc) == null ? void 0 : _a.close());
|
|
4903
|
+
await this._appRpc?.close();
|
|
4238
4904
|
this._appRpc = void 0;
|
|
4239
4905
|
}
|
|
4240
4906
|
};
|
|
4241
4907
|
|
|
4242
4908
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
4243
|
-
function
|
|
4909
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
4244
4910
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4245
4911
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4246
4912
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4250,7 +4916,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4250
4916
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4251
4917
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4252
4918
|
}
|
|
4253
|
-
var
|
|
4919
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts";
|
|
4254
4920
|
var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
4255
4921
|
var IFrameHostRuntime = class {
|
|
4256
4922
|
constructor({ config, origin, appPort, shellPort }) {
|
|
@@ -4270,15 +4936,14 @@ var IFrameHostRuntime = class {
|
|
|
4270
4936
|
return this._shellRuntime;
|
|
4271
4937
|
}
|
|
4272
4938
|
async start() {
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
L: 70,
|
|
4939
|
+
(0, import_log17.log)("starting...", void 0, {
|
|
4940
|
+
F: __dxlog_file19,
|
|
4941
|
+
L: 71,
|
|
4277
4942
|
S: this,
|
|
4278
4943
|
C: (f, a) => f(...a)
|
|
4279
4944
|
});
|
|
4280
4945
|
try {
|
|
4281
|
-
this._config = await (0,
|
|
4946
|
+
this._config = await (0, import_util11.getAsyncValue)(this._configProvider);
|
|
4282
4947
|
this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)({
|
|
4283
4948
|
iceServers: this._config.get("runtime.services.ice")
|
|
4284
4949
|
});
|
|
@@ -4315,59 +4980,58 @@ var IFrameHostRuntime = class {
|
|
|
4315
4980
|
...middleware
|
|
4316
4981
|
});
|
|
4317
4982
|
await Promise.all([
|
|
4318
|
-
this._clientServices.open(),
|
|
4983
|
+
this._clientServices.open(new import_context11.Context()),
|
|
4319
4984
|
this._clientRpc.open(),
|
|
4320
|
-
|
|
4985
|
+
this._shellRuntime?.open()
|
|
4321
4986
|
]);
|
|
4322
4987
|
this._ready.wake(void 0);
|
|
4323
|
-
(0,
|
|
4324
|
-
F:
|
|
4325
|
-
L:
|
|
4988
|
+
(0, import_log17.log)("started", void 0, {
|
|
4989
|
+
F: __dxlog_file19,
|
|
4990
|
+
L: 114,
|
|
4326
4991
|
S: this,
|
|
4327
4992
|
C: (f, a) => f(...a)
|
|
4328
4993
|
});
|
|
4329
4994
|
} catch (err) {
|
|
4330
4995
|
this._ready.wake(err);
|
|
4331
|
-
|
|
4332
|
-
F:
|
|
4333
|
-
L:
|
|
4996
|
+
import_log17.log.catch(err, void 0, {
|
|
4997
|
+
F: __dxlog_file19,
|
|
4998
|
+
L: 117,
|
|
4334
4999
|
S: this,
|
|
4335
5000
|
C: (f, a) => f(...a)
|
|
4336
5001
|
});
|
|
4337
5002
|
}
|
|
4338
5003
|
}
|
|
4339
5004
|
async stop() {
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
L: 121,
|
|
5005
|
+
(0, import_log17.log)("stopping...", void 0, {
|
|
5006
|
+
F: __dxlog_file19,
|
|
5007
|
+
L: 122,
|
|
4344
5008
|
S: this,
|
|
4345
5009
|
C: (f, a) => f(...a)
|
|
4346
5010
|
});
|
|
4347
5011
|
await this._clientRpc.close();
|
|
4348
5012
|
await this._clientServices.close();
|
|
4349
|
-
await
|
|
4350
|
-
(0,
|
|
4351
|
-
F:
|
|
4352
|
-
L:
|
|
5013
|
+
await this._shellRuntime?.close();
|
|
5014
|
+
(0, import_log17.log)("stopped", void 0, {
|
|
5015
|
+
F: __dxlog_file19,
|
|
5016
|
+
L: 126,
|
|
4353
5017
|
S: this,
|
|
4354
5018
|
C: (f, a) => f(...a)
|
|
4355
5019
|
});
|
|
4356
5020
|
}
|
|
4357
5021
|
};
|
|
4358
|
-
|
|
4359
|
-
|
|
5022
|
+
_ts_decorate8([
|
|
5023
|
+
import_log17.logInfo
|
|
4360
5024
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
4361
5025
|
|
|
4362
5026
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
4363
5027
|
var import_async20 = require("@dxos/async");
|
|
4364
5028
|
var import_client_protocol8 = require("@dxos/client-protocol");
|
|
4365
5029
|
var import_errors6 = require("@dxos/errors");
|
|
4366
|
-
var
|
|
5030
|
+
var import_log18 = require("@dxos/log");
|
|
4367
5031
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
4368
5032
|
var import_rpc3 = require("@dxos/rpc");
|
|
4369
|
-
var
|
|
4370
|
-
var
|
|
5033
|
+
var import_util12 = require("@dxos/util");
|
|
5034
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts";
|
|
4371
5035
|
var IFrameProxyRuntime = class {
|
|
4372
5036
|
constructor({ config, systemPort, shellPort }) {
|
|
4373
5037
|
this._id = String(Math.floor(Math.random() * 1e6));
|
|
@@ -4383,8 +5047,7 @@ var IFrameProxyRuntime = class {
|
|
|
4383
5047
|
return this._shellRuntime;
|
|
4384
5048
|
}
|
|
4385
5049
|
async open(origin) {
|
|
4386
|
-
|
|
4387
|
-
this._config = await (0, import_util10.getAsyncValue)(this._configProvider);
|
|
5050
|
+
this._config = await (0, import_util12.getAsyncValue)(this._configProvider);
|
|
4388
5051
|
this._transportService = new import_network_manager4.WebRTCTransportService({
|
|
4389
5052
|
iceServers: this._config.get("runtime.services.ice")
|
|
4390
5053
|
});
|
|
@@ -4415,20 +5078,19 @@ var IFrameProxyRuntime = class {
|
|
|
4415
5078
|
lockKey
|
|
4416
5079
|
});
|
|
4417
5080
|
} catch (err) {
|
|
4418
|
-
|
|
4419
|
-
F:
|
|
5081
|
+
import_log18.log.catch(err, void 0, {
|
|
5082
|
+
F: __dxlog_file20,
|
|
4420
5083
|
L: 85,
|
|
4421
5084
|
S: this,
|
|
4422
5085
|
C: (f, a) => f(...a)
|
|
4423
5086
|
});
|
|
4424
5087
|
throw new import_errors6.RemoteServiceConnectionError("Failed to connect to worker");
|
|
4425
5088
|
}
|
|
4426
|
-
await
|
|
5089
|
+
await this._shellRuntime?.open();
|
|
4427
5090
|
}
|
|
4428
5091
|
async close() {
|
|
4429
|
-
var _a;
|
|
4430
5092
|
this._release.wake();
|
|
4431
|
-
await
|
|
5093
|
+
await this._shellRuntime?.close();
|
|
4432
5094
|
await this._systemRpc.rpc.WorkerService.stop();
|
|
4433
5095
|
await this._systemRpc.close();
|
|
4434
5096
|
}
|
|
@@ -4439,18 +5101,19 @@ var IFrameProxyRuntime = class {
|
|
|
4439
5101
|
|
|
4440
5102
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
4441
5103
|
var import_async22 = require("@dxos/async");
|
|
4442
|
-
var
|
|
5104
|
+
var import_context12 = require("@dxos/context");
|
|
5105
|
+
var import_log20 = require("@dxos/log");
|
|
4443
5106
|
var import_messaging3 = require("@dxos/messaging");
|
|
4444
5107
|
var import_network_manager5 = require("@dxos/network-manager");
|
|
4445
5108
|
|
|
4446
5109
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
4447
|
-
var import_tiny_invariant15 = __toESM(require("tiny-invariant"));
|
|
4448
5110
|
var import_async21 = require("@dxos/async");
|
|
4449
5111
|
var import_client_protocol9 = require("@dxos/client-protocol");
|
|
4450
|
-
var
|
|
5112
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
5113
|
+
var import_log19 = require("@dxos/log");
|
|
4451
5114
|
var import_rpc4 = require("@dxos/rpc");
|
|
4452
|
-
var
|
|
4453
|
-
function
|
|
5115
|
+
var import_util13 = require("@dxos/util");
|
|
5116
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
4454
5117
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4455
5118
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4456
5119
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4460,12 +5123,20 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4460
5123
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4461
5124
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4462
5125
|
}
|
|
4463
|
-
var
|
|
5126
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-session.ts";
|
|
4464
5127
|
var WorkerSession = class {
|
|
4465
5128
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
4466
5129
|
this._startTrigger = new import_async21.Trigger();
|
|
4467
|
-
this.onClose = new
|
|
4468
|
-
(0,
|
|
5130
|
+
this.onClose = new import_util13.Callback();
|
|
5131
|
+
(0, import_invariant16.invariant)(serviceHost, void 0, {
|
|
5132
|
+
F: __dxlog_file21,
|
|
5133
|
+
L: 49,
|
|
5134
|
+
S: this,
|
|
5135
|
+
A: [
|
|
5136
|
+
"serviceHost",
|
|
5137
|
+
""
|
|
5138
|
+
]
|
|
5139
|
+
});
|
|
4469
5140
|
this._serviceHost = serviceHost;
|
|
4470
5141
|
const middleware = {
|
|
4471
5142
|
handleCall: async (method, params, handler) => {
|
|
@@ -4512,8 +5183,8 @@ var WorkerSession = class {
|
|
|
4512
5183
|
try {
|
|
4513
5184
|
await this.close();
|
|
4514
5185
|
} catch (err) {
|
|
4515
|
-
|
|
4516
|
-
F:
|
|
5186
|
+
import_log19.log.catch(err, void 0, {
|
|
5187
|
+
F: __dxlog_file21,
|
|
4517
5188
|
L: 99,
|
|
4518
5189
|
S: this,
|
|
4519
5190
|
C: (f, a) => f(...a)
|
|
@@ -4529,8 +5200,8 @@ var WorkerSession = class {
|
|
|
4529
5200
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
4530
5201
|
}
|
|
4531
5202
|
async open() {
|
|
4532
|
-
|
|
4533
|
-
F:
|
|
5203
|
+
import_log19.log.info("opening...", void 0, {
|
|
5204
|
+
F: __dxlog_file21,
|
|
4534
5205
|
L: 113,
|
|
4535
5206
|
S: this,
|
|
4536
5207
|
C: (f, a) => f(...a)
|
|
@@ -4546,26 +5217,26 @@ var WorkerSession = class {
|
|
|
4546
5217
|
if (this.lockKey) {
|
|
4547
5218
|
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
4548
5219
|
}
|
|
4549
|
-
|
|
4550
|
-
F:
|
|
4551
|
-
L:
|
|
5220
|
+
import_log19.log.info("opened", void 0, {
|
|
5221
|
+
F: __dxlog_file21,
|
|
5222
|
+
L: 124,
|
|
4552
5223
|
S: this,
|
|
4553
5224
|
C: (f, a) => f(...a)
|
|
4554
5225
|
});
|
|
4555
5226
|
}
|
|
4556
5227
|
async close() {
|
|
4557
|
-
|
|
4558
|
-
F:
|
|
4559
|
-
L:
|
|
5228
|
+
import_log19.log.info("closing...", void 0, {
|
|
5229
|
+
F: __dxlog_file21,
|
|
5230
|
+
L: 128,
|
|
4560
5231
|
S: this,
|
|
4561
5232
|
C: (f, a) => f(...a)
|
|
4562
5233
|
});
|
|
4563
5234
|
try {
|
|
4564
5235
|
await this.onClose.callIfSet();
|
|
4565
5236
|
} catch (err) {
|
|
4566
|
-
|
|
4567
|
-
F:
|
|
4568
|
-
L:
|
|
5237
|
+
import_log19.log.catch(err, void 0, {
|
|
5238
|
+
F: __dxlog_file21,
|
|
5239
|
+
L: 132,
|
|
4569
5240
|
S: this,
|
|
4570
5241
|
C: (f, a) => f(...a)
|
|
4571
5242
|
});
|
|
@@ -4574,9 +5245,9 @@ var WorkerSession = class {
|
|
|
4574
5245
|
this._clientRpc.close(),
|
|
4575
5246
|
this._iframeRpc.close()
|
|
4576
5247
|
]);
|
|
4577
|
-
|
|
4578
|
-
F:
|
|
4579
|
-
L:
|
|
5248
|
+
import_log19.log.info("closed", void 0, {
|
|
5249
|
+
F: __dxlog_file21,
|
|
5250
|
+
L: 136,
|
|
4580
5251
|
S: this,
|
|
4581
5252
|
C: (f, a) => f(...a)
|
|
4582
5253
|
});
|
|
@@ -4584,10 +5255,10 @@ var WorkerSession = class {
|
|
|
4584
5255
|
async _maybeOpenShell() {
|
|
4585
5256
|
try {
|
|
4586
5257
|
await (0, import_async21.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
4587
|
-
} catch
|
|
4588
|
-
|
|
4589
|
-
F:
|
|
4590
|
-
L:
|
|
5258
|
+
} catch {
|
|
5259
|
+
import_log19.log.info("No shell connected.", void 0, {
|
|
5260
|
+
F: __dxlog_file21,
|
|
5261
|
+
L: 143,
|
|
4591
5262
|
S: this,
|
|
4592
5263
|
C: (f, a) => f(...a)
|
|
4593
5264
|
});
|
|
@@ -4598,15 +5269,15 @@ var WorkerSession = class {
|
|
|
4598
5269
|
}).then(callback);
|
|
4599
5270
|
}
|
|
4600
5271
|
};
|
|
4601
|
-
|
|
4602
|
-
|
|
5272
|
+
_ts_decorate9([
|
|
5273
|
+
import_log19.logInfo
|
|
4603
5274
|
], WorkerSession.prototype, "origin", void 0);
|
|
4604
|
-
|
|
4605
|
-
|
|
5275
|
+
_ts_decorate9([
|
|
5276
|
+
import_log19.logInfo
|
|
4606
5277
|
], WorkerSession.prototype, "lockKey", void 0);
|
|
4607
5278
|
|
|
4608
5279
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
4609
|
-
var
|
|
5280
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-runtime.ts";
|
|
4610
5281
|
var WorkerRuntime = class {
|
|
4611
5282
|
// prettier-ignore
|
|
4612
5283
|
constructor(_configProvider) {
|
|
@@ -4626,9 +5297,9 @@ var WorkerRuntime = class {
|
|
|
4626
5297
|
return this._clientServices;
|
|
4627
5298
|
}
|
|
4628
5299
|
async start() {
|
|
4629
|
-
(0,
|
|
4630
|
-
F:
|
|
4631
|
-
L:
|
|
5300
|
+
(0, import_log20.log)("starting...", void 0, {
|
|
5301
|
+
F: __dxlog_file22,
|
|
5302
|
+
L: 49,
|
|
4632
5303
|
S: this,
|
|
4633
5304
|
C: (f, a) => f(...a)
|
|
4634
5305
|
});
|
|
@@ -4640,19 +5311,19 @@ var WorkerRuntime = class {
|
|
|
4640
5311
|
signalManager: signals ? new import_messaging3.WebsocketSignalManager(signals) : new import_messaging3.MemorySignalManager(new import_messaging3.MemorySignalManagerContext()),
|
|
4641
5312
|
transportFactory: this._transportFactory
|
|
4642
5313
|
});
|
|
4643
|
-
await this._clientServices.open();
|
|
5314
|
+
await this._clientServices.open(new import_context12.Context());
|
|
4644
5315
|
this._ready.wake(void 0);
|
|
4645
|
-
(0,
|
|
4646
|
-
F:
|
|
4647
|
-
L:
|
|
5316
|
+
(0, import_log20.log)("started", void 0, {
|
|
5317
|
+
F: __dxlog_file22,
|
|
5318
|
+
L: 63,
|
|
4648
5319
|
S: this,
|
|
4649
5320
|
C: (f, a) => f(...a)
|
|
4650
5321
|
});
|
|
4651
5322
|
} catch (err) {
|
|
4652
5323
|
this._ready.wake(err);
|
|
4653
|
-
|
|
4654
|
-
F:
|
|
4655
|
-
L:
|
|
5324
|
+
import_log20.log.catch("starting", err, {
|
|
5325
|
+
F: __dxlog_file22,
|
|
5326
|
+
L: 66,
|
|
4656
5327
|
S: this,
|
|
4657
5328
|
C: (f, a) => f(...a)
|
|
4658
5329
|
});
|
|
@@ -4684,9 +5355,9 @@ var WorkerRuntime = class {
|
|
|
4684
5355
|
* Selects one of the existing session fro WebRTC networking.
|
|
4685
5356
|
*/
|
|
4686
5357
|
_reconnectWebrtc() {
|
|
4687
|
-
(0,
|
|
4688
|
-
F:
|
|
4689
|
-
L:
|
|
5358
|
+
(0, import_log20.log)("reconnecting webrtc...", void 0, {
|
|
5359
|
+
F: __dxlog_file22,
|
|
5360
|
+
L: 103,
|
|
4690
5361
|
S: this,
|
|
4691
5362
|
C: (f, a) => f(...a)
|
|
4692
5363
|
});
|
|
@@ -4733,6 +5404,7 @@ var WorkerRuntime = class {
|
|
|
4733
5404
|
WorkerSession,
|
|
4734
5405
|
createAuthProvider,
|
|
4735
5406
|
createDefaultModelFactory,
|
|
5407
|
+
createDiagnostics,
|
|
4736
5408
|
createStorageObjects,
|
|
4737
5409
|
getNetworkPeers,
|
|
4738
5410
|
isLocked,
|