@dxos/client-services 0.6.12-staging.e11e696 → 0.6.13-main.548ca8d
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-UEQIHAL2.mjs} +868 -619
- package/dist/lib/browser/chunk-UEQIHAL2.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 +4 -2
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-2KIDYJ7O.cjs → chunk-MA5EWTRH.cjs} +900 -655
- package/dist/lib/node/chunk-MA5EWTRH.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 +11 -9
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node-esm/{chunk-36ZRRDQI.mjs → chunk-AIBLDI4U.mjs} +859 -610
- package/dist/lib/node-esm/chunk-AIBLDI4U.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 +4 -2
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- 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 +2 -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/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +38 -38
- 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 +4 -3
- package/src/packlets/spaces/data-space-manager.ts +31 -3
- package/src/packlets/spaces/data-space.ts +4 -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 +1 -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
|
@@ -404,7 +404,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
|
404
404
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
405
405
|
|
|
406
406
|
// packages/sdk/client-services/src/version.ts
|
|
407
|
-
var DXOS_VERSION = "0.6.
|
|
407
|
+
var DXOS_VERSION = "0.6.13-main.548ca8d";
|
|
408
408
|
|
|
409
409
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
410
410
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -2020,6 +2020,7 @@ import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
|
2020
2020
|
import { log as log8 } from "@dxos/log";
|
|
2021
2021
|
import { AlreadyJoinedError, trace as Trace } from "@dxos/protocols";
|
|
2022
2022
|
import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
2023
|
+
import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
|
|
2023
2024
|
import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2024
2025
|
import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
|
|
2025
2026
|
import { trace } from "@dxos/tracing";
|
|
@@ -2445,12 +2446,36 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2445
2446
|
}
|
|
2446
2447
|
});
|
|
2447
2448
|
}
|
|
2449
|
+
async setSpaceEdgeReplicationSetting(spaceKey, setting) {
|
|
2450
|
+
const space = this._spaces.get(spaceKey);
|
|
2451
|
+
invariant5(space, "Space not found.", {
|
|
2452
|
+
F: __dxlog_file10,
|
|
2453
|
+
L: 399,
|
|
2454
|
+
S: this,
|
|
2455
|
+
A: [
|
|
2456
|
+
"space",
|
|
2457
|
+
"'Space not found.'"
|
|
2458
|
+
]
|
|
2459
|
+
});
|
|
2460
|
+
await this._metadataStore.setSpaceEdgeReplicationSetting(spaceKey, setting);
|
|
2461
|
+
if (space.isOpen) {
|
|
2462
|
+
switch (setting) {
|
|
2463
|
+
case EdgeReplicationSetting.DISABLED:
|
|
2464
|
+
await this._echoEdgeReplicator?.disconnectFromSpace(space.id);
|
|
2465
|
+
break;
|
|
2466
|
+
case EdgeReplicationSetting.ENABLED:
|
|
2467
|
+
await this._echoEdgeReplicator?.connectToSpace(space.id);
|
|
2468
|
+
break;
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
space.stateUpdate.emit();
|
|
2472
|
+
}
|
|
2448
2473
|
async _constructSpace(metadata) {
|
|
2449
2474
|
log8("construct space", {
|
|
2450
2475
|
metadata
|
|
2451
2476
|
}, {
|
|
2452
2477
|
F: __dxlog_file10,
|
|
2453
|
-
L:
|
|
2478
|
+
L: 418,
|
|
2454
2479
|
S: this,
|
|
2455
2480
|
C: (f, a) => f(...a)
|
|
2456
2481
|
});
|
|
@@ -2494,7 +2519,7 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2494
2519
|
err
|
|
2495
2520
|
}, {
|
|
2496
2521
|
F: __dxlog_file10,
|
|
2497
|
-
L:
|
|
2522
|
+
L: 460,
|
|
2498
2523
|
S: this,
|
|
2499
2524
|
C: (f, a) => f(...a)
|
|
2500
2525
|
});
|
|
@@ -2504,7 +2529,7 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2504
2529
|
onAuthFailure: () => {
|
|
2505
2530
|
log8.warn("auth failure", void 0, {
|
|
2506
2531
|
F: __dxlog_file10,
|
|
2507
|
-
L:
|
|
2532
|
+
L: 465,
|
|
2508
2533
|
S: this,
|
|
2509
2534
|
C: (f, a) => f(...a)
|
|
2510
2535
|
});
|
|
@@ -2537,7 +2562,7 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2537
2562
|
space: space.key
|
|
2538
2563
|
}, {
|
|
2539
2564
|
F: __dxlog_file10,
|
|
2540
|
-
L:
|
|
2565
|
+
L: 492,
|
|
2541
2566
|
S: this,
|
|
2542
2567
|
C: (f, a) => f(...a)
|
|
2543
2568
|
});
|
|
@@ -2548,7 +2573,7 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2548
2573
|
open: this._lifecycleState === LifecycleState.OPEN
|
|
2549
2574
|
}, {
|
|
2550
2575
|
F: __dxlog_file10,
|
|
2551
|
-
L:
|
|
2576
|
+
L: 495,
|
|
2552
2577
|
S: this,
|
|
2553
2578
|
C: (f, a) => f(...a)
|
|
2554
2579
|
});
|
|
@@ -2567,7 +2592,7 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2567
2592
|
space: space.key
|
|
2568
2593
|
}, {
|
|
2569
2594
|
F: __dxlog_file10,
|
|
2570
|
-
L:
|
|
2595
|
+
L: 503,
|
|
2571
2596
|
S: this,
|
|
2572
2597
|
C: (f, a) => f(...a)
|
|
2573
2598
|
});
|
|
@@ -2579,10 +2604,25 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2579
2604
|
edgeFeatures: this._edgeFeatures
|
|
2580
2605
|
});
|
|
2581
2606
|
dataSpace.postOpen.append(async () => {
|
|
2582
|
-
|
|
2607
|
+
const setting = dataSpace.getEdgeReplicationSetting();
|
|
2608
|
+
if (setting === EdgeReplicationSetting.ENABLED) {
|
|
2609
|
+
await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
|
|
2610
|
+
} else if (this._echoEdgeReplicator) {
|
|
2611
|
+
log8("not connecting EchoEdgeReplicator because of EdgeReplicationSetting", {
|
|
2612
|
+
spaceId: dataSpace.id
|
|
2613
|
+
}, {
|
|
2614
|
+
F: __dxlog_file10,
|
|
2615
|
+
L: 516,
|
|
2616
|
+
S: this,
|
|
2617
|
+
C: (f, a) => f(...a)
|
|
2618
|
+
});
|
|
2619
|
+
}
|
|
2583
2620
|
});
|
|
2584
2621
|
dataSpace.preClose.append(async () => {
|
|
2585
|
-
|
|
2622
|
+
const setting = dataSpace.getEdgeReplicationSetting();
|
|
2623
|
+
if (setting === EdgeReplicationSetting.ENABLED) {
|
|
2624
|
+
await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
|
|
2625
|
+
}
|
|
2586
2626
|
});
|
|
2587
2627
|
presence.newPeer.on((peerState) => {
|
|
2588
2628
|
if (dataSpace.state === SpaceState.SPACE_READY) {
|
|
@@ -2602,7 +2642,7 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2602
2642
|
space: space.key
|
|
2603
2643
|
}, {
|
|
2604
2644
|
F: __dxlog_file10,
|
|
2605
|
-
L:
|
|
2645
|
+
L: 543,
|
|
2606
2646
|
S: this,
|
|
2607
2647
|
C: (f, a) => f(...a)
|
|
2608
2648
|
});
|
|
@@ -2635,7 +2675,7 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2635
2675
|
closedSessions
|
|
2636
2676
|
}, {
|
|
2637
2677
|
F: __dxlog_file10,
|
|
2638
|
-
L:
|
|
2678
|
+
L: 569,
|
|
2639
2679
|
S: this,
|
|
2640
2680
|
C: (f, a) => f(...a)
|
|
2641
2681
|
});
|
|
@@ -2650,7 +2690,7 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2650
2690
|
peerId: peerState.peerId
|
|
2651
2691
|
}, {
|
|
2652
2692
|
F: __dxlog_file10,
|
|
2653
|
-
L:
|
|
2693
|
+
L: 583,
|
|
2654
2694
|
S: this,
|
|
2655
2695
|
C: (f, a) => f(...a)
|
|
2656
2696
|
});
|
|
@@ -2735,7 +2775,7 @@ var SpacesServiceImpl = class {
|
|
|
2735
2775
|
await this._updateMetrics();
|
|
2736
2776
|
return this._serializeSpace(space);
|
|
2737
2777
|
}
|
|
2738
|
-
async updateSpace({ spaceKey, state }) {
|
|
2778
|
+
async updateSpace({ spaceKey, state, edgeReplication }) {
|
|
2739
2779
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2740
2780
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise(new SpaceNotFoundError(spaceKey));
|
|
2741
2781
|
if (state) {
|
|
@@ -2750,6 +2790,9 @@ var SpacesServiceImpl = class {
|
|
|
2750
2790
|
throw new ApiError("Invalid space state");
|
|
2751
2791
|
}
|
|
2752
2792
|
}
|
|
2793
|
+
if (edgeReplication !== void 0) {
|
|
2794
|
+
await dataSpaceManager.setSpaceEdgeReplicationSetting(spaceKey, edgeReplication);
|
|
2795
|
+
}
|
|
2753
2796
|
}
|
|
2754
2797
|
async updateMemberRole(request) {
|
|
2755
2798
|
const identity = this._requireIdentity();
|
|
@@ -2766,7 +2809,7 @@ var SpacesServiceImpl = class {
|
|
|
2766
2809
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
2767
2810
|
invariant6(credentials[0].credential, void 0, {
|
|
2768
2811
|
F: __dxlog_file11,
|
|
2769
|
-
L:
|
|
2812
|
+
L: 106,
|
|
2770
2813
|
S: this,
|
|
2771
2814
|
A: [
|
|
2772
2815
|
"credentials[0].credential",
|
|
@@ -2776,7 +2819,7 @@ var SpacesServiceImpl = class {
|
|
|
2776
2819
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2777
2820
|
invariant6(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2778
2821
|
F: __dxlog_file11,
|
|
2779
|
-
L:
|
|
2822
|
+
L: 108,
|
|
2780
2823
|
S: this,
|
|
2781
2824
|
A: [
|
|
2782
2825
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2794,7 +2837,7 @@ var SpacesServiceImpl = class {
|
|
|
2794
2837
|
ids: spaces.map((space) => space.id)
|
|
2795
2838
|
}), {
|
|
2796
2839
|
F: __dxlog_file11,
|
|
2797
|
-
L:
|
|
2840
|
+
L: 119,
|
|
2798
2841
|
S: this,
|
|
2799
2842
|
C: (f, a) => f(...a)
|
|
2800
2843
|
});
|
|
@@ -2886,7 +2929,7 @@ var SpacesServiceImpl = class {
|
|
|
2886
2929
|
} else {
|
|
2887
2930
|
invariant6(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
2888
2931
|
F: __dxlog_file11,
|
|
2889
|
-
L:
|
|
2932
|
+
L: 217,
|
|
2890
2933
|
S: this,
|
|
2891
2934
|
A: [
|
|
2892
2935
|
"!credential.id",
|
|
@@ -2895,7 +2938,7 @@ var SpacesServiceImpl = class {
|
|
|
2895
2938
|
});
|
|
2896
2939
|
invariant6(this._identityManager.identity, "Identity is not available", {
|
|
2897
2940
|
F: __dxlog_file11,
|
|
2898
|
-
L:
|
|
2941
|
+
L: 218,
|
|
2899
2942
|
S: this,
|
|
2900
2943
|
A: [
|
|
2901
2944
|
"this._identityManager.identity",
|
|
@@ -2905,7 +2948,7 @@ var SpacesServiceImpl = class {
|
|
|
2905
2948
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
2906
2949
|
invariant6(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
2907
2950
|
F: __dxlog_file11,
|
|
2908
|
-
L:
|
|
2951
|
+
L: 220,
|
|
2909
2952
|
S: this,
|
|
2910
2953
|
A: [
|
|
2911
2954
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -2955,7 +2998,7 @@ var SpacesServiceImpl = class {
|
|
|
2955
2998
|
const assertion = getCredentialAssertion3(credential);
|
|
2956
2999
|
invariant6(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2957
3000
|
F: __dxlog_file11,
|
|
2958
|
-
L:
|
|
3001
|
+
L: 254,
|
|
2959
3002
|
S: this,
|
|
2960
3003
|
A: [
|
|
2961
3004
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2965,7 +3008,7 @@ var SpacesServiceImpl = class {
|
|
|
2965
3008
|
const myIdentity = this._identityManager.identity;
|
|
2966
3009
|
invariant6(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
2967
3010
|
F: __dxlog_file11,
|
|
2968
|
-
L:
|
|
3011
|
+
L: 256,
|
|
2969
3012
|
S: this,
|
|
2970
3013
|
A: [
|
|
2971
3014
|
"myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
|
|
@@ -3027,7 +3070,8 @@ var SpacesServiceImpl = class {
|
|
|
3027
3070
|
}),
|
|
3028
3071
|
creator: space.inner.spaceState.creator?.key,
|
|
3029
3072
|
cache: space.cache,
|
|
3030
|
-
metrics: space.metrics
|
|
3073
|
+
metrics: space.metrics,
|
|
3074
|
+
edgeReplication: space.getEdgeReplicationSetting()
|
|
3031
3075
|
};
|
|
3032
3076
|
}
|
|
3033
3077
|
_requireIdentity() {
|
|
@@ -4478,6 +4522,9 @@ var DataSpace = class {
|
|
|
4478
4522
|
});
|
|
4479
4523
|
this.stateUpdate.emit();
|
|
4480
4524
|
}
|
|
4525
|
+
getEdgeReplicationSetting() {
|
|
4526
|
+
return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
|
|
4527
|
+
}
|
|
4481
4528
|
};
|
|
4482
4529
|
_ts_decorate6([
|
|
4483
4530
|
trace5.info()
|
|
@@ -4640,30 +4687,30 @@ var DeviceInvitationProtocol = class {
|
|
|
4640
4687
|
};
|
|
4641
4688
|
|
|
4642
4689
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
4643
|
-
import {
|
|
4690
|
+
import { scheduleTask as scheduleTask7, TimeoutError as TimeoutError2 } from "@dxos/async";
|
|
4644
4691
|
import { INVITATION_TIMEOUT } from "@dxos/client-protocol";
|
|
4645
4692
|
import { ContextDisposedError as ContextDisposedError3 } from "@dxos/context";
|
|
4646
4693
|
import { createKeyPair, sign } from "@dxos/crypto";
|
|
4647
|
-
import { invariant as
|
|
4694
|
+
import { invariant as invariant15 } from "@dxos/invariant";
|
|
4648
4695
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4649
|
-
import { log as
|
|
4696
|
+
import { log as log19 } from "@dxos/log";
|
|
4650
4697
|
import { createTeleportProtocolFactory } from "@dxos/network-manager";
|
|
4651
4698
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace7 } from "@dxos/protocols";
|
|
4652
|
-
import { Invitation as
|
|
4699
|
+
import { Invitation as Invitation7 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4653
4700
|
import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
4654
4701
|
import { InvitationOptions as InvitationOptions4 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
4655
4702
|
import { trace as _trace } from "@dxos/tracing";
|
|
4656
4703
|
import { ComplexSet as ComplexSet5 } from "@dxos/util";
|
|
4657
4704
|
|
|
4658
|
-
// packages/sdk/client-services/src/packlets/invitations/invitation-
|
|
4659
|
-
import {
|
|
4660
|
-
import {
|
|
4705
|
+
// packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts
|
|
4706
|
+
import { scheduleMicroTask as scheduleMicroTask3, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
4707
|
+
import { ed25519Signature } from "@dxos/crypto";
|
|
4661
4708
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
4709
|
+
import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
4662
4710
|
import { log as log14 } from "@dxos/log";
|
|
4663
|
-
import {
|
|
4711
|
+
import { EdgeAuthChallengeError, EdgeCallFailedError as EdgeCallFailedError2 } from "@dxos/protocols";
|
|
4664
4712
|
import { schema as schema3 } from "@dxos/protocols/proto";
|
|
4665
|
-
import {
|
|
4666
|
-
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
4713
|
+
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4667
4714
|
|
|
4668
4715
|
// packages/sdk/client-services/src/packlets/invitations/utils.ts
|
|
4669
4716
|
import { cancelWithContext as cancelWithContext3, ContextDisposedError as ContextDisposedError2 } from "@dxos/context";
|
|
@@ -4684,24 +4731,184 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
|
|
|
4684
4731
|
})());
|
|
4685
4732
|
};
|
|
4686
4733
|
|
|
4734
|
+
// packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts
|
|
4735
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
|
|
4736
|
+
var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
|
|
4737
|
+
var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
|
|
4738
|
+
var EdgeInvitationHandler = class {
|
|
4739
|
+
constructor(config, _client, _callbacks) {
|
|
4740
|
+
this._client = _client;
|
|
4741
|
+
this._callbacks = _callbacks;
|
|
4742
|
+
this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
|
|
4743
|
+
this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
|
|
4744
|
+
}
|
|
4745
|
+
handle(ctx, guardedState, protocol, deviceProfile) {
|
|
4746
|
+
if (!this._client) {
|
|
4747
|
+
log14("edge disabled", void 0, {
|
|
4748
|
+
F: __dxlog_file17,
|
|
4749
|
+
L: 65,
|
|
4750
|
+
S: this,
|
|
4751
|
+
C: (f, a) => f(...a)
|
|
4752
|
+
});
|
|
4753
|
+
return;
|
|
4754
|
+
}
|
|
4755
|
+
const invitation = guardedState.current;
|
|
4756
|
+
const spaceId = invitation.spaceId;
|
|
4757
|
+
const canBeHandledByEdge = invitation.authMethod !== Invitation4.AuthMethod.SHARED_SECRET && invitation.type === Invitation4.Type.DELEGATED && invitation.kind === Invitation4.Kind.SPACE && spaceId != null && SpaceId2.isValid(spaceId);
|
|
4758
|
+
if (!canBeHandledByEdge) {
|
|
4759
|
+
log14("invitation could not be handled by edge", {
|
|
4760
|
+
invitation
|
|
4761
|
+
}, {
|
|
4762
|
+
F: __dxlog_file17,
|
|
4763
|
+
L: 79,
|
|
4764
|
+
S: this,
|
|
4765
|
+
C: (f, a) => f(...a)
|
|
4766
|
+
});
|
|
4767
|
+
return;
|
|
4768
|
+
}
|
|
4769
|
+
ctx.onDispose(() => {
|
|
4770
|
+
this._flowLock?.release();
|
|
4771
|
+
this._flowLock = void 0;
|
|
4772
|
+
});
|
|
4773
|
+
const tryHandleInvitation = async () => {
|
|
4774
|
+
const admissionRequest = await protocol.createAdmissionRequest(deviceProfile);
|
|
4775
|
+
if (admissionRequest.space) {
|
|
4776
|
+
try {
|
|
4777
|
+
await this._handleSpaceInvitationFlow(ctx, guardedState, admissionRequest.space, spaceId);
|
|
4778
|
+
} catch (error) {
|
|
4779
|
+
if (error instanceof EdgeCallFailedError2) {
|
|
4780
|
+
log14.info("join space with edge unsuccessful", {
|
|
4781
|
+
reason: error.message,
|
|
4782
|
+
retryable: error.isRetryable,
|
|
4783
|
+
after: error.retryAfterMs ?? this._calculateNextRetryMs()
|
|
4784
|
+
}, {
|
|
4785
|
+
F: __dxlog_file17,
|
|
4786
|
+
L: 95,
|
|
4787
|
+
S: this,
|
|
4788
|
+
C: (f, a) => f(...a)
|
|
4789
|
+
});
|
|
4790
|
+
if (error.isRetryable) {
|
|
4791
|
+
scheduleTask5(ctx, tryHandleInvitation, error.retryAfterMs ?? this._calculateNextRetryMs());
|
|
4792
|
+
}
|
|
4793
|
+
} else {
|
|
4794
|
+
log14.info("failed to handle invitation with edge", {
|
|
4795
|
+
error
|
|
4796
|
+
}, {
|
|
4797
|
+
F: __dxlog_file17,
|
|
4798
|
+
L: 104,
|
|
4799
|
+
S: this,
|
|
4800
|
+
C: (f, a) => f(...a)
|
|
4801
|
+
});
|
|
4802
|
+
scheduleTask5(ctx, tryHandleInvitation, this._calculateNextRetryMs());
|
|
4803
|
+
}
|
|
4804
|
+
}
|
|
4805
|
+
}
|
|
4806
|
+
};
|
|
4807
|
+
scheduleMicroTask3(ctx, tryHandleInvitation);
|
|
4808
|
+
}
|
|
4809
|
+
async _handleSpaceInvitationFlow(ctx, guardedState, admissionRequest, spaceId) {
|
|
4810
|
+
try {
|
|
4811
|
+
log14("edge invitation flow", void 0, {
|
|
4812
|
+
F: __dxlog_file17,
|
|
4813
|
+
L: 120,
|
|
4814
|
+
S: this,
|
|
4815
|
+
C: (f, a) => f(...a)
|
|
4816
|
+
});
|
|
4817
|
+
this._flowLock = await tryAcquireBeforeContextDisposed(ctx, guardedState.mutex);
|
|
4818
|
+
log14("edge invitation flow acquired the lock", void 0, {
|
|
4819
|
+
F: __dxlog_file17,
|
|
4820
|
+
L: 122,
|
|
4821
|
+
S: this,
|
|
4822
|
+
C: (f, a) => f(...a)
|
|
4823
|
+
});
|
|
4824
|
+
guardedState.set(this, Invitation4.State.CONNECTING);
|
|
4825
|
+
const response = await this._joinSpaceByInvitation(guardedState, spaceId, {
|
|
4826
|
+
identityKey: admissionRequest.identityKey.toHex(),
|
|
4827
|
+
invitationId: guardedState.current.invitationId
|
|
4828
|
+
});
|
|
4829
|
+
const admissionResponse = await this._mapToAdmissionResponse(response);
|
|
4830
|
+
await this._callbacks.onInvitationSuccess(admissionResponse, {
|
|
4831
|
+
space: admissionRequest
|
|
4832
|
+
});
|
|
4833
|
+
} catch (error) {
|
|
4834
|
+
guardedState.set(this, Invitation4.State.ERROR);
|
|
4835
|
+
throw error;
|
|
4836
|
+
} finally {
|
|
4837
|
+
this._flowLock?.release();
|
|
4838
|
+
this._flowLock = void 0;
|
|
4839
|
+
}
|
|
4840
|
+
}
|
|
4841
|
+
async _mapToAdmissionResponse(edgeResponse) {
|
|
4842
|
+
const credentialBytes = Buffer.from(edgeResponse.spaceMemberCredential, "base64");
|
|
4843
|
+
const codec = schema3.getCodecForType("dxos.halo.credentials.Credential");
|
|
4844
|
+
return {
|
|
4845
|
+
space: {
|
|
4846
|
+
credential: codec.decode(credentialBytes)
|
|
4847
|
+
}
|
|
4848
|
+
};
|
|
4849
|
+
}
|
|
4850
|
+
async _joinSpaceByInvitation(guardedState, spaceId, request) {
|
|
4851
|
+
invariant11(this._client, void 0, {
|
|
4852
|
+
F: __dxlog_file17,
|
|
4853
|
+
L: 157,
|
|
4854
|
+
S: this,
|
|
4855
|
+
A: [
|
|
4856
|
+
"this._client",
|
|
4857
|
+
""
|
|
4858
|
+
]
|
|
4859
|
+
});
|
|
4860
|
+
try {
|
|
4861
|
+
return await this._client.joinSpaceByInvitation(spaceId, request);
|
|
4862
|
+
} catch (error) {
|
|
4863
|
+
if (error instanceof EdgeAuthChallengeError) {
|
|
4864
|
+
guardedState.set(this, Invitation4.State.AUTHENTICATING);
|
|
4865
|
+
const publicKey = guardedState.current.guestKeypair?.publicKey;
|
|
4866
|
+
const privateKey = guardedState.current.guestKeypair?.privateKey;
|
|
4867
|
+
if (!privateKey || !publicKey) {
|
|
4868
|
+
throw error;
|
|
4869
|
+
}
|
|
4870
|
+
const signature = await ed25519Signature(privateKey, Buffer.from(error.challenge, "base64"));
|
|
4871
|
+
request.signature = Buffer.from(signature).toString("base64");
|
|
4872
|
+
return this._client.joinSpaceByInvitation(spaceId, request);
|
|
4873
|
+
} else {
|
|
4874
|
+
throw error;
|
|
4875
|
+
}
|
|
4876
|
+
}
|
|
4877
|
+
}
|
|
4878
|
+
hasFlowLock() {
|
|
4879
|
+
return this._flowLock != null;
|
|
4880
|
+
}
|
|
4881
|
+
_calculateNextRetryMs() {
|
|
4882
|
+
return this._retryInterval + Math.random() * this._retryJitter;
|
|
4883
|
+
}
|
|
4884
|
+
};
|
|
4885
|
+
|
|
4687
4886
|
// packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
|
|
4688
|
-
|
|
4887
|
+
import { Trigger as Trigger5 } from "@dxos/async";
|
|
4888
|
+
import { cancelWithContext as cancelWithContext4, Context as Context6 } from "@dxos/context";
|
|
4889
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
4890
|
+
import { log as log15 } from "@dxos/log";
|
|
4891
|
+
import { InvalidInvitationExtensionRoleError } from "@dxos/protocols";
|
|
4892
|
+
import { schema as schema4 } from "@dxos/protocols/proto";
|
|
4893
|
+
import { InvitationOptions } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
4894
|
+
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
4895
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
|
|
4689
4896
|
var OPTIONS_TIMEOUT = 1e4;
|
|
4690
4897
|
var InvitationGuestExtension = class extends RpcExtension2 {
|
|
4691
4898
|
constructor(_invitationFlowMutex, _callbacks) {
|
|
4692
4899
|
super({
|
|
4693
4900
|
requested: {
|
|
4694
|
-
InvitationHostService:
|
|
4901
|
+
InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
|
|
4695
4902
|
},
|
|
4696
4903
|
exposed: {
|
|
4697
|
-
InvitationHostService:
|
|
4904
|
+
InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
|
|
4698
4905
|
}
|
|
4699
4906
|
});
|
|
4700
4907
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
4701
4908
|
this._callbacks = _callbacks;
|
|
4702
4909
|
this._ctx = new Context6(void 0, {
|
|
4703
|
-
F:
|
|
4704
|
-
L:
|
|
4910
|
+
F: __dxlog_file18,
|
|
4911
|
+
L: 38
|
|
4705
4912
|
});
|
|
4706
4913
|
this._remoteOptionsTrigger = new Trigger5();
|
|
4707
4914
|
this._invitationFlowLock = null;
|
|
@@ -4713,9 +4920,9 @@ var InvitationGuestExtension = class extends RpcExtension2 {
|
|
|
4713
4920
|
return {
|
|
4714
4921
|
InvitationHostService: {
|
|
4715
4922
|
options: async (options) => {
|
|
4716
|
-
|
|
4717
|
-
F:
|
|
4718
|
-
L:
|
|
4923
|
+
invariant12(!this._remoteOptions, "Remote options already set.", {
|
|
4924
|
+
F: __dxlog_file18,
|
|
4925
|
+
L: 68,
|
|
4719
4926
|
S: this,
|
|
4720
4927
|
A: [
|
|
4721
4928
|
"!this._remoteOptions",
|
|
@@ -4740,34 +4947,34 @@ var InvitationGuestExtension = class extends RpcExtension2 {
|
|
|
4740
4947
|
async onOpen(context) {
|
|
4741
4948
|
await super.onOpen(context);
|
|
4742
4949
|
try {
|
|
4743
|
-
|
|
4744
|
-
F:
|
|
4745
|
-
L:
|
|
4950
|
+
log15("guest acquire lock", void 0, {
|
|
4951
|
+
F: __dxlog_file18,
|
|
4952
|
+
L: 89,
|
|
4746
4953
|
S: this,
|
|
4747
4954
|
C: (f, a) => f(...a)
|
|
4748
4955
|
});
|
|
4749
4956
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
4750
|
-
|
|
4751
|
-
F:
|
|
4752
|
-
L:
|
|
4957
|
+
log15("guest lock acquired", void 0, {
|
|
4958
|
+
F: __dxlog_file18,
|
|
4959
|
+
L: 91,
|
|
4753
4960
|
S: this,
|
|
4754
4961
|
C: (f, a) => f(...a)
|
|
4755
4962
|
});
|
|
4756
4963
|
await cancelWithContext4(this._ctx, this.rpc.InvitationHostService.options({
|
|
4757
4964
|
role: InvitationOptions.Role.GUEST
|
|
4758
4965
|
}));
|
|
4759
|
-
|
|
4760
|
-
F:
|
|
4761
|
-
L:
|
|
4966
|
+
log15("options sent", void 0, {
|
|
4967
|
+
F: __dxlog_file18,
|
|
4968
|
+
L: 96,
|
|
4762
4969
|
S: this,
|
|
4763
4970
|
C: (f, a) => f(...a)
|
|
4764
4971
|
});
|
|
4765
4972
|
await cancelWithContext4(this._ctx, this._remoteOptionsTrigger.wait({
|
|
4766
4973
|
timeout: OPTIONS_TIMEOUT
|
|
4767
4974
|
}));
|
|
4768
|
-
|
|
4769
|
-
F:
|
|
4770
|
-
L:
|
|
4975
|
+
log15("options received", void 0, {
|
|
4976
|
+
F: __dxlog_file18,
|
|
4977
|
+
L: 98,
|
|
4771
4978
|
S: this,
|
|
4772
4979
|
C: (f, a) => f(...a)
|
|
4773
4980
|
});
|
|
@@ -4799,9 +5006,9 @@ var InvitationGuestExtension = class extends RpcExtension2 {
|
|
|
4799
5006
|
if (this._invitationFlowLock != null) {
|
|
4800
5007
|
this._invitationFlowLock.release();
|
|
4801
5008
|
this._invitationFlowLock = null;
|
|
4802
|
-
|
|
4803
|
-
F:
|
|
4804
|
-
L:
|
|
5009
|
+
log15("invitation flow lock released", void 0, {
|
|
5010
|
+
F: __dxlog_file18,
|
|
5011
|
+
L: 131,
|
|
4805
5012
|
S: this,
|
|
4806
5013
|
C: (f, a) => f(...a)
|
|
4807
5014
|
});
|
|
@@ -4810,35 +5017,35 @@ var InvitationGuestExtension = class extends RpcExtension2 {
|
|
|
4810
5017
|
};
|
|
4811
5018
|
|
|
4812
5019
|
// packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts
|
|
4813
|
-
import { Trigger as Trigger6, scheduleTask as
|
|
5020
|
+
import { Trigger as Trigger6, scheduleTask as scheduleTask6 } from "@dxos/async";
|
|
4814
5021
|
import { cancelWithContext as cancelWithContext5, Context as Context7 } from "@dxos/context";
|
|
4815
5022
|
import { randomBytes, verify } from "@dxos/crypto";
|
|
4816
|
-
import { invariant as
|
|
5023
|
+
import { invariant as invariant13, InvariantViolation } from "@dxos/invariant";
|
|
4817
5024
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
4818
|
-
import { log as
|
|
5025
|
+
import { log as log16 } from "@dxos/log";
|
|
4819
5026
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, trace as trace6 } from "@dxos/protocols";
|
|
4820
|
-
import { schema as
|
|
4821
|
-
import { Invitation as
|
|
5027
|
+
import { schema as schema5 } from "@dxos/protocols/proto";
|
|
5028
|
+
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4822
5029
|
import { AuthenticationResponse, InvitationOptions as InvitationOptions2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
4823
5030
|
import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
|
|
4824
|
-
var
|
|
5031
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
|
|
4825
5032
|
var OPTIONS_TIMEOUT2 = 1e4;
|
|
4826
5033
|
var MAX_OTP_ATTEMPTS = 3;
|
|
4827
5034
|
var InvitationHostExtension = class extends RpcExtension3 {
|
|
4828
5035
|
constructor(_invitationFlowMutex, _callbacks) {
|
|
4829
5036
|
super({
|
|
4830
5037
|
requested: {
|
|
4831
|
-
InvitationHostService:
|
|
5038
|
+
InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
|
|
4832
5039
|
},
|
|
4833
5040
|
exposed: {
|
|
4834
|
-
InvitationHostService:
|
|
5041
|
+
InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
|
|
4835
5042
|
}
|
|
4836
5043
|
});
|
|
4837
5044
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
4838
5045
|
this._callbacks = _callbacks;
|
|
4839
5046
|
this._ctx = new Context7(void 0, {
|
|
4840
|
-
F:
|
|
4841
|
-
L:
|
|
5047
|
+
F: __dxlog_file19,
|
|
5048
|
+
L: 57
|
|
4842
5049
|
});
|
|
4843
5050
|
this._remoteOptionsTrigger = new Trigger6();
|
|
4844
5051
|
this._challenge = void 0;
|
|
@@ -4857,9 +5064,9 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
4857
5064
|
// Perhaps in the future we will have more complex logic here.
|
|
4858
5065
|
InvitationHostService: {
|
|
4859
5066
|
options: async (options) => {
|
|
4860
|
-
|
|
4861
|
-
F:
|
|
4862
|
-
L:
|
|
5067
|
+
invariant13(!this._remoteOptions, "Remote options already set.", {
|
|
5068
|
+
F: __dxlog_file19,
|
|
5069
|
+
L: 106,
|
|
4863
5070
|
S: this,
|
|
4864
5071
|
A: [
|
|
4865
5072
|
"!this._remoteOptions",
|
|
@@ -4872,48 +5079,48 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
4872
5079
|
introduce: async (request) => {
|
|
4873
5080
|
const { profile, invitationId } = request;
|
|
4874
5081
|
const traceId = PublicKey9.random().toHex();
|
|
4875
|
-
|
|
5082
|
+
log16.trace("dxos.sdk.invitation-handler.host.introduce", trace6.begin({
|
|
4876
5083
|
id: traceId
|
|
4877
5084
|
}), {
|
|
4878
|
-
F:
|
|
4879
|
-
L:
|
|
5085
|
+
F: __dxlog_file19,
|
|
5086
|
+
L: 114,
|
|
4880
5087
|
S: this,
|
|
4881
5088
|
C: (f, a) => f(...a)
|
|
4882
5089
|
});
|
|
4883
5090
|
const invitation = this._requireActiveInvitation();
|
|
4884
|
-
this._assertInvitationState(
|
|
5091
|
+
this._assertInvitationState(Invitation5.State.CONNECTED);
|
|
4885
5092
|
if (invitationId !== invitation?.invitationId) {
|
|
4886
|
-
|
|
5093
|
+
log16.warn("incorrect invitationId", {
|
|
4887
5094
|
expected: invitation.invitationId,
|
|
4888
5095
|
actual: invitationId
|
|
4889
5096
|
}, {
|
|
4890
|
-
F:
|
|
4891
|
-
L:
|
|
5097
|
+
F: __dxlog_file19,
|
|
5098
|
+
L: 119,
|
|
4892
5099
|
S: this,
|
|
4893
5100
|
C: (f, a) => f(...a)
|
|
4894
5101
|
});
|
|
4895
5102
|
this._callbacks.onError(new Error("Incorrect invitationId."));
|
|
4896
|
-
|
|
5103
|
+
scheduleTask6(this._ctx, () => this.close());
|
|
4897
5104
|
return {
|
|
4898
|
-
authMethod:
|
|
5105
|
+
authMethod: Invitation5.AuthMethod.NONE
|
|
4899
5106
|
};
|
|
4900
5107
|
}
|
|
4901
|
-
|
|
5108
|
+
log16("guest introduced themselves", {
|
|
4902
5109
|
guestProfile: profile
|
|
4903
5110
|
}, {
|
|
4904
|
-
F:
|
|
4905
|
-
L:
|
|
5111
|
+
F: __dxlog_file19,
|
|
5112
|
+
L: 128,
|
|
4906
5113
|
S: this,
|
|
4907
5114
|
C: (f, a) => f(...a)
|
|
4908
5115
|
});
|
|
4909
5116
|
this.guestProfile = profile;
|
|
4910
|
-
this._callbacks.onStateUpdate(
|
|
4911
|
-
this._challenge = invitation.authMethod ===
|
|
4912
|
-
|
|
5117
|
+
this._callbacks.onStateUpdate(Invitation5.State.READY_FOR_AUTHENTICATION);
|
|
5118
|
+
this._challenge = invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
|
|
5119
|
+
log16.trace("dxos.sdk.invitation-handler.host.introduce", trace6.end({
|
|
4913
5120
|
id: traceId
|
|
4914
5121
|
}), {
|
|
4915
|
-
F:
|
|
4916
|
-
L:
|
|
5122
|
+
F: __dxlog_file19,
|
|
5123
|
+
L: 134,
|
|
4917
5124
|
S: this,
|
|
4918
5125
|
C: (f, a) => f(...a)
|
|
4919
5126
|
});
|
|
@@ -4924,34 +5131,34 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
4924
5131
|
},
|
|
4925
5132
|
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
4926
5133
|
const traceId = PublicKey9.random().toHex();
|
|
4927
|
-
|
|
5134
|
+
log16.trace("dxos.sdk.invitation-handler.host.authenticate", trace6.begin({
|
|
4928
5135
|
id: traceId
|
|
4929
5136
|
}), {
|
|
4930
|
-
F:
|
|
4931
|
-
L:
|
|
5137
|
+
F: __dxlog_file19,
|
|
5138
|
+
L: 143,
|
|
4932
5139
|
S: this,
|
|
4933
5140
|
C: (f, a) => f(...a)
|
|
4934
5141
|
});
|
|
4935
5142
|
const invitation = this._requireActiveInvitation();
|
|
4936
|
-
|
|
5143
|
+
log16("received authentication request", {
|
|
4937
5144
|
authCode: code
|
|
4938
5145
|
}, {
|
|
4939
|
-
F:
|
|
4940
|
-
L:
|
|
5146
|
+
F: __dxlog_file19,
|
|
5147
|
+
L: 146,
|
|
4941
5148
|
S: this,
|
|
4942
5149
|
C: (f, a) => f(...a)
|
|
4943
5150
|
});
|
|
4944
5151
|
let status = AuthenticationResponse.Status.OK;
|
|
4945
5152
|
this._assertInvitationState([
|
|
4946
|
-
|
|
4947
|
-
|
|
5153
|
+
Invitation5.State.AUTHENTICATING,
|
|
5154
|
+
Invitation5.State.READY_FOR_AUTHENTICATION
|
|
4948
5155
|
]);
|
|
4949
|
-
this._callbacks.onStateUpdate(
|
|
5156
|
+
this._callbacks.onStateUpdate(Invitation5.State.AUTHENTICATING);
|
|
4950
5157
|
switch (invitation.authMethod) {
|
|
4951
|
-
case
|
|
4952
|
-
|
|
4953
|
-
F:
|
|
4954
|
-
L:
|
|
5158
|
+
case Invitation5.AuthMethod.NONE: {
|
|
5159
|
+
log16("authentication not required", void 0, {
|
|
5160
|
+
F: __dxlog_file19,
|
|
5161
|
+
L: 154,
|
|
4955
5162
|
S: this,
|
|
4956
5163
|
C: (f, a) => f(...a)
|
|
4957
5164
|
});
|
|
@@ -4959,7 +5166,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
4959
5166
|
status: AuthenticationResponse.Status.OK
|
|
4960
5167
|
};
|
|
4961
5168
|
}
|
|
4962
|
-
case
|
|
5169
|
+
case Invitation5.AuthMethod.SHARED_SECRET: {
|
|
4963
5170
|
if (invitation.authCode) {
|
|
4964
5171
|
if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
|
|
4965
5172
|
status = AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
|
|
@@ -4971,7 +5178,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
4971
5178
|
}
|
|
4972
5179
|
break;
|
|
4973
5180
|
}
|
|
4974
|
-
case
|
|
5181
|
+
case Invitation5.AuthMethod.KNOWN_PUBLIC_KEY: {
|
|
4975
5182
|
if (!invitation.guestKeypair) {
|
|
4976
5183
|
status = AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
4977
5184
|
break;
|
|
@@ -4985,11 +5192,11 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
4985
5192
|
break;
|
|
4986
5193
|
}
|
|
4987
5194
|
default: {
|
|
4988
|
-
|
|
5195
|
+
log16.error("invalid authentication method", {
|
|
4989
5196
|
authMethod: invitation.authMethod
|
|
4990
5197
|
}, {
|
|
4991
|
-
F:
|
|
4992
|
-
L:
|
|
5198
|
+
F: __dxlog_file19,
|
|
5199
|
+
L: 192,
|
|
4993
5200
|
S: this,
|
|
4994
5201
|
C: (f, a) => f(...a)
|
|
4995
5202
|
});
|
|
@@ -5002,19 +5209,19 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
5002
5209
|
AuthenticationResponse.Status.INVALID_OTP
|
|
5003
5210
|
].includes(status)) {
|
|
5004
5211
|
this._callbacks.onError(new Error(`Authentication failed, with status=${status}`));
|
|
5005
|
-
|
|
5212
|
+
scheduleTask6(this._ctx, () => this.close());
|
|
5006
5213
|
return {
|
|
5007
5214
|
status
|
|
5008
5215
|
};
|
|
5009
5216
|
}
|
|
5010
|
-
|
|
5217
|
+
log16.trace("dxos.sdk.invitation-handler.host.authenticate", trace6.end({
|
|
5011
5218
|
id: traceId,
|
|
5012
5219
|
data: {
|
|
5013
5220
|
status
|
|
5014
5221
|
}
|
|
5015
5222
|
}), {
|
|
5016
|
-
F:
|
|
5017
|
-
L:
|
|
5223
|
+
F: __dxlog_file19,
|
|
5224
|
+
L: 204,
|
|
5018
5225
|
S: this,
|
|
5019
5226
|
C: (f, a) => f(...a)
|
|
5020
5227
|
});
|
|
@@ -5024,28 +5231,28 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
5024
5231
|
},
|
|
5025
5232
|
admit: async (request) => {
|
|
5026
5233
|
const traceId = PublicKey9.random().toHex();
|
|
5027
|
-
|
|
5234
|
+
log16.trace("dxos.sdk.invitation-handler.host.admit", trace6.begin({
|
|
5028
5235
|
id: traceId
|
|
5029
5236
|
}), {
|
|
5030
|
-
F:
|
|
5031
|
-
L:
|
|
5237
|
+
F: __dxlog_file19,
|
|
5238
|
+
L: 210,
|
|
5032
5239
|
S: this,
|
|
5033
5240
|
C: (f, a) => f(...a)
|
|
5034
5241
|
});
|
|
5035
5242
|
const invitation = this._requireActiveInvitation();
|
|
5036
5243
|
try {
|
|
5037
5244
|
if (isAuthenticationRequired(invitation)) {
|
|
5038
|
-
this._assertInvitationState(
|
|
5245
|
+
this._assertInvitationState(Invitation5.State.AUTHENTICATING);
|
|
5039
5246
|
if (!this.authenticationPassed) {
|
|
5040
5247
|
throw new Error("Not authenticated");
|
|
5041
5248
|
}
|
|
5042
5249
|
}
|
|
5043
5250
|
const response = await this._callbacks.admit(request);
|
|
5044
|
-
|
|
5251
|
+
log16.trace("dxos.sdk.invitation-handler.host.admit", trace6.end({
|
|
5045
5252
|
id: traceId
|
|
5046
5253
|
}), {
|
|
5047
|
-
F:
|
|
5048
|
-
L:
|
|
5254
|
+
F: __dxlog_file19,
|
|
5255
|
+
L: 224,
|
|
5049
5256
|
S: this,
|
|
5050
5257
|
C: (f, a) => f(...a)
|
|
5051
5258
|
});
|
|
@@ -5061,36 +5268,36 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
5061
5268
|
async onOpen(context) {
|
|
5062
5269
|
await super.onOpen(context);
|
|
5063
5270
|
try {
|
|
5064
|
-
|
|
5065
|
-
F:
|
|
5066
|
-
L:
|
|
5271
|
+
log16("host acquire lock", void 0, {
|
|
5272
|
+
F: __dxlog_file19,
|
|
5273
|
+
L: 239,
|
|
5067
5274
|
S: this,
|
|
5068
5275
|
C: (f, a) => f(...a)
|
|
5069
5276
|
});
|
|
5070
5277
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
5071
|
-
|
|
5072
|
-
F:
|
|
5073
|
-
L:
|
|
5278
|
+
log16("host lock acquired", void 0, {
|
|
5279
|
+
F: __dxlog_file19,
|
|
5280
|
+
L: 241,
|
|
5074
5281
|
S: this,
|
|
5075
5282
|
C: (f, a) => f(...a)
|
|
5076
5283
|
});
|
|
5077
5284
|
const lastState = this._requireActiveInvitation().state;
|
|
5078
|
-
this._callbacks.onStateUpdate(
|
|
5285
|
+
this._callbacks.onStateUpdate(Invitation5.State.CONNECTING);
|
|
5079
5286
|
await this.rpc.InvitationHostService.options({
|
|
5080
5287
|
role: InvitationOptions2.Role.HOST
|
|
5081
5288
|
});
|
|
5082
|
-
|
|
5083
|
-
F:
|
|
5084
|
-
L:
|
|
5289
|
+
log16("options sent", void 0, {
|
|
5290
|
+
F: __dxlog_file19,
|
|
5291
|
+
L: 245,
|
|
5085
5292
|
S: this,
|
|
5086
5293
|
C: (f, a) => f(...a)
|
|
5087
5294
|
});
|
|
5088
5295
|
await cancelWithContext5(this._ctx, this._remoteOptionsTrigger.wait({
|
|
5089
5296
|
timeout: OPTIONS_TIMEOUT2
|
|
5090
5297
|
}));
|
|
5091
|
-
|
|
5092
|
-
F:
|
|
5093
|
-
L:
|
|
5298
|
+
log16("options received", void 0, {
|
|
5299
|
+
F: __dxlog_file19,
|
|
5300
|
+
L: 247,
|
|
5094
5301
|
S: this,
|
|
5095
5302
|
C: (f, a) => f(...a)
|
|
5096
5303
|
});
|
|
@@ -5102,7 +5309,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
5102
5309
|
remotePeerId: context.remotePeerId
|
|
5103
5310
|
});
|
|
5104
5311
|
}
|
|
5105
|
-
this._callbacks.onStateUpdate(
|
|
5312
|
+
this._callbacks.onStateUpdate(Invitation5.State.CONNECTED);
|
|
5106
5313
|
this._callbacks.onOpen(this._ctx, context);
|
|
5107
5314
|
} catch (err) {
|
|
5108
5315
|
if (this._invitationFlowLock != null) {
|
|
@@ -5116,7 +5323,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
5116
5323
|
_requireActiveInvitation() {
|
|
5117
5324
|
const invitation = this._callbacks.activeInvitation;
|
|
5118
5325
|
if (invitation == null) {
|
|
5119
|
-
|
|
5326
|
+
scheduleTask6(this._ctx, () => this.close());
|
|
5120
5327
|
throw new Error("Active invitation not found");
|
|
5121
5328
|
}
|
|
5122
5329
|
return invitation;
|
|
@@ -5127,7 +5334,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
5127
5334
|
stateOrMany
|
|
5128
5335
|
];
|
|
5129
5336
|
if (!validStates.includes(invitation.state)) {
|
|
5130
|
-
|
|
5337
|
+
scheduleTask6(this._ctx, () => this.close());
|
|
5131
5338
|
throw new InvariantViolation(`Expected ${stateToString(invitation.state)} to be one of [${validStates.map(stateToString).join(", ")}]`);
|
|
5132
5339
|
}
|
|
5133
5340
|
}
|
|
@@ -5142,32 +5349,127 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
5142
5349
|
if (this._invitationFlowLock != null) {
|
|
5143
5350
|
this._invitationFlowLock?.release();
|
|
5144
5351
|
this._invitationFlowLock = null;
|
|
5145
|
-
|
|
5146
|
-
F:
|
|
5147
|
-
L:
|
|
5352
|
+
log16("invitation flow lock released", void 0, {
|
|
5353
|
+
F: __dxlog_file19,
|
|
5354
|
+
L: 302,
|
|
5148
5355
|
S: this,
|
|
5149
5356
|
C: (f, a) => f(...a)
|
|
5150
5357
|
});
|
|
5151
5358
|
}
|
|
5152
5359
|
}
|
|
5153
5360
|
};
|
|
5154
|
-
var isAuthenticationRequired = (invitation) => invitation.authMethod !==
|
|
5361
|
+
var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation5.AuthMethod.NONE;
|
|
5362
|
+
|
|
5363
|
+
// packages/sdk/client-services/src/packlets/invitations/invitation-state.ts
|
|
5364
|
+
import { Mutex as Mutex3 } from "@dxos/async";
|
|
5365
|
+
import { log as log17 } from "@dxos/log";
|
|
5366
|
+
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5367
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-state.ts";
|
|
5368
|
+
var createGuardedInvitationState = (ctx, invitation, stream) => {
|
|
5369
|
+
const mutex = new Mutex3();
|
|
5370
|
+
let lastActiveLockHolder = null;
|
|
5371
|
+
let currentInvitation = {
|
|
5372
|
+
...invitation
|
|
5373
|
+
};
|
|
5374
|
+
const isStateChangeAllowed = (lockHolder) => {
|
|
5375
|
+
if (ctx.disposed || lockHolder !== null && mutex.isLocked() && !lockHolder.hasFlowLock()) {
|
|
5376
|
+
return false;
|
|
5377
|
+
}
|
|
5378
|
+
return lockHolder == null || lastActiveLockHolder !== lockHolder || isNonTerminalState(currentInvitation.state);
|
|
5379
|
+
};
|
|
5380
|
+
return {
|
|
5381
|
+
mutex,
|
|
5382
|
+
get current() {
|
|
5383
|
+
return currentInvitation;
|
|
5384
|
+
},
|
|
5385
|
+
// disposing context prevents any further state updates
|
|
5386
|
+
complete: (newState) => {
|
|
5387
|
+
currentInvitation = {
|
|
5388
|
+
...currentInvitation,
|
|
5389
|
+
...newState
|
|
5390
|
+
};
|
|
5391
|
+
stream.next(currentInvitation);
|
|
5392
|
+
return ctx.dispose();
|
|
5393
|
+
},
|
|
5394
|
+
set: (lockHolder, newState) => {
|
|
5395
|
+
if (isStateChangeAllowed(lockHolder)) {
|
|
5396
|
+
logStateUpdate(currentInvitation, lockHolder, newState);
|
|
5397
|
+
currentInvitation = {
|
|
5398
|
+
...currentInvitation,
|
|
5399
|
+
state: newState
|
|
5400
|
+
};
|
|
5401
|
+
stream.next(currentInvitation);
|
|
5402
|
+
lastActiveLockHolder = lockHolder;
|
|
5403
|
+
return true;
|
|
5404
|
+
}
|
|
5405
|
+
return false;
|
|
5406
|
+
},
|
|
5407
|
+
error: (lockHolder, error) => {
|
|
5408
|
+
if (isStateChangeAllowed(lockHolder)) {
|
|
5409
|
+
logStateUpdate(currentInvitation, lockHolder, Invitation6.State.ERROR);
|
|
5410
|
+
currentInvitation = {
|
|
5411
|
+
...currentInvitation,
|
|
5412
|
+
state: Invitation6.State.ERROR
|
|
5413
|
+
};
|
|
5414
|
+
stream.next(currentInvitation);
|
|
5415
|
+
stream.error(error);
|
|
5416
|
+
lastActiveLockHolder = lockHolder;
|
|
5417
|
+
return true;
|
|
5418
|
+
}
|
|
5419
|
+
return false;
|
|
5420
|
+
}
|
|
5421
|
+
};
|
|
5422
|
+
};
|
|
5423
|
+
var logStateUpdate = (invitation, actor, newState) => {
|
|
5424
|
+
if (isNonTerminalState(newState)) {
|
|
5425
|
+
log17("invitation state update", {
|
|
5426
|
+
actor: actor?.constructor.name,
|
|
5427
|
+
newState: stateToString(newState),
|
|
5428
|
+
oldState: stateToString(invitation.state)
|
|
5429
|
+
}, {
|
|
5430
|
+
F: __dxlog_file20,
|
|
5431
|
+
L: 89,
|
|
5432
|
+
S: void 0,
|
|
5433
|
+
C: (f, a) => f(...a)
|
|
5434
|
+
});
|
|
5435
|
+
} else {
|
|
5436
|
+
log17.info("invitation state update", {
|
|
5437
|
+
actor: actor?.constructor.name,
|
|
5438
|
+
newState: stateToString(newState),
|
|
5439
|
+
oldState: stateToString(invitation.state)
|
|
5440
|
+
}, {
|
|
5441
|
+
F: __dxlog_file20,
|
|
5442
|
+
L: 95,
|
|
5443
|
+
S: void 0,
|
|
5444
|
+
C: (f, a) => f(...a)
|
|
5445
|
+
});
|
|
5446
|
+
}
|
|
5447
|
+
};
|
|
5448
|
+
var isNonTerminalState = (currentState) => {
|
|
5449
|
+
return ![
|
|
5450
|
+
Invitation6.State.SUCCESS,
|
|
5451
|
+
Invitation6.State.ERROR,
|
|
5452
|
+
Invitation6.State.CANCELLED,
|
|
5453
|
+
Invitation6.State.TIMEOUT,
|
|
5454
|
+
Invitation6.State.EXPIRED
|
|
5455
|
+
].includes(currentState);
|
|
5456
|
+
};
|
|
5155
5457
|
|
|
5156
5458
|
// packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts
|
|
5157
|
-
import { invariant as
|
|
5459
|
+
import { invariant as invariant14 } from "@dxos/invariant";
|
|
5158
5460
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
5159
|
-
import { log as
|
|
5461
|
+
import { log as log18 } from "@dxos/log";
|
|
5160
5462
|
import { InvitationOptions as InvitationOptions3 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
5161
5463
|
import { ComplexSet as ComplexSet4 } from "@dxos/util";
|
|
5162
|
-
var
|
|
5464
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
|
|
5163
5465
|
var InvitationTopology = class {
|
|
5164
5466
|
constructor(_role) {
|
|
5165
5467
|
this._role = _role;
|
|
5166
5468
|
this._seenPeers = new ComplexSet4(PublicKey10.hash);
|
|
5167
5469
|
}
|
|
5168
5470
|
init(controller) {
|
|
5169
|
-
|
|
5170
|
-
F:
|
|
5471
|
+
invariant14(!this._controller, "Already initialized.", {
|
|
5472
|
+
F: __dxlog_file21,
|
|
5171
5473
|
L: 42,
|
|
5172
5474
|
S: this,
|
|
5173
5475
|
A: [
|
|
@@ -5178,8 +5480,8 @@ var InvitationTopology = class {
|
|
|
5178
5480
|
this._controller = controller;
|
|
5179
5481
|
}
|
|
5180
5482
|
update() {
|
|
5181
|
-
|
|
5182
|
-
F:
|
|
5483
|
+
invariant14(this._controller, "Not initialized.", {
|
|
5484
|
+
F: __dxlog_file21,
|
|
5183
5485
|
L: 47,
|
|
5184
5486
|
S: this,
|
|
5185
5487
|
A: [
|
|
@@ -5198,11 +5500,11 @@ var InvitationTopology = class {
|
|
|
5198
5500
|
const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
|
|
5199
5501
|
this._seenPeers = new ComplexSet4(PublicKey10.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
|
|
5200
5502
|
if (firstUnknownPeer != null) {
|
|
5201
|
-
|
|
5503
|
+
log18("invitation connect", {
|
|
5202
5504
|
ownPeerId,
|
|
5203
5505
|
remotePeerId: firstUnknownPeer
|
|
5204
5506
|
}, {
|
|
5205
|
-
F:
|
|
5507
|
+
F: __dxlog_file21,
|
|
5206
5508
|
L: 69,
|
|
5207
5509
|
S: this,
|
|
5208
5510
|
C: (f, a) => f(...a)
|
|
@@ -5212,8 +5514,8 @@ var InvitationTopology = class {
|
|
|
5212
5514
|
}
|
|
5213
5515
|
}
|
|
5214
5516
|
async onOffer(peer) {
|
|
5215
|
-
|
|
5216
|
-
F:
|
|
5517
|
+
invariant14(this._controller, "Not initialized.", {
|
|
5518
|
+
F: __dxlog_file21,
|
|
5217
5519
|
L: 76,
|
|
5218
5520
|
S: this,
|
|
5219
5521
|
A: [
|
|
@@ -5232,20 +5534,21 @@ var InvitationTopology = class {
|
|
|
5232
5534
|
};
|
|
5233
5535
|
|
|
5234
5536
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
5235
|
-
var
|
|
5537
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
5236
5538
|
var metrics = _trace.metrics;
|
|
5237
5539
|
var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
|
|
5238
5540
|
var InvitationsHandler = class {
|
|
5239
5541
|
/**
|
|
5240
5542
|
* @internal
|
|
5241
5543
|
*/
|
|
5242
|
-
constructor(_networkManager,
|
|
5544
|
+
constructor(_networkManager, _edgeClient, _connectionParams) {
|
|
5243
5545
|
this._networkManager = _networkManager;
|
|
5244
|
-
this.
|
|
5546
|
+
this._edgeClient = _edgeClient;
|
|
5547
|
+
this._connectionParams = _connectionParams;
|
|
5245
5548
|
}
|
|
5246
5549
|
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
5247
5550
|
metrics.increment("dxos.invitation.created");
|
|
5248
|
-
const guardedState =
|
|
5551
|
+
const guardedState = createGuardedInvitationState(ctx, invitation, stream);
|
|
5249
5552
|
const createExtension = () => {
|
|
5250
5553
|
const extension = new InvitationHostExtension(guardedState.mutex, {
|
|
5251
5554
|
get activeInvitation() {
|
|
@@ -5258,9 +5561,9 @@ var InvitationsHandler = class {
|
|
|
5258
5561
|
admit: async (admissionRequest) => {
|
|
5259
5562
|
try {
|
|
5260
5563
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
5261
|
-
|
|
5262
|
-
F:
|
|
5263
|
-
L:
|
|
5564
|
+
invariant15(deviceKey, void 0, {
|
|
5565
|
+
F: __dxlog_file22,
|
|
5566
|
+
L: 100,
|
|
5264
5567
|
S: this,
|
|
5265
5568
|
A: [
|
|
5266
5569
|
"deviceKey",
|
|
@@ -5282,44 +5585,44 @@ var InvitationsHandler = class {
|
|
|
5282
5585
|
guardedState.error(extension, new ContextDisposedError3());
|
|
5283
5586
|
}
|
|
5284
5587
|
});
|
|
5285
|
-
|
|
5588
|
+
scheduleTask7(connectionCtx, async () => {
|
|
5286
5589
|
const traceId = PublicKey11.random().toHex();
|
|
5287
5590
|
try {
|
|
5288
|
-
|
|
5591
|
+
log19.trace("dxos.sdk.invitations-handler.host.onOpen", trace7.begin({
|
|
5289
5592
|
id: traceId
|
|
5290
5593
|
}), {
|
|
5291
|
-
F:
|
|
5292
|
-
L:
|
|
5594
|
+
F: __dxlog_file22,
|
|
5595
|
+
L: 125,
|
|
5293
5596
|
S: this,
|
|
5294
5597
|
C: (f, a) => f(...a)
|
|
5295
5598
|
});
|
|
5296
|
-
|
|
5599
|
+
log19("connected", {
|
|
5297
5600
|
...protocol.toJSON()
|
|
5298
5601
|
}, {
|
|
5299
|
-
F:
|
|
5300
|
-
L:
|
|
5602
|
+
F: __dxlog_file22,
|
|
5603
|
+
L: 126,
|
|
5301
5604
|
S: this,
|
|
5302
5605
|
C: (f, a) => f(...a)
|
|
5303
5606
|
});
|
|
5304
5607
|
const deviceKey = await extension.completedTrigger.wait({
|
|
5305
5608
|
timeout: invitation.timeout
|
|
5306
5609
|
});
|
|
5307
|
-
|
|
5610
|
+
log19("admitted guest", {
|
|
5308
5611
|
guest: deviceKey,
|
|
5309
5612
|
...protocol.toJSON()
|
|
5310
5613
|
}, {
|
|
5311
|
-
F:
|
|
5312
|
-
L:
|
|
5614
|
+
F: __dxlog_file22,
|
|
5615
|
+
L: 128,
|
|
5313
5616
|
S: this,
|
|
5314
5617
|
C: (f, a) => f(...a)
|
|
5315
5618
|
});
|
|
5316
|
-
guardedState.set(extension,
|
|
5619
|
+
guardedState.set(extension, Invitation7.State.SUCCESS);
|
|
5317
5620
|
metrics.increment("dxos.invitation.success");
|
|
5318
|
-
|
|
5621
|
+
log19.trace("dxos.sdk.invitations-handler.host.onOpen", trace7.end({
|
|
5319
5622
|
id: traceId
|
|
5320
5623
|
}), {
|
|
5321
|
-
F:
|
|
5322
|
-
L:
|
|
5624
|
+
F: __dxlog_file22,
|
|
5625
|
+
L: 131,
|
|
5323
5626
|
S: this,
|
|
5324
5627
|
C: (f, a) => f(...a)
|
|
5325
5628
|
});
|
|
@@ -5329,13 +5632,13 @@ var InvitationsHandler = class {
|
|
|
5329
5632
|
}
|
|
5330
5633
|
} catch (err) {
|
|
5331
5634
|
if (err instanceof TimeoutError2) {
|
|
5332
|
-
if (guardedState.set(extension,
|
|
5635
|
+
if (guardedState.set(extension, Invitation7.State.TIMEOUT)) {
|
|
5333
5636
|
metrics.increment("dxos.invitation.timeout");
|
|
5334
|
-
|
|
5637
|
+
log19("timeout", {
|
|
5335
5638
|
...protocol.toJSON()
|
|
5336
5639
|
}, {
|
|
5337
|
-
F:
|
|
5338
|
-
L:
|
|
5640
|
+
F: __dxlog_file22,
|
|
5641
|
+
L: 141,
|
|
5339
5642
|
S: this,
|
|
5340
5643
|
C: (f, a) => f(...a)
|
|
5341
5644
|
});
|
|
@@ -5343,20 +5646,20 @@ var InvitationsHandler = class {
|
|
|
5343
5646
|
} else {
|
|
5344
5647
|
if (guardedState.error(extension, err)) {
|
|
5345
5648
|
metrics.increment("dxos.invitation.failed");
|
|
5346
|
-
|
|
5347
|
-
F:
|
|
5348
|
-
L:
|
|
5649
|
+
log19.error("failed", err, {
|
|
5650
|
+
F: __dxlog_file22,
|
|
5651
|
+
L: 146,
|
|
5349
5652
|
S: this,
|
|
5350
5653
|
C: (f, a) => f(...a)
|
|
5351
5654
|
});
|
|
5352
5655
|
}
|
|
5353
5656
|
}
|
|
5354
|
-
|
|
5657
|
+
log19.trace("dxos.sdk.invitations-handler.host.onOpen", trace7.error({
|
|
5355
5658
|
id: traceId,
|
|
5356
5659
|
error: err
|
|
5357
5660
|
}), {
|
|
5358
|
-
F:
|
|
5359
|
-
L:
|
|
5661
|
+
F: __dxlog_file22,
|
|
5662
|
+
L: 149,
|
|
5360
5663
|
S: this,
|
|
5361
5664
|
C: (f, a) => f(...a)
|
|
5362
5665
|
});
|
|
@@ -5366,24 +5669,24 @@ var InvitationsHandler = class {
|
|
|
5366
5669
|
},
|
|
5367
5670
|
onError: (err) => {
|
|
5368
5671
|
if (err instanceof InvalidInvitationExtensionRoleError3) {
|
|
5369
|
-
|
|
5672
|
+
log19("invalid role", {
|
|
5370
5673
|
...err.context
|
|
5371
5674
|
}, {
|
|
5372
|
-
F:
|
|
5373
|
-
L:
|
|
5675
|
+
F: __dxlog_file22,
|
|
5676
|
+
L: 157,
|
|
5374
5677
|
S: this,
|
|
5375
5678
|
C: (f, a) => f(...a)
|
|
5376
5679
|
});
|
|
5377
5680
|
return;
|
|
5378
5681
|
}
|
|
5379
5682
|
if (err instanceof TimeoutError2) {
|
|
5380
|
-
if (guardedState.set(extension,
|
|
5683
|
+
if (guardedState.set(extension, Invitation7.State.TIMEOUT)) {
|
|
5381
5684
|
metrics.increment("dxos.invitation.timeout");
|
|
5382
|
-
|
|
5685
|
+
log19("timeout", {
|
|
5383
5686
|
err
|
|
5384
5687
|
}, {
|
|
5385
|
-
F:
|
|
5386
|
-
L:
|
|
5688
|
+
F: __dxlog_file22,
|
|
5689
|
+
L: 163,
|
|
5387
5690
|
S: this,
|
|
5388
5691
|
C: (f, a) => f(...a)
|
|
5389
5692
|
});
|
|
@@ -5391,9 +5694,9 @@ var InvitationsHandler = class {
|
|
|
5391
5694
|
} else {
|
|
5392
5695
|
if (guardedState.error(extension, err)) {
|
|
5393
5696
|
metrics.increment("dxos.invitation.failed");
|
|
5394
|
-
|
|
5395
|
-
F:
|
|
5396
|
-
L:
|
|
5697
|
+
log19.error("failed", err, {
|
|
5698
|
+
F: __dxlog_file22,
|
|
5699
|
+
L: 168,
|
|
5397
5700
|
S: this,
|
|
5398
5701
|
C: (f, a) => f(...a)
|
|
5399
5702
|
});
|
|
@@ -5405,33 +5708,33 @@ var InvitationsHandler = class {
|
|
|
5405
5708
|
};
|
|
5406
5709
|
if (invitation.lifetime && invitation.created) {
|
|
5407
5710
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
5408
|
-
|
|
5409
|
-
F:
|
|
5410
|
-
L:
|
|
5711
|
+
log19.warn("invitation has already expired", void 0, {
|
|
5712
|
+
F: __dxlog_file22,
|
|
5713
|
+
L: 179,
|
|
5411
5714
|
S: this,
|
|
5412
5715
|
C: (f, a) => f(...a)
|
|
5413
5716
|
});
|
|
5414
5717
|
} else {
|
|
5415
|
-
|
|
5718
|
+
scheduleTask7(ctx, async () => {
|
|
5416
5719
|
await swarmConnection.close();
|
|
5417
|
-
guardedState.set(null,
|
|
5720
|
+
guardedState.set(null, Invitation7.State.EXPIRED);
|
|
5418
5721
|
metrics.increment("dxos.invitation.expired");
|
|
5419
5722
|
await ctx.dispose();
|
|
5420
5723
|
}, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
|
|
5421
5724
|
}
|
|
5422
5725
|
}
|
|
5423
5726
|
let swarmConnection;
|
|
5424
|
-
|
|
5727
|
+
scheduleTask7(ctx, async () => {
|
|
5425
5728
|
swarmConnection = await this._joinSwarm(ctx, invitation, InvitationOptions4.Role.HOST, createExtension);
|
|
5426
|
-
guardedState.set(null,
|
|
5729
|
+
guardedState.set(null, Invitation7.State.CONNECTING);
|
|
5427
5730
|
});
|
|
5428
5731
|
}
|
|
5429
5732
|
acceptInvitation(ctx, stream, protocol, invitation, otpEnteredTrigger, deviceProfile) {
|
|
5430
5733
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
5431
5734
|
if (deviceProfile) {
|
|
5432
|
-
|
|
5433
|
-
F:
|
|
5434
|
-
L:
|
|
5735
|
+
invariant15(invitation.kind === Invitation7.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
5736
|
+
F: __dxlog_file22,
|
|
5737
|
+
L: 213,
|
|
5435
5738
|
S: this,
|
|
5436
5739
|
A: [
|
|
5437
5740
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -5440,23 +5743,23 @@ var InvitationsHandler = class {
|
|
|
5440
5743
|
});
|
|
5441
5744
|
}
|
|
5442
5745
|
const triedPeersIds = new ComplexSet5(PublicKey11.hash);
|
|
5443
|
-
const guardedState =
|
|
5746
|
+
const guardedState = createGuardedInvitationState(ctx, invitation, stream);
|
|
5444
5747
|
const shouldCancelInvitationFlow = (extension) => {
|
|
5445
5748
|
const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
|
|
5446
|
-
|
|
5749
|
+
log19("should cancel invitation flow", {
|
|
5447
5750
|
isLockedByAnotherConnection,
|
|
5448
|
-
invitationType:
|
|
5751
|
+
invitationType: Invitation7.Type.DELEGATED,
|
|
5449
5752
|
triedPeers: triedPeersIds.size
|
|
5450
5753
|
}, {
|
|
5451
|
-
F:
|
|
5452
|
-
L:
|
|
5754
|
+
F: __dxlog_file22,
|
|
5755
|
+
L: 221,
|
|
5453
5756
|
S: this,
|
|
5454
5757
|
C: (f, a) => f(...a)
|
|
5455
5758
|
});
|
|
5456
5759
|
if (isLockedByAnotherConnection) {
|
|
5457
5760
|
return false;
|
|
5458
5761
|
}
|
|
5459
|
-
return invitation.type !==
|
|
5762
|
+
return invitation.type !== Invitation7.Type.DELEGATED || triedPeersIds.size >= MAX_DELEGATED_INVITATION_HOST_TRIES;
|
|
5460
5763
|
};
|
|
5461
5764
|
let admitted = false;
|
|
5462
5765
|
const createExtension = () => {
|
|
@@ -5471,12 +5774,12 @@ var InvitationsHandler = class {
|
|
|
5471
5774
|
return;
|
|
5472
5775
|
}
|
|
5473
5776
|
connectionCtx.onDispose(async () => {
|
|
5474
|
-
|
|
5777
|
+
log19("extension disposed", {
|
|
5475
5778
|
admitted,
|
|
5476
5779
|
currentState: guardedState.current.state
|
|
5477
5780
|
}, {
|
|
5478
|
-
F:
|
|
5479
|
-
L:
|
|
5781
|
+
F: __dxlog_file22,
|
|
5782
|
+
L: 249,
|
|
5480
5783
|
S: this,
|
|
5481
5784
|
C: (f, a) => f(...a)
|
|
5482
5785
|
});
|
|
@@ -5487,35 +5790,35 @@ var InvitationsHandler = class {
|
|
|
5487
5790
|
}
|
|
5488
5791
|
}
|
|
5489
5792
|
});
|
|
5490
|
-
|
|
5793
|
+
scheduleTask7(connectionCtx, async () => {
|
|
5491
5794
|
const traceId = PublicKey11.random().toHex();
|
|
5492
5795
|
try {
|
|
5493
|
-
|
|
5796
|
+
log19.trace("dxos.sdk.invitations-handler.guest.onOpen", trace7.begin({
|
|
5494
5797
|
id: traceId
|
|
5495
5798
|
}), {
|
|
5496
|
-
F:
|
|
5497
|
-
L:
|
|
5799
|
+
F: __dxlog_file22,
|
|
5800
|
+
L: 261,
|
|
5498
5801
|
S: this,
|
|
5499
5802
|
C: (f, a) => f(...a)
|
|
5500
5803
|
});
|
|
5501
|
-
|
|
5502
|
-
guardedState.set(extension,
|
|
5804
|
+
scheduleTask7(connectionCtx, () => {
|
|
5805
|
+
guardedState.set(extension, Invitation7.State.TIMEOUT);
|
|
5503
5806
|
extensionCtx.close();
|
|
5504
5807
|
}, timeout);
|
|
5505
|
-
|
|
5808
|
+
log19("connected", {
|
|
5506
5809
|
...protocol.toJSON()
|
|
5507
5810
|
}, {
|
|
5508
|
-
F:
|
|
5509
|
-
L:
|
|
5811
|
+
F: __dxlog_file22,
|
|
5812
|
+
L: 272,
|
|
5510
5813
|
S: this,
|
|
5511
5814
|
C: (f, a) => f(...a)
|
|
5512
5815
|
});
|
|
5513
|
-
guardedState.set(extension,
|
|
5514
|
-
|
|
5816
|
+
guardedState.set(extension, Invitation7.State.CONNECTED);
|
|
5817
|
+
log19("introduce", {
|
|
5515
5818
|
...protocol.toJSON()
|
|
5516
5819
|
}, {
|
|
5517
|
-
F:
|
|
5518
|
-
L:
|
|
5820
|
+
F: __dxlog_file22,
|
|
5821
|
+
L: 276,
|
|
5519
5822
|
S: this,
|
|
5520
5823
|
C: (f, a) => f(...a)
|
|
5521
5824
|
});
|
|
@@ -5523,33 +5826,33 @@ var InvitationsHandler = class {
|
|
|
5523
5826
|
invitationId: invitation.invitationId,
|
|
5524
5827
|
...protocol.createIntroduction()
|
|
5525
5828
|
});
|
|
5526
|
-
|
|
5829
|
+
log19("introduce response", {
|
|
5527
5830
|
...protocol.toJSON(),
|
|
5528
5831
|
response: introductionResponse
|
|
5529
5832
|
}, {
|
|
5530
|
-
F:
|
|
5531
|
-
L:
|
|
5833
|
+
F: __dxlog_file22,
|
|
5834
|
+
L: 281,
|
|
5532
5835
|
S: this,
|
|
5533
5836
|
C: (f, a) => f(...a)
|
|
5534
5837
|
});
|
|
5535
5838
|
invitation.authMethod = introductionResponse.authMethod;
|
|
5536
5839
|
if (isAuthenticationRequired(invitation)) {
|
|
5537
5840
|
switch (invitation.authMethod) {
|
|
5538
|
-
case
|
|
5841
|
+
case Invitation7.AuthMethod.SHARED_SECRET:
|
|
5539
5842
|
await this._handleGuestOtpAuth(extension, (state) => guardedState.set(extension, state), otpEnteredTrigger, {
|
|
5540
5843
|
timeout
|
|
5541
5844
|
});
|
|
5542
5845
|
break;
|
|
5543
|
-
case
|
|
5846
|
+
case Invitation7.AuthMethod.KNOWN_PUBLIC_KEY:
|
|
5544
5847
|
await this._handleGuestKpkAuth(extension, (state) => guardedState.set(extension, state), invitation, introductionResponse);
|
|
5545
5848
|
break;
|
|
5546
5849
|
}
|
|
5547
5850
|
}
|
|
5548
|
-
|
|
5851
|
+
log19("request admission", {
|
|
5549
5852
|
...protocol.toJSON()
|
|
5550
5853
|
}, {
|
|
5551
|
-
F:
|
|
5552
|
-
L:
|
|
5854
|
+
F: __dxlog_file22,
|
|
5855
|
+
L: 307,
|
|
5553
5856
|
S: this,
|
|
5554
5857
|
C: (f, a) => f(...a)
|
|
5555
5858
|
});
|
|
@@ -5557,54 +5860,54 @@ var InvitationsHandler = class {
|
|
|
5557
5860
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
5558
5861
|
admitted = true;
|
|
5559
5862
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
5560
|
-
|
|
5863
|
+
log19("admitted by host", {
|
|
5561
5864
|
...protocol.toJSON()
|
|
5562
5865
|
}, {
|
|
5563
|
-
F:
|
|
5564
|
-
L:
|
|
5866
|
+
F: __dxlog_file22,
|
|
5867
|
+
L: 318,
|
|
5565
5868
|
S: this,
|
|
5566
5869
|
C: (f, a) => f(...a)
|
|
5567
5870
|
});
|
|
5568
|
-
|
|
5871
|
+
guardedState.complete({
|
|
5569
5872
|
...guardedState.current,
|
|
5570
5873
|
...result,
|
|
5571
|
-
state:
|
|
5874
|
+
state: Invitation7.State.SUCCESS
|
|
5572
5875
|
});
|
|
5573
|
-
|
|
5876
|
+
log19.trace("dxos.sdk.invitations-handler.guest.onOpen", trace7.end({
|
|
5574
5877
|
id: traceId
|
|
5575
5878
|
}), {
|
|
5576
|
-
F:
|
|
5577
|
-
L:
|
|
5879
|
+
F: __dxlog_file22,
|
|
5880
|
+
L: 324,
|
|
5578
5881
|
S: this,
|
|
5579
5882
|
C: (f, a) => f(...a)
|
|
5580
5883
|
});
|
|
5581
5884
|
} catch (err) {
|
|
5582
5885
|
if (err instanceof TimeoutError2) {
|
|
5583
|
-
|
|
5886
|
+
log19("timeout", {
|
|
5584
5887
|
...protocol.toJSON()
|
|
5585
5888
|
}, {
|
|
5586
|
-
F:
|
|
5587
|
-
L:
|
|
5889
|
+
F: __dxlog_file22,
|
|
5890
|
+
L: 327,
|
|
5588
5891
|
S: this,
|
|
5589
5892
|
C: (f, a) => f(...a)
|
|
5590
5893
|
});
|
|
5591
|
-
guardedState.set(extension,
|
|
5894
|
+
guardedState.set(extension, Invitation7.State.TIMEOUT);
|
|
5592
5895
|
} else {
|
|
5593
|
-
|
|
5594
|
-
F:
|
|
5595
|
-
L:
|
|
5896
|
+
log19("auth failed", err, {
|
|
5897
|
+
F: __dxlog_file22,
|
|
5898
|
+
L: 330,
|
|
5596
5899
|
S: this,
|
|
5597
5900
|
C: (f, a) => f(...a)
|
|
5598
5901
|
});
|
|
5599
5902
|
guardedState.error(extension, err);
|
|
5600
5903
|
}
|
|
5601
5904
|
extensionCtx.close(err);
|
|
5602
|
-
|
|
5905
|
+
log19.trace("dxos.sdk.invitations-handler.guest.onOpen", trace7.error({
|
|
5603
5906
|
id: traceId,
|
|
5604
5907
|
error: err
|
|
5605
5908
|
}), {
|
|
5606
|
-
F:
|
|
5607
|
-
L:
|
|
5909
|
+
F: __dxlog_file22,
|
|
5910
|
+
L: 334,
|
|
5608
5911
|
S: this,
|
|
5609
5912
|
C: (f, a) => f(...a)
|
|
5610
5913
|
});
|
|
@@ -5616,19 +5919,19 @@ var InvitationsHandler = class {
|
|
|
5616
5919
|
return;
|
|
5617
5920
|
}
|
|
5618
5921
|
if (err instanceof TimeoutError2) {
|
|
5619
|
-
|
|
5922
|
+
log19("timeout", {
|
|
5620
5923
|
...protocol.toJSON()
|
|
5621
5924
|
}, {
|
|
5622
|
-
F:
|
|
5623
|
-
L:
|
|
5925
|
+
F: __dxlog_file22,
|
|
5926
|
+
L: 343,
|
|
5624
5927
|
S: this,
|
|
5625
5928
|
C: (f, a) => f(...a)
|
|
5626
5929
|
});
|
|
5627
|
-
guardedState.set(extension,
|
|
5930
|
+
guardedState.set(extension, Invitation7.State.TIMEOUT);
|
|
5628
5931
|
} else {
|
|
5629
|
-
|
|
5630
|
-
F:
|
|
5631
|
-
L:
|
|
5932
|
+
log19("auth failed", err, {
|
|
5933
|
+
F: __dxlog_file22,
|
|
5934
|
+
L: 346,
|
|
5632
5935
|
S: this,
|
|
5633
5936
|
C: (f, a) => f(...a)
|
|
5634
5937
|
});
|
|
@@ -5638,15 +5941,34 @@ var InvitationsHandler = class {
|
|
|
5638
5941
|
});
|
|
5639
5942
|
return extension;
|
|
5640
5943
|
};
|
|
5641
|
-
|
|
5944
|
+
const edgeInvitationHandler = new EdgeInvitationHandler(this._connectionParams?.edgeInvitations, this._edgeClient, {
|
|
5945
|
+
onInvitationSuccess: async (admissionResponse, admissionRequest) => {
|
|
5946
|
+
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
5947
|
+
log19("admitted by edge", {
|
|
5948
|
+
...protocol.toJSON()
|
|
5949
|
+
}, {
|
|
5950
|
+
F: __dxlog_file22,
|
|
5951
|
+
L: 358,
|
|
5952
|
+
S: this,
|
|
5953
|
+
C: (f, a) => f(...a)
|
|
5954
|
+
});
|
|
5955
|
+
guardedState.complete({
|
|
5956
|
+
...guardedState.current,
|
|
5957
|
+
...result,
|
|
5958
|
+
state: Invitation7.State.SUCCESS
|
|
5959
|
+
});
|
|
5960
|
+
}
|
|
5961
|
+
});
|
|
5962
|
+
edgeInvitationHandler.handle(ctx, guardedState, protocol, deviceProfile);
|
|
5963
|
+
scheduleTask7(ctx, async () => {
|
|
5642
5964
|
const error = protocol.checkInvitation(invitation);
|
|
5643
5965
|
if (error) {
|
|
5644
5966
|
stream.error(error);
|
|
5645
5967
|
await ctx.dispose();
|
|
5646
5968
|
} else {
|
|
5647
|
-
|
|
5648
|
-
F:
|
|
5649
|
-
L:
|
|
5969
|
+
invariant15(invitation.swarmKey, void 0, {
|
|
5970
|
+
F: __dxlog_file22,
|
|
5971
|
+
L: 370,
|
|
5650
5972
|
S: this,
|
|
5651
5973
|
A: [
|
|
5652
5974
|
"invitation.swarmKey",
|
|
@@ -5655,14 +5977,14 @@ var InvitationsHandler = class {
|
|
|
5655
5977
|
});
|
|
5656
5978
|
const timeoutInactive = () => {
|
|
5657
5979
|
if (guardedState.mutex.isLocked()) {
|
|
5658
|
-
|
|
5980
|
+
scheduleTask7(ctx, timeoutInactive, timeout);
|
|
5659
5981
|
} else {
|
|
5660
|
-
guardedState.set(null,
|
|
5982
|
+
guardedState.set(null, Invitation7.State.TIMEOUT);
|
|
5661
5983
|
}
|
|
5662
5984
|
};
|
|
5663
|
-
|
|
5985
|
+
scheduleTask7(ctx, timeoutInactive, timeout);
|
|
5664
5986
|
await this._joinSwarm(ctx, invitation, InvitationOptions4.Role.GUEST, createExtension);
|
|
5665
|
-
guardedState.set(null,
|
|
5987
|
+
guardedState.set(null, Invitation7.State.CONNECTING);
|
|
5666
5988
|
}
|
|
5667
5989
|
});
|
|
5668
5990
|
}
|
|
@@ -5670,7 +5992,7 @@ var InvitationsHandler = class {
|
|
|
5670
5992
|
let label;
|
|
5671
5993
|
if (role === InvitationOptions4.Role.GUEST) {
|
|
5672
5994
|
label = "invitation guest";
|
|
5673
|
-
} else if (invitation.kind ===
|
|
5995
|
+
} else if (invitation.kind === Invitation7.Kind.DEVICE) {
|
|
5674
5996
|
label = "invitation host for device";
|
|
5675
5997
|
} else {
|
|
5676
5998
|
label = `invitation host for space ${invitation.spaceKey?.truncate()}`;
|
|
@@ -5679,123 +6001,30 @@ var InvitationsHandler = class {
|
|
|
5679
6001
|
topic: invitation.swarmKey,
|
|
5680
6002
|
protocolProvider: createTeleportProtocolFactory(async (teleport) => {
|
|
5681
6003
|
teleport.addExtension("dxos.halo.invitations", extensionFactory());
|
|
5682
|
-
}, this.
|
|
6004
|
+
}, this._connectionParams?.teleport),
|
|
5683
6005
|
topology: new InvitationTopology(role),
|
|
5684
6006
|
label
|
|
5685
6007
|
});
|
|
5686
6008
|
ctx.onDispose(() => swarmConnection.close());
|
|
5687
6009
|
return swarmConnection;
|
|
5688
6010
|
}
|
|
5689
|
-
/**
|
|
5690
|
-
* A utility object for serializing invitation state changes by multiple concurrent
|
|
5691
|
-
* invitation flow connections.
|
|
5692
|
-
*/
|
|
5693
|
-
_createGuardedState(ctx, invitation, stream) {
|
|
5694
|
-
const mutex = new Mutex3();
|
|
5695
|
-
let lastActiveExtension = null;
|
|
5696
|
-
let currentInvitation = {
|
|
5697
|
-
...invitation
|
|
5698
|
-
};
|
|
5699
|
-
const isStateChangeAllowed = (extension) => {
|
|
5700
|
-
if (ctx.disposed || extension !== null && mutex.isLocked() && !extension.hasFlowLock()) {
|
|
5701
|
-
return false;
|
|
5702
|
-
}
|
|
5703
|
-
return extension == null || lastActiveExtension !== extension || this._isNotTerminal(currentInvitation.state);
|
|
5704
|
-
};
|
|
5705
|
-
return {
|
|
5706
|
-
mutex,
|
|
5707
|
-
get current() {
|
|
5708
|
-
return currentInvitation;
|
|
5709
|
-
},
|
|
5710
|
-
// disposing context prevents any further state updates
|
|
5711
|
-
complete: (newState) => {
|
|
5712
|
-
currentInvitation = {
|
|
5713
|
-
...currentInvitation,
|
|
5714
|
-
...newState
|
|
5715
|
-
};
|
|
5716
|
-
stream.next(currentInvitation);
|
|
5717
|
-
return ctx.dispose();
|
|
5718
|
-
},
|
|
5719
|
-
set: (extension, newState) => {
|
|
5720
|
-
if (isStateChangeAllowed(extension)) {
|
|
5721
|
-
this._logStateUpdate(currentInvitation, extension, newState);
|
|
5722
|
-
currentInvitation = {
|
|
5723
|
-
...currentInvitation,
|
|
5724
|
-
state: newState
|
|
5725
|
-
};
|
|
5726
|
-
stream.next(currentInvitation);
|
|
5727
|
-
lastActiveExtension = extension;
|
|
5728
|
-
return true;
|
|
5729
|
-
}
|
|
5730
|
-
return false;
|
|
5731
|
-
},
|
|
5732
|
-
error: (extension, error) => {
|
|
5733
|
-
if (isStateChangeAllowed(extension)) {
|
|
5734
|
-
this._logStateUpdate(currentInvitation, extension, Invitation5.State.ERROR);
|
|
5735
|
-
currentInvitation = {
|
|
5736
|
-
...currentInvitation,
|
|
5737
|
-
state: Invitation5.State.ERROR
|
|
5738
|
-
};
|
|
5739
|
-
stream.next(currentInvitation);
|
|
5740
|
-
stream.error(error);
|
|
5741
|
-
lastActiveExtension = extension;
|
|
5742
|
-
return true;
|
|
5743
|
-
}
|
|
5744
|
-
return false;
|
|
5745
|
-
}
|
|
5746
|
-
};
|
|
5747
|
-
}
|
|
5748
|
-
_logStateUpdate(invitation, actor, newState) {
|
|
5749
|
-
if (this._isNotTerminal(newState)) {
|
|
5750
|
-
log17("invitation state update", {
|
|
5751
|
-
actor: actor?.constructor.name,
|
|
5752
|
-
newState: stateToString(newState),
|
|
5753
|
-
oldState: stateToString(invitation.state)
|
|
5754
|
-
}, {
|
|
5755
|
-
F: __dxlog_file20,
|
|
5756
|
-
L: 460,
|
|
5757
|
-
S: this,
|
|
5758
|
-
C: (f, a) => f(...a)
|
|
5759
|
-
});
|
|
5760
|
-
} else {
|
|
5761
|
-
log17("invitation state update", {
|
|
5762
|
-
actor: actor?.constructor.name,
|
|
5763
|
-
newState: stateToString(newState),
|
|
5764
|
-
oldState: stateToString(invitation.state)
|
|
5765
|
-
}, {
|
|
5766
|
-
F: __dxlog_file20,
|
|
5767
|
-
L: 466,
|
|
5768
|
-
S: this,
|
|
5769
|
-
C: (f, a) => f(...a)
|
|
5770
|
-
});
|
|
5771
|
-
}
|
|
5772
|
-
}
|
|
5773
|
-
_isNotTerminal(currentState) {
|
|
5774
|
-
return ![
|
|
5775
|
-
Invitation5.State.SUCCESS,
|
|
5776
|
-
Invitation5.State.ERROR,
|
|
5777
|
-
Invitation5.State.CANCELLED,
|
|
5778
|
-
Invitation5.State.TIMEOUT,
|
|
5779
|
-
Invitation5.State.EXPIRED
|
|
5780
|
-
].includes(currentState);
|
|
5781
|
-
}
|
|
5782
6011
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
5783
6012
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
5784
|
-
|
|
5785
|
-
F:
|
|
5786
|
-
L:
|
|
6013
|
+
log19("guest waiting for authentication code...", void 0, {
|
|
6014
|
+
F: __dxlog_file22,
|
|
6015
|
+
L: 422,
|
|
5787
6016
|
S: this,
|
|
5788
6017
|
C: (f, a) => f(...a)
|
|
5789
6018
|
});
|
|
5790
|
-
setState(
|
|
6019
|
+
setState(Invitation7.State.READY_FOR_AUTHENTICATION);
|
|
5791
6020
|
const authCode = await authenticated.wait(options);
|
|
5792
|
-
|
|
5793
|
-
F:
|
|
5794
|
-
L:
|
|
6021
|
+
log19("sending authentication request", void 0, {
|
|
6022
|
+
F: __dxlog_file22,
|
|
6023
|
+
L: 426,
|
|
5795
6024
|
S: this,
|
|
5796
6025
|
C: (f, a) => f(...a)
|
|
5797
6026
|
});
|
|
5798
|
-
setState(
|
|
6027
|
+
setState(Invitation7.State.AUTHENTICATING);
|
|
5799
6028
|
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
5800
6029
|
authCode
|
|
5801
6030
|
});
|
|
@@ -5806,11 +6035,11 @@ var InvitationsHandler = class {
|
|
|
5806
6035
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
5807
6036
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
5808
6037
|
} else {
|
|
5809
|
-
|
|
6038
|
+
log19("retrying invalid code", {
|
|
5810
6039
|
attempt
|
|
5811
6040
|
}, {
|
|
5812
|
-
F:
|
|
5813
|
-
L:
|
|
6041
|
+
F: __dxlog_file22,
|
|
6042
|
+
L: 437,
|
|
5814
6043
|
S: this,
|
|
5815
6044
|
C: (f, a) => f(...a)
|
|
5816
6045
|
});
|
|
@@ -5826,13 +6055,13 @@ var InvitationsHandler = class {
|
|
|
5826
6055
|
if (introductionResponse.challenge == null) {
|
|
5827
6056
|
throw new Error("challenge missing in the introduction");
|
|
5828
6057
|
}
|
|
5829
|
-
|
|
5830
|
-
F:
|
|
5831
|
-
L:
|
|
6058
|
+
log19("sending authentication request", void 0, {
|
|
6059
|
+
F: __dxlog_file22,
|
|
6060
|
+
L: 456,
|
|
5832
6061
|
S: this,
|
|
5833
6062
|
C: (f, a) => f(...a)
|
|
5834
6063
|
});
|
|
5835
|
-
setState(
|
|
6064
|
+
setState(Invitation7.State.AUTHENTICATING);
|
|
5836
6065
|
const signature = sign(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
|
|
5837
6066
|
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
5838
6067
|
signedChallenge: signature
|
|
@@ -5950,12 +6179,12 @@ var InvitationsServiceImpl = class {
|
|
|
5950
6179
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
5951
6180
|
import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
|
|
5952
6181
|
import { writeMessages as writeMessages4 } from "@dxos/feed-store";
|
|
5953
|
-
import { invariant as
|
|
5954
|
-
import { log as
|
|
6182
|
+
import { invariant as invariant16 } from "@dxos/invariant";
|
|
6183
|
+
import { log as log20 } from "@dxos/log";
|
|
5955
6184
|
import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
|
|
5956
|
-
import { Invitation as
|
|
6185
|
+
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5957
6186
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
5958
|
-
var
|
|
6187
|
+
var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
5959
6188
|
var SpaceInvitationProtocol = class {
|
|
5960
6189
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
5961
6190
|
this._spaceManager = _spaceManager;
|
|
@@ -5983,27 +6212,47 @@ var SpaceInvitationProtocol = class {
|
|
|
5983
6212
|
return void 0;
|
|
5984
6213
|
}
|
|
5985
6214
|
getInvitationContext() {
|
|
6215
|
+
invariant16(this._spaceKey, void 0, {
|
|
6216
|
+
F: __dxlog_file23,
|
|
6217
|
+
L: 63,
|
|
6218
|
+
S: this,
|
|
6219
|
+
A: [
|
|
6220
|
+
"this._spaceKey",
|
|
6221
|
+
""
|
|
6222
|
+
]
|
|
6223
|
+
});
|
|
6224
|
+
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6225
|
+
invariant16(space, void 0, {
|
|
6226
|
+
F: __dxlog_file23,
|
|
6227
|
+
L: 65,
|
|
6228
|
+
S: this,
|
|
6229
|
+
A: [
|
|
6230
|
+
"space",
|
|
6231
|
+
""
|
|
6232
|
+
]
|
|
6233
|
+
});
|
|
5986
6234
|
return {
|
|
5987
|
-
kind:
|
|
5988
|
-
spaceKey: this._spaceKey
|
|
6235
|
+
kind: Invitation8.Kind.SPACE,
|
|
6236
|
+
spaceKey: this._spaceKey,
|
|
6237
|
+
spaceId: space.id
|
|
5989
6238
|
};
|
|
5990
6239
|
}
|
|
5991
6240
|
async admit(invitation, request, guestProfile) {
|
|
5992
|
-
|
|
5993
|
-
F:
|
|
5994
|
-
L:
|
|
6241
|
+
invariant16(this._spaceKey && request.space, void 0, {
|
|
6242
|
+
F: __dxlog_file23,
|
|
6243
|
+
L: 78,
|
|
5995
6244
|
S: this,
|
|
5996
6245
|
A: [
|
|
5997
6246
|
"this._spaceKey && request.space",
|
|
5998
6247
|
""
|
|
5999
6248
|
]
|
|
6000
6249
|
});
|
|
6001
|
-
|
|
6250
|
+
log20("writing guest credentials", {
|
|
6002
6251
|
host: this._signingContext.deviceKey,
|
|
6003
6252
|
guest: request.space.deviceKey
|
|
6004
6253
|
}, {
|
|
6005
|
-
F:
|
|
6006
|
-
L:
|
|
6254
|
+
F: __dxlog_file23,
|
|
6255
|
+
L: 79,
|
|
6007
6256
|
S: this,
|
|
6008
6257
|
C: (f, a) => f(...a)
|
|
6009
6258
|
});
|
|
@@ -6023,9 +6272,9 @@ var SpaceInvitationProtocol = class {
|
|
|
6023
6272
|
};
|
|
6024
6273
|
}
|
|
6025
6274
|
async delegate(invitation) {
|
|
6026
|
-
|
|
6027
|
-
F:
|
|
6028
|
-
L:
|
|
6275
|
+
invariant16(this._spaceKey, void 0, {
|
|
6276
|
+
F: __dxlog_file23,
|
|
6277
|
+
L: 99,
|
|
6029
6278
|
S: this,
|
|
6030
6279
|
A: [
|
|
6031
6280
|
"this._spaceKey",
|
|
@@ -6033,19 +6282,19 @@ var SpaceInvitationProtocol = class {
|
|
|
6033
6282
|
]
|
|
6034
6283
|
});
|
|
6035
6284
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6036
|
-
|
|
6037
|
-
F:
|
|
6038
|
-
L:
|
|
6285
|
+
invariant16(space, void 0, {
|
|
6286
|
+
F: __dxlog_file23,
|
|
6287
|
+
L: 101,
|
|
6039
6288
|
S: this,
|
|
6040
6289
|
A: [
|
|
6041
6290
|
"space",
|
|
6042
6291
|
""
|
|
6043
6292
|
]
|
|
6044
6293
|
});
|
|
6045
|
-
if (invitation.authMethod ===
|
|
6046
|
-
|
|
6047
|
-
F:
|
|
6048
|
-
L:
|
|
6294
|
+
if (invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
6295
|
+
invariant16(invitation.guestKeypair?.publicKey, void 0, {
|
|
6296
|
+
F: __dxlog_file23,
|
|
6297
|
+
L: 103,
|
|
6049
6298
|
S: this,
|
|
6050
6299
|
A: [
|
|
6051
6300
|
"invitation.guestKeypair?.publicKey",
|
|
@@ -6053,12 +6302,12 @@ var SpaceInvitationProtocol = class {
|
|
|
6053
6302
|
]
|
|
6054
6303
|
});
|
|
6055
6304
|
}
|
|
6056
|
-
|
|
6305
|
+
log20("writing delegate space invitation", {
|
|
6057
6306
|
host: this._signingContext.deviceKey,
|
|
6058
6307
|
id: invitation.invitationId
|
|
6059
6308
|
}, {
|
|
6060
|
-
F:
|
|
6061
|
-
L:
|
|
6309
|
+
F: __dxlog_file23,
|
|
6310
|
+
L: 106,
|
|
6062
6311
|
S: this,
|
|
6063
6312
|
C: (f, a) => f(...a)
|
|
6064
6313
|
});
|
|
@@ -6069,11 +6318,11 @@ var SpaceInvitationProtocol = class {
|
|
|
6069
6318
|
role: invitation.role ?? SpaceMember6.Role.ADMIN,
|
|
6070
6319
|
expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
|
|
6071
6320
|
multiUse: invitation.multiUse ?? false,
|
|
6072
|
-
guestKey: invitation.authMethod ===
|
|
6321
|
+
guestKey: invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
6073
6322
|
});
|
|
6074
|
-
|
|
6075
|
-
F:
|
|
6076
|
-
L:
|
|
6323
|
+
invariant16(credential.credential, void 0, {
|
|
6324
|
+
F: __dxlog_file23,
|
|
6325
|
+
L: 126,
|
|
6077
6326
|
S: this,
|
|
6078
6327
|
A: [
|
|
6079
6328
|
"credential.credential",
|
|
@@ -6086,18 +6335,18 @@ var SpaceInvitationProtocol = class {
|
|
|
6086
6335
|
return credential.credential.credential.id;
|
|
6087
6336
|
}
|
|
6088
6337
|
async cancelDelegation(invitation) {
|
|
6089
|
-
|
|
6090
|
-
F:
|
|
6091
|
-
L:
|
|
6338
|
+
invariant16(this._spaceKey, void 0, {
|
|
6339
|
+
F: __dxlog_file23,
|
|
6340
|
+
L: 132,
|
|
6092
6341
|
S: this,
|
|
6093
6342
|
A: [
|
|
6094
6343
|
"this._spaceKey",
|
|
6095
6344
|
""
|
|
6096
6345
|
]
|
|
6097
6346
|
});
|
|
6098
|
-
|
|
6099
|
-
F:
|
|
6100
|
-
L:
|
|
6347
|
+
invariant16(invitation.type === Invitation8.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
6348
|
+
F: __dxlog_file23,
|
|
6349
|
+
L: 133,
|
|
6101
6350
|
S: this,
|
|
6102
6351
|
A: [
|
|
6103
6352
|
"invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
|
|
@@ -6105,28 +6354,28 @@ var SpaceInvitationProtocol = class {
|
|
|
6105
6354
|
]
|
|
6106
6355
|
});
|
|
6107
6356
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6108
|
-
|
|
6109
|
-
F:
|
|
6110
|
-
L:
|
|
6357
|
+
invariant16(space, void 0, {
|
|
6358
|
+
F: __dxlog_file23,
|
|
6359
|
+
L: 135,
|
|
6111
6360
|
S: this,
|
|
6112
6361
|
A: [
|
|
6113
6362
|
"space",
|
|
6114
6363
|
""
|
|
6115
6364
|
]
|
|
6116
6365
|
});
|
|
6117
|
-
|
|
6366
|
+
log20("cancelling delegated space invitation", {
|
|
6118
6367
|
host: this._signingContext.deviceKey,
|
|
6119
6368
|
id: invitation.invitationId
|
|
6120
6369
|
}, {
|
|
6121
|
-
F:
|
|
6122
|
-
L:
|
|
6370
|
+
F: __dxlog_file23,
|
|
6371
|
+
L: 137,
|
|
6123
6372
|
S: this,
|
|
6124
6373
|
C: (f, a) => f(...a)
|
|
6125
6374
|
});
|
|
6126
6375
|
const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
6127
|
-
|
|
6128
|
-
F:
|
|
6129
|
-
L:
|
|
6376
|
+
invariant16(credential.credential, void 0, {
|
|
6377
|
+
F: __dxlog_file23,
|
|
6378
|
+
L: 144,
|
|
6130
6379
|
S: this,
|
|
6131
6380
|
A: [
|
|
6132
6381
|
"credential.credential",
|
|
@@ -6163,9 +6412,9 @@ var SpaceInvitationProtocol = class {
|
|
|
6163
6412
|
};
|
|
6164
6413
|
}
|
|
6165
6414
|
async accept(response) {
|
|
6166
|
-
|
|
6167
|
-
F:
|
|
6168
|
-
L:
|
|
6415
|
+
invariant16(response.space, void 0, {
|
|
6416
|
+
F: __dxlog_file23,
|
|
6417
|
+
L: 179,
|
|
6169
6418
|
S: this,
|
|
6170
6419
|
A: [
|
|
6171
6420
|
"response.space",
|
|
@@ -6174,18 +6423,18 @@ var SpaceInvitationProtocol = class {
|
|
|
6174
6423
|
});
|
|
6175
6424
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
6176
6425
|
const assertion = getCredentialAssertion4(credential);
|
|
6177
|
-
|
|
6178
|
-
F:
|
|
6179
|
-
L:
|
|
6426
|
+
invariant16(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
6427
|
+
F: __dxlog_file23,
|
|
6428
|
+
L: 182,
|
|
6180
6429
|
S: this,
|
|
6181
6430
|
A: [
|
|
6182
6431
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
6183
6432
|
"'Invalid credential'"
|
|
6184
6433
|
]
|
|
6185
6434
|
});
|
|
6186
|
-
|
|
6187
|
-
F:
|
|
6188
|
-
L:
|
|
6435
|
+
invariant16(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
6436
|
+
F: __dxlog_file23,
|
|
6437
|
+
L: 183,
|
|
6189
6438
|
S: this,
|
|
6190
6439
|
A: [
|
|
6191
6440
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -6214,12 +6463,12 @@ import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvita
|
|
|
6214
6463
|
import { Context as Context8 } from "@dxos/context";
|
|
6215
6464
|
import { generatePasscode } from "@dxos/credentials";
|
|
6216
6465
|
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
6217
|
-
import { invariant as
|
|
6466
|
+
import { invariant as invariant17 } from "@dxos/invariant";
|
|
6218
6467
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
6219
|
-
import { log as
|
|
6220
|
-
import { Invitation as
|
|
6468
|
+
import { log as log21 } from "@dxos/log";
|
|
6469
|
+
import { Invitation as Invitation9 } from "@dxos/protocols/proto/dxos/client/services";
|
|
6221
6470
|
import { SpaceMember as SpaceMember7 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
6222
|
-
var
|
|
6471
|
+
var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
6223
6472
|
var InvitationsManager = class {
|
|
6224
6473
|
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
6225
6474
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -6261,8 +6510,8 @@ var InvitationsManager = class {
|
|
|
6261
6510
|
try {
|
|
6262
6511
|
await this._persistIfRequired(handler, stream, invitation);
|
|
6263
6512
|
} catch (err) {
|
|
6264
|
-
|
|
6265
|
-
F:
|
|
6513
|
+
log21.catch(err, void 0, {
|
|
6514
|
+
F: __dxlog_file24,
|
|
6266
6515
|
L: 82,
|
|
6267
6516
|
S: this,
|
|
6268
6517
|
C: (f, a) => f(...a)
|
|
@@ -6284,8 +6533,8 @@ var InvitationsManager = class {
|
|
|
6284
6533
|
const persistentInvitations = this._metadataStore.getInvitations();
|
|
6285
6534
|
const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
|
|
6286
6535
|
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
6287
|
-
|
|
6288
|
-
F:
|
|
6536
|
+
invariant17(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
6537
|
+
F: __dxlog_file24,
|
|
6289
6538
|
L: 103,
|
|
6290
6539
|
S: this,
|
|
6291
6540
|
A: [
|
|
@@ -6303,8 +6552,8 @@ var InvitationsManager = class {
|
|
|
6303
6552
|
invitations: cInvitations.map((invitation) => invitation.get())
|
|
6304
6553
|
};
|
|
6305
6554
|
} catch (err) {
|
|
6306
|
-
|
|
6307
|
-
F:
|
|
6555
|
+
log21.catch(err, void 0, {
|
|
6556
|
+
F: __dxlog_file24,
|
|
6308
6557
|
L: 110,
|
|
6309
6558
|
S: this,
|
|
6310
6559
|
C: (f, a) => f(...a)
|
|
@@ -6335,14 +6584,14 @@ var InvitationsManager = class {
|
|
|
6335
6584
|
return invitation;
|
|
6336
6585
|
}
|
|
6337
6586
|
async authenticate({ invitationId, authCode }) {
|
|
6338
|
-
|
|
6339
|
-
F:
|
|
6587
|
+
log21("authenticating...", void 0, {
|
|
6588
|
+
F: __dxlog_file24,
|
|
6340
6589
|
L: 140,
|
|
6341
6590
|
S: this,
|
|
6342
6591
|
C: (f, a) => f(...a)
|
|
6343
6592
|
});
|
|
6344
|
-
|
|
6345
|
-
F:
|
|
6593
|
+
invariant17(invitationId, void 0, {
|
|
6594
|
+
F: __dxlog_file24,
|
|
6346
6595
|
L: 141,
|
|
6347
6596
|
S: this,
|
|
6348
6597
|
A: [
|
|
@@ -6352,10 +6601,10 @@ var InvitationsManager = class {
|
|
|
6352
6601
|
});
|
|
6353
6602
|
const observable = this._acceptInvitations.get(invitationId);
|
|
6354
6603
|
if (!observable) {
|
|
6355
|
-
|
|
6604
|
+
log21.warn("invalid invitation", {
|
|
6356
6605
|
invitationId
|
|
6357
6606
|
}, {
|
|
6358
|
-
F:
|
|
6607
|
+
F: __dxlog_file24,
|
|
6359
6608
|
L: 144,
|
|
6360
6609
|
S: this,
|
|
6361
6610
|
C: (f, a) => f(...a)
|
|
@@ -6365,16 +6614,16 @@ var InvitationsManager = class {
|
|
|
6365
6614
|
}
|
|
6366
6615
|
}
|
|
6367
6616
|
async cancelInvitation({ invitationId }) {
|
|
6368
|
-
|
|
6617
|
+
log21("cancelInvitation...", {
|
|
6369
6618
|
invitationId
|
|
6370
6619
|
}, {
|
|
6371
|
-
F:
|
|
6620
|
+
F: __dxlog_file24,
|
|
6372
6621
|
L: 151,
|
|
6373
6622
|
S: this,
|
|
6374
6623
|
C: (f, a) => f(...a)
|
|
6375
6624
|
});
|
|
6376
|
-
|
|
6377
|
-
F:
|
|
6625
|
+
invariant17(invitationId, void 0, {
|
|
6626
|
+
F: __dxlog_file24,
|
|
6378
6627
|
L: 152,
|
|
6379
6628
|
S: this,
|
|
6380
6629
|
A: [
|
|
@@ -6387,7 +6636,7 @@ var InvitationsManager = class {
|
|
|
6387
6636
|
if (created.get().persistent) {
|
|
6388
6637
|
await this._metadataStore.removeInvitation(invitationId);
|
|
6389
6638
|
}
|
|
6390
|
-
if (created.get().type ===
|
|
6639
|
+
if (created.get().type === Invitation9.Type.DELEGATED) {
|
|
6391
6640
|
const handler = this._getHandler(created.get());
|
|
6392
6641
|
await handler.cancelDelegation(created.get());
|
|
6393
6642
|
}
|
|
@@ -6421,8 +6670,8 @@ var InvitationsManager = class {
|
|
|
6421
6670
|
}
|
|
6422
6671
|
}
|
|
6423
6672
|
_createInvitation(protocol, options) {
|
|
6424
|
-
const { invitationId = PublicKey12.random().toHex(), type =
|
|
6425
|
-
const authCode = options?.authCode ?? (authMethod ===
|
|
6673
|
+
const { invitationId = PublicKey12.random().toHex(), type = Invitation9.Type.INTERACTIVE, authMethod = Invitation9.AuthMethod.SHARED_SECRET, state = Invitation9.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey12.random(), persistent = options?.authMethod !== Invitation9.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = SpaceMember7.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
|
|
6674
|
+
const authCode = options?.authCode ?? (authMethod === Invitation9.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
6426
6675
|
return {
|
|
6427
6676
|
invitationId,
|
|
6428
6677
|
type,
|
|
@@ -6431,8 +6680,8 @@ var InvitationsManager = class {
|
|
|
6431
6680
|
swarmKey,
|
|
6432
6681
|
authCode,
|
|
6433
6682
|
timeout,
|
|
6434
|
-
persistent: persistent && type !==
|
|
6435
|
-
guestKeypair: guestKeypair ?? (authMethod ===
|
|
6683
|
+
persistent: persistent && type !== Invitation9.Type.DELEGATED,
|
|
6684
|
+
guestKeypair: guestKeypair ?? (authMethod === Invitation9.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
6436
6685
|
created,
|
|
6437
6686
|
lifetime,
|
|
6438
6687
|
role,
|
|
@@ -6449,14 +6698,14 @@ var InvitationsManager = class {
|
|
|
6449
6698
|
void ctx.dispose();
|
|
6450
6699
|
}
|
|
6451
6700
|
}, {
|
|
6452
|
-
F:
|
|
6701
|
+
F: __dxlog_file24,
|
|
6453
6702
|
L: 234
|
|
6454
6703
|
});
|
|
6455
6704
|
ctx.onDispose(() => {
|
|
6456
|
-
|
|
6705
|
+
log21("complete", {
|
|
6457
6706
|
...handler.toJSON()
|
|
6458
6707
|
}, {
|
|
6459
|
-
F:
|
|
6708
|
+
F: __dxlog_file24,
|
|
6460
6709
|
L: 241,
|
|
6461
6710
|
S: this,
|
|
6462
6711
|
C: (f, a) => f(...a)
|
|
@@ -6469,7 +6718,7 @@ var InvitationsManager = class {
|
|
|
6469
6718
|
onCancel: async () => {
|
|
6470
6719
|
stream.next({
|
|
6471
6720
|
...invitation,
|
|
6472
|
-
state:
|
|
6721
|
+
state: Invitation9.State.CANCELLED
|
|
6473
6722
|
});
|
|
6474
6723
|
await ctx.dispose();
|
|
6475
6724
|
}
|
|
@@ -6486,41 +6735,41 @@ var InvitationsManager = class {
|
|
|
6486
6735
|
const ctx = new Context8({
|
|
6487
6736
|
onError: (err) => {
|
|
6488
6737
|
if (err instanceof TimeoutError3) {
|
|
6489
|
-
|
|
6738
|
+
log21("timeout", {
|
|
6490
6739
|
...handler.toJSON()
|
|
6491
6740
|
}, {
|
|
6492
|
-
F:
|
|
6741
|
+
F: __dxlog_file24,
|
|
6493
6742
|
L: 261,
|
|
6494
6743
|
S: this,
|
|
6495
6744
|
C: (f, a) => f(...a)
|
|
6496
6745
|
});
|
|
6497
6746
|
stream.next({
|
|
6498
6747
|
...initialState,
|
|
6499
|
-
state:
|
|
6748
|
+
state: Invitation9.State.TIMEOUT
|
|
6500
6749
|
});
|
|
6501
6750
|
} else {
|
|
6502
|
-
|
|
6503
|
-
F:
|
|
6751
|
+
log21.warn("auth failed", err, {
|
|
6752
|
+
F: __dxlog_file24,
|
|
6504
6753
|
L: 264,
|
|
6505
6754
|
S: this,
|
|
6506
6755
|
C: (f, a) => f(...a)
|
|
6507
6756
|
});
|
|
6508
6757
|
stream.next({
|
|
6509
6758
|
...initialState,
|
|
6510
|
-
state:
|
|
6759
|
+
state: Invitation9.State.ERROR
|
|
6511
6760
|
});
|
|
6512
6761
|
}
|
|
6513
6762
|
void ctx.dispose();
|
|
6514
6763
|
}
|
|
6515
6764
|
}, {
|
|
6516
|
-
F:
|
|
6765
|
+
F: __dxlog_file24,
|
|
6517
6766
|
L: 258
|
|
6518
6767
|
});
|
|
6519
6768
|
ctx.onDispose(() => {
|
|
6520
|
-
|
|
6769
|
+
log21("complete", {
|
|
6521
6770
|
...handler.toJSON()
|
|
6522
6771
|
}, {
|
|
6523
|
-
F:
|
|
6772
|
+
F: __dxlog_file24,
|
|
6524
6773
|
L: 271,
|
|
6525
6774
|
S: this,
|
|
6526
6775
|
C: (f, a) => f(...a)
|
|
@@ -6533,7 +6782,7 @@ var InvitationsManager = class {
|
|
|
6533
6782
|
onCancel: async () => {
|
|
6534
6783
|
stream.next({
|
|
6535
6784
|
...initialState,
|
|
6536
|
-
state:
|
|
6785
|
+
state: Invitation9.State.CANCELLED
|
|
6537
6786
|
});
|
|
6538
6787
|
await ctx.dispose();
|
|
6539
6788
|
},
|
|
@@ -6549,7 +6798,7 @@ var InvitationsManager = class {
|
|
|
6549
6798
|
};
|
|
6550
6799
|
}
|
|
6551
6800
|
async _persistIfRequired(handler, changeStream, invitation) {
|
|
6552
|
-
if (invitation.type ===
|
|
6801
|
+
if (invitation.type === Invitation9.Type.DELEGATED && invitation.delegationCredentialId == null) {
|
|
6553
6802
|
const delegationCredentialId = await handler.delegate(invitation);
|
|
6554
6803
|
changeStream.next({
|
|
6555
6804
|
...invitation,
|
|
@@ -6564,8 +6813,8 @@ var InvitationsManager = class {
|
|
|
6564
6813
|
try {
|
|
6565
6814
|
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
6566
6815
|
} catch (err) {
|
|
6567
|
-
|
|
6568
|
-
F:
|
|
6816
|
+
log21.catch(err, void 0, {
|
|
6817
|
+
F: __dxlog_file24,
|
|
6569
6818
|
L: 307,
|
|
6570
6819
|
S: this,
|
|
6571
6820
|
C: (f, a) => f(...a)
|
|
@@ -6582,14 +6831,14 @@ var InvitationsManager = class {
|
|
|
6582
6831
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
6583
6832
|
import { asyncTimeout as asyncTimeout2, Trigger as Trigger8 } from "@dxos/async";
|
|
6584
6833
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
6585
|
-
import { log as
|
|
6834
|
+
import { log as log22, logInfo as logInfo3 } from "@dxos/log";
|
|
6586
6835
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
6587
6836
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6588
6837
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6589
6838
|
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;
|
|
6590
6839
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6591
6840
|
}
|
|
6592
|
-
var
|
|
6841
|
+
var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
6593
6842
|
var Message;
|
|
6594
6843
|
(function(Message2) {
|
|
6595
6844
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -6611,29 +6860,29 @@ var Lock = class {
|
|
|
6611
6860
|
message: "acquiring"
|
|
6612
6861
|
});
|
|
6613
6862
|
try {
|
|
6614
|
-
|
|
6615
|
-
F:
|
|
6863
|
+
log22("aquiring lock...", void 0, {
|
|
6864
|
+
F: __dxlog_file25,
|
|
6616
6865
|
L: 42,
|
|
6617
6866
|
S: this,
|
|
6618
6867
|
C: (f, a) => f(...a)
|
|
6619
6868
|
});
|
|
6620
6869
|
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
6621
|
-
|
|
6622
|
-
F:
|
|
6870
|
+
log22("acquired lock", void 0, {
|
|
6871
|
+
F: __dxlog_file25,
|
|
6623
6872
|
L: 44,
|
|
6624
6873
|
S: this,
|
|
6625
6874
|
C: (f, a) => f(...a)
|
|
6626
6875
|
});
|
|
6627
6876
|
} catch {
|
|
6628
|
-
|
|
6629
|
-
F:
|
|
6877
|
+
log22("stealing lock...", void 0, {
|
|
6878
|
+
F: __dxlog_file25,
|
|
6630
6879
|
L: 46,
|
|
6631
6880
|
S: this,
|
|
6632
6881
|
C: (f, a) => f(...a)
|
|
6633
6882
|
});
|
|
6634
6883
|
await this._requestLock(true);
|
|
6635
|
-
|
|
6636
|
-
F:
|
|
6884
|
+
log22("stolen lock", void 0, {
|
|
6885
|
+
F: __dxlog_file25,
|
|
6637
6886
|
L: 48,
|
|
6638
6887
|
S: this,
|
|
6639
6888
|
C: (f, a) => f(...a)
|
|
@@ -6649,10 +6898,10 @@ var Lock = class {
|
|
|
6649
6898
|
}
|
|
6650
6899
|
}
|
|
6651
6900
|
async _requestLock(steal = false) {
|
|
6652
|
-
|
|
6901
|
+
log22("requesting lock...", {
|
|
6653
6902
|
steal
|
|
6654
6903
|
}, {
|
|
6655
|
-
F:
|
|
6904
|
+
F: __dxlog_file25,
|
|
6656
6905
|
L: 63,
|
|
6657
6906
|
S: this,
|
|
6658
6907
|
C: (f, a) => f(...a)
|
|
@@ -6665,15 +6914,15 @@ var Lock = class {
|
|
|
6665
6914
|
acquired.wake();
|
|
6666
6915
|
this._releaseTrigger = new Trigger8();
|
|
6667
6916
|
await this._releaseTrigger.wait();
|
|
6668
|
-
|
|
6669
|
-
F:
|
|
6917
|
+
log22("releasing lock...", void 0, {
|
|
6918
|
+
F: __dxlog_file25,
|
|
6670
6919
|
L: 72,
|
|
6671
6920
|
S: this,
|
|
6672
6921
|
C: (f, a) => f(...a)
|
|
6673
6922
|
});
|
|
6674
6923
|
await this._onRelease?.();
|
|
6675
|
-
|
|
6676
|
-
F:
|
|
6924
|
+
log22("released lock", void 0, {
|
|
6925
|
+
F: __dxlog_file25,
|
|
6677
6926
|
L: 74,
|
|
6678
6927
|
S: this,
|
|
6679
6928
|
C: (f, a) => f(...a)
|
|
@@ -6682,10 +6931,10 @@ var Lock = class {
|
|
|
6682
6931
|
await this._onRelease?.();
|
|
6683
6932
|
});
|
|
6684
6933
|
await acquired.wait();
|
|
6685
|
-
|
|
6934
|
+
log22("recieved lock", {
|
|
6686
6935
|
steal
|
|
6687
6936
|
}, {
|
|
6688
|
-
F:
|
|
6937
|
+
F: __dxlog_file25,
|
|
6689
6938
|
L: 81,
|
|
6690
6939
|
S: this,
|
|
6691
6940
|
C: (f, a) => f(...a)
|
|
@@ -6777,19 +7026,19 @@ ClientRpcServer = _ts_decorate8([
|
|
|
6777
7026
|
], ClientRpcServer);
|
|
6778
7027
|
|
|
6779
7028
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
6780
|
-
import { Mutex as Mutex4, scheduleMicroTask as
|
|
7029
|
+
import { Mutex as Mutex4, scheduleMicroTask as scheduleMicroTask4, Trigger as Trigger9 } from "@dxos/async";
|
|
6781
7030
|
import { Context as Context9, Resource as Resource6 } from "@dxos/context";
|
|
6782
7031
|
import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
6783
7032
|
import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
|
|
6784
7033
|
import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
6785
7034
|
import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from "@dxos/edge-client";
|
|
6786
7035
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
6787
|
-
import { invariant as
|
|
7036
|
+
import { invariant as invariant18 } from "@dxos/invariant";
|
|
6788
7037
|
import { Keyring } from "@dxos/keyring";
|
|
6789
7038
|
import { PublicKey as PublicKey13 } from "@dxos/keys";
|
|
6790
|
-
import { log as
|
|
7039
|
+
import { log as log23 } from "@dxos/log";
|
|
6791
7040
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
|
|
6792
|
-
import { Invitation as
|
|
7041
|
+
import { Invitation as Invitation10 } from "@dxos/protocols/proto/dxos/client/services";
|
|
6793
7042
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
6794
7043
|
import { trace as Trace3 } from "@dxos/tracing";
|
|
6795
7044
|
import { safeInstanceof } from "@dxos/util";
|
|
@@ -6861,7 +7110,7 @@ function _using_ctx3() {
|
|
|
6861
7110
|
}
|
|
6862
7111
|
};
|
|
6863
7112
|
}
|
|
6864
|
-
var
|
|
7113
|
+
var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
6865
7114
|
var ServiceContext = class extends Resource6 {
|
|
6866
7115
|
constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
|
|
6867
7116
|
super();
|
|
@@ -6911,16 +7160,16 @@ var ServiceContext = class extends Resource6 {
|
|
|
6911
7160
|
callbacks: {
|
|
6912
7161
|
onIdentityConstruction: (identity) => {
|
|
6913
7162
|
if (this._edgeConnection) {
|
|
6914
|
-
|
|
7163
|
+
scheduleMicroTask4(this._ctx, async () => {
|
|
6915
7164
|
try {
|
|
6916
7165
|
var _usingCtx = _using_ctx3();
|
|
6917
7166
|
const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
|
|
6918
|
-
|
|
7167
|
+
log23.info("Setting identity on edge connection", {
|
|
6919
7168
|
identity: identity.identityKey.toHex(),
|
|
6920
7169
|
oldIdentity: this._edgeConnection.identityKey,
|
|
6921
7170
|
swarms: this.networkManager.topics
|
|
6922
7171
|
}, {
|
|
6923
|
-
F:
|
|
7172
|
+
F: __dxlog_file26,
|
|
6924
7173
|
L: 147,
|
|
6925
7174
|
S: this,
|
|
6926
7175
|
C: (f, a) => f(...a)
|
|
@@ -6928,8 +7177,8 @@ var ServiceContext = class extends Resource6 {
|
|
|
6928
7177
|
await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
|
|
6929
7178
|
await identity.ready();
|
|
6930
7179
|
});
|
|
6931
|
-
|
|
6932
|
-
F:
|
|
7180
|
+
invariant18(identity.deviceCredentialChain, void 0, {
|
|
7181
|
+
F: __dxlog_file26,
|
|
6933
7182
|
L: 157,
|
|
6934
7183
|
S: this,
|
|
6935
7184
|
A: [
|
|
@@ -6956,9 +7205,9 @@ var ServiceContext = class extends Resource6 {
|
|
|
6956
7205
|
kv: this.level
|
|
6957
7206
|
});
|
|
6958
7207
|
this._meshReplicator = new MeshEchoReplicator();
|
|
6959
|
-
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
7208
|
+
this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
|
|
6960
7209
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
6961
|
-
this._handlerFactories.set(
|
|
7210
|
+
this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
6962
7211
|
if (!this._runtimeParams?.disableP2pReplication) {
|
|
6963
7212
|
this._meshReplicator = new MeshEchoReplicator();
|
|
6964
7213
|
}
|
|
@@ -6970,17 +7219,17 @@ var ServiceContext = class extends Resource6 {
|
|
|
6970
7219
|
}
|
|
6971
7220
|
async _open(ctx) {
|
|
6972
7221
|
await this._checkStorageVersion();
|
|
6973
|
-
|
|
6974
|
-
F:
|
|
6975
|
-
L:
|
|
7222
|
+
log23("opening...", void 0, {
|
|
7223
|
+
F: __dxlog_file26,
|
|
7224
|
+
L: 218,
|
|
6976
7225
|
S: this,
|
|
6977
7226
|
C: (f, a) => f(...a)
|
|
6978
7227
|
});
|
|
6979
|
-
|
|
7228
|
+
log23.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
6980
7229
|
id: this._instanceId
|
|
6981
7230
|
}), {
|
|
6982
|
-
F:
|
|
6983
|
-
L:
|
|
7231
|
+
F: __dxlog_file26,
|
|
7232
|
+
L: 219,
|
|
6984
7233
|
S: this,
|
|
6985
7234
|
C: (f, a) => f(...a)
|
|
6986
7235
|
});
|
|
@@ -7004,33 +7253,33 @@ var ServiceContext = class extends Resource6 {
|
|
|
7004
7253
|
await this._initialize(ctx);
|
|
7005
7254
|
}
|
|
7006
7255
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
7007
|
-
|
|
7256
|
+
log23("loaded persistent invitations", {
|
|
7008
7257
|
count: loadedInvitations.invitations?.length
|
|
7009
7258
|
}, {
|
|
7010
|
-
F:
|
|
7011
|
-
L:
|
|
7259
|
+
F: __dxlog_file26,
|
|
7260
|
+
L: 246,
|
|
7012
7261
|
S: this,
|
|
7013
7262
|
C: (f, a) => f(...a)
|
|
7014
7263
|
});
|
|
7015
|
-
|
|
7264
|
+
log23.trace("dxos.sdk.service-context.open", trace9.end({
|
|
7016
7265
|
id: this._instanceId
|
|
7017
7266
|
}), {
|
|
7018
|
-
F:
|
|
7019
|
-
L:
|
|
7267
|
+
F: __dxlog_file26,
|
|
7268
|
+
L: 248,
|
|
7020
7269
|
S: this,
|
|
7021
7270
|
C: (f, a) => f(...a)
|
|
7022
7271
|
});
|
|
7023
|
-
|
|
7024
|
-
F:
|
|
7025
|
-
L:
|
|
7272
|
+
log23("opened", void 0, {
|
|
7273
|
+
F: __dxlog_file26,
|
|
7274
|
+
L: 249,
|
|
7026
7275
|
S: this,
|
|
7027
7276
|
C: (f, a) => f(...a)
|
|
7028
7277
|
});
|
|
7029
7278
|
}
|
|
7030
7279
|
async _close(ctx) {
|
|
7031
|
-
|
|
7032
|
-
F:
|
|
7033
|
-
L:
|
|
7280
|
+
log23("closing...", void 0, {
|
|
7281
|
+
F: __dxlog_file26,
|
|
7282
|
+
L: 253,
|
|
7034
7283
|
S: this,
|
|
7035
7284
|
C: (f, a) => f(...a)
|
|
7036
7285
|
});
|
|
@@ -7046,9 +7295,9 @@ var ServiceContext = class extends Resource6 {
|
|
|
7046
7295
|
await this.networkManager.close();
|
|
7047
7296
|
await this.signalManager.close();
|
|
7048
7297
|
await this._edgeConnection?.close();
|
|
7049
|
-
|
|
7050
|
-
F:
|
|
7051
|
-
L:
|
|
7298
|
+
log23("closed", void 0, {
|
|
7299
|
+
F: __dxlog_file26,
|
|
7300
|
+
L: 268,
|
|
7052
7301
|
S: this,
|
|
7053
7302
|
C: (f, a) => f(...a)
|
|
7054
7303
|
});
|
|
@@ -7056,16 +7305,16 @@ var ServiceContext = class extends Resource6 {
|
|
|
7056
7305
|
async createIdentity(params = {}) {
|
|
7057
7306
|
const identity = await this.identityManager.createIdentity(params);
|
|
7058
7307
|
await this._initialize(new Context9(void 0, {
|
|
7059
|
-
F:
|
|
7060
|
-
L:
|
|
7308
|
+
F: __dxlog_file26,
|
|
7309
|
+
L: 273
|
|
7061
7310
|
}));
|
|
7062
7311
|
return identity;
|
|
7063
7312
|
}
|
|
7064
7313
|
getInvitationHandler(invitation) {
|
|
7065
7314
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
7066
|
-
|
|
7067
|
-
F:
|
|
7068
|
-
L:
|
|
7315
|
+
invariant18(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
7316
|
+
F: __dxlog_file26,
|
|
7317
|
+
L: 279,
|
|
7069
7318
|
S: this,
|
|
7070
7319
|
A: [
|
|
7071
7320
|
"factory",
|
|
@@ -7085,8 +7334,8 @@ var ServiceContext = class extends Resource6 {
|
|
|
7085
7334
|
async _acceptIdentity(params) {
|
|
7086
7335
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
7087
7336
|
await this._initialize(new Context9(void 0, {
|
|
7088
|
-
F:
|
|
7089
|
-
L:
|
|
7337
|
+
F: __dxlog_file26,
|
|
7338
|
+
L: 295
|
|
7090
7339
|
}));
|
|
7091
7340
|
return identity;
|
|
7092
7341
|
}
|
|
@@ -7098,9 +7347,9 @@ var ServiceContext = class extends Resource6 {
|
|
|
7098
7347
|
}
|
|
7099
7348
|
// Called when identity is created.
|
|
7100
7349
|
async _initialize(ctx) {
|
|
7101
|
-
|
|
7102
|
-
F:
|
|
7103
|
-
L:
|
|
7350
|
+
log23("initializing spaces...", void 0, {
|
|
7351
|
+
F: __dxlog_file26,
|
|
7352
|
+
L: 310,
|
|
7104
7353
|
S: this,
|
|
7105
7354
|
C: (f, a) => f(...a)
|
|
7106
7355
|
});
|
|
@@ -7134,10 +7383,10 @@ var ServiceContext = class extends Resource6 {
|
|
|
7134
7383
|
edgeFeatures: this._edgeFeatures
|
|
7135
7384
|
});
|
|
7136
7385
|
await this.dataSpaceManager.open();
|
|
7137
|
-
this._handlerFactories.set(
|
|
7138
|
-
|
|
7139
|
-
F:
|
|
7140
|
-
L:
|
|
7386
|
+
this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
|
|
7387
|
+
invariant18(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
7388
|
+
F: __dxlog_file26,
|
|
7389
|
+
L: 340,
|
|
7141
7390
|
S: this,
|
|
7142
7391
|
A: [
|
|
7143
7392
|
"this.dataSpaceManager",
|
|
@@ -7157,33 +7406,33 @@ var ServiceContext = class extends Resource6 {
|
|
|
7157
7406
|
return;
|
|
7158
7407
|
}
|
|
7159
7408
|
if (!this.dataSpaceManager) {
|
|
7160
|
-
|
|
7409
|
+
log23("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
7161
7410
|
details: assertion
|
|
7162
7411
|
}, {
|
|
7163
|
-
F:
|
|
7164
|
-
L:
|
|
7412
|
+
F: __dxlog_file26,
|
|
7413
|
+
L: 356,
|
|
7165
7414
|
S: this,
|
|
7166
7415
|
C: (f, a) => f(...a)
|
|
7167
7416
|
});
|
|
7168
7417
|
return;
|
|
7169
7418
|
}
|
|
7170
7419
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
7171
|
-
|
|
7420
|
+
log23("space already exists, ignoring space admission", {
|
|
7172
7421
|
details: assertion
|
|
7173
7422
|
}, {
|
|
7174
|
-
F:
|
|
7175
|
-
L:
|
|
7423
|
+
F: __dxlog_file26,
|
|
7424
|
+
L: 360,
|
|
7176
7425
|
S: this,
|
|
7177
7426
|
C: (f, a) => f(...a)
|
|
7178
7427
|
});
|
|
7179
7428
|
return;
|
|
7180
7429
|
}
|
|
7181
7430
|
try {
|
|
7182
|
-
|
|
7431
|
+
log23("accepting space recorded in halo", {
|
|
7183
7432
|
details: assertion
|
|
7184
7433
|
}, {
|
|
7185
|
-
F:
|
|
7186
|
-
L:
|
|
7434
|
+
F: __dxlog_file26,
|
|
7435
|
+
L: 365,
|
|
7187
7436
|
S: this,
|
|
7188
7437
|
C: (f, a) => f(...a)
|
|
7189
7438
|
});
|
|
@@ -7192,9 +7441,9 @@ var ServiceContext = class extends Resource6 {
|
|
|
7192
7441
|
genesisFeedKey: assertion.genesisFeedKey
|
|
7193
7442
|
});
|
|
7194
7443
|
} catch (err) {
|
|
7195
|
-
|
|
7196
|
-
F:
|
|
7197
|
-
L:
|
|
7444
|
+
log23.catch(err, void 0, {
|
|
7445
|
+
F: __dxlog_file26,
|
|
7446
|
+
L: 371,
|
|
7198
7447
|
S: this,
|
|
7199
7448
|
C: (f, a) => f(...a)
|
|
7200
7449
|
});
|
|
@@ -7315,11 +7564,11 @@ var createLevel = async (config) => {
|
|
|
7315
7564
|
|
|
7316
7565
|
// packages/sdk/client-services/src/packlets/storage/profile-archive.ts
|
|
7317
7566
|
import { cbor } from "@dxos/automerge/automerge-repo";
|
|
7318
|
-
import { invariant as
|
|
7319
|
-
import { log as
|
|
7567
|
+
import { invariant as invariant19 } from "@dxos/invariant";
|
|
7568
|
+
import { log as log24 } from "@dxos/log";
|
|
7320
7569
|
import { ProfileArchiveEntryType } from "@dxos/protocols";
|
|
7321
7570
|
import { arrayToBuffer as arrayToBuffer2 } from "@dxos/util";
|
|
7322
|
-
var
|
|
7571
|
+
var __dxlog_file27 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
|
|
7323
7572
|
var encodeProfileArchive = (profile) => cbor.encode(profile);
|
|
7324
7573
|
var decodeProfileArchive = (data) => cbor.decode(data);
|
|
7325
7574
|
var exportProfileData = async ({ storage, level }) => {
|
|
@@ -7332,10 +7581,10 @@ var exportProfileData = async ({ storage, level }) => {
|
|
|
7332
7581
|
{
|
|
7333
7582
|
const directory = await storage.createDirectory();
|
|
7334
7583
|
const files = await directory.list();
|
|
7335
|
-
|
|
7584
|
+
log24.info("begin exporting files", {
|
|
7336
7585
|
count: files.length
|
|
7337
7586
|
}, {
|
|
7338
|
-
F:
|
|
7587
|
+
F: __dxlog_file27,
|
|
7339
7588
|
L: 30,
|
|
7340
7589
|
S: void 0,
|
|
7341
7590
|
C: (f, a) => f(...a)
|
|
@@ -7350,18 +7599,18 @@ var exportProfileData = async ({ storage, level }) => {
|
|
|
7350
7599
|
value: data
|
|
7351
7600
|
});
|
|
7352
7601
|
}
|
|
7353
|
-
|
|
7602
|
+
log24.info("done exporting files", {
|
|
7354
7603
|
count: files.length
|
|
7355
7604
|
}, {
|
|
7356
|
-
F:
|
|
7605
|
+
F: __dxlog_file27,
|
|
7357
7606
|
L: 41,
|
|
7358
7607
|
S: void 0,
|
|
7359
7608
|
C: (f, a) => f(...a)
|
|
7360
7609
|
});
|
|
7361
7610
|
}
|
|
7362
7611
|
{
|
|
7363
|
-
|
|
7364
|
-
F:
|
|
7612
|
+
log24.info("begin exporting kv pairs", void 0, {
|
|
7613
|
+
F: __dxlog_file27,
|
|
7365
7614
|
L: 45,
|
|
7366
7615
|
S: void 0,
|
|
7367
7616
|
C: (f, a) => f(...a)
|
|
@@ -7379,10 +7628,10 @@ var exportProfileData = async ({ storage, level }) => {
|
|
|
7379
7628
|
});
|
|
7380
7629
|
count++;
|
|
7381
7630
|
}
|
|
7382
|
-
|
|
7631
|
+
log24.info("done exporting kv pairs", {
|
|
7383
7632
|
count
|
|
7384
7633
|
}, {
|
|
7385
|
-
F:
|
|
7634
|
+
F: __dxlog_file27,
|
|
7386
7635
|
L: 56,
|
|
7387
7636
|
S: void 0,
|
|
7388
7637
|
C: (f, a) => f(...a)
|
|
@@ -7397,8 +7646,8 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
7397
7646
|
switch (entry2.type) {
|
|
7398
7647
|
case ProfileArchiveEntryType.FILE: {
|
|
7399
7648
|
const directory = await storage.createDirectory();
|
|
7400
|
-
|
|
7401
|
-
F:
|
|
7649
|
+
invariant19(typeof entry2.key === "string", "Invalid key type", {
|
|
7650
|
+
F: __dxlog_file27,
|
|
7402
7651
|
L: 79,
|
|
7403
7652
|
S: void 0,
|
|
7404
7653
|
A: [
|
|
@@ -7407,8 +7656,8 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
7407
7656
|
]
|
|
7408
7657
|
});
|
|
7409
7658
|
const file = await directory.getOrCreateFile(entry2.key);
|
|
7410
|
-
|
|
7411
|
-
F:
|
|
7659
|
+
invariant19(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
7660
|
+
F: __dxlog_file27,
|
|
7412
7661
|
L: 81,
|
|
7413
7662
|
S: void 0,
|
|
7414
7663
|
A: [
|
|
@@ -7421,8 +7670,8 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
7421
7670
|
break;
|
|
7422
7671
|
}
|
|
7423
7672
|
case ProfileArchiveEntryType.KEY_VALUE: {
|
|
7424
|
-
|
|
7425
|
-
F:
|
|
7673
|
+
invariant19(entry2.key instanceof Uint8Array, "Invalid key type", {
|
|
7674
|
+
F: __dxlog_file27,
|
|
7426
7675
|
L: 87,
|
|
7427
7676
|
S: void 0,
|
|
7428
7677
|
A: [
|
|
@@ -7430,8 +7679,8 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
7430
7679
|
"'Invalid key type'"
|
|
7431
7680
|
]
|
|
7432
7681
|
});
|
|
7433
|
-
|
|
7434
|
-
F:
|
|
7682
|
+
invariant19(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
7683
|
+
F: __dxlog_file27,
|
|
7435
7684
|
L: 88,
|
|
7436
7685
|
S: void 0,
|
|
7437
7686
|
A: [
|
|
@@ -7451,20 +7700,20 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
7451
7700
|
if (++count % 1e3 === 0) {
|
|
7452
7701
|
await batch.write();
|
|
7453
7702
|
batch = level.batch();
|
|
7454
|
-
|
|
7703
|
+
log24.info("importing", {
|
|
7455
7704
|
count,
|
|
7456
7705
|
total: archive.storage.length,
|
|
7457
7706
|
progress: `${(count / archive.storage.length * 100).toFixed()}%`
|
|
7458
7707
|
}, {
|
|
7459
|
-
F:
|
|
7708
|
+
F: __dxlog_file27,
|
|
7460
7709
|
L: 101,
|
|
7461
7710
|
S: void 0,
|
|
7462
7711
|
C: (f, a) => f(...a)
|
|
7463
7712
|
});
|
|
7464
7713
|
}
|
|
7465
7714
|
}
|
|
7466
|
-
|
|
7467
|
-
F:
|
|
7715
|
+
log24.info("committing changes..", void 0, {
|
|
7716
|
+
F: __dxlog_file27,
|
|
7468
7717
|
L: 109,
|
|
7469
7718
|
S: void 0,
|
|
7470
7719
|
C: (f, a) => f(...a)
|
|
@@ -7477,9 +7726,9 @@ import { Event as Event10, synchronized as synchronized3 } from "@dxos/async";
|
|
|
7477
7726
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
7478
7727
|
import { Context as Context10 } from "@dxos/context";
|
|
7479
7728
|
import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity } from "@dxos/edge-client";
|
|
7480
|
-
import { invariant as
|
|
7729
|
+
import { invariant as invariant21 } from "@dxos/invariant";
|
|
7481
7730
|
import { PublicKey as PublicKey17 } from "@dxos/keys";
|
|
7482
|
-
import { log as
|
|
7731
|
+
import { log as log26 } from "@dxos/log";
|
|
7483
7732
|
import { EdgeSignalManager, WebsocketSignalManager } from "@dxos/messaging";
|
|
7484
7733
|
import { SwarmNetworkManager, createIceProvider, createRtcTransportFactory } from "@dxos/network-manager";
|
|
7485
7734
|
import { trace as trace10 } from "@dxos/protocols";
|
|
@@ -7490,9 +7739,9 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
|
7490
7739
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
7491
7740
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
7492
7741
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
7493
|
-
import { invariant as
|
|
7742
|
+
import { invariant as invariant20 } from "@dxos/invariant";
|
|
7494
7743
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
7495
|
-
var
|
|
7744
|
+
var __dxlog_file28 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
7496
7745
|
var DevicesServiceImpl = class {
|
|
7497
7746
|
constructor(_identityManager) {
|
|
7498
7747
|
this._identityManager = _identityManager;
|
|
@@ -7509,8 +7758,8 @@ var DevicesServiceImpl = class {
|
|
|
7509
7758
|
devices: []
|
|
7510
7759
|
});
|
|
7511
7760
|
} else {
|
|
7512
|
-
|
|
7513
|
-
F:
|
|
7761
|
+
invariant20(this._identityManager.identity?.presence, "presence not present", {
|
|
7762
|
+
F: __dxlog_file28,
|
|
7514
7763
|
L: 32,
|
|
7515
7764
|
S: this,
|
|
7516
7765
|
A: [
|
|
@@ -7570,7 +7819,7 @@ var DevicesServiceImpl = class {
|
|
|
7570
7819
|
};
|
|
7571
7820
|
|
|
7572
7821
|
// packages/sdk/client-services/src/packlets/identity/contacts-service.ts
|
|
7573
|
-
import { EventSubscriptions as EventSubscriptions4, scheduleTask as
|
|
7822
|
+
import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask8, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
|
|
7574
7823
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
7575
7824
|
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
7576
7825
|
import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
|
|
@@ -7629,7 +7878,7 @@ var ContactsServiceImpl = class {
|
|
|
7629
7878
|
}, {
|
|
7630
7879
|
maxFrequency: 2
|
|
7631
7880
|
});
|
|
7632
|
-
|
|
7881
|
+
scheduleTask8(ctx, async () => {
|
|
7633
7882
|
const subscriptions = new EventSubscriptions4();
|
|
7634
7883
|
ctx.onDispose(() => subscriptions.clear());
|
|
7635
7884
|
const subscribeToSpaceAndUpdate = () => {
|
|
@@ -7656,7 +7905,7 @@ var ContactsServiceImpl = class {
|
|
|
7656
7905
|
import { Event as Event9 } from "@dxos/async";
|
|
7657
7906
|
import { Stream as Stream13 } from "@dxos/codec-protobuf";
|
|
7658
7907
|
import { PublicKey as PublicKey16 } from "@dxos/keys";
|
|
7659
|
-
import { getContextFromEntry, log as
|
|
7908
|
+
import { getContextFromEntry, log as log25 } from "@dxos/log";
|
|
7660
7909
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
7661
7910
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
7662
7911
|
var LoggingServiceImpl = class {
|
|
@@ -7669,11 +7918,11 @@ var LoggingServiceImpl = class {
|
|
|
7669
7918
|
};
|
|
7670
7919
|
}
|
|
7671
7920
|
async open() {
|
|
7672
|
-
|
|
7921
|
+
log25.runtimeConfig.processors.push(this._logProcessor);
|
|
7673
7922
|
}
|
|
7674
7923
|
async close() {
|
|
7675
|
-
const index =
|
|
7676
|
-
|
|
7924
|
+
const index = log25.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
7925
|
+
log25.runtimeConfig.processors.splice(index, 1);
|
|
7677
7926
|
}
|
|
7678
7927
|
async controlMetrics({ reset, record }) {
|
|
7679
7928
|
if (reset) {
|
|
@@ -7873,7 +8122,7 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
7873
8122
|
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;
|
|
7874
8123
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7875
8124
|
}
|
|
7876
|
-
var
|
|
8125
|
+
var __dxlog_file29 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
7877
8126
|
var ClientServicesHost = class {
|
|
7878
8127
|
constructor({
|
|
7879
8128
|
config,
|
|
@@ -7912,7 +8161,7 @@ var ClientServicesHost = class {
|
|
|
7912
8161
|
onAcquire: () => {
|
|
7913
8162
|
if (!this._opening) {
|
|
7914
8163
|
void this.open(new Context10(void 0, {
|
|
7915
|
-
F:
|
|
8164
|
+
F: __dxlog_file29,
|
|
7916
8165
|
L: 133
|
|
7917
8166
|
}));
|
|
7918
8167
|
}
|
|
@@ -7969,8 +8218,8 @@ var ClientServicesHost = class {
|
|
|
7969
8218
|
* Can only be called once.
|
|
7970
8219
|
*/
|
|
7971
8220
|
initialize({ config, ...options }) {
|
|
7972
|
-
|
|
7973
|
-
F:
|
|
8221
|
+
invariant21(!this._open, "service host is open", {
|
|
8222
|
+
F: __dxlog_file29,
|
|
7974
8223
|
L: 199,
|
|
7975
8224
|
S: this,
|
|
7976
8225
|
A: [
|
|
@@ -7978,15 +8227,15 @@ var ClientServicesHost = class {
|
|
|
7978
8227
|
"'service host is open'"
|
|
7979
8228
|
]
|
|
7980
8229
|
});
|
|
7981
|
-
|
|
7982
|
-
F:
|
|
8230
|
+
log26("initializing...", void 0, {
|
|
8231
|
+
F: __dxlog_file29,
|
|
7983
8232
|
L: 200,
|
|
7984
8233
|
S: this,
|
|
7985
8234
|
C: (f, a) => f(...a)
|
|
7986
8235
|
});
|
|
7987
8236
|
if (config) {
|
|
7988
|
-
|
|
7989
|
-
F:
|
|
8237
|
+
invariant21(!this._config, "config already set", {
|
|
8238
|
+
F: __dxlog_file29,
|
|
7990
8239
|
L: 203,
|
|
7991
8240
|
S: this,
|
|
7992
8241
|
A: [
|
|
@@ -8000,8 +8249,8 @@ var ClientServicesHost = class {
|
|
|
8000
8249
|
}
|
|
8001
8250
|
}
|
|
8002
8251
|
if (!options.signalManager) {
|
|
8003
|
-
|
|
8004
|
-
F:
|
|
8252
|
+
log26.warn("running signaling without telemetry metadata.", void 0, {
|
|
8253
|
+
F: __dxlog_file29,
|
|
8005
8254
|
L: 211,
|
|
8006
8255
|
S: this,
|
|
8007
8256
|
C: (f, a) => f(...a)
|
|
@@ -8020,8 +8269,8 @@ var ClientServicesHost = class {
|
|
|
8020
8269
|
edgeConnection: this._edgeConnection
|
|
8021
8270
|
}) : new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
8022
8271
|
this._signalManager = signalManager;
|
|
8023
|
-
|
|
8024
|
-
F:
|
|
8272
|
+
invariant21(!this._networkManager, "network manager already set", {
|
|
8273
|
+
F: __dxlog_file29,
|
|
8025
8274
|
L: 233,
|
|
8026
8275
|
S: this,
|
|
8027
8276
|
A: [
|
|
@@ -8038,8 +8287,8 @@ var ClientServicesHost = class {
|
|
|
8038
8287
|
peerKey: this._edgeConnection.peerKey
|
|
8039
8288
|
} : void 0
|
|
8040
8289
|
});
|
|
8041
|
-
|
|
8042
|
-
F:
|
|
8290
|
+
log26("initialized", void 0, {
|
|
8291
|
+
F: __dxlog_file29,
|
|
8043
8292
|
L: 246,
|
|
8044
8293
|
S: this,
|
|
8045
8294
|
C: (f, a) => f(...a)
|
|
@@ -8050,16 +8299,16 @@ var ClientServicesHost = class {
|
|
|
8050
8299
|
return;
|
|
8051
8300
|
}
|
|
8052
8301
|
const traceId = PublicKey17.random().toHex();
|
|
8053
|
-
|
|
8302
|
+
log26.trace("dxos.client-services.host.open", trace10.begin({
|
|
8054
8303
|
id: traceId
|
|
8055
8304
|
}), {
|
|
8056
|
-
F:
|
|
8305
|
+
F: __dxlog_file29,
|
|
8057
8306
|
L: 257,
|
|
8058
8307
|
S: this,
|
|
8059
8308
|
C: (f, a) => f(...a)
|
|
8060
8309
|
});
|
|
8061
|
-
|
|
8062
|
-
F:
|
|
8310
|
+
invariant21(this._config, "config not set", {
|
|
8311
|
+
F: __dxlog_file29,
|
|
8063
8312
|
L: 259,
|
|
8064
8313
|
S: this,
|
|
8065
8314
|
A: [
|
|
@@ -8067,8 +8316,8 @@ var ClientServicesHost = class {
|
|
|
8067
8316
|
"'config not set'"
|
|
8068
8317
|
]
|
|
8069
8318
|
});
|
|
8070
|
-
|
|
8071
|
-
F:
|
|
8319
|
+
invariant21(this._storage, "storage not set", {
|
|
8320
|
+
F: __dxlog_file29,
|
|
8072
8321
|
L: 260,
|
|
8073
8322
|
S: this,
|
|
8074
8323
|
A: [
|
|
@@ -8076,8 +8325,8 @@ var ClientServicesHost = class {
|
|
|
8076
8325
|
"'storage not set'"
|
|
8077
8326
|
]
|
|
8078
8327
|
});
|
|
8079
|
-
|
|
8080
|
-
F:
|
|
8328
|
+
invariant21(this._signalManager, "signal manager not set", {
|
|
8329
|
+
F: __dxlog_file29,
|
|
8081
8330
|
L: 261,
|
|
8082
8331
|
S: this,
|
|
8083
8332
|
A: [
|
|
@@ -8085,8 +8334,8 @@ var ClientServicesHost = class {
|
|
|
8085
8334
|
"'signal manager not set'"
|
|
8086
8335
|
]
|
|
8087
8336
|
});
|
|
8088
|
-
|
|
8089
|
-
F:
|
|
8337
|
+
invariant21(this._networkManager, "network manager not set", {
|
|
8338
|
+
F: __dxlog_file29,
|
|
8090
8339
|
L: 262,
|
|
8091
8340
|
S: this,
|
|
8092
8341
|
A: [
|
|
@@ -8095,10 +8344,10 @@ var ClientServicesHost = class {
|
|
|
8095
8344
|
]
|
|
8096
8345
|
});
|
|
8097
8346
|
this._opening = true;
|
|
8098
|
-
|
|
8347
|
+
log26("opening...", {
|
|
8099
8348
|
lockKey: this._resourceLock?.lockKey
|
|
8100
8349
|
}, {
|
|
8101
|
-
F:
|
|
8350
|
+
F: __dxlog_file29,
|
|
8102
8351
|
L: 265,
|
|
8103
8352
|
S: this,
|
|
8104
8353
|
C: (f, a) => f(...a)
|
|
@@ -8151,18 +8400,18 @@ var ClientServicesHost = class {
|
|
|
8151
8400
|
this._open = true;
|
|
8152
8401
|
this._statusUpdate.emit();
|
|
8153
8402
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
8154
|
-
|
|
8403
|
+
log26("opened", {
|
|
8155
8404
|
deviceKey
|
|
8156
8405
|
}, {
|
|
8157
|
-
F:
|
|
8406
|
+
F: __dxlog_file29,
|
|
8158
8407
|
L: 354,
|
|
8159
8408
|
S: this,
|
|
8160
8409
|
C: (f, a) => f(...a)
|
|
8161
8410
|
});
|
|
8162
|
-
|
|
8411
|
+
log26.trace("dxos.client-services.host.open", trace10.end({
|
|
8163
8412
|
id: traceId
|
|
8164
8413
|
}), {
|
|
8165
|
-
F:
|
|
8414
|
+
F: __dxlog_file29,
|
|
8166
8415
|
L: 355,
|
|
8167
8416
|
S: this,
|
|
8168
8417
|
C: (f, a) => f(...a)
|
|
@@ -8173,10 +8422,10 @@ var ClientServicesHost = class {
|
|
|
8173
8422
|
return;
|
|
8174
8423
|
}
|
|
8175
8424
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
8176
|
-
|
|
8425
|
+
log26("closing...", {
|
|
8177
8426
|
deviceKey
|
|
8178
8427
|
}, {
|
|
8179
|
-
F:
|
|
8428
|
+
F: __dxlog_file29,
|
|
8180
8429
|
L: 366,
|
|
8181
8430
|
S: this,
|
|
8182
8431
|
C: (f, a) => f(...a)
|
|
@@ -8191,10 +8440,10 @@ var ClientServicesHost = class {
|
|
|
8191
8440
|
await this._level?.close();
|
|
8192
8441
|
this._open = false;
|
|
8193
8442
|
this._statusUpdate.emit();
|
|
8194
|
-
|
|
8443
|
+
log26("closed", {
|
|
8195
8444
|
deviceKey
|
|
8196
8445
|
}, {
|
|
8197
|
-
F:
|
|
8446
|
+
F: __dxlog_file29,
|
|
8198
8447
|
L: 375,
|
|
8199
8448
|
S: this,
|
|
8200
8449
|
C: (f, a) => f(...a)
|
|
@@ -8202,32 +8451,32 @@ var ClientServicesHost = class {
|
|
|
8202
8451
|
}
|
|
8203
8452
|
async reset() {
|
|
8204
8453
|
const traceId = PublicKey17.random().toHex();
|
|
8205
|
-
|
|
8454
|
+
log26.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
8206
8455
|
id: traceId
|
|
8207
8456
|
}), {
|
|
8208
|
-
F:
|
|
8457
|
+
F: __dxlog_file29,
|
|
8209
8458
|
L: 380,
|
|
8210
8459
|
S: this,
|
|
8211
8460
|
C: (f, a) => f(...a)
|
|
8212
8461
|
});
|
|
8213
|
-
|
|
8214
|
-
F:
|
|
8462
|
+
log26.info("resetting...", void 0, {
|
|
8463
|
+
F: __dxlog_file29,
|
|
8215
8464
|
L: 382,
|
|
8216
8465
|
S: this,
|
|
8217
8466
|
C: (f, a) => f(...a)
|
|
8218
8467
|
});
|
|
8219
8468
|
await this._serviceContext?.close();
|
|
8220
8469
|
await this._storage.reset();
|
|
8221
|
-
|
|
8222
|
-
F:
|
|
8470
|
+
log26.info("reset", void 0, {
|
|
8471
|
+
F: __dxlog_file29,
|
|
8223
8472
|
L: 385,
|
|
8224
8473
|
S: this,
|
|
8225
8474
|
C: (f, a) => f(...a)
|
|
8226
8475
|
});
|
|
8227
|
-
|
|
8476
|
+
log26.trace("dxos.sdk.client-services-host.reset", trace10.end({
|
|
8228
8477
|
id: traceId
|
|
8229
8478
|
}), {
|
|
8230
|
-
F:
|
|
8479
|
+
F: __dxlog_file29,
|
|
8231
8480
|
L: 386,
|
|
8232
8481
|
S: this,
|
|
8233
8482
|
C: (f, a) => f(...a)
|
|
@@ -8302,4 +8551,4 @@ export {
|
|
|
8302
8551
|
importProfileData,
|
|
8303
8552
|
ClientServicesHost
|
|
8304
8553
|
};
|
|
8305
|
-
//# sourceMappingURL=chunk-
|
|
8554
|
+
//# sourceMappingURL=chunk-UEQIHAL2.mjs.map
|