@dxos/client-services 0.1.41 → 0.1.45-next.45667d4
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-T73F4MV4.mjs → chunk-IHSMRQ3L.mjs} +985 -867
- package/dist/lib/browser/chunk-IHSMRQ3L.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +7 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +121 -297
- package/dist/lib/browser/packlets/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +589 -469
- 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 +688 -740
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +4 -2
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts +5 -4
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts +2 -3
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +1 -3
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +1 -2
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts +6 -4
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +2 -2
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +0 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/local-client-services.d.ts +1 -1
- package/dist/types/src/packlets/services/local-client-services.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +4 -2
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +16 -9
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +12 -7
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +15 -10
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +5 -0
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +4 -4
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/credential-utils.d.ts +1 -1
- package/dist/types/src/packlets/testing/index.d.ts +0 -1
- package/dist/types/src/packlets/testing/index.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +13 -7
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +35 -32
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +5 -2
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/vault-resource-lock.d.ts +1 -1
- package/dist/types/src/packlets/vault/vault-resource-lock.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts +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 +4 -7
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/package.json +30 -31
- package/src/index.ts +1 -0
- package/src/packlets/devices/devices-service.ts +5 -5
- package/src/packlets/devtools/devtools.ts +25 -4
- package/src/packlets/devtools/feeds.ts +10 -10
- package/src/packlets/devtools/keys.ts +6 -6
- package/src/packlets/devtools/network.ts +14 -13
- package/src/packlets/devtools/spaces.ts +4 -4
- package/src/packlets/identity/authenticator.test.ts +1 -1
- package/src/packlets/identity/authenticator.ts +2 -2
- package/src/packlets/identity/identity-manager.test.ts +17 -13
- package/src/packlets/identity/identity-manager.ts +21 -22
- package/src/packlets/identity/identity-service.ts +3 -3
- package/src/packlets/identity/identity.test.ts +65 -36
- package/src/packlets/identity/identity.ts +17 -17
- package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
- package/src/packlets/invitations/device-invitation-protocol.ts +7 -7
- package/src/packlets/invitations/invitation-extension.ts +16 -27
- package/src/packlets/invitations/invitations-handler.ts +17 -25
- package/src/packlets/invitations/invitations-service.ts +11 -11
- package/src/packlets/invitations/space-invitation-protocol.test.ts +9 -9
- package/src/packlets/invitations/space-invitation-protocol.ts +11 -12
- package/src/packlets/logging/logging-service.ts +8 -3
- package/src/packlets/network/network-service.test.ts +8 -8
- package/src/packlets/network/network-service.ts +20 -8
- package/src/packlets/services/client-rpc-server.ts +5 -5
- package/src/packlets/services/index.ts +0 -1
- package/src/packlets/services/local-client-services.ts +1 -1
- package/src/packlets/services/service-context.test.ts +3 -3
- package/src/packlets/services/service-context.ts +26 -24
- package/src/packlets/services/service-host.test.ts +6 -6
- package/src/packlets/services/service-host.ts +57 -31
- package/src/packlets/services/service-registry.test.ts +20 -38
- package/src/packlets/spaces/data-space-manager.test.ts +17 -29
- package/src/packlets/spaces/data-space-manager.ts +29 -35
- package/src/packlets/spaces/data-space.ts +73 -47
- package/src/packlets/spaces/genesis.ts +81 -0
- package/src/packlets/spaces/notarization-plugin.test.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.ts +12 -12
- package/src/packlets/spaces/spaces-service.test.ts +2 -2
- package/src/packlets/spaces/spaces-service.ts +21 -10
- package/src/packlets/storage/storage.ts +3 -3
- package/src/packlets/system/system-service.test.ts +1 -1
- package/src/packlets/system/system-service.ts +1 -1
- package/src/packlets/testing/credential-utils.ts +4 -4
- package/src/packlets/testing/index.ts +0 -1
- package/src/packlets/testing/invitation-utils.ts +28 -33
- package/src/packlets/testing/test-builder.ts +132 -168
- package/src/packlets/vault/iframe-host-runtime.ts +8 -11
- package/src/packlets/vault/iframe-proxy-runtime.ts +25 -9
- package/src/packlets/vault/shell-runtime.ts +4 -4
- package/src/packlets/vault/vault-resource-lock.ts +2 -2
- package/src/packlets/vault/worker-runtime.ts +7 -9
- package/src/packlets/vault/worker-session.ts +24 -45
- package/dist/lib/browser/chunk-T73F4MV4.mjs.map +0 -7
- package/dist/types/src/packlets/services/utils.d.ts +0 -7
- package/dist/types/src/packlets/services/utils.d.ts.map +0 -1
- package/dist/types/src/packlets/testing/host-test-builder.d.ts +0 -43
- package/dist/types/src/packlets/testing/host-test-builder.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/client-services.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/client-services.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/client.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/client.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/halo-credentials.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/halo-credentials.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/halo-persistent.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/halo-persistent.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/halo-profile.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/halo-profile.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/invitations.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/invitations.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/shared-worker.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/shared-worker.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/spaces-invitations.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/spaces-invitations.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/spaces.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/spaces.test.d.ts.map +0 -1
- package/dist/types/src/packlets/tests/text.test.d.ts +0 -2
- package/dist/types/src/packlets/tests/text.test.d.ts.map +0 -1
- package/src/packlets/services/utils.ts +0 -53
- package/src/packlets/testing/host-test-builder.ts +0 -163
- package/src/packlets/tests/client-services.test.ts +0 -222
- package/src/packlets/tests/client.test.ts +0 -140
- package/src/packlets/tests/halo-credentials.test.ts +0 -94
- package/src/packlets/tests/halo-persistent.test.ts +0 -53
- package/src/packlets/tests/halo-profile.test.ts +0 -48
- package/src/packlets/tests/invitations.test.ts +0 -389
- package/src/packlets/tests/shared-worker.test.ts +0 -92
- package/src/packlets/tests/spaces-invitations.test.ts +0 -46
- package/src/packlets/tests/spaces.test.ts +0 -147
- package/src/packlets/tests/text.test.ts +0 -206
package/dist/lib/node/index.cjs
CHANGED
|
@@ -31,6 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
ClientServicesHost: () => ClientServicesHost,
|
|
34
|
+
DataSpace: () => DataSpace,
|
|
35
|
+
DataSpaceManager: () => DataSpaceManager,
|
|
34
36
|
DeviceInvitationProtocol: () => DeviceInvitationProtocol,
|
|
35
37
|
DevtoolsHostEvents: () => DevtoolsHostEvents,
|
|
36
38
|
DevtoolsServiceImpl: () => DevtoolsServiceImpl,
|
|
@@ -47,13 +49,13 @@ __export(src_exports, {
|
|
|
47
49
|
ServiceRegistry: () => ServiceRegistry,
|
|
48
50
|
ShellRuntimeImpl: () => ShellRuntimeImpl,
|
|
49
51
|
SpaceInvitationProtocol: () => SpaceInvitationProtocol,
|
|
52
|
+
SpacesServiceImpl: () => SpacesServiceImpl,
|
|
50
53
|
TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
|
|
51
54
|
VaultResourceLock: () => VaultResourceLock,
|
|
52
55
|
WorkerRuntime: () => WorkerRuntime,
|
|
53
56
|
WorkerSession: () => WorkerSession,
|
|
54
57
|
createAuthProvider: () => createAuthProvider,
|
|
55
58
|
createStorageObjects: () => createStorageObjects,
|
|
56
|
-
fromHost: () => fromHost,
|
|
57
59
|
getNetworkPeers: () => getNetworkPeers,
|
|
58
60
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
59
61
|
subscribeToFeeds: () => subscribeToFeeds,
|
|
@@ -66,7 +68,7 @@ __export(src_exports, {
|
|
|
66
68
|
module.exports = __toCommonJS(src_exports);
|
|
67
69
|
|
|
68
70
|
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
69
|
-
var
|
|
71
|
+
var import_async3 = require("@dxos/async");
|
|
70
72
|
var import_codec_protobuf5 = require("@dxos/codec-protobuf");
|
|
71
73
|
|
|
72
74
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
@@ -77,9 +79,6 @@ var import_keys = require("@dxos/keys");
|
|
|
77
79
|
var import_util = require("@dxos/util");
|
|
78
80
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
79
81
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
80
|
-
if ((feedKeys == null ? void 0 : feedKeys.length) === 0) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
82
|
const subscriptions = new import_async.EventSubscriptions();
|
|
84
83
|
const feedMap = new import_util.ComplexMap(import_keys.PublicKey.hash);
|
|
85
84
|
const update = () => {
|
|
@@ -88,13 +87,14 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
88
87
|
if (!feedMap.has(feed.key)) {
|
|
89
88
|
feedMap.set(feed.key, feed);
|
|
90
89
|
feed.on("close", update);
|
|
91
|
-
subscriptions.add(feed.off("close", update));
|
|
90
|
+
subscriptions.add(() => feed.off("close", update));
|
|
92
91
|
}
|
|
93
92
|
});
|
|
94
93
|
next({
|
|
95
94
|
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
96
95
|
feedKey: feed.key,
|
|
97
|
-
length: feed.properties.length
|
|
96
|
+
length: feed.properties.length,
|
|
97
|
+
diskUsage: feed.core.byteLength
|
|
98
98
|
}))
|
|
99
99
|
});
|
|
100
100
|
};
|
|
@@ -145,26 +145,26 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
// packages/sdk/client-services/src/packlets/devtools/keys.ts
|
|
148
|
+
var import_async2 = require("@dxos/async");
|
|
148
149
|
var import_codec_protobuf2 = require("@dxos/codec-protobuf");
|
|
149
|
-
var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf2.Stream(({ next }) => {
|
|
150
|
-
const update = () => {
|
|
150
|
+
var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf2.Stream(({ next, ctx }) => {
|
|
151
|
+
const update = async () => {
|
|
151
152
|
next({
|
|
152
|
-
keys: keyring.list()
|
|
153
|
+
keys: await keyring.list()
|
|
153
154
|
});
|
|
154
155
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return unsubscribe;
|
|
156
|
+
keyring.keysUpdate.on(ctx, update);
|
|
157
|
+
(0, import_async2.scheduleTask)(ctx, update);
|
|
158
158
|
});
|
|
159
159
|
|
|
160
160
|
// packages/sdk/client-services/src/packlets/devtools/network.ts
|
|
161
161
|
var import_codec_protobuf3 = require("@dxos/codec-protobuf");
|
|
162
162
|
var import_context = require("@dxos/context");
|
|
163
163
|
var import_keys2 = require("@dxos/keys");
|
|
164
|
-
var subscribeToNetworkStatus = ({
|
|
164
|
+
var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf3.Stream(({ next, close }) => {
|
|
165
165
|
const update = () => {
|
|
166
166
|
try {
|
|
167
|
-
const status =
|
|
167
|
+
const status = signalManager.getStatus();
|
|
168
168
|
next({
|
|
169
169
|
servers: status
|
|
170
170
|
});
|
|
@@ -172,12 +172,12 @@ var subscribeToNetworkStatus = ({ networkManager }) => new import_codec_protobuf
|
|
|
172
172
|
close(err);
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
|
-
|
|
175
|
+
signalManager.statusChanged.on(() => update());
|
|
176
176
|
update();
|
|
177
177
|
});
|
|
178
|
-
var subscribeToSignal = ({
|
|
178
|
+
var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf3.Stream(({ next }) => {
|
|
179
179
|
const ctx = new import_context.Context();
|
|
180
|
-
|
|
180
|
+
signalManager.onMessage.on(ctx, (message) => {
|
|
181
181
|
next({
|
|
182
182
|
message: {
|
|
183
183
|
author: message.author.asUint8Array(),
|
|
@@ -187,7 +187,7 @@ var subscribeToSignal = ({ networkManager }) => new import_codec_protobuf3.Strea
|
|
|
187
187
|
receivedAt: new Date()
|
|
188
188
|
});
|
|
189
189
|
});
|
|
190
|
-
|
|
190
|
+
signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
191
191
|
next({
|
|
192
192
|
swarmEvent: swarmEvent.swarmEvent,
|
|
193
193
|
receivedAt: new Date()
|
|
@@ -284,7 +284,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
284
284
|
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
285
285
|
var DevtoolsHostEvents = class {
|
|
286
286
|
constructor() {
|
|
287
|
-
this.ready = new
|
|
287
|
+
this.ready = new import_async3.Event();
|
|
288
288
|
}
|
|
289
289
|
};
|
|
290
290
|
var DevtoolsServiceImpl = class {
|
|
@@ -303,6 +303,24 @@ var DevtoolsServiceImpl = class {
|
|
|
303
303
|
getConfig(request) {
|
|
304
304
|
throw new Error();
|
|
305
305
|
}
|
|
306
|
+
async getStorageInfo() {
|
|
307
|
+
var _a, _b, _c, _d, _e;
|
|
308
|
+
const storageUsage = (_c = await ((_b = (_a = this.params.context.storage).getDiskInfo) == null ? void 0 : _b.call(_a))) != null ? _c : {
|
|
309
|
+
used: 0
|
|
310
|
+
};
|
|
311
|
+
const navigatorInfo = typeof navigator === "object" ? await navigator.storage.estimate() : void 0;
|
|
312
|
+
return {
|
|
313
|
+
type: this.params.context.storage.type,
|
|
314
|
+
storageUsage: storageUsage.used,
|
|
315
|
+
originUsage: (_d = navigatorInfo == null ? void 0 : navigatorInfo.usage) != null ? _d : 0,
|
|
316
|
+
usageQuota: (_e = navigatorInfo == null ? void 0 : navigatorInfo.quota) != null ? _e : 0
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
async getSnapshots() {
|
|
320
|
+
return {
|
|
321
|
+
snapshots: await this.params.context.snapshotStore.listSnapshots()
|
|
322
|
+
};
|
|
323
|
+
}
|
|
306
324
|
resetStorage(request) {
|
|
307
325
|
throw new Error();
|
|
308
326
|
}
|
|
@@ -353,12 +371,12 @@ var DevtoolsServiceImpl = class {
|
|
|
353
371
|
}
|
|
354
372
|
subscribeToSignalStatus(request) {
|
|
355
373
|
return subscribeToNetworkStatus({
|
|
356
|
-
|
|
374
|
+
signalManager: this.params.context.signalManager
|
|
357
375
|
});
|
|
358
376
|
}
|
|
359
377
|
subscribeToSignal() {
|
|
360
378
|
return subscribeToSignal({
|
|
361
|
-
|
|
379
|
+
signalManager: this.params.context.signalManager
|
|
362
380
|
});
|
|
363
381
|
}
|
|
364
382
|
subscribeToSwarmInfo() {
|
|
@@ -369,7 +387,7 @@ var DevtoolsServiceImpl = class {
|
|
|
369
387
|
};
|
|
370
388
|
|
|
371
389
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
372
|
-
var
|
|
390
|
+
var import_async4 = require("@dxos/async");
|
|
373
391
|
var import_context2 = require("@dxos/context");
|
|
374
392
|
var import_credentials = require("@dxos/credentials");
|
|
375
393
|
var import_log = require("@dxos/log");
|
|
@@ -439,7 +457,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
439
457
|
});
|
|
440
458
|
return true;
|
|
441
459
|
}
|
|
442
|
-
const trigger = new
|
|
460
|
+
const trigger = new import_async4.Trigger();
|
|
443
461
|
this._ctx.onDispose(() => {
|
|
444
462
|
trigger.wake(false);
|
|
445
463
|
});
|
|
@@ -484,7 +502,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
484
502
|
|
|
485
503
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
486
504
|
var import_node_assert = __toESM(require("node:assert"));
|
|
487
|
-
var
|
|
505
|
+
var import_async5 = require("@dxos/async");
|
|
488
506
|
var import_credentials2 = require("@dxos/credentials");
|
|
489
507
|
var import_debug = require("@dxos/debug");
|
|
490
508
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
@@ -493,7 +511,7 @@ var import_credentials3 = require("@dxos/protocols/proto/dxos/halo/credentials")
|
|
|
493
511
|
var AUTH_TIMEOUT = 3e4;
|
|
494
512
|
var Identity = class {
|
|
495
513
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
496
|
-
this.stateUpdate = new
|
|
514
|
+
this.stateUpdate = new import_async5.Event();
|
|
497
515
|
this.space = space;
|
|
498
516
|
this._signer = signer;
|
|
499
517
|
this.identityKey = identityKey;
|
|
@@ -627,7 +645,7 @@ var Identity = class {
|
|
|
627
645
|
|
|
628
646
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
629
647
|
var import_node_assert2 = __toESM(require("node:assert"));
|
|
630
|
-
var
|
|
648
|
+
var import_async6 = require("@dxos/async");
|
|
631
649
|
var import_credentials4 = require("@dxos/credentials");
|
|
632
650
|
var import_keys4 = require("@dxos/keys");
|
|
633
651
|
var import_log3 = require("@dxos/log");
|
|
@@ -642,20 +660,19 @@ var IdentityManager = class {
|
|
|
642
660
|
this._keyring = _keyring;
|
|
643
661
|
this._feedStore = _feedStore;
|
|
644
662
|
this._spaceManager = _spaceManager;
|
|
645
|
-
this.stateUpdate = new
|
|
646
|
-
this._instanceId = import_keys4.PublicKey.random().toHex();
|
|
663
|
+
this.stateUpdate = new import_async6.Event();
|
|
647
664
|
}
|
|
648
665
|
get identity() {
|
|
649
666
|
return this._identity;
|
|
650
667
|
}
|
|
651
668
|
async open() {
|
|
652
669
|
var _a;
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
670
|
+
const traceId = import_keys4.PublicKey.random().toHex();
|
|
671
|
+
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
|
|
672
|
+
id: traceId
|
|
656
673
|
}), {
|
|
657
674
|
file: "identity-manager.ts",
|
|
658
|
-
line:
|
|
675
|
+
line: 70,
|
|
659
676
|
scope: this,
|
|
660
677
|
callSite: (f, a) => f(...a)
|
|
661
678
|
});
|
|
@@ -665,7 +682,7 @@ var IdentityManager = class {
|
|
|
665
682
|
identityRecord
|
|
666
683
|
}, {
|
|
667
684
|
file: "identity-manager.ts",
|
|
668
|
-
line:
|
|
685
|
+
line: 74,
|
|
669
686
|
scope: this,
|
|
670
687
|
callSite: (f, a) => f(...a)
|
|
671
688
|
});
|
|
@@ -678,31 +695,31 @@ var IdentityManager = class {
|
|
|
678
695
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
679
696
|
}, {
|
|
680
697
|
file: "identity-manager.ts",
|
|
681
|
-
line:
|
|
698
|
+
line: 79,
|
|
682
699
|
scope: this,
|
|
683
700
|
callSite: (f, a) => f(...a)
|
|
684
701
|
});
|
|
685
702
|
this.stateUpdate.emit();
|
|
686
703
|
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
var _a;
|
|
690
|
-
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
691
|
-
import_log3.log.trace("dxos.halo.identity-manager", import_protocols2.trace.end({
|
|
692
|
-
id: this._instanceId
|
|
704
|
+
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.end({
|
|
705
|
+
id: traceId
|
|
693
706
|
}), {
|
|
694
707
|
file: "identity-manager.ts",
|
|
695
|
-
line:
|
|
708
|
+
line: 85,
|
|
696
709
|
scope: this,
|
|
697
710
|
callSite: (f, a) => f(...a)
|
|
698
711
|
});
|
|
699
712
|
}
|
|
713
|
+
async close() {
|
|
714
|
+
var _a;
|
|
715
|
+
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
716
|
+
}
|
|
700
717
|
async createIdentity({ displayName } = {}) {
|
|
701
718
|
var _a;
|
|
702
719
|
(0, import_node_assert2.default)(!this._identity, "Identity already exists.");
|
|
703
720
|
(0, import_log3.log)("creating identity...", {}, {
|
|
704
721
|
file: "identity-manager.ts",
|
|
705
|
-
line:
|
|
722
|
+
line: 94,
|
|
706
723
|
scope: this,
|
|
707
724
|
callSite: (f, a) => f(...a)
|
|
708
725
|
});
|
|
@@ -751,7 +768,7 @@ var IdentityManager = class {
|
|
|
751
768
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
752
769
|
}, {
|
|
753
770
|
file: "identity-manager.ts",
|
|
754
|
-
line:
|
|
771
|
+
line: 149,
|
|
755
772
|
scope: this,
|
|
756
773
|
callSite: (f, a) => f(...a)
|
|
757
774
|
});
|
|
@@ -761,7 +778,7 @@ var IdentityManager = class {
|
|
|
761
778
|
deviceKey: identity.deviceKey
|
|
762
779
|
}, {
|
|
763
780
|
file: "identity-manager.ts",
|
|
764
|
-
line:
|
|
781
|
+
line: 155,
|
|
765
782
|
scope: this,
|
|
766
783
|
callSite: (f, a) => f(...a)
|
|
767
784
|
});
|
|
@@ -776,7 +793,7 @@ var IdentityManager = class {
|
|
|
776
793
|
params
|
|
777
794
|
}, {
|
|
778
795
|
file: "identity-manager.ts",
|
|
779
|
-
line:
|
|
796
|
+
line: 163,
|
|
780
797
|
scope: this,
|
|
781
798
|
callSite: (f, a) => f(...a)
|
|
782
799
|
});
|
|
@@ -802,7 +819,7 @@ var IdentityManager = class {
|
|
|
802
819
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
803
820
|
}, {
|
|
804
821
|
file: "identity-manager.ts",
|
|
805
|
-
line:
|
|
822
|
+
line: 183,
|
|
806
823
|
scope: this,
|
|
807
824
|
callSite: (f, a) => f(...a)
|
|
808
825
|
});
|
|
@@ -812,7 +829,7 @@ var IdentityManager = class {
|
|
|
812
829
|
deviceKey: identity.deviceKey
|
|
813
830
|
}, {
|
|
814
831
|
file: "identity-manager.ts",
|
|
815
|
-
line:
|
|
832
|
+
line: 189,
|
|
816
833
|
scope: this,
|
|
817
834
|
callSite: (f, a) => f(...a)
|
|
818
835
|
});
|
|
@@ -824,7 +841,7 @@ var IdentityManager = class {
|
|
|
824
841
|
identityRecord
|
|
825
842
|
}, {
|
|
826
843
|
file: "identity-manager.ts",
|
|
827
|
-
line:
|
|
844
|
+
line: 195,
|
|
828
845
|
scope: this,
|
|
829
846
|
callSite: (f, a) => f(...a)
|
|
830
847
|
});
|
|
@@ -857,7 +874,7 @@ var IdentityManager = class {
|
|
|
857
874
|
identityKey: identityRecord.identityKey
|
|
858
875
|
}, {
|
|
859
876
|
file: "identity-manager.ts",
|
|
860
|
-
line:
|
|
877
|
+
line: 223,
|
|
861
878
|
scope: this,
|
|
862
879
|
callSite: (f, a) => f(...a)
|
|
863
880
|
});
|
|
@@ -874,7 +891,8 @@ var IdentityManager = class {
|
|
|
874
891
|
},
|
|
875
892
|
swarmIdentity,
|
|
876
893
|
onNetworkConnection: () => {
|
|
877
|
-
}
|
|
894
|
+
},
|
|
895
|
+
memberKey: identityKey
|
|
878
896
|
});
|
|
879
897
|
}
|
|
880
898
|
};
|
|
@@ -994,8 +1012,8 @@ var DeviceInvitationProtocol = class {
|
|
|
994
1012
|
|
|
995
1013
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
996
1014
|
var import_node_assert6 = __toESM(require("node:assert"));
|
|
997
|
-
var
|
|
998
|
-
var
|
|
1015
|
+
var import_async8 = require("@dxos/async");
|
|
1016
|
+
var import_client_protocol = require("@dxos/client-protocol");
|
|
999
1017
|
var import_context4 = require("@dxos/context");
|
|
1000
1018
|
var import_credentials7 = require("@dxos/credentials");
|
|
1001
1019
|
var import_errors2 = require("@dxos/errors");
|
|
@@ -1008,7 +1026,7 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
|
|
|
1008
1026
|
|
|
1009
1027
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
1010
1028
|
var import_node_assert5 = __toESM(require("node:assert"));
|
|
1011
|
-
var
|
|
1029
|
+
var import_async7 = require("@dxos/async");
|
|
1012
1030
|
var import_context3 = require("@dxos/context");
|
|
1013
1031
|
var import_errors = require("@dxos/errors");
|
|
1014
1032
|
var import_keys5 = require("@dxos/keys");
|
|
@@ -1029,7 +1047,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1029
1047
|
});
|
|
1030
1048
|
this._callbacks = _callbacks;
|
|
1031
1049
|
this._ctx = new import_context3.Context();
|
|
1032
|
-
this._remoteOptionsTrigger = new
|
|
1050
|
+
this._remoteOptionsTrigger = new import_async7.Trigger();
|
|
1033
1051
|
}
|
|
1034
1052
|
async getHandlers() {
|
|
1035
1053
|
return {
|
|
@@ -1044,11 +1062,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1044
1062
|
introduce: async (request) => {
|
|
1045
1063
|
const traceId = import_keys5.PublicKey.random().toHex();
|
|
1046
1064
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
|
|
1047
|
-
id: traceId
|
|
1048
|
-
parentId: this._traceParent
|
|
1065
|
+
id: traceId
|
|
1049
1066
|
}), {
|
|
1050
1067
|
file: "invitation-extension.ts",
|
|
1051
|
-
line:
|
|
1068
|
+
line: 76,
|
|
1052
1069
|
scope: this,
|
|
1053
1070
|
callSite: (f, a) => f(...a)
|
|
1054
1071
|
});
|
|
@@ -1057,7 +1074,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1057
1074
|
id: traceId
|
|
1058
1075
|
}), {
|
|
1059
1076
|
file: "invitation-extension.ts",
|
|
1060
|
-
line:
|
|
1077
|
+
line: 78,
|
|
1061
1078
|
scope: this,
|
|
1062
1079
|
callSite: (f, a) => f(...a)
|
|
1063
1080
|
});
|
|
@@ -1066,11 +1083,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1066
1083
|
authenticate: async (request) => {
|
|
1067
1084
|
const traceId = import_keys5.PublicKey.random().toHex();
|
|
1068
1085
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
|
|
1069
|
-
id: traceId
|
|
1070
|
-
parentId: this._traceParent
|
|
1086
|
+
id: traceId
|
|
1071
1087
|
}), {
|
|
1072
1088
|
file: "invitation-extension.ts",
|
|
1073
|
-
line:
|
|
1089
|
+
line: 84,
|
|
1074
1090
|
scope: this,
|
|
1075
1091
|
callSite: (f, a) => f(...a)
|
|
1076
1092
|
});
|
|
@@ -1082,7 +1098,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1082
1098
|
}
|
|
1083
1099
|
}), {
|
|
1084
1100
|
file: "invitation-extension.ts",
|
|
1085
|
-
line:
|
|
1101
|
+
line: 86,
|
|
1086
1102
|
scope: this,
|
|
1087
1103
|
callSite: (f, a) => f(...a)
|
|
1088
1104
|
});
|
|
@@ -1091,11 +1107,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1091
1107
|
admit: async (request) => {
|
|
1092
1108
|
const traceId = import_keys5.PublicKey.random().toHex();
|
|
1093
1109
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
|
|
1094
|
-
id: traceId
|
|
1095
|
-
parentId: this._traceParent
|
|
1110
|
+
id: traceId
|
|
1096
1111
|
}), {
|
|
1097
1112
|
file: "invitation-extension.ts",
|
|
1098
|
-
line:
|
|
1113
|
+
line: 92,
|
|
1099
1114
|
scope: this,
|
|
1100
1115
|
callSite: (f, a) => f(...a)
|
|
1101
1116
|
});
|
|
@@ -1104,7 +1119,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1104
1119
|
id: traceId
|
|
1105
1120
|
}), {
|
|
1106
1121
|
file: "invitation-extension.ts",
|
|
1107
|
-
line:
|
|
1122
|
+
line: 94,
|
|
1108
1123
|
scope: this,
|
|
1109
1124
|
callSite: (f, a) => f(...a)
|
|
1110
1125
|
});
|
|
@@ -1150,7 +1165,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1150
1165
|
});
|
|
1151
1166
|
this._callbacks = _callbacks;
|
|
1152
1167
|
this._ctx = new import_context3.Context();
|
|
1153
|
-
this._remoteOptionsTrigger = new
|
|
1168
|
+
this._remoteOptionsTrigger = new import_async7.Trigger();
|
|
1154
1169
|
}
|
|
1155
1170
|
async getHandlers() {
|
|
1156
1171
|
return {
|
|
@@ -1178,7 +1193,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1178
1193
|
try {
|
|
1179
1194
|
(0, import_log4.log)("begin options", {}, {
|
|
1180
1195
|
file: "invitation-extension.ts",
|
|
1181
|
-
line:
|
|
1196
|
+
line: 178,
|
|
1182
1197
|
scope: this,
|
|
1183
1198
|
callSite: (f, a) => f(...a)
|
|
1184
1199
|
});
|
|
@@ -1190,7 +1205,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1190
1205
|
}));
|
|
1191
1206
|
(0, import_log4.log)("end options", {}, {
|
|
1192
1207
|
file: "invitation-extension.ts",
|
|
1193
|
-
line:
|
|
1208
|
+
line: 181,
|
|
1194
1209
|
scope: this,
|
|
1195
1210
|
callSite: (f, a) => f(...a)
|
|
1196
1211
|
});
|
|
@@ -1204,7 +1219,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1204
1219
|
} catch (err) {
|
|
1205
1220
|
(0, import_log4.log)("openError", err, {
|
|
1206
1221
|
file: "invitation-extension.ts",
|
|
1207
|
-
line:
|
|
1222
|
+
line: 191,
|
|
1208
1223
|
scope: this,
|
|
1209
1224
|
callSite: (f, a) => f(...a)
|
|
1210
1225
|
});
|
|
@@ -1214,7 +1229,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1214
1229
|
async onClose() {
|
|
1215
1230
|
(0, import_log4.log)("onClose", {}, {
|
|
1216
1231
|
file: "invitation-extension.ts",
|
|
1217
|
-
line:
|
|
1232
|
+
line: 197,
|
|
1218
1233
|
scope: this,
|
|
1219
1234
|
callSite: (f, a) => f(...a)
|
|
1220
1235
|
});
|
|
@@ -1225,13 +1240,16 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1225
1240
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1226
1241
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1227
1242
|
var InvitationsHandler = class {
|
|
1243
|
+
/**
|
|
1244
|
+
* @internal
|
|
1245
|
+
*/
|
|
1228
1246
|
constructor(_networkManager) {
|
|
1229
1247
|
this._networkManager = _networkManager;
|
|
1230
1248
|
}
|
|
1231
1249
|
createInvitation(protocol, options) {
|
|
1232
1250
|
var _a;
|
|
1233
|
-
const { invitationId = import_keys6.PublicKey.random().toHex(), type = import_services2.Invitation.Type.INTERACTIVE, authMethod = import_services2.Invitation.AuthMethod.SHARED_SECRET, state = import_services2.Invitation.State.INIT, timeout =
|
|
1234
|
-
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services2.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(
|
|
1251
|
+
const { invitationId = import_keys6.PublicKey.random().toHex(), type = import_services2.Invitation.Type.INTERACTIVE, authMethod = import_services2.Invitation.AuthMethod.SHARED_SECRET, state = import_services2.Invitation.State.INIT, timeout = import_client_protocol.INVITATION_TIMEOUT, swarmKey = import_keys6.PublicKey.random() } = options != null ? options : {};
|
|
1252
|
+
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services2.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol.AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1235
1253
|
(0, import_node_assert6.default)(protocol);
|
|
1236
1254
|
const invitation = {
|
|
1237
1255
|
invitationId,
|
|
@@ -1243,7 +1261,7 @@ var InvitationsHandler = class {
|
|
|
1243
1261
|
timeout,
|
|
1244
1262
|
...protocol.getInvitationContext()
|
|
1245
1263
|
};
|
|
1246
|
-
const stream = new
|
|
1264
|
+
const stream = new import_async8.PushStream();
|
|
1247
1265
|
const ctx = new import_context4.Context({
|
|
1248
1266
|
onError: (err) => {
|
|
1249
1267
|
void ctx.dispose();
|
|
@@ -1255,14 +1273,14 @@ var InvitationsHandler = class {
|
|
|
1255
1273
|
...protocol.toJSON()
|
|
1256
1274
|
}, {
|
|
1257
1275
|
file: "invitations-handler.ts",
|
|
1258
|
-
line:
|
|
1276
|
+
line: 98,
|
|
1259
1277
|
scope: this,
|
|
1260
1278
|
callSite: (f, a) => f(...a)
|
|
1261
1279
|
});
|
|
1262
1280
|
stream.complete();
|
|
1263
1281
|
});
|
|
1264
1282
|
const createExtension = () => {
|
|
1265
|
-
const success = new
|
|
1283
|
+
const success = new import_async8.Trigger();
|
|
1266
1284
|
let guestProfile;
|
|
1267
1285
|
let authenticationPassed = false;
|
|
1268
1286
|
let authenticationRetry = 0;
|
|
@@ -1273,7 +1291,7 @@ var InvitationsHandler = class {
|
|
|
1273
1291
|
...protocol.toJSON()
|
|
1274
1292
|
}, {
|
|
1275
1293
|
file: "invitations-handler.ts",
|
|
1276
|
-
line:
|
|
1294
|
+
line: 111,
|
|
1277
1295
|
scope: this,
|
|
1278
1296
|
callSite: (f, a) => f(...a)
|
|
1279
1297
|
});
|
|
@@ -1292,7 +1310,7 @@ var InvitationsHandler = class {
|
|
|
1292
1310
|
authCode: code
|
|
1293
1311
|
}, {
|
|
1294
1312
|
file: "invitations-handler.ts",
|
|
1295
|
-
line:
|
|
1313
|
+
line: 130,
|
|
1296
1314
|
scope: this,
|
|
1297
1315
|
callSite: (f, a) => f(...a)
|
|
1298
1316
|
});
|
|
@@ -1301,7 +1319,7 @@ var InvitationsHandler = class {
|
|
|
1301
1319
|
case import_services2.Invitation.AuthMethod.NONE: {
|
|
1302
1320
|
(0, import_log5.log)("authentication not required", {}, {
|
|
1303
1321
|
file: "invitations-handler.ts",
|
|
1304
|
-
line:
|
|
1322
|
+
line: 135,
|
|
1305
1323
|
scope: this,
|
|
1306
1324
|
callSite: (f, a) => f(...a)
|
|
1307
1325
|
});
|
|
@@ -1326,7 +1344,7 @@ var InvitationsHandler = class {
|
|
|
1326
1344
|
authMethod: invitation.authMethod
|
|
1327
1345
|
}, {
|
|
1328
1346
|
file: "invitations-handler.ts",
|
|
1329
|
-
line:
|
|
1347
|
+
line: 153,
|
|
1330
1348
|
scope: this,
|
|
1331
1349
|
callSite: (f, a) => f(...a)
|
|
1332
1350
|
});
|
|
@@ -1355,15 +1373,14 @@ var InvitationsHandler = class {
|
|
|
1355
1373
|
}
|
|
1356
1374
|
},
|
|
1357
1375
|
onOpen: () => {
|
|
1358
|
-
(0,
|
|
1376
|
+
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1359
1377
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1360
1378
|
try {
|
|
1361
1379
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
|
|
1362
|
-
id: traceId
|
|
1363
|
-
parentId: this._traceParent
|
|
1380
|
+
id: traceId
|
|
1364
1381
|
}), {
|
|
1365
1382
|
file: "invitations-handler.ts",
|
|
1366
|
-
line:
|
|
1383
|
+
line: 188,
|
|
1367
1384
|
scope: this,
|
|
1368
1385
|
callSite: (f, a) => f(...a)
|
|
1369
1386
|
});
|
|
@@ -1371,7 +1388,7 @@ var InvitationsHandler = class {
|
|
|
1371
1388
|
...protocol.toJSON()
|
|
1372
1389
|
}, {
|
|
1373
1390
|
file: "invitations-handler.ts",
|
|
1374
|
-
line:
|
|
1391
|
+
line: 189,
|
|
1375
1392
|
scope: this,
|
|
1376
1393
|
callSite: (f, a) => f(...a)
|
|
1377
1394
|
});
|
|
@@ -1387,7 +1404,7 @@ var InvitationsHandler = class {
|
|
|
1387
1404
|
...protocol.toJSON()
|
|
1388
1405
|
}, {
|
|
1389
1406
|
file: "invitations-handler.ts",
|
|
1390
|
-
line:
|
|
1407
|
+
line: 192,
|
|
1391
1408
|
scope: this,
|
|
1392
1409
|
callSite: (f, a) => f(...a)
|
|
1393
1410
|
});
|
|
@@ -1399,17 +1416,17 @@ var InvitationsHandler = class {
|
|
|
1399
1416
|
id: traceId
|
|
1400
1417
|
}), {
|
|
1401
1418
|
file: "invitations-handler.ts",
|
|
1402
|
-
line:
|
|
1419
|
+
line: 194,
|
|
1403
1420
|
scope: this,
|
|
1404
1421
|
callSite: (f, a) => f(...a)
|
|
1405
1422
|
});
|
|
1406
1423
|
} catch (err) {
|
|
1407
|
-
if (err instanceof
|
|
1424
|
+
if (err instanceof import_async8.TimeoutError) {
|
|
1408
1425
|
(0, import_log5.log)("timeout", {
|
|
1409
1426
|
...protocol.toJSON()
|
|
1410
1427
|
}, {
|
|
1411
1428
|
file: "invitations-handler.ts",
|
|
1412
|
-
line:
|
|
1429
|
+
line: 197,
|
|
1413
1430
|
scope: this,
|
|
1414
1431
|
callSite: (f, a) => f(...a)
|
|
1415
1432
|
});
|
|
@@ -1420,7 +1437,7 @@ var InvitationsHandler = class {
|
|
|
1420
1437
|
} else {
|
|
1421
1438
|
import_log5.log.error("failed", err, {
|
|
1422
1439
|
file: "invitations-handler.ts",
|
|
1423
|
-
line:
|
|
1440
|
+
line: 200,
|
|
1424
1441
|
scope: this,
|
|
1425
1442
|
callSite: (f, a) => f(...a)
|
|
1426
1443
|
});
|
|
@@ -1431,13 +1448,13 @@ var InvitationsHandler = class {
|
|
|
1431
1448
|
error: err
|
|
1432
1449
|
}), {
|
|
1433
1450
|
file: "invitations-handler.ts",
|
|
1434
|
-
line:
|
|
1451
|
+
line: 203,
|
|
1435
1452
|
scope: this,
|
|
1436
1453
|
callSite: (f, a) => f(...a)
|
|
1437
1454
|
});
|
|
1438
1455
|
} finally {
|
|
1439
1456
|
if (type !== import_services2.Invitation.Type.MULTIUSE) {
|
|
1440
|
-
await (0,
|
|
1457
|
+
await (0, import_async8.sleep)(import_client_protocol.ON_CLOSE_DELAY);
|
|
1441
1458
|
await ctx.dispose();
|
|
1442
1459
|
}
|
|
1443
1460
|
}
|
|
@@ -1447,12 +1464,12 @@ var InvitationsHandler = class {
|
|
|
1447
1464
|
if (err instanceof import_errors2.InvalidInvitationExtensionRoleError) {
|
|
1448
1465
|
return;
|
|
1449
1466
|
}
|
|
1450
|
-
if (err instanceof
|
|
1467
|
+
if (err instanceof import_async8.TimeoutError) {
|
|
1451
1468
|
(0, import_log5.log)("timeout", {
|
|
1452
1469
|
...protocol.toJSON()
|
|
1453
1470
|
}, {
|
|
1454
1471
|
file: "invitations-handler.ts",
|
|
1455
|
-
line:
|
|
1472
|
+
line: 217,
|
|
1456
1473
|
scope: this,
|
|
1457
1474
|
callSite: (f, a) => f(...a)
|
|
1458
1475
|
});
|
|
@@ -1463,7 +1480,7 @@ var InvitationsHandler = class {
|
|
|
1463
1480
|
} else {
|
|
1464
1481
|
import_log5.log.error("failed", err, {
|
|
1465
1482
|
file: "invitations-handler.ts",
|
|
1466
|
-
line:
|
|
1483
|
+
line: 220,
|
|
1467
1484
|
scope: this,
|
|
1468
1485
|
callSite: (f, a) => f(...a)
|
|
1469
1486
|
});
|
|
@@ -1471,10 +1488,9 @@ var InvitationsHandler = class {
|
|
|
1471
1488
|
}
|
|
1472
1489
|
}
|
|
1473
1490
|
});
|
|
1474
|
-
extension._traceParent = this._traceParent;
|
|
1475
1491
|
return extension;
|
|
1476
1492
|
};
|
|
1477
|
-
(0,
|
|
1493
|
+
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1478
1494
|
const topic = invitation.swarmKey;
|
|
1479
1495
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1480
1496
|
topic,
|
|
@@ -1490,7 +1506,7 @@ var InvitationsHandler = class {
|
|
|
1490
1506
|
state: import_services2.Invitation.State.CONNECTING
|
|
1491
1507
|
});
|
|
1492
1508
|
});
|
|
1493
|
-
const observable = new
|
|
1509
|
+
const observable = new import_client_protocol.CancellableInvitationObservable({
|
|
1494
1510
|
initialInvitation: invitation,
|
|
1495
1511
|
subscriber: stream.observable,
|
|
1496
1512
|
onCancel: async () => {
|
|
@@ -1504,11 +1520,11 @@ var InvitationsHandler = class {
|
|
|
1504
1520
|
return observable;
|
|
1505
1521
|
}
|
|
1506
1522
|
acceptInvitation(protocol, invitation) {
|
|
1507
|
-
const { timeout =
|
|
1523
|
+
const { timeout = import_client_protocol.INVITATION_TIMEOUT } = invitation;
|
|
1508
1524
|
(0, import_node_assert6.default)(protocol);
|
|
1509
|
-
const authenticated = new
|
|
1525
|
+
const authenticated = new import_async8.Trigger();
|
|
1510
1526
|
let currentState;
|
|
1511
|
-
const stream = new
|
|
1527
|
+
const stream = new import_async8.PushStream();
|
|
1512
1528
|
const setState = (newData) => {
|
|
1513
1529
|
(0, import_node_assert6.default)(newData.state !== void 0);
|
|
1514
1530
|
currentState = newData.state;
|
|
@@ -1519,12 +1535,12 @@ var InvitationsHandler = class {
|
|
|
1519
1535
|
};
|
|
1520
1536
|
const ctx = new import_context4.Context({
|
|
1521
1537
|
onError: (err) => {
|
|
1522
|
-
if (err instanceof
|
|
1538
|
+
if (err instanceof import_async8.TimeoutError) {
|
|
1523
1539
|
(0, import_log5.log)("timeout", {
|
|
1524
1540
|
...protocol.toJSON()
|
|
1525
1541
|
}, {
|
|
1526
1542
|
file: "invitations-handler.ts",
|
|
1527
|
-
line:
|
|
1543
|
+
line: 274,
|
|
1528
1544
|
scope: this,
|
|
1529
1545
|
callSite: (f, a) => f(...a)
|
|
1530
1546
|
});
|
|
@@ -1534,7 +1550,7 @@ var InvitationsHandler = class {
|
|
|
1534
1550
|
} else {
|
|
1535
1551
|
import_log5.log.warn("auth failed", err, {
|
|
1536
1552
|
file: "invitations-handler.ts",
|
|
1537
|
-
line:
|
|
1553
|
+
line: 277,
|
|
1538
1554
|
scope: this,
|
|
1539
1555
|
callSite: (f, a) => f(...a)
|
|
1540
1556
|
});
|
|
@@ -1548,7 +1564,7 @@ var InvitationsHandler = class {
|
|
|
1548
1564
|
...protocol.toJSON()
|
|
1549
1565
|
}, {
|
|
1550
1566
|
file: "invitations-handler.ts",
|
|
1551
|
-
line:
|
|
1567
|
+
line: 285,
|
|
1552
1568
|
scope: this,
|
|
1553
1569
|
callSite: (f, a) => f(...a)
|
|
1554
1570
|
});
|
|
@@ -1563,7 +1579,7 @@ var InvitationsHandler = class {
|
|
|
1563
1579
|
currentState
|
|
1564
1580
|
}, {
|
|
1565
1581
|
file: "invitations-handler.ts",
|
|
1566
|
-
line:
|
|
1582
|
+
line: 295,
|
|
1567
1583
|
scope: this,
|
|
1568
1584
|
callSite: (f, a) => f(...a)
|
|
1569
1585
|
});
|
|
@@ -1571,27 +1587,26 @@ var InvitationsHandler = class {
|
|
|
1571
1587
|
stream.error(new Error("Remote peer disconnected."));
|
|
1572
1588
|
}
|
|
1573
1589
|
});
|
|
1574
|
-
(0,
|
|
1590
|
+
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1575
1591
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1576
1592
|
try {
|
|
1577
1593
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
|
|
1578
|
-
id: traceId
|
|
1579
|
-
parentId: this._traceParent
|
|
1594
|
+
id: traceId
|
|
1580
1595
|
}), {
|
|
1581
1596
|
file: "invitations-handler.ts",
|
|
1582
|
-
line:
|
|
1597
|
+
line: 304,
|
|
1583
1598
|
scope: this,
|
|
1584
1599
|
callSite: (f, a) => f(...a)
|
|
1585
1600
|
});
|
|
1586
1601
|
if (++connectionCount > 1) {
|
|
1587
1602
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
1588
1603
|
}
|
|
1589
|
-
(0,
|
|
1604
|
+
(0, import_async8.scheduleTask)(ctx, () => ctx.raise(new import_async8.TimeoutError(timeout)), timeout);
|
|
1590
1605
|
(0, import_log5.log)("connected", {
|
|
1591
1606
|
...protocol.toJSON()
|
|
1592
1607
|
}, {
|
|
1593
1608
|
file: "invitations-handler.ts",
|
|
1594
|
-
line:
|
|
1609
|
+
line: 312,
|
|
1595
1610
|
scope: this,
|
|
1596
1611
|
callSite: (f, a) => f(...a)
|
|
1597
1612
|
});
|
|
@@ -1602,7 +1617,7 @@ var InvitationsHandler = class {
|
|
|
1602
1617
|
...protocol.toJSON()
|
|
1603
1618
|
}, {
|
|
1604
1619
|
file: "invitations-handler.ts",
|
|
1605
|
-
line:
|
|
1620
|
+
line: 316,
|
|
1606
1621
|
scope: this,
|
|
1607
1622
|
callSite: (f, a) => f(...a)
|
|
1608
1623
|
});
|
|
@@ -1612,7 +1627,7 @@ var InvitationsHandler = class {
|
|
|
1612
1627
|
response: introductionResponse
|
|
1613
1628
|
}, {
|
|
1614
1629
|
file: "invitations-handler.ts",
|
|
1615
|
-
line:
|
|
1630
|
+
line: 320,
|
|
1616
1631
|
scope: this,
|
|
1617
1632
|
callSite: (f, a) => f(...a)
|
|
1618
1633
|
});
|
|
@@ -1624,7 +1639,7 @@ var InvitationsHandler = class {
|
|
|
1624
1639
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1625
1640
|
(0, import_log5.log)("guest waiting for authentication code...", {}, {
|
|
1626
1641
|
file: "invitations-handler.ts",
|
|
1627
|
-
line:
|
|
1642
|
+
line: 329,
|
|
1628
1643
|
scope: this,
|
|
1629
1644
|
callSite: (f, a) => f(...a)
|
|
1630
1645
|
});
|
|
@@ -1636,7 +1651,7 @@ var InvitationsHandler = class {
|
|
|
1636
1651
|
});
|
|
1637
1652
|
(0, import_log5.log)("sending authentication request", {}, {
|
|
1638
1653
|
file: "invitations-handler.ts",
|
|
1639
|
-
line:
|
|
1654
|
+
line: 333,
|
|
1640
1655
|
scope: this,
|
|
1641
1656
|
callSite: (f, a) => f(...a)
|
|
1642
1657
|
});
|
|
@@ -1657,7 +1672,7 @@ var InvitationsHandler = class {
|
|
|
1657
1672
|
attempt
|
|
1658
1673
|
}, {
|
|
1659
1674
|
file: "invitations-handler.ts",
|
|
1660
|
-
line:
|
|
1675
|
+
line: 344,
|
|
1661
1676
|
scope: this,
|
|
1662
1677
|
callSite: (f, a) => f(...a)
|
|
1663
1678
|
});
|
|
@@ -1674,7 +1689,7 @@ var InvitationsHandler = class {
|
|
|
1674
1689
|
...protocol.toJSON()
|
|
1675
1690
|
}, {
|
|
1676
1691
|
file: "invitations-handler.ts",
|
|
1677
|
-
line:
|
|
1692
|
+
line: 355,
|
|
1678
1693
|
scope: this,
|
|
1679
1694
|
callSite: (f, a) => f(...a)
|
|
1680
1695
|
});
|
|
@@ -1685,7 +1700,7 @@ var InvitationsHandler = class {
|
|
|
1685
1700
|
...protocol.toJSON()
|
|
1686
1701
|
}, {
|
|
1687
1702
|
file: "invitations-handler.ts",
|
|
1688
|
-
line:
|
|
1703
|
+
line: 363,
|
|
1689
1704
|
scope: this,
|
|
1690
1705
|
callSite: (f, a) => f(...a)
|
|
1691
1706
|
});
|
|
@@ -1697,17 +1712,17 @@ var InvitationsHandler = class {
|
|
|
1697
1712
|
id: traceId
|
|
1698
1713
|
}), {
|
|
1699
1714
|
file: "invitations-handler.ts",
|
|
1700
|
-
line:
|
|
1715
|
+
line: 365,
|
|
1701
1716
|
scope: this,
|
|
1702
1717
|
callSite: (f, a) => f(...a)
|
|
1703
1718
|
});
|
|
1704
1719
|
} catch (err) {
|
|
1705
|
-
if (err instanceof
|
|
1720
|
+
if (err instanceof import_async8.TimeoutError) {
|
|
1706
1721
|
(0, import_log5.log)("timeout", {
|
|
1707
1722
|
...protocol.toJSON()
|
|
1708
1723
|
}, {
|
|
1709
1724
|
file: "invitations-handler.ts",
|
|
1710
|
-
line:
|
|
1725
|
+
line: 368,
|
|
1711
1726
|
scope: this,
|
|
1712
1727
|
callSite: (f, a) => f(...a)
|
|
1713
1728
|
});
|
|
@@ -1717,7 +1732,7 @@ var InvitationsHandler = class {
|
|
|
1717
1732
|
} else {
|
|
1718
1733
|
(0, import_log5.log)("auth failed", err, {
|
|
1719
1734
|
file: "invitations-handler.ts",
|
|
1720
|
-
line:
|
|
1735
|
+
line: 371,
|
|
1721
1736
|
scope: this,
|
|
1722
1737
|
callSite: (f, a) => f(...a)
|
|
1723
1738
|
});
|
|
@@ -1728,7 +1743,7 @@ var InvitationsHandler = class {
|
|
|
1728
1743
|
error: err
|
|
1729
1744
|
}), {
|
|
1730
1745
|
file: "invitations-handler.ts",
|
|
1731
|
-
line:
|
|
1746
|
+
line: 374,
|
|
1732
1747
|
scope: this,
|
|
1733
1748
|
callSite: (f, a) => f(...a)
|
|
1734
1749
|
});
|
|
@@ -1741,12 +1756,12 @@ var InvitationsHandler = class {
|
|
|
1741
1756
|
if (err instanceof import_errors2.InvalidInvitationExtensionRoleError) {
|
|
1742
1757
|
return;
|
|
1743
1758
|
}
|
|
1744
|
-
if (err instanceof
|
|
1759
|
+
if (err instanceof import_async8.TimeoutError) {
|
|
1745
1760
|
(0, import_log5.log)("timeout", {
|
|
1746
1761
|
...protocol.toJSON()
|
|
1747
1762
|
}, {
|
|
1748
1763
|
file: "invitations-handler.ts",
|
|
1749
|
-
line:
|
|
1764
|
+
line: 385,
|
|
1750
1765
|
scope: this,
|
|
1751
1766
|
callSite: (f, a) => f(...a)
|
|
1752
1767
|
});
|
|
@@ -1756,7 +1771,7 @@ var InvitationsHandler = class {
|
|
|
1756
1771
|
} else {
|
|
1757
1772
|
(0, import_log5.log)("auth failed", err, {
|
|
1758
1773
|
file: "invitations-handler.ts",
|
|
1759
|
-
line:
|
|
1774
|
+
line: 388,
|
|
1760
1775
|
scope: this,
|
|
1761
1776
|
callSite: (f, a) => f(...a)
|
|
1762
1777
|
});
|
|
@@ -1766,7 +1781,7 @@ var InvitationsHandler = class {
|
|
|
1766
1781
|
});
|
|
1767
1782
|
return extension;
|
|
1768
1783
|
};
|
|
1769
|
-
(0,
|
|
1784
|
+
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1770
1785
|
(0, import_node_assert6.default)(invitation.swarmKey);
|
|
1771
1786
|
const topic = invitation.swarmKey;
|
|
1772
1787
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
@@ -1782,7 +1797,7 @@ var InvitationsHandler = class {
|
|
|
1782
1797
|
state: import_services2.Invitation.State.CONNECTING
|
|
1783
1798
|
});
|
|
1784
1799
|
});
|
|
1785
|
-
const observable = new
|
|
1800
|
+
const observable = new import_client_protocol.AuthenticatingInvitationObservable({
|
|
1786
1801
|
initialInvitation: invitation,
|
|
1787
1802
|
subscriber: stream.observable,
|
|
1788
1803
|
onCancel: async () => {
|
|
@@ -1802,7 +1817,7 @@ var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_
|
|
|
1802
1817
|
|
|
1803
1818
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1804
1819
|
var import_node_assert7 = __toESM(require("node:assert"));
|
|
1805
|
-
var
|
|
1820
|
+
var import_async9 = require("@dxos/async");
|
|
1806
1821
|
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
1807
1822
|
var import_log6 = require("@dxos/log");
|
|
1808
1823
|
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -1812,10 +1827,10 @@ var InvitationsServiceImpl = class {
|
|
|
1812
1827
|
this._getHandler = _getHandler;
|
|
1813
1828
|
this._createInvitations = /* @__PURE__ */ new Map();
|
|
1814
1829
|
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
1815
|
-
this._invitationCreated = new
|
|
1816
|
-
this._invitationAccepted = new
|
|
1817
|
-
this._removedCreated = new
|
|
1818
|
-
this._removedAccepted = new
|
|
1830
|
+
this._invitationCreated = new import_async9.Event();
|
|
1831
|
+
this._invitationAccepted = new import_async9.Event();
|
|
1832
|
+
this._removedCreated = new import_async9.Event();
|
|
1833
|
+
this._removedAccepted = new import_async9.Event();
|
|
1819
1834
|
}
|
|
1820
1835
|
// TODO(burdon): Guest/host label.
|
|
1821
1836
|
getLoggingContext() {
|
|
@@ -2005,7 +2020,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2005
2020
|
guest: deviceKey
|
|
2006
2021
|
}, {
|
|
2007
2022
|
file: "space-invitation-protocol.ts",
|
|
2008
|
-
line:
|
|
2023
|
+
line: 50,
|
|
2009
2024
|
scope: this,
|
|
2010
2025
|
callSite: (f, a) => f(...a)
|
|
2011
2026
|
});
|
|
@@ -2060,15 +2075,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2060
2075
|
|
|
2061
2076
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
2062
2077
|
var import_node_assert14 = __toESM(require("node:assert"));
|
|
2063
|
-
var
|
|
2064
|
-
var
|
|
2065
|
-
var
|
|
2078
|
+
var import_async23 = require("@dxos/async");
|
|
2079
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
2080
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
2081
|
+
var import_keys11 = require("@dxos/keys");
|
|
2066
2082
|
var import_log19 = require("@dxos/log");
|
|
2067
|
-
var
|
|
2068
|
-
var
|
|
2083
|
+
var import_messaging3 = require("@dxos/messaging");
|
|
2084
|
+
var import_network_manager5 = require("@dxos/network-manager");
|
|
2085
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
2086
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2069
2087
|
|
|
2070
2088
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
2071
|
-
var
|
|
2089
|
+
var import_async10 = require("@dxos/async");
|
|
2072
2090
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
2073
2091
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2074
2092
|
var DevicesServiceImpl = class {
|
|
@@ -2099,7 +2117,7 @@ var DevicesServiceImpl = class {
|
|
|
2099
2117
|
});
|
|
2100
2118
|
}
|
|
2101
2119
|
};
|
|
2102
|
-
const subscriptions = new
|
|
2120
|
+
const subscriptions = new import_async10.EventSubscriptions();
|
|
2103
2121
|
subscriptions.add(this._identityManager.stateUpdate.on(() => {
|
|
2104
2122
|
update();
|
|
2105
2123
|
if (this._identityManager.identity) {
|
|
@@ -2115,12 +2133,12 @@ var DevicesServiceImpl = class {
|
|
|
2115
2133
|
};
|
|
2116
2134
|
|
|
2117
2135
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
2118
|
-
var
|
|
2136
|
+
var import_async11 = require("@dxos/async");
|
|
2119
2137
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
2120
2138
|
var import_log8 = require("@dxos/log");
|
|
2121
2139
|
var LoggingServiceImpl = class {
|
|
2122
2140
|
constructor() {
|
|
2123
|
-
this._logs = new
|
|
2141
|
+
this._logs = new import_async11.Event();
|
|
2124
2142
|
this._logProcessor = (_config, entry2) => {
|
|
2125
2143
|
this._logs.emit(entry2);
|
|
2126
2144
|
};
|
|
@@ -2152,19 +2170,23 @@ var LoggingServiceImpl = class {
|
|
|
2152
2170
|
});
|
|
2153
2171
|
}
|
|
2154
2172
|
};
|
|
2155
|
-
var jsonify = (value) => {
|
|
2173
|
+
var jsonify = (value, handles = /* @__PURE__ */ new WeakSet()) => {
|
|
2156
2174
|
if (typeof value === "function") {
|
|
2157
2175
|
return null;
|
|
2158
2176
|
} else if (typeof value === "object" && value !== null) {
|
|
2177
|
+
if (handles.has(value)) {
|
|
2178
|
+
return null;
|
|
2179
|
+
}
|
|
2180
|
+
handles.add(value);
|
|
2159
2181
|
if (Array.isArray(value)) {
|
|
2160
|
-
return value.map(jsonify);
|
|
2182
|
+
return value.map((x) => jsonify(x, handles));
|
|
2161
2183
|
} else {
|
|
2162
2184
|
if (typeof value.toJSON === "function") {
|
|
2163
2185
|
return value.toJSON();
|
|
2164
2186
|
}
|
|
2165
2187
|
const res = {};
|
|
2166
2188
|
for (const key of Object.keys(value)) {
|
|
2167
|
-
res[key] = jsonify(value[key]);
|
|
2189
|
+
res[key] = jsonify(value[key], handles);
|
|
2168
2190
|
}
|
|
2169
2191
|
return res;
|
|
2170
2192
|
}
|
|
@@ -2176,53 +2198,62 @@ var jsonify = (value) => {
|
|
|
2176
2198
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
2177
2199
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2178
2200
|
var NetworkServiceImpl = class {
|
|
2179
|
-
constructor(networkManager) {
|
|
2201
|
+
constructor(networkManager, signalManager) {
|
|
2180
2202
|
this.networkManager = networkManager;
|
|
2203
|
+
this.signalManager = signalManager;
|
|
2181
2204
|
}
|
|
2182
|
-
|
|
2205
|
+
queryStatus() {
|
|
2183
2206
|
return new import_codec_protobuf10.Stream(({ next }) => {
|
|
2184
|
-
const
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2207
|
+
const update = () => {
|
|
2208
|
+
next({
|
|
2209
|
+
swarm: this.networkManager.connectionState,
|
|
2210
|
+
signaling: this.signalManager.getStatus().map(({ host, state }) => ({
|
|
2211
|
+
server: host,
|
|
2212
|
+
state
|
|
2213
|
+
}))
|
|
2214
|
+
});
|
|
2215
|
+
};
|
|
2216
|
+
const unsubscribeSwarm = this.networkManager.connectionStateChanged.on(() => update());
|
|
2217
|
+
const unsubscribeSignal = this.signalManager.statusChanged.on(() => update());
|
|
2218
|
+
update();
|
|
2219
|
+
return () => {
|
|
2220
|
+
unsubscribeSwarm();
|
|
2221
|
+
unsubscribeSignal();
|
|
2222
|
+
};
|
|
2191
2223
|
});
|
|
2192
2224
|
}
|
|
2193
|
-
async
|
|
2194
|
-
await this.networkManager.setConnectionState(request.
|
|
2225
|
+
async updateConfig(request) {
|
|
2226
|
+
await this.networkManager.setConnectionState(request.swarm);
|
|
2195
2227
|
}
|
|
2196
2228
|
};
|
|
2197
2229
|
|
|
2198
2230
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2199
2231
|
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2200
|
-
var
|
|
2201
|
-
var import_client3 = require("@dxos/client");
|
|
2232
|
+
var import_async14 = require("@dxos/async");
|
|
2202
2233
|
var import_context7 = require("@dxos/context");
|
|
2203
|
-
var
|
|
2204
|
-
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
2234
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
2205
2235
|
var import_keys9 = require("@dxos/keys");
|
|
2206
2236
|
var import_log11 = require("@dxos/log");
|
|
2207
2237
|
var import_protocols6 = require("@dxos/protocols");
|
|
2238
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2208
2239
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
2209
2240
|
var import_util5 = require("@dxos/util");
|
|
2210
2241
|
|
|
2211
2242
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2212
|
-
var
|
|
2213
|
-
var import_client2 = require("@dxos/client");
|
|
2243
|
+
var import_async13 = require("@dxos/async");
|
|
2214
2244
|
var import_context6 = require("@dxos/context");
|
|
2215
2245
|
var import_debug3 = require("@dxos/debug");
|
|
2216
2246
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
2217
2247
|
var import_errors3 = require("@dxos/errors");
|
|
2218
2248
|
var import_keys8 = require("@dxos/keys");
|
|
2219
2249
|
var import_log10 = require("@dxos/log");
|
|
2250
|
+
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2220
2251
|
var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2221
2252
|
var import_util4 = require("@dxos/util");
|
|
2222
2253
|
|
|
2223
2254
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2224
2255
|
var import_node_assert9 = __toESM(require("node:assert"));
|
|
2225
|
-
var
|
|
2256
|
+
var import_async12 = require("@dxos/async");
|
|
2226
2257
|
var import_context5 = require("@dxos/context");
|
|
2227
2258
|
var import_keys7 = require("@dxos/keys");
|
|
2228
2259
|
var import_log9 = require("@dxos/log");
|
|
@@ -2235,7 +2266,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2235
2266
|
var NotarizationPlugin = class {
|
|
2236
2267
|
constructor() {
|
|
2237
2268
|
this._ctx = new import_context5.Context();
|
|
2238
|
-
this._extensionOpened = new
|
|
2269
|
+
this._extensionOpened = new import_async12.Event();
|
|
2239
2270
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2240
2271
|
this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
|
|
2241
2272
|
this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys7.PublicKey.hash);
|
|
@@ -2258,7 +2289,7 @@ var NotarizationPlugin = class {
|
|
|
2258
2289
|
callSite: (f, a) => f(...a)
|
|
2259
2290
|
});
|
|
2260
2291
|
(0, import_node_assert9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2261
|
-
const errors = new
|
|
2292
|
+
const errors = new import_async12.Trigger();
|
|
2262
2293
|
const ctx = this._ctx.derive({
|
|
2263
2294
|
onError: (err) => {
|
|
2264
2295
|
import_log9.log.warn("Notarization error", {
|
|
@@ -2275,7 +2306,7 @@ var NotarizationPlugin = class {
|
|
|
2275
2306
|
});
|
|
2276
2307
|
opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
|
|
2277
2308
|
if (timeout !== 0) {
|
|
2278
|
-
(0,
|
|
2309
|
+
(0, import_async12.scheduleTask)(ctx, () => {
|
|
2279
2310
|
import_log9.log.warn("Notarization timeout", {
|
|
2280
2311
|
timeout,
|
|
2281
2312
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
@@ -2286,12 +2317,12 @@ var NotarizationPlugin = class {
|
|
|
2286
2317
|
callSite: (f, a) => f(...a)
|
|
2287
2318
|
});
|
|
2288
2319
|
void ctx.dispose();
|
|
2289
|
-
errors.throw(new
|
|
2320
|
+
errors.throw(new import_async12.TimeoutError(timeout, "Notarization timed out"));
|
|
2290
2321
|
}, timeout);
|
|
2291
2322
|
}
|
|
2292
2323
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
2293
2324
|
const peersTried = /* @__PURE__ */ new Set();
|
|
2294
|
-
const notarizeTask = new
|
|
2325
|
+
const notarizeTask = new import_async12.DeferredTask(ctx, async () => {
|
|
2295
2326
|
try {
|
|
2296
2327
|
if (this._extensions.size === 0) {
|
|
2297
2328
|
return;
|
|
@@ -2309,7 +2340,7 @@ var NotarizationPlugin = class {
|
|
|
2309
2340
|
callSite: (f, a) => f(...a)
|
|
2310
2341
|
});
|
|
2311
2342
|
peersTried.clear();
|
|
2312
|
-
(0,
|
|
2343
|
+
(0, import_async12.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
2313
2344
|
return;
|
|
2314
2345
|
}
|
|
2315
2346
|
peersTried.add(peer);
|
|
@@ -2331,7 +2362,7 @@ var NotarizationPlugin = class {
|
|
|
2331
2362
|
scope: this,
|
|
2332
2363
|
callSite: (f, a) => f(...a)
|
|
2333
2364
|
});
|
|
2334
|
-
await (0,
|
|
2365
|
+
await (0, import_async12.sleep)(successDelay);
|
|
2335
2366
|
} catch (err) {
|
|
2336
2367
|
import_log9.log.warn("error notarizing (recoverable)", err, {
|
|
2337
2368
|
file: "notarization-plugin.ts",
|
|
@@ -2380,7 +2411,7 @@ var NotarizationPlugin = class {
|
|
|
2380
2411
|
if (this._processedCredentials.has(id)) {
|
|
2381
2412
|
return;
|
|
2382
2413
|
}
|
|
2383
|
-
await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new
|
|
2414
|
+
await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new import_async12.Trigger()).value.wait();
|
|
2384
2415
|
}
|
|
2385
2416
|
/**
|
|
2386
2417
|
* Requests from other peers to notarize credentials.
|
|
@@ -2474,8 +2505,13 @@ var AUTH_TIMEOUT2 = 3e4;
|
|
|
2474
2505
|
var DataSpace = class DataSpace2 {
|
|
2475
2506
|
constructor(params) {
|
|
2476
2507
|
this._ctx = new import_context6.Context();
|
|
2477
|
-
this._state =
|
|
2478
|
-
|
|
2508
|
+
this._state = import_services6.SpaceState.CLOSED;
|
|
2509
|
+
/**
|
|
2510
|
+
* Error for _state === SpaceState.ERROR.
|
|
2511
|
+
*/
|
|
2512
|
+
this.error = void 0;
|
|
2513
|
+
this.stateUpdate = new import_async13.Event();
|
|
2514
|
+
this.metrics = {};
|
|
2479
2515
|
var _a;
|
|
2480
2516
|
this._inner = params.inner;
|
|
2481
2517
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
@@ -2486,21 +2522,13 @@ var DataSpace = class DataSpace2 {
|
|
|
2486
2522
|
this._metadataStore = params.metadataStore;
|
|
2487
2523
|
this._signingContext = params.signingContext;
|
|
2488
2524
|
this._callbacks = (_a = params.callbacks) != null ? _a : {};
|
|
2489
|
-
this._dataPipeline = new import_echo_pipeline.DataPipeline({
|
|
2490
|
-
modelFactory: params.modelFactory,
|
|
2491
|
-
metadataStore: params.metadataStore,
|
|
2492
|
-
snapshotManager: params.snapshotManager,
|
|
2493
|
-
memberKey: params.memberKey,
|
|
2494
|
-
spaceKey: this._inner.key,
|
|
2495
|
-
feedInfoProvider: (feedKey) => this._inner.spaceState.feeds.get(feedKey),
|
|
2496
|
-
snapshotId: params.snapshotId
|
|
2497
|
-
});
|
|
2498
2525
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2499
2526
|
trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2500
2527
|
update: this._inner.stateUpdate,
|
|
2501
2528
|
authTimeout: AUTH_TIMEOUT2
|
|
2502
2529
|
});
|
|
2503
2530
|
this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
|
|
2531
|
+
this._cache = params.cache;
|
|
2504
2532
|
}
|
|
2505
2533
|
get key() {
|
|
2506
2534
|
return this._inner.key;
|
|
@@ -2516,7 +2544,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2516
2544
|
return this._inner;
|
|
2517
2545
|
}
|
|
2518
2546
|
get dataPipeline() {
|
|
2519
|
-
return this.
|
|
2547
|
+
return this._inner.dataPipeline;
|
|
2520
2548
|
}
|
|
2521
2549
|
get presence() {
|
|
2522
2550
|
return this._presence;
|
|
@@ -2524,16 +2552,19 @@ var DataSpace = class DataSpace2 {
|
|
|
2524
2552
|
get notarizationPlugin() {
|
|
2525
2553
|
return this._notarizationPluginConsumer.processor;
|
|
2526
2554
|
}
|
|
2555
|
+
get cache() {
|
|
2556
|
+
return this._cache;
|
|
2557
|
+
}
|
|
2527
2558
|
async open() {
|
|
2528
2559
|
await this.notarizationPlugin.open();
|
|
2529
2560
|
await this._notarizationPluginConsumer.open();
|
|
2530
2561
|
await this._inner.open();
|
|
2531
|
-
this._state =
|
|
2562
|
+
this._state = import_services6.SpaceState.INACTIVE;
|
|
2563
|
+
this.metrics.open = new Date();
|
|
2532
2564
|
}
|
|
2533
2565
|
async close() {
|
|
2534
|
-
this._state =
|
|
2566
|
+
this._state = import_services6.SpaceState.CLOSED;
|
|
2535
2567
|
await this._ctx.dispose();
|
|
2536
|
-
await this._dataPipeline.close();
|
|
2537
2568
|
await this.authVerifier.close();
|
|
2538
2569
|
await this._inner.close();
|
|
2539
2570
|
await this._notarizationPluginConsumer.close();
|
|
@@ -2550,14 +2581,15 @@ var DataSpace = class DataSpace2 {
|
|
|
2550
2581
|
* Initialize the data pipeline in a separate task.
|
|
2551
2582
|
*/
|
|
2552
2583
|
initializeDataPipelineAsync() {
|
|
2553
|
-
(0,
|
|
2584
|
+
(0, import_async13.scheduleTask)(this._ctx, async () => {
|
|
2554
2585
|
try {
|
|
2586
|
+
this.metrics.pipelineInitBegin = new Date();
|
|
2555
2587
|
await this.initializeDataPipeline();
|
|
2556
2588
|
} catch (err) {
|
|
2557
2589
|
if (err instanceof import_errors3.CancelledError) {
|
|
2558
2590
|
(0, import_log10.log)("Data pipeline initialization cancelled", err, {
|
|
2559
2591
|
file: "data-space.ts",
|
|
2560
|
-
line:
|
|
2592
|
+
line: 173,
|
|
2561
2593
|
scope: this,
|
|
2562
2594
|
callSite: (f, a) => f(...a)
|
|
2563
2595
|
});
|
|
@@ -2565,27 +2597,33 @@ var DataSpace = class DataSpace2 {
|
|
|
2565
2597
|
}
|
|
2566
2598
|
import_log10.log.error("Error initializing data pipeline", err, {
|
|
2567
2599
|
file: "data-space.ts",
|
|
2568
|
-
line:
|
|
2600
|
+
line: 177,
|
|
2569
2601
|
scope: this,
|
|
2570
2602
|
callSite: (f, a) => f(...a)
|
|
2571
2603
|
});
|
|
2604
|
+
this._state = import_services6.SpaceState.ERROR;
|
|
2605
|
+
this.error = err;
|
|
2606
|
+
this.stateUpdate.emit();
|
|
2607
|
+
} finally {
|
|
2608
|
+
this.metrics.ready = new Date();
|
|
2572
2609
|
}
|
|
2573
2610
|
});
|
|
2574
2611
|
}
|
|
2575
2612
|
async initializeDataPipeline() {
|
|
2576
2613
|
var _a, _b, _c, _d;
|
|
2577
|
-
if (this._state !==
|
|
2614
|
+
if (this._state !== import_services6.SpaceState.INACTIVE) {
|
|
2578
2615
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2579
2616
|
}
|
|
2580
|
-
this._state =
|
|
2617
|
+
this._state = import_services6.SpaceState.INITIALIZING;
|
|
2581
2618
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2582
2619
|
ctx: this._ctx,
|
|
2583
2620
|
breakOnStall: false
|
|
2584
2621
|
});
|
|
2622
|
+
this.metrics.controlPipelineReady = new Date();
|
|
2585
2623
|
await this._createWritableFeeds();
|
|
2586
2624
|
(0, import_log10.log)("Writable feeds created", {}, {
|
|
2587
2625
|
file: "data-space.ts",
|
|
2588
|
-
line:
|
|
2626
|
+
line: 202,
|
|
2589
2627
|
scope: this,
|
|
2590
2628
|
callSite: (f, a) => f(...a)
|
|
2591
2629
|
});
|
|
@@ -2595,33 +2633,28 @@ var DataSpace = class DataSpace2 {
|
|
|
2595
2633
|
credential
|
|
2596
2634
|
}
|
|
2597
2635
|
}), this._inner.controlPipeline.writer));
|
|
2598
|
-
await this.
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
start
|
|
2602
|
-
});
|
|
2603
|
-
await pipeline.start();
|
|
2604
|
-
return pipeline;
|
|
2605
|
-
}
|
|
2606
|
-
});
|
|
2636
|
+
await this._inner.initializeDataPipeline();
|
|
2637
|
+
this.metrics.dataPipelineOpen = new Date();
|
|
2638
|
+
await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2607
2639
|
(0, import_log10.log)("waiting for data pipeline to reach target timeframe", {}, {
|
|
2608
2640
|
file: "data-space.ts",
|
|
2609
|
-
line:
|
|
2641
|
+
line: 221,
|
|
2610
2642
|
scope: this,
|
|
2611
2643
|
callSite: (f, a) => f(...a)
|
|
2612
2644
|
});
|
|
2613
|
-
await this.
|
|
2645
|
+
await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2614
2646
|
ctx: this._ctx,
|
|
2615
2647
|
breakOnStall: false
|
|
2616
2648
|
});
|
|
2649
|
+
this.metrics.dataPipelineReady = new Date();
|
|
2617
2650
|
(0, import_log10.log)("data pipeline ready", {}, {
|
|
2618
2651
|
file: "data-space.ts",
|
|
2619
|
-
line:
|
|
2652
|
+
line: 230,
|
|
2620
2653
|
scope: this,
|
|
2621
2654
|
callSite: (f, a) => f(...a)
|
|
2622
2655
|
});
|
|
2623
2656
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2624
|
-
this._state =
|
|
2657
|
+
this._state = import_services6.SpaceState.READY;
|
|
2625
2658
|
this.stateUpdate.emit();
|
|
2626
2659
|
await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
|
|
2627
2660
|
}
|
|
@@ -2668,14 +2701,105 @@ var DataSpace = class DataSpace2 {
|
|
|
2668
2701
|
}
|
|
2669
2702
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
2670
2703
|
}
|
|
2704
|
+
async createEpoch() {
|
|
2705
|
+
var _a, _b;
|
|
2706
|
+
const epoch = await this.dataPipeline.createEpoch();
|
|
2707
|
+
await this.inner.controlPipeline.writer.write({
|
|
2708
|
+
credential: {
|
|
2709
|
+
credential: await this._signingContext.credentialSigner.createCredential({
|
|
2710
|
+
subject: this.key,
|
|
2711
|
+
assertion: {
|
|
2712
|
+
"@type": "dxos.halo.credentials.Epoch",
|
|
2713
|
+
...epoch
|
|
2714
|
+
}
|
|
2715
|
+
})
|
|
2716
|
+
}
|
|
2717
|
+
});
|
|
2718
|
+
for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
|
|
2719
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
2720
|
+
if (indexBeforeEpoch) {
|
|
2721
|
+
await feed.clear(0, indexBeforeEpoch + 1);
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2671
2725
|
};
|
|
2672
2726
|
__decorate([
|
|
2673
2727
|
(0, import_debug3.timed)(1e4)
|
|
2674
2728
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2675
2729
|
DataSpace = __decorate([
|
|
2676
|
-
(0,
|
|
2730
|
+
(0, import_async13.trackLeaks)("open", "close")
|
|
2677
2731
|
], DataSpace);
|
|
2678
2732
|
|
|
2733
|
+
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
2734
|
+
var import_credentials10 = require("@dxos/credentials");
|
|
2735
|
+
var import_debug4 = require("@dxos/debug");
|
|
2736
|
+
var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2737
|
+
var import_timeframe = require("@dxos/timeframe");
|
|
2738
|
+
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
2739
|
+
var _a, _b, _c, _d;
|
|
2740
|
+
const credentials = [
|
|
2741
|
+
await (0, import_credentials10.createCredential)({
|
|
2742
|
+
signer: keyring,
|
|
2743
|
+
issuer: space.key,
|
|
2744
|
+
subject: space.key,
|
|
2745
|
+
assertion: {
|
|
2746
|
+
"@type": "dxos.halo.credentials.SpaceGenesis",
|
|
2747
|
+
spaceKey: space.key
|
|
2748
|
+
}
|
|
2749
|
+
}),
|
|
2750
|
+
await (0, import_credentials10.createCredential)({
|
|
2751
|
+
signer: keyring,
|
|
2752
|
+
issuer: space.key,
|
|
2753
|
+
subject: signingContext.identityKey,
|
|
2754
|
+
assertion: {
|
|
2755
|
+
"@type": "dxos.halo.credentials.SpaceMember",
|
|
2756
|
+
spaceKey: space.key,
|
|
2757
|
+
role: import_credentials11.SpaceMember.Role.ADMIN,
|
|
2758
|
+
profile: signingContext.profile,
|
|
2759
|
+
genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0, import_debug4.failUndefined)()
|
|
2760
|
+
}
|
|
2761
|
+
}),
|
|
2762
|
+
await signingContext.credentialSigner.createCredential({
|
|
2763
|
+
subject: (_b = space.controlFeedKey) != null ? _b : (0, import_debug4.failUndefined)(),
|
|
2764
|
+
assertion: {
|
|
2765
|
+
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2766
|
+
spaceKey: space.key,
|
|
2767
|
+
identityKey: signingContext.identityKey,
|
|
2768
|
+
deviceKey: signingContext.deviceKey,
|
|
2769
|
+
designation: import_credentials11.AdmittedFeed.Designation.CONTROL
|
|
2770
|
+
}
|
|
2771
|
+
}),
|
|
2772
|
+
await signingContext.credentialSigner.createCredential({
|
|
2773
|
+
subject: (_c = space.dataFeedKey) != null ? _c : (0, import_debug4.failUndefined)(),
|
|
2774
|
+
assertion: {
|
|
2775
|
+
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2776
|
+
spaceKey: space.key,
|
|
2777
|
+
identityKey: signingContext.identityKey,
|
|
2778
|
+
deviceKey: signingContext.deviceKey,
|
|
2779
|
+
designation: import_credentials11.AdmittedFeed.Designation.DATA
|
|
2780
|
+
}
|
|
2781
|
+
}),
|
|
2782
|
+
await signingContext.credentialSigner.createCredential({
|
|
2783
|
+
subject: (_d = space.key) != null ? _d : (0, import_debug4.failUndefined)(),
|
|
2784
|
+
assertion: {
|
|
2785
|
+
"@type": "dxos.halo.credentials.Epoch",
|
|
2786
|
+
number: 0,
|
|
2787
|
+
previousId: void 0,
|
|
2788
|
+
timeframe: new import_timeframe.Timeframe(),
|
|
2789
|
+
snapshotCid: void 0
|
|
2790
|
+
}
|
|
2791
|
+
})
|
|
2792
|
+
];
|
|
2793
|
+
for (const credential of credentials) {
|
|
2794
|
+
await space.controlPipeline.writer.write({
|
|
2795
|
+
credential: {
|
|
2796
|
+
credential
|
|
2797
|
+
}
|
|
2798
|
+
});
|
|
2799
|
+
}
|
|
2800
|
+
return credentials;
|
|
2801
|
+
};
|
|
2802
|
+
|
|
2679
2803
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2680
2804
|
var __decorate2 = function(decorators, target, key, desc) {
|
|
2681
2805
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -2688,17 +2812,15 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2688
2812
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2689
2813
|
};
|
|
2690
2814
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2691
|
-
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext,
|
|
2815
|
+
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2692
2816
|
this._spaceManager = _spaceManager;
|
|
2693
2817
|
this._metadataStore = _metadataStore;
|
|
2694
2818
|
this._dataServiceSubscriptions = _dataServiceSubscriptions;
|
|
2695
2819
|
this._keyring = _keyring;
|
|
2696
2820
|
this._signingContext = _signingContext;
|
|
2697
|
-
this._modelFactory = _modelFactory;
|
|
2698
2821
|
this._feedStore = _feedStore;
|
|
2699
|
-
this._snapshotStore = _snapshotStore;
|
|
2700
2822
|
this._ctx = new import_context7.Context();
|
|
2701
|
-
this.updated = new
|
|
2823
|
+
this.updated = new import_async14.Event();
|
|
2702
2824
|
this._spaces = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
|
|
2703
2825
|
this._isOpen = false;
|
|
2704
2826
|
this._instanceId = import_keys9.PublicKey.random().toHex();
|
|
@@ -2710,16 +2832,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2710
2832
|
async open() {
|
|
2711
2833
|
(0, import_log11.log)("open", {}, {
|
|
2712
2834
|
file: "data-space-manager.ts",
|
|
2713
|
-
line:
|
|
2835
|
+
line: 80,
|
|
2714
2836
|
scope: this,
|
|
2715
2837
|
callSite: (f, a) => f(...a)
|
|
2716
2838
|
});
|
|
2717
|
-
import_log11.log.trace("dxos.echo.data-space-manager", import_protocols6.trace.begin({
|
|
2718
|
-
id: this._instanceId
|
|
2719
|
-
parentId: this._traceParent
|
|
2839
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
|
|
2840
|
+
id: this._instanceId
|
|
2720
2841
|
}), {
|
|
2721
2842
|
file: "data-space-manager.ts",
|
|
2722
|
-
line:
|
|
2843
|
+
line: 81,
|
|
2723
2844
|
scope: this,
|
|
2724
2845
|
callSite: (f, a) => f(...a)
|
|
2725
2846
|
});
|
|
@@ -2728,7 +2849,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2728
2849
|
spaces: this._metadataStore.spaces.length
|
|
2729
2850
|
}, {
|
|
2730
2851
|
file: "data-space-manager.ts",
|
|
2731
|
-
line:
|
|
2852
|
+
line: 83,
|
|
2732
2853
|
scope: this,
|
|
2733
2854
|
callSite: (f, a) => f(...a)
|
|
2734
2855
|
});
|
|
@@ -2738,7 +2859,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2738
2859
|
spaceMetadata
|
|
2739
2860
|
}, {
|
|
2740
2861
|
file: "data-space-manager.ts",
|
|
2741
|
-
line:
|
|
2862
|
+
line: 87,
|
|
2742
2863
|
scope: this,
|
|
2743
2864
|
callSite: (f, a) => f(...a)
|
|
2744
2865
|
});
|
|
@@ -2750,7 +2871,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2750
2871
|
err
|
|
2751
2872
|
}, {
|
|
2752
2873
|
file: "data-space-manager.ts",
|
|
2753
|
-
line:
|
|
2874
|
+
line: 91,
|
|
2754
2875
|
scope: this,
|
|
2755
2876
|
callSite: (f, a) => f(...a)
|
|
2756
2877
|
});
|
|
@@ -2758,11 +2879,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2758
2879
|
}
|
|
2759
2880
|
this._isOpen = true;
|
|
2760
2881
|
this.updated.emit();
|
|
2882
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
|
|
2883
|
+
id: this._instanceId
|
|
2884
|
+
}), {
|
|
2885
|
+
file: "data-space-manager.ts",
|
|
2886
|
+
line: 97,
|
|
2887
|
+
scope: this,
|
|
2888
|
+
callSite: (f, a) => f(...a)
|
|
2889
|
+
});
|
|
2761
2890
|
}
|
|
2762
2891
|
async close() {
|
|
2763
2892
|
(0, import_log11.log)("close", {}, {
|
|
2764
2893
|
file: "data-space-manager.ts",
|
|
2765
|
-
line:
|
|
2894
|
+
line: 102,
|
|
2766
2895
|
scope: this,
|
|
2767
2896
|
callSite: (f, a) => f(...a)
|
|
2768
2897
|
});
|
|
@@ -2771,14 +2900,6 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2771
2900
|
for (const space of this._spaces.values()) {
|
|
2772
2901
|
await space.close();
|
|
2773
2902
|
}
|
|
2774
|
-
import_log11.log.trace("dxos.echo.data-space-manager", import_protocols6.trace.end({
|
|
2775
|
-
id: this._instanceId
|
|
2776
|
-
}), {
|
|
2777
|
-
file: "data-space-manager.ts",
|
|
2778
|
-
line: 110,
|
|
2779
|
-
scope: this,
|
|
2780
|
-
callSite: (f, a) => f(...a)
|
|
2781
|
-
});
|
|
2782
2903
|
}
|
|
2783
2904
|
/**
|
|
2784
2905
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
@@ -2798,15 +2919,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2798
2919
|
spaceKey
|
|
2799
2920
|
}, {
|
|
2800
2921
|
file: "data-space-manager.ts",
|
|
2801
|
-
line:
|
|
2922
|
+
line: 126,
|
|
2802
2923
|
scope: this,
|
|
2803
2924
|
callSite: (f, a) => f(...a)
|
|
2804
2925
|
});
|
|
2805
2926
|
const space = await this._constructSpace(metadata);
|
|
2806
|
-
const credentials = await
|
|
2927
|
+
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2807
2928
|
await this._metadataStore.addSpace(metadata);
|
|
2808
2929
|
const memberCredential = credentials[1];
|
|
2809
|
-
(0, import_node_assert10.default)((0,
|
|
2930
|
+
(0, import_node_assert10.default)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2810
2931
|
await this._signingContext.recordCredential(memberCredential);
|
|
2811
2932
|
await space.initializeDataPipeline();
|
|
2812
2933
|
this.updated.emit();
|
|
@@ -2818,7 +2939,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2818
2939
|
opts
|
|
2819
2940
|
}, {
|
|
2820
2941
|
file: "data-space-manager.ts",
|
|
2821
|
-
line:
|
|
2942
|
+
line: 145,
|
|
2822
2943
|
scope: this,
|
|
2823
2944
|
callSite: (f, a) => f(...a)
|
|
2824
2945
|
});
|
|
@@ -2844,7 +2965,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2844
2965
|
async waitUntilSpaceReady(spaceKey) {
|
|
2845
2966
|
await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
2846
2967
|
const space = this._spaces.get(spaceKey);
|
|
2847
|
-
return !!space && space.state ===
|
|
2968
|
+
return !!space && space.state === import_services7.SpaceState.READY;
|
|
2848
2969
|
}));
|
|
2849
2970
|
}
|
|
2850
2971
|
async _constructSpace(metadata) {
|
|
@@ -2852,7 +2973,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2852
2973
|
metadata
|
|
2853
2974
|
}, {
|
|
2854
2975
|
file: "data-space-manager.ts",
|
|
2855
|
-
line:
|
|
2976
|
+
line: 181,
|
|
2856
2977
|
scope: this,
|
|
2857
2978
|
callSite: (f, a) => f(...a)
|
|
2858
2979
|
});
|
|
@@ -2865,7 +2986,6 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2865
2986
|
identityKey: this._signingContext.identityKey,
|
|
2866
2987
|
gossip
|
|
2867
2988
|
});
|
|
2868
|
-
const snapshotManager = new import_echo_pipeline2.SnapshotManager(this._snapshotStore);
|
|
2869
2989
|
const controlFeed = metadata.controlFeedKey && await this._feedStore.openFeed(metadata.controlFeedKey, {
|
|
2870
2990
|
writable: true
|
|
2871
2991
|
});
|
|
@@ -2883,35 +3003,32 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2883
3003
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
2884
3004
|
remotePeerId: session.remotePeerId
|
|
2885
3005
|
}));
|
|
2886
|
-
session.addExtension("dxos.mesh.teleport.objectsync", snapshotManager.objectSync.createExtension());
|
|
3006
|
+
session.addExtension("dxos.mesh.teleport.objectsync", space.snapshotManager.objectSync.createExtension());
|
|
2887
3007
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2888
|
-
}
|
|
3008
|
+
},
|
|
3009
|
+
memberKey: this._signingContext.identityKey
|
|
2889
3010
|
});
|
|
2890
3011
|
controlFeed && space.setControlFeed(controlFeed);
|
|
2891
3012
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2892
3013
|
const dataSpace = new DataSpace({
|
|
2893
3014
|
inner: space,
|
|
2894
|
-
modelFactory: this._modelFactory,
|
|
2895
3015
|
metadataStore: this._metadataStore,
|
|
2896
|
-
snapshotManager,
|
|
2897
3016
|
gossip,
|
|
2898
3017
|
presence,
|
|
2899
|
-
memberKey: this._signingContext.identityKey,
|
|
2900
3018
|
keyring: this._keyring,
|
|
2901
3019
|
feedStore: this._feedStore,
|
|
2902
3020
|
signingContext: this._signingContext,
|
|
2903
|
-
snapshotId: metadata.snapshot,
|
|
2904
3021
|
callbacks: {
|
|
2905
3022
|
beforeReady: async () => {
|
|
2906
3023
|
(0, import_log11.log)("before space ready", {
|
|
2907
3024
|
space: space.key
|
|
2908
3025
|
}, {
|
|
2909
3026
|
file: "data-space-manager.ts",
|
|
2910
|
-
line:
|
|
3027
|
+
line: 226,
|
|
2911
3028
|
scope: this,
|
|
2912
3029
|
callSite: (f, a) => f(...a)
|
|
2913
3030
|
});
|
|
2914
|
-
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.
|
|
3031
|
+
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2915
3032
|
},
|
|
2916
3033
|
afterReady: async () => {
|
|
2917
3034
|
(0, import_log11.log)("after space ready", {
|
|
@@ -2919,7 +3036,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2919
3036
|
open: this._isOpen
|
|
2920
3037
|
}, {
|
|
2921
3038
|
file: "data-space-manager.ts",
|
|
2922
|
-
line:
|
|
3039
|
+
line: 233,
|
|
2923
3040
|
scope: this,
|
|
2924
3041
|
callSite: (f, a) => f(...a)
|
|
2925
3042
|
});
|
|
@@ -2927,7 +3044,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2927
3044
|
this.updated.emit();
|
|
2928
3045
|
}
|
|
2929
3046
|
}
|
|
2930
|
-
}
|
|
3047
|
+
},
|
|
3048
|
+
cache: metadata.cache
|
|
2931
3049
|
});
|
|
2932
3050
|
await dataSpace.open();
|
|
2933
3051
|
if (metadata.controlTimeframe) {
|
|
@@ -2941,28 +3059,29 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2941
3059
|
}
|
|
2942
3060
|
};
|
|
2943
3061
|
__decorate2([
|
|
2944
|
-
|
|
3062
|
+
import_async14.synchronized
|
|
2945
3063
|
], DataSpaceManager.prototype, "open", null);
|
|
2946
3064
|
__decorate2([
|
|
2947
|
-
|
|
3065
|
+
import_async14.synchronized
|
|
2948
3066
|
], DataSpaceManager.prototype, "close", null);
|
|
2949
3067
|
__decorate2([
|
|
2950
|
-
|
|
3068
|
+
import_async14.synchronized
|
|
2951
3069
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2952
3070
|
__decorate2([
|
|
2953
|
-
|
|
3071
|
+
import_async14.synchronized
|
|
2954
3072
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2955
3073
|
DataSpaceManager = __decorate2([
|
|
2956
|
-
(0,
|
|
3074
|
+
(0, import_async14.trackLeaks)("open", "close")
|
|
2957
3075
|
], DataSpaceManager);
|
|
2958
3076
|
|
|
2959
3077
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2960
|
-
var
|
|
3078
|
+
var import_async15 = require("@dxos/async");
|
|
2961
3079
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
2962
|
-
var
|
|
2963
|
-
var
|
|
3080
|
+
var import_debug5 = require("@dxos/debug");
|
|
3081
|
+
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
2964
3082
|
var import_log12 = require("@dxos/log");
|
|
2965
|
-
var
|
|
3083
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
3084
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2966
3085
|
var import_util6 = require("@dxos/util");
|
|
2967
3086
|
var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
|
|
2968
3087
|
var SpacesServiceImpl = class {
|
|
@@ -2981,7 +3100,7 @@ var SpacesServiceImpl = class {
|
|
|
2981
3100
|
return this._transformSpace(space);
|
|
2982
3101
|
}
|
|
2983
3102
|
async updateSpace(request) {
|
|
2984
|
-
(0,
|
|
3103
|
+
(0, import_debug5.todo)();
|
|
2985
3104
|
}
|
|
2986
3105
|
querySpaces() {
|
|
2987
3106
|
return new import_codec_protobuf11.Stream(({ next, ctx }) => {
|
|
@@ -2992,7 +3111,7 @@ var SpacesServiceImpl = class {
|
|
|
2992
3111
|
spaces
|
|
2993
3112
|
}, {
|
|
2994
3113
|
file: "spaces-service.ts",
|
|
2995
|
-
line:
|
|
3114
|
+
line: 62,
|
|
2996
3115
|
scope: this,
|
|
2997
3116
|
callSite: (f, a) => f(...a)
|
|
2998
3117
|
});
|
|
@@ -3000,9 +3119,9 @@ var SpacesServiceImpl = class {
|
|
|
3000
3119
|
spaces
|
|
3001
3120
|
});
|
|
3002
3121
|
};
|
|
3003
|
-
(0,
|
|
3122
|
+
(0, import_async15.scheduleTask)(ctx, async () => {
|
|
3004
3123
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3005
|
-
const subscriptions = new
|
|
3124
|
+
const subscriptions = new import_async15.EventSubscriptions();
|
|
3006
3125
|
ctx.onDispose(() => subscriptions.clear());
|
|
3007
3126
|
const subscribeSpaces = () => {
|
|
3008
3127
|
subscriptions.clear();
|
|
@@ -3032,15 +3151,15 @@ var SpacesServiceImpl = class {
|
|
|
3032
3151
|
async postMessage({ spaceKey, channel, message }) {
|
|
3033
3152
|
var _a;
|
|
3034
3153
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3035
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
3154
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3036
3155
|
await space.postMessage(getChannelId(channel), message);
|
|
3037
3156
|
}
|
|
3038
3157
|
subscribeMessages({ spaceKey, channel }) {
|
|
3039
3158
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3040
|
-
(0,
|
|
3159
|
+
(0, import_async15.scheduleTask)(ctx, async () => {
|
|
3041
3160
|
var _a;
|
|
3042
3161
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3043
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
3162
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3044
3163
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3045
3164
|
next(message);
|
|
3046
3165
|
});
|
|
@@ -3051,19 +3170,19 @@ var SpacesServiceImpl = class {
|
|
|
3051
3170
|
queryCredentials({ spaceKey }) {
|
|
3052
3171
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3053
3172
|
var _a;
|
|
3054
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
3173
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3055
3174
|
const processor = space.spaceState.registerProcessor({
|
|
3056
3175
|
process: async (credential) => {
|
|
3057
3176
|
next(credential);
|
|
3058
3177
|
}
|
|
3059
3178
|
});
|
|
3060
3179
|
ctx.onDispose(() => processor.close());
|
|
3061
|
-
(0,
|
|
3180
|
+
(0, import_async15.scheduleTask)(ctx, () => processor.open());
|
|
3062
3181
|
});
|
|
3063
3182
|
}
|
|
3064
3183
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3065
3184
|
var _a;
|
|
3066
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
3185
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3067
3186
|
for (const credential of credentials != null ? credentials : []) {
|
|
3068
3187
|
await space.controlPipeline.writer.write({
|
|
3069
3188
|
credential: {
|
|
@@ -3072,11 +3191,18 @@ var SpacesServiceImpl = class {
|
|
|
3072
3191
|
});
|
|
3073
3192
|
}
|
|
3074
3193
|
}
|
|
3194
|
+
async createEpoch({ spaceKey }) {
|
|
3195
|
+
var _a;
|
|
3196
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3197
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3198
|
+
await space.createEpoch();
|
|
3199
|
+
}
|
|
3075
3200
|
_transformSpace(space) {
|
|
3076
3201
|
var _a, _b, _c, _d, _e;
|
|
3077
3202
|
return {
|
|
3078
3203
|
spaceKey: space.key,
|
|
3079
3204
|
state: space.state,
|
|
3205
|
+
error: space.error ? (0, import_protocols7.encodeError)(space.error) : void 0,
|
|
3080
3206
|
pipeline: {
|
|
3081
3207
|
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
3082
3208
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
@@ -3096,9 +3222,11 @@ var SpacesServiceImpl = class {
|
|
|
3096
3222
|
displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : (0, import_util6.humanize)(member.key)
|
|
3097
3223
|
}
|
|
3098
3224
|
},
|
|
3099
|
-
presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ?
|
|
3225
|
+
presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services8.SpaceMember.PresenceState.ONLINE : import_services8.SpaceMember.PresenceState.OFFLINE
|
|
3100
3226
|
};
|
|
3101
|
-
})
|
|
3227
|
+
}),
|
|
3228
|
+
cache: space.cache,
|
|
3229
|
+
metrics: space.metrics
|
|
3102
3230
|
};
|
|
3103
3231
|
}
|
|
3104
3232
|
};
|
|
@@ -3190,7 +3318,7 @@ var SystemServiceImpl = class {
|
|
|
3190
3318
|
};
|
|
3191
3319
|
|
|
3192
3320
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3193
|
-
var
|
|
3321
|
+
var import_async17 = require("@dxos/async");
|
|
3194
3322
|
var import_log13 = require("@dxos/log");
|
|
3195
3323
|
var import_messaging = require("@dxos/messaging");
|
|
3196
3324
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
@@ -3198,7 +3326,7 @@ var import_util7 = require("@dxos/util");
|
|
|
3198
3326
|
|
|
3199
3327
|
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
3200
3328
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
3201
|
-
var
|
|
3329
|
+
var import_debug6 = require("@dxos/debug");
|
|
3202
3330
|
var import_rpc = require("@dxos/rpc");
|
|
3203
3331
|
var ClientRpcServer = class {
|
|
3204
3332
|
constructor(params) {
|
|
@@ -3238,7 +3366,7 @@ var ClientRpcServer = class {
|
|
|
3238
3366
|
_getServiceHandler(serviceName) {
|
|
3239
3367
|
var _a;
|
|
3240
3368
|
if (!this._handlerCache.has(serviceName)) {
|
|
3241
|
-
const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : (0,
|
|
3369
|
+
const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : (0, import_debug6.raise)(new Error(`Service not available: ${serviceName}`));
|
|
3242
3370
|
const service = this._serviceRegistry.services[key];
|
|
3243
3371
|
if (!service) {
|
|
3244
3372
|
throw new Error(`Service not available: ${serviceName}`);
|
|
@@ -3251,14 +3379,14 @@ var ClientRpcServer = class {
|
|
|
3251
3379
|
|
|
3252
3380
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
3253
3381
|
var import_node_assert11 = __toESM(require("node:assert"));
|
|
3254
|
-
var
|
|
3255
|
-
var
|
|
3382
|
+
var import_async16 = require("@dxos/async");
|
|
3383
|
+
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
3256
3384
|
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
3257
3385
|
var import_rpc2 = require("@dxos/rpc");
|
|
3258
3386
|
var ShellRuntimeImpl = class {
|
|
3259
3387
|
constructor(_port) {
|
|
3260
3388
|
this._port = _port;
|
|
3261
|
-
this.layoutUpdate = new
|
|
3389
|
+
this.layoutUpdate = new import_async16.Event();
|
|
3262
3390
|
this._layout = import_iframe.ShellLayout.DEFAULT;
|
|
3263
3391
|
}
|
|
3264
3392
|
get layout() {
|
|
@@ -3285,8 +3413,8 @@ var ShellRuntimeImpl = class {
|
|
|
3285
3413
|
}
|
|
3286
3414
|
async open() {
|
|
3287
3415
|
this._appRpc = (0, import_rpc2.createProtoRpcPeer)({
|
|
3288
|
-
requested:
|
|
3289
|
-
exposed:
|
|
3416
|
+
requested: import_client_protocol2.appServiceBundle,
|
|
3417
|
+
exposed: import_client_protocol2.shellServiceBundle,
|
|
3290
3418
|
handlers: {
|
|
3291
3419
|
ShellService: {
|
|
3292
3420
|
setLayout: async (request) => {
|
|
@@ -3309,8 +3437,8 @@ var ShellRuntimeImpl = class {
|
|
|
3309
3437
|
};
|
|
3310
3438
|
var MemoryShellRuntime = class {
|
|
3311
3439
|
constructor({ layout, invitationCode, spaceKey } = {}) {
|
|
3312
|
-
this.layoutUpdate = new
|
|
3313
|
-
this.contextUpdate = new
|
|
3440
|
+
this.layoutUpdate = new import_async16.Event();
|
|
3441
|
+
this.contextUpdate = new import_async16.Event();
|
|
3314
3442
|
this._layout = layout != null ? layout : import_iframe.ShellLayout.DEFAULT;
|
|
3315
3443
|
this._invitationCode = invitationCode;
|
|
3316
3444
|
this._spaceKey = spaceKey;
|
|
@@ -3352,7 +3480,7 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3352
3480
|
var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
3353
3481
|
var IFrameHostRuntime = class {
|
|
3354
3482
|
constructor({ config, origin, appPort, shellPort }) {
|
|
3355
|
-
this._ready = new
|
|
3483
|
+
this._ready = new import_async17.Trigger();
|
|
3356
3484
|
this._configProvider = config;
|
|
3357
3485
|
this.origin = origin;
|
|
3358
3486
|
this._appPort = appPort;
|
|
@@ -3384,11 +3512,8 @@ var IFrameHostRuntime = class {
|
|
|
3384
3512
|
this._clientServices = new LocalClientServices({
|
|
3385
3513
|
lockKey: LOCK_KEY,
|
|
3386
3514
|
config: this._config,
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
signalManager: signals ? new import_messaging.WebsocketSignalManager(signals) : new import_messaging.MemorySignalManager(new import_messaging.MemorySignalManagerContext()),
|
|
3390
|
-
transportFactory: this._transportFactory
|
|
3391
|
-
})
|
|
3515
|
+
signalManager: signals ? new import_messaging.WebsocketSignalManager(signals) : new import_messaging.MemorySignalManager(new import_messaging.MemorySignalManagerContext()),
|
|
3516
|
+
transportFactory: this._transportFactory
|
|
3392
3517
|
});
|
|
3393
3518
|
const middleware = {
|
|
3394
3519
|
handleCall: async (method, params, handler) => {
|
|
@@ -3423,7 +3548,7 @@ var IFrameHostRuntime = class {
|
|
|
3423
3548
|
this._ready.wake(void 0);
|
|
3424
3549
|
(0, import_log13.log)("started", {}, {
|
|
3425
3550
|
file: "iframe-host-runtime.ts",
|
|
3426
|
-
line:
|
|
3551
|
+
line: 112,
|
|
3427
3552
|
scope: this,
|
|
3428
3553
|
callSite: (f, a) => f(...a)
|
|
3429
3554
|
});
|
|
@@ -3431,7 +3556,7 @@ var IFrameHostRuntime = class {
|
|
|
3431
3556
|
this._ready.wake(err);
|
|
3432
3557
|
import_log13.log.catch(err, {}, {
|
|
3433
3558
|
file: "iframe-host-runtime.ts",
|
|
3434
|
-
line:
|
|
3559
|
+
line: 115,
|
|
3435
3560
|
scope: this,
|
|
3436
3561
|
callSite: (f, a) => f(...a)
|
|
3437
3562
|
});
|
|
@@ -3441,7 +3566,7 @@ var IFrameHostRuntime = class {
|
|
|
3441
3566
|
var _a;
|
|
3442
3567
|
(0, import_log13.log)("stopping...", {}, {
|
|
3443
3568
|
file: "iframe-host-runtime.ts",
|
|
3444
|
-
line:
|
|
3569
|
+
line: 120,
|
|
3445
3570
|
scope: this,
|
|
3446
3571
|
callSite: (f, a) => f(...a)
|
|
3447
3572
|
});
|
|
@@ -3450,7 +3575,7 @@ var IFrameHostRuntime = class {
|
|
|
3450
3575
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
3451
3576
|
(0, import_log13.log)("stopped", {}, {
|
|
3452
3577
|
file: "iframe-host-runtime.ts",
|
|
3453
|
-
line:
|
|
3578
|
+
line: 124,
|
|
3454
3579
|
scope: this,
|
|
3455
3580
|
callSite: (f, a) => f(...a)
|
|
3456
3581
|
});
|
|
@@ -3461,7 +3586,8 @@ __decorate3([
|
|
|
3461
3586
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
3462
3587
|
|
|
3463
3588
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
3464
|
-
var
|
|
3589
|
+
var import_async18 = require("@dxos/async");
|
|
3590
|
+
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
3465
3591
|
var import_errors5 = require("@dxos/errors");
|
|
3466
3592
|
var import_log14 = require("@dxos/log");
|
|
3467
3593
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
@@ -3469,6 +3595,8 @@ var import_rpc3 = require("@dxos/rpc");
|
|
|
3469
3595
|
var import_util8 = require("@dxos/util");
|
|
3470
3596
|
var IFrameProxyRuntime = class {
|
|
3471
3597
|
constructor({ config, systemPort, shellPort }) {
|
|
3598
|
+
this._id = String(Math.floor(Math.random() * 1e6));
|
|
3599
|
+
this._release = new import_async18.Trigger();
|
|
3472
3600
|
this._configProvider = config;
|
|
3473
3601
|
this._systemPort = systemPort;
|
|
3474
3602
|
this._shellPort = shellPort;
|
|
@@ -3486,27 +3614,35 @@ var IFrameProxyRuntime = class {
|
|
|
3486
3614
|
iceServers: this._config.get("runtime.services.ice")
|
|
3487
3615
|
});
|
|
3488
3616
|
this._systemRpc = (0, import_rpc3.createProtoRpcPeer)({
|
|
3489
|
-
requested:
|
|
3490
|
-
exposed:
|
|
3617
|
+
requested: import_client_protocol3.workerServiceBundle,
|
|
3618
|
+
exposed: import_client_protocol3.iframeServiceBundle,
|
|
3491
3619
|
handlers: {
|
|
3492
|
-
BridgeService: this._transportService
|
|
3493
|
-
IframeService: {
|
|
3494
|
-
async heartbeat() {
|
|
3495
|
-
}
|
|
3496
|
-
}
|
|
3620
|
+
BridgeService: this._transportService
|
|
3497
3621
|
},
|
|
3498
3622
|
port: this._systemPort,
|
|
3499
3623
|
timeout: 200
|
|
3500
3624
|
});
|
|
3625
|
+
let lockKey;
|
|
3626
|
+
if (typeof navigator !== "undefined") {
|
|
3627
|
+
lockKey = this._lockKey(origin);
|
|
3628
|
+
this._release = new import_async18.Trigger();
|
|
3629
|
+
const ready = new import_async18.Trigger();
|
|
3630
|
+
void navigator.locks.request(lockKey, async () => {
|
|
3631
|
+
ready.wake();
|
|
3632
|
+
await this._release.wait();
|
|
3633
|
+
});
|
|
3634
|
+
await ready.wait();
|
|
3635
|
+
}
|
|
3501
3636
|
try {
|
|
3502
3637
|
await this._systemRpc.open();
|
|
3503
3638
|
await this._systemRpc.rpc.WorkerService.start({
|
|
3504
|
-
origin
|
|
3639
|
+
origin,
|
|
3640
|
+
lockKey
|
|
3505
3641
|
});
|
|
3506
3642
|
} catch (err) {
|
|
3507
3643
|
import_log14.log.catch(err, {}, {
|
|
3508
3644
|
file: "iframe-proxy-runtime.ts",
|
|
3509
|
-
line:
|
|
3645
|
+
line: 85,
|
|
3510
3646
|
scope: this,
|
|
3511
3647
|
callSite: (f, a) => f(...a)
|
|
3512
3648
|
});
|
|
@@ -3516,14 +3652,18 @@ var IFrameProxyRuntime = class {
|
|
|
3516
3652
|
}
|
|
3517
3653
|
async close() {
|
|
3518
3654
|
var _a;
|
|
3655
|
+
this._release.wake();
|
|
3519
3656
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
3520
3657
|
await this._systemRpc.rpc.WorkerService.stop();
|
|
3521
3658
|
await this._systemRpc.close();
|
|
3522
3659
|
}
|
|
3660
|
+
_lockKey(origin) {
|
|
3661
|
+
return `${origin}-${this._id}`;
|
|
3662
|
+
}
|
|
3523
3663
|
};
|
|
3524
3664
|
|
|
3525
3665
|
// packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
|
|
3526
|
-
var
|
|
3666
|
+
var import_async19 = require("@dxos/async");
|
|
3527
3667
|
var import_log15 = require("@dxos/log");
|
|
3528
3668
|
var __decorate4 = function(decorators, target, key, desc) {
|
|
3529
3669
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3542,7 +3682,7 @@ var Message;
|
|
|
3542
3682
|
var VaultResourceLock = class {
|
|
3543
3683
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
3544
3684
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
3545
|
-
this._releaseTrigger = new
|
|
3685
|
+
this._releaseTrigger = new import_async19.Trigger();
|
|
3546
3686
|
this._lockKey = lockKey;
|
|
3547
3687
|
this._onAcquire = onAcquire;
|
|
3548
3688
|
this._onRelease = onRelease;
|
|
@@ -3562,7 +3702,7 @@ var VaultResourceLock = class {
|
|
|
3562
3702
|
scope: this,
|
|
3563
3703
|
callSite: (f, a) => f(...a)
|
|
3564
3704
|
});
|
|
3565
|
-
await (0,
|
|
3705
|
+
await (0, import_async19.asyncTimeout)(this._requestLock(), 3e3);
|
|
3566
3706
|
(0, import_log15.log)("acquired lock", {}, {
|
|
3567
3707
|
file: "vault-resource-lock.ts",
|
|
3568
3708
|
line: 46,
|
|
@@ -3602,14 +3742,14 @@ var VaultResourceLock = class {
|
|
|
3602
3742
|
scope: this,
|
|
3603
3743
|
callSite: (f, a) => f(...a)
|
|
3604
3744
|
});
|
|
3605
|
-
const acquired = new
|
|
3745
|
+
const acquired = new import_async19.Trigger();
|
|
3606
3746
|
void navigator.locks.request(this._lockKey, {
|
|
3607
3747
|
steal
|
|
3608
3748
|
}, async () => {
|
|
3609
3749
|
var _a, _b;
|
|
3610
3750
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3611
3751
|
acquired.wake();
|
|
3612
|
-
this._releaseTrigger = new
|
|
3752
|
+
this._releaseTrigger = new import_async19.Trigger();
|
|
3613
3753
|
await this._releaseTrigger.wait();
|
|
3614
3754
|
(0, import_log15.log)("releasing lock...", {}, {
|
|
3615
3755
|
file: "vault-resource-lock.ts",
|
|
@@ -3644,15 +3784,15 @@ __decorate4([
|
|
|
3644
3784
|
], VaultResourceLock.prototype, "lockKey", null);
|
|
3645
3785
|
|
|
3646
3786
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
3647
|
-
var
|
|
3787
|
+
var import_async21 = require("@dxos/async");
|
|
3648
3788
|
var import_log17 = require("@dxos/log");
|
|
3649
3789
|
var import_messaging2 = require("@dxos/messaging");
|
|
3650
3790
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
3651
3791
|
|
|
3652
3792
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
3653
3793
|
var import_node_assert12 = __toESM(require("node:assert"));
|
|
3654
|
-
var
|
|
3655
|
-
var
|
|
3794
|
+
var import_async20 = require("@dxos/async");
|
|
3795
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
3656
3796
|
var import_log16 = require("@dxos/log");
|
|
3657
3797
|
var import_rpc4 = require("@dxos/rpc");
|
|
3658
3798
|
var import_util9 = require("@dxos/util");
|
|
@@ -3667,14 +3807,10 @@ var __decorate5 = function(decorators, target, key, desc) {
|
|
|
3667
3807
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3668
3808
|
};
|
|
3669
3809
|
var WorkerSession = class {
|
|
3670
|
-
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal
|
|
3671
|
-
|
|
3672
|
-
} }) {
|
|
3673
|
-
this._startTrigger = new import_async18.Trigger();
|
|
3810
|
+
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
3811
|
+
this._startTrigger = new import_async20.Trigger();
|
|
3674
3812
|
this.onClose = new import_util9.Callback();
|
|
3675
|
-
(0, import_node_assert12.default)(options);
|
|
3676
3813
|
(0, import_node_assert12.default)(serviceHost);
|
|
3677
|
-
this._options = options;
|
|
3678
3814
|
this._serviceHost = serviceHost;
|
|
3679
3815
|
const middleware = {
|
|
3680
3816
|
handleCall: async (method, params, handler) => {
|
|
@@ -3707,12 +3843,13 @@ var WorkerSession = class {
|
|
|
3707
3843
|
...middleware
|
|
3708
3844
|
});
|
|
3709
3845
|
this._iframeRpc = (0, import_rpc4.createProtoRpcPeer)({
|
|
3710
|
-
requested:
|
|
3711
|
-
exposed:
|
|
3846
|
+
requested: import_client_protocol4.iframeServiceBundle,
|
|
3847
|
+
exposed: import_client_protocol4.workerServiceBundle,
|
|
3712
3848
|
handlers: {
|
|
3713
3849
|
WorkerService: {
|
|
3714
3850
|
start: async (request) => {
|
|
3715
3851
|
this.origin = request.origin;
|
|
3852
|
+
this.lockKey = request.lockKey;
|
|
3716
3853
|
this._startTrigger.wake();
|
|
3717
3854
|
},
|
|
3718
3855
|
stop: async () => {
|
|
@@ -3722,7 +3859,7 @@ var WorkerSession = class {
|
|
|
3722
3859
|
} catch (err) {
|
|
3723
3860
|
import_log16.log.catch(err, {}, {
|
|
3724
3861
|
file: "worker-session.ts",
|
|
3725
|
-
line:
|
|
3862
|
+
line: 95,
|
|
3726
3863
|
scope: this,
|
|
3727
3864
|
callSite: (f, a) => f(...a)
|
|
3728
3865
|
});
|
|
@@ -3733,14 +3870,13 @@ var WorkerSession = class {
|
|
|
3733
3870
|
},
|
|
3734
3871
|
port: systemPort,
|
|
3735
3872
|
timeout: 1e3
|
|
3736
|
-
// With low timeout heartbeat may fail if the tab's thread is saturated.
|
|
3737
3873
|
});
|
|
3738
3874
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
3739
3875
|
}
|
|
3740
3876
|
async open() {
|
|
3741
3877
|
import_log16.log.info("opening..", {}, {
|
|
3742
3878
|
file: "worker-session.ts",
|
|
3743
|
-
line:
|
|
3879
|
+
line: 109,
|
|
3744
3880
|
scope: this,
|
|
3745
3881
|
callSite: (f, a) => f(...a)
|
|
3746
3882
|
});
|
|
@@ -3752,35 +3888,14 @@ var WorkerSession = class {
|
|
|
3752
3888
|
await this._startTrigger.wait({
|
|
3753
3889
|
timeout: 3e3
|
|
3754
3890
|
});
|
|
3755
|
-
this.
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
} catch (err1) {
|
|
3759
|
-
import_log16.log.warn("Heartbeat failed", {
|
|
3760
|
-
err: err1
|
|
3761
|
-
}, {
|
|
3762
|
-
file: "worker-session.ts",
|
|
3763
|
-
line: 133,
|
|
3764
|
-
scope: this,
|
|
3765
|
-
callSite: (f, a) => f(...a)
|
|
3766
|
-
});
|
|
3767
|
-
try {
|
|
3768
|
-
await this.close();
|
|
3769
|
-
} catch (err) {
|
|
3770
|
-
import_log16.log.catch(err, {}, {
|
|
3771
|
-
file: "worker-session.ts",
|
|
3772
|
-
line: 137,
|
|
3773
|
-
scope: this,
|
|
3774
|
-
callSite: (f, a) => f(...a)
|
|
3775
|
-
});
|
|
3776
|
-
}
|
|
3777
|
-
}
|
|
3778
|
-
}, this._options.heartbeatInterval);
|
|
3891
|
+
if (this.lockKey) {
|
|
3892
|
+
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
3893
|
+
}
|
|
3779
3894
|
}
|
|
3780
3895
|
async close() {
|
|
3781
3896
|
import_log16.log.info("closing..", {}, {
|
|
3782
3897
|
file: "worker-session.ts",
|
|
3783
|
-
line:
|
|
3898
|
+
line: 119,
|
|
3784
3899
|
scope: this,
|
|
3785
3900
|
callSite: (f, a) => f(...a)
|
|
3786
3901
|
});
|
|
@@ -3789,14 +3904,11 @@ var WorkerSession = class {
|
|
|
3789
3904
|
} catch (err) {
|
|
3790
3905
|
import_log16.log.catch(err, {}, {
|
|
3791
3906
|
file: "worker-session.ts",
|
|
3792
|
-
line:
|
|
3907
|
+
line: 123,
|
|
3793
3908
|
scope: this,
|
|
3794
3909
|
callSite: (f, a) => f(...a)
|
|
3795
3910
|
});
|
|
3796
3911
|
}
|
|
3797
|
-
if (this._heartbeatTimer !== void 0) {
|
|
3798
|
-
clearInterval(this._heartbeatTimer);
|
|
3799
|
-
}
|
|
3800
3912
|
await Promise.all([
|
|
3801
3913
|
this._clientRpc.close(),
|
|
3802
3914
|
this._iframeRpc.close()
|
|
@@ -3804,20 +3916,27 @@ var WorkerSession = class {
|
|
|
3804
3916
|
}
|
|
3805
3917
|
async _maybeOpenShell() {
|
|
3806
3918
|
try {
|
|
3807
|
-
await (0,
|
|
3919
|
+
await (0, import_async20.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
3808
3920
|
} catch (e) {
|
|
3809
3921
|
import_log16.log.info("No shell connected.", {}, {
|
|
3810
3922
|
file: "worker-session.ts",
|
|
3811
|
-
line:
|
|
3923
|
+
line: 133,
|
|
3812
3924
|
scope: this,
|
|
3813
3925
|
callSite: (f, a) => f(...a)
|
|
3814
3926
|
});
|
|
3815
3927
|
}
|
|
3816
3928
|
}
|
|
3929
|
+
_afterLockReleases(lockKey, callback) {
|
|
3930
|
+
return navigator.locks.request(lockKey, () => {
|
|
3931
|
+
}).then(callback);
|
|
3932
|
+
}
|
|
3817
3933
|
};
|
|
3818
3934
|
__decorate5([
|
|
3819
3935
|
import_log16.logInfo
|
|
3820
3936
|
], WorkerSession.prototype, "origin", void 0);
|
|
3937
|
+
__decorate5([
|
|
3938
|
+
import_log16.logInfo
|
|
3939
|
+
], WorkerSession.prototype, "lockKey", void 0);
|
|
3821
3940
|
|
|
3822
3941
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
3823
3942
|
var WorkerRuntime = class {
|
|
@@ -3825,7 +3944,7 @@ var WorkerRuntime = class {
|
|
|
3825
3944
|
constructor(_configProvider) {
|
|
3826
3945
|
this._configProvider = _configProvider;
|
|
3827
3946
|
this._transportFactory = new import_network_manager4.WebRTCTransportProxyFactory();
|
|
3828
|
-
this._ready = new
|
|
3947
|
+
this._ready = new import_async21.Trigger();
|
|
3829
3948
|
this.sessions = /* @__PURE__ */ new Set();
|
|
3830
3949
|
this._clientServices = new ClientServicesHost();
|
|
3831
3950
|
}
|
|
@@ -3844,17 +3963,14 @@ var WorkerRuntime = class {
|
|
|
3844
3963
|
const signals = this._config.get("runtime.services.signaling");
|
|
3845
3964
|
this._clientServices.initialize({
|
|
3846
3965
|
config: this._config,
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
signalManager: signals ? new import_messaging2.WebsocketSignalManager(signals) : new import_messaging2.MemorySignalManager(new import_messaging2.MemorySignalManagerContext()),
|
|
3850
|
-
transportFactory: this._transportFactory
|
|
3851
|
-
})
|
|
3966
|
+
signalManager: signals ? new import_messaging2.WebsocketSignalManager(signals) : new import_messaging2.MemorySignalManager(new import_messaging2.MemorySignalManagerContext()),
|
|
3967
|
+
transportFactory: this._transportFactory
|
|
3852
3968
|
});
|
|
3853
3969
|
await this._clientServices.open();
|
|
3854
3970
|
this._ready.wake(void 0);
|
|
3855
3971
|
(0, import_log17.log)("started", {}, {
|
|
3856
3972
|
file: "worker-runtime.ts",
|
|
3857
|
-
line:
|
|
3973
|
+
line: 62,
|
|
3858
3974
|
scope: this,
|
|
3859
3975
|
callSite: (f, a) => f(...a)
|
|
3860
3976
|
});
|
|
@@ -3862,7 +3978,7 @@ var WorkerRuntime = class {
|
|
|
3862
3978
|
this._ready.wake(err);
|
|
3863
3979
|
import_log17.log.catch(err, {}, {
|
|
3864
3980
|
file: "worker-runtime.ts",
|
|
3865
|
-
line:
|
|
3981
|
+
line: 65,
|
|
3866
3982
|
scope: this,
|
|
3867
3983
|
callSite: (f, a) => f(...a)
|
|
3868
3984
|
});
|
|
@@ -3894,6 +4010,12 @@ var WorkerRuntime = class {
|
|
|
3894
4010
|
* Selects one of the existing session fro WebRTC networking.
|
|
3895
4011
|
*/
|
|
3896
4012
|
_reconnectWebrtc() {
|
|
4013
|
+
(0, import_log17.log)("reconnecting webrtc...", {}, {
|
|
4014
|
+
file: "worker-runtime.ts",
|
|
4015
|
+
line: 102,
|
|
4016
|
+
scope: this,
|
|
4017
|
+
callSite: (f, a) => f(...a)
|
|
4018
|
+
});
|
|
3897
4019
|
if (this._sessionForNetworking) {
|
|
3898
4020
|
if (!this.sessions.has(this._sessionForNetworking)) {
|
|
3899
4021
|
this._sessionForNetworking = void 0;
|
|
@@ -3913,68 +4035,69 @@ var WorkerRuntime = class {
|
|
|
3913
4035
|
|
|
3914
4036
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3915
4037
|
var import_node_assert13 = __toESM(require("node:assert"));
|
|
3916
|
-
var
|
|
3917
|
-
var
|
|
3918
|
-
var
|
|
3919
|
-
var
|
|
3920
|
-
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
4038
|
+
var import_async22 = require("@dxos/async");
|
|
4039
|
+
var import_credentials13 = require("@dxos/credentials");
|
|
4040
|
+
var import_debug7 = require("@dxos/debug");
|
|
4041
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
3921
4042
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
3922
4043
|
var import_keyring = require("@dxos/keyring");
|
|
3923
4044
|
var import_keys10 = require("@dxos/keys");
|
|
3924
4045
|
var import_log18 = require("@dxos/log");
|
|
3925
|
-
var
|
|
4046
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
4047
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3926
4048
|
var ServiceContext = class {
|
|
3927
4049
|
// prettier-ignore
|
|
3928
|
-
constructor(storage, networkManager, modelFactory) {
|
|
4050
|
+
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
3929
4051
|
this.storage = storage;
|
|
3930
4052
|
this.networkManager = networkManager;
|
|
4053
|
+
this.signalManager = signalManager;
|
|
3931
4054
|
this.modelFactory = modelFactory;
|
|
3932
|
-
this.initialized = new
|
|
3933
|
-
this.dataServiceSubscriptions = new
|
|
4055
|
+
this.initialized = new import_async22.Trigger();
|
|
4056
|
+
this.dataServiceSubscriptions = new import_echo_pipeline3.DataServiceSubscriptions();
|
|
3934
4057
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
3935
4058
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
3936
|
-
|
|
3937
|
-
this.
|
|
3938
|
-
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4059
|
+
this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
|
|
4060
|
+
this.snapshotStore = new import_echo_pipeline3.SnapshotStore(storage.createDirectory("snapshots"));
|
|
3939
4061
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
3940
4062
|
this.feedStore = new import_feed_store4.FeedStore({
|
|
3941
4063
|
factory: new import_feed_store4.FeedFactory({
|
|
3942
4064
|
root: storage.createDirectory("feeds"),
|
|
3943
4065
|
signer: this.keyring,
|
|
3944
4066
|
hypercore: {
|
|
3945
|
-
valueEncoding:
|
|
4067
|
+
valueEncoding: import_echo_pipeline3.valueEncoding
|
|
3946
4068
|
}
|
|
3947
4069
|
})
|
|
3948
4070
|
});
|
|
3949
|
-
this.spaceManager = new
|
|
4071
|
+
this.spaceManager = new import_echo_pipeline3.SpaceManager({
|
|
3950
4072
|
feedStore: this.feedStore,
|
|
3951
|
-
networkManager: this.networkManager
|
|
4073
|
+
networkManager: this.networkManager,
|
|
4074
|
+
metadataStore: this.metadataStore,
|
|
4075
|
+
modelFactory: this.modelFactory,
|
|
4076
|
+
snapshotStore: this.snapshotStore
|
|
3952
4077
|
});
|
|
3953
|
-
this.spaceManager._traceParent = this._instanceId;
|
|
3954
4078
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3955
|
-
this.identityManager._traceParent = this._instanceId;
|
|
3956
4079
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3957
|
-
this.
|
|
3958
|
-
this._handlerFactories.set(import_client7.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
|
|
4080
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
|
|
3959
4081
|
var _a;
|
|
3960
|
-
return (_a = this.identityManager.identity) != null ? _a : (0,
|
|
4082
|
+
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
3961
4083
|
}, this._acceptIdentity.bind(this)));
|
|
3962
4084
|
}
|
|
3963
4085
|
async open() {
|
|
3964
|
-
import_log18.log.trace("dxos.sdk.service-context",
|
|
4086
|
+
import_log18.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
|
|
3965
4087
|
id: this._instanceId
|
|
3966
4088
|
}), {
|
|
3967
4089
|
file: "service-context.ts",
|
|
3968
|
-
line:
|
|
4090
|
+
line: 119,
|
|
3969
4091
|
scope: this,
|
|
3970
4092
|
callSite: (f, a) => f(...a)
|
|
3971
4093
|
});
|
|
3972
4094
|
(0, import_log18.log)("opening...", {}, {
|
|
3973
4095
|
file: "service-context.ts",
|
|
3974
|
-
line:
|
|
4096
|
+
line: 121,
|
|
3975
4097
|
scope: this,
|
|
3976
4098
|
callSite: (f, a) => f(...a)
|
|
3977
4099
|
});
|
|
4100
|
+
await this.signalManager.open();
|
|
3978
4101
|
await this.networkManager.open();
|
|
3979
4102
|
await this.spaceManager.open();
|
|
3980
4103
|
await this.identityManager.open();
|
|
@@ -3983,7 +4106,15 @@ var ServiceContext = class {
|
|
|
3983
4106
|
}
|
|
3984
4107
|
(0, import_log18.log)("opened", {}, {
|
|
3985
4108
|
file: "service-context.ts",
|
|
3986
|
-
line:
|
|
4109
|
+
line: 129,
|
|
4110
|
+
scope: this,
|
|
4111
|
+
callSite: (f, a) => f(...a)
|
|
4112
|
+
});
|
|
4113
|
+
import_log18.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
|
|
4114
|
+
id: this._instanceId
|
|
4115
|
+
}), {
|
|
4116
|
+
file: "service-context.ts",
|
|
4117
|
+
line: 130,
|
|
3987
4118
|
scope: this,
|
|
3988
4119
|
callSite: (f, a) => f(...a)
|
|
3989
4120
|
});
|
|
@@ -3992,7 +4123,7 @@ var ServiceContext = class {
|
|
|
3992
4123
|
var _a, _b;
|
|
3993
4124
|
(0, import_log18.log)("closing...", {}, {
|
|
3994
4125
|
file: "service-context.ts",
|
|
3995
|
-
line:
|
|
4126
|
+
line: 134,
|
|
3996
4127
|
scope: this,
|
|
3997
4128
|
callSite: (f, a) => f(...a)
|
|
3998
4129
|
});
|
|
@@ -4002,18 +4133,11 @@ var ServiceContext = class {
|
|
|
4002
4133
|
await this.spaceManager.close();
|
|
4003
4134
|
await this.feedStore.close();
|
|
4004
4135
|
await this.networkManager.close();
|
|
4136
|
+
await this.signalManager.close();
|
|
4005
4137
|
this.dataServiceSubscriptions.clear();
|
|
4006
4138
|
(0, import_log18.log)("closed", {}, {
|
|
4007
4139
|
file: "service-context.ts",
|
|
4008
|
-
line:
|
|
4009
|
-
scope: this,
|
|
4010
|
-
callSite: (f, a) => f(...a)
|
|
4011
|
-
});
|
|
4012
|
-
import_log18.log.trace("dxos.sdk.service-context", import_protocols7.trace.end({
|
|
4013
|
-
id: this._instanceId
|
|
4014
|
-
}), {
|
|
4015
|
-
file: "service-context.ts",
|
|
4016
|
-
line: 138,
|
|
4140
|
+
line: 143,
|
|
4017
4141
|
scope: this,
|
|
4018
4142
|
callSite: (f, a) => f(...a)
|
|
4019
4143
|
});
|
|
@@ -4038,11 +4162,11 @@ var ServiceContext = class {
|
|
|
4038
4162
|
var _a;
|
|
4039
4163
|
(0, import_log18.log)("initializing spaces...", {}, {
|
|
4040
4164
|
file: "service-context.ts",
|
|
4041
|
-
line:
|
|
4165
|
+
line: 168,
|
|
4042
4166
|
scope: this,
|
|
4043
4167
|
callSite: (f, a) => f(...a)
|
|
4044
4168
|
});
|
|
4045
|
-
const identity = (_a = this.identityManager.identity) != null ? _a : (0,
|
|
4169
|
+
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
4046
4170
|
const signingContext = {
|
|
4047
4171
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
4048
4172
|
identityKey: identity.identityKey,
|
|
@@ -4056,17 +4180,16 @@ var ServiceContext = class {
|
|
|
4056
4180
|
});
|
|
4057
4181
|
}
|
|
4058
4182
|
};
|
|
4059
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.
|
|
4060
|
-
this.dataSpaceManager._traceParent = this._instanceId;
|
|
4183
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
4061
4184
|
await this.dataSpaceManager.open();
|
|
4062
|
-
this._handlerFactories.set(
|
|
4185
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
4063
4186
|
(0, import_node_assert13.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
4064
4187
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
4065
4188
|
});
|
|
4066
4189
|
this.initialized.wake();
|
|
4067
4190
|
this._deviceSpaceSync = identity.space.spaceState.registerProcessor({
|
|
4068
4191
|
process: async (credential) => {
|
|
4069
|
-
const assertion = (0,
|
|
4192
|
+
const assertion = (0, import_credentials13.getCredentialAssertion)(credential);
|
|
4070
4193
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
4071
4194
|
return;
|
|
4072
4195
|
}
|
|
@@ -4078,7 +4201,7 @@ var ServiceContext = class {
|
|
|
4078
4201
|
details: assertion
|
|
4079
4202
|
}, {
|
|
4080
4203
|
file: "service-context.ts",
|
|
4081
|
-
line:
|
|
4204
|
+
line: 207,
|
|
4082
4205
|
scope: this,
|
|
4083
4206
|
callSite: (f, a) => f(...a)
|
|
4084
4207
|
});
|
|
@@ -4089,7 +4212,7 @@ var ServiceContext = class {
|
|
|
4089
4212
|
details: assertion
|
|
4090
4213
|
}, {
|
|
4091
4214
|
file: "service-context.ts",
|
|
4092
|
-
line:
|
|
4215
|
+
line: 211,
|
|
4093
4216
|
scope: this,
|
|
4094
4217
|
callSite: (f, a) => f(...a)
|
|
4095
4218
|
});
|
|
@@ -4100,7 +4223,7 @@ var ServiceContext = class {
|
|
|
4100
4223
|
details: assertion
|
|
4101
4224
|
}, {
|
|
4102
4225
|
file: "service-context.ts",
|
|
4103
|
-
line:
|
|
4226
|
+
line: 216,
|
|
4104
4227
|
scope: this,
|
|
4105
4228
|
callSite: (f, a) => f(...a)
|
|
4106
4229
|
});
|
|
@@ -4111,7 +4234,7 @@ var ServiceContext = class {
|
|
|
4111
4234
|
} catch (err) {
|
|
4112
4235
|
import_log18.log.catch(err, {}, {
|
|
4113
4236
|
file: "service-context.ts",
|
|
4114
|
-
line:
|
|
4237
|
+
line: 222,
|
|
4115
4238
|
scope: this,
|
|
4116
4239
|
callSite: (f, a) => f(...a)
|
|
4117
4240
|
});
|
|
@@ -4150,41 +4273,45 @@ var ServiceRegistry = class {
|
|
|
4150
4273
|
var ClientServicesHost = class {
|
|
4151
4274
|
constructor({
|
|
4152
4275
|
config,
|
|
4153
|
-
modelFactory = (0,
|
|
4276
|
+
modelFactory = (0, import_client_protocol5.createDefaultModelFactory)(),
|
|
4154
4277
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
4155
|
-
|
|
4278
|
+
transportFactory,
|
|
4279
|
+
signalManager,
|
|
4280
|
+
connectionLog,
|
|
4156
4281
|
storage,
|
|
4157
4282
|
// TODO(wittjosiah): Turn this on by default.
|
|
4158
4283
|
lockKey
|
|
4159
4284
|
} = {}) {
|
|
4160
|
-
this._statusUpdate = new
|
|
4285
|
+
this._statusUpdate = new import_async23.Event();
|
|
4161
4286
|
this._opening = false;
|
|
4162
4287
|
this._open = false;
|
|
4163
|
-
this._instanceId = import_client8.PublicKey.random().toHex();
|
|
4164
4288
|
this._storage = storage;
|
|
4165
4289
|
this._modelFactory = modelFactory;
|
|
4166
4290
|
if (config) {
|
|
4167
4291
|
this.initialize({
|
|
4168
4292
|
config,
|
|
4169
|
-
|
|
4293
|
+
transportFactory,
|
|
4294
|
+
signalManager
|
|
4170
4295
|
});
|
|
4171
4296
|
}
|
|
4172
4297
|
this._resourceLock = lockKey ? new VaultResourceLock({
|
|
4173
4298
|
lockKey,
|
|
4174
4299
|
onAcquire: () => {
|
|
4175
|
-
this._opening
|
|
4300
|
+
if (!this._opening) {
|
|
4301
|
+
void this.open();
|
|
4302
|
+
}
|
|
4176
4303
|
},
|
|
4177
4304
|
onRelease: () => this.close()
|
|
4178
4305
|
}) : void 0;
|
|
4179
4306
|
this._systemService = new SystemServiceImpl({
|
|
4180
4307
|
config: this._config,
|
|
4181
4308
|
statusUpdate: this._statusUpdate,
|
|
4182
|
-
getCurrentStatus: () => this.isOpen ?
|
|
4309
|
+
getCurrentStatus: () => this.isOpen ? import_services12.SystemStatus.ACTIVE : import_services12.SystemStatus.INACTIVE,
|
|
4183
4310
|
onUpdateStatus: async (status) => {
|
|
4184
4311
|
var _a, _b;
|
|
4185
|
-
if (!this.isOpen && status ===
|
|
4312
|
+
if (!this.isOpen && status === import_services12.SystemStatus.ACTIVE) {
|
|
4186
4313
|
await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
|
|
4187
|
-
} else if (this.isOpen && status ===
|
|
4314
|
+
} else if (this.isOpen && status === import_services12.SystemStatus.INACTIVE) {
|
|
4188
4315
|
await ((_b = this._resourceLock) == null ? void 0 : _b.release());
|
|
4189
4316
|
}
|
|
4190
4317
|
},
|
|
@@ -4193,7 +4320,7 @@ var ClientServicesHost = class {
|
|
|
4193
4320
|
}
|
|
4194
4321
|
});
|
|
4195
4322
|
this._loggingService = new LoggingServiceImpl();
|
|
4196
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
4323
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
4197
4324
|
SystemService: this._systemService
|
|
4198
4325
|
});
|
|
4199
4326
|
}
|
|
@@ -4214,7 +4341,8 @@ var ClientServicesHost = class {
|
|
|
4214
4341
|
* Config can also be provided in the constructor.
|
|
4215
4342
|
* Can only be called once.
|
|
4216
4343
|
*/
|
|
4217
|
-
initialize({ config,
|
|
4344
|
+
initialize({ config, ...options }) {
|
|
4345
|
+
var _a, _b, _c;
|
|
4218
4346
|
(0, import_node_assert14.default)(!this._open, "service host is open");
|
|
4219
4347
|
if (config) {
|
|
4220
4348
|
(0, import_node_assert14.default)(!this._config, "config already set");
|
|
@@ -4223,39 +4351,47 @@ var ClientServicesHost = class {
|
|
|
4223
4351
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
4224
4352
|
}
|
|
4225
4353
|
}
|
|
4226
|
-
|
|
4227
|
-
(
|
|
4228
|
-
|
|
4229
|
-
|
|
4354
|
+
const { connectionLog = true, transportFactory = (0, import_network_manager5.createWebRTCTransportFactory)({
|
|
4355
|
+
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
4356
|
+
}), signalManager = new import_messaging3.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
4357
|
+
this._signalManager = signalManager;
|
|
4358
|
+
(0, import_node_assert14.default)(!this._networkManager, "network manager already set");
|
|
4359
|
+
this._networkManager = new import_network_manager5.NetworkManager({
|
|
4360
|
+
log: connectionLog,
|
|
4361
|
+
transportFactory,
|
|
4362
|
+
signalManager
|
|
4363
|
+
});
|
|
4230
4364
|
}
|
|
4231
4365
|
async open() {
|
|
4232
4366
|
var _a, _b, _c;
|
|
4233
4367
|
if (this._open) {
|
|
4234
4368
|
return;
|
|
4235
4369
|
}
|
|
4236
|
-
|
|
4237
|
-
|
|
4370
|
+
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4371
|
+
import_log19.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
|
|
4372
|
+
id: traceId
|
|
4238
4373
|
}), {
|
|
4239
4374
|
file: "service-host.ts",
|
|
4240
|
-
line:
|
|
4375
|
+
line: 186,
|
|
4241
4376
|
scope: this,
|
|
4242
4377
|
callSite: (f, a) => f(...a)
|
|
4243
4378
|
});
|
|
4244
4379
|
(0, import_node_assert14.default)(this._config, "config not set");
|
|
4245
4380
|
(0, import_node_assert14.default)(this._storage, "storage not set");
|
|
4381
|
+
(0, import_node_assert14.default)(this._signalManager, "signal manager not set");
|
|
4246
4382
|
(0, import_node_assert14.default)(this._networkManager, "network manager not set");
|
|
4247
4383
|
this._opening = true;
|
|
4248
4384
|
(0, import_log19.log)("opening...", {
|
|
4249
4385
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
4250
4386
|
}, {
|
|
4251
4387
|
file: "service-host.ts",
|
|
4252
|
-
line:
|
|
4388
|
+
line: 194,
|
|
4253
4389
|
scope: this,
|
|
4254
4390
|
callSite: (f, a) => f(...a)
|
|
4255
4391
|
});
|
|
4256
4392
|
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
4257
4393
|
await this._loggingService.open();
|
|
4258
|
-
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._modelFactory);
|
|
4394
|
+
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4259
4395
|
this._serviceRegistry.setServices({
|
|
4260
4396
|
SystemService: this._systemService,
|
|
4261
4397
|
IdentityService: new IdentityServiceImpl(this._serviceContext),
|
|
@@ -4265,8 +4401,8 @@ var ClientServicesHost = class {
|
|
|
4265
4401
|
await this._serviceContext.initialized.wait();
|
|
4266
4402
|
return this._serviceContext.dataSpaceManager;
|
|
4267
4403
|
}),
|
|
4268
|
-
DataService: new
|
|
4269
|
-
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager),
|
|
4404
|
+
DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4405
|
+
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
4270
4406
|
LoggingService: this._loggingService,
|
|
4271
4407
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4272
4408
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
@@ -4284,7 +4420,15 @@ var ClientServicesHost = class {
|
|
|
4284
4420
|
deviceKey
|
|
4285
4421
|
}, {
|
|
4286
4422
|
file: "service-host.ts",
|
|
4287
|
-
line:
|
|
4423
|
+
line: 249,
|
|
4424
|
+
scope: this,
|
|
4425
|
+
callSite: (f, a) => f(...a)
|
|
4426
|
+
});
|
|
4427
|
+
import_log19.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
|
|
4428
|
+
id: traceId
|
|
4429
|
+
}), {
|
|
4430
|
+
file: "service-host.ts",
|
|
4431
|
+
line: 250,
|
|
4288
4432
|
scope: this,
|
|
4289
4433
|
callSite: (f, a) => f(...a)
|
|
4290
4434
|
});
|
|
@@ -4299,7 +4443,7 @@ var ClientServicesHost = class {
|
|
|
4299
4443
|
deviceKey
|
|
4300
4444
|
}, {
|
|
4301
4445
|
file: "service-host.ts",
|
|
4302
|
-
line:
|
|
4446
|
+
line: 259,
|
|
4303
4447
|
scope: this,
|
|
4304
4448
|
callSite: (f, a) => f(...a)
|
|
4305
4449
|
});
|
|
@@ -4314,24 +4458,25 @@ var ClientServicesHost = class {
|
|
|
4314
4458
|
deviceKey
|
|
4315
4459
|
}, {
|
|
4316
4460
|
file: "service-host.ts",
|
|
4317
|
-
line:
|
|
4461
|
+
line: 265,
|
|
4318
4462
|
scope: this,
|
|
4319
4463
|
callSite: (f, a) => f(...a)
|
|
4320
4464
|
});
|
|
4321
|
-
|
|
4322
|
-
|
|
4465
|
+
}
|
|
4466
|
+
async reset() {
|
|
4467
|
+
var _a;
|
|
4468
|
+
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4469
|
+
import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
|
|
4470
|
+
id: traceId
|
|
4323
4471
|
}), {
|
|
4324
4472
|
file: "service-host.ts",
|
|
4325
|
-
line:
|
|
4473
|
+
line: 270,
|
|
4326
4474
|
scope: this,
|
|
4327
4475
|
callSite: (f, a) => f(...a)
|
|
4328
4476
|
});
|
|
4329
|
-
}
|
|
4330
|
-
async reset() {
|
|
4331
|
-
var _a;
|
|
4332
4477
|
(0, import_log19.log)("resetting...", {}, {
|
|
4333
4478
|
file: "service-host.ts",
|
|
4334
|
-
line:
|
|
4479
|
+
line: 272,
|
|
4335
4480
|
scope: this,
|
|
4336
4481
|
callSite: (f, a) => f(...a)
|
|
4337
4482
|
});
|
|
@@ -4339,7 +4484,15 @@ var ClientServicesHost = class {
|
|
|
4339
4484
|
await this._storage.reset();
|
|
4340
4485
|
(0, import_log19.log)("reset", {}, {
|
|
4341
4486
|
file: "service-host.ts",
|
|
4342
|
-
line:
|
|
4487
|
+
line: 275,
|
|
4488
|
+
scope: this,
|
|
4489
|
+
callSite: (f, a) => f(...a)
|
|
4490
|
+
});
|
|
4491
|
+
import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
|
|
4492
|
+
id: traceId
|
|
4493
|
+
}), {
|
|
4494
|
+
file: "service-host.ts",
|
|
4495
|
+
line: 276,
|
|
4343
4496
|
scope: this,
|
|
4344
4497
|
callSite: (f, a) => f(...a)
|
|
4345
4498
|
});
|
|
@@ -4367,44 +4520,11 @@ var LocalClientServices = class {
|
|
|
4367
4520
|
await this._host.close();
|
|
4368
4521
|
}
|
|
4369
4522
|
};
|
|
4370
|
-
|
|
4371
|
-
// packages/sdk/client-services/src/packlets/services/utils.ts
|
|
4372
|
-
var import_config2 = require("@dxos/config");
|
|
4373
|
-
var import_log20 = require("@dxos/log");
|
|
4374
|
-
var import_messaging3 = require("@dxos/messaging");
|
|
4375
|
-
var import_network_manager5 = require("@dxos/network-manager");
|
|
4376
|
-
var fromHost = (config = new import_config2.Config()) => {
|
|
4377
|
-
return new LocalClientServices({
|
|
4378
|
-
config,
|
|
4379
|
-
networkManager: createNetworkManager(config)
|
|
4380
|
-
});
|
|
4381
|
-
};
|
|
4382
|
-
var createNetworkManager = (config, options = {}) => {
|
|
4383
|
-
const signals = config.get("runtime.services.signaling");
|
|
4384
|
-
if (signals) {
|
|
4385
|
-
const { log: log1 = true, signalManager = new import_messaging3.WebsocketSignalManager(signals), transportFactory = (0, import_network_manager5.createWebRTCTransportFactory)({
|
|
4386
|
-
iceServers: config.get("runtime.services.ice")
|
|
4387
|
-
}) } = options;
|
|
4388
|
-
return new import_network_manager5.NetworkManager({
|
|
4389
|
-
log: log1,
|
|
4390
|
-
signalManager,
|
|
4391
|
-
transportFactory
|
|
4392
|
-
});
|
|
4393
|
-
}
|
|
4394
|
-
import_log20.log.warn("P2P network is not configured.", {}, {
|
|
4395
|
-
file: "utils.ts",
|
|
4396
|
-
line: 48,
|
|
4397
|
-
scope: void 0,
|
|
4398
|
-
callSite: (f, a) => f(...a)
|
|
4399
|
-
});
|
|
4400
|
-
return new import_network_manager5.NetworkManager({
|
|
4401
|
-
signalManager: new import_messaging3.MemorySignalManager(new import_messaging3.MemorySignalManagerContext()),
|
|
4402
|
-
transportFactory: import_network_manager5.MemoryTransportFactory
|
|
4403
|
-
});
|
|
4404
|
-
};
|
|
4405
4523
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4406
4524
|
0 && (module.exports = {
|
|
4407
4525
|
ClientServicesHost,
|
|
4526
|
+
DataSpace,
|
|
4527
|
+
DataSpaceManager,
|
|
4408
4528
|
DeviceInvitationProtocol,
|
|
4409
4529
|
DevtoolsHostEvents,
|
|
4410
4530
|
DevtoolsServiceImpl,
|
|
@@ -4421,13 +4541,13 @@ var createNetworkManager = (config, options = {}) => {
|
|
|
4421
4541
|
ServiceRegistry,
|
|
4422
4542
|
ShellRuntimeImpl,
|
|
4423
4543
|
SpaceInvitationProtocol,
|
|
4544
|
+
SpacesServiceImpl,
|
|
4424
4545
|
TrustedKeySetAuthVerifier,
|
|
4425
4546
|
VaultResourceLock,
|
|
4426
4547
|
WorkerRuntime,
|
|
4427
4548
|
WorkerSession,
|
|
4428
4549
|
createAuthProvider,
|
|
4429
4550
|
createStorageObjects,
|
|
4430
|
-
fromHost,
|
|
4431
4551
|
getNetworkPeers,
|
|
4432
4552
|
subscribeToFeedBlocks,
|
|
4433
4553
|
subscribeToFeeds,
|