@dxos/client-services 0.1.18 → 0.1.19
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/index.mjs +460 -314
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +498 -352
- package/dist/lib/node/index.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/packlets/deprecated/space.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +21 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +3 -9
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +5 -4
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/halo-invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts +6 -4
- package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitations-service.d.ts +5 -4
- package/dist/types/src/packlets/invitations/space-invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +3 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +28 -0
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts +23 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -0
- package/package.json +28 -27
- package/src/packlets/deprecated/space.ts +16 -8
- package/src/packlets/devtools/spaces.ts +1 -1
- package/src/packlets/identity/authenticator.test.ts +8 -3
- package/src/packlets/identity/authenticator.ts +68 -24
- package/src/packlets/identity/identity-manager.test.ts +11 -9
- package/src/packlets/identity/identity-manager.ts +33 -46
- package/src/packlets/identity/identity.test.ts +40 -17
- package/src/packlets/identity/identity.ts +26 -16
- package/src/packlets/invitations/halo-invitations-handler.ts +1 -2
- package/src/packlets/invitations/space-invitations-handler.test.ts +7 -7
- package/src/packlets/invitations/space-invitations-handler.ts +9 -8
- package/src/packlets/invitations/space-invitations-service.test.ts +10 -10
- package/src/packlets/invitations/space-invitations-service.ts +6 -5
- package/src/packlets/services/service-context.ts +21 -21
- package/src/packlets/services/service-host.ts +1 -1
- package/src/packlets/services/service-registry.test.ts +3 -3
- package/src/packlets/spaces/data-space-manager.ts +118 -0
- package/src/packlets/spaces/data-space.ts +66 -0
- package/dist/types/src/packlets/invitations/rpc-extension.d.ts +0 -17
- package/dist/types/src/packlets/invitations/rpc-extension.d.ts.map +0 -1
- package/src/packlets/invitations/rpc-extension.ts +0 -56
package/dist/lib/node/index.cjs
CHANGED
|
@@ -35,6 +35,7 @@ __export(src_exports, {
|
|
|
35
35
|
ClientServicesProxy: () => ClientServicesProxy,
|
|
36
36
|
DevtoolsHostEvents: () => DevtoolsHostEvents,
|
|
37
37
|
DevtoolsServiceImpl: () => DevtoolsServiceImpl,
|
|
38
|
+
HaloAuthVerifier: () => HaloAuthVerifier,
|
|
38
39
|
HaloInvitationsHandler: () => HaloInvitationsHandler,
|
|
39
40
|
HaloInvitationsProxy: () => HaloInvitationsProxy,
|
|
40
41
|
HaloInvitationsServiceImpl: () => HaloInvitationsServiceImpl,
|
|
@@ -59,7 +60,6 @@ __export(src_exports, {
|
|
|
59
60
|
clientServiceBundle: () => clientServiceBundle,
|
|
60
61
|
createDefaultModelFactory: () => createDefaultModelFactory,
|
|
61
62
|
createHaloAuthProvider: () => createHaloAuthProvider,
|
|
62
|
-
createHaloAuthVerifier: () => createHaloAuthVerifier,
|
|
63
63
|
createStorageObjects: () => createStorageObjects,
|
|
64
64
|
getNetworkPeers: () => getNetworkPeers,
|
|
65
65
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
@@ -79,6 +79,7 @@ var import_async = require("@dxos/async");
|
|
|
79
79
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
80
80
|
var import_debug = require("@dxos/debug");
|
|
81
81
|
var import_log = require("@dxos/log");
|
|
82
|
+
var import_client = require("@dxos/protocols/proto/dxos/client");
|
|
82
83
|
var import_util = require("@dxos/util");
|
|
83
84
|
var SpaceServiceImpl = class {
|
|
84
85
|
constructor(serviceContext) {
|
|
@@ -101,26 +102,27 @@ var SpaceServiceImpl = class {
|
|
|
101
102
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
102
103
|
const subscriptions = new import_async.EventSubscriptions();
|
|
103
104
|
const onUpdate = () => {
|
|
104
|
-
const spaces = Array.from(this.serviceContext.
|
|
105
|
+
const spaces = Array.from(this.serviceContext.dataSpaceManager.spaces.values()).map((space) => ({
|
|
105
106
|
publicKey: space.key,
|
|
106
107
|
isOpen: true,
|
|
107
108
|
isActive: true,
|
|
108
|
-
members: Array.from(space.spaceState.members.values()).map((member) => {
|
|
109
|
-
var _a, _b;
|
|
109
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
110
|
+
var _a, _b, _c;
|
|
110
111
|
return {
|
|
111
112
|
identityKey: member.key,
|
|
112
113
|
profile: {
|
|
113
114
|
identityKey: member.key,
|
|
114
115
|
displayName: (_b = (_a = member.assertion.profile) == null ? void 0 : _a.displayName) != null ? _b : (0, import_util.humanize)(member.key)
|
|
115
|
-
}
|
|
116
|
+
},
|
|
117
|
+
presenceState: ((_c = this.serviceContext.identityManager.identity) == null ? void 0 : _c.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_client.SpaceMember.PresenceState.ONLINE : import_client.SpaceMember.PresenceState.OFFLINE
|
|
116
118
|
};
|
|
117
119
|
})
|
|
118
120
|
}));
|
|
119
121
|
(0, import_log.log)("update", {
|
|
120
122
|
spaces
|
|
121
123
|
}, {
|
|
122
|
-
file: "
|
|
123
|
-
line:
|
|
124
|
+
file: "space.ts",
|
|
125
|
+
line: 120,
|
|
124
126
|
scope: this,
|
|
125
127
|
callSite: (f, a) => f(...a)
|
|
126
128
|
});
|
|
@@ -129,20 +131,22 @@ var SpaceServiceImpl = class {
|
|
|
129
131
|
});
|
|
130
132
|
};
|
|
131
133
|
setTimeout(async () => {
|
|
132
|
-
if (!this.serviceContext.
|
|
134
|
+
if (!this.serviceContext.dataSpaceManager) {
|
|
133
135
|
next({
|
|
134
136
|
spaces: []
|
|
135
137
|
});
|
|
136
138
|
}
|
|
137
139
|
await this.serviceContext.initialized.wait();
|
|
138
|
-
subscriptions.add(this.serviceContext.
|
|
139
|
-
this.serviceContext.
|
|
140
|
+
subscriptions.add(this.serviceContext.dataSpaceManager.updated.on(() => {
|
|
141
|
+
this.serviceContext.dataSpaceManager.spaces.forEach((space) => {
|
|
140
142
|
subscriptions.add(space.stateUpdate.on(onUpdate));
|
|
143
|
+
subscriptions.add(space.presence.updated.on(onUpdate));
|
|
141
144
|
});
|
|
142
145
|
onUpdate();
|
|
143
146
|
}));
|
|
144
|
-
this.serviceContext.
|
|
147
|
+
this.serviceContext.dataSpaceManager.spaces.forEach((space) => {
|
|
145
148
|
subscriptions.add(space.stateUpdate.on(onUpdate));
|
|
149
|
+
subscriptions.add(space.presence.updated.on(onUpdate));
|
|
146
150
|
});
|
|
147
151
|
onUpdate();
|
|
148
152
|
});
|
|
@@ -154,7 +158,7 @@ var SpaceServiceImpl = class {
|
|
|
154
158
|
}
|
|
155
159
|
async createSpace() {
|
|
156
160
|
await this.serviceContext.initialized.wait();
|
|
157
|
-
const space = await this.serviceContext.
|
|
161
|
+
const space = await this.serviceContext.dataSpaceManager.createSpace();
|
|
158
162
|
return {
|
|
159
163
|
publicKey: space.key,
|
|
160
164
|
isOpen: true,
|
|
@@ -451,7 +455,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => new import_codec_protob
|
|
|
451
455
|
};
|
|
452
456
|
const timeout = setTimeout(async () => {
|
|
453
457
|
await context.initialized.wait();
|
|
454
|
-
unsubscribe = context.
|
|
458
|
+
unsubscribe = context.dataSpaceManager.updated.on(() => update());
|
|
455
459
|
await update();
|
|
456
460
|
});
|
|
457
461
|
return () => {
|
|
@@ -548,6 +552,8 @@ var DevtoolsServiceImpl = class {
|
|
|
548
552
|
};
|
|
549
553
|
|
|
550
554
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
555
|
+
var import_async4 = require("@dxos/async");
|
|
556
|
+
var import_context = require("@dxos/context");
|
|
551
557
|
var import_credentials = require("@dxos/credentials");
|
|
552
558
|
var import_log2 = require("@dxos/log");
|
|
553
559
|
var import_protocols = require("@dxos/protocols");
|
|
@@ -561,76 +567,108 @@ var createHaloAuthProvider = (signer) => async (nonce) => {
|
|
|
561
567
|
});
|
|
562
568
|
return import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential").encode(credential);
|
|
563
569
|
};
|
|
564
|
-
var
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (result.kind === "fail") {
|
|
569
|
-
(0, import_log2.log)("Invalid credential", {
|
|
570
|
-
result
|
|
571
|
-
}, {
|
|
572
|
-
file: "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts",
|
|
573
|
-
line: 34,
|
|
574
|
-
scope: void 0,
|
|
575
|
-
callSite: (f, a) => f(...a)
|
|
576
|
-
});
|
|
577
|
-
return false;
|
|
578
|
-
}
|
|
579
|
-
if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
|
|
580
|
-
(0, import_log2.log)("Invalid nonce", {
|
|
581
|
-
nonce,
|
|
582
|
-
credential
|
|
583
|
-
}, {
|
|
584
|
-
file: "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts",
|
|
585
|
-
line: 39,
|
|
586
|
-
scope: void 0,
|
|
587
|
-
callSite: (f, a) => f(...a)
|
|
588
|
-
});
|
|
589
|
-
return false;
|
|
570
|
+
var HaloAuthVerifier = class {
|
|
571
|
+
constructor(_params) {
|
|
572
|
+
this._params = _params;
|
|
573
|
+
this._ctx = new import_context.Context();
|
|
590
574
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
575
|
+
async close() {
|
|
576
|
+
await this._ctx.dispose();
|
|
577
|
+
}
|
|
578
|
+
_isTrustedDevice(deviceKey) {
|
|
579
|
+
const deviceSet = this._params.trustedDevicesProvider();
|
|
580
|
+
return deviceSet.has(deviceKey);
|
|
581
|
+
}
|
|
582
|
+
get verifier() {
|
|
583
|
+
return async (nonce, auth) => {
|
|
584
|
+
const credential = import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential").decode(auth);
|
|
585
|
+
const result = await (0, import_credentials.verifyCredential)(credential);
|
|
586
|
+
if (result.kind === "fail") {
|
|
587
|
+
(0, import_log2.log)("Invalid credential", {
|
|
588
|
+
result
|
|
589
|
+
}, {
|
|
590
|
+
file: "authenticator.ts",
|
|
591
|
+
line: 61,
|
|
592
|
+
scope: this,
|
|
593
|
+
callSite: (f, a) => f(...a)
|
|
594
|
+
});
|
|
595
|
+
return false;
|
|
596
|
+
}
|
|
597
|
+
if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
|
|
598
|
+
(0, import_log2.log)("Invalid nonce", {
|
|
599
|
+
nonce,
|
|
600
|
+
credential
|
|
601
|
+
}, {
|
|
602
|
+
file: "authenticator.ts",
|
|
603
|
+
line: 66,
|
|
604
|
+
scope: this,
|
|
605
|
+
callSite: (f, a) => f(...a)
|
|
606
|
+
});
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
if (this._isTrustedDevice(credential.issuer)) {
|
|
610
|
+
return true;
|
|
611
|
+
}
|
|
612
|
+
const trigger = new import_async4.Trigger();
|
|
613
|
+
this._ctx.onDispose(() => {
|
|
614
|
+
trigger.wake(false);
|
|
615
|
+
});
|
|
616
|
+
const clear = this._params.update.on(this._ctx, () => {
|
|
617
|
+
if (this._isTrustedDevice(credential.issuer)) {
|
|
618
|
+
trigger.wake(true);
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
try {
|
|
622
|
+
await trigger.wait({
|
|
623
|
+
timeout: this._params.authTimeout
|
|
624
|
+
});
|
|
625
|
+
return true;
|
|
626
|
+
} catch (e) {
|
|
627
|
+
return false;
|
|
628
|
+
} finally {
|
|
629
|
+
clear();
|
|
630
|
+
}
|
|
631
|
+
};
|
|
599
632
|
}
|
|
600
|
-
return true;
|
|
601
633
|
};
|
|
602
634
|
|
|
603
635
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
604
636
|
var import_node_assert2 = __toESM(require("node:assert"));
|
|
605
|
-
var
|
|
637
|
+
var import_async5 = require("@dxos/async");
|
|
606
638
|
var import_credentials2 = require("@dxos/credentials");
|
|
607
|
-
var import_debug3 = require("@dxos/debug");
|
|
608
639
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
609
640
|
var import_log3 = require("@dxos/log");
|
|
610
641
|
var import_credentials3 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
642
|
+
var AUTH_TIMEOUT = 3e4;
|
|
611
643
|
var Identity = class {
|
|
612
644
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
613
|
-
this.stateUpdate = new
|
|
614
|
-
this.
|
|
645
|
+
this.stateUpdate = new import_async5.Event();
|
|
646
|
+
this.space = space;
|
|
615
647
|
this._signer = signer;
|
|
616
648
|
this.identityKey = identityKey;
|
|
617
649
|
this.deviceKey = deviceKey;
|
|
618
650
|
this._deviceStateMachine = new import_credentials2.DeviceStateMachine(this.identityKey, this.deviceKey);
|
|
619
651
|
this._profileStateMachine = new import_credentials2.ProfileStateMachine(this.identityKey);
|
|
620
|
-
this.
|
|
652
|
+
this.space.onCredentialProcessed.set(async (credential) => {
|
|
621
653
|
await this._deviceStateMachine.process(credential);
|
|
622
654
|
await this._profileStateMachine.process(credential);
|
|
623
655
|
this.stateUpdate.emit();
|
|
624
656
|
});
|
|
657
|
+
this.authVerifier = new HaloAuthVerifier({
|
|
658
|
+
trustedDevicesProvider: () => this.authorizedDeviceKeys,
|
|
659
|
+
update: this.stateUpdate,
|
|
660
|
+
authTimeout: AUTH_TIMEOUT
|
|
661
|
+
});
|
|
625
662
|
}
|
|
626
663
|
get authorizedDeviceKeys() {
|
|
627
664
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
628
665
|
}
|
|
629
666
|
async open() {
|
|
630
|
-
await this.
|
|
667
|
+
await this.space.open();
|
|
631
668
|
}
|
|
632
669
|
async close() {
|
|
633
|
-
await this.
|
|
670
|
+
await this.authVerifier.close();
|
|
671
|
+
await this.space.close();
|
|
634
672
|
}
|
|
635
673
|
async ready() {
|
|
636
674
|
await this._deviceStateMachine.deviceChainReady.wait();
|
|
@@ -639,23 +677,19 @@ var Identity = class {
|
|
|
639
677
|
return this._profileStateMachine.profile;
|
|
640
678
|
}
|
|
641
679
|
get controlPipeline() {
|
|
642
|
-
return this.
|
|
680
|
+
return this.space.controlPipeline;
|
|
643
681
|
}
|
|
644
682
|
get haloSpaceKey() {
|
|
645
|
-
return this.
|
|
683
|
+
return this.space.key;
|
|
646
684
|
}
|
|
647
685
|
get haloGenesisFeedKey() {
|
|
648
|
-
return this.
|
|
649
|
-
}
|
|
650
|
-
get haloDatabase() {
|
|
651
|
-
var _a;
|
|
652
|
-
return (_a = this._space.database) != null ? _a : (0, import_debug3.failUndefined)();
|
|
686
|
+
return this.space.genesisFeedKey;
|
|
653
687
|
}
|
|
654
688
|
getAdmissionCredentials() {
|
|
655
689
|
return {
|
|
656
690
|
deviceKey: this.deviceKey,
|
|
657
|
-
controlFeedKey: this.
|
|
658
|
-
dataFeedKey: this.
|
|
691
|
+
controlFeedKey: this.space.controlFeedKey,
|
|
692
|
+
dataFeedKey: this.space.dataFeedKey
|
|
659
693
|
};
|
|
660
694
|
}
|
|
661
695
|
getIdentityCredentialSigner() {
|
|
@@ -673,8 +707,8 @@ var Identity = class {
|
|
|
673
707
|
controlFeedKey,
|
|
674
708
|
dataFeedKey
|
|
675
709
|
}, {
|
|
676
|
-
file: "
|
|
677
|
-
line:
|
|
710
|
+
file: "identity.ts",
|
|
711
|
+
line: 147,
|
|
678
712
|
scope: this,
|
|
679
713
|
callSite: (f, a) => f(...a)
|
|
680
714
|
});
|
|
@@ -717,19 +751,19 @@ var Identity = class {
|
|
|
717
751
|
|
|
718
752
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
719
753
|
var import_node_assert3 = __toESM(require("node:assert"));
|
|
720
|
-
var
|
|
754
|
+
var import_async6 = require("@dxos/async");
|
|
721
755
|
var import_credentials4 = require("@dxos/credentials");
|
|
722
756
|
var import_echo_db = require("@dxos/echo-db");
|
|
723
757
|
var import_log4 = require("@dxos/log");
|
|
724
758
|
var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
759
|
+
var import_teleport_extension_presence = require("@dxos/teleport-extension-presence");
|
|
760
|
+
var import_util3 = require("@dxos/util");
|
|
725
761
|
var IdentityManager = class {
|
|
726
|
-
constructor(_metadataStore,
|
|
762
|
+
constructor(_metadataStore, _keyring, _spaceManager) {
|
|
727
763
|
this._metadataStore = _metadataStore;
|
|
728
|
-
this._feedStore = _feedStore;
|
|
729
764
|
this._keyring = _keyring;
|
|
730
|
-
this.
|
|
731
|
-
this.
|
|
732
|
-
this.stateUpdate = new import_async5.Event();
|
|
765
|
+
this._spaceManager = _spaceManager;
|
|
766
|
+
this.stateUpdate = new import_async6.Event();
|
|
733
767
|
}
|
|
734
768
|
get identity() {
|
|
735
769
|
return this._identity;
|
|
@@ -751,8 +785,8 @@ var IdentityManager = class {
|
|
|
751
785
|
async createIdentity({ displayName } = {}) {
|
|
752
786
|
(0, import_node_assert3.default)(!this._identity, "Identity already exists.");
|
|
753
787
|
(0, import_log4.log)("creating identity...", {}, {
|
|
754
|
-
file: "
|
|
755
|
-
line:
|
|
788
|
+
file: "identity-manager.ts",
|
|
789
|
+
line: 72,
|
|
756
790
|
scope: this,
|
|
757
791
|
callSite: (f, a) => f(...a)
|
|
758
792
|
});
|
|
@@ -796,8 +830,8 @@ var IdentityManager = class {
|
|
|
796
830
|
identityKey: identity.identityKey,
|
|
797
831
|
deviceKey: identity.deviceKey
|
|
798
832
|
}, {
|
|
799
|
-
file: "
|
|
800
|
-
line:
|
|
833
|
+
file: "identity-manager.ts",
|
|
834
|
+
line: 131,
|
|
801
835
|
scope: this,
|
|
802
836
|
callSite: (f, a) => f(...a)
|
|
803
837
|
});
|
|
@@ -807,8 +841,8 @@ var IdentityManager = class {
|
|
|
807
841
|
(0, import_log4.log)("accepting identity", {
|
|
808
842
|
params
|
|
809
843
|
}, {
|
|
810
|
-
file: "
|
|
811
|
-
line:
|
|
844
|
+
file: "identity-manager.ts",
|
|
845
|
+
line: 139,
|
|
812
846
|
scope: this,
|
|
813
847
|
callSite: (f, a) => f(...a)
|
|
814
848
|
});
|
|
@@ -835,8 +869,8 @@ var IdentityManager = class {
|
|
|
835
869
|
(0, import_log4.log)("constructing identity", {
|
|
836
870
|
identityRecord
|
|
837
871
|
}, {
|
|
838
|
-
file: "
|
|
839
|
-
line:
|
|
872
|
+
file: "identity-manager.ts",
|
|
873
|
+
line: 163,
|
|
840
874
|
scope: this,
|
|
841
875
|
callSite: (f, a) => f(...a)
|
|
842
876
|
});
|
|
@@ -844,46 +878,43 @@ var IdentityManager = class {
|
|
|
844
878
|
spaceRecord: identityRecord.haloSpace,
|
|
845
879
|
swarmIdentity: {
|
|
846
880
|
peerKey: identityRecord.deviceKey,
|
|
847
|
-
credentialProvider:
|
|
848
|
-
credentialAuthenticator:
|
|
849
|
-
}
|
|
850
|
-
});
|
|
851
|
-
(0, import_log4.log)("done", {
|
|
881
|
+
credentialProvider: createHaloAuthProvider((0, import_credentials4.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
|
|
882
|
+
credentialAuthenticator: (0, import_util3.deferFunction)(() => identity.authVerifier.verifier)
|
|
883
|
+
},
|
|
852
884
|
identityKey: identityRecord.identityKey
|
|
853
|
-
}, {
|
|
854
|
-
file: "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts",
|
|
855
|
-
line: 184,
|
|
856
|
-
scope: this,
|
|
857
|
-
callSite: (f, a) => f(...a)
|
|
858
885
|
});
|
|
859
|
-
|
|
886
|
+
const identity = new Identity({
|
|
860
887
|
space,
|
|
861
888
|
signer: this._keyring,
|
|
862
889
|
identityKey: identityRecord.identityKey,
|
|
863
890
|
deviceKey: identityRecord.deviceKey
|
|
864
891
|
});
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
});
|
|
873
|
-
const genesisFeed = await this._feedStore.openFeed(spaceRecord.genesisFeedKey);
|
|
874
|
-
const protocol = new import_echo_db.SpaceProtocol({
|
|
875
|
-
topic: spaceRecord.spaceKey,
|
|
876
|
-
identity: swarmIdentity,
|
|
877
|
-
networkManager: this._networkManager
|
|
892
|
+
(0, import_log4.log)("done", {
|
|
893
|
+
identityKey: identityRecord.identityKey
|
|
894
|
+
}, {
|
|
895
|
+
file: "identity-manager.ts",
|
|
896
|
+
line: 182,
|
|
897
|
+
scope: this,
|
|
898
|
+
callSite: (f, a) => f(...a)
|
|
878
899
|
});
|
|
879
|
-
return
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
900
|
+
return identity;
|
|
901
|
+
}
|
|
902
|
+
async _constructSpace({ spaceRecord, swarmIdentity, identityKey }) {
|
|
903
|
+
return this._spaceManager.constructSpace({
|
|
904
|
+
metadata: {
|
|
905
|
+
key: spaceRecord.spaceKey,
|
|
906
|
+
genesisFeedKey: spaceRecord.genesisFeedKey,
|
|
907
|
+
controlFeedKey: spaceRecord.writeControlFeedKey,
|
|
908
|
+
dataFeedKey: spaceRecord.writeDataFeedKey
|
|
909
|
+
},
|
|
910
|
+
dataPipelineControllerProvider: () => new import_echo_db.NoopDataPipelineController(),
|
|
911
|
+
swarmIdentity,
|
|
912
|
+
presence: new import_teleport_extension_presence.Presence({
|
|
913
|
+
localPeerId: swarmIdentity.peerKey,
|
|
914
|
+
announceInterval: 1e3,
|
|
915
|
+
offlineTimeout: 3e4,
|
|
916
|
+
identityKey
|
|
917
|
+
})
|
|
887
918
|
});
|
|
888
919
|
}
|
|
889
920
|
};
|
|
@@ -904,25 +935,26 @@ var InvitationEncoder = class {
|
|
|
904
935
|
|
|
905
936
|
// packages/sdk/client-services/src/packlets/invitations/halo-invitations-handler.ts
|
|
906
937
|
var import_node_assert5 = __toESM(require("node:assert"));
|
|
907
|
-
var
|
|
908
|
-
var
|
|
938
|
+
var import_async8 = require("@dxos/async");
|
|
939
|
+
var import_context2 = require("@dxos/context");
|
|
909
940
|
var import_credentials6 = require("@dxos/credentials");
|
|
910
|
-
var
|
|
941
|
+
var import_debug3 = require("@dxos/debug");
|
|
911
942
|
var import_keys4 = require("@dxos/keys");
|
|
912
943
|
var import_log5 = require("@dxos/log");
|
|
913
944
|
var import_network_manager = require("@dxos/network-manager");
|
|
914
945
|
var import_protocols3 = require("@dxos/protocols");
|
|
915
946
|
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
916
947
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
948
|
+
var import_teleport = require("@dxos/teleport");
|
|
917
949
|
|
|
918
950
|
// packages/sdk/client-services/src/packlets/invitations/invitations.ts
|
|
919
951
|
var import_node_assert4 = __toESM(require("node:assert"));
|
|
920
|
-
var
|
|
952
|
+
var import_async7 = require("@dxos/async");
|
|
921
953
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
922
954
|
var AUTHENTICATION_CODE_LENGTH = 6;
|
|
923
955
|
var INVITATION_TIMEOUT = 3 * 6e4;
|
|
924
956
|
var ON_CLOSE_DELAY = 500;
|
|
925
|
-
var InvitationObservableProvider = class extends
|
|
957
|
+
var InvitationObservableProvider = class extends import_async7.CancellableObservableProvider {
|
|
926
958
|
get invitation() {
|
|
927
959
|
return this._invitation;
|
|
928
960
|
}
|
|
@@ -962,45 +994,6 @@ var AbstractInvitationsHandler = class {
|
|
|
962
994
|
}
|
|
963
995
|
};
|
|
964
996
|
|
|
965
|
-
// packages/sdk/client-services/src/packlets/invitations/rpc-extension.ts
|
|
966
|
-
var import_rpc = require("@dxos/rpc");
|
|
967
|
-
var RpcExtension = class {
|
|
968
|
-
constructor(_params) {
|
|
969
|
-
this._params = _params;
|
|
970
|
-
}
|
|
971
|
-
get initiator() {
|
|
972
|
-
return this._extensionContext.initiator;
|
|
973
|
-
}
|
|
974
|
-
get localPeerId() {
|
|
975
|
-
return this._extensionContext.localPeerId;
|
|
976
|
-
}
|
|
977
|
-
get remotePeerId() {
|
|
978
|
-
return this._extensionContext.remotePeerId;
|
|
979
|
-
}
|
|
980
|
-
get rpc() {
|
|
981
|
-
return this._rpc.rpc;
|
|
982
|
-
}
|
|
983
|
-
async onOpen(context) {
|
|
984
|
-
this._extensionContext = context;
|
|
985
|
-
const handlers = await this.getHandlers();
|
|
986
|
-
const port = context.createPort("rpc", {
|
|
987
|
-
contentType: 'application/x-protobuf; messageType="dxos.rpc.Message"'
|
|
988
|
-
});
|
|
989
|
-
this._rpc = (0, import_rpc.createProtoRpcPeer)({
|
|
990
|
-
...this._params,
|
|
991
|
-
handlers,
|
|
992
|
-
port
|
|
993
|
-
});
|
|
994
|
-
await this._rpc.open();
|
|
995
|
-
}
|
|
996
|
-
async onClose(err) {
|
|
997
|
-
await this._rpc.close();
|
|
998
|
-
}
|
|
999
|
-
close() {
|
|
1000
|
-
this._extensionContext.close();
|
|
1001
|
-
}
|
|
1002
|
-
};
|
|
1003
|
-
|
|
1004
997
|
// packages/sdk/client-services/src/packlets/invitations/halo-invitations-handler.ts
|
|
1005
998
|
var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
1006
999
|
constructor(networkManager, _identityManager) {
|
|
@@ -1011,14 +1004,14 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1011
1004
|
var _a;
|
|
1012
1005
|
const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
|
|
1013
1006
|
(0, import_node_assert5.default)(type !== import_services2.Invitation.Type.OFFLINE);
|
|
1014
|
-
const identity = (_a = this._identityManager.identity) != null ? _a : (0,
|
|
1007
|
+
const identity = (_a = this._identityManager.identity) != null ? _a : (0, import_debug3.failUndefined)();
|
|
1015
1008
|
const invitation = {
|
|
1016
1009
|
type,
|
|
1017
1010
|
invitationId: import_keys4.PublicKey.random().toHex(),
|
|
1018
1011
|
swarmKey: swarmKey != null ? swarmKey : import_keys4.PublicKey.random(),
|
|
1019
1012
|
authenticationCode: (0, import_credentials6.generatePasscode)(AUTHENTICATION_CODE_LENGTH)
|
|
1020
1013
|
};
|
|
1021
|
-
const ctx = new
|
|
1014
|
+
const ctx = new import_context2.Context({
|
|
1022
1015
|
onError: (err) => {
|
|
1023
1016
|
void ctx.dispose();
|
|
1024
1017
|
observable.callback.onError(err);
|
|
@@ -1028,7 +1021,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1028
1021
|
await ctx.dispose();
|
|
1029
1022
|
});
|
|
1030
1023
|
let authenticationCode;
|
|
1031
|
-
const complete = new
|
|
1024
|
+
const complete = new import_async8.Trigger();
|
|
1032
1025
|
const createExtension = () => {
|
|
1033
1026
|
const hostInvitationExtension = new HostHaloInvitationExtension({
|
|
1034
1027
|
requestAdmission: async () => {
|
|
@@ -1036,8 +1029,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1036
1029
|
(0, import_log5.log)("responding with admission offer", {
|
|
1037
1030
|
host: identity.deviceKey
|
|
1038
1031
|
}, {
|
|
1039
|
-
file: "
|
|
1040
|
-
line:
|
|
1032
|
+
file: "halo-invitations-handler.ts",
|
|
1033
|
+
line: 84,
|
|
1041
1034
|
scope: this,
|
|
1042
1035
|
callSite: (f, a) => f(...a)
|
|
1043
1036
|
});
|
|
@@ -1052,8 +1045,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1052
1045
|
(0, import_log5.log)("received authentication request", {
|
|
1053
1046
|
authenticationCode: code
|
|
1054
1047
|
}, {
|
|
1055
|
-
file: "
|
|
1056
|
-
line:
|
|
1048
|
+
file: "halo-invitations-handler.ts",
|
|
1049
|
+
line: 98,
|
|
1057
1050
|
scope: this,
|
|
1058
1051
|
callSite: (f, a) => f(...a)
|
|
1059
1052
|
});
|
|
@@ -1073,8 +1066,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1073
1066
|
host: identity.deviceKey,
|
|
1074
1067
|
guest: credentials.deviceKey
|
|
1075
1068
|
}, {
|
|
1076
|
-
file: "
|
|
1077
|
-
line:
|
|
1069
|
+
file: "halo-invitations-handler.ts",
|
|
1070
|
+
line: 113,
|
|
1078
1071
|
scope: this,
|
|
1079
1072
|
callSite: (f, a) => f(...a)
|
|
1080
1073
|
});
|
|
@@ -1086,14 +1079,14 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1086
1079
|
}
|
|
1087
1080
|
},
|
|
1088
1081
|
onOpen: () => {
|
|
1089
|
-
(0,
|
|
1082
|
+
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1090
1083
|
var _a2, _b;
|
|
1091
1084
|
try {
|
|
1092
1085
|
(0, import_log5.log)("connected", {
|
|
1093
1086
|
host: identity.deviceKey
|
|
1094
1087
|
}, {
|
|
1095
|
-
file: "
|
|
1096
|
-
line:
|
|
1088
|
+
file: "halo-invitations-handler.ts",
|
|
1089
|
+
line: 129,
|
|
1097
1090
|
scope: this,
|
|
1098
1091
|
callSite: (f, a) => f(...a)
|
|
1099
1092
|
});
|
|
@@ -1105,8 +1098,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1105
1098
|
host: identity.deviceKey,
|
|
1106
1099
|
guest: deviceKey
|
|
1107
1100
|
}, {
|
|
1108
|
-
file: "
|
|
1109
|
-
line:
|
|
1101
|
+
file: "halo-invitations-handler.ts",
|
|
1102
|
+
line: 132,
|
|
1110
1103
|
scope: this,
|
|
1111
1104
|
callSite: (f, a) => f(...a)
|
|
1112
1105
|
});
|
|
@@ -1114,15 +1107,15 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1114
1107
|
} catch (err) {
|
|
1115
1108
|
if (!observable.cancelled) {
|
|
1116
1109
|
import_log5.log.error("failed", err, {
|
|
1117
|
-
file: "
|
|
1118
|
-
line:
|
|
1110
|
+
file: "halo-invitations-handler.ts",
|
|
1111
|
+
line: 136,
|
|
1119
1112
|
scope: this,
|
|
1120
1113
|
callSite: (f, a) => f(...a)
|
|
1121
1114
|
});
|
|
1122
1115
|
observable.callback.onError(err);
|
|
1123
1116
|
}
|
|
1124
1117
|
} finally {
|
|
1125
|
-
await (0,
|
|
1118
|
+
await (0, import_async8.sleep)(ON_CLOSE_DELAY);
|
|
1126
1119
|
await ctx.dispose();
|
|
1127
1120
|
}
|
|
1128
1121
|
});
|
|
@@ -1130,7 +1123,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1130
1123
|
});
|
|
1131
1124
|
return hostInvitationExtension;
|
|
1132
1125
|
};
|
|
1133
|
-
(0,
|
|
1126
|
+
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1134
1127
|
var _a2, _b;
|
|
1135
1128
|
const topic = invitation.swarmKey;
|
|
1136
1129
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
@@ -1148,13 +1141,13 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1148
1141
|
}
|
|
1149
1142
|
acceptInvitation(invitation, options) {
|
|
1150
1143
|
const { timeout = INVITATION_TIMEOUT } = options != null ? options : {};
|
|
1151
|
-
const ctx = new
|
|
1144
|
+
const ctx = new import_context2.Context({
|
|
1152
1145
|
onError: (err) => {
|
|
1153
1146
|
void ctx.dispose();
|
|
1154
1147
|
observable.callback.onError(err);
|
|
1155
1148
|
}
|
|
1156
1149
|
});
|
|
1157
|
-
const authenticated = new
|
|
1150
|
+
const authenticated = new import_async8.Trigger();
|
|
1158
1151
|
const observable = new AuthenticatingInvitationProvider({
|
|
1159
1152
|
onCancel: async () => {
|
|
1160
1153
|
await ctx.dispose();
|
|
@@ -1164,34 +1157,34 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1164
1157
|
}
|
|
1165
1158
|
});
|
|
1166
1159
|
let connectionCount = 0;
|
|
1167
|
-
const complete = new
|
|
1160
|
+
const complete = new import_async8.Trigger();
|
|
1168
1161
|
const createExtension = () => {
|
|
1169
1162
|
const extension = new GuestHaloInvitationExtension({
|
|
1170
1163
|
onOpen: () => {
|
|
1171
|
-
(0,
|
|
1164
|
+
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1172
1165
|
var _a, _b, _c, _d;
|
|
1173
1166
|
try {
|
|
1174
1167
|
if (++connectionCount > 1) {
|
|
1175
1168
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
1176
1169
|
}
|
|
1177
1170
|
(0, import_log5.log)("connected", {}, {
|
|
1178
|
-
file: "
|
|
1179
|
-
line:
|
|
1171
|
+
file: "halo-invitations-handler.ts",
|
|
1172
|
+
line: 209,
|
|
1180
1173
|
scope: this,
|
|
1181
1174
|
callSite: (f, a) => f(...a)
|
|
1182
1175
|
});
|
|
1183
1176
|
(_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
|
|
1184
1177
|
(0, import_log5.log)("sending admission request", {}, {
|
|
1185
|
-
file: "
|
|
1186
|
-
line:
|
|
1178
|
+
file: "halo-invitations-handler.ts",
|
|
1179
|
+
line: 213,
|
|
1187
1180
|
scope: this,
|
|
1188
1181
|
callSite: (f, a) => f(...a)
|
|
1189
1182
|
});
|
|
1190
1183
|
const { identityKey, haloSpaceKey, genesisFeedKey } = await extension.rpc.HaloHostService.requestAdmission();
|
|
1191
1184
|
if (invitation.type === void 0 || invitation.type === import_services2.Invitation.Type.INTERACTIVE) {
|
|
1192
1185
|
(0, import_log5.log)("guest waiting for authentication code...", {}, {
|
|
1193
|
-
file: "
|
|
1194
|
-
line:
|
|
1186
|
+
file: "halo-invitations-handler.ts",
|
|
1187
|
+
line: 220,
|
|
1195
1188
|
scope: this,
|
|
1196
1189
|
callSite: (f, a) => f(...a)
|
|
1197
1190
|
});
|
|
@@ -1200,8 +1193,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1200
1193
|
timeout
|
|
1201
1194
|
});
|
|
1202
1195
|
(0, import_log5.log)("sending authentication request", {}, {
|
|
1203
|
-
file: "
|
|
1204
|
-
line:
|
|
1196
|
+
file: "halo-invitations-handler.ts",
|
|
1197
|
+
line: 223,
|
|
1205
1198
|
scope: this,
|
|
1206
1199
|
callSite: (f, a) => f(...a)
|
|
1207
1200
|
});
|
|
@@ -1218,8 +1211,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1218
1211
|
guest: identity.deviceKey,
|
|
1219
1212
|
identityKey
|
|
1220
1213
|
}, {
|
|
1221
|
-
file: "
|
|
1222
|
-
line:
|
|
1214
|
+
file: "halo-invitations-handler.ts",
|
|
1215
|
+
line: 236,
|
|
1223
1216
|
scope: this,
|
|
1224
1217
|
callSite: (f, a) => f(...a)
|
|
1225
1218
|
});
|
|
@@ -1228,8 +1221,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1228
1221
|
guest: identity.deviceKey,
|
|
1229
1222
|
identityKey
|
|
1230
1223
|
}, {
|
|
1231
|
-
file: "
|
|
1232
|
-
line:
|
|
1224
|
+
file: "halo-invitations-handler.ts",
|
|
1225
|
+
line: 240,
|
|
1233
1226
|
scope: this,
|
|
1234
1227
|
callSite: (f, a) => f(...a)
|
|
1235
1228
|
});
|
|
@@ -1237,8 +1230,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1237
1230
|
} catch (err) {
|
|
1238
1231
|
if (!observable.cancelled) {
|
|
1239
1232
|
import_log5.log.warn("auth failed", err, {
|
|
1240
|
-
file: "
|
|
1241
|
-
line:
|
|
1233
|
+
file: "halo-invitations-handler.ts",
|
|
1234
|
+
line: 244,
|
|
1242
1235
|
scope: this,
|
|
1243
1236
|
callSite: (f, a) => f(...a)
|
|
1244
1237
|
});
|
|
@@ -1252,7 +1245,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1252
1245
|
});
|
|
1253
1246
|
return extension;
|
|
1254
1247
|
};
|
|
1255
|
-
(0,
|
|
1248
|
+
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1256
1249
|
var _a, _b;
|
|
1257
1250
|
(0, import_node_assert5.default)(invitation.swarmKey);
|
|
1258
1251
|
const topic = invitation.swarmKey;
|
|
@@ -1273,7 +1266,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1273
1266
|
return observable;
|
|
1274
1267
|
}
|
|
1275
1268
|
};
|
|
1276
|
-
var HostHaloInvitationExtension = class extends RpcExtension {
|
|
1269
|
+
var HostHaloInvitationExtension = class extends import_teleport.RpcExtension {
|
|
1277
1270
|
constructor(_callbacks) {
|
|
1278
1271
|
super({
|
|
1279
1272
|
exposed: {
|
|
@@ -1302,7 +1295,7 @@ var HostHaloInvitationExtension = class extends RpcExtension {
|
|
|
1302
1295
|
this._callbacks.onOpen();
|
|
1303
1296
|
}
|
|
1304
1297
|
};
|
|
1305
|
-
var GuestHaloInvitationExtension = class extends RpcExtension {
|
|
1298
|
+
var GuestHaloInvitationExtension = class extends import_teleport.RpcExtension {
|
|
1306
1299
|
constructor(_callbacks) {
|
|
1307
1300
|
super({
|
|
1308
1301
|
requested: {
|
|
@@ -1322,7 +1315,7 @@ var GuestHaloInvitationExtension = class extends RpcExtension {
|
|
|
1322
1315
|
|
|
1323
1316
|
// packages/sdk/client-services/src/packlets/invitations/invitations-proxy.ts
|
|
1324
1317
|
var import_node_assert6 = __toESM(require("node:assert"));
|
|
1325
|
-
var
|
|
1318
|
+
var import_async9 = require("@dxos/async");
|
|
1326
1319
|
var import_log6 = require("@dxos/log");
|
|
1327
1320
|
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1328
1321
|
var AbstractInvitationsProxy = class {
|
|
@@ -1371,7 +1364,7 @@ var AbstractInvitationsProxy = class {
|
|
|
1371
1364
|
}
|
|
1372
1365
|
default: {
|
|
1373
1366
|
import_log6.log.error(`Invalid state: ${invitation2.state}`, {}, {
|
|
1374
|
-
file: "
|
|
1367
|
+
file: "invitations-proxy.ts",
|
|
1375
1368
|
line: 81,
|
|
1376
1369
|
scope: this,
|
|
1377
1370
|
callSite: (f, a) => f(...a)
|
|
@@ -1380,7 +1373,7 @@ var AbstractInvitationsProxy = class {
|
|
|
1380
1373
|
}
|
|
1381
1374
|
}, (err) => {
|
|
1382
1375
|
if (err) {
|
|
1383
|
-
(0,
|
|
1376
|
+
(0, import_async9.observableError)(observable, err);
|
|
1384
1377
|
}
|
|
1385
1378
|
});
|
|
1386
1379
|
return observable;
|
|
@@ -1437,7 +1430,7 @@ var AbstractInvitationsProxy = class {
|
|
|
1437
1430
|
}
|
|
1438
1431
|
default: {
|
|
1439
1432
|
import_log6.log.error(`Invalid state: ${invitation2.state}`, {}, {
|
|
1440
|
-
file: "
|
|
1433
|
+
file: "invitations-proxy.ts",
|
|
1441
1434
|
line: 146,
|
|
1442
1435
|
scope: this,
|
|
1443
1436
|
callSite: (f, a) => f(...a)
|
|
@@ -1446,7 +1439,7 @@ var AbstractInvitationsProxy = class {
|
|
|
1446
1439
|
}
|
|
1447
1440
|
}, (err) => {
|
|
1448
1441
|
if (err) {
|
|
1449
|
-
(0,
|
|
1442
|
+
(0, import_async9.observableError)(observable, err);
|
|
1450
1443
|
}
|
|
1451
1444
|
});
|
|
1452
1445
|
return observable;
|
|
@@ -1483,7 +1476,7 @@ var AbstractInvitationsService = class {
|
|
|
1483
1476
|
const invitationsHandler = this._getInvitationsHandler();
|
|
1484
1477
|
const context = this.getContext(invitation);
|
|
1485
1478
|
(0, import_log7.log)("stream opened", this.getLoggingContext(), {
|
|
1486
|
-
file: "
|
|
1479
|
+
file: "invitations-service.ts",
|
|
1487
1480
|
line: 43,
|
|
1488
1481
|
scope: this,
|
|
1489
1482
|
callSite: (f, a) => f(...a)
|
|
@@ -1541,14 +1534,14 @@ var AbstractInvitationsService = class {
|
|
|
1541
1534
|
...context2,
|
|
1542
1535
|
err
|
|
1543
1536
|
}, {
|
|
1544
|
-
file: "
|
|
1537
|
+
file: "invitations-service.ts",
|
|
1545
1538
|
line: 92,
|
|
1546
1539
|
scope: this,
|
|
1547
1540
|
callSite: (f, a) => f(...a)
|
|
1548
1541
|
});
|
|
1549
1542
|
} else {
|
|
1550
1543
|
(0, import_log7.log)("stream closed", context2, {
|
|
1551
|
-
file: "
|
|
1544
|
+
file: "invitations-service.ts",
|
|
1552
1545
|
line: 94,
|
|
1553
1546
|
scope: this,
|
|
1554
1547
|
callSite: (f, a) => f(...a)
|
|
@@ -1561,7 +1554,7 @@ var AbstractInvitationsService = class {
|
|
|
1561
1554
|
acceptInvitation(invitation, options) {
|
|
1562
1555
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
1563
1556
|
(0, import_log7.log)("stream opened", this.getLoggingContext(), {
|
|
1564
|
-
file: "
|
|
1557
|
+
file: "invitations-service.ts",
|
|
1565
1558
|
line: 104,
|
|
1566
1559
|
scope: this,
|
|
1567
1560
|
callSite: (f, a) => f(...a)
|
|
@@ -1615,14 +1608,14 @@ var AbstractInvitationsService = class {
|
|
|
1615
1608
|
...context,
|
|
1616
1609
|
err
|
|
1617
1610
|
}, {
|
|
1618
|
-
file: "
|
|
1611
|
+
file: "invitations-service.ts",
|
|
1619
1612
|
line: 152,
|
|
1620
1613
|
scope: this,
|
|
1621
1614
|
callSite: (f, a) => f(...a)
|
|
1622
1615
|
});
|
|
1623
1616
|
} else {
|
|
1624
1617
|
(0, import_log7.log)("stream closed", context, {
|
|
1625
|
-
file: "
|
|
1618
|
+
file: "invitations-service.ts",
|
|
1626
1619
|
line: 154,
|
|
1627
1620
|
scope: this,
|
|
1628
1621
|
callSite: (f, a) => f(...a)
|
|
@@ -1634,7 +1627,7 @@ var AbstractInvitationsService = class {
|
|
|
1634
1627
|
}
|
|
1635
1628
|
async authenticate({ invitationId, authenticationCode }) {
|
|
1636
1629
|
(0, import_log7.log)("authenticating...", {}, {
|
|
1637
|
-
file: "
|
|
1630
|
+
file: "invitations-service.ts",
|
|
1638
1631
|
line: 163,
|
|
1639
1632
|
scope: this,
|
|
1640
1633
|
callSite: (f, a) => f(...a)
|
|
@@ -1645,7 +1638,7 @@ var AbstractInvitationsService = class {
|
|
|
1645
1638
|
import_log7.log.warn("invalid invitation", {
|
|
1646
1639
|
invitationId
|
|
1647
1640
|
}, {
|
|
1648
|
-
file: "
|
|
1641
|
+
file: "invitations-service.ts",
|
|
1649
1642
|
line: 167,
|
|
1650
1643
|
scope: this,
|
|
1651
1644
|
callSite: (f, a) => f(...a)
|
|
@@ -1657,7 +1650,7 @@ var AbstractInvitationsService = class {
|
|
|
1657
1650
|
async cancelInvitation(invitation) {
|
|
1658
1651
|
var _a;
|
|
1659
1652
|
(0, import_log7.log)("cancelling...", {}, {
|
|
1660
|
-
file: "
|
|
1653
|
+
file: "invitations-service.ts",
|
|
1661
1654
|
line: 174,
|
|
1662
1655
|
scope: this,
|
|
1663
1656
|
callSite: (f, a) => f(...a)
|
|
@@ -1668,7 +1661,7 @@ var AbstractInvitationsService = class {
|
|
|
1668
1661
|
import_log7.log.warn("invalid invitation", {
|
|
1669
1662
|
invitationId: invitation.invitationId
|
|
1670
1663
|
}, {
|
|
1671
|
-
file: "
|
|
1664
|
+
file: "invitations-service.ts",
|
|
1672
1665
|
line: 179,
|
|
1673
1666
|
scope: this,
|
|
1674
1667
|
callSite: (f, a) => f(...a)
|
|
@@ -1691,8 +1684,8 @@ var HaloInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
1691
1684
|
|
|
1692
1685
|
// packages/sdk/client-services/src/packlets/invitations/space-invitations-handler.ts
|
|
1693
1686
|
var import_node_assert8 = __toESM(require("node:assert"));
|
|
1694
|
-
var
|
|
1695
|
-
var
|
|
1687
|
+
var import_async10 = require("@dxos/async");
|
|
1688
|
+
var import_context3 = require("@dxos/context");
|
|
1696
1689
|
var import_credentials7 = require("@dxos/credentials");
|
|
1697
1690
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
1698
1691
|
var import_keys5 = require("@dxos/keys");
|
|
@@ -1701,6 +1694,7 @@ var import_network_manager2 = require("@dxos/network-manager");
|
|
|
1701
1694
|
var import_protocols4 = require("@dxos/protocols");
|
|
1702
1695
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1703
1696
|
var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
1697
|
+
var import_teleport2 = require("@dxos/teleport");
|
|
1704
1698
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1705
1699
|
var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
1706
1700
|
constructor(networkManager, _spaceManager, _signingContext, _keyring) {
|
|
@@ -1721,7 +1715,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1721
1715
|
spaceKey: space.key,
|
|
1722
1716
|
authenticationCode: (0, import_credentials7.generatePasscode)(AUTHENTICATION_CODE_LENGTH)
|
|
1723
1717
|
};
|
|
1724
|
-
const ctx = new
|
|
1718
|
+
const ctx = new import_context3.Context({
|
|
1725
1719
|
onError: (err) => {
|
|
1726
1720
|
void ctx.dispose();
|
|
1727
1721
|
observable.callback.onError(err);
|
|
@@ -1732,7 +1726,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1732
1726
|
});
|
|
1733
1727
|
let authenticationCode;
|
|
1734
1728
|
let authenticationRetry = 0;
|
|
1735
|
-
const complete = new
|
|
1729
|
+
const complete = new import_async10.Trigger();
|
|
1736
1730
|
const createExtension = () => {
|
|
1737
1731
|
let guestProfile;
|
|
1738
1732
|
const hostInvitationExtension = new HostSpaceInvitationExtension({
|
|
@@ -1743,8 +1737,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1743
1737
|
host: this._signingContext.deviceKey,
|
|
1744
1738
|
spaceKey: space.key
|
|
1745
1739
|
}, {
|
|
1746
|
-
file: "
|
|
1747
|
-
line:
|
|
1740
|
+
file: "space-invitations-handler.ts",
|
|
1741
|
+
line: 98,
|
|
1748
1742
|
scope: this,
|
|
1749
1743
|
callSite: (f, a) => f(...a)
|
|
1750
1744
|
});
|
|
@@ -1755,8 +1749,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1755
1749
|
(0, import_log8.log)("received authentication request", {
|
|
1756
1750
|
authenticationCode: code
|
|
1757
1751
|
}, {
|
|
1758
|
-
file: "
|
|
1759
|
-
line:
|
|
1752
|
+
file: "space-invitations-handler.ts",
|
|
1753
|
+
line: 112,
|
|
1760
1754
|
scope: this,
|
|
1761
1755
|
callSite: (f, a) => f(...a)
|
|
1762
1756
|
});
|
|
@@ -1785,16 +1779,16 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1785
1779
|
host: this._signingContext.deviceKey,
|
|
1786
1780
|
guest: deviceKey
|
|
1787
1781
|
}, {
|
|
1788
|
-
file: "
|
|
1789
|
-
line:
|
|
1782
|
+
file: "space-invitations-handler.ts",
|
|
1783
|
+
line: 136,
|
|
1790
1784
|
scope: this,
|
|
1791
1785
|
callSite: (f, a) => f(...a)
|
|
1792
1786
|
});
|
|
1793
|
-
const credentials = await (0, import_credentials7.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, deviceKey, space.key, controlFeedKey, dataFeedKey, space.genesisFeedKey, guestProfile);
|
|
1787
|
+
const credentials = await (0, import_credentials7.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, deviceKey, space.key, controlFeedKey, dataFeedKey, space.inner.genesisFeedKey, guestProfile);
|
|
1794
1788
|
(0, import_node_assert8.default)(credentials[0]["@type"] === "dxos.echo.feed.CredentialsMessage");
|
|
1795
1789
|
const spaceMemberCredential = credentials[0].credential;
|
|
1796
1790
|
(0, import_node_assert8.default)((0, import_credentials7.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
1797
|
-
await (0, import_feed_store3.writeMessages)(space.controlPipeline.writer, credentials);
|
|
1791
|
+
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
1798
1792
|
complete.wake(deviceKey);
|
|
1799
1793
|
return {
|
|
1800
1794
|
credential: spaceMemberCredential
|
|
@@ -1805,14 +1799,14 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1805
1799
|
}
|
|
1806
1800
|
},
|
|
1807
1801
|
onOpen: () => {
|
|
1808
|
-
(0,
|
|
1802
|
+
(0, import_async10.scheduleTask)(ctx, async () => {
|
|
1809
1803
|
var _a, _b;
|
|
1810
1804
|
try {
|
|
1811
1805
|
(0, import_log8.log)("connected", {
|
|
1812
1806
|
host: this._signingContext.deviceKey
|
|
1813
1807
|
}, {
|
|
1814
|
-
file: "
|
|
1815
|
-
line:
|
|
1808
|
+
file: "space-invitations-handler.ts",
|
|
1809
|
+
line: 170,
|
|
1816
1810
|
scope: this,
|
|
1817
1811
|
callSite: (f, a) => f(...a)
|
|
1818
1812
|
});
|
|
@@ -1824,8 +1818,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1824
1818
|
host: this._signingContext.deviceKey,
|
|
1825
1819
|
guest: deviceKey
|
|
1826
1820
|
}, {
|
|
1827
|
-
file: "
|
|
1828
|
-
line:
|
|
1821
|
+
file: "space-invitations-handler.ts",
|
|
1822
|
+
line: 173,
|
|
1829
1823
|
scope: this,
|
|
1830
1824
|
callSite: (f, a) => f(...a)
|
|
1831
1825
|
});
|
|
@@ -1833,15 +1827,15 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1833
1827
|
} catch (err) {
|
|
1834
1828
|
if (!observable.cancelled) {
|
|
1835
1829
|
import_log8.log.error("failed", err, {
|
|
1836
|
-
file: "
|
|
1837
|
-
line:
|
|
1830
|
+
file: "space-invitations-handler.ts",
|
|
1831
|
+
line: 177,
|
|
1838
1832
|
scope: this,
|
|
1839
1833
|
callSite: (f, a) => f(...a)
|
|
1840
1834
|
});
|
|
1841
1835
|
observable.callback.onError(err);
|
|
1842
1836
|
}
|
|
1843
1837
|
} finally {
|
|
1844
|
-
await (0,
|
|
1838
|
+
await (0, import_async10.sleep)(ON_CLOSE_DELAY);
|
|
1845
1839
|
await ctx.dispose();
|
|
1846
1840
|
}
|
|
1847
1841
|
});
|
|
@@ -1849,7 +1843,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1849
1843
|
});
|
|
1850
1844
|
return hostInvitationExtension;
|
|
1851
1845
|
};
|
|
1852
|
-
(0,
|
|
1846
|
+
(0, import_async10.scheduleTask)(ctx, async () => {
|
|
1853
1847
|
var _a, _b;
|
|
1854
1848
|
const topic = invitation.swarmKey;
|
|
1855
1849
|
const swarmConnection2 = await this._networkManager.joinSwarm({
|
|
@@ -1867,13 +1861,13 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1867
1861
|
}
|
|
1868
1862
|
acceptInvitation(invitation, options) {
|
|
1869
1863
|
const { timeout = INVITATION_TIMEOUT } = options != null ? options : {};
|
|
1870
|
-
const ctx = new
|
|
1864
|
+
const ctx = new import_context3.Context({
|
|
1871
1865
|
onError: (err) => {
|
|
1872
1866
|
void ctx.dispose();
|
|
1873
1867
|
observable.callback.onError(err);
|
|
1874
1868
|
}
|
|
1875
1869
|
});
|
|
1876
|
-
const authenticated = new
|
|
1870
|
+
const authenticated = new import_async10.Trigger();
|
|
1877
1871
|
const observable = new AuthenticatingInvitationProvider({
|
|
1878
1872
|
onCancel: async () => {
|
|
1879
1873
|
await ctx.dispose();
|
|
@@ -1883,11 +1877,11 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1883
1877
|
}
|
|
1884
1878
|
});
|
|
1885
1879
|
let connectionCount = 0;
|
|
1886
|
-
const complete = new
|
|
1880
|
+
const complete = new import_async10.Trigger();
|
|
1887
1881
|
const createExtension = () => {
|
|
1888
1882
|
const extension = new GuestSpaceInvitationExtension({
|
|
1889
1883
|
onOpen: () => {
|
|
1890
|
-
(0,
|
|
1884
|
+
(0, import_async10.scheduleTask)(ctx, async () => {
|
|
1891
1885
|
var _a, _b, _c, _d;
|
|
1892
1886
|
try {
|
|
1893
1887
|
if (++connectionCount > 1) {
|
|
@@ -1896,8 +1890,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1896
1890
|
(0, import_log8.log)("connected", {
|
|
1897
1891
|
guest: this._signingContext.deviceKey
|
|
1898
1892
|
}, {
|
|
1899
|
-
file: "
|
|
1900
|
-
line:
|
|
1893
|
+
file: "space-invitations-handler.ts",
|
|
1894
|
+
line: 248,
|
|
1901
1895
|
scope: this,
|
|
1902
1896
|
callSite: (f, a) => f(...a)
|
|
1903
1897
|
});
|
|
@@ -1905,8 +1899,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1905
1899
|
(0, import_log8.log)("introduce", {
|
|
1906
1900
|
guest: this._signingContext.deviceKey
|
|
1907
1901
|
}, {
|
|
1908
|
-
file: "
|
|
1909
|
-
line:
|
|
1902
|
+
file: "space-invitations-handler.ts",
|
|
1903
|
+
line: 252,
|
|
1910
1904
|
scope: this,
|
|
1911
1905
|
callSite: (f, a) => f(...a)
|
|
1912
1906
|
});
|
|
@@ -1916,8 +1910,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1916
1910
|
if (invitation.type === void 0 || invitation.type === import_services5.Invitation.Type.INTERACTIVE) {
|
|
1917
1911
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1918
1912
|
(0, import_log8.log)("guest waiting for authentication code...", {}, {
|
|
1919
|
-
file: "
|
|
1920
|
-
line:
|
|
1913
|
+
file: "space-invitations-handler.ts",
|
|
1914
|
+
line: 261,
|
|
1921
1915
|
scope: this,
|
|
1922
1916
|
callSite: (f, a) => f(...a)
|
|
1923
1917
|
});
|
|
@@ -1926,8 +1920,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1926
1920
|
timeout
|
|
1927
1921
|
});
|
|
1928
1922
|
(0, import_log8.log)("sending authentication request", {}, {
|
|
1929
|
-
file: "
|
|
1930
|
-
line:
|
|
1923
|
+
file: "space-invitations-handler.ts",
|
|
1924
|
+
line: 265,
|
|
1931
1925
|
scope: this,
|
|
1932
1926
|
callSite: (f, a) => f(...a)
|
|
1933
1927
|
});
|
|
@@ -1944,8 +1938,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1944
1938
|
(0, import_log8.log)("retrying invalid code", {
|
|
1945
1939
|
attempt
|
|
1946
1940
|
}, {
|
|
1947
|
-
file: "
|
|
1948
|
-
line:
|
|
1941
|
+
file: "space-invitations-handler.ts",
|
|
1942
|
+
line: 275,
|
|
1949
1943
|
scope: this,
|
|
1950
1944
|
callSite: (f, a) => f(...a)
|
|
1951
1945
|
});
|
|
@@ -1959,8 +1953,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1959
1953
|
(0, import_log8.log)("request admission", {
|
|
1960
1954
|
guest: this._signingContext.deviceKey
|
|
1961
1955
|
}, {
|
|
1962
|
-
file: "
|
|
1963
|
-
line:
|
|
1956
|
+
file: "space-invitations-handler.ts",
|
|
1957
|
+
line: 286,
|
|
1964
1958
|
scope: this,
|
|
1965
1959
|
callSite: (f, a) => f(...a)
|
|
1966
1960
|
});
|
|
@@ -1983,8 +1977,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1983
1977
|
guest: this._signingContext.deviceKey,
|
|
1984
1978
|
spaceKey: space.key
|
|
1985
1979
|
}, {
|
|
1986
|
-
file: "
|
|
1987
|
-
line:
|
|
1980
|
+
file: "space-invitations-handler.ts",
|
|
1981
|
+
line: 309,
|
|
1988
1982
|
scope: this,
|
|
1989
1983
|
callSite: (f, a) => f(...a)
|
|
1990
1984
|
});
|
|
@@ -1992,8 +1986,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1992
1986
|
} catch (err) {
|
|
1993
1987
|
if (!observable.cancelled) {
|
|
1994
1988
|
import_log8.log.warn("auth failed", err, {
|
|
1995
|
-
file: "
|
|
1996
|
-
line:
|
|
1989
|
+
file: "space-invitations-handler.ts",
|
|
1990
|
+
line: 313,
|
|
1997
1991
|
scope: this,
|
|
1998
1992
|
callSite: (f, a) => f(...a)
|
|
1999
1993
|
});
|
|
@@ -2007,7 +2001,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2007
2001
|
});
|
|
2008
2002
|
return extension;
|
|
2009
2003
|
};
|
|
2010
|
-
(0,
|
|
2004
|
+
(0, import_async10.scheduleTask)(ctx, async () => {
|
|
2011
2005
|
var _a, _b;
|
|
2012
2006
|
(0, import_node_assert8.default)(invitation.swarmKey);
|
|
2013
2007
|
const topic = invitation.swarmKey;
|
|
@@ -2028,7 +2022,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2028
2022
|
return observable;
|
|
2029
2023
|
}
|
|
2030
2024
|
};
|
|
2031
|
-
var HostSpaceInvitationExtension = class extends RpcExtension {
|
|
2025
|
+
var HostSpaceInvitationExtension = class extends import_teleport2.RpcExtension {
|
|
2032
2026
|
constructor(_callbacks) {
|
|
2033
2027
|
super({
|
|
2034
2028
|
exposed: {
|
|
@@ -2057,7 +2051,7 @@ var HostSpaceInvitationExtension = class extends RpcExtension {
|
|
|
2057
2051
|
this._callbacks.onOpen();
|
|
2058
2052
|
}
|
|
2059
2053
|
};
|
|
2060
|
-
var GuestSpaceInvitationExtension = class extends RpcExtension {
|
|
2054
|
+
var GuestSpaceInvitationExtension = class extends import_teleport2.RpcExtension {
|
|
2061
2055
|
constructor(_callbacks) {
|
|
2062
2056
|
super({
|
|
2063
2057
|
requested: {
|
|
@@ -2102,124 +2096,275 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
2102
2096
|
};
|
|
2103
2097
|
|
|
2104
2098
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2105
|
-
var
|
|
2106
|
-
var
|
|
2107
|
-
var
|
|
2099
|
+
var import_async12 = require("@dxos/async");
|
|
2100
|
+
var import_debug4 = require("@dxos/debug");
|
|
2101
|
+
var import_echo_db4 = require("@dxos/echo-db");
|
|
2108
2102
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
2109
2103
|
var import_keyring = require("@dxos/keyring");
|
|
2104
|
+
var import_log10 = require("@dxos/log");
|
|
2105
|
+
|
|
2106
|
+
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2107
|
+
var import_async11 = require("@dxos/async");
|
|
2108
|
+
var import_echo_db3 = require("@dxos/echo-db");
|
|
2109
|
+
var import_keys6 = require("@dxos/keys");
|
|
2110
2110
|
var import_log9 = require("@dxos/log");
|
|
2111
|
+
var import_teleport_extension_presence2 = require("@dxos/teleport-extension-presence");
|
|
2112
|
+
var import_util4 = require("@dxos/util");
|
|
2113
|
+
|
|
2114
|
+
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2115
|
+
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2116
|
+
var import_context4 = require("@dxos/context");
|
|
2117
|
+
var import_echo_db2 = require("@dxos/echo-db");
|
|
2118
|
+
var DataSpace = class {
|
|
2119
|
+
constructor(_inner, _modelFactory, _memberKey, _presence) {
|
|
2120
|
+
this._inner = _inner;
|
|
2121
|
+
this._modelFactory = _modelFactory;
|
|
2122
|
+
this._memberKey = _memberKey;
|
|
2123
|
+
this._presence = _presence;
|
|
2124
|
+
this._ctx = new import_context4.Context();
|
|
2125
|
+
this._dataPipelineController = new import_echo_db2.DataPipelineControllerImpl(_modelFactory, _memberKey, (feedKey) => _inner.spaceState.feeds.get(feedKey));
|
|
2126
|
+
}
|
|
2127
|
+
get key() {
|
|
2128
|
+
return this._inner.key;
|
|
2129
|
+
}
|
|
2130
|
+
get inner() {
|
|
2131
|
+
return this._inner;
|
|
2132
|
+
}
|
|
2133
|
+
get isOpen() {
|
|
2134
|
+
return this._inner.isOpen;
|
|
2135
|
+
}
|
|
2136
|
+
get dataPipelineController() {
|
|
2137
|
+
return this._dataPipelineController;
|
|
2138
|
+
}
|
|
2139
|
+
get database() {
|
|
2140
|
+
(0, import_node_assert10.default)(this._dataPipelineController.database);
|
|
2141
|
+
return this._dataPipelineController.database;
|
|
2142
|
+
}
|
|
2143
|
+
get stateUpdate() {
|
|
2144
|
+
return this._inner.stateUpdate;
|
|
2145
|
+
}
|
|
2146
|
+
get presence() {
|
|
2147
|
+
return this._presence;
|
|
2148
|
+
}
|
|
2149
|
+
async open() {
|
|
2150
|
+
await this._inner.open();
|
|
2151
|
+
}
|
|
2152
|
+
async close() {
|
|
2153
|
+
await this._ctx.dispose();
|
|
2154
|
+
await this._inner.close();
|
|
2155
|
+
await this._presence.destroy();
|
|
2156
|
+
}
|
|
2157
|
+
};
|
|
2158
|
+
|
|
2159
|
+
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2160
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
2161
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2162
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2163
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2164
|
+
else
|
|
2165
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2166
|
+
if (d = decorators[i])
|
|
2167
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2168
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2169
|
+
};
|
|
2170
|
+
var DataSpaceManager = class {
|
|
2171
|
+
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _modelFactory) {
|
|
2172
|
+
this._spaceManager = _spaceManager;
|
|
2173
|
+
this._metadataStore = _metadataStore;
|
|
2174
|
+
this._dataServiceSubscriptions = _dataServiceSubscriptions;
|
|
2175
|
+
this._keyring = _keyring;
|
|
2176
|
+
this._signingContext = _signingContext;
|
|
2177
|
+
this._modelFactory = _modelFactory;
|
|
2178
|
+
this.updated = new import_async11.Event();
|
|
2179
|
+
this._spaces = new import_util4.ComplexMap(import_keys6.PublicKey.hash);
|
|
2180
|
+
}
|
|
2181
|
+
get spaces() {
|
|
2182
|
+
return this._spaces;
|
|
2183
|
+
}
|
|
2184
|
+
async open() {
|
|
2185
|
+
await this._metadataStore.load();
|
|
2186
|
+
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2187
|
+
await this._constructSpace(spaceMetadata);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
async close() {
|
|
2191
|
+
}
|
|
2192
|
+
async createSpace() {
|
|
2193
|
+
const spaceKey = await this._keyring.createKey();
|
|
2194
|
+
const controlFeedKey = await this._keyring.createKey();
|
|
2195
|
+
const dataFeedKey = await this._keyring.createKey();
|
|
2196
|
+
const metadata = {
|
|
2197
|
+
key: spaceKey,
|
|
2198
|
+
genesisFeedKey: controlFeedKey,
|
|
2199
|
+
controlFeedKey,
|
|
2200
|
+
dataFeedKey
|
|
2201
|
+
};
|
|
2202
|
+
(0, import_log9.log)("creating space...", {
|
|
2203
|
+
spaceKey
|
|
2204
|
+
}, {
|
|
2205
|
+
file: "data-space-manager.ts",
|
|
2206
|
+
line: 70,
|
|
2207
|
+
scope: this,
|
|
2208
|
+
callSite: (f, a) => f(...a)
|
|
2209
|
+
});
|
|
2210
|
+
const space = await this._constructSpace(metadata);
|
|
2211
|
+
await (0, import_echo_db3.spaceGenesis)(this._keyring, this._signingContext, space.inner);
|
|
2212
|
+
await this._metadataStore.addSpace(metadata);
|
|
2213
|
+
this.updated.emit();
|
|
2214
|
+
return space;
|
|
2215
|
+
}
|
|
2216
|
+
async acceptSpace(opts) {
|
|
2217
|
+
const metadata = {
|
|
2218
|
+
key: opts.spaceKey,
|
|
2219
|
+
genesisFeedKey: opts.genesisFeedKey,
|
|
2220
|
+
controlFeedKey: opts.controlFeedKey,
|
|
2221
|
+
dataFeedKey: opts.dataFeedKey
|
|
2222
|
+
};
|
|
2223
|
+
const space = await this._constructSpace(metadata);
|
|
2224
|
+
await this._metadataStore.addSpace(metadata);
|
|
2225
|
+
this.updated.emit();
|
|
2226
|
+
return space;
|
|
2227
|
+
}
|
|
2228
|
+
async _constructSpace(metadata) {
|
|
2229
|
+
const presence = new import_teleport_extension_presence2.Presence({
|
|
2230
|
+
localPeerId: this._signingContext.deviceKey,
|
|
2231
|
+
announceInterval: 1e3,
|
|
2232
|
+
offlineTimeout: 3e4,
|
|
2233
|
+
identityKey: this._signingContext.identityKey
|
|
2234
|
+
});
|
|
2235
|
+
const space = await this._spaceManager.constructSpace({
|
|
2236
|
+
metadata,
|
|
2237
|
+
swarmIdentity: {
|
|
2238
|
+
peerKey: this._signingContext.deviceKey,
|
|
2239
|
+
credentialProvider: this._signingContext.credentialProvider,
|
|
2240
|
+
credentialAuthenticator: this._signingContext.credentialAuthenticator
|
|
2241
|
+
},
|
|
2242
|
+
dataPipelineControllerProvider: () => dataSpace.dataPipelineController,
|
|
2243
|
+
presence
|
|
2244
|
+
});
|
|
2245
|
+
const dataSpace = new DataSpace(space, this._modelFactory, this._signingContext.identityKey, presence);
|
|
2246
|
+
await space.open();
|
|
2247
|
+
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.database.createDataServiceHost());
|
|
2248
|
+
this._spaces.set(metadata.key, dataSpace);
|
|
2249
|
+
return dataSpace;
|
|
2250
|
+
}
|
|
2251
|
+
};
|
|
2252
|
+
__decorate([
|
|
2253
|
+
import_async11.synchronized
|
|
2254
|
+
], DataSpaceManager.prototype, "open", null);
|
|
2255
|
+
__decorate([
|
|
2256
|
+
import_async11.synchronized
|
|
2257
|
+
], DataSpaceManager.prototype, "close", null);
|
|
2258
|
+
|
|
2259
|
+
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2111
2260
|
var ServiceContext = class {
|
|
2112
2261
|
constructor(storage, networkManager, modelFactory) {
|
|
2113
2262
|
this.storage = storage;
|
|
2114
2263
|
this.networkManager = networkManager;
|
|
2115
2264
|
this.modelFactory = modelFactory;
|
|
2116
|
-
this.initialized = new
|
|
2117
|
-
this.dataServiceSubscriptions = new
|
|
2118
|
-
this.metadataStore = new
|
|
2265
|
+
this.initialized = new import_async12.Trigger();
|
|
2266
|
+
this.dataServiceSubscriptions = new import_echo_db4.DataServiceSubscriptions();
|
|
2267
|
+
this.metadataStore = new import_echo_db4.MetadataStore(storage.createDirectory("metadata"));
|
|
2119
2268
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
2120
2269
|
this.feedStore = new import_feed_store4.FeedStore({
|
|
2121
2270
|
factory: new import_feed_store4.FeedFactory({
|
|
2122
2271
|
root: storage.createDirectory("feeds"),
|
|
2123
2272
|
signer: this.keyring,
|
|
2124
2273
|
hypercore: {
|
|
2125
|
-
valueEncoding:
|
|
2274
|
+
valueEncoding: import_echo_db4.valueEncoding
|
|
2126
2275
|
}
|
|
2127
2276
|
})
|
|
2128
2277
|
});
|
|
2129
|
-
this.
|
|
2278
|
+
this.spaceManager = new import_echo_db4.SpaceManager({
|
|
2279
|
+
feedStore: this.feedStore,
|
|
2280
|
+
networkManager: this.networkManager
|
|
2281
|
+
});
|
|
2282
|
+
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.spaceManager);
|
|
2130
2283
|
this.haloInvitations = new HaloInvitationsHandler(this.networkManager, this.identityManager);
|
|
2131
2284
|
}
|
|
2132
2285
|
async open() {
|
|
2133
|
-
(0,
|
|
2134
|
-
file: "
|
|
2135
|
-
line:
|
|
2286
|
+
(0, import_log10.log)("opening...", {}, {
|
|
2287
|
+
file: "service-context.ts",
|
|
2288
|
+
line: 81,
|
|
2136
2289
|
scope: this,
|
|
2137
2290
|
callSite: (f, a) => f(...a)
|
|
2138
2291
|
});
|
|
2292
|
+
await this.spaceManager.open();
|
|
2139
2293
|
await this.identityManager.open();
|
|
2140
2294
|
if (this.identityManager.identity) {
|
|
2141
2295
|
await this._initialize();
|
|
2142
2296
|
}
|
|
2143
|
-
(0,
|
|
2144
|
-
file: "
|
|
2145
|
-
line:
|
|
2297
|
+
(0, import_log10.log)("opened", {}, {
|
|
2298
|
+
file: "service-context.ts",
|
|
2299
|
+
line: 87,
|
|
2146
2300
|
scope: this,
|
|
2147
2301
|
callSite: (f, a) => f(...a)
|
|
2148
2302
|
});
|
|
2149
2303
|
}
|
|
2150
2304
|
async close() {
|
|
2151
2305
|
var _a;
|
|
2152
|
-
(0,
|
|
2153
|
-
file: "
|
|
2154
|
-
line:
|
|
2306
|
+
(0, import_log10.log)("closing...", {}, {
|
|
2307
|
+
file: "service-context.ts",
|
|
2308
|
+
line: 91,
|
|
2155
2309
|
scope: this,
|
|
2156
2310
|
callSite: (f, a) => f(...a)
|
|
2157
2311
|
});
|
|
2312
|
+
await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
|
|
2158
2313
|
await this.identityManager.close();
|
|
2159
|
-
await
|
|
2314
|
+
await this.spaceManager.close();
|
|
2160
2315
|
await this.feedStore.close();
|
|
2161
2316
|
await this.networkManager.close();
|
|
2162
2317
|
this.dataServiceSubscriptions.clear();
|
|
2163
|
-
(0,
|
|
2164
|
-
file: "
|
|
2165
|
-
line:
|
|
2318
|
+
(0, import_log10.log)("closed", {}, {
|
|
2319
|
+
file: "service-context.ts",
|
|
2320
|
+
line: 98,
|
|
2166
2321
|
scope: this,
|
|
2167
2322
|
callSite: (f, a) => f(...a)
|
|
2168
2323
|
});
|
|
2169
2324
|
}
|
|
2170
2325
|
async reset() {
|
|
2171
|
-
(0,
|
|
2172
|
-
file: "
|
|
2173
|
-
line:
|
|
2326
|
+
(0, import_log10.log)("resetting...", {}, {
|
|
2327
|
+
file: "service-context.ts",
|
|
2328
|
+
line: 102,
|
|
2174
2329
|
scope: this,
|
|
2175
2330
|
callSite: (f, a) => f(...a)
|
|
2176
2331
|
});
|
|
2177
2332
|
await this.close();
|
|
2178
2333
|
await this.storage.reset();
|
|
2179
|
-
(0,
|
|
2180
|
-
file: "
|
|
2181
|
-
line:
|
|
2334
|
+
(0, import_log10.log)("reset", {}, {
|
|
2335
|
+
file: "service-context.ts",
|
|
2336
|
+
line: 105,
|
|
2182
2337
|
scope: this,
|
|
2183
2338
|
callSite: (f, a) => f(...a)
|
|
2184
2339
|
});
|
|
2185
2340
|
}
|
|
2186
2341
|
async createIdentity(params = {}) {
|
|
2187
2342
|
const identity = await this.identityManager.createIdentity(params);
|
|
2188
|
-
this.dataServiceSubscriptions.registerSpace(identity.haloSpaceKey, identity.haloDatabase.createDataServiceHost());
|
|
2189
2343
|
await this._initialize();
|
|
2190
2344
|
return identity;
|
|
2191
2345
|
}
|
|
2192
2346
|
async _initialize() {
|
|
2193
2347
|
var _a;
|
|
2194
|
-
const identity = (_a = this.identityManager.identity) != null ? _a : (0,
|
|
2348
|
+
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug4.failUndefined)();
|
|
2195
2349
|
const signingContext = {
|
|
2196
|
-
credentialProvider:
|
|
2197
|
-
credentialAuthenticator:
|
|
2350
|
+
credentialProvider: import_echo_db4.MOCK_AUTH_PROVIDER,
|
|
2351
|
+
credentialAuthenticator: import_echo_db4.MOCK_AUTH_VERIFIER,
|
|
2198
2352
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
2199
2353
|
identityKey: identity.identityKey,
|
|
2200
2354
|
deviceKey: identity.deviceKey,
|
|
2201
2355
|
profile: identity.profileDocument
|
|
2202
2356
|
};
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
networkManager: this.networkManager,
|
|
2207
|
-
keyring: this.keyring,
|
|
2208
|
-
dataServiceSubscriptions: this.dataServiceSubscriptions,
|
|
2209
|
-
modelFactory: this.modelFactory,
|
|
2210
|
-
signingContext
|
|
2211
|
-
});
|
|
2212
|
-
await spaceManager.open();
|
|
2213
|
-
this.spaceManager = spaceManager;
|
|
2214
|
-
this.spaceInvitations = new SpaceInvitationsHandler(this.networkManager, this.spaceManager, signingContext, this.keyring);
|
|
2357
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.modelFactory);
|
|
2358
|
+
await this.dataSpaceManager.open();
|
|
2359
|
+
this.spaceInvitations = new SpaceInvitationsHandler(this.networkManager, this.dataSpaceManager, signingContext, this.keyring);
|
|
2215
2360
|
this.initialized.wake();
|
|
2216
2361
|
}
|
|
2217
2362
|
};
|
|
2218
2363
|
|
|
2219
2364
|
// packages/sdk/client-services/src/packlets/services/service-definitions.ts
|
|
2220
2365
|
var import_protocols5 = require("@dxos/protocols");
|
|
2221
|
-
var
|
|
2222
|
-
var clientServiceBundle = (0,
|
|
2366
|
+
var import_rpc = require("@dxos/rpc");
|
|
2367
|
+
var clientServiceBundle = (0, import_rpc.createServiceBundle)({
|
|
2223
2368
|
HaloInvitationsService: import_protocols5.schema.getService("dxos.client.services.HaloInvitationsService"),
|
|
2224
2369
|
DevicesService: import_protocols5.schema.getService("dxos.client.services.DevicesService"),
|
|
2225
2370
|
SpaceInvitationsService: import_protocols5.schema.getService("dxos.client.services.SpaceInvitationsService"),
|
|
@@ -2233,15 +2378,15 @@ var clientServiceBundle = (0, import_rpc2.createServiceBundle)({
|
|
|
2233
2378
|
});
|
|
2234
2379
|
|
|
2235
2380
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
2236
|
-
var
|
|
2237
|
-
var
|
|
2238
|
-
var
|
|
2381
|
+
var import_debug5 = require("@dxos/debug");
|
|
2382
|
+
var import_echo_db5 = require("@dxos/echo-db");
|
|
2383
|
+
var import_log11 = require("@dxos/log");
|
|
2239
2384
|
var import_model_factory = require("@dxos/model-factory");
|
|
2240
2385
|
var import_object_model = require("@dxos/object-model");
|
|
2241
2386
|
var import_text_model = require("@dxos/text-model");
|
|
2242
2387
|
|
|
2243
2388
|
// packages/sdk/client-services/src/packlets/identity/devices-service-impl.ts
|
|
2244
|
-
var
|
|
2389
|
+
var import_async13 = require("@dxos/async");
|
|
2245
2390
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
2246
2391
|
var DevicesServiceImpl = class {
|
|
2247
2392
|
constructor(_identityManager) {
|
|
@@ -2267,7 +2412,7 @@ var DevicesServiceImpl = class {
|
|
|
2267
2412
|
});
|
|
2268
2413
|
}
|
|
2269
2414
|
};
|
|
2270
|
-
const dispose = new
|
|
2415
|
+
const dispose = new import_async13.EventSubscriptions();
|
|
2271
2416
|
dispose.add(this._identityManager.stateUpdate.on(() => {
|
|
2272
2417
|
update();
|
|
2273
2418
|
if (this._identityManager.identity) {
|
|
@@ -2302,7 +2447,7 @@ var import_memdown = __toESM(require("memdown"));
|
|
|
2302
2447
|
var import_errors = require("@dxos/errors");
|
|
2303
2448
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
2304
2449
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
2305
|
-
var
|
|
2450
|
+
var import_util5 = require("@dxos/util");
|
|
2306
2451
|
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
2307
2452
|
var createStorageObjects = (config) => {
|
|
2308
2453
|
const { path = "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
|
|
@@ -2327,7 +2472,7 @@ var createStorageObjects = (config) => {
|
|
|
2327
2472
|
};
|
|
2328
2473
|
};
|
|
2329
2474
|
var createKeyStorage = (path, type) => {
|
|
2330
|
-
const defaultedType = type != null ? type : (0,
|
|
2475
|
+
const defaultedType = type != null ? type : (0, import_util5.isNode)() ? "jsondown" : "leveljs";
|
|
2331
2476
|
switch (defaultedType) {
|
|
2332
2477
|
case "leveljs":
|
|
2333
2478
|
return (0, import_level_js.default)(path);
|
|
@@ -2410,20 +2555,20 @@ var ClientServicesHost = class {
|
|
|
2410
2555
|
var _a;
|
|
2411
2556
|
await this._initialize();
|
|
2412
2557
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
2413
|
-
(0,
|
|
2558
|
+
(0, import_log11.log)("opening...", {
|
|
2414
2559
|
deviceKey
|
|
2415
2560
|
}, {
|
|
2416
|
-
file: "
|
|
2561
|
+
file: "service-host.ts",
|
|
2417
2562
|
line: 69,
|
|
2418
2563
|
scope: this,
|
|
2419
2564
|
callSite: (f, a) => f(...a)
|
|
2420
2565
|
});
|
|
2421
2566
|
await this._initialize();
|
|
2422
2567
|
await this._serviceContext.open();
|
|
2423
|
-
(0,
|
|
2568
|
+
(0, import_log11.log)("opened", {
|
|
2424
2569
|
deviceKey
|
|
2425
2570
|
}, {
|
|
2426
|
-
file: "
|
|
2571
|
+
file: "service-host.ts",
|
|
2427
2572
|
line: 72,
|
|
2428
2573
|
scope: this,
|
|
2429
2574
|
callSite: (f, a) => f(...a)
|
|
@@ -2432,19 +2577,19 @@ var ClientServicesHost = class {
|
|
|
2432
2577
|
async close() {
|
|
2433
2578
|
var _a;
|
|
2434
2579
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
2435
|
-
(0,
|
|
2580
|
+
(0, import_log11.log)("closing...", {
|
|
2436
2581
|
deviceKey
|
|
2437
2582
|
}, {
|
|
2438
|
-
file: "
|
|
2583
|
+
file: "service-host.ts",
|
|
2439
2584
|
line: 77,
|
|
2440
2585
|
scope: this,
|
|
2441
2586
|
callSite: (f, a) => f(...a)
|
|
2442
2587
|
});
|
|
2443
2588
|
await this._serviceContext.close();
|
|
2444
|
-
(0,
|
|
2589
|
+
(0, import_log11.log)("closed", {
|
|
2445
2590
|
deviceKey
|
|
2446
2591
|
}, {
|
|
2447
|
-
file: "
|
|
2592
|
+
file: "service-host.ts",
|
|
2448
2593
|
line: 79,
|
|
2449
2594
|
scope: this,
|
|
2450
2595
|
callSite: (f, a) => f(...a)
|
|
@@ -2458,13 +2603,13 @@ var ClientServicesHost = class {
|
|
|
2458
2603
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
2459
2604
|
SpaceInvitationsService: new SpaceInvitationsServiceImpl(this._serviceContext.identityManager, () => {
|
|
2460
2605
|
var _a;
|
|
2461
|
-
return (_a = this._serviceContext.spaceInvitations) != null ? _a : (0,
|
|
2606
|
+
return (_a = this._serviceContext.spaceInvitations) != null ? _a : (0, import_debug5.raise)(new Error("SpaceInvitations not initialized"));
|
|
2462
2607
|
}, () => {
|
|
2463
2608
|
var _a;
|
|
2464
|
-
return (_a = this._serviceContext.
|
|
2609
|
+
return (_a = this._serviceContext.dataSpaceManager) != null ? _a : (0, import_debug5.raise)(new Error("SpaceManager not initialized"));
|
|
2465
2610
|
}),
|
|
2466
2611
|
SpacesService: new SpacesServiceImpl(),
|
|
2467
|
-
DataService: new
|
|
2612
|
+
DataService: new import_echo_db5.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
2468
2613
|
ProfileService: new ProfileServiceImpl(this._serviceContext),
|
|
2469
2614
|
SpaceService: new SpaceServiceImpl(this._serviceContext),
|
|
2470
2615
|
SystemService: new SystemServiceImpl(this._config, this._serviceContext),
|
|
@@ -2479,13 +2624,13 @@ var ClientServicesHost = class {
|
|
|
2479
2624
|
};
|
|
2480
2625
|
|
|
2481
2626
|
// packages/sdk/client-services/src/packlets/services/service-proxy.ts
|
|
2482
|
-
var
|
|
2627
|
+
var import_async14 = require("@dxos/async");
|
|
2483
2628
|
var import_errors2 = require("@dxos/errors");
|
|
2484
|
-
var
|
|
2629
|
+
var import_rpc2 = require("@dxos/rpc");
|
|
2485
2630
|
var ClientServicesProxy = class {
|
|
2486
2631
|
constructor(port, _timeout = 3e4) {
|
|
2487
2632
|
this._timeout = _timeout;
|
|
2488
|
-
this._proxy = (0,
|
|
2633
|
+
this._proxy = (0, import_rpc2.createProtoRpcPeer)({
|
|
2489
2634
|
requested: clientServiceBundle,
|
|
2490
2635
|
exposed: {},
|
|
2491
2636
|
handlers: {},
|
|
@@ -2502,7 +2647,7 @@ var ClientServicesProxy = class {
|
|
|
2502
2647
|
return this._proxy.rpc;
|
|
2503
2648
|
}
|
|
2504
2649
|
async open() {
|
|
2505
|
-
await (0,
|
|
2650
|
+
await (0, import_async14.asyncTimeout)(this._proxy.open(), this._timeout, new import_errors2.RemoteServiceConnectionTimeout());
|
|
2506
2651
|
}
|
|
2507
2652
|
async close() {
|
|
2508
2653
|
await this._proxy.close();
|
|
@@ -2511,7 +2656,7 @@ var ClientServicesProxy = class {
|
|
|
2511
2656
|
|
|
2512
2657
|
// packages/sdk/client-services/src/packlets/vault/iframe-runtime.ts
|
|
2513
2658
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
2514
|
-
var
|
|
2659
|
+
var import_rpc3 = require("@dxos/rpc");
|
|
2515
2660
|
|
|
2516
2661
|
// packages/sdk/client-services/src/packlets/vault/services.ts
|
|
2517
2662
|
var import_protocols6 = require("@dxos/protocols");
|
|
@@ -2530,7 +2675,7 @@ var IFrameRuntime = class {
|
|
|
2530
2675
|
this._systemPort = systemPort;
|
|
2531
2676
|
this._windowAppPort = windowAppPort;
|
|
2532
2677
|
this._workerAppPort = workerAppPort;
|
|
2533
|
-
this._systemRpc = (0,
|
|
2678
|
+
this._systemRpc = (0, import_rpc3.createProtoRpcPeer)({
|
|
2534
2679
|
requested: workerServiceBundle,
|
|
2535
2680
|
exposed: iframeServiceBundle,
|
|
2536
2681
|
handlers: {
|
|
@@ -2559,17 +2704,17 @@ var IFrameRuntime = class {
|
|
|
2559
2704
|
};
|
|
2560
2705
|
|
|
2561
2706
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
2562
|
-
var
|
|
2707
|
+
var import_async16 = require("@dxos/async");
|
|
2563
2708
|
var import_messaging = require("@dxos/messaging");
|
|
2564
2709
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
2565
2710
|
|
|
2566
2711
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
2567
|
-
var
|
|
2568
|
-
var
|
|
2569
|
-
var
|
|
2570
|
-
var
|
|
2571
|
-
var
|
|
2572
|
-
var
|
|
2712
|
+
var import_node_assert11 = __toESM(require("node:assert"));
|
|
2713
|
+
var import_async15 = require("@dxos/async");
|
|
2714
|
+
var import_log12 = require("@dxos/log");
|
|
2715
|
+
var import_rpc4 = require("@dxos/rpc");
|
|
2716
|
+
var import_util6 = require("@dxos/util");
|
|
2717
|
+
var __decorate2 = function(decorators, target, key, desc) {
|
|
2573
2718
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2574
2719
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2575
2720
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2583,13 +2728,13 @@ var WorkerSession = class {
|
|
|
2583
2728
|
constructor({ getServices, systemPort, appPort, options = {
|
|
2584
2729
|
heartbeatInterval: 1e3
|
|
2585
2730
|
} }) {
|
|
2586
|
-
this._startTrigger = new
|
|
2587
|
-
this.onClose = new
|
|
2588
|
-
(0,
|
|
2589
|
-
(0,
|
|
2731
|
+
this._startTrigger = new import_async15.Trigger();
|
|
2732
|
+
this.onClose = new import_util6.Callback();
|
|
2733
|
+
(0, import_node_assert11.default)(options);
|
|
2734
|
+
(0, import_node_assert11.default)(getServices);
|
|
2590
2735
|
this._options = options;
|
|
2591
2736
|
this._getServices = getServices;
|
|
2592
|
-
this._clientRpc = (0,
|
|
2737
|
+
this._clientRpc = (0, import_rpc4.createProtoRpcPeer)({
|
|
2593
2738
|
exposed: clientServiceBundle,
|
|
2594
2739
|
handlers: {
|
|
2595
2740
|
HaloInvitationsService: async () => (await this._getServices()).services.HaloInvitationsService,
|
|
@@ -2605,7 +2750,7 @@ var WorkerSession = class {
|
|
|
2605
2750
|
},
|
|
2606
2751
|
port: appPort
|
|
2607
2752
|
});
|
|
2608
|
-
this._iframeRpc = (0,
|
|
2753
|
+
this._iframeRpc = (0, import_rpc4.createProtoRpcPeer)({
|
|
2609
2754
|
requested: iframeServiceBundle,
|
|
2610
2755
|
exposed: workerServiceBundle,
|
|
2611
2756
|
handlers: {
|
|
@@ -2619,8 +2764,8 @@ var WorkerSession = class {
|
|
|
2619
2764
|
try {
|
|
2620
2765
|
await this.close();
|
|
2621
2766
|
} catch (err) {
|
|
2622
|
-
|
|
2623
|
-
file: "
|
|
2767
|
+
import_log12.log.catch(err, {}, {
|
|
2768
|
+
file: "worker-session.ts",
|
|
2624
2769
|
line: 89,
|
|
2625
2770
|
scope: this,
|
|
2626
2771
|
callSite: (f, a) => f(...a)
|
|
@@ -2636,8 +2781,8 @@ var WorkerSession = class {
|
|
|
2636
2781
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
2637
2782
|
}
|
|
2638
2783
|
async open() {
|
|
2639
|
-
|
|
2640
|
-
file: "
|
|
2784
|
+
import_log12.log.info("opening..", {}, {
|
|
2785
|
+
file: "worker-session.ts",
|
|
2641
2786
|
line: 103,
|
|
2642
2787
|
scope: this,
|
|
2643
2788
|
callSite: (f, a) => f(...a)
|
|
@@ -2653,10 +2798,10 @@ var WorkerSession = class {
|
|
|
2653
2798
|
try {
|
|
2654
2799
|
await this._iframeRpc.rpc.IframeService.heartbeat();
|
|
2655
2800
|
} catch (err1) {
|
|
2656
|
-
|
|
2801
|
+
import_log12.log.warn("Heartbeat failed", {
|
|
2657
2802
|
err: err1
|
|
2658
2803
|
}, {
|
|
2659
|
-
file: "
|
|
2804
|
+
file: "worker-session.ts",
|
|
2660
2805
|
line: 115,
|
|
2661
2806
|
scope: this,
|
|
2662
2807
|
callSite: (f, a) => f(...a)
|
|
@@ -2664,8 +2809,8 @@ var WorkerSession = class {
|
|
|
2664
2809
|
try {
|
|
2665
2810
|
await this.close();
|
|
2666
2811
|
} catch (err) {
|
|
2667
|
-
|
|
2668
|
-
file: "
|
|
2812
|
+
import_log12.log.catch(err, {}, {
|
|
2813
|
+
file: "worker-session.ts",
|
|
2669
2814
|
line: 119,
|
|
2670
2815
|
scope: this,
|
|
2671
2816
|
callSite: (f, a) => f(...a)
|
|
@@ -2675,8 +2820,8 @@ var WorkerSession = class {
|
|
|
2675
2820
|
}, this._options.heartbeatInterval);
|
|
2676
2821
|
}
|
|
2677
2822
|
async close() {
|
|
2678
|
-
|
|
2679
|
-
file: "
|
|
2823
|
+
import_log12.log.info("closing..", {}, {
|
|
2824
|
+
file: "worker-session.ts",
|
|
2680
2825
|
line: 126,
|
|
2681
2826
|
scope: this,
|
|
2682
2827
|
callSite: (f, a) => f(...a)
|
|
@@ -2684,8 +2829,8 @@ var WorkerSession = class {
|
|
|
2684
2829
|
try {
|
|
2685
2830
|
await this.onClose.callIfSet();
|
|
2686
2831
|
} catch (err) {
|
|
2687
|
-
|
|
2688
|
-
file: "
|
|
2832
|
+
import_log12.log.catch(err, {}, {
|
|
2833
|
+
file: "worker-session.ts",
|
|
2689
2834
|
line: 130,
|
|
2690
2835
|
scope: this,
|
|
2691
2836
|
callSite: (f, a) => f(...a)
|
|
@@ -2700,8 +2845,8 @@ var WorkerSession = class {
|
|
|
2700
2845
|
]);
|
|
2701
2846
|
}
|
|
2702
2847
|
};
|
|
2703
|
-
|
|
2704
|
-
|
|
2848
|
+
__decorate2([
|
|
2849
|
+
import_log12.logInfo
|
|
2705
2850
|
], WorkerSession.prototype, "origin", void 0);
|
|
2706
2851
|
|
|
2707
2852
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
@@ -2709,7 +2854,7 @@ var WorkerRuntime = class {
|
|
|
2709
2854
|
constructor(_configProvider) {
|
|
2710
2855
|
this._configProvider = _configProvider;
|
|
2711
2856
|
this._transportFactory = new import_network_manager4.WebRTCTransportProxyFactory();
|
|
2712
|
-
this._ready = new
|
|
2857
|
+
this._ready = new import_async16.Trigger();
|
|
2713
2858
|
this.sessions = /* @__PURE__ */ new Set();
|
|
2714
2859
|
}
|
|
2715
2860
|
async start() {
|
|
@@ -2784,6 +2929,7 @@ var WorkerRuntime = class {
|
|
|
2784
2929
|
ClientServicesProxy,
|
|
2785
2930
|
DevtoolsHostEvents,
|
|
2786
2931
|
DevtoolsServiceImpl,
|
|
2932
|
+
HaloAuthVerifier,
|
|
2787
2933
|
HaloInvitationsHandler,
|
|
2788
2934
|
HaloInvitationsProxy,
|
|
2789
2935
|
HaloInvitationsServiceImpl,
|
|
@@ -2808,7 +2954,6 @@ var WorkerRuntime = class {
|
|
|
2808
2954
|
clientServiceBundle,
|
|
2809
2955
|
createDefaultModelFactory,
|
|
2810
2956
|
createHaloAuthProvider,
|
|
2811
|
-
createHaloAuthVerifier,
|
|
2812
2957
|
createStorageObjects,
|
|
2813
2958
|
getNetworkPeers,
|
|
2814
2959
|
subscribeToFeedBlocks,
|
|
@@ -2820,3 +2965,4 @@ var WorkerRuntime = class {
|
|
|
2820
2965
|
subscribeToSwarmInfo,
|
|
2821
2966
|
wrapObservable
|
|
2822
2967
|
});
|
|
2968
|
+
//# sourceMappingURL=index.cjs.map
|