@dxos/client-services 0.1.30-next.7c60cd3 → 0.1.31-next.ea8f0bc
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-JLLUQQXD.mjs → chunk-ZIQUYEJS.mjs} +898 -1132
- package/dist/lib/browser/chunk-ZIQUYEJS.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +5 -41
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +163 -50
- package/dist/lib/browser/packlets/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +785 -1043
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +2812 -2686
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/invitations/device-invitations-handler.d.ts +1 -2
- package/dist/types/src/packlets/invitations/device-invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitations-service.d.ts +1 -1
- package/dist/types/src/packlets/invitations/device-invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/index.d.ts +0 -6
- package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +2 -3
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts +2 -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 +2 -3
- package/dist/types/src/packlets/invitations/space-invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +22 -0
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -0
- package/dist/types/src/packlets/services/index.d.ts +2 -3
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/local-client-services.d.ts +3 -2
- package/dist/types/src/packlets/services/local-client-services.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +22 -8
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-registry.d.ts +3 -1
- package/dist/types/src/packlets/services/service-registry.d.ts.map +1 -1
- package/dist/types/src/packlets/services/utils.d.ts +7 -0
- package/dist/types/src/packlets/services/utils.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/index.d.ts +2 -0
- package/dist/types/src/packlets/spaces/index.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +2 -2
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/host-test-builder.d.ts +43 -0
- package/dist/types/src/packlets/testing/host-test-builder.d.ts.map +1 -0
- package/dist/types/src/packlets/testing/index.d.ts +1 -0
- package/dist/types/src/packlets/testing/index.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +30 -34
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/tests/client-services.test.d.ts +2 -0
- package/dist/types/src/packlets/tests/client-services.test.d.ts.map +1 -0
- package/dist/types/src/packlets/tests/client.test.d.ts +2 -0
- package/dist/types/src/packlets/tests/client.test.d.ts.map +1 -0
- package/dist/types/src/packlets/tests/halo-credentials.test.d.ts +2 -0
- package/dist/types/src/packlets/tests/halo-credentials.test.d.ts.map +1 -0
- package/dist/types/src/packlets/tests/halo-persistent.test.d.ts +2 -0
- package/dist/types/src/packlets/tests/halo-persistent.test.d.ts.map +1 -0
- package/dist/types/src/packlets/tests/halo-profile.test.d.ts +2 -0
- package/dist/types/src/packlets/tests/halo-profile.test.d.ts.map +1 -0
- package/dist/types/src/packlets/tests/shared-worker.test.d.ts +2 -0
- package/dist/types/src/packlets/tests/shared-worker.test.d.ts.map +1 -0
- package/dist/types/src/packlets/tests/spaces-invitations.test.d.ts +2 -0
- package/dist/types/src/packlets/tests/spaces-invitations.test.d.ts.map +1 -0
- package/dist/types/src/packlets/tests/spaces.test.d.ts +2 -0
- package/dist/types/src/packlets/tests/spaces.test.d.ts.map +1 -0
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +0 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/index.d.ts +0 -2
- package/dist/types/src/packlets/vault/index.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts +4 -4
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/package.json +30 -30
- package/src/packlets/invitations/device-invitations-handler.ts +10 -9
- package/src/packlets/invitations/device-invitations-service.test.ts +1 -1
- package/src/packlets/invitations/device-invitations-service.ts +1 -1
- package/src/packlets/invitations/index.ts +0 -6
- package/src/packlets/invitations/invitations-service.ts +7 -2
- package/src/packlets/invitations/space-invitations-handler.test.ts +3 -3
- package/src/packlets/invitations/space-invitations-handler.ts +11 -11
- package/src/packlets/invitations/space-invitations-service.test.ts +1 -1
- package/src/packlets/invitations/space-invitations-service.ts +2 -3
- package/src/packlets/services/client-rpc-server.ts +91 -0
- package/src/packlets/services/index.ts +2 -3
- package/src/packlets/services/local-client-services.ts +5 -1
- package/src/packlets/services/service-context.test.ts +4 -4
- package/src/packlets/services/service-context.ts +1 -1
- package/src/packlets/services/service-host.ts +52 -19
- package/src/packlets/services/service-registry.test.ts +2 -2
- package/src/packlets/services/service-registry.ts +9 -1
- package/src/packlets/services/utils.ts +53 -0
- package/src/packlets/spaces/data-space-manager.test.ts +4 -4
- package/src/packlets/spaces/index.ts +2 -0
- package/src/packlets/system/system-service.ts +3 -3
- package/src/packlets/testing/host-test-builder.ts +163 -0
- package/src/packlets/testing/index.ts +1 -0
- package/src/packlets/testing/invitation-utils.ts +1 -2
- package/src/packlets/testing/test-builder.ts +118 -140
- package/src/packlets/tests/client-services.test.ts +252 -0
- package/src/packlets/tests/client.test.ts +143 -0
- package/src/packlets/tests/halo-credentials.test.ts +94 -0
- package/src/packlets/tests/halo-persistent.test.ts +53 -0
- package/src/packlets/tests/halo-profile.test.ts +74 -0
- package/src/packlets/tests/shared-worker.test.ts +93 -0
- package/src/packlets/tests/spaces-invitations.test.ts +24 -0
- package/src/packlets/tests/spaces.test.ts +68 -0
- package/src/packlets/vault/iframe-host-runtime.ts +26 -34
- package/src/packlets/vault/iframe-proxy-runtime.ts +1 -1
- package/src/packlets/vault/index.ts +0 -2
- package/src/packlets/vault/shell-runtime.ts +1 -2
- package/src/packlets/vault/worker-runtime.ts +5 -15
- package/src/packlets/vault/worker-session.ts +39 -23
- package/dist/lib/browser/chunk-JLLUQQXD.mjs.map +0 -7
- package/dist/types/src/packlets/invitations/device-invitations-proxy.d.ts +0 -8
- package/dist/types/src/packlets/invitations/device-invitations-proxy.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/encoder.d.ts +0 -9
- package/dist/types/src/packlets/invitations/encoder.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/encoder.test.d.ts +0 -2
- package/dist/types/src/packlets/invitations/encoder.test.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +0 -56
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/invitations-proxy.d.ts +0 -18
- package/dist/types/src/packlets/invitations/invitations-proxy.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/invitations.d.ts +0 -55
- package/dist/types/src/packlets/invitations/invitations.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/space-invitations-proxy.d.ts +0 -11
- package/dist/types/src/packlets/invitations/space-invitations-proxy.d.ts.map +0 -1
- package/dist/types/src/packlets/services/service-definitions.d.ts +0 -30
- package/dist/types/src/packlets/services/service-definitions.d.ts.map +0 -1
- package/dist/types/src/packlets/services/service-proxy.d.ts +0 -17
- package/dist/types/src/packlets/services/service-proxy.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/services.d.ts +0 -21
- package/dist/types/src/packlets/vault/services.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/shell-controller.d.ts +0 -18
- package/dist/types/src/packlets/vault/shell-controller.d.ts.map +0 -1
- package/src/packlets/invitations/device-invitations-proxy.ts +0 -14
- package/src/packlets/invitations/encoder.test.ts +0 -23
- package/src/packlets/invitations/encoder.ts +0 -26
- package/src/packlets/invitations/invitations-handler.ts +0 -68
- package/src/packlets/invitations/invitations-proxy.ts +0 -159
- package/src/packlets/invitations/invitations.ts +0 -113
- package/src/packlets/invitations/space-invitations-proxy.ts +0 -16
- package/src/packlets/services/service-definitions.ts +0 -68
- package/src/packlets/services/service-proxy.ts +0 -54
- package/src/packlets/vault/services.ts +0 -42
- package/src/packlets/vault/shell-controller.ts +0 -56
|
@@ -804,79 +804,17 @@ var IdentityServiceImpl = class {
|
|
|
804
804
|
}
|
|
805
805
|
};
|
|
806
806
|
|
|
807
|
-
// packages/sdk/client-services/src/packlets/invitations/encoder.ts
|
|
808
|
-
import base from "base-x";
|
|
809
|
-
import { schema as schema2 } from "@dxos/protocols";
|
|
810
|
-
var base62 = base("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
|
811
|
-
var codec = schema2.getCodecForType("dxos.client.services.Invitation");
|
|
812
|
-
var InvitationEncoder = class {
|
|
813
|
-
static decode(text) {
|
|
814
|
-
return codec.decode(base62.decode(text));
|
|
815
|
-
}
|
|
816
|
-
static encode(invitation) {
|
|
817
|
-
return base62.encode(codec.encode(invitation));
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
// packages/sdk/client-services/src/packlets/invitations/invitations.ts
|
|
822
|
-
import assert4 from "@dxos/node-std/assert";
|
|
823
|
-
import { CancellableObservableProvider } from "@dxos/async";
|
|
824
|
-
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
825
|
-
var AUTHENTICATION_CODE_LENGTH = 6;
|
|
826
|
-
var INVITATION_TIMEOUT = 3 * 6e4;
|
|
827
|
-
var ON_CLOSE_DELAY = 1e3;
|
|
828
|
-
var InvitationObservableProvider = class extends CancellableObservableProvider {
|
|
829
|
-
get invitation() {
|
|
830
|
-
return this._invitation;
|
|
831
|
-
}
|
|
832
|
-
setInvitation(invitation) {
|
|
833
|
-
this._invitation = invitation;
|
|
834
|
-
}
|
|
835
|
-
};
|
|
836
|
-
var AuthenticatingInvitationProvider = class extends InvitationObservableProvider {
|
|
837
|
-
// prettier-ignore
|
|
838
|
-
constructor(_actions) {
|
|
839
|
-
super(() => this._actions.onCancel());
|
|
840
|
-
this._actions = _actions;
|
|
841
|
-
}
|
|
842
|
-
async authenticate(authenticationCode) {
|
|
843
|
-
return this._actions.onAuthenticate(authenticationCode);
|
|
844
|
-
}
|
|
845
|
-
};
|
|
846
|
-
var wrapObservable = async (observable) => {
|
|
847
|
-
return new Promise((resolve, reject) => {
|
|
848
|
-
const unsubscribe = observable.subscribe({
|
|
849
|
-
onSuccess: (invitation) => {
|
|
850
|
-
assert4(invitation.state === Invitation.State.SUCCESS);
|
|
851
|
-
unsubscribe();
|
|
852
|
-
resolve(invitation);
|
|
853
|
-
},
|
|
854
|
-
onError: (err) => {
|
|
855
|
-
unsubscribe();
|
|
856
|
-
reject(err);
|
|
857
|
-
}
|
|
858
|
-
});
|
|
859
|
-
});
|
|
860
|
-
};
|
|
861
|
-
|
|
862
|
-
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
863
|
-
var AbstractInvitationsHandler = class {
|
|
864
|
-
// prettier-ignore
|
|
865
|
-
constructor(_networkManager) {
|
|
866
|
-
this._networkManager = _networkManager;
|
|
867
|
-
}
|
|
868
|
-
};
|
|
869
|
-
|
|
870
807
|
// packages/sdk/client-services/src/packlets/invitations/device-invitations-handler.ts
|
|
871
|
-
import
|
|
808
|
+
import assert4 from "@dxos/node-std/assert";
|
|
872
809
|
import { scheduleTask, sleep, Trigger as Trigger2 } from "@dxos/async";
|
|
810
|
+
import { AbstractInvitationsHandler, AuthenticatingInvitationProvider, AUTHENTICATION_CODE_LENGTH, InvitationObservableProvider, INVITATION_TIMEOUT, ON_CLOSE_DELAY } from "@dxos/client";
|
|
873
811
|
import { Context as Context3 } from "@dxos/context";
|
|
874
812
|
import { generatePasscode } from "@dxos/credentials";
|
|
875
813
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
876
814
|
import { log as log4 } from "@dxos/log";
|
|
877
815
|
import { createTeleportProtocolFactory, StarTopology } from "@dxos/network-manager";
|
|
878
|
-
import { schema as
|
|
879
|
-
import { Invitation
|
|
816
|
+
import { schema as schema2 } from "@dxos/protocols";
|
|
817
|
+
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
880
818
|
import { AuthenticationResponse } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
881
819
|
import { RpcExtension } from "@dxos/teleport";
|
|
882
820
|
var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
@@ -890,7 +828,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
890
828
|
*/
|
|
891
829
|
createInvitation(context, options) {
|
|
892
830
|
const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
|
|
893
|
-
|
|
831
|
+
assert4(type !== Invitation.Type.OFFLINE);
|
|
894
832
|
const identity = this._params.getIdentity();
|
|
895
833
|
const invitation = {
|
|
896
834
|
type,
|
|
@@ -916,7 +854,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
916
854
|
host: identity.deviceKey
|
|
917
855
|
}, {
|
|
918
856
|
file: "device-invitations-handler.ts",
|
|
919
|
-
line:
|
|
857
|
+
line: 92,
|
|
920
858
|
scope: this,
|
|
921
859
|
callSite: (f, a) => f(...a)
|
|
922
860
|
});
|
|
@@ -932,7 +870,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
932
870
|
authenticationCode: code
|
|
933
871
|
}, {
|
|
934
872
|
file: "device-invitations-handler.ts",
|
|
935
|
-
line:
|
|
873
|
+
line: 106,
|
|
936
874
|
scope: this,
|
|
937
875
|
callSite: (f, a) => f(...a)
|
|
938
876
|
});
|
|
@@ -944,7 +882,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
944
882
|
// TODO(burdon): Not used: controlFeedKey, dataFeedKey.
|
|
945
883
|
presentAdmissionCredentials: async (credentials) => {
|
|
946
884
|
try {
|
|
947
|
-
if (invitation.type !==
|
|
885
|
+
if (invitation.type !== Invitation.Type.INTERACTIVE_TESTING) {
|
|
948
886
|
if (invitation.authenticationCode === void 0 || invitation.authenticationCode !== authenticationCode) {
|
|
949
887
|
throw new Error(`invalid authentication code: ${authenticationCode}`);
|
|
950
888
|
}
|
|
@@ -954,7 +892,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
954
892
|
guest: credentials.deviceKey
|
|
955
893
|
}, {
|
|
956
894
|
file: "device-invitations-handler.ts",
|
|
957
|
-
line:
|
|
895
|
+
line: 121,
|
|
958
896
|
scope: this,
|
|
959
897
|
callSite: (f, a) => f(...a)
|
|
960
898
|
});
|
|
@@ -973,7 +911,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
973
911
|
host: identity.deviceKey
|
|
974
912
|
}, {
|
|
975
913
|
file: "device-invitations-handler.ts",
|
|
976
|
-
line:
|
|
914
|
+
line: 137,
|
|
977
915
|
scope: this,
|
|
978
916
|
callSite: (f, a) => f(...a)
|
|
979
917
|
});
|
|
@@ -986,7 +924,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
986
924
|
guest: deviceKey
|
|
987
925
|
}, {
|
|
988
926
|
file: "device-invitations-handler.ts",
|
|
989
|
-
line:
|
|
927
|
+
line: 140,
|
|
990
928
|
scope: this,
|
|
991
929
|
callSite: (f, a) => f(...a)
|
|
992
930
|
});
|
|
@@ -995,7 +933,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
995
933
|
if (!observable.cancelled) {
|
|
996
934
|
log4.error("failed", err, {
|
|
997
935
|
file: "device-invitations-handler.ts",
|
|
998
|
-
line:
|
|
936
|
+
line: 144,
|
|
999
937
|
scope: this,
|
|
1000
938
|
callSite: (f, a) => f(...a)
|
|
1001
939
|
});
|
|
@@ -1060,22 +998,22 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1060
998
|
}
|
|
1061
999
|
log4("connected", {}, {
|
|
1062
1000
|
file: "device-invitations-handler.ts",
|
|
1063
|
-
line:
|
|
1001
|
+
line: 215,
|
|
1064
1002
|
scope: this,
|
|
1065
1003
|
callSite: (f, a) => f(...a)
|
|
1066
1004
|
});
|
|
1067
1005
|
(_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
|
|
1068
1006
|
log4("sending admission request", {}, {
|
|
1069
1007
|
file: "device-invitations-handler.ts",
|
|
1070
|
-
line:
|
|
1008
|
+
line: 219,
|
|
1071
1009
|
scope: this,
|
|
1072
1010
|
callSite: (f, a) => f(...a)
|
|
1073
1011
|
});
|
|
1074
1012
|
const { identityKey, haloSpaceKey, genesisFeedKey } = await extension.rpc.HaloHostService.requestAdmission();
|
|
1075
|
-
if (invitation.type === void 0 || invitation.type ===
|
|
1013
|
+
if (invitation.type === void 0 || invitation.type === Invitation.Type.INTERACTIVE) {
|
|
1076
1014
|
log4("guest waiting for authentication code...", {}, {
|
|
1077
1015
|
file: "device-invitations-handler.ts",
|
|
1078
|
-
line:
|
|
1016
|
+
line: 226,
|
|
1079
1017
|
scope: this,
|
|
1080
1018
|
callSite: (f, a) => f(...a)
|
|
1081
1019
|
});
|
|
@@ -1085,7 +1023,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1085
1023
|
});
|
|
1086
1024
|
log4("sending authentication request", {}, {
|
|
1087
1025
|
file: "device-invitations-handler.ts",
|
|
1088
|
-
line:
|
|
1026
|
+
line: 229,
|
|
1089
1027
|
scope: this,
|
|
1090
1028
|
callSite: (f, a) => f(...a)
|
|
1091
1029
|
});
|
|
@@ -1103,7 +1041,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1103
1041
|
dataFeedKey
|
|
1104
1042
|
}, {
|
|
1105
1043
|
file: "device-invitations-handler.ts",
|
|
1106
|
-
line:
|
|
1044
|
+
line: 238,
|
|
1107
1045
|
scope: this,
|
|
1108
1046
|
callSite: (f, a) => f(...a)
|
|
1109
1047
|
});
|
|
@@ -1125,7 +1063,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1125
1063
|
identityKey
|
|
1126
1064
|
}, {
|
|
1127
1065
|
file: "device-invitations-handler.ts",
|
|
1128
|
-
line:
|
|
1066
|
+
line: 257,
|
|
1129
1067
|
scope: this,
|
|
1130
1068
|
callSite: (f, a) => f(...a)
|
|
1131
1069
|
});
|
|
@@ -1134,7 +1072,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1134
1072
|
if (!observable.cancelled) {
|
|
1135
1073
|
log4.warn("auth failed", err, {
|
|
1136
1074
|
file: "device-invitations-handler.ts",
|
|
1137
|
-
line:
|
|
1075
|
+
line: 261,
|
|
1138
1076
|
scope: this,
|
|
1139
1077
|
callSite: (f, a) => f(...a)
|
|
1140
1078
|
});
|
|
@@ -1150,7 +1088,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1150
1088
|
};
|
|
1151
1089
|
scheduleTask(ctx, async () => {
|
|
1152
1090
|
var _a, _b;
|
|
1153
|
-
|
|
1091
|
+
assert4(invitation.swarmKey);
|
|
1154
1092
|
const topic = invitation.swarmKey;
|
|
1155
1093
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1156
1094
|
topic,
|
|
@@ -1173,7 +1111,7 @@ var HostHaloInvitationExtension = class extends RpcExtension {
|
|
|
1173
1111
|
constructor(_callbacks) {
|
|
1174
1112
|
super({
|
|
1175
1113
|
exposed: {
|
|
1176
|
-
HaloHostService:
|
|
1114
|
+
HaloHostService: schema2.getService("dxos.halo.invitations.HaloHostService")
|
|
1177
1115
|
}
|
|
1178
1116
|
});
|
|
1179
1117
|
this._callbacks = _callbacks;
|
|
@@ -1205,7 +1143,7 @@ var GuestHaloInvitationExtension = class extends RpcExtension {
|
|
|
1205
1143
|
constructor(_callbacks) {
|
|
1206
1144
|
super({
|
|
1207
1145
|
requested: {
|
|
1208
|
-
HaloHostService:
|
|
1146
|
+
HaloHostService: schema2.getService("dxos.halo.invitations.HaloHostService")
|
|
1209
1147
|
}
|
|
1210
1148
|
});
|
|
1211
1149
|
this._callbacks = _callbacks;
|
|
@@ -1219,152 +1157,11 @@ var GuestHaloInvitationExtension = class extends RpcExtension {
|
|
|
1219
1157
|
}
|
|
1220
1158
|
};
|
|
1221
1159
|
|
|
1222
|
-
// packages/sdk/client-services/src/packlets/invitations/invitations-proxy.ts
|
|
1223
|
-
import assert6 from "@dxos/node-std/assert";
|
|
1224
|
-
import { observableError } from "@dxos/async";
|
|
1225
|
-
import { log as log5 } from "@dxos/log";
|
|
1226
|
-
import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1227
|
-
var AbstractInvitationsProxy = class {
|
|
1228
|
-
// prettier-ignore
|
|
1229
|
-
constructor(_invitationsService) {
|
|
1230
|
-
this._invitationsService = _invitationsService;
|
|
1231
|
-
}
|
|
1232
|
-
createInvitation(context, options) {
|
|
1233
|
-
let invitationId;
|
|
1234
|
-
const observable = new InvitationObservableProvider(async () => {
|
|
1235
|
-
if (invitationId) {
|
|
1236
|
-
await this._invitationsService.cancelInvitation({
|
|
1237
|
-
invitationId
|
|
1238
|
-
});
|
|
1239
|
-
}
|
|
1240
|
-
});
|
|
1241
|
-
const invitation = {
|
|
1242
|
-
...this.getInvitationOptions(context),
|
|
1243
|
-
...options
|
|
1244
|
-
};
|
|
1245
|
-
const stream = this._invitationsService.createInvitation(invitation);
|
|
1246
|
-
stream.subscribe((invitation2) => {
|
|
1247
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1248
|
-
observable.setInvitation(invitation2);
|
|
1249
|
-
switch (invitation2.state) {
|
|
1250
|
-
case Invitation3.State.CONNECTING: {
|
|
1251
|
-
assert6(invitation2.invitationId);
|
|
1252
|
-
invitationId = invitation2.invitationId;
|
|
1253
|
-
(_b = (_a = observable.callback).onConnecting) == null ? void 0 : _b.call(_a, invitation2);
|
|
1254
|
-
break;
|
|
1255
|
-
}
|
|
1256
|
-
case Invitation3.State.CONNECTED: {
|
|
1257
|
-
(_d = (_c = observable.callback).onConnected) == null ? void 0 : _d.call(_c, invitation2);
|
|
1258
|
-
break;
|
|
1259
|
-
}
|
|
1260
|
-
case Invitation3.State.AUTHENTICATING: {
|
|
1261
|
-
(_f = (_e = observable.callback).onAuthenticating) == null ? void 0 : _f.call(_e, invitation2);
|
|
1262
|
-
break;
|
|
1263
|
-
}
|
|
1264
|
-
case Invitation3.State.SUCCESS: {
|
|
1265
|
-
(_h = (_g = observable.callback).onSuccess) == null ? void 0 : _h.call(_g, invitation2);
|
|
1266
|
-
break;
|
|
1267
|
-
}
|
|
1268
|
-
case Invitation3.State.CANCELLED: {
|
|
1269
|
-
(_j = (_i = observable.callback).onCancelled) == null ? void 0 : _j.call(_i);
|
|
1270
|
-
break;
|
|
1271
|
-
}
|
|
1272
|
-
default: {
|
|
1273
|
-
log5.error(`Invalid state: ${invitation2.state}`, {}, {
|
|
1274
|
-
file: "invitations-proxy.ts",
|
|
1275
|
-
line: 81,
|
|
1276
|
-
scope: this,
|
|
1277
|
-
callSite: (f, a) => f(...a)
|
|
1278
|
-
});
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
}, (err) => {
|
|
1282
|
-
if (err) {
|
|
1283
|
-
observableError(observable, err);
|
|
1284
|
-
}
|
|
1285
|
-
});
|
|
1286
|
-
return observable;
|
|
1287
|
-
}
|
|
1288
|
-
acceptInvitation(invitation, options) {
|
|
1289
|
-
assert6(invitation && invitation.swarmKey);
|
|
1290
|
-
const observable = new AuthenticatingInvitationProvider({
|
|
1291
|
-
onCancel: async () => {
|
|
1292
|
-
var _a;
|
|
1293
|
-
const invitationId = (_a = observable.invitation) == null ? void 0 : _a.invitationId;
|
|
1294
|
-
assert6(invitationId);
|
|
1295
|
-
await this._invitationsService.cancelInvitation({
|
|
1296
|
-
invitationId
|
|
1297
|
-
});
|
|
1298
|
-
},
|
|
1299
|
-
onAuthenticate: async (authenticationCode) => {
|
|
1300
|
-
var _a;
|
|
1301
|
-
const invitationId = (_a = observable.invitation) == null ? void 0 : _a.invitationId;
|
|
1302
|
-
assert6(invitationId);
|
|
1303
|
-
await this._invitationsService.authenticate({
|
|
1304
|
-
invitationId,
|
|
1305
|
-
authenticationCode
|
|
1306
|
-
});
|
|
1307
|
-
}
|
|
1308
|
-
});
|
|
1309
|
-
const stream = this._invitationsService.acceptInvitation({
|
|
1310
|
-
...invitation,
|
|
1311
|
-
...options
|
|
1312
|
-
});
|
|
1313
|
-
stream.subscribe((invitation2) => {
|
|
1314
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1315
|
-
assert6(invitation2.invitationId);
|
|
1316
|
-
observable.setInvitation(invitation2);
|
|
1317
|
-
switch (invitation2.state) {
|
|
1318
|
-
case Invitation3.State.CONNECTING: {
|
|
1319
|
-
(_b = (_a = observable.callback).onConnecting) == null ? void 0 : _b.call(_a, invitation2);
|
|
1320
|
-
break;
|
|
1321
|
-
}
|
|
1322
|
-
case Invitation3.State.CONNECTED: {
|
|
1323
|
-
(_d = (_c = observable.callback).onConnected) == null ? void 0 : _d.call(_c, invitation2);
|
|
1324
|
-
break;
|
|
1325
|
-
}
|
|
1326
|
-
case Invitation3.State.AUTHENTICATING: {
|
|
1327
|
-
(_f = (_e = observable.callback).onAuthenticating) == null ? void 0 : _f.call(_e, invitation2);
|
|
1328
|
-
break;
|
|
1329
|
-
}
|
|
1330
|
-
case Invitation3.State.SUCCESS: {
|
|
1331
|
-
(_h = (_g = observable.callback).onSuccess) == null ? void 0 : _h.call(_g, invitation2);
|
|
1332
|
-
break;
|
|
1333
|
-
}
|
|
1334
|
-
case Invitation3.State.CANCELLED: {
|
|
1335
|
-
(_j = (_i = observable.callback).onCancelled) == null ? void 0 : _j.call(_i);
|
|
1336
|
-
break;
|
|
1337
|
-
}
|
|
1338
|
-
default: {
|
|
1339
|
-
log5.error(`Invalid state: ${invitation2.state}`, {}, {
|
|
1340
|
-
file: "invitations-proxy.ts",
|
|
1341
|
-
line: 146,
|
|
1342
|
-
scope: this,
|
|
1343
|
-
callSite: (f, a) => f(...a)
|
|
1344
|
-
});
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
}, (err) => {
|
|
1348
|
-
if (err) {
|
|
1349
|
-
observableError(observable, err);
|
|
1350
|
-
}
|
|
1351
|
-
});
|
|
1352
|
-
return observable;
|
|
1353
|
-
}
|
|
1354
|
-
};
|
|
1355
|
-
|
|
1356
|
-
// packages/sdk/client-services/src/packlets/invitations/device-invitations-proxy.ts
|
|
1357
|
-
var DeviceInvitationsProxy = class extends AbstractInvitationsProxy {
|
|
1358
|
-
getInvitationOptions() {
|
|
1359
|
-
return {};
|
|
1360
|
-
}
|
|
1361
|
-
};
|
|
1362
|
-
|
|
1363
1160
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1364
|
-
import
|
|
1161
|
+
import assert5 from "@dxos/node-std/assert";
|
|
1365
1162
|
import { Stream as Stream7 } from "@dxos/codec-protobuf";
|
|
1366
|
-
import { log as
|
|
1367
|
-
import { Invitation as
|
|
1163
|
+
import { log as log5 } from "@dxos/log";
|
|
1164
|
+
import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1368
1165
|
var AbstractInvitationsService = class {
|
|
1369
1166
|
// prettier-ignore
|
|
1370
1167
|
constructor(_identityManager, _getInvitationsHandler) {
|
|
@@ -1384,9 +1181,9 @@ var AbstractInvitationsService = class {
|
|
|
1384
1181
|
return new Stream7(({ next, close }) => {
|
|
1385
1182
|
const invitationsHandler = this._getInvitationsHandler();
|
|
1386
1183
|
const context = this.getContext(invitation);
|
|
1387
|
-
|
|
1184
|
+
log5("stream opened", this.getLoggingContext(), {
|
|
1388
1185
|
file: "invitations-service.ts",
|
|
1389
|
-
line:
|
|
1186
|
+
line: 48,
|
|
1390
1187
|
scope: this,
|
|
1391
1188
|
callSite: (f, a) => f(...a)
|
|
1392
1189
|
});
|
|
@@ -1399,60 +1196,60 @@ var AbstractInvitationsService = class {
|
|
|
1399
1196
|
});
|
|
1400
1197
|
observable.subscribe({
|
|
1401
1198
|
onConnecting: (invitation2) => {
|
|
1402
|
-
|
|
1199
|
+
assert5(invitation2.invitationId);
|
|
1403
1200
|
invitationId = invitation2.invitationId;
|
|
1404
1201
|
this._createInvitations.set(invitation2.invitationId, observable);
|
|
1405
|
-
invitation2.state =
|
|
1202
|
+
invitation2.state = Invitation2.State.CONNECTING;
|
|
1406
1203
|
next(invitation2);
|
|
1407
1204
|
},
|
|
1408
1205
|
onConnected: (invitation2) => {
|
|
1409
|
-
|
|
1410
|
-
invitation2.state =
|
|
1206
|
+
assert5(invitation2.invitationId);
|
|
1207
|
+
invitation2.state = Invitation2.State.CONNECTED;
|
|
1411
1208
|
next(invitation2);
|
|
1412
1209
|
},
|
|
1413
1210
|
onAuthenticating: (invitation2) => {
|
|
1414
|
-
|
|
1415
|
-
invitation2.state =
|
|
1211
|
+
assert5(invitation2.invitationId);
|
|
1212
|
+
invitation2.state = Invitation2.State.AUTHENTICATING;
|
|
1416
1213
|
next(invitation2);
|
|
1417
1214
|
},
|
|
1418
1215
|
onSuccess: (invitation2) => {
|
|
1419
|
-
|
|
1420
|
-
invitation2.state =
|
|
1216
|
+
assert5(invitation2.invitationId);
|
|
1217
|
+
invitation2.state = Invitation2.State.SUCCESS;
|
|
1421
1218
|
next(invitation2);
|
|
1422
1219
|
close();
|
|
1423
1220
|
},
|
|
1424
1221
|
onCancelled: () => {
|
|
1425
|
-
|
|
1222
|
+
assert5(invitationId);
|
|
1426
1223
|
invitation.invitationId = invitationId;
|
|
1427
|
-
invitation.state =
|
|
1224
|
+
invitation.state = Invitation2.State.CANCELLED;
|
|
1428
1225
|
next(invitation);
|
|
1429
1226
|
close();
|
|
1430
1227
|
},
|
|
1431
1228
|
onTimeout: (err) => {
|
|
1432
|
-
invitation.state =
|
|
1229
|
+
invitation.state = Invitation2.State.TIMEOUT;
|
|
1433
1230
|
close(err);
|
|
1434
1231
|
},
|
|
1435
1232
|
onError: (err) => {
|
|
1436
|
-
invitation.state =
|
|
1233
|
+
invitation.state = Invitation2.State.ERROR;
|
|
1437
1234
|
close(err);
|
|
1438
1235
|
}
|
|
1439
1236
|
});
|
|
1440
1237
|
return (err) => {
|
|
1441
1238
|
const context2 = this.getLoggingContext();
|
|
1442
1239
|
if (err) {
|
|
1443
|
-
|
|
1240
|
+
log5.warn("stream closed", {
|
|
1444
1241
|
...context2,
|
|
1445
1242
|
err
|
|
1446
1243
|
}, {
|
|
1447
1244
|
file: "invitations-service.ts",
|
|
1448
|
-
line:
|
|
1245
|
+
line: 97,
|
|
1449
1246
|
scope: this,
|
|
1450
1247
|
callSite: (f, a) => f(...a)
|
|
1451
1248
|
});
|
|
1452
1249
|
} else {
|
|
1453
|
-
|
|
1250
|
+
log5("stream closed", context2, {
|
|
1454
1251
|
file: "invitations-service.ts",
|
|
1455
|
-
line:
|
|
1252
|
+
line: 99,
|
|
1456
1253
|
scope: this,
|
|
1457
1254
|
callSite: (f, a) => f(...a)
|
|
1458
1255
|
});
|
|
@@ -1463,9 +1260,9 @@ var AbstractInvitationsService = class {
|
|
|
1463
1260
|
}
|
|
1464
1261
|
acceptInvitation(invitation, options) {
|
|
1465
1262
|
return new Stream7(({ next, close }) => {
|
|
1466
|
-
|
|
1263
|
+
log5("stream opened", this.getLoggingContext(), {
|
|
1467
1264
|
file: "invitations-service.ts",
|
|
1468
|
-
line:
|
|
1265
|
+
line: 109,
|
|
1469
1266
|
scope: this,
|
|
1470
1267
|
callSite: (f, a) => f(...a)
|
|
1471
1268
|
});
|
|
@@ -1474,59 +1271,59 @@ var AbstractInvitationsService = class {
|
|
|
1474
1271
|
const observable = invitationsHandler.acceptInvitation(invitation, options);
|
|
1475
1272
|
observable.subscribe({
|
|
1476
1273
|
onConnecting: (invitation2) => {
|
|
1477
|
-
|
|
1274
|
+
assert5(invitation2.invitationId);
|
|
1478
1275
|
invitationId = invitation2.invitationId;
|
|
1479
1276
|
this._acceptInvitations.set(invitation2.invitationId, observable);
|
|
1480
|
-
invitation2.state =
|
|
1277
|
+
invitation2.state = Invitation2.State.CONNECTING;
|
|
1481
1278
|
next(invitation2);
|
|
1482
1279
|
},
|
|
1483
1280
|
onConnected: (invitation2) => {
|
|
1484
|
-
|
|
1485
|
-
invitation2.state =
|
|
1281
|
+
assert5(invitation2.invitationId);
|
|
1282
|
+
invitation2.state = Invitation2.State.CONNECTED;
|
|
1486
1283
|
next(invitation2);
|
|
1487
1284
|
},
|
|
1488
1285
|
onAuthenticating: (invitation2) => {
|
|
1489
|
-
|
|
1490
|
-
invitation2.state =
|
|
1286
|
+
assert5(invitation2.invitationId);
|
|
1287
|
+
invitation2.state = Invitation2.State.AUTHENTICATING;
|
|
1491
1288
|
next(invitation2);
|
|
1492
1289
|
},
|
|
1493
1290
|
onSuccess: (invitation2) => {
|
|
1494
|
-
invitation2.state =
|
|
1291
|
+
invitation2.state = Invitation2.State.SUCCESS;
|
|
1495
1292
|
next(invitation2);
|
|
1496
1293
|
close();
|
|
1497
1294
|
},
|
|
1498
1295
|
onCancelled: () => {
|
|
1499
|
-
|
|
1296
|
+
assert5(invitationId);
|
|
1500
1297
|
invitation.invitationId = invitationId;
|
|
1501
|
-
invitation.state =
|
|
1298
|
+
invitation.state = Invitation2.State.CANCELLED;
|
|
1502
1299
|
next(invitation);
|
|
1503
1300
|
close();
|
|
1504
1301
|
},
|
|
1505
1302
|
onTimeout: (err) => {
|
|
1506
|
-
invitation.state =
|
|
1303
|
+
invitation.state = Invitation2.State.TIMEOUT;
|
|
1507
1304
|
close(err);
|
|
1508
1305
|
},
|
|
1509
1306
|
onError: (err) => {
|
|
1510
|
-
invitation.state =
|
|
1307
|
+
invitation.state = Invitation2.State.ERROR;
|
|
1511
1308
|
close(err);
|
|
1512
1309
|
}
|
|
1513
1310
|
});
|
|
1514
1311
|
return (err) => {
|
|
1515
1312
|
const context = this.getLoggingContext();
|
|
1516
1313
|
if (err) {
|
|
1517
|
-
|
|
1314
|
+
log5.warn("stream closed", {
|
|
1518
1315
|
...context,
|
|
1519
1316
|
err
|
|
1520
1317
|
}, {
|
|
1521
1318
|
file: "invitations-service.ts",
|
|
1522
|
-
line:
|
|
1319
|
+
line: 157,
|
|
1523
1320
|
scope: this,
|
|
1524
1321
|
callSite: (f, a) => f(...a)
|
|
1525
1322
|
});
|
|
1526
1323
|
} else {
|
|
1527
|
-
|
|
1324
|
+
log5("stream closed", context, {
|
|
1528
1325
|
file: "invitations-service.ts",
|
|
1529
|
-
line:
|
|
1326
|
+
line: 159,
|
|
1530
1327
|
scope: this,
|
|
1531
1328
|
callSite: (f, a) => f(...a)
|
|
1532
1329
|
});
|
|
@@ -1536,20 +1333,20 @@ var AbstractInvitationsService = class {
|
|
|
1536
1333
|
});
|
|
1537
1334
|
}
|
|
1538
1335
|
async authenticate({ invitationId, authenticationCode }) {
|
|
1539
|
-
|
|
1336
|
+
log5("authenticating...", {}, {
|
|
1540
1337
|
file: "invitations-service.ts",
|
|
1541
|
-
line:
|
|
1338
|
+
line: 168,
|
|
1542
1339
|
scope: this,
|
|
1543
1340
|
callSite: (f, a) => f(...a)
|
|
1544
1341
|
});
|
|
1545
|
-
|
|
1342
|
+
assert5(invitationId);
|
|
1546
1343
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1547
1344
|
if (!observable) {
|
|
1548
|
-
|
|
1345
|
+
log5.warn("invalid invitation", {
|
|
1549
1346
|
invitationId
|
|
1550
1347
|
}, {
|
|
1551
1348
|
file: "invitations-service.ts",
|
|
1552
|
-
line:
|
|
1349
|
+
line: 172,
|
|
1553
1350
|
scope: this,
|
|
1554
1351
|
callSite: (f, a) => f(...a)
|
|
1555
1352
|
});
|
|
@@ -1559,20 +1356,20 @@ var AbstractInvitationsService = class {
|
|
|
1559
1356
|
}
|
|
1560
1357
|
async cancelInvitation(invitation) {
|
|
1561
1358
|
var _a;
|
|
1562
|
-
|
|
1359
|
+
log5("cancelling...", {}, {
|
|
1563
1360
|
file: "invitations-service.ts",
|
|
1564
|
-
line:
|
|
1361
|
+
line: 179,
|
|
1565
1362
|
scope: this,
|
|
1566
1363
|
callSite: (f, a) => f(...a)
|
|
1567
1364
|
});
|
|
1568
|
-
|
|
1365
|
+
assert5(invitation.invitationId);
|
|
1569
1366
|
const observable = (_a = this._createInvitations.get(invitation.invitationId)) != null ? _a : this._acceptInvitations.get(invitation.invitationId);
|
|
1570
1367
|
if (!observable) {
|
|
1571
|
-
|
|
1368
|
+
log5.warn("invalid invitation", {
|
|
1572
1369
|
invitationId: invitation.invitationId
|
|
1573
1370
|
}, {
|
|
1574
1371
|
file: "invitations-service.ts",
|
|
1575
|
-
line:
|
|
1372
|
+
line: 184,
|
|
1576
1373
|
scope: this,
|
|
1577
1374
|
callSite: (f, a) => f(...a)
|
|
1578
1375
|
});
|
|
@@ -1594,20 +1391,21 @@ var DeviceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
1594
1391
|
};
|
|
1595
1392
|
|
|
1596
1393
|
// packages/sdk/client-services/src/packlets/invitations/space-invitations-handler.ts
|
|
1597
|
-
import
|
|
1394
|
+
import assert6 from "@dxos/node-std/assert";
|
|
1598
1395
|
import { scheduleTask as scheduleTask2, sleep as sleep2, Trigger as Trigger3 } from "@dxos/async";
|
|
1396
|
+
import { AuthenticatingInvitationProvider as AuthenticatingInvitationProvider2, AUTHENTICATION_CODE_LENGTH as AUTHENTICATION_CODE_LENGTH2, InvitationObservableProvider as InvitationObservableProvider2, INVITATION_TIMEOUT as INVITATION_TIMEOUT2, ON_CLOSE_DELAY as ON_CLOSE_DELAY2, AbstractInvitationsHandler as AbstractInvitationsHandler2 } from "@dxos/client";
|
|
1599
1397
|
import { Context as Context4 } from "@dxos/context";
|
|
1600
1398
|
import { createAdmissionCredentials, generatePasscode as generatePasscode2, getCredentialAssertion } from "@dxos/credentials";
|
|
1601
1399
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
1602
1400
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1603
|
-
import { log as
|
|
1401
|
+
import { log as log6 } from "@dxos/log";
|
|
1604
1402
|
import { createTeleportProtocolFactory as createTeleportProtocolFactory2, StarTopology as StarTopology2 } from "@dxos/network-manager";
|
|
1605
|
-
import { schema as
|
|
1606
|
-
import { Invitation as
|
|
1403
|
+
import { schema as schema3 } from "@dxos/protocols";
|
|
1404
|
+
import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1607
1405
|
import { AuthenticationResponse as AuthenticationResponse2, AuthMethod } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1608
1406
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
1609
1407
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1610
|
-
var SpaceInvitationsHandler = class extends
|
|
1408
|
+
var SpaceInvitationsHandler = class extends AbstractInvitationsHandler2 {
|
|
1611
1409
|
constructor(networkManager, _spaceManager, _signingContext, _keyring) {
|
|
1612
1410
|
super(networkManager);
|
|
1613
1411
|
this._spaceManager = _spaceManager;
|
|
@@ -1620,16 +1418,16 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1620
1418
|
createInvitation(space, options) {
|
|
1621
1419
|
var _a;
|
|
1622
1420
|
let swarmConnection;
|
|
1623
|
-
const { type, timeout =
|
|
1624
|
-
|
|
1625
|
-
|
|
1421
|
+
const { type, timeout = INVITATION_TIMEOUT2, swarmKey } = options != null ? options : {};
|
|
1422
|
+
assert6(type !== Invitation3.Type.OFFLINE);
|
|
1423
|
+
assert6(space);
|
|
1626
1424
|
const invitation = {
|
|
1627
1425
|
type,
|
|
1628
1426
|
invitationId: PublicKey4.random().toHex(),
|
|
1629
1427
|
swarmKey: swarmKey != null ? swarmKey : PublicKey4.random(),
|
|
1630
1428
|
spaceKey: space.key,
|
|
1631
1429
|
authMethod: (_a = options == null ? void 0 : options.authMethod) != null ? _a : AuthMethod.SHARED_SECRET,
|
|
1632
|
-
authenticationCode: generatePasscode2(
|
|
1430
|
+
authenticationCode: generatePasscode2(AUTHENTICATION_CODE_LENGTH2)
|
|
1633
1431
|
// TODO(dmaretskyi): Don't generate if authMethod === NONE .
|
|
1634
1432
|
};
|
|
1635
1433
|
const ctx = new Context4({
|
|
@@ -1638,7 +1436,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1638
1436
|
observable.callback.onError(err);
|
|
1639
1437
|
}
|
|
1640
1438
|
});
|
|
1641
|
-
const observable = new
|
|
1439
|
+
const observable = new InvitationObservableProvider2(async () => {
|
|
1642
1440
|
await (swarmConnection == null ? void 0 : swarmConnection.close());
|
|
1643
1441
|
});
|
|
1644
1442
|
let authenticationPassed = false;
|
|
@@ -1649,7 +1447,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1649
1447
|
const hostInvitationExtension = new HostSpaceInvitationExtension({
|
|
1650
1448
|
introduce: async ({ profile }) => {
|
|
1651
1449
|
var _a2, _b;
|
|
1652
|
-
|
|
1450
|
+
log6("guest introduced itself", {
|
|
1653
1451
|
guestProfile: profile,
|
|
1654
1452
|
host: this._signingContext.deviceKey,
|
|
1655
1453
|
spaceKey: space.key
|
|
@@ -1662,12 +1460,12 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1662
1460
|
guestProfile = profile;
|
|
1663
1461
|
(_b = (_a2 = observable.callback).onAuthenticating) == null ? void 0 : _b.call(_a2, invitation);
|
|
1664
1462
|
return {
|
|
1665
|
-
spaceKey: type ===
|
|
1463
|
+
spaceKey: type === Invitation3.Type.INTERACTIVE_TESTING || type === Invitation3.Type.MULTIUSE_TESTING ? space.key : void 0,
|
|
1666
1464
|
authMethod: invitation.authMethod
|
|
1667
1465
|
};
|
|
1668
1466
|
},
|
|
1669
1467
|
authenticate: async ({ authenticationCode: code }) => {
|
|
1670
|
-
|
|
1468
|
+
log6("received authentication request", {
|
|
1671
1469
|
authenticationCode: code
|
|
1672
1470
|
}, {
|
|
1673
1471
|
file: "space-invitations-handler.ts",
|
|
@@ -1678,7 +1476,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1678
1476
|
let status = AuthenticationResponse2.Status.OK;
|
|
1679
1477
|
switch (invitation.authMethod) {
|
|
1680
1478
|
case AuthMethod.NONE: {
|
|
1681
|
-
|
|
1479
|
+
log6("authentication not required", {}, {
|
|
1682
1480
|
file: "space-invitations-handler.ts",
|
|
1683
1481
|
line: 128,
|
|
1684
1482
|
scope: this,
|
|
@@ -1701,7 +1499,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1701
1499
|
break;
|
|
1702
1500
|
}
|
|
1703
1501
|
default: {
|
|
1704
|
-
|
|
1502
|
+
log6.error("invalid authentication method", {
|
|
1705
1503
|
authMethod: invitation.authMethod
|
|
1706
1504
|
}, {
|
|
1707
1505
|
file: "space-invitations-handler.ts",
|
|
@@ -1722,7 +1520,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1722
1520
|
if (isAuthenticationRequired(invitation) && !authenticationPassed) {
|
|
1723
1521
|
throw new Error("Not authenticated");
|
|
1724
1522
|
}
|
|
1725
|
-
|
|
1523
|
+
log6("writing guest credentials", {
|
|
1726
1524
|
host: this._signingContext.deviceKey,
|
|
1727
1525
|
guest: deviceKey
|
|
1728
1526
|
}, {
|
|
@@ -1732,9 +1530,9 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1732
1530
|
callSite: (f, a) => f(...a)
|
|
1733
1531
|
});
|
|
1734
1532
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
1735
|
-
|
|
1533
|
+
assert6(credentials[0].credential);
|
|
1736
1534
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1737
|
-
|
|
1535
|
+
assert6(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
1738
1536
|
await writeMessages2(space.inner.controlPipeline.writer, credentials);
|
|
1739
1537
|
complete.wake(deviceKey);
|
|
1740
1538
|
return {
|
|
@@ -1749,7 +1547,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1749
1547
|
scheduleTask2(ctx, async () => {
|
|
1750
1548
|
var _a2, _b;
|
|
1751
1549
|
try {
|
|
1752
|
-
|
|
1550
|
+
log6("connected", {
|
|
1753
1551
|
host: this._signingContext.deviceKey
|
|
1754
1552
|
}, {
|
|
1755
1553
|
file: "space-invitations-handler.ts",
|
|
@@ -1761,7 +1559,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1761
1559
|
const deviceKey = await complete.wait({
|
|
1762
1560
|
timeout
|
|
1763
1561
|
});
|
|
1764
|
-
|
|
1562
|
+
log6("admitted guest", {
|
|
1765
1563
|
host: this._signingContext.deviceKey,
|
|
1766
1564
|
guest: deviceKey
|
|
1767
1565
|
}, {
|
|
@@ -1773,7 +1571,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1773
1571
|
observable.callback.onSuccess(invitation);
|
|
1774
1572
|
} catch (err) {
|
|
1775
1573
|
if (!observable.cancelled) {
|
|
1776
|
-
|
|
1574
|
+
log6.error("failed", err, {
|
|
1777
1575
|
file: "space-invitations-handler.ts",
|
|
1778
1576
|
line: 198,
|
|
1779
1577
|
scope: this,
|
|
@@ -1782,8 +1580,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1782
1580
|
observable.callback.onError(err);
|
|
1783
1581
|
}
|
|
1784
1582
|
} finally {
|
|
1785
|
-
if (type !==
|
|
1786
|
-
await sleep2(
|
|
1583
|
+
if (type !== Invitation3.Type.MULTIUSE_TESTING) {
|
|
1584
|
+
await sleep2(ON_CLOSE_DELAY2);
|
|
1787
1585
|
await ctx.dispose();
|
|
1788
1586
|
}
|
|
1789
1587
|
}
|
|
@@ -1814,7 +1612,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1814
1612
|
* which then writes the guest's credentials to the space.
|
|
1815
1613
|
*/
|
|
1816
1614
|
acceptInvitation(invitation, options) {
|
|
1817
|
-
const { timeout =
|
|
1615
|
+
const { timeout = INVITATION_TIMEOUT2 } = options != null ? options : {};
|
|
1818
1616
|
const ctx = new Context4({
|
|
1819
1617
|
onError: (err) => {
|
|
1820
1618
|
void ctx.dispose();
|
|
@@ -1822,7 +1620,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1822
1620
|
}
|
|
1823
1621
|
});
|
|
1824
1622
|
const authenticated = new Trigger3();
|
|
1825
|
-
const observable = new
|
|
1623
|
+
const observable = new AuthenticatingInvitationProvider2({
|
|
1826
1624
|
onCancel: async () => {
|
|
1827
1625
|
await ctx.dispose();
|
|
1828
1626
|
},
|
|
@@ -1841,7 +1639,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1841
1639
|
if (++connectionCount > 1) {
|
|
1842
1640
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
1843
1641
|
}
|
|
1844
|
-
|
|
1642
|
+
log6("connected", {
|
|
1845
1643
|
guest: this._signingContext.deviceKey
|
|
1846
1644
|
}, {
|
|
1847
1645
|
file: "space-invitations-handler.ts",
|
|
@@ -1850,7 +1648,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1850
1648
|
callSite: (f, a) => f(...a)
|
|
1851
1649
|
});
|
|
1852
1650
|
(_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
|
|
1853
|
-
|
|
1651
|
+
log6("introduce", {
|
|
1854
1652
|
guest: this._signingContext.deviceKey
|
|
1855
1653
|
}, {
|
|
1856
1654
|
file: "space-invitations-handler.ts",
|
|
@@ -1861,7 +1659,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1861
1659
|
const introductionResponse = await extension.rpc.SpaceHostService.introduce({
|
|
1862
1660
|
profile: this._signingContext.profile
|
|
1863
1661
|
});
|
|
1864
|
-
|
|
1662
|
+
log6("introduce response", {
|
|
1865
1663
|
guest: this._signingContext.deviceKey,
|
|
1866
1664
|
response: introductionResponse
|
|
1867
1665
|
}, {
|
|
@@ -1877,7 +1675,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1877
1675
|
if (isAuthenticationRequired(invitation)) {
|
|
1878
1676
|
(_d = (_c = observable.callback).onAuthenticating) == null ? void 0 : _d.call(_c, invitation);
|
|
1879
1677
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1880
|
-
|
|
1678
|
+
log6("guest waiting for authentication code...", {}, {
|
|
1881
1679
|
file: "space-invitations-handler.ts",
|
|
1882
1680
|
line: 293,
|
|
1883
1681
|
scope: this,
|
|
@@ -1887,7 +1685,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1887
1685
|
const authenticationCode = await authenticated.wait({
|
|
1888
1686
|
timeout
|
|
1889
1687
|
});
|
|
1890
|
-
|
|
1688
|
+
log6("sending authentication request", {}, {
|
|
1891
1689
|
file: "space-invitations-handler.ts",
|
|
1892
1690
|
line: 297,
|
|
1893
1691
|
scope: this,
|
|
@@ -1903,7 +1701,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1903
1701
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
1904
1702
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
1905
1703
|
} else {
|
|
1906
|
-
|
|
1704
|
+
log6("retrying invalid code", {
|
|
1907
1705
|
attempt
|
|
1908
1706
|
}, {
|
|
1909
1707
|
file: "space-invitations-handler.ts",
|
|
@@ -1918,7 +1716,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1918
1716
|
}
|
|
1919
1717
|
const controlFeedKey = await this._keyring.createKey();
|
|
1920
1718
|
const dataFeedKey = await this._keyring.createKey();
|
|
1921
|
-
|
|
1719
|
+
log6("request admission", {
|
|
1922
1720
|
guest: this._signingContext.deviceKey
|
|
1923
1721
|
}, {
|
|
1924
1722
|
file: "space-invitations-handler.ts",
|
|
@@ -1933,14 +1731,14 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1933
1731
|
dataFeedKey
|
|
1934
1732
|
});
|
|
1935
1733
|
const assertion = getCredentialAssertion(credential);
|
|
1936
|
-
|
|
1937
|
-
|
|
1734
|
+
assert6(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
1735
|
+
assert6(credential.subject.id.equals(this._signingContext.identityKey));
|
|
1938
1736
|
const space = await this._spaceManager.acceptSpace({
|
|
1939
1737
|
spaceKey: assertion.spaceKey,
|
|
1940
1738
|
genesisFeedKey: assertion.genesisFeedKey
|
|
1941
1739
|
});
|
|
1942
1740
|
await this._signingContext.recordCredential(credential);
|
|
1943
|
-
|
|
1741
|
+
log6("admitted by host", {
|
|
1944
1742
|
guest: this._signingContext.deviceKey,
|
|
1945
1743
|
spaceKey: space.key
|
|
1946
1744
|
}, {
|
|
@@ -1952,7 +1750,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1952
1750
|
complete.wake();
|
|
1953
1751
|
} catch (err) {
|
|
1954
1752
|
if (!observable.cancelled) {
|
|
1955
|
-
|
|
1753
|
+
log6.warn("auth failed", err, {
|
|
1956
1754
|
file: "space-invitations-handler.ts",
|
|
1957
1755
|
line: 344,
|
|
1958
1756
|
scope: this,
|
|
@@ -1970,7 +1768,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1970
1768
|
};
|
|
1971
1769
|
scheduleTask2(ctx, async () => {
|
|
1972
1770
|
var _a, _b;
|
|
1973
|
-
|
|
1771
|
+
assert6(invitation.swarmKey);
|
|
1974
1772
|
const topic = invitation.swarmKey;
|
|
1975
1773
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1976
1774
|
topic,
|
|
@@ -1989,12 +1787,12 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1989
1787
|
return observable;
|
|
1990
1788
|
}
|
|
1991
1789
|
};
|
|
1992
|
-
var isAuthenticationRequired = (invitation) => invitation.authMethod !== AuthMethod.NONE && invitation.type !==
|
|
1790
|
+
var isAuthenticationRequired = (invitation) => invitation.authMethod !== AuthMethod.NONE && invitation.type !== Invitation3.Type.INTERACTIVE_TESTING && invitation.type !== Invitation3.Type.MULTIUSE_TESTING;
|
|
1993
1791
|
var HostSpaceInvitationExtension = class extends RpcExtension2 {
|
|
1994
1792
|
constructor(_callbacks) {
|
|
1995
1793
|
super({
|
|
1996
1794
|
exposed: {
|
|
1997
|
-
SpaceHostService:
|
|
1795
|
+
SpaceHostService: schema3.getService("dxos.halo.invitations.SpaceHostService")
|
|
1998
1796
|
}
|
|
1999
1797
|
});
|
|
2000
1798
|
this._callbacks = _callbacks;
|
|
@@ -2025,7 +1823,7 @@ var GuestSpaceInvitationExtension = class extends RpcExtension2 {
|
|
|
2025
1823
|
constructor(_callbacks) {
|
|
2026
1824
|
super({
|
|
2027
1825
|
requested: {
|
|
2028
|
-
SpaceHostService:
|
|
1826
|
+
SpaceHostService: schema3.getService("dxos.halo.invitations.SpaceHostService")
|
|
2029
1827
|
}
|
|
2030
1828
|
});
|
|
2031
1829
|
this._callbacks = _callbacks;
|
|
@@ -2039,17 +1837,8 @@ var GuestSpaceInvitationExtension = class extends RpcExtension2 {
|
|
|
2039
1837
|
}
|
|
2040
1838
|
};
|
|
2041
1839
|
|
|
2042
|
-
// packages/sdk/client-services/src/packlets/invitations/space-invitations-proxy.ts
|
|
2043
|
-
var SpaceInvitationsProxy = class extends AbstractInvitationsProxy {
|
|
2044
|
-
getInvitationOptions(context) {
|
|
2045
|
-
return {
|
|
2046
|
-
spaceKey: context
|
|
2047
|
-
};
|
|
2048
|
-
}
|
|
2049
|
-
};
|
|
2050
|
-
|
|
2051
1840
|
// packages/sdk/client-services/src/packlets/invitations/space-invitations-service.ts
|
|
2052
|
-
import
|
|
1841
|
+
import assert7 from "@dxos/node-std/assert";
|
|
2053
1842
|
var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
2054
1843
|
// prettier-ignore
|
|
2055
1844
|
constructor(identityManager, invitationsHandler, _getSpaceManager) {
|
|
@@ -2058,72 +1847,295 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
2058
1847
|
this._getSpaceManager = _getSpaceManager;
|
|
2059
1848
|
}
|
|
2060
1849
|
getContext(invitation) {
|
|
2061
|
-
|
|
1850
|
+
assert7(invitation.spaceKey);
|
|
2062
1851
|
const spaceManager = this._getSpaceManager();
|
|
2063
1852
|
const space = spaceManager.spaces.get(invitation.spaceKey);
|
|
2064
|
-
|
|
1853
|
+
assert7(space);
|
|
2065
1854
|
return space;
|
|
2066
1855
|
}
|
|
2067
1856
|
};
|
|
2068
1857
|
|
|
2069
|
-
// packages/sdk/client-services/src/packlets/
|
|
2070
|
-
import {
|
|
2071
|
-
import {
|
|
2072
|
-
import {
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
1858
|
+
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
1859
|
+
import { InvalidConfigError } from "@dxos/errors";
|
|
1860
|
+
import { Runtime } from "@dxos/protocols/proto/dxos/config";
|
|
1861
|
+
import { createStorage, StorageType } from "@dxos/random-access-storage";
|
|
1862
|
+
var StorageDriver = Runtime.Client.Storage.StorageDriver;
|
|
1863
|
+
var createStorageObjects = (config) => {
|
|
1864
|
+
const { path = "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
|
|
1865
|
+
if (persistent && storageType === StorageDriver.RAM) {
|
|
1866
|
+
throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
1867
|
+
}
|
|
1868
|
+
if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
|
|
1869
|
+
throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
1870
|
+
}
|
|
1871
|
+
if (persistent && keyStorage === StorageDriver.RAM) {
|
|
1872
|
+
throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
1873
|
+
}
|
|
1874
|
+
if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
|
|
1875
|
+
throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
1876
|
+
}
|
|
1877
|
+
return {
|
|
1878
|
+
storage: createStorage({
|
|
1879
|
+
type: persistent ? toStorageType(storageType) : StorageType.RAM,
|
|
1880
|
+
root: `${path}/`
|
|
1881
|
+
})
|
|
1882
|
+
};
|
|
1883
|
+
};
|
|
1884
|
+
var toStorageType = (type) => {
|
|
1885
|
+
switch (type) {
|
|
1886
|
+
case void 0:
|
|
1887
|
+
return void 0;
|
|
1888
|
+
case StorageDriver.RAM:
|
|
1889
|
+
return StorageType.RAM;
|
|
1890
|
+
case StorageDriver.CHROME:
|
|
1891
|
+
return StorageType.CHROME;
|
|
1892
|
+
case StorageDriver.FIREFOX:
|
|
1893
|
+
return StorageType.FIREFOX;
|
|
1894
|
+
case StorageDriver.IDB:
|
|
1895
|
+
return StorageType.IDB;
|
|
1896
|
+
case StorageDriver.NODE:
|
|
1897
|
+
return StorageType.NODE;
|
|
1898
|
+
default:
|
|
1899
|
+
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
1900
|
+
}
|
|
1901
|
+
};
|
|
2097
1902
|
|
|
2098
|
-
// packages/sdk/client-services/src/packlets/
|
|
2099
|
-
import
|
|
2100
|
-
import {
|
|
2101
|
-
import {
|
|
2102
|
-
import {
|
|
2103
|
-
import {
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
this.
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
this.
|
|
2115
|
-
|
|
1903
|
+
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
1904
|
+
import assert8 from "@dxos/node-std/assert";
|
|
1905
|
+
import { Event as Event3 } from "@dxos/async";
|
|
1906
|
+
import { appServiceBundle, shellServiceBundle } from "@dxos/client";
|
|
1907
|
+
import { ShellLayout } from "@dxos/protocols/proto/dxos/iframe";
|
|
1908
|
+
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
1909
|
+
var ShellRuntimeImpl = class {
|
|
1910
|
+
constructor(_port) {
|
|
1911
|
+
this._port = _port;
|
|
1912
|
+
this.layoutUpdate = new Event3();
|
|
1913
|
+
this._layout = ShellLayout.DEFAULT;
|
|
1914
|
+
}
|
|
1915
|
+
get layout() {
|
|
1916
|
+
return this._layout;
|
|
1917
|
+
}
|
|
1918
|
+
get invitationCode() {
|
|
1919
|
+
return this._invitationCode;
|
|
1920
|
+
}
|
|
1921
|
+
get spaceKey() {
|
|
1922
|
+
return this._spaceKey;
|
|
1923
|
+
}
|
|
1924
|
+
setLayout(layout, options = {}) {
|
|
1925
|
+
this._layout = layout;
|
|
1926
|
+
this._invitationCode = options.invitationCode;
|
|
1927
|
+
this._spaceKey = options.spaceKey;
|
|
1928
|
+
this.layoutUpdate.emit({
|
|
1929
|
+
layout,
|
|
1930
|
+
...options
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
async setAppContext(context) {
|
|
1934
|
+
assert8(this._appRpc, "runtime not open");
|
|
1935
|
+
await this._appRpc.rpc.AppService.setContext(context);
|
|
2116
1936
|
}
|
|
2117
1937
|
async open() {
|
|
1938
|
+
this._appRpc = createProtoRpcPeer({
|
|
1939
|
+
requested: appServiceBundle,
|
|
1940
|
+
exposed: shellServiceBundle,
|
|
1941
|
+
handlers: {
|
|
1942
|
+
ShellService: {
|
|
1943
|
+
setLayout: async (request) => {
|
|
1944
|
+
this._layout = request.layout;
|
|
1945
|
+
this._invitationCode = request.invitationCode;
|
|
1946
|
+
this._spaceKey = request.spaceKey;
|
|
1947
|
+
this.layoutUpdate.emit(request);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
},
|
|
1951
|
+
port: this._port
|
|
1952
|
+
});
|
|
1953
|
+
await this._appRpc.open();
|
|
2118
1954
|
}
|
|
2119
1955
|
async close() {
|
|
2120
|
-
|
|
1956
|
+
var _a;
|
|
1957
|
+
await ((_a = this._appRpc) == null ? void 0 : _a.close());
|
|
1958
|
+
this._appRpc = void 0;
|
|
2121
1959
|
}
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
1960
|
+
};
|
|
1961
|
+
var MemoryShellRuntime = class {
|
|
1962
|
+
constructor({ layout, invitationCode, spaceKey } = {}) {
|
|
1963
|
+
this.layoutUpdate = new Event3();
|
|
1964
|
+
this.contextUpdate = new Event3();
|
|
1965
|
+
this._layout = layout != null ? layout : ShellLayout.DEFAULT;
|
|
1966
|
+
this._invitationCode = invitationCode;
|
|
1967
|
+
this._spaceKey = spaceKey;
|
|
1968
|
+
}
|
|
1969
|
+
get layout() {
|
|
1970
|
+
return this._layout;
|
|
1971
|
+
}
|
|
1972
|
+
get invitationCode() {
|
|
1973
|
+
return this._invitationCode;
|
|
1974
|
+
}
|
|
1975
|
+
get spaceKey() {
|
|
1976
|
+
return this._spaceKey;
|
|
1977
|
+
}
|
|
1978
|
+
setLayout(layout, options = {}) {
|
|
1979
|
+
this._layout = layout;
|
|
1980
|
+
this._invitationCode = options.invitationCode;
|
|
1981
|
+
this._spaceKey = options.spaceKey;
|
|
1982
|
+
this.layoutUpdate.emit({
|
|
1983
|
+
layout,
|
|
1984
|
+
...options
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1987
|
+
async setAppContext(context) {
|
|
1988
|
+
this.contextUpdate.emit(context);
|
|
1989
|
+
}
|
|
1990
|
+
};
|
|
1991
|
+
|
|
1992
|
+
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
1993
|
+
import { Trigger as Trigger9 } from "@dxos/async";
|
|
1994
|
+
import { log as log16, logInfo as logInfo2 } from "@dxos/log";
|
|
1995
|
+
import { MemorySignalManager as MemorySignalManager3, MemorySignalManagerContext as MemorySignalManagerContext3, WebsocketSignalManager as WebsocketSignalManager3 } from "@dxos/messaging";
|
|
1996
|
+
import { createWebRTCTransportFactory as createWebRTCTransportFactory2, NetworkManager as NetworkManager3 } from "@dxos/network-manager";
|
|
1997
|
+
import { getAsyncValue } from "@dxos/util";
|
|
1998
|
+
|
|
1999
|
+
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
2000
|
+
import assert12 from "@dxos/node-std/assert";
|
|
2001
|
+
import { Event as Event6 } from "@dxos/async";
|
|
2002
|
+
import { clientServiceBundle, createDefaultModelFactory } from "@dxos/client";
|
|
2003
|
+
import { raise as raise3 } from "@dxos/debug";
|
|
2004
|
+
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
2005
|
+
import { log as log14 } from "@dxos/log";
|
|
2006
|
+
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
2007
|
+
|
|
2008
|
+
// packages/sdk/client-services/src/packlets/deprecated/tracing.ts
|
|
2009
|
+
var TracingServiceImpl = class {
|
|
2010
|
+
constructor(_config) {
|
|
2011
|
+
this._config = _config;
|
|
2012
|
+
}
|
|
2013
|
+
async setTracingOptions() {
|
|
2014
|
+
throw new Error("Tracing not available.");
|
|
2015
|
+
}
|
|
2016
|
+
subscribeToRpcTrace() {
|
|
2017
|
+
throw new Error("Tracing not available.");
|
|
2018
|
+
}
|
|
2019
|
+
};
|
|
2020
|
+
|
|
2021
|
+
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
2022
|
+
import { EventSubscriptions as EventSubscriptions2 } from "@dxos/async";
|
|
2023
|
+
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
2024
|
+
import { DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
|
|
2025
|
+
var DevicesServiceImpl = class {
|
|
2026
|
+
constructor(_identityManager) {
|
|
2027
|
+
this._identityManager = _identityManager;
|
|
2028
|
+
}
|
|
2029
|
+
updateDevice(request) {
|
|
2030
|
+
throw new Error("Method not implemented.");
|
|
2031
|
+
}
|
|
2032
|
+
queryDevices() {
|
|
2033
|
+
return new Stream8(({ next }) => {
|
|
2034
|
+
const update = () => {
|
|
2035
|
+
var _a;
|
|
2036
|
+
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
2037
|
+
if (!deviceKeys) {
|
|
2038
|
+
next({
|
|
2039
|
+
devices: []
|
|
2040
|
+
});
|
|
2041
|
+
} else {
|
|
2042
|
+
next({
|
|
2043
|
+
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
2044
|
+
var _a2;
|
|
2045
|
+
return {
|
|
2046
|
+
deviceKey: key,
|
|
2047
|
+
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
|
|
2048
|
+
};
|
|
2049
|
+
})
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
2053
|
+
const subscriptions = new EventSubscriptions2();
|
|
2054
|
+
subscriptions.add(this._identityManager.stateUpdate.on(() => {
|
|
2055
|
+
update();
|
|
2056
|
+
if (this._identityManager.identity) {
|
|
2057
|
+
subscriptions.add(this._identityManager.identity.stateUpdate.on(() => {
|
|
2058
|
+
update();
|
|
2059
|
+
}));
|
|
2060
|
+
}
|
|
2061
|
+
}));
|
|
2062
|
+
update();
|
|
2063
|
+
return () => subscriptions.clear();
|
|
2064
|
+
});
|
|
2065
|
+
}
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2068
|
+
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
2069
|
+
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
2070
|
+
var NetworkServiceImpl = class {
|
|
2071
|
+
constructor(networkManager) {
|
|
2072
|
+
this.networkManager = networkManager;
|
|
2073
|
+
}
|
|
2074
|
+
subscribeToNetworkStatus() {
|
|
2075
|
+
return new Stream9(({ next }) => {
|
|
2076
|
+
const unsubscribe = this.networkManager.connectionStateChanged.on((state) => next({
|
|
2077
|
+
state
|
|
2078
|
+
}));
|
|
2079
|
+
next({
|
|
2080
|
+
state: this.networkManager.connectionState
|
|
2081
|
+
});
|
|
2082
|
+
return unsubscribe;
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
async setNetworkOptions(request) {
|
|
2086
|
+
await this.networkManager.setConnectionState(request.state);
|
|
2087
|
+
}
|
|
2088
|
+
};
|
|
2089
|
+
|
|
2090
|
+
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2091
|
+
import assert10 from "@dxos/node-std/assert";
|
|
2092
|
+
import { Event as Event5, synchronized, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
2093
|
+
import { Context as Context7 } from "@dxos/context";
|
|
2094
|
+
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
2095
|
+
import { spaceGenesis, SnapshotManager } from "@dxos/echo-pipeline";
|
|
2096
|
+
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2097
|
+
import { log as log8 } from "@dxos/log";
|
|
2098
|
+
import { Presence } from "@dxos/teleport-extension-presence";
|
|
2099
|
+
import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxos/util";
|
|
2100
|
+
|
|
2101
|
+
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2102
|
+
import { trackLeaks } from "@dxos/async";
|
|
2103
|
+
import { Context as Context6 } from "@dxos/context";
|
|
2104
|
+
import { timed } from "@dxos/debug";
|
|
2105
|
+
import { DataPipelineControllerImpl, createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2106
|
+
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2107
|
+
import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2108
|
+
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2109
|
+
|
|
2110
|
+
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2111
|
+
import assert9 from "@dxos/node-std/assert";
|
|
2112
|
+
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, TimeoutError, Trigger as Trigger4 } from "@dxos/async";
|
|
2113
|
+
import { Context as Context5 } from "@dxos/context";
|
|
2114
|
+
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
2115
|
+
import { log as log7 } from "@dxos/log";
|
|
2116
|
+
import { schema as schema4 } from "@dxos/protocols";
|
|
2117
|
+
import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
|
|
2118
|
+
import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
|
|
2119
|
+
var RETRY_TIMEOUT = 1e3;
|
|
2120
|
+
var NOTARIZE_TIMEOUT = 1e4;
|
|
2121
|
+
var NotarizationPlugin = class {
|
|
2122
|
+
constructor() {
|
|
2123
|
+
this._ctx = new Context5();
|
|
2124
|
+
this._extensionOpened = new Event4();
|
|
2125
|
+
this._extensions = /* @__PURE__ */ new Set();
|
|
2126
|
+
this._processedCredentials = new ComplexSet(PublicKey5.hash);
|
|
2127
|
+
this._processCredentialsTriggers = new ComplexMap2(PublicKey5.hash);
|
|
2128
|
+
}
|
|
2129
|
+
async open() {
|
|
2130
|
+
}
|
|
2131
|
+
async close() {
|
|
2132
|
+
await this._ctx.dispose();
|
|
2133
|
+
}
|
|
2134
|
+
/**
|
|
2135
|
+
* Request credentials to be notarized.
|
|
2136
|
+
*/
|
|
2137
|
+
async notarize(credentials) {
|
|
2138
|
+
log7("notarize", {
|
|
2127
2139
|
credentials
|
|
2128
2140
|
}, {
|
|
2129
2141
|
file: "notarization-plugin.ts",
|
|
@@ -2131,11 +2143,11 @@ var NotarizationPlugin = class {
|
|
|
2131
2143
|
scope: this,
|
|
2132
2144
|
callSite: (f, a) => f(...a)
|
|
2133
2145
|
});
|
|
2134
|
-
|
|
2146
|
+
assert9(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2135
2147
|
const errors = new Trigger4();
|
|
2136
2148
|
const ctx = this._ctx.derive({
|
|
2137
2149
|
onError: (err) => {
|
|
2138
|
-
|
|
2150
|
+
log7.warn("Notarization error", {
|
|
2139
2151
|
err
|
|
2140
2152
|
}, {
|
|
2141
2153
|
file: "notarization-plugin.ts",
|
|
@@ -2148,7 +2160,7 @@ var NotarizationPlugin = class {
|
|
|
2148
2160
|
}
|
|
2149
2161
|
});
|
|
2150
2162
|
scheduleTask3(ctx, () => {
|
|
2151
|
-
|
|
2163
|
+
log7.warn("Notarization timeout", {}, {
|
|
2152
2164
|
file: "notarization-plugin.ts",
|
|
2153
2165
|
line: 61,
|
|
2154
2166
|
scope: this,
|
|
@@ -2162,7 +2174,7 @@ var NotarizationPlugin = class {
|
|
|
2162
2174
|
const notarizeTask = new DeferredTask(ctx, async () => {
|
|
2163
2175
|
try {
|
|
2164
2176
|
if (this._extensions.size === 0) {
|
|
2165
|
-
|
|
2177
|
+
log7.warn("No peers to notarize with", {}, {
|
|
2166
2178
|
file: "notarization-plugin.ts",
|
|
2167
2179
|
line: 76,
|
|
2168
2180
|
scope: this,
|
|
@@ -2174,7 +2186,7 @@ var NotarizationPlugin = class {
|
|
|
2174
2186
|
...this._extensions
|
|
2175
2187
|
].find((peer2) => !peersTried.has(peer2));
|
|
2176
2188
|
if (!peer) {
|
|
2177
|
-
|
|
2189
|
+
log7.warn("Exhausted all peers to notarize with", {
|
|
2178
2190
|
retryIn: RETRY_TIMEOUT
|
|
2179
2191
|
}, {
|
|
2180
2192
|
file: "notarization-plugin.ts",
|
|
@@ -2187,7 +2199,7 @@ var NotarizationPlugin = class {
|
|
|
2187
2199
|
return;
|
|
2188
2200
|
}
|
|
2189
2201
|
peersTried.add(peer);
|
|
2190
|
-
|
|
2202
|
+
log7("try notarizing", {
|
|
2191
2203
|
peer: peer.localPeerId,
|
|
2192
2204
|
credentialId: credentials.map((credential) => credential.id)
|
|
2193
2205
|
}, {
|
|
@@ -2199,14 +2211,14 @@ var NotarizationPlugin = class {
|
|
|
2199
2211
|
await peer.rpc.NotarizationService.notarize({
|
|
2200
2212
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2201
2213
|
});
|
|
2202
|
-
|
|
2214
|
+
log7("success", {}, {
|
|
2203
2215
|
file: "notarization-plugin.ts",
|
|
2204
2216
|
line: 94,
|
|
2205
2217
|
scope: this,
|
|
2206
2218
|
callSite: (f, a) => f(...a)
|
|
2207
2219
|
});
|
|
2208
2220
|
} catch (err) {
|
|
2209
|
-
|
|
2221
|
+
log7.warn("error notarizing (recoverable)", err, {
|
|
2210
2222
|
file: "notarization-plugin.ts",
|
|
2211
2223
|
line: 96,
|
|
2212
2224
|
scope: this,
|
|
@@ -2222,7 +2234,7 @@ var NotarizationPlugin = class {
|
|
|
2222
2234
|
allNotarized,
|
|
2223
2235
|
errors.wait()
|
|
2224
2236
|
]);
|
|
2225
|
-
|
|
2237
|
+
log7("done", {}, {
|
|
2226
2238
|
file: "notarization-plugin.ts",
|
|
2227
2239
|
line: 107,
|
|
2228
2240
|
scope: this,
|
|
@@ -2245,7 +2257,7 @@ var NotarizationPlugin = class {
|
|
|
2245
2257
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2246
2258
|
}
|
|
2247
2259
|
setWriter(writer) {
|
|
2248
|
-
|
|
2260
|
+
assert9(!this._writer, "Writer already set.");
|
|
2249
2261
|
this._writer = writer;
|
|
2250
2262
|
}
|
|
2251
2263
|
async _waitUntilProcessed(id) {
|
|
@@ -2263,7 +2275,7 @@ var NotarizationPlugin = class {
|
|
|
2263
2275
|
throw new Error("Writer not set");
|
|
2264
2276
|
}
|
|
2265
2277
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2266
|
-
|
|
2278
|
+
assert9(credential.id, "Credential must have an id");
|
|
2267
2279
|
if (this._processedCredentials.has(credential.id)) {
|
|
2268
2280
|
continue;
|
|
2269
2281
|
}
|
|
@@ -2273,7 +2285,7 @@ var NotarizationPlugin = class {
|
|
|
2273
2285
|
createExtension() {
|
|
2274
2286
|
const extension = new NotarizationTeleportExtension({
|
|
2275
2287
|
onOpen: async () => {
|
|
2276
|
-
|
|
2288
|
+
log7("extension opened", {
|
|
2277
2289
|
peer: extension.localPeerId
|
|
2278
2290
|
}, {
|
|
2279
2291
|
file: "notarization-plugin.ts",
|
|
@@ -2285,7 +2297,7 @@ var NotarizationPlugin = class {
|
|
|
2285
2297
|
this._extensionOpened.emit();
|
|
2286
2298
|
},
|
|
2287
2299
|
onClose: async () => {
|
|
2288
|
-
|
|
2300
|
+
log7("extension closed", {
|
|
2289
2301
|
peer: extension.localPeerId
|
|
2290
2302
|
}, {
|
|
2291
2303
|
file: "notarization-plugin.ts",
|
|
@@ -2304,10 +2316,10 @@ var NotarizationTeleportExtension = class extends RpcExtension3 {
|
|
|
2304
2316
|
constructor(_params) {
|
|
2305
2317
|
super({
|
|
2306
2318
|
requested: {
|
|
2307
|
-
NotarizationService:
|
|
2319
|
+
NotarizationService: schema4.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2308
2320
|
},
|
|
2309
2321
|
exposed: {
|
|
2310
|
-
NotarizationService:
|
|
2322
|
+
NotarizationService: schema4.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2311
2323
|
}
|
|
2312
2324
|
});
|
|
2313
2325
|
this._params = _params;
|
|
@@ -2486,7 +2498,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2486
2498
|
this._feedStore = _feedStore;
|
|
2487
2499
|
this._snapshotStore = _snapshotStore;
|
|
2488
2500
|
this._ctx = new Context7();
|
|
2489
|
-
this.updated = new
|
|
2501
|
+
this.updated = new Event5();
|
|
2490
2502
|
this._spaces = new ComplexMap3(PublicKey7.hash);
|
|
2491
2503
|
}
|
|
2492
2504
|
// TODO(burdon): Remove.
|
|
@@ -2495,7 +2507,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2495
2507
|
}
|
|
2496
2508
|
async open() {
|
|
2497
2509
|
await this._metadataStore.load();
|
|
2498
|
-
|
|
2510
|
+
log8("metadata loaded", {
|
|
2499
2511
|
spaces: this._metadataStore.spaces.length
|
|
2500
2512
|
}, {
|
|
2501
2513
|
file: "data-space-manager.ts",
|
|
@@ -2504,7 +2516,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2504
2516
|
callSite: (f, a) => f(...a)
|
|
2505
2517
|
});
|
|
2506
2518
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2507
|
-
|
|
2519
|
+
log8("load space", {
|
|
2508
2520
|
spaceMetadata
|
|
2509
2521
|
}, {
|
|
2510
2522
|
file: "data-space-manager.ts",
|
|
@@ -2515,7 +2527,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2515
2527
|
const space = await this._constructSpace(spaceMetadata);
|
|
2516
2528
|
await space.initializeDataPipeline();
|
|
2517
2529
|
if (spaceMetadata.dataTimeframe) {
|
|
2518
|
-
|
|
2530
|
+
log8("waiting for latest timeframe", {
|
|
2519
2531
|
spaceMetadata
|
|
2520
2532
|
}, {
|
|
2521
2533
|
file: "data-space-manager.ts",
|
|
@@ -2550,7 +2562,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2550
2562
|
controlFeedKey,
|
|
2551
2563
|
dataFeedKey
|
|
2552
2564
|
};
|
|
2553
|
-
|
|
2565
|
+
log8("creating space...", {
|
|
2554
2566
|
spaceKey
|
|
2555
2567
|
}, {
|
|
2556
2568
|
file: "data-space-manager.ts",
|
|
@@ -2562,7 +2574,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2562
2574
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2563
2575
|
await this._metadataStore.addSpace(metadata);
|
|
2564
2576
|
const memberCredential = credentials[1];
|
|
2565
|
-
|
|
2577
|
+
assert10(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2566
2578
|
await this._signingContext.recordCredential(memberCredential);
|
|
2567
2579
|
await space.initializeDataPipeline();
|
|
2568
2580
|
this._dataServiceSubscriptions.registerSpace(space.key, space.dataPipelineController.databaseBackend.createDataServiceHost());
|
|
@@ -2571,7 +2583,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2571
2583
|
}
|
|
2572
2584
|
// TODO(burdon): Rename join space.
|
|
2573
2585
|
async acceptSpace(opts) {
|
|
2574
|
-
|
|
2586
|
+
assert10(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2575
2587
|
const metadata = {
|
|
2576
2588
|
key: opts.spaceKey,
|
|
2577
2589
|
genesisFeedKey: opts.genesisFeedKey
|
|
@@ -2647,484 +2659,28 @@ DataSpaceManager = __decorate2([
|
|
|
2647
2659
|
trackLeaks2("open", "close")
|
|
2648
2660
|
], DataSpaceManager);
|
|
2649
2661
|
|
|
2650
|
-
// packages/sdk/client-services/src/packlets/
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
this.
|
|
2661
|
-
this.
|
|
2662
|
-
this.
|
|
2663
|
-
|
|
2664
|
-
root: storage.createDirectory("feeds"),
|
|
2665
|
-
signer: this.keyring,
|
|
2666
|
-
hypercore: {
|
|
2667
|
-
valueEncoding
|
|
2668
|
-
}
|
|
2669
|
-
})
|
|
2670
|
-
});
|
|
2671
|
-
this.spaceManager = new SpaceManager({
|
|
2672
|
-
feedStore: this.feedStore,
|
|
2673
|
-
networkManager: this.networkManager
|
|
2674
|
-
});
|
|
2675
|
-
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
2676
|
-
this.deviceInvitations = new DeviceInvitationsHandler({
|
|
2677
|
-
networkManager: this.networkManager,
|
|
2678
|
-
getIdentity: () => {
|
|
2679
|
-
var _a;
|
|
2680
|
-
return (_a = this.identityManager.identity) != null ? _a : failUndefined2();
|
|
2681
|
-
},
|
|
2682
|
-
acceptIdentity: this._acceptIdentity.bind(this),
|
|
2683
|
-
keyring: this.keyring
|
|
2684
|
-
});
|
|
2662
|
+
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2663
|
+
import { EventSubscriptions as EventSubscriptions3, scheduleTask as scheduleTask4 } from "@dxos/async";
|
|
2664
|
+
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
2665
|
+
import { raise, todo as todo2 } from "@dxos/debug";
|
|
2666
|
+
import { SpaceNotFoundError } from "@dxos/echo-pipeline";
|
|
2667
|
+
import { log as log9 } from "@dxos/log";
|
|
2668
|
+
import { SpaceMember, SpaceStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
2669
|
+
import { humanize } from "@dxos/util";
|
|
2670
|
+
var SpacesServiceImpl = class {
|
|
2671
|
+
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
2672
|
+
this._identityManager = _identityManager;
|
|
2673
|
+
this._spaceManager = _spaceManager;
|
|
2674
|
+
this._dataServiceSubscriptions = _dataServiceSubscriptions;
|
|
2675
|
+
this._getDataSpaceManager = _getDataSpaceManager;
|
|
2685
2676
|
}
|
|
2686
|
-
async
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
line: 94,
|
|
2690
|
-
scope: this,
|
|
2691
|
-
callSite: (f, a) => f(...a)
|
|
2692
|
-
});
|
|
2693
|
-
await this.networkManager.open();
|
|
2694
|
-
await this.spaceManager.open();
|
|
2695
|
-
await this.identityManager.open();
|
|
2696
|
-
if (this.identityManager.identity) {
|
|
2697
|
-
await this._initialize();
|
|
2677
|
+
async createSpace() {
|
|
2678
|
+
if (!this._identityManager.identity) {
|
|
2679
|
+
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
|
|
2698
2680
|
}
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
scope: this,
|
|
2703
|
-
callSite: (f, a) => f(...a)
|
|
2704
|
-
});
|
|
2705
|
-
}
|
|
2706
|
-
async close() {
|
|
2707
|
-
var _a, _b;
|
|
2708
|
-
log10("closing...", {}, {
|
|
2709
|
-
file: "service-context.ts",
|
|
2710
|
-
line: 105,
|
|
2711
|
-
scope: this,
|
|
2712
|
-
callSite: (f, a) => f(...a)
|
|
2713
|
-
});
|
|
2714
|
-
await ((_a = this._deviceSpaceSync) == null ? void 0 : _a.close());
|
|
2715
|
-
await ((_b = this.dataSpaceManager) == null ? void 0 : _b.close());
|
|
2716
|
-
await this.identityManager.close();
|
|
2717
|
-
await this.spaceManager.close();
|
|
2718
|
-
await this.feedStore.close();
|
|
2719
|
-
await this.networkManager.close();
|
|
2720
|
-
this.dataServiceSubscriptions.clear();
|
|
2721
|
-
log10("closed", {}, {
|
|
2722
|
-
file: "service-context.ts",
|
|
2723
|
-
line: 113,
|
|
2724
|
-
scope: this,
|
|
2725
|
-
callSite: (f, a) => f(...a)
|
|
2726
|
-
});
|
|
2727
|
-
}
|
|
2728
|
-
async reset() {
|
|
2729
|
-
log10("resetting...", {}, {
|
|
2730
|
-
file: "service-context.ts",
|
|
2731
|
-
line: 117,
|
|
2732
|
-
scope: this,
|
|
2733
|
-
callSite: (f, a) => f(...a)
|
|
2734
|
-
});
|
|
2735
|
-
await this.close();
|
|
2736
|
-
await this.storage.reset();
|
|
2737
|
-
log10("reset", {}, {
|
|
2738
|
-
file: "service-context.ts",
|
|
2739
|
-
line: 120,
|
|
2740
|
-
scope: this,
|
|
2741
|
-
callSite: (f, a) => f(...a)
|
|
2742
|
-
});
|
|
2743
|
-
}
|
|
2744
|
-
async createIdentity(params = {}) {
|
|
2745
|
-
const identity = await this.identityManager.createIdentity(params);
|
|
2746
|
-
await this._initialize();
|
|
2747
|
-
return identity;
|
|
2748
|
-
}
|
|
2749
|
-
async _acceptIdentity(params) {
|
|
2750
|
-
const identity = await this.identityManager.acceptIdentity(params);
|
|
2751
|
-
await this._initialize();
|
|
2752
|
-
return identity;
|
|
2753
|
-
}
|
|
2754
|
-
// Called when identity is created.
|
|
2755
|
-
async _initialize() {
|
|
2756
|
-
var _a;
|
|
2757
|
-
log10("initializing spaces...", {}, {
|
|
2758
|
-
file: "service-context.ts",
|
|
2759
|
-
line: 139,
|
|
2760
|
-
scope: this,
|
|
2761
|
-
callSite: (f, a) => f(...a)
|
|
2762
|
-
});
|
|
2763
|
-
const identity = (_a = this.identityManager.identity) != null ? _a : failUndefined2();
|
|
2764
|
-
const signingContext = {
|
|
2765
|
-
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
2766
|
-
identityKey: identity.identityKey,
|
|
2767
|
-
deviceKey: identity.deviceKey,
|
|
2768
|
-
profile: identity.profileDocument,
|
|
2769
|
-
recordCredential: async (credential) => {
|
|
2770
|
-
await identity.controlPipeline.writer.write({
|
|
2771
|
-
credential: {
|
|
2772
|
-
credential
|
|
2773
|
-
}
|
|
2774
|
-
});
|
|
2775
|
-
}
|
|
2776
|
-
};
|
|
2777
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.modelFactory, this.feedStore, this.snapshotStore);
|
|
2778
|
-
await this.dataSpaceManager.open();
|
|
2779
|
-
this.spaceInvitations = new SpaceInvitationsHandler(this.networkManager, this.dataSpaceManager, signingContext, this.keyring);
|
|
2780
|
-
this.initialized.wake();
|
|
2781
|
-
this._deviceSpaceSync = identity.space.spaceState.registerProcessor({
|
|
2782
|
-
process: async (credential) => {
|
|
2783
|
-
const assertion = getCredentialAssertion3(credential);
|
|
2784
|
-
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
2785
|
-
return;
|
|
2786
|
-
}
|
|
2787
|
-
if (assertion.spaceKey.equals(identity.space.key)) {
|
|
2788
|
-
return;
|
|
2789
|
-
}
|
|
2790
|
-
if (!this.dataSpaceManager) {
|
|
2791
|
-
log10("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
2792
|
-
details: assertion
|
|
2793
|
-
}, {
|
|
2794
|
-
file: "service-context.ts",
|
|
2795
|
-
line: 182,
|
|
2796
|
-
scope: this,
|
|
2797
|
-
callSite: (f, a) => f(...a)
|
|
2798
|
-
});
|
|
2799
|
-
return;
|
|
2800
|
-
}
|
|
2801
|
-
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
2802
|
-
log10("space already exists, ignoring space admission", {
|
|
2803
|
-
details: assertion
|
|
2804
|
-
}, {
|
|
2805
|
-
file: "service-context.ts",
|
|
2806
|
-
line: 186,
|
|
2807
|
-
scope: this,
|
|
2808
|
-
callSite: (f, a) => f(...a)
|
|
2809
|
-
});
|
|
2810
|
-
return;
|
|
2811
|
-
}
|
|
2812
|
-
try {
|
|
2813
|
-
log10("accepting space recorded in halo", {
|
|
2814
|
-
details: assertion
|
|
2815
|
-
}, {
|
|
2816
|
-
file: "service-context.ts",
|
|
2817
|
-
line: 191,
|
|
2818
|
-
scope: this,
|
|
2819
|
-
callSite: (f, a) => f(...a)
|
|
2820
|
-
});
|
|
2821
|
-
await this.dataSpaceManager.acceptSpace({
|
|
2822
|
-
spaceKey: assertion.spaceKey,
|
|
2823
|
-
genesisFeedKey: assertion.genesisFeedKey
|
|
2824
|
-
});
|
|
2825
|
-
} catch (err) {
|
|
2826
|
-
log10.catch(err, {}, {
|
|
2827
|
-
file: "service-context.ts",
|
|
2828
|
-
line: 197,
|
|
2829
|
-
scope: this,
|
|
2830
|
-
callSite: (f, a) => f(...a)
|
|
2831
|
-
});
|
|
2832
|
-
}
|
|
2833
|
-
}
|
|
2834
|
-
});
|
|
2835
|
-
await this._deviceSpaceSync.open();
|
|
2836
|
-
}
|
|
2837
|
-
};
|
|
2838
|
-
|
|
2839
|
-
// packages/sdk/client-services/src/packlets/services/service-definitions.ts
|
|
2840
|
-
import { schema as schema6 } from "@dxos/protocols";
|
|
2841
|
-
import { createServiceBundle } from "@dxos/rpc";
|
|
2842
|
-
var clientServiceBundle = createServiceBundle({
|
|
2843
|
-
SystemService: schema6.getService("dxos.client.services.SystemService"),
|
|
2844
|
-
IdentityService: schema6.getService("dxos.client.services.IdentityService"),
|
|
2845
|
-
DeviceInvitationsService: schema6.getService("dxos.client.services.DeviceInvitationsService"),
|
|
2846
|
-
DevicesService: schema6.getService("dxos.client.services.DevicesService"),
|
|
2847
|
-
SpaceInvitationsService: schema6.getService("dxos.client.services.SpaceInvitationsService"),
|
|
2848
|
-
SpacesService: schema6.getService("dxos.client.services.SpacesService"),
|
|
2849
|
-
DataService: schema6.getService("dxos.echo.service.DataService"),
|
|
2850
|
-
NetworkService: schema6.getService("dxos.client.services.NetworkService"),
|
|
2851
|
-
// TODO(burdon): Deprecated.
|
|
2852
|
-
DevtoolsHost: schema6.getService("dxos.devtools.host.DevtoolsHost"),
|
|
2853
|
-
TracingService: schema6.getService("dxos.devtools.host.TracingService")
|
|
2854
|
-
});
|
|
2855
|
-
|
|
2856
|
-
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
2857
|
-
import { InvalidConfigError } from "@dxos/errors";
|
|
2858
|
-
import { Runtime } from "@dxos/protocols/proto/dxos/config";
|
|
2859
|
-
import { createStorage, StorageType } from "@dxos/random-access-storage";
|
|
2860
|
-
var StorageDriver = Runtime.Client.Storage.StorageDriver;
|
|
2861
|
-
var createStorageObjects = (config) => {
|
|
2862
|
-
const { path = "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
|
|
2863
|
-
if (persistent && storageType === StorageDriver.RAM) {
|
|
2864
|
-
throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
2865
|
-
}
|
|
2866
|
-
if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
|
|
2867
|
-
throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
2868
|
-
}
|
|
2869
|
-
if (persistent && keyStorage === StorageDriver.RAM) {
|
|
2870
|
-
throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
2871
|
-
}
|
|
2872
|
-
if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
|
|
2873
|
-
throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
2874
|
-
}
|
|
2875
|
-
return {
|
|
2876
|
-
storage: createStorage({
|
|
2877
|
-
type: persistent ? toStorageType(storageType) : StorageType.RAM,
|
|
2878
|
-
root: `${path}/`
|
|
2879
|
-
})
|
|
2880
|
-
};
|
|
2881
|
-
};
|
|
2882
|
-
var toStorageType = (type) => {
|
|
2883
|
-
switch (type) {
|
|
2884
|
-
case void 0:
|
|
2885
|
-
return void 0;
|
|
2886
|
-
case StorageDriver.RAM:
|
|
2887
|
-
return StorageType.RAM;
|
|
2888
|
-
case StorageDriver.CHROME:
|
|
2889
|
-
return StorageType.CHROME;
|
|
2890
|
-
case StorageDriver.FIREFOX:
|
|
2891
|
-
return StorageType.FIREFOX;
|
|
2892
|
-
case StorageDriver.IDB:
|
|
2893
|
-
return StorageType.IDB;
|
|
2894
|
-
case StorageDriver.NODE:
|
|
2895
|
-
return StorageType.NODE;
|
|
2896
|
-
default:
|
|
2897
|
-
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
2898
|
-
}
|
|
2899
|
-
};
|
|
2900
|
-
|
|
2901
|
-
// packages/sdk/client-services/src/packlets/vault/services.ts
|
|
2902
|
-
import { schema as schema7 } from "@dxos/protocols";
|
|
2903
|
-
var iframeServiceBundle = {
|
|
2904
|
-
IframeService: schema7.getService("dxos.iframe.IframeService"),
|
|
2905
|
-
BridgeService: schema7.getService("dxos.mesh.bridge.BridgeService")
|
|
2906
|
-
};
|
|
2907
|
-
var workerServiceBundle = {
|
|
2908
|
-
WorkerService: schema7.getService("dxos.iframe.WorkerService")
|
|
2909
|
-
};
|
|
2910
|
-
var appServiceBundle = {
|
|
2911
|
-
AppService: schema7.getService("dxos.iframe.AppService")
|
|
2912
|
-
};
|
|
2913
|
-
var shellServiceBundle = {
|
|
2914
|
-
ShellService: schema7.getService("dxos.iframe.ShellService")
|
|
2915
|
-
};
|
|
2916
|
-
|
|
2917
|
-
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
2918
|
-
import assert12 from "@dxos/node-std/assert";
|
|
2919
|
-
import { Event as Event5 } from "@dxos/async";
|
|
2920
|
-
import { ShellLayout } from "@dxos/protocols/proto/dxos/iframe";
|
|
2921
|
-
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
2922
|
-
var ShellRuntimeImpl = class {
|
|
2923
|
-
constructor(_port) {
|
|
2924
|
-
this._port = _port;
|
|
2925
|
-
this.layoutUpdate = new Event5();
|
|
2926
|
-
this._layout = ShellLayout.DEFAULT;
|
|
2927
|
-
}
|
|
2928
|
-
get layout() {
|
|
2929
|
-
return this._layout;
|
|
2930
|
-
}
|
|
2931
|
-
get invitationCode() {
|
|
2932
|
-
return this._invitationCode;
|
|
2933
|
-
}
|
|
2934
|
-
get spaceKey() {
|
|
2935
|
-
return this._spaceKey;
|
|
2936
|
-
}
|
|
2937
|
-
setLayout(layout, options = {}) {
|
|
2938
|
-
this._layout = layout;
|
|
2939
|
-
this._invitationCode = options.invitationCode;
|
|
2940
|
-
this._spaceKey = options.spaceKey;
|
|
2941
|
-
this.layoutUpdate.emit({
|
|
2942
|
-
layout,
|
|
2943
|
-
...options
|
|
2944
|
-
});
|
|
2945
|
-
}
|
|
2946
|
-
async setAppContext(context) {
|
|
2947
|
-
assert12(this._appRpc, "runtime not open");
|
|
2948
|
-
await this._appRpc.rpc.AppService.setContext(context);
|
|
2949
|
-
}
|
|
2950
|
-
async open() {
|
|
2951
|
-
this._appRpc = createProtoRpcPeer({
|
|
2952
|
-
requested: appServiceBundle,
|
|
2953
|
-
exposed: shellServiceBundle,
|
|
2954
|
-
handlers: {
|
|
2955
|
-
ShellService: {
|
|
2956
|
-
setLayout: async (request) => {
|
|
2957
|
-
this._layout = request.layout;
|
|
2958
|
-
this._invitationCode = request.invitationCode;
|
|
2959
|
-
this._spaceKey = request.spaceKey;
|
|
2960
|
-
this.layoutUpdate.emit(request);
|
|
2961
|
-
}
|
|
2962
|
-
}
|
|
2963
|
-
},
|
|
2964
|
-
port: this._port
|
|
2965
|
-
});
|
|
2966
|
-
await this._appRpc.open();
|
|
2967
|
-
}
|
|
2968
|
-
async close() {
|
|
2969
|
-
var _a;
|
|
2970
|
-
await ((_a = this._appRpc) == null ? void 0 : _a.close());
|
|
2971
|
-
this._appRpc = void 0;
|
|
2972
|
-
}
|
|
2973
|
-
};
|
|
2974
|
-
var MemoryShellRuntime = class {
|
|
2975
|
-
constructor({ layout, invitationCode, spaceKey } = {}) {
|
|
2976
|
-
this.layoutUpdate = new Event5();
|
|
2977
|
-
this.contextUpdate = new Event5();
|
|
2978
|
-
this._layout = layout != null ? layout : ShellLayout.DEFAULT;
|
|
2979
|
-
this._invitationCode = invitationCode;
|
|
2980
|
-
this._spaceKey = spaceKey;
|
|
2981
|
-
}
|
|
2982
|
-
get layout() {
|
|
2983
|
-
return this._layout;
|
|
2984
|
-
}
|
|
2985
|
-
get invitationCode() {
|
|
2986
|
-
return this._invitationCode;
|
|
2987
|
-
}
|
|
2988
|
-
get spaceKey() {
|
|
2989
|
-
return this._spaceKey;
|
|
2990
|
-
}
|
|
2991
|
-
setLayout(layout, options = {}) {
|
|
2992
|
-
this._layout = layout;
|
|
2993
|
-
this._invitationCode = options.invitationCode;
|
|
2994
|
-
this._spaceKey = options.spaceKey;
|
|
2995
|
-
this.layoutUpdate.emit({
|
|
2996
|
-
layout,
|
|
2997
|
-
...options
|
|
2998
|
-
});
|
|
2999
|
-
}
|
|
3000
|
-
async setAppContext(context) {
|
|
3001
|
-
this.contextUpdate.emit(context);
|
|
3002
|
-
}
|
|
3003
|
-
};
|
|
3004
|
-
|
|
3005
|
-
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3006
|
-
import { Trigger as Trigger9 } from "@dxos/async";
|
|
3007
|
-
import { log as log17, logInfo as logInfo2 } from "@dxos/log";
|
|
3008
|
-
import { MemorySignalManager as MemorySignalManager2, MemorySignalManagerContext as MemorySignalManagerContext2, WebsocketSignalManager as WebsocketSignalManager2 } from "@dxos/messaging";
|
|
3009
|
-
import { createWebRTCTransportFactory, NetworkManager as NetworkManager2 } from "@dxos/network-manager";
|
|
3010
|
-
import { createProtoRpcPeer as createProtoRpcPeer6 } from "@dxos/rpc";
|
|
3011
|
-
import { getAsyncValue } from "@dxos/util";
|
|
3012
|
-
|
|
3013
|
-
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3014
|
-
import assert14 from "@dxos/node-std/assert";
|
|
3015
|
-
import { Event as Event7 } from "@dxos/async";
|
|
3016
|
-
import { raise as raise2 } from "@dxos/debug";
|
|
3017
|
-
import { DocumentModel } from "@dxos/document-model";
|
|
3018
|
-
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
3019
|
-
import { log as log16 } from "@dxos/log";
|
|
3020
|
-
import { ModelFactory } from "@dxos/model-factory";
|
|
3021
|
-
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
3022
|
-
import { TextModel } from "@dxos/text-model";
|
|
3023
|
-
|
|
3024
|
-
// packages/sdk/client-services/src/packlets/deprecated/tracing.ts
|
|
3025
|
-
var TracingServiceImpl = class {
|
|
3026
|
-
constructor(_config) {
|
|
3027
|
-
this._config = _config;
|
|
3028
|
-
}
|
|
3029
|
-
async setTracingOptions() {
|
|
3030
|
-
throw new Error("Tracing not available.");
|
|
3031
|
-
}
|
|
3032
|
-
subscribeToRpcTrace() {
|
|
3033
|
-
throw new Error("Tracing not available.");
|
|
3034
|
-
}
|
|
3035
|
-
};
|
|
3036
|
-
|
|
3037
|
-
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3038
|
-
import { EventSubscriptions as EventSubscriptions2 } from "@dxos/async";
|
|
3039
|
-
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
3040
|
-
import { DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
|
|
3041
|
-
var DevicesServiceImpl = class {
|
|
3042
|
-
constructor(_identityManager) {
|
|
3043
|
-
this._identityManager = _identityManager;
|
|
3044
|
-
}
|
|
3045
|
-
updateDevice(request) {
|
|
3046
|
-
throw new Error("Method not implemented.");
|
|
3047
|
-
}
|
|
3048
|
-
queryDevices() {
|
|
3049
|
-
return new Stream8(({ next }) => {
|
|
3050
|
-
const update = () => {
|
|
3051
|
-
var _a;
|
|
3052
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
3053
|
-
if (!deviceKeys) {
|
|
3054
|
-
next({
|
|
3055
|
-
devices: []
|
|
3056
|
-
});
|
|
3057
|
-
} else {
|
|
3058
|
-
next({
|
|
3059
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
3060
|
-
var _a2;
|
|
3061
|
-
return {
|
|
3062
|
-
deviceKey: key,
|
|
3063
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
|
|
3064
|
-
};
|
|
3065
|
-
})
|
|
3066
|
-
});
|
|
3067
|
-
}
|
|
3068
|
-
};
|
|
3069
|
-
const subscriptions = new EventSubscriptions2();
|
|
3070
|
-
subscriptions.add(this._identityManager.stateUpdate.on(() => {
|
|
3071
|
-
update();
|
|
3072
|
-
if (this._identityManager.identity) {
|
|
3073
|
-
subscriptions.add(this._identityManager.identity.stateUpdate.on(() => {
|
|
3074
|
-
update();
|
|
3075
|
-
}));
|
|
3076
|
-
}
|
|
3077
|
-
}));
|
|
3078
|
-
update();
|
|
3079
|
-
return () => subscriptions.clear();
|
|
3080
|
-
});
|
|
3081
|
-
}
|
|
3082
|
-
};
|
|
3083
|
-
|
|
3084
|
-
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
3085
|
-
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
3086
|
-
var NetworkServiceImpl = class {
|
|
3087
|
-
constructor(networkManager) {
|
|
3088
|
-
this.networkManager = networkManager;
|
|
3089
|
-
}
|
|
3090
|
-
subscribeToNetworkStatus() {
|
|
3091
|
-
return new Stream9(({ next }) => {
|
|
3092
|
-
const unsubscribe = this.networkManager.connectionStateChanged.on((state) => next({
|
|
3093
|
-
state
|
|
3094
|
-
}));
|
|
3095
|
-
next({
|
|
3096
|
-
state: this.networkManager.connectionState
|
|
3097
|
-
});
|
|
3098
|
-
return unsubscribe;
|
|
3099
|
-
});
|
|
3100
|
-
}
|
|
3101
|
-
async setNetworkOptions(request) {
|
|
3102
|
-
await this.networkManager.setConnectionState(request.state);
|
|
3103
|
-
}
|
|
3104
|
-
};
|
|
3105
|
-
|
|
3106
|
-
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
3107
|
-
import { EventSubscriptions as EventSubscriptions3, scheduleTask as scheduleTask4 } from "@dxos/async";
|
|
3108
|
-
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
3109
|
-
import { raise, todo as todo2 } from "@dxos/debug";
|
|
3110
|
-
import { SpaceNotFoundError } from "@dxos/echo-pipeline";
|
|
3111
|
-
import { log as log11 } from "@dxos/log";
|
|
3112
|
-
import { SpaceMember, SpaceStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
3113
|
-
import { humanize } from "@dxos/util";
|
|
3114
|
-
var SpacesServiceImpl = class {
|
|
3115
|
-
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
3116
|
-
this._identityManager = _identityManager;
|
|
3117
|
-
this._spaceManager = _spaceManager;
|
|
3118
|
-
this._dataServiceSubscriptions = _dataServiceSubscriptions;
|
|
3119
|
-
this._getDataSpaceManager = _getDataSpaceManager;
|
|
3120
|
-
}
|
|
3121
|
-
async createSpace() {
|
|
3122
|
-
if (!this._identityManager.identity) {
|
|
3123
|
-
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
|
|
3124
|
-
}
|
|
3125
|
-
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3126
|
-
const space = await dataSpaceManager.createSpace();
|
|
3127
|
-
return this._transformSpace(space);
|
|
2681
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2682
|
+
const space = await dataSpaceManager.createSpace();
|
|
2683
|
+
return this._transformSpace(space);
|
|
3128
2684
|
}
|
|
3129
2685
|
async updateSpace(request) {
|
|
3130
2686
|
todo2();
|
|
@@ -3134,7 +2690,7 @@ var SpacesServiceImpl = class {
|
|
|
3134
2690
|
const onUpdate = async () => {
|
|
3135
2691
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3136
2692
|
const spaces = Array.from(dataSpaceManager.spaces.values()).filter((space) => this._dataServiceSubscriptions.getDataService(space.key)).map((space) => this._transformSpace(space));
|
|
3137
|
-
|
|
2693
|
+
log9("update", {
|
|
3138
2694
|
spaces
|
|
3139
2695
|
}, {
|
|
3140
2696
|
file: "spaces-service.ts",
|
|
@@ -3231,7 +2787,8 @@ var SystemServiceImpl = class {
|
|
|
3231
2787
|
this._onReset = onReset;
|
|
3232
2788
|
}
|
|
3233
2789
|
async getConfig() {
|
|
3234
|
-
|
|
2790
|
+
var _a, _b;
|
|
2791
|
+
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
3235
2792
|
}
|
|
3236
2793
|
async updateStatus({ status }) {
|
|
3237
2794
|
await this._onUpdateStatus(status);
|
|
@@ -3258,6 +2815,7 @@ var SystemServiceImpl = class {
|
|
|
3258
2815
|
};
|
|
3259
2816
|
|
|
3260
2817
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
2818
|
+
import { iframeServiceBundle, workerServiceBundle } from "@dxos/client";
|
|
3261
2819
|
import { WebRTCTransportService } from "@dxos/network-manager";
|
|
3262
2820
|
import { createProtoRpcPeer as createProtoRpcPeer2 } from "@dxos/rpc";
|
|
3263
2821
|
var IFrameProxyRuntime = class {
|
|
@@ -3305,72 +2863,9 @@ var IFrameProxyRuntime = class {
|
|
|
3305
2863
|
}
|
|
3306
2864
|
};
|
|
3307
2865
|
|
|
3308
|
-
// packages/sdk/client-services/src/packlets/vault/shell-controller.ts
|
|
3309
|
-
import { Event as Event6 } from "@dxos/async";
|
|
3310
|
-
import { log as log12 } from "@dxos/log";
|
|
3311
|
-
import { ShellDisplay } from "@dxos/protocols/proto/dxos/iframe";
|
|
3312
|
-
import { createProtoRpcPeer as createProtoRpcPeer3 } from "@dxos/rpc";
|
|
3313
|
-
var ShellController = class {
|
|
3314
|
-
constructor(_port) {
|
|
3315
|
-
this._port = _port;
|
|
3316
|
-
this.contextUpdate = new Event6();
|
|
3317
|
-
this._display = ShellDisplay.NONE;
|
|
3318
|
-
}
|
|
3319
|
-
get display() {
|
|
3320
|
-
return this._display;
|
|
3321
|
-
}
|
|
3322
|
-
async setLayout(layout, options = {}) {
|
|
3323
|
-
var _a;
|
|
3324
|
-
log12("set layout", {
|
|
3325
|
-
layout,
|
|
3326
|
-
...options
|
|
3327
|
-
}, {
|
|
3328
|
-
file: "shell-controller.ts",
|
|
3329
|
-
line: 27,
|
|
3330
|
-
scope: this,
|
|
3331
|
-
callSite: (f, a) => f(...a)
|
|
3332
|
-
});
|
|
3333
|
-
this._display = ShellDisplay.FULLSCREEN;
|
|
3334
|
-
this.contextUpdate.emit({
|
|
3335
|
-
display: this._display
|
|
3336
|
-
});
|
|
3337
|
-
await ((_a = this._shellRpc) == null ? void 0 : _a.rpc.ShellService.setLayout({
|
|
3338
|
-
layout,
|
|
3339
|
-
...options
|
|
3340
|
-
}));
|
|
3341
|
-
}
|
|
3342
|
-
async open() {
|
|
3343
|
-
this._shellRpc = createProtoRpcPeer3({
|
|
3344
|
-
requested: shellServiceBundle,
|
|
3345
|
-
exposed: appServiceBundle,
|
|
3346
|
-
handlers: {
|
|
3347
|
-
AppService: {
|
|
3348
|
-
setContext: async (request) => {
|
|
3349
|
-
log12("set context", request, {
|
|
3350
|
-
file: "shell-controller.ts",
|
|
3351
|
-
line: 40,
|
|
3352
|
-
scope: this,
|
|
3353
|
-
callSite: (f, a) => f(...a)
|
|
3354
|
-
});
|
|
3355
|
-
this._display = request.display;
|
|
3356
|
-
this.contextUpdate.emit(request);
|
|
3357
|
-
}
|
|
3358
|
-
}
|
|
3359
|
-
},
|
|
3360
|
-
port: this._port
|
|
3361
|
-
});
|
|
3362
|
-
await this._shellRpc.open();
|
|
3363
|
-
}
|
|
3364
|
-
async close() {
|
|
3365
|
-
var _a;
|
|
3366
|
-
await ((_a = this._shellRpc) == null ? void 0 : _a.close());
|
|
3367
|
-
this._shellRpc = void 0;
|
|
3368
|
-
}
|
|
3369
|
-
};
|
|
3370
|
-
|
|
3371
2866
|
// packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
|
|
3372
|
-
import { asyncTimeout, Trigger as
|
|
3373
|
-
import { log as
|
|
2867
|
+
import { asyncTimeout, Trigger as Trigger5 } from "@dxos/async";
|
|
2868
|
+
import { log as log10 } from "@dxos/log";
|
|
3374
2869
|
var Message;
|
|
3375
2870
|
(function(Message2) {
|
|
3376
2871
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -3378,7 +2873,7 @@ var Message;
|
|
|
3378
2873
|
var VaultResourceLock = class {
|
|
3379
2874
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
3380
2875
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
3381
|
-
this._releaseTrigger = new
|
|
2876
|
+
this._releaseTrigger = new Trigger5();
|
|
3382
2877
|
this._lockKey = lockKey;
|
|
3383
2878
|
this._onAcquire = onAcquire;
|
|
3384
2879
|
this._onRelease = onRelease;
|
|
@@ -3403,7 +2898,7 @@ var VaultResourceLock = class {
|
|
|
3403
2898
|
}
|
|
3404
2899
|
}
|
|
3405
2900
|
async _requestLock(steal = false) {
|
|
3406
|
-
|
|
2901
|
+
log10("requesting lock...", {
|
|
3407
2902
|
steal
|
|
3408
2903
|
}, {
|
|
3409
2904
|
file: "vault-resource-lock.ts",
|
|
@@ -3411,23 +2906,23 @@ var VaultResourceLock = class {
|
|
|
3411
2906
|
scope: this,
|
|
3412
2907
|
callSite: (f, a) => f(...a)
|
|
3413
2908
|
});
|
|
3414
|
-
const acquired = new
|
|
2909
|
+
const acquired = new Trigger5();
|
|
3415
2910
|
void navigator.locks.request(this._lockKey, {
|
|
3416
2911
|
steal
|
|
3417
2912
|
}, async () => {
|
|
3418
2913
|
var _a, _b;
|
|
3419
2914
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3420
2915
|
acquired.wake();
|
|
3421
|
-
this._releaseTrigger = new
|
|
2916
|
+
this._releaseTrigger = new Trigger5();
|
|
3422
2917
|
await this._releaseTrigger.wait();
|
|
3423
|
-
|
|
2918
|
+
log10("releasing lock...", {}, {
|
|
3424
2919
|
file: "vault-resource-lock.ts",
|
|
3425
2920
|
line: 65,
|
|
3426
2921
|
scope: this,
|
|
3427
2922
|
callSite: (f, a) => f(...a)
|
|
3428
2923
|
});
|
|
3429
2924
|
await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
|
|
3430
|
-
|
|
2925
|
+
log10("released lock", {}, {
|
|
3431
2926
|
file: "vault-resource-lock.ts",
|
|
3432
2927
|
line: 67,
|
|
3433
2928
|
scope: this,
|
|
@@ -3438,7 +2933,7 @@ var VaultResourceLock = class {
|
|
|
3438
2933
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3439
2934
|
});
|
|
3440
2935
|
await acquired.wait();
|
|
3441
|
-
|
|
2936
|
+
log10("recieved lock", {
|
|
3442
2937
|
steal
|
|
3443
2938
|
}, {
|
|
3444
2939
|
file: "vault-resource-lock.ts",
|
|
@@ -3450,17 +2945,73 @@ var VaultResourceLock = class {
|
|
|
3450
2945
|
};
|
|
3451
2946
|
|
|
3452
2947
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
3453
|
-
import { Trigger as
|
|
3454
|
-
import { log as
|
|
2948
|
+
import { Trigger as Trigger7 } from "@dxos/async";
|
|
2949
|
+
import { log as log12 } from "@dxos/log";
|
|
3455
2950
|
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from "@dxos/messaging";
|
|
3456
2951
|
import { NetworkManager, WebRTCTransportProxyFactory } from "@dxos/network-manager";
|
|
3457
2952
|
|
|
3458
2953
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
3459
|
-
import
|
|
3460
|
-
import { asyncTimeout as asyncTimeout2, Trigger as
|
|
3461
|
-
import {
|
|
3462
|
-
import {
|
|
2954
|
+
import assert11 from "@dxos/node-std/assert";
|
|
2955
|
+
import { asyncTimeout as asyncTimeout2, Trigger as Trigger6 } from "@dxos/async";
|
|
2956
|
+
import { iframeServiceBundle as iframeServiceBundle2, workerServiceBundle as workerServiceBundle2 } from "@dxos/client";
|
|
2957
|
+
import { log as log11, logInfo } from "@dxos/log";
|
|
2958
|
+
import { createProtoRpcPeer as createProtoRpcPeer3 } from "@dxos/rpc";
|
|
3463
2959
|
import { Callback } from "@dxos/util";
|
|
2960
|
+
|
|
2961
|
+
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
2962
|
+
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
2963
|
+
import { raise as raise2 } from "@dxos/debug";
|
|
2964
|
+
import { parseMethodName, RpcPeer } from "@dxos/rpc";
|
|
2965
|
+
var ClientRpcServer = class {
|
|
2966
|
+
constructor(params) {
|
|
2967
|
+
this._handlerCache = /* @__PURE__ */ new Map();
|
|
2968
|
+
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
2969
|
+
this._handleCall = handleCall;
|
|
2970
|
+
this._handleStream = handleStream;
|
|
2971
|
+
this._serviceRegistry = serviceRegistry;
|
|
2972
|
+
this._rpcPeer = new RpcPeer({
|
|
2973
|
+
...rpcOptions,
|
|
2974
|
+
callHandler: (method, params2) => {
|
|
2975
|
+
const [serviceName, methodName] = parseMethodName(method);
|
|
2976
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
2977
|
+
if (this._handleCall) {
|
|
2978
|
+
return this._handleCall(methodName, params2, handler);
|
|
2979
|
+
} else {
|
|
2980
|
+
return handler(methodName, params2);
|
|
2981
|
+
}
|
|
2982
|
+
},
|
|
2983
|
+
streamHandler: (method, params2) => {
|
|
2984
|
+
const [serviceName, methodName] = parseMethodName(method);
|
|
2985
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
2986
|
+
if (this._handleStream) {
|
|
2987
|
+
return Stream12.unwrapPromise(this._handleStream(methodName, params2, handler));
|
|
2988
|
+
} else {
|
|
2989
|
+
return handler(methodName, params2);
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
});
|
|
2993
|
+
}
|
|
2994
|
+
async open() {
|
|
2995
|
+
await this._rpcPeer.open();
|
|
2996
|
+
}
|
|
2997
|
+
async close() {
|
|
2998
|
+
await this._rpcPeer.close();
|
|
2999
|
+
}
|
|
3000
|
+
_getServiceHandler(serviceName) {
|
|
3001
|
+
var _a;
|
|
3002
|
+
if (!this._handlerCache.has(serviceName)) {
|
|
3003
|
+
const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : raise2(new Error(`Service not available: ${serviceName}`));
|
|
3004
|
+
const service = this._serviceRegistry.services[key];
|
|
3005
|
+
if (!service) {
|
|
3006
|
+
throw new Error(`Service not available: ${serviceName}`);
|
|
3007
|
+
}
|
|
3008
|
+
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
3009
|
+
}
|
|
3010
|
+
return this._handlerCache.get(serviceName);
|
|
3011
|
+
}
|
|
3012
|
+
};
|
|
3013
|
+
|
|
3014
|
+
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
3464
3015
|
var __decorate3 = function(decorators, target, key, desc) {
|
|
3465
3016
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3466
3017
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -3472,40 +3023,48 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3472
3023
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3473
3024
|
};
|
|
3474
3025
|
var WorkerSession = class {
|
|
3475
|
-
constructor({
|
|
3026
|
+
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal, options = {
|
|
3476
3027
|
heartbeatInterval: 1e3
|
|
3477
3028
|
} }) {
|
|
3478
|
-
this._startTrigger = new
|
|
3029
|
+
this._startTrigger = new Trigger6();
|
|
3479
3030
|
this.onClose = new Callback();
|
|
3480
|
-
|
|
3481
|
-
|
|
3031
|
+
assert11(options);
|
|
3032
|
+
assert11(serviceHost);
|
|
3482
3033
|
this._options = options;
|
|
3483
|
-
this.
|
|
3484
|
-
const
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3034
|
+
this._serviceHost = serviceHost;
|
|
3035
|
+
const middleware = {
|
|
3036
|
+
handleCall: async (method, params, handler) => {
|
|
3037
|
+
const error = await readySignal.wait({
|
|
3038
|
+
timeout: 3e3
|
|
3039
|
+
});
|
|
3040
|
+
if (error) {
|
|
3041
|
+
throw error;
|
|
3042
|
+
}
|
|
3043
|
+
return handler(method, params);
|
|
3044
|
+
},
|
|
3045
|
+
handleStream: async (method, params, handler) => {
|
|
3046
|
+
const error = await readySignal.wait({
|
|
3047
|
+
timeout: 3e3
|
|
3048
|
+
});
|
|
3049
|
+
if (error) {
|
|
3050
|
+
throw error;
|
|
3051
|
+
}
|
|
3052
|
+
return handler(method, params);
|
|
3053
|
+
}
|
|
3495
3054
|
};
|
|
3496
|
-
this._clientRpc =
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
});
|
|
3501
|
-
this._shellClientRpc =
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
});
|
|
3506
|
-
this._iframeRpc =
|
|
3507
|
-
requested:
|
|
3508
|
-
exposed:
|
|
3055
|
+
this._clientRpc = new ClientRpcServer({
|
|
3056
|
+
serviceRegistry: this._serviceHost.serviceRegistry,
|
|
3057
|
+
port: appPort,
|
|
3058
|
+
...middleware
|
|
3059
|
+
});
|
|
3060
|
+
this._shellClientRpc = new ClientRpcServer({
|
|
3061
|
+
serviceRegistry: this._serviceHost.serviceRegistry,
|
|
3062
|
+
port: shellPort,
|
|
3063
|
+
...middleware
|
|
3064
|
+
});
|
|
3065
|
+
this._iframeRpc = createProtoRpcPeer3({
|
|
3066
|
+
requested: iframeServiceBundle2,
|
|
3067
|
+
exposed: workerServiceBundle2,
|
|
3509
3068
|
handlers: {
|
|
3510
3069
|
WorkerService: {
|
|
3511
3070
|
start: async (request) => {
|
|
@@ -3517,9 +3076,9 @@ var WorkerSession = class {
|
|
|
3517
3076
|
try {
|
|
3518
3077
|
await this.close();
|
|
3519
3078
|
} catch (err) {
|
|
3520
|
-
|
|
3079
|
+
log11.catch(err, {}, {
|
|
3521
3080
|
file: "worker-session.ts",
|
|
3522
|
-
line:
|
|
3081
|
+
line: 107,
|
|
3523
3082
|
scope: this,
|
|
3524
3083
|
callSite: (f, a) => f(...a)
|
|
3525
3084
|
});
|
|
@@ -3535,9 +3094,9 @@ var WorkerSession = class {
|
|
|
3535
3094
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
3536
3095
|
}
|
|
3537
3096
|
async open() {
|
|
3538
|
-
|
|
3097
|
+
log11.info("opening..", {}, {
|
|
3539
3098
|
file: "worker-session.ts",
|
|
3540
|
-
line:
|
|
3099
|
+
line: 121,
|
|
3541
3100
|
scope: this,
|
|
3542
3101
|
callSite: (f, a) => f(...a)
|
|
3543
3102
|
});
|
|
@@ -3553,20 +3112,20 @@ var WorkerSession = class {
|
|
|
3553
3112
|
try {
|
|
3554
3113
|
await this._iframeRpc.rpc.IframeService.heartbeat();
|
|
3555
3114
|
} catch (err1) {
|
|
3556
|
-
|
|
3115
|
+
log11.warn("Heartbeat failed", {
|
|
3557
3116
|
err: err1
|
|
3558
3117
|
}, {
|
|
3559
3118
|
file: "worker-session.ts",
|
|
3560
|
-
line:
|
|
3119
|
+
line: 133,
|
|
3561
3120
|
scope: this,
|
|
3562
3121
|
callSite: (f, a) => f(...a)
|
|
3563
3122
|
});
|
|
3564
3123
|
try {
|
|
3565
3124
|
await this.close();
|
|
3566
3125
|
} catch (err) {
|
|
3567
|
-
|
|
3126
|
+
log11.catch(err, {}, {
|
|
3568
3127
|
file: "worker-session.ts",
|
|
3569
|
-
line:
|
|
3128
|
+
line: 137,
|
|
3570
3129
|
scope: this,
|
|
3571
3130
|
callSite: (f, a) => f(...a)
|
|
3572
3131
|
});
|
|
@@ -3575,18 +3134,18 @@ var WorkerSession = class {
|
|
|
3575
3134
|
}, this._options.heartbeatInterval);
|
|
3576
3135
|
}
|
|
3577
3136
|
async close() {
|
|
3578
|
-
|
|
3137
|
+
log11.info("closing..", {}, {
|
|
3579
3138
|
file: "worker-session.ts",
|
|
3580
|
-
line:
|
|
3139
|
+
line: 144,
|
|
3581
3140
|
scope: this,
|
|
3582
3141
|
callSite: (f, a) => f(...a)
|
|
3583
3142
|
});
|
|
3584
3143
|
try {
|
|
3585
3144
|
await this.onClose.callIfSet();
|
|
3586
3145
|
} catch (err) {
|
|
3587
|
-
|
|
3146
|
+
log11.catch(err, {}, {
|
|
3588
3147
|
file: "worker-session.ts",
|
|
3589
|
-
line:
|
|
3148
|
+
line: 148,
|
|
3590
3149
|
scope: this,
|
|
3591
3150
|
callSite: (f, a) => f(...a)
|
|
3592
3151
|
});
|
|
@@ -3603,9 +3162,9 @@ var WorkerSession = class {
|
|
|
3603
3162
|
try {
|
|
3604
3163
|
await asyncTimeout2(this._shellClientRpc.open(), 1e3);
|
|
3605
3164
|
} catch (e) {
|
|
3606
|
-
|
|
3165
|
+
log11.info("No shell connected.", {}, {
|
|
3607
3166
|
file: "worker-session.ts",
|
|
3608
|
-
line:
|
|
3167
|
+
line: 162,
|
|
3609
3168
|
scope: this,
|
|
3610
3169
|
callSite: (f, a) => f(...a)
|
|
3611
3170
|
});
|
|
@@ -3622,20 +3181,21 @@ var WorkerRuntime = class {
|
|
|
3622
3181
|
constructor(_configProvider) {
|
|
3623
3182
|
this._configProvider = _configProvider;
|
|
3624
3183
|
this._transportFactory = new WebRTCTransportProxyFactory();
|
|
3625
|
-
this._ready = new
|
|
3184
|
+
this._ready = new Trigger7();
|
|
3626
3185
|
this.sessions = /* @__PURE__ */ new Set();
|
|
3186
|
+
this._clientServices = new ClientServicesHost();
|
|
3627
3187
|
}
|
|
3628
3188
|
async start() {
|
|
3629
|
-
|
|
3189
|
+
log12("starting...", {}, {
|
|
3630
3190
|
file: "worker-runtime.ts",
|
|
3631
|
-
line:
|
|
3191
|
+
line: 44,
|
|
3632
3192
|
scope: this,
|
|
3633
3193
|
callSite: (f, a) => f(...a)
|
|
3634
3194
|
});
|
|
3635
3195
|
try {
|
|
3636
3196
|
this._config = await this._configProvider();
|
|
3637
3197
|
const signalServer = this._config.get("runtime.services.signal.server");
|
|
3638
|
-
this._clientServices
|
|
3198
|
+
this._clientServices.initialize({
|
|
3639
3199
|
config: this._config,
|
|
3640
3200
|
networkManager: new NetworkManager({
|
|
3641
3201
|
log: true,
|
|
@@ -3647,17 +3207,17 @@ var WorkerRuntime = class {
|
|
|
3647
3207
|
});
|
|
3648
3208
|
await this._clientServices.open();
|
|
3649
3209
|
this._ready.wake(void 0);
|
|
3650
|
-
|
|
3210
|
+
log12("started", {}, {
|
|
3651
3211
|
file: "worker-runtime.ts",
|
|
3652
|
-
line:
|
|
3212
|
+
line: 61,
|
|
3653
3213
|
scope: this,
|
|
3654
3214
|
callSite: (f, a) => f(...a)
|
|
3655
3215
|
});
|
|
3656
3216
|
} catch (err) {
|
|
3657
3217
|
this._ready.wake(err);
|
|
3658
|
-
|
|
3218
|
+
log12.catch(err, {}, {
|
|
3659
3219
|
file: "worker-runtime.ts",
|
|
3660
|
-
line:
|
|
3220
|
+
line: 64,
|
|
3661
3221
|
scope: this,
|
|
3662
3222
|
callSite: (f, a) => f(...a)
|
|
3663
3223
|
});
|
|
@@ -3671,17 +3231,7 @@ var WorkerRuntime = class {
|
|
|
3671
3231
|
*/
|
|
3672
3232
|
async createSession({ appPort, systemPort, shellPort }) {
|
|
3673
3233
|
const session = new WorkerSession({
|
|
3674
|
-
|
|
3675
|
-
const error = await this._ready.wait();
|
|
3676
|
-
if (error) {
|
|
3677
|
-
throw error;
|
|
3678
|
-
}
|
|
3679
|
-
const service = find(this._clientServices.services);
|
|
3680
|
-
if (!service) {
|
|
3681
|
-
throw new Error("Service not found");
|
|
3682
|
-
}
|
|
3683
|
-
return service;
|
|
3684
|
-
},
|
|
3234
|
+
serviceHost: this._clientServices,
|
|
3685
3235
|
appPort,
|
|
3686
3236
|
systemPort,
|
|
3687
3237
|
shellPort,
|
|
@@ -3716,10 +3266,206 @@ var WorkerRuntime = class {
|
|
|
3716
3266
|
}
|
|
3717
3267
|
};
|
|
3718
3268
|
|
|
3269
|
+
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3270
|
+
import { Trigger as Trigger8 } from "@dxos/async";
|
|
3271
|
+
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
3272
|
+
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
3273
|
+
import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
|
|
3274
|
+
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
3275
|
+
import { Keyring } from "@dxos/keyring";
|
|
3276
|
+
import { log as log13 } from "@dxos/log";
|
|
3277
|
+
var ServiceContext = class {
|
|
3278
|
+
// prettier-ignore
|
|
3279
|
+
constructor(storage, networkManager, modelFactory) {
|
|
3280
|
+
this.storage = storage;
|
|
3281
|
+
this.networkManager = networkManager;
|
|
3282
|
+
this.modelFactory = modelFactory;
|
|
3283
|
+
this.initialized = new Trigger8();
|
|
3284
|
+
this.dataServiceSubscriptions = new DataServiceSubscriptions();
|
|
3285
|
+
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
3286
|
+
this.snapshotStore = new SnapshotStore(storage.createDirectory("snapshots"));
|
|
3287
|
+
this.keyring = new Keyring(storage.createDirectory("keyring"));
|
|
3288
|
+
this.feedStore = new FeedStore({
|
|
3289
|
+
factory: new FeedFactory({
|
|
3290
|
+
root: storage.createDirectory("feeds"),
|
|
3291
|
+
signer: this.keyring,
|
|
3292
|
+
hypercore: {
|
|
3293
|
+
valueEncoding
|
|
3294
|
+
}
|
|
3295
|
+
})
|
|
3296
|
+
});
|
|
3297
|
+
this.spaceManager = new SpaceManager({
|
|
3298
|
+
feedStore: this.feedStore,
|
|
3299
|
+
networkManager: this.networkManager
|
|
3300
|
+
});
|
|
3301
|
+
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3302
|
+
this.deviceInvitations = new DeviceInvitationsHandler({
|
|
3303
|
+
networkManager: this.networkManager,
|
|
3304
|
+
getIdentity: () => {
|
|
3305
|
+
var _a;
|
|
3306
|
+
return (_a = this.identityManager.identity) != null ? _a : failUndefined2();
|
|
3307
|
+
},
|
|
3308
|
+
acceptIdentity: this._acceptIdentity.bind(this),
|
|
3309
|
+
keyring: this.keyring
|
|
3310
|
+
});
|
|
3311
|
+
}
|
|
3312
|
+
async open() {
|
|
3313
|
+
log13("opening...", {}, {
|
|
3314
|
+
file: "service-context.ts",
|
|
3315
|
+
line: 94,
|
|
3316
|
+
scope: this,
|
|
3317
|
+
callSite: (f, a) => f(...a)
|
|
3318
|
+
});
|
|
3319
|
+
await this.networkManager.open();
|
|
3320
|
+
await this.spaceManager.open();
|
|
3321
|
+
await this.identityManager.open();
|
|
3322
|
+
if (this.identityManager.identity) {
|
|
3323
|
+
await this._initialize();
|
|
3324
|
+
}
|
|
3325
|
+
log13("opened", {}, {
|
|
3326
|
+
file: "service-context.ts",
|
|
3327
|
+
line: 101,
|
|
3328
|
+
scope: this,
|
|
3329
|
+
callSite: (f, a) => f(...a)
|
|
3330
|
+
});
|
|
3331
|
+
}
|
|
3332
|
+
async close() {
|
|
3333
|
+
var _a, _b;
|
|
3334
|
+
log13("closing...", {}, {
|
|
3335
|
+
file: "service-context.ts",
|
|
3336
|
+
line: 105,
|
|
3337
|
+
scope: this,
|
|
3338
|
+
callSite: (f, a) => f(...a)
|
|
3339
|
+
});
|
|
3340
|
+
await ((_a = this._deviceSpaceSync) == null ? void 0 : _a.close());
|
|
3341
|
+
await ((_b = this.dataSpaceManager) == null ? void 0 : _b.close());
|
|
3342
|
+
await this.identityManager.close();
|
|
3343
|
+
await this.spaceManager.close();
|
|
3344
|
+
await this.feedStore.close();
|
|
3345
|
+
await this.networkManager.close();
|
|
3346
|
+
this.dataServiceSubscriptions.clear();
|
|
3347
|
+
log13("closed", {}, {
|
|
3348
|
+
file: "service-context.ts",
|
|
3349
|
+
line: 113,
|
|
3350
|
+
scope: this,
|
|
3351
|
+
callSite: (f, a) => f(...a)
|
|
3352
|
+
});
|
|
3353
|
+
}
|
|
3354
|
+
async reset() {
|
|
3355
|
+
log13("resetting...", {}, {
|
|
3356
|
+
file: "service-context.ts",
|
|
3357
|
+
line: 117,
|
|
3358
|
+
scope: this,
|
|
3359
|
+
callSite: (f, a) => f(...a)
|
|
3360
|
+
});
|
|
3361
|
+
await this.close();
|
|
3362
|
+
await this.storage.reset();
|
|
3363
|
+
log13("reset", {}, {
|
|
3364
|
+
file: "service-context.ts",
|
|
3365
|
+
line: 120,
|
|
3366
|
+
scope: this,
|
|
3367
|
+
callSite: (f, a) => f(...a)
|
|
3368
|
+
});
|
|
3369
|
+
}
|
|
3370
|
+
async createIdentity(params = {}) {
|
|
3371
|
+
const identity = await this.identityManager.createIdentity(params);
|
|
3372
|
+
await this._initialize();
|
|
3373
|
+
return identity;
|
|
3374
|
+
}
|
|
3375
|
+
async _acceptIdentity(params) {
|
|
3376
|
+
const identity = await this.identityManager.acceptIdentity(params);
|
|
3377
|
+
await this._initialize();
|
|
3378
|
+
return identity;
|
|
3379
|
+
}
|
|
3380
|
+
// Called when identity is created.
|
|
3381
|
+
async _initialize() {
|
|
3382
|
+
var _a;
|
|
3383
|
+
log13("initializing spaces...", {}, {
|
|
3384
|
+
file: "service-context.ts",
|
|
3385
|
+
line: 139,
|
|
3386
|
+
scope: this,
|
|
3387
|
+
callSite: (f, a) => f(...a)
|
|
3388
|
+
});
|
|
3389
|
+
const identity = (_a = this.identityManager.identity) != null ? _a : failUndefined2();
|
|
3390
|
+
const signingContext = {
|
|
3391
|
+
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3392
|
+
identityKey: identity.identityKey,
|
|
3393
|
+
deviceKey: identity.deviceKey,
|
|
3394
|
+
profile: identity.profileDocument,
|
|
3395
|
+
recordCredential: async (credential) => {
|
|
3396
|
+
await identity.controlPipeline.writer.write({
|
|
3397
|
+
credential: {
|
|
3398
|
+
credential
|
|
3399
|
+
}
|
|
3400
|
+
});
|
|
3401
|
+
}
|
|
3402
|
+
};
|
|
3403
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.modelFactory, this.feedStore, this.snapshotStore);
|
|
3404
|
+
await this.dataSpaceManager.open();
|
|
3405
|
+
this.spaceInvitations = new SpaceInvitationsHandler(this.networkManager, this.dataSpaceManager, signingContext, this.keyring);
|
|
3406
|
+
this.initialized.wake();
|
|
3407
|
+
this._deviceSpaceSync = identity.space.spaceState.registerProcessor({
|
|
3408
|
+
process: async (credential) => {
|
|
3409
|
+
const assertion = getCredentialAssertion3(credential);
|
|
3410
|
+
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3411
|
+
return;
|
|
3412
|
+
}
|
|
3413
|
+
if (assertion.spaceKey.equals(identity.space.key)) {
|
|
3414
|
+
return;
|
|
3415
|
+
}
|
|
3416
|
+
if (!this.dataSpaceManager) {
|
|
3417
|
+
log13("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3418
|
+
details: assertion
|
|
3419
|
+
}, {
|
|
3420
|
+
file: "service-context.ts",
|
|
3421
|
+
line: 182,
|
|
3422
|
+
scope: this,
|
|
3423
|
+
callSite: (f, a) => f(...a)
|
|
3424
|
+
});
|
|
3425
|
+
return;
|
|
3426
|
+
}
|
|
3427
|
+
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3428
|
+
log13("space already exists, ignoring space admission", {
|
|
3429
|
+
details: assertion
|
|
3430
|
+
}, {
|
|
3431
|
+
file: "service-context.ts",
|
|
3432
|
+
line: 186,
|
|
3433
|
+
scope: this,
|
|
3434
|
+
callSite: (f, a) => f(...a)
|
|
3435
|
+
});
|
|
3436
|
+
return;
|
|
3437
|
+
}
|
|
3438
|
+
try {
|
|
3439
|
+
log13("accepting space recorded in halo", {
|
|
3440
|
+
details: assertion
|
|
3441
|
+
}, {
|
|
3442
|
+
file: "service-context.ts",
|
|
3443
|
+
line: 191,
|
|
3444
|
+
scope: this,
|
|
3445
|
+
callSite: (f, a) => f(...a)
|
|
3446
|
+
});
|
|
3447
|
+
await this.dataSpaceManager.acceptSpace({
|
|
3448
|
+
spaceKey: assertion.spaceKey,
|
|
3449
|
+
genesisFeedKey: assertion.genesisFeedKey
|
|
3450
|
+
});
|
|
3451
|
+
} catch (err) {
|
|
3452
|
+
log13.catch(err, {}, {
|
|
3453
|
+
file: "service-context.ts",
|
|
3454
|
+
line: 197,
|
|
3455
|
+
scope: this,
|
|
3456
|
+
callSite: (f, a) => f(...a)
|
|
3457
|
+
});
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
});
|
|
3461
|
+
await this._deviceSpaceSync.open();
|
|
3462
|
+
}
|
|
3463
|
+
};
|
|
3464
|
+
|
|
3719
3465
|
// packages/sdk/client-services/src/packlets/services/service-registry.ts
|
|
3720
3466
|
var ServiceRegistry = class {
|
|
3721
3467
|
// prettier-ignore
|
|
3722
|
-
constructor(_serviceBundle, _handlers) {
|
|
3468
|
+
constructor(_serviceBundle, _handlers = {}) {
|
|
3723
3469
|
this._serviceBundle = _serviceBundle;
|
|
3724
3470
|
this._handlers = _handlers;
|
|
3725
3471
|
}
|
|
@@ -3732,28 +3478,35 @@ var ServiceRegistry = class {
|
|
|
3732
3478
|
setServices(services) {
|
|
3733
3479
|
this._handlers = services;
|
|
3734
3480
|
}
|
|
3481
|
+
addService(name, service) {
|
|
3482
|
+
this._handlers[name] = service;
|
|
3483
|
+
}
|
|
3484
|
+
removeService(name) {
|
|
3485
|
+
delete this._handlers[name];
|
|
3486
|
+
}
|
|
3735
3487
|
};
|
|
3736
3488
|
|
|
3737
3489
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3738
|
-
var createDefaultModelFactory = () => {
|
|
3739
|
-
return new ModelFactory().registerModel(DocumentModel).registerModel(TextModel);
|
|
3740
|
-
};
|
|
3741
3490
|
var ClientServicesHost = class {
|
|
3742
3491
|
constructor({
|
|
3743
3492
|
config,
|
|
3744
3493
|
modelFactory = createDefaultModelFactory(),
|
|
3745
3494
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3746
3495
|
networkManager,
|
|
3747
|
-
storage
|
|
3496
|
+
storage,
|
|
3748
3497
|
// TODO(wittjosiah): Turn this on by default.
|
|
3749
3498
|
lockKey
|
|
3750
|
-
}) {
|
|
3751
|
-
this._statusUpdate = new
|
|
3499
|
+
} = {}) {
|
|
3500
|
+
this._statusUpdate = new Event6();
|
|
3752
3501
|
this._open = false;
|
|
3753
|
-
this._config = config;
|
|
3754
|
-
this._modelFactory = modelFactory;
|
|
3755
|
-
this._networkManager = networkManager;
|
|
3756
3502
|
this._storage = storage;
|
|
3503
|
+
this._modelFactory = modelFactory;
|
|
3504
|
+
if (config) {
|
|
3505
|
+
this.initialize({
|
|
3506
|
+
config,
|
|
3507
|
+
networkManager
|
|
3508
|
+
});
|
|
3509
|
+
}
|
|
3757
3510
|
this._resourceLock = lockKey ? new VaultResourceLock({
|
|
3758
3511
|
lockKey,
|
|
3759
3512
|
onAcquire: () => this.open(),
|
|
@@ -3772,7 +3525,7 @@ var ClientServicesHost = class {
|
|
|
3772
3525
|
}
|
|
3773
3526
|
},
|
|
3774
3527
|
onReset: async () => {
|
|
3775
|
-
|
|
3528
|
+
assert12(this._serviceContext, "service host is closed");
|
|
3776
3529
|
await this._serviceContext.reset();
|
|
3777
3530
|
}
|
|
3778
3531
|
});
|
|
@@ -3783,20 +3536,45 @@ var ClientServicesHost = class {
|
|
|
3783
3536
|
get isOpen() {
|
|
3784
3537
|
return this._open;
|
|
3785
3538
|
}
|
|
3539
|
+
get serviceRegistry() {
|
|
3540
|
+
return this._serviceRegistry;
|
|
3541
|
+
}
|
|
3786
3542
|
get descriptors() {
|
|
3787
3543
|
return this._serviceRegistry.descriptors;
|
|
3788
3544
|
}
|
|
3789
3545
|
get services() {
|
|
3790
3546
|
return this._serviceRegistry.services;
|
|
3791
3547
|
}
|
|
3548
|
+
/**
|
|
3549
|
+
* Initialize the service host with the config.
|
|
3550
|
+
* Config can also be provided in the constructor.
|
|
3551
|
+
* Can only be called once.
|
|
3552
|
+
*/
|
|
3553
|
+
initialize({ config, networkManager }) {
|
|
3554
|
+
assert12(!this._open, "service host is open");
|
|
3555
|
+
if (config) {
|
|
3556
|
+
assert12(!this._config, "config already set");
|
|
3557
|
+
this._config = config;
|
|
3558
|
+
if (!this._storage) {
|
|
3559
|
+
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
if (networkManager) {
|
|
3563
|
+
assert12(!this._networkManager, "network manager already set");
|
|
3564
|
+
this._networkManager = networkManager;
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3792
3567
|
async open() {
|
|
3793
3568
|
var _a, _b;
|
|
3794
3569
|
if (this._open) {
|
|
3795
3570
|
return;
|
|
3796
3571
|
}
|
|
3797
|
-
|
|
3572
|
+
assert12(this._config, "config not set");
|
|
3573
|
+
assert12(this._storage, "storage not set");
|
|
3574
|
+
assert12(this._networkManager, "network manager not set");
|
|
3575
|
+
log14("opening...", {}, {
|
|
3798
3576
|
file: "service-host.ts",
|
|
3799
|
-
line:
|
|
3577
|
+
line: 166,
|
|
3800
3578
|
scope: this,
|
|
3801
3579
|
callSite: (f, a) => f(...a)
|
|
3802
3580
|
});
|
|
@@ -3809,10 +3587,10 @@ var ClientServicesHost = class {
|
|
|
3809
3587
|
DeviceInvitationsService: new DeviceInvitationsServiceImpl(this._serviceContext.identityManager, this._serviceContext.deviceInvitations),
|
|
3810
3588
|
SpaceInvitationsService: new SpaceInvitationsServiceImpl(this._serviceContext.identityManager, () => {
|
|
3811
3589
|
var _a2;
|
|
3812
|
-
return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 :
|
|
3590
|
+
return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 : raise3(new Error("SpaceInvitations not initialized"));
|
|
3813
3591
|
}, () => {
|
|
3814
3592
|
var _a2;
|
|
3815
|
-
return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 :
|
|
3593
|
+
return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : raise3(new Error("SpaceManager not initialized"));
|
|
3816
3594
|
}),
|
|
3817
3595
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
3818
3596
|
await this._serviceContext.initialized.wait();
|
|
@@ -3832,11 +3610,11 @@ var ClientServicesHost = class {
|
|
|
3832
3610
|
this._open = true;
|
|
3833
3611
|
this._statusUpdate.emit();
|
|
3834
3612
|
const deviceKey = (_b = this._serviceContext.identityManager.identity) == null ? void 0 : _b.deviceKey;
|
|
3835
|
-
|
|
3613
|
+
log14("opened", {
|
|
3836
3614
|
deviceKey
|
|
3837
3615
|
}, {
|
|
3838
3616
|
file: "service-host.ts",
|
|
3839
|
-
line:
|
|
3617
|
+
line: 219,
|
|
3840
3618
|
scope: this,
|
|
3841
3619
|
callSite: (f, a) => f(...a)
|
|
3842
3620
|
});
|
|
@@ -3847,11 +3625,11 @@ var ClientServicesHost = class {
|
|
|
3847
3625
|
return;
|
|
3848
3626
|
}
|
|
3849
3627
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
3850
|
-
|
|
3628
|
+
log14("closing...", {
|
|
3851
3629
|
deviceKey
|
|
3852
3630
|
}, {
|
|
3853
3631
|
file: "service-host.ts",
|
|
3854
|
-
line:
|
|
3632
|
+
line: 228,
|
|
3855
3633
|
scope: this,
|
|
3856
3634
|
callSite: (f, a) => f(...a)
|
|
3857
3635
|
});
|
|
@@ -3861,49 +3639,17 @@ var ClientServicesHost = class {
|
|
|
3861
3639
|
await this._serviceContext.close();
|
|
3862
3640
|
this._open = false;
|
|
3863
3641
|
this._statusUpdate.emit();
|
|
3864
|
-
|
|
3642
|
+
log14("closed", {
|
|
3865
3643
|
deviceKey
|
|
3866
3644
|
}, {
|
|
3867
3645
|
file: "service-host.ts",
|
|
3868
|
-
line:
|
|
3646
|
+
line: 233,
|
|
3869
3647
|
scope: this,
|
|
3870
3648
|
callSite: (f, a) => f(...a)
|
|
3871
3649
|
});
|
|
3872
3650
|
}
|
|
3873
3651
|
};
|
|
3874
3652
|
|
|
3875
|
-
// packages/sdk/client-services/src/packlets/services/service-proxy.ts
|
|
3876
|
-
import { asyncTimeout as asyncTimeout3 } from "@dxos/async";
|
|
3877
|
-
import { RemoteServiceConnectionTimeout } from "@dxos/errors";
|
|
3878
|
-
import { createProtoRpcPeer as createProtoRpcPeer5 } from "@dxos/rpc";
|
|
3879
|
-
var ClientServicesProxy = class {
|
|
3880
|
-
// prettier-ignore
|
|
3881
|
-
constructor(port, _timeout = 3e4) {
|
|
3882
|
-
this._timeout = _timeout;
|
|
3883
|
-
this._proxy = createProtoRpcPeer5({
|
|
3884
|
-
requested: clientServiceBundle,
|
|
3885
|
-
exposed: {},
|
|
3886
|
-
handlers: {},
|
|
3887
|
-
port
|
|
3888
|
-
});
|
|
3889
|
-
}
|
|
3890
|
-
get proxy() {
|
|
3891
|
-
return this._proxy;
|
|
3892
|
-
}
|
|
3893
|
-
get descriptors() {
|
|
3894
|
-
return clientServiceBundle;
|
|
3895
|
-
}
|
|
3896
|
-
get services() {
|
|
3897
|
-
return this._proxy.rpc;
|
|
3898
|
-
}
|
|
3899
|
-
async open() {
|
|
3900
|
-
await asyncTimeout3(this._proxy.open(), this._timeout, new RemoteServiceConnectionTimeout());
|
|
3901
|
-
}
|
|
3902
|
-
async close() {
|
|
3903
|
-
await this._proxy.close();
|
|
3904
|
-
}
|
|
3905
|
-
};
|
|
3906
|
-
|
|
3907
3653
|
// packages/sdk/client-services/src/packlets/services/local-client-services.ts
|
|
3908
3654
|
var LocalClientServices = class {
|
|
3909
3655
|
constructor(params) {
|
|
@@ -3915,6 +3661,9 @@ var LocalClientServices = class {
|
|
|
3915
3661
|
get services() {
|
|
3916
3662
|
return this._host.services;
|
|
3917
3663
|
}
|
|
3664
|
+
get host() {
|
|
3665
|
+
return this._host;
|
|
3666
|
+
}
|
|
3918
3667
|
async open() {
|
|
3919
3668
|
await this._host.open();
|
|
3920
3669
|
}
|
|
@@ -3923,6 +3672,43 @@ var LocalClientServices = class {
|
|
|
3923
3672
|
}
|
|
3924
3673
|
};
|
|
3925
3674
|
|
|
3675
|
+
// packages/sdk/client-services/src/packlets/services/utils.ts
|
|
3676
|
+
import { Config } from "@dxos/config";
|
|
3677
|
+
import { log as log15 } from "@dxos/log";
|
|
3678
|
+
import { MemorySignalManager as MemorySignalManager2, MemorySignalManagerContext as MemorySignalManagerContext2, WebsocketSignalManager as WebsocketSignalManager2 } from "@dxos/messaging";
|
|
3679
|
+
import { createWebRTCTransportFactory, MemoryTransportFactory, NetworkManager as NetworkManager2 } from "@dxos/network-manager";
|
|
3680
|
+
var fromHost = (config = new Config()) => {
|
|
3681
|
+
return new LocalClientServices({
|
|
3682
|
+
config,
|
|
3683
|
+
networkManager: createNetworkManager(config)
|
|
3684
|
+
});
|
|
3685
|
+
};
|
|
3686
|
+
var createNetworkManager = (config, options = {}) => {
|
|
3687
|
+
const signalServer = config.get("runtime.services.signal.server");
|
|
3688
|
+
if (signalServer) {
|
|
3689
|
+
const { log: log1 = true, signalManager = new WebsocketSignalManager2([
|
|
3690
|
+
signalServer
|
|
3691
|
+
]), transportFactory = createWebRTCTransportFactory({
|
|
3692
|
+
iceServers: config.get("runtime.services.ice")
|
|
3693
|
+
}) } = options;
|
|
3694
|
+
return new NetworkManager2({
|
|
3695
|
+
log: log1,
|
|
3696
|
+
signalManager,
|
|
3697
|
+
transportFactory
|
|
3698
|
+
});
|
|
3699
|
+
}
|
|
3700
|
+
log15.warn("P2P network is not configured.", {}, {
|
|
3701
|
+
file: "utils.ts",
|
|
3702
|
+
line: 48,
|
|
3703
|
+
scope: void 0,
|
|
3704
|
+
callSite: (f, a) => f(...a)
|
|
3705
|
+
});
|
|
3706
|
+
return new NetworkManager2({
|
|
3707
|
+
signalManager: new MemorySignalManager2(new MemorySignalManagerContext2()),
|
|
3708
|
+
transportFactory: MemoryTransportFactory
|
|
3709
|
+
});
|
|
3710
|
+
};
|
|
3711
|
+
|
|
3926
3712
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3927
3713
|
var __decorate4 = function(decorators, target, key, desc) {
|
|
3928
3714
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3937,22 +3723,11 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
3937
3723
|
var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
3938
3724
|
var IFrameHostRuntime = class {
|
|
3939
3725
|
constructor({ configProvider, appPort, shellPort }) {
|
|
3940
|
-
this._transportFactory =
|
|
3726
|
+
this._transportFactory = createWebRTCTransportFactory2();
|
|
3941
3727
|
this._ready = new Trigger9();
|
|
3942
3728
|
this._configProvider = configProvider;
|
|
3943
3729
|
this._appPort = appPort;
|
|
3944
3730
|
this._shellPort = shellPort;
|
|
3945
|
-
this._getService = async (find) => {
|
|
3946
|
-
const error = await this._ready.wait();
|
|
3947
|
-
if (error) {
|
|
3948
|
-
throw error;
|
|
3949
|
-
}
|
|
3950
|
-
const service = await find(this._clientServices.services);
|
|
3951
|
-
if (!service) {
|
|
3952
|
-
throw new Error("Service not found");
|
|
3953
|
-
}
|
|
3954
|
-
return service;
|
|
3955
|
-
};
|
|
3956
3731
|
if (this._shellPort) {
|
|
3957
3732
|
this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
|
|
3958
3733
|
}
|
|
@@ -3965,9 +3740,9 @@ var IFrameHostRuntime = class {
|
|
|
3965
3740
|
}
|
|
3966
3741
|
async start() {
|
|
3967
3742
|
var _a;
|
|
3968
|
-
|
|
3743
|
+
log16("starting...", {}, {
|
|
3969
3744
|
file: "iframe-host-runtime.ts",
|
|
3970
|
-
line:
|
|
3745
|
+
line: 67,
|
|
3971
3746
|
scope: this,
|
|
3972
3747
|
callSite: (f, a) => f(...a)
|
|
3973
3748
|
});
|
|
@@ -3977,29 +3752,38 @@ var IFrameHostRuntime = class {
|
|
|
3977
3752
|
this._clientServices = new LocalClientServices({
|
|
3978
3753
|
lockKey: LOCK_KEY,
|
|
3979
3754
|
config: this._config,
|
|
3980
|
-
networkManager: new
|
|
3755
|
+
networkManager: new NetworkManager3({
|
|
3981
3756
|
log: true,
|
|
3982
|
-
signalManager: signalServer ? new
|
|
3757
|
+
signalManager: signalServer ? new WebsocketSignalManager3([
|
|
3983
3758
|
signalServer
|
|
3984
|
-
]) : new
|
|
3759
|
+
]) : new MemorySignalManager3(new MemorySignalManagerContext3()),
|
|
3985
3760
|
transportFactory: this._transportFactory
|
|
3986
3761
|
})
|
|
3987
3762
|
});
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
|
|
3998
|
-
SpacesService: async () => await this._getService((services) => services.SpacesService),
|
|
3999
|
-
SystemService: async () => await this._getService((services) => services.SystemService),
|
|
4000
|
-
TracingService: async () => await this._getService((services) => services.TracingService)
|
|
3763
|
+
const middleware = {
|
|
3764
|
+
handleCall: async (method, params, handler) => {
|
|
3765
|
+
const error = await this._ready.wait({
|
|
3766
|
+
timeout: 3e3
|
|
3767
|
+
});
|
|
3768
|
+
if (error) {
|
|
3769
|
+
throw error;
|
|
3770
|
+
}
|
|
3771
|
+
return handler(method, params);
|
|
4001
3772
|
},
|
|
4002
|
-
|
|
3773
|
+
handleStream: async (method, params, handler) => {
|
|
3774
|
+
const error = await this._ready.wait({
|
|
3775
|
+
timeout: 3e3
|
|
3776
|
+
});
|
|
3777
|
+
if (error) {
|
|
3778
|
+
throw error;
|
|
3779
|
+
}
|
|
3780
|
+
return handler(method, params);
|
|
3781
|
+
}
|
|
3782
|
+
};
|
|
3783
|
+
this._clientRpc = new ClientRpcServer({
|
|
3784
|
+
serviceRegistry: this._clientServices.host.serviceRegistry,
|
|
3785
|
+
port: this._appPort,
|
|
3786
|
+
...middleware
|
|
4003
3787
|
});
|
|
4004
3788
|
await Promise.all([
|
|
4005
3789
|
this._clientServices.open(),
|
|
@@ -4007,17 +3791,17 @@ var IFrameHostRuntime = class {
|
|
|
4007
3791
|
(_a = this._shellRuntime) == null ? void 0 : _a.open()
|
|
4008
3792
|
]);
|
|
4009
3793
|
this._ready.wake(void 0);
|
|
4010
|
-
|
|
3794
|
+
log16("started", {}, {
|
|
4011
3795
|
file: "iframe-host-runtime.ts",
|
|
4012
|
-
line:
|
|
3796
|
+
line: 110,
|
|
4013
3797
|
scope: this,
|
|
4014
3798
|
callSite: (f, a) => f(...a)
|
|
4015
3799
|
});
|
|
4016
3800
|
} catch (err) {
|
|
4017
3801
|
this._ready.wake(err);
|
|
4018
|
-
|
|
3802
|
+
log16.catch(err, {}, {
|
|
4019
3803
|
file: "iframe-host-runtime.ts",
|
|
4020
|
-
line:
|
|
3804
|
+
line: 113,
|
|
4021
3805
|
scope: this,
|
|
4022
3806
|
callSite: (f, a) => f(...a)
|
|
4023
3807
|
});
|
|
@@ -4025,18 +3809,18 @@ var IFrameHostRuntime = class {
|
|
|
4025
3809
|
}
|
|
4026
3810
|
async stop() {
|
|
4027
3811
|
var _a;
|
|
4028
|
-
|
|
3812
|
+
log16("stopping...", {}, {
|
|
4029
3813
|
file: "iframe-host-runtime.ts",
|
|
4030
|
-
line:
|
|
3814
|
+
line: 118,
|
|
4031
3815
|
scope: this,
|
|
4032
3816
|
callSite: (f, a) => f(...a)
|
|
4033
3817
|
});
|
|
4034
3818
|
await this._clientRpc.close();
|
|
4035
3819
|
await this._clientServices.close();
|
|
4036
3820
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
4037
|
-
|
|
3821
|
+
log16("stopped", {}, {
|
|
4038
3822
|
file: "iframe-host-runtime.ts",
|
|
4039
|
-
line:
|
|
3823
|
+
line: 122,
|
|
4040
3824
|
scope: this,
|
|
4041
3825
|
callSite: (f, a) => f(...a)
|
|
4042
3826
|
});
|
|
@@ -4062,41 +3846,23 @@ export {
|
|
|
4062
3846
|
Identity,
|
|
4063
3847
|
IdentityManager,
|
|
4064
3848
|
IdentityServiceImpl,
|
|
4065
|
-
InvitationEncoder,
|
|
4066
|
-
AUTHENTICATION_CODE_LENGTH,
|
|
4067
|
-
INVITATION_TIMEOUT,
|
|
4068
|
-
ON_CLOSE_DELAY,
|
|
4069
|
-
InvitationObservableProvider,
|
|
4070
|
-
AuthenticatingInvitationProvider,
|
|
4071
|
-
wrapObservable,
|
|
4072
|
-
AbstractInvitationsHandler,
|
|
4073
3849
|
DeviceInvitationsHandler,
|
|
4074
|
-
AbstractInvitationsProxy,
|
|
4075
|
-
DeviceInvitationsProxy,
|
|
4076
3850
|
AbstractInvitationsService,
|
|
4077
3851
|
DeviceInvitationsServiceImpl,
|
|
4078
3852
|
SpaceInvitationsHandler,
|
|
4079
|
-
SpaceInvitationsProxy,
|
|
4080
3853
|
SpaceInvitationsServiceImpl,
|
|
4081
|
-
ServiceContext,
|
|
4082
|
-
clientServiceBundle,
|
|
4083
3854
|
createStorageObjects,
|
|
4084
|
-
iframeServiceBundle,
|
|
4085
|
-
workerServiceBundle,
|
|
4086
|
-
appServiceBundle,
|
|
4087
|
-
shellServiceBundle,
|
|
4088
3855
|
ShellRuntimeImpl,
|
|
4089
3856
|
MemoryShellRuntime,
|
|
4090
3857
|
IFrameHostRuntime,
|
|
4091
3858
|
IFrameProxyRuntime,
|
|
4092
|
-
ShellController,
|
|
4093
3859
|
VaultResourceLock,
|
|
4094
3860
|
WorkerSession,
|
|
4095
3861
|
WorkerRuntime,
|
|
3862
|
+
ServiceContext,
|
|
4096
3863
|
ServiceRegistry,
|
|
4097
|
-
createDefaultModelFactory,
|
|
4098
3864
|
ClientServicesHost,
|
|
4099
|
-
|
|
4100
|
-
|
|
3865
|
+
LocalClientServices,
|
|
3866
|
+
fromHost
|
|
4101
3867
|
};
|
|
4102
|
-
//# sourceMappingURL=chunk-
|
|
3868
|
+
//# sourceMappingURL=chunk-ZIQUYEJS.mjs.map
|