@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
|
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// packages/sdk/client-services/src/packlets/testing/index.ts
|
|
31
31
|
var testing_exports = {};
|
|
32
32
|
__export(testing_exports, {
|
|
33
|
-
HostTestBuilder: () => HostTestBuilder,
|
|
34
33
|
TestBuilder: () => TestBuilder,
|
|
35
34
|
TestPeer: () => TestPeer,
|
|
36
35
|
createIdentity: () => createIdentity,
|
|
@@ -39,13 +38,9 @@ __export(testing_exports, {
|
|
|
39
38
|
createServiceContext: () => createServiceContext,
|
|
40
39
|
createServiceHost: () => createServiceHost,
|
|
41
40
|
createSigningContext: () => createSigningContext,
|
|
42
|
-
joinCommonSpace: () => joinCommonSpace,
|
|
43
41
|
performInvitation: () => performInvitation,
|
|
44
42
|
sanitizeInvitation: () => sanitizeInvitation,
|
|
45
|
-
|
|
46
|
-
syncItemsLocal: () => syncItemsLocal,
|
|
47
|
-
testConfigWithLocalSignal: () => testConfigWithLocalSignal,
|
|
48
|
-
testSpace: () => testSpace
|
|
43
|
+
syncItemsLocal: () => syncItemsLocal
|
|
49
44
|
});
|
|
50
45
|
module.exports = __toCommonJS(testing_exports);
|
|
51
46
|
|
|
@@ -65,25 +60,22 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
|
|
|
65
60
|
}
|
|
66
61
|
});
|
|
67
62
|
|
|
68
|
-
// packages/sdk/client-services/src/packlets/testing/
|
|
69
|
-
var
|
|
70
|
-
var
|
|
71
|
-
var
|
|
72
|
-
var import_testing = require("@dxos/echo-pipeline/testing");
|
|
73
|
-
var import_feed_store5 = require("@dxos/feed-store");
|
|
74
|
-
var import_keyring2 = require("@dxos/keyring");
|
|
75
|
-
var import_messaging4 = require("@dxos/messaging");
|
|
76
|
-
var import_network_manager6 = require("@dxos/network-manager");
|
|
77
|
-
var import_random_access_storage2 = require("@dxos/random-access-storage");
|
|
63
|
+
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
64
|
+
var import_node_assert15 = __toESM(require("node:assert"));
|
|
65
|
+
var import_async24 = require("@dxos/async");
|
|
66
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
78
67
|
|
|
79
68
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
80
69
|
var import_node_assert14 = __toESM(require("node:assert"));
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
var
|
|
70
|
+
var import_async23 = require("@dxos/async");
|
|
71
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
72
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
73
|
+
var import_keys12 = require("@dxos/keys");
|
|
84
74
|
var import_log19 = require("@dxos/log");
|
|
85
|
-
var
|
|
86
|
-
var
|
|
75
|
+
var import_messaging3 = require("@dxos/messaging");
|
|
76
|
+
var import_network_manager5 = require("@dxos/network-manager");
|
|
77
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
78
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
87
79
|
|
|
88
80
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
89
81
|
var import_async = require("@dxos/async");
|
|
@@ -133,7 +125,7 @@ var DevicesServiceImpl = class {
|
|
|
133
125
|
};
|
|
134
126
|
|
|
135
127
|
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
136
|
-
var
|
|
128
|
+
var import_async4 = require("@dxos/async");
|
|
137
129
|
var import_codec_protobuf6 = require("@dxos/codec-protobuf");
|
|
138
130
|
|
|
139
131
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
@@ -144,9 +136,6 @@ var import_keys2 = require("@dxos/keys");
|
|
|
144
136
|
var import_util = require("@dxos/util");
|
|
145
137
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
146
138
|
return new import_codec_protobuf2.Stream(({ next }) => {
|
|
147
|
-
if ((feedKeys == null ? void 0 : feedKeys.length) === 0) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
139
|
const subscriptions = new import_async2.EventSubscriptions();
|
|
151
140
|
const feedMap = new import_util.ComplexMap(import_keys2.PublicKey.hash);
|
|
152
141
|
const update = () => {
|
|
@@ -155,13 +144,14 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
155
144
|
if (!feedMap.has(feed.key)) {
|
|
156
145
|
feedMap.set(feed.key, feed);
|
|
157
146
|
feed.on("close", update);
|
|
158
|
-
subscriptions.add(feed.off("close", update));
|
|
147
|
+
subscriptions.add(() => feed.off("close", update));
|
|
159
148
|
}
|
|
160
149
|
});
|
|
161
150
|
next({
|
|
162
151
|
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
163
152
|
feedKey: feed.key,
|
|
164
|
-
length: feed.properties.length
|
|
153
|
+
length: feed.properties.length,
|
|
154
|
+
diskUsage: feed.core.byteLength
|
|
165
155
|
}))
|
|
166
156
|
});
|
|
167
157
|
};
|
|
@@ -212,26 +202,26 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
|
212
202
|
};
|
|
213
203
|
|
|
214
204
|
// packages/sdk/client-services/src/packlets/devtools/keys.ts
|
|
205
|
+
var import_async3 = require("@dxos/async");
|
|
215
206
|
var import_codec_protobuf3 = require("@dxos/codec-protobuf");
|
|
216
|
-
var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf3.Stream(({ next }) => {
|
|
217
|
-
const update = () => {
|
|
207
|
+
var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf3.Stream(({ next, ctx }) => {
|
|
208
|
+
const update = async () => {
|
|
218
209
|
next({
|
|
219
|
-
keys: keyring.list()
|
|
210
|
+
keys: await keyring.list()
|
|
220
211
|
});
|
|
221
212
|
};
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
return unsubscribe;
|
|
213
|
+
keyring.keysUpdate.on(ctx, update);
|
|
214
|
+
(0, import_async3.scheduleTask)(ctx, update);
|
|
225
215
|
});
|
|
226
216
|
|
|
227
217
|
// packages/sdk/client-services/src/packlets/devtools/network.ts
|
|
228
218
|
var import_codec_protobuf4 = require("@dxos/codec-protobuf");
|
|
229
219
|
var import_context = require("@dxos/context");
|
|
230
220
|
var import_keys3 = require("@dxos/keys");
|
|
231
|
-
var subscribeToNetworkStatus = ({
|
|
221
|
+
var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf4.Stream(({ next, close }) => {
|
|
232
222
|
const update = () => {
|
|
233
223
|
try {
|
|
234
|
-
const status =
|
|
224
|
+
const status = signalManager.getStatus();
|
|
235
225
|
next({
|
|
236
226
|
servers: status
|
|
237
227
|
});
|
|
@@ -239,12 +229,12 @@ var subscribeToNetworkStatus = ({ networkManager }) => new import_codec_protobuf
|
|
|
239
229
|
close(err);
|
|
240
230
|
}
|
|
241
231
|
};
|
|
242
|
-
|
|
232
|
+
signalManager.statusChanged.on(() => update());
|
|
243
233
|
update();
|
|
244
234
|
});
|
|
245
|
-
var subscribeToSignal = ({
|
|
235
|
+
var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf4.Stream(({ next }) => {
|
|
246
236
|
const ctx = new import_context.Context();
|
|
247
|
-
|
|
237
|
+
signalManager.onMessage.on(ctx, (message) => {
|
|
248
238
|
next({
|
|
249
239
|
message: {
|
|
250
240
|
author: message.author.asUint8Array(),
|
|
@@ -254,7 +244,7 @@ var subscribeToSignal = ({ networkManager }) => new import_codec_protobuf4.Strea
|
|
|
254
244
|
receivedAt: new Date()
|
|
255
245
|
});
|
|
256
246
|
});
|
|
257
|
-
|
|
247
|
+
signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
258
248
|
next({
|
|
259
249
|
swarmEvent: swarmEvent.swarmEvent,
|
|
260
250
|
receivedAt: new Date()
|
|
@@ -318,7 +308,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
318
308
|
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
319
309
|
var DevtoolsHostEvents = class {
|
|
320
310
|
constructor() {
|
|
321
|
-
this.ready = new
|
|
311
|
+
this.ready = new import_async4.Event();
|
|
322
312
|
}
|
|
323
313
|
};
|
|
324
314
|
var DevtoolsServiceImpl = class {
|
|
@@ -337,6 +327,24 @@ var DevtoolsServiceImpl = class {
|
|
|
337
327
|
getConfig(request) {
|
|
338
328
|
throw new Error();
|
|
339
329
|
}
|
|
330
|
+
async getStorageInfo() {
|
|
331
|
+
var _a, _b, _c, _d, _e;
|
|
332
|
+
const storageUsage = (_c = await ((_b = (_a = this.params.context.storage).getDiskInfo) == null ? void 0 : _b.call(_a))) != null ? _c : {
|
|
333
|
+
used: 0
|
|
334
|
+
};
|
|
335
|
+
const navigatorInfo = typeof navigator === "object" ? await navigator.storage.estimate() : void 0;
|
|
336
|
+
return {
|
|
337
|
+
type: this.params.context.storage.type,
|
|
338
|
+
storageUsage: storageUsage.used,
|
|
339
|
+
originUsage: (_d = navigatorInfo == null ? void 0 : navigatorInfo.usage) != null ? _d : 0,
|
|
340
|
+
usageQuota: (_e = navigatorInfo == null ? void 0 : navigatorInfo.quota) != null ? _e : 0
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
async getSnapshots() {
|
|
344
|
+
return {
|
|
345
|
+
snapshots: await this.params.context.snapshotStore.listSnapshots()
|
|
346
|
+
};
|
|
347
|
+
}
|
|
340
348
|
resetStorage(request) {
|
|
341
349
|
throw new Error();
|
|
342
350
|
}
|
|
@@ -387,12 +395,12 @@ var DevtoolsServiceImpl = class {
|
|
|
387
395
|
}
|
|
388
396
|
subscribeToSignalStatus(request) {
|
|
389
397
|
return subscribeToNetworkStatus({
|
|
390
|
-
|
|
398
|
+
signalManager: this.params.context.signalManager
|
|
391
399
|
});
|
|
392
400
|
}
|
|
393
401
|
subscribeToSignal() {
|
|
394
402
|
return subscribeToSignal({
|
|
395
|
-
|
|
403
|
+
signalManager: this.params.context.signalManager
|
|
396
404
|
});
|
|
397
405
|
}
|
|
398
406
|
subscribeToSwarmInfo() {
|
|
@@ -403,7 +411,7 @@ var DevtoolsServiceImpl = class {
|
|
|
403
411
|
};
|
|
404
412
|
|
|
405
413
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
406
|
-
var
|
|
414
|
+
var import_async5 = require("@dxos/async");
|
|
407
415
|
var import_context2 = require("@dxos/context");
|
|
408
416
|
var import_credentials2 = require("@dxos/credentials");
|
|
409
417
|
var import_log = require("@dxos/log");
|
|
@@ -473,7 +481,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
473
481
|
});
|
|
474
482
|
return true;
|
|
475
483
|
}
|
|
476
|
-
const trigger = new
|
|
484
|
+
const trigger = new import_async5.Trigger();
|
|
477
485
|
this._ctx.onDispose(() => {
|
|
478
486
|
trigger.wake(false);
|
|
479
487
|
});
|
|
@@ -518,7 +526,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
518
526
|
|
|
519
527
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
520
528
|
var import_node_assert = __toESM(require("node:assert"));
|
|
521
|
-
var
|
|
529
|
+
var import_async6 = require("@dxos/async");
|
|
522
530
|
var import_credentials3 = require("@dxos/credentials");
|
|
523
531
|
var import_debug = require("@dxos/debug");
|
|
524
532
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
@@ -527,7 +535,7 @@ var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials")
|
|
|
527
535
|
var AUTH_TIMEOUT = 3e4;
|
|
528
536
|
var Identity = class {
|
|
529
537
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
530
|
-
this.stateUpdate = new
|
|
538
|
+
this.stateUpdate = new import_async6.Event();
|
|
531
539
|
this.space = space;
|
|
532
540
|
this._signer = signer;
|
|
533
541
|
this.identityKey = identityKey;
|
|
@@ -661,7 +669,7 @@ var Identity = class {
|
|
|
661
669
|
|
|
662
670
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
663
671
|
var import_node_assert2 = __toESM(require("node:assert"));
|
|
664
|
-
var
|
|
672
|
+
var import_async7 = require("@dxos/async");
|
|
665
673
|
var import_credentials5 = require("@dxos/credentials");
|
|
666
674
|
var import_keys5 = require("@dxos/keys");
|
|
667
675
|
var import_log3 = require("@dxos/log");
|
|
@@ -676,20 +684,19 @@ var IdentityManager = class {
|
|
|
676
684
|
this._keyring = _keyring;
|
|
677
685
|
this._feedStore = _feedStore;
|
|
678
686
|
this._spaceManager = _spaceManager;
|
|
679
|
-
this.stateUpdate = new
|
|
680
|
-
this._instanceId = import_keys5.PublicKey.random().toHex();
|
|
687
|
+
this.stateUpdate = new import_async7.Event();
|
|
681
688
|
}
|
|
682
689
|
get identity() {
|
|
683
690
|
return this._identity;
|
|
684
691
|
}
|
|
685
692
|
async open() {
|
|
686
693
|
var _a;
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
694
|
+
const traceId = import_keys5.PublicKey.random().toHex();
|
|
695
|
+
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
|
|
696
|
+
id: traceId
|
|
690
697
|
}), {
|
|
691
698
|
file: "identity-manager.ts",
|
|
692
|
-
line:
|
|
699
|
+
line: 70,
|
|
693
700
|
scope: this,
|
|
694
701
|
callSite: (f, a) => f(...a)
|
|
695
702
|
});
|
|
@@ -699,7 +706,7 @@ var IdentityManager = class {
|
|
|
699
706
|
identityRecord
|
|
700
707
|
}, {
|
|
701
708
|
file: "identity-manager.ts",
|
|
702
|
-
line:
|
|
709
|
+
line: 74,
|
|
703
710
|
scope: this,
|
|
704
711
|
callSite: (f, a) => f(...a)
|
|
705
712
|
});
|
|
@@ -712,31 +719,31 @@ var IdentityManager = class {
|
|
|
712
719
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
713
720
|
}, {
|
|
714
721
|
file: "identity-manager.ts",
|
|
715
|
-
line:
|
|
722
|
+
line: 79,
|
|
716
723
|
scope: this,
|
|
717
724
|
callSite: (f, a) => f(...a)
|
|
718
725
|
});
|
|
719
726
|
this.stateUpdate.emit();
|
|
720
727
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
var _a;
|
|
724
|
-
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
725
|
-
import_log3.log.trace("dxos.halo.identity-manager", import_protocols2.trace.end({
|
|
726
|
-
id: this._instanceId
|
|
728
|
+
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.end({
|
|
729
|
+
id: traceId
|
|
727
730
|
}), {
|
|
728
731
|
file: "identity-manager.ts",
|
|
729
|
-
line:
|
|
732
|
+
line: 85,
|
|
730
733
|
scope: this,
|
|
731
734
|
callSite: (f, a) => f(...a)
|
|
732
735
|
});
|
|
733
736
|
}
|
|
737
|
+
async close() {
|
|
738
|
+
var _a;
|
|
739
|
+
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
740
|
+
}
|
|
734
741
|
async createIdentity({ displayName } = {}) {
|
|
735
742
|
var _a;
|
|
736
743
|
(0, import_node_assert2.default)(!this._identity, "Identity already exists.");
|
|
737
744
|
(0, import_log3.log)("creating identity...", {}, {
|
|
738
745
|
file: "identity-manager.ts",
|
|
739
|
-
line:
|
|
746
|
+
line: 94,
|
|
740
747
|
scope: this,
|
|
741
748
|
callSite: (f, a) => f(...a)
|
|
742
749
|
});
|
|
@@ -785,7 +792,7 @@ var IdentityManager = class {
|
|
|
785
792
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
786
793
|
}, {
|
|
787
794
|
file: "identity-manager.ts",
|
|
788
|
-
line:
|
|
795
|
+
line: 149,
|
|
789
796
|
scope: this,
|
|
790
797
|
callSite: (f, a) => f(...a)
|
|
791
798
|
});
|
|
@@ -795,7 +802,7 @@ var IdentityManager = class {
|
|
|
795
802
|
deviceKey: identity.deviceKey
|
|
796
803
|
}, {
|
|
797
804
|
file: "identity-manager.ts",
|
|
798
|
-
line:
|
|
805
|
+
line: 155,
|
|
799
806
|
scope: this,
|
|
800
807
|
callSite: (f, a) => f(...a)
|
|
801
808
|
});
|
|
@@ -810,7 +817,7 @@ var IdentityManager = class {
|
|
|
810
817
|
params
|
|
811
818
|
}, {
|
|
812
819
|
file: "identity-manager.ts",
|
|
813
|
-
line:
|
|
820
|
+
line: 163,
|
|
814
821
|
scope: this,
|
|
815
822
|
callSite: (f, a) => f(...a)
|
|
816
823
|
});
|
|
@@ -836,7 +843,7 @@ var IdentityManager = class {
|
|
|
836
843
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
837
844
|
}, {
|
|
838
845
|
file: "identity-manager.ts",
|
|
839
|
-
line:
|
|
846
|
+
line: 183,
|
|
840
847
|
scope: this,
|
|
841
848
|
callSite: (f, a) => f(...a)
|
|
842
849
|
});
|
|
@@ -846,7 +853,7 @@ var IdentityManager = class {
|
|
|
846
853
|
deviceKey: identity.deviceKey
|
|
847
854
|
}, {
|
|
848
855
|
file: "identity-manager.ts",
|
|
849
|
-
line:
|
|
856
|
+
line: 189,
|
|
850
857
|
scope: this,
|
|
851
858
|
callSite: (f, a) => f(...a)
|
|
852
859
|
});
|
|
@@ -858,7 +865,7 @@ var IdentityManager = class {
|
|
|
858
865
|
identityRecord
|
|
859
866
|
}, {
|
|
860
867
|
file: "identity-manager.ts",
|
|
861
|
-
line:
|
|
868
|
+
line: 195,
|
|
862
869
|
scope: this,
|
|
863
870
|
callSite: (f, a) => f(...a)
|
|
864
871
|
});
|
|
@@ -891,7 +898,7 @@ var IdentityManager = class {
|
|
|
891
898
|
identityKey: identityRecord.identityKey
|
|
892
899
|
}, {
|
|
893
900
|
file: "identity-manager.ts",
|
|
894
|
-
line:
|
|
901
|
+
line: 223,
|
|
895
902
|
scope: this,
|
|
896
903
|
callSite: (f, a) => f(...a)
|
|
897
904
|
});
|
|
@@ -908,7 +915,8 @@ var IdentityManager = class {
|
|
|
908
915
|
},
|
|
909
916
|
swarmIdentity,
|
|
910
917
|
onNetworkConnection: () => {
|
|
911
|
-
}
|
|
918
|
+
},
|
|
919
|
+
memberKey: identityKey
|
|
912
920
|
});
|
|
913
921
|
}
|
|
914
922
|
};
|
|
@@ -1028,8 +1036,8 @@ var DeviceInvitationProtocol = class {
|
|
|
1028
1036
|
|
|
1029
1037
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1030
1038
|
var import_node_assert6 = __toESM(require("node:assert"));
|
|
1031
|
-
var
|
|
1032
|
-
var
|
|
1039
|
+
var import_async9 = require("@dxos/async");
|
|
1040
|
+
var import_client_protocol = require("@dxos/client-protocol");
|
|
1033
1041
|
var import_context4 = require("@dxos/context");
|
|
1034
1042
|
var import_credentials8 = require("@dxos/credentials");
|
|
1035
1043
|
var import_errors2 = require("@dxos/errors");
|
|
@@ -1042,7 +1050,7 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
|
|
|
1042
1050
|
|
|
1043
1051
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
1044
1052
|
var import_node_assert5 = __toESM(require("node:assert"));
|
|
1045
|
-
var
|
|
1053
|
+
var import_async8 = require("@dxos/async");
|
|
1046
1054
|
var import_context3 = require("@dxos/context");
|
|
1047
1055
|
var import_errors = require("@dxos/errors");
|
|
1048
1056
|
var import_keys6 = require("@dxos/keys");
|
|
@@ -1063,7 +1071,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1063
1071
|
});
|
|
1064
1072
|
this._callbacks = _callbacks;
|
|
1065
1073
|
this._ctx = new import_context3.Context();
|
|
1066
|
-
this._remoteOptionsTrigger = new
|
|
1074
|
+
this._remoteOptionsTrigger = new import_async8.Trigger();
|
|
1067
1075
|
}
|
|
1068
1076
|
async getHandlers() {
|
|
1069
1077
|
return {
|
|
@@ -1078,11 +1086,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1078
1086
|
introduce: async (request) => {
|
|
1079
1087
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1080
1088
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
|
|
1081
|
-
id: traceId
|
|
1082
|
-
parentId: this._traceParent
|
|
1089
|
+
id: traceId
|
|
1083
1090
|
}), {
|
|
1084
1091
|
file: "invitation-extension.ts",
|
|
1085
|
-
line:
|
|
1092
|
+
line: 76,
|
|
1086
1093
|
scope: this,
|
|
1087
1094
|
callSite: (f, a) => f(...a)
|
|
1088
1095
|
});
|
|
@@ -1091,7 +1098,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1091
1098
|
id: traceId
|
|
1092
1099
|
}), {
|
|
1093
1100
|
file: "invitation-extension.ts",
|
|
1094
|
-
line:
|
|
1101
|
+
line: 78,
|
|
1095
1102
|
scope: this,
|
|
1096
1103
|
callSite: (f, a) => f(...a)
|
|
1097
1104
|
});
|
|
@@ -1100,11 +1107,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1100
1107
|
authenticate: async (request) => {
|
|
1101
1108
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1102
1109
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
|
|
1103
|
-
id: traceId
|
|
1104
|
-
parentId: this._traceParent
|
|
1110
|
+
id: traceId
|
|
1105
1111
|
}), {
|
|
1106
1112
|
file: "invitation-extension.ts",
|
|
1107
|
-
line:
|
|
1113
|
+
line: 84,
|
|
1108
1114
|
scope: this,
|
|
1109
1115
|
callSite: (f, a) => f(...a)
|
|
1110
1116
|
});
|
|
@@ -1116,7 +1122,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1116
1122
|
}
|
|
1117
1123
|
}), {
|
|
1118
1124
|
file: "invitation-extension.ts",
|
|
1119
|
-
line:
|
|
1125
|
+
line: 86,
|
|
1120
1126
|
scope: this,
|
|
1121
1127
|
callSite: (f, a) => f(...a)
|
|
1122
1128
|
});
|
|
@@ -1125,11 +1131,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1125
1131
|
admit: async (request) => {
|
|
1126
1132
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1127
1133
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
|
|
1128
|
-
id: traceId
|
|
1129
|
-
parentId: this._traceParent
|
|
1134
|
+
id: traceId
|
|
1130
1135
|
}), {
|
|
1131
1136
|
file: "invitation-extension.ts",
|
|
1132
|
-
line:
|
|
1137
|
+
line: 92,
|
|
1133
1138
|
scope: this,
|
|
1134
1139
|
callSite: (f, a) => f(...a)
|
|
1135
1140
|
});
|
|
@@ -1138,7 +1143,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1138
1143
|
id: traceId
|
|
1139
1144
|
}), {
|
|
1140
1145
|
file: "invitation-extension.ts",
|
|
1141
|
-
line:
|
|
1146
|
+
line: 94,
|
|
1142
1147
|
scope: this,
|
|
1143
1148
|
callSite: (f, a) => f(...a)
|
|
1144
1149
|
});
|
|
@@ -1184,7 +1189,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1184
1189
|
});
|
|
1185
1190
|
this._callbacks = _callbacks;
|
|
1186
1191
|
this._ctx = new import_context3.Context();
|
|
1187
|
-
this._remoteOptionsTrigger = new
|
|
1192
|
+
this._remoteOptionsTrigger = new import_async8.Trigger();
|
|
1188
1193
|
}
|
|
1189
1194
|
async getHandlers() {
|
|
1190
1195
|
return {
|
|
@@ -1212,7 +1217,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1212
1217
|
try {
|
|
1213
1218
|
(0, import_log4.log)("begin options", {}, {
|
|
1214
1219
|
file: "invitation-extension.ts",
|
|
1215
|
-
line:
|
|
1220
|
+
line: 178,
|
|
1216
1221
|
scope: this,
|
|
1217
1222
|
callSite: (f, a) => f(...a)
|
|
1218
1223
|
});
|
|
@@ -1224,7 +1229,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1224
1229
|
}));
|
|
1225
1230
|
(0, import_log4.log)("end options", {}, {
|
|
1226
1231
|
file: "invitation-extension.ts",
|
|
1227
|
-
line:
|
|
1232
|
+
line: 181,
|
|
1228
1233
|
scope: this,
|
|
1229
1234
|
callSite: (f, a) => f(...a)
|
|
1230
1235
|
});
|
|
@@ -1238,7 +1243,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1238
1243
|
} catch (err) {
|
|
1239
1244
|
(0, import_log4.log)("openError", err, {
|
|
1240
1245
|
file: "invitation-extension.ts",
|
|
1241
|
-
line:
|
|
1246
|
+
line: 191,
|
|
1242
1247
|
scope: this,
|
|
1243
1248
|
callSite: (f, a) => f(...a)
|
|
1244
1249
|
});
|
|
@@ -1248,7 +1253,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1248
1253
|
async onClose() {
|
|
1249
1254
|
(0, import_log4.log)("onClose", {}, {
|
|
1250
1255
|
file: "invitation-extension.ts",
|
|
1251
|
-
line:
|
|
1256
|
+
line: 197,
|
|
1252
1257
|
scope: this,
|
|
1253
1258
|
callSite: (f, a) => f(...a)
|
|
1254
1259
|
});
|
|
@@ -1259,13 +1264,16 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1259
1264
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1260
1265
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1261
1266
|
var InvitationsHandler = class {
|
|
1267
|
+
/**
|
|
1268
|
+
* @internal
|
|
1269
|
+
*/
|
|
1262
1270
|
constructor(_networkManager) {
|
|
1263
1271
|
this._networkManager = _networkManager;
|
|
1264
1272
|
}
|
|
1265
1273
|
createInvitation(protocol, options) {
|
|
1266
1274
|
var _a;
|
|
1267
|
-
const { invitationId = import_keys7.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout =
|
|
1268
|
-
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials8.generatePasscode)(
|
|
1275
|
+
const { invitationId = import_keys7.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol.INVITATION_TIMEOUT, swarmKey = import_keys7.PublicKey.random() } = options != null ? options : {};
|
|
1276
|
+
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials8.generatePasscode)(import_client_protocol.AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1269
1277
|
(0, import_node_assert6.default)(protocol);
|
|
1270
1278
|
const invitation = {
|
|
1271
1279
|
invitationId,
|
|
@@ -1277,7 +1285,7 @@ var InvitationsHandler = class {
|
|
|
1277
1285
|
timeout,
|
|
1278
1286
|
...protocol.getInvitationContext()
|
|
1279
1287
|
};
|
|
1280
|
-
const stream = new
|
|
1288
|
+
const stream = new import_async9.PushStream();
|
|
1281
1289
|
const ctx = new import_context4.Context({
|
|
1282
1290
|
onError: (err) => {
|
|
1283
1291
|
void ctx.dispose();
|
|
@@ -1289,14 +1297,14 @@ var InvitationsHandler = class {
|
|
|
1289
1297
|
...protocol.toJSON()
|
|
1290
1298
|
}, {
|
|
1291
1299
|
file: "invitations-handler.ts",
|
|
1292
|
-
line:
|
|
1300
|
+
line: 98,
|
|
1293
1301
|
scope: this,
|
|
1294
1302
|
callSite: (f, a) => f(...a)
|
|
1295
1303
|
});
|
|
1296
1304
|
stream.complete();
|
|
1297
1305
|
});
|
|
1298
1306
|
const createExtension = () => {
|
|
1299
|
-
const success = new
|
|
1307
|
+
const success = new import_async9.Trigger();
|
|
1300
1308
|
let guestProfile;
|
|
1301
1309
|
let authenticationPassed = false;
|
|
1302
1310
|
let authenticationRetry = 0;
|
|
@@ -1307,7 +1315,7 @@ var InvitationsHandler = class {
|
|
|
1307
1315
|
...protocol.toJSON()
|
|
1308
1316
|
}, {
|
|
1309
1317
|
file: "invitations-handler.ts",
|
|
1310
|
-
line:
|
|
1318
|
+
line: 111,
|
|
1311
1319
|
scope: this,
|
|
1312
1320
|
callSite: (f, a) => f(...a)
|
|
1313
1321
|
});
|
|
@@ -1326,7 +1334,7 @@ var InvitationsHandler = class {
|
|
|
1326
1334
|
authCode: code
|
|
1327
1335
|
}, {
|
|
1328
1336
|
file: "invitations-handler.ts",
|
|
1329
|
-
line:
|
|
1337
|
+
line: 130,
|
|
1330
1338
|
scope: this,
|
|
1331
1339
|
callSite: (f, a) => f(...a)
|
|
1332
1340
|
});
|
|
@@ -1335,7 +1343,7 @@ var InvitationsHandler = class {
|
|
|
1335
1343
|
case import_services3.Invitation.AuthMethod.NONE: {
|
|
1336
1344
|
(0, import_log5.log)("authentication not required", {}, {
|
|
1337
1345
|
file: "invitations-handler.ts",
|
|
1338
|
-
line:
|
|
1346
|
+
line: 135,
|
|
1339
1347
|
scope: this,
|
|
1340
1348
|
callSite: (f, a) => f(...a)
|
|
1341
1349
|
});
|
|
@@ -1360,7 +1368,7 @@ var InvitationsHandler = class {
|
|
|
1360
1368
|
authMethod: invitation.authMethod
|
|
1361
1369
|
}, {
|
|
1362
1370
|
file: "invitations-handler.ts",
|
|
1363
|
-
line:
|
|
1371
|
+
line: 153,
|
|
1364
1372
|
scope: this,
|
|
1365
1373
|
callSite: (f, a) => f(...a)
|
|
1366
1374
|
});
|
|
@@ -1389,15 +1397,14 @@ var InvitationsHandler = class {
|
|
|
1389
1397
|
}
|
|
1390
1398
|
},
|
|
1391
1399
|
onOpen: () => {
|
|
1392
|
-
(0,
|
|
1400
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
1393
1401
|
const traceId = import_keys7.PublicKey.random().toHex();
|
|
1394
1402
|
try {
|
|
1395
1403
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
|
|
1396
|
-
id: traceId
|
|
1397
|
-
parentId: this._traceParent
|
|
1404
|
+
id: traceId
|
|
1398
1405
|
}), {
|
|
1399
1406
|
file: "invitations-handler.ts",
|
|
1400
|
-
line:
|
|
1407
|
+
line: 188,
|
|
1401
1408
|
scope: this,
|
|
1402
1409
|
callSite: (f, a) => f(...a)
|
|
1403
1410
|
});
|
|
@@ -1405,7 +1412,7 @@ var InvitationsHandler = class {
|
|
|
1405
1412
|
...protocol.toJSON()
|
|
1406
1413
|
}, {
|
|
1407
1414
|
file: "invitations-handler.ts",
|
|
1408
|
-
line:
|
|
1415
|
+
line: 189,
|
|
1409
1416
|
scope: this,
|
|
1410
1417
|
callSite: (f, a) => f(...a)
|
|
1411
1418
|
});
|
|
@@ -1421,7 +1428,7 @@ var InvitationsHandler = class {
|
|
|
1421
1428
|
...protocol.toJSON()
|
|
1422
1429
|
}, {
|
|
1423
1430
|
file: "invitations-handler.ts",
|
|
1424
|
-
line:
|
|
1431
|
+
line: 192,
|
|
1425
1432
|
scope: this,
|
|
1426
1433
|
callSite: (f, a) => f(...a)
|
|
1427
1434
|
});
|
|
@@ -1433,17 +1440,17 @@ var InvitationsHandler = class {
|
|
|
1433
1440
|
id: traceId
|
|
1434
1441
|
}), {
|
|
1435
1442
|
file: "invitations-handler.ts",
|
|
1436
|
-
line:
|
|
1443
|
+
line: 194,
|
|
1437
1444
|
scope: this,
|
|
1438
1445
|
callSite: (f, a) => f(...a)
|
|
1439
1446
|
});
|
|
1440
1447
|
} catch (err) {
|
|
1441
|
-
if (err instanceof
|
|
1448
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
1442
1449
|
(0, import_log5.log)("timeout", {
|
|
1443
1450
|
...protocol.toJSON()
|
|
1444
1451
|
}, {
|
|
1445
1452
|
file: "invitations-handler.ts",
|
|
1446
|
-
line:
|
|
1453
|
+
line: 197,
|
|
1447
1454
|
scope: this,
|
|
1448
1455
|
callSite: (f, a) => f(...a)
|
|
1449
1456
|
});
|
|
@@ -1454,7 +1461,7 @@ var InvitationsHandler = class {
|
|
|
1454
1461
|
} else {
|
|
1455
1462
|
import_log5.log.error("failed", err, {
|
|
1456
1463
|
file: "invitations-handler.ts",
|
|
1457
|
-
line:
|
|
1464
|
+
line: 200,
|
|
1458
1465
|
scope: this,
|
|
1459
1466
|
callSite: (f, a) => f(...a)
|
|
1460
1467
|
});
|
|
@@ -1465,13 +1472,13 @@ var InvitationsHandler = class {
|
|
|
1465
1472
|
error: err
|
|
1466
1473
|
}), {
|
|
1467
1474
|
file: "invitations-handler.ts",
|
|
1468
|
-
line:
|
|
1475
|
+
line: 203,
|
|
1469
1476
|
scope: this,
|
|
1470
1477
|
callSite: (f, a) => f(...a)
|
|
1471
1478
|
});
|
|
1472
1479
|
} finally {
|
|
1473
1480
|
if (type !== import_services3.Invitation.Type.MULTIUSE) {
|
|
1474
|
-
await (0,
|
|
1481
|
+
await (0, import_async9.sleep)(import_client_protocol.ON_CLOSE_DELAY);
|
|
1475
1482
|
await ctx.dispose();
|
|
1476
1483
|
}
|
|
1477
1484
|
}
|
|
@@ -1481,12 +1488,12 @@ var InvitationsHandler = class {
|
|
|
1481
1488
|
if (err instanceof import_errors2.InvalidInvitationExtensionRoleError) {
|
|
1482
1489
|
return;
|
|
1483
1490
|
}
|
|
1484
|
-
if (err instanceof
|
|
1491
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
1485
1492
|
(0, import_log5.log)("timeout", {
|
|
1486
1493
|
...protocol.toJSON()
|
|
1487
1494
|
}, {
|
|
1488
1495
|
file: "invitations-handler.ts",
|
|
1489
|
-
line:
|
|
1496
|
+
line: 217,
|
|
1490
1497
|
scope: this,
|
|
1491
1498
|
callSite: (f, a) => f(...a)
|
|
1492
1499
|
});
|
|
@@ -1497,7 +1504,7 @@ var InvitationsHandler = class {
|
|
|
1497
1504
|
} else {
|
|
1498
1505
|
import_log5.log.error("failed", err, {
|
|
1499
1506
|
file: "invitations-handler.ts",
|
|
1500
|
-
line:
|
|
1507
|
+
line: 220,
|
|
1501
1508
|
scope: this,
|
|
1502
1509
|
callSite: (f, a) => f(...a)
|
|
1503
1510
|
});
|
|
@@ -1505,10 +1512,9 @@ var InvitationsHandler = class {
|
|
|
1505
1512
|
}
|
|
1506
1513
|
}
|
|
1507
1514
|
});
|
|
1508
|
-
extension._traceParent = this._traceParent;
|
|
1509
1515
|
return extension;
|
|
1510
1516
|
};
|
|
1511
|
-
(0,
|
|
1517
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
1512
1518
|
const topic = invitation.swarmKey;
|
|
1513
1519
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1514
1520
|
topic,
|
|
@@ -1524,7 +1530,7 @@ var InvitationsHandler = class {
|
|
|
1524
1530
|
state: import_services3.Invitation.State.CONNECTING
|
|
1525
1531
|
});
|
|
1526
1532
|
});
|
|
1527
|
-
const observable = new
|
|
1533
|
+
const observable = new import_client_protocol.CancellableInvitationObservable({
|
|
1528
1534
|
initialInvitation: invitation,
|
|
1529
1535
|
subscriber: stream.observable,
|
|
1530
1536
|
onCancel: async () => {
|
|
@@ -1538,11 +1544,11 @@ var InvitationsHandler = class {
|
|
|
1538
1544
|
return observable;
|
|
1539
1545
|
}
|
|
1540
1546
|
acceptInvitation(protocol, invitation) {
|
|
1541
|
-
const { timeout =
|
|
1547
|
+
const { timeout = import_client_protocol.INVITATION_TIMEOUT } = invitation;
|
|
1542
1548
|
(0, import_node_assert6.default)(protocol);
|
|
1543
|
-
const authenticated = new
|
|
1549
|
+
const authenticated = new import_async9.Trigger();
|
|
1544
1550
|
let currentState;
|
|
1545
|
-
const stream = new
|
|
1551
|
+
const stream = new import_async9.PushStream();
|
|
1546
1552
|
const setState = (newData) => {
|
|
1547
1553
|
(0, import_node_assert6.default)(newData.state !== void 0);
|
|
1548
1554
|
currentState = newData.state;
|
|
@@ -1553,12 +1559,12 @@ var InvitationsHandler = class {
|
|
|
1553
1559
|
};
|
|
1554
1560
|
const ctx = new import_context4.Context({
|
|
1555
1561
|
onError: (err) => {
|
|
1556
|
-
if (err instanceof
|
|
1562
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
1557
1563
|
(0, import_log5.log)("timeout", {
|
|
1558
1564
|
...protocol.toJSON()
|
|
1559
1565
|
}, {
|
|
1560
1566
|
file: "invitations-handler.ts",
|
|
1561
|
-
line:
|
|
1567
|
+
line: 274,
|
|
1562
1568
|
scope: this,
|
|
1563
1569
|
callSite: (f, a) => f(...a)
|
|
1564
1570
|
});
|
|
@@ -1568,7 +1574,7 @@ var InvitationsHandler = class {
|
|
|
1568
1574
|
} else {
|
|
1569
1575
|
import_log5.log.warn("auth failed", err, {
|
|
1570
1576
|
file: "invitations-handler.ts",
|
|
1571
|
-
line:
|
|
1577
|
+
line: 277,
|
|
1572
1578
|
scope: this,
|
|
1573
1579
|
callSite: (f, a) => f(...a)
|
|
1574
1580
|
});
|
|
@@ -1582,7 +1588,7 @@ var InvitationsHandler = class {
|
|
|
1582
1588
|
...protocol.toJSON()
|
|
1583
1589
|
}, {
|
|
1584
1590
|
file: "invitations-handler.ts",
|
|
1585
|
-
line:
|
|
1591
|
+
line: 285,
|
|
1586
1592
|
scope: this,
|
|
1587
1593
|
callSite: (f, a) => f(...a)
|
|
1588
1594
|
});
|
|
@@ -1597,7 +1603,7 @@ var InvitationsHandler = class {
|
|
|
1597
1603
|
currentState
|
|
1598
1604
|
}, {
|
|
1599
1605
|
file: "invitations-handler.ts",
|
|
1600
|
-
line:
|
|
1606
|
+
line: 295,
|
|
1601
1607
|
scope: this,
|
|
1602
1608
|
callSite: (f, a) => f(...a)
|
|
1603
1609
|
});
|
|
@@ -1605,27 +1611,26 @@ var InvitationsHandler = class {
|
|
|
1605
1611
|
stream.error(new Error("Remote peer disconnected."));
|
|
1606
1612
|
}
|
|
1607
1613
|
});
|
|
1608
|
-
(0,
|
|
1614
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
1609
1615
|
const traceId = import_keys7.PublicKey.random().toHex();
|
|
1610
1616
|
try {
|
|
1611
1617
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
|
|
1612
|
-
id: traceId
|
|
1613
|
-
parentId: this._traceParent
|
|
1618
|
+
id: traceId
|
|
1614
1619
|
}), {
|
|
1615
1620
|
file: "invitations-handler.ts",
|
|
1616
|
-
line:
|
|
1621
|
+
line: 304,
|
|
1617
1622
|
scope: this,
|
|
1618
1623
|
callSite: (f, a) => f(...a)
|
|
1619
1624
|
});
|
|
1620
1625
|
if (++connectionCount > 1) {
|
|
1621
1626
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
1622
1627
|
}
|
|
1623
|
-
(0,
|
|
1628
|
+
(0, import_async9.scheduleTask)(ctx, () => ctx.raise(new import_async9.TimeoutError(timeout)), timeout);
|
|
1624
1629
|
(0, import_log5.log)("connected", {
|
|
1625
1630
|
...protocol.toJSON()
|
|
1626
1631
|
}, {
|
|
1627
1632
|
file: "invitations-handler.ts",
|
|
1628
|
-
line:
|
|
1633
|
+
line: 312,
|
|
1629
1634
|
scope: this,
|
|
1630
1635
|
callSite: (f, a) => f(...a)
|
|
1631
1636
|
});
|
|
@@ -1636,7 +1641,7 @@ var InvitationsHandler = class {
|
|
|
1636
1641
|
...protocol.toJSON()
|
|
1637
1642
|
}, {
|
|
1638
1643
|
file: "invitations-handler.ts",
|
|
1639
|
-
line:
|
|
1644
|
+
line: 316,
|
|
1640
1645
|
scope: this,
|
|
1641
1646
|
callSite: (f, a) => f(...a)
|
|
1642
1647
|
});
|
|
@@ -1646,7 +1651,7 @@ var InvitationsHandler = class {
|
|
|
1646
1651
|
response: introductionResponse
|
|
1647
1652
|
}, {
|
|
1648
1653
|
file: "invitations-handler.ts",
|
|
1649
|
-
line:
|
|
1654
|
+
line: 320,
|
|
1650
1655
|
scope: this,
|
|
1651
1656
|
callSite: (f, a) => f(...a)
|
|
1652
1657
|
});
|
|
@@ -1658,7 +1663,7 @@ var InvitationsHandler = class {
|
|
|
1658
1663
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1659
1664
|
(0, import_log5.log)("guest waiting for authentication code...", {}, {
|
|
1660
1665
|
file: "invitations-handler.ts",
|
|
1661
|
-
line:
|
|
1666
|
+
line: 329,
|
|
1662
1667
|
scope: this,
|
|
1663
1668
|
callSite: (f, a) => f(...a)
|
|
1664
1669
|
});
|
|
@@ -1670,7 +1675,7 @@ var InvitationsHandler = class {
|
|
|
1670
1675
|
});
|
|
1671
1676
|
(0, import_log5.log)("sending authentication request", {}, {
|
|
1672
1677
|
file: "invitations-handler.ts",
|
|
1673
|
-
line:
|
|
1678
|
+
line: 333,
|
|
1674
1679
|
scope: this,
|
|
1675
1680
|
callSite: (f, a) => f(...a)
|
|
1676
1681
|
});
|
|
@@ -1691,7 +1696,7 @@ var InvitationsHandler = class {
|
|
|
1691
1696
|
attempt
|
|
1692
1697
|
}, {
|
|
1693
1698
|
file: "invitations-handler.ts",
|
|
1694
|
-
line:
|
|
1699
|
+
line: 344,
|
|
1695
1700
|
scope: this,
|
|
1696
1701
|
callSite: (f, a) => f(...a)
|
|
1697
1702
|
});
|
|
@@ -1708,7 +1713,7 @@ var InvitationsHandler = class {
|
|
|
1708
1713
|
...protocol.toJSON()
|
|
1709
1714
|
}, {
|
|
1710
1715
|
file: "invitations-handler.ts",
|
|
1711
|
-
line:
|
|
1716
|
+
line: 355,
|
|
1712
1717
|
scope: this,
|
|
1713
1718
|
callSite: (f, a) => f(...a)
|
|
1714
1719
|
});
|
|
@@ -1719,7 +1724,7 @@ var InvitationsHandler = class {
|
|
|
1719
1724
|
...protocol.toJSON()
|
|
1720
1725
|
}, {
|
|
1721
1726
|
file: "invitations-handler.ts",
|
|
1722
|
-
line:
|
|
1727
|
+
line: 363,
|
|
1723
1728
|
scope: this,
|
|
1724
1729
|
callSite: (f, a) => f(...a)
|
|
1725
1730
|
});
|
|
@@ -1731,17 +1736,17 @@ var InvitationsHandler = class {
|
|
|
1731
1736
|
id: traceId
|
|
1732
1737
|
}), {
|
|
1733
1738
|
file: "invitations-handler.ts",
|
|
1734
|
-
line:
|
|
1739
|
+
line: 365,
|
|
1735
1740
|
scope: this,
|
|
1736
1741
|
callSite: (f, a) => f(...a)
|
|
1737
1742
|
});
|
|
1738
1743
|
} catch (err) {
|
|
1739
|
-
if (err instanceof
|
|
1744
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
1740
1745
|
(0, import_log5.log)("timeout", {
|
|
1741
1746
|
...protocol.toJSON()
|
|
1742
1747
|
}, {
|
|
1743
1748
|
file: "invitations-handler.ts",
|
|
1744
|
-
line:
|
|
1749
|
+
line: 368,
|
|
1745
1750
|
scope: this,
|
|
1746
1751
|
callSite: (f, a) => f(...a)
|
|
1747
1752
|
});
|
|
@@ -1751,7 +1756,7 @@ var InvitationsHandler = class {
|
|
|
1751
1756
|
} else {
|
|
1752
1757
|
(0, import_log5.log)("auth failed", err, {
|
|
1753
1758
|
file: "invitations-handler.ts",
|
|
1754
|
-
line:
|
|
1759
|
+
line: 371,
|
|
1755
1760
|
scope: this,
|
|
1756
1761
|
callSite: (f, a) => f(...a)
|
|
1757
1762
|
});
|
|
@@ -1762,7 +1767,7 @@ var InvitationsHandler = class {
|
|
|
1762
1767
|
error: err
|
|
1763
1768
|
}), {
|
|
1764
1769
|
file: "invitations-handler.ts",
|
|
1765
|
-
line:
|
|
1770
|
+
line: 374,
|
|
1766
1771
|
scope: this,
|
|
1767
1772
|
callSite: (f, a) => f(...a)
|
|
1768
1773
|
});
|
|
@@ -1775,12 +1780,12 @@ var InvitationsHandler = class {
|
|
|
1775
1780
|
if (err instanceof import_errors2.InvalidInvitationExtensionRoleError) {
|
|
1776
1781
|
return;
|
|
1777
1782
|
}
|
|
1778
|
-
if (err instanceof
|
|
1783
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
1779
1784
|
(0, import_log5.log)("timeout", {
|
|
1780
1785
|
...protocol.toJSON()
|
|
1781
1786
|
}, {
|
|
1782
1787
|
file: "invitations-handler.ts",
|
|
1783
|
-
line:
|
|
1788
|
+
line: 385,
|
|
1784
1789
|
scope: this,
|
|
1785
1790
|
callSite: (f, a) => f(...a)
|
|
1786
1791
|
});
|
|
@@ -1790,7 +1795,7 @@ var InvitationsHandler = class {
|
|
|
1790
1795
|
} else {
|
|
1791
1796
|
(0, import_log5.log)("auth failed", err, {
|
|
1792
1797
|
file: "invitations-handler.ts",
|
|
1793
|
-
line:
|
|
1798
|
+
line: 388,
|
|
1794
1799
|
scope: this,
|
|
1795
1800
|
callSite: (f, a) => f(...a)
|
|
1796
1801
|
});
|
|
@@ -1800,7 +1805,7 @@ var InvitationsHandler = class {
|
|
|
1800
1805
|
});
|
|
1801
1806
|
return extension;
|
|
1802
1807
|
};
|
|
1803
|
-
(0,
|
|
1808
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
1804
1809
|
(0, import_node_assert6.default)(invitation.swarmKey);
|
|
1805
1810
|
const topic = invitation.swarmKey;
|
|
1806
1811
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
@@ -1816,7 +1821,7 @@ var InvitationsHandler = class {
|
|
|
1816
1821
|
state: import_services3.Invitation.State.CONNECTING
|
|
1817
1822
|
});
|
|
1818
1823
|
});
|
|
1819
|
-
const observable = new
|
|
1824
|
+
const observable = new import_client_protocol.AuthenticatingInvitationObservable({
|
|
1820
1825
|
initialInvitation: invitation,
|
|
1821
1826
|
subscriber: stream.observable,
|
|
1822
1827
|
onCancel: async () => {
|
|
@@ -1836,7 +1841,7 @@ var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_
|
|
|
1836
1841
|
|
|
1837
1842
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1838
1843
|
var import_node_assert7 = __toESM(require("node:assert"));
|
|
1839
|
-
var
|
|
1844
|
+
var import_async10 = require("@dxos/async");
|
|
1840
1845
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
1841
1846
|
var import_log6 = require("@dxos/log");
|
|
1842
1847
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -1846,10 +1851,10 @@ var InvitationsServiceImpl = class {
|
|
|
1846
1851
|
this._getHandler = _getHandler;
|
|
1847
1852
|
this._createInvitations = /* @__PURE__ */ new Map();
|
|
1848
1853
|
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
1849
|
-
this._invitationCreated = new
|
|
1850
|
-
this._invitationAccepted = new
|
|
1851
|
-
this._removedCreated = new
|
|
1852
|
-
this._removedAccepted = new
|
|
1854
|
+
this._invitationCreated = new import_async10.Event();
|
|
1855
|
+
this._invitationAccepted = new import_async10.Event();
|
|
1856
|
+
this._removedCreated = new import_async10.Event();
|
|
1857
|
+
this._removedAccepted = new import_async10.Event();
|
|
1853
1858
|
}
|
|
1854
1859
|
// TODO(burdon): Guest/host label.
|
|
1855
1860
|
getLoggingContext() {
|
|
@@ -2039,7 +2044,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2039
2044
|
guest: deviceKey
|
|
2040
2045
|
}, {
|
|
2041
2046
|
file: "space-invitation-protocol.ts",
|
|
2042
|
-
line:
|
|
2047
|
+
line: 50,
|
|
2043
2048
|
scope: this,
|
|
2044
2049
|
callSite: (f, a) => f(...a)
|
|
2045
2050
|
});
|
|
@@ -2093,12 +2098,12 @@ var SpaceInvitationProtocol = class {
|
|
|
2093
2098
|
};
|
|
2094
2099
|
|
|
2095
2100
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
2096
|
-
var
|
|
2101
|
+
var import_async11 = require("@dxos/async");
|
|
2097
2102
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
2098
2103
|
var import_log8 = require("@dxos/log");
|
|
2099
2104
|
var LoggingServiceImpl = class {
|
|
2100
2105
|
constructor() {
|
|
2101
|
-
this._logs = new
|
|
2106
|
+
this._logs = new import_async11.Event();
|
|
2102
2107
|
this._logProcessor = (_config, entry2) => {
|
|
2103
2108
|
this._logs.emit(entry2);
|
|
2104
2109
|
};
|
|
@@ -2130,19 +2135,23 @@ var LoggingServiceImpl = class {
|
|
|
2130
2135
|
});
|
|
2131
2136
|
}
|
|
2132
2137
|
};
|
|
2133
|
-
var jsonify = (value) => {
|
|
2138
|
+
var jsonify = (value, handles = /* @__PURE__ */ new WeakSet()) => {
|
|
2134
2139
|
if (typeof value === "function") {
|
|
2135
2140
|
return null;
|
|
2136
2141
|
} else if (typeof value === "object" && value !== null) {
|
|
2142
|
+
if (handles.has(value)) {
|
|
2143
|
+
return null;
|
|
2144
|
+
}
|
|
2145
|
+
handles.add(value);
|
|
2137
2146
|
if (Array.isArray(value)) {
|
|
2138
|
-
return value.map(jsonify);
|
|
2147
|
+
return value.map((x) => jsonify(x, handles));
|
|
2139
2148
|
} else {
|
|
2140
2149
|
if (typeof value.toJSON === "function") {
|
|
2141
2150
|
return value.toJSON();
|
|
2142
2151
|
}
|
|
2143
2152
|
const res = {};
|
|
2144
2153
|
for (const key of Object.keys(value)) {
|
|
2145
|
-
res[key] = jsonify(value[key]);
|
|
2154
|
+
res[key] = jsonify(value[key], handles);
|
|
2146
2155
|
}
|
|
2147
2156
|
return res;
|
|
2148
2157
|
}
|
|
@@ -2154,53 +2163,62 @@ var jsonify = (value) => {
|
|
|
2154
2163
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
2155
2164
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2156
2165
|
var NetworkServiceImpl = class {
|
|
2157
|
-
constructor(networkManager) {
|
|
2166
|
+
constructor(networkManager, signalManager) {
|
|
2158
2167
|
this.networkManager = networkManager;
|
|
2168
|
+
this.signalManager = signalManager;
|
|
2159
2169
|
}
|
|
2160
|
-
|
|
2170
|
+
queryStatus() {
|
|
2161
2171
|
return new import_codec_protobuf10.Stream(({ next }) => {
|
|
2162
|
-
const
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2172
|
+
const update = () => {
|
|
2173
|
+
next({
|
|
2174
|
+
swarm: this.networkManager.connectionState,
|
|
2175
|
+
signaling: this.signalManager.getStatus().map(({ host, state }) => ({
|
|
2176
|
+
server: host,
|
|
2177
|
+
state
|
|
2178
|
+
}))
|
|
2179
|
+
});
|
|
2180
|
+
};
|
|
2181
|
+
const unsubscribeSwarm = this.networkManager.connectionStateChanged.on(() => update());
|
|
2182
|
+
const unsubscribeSignal = this.signalManager.statusChanged.on(() => update());
|
|
2183
|
+
update();
|
|
2184
|
+
return () => {
|
|
2185
|
+
unsubscribeSwarm();
|
|
2186
|
+
unsubscribeSignal();
|
|
2187
|
+
};
|
|
2169
2188
|
});
|
|
2170
2189
|
}
|
|
2171
|
-
async
|
|
2172
|
-
await this.networkManager.setConnectionState(request.
|
|
2190
|
+
async updateConfig(request) {
|
|
2191
|
+
await this.networkManager.setConnectionState(request.swarm);
|
|
2173
2192
|
}
|
|
2174
2193
|
};
|
|
2175
2194
|
|
|
2176
2195
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2177
2196
|
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2178
|
-
var
|
|
2179
|
-
var import_client3 = require("@dxos/client");
|
|
2197
|
+
var import_async14 = require("@dxos/async");
|
|
2180
2198
|
var import_context7 = require("@dxos/context");
|
|
2181
|
-
var
|
|
2182
|
-
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
2199
|
+
var import_credentials13 = require("@dxos/credentials");
|
|
2183
2200
|
var import_keys10 = require("@dxos/keys");
|
|
2184
2201
|
var import_log11 = require("@dxos/log");
|
|
2185
2202
|
var import_protocols6 = require("@dxos/protocols");
|
|
2203
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2186
2204
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
2187
2205
|
var import_util5 = require("@dxos/util");
|
|
2188
2206
|
|
|
2189
2207
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2190
|
-
var
|
|
2191
|
-
var import_client2 = require("@dxos/client");
|
|
2208
|
+
var import_async13 = require("@dxos/async");
|
|
2192
2209
|
var import_context6 = require("@dxos/context");
|
|
2193
2210
|
var import_debug3 = require("@dxos/debug");
|
|
2194
2211
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
2195
2212
|
var import_errors3 = require("@dxos/errors");
|
|
2196
2213
|
var import_keys9 = require("@dxos/keys");
|
|
2197
2214
|
var import_log10 = require("@dxos/log");
|
|
2215
|
+
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2198
2216
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2199
2217
|
var import_util4 = require("@dxos/util");
|
|
2200
2218
|
|
|
2201
2219
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2202
2220
|
var import_node_assert9 = __toESM(require("node:assert"));
|
|
2203
|
-
var
|
|
2221
|
+
var import_async12 = require("@dxos/async");
|
|
2204
2222
|
var import_context5 = require("@dxos/context");
|
|
2205
2223
|
var import_keys8 = require("@dxos/keys");
|
|
2206
2224
|
var import_log9 = require("@dxos/log");
|
|
@@ -2213,7 +2231,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2213
2231
|
var NotarizationPlugin = class {
|
|
2214
2232
|
constructor() {
|
|
2215
2233
|
this._ctx = new import_context5.Context();
|
|
2216
|
-
this._extensionOpened = new
|
|
2234
|
+
this._extensionOpened = new import_async12.Event();
|
|
2217
2235
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2218
2236
|
this._processedCredentials = new import_util3.ComplexSet(import_keys8.PublicKey.hash);
|
|
2219
2237
|
this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys8.PublicKey.hash);
|
|
@@ -2236,7 +2254,7 @@ var NotarizationPlugin = class {
|
|
|
2236
2254
|
callSite: (f, a) => f(...a)
|
|
2237
2255
|
});
|
|
2238
2256
|
(0, import_node_assert9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2239
|
-
const errors = new
|
|
2257
|
+
const errors = new import_async12.Trigger();
|
|
2240
2258
|
const ctx = this._ctx.derive({
|
|
2241
2259
|
onError: (err) => {
|
|
2242
2260
|
import_log9.log.warn("Notarization error", {
|
|
@@ -2253,7 +2271,7 @@ var NotarizationPlugin = class {
|
|
|
2253
2271
|
});
|
|
2254
2272
|
opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
|
|
2255
2273
|
if (timeout !== 0) {
|
|
2256
|
-
(0,
|
|
2274
|
+
(0, import_async12.scheduleTask)(ctx, () => {
|
|
2257
2275
|
import_log9.log.warn("Notarization timeout", {
|
|
2258
2276
|
timeout,
|
|
2259
2277
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
@@ -2264,12 +2282,12 @@ var NotarizationPlugin = class {
|
|
|
2264
2282
|
callSite: (f, a) => f(...a)
|
|
2265
2283
|
});
|
|
2266
2284
|
void ctx.dispose();
|
|
2267
|
-
errors.throw(new
|
|
2285
|
+
errors.throw(new import_async12.TimeoutError(timeout, "Notarization timed out"));
|
|
2268
2286
|
}, timeout);
|
|
2269
2287
|
}
|
|
2270
2288
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
2271
2289
|
const peersTried = /* @__PURE__ */ new Set();
|
|
2272
|
-
const notarizeTask = new
|
|
2290
|
+
const notarizeTask = new import_async12.DeferredTask(ctx, async () => {
|
|
2273
2291
|
try {
|
|
2274
2292
|
if (this._extensions.size === 0) {
|
|
2275
2293
|
return;
|
|
@@ -2287,7 +2305,7 @@ var NotarizationPlugin = class {
|
|
|
2287
2305
|
callSite: (f, a) => f(...a)
|
|
2288
2306
|
});
|
|
2289
2307
|
peersTried.clear();
|
|
2290
|
-
(0,
|
|
2308
|
+
(0, import_async12.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
2291
2309
|
return;
|
|
2292
2310
|
}
|
|
2293
2311
|
peersTried.add(peer);
|
|
@@ -2309,7 +2327,7 @@ var NotarizationPlugin = class {
|
|
|
2309
2327
|
scope: this,
|
|
2310
2328
|
callSite: (f, a) => f(...a)
|
|
2311
2329
|
});
|
|
2312
|
-
await (0,
|
|
2330
|
+
await (0, import_async12.sleep)(successDelay);
|
|
2313
2331
|
} catch (err) {
|
|
2314
2332
|
import_log9.log.warn("error notarizing (recoverable)", err, {
|
|
2315
2333
|
file: "notarization-plugin.ts",
|
|
@@ -2358,7 +2376,7 @@ var NotarizationPlugin = class {
|
|
|
2358
2376
|
if (this._processedCredentials.has(id)) {
|
|
2359
2377
|
return;
|
|
2360
2378
|
}
|
|
2361
|
-
await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new
|
|
2379
|
+
await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new import_async12.Trigger()).value.wait();
|
|
2362
2380
|
}
|
|
2363
2381
|
/**
|
|
2364
2382
|
* Requests from other peers to notarize credentials.
|
|
@@ -2452,8 +2470,13 @@ var AUTH_TIMEOUT2 = 3e4;
|
|
|
2452
2470
|
var DataSpace = class DataSpace2 {
|
|
2453
2471
|
constructor(params) {
|
|
2454
2472
|
this._ctx = new import_context6.Context();
|
|
2455
|
-
this._state =
|
|
2456
|
-
|
|
2473
|
+
this._state = import_services6.SpaceState.CLOSED;
|
|
2474
|
+
/**
|
|
2475
|
+
* Error for _state === SpaceState.ERROR.
|
|
2476
|
+
*/
|
|
2477
|
+
this.error = void 0;
|
|
2478
|
+
this.stateUpdate = new import_async13.Event();
|
|
2479
|
+
this.metrics = {};
|
|
2457
2480
|
var _a;
|
|
2458
2481
|
this._inner = params.inner;
|
|
2459
2482
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
@@ -2464,21 +2487,13 @@ var DataSpace = class DataSpace2 {
|
|
|
2464
2487
|
this._metadataStore = params.metadataStore;
|
|
2465
2488
|
this._signingContext = params.signingContext;
|
|
2466
2489
|
this._callbacks = (_a = params.callbacks) != null ? _a : {};
|
|
2467
|
-
this._dataPipeline = new import_echo_pipeline.DataPipeline({
|
|
2468
|
-
modelFactory: params.modelFactory,
|
|
2469
|
-
metadataStore: params.metadataStore,
|
|
2470
|
-
snapshotManager: params.snapshotManager,
|
|
2471
|
-
memberKey: params.memberKey,
|
|
2472
|
-
spaceKey: this._inner.key,
|
|
2473
|
-
feedInfoProvider: (feedKey) => this._inner.spaceState.feeds.get(feedKey),
|
|
2474
|
-
snapshotId: params.snapshotId
|
|
2475
|
-
});
|
|
2476
2490
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2477
2491
|
trustedKeysProvider: () => new import_util4.ComplexSet(import_keys9.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2478
2492
|
update: this._inner.stateUpdate,
|
|
2479
2493
|
authTimeout: AUTH_TIMEOUT2
|
|
2480
2494
|
});
|
|
2481
2495
|
this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
|
|
2496
|
+
this._cache = params.cache;
|
|
2482
2497
|
}
|
|
2483
2498
|
get key() {
|
|
2484
2499
|
return this._inner.key;
|
|
@@ -2494,7 +2509,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2494
2509
|
return this._inner;
|
|
2495
2510
|
}
|
|
2496
2511
|
get dataPipeline() {
|
|
2497
|
-
return this.
|
|
2512
|
+
return this._inner.dataPipeline;
|
|
2498
2513
|
}
|
|
2499
2514
|
get presence() {
|
|
2500
2515
|
return this._presence;
|
|
@@ -2502,16 +2517,19 @@ var DataSpace = class DataSpace2 {
|
|
|
2502
2517
|
get notarizationPlugin() {
|
|
2503
2518
|
return this._notarizationPluginConsumer.processor;
|
|
2504
2519
|
}
|
|
2520
|
+
get cache() {
|
|
2521
|
+
return this._cache;
|
|
2522
|
+
}
|
|
2505
2523
|
async open() {
|
|
2506
2524
|
await this.notarizationPlugin.open();
|
|
2507
2525
|
await this._notarizationPluginConsumer.open();
|
|
2508
2526
|
await this._inner.open();
|
|
2509
|
-
this._state =
|
|
2527
|
+
this._state = import_services6.SpaceState.INACTIVE;
|
|
2528
|
+
this.metrics.open = new Date();
|
|
2510
2529
|
}
|
|
2511
2530
|
async close() {
|
|
2512
|
-
this._state =
|
|
2531
|
+
this._state = import_services6.SpaceState.CLOSED;
|
|
2513
2532
|
await this._ctx.dispose();
|
|
2514
|
-
await this._dataPipeline.close();
|
|
2515
2533
|
await this.authVerifier.close();
|
|
2516
2534
|
await this._inner.close();
|
|
2517
2535
|
await this._notarizationPluginConsumer.close();
|
|
@@ -2528,14 +2546,15 @@ var DataSpace = class DataSpace2 {
|
|
|
2528
2546
|
* Initialize the data pipeline in a separate task.
|
|
2529
2547
|
*/
|
|
2530
2548
|
initializeDataPipelineAsync() {
|
|
2531
|
-
(0,
|
|
2549
|
+
(0, import_async13.scheduleTask)(this._ctx, async () => {
|
|
2532
2550
|
try {
|
|
2551
|
+
this.metrics.pipelineInitBegin = new Date();
|
|
2533
2552
|
await this.initializeDataPipeline();
|
|
2534
2553
|
} catch (err) {
|
|
2535
2554
|
if (err instanceof import_errors3.CancelledError) {
|
|
2536
2555
|
(0, import_log10.log)("Data pipeline initialization cancelled", err, {
|
|
2537
2556
|
file: "data-space.ts",
|
|
2538
|
-
line:
|
|
2557
|
+
line: 173,
|
|
2539
2558
|
scope: this,
|
|
2540
2559
|
callSite: (f, a) => f(...a)
|
|
2541
2560
|
});
|
|
@@ -2543,27 +2562,33 @@ var DataSpace = class DataSpace2 {
|
|
|
2543
2562
|
}
|
|
2544
2563
|
import_log10.log.error("Error initializing data pipeline", err, {
|
|
2545
2564
|
file: "data-space.ts",
|
|
2546
|
-
line:
|
|
2565
|
+
line: 177,
|
|
2547
2566
|
scope: this,
|
|
2548
2567
|
callSite: (f, a) => f(...a)
|
|
2549
2568
|
});
|
|
2569
|
+
this._state = import_services6.SpaceState.ERROR;
|
|
2570
|
+
this.error = err;
|
|
2571
|
+
this.stateUpdate.emit();
|
|
2572
|
+
} finally {
|
|
2573
|
+
this.metrics.ready = new Date();
|
|
2550
2574
|
}
|
|
2551
2575
|
});
|
|
2552
2576
|
}
|
|
2553
2577
|
async initializeDataPipeline() {
|
|
2554
2578
|
var _a, _b, _c, _d;
|
|
2555
|
-
if (this._state !==
|
|
2579
|
+
if (this._state !== import_services6.SpaceState.INACTIVE) {
|
|
2556
2580
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2557
2581
|
}
|
|
2558
|
-
this._state =
|
|
2582
|
+
this._state = import_services6.SpaceState.INITIALIZING;
|
|
2559
2583
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2560
2584
|
ctx: this._ctx,
|
|
2561
2585
|
breakOnStall: false
|
|
2562
2586
|
});
|
|
2587
|
+
this.metrics.controlPipelineReady = new Date();
|
|
2563
2588
|
await this._createWritableFeeds();
|
|
2564
2589
|
(0, import_log10.log)("Writable feeds created", {}, {
|
|
2565
2590
|
file: "data-space.ts",
|
|
2566
|
-
line:
|
|
2591
|
+
line: 202,
|
|
2567
2592
|
scope: this,
|
|
2568
2593
|
callSite: (f, a) => f(...a)
|
|
2569
2594
|
});
|
|
@@ -2573,33 +2598,28 @@ var DataSpace = class DataSpace2 {
|
|
|
2573
2598
|
credential
|
|
2574
2599
|
}
|
|
2575
2600
|
}), this._inner.controlPipeline.writer));
|
|
2576
|
-
await this.
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
start
|
|
2580
|
-
});
|
|
2581
|
-
await pipeline.start();
|
|
2582
|
-
return pipeline;
|
|
2583
|
-
}
|
|
2584
|
-
});
|
|
2601
|
+
await this._inner.initializeDataPipeline();
|
|
2602
|
+
this.metrics.dataPipelineOpen = new Date();
|
|
2603
|
+
await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2585
2604
|
(0, import_log10.log)("waiting for data pipeline to reach target timeframe", {}, {
|
|
2586
2605
|
file: "data-space.ts",
|
|
2587
|
-
line:
|
|
2606
|
+
line: 221,
|
|
2588
2607
|
scope: this,
|
|
2589
2608
|
callSite: (f, a) => f(...a)
|
|
2590
2609
|
});
|
|
2591
|
-
await this.
|
|
2610
|
+
await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2592
2611
|
ctx: this._ctx,
|
|
2593
2612
|
breakOnStall: false
|
|
2594
2613
|
});
|
|
2614
|
+
this.metrics.dataPipelineReady = new Date();
|
|
2595
2615
|
(0, import_log10.log)("data pipeline ready", {}, {
|
|
2596
2616
|
file: "data-space.ts",
|
|
2597
|
-
line:
|
|
2617
|
+
line: 230,
|
|
2598
2618
|
scope: this,
|
|
2599
2619
|
callSite: (f, a) => f(...a)
|
|
2600
2620
|
});
|
|
2601
2621
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2602
|
-
this._state =
|
|
2622
|
+
this._state = import_services6.SpaceState.READY;
|
|
2603
2623
|
this.stateUpdate.emit();
|
|
2604
2624
|
await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
|
|
2605
2625
|
}
|
|
@@ -2646,14 +2666,105 @@ var DataSpace = class DataSpace2 {
|
|
|
2646
2666
|
}
|
|
2647
2667
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
2648
2668
|
}
|
|
2669
|
+
async createEpoch() {
|
|
2670
|
+
var _a, _b;
|
|
2671
|
+
const epoch = await this.dataPipeline.createEpoch();
|
|
2672
|
+
await this.inner.controlPipeline.writer.write({
|
|
2673
|
+
credential: {
|
|
2674
|
+
credential: await this._signingContext.credentialSigner.createCredential({
|
|
2675
|
+
subject: this.key,
|
|
2676
|
+
assertion: {
|
|
2677
|
+
"@type": "dxos.halo.credentials.Epoch",
|
|
2678
|
+
...epoch
|
|
2679
|
+
}
|
|
2680
|
+
})
|
|
2681
|
+
}
|
|
2682
|
+
});
|
|
2683
|
+
for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
|
|
2684
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
2685
|
+
if (indexBeforeEpoch) {
|
|
2686
|
+
await feed.clear(0, indexBeforeEpoch + 1);
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2649
2690
|
};
|
|
2650
2691
|
__decorate([
|
|
2651
2692
|
(0, import_debug3.timed)(1e4)
|
|
2652
2693
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2653
2694
|
DataSpace = __decorate([
|
|
2654
|
-
(0,
|
|
2695
|
+
(0, import_async13.trackLeaks)("open", "close")
|
|
2655
2696
|
], DataSpace);
|
|
2656
2697
|
|
|
2698
|
+
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
2699
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
2700
|
+
var import_debug4 = require("@dxos/debug");
|
|
2701
|
+
var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2702
|
+
var import_timeframe = require("@dxos/timeframe");
|
|
2703
|
+
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
2704
|
+
var _a, _b, _c, _d;
|
|
2705
|
+
const credentials = [
|
|
2706
|
+
await (0, import_credentials11.createCredential)({
|
|
2707
|
+
signer: keyring,
|
|
2708
|
+
issuer: space.key,
|
|
2709
|
+
subject: space.key,
|
|
2710
|
+
assertion: {
|
|
2711
|
+
"@type": "dxos.halo.credentials.SpaceGenesis",
|
|
2712
|
+
spaceKey: space.key
|
|
2713
|
+
}
|
|
2714
|
+
}),
|
|
2715
|
+
await (0, import_credentials11.createCredential)({
|
|
2716
|
+
signer: keyring,
|
|
2717
|
+
issuer: space.key,
|
|
2718
|
+
subject: signingContext.identityKey,
|
|
2719
|
+
assertion: {
|
|
2720
|
+
"@type": "dxos.halo.credentials.SpaceMember",
|
|
2721
|
+
spaceKey: space.key,
|
|
2722
|
+
role: import_credentials12.SpaceMember.Role.ADMIN,
|
|
2723
|
+
profile: signingContext.profile,
|
|
2724
|
+
genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0, import_debug4.failUndefined)()
|
|
2725
|
+
}
|
|
2726
|
+
}),
|
|
2727
|
+
await signingContext.credentialSigner.createCredential({
|
|
2728
|
+
subject: (_b = space.controlFeedKey) != null ? _b : (0, import_debug4.failUndefined)(),
|
|
2729
|
+
assertion: {
|
|
2730
|
+
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2731
|
+
spaceKey: space.key,
|
|
2732
|
+
identityKey: signingContext.identityKey,
|
|
2733
|
+
deviceKey: signingContext.deviceKey,
|
|
2734
|
+
designation: import_credentials12.AdmittedFeed.Designation.CONTROL
|
|
2735
|
+
}
|
|
2736
|
+
}),
|
|
2737
|
+
await signingContext.credentialSigner.createCredential({
|
|
2738
|
+
subject: (_c = space.dataFeedKey) != null ? _c : (0, import_debug4.failUndefined)(),
|
|
2739
|
+
assertion: {
|
|
2740
|
+
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2741
|
+
spaceKey: space.key,
|
|
2742
|
+
identityKey: signingContext.identityKey,
|
|
2743
|
+
deviceKey: signingContext.deviceKey,
|
|
2744
|
+
designation: import_credentials12.AdmittedFeed.Designation.DATA
|
|
2745
|
+
}
|
|
2746
|
+
}),
|
|
2747
|
+
await signingContext.credentialSigner.createCredential({
|
|
2748
|
+
subject: (_d = space.key) != null ? _d : (0, import_debug4.failUndefined)(),
|
|
2749
|
+
assertion: {
|
|
2750
|
+
"@type": "dxos.halo.credentials.Epoch",
|
|
2751
|
+
number: 0,
|
|
2752
|
+
previousId: void 0,
|
|
2753
|
+
timeframe: new import_timeframe.Timeframe(),
|
|
2754
|
+
snapshotCid: void 0
|
|
2755
|
+
}
|
|
2756
|
+
})
|
|
2757
|
+
];
|
|
2758
|
+
for (const credential of credentials) {
|
|
2759
|
+
await space.controlPipeline.writer.write({
|
|
2760
|
+
credential: {
|
|
2761
|
+
credential
|
|
2762
|
+
}
|
|
2763
|
+
});
|
|
2764
|
+
}
|
|
2765
|
+
return credentials;
|
|
2766
|
+
};
|
|
2767
|
+
|
|
2657
2768
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2658
2769
|
var __decorate2 = function(decorators, target, key, desc) {
|
|
2659
2770
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -2666,17 +2777,15 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2666
2777
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2667
2778
|
};
|
|
2668
2779
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2669
|
-
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext,
|
|
2780
|
+
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2670
2781
|
this._spaceManager = _spaceManager;
|
|
2671
2782
|
this._metadataStore = _metadataStore;
|
|
2672
2783
|
this._dataServiceSubscriptions = _dataServiceSubscriptions;
|
|
2673
2784
|
this._keyring = _keyring;
|
|
2674
2785
|
this._signingContext = _signingContext;
|
|
2675
|
-
this._modelFactory = _modelFactory;
|
|
2676
2786
|
this._feedStore = _feedStore;
|
|
2677
|
-
this._snapshotStore = _snapshotStore;
|
|
2678
2787
|
this._ctx = new import_context7.Context();
|
|
2679
|
-
this.updated = new
|
|
2788
|
+
this.updated = new import_async14.Event();
|
|
2680
2789
|
this._spaces = new import_util5.ComplexMap(import_keys10.PublicKey.hash);
|
|
2681
2790
|
this._isOpen = false;
|
|
2682
2791
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
@@ -2688,16 +2797,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2688
2797
|
async open() {
|
|
2689
2798
|
(0, import_log11.log)("open", {}, {
|
|
2690
2799
|
file: "data-space-manager.ts",
|
|
2691
|
-
line:
|
|
2800
|
+
line: 80,
|
|
2692
2801
|
scope: this,
|
|
2693
2802
|
callSite: (f, a) => f(...a)
|
|
2694
2803
|
});
|
|
2695
|
-
import_log11.log.trace("dxos.echo.data-space-manager", import_protocols6.trace.begin({
|
|
2696
|
-
id: this._instanceId
|
|
2697
|
-
parentId: this._traceParent
|
|
2804
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
|
|
2805
|
+
id: this._instanceId
|
|
2698
2806
|
}), {
|
|
2699
2807
|
file: "data-space-manager.ts",
|
|
2700
|
-
line:
|
|
2808
|
+
line: 81,
|
|
2701
2809
|
scope: this,
|
|
2702
2810
|
callSite: (f, a) => f(...a)
|
|
2703
2811
|
});
|
|
@@ -2706,7 +2814,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2706
2814
|
spaces: this._metadataStore.spaces.length
|
|
2707
2815
|
}, {
|
|
2708
2816
|
file: "data-space-manager.ts",
|
|
2709
|
-
line:
|
|
2817
|
+
line: 83,
|
|
2710
2818
|
scope: this,
|
|
2711
2819
|
callSite: (f, a) => f(...a)
|
|
2712
2820
|
});
|
|
@@ -2716,7 +2824,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2716
2824
|
spaceMetadata
|
|
2717
2825
|
}, {
|
|
2718
2826
|
file: "data-space-manager.ts",
|
|
2719
|
-
line:
|
|
2827
|
+
line: 87,
|
|
2720
2828
|
scope: this,
|
|
2721
2829
|
callSite: (f, a) => f(...a)
|
|
2722
2830
|
});
|
|
@@ -2728,7 +2836,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2728
2836
|
err
|
|
2729
2837
|
}, {
|
|
2730
2838
|
file: "data-space-manager.ts",
|
|
2731
|
-
line:
|
|
2839
|
+
line: 91,
|
|
2732
2840
|
scope: this,
|
|
2733
2841
|
callSite: (f, a) => f(...a)
|
|
2734
2842
|
});
|
|
@@ -2736,11 +2844,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2736
2844
|
}
|
|
2737
2845
|
this._isOpen = true;
|
|
2738
2846
|
this.updated.emit();
|
|
2847
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
|
|
2848
|
+
id: this._instanceId
|
|
2849
|
+
}), {
|
|
2850
|
+
file: "data-space-manager.ts",
|
|
2851
|
+
line: 97,
|
|
2852
|
+
scope: this,
|
|
2853
|
+
callSite: (f, a) => f(...a)
|
|
2854
|
+
});
|
|
2739
2855
|
}
|
|
2740
2856
|
async close() {
|
|
2741
2857
|
(0, import_log11.log)("close", {}, {
|
|
2742
2858
|
file: "data-space-manager.ts",
|
|
2743
|
-
line:
|
|
2859
|
+
line: 102,
|
|
2744
2860
|
scope: this,
|
|
2745
2861
|
callSite: (f, a) => f(...a)
|
|
2746
2862
|
});
|
|
@@ -2749,14 +2865,6 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2749
2865
|
for (const space of this._spaces.values()) {
|
|
2750
2866
|
await space.close();
|
|
2751
2867
|
}
|
|
2752
|
-
import_log11.log.trace("dxos.echo.data-space-manager", import_protocols6.trace.end({
|
|
2753
|
-
id: this._instanceId
|
|
2754
|
-
}), {
|
|
2755
|
-
file: "data-space-manager.ts",
|
|
2756
|
-
line: 110,
|
|
2757
|
-
scope: this,
|
|
2758
|
-
callSite: (f, a) => f(...a)
|
|
2759
|
-
});
|
|
2760
2868
|
}
|
|
2761
2869
|
/**
|
|
2762
2870
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
@@ -2776,15 +2884,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2776
2884
|
spaceKey
|
|
2777
2885
|
}, {
|
|
2778
2886
|
file: "data-space-manager.ts",
|
|
2779
|
-
line:
|
|
2887
|
+
line: 126,
|
|
2780
2888
|
scope: this,
|
|
2781
2889
|
callSite: (f, a) => f(...a)
|
|
2782
2890
|
});
|
|
2783
2891
|
const space = await this._constructSpace(metadata);
|
|
2784
|
-
const credentials = await
|
|
2892
|
+
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2785
2893
|
await this._metadataStore.addSpace(metadata);
|
|
2786
2894
|
const memberCredential = credentials[1];
|
|
2787
|
-
(0, import_node_assert10.default)((0,
|
|
2895
|
+
(0, import_node_assert10.default)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2788
2896
|
await this._signingContext.recordCredential(memberCredential);
|
|
2789
2897
|
await space.initializeDataPipeline();
|
|
2790
2898
|
this.updated.emit();
|
|
@@ -2796,7 +2904,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2796
2904
|
opts
|
|
2797
2905
|
}, {
|
|
2798
2906
|
file: "data-space-manager.ts",
|
|
2799
|
-
line:
|
|
2907
|
+
line: 145,
|
|
2800
2908
|
scope: this,
|
|
2801
2909
|
callSite: (f, a) => f(...a)
|
|
2802
2910
|
});
|
|
@@ -2822,7 +2930,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2822
2930
|
async waitUntilSpaceReady(spaceKey) {
|
|
2823
2931
|
await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
2824
2932
|
const space = this._spaces.get(spaceKey);
|
|
2825
|
-
return !!space && space.state ===
|
|
2933
|
+
return !!space && space.state === import_services7.SpaceState.READY;
|
|
2826
2934
|
}));
|
|
2827
2935
|
}
|
|
2828
2936
|
async _constructSpace(metadata) {
|
|
@@ -2830,7 +2938,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2830
2938
|
metadata
|
|
2831
2939
|
}, {
|
|
2832
2940
|
file: "data-space-manager.ts",
|
|
2833
|
-
line:
|
|
2941
|
+
line: 181,
|
|
2834
2942
|
scope: this,
|
|
2835
2943
|
callSite: (f, a) => f(...a)
|
|
2836
2944
|
});
|
|
@@ -2843,7 +2951,6 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2843
2951
|
identityKey: this._signingContext.identityKey,
|
|
2844
2952
|
gossip
|
|
2845
2953
|
});
|
|
2846
|
-
const snapshotManager = new import_echo_pipeline2.SnapshotManager(this._snapshotStore);
|
|
2847
2954
|
const controlFeed = metadata.controlFeedKey && await this._feedStore.openFeed(metadata.controlFeedKey, {
|
|
2848
2955
|
writable: true
|
|
2849
2956
|
});
|
|
@@ -2861,35 +2968,32 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2861
2968
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
2862
2969
|
remotePeerId: session.remotePeerId
|
|
2863
2970
|
}));
|
|
2864
|
-
session.addExtension("dxos.mesh.teleport.objectsync", snapshotManager.objectSync.createExtension());
|
|
2971
|
+
session.addExtension("dxos.mesh.teleport.objectsync", space.snapshotManager.objectSync.createExtension());
|
|
2865
2972
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2866
|
-
}
|
|
2973
|
+
},
|
|
2974
|
+
memberKey: this._signingContext.identityKey
|
|
2867
2975
|
});
|
|
2868
2976
|
controlFeed && space.setControlFeed(controlFeed);
|
|
2869
2977
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2870
2978
|
const dataSpace = new DataSpace({
|
|
2871
2979
|
inner: space,
|
|
2872
|
-
modelFactory: this._modelFactory,
|
|
2873
2980
|
metadataStore: this._metadataStore,
|
|
2874
|
-
snapshotManager,
|
|
2875
2981
|
gossip,
|
|
2876
2982
|
presence,
|
|
2877
|
-
memberKey: this._signingContext.identityKey,
|
|
2878
2983
|
keyring: this._keyring,
|
|
2879
2984
|
feedStore: this._feedStore,
|
|
2880
2985
|
signingContext: this._signingContext,
|
|
2881
|
-
snapshotId: metadata.snapshot,
|
|
2882
2986
|
callbacks: {
|
|
2883
2987
|
beforeReady: async () => {
|
|
2884
2988
|
(0, import_log11.log)("before space ready", {
|
|
2885
2989
|
space: space.key
|
|
2886
2990
|
}, {
|
|
2887
2991
|
file: "data-space-manager.ts",
|
|
2888
|
-
line:
|
|
2992
|
+
line: 226,
|
|
2889
2993
|
scope: this,
|
|
2890
2994
|
callSite: (f, a) => f(...a)
|
|
2891
2995
|
});
|
|
2892
|
-
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.
|
|
2996
|
+
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2893
2997
|
},
|
|
2894
2998
|
afterReady: async () => {
|
|
2895
2999
|
(0, import_log11.log)("after space ready", {
|
|
@@ -2897,7 +3001,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2897
3001
|
open: this._isOpen
|
|
2898
3002
|
}, {
|
|
2899
3003
|
file: "data-space-manager.ts",
|
|
2900
|
-
line:
|
|
3004
|
+
line: 233,
|
|
2901
3005
|
scope: this,
|
|
2902
3006
|
callSite: (f, a) => f(...a)
|
|
2903
3007
|
});
|
|
@@ -2905,7 +3009,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2905
3009
|
this.updated.emit();
|
|
2906
3010
|
}
|
|
2907
3011
|
}
|
|
2908
|
-
}
|
|
3012
|
+
},
|
|
3013
|
+
cache: metadata.cache
|
|
2909
3014
|
});
|
|
2910
3015
|
await dataSpace.open();
|
|
2911
3016
|
if (metadata.controlTimeframe) {
|
|
@@ -2919,28 +3024,29 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2919
3024
|
}
|
|
2920
3025
|
};
|
|
2921
3026
|
__decorate2([
|
|
2922
|
-
|
|
3027
|
+
import_async14.synchronized
|
|
2923
3028
|
], DataSpaceManager.prototype, "open", null);
|
|
2924
3029
|
__decorate2([
|
|
2925
|
-
|
|
3030
|
+
import_async14.synchronized
|
|
2926
3031
|
], DataSpaceManager.prototype, "close", null);
|
|
2927
3032
|
__decorate2([
|
|
2928
|
-
|
|
3033
|
+
import_async14.synchronized
|
|
2929
3034
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2930
3035
|
__decorate2([
|
|
2931
|
-
|
|
3036
|
+
import_async14.synchronized
|
|
2932
3037
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2933
3038
|
DataSpaceManager = __decorate2([
|
|
2934
|
-
(0,
|
|
3039
|
+
(0, import_async14.trackLeaks)("open", "close")
|
|
2935
3040
|
], DataSpaceManager);
|
|
2936
3041
|
|
|
2937
3042
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2938
|
-
var
|
|
3043
|
+
var import_async15 = require("@dxos/async");
|
|
2939
3044
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
2940
|
-
var
|
|
2941
|
-
var
|
|
3045
|
+
var import_debug5 = require("@dxos/debug");
|
|
3046
|
+
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
2942
3047
|
var import_log12 = require("@dxos/log");
|
|
2943
|
-
var
|
|
3048
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
3049
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2944
3050
|
var import_util6 = require("@dxos/util");
|
|
2945
3051
|
var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
|
|
2946
3052
|
var SpacesServiceImpl = class {
|
|
@@ -2959,7 +3065,7 @@ var SpacesServiceImpl = class {
|
|
|
2959
3065
|
return this._transformSpace(space);
|
|
2960
3066
|
}
|
|
2961
3067
|
async updateSpace(request) {
|
|
2962
|
-
(0,
|
|
3068
|
+
(0, import_debug5.todo)();
|
|
2963
3069
|
}
|
|
2964
3070
|
querySpaces() {
|
|
2965
3071
|
return new import_codec_protobuf11.Stream(({ next, ctx }) => {
|
|
@@ -2970,7 +3076,7 @@ var SpacesServiceImpl = class {
|
|
|
2970
3076
|
spaces
|
|
2971
3077
|
}, {
|
|
2972
3078
|
file: "spaces-service.ts",
|
|
2973
|
-
line:
|
|
3079
|
+
line: 62,
|
|
2974
3080
|
scope: this,
|
|
2975
3081
|
callSite: (f, a) => f(...a)
|
|
2976
3082
|
});
|
|
@@ -2978,9 +3084,9 @@ var SpacesServiceImpl = class {
|
|
|
2978
3084
|
spaces
|
|
2979
3085
|
});
|
|
2980
3086
|
};
|
|
2981
|
-
(0,
|
|
3087
|
+
(0, import_async15.scheduleTask)(ctx, async () => {
|
|
2982
3088
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2983
|
-
const subscriptions = new
|
|
3089
|
+
const subscriptions = new import_async15.EventSubscriptions();
|
|
2984
3090
|
ctx.onDispose(() => subscriptions.clear());
|
|
2985
3091
|
const subscribeSpaces = () => {
|
|
2986
3092
|
subscriptions.clear();
|
|
@@ -3010,15 +3116,15 @@ var SpacesServiceImpl = class {
|
|
|
3010
3116
|
async postMessage({ spaceKey, channel, message }) {
|
|
3011
3117
|
var _a;
|
|
3012
3118
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3013
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
3119
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3014
3120
|
await space.postMessage(getChannelId(channel), message);
|
|
3015
3121
|
}
|
|
3016
3122
|
subscribeMessages({ spaceKey, channel }) {
|
|
3017
3123
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3018
|
-
(0,
|
|
3124
|
+
(0, import_async15.scheduleTask)(ctx, async () => {
|
|
3019
3125
|
var _a;
|
|
3020
3126
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3021
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
3127
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3022
3128
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3023
3129
|
next(message);
|
|
3024
3130
|
});
|
|
@@ -3029,19 +3135,19 @@ var SpacesServiceImpl = class {
|
|
|
3029
3135
|
queryCredentials({ spaceKey }) {
|
|
3030
3136
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3031
3137
|
var _a;
|
|
3032
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
3138
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3033
3139
|
const processor = space.spaceState.registerProcessor({
|
|
3034
3140
|
process: async (credential) => {
|
|
3035
3141
|
next(credential);
|
|
3036
3142
|
}
|
|
3037
3143
|
});
|
|
3038
3144
|
ctx.onDispose(() => processor.close());
|
|
3039
|
-
(0,
|
|
3145
|
+
(0, import_async15.scheduleTask)(ctx, () => processor.open());
|
|
3040
3146
|
});
|
|
3041
3147
|
}
|
|
3042
3148
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3043
3149
|
var _a;
|
|
3044
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
3150
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3045
3151
|
for (const credential of credentials != null ? credentials : []) {
|
|
3046
3152
|
await space.controlPipeline.writer.write({
|
|
3047
3153
|
credential: {
|
|
@@ -3050,11 +3156,18 @@ var SpacesServiceImpl = class {
|
|
|
3050
3156
|
});
|
|
3051
3157
|
}
|
|
3052
3158
|
}
|
|
3159
|
+
async createEpoch({ spaceKey }) {
|
|
3160
|
+
var _a;
|
|
3161
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3162
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3163
|
+
await space.createEpoch();
|
|
3164
|
+
}
|
|
3053
3165
|
_transformSpace(space) {
|
|
3054
3166
|
var _a, _b, _c, _d, _e;
|
|
3055
3167
|
return {
|
|
3056
3168
|
spaceKey: space.key,
|
|
3057
3169
|
state: space.state,
|
|
3170
|
+
error: space.error ? (0, import_protocols7.encodeError)(space.error) : void 0,
|
|
3058
3171
|
pipeline: {
|
|
3059
3172
|
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
3060
3173
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
@@ -3074,9 +3187,11 @@ var SpacesServiceImpl = class {
|
|
|
3074
3187
|
displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : (0, import_util6.humanize)(member.key)
|
|
3075
3188
|
}
|
|
3076
3189
|
},
|
|
3077
|
-
presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ?
|
|
3190
|
+
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
|
|
3078
3191
|
};
|
|
3079
|
-
})
|
|
3192
|
+
}),
|
|
3193
|
+
cache: space.cache,
|
|
3194
|
+
metrics: space.metrics
|
|
3080
3195
|
};
|
|
3081
3196
|
}
|
|
3082
3197
|
};
|
|
@@ -3168,7 +3283,7 @@ var SystemServiceImpl = class {
|
|
|
3168
3283
|
};
|
|
3169
3284
|
|
|
3170
3285
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3171
|
-
var
|
|
3286
|
+
var import_async17 = require("@dxos/async");
|
|
3172
3287
|
var import_log13 = require("@dxos/log");
|
|
3173
3288
|
var import_messaging = require("@dxos/messaging");
|
|
3174
3289
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
@@ -3176,7 +3291,7 @@ var import_util7 = require("@dxos/util");
|
|
|
3176
3291
|
|
|
3177
3292
|
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
3178
3293
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
3179
|
-
var
|
|
3294
|
+
var import_debug6 = require("@dxos/debug");
|
|
3180
3295
|
var import_rpc = require("@dxos/rpc");
|
|
3181
3296
|
var ClientRpcServer = class {
|
|
3182
3297
|
constructor(params) {
|
|
@@ -3216,7 +3331,7 @@ var ClientRpcServer = class {
|
|
|
3216
3331
|
_getServiceHandler(serviceName) {
|
|
3217
3332
|
var _a;
|
|
3218
3333
|
if (!this._handlerCache.has(serviceName)) {
|
|
3219
|
-
const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : (0,
|
|
3334
|
+
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}`));
|
|
3220
3335
|
const service = this._serviceRegistry.services[key];
|
|
3221
3336
|
if (!service) {
|
|
3222
3337
|
throw new Error(`Service not available: ${serviceName}`);
|
|
@@ -3229,14 +3344,14 @@ var ClientRpcServer = class {
|
|
|
3229
3344
|
|
|
3230
3345
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
3231
3346
|
var import_node_assert11 = __toESM(require("node:assert"));
|
|
3232
|
-
var
|
|
3233
|
-
var
|
|
3347
|
+
var import_async16 = require("@dxos/async");
|
|
3348
|
+
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
3234
3349
|
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
3235
3350
|
var import_rpc2 = require("@dxos/rpc");
|
|
3236
3351
|
var ShellRuntimeImpl = class {
|
|
3237
3352
|
constructor(_port) {
|
|
3238
3353
|
this._port = _port;
|
|
3239
|
-
this.layoutUpdate = new
|
|
3354
|
+
this.layoutUpdate = new import_async16.Event();
|
|
3240
3355
|
this._layout = import_iframe.ShellLayout.DEFAULT;
|
|
3241
3356
|
}
|
|
3242
3357
|
get layout() {
|
|
@@ -3263,8 +3378,8 @@ var ShellRuntimeImpl = class {
|
|
|
3263
3378
|
}
|
|
3264
3379
|
async open() {
|
|
3265
3380
|
this._appRpc = (0, import_rpc2.createProtoRpcPeer)({
|
|
3266
|
-
requested:
|
|
3267
|
-
exposed:
|
|
3381
|
+
requested: import_client_protocol2.appServiceBundle,
|
|
3382
|
+
exposed: import_client_protocol2.shellServiceBundle,
|
|
3268
3383
|
handlers: {
|
|
3269
3384
|
ShellService: {
|
|
3270
3385
|
setLayout: async (request) => {
|
|
@@ -3300,7 +3415,7 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3300
3415
|
var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
3301
3416
|
var IFrameHostRuntime = class {
|
|
3302
3417
|
constructor({ config, origin, appPort, shellPort }) {
|
|
3303
|
-
this._ready = new
|
|
3418
|
+
this._ready = new import_async17.Trigger();
|
|
3304
3419
|
this._configProvider = config;
|
|
3305
3420
|
this.origin = origin;
|
|
3306
3421
|
this._appPort = appPort;
|
|
@@ -3332,11 +3447,8 @@ var IFrameHostRuntime = class {
|
|
|
3332
3447
|
this._clientServices = new LocalClientServices({
|
|
3333
3448
|
lockKey: LOCK_KEY,
|
|
3334
3449
|
config: this._config,
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
signalManager: signals ? new import_messaging.WebsocketSignalManager(signals) : new import_messaging.MemorySignalManager(new import_messaging.MemorySignalManagerContext()),
|
|
3338
|
-
transportFactory: this._transportFactory
|
|
3339
|
-
})
|
|
3450
|
+
signalManager: signals ? new import_messaging.WebsocketSignalManager(signals) : new import_messaging.MemorySignalManager(new import_messaging.MemorySignalManagerContext()),
|
|
3451
|
+
transportFactory: this._transportFactory
|
|
3340
3452
|
});
|
|
3341
3453
|
const middleware = {
|
|
3342
3454
|
handleCall: async (method, params, handler) => {
|
|
@@ -3371,7 +3483,7 @@ var IFrameHostRuntime = class {
|
|
|
3371
3483
|
this._ready.wake(void 0);
|
|
3372
3484
|
(0, import_log13.log)("started", {}, {
|
|
3373
3485
|
file: "iframe-host-runtime.ts",
|
|
3374
|
-
line:
|
|
3486
|
+
line: 112,
|
|
3375
3487
|
scope: this,
|
|
3376
3488
|
callSite: (f, a) => f(...a)
|
|
3377
3489
|
});
|
|
@@ -3379,7 +3491,7 @@ var IFrameHostRuntime = class {
|
|
|
3379
3491
|
this._ready.wake(err);
|
|
3380
3492
|
import_log13.log.catch(err, {}, {
|
|
3381
3493
|
file: "iframe-host-runtime.ts",
|
|
3382
|
-
line:
|
|
3494
|
+
line: 115,
|
|
3383
3495
|
scope: this,
|
|
3384
3496
|
callSite: (f, a) => f(...a)
|
|
3385
3497
|
});
|
|
@@ -3389,7 +3501,7 @@ var IFrameHostRuntime = class {
|
|
|
3389
3501
|
var _a;
|
|
3390
3502
|
(0, import_log13.log)("stopping...", {}, {
|
|
3391
3503
|
file: "iframe-host-runtime.ts",
|
|
3392
|
-
line:
|
|
3504
|
+
line: 120,
|
|
3393
3505
|
scope: this,
|
|
3394
3506
|
callSite: (f, a) => f(...a)
|
|
3395
3507
|
});
|
|
@@ -3398,7 +3510,7 @@ var IFrameHostRuntime = class {
|
|
|
3398
3510
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
3399
3511
|
(0, import_log13.log)("stopped", {}, {
|
|
3400
3512
|
file: "iframe-host-runtime.ts",
|
|
3401
|
-
line:
|
|
3513
|
+
line: 124,
|
|
3402
3514
|
scope: this,
|
|
3403
3515
|
callSite: (f, a) => f(...a)
|
|
3404
3516
|
});
|
|
@@ -3409,7 +3521,8 @@ __decorate3([
|
|
|
3409
3521
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
3410
3522
|
|
|
3411
3523
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
3412
|
-
var
|
|
3524
|
+
var import_async18 = require("@dxos/async");
|
|
3525
|
+
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
3413
3526
|
var import_errors5 = require("@dxos/errors");
|
|
3414
3527
|
var import_log14 = require("@dxos/log");
|
|
3415
3528
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
@@ -3417,7 +3530,7 @@ var import_rpc3 = require("@dxos/rpc");
|
|
|
3417
3530
|
var import_util8 = require("@dxos/util");
|
|
3418
3531
|
|
|
3419
3532
|
// packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
|
|
3420
|
-
var
|
|
3533
|
+
var import_async19 = require("@dxos/async");
|
|
3421
3534
|
var import_log15 = require("@dxos/log");
|
|
3422
3535
|
var __decorate4 = function(decorators, target, key, desc) {
|
|
3423
3536
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3436,7 +3549,7 @@ var Message;
|
|
|
3436
3549
|
var VaultResourceLock = class {
|
|
3437
3550
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
3438
3551
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
3439
|
-
this._releaseTrigger = new
|
|
3552
|
+
this._releaseTrigger = new import_async19.Trigger();
|
|
3440
3553
|
this._lockKey = lockKey;
|
|
3441
3554
|
this._onAcquire = onAcquire;
|
|
3442
3555
|
this._onRelease = onRelease;
|
|
@@ -3456,7 +3569,7 @@ var VaultResourceLock = class {
|
|
|
3456
3569
|
scope: this,
|
|
3457
3570
|
callSite: (f, a) => f(...a)
|
|
3458
3571
|
});
|
|
3459
|
-
await (0,
|
|
3572
|
+
await (0, import_async19.asyncTimeout)(this._requestLock(), 3e3);
|
|
3460
3573
|
(0, import_log15.log)("acquired lock", {}, {
|
|
3461
3574
|
file: "vault-resource-lock.ts",
|
|
3462
3575
|
line: 46,
|
|
@@ -3496,14 +3609,14 @@ var VaultResourceLock = class {
|
|
|
3496
3609
|
scope: this,
|
|
3497
3610
|
callSite: (f, a) => f(...a)
|
|
3498
3611
|
});
|
|
3499
|
-
const acquired = new
|
|
3612
|
+
const acquired = new import_async19.Trigger();
|
|
3500
3613
|
void navigator.locks.request(this._lockKey, {
|
|
3501
3614
|
steal
|
|
3502
3615
|
}, async () => {
|
|
3503
3616
|
var _a, _b;
|
|
3504
3617
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3505
3618
|
acquired.wake();
|
|
3506
|
-
this._releaseTrigger = new
|
|
3619
|
+
this._releaseTrigger = new import_async19.Trigger();
|
|
3507
3620
|
await this._releaseTrigger.wait();
|
|
3508
3621
|
(0, import_log15.log)("releasing lock...", {}, {
|
|
3509
3622
|
file: "vault-resource-lock.ts",
|
|
@@ -3538,15 +3651,15 @@ __decorate4([
|
|
|
3538
3651
|
], VaultResourceLock.prototype, "lockKey", null);
|
|
3539
3652
|
|
|
3540
3653
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
3541
|
-
var
|
|
3654
|
+
var import_async21 = require("@dxos/async");
|
|
3542
3655
|
var import_log17 = require("@dxos/log");
|
|
3543
3656
|
var import_messaging2 = require("@dxos/messaging");
|
|
3544
3657
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
3545
3658
|
|
|
3546
3659
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
3547
3660
|
var import_node_assert12 = __toESM(require("node:assert"));
|
|
3548
|
-
var
|
|
3549
|
-
var
|
|
3661
|
+
var import_async20 = require("@dxos/async");
|
|
3662
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
3550
3663
|
var import_log16 = require("@dxos/log");
|
|
3551
3664
|
var import_rpc4 = require("@dxos/rpc");
|
|
3552
3665
|
var import_util9 = require("@dxos/util");
|
|
@@ -3561,14 +3674,10 @@ var __decorate5 = function(decorators, target, key, desc) {
|
|
|
3561
3674
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3562
3675
|
};
|
|
3563
3676
|
var WorkerSession = class {
|
|
3564
|
-
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal
|
|
3565
|
-
|
|
3566
|
-
} }) {
|
|
3567
|
-
this._startTrigger = new import_async18.Trigger();
|
|
3677
|
+
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
3678
|
+
this._startTrigger = new import_async20.Trigger();
|
|
3568
3679
|
this.onClose = new import_util9.Callback();
|
|
3569
|
-
(0, import_node_assert12.default)(options);
|
|
3570
3680
|
(0, import_node_assert12.default)(serviceHost);
|
|
3571
|
-
this._options = options;
|
|
3572
3681
|
this._serviceHost = serviceHost;
|
|
3573
3682
|
const middleware = {
|
|
3574
3683
|
handleCall: async (method, params, handler) => {
|
|
@@ -3601,12 +3710,13 @@ var WorkerSession = class {
|
|
|
3601
3710
|
...middleware
|
|
3602
3711
|
});
|
|
3603
3712
|
this._iframeRpc = (0, import_rpc4.createProtoRpcPeer)({
|
|
3604
|
-
requested:
|
|
3605
|
-
exposed:
|
|
3713
|
+
requested: import_client_protocol4.iframeServiceBundle,
|
|
3714
|
+
exposed: import_client_protocol4.workerServiceBundle,
|
|
3606
3715
|
handlers: {
|
|
3607
3716
|
WorkerService: {
|
|
3608
3717
|
start: async (request) => {
|
|
3609
3718
|
this.origin = request.origin;
|
|
3719
|
+
this.lockKey = request.lockKey;
|
|
3610
3720
|
this._startTrigger.wake();
|
|
3611
3721
|
},
|
|
3612
3722
|
stop: async () => {
|
|
@@ -3616,7 +3726,7 @@ var WorkerSession = class {
|
|
|
3616
3726
|
} catch (err) {
|
|
3617
3727
|
import_log16.log.catch(err, {}, {
|
|
3618
3728
|
file: "worker-session.ts",
|
|
3619
|
-
line:
|
|
3729
|
+
line: 95,
|
|
3620
3730
|
scope: this,
|
|
3621
3731
|
callSite: (f, a) => f(...a)
|
|
3622
3732
|
});
|
|
@@ -3627,14 +3737,13 @@ var WorkerSession = class {
|
|
|
3627
3737
|
},
|
|
3628
3738
|
port: systemPort,
|
|
3629
3739
|
timeout: 1e3
|
|
3630
|
-
// With low timeout heartbeat may fail if the tab's thread is saturated.
|
|
3631
3740
|
});
|
|
3632
3741
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
3633
3742
|
}
|
|
3634
3743
|
async open() {
|
|
3635
3744
|
import_log16.log.info("opening..", {}, {
|
|
3636
3745
|
file: "worker-session.ts",
|
|
3637
|
-
line:
|
|
3746
|
+
line: 109,
|
|
3638
3747
|
scope: this,
|
|
3639
3748
|
callSite: (f, a) => f(...a)
|
|
3640
3749
|
});
|
|
@@ -3646,35 +3755,14 @@ var WorkerSession = class {
|
|
|
3646
3755
|
await this._startTrigger.wait({
|
|
3647
3756
|
timeout: 3e3
|
|
3648
3757
|
});
|
|
3649
|
-
this.
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
} catch (err1) {
|
|
3653
|
-
import_log16.log.warn("Heartbeat failed", {
|
|
3654
|
-
err: err1
|
|
3655
|
-
}, {
|
|
3656
|
-
file: "worker-session.ts",
|
|
3657
|
-
line: 133,
|
|
3658
|
-
scope: this,
|
|
3659
|
-
callSite: (f, a) => f(...a)
|
|
3660
|
-
});
|
|
3661
|
-
try {
|
|
3662
|
-
await this.close();
|
|
3663
|
-
} catch (err) {
|
|
3664
|
-
import_log16.log.catch(err, {}, {
|
|
3665
|
-
file: "worker-session.ts",
|
|
3666
|
-
line: 137,
|
|
3667
|
-
scope: this,
|
|
3668
|
-
callSite: (f, a) => f(...a)
|
|
3669
|
-
});
|
|
3670
|
-
}
|
|
3671
|
-
}
|
|
3672
|
-
}, this._options.heartbeatInterval);
|
|
3758
|
+
if (this.lockKey) {
|
|
3759
|
+
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
3760
|
+
}
|
|
3673
3761
|
}
|
|
3674
3762
|
async close() {
|
|
3675
3763
|
import_log16.log.info("closing..", {}, {
|
|
3676
3764
|
file: "worker-session.ts",
|
|
3677
|
-
line:
|
|
3765
|
+
line: 119,
|
|
3678
3766
|
scope: this,
|
|
3679
3767
|
callSite: (f, a) => f(...a)
|
|
3680
3768
|
});
|
|
@@ -3683,14 +3771,11 @@ var WorkerSession = class {
|
|
|
3683
3771
|
} catch (err) {
|
|
3684
3772
|
import_log16.log.catch(err, {}, {
|
|
3685
3773
|
file: "worker-session.ts",
|
|
3686
|
-
line:
|
|
3774
|
+
line: 123,
|
|
3687
3775
|
scope: this,
|
|
3688
3776
|
callSite: (f, a) => f(...a)
|
|
3689
3777
|
});
|
|
3690
3778
|
}
|
|
3691
|
-
if (this._heartbeatTimer !== void 0) {
|
|
3692
|
-
clearInterval(this._heartbeatTimer);
|
|
3693
|
-
}
|
|
3694
3779
|
await Promise.all([
|
|
3695
3780
|
this._clientRpc.close(),
|
|
3696
3781
|
this._iframeRpc.close()
|
|
@@ -3698,85 +3783,93 @@ var WorkerSession = class {
|
|
|
3698
3783
|
}
|
|
3699
3784
|
async _maybeOpenShell() {
|
|
3700
3785
|
try {
|
|
3701
|
-
await (0,
|
|
3786
|
+
await (0, import_async20.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
3702
3787
|
} catch (e) {
|
|
3703
3788
|
import_log16.log.info("No shell connected.", {}, {
|
|
3704
3789
|
file: "worker-session.ts",
|
|
3705
|
-
line:
|
|
3790
|
+
line: 133,
|
|
3706
3791
|
scope: this,
|
|
3707
3792
|
callSite: (f, a) => f(...a)
|
|
3708
3793
|
});
|
|
3709
3794
|
}
|
|
3710
3795
|
}
|
|
3796
|
+
_afterLockReleases(lockKey, callback) {
|
|
3797
|
+
return navigator.locks.request(lockKey, () => {
|
|
3798
|
+
}).then(callback);
|
|
3799
|
+
}
|
|
3711
3800
|
};
|
|
3712
3801
|
__decorate5([
|
|
3713
3802
|
import_log16.logInfo
|
|
3714
3803
|
], WorkerSession.prototype, "origin", void 0);
|
|
3804
|
+
__decorate5([
|
|
3805
|
+
import_log16.logInfo
|
|
3806
|
+
], WorkerSession.prototype, "lockKey", void 0);
|
|
3715
3807
|
|
|
3716
3808
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3717
3809
|
var import_node_assert13 = __toESM(require("node:assert"));
|
|
3718
|
-
var
|
|
3719
|
-
var
|
|
3720
|
-
var
|
|
3721
|
-
var
|
|
3722
|
-
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3810
|
+
var import_async22 = require("@dxos/async");
|
|
3811
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
3812
|
+
var import_debug7 = require("@dxos/debug");
|
|
3813
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
3723
3814
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
3724
3815
|
var import_keyring = require("@dxos/keyring");
|
|
3725
3816
|
var import_keys11 = require("@dxos/keys");
|
|
3726
3817
|
var import_log18 = require("@dxos/log");
|
|
3727
|
-
var
|
|
3818
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
3819
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3728
3820
|
var ServiceContext = class {
|
|
3729
3821
|
// prettier-ignore
|
|
3730
|
-
constructor(storage, networkManager, modelFactory) {
|
|
3822
|
+
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
3731
3823
|
this.storage = storage;
|
|
3732
3824
|
this.networkManager = networkManager;
|
|
3825
|
+
this.signalManager = signalManager;
|
|
3733
3826
|
this.modelFactory = modelFactory;
|
|
3734
|
-
this.initialized = new
|
|
3735
|
-
this.dataServiceSubscriptions = new
|
|
3827
|
+
this.initialized = new import_async22.Trigger();
|
|
3828
|
+
this.dataServiceSubscriptions = new import_echo_pipeline3.DataServiceSubscriptions();
|
|
3736
3829
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
3737
3830
|
this._instanceId = import_keys11.PublicKey.random().toHex();
|
|
3738
|
-
|
|
3739
|
-
this.
|
|
3740
|
-
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
3831
|
+
this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
|
|
3832
|
+
this.snapshotStore = new import_echo_pipeline3.SnapshotStore(storage.createDirectory("snapshots"));
|
|
3741
3833
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
3742
3834
|
this.feedStore = new import_feed_store4.FeedStore({
|
|
3743
3835
|
factory: new import_feed_store4.FeedFactory({
|
|
3744
3836
|
root: storage.createDirectory("feeds"),
|
|
3745
3837
|
signer: this.keyring,
|
|
3746
3838
|
hypercore: {
|
|
3747
|
-
valueEncoding:
|
|
3839
|
+
valueEncoding: import_echo_pipeline3.valueEncoding
|
|
3748
3840
|
}
|
|
3749
3841
|
})
|
|
3750
3842
|
});
|
|
3751
|
-
this.spaceManager = new
|
|
3843
|
+
this.spaceManager = new import_echo_pipeline3.SpaceManager({
|
|
3752
3844
|
feedStore: this.feedStore,
|
|
3753
|
-
networkManager: this.networkManager
|
|
3845
|
+
networkManager: this.networkManager,
|
|
3846
|
+
metadataStore: this.metadataStore,
|
|
3847
|
+
modelFactory: this.modelFactory,
|
|
3848
|
+
snapshotStore: this.snapshotStore
|
|
3754
3849
|
});
|
|
3755
|
-
this.spaceManager._traceParent = this._instanceId;
|
|
3756
3850
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3757
|
-
this.identityManager._traceParent = this._instanceId;
|
|
3758
3851
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3759
|
-
this.
|
|
3760
|
-
this._handlerFactories.set(import_client7.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
|
|
3852
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
|
|
3761
3853
|
var _a;
|
|
3762
|
-
return (_a = this.identityManager.identity) != null ? _a : (0,
|
|
3854
|
+
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
3763
3855
|
}, this._acceptIdentity.bind(this)));
|
|
3764
3856
|
}
|
|
3765
3857
|
async open() {
|
|
3766
|
-
import_log18.log.trace("dxos.sdk.service-context",
|
|
3858
|
+
import_log18.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
|
|
3767
3859
|
id: this._instanceId
|
|
3768
3860
|
}), {
|
|
3769
3861
|
file: "service-context.ts",
|
|
3770
|
-
line:
|
|
3862
|
+
line: 119,
|
|
3771
3863
|
scope: this,
|
|
3772
3864
|
callSite: (f, a) => f(...a)
|
|
3773
3865
|
});
|
|
3774
3866
|
(0, import_log18.log)("opening...", {}, {
|
|
3775
3867
|
file: "service-context.ts",
|
|
3776
|
-
line:
|
|
3868
|
+
line: 121,
|
|
3777
3869
|
scope: this,
|
|
3778
3870
|
callSite: (f, a) => f(...a)
|
|
3779
3871
|
});
|
|
3872
|
+
await this.signalManager.open();
|
|
3780
3873
|
await this.networkManager.open();
|
|
3781
3874
|
await this.spaceManager.open();
|
|
3782
3875
|
await this.identityManager.open();
|
|
@@ -3785,7 +3878,15 @@ var ServiceContext = class {
|
|
|
3785
3878
|
}
|
|
3786
3879
|
(0, import_log18.log)("opened", {}, {
|
|
3787
3880
|
file: "service-context.ts",
|
|
3788
|
-
line:
|
|
3881
|
+
line: 129,
|
|
3882
|
+
scope: this,
|
|
3883
|
+
callSite: (f, a) => f(...a)
|
|
3884
|
+
});
|
|
3885
|
+
import_log18.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
|
|
3886
|
+
id: this._instanceId
|
|
3887
|
+
}), {
|
|
3888
|
+
file: "service-context.ts",
|
|
3889
|
+
line: 130,
|
|
3789
3890
|
scope: this,
|
|
3790
3891
|
callSite: (f, a) => f(...a)
|
|
3791
3892
|
});
|
|
@@ -3794,7 +3895,7 @@ var ServiceContext = class {
|
|
|
3794
3895
|
var _a, _b;
|
|
3795
3896
|
(0, import_log18.log)("closing...", {}, {
|
|
3796
3897
|
file: "service-context.ts",
|
|
3797
|
-
line:
|
|
3898
|
+
line: 134,
|
|
3798
3899
|
scope: this,
|
|
3799
3900
|
callSite: (f, a) => f(...a)
|
|
3800
3901
|
});
|
|
@@ -3804,18 +3905,11 @@ var ServiceContext = class {
|
|
|
3804
3905
|
await this.spaceManager.close();
|
|
3805
3906
|
await this.feedStore.close();
|
|
3806
3907
|
await this.networkManager.close();
|
|
3908
|
+
await this.signalManager.close();
|
|
3807
3909
|
this.dataServiceSubscriptions.clear();
|
|
3808
3910
|
(0, import_log18.log)("closed", {}, {
|
|
3809
3911
|
file: "service-context.ts",
|
|
3810
|
-
line:
|
|
3811
|
-
scope: this,
|
|
3812
|
-
callSite: (f, a) => f(...a)
|
|
3813
|
-
});
|
|
3814
|
-
import_log18.log.trace("dxos.sdk.service-context", import_protocols7.trace.end({
|
|
3815
|
-
id: this._instanceId
|
|
3816
|
-
}), {
|
|
3817
|
-
file: "service-context.ts",
|
|
3818
|
-
line: 138,
|
|
3912
|
+
line: 143,
|
|
3819
3913
|
scope: this,
|
|
3820
3914
|
callSite: (f, a) => f(...a)
|
|
3821
3915
|
});
|
|
@@ -3840,11 +3934,11 @@ var ServiceContext = class {
|
|
|
3840
3934
|
var _a;
|
|
3841
3935
|
(0, import_log18.log)("initializing spaces...", {}, {
|
|
3842
3936
|
file: "service-context.ts",
|
|
3843
|
-
line:
|
|
3937
|
+
line: 168,
|
|
3844
3938
|
scope: this,
|
|
3845
3939
|
callSite: (f, a) => f(...a)
|
|
3846
3940
|
});
|
|
3847
|
-
const identity = (_a = this.identityManager.identity) != null ? _a : (0,
|
|
3941
|
+
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
3848
3942
|
const signingContext = {
|
|
3849
3943
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3850
3944
|
identityKey: identity.identityKey,
|
|
@@ -3858,17 +3952,16 @@ var ServiceContext = class {
|
|
|
3858
3952
|
});
|
|
3859
3953
|
}
|
|
3860
3954
|
};
|
|
3861
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.
|
|
3862
|
-
this.dataSpaceManager._traceParent = this._instanceId;
|
|
3955
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3863
3956
|
await this.dataSpaceManager.open();
|
|
3864
|
-
this._handlerFactories.set(
|
|
3957
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
3865
3958
|
(0, import_node_assert13.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
3866
3959
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3867
3960
|
});
|
|
3868
3961
|
this.initialized.wake();
|
|
3869
3962
|
this._deviceSpaceSync = identity.space.spaceState.registerProcessor({
|
|
3870
3963
|
process: async (credential) => {
|
|
3871
|
-
const assertion = (0,
|
|
3964
|
+
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
3872
3965
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3873
3966
|
return;
|
|
3874
3967
|
}
|
|
@@ -3880,7 +3973,7 @@ var ServiceContext = class {
|
|
|
3880
3973
|
details: assertion
|
|
3881
3974
|
}, {
|
|
3882
3975
|
file: "service-context.ts",
|
|
3883
|
-
line:
|
|
3976
|
+
line: 207,
|
|
3884
3977
|
scope: this,
|
|
3885
3978
|
callSite: (f, a) => f(...a)
|
|
3886
3979
|
});
|
|
@@ -3891,7 +3984,7 @@ var ServiceContext = class {
|
|
|
3891
3984
|
details: assertion
|
|
3892
3985
|
}, {
|
|
3893
3986
|
file: "service-context.ts",
|
|
3894
|
-
line:
|
|
3987
|
+
line: 211,
|
|
3895
3988
|
scope: this,
|
|
3896
3989
|
callSite: (f, a) => f(...a)
|
|
3897
3990
|
});
|
|
@@ -3902,7 +3995,7 @@ var ServiceContext = class {
|
|
|
3902
3995
|
details: assertion
|
|
3903
3996
|
}, {
|
|
3904
3997
|
file: "service-context.ts",
|
|
3905
|
-
line:
|
|
3998
|
+
line: 216,
|
|
3906
3999
|
scope: this,
|
|
3907
4000
|
callSite: (f, a) => f(...a)
|
|
3908
4001
|
});
|
|
@@ -3913,7 +4006,7 @@ var ServiceContext = class {
|
|
|
3913
4006
|
} catch (err) {
|
|
3914
4007
|
import_log18.log.catch(err, {}, {
|
|
3915
4008
|
file: "service-context.ts",
|
|
3916
|
-
line:
|
|
4009
|
+
line: 222,
|
|
3917
4010
|
scope: this,
|
|
3918
4011
|
callSite: (f, a) => f(...a)
|
|
3919
4012
|
});
|
|
@@ -3952,41 +4045,45 @@ var ServiceRegistry = class {
|
|
|
3952
4045
|
var ClientServicesHost = class {
|
|
3953
4046
|
constructor({
|
|
3954
4047
|
config,
|
|
3955
|
-
modelFactory = (0,
|
|
4048
|
+
modelFactory = (0, import_client_protocol5.createDefaultModelFactory)(),
|
|
3956
4049
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3957
|
-
|
|
4050
|
+
transportFactory,
|
|
4051
|
+
signalManager,
|
|
4052
|
+
connectionLog,
|
|
3958
4053
|
storage,
|
|
3959
4054
|
// TODO(wittjosiah): Turn this on by default.
|
|
3960
4055
|
lockKey
|
|
3961
4056
|
} = {}) {
|
|
3962
|
-
this._statusUpdate = new
|
|
4057
|
+
this._statusUpdate = new import_async23.Event();
|
|
3963
4058
|
this._opening = false;
|
|
3964
4059
|
this._open = false;
|
|
3965
|
-
this._instanceId = import_client8.PublicKey.random().toHex();
|
|
3966
4060
|
this._storage = storage;
|
|
3967
4061
|
this._modelFactory = modelFactory;
|
|
3968
4062
|
if (config) {
|
|
3969
4063
|
this.initialize({
|
|
3970
4064
|
config,
|
|
3971
|
-
|
|
4065
|
+
transportFactory,
|
|
4066
|
+
signalManager
|
|
3972
4067
|
});
|
|
3973
4068
|
}
|
|
3974
4069
|
this._resourceLock = lockKey ? new VaultResourceLock({
|
|
3975
4070
|
lockKey,
|
|
3976
4071
|
onAcquire: () => {
|
|
3977
|
-
this._opening
|
|
4072
|
+
if (!this._opening) {
|
|
4073
|
+
void this.open();
|
|
4074
|
+
}
|
|
3978
4075
|
},
|
|
3979
4076
|
onRelease: () => this.close()
|
|
3980
4077
|
}) : void 0;
|
|
3981
4078
|
this._systemService = new SystemServiceImpl({
|
|
3982
4079
|
config: this._config,
|
|
3983
4080
|
statusUpdate: this._statusUpdate,
|
|
3984
|
-
getCurrentStatus: () => this.isOpen ?
|
|
4081
|
+
getCurrentStatus: () => this.isOpen ? import_services12.SystemStatus.ACTIVE : import_services12.SystemStatus.INACTIVE,
|
|
3985
4082
|
onUpdateStatus: async (status) => {
|
|
3986
4083
|
var _a, _b;
|
|
3987
|
-
if (!this.isOpen && status ===
|
|
4084
|
+
if (!this.isOpen && status === import_services12.SystemStatus.ACTIVE) {
|
|
3988
4085
|
await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
|
|
3989
|
-
} else if (this.isOpen && status ===
|
|
4086
|
+
} else if (this.isOpen && status === import_services12.SystemStatus.INACTIVE) {
|
|
3990
4087
|
await ((_b = this._resourceLock) == null ? void 0 : _b.release());
|
|
3991
4088
|
}
|
|
3992
4089
|
},
|
|
@@ -3995,7 +4092,7 @@ var ClientServicesHost = class {
|
|
|
3995
4092
|
}
|
|
3996
4093
|
});
|
|
3997
4094
|
this._loggingService = new LoggingServiceImpl();
|
|
3998
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
4095
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
3999
4096
|
SystemService: this._systemService
|
|
4000
4097
|
});
|
|
4001
4098
|
}
|
|
@@ -4016,7 +4113,8 @@ var ClientServicesHost = class {
|
|
|
4016
4113
|
* Config can also be provided in the constructor.
|
|
4017
4114
|
* Can only be called once.
|
|
4018
4115
|
*/
|
|
4019
|
-
initialize({ config,
|
|
4116
|
+
initialize({ config, ...options }) {
|
|
4117
|
+
var _a, _b, _c;
|
|
4020
4118
|
(0, import_node_assert14.default)(!this._open, "service host is open");
|
|
4021
4119
|
if (config) {
|
|
4022
4120
|
(0, import_node_assert14.default)(!this._config, "config already set");
|
|
@@ -4025,39 +4123,47 @@ var ClientServicesHost = class {
|
|
|
4025
4123
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
4026
4124
|
}
|
|
4027
4125
|
}
|
|
4028
|
-
|
|
4029
|
-
(
|
|
4030
|
-
|
|
4031
|
-
|
|
4126
|
+
const { connectionLog = true, transportFactory = (0, import_network_manager5.createWebRTCTransportFactory)({
|
|
4127
|
+
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
4128
|
+
}), signalManager = new import_messaging3.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
4129
|
+
this._signalManager = signalManager;
|
|
4130
|
+
(0, import_node_assert14.default)(!this._networkManager, "network manager already set");
|
|
4131
|
+
this._networkManager = new import_network_manager5.NetworkManager({
|
|
4132
|
+
log: connectionLog,
|
|
4133
|
+
transportFactory,
|
|
4134
|
+
signalManager
|
|
4135
|
+
});
|
|
4032
4136
|
}
|
|
4033
4137
|
async open() {
|
|
4034
4138
|
var _a, _b, _c;
|
|
4035
4139
|
if (this._open) {
|
|
4036
4140
|
return;
|
|
4037
4141
|
}
|
|
4038
|
-
|
|
4039
|
-
|
|
4142
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
4143
|
+
import_log19.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
|
|
4144
|
+
id: traceId
|
|
4040
4145
|
}), {
|
|
4041
4146
|
file: "service-host.ts",
|
|
4042
|
-
line:
|
|
4147
|
+
line: 186,
|
|
4043
4148
|
scope: this,
|
|
4044
4149
|
callSite: (f, a) => f(...a)
|
|
4045
4150
|
});
|
|
4046
4151
|
(0, import_node_assert14.default)(this._config, "config not set");
|
|
4047
4152
|
(0, import_node_assert14.default)(this._storage, "storage not set");
|
|
4153
|
+
(0, import_node_assert14.default)(this._signalManager, "signal manager not set");
|
|
4048
4154
|
(0, import_node_assert14.default)(this._networkManager, "network manager not set");
|
|
4049
4155
|
this._opening = true;
|
|
4050
4156
|
(0, import_log19.log)("opening...", {
|
|
4051
4157
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
4052
4158
|
}, {
|
|
4053
4159
|
file: "service-host.ts",
|
|
4054
|
-
line:
|
|
4160
|
+
line: 194,
|
|
4055
4161
|
scope: this,
|
|
4056
4162
|
callSite: (f, a) => f(...a)
|
|
4057
4163
|
});
|
|
4058
4164
|
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
4059
4165
|
await this._loggingService.open();
|
|
4060
|
-
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._modelFactory);
|
|
4166
|
+
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4061
4167
|
this._serviceRegistry.setServices({
|
|
4062
4168
|
SystemService: this._systemService,
|
|
4063
4169
|
IdentityService: new IdentityServiceImpl(this._serviceContext),
|
|
@@ -4067,8 +4173,8 @@ var ClientServicesHost = class {
|
|
|
4067
4173
|
await this._serviceContext.initialized.wait();
|
|
4068
4174
|
return this._serviceContext.dataSpaceManager;
|
|
4069
4175
|
}),
|
|
4070
|
-
DataService: new
|
|
4071
|
-
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager),
|
|
4176
|
+
DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4177
|
+
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
4072
4178
|
LoggingService: this._loggingService,
|
|
4073
4179
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4074
4180
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
@@ -4086,7 +4192,15 @@ var ClientServicesHost = class {
|
|
|
4086
4192
|
deviceKey
|
|
4087
4193
|
}, {
|
|
4088
4194
|
file: "service-host.ts",
|
|
4089
|
-
line:
|
|
4195
|
+
line: 249,
|
|
4196
|
+
scope: this,
|
|
4197
|
+
callSite: (f, a) => f(...a)
|
|
4198
|
+
});
|
|
4199
|
+
import_log19.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
|
|
4200
|
+
id: traceId
|
|
4201
|
+
}), {
|
|
4202
|
+
file: "service-host.ts",
|
|
4203
|
+
line: 250,
|
|
4090
4204
|
scope: this,
|
|
4091
4205
|
callSite: (f, a) => f(...a)
|
|
4092
4206
|
});
|
|
@@ -4101,7 +4215,7 @@ var ClientServicesHost = class {
|
|
|
4101
4215
|
deviceKey
|
|
4102
4216
|
}, {
|
|
4103
4217
|
file: "service-host.ts",
|
|
4104
|
-
line:
|
|
4218
|
+
line: 259,
|
|
4105
4219
|
scope: this,
|
|
4106
4220
|
callSite: (f, a) => f(...a)
|
|
4107
4221
|
});
|
|
@@ -4116,24 +4230,25 @@ var ClientServicesHost = class {
|
|
|
4116
4230
|
deviceKey
|
|
4117
4231
|
}, {
|
|
4118
4232
|
file: "service-host.ts",
|
|
4119
|
-
line:
|
|
4233
|
+
line: 265,
|
|
4120
4234
|
scope: this,
|
|
4121
4235
|
callSite: (f, a) => f(...a)
|
|
4122
4236
|
});
|
|
4123
|
-
|
|
4124
|
-
|
|
4237
|
+
}
|
|
4238
|
+
async reset() {
|
|
4239
|
+
var _a;
|
|
4240
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
4241
|
+
import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
|
|
4242
|
+
id: traceId
|
|
4125
4243
|
}), {
|
|
4126
4244
|
file: "service-host.ts",
|
|
4127
|
-
line:
|
|
4245
|
+
line: 270,
|
|
4128
4246
|
scope: this,
|
|
4129
4247
|
callSite: (f, a) => f(...a)
|
|
4130
4248
|
});
|
|
4131
|
-
}
|
|
4132
|
-
async reset() {
|
|
4133
|
-
var _a;
|
|
4134
4249
|
(0, import_log19.log)("resetting...", {}, {
|
|
4135
4250
|
file: "service-host.ts",
|
|
4136
|
-
line:
|
|
4251
|
+
line: 272,
|
|
4137
4252
|
scope: this,
|
|
4138
4253
|
callSite: (f, a) => f(...a)
|
|
4139
4254
|
});
|
|
@@ -4141,7 +4256,15 @@ var ClientServicesHost = class {
|
|
|
4141
4256
|
await this._storage.reset();
|
|
4142
4257
|
(0, import_log19.log)("reset", {}, {
|
|
4143
4258
|
file: "service-host.ts",
|
|
4144
|
-
line:
|
|
4259
|
+
line: 275,
|
|
4260
|
+
scope: this,
|
|
4261
|
+
callSite: (f, a) => f(...a)
|
|
4262
|
+
});
|
|
4263
|
+
import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
|
|
4264
|
+
id: traceId
|
|
4265
|
+
}), {
|
|
4266
|
+
file: "service-host.ts",
|
|
4267
|
+
line: 276,
|
|
4145
4268
|
scope: this,
|
|
4146
4269
|
callSite: (f, a) => f(...a)
|
|
4147
4270
|
});
|
|
@@ -4170,129 +4293,7 @@ var LocalClientServices = class {
|
|
|
4170
4293
|
}
|
|
4171
4294
|
};
|
|
4172
4295
|
|
|
4173
|
-
// packages/sdk/client-services/src/packlets/services/utils.ts
|
|
4174
|
-
var import_config2 = require("@dxos/config");
|
|
4175
|
-
var import_log20 = require("@dxos/log");
|
|
4176
|
-
var import_messaging3 = require("@dxos/messaging");
|
|
4177
|
-
var import_network_manager5 = require("@dxos/network-manager");
|
|
4178
|
-
|
|
4179
|
-
// packages/sdk/client-services/src/packlets/testing/host-test-builder.ts
|
|
4180
|
-
var createServiceHost = (config, signalManagerContext) => {
|
|
4181
|
-
const networkManager = new import_network_manager6.NetworkManager({
|
|
4182
|
-
signalManager: new import_messaging4.MemorySignalManager(signalManagerContext),
|
|
4183
|
-
transportFactory: import_network_manager6.MemoryTransportFactory
|
|
4184
|
-
});
|
|
4185
|
-
return new ClientServicesHost({
|
|
4186
|
-
config,
|
|
4187
|
-
networkManager
|
|
4188
|
-
});
|
|
4189
|
-
};
|
|
4190
|
-
var createServiceContext = ({ signalContext = new import_messaging4.MemorySignalManagerContext(), storage = (0, import_random_access_storage2.createStorage)({
|
|
4191
|
-
type: import_random_access_storage2.StorageType.RAM
|
|
4192
|
-
}) } = {}) => {
|
|
4193
|
-
const networkManager = new import_network_manager6.NetworkManager({
|
|
4194
|
-
signalManager: new import_messaging4.MemorySignalManager(signalContext),
|
|
4195
|
-
transportFactory: import_network_manager6.MemoryTransportFactory
|
|
4196
|
-
});
|
|
4197
|
-
const modelFactory = (0, import_client9.createDefaultModelFactory)();
|
|
4198
|
-
return new ServiceContext(storage, networkManager, modelFactory);
|
|
4199
|
-
};
|
|
4200
|
-
var createPeers = async (numPeers) => {
|
|
4201
|
-
const signalContext = new import_messaging4.MemorySignalManagerContext();
|
|
4202
|
-
return await Promise.all(Array.from(Array(numPeers)).map(async () => {
|
|
4203
|
-
const peer = createServiceContext({
|
|
4204
|
-
signalContext
|
|
4205
|
-
});
|
|
4206
|
-
await peer.open();
|
|
4207
|
-
return peer;
|
|
4208
|
-
}));
|
|
4209
|
-
};
|
|
4210
|
-
var createIdentity = async (peer) => {
|
|
4211
|
-
await peer.createIdentity();
|
|
4212
|
-
return peer;
|
|
4213
|
-
};
|
|
4214
|
-
var syncItemsLocal = async (db1, db2) => {
|
|
4215
|
-
await (0, import_testing.testLocalDatabase)(db1, db2);
|
|
4216
|
-
await (0, import_testing.testLocalDatabase)(db2, db1);
|
|
4217
|
-
};
|
|
4218
|
-
var HostTestBuilder = class {
|
|
4219
|
-
constructor() {
|
|
4220
|
-
this.signalContext = new import_messaging4.MemorySignalManagerContext();
|
|
4221
|
-
}
|
|
4222
|
-
createPeer() {
|
|
4223
|
-
return new TestPeer(this.signalContext);
|
|
4224
|
-
}
|
|
4225
|
-
};
|
|
4226
|
-
var TestPeer = class {
|
|
4227
|
-
constructor(signalContext) {
|
|
4228
|
-
this.signalContext = signalContext;
|
|
4229
|
-
this._props = {};
|
|
4230
|
-
}
|
|
4231
|
-
get storage() {
|
|
4232
|
-
var _a, _b;
|
|
4233
|
-
return (_b = (_a = this._props).storage) != null ? _b : _a.storage = (0, import_random_access_storage2.createStorage)({
|
|
4234
|
-
type: import_random_access_storage2.StorageType.RAM
|
|
4235
|
-
});
|
|
4236
|
-
}
|
|
4237
|
-
get keyring() {
|
|
4238
|
-
var _a, _b;
|
|
4239
|
-
return (_b = (_a = this._props).keyring) != null ? _b : _a.keyring = new import_keyring2.Keyring(this.storage.createDirectory("keyring"));
|
|
4240
|
-
}
|
|
4241
|
-
get feedStore() {
|
|
4242
|
-
var _a, _b;
|
|
4243
|
-
return (_b = (_a = this._props).feedStore) != null ? _b : _a.feedStore = new import_feed_store5.FeedStore({
|
|
4244
|
-
factory: new import_feed_store5.FeedFactory({
|
|
4245
|
-
root: this.storage.createDirectory("feeds"),
|
|
4246
|
-
signer: this.keyring,
|
|
4247
|
-
hypercore: {
|
|
4248
|
-
valueEncoding: import_echo_pipeline6.valueEncoding
|
|
4249
|
-
}
|
|
4250
|
-
})
|
|
4251
|
-
});
|
|
4252
|
-
}
|
|
4253
|
-
get metadataStore() {
|
|
4254
|
-
var _a, _b;
|
|
4255
|
-
return (_b = (_a = this._props).metadataStore) != null ? _b : _a.metadataStore = new import_echo_pipeline6.MetadataStore(this.storage.createDirectory("metadata"));
|
|
4256
|
-
}
|
|
4257
|
-
get snapshotStore() {
|
|
4258
|
-
var _a, _b;
|
|
4259
|
-
return (_b = (_a = this._props).snapshotStore) != null ? _b : _a.snapshotStore = new import_echo_pipeline6.SnapshotStore(this.storage.createDirectory("snapshots"));
|
|
4260
|
-
}
|
|
4261
|
-
get networkManager() {
|
|
4262
|
-
var _a, _b;
|
|
4263
|
-
return (_b = (_a = this._props).networkManager) != null ? _b : _a.networkManager = new import_network_manager6.NetworkManager({
|
|
4264
|
-
signalManager: new import_messaging4.MemorySignalManager(this.signalContext),
|
|
4265
|
-
transportFactory: import_network_manager6.MemoryTransportFactory
|
|
4266
|
-
});
|
|
4267
|
-
}
|
|
4268
|
-
get spaceManager() {
|
|
4269
|
-
var _a, _b;
|
|
4270
|
-
return (_b = (_a = this._props).spaceManager) != null ? _b : _a.spaceManager = new import_echo_pipeline6.SpaceManager({
|
|
4271
|
-
feedStore: this.feedStore,
|
|
4272
|
-
networkManager: this.networkManager
|
|
4273
|
-
});
|
|
4274
|
-
}
|
|
4275
|
-
};
|
|
4276
|
-
var createSigningContext = async (keyring) => {
|
|
4277
|
-
const identityKey = await keyring.createKey();
|
|
4278
|
-
const deviceKey = await keyring.createKey();
|
|
4279
|
-
return {
|
|
4280
|
-
identityKey,
|
|
4281
|
-
deviceKey,
|
|
4282
|
-
credentialSigner: (0, import_credentials13.createCredentialSignerWithChain)(keyring, {
|
|
4283
|
-
credential: await new import_credentials13.CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey)
|
|
4284
|
-
}, deviceKey),
|
|
4285
|
-
recordCredential: async () => {
|
|
4286
|
-
}
|
|
4287
|
-
// No-op.
|
|
4288
|
-
};
|
|
4289
|
-
};
|
|
4290
|
-
|
|
4291
4296
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
4292
|
-
var import_node_assert15 = __toESM(require("node:assert"));
|
|
4293
|
-
var import_async22 = require("@dxos/async");
|
|
4294
|
-
var import_client10 = require("@dxos/client");
|
|
4295
|
-
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4296
4297
|
var sanitizeInvitation = (invitation) => {
|
|
4297
4298
|
return {
|
|
4298
4299
|
invitationId: invitation.invitationId,
|
|
@@ -4305,14 +4306,14 @@ var sanitizeInvitation = (invitation) => {
|
|
|
4305
4306
|
};
|
|
4306
4307
|
};
|
|
4307
4308
|
var performInvitation = ({ host, guest, options, hooks }) => {
|
|
4308
|
-
const hostComplete = new
|
|
4309
|
-
const guestComplete = new
|
|
4310
|
-
const authCode = new
|
|
4309
|
+
const hostComplete = new import_async24.Trigger();
|
|
4310
|
+
const guestComplete = new import_async24.Trigger();
|
|
4311
|
+
const authCode = new import_async24.Trigger();
|
|
4311
4312
|
const hostObservable = createInvitation(host, options);
|
|
4312
4313
|
hostObservable.subscribe(async (hostInvitation) => {
|
|
4313
4314
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
4314
4315
|
switch (hostInvitation.state) {
|
|
4315
|
-
case
|
|
4316
|
+
case import_services13.Invitation.State.CONNECTING: {
|
|
4316
4317
|
if ((_b = (_a = hooks == null ? void 0 : hooks.host) == null ? void 0 : _a.onConnecting) == null ? void 0 : _b.call(_a, hostObservable)) {
|
|
4317
4318
|
break;
|
|
4318
4319
|
}
|
|
@@ -4320,29 +4321,29 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4320
4321
|
guestObservable.subscribe(async (guestInvitation) => {
|
|
4321
4322
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
|
|
4322
4323
|
switch (guestInvitation.state) {
|
|
4323
|
-
case
|
|
4324
|
+
case import_services13.Invitation.State.CONNECTING: {
|
|
4324
4325
|
if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
|
|
4325
4326
|
break;
|
|
4326
4327
|
}
|
|
4327
4328
|
(0, import_node_assert15.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
|
|
4328
4329
|
break;
|
|
4329
4330
|
}
|
|
4330
|
-
case
|
|
4331
|
+
case import_services13.Invitation.State.CONNECTED: {
|
|
4331
4332
|
(_d2 = (_c2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _c2.onConnected) == null ? void 0 : _d2.call(_c2, guestObservable);
|
|
4332
4333
|
break;
|
|
4333
4334
|
}
|
|
4334
|
-
case
|
|
4335
|
+
case import_services13.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
4335
4336
|
if ((_f2 = (_e2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _e2.onReady) == null ? void 0 : _f2.call(_e2, guestObservable)) {
|
|
4336
4337
|
break;
|
|
4337
4338
|
}
|
|
4338
4339
|
await guestObservable.authenticate(await authCode.wait());
|
|
4339
4340
|
break;
|
|
4340
4341
|
}
|
|
4341
|
-
case
|
|
4342
|
+
case import_services13.Invitation.State.AUTHENTICATING: {
|
|
4342
4343
|
(_h2 = (_g2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _g2.onAuthenticating) == null ? void 0 : _h2.call(_g2, guestObservable);
|
|
4343
4344
|
break;
|
|
4344
4345
|
}
|
|
4345
|
-
case
|
|
4346
|
+
case import_services13.Invitation.State.SUCCESS: {
|
|
4346
4347
|
if ((_j2 = (_i2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _i2.onSuccess) == null ? void 0 : _j2.call(_i2, guestObservable)) {
|
|
4347
4348
|
break;
|
|
4348
4349
|
}
|
|
@@ -4351,7 +4352,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4351
4352
|
});
|
|
4352
4353
|
break;
|
|
4353
4354
|
}
|
|
4354
|
-
case
|
|
4355
|
+
case import_services13.Invitation.State.CANCELLED: {
|
|
4355
4356
|
if ((_l2 = (_k2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _k2.onCancelled) == null ? void 0 : _l2.call(_k2, guestObservable)) {
|
|
4356
4357
|
break;
|
|
4357
4358
|
}
|
|
@@ -4360,7 +4361,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4360
4361
|
});
|
|
4361
4362
|
break;
|
|
4362
4363
|
}
|
|
4363
|
-
case
|
|
4364
|
+
case import_services13.Invitation.State.TIMEOUT: {
|
|
4364
4365
|
if ((_n2 = (_m2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _m2.onTimeout) == null ? void 0 : _n2.call(_m2, guestObservable)) {
|
|
4365
4366
|
return;
|
|
4366
4367
|
}
|
|
@@ -4380,11 +4381,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4380
4381
|
});
|
|
4381
4382
|
break;
|
|
4382
4383
|
}
|
|
4383
|
-
case
|
|
4384
|
+
case import_services13.Invitation.State.CONNECTED: {
|
|
4384
4385
|
(_d = (_c = hooks == null ? void 0 : hooks.host) == null ? void 0 : _c.onConnected) == null ? void 0 : _d.call(_c, hostObservable);
|
|
4385
4386
|
break;
|
|
4386
4387
|
}
|
|
4387
|
-
case
|
|
4388
|
+
case import_services13.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
4388
4389
|
if ((_f = (_e = hooks == null ? void 0 : hooks.host) == null ? void 0 : _e.onReady) == null ? void 0 : _f.call(_e, hostObservable)) {
|
|
4389
4390
|
break;
|
|
4390
4391
|
}
|
|
@@ -4393,11 +4394,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4393
4394
|
}
|
|
4394
4395
|
break;
|
|
4395
4396
|
}
|
|
4396
|
-
case
|
|
4397
|
+
case import_services13.Invitation.State.AUTHENTICATING: {
|
|
4397
4398
|
(_h = (_g = hooks == null ? void 0 : hooks.host) == null ? void 0 : _g.onAuthenticating) == null ? void 0 : _h.call(_g, hostObservable);
|
|
4398
4399
|
break;
|
|
4399
4400
|
}
|
|
4400
|
-
case
|
|
4401
|
+
case import_services13.Invitation.State.SUCCESS: {
|
|
4401
4402
|
if ((_j = (_i = hooks == null ? void 0 : hooks.host) == null ? void 0 : _i.onSuccess) == null ? void 0 : _j.call(_i, hostObservable)) {
|
|
4402
4403
|
break;
|
|
4403
4404
|
}
|
|
@@ -4406,7 +4407,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4406
4407
|
});
|
|
4407
4408
|
break;
|
|
4408
4409
|
}
|
|
4409
|
-
case
|
|
4410
|
+
case import_services13.Invitation.State.CANCELLED: {
|
|
4410
4411
|
if ((_l = (_k = hooks == null ? void 0 : hooks.host) == null ? void 0 : _k.onCancelled) == null ? void 0 : _l.call(_k, hostObservable)) {
|
|
4411
4412
|
break;
|
|
4412
4413
|
}
|
|
@@ -4415,7 +4416,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4415
4416
|
});
|
|
4416
4417
|
break;
|
|
4417
4418
|
}
|
|
4418
|
-
case
|
|
4419
|
+
case import_services13.Invitation.State.TIMEOUT: {
|
|
4419
4420
|
if ((_n = (_m = hooks == null ? void 0 : hooks.host) == null ? void 0 : _m.onTimeout) == null ? void 0 : _n.call(_m, hostObservable)) {
|
|
4420
4421
|
break;
|
|
4421
4422
|
}
|
|
@@ -4441,200 +4442,151 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4441
4442
|
};
|
|
4442
4443
|
var createInvitation = (host, options) => {
|
|
4443
4444
|
options != null ? options : options = {
|
|
4444
|
-
authMethod:
|
|
4445
|
+
authMethod: import_services13.Invitation.AuthMethod.NONE,
|
|
4445
4446
|
...options != null ? options : {}
|
|
4446
4447
|
};
|
|
4447
|
-
if (host instanceof
|
|
4448
|
-
|
|
4448
|
+
if (host instanceof ServiceContext) {
|
|
4449
|
+
const hostHandler = host.getInvitationHandler({
|
|
4450
|
+
kind: import_services13.Invitation.Kind.SPACE,
|
|
4451
|
+
...options
|
|
4452
|
+
});
|
|
4453
|
+
return host.invitations.createInvitation(hostHandler, options);
|
|
4449
4454
|
}
|
|
4450
|
-
|
|
4451
|
-
kind: import_services11.Invitation.Kind.SPACE,
|
|
4452
|
-
...options
|
|
4453
|
-
});
|
|
4454
|
-
return host.invitations.createInvitation(hostHandler, options);
|
|
4455
|
+
return host.createInvitation(options);
|
|
4455
4456
|
};
|
|
4456
4457
|
var acceptInvitation = (guest, invitation) => {
|
|
4457
4458
|
invitation = sanitizeInvitation(invitation);
|
|
4458
|
-
if (guest instanceof
|
|
4459
|
-
|
|
4459
|
+
if (guest instanceof ServiceContext) {
|
|
4460
|
+
const guestHandler = guest.getInvitationHandler({
|
|
4461
|
+
kind: invitation.kind
|
|
4462
|
+
});
|
|
4463
|
+
return guest.invitations.acceptInvitation(guestHandler, invitation);
|
|
4460
4464
|
}
|
|
4461
|
-
|
|
4462
|
-
kind: invitation.kind
|
|
4463
|
-
});
|
|
4464
|
-
return guest.invitations.acceptInvitation(guestHandler, invitation);
|
|
4465
|
+
return guest.acceptInvitation(invitation);
|
|
4465
4466
|
};
|
|
4466
4467
|
|
|
4467
4468
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
4468
|
-
var
|
|
4469
|
-
var
|
|
4470
|
-
var
|
|
4471
|
-
var
|
|
4472
|
-
var
|
|
4473
|
-
var
|
|
4474
|
-
var
|
|
4475
|
-
var
|
|
4476
|
-
var
|
|
4477
|
-
var
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
}
|
|
4492
|
-
|
|
4469
|
+
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
4470
|
+
var import_credentials15 = require("@dxos/credentials");
|
|
4471
|
+
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
4472
|
+
var import_testing = require("@dxos/echo-pipeline/testing");
|
|
4473
|
+
var import_feed_store5 = require("@dxos/feed-store");
|
|
4474
|
+
var import_keyring2 = require("@dxos/keyring");
|
|
4475
|
+
var import_messaging4 = require("@dxos/messaging");
|
|
4476
|
+
var import_network_manager6 = require("@dxos/network-manager");
|
|
4477
|
+
var import_random_access_storage2 = require("@dxos/random-access-storage");
|
|
4478
|
+
var createServiceHost = (config, signalManagerContext) => {
|
|
4479
|
+
return new ClientServicesHost({
|
|
4480
|
+
config,
|
|
4481
|
+
signalManager: new import_messaging4.MemorySignalManager(signalManagerContext),
|
|
4482
|
+
transportFactory: import_network_manager6.MemoryTransportFactory
|
|
4483
|
+
});
|
|
4484
|
+
};
|
|
4485
|
+
var createServiceContext = ({ signalContext = new import_messaging4.MemorySignalManagerContext(), storage = (0, import_random_access_storage2.createStorage)({
|
|
4486
|
+
type: import_random_access_storage2.StorageType.RAM
|
|
4487
|
+
}) } = {}) => {
|
|
4488
|
+
const signalManager = new import_messaging4.MemorySignalManager(signalContext);
|
|
4489
|
+
const networkManager = new import_network_manager6.NetworkManager({
|
|
4490
|
+
signalManager,
|
|
4491
|
+
transportFactory: import_network_manager6.MemoryTransportFactory
|
|
4492
|
+
});
|
|
4493
|
+
const modelFactory = (0, import_client_protocol6.createDefaultModelFactory)();
|
|
4494
|
+
return new ServiceContext(storage, networkManager, signalManager, modelFactory);
|
|
4495
|
+
};
|
|
4496
|
+
var createPeers = async (numPeers) => {
|
|
4497
|
+
const signalContext = new import_messaging4.MemorySignalManagerContext();
|
|
4498
|
+
return await Promise.all(Array.from(Array(numPeers)).map(async () => {
|
|
4499
|
+
const peer = createServiceContext({
|
|
4500
|
+
signalContext
|
|
4501
|
+
});
|
|
4502
|
+
await peer.open();
|
|
4503
|
+
return peer;
|
|
4504
|
+
}));
|
|
4505
|
+
};
|
|
4506
|
+
var createIdentity = async (peer) => {
|
|
4507
|
+
await peer.createIdentity();
|
|
4508
|
+
return peer;
|
|
4509
|
+
};
|
|
4510
|
+
var syncItemsLocal = async (db1, db2) => {
|
|
4511
|
+
await (0, import_testing.testLocalDatabase)(db1, db2);
|
|
4512
|
+
await (0, import_testing.testLocalDatabase)(db2, db1);
|
|
4513
|
+
};
|
|
4493
4514
|
var TestBuilder = class {
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
this._modelFactory = _modelFactory;
|
|
4497
|
-
this._signalManagerContext = _signalManagerContext;
|
|
4498
|
-
this._config = config != null ? config : new import_config3.Config();
|
|
4515
|
+
constructor() {
|
|
4516
|
+
this.signalContext = new import_messaging4.MemorySignalManagerContext();
|
|
4499
4517
|
}
|
|
4500
|
-
|
|
4501
|
-
return this.
|
|
4518
|
+
createPeer() {
|
|
4519
|
+
return new TestPeer(this.signalContext);
|
|
4502
4520
|
}
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
if (signals) {
|
|
4509
|
-
return new import_network_manager7.NetworkManager({
|
|
4510
|
-
log: true,
|
|
4511
|
-
signalManager: new import_messaging5.WebsocketSignalManager(signals),
|
|
4512
|
-
transportFactory: (0, import_network_manager7.createWebRTCTransportFactory)({
|
|
4513
|
-
iceServers: this._config.get("runtime.services.ice")
|
|
4514
|
-
})
|
|
4515
|
-
});
|
|
4516
|
-
}
|
|
4517
|
-
return new import_network_manager7.NetworkManager({
|
|
4518
|
-
log: true,
|
|
4519
|
-
signalManager: new import_messaging5.MemorySignalManager(this._signalManagerContext),
|
|
4520
|
-
transportFactory: import_network_manager7.MemoryTransportFactory
|
|
4521
|
-
});
|
|
4521
|
+
};
|
|
4522
|
+
var TestPeer = class {
|
|
4523
|
+
constructor(signalContext) {
|
|
4524
|
+
this.signalContext = signalContext;
|
|
4525
|
+
this._props = {};
|
|
4522
4526
|
}
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
return new ClientServicesHost({
|
|
4528
|
-
config: this._config,
|
|
4529
|
-
modelFactory: this._modelFactory,
|
|
4530
|
-
networkManager: this.networkManager,
|
|
4531
|
-
storage: this.storage
|
|
4527
|
+
get storage() {
|
|
4528
|
+
var _a, _b;
|
|
4529
|
+
return (_b = (_a = this._props).storage) != null ? _b : _a.storage = (0, import_random_access_storage2.createStorage)({
|
|
4530
|
+
type: import_random_access_storage2.StorageType.RAM
|
|
4532
4531
|
});
|
|
4533
4532
|
}
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4533
|
+
get keyring() {
|
|
4534
|
+
var _a, _b;
|
|
4535
|
+
return (_b = (_a = this._props).keyring) != null ? _b : _a.keyring = new import_keyring2.Keyring(this.storage.createDirectory("keyring"));
|
|
4536
|
+
}
|
|
4537
|
+
get feedStore() {
|
|
4538
|
+
var _a, _b;
|
|
4539
|
+
return (_b = (_a = this._props).feedStore) != null ? _b : _a.feedStore = new import_feed_store5.FeedStore({
|
|
4540
|
+
factory: new import_feed_store5.FeedFactory({
|
|
4541
|
+
root: this.storage.createDirectory("feeds"),
|
|
4542
|
+
signer: this.keyring,
|
|
4543
|
+
hypercore: {
|
|
4544
|
+
valueEncoding: import_echo_pipeline5.valueEncoding
|
|
4545
|
+
}
|
|
4546
|
+
})
|
|
4543
4547
|
});
|
|
4544
4548
|
}
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4549
|
+
get metadataStore() {
|
|
4550
|
+
var _a, _b;
|
|
4551
|
+
return (_b = (_a = this._props).metadataStore) != null ? _b : _a.metadataStore = new import_echo_pipeline5.MetadataStore(this.storage.createDirectory("metadata"));
|
|
4552
|
+
}
|
|
4553
|
+
get snapshotStore() {
|
|
4554
|
+
var _a, _b;
|
|
4555
|
+
return (_b = (_a = this._props).snapshotStore) != null ? _b : _a.snapshotStore = new import_echo_pipeline5.SnapshotStore(this.storage.createDirectory("snapshots"));
|
|
4556
|
+
}
|
|
4557
|
+
get networkManager() {
|
|
4558
|
+
var _a, _b;
|
|
4559
|
+
return (_b = (_a = this._props).networkManager) != null ? _b : _a.networkManager = new import_network_manager6.NetworkManager({
|
|
4560
|
+
signalManager: new import_messaging4.MemorySignalManager(this.signalContext),
|
|
4561
|
+
transportFactory: import_network_manager6.MemoryTransportFactory
|
|
4554
4562
|
});
|
|
4555
|
-
|
|
4556
|
-
|
|
4563
|
+
}
|
|
4564
|
+
get spaceManager() {
|
|
4565
|
+
var _a, _b;
|
|
4566
|
+
return (_b = (_a = this._props).spaceManager) != null ? _b : _a.spaceManager = new import_echo_pipeline5.SpaceManager({
|
|
4567
|
+
feedStore: this.feedStore,
|
|
4568
|
+
networkManager: this.networkManager,
|
|
4569
|
+
metadataStore: this.metadataStore,
|
|
4570
|
+
modelFactory: (0, import_client_protocol6.createDefaultModelFactory)(),
|
|
4571
|
+
snapshotStore: this.snapshotStore
|
|
4557
4572
|
});
|
|
4558
|
-
return [
|
|
4559
|
-
client,
|
|
4560
|
-
server
|
|
4561
|
-
];
|
|
4562
4573
|
}
|
|
4563
4574
|
};
|
|
4564
|
-
var
|
|
4565
|
-
const
|
|
4566
|
-
const
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
};
|
|
4576
|
-
var joinCommonSpace = async ([initialPeer, ...peers], spaceKey) => {
|
|
4577
|
-
const rootSpace = spaceKey ? initialPeer.getSpace(spaceKey) : await initialPeer.createSpace();
|
|
4578
|
-
(0, import_node_assert16.default)(rootSpace, "Space not found.");
|
|
4579
|
-
await Promise.all(peers.map(async (peer) => {
|
|
4580
|
-
const hostDone = new import_async23.Trigger();
|
|
4581
|
-
const guestDone = new import_async23.Trigger();
|
|
4582
|
-
const hostObservable = rootSpace.createInvitation({
|
|
4583
|
-
authMethod: import_client11.Invitation.AuthMethod.NONE
|
|
4584
|
-
});
|
|
4585
|
-
(0, import_log21.log)("invitation created", {}, {
|
|
4586
|
-
file: "test-builder.ts",
|
|
4587
|
-
line: 156,
|
|
4588
|
-
scope: void 0,
|
|
4589
|
-
callSite: (f, a) => f(...a)
|
|
4590
|
-
});
|
|
4591
|
-
hostObservable.subscribe((hostInvitation) => {
|
|
4592
|
-
switch (hostInvitation.state) {
|
|
4593
|
-
case import_client11.Invitation.State.CONNECTING: {
|
|
4594
|
-
const guestObservable = peer.acceptInvitation(hostInvitation);
|
|
4595
|
-
(0, import_log21.log)("invitation accepted", {}, {
|
|
4596
|
-
file: "test-builder.ts",
|
|
4597
|
-
line: 162,
|
|
4598
|
-
scope: void 0,
|
|
4599
|
-
callSite: (f, a) => f(...a)
|
|
4600
|
-
});
|
|
4601
|
-
guestObservable.subscribe((guestInvitation) => {
|
|
4602
|
-
switch (guestInvitation.state) {
|
|
4603
|
-
case import_client11.Invitation.State.SUCCESS: {
|
|
4604
|
-
guestDone.wake(guestInvitation);
|
|
4605
|
-
(0, import_log21.log)("invitation guestDone", {}, {
|
|
4606
|
-
file: "test-builder.ts",
|
|
4607
|
-
line: 169,
|
|
4608
|
-
scope: void 0,
|
|
4609
|
-
callSite: (f, a) => f(...a)
|
|
4610
|
-
});
|
|
4611
|
-
break;
|
|
4612
|
-
}
|
|
4613
|
-
}
|
|
4614
|
-
}, (err) => (0, import_debug7.raise)(err));
|
|
4615
|
-
break;
|
|
4616
|
-
}
|
|
4617
|
-
case import_client11.Invitation.State.SUCCESS: {
|
|
4618
|
-
hostDone.wake(hostInvitation);
|
|
4619
|
-
(0, import_log21.log)("invitation hostDone", {}, {
|
|
4620
|
-
file: "test-builder.ts",
|
|
4621
|
-
line: 181,
|
|
4622
|
-
scope: void 0,
|
|
4623
|
-
callSite: (f, a) => f(...a)
|
|
4624
|
-
});
|
|
4625
|
-
}
|
|
4626
|
-
}
|
|
4627
|
-
}, (err) => (0, import_debug7.raise)(err));
|
|
4628
|
-
await Promise.all([
|
|
4629
|
-
hostDone.wait(),
|
|
4630
|
-
guestDone.wait()
|
|
4631
|
-
]);
|
|
4632
|
-
}));
|
|
4633
|
-
return rootSpace.key;
|
|
4575
|
+
var createSigningContext = async (keyring) => {
|
|
4576
|
+
const identityKey = await keyring.createKey();
|
|
4577
|
+
const deviceKey = await keyring.createKey();
|
|
4578
|
+
return {
|
|
4579
|
+
identityKey,
|
|
4580
|
+
deviceKey,
|
|
4581
|
+
credentialSigner: (0, import_credentials15.createCredentialSignerWithChain)(keyring, {
|
|
4582
|
+
credential: await new import_credentials15.CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey)
|
|
4583
|
+
}, deviceKey),
|
|
4584
|
+
recordCredential: async () => {
|
|
4585
|
+
}
|
|
4586
|
+
};
|
|
4634
4587
|
};
|
|
4635
4588
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4636
4589
|
0 && (module.exports = {
|
|
4637
|
-
HostTestBuilder,
|
|
4638
4590
|
TestBuilder,
|
|
4639
4591
|
TestPeer,
|
|
4640
4592
|
createIdentity,
|
|
@@ -4643,12 +4595,8 @@ var joinCommonSpace = async ([initialPeer, ...peers], spaceKey) => {
|
|
|
4643
4595
|
createServiceContext,
|
|
4644
4596
|
createServiceHost,
|
|
4645
4597
|
createSigningContext,
|
|
4646
|
-
joinCommonSpace,
|
|
4647
4598
|
performInvitation,
|
|
4648
4599
|
sanitizeInvitation,
|
|
4649
|
-
|
|
4650
|
-
syncItemsLocal,
|
|
4651
|
-
testConfigWithLocalSignal,
|
|
4652
|
-
testSpace
|
|
4600
|
+
syncItemsLocal
|
|
4653
4601
|
});
|
|
4654
4602
|
//# sourceMappingURL=index.cjs.map
|