@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
|
@@ -6,6 +6,7 @@ import { EventSubscriptions } from "@dxos/async";
|
|
|
6
6
|
import { Stream } from "@dxos/codec-protobuf";
|
|
7
7
|
import { todo } from "@dxos/debug";
|
|
8
8
|
import { log } from "@dxos/log";
|
|
9
|
+
import { SpaceMember } from "@dxos/protocols/proto/dxos/client";
|
|
9
10
|
import { humanize } from "@dxos/util";
|
|
10
11
|
var SpaceServiceImpl = class {
|
|
11
12
|
constructor(serviceContext) {
|
|
@@ -28,26 +29,27 @@ var SpaceServiceImpl = class {
|
|
|
28
29
|
return new Stream(({ next }) => {
|
|
29
30
|
const subscriptions = new EventSubscriptions();
|
|
30
31
|
const onUpdate = () => {
|
|
31
|
-
const spaces = Array.from(this.serviceContext.
|
|
32
|
+
const spaces = Array.from(this.serviceContext.dataSpaceManager.spaces.values()).map((space) => ({
|
|
32
33
|
publicKey: space.key,
|
|
33
34
|
isOpen: true,
|
|
34
35
|
isActive: true,
|
|
35
|
-
members: Array.from(space.spaceState.members.values()).map((member) => {
|
|
36
|
-
var _a, _b;
|
|
36
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
37
|
+
var _a, _b, _c;
|
|
37
38
|
return {
|
|
38
39
|
identityKey: member.key,
|
|
39
40
|
profile: {
|
|
40
41
|
identityKey: member.key,
|
|
41
42
|
displayName: (_b = (_a = member.assertion.profile) == null ? void 0 : _a.displayName) != null ? _b : humanize(member.key)
|
|
42
|
-
}
|
|
43
|
+
},
|
|
44
|
+
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 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
|
|
43
45
|
};
|
|
44
46
|
})
|
|
45
47
|
}));
|
|
46
48
|
log("update", {
|
|
47
49
|
spaces
|
|
48
50
|
}, {
|
|
49
|
-
file: "
|
|
50
|
-
line:
|
|
51
|
+
file: "space.ts",
|
|
52
|
+
line: 120,
|
|
51
53
|
scope: this,
|
|
52
54
|
callSite: (f, a) => f(...a)
|
|
53
55
|
});
|
|
@@ -56,20 +58,22 @@ var SpaceServiceImpl = class {
|
|
|
56
58
|
});
|
|
57
59
|
};
|
|
58
60
|
setTimeout(async () => {
|
|
59
|
-
if (!this.serviceContext.
|
|
61
|
+
if (!this.serviceContext.dataSpaceManager) {
|
|
60
62
|
next({
|
|
61
63
|
spaces: []
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
66
|
await this.serviceContext.initialized.wait();
|
|
65
|
-
subscriptions.add(this.serviceContext.
|
|
66
|
-
this.serviceContext.
|
|
67
|
+
subscriptions.add(this.serviceContext.dataSpaceManager.updated.on(() => {
|
|
68
|
+
this.serviceContext.dataSpaceManager.spaces.forEach((space) => {
|
|
67
69
|
subscriptions.add(space.stateUpdate.on(onUpdate));
|
|
70
|
+
subscriptions.add(space.presence.updated.on(onUpdate));
|
|
68
71
|
});
|
|
69
72
|
onUpdate();
|
|
70
73
|
}));
|
|
71
|
-
this.serviceContext.
|
|
74
|
+
this.serviceContext.dataSpaceManager.spaces.forEach((space) => {
|
|
72
75
|
subscriptions.add(space.stateUpdate.on(onUpdate));
|
|
76
|
+
subscriptions.add(space.presence.updated.on(onUpdate));
|
|
73
77
|
});
|
|
74
78
|
onUpdate();
|
|
75
79
|
});
|
|
@@ -81,7 +85,7 @@ var SpaceServiceImpl = class {
|
|
|
81
85
|
}
|
|
82
86
|
async createSpace() {
|
|
83
87
|
await this.serviceContext.initialized.wait();
|
|
84
|
-
const space = await this.serviceContext.
|
|
88
|
+
const space = await this.serviceContext.dataSpaceManager.createSpace();
|
|
85
89
|
return {
|
|
86
90
|
publicKey: space.key,
|
|
87
91
|
isOpen: true,
|
|
@@ -378,7 +382,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => new Stream6(({ next })
|
|
|
378
382
|
};
|
|
379
383
|
const timeout = setTimeout(async () => {
|
|
380
384
|
await context.initialized.wait();
|
|
381
|
-
unsubscribe = context.
|
|
385
|
+
unsubscribe = context.dataSpaceManager.updated.on(() => update());
|
|
382
386
|
await update();
|
|
383
387
|
});
|
|
384
388
|
return () => {
|
|
@@ -475,6 +479,8 @@ var DevtoolsServiceImpl = class {
|
|
|
475
479
|
};
|
|
476
480
|
|
|
477
481
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
482
|
+
import { Trigger } from "@dxos/async";
|
|
483
|
+
import { Context } from "@dxos/context";
|
|
478
484
|
import { verifyCredential } from "@dxos/credentials";
|
|
479
485
|
import { log as log2 } from "@dxos/log";
|
|
480
486
|
import { schema } from "@dxos/protocols";
|
|
@@ -488,76 +494,108 @@ var createHaloAuthProvider = (signer) => async (nonce) => {
|
|
|
488
494
|
});
|
|
489
495
|
return schema.getCodecForType("dxos.halo.credentials.Credential").encode(credential);
|
|
490
496
|
};
|
|
491
|
-
var
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
if (result.kind === "fail") {
|
|
496
|
-
log2("Invalid credential", {
|
|
497
|
-
result
|
|
498
|
-
}, {
|
|
499
|
-
file: "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts",
|
|
500
|
-
line: 34,
|
|
501
|
-
scope: void 0,
|
|
502
|
-
callSite: (f, a) => f(...a)
|
|
503
|
-
});
|
|
504
|
-
return false;
|
|
505
|
-
}
|
|
506
|
-
if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
|
|
507
|
-
log2("Invalid nonce", {
|
|
508
|
-
nonce,
|
|
509
|
-
credential
|
|
510
|
-
}, {
|
|
511
|
-
file: "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts",
|
|
512
|
-
line: 39,
|
|
513
|
-
scope: void 0,
|
|
514
|
-
callSite: (f, a) => f(...a)
|
|
515
|
-
});
|
|
516
|
-
return false;
|
|
497
|
+
var HaloAuthVerifier = class {
|
|
498
|
+
constructor(_params) {
|
|
499
|
+
this._params = _params;
|
|
500
|
+
this._ctx = new Context();
|
|
517
501
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
502
|
+
async close() {
|
|
503
|
+
await this._ctx.dispose();
|
|
504
|
+
}
|
|
505
|
+
_isTrustedDevice(deviceKey) {
|
|
506
|
+
const deviceSet = this._params.trustedDevicesProvider();
|
|
507
|
+
return deviceSet.has(deviceKey);
|
|
508
|
+
}
|
|
509
|
+
get verifier() {
|
|
510
|
+
return async (nonce, auth) => {
|
|
511
|
+
const credential = schema.getCodecForType("dxos.halo.credentials.Credential").decode(auth);
|
|
512
|
+
const result = await verifyCredential(credential);
|
|
513
|
+
if (result.kind === "fail") {
|
|
514
|
+
log2("Invalid credential", {
|
|
515
|
+
result
|
|
516
|
+
}, {
|
|
517
|
+
file: "authenticator.ts",
|
|
518
|
+
line: 61,
|
|
519
|
+
scope: this,
|
|
520
|
+
callSite: (f, a) => f(...a)
|
|
521
|
+
});
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
|
|
525
|
+
log2("Invalid nonce", {
|
|
526
|
+
nonce,
|
|
527
|
+
credential
|
|
528
|
+
}, {
|
|
529
|
+
file: "authenticator.ts",
|
|
530
|
+
line: 66,
|
|
531
|
+
scope: this,
|
|
532
|
+
callSite: (f, a) => f(...a)
|
|
533
|
+
});
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
if (this._isTrustedDevice(credential.issuer)) {
|
|
537
|
+
return true;
|
|
538
|
+
}
|
|
539
|
+
const trigger = new Trigger();
|
|
540
|
+
this._ctx.onDispose(() => {
|
|
541
|
+
trigger.wake(false);
|
|
542
|
+
});
|
|
543
|
+
const clear = this._params.update.on(this._ctx, () => {
|
|
544
|
+
if (this._isTrustedDevice(credential.issuer)) {
|
|
545
|
+
trigger.wake(true);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
try {
|
|
549
|
+
await trigger.wait({
|
|
550
|
+
timeout: this._params.authTimeout
|
|
551
|
+
});
|
|
552
|
+
return true;
|
|
553
|
+
} catch (e) {
|
|
554
|
+
return false;
|
|
555
|
+
} finally {
|
|
556
|
+
clear();
|
|
557
|
+
}
|
|
558
|
+
};
|
|
526
559
|
}
|
|
527
|
-
return true;
|
|
528
560
|
};
|
|
529
561
|
|
|
530
562
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
531
563
|
import assert2 from "@dxos/node-std/assert";
|
|
532
564
|
import { Event } from "@dxos/async";
|
|
533
565
|
import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
|
|
534
|
-
import { failUndefined } from "@dxos/debug";
|
|
535
566
|
import { writeMessages } from "@dxos/feed-store";
|
|
536
567
|
import { log as log3 } from "@dxos/log";
|
|
537
568
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
569
|
+
var AUTH_TIMEOUT = 3e4;
|
|
538
570
|
var Identity = class {
|
|
539
571
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
540
572
|
this.stateUpdate = new Event();
|
|
541
|
-
this.
|
|
573
|
+
this.space = space;
|
|
542
574
|
this._signer = signer;
|
|
543
575
|
this.identityKey = identityKey;
|
|
544
576
|
this.deviceKey = deviceKey;
|
|
545
577
|
this._deviceStateMachine = new DeviceStateMachine(this.identityKey, this.deviceKey);
|
|
546
578
|
this._profileStateMachine = new ProfileStateMachine(this.identityKey);
|
|
547
|
-
this.
|
|
579
|
+
this.space.onCredentialProcessed.set(async (credential) => {
|
|
548
580
|
await this._deviceStateMachine.process(credential);
|
|
549
581
|
await this._profileStateMachine.process(credential);
|
|
550
582
|
this.stateUpdate.emit();
|
|
551
583
|
});
|
|
584
|
+
this.authVerifier = new HaloAuthVerifier({
|
|
585
|
+
trustedDevicesProvider: () => this.authorizedDeviceKeys,
|
|
586
|
+
update: this.stateUpdate,
|
|
587
|
+
authTimeout: AUTH_TIMEOUT
|
|
588
|
+
});
|
|
552
589
|
}
|
|
553
590
|
get authorizedDeviceKeys() {
|
|
554
591
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
555
592
|
}
|
|
556
593
|
async open() {
|
|
557
|
-
await this.
|
|
594
|
+
await this.space.open();
|
|
558
595
|
}
|
|
559
596
|
async close() {
|
|
560
|
-
await this.
|
|
597
|
+
await this.authVerifier.close();
|
|
598
|
+
await this.space.close();
|
|
561
599
|
}
|
|
562
600
|
async ready() {
|
|
563
601
|
await this._deviceStateMachine.deviceChainReady.wait();
|
|
@@ -566,23 +604,19 @@ var Identity = class {
|
|
|
566
604
|
return this._profileStateMachine.profile;
|
|
567
605
|
}
|
|
568
606
|
get controlPipeline() {
|
|
569
|
-
return this.
|
|
607
|
+
return this.space.controlPipeline;
|
|
570
608
|
}
|
|
571
609
|
get haloSpaceKey() {
|
|
572
|
-
return this.
|
|
610
|
+
return this.space.key;
|
|
573
611
|
}
|
|
574
612
|
get haloGenesisFeedKey() {
|
|
575
|
-
return this.
|
|
576
|
-
}
|
|
577
|
-
get haloDatabase() {
|
|
578
|
-
var _a;
|
|
579
|
-
return (_a = this._space.database) != null ? _a : failUndefined();
|
|
613
|
+
return this.space.genesisFeedKey;
|
|
580
614
|
}
|
|
581
615
|
getAdmissionCredentials() {
|
|
582
616
|
return {
|
|
583
617
|
deviceKey: this.deviceKey,
|
|
584
|
-
controlFeedKey: this.
|
|
585
|
-
dataFeedKey: this.
|
|
618
|
+
controlFeedKey: this.space.controlFeedKey,
|
|
619
|
+
dataFeedKey: this.space.dataFeedKey
|
|
586
620
|
};
|
|
587
621
|
}
|
|
588
622
|
getIdentityCredentialSigner() {
|
|
@@ -600,8 +634,8 @@ var Identity = class {
|
|
|
600
634
|
controlFeedKey,
|
|
601
635
|
dataFeedKey
|
|
602
636
|
}, {
|
|
603
|
-
file: "
|
|
604
|
-
line:
|
|
637
|
+
file: "identity.ts",
|
|
638
|
+
line: 147,
|
|
605
639
|
scope: this,
|
|
606
640
|
callSite: (f, a) => f(...a)
|
|
607
641
|
});
|
|
@@ -645,17 +679,17 @@ var Identity = class {
|
|
|
645
679
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
646
680
|
import assert3 from "@dxos/node-std/assert";
|
|
647
681
|
import { Event as Event2 } from "@dxos/async";
|
|
648
|
-
import { CredentialGenerator } from "@dxos/credentials";
|
|
649
|
-
import {
|
|
682
|
+
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
|
|
683
|
+
import { NoopDataPipelineController } from "@dxos/echo-db";
|
|
650
684
|
import { log as log4 } from "@dxos/log";
|
|
651
685
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
686
|
+
import { Presence } from "@dxos/teleport-extension-presence";
|
|
687
|
+
import { deferFunction } from "@dxos/util";
|
|
652
688
|
var IdentityManager = class {
|
|
653
|
-
constructor(_metadataStore,
|
|
689
|
+
constructor(_metadataStore, _keyring, _spaceManager) {
|
|
654
690
|
this._metadataStore = _metadataStore;
|
|
655
|
-
this._feedStore = _feedStore;
|
|
656
691
|
this._keyring = _keyring;
|
|
657
|
-
this.
|
|
658
|
-
this._modelFactory = _modelFactory;
|
|
692
|
+
this._spaceManager = _spaceManager;
|
|
659
693
|
this.stateUpdate = new Event2();
|
|
660
694
|
}
|
|
661
695
|
get identity() {
|
|
@@ -678,8 +712,8 @@ var IdentityManager = class {
|
|
|
678
712
|
async createIdentity({ displayName } = {}) {
|
|
679
713
|
assert3(!this._identity, "Identity already exists.");
|
|
680
714
|
log4("creating identity...", {}, {
|
|
681
|
-
file: "
|
|
682
|
-
line:
|
|
715
|
+
file: "identity-manager.ts",
|
|
716
|
+
line: 72,
|
|
683
717
|
scope: this,
|
|
684
718
|
callSite: (f, a) => f(...a)
|
|
685
719
|
});
|
|
@@ -723,8 +757,8 @@ var IdentityManager = class {
|
|
|
723
757
|
identityKey: identity.identityKey,
|
|
724
758
|
deviceKey: identity.deviceKey
|
|
725
759
|
}, {
|
|
726
|
-
file: "
|
|
727
|
-
line:
|
|
760
|
+
file: "identity-manager.ts",
|
|
761
|
+
line: 131,
|
|
728
762
|
scope: this,
|
|
729
763
|
callSite: (f, a) => f(...a)
|
|
730
764
|
});
|
|
@@ -734,8 +768,8 @@ var IdentityManager = class {
|
|
|
734
768
|
log4("accepting identity", {
|
|
735
769
|
params
|
|
736
770
|
}, {
|
|
737
|
-
file: "
|
|
738
|
-
line:
|
|
771
|
+
file: "identity-manager.ts",
|
|
772
|
+
line: 139,
|
|
739
773
|
scope: this,
|
|
740
774
|
callSite: (f, a) => f(...a)
|
|
741
775
|
});
|
|
@@ -762,8 +796,8 @@ var IdentityManager = class {
|
|
|
762
796
|
log4("constructing identity", {
|
|
763
797
|
identityRecord
|
|
764
798
|
}, {
|
|
765
|
-
file: "
|
|
766
|
-
line:
|
|
799
|
+
file: "identity-manager.ts",
|
|
800
|
+
line: 163,
|
|
767
801
|
scope: this,
|
|
768
802
|
callSite: (f, a) => f(...a)
|
|
769
803
|
});
|
|
@@ -771,46 +805,43 @@ var IdentityManager = class {
|
|
|
771
805
|
spaceRecord: identityRecord.haloSpace,
|
|
772
806
|
swarmIdentity: {
|
|
773
807
|
peerKey: identityRecord.deviceKey,
|
|
774
|
-
credentialProvider:
|
|
775
|
-
credentialAuthenticator:
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
log4("done", {
|
|
808
|
+
credentialProvider: createHaloAuthProvider(createCredentialSignerWithKey2(this._keyring, identityRecord.deviceKey)),
|
|
809
|
+
credentialAuthenticator: deferFunction(() => identity.authVerifier.verifier)
|
|
810
|
+
},
|
|
779
811
|
identityKey: identityRecord.identityKey
|
|
780
|
-
}, {
|
|
781
|
-
file: "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts",
|
|
782
|
-
line: 184,
|
|
783
|
-
scope: this,
|
|
784
|
-
callSite: (f, a) => f(...a)
|
|
785
812
|
});
|
|
786
|
-
|
|
813
|
+
const identity = new Identity({
|
|
787
814
|
space,
|
|
788
815
|
signer: this._keyring,
|
|
789
816
|
identityKey: identityRecord.identityKey,
|
|
790
817
|
deviceKey: identityRecord.deviceKey
|
|
791
818
|
});
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
});
|
|
800
|
-
const genesisFeed = await this._feedStore.openFeed(spaceRecord.genesisFeedKey);
|
|
801
|
-
const protocol = new SpaceProtocol({
|
|
802
|
-
topic: spaceRecord.spaceKey,
|
|
803
|
-
identity: swarmIdentity,
|
|
804
|
-
networkManager: this._networkManager
|
|
819
|
+
log4("done", {
|
|
820
|
+
identityKey: identityRecord.identityKey
|
|
821
|
+
}, {
|
|
822
|
+
file: "identity-manager.ts",
|
|
823
|
+
line: 182,
|
|
824
|
+
scope: this,
|
|
825
|
+
callSite: (f, a) => f(...a)
|
|
805
826
|
});
|
|
806
|
-
return
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
827
|
+
return identity;
|
|
828
|
+
}
|
|
829
|
+
async _constructSpace({ spaceRecord, swarmIdentity, identityKey }) {
|
|
830
|
+
return this._spaceManager.constructSpace({
|
|
831
|
+
metadata: {
|
|
832
|
+
key: spaceRecord.spaceKey,
|
|
833
|
+
genesisFeedKey: spaceRecord.genesisFeedKey,
|
|
834
|
+
controlFeedKey: spaceRecord.writeControlFeedKey,
|
|
835
|
+
dataFeedKey: spaceRecord.writeDataFeedKey
|
|
836
|
+
},
|
|
837
|
+
dataPipelineControllerProvider: () => new NoopDataPipelineController(),
|
|
838
|
+
swarmIdentity,
|
|
839
|
+
presence: new Presence({
|
|
840
|
+
localPeerId: swarmIdentity.peerKey,
|
|
841
|
+
announceInterval: 1e3,
|
|
842
|
+
offlineTimeout: 3e4,
|
|
843
|
+
identityKey
|
|
844
|
+
})
|
|
814
845
|
});
|
|
815
846
|
}
|
|
816
847
|
};
|
|
@@ -831,16 +862,17 @@ var InvitationEncoder = class {
|
|
|
831
862
|
|
|
832
863
|
// packages/sdk/client-services/src/packlets/invitations/halo-invitations-handler.ts
|
|
833
864
|
import assert5 from "@dxos/node-std/assert";
|
|
834
|
-
import { scheduleTask, sleep, Trigger } from "@dxos/async";
|
|
835
|
-
import { Context } from "@dxos/context";
|
|
865
|
+
import { scheduleTask, sleep, Trigger as Trigger2 } from "@dxos/async";
|
|
866
|
+
import { Context as Context2 } from "@dxos/context";
|
|
836
867
|
import { generatePasscode } from "@dxos/credentials";
|
|
837
|
-
import { failUndefined
|
|
868
|
+
import { failUndefined } from "@dxos/debug";
|
|
838
869
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
839
870
|
import { log as log5 } from "@dxos/log";
|
|
840
871
|
import { createTeleportProtocolFactory, StarTopology } from "@dxos/network-manager";
|
|
841
872
|
import { schema as schema3 } from "@dxos/protocols";
|
|
842
873
|
import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
843
874
|
import { AuthenticationResponse } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
875
|
+
import { RpcExtension } from "@dxos/teleport";
|
|
844
876
|
|
|
845
877
|
// packages/sdk/client-services/src/packlets/invitations/invitations.ts
|
|
846
878
|
import assert4 from "@dxos/node-std/assert";
|
|
@@ -889,45 +921,6 @@ var AbstractInvitationsHandler = class {
|
|
|
889
921
|
}
|
|
890
922
|
};
|
|
891
923
|
|
|
892
|
-
// packages/sdk/client-services/src/packlets/invitations/rpc-extension.ts
|
|
893
|
-
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
894
|
-
var RpcExtension = class {
|
|
895
|
-
constructor(_params) {
|
|
896
|
-
this._params = _params;
|
|
897
|
-
}
|
|
898
|
-
get initiator() {
|
|
899
|
-
return this._extensionContext.initiator;
|
|
900
|
-
}
|
|
901
|
-
get localPeerId() {
|
|
902
|
-
return this._extensionContext.localPeerId;
|
|
903
|
-
}
|
|
904
|
-
get remotePeerId() {
|
|
905
|
-
return this._extensionContext.remotePeerId;
|
|
906
|
-
}
|
|
907
|
-
get rpc() {
|
|
908
|
-
return this._rpc.rpc;
|
|
909
|
-
}
|
|
910
|
-
async onOpen(context) {
|
|
911
|
-
this._extensionContext = context;
|
|
912
|
-
const handlers = await this.getHandlers();
|
|
913
|
-
const port = context.createPort("rpc", {
|
|
914
|
-
contentType: 'application/x-protobuf; messageType="dxos.rpc.Message"'
|
|
915
|
-
});
|
|
916
|
-
this._rpc = createProtoRpcPeer({
|
|
917
|
-
...this._params,
|
|
918
|
-
handlers,
|
|
919
|
-
port
|
|
920
|
-
});
|
|
921
|
-
await this._rpc.open();
|
|
922
|
-
}
|
|
923
|
-
async onClose(err) {
|
|
924
|
-
await this._rpc.close();
|
|
925
|
-
}
|
|
926
|
-
close() {
|
|
927
|
-
this._extensionContext.close();
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
|
-
|
|
931
924
|
// packages/sdk/client-services/src/packlets/invitations/halo-invitations-handler.ts
|
|
932
925
|
var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
933
926
|
constructor(networkManager, _identityManager) {
|
|
@@ -938,14 +931,14 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
938
931
|
var _a;
|
|
939
932
|
const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
|
|
940
933
|
assert5(type !== Invitation2.Type.OFFLINE);
|
|
941
|
-
const identity = (_a = this._identityManager.identity) != null ? _a :
|
|
934
|
+
const identity = (_a = this._identityManager.identity) != null ? _a : failUndefined();
|
|
942
935
|
const invitation = {
|
|
943
936
|
type,
|
|
944
937
|
invitationId: PublicKey3.random().toHex(),
|
|
945
938
|
swarmKey: swarmKey != null ? swarmKey : PublicKey3.random(),
|
|
946
939
|
authenticationCode: generatePasscode(AUTHENTICATION_CODE_LENGTH)
|
|
947
940
|
};
|
|
948
|
-
const ctx = new
|
|
941
|
+
const ctx = new Context2({
|
|
949
942
|
onError: (err) => {
|
|
950
943
|
void ctx.dispose();
|
|
951
944
|
observable.callback.onError(err);
|
|
@@ -955,7 +948,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
955
948
|
await ctx.dispose();
|
|
956
949
|
});
|
|
957
950
|
let authenticationCode;
|
|
958
|
-
const complete = new
|
|
951
|
+
const complete = new Trigger2();
|
|
959
952
|
const createExtension = () => {
|
|
960
953
|
const hostInvitationExtension = new HostHaloInvitationExtension({
|
|
961
954
|
requestAdmission: async () => {
|
|
@@ -963,8 +956,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
963
956
|
log5("responding with admission offer", {
|
|
964
957
|
host: identity.deviceKey
|
|
965
958
|
}, {
|
|
966
|
-
file: "
|
|
967
|
-
line:
|
|
959
|
+
file: "halo-invitations-handler.ts",
|
|
960
|
+
line: 84,
|
|
968
961
|
scope: this,
|
|
969
962
|
callSite: (f, a) => f(...a)
|
|
970
963
|
});
|
|
@@ -979,8 +972,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
979
972
|
log5("received authentication request", {
|
|
980
973
|
authenticationCode: code
|
|
981
974
|
}, {
|
|
982
|
-
file: "
|
|
983
|
-
line:
|
|
975
|
+
file: "halo-invitations-handler.ts",
|
|
976
|
+
line: 98,
|
|
984
977
|
scope: this,
|
|
985
978
|
callSite: (f, a) => f(...a)
|
|
986
979
|
});
|
|
@@ -1000,8 +993,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1000
993
|
host: identity.deviceKey,
|
|
1001
994
|
guest: credentials.deviceKey
|
|
1002
995
|
}, {
|
|
1003
|
-
file: "
|
|
1004
|
-
line:
|
|
996
|
+
file: "halo-invitations-handler.ts",
|
|
997
|
+
line: 113,
|
|
1005
998
|
scope: this,
|
|
1006
999
|
callSite: (f, a) => f(...a)
|
|
1007
1000
|
});
|
|
@@ -1019,8 +1012,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1019
1012
|
log5("connected", {
|
|
1020
1013
|
host: identity.deviceKey
|
|
1021
1014
|
}, {
|
|
1022
|
-
file: "
|
|
1023
|
-
line:
|
|
1015
|
+
file: "halo-invitations-handler.ts",
|
|
1016
|
+
line: 129,
|
|
1024
1017
|
scope: this,
|
|
1025
1018
|
callSite: (f, a) => f(...a)
|
|
1026
1019
|
});
|
|
@@ -1032,8 +1025,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1032
1025
|
host: identity.deviceKey,
|
|
1033
1026
|
guest: deviceKey
|
|
1034
1027
|
}, {
|
|
1035
|
-
file: "
|
|
1036
|
-
line:
|
|
1028
|
+
file: "halo-invitations-handler.ts",
|
|
1029
|
+
line: 132,
|
|
1037
1030
|
scope: this,
|
|
1038
1031
|
callSite: (f, a) => f(...a)
|
|
1039
1032
|
});
|
|
@@ -1041,8 +1034,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1041
1034
|
} catch (err) {
|
|
1042
1035
|
if (!observable.cancelled) {
|
|
1043
1036
|
log5.error("failed", err, {
|
|
1044
|
-
file: "
|
|
1045
|
-
line:
|
|
1037
|
+
file: "halo-invitations-handler.ts",
|
|
1038
|
+
line: 136,
|
|
1046
1039
|
scope: this,
|
|
1047
1040
|
callSite: (f, a) => f(...a)
|
|
1048
1041
|
});
|
|
@@ -1075,13 +1068,13 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1075
1068
|
}
|
|
1076
1069
|
acceptInvitation(invitation, options) {
|
|
1077
1070
|
const { timeout = INVITATION_TIMEOUT } = options != null ? options : {};
|
|
1078
|
-
const ctx = new
|
|
1071
|
+
const ctx = new Context2({
|
|
1079
1072
|
onError: (err) => {
|
|
1080
1073
|
void ctx.dispose();
|
|
1081
1074
|
observable.callback.onError(err);
|
|
1082
1075
|
}
|
|
1083
1076
|
});
|
|
1084
|
-
const authenticated = new
|
|
1077
|
+
const authenticated = new Trigger2();
|
|
1085
1078
|
const observable = new AuthenticatingInvitationProvider({
|
|
1086
1079
|
onCancel: async () => {
|
|
1087
1080
|
await ctx.dispose();
|
|
@@ -1091,7 +1084,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1091
1084
|
}
|
|
1092
1085
|
});
|
|
1093
1086
|
let connectionCount = 0;
|
|
1094
|
-
const complete = new
|
|
1087
|
+
const complete = new Trigger2();
|
|
1095
1088
|
const createExtension = () => {
|
|
1096
1089
|
const extension = new GuestHaloInvitationExtension({
|
|
1097
1090
|
onOpen: () => {
|
|
@@ -1102,23 +1095,23 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1102
1095
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
1103
1096
|
}
|
|
1104
1097
|
log5("connected", {}, {
|
|
1105
|
-
file: "
|
|
1106
|
-
line:
|
|
1098
|
+
file: "halo-invitations-handler.ts",
|
|
1099
|
+
line: 209,
|
|
1107
1100
|
scope: this,
|
|
1108
1101
|
callSite: (f, a) => f(...a)
|
|
1109
1102
|
});
|
|
1110
1103
|
(_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
|
|
1111
1104
|
log5("sending admission request", {}, {
|
|
1112
|
-
file: "
|
|
1113
|
-
line:
|
|
1105
|
+
file: "halo-invitations-handler.ts",
|
|
1106
|
+
line: 213,
|
|
1114
1107
|
scope: this,
|
|
1115
1108
|
callSite: (f, a) => f(...a)
|
|
1116
1109
|
});
|
|
1117
1110
|
const { identityKey, haloSpaceKey, genesisFeedKey } = await extension.rpc.HaloHostService.requestAdmission();
|
|
1118
1111
|
if (invitation.type === void 0 || invitation.type === Invitation2.Type.INTERACTIVE) {
|
|
1119
1112
|
log5("guest waiting for authentication code...", {}, {
|
|
1120
|
-
file: "
|
|
1121
|
-
line:
|
|
1113
|
+
file: "halo-invitations-handler.ts",
|
|
1114
|
+
line: 220,
|
|
1122
1115
|
scope: this,
|
|
1123
1116
|
callSite: (f, a) => f(...a)
|
|
1124
1117
|
});
|
|
@@ -1127,8 +1120,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1127
1120
|
timeout
|
|
1128
1121
|
});
|
|
1129
1122
|
log5("sending authentication request", {}, {
|
|
1130
|
-
file: "
|
|
1131
|
-
line:
|
|
1123
|
+
file: "halo-invitations-handler.ts",
|
|
1124
|
+
line: 223,
|
|
1132
1125
|
scope: this,
|
|
1133
1126
|
callSite: (f, a) => f(...a)
|
|
1134
1127
|
});
|
|
@@ -1145,8 +1138,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1145
1138
|
guest: identity.deviceKey,
|
|
1146
1139
|
identityKey
|
|
1147
1140
|
}, {
|
|
1148
|
-
file: "
|
|
1149
|
-
line:
|
|
1141
|
+
file: "halo-invitations-handler.ts",
|
|
1142
|
+
line: 236,
|
|
1150
1143
|
scope: this,
|
|
1151
1144
|
callSite: (f, a) => f(...a)
|
|
1152
1145
|
});
|
|
@@ -1155,8 +1148,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1155
1148
|
guest: identity.deviceKey,
|
|
1156
1149
|
identityKey
|
|
1157
1150
|
}, {
|
|
1158
|
-
file: "
|
|
1159
|
-
line:
|
|
1151
|
+
file: "halo-invitations-handler.ts",
|
|
1152
|
+
line: 240,
|
|
1160
1153
|
scope: this,
|
|
1161
1154
|
callSite: (f, a) => f(...a)
|
|
1162
1155
|
});
|
|
@@ -1164,8 +1157,8 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1164
1157
|
} catch (err) {
|
|
1165
1158
|
if (!observable.cancelled) {
|
|
1166
1159
|
log5.warn("auth failed", err, {
|
|
1167
|
-
file: "
|
|
1168
|
-
line:
|
|
1160
|
+
file: "halo-invitations-handler.ts",
|
|
1161
|
+
line: 244,
|
|
1169
1162
|
scope: this,
|
|
1170
1163
|
callSite: (f, a) => f(...a)
|
|
1171
1164
|
});
|
|
@@ -1298,7 +1291,7 @@ var AbstractInvitationsProxy = class {
|
|
|
1298
1291
|
}
|
|
1299
1292
|
default: {
|
|
1300
1293
|
log6.error(`Invalid state: ${invitation2.state}`, {}, {
|
|
1301
|
-
file: "
|
|
1294
|
+
file: "invitations-proxy.ts",
|
|
1302
1295
|
line: 81,
|
|
1303
1296
|
scope: this,
|
|
1304
1297
|
callSite: (f, a) => f(...a)
|
|
@@ -1364,7 +1357,7 @@ var AbstractInvitationsProxy = class {
|
|
|
1364
1357
|
}
|
|
1365
1358
|
default: {
|
|
1366
1359
|
log6.error(`Invalid state: ${invitation2.state}`, {}, {
|
|
1367
|
-
file: "
|
|
1360
|
+
file: "invitations-proxy.ts",
|
|
1368
1361
|
line: 146,
|
|
1369
1362
|
scope: this,
|
|
1370
1363
|
callSite: (f, a) => f(...a)
|
|
@@ -1410,7 +1403,7 @@ var AbstractInvitationsService = class {
|
|
|
1410
1403
|
const invitationsHandler = this._getInvitationsHandler();
|
|
1411
1404
|
const context = this.getContext(invitation);
|
|
1412
1405
|
log7("stream opened", this.getLoggingContext(), {
|
|
1413
|
-
file: "
|
|
1406
|
+
file: "invitations-service.ts",
|
|
1414
1407
|
line: 43,
|
|
1415
1408
|
scope: this,
|
|
1416
1409
|
callSite: (f, a) => f(...a)
|
|
@@ -1468,14 +1461,14 @@ var AbstractInvitationsService = class {
|
|
|
1468
1461
|
...context2,
|
|
1469
1462
|
err
|
|
1470
1463
|
}, {
|
|
1471
|
-
file: "
|
|
1464
|
+
file: "invitations-service.ts",
|
|
1472
1465
|
line: 92,
|
|
1473
1466
|
scope: this,
|
|
1474
1467
|
callSite: (f, a) => f(...a)
|
|
1475
1468
|
});
|
|
1476
1469
|
} else {
|
|
1477
1470
|
log7("stream closed", context2, {
|
|
1478
|
-
file: "
|
|
1471
|
+
file: "invitations-service.ts",
|
|
1479
1472
|
line: 94,
|
|
1480
1473
|
scope: this,
|
|
1481
1474
|
callSite: (f, a) => f(...a)
|
|
@@ -1488,7 +1481,7 @@ var AbstractInvitationsService = class {
|
|
|
1488
1481
|
acceptInvitation(invitation, options) {
|
|
1489
1482
|
return new Stream8(({ next, close }) => {
|
|
1490
1483
|
log7("stream opened", this.getLoggingContext(), {
|
|
1491
|
-
file: "
|
|
1484
|
+
file: "invitations-service.ts",
|
|
1492
1485
|
line: 104,
|
|
1493
1486
|
scope: this,
|
|
1494
1487
|
callSite: (f, a) => f(...a)
|
|
@@ -1542,14 +1535,14 @@ var AbstractInvitationsService = class {
|
|
|
1542
1535
|
...context,
|
|
1543
1536
|
err
|
|
1544
1537
|
}, {
|
|
1545
|
-
file: "
|
|
1538
|
+
file: "invitations-service.ts",
|
|
1546
1539
|
line: 152,
|
|
1547
1540
|
scope: this,
|
|
1548
1541
|
callSite: (f, a) => f(...a)
|
|
1549
1542
|
});
|
|
1550
1543
|
} else {
|
|
1551
1544
|
log7("stream closed", context, {
|
|
1552
|
-
file: "
|
|
1545
|
+
file: "invitations-service.ts",
|
|
1553
1546
|
line: 154,
|
|
1554
1547
|
scope: this,
|
|
1555
1548
|
callSite: (f, a) => f(...a)
|
|
@@ -1561,7 +1554,7 @@ var AbstractInvitationsService = class {
|
|
|
1561
1554
|
}
|
|
1562
1555
|
async authenticate({ invitationId, authenticationCode }) {
|
|
1563
1556
|
log7("authenticating...", {}, {
|
|
1564
|
-
file: "
|
|
1557
|
+
file: "invitations-service.ts",
|
|
1565
1558
|
line: 163,
|
|
1566
1559
|
scope: this,
|
|
1567
1560
|
callSite: (f, a) => f(...a)
|
|
@@ -1572,7 +1565,7 @@ var AbstractInvitationsService = class {
|
|
|
1572
1565
|
log7.warn("invalid invitation", {
|
|
1573
1566
|
invitationId
|
|
1574
1567
|
}, {
|
|
1575
|
-
file: "
|
|
1568
|
+
file: "invitations-service.ts",
|
|
1576
1569
|
line: 167,
|
|
1577
1570
|
scope: this,
|
|
1578
1571
|
callSite: (f, a) => f(...a)
|
|
@@ -1584,7 +1577,7 @@ var AbstractInvitationsService = class {
|
|
|
1584
1577
|
async cancelInvitation(invitation) {
|
|
1585
1578
|
var _a;
|
|
1586
1579
|
log7("cancelling...", {}, {
|
|
1587
|
-
file: "
|
|
1580
|
+
file: "invitations-service.ts",
|
|
1588
1581
|
line: 174,
|
|
1589
1582
|
scope: this,
|
|
1590
1583
|
callSite: (f, a) => f(...a)
|
|
@@ -1595,7 +1588,7 @@ var AbstractInvitationsService = class {
|
|
|
1595
1588
|
log7.warn("invalid invitation", {
|
|
1596
1589
|
invitationId: invitation.invitationId
|
|
1597
1590
|
}, {
|
|
1598
|
-
file: "
|
|
1591
|
+
file: "invitations-service.ts",
|
|
1599
1592
|
line: 179,
|
|
1600
1593
|
scope: this,
|
|
1601
1594
|
callSite: (f, a) => f(...a)
|
|
@@ -1618,8 +1611,8 @@ var HaloInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
1618
1611
|
|
|
1619
1612
|
// packages/sdk/client-services/src/packlets/invitations/space-invitations-handler.ts
|
|
1620
1613
|
import assert8 from "@dxos/node-std/assert";
|
|
1621
|
-
import { scheduleTask as scheduleTask2, sleep as sleep2, Trigger as
|
|
1622
|
-
import { Context as
|
|
1614
|
+
import { scheduleTask as scheduleTask2, sleep as sleep2, Trigger as Trigger3 } from "@dxos/async";
|
|
1615
|
+
import { Context as Context3 } from "@dxos/context";
|
|
1623
1616
|
import { createAdmissionCredentials, generatePasscode as generatePasscode2, getCredentialAssertion } from "@dxos/credentials";
|
|
1624
1617
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
1625
1618
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
@@ -1628,6 +1621,7 @@ import { createTeleportProtocolFactory as createTeleportProtocolFactory2, StarTo
|
|
|
1628
1621
|
import { schema as schema4 } from "@dxos/protocols";
|
|
1629
1622
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1630
1623
|
import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1624
|
+
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
1631
1625
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1632
1626
|
var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
1633
1627
|
constructor(networkManager, _spaceManager, _signingContext, _keyring) {
|
|
@@ -1648,7 +1642,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1648
1642
|
spaceKey: space.key,
|
|
1649
1643
|
authenticationCode: generatePasscode2(AUTHENTICATION_CODE_LENGTH)
|
|
1650
1644
|
};
|
|
1651
|
-
const ctx = new
|
|
1645
|
+
const ctx = new Context3({
|
|
1652
1646
|
onError: (err) => {
|
|
1653
1647
|
void ctx.dispose();
|
|
1654
1648
|
observable.callback.onError(err);
|
|
@@ -1659,7 +1653,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1659
1653
|
});
|
|
1660
1654
|
let authenticationCode;
|
|
1661
1655
|
let authenticationRetry = 0;
|
|
1662
|
-
const complete = new
|
|
1656
|
+
const complete = new Trigger3();
|
|
1663
1657
|
const createExtension = () => {
|
|
1664
1658
|
let guestProfile;
|
|
1665
1659
|
const hostInvitationExtension = new HostSpaceInvitationExtension({
|
|
@@ -1670,8 +1664,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1670
1664
|
host: this._signingContext.deviceKey,
|
|
1671
1665
|
spaceKey: space.key
|
|
1672
1666
|
}, {
|
|
1673
|
-
file: "
|
|
1674
|
-
line:
|
|
1667
|
+
file: "space-invitations-handler.ts",
|
|
1668
|
+
line: 98,
|
|
1675
1669
|
scope: this,
|
|
1676
1670
|
callSite: (f, a) => f(...a)
|
|
1677
1671
|
});
|
|
@@ -1682,8 +1676,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1682
1676
|
log8("received authentication request", {
|
|
1683
1677
|
authenticationCode: code
|
|
1684
1678
|
}, {
|
|
1685
|
-
file: "
|
|
1686
|
-
line:
|
|
1679
|
+
file: "space-invitations-handler.ts",
|
|
1680
|
+
line: 112,
|
|
1687
1681
|
scope: this,
|
|
1688
1682
|
callSite: (f, a) => f(...a)
|
|
1689
1683
|
});
|
|
@@ -1712,16 +1706,16 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1712
1706
|
host: this._signingContext.deviceKey,
|
|
1713
1707
|
guest: deviceKey
|
|
1714
1708
|
}, {
|
|
1715
|
-
file: "
|
|
1716
|
-
line:
|
|
1709
|
+
file: "space-invitations-handler.ts",
|
|
1710
|
+
line: 136,
|
|
1717
1711
|
scope: this,
|
|
1718
1712
|
callSite: (f, a) => f(...a)
|
|
1719
1713
|
});
|
|
1720
|
-
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, deviceKey, space.key, controlFeedKey, dataFeedKey, space.genesisFeedKey, guestProfile);
|
|
1714
|
+
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, deviceKey, space.key, controlFeedKey, dataFeedKey, space.inner.genesisFeedKey, guestProfile);
|
|
1721
1715
|
assert8(credentials[0]["@type"] === "dxos.echo.feed.CredentialsMessage");
|
|
1722
1716
|
const spaceMemberCredential = credentials[0].credential;
|
|
1723
1717
|
assert8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
1724
|
-
await writeMessages2(space.controlPipeline.writer, credentials);
|
|
1718
|
+
await writeMessages2(space.inner.controlPipeline.writer, credentials);
|
|
1725
1719
|
complete.wake(deviceKey);
|
|
1726
1720
|
return {
|
|
1727
1721
|
credential: spaceMemberCredential
|
|
@@ -1738,8 +1732,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1738
1732
|
log8("connected", {
|
|
1739
1733
|
host: this._signingContext.deviceKey
|
|
1740
1734
|
}, {
|
|
1741
|
-
file: "
|
|
1742
|
-
line:
|
|
1735
|
+
file: "space-invitations-handler.ts",
|
|
1736
|
+
line: 170,
|
|
1743
1737
|
scope: this,
|
|
1744
1738
|
callSite: (f, a) => f(...a)
|
|
1745
1739
|
});
|
|
@@ -1751,8 +1745,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1751
1745
|
host: this._signingContext.deviceKey,
|
|
1752
1746
|
guest: deviceKey
|
|
1753
1747
|
}, {
|
|
1754
|
-
file: "
|
|
1755
|
-
line:
|
|
1748
|
+
file: "space-invitations-handler.ts",
|
|
1749
|
+
line: 173,
|
|
1756
1750
|
scope: this,
|
|
1757
1751
|
callSite: (f, a) => f(...a)
|
|
1758
1752
|
});
|
|
@@ -1760,8 +1754,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1760
1754
|
} catch (err) {
|
|
1761
1755
|
if (!observable.cancelled) {
|
|
1762
1756
|
log8.error("failed", err, {
|
|
1763
|
-
file: "
|
|
1764
|
-
line:
|
|
1757
|
+
file: "space-invitations-handler.ts",
|
|
1758
|
+
line: 177,
|
|
1765
1759
|
scope: this,
|
|
1766
1760
|
callSite: (f, a) => f(...a)
|
|
1767
1761
|
});
|
|
@@ -1794,13 +1788,13 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1794
1788
|
}
|
|
1795
1789
|
acceptInvitation(invitation, options) {
|
|
1796
1790
|
const { timeout = INVITATION_TIMEOUT } = options != null ? options : {};
|
|
1797
|
-
const ctx = new
|
|
1791
|
+
const ctx = new Context3({
|
|
1798
1792
|
onError: (err) => {
|
|
1799
1793
|
void ctx.dispose();
|
|
1800
1794
|
observable.callback.onError(err);
|
|
1801
1795
|
}
|
|
1802
1796
|
});
|
|
1803
|
-
const authenticated = new
|
|
1797
|
+
const authenticated = new Trigger3();
|
|
1804
1798
|
const observable = new AuthenticatingInvitationProvider({
|
|
1805
1799
|
onCancel: async () => {
|
|
1806
1800
|
await ctx.dispose();
|
|
@@ -1810,7 +1804,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1810
1804
|
}
|
|
1811
1805
|
});
|
|
1812
1806
|
let connectionCount = 0;
|
|
1813
|
-
const complete = new
|
|
1807
|
+
const complete = new Trigger3();
|
|
1814
1808
|
const createExtension = () => {
|
|
1815
1809
|
const extension = new GuestSpaceInvitationExtension({
|
|
1816
1810
|
onOpen: () => {
|
|
@@ -1823,8 +1817,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1823
1817
|
log8("connected", {
|
|
1824
1818
|
guest: this._signingContext.deviceKey
|
|
1825
1819
|
}, {
|
|
1826
|
-
file: "
|
|
1827
|
-
line:
|
|
1820
|
+
file: "space-invitations-handler.ts",
|
|
1821
|
+
line: 248,
|
|
1828
1822
|
scope: this,
|
|
1829
1823
|
callSite: (f, a) => f(...a)
|
|
1830
1824
|
});
|
|
@@ -1832,8 +1826,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1832
1826
|
log8("introduce", {
|
|
1833
1827
|
guest: this._signingContext.deviceKey
|
|
1834
1828
|
}, {
|
|
1835
|
-
file: "
|
|
1836
|
-
line:
|
|
1829
|
+
file: "space-invitations-handler.ts",
|
|
1830
|
+
line: 252,
|
|
1837
1831
|
scope: this,
|
|
1838
1832
|
callSite: (f, a) => f(...a)
|
|
1839
1833
|
});
|
|
@@ -1843,8 +1837,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1843
1837
|
if (invitation.type === void 0 || invitation.type === Invitation5.Type.INTERACTIVE) {
|
|
1844
1838
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1845
1839
|
log8("guest waiting for authentication code...", {}, {
|
|
1846
|
-
file: "
|
|
1847
|
-
line:
|
|
1840
|
+
file: "space-invitations-handler.ts",
|
|
1841
|
+
line: 261,
|
|
1848
1842
|
scope: this,
|
|
1849
1843
|
callSite: (f, a) => f(...a)
|
|
1850
1844
|
});
|
|
@@ -1853,8 +1847,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1853
1847
|
timeout
|
|
1854
1848
|
});
|
|
1855
1849
|
log8("sending authentication request", {}, {
|
|
1856
|
-
file: "
|
|
1857
|
-
line:
|
|
1850
|
+
file: "space-invitations-handler.ts",
|
|
1851
|
+
line: 265,
|
|
1858
1852
|
scope: this,
|
|
1859
1853
|
callSite: (f, a) => f(...a)
|
|
1860
1854
|
});
|
|
@@ -1871,8 +1865,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1871
1865
|
log8("retrying invalid code", {
|
|
1872
1866
|
attempt
|
|
1873
1867
|
}, {
|
|
1874
|
-
file: "
|
|
1875
|
-
line:
|
|
1868
|
+
file: "space-invitations-handler.ts",
|
|
1869
|
+
line: 275,
|
|
1876
1870
|
scope: this,
|
|
1877
1871
|
callSite: (f, a) => f(...a)
|
|
1878
1872
|
});
|
|
@@ -1886,8 +1880,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1886
1880
|
log8("request admission", {
|
|
1887
1881
|
guest: this._signingContext.deviceKey
|
|
1888
1882
|
}, {
|
|
1889
|
-
file: "
|
|
1890
|
-
line:
|
|
1883
|
+
file: "space-invitations-handler.ts",
|
|
1884
|
+
line: 286,
|
|
1891
1885
|
scope: this,
|
|
1892
1886
|
callSite: (f, a) => f(...a)
|
|
1893
1887
|
});
|
|
@@ -1910,8 +1904,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1910
1904
|
guest: this._signingContext.deviceKey,
|
|
1911
1905
|
spaceKey: space.key
|
|
1912
1906
|
}, {
|
|
1913
|
-
file: "
|
|
1914
|
-
line:
|
|
1907
|
+
file: "space-invitations-handler.ts",
|
|
1908
|
+
line: 309,
|
|
1915
1909
|
scope: this,
|
|
1916
1910
|
callSite: (f, a) => f(...a)
|
|
1917
1911
|
});
|
|
@@ -1919,8 +1913,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1919
1913
|
} catch (err) {
|
|
1920
1914
|
if (!observable.cancelled) {
|
|
1921
1915
|
log8.warn("auth failed", err, {
|
|
1922
|
-
file: "
|
|
1923
|
-
line:
|
|
1916
|
+
file: "space-invitations-handler.ts",
|
|
1917
|
+
line: 313,
|
|
1924
1918
|
scope: this,
|
|
1925
1919
|
callSite: (f, a) => f(...a)
|
|
1926
1920
|
});
|
|
@@ -1955,7 +1949,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1955
1949
|
return observable;
|
|
1956
1950
|
}
|
|
1957
1951
|
};
|
|
1958
|
-
var HostSpaceInvitationExtension = class extends
|
|
1952
|
+
var HostSpaceInvitationExtension = class extends RpcExtension2 {
|
|
1959
1953
|
constructor(_callbacks) {
|
|
1960
1954
|
super({
|
|
1961
1955
|
exposed: {
|
|
@@ -1984,7 +1978,7 @@ var HostSpaceInvitationExtension = class extends RpcExtension {
|
|
|
1984
1978
|
this._callbacks.onOpen();
|
|
1985
1979
|
}
|
|
1986
1980
|
};
|
|
1987
|
-
var GuestSpaceInvitationExtension = class extends
|
|
1981
|
+
var GuestSpaceInvitationExtension = class extends RpcExtension2 {
|
|
1988
1982
|
constructor(_callbacks) {
|
|
1989
1983
|
super({
|
|
1990
1984
|
requested: {
|
|
@@ -2029,18 +2023,173 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
2029
2023
|
};
|
|
2030
2024
|
|
|
2031
2025
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2032
|
-
import { Trigger as
|
|
2033
|
-
import { failUndefined as
|
|
2034
|
-
import { MOCK_AUTH_PROVIDER
|
|
2026
|
+
import { Trigger as Trigger4 } from "@dxos/async";
|
|
2027
|
+
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
2028
|
+
import { MOCK_AUTH_PROVIDER, MOCK_AUTH_VERIFIER, valueEncoding, DataServiceSubscriptions, MetadataStore, SpaceManager } from "@dxos/echo-db";
|
|
2035
2029
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
2036
2030
|
import { Keyring } from "@dxos/keyring";
|
|
2031
|
+
import { log as log10 } from "@dxos/log";
|
|
2032
|
+
|
|
2033
|
+
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2034
|
+
import { Event as Event3, synchronized } from "@dxos/async";
|
|
2035
|
+
import { spaceGenesis } from "@dxos/echo-db";
|
|
2036
|
+
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
2037
2037
|
import { log as log9 } from "@dxos/log";
|
|
2038
|
+
import { Presence as Presence2 } from "@dxos/teleport-extension-presence";
|
|
2039
|
+
import { ComplexMap as ComplexMap2 } from "@dxos/util";
|
|
2040
|
+
|
|
2041
|
+
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2042
|
+
import assert10 from "@dxos/node-std/assert";
|
|
2043
|
+
import { Context as Context4 } from "@dxos/context";
|
|
2044
|
+
import { DataPipelineControllerImpl } from "@dxos/echo-db";
|
|
2045
|
+
var DataSpace = class {
|
|
2046
|
+
constructor(_inner, _modelFactory, _memberKey, _presence) {
|
|
2047
|
+
this._inner = _inner;
|
|
2048
|
+
this._modelFactory = _modelFactory;
|
|
2049
|
+
this._memberKey = _memberKey;
|
|
2050
|
+
this._presence = _presence;
|
|
2051
|
+
this._ctx = new Context4();
|
|
2052
|
+
this._dataPipelineController = new DataPipelineControllerImpl(_modelFactory, _memberKey, (feedKey) => _inner.spaceState.feeds.get(feedKey));
|
|
2053
|
+
}
|
|
2054
|
+
get key() {
|
|
2055
|
+
return this._inner.key;
|
|
2056
|
+
}
|
|
2057
|
+
get inner() {
|
|
2058
|
+
return this._inner;
|
|
2059
|
+
}
|
|
2060
|
+
get isOpen() {
|
|
2061
|
+
return this._inner.isOpen;
|
|
2062
|
+
}
|
|
2063
|
+
get dataPipelineController() {
|
|
2064
|
+
return this._dataPipelineController;
|
|
2065
|
+
}
|
|
2066
|
+
get database() {
|
|
2067
|
+
assert10(this._dataPipelineController.database);
|
|
2068
|
+
return this._dataPipelineController.database;
|
|
2069
|
+
}
|
|
2070
|
+
get stateUpdate() {
|
|
2071
|
+
return this._inner.stateUpdate;
|
|
2072
|
+
}
|
|
2073
|
+
get presence() {
|
|
2074
|
+
return this._presence;
|
|
2075
|
+
}
|
|
2076
|
+
async open() {
|
|
2077
|
+
await this._inner.open();
|
|
2078
|
+
}
|
|
2079
|
+
async close() {
|
|
2080
|
+
await this._ctx.dispose();
|
|
2081
|
+
await this._inner.close();
|
|
2082
|
+
await this._presence.destroy();
|
|
2083
|
+
}
|
|
2084
|
+
};
|
|
2085
|
+
|
|
2086
|
+
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2087
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
2088
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2089
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2090
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2091
|
+
else
|
|
2092
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2093
|
+
if (d = decorators[i])
|
|
2094
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2095
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2096
|
+
};
|
|
2097
|
+
var DataSpaceManager = class {
|
|
2098
|
+
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _modelFactory) {
|
|
2099
|
+
this._spaceManager = _spaceManager;
|
|
2100
|
+
this._metadataStore = _metadataStore;
|
|
2101
|
+
this._dataServiceSubscriptions = _dataServiceSubscriptions;
|
|
2102
|
+
this._keyring = _keyring;
|
|
2103
|
+
this._signingContext = _signingContext;
|
|
2104
|
+
this._modelFactory = _modelFactory;
|
|
2105
|
+
this.updated = new Event3();
|
|
2106
|
+
this._spaces = new ComplexMap2(PublicKey5.hash);
|
|
2107
|
+
}
|
|
2108
|
+
get spaces() {
|
|
2109
|
+
return this._spaces;
|
|
2110
|
+
}
|
|
2111
|
+
async open() {
|
|
2112
|
+
await this._metadataStore.load();
|
|
2113
|
+
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2114
|
+
await this._constructSpace(spaceMetadata);
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
async close() {
|
|
2118
|
+
}
|
|
2119
|
+
async createSpace() {
|
|
2120
|
+
const spaceKey = await this._keyring.createKey();
|
|
2121
|
+
const controlFeedKey = await this._keyring.createKey();
|
|
2122
|
+
const dataFeedKey = await this._keyring.createKey();
|
|
2123
|
+
const metadata = {
|
|
2124
|
+
key: spaceKey,
|
|
2125
|
+
genesisFeedKey: controlFeedKey,
|
|
2126
|
+
controlFeedKey,
|
|
2127
|
+
dataFeedKey
|
|
2128
|
+
};
|
|
2129
|
+
log9("creating space...", {
|
|
2130
|
+
spaceKey
|
|
2131
|
+
}, {
|
|
2132
|
+
file: "data-space-manager.ts",
|
|
2133
|
+
line: 70,
|
|
2134
|
+
scope: this,
|
|
2135
|
+
callSite: (f, a) => f(...a)
|
|
2136
|
+
});
|
|
2137
|
+
const space = await this._constructSpace(metadata);
|
|
2138
|
+
await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2139
|
+
await this._metadataStore.addSpace(metadata);
|
|
2140
|
+
this.updated.emit();
|
|
2141
|
+
return space;
|
|
2142
|
+
}
|
|
2143
|
+
async acceptSpace(opts) {
|
|
2144
|
+
const metadata = {
|
|
2145
|
+
key: opts.spaceKey,
|
|
2146
|
+
genesisFeedKey: opts.genesisFeedKey,
|
|
2147
|
+
controlFeedKey: opts.controlFeedKey,
|
|
2148
|
+
dataFeedKey: opts.dataFeedKey
|
|
2149
|
+
};
|
|
2150
|
+
const space = await this._constructSpace(metadata);
|
|
2151
|
+
await this._metadataStore.addSpace(metadata);
|
|
2152
|
+
this.updated.emit();
|
|
2153
|
+
return space;
|
|
2154
|
+
}
|
|
2155
|
+
async _constructSpace(metadata) {
|
|
2156
|
+
const presence = new Presence2({
|
|
2157
|
+
localPeerId: this._signingContext.deviceKey,
|
|
2158
|
+
announceInterval: 1e3,
|
|
2159
|
+
offlineTimeout: 3e4,
|
|
2160
|
+
identityKey: this._signingContext.identityKey
|
|
2161
|
+
});
|
|
2162
|
+
const space = await this._spaceManager.constructSpace({
|
|
2163
|
+
metadata,
|
|
2164
|
+
swarmIdentity: {
|
|
2165
|
+
peerKey: this._signingContext.deviceKey,
|
|
2166
|
+
credentialProvider: this._signingContext.credentialProvider,
|
|
2167
|
+
credentialAuthenticator: this._signingContext.credentialAuthenticator
|
|
2168
|
+
},
|
|
2169
|
+
dataPipelineControllerProvider: () => dataSpace.dataPipelineController,
|
|
2170
|
+
presence
|
|
2171
|
+
});
|
|
2172
|
+
const dataSpace = new DataSpace(space, this._modelFactory, this._signingContext.identityKey, presence);
|
|
2173
|
+
await space.open();
|
|
2174
|
+
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.database.createDataServiceHost());
|
|
2175
|
+
this._spaces.set(metadata.key, dataSpace);
|
|
2176
|
+
return dataSpace;
|
|
2177
|
+
}
|
|
2178
|
+
};
|
|
2179
|
+
__decorate([
|
|
2180
|
+
synchronized
|
|
2181
|
+
], DataSpaceManager.prototype, "open", null);
|
|
2182
|
+
__decorate([
|
|
2183
|
+
synchronized
|
|
2184
|
+
], DataSpaceManager.prototype, "close", null);
|
|
2185
|
+
|
|
2186
|
+
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2038
2187
|
var ServiceContext = class {
|
|
2039
2188
|
constructor(storage, networkManager, modelFactory) {
|
|
2040
2189
|
this.storage = storage;
|
|
2041
2190
|
this.networkManager = networkManager;
|
|
2042
2191
|
this.modelFactory = modelFactory;
|
|
2043
|
-
this.initialized = new
|
|
2192
|
+
this.initialized = new Trigger4();
|
|
2044
2193
|
this.dataServiceSubscriptions = new DataServiceSubscriptions();
|
|
2045
2194
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
2046
2195
|
this.keyring = new Keyring(storage.createDirectory("keyring"));
|
|
@@ -2053,92 +2202,88 @@ var ServiceContext = class {
|
|
|
2053
2202
|
}
|
|
2054
2203
|
})
|
|
2055
2204
|
});
|
|
2056
|
-
this.
|
|
2205
|
+
this.spaceManager = new SpaceManager({
|
|
2206
|
+
feedStore: this.feedStore,
|
|
2207
|
+
networkManager: this.networkManager
|
|
2208
|
+
});
|
|
2209
|
+
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.spaceManager);
|
|
2057
2210
|
this.haloInvitations = new HaloInvitationsHandler(this.networkManager, this.identityManager);
|
|
2058
2211
|
}
|
|
2059
2212
|
async open() {
|
|
2060
|
-
|
|
2061
|
-
file: "
|
|
2062
|
-
line:
|
|
2213
|
+
log10("opening...", {}, {
|
|
2214
|
+
file: "service-context.ts",
|
|
2215
|
+
line: 81,
|
|
2063
2216
|
scope: this,
|
|
2064
2217
|
callSite: (f, a) => f(...a)
|
|
2065
2218
|
});
|
|
2219
|
+
await this.spaceManager.open();
|
|
2066
2220
|
await this.identityManager.open();
|
|
2067
2221
|
if (this.identityManager.identity) {
|
|
2068
2222
|
await this._initialize();
|
|
2069
2223
|
}
|
|
2070
|
-
|
|
2071
|
-
file: "
|
|
2072
|
-
line:
|
|
2224
|
+
log10("opened", {}, {
|
|
2225
|
+
file: "service-context.ts",
|
|
2226
|
+
line: 87,
|
|
2073
2227
|
scope: this,
|
|
2074
2228
|
callSite: (f, a) => f(...a)
|
|
2075
2229
|
});
|
|
2076
2230
|
}
|
|
2077
2231
|
async close() {
|
|
2078
2232
|
var _a;
|
|
2079
|
-
|
|
2080
|
-
file: "
|
|
2081
|
-
line:
|
|
2233
|
+
log10("closing...", {}, {
|
|
2234
|
+
file: "service-context.ts",
|
|
2235
|
+
line: 91,
|
|
2082
2236
|
scope: this,
|
|
2083
2237
|
callSite: (f, a) => f(...a)
|
|
2084
2238
|
});
|
|
2239
|
+
await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
|
|
2085
2240
|
await this.identityManager.close();
|
|
2086
|
-
await
|
|
2241
|
+
await this.spaceManager.close();
|
|
2087
2242
|
await this.feedStore.close();
|
|
2088
2243
|
await this.networkManager.close();
|
|
2089
2244
|
this.dataServiceSubscriptions.clear();
|
|
2090
|
-
|
|
2091
|
-
file: "
|
|
2092
|
-
line:
|
|
2245
|
+
log10("closed", {}, {
|
|
2246
|
+
file: "service-context.ts",
|
|
2247
|
+
line: 98,
|
|
2093
2248
|
scope: this,
|
|
2094
2249
|
callSite: (f, a) => f(...a)
|
|
2095
2250
|
});
|
|
2096
2251
|
}
|
|
2097
2252
|
async reset() {
|
|
2098
|
-
|
|
2099
|
-
file: "
|
|
2100
|
-
line:
|
|
2253
|
+
log10("resetting...", {}, {
|
|
2254
|
+
file: "service-context.ts",
|
|
2255
|
+
line: 102,
|
|
2101
2256
|
scope: this,
|
|
2102
2257
|
callSite: (f, a) => f(...a)
|
|
2103
2258
|
});
|
|
2104
2259
|
await this.close();
|
|
2105
2260
|
await this.storage.reset();
|
|
2106
|
-
|
|
2107
|
-
file: "
|
|
2108
|
-
line:
|
|
2261
|
+
log10("reset", {}, {
|
|
2262
|
+
file: "service-context.ts",
|
|
2263
|
+
line: 105,
|
|
2109
2264
|
scope: this,
|
|
2110
2265
|
callSite: (f, a) => f(...a)
|
|
2111
2266
|
});
|
|
2112
2267
|
}
|
|
2113
2268
|
async createIdentity(params = {}) {
|
|
2114
2269
|
const identity = await this.identityManager.createIdentity(params);
|
|
2115
|
-
this.dataServiceSubscriptions.registerSpace(identity.haloSpaceKey, identity.haloDatabase.createDataServiceHost());
|
|
2116
2270
|
await this._initialize();
|
|
2117
2271
|
return identity;
|
|
2118
2272
|
}
|
|
2119
2273
|
async _initialize() {
|
|
2120
2274
|
var _a;
|
|
2121
|
-
const identity = (_a = this.identityManager.identity) != null ? _a :
|
|
2275
|
+
const identity = (_a = this.identityManager.identity) != null ? _a : failUndefined2();
|
|
2122
2276
|
const signingContext = {
|
|
2123
|
-
credentialProvider:
|
|
2124
|
-
credentialAuthenticator:
|
|
2277
|
+
credentialProvider: MOCK_AUTH_PROVIDER,
|
|
2278
|
+
credentialAuthenticator: MOCK_AUTH_VERIFIER,
|
|
2125
2279
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
2126
2280
|
identityKey: identity.identityKey,
|
|
2127
2281
|
deviceKey: identity.deviceKey,
|
|
2128
2282
|
profile: identity.profileDocument
|
|
2129
2283
|
};
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
networkManager: this.networkManager,
|
|
2134
|
-
keyring: this.keyring,
|
|
2135
|
-
dataServiceSubscriptions: this.dataServiceSubscriptions,
|
|
2136
|
-
modelFactory: this.modelFactory,
|
|
2137
|
-
signingContext
|
|
2138
|
-
});
|
|
2139
|
-
await spaceManager.open();
|
|
2140
|
-
this.spaceManager = spaceManager;
|
|
2141
|
-
this.spaceInvitations = new SpaceInvitationsHandler(this.networkManager, this.spaceManager, signingContext, this.keyring);
|
|
2284
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.modelFactory);
|
|
2285
|
+
await this.dataSpaceManager.open();
|
|
2286
|
+
this.spaceInvitations = new SpaceInvitationsHandler(this.networkManager, this.dataSpaceManager, signingContext, this.keyring);
|
|
2142
2287
|
this.initialized.wake();
|
|
2143
2288
|
}
|
|
2144
2289
|
};
|
|
@@ -2162,7 +2307,7 @@ var clientServiceBundle = createServiceBundle({
|
|
|
2162
2307
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
2163
2308
|
import { raise } from "@dxos/debug";
|
|
2164
2309
|
import { DataServiceImpl } from "@dxos/echo-db";
|
|
2165
|
-
import { log as
|
|
2310
|
+
import { log as log11 } from "@dxos/log";
|
|
2166
2311
|
import { ModelFactory } from "@dxos/model-factory";
|
|
2167
2312
|
import { ObjectModel } from "@dxos/object-model";
|
|
2168
2313
|
import { TextModel } from "@dxos/text-model";
|
|
@@ -2337,20 +2482,20 @@ var ClientServicesHost = class {
|
|
|
2337
2482
|
var _a;
|
|
2338
2483
|
await this._initialize();
|
|
2339
2484
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
2340
|
-
|
|
2485
|
+
log11("opening...", {
|
|
2341
2486
|
deviceKey
|
|
2342
2487
|
}, {
|
|
2343
|
-
file: "
|
|
2488
|
+
file: "service-host.ts",
|
|
2344
2489
|
line: 69,
|
|
2345
2490
|
scope: this,
|
|
2346
2491
|
callSite: (f, a) => f(...a)
|
|
2347
2492
|
});
|
|
2348
2493
|
await this._initialize();
|
|
2349
2494
|
await this._serviceContext.open();
|
|
2350
|
-
|
|
2495
|
+
log11("opened", {
|
|
2351
2496
|
deviceKey
|
|
2352
2497
|
}, {
|
|
2353
|
-
file: "
|
|
2498
|
+
file: "service-host.ts",
|
|
2354
2499
|
line: 72,
|
|
2355
2500
|
scope: this,
|
|
2356
2501
|
callSite: (f, a) => f(...a)
|
|
@@ -2359,19 +2504,19 @@ var ClientServicesHost = class {
|
|
|
2359
2504
|
async close() {
|
|
2360
2505
|
var _a;
|
|
2361
2506
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
2362
|
-
|
|
2507
|
+
log11("closing...", {
|
|
2363
2508
|
deviceKey
|
|
2364
2509
|
}, {
|
|
2365
|
-
file: "
|
|
2510
|
+
file: "service-host.ts",
|
|
2366
2511
|
line: 77,
|
|
2367
2512
|
scope: this,
|
|
2368
2513
|
callSite: (f, a) => f(...a)
|
|
2369
2514
|
});
|
|
2370
2515
|
await this._serviceContext.close();
|
|
2371
|
-
|
|
2516
|
+
log11("closed", {
|
|
2372
2517
|
deviceKey
|
|
2373
2518
|
}, {
|
|
2374
|
-
file: "
|
|
2519
|
+
file: "service-host.ts",
|
|
2375
2520
|
line: 79,
|
|
2376
2521
|
scope: this,
|
|
2377
2522
|
callSite: (f, a) => f(...a)
|
|
@@ -2388,7 +2533,7 @@ var ClientServicesHost = class {
|
|
|
2388
2533
|
return (_a = this._serviceContext.spaceInvitations) != null ? _a : raise(new Error("SpaceInvitations not initialized"));
|
|
2389
2534
|
}, () => {
|
|
2390
2535
|
var _a;
|
|
2391
|
-
return (_a = this._serviceContext.
|
|
2536
|
+
return (_a = this._serviceContext.dataSpaceManager) != null ? _a : raise(new Error("SpaceManager not initialized"));
|
|
2392
2537
|
}),
|
|
2393
2538
|
SpacesService: new SpacesServiceImpl(),
|
|
2394
2539
|
DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
@@ -2408,11 +2553,11 @@ var ClientServicesHost = class {
|
|
|
2408
2553
|
// packages/sdk/client-services/src/packlets/services/service-proxy.ts
|
|
2409
2554
|
import { asyncTimeout } from "@dxos/async";
|
|
2410
2555
|
import { RemoteServiceConnectionTimeout } from "@dxos/errors";
|
|
2411
|
-
import { createProtoRpcPeer
|
|
2556
|
+
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
2412
2557
|
var ClientServicesProxy = class {
|
|
2413
2558
|
constructor(port, _timeout = 3e4) {
|
|
2414
2559
|
this._timeout = _timeout;
|
|
2415
|
-
this._proxy =
|
|
2560
|
+
this._proxy = createProtoRpcPeer({
|
|
2416
2561
|
requested: clientServiceBundle,
|
|
2417
2562
|
exposed: {},
|
|
2418
2563
|
handlers: {},
|
|
@@ -2438,7 +2583,7 @@ var ClientServicesProxy = class {
|
|
|
2438
2583
|
|
|
2439
2584
|
// packages/sdk/client-services/src/packlets/vault/iframe-runtime.ts
|
|
2440
2585
|
import { WebRTCTransportService } from "@dxos/network-manager";
|
|
2441
|
-
import { createProtoRpcPeer as
|
|
2586
|
+
import { createProtoRpcPeer as createProtoRpcPeer2 } from "@dxos/rpc";
|
|
2442
2587
|
|
|
2443
2588
|
// packages/sdk/client-services/src/packlets/vault/services.ts
|
|
2444
2589
|
import { schema as schema6 } from "@dxos/protocols";
|
|
@@ -2457,7 +2602,7 @@ var IFrameRuntime = class {
|
|
|
2457
2602
|
this._systemPort = systemPort;
|
|
2458
2603
|
this._windowAppPort = windowAppPort;
|
|
2459
2604
|
this._workerAppPort = workerAppPort;
|
|
2460
|
-
this._systemRpc =
|
|
2605
|
+
this._systemRpc = createProtoRpcPeer2({
|
|
2461
2606
|
requested: workerServiceBundle,
|
|
2462
2607
|
exposed: iframeServiceBundle,
|
|
2463
2608
|
handlers: {
|
|
@@ -2486,17 +2631,17 @@ var IFrameRuntime = class {
|
|
|
2486
2631
|
};
|
|
2487
2632
|
|
|
2488
2633
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
2489
|
-
import { Trigger as
|
|
2634
|
+
import { Trigger as Trigger6 } from "@dxos/async";
|
|
2490
2635
|
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from "@dxos/messaging";
|
|
2491
2636
|
import { NetworkManager, WebRTCTransportProxyFactory } from "@dxos/network-manager";
|
|
2492
2637
|
|
|
2493
2638
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
2494
|
-
import
|
|
2495
|
-
import { Trigger as
|
|
2496
|
-
import { log as
|
|
2497
|
-
import { createProtoRpcPeer as
|
|
2639
|
+
import assert11 from "@dxos/node-std/assert";
|
|
2640
|
+
import { Trigger as Trigger5 } from "@dxos/async";
|
|
2641
|
+
import { log as log12, logInfo } from "@dxos/log";
|
|
2642
|
+
import { createProtoRpcPeer as createProtoRpcPeer3 } from "@dxos/rpc";
|
|
2498
2643
|
import { Callback } from "@dxos/util";
|
|
2499
|
-
var
|
|
2644
|
+
var __decorate2 = function(decorators, target, key, desc) {
|
|
2500
2645
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2501
2646
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2502
2647
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2510,13 +2655,13 @@ var WorkerSession = class {
|
|
|
2510
2655
|
constructor({ getServices, systemPort, appPort, options = {
|
|
2511
2656
|
heartbeatInterval: 1e3
|
|
2512
2657
|
} }) {
|
|
2513
|
-
this._startTrigger = new
|
|
2658
|
+
this._startTrigger = new Trigger5();
|
|
2514
2659
|
this.onClose = new Callback();
|
|
2515
|
-
|
|
2516
|
-
|
|
2660
|
+
assert11(options);
|
|
2661
|
+
assert11(getServices);
|
|
2517
2662
|
this._options = options;
|
|
2518
2663
|
this._getServices = getServices;
|
|
2519
|
-
this._clientRpc =
|
|
2664
|
+
this._clientRpc = createProtoRpcPeer3({
|
|
2520
2665
|
exposed: clientServiceBundle,
|
|
2521
2666
|
handlers: {
|
|
2522
2667
|
HaloInvitationsService: async () => (await this._getServices()).services.HaloInvitationsService,
|
|
@@ -2532,7 +2677,7 @@ var WorkerSession = class {
|
|
|
2532
2677
|
},
|
|
2533
2678
|
port: appPort
|
|
2534
2679
|
});
|
|
2535
|
-
this._iframeRpc =
|
|
2680
|
+
this._iframeRpc = createProtoRpcPeer3({
|
|
2536
2681
|
requested: iframeServiceBundle,
|
|
2537
2682
|
exposed: workerServiceBundle,
|
|
2538
2683
|
handlers: {
|
|
@@ -2546,8 +2691,8 @@ var WorkerSession = class {
|
|
|
2546
2691
|
try {
|
|
2547
2692
|
await this.close();
|
|
2548
2693
|
} catch (err) {
|
|
2549
|
-
|
|
2550
|
-
file: "
|
|
2694
|
+
log12.catch(err, {}, {
|
|
2695
|
+
file: "worker-session.ts",
|
|
2551
2696
|
line: 89,
|
|
2552
2697
|
scope: this,
|
|
2553
2698
|
callSite: (f, a) => f(...a)
|
|
@@ -2563,8 +2708,8 @@ var WorkerSession = class {
|
|
|
2563
2708
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
2564
2709
|
}
|
|
2565
2710
|
async open() {
|
|
2566
|
-
|
|
2567
|
-
file: "
|
|
2711
|
+
log12.info("opening..", {}, {
|
|
2712
|
+
file: "worker-session.ts",
|
|
2568
2713
|
line: 103,
|
|
2569
2714
|
scope: this,
|
|
2570
2715
|
callSite: (f, a) => f(...a)
|
|
@@ -2580,10 +2725,10 @@ var WorkerSession = class {
|
|
|
2580
2725
|
try {
|
|
2581
2726
|
await this._iframeRpc.rpc.IframeService.heartbeat();
|
|
2582
2727
|
} catch (err1) {
|
|
2583
|
-
|
|
2728
|
+
log12.warn("Heartbeat failed", {
|
|
2584
2729
|
err: err1
|
|
2585
2730
|
}, {
|
|
2586
|
-
file: "
|
|
2731
|
+
file: "worker-session.ts",
|
|
2587
2732
|
line: 115,
|
|
2588
2733
|
scope: this,
|
|
2589
2734
|
callSite: (f, a) => f(...a)
|
|
@@ -2591,8 +2736,8 @@ var WorkerSession = class {
|
|
|
2591
2736
|
try {
|
|
2592
2737
|
await this.close();
|
|
2593
2738
|
} catch (err) {
|
|
2594
|
-
|
|
2595
|
-
file: "
|
|
2739
|
+
log12.catch(err, {}, {
|
|
2740
|
+
file: "worker-session.ts",
|
|
2596
2741
|
line: 119,
|
|
2597
2742
|
scope: this,
|
|
2598
2743
|
callSite: (f, a) => f(...a)
|
|
@@ -2602,8 +2747,8 @@ var WorkerSession = class {
|
|
|
2602
2747
|
}, this._options.heartbeatInterval);
|
|
2603
2748
|
}
|
|
2604
2749
|
async close() {
|
|
2605
|
-
|
|
2606
|
-
file: "
|
|
2750
|
+
log12.info("closing..", {}, {
|
|
2751
|
+
file: "worker-session.ts",
|
|
2607
2752
|
line: 126,
|
|
2608
2753
|
scope: this,
|
|
2609
2754
|
callSite: (f, a) => f(...a)
|
|
@@ -2611,8 +2756,8 @@ var WorkerSession = class {
|
|
|
2611
2756
|
try {
|
|
2612
2757
|
await this.onClose.callIfSet();
|
|
2613
2758
|
} catch (err) {
|
|
2614
|
-
|
|
2615
|
-
file: "
|
|
2759
|
+
log12.catch(err, {}, {
|
|
2760
|
+
file: "worker-session.ts",
|
|
2616
2761
|
line: 130,
|
|
2617
2762
|
scope: this,
|
|
2618
2763
|
callSite: (f, a) => f(...a)
|
|
@@ -2627,7 +2772,7 @@ var WorkerSession = class {
|
|
|
2627
2772
|
]);
|
|
2628
2773
|
}
|
|
2629
2774
|
};
|
|
2630
|
-
|
|
2775
|
+
__decorate2([
|
|
2631
2776
|
logInfo
|
|
2632
2777
|
], WorkerSession.prototype, "origin", void 0);
|
|
2633
2778
|
|
|
@@ -2636,7 +2781,7 @@ var WorkerRuntime = class {
|
|
|
2636
2781
|
constructor(_configProvider) {
|
|
2637
2782
|
this._configProvider = _configProvider;
|
|
2638
2783
|
this._transportFactory = new WebRTCTransportProxyFactory();
|
|
2639
|
-
this._ready = new
|
|
2784
|
+
this._ready = new Trigger6();
|
|
2640
2785
|
this.sessions = /* @__PURE__ */ new Set();
|
|
2641
2786
|
}
|
|
2642
2787
|
async start() {
|
|
@@ -2710,6 +2855,7 @@ export {
|
|
|
2710
2855
|
ClientServicesProxy,
|
|
2711
2856
|
DevtoolsHostEvents,
|
|
2712
2857
|
DevtoolsServiceImpl,
|
|
2858
|
+
HaloAuthVerifier,
|
|
2713
2859
|
HaloInvitationsHandler,
|
|
2714
2860
|
HaloInvitationsProxy,
|
|
2715
2861
|
HaloInvitationsServiceImpl,
|
|
@@ -2734,7 +2880,6 @@ export {
|
|
|
2734
2880
|
clientServiceBundle,
|
|
2735
2881
|
createDefaultModelFactory,
|
|
2736
2882
|
createHaloAuthProvider,
|
|
2737
|
-
createHaloAuthVerifier,
|
|
2738
2883
|
createStorageObjects,
|
|
2739
2884
|
getNetworkPeers,
|
|
2740
2885
|
subscribeToFeedBlocks,
|
|
@@ -2746,3 +2891,4 @@ export {
|
|
|
2746
2891
|
subscribeToSwarmInfo,
|
|
2747
2892
|
wrapObservable
|
|
2748
2893
|
};
|
|
2894
|
+
//# sourceMappingURL=index.mjs.map
|