@dxos/client-services 0.1.31-next.ea8f0bc → 0.1.32-next.77d513e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-ZIQUYEJS.mjs → chunk-E3FD43YN.mjs} +460 -213
- package/dist/lib/browser/chunk-E3FD43YN.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +64 -6
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +462 -215
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +524 -218
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts +6 -0
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +19 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +32 -5
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +29 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +4 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/host-test-builder.d.ts +2 -2
- package/dist/types/src/packlets/testing/host-test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +2 -0
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/tests/text.test.d.ts +2 -0
- package/dist/types/src/packlets/tests/text.test.d.ts.map +1 -0
- package/dist/types/src/packlets/vault/vault-resource-lock.d.ts +1 -0
- package/dist/types/src/packlets/vault/vault-resource-lock.d.ts.map +1 -1
- package/package.json +31 -30
- package/src/packlets/identity/identity-manager.ts +32 -17
- package/src/packlets/invitations/device-invitations-handler.ts +5 -3
- package/src/packlets/invitations/space-invitations-handler.test.ts +20 -3
- package/src/packlets/invitations/space-invitations-handler.ts +15 -8
- package/src/packlets/services/service-context.test.ts +6 -5
- package/src/packlets/services/service-host.ts +7 -2
- package/src/packlets/spaces/data-space-manager.test.ts +77 -2
- package/src/packlets/spaces/data-space-manager.ts +87 -37
- package/src/packlets/spaces/data-space.ts +103 -16
- package/src/packlets/spaces/notarization-plugin.test.ts +3 -1
- package/src/packlets/spaces/notarization-plugin.ts +67 -19
- package/src/packlets/spaces/spaces-service.test.ts +1 -1
- package/src/packlets/spaces/spaces-service.ts +53 -17
- package/src/packlets/testing/host-test-builder.ts +2 -2
- package/src/packlets/testing/test-builder.ts +45 -5
- package/src/packlets/tests/client-services.test.ts +24 -11
- package/src/packlets/tests/client.test.ts +3 -6
- package/src/packlets/tests/halo-profile.test.ts +5 -5
- package/src/packlets/tests/spaces-invitations.test.ts +47 -7
- package/src/packlets/tests/spaces.test.ts +86 -9
- package/src/packlets/tests/text.test.ts +206 -0
- package/src/packlets/vault/vault-resource-lock.ts +10 -1
- package/dist/lib/browser/chunk-ZIQUYEJS.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -653,7 +653,7 @@ var IdentityManager = class {
|
|
|
653
653
|
identityRecord
|
|
654
654
|
}, {
|
|
655
655
|
file: "identity-manager.ts",
|
|
656
|
-
line:
|
|
656
|
+
line: 71,
|
|
657
657
|
scope: this,
|
|
658
658
|
callSite: (f, a) => f(...a)
|
|
659
659
|
});
|
|
@@ -672,7 +672,7 @@ var IdentityManager = class {
|
|
|
672
672
|
(0, import_node_assert2.default)(!this._identity, "Identity already exists.");
|
|
673
673
|
(0, import_log3.log)("creating identity...", {}, {
|
|
674
674
|
file: "identity-manager.ts",
|
|
675
|
-
line:
|
|
675
|
+
line: 86,
|
|
676
676
|
scope: this,
|
|
677
677
|
callSite: (f, a) => f(...a)
|
|
678
678
|
});
|
|
@@ -681,21 +681,23 @@ var IdentityManager = class {
|
|
|
681
681
|
identityKey: await this._keyring.createKey(),
|
|
682
682
|
deviceKey: await this._keyring.createKey(),
|
|
683
683
|
haloSpace: {
|
|
684
|
-
|
|
684
|
+
key: await this._keyring.createKey(),
|
|
685
685
|
genesisFeedKey: controlFeedKey,
|
|
686
|
-
|
|
687
|
-
|
|
686
|
+
controlFeedKey,
|
|
687
|
+
dataFeedKey: await this._keyring.createKey()
|
|
688
688
|
}
|
|
689
689
|
};
|
|
690
690
|
const identity = await this._constructIdentity(identityRecord);
|
|
691
691
|
await identity.open();
|
|
692
692
|
{
|
|
693
693
|
const generator = new import_credentials4.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
694
|
+
(0, import_node_assert2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
|
|
695
|
+
(0, import_node_assert2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
|
|
694
696
|
const credentials = [
|
|
695
697
|
// Space genesis.
|
|
696
|
-
...await generator.createSpaceGenesis(identityRecord.haloSpace.
|
|
698
|
+
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
697
699
|
// Feed admission.
|
|
698
|
-
await generator.createFeedAdmission(identityRecord.haloSpace.
|
|
700
|
+
await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials5.AdmittedFeed.Designation.DATA)
|
|
699
701
|
];
|
|
700
702
|
if (displayName) {
|
|
701
703
|
credentials.push(await generator.createProfileCredential({
|
|
@@ -720,7 +722,7 @@ var IdentityManager = class {
|
|
|
720
722
|
deviceKey: identity.deviceKey
|
|
721
723
|
}, {
|
|
722
724
|
file: "identity-manager.ts",
|
|
723
|
-
line:
|
|
725
|
+
line: 143,
|
|
724
726
|
scope: this,
|
|
725
727
|
callSite: (f, a) => f(...a)
|
|
726
728
|
});
|
|
@@ -734,7 +736,7 @@ var IdentityManager = class {
|
|
|
734
736
|
params
|
|
735
737
|
}, {
|
|
736
738
|
file: "identity-manager.ts",
|
|
737
|
-
line:
|
|
739
|
+
line: 151,
|
|
738
740
|
scope: this,
|
|
739
741
|
callSite: (f, a) => f(...a)
|
|
740
742
|
});
|
|
@@ -743,10 +745,11 @@ var IdentityManager = class {
|
|
|
743
745
|
identityKey: params.identityKey,
|
|
744
746
|
deviceKey: params.deviceKey,
|
|
745
747
|
haloSpace: {
|
|
746
|
-
|
|
748
|
+
key: params.haloSpaceKey,
|
|
747
749
|
genesisFeedKey: params.haloGenesisFeedKey,
|
|
748
|
-
|
|
749
|
-
|
|
750
|
+
controlFeedKey: params.controlFeedKey,
|
|
751
|
+
dataFeedKey: params.dataFeedKey,
|
|
752
|
+
controlTimeframe: params.controlTimeframe
|
|
750
753
|
}
|
|
751
754
|
};
|
|
752
755
|
const identity = await this._constructIdentity(identityRecord);
|
|
@@ -760,7 +763,7 @@ var IdentityManager = class {
|
|
|
760
763
|
deviceKey: identity.deviceKey
|
|
761
764
|
}, {
|
|
762
765
|
file: "identity-manager.ts",
|
|
763
|
-
line:
|
|
766
|
+
line: 172,
|
|
764
767
|
scope: this,
|
|
765
768
|
callSite: (f, a) => f(...a)
|
|
766
769
|
});
|
|
@@ -772,14 +775,16 @@ var IdentityManager = class {
|
|
|
772
775
|
identityRecord
|
|
773
776
|
}, {
|
|
774
777
|
file: "identity-manager.ts",
|
|
775
|
-
line:
|
|
778
|
+
line: 178,
|
|
776
779
|
scope: this,
|
|
777
780
|
callSite: (f, a) => f(...a)
|
|
778
781
|
});
|
|
779
|
-
|
|
782
|
+
(0, import_node_assert2.default)(identityRecord.haloSpace.controlFeedKey);
|
|
783
|
+
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
780
784
|
writable: true
|
|
781
785
|
});
|
|
782
|
-
|
|
786
|
+
(0, import_node_assert2.default)(identityRecord.haloSpace.dataFeedKey);
|
|
787
|
+
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
783
788
|
writable: true
|
|
784
789
|
});
|
|
785
790
|
const space = await this._constructSpace({
|
|
@@ -803,16 +808,19 @@ var IdentityManager = class {
|
|
|
803
808
|
identityKey: identityRecord.identityKey
|
|
804
809
|
}, {
|
|
805
810
|
file: "identity-manager.ts",
|
|
806
|
-
line:
|
|
811
|
+
line: 206,
|
|
807
812
|
scope: this,
|
|
808
813
|
callSite: (f, a) => f(...a)
|
|
809
814
|
});
|
|
815
|
+
if (identityRecord.haloSpace.controlTimeframe) {
|
|
816
|
+
identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
|
|
817
|
+
}
|
|
810
818
|
return identity;
|
|
811
819
|
}
|
|
812
820
|
async _constructSpace({ spaceRecord, swarmIdentity, identityKey }) {
|
|
813
821
|
return this._spaceManager.constructSpace({
|
|
814
822
|
metadata: {
|
|
815
|
-
key: spaceRecord.
|
|
823
|
+
key: spaceRecord.key,
|
|
816
824
|
genesisFeedKey: spaceRecord.genesisFeedKey
|
|
817
825
|
},
|
|
818
826
|
swarmIdentity,
|
|
@@ -928,7 +936,8 @@ var DeviceInvitationsHandler = class extends import_client.AbstractInvitationsHa
|
|
|
928
936
|
return {
|
|
929
937
|
identityKey: identity.identityKey,
|
|
930
938
|
haloSpaceKey: identity.haloSpaceKey,
|
|
931
|
-
genesisFeedKey: identity.haloGenesisFeedKey
|
|
939
|
+
genesisFeedKey: identity.haloGenesisFeedKey,
|
|
940
|
+
controlTimeframe: identity.controlPipeline.state.timeframe
|
|
932
941
|
};
|
|
933
942
|
},
|
|
934
943
|
authenticate: async ({ authenticationCode: code }) => {
|
|
@@ -936,7 +945,7 @@ var DeviceInvitationsHandler = class extends import_client.AbstractInvitationsHa
|
|
|
936
945
|
authenticationCode: code
|
|
937
946
|
}, {
|
|
938
947
|
file: "device-invitations-handler.ts",
|
|
939
|
-
line:
|
|
948
|
+
line: 107,
|
|
940
949
|
scope: this,
|
|
941
950
|
callSite: (f, a) => f(...a)
|
|
942
951
|
});
|
|
@@ -958,7 +967,7 @@ var DeviceInvitationsHandler = class extends import_client.AbstractInvitationsHa
|
|
|
958
967
|
guest: credentials.deviceKey
|
|
959
968
|
}, {
|
|
960
969
|
file: "device-invitations-handler.ts",
|
|
961
|
-
line:
|
|
970
|
+
line: 122,
|
|
962
971
|
scope: this,
|
|
963
972
|
callSite: (f, a) => f(...a)
|
|
964
973
|
});
|
|
@@ -977,7 +986,7 @@ var DeviceInvitationsHandler = class extends import_client.AbstractInvitationsHa
|
|
|
977
986
|
host: identity.deviceKey
|
|
978
987
|
}, {
|
|
979
988
|
file: "device-invitations-handler.ts",
|
|
980
|
-
line:
|
|
989
|
+
line: 138,
|
|
981
990
|
scope: this,
|
|
982
991
|
callSite: (f, a) => f(...a)
|
|
983
992
|
});
|
|
@@ -990,7 +999,7 @@ var DeviceInvitationsHandler = class extends import_client.AbstractInvitationsHa
|
|
|
990
999
|
guest: deviceKey
|
|
991
1000
|
}, {
|
|
992
1001
|
file: "device-invitations-handler.ts",
|
|
993
|
-
line:
|
|
1002
|
+
line: 141,
|
|
994
1003
|
scope: this,
|
|
995
1004
|
callSite: (f, a) => f(...a)
|
|
996
1005
|
});
|
|
@@ -999,7 +1008,7 @@ var DeviceInvitationsHandler = class extends import_client.AbstractInvitationsHa
|
|
|
999
1008
|
if (!observable.cancelled) {
|
|
1000
1009
|
import_log4.log.error("failed", err, {
|
|
1001
1010
|
file: "device-invitations-handler.ts",
|
|
1002
|
-
line:
|
|
1011
|
+
line: 145,
|
|
1003
1012
|
scope: this,
|
|
1004
1013
|
callSite: (f, a) => f(...a)
|
|
1005
1014
|
});
|
|
@@ -1064,22 +1073,22 @@ var DeviceInvitationsHandler = class extends import_client.AbstractInvitationsHa
|
|
|
1064
1073
|
}
|
|
1065
1074
|
(0, import_log4.log)("connected", {}, {
|
|
1066
1075
|
file: "device-invitations-handler.ts",
|
|
1067
|
-
line:
|
|
1076
|
+
line: 216,
|
|
1068
1077
|
scope: this,
|
|
1069
1078
|
callSite: (f, a) => f(...a)
|
|
1070
1079
|
});
|
|
1071
1080
|
(_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
|
|
1072
1081
|
(0, import_log4.log)("sending admission request", {}, {
|
|
1073
1082
|
file: "device-invitations-handler.ts",
|
|
1074
|
-
line:
|
|
1083
|
+
line: 220,
|
|
1075
1084
|
scope: this,
|
|
1076
1085
|
callSite: (f, a) => f(...a)
|
|
1077
1086
|
});
|
|
1078
|
-
const { identityKey, haloSpaceKey, genesisFeedKey } = await extension.rpc.HaloHostService.requestAdmission();
|
|
1087
|
+
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = await extension.rpc.HaloHostService.requestAdmission();
|
|
1079
1088
|
if (invitation.type === void 0 || invitation.type === import_services.Invitation.Type.INTERACTIVE) {
|
|
1080
1089
|
(0, import_log4.log)("guest waiting for authentication code...", {}, {
|
|
1081
1090
|
file: "device-invitations-handler.ts",
|
|
1082
|
-
line:
|
|
1091
|
+
line: 227,
|
|
1083
1092
|
scope: this,
|
|
1084
1093
|
callSite: (f, a) => f(...a)
|
|
1085
1094
|
});
|
|
@@ -1089,7 +1098,7 @@ var DeviceInvitationsHandler = class extends import_client.AbstractInvitationsHa
|
|
|
1089
1098
|
});
|
|
1090
1099
|
(0, import_log4.log)("sending authentication request", {}, {
|
|
1091
1100
|
file: "device-invitations-handler.ts",
|
|
1092
|
-
line:
|
|
1101
|
+
line: 230,
|
|
1093
1102
|
scope: this,
|
|
1094
1103
|
callSite: (f, a) => f(...a)
|
|
1095
1104
|
});
|
|
@@ -1107,7 +1116,7 @@ var DeviceInvitationsHandler = class extends import_client.AbstractInvitationsHa
|
|
|
1107
1116
|
dataFeedKey
|
|
1108
1117
|
}, {
|
|
1109
1118
|
file: "device-invitations-handler.ts",
|
|
1110
|
-
line:
|
|
1119
|
+
line: 239,
|
|
1111
1120
|
scope: this,
|
|
1112
1121
|
callSite: (f, a) => f(...a)
|
|
1113
1122
|
});
|
|
@@ -1122,14 +1131,15 @@ var DeviceInvitationsHandler = class extends import_client.AbstractInvitationsHa
|
|
|
1122
1131
|
haloSpaceKey,
|
|
1123
1132
|
haloGenesisFeedKey: genesisFeedKey,
|
|
1124
1133
|
controlFeedKey,
|
|
1125
|
-
dataFeedKey
|
|
1134
|
+
dataFeedKey,
|
|
1135
|
+
controlTimeframe
|
|
1126
1136
|
});
|
|
1127
1137
|
(0, import_log4.log)("admitted by host", {
|
|
1128
1138
|
guest: identity.deviceKey,
|
|
1129
1139
|
identityKey
|
|
1130
1140
|
}, {
|
|
1131
1141
|
file: "device-invitations-handler.ts",
|
|
1132
|
-
line:
|
|
1142
|
+
line: 259,
|
|
1133
1143
|
scope: this,
|
|
1134
1144
|
callSite: (f, a) => f(...a)
|
|
1135
1145
|
});
|
|
@@ -1138,7 +1148,7 @@ var DeviceInvitationsHandler = class extends import_client.AbstractInvitationsHa
|
|
|
1138
1148
|
if (!observable.cancelled) {
|
|
1139
1149
|
import_log4.log.warn("auth failed", err, {
|
|
1140
1150
|
file: "device-invitations-handler.ts",
|
|
1141
|
-
line:
|
|
1151
|
+
line: 263,
|
|
1142
1152
|
scope: this,
|
|
1143
1153
|
callSite: (f, a) => f(...a)
|
|
1144
1154
|
});
|
|
@@ -1582,6 +1592,7 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1582
1592
|
};
|
|
1583
1593
|
},
|
|
1584
1594
|
requestAdmission: async ({ identityKey, deviceKey, controlFeedKey, dataFeedKey }) => {
|
|
1595
|
+
var _a2;
|
|
1585
1596
|
try {
|
|
1586
1597
|
if (isAuthenticationRequired(invitation) && !authenticationPassed) {
|
|
1587
1598
|
throw new Error("Not authenticated");
|
|
@@ -1602,7 +1613,9 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1602
1613
|
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
1603
1614
|
complete.wake(deviceKey);
|
|
1604
1615
|
return {
|
|
1605
|
-
credential: spaceMemberCredential
|
|
1616
|
+
credential: spaceMemberCredential,
|
|
1617
|
+
controlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
1618
|
+
dataTimeframe: (_a2 = space.dataPipeline.pipelineState) == null ? void 0 : _a2.timeframe
|
|
1606
1619
|
};
|
|
1607
1620
|
} catch (err) {
|
|
1608
1621
|
observable.callback.onError(err);
|
|
@@ -1617,7 +1630,7 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1617
1630
|
host: this._signingContext.deviceKey
|
|
1618
1631
|
}, {
|
|
1619
1632
|
file: "space-invitations-handler.ts",
|
|
1620
|
-
line:
|
|
1633
|
+
line: 195,
|
|
1621
1634
|
scope: this,
|
|
1622
1635
|
callSite: (f, a) => f(...a)
|
|
1623
1636
|
});
|
|
@@ -1630,7 +1643,7 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1630
1643
|
guest: deviceKey
|
|
1631
1644
|
}, {
|
|
1632
1645
|
file: "space-invitations-handler.ts",
|
|
1633
|
-
line:
|
|
1646
|
+
line: 198,
|
|
1634
1647
|
scope: this,
|
|
1635
1648
|
callSite: (f, a) => f(...a)
|
|
1636
1649
|
});
|
|
@@ -1639,7 +1652,7 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1639
1652
|
if (!observable.cancelled) {
|
|
1640
1653
|
import_log6.log.error("failed", err, {
|
|
1641
1654
|
file: "space-invitations-handler.ts",
|
|
1642
|
-
line:
|
|
1655
|
+
line: 202,
|
|
1643
1656
|
scope: this,
|
|
1644
1657
|
callSite: (f, a) => f(...a)
|
|
1645
1658
|
});
|
|
@@ -1709,7 +1722,7 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1709
1722
|
guest: this._signingContext.deviceKey
|
|
1710
1723
|
}, {
|
|
1711
1724
|
file: "space-invitations-handler.ts",
|
|
1712
|
-
line:
|
|
1725
|
+
line: 275,
|
|
1713
1726
|
scope: this,
|
|
1714
1727
|
callSite: (f, a) => f(...a)
|
|
1715
1728
|
});
|
|
@@ -1718,7 +1731,7 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1718
1731
|
guest: this._signingContext.deviceKey
|
|
1719
1732
|
}, {
|
|
1720
1733
|
file: "space-invitations-handler.ts",
|
|
1721
|
-
line:
|
|
1734
|
+
line: 279,
|
|
1722
1735
|
scope: this,
|
|
1723
1736
|
callSite: (f, a) => f(...a)
|
|
1724
1737
|
});
|
|
@@ -1730,7 +1743,7 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1730
1743
|
response: introductionResponse
|
|
1731
1744
|
}, {
|
|
1732
1745
|
file: "space-invitations-handler.ts",
|
|
1733
|
-
line:
|
|
1746
|
+
line: 283,
|
|
1734
1747
|
scope: this,
|
|
1735
1748
|
callSite: (f, a) => f(...a)
|
|
1736
1749
|
});
|
|
@@ -1743,7 +1756,7 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1743
1756
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1744
1757
|
(0, import_log6.log)("guest waiting for authentication code...", {}, {
|
|
1745
1758
|
file: "space-invitations-handler.ts",
|
|
1746
|
-
line:
|
|
1759
|
+
line: 297,
|
|
1747
1760
|
scope: this,
|
|
1748
1761
|
callSite: (f, a) => f(...a)
|
|
1749
1762
|
});
|
|
@@ -1753,7 +1766,7 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1753
1766
|
});
|
|
1754
1767
|
(0, import_log6.log)("sending authentication request", {}, {
|
|
1755
1768
|
file: "space-invitations-handler.ts",
|
|
1756
|
-
line:
|
|
1769
|
+
line: 301,
|
|
1757
1770
|
scope: this,
|
|
1758
1771
|
callSite: (f, a) => f(...a)
|
|
1759
1772
|
});
|
|
@@ -1771,7 +1784,7 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1771
1784
|
attempt
|
|
1772
1785
|
}, {
|
|
1773
1786
|
file: "space-invitations-handler.ts",
|
|
1774
|
-
line:
|
|
1787
|
+
line: 311,
|
|
1775
1788
|
scope: this,
|
|
1776
1789
|
callSite: (f, a) => f(...a)
|
|
1777
1790
|
});
|
|
@@ -1786,11 +1799,11 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1786
1799
|
guest: this._signingContext.deviceKey
|
|
1787
1800
|
}, {
|
|
1788
1801
|
file: "space-invitations-handler.ts",
|
|
1789
|
-
line:
|
|
1802
|
+
line: 322,
|
|
1790
1803
|
scope: this,
|
|
1791
1804
|
callSite: (f, a) => f(...a)
|
|
1792
1805
|
});
|
|
1793
|
-
const { credential } = await extension.rpc.SpaceHostService.requestAdmission({
|
|
1806
|
+
const { credential, controlTimeframe, dataTimeframe } = await extension.rpc.SpaceHostService.requestAdmission({
|
|
1794
1807
|
identityKey: this._signingContext.identityKey,
|
|
1795
1808
|
deviceKey: this._signingContext.deviceKey,
|
|
1796
1809
|
controlFeedKey,
|
|
@@ -1801,7 +1814,9 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1801
1814
|
(0, import_node_assert6.default)(credential.subject.id.equals(this._signingContext.identityKey));
|
|
1802
1815
|
const space = await this._spaceManager.acceptSpace({
|
|
1803
1816
|
spaceKey: assertion.spaceKey,
|
|
1804
|
-
genesisFeedKey: assertion.genesisFeedKey
|
|
1817
|
+
genesisFeedKey: assertion.genesisFeedKey,
|
|
1818
|
+
controlTimeframe,
|
|
1819
|
+
dataTimeframe
|
|
1805
1820
|
});
|
|
1806
1821
|
await this._signingContext.recordCredential(credential);
|
|
1807
1822
|
(0, import_log6.log)("admitted by host", {
|
|
@@ -1809,7 +1824,7 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1809
1824
|
spaceKey: space.key
|
|
1810
1825
|
}, {
|
|
1811
1826
|
file: "space-invitations-handler.ts",
|
|
1812
|
-
line:
|
|
1827
|
+
line: 347,
|
|
1813
1828
|
scope: this,
|
|
1814
1829
|
callSite: (f, a) => f(...a)
|
|
1815
1830
|
});
|
|
@@ -1818,7 +1833,7 @@ var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHa
|
|
|
1818
1833
|
if (!observable.cancelled) {
|
|
1819
1834
|
import_log6.log.warn("auth failed", err, {
|
|
1820
1835
|
file: "space-invitations-handler.ts",
|
|
1821
|
-
line:
|
|
1836
|
+
line: 351,
|
|
1822
1837
|
scope: this,
|
|
1823
1838
|
callSite: (f, a) => f(...a)
|
|
1824
1839
|
});
|
|
@@ -1924,10 +1939,10 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
1924
1939
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
1925
1940
|
var import_node_assert12 = __toESM(require("node:assert"));
|
|
1926
1941
|
var import_async19 = require("@dxos/async");
|
|
1927
|
-
var
|
|
1942
|
+
var import_client8 = require("@dxos/client");
|
|
1928
1943
|
var import_debug7 = require("@dxos/debug");
|
|
1929
1944
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
1930
|
-
var
|
|
1945
|
+
var import_log16 = require("@dxos/log");
|
|
1931
1946
|
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1932
1947
|
|
|
1933
1948
|
// packages/sdk/client-services/src/packlets/deprecated/tracing.ts
|
|
@@ -2015,20 +2030,24 @@ var NetworkServiceImpl = class {
|
|
|
2015
2030
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2016
2031
|
var import_node_assert9 = __toESM(require("node:assert"));
|
|
2017
2032
|
var import_async11 = require("@dxos/async");
|
|
2033
|
+
var import_client4 = require("@dxos/client");
|
|
2018
2034
|
var import_context7 = require("@dxos/context");
|
|
2019
2035
|
var import_credentials10 = require("@dxos/credentials");
|
|
2020
2036
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
2021
2037
|
var import_keys8 = require("@dxos/keys");
|
|
2022
|
-
var
|
|
2023
|
-
var
|
|
2038
|
+
var import_log9 = require("@dxos/log");
|
|
2039
|
+
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
2024
2040
|
var import_util5 = require("@dxos/util");
|
|
2025
2041
|
|
|
2026
2042
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2027
2043
|
var import_async10 = require("@dxos/async");
|
|
2044
|
+
var import_client3 = require("@dxos/client");
|
|
2028
2045
|
var import_context6 = require("@dxos/context");
|
|
2029
2046
|
var import_debug3 = require("@dxos/debug");
|
|
2030
2047
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
2048
|
+
var import_errors = require("@dxos/errors");
|
|
2031
2049
|
var import_keys7 = require("@dxos/keys");
|
|
2050
|
+
var import_log8 = require("@dxos/log");
|
|
2032
2051
|
var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2033
2052
|
var import_util4 = require("@dxos/util");
|
|
2034
2053
|
|
|
@@ -2041,8 +2060,9 @@ var import_log7 = require("@dxos/log");
|
|
|
2041
2060
|
var import_protocols4 = require("@dxos/protocols");
|
|
2042
2061
|
var import_teleport3 = require("@dxos/teleport");
|
|
2043
2062
|
var import_util3 = require("@dxos/util");
|
|
2044
|
-
var
|
|
2045
|
-
var
|
|
2063
|
+
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2064
|
+
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2065
|
+
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
2046
2066
|
var NotarizationPlugin = class {
|
|
2047
2067
|
constructor() {
|
|
2048
2068
|
this._ctx = new import_context5.Context();
|
|
@@ -2059,12 +2079,12 @@ var NotarizationPlugin = class {
|
|
|
2059
2079
|
/**
|
|
2060
2080
|
* Request credentials to be notarized.
|
|
2061
2081
|
*/
|
|
2062
|
-
async notarize(credentials) {
|
|
2082
|
+
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
2063
2083
|
(0, import_log7.log)("notarize", {
|
|
2064
2084
|
credentials
|
|
2065
2085
|
}, {
|
|
2066
2086
|
file: "notarization-plugin.ts",
|
|
2067
|
-
line:
|
|
2087
|
+
line: 85,
|
|
2068
2088
|
scope: this,
|
|
2069
2089
|
callSite: (f, a) => f(...a)
|
|
2070
2090
|
});
|
|
@@ -2076,7 +2096,7 @@ var NotarizationPlugin = class {
|
|
|
2076
2096
|
err
|
|
2077
2097
|
}, {
|
|
2078
2098
|
file: "notarization-plugin.ts",
|
|
2079
|
-
line:
|
|
2099
|
+
line: 94,
|
|
2080
2100
|
scope: this,
|
|
2081
2101
|
callSite: (f, a) => f(...a)
|
|
2082
2102
|
});
|
|
@@ -2084,27 +2104,27 @@ var NotarizationPlugin = class {
|
|
|
2084
2104
|
errors.throw(err);
|
|
2085
2105
|
}
|
|
2086
2106
|
});
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2107
|
+
opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
|
|
2108
|
+
if (timeout !== 0) {
|
|
2109
|
+
(0, import_async9.scheduleTask)(ctx, () => {
|
|
2110
|
+
import_log7.log.warn("Notarization timeout", {
|
|
2111
|
+
timeout,
|
|
2112
|
+
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2113
|
+
}, {
|
|
2114
|
+
file: "notarization-plugin.ts",
|
|
2115
|
+
line: 106,
|
|
2116
|
+
scope: this,
|
|
2117
|
+
callSite: (f, a) => f(...a)
|
|
2118
|
+
});
|
|
2119
|
+
void ctx.dispose();
|
|
2120
|
+
errors.throw(new import_async9.TimeoutError(timeout, "Notarization timed out"));
|
|
2121
|
+
}, timeout);
|
|
2122
|
+
}
|
|
2097
2123
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
2098
2124
|
const peersTried = /* @__PURE__ */ new Set();
|
|
2099
2125
|
const notarizeTask = new import_async9.DeferredTask(ctx, async () => {
|
|
2100
2126
|
try {
|
|
2101
2127
|
if (this._extensions.size === 0) {
|
|
2102
|
-
import_log7.log.warn("No peers to notarize with", {}, {
|
|
2103
|
-
file: "notarization-plugin.ts",
|
|
2104
|
-
line: 76,
|
|
2105
|
-
scope: this,
|
|
2106
|
-
callSite: (f, a) => f(...a)
|
|
2107
|
-
});
|
|
2108
2128
|
return;
|
|
2109
2129
|
}
|
|
2110
2130
|
const peer = [
|
|
@@ -2112,15 +2132,15 @@ var NotarizationPlugin = class {
|
|
|
2112
2132
|
].find((peer2) => !peersTried.has(peer2));
|
|
2113
2133
|
if (!peer) {
|
|
2114
2134
|
import_log7.log.warn("Exhausted all peers to notarize with", {
|
|
2115
|
-
retryIn:
|
|
2135
|
+
retryIn: retryTimeout
|
|
2116
2136
|
}, {
|
|
2117
2137
|
file: "notarization-plugin.ts",
|
|
2118
|
-
line:
|
|
2138
|
+
line: 131,
|
|
2119
2139
|
scope: this,
|
|
2120
2140
|
callSite: (f, a) => f(...a)
|
|
2121
2141
|
});
|
|
2122
2142
|
peersTried.clear();
|
|
2123
|
-
(0, import_async9.scheduleTask)(ctx, () => notarizeTask.schedule(),
|
|
2143
|
+
(0, import_async9.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
2124
2144
|
return;
|
|
2125
2145
|
}
|
|
2126
2146
|
peersTried.add(peer);
|
|
@@ -2129,7 +2149,7 @@ var NotarizationPlugin = class {
|
|
|
2129
2149
|
credentialId: credentials.map((credential) => credential.id)
|
|
2130
2150
|
}, {
|
|
2131
2151
|
file: "notarization-plugin.ts",
|
|
2132
|
-
line:
|
|
2152
|
+
line: 138,
|
|
2133
2153
|
scope: this,
|
|
2134
2154
|
callSite: (f, a) => f(...a)
|
|
2135
2155
|
});
|
|
@@ -2138,14 +2158,15 @@ var NotarizationPlugin = class {
|
|
|
2138
2158
|
});
|
|
2139
2159
|
(0, import_log7.log)("success", {}, {
|
|
2140
2160
|
file: "notarization-plugin.ts",
|
|
2141
|
-
line:
|
|
2161
|
+
line: 142,
|
|
2142
2162
|
scope: this,
|
|
2143
2163
|
callSite: (f, a) => f(...a)
|
|
2144
2164
|
});
|
|
2165
|
+
await (0, import_async9.sleep)(successDelay);
|
|
2145
2166
|
} catch (err) {
|
|
2146
2167
|
import_log7.log.warn("error notarizing (recoverable)", err, {
|
|
2147
2168
|
file: "notarization-plugin.ts",
|
|
2148
|
-
line:
|
|
2169
|
+
line: 145,
|
|
2149
2170
|
scope: this,
|
|
2150
2171
|
callSite: (f, a) => f(...a)
|
|
2151
2172
|
});
|
|
@@ -2156,12 +2177,13 @@ var NotarizationPlugin = class {
|
|
|
2156
2177
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
2157
2178
|
try {
|
|
2158
2179
|
await Promise.race([
|
|
2180
|
+
(0, import_context5.rejectOnDispose)(ctx),
|
|
2159
2181
|
allNotarized,
|
|
2160
2182
|
errors.wait()
|
|
2161
2183
|
]);
|
|
2162
2184
|
(0, import_log7.log)("done", {}, {
|
|
2163
2185
|
file: "notarization-plugin.ts",
|
|
2164
|
-
line:
|
|
2186
|
+
line: 155,
|
|
2165
2187
|
scope: this,
|
|
2166
2188
|
callSite: (f, a) => f(...a)
|
|
2167
2189
|
});
|
|
@@ -2214,7 +2236,7 @@ var NotarizationPlugin = class {
|
|
|
2214
2236
|
peer: extension.localPeerId
|
|
2215
2237
|
}, {
|
|
2216
2238
|
file: "notarization-plugin.ts",
|
|
2217
|
-
line:
|
|
2239
|
+
line: 204,
|
|
2218
2240
|
scope: this,
|
|
2219
2241
|
callSite: (f, a) => f(...a)
|
|
2220
2242
|
});
|
|
@@ -2226,7 +2248,7 @@ var NotarizationPlugin = class {
|
|
|
2226
2248
|
peer: extension.localPeerId
|
|
2227
2249
|
}, {
|
|
2228
2250
|
file: "notarization-plugin.ts",
|
|
2229
|
-
line:
|
|
2251
|
+
line: 209,
|
|
2230
2252
|
scope: this,
|
|
2231
2253
|
callSite: (f, a) => f(...a)
|
|
2232
2254
|
});
|
|
@@ -2280,17 +2302,22 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
2280
2302
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2281
2303
|
};
|
|
2282
2304
|
var AUTH_TIMEOUT2 = 3e4;
|
|
2283
|
-
var CONTROL_PIPELINE_READY_TIMEFRAME = 3e3;
|
|
2284
2305
|
var DataSpace = class DataSpace2 {
|
|
2285
2306
|
constructor(params) {
|
|
2286
2307
|
this._ctx = new import_context6.Context();
|
|
2308
|
+
this._state = import_client3.SpaceState.CLOSED;
|
|
2309
|
+
this.stateUpdate = new import_async10.Event();
|
|
2310
|
+
var _a;
|
|
2287
2311
|
this._inner = params.inner;
|
|
2312
|
+
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
2313
|
+
this._gossip = params.gossip;
|
|
2288
2314
|
this._presence = params.presence;
|
|
2289
2315
|
this._keyring = params.keyring;
|
|
2290
2316
|
this._feedStore = params.feedStore;
|
|
2291
2317
|
this._metadataStore = params.metadataStore;
|
|
2292
2318
|
this._signingContext = params.signingContext;
|
|
2293
|
-
this.
|
|
2319
|
+
this._callbacks = (_a = params.callbacks) != null ? _a : {};
|
|
2320
|
+
this._dataPipeline = new import_echo_pipeline.DataPipeline({
|
|
2294
2321
|
modelFactory: params.modelFactory,
|
|
2295
2322
|
metadataStore: params.metadataStore,
|
|
2296
2323
|
snapshotManager: params.snapshotManager,
|
|
@@ -2312,15 +2339,15 @@ var DataSpace = class DataSpace2 {
|
|
|
2312
2339
|
get isOpen() {
|
|
2313
2340
|
return this._inner.isOpen;
|
|
2314
2341
|
}
|
|
2342
|
+
get state() {
|
|
2343
|
+
return this._state;
|
|
2344
|
+
}
|
|
2315
2345
|
// TODO(burdon): Can we mark this for debugging only?
|
|
2316
2346
|
get inner() {
|
|
2317
2347
|
return this._inner;
|
|
2318
2348
|
}
|
|
2319
|
-
get
|
|
2320
|
-
return this.
|
|
2321
|
-
}
|
|
2322
|
-
get stateUpdate() {
|
|
2323
|
-
return this._inner.stateUpdate;
|
|
2349
|
+
get dataPipeline() {
|
|
2350
|
+
return this._dataPipeline;
|
|
2324
2351
|
}
|
|
2325
2352
|
get presence() {
|
|
2326
2353
|
return this._presence;
|
|
@@ -2332,26 +2359,102 @@ var DataSpace = class DataSpace2 {
|
|
|
2332
2359
|
await this.notarizationPlugin.open();
|
|
2333
2360
|
await this._notarizationPluginConsumer.open();
|
|
2334
2361
|
await this._inner.open();
|
|
2362
|
+
this._state = import_client3.SpaceState.INACTIVE;
|
|
2335
2363
|
}
|
|
2336
2364
|
async close() {
|
|
2365
|
+
this._state = import_client3.SpaceState.CLOSED;
|
|
2337
2366
|
await this._ctx.dispose();
|
|
2367
|
+
await this._dataPipeline.close();
|
|
2338
2368
|
await this.authVerifier.close();
|
|
2339
2369
|
await this._inner.close();
|
|
2340
2370
|
await this._notarizationPluginConsumer.close();
|
|
2341
2371
|
await this.notarizationPlugin.close();
|
|
2342
2372
|
await this._presence.destroy();
|
|
2343
2373
|
}
|
|
2374
|
+
async postMessage(channel, message) {
|
|
2375
|
+
return this._gossip.postMessage(channel, message);
|
|
2376
|
+
}
|
|
2377
|
+
listen(channel, callback) {
|
|
2378
|
+
return this._gossip.listen(channel, callback);
|
|
2379
|
+
}
|
|
2380
|
+
/**
|
|
2381
|
+
* Initialize the data pipeline in a separate task.
|
|
2382
|
+
*/
|
|
2383
|
+
initializeDataPipelineAsync() {
|
|
2384
|
+
(0, import_async10.scheduleTask)(this._ctx, async () => {
|
|
2385
|
+
try {
|
|
2386
|
+
await this.initializeDataPipeline();
|
|
2387
|
+
} catch (err) {
|
|
2388
|
+
if (err instanceof import_errors.CancelledError) {
|
|
2389
|
+
(0, import_log8.log)("Data pipeline initialization cancelled", err, {
|
|
2390
|
+
file: "data-space.ts",
|
|
2391
|
+
line: 178,
|
|
2392
|
+
scope: this,
|
|
2393
|
+
callSite: (f, a) => f(...a)
|
|
2394
|
+
});
|
|
2395
|
+
return;
|
|
2396
|
+
}
|
|
2397
|
+
import_log8.log.error("Error initializing data pipeline", err, {
|
|
2398
|
+
file: "data-space.ts",
|
|
2399
|
+
line: 182,
|
|
2400
|
+
scope: this,
|
|
2401
|
+
callSite: (f, a) => f(...a)
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
});
|
|
2405
|
+
}
|
|
2344
2406
|
async initializeDataPipeline() {
|
|
2407
|
+
var _a, _b, _c, _d;
|
|
2408
|
+
if (this._state !== import_client3.SpaceState.INACTIVE) {
|
|
2409
|
+
throw new import_errors.SystemError("Invalid operation");
|
|
2410
|
+
}
|
|
2411
|
+
this._state = import_client3.SpaceState.INITIALIZING;
|
|
2345
2412
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2346
|
-
|
|
2413
|
+
ctx: this._ctx,
|
|
2414
|
+
breakOnStall: false
|
|
2347
2415
|
});
|
|
2348
2416
|
await this._createWritableFeeds();
|
|
2417
|
+
(0, import_log8.log)("Writable feeds created", {}, {
|
|
2418
|
+
file: "data-space.ts",
|
|
2419
|
+
line: 200,
|
|
2420
|
+
scope: this,
|
|
2421
|
+
callSite: (f, a) => f(...a)
|
|
2422
|
+
});
|
|
2423
|
+
this.stateUpdate.emit();
|
|
2349
2424
|
this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
|
|
2350
2425
|
credential: {
|
|
2351
2426
|
credential
|
|
2352
2427
|
}
|
|
2353
2428
|
}), this._inner.controlPipeline.writer));
|
|
2354
|
-
await this.
|
|
2429
|
+
await this._dataPipeline.open({
|
|
2430
|
+
openPipeline: async (start) => {
|
|
2431
|
+
const pipeline = await this._inner.createDataPipeline({
|
|
2432
|
+
start
|
|
2433
|
+
});
|
|
2434
|
+
await pipeline.start();
|
|
2435
|
+
return pipeline;
|
|
2436
|
+
}
|
|
2437
|
+
});
|
|
2438
|
+
(0, import_log8.log)("waiting for data pipeline to reach target timeframe", {}, {
|
|
2439
|
+
file: "data-space.ts",
|
|
2440
|
+
line: 220,
|
|
2441
|
+
scope: this,
|
|
2442
|
+
callSite: (f, a) => f(...a)
|
|
2443
|
+
});
|
|
2444
|
+
await this._dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2445
|
+
ctx: this._ctx,
|
|
2446
|
+
breakOnStall: false
|
|
2447
|
+
});
|
|
2448
|
+
(0, import_log8.log)("data pipeline ready", {}, {
|
|
2449
|
+
file: "data-space.ts",
|
|
2450
|
+
line: 227,
|
|
2451
|
+
scope: this,
|
|
2452
|
+
callSite: (f, a) => f(...a)
|
|
2453
|
+
});
|
|
2454
|
+
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2455
|
+
this._state = import_client3.SpaceState.READY;
|
|
2456
|
+
this.stateUpdate.emit();
|
|
2457
|
+
await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
|
|
2355
2458
|
}
|
|
2356
2459
|
async _createWritableFeeds() {
|
|
2357
2460
|
const credentials = [];
|
|
@@ -2388,7 +2491,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2388
2491
|
}));
|
|
2389
2492
|
}
|
|
2390
2493
|
if (credentials.length > 0) {
|
|
2391
|
-
await this.notarizationPlugin.notarize(
|
|
2494
|
+
await this.notarizationPlugin.notarize({
|
|
2495
|
+
ctx: this._ctx,
|
|
2496
|
+
credentials,
|
|
2497
|
+
timeout: 0
|
|
2498
|
+
});
|
|
2392
2499
|
}
|
|
2393
2500
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
2394
2501
|
}
|
|
@@ -2411,7 +2518,6 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2411
2518
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2412
2519
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2413
2520
|
};
|
|
2414
|
-
var DATA_PIPELINE_READY_TIMEOUT = 3e3;
|
|
2415
2521
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2416
2522
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _modelFactory, _feedStore, _snapshotStore) {
|
|
2417
2523
|
this._spaceManager = _spaceManager;
|
|
@@ -2425,50 +2531,51 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2425
2531
|
this._ctx = new import_context7.Context();
|
|
2426
2532
|
this.updated = new import_async11.Event();
|
|
2427
2533
|
this._spaces = new import_util5.ComplexMap(import_keys8.PublicKey.hash);
|
|
2534
|
+
this._isOpen = false;
|
|
2428
2535
|
}
|
|
2429
2536
|
// TODO(burdon): Remove.
|
|
2430
2537
|
get spaces() {
|
|
2431
2538
|
return this._spaces;
|
|
2432
2539
|
}
|
|
2433
2540
|
async open() {
|
|
2541
|
+
(0, import_log9.log)("open", {}, {
|
|
2542
|
+
file: "data-space-manager.ts",
|
|
2543
|
+
line: 80,
|
|
2544
|
+
scope: this,
|
|
2545
|
+
callSite: (f, a) => f(...a)
|
|
2546
|
+
});
|
|
2434
2547
|
await this._metadataStore.load();
|
|
2435
|
-
(0,
|
|
2548
|
+
(0, import_log9.log)("metadata loaded", {
|
|
2436
2549
|
spaces: this._metadataStore.spaces.length
|
|
2437
2550
|
}, {
|
|
2438
2551
|
file: "data-space-manager.ts",
|
|
2439
|
-
line:
|
|
2552
|
+
line: 82,
|
|
2440
2553
|
scope: this,
|
|
2441
2554
|
callSite: (f, a) => f(...a)
|
|
2442
2555
|
});
|
|
2443
2556
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2444
|
-
(0,
|
|
2557
|
+
(0, import_log9.log)("load space", {
|
|
2445
2558
|
spaceMetadata
|
|
2446
2559
|
}, {
|
|
2447
2560
|
file: "data-space-manager.ts",
|
|
2448
|
-
line:
|
|
2561
|
+
line: 85,
|
|
2449
2562
|
scope: this,
|
|
2450
2563
|
callSite: (f, a) => f(...a)
|
|
2451
2564
|
});
|
|
2452
2565
|
const space = await this._constructSpace(spaceMetadata);
|
|
2453
|
-
|
|
2454
|
-
if (spaceMetadata.dataTimeframe) {
|
|
2455
|
-
(0, import_log8.log)("waiting for latest timeframe", {
|
|
2456
|
-
spaceMetadata
|
|
2457
|
-
}, {
|
|
2458
|
-
file: "data-space-manager.ts",
|
|
2459
|
-
line: 74,
|
|
2460
|
-
scope: this,
|
|
2461
|
-
callSite: (f, a) => f(...a)
|
|
2462
|
-
});
|
|
2463
|
-
await space.dataPipelineController.pipelineState.setTargetTimeframe(spaceMetadata.dataTimeframe);
|
|
2464
|
-
}
|
|
2465
|
-
await space.dataPipelineController.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2466
|
-
timeout: DATA_PIPELINE_READY_TIMEOUT
|
|
2467
|
-
});
|
|
2468
|
-
this._dataServiceSubscriptions.registerSpace(space.key, space.dataPipelineController.databaseBackend.createDataServiceHost());
|
|
2566
|
+
space.initializeDataPipelineAsync();
|
|
2469
2567
|
}
|
|
2568
|
+
this._isOpen = true;
|
|
2569
|
+
this.updated.emit();
|
|
2470
2570
|
}
|
|
2471
2571
|
async close() {
|
|
2572
|
+
(0, import_log9.log)("close", {}, {
|
|
2573
|
+
file: "data-space-manager.ts",
|
|
2574
|
+
line: 96,
|
|
2575
|
+
scope: this,
|
|
2576
|
+
callSite: (f, a) => f(...a)
|
|
2577
|
+
});
|
|
2578
|
+
this._isOpen = false;
|
|
2472
2579
|
await this._ctx.dispose();
|
|
2473
2580
|
for (const space of this._spaces.values()) {
|
|
2474
2581
|
await space.close();
|
|
@@ -2478,6 +2585,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2478
2585
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2479
2586
|
*/
|
|
2480
2587
|
async createSpace() {
|
|
2588
|
+
(0, import_node_assert9.default)(this._isOpen, "Not open.");
|
|
2481
2589
|
const spaceKey = await this._keyring.createKey();
|
|
2482
2590
|
const controlFeedKey = await this._keyring.createKey();
|
|
2483
2591
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2487,11 +2595,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2487
2595
|
controlFeedKey,
|
|
2488
2596
|
dataFeedKey
|
|
2489
2597
|
};
|
|
2490
|
-
(0,
|
|
2598
|
+
(0, import_log9.log)("creating space...", {
|
|
2491
2599
|
spaceKey
|
|
2492
2600
|
}, {
|
|
2493
2601
|
file: "data-space-manager.ts",
|
|
2494
|
-
line:
|
|
2602
|
+
line: 120,
|
|
2495
2603
|
scope: this,
|
|
2496
2604
|
callSite: (f, a) => f(...a)
|
|
2497
2605
|
});
|
|
@@ -2502,30 +2610,61 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2502
2610
|
(0, import_node_assert9.default)((0, import_credentials10.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2503
2611
|
await this._signingContext.recordCredential(memberCredential);
|
|
2504
2612
|
await space.initializeDataPipeline();
|
|
2505
|
-
this._dataServiceSubscriptions.registerSpace(space.key, space.dataPipelineController.databaseBackend.createDataServiceHost());
|
|
2506
2613
|
this.updated.emit();
|
|
2507
2614
|
return space;
|
|
2508
2615
|
}
|
|
2509
2616
|
// TODO(burdon): Rename join space.
|
|
2510
2617
|
async acceptSpace(opts) {
|
|
2618
|
+
(0, import_log9.log)("accept space", {
|
|
2619
|
+
opts
|
|
2620
|
+
}, {
|
|
2621
|
+
file: "data-space-manager.ts",
|
|
2622
|
+
line: 139,
|
|
2623
|
+
scope: this,
|
|
2624
|
+
callSite: (f, a) => f(...a)
|
|
2625
|
+
});
|
|
2626
|
+
(0, import_node_assert9.default)(this._isOpen, "Not open.");
|
|
2511
2627
|
(0, import_node_assert9.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2512
2628
|
const metadata = {
|
|
2513
2629
|
key: opts.spaceKey,
|
|
2514
|
-
genesisFeedKey: opts.genesisFeedKey
|
|
2630
|
+
genesisFeedKey: opts.genesisFeedKey,
|
|
2631
|
+
controlTimeframe: opts.controlTimeframe,
|
|
2632
|
+
dataTimeframe: opts.dataTimeframe
|
|
2515
2633
|
};
|
|
2516
2634
|
const space = await this._constructSpace(metadata);
|
|
2517
2635
|
await this._metadataStore.addSpace(metadata);
|
|
2518
|
-
|
|
2519
|
-
this._dataServiceSubscriptions.registerSpace(space.key, space.dataPipelineController.databaseBackend.createDataServiceHost());
|
|
2636
|
+
space.initializeDataPipelineAsync();
|
|
2520
2637
|
this.updated.emit();
|
|
2521
2638
|
return space;
|
|
2522
2639
|
}
|
|
2640
|
+
/**
|
|
2641
|
+
* Wait until the space data pipeline is fully initialized.
|
|
2642
|
+
* Used by invitation handler.
|
|
2643
|
+
* TODO(dmaretskyi): Consider removing.
|
|
2644
|
+
*/
|
|
2645
|
+
async waitUntilSpaceReady(spaceKey) {
|
|
2646
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
2647
|
+
const space = this._spaces.get(spaceKey);
|
|
2648
|
+
return !!space && space.state === import_client4.SpaceState.READY;
|
|
2649
|
+
}));
|
|
2650
|
+
}
|
|
2523
2651
|
async _constructSpace(metadata) {
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2652
|
+
(0, import_log9.log)("construct space", {
|
|
2653
|
+
metadata
|
|
2654
|
+
}, {
|
|
2655
|
+
file: "data-space-manager.ts",
|
|
2656
|
+
line: 175,
|
|
2657
|
+
scope: this,
|
|
2658
|
+
callSite: (f, a) => f(...a)
|
|
2659
|
+
});
|
|
2660
|
+
const gossip = new import_teleport_extension_gossip.Gossip({
|
|
2661
|
+
localPeerId: this._signingContext.deviceKey
|
|
2662
|
+
});
|
|
2663
|
+
const presence = new import_teleport_extension_gossip.Presence({
|
|
2664
|
+
announceInterval: 500,
|
|
2665
|
+
offlineTimeout: 5e3,
|
|
2666
|
+
identityKey: this._signingContext.identityKey,
|
|
2667
|
+
gossip
|
|
2529
2668
|
});
|
|
2530
2669
|
const snapshotManager = new import_echo_pipeline2.SnapshotManager(this._snapshotStore);
|
|
2531
2670
|
const controlFeed = metadata.controlFeedKey && await this._feedStore.openFeed(metadata.controlFeedKey, {
|
|
@@ -2542,7 +2681,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2542
2681
|
credentialAuthenticator: (0, import_util5.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
2543
2682
|
},
|
|
2544
2683
|
onNetworkConnection: (session) => {
|
|
2545
|
-
session.addExtension("dxos.mesh.teleport.
|
|
2684
|
+
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
2546
2685
|
remotePeerId: session.remotePeerId
|
|
2547
2686
|
}));
|
|
2548
2687
|
session.addExtension("dxos.mesh.teleport.objectsync", snapshotManager.objectSync.createExtension());
|
|
@@ -2556,14 +2695,48 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2556
2695
|
modelFactory: this._modelFactory,
|
|
2557
2696
|
metadataStore: this._metadataStore,
|
|
2558
2697
|
snapshotManager,
|
|
2698
|
+
gossip,
|
|
2559
2699
|
presence,
|
|
2560
2700
|
memberKey: this._signingContext.identityKey,
|
|
2561
2701
|
keyring: this._keyring,
|
|
2562
2702
|
feedStore: this._feedStore,
|
|
2563
2703
|
signingContext: this._signingContext,
|
|
2564
|
-
snapshotId: metadata.snapshot
|
|
2704
|
+
snapshotId: metadata.snapshot,
|
|
2705
|
+
callbacks: {
|
|
2706
|
+
beforeReady: async () => {
|
|
2707
|
+
(0, import_log9.log)("before space ready", {
|
|
2708
|
+
space: space.key
|
|
2709
|
+
}, {
|
|
2710
|
+
file: "data-space-manager.ts",
|
|
2711
|
+
line: 224,
|
|
2712
|
+
scope: this,
|
|
2713
|
+
callSite: (f, a) => f(...a)
|
|
2714
|
+
});
|
|
2715
|
+
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseBackend.createDataServiceHost());
|
|
2716
|
+
},
|
|
2717
|
+
afterReady: async () => {
|
|
2718
|
+
(0, import_log9.log)("after space ready", {
|
|
2719
|
+
space: space.key,
|
|
2720
|
+
open: this._isOpen
|
|
2721
|
+
}, {
|
|
2722
|
+
file: "data-space-manager.ts",
|
|
2723
|
+
line: 231,
|
|
2724
|
+
scope: this,
|
|
2725
|
+
callSite: (f, a) => f(...a)
|
|
2726
|
+
});
|
|
2727
|
+
if (this._isOpen) {
|
|
2728
|
+
this.updated.emit();
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2565
2732
|
});
|
|
2566
2733
|
await dataSpace.open();
|
|
2734
|
+
if (metadata.controlTimeframe) {
|
|
2735
|
+
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
2736
|
+
}
|
|
2737
|
+
if (metadata.dataTimeframe) {
|
|
2738
|
+
dataSpace.dataPipeline.setTargetTimeframe(metadata.dataTimeframe);
|
|
2739
|
+
}
|
|
2567
2740
|
this._spaces.set(metadata.key, dataSpace);
|
|
2568
2741
|
return dataSpace;
|
|
2569
2742
|
}
|
|
@@ -2589,9 +2762,10 @@ var import_async12 = require("@dxos/async");
|
|
|
2589
2762
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2590
2763
|
var import_debug4 = require("@dxos/debug");
|
|
2591
2764
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
2592
|
-
var
|
|
2765
|
+
var import_log10 = require("@dxos/log");
|
|
2593
2766
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2594
2767
|
var import_util6 = require("@dxos/util");
|
|
2768
|
+
var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
|
|
2595
2769
|
var SpacesServiceImpl = class {
|
|
2596
2770
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
2597
2771
|
this._identityManager = _identityManager;
|
|
@@ -2614,12 +2788,12 @@ var SpacesServiceImpl = class {
|
|
|
2614
2788
|
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
2615
2789
|
const onUpdate = async () => {
|
|
2616
2790
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2617
|
-
const spaces = Array.from(dataSpaceManager.spaces.values()).
|
|
2618
|
-
(0,
|
|
2791
|
+
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._transformSpace(space));
|
|
2792
|
+
(0, import_log10.log)("update", {
|
|
2619
2793
|
spaces
|
|
2620
2794
|
}, {
|
|
2621
2795
|
file: "spaces-service.ts",
|
|
2622
|
-
line:
|
|
2796
|
+
line: 60,
|
|
2623
2797
|
scope: this,
|
|
2624
2798
|
callSite: (f, a) => f(...a)
|
|
2625
2799
|
});
|
|
@@ -2627,28 +2801,27 @@ var SpacesServiceImpl = class {
|
|
|
2627
2801
|
spaces
|
|
2628
2802
|
});
|
|
2629
2803
|
};
|
|
2630
|
-
|
|
2804
|
+
(0, import_async12.scheduleTask)(ctx, async () => {
|
|
2631
2805
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2632
2806
|
const subscriptions = new import_async12.EventSubscriptions();
|
|
2807
|
+
ctx.onDispose(() => subscriptions.clear());
|
|
2633
2808
|
const subscribeSpaces = () => {
|
|
2634
2809
|
subscriptions.clear();
|
|
2635
2810
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
2636
|
-
if (!this._dataServiceSubscriptions.getDataService(space.key)) {
|
|
2637
|
-
continue;
|
|
2638
|
-
}
|
|
2639
2811
|
subscriptions.add(space.stateUpdate.on(ctx, onUpdate));
|
|
2640
2812
|
subscriptions.add(space.presence.updated.on(ctx, onUpdate));
|
|
2813
|
+
space.inner.controlPipeline.state.timeframeUpdate.debounce(TIMEFRAME_UPDATE_DEBOUNCE_TIME).on(ctx, onUpdate);
|
|
2814
|
+
if (space.dataPipeline.pipelineState) {
|
|
2815
|
+
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.debounce(TIMEFRAME_UPDATE_DEBOUNCE_TIME).on(ctx, onUpdate));
|
|
2816
|
+
}
|
|
2641
2817
|
}
|
|
2642
2818
|
};
|
|
2643
2819
|
dataSpaceManager.updated.on(ctx, () => {
|
|
2644
2820
|
subscribeSpaces();
|
|
2645
2821
|
void onUpdate();
|
|
2646
2822
|
});
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
subscribeSpaces();
|
|
2650
|
-
void onUpdate();
|
|
2651
|
-
});
|
|
2823
|
+
subscribeSpaces();
|
|
2824
|
+
void onUpdate();
|
|
2652
2825
|
});
|
|
2653
2826
|
if (!this._identityManager.identity) {
|
|
2654
2827
|
next({
|
|
@@ -2657,6 +2830,25 @@ var SpacesServiceImpl = class {
|
|
|
2657
2830
|
}
|
|
2658
2831
|
});
|
|
2659
2832
|
}
|
|
2833
|
+
async postMessage({ spaceKey, channel, message }) {
|
|
2834
|
+
var _a;
|
|
2835
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2836
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug4.raise)(new import_echo_pipeline3.SpaceNotFoundError(spaceKey));
|
|
2837
|
+
await space.postMessage(getChannelId(channel), message);
|
|
2838
|
+
}
|
|
2839
|
+
subscribeMessages({ spaceKey, channel }) {
|
|
2840
|
+
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
2841
|
+
(0, import_async12.scheduleTask)(ctx, async () => {
|
|
2842
|
+
var _a;
|
|
2843
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2844
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug4.raise)(new import_echo_pipeline3.SpaceNotFoundError(spaceKey));
|
|
2845
|
+
const handle = space.listen(getChannelId(channel), (message) => {
|
|
2846
|
+
next(message);
|
|
2847
|
+
});
|
|
2848
|
+
ctx.onDispose(() => handle.unsubscribe());
|
|
2849
|
+
});
|
|
2850
|
+
});
|
|
2851
|
+
}
|
|
2660
2852
|
queryCredentials({ spaceKey }) {
|
|
2661
2853
|
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
2662
2854
|
var _a;
|
|
@@ -2682,16 +2874,23 @@ var SpacesServiceImpl = class {
|
|
|
2682
2874
|
}
|
|
2683
2875
|
}
|
|
2684
2876
|
_transformSpace(space) {
|
|
2877
|
+
var _a, _b;
|
|
2685
2878
|
return {
|
|
2686
2879
|
spaceKey: space.key,
|
|
2687
|
-
|
|
2880
|
+
state: space.state,
|
|
2881
|
+
pipeline: {
|
|
2882
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2883
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2884
|
+
currentDataTimeframe: (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.timeframe,
|
|
2885
|
+
targetDataTimeframe: (_b = space.dataPipeline.pipelineState) == null ? void 0 : _b.targetTimeframe
|
|
2886
|
+
},
|
|
2688
2887
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
2689
|
-
var
|
|
2888
|
+
var _a2, _b2, _c;
|
|
2690
2889
|
return {
|
|
2691
2890
|
identity: {
|
|
2692
2891
|
identityKey: member.key,
|
|
2693
2892
|
profile: {
|
|
2694
|
-
displayName: (
|
|
2893
|
+
displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : (0, import_util6.humanize)(member.key)
|
|
2695
2894
|
}
|
|
2696
2895
|
},
|
|
2697
2896
|
presence: ((_c = this._identityManager.identity) == null ? void 0 : _c.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services5.SpaceMember.PresenceState.ONLINE : import_services5.SpaceMember.PresenceState.OFFLINE
|
|
@@ -2700,25 +2899,26 @@ var SpacesServiceImpl = class {
|
|
|
2700
2899
|
};
|
|
2701
2900
|
}
|
|
2702
2901
|
};
|
|
2902
|
+
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
2703
2903
|
|
|
2704
2904
|
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
2705
|
-
var
|
|
2905
|
+
var import_errors2 = require("@dxos/errors");
|
|
2706
2906
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
2707
2907
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
2708
2908
|
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
2709
2909
|
var createStorageObjects = (config) => {
|
|
2710
2910
|
const { path = "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
|
|
2711
2911
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
2712
|
-
throw new
|
|
2912
|
+
throw new import_errors2.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
2713
2913
|
}
|
|
2714
2914
|
if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
|
|
2715
|
-
throw new
|
|
2915
|
+
throw new import_errors2.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
2716
2916
|
}
|
|
2717
2917
|
if (persistent && keyStorage === StorageDriver.RAM) {
|
|
2718
|
-
throw new
|
|
2918
|
+
throw new import_errors2.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
2719
2919
|
}
|
|
2720
2920
|
if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
|
|
2721
|
-
throw new
|
|
2921
|
+
throw new import_errors2.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
2722
2922
|
}
|
|
2723
2923
|
return {
|
|
2724
2924
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -2786,7 +2986,7 @@ var SystemServiceImpl = class {
|
|
|
2786
2986
|
|
|
2787
2987
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
2788
2988
|
var import_async14 = require("@dxos/async");
|
|
2789
|
-
var
|
|
2989
|
+
var import_log11 = require("@dxos/log");
|
|
2790
2990
|
var import_messaging = require("@dxos/messaging");
|
|
2791
2991
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
2792
2992
|
var import_util7 = require("@dxos/util");
|
|
@@ -2847,7 +3047,7 @@ var ClientRpcServer = class {
|
|
|
2847
3047
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
2848
3048
|
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2849
3049
|
var import_async13 = require("@dxos/async");
|
|
2850
|
-
var
|
|
3050
|
+
var import_client5 = require("@dxos/client");
|
|
2851
3051
|
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
2852
3052
|
var import_rpc2 = require("@dxos/rpc");
|
|
2853
3053
|
var ShellRuntimeImpl = class {
|
|
@@ -2880,8 +3080,8 @@ var ShellRuntimeImpl = class {
|
|
|
2880
3080
|
}
|
|
2881
3081
|
async open() {
|
|
2882
3082
|
this._appRpc = (0, import_rpc2.createProtoRpcPeer)({
|
|
2883
|
-
requested:
|
|
2884
|
-
exposed:
|
|
3083
|
+
requested: import_client5.appServiceBundle,
|
|
3084
|
+
exposed: import_client5.shellServiceBundle,
|
|
2885
3085
|
handlers: {
|
|
2886
3086
|
ShellService: {
|
|
2887
3087
|
setLayout: async (request) => {
|
|
@@ -2964,7 +3164,7 @@ var IFrameHostRuntime = class {
|
|
|
2964
3164
|
}
|
|
2965
3165
|
async start() {
|
|
2966
3166
|
var _a;
|
|
2967
|
-
(0,
|
|
3167
|
+
(0, import_log11.log)("starting...", {}, {
|
|
2968
3168
|
file: "iframe-host-runtime.ts",
|
|
2969
3169
|
line: 67,
|
|
2970
3170
|
scope: this,
|
|
@@ -3015,7 +3215,7 @@ var IFrameHostRuntime = class {
|
|
|
3015
3215
|
(_a = this._shellRuntime) == null ? void 0 : _a.open()
|
|
3016
3216
|
]);
|
|
3017
3217
|
this._ready.wake(void 0);
|
|
3018
|
-
(0,
|
|
3218
|
+
(0, import_log11.log)("started", {}, {
|
|
3019
3219
|
file: "iframe-host-runtime.ts",
|
|
3020
3220
|
line: 110,
|
|
3021
3221
|
scope: this,
|
|
@@ -3023,7 +3223,7 @@ var IFrameHostRuntime = class {
|
|
|
3023
3223
|
});
|
|
3024
3224
|
} catch (err) {
|
|
3025
3225
|
this._ready.wake(err);
|
|
3026
|
-
|
|
3226
|
+
import_log11.log.catch(err, {}, {
|
|
3027
3227
|
file: "iframe-host-runtime.ts",
|
|
3028
3228
|
line: 113,
|
|
3029
3229
|
scope: this,
|
|
@@ -3033,7 +3233,7 @@ var IFrameHostRuntime = class {
|
|
|
3033
3233
|
}
|
|
3034
3234
|
async stop() {
|
|
3035
3235
|
var _a;
|
|
3036
|
-
(0,
|
|
3236
|
+
(0, import_log11.log)("stopping...", {}, {
|
|
3037
3237
|
file: "iframe-host-runtime.ts",
|
|
3038
3238
|
line: 118,
|
|
3039
3239
|
scope: this,
|
|
@@ -3042,7 +3242,7 @@ var IFrameHostRuntime = class {
|
|
|
3042
3242
|
await this._clientRpc.close();
|
|
3043
3243
|
await this._clientServices.close();
|
|
3044
3244
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
3045
|
-
(0,
|
|
3245
|
+
(0, import_log11.log)("stopped", {}, {
|
|
3046
3246
|
file: "iframe-host-runtime.ts",
|
|
3047
3247
|
line: 122,
|
|
3048
3248
|
scope: this,
|
|
@@ -3051,11 +3251,11 @@ var IFrameHostRuntime = class {
|
|
|
3051
3251
|
}
|
|
3052
3252
|
};
|
|
3053
3253
|
__decorate3([
|
|
3054
|
-
|
|
3254
|
+
import_log11.logInfo
|
|
3055
3255
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
3056
3256
|
|
|
3057
3257
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
3058
|
-
var
|
|
3258
|
+
var import_client6 = require("@dxos/client");
|
|
3059
3259
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
3060
3260
|
var import_rpc3 = require("@dxos/rpc");
|
|
3061
3261
|
var IFrameProxyRuntime = class {
|
|
@@ -3066,8 +3266,8 @@ var IFrameProxyRuntime = class {
|
|
|
3066
3266
|
this._workerAppPort = workerAppPort;
|
|
3067
3267
|
this._shellPort = shellPort;
|
|
3068
3268
|
this._systemRpc = (0, import_rpc3.createProtoRpcPeer)({
|
|
3069
|
-
requested:
|
|
3070
|
-
exposed:
|
|
3269
|
+
requested: import_client6.workerServiceBundle,
|
|
3270
|
+
exposed: import_client6.iframeServiceBundle,
|
|
3071
3271
|
handlers: {
|
|
3072
3272
|
BridgeService: this._transportService,
|
|
3073
3273
|
IframeService: {
|
|
@@ -3105,7 +3305,17 @@ var IFrameProxyRuntime = class {
|
|
|
3105
3305
|
|
|
3106
3306
|
// packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
|
|
3107
3307
|
var import_async15 = require("@dxos/async");
|
|
3108
|
-
var
|
|
3308
|
+
var import_log12 = require("@dxos/log");
|
|
3309
|
+
var __decorate4 = function(decorators, target, key, desc) {
|
|
3310
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3311
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3312
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3313
|
+
else
|
|
3314
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3315
|
+
if (d = decorators[i])
|
|
3316
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3317
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3318
|
+
};
|
|
3109
3319
|
var Message;
|
|
3110
3320
|
(function(Message2) {
|
|
3111
3321
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -3119,14 +3329,41 @@ var VaultResourceLock = class {
|
|
|
3119
3329
|
this._onRelease = onRelease;
|
|
3120
3330
|
this._broadcastChannel.onmessage = this._onMessage.bind(this);
|
|
3121
3331
|
}
|
|
3332
|
+
get lockKey() {
|
|
3333
|
+
return this._lockKey;
|
|
3334
|
+
}
|
|
3122
3335
|
async acquire() {
|
|
3123
3336
|
this._broadcastChannel.postMessage({
|
|
3124
3337
|
message: Message.ACQUIRING
|
|
3125
3338
|
});
|
|
3126
3339
|
try {
|
|
3340
|
+
(0, import_log12.log)("aquiring lock...", {}, {
|
|
3341
|
+
file: "vault-resource-lock.ts",
|
|
3342
|
+
line: 44,
|
|
3343
|
+
scope: this,
|
|
3344
|
+
callSite: (f, a) => f(...a)
|
|
3345
|
+
});
|
|
3127
3346
|
await (0, import_async15.asyncTimeout)(this._requestLock(), 3e3);
|
|
3347
|
+
(0, import_log12.log)("acquired lock", {}, {
|
|
3348
|
+
file: "vault-resource-lock.ts",
|
|
3349
|
+
line: 46,
|
|
3350
|
+
scope: this,
|
|
3351
|
+
callSite: (f, a) => f(...a)
|
|
3352
|
+
});
|
|
3128
3353
|
} catch (e) {
|
|
3354
|
+
(0, import_log12.log)("stealing lock...", {}, {
|
|
3355
|
+
file: "vault-resource-lock.ts",
|
|
3356
|
+
line: 48,
|
|
3357
|
+
scope: this,
|
|
3358
|
+
callSite: (f, a) => f(...a)
|
|
3359
|
+
});
|
|
3129
3360
|
await this._requestLock(true);
|
|
3361
|
+
(0, import_log12.log)("stolen lock", {}, {
|
|
3362
|
+
file: "vault-resource-lock.ts",
|
|
3363
|
+
line: 50,
|
|
3364
|
+
scope: this,
|
|
3365
|
+
callSite: (f, a) => f(...a)
|
|
3366
|
+
});
|
|
3130
3367
|
}
|
|
3131
3368
|
}
|
|
3132
3369
|
async release() {
|
|
@@ -3138,11 +3375,11 @@ var VaultResourceLock = class {
|
|
|
3138
3375
|
}
|
|
3139
3376
|
}
|
|
3140
3377
|
async _requestLock(steal = false) {
|
|
3141
|
-
(0,
|
|
3378
|
+
(0, import_log12.log)("requesting lock...", {
|
|
3142
3379
|
steal
|
|
3143
3380
|
}, {
|
|
3144
3381
|
file: "vault-resource-lock.ts",
|
|
3145
|
-
line:
|
|
3382
|
+
line: 65,
|
|
3146
3383
|
scope: this,
|
|
3147
3384
|
callSite: (f, a) => f(...a)
|
|
3148
3385
|
});
|
|
@@ -3155,16 +3392,16 @@ var VaultResourceLock = class {
|
|
|
3155
3392
|
acquired.wake();
|
|
3156
3393
|
this._releaseTrigger = new import_async15.Trigger();
|
|
3157
3394
|
await this._releaseTrigger.wait();
|
|
3158
|
-
(0,
|
|
3395
|
+
(0, import_log12.log)("releasing lock...", {}, {
|
|
3159
3396
|
file: "vault-resource-lock.ts",
|
|
3160
|
-
line:
|
|
3397
|
+
line: 74,
|
|
3161
3398
|
scope: this,
|
|
3162
3399
|
callSite: (f, a) => f(...a)
|
|
3163
3400
|
});
|
|
3164
3401
|
await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
|
|
3165
|
-
(0,
|
|
3402
|
+
(0, import_log12.log)("released lock", {}, {
|
|
3166
3403
|
file: "vault-resource-lock.ts",
|
|
3167
|
-
line:
|
|
3404
|
+
line: 76,
|
|
3168
3405
|
scope: this,
|
|
3169
3406
|
callSite: (f, a) => f(...a)
|
|
3170
3407
|
});
|
|
@@ -3173,31 +3410,34 @@ var VaultResourceLock = class {
|
|
|
3173
3410
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3174
3411
|
});
|
|
3175
3412
|
await acquired.wait();
|
|
3176
|
-
(0,
|
|
3413
|
+
(0, import_log12.log)("recieved lock", {
|
|
3177
3414
|
steal
|
|
3178
3415
|
}, {
|
|
3179
3416
|
file: "vault-resource-lock.ts",
|
|
3180
|
-
line:
|
|
3417
|
+
line: 83,
|
|
3181
3418
|
scope: this,
|
|
3182
3419
|
callSite: (f, a) => f(...a)
|
|
3183
3420
|
});
|
|
3184
3421
|
}
|
|
3185
3422
|
};
|
|
3423
|
+
__decorate4([
|
|
3424
|
+
import_log12.logInfo
|
|
3425
|
+
], VaultResourceLock.prototype, "lockKey", null);
|
|
3186
3426
|
|
|
3187
3427
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
3188
3428
|
var import_async17 = require("@dxos/async");
|
|
3189
|
-
var
|
|
3429
|
+
var import_log14 = require("@dxos/log");
|
|
3190
3430
|
var import_messaging2 = require("@dxos/messaging");
|
|
3191
3431
|
var import_network_manager5 = require("@dxos/network-manager");
|
|
3192
3432
|
|
|
3193
3433
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
3194
3434
|
var import_node_assert11 = __toESM(require("node:assert"));
|
|
3195
3435
|
var import_async16 = require("@dxos/async");
|
|
3196
|
-
var
|
|
3197
|
-
var
|
|
3436
|
+
var import_client7 = require("@dxos/client");
|
|
3437
|
+
var import_log13 = require("@dxos/log");
|
|
3198
3438
|
var import_rpc4 = require("@dxos/rpc");
|
|
3199
3439
|
var import_util8 = require("@dxos/util");
|
|
3200
|
-
var
|
|
3440
|
+
var __decorate5 = function(decorators, target, key, desc) {
|
|
3201
3441
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3202
3442
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3203
3443
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3248,8 +3488,8 @@ var WorkerSession = class {
|
|
|
3248
3488
|
...middleware
|
|
3249
3489
|
});
|
|
3250
3490
|
this._iframeRpc = (0, import_rpc4.createProtoRpcPeer)({
|
|
3251
|
-
requested:
|
|
3252
|
-
exposed:
|
|
3491
|
+
requested: import_client7.iframeServiceBundle,
|
|
3492
|
+
exposed: import_client7.workerServiceBundle,
|
|
3253
3493
|
handlers: {
|
|
3254
3494
|
WorkerService: {
|
|
3255
3495
|
start: async (request) => {
|
|
@@ -3261,7 +3501,7 @@ var WorkerSession = class {
|
|
|
3261
3501
|
try {
|
|
3262
3502
|
await this.close();
|
|
3263
3503
|
} catch (err) {
|
|
3264
|
-
|
|
3504
|
+
import_log13.log.catch(err, {}, {
|
|
3265
3505
|
file: "worker-session.ts",
|
|
3266
3506
|
line: 107,
|
|
3267
3507
|
scope: this,
|
|
@@ -3279,7 +3519,7 @@ var WorkerSession = class {
|
|
|
3279
3519
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
3280
3520
|
}
|
|
3281
3521
|
async open() {
|
|
3282
|
-
|
|
3522
|
+
import_log13.log.info("opening..", {}, {
|
|
3283
3523
|
file: "worker-session.ts",
|
|
3284
3524
|
line: 121,
|
|
3285
3525
|
scope: this,
|
|
@@ -3297,7 +3537,7 @@ var WorkerSession = class {
|
|
|
3297
3537
|
try {
|
|
3298
3538
|
await this._iframeRpc.rpc.IframeService.heartbeat();
|
|
3299
3539
|
} catch (err1) {
|
|
3300
|
-
|
|
3540
|
+
import_log13.log.warn("Heartbeat failed", {
|
|
3301
3541
|
err: err1
|
|
3302
3542
|
}, {
|
|
3303
3543
|
file: "worker-session.ts",
|
|
@@ -3308,7 +3548,7 @@ var WorkerSession = class {
|
|
|
3308
3548
|
try {
|
|
3309
3549
|
await this.close();
|
|
3310
3550
|
} catch (err) {
|
|
3311
|
-
|
|
3551
|
+
import_log13.log.catch(err, {}, {
|
|
3312
3552
|
file: "worker-session.ts",
|
|
3313
3553
|
line: 137,
|
|
3314
3554
|
scope: this,
|
|
@@ -3319,7 +3559,7 @@ var WorkerSession = class {
|
|
|
3319
3559
|
}, this._options.heartbeatInterval);
|
|
3320
3560
|
}
|
|
3321
3561
|
async close() {
|
|
3322
|
-
|
|
3562
|
+
import_log13.log.info("closing..", {}, {
|
|
3323
3563
|
file: "worker-session.ts",
|
|
3324
3564
|
line: 144,
|
|
3325
3565
|
scope: this,
|
|
@@ -3328,7 +3568,7 @@ var WorkerSession = class {
|
|
|
3328
3568
|
try {
|
|
3329
3569
|
await this.onClose.callIfSet();
|
|
3330
3570
|
} catch (err) {
|
|
3331
|
-
|
|
3571
|
+
import_log13.log.catch(err, {}, {
|
|
3332
3572
|
file: "worker-session.ts",
|
|
3333
3573
|
line: 148,
|
|
3334
3574
|
scope: this,
|
|
@@ -3347,7 +3587,7 @@ var WorkerSession = class {
|
|
|
3347
3587
|
try {
|
|
3348
3588
|
await (0, import_async16.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
3349
3589
|
} catch (e) {
|
|
3350
|
-
|
|
3590
|
+
import_log13.log.info("No shell connected.", {}, {
|
|
3351
3591
|
file: "worker-session.ts",
|
|
3352
3592
|
line: 162,
|
|
3353
3593
|
scope: this,
|
|
@@ -3356,8 +3596,8 @@ var WorkerSession = class {
|
|
|
3356
3596
|
}
|
|
3357
3597
|
}
|
|
3358
3598
|
};
|
|
3359
|
-
|
|
3360
|
-
|
|
3599
|
+
__decorate5([
|
|
3600
|
+
import_log13.logInfo
|
|
3361
3601
|
], WorkerSession.prototype, "origin", void 0);
|
|
3362
3602
|
|
|
3363
3603
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
@@ -3371,7 +3611,7 @@ var WorkerRuntime = class {
|
|
|
3371
3611
|
this._clientServices = new ClientServicesHost();
|
|
3372
3612
|
}
|
|
3373
3613
|
async start() {
|
|
3374
|
-
(0,
|
|
3614
|
+
(0, import_log14.log)("starting...", {}, {
|
|
3375
3615
|
file: "worker-runtime.ts",
|
|
3376
3616
|
line: 44,
|
|
3377
3617
|
scope: this,
|
|
@@ -3392,7 +3632,7 @@ var WorkerRuntime = class {
|
|
|
3392
3632
|
});
|
|
3393
3633
|
await this._clientServices.open();
|
|
3394
3634
|
this._ready.wake(void 0);
|
|
3395
|
-
(0,
|
|
3635
|
+
(0, import_log14.log)("started", {}, {
|
|
3396
3636
|
file: "worker-runtime.ts",
|
|
3397
3637
|
line: 61,
|
|
3398
3638
|
scope: this,
|
|
@@ -3400,7 +3640,7 @@ var WorkerRuntime = class {
|
|
|
3400
3640
|
});
|
|
3401
3641
|
} catch (err) {
|
|
3402
3642
|
this._ready.wake(err);
|
|
3403
|
-
|
|
3643
|
+
import_log14.log.catch(err, {}, {
|
|
3404
3644
|
file: "worker-runtime.ts",
|
|
3405
3645
|
line: 64,
|
|
3406
3646
|
scope: this,
|
|
@@ -3458,7 +3698,7 @@ var import_debug6 = require("@dxos/debug");
|
|
|
3458
3698
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3459
3699
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
3460
3700
|
var import_keyring = require("@dxos/keyring");
|
|
3461
|
-
var
|
|
3701
|
+
var import_log15 = require("@dxos/log");
|
|
3462
3702
|
var ServiceContext = class {
|
|
3463
3703
|
// prettier-ignore
|
|
3464
3704
|
constructor(storage, networkManager, modelFactory) {
|
|
@@ -3495,7 +3735,7 @@ var ServiceContext = class {
|
|
|
3495
3735
|
});
|
|
3496
3736
|
}
|
|
3497
3737
|
async open() {
|
|
3498
|
-
(0,
|
|
3738
|
+
(0, import_log15.log)("opening...", {}, {
|
|
3499
3739
|
file: "service-context.ts",
|
|
3500
3740
|
line: 94,
|
|
3501
3741
|
scope: this,
|
|
@@ -3507,7 +3747,7 @@ var ServiceContext = class {
|
|
|
3507
3747
|
if (this.identityManager.identity) {
|
|
3508
3748
|
await this._initialize();
|
|
3509
3749
|
}
|
|
3510
|
-
(0,
|
|
3750
|
+
(0, import_log15.log)("opened", {}, {
|
|
3511
3751
|
file: "service-context.ts",
|
|
3512
3752
|
line: 101,
|
|
3513
3753
|
scope: this,
|
|
@@ -3516,7 +3756,7 @@ var ServiceContext = class {
|
|
|
3516
3756
|
}
|
|
3517
3757
|
async close() {
|
|
3518
3758
|
var _a, _b;
|
|
3519
|
-
(0,
|
|
3759
|
+
(0, import_log15.log)("closing...", {}, {
|
|
3520
3760
|
file: "service-context.ts",
|
|
3521
3761
|
line: 105,
|
|
3522
3762
|
scope: this,
|
|
@@ -3529,7 +3769,7 @@ var ServiceContext = class {
|
|
|
3529
3769
|
await this.feedStore.close();
|
|
3530
3770
|
await this.networkManager.close();
|
|
3531
3771
|
this.dataServiceSubscriptions.clear();
|
|
3532
|
-
(0,
|
|
3772
|
+
(0, import_log15.log)("closed", {}, {
|
|
3533
3773
|
file: "service-context.ts",
|
|
3534
3774
|
line: 113,
|
|
3535
3775
|
scope: this,
|
|
@@ -3537,7 +3777,7 @@ var ServiceContext = class {
|
|
|
3537
3777
|
});
|
|
3538
3778
|
}
|
|
3539
3779
|
async reset() {
|
|
3540
|
-
(0,
|
|
3780
|
+
(0, import_log15.log)("resetting...", {}, {
|
|
3541
3781
|
file: "service-context.ts",
|
|
3542
3782
|
line: 117,
|
|
3543
3783
|
scope: this,
|
|
@@ -3545,7 +3785,7 @@ var ServiceContext = class {
|
|
|
3545
3785
|
});
|
|
3546
3786
|
await this.close();
|
|
3547
3787
|
await this.storage.reset();
|
|
3548
|
-
(0,
|
|
3788
|
+
(0, import_log15.log)("reset", {}, {
|
|
3549
3789
|
file: "service-context.ts",
|
|
3550
3790
|
line: 120,
|
|
3551
3791
|
scope: this,
|
|
@@ -3565,7 +3805,7 @@ var ServiceContext = class {
|
|
|
3565
3805
|
// Called when identity is created.
|
|
3566
3806
|
async _initialize() {
|
|
3567
3807
|
var _a;
|
|
3568
|
-
(0,
|
|
3808
|
+
(0, import_log15.log)("initializing spaces...", {}, {
|
|
3569
3809
|
file: "service-context.ts",
|
|
3570
3810
|
line: 139,
|
|
3571
3811
|
scope: this,
|
|
@@ -3599,7 +3839,7 @@ var ServiceContext = class {
|
|
|
3599
3839
|
return;
|
|
3600
3840
|
}
|
|
3601
3841
|
if (!this.dataSpaceManager) {
|
|
3602
|
-
(0,
|
|
3842
|
+
(0, import_log15.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3603
3843
|
details: assertion
|
|
3604
3844
|
}, {
|
|
3605
3845
|
file: "service-context.ts",
|
|
@@ -3610,7 +3850,7 @@ var ServiceContext = class {
|
|
|
3610
3850
|
return;
|
|
3611
3851
|
}
|
|
3612
3852
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3613
|
-
(0,
|
|
3853
|
+
(0, import_log15.log)("space already exists, ignoring space admission", {
|
|
3614
3854
|
details: assertion
|
|
3615
3855
|
}, {
|
|
3616
3856
|
file: "service-context.ts",
|
|
@@ -3621,7 +3861,7 @@ var ServiceContext = class {
|
|
|
3621
3861
|
return;
|
|
3622
3862
|
}
|
|
3623
3863
|
try {
|
|
3624
|
-
(0,
|
|
3864
|
+
(0, import_log15.log)("accepting space recorded in halo", {
|
|
3625
3865
|
details: assertion
|
|
3626
3866
|
}, {
|
|
3627
3867
|
file: "service-context.ts",
|
|
@@ -3634,7 +3874,7 @@ var ServiceContext = class {
|
|
|
3634
3874
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3635
3875
|
});
|
|
3636
3876
|
} catch (err) {
|
|
3637
|
-
|
|
3877
|
+
import_log15.log.catch(err, {}, {
|
|
3638
3878
|
file: "service-context.ts",
|
|
3639
3879
|
line: 197,
|
|
3640
3880
|
scope: this,
|
|
@@ -3675,7 +3915,7 @@ var ServiceRegistry = class {
|
|
|
3675
3915
|
var ClientServicesHost = class {
|
|
3676
3916
|
constructor({
|
|
3677
3917
|
config,
|
|
3678
|
-
modelFactory = (0,
|
|
3918
|
+
modelFactory = (0, import_client8.createDefaultModelFactory)(),
|
|
3679
3919
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3680
3920
|
networkManager,
|
|
3681
3921
|
storage,
|
|
@@ -3683,6 +3923,7 @@ var ClientServicesHost = class {
|
|
|
3683
3923
|
lockKey
|
|
3684
3924
|
} = {}) {
|
|
3685
3925
|
this._statusUpdate = new import_async19.Event();
|
|
3926
|
+
this._opening = false;
|
|
3686
3927
|
this._open = false;
|
|
3687
3928
|
this._storage = storage;
|
|
3688
3929
|
this._modelFactory = modelFactory;
|
|
@@ -3694,7 +3935,9 @@ var ClientServicesHost = class {
|
|
|
3694
3935
|
}
|
|
3695
3936
|
this._resourceLock = lockKey ? new VaultResourceLock({
|
|
3696
3937
|
lockKey,
|
|
3697
|
-
onAcquire: () =>
|
|
3938
|
+
onAcquire: () => {
|
|
3939
|
+
this._opening || this.open();
|
|
3940
|
+
},
|
|
3698
3941
|
onRelease: () => this.close()
|
|
3699
3942
|
}) : void 0;
|
|
3700
3943
|
this._systemService = new SystemServiceImpl({
|
|
@@ -3714,7 +3957,7 @@ var ClientServicesHost = class {
|
|
|
3714
3957
|
await this._serviceContext.reset();
|
|
3715
3958
|
}
|
|
3716
3959
|
});
|
|
3717
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
3960
|
+
this._serviceRegistry = new ServiceRegistry(import_client8.clientServiceBundle, {
|
|
3718
3961
|
SystemService: this._systemService
|
|
3719
3962
|
});
|
|
3720
3963
|
}
|
|
@@ -3750,20 +3993,23 @@ var ClientServicesHost = class {
|
|
|
3750
3993
|
}
|
|
3751
3994
|
}
|
|
3752
3995
|
async open() {
|
|
3753
|
-
var _a, _b;
|
|
3996
|
+
var _a, _b, _c;
|
|
3754
3997
|
if (this._open) {
|
|
3755
3998
|
return;
|
|
3756
3999
|
}
|
|
3757
4000
|
(0, import_node_assert12.default)(this._config, "config not set");
|
|
3758
4001
|
(0, import_node_assert12.default)(this._storage, "storage not set");
|
|
3759
4002
|
(0, import_node_assert12.default)(this._networkManager, "network manager not set");
|
|
3760
|
-
|
|
4003
|
+
this._opening = true;
|
|
4004
|
+
(0, import_log16.log)("opening...", {
|
|
4005
|
+
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
4006
|
+
}, {
|
|
3761
4007
|
file: "service-host.ts",
|
|
3762
|
-
line:
|
|
4008
|
+
line: 170,
|
|
3763
4009
|
scope: this,
|
|
3764
4010
|
callSite: (f, a) => f(...a)
|
|
3765
4011
|
});
|
|
3766
|
-
await ((
|
|
4012
|
+
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
3767
4013
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._modelFactory);
|
|
3768
4014
|
this._serviceRegistry.setServices({
|
|
3769
4015
|
SystemService: this._systemService,
|
|
@@ -3792,14 +4038,15 @@ var ClientServicesHost = class {
|
|
|
3792
4038
|
})
|
|
3793
4039
|
});
|
|
3794
4040
|
await this._serviceContext.open();
|
|
4041
|
+
this._opening = false;
|
|
3795
4042
|
this._open = true;
|
|
3796
4043
|
this._statusUpdate.emit();
|
|
3797
|
-
const deviceKey = (
|
|
3798
|
-
(0,
|
|
4044
|
+
const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
|
|
4045
|
+
(0, import_log16.log)("opened", {
|
|
3799
4046
|
deviceKey
|
|
3800
4047
|
}, {
|
|
3801
4048
|
file: "service-host.ts",
|
|
3802
|
-
line:
|
|
4049
|
+
line: 224,
|
|
3803
4050
|
scope: this,
|
|
3804
4051
|
callSite: (f, a) => f(...a)
|
|
3805
4052
|
});
|
|
@@ -3810,11 +4057,11 @@ var ClientServicesHost = class {
|
|
|
3810
4057
|
return;
|
|
3811
4058
|
}
|
|
3812
4059
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
3813
|
-
(0,
|
|
4060
|
+
(0, import_log16.log)("closing...", {
|
|
3814
4061
|
deviceKey
|
|
3815
4062
|
}, {
|
|
3816
4063
|
file: "service-host.ts",
|
|
3817
|
-
line:
|
|
4064
|
+
line: 233,
|
|
3818
4065
|
scope: this,
|
|
3819
4066
|
callSite: (f, a) => f(...a)
|
|
3820
4067
|
});
|
|
@@ -3824,11 +4071,11 @@ var ClientServicesHost = class {
|
|
|
3824
4071
|
await this._serviceContext.close();
|
|
3825
4072
|
this._open = false;
|
|
3826
4073
|
this._statusUpdate.emit();
|
|
3827
|
-
(0,
|
|
4074
|
+
(0, import_log16.log)("closed", {
|
|
3828
4075
|
deviceKey
|
|
3829
4076
|
}, {
|
|
3830
4077
|
file: "service-host.ts",
|
|
3831
|
-
line:
|
|
4078
|
+
line: 238,
|
|
3832
4079
|
scope: this,
|
|
3833
4080
|
callSite: (f, a) => f(...a)
|
|
3834
4081
|
});
|
|
@@ -3859,7 +4106,7 @@ var LocalClientServices = class {
|
|
|
3859
4106
|
|
|
3860
4107
|
// packages/sdk/client-services/src/packlets/services/utils.ts
|
|
3861
4108
|
var import_config2 = require("@dxos/config");
|
|
3862
|
-
var
|
|
4109
|
+
var import_log17 = require("@dxos/log");
|
|
3863
4110
|
var import_messaging3 = require("@dxos/messaging");
|
|
3864
4111
|
var import_network_manager6 = require("@dxos/network-manager");
|
|
3865
4112
|
var fromHost = (config = new import_config2.Config()) => {
|
|
@@ -3882,7 +4129,7 @@ var createNetworkManager = (config, options = {}) => {
|
|
|
3882
4129
|
transportFactory
|
|
3883
4130
|
});
|
|
3884
4131
|
}
|
|
3885
|
-
|
|
4132
|
+
import_log17.log.warn("P2P network is not configured.", {}, {
|
|
3886
4133
|
file: "utils.ts",
|
|
3887
4134
|
line: 48,
|
|
3888
4135
|
scope: void 0,
|