@dxos/client-services 0.6.12-staging.e11e696 → 0.6.13-main.09887cd
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-67FEJJ6J.mjs → chunk-XOKN3TE7.mjs} +1055 -768
- package/dist/lib/browser/chunk-XOKN3TE7.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +8 -2
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-2KIDYJ7O.cjs → chunk-IFHGVXW2.cjs} +1062 -779
- package/dist/lib/node/chunk-IFHGVXW2.cjs.map +7 -0
- package/dist/lib/node/index.cjs +45 -45
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +15 -9
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node-esm/{chunk-36ZRRDQI.mjs → chunk-FTEPRZ23.mjs} +1047 -760
- package/dist/lib/node-esm/chunk-FTEPRZ23.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +8 -2
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts +11 -7
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts +30 -0
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts +2 -1
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts +2 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-state.d.ts +19 -0
- package/dist/types/src/packlets/invitations/invitation-state.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +8 -8
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +3 -3
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +2 -0
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +1 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +38 -38
- package/src/packlets/identity/identity-manager.test.ts +26 -10
- package/src/packlets/identity/identity-manager.ts +19 -19
- package/src/packlets/identity/identity.test.ts +2 -0
- package/src/packlets/identity/identity.ts +17 -12
- package/src/packlets/invitations/device-invitation-protocol.ts +5 -1
- package/src/packlets/invitations/edge-invitation-handler.ts +184 -0
- package/src/packlets/invitations/invitation-guest-extenstion.ts +8 -4
- package/src/packlets/invitations/invitation-host-extension.ts +8 -4
- package/src/packlets/invitations/invitation-state.ts +111 -0
- package/src/packlets/invitations/invitations-handler.test.ts +2 -2
- package/src/packlets/invitations/invitations-handler.ts +23 -92
- package/src/packlets/invitations/space-invitation-protocol.ts +4 -0
- package/src/packlets/services/service-context.ts +65 -45
- package/src/packlets/spaces/data-space-manager.ts +31 -3
- package/src/packlets/spaces/data-space.ts +5 -0
- package/src/packlets/spaces/edge-feed-replicator.test.ts +2 -0
- package/src/packlets/spaces/spaces-service.ts +6 -1
- package/src/packlets/testing/test-builder.ts +5 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-67FEJJ6J.mjs.map +0 -7
- package/dist/lib/node/chunk-2KIDYJ7O.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-36ZRRDQI.mjs.map +0 -7
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_IFHGVXW2_exports = {};
|
|
30
|
+
__export(chunk_IFHGVXW2_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
DataSpace: () => DataSpace,
|
|
@@ -70,7 +70,7 @@ __export(chunk_2KIDYJ7O_exports, {
|
|
|
70
70
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
71
71
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
72
72
|
});
|
|
73
|
-
module.exports = __toCommonJS(
|
|
73
|
+
module.exports = __toCommonJS(chunk_IFHGVXW2_exports);
|
|
74
74
|
var import_async = require("@dxos/async");
|
|
75
75
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
76
76
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -177,6 +177,7 @@ var import_keys8 = require("@dxos/keys");
|
|
|
177
177
|
var import_log9 = require("@dxos/log");
|
|
178
178
|
var import_protocols5 = require("@dxos/protocols");
|
|
179
179
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
180
|
+
var import_metadata = require("@dxos/protocols/proto/dxos/echo/metadata");
|
|
180
181
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
181
182
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
182
183
|
var import_tracing5 = require("@dxos/tracing");
|
|
@@ -218,6 +219,7 @@ var import_invariant10 = require("@dxos/invariant");
|
|
|
218
219
|
var import_log12 = require("@dxos/log");
|
|
219
220
|
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
220
221
|
var import_util9 = require("@dxos/util");
|
|
222
|
+
var import_credentials17 = require("@dxos/credentials");
|
|
221
223
|
var import_invariant11 = require("@dxos/invariant");
|
|
222
224
|
var import_protocols8 = require("@dxos/protocols");
|
|
223
225
|
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -236,117 +238,128 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
|
|
|
236
238
|
var import_tracing8 = require("@dxos/tracing");
|
|
237
239
|
var import_util10 = require("@dxos/util");
|
|
238
240
|
var import_async16 = require("@dxos/async");
|
|
239
|
-
var
|
|
241
|
+
var import_crypto2 = require("@dxos/crypto");
|
|
240
242
|
var import_invariant13 = require("@dxos/invariant");
|
|
243
|
+
var import_keys11 = require("@dxos/keys");
|
|
241
244
|
var import_log14 = require("@dxos/log");
|
|
242
245
|
var import_protocols10 = require("@dxos/protocols");
|
|
243
246
|
var import_proto3 = require("@dxos/protocols/proto");
|
|
244
|
-
var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
245
|
-
var import_teleport2 = require("@dxos/teleport");
|
|
246
|
-
var import_context12 = require("@dxos/context");
|
|
247
247
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
248
|
+
var import_context11 = require("@dxos/context");
|
|
249
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
248
250
|
var import_async17 = require("@dxos/async");
|
|
249
|
-
var
|
|
250
|
-
var import_crypto2 = require("@dxos/crypto");
|
|
251
|
+
var import_context12 = require("@dxos/context");
|
|
251
252
|
var import_invariant14 = require("@dxos/invariant");
|
|
252
|
-
var import_keys11 = require("@dxos/keys");
|
|
253
253
|
var import_log15 = require("@dxos/log");
|
|
254
254
|
var import_protocols11 = require("@dxos/protocols");
|
|
255
255
|
var import_proto4 = require("@dxos/protocols/proto");
|
|
256
|
-
var
|
|
257
|
-
var
|
|
258
|
-
var
|
|
256
|
+
var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
257
|
+
var import_teleport2 = require("@dxos/teleport");
|
|
258
|
+
var import_async18 = require("@dxos/async");
|
|
259
|
+
var import_context13 = require("@dxos/context");
|
|
260
|
+
var import_crypto3 = require("@dxos/crypto");
|
|
259
261
|
var import_invariant15 = require("@dxos/invariant");
|
|
260
262
|
var import_keys12 = require("@dxos/keys");
|
|
261
263
|
var import_log16 = require("@dxos/log");
|
|
264
|
+
var import_protocols12 = require("@dxos/protocols");
|
|
265
|
+
var import_proto5 = require("@dxos/protocols/proto");
|
|
266
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
267
|
+
var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
268
|
+
var import_teleport3 = require("@dxos/teleport");
|
|
269
|
+
var import_async19 = require("@dxos/async");
|
|
270
|
+
var import_log17 = require("@dxos/log");
|
|
271
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
272
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
273
|
+
var import_keys13 = require("@dxos/keys");
|
|
274
|
+
var import_log18 = require("@dxos/log");
|
|
262
275
|
var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
263
276
|
var import_util11 = require("@dxos/util");
|
|
264
277
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
265
|
-
var
|
|
266
|
-
var
|
|
278
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
279
|
+
var import_credentials18 = require("@dxos/credentials");
|
|
267
280
|
var import_feed_store5 = require("@dxos/feed-store");
|
|
268
|
-
var
|
|
269
|
-
var
|
|
270
|
-
var
|
|
271
|
-
var
|
|
272
|
-
var
|
|
273
|
-
var
|
|
281
|
+
var import_invariant17 = require("@dxos/invariant");
|
|
282
|
+
var import_log19 = require("@dxos/log");
|
|
283
|
+
var import_protocols13 = require("@dxos/protocols");
|
|
284
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
285
|
+
var import_credentials19 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
286
|
+
var import_async20 = require("@dxos/async");
|
|
274
287
|
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
275
288
|
var import_context14 = require("@dxos/context");
|
|
276
|
-
var
|
|
289
|
+
var import_credentials20 = require("@dxos/credentials");
|
|
277
290
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
278
|
-
var import_invariant17 = require("@dxos/invariant");
|
|
279
|
-
var import_keys13 = require("@dxos/keys");
|
|
280
|
-
var import_log18 = require("@dxos/log");
|
|
281
|
-
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
282
|
-
var import_credentials20 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
283
291
|
var import_invariant18 = require("@dxos/invariant");
|
|
292
|
+
var import_keys14 = require("@dxos/keys");
|
|
293
|
+
var import_log20 = require("@dxos/log");
|
|
294
|
+
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
295
|
+
var import_credentials21 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
296
|
+
var import_invariant19 = require("@dxos/invariant");
|
|
284
297
|
var import_lock_file = require("@dxos/lock-file");
|
|
285
|
-
var
|
|
298
|
+
var import_log21 = require("@dxos/log");
|
|
286
299
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
287
300
|
var import_debug5 = require("@dxos/debug");
|
|
288
301
|
var import_rpc = require("@dxos/rpc");
|
|
289
302
|
var import_tracing9 = require("@dxos/tracing");
|
|
290
|
-
var
|
|
303
|
+
var import_async21 = require("@dxos/async");
|
|
291
304
|
var import_context15 = require("@dxos/context");
|
|
292
|
-
var
|
|
305
|
+
var import_credentials22 = require("@dxos/credentials");
|
|
293
306
|
var import_debug6 = require("@dxos/debug");
|
|
294
307
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
295
308
|
var import_edge_client2 = require("@dxos/edge-client");
|
|
296
309
|
var import_feed_store6 = require("@dxos/feed-store");
|
|
297
|
-
var
|
|
310
|
+
var import_invariant20 = require("@dxos/invariant");
|
|
298
311
|
var import_keyring = require("@dxos/keyring");
|
|
299
|
-
var
|
|
300
|
-
var
|
|
301
|
-
var
|
|
302
|
-
var
|
|
312
|
+
var import_keys15 = require("@dxos/keys");
|
|
313
|
+
var import_log22 = require("@dxos/log");
|
|
314
|
+
var import_protocols14 = require("@dxos/protocols");
|
|
315
|
+
var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
|
|
303
316
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
304
317
|
var import_tracing10 = require("@dxos/tracing");
|
|
305
318
|
var import_util12 = require("@dxos/util");
|
|
306
|
-
var
|
|
319
|
+
var import_protocols15 = require("@dxos/protocols");
|
|
307
320
|
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
308
321
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
309
322
|
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
310
323
|
var import_config3 = require("@dxos/protocols/proto/dxos/config");
|
|
311
324
|
var import_util13 = require("@dxos/util");
|
|
312
325
|
var import_node_path = __toESM(require("node:path"));
|
|
313
|
-
var
|
|
326
|
+
var import_keys16 = require("@dxos/keys");
|
|
314
327
|
var import_kv_store = require("@dxos/kv-store");
|
|
315
328
|
var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
316
|
-
var
|
|
317
|
-
var
|
|
318
|
-
var
|
|
329
|
+
var import_invariant21 = require("@dxos/invariant");
|
|
330
|
+
var import_log23 = require("@dxos/log");
|
|
331
|
+
var import_protocols16 = require("@dxos/protocols");
|
|
319
332
|
var import_util14 = require("@dxos/util");
|
|
320
|
-
var
|
|
333
|
+
var import_async22 = require("@dxos/async");
|
|
321
334
|
var import_client_protocol8 = require("@dxos/client-protocol");
|
|
322
335
|
var import_context16 = require("@dxos/context");
|
|
323
336
|
var import_edge_client3 = require("@dxos/edge-client");
|
|
324
|
-
var
|
|
325
|
-
var
|
|
326
|
-
var
|
|
337
|
+
var import_invariant22 = require("@dxos/invariant");
|
|
338
|
+
var import_keys17 = require("@dxos/keys");
|
|
339
|
+
var import_log24 = require("@dxos/log");
|
|
327
340
|
var import_messaging = require("@dxos/messaging");
|
|
328
341
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
329
|
-
var
|
|
330
|
-
var
|
|
342
|
+
var import_protocols17 = require("@dxos/protocols");
|
|
343
|
+
var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
|
|
331
344
|
var import_tracing11 = require("@dxos/tracing");
|
|
332
345
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
333
|
-
var
|
|
346
|
+
var import_async23 = require("@dxos/async");
|
|
334
347
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
335
|
-
var
|
|
336
|
-
var
|
|
337
|
-
var
|
|
348
|
+
var import_invariant23 = require("@dxos/invariant");
|
|
349
|
+
var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
|
|
350
|
+
var import_async24 = require("@dxos/async");
|
|
338
351
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
339
|
-
var
|
|
352
|
+
var import_keys18 = require("@dxos/keys");
|
|
340
353
|
var import_util15 = require("@dxos/util");
|
|
341
|
-
var
|
|
354
|
+
var import_async25 = require("@dxos/async");
|
|
342
355
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
343
|
-
var
|
|
344
|
-
var
|
|
345
|
-
var
|
|
356
|
+
var import_keys19 = require("@dxos/keys");
|
|
357
|
+
var import_log25 = require("@dxos/log");
|
|
358
|
+
var import_services22 = require("@dxos/protocols/proto/dxos/client/services");
|
|
346
359
|
var import_util16 = require("@dxos/util");
|
|
347
360
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
348
361
|
var import_codec_protobuf16 = require("@dxos/codec-protobuf");
|
|
349
|
-
var
|
|
362
|
+
var import_services23 = require("@dxos/protocols/proto/dxos/client/services");
|
|
350
363
|
var import_util17 = require("@dxos/util");
|
|
351
364
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/feeds.ts";
|
|
352
365
|
var subscribeToFeeds = ({ feedStore, spaceManager }, { feedKeys }) => {
|
|
@@ -706,7 +719,7 @@ var DevtoolsServiceImpl = class {
|
|
|
706
719
|
});
|
|
707
720
|
}
|
|
708
721
|
};
|
|
709
|
-
var DXOS_VERSION = "0.6.
|
|
722
|
+
var DXOS_VERSION = "0.6.13-main.09887cd";
|
|
710
723
|
var getPlatform = () => {
|
|
711
724
|
if (process.browser) {
|
|
712
725
|
if (typeof window !== "undefined") {
|
|
@@ -2541,12 +2554,36 @@ var DataSpaceManager = class extends import_context7.Resource {
|
|
|
2541
2554
|
}
|
|
2542
2555
|
});
|
|
2543
2556
|
}
|
|
2557
|
+
async setSpaceEdgeReplicationSetting(spaceKey, setting) {
|
|
2558
|
+
const space = this._spaces.get(spaceKey);
|
|
2559
|
+
(0, import_invariant7.invariant)(space, "Space not found.", {
|
|
2560
|
+
F: __dxlog_file9,
|
|
2561
|
+
L: 399,
|
|
2562
|
+
S: this,
|
|
2563
|
+
A: [
|
|
2564
|
+
"space",
|
|
2565
|
+
"'Space not found.'"
|
|
2566
|
+
]
|
|
2567
|
+
});
|
|
2568
|
+
await this._metadataStore.setSpaceEdgeReplicationSetting(spaceKey, setting);
|
|
2569
|
+
if (space.isOpen) {
|
|
2570
|
+
switch (setting) {
|
|
2571
|
+
case import_metadata.EdgeReplicationSetting.DISABLED:
|
|
2572
|
+
await this._echoEdgeReplicator?.disconnectFromSpace(space.id);
|
|
2573
|
+
break;
|
|
2574
|
+
case import_metadata.EdgeReplicationSetting.ENABLED:
|
|
2575
|
+
await this._echoEdgeReplicator?.connectToSpace(space.id);
|
|
2576
|
+
break;
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
space.stateUpdate.emit();
|
|
2580
|
+
}
|
|
2544
2581
|
async _constructSpace(metadata) {
|
|
2545
2582
|
(0, import_log9.log)("construct space", {
|
|
2546
2583
|
metadata
|
|
2547
2584
|
}, {
|
|
2548
2585
|
F: __dxlog_file9,
|
|
2549
|
-
L:
|
|
2586
|
+
L: 418,
|
|
2550
2587
|
S: this,
|
|
2551
2588
|
C: (f, a) => f(...a)
|
|
2552
2589
|
});
|
|
@@ -2590,7 +2627,7 @@ var DataSpaceManager = class extends import_context7.Resource {
|
|
|
2590
2627
|
err
|
|
2591
2628
|
}, {
|
|
2592
2629
|
F: __dxlog_file9,
|
|
2593
|
-
L:
|
|
2630
|
+
L: 460,
|
|
2594
2631
|
S: this,
|
|
2595
2632
|
C: (f, a) => f(...a)
|
|
2596
2633
|
});
|
|
@@ -2600,7 +2637,7 @@ var DataSpaceManager = class extends import_context7.Resource {
|
|
|
2600
2637
|
onAuthFailure: () => {
|
|
2601
2638
|
import_log9.log.warn("auth failure", void 0, {
|
|
2602
2639
|
F: __dxlog_file9,
|
|
2603
|
-
L:
|
|
2640
|
+
L: 465,
|
|
2604
2641
|
S: this,
|
|
2605
2642
|
C: (f, a) => f(...a)
|
|
2606
2643
|
});
|
|
@@ -2633,7 +2670,7 @@ var DataSpaceManager = class extends import_context7.Resource {
|
|
|
2633
2670
|
space: space.key
|
|
2634
2671
|
}, {
|
|
2635
2672
|
F: __dxlog_file9,
|
|
2636
|
-
L:
|
|
2673
|
+
L: 492,
|
|
2637
2674
|
S: this,
|
|
2638
2675
|
C: (f, a) => f(...a)
|
|
2639
2676
|
});
|
|
@@ -2644,7 +2681,7 @@ var DataSpaceManager = class extends import_context7.Resource {
|
|
|
2644
2681
|
open: this._lifecycleState === import_context7.LifecycleState.OPEN
|
|
2645
2682
|
}, {
|
|
2646
2683
|
F: __dxlog_file9,
|
|
2647
|
-
L:
|
|
2684
|
+
L: 495,
|
|
2648
2685
|
S: this,
|
|
2649
2686
|
C: (f, a) => f(...a)
|
|
2650
2687
|
});
|
|
@@ -2663,7 +2700,7 @@ var DataSpaceManager = class extends import_context7.Resource {
|
|
|
2663
2700
|
space: space.key
|
|
2664
2701
|
}, {
|
|
2665
2702
|
F: __dxlog_file9,
|
|
2666
|
-
L:
|
|
2703
|
+
L: 503,
|
|
2667
2704
|
S: this,
|
|
2668
2705
|
C: (f, a) => f(...a)
|
|
2669
2706
|
});
|
|
@@ -2675,10 +2712,25 @@ var DataSpaceManager = class extends import_context7.Resource {
|
|
|
2675
2712
|
edgeFeatures: this._edgeFeatures
|
|
2676
2713
|
});
|
|
2677
2714
|
dataSpace.postOpen.append(async () => {
|
|
2678
|
-
|
|
2715
|
+
const setting = dataSpace.getEdgeReplicationSetting();
|
|
2716
|
+
if (setting === import_metadata.EdgeReplicationSetting.ENABLED) {
|
|
2717
|
+
await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
|
|
2718
|
+
} else if (this._echoEdgeReplicator) {
|
|
2719
|
+
(0, import_log9.log)("not connecting EchoEdgeReplicator because of EdgeReplicationSetting", {
|
|
2720
|
+
spaceId: dataSpace.id
|
|
2721
|
+
}, {
|
|
2722
|
+
F: __dxlog_file9,
|
|
2723
|
+
L: 516,
|
|
2724
|
+
S: this,
|
|
2725
|
+
C: (f, a) => f(...a)
|
|
2726
|
+
});
|
|
2727
|
+
}
|
|
2679
2728
|
});
|
|
2680
2729
|
dataSpace.preClose.append(async () => {
|
|
2681
|
-
|
|
2730
|
+
const setting = dataSpace.getEdgeReplicationSetting();
|
|
2731
|
+
if (setting === import_metadata.EdgeReplicationSetting.ENABLED) {
|
|
2732
|
+
await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
|
|
2733
|
+
}
|
|
2682
2734
|
});
|
|
2683
2735
|
presence.newPeer.on((peerState) => {
|
|
2684
2736
|
if (dataSpace.state === import_services6.SpaceState.SPACE_READY) {
|
|
@@ -2698,7 +2750,7 @@ var DataSpaceManager = class extends import_context7.Resource {
|
|
|
2698
2750
|
space: space.key
|
|
2699
2751
|
}, {
|
|
2700
2752
|
F: __dxlog_file9,
|
|
2701
|
-
L:
|
|
2753
|
+
L: 543,
|
|
2702
2754
|
S: this,
|
|
2703
2755
|
C: (f, a) => f(...a)
|
|
2704
2756
|
});
|
|
@@ -2731,7 +2783,7 @@ var DataSpaceManager = class extends import_context7.Resource {
|
|
|
2731
2783
|
closedSessions
|
|
2732
2784
|
}, {
|
|
2733
2785
|
F: __dxlog_file9,
|
|
2734
|
-
L:
|
|
2786
|
+
L: 569,
|
|
2735
2787
|
S: this,
|
|
2736
2788
|
C: (f, a) => f(...a)
|
|
2737
2789
|
});
|
|
@@ -2746,7 +2798,7 @@ var DataSpaceManager = class extends import_context7.Resource {
|
|
|
2746
2798
|
peerId: peerState.peerId
|
|
2747
2799
|
}, {
|
|
2748
2800
|
F: __dxlog_file9,
|
|
2749
|
-
L:
|
|
2801
|
+
L: 583,
|
|
2750
2802
|
S: this,
|
|
2751
2803
|
C: (f, a) => f(...a)
|
|
2752
2804
|
});
|
|
@@ -2819,7 +2871,7 @@ var SpacesServiceImpl = class {
|
|
|
2819
2871
|
await this._updateMetrics();
|
|
2820
2872
|
return this._serializeSpace(space);
|
|
2821
2873
|
}
|
|
2822
|
-
async updateSpace({ spaceKey, state }) {
|
|
2874
|
+
async updateSpace({ spaceKey, state, edgeReplication }) {
|
|
2823
2875
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2824
2876
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug3.raise)(new import_protocols6.SpaceNotFoundError(spaceKey));
|
|
2825
2877
|
if (state) {
|
|
@@ -2834,6 +2886,9 @@ var SpacesServiceImpl = class {
|
|
|
2834
2886
|
throw new import_protocols6.ApiError("Invalid space state");
|
|
2835
2887
|
}
|
|
2836
2888
|
}
|
|
2889
|
+
if (edgeReplication !== void 0) {
|
|
2890
|
+
await dataSpaceManager.setSpaceEdgeReplicationSetting(spaceKey, edgeReplication);
|
|
2891
|
+
}
|
|
2837
2892
|
}
|
|
2838
2893
|
async updateMemberRole(request) {
|
|
2839
2894
|
const identity = this._requireIdentity();
|
|
@@ -2850,7 +2905,7 @@ var SpacesServiceImpl = class {
|
|
|
2850
2905
|
const credentials = await (0, import_credentials13.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
2851
2906
|
(0, import_invariant8.invariant)(credentials[0].credential, void 0, {
|
|
2852
2907
|
F: __dxlog_file10,
|
|
2853
|
-
L:
|
|
2908
|
+
L: 106,
|
|
2854
2909
|
S: this,
|
|
2855
2910
|
A: [
|
|
2856
2911
|
"credentials[0].credential",
|
|
@@ -2860,7 +2915,7 @@ var SpacesServiceImpl = class {
|
|
|
2860
2915
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2861
2916
|
(0, import_invariant8.invariant)((0, import_credentials13.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2862
2917
|
F: __dxlog_file10,
|
|
2863
|
-
L:
|
|
2918
|
+
L: 108,
|
|
2864
2919
|
S: this,
|
|
2865
2920
|
A: [
|
|
2866
2921
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2878,7 +2933,7 @@ var SpacesServiceImpl = class {
|
|
|
2878
2933
|
ids: spaces.map((space) => space.id)
|
|
2879
2934
|
}), {
|
|
2880
2935
|
F: __dxlog_file10,
|
|
2881
|
-
L:
|
|
2936
|
+
L: 119,
|
|
2882
2937
|
S: this,
|
|
2883
2938
|
C: (f, a) => f(...a)
|
|
2884
2939
|
});
|
|
@@ -2970,7 +3025,7 @@ var SpacesServiceImpl = class {
|
|
|
2970
3025
|
} else {
|
|
2971
3026
|
(0, import_invariant8.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
2972
3027
|
F: __dxlog_file10,
|
|
2973
|
-
L:
|
|
3028
|
+
L: 217,
|
|
2974
3029
|
S: this,
|
|
2975
3030
|
A: [
|
|
2976
3031
|
"!credential.id",
|
|
@@ -2979,7 +3034,7 @@ var SpacesServiceImpl = class {
|
|
|
2979
3034
|
});
|
|
2980
3035
|
(0, import_invariant8.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
2981
3036
|
F: __dxlog_file10,
|
|
2982
|
-
L:
|
|
3037
|
+
L: 218,
|
|
2983
3038
|
S: this,
|
|
2984
3039
|
A: [
|
|
2985
3040
|
"this._identityManager.identity",
|
|
@@ -2989,7 +3044,7 @@ var SpacesServiceImpl = class {
|
|
|
2989
3044
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
2990
3045
|
(0, import_invariant8.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
2991
3046
|
F: __dxlog_file10,
|
|
2992
|
-
L:
|
|
3047
|
+
L: 220,
|
|
2993
3048
|
S: this,
|
|
2994
3049
|
A: [
|
|
2995
3050
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -3039,7 +3094,7 @@ var SpacesServiceImpl = class {
|
|
|
3039
3094
|
const assertion = (0, import_credentials13.getCredentialAssertion)(credential);
|
|
3040
3095
|
(0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
3041
3096
|
F: __dxlog_file10,
|
|
3042
|
-
L:
|
|
3097
|
+
L: 254,
|
|
3043
3098
|
S: this,
|
|
3044
3099
|
A: [
|
|
3045
3100
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3049,7 +3104,7 @@ var SpacesServiceImpl = class {
|
|
|
3049
3104
|
const myIdentity = this._identityManager.identity;
|
|
3050
3105
|
(0, import_invariant8.invariant)(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
3051
3106
|
F: __dxlog_file10,
|
|
3052
|
-
L:
|
|
3107
|
+
L: 256,
|
|
3053
3108
|
S: this,
|
|
3054
3109
|
A: [
|
|
3055
3110
|
"myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
|
|
@@ -3111,7 +3166,8 @@ var SpacesServiceImpl = class {
|
|
|
3111
3166
|
}),
|
|
3112
3167
|
creator: space.inner.spaceState.creator?.key,
|
|
3113
3168
|
cache: space.cache,
|
|
3114
|
-
metrics: space.metrics
|
|
3169
|
+
metrics: space.metrics,
|
|
3170
|
+
edgeReplication: space.getEdgeReplicationSetting()
|
|
3115
3171
|
};
|
|
3116
3172
|
}
|
|
3117
3173
|
_requireIdentity() {
|
|
@@ -3156,7 +3212,7 @@ var Identity = class {
|
|
|
3156
3212
|
deviceKey: params.deviceKey
|
|
3157
3213
|
}, {
|
|
3158
3214
|
F: __dxlog_file11,
|
|
3159
|
-
L:
|
|
3215
|
+
L: 79,
|
|
3160
3216
|
S: this,
|
|
3161
3217
|
C: (f, a) => f(...a)
|
|
3162
3218
|
});
|
|
@@ -3197,10 +3253,13 @@ var Identity = class {
|
|
|
3197
3253
|
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
3198
3254
|
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
3199
3255
|
await this.space.spaceState.addCredentialProcessor(this._defaultSpaceStateMachine);
|
|
3256
|
+
await this.space.open(ctx);
|
|
3257
|
+
}
|
|
3258
|
+
async joinNetwork() {
|
|
3200
3259
|
if (this._edgeFeedReplicator) {
|
|
3201
3260
|
this.space.protocol.feedAdded.append(this._onFeedAdded);
|
|
3202
3261
|
}
|
|
3203
|
-
await this.space.
|
|
3262
|
+
await this.space.startProtocol();
|
|
3204
3263
|
await this._edgeFeedReplicator?.open();
|
|
3205
3264
|
}
|
|
3206
3265
|
async close(ctx) {
|
|
@@ -3252,7 +3311,7 @@ var Identity = class {
|
|
|
3252
3311
|
getIdentityCredentialSigner() {
|
|
3253
3312
|
(0, import_invariant6.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
3254
3313
|
F: __dxlog_file11,
|
|
3255
|
-
L:
|
|
3314
|
+
L: 191,
|
|
3256
3315
|
S: this,
|
|
3257
3316
|
A: [
|
|
3258
3317
|
"this._deviceStateMachine.deviceCredentialChain",
|
|
@@ -3296,20 +3355,21 @@ var Identity = class {
|
|
|
3296
3355
|
dataFeedKey
|
|
3297
3356
|
}, {
|
|
3298
3357
|
F: __dxlog_file11,
|
|
3299
|
-
L:
|
|
3358
|
+
L: 216,
|
|
3300
3359
|
S: this,
|
|
3301
3360
|
C: (f, a) => f(...a)
|
|
3302
3361
|
});
|
|
3303
3362
|
const signer = this.getIdentityCredentialSigner();
|
|
3363
|
+
const deviceCredential = await signer.createCredential({
|
|
3364
|
+
subject: deviceKey,
|
|
3365
|
+
assertion: {
|
|
3366
|
+
"@type": "dxos.halo.credentials.AuthorizedDevice",
|
|
3367
|
+
identityKey: this.identityKey,
|
|
3368
|
+
deviceKey
|
|
3369
|
+
}
|
|
3370
|
+
});
|
|
3304
3371
|
await (0, import_feed_store2.writeMessages)(this.controlPipeline.writer, [
|
|
3305
|
-
|
|
3306
|
-
subject: deviceKey,
|
|
3307
|
-
assertion: {
|
|
3308
|
-
"@type": "dxos.halo.credentials.AuthorizedDevice",
|
|
3309
|
-
identityKey: this.identityKey,
|
|
3310
|
-
deviceKey
|
|
3311
|
-
}
|
|
3312
|
-
}),
|
|
3372
|
+
deviceCredential,
|
|
3313
3373
|
await signer.createCredential({
|
|
3314
3374
|
subject: controlFeedKey,
|
|
3315
3375
|
assertion: {
|
|
@@ -3335,6 +3395,7 @@ var Identity = class {
|
|
|
3335
3395
|
credential
|
|
3336
3396
|
}
|
|
3337
3397
|
})));
|
|
3398
|
+
return deviceCredential;
|
|
3338
3399
|
}
|
|
3339
3400
|
};
|
|
3340
3401
|
_ts_decorate4([
|
|
@@ -3367,7 +3428,6 @@ var IdentityManager = class {
|
|
|
3367
3428
|
this._edgeFeatures = params.edgeFeatures;
|
|
3368
3429
|
this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
|
|
3369
3430
|
this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
|
|
3370
|
-
this._callbacks = params.callbacks;
|
|
3371
3431
|
}
|
|
3372
3432
|
get identity() {
|
|
3373
3433
|
return this._identity;
|
|
@@ -3378,7 +3438,7 @@ var IdentityManager = class {
|
|
|
3378
3438
|
id: traceId
|
|
3379
3439
|
}), {
|
|
3380
3440
|
F: __dxlog_file12,
|
|
3381
|
-
L:
|
|
3441
|
+
L: 116,
|
|
3382
3442
|
S: this,
|
|
3383
3443
|
C: (f, a) => f(...a)
|
|
3384
3444
|
});
|
|
@@ -3387,7 +3447,7 @@ var IdentityManager = class {
|
|
|
3387
3447
|
identityRecord
|
|
3388
3448
|
}, {
|
|
3389
3449
|
F: __dxlog_file12,
|
|
3390
|
-
L:
|
|
3450
|
+
L: 119,
|
|
3391
3451
|
S: this,
|
|
3392
3452
|
C: (f, a) => f(...a)
|
|
3393
3453
|
});
|
|
@@ -3400,7 +3460,7 @@ var IdentityManager = class {
|
|
|
3400
3460
|
displayName: this._identity.profileDocument?.displayName
|
|
3401
3461
|
}, {
|
|
3402
3462
|
F: __dxlog_file12,
|
|
3403
|
-
L:
|
|
3463
|
+
L: 124,
|
|
3404
3464
|
S: this,
|
|
3405
3465
|
C: (f, a) => f(...a)
|
|
3406
3466
|
});
|
|
@@ -3410,7 +3470,7 @@ var IdentityManager = class {
|
|
|
3410
3470
|
id: traceId
|
|
3411
3471
|
}), {
|
|
3412
3472
|
F: __dxlog_file12,
|
|
3413
|
-
L:
|
|
3473
|
+
L: 131,
|
|
3414
3474
|
S: this,
|
|
3415
3475
|
C: (f, a) => f(...a)
|
|
3416
3476
|
});
|
|
@@ -3418,13 +3478,13 @@ var IdentityManager = class {
|
|
|
3418
3478
|
async close() {
|
|
3419
3479
|
await this._identity?.close(new import_context8.Context(void 0, {
|
|
3420
3480
|
F: __dxlog_file12,
|
|
3421
|
-
L:
|
|
3481
|
+
L: 135
|
|
3422
3482
|
}));
|
|
3423
3483
|
}
|
|
3424
3484
|
async createIdentity({ displayName, deviceProfile } = {}) {
|
|
3425
3485
|
(0, import_invariant9.invariant)(!this._identity, "Identity already exists.", {
|
|
3426
3486
|
F: __dxlog_file12,
|
|
3427
|
-
L:
|
|
3487
|
+
L: 140,
|
|
3428
3488
|
S: this,
|
|
3429
3489
|
A: [
|
|
3430
3490
|
"!this._identity",
|
|
@@ -3433,7 +3493,7 @@ var IdentityManager = class {
|
|
|
3433
3493
|
});
|
|
3434
3494
|
(0, import_log11.log)("creating identity...", void 0, {
|
|
3435
3495
|
F: __dxlog_file12,
|
|
3436
|
-
L:
|
|
3496
|
+
L: 141,
|
|
3437
3497
|
S: this,
|
|
3438
3498
|
C: (f, a) => f(...a)
|
|
3439
3499
|
});
|
|
@@ -3451,13 +3511,13 @@ var IdentityManager = class {
|
|
|
3451
3511
|
const identity = await this._constructIdentity(identityRecord);
|
|
3452
3512
|
await identity.open(new import_context8.Context(void 0, {
|
|
3453
3513
|
F: __dxlog_file12,
|
|
3454
|
-
L:
|
|
3514
|
+
L: 156
|
|
3455
3515
|
}));
|
|
3456
3516
|
{
|
|
3457
3517
|
const generator = new import_credentials14.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
3458
3518
|
(0, import_invariant9.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
3459
3519
|
F: __dxlog_file12,
|
|
3460
|
-
L:
|
|
3520
|
+
L: 160,
|
|
3461
3521
|
S: this,
|
|
3462
3522
|
A: [
|
|
3463
3523
|
"identityRecord.haloSpace.genesisFeedKey",
|
|
@@ -3466,7 +3526,7 @@ var IdentityManager = class {
|
|
|
3466
3526
|
});
|
|
3467
3527
|
(0, import_invariant9.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
3468
3528
|
F: __dxlog_file12,
|
|
3469
|
-
L:
|
|
3529
|
+
L: 161,
|
|
3470
3530
|
S: this,
|
|
3471
3531
|
A: [
|
|
3472
3532
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -3505,7 +3565,7 @@ var IdentityManager = class {
|
|
|
3505
3565
|
displayName: this._identity.profileDocument?.displayName
|
|
3506
3566
|
}, {
|
|
3507
3567
|
F: __dxlog_file12,
|
|
3508
|
-
L:
|
|
3568
|
+
L: 199,
|
|
3509
3569
|
S: this,
|
|
3510
3570
|
C: (f, a) => f(...a)
|
|
3511
3571
|
});
|
|
@@ -3516,7 +3576,7 @@ var IdentityManager = class {
|
|
|
3516
3576
|
profile: identity.profileDocument
|
|
3517
3577
|
}, {
|
|
3518
3578
|
F: __dxlog_file12,
|
|
3519
|
-
L:
|
|
3579
|
+
L: 205,
|
|
3520
3580
|
S: this,
|
|
3521
3581
|
C: (f, a) => f(...a)
|
|
3522
3582
|
});
|
|
@@ -3546,20 +3606,20 @@ var IdentityManager = class {
|
|
|
3546
3606
|
};
|
|
3547
3607
|
}
|
|
3548
3608
|
/**
|
|
3549
|
-
*
|
|
3609
|
+
* Prepare an identity object as the first step of acceptIdentity flow.
|
|
3550
3610
|
*/
|
|
3551
|
-
async
|
|
3611
|
+
async prepareIdentity(params) {
|
|
3552
3612
|
(0, import_log11.log)("accepting identity", {
|
|
3553
3613
|
params
|
|
3554
3614
|
}, {
|
|
3555
3615
|
F: __dxlog_file12,
|
|
3556
|
-
L:
|
|
3616
|
+
L: 244,
|
|
3557
3617
|
S: this,
|
|
3558
3618
|
C: (f, a) => f(...a)
|
|
3559
3619
|
});
|
|
3560
3620
|
(0, import_invariant9.invariant)(!this._identity, "Identity already exists.", {
|
|
3561
3621
|
F: __dxlog_file12,
|
|
3562
|
-
L:
|
|
3622
|
+
L: 245,
|
|
3563
3623
|
S: this,
|
|
3564
3624
|
A: [
|
|
3565
3625
|
"!this._identity",
|
|
@@ -3580,23 +3640,32 @@ var IdentityManager = class {
|
|
|
3580
3640
|
const identity = await this._constructIdentity(identityRecord);
|
|
3581
3641
|
await identity.open(new import_context8.Context(void 0, {
|
|
3582
3642
|
F: __dxlog_file12,
|
|
3583
|
-
L:
|
|
3643
|
+
L: 259
|
|
3584
3644
|
}));
|
|
3645
|
+
return {
|
|
3646
|
+
identity,
|
|
3647
|
+
identityRecord
|
|
3648
|
+
};
|
|
3649
|
+
}
|
|
3650
|
+
/**
|
|
3651
|
+
* Accept an existing identity. Expects its device key to be authorized (now or later).
|
|
3652
|
+
*/
|
|
3653
|
+
async acceptIdentity(identity, identityRecord, profile) {
|
|
3585
3654
|
this._identity = identity;
|
|
3586
|
-
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
3587
3655
|
await this._identity.ready();
|
|
3656
|
+
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
3588
3657
|
import_log11.log.trace("dxos.halo.identity", {
|
|
3589
|
-
identityKey:
|
|
3658
|
+
identityKey: this._identity.identityKey,
|
|
3590
3659
|
displayName: this._identity.profileDocument?.displayName
|
|
3591
3660
|
}, {
|
|
3592
3661
|
F: __dxlog_file12,
|
|
3593
|
-
L:
|
|
3662
|
+
L: 273,
|
|
3594
3663
|
S: this,
|
|
3595
3664
|
C: (f, a) => f(...a)
|
|
3596
3665
|
});
|
|
3597
3666
|
await this.updateDeviceProfile({
|
|
3598
3667
|
...this.createDefaultDeviceProfile(),
|
|
3599
|
-
...
|
|
3668
|
+
...profile
|
|
3600
3669
|
});
|
|
3601
3670
|
this.stateUpdate.emit();
|
|
3602
3671
|
(0, import_log11.log)("accepted identity", {
|
|
@@ -3604,11 +3673,10 @@ var IdentityManager = class {
|
|
|
3604
3673
|
deviceKey: identity.deviceKey
|
|
3605
3674
|
}, {
|
|
3606
3675
|
F: __dxlog_file12,
|
|
3607
|
-
L:
|
|
3676
|
+
L: 284,
|
|
3608
3677
|
S: this,
|
|
3609
3678
|
C: (f, a) => f(...a)
|
|
3610
3679
|
});
|
|
3611
|
-
return identity;
|
|
3612
3680
|
}
|
|
3613
3681
|
/**
|
|
3614
3682
|
* Update the profile document of an existing identity.
|
|
@@ -3616,7 +3684,7 @@ var IdentityManager = class {
|
|
|
3616
3684
|
async updateProfile(profile) {
|
|
3617
3685
|
(0, import_invariant9.invariant)(this._identity, "Identity not initialized.", {
|
|
3618
3686
|
F: __dxlog_file12,
|
|
3619
|
-
L:
|
|
3687
|
+
L: 291,
|
|
3620
3688
|
S: this,
|
|
3621
3689
|
A: [
|
|
3622
3690
|
"this._identity",
|
|
@@ -3647,7 +3715,7 @@ var IdentityManager = class {
|
|
|
3647
3715
|
async updateDeviceProfile(profile) {
|
|
3648
3716
|
(0, import_invariant9.invariant)(this._identity, "Identity not initialized.", {
|
|
3649
3717
|
F: __dxlog_file12,
|
|
3650
|
-
L:
|
|
3718
|
+
L: 308,
|
|
3651
3719
|
S: this,
|
|
3652
3720
|
A: [
|
|
3653
3721
|
"this._identity",
|
|
@@ -3683,7 +3751,7 @@ var IdentityManager = class {
|
|
|
3683
3751
|
async _constructIdentity(identityRecord) {
|
|
3684
3752
|
(0, import_invariant9.invariant)(!this._identity, void 0, {
|
|
3685
3753
|
F: __dxlog_file12,
|
|
3686
|
-
L:
|
|
3754
|
+
L: 334,
|
|
3687
3755
|
S: this,
|
|
3688
3756
|
A: [
|
|
3689
3757
|
"!this._identity",
|
|
@@ -3694,7 +3762,7 @@ var IdentityManager = class {
|
|
|
3694
3762
|
identityRecord
|
|
3695
3763
|
}, {
|
|
3696
3764
|
F: __dxlog_file12,
|
|
3697
|
-
L:
|
|
3765
|
+
L: 335,
|
|
3698
3766
|
S: this,
|
|
3699
3767
|
C: (f, a) => f(...a)
|
|
3700
3768
|
});
|
|
@@ -3709,7 +3777,7 @@ var IdentityManager = class {
|
|
|
3709
3777
|
});
|
|
3710
3778
|
(0, import_invariant9.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
3711
3779
|
F: __dxlog_file12,
|
|
3712
|
-
L:
|
|
3780
|
+
L: 348,
|
|
3713
3781
|
S: this,
|
|
3714
3782
|
A: [
|
|
3715
3783
|
"identityRecord.haloSpace.controlFeedKey",
|
|
@@ -3721,7 +3789,7 @@ var IdentityManager = class {
|
|
|
3721
3789
|
});
|
|
3722
3790
|
(0, import_invariant9.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
3723
3791
|
F: __dxlog_file12,
|
|
3724
|
-
L:
|
|
3792
|
+
L: 352,
|
|
3725
3793
|
S: this,
|
|
3726
3794
|
A: [
|
|
3727
3795
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -3758,11 +3826,10 @@ var IdentityManager = class {
|
|
|
3758
3826
|
identityKey: identityRecord.identityKey
|
|
3759
3827
|
}, {
|
|
3760
3828
|
F: __dxlog_file12,
|
|
3761
|
-
L:
|
|
3829
|
+
L: 381,
|
|
3762
3830
|
S: this,
|
|
3763
3831
|
C: (f, a) => f(...a)
|
|
3764
3832
|
});
|
|
3765
|
-
this._callbacks?.onIdentityConstruction?.(identity);
|
|
3766
3833
|
if (identityRecord.haloSpace.controlTimeframe) {
|
|
3767
3834
|
identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
|
|
3768
3835
|
}
|
|
@@ -4131,13 +4198,14 @@ var DataSpace = class {
|
|
|
4131
4198
|
F: __dxlog_file14,
|
|
4132
4199
|
L: 244
|
|
4133
4200
|
}));
|
|
4201
|
+
await this._inner.startProtocol();
|
|
4134
4202
|
await this._edgeFeedReplicator?.open();
|
|
4135
4203
|
this._state = import_services4.SpaceState.SPACE_CONTROL_ONLY;
|
|
4136
4204
|
(0, import_log4.log)("new state", {
|
|
4137
4205
|
state: import_services4.SpaceState[this._state]
|
|
4138
4206
|
}, {
|
|
4139
4207
|
F: __dxlog_file14,
|
|
4140
|
-
L:
|
|
4208
|
+
L: 250,
|
|
4141
4209
|
S: this,
|
|
4142
4210
|
C: (f, a) => f(...a)
|
|
4143
4211
|
});
|
|
@@ -4157,14 +4225,14 @@ var DataSpace = class {
|
|
|
4157
4225
|
state: import_services4.SpaceState[this._state]
|
|
4158
4226
|
}, {
|
|
4159
4227
|
F: __dxlog_file14,
|
|
4160
|
-
L:
|
|
4228
|
+
L: 269,
|
|
4161
4229
|
S: this,
|
|
4162
4230
|
C: (f, a) => f(...a)
|
|
4163
4231
|
});
|
|
4164
4232
|
await this._ctx.dispose();
|
|
4165
4233
|
this._ctx = new import_context4.Context(void 0, {
|
|
4166
4234
|
F: __dxlog_file14,
|
|
4167
|
-
L:
|
|
4235
|
+
L: 271
|
|
4168
4236
|
});
|
|
4169
4237
|
if (this._edgeFeedReplicator) {
|
|
4170
4238
|
this.inner.protocol.feedAdded.remove(this._onFeedAdded);
|
|
@@ -4197,7 +4265,7 @@ var DataSpace = class {
|
|
|
4197
4265
|
if (err instanceof import_protocols3.CancelledError || err instanceof import_context4.ContextDisposedError) {
|
|
4198
4266
|
(0, import_log4.log)("data pipeline initialization cancelled", err, {
|
|
4199
4267
|
F: __dxlog_file14,
|
|
4200
|
-
L:
|
|
4268
|
+
L: 309,
|
|
4201
4269
|
S: this,
|
|
4202
4270
|
C: (f, a) => f(...a)
|
|
4203
4271
|
});
|
|
@@ -4205,7 +4273,7 @@ var DataSpace = class {
|
|
|
4205
4273
|
}
|
|
4206
4274
|
import_log4.log.error("Error initializing data pipeline", err, {
|
|
4207
4275
|
F: __dxlog_file14,
|
|
4208
|
-
L:
|
|
4276
|
+
L: 313,
|
|
4209
4277
|
S: this,
|
|
4210
4278
|
C: (f, a) => f(...a)
|
|
4211
4279
|
});
|
|
@@ -4214,7 +4282,7 @@ var DataSpace = class {
|
|
|
4214
4282
|
state: import_services4.SpaceState[this._state]
|
|
4215
4283
|
}, {
|
|
4216
4284
|
F: __dxlog_file14,
|
|
4217
|
-
L:
|
|
4285
|
+
L: 315,
|
|
4218
4286
|
S: this,
|
|
4219
4287
|
C: (f, a) => f(...a)
|
|
4220
4288
|
});
|
|
@@ -4234,13 +4302,13 @@ var DataSpace = class {
|
|
|
4234
4302
|
state: import_services4.SpaceState[this._state]
|
|
4235
4303
|
}, {
|
|
4236
4304
|
F: __dxlog_file14,
|
|
4237
|
-
L:
|
|
4305
|
+
L: 331,
|
|
4238
4306
|
S: this,
|
|
4239
4307
|
C: (f, a) => f(...a)
|
|
4240
4308
|
});
|
|
4241
4309
|
(0, import_log4.log)("initializing control pipeline", void 0, {
|
|
4242
4310
|
F: __dxlog_file14,
|
|
4243
|
-
L:
|
|
4311
|
+
L: 333,
|
|
4244
4312
|
S: this,
|
|
4245
4313
|
C: (f, a) => f(...a)
|
|
4246
4314
|
});
|
|
@@ -4249,21 +4317,21 @@ var DataSpace = class {
|
|
|
4249
4317
|
const ready = this.stateUpdate.waitForCondition(() => this._state === import_services4.SpaceState.SPACE_READY);
|
|
4250
4318
|
(0, import_log4.log)("initializing automerge root", void 0, {
|
|
4251
4319
|
F: __dxlog_file14,
|
|
4252
|
-
L:
|
|
4320
|
+
L: 341,
|
|
4253
4321
|
S: this,
|
|
4254
4322
|
C: (f, a) => f(...a)
|
|
4255
4323
|
});
|
|
4256
4324
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4257
4325
|
(0, import_log4.log)("waiting for space to be ready", void 0, {
|
|
4258
4326
|
F: __dxlog_file14,
|
|
4259
|
-
L:
|
|
4327
|
+
L: 345,
|
|
4260
4328
|
S: this,
|
|
4261
4329
|
C: (f, a) => f(...a)
|
|
4262
4330
|
});
|
|
4263
4331
|
await ready;
|
|
4264
4332
|
(0, import_log4.log)("space is ready", void 0, {
|
|
4265
4333
|
F: __dxlog_file14,
|
|
4266
|
-
L:
|
|
4334
|
+
L: 347,
|
|
4267
4335
|
S: this,
|
|
4268
4336
|
C: (f, a) => f(...a)
|
|
4269
4337
|
});
|
|
@@ -4275,7 +4343,7 @@ var DataSpace = class {
|
|
|
4275
4343
|
state: import_services4.SpaceState[this._state]
|
|
4276
4344
|
}, {
|
|
4277
4345
|
F: __dxlog_file14,
|
|
4278
|
-
L:
|
|
4346
|
+
L: 354,
|
|
4279
4347
|
S: this,
|
|
4280
4348
|
C: (f, a) => f(...a)
|
|
4281
4349
|
});
|
|
@@ -4292,7 +4360,7 @@ var DataSpace = class {
|
|
|
4292
4360
|
await this._createWritableFeeds();
|
|
4293
4361
|
(0, import_log4.log)("writable feeds created", void 0, {
|
|
4294
4362
|
F: __dxlog_file14,
|
|
4295
|
-
L:
|
|
4363
|
+
L: 371,
|
|
4296
4364
|
S: this,
|
|
4297
4365
|
C: (f, a) => f(...a)
|
|
4298
4366
|
});
|
|
@@ -4346,7 +4414,7 @@ var DataSpace = class {
|
|
|
4346
4414
|
count: credentials.length
|
|
4347
4415
|
}, {
|
|
4348
4416
|
F: __dxlog_file14,
|
|
4349
|
-
L:
|
|
4417
|
+
L: 429,
|
|
4350
4418
|
S: this,
|
|
4351
4419
|
C: (f, a) => f(...a)
|
|
4352
4420
|
});
|
|
@@ -4357,14 +4425,14 @@ var DataSpace = class {
|
|
|
4357
4425
|
});
|
|
4358
4426
|
(0, import_log4.log)("credentials notarized", void 0, {
|
|
4359
4427
|
F: __dxlog_file14,
|
|
4360
|
-
L:
|
|
4428
|
+
L: 433,
|
|
4361
4429
|
S: this,
|
|
4362
4430
|
C: (f, a) => f(...a)
|
|
4363
4431
|
});
|
|
4364
4432
|
} catch (err) {
|
|
4365
4433
|
import_log4.log.error("error notarizing credentials for feed admission", err, {
|
|
4366
4434
|
F: __dxlog_file14,
|
|
4367
|
-
L:
|
|
4435
|
+
L: 435,
|
|
4368
4436
|
S: this,
|
|
4369
4437
|
C: (f, a) => f(...a)
|
|
4370
4438
|
});
|
|
@@ -4379,7 +4447,7 @@ var DataSpace = class {
|
|
|
4379
4447
|
rootUrl
|
|
4380
4448
|
}, {
|
|
4381
4449
|
F: __dxlog_file14,
|
|
4382
|
-
L:
|
|
4450
|
+
L: 445,
|
|
4383
4451
|
S: this,
|
|
4384
4452
|
C: (f, a) => f(...a)
|
|
4385
4453
|
});
|
|
@@ -4431,7 +4499,7 @@ var DataSpace = class {
|
|
|
4431
4499
|
err
|
|
4432
4500
|
}, {
|
|
4433
4501
|
F: __dxlog_file14,
|
|
4434
|
-
L:
|
|
4502
|
+
L: 488,
|
|
4435
4503
|
S: this,
|
|
4436
4504
|
C: (f, a) => f(...a)
|
|
4437
4505
|
});
|
|
@@ -4521,12 +4589,15 @@ var DataSpace = class {
|
|
|
4521
4589
|
state: import_services4.SpaceState[this._state]
|
|
4522
4590
|
}, {
|
|
4523
4591
|
F: __dxlog_file14,
|
|
4524
|
-
L:
|
|
4592
|
+
L: 570,
|
|
4525
4593
|
S: this,
|
|
4526
4594
|
C: (f, a) => f(...a)
|
|
4527
4595
|
});
|
|
4528
4596
|
this.stateUpdate.emit();
|
|
4529
4597
|
}
|
|
4598
|
+
getEdgeReplicationSetting() {
|
|
4599
|
+
return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
|
|
4600
|
+
}
|
|
4530
4601
|
};
|
|
4531
4602
|
_ts_decorate6([
|
|
4532
4603
|
import_tracing3.trace.info()
|
|
@@ -4603,7 +4674,7 @@ var DeviceInvitationProtocol = class {
|
|
|
4603
4674
|
async admit(_, request) {
|
|
4604
4675
|
(0, import_invariant11.invariant)(request.device, void 0, {
|
|
4605
4676
|
F: __dxlog_file15,
|
|
4606
|
-
L:
|
|
4677
|
+
L: 51,
|
|
4607
4678
|
S: this,
|
|
4608
4679
|
A: [
|
|
4609
4680
|
"request.device",
|
|
@@ -4611,13 +4682,23 @@ var DeviceInvitationProtocol = class {
|
|
|
4611
4682
|
]
|
|
4612
4683
|
});
|
|
4613
4684
|
const identity = this._getIdentity();
|
|
4614
|
-
await identity.admitDevice(request.device);
|
|
4685
|
+
const credential = await identity.admitDevice(request.device);
|
|
4686
|
+
(0, import_invariant11.invariant)((0, import_credentials17.getCredentialAssertion)(credential)["@type"] === "dxos.halo.credentials.AuthorizedDevice", void 0, {
|
|
4687
|
+
F: __dxlog_file15,
|
|
4688
|
+
L: 54,
|
|
4689
|
+
S: this,
|
|
4690
|
+
A: [
|
|
4691
|
+
"getCredentialAssertion(credential)['@type'] === 'dxos.halo.credentials.AuthorizedDevice'",
|
|
4692
|
+
""
|
|
4693
|
+
]
|
|
4694
|
+
});
|
|
4615
4695
|
return {
|
|
4616
4696
|
device: {
|
|
4617
4697
|
identityKey: identity.identityKey,
|
|
4618
4698
|
haloSpaceKey: identity.haloSpaceKey,
|
|
4619
4699
|
genesisFeedKey: identity.haloGenesisFeedKey,
|
|
4620
|
-
controlTimeframe: identity.controlPipeline.state.timeframe
|
|
4700
|
+
controlTimeframe: identity.controlPipeline.state.timeframe,
|
|
4701
|
+
credential
|
|
4621
4702
|
}
|
|
4622
4703
|
};
|
|
4623
4704
|
}
|
|
@@ -4649,7 +4730,7 @@ var DeviceInvitationProtocol = class {
|
|
|
4649
4730
|
async accept(response, request) {
|
|
4650
4731
|
(0, import_invariant11.invariant)(response.device, void 0, {
|
|
4651
4732
|
F: __dxlog_file15,
|
|
4652
|
-
L:
|
|
4733
|
+
L: 98,
|
|
4653
4734
|
S: this,
|
|
4654
4735
|
A: [
|
|
4655
4736
|
"response.device",
|
|
@@ -4659,7 +4740,7 @@ var DeviceInvitationProtocol = class {
|
|
|
4659
4740
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
4660
4741
|
(0, import_invariant11.invariant)(request.device, void 0, {
|
|
4661
4742
|
F: __dxlog_file15,
|
|
4662
|
-
L:
|
|
4743
|
+
L: 101,
|
|
4663
4744
|
S: this,
|
|
4664
4745
|
A: [
|
|
4665
4746
|
"request.device",
|
|
@@ -4675,7 +4756,8 @@ var DeviceInvitationProtocol = class {
|
|
|
4675
4756
|
controlFeedKey,
|
|
4676
4757
|
dataFeedKey,
|
|
4677
4758
|
controlTimeframe,
|
|
4678
|
-
deviceProfile: profile
|
|
4759
|
+
deviceProfile: profile,
|
|
4760
|
+
authorizedDeviceCredential: response.device.credential
|
|
4679
4761
|
});
|
|
4680
4762
|
return {
|
|
4681
4763
|
identityKey
|
|
@@ -4683,39 +4765,189 @@ var DeviceInvitationProtocol = class {
|
|
|
4683
4765
|
}
|
|
4684
4766
|
};
|
|
4685
4767
|
var stateToString = (state) => {
|
|
4686
|
-
return Object.entries(
|
|
4768
|
+
return Object.entries(import_services13.Invitation.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
|
|
4687
4769
|
};
|
|
4688
4770
|
var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
|
|
4689
4771
|
let guard;
|
|
4690
|
-
return (0,
|
|
4772
|
+
return (0, import_context11.cancelWithContext)(ctx, (async () => {
|
|
4691
4773
|
guard = await mutex.acquire();
|
|
4692
4774
|
if (ctx.disposed) {
|
|
4693
4775
|
guard.release();
|
|
4694
4776
|
guard = void 0;
|
|
4695
|
-
throw new
|
|
4777
|
+
throw new import_context11.ContextDisposedError();
|
|
4696
4778
|
}
|
|
4697
4779
|
return guard;
|
|
4698
4780
|
})());
|
|
4699
4781
|
};
|
|
4700
|
-
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-
|
|
4782
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
|
|
4783
|
+
var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
|
|
4784
|
+
var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
|
|
4785
|
+
var EdgeInvitationHandler = class {
|
|
4786
|
+
constructor(config, _client, _callbacks) {
|
|
4787
|
+
this._client = _client;
|
|
4788
|
+
this._callbacks = _callbacks;
|
|
4789
|
+
this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
|
|
4790
|
+
this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
|
|
4791
|
+
}
|
|
4792
|
+
handle(ctx, guardedState, protocol, deviceProfile) {
|
|
4793
|
+
if (!this._client) {
|
|
4794
|
+
(0, import_log14.log)("edge disabled", void 0, {
|
|
4795
|
+
F: __dxlog_file16,
|
|
4796
|
+
L: 65,
|
|
4797
|
+
S: this,
|
|
4798
|
+
C: (f, a) => f(...a)
|
|
4799
|
+
});
|
|
4800
|
+
return;
|
|
4801
|
+
}
|
|
4802
|
+
const invitation = guardedState.current;
|
|
4803
|
+
const spaceId = invitation.spaceId;
|
|
4804
|
+
const canBeHandledByEdge = invitation.authMethod !== import_services12.Invitation.AuthMethod.SHARED_SECRET && invitation.type === import_services12.Invitation.Type.DELEGATED && invitation.kind === import_services12.Invitation.Kind.SPACE && spaceId != null && import_keys11.SpaceId.isValid(spaceId);
|
|
4805
|
+
if (!canBeHandledByEdge) {
|
|
4806
|
+
(0, import_log14.log)("invitation could not be handled by edge", {
|
|
4807
|
+
invitation
|
|
4808
|
+
}, {
|
|
4809
|
+
F: __dxlog_file16,
|
|
4810
|
+
L: 79,
|
|
4811
|
+
S: this,
|
|
4812
|
+
C: (f, a) => f(...a)
|
|
4813
|
+
});
|
|
4814
|
+
return;
|
|
4815
|
+
}
|
|
4816
|
+
ctx.onDispose(() => {
|
|
4817
|
+
this._flowLock?.release();
|
|
4818
|
+
this._flowLock = void 0;
|
|
4819
|
+
});
|
|
4820
|
+
const tryHandleInvitation = async () => {
|
|
4821
|
+
const admissionRequest = await protocol.createAdmissionRequest(deviceProfile);
|
|
4822
|
+
if (admissionRequest.space) {
|
|
4823
|
+
try {
|
|
4824
|
+
await this._handleSpaceInvitationFlow(ctx, guardedState, admissionRequest.space, spaceId);
|
|
4825
|
+
} catch (error) {
|
|
4826
|
+
if (error instanceof import_protocols10.EdgeCallFailedError) {
|
|
4827
|
+
import_log14.log.info("join space with edge unsuccessful", {
|
|
4828
|
+
reason: error.message,
|
|
4829
|
+
retryable: error.isRetryable,
|
|
4830
|
+
after: error.retryAfterMs ?? this._calculateNextRetryMs()
|
|
4831
|
+
}, {
|
|
4832
|
+
F: __dxlog_file16,
|
|
4833
|
+
L: 95,
|
|
4834
|
+
S: this,
|
|
4835
|
+
C: (f, a) => f(...a)
|
|
4836
|
+
});
|
|
4837
|
+
if (error.isRetryable) {
|
|
4838
|
+
(0, import_async16.scheduleTask)(ctx, tryHandleInvitation, error.retryAfterMs ?? this._calculateNextRetryMs());
|
|
4839
|
+
}
|
|
4840
|
+
} else {
|
|
4841
|
+
import_log14.log.info("failed to handle invitation with edge", {
|
|
4842
|
+
error
|
|
4843
|
+
}, {
|
|
4844
|
+
F: __dxlog_file16,
|
|
4845
|
+
L: 104,
|
|
4846
|
+
S: this,
|
|
4847
|
+
C: (f, a) => f(...a)
|
|
4848
|
+
});
|
|
4849
|
+
(0, import_async16.scheduleTask)(ctx, tryHandleInvitation, this._calculateNextRetryMs());
|
|
4850
|
+
}
|
|
4851
|
+
}
|
|
4852
|
+
}
|
|
4853
|
+
};
|
|
4854
|
+
(0, import_async16.scheduleMicroTask)(ctx, tryHandleInvitation);
|
|
4855
|
+
}
|
|
4856
|
+
async _handleSpaceInvitationFlow(ctx, guardedState, admissionRequest, spaceId) {
|
|
4857
|
+
try {
|
|
4858
|
+
(0, import_log14.log)("edge invitation flow", void 0, {
|
|
4859
|
+
F: __dxlog_file16,
|
|
4860
|
+
L: 120,
|
|
4861
|
+
S: this,
|
|
4862
|
+
C: (f, a) => f(...a)
|
|
4863
|
+
});
|
|
4864
|
+
this._flowLock = await tryAcquireBeforeContextDisposed(ctx, guardedState.mutex);
|
|
4865
|
+
(0, import_log14.log)("edge invitation flow acquired the lock", void 0, {
|
|
4866
|
+
F: __dxlog_file16,
|
|
4867
|
+
L: 122,
|
|
4868
|
+
S: this,
|
|
4869
|
+
C: (f, a) => f(...a)
|
|
4870
|
+
});
|
|
4871
|
+
guardedState.set(this, import_services12.Invitation.State.CONNECTING);
|
|
4872
|
+
const response = await this._joinSpaceByInvitation(guardedState, spaceId, {
|
|
4873
|
+
identityKey: admissionRequest.identityKey.toHex(),
|
|
4874
|
+
invitationId: guardedState.current.invitationId
|
|
4875
|
+
});
|
|
4876
|
+
const admissionResponse = await this._mapToAdmissionResponse(response);
|
|
4877
|
+
await this._callbacks.onInvitationSuccess(admissionResponse, {
|
|
4878
|
+
space: admissionRequest
|
|
4879
|
+
});
|
|
4880
|
+
} catch (error) {
|
|
4881
|
+
guardedState.set(this, import_services12.Invitation.State.ERROR);
|
|
4882
|
+
throw error;
|
|
4883
|
+
} finally {
|
|
4884
|
+
this._flowLock?.release();
|
|
4885
|
+
this._flowLock = void 0;
|
|
4886
|
+
}
|
|
4887
|
+
}
|
|
4888
|
+
async _mapToAdmissionResponse(edgeResponse) {
|
|
4889
|
+
const credentialBytes = Buffer.from(edgeResponse.spaceMemberCredential, "base64");
|
|
4890
|
+
const codec = import_proto3.schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
4891
|
+
return {
|
|
4892
|
+
space: {
|
|
4893
|
+
credential: codec.decode(credentialBytes)
|
|
4894
|
+
}
|
|
4895
|
+
};
|
|
4896
|
+
}
|
|
4897
|
+
async _joinSpaceByInvitation(guardedState, spaceId, request) {
|
|
4898
|
+
(0, import_invariant13.invariant)(this._client, void 0, {
|
|
4899
|
+
F: __dxlog_file16,
|
|
4900
|
+
L: 157,
|
|
4901
|
+
S: this,
|
|
4902
|
+
A: [
|
|
4903
|
+
"this._client",
|
|
4904
|
+
""
|
|
4905
|
+
]
|
|
4906
|
+
});
|
|
4907
|
+
try {
|
|
4908
|
+
return await this._client.joinSpaceByInvitation(spaceId, request);
|
|
4909
|
+
} catch (error) {
|
|
4910
|
+
if (error instanceof import_protocols10.EdgeAuthChallengeError) {
|
|
4911
|
+
guardedState.set(this, import_services12.Invitation.State.AUTHENTICATING);
|
|
4912
|
+
const publicKey = guardedState.current.guestKeypair?.publicKey;
|
|
4913
|
+
const privateKey = guardedState.current.guestKeypair?.privateKey;
|
|
4914
|
+
if (!privateKey || !publicKey) {
|
|
4915
|
+
throw error;
|
|
4916
|
+
}
|
|
4917
|
+
const signature = await (0, import_crypto2.ed25519Signature)(privateKey, Buffer.from(error.challenge, "base64"));
|
|
4918
|
+
request.signature = Buffer.from(signature).toString("base64");
|
|
4919
|
+
return this._client.joinSpaceByInvitation(spaceId, request);
|
|
4920
|
+
} else {
|
|
4921
|
+
throw error;
|
|
4922
|
+
}
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
hasFlowLock() {
|
|
4926
|
+
return this._flowLock != null;
|
|
4927
|
+
}
|
|
4928
|
+
_calculateNextRetryMs() {
|
|
4929
|
+
return this._retryInterval + Math.random() * this._retryJitter;
|
|
4930
|
+
}
|
|
4931
|
+
};
|
|
4932
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
|
|
4701
4933
|
var OPTIONS_TIMEOUT = 1e4;
|
|
4702
4934
|
var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
|
|
4703
4935
|
constructor(_invitationFlowMutex, _callbacks) {
|
|
4704
4936
|
super({
|
|
4705
4937
|
requested: {
|
|
4706
|
-
InvitationHostService:
|
|
4938
|
+
InvitationHostService: import_proto4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
4707
4939
|
},
|
|
4708
4940
|
exposed: {
|
|
4709
|
-
InvitationHostService:
|
|
4941
|
+
InvitationHostService: import_proto4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
4710
4942
|
}
|
|
4711
4943
|
});
|
|
4712
4944
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
4713
4945
|
this._callbacks = _callbacks;
|
|
4714
|
-
this._ctx = new
|
|
4715
|
-
F:
|
|
4716
|
-
L:
|
|
4946
|
+
this._ctx = new import_context12.Context(void 0, {
|
|
4947
|
+
F: __dxlog_file17,
|
|
4948
|
+
L: 38
|
|
4717
4949
|
});
|
|
4718
|
-
this._remoteOptionsTrigger = new
|
|
4950
|
+
this._remoteOptionsTrigger = new import_async17.Trigger();
|
|
4719
4951
|
this._invitationFlowLock = null;
|
|
4720
4952
|
}
|
|
4721
4953
|
hasFlowLock() {
|
|
@@ -4725,9 +4957,9 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
|
|
|
4725
4957
|
return {
|
|
4726
4958
|
InvitationHostService: {
|
|
4727
4959
|
options: async (options) => {
|
|
4728
|
-
(0,
|
|
4729
|
-
F:
|
|
4730
|
-
L:
|
|
4960
|
+
(0, import_invariant14.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
4961
|
+
F: __dxlog_file17,
|
|
4962
|
+
L: 68,
|
|
4731
4963
|
S: this,
|
|
4732
4964
|
A: [
|
|
4733
4965
|
"!this._remoteOptions",
|
|
@@ -4752,39 +4984,39 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
|
|
|
4752
4984
|
async onOpen(context) {
|
|
4753
4985
|
await super.onOpen(context);
|
|
4754
4986
|
try {
|
|
4755
|
-
(0,
|
|
4756
|
-
F:
|
|
4757
|
-
L:
|
|
4987
|
+
(0, import_log15.log)("guest acquire lock", void 0, {
|
|
4988
|
+
F: __dxlog_file17,
|
|
4989
|
+
L: 89,
|
|
4758
4990
|
S: this,
|
|
4759
4991
|
C: (f, a) => f(...a)
|
|
4760
4992
|
});
|
|
4761
4993
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
4762
|
-
(0,
|
|
4763
|
-
F:
|
|
4764
|
-
L:
|
|
4994
|
+
(0, import_log15.log)("guest lock acquired", void 0, {
|
|
4995
|
+
F: __dxlog_file17,
|
|
4996
|
+
L: 91,
|
|
4765
4997
|
S: this,
|
|
4766
4998
|
C: (f, a) => f(...a)
|
|
4767
4999
|
});
|
|
4768
|
-
await (0,
|
|
5000
|
+
await (0, import_context12.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
4769
5001
|
role: import_invitations3.InvitationOptions.Role.GUEST
|
|
4770
5002
|
}));
|
|
4771
|
-
(0,
|
|
4772
|
-
F:
|
|
4773
|
-
L:
|
|
5003
|
+
(0, import_log15.log)("options sent", void 0, {
|
|
5004
|
+
F: __dxlog_file17,
|
|
5005
|
+
L: 96,
|
|
4774
5006
|
S: this,
|
|
4775
5007
|
C: (f, a) => f(...a)
|
|
4776
5008
|
});
|
|
4777
|
-
await (0,
|
|
5009
|
+
await (0, import_context12.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
4778
5010
|
timeout: OPTIONS_TIMEOUT
|
|
4779
5011
|
}));
|
|
4780
|
-
(0,
|
|
4781
|
-
F:
|
|
4782
|
-
L:
|
|
5012
|
+
(0, import_log15.log)("options received", void 0, {
|
|
5013
|
+
F: __dxlog_file17,
|
|
5014
|
+
L: 98,
|
|
4783
5015
|
S: this,
|
|
4784
5016
|
C: (f, a) => f(...a)
|
|
4785
5017
|
});
|
|
4786
5018
|
if (this._remoteOptions?.role !== import_invitations3.InvitationOptions.Role.HOST) {
|
|
4787
|
-
throw new
|
|
5019
|
+
throw new import_protocols11.InvalidInvitationExtensionRoleError(void 0, {
|
|
4788
5020
|
expected: import_invitations3.InvitationOptions.Role.HOST,
|
|
4789
5021
|
remoteOptions: this._remoteOptions,
|
|
4790
5022
|
remotePeerId: context.remotePeerId
|
|
@@ -4811,40 +5043,40 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
|
|
|
4811
5043
|
if (this._invitationFlowLock != null) {
|
|
4812
5044
|
this._invitationFlowLock.release();
|
|
4813
5045
|
this._invitationFlowLock = null;
|
|
4814
|
-
(0,
|
|
4815
|
-
F:
|
|
4816
|
-
L:
|
|
5046
|
+
(0, import_log15.log)("invitation flow lock released", void 0, {
|
|
5047
|
+
F: __dxlog_file17,
|
|
5048
|
+
L: 131,
|
|
4817
5049
|
S: this,
|
|
4818
5050
|
C: (f, a) => f(...a)
|
|
4819
5051
|
});
|
|
4820
5052
|
}
|
|
4821
5053
|
}
|
|
4822
5054
|
};
|
|
4823
|
-
var
|
|
5055
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
|
|
4824
5056
|
var OPTIONS_TIMEOUT2 = 1e4;
|
|
4825
5057
|
var MAX_OTP_ATTEMPTS = 3;
|
|
4826
5058
|
var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
4827
5059
|
constructor(_invitationFlowMutex, _callbacks) {
|
|
4828
5060
|
super({
|
|
4829
5061
|
requested: {
|
|
4830
|
-
InvitationHostService:
|
|
5062
|
+
InvitationHostService: import_proto5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
4831
5063
|
},
|
|
4832
5064
|
exposed: {
|
|
4833
|
-
InvitationHostService:
|
|
5065
|
+
InvitationHostService: import_proto5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
4834
5066
|
}
|
|
4835
5067
|
});
|
|
4836
5068
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
4837
5069
|
this._callbacks = _callbacks;
|
|
4838
5070
|
this._ctx = new import_context13.Context(void 0, {
|
|
4839
|
-
F:
|
|
4840
|
-
L:
|
|
5071
|
+
F: __dxlog_file18,
|
|
5072
|
+
L: 57
|
|
4841
5073
|
});
|
|
4842
|
-
this._remoteOptionsTrigger = new
|
|
5074
|
+
this._remoteOptionsTrigger = new import_async18.Trigger();
|
|
4843
5075
|
this._challenge = void 0;
|
|
4844
5076
|
this.guestProfile = void 0;
|
|
4845
5077
|
this.authenticationPassed = false;
|
|
4846
5078
|
this.authenticationRetry = 0;
|
|
4847
|
-
this.completedTrigger = new
|
|
5079
|
+
this.completedTrigger = new import_async18.Trigger();
|
|
4848
5080
|
this._invitationFlowLock = null;
|
|
4849
5081
|
}
|
|
4850
5082
|
hasFlowLock() {
|
|
@@ -4856,9 +5088,9 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
|
4856
5088
|
// Perhaps in the future we will have more complex logic here.
|
|
4857
5089
|
InvitationHostService: {
|
|
4858
5090
|
options: async (options) => {
|
|
4859
|
-
(0,
|
|
4860
|
-
F:
|
|
4861
|
-
L:
|
|
5091
|
+
(0, import_invariant15.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
5092
|
+
F: __dxlog_file18,
|
|
5093
|
+
L: 106,
|
|
4862
5094
|
S: this,
|
|
4863
5095
|
A: [
|
|
4864
5096
|
"!this._remoteOptions",
|
|
@@ -4870,49 +5102,49 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
|
4870
5102
|
},
|
|
4871
5103
|
introduce: async (request) => {
|
|
4872
5104
|
const { profile, invitationId } = request;
|
|
4873
|
-
const traceId =
|
|
4874
|
-
|
|
5105
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5106
|
+
import_log16.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols12.trace.begin({
|
|
4875
5107
|
id: traceId
|
|
4876
5108
|
}), {
|
|
4877
|
-
F:
|
|
4878
|
-
L:
|
|
5109
|
+
F: __dxlog_file18,
|
|
5110
|
+
L: 114,
|
|
4879
5111
|
S: this,
|
|
4880
5112
|
C: (f, a) => f(...a)
|
|
4881
5113
|
});
|
|
4882
5114
|
const invitation = this._requireActiveInvitation();
|
|
4883
|
-
this._assertInvitationState(
|
|
5115
|
+
this._assertInvitationState(import_services14.Invitation.State.CONNECTED);
|
|
4884
5116
|
if (invitationId !== invitation?.invitationId) {
|
|
4885
|
-
|
|
5117
|
+
import_log16.log.warn("incorrect invitationId", {
|
|
4886
5118
|
expected: invitation.invitationId,
|
|
4887
5119
|
actual: invitationId
|
|
4888
5120
|
}, {
|
|
4889
|
-
F:
|
|
4890
|
-
L:
|
|
5121
|
+
F: __dxlog_file18,
|
|
5122
|
+
L: 119,
|
|
4891
5123
|
S: this,
|
|
4892
5124
|
C: (f, a) => f(...a)
|
|
4893
5125
|
});
|
|
4894
5126
|
this._callbacks.onError(new Error("Incorrect invitationId."));
|
|
4895
|
-
(0,
|
|
5127
|
+
(0, import_async18.scheduleTask)(this._ctx, () => this.close());
|
|
4896
5128
|
return {
|
|
4897
|
-
authMethod:
|
|
5129
|
+
authMethod: import_services14.Invitation.AuthMethod.NONE
|
|
4898
5130
|
};
|
|
4899
5131
|
}
|
|
4900
|
-
(0,
|
|
5132
|
+
(0, import_log16.log)("guest introduced themselves", {
|
|
4901
5133
|
guestProfile: profile
|
|
4902
5134
|
}, {
|
|
4903
|
-
F:
|
|
4904
|
-
L:
|
|
5135
|
+
F: __dxlog_file18,
|
|
5136
|
+
L: 128,
|
|
4905
5137
|
S: this,
|
|
4906
5138
|
C: (f, a) => f(...a)
|
|
4907
5139
|
});
|
|
4908
5140
|
this.guestProfile = profile;
|
|
4909
|
-
this._callbacks.onStateUpdate(
|
|
4910
|
-
this._challenge = invitation.authMethod ===
|
|
4911
|
-
|
|
5141
|
+
this._callbacks.onStateUpdate(import_services14.Invitation.State.READY_FOR_AUTHENTICATION);
|
|
5142
|
+
this._challenge = invitation.authMethod === import_services14.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto3.randomBytes)(32) : void 0;
|
|
5143
|
+
import_log16.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols12.trace.end({
|
|
4912
5144
|
id: traceId
|
|
4913
5145
|
}), {
|
|
4914
|
-
F:
|
|
4915
|
-
L:
|
|
5146
|
+
F: __dxlog_file18,
|
|
5147
|
+
L: 134,
|
|
4916
5148
|
S: this,
|
|
4917
5149
|
C: (f, a) => f(...a)
|
|
4918
5150
|
});
|
|
@@ -4922,35 +5154,35 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
|
4922
5154
|
};
|
|
4923
5155
|
},
|
|
4924
5156
|
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
4925
|
-
const traceId =
|
|
4926
|
-
|
|
5157
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5158
|
+
import_log16.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols12.trace.begin({
|
|
4927
5159
|
id: traceId
|
|
4928
5160
|
}), {
|
|
4929
|
-
F:
|
|
4930
|
-
L:
|
|
5161
|
+
F: __dxlog_file18,
|
|
5162
|
+
L: 143,
|
|
4931
5163
|
S: this,
|
|
4932
5164
|
C: (f, a) => f(...a)
|
|
4933
5165
|
});
|
|
4934
5166
|
const invitation = this._requireActiveInvitation();
|
|
4935
|
-
(0,
|
|
5167
|
+
(0, import_log16.log)("received authentication request", {
|
|
4936
5168
|
authCode: code
|
|
4937
5169
|
}, {
|
|
4938
|
-
F:
|
|
4939
|
-
L:
|
|
5170
|
+
F: __dxlog_file18,
|
|
5171
|
+
L: 146,
|
|
4940
5172
|
S: this,
|
|
4941
5173
|
C: (f, a) => f(...a)
|
|
4942
5174
|
});
|
|
4943
5175
|
let status = import_invitations4.AuthenticationResponse.Status.OK;
|
|
4944
5176
|
this._assertInvitationState([
|
|
4945
|
-
|
|
4946
|
-
|
|
5177
|
+
import_services14.Invitation.State.AUTHENTICATING,
|
|
5178
|
+
import_services14.Invitation.State.READY_FOR_AUTHENTICATION
|
|
4947
5179
|
]);
|
|
4948
|
-
this._callbacks.onStateUpdate(
|
|
5180
|
+
this._callbacks.onStateUpdate(import_services14.Invitation.State.AUTHENTICATING);
|
|
4949
5181
|
switch (invitation.authMethod) {
|
|
4950
|
-
case
|
|
4951
|
-
(0,
|
|
4952
|
-
F:
|
|
4953
|
-
L:
|
|
5182
|
+
case import_services14.Invitation.AuthMethod.NONE: {
|
|
5183
|
+
(0, import_log16.log)("authentication not required", void 0, {
|
|
5184
|
+
F: __dxlog_file18,
|
|
5185
|
+
L: 154,
|
|
4954
5186
|
S: this,
|
|
4955
5187
|
C: (f, a) => f(...a)
|
|
4956
5188
|
});
|
|
@@ -4958,7 +5190,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
|
4958
5190
|
status: import_invitations4.AuthenticationResponse.Status.OK
|
|
4959
5191
|
};
|
|
4960
5192
|
}
|
|
4961
|
-
case
|
|
5193
|
+
case import_services14.Invitation.AuthMethod.SHARED_SECRET: {
|
|
4962
5194
|
if (invitation.authCode) {
|
|
4963
5195
|
if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
|
|
4964
5196
|
status = import_invitations4.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
|
|
@@ -4970,12 +5202,12 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
|
4970
5202
|
}
|
|
4971
5203
|
break;
|
|
4972
5204
|
}
|
|
4973
|
-
case
|
|
5205
|
+
case import_services14.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
|
|
4974
5206
|
if (!invitation.guestKeypair) {
|
|
4975
5207
|
status = import_invitations4.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
4976
5208
|
break;
|
|
4977
5209
|
}
|
|
4978
|
-
const isSignatureValid = this._challenge && (0,
|
|
5210
|
+
const isSignatureValid = this._challenge && (0, import_crypto3.verify)(this._challenge, Buffer.from(signedChallenge ?? []), invitation.guestKeypair.publicKey.asBuffer());
|
|
4979
5211
|
if (isSignatureValid) {
|
|
4980
5212
|
this.authenticationPassed = true;
|
|
4981
5213
|
} else {
|
|
@@ -4984,11 +5216,11 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
|
4984
5216
|
break;
|
|
4985
5217
|
}
|
|
4986
5218
|
default: {
|
|
4987
|
-
|
|
5219
|
+
import_log16.log.error("invalid authentication method", {
|
|
4988
5220
|
authMethod: invitation.authMethod
|
|
4989
5221
|
}, {
|
|
4990
|
-
F:
|
|
4991
|
-
L:
|
|
5222
|
+
F: __dxlog_file18,
|
|
5223
|
+
L: 192,
|
|
4992
5224
|
S: this,
|
|
4993
5225
|
C: (f, a) => f(...a)
|
|
4994
5226
|
});
|
|
@@ -5001,19 +5233,19 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
|
5001
5233
|
import_invitations4.AuthenticationResponse.Status.INVALID_OTP
|
|
5002
5234
|
].includes(status)) {
|
|
5003
5235
|
this._callbacks.onError(new Error(`Authentication failed, with status=${status}`));
|
|
5004
|
-
(0,
|
|
5236
|
+
(0, import_async18.scheduleTask)(this._ctx, () => this.close());
|
|
5005
5237
|
return {
|
|
5006
5238
|
status
|
|
5007
5239
|
};
|
|
5008
5240
|
}
|
|
5009
|
-
|
|
5241
|
+
import_log16.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols12.trace.end({
|
|
5010
5242
|
id: traceId,
|
|
5011
5243
|
data: {
|
|
5012
5244
|
status
|
|
5013
5245
|
}
|
|
5014
5246
|
}), {
|
|
5015
|
-
F:
|
|
5016
|
-
L:
|
|
5247
|
+
F: __dxlog_file18,
|
|
5248
|
+
L: 204,
|
|
5017
5249
|
S: this,
|
|
5018
5250
|
C: (f, a) => f(...a)
|
|
5019
5251
|
});
|
|
@@ -5022,29 +5254,29 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
|
5022
5254
|
};
|
|
5023
5255
|
},
|
|
5024
5256
|
admit: async (request) => {
|
|
5025
|
-
const traceId =
|
|
5026
|
-
|
|
5257
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5258
|
+
import_log16.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols12.trace.begin({
|
|
5027
5259
|
id: traceId
|
|
5028
5260
|
}), {
|
|
5029
|
-
F:
|
|
5030
|
-
L:
|
|
5261
|
+
F: __dxlog_file18,
|
|
5262
|
+
L: 210,
|
|
5031
5263
|
S: this,
|
|
5032
5264
|
C: (f, a) => f(...a)
|
|
5033
5265
|
});
|
|
5034
5266
|
const invitation = this._requireActiveInvitation();
|
|
5035
5267
|
try {
|
|
5036
5268
|
if (isAuthenticationRequired(invitation)) {
|
|
5037
|
-
this._assertInvitationState(
|
|
5269
|
+
this._assertInvitationState(import_services14.Invitation.State.AUTHENTICATING);
|
|
5038
5270
|
if (!this.authenticationPassed) {
|
|
5039
5271
|
throw new Error("Not authenticated");
|
|
5040
5272
|
}
|
|
5041
5273
|
}
|
|
5042
5274
|
const response = await this._callbacks.admit(request);
|
|
5043
|
-
|
|
5275
|
+
import_log16.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols12.trace.end({
|
|
5044
5276
|
id: traceId
|
|
5045
5277
|
}), {
|
|
5046
|
-
F:
|
|
5047
|
-
L:
|
|
5278
|
+
F: __dxlog_file18,
|
|
5279
|
+
L: 224,
|
|
5048
5280
|
S: this,
|
|
5049
5281
|
C: (f, a) => f(...a)
|
|
5050
5282
|
});
|
|
@@ -5060,48 +5292,48 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
|
5060
5292
|
async onOpen(context) {
|
|
5061
5293
|
await super.onOpen(context);
|
|
5062
5294
|
try {
|
|
5063
|
-
(0,
|
|
5064
|
-
F:
|
|
5065
|
-
L:
|
|
5295
|
+
(0, import_log16.log)("host acquire lock", void 0, {
|
|
5296
|
+
F: __dxlog_file18,
|
|
5297
|
+
L: 239,
|
|
5066
5298
|
S: this,
|
|
5067
5299
|
C: (f, a) => f(...a)
|
|
5068
5300
|
});
|
|
5069
5301
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
5070
|
-
(0,
|
|
5071
|
-
F:
|
|
5072
|
-
L:
|
|
5302
|
+
(0, import_log16.log)("host lock acquired", void 0, {
|
|
5303
|
+
F: __dxlog_file18,
|
|
5304
|
+
L: 241,
|
|
5073
5305
|
S: this,
|
|
5074
5306
|
C: (f, a) => f(...a)
|
|
5075
5307
|
});
|
|
5076
5308
|
const lastState = this._requireActiveInvitation().state;
|
|
5077
|
-
this._callbacks.onStateUpdate(
|
|
5309
|
+
this._callbacks.onStateUpdate(import_services14.Invitation.State.CONNECTING);
|
|
5078
5310
|
await this.rpc.InvitationHostService.options({
|
|
5079
5311
|
role: import_invitations4.InvitationOptions.Role.HOST
|
|
5080
5312
|
});
|
|
5081
|
-
(0,
|
|
5082
|
-
F:
|
|
5083
|
-
L:
|
|
5313
|
+
(0, import_log16.log)("options sent", void 0, {
|
|
5314
|
+
F: __dxlog_file18,
|
|
5315
|
+
L: 245,
|
|
5084
5316
|
S: this,
|
|
5085
5317
|
C: (f, a) => f(...a)
|
|
5086
5318
|
});
|
|
5087
5319
|
await (0, import_context13.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
5088
5320
|
timeout: OPTIONS_TIMEOUT2
|
|
5089
5321
|
}));
|
|
5090
|
-
(0,
|
|
5091
|
-
F:
|
|
5092
|
-
L:
|
|
5322
|
+
(0, import_log16.log)("options received", void 0, {
|
|
5323
|
+
F: __dxlog_file18,
|
|
5324
|
+
L: 247,
|
|
5093
5325
|
S: this,
|
|
5094
5326
|
C: (f, a) => f(...a)
|
|
5095
5327
|
});
|
|
5096
5328
|
if (this._remoteOptions?.role !== import_invitations4.InvitationOptions.Role.GUEST) {
|
|
5097
5329
|
this._callbacks.onStateUpdate(lastState);
|
|
5098
|
-
throw new
|
|
5330
|
+
throw new import_protocols12.InvalidInvitationExtensionRoleError(void 0, {
|
|
5099
5331
|
expected: import_invitations4.InvitationOptions.Role.GUEST,
|
|
5100
5332
|
remoteOptions: this._remoteOptions,
|
|
5101
5333
|
remotePeerId: context.remotePeerId
|
|
5102
5334
|
});
|
|
5103
5335
|
}
|
|
5104
|
-
this._callbacks.onStateUpdate(
|
|
5336
|
+
this._callbacks.onStateUpdate(import_services14.Invitation.State.CONNECTED);
|
|
5105
5337
|
this._callbacks.onOpen(this._ctx, context);
|
|
5106
5338
|
} catch (err) {
|
|
5107
5339
|
if (this._invitationFlowLock != null) {
|
|
@@ -5115,7 +5347,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
|
5115
5347
|
_requireActiveInvitation() {
|
|
5116
5348
|
const invitation = this._callbacks.activeInvitation;
|
|
5117
5349
|
if (invitation == null) {
|
|
5118
|
-
(0,
|
|
5350
|
+
(0, import_async18.scheduleTask)(this._ctx, () => this.close());
|
|
5119
5351
|
throw new Error("Active invitation not found");
|
|
5120
5352
|
}
|
|
5121
5353
|
return invitation;
|
|
@@ -5126,8 +5358,8 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
|
5126
5358
|
stateOrMany
|
|
5127
5359
|
];
|
|
5128
5360
|
if (!validStates.includes(invitation.state)) {
|
|
5129
|
-
(0,
|
|
5130
|
-
throw new
|
|
5361
|
+
(0, import_async18.scheduleTask)(this._ctx, () => this.close());
|
|
5362
|
+
throw new import_invariant15.InvariantViolation(`Expected ${stateToString(invitation.state)} to be one of [${validStates.map(stateToString).join(", ")}]`);
|
|
5131
5363
|
}
|
|
5132
5364
|
}
|
|
5133
5365
|
async onClose() {
|
|
@@ -5141,25 +5373,115 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
|
|
|
5141
5373
|
if (this._invitationFlowLock != null) {
|
|
5142
5374
|
this._invitationFlowLock?.release();
|
|
5143
5375
|
this._invitationFlowLock = null;
|
|
5144
|
-
(0,
|
|
5145
|
-
F:
|
|
5146
|
-
L:
|
|
5376
|
+
(0, import_log16.log)("invitation flow lock released", void 0, {
|
|
5377
|
+
F: __dxlog_file18,
|
|
5378
|
+
L: 302,
|
|
5147
5379
|
S: this,
|
|
5148
5380
|
C: (f, a) => f(...a)
|
|
5149
5381
|
});
|
|
5150
5382
|
}
|
|
5151
5383
|
}
|
|
5152
5384
|
};
|
|
5153
|
-
var isAuthenticationRequired = (invitation) => invitation.authMethod !==
|
|
5154
|
-
var
|
|
5385
|
+
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services14.Invitation.AuthMethod.NONE;
|
|
5386
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-state.ts";
|
|
5387
|
+
var createGuardedInvitationState = (ctx, invitation, stream) => {
|
|
5388
|
+
const mutex = new import_async19.Mutex();
|
|
5389
|
+
let lastActiveLockHolder = null;
|
|
5390
|
+
let currentInvitation = {
|
|
5391
|
+
...invitation
|
|
5392
|
+
};
|
|
5393
|
+
const isStateChangeAllowed = (lockHolder) => {
|
|
5394
|
+
if (ctx.disposed || lockHolder !== null && mutex.isLocked() && !lockHolder.hasFlowLock()) {
|
|
5395
|
+
return false;
|
|
5396
|
+
}
|
|
5397
|
+
return lockHolder == null || lastActiveLockHolder !== lockHolder || isNonTerminalState(currentInvitation.state);
|
|
5398
|
+
};
|
|
5399
|
+
return {
|
|
5400
|
+
mutex,
|
|
5401
|
+
get current() {
|
|
5402
|
+
return currentInvitation;
|
|
5403
|
+
},
|
|
5404
|
+
// disposing context prevents any further state updates
|
|
5405
|
+
complete: (newState) => {
|
|
5406
|
+
currentInvitation = {
|
|
5407
|
+
...currentInvitation,
|
|
5408
|
+
...newState
|
|
5409
|
+
};
|
|
5410
|
+
stream.next(currentInvitation);
|
|
5411
|
+
return ctx.dispose();
|
|
5412
|
+
},
|
|
5413
|
+
set: (lockHolder, newState) => {
|
|
5414
|
+
if (isStateChangeAllowed(lockHolder)) {
|
|
5415
|
+
logStateUpdate(currentInvitation, lockHolder, newState);
|
|
5416
|
+
currentInvitation = {
|
|
5417
|
+
...currentInvitation,
|
|
5418
|
+
state: newState
|
|
5419
|
+
};
|
|
5420
|
+
stream.next(currentInvitation);
|
|
5421
|
+
lastActiveLockHolder = lockHolder;
|
|
5422
|
+
return true;
|
|
5423
|
+
}
|
|
5424
|
+
return false;
|
|
5425
|
+
},
|
|
5426
|
+
error: (lockHolder, error) => {
|
|
5427
|
+
if (isStateChangeAllowed(lockHolder)) {
|
|
5428
|
+
logStateUpdate(currentInvitation, lockHolder, import_services15.Invitation.State.ERROR);
|
|
5429
|
+
currentInvitation = {
|
|
5430
|
+
...currentInvitation,
|
|
5431
|
+
state: import_services15.Invitation.State.ERROR
|
|
5432
|
+
};
|
|
5433
|
+
stream.next(currentInvitation);
|
|
5434
|
+
stream.error(error);
|
|
5435
|
+
lastActiveLockHolder = lockHolder;
|
|
5436
|
+
return true;
|
|
5437
|
+
}
|
|
5438
|
+
return false;
|
|
5439
|
+
}
|
|
5440
|
+
};
|
|
5441
|
+
};
|
|
5442
|
+
var logStateUpdate = (invitation, actor, newState) => {
|
|
5443
|
+
if (isNonTerminalState(newState)) {
|
|
5444
|
+
(0, import_log17.log)("invitation state update", {
|
|
5445
|
+
actor: actor?.constructor.name,
|
|
5446
|
+
newState: stateToString(newState),
|
|
5447
|
+
oldState: stateToString(invitation.state)
|
|
5448
|
+
}, {
|
|
5449
|
+
F: __dxlog_file19,
|
|
5450
|
+
L: 89,
|
|
5451
|
+
S: void 0,
|
|
5452
|
+
C: (f, a) => f(...a)
|
|
5453
|
+
});
|
|
5454
|
+
} else {
|
|
5455
|
+
import_log17.log.info("invitation state update", {
|
|
5456
|
+
actor: actor?.constructor.name,
|
|
5457
|
+
newState: stateToString(newState),
|
|
5458
|
+
oldState: stateToString(invitation.state)
|
|
5459
|
+
}, {
|
|
5460
|
+
F: __dxlog_file19,
|
|
5461
|
+
L: 95,
|
|
5462
|
+
S: void 0,
|
|
5463
|
+
C: (f, a) => f(...a)
|
|
5464
|
+
});
|
|
5465
|
+
}
|
|
5466
|
+
};
|
|
5467
|
+
var isNonTerminalState = (currentState) => {
|
|
5468
|
+
return ![
|
|
5469
|
+
import_services15.Invitation.State.SUCCESS,
|
|
5470
|
+
import_services15.Invitation.State.ERROR,
|
|
5471
|
+
import_services15.Invitation.State.CANCELLED,
|
|
5472
|
+
import_services15.Invitation.State.TIMEOUT,
|
|
5473
|
+
import_services15.Invitation.State.EXPIRED
|
|
5474
|
+
].includes(currentState);
|
|
5475
|
+
};
|
|
5476
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
|
|
5155
5477
|
var InvitationTopology = class {
|
|
5156
5478
|
constructor(_role) {
|
|
5157
5479
|
this._role = _role;
|
|
5158
|
-
this._seenPeers = new import_util11.ComplexSet(
|
|
5480
|
+
this._seenPeers = new import_util11.ComplexSet(import_keys13.PublicKey.hash);
|
|
5159
5481
|
}
|
|
5160
5482
|
init(controller) {
|
|
5161
|
-
(0,
|
|
5162
|
-
F:
|
|
5483
|
+
(0, import_invariant16.invariant)(!this._controller, "Already initialized.", {
|
|
5484
|
+
F: __dxlog_file20,
|
|
5163
5485
|
L: 42,
|
|
5164
5486
|
S: this,
|
|
5165
5487
|
A: [
|
|
@@ -5170,8 +5492,8 @@ var InvitationTopology = class {
|
|
|
5170
5492
|
this._controller = controller;
|
|
5171
5493
|
}
|
|
5172
5494
|
update() {
|
|
5173
|
-
(0,
|
|
5174
|
-
F:
|
|
5495
|
+
(0, import_invariant16.invariant)(this._controller, "Not initialized.", {
|
|
5496
|
+
F: __dxlog_file20,
|
|
5175
5497
|
L: 47,
|
|
5176
5498
|
S: this,
|
|
5177
5499
|
A: [
|
|
@@ -5188,13 +5510,13 @@ var InvitationTopology = class {
|
|
|
5188
5510
|
return;
|
|
5189
5511
|
}
|
|
5190
5512
|
const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
|
|
5191
|
-
this._seenPeers = new import_util11.ComplexSet(
|
|
5513
|
+
this._seenPeers = new import_util11.ComplexSet(import_keys13.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
|
|
5192
5514
|
if (firstUnknownPeer != null) {
|
|
5193
|
-
(0,
|
|
5515
|
+
(0, import_log18.log)("invitation connect", {
|
|
5194
5516
|
ownPeerId,
|
|
5195
5517
|
remotePeerId: firstUnknownPeer
|
|
5196
5518
|
}, {
|
|
5197
|
-
F:
|
|
5519
|
+
F: __dxlog_file20,
|
|
5198
5520
|
L: 69,
|
|
5199
5521
|
S: this,
|
|
5200
5522
|
C: (f, a) => f(...a)
|
|
@@ -5204,8 +5526,8 @@ var InvitationTopology = class {
|
|
|
5204
5526
|
}
|
|
5205
5527
|
}
|
|
5206
5528
|
async onOffer(peer) {
|
|
5207
|
-
(0,
|
|
5208
|
-
F:
|
|
5529
|
+
(0, import_invariant16.invariant)(this._controller, "Not initialized.", {
|
|
5530
|
+
F: __dxlog_file20,
|
|
5209
5531
|
L: 76,
|
|
5210
5532
|
S: this,
|
|
5211
5533
|
A: [
|
|
@@ -5222,20 +5544,21 @@ var InvitationTopology = class {
|
|
|
5222
5544
|
return `InvitationTopology(${this._role === import_invitations5.InvitationOptions.Role.GUEST ? "guest" : "host"})`;
|
|
5223
5545
|
}
|
|
5224
5546
|
};
|
|
5225
|
-
var
|
|
5547
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
5226
5548
|
var metrics = import_tracing8.trace.metrics;
|
|
5227
5549
|
var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
|
|
5228
5550
|
var InvitationsHandler = class {
|
|
5229
5551
|
/**
|
|
5230
5552
|
* @internal
|
|
5231
5553
|
*/
|
|
5232
|
-
constructor(_networkManager,
|
|
5554
|
+
constructor(_networkManager, _edgeClient, _connectionParams) {
|
|
5233
5555
|
this._networkManager = _networkManager;
|
|
5234
|
-
this.
|
|
5556
|
+
this._edgeClient = _edgeClient;
|
|
5557
|
+
this._connectionParams = _connectionParams;
|
|
5235
5558
|
}
|
|
5236
5559
|
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
5237
5560
|
metrics.increment("dxos.invitation.created");
|
|
5238
|
-
const guardedState =
|
|
5561
|
+
const guardedState = createGuardedInvitationState(ctx, invitation, stream);
|
|
5239
5562
|
const createExtension = () => {
|
|
5240
5563
|
const extension = new InvitationHostExtension(guardedState.mutex, {
|
|
5241
5564
|
get activeInvitation() {
|
|
@@ -5249,8 +5572,8 @@ var InvitationsHandler = class {
|
|
|
5249
5572
|
try {
|
|
5250
5573
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
5251
5574
|
(0, import_invariant12.invariant)(deviceKey, void 0, {
|
|
5252
|
-
F:
|
|
5253
|
-
L:
|
|
5575
|
+
F: __dxlog_file21,
|
|
5576
|
+
L: 100,
|
|
5254
5577
|
S: this,
|
|
5255
5578
|
A: [
|
|
5256
5579
|
"deviceKey",
|
|
@@ -5278,16 +5601,16 @@ var InvitationsHandler = class {
|
|
|
5278
5601
|
import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.begin({
|
|
5279
5602
|
id: traceId
|
|
5280
5603
|
}), {
|
|
5281
|
-
F:
|
|
5282
|
-
L:
|
|
5604
|
+
F: __dxlog_file21,
|
|
5605
|
+
L: 125,
|
|
5283
5606
|
S: this,
|
|
5284
5607
|
C: (f, a) => f(...a)
|
|
5285
5608
|
});
|
|
5286
5609
|
(0, import_log13.log)("connected", {
|
|
5287
5610
|
...protocol.toJSON()
|
|
5288
5611
|
}, {
|
|
5289
|
-
F:
|
|
5290
|
-
L:
|
|
5612
|
+
F: __dxlog_file21,
|
|
5613
|
+
L: 126,
|
|
5291
5614
|
S: this,
|
|
5292
5615
|
C: (f, a) => f(...a)
|
|
5293
5616
|
});
|
|
@@ -5298,8 +5621,8 @@ var InvitationsHandler = class {
|
|
|
5298
5621
|
guest: deviceKey,
|
|
5299
5622
|
...protocol.toJSON()
|
|
5300
5623
|
}, {
|
|
5301
|
-
F:
|
|
5302
|
-
L:
|
|
5624
|
+
F: __dxlog_file21,
|
|
5625
|
+
L: 128,
|
|
5303
5626
|
S: this,
|
|
5304
5627
|
C: (f, a) => f(...a)
|
|
5305
5628
|
});
|
|
@@ -5308,8 +5631,8 @@ var InvitationsHandler = class {
|
|
|
5308
5631
|
import_log13.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols9.trace.end({
|
|
5309
5632
|
id: traceId
|
|
5310
5633
|
}), {
|
|
5311
|
-
F:
|
|
5312
|
-
L:
|
|
5634
|
+
F: __dxlog_file21,
|
|
5635
|
+
L: 131,
|
|
5313
5636
|
S: this,
|
|
5314
5637
|
C: (f, a) => f(...a)
|
|
5315
5638
|
});
|
|
@@ -5324,8 +5647,8 @@ var InvitationsHandler = class {
|
|
|
5324
5647
|
(0, import_log13.log)("timeout", {
|
|
5325
5648
|
...protocol.toJSON()
|
|
5326
5649
|
}, {
|
|
5327
|
-
F:
|
|
5328
|
-
L:
|
|
5650
|
+
F: __dxlog_file21,
|
|
5651
|
+
L: 141,
|
|
5329
5652
|
S: this,
|
|
5330
5653
|
C: (f, a) => f(...a)
|
|
5331
5654
|
});
|
|
@@ -5334,8 +5657,8 @@ var InvitationsHandler = class {
|
|
|
5334
5657
|
if (guardedState.error(extension, err)) {
|
|
5335
5658
|
metrics.increment("dxos.invitation.failed");
|
|
5336
5659
|
import_log13.log.error("failed", err, {
|
|
5337
|
-
F:
|
|
5338
|
-
L:
|
|
5660
|
+
F: __dxlog_file21,
|
|
5661
|
+
L: 146,
|
|
5339
5662
|
S: this,
|
|
5340
5663
|
C: (f, a) => f(...a)
|
|
5341
5664
|
});
|
|
@@ -5345,8 +5668,8 @@ var InvitationsHandler = class {
|
|
|
5345
5668
|
id: traceId,
|
|
5346
5669
|
error: err
|
|
5347
5670
|
}), {
|
|
5348
|
-
F:
|
|
5349
|
-
L:
|
|
5671
|
+
F: __dxlog_file21,
|
|
5672
|
+
L: 149,
|
|
5350
5673
|
S: this,
|
|
5351
5674
|
C: (f, a) => f(...a)
|
|
5352
5675
|
});
|
|
@@ -5359,8 +5682,8 @@ var InvitationsHandler = class {
|
|
|
5359
5682
|
(0, import_log13.log)("invalid role", {
|
|
5360
5683
|
...err.context
|
|
5361
5684
|
}, {
|
|
5362
|
-
F:
|
|
5363
|
-
L:
|
|
5685
|
+
F: __dxlog_file21,
|
|
5686
|
+
L: 157,
|
|
5364
5687
|
S: this,
|
|
5365
5688
|
C: (f, a) => f(...a)
|
|
5366
5689
|
});
|
|
@@ -5372,8 +5695,8 @@ var InvitationsHandler = class {
|
|
|
5372
5695
|
(0, import_log13.log)("timeout", {
|
|
5373
5696
|
err
|
|
5374
5697
|
}, {
|
|
5375
|
-
F:
|
|
5376
|
-
L:
|
|
5698
|
+
F: __dxlog_file21,
|
|
5699
|
+
L: 163,
|
|
5377
5700
|
S: this,
|
|
5378
5701
|
C: (f, a) => f(...a)
|
|
5379
5702
|
});
|
|
@@ -5382,8 +5705,8 @@ var InvitationsHandler = class {
|
|
|
5382
5705
|
if (guardedState.error(extension, err)) {
|
|
5383
5706
|
metrics.increment("dxos.invitation.failed");
|
|
5384
5707
|
import_log13.log.error("failed", err, {
|
|
5385
|
-
F:
|
|
5386
|
-
L:
|
|
5708
|
+
F: __dxlog_file21,
|
|
5709
|
+
L: 168,
|
|
5387
5710
|
S: this,
|
|
5388
5711
|
C: (f, a) => f(...a)
|
|
5389
5712
|
});
|
|
@@ -5396,8 +5719,8 @@ var InvitationsHandler = class {
|
|
|
5396
5719
|
if (invitation.lifetime && invitation.created) {
|
|
5397
5720
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
5398
5721
|
import_log13.log.warn("invitation has already expired", void 0, {
|
|
5399
|
-
F:
|
|
5400
|
-
L:
|
|
5722
|
+
F: __dxlog_file21,
|
|
5723
|
+
L: 179,
|
|
5401
5724
|
S: this,
|
|
5402
5725
|
C: (f, a) => f(...a)
|
|
5403
5726
|
});
|
|
@@ -5420,8 +5743,8 @@ var InvitationsHandler = class {
|
|
|
5420
5743
|
const { timeout = import_client_protocol5.INVITATION_TIMEOUT } = invitation;
|
|
5421
5744
|
if (deviceProfile) {
|
|
5422
5745
|
(0, import_invariant12.invariant)(invitation.kind === import_services11.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
5423
|
-
F:
|
|
5424
|
-
L:
|
|
5746
|
+
F: __dxlog_file21,
|
|
5747
|
+
L: 213,
|
|
5425
5748
|
S: this,
|
|
5426
5749
|
A: [
|
|
5427
5750
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -5430,7 +5753,7 @@ var InvitationsHandler = class {
|
|
|
5430
5753
|
});
|
|
5431
5754
|
}
|
|
5432
5755
|
const triedPeersIds = new import_util10.ComplexSet(import_keys10.PublicKey.hash);
|
|
5433
|
-
const guardedState =
|
|
5756
|
+
const guardedState = createGuardedInvitationState(ctx, invitation, stream);
|
|
5434
5757
|
const shouldCancelInvitationFlow = (extension) => {
|
|
5435
5758
|
const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
|
|
5436
5759
|
(0, import_log13.log)("should cancel invitation flow", {
|
|
@@ -5438,8 +5761,8 @@ var InvitationsHandler = class {
|
|
|
5438
5761
|
invitationType: import_services11.Invitation.Type.DELEGATED,
|
|
5439
5762
|
triedPeers: triedPeersIds.size
|
|
5440
5763
|
}, {
|
|
5441
|
-
F:
|
|
5442
|
-
L:
|
|
5764
|
+
F: __dxlog_file21,
|
|
5765
|
+
L: 221,
|
|
5443
5766
|
S: this,
|
|
5444
5767
|
C: (f, a) => f(...a)
|
|
5445
5768
|
});
|
|
@@ -5465,8 +5788,8 @@ var InvitationsHandler = class {
|
|
|
5465
5788
|
admitted,
|
|
5466
5789
|
currentState: guardedState.current.state
|
|
5467
5790
|
}, {
|
|
5468
|
-
F:
|
|
5469
|
-
L:
|
|
5791
|
+
F: __dxlog_file21,
|
|
5792
|
+
L: 249,
|
|
5470
5793
|
S: this,
|
|
5471
5794
|
C: (f, a) => f(...a)
|
|
5472
5795
|
});
|
|
@@ -5483,8 +5806,8 @@ var InvitationsHandler = class {
|
|
|
5483
5806
|
import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.begin({
|
|
5484
5807
|
id: traceId
|
|
5485
5808
|
}), {
|
|
5486
|
-
F:
|
|
5487
|
-
L:
|
|
5809
|
+
F: __dxlog_file21,
|
|
5810
|
+
L: 261,
|
|
5488
5811
|
S: this,
|
|
5489
5812
|
C: (f, a) => f(...a)
|
|
5490
5813
|
});
|
|
@@ -5495,8 +5818,8 @@ var InvitationsHandler = class {
|
|
|
5495
5818
|
(0, import_log13.log)("connected", {
|
|
5496
5819
|
...protocol.toJSON()
|
|
5497
5820
|
}, {
|
|
5498
|
-
F:
|
|
5499
|
-
L:
|
|
5821
|
+
F: __dxlog_file21,
|
|
5822
|
+
L: 272,
|
|
5500
5823
|
S: this,
|
|
5501
5824
|
C: (f, a) => f(...a)
|
|
5502
5825
|
});
|
|
@@ -5504,8 +5827,8 @@ var InvitationsHandler = class {
|
|
|
5504
5827
|
(0, import_log13.log)("introduce", {
|
|
5505
5828
|
...protocol.toJSON()
|
|
5506
5829
|
}, {
|
|
5507
|
-
F:
|
|
5508
|
-
L:
|
|
5830
|
+
F: __dxlog_file21,
|
|
5831
|
+
L: 276,
|
|
5509
5832
|
S: this,
|
|
5510
5833
|
C: (f, a) => f(...a)
|
|
5511
5834
|
});
|
|
@@ -5517,8 +5840,8 @@ var InvitationsHandler = class {
|
|
|
5517
5840
|
...protocol.toJSON(),
|
|
5518
5841
|
response: introductionResponse
|
|
5519
5842
|
}, {
|
|
5520
|
-
F:
|
|
5521
|
-
L:
|
|
5843
|
+
F: __dxlog_file21,
|
|
5844
|
+
L: 281,
|
|
5522
5845
|
S: this,
|
|
5523
5846
|
C: (f, a) => f(...a)
|
|
5524
5847
|
});
|
|
@@ -5538,8 +5861,8 @@ var InvitationsHandler = class {
|
|
|
5538
5861
|
(0, import_log13.log)("request admission", {
|
|
5539
5862
|
...protocol.toJSON()
|
|
5540
5863
|
}, {
|
|
5541
|
-
F:
|
|
5542
|
-
L:
|
|
5864
|
+
F: __dxlog_file21,
|
|
5865
|
+
L: 307,
|
|
5543
5866
|
S: this,
|
|
5544
5867
|
C: (f, a) => f(...a)
|
|
5545
5868
|
});
|
|
@@ -5550,12 +5873,12 @@ var InvitationsHandler = class {
|
|
|
5550
5873
|
(0, import_log13.log)("admitted by host", {
|
|
5551
5874
|
...protocol.toJSON()
|
|
5552
5875
|
}, {
|
|
5553
|
-
F:
|
|
5554
|
-
L:
|
|
5876
|
+
F: __dxlog_file21,
|
|
5877
|
+
L: 318,
|
|
5555
5878
|
S: this,
|
|
5556
5879
|
C: (f, a) => f(...a)
|
|
5557
5880
|
});
|
|
5558
|
-
|
|
5881
|
+
guardedState.complete({
|
|
5559
5882
|
...guardedState.current,
|
|
5560
5883
|
...result,
|
|
5561
5884
|
state: import_services11.Invitation.State.SUCCESS
|
|
@@ -5563,8 +5886,8 @@ var InvitationsHandler = class {
|
|
|
5563
5886
|
import_log13.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols9.trace.end({
|
|
5564
5887
|
id: traceId
|
|
5565
5888
|
}), {
|
|
5566
|
-
F:
|
|
5567
|
-
L:
|
|
5889
|
+
F: __dxlog_file21,
|
|
5890
|
+
L: 324,
|
|
5568
5891
|
S: this,
|
|
5569
5892
|
C: (f, a) => f(...a)
|
|
5570
5893
|
});
|
|
@@ -5573,16 +5896,16 @@ var InvitationsHandler = class {
|
|
|
5573
5896
|
(0, import_log13.log)("timeout", {
|
|
5574
5897
|
...protocol.toJSON()
|
|
5575
5898
|
}, {
|
|
5576
|
-
F:
|
|
5577
|
-
L:
|
|
5899
|
+
F: __dxlog_file21,
|
|
5900
|
+
L: 327,
|
|
5578
5901
|
S: this,
|
|
5579
5902
|
C: (f, a) => f(...a)
|
|
5580
5903
|
});
|
|
5581
5904
|
guardedState.set(extension, import_services11.Invitation.State.TIMEOUT);
|
|
5582
5905
|
} else {
|
|
5583
5906
|
(0, import_log13.log)("auth failed", err, {
|
|
5584
|
-
F:
|
|
5585
|
-
L:
|
|
5907
|
+
F: __dxlog_file21,
|
|
5908
|
+
L: 330,
|
|
5586
5909
|
S: this,
|
|
5587
5910
|
C: (f, a) => f(...a)
|
|
5588
5911
|
});
|
|
@@ -5593,8 +5916,8 @@ var InvitationsHandler = class {
|
|
|
5593
5916
|
id: traceId,
|
|
5594
5917
|
error: err
|
|
5595
5918
|
}), {
|
|
5596
|
-
F:
|
|
5597
|
-
L:
|
|
5919
|
+
F: __dxlog_file21,
|
|
5920
|
+
L: 334,
|
|
5598
5921
|
S: this,
|
|
5599
5922
|
C: (f, a) => f(...a)
|
|
5600
5923
|
});
|
|
@@ -5609,16 +5932,16 @@ var InvitationsHandler = class {
|
|
|
5609
5932
|
(0, import_log13.log)("timeout", {
|
|
5610
5933
|
...protocol.toJSON()
|
|
5611
5934
|
}, {
|
|
5612
|
-
F:
|
|
5613
|
-
L:
|
|
5935
|
+
F: __dxlog_file21,
|
|
5936
|
+
L: 343,
|
|
5614
5937
|
S: this,
|
|
5615
5938
|
C: (f, a) => f(...a)
|
|
5616
5939
|
});
|
|
5617
5940
|
guardedState.set(extension, import_services11.Invitation.State.TIMEOUT);
|
|
5618
5941
|
} else {
|
|
5619
5942
|
(0, import_log13.log)("auth failed", err, {
|
|
5620
|
-
F:
|
|
5621
|
-
L:
|
|
5943
|
+
F: __dxlog_file21,
|
|
5944
|
+
L: 346,
|
|
5622
5945
|
S: this,
|
|
5623
5946
|
C: (f, a) => f(...a)
|
|
5624
5947
|
});
|
|
@@ -5628,6 +5951,25 @@ var InvitationsHandler = class {
|
|
|
5628
5951
|
});
|
|
5629
5952
|
return extension;
|
|
5630
5953
|
};
|
|
5954
|
+
const edgeInvitationHandler = new EdgeInvitationHandler(this._connectionParams?.edgeInvitations, this._edgeClient, {
|
|
5955
|
+
onInvitationSuccess: async (admissionResponse, admissionRequest) => {
|
|
5956
|
+
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
5957
|
+
(0, import_log13.log)("admitted by edge", {
|
|
5958
|
+
...protocol.toJSON()
|
|
5959
|
+
}, {
|
|
5960
|
+
F: __dxlog_file21,
|
|
5961
|
+
L: 358,
|
|
5962
|
+
S: this,
|
|
5963
|
+
C: (f, a) => f(...a)
|
|
5964
|
+
});
|
|
5965
|
+
guardedState.complete({
|
|
5966
|
+
...guardedState.current,
|
|
5967
|
+
...result,
|
|
5968
|
+
state: import_services11.Invitation.State.SUCCESS
|
|
5969
|
+
});
|
|
5970
|
+
}
|
|
5971
|
+
});
|
|
5972
|
+
edgeInvitationHandler.handle(ctx, guardedState, protocol, deviceProfile);
|
|
5631
5973
|
(0, import_async15.scheduleTask)(ctx, async () => {
|
|
5632
5974
|
const error = protocol.checkInvitation(invitation);
|
|
5633
5975
|
if (error) {
|
|
@@ -5635,8 +5977,8 @@ var InvitationsHandler = class {
|
|
|
5635
5977
|
await ctx.dispose();
|
|
5636
5978
|
} else {
|
|
5637
5979
|
(0, import_invariant12.invariant)(invitation.swarmKey, void 0, {
|
|
5638
|
-
F:
|
|
5639
|
-
L:
|
|
5980
|
+
F: __dxlog_file21,
|
|
5981
|
+
L: 370,
|
|
5640
5982
|
S: this,
|
|
5641
5983
|
A: [
|
|
5642
5984
|
"invitation.swarmKey",
|
|
@@ -5669,119 +6011,26 @@ var InvitationsHandler = class {
|
|
|
5669
6011
|
topic: invitation.swarmKey,
|
|
5670
6012
|
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
5671
6013
|
teleport.addExtension("dxos.halo.invitations", extensionFactory());
|
|
5672
|
-
}, this.
|
|
6014
|
+
}, this._connectionParams?.teleport),
|
|
5673
6015
|
topology: new InvitationTopology(role),
|
|
5674
6016
|
label
|
|
5675
6017
|
});
|
|
5676
6018
|
ctx.onDispose(() => swarmConnection.close());
|
|
5677
6019
|
return swarmConnection;
|
|
5678
6020
|
}
|
|
5679
|
-
/**
|
|
5680
|
-
* A utility object for serializing invitation state changes by multiple concurrent
|
|
5681
|
-
* invitation flow connections.
|
|
5682
|
-
*/
|
|
5683
|
-
_createGuardedState(ctx, invitation, stream) {
|
|
5684
|
-
const mutex = new import_async15.Mutex();
|
|
5685
|
-
let lastActiveExtension = null;
|
|
5686
|
-
let currentInvitation = {
|
|
5687
|
-
...invitation
|
|
5688
|
-
};
|
|
5689
|
-
const isStateChangeAllowed = (extension) => {
|
|
5690
|
-
if (ctx.disposed || extension !== null && mutex.isLocked() && !extension.hasFlowLock()) {
|
|
5691
|
-
return false;
|
|
5692
|
-
}
|
|
5693
|
-
return extension == null || lastActiveExtension !== extension || this._isNotTerminal(currentInvitation.state);
|
|
5694
|
-
};
|
|
5695
|
-
return {
|
|
5696
|
-
mutex,
|
|
5697
|
-
get current() {
|
|
5698
|
-
return currentInvitation;
|
|
5699
|
-
},
|
|
5700
|
-
// disposing context prevents any further state updates
|
|
5701
|
-
complete: (newState) => {
|
|
5702
|
-
currentInvitation = {
|
|
5703
|
-
...currentInvitation,
|
|
5704
|
-
...newState
|
|
5705
|
-
};
|
|
5706
|
-
stream.next(currentInvitation);
|
|
5707
|
-
return ctx.dispose();
|
|
5708
|
-
},
|
|
5709
|
-
set: (extension, newState) => {
|
|
5710
|
-
if (isStateChangeAllowed(extension)) {
|
|
5711
|
-
this._logStateUpdate(currentInvitation, extension, newState);
|
|
5712
|
-
currentInvitation = {
|
|
5713
|
-
...currentInvitation,
|
|
5714
|
-
state: newState
|
|
5715
|
-
};
|
|
5716
|
-
stream.next(currentInvitation);
|
|
5717
|
-
lastActiveExtension = extension;
|
|
5718
|
-
return true;
|
|
5719
|
-
}
|
|
5720
|
-
return false;
|
|
5721
|
-
},
|
|
5722
|
-
error: (extension, error) => {
|
|
5723
|
-
if (isStateChangeAllowed(extension)) {
|
|
5724
|
-
this._logStateUpdate(currentInvitation, extension, import_services11.Invitation.State.ERROR);
|
|
5725
|
-
currentInvitation = {
|
|
5726
|
-
...currentInvitation,
|
|
5727
|
-
state: import_services11.Invitation.State.ERROR
|
|
5728
|
-
};
|
|
5729
|
-
stream.next(currentInvitation);
|
|
5730
|
-
stream.error(error);
|
|
5731
|
-
lastActiveExtension = extension;
|
|
5732
|
-
return true;
|
|
5733
|
-
}
|
|
5734
|
-
return false;
|
|
5735
|
-
}
|
|
5736
|
-
};
|
|
5737
|
-
}
|
|
5738
|
-
_logStateUpdate(invitation, actor, newState) {
|
|
5739
|
-
if (this._isNotTerminal(newState)) {
|
|
5740
|
-
(0, import_log13.log)("invitation state update", {
|
|
5741
|
-
actor: actor?.constructor.name,
|
|
5742
|
-
newState: stateToString(newState),
|
|
5743
|
-
oldState: stateToString(invitation.state)
|
|
5744
|
-
}, {
|
|
5745
|
-
F: __dxlog_file19,
|
|
5746
|
-
L: 460,
|
|
5747
|
-
S: this,
|
|
5748
|
-
C: (f, a) => f(...a)
|
|
5749
|
-
});
|
|
5750
|
-
} else {
|
|
5751
|
-
(0, import_log13.log)("invitation state update", {
|
|
5752
|
-
actor: actor?.constructor.name,
|
|
5753
|
-
newState: stateToString(newState),
|
|
5754
|
-
oldState: stateToString(invitation.state)
|
|
5755
|
-
}, {
|
|
5756
|
-
F: __dxlog_file19,
|
|
5757
|
-
L: 466,
|
|
5758
|
-
S: this,
|
|
5759
|
-
C: (f, a) => f(...a)
|
|
5760
|
-
});
|
|
5761
|
-
}
|
|
5762
|
-
}
|
|
5763
|
-
_isNotTerminal(currentState) {
|
|
5764
|
-
return ![
|
|
5765
|
-
import_services11.Invitation.State.SUCCESS,
|
|
5766
|
-
import_services11.Invitation.State.ERROR,
|
|
5767
|
-
import_services11.Invitation.State.CANCELLED,
|
|
5768
|
-
import_services11.Invitation.State.TIMEOUT,
|
|
5769
|
-
import_services11.Invitation.State.EXPIRED
|
|
5770
|
-
].includes(currentState);
|
|
5771
|
-
}
|
|
5772
6021
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
5773
6022
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
5774
6023
|
(0, import_log13.log)("guest waiting for authentication code...", void 0, {
|
|
5775
|
-
F:
|
|
5776
|
-
L:
|
|
6024
|
+
F: __dxlog_file21,
|
|
6025
|
+
L: 422,
|
|
5777
6026
|
S: this,
|
|
5778
6027
|
C: (f, a) => f(...a)
|
|
5779
6028
|
});
|
|
5780
6029
|
setState(import_services11.Invitation.State.READY_FOR_AUTHENTICATION);
|
|
5781
6030
|
const authCode = await authenticated.wait(options);
|
|
5782
6031
|
(0, import_log13.log)("sending authentication request", void 0, {
|
|
5783
|
-
F:
|
|
5784
|
-
L:
|
|
6032
|
+
F: __dxlog_file21,
|
|
6033
|
+
L: 426,
|
|
5785
6034
|
S: this,
|
|
5786
6035
|
C: (f, a) => f(...a)
|
|
5787
6036
|
});
|
|
@@ -5799,8 +6048,8 @@ var InvitationsHandler = class {
|
|
|
5799
6048
|
(0, import_log13.log)("retrying invalid code", {
|
|
5800
6049
|
attempt
|
|
5801
6050
|
}, {
|
|
5802
|
-
F:
|
|
5803
|
-
L:
|
|
6051
|
+
F: __dxlog_file21,
|
|
6052
|
+
L: 437,
|
|
5804
6053
|
S: this,
|
|
5805
6054
|
C: (f, a) => f(...a)
|
|
5806
6055
|
});
|
|
@@ -5817,8 +6066,8 @@ var InvitationsHandler = class {
|
|
|
5817
6066
|
throw new Error("challenge missing in the introduction");
|
|
5818
6067
|
}
|
|
5819
6068
|
(0, import_log13.log)("sending authentication request", void 0, {
|
|
5820
|
-
F:
|
|
5821
|
-
L:
|
|
6069
|
+
F: __dxlog_file21,
|
|
6070
|
+
L: 456,
|
|
5822
6071
|
S: this,
|
|
5823
6072
|
C: (f, a) => f(...a)
|
|
5824
6073
|
});
|
|
@@ -5868,8 +6117,8 @@ var InvitationsServiceImpl = class {
|
|
|
5868
6117
|
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
5869
6118
|
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
5870
6119
|
next({
|
|
5871
|
-
action:
|
|
5872
|
-
type:
|
|
6120
|
+
action: import_services16.QueryInvitationsResponse.Action.ADDED,
|
|
6121
|
+
type: import_services16.QueryInvitationsResponse.Type.CREATED,
|
|
5873
6122
|
invitations: [
|
|
5874
6123
|
invitation
|
|
5875
6124
|
]
|
|
@@ -5877,8 +6126,8 @@ var InvitationsServiceImpl = class {
|
|
|
5877
6126
|
});
|
|
5878
6127
|
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
5879
6128
|
next({
|
|
5880
|
-
action:
|
|
5881
|
-
type:
|
|
6129
|
+
action: import_services16.QueryInvitationsResponse.Action.ADDED,
|
|
6130
|
+
type: import_services16.QueryInvitationsResponse.Type.ACCEPTED,
|
|
5882
6131
|
invitations: [
|
|
5883
6132
|
invitation
|
|
5884
6133
|
]
|
|
@@ -5886,8 +6135,8 @@ var InvitationsServiceImpl = class {
|
|
|
5886
6135
|
});
|
|
5887
6136
|
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
5888
6137
|
next({
|
|
5889
|
-
action:
|
|
5890
|
-
type:
|
|
6138
|
+
action: import_services16.QueryInvitationsResponse.Action.REMOVED,
|
|
6139
|
+
type: import_services16.QueryInvitationsResponse.Type.CREATED,
|
|
5891
6140
|
invitations: [
|
|
5892
6141
|
invitation
|
|
5893
6142
|
]
|
|
@@ -5895,8 +6144,8 @@ var InvitationsServiceImpl = class {
|
|
|
5895
6144
|
});
|
|
5896
6145
|
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
5897
6146
|
next({
|
|
5898
|
-
action:
|
|
5899
|
-
type:
|
|
6147
|
+
action: import_services16.QueryInvitationsResponse.Action.REMOVED,
|
|
6148
|
+
type: import_services16.QueryInvitationsResponse.Type.ACCEPTED,
|
|
5900
6149
|
invitations: [
|
|
5901
6150
|
invitation
|
|
5902
6151
|
]
|
|
@@ -5904,35 +6153,35 @@ var InvitationsServiceImpl = class {
|
|
|
5904
6153
|
});
|
|
5905
6154
|
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
5906
6155
|
next({
|
|
5907
|
-
action:
|
|
5908
|
-
type:
|
|
6156
|
+
action: import_services16.QueryInvitationsResponse.Action.SAVED,
|
|
6157
|
+
type: import_services16.QueryInvitationsResponse.Type.CREATED,
|
|
5909
6158
|
invitations: [
|
|
5910
6159
|
invitation
|
|
5911
6160
|
]
|
|
5912
6161
|
});
|
|
5913
6162
|
});
|
|
5914
6163
|
next({
|
|
5915
|
-
action:
|
|
5916
|
-
type:
|
|
6164
|
+
action: import_services16.QueryInvitationsResponse.Action.ADDED,
|
|
6165
|
+
type: import_services16.QueryInvitationsResponse.Type.CREATED,
|
|
5917
6166
|
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
5918
6167
|
existing: true
|
|
5919
6168
|
});
|
|
5920
6169
|
next({
|
|
5921
|
-
action:
|
|
5922
|
-
type:
|
|
6170
|
+
action: import_services16.QueryInvitationsResponse.Action.ADDED,
|
|
6171
|
+
type: import_services16.QueryInvitationsResponse.Type.ACCEPTED,
|
|
5923
6172
|
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
5924
6173
|
existing: true
|
|
5925
6174
|
});
|
|
5926
6175
|
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
5927
6176
|
next({
|
|
5928
|
-
action:
|
|
5929
|
-
type:
|
|
6177
|
+
action: import_services16.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
6178
|
+
type: import_services16.QueryInvitationsResponse.Type.CREATED
|
|
5930
6179
|
});
|
|
5931
6180
|
});
|
|
5932
6181
|
});
|
|
5933
6182
|
}
|
|
5934
6183
|
};
|
|
5935
|
-
var
|
|
6184
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
5936
6185
|
var SpaceInvitationProtocol = class {
|
|
5937
6186
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
5938
6187
|
this._spaceManager = _spaceManager;
|
|
@@ -5948,46 +6197,66 @@ var SpaceInvitationProtocol = class {
|
|
|
5948
6197
|
}
|
|
5949
6198
|
checkCanInviteNewMembers() {
|
|
5950
6199
|
if (this._spaceKey == null) {
|
|
5951
|
-
return new
|
|
6200
|
+
return new import_protocols13.InvalidInvitationError("No spaceKey was provided for a space invitation.");
|
|
5952
6201
|
}
|
|
5953
6202
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
5954
6203
|
if (space == null) {
|
|
5955
|
-
return new
|
|
6204
|
+
return new import_protocols13.SpaceNotFoundError(this._spaceKey);
|
|
5956
6205
|
}
|
|
5957
6206
|
if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
|
|
5958
|
-
return new
|
|
6207
|
+
return new import_protocols13.AuthorizationError("No member management permission.");
|
|
5959
6208
|
}
|
|
5960
6209
|
return void 0;
|
|
5961
6210
|
}
|
|
5962
6211
|
getInvitationContext() {
|
|
6212
|
+
(0, import_invariant17.invariant)(this._spaceKey, void 0, {
|
|
6213
|
+
F: __dxlog_file22,
|
|
6214
|
+
L: 63,
|
|
6215
|
+
S: this,
|
|
6216
|
+
A: [
|
|
6217
|
+
"this._spaceKey",
|
|
6218
|
+
""
|
|
6219
|
+
]
|
|
6220
|
+
});
|
|
6221
|
+
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6222
|
+
(0, import_invariant17.invariant)(space, void 0, {
|
|
6223
|
+
F: __dxlog_file22,
|
|
6224
|
+
L: 65,
|
|
6225
|
+
S: this,
|
|
6226
|
+
A: [
|
|
6227
|
+
"space",
|
|
6228
|
+
""
|
|
6229
|
+
]
|
|
6230
|
+
});
|
|
5963
6231
|
return {
|
|
5964
|
-
kind:
|
|
5965
|
-
spaceKey: this._spaceKey
|
|
6232
|
+
kind: import_services17.Invitation.Kind.SPACE,
|
|
6233
|
+
spaceKey: this._spaceKey,
|
|
6234
|
+
spaceId: space.id
|
|
5966
6235
|
};
|
|
5967
6236
|
}
|
|
5968
6237
|
async admit(invitation, request, guestProfile) {
|
|
5969
|
-
(0,
|
|
5970
|
-
F:
|
|
5971
|
-
L:
|
|
6238
|
+
(0, import_invariant17.invariant)(this._spaceKey && request.space, void 0, {
|
|
6239
|
+
F: __dxlog_file22,
|
|
6240
|
+
L: 78,
|
|
5972
6241
|
S: this,
|
|
5973
6242
|
A: [
|
|
5974
6243
|
"this._spaceKey && request.space",
|
|
5975
6244
|
""
|
|
5976
6245
|
]
|
|
5977
6246
|
});
|
|
5978
|
-
(0,
|
|
6247
|
+
(0, import_log19.log)("writing guest credentials", {
|
|
5979
6248
|
host: this._signingContext.deviceKey,
|
|
5980
6249
|
guest: request.space.deviceKey
|
|
5981
6250
|
}, {
|
|
5982
|
-
F:
|
|
5983
|
-
L:
|
|
6251
|
+
F: __dxlog_file22,
|
|
6252
|
+
L: 79,
|
|
5984
6253
|
S: this,
|
|
5985
6254
|
C: (f, a) => f(...a)
|
|
5986
6255
|
});
|
|
5987
6256
|
const spaceMemberCredential = await this._spaceManager.admitMember({
|
|
5988
6257
|
spaceKey: this._spaceKey,
|
|
5989
6258
|
identityKey: request.space.identityKey,
|
|
5990
|
-
role: invitation.role ??
|
|
6259
|
+
role: invitation.role ?? import_credentials19.SpaceMember.Role.ADMIN,
|
|
5991
6260
|
profile: guestProfile,
|
|
5992
6261
|
delegationCredentialId: invitation.delegationCredentialId
|
|
5993
6262
|
});
|
|
@@ -6000,9 +6269,9 @@ var SpaceInvitationProtocol = class {
|
|
|
6000
6269
|
};
|
|
6001
6270
|
}
|
|
6002
6271
|
async delegate(invitation) {
|
|
6003
|
-
(0,
|
|
6004
|
-
F:
|
|
6005
|
-
L:
|
|
6272
|
+
(0, import_invariant17.invariant)(this._spaceKey, void 0, {
|
|
6273
|
+
F: __dxlog_file22,
|
|
6274
|
+
L: 99,
|
|
6006
6275
|
S: this,
|
|
6007
6276
|
A: [
|
|
6008
6277
|
"this._spaceKey",
|
|
@@ -6010,19 +6279,19 @@ var SpaceInvitationProtocol = class {
|
|
|
6010
6279
|
]
|
|
6011
6280
|
});
|
|
6012
6281
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6013
|
-
(0,
|
|
6014
|
-
F:
|
|
6015
|
-
L:
|
|
6282
|
+
(0, import_invariant17.invariant)(space, void 0, {
|
|
6283
|
+
F: __dxlog_file22,
|
|
6284
|
+
L: 101,
|
|
6016
6285
|
S: this,
|
|
6017
6286
|
A: [
|
|
6018
6287
|
"space",
|
|
6019
6288
|
""
|
|
6020
6289
|
]
|
|
6021
6290
|
});
|
|
6022
|
-
if (invitation.authMethod ===
|
|
6023
|
-
(0,
|
|
6024
|
-
F:
|
|
6025
|
-
L:
|
|
6291
|
+
if (invitation.authMethod === import_services17.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
6292
|
+
(0, import_invariant17.invariant)(invitation.guestKeypair?.publicKey, void 0, {
|
|
6293
|
+
F: __dxlog_file22,
|
|
6294
|
+
L: 103,
|
|
6026
6295
|
S: this,
|
|
6027
6296
|
A: [
|
|
6028
6297
|
"invitation.guestKeypair?.publicKey",
|
|
@@ -6030,27 +6299,27 @@ var SpaceInvitationProtocol = class {
|
|
|
6030
6299
|
]
|
|
6031
6300
|
});
|
|
6032
6301
|
}
|
|
6033
|
-
(0,
|
|
6302
|
+
(0, import_log19.log)("writing delegate space invitation", {
|
|
6034
6303
|
host: this._signingContext.deviceKey,
|
|
6035
6304
|
id: invitation.invitationId
|
|
6036
6305
|
}, {
|
|
6037
|
-
F:
|
|
6038
|
-
L:
|
|
6306
|
+
F: __dxlog_file22,
|
|
6307
|
+
L: 106,
|
|
6039
6308
|
S: this,
|
|
6040
6309
|
C: (f, a) => f(...a)
|
|
6041
6310
|
});
|
|
6042
|
-
const credential = await (0,
|
|
6311
|
+
const credential = await (0, import_credentials18.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
|
|
6043
6312
|
invitationId: invitation.invitationId,
|
|
6044
6313
|
authMethod: invitation.authMethod,
|
|
6045
6314
|
swarmKey: invitation.swarmKey,
|
|
6046
|
-
role: invitation.role ??
|
|
6315
|
+
role: invitation.role ?? import_credentials19.SpaceMember.Role.ADMIN,
|
|
6047
6316
|
expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
|
|
6048
6317
|
multiUse: invitation.multiUse ?? false,
|
|
6049
|
-
guestKey: invitation.authMethod ===
|
|
6318
|
+
guestKey: invitation.authMethod === import_services17.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
6050
6319
|
});
|
|
6051
|
-
(0,
|
|
6052
|
-
F:
|
|
6053
|
-
L:
|
|
6320
|
+
(0, import_invariant17.invariant)(credential.credential, void 0, {
|
|
6321
|
+
F: __dxlog_file22,
|
|
6322
|
+
L: 126,
|
|
6054
6323
|
S: this,
|
|
6055
6324
|
A: [
|
|
6056
6325
|
"credential.credential",
|
|
@@ -6063,18 +6332,18 @@ var SpaceInvitationProtocol = class {
|
|
|
6063
6332
|
return credential.credential.credential.id;
|
|
6064
6333
|
}
|
|
6065
6334
|
async cancelDelegation(invitation) {
|
|
6066
|
-
(0,
|
|
6067
|
-
F:
|
|
6068
|
-
L:
|
|
6335
|
+
(0, import_invariant17.invariant)(this._spaceKey, void 0, {
|
|
6336
|
+
F: __dxlog_file22,
|
|
6337
|
+
L: 132,
|
|
6069
6338
|
S: this,
|
|
6070
6339
|
A: [
|
|
6071
6340
|
"this._spaceKey",
|
|
6072
6341
|
""
|
|
6073
6342
|
]
|
|
6074
6343
|
});
|
|
6075
|
-
(0,
|
|
6076
|
-
F:
|
|
6077
|
-
L:
|
|
6344
|
+
(0, import_invariant17.invariant)(invitation.type === import_services17.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
6345
|
+
F: __dxlog_file22,
|
|
6346
|
+
L: 133,
|
|
6078
6347
|
S: this,
|
|
6079
6348
|
A: [
|
|
6080
6349
|
"invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
|
|
@@ -6082,28 +6351,28 @@ var SpaceInvitationProtocol = class {
|
|
|
6082
6351
|
]
|
|
6083
6352
|
});
|
|
6084
6353
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6085
|
-
(0,
|
|
6086
|
-
F:
|
|
6087
|
-
L:
|
|
6354
|
+
(0, import_invariant17.invariant)(space, void 0, {
|
|
6355
|
+
F: __dxlog_file22,
|
|
6356
|
+
L: 135,
|
|
6088
6357
|
S: this,
|
|
6089
6358
|
A: [
|
|
6090
6359
|
"space",
|
|
6091
6360
|
""
|
|
6092
6361
|
]
|
|
6093
6362
|
});
|
|
6094
|
-
(0,
|
|
6363
|
+
(0, import_log19.log)("cancelling delegated space invitation", {
|
|
6095
6364
|
host: this._signingContext.deviceKey,
|
|
6096
6365
|
id: invitation.invitationId
|
|
6097
6366
|
}, {
|
|
6098
|
-
F:
|
|
6099
|
-
L:
|
|
6367
|
+
F: __dxlog_file22,
|
|
6368
|
+
L: 137,
|
|
6100
6369
|
S: this,
|
|
6101
6370
|
C: (f, a) => f(...a)
|
|
6102
6371
|
});
|
|
6103
|
-
const credential = await (0,
|
|
6104
|
-
(0,
|
|
6105
|
-
F:
|
|
6106
|
-
L:
|
|
6372
|
+
const credential = await (0, import_credentials18.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
6373
|
+
(0, import_invariant17.invariant)(credential.credential, void 0, {
|
|
6374
|
+
F: __dxlog_file22,
|
|
6375
|
+
L: 144,
|
|
6107
6376
|
S: this,
|
|
6108
6377
|
A: [
|
|
6109
6378
|
"credential.credential",
|
|
@@ -6116,10 +6385,10 @@ var SpaceInvitationProtocol = class {
|
|
|
6116
6385
|
}
|
|
6117
6386
|
checkInvitation(invitation) {
|
|
6118
6387
|
if (invitation.spaceKey == null) {
|
|
6119
|
-
return new
|
|
6388
|
+
return new import_protocols13.InvalidInvitationError("No spaceKey was provided for a space invitation.");
|
|
6120
6389
|
}
|
|
6121
6390
|
if (this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
6122
|
-
return new
|
|
6391
|
+
return new import_protocols13.AlreadyJoinedError("Already joined space.");
|
|
6123
6392
|
}
|
|
6124
6393
|
}
|
|
6125
6394
|
createIntroduction() {
|
|
@@ -6140,9 +6409,9 @@ var SpaceInvitationProtocol = class {
|
|
|
6140
6409
|
};
|
|
6141
6410
|
}
|
|
6142
6411
|
async accept(response) {
|
|
6143
|
-
(0,
|
|
6144
|
-
F:
|
|
6145
|
-
L:
|
|
6412
|
+
(0, import_invariant17.invariant)(response.space, void 0, {
|
|
6413
|
+
F: __dxlog_file22,
|
|
6414
|
+
L: 179,
|
|
6146
6415
|
S: this,
|
|
6147
6416
|
A: [
|
|
6148
6417
|
"response.space",
|
|
@@ -6150,19 +6419,19 @@ var SpaceInvitationProtocol = class {
|
|
|
6150
6419
|
]
|
|
6151
6420
|
});
|
|
6152
6421
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
6153
|
-
const assertion = (0,
|
|
6154
|
-
(0,
|
|
6155
|
-
F:
|
|
6156
|
-
L:
|
|
6422
|
+
const assertion = (0, import_credentials18.getCredentialAssertion)(credential);
|
|
6423
|
+
(0, import_invariant17.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
6424
|
+
F: __dxlog_file22,
|
|
6425
|
+
L: 182,
|
|
6157
6426
|
S: this,
|
|
6158
6427
|
A: [
|
|
6159
6428
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
6160
6429
|
"'Invalid credential'"
|
|
6161
6430
|
]
|
|
6162
6431
|
});
|
|
6163
|
-
(0,
|
|
6164
|
-
F:
|
|
6165
|
-
L:
|
|
6432
|
+
(0, import_invariant17.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
6433
|
+
F: __dxlog_file22,
|
|
6434
|
+
L: 183,
|
|
6166
6435
|
S: this,
|
|
6167
6436
|
A: [
|
|
6168
6437
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -6170,7 +6439,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6170
6439
|
]
|
|
6171
6440
|
});
|
|
6172
6441
|
if (this._spaceManager.spaces.has(assertion.spaceKey)) {
|
|
6173
|
-
throw new
|
|
6442
|
+
throw new import_protocols13.AlreadyJoinedError("Already joined space.");
|
|
6174
6443
|
}
|
|
6175
6444
|
await this._spaceManager.acceptSpace({
|
|
6176
6445
|
spaceKey: assertion.spaceKey,
|
|
@@ -6184,7 +6453,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6184
6453
|
};
|
|
6185
6454
|
}
|
|
6186
6455
|
};
|
|
6187
|
-
var
|
|
6456
|
+
var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
6188
6457
|
var InvitationsManager = class {
|
|
6189
6458
|
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
6190
6459
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -6192,12 +6461,12 @@ var InvitationsManager = class {
|
|
|
6192
6461
|
this._metadataStore = _metadataStore;
|
|
6193
6462
|
this._createInvitations = /* @__PURE__ */ new Map();
|
|
6194
6463
|
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
6195
|
-
this.invitationCreated = new
|
|
6196
|
-
this.invitationAccepted = new
|
|
6197
|
-
this.removedCreated = new
|
|
6198
|
-
this.removedAccepted = new
|
|
6199
|
-
this.saved = new
|
|
6200
|
-
this._persistentInvitationsLoadedEvent = new
|
|
6464
|
+
this.invitationCreated = new import_async20.Event();
|
|
6465
|
+
this.invitationAccepted = new import_async20.Event();
|
|
6466
|
+
this.removedCreated = new import_async20.Event();
|
|
6467
|
+
this.removedAccepted = new import_async20.Event();
|
|
6468
|
+
this.saved = new import_async20.Event();
|
|
6469
|
+
this._persistentInvitationsLoadedEvent = new import_async20.Event();
|
|
6201
6470
|
this._persistentInvitationsLoaded = false;
|
|
6202
6471
|
}
|
|
6203
6472
|
async createInvitation(options) {
|
|
@@ -6226,8 +6495,8 @@ var InvitationsManager = class {
|
|
|
6226
6495
|
try {
|
|
6227
6496
|
await this._persistIfRequired(handler, stream, invitation);
|
|
6228
6497
|
} catch (err) {
|
|
6229
|
-
|
|
6230
|
-
F:
|
|
6498
|
+
import_log20.log.catch(err, void 0, {
|
|
6499
|
+
F: __dxlog_file23,
|
|
6231
6500
|
L: 82,
|
|
6232
6501
|
S: this,
|
|
6233
6502
|
C: (f, a) => f(...a)
|
|
@@ -6249,8 +6518,8 @@ var InvitationsManager = class {
|
|
|
6249
6518
|
const persistentInvitations = this._metadataStore.getInvitations();
|
|
6250
6519
|
const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline4.hasInvitationExpired)(invitation));
|
|
6251
6520
|
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
6252
|
-
(0,
|
|
6253
|
-
F:
|
|
6521
|
+
(0, import_invariant18.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
6522
|
+
F: __dxlog_file23,
|
|
6254
6523
|
L: 103,
|
|
6255
6524
|
S: this,
|
|
6256
6525
|
A: [
|
|
@@ -6268,8 +6537,8 @@ var InvitationsManager = class {
|
|
|
6268
6537
|
invitations: cInvitations.map((invitation) => invitation.get())
|
|
6269
6538
|
};
|
|
6270
6539
|
} catch (err) {
|
|
6271
|
-
|
|
6272
|
-
F:
|
|
6540
|
+
import_log20.log.catch(err, void 0, {
|
|
6541
|
+
F: __dxlog_file23,
|
|
6273
6542
|
L: 110,
|
|
6274
6543
|
S: this,
|
|
6275
6544
|
C: (f, a) => f(...a)
|
|
@@ -6300,14 +6569,14 @@ var InvitationsManager = class {
|
|
|
6300
6569
|
return invitation;
|
|
6301
6570
|
}
|
|
6302
6571
|
async authenticate({ invitationId, authCode }) {
|
|
6303
|
-
(0,
|
|
6304
|
-
F:
|
|
6572
|
+
(0, import_log20.log)("authenticating...", void 0, {
|
|
6573
|
+
F: __dxlog_file23,
|
|
6305
6574
|
L: 140,
|
|
6306
6575
|
S: this,
|
|
6307
6576
|
C: (f, a) => f(...a)
|
|
6308
6577
|
});
|
|
6309
|
-
(0,
|
|
6310
|
-
F:
|
|
6578
|
+
(0, import_invariant18.invariant)(invitationId, void 0, {
|
|
6579
|
+
F: __dxlog_file23,
|
|
6311
6580
|
L: 141,
|
|
6312
6581
|
S: this,
|
|
6313
6582
|
A: [
|
|
@@ -6317,10 +6586,10 @@ var InvitationsManager = class {
|
|
|
6317
6586
|
});
|
|
6318
6587
|
const observable = this._acceptInvitations.get(invitationId);
|
|
6319
6588
|
if (!observable) {
|
|
6320
|
-
|
|
6589
|
+
import_log20.log.warn("invalid invitation", {
|
|
6321
6590
|
invitationId
|
|
6322
6591
|
}, {
|
|
6323
|
-
F:
|
|
6592
|
+
F: __dxlog_file23,
|
|
6324
6593
|
L: 144,
|
|
6325
6594
|
S: this,
|
|
6326
6595
|
C: (f, a) => f(...a)
|
|
@@ -6330,16 +6599,16 @@ var InvitationsManager = class {
|
|
|
6330
6599
|
}
|
|
6331
6600
|
}
|
|
6332
6601
|
async cancelInvitation({ invitationId }) {
|
|
6333
|
-
(0,
|
|
6602
|
+
(0, import_log20.log)("cancelInvitation...", {
|
|
6334
6603
|
invitationId
|
|
6335
6604
|
}, {
|
|
6336
|
-
F:
|
|
6605
|
+
F: __dxlog_file23,
|
|
6337
6606
|
L: 151,
|
|
6338
6607
|
S: this,
|
|
6339
6608
|
C: (f, a) => f(...a)
|
|
6340
6609
|
});
|
|
6341
|
-
(0,
|
|
6342
|
-
F:
|
|
6610
|
+
(0, import_invariant18.invariant)(invitationId, void 0, {
|
|
6611
|
+
F: __dxlog_file23,
|
|
6343
6612
|
L: 152,
|
|
6344
6613
|
S: this,
|
|
6345
6614
|
A: [
|
|
@@ -6352,7 +6621,7 @@ var InvitationsManager = class {
|
|
|
6352
6621
|
if (created.get().persistent) {
|
|
6353
6622
|
await this._metadataStore.removeInvitation(invitationId);
|
|
6354
6623
|
}
|
|
6355
|
-
if (created.get().type ===
|
|
6624
|
+
if (created.get().type === import_services18.Invitation.Type.DELEGATED) {
|
|
6356
6625
|
const handler = this._getHandler(created.get());
|
|
6357
6626
|
await handler.cancelDelegation(created.get());
|
|
6358
6627
|
}
|
|
@@ -6386,8 +6655,8 @@ var InvitationsManager = class {
|
|
|
6386
6655
|
}
|
|
6387
6656
|
}
|
|
6388
6657
|
_createInvitation(protocol, options) {
|
|
6389
|
-
const { invitationId =
|
|
6390
|
-
const authCode = options?.authCode ?? (authMethod ===
|
|
6658
|
+
const { invitationId = import_keys14.PublicKey.random().toHex(), type = import_services18.Invitation.Type.INTERACTIVE, authMethod = import_services18.Invitation.AuthMethod.SHARED_SECRET, state = import_services18.Invitation.State.INIT, timeout = import_client_protocol6.INVITATION_TIMEOUT, swarmKey = import_keys14.PublicKey.random(), persistent = options?.authMethod !== import_services18.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials21.SpaceMember.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
|
|
6659
|
+
const authCode = options?.authCode ?? (authMethod === import_services18.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials20.generatePasscode)(import_client_protocol6.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
6391
6660
|
return {
|
|
6392
6661
|
invitationId,
|
|
6393
6662
|
type,
|
|
@@ -6396,8 +6665,8 @@ var InvitationsManager = class {
|
|
|
6396
6665
|
swarmKey,
|
|
6397
6666
|
authCode,
|
|
6398
6667
|
timeout,
|
|
6399
|
-
persistent: persistent && type !==
|
|
6400
|
-
guestKeypair: guestKeypair ?? (authMethod ===
|
|
6668
|
+
persistent: persistent && type !== import_services18.Invitation.Type.DELEGATED,
|
|
6669
|
+
guestKeypair: guestKeypair ?? (authMethod === import_services18.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
6401
6670
|
created,
|
|
6402
6671
|
lifetime,
|
|
6403
6672
|
role,
|
|
@@ -6407,21 +6676,21 @@ var InvitationsManager = class {
|
|
|
6407
6676
|
};
|
|
6408
6677
|
}
|
|
6409
6678
|
_createObservableInvitation(handler, invitation) {
|
|
6410
|
-
const stream = new
|
|
6679
|
+
const stream = new import_async20.PushStream();
|
|
6411
6680
|
const ctx = new import_context14.Context({
|
|
6412
6681
|
onError: (err) => {
|
|
6413
6682
|
stream.error(err);
|
|
6414
6683
|
void ctx.dispose();
|
|
6415
6684
|
}
|
|
6416
6685
|
}, {
|
|
6417
|
-
F:
|
|
6686
|
+
F: __dxlog_file23,
|
|
6418
6687
|
L: 234
|
|
6419
6688
|
});
|
|
6420
6689
|
ctx.onDispose(() => {
|
|
6421
|
-
(0,
|
|
6690
|
+
(0, import_log20.log)("complete", {
|
|
6422
6691
|
...handler.toJSON()
|
|
6423
6692
|
}, {
|
|
6424
|
-
F:
|
|
6693
|
+
F: __dxlog_file23,
|
|
6425
6694
|
L: 241,
|
|
6426
6695
|
S: this,
|
|
6427
6696
|
C: (f, a) => f(...a)
|
|
@@ -6434,7 +6703,7 @@ var InvitationsManager = class {
|
|
|
6434
6703
|
onCancel: async () => {
|
|
6435
6704
|
stream.next({
|
|
6436
6705
|
...invitation,
|
|
6437
|
-
state:
|
|
6706
|
+
state: import_services18.Invitation.State.CANCELLED
|
|
6438
6707
|
});
|
|
6439
6708
|
await ctx.dispose();
|
|
6440
6709
|
}
|
|
@@ -6446,46 +6715,46 @@ var InvitationsManager = class {
|
|
|
6446
6715
|
};
|
|
6447
6716
|
}
|
|
6448
6717
|
_createObservableAcceptingInvitation(handler, initialState) {
|
|
6449
|
-
const otpEnteredTrigger = new
|
|
6450
|
-
const stream = new
|
|
6718
|
+
const otpEnteredTrigger = new import_async20.Trigger();
|
|
6719
|
+
const stream = new import_async20.PushStream();
|
|
6451
6720
|
const ctx = new import_context14.Context({
|
|
6452
6721
|
onError: (err) => {
|
|
6453
|
-
if (err instanceof
|
|
6454
|
-
(0,
|
|
6722
|
+
if (err instanceof import_async20.TimeoutError) {
|
|
6723
|
+
(0, import_log20.log)("timeout", {
|
|
6455
6724
|
...handler.toJSON()
|
|
6456
6725
|
}, {
|
|
6457
|
-
F:
|
|
6726
|
+
F: __dxlog_file23,
|
|
6458
6727
|
L: 261,
|
|
6459
6728
|
S: this,
|
|
6460
6729
|
C: (f, a) => f(...a)
|
|
6461
6730
|
});
|
|
6462
6731
|
stream.next({
|
|
6463
6732
|
...initialState,
|
|
6464
|
-
state:
|
|
6733
|
+
state: import_services18.Invitation.State.TIMEOUT
|
|
6465
6734
|
});
|
|
6466
6735
|
} else {
|
|
6467
|
-
|
|
6468
|
-
F:
|
|
6736
|
+
import_log20.log.warn("auth failed", err, {
|
|
6737
|
+
F: __dxlog_file23,
|
|
6469
6738
|
L: 264,
|
|
6470
6739
|
S: this,
|
|
6471
6740
|
C: (f, a) => f(...a)
|
|
6472
6741
|
});
|
|
6473
6742
|
stream.next({
|
|
6474
6743
|
...initialState,
|
|
6475
|
-
state:
|
|
6744
|
+
state: import_services18.Invitation.State.ERROR
|
|
6476
6745
|
});
|
|
6477
6746
|
}
|
|
6478
6747
|
void ctx.dispose();
|
|
6479
6748
|
}
|
|
6480
6749
|
}, {
|
|
6481
|
-
F:
|
|
6750
|
+
F: __dxlog_file23,
|
|
6482
6751
|
L: 258
|
|
6483
6752
|
});
|
|
6484
6753
|
ctx.onDispose(() => {
|
|
6485
|
-
(0,
|
|
6754
|
+
(0, import_log20.log)("complete", {
|
|
6486
6755
|
...handler.toJSON()
|
|
6487
6756
|
}, {
|
|
6488
|
-
F:
|
|
6757
|
+
F: __dxlog_file23,
|
|
6489
6758
|
L: 271,
|
|
6490
6759
|
S: this,
|
|
6491
6760
|
C: (f, a) => f(...a)
|
|
@@ -6498,7 +6767,7 @@ var InvitationsManager = class {
|
|
|
6498
6767
|
onCancel: async () => {
|
|
6499
6768
|
stream.next({
|
|
6500
6769
|
...initialState,
|
|
6501
|
-
state:
|
|
6770
|
+
state: import_services18.Invitation.State.CANCELLED
|
|
6502
6771
|
});
|
|
6503
6772
|
await ctx.dispose();
|
|
6504
6773
|
},
|
|
@@ -6514,7 +6783,7 @@ var InvitationsManager = class {
|
|
|
6514
6783
|
};
|
|
6515
6784
|
}
|
|
6516
6785
|
async _persistIfRequired(handler, changeStream, invitation) {
|
|
6517
|
-
if (invitation.type ===
|
|
6786
|
+
if (invitation.type === import_services18.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
|
|
6518
6787
|
const delegationCredentialId = await handler.delegate(invitation);
|
|
6519
6788
|
changeStream.next({
|
|
6520
6789
|
...invitation,
|
|
@@ -6529,8 +6798,8 @@ var InvitationsManager = class {
|
|
|
6529
6798
|
try {
|
|
6530
6799
|
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
6531
6800
|
} catch (err) {
|
|
6532
|
-
|
|
6533
|
-
F:
|
|
6801
|
+
import_log20.log.catch(err, void 0, {
|
|
6802
|
+
F: __dxlog_file23,
|
|
6534
6803
|
L: 307,
|
|
6535
6804
|
S: this,
|
|
6536
6805
|
C: (f, a) => f(...a)
|
|
@@ -6549,7 +6818,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
6549
6818
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6550
6819
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6551
6820
|
}
|
|
6552
|
-
var
|
|
6821
|
+
var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
6553
6822
|
var Lock = class {
|
|
6554
6823
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
6555
6824
|
this._lockPath = lockPath;
|
|
@@ -6560,16 +6829,16 @@ var Lock = class {
|
|
|
6560
6829
|
return this._lockPath;
|
|
6561
6830
|
}
|
|
6562
6831
|
async acquire() {
|
|
6563
|
-
(0,
|
|
6564
|
-
F:
|
|
6832
|
+
(0, import_log21.log)("acquiring lock...", void 0, {
|
|
6833
|
+
F: __dxlog_file24,
|
|
6565
6834
|
L: 32,
|
|
6566
6835
|
S: this,
|
|
6567
6836
|
C: (f, a) => f(...a)
|
|
6568
6837
|
});
|
|
6569
6838
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
6570
6839
|
await this._onAcquire?.();
|
|
6571
|
-
(0,
|
|
6572
|
-
F:
|
|
6840
|
+
(0, import_log21.log)("acquired lock", void 0, {
|
|
6841
|
+
F: __dxlog_file24,
|
|
6573
6842
|
L: 37,
|
|
6574
6843
|
S: this,
|
|
6575
6844
|
C: (f, a) => f(...a)
|
|
@@ -6577,8 +6846,8 @@ var Lock = class {
|
|
|
6577
6846
|
}
|
|
6578
6847
|
async release() {
|
|
6579
6848
|
await this._onRelease?.();
|
|
6580
|
-
(0,
|
|
6581
|
-
F:
|
|
6849
|
+
(0, import_invariant19.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
6850
|
+
F: __dxlog_file24,
|
|
6582
6851
|
L: 42,
|
|
6583
6852
|
S: this,
|
|
6584
6853
|
A: [
|
|
@@ -6590,7 +6859,7 @@ var Lock = class {
|
|
|
6590
6859
|
}
|
|
6591
6860
|
};
|
|
6592
6861
|
_ts_decorate7([
|
|
6593
|
-
|
|
6862
|
+
import_log21.logInfo
|
|
6594
6863
|
], Lock.prototype, "lockKey", null);
|
|
6595
6864
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
6596
6865
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
@@ -6732,7 +7001,7 @@ function _using_ctx3() {
|
|
|
6732
7001
|
}
|
|
6733
7002
|
};
|
|
6734
7003
|
}
|
|
6735
|
-
var
|
|
7004
|
+
var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
6736
7005
|
var ServiceContext = class extends import_context15.Resource {
|
|
6737
7006
|
constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
|
|
6738
7007
|
super();
|
|
@@ -6744,12 +7013,12 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
6744
7013
|
this._edgeHttpClient = _edgeHttpClient;
|
|
6745
7014
|
this._runtimeParams = _runtimeParams;
|
|
6746
7015
|
this._edgeFeatures = _edgeFeatures;
|
|
6747
|
-
this._edgeIdentityUpdateMutex = new
|
|
6748
|
-
this.initialized = new
|
|
7016
|
+
this._edgeIdentityUpdateMutex = new import_async21.Mutex();
|
|
7017
|
+
this.initialized = new import_async21.Trigger();
|
|
6749
7018
|
this._meshReplicator = void 0;
|
|
6750
7019
|
this._echoEdgeReplicator = void 0;
|
|
6751
7020
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
6752
|
-
this._instanceId =
|
|
7021
|
+
this._instanceId = import_keys15.PublicKey.random().toHex();
|
|
6753
7022
|
this.metadataStore = new import_echo_pipeline5.MetadataStore(storage.createDirectory("metadata"));
|
|
6754
7023
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
6755
7024
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
@@ -6778,58 +7047,15 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
6778
7047
|
devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
|
|
6779
7048
|
devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
|
|
6780
7049
|
edgeConnection: this._edgeConnection,
|
|
6781
|
-
edgeFeatures: this._edgeFeatures
|
|
6782
|
-
callbacks: {
|
|
6783
|
-
onIdentityConstruction: (identity) => {
|
|
6784
|
-
if (this._edgeConnection) {
|
|
6785
|
-
(0, import_async19.scheduleMicroTask)(this._ctx, async () => {
|
|
6786
|
-
try {
|
|
6787
|
-
var _usingCtx = _using_ctx3();
|
|
6788
|
-
const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
|
|
6789
|
-
import_log20.log.info("Setting identity on edge connection", {
|
|
6790
|
-
identity: identity.identityKey.toHex(),
|
|
6791
|
-
oldIdentity: this._edgeConnection.identityKey,
|
|
6792
|
-
swarms: this.networkManager.topics
|
|
6793
|
-
}, {
|
|
6794
|
-
F: __dxlog_file23,
|
|
6795
|
-
L: 147,
|
|
6796
|
-
S: this,
|
|
6797
|
-
C: (f, a) => f(...a)
|
|
6798
|
-
});
|
|
6799
|
-
await (0, import_debug6.warnAfterTimeout)(1e4, "Waiting for identity to be ready for edge connection", async () => {
|
|
6800
|
-
await identity.ready();
|
|
6801
|
-
});
|
|
6802
|
-
(0, import_invariant19.invariant)(identity.deviceCredentialChain, void 0, {
|
|
6803
|
-
F: __dxlog_file23,
|
|
6804
|
-
L: 157,
|
|
6805
|
-
S: this,
|
|
6806
|
-
A: [
|
|
6807
|
-
"identity.deviceCredentialChain",
|
|
6808
|
-
""
|
|
6809
|
-
]
|
|
6810
|
-
});
|
|
6811
|
-
this._edgeConnection.setIdentity(await (0, import_edge_client2.createChainEdgeIdentity)(identity.signer, identity.identityKey, identity.deviceKey, identity.deviceCredentialChain, []));
|
|
6812
|
-
this.networkManager.setPeerInfo({
|
|
6813
|
-
identityKey: identity.identityKey.toHex(),
|
|
6814
|
-
peerKey: identity.deviceKey.toHex()
|
|
6815
|
-
});
|
|
6816
|
-
} catch (_) {
|
|
6817
|
-
_usingCtx.e = _;
|
|
6818
|
-
} finally {
|
|
6819
|
-
_usingCtx.d();
|
|
6820
|
-
}
|
|
6821
|
-
});
|
|
6822
|
-
}
|
|
6823
|
-
}
|
|
6824
|
-
}
|
|
7050
|
+
edgeFeatures: this._edgeFeatures
|
|
6825
7051
|
});
|
|
6826
7052
|
this.echoHost = new import_echo_pipeline5.EchoHost({
|
|
6827
7053
|
kv: this.level
|
|
6828
7054
|
});
|
|
6829
7055
|
this._meshReplicator = new import_echo_pipeline5.MeshEchoReplicator();
|
|
6830
|
-
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
7056
|
+
this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
|
|
6831
7057
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
6832
|
-
this._handlerFactories.set(
|
|
7058
|
+
this._handlerFactories.set(import_services19.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
6833
7059
|
if (!this._runtimeParams?.disableP2pReplication) {
|
|
6834
7060
|
this._meshReplicator = new import_echo_pipeline5.MeshEchoReplicator();
|
|
6835
7061
|
}
|
|
@@ -6841,24 +7067,23 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
6841
7067
|
}
|
|
6842
7068
|
async _open(ctx) {
|
|
6843
7069
|
await this._checkStorageVersion();
|
|
6844
|
-
(0,
|
|
6845
|
-
F:
|
|
6846
|
-
L:
|
|
7070
|
+
(0, import_log22.log)("opening...", void 0, {
|
|
7071
|
+
F: __dxlog_file25,
|
|
7072
|
+
L: 184,
|
|
6847
7073
|
S: this,
|
|
6848
7074
|
C: (f, a) => f(...a)
|
|
6849
7075
|
});
|
|
6850
|
-
|
|
7076
|
+
import_log22.log.trace("dxos.sdk.service-context.open", import_protocols14.trace.begin({
|
|
6851
7077
|
id: this._instanceId
|
|
6852
7078
|
}), {
|
|
6853
|
-
F:
|
|
6854
|
-
L:
|
|
7079
|
+
F: __dxlog_file25,
|
|
7080
|
+
L: 185,
|
|
6855
7081
|
S: this,
|
|
6856
7082
|
C: (f, a) => f(...a)
|
|
6857
7083
|
});
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
}
|
|
7084
|
+
await this.identityManager.open(ctx);
|
|
7085
|
+
await this._setNetworkIdentity();
|
|
7086
|
+
await this._edgeConnection?.open();
|
|
6862
7087
|
await this.signalManager.open();
|
|
6863
7088
|
await this.networkManager.open();
|
|
6864
7089
|
await this.echoHost.open(ctx);
|
|
@@ -6870,38 +7095,38 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
6870
7095
|
}
|
|
6871
7096
|
await this.metadataStore.load();
|
|
6872
7097
|
await this.spaceManager.open();
|
|
6873
|
-
await this.identityManager.open(ctx);
|
|
6874
7098
|
if (this.identityManager.identity) {
|
|
7099
|
+
await this.identityManager.identity.joinNetwork();
|
|
6875
7100
|
await this._initialize(ctx);
|
|
6876
7101
|
}
|
|
6877
7102
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
6878
|
-
(0,
|
|
7103
|
+
(0, import_log22.log)("loaded persistent invitations", {
|
|
6879
7104
|
count: loadedInvitations.invitations?.length
|
|
6880
7105
|
}, {
|
|
6881
|
-
F:
|
|
6882
|
-
L:
|
|
7106
|
+
F: __dxlog_file25,
|
|
7107
|
+
L: 213,
|
|
6883
7108
|
S: this,
|
|
6884
7109
|
C: (f, a) => f(...a)
|
|
6885
7110
|
});
|
|
6886
|
-
|
|
7111
|
+
import_log22.log.trace("dxos.sdk.service-context.open", import_protocols14.trace.end({
|
|
6887
7112
|
id: this._instanceId
|
|
6888
7113
|
}), {
|
|
6889
|
-
F:
|
|
6890
|
-
L:
|
|
7114
|
+
F: __dxlog_file25,
|
|
7115
|
+
L: 215,
|
|
6891
7116
|
S: this,
|
|
6892
7117
|
C: (f, a) => f(...a)
|
|
6893
7118
|
});
|
|
6894
|
-
(0,
|
|
6895
|
-
F:
|
|
6896
|
-
L:
|
|
7119
|
+
(0, import_log22.log)("opened", void 0, {
|
|
7120
|
+
F: __dxlog_file25,
|
|
7121
|
+
L: 216,
|
|
6897
7122
|
S: this,
|
|
6898
7123
|
C: (f, a) => f(...a)
|
|
6899
7124
|
});
|
|
6900
7125
|
}
|
|
6901
7126
|
async _close(ctx) {
|
|
6902
|
-
(0,
|
|
6903
|
-
F:
|
|
6904
|
-
L:
|
|
7127
|
+
(0, import_log22.log)("closing...", void 0, {
|
|
7128
|
+
F: __dxlog_file25,
|
|
7129
|
+
L: 220,
|
|
6905
7130
|
S: this,
|
|
6906
7131
|
C: (f, a) => f(...a)
|
|
6907
7132
|
});
|
|
@@ -6917,26 +7142,28 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
6917
7142
|
await this.networkManager.close();
|
|
6918
7143
|
await this.signalManager.close();
|
|
6919
7144
|
await this._edgeConnection?.close();
|
|
6920
|
-
(0,
|
|
6921
|
-
F:
|
|
6922
|
-
L:
|
|
7145
|
+
(0, import_log22.log)("closed", void 0, {
|
|
7146
|
+
F: __dxlog_file25,
|
|
7147
|
+
L: 235,
|
|
6923
7148
|
S: this,
|
|
6924
7149
|
C: (f, a) => f(...a)
|
|
6925
7150
|
});
|
|
6926
7151
|
}
|
|
6927
7152
|
async createIdentity(params = {}) {
|
|
6928
7153
|
const identity = await this.identityManager.createIdentity(params);
|
|
7154
|
+
await this._setNetworkIdentity();
|
|
7155
|
+
await identity.joinNetwork();
|
|
6929
7156
|
await this._initialize(new import_context15.Context(void 0, {
|
|
6930
|
-
F:
|
|
6931
|
-
L:
|
|
7157
|
+
F: __dxlog_file25,
|
|
7158
|
+
L: 242
|
|
6932
7159
|
}));
|
|
6933
7160
|
return identity;
|
|
6934
7161
|
}
|
|
6935
7162
|
getInvitationHandler(invitation) {
|
|
6936
7163
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
6937
|
-
(0,
|
|
6938
|
-
F:
|
|
6939
|
-
L:
|
|
7164
|
+
(0, import_invariant20.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
7165
|
+
F: __dxlog_file25,
|
|
7166
|
+
L: 248,
|
|
6940
7167
|
S: this,
|
|
6941
7168
|
A: [
|
|
6942
7169
|
"factory",
|
|
@@ -6954,24 +7181,29 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
6954
7181
|
}
|
|
6955
7182
|
}
|
|
6956
7183
|
async _acceptIdentity(params) {
|
|
6957
|
-
const identity = await this.identityManager.
|
|
7184
|
+
const { identity, identityRecord } = await this.identityManager.prepareIdentity(params);
|
|
7185
|
+
await this._setNetworkIdentity({
|
|
7186
|
+
deviceCredential: params.authorizedDeviceCredential
|
|
7187
|
+
});
|
|
7188
|
+
await identity.joinNetwork();
|
|
7189
|
+
await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
|
|
6958
7190
|
await this._initialize(new import_context15.Context(void 0, {
|
|
6959
|
-
F:
|
|
6960
|
-
L:
|
|
7191
|
+
F: __dxlog_file25,
|
|
7192
|
+
L: 267
|
|
6961
7193
|
}));
|
|
6962
7194
|
return identity;
|
|
6963
7195
|
}
|
|
6964
7196
|
async _checkStorageVersion() {
|
|
6965
7197
|
await this.metadataStore.load();
|
|
6966
|
-
if (this.metadataStore.version !==
|
|
6967
|
-
throw new
|
|
7198
|
+
if (this.metadataStore.version !== import_protocols14.STORAGE_VERSION) {
|
|
7199
|
+
throw new import_protocols14.InvalidStorageVersionError(import_protocols14.STORAGE_VERSION, this.metadataStore.version);
|
|
6968
7200
|
}
|
|
6969
7201
|
}
|
|
6970
7202
|
// Called when identity is created.
|
|
6971
7203
|
async _initialize(ctx) {
|
|
6972
|
-
(0,
|
|
6973
|
-
F:
|
|
6974
|
-
L:
|
|
7204
|
+
(0, import_log22.log)("initializing spaces...", void 0, {
|
|
7205
|
+
F: __dxlog_file25,
|
|
7206
|
+
L: 282,
|
|
6975
7207
|
S: this,
|
|
6976
7208
|
C: (f, a) => f(...a)
|
|
6977
7209
|
});
|
|
@@ -7005,10 +7237,10 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
7005
7237
|
edgeFeatures: this._edgeFeatures
|
|
7006
7238
|
});
|
|
7007
7239
|
await this.dataSpaceManager.open();
|
|
7008
|
-
this._handlerFactories.set(
|
|
7009
|
-
(0,
|
|
7010
|
-
F:
|
|
7011
|
-
L:
|
|
7240
|
+
this._handlerFactories.set(import_services19.Invitation.Kind.SPACE, (invitation) => {
|
|
7241
|
+
(0, import_invariant20.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
7242
|
+
F: __dxlog_file25,
|
|
7243
|
+
L: 312,
|
|
7012
7244
|
S: this,
|
|
7013
7245
|
A: [
|
|
7014
7246
|
"this.dataSpaceManager",
|
|
@@ -7020,7 +7252,7 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
7020
7252
|
this.initialized.wake();
|
|
7021
7253
|
this._deviceSpaceSync = {
|
|
7022
7254
|
processCredential: async (credential) => {
|
|
7023
|
-
const assertion = (0,
|
|
7255
|
+
const assertion = (0, import_credentials22.getCredentialAssertion)(credential);
|
|
7024
7256
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
7025
7257
|
return;
|
|
7026
7258
|
}
|
|
@@ -7028,33 +7260,33 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
7028
7260
|
return;
|
|
7029
7261
|
}
|
|
7030
7262
|
if (!this.dataSpaceManager) {
|
|
7031
|
-
(0,
|
|
7263
|
+
(0, import_log22.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
7032
7264
|
details: assertion
|
|
7033
7265
|
}, {
|
|
7034
|
-
F:
|
|
7035
|
-
L:
|
|
7266
|
+
F: __dxlog_file25,
|
|
7267
|
+
L: 328,
|
|
7036
7268
|
S: this,
|
|
7037
7269
|
C: (f, a) => f(...a)
|
|
7038
7270
|
});
|
|
7039
7271
|
return;
|
|
7040
7272
|
}
|
|
7041
7273
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
7042
|
-
(0,
|
|
7274
|
+
(0, import_log22.log)("space already exists, ignoring space admission", {
|
|
7043
7275
|
details: assertion
|
|
7044
7276
|
}, {
|
|
7045
|
-
F:
|
|
7046
|
-
L:
|
|
7277
|
+
F: __dxlog_file25,
|
|
7278
|
+
L: 332,
|
|
7047
7279
|
S: this,
|
|
7048
7280
|
C: (f, a) => f(...a)
|
|
7049
7281
|
});
|
|
7050
7282
|
return;
|
|
7051
7283
|
}
|
|
7052
7284
|
try {
|
|
7053
|
-
(0,
|
|
7285
|
+
(0, import_log22.log)("accepting space recorded in halo", {
|
|
7054
7286
|
details: assertion
|
|
7055
7287
|
}, {
|
|
7056
|
-
F:
|
|
7057
|
-
L:
|
|
7288
|
+
F: __dxlog_file25,
|
|
7289
|
+
L: 337,
|
|
7058
7290
|
S: this,
|
|
7059
7291
|
C: (f, a) => f(...a)
|
|
7060
7292
|
});
|
|
@@ -7063,9 +7295,9 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
7063
7295
|
genesisFeedKey: assertion.genesisFeedKey
|
|
7064
7296
|
});
|
|
7065
7297
|
} catch (err) {
|
|
7066
|
-
|
|
7067
|
-
F:
|
|
7068
|
-
L:
|
|
7298
|
+
import_log22.log.catch(err, void 0, {
|
|
7299
|
+
F: __dxlog_file25,
|
|
7300
|
+
L: 343,
|
|
7069
7301
|
S: this,
|
|
7070
7302
|
C: (f, a) => f(...a)
|
|
7071
7303
|
});
|
|
@@ -7074,6 +7306,57 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
7074
7306
|
};
|
|
7075
7307
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
7076
7308
|
}
|
|
7309
|
+
async _setNetworkIdentity(params) {
|
|
7310
|
+
try {
|
|
7311
|
+
var _usingCtx = _using_ctx3();
|
|
7312
|
+
const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
|
|
7313
|
+
let edgeIdentity;
|
|
7314
|
+
const identity = this.identityManager.identity;
|
|
7315
|
+
if (identity) {
|
|
7316
|
+
import_log22.log.info("Setting identity on edge connection", {
|
|
7317
|
+
identity: identity.identityKey.toHex(),
|
|
7318
|
+
swarms: this.networkManager.topics
|
|
7319
|
+
}, {
|
|
7320
|
+
F: __dxlog_file25,
|
|
7321
|
+
L: 357,
|
|
7322
|
+
S: this,
|
|
7323
|
+
C: (f, a) => f(...a)
|
|
7324
|
+
});
|
|
7325
|
+
if (params?.deviceCredential) {
|
|
7326
|
+
edgeIdentity = await (0, import_edge_client2.createChainEdgeIdentity)(identity.signer, identity.identityKey, identity.deviceKey, {
|
|
7327
|
+
credential: params.deviceCredential
|
|
7328
|
+
}, []);
|
|
7329
|
+
} else {
|
|
7330
|
+
await (0, import_debug6.warnAfterTimeout)(1e4, "Waiting for identity to be ready for edge connection", async () => {
|
|
7331
|
+
await identity.ready();
|
|
7332
|
+
});
|
|
7333
|
+
(0, import_invariant20.invariant)(identity.deviceCredentialChain, void 0, {
|
|
7334
|
+
F: __dxlog_file25,
|
|
7335
|
+
L: 375,
|
|
7336
|
+
S: this,
|
|
7337
|
+
A: [
|
|
7338
|
+
"identity.deviceCredentialChain",
|
|
7339
|
+
""
|
|
7340
|
+
]
|
|
7341
|
+
});
|
|
7342
|
+
edgeIdentity = await (0, import_edge_client2.createChainEdgeIdentity)(identity.signer, identity.identityKey, identity.deviceKey, identity.deviceCredentialChain, []);
|
|
7343
|
+
}
|
|
7344
|
+
} else {
|
|
7345
|
+
edgeIdentity = await (0, import_edge_client2.createEphemeralEdgeIdentity)();
|
|
7346
|
+
}
|
|
7347
|
+
if (this._edgeConnection) {
|
|
7348
|
+
this._edgeConnection.setIdentity(edgeIdentity);
|
|
7349
|
+
}
|
|
7350
|
+
this.networkManager.setPeerInfo({
|
|
7351
|
+
identityKey: edgeIdentity.identityKey,
|
|
7352
|
+
peerKey: edgeIdentity.peerKey
|
|
7353
|
+
});
|
|
7354
|
+
} catch (_) {
|
|
7355
|
+
_usingCtx.e = _;
|
|
7356
|
+
} finally {
|
|
7357
|
+
_usingCtx.d();
|
|
7358
|
+
}
|
|
7359
|
+
}
|
|
7077
7360
|
};
|
|
7078
7361
|
_ts_decorate9([
|
|
7079
7362
|
import_tracing10.trace.span()
|
|
@@ -7119,16 +7402,16 @@ var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
|
|
|
7119
7402
|
var createStorageObjects = (config) => {
|
|
7120
7403
|
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
7121
7404
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
7122
|
-
throw new
|
|
7405
|
+
throw new import_protocols15.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
7123
7406
|
}
|
|
7124
7407
|
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
7125
|
-
throw new
|
|
7408
|
+
throw new import_protocols15.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
7126
7409
|
}
|
|
7127
7410
|
if (persistent && keyStore === StorageDriver.RAM) {
|
|
7128
|
-
throw new
|
|
7411
|
+
throw new import_protocols15.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
7129
7412
|
}
|
|
7130
7413
|
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
7131
|
-
throw new
|
|
7414
|
+
throw new import_protocols15.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
7132
7415
|
}
|
|
7133
7416
|
return {
|
|
7134
7417
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -7159,12 +7442,12 @@ var toStorageType = (type) => {
|
|
|
7159
7442
|
};
|
|
7160
7443
|
var createLevel = async (config) => {
|
|
7161
7444
|
const persistent = isPersistent(config);
|
|
7162
|
-
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${
|
|
7445
|
+
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys16.PublicKey.random().toHex()}`;
|
|
7163
7446
|
const level = (0, import_kv_store.createLevel)(storagePath);
|
|
7164
7447
|
await level.open();
|
|
7165
7448
|
return level;
|
|
7166
7449
|
};
|
|
7167
|
-
var
|
|
7450
|
+
var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
|
|
7168
7451
|
var encodeProfileArchive = (profile) => import_automerge_repo.cbor.encode(profile);
|
|
7169
7452
|
var decodeProfileArchive = (data) => import_automerge_repo.cbor.decode(data);
|
|
7170
7453
|
var exportProfileData = async ({ storage, level }) => {
|
|
@@ -7177,10 +7460,10 @@ var exportProfileData = async ({ storage, level }) => {
|
|
|
7177
7460
|
{
|
|
7178
7461
|
const directory = await storage.createDirectory();
|
|
7179
7462
|
const files = await directory.list();
|
|
7180
|
-
|
|
7463
|
+
import_log23.log.info("begin exporting files", {
|
|
7181
7464
|
count: files.length
|
|
7182
7465
|
}, {
|
|
7183
|
-
F:
|
|
7466
|
+
F: __dxlog_file26,
|
|
7184
7467
|
L: 30,
|
|
7185
7468
|
S: void 0,
|
|
7186
7469
|
C: (f, a) => f(...a)
|
|
@@ -7190,23 +7473,23 @@ var exportProfileData = async ({ storage, level }) => {
|
|
|
7190
7473
|
const { size } = await file.stat();
|
|
7191
7474
|
const data = await file.read(0, size);
|
|
7192
7475
|
archive.storage.push({
|
|
7193
|
-
type:
|
|
7476
|
+
type: import_protocols16.ProfileArchiveEntryType.FILE,
|
|
7194
7477
|
key: filename,
|
|
7195
7478
|
value: data
|
|
7196
7479
|
});
|
|
7197
7480
|
}
|
|
7198
|
-
|
|
7481
|
+
import_log23.log.info("done exporting files", {
|
|
7199
7482
|
count: files.length
|
|
7200
7483
|
}, {
|
|
7201
|
-
F:
|
|
7484
|
+
F: __dxlog_file26,
|
|
7202
7485
|
L: 41,
|
|
7203
7486
|
S: void 0,
|
|
7204
7487
|
C: (f, a) => f(...a)
|
|
7205
7488
|
});
|
|
7206
7489
|
}
|
|
7207
7490
|
{
|
|
7208
|
-
|
|
7209
|
-
F:
|
|
7491
|
+
import_log23.log.info("begin exporting kv pairs", void 0, {
|
|
7492
|
+
F: __dxlog_file26,
|
|
7210
7493
|
L: 45,
|
|
7211
7494
|
S: void 0,
|
|
7212
7495
|
C: (f, a) => f(...a)
|
|
@@ -7218,16 +7501,16 @@ var exportProfileData = async ({ storage, level }) => {
|
|
|
7218
7501
|
let count = 0;
|
|
7219
7502
|
for await (const [key, value] of iter) {
|
|
7220
7503
|
archive.storage.push({
|
|
7221
|
-
type:
|
|
7504
|
+
type: import_protocols16.ProfileArchiveEntryType.KEY_VALUE,
|
|
7222
7505
|
key,
|
|
7223
7506
|
value
|
|
7224
7507
|
});
|
|
7225
7508
|
count++;
|
|
7226
7509
|
}
|
|
7227
|
-
|
|
7510
|
+
import_log23.log.info("done exporting kv pairs", {
|
|
7228
7511
|
count
|
|
7229
7512
|
}, {
|
|
7230
|
-
F:
|
|
7513
|
+
F: __dxlog_file26,
|
|
7231
7514
|
L: 56,
|
|
7232
7515
|
S: void 0,
|
|
7233
7516
|
C: (f, a) => f(...a)
|
|
@@ -7240,10 +7523,10 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
7240
7523
|
let count = 0;
|
|
7241
7524
|
for (const entry2 of archive.storage) {
|
|
7242
7525
|
switch (entry2.type) {
|
|
7243
|
-
case
|
|
7526
|
+
case import_protocols16.ProfileArchiveEntryType.FILE: {
|
|
7244
7527
|
const directory = await storage.createDirectory();
|
|
7245
|
-
(0,
|
|
7246
|
-
F:
|
|
7528
|
+
(0, import_invariant21.invariant)(typeof entry2.key === "string", "Invalid key type", {
|
|
7529
|
+
F: __dxlog_file26,
|
|
7247
7530
|
L: 79,
|
|
7248
7531
|
S: void 0,
|
|
7249
7532
|
A: [
|
|
@@ -7252,8 +7535,8 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
7252
7535
|
]
|
|
7253
7536
|
});
|
|
7254
7537
|
const file = await directory.getOrCreateFile(entry2.key);
|
|
7255
|
-
(0,
|
|
7256
|
-
F:
|
|
7538
|
+
(0, import_invariant21.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
7539
|
+
F: __dxlog_file26,
|
|
7257
7540
|
L: 81,
|
|
7258
7541
|
S: void 0,
|
|
7259
7542
|
A: [
|
|
@@ -7265,9 +7548,9 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
7265
7548
|
await file.close();
|
|
7266
7549
|
break;
|
|
7267
7550
|
}
|
|
7268
|
-
case
|
|
7269
|
-
(0,
|
|
7270
|
-
F:
|
|
7551
|
+
case import_protocols16.ProfileArchiveEntryType.KEY_VALUE: {
|
|
7552
|
+
(0, import_invariant21.invariant)(entry2.key instanceof Uint8Array, "Invalid key type", {
|
|
7553
|
+
F: __dxlog_file26,
|
|
7271
7554
|
L: 87,
|
|
7272
7555
|
S: void 0,
|
|
7273
7556
|
A: [
|
|
@@ -7275,8 +7558,8 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
7275
7558
|
"'Invalid key type'"
|
|
7276
7559
|
]
|
|
7277
7560
|
});
|
|
7278
|
-
(0,
|
|
7279
|
-
F:
|
|
7561
|
+
(0, import_invariant21.invariant)(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
7562
|
+
F: __dxlog_file26,
|
|
7280
7563
|
L: 88,
|
|
7281
7564
|
S: void 0,
|
|
7282
7565
|
A: [
|
|
@@ -7296,27 +7579,27 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
7296
7579
|
if (++count % 1e3 === 0) {
|
|
7297
7580
|
await batch.write();
|
|
7298
7581
|
batch = level.batch();
|
|
7299
|
-
|
|
7582
|
+
import_log23.log.info("importing", {
|
|
7300
7583
|
count,
|
|
7301
7584
|
total: archive.storage.length,
|
|
7302
7585
|
progress: `${(count / archive.storage.length * 100).toFixed()}%`
|
|
7303
7586
|
}, {
|
|
7304
|
-
F:
|
|
7587
|
+
F: __dxlog_file26,
|
|
7305
7588
|
L: 101,
|
|
7306
7589
|
S: void 0,
|
|
7307
7590
|
C: (f, a) => f(...a)
|
|
7308
7591
|
});
|
|
7309
7592
|
}
|
|
7310
7593
|
}
|
|
7311
|
-
|
|
7312
|
-
F:
|
|
7594
|
+
import_log23.log.info("committing changes..", void 0, {
|
|
7595
|
+
F: __dxlog_file26,
|
|
7313
7596
|
L: 109,
|
|
7314
7597
|
S: void 0,
|
|
7315
7598
|
C: (f, a) => f(...a)
|
|
7316
7599
|
});
|
|
7317
7600
|
await batch.write();
|
|
7318
7601
|
};
|
|
7319
|
-
var
|
|
7602
|
+
var __dxlog_file27 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
7320
7603
|
var DevicesServiceImpl = class {
|
|
7321
7604
|
constructor(_identityManager) {
|
|
7322
7605
|
this._identityManager = _identityManager;
|
|
@@ -7333,8 +7616,8 @@ var DevicesServiceImpl = class {
|
|
|
7333
7616
|
devices: []
|
|
7334
7617
|
});
|
|
7335
7618
|
} else {
|
|
7336
|
-
(0,
|
|
7337
|
-
F:
|
|
7619
|
+
(0, import_invariant23.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
7620
|
+
F: __dxlog_file27,
|
|
7338
7621
|
L: 32,
|
|
7339
7622
|
S: this,
|
|
7340
7623
|
A: [
|
|
@@ -7349,9 +7632,9 @@ var DevicesServiceImpl = class {
|
|
|
7349
7632
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
7350
7633
|
return {
|
|
7351
7634
|
deviceKey: key,
|
|
7352
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
7635
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services21.DeviceKind.CURRENT : import_services21.DeviceKind.TRUSTED,
|
|
7353
7636
|
profile,
|
|
7354
|
-
presence: isMe ?
|
|
7637
|
+
presence: isMe ? import_services21.Device.PresenceState.ONLINE : peerState ? import_services21.Device.PresenceState.ONLINE : import_services21.Device.PresenceState.OFFLINE
|
|
7355
7638
|
};
|
|
7356
7639
|
})
|
|
7357
7640
|
});
|
|
@@ -7375,7 +7658,7 @@ var DevicesServiceImpl = class {
|
|
|
7375
7658
|
presenceSubscribed = true;
|
|
7376
7659
|
}
|
|
7377
7660
|
};
|
|
7378
|
-
const subscriptions = new
|
|
7661
|
+
const subscriptions = new import_async23.EventSubscriptions();
|
|
7379
7662
|
if (this._identityManager.identity) {
|
|
7380
7663
|
subscribeIdentity();
|
|
7381
7664
|
subscribePresence();
|
|
@@ -7431,7 +7714,7 @@ var ContactsServiceImpl = class {
|
|
|
7431
7714
|
});
|
|
7432
7715
|
}
|
|
7433
7716
|
return acc;
|
|
7434
|
-
}, new import_util15.ComplexMap(
|
|
7717
|
+
}, new import_util15.ComplexMap(import_keys18.PublicKey.hash));
|
|
7435
7718
|
return {
|
|
7436
7719
|
contacts: [
|
|
7437
7720
|
...contacts.values()
|
|
@@ -7439,16 +7722,16 @@ var ContactsServiceImpl = class {
|
|
|
7439
7722
|
};
|
|
7440
7723
|
}
|
|
7441
7724
|
queryContacts() {
|
|
7442
|
-
const subscribedSpaceKeySet = new import_util15.ComplexSet(
|
|
7725
|
+
const subscribedSpaceKeySet = new import_util15.ComplexSet(import_keys18.PublicKey.hash);
|
|
7443
7726
|
return new import_codec_protobuf13.Stream(({ next, ctx }) => {
|
|
7444
|
-
const pushUpdateTask = new
|
|
7727
|
+
const pushUpdateTask = new import_async24.UpdateScheduler(ctx, async () => {
|
|
7445
7728
|
const contacts = await this.getContacts();
|
|
7446
7729
|
next(contacts);
|
|
7447
7730
|
}, {
|
|
7448
7731
|
maxFrequency: 2
|
|
7449
7732
|
});
|
|
7450
|
-
(0,
|
|
7451
|
-
const subscriptions = new
|
|
7733
|
+
(0, import_async24.scheduleTask)(ctx, async () => {
|
|
7734
|
+
const subscriptions = new import_async24.EventSubscriptions();
|
|
7452
7735
|
ctx.onDispose(() => subscriptions.clear());
|
|
7453
7736
|
const subscribeToSpaceAndUpdate = () => {
|
|
7454
7737
|
const oldSetSize = subscribedSpaceKeySet.size;
|
|
@@ -7471,19 +7754,19 @@ var ContactsServiceImpl = class {
|
|
|
7471
7754
|
};
|
|
7472
7755
|
var LoggingServiceImpl = class {
|
|
7473
7756
|
constructor() {
|
|
7474
|
-
this._logs = new
|
|
7757
|
+
this._logs = new import_async25.Event();
|
|
7475
7758
|
this._started = Date.now();
|
|
7476
|
-
this._sessionId =
|
|
7759
|
+
this._sessionId = import_keys19.PublicKey.random().toHex();
|
|
7477
7760
|
this._logProcessor = (_config, entry2) => {
|
|
7478
7761
|
this._logs.emit(entry2);
|
|
7479
7762
|
};
|
|
7480
7763
|
}
|
|
7481
7764
|
async open() {
|
|
7482
|
-
|
|
7765
|
+
import_log25.log.runtimeConfig.processors.push(this._logProcessor);
|
|
7483
7766
|
}
|
|
7484
7767
|
async close() {
|
|
7485
|
-
const index =
|
|
7486
|
-
|
|
7768
|
+
const index = import_log25.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
7769
|
+
import_log25.log.runtimeConfig.processors.splice(index, 1);
|
|
7487
7770
|
}
|
|
7488
7771
|
async controlMetrics({ reset, record }) {
|
|
7489
7772
|
if (reset) {
|
|
@@ -7544,7 +7827,7 @@ var LoggingServiceImpl = class {
|
|
|
7544
7827
|
}
|
|
7545
7828
|
const record = {
|
|
7546
7829
|
...entry2,
|
|
7547
|
-
context: (0, import_util16.jsonify)((0,
|
|
7830
|
+
context: (0, import_util16.jsonify)((0, import_log25.getContextFromEntry)(entry2)),
|
|
7548
7831
|
timestamp: /* @__PURE__ */ new Date(),
|
|
7549
7832
|
meta: {
|
|
7550
7833
|
// TODO(dmaretskyi): Fix proto.
|
|
@@ -7570,16 +7853,16 @@ var LoggingServiceImpl = class {
|
|
|
7570
7853
|
};
|
|
7571
7854
|
var matchFilter = (filter, level, path2, options) => {
|
|
7572
7855
|
switch (options) {
|
|
7573
|
-
case
|
|
7856
|
+
case import_services22.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
7574
7857
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
7575
|
-
case
|
|
7858
|
+
case import_services22.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
7576
7859
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
7577
7860
|
}
|
|
7578
7861
|
};
|
|
7579
7862
|
var shouldLog = (entry2, request) => {
|
|
7580
|
-
const options = request.options ??
|
|
7863
|
+
const options = request.options ?? import_services22.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
7581
7864
|
if (request.filters === void 0) {
|
|
7582
|
-
return options ===
|
|
7865
|
+
return options === import_services22.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
7583
7866
|
} else {
|
|
7584
7867
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
7585
7868
|
}
|
|
@@ -7635,8 +7918,8 @@ var SystemServiceImpl = class {
|
|
|
7635
7918
|
return {
|
|
7636
7919
|
timestamp: /* @__PURE__ */ new Date(),
|
|
7637
7920
|
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util17.jsonKeyReplacer)({
|
|
7638
|
-
truncate: keys ===
|
|
7639
|
-
humanize: keys ===
|
|
7921
|
+
truncate: keys === import_services23.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
7922
|
+
humanize: keys === import_services23.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
7640
7923
|
})))
|
|
7641
7924
|
};
|
|
7642
7925
|
}
|
|
@@ -7673,7 +7956,7 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
7673
7956
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7674
7957
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7675
7958
|
}
|
|
7676
|
-
var
|
|
7959
|
+
var __dxlog_file28 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
7677
7960
|
var ClientServicesHost = class {
|
|
7678
7961
|
constructor({
|
|
7679
7962
|
config,
|
|
@@ -7687,7 +7970,7 @@ var ClientServicesHost = class {
|
|
|
7687
7970
|
runtimeParams
|
|
7688
7971
|
} = {}) {
|
|
7689
7972
|
this._tracingService = import_tracing11.TRACE_PROCESSOR.createTraceSender();
|
|
7690
|
-
this._statusUpdate = new
|
|
7973
|
+
this._statusUpdate = new import_async22.Event();
|
|
7691
7974
|
this._edgeConnection = void 0;
|
|
7692
7975
|
this._edgeHttpClient = void 0;
|
|
7693
7976
|
this._opening = false;
|
|
@@ -7712,7 +7995,7 @@ var ClientServicesHost = class {
|
|
|
7712
7995
|
onAcquire: () => {
|
|
7713
7996
|
if (!this._opening) {
|
|
7714
7997
|
void this.open(new import_context16.Context(void 0, {
|
|
7715
|
-
F:
|
|
7998
|
+
F: __dxlog_file28,
|
|
7716
7999
|
L: 133
|
|
7717
8000
|
}));
|
|
7718
8001
|
}
|
|
@@ -7723,14 +8006,14 @@ var ClientServicesHost = class {
|
|
|
7723
8006
|
this._systemService = new SystemServiceImpl({
|
|
7724
8007
|
config: () => this._config,
|
|
7725
8008
|
statusUpdate: this._statusUpdate,
|
|
7726
|
-
getCurrentStatus: () => this.isOpen ?
|
|
8009
|
+
getCurrentStatus: () => this.isOpen ? import_services20.SystemStatus.ACTIVE : import_services20.SystemStatus.INACTIVE,
|
|
7727
8010
|
getDiagnostics: () => {
|
|
7728
8011
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
7729
8012
|
},
|
|
7730
8013
|
onUpdateStatus: async (status) => {
|
|
7731
|
-
if (!this.isOpen && status ===
|
|
8014
|
+
if (!this.isOpen && status === import_services20.SystemStatus.ACTIVE) {
|
|
7732
8015
|
await this._resourceLock?.acquire();
|
|
7733
|
-
} else if (this.isOpen && status ===
|
|
8016
|
+
} else if (this.isOpen && status === import_services20.SystemStatus.INACTIVE) {
|
|
7734
8017
|
await this._resourceLock?.release();
|
|
7735
8018
|
}
|
|
7736
8019
|
},
|
|
@@ -7769,8 +8052,8 @@ var ClientServicesHost = class {
|
|
|
7769
8052
|
* Can only be called once.
|
|
7770
8053
|
*/
|
|
7771
8054
|
initialize({ config, ...options }) {
|
|
7772
|
-
(0,
|
|
7773
|
-
F:
|
|
8055
|
+
(0, import_invariant22.invariant)(!this._open, "service host is open", {
|
|
8056
|
+
F: __dxlog_file28,
|
|
7774
8057
|
L: 199,
|
|
7775
8058
|
S: this,
|
|
7776
8059
|
A: [
|
|
@@ -7778,15 +8061,15 @@ var ClientServicesHost = class {
|
|
|
7778
8061
|
"'service host is open'"
|
|
7779
8062
|
]
|
|
7780
8063
|
});
|
|
7781
|
-
(0,
|
|
7782
|
-
F:
|
|
8064
|
+
(0, import_log24.log)("initializing...", void 0, {
|
|
8065
|
+
F: __dxlog_file28,
|
|
7783
8066
|
L: 200,
|
|
7784
8067
|
S: this,
|
|
7785
8068
|
C: (f, a) => f(...a)
|
|
7786
8069
|
});
|
|
7787
8070
|
if (config) {
|
|
7788
|
-
(0,
|
|
7789
|
-
F:
|
|
8071
|
+
(0, import_invariant22.invariant)(!this._config, "config already set", {
|
|
8072
|
+
F: __dxlog_file28,
|
|
7790
8073
|
L: 203,
|
|
7791
8074
|
S: this,
|
|
7792
8075
|
A: [
|
|
@@ -7800,8 +8083,8 @@ var ClientServicesHost = class {
|
|
|
7800
8083
|
}
|
|
7801
8084
|
}
|
|
7802
8085
|
if (!options.signalManager) {
|
|
7803
|
-
|
|
7804
|
-
F:
|
|
8086
|
+
import_log24.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
8087
|
+
F: __dxlog_file28,
|
|
7805
8088
|
L: 211,
|
|
7806
8089
|
S: this,
|
|
7807
8090
|
C: (f, a) => f(...a)
|
|
@@ -7820,8 +8103,8 @@ var ClientServicesHost = class {
|
|
|
7820
8103
|
edgeConnection: this._edgeConnection
|
|
7821
8104
|
}) : new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
7822
8105
|
this._signalManager = signalManager;
|
|
7823
|
-
(0,
|
|
7824
|
-
F:
|
|
8106
|
+
(0, import_invariant22.invariant)(!this._networkManager, "network manager already set", {
|
|
8107
|
+
F: __dxlog_file28,
|
|
7825
8108
|
L: 233,
|
|
7826
8109
|
S: this,
|
|
7827
8110
|
A: [
|
|
@@ -7838,8 +8121,8 @@ var ClientServicesHost = class {
|
|
|
7838
8121
|
peerKey: this._edgeConnection.peerKey
|
|
7839
8122
|
} : void 0
|
|
7840
8123
|
});
|
|
7841
|
-
(0,
|
|
7842
|
-
F:
|
|
8124
|
+
(0, import_log24.log)("initialized", void 0, {
|
|
8125
|
+
F: __dxlog_file28,
|
|
7843
8126
|
L: 246,
|
|
7844
8127
|
S: this,
|
|
7845
8128
|
C: (f, a) => f(...a)
|
|
@@ -7849,17 +8132,17 @@ var ClientServicesHost = class {
|
|
|
7849
8132
|
if (this._open) {
|
|
7850
8133
|
return;
|
|
7851
8134
|
}
|
|
7852
|
-
const traceId =
|
|
7853
|
-
|
|
8135
|
+
const traceId = import_keys17.PublicKey.random().toHex();
|
|
8136
|
+
import_log24.log.trace("dxos.client-services.host.open", import_protocols17.trace.begin({
|
|
7854
8137
|
id: traceId
|
|
7855
8138
|
}), {
|
|
7856
|
-
F:
|
|
8139
|
+
F: __dxlog_file28,
|
|
7857
8140
|
L: 257,
|
|
7858
8141
|
S: this,
|
|
7859
8142
|
C: (f, a) => f(...a)
|
|
7860
8143
|
});
|
|
7861
|
-
(0,
|
|
7862
|
-
F:
|
|
8144
|
+
(0, import_invariant22.invariant)(this._config, "config not set", {
|
|
8145
|
+
F: __dxlog_file28,
|
|
7863
8146
|
L: 259,
|
|
7864
8147
|
S: this,
|
|
7865
8148
|
A: [
|
|
@@ -7867,8 +8150,8 @@ var ClientServicesHost = class {
|
|
|
7867
8150
|
"'config not set'"
|
|
7868
8151
|
]
|
|
7869
8152
|
});
|
|
7870
|
-
(0,
|
|
7871
|
-
F:
|
|
8153
|
+
(0, import_invariant22.invariant)(this._storage, "storage not set", {
|
|
8154
|
+
F: __dxlog_file28,
|
|
7872
8155
|
L: 260,
|
|
7873
8156
|
S: this,
|
|
7874
8157
|
A: [
|
|
@@ -7876,8 +8159,8 @@ var ClientServicesHost = class {
|
|
|
7876
8159
|
"'storage not set'"
|
|
7877
8160
|
]
|
|
7878
8161
|
});
|
|
7879
|
-
(0,
|
|
7880
|
-
F:
|
|
8162
|
+
(0, import_invariant22.invariant)(this._signalManager, "signal manager not set", {
|
|
8163
|
+
F: __dxlog_file28,
|
|
7881
8164
|
L: 261,
|
|
7882
8165
|
S: this,
|
|
7883
8166
|
A: [
|
|
@@ -7885,8 +8168,8 @@ var ClientServicesHost = class {
|
|
|
7885
8168
|
"'signal manager not set'"
|
|
7886
8169
|
]
|
|
7887
8170
|
});
|
|
7888
|
-
(0,
|
|
7889
|
-
F:
|
|
8171
|
+
(0, import_invariant22.invariant)(this._networkManager, "network manager not set", {
|
|
8172
|
+
F: __dxlog_file28,
|
|
7890
8173
|
L: 262,
|
|
7891
8174
|
S: this,
|
|
7892
8175
|
A: [
|
|
@@ -7895,10 +8178,10 @@ var ClientServicesHost = class {
|
|
|
7895
8178
|
]
|
|
7896
8179
|
});
|
|
7897
8180
|
this._opening = true;
|
|
7898
|
-
(0,
|
|
8181
|
+
(0, import_log24.log)("opening...", {
|
|
7899
8182
|
lockKey: this._resourceLock?.lockKey
|
|
7900
8183
|
}, {
|
|
7901
|
-
F:
|
|
8184
|
+
F: __dxlog_file28,
|
|
7902
8185
|
L: 265,
|
|
7903
8186
|
S: this,
|
|
7904
8187
|
C: (f, a) => f(...a)
|
|
@@ -7951,18 +8234,18 @@ var ClientServicesHost = class {
|
|
|
7951
8234
|
this._open = true;
|
|
7952
8235
|
this._statusUpdate.emit();
|
|
7953
8236
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
7954
|
-
(0,
|
|
8237
|
+
(0, import_log24.log)("opened", {
|
|
7955
8238
|
deviceKey
|
|
7956
8239
|
}, {
|
|
7957
|
-
F:
|
|
8240
|
+
F: __dxlog_file28,
|
|
7958
8241
|
L: 354,
|
|
7959
8242
|
S: this,
|
|
7960
8243
|
C: (f, a) => f(...a)
|
|
7961
8244
|
});
|
|
7962
|
-
|
|
8245
|
+
import_log24.log.trace("dxos.client-services.host.open", import_protocols17.trace.end({
|
|
7963
8246
|
id: traceId
|
|
7964
8247
|
}), {
|
|
7965
|
-
F:
|
|
8248
|
+
F: __dxlog_file28,
|
|
7966
8249
|
L: 355,
|
|
7967
8250
|
S: this,
|
|
7968
8251
|
C: (f, a) => f(...a)
|
|
@@ -7973,10 +8256,10 @@ var ClientServicesHost = class {
|
|
|
7973
8256
|
return;
|
|
7974
8257
|
}
|
|
7975
8258
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
7976
|
-
(0,
|
|
8259
|
+
(0, import_log24.log)("closing...", {
|
|
7977
8260
|
deviceKey
|
|
7978
8261
|
}, {
|
|
7979
|
-
F:
|
|
8262
|
+
F: __dxlog_file28,
|
|
7980
8263
|
L: 366,
|
|
7981
8264
|
S: this,
|
|
7982
8265
|
C: (f, a) => f(...a)
|
|
@@ -7991,43 +8274,43 @@ var ClientServicesHost = class {
|
|
|
7991
8274
|
await this._level?.close();
|
|
7992
8275
|
this._open = false;
|
|
7993
8276
|
this._statusUpdate.emit();
|
|
7994
|
-
(0,
|
|
8277
|
+
(0, import_log24.log)("closed", {
|
|
7995
8278
|
deviceKey
|
|
7996
8279
|
}, {
|
|
7997
|
-
F:
|
|
8280
|
+
F: __dxlog_file28,
|
|
7998
8281
|
L: 375,
|
|
7999
8282
|
S: this,
|
|
8000
8283
|
C: (f, a) => f(...a)
|
|
8001
8284
|
});
|
|
8002
8285
|
}
|
|
8003
8286
|
async reset() {
|
|
8004
|
-
const traceId =
|
|
8005
|
-
|
|
8287
|
+
const traceId = import_keys17.PublicKey.random().toHex();
|
|
8288
|
+
import_log24.log.trace("dxos.sdk.client-services-host.reset", import_protocols17.trace.begin({
|
|
8006
8289
|
id: traceId
|
|
8007
8290
|
}), {
|
|
8008
|
-
F:
|
|
8291
|
+
F: __dxlog_file28,
|
|
8009
8292
|
L: 380,
|
|
8010
8293
|
S: this,
|
|
8011
8294
|
C: (f, a) => f(...a)
|
|
8012
8295
|
});
|
|
8013
|
-
|
|
8014
|
-
F:
|
|
8296
|
+
import_log24.log.info("resetting...", void 0, {
|
|
8297
|
+
F: __dxlog_file28,
|
|
8015
8298
|
L: 382,
|
|
8016
8299
|
S: this,
|
|
8017
8300
|
C: (f, a) => f(...a)
|
|
8018
8301
|
});
|
|
8019
8302
|
await this._serviceContext?.close();
|
|
8020
8303
|
await this._storage.reset();
|
|
8021
|
-
|
|
8022
|
-
F:
|
|
8304
|
+
import_log24.log.info("reset", void 0, {
|
|
8305
|
+
F: __dxlog_file28,
|
|
8023
8306
|
L: 385,
|
|
8024
8307
|
S: this,
|
|
8025
8308
|
C: (f, a) => f(...a)
|
|
8026
8309
|
});
|
|
8027
|
-
|
|
8310
|
+
import_log24.log.trace("dxos.sdk.client-services-host.reset", import_protocols17.trace.end({
|
|
8028
8311
|
id: traceId
|
|
8029
8312
|
}), {
|
|
8030
|
-
F:
|
|
8313
|
+
F: __dxlog_file28,
|
|
8031
8314
|
L: 386,
|
|
8032
8315
|
S: this,
|
|
8033
8316
|
C: (f, a) => f(...a)
|
|
@@ -8047,11 +8330,11 @@ _ts_decorate10([
|
|
|
8047
8330
|
import_tracing11.trace.info()
|
|
8048
8331
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
8049
8332
|
_ts_decorate10([
|
|
8050
|
-
|
|
8333
|
+
import_async22.synchronized,
|
|
8051
8334
|
import_tracing11.trace.span()
|
|
8052
8335
|
], ClientServicesHost.prototype, "open", null);
|
|
8053
8336
|
_ts_decorate10([
|
|
8054
|
-
|
|
8337
|
+
import_async22.synchronized,
|
|
8055
8338
|
import_tracing11.trace.span()
|
|
8056
8339
|
], ClientServicesHost.prototype, "close", null);
|
|
8057
8340
|
ClientServicesHost = _ts_decorate10([
|
|
@@ -8101,4 +8384,4 @@ ClientServicesHost = _ts_decorate10([
|
|
|
8101
8384
|
subscribeToSpaces,
|
|
8102
8385
|
subscribeToSwarmInfo
|
|
8103
8386
|
});
|
|
8104
|
-
//# sourceMappingURL=chunk-
|
|
8387
|
+
//# sourceMappingURL=chunk-IFHGVXW2.cjs.map
|