@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
package/dist/lib/node/index.cjs
CHANGED
|
@@ -30,57 +30,39 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// packages/sdk/client-services/src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
AUTHENTICATION_CODE_LENGTH: () => AUTHENTICATION_CODE_LENGTH,
|
|
34
|
-
AbstractInvitationsHandler: () => AbstractInvitationsHandler,
|
|
35
|
-
AbstractInvitationsProxy: () => AbstractInvitationsProxy,
|
|
36
33
|
AbstractInvitationsService: () => AbstractInvitationsService,
|
|
37
|
-
AuthenticatingInvitationProvider: () => AuthenticatingInvitationProvider,
|
|
38
34
|
ClientServicesHost: () => ClientServicesHost,
|
|
39
|
-
ClientServicesProxy: () => ClientServicesProxy,
|
|
40
35
|
DeviceInvitationsHandler: () => DeviceInvitationsHandler,
|
|
41
|
-
DeviceInvitationsProxy: () => DeviceInvitationsProxy,
|
|
42
36
|
DeviceInvitationsServiceImpl: () => DeviceInvitationsServiceImpl,
|
|
43
37
|
DevtoolsHostEvents: () => DevtoolsHostEvents,
|
|
44
38
|
DevtoolsServiceImpl: () => DevtoolsServiceImpl,
|
|
45
39
|
IFrameHostRuntime: () => IFrameHostRuntime,
|
|
46
40
|
IFrameProxyRuntime: () => IFrameProxyRuntime,
|
|
47
|
-
INVITATION_TIMEOUT: () => INVITATION_TIMEOUT,
|
|
48
41
|
Identity: () => Identity,
|
|
49
42
|
IdentityManager: () => IdentityManager,
|
|
50
43
|
IdentityServiceImpl: () => IdentityServiceImpl,
|
|
51
|
-
InvitationEncoder: () => InvitationEncoder,
|
|
52
|
-
InvitationObservableProvider: () => InvitationObservableProvider,
|
|
53
44
|
LocalClientServices: () => LocalClientServices,
|
|
54
45
|
MemoryShellRuntime: () => MemoryShellRuntime,
|
|
55
|
-
ON_CLOSE_DELAY: () => ON_CLOSE_DELAY,
|
|
56
46
|
ServiceContext: () => ServiceContext,
|
|
57
47
|
ServiceRegistry: () => ServiceRegistry,
|
|
58
|
-
ShellController: () => ShellController,
|
|
59
48
|
ShellRuntimeImpl: () => ShellRuntimeImpl,
|
|
60
49
|
SpaceInvitationsHandler: () => SpaceInvitationsHandler,
|
|
61
|
-
SpaceInvitationsProxy: () => SpaceInvitationsProxy,
|
|
62
50
|
SpaceInvitationsServiceImpl: () => SpaceInvitationsServiceImpl,
|
|
63
51
|
TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
|
|
64
52
|
VaultResourceLock: () => VaultResourceLock,
|
|
65
53
|
WorkerRuntime: () => WorkerRuntime,
|
|
66
54
|
WorkerSession: () => WorkerSession,
|
|
67
|
-
appServiceBundle: () => appServiceBundle,
|
|
68
|
-
clientServiceBundle: () => clientServiceBundle,
|
|
69
55
|
createAuthProvider: () => createAuthProvider,
|
|
70
|
-
createDefaultModelFactory: () => createDefaultModelFactory,
|
|
71
56
|
createStorageObjects: () => createStorageObjects,
|
|
57
|
+
fromHost: () => fromHost,
|
|
72
58
|
getNetworkPeers: () => getNetworkPeers,
|
|
73
|
-
iframeServiceBundle: () => iframeServiceBundle,
|
|
74
|
-
shellServiceBundle: () => shellServiceBundle,
|
|
75
59
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
76
60
|
subscribeToFeeds: () => subscribeToFeeds,
|
|
77
61
|
subscribeToNetworkStatus: () => subscribeToNetworkStatus,
|
|
78
62
|
subscribeToNetworkTopics: () => subscribeToNetworkTopics,
|
|
79
63
|
subscribeToSignal: () => subscribeToSignal,
|
|
80
64
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
81
|
-
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
82
|
-
workerServiceBundle: () => workerServiceBundle,
|
|
83
|
-
wrapObservable: () => wrapObservable
|
|
65
|
+
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
84
66
|
});
|
|
85
67
|
module.exports = __toCommonJS(src_exports);
|
|
86
68
|
|
|
@@ -888,84 +870,20 @@ var IdentityServiceImpl = class {
|
|
|
888
870
|
}
|
|
889
871
|
};
|
|
890
872
|
|
|
891
|
-
// packages/sdk/client-services/src/packlets/invitations/encoder.ts
|
|
892
|
-
var import_base_x = __toESM(require("base-x"));
|
|
893
|
-
var import_protocols2 = require("@dxos/protocols");
|
|
894
|
-
var base62 = (0, import_base_x.default)("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
|
895
|
-
var codec = import_protocols2.schema.getCodecForType("dxos.client.services.Invitation");
|
|
896
|
-
var InvitationEncoder = class {
|
|
897
|
-
static decode(text) {
|
|
898
|
-
return codec.decode(base62.decode(text));
|
|
899
|
-
}
|
|
900
|
-
static encode(invitation) {
|
|
901
|
-
return base62.encode(codec.encode(invitation));
|
|
902
|
-
}
|
|
903
|
-
};
|
|
904
|
-
|
|
905
873
|
// packages/sdk/client-services/src/packlets/invitations/device-invitations-handler.ts
|
|
906
|
-
var
|
|
907
|
-
var
|
|
874
|
+
var import_node_assert4 = __toESM(require("node:assert"));
|
|
875
|
+
var import_async6 = require("@dxos/async");
|
|
876
|
+
var import_client = require("@dxos/client");
|
|
908
877
|
var import_context3 = require("@dxos/context");
|
|
909
878
|
var import_credentials7 = require("@dxos/credentials");
|
|
910
879
|
var import_keys4 = require("@dxos/keys");
|
|
911
880
|
var import_log4 = require("@dxos/log");
|
|
912
881
|
var import_network_manager = require("@dxos/network-manager");
|
|
913
|
-
var
|
|
914
|
-
var
|
|
882
|
+
var import_protocols2 = require("@dxos/protocols");
|
|
883
|
+
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
915
884
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
916
885
|
var import_teleport = require("@dxos/teleport");
|
|
917
|
-
|
|
918
|
-
// packages/sdk/client-services/src/packlets/invitations/invitations.ts
|
|
919
|
-
var import_node_assert4 = __toESM(require("node:assert"));
|
|
920
|
-
var import_async6 = require("@dxos/async");
|
|
921
|
-
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
922
|
-
var AUTHENTICATION_CODE_LENGTH = 6;
|
|
923
|
-
var INVITATION_TIMEOUT = 3 * 6e4;
|
|
924
|
-
var ON_CLOSE_DELAY = 1e3;
|
|
925
|
-
var InvitationObservableProvider = class extends import_async6.CancellableObservableProvider {
|
|
926
|
-
get invitation() {
|
|
927
|
-
return this._invitation;
|
|
928
|
-
}
|
|
929
|
-
setInvitation(invitation) {
|
|
930
|
-
this._invitation = invitation;
|
|
931
|
-
}
|
|
932
|
-
};
|
|
933
|
-
var AuthenticatingInvitationProvider = class extends InvitationObservableProvider {
|
|
934
|
-
// prettier-ignore
|
|
935
|
-
constructor(_actions) {
|
|
936
|
-
super(() => this._actions.onCancel());
|
|
937
|
-
this._actions = _actions;
|
|
938
|
-
}
|
|
939
|
-
async authenticate(authenticationCode) {
|
|
940
|
-
return this._actions.onAuthenticate(authenticationCode);
|
|
941
|
-
}
|
|
942
|
-
};
|
|
943
|
-
var wrapObservable = async (observable) => {
|
|
944
|
-
return new Promise((resolve, reject) => {
|
|
945
|
-
const unsubscribe = observable.subscribe({
|
|
946
|
-
onSuccess: (invitation) => {
|
|
947
|
-
(0, import_node_assert4.default)(invitation.state === import_services.Invitation.State.SUCCESS);
|
|
948
|
-
unsubscribe();
|
|
949
|
-
resolve(invitation);
|
|
950
|
-
},
|
|
951
|
-
onError: (err) => {
|
|
952
|
-
unsubscribe();
|
|
953
|
-
reject(err);
|
|
954
|
-
}
|
|
955
|
-
});
|
|
956
|
-
});
|
|
957
|
-
};
|
|
958
|
-
|
|
959
|
-
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
960
|
-
var AbstractInvitationsHandler = class {
|
|
961
|
-
// prettier-ignore
|
|
962
|
-
constructor(_networkManager) {
|
|
963
|
-
this._networkManager = _networkManager;
|
|
964
|
-
}
|
|
965
|
-
};
|
|
966
|
-
|
|
967
|
-
// packages/sdk/client-services/src/packlets/invitations/device-invitations-handler.ts
|
|
968
|
-
var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
886
|
+
var DeviceInvitationsHandler = class extends import_client.AbstractInvitationsHandler {
|
|
969
887
|
// prettier-ignore
|
|
970
888
|
constructor(_params) {
|
|
971
889
|
super(_params.networkManager);
|
|
@@ -975,14 +893,14 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
975
893
|
* Creates an invitation and listens for a join request from the invited (guest) peer.
|
|
976
894
|
*/
|
|
977
895
|
createInvitation(context, options) {
|
|
978
|
-
const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
|
|
979
|
-
(0,
|
|
896
|
+
const { type, timeout = import_client.INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
|
|
897
|
+
(0, import_node_assert4.default)(type !== import_services.Invitation.Type.OFFLINE);
|
|
980
898
|
const identity = this._params.getIdentity();
|
|
981
899
|
const invitation = {
|
|
982
900
|
type,
|
|
983
901
|
invitationId: import_keys4.PublicKey.random().toHex(),
|
|
984
902
|
swarmKey: swarmKey != null ? swarmKey : import_keys4.PublicKey.random(),
|
|
985
|
-
authenticationCode: (0, import_credentials7.generatePasscode)(AUTHENTICATION_CODE_LENGTH)
|
|
903
|
+
authenticationCode: (0, import_credentials7.generatePasscode)(import_client.AUTHENTICATION_CODE_LENGTH)
|
|
986
904
|
};
|
|
987
905
|
const ctx = new import_context3.Context({
|
|
988
906
|
onError: (err) => {
|
|
@@ -990,11 +908,11 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
990
908
|
observable.callback.onError(err);
|
|
991
909
|
}
|
|
992
910
|
});
|
|
993
|
-
const observable = new InvitationObservableProvider(async () => {
|
|
911
|
+
const observable = new import_client.InvitationObservableProvider(async () => {
|
|
994
912
|
await ctx.dispose();
|
|
995
913
|
});
|
|
996
914
|
let authenticationCode;
|
|
997
|
-
const complete = new
|
|
915
|
+
const complete = new import_async6.Trigger();
|
|
998
916
|
const createExtension = () => new HostHaloInvitationExtension({
|
|
999
917
|
requestAdmission: async () => {
|
|
1000
918
|
var _a, _b;
|
|
@@ -1002,7 +920,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1002
920
|
host: identity.deviceKey
|
|
1003
921
|
}, {
|
|
1004
922
|
file: "device-invitations-handler.ts",
|
|
1005
|
-
line:
|
|
923
|
+
line: 92,
|
|
1006
924
|
scope: this,
|
|
1007
925
|
callSite: (f, a) => f(...a)
|
|
1008
926
|
});
|
|
@@ -1018,7 +936,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1018
936
|
authenticationCode: code
|
|
1019
937
|
}, {
|
|
1020
938
|
file: "device-invitations-handler.ts",
|
|
1021
|
-
line:
|
|
939
|
+
line: 106,
|
|
1022
940
|
scope: this,
|
|
1023
941
|
callSite: (f, a) => f(...a)
|
|
1024
942
|
});
|
|
@@ -1030,7 +948,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1030
948
|
// TODO(burdon): Not used: controlFeedKey, dataFeedKey.
|
|
1031
949
|
presentAdmissionCredentials: async (credentials) => {
|
|
1032
950
|
try {
|
|
1033
|
-
if (invitation.type !==
|
|
951
|
+
if (invitation.type !== import_services.Invitation.Type.INTERACTIVE_TESTING) {
|
|
1034
952
|
if (invitation.authenticationCode === void 0 || invitation.authenticationCode !== authenticationCode) {
|
|
1035
953
|
throw new Error(`invalid authentication code: ${authenticationCode}`);
|
|
1036
954
|
}
|
|
@@ -1040,7 +958,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1040
958
|
guest: credentials.deviceKey
|
|
1041
959
|
}, {
|
|
1042
960
|
file: "device-invitations-handler.ts",
|
|
1043
|
-
line:
|
|
961
|
+
line: 121,
|
|
1044
962
|
scope: this,
|
|
1045
963
|
callSite: (f, a) => f(...a)
|
|
1046
964
|
});
|
|
@@ -1052,14 +970,14 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1052
970
|
}
|
|
1053
971
|
},
|
|
1054
972
|
onOpen: () => {
|
|
1055
|
-
(0,
|
|
973
|
+
(0, import_async6.scheduleTask)(ctx, async () => {
|
|
1056
974
|
var _a, _b;
|
|
1057
975
|
try {
|
|
1058
976
|
(0, import_log4.log)("connected", {
|
|
1059
977
|
host: identity.deviceKey
|
|
1060
978
|
}, {
|
|
1061
979
|
file: "device-invitations-handler.ts",
|
|
1062
|
-
line:
|
|
980
|
+
line: 137,
|
|
1063
981
|
scope: this,
|
|
1064
982
|
callSite: (f, a) => f(...a)
|
|
1065
983
|
});
|
|
@@ -1072,7 +990,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1072
990
|
guest: deviceKey
|
|
1073
991
|
}, {
|
|
1074
992
|
file: "device-invitations-handler.ts",
|
|
1075
|
-
line:
|
|
993
|
+
line: 140,
|
|
1076
994
|
scope: this,
|
|
1077
995
|
callSite: (f, a) => f(...a)
|
|
1078
996
|
});
|
|
@@ -1081,20 +999,20 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1081
999
|
if (!observable.cancelled) {
|
|
1082
1000
|
import_log4.log.error("failed", err, {
|
|
1083
1001
|
file: "device-invitations-handler.ts",
|
|
1084
|
-
line:
|
|
1002
|
+
line: 144,
|
|
1085
1003
|
scope: this,
|
|
1086
1004
|
callSite: (f, a) => f(...a)
|
|
1087
1005
|
});
|
|
1088
1006
|
observable.callback.onError(err);
|
|
1089
1007
|
}
|
|
1090
1008
|
} finally {
|
|
1091
|
-
await (0,
|
|
1009
|
+
await (0, import_async6.sleep)(import_client.ON_CLOSE_DELAY);
|
|
1092
1010
|
await ctx.dispose();
|
|
1093
1011
|
}
|
|
1094
1012
|
});
|
|
1095
1013
|
}
|
|
1096
1014
|
});
|
|
1097
|
-
(0,
|
|
1015
|
+
(0, import_async6.scheduleTask)(ctx, async () => {
|
|
1098
1016
|
var _a, _b;
|
|
1099
1017
|
const topic = invitation.swarmKey;
|
|
1100
1018
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
@@ -1116,15 +1034,15 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1116
1034
|
* which then writes the guest's credentials to the halo.
|
|
1117
1035
|
*/
|
|
1118
1036
|
acceptInvitation(invitation, options) {
|
|
1119
|
-
const { timeout = INVITATION_TIMEOUT } = options != null ? options : {};
|
|
1037
|
+
const { timeout = import_client.INVITATION_TIMEOUT } = options != null ? options : {};
|
|
1120
1038
|
const ctx = new import_context3.Context({
|
|
1121
1039
|
onError: (err) => {
|
|
1122
1040
|
void ctx.dispose();
|
|
1123
1041
|
observable.callback.onError(err);
|
|
1124
1042
|
}
|
|
1125
1043
|
});
|
|
1126
|
-
const authenticated = new
|
|
1127
|
-
const observable = new AuthenticatingInvitationProvider({
|
|
1044
|
+
const authenticated = new import_async6.Trigger();
|
|
1045
|
+
const observable = new import_client.AuthenticatingInvitationProvider({
|
|
1128
1046
|
onCancel: async () => {
|
|
1129
1047
|
await ctx.dispose();
|
|
1130
1048
|
},
|
|
@@ -1134,11 +1052,11 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1134
1052
|
}
|
|
1135
1053
|
});
|
|
1136
1054
|
let connectionCount = 0;
|
|
1137
|
-
const complete = new
|
|
1055
|
+
const complete = new import_async6.Trigger();
|
|
1138
1056
|
const createExtension = () => {
|
|
1139
1057
|
const extension = new GuestHaloInvitationExtension({
|
|
1140
1058
|
onOpen: () => {
|
|
1141
|
-
(0,
|
|
1059
|
+
(0, import_async6.scheduleTask)(ctx, async () => {
|
|
1142
1060
|
var _a, _b, _c, _d;
|
|
1143
1061
|
try {
|
|
1144
1062
|
if (++connectionCount > 1) {
|
|
@@ -1146,22 +1064,22 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1146
1064
|
}
|
|
1147
1065
|
(0, import_log4.log)("connected", {}, {
|
|
1148
1066
|
file: "device-invitations-handler.ts",
|
|
1149
|
-
line:
|
|
1067
|
+
line: 215,
|
|
1150
1068
|
scope: this,
|
|
1151
1069
|
callSite: (f, a) => f(...a)
|
|
1152
1070
|
});
|
|
1153
1071
|
(_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
|
|
1154
1072
|
(0, import_log4.log)("sending admission request", {}, {
|
|
1155
1073
|
file: "device-invitations-handler.ts",
|
|
1156
|
-
line:
|
|
1074
|
+
line: 219,
|
|
1157
1075
|
scope: this,
|
|
1158
1076
|
callSite: (f, a) => f(...a)
|
|
1159
1077
|
});
|
|
1160
1078
|
const { identityKey, haloSpaceKey, genesisFeedKey } = await extension.rpc.HaloHostService.requestAdmission();
|
|
1161
|
-
if (invitation.type === void 0 || invitation.type ===
|
|
1079
|
+
if (invitation.type === void 0 || invitation.type === import_services.Invitation.Type.INTERACTIVE) {
|
|
1162
1080
|
(0, import_log4.log)("guest waiting for authentication code...", {}, {
|
|
1163
1081
|
file: "device-invitations-handler.ts",
|
|
1164
|
-
line:
|
|
1082
|
+
line: 226,
|
|
1165
1083
|
scope: this,
|
|
1166
1084
|
callSite: (f, a) => f(...a)
|
|
1167
1085
|
});
|
|
@@ -1171,7 +1089,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1171
1089
|
});
|
|
1172
1090
|
(0, import_log4.log)("sending authentication request", {}, {
|
|
1173
1091
|
file: "device-invitations-handler.ts",
|
|
1174
|
-
line:
|
|
1092
|
+
line: 229,
|
|
1175
1093
|
scope: this,
|
|
1176
1094
|
callSite: (f, a) => f(...a)
|
|
1177
1095
|
});
|
|
@@ -1189,7 +1107,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1189
1107
|
dataFeedKey
|
|
1190
1108
|
}, {
|
|
1191
1109
|
file: "device-invitations-handler.ts",
|
|
1192
|
-
line:
|
|
1110
|
+
line: 238,
|
|
1193
1111
|
scope: this,
|
|
1194
1112
|
callSite: (f, a) => f(...a)
|
|
1195
1113
|
});
|
|
@@ -1211,7 +1129,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1211
1129
|
identityKey
|
|
1212
1130
|
}, {
|
|
1213
1131
|
file: "device-invitations-handler.ts",
|
|
1214
|
-
line:
|
|
1132
|
+
line: 257,
|
|
1215
1133
|
scope: this,
|
|
1216
1134
|
callSite: (f, a) => f(...a)
|
|
1217
1135
|
});
|
|
@@ -1220,7 +1138,7 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1220
1138
|
if (!observable.cancelled) {
|
|
1221
1139
|
import_log4.log.warn("auth failed", err, {
|
|
1222
1140
|
file: "device-invitations-handler.ts",
|
|
1223
|
-
line:
|
|
1141
|
+
line: 261,
|
|
1224
1142
|
scope: this,
|
|
1225
1143
|
callSite: (f, a) => f(...a)
|
|
1226
1144
|
});
|
|
@@ -1234,9 +1152,9 @@ var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1234
1152
|
});
|
|
1235
1153
|
return extension;
|
|
1236
1154
|
};
|
|
1237
|
-
(0,
|
|
1155
|
+
(0, import_async6.scheduleTask)(ctx, async () => {
|
|
1238
1156
|
var _a, _b;
|
|
1239
|
-
(0,
|
|
1157
|
+
(0, import_node_assert4.default)(invitation.swarmKey);
|
|
1240
1158
|
const topic = invitation.swarmKey;
|
|
1241
1159
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1242
1160
|
topic,
|
|
@@ -1259,7 +1177,7 @@ var HostHaloInvitationExtension = class extends import_teleport.RpcExtension {
|
|
|
1259
1177
|
constructor(_callbacks) {
|
|
1260
1178
|
super({
|
|
1261
1179
|
exposed: {
|
|
1262
|
-
HaloHostService:
|
|
1180
|
+
HaloHostService: import_protocols2.schema.getService("dxos.halo.invitations.HaloHostService")
|
|
1263
1181
|
}
|
|
1264
1182
|
});
|
|
1265
1183
|
this._callbacks = _callbacks;
|
|
@@ -1291,7 +1209,7 @@ var GuestHaloInvitationExtension = class extends import_teleport.RpcExtension {
|
|
|
1291
1209
|
constructor(_callbacks) {
|
|
1292
1210
|
super({
|
|
1293
1211
|
requested: {
|
|
1294
|
-
HaloHostService:
|
|
1212
|
+
HaloHostService: import_protocols2.schema.getService("dxos.halo.invitations.HaloHostService")
|
|
1295
1213
|
}
|
|
1296
1214
|
});
|
|
1297
1215
|
this._callbacks = _callbacks;
|
|
@@ -1305,152 +1223,11 @@ var GuestHaloInvitationExtension = class extends import_teleport.RpcExtension {
|
|
|
1305
1223
|
}
|
|
1306
1224
|
};
|
|
1307
1225
|
|
|
1308
|
-
// packages/sdk/client-services/src/packlets/invitations/invitations-proxy.ts
|
|
1309
|
-
var import_node_assert6 = __toESM(require("node:assert"));
|
|
1310
|
-
var import_async8 = require("@dxos/async");
|
|
1311
|
-
var import_log5 = require("@dxos/log");
|
|
1312
|
-
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1313
|
-
var AbstractInvitationsProxy = class {
|
|
1314
|
-
// prettier-ignore
|
|
1315
|
-
constructor(_invitationsService) {
|
|
1316
|
-
this._invitationsService = _invitationsService;
|
|
1317
|
-
}
|
|
1318
|
-
createInvitation(context, options) {
|
|
1319
|
-
let invitationId;
|
|
1320
|
-
const observable = new InvitationObservableProvider(async () => {
|
|
1321
|
-
if (invitationId) {
|
|
1322
|
-
await this._invitationsService.cancelInvitation({
|
|
1323
|
-
invitationId
|
|
1324
|
-
});
|
|
1325
|
-
}
|
|
1326
|
-
});
|
|
1327
|
-
const invitation = {
|
|
1328
|
-
...this.getInvitationOptions(context),
|
|
1329
|
-
...options
|
|
1330
|
-
};
|
|
1331
|
-
const stream = this._invitationsService.createInvitation(invitation);
|
|
1332
|
-
stream.subscribe((invitation2) => {
|
|
1333
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1334
|
-
observable.setInvitation(invitation2);
|
|
1335
|
-
switch (invitation2.state) {
|
|
1336
|
-
case import_services3.Invitation.State.CONNECTING: {
|
|
1337
|
-
(0, import_node_assert6.default)(invitation2.invitationId);
|
|
1338
|
-
invitationId = invitation2.invitationId;
|
|
1339
|
-
(_b = (_a = observable.callback).onConnecting) == null ? void 0 : _b.call(_a, invitation2);
|
|
1340
|
-
break;
|
|
1341
|
-
}
|
|
1342
|
-
case import_services3.Invitation.State.CONNECTED: {
|
|
1343
|
-
(_d = (_c = observable.callback).onConnected) == null ? void 0 : _d.call(_c, invitation2);
|
|
1344
|
-
break;
|
|
1345
|
-
}
|
|
1346
|
-
case import_services3.Invitation.State.AUTHENTICATING: {
|
|
1347
|
-
(_f = (_e = observable.callback).onAuthenticating) == null ? void 0 : _f.call(_e, invitation2);
|
|
1348
|
-
break;
|
|
1349
|
-
}
|
|
1350
|
-
case import_services3.Invitation.State.SUCCESS: {
|
|
1351
|
-
(_h = (_g = observable.callback).onSuccess) == null ? void 0 : _h.call(_g, invitation2);
|
|
1352
|
-
break;
|
|
1353
|
-
}
|
|
1354
|
-
case import_services3.Invitation.State.CANCELLED: {
|
|
1355
|
-
(_j = (_i = observable.callback).onCancelled) == null ? void 0 : _j.call(_i);
|
|
1356
|
-
break;
|
|
1357
|
-
}
|
|
1358
|
-
default: {
|
|
1359
|
-
import_log5.log.error(`Invalid state: ${invitation2.state}`, {}, {
|
|
1360
|
-
file: "invitations-proxy.ts",
|
|
1361
|
-
line: 81,
|
|
1362
|
-
scope: this,
|
|
1363
|
-
callSite: (f, a) => f(...a)
|
|
1364
|
-
});
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
}, (err) => {
|
|
1368
|
-
if (err) {
|
|
1369
|
-
(0, import_async8.observableError)(observable, err);
|
|
1370
|
-
}
|
|
1371
|
-
});
|
|
1372
|
-
return observable;
|
|
1373
|
-
}
|
|
1374
|
-
acceptInvitation(invitation, options) {
|
|
1375
|
-
(0, import_node_assert6.default)(invitation && invitation.swarmKey);
|
|
1376
|
-
const observable = new AuthenticatingInvitationProvider({
|
|
1377
|
-
onCancel: async () => {
|
|
1378
|
-
var _a;
|
|
1379
|
-
const invitationId = (_a = observable.invitation) == null ? void 0 : _a.invitationId;
|
|
1380
|
-
(0, import_node_assert6.default)(invitationId);
|
|
1381
|
-
await this._invitationsService.cancelInvitation({
|
|
1382
|
-
invitationId
|
|
1383
|
-
});
|
|
1384
|
-
},
|
|
1385
|
-
onAuthenticate: async (authenticationCode) => {
|
|
1386
|
-
var _a;
|
|
1387
|
-
const invitationId = (_a = observable.invitation) == null ? void 0 : _a.invitationId;
|
|
1388
|
-
(0, import_node_assert6.default)(invitationId);
|
|
1389
|
-
await this._invitationsService.authenticate({
|
|
1390
|
-
invitationId,
|
|
1391
|
-
authenticationCode
|
|
1392
|
-
});
|
|
1393
|
-
}
|
|
1394
|
-
});
|
|
1395
|
-
const stream = this._invitationsService.acceptInvitation({
|
|
1396
|
-
...invitation,
|
|
1397
|
-
...options
|
|
1398
|
-
});
|
|
1399
|
-
stream.subscribe((invitation2) => {
|
|
1400
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1401
|
-
(0, import_node_assert6.default)(invitation2.invitationId);
|
|
1402
|
-
observable.setInvitation(invitation2);
|
|
1403
|
-
switch (invitation2.state) {
|
|
1404
|
-
case import_services3.Invitation.State.CONNECTING: {
|
|
1405
|
-
(_b = (_a = observable.callback).onConnecting) == null ? void 0 : _b.call(_a, invitation2);
|
|
1406
|
-
break;
|
|
1407
|
-
}
|
|
1408
|
-
case import_services3.Invitation.State.CONNECTED: {
|
|
1409
|
-
(_d = (_c = observable.callback).onConnected) == null ? void 0 : _d.call(_c, invitation2);
|
|
1410
|
-
break;
|
|
1411
|
-
}
|
|
1412
|
-
case import_services3.Invitation.State.AUTHENTICATING: {
|
|
1413
|
-
(_f = (_e = observable.callback).onAuthenticating) == null ? void 0 : _f.call(_e, invitation2);
|
|
1414
|
-
break;
|
|
1415
|
-
}
|
|
1416
|
-
case import_services3.Invitation.State.SUCCESS: {
|
|
1417
|
-
(_h = (_g = observable.callback).onSuccess) == null ? void 0 : _h.call(_g, invitation2);
|
|
1418
|
-
break;
|
|
1419
|
-
}
|
|
1420
|
-
case import_services3.Invitation.State.CANCELLED: {
|
|
1421
|
-
(_j = (_i = observable.callback).onCancelled) == null ? void 0 : _j.call(_i);
|
|
1422
|
-
break;
|
|
1423
|
-
}
|
|
1424
|
-
default: {
|
|
1425
|
-
import_log5.log.error(`Invalid state: ${invitation2.state}`, {}, {
|
|
1426
|
-
file: "invitations-proxy.ts",
|
|
1427
|
-
line: 146,
|
|
1428
|
-
scope: this,
|
|
1429
|
-
callSite: (f, a) => f(...a)
|
|
1430
|
-
});
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
}, (err) => {
|
|
1434
|
-
if (err) {
|
|
1435
|
-
(0, import_async8.observableError)(observable, err);
|
|
1436
|
-
}
|
|
1437
|
-
});
|
|
1438
|
-
return observable;
|
|
1439
|
-
}
|
|
1440
|
-
};
|
|
1441
|
-
|
|
1442
|
-
// packages/sdk/client-services/src/packlets/invitations/device-invitations-proxy.ts
|
|
1443
|
-
var DeviceInvitationsProxy = class extends AbstractInvitationsProxy {
|
|
1444
|
-
getInvitationOptions() {
|
|
1445
|
-
return {};
|
|
1446
|
-
}
|
|
1447
|
-
};
|
|
1448
|
-
|
|
1449
1226
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1450
|
-
var
|
|
1227
|
+
var import_node_assert5 = __toESM(require("node:assert"));
|
|
1451
1228
|
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
1452
|
-
var
|
|
1453
|
-
var
|
|
1229
|
+
var import_log5 = require("@dxos/log");
|
|
1230
|
+
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1454
1231
|
var AbstractInvitationsService = class {
|
|
1455
1232
|
// prettier-ignore
|
|
1456
1233
|
constructor(_identityManager, _getInvitationsHandler) {
|
|
@@ -1470,9 +1247,9 @@ var AbstractInvitationsService = class {
|
|
|
1470
1247
|
return new import_codec_protobuf7.Stream(({ next, close }) => {
|
|
1471
1248
|
const invitationsHandler = this._getInvitationsHandler();
|
|
1472
1249
|
const context = this.getContext(invitation);
|
|
1473
|
-
(0,
|
|
1250
|
+
(0, import_log5.log)("stream opened", this.getLoggingContext(), {
|
|
1474
1251
|
file: "invitations-service.ts",
|
|
1475
|
-
line:
|
|
1252
|
+
line: 48,
|
|
1476
1253
|
scope: this,
|
|
1477
1254
|
callSite: (f, a) => f(...a)
|
|
1478
1255
|
});
|
|
@@ -1485,60 +1262,60 @@ var AbstractInvitationsService = class {
|
|
|
1485
1262
|
});
|
|
1486
1263
|
observable.subscribe({
|
|
1487
1264
|
onConnecting: (invitation2) => {
|
|
1488
|
-
(0,
|
|
1265
|
+
(0, import_node_assert5.default)(invitation2.invitationId);
|
|
1489
1266
|
invitationId = invitation2.invitationId;
|
|
1490
1267
|
this._createInvitations.set(invitation2.invitationId, observable);
|
|
1491
|
-
invitation2.state =
|
|
1268
|
+
invitation2.state = import_services2.Invitation.State.CONNECTING;
|
|
1492
1269
|
next(invitation2);
|
|
1493
1270
|
},
|
|
1494
1271
|
onConnected: (invitation2) => {
|
|
1495
|
-
(0,
|
|
1496
|
-
invitation2.state =
|
|
1272
|
+
(0, import_node_assert5.default)(invitation2.invitationId);
|
|
1273
|
+
invitation2.state = import_services2.Invitation.State.CONNECTED;
|
|
1497
1274
|
next(invitation2);
|
|
1498
1275
|
},
|
|
1499
1276
|
onAuthenticating: (invitation2) => {
|
|
1500
|
-
(0,
|
|
1501
|
-
invitation2.state =
|
|
1277
|
+
(0, import_node_assert5.default)(invitation2.invitationId);
|
|
1278
|
+
invitation2.state = import_services2.Invitation.State.AUTHENTICATING;
|
|
1502
1279
|
next(invitation2);
|
|
1503
1280
|
},
|
|
1504
1281
|
onSuccess: (invitation2) => {
|
|
1505
|
-
(0,
|
|
1506
|
-
invitation2.state =
|
|
1282
|
+
(0, import_node_assert5.default)(invitation2.invitationId);
|
|
1283
|
+
invitation2.state = import_services2.Invitation.State.SUCCESS;
|
|
1507
1284
|
next(invitation2);
|
|
1508
1285
|
close();
|
|
1509
1286
|
},
|
|
1510
1287
|
onCancelled: () => {
|
|
1511
|
-
(0,
|
|
1288
|
+
(0, import_node_assert5.default)(invitationId);
|
|
1512
1289
|
invitation.invitationId = invitationId;
|
|
1513
|
-
invitation.state =
|
|
1290
|
+
invitation.state = import_services2.Invitation.State.CANCELLED;
|
|
1514
1291
|
next(invitation);
|
|
1515
1292
|
close();
|
|
1516
1293
|
},
|
|
1517
1294
|
onTimeout: (err) => {
|
|
1518
|
-
invitation.state =
|
|
1295
|
+
invitation.state = import_services2.Invitation.State.TIMEOUT;
|
|
1519
1296
|
close(err);
|
|
1520
1297
|
},
|
|
1521
1298
|
onError: (err) => {
|
|
1522
|
-
invitation.state =
|
|
1299
|
+
invitation.state = import_services2.Invitation.State.ERROR;
|
|
1523
1300
|
close(err);
|
|
1524
1301
|
}
|
|
1525
1302
|
});
|
|
1526
1303
|
return (err) => {
|
|
1527
1304
|
const context2 = this.getLoggingContext();
|
|
1528
1305
|
if (err) {
|
|
1529
|
-
|
|
1306
|
+
import_log5.log.warn("stream closed", {
|
|
1530
1307
|
...context2,
|
|
1531
1308
|
err
|
|
1532
1309
|
}, {
|
|
1533
1310
|
file: "invitations-service.ts",
|
|
1534
|
-
line:
|
|
1311
|
+
line: 97,
|
|
1535
1312
|
scope: this,
|
|
1536
1313
|
callSite: (f, a) => f(...a)
|
|
1537
1314
|
});
|
|
1538
1315
|
} else {
|
|
1539
|
-
(0,
|
|
1316
|
+
(0, import_log5.log)("stream closed", context2, {
|
|
1540
1317
|
file: "invitations-service.ts",
|
|
1541
|
-
line:
|
|
1318
|
+
line: 99,
|
|
1542
1319
|
scope: this,
|
|
1543
1320
|
callSite: (f, a) => f(...a)
|
|
1544
1321
|
});
|
|
@@ -1549,9 +1326,9 @@ var AbstractInvitationsService = class {
|
|
|
1549
1326
|
}
|
|
1550
1327
|
acceptInvitation(invitation, options) {
|
|
1551
1328
|
return new import_codec_protobuf7.Stream(({ next, close }) => {
|
|
1552
|
-
(0,
|
|
1329
|
+
(0, import_log5.log)("stream opened", this.getLoggingContext(), {
|
|
1553
1330
|
file: "invitations-service.ts",
|
|
1554
|
-
line:
|
|
1331
|
+
line: 109,
|
|
1555
1332
|
scope: this,
|
|
1556
1333
|
callSite: (f, a) => f(...a)
|
|
1557
1334
|
});
|
|
@@ -1560,59 +1337,59 @@ var AbstractInvitationsService = class {
|
|
|
1560
1337
|
const observable = invitationsHandler.acceptInvitation(invitation, options);
|
|
1561
1338
|
observable.subscribe({
|
|
1562
1339
|
onConnecting: (invitation2) => {
|
|
1563
|
-
(0,
|
|
1340
|
+
(0, import_node_assert5.default)(invitation2.invitationId);
|
|
1564
1341
|
invitationId = invitation2.invitationId;
|
|
1565
1342
|
this._acceptInvitations.set(invitation2.invitationId, observable);
|
|
1566
|
-
invitation2.state =
|
|
1343
|
+
invitation2.state = import_services2.Invitation.State.CONNECTING;
|
|
1567
1344
|
next(invitation2);
|
|
1568
1345
|
},
|
|
1569
1346
|
onConnected: (invitation2) => {
|
|
1570
|
-
(0,
|
|
1571
|
-
invitation2.state =
|
|
1347
|
+
(0, import_node_assert5.default)(invitation2.invitationId);
|
|
1348
|
+
invitation2.state = import_services2.Invitation.State.CONNECTED;
|
|
1572
1349
|
next(invitation2);
|
|
1573
1350
|
},
|
|
1574
1351
|
onAuthenticating: (invitation2) => {
|
|
1575
|
-
(0,
|
|
1576
|
-
invitation2.state =
|
|
1352
|
+
(0, import_node_assert5.default)(invitation2.invitationId);
|
|
1353
|
+
invitation2.state = import_services2.Invitation.State.AUTHENTICATING;
|
|
1577
1354
|
next(invitation2);
|
|
1578
1355
|
},
|
|
1579
1356
|
onSuccess: (invitation2) => {
|
|
1580
|
-
invitation2.state =
|
|
1357
|
+
invitation2.state = import_services2.Invitation.State.SUCCESS;
|
|
1581
1358
|
next(invitation2);
|
|
1582
1359
|
close();
|
|
1583
1360
|
},
|
|
1584
1361
|
onCancelled: () => {
|
|
1585
|
-
(0,
|
|
1362
|
+
(0, import_node_assert5.default)(invitationId);
|
|
1586
1363
|
invitation.invitationId = invitationId;
|
|
1587
|
-
invitation.state =
|
|
1364
|
+
invitation.state = import_services2.Invitation.State.CANCELLED;
|
|
1588
1365
|
next(invitation);
|
|
1589
1366
|
close();
|
|
1590
1367
|
},
|
|
1591
1368
|
onTimeout: (err) => {
|
|
1592
|
-
invitation.state =
|
|
1369
|
+
invitation.state = import_services2.Invitation.State.TIMEOUT;
|
|
1593
1370
|
close(err);
|
|
1594
1371
|
},
|
|
1595
1372
|
onError: (err) => {
|
|
1596
|
-
invitation.state =
|
|
1373
|
+
invitation.state = import_services2.Invitation.State.ERROR;
|
|
1597
1374
|
close(err);
|
|
1598
1375
|
}
|
|
1599
1376
|
});
|
|
1600
1377
|
return (err) => {
|
|
1601
1378
|
const context = this.getLoggingContext();
|
|
1602
1379
|
if (err) {
|
|
1603
|
-
|
|
1380
|
+
import_log5.log.warn("stream closed", {
|
|
1604
1381
|
...context,
|
|
1605
1382
|
err
|
|
1606
1383
|
}, {
|
|
1607
1384
|
file: "invitations-service.ts",
|
|
1608
|
-
line:
|
|
1385
|
+
line: 157,
|
|
1609
1386
|
scope: this,
|
|
1610
1387
|
callSite: (f, a) => f(...a)
|
|
1611
1388
|
});
|
|
1612
1389
|
} else {
|
|
1613
|
-
(0,
|
|
1390
|
+
(0, import_log5.log)("stream closed", context, {
|
|
1614
1391
|
file: "invitations-service.ts",
|
|
1615
|
-
line:
|
|
1392
|
+
line: 159,
|
|
1616
1393
|
scope: this,
|
|
1617
1394
|
callSite: (f, a) => f(...a)
|
|
1618
1395
|
});
|
|
@@ -1622,20 +1399,20 @@ var AbstractInvitationsService = class {
|
|
|
1622
1399
|
});
|
|
1623
1400
|
}
|
|
1624
1401
|
async authenticate({ invitationId, authenticationCode }) {
|
|
1625
|
-
(0,
|
|
1402
|
+
(0, import_log5.log)("authenticating...", {}, {
|
|
1626
1403
|
file: "invitations-service.ts",
|
|
1627
|
-
line:
|
|
1404
|
+
line: 168,
|
|
1628
1405
|
scope: this,
|
|
1629
1406
|
callSite: (f, a) => f(...a)
|
|
1630
1407
|
});
|
|
1631
|
-
(0,
|
|
1408
|
+
(0, import_node_assert5.default)(invitationId);
|
|
1632
1409
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1633
1410
|
if (!observable) {
|
|
1634
|
-
|
|
1411
|
+
import_log5.log.warn("invalid invitation", {
|
|
1635
1412
|
invitationId
|
|
1636
1413
|
}, {
|
|
1637
1414
|
file: "invitations-service.ts",
|
|
1638
|
-
line:
|
|
1415
|
+
line: 172,
|
|
1639
1416
|
scope: this,
|
|
1640
1417
|
callSite: (f, a) => f(...a)
|
|
1641
1418
|
});
|
|
@@ -1645,20 +1422,20 @@ var AbstractInvitationsService = class {
|
|
|
1645
1422
|
}
|
|
1646
1423
|
async cancelInvitation(invitation) {
|
|
1647
1424
|
var _a;
|
|
1648
|
-
(0,
|
|
1425
|
+
(0, import_log5.log)("cancelling...", {}, {
|
|
1649
1426
|
file: "invitations-service.ts",
|
|
1650
|
-
line:
|
|
1427
|
+
line: 179,
|
|
1651
1428
|
scope: this,
|
|
1652
1429
|
callSite: (f, a) => f(...a)
|
|
1653
1430
|
});
|
|
1654
|
-
(0,
|
|
1431
|
+
(0, import_node_assert5.default)(invitation.invitationId);
|
|
1655
1432
|
const observable = (_a = this._createInvitations.get(invitation.invitationId)) != null ? _a : this._acceptInvitations.get(invitation.invitationId);
|
|
1656
1433
|
if (!observable) {
|
|
1657
|
-
|
|
1434
|
+
import_log5.log.warn("invalid invitation", {
|
|
1658
1435
|
invitationId: invitation.invitationId
|
|
1659
1436
|
}, {
|
|
1660
1437
|
file: "invitations-service.ts",
|
|
1661
|
-
line:
|
|
1438
|
+
line: 184,
|
|
1662
1439
|
scope: this,
|
|
1663
1440
|
callSite: (f, a) => f(...a)
|
|
1664
1441
|
});
|
|
@@ -1680,20 +1457,21 @@ var DeviceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
1680
1457
|
};
|
|
1681
1458
|
|
|
1682
1459
|
// packages/sdk/client-services/src/packlets/invitations/space-invitations-handler.ts
|
|
1683
|
-
var
|
|
1684
|
-
var
|
|
1460
|
+
var import_node_assert6 = __toESM(require("node:assert"));
|
|
1461
|
+
var import_async7 = require("@dxos/async");
|
|
1462
|
+
var import_client2 = require("@dxos/client");
|
|
1685
1463
|
var import_context4 = require("@dxos/context");
|
|
1686
1464
|
var import_credentials8 = require("@dxos/credentials");
|
|
1687
1465
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
1688
1466
|
var import_keys5 = require("@dxos/keys");
|
|
1689
|
-
var
|
|
1467
|
+
var import_log6 = require("@dxos/log");
|
|
1690
1468
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
1691
|
-
var
|
|
1692
|
-
var
|
|
1693
|
-
var
|
|
1469
|
+
var import_protocols3 = require("@dxos/protocols");
|
|
1470
|
+
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1471
|
+
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
1694
1472
|
var import_teleport2 = require("@dxos/teleport");
|
|
1695
1473
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1696
|
-
var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
1474
|
+
var SpaceInvitationsHandler = class extends import_client2.AbstractInvitationsHandler {
|
|
1697
1475
|
constructor(networkManager, _spaceManager, _signingContext, _keyring) {
|
|
1698
1476
|
super(networkManager);
|
|
1699
1477
|
this._spaceManager = _spaceManager;
|
|
@@ -1706,16 +1484,16 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1706
1484
|
createInvitation(space, options) {
|
|
1707
1485
|
var _a;
|
|
1708
1486
|
let swarmConnection;
|
|
1709
|
-
const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
|
|
1710
|
-
(0,
|
|
1711
|
-
(0,
|
|
1487
|
+
const { type, timeout = import_client2.INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
|
|
1488
|
+
(0, import_node_assert6.default)(type !== import_services3.Invitation.Type.OFFLINE);
|
|
1489
|
+
(0, import_node_assert6.default)(space);
|
|
1712
1490
|
const invitation = {
|
|
1713
1491
|
type,
|
|
1714
1492
|
invitationId: import_keys5.PublicKey.random().toHex(),
|
|
1715
1493
|
swarmKey: swarmKey != null ? swarmKey : import_keys5.PublicKey.random(),
|
|
1716
1494
|
spaceKey: space.key,
|
|
1717
|
-
authMethod: (_a = options == null ? void 0 : options.authMethod) != null ? _a :
|
|
1718
|
-
authenticationCode: (0, import_credentials8.generatePasscode)(AUTHENTICATION_CODE_LENGTH)
|
|
1495
|
+
authMethod: (_a = options == null ? void 0 : options.authMethod) != null ? _a : import_invitations2.AuthMethod.SHARED_SECRET,
|
|
1496
|
+
authenticationCode: (0, import_credentials8.generatePasscode)(import_client2.AUTHENTICATION_CODE_LENGTH)
|
|
1719
1497
|
// TODO(dmaretskyi): Don't generate if authMethod === NONE .
|
|
1720
1498
|
};
|
|
1721
1499
|
const ctx = new import_context4.Context({
|
|
@@ -1724,18 +1502,18 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1724
1502
|
observable.callback.onError(err);
|
|
1725
1503
|
}
|
|
1726
1504
|
});
|
|
1727
|
-
const observable = new InvitationObservableProvider(async () => {
|
|
1505
|
+
const observable = new import_client2.InvitationObservableProvider(async () => {
|
|
1728
1506
|
await (swarmConnection == null ? void 0 : swarmConnection.close());
|
|
1729
1507
|
});
|
|
1730
1508
|
let authenticationPassed = false;
|
|
1731
1509
|
let authenticationRetry = 0;
|
|
1732
1510
|
const createExtension = () => {
|
|
1733
|
-
const complete = new
|
|
1511
|
+
const complete = new import_async7.Trigger();
|
|
1734
1512
|
let guestProfile;
|
|
1735
1513
|
const hostInvitationExtension = new HostSpaceInvitationExtension({
|
|
1736
1514
|
introduce: async ({ profile }) => {
|
|
1737
1515
|
var _a2, _b;
|
|
1738
|
-
(0,
|
|
1516
|
+
(0, import_log6.log)("guest introduced itself", {
|
|
1739
1517
|
guestProfile: profile,
|
|
1740
1518
|
host: this._signingContext.deviceKey,
|
|
1741
1519
|
spaceKey: space.key
|
|
@@ -1748,12 +1526,12 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1748
1526
|
guestProfile = profile;
|
|
1749
1527
|
(_b = (_a2 = observable.callback).onAuthenticating) == null ? void 0 : _b.call(_a2, invitation);
|
|
1750
1528
|
return {
|
|
1751
|
-
spaceKey: type ===
|
|
1529
|
+
spaceKey: type === import_services3.Invitation.Type.INTERACTIVE_TESTING || type === import_services3.Invitation.Type.MULTIUSE_TESTING ? space.key : void 0,
|
|
1752
1530
|
authMethod: invitation.authMethod
|
|
1753
1531
|
};
|
|
1754
1532
|
},
|
|
1755
1533
|
authenticate: async ({ authenticationCode: code }) => {
|
|
1756
|
-
(0,
|
|
1534
|
+
(0, import_log6.log)("received authentication request", {
|
|
1757
1535
|
authenticationCode: code
|
|
1758
1536
|
}, {
|
|
1759
1537
|
file: "space-invitations-handler.ts",
|
|
@@ -1761,25 +1539,25 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1761
1539
|
scope: this,
|
|
1762
1540
|
callSite: (f, a) => f(...a)
|
|
1763
1541
|
});
|
|
1764
|
-
let status =
|
|
1542
|
+
let status = import_invitations2.AuthenticationResponse.Status.OK;
|
|
1765
1543
|
switch (invitation.authMethod) {
|
|
1766
|
-
case
|
|
1767
|
-
(0,
|
|
1544
|
+
case import_invitations2.AuthMethod.NONE: {
|
|
1545
|
+
(0, import_log6.log)("authentication not required", {}, {
|
|
1768
1546
|
file: "space-invitations-handler.ts",
|
|
1769
1547
|
line: 128,
|
|
1770
1548
|
scope: this,
|
|
1771
1549
|
callSite: (f, a) => f(...a)
|
|
1772
1550
|
});
|
|
1773
1551
|
return {
|
|
1774
|
-
status:
|
|
1552
|
+
status: import_invitations2.AuthenticationResponse.Status.OK
|
|
1775
1553
|
};
|
|
1776
1554
|
}
|
|
1777
|
-
case
|
|
1555
|
+
case import_invitations2.AuthMethod.SHARED_SECRET: {
|
|
1778
1556
|
if (invitation.authenticationCode) {
|
|
1779
1557
|
if (authenticationRetry++ > MAX_OTP_ATTEMPTS) {
|
|
1780
|
-
status =
|
|
1558
|
+
status = import_invitations2.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
|
|
1781
1559
|
} else if (code !== invitation.authenticationCode) {
|
|
1782
|
-
status =
|
|
1560
|
+
status = import_invitations2.AuthenticationResponse.Status.INVALID_OTP;
|
|
1783
1561
|
} else {
|
|
1784
1562
|
authenticationPassed = true;
|
|
1785
1563
|
}
|
|
@@ -1787,7 +1565,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1787
1565
|
break;
|
|
1788
1566
|
}
|
|
1789
1567
|
default: {
|
|
1790
|
-
|
|
1568
|
+
import_log6.log.error("invalid authentication method", {
|
|
1791
1569
|
authMethod: invitation.authMethod
|
|
1792
1570
|
}, {
|
|
1793
1571
|
file: "space-invitations-handler.ts",
|
|
@@ -1795,7 +1573,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1795
1573
|
scope: this,
|
|
1796
1574
|
callSite: (f, a) => f(...a)
|
|
1797
1575
|
});
|
|
1798
|
-
status =
|
|
1576
|
+
status = import_invitations2.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1799
1577
|
break;
|
|
1800
1578
|
}
|
|
1801
1579
|
}
|
|
@@ -1808,7 +1586,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1808
1586
|
if (isAuthenticationRequired(invitation) && !authenticationPassed) {
|
|
1809
1587
|
throw new Error("Not authenticated");
|
|
1810
1588
|
}
|
|
1811
|
-
(0,
|
|
1589
|
+
(0, import_log6.log)("writing guest credentials", {
|
|
1812
1590
|
host: this._signingContext.deviceKey,
|
|
1813
1591
|
guest: deviceKey
|
|
1814
1592
|
}, {
|
|
@@ -1818,9 +1596,9 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1818
1596
|
callSite: (f, a) => f(...a)
|
|
1819
1597
|
});
|
|
1820
1598
|
const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
1821
|
-
(0,
|
|
1599
|
+
(0, import_node_assert6.default)(credentials[0].credential);
|
|
1822
1600
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1823
|
-
(0,
|
|
1601
|
+
(0, import_node_assert6.default)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
1824
1602
|
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
1825
1603
|
complete.wake(deviceKey);
|
|
1826
1604
|
return {
|
|
@@ -1832,10 +1610,10 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1832
1610
|
}
|
|
1833
1611
|
},
|
|
1834
1612
|
onOpen: () => {
|
|
1835
|
-
(0,
|
|
1613
|
+
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1836
1614
|
var _a2, _b;
|
|
1837
1615
|
try {
|
|
1838
|
-
(0,
|
|
1616
|
+
(0, import_log6.log)("connected", {
|
|
1839
1617
|
host: this._signingContext.deviceKey
|
|
1840
1618
|
}, {
|
|
1841
1619
|
file: "space-invitations-handler.ts",
|
|
@@ -1847,7 +1625,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1847
1625
|
const deviceKey = await complete.wait({
|
|
1848
1626
|
timeout
|
|
1849
1627
|
});
|
|
1850
|
-
(0,
|
|
1628
|
+
(0, import_log6.log)("admitted guest", {
|
|
1851
1629
|
host: this._signingContext.deviceKey,
|
|
1852
1630
|
guest: deviceKey
|
|
1853
1631
|
}, {
|
|
@@ -1859,7 +1637,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1859
1637
|
observable.callback.onSuccess(invitation);
|
|
1860
1638
|
} catch (err) {
|
|
1861
1639
|
if (!observable.cancelled) {
|
|
1862
|
-
|
|
1640
|
+
import_log6.log.error("failed", err, {
|
|
1863
1641
|
file: "space-invitations-handler.ts",
|
|
1864
1642
|
line: 198,
|
|
1865
1643
|
scope: this,
|
|
@@ -1868,8 +1646,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1868
1646
|
observable.callback.onError(err);
|
|
1869
1647
|
}
|
|
1870
1648
|
} finally {
|
|
1871
|
-
if (type !==
|
|
1872
|
-
await (0,
|
|
1649
|
+
if (type !== import_services3.Invitation.Type.MULTIUSE_TESTING) {
|
|
1650
|
+
await (0, import_async7.sleep)(import_client2.ON_CLOSE_DELAY);
|
|
1873
1651
|
await ctx.dispose();
|
|
1874
1652
|
}
|
|
1875
1653
|
}
|
|
@@ -1878,7 +1656,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1878
1656
|
});
|
|
1879
1657
|
return hostInvitationExtension;
|
|
1880
1658
|
};
|
|
1881
|
-
(0,
|
|
1659
|
+
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1882
1660
|
var _a2, _b;
|
|
1883
1661
|
const topic = invitation.swarmKey;
|
|
1884
1662
|
const swarmConnection2 = await this._networkManager.joinSwarm({
|
|
@@ -1900,15 +1678,15 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1900
1678
|
* which then writes the guest's credentials to the space.
|
|
1901
1679
|
*/
|
|
1902
1680
|
acceptInvitation(invitation, options) {
|
|
1903
|
-
const { timeout = INVITATION_TIMEOUT } = options != null ? options : {};
|
|
1681
|
+
const { timeout = import_client2.INVITATION_TIMEOUT } = options != null ? options : {};
|
|
1904
1682
|
const ctx = new import_context4.Context({
|
|
1905
1683
|
onError: (err) => {
|
|
1906
1684
|
void ctx.dispose();
|
|
1907
1685
|
observable.callback.onError(err);
|
|
1908
1686
|
}
|
|
1909
1687
|
});
|
|
1910
|
-
const authenticated = new
|
|
1911
|
-
const observable = new AuthenticatingInvitationProvider({
|
|
1688
|
+
const authenticated = new import_async7.Trigger();
|
|
1689
|
+
const observable = new import_client2.AuthenticatingInvitationProvider({
|
|
1912
1690
|
onCancel: async () => {
|
|
1913
1691
|
await ctx.dispose();
|
|
1914
1692
|
},
|
|
@@ -1917,17 +1695,17 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1917
1695
|
}
|
|
1918
1696
|
});
|
|
1919
1697
|
let connectionCount = 0;
|
|
1920
|
-
const complete = new
|
|
1698
|
+
const complete = new import_async7.Trigger();
|
|
1921
1699
|
const createExtension = () => {
|
|
1922
1700
|
const extension = new GuestSpaceInvitationExtension({
|
|
1923
1701
|
onOpen: () => {
|
|
1924
|
-
(0,
|
|
1702
|
+
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1925
1703
|
var _a, _b, _c, _d, _e, _f;
|
|
1926
1704
|
try {
|
|
1927
1705
|
if (++connectionCount > 1) {
|
|
1928
1706
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
1929
1707
|
}
|
|
1930
|
-
(0,
|
|
1708
|
+
(0, import_log6.log)("connected", {
|
|
1931
1709
|
guest: this._signingContext.deviceKey
|
|
1932
1710
|
}, {
|
|
1933
1711
|
file: "space-invitations-handler.ts",
|
|
@@ -1936,7 +1714,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1936
1714
|
callSite: (f, a) => f(...a)
|
|
1937
1715
|
});
|
|
1938
1716
|
(_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
|
|
1939
|
-
(0,
|
|
1717
|
+
(0, import_log6.log)("introduce", {
|
|
1940
1718
|
guest: this._signingContext.deviceKey
|
|
1941
1719
|
}, {
|
|
1942
1720
|
file: "space-invitations-handler.ts",
|
|
@@ -1947,7 +1725,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1947
1725
|
const introductionResponse = await extension.rpc.SpaceHostService.introduce({
|
|
1948
1726
|
profile: this._signingContext.profile
|
|
1949
1727
|
});
|
|
1950
|
-
(0,
|
|
1728
|
+
(0, import_log6.log)("introduce response", {
|
|
1951
1729
|
guest: this._signingContext.deviceKey,
|
|
1952
1730
|
response: introductionResponse
|
|
1953
1731
|
}, {
|
|
@@ -1963,7 +1741,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1963
1741
|
if (isAuthenticationRequired(invitation)) {
|
|
1964
1742
|
(_d = (_c = observable.callback).onAuthenticating) == null ? void 0 : _d.call(_c, invitation);
|
|
1965
1743
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1966
|
-
(0,
|
|
1744
|
+
(0, import_log6.log)("guest waiting for authentication code...", {}, {
|
|
1967
1745
|
file: "space-invitations-handler.ts",
|
|
1968
1746
|
line: 293,
|
|
1969
1747
|
scope: this,
|
|
@@ -1973,7 +1751,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1973
1751
|
const authenticationCode = await authenticated.wait({
|
|
1974
1752
|
timeout
|
|
1975
1753
|
});
|
|
1976
|
-
(0,
|
|
1754
|
+
(0, import_log6.log)("sending authentication request", {}, {
|
|
1977
1755
|
file: "space-invitations-handler.ts",
|
|
1978
1756
|
line: 297,
|
|
1979
1757
|
scope: this,
|
|
@@ -1982,14 +1760,14 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1982
1760
|
const response = await extension.rpc.SpaceHostService.authenticate({
|
|
1983
1761
|
authenticationCode
|
|
1984
1762
|
});
|
|
1985
|
-
if (response.status === void 0 || response.status ===
|
|
1763
|
+
if (response.status === void 0 || response.status === import_invitations2.AuthenticationResponse.Status.OK) {
|
|
1986
1764
|
break;
|
|
1987
1765
|
}
|
|
1988
|
-
if (response.status ===
|
|
1766
|
+
if (response.status === import_invitations2.AuthenticationResponse.Status.INVALID_OTP) {
|
|
1989
1767
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
1990
1768
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
1991
1769
|
} else {
|
|
1992
|
-
(0,
|
|
1770
|
+
(0, import_log6.log)("retrying invalid code", {
|
|
1993
1771
|
attempt
|
|
1994
1772
|
}, {
|
|
1995
1773
|
file: "space-invitations-handler.ts",
|
|
@@ -2004,7 +1782,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2004
1782
|
}
|
|
2005
1783
|
const controlFeedKey = await this._keyring.createKey();
|
|
2006
1784
|
const dataFeedKey = await this._keyring.createKey();
|
|
2007
|
-
(0,
|
|
1785
|
+
(0, import_log6.log)("request admission", {
|
|
2008
1786
|
guest: this._signingContext.deviceKey
|
|
2009
1787
|
}, {
|
|
2010
1788
|
file: "space-invitations-handler.ts",
|
|
@@ -2019,14 +1797,14 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2019
1797
|
dataFeedKey
|
|
2020
1798
|
});
|
|
2021
1799
|
const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
|
|
2022
|
-
(0,
|
|
2023
|
-
(0,
|
|
1800
|
+
(0, import_node_assert6.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
1801
|
+
(0, import_node_assert6.default)(credential.subject.id.equals(this._signingContext.identityKey));
|
|
2024
1802
|
const space = await this._spaceManager.acceptSpace({
|
|
2025
1803
|
spaceKey: assertion.spaceKey,
|
|
2026
1804
|
genesisFeedKey: assertion.genesisFeedKey
|
|
2027
1805
|
});
|
|
2028
1806
|
await this._signingContext.recordCredential(credential);
|
|
2029
|
-
(0,
|
|
1807
|
+
(0, import_log6.log)("admitted by host", {
|
|
2030
1808
|
guest: this._signingContext.deviceKey,
|
|
2031
1809
|
spaceKey: space.key
|
|
2032
1810
|
}, {
|
|
@@ -2038,7 +1816,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2038
1816
|
complete.wake();
|
|
2039
1817
|
} catch (err) {
|
|
2040
1818
|
if (!observable.cancelled) {
|
|
2041
|
-
|
|
1819
|
+
import_log6.log.warn("auth failed", err, {
|
|
2042
1820
|
file: "space-invitations-handler.ts",
|
|
2043
1821
|
line: 344,
|
|
2044
1822
|
scope: this,
|
|
@@ -2054,9 +1832,9 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2054
1832
|
});
|
|
2055
1833
|
return extension;
|
|
2056
1834
|
};
|
|
2057
|
-
(0,
|
|
1835
|
+
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
2058
1836
|
var _a, _b;
|
|
2059
|
-
(0,
|
|
1837
|
+
(0, import_node_assert6.default)(invitation.swarmKey);
|
|
2060
1838
|
const topic = invitation.swarmKey;
|
|
2061
1839
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
2062
1840
|
topic,
|
|
@@ -2075,12 +1853,12 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2075
1853
|
return observable;
|
|
2076
1854
|
}
|
|
2077
1855
|
};
|
|
2078
|
-
var isAuthenticationRequired = (invitation) => invitation.authMethod !==
|
|
1856
|
+
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_invitations2.AuthMethod.NONE && invitation.type !== import_services3.Invitation.Type.INTERACTIVE_TESTING && invitation.type !== import_services3.Invitation.Type.MULTIUSE_TESTING;
|
|
2079
1857
|
var HostSpaceInvitationExtension = class extends import_teleport2.RpcExtension {
|
|
2080
1858
|
constructor(_callbacks) {
|
|
2081
1859
|
super({
|
|
2082
1860
|
exposed: {
|
|
2083
|
-
SpaceHostService:
|
|
1861
|
+
SpaceHostService: import_protocols3.schema.getService("dxos.halo.invitations.SpaceHostService")
|
|
2084
1862
|
}
|
|
2085
1863
|
});
|
|
2086
1864
|
this._callbacks = _callbacks;
|
|
@@ -2111,7 +1889,7 @@ var GuestSpaceInvitationExtension = class extends import_teleport2.RpcExtension
|
|
|
2111
1889
|
constructor(_callbacks) {
|
|
2112
1890
|
super({
|
|
2113
1891
|
requested: {
|
|
2114
|
-
SpaceHostService:
|
|
1892
|
+
SpaceHostService: import_protocols3.schema.getService("dxos.halo.invitations.SpaceHostService")
|
|
2115
1893
|
}
|
|
2116
1894
|
});
|
|
2117
1895
|
this._callbacks = _callbacks;
|
|
@@ -2125,17 +1903,8 @@ var GuestSpaceInvitationExtension = class extends import_teleport2.RpcExtension
|
|
|
2125
1903
|
}
|
|
2126
1904
|
};
|
|
2127
1905
|
|
|
2128
|
-
// packages/sdk/client-services/src/packlets/invitations/space-invitations-proxy.ts
|
|
2129
|
-
var SpaceInvitationsProxy = class extends AbstractInvitationsProxy {
|
|
2130
|
-
getInvitationOptions(context) {
|
|
2131
|
-
return {
|
|
2132
|
-
spaceKey: context
|
|
2133
|
-
};
|
|
2134
|
-
}
|
|
2135
|
-
};
|
|
2136
|
-
|
|
2137
1906
|
// packages/sdk/client-services/src/packlets/invitations/space-invitations-service.ts
|
|
2138
|
-
var
|
|
1907
|
+
var import_node_assert7 = __toESM(require("node:assert"));
|
|
2139
1908
|
var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
2140
1909
|
// prettier-ignore
|
|
2141
1910
|
constructor(identityManager, invitationsHandler, _getSpaceManager) {
|
|
@@ -2144,36 +1913,118 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
2144
1913
|
this._getSpaceManager = _getSpaceManager;
|
|
2145
1914
|
}
|
|
2146
1915
|
getContext(invitation) {
|
|
2147
|
-
(0,
|
|
1916
|
+
(0, import_node_assert7.default)(invitation.spaceKey);
|
|
2148
1917
|
const spaceManager = this._getSpaceManager();
|
|
2149
1918
|
const space = spaceManager.spaces.get(invitation.spaceKey);
|
|
2150
|
-
(0,
|
|
1919
|
+
(0, import_node_assert7.default)(space);
|
|
2151
1920
|
return space;
|
|
2152
1921
|
}
|
|
2153
1922
|
};
|
|
2154
1923
|
|
|
2155
|
-
// packages/sdk/client-services/src/packlets/services/service-
|
|
2156
|
-
var
|
|
2157
|
-
var
|
|
2158
|
-
var
|
|
2159
|
-
var
|
|
2160
|
-
var
|
|
2161
|
-
var
|
|
2162
|
-
var
|
|
1924
|
+
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
1925
|
+
var import_node_assert12 = __toESM(require("node:assert"));
|
|
1926
|
+
var import_async19 = require("@dxos/async");
|
|
1927
|
+
var import_client6 = require("@dxos/client");
|
|
1928
|
+
var import_debug7 = require("@dxos/debug");
|
|
1929
|
+
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
1930
|
+
var import_log15 = require("@dxos/log");
|
|
1931
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1932
|
+
|
|
1933
|
+
// packages/sdk/client-services/src/packlets/deprecated/tracing.ts
|
|
1934
|
+
var TracingServiceImpl = class {
|
|
1935
|
+
constructor(_config) {
|
|
1936
|
+
this._config = _config;
|
|
1937
|
+
}
|
|
1938
|
+
async setTracingOptions() {
|
|
1939
|
+
throw new Error("Tracing not available.");
|
|
1940
|
+
}
|
|
1941
|
+
subscribeToRpcTrace() {
|
|
1942
|
+
throw new Error("Tracing not available.");
|
|
1943
|
+
}
|
|
1944
|
+
};
|
|
1945
|
+
|
|
1946
|
+
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
1947
|
+
var import_async8 = require("@dxos/async");
|
|
1948
|
+
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
1949
|
+
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1950
|
+
var DevicesServiceImpl = class {
|
|
1951
|
+
constructor(_identityManager) {
|
|
1952
|
+
this._identityManager = _identityManager;
|
|
1953
|
+
}
|
|
1954
|
+
updateDevice(request) {
|
|
1955
|
+
throw new Error("Method not implemented.");
|
|
1956
|
+
}
|
|
1957
|
+
queryDevices() {
|
|
1958
|
+
return new import_codec_protobuf8.Stream(({ next }) => {
|
|
1959
|
+
const update = () => {
|
|
1960
|
+
var _a;
|
|
1961
|
+
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
1962
|
+
if (!deviceKeys) {
|
|
1963
|
+
next({
|
|
1964
|
+
devices: []
|
|
1965
|
+
});
|
|
1966
|
+
} else {
|
|
1967
|
+
next({
|
|
1968
|
+
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
1969
|
+
var _a2;
|
|
1970
|
+
return {
|
|
1971
|
+
deviceKey: key,
|
|
1972
|
+
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services4.DeviceKind.CURRENT : import_services4.DeviceKind.TRUSTED
|
|
1973
|
+
};
|
|
1974
|
+
})
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
const subscriptions = new import_async8.EventSubscriptions();
|
|
1979
|
+
subscriptions.add(this._identityManager.stateUpdate.on(() => {
|
|
1980
|
+
update();
|
|
1981
|
+
if (this._identityManager.identity) {
|
|
1982
|
+
subscriptions.add(this._identityManager.identity.stateUpdate.on(() => {
|
|
1983
|
+
update();
|
|
1984
|
+
}));
|
|
1985
|
+
}
|
|
1986
|
+
}));
|
|
1987
|
+
update();
|
|
1988
|
+
return () => subscriptions.clear();
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
|
|
1993
|
+
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
1994
|
+
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
1995
|
+
var NetworkServiceImpl = class {
|
|
1996
|
+
constructor(networkManager) {
|
|
1997
|
+
this.networkManager = networkManager;
|
|
1998
|
+
}
|
|
1999
|
+
subscribeToNetworkStatus() {
|
|
2000
|
+
return new import_codec_protobuf9.Stream(({ next }) => {
|
|
2001
|
+
const unsubscribe = this.networkManager.connectionStateChanged.on((state) => next({
|
|
2002
|
+
state
|
|
2003
|
+
}));
|
|
2004
|
+
next({
|
|
2005
|
+
state: this.networkManager.connectionState
|
|
2006
|
+
});
|
|
2007
|
+
return unsubscribe;
|
|
2008
|
+
});
|
|
2009
|
+
}
|
|
2010
|
+
async setNetworkOptions(request) {
|
|
2011
|
+
await this.networkManager.setConnectionState(request.state);
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
2163
2014
|
|
|
2164
2015
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2165
|
-
var
|
|
2166
|
-
var
|
|
2016
|
+
var import_node_assert9 = __toESM(require("node:assert"));
|
|
2017
|
+
var import_async11 = require("@dxos/async");
|
|
2167
2018
|
var import_context7 = require("@dxos/context");
|
|
2168
2019
|
var import_credentials10 = require("@dxos/credentials");
|
|
2169
2020
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
2170
2021
|
var import_keys8 = require("@dxos/keys");
|
|
2171
|
-
var
|
|
2022
|
+
var import_log8 = require("@dxos/log");
|
|
2172
2023
|
var import_teleport_extension_presence = require("@dxos/teleport-extension-presence");
|
|
2173
2024
|
var import_util5 = require("@dxos/util");
|
|
2174
2025
|
|
|
2175
2026
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2176
|
-
var
|
|
2027
|
+
var import_async10 = require("@dxos/async");
|
|
2177
2028
|
var import_context6 = require("@dxos/context");
|
|
2178
2029
|
var import_debug3 = require("@dxos/debug");
|
|
2179
2030
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
@@ -2182,12 +2033,12 @@ var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials")
|
|
|
2182
2033
|
var import_util4 = require("@dxos/util");
|
|
2183
2034
|
|
|
2184
2035
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2185
|
-
var
|
|
2186
|
-
var
|
|
2036
|
+
var import_node_assert8 = __toESM(require("node:assert"));
|
|
2037
|
+
var import_async9 = require("@dxos/async");
|
|
2187
2038
|
var import_context5 = require("@dxos/context");
|
|
2188
2039
|
var import_keys6 = require("@dxos/keys");
|
|
2189
|
-
var
|
|
2190
|
-
var
|
|
2040
|
+
var import_log7 = require("@dxos/log");
|
|
2041
|
+
var import_protocols4 = require("@dxos/protocols");
|
|
2191
2042
|
var import_teleport3 = require("@dxos/teleport");
|
|
2192
2043
|
var import_util3 = require("@dxos/util");
|
|
2193
2044
|
var RETRY_TIMEOUT = 1e3;
|
|
@@ -2195,7 +2046,7 @@ var NOTARIZE_TIMEOUT = 1e4;
|
|
|
2195
2046
|
var NotarizationPlugin = class {
|
|
2196
2047
|
constructor() {
|
|
2197
2048
|
this._ctx = new import_context5.Context();
|
|
2198
|
-
this._extensionOpened = new
|
|
2049
|
+
this._extensionOpened = new import_async9.Event();
|
|
2199
2050
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2200
2051
|
this._processedCredentials = new import_util3.ComplexSet(import_keys6.PublicKey.hash);
|
|
2201
2052
|
this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys6.PublicKey.hash);
|
|
@@ -2209,7 +2060,7 @@ var NotarizationPlugin = class {
|
|
|
2209
2060
|
* Request credentials to be notarized.
|
|
2210
2061
|
*/
|
|
2211
2062
|
async notarize(credentials) {
|
|
2212
|
-
(0,
|
|
2063
|
+
(0, import_log7.log)("notarize", {
|
|
2213
2064
|
credentials
|
|
2214
2065
|
}, {
|
|
2215
2066
|
file: "notarization-plugin.ts",
|
|
@@ -2217,11 +2068,11 @@ var NotarizationPlugin = class {
|
|
|
2217
2068
|
scope: this,
|
|
2218
2069
|
callSite: (f, a) => f(...a)
|
|
2219
2070
|
});
|
|
2220
|
-
(0,
|
|
2221
|
-
const errors = new
|
|
2071
|
+
(0, import_node_assert8.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2072
|
+
const errors = new import_async9.Trigger();
|
|
2222
2073
|
const ctx = this._ctx.derive({
|
|
2223
2074
|
onError: (err) => {
|
|
2224
|
-
|
|
2075
|
+
import_log7.log.warn("Notarization error", {
|
|
2225
2076
|
err
|
|
2226
2077
|
}, {
|
|
2227
2078
|
file: "notarization-plugin.ts",
|
|
@@ -2233,22 +2084,22 @@ var NotarizationPlugin = class {
|
|
|
2233
2084
|
errors.throw(err);
|
|
2234
2085
|
}
|
|
2235
2086
|
});
|
|
2236
|
-
(0,
|
|
2237
|
-
|
|
2087
|
+
(0, import_async9.scheduleTask)(ctx, () => {
|
|
2088
|
+
import_log7.log.warn("Notarization timeout", {}, {
|
|
2238
2089
|
file: "notarization-plugin.ts",
|
|
2239
2090
|
line: 61,
|
|
2240
2091
|
scope: this,
|
|
2241
2092
|
callSite: (f, a) => f(...a)
|
|
2242
2093
|
});
|
|
2243
2094
|
void ctx.dispose();
|
|
2244
|
-
errors.throw(new
|
|
2095
|
+
errors.throw(new import_async9.TimeoutError(NOTARIZE_TIMEOUT, "Notarization timed out"));
|
|
2245
2096
|
}, NOTARIZE_TIMEOUT);
|
|
2246
2097
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
2247
2098
|
const peersTried = /* @__PURE__ */ new Set();
|
|
2248
|
-
const notarizeTask = new
|
|
2099
|
+
const notarizeTask = new import_async9.DeferredTask(ctx, async () => {
|
|
2249
2100
|
try {
|
|
2250
2101
|
if (this._extensions.size === 0) {
|
|
2251
|
-
|
|
2102
|
+
import_log7.log.warn("No peers to notarize with", {}, {
|
|
2252
2103
|
file: "notarization-plugin.ts",
|
|
2253
2104
|
line: 76,
|
|
2254
2105
|
scope: this,
|
|
@@ -2260,7 +2111,7 @@ var NotarizationPlugin = class {
|
|
|
2260
2111
|
...this._extensions
|
|
2261
2112
|
].find((peer2) => !peersTried.has(peer2));
|
|
2262
2113
|
if (!peer) {
|
|
2263
|
-
|
|
2114
|
+
import_log7.log.warn("Exhausted all peers to notarize with", {
|
|
2264
2115
|
retryIn: RETRY_TIMEOUT
|
|
2265
2116
|
}, {
|
|
2266
2117
|
file: "notarization-plugin.ts",
|
|
@@ -2269,11 +2120,11 @@ var NotarizationPlugin = class {
|
|
|
2269
2120
|
callSite: (f, a) => f(...a)
|
|
2270
2121
|
});
|
|
2271
2122
|
peersTried.clear();
|
|
2272
|
-
(0,
|
|
2123
|
+
(0, import_async9.scheduleTask)(ctx, () => notarizeTask.schedule(), RETRY_TIMEOUT);
|
|
2273
2124
|
return;
|
|
2274
2125
|
}
|
|
2275
2126
|
peersTried.add(peer);
|
|
2276
|
-
(0,
|
|
2127
|
+
(0, import_log7.log)("try notarizing", {
|
|
2277
2128
|
peer: peer.localPeerId,
|
|
2278
2129
|
credentialId: credentials.map((credential) => credential.id)
|
|
2279
2130
|
}, {
|
|
@@ -2285,14 +2136,14 @@ var NotarizationPlugin = class {
|
|
|
2285
2136
|
await peer.rpc.NotarizationService.notarize({
|
|
2286
2137
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2287
2138
|
});
|
|
2288
|
-
(0,
|
|
2139
|
+
(0, import_log7.log)("success", {}, {
|
|
2289
2140
|
file: "notarization-plugin.ts",
|
|
2290
2141
|
line: 94,
|
|
2291
2142
|
scope: this,
|
|
2292
2143
|
callSite: (f, a) => f(...a)
|
|
2293
2144
|
});
|
|
2294
2145
|
} catch (err) {
|
|
2295
|
-
|
|
2146
|
+
import_log7.log.warn("error notarizing (recoverable)", err, {
|
|
2296
2147
|
file: "notarization-plugin.ts",
|
|
2297
2148
|
line: 96,
|
|
2298
2149
|
scope: this,
|
|
@@ -2308,7 +2159,7 @@ var NotarizationPlugin = class {
|
|
|
2308
2159
|
allNotarized,
|
|
2309
2160
|
errors.wait()
|
|
2310
2161
|
]);
|
|
2311
|
-
(0,
|
|
2162
|
+
(0, import_log7.log)("done", {}, {
|
|
2312
2163
|
file: "notarization-plugin.ts",
|
|
2313
2164
|
line: 107,
|
|
2314
2165
|
scope: this,
|
|
@@ -2331,14 +2182,14 @@ var NotarizationPlugin = class {
|
|
|
2331
2182
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2332
2183
|
}
|
|
2333
2184
|
setWriter(writer) {
|
|
2334
|
-
(0,
|
|
2185
|
+
(0, import_node_assert8.default)(!this._writer, "Writer already set.");
|
|
2335
2186
|
this._writer = writer;
|
|
2336
2187
|
}
|
|
2337
2188
|
async _waitUntilProcessed(id) {
|
|
2338
2189
|
if (this._processedCredentials.has(id)) {
|
|
2339
2190
|
return;
|
|
2340
2191
|
}
|
|
2341
|
-
await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new
|
|
2192
|
+
await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new import_async9.Trigger()).value.wait();
|
|
2342
2193
|
}
|
|
2343
2194
|
/**
|
|
2344
2195
|
* Requests from other peers to notarize credentials.
|
|
@@ -2349,7 +2200,7 @@ var NotarizationPlugin = class {
|
|
|
2349
2200
|
throw new Error("Writer not set");
|
|
2350
2201
|
}
|
|
2351
2202
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2352
|
-
(0,
|
|
2203
|
+
(0, import_node_assert8.default)(credential.id, "Credential must have an id");
|
|
2353
2204
|
if (this._processedCredentials.has(credential.id)) {
|
|
2354
2205
|
continue;
|
|
2355
2206
|
}
|
|
@@ -2359,7 +2210,7 @@ var NotarizationPlugin = class {
|
|
|
2359
2210
|
createExtension() {
|
|
2360
2211
|
const extension = new NotarizationTeleportExtension({
|
|
2361
2212
|
onOpen: async () => {
|
|
2362
|
-
(0,
|
|
2213
|
+
(0, import_log7.log)("extension opened", {
|
|
2363
2214
|
peer: extension.localPeerId
|
|
2364
2215
|
}, {
|
|
2365
2216
|
file: "notarization-plugin.ts",
|
|
@@ -2371,7 +2222,7 @@ var NotarizationPlugin = class {
|
|
|
2371
2222
|
this._extensionOpened.emit();
|
|
2372
2223
|
},
|
|
2373
2224
|
onClose: async () => {
|
|
2374
|
-
(0,
|
|
2225
|
+
(0, import_log7.log)("extension closed", {
|
|
2375
2226
|
peer: extension.localPeerId
|
|
2376
2227
|
}, {
|
|
2377
2228
|
file: "notarization-plugin.ts",
|
|
@@ -2390,10 +2241,10 @@ var NotarizationTeleportExtension = class extends import_teleport3.RpcExtension
|
|
|
2390
2241
|
constructor(_params) {
|
|
2391
2242
|
super({
|
|
2392
2243
|
requested: {
|
|
2393
|
-
NotarizationService:
|
|
2244
|
+
NotarizationService: import_protocols4.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2394
2245
|
},
|
|
2395
2246
|
exposed: {
|
|
2396
|
-
NotarizationService:
|
|
2247
|
+
NotarizationService: import_protocols4.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2397
2248
|
}
|
|
2398
2249
|
});
|
|
2399
2250
|
this._params = _params;
|
|
@@ -2546,7 +2397,7 @@ __decorate([
|
|
|
2546
2397
|
(0, import_debug3.timed)(1e4)
|
|
2547
2398
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2548
2399
|
DataSpace = __decorate([
|
|
2549
|
-
(0,
|
|
2400
|
+
(0, import_async10.trackLeaks)("open", "close")
|
|
2550
2401
|
], DataSpace);
|
|
2551
2402
|
|
|
2552
2403
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
@@ -2572,7 +2423,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2572
2423
|
this._feedStore = _feedStore;
|
|
2573
2424
|
this._snapshotStore = _snapshotStore;
|
|
2574
2425
|
this._ctx = new import_context7.Context();
|
|
2575
|
-
this.updated = new
|
|
2426
|
+
this.updated = new import_async11.Event();
|
|
2576
2427
|
this._spaces = new import_util5.ComplexMap(import_keys8.PublicKey.hash);
|
|
2577
2428
|
}
|
|
2578
2429
|
// TODO(burdon): Remove.
|
|
@@ -2581,7 +2432,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2581
2432
|
}
|
|
2582
2433
|
async open() {
|
|
2583
2434
|
await this._metadataStore.load();
|
|
2584
|
-
(0,
|
|
2435
|
+
(0, import_log8.log)("metadata loaded", {
|
|
2585
2436
|
spaces: this._metadataStore.spaces.length
|
|
2586
2437
|
}, {
|
|
2587
2438
|
file: "data-space-manager.ts",
|
|
@@ -2590,7 +2441,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2590
2441
|
callSite: (f, a) => f(...a)
|
|
2591
2442
|
});
|
|
2592
2443
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2593
|
-
(0,
|
|
2444
|
+
(0, import_log8.log)("load space", {
|
|
2594
2445
|
spaceMetadata
|
|
2595
2446
|
}, {
|
|
2596
2447
|
file: "data-space-manager.ts",
|
|
@@ -2601,7 +2452,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2601
2452
|
const space = await this._constructSpace(spaceMetadata);
|
|
2602
2453
|
await space.initializeDataPipeline();
|
|
2603
2454
|
if (spaceMetadata.dataTimeframe) {
|
|
2604
|
-
(0,
|
|
2455
|
+
(0, import_log8.log)("waiting for latest timeframe", {
|
|
2605
2456
|
spaceMetadata
|
|
2606
2457
|
}, {
|
|
2607
2458
|
file: "data-space-manager.ts",
|
|
@@ -2636,7 +2487,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2636
2487
|
controlFeedKey,
|
|
2637
2488
|
dataFeedKey
|
|
2638
2489
|
};
|
|
2639
|
-
(0,
|
|
2490
|
+
(0, import_log8.log)("creating space...", {
|
|
2640
2491
|
spaceKey
|
|
2641
2492
|
}, {
|
|
2642
2493
|
file: "data-space-manager.ts",
|
|
@@ -2648,7 +2499,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2648
2499
|
const credentials = await (0, import_echo_pipeline2.spaceGenesis)(this._keyring, this._signingContext, space.inner);
|
|
2649
2500
|
await this._metadataStore.addSpace(metadata);
|
|
2650
2501
|
const memberCredential = credentials[1];
|
|
2651
|
-
(0,
|
|
2502
|
+
(0, import_node_assert9.default)((0, import_credentials10.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2652
2503
|
await this._signingContext.recordCredential(memberCredential);
|
|
2653
2504
|
await space.initializeDataPipeline();
|
|
2654
2505
|
this._dataServiceSubscriptions.registerSpace(space.key, space.dataPipelineController.databaseBackend.createDataServiceHost());
|
|
@@ -2657,7 +2508,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2657
2508
|
}
|
|
2658
2509
|
// TODO(burdon): Rename join space.
|
|
2659
2510
|
async acceptSpace(opts) {
|
|
2660
|
-
(0,
|
|
2511
|
+
(0, import_node_assert9.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2661
2512
|
const metadata = {
|
|
2662
2513
|
key: opts.spaceKey,
|
|
2663
2514
|
genesisFeedKey: opts.genesisFeedKey
|
|
@@ -2718,327 +2569,28 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2718
2569
|
}
|
|
2719
2570
|
};
|
|
2720
2571
|
__decorate2([
|
|
2721
|
-
|
|
2572
|
+
import_async11.synchronized
|
|
2722
2573
|
], DataSpaceManager.prototype, "open", null);
|
|
2723
2574
|
__decorate2([
|
|
2724
|
-
|
|
2575
|
+
import_async11.synchronized
|
|
2725
2576
|
], DataSpaceManager.prototype, "close", null);
|
|
2726
2577
|
__decorate2([
|
|
2727
|
-
|
|
2578
|
+
import_async11.synchronized
|
|
2728
2579
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2729
2580
|
__decorate2([
|
|
2730
|
-
|
|
2581
|
+
import_async11.synchronized
|
|
2731
2582
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2732
2583
|
DataSpaceManager = __decorate2([
|
|
2733
|
-
(0,
|
|
2584
|
+
(0, import_async11.trackLeaks)("open", "close")
|
|
2734
2585
|
], DataSpaceManager);
|
|
2735
2586
|
|
|
2736
|
-
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2737
|
-
var ServiceContext = class {
|
|
2738
|
-
// prettier-ignore
|
|
2739
|
-
constructor(storage, networkManager, modelFactory) {
|
|
2740
|
-
this.storage = storage;
|
|
2741
|
-
this.networkManager = networkManager;
|
|
2742
|
-
this.modelFactory = modelFactory;
|
|
2743
|
-
this.initialized = new import_async13.Trigger();
|
|
2744
|
-
this.dataServiceSubscriptions = new import_echo_pipeline3.DataServiceSubscriptions();
|
|
2745
|
-
this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
|
|
2746
|
-
this.snapshotStore = new import_echo_pipeline3.SnapshotStore(storage.createDirectory("snapshots"));
|
|
2747
|
-
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
2748
|
-
this.feedStore = new import_feed_store4.FeedStore({
|
|
2749
|
-
factory: new import_feed_store4.FeedFactory({
|
|
2750
|
-
root: storage.createDirectory("feeds"),
|
|
2751
|
-
signer: this.keyring,
|
|
2752
|
-
hypercore: {
|
|
2753
|
-
valueEncoding: import_echo_pipeline3.valueEncoding
|
|
2754
|
-
}
|
|
2755
|
-
})
|
|
2756
|
-
});
|
|
2757
|
-
this.spaceManager = new import_echo_pipeline3.SpaceManager({
|
|
2758
|
-
feedStore: this.feedStore,
|
|
2759
|
-
networkManager: this.networkManager
|
|
2760
|
-
});
|
|
2761
|
-
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
2762
|
-
this.deviceInvitations = new DeviceInvitationsHandler({
|
|
2763
|
-
networkManager: this.networkManager,
|
|
2764
|
-
getIdentity: () => {
|
|
2765
|
-
var _a;
|
|
2766
|
-
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug4.failUndefined)();
|
|
2767
|
-
},
|
|
2768
|
-
acceptIdentity: this._acceptIdentity.bind(this),
|
|
2769
|
-
keyring: this.keyring
|
|
2770
|
-
});
|
|
2771
|
-
}
|
|
2772
|
-
async open() {
|
|
2773
|
-
(0, import_log10.log)("opening...", {}, {
|
|
2774
|
-
file: "service-context.ts",
|
|
2775
|
-
line: 94,
|
|
2776
|
-
scope: this,
|
|
2777
|
-
callSite: (f, a) => f(...a)
|
|
2778
|
-
});
|
|
2779
|
-
await this.networkManager.open();
|
|
2780
|
-
await this.spaceManager.open();
|
|
2781
|
-
await this.identityManager.open();
|
|
2782
|
-
if (this.identityManager.identity) {
|
|
2783
|
-
await this._initialize();
|
|
2784
|
-
}
|
|
2785
|
-
(0, import_log10.log)("opened", {}, {
|
|
2786
|
-
file: "service-context.ts",
|
|
2787
|
-
line: 101,
|
|
2788
|
-
scope: this,
|
|
2789
|
-
callSite: (f, a) => f(...a)
|
|
2790
|
-
});
|
|
2791
|
-
}
|
|
2792
|
-
async close() {
|
|
2793
|
-
var _a, _b;
|
|
2794
|
-
(0, import_log10.log)("closing...", {}, {
|
|
2795
|
-
file: "service-context.ts",
|
|
2796
|
-
line: 105,
|
|
2797
|
-
scope: this,
|
|
2798
|
-
callSite: (f, a) => f(...a)
|
|
2799
|
-
});
|
|
2800
|
-
await ((_a = this._deviceSpaceSync) == null ? void 0 : _a.close());
|
|
2801
|
-
await ((_b = this.dataSpaceManager) == null ? void 0 : _b.close());
|
|
2802
|
-
await this.identityManager.close();
|
|
2803
|
-
await this.spaceManager.close();
|
|
2804
|
-
await this.feedStore.close();
|
|
2805
|
-
await this.networkManager.close();
|
|
2806
|
-
this.dataServiceSubscriptions.clear();
|
|
2807
|
-
(0, import_log10.log)("closed", {}, {
|
|
2808
|
-
file: "service-context.ts",
|
|
2809
|
-
line: 113,
|
|
2810
|
-
scope: this,
|
|
2811
|
-
callSite: (f, a) => f(...a)
|
|
2812
|
-
});
|
|
2813
|
-
}
|
|
2814
|
-
async reset() {
|
|
2815
|
-
(0, import_log10.log)("resetting...", {}, {
|
|
2816
|
-
file: "service-context.ts",
|
|
2817
|
-
line: 117,
|
|
2818
|
-
scope: this,
|
|
2819
|
-
callSite: (f, a) => f(...a)
|
|
2820
|
-
});
|
|
2821
|
-
await this.close();
|
|
2822
|
-
await this.storage.reset();
|
|
2823
|
-
(0, import_log10.log)("reset", {}, {
|
|
2824
|
-
file: "service-context.ts",
|
|
2825
|
-
line: 120,
|
|
2826
|
-
scope: this,
|
|
2827
|
-
callSite: (f, a) => f(...a)
|
|
2828
|
-
});
|
|
2829
|
-
}
|
|
2830
|
-
async createIdentity(params = {}) {
|
|
2831
|
-
const identity = await this.identityManager.createIdentity(params);
|
|
2832
|
-
await this._initialize();
|
|
2833
|
-
return identity;
|
|
2834
|
-
}
|
|
2835
|
-
async _acceptIdentity(params) {
|
|
2836
|
-
const identity = await this.identityManager.acceptIdentity(params);
|
|
2837
|
-
await this._initialize();
|
|
2838
|
-
return identity;
|
|
2839
|
-
}
|
|
2840
|
-
// Called when identity is created.
|
|
2841
|
-
async _initialize() {
|
|
2842
|
-
var _a;
|
|
2843
|
-
(0, import_log10.log)("initializing spaces...", {}, {
|
|
2844
|
-
file: "service-context.ts",
|
|
2845
|
-
line: 139,
|
|
2846
|
-
scope: this,
|
|
2847
|
-
callSite: (f, a) => f(...a)
|
|
2848
|
-
});
|
|
2849
|
-
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug4.failUndefined)();
|
|
2850
|
-
const signingContext = {
|
|
2851
|
-
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
2852
|
-
identityKey: identity.identityKey,
|
|
2853
|
-
deviceKey: identity.deviceKey,
|
|
2854
|
-
profile: identity.profileDocument,
|
|
2855
|
-
recordCredential: async (credential) => {
|
|
2856
|
-
await identity.controlPipeline.writer.write({
|
|
2857
|
-
credential: {
|
|
2858
|
-
credential
|
|
2859
|
-
}
|
|
2860
|
-
});
|
|
2861
|
-
}
|
|
2862
|
-
};
|
|
2863
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.modelFactory, this.feedStore, this.snapshotStore);
|
|
2864
|
-
await this.dataSpaceManager.open();
|
|
2865
|
-
this.spaceInvitations = new SpaceInvitationsHandler(this.networkManager, this.dataSpaceManager, signingContext, this.keyring);
|
|
2866
|
-
this.initialized.wake();
|
|
2867
|
-
this._deviceSpaceSync = identity.space.spaceState.registerProcessor({
|
|
2868
|
-
process: async (credential) => {
|
|
2869
|
-
const assertion = (0, import_credentials11.getCredentialAssertion)(credential);
|
|
2870
|
-
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
2871
|
-
return;
|
|
2872
|
-
}
|
|
2873
|
-
if (assertion.spaceKey.equals(identity.space.key)) {
|
|
2874
|
-
return;
|
|
2875
|
-
}
|
|
2876
|
-
if (!this.dataSpaceManager) {
|
|
2877
|
-
(0, import_log10.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
2878
|
-
details: assertion
|
|
2879
|
-
}, {
|
|
2880
|
-
file: "service-context.ts",
|
|
2881
|
-
line: 182,
|
|
2882
|
-
scope: this,
|
|
2883
|
-
callSite: (f, a) => f(...a)
|
|
2884
|
-
});
|
|
2885
|
-
return;
|
|
2886
|
-
}
|
|
2887
|
-
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
2888
|
-
(0, import_log10.log)("space already exists, ignoring space admission", {
|
|
2889
|
-
details: assertion
|
|
2890
|
-
}, {
|
|
2891
|
-
file: "service-context.ts",
|
|
2892
|
-
line: 186,
|
|
2893
|
-
scope: this,
|
|
2894
|
-
callSite: (f, a) => f(...a)
|
|
2895
|
-
});
|
|
2896
|
-
return;
|
|
2897
|
-
}
|
|
2898
|
-
try {
|
|
2899
|
-
(0, import_log10.log)("accepting space recorded in halo", {
|
|
2900
|
-
details: assertion
|
|
2901
|
-
}, {
|
|
2902
|
-
file: "service-context.ts",
|
|
2903
|
-
line: 191,
|
|
2904
|
-
scope: this,
|
|
2905
|
-
callSite: (f, a) => f(...a)
|
|
2906
|
-
});
|
|
2907
|
-
await this.dataSpaceManager.acceptSpace({
|
|
2908
|
-
spaceKey: assertion.spaceKey,
|
|
2909
|
-
genesisFeedKey: assertion.genesisFeedKey
|
|
2910
|
-
});
|
|
2911
|
-
} catch (err) {
|
|
2912
|
-
import_log10.log.catch(err, {}, {
|
|
2913
|
-
file: "service-context.ts",
|
|
2914
|
-
line: 197,
|
|
2915
|
-
scope: this,
|
|
2916
|
-
callSite: (f, a) => f(...a)
|
|
2917
|
-
});
|
|
2918
|
-
}
|
|
2919
|
-
}
|
|
2920
|
-
});
|
|
2921
|
-
await this._deviceSpaceSync.open();
|
|
2922
|
-
}
|
|
2923
|
-
};
|
|
2924
|
-
|
|
2925
|
-
// packages/sdk/client-services/src/packlets/services/service-definitions.ts
|
|
2926
|
-
var import_protocols6 = require("@dxos/protocols");
|
|
2927
|
-
var import_rpc = require("@dxos/rpc");
|
|
2928
|
-
var clientServiceBundle = (0, import_rpc.createServiceBundle)({
|
|
2929
|
-
SystemService: import_protocols6.schema.getService("dxos.client.services.SystemService"),
|
|
2930
|
-
IdentityService: import_protocols6.schema.getService("dxos.client.services.IdentityService"),
|
|
2931
|
-
DeviceInvitationsService: import_protocols6.schema.getService("dxos.client.services.DeviceInvitationsService"),
|
|
2932
|
-
DevicesService: import_protocols6.schema.getService("dxos.client.services.DevicesService"),
|
|
2933
|
-
SpaceInvitationsService: import_protocols6.schema.getService("dxos.client.services.SpaceInvitationsService"),
|
|
2934
|
-
SpacesService: import_protocols6.schema.getService("dxos.client.services.SpacesService"),
|
|
2935
|
-
DataService: import_protocols6.schema.getService("dxos.echo.service.DataService"),
|
|
2936
|
-
NetworkService: import_protocols6.schema.getService("dxos.client.services.NetworkService"),
|
|
2937
|
-
// TODO(burdon): Deprecated.
|
|
2938
|
-
DevtoolsHost: import_protocols6.schema.getService("dxos.devtools.host.DevtoolsHost"),
|
|
2939
|
-
TracingService: import_protocols6.schema.getService("dxos.devtools.host.TracingService")
|
|
2940
|
-
});
|
|
2941
|
-
|
|
2942
|
-
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
2943
|
-
var import_node_assert14 = __toESM(require("node:assert"));
|
|
2944
|
-
var import_async22 = require("@dxos/async");
|
|
2945
|
-
var import_debug6 = require("@dxos/debug");
|
|
2946
|
-
var import_document_model = require("@dxos/document-model");
|
|
2947
|
-
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
2948
|
-
var import_log17 = require("@dxos/log");
|
|
2949
|
-
var import_model_factory = require("@dxos/model-factory");
|
|
2950
|
-
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2951
|
-
var import_text_model = require("@dxos/text-model");
|
|
2952
|
-
|
|
2953
|
-
// packages/sdk/client-services/src/packlets/deprecated/tracing.ts
|
|
2954
|
-
var TracingServiceImpl = class {
|
|
2955
|
-
constructor(_config) {
|
|
2956
|
-
this._config = _config;
|
|
2957
|
-
}
|
|
2958
|
-
async setTracingOptions() {
|
|
2959
|
-
throw new Error("Tracing not available.");
|
|
2960
|
-
}
|
|
2961
|
-
subscribeToRpcTrace() {
|
|
2962
|
-
throw new Error("Tracing not available.");
|
|
2963
|
-
}
|
|
2964
|
-
};
|
|
2965
|
-
|
|
2966
|
-
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
2967
|
-
var import_async14 = require("@dxos/async");
|
|
2968
|
-
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
2969
|
-
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2970
|
-
var DevicesServiceImpl = class {
|
|
2971
|
-
constructor(_identityManager) {
|
|
2972
|
-
this._identityManager = _identityManager;
|
|
2973
|
-
}
|
|
2974
|
-
updateDevice(request) {
|
|
2975
|
-
throw new Error("Method not implemented.");
|
|
2976
|
-
}
|
|
2977
|
-
queryDevices() {
|
|
2978
|
-
return new import_codec_protobuf8.Stream(({ next }) => {
|
|
2979
|
-
const update = () => {
|
|
2980
|
-
var _a;
|
|
2981
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
2982
|
-
if (!deviceKeys) {
|
|
2983
|
-
next({
|
|
2984
|
-
devices: []
|
|
2985
|
-
});
|
|
2986
|
-
} else {
|
|
2987
|
-
next({
|
|
2988
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
2989
|
-
var _a2;
|
|
2990
|
-
return {
|
|
2991
|
-
deviceKey: key,
|
|
2992
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services6.DeviceKind.CURRENT : import_services6.DeviceKind.TRUSTED
|
|
2993
|
-
};
|
|
2994
|
-
})
|
|
2995
|
-
});
|
|
2996
|
-
}
|
|
2997
|
-
};
|
|
2998
|
-
const subscriptions = new import_async14.EventSubscriptions();
|
|
2999
|
-
subscriptions.add(this._identityManager.stateUpdate.on(() => {
|
|
3000
|
-
update();
|
|
3001
|
-
if (this._identityManager.identity) {
|
|
3002
|
-
subscriptions.add(this._identityManager.identity.stateUpdate.on(() => {
|
|
3003
|
-
update();
|
|
3004
|
-
}));
|
|
3005
|
-
}
|
|
3006
|
-
}));
|
|
3007
|
-
update();
|
|
3008
|
-
return () => subscriptions.clear();
|
|
3009
|
-
});
|
|
3010
|
-
}
|
|
3011
|
-
};
|
|
3012
|
-
|
|
3013
|
-
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
3014
|
-
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
3015
|
-
var NetworkServiceImpl = class {
|
|
3016
|
-
constructor(networkManager) {
|
|
3017
|
-
this.networkManager = networkManager;
|
|
3018
|
-
}
|
|
3019
|
-
subscribeToNetworkStatus() {
|
|
3020
|
-
return new import_codec_protobuf9.Stream(({ next }) => {
|
|
3021
|
-
const unsubscribe = this.networkManager.connectionStateChanged.on((state) => next({
|
|
3022
|
-
state
|
|
3023
|
-
}));
|
|
3024
|
-
next({
|
|
3025
|
-
state: this.networkManager.connectionState
|
|
3026
|
-
});
|
|
3027
|
-
return unsubscribe;
|
|
3028
|
-
});
|
|
3029
|
-
}
|
|
3030
|
-
async setNetworkOptions(request) {
|
|
3031
|
-
await this.networkManager.setConnectionState(request.state);
|
|
3032
|
-
}
|
|
3033
|
-
};
|
|
3034
|
-
|
|
3035
2587
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
3036
|
-
var
|
|
2588
|
+
var import_async12 = require("@dxos/async");
|
|
3037
2589
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
3038
|
-
var
|
|
3039
|
-
var
|
|
3040
|
-
var
|
|
3041
|
-
var
|
|
2590
|
+
var import_debug4 = require("@dxos/debug");
|
|
2591
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
2592
|
+
var import_log9 = require("@dxos/log");
|
|
2593
|
+
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3042
2594
|
var import_util6 = require("@dxos/util");
|
|
3043
2595
|
var SpacesServiceImpl = class {
|
|
3044
2596
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
@@ -3056,14 +2608,14 @@ var SpacesServiceImpl = class {
|
|
|
3056
2608
|
return this._transformSpace(space);
|
|
3057
2609
|
}
|
|
3058
2610
|
async updateSpace(request) {
|
|
3059
|
-
(0,
|
|
2611
|
+
(0, import_debug4.todo)();
|
|
3060
2612
|
}
|
|
3061
2613
|
querySpaces() {
|
|
3062
2614
|
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
3063
2615
|
const onUpdate = async () => {
|
|
3064
2616
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3065
2617
|
const spaces = Array.from(dataSpaceManager.spaces.values()).filter((space) => this._dataServiceSubscriptions.getDataService(space.key)).map((space) => this._transformSpace(space));
|
|
3066
|
-
(0,
|
|
2618
|
+
(0, import_log9.log)("update", {
|
|
3067
2619
|
spaces
|
|
3068
2620
|
}, {
|
|
3069
2621
|
file: "spaces-service.ts",
|
|
@@ -3077,7 +2629,7 @@ var SpacesServiceImpl = class {
|
|
|
3077
2629
|
};
|
|
3078
2630
|
setTimeout(async () => {
|
|
3079
2631
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3080
|
-
const subscriptions = new
|
|
2632
|
+
const subscriptions = new import_async12.EventSubscriptions();
|
|
3081
2633
|
const subscribeSpaces = () => {
|
|
3082
2634
|
subscriptions.clear();
|
|
3083
2635
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
@@ -3093,7 +2645,7 @@ var SpacesServiceImpl = class {
|
|
|
3093
2645
|
void onUpdate();
|
|
3094
2646
|
});
|
|
3095
2647
|
ctx.onDispose(() => subscriptions.clear());
|
|
3096
|
-
(0,
|
|
2648
|
+
(0, import_async12.scheduleTask)(ctx, () => {
|
|
3097
2649
|
subscribeSpaces();
|
|
3098
2650
|
void onUpdate();
|
|
3099
2651
|
});
|
|
@@ -3108,19 +2660,19 @@ var SpacesServiceImpl = class {
|
|
|
3108
2660
|
queryCredentials({ spaceKey }) {
|
|
3109
2661
|
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
3110
2662
|
var _a;
|
|
3111
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
2663
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug4.raise)(new import_echo_pipeline3.SpaceNotFoundError(spaceKey));
|
|
3112
2664
|
const processor = space.spaceState.registerProcessor({
|
|
3113
2665
|
process: async (credential) => {
|
|
3114
2666
|
next(credential);
|
|
3115
2667
|
}
|
|
3116
2668
|
});
|
|
3117
2669
|
ctx.onDispose(() => processor.close());
|
|
3118
|
-
(0,
|
|
2670
|
+
(0, import_async12.scheduleTask)(ctx, () => processor.open());
|
|
3119
2671
|
});
|
|
3120
2672
|
}
|
|
3121
2673
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3122
2674
|
var _a;
|
|
3123
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
2675
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug4.raise)(new import_echo_pipeline3.SpaceNotFoundError(spaceKey));
|
|
3124
2676
|
for (const credential of credentials != null ? credentials : []) {
|
|
3125
2677
|
await space.controlPipeline.writer.write({
|
|
3126
2678
|
credential: {
|
|
@@ -3132,7 +2684,7 @@ var SpacesServiceImpl = class {
|
|
|
3132
2684
|
_transformSpace(space) {
|
|
3133
2685
|
return {
|
|
3134
2686
|
spaceKey: space.key,
|
|
3135
|
-
status: space.isOpen ?
|
|
2687
|
+
status: space.isOpen ? import_services5.SpaceStatus.ACTIVE : import_services5.SpaceStatus.INACTIVE,
|
|
3136
2688
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3137
2689
|
var _a, _b, _c;
|
|
3138
2690
|
return {
|
|
@@ -3142,7 +2694,7 @@ var SpacesServiceImpl = class {
|
|
|
3142
2694
|
displayName: (_b = (_a = member.assertion.profile) == null ? void 0 : _a.displayName) != null ? _b : (0, import_util6.humanize)(member.key)
|
|
3143
2695
|
}
|
|
3144
2696
|
},
|
|
3145
|
-
presence: ((_c = this._identityManager.identity) == null ? void 0 : _c.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ?
|
|
2697
|
+
presence: ((_c = this._identityManager.identity) == null ? void 0 : _c.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services5.SpaceMember.PresenceState.ONLINE : import_services5.SpaceMember.PresenceState.OFFLINE
|
|
3146
2698
|
};
|
|
3147
2699
|
})
|
|
3148
2700
|
};
|
|
@@ -3205,7 +2757,8 @@ var SystemServiceImpl = class {
|
|
|
3205
2757
|
this._onReset = onReset;
|
|
3206
2758
|
}
|
|
3207
2759
|
async getConfig() {
|
|
3208
|
-
|
|
2760
|
+
var _a, _b;
|
|
2761
|
+
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
3209
2762
|
}
|
|
3210
2763
|
async updateStatus({ status }) {
|
|
3211
2764
|
await this._onUpdateStatus(status);
|
|
@@ -3232,40 +2785,75 @@ var SystemServiceImpl = class {
|
|
|
3232
2785
|
};
|
|
3233
2786
|
|
|
3234
2787
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3235
|
-
var
|
|
3236
|
-
var
|
|
2788
|
+
var import_async14 = require("@dxos/async");
|
|
2789
|
+
var import_log10 = require("@dxos/log");
|
|
3237
2790
|
var import_messaging = require("@dxos/messaging");
|
|
3238
2791
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
3239
|
-
var import_rpc3 = require("@dxos/rpc");
|
|
3240
2792
|
var import_util7 = require("@dxos/util");
|
|
3241
2793
|
|
|
3242
|
-
// packages/sdk/client-services/src/packlets/
|
|
3243
|
-
var
|
|
3244
|
-
var
|
|
3245
|
-
var
|
|
3246
|
-
var
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
2794
|
+
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
2795
|
+
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
2796
|
+
var import_debug5 = require("@dxos/debug");
|
|
2797
|
+
var import_rpc = require("@dxos/rpc");
|
|
2798
|
+
var ClientRpcServer = class {
|
|
2799
|
+
constructor(params) {
|
|
2800
|
+
this._handlerCache = /* @__PURE__ */ new Map();
|
|
2801
|
+
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
2802
|
+
this._handleCall = handleCall;
|
|
2803
|
+
this._handleStream = handleStream;
|
|
2804
|
+
this._serviceRegistry = serviceRegistry;
|
|
2805
|
+
this._rpcPeer = new import_rpc.RpcPeer({
|
|
2806
|
+
...rpcOptions,
|
|
2807
|
+
callHandler: (method, params2) => {
|
|
2808
|
+
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
2809
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
2810
|
+
if (this._handleCall) {
|
|
2811
|
+
return this._handleCall(methodName, params2, handler);
|
|
2812
|
+
} else {
|
|
2813
|
+
return handler(methodName, params2);
|
|
2814
|
+
}
|
|
2815
|
+
},
|
|
2816
|
+
streamHandler: (method, params2) => {
|
|
2817
|
+
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
2818
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
2819
|
+
if (this._handleStream) {
|
|
2820
|
+
return import_codec_protobuf12.Stream.unwrapPromise(this._handleStream(methodName, params2, handler));
|
|
2821
|
+
} else {
|
|
2822
|
+
return handler(methodName, params2);
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
});
|
|
2826
|
+
}
|
|
2827
|
+
async open() {
|
|
2828
|
+
await this._rpcPeer.open();
|
|
2829
|
+
}
|
|
2830
|
+
async close() {
|
|
2831
|
+
await this._rpcPeer.close();
|
|
2832
|
+
}
|
|
2833
|
+
_getServiceHandler(serviceName) {
|
|
2834
|
+
var _a;
|
|
2835
|
+
if (!this._handlerCache.has(serviceName)) {
|
|
2836
|
+
const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : (0, import_debug5.raise)(new Error(`Service not available: ${serviceName}`));
|
|
2837
|
+
const service = this._serviceRegistry.services[key];
|
|
2838
|
+
if (!service) {
|
|
2839
|
+
throw new Error(`Service not available: ${serviceName}`);
|
|
2840
|
+
}
|
|
2841
|
+
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
2842
|
+
}
|
|
2843
|
+
return this._handlerCache.get(serviceName);
|
|
2844
|
+
}
|
|
3262
2845
|
};
|
|
3263
2846
|
|
|
3264
2847
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
2848
|
+
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2849
|
+
var import_async13 = require("@dxos/async");
|
|
2850
|
+
var import_client3 = require("@dxos/client");
|
|
2851
|
+
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
2852
|
+
var import_rpc2 = require("@dxos/rpc");
|
|
3265
2853
|
var ShellRuntimeImpl = class {
|
|
3266
2854
|
constructor(_port) {
|
|
3267
2855
|
this._port = _port;
|
|
3268
|
-
this.layoutUpdate = new
|
|
2856
|
+
this.layoutUpdate = new import_async13.Event();
|
|
3269
2857
|
this._layout = import_iframe.ShellLayout.DEFAULT;
|
|
3270
2858
|
}
|
|
3271
2859
|
get layout() {
|
|
@@ -3287,13 +2875,13 @@ var ShellRuntimeImpl = class {
|
|
|
3287
2875
|
});
|
|
3288
2876
|
}
|
|
3289
2877
|
async setAppContext(context) {
|
|
3290
|
-
(0,
|
|
2878
|
+
(0, import_node_assert10.default)(this._appRpc, "runtime not open");
|
|
3291
2879
|
await this._appRpc.rpc.AppService.setContext(context);
|
|
3292
2880
|
}
|
|
3293
2881
|
async open() {
|
|
3294
2882
|
this._appRpc = (0, import_rpc2.createProtoRpcPeer)({
|
|
3295
|
-
requested: appServiceBundle,
|
|
3296
|
-
exposed: shellServiceBundle,
|
|
2883
|
+
requested: import_client3.appServiceBundle,
|
|
2884
|
+
exposed: import_client3.shellServiceBundle,
|
|
3297
2885
|
handlers: {
|
|
3298
2886
|
ShellService: {
|
|
3299
2887
|
setLayout: async (request) => {
|
|
@@ -3316,8 +2904,8 @@ var ShellRuntimeImpl = class {
|
|
|
3316
2904
|
};
|
|
3317
2905
|
var MemoryShellRuntime = class {
|
|
3318
2906
|
constructor({ layout, invitationCode, spaceKey } = {}) {
|
|
3319
|
-
this.layoutUpdate = new
|
|
3320
|
-
this.contextUpdate = new
|
|
2907
|
+
this.layoutUpdate = new import_async13.Event();
|
|
2908
|
+
this.contextUpdate = new import_async13.Event();
|
|
3321
2909
|
this._layout = layout != null ? layout : import_iframe.ShellLayout.DEFAULT;
|
|
3322
2910
|
this._invitationCode = invitationCode;
|
|
3323
2911
|
this._spaceKey = spaceKey;
|
|
@@ -3360,21 +2948,10 @@ var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
|
3360
2948
|
var IFrameHostRuntime = class {
|
|
3361
2949
|
constructor({ configProvider, appPort, shellPort }) {
|
|
3362
2950
|
this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)();
|
|
3363
|
-
this._ready = new
|
|
2951
|
+
this._ready = new import_async14.Trigger();
|
|
3364
2952
|
this._configProvider = configProvider;
|
|
3365
2953
|
this._appPort = appPort;
|
|
3366
2954
|
this._shellPort = shellPort;
|
|
3367
|
-
this._getService = async (find) => {
|
|
3368
|
-
const error = await this._ready.wait();
|
|
3369
|
-
if (error) {
|
|
3370
|
-
throw error;
|
|
3371
|
-
}
|
|
3372
|
-
const service = await find(this._clientServices.services);
|
|
3373
|
-
if (!service) {
|
|
3374
|
-
throw new Error("Service not found");
|
|
3375
|
-
}
|
|
3376
|
-
return service;
|
|
3377
|
-
};
|
|
3378
2955
|
if (this._shellPort) {
|
|
3379
2956
|
this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
|
|
3380
2957
|
}
|
|
@@ -3387,9 +2964,9 @@ var IFrameHostRuntime = class {
|
|
|
3387
2964
|
}
|
|
3388
2965
|
async start() {
|
|
3389
2966
|
var _a;
|
|
3390
|
-
(0,
|
|
2967
|
+
(0, import_log10.log)("starting...", {}, {
|
|
3391
2968
|
file: "iframe-host-runtime.ts",
|
|
3392
|
-
line:
|
|
2969
|
+
line: 67,
|
|
3393
2970
|
scope: this,
|
|
3394
2971
|
callSite: (f, a) => f(...a)
|
|
3395
2972
|
});
|
|
@@ -3407,21 +2984,30 @@ var IFrameHostRuntime = class {
|
|
|
3407
2984
|
transportFactory: this._transportFactory
|
|
3408
2985
|
})
|
|
3409
2986
|
});
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
|
|
3420
|
-
SpacesService: async () => await this._getService((services) => services.SpacesService),
|
|
3421
|
-
SystemService: async () => await this._getService((services) => services.SystemService),
|
|
3422
|
-
TracingService: async () => await this._getService((services) => services.TracingService)
|
|
2987
|
+
const middleware = {
|
|
2988
|
+
handleCall: async (method, params, handler) => {
|
|
2989
|
+
const error = await this._ready.wait({
|
|
2990
|
+
timeout: 3e3
|
|
2991
|
+
});
|
|
2992
|
+
if (error) {
|
|
2993
|
+
throw error;
|
|
2994
|
+
}
|
|
2995
|
+
return handler(method, params);
|
|
3423
2996
|
},
|
|
3424
|
-
|
|
2997
|
+
handleStream: async (method, params, handler) => {
|
|
2998
|
+
const error = await this._ready.wait({
|
|
2999
|
+
timeout: 3e3
|
|
3000
|
+
});
|
|
3001
|
+
if (error) {
|
|
3002
|
+
throw error;
|
|
3003
|
+
}
|
|
3004
|
+
return handler(method, params);
|
|
3005
|
+
}
|
|
3006
|
+
};
|
|
3007
|
+
this._clientRpc = new ClientRpcServer({
|
|
3008
|
+
serviceRegistry: this._clientServices.host.serviceRegistry,
|
|
3009
|
+
port: this._appPort,
|
|
3010
|
+
...middleware
|
|
3425
3011
|
});
|
|
3426
3012
|
await Promise.all([
|
|
3427
3013
|
this._clientServices.open(),
|
|
@@ -3429,17 +3015,17 @@ var IFrameHostRuntime = class {
|
|
|
3429
3015
|
(_a = this._shellRuntime) == null ? void 0 : _a.open()
|
|
3430
3016
|
]);
|
|
3431
3017
|
this._ready.wake(void 0);
|
|
3432
|
-
(0,
|
|
3018
|
+
(0, import_log10.log)("started", {}, {
|
|
3433
3019
|
file: "iframe-host-runtime.ts",
|
|
3434
|
-
line:
|
|
3020
|
+
line: 110,
|
|
3435
3021
|
scope: this,
|
|
3436
3022
|
callSite: (f, a) => f(...a)
|
|
3437
3023
|
});
|
|
3438
3024
|
} catch (err) {
|
|
3439
3025
|
this._ready.wake(err);
|
|
3440
|
-
|
|
3026
|
+
import_log10.log.catch(err, {}, {
|
|
3441
3027
|
file: "iframe-host-runtime.ts",
|
|
3442
|
-
line:
|
|
3028
|
+
line: 113,
|
|
3443
3029
|
scope: this,
|
|
3444
3030
|
callSite: (f, a) => f(...a)
|
|
3445
3031
|
});
|
|
@@ -3447,30 +3033,31 @@ var IFrameHostRuntime = class {
|
|
|
3447
3033
|
}
|
|
3448
3034
|
async stop() {
|
|
3449
3035
|
var _a;
|
|
3450
|
-
(0,
|
|
3036
|
+
(0, import_log10.log)("stopping...", {}, {
|
|
3451
3037
|
file: "iframe-host-runtime.ts",
|
|
3452
|
-
line:
|
|
3038
|
+
line: 118,
|
|
3453
3039
|
scope: this,
|
|
3454
3040
|
callSite: (f, a) => f(...a)
|
|
3455
3041
|
});
|
|
3456
3042
|
await this._clientRpc.close();
|
|
3457
3043
|
await this._clientServices.close();
|
|
3458
3044
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
3459
|
-
(0,
|
|
3045
|
+
(0, import_log10.log)("stopped", {}, {
|
|
3460
3046
|
file: "iframe-host-runtime.ts",
|
|
3461
|
-
line:
|
|
3047
|
+
line: 122,
|
|
3462
3048
|
scope: this,
|
|
3463
3049
|
callSite: (f, a) => f(...a)
|
|
3464
3050
|
});
|
|
3465
3051
|
}
|
|
3466
3052
|
};
|
|
3467
3053
|
__decorate3([
|
|
3468
|
-
|
|
3054
|
+
import_log10.logInfo
|
|
3469
3055
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
3470
3056
|
|
|
3471
3057
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
3058
|
+
var import_client4 = require("@dxos/client");
|
|
3472
3059
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
3473
|
-
var
|
|
3060
|
+
var import_rpc3 = require("@dxos/rpc");
|
|
3474
3061
|
var IFrameProxyRuntime = class {
|
|
3475
3062
|
constructor({ systemPort, workerAppPort, windowAppPort, shellPort }) {
|
|
3476
3063
|
this._transportService = new import_network_manager4.WebRTCTransportService();
|
|
@@ -3478,9 +3065,9 @@ var IFrameProxyRuntime = class {
|
|
|
3478
3065
|
this._windowAppPort = windowAppPort;
|
|
3479
3066
|
this._workerAppPort = workerAppPort;
|
|
3480
3067
|
this._shellPort = shellPort;
|
|
3481
|
-
this._systemRpc = (0,
|
|
3482
|
-
requested: workerServiceBundle,
|
|
3483
|
-
exposed: iframeServiceBundle,
|
|
3068
|
+
this._systemRpc = (0, import_rpc3.createProtoRpcPeer)({
|
|
3069
|
+
requested: import_client4.workerServiceBundle,
|
|
3070
|
+
exposed: import_client4.iframeServiceBundle,
|
|
3484
3071
|
handlers: {
|
|
3485
3072
|
BridgeService: this._transportService,
|
|
3486
3073
|
IframeService: {
|
|
@@ -3506,82 +3093,19 @@ var IFrameProxyRuntime = class {
|
|
|
3506
3093
|
await this._systemRpc.rpc.WorkerService.start({
|
|
3507
3094
|
origin
|
|
3508
3095
|
});
|
|
3509
|
-
await ((_a = this._shellRuntime) == null ? void 0 : _a.open());
|
|
3510
|
-
}
|
|
3511
|
-
async close() {
|
|
3512
|
-
var _a;
|
|
3513
|
-
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
3514
|
-
await this._systemRpc.rpc.WorkerService.stop();
|
|
3515
|
-
await this._systemRpc.close();
|
|
3516
|
-
}
|
|
3517
|
-
};
|
|
3518
|
-
|
|
3519
|
-
// packages/sdk/client-services/src/packlets/vault/shell-controller.ts
|
|
3520
|
-
var import_async18 = require("@dxos/async");
|
|
3521
|
-
var import_log13 = require("@dxos/log");
|
|
3522
|
-
var import_iframe2 = require("@dxos/protocols/proto/dxos/iframe");
|
|
3523
|
-
var import_rpc5 = require("@dxos/rpc");
|
|
3524
|
-
var ShellController = class {
|
|
3525
|
-
constructor(_port) {
|
|
3526
|
-
this._port = _port;
|
|
3527
|
-
this.contextUpdate = new import_async18.Event();
|
|
3528
|
-
this._display = import_iframe2.ShellDisplay.NONE;
|
|
3529
|
-
}
|
|
3530
|
-
get display() {
|
|
3531
|
-
return this._display;
|
|
3532
|
-
}
|
|
3533
|
-
async setLayout(layout, options = {}) {
|
|
3534
|
-
var _a;
|
|
3535
|
-
(0, import_log13.log)("set layout", {
|
|
3536
|
-
layout,
|
|
3537
|
-
...options
|
|
3538
|
-
}, {
|
|
3539
|
-
file: "shell-controller.ts",
|
|
3540
|
-
line: 27,
|
|
3541
|
-
scope: this,
|
|
3542
|
-
callSite: (f, a) => f(...a)
|
|
3543
|
-
});
|
|
3544
|
-
this._display = import_iframe2.ShellDisplay.FULLSCREEN;
|
|
3545
|
-
this.contextUpdate.emit({
|
|
3546
|
-
display: this._display
|
|
3547
|
-
});
|
|
3548
|
-
await ((_a = this._shellRpc) == null ? void 0 : _a.rpc.ShellService.setLayout({
|
|
3549
|
-
layout,
|
|
3550
|
-
...options
|
|
3551
|
-
}));
|
|
3552
|
-
}
|
|
3553
|
-
async open() {
|
|
3554
|
-
this._shellRpc = (0, import_rpc5.createProtoRpcPeer)({
|
|
3555
|
-
requested: shellServiceBundle,
|
|
3556
|
-
exposed: appServiceBundle,
|
|
3557
|
-
handlers: {
|
|
3558
|
-
AppService: {
|
|
3559
|
-
setContext: async (request) => {
|
|
3560
|
-
(0, import_log13.log)("set context", request, {
|
|
3561
|
-
file: "shell-controller.ts",
|
|
3562
|
-
line: 40,
|
|
3563
|
-
scope: this,
|
|
3564
|
-
callSite: (f, a) => f(...a)
|
|
3565
|
-
});
|
|
3566
|
-
this._display = request.display;
|
|
3567
|
-
this.contextUpdate.emit(request);
|
|
3568
|
-
}
|
|
3569
|
-
}
|
|
3570
|
-
},
|
|
3571
|
-
port: this._port
|
|
3572
|
-
});
|
|
3573
|
-
await this._shellRpc.open();
|
|
3096
|
+
await ((_a = this._shellRuntime) == null ? void 0 : _a.open());
|
|
3574
3097
|
}
|
|
3575
3098
|
async close() {
|
|
3576
3099
|
var _a;
|
|
3577
|
-
await ((_a = this.
|
|
3578
|
-
this.
|
|
3100
|
+
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
3101
|
+
await this._systemRpc.rpc.WorkerService.stop();
|
|
3102
|
+
await this._systemRpc.close();
|
|
3579
3103
|
}
|
|
3580
3104
|
};
|
|
3581
3105
|
|
|
3582
3106
|
// packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
|
|
3583
|
-
var
|
|
3584
|
-
var
|
|
3107
|
+
var import_async15 = require("@dxos/async");
|
|
3108
|
+
var import_log11 = require("@dxos/log");
|
|
3585
3109
|
var Message;
|
|
3586
3110
|
(function(Message2) {
|
|
3587
3111
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -3589,7 +3113,7 @@ var Message;
|
|
|
3589
3113
|
var VaultResourceLock = class {
|
|
3590
3114
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
3591
3115
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
3592
|
-
this._releaseTrigger = new
|
|
3116
|
+
this._releaseTrigger = new import_async15.Trigger();
|
|
3593
3117
|
this._lockKey = lockKey;
|
|
3594
3118
|
this._onAcquire = onAcquire;
|
|
3595
3119
|
this._onRelease = onRelease;
|
|
@@ -3600,7 +3124,7 @@ var VaultResourceLock = class {
|
|
|
3600
3124
|
message: Message.ACQUIRING
|
|
3601
3125
|
});
|
|
3602
3126
|
try {
|
|
3603
|
-
await (0,
|
|
3127
|
+
await (0, import_async15.asyncTimeout)(this._requestLock(), 3e3);
|
|
3604
3128
|
} catch (e) {
|
|
3605
3129
|
await this._requestLock(true);
|
|
3606
3130
|
}
|
|
@@ -3614,7 +3138,7 @@ var VaultResourceLock = class {
|
|
|
3614
3138
|
}
|
|
3615
3139
|
}
|
|
3616
3140
|
async _requestLock(steal = false) {
|
|
3617
|
-
(0,
|
|
3141
|
+
(0, import_log11.log)("requesting lock...", {
|
|
3618
3142
|
steal
|
|
3619
3143
|
}, {
|
|
3620
3144
|
file: "vault-resource-lock.ts",
|
|
@@ -3622,23 +3146,23 @@ var VaultResourceLock = class {
|
|
|
3622
3146
|
scope: this,
|
|
3623
3147
|
callSite: (f, a) => f(...a)
|
|
3624
3148
|
});
|
|
3625
|
-
const acquired = new
|
|
3149
|
+
const acquired = new import_async15.Trigger();
|
|
3626
3150
|
void navigator.locks.request(this._lockKey, {
|
|
3627
3151
|
steal
|
|
3628
3152
|
}, async () => {
|
|
3629
3153
|
var _a, _b;
|
|
3630
3154
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3631
3155
|
acquired.wake();
|
|
3632
|
-
this._releaseTrigger = new
|
|
3156
|
+
this._releaseTrigger = new import_async15.Trigger();
|
|
3633
3157
|
await this._releaseTrigger.wait();
|
|
3634
|
-
(0,
|
|
3158
|
+
(0, import_log11.log)("releasing lock...", {}, {
|
|
3635
3159
|
file: "vault-resource-lock.ts",
|
|
3636
3160
|
line: 65,
|
|
3637
3161
|
scope: this,
|
|
3638
3162
|
callSite: (f, a) => f(...a)
|
|
3639
3163
|
});
|
|
3640
3164
|
await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
|
|
3641
|
-
(0,
|
|
3165
|
+
(0, import_log11.log)("released lock", {}, {
|
|
3642
3166
|
file: "vault-resource-lock.ts",
|
|
3643
3167
|
line: 67,
|
|
3644
3168
|
scope: this,
|
|
@@ -3649,7 +3173,7 @@ var VaultResourceLock = class {
|
|
|
3649
3173
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3650
3174
|
});
|
|
3651
3175
|
await acquired.wait();
|
|
3652
|
-
(0,
|
|
3176
|
+
(0, import_log11.log)("recieved lock", {
|
|
3653
3177
|
steal
|
|
3654
3178
|
}, {
|
|
3655
3179
|
file: "vault-resource-lock.ts",
|
|
@@ -3661,16 +3185,17 @@ var VaultResourceLock = class {
|
|
|
3661
3185
|
};
|
|
3662
3186
|
|
|
3663
3187
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
3664
|
-
var
|
|
3665
|
-
var
|
|
3188
|
+
var import_async17 = require("@dxos/async");
|
|
3189
|
+
var import_log13 = require("@dxos/log");
|
|
3666
3190
|
var import_messaging2 = require("@dxos/messaging");
|
|
3667
3191
|
var import_network_manager5 = require("@dxos/network-manager");
|
|
3668
3192
|
|
|
3669
3193
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
3670
|
-
var
|
|
3671
|
-
var
|
|
3672
|
-
var
|
|
3673
|
-
var
|
|
3194
|
+
var import_node_assert11 = __toESM(require("node:assert"));
|
|
3195
|
+
var import_async16 = require("@dxos/async");
|
|
3196
|
+
var import_client5 = require("@dxos/client");
|
|
3197
|
+
var import_log12 = require("@dxos/log");
|
|
3198
|
+
var import_rpc4 = require("@dxos/rpc");
|
|
3674
3199
|
var import_util8 = require("@dxos/util");
|
|
3675
3200
|
var __decorate4 = function(decorators, target, key, desc) {
|
|
3676
3201
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3683,40 +3208,48 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
3683
3208
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3684
3209
|
};
|
|
3685
3210
|
var WorkerSession = class {
|
|
3686
|
-
constructor({
|
|
3211
|
+
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal, options = {
|
|
3687
3212
|
heartbeatInterval: 1e3
|
|
3688
3213
|
} }) {
|
|
3689
|
-
this._startTrigger = new
|
|
3214
|
+
this._startTrigger = new import_async16.Trigger();
|
|
3690
3215
|
this.onClose = new import_util8.Callback();
|
|
3691
|
-
(0,
|
|
3692
|
-
(0,
|
|
3216
|
+
(0, import_node_assert11.default)(options);
|
|
3217
|
+
(0, import_node_assert11.default)(serviceHost);
|
|
3693
3218
|
this._options = options;
|
|
3694
|
-
this.
|
|
3695
|
-
const
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3219
|
+
this._serviceHost = serviceHost;
|
|
3220
|
+
const middleware = {
|
|
3221
|
+
handleCall: async (method, params, handler) => {
|
|
3222
|
+
const error = await readySignal.wait({
|
|
3223
|
+
timeout: 3e3
|
|
3224
|
+
});
|
|
3225
|
+
if (error) {
|
|
3226
|
+
throw error;
|
|
3227
|
+
}
|
|
3228
|
+
return handler(method, params);
|
|
3229
|
+
},
|
|
3230
|
+
handleStream: async (method, params, handler) => {
|
|
3231
|
+
const error = await readySignal.wait({
|
|
3232
|
+
timeout: 3e3
|
|
3233
|
+
});
|
|
3234
|
+
if (error) {
|
|
3235
|
+
throw error;
|
|
3236
|
+
}
|
|
3237
|
+
return handler(method, params);
|
|
3238
|
+
}
|
|
3706
3239
|
};
|
|
3707
|
-
this._clientRpc =
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
});
|
|
3712
|
-
this._shellClientRpc =
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
});
|
|
3717
|
-
this._iframeRpc = (0,
|
|
3718
|
-
requested: iframeServiceBundle,
|
|
3719
|
-
exposed: workerServiceBundle,
|
|
3240
|
+
this._clientRpc = new ClientRpcServer({
|
|
3241
|
+
serviceRegistry: this._serviceHost.serviceRegistry,
|
|
3242
|
+
port: appPort,
|
|
3243
|
+
...middleware
|
|
3244
|
+
});
|
|
3245
|
+
this._shellClientRpc = new ClientRpcServer({
|
|
3246
|
+
serviceRegistry: this._serviceHost.serviceRegistry,
|
|
3247
|
+
port: shellPort,
|
|
3248
|
+
...middleware
|
|
3249
|
+
});
|
|
3250
|
+
this._iframeRpc = (0, import_rpc4.createProtoRpcPeer)({
|
|
3251
|
+
requested: import_client5.iframeServiceBundle,
|
|
3252
|
+
exposed: import_client5.workerServiceBundle,
|
|
3720
3253
|
handlers: {
|
|
3721
3254
|
WorkerService: {
|
|
3722
3255
|
start: async (request) => {
|
|
@@ -3728,9 +3261,9 @@ var WorkerSession = class {
|
|
|
3728
3261
|
try {
|
|
3729
3262
|
await this.close();
|
|
3730
3263
|
} catch (err) {
|
|
3731
|
-
|
|
3264
|
+
import_log12.log.catch(err, {}, {
|
|
3732
3265
|
file: "worker-session.ts",
|
|
3733
|
-
line:
|
|
3266
|
+
line: 107,
|
|
3734
3267
|
scope: this,
|
|
3735
3268
|
callSite: (f, a) => f(...a)
|
|
3736
3269
|
});
|
|
@@ -3746,9 +3279,9 @@ var WorkerSession = class {
|
|
|
3746
3279
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
3747
3280
|
}
|
|
3748
3281
|
async open() {
|
|
3749
|
-
|
|
3282
|
+
import_log12.log.info("opening..", {}, {
|
|
3750
3283
|
file: "worker-session.ts",
|
|
3751
|
-
line:
|
|
3284
|
+
line: 121,
|
|
3752
3285
|
scope: this,
|
|
3753
3286
|
callSite: (f, a) => f(...a)
|
|
3754
3287
|
});
|
|
@@ -3764,20 +3297,20 @@ var WorkerSession = class {
|
|
|
3764
3297
|
try {
|
|
3765
3298
|
await this._iframeRpc.rpc.IframeService.heartbeat();
|
|
3766
3299
|
} catch (err1) {
|
|
3767
|
-
|
|
3300
|
+
import_log12.log.warn("Heartbeat failed", {
|
|
3768
3301
|
err: err1
|
|
3769
3302
|
}, {
|
|
3770
3303
|
file: "worker-session.ts",
|
|
3771
|
-
line:
|
|
3304
|
+
line: 133,
|
|
3772
3305
|
scope: this,
|
|
3773
3306
|
callSite: (f, a) => f(...a)
|
|
3774
3307
|
});
|
|
3775
3308
|
try {
|
|
3776
3309
|
await this.close();
|
|
3777
3310
|
} catch (err) {
|
|
3778
|
-
|
|
3311
|
+
import_log12.log.catch(err, {}, {
|
|
3779
3312
|
file: "worker-session.ts",
|
|
3780
|
-
line:
|
|
3313
|
+
line: 137,
|
|
3781
3314
|
scope: this,
|
|
3782
3315
|
callSite: (f, a) => f(...a)
|
|
3783
3316
|
});
|
|
@@ -3786,18 +3319,18 @@ var WorkerSession = class {
|
|
|
3786
3319
|
}, this._options.heartbeatInterval);
|
|
3787
3320
|
}
|
|
3788
3321
|
async close() {
|
|
3789
|
-
|
|
3322
|
+
import_log12.log.info("closing..", {}, {
|
|
3790
3323
|
file: "worker-session.ts",
|
|
3791
|
-
line:
|
|
3324
|
+
line: 144,
|
|
3792
3325
|
scope: this,
|
|
3793
3326
|
callSite: (f, a) => f(...a)
|
|
3794
3327
|
});
|
|
3795
3328
|
try {
|
|
3796
3329
|
await this.onClose.callIfSet();
|
|
3797
3330
|
} catch (err) {
|
|
3798
|
-
|
|
3331
|
+
import_log12.log.catch(err, {}, {
|
|
3799
3332
|
file: "worker-session.ts",
|
|
3800
|
-
line:
|
|
3333
|
+
line: 148,
|
|
3801
3334
|
scope: this,
|
|
3802
3335
|
callSite: (f, a) => f(...a)
|
|
3803
3336
|
});
|
|
@@ -3812,11 +3345,11 @@ var WorkerSession = class {
|
|
|
3812
3345
|
}
|
|
3813
3346
|
async _maybeOpenShell() {
|
|
3814
3347
|
try {
|
|
3815
|
-
await (0,
|
|
3348
|
+
await (0, import_async16.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
3816
3349
|
} catch (e) {
|
|
3817
|
-
|
|
3350
|
+
import_log12.log.info("No shell connected.", {}, {
|
|
3818
3351
|
file: "worker-session.ts",
|
|
3819
|
-
line:
|
|
3352
|
+
line: 162,
|
|
3820
3353
|
scope: this,
|
|
3821
3354
|
callSite: (f, a) => f(...a)
|
|
3822
3355
|
});
|
|
@@ -3824,7 +3357,7 @@ var WorkerSession = class {
|
|
|
3824
3357
|
}
|
|
3825
3358
|
};
|
|
3826
3359
|
__decorate4([
|
|
3827
|
-
|
|
3360
|
+
import_log12.logInfo
|
|
3828
3361
|
], WorkerSession.prototype, "origin", void 0);
|
|
3829
3362
|
|
|
3830
3363
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
@@ -3833,20 +3366,21 @@ var WorkerRuntime = class {
|
|
|
3833
3366
|
constructor(_configProvider) {
|
|
3834
3367
|
this._configProvider = _configProvider;
|
|
3835
3368
|
this._transportFactory = new import_network_manager5.WebRTCTransportProxyFactory();
|
|
3836
|
-
this._ready = new
|
|
3369
|
+
this._ready = new import_async17.Trigger();
|
|
3837
3370
|
this.sessions = /* @__PURE__ */ new Set();
|
|
3371
|
+
this._clientServices = new ClientServicesHost();
|
|
3838
3372
|
}
|
|
3839
3373
|
async start() {
|
|
3840
|
-
(0,
|
|
3374
|
+
(0, import_log13.log)("starting...", {}, {
|
|
3841
3375
|
file: "worker-runtime.ts",
|
|
3842
|
-
line:
|
|
3376
|
+
line: 44,
|
|
3843
3377
|
scope: this,
|
|
3844
3378
|
callSite: (f, a) => f(...a)
|
|
3845
3379
|
});
|
|
3846
3380
|
try {
|
|
3847
3381
|
this._config = await this._configProvider();
|
|
3848
3382
|
const signalServer = this._config.get("runtime.services.signal.server");
|
|
3849
|
-
this._clientServices
|
|
3383
|
+
this._clientServices.initialize({
|
|
3850
3384
|
config: this._config,
|
|
3851
3385
|
networkManager: new import_network_manager5.NetworkManager({
|
|
3852
3386
|
log: true,
|
|
@@ -3858,17 +3392,17 @@ var WorkerRuntime = class {
|
|
|
3858
3392
|
});
|
|
3859
3393
|
await this._clientServices.open();
|
|
3860
3394
|
this._ready.wake(void 0);
|
|
3861
|
-
(0,
|
|
3395
|
+
(0, import_log13.log)("started", {}, {
|
|
3862
3396
|
file: "worker-runtime.ts",
|
|
3863
|
-
line:
|
|
3397
|
+
line: 61,
|
|
3864
3398
|
scope: this,
|
|
3865
3399
|
callSite: (f, a) => f(...a)
|
|
3866
3400
|
});
|
|
3867
3401
|
} catch (err) {
|
|
3868
3402
|
this._ready.wake(err);
|
|
3869
|
-
|
|
3403
|
+
import_log13.log.catch(err, {}, {
|
|
3870
3404
|
file: "worker-runtime.ts",
|
|
3871
|
-
line:
|
|
3405
|
+
line: 64,
|
|
3872
3406
|
scope: this,
|
|
3873
3407
|
callSite: (f, a) => f(...a)
|
|
3874
3408
|
});
|
|
@@ -3882,17 +3416,7 @@ var WorkerRuntime = class {
|
|
|
3882
3416
|
*/
|
|
3883
3417
|
async createSession({ appPort, systemPort, shellPort }) {
|
|
3884
3418
|
const session = new WorkerSession({
|
|
3885
|
-
|
|
3886
|
-
const error = await this._ready.wait();
|
|
3887
|
-
if (error) {
|
|
3888
|
-
throw error;
|
|
3889
|
-
}
|
|
3890
|
-
const service = find(this._clientServices.services);
|
|
3891
|
-
if (!service) {
|
|
3892
|
-
throw new Error("Service not found");
|
|
3893
|
-
}
|
|
3894
|
-
return service;
|
|
3895
|
-
},
|
|
3419
|
+
serviceHost: this._clientServices,
|
|
3896
3420
|
appPort,
|
|
3897
3421
|
systemPort,
|
|
3898
3422
|
shellPort,
|
|
@@ -3927,10 +3451,206 @@ var WorkerRuntime = class {
|
|
|
3927
3451
|
}
|
|
3928
3452
|
};
|
|
3929
3453
|
|
|
3454
|
+
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3455
|
+
var import_async18 = require("@dxos/async");
|
|
3456
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
3457
|
+
var import_debug6 = require("@dxos/debug");
|
|
3458
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3459
|
+
var import_feed_store4 = require("@dxos/feed-store");
|
|
3460
|
+
var import_keyring = require("@dxos/keyring");
|
|
3461
|
+
var import_log14 = require("@dxos/log");
|
|
3462
|
+
var ServiceContext = class {
|
|
3463
|
+
// prettier-ignore
|
|
3464
|
+
constructor(storage, networkManager, modelFactory) {
|
|
3465
|
+
this.storage = storage;
|
|
3466
|
+
this.networkManager = networkManager;
|
|
3467
|
+
this.modelFactory = modelFactory;
|
|
3468
|
+
this.initialized = new import_async18.Trigger();
|
|
3469
|
+
this.dataServiceSubscriptions = new import_echo_pipeline4.DataServiceSubscriptions();
|
|
3470
|
+
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
3471
|
+
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
3472
|
+
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
3473
|
+
this.feedStore = new import_feed_store4.FeedStore({
|
|
3474
|
+
factory: new import_feed_store4.FeedFactory({
|
|
3475
|
+
root: storage.createDirectory("feeds"),
|
|
3476
|
+
signer: this.keyring,
|
|
3477
|
+
hypercore: {
|
|
3478
|
+
valueEncoding: import_echo_pipeline4.valueEncoding
|
|
3479
|
+
}
|
|
3480
|
+
})
|
|
3481
|
+
});
|
|
3482
|
+
this.spaceManager = new import_echo_pipeline4.SpaceManager({
|
|
3483
|
+
feedStore: this.feedStore,
|
|
3484
|
+
networkManager: this.networkManager
|
|
3485
|
+
});
|
|
3486
|
+
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3487
|
+
this.deviceInvitations = new DeviceInvitationsHandler({
|
|
3488
|
+
networkManager: this.networkManager,
|
|
3489
|
+
getIdentity: () => {
|
|
3490
|
+
var _a;
|
|
3491
|
+
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
|
|
3492
|
+
},
|
|
3493
|
+
acceptIdentity: this._acceptIdentity.bind(this),
|
|
3494
|
+
keyring: this.keyring
|
|
3495
|
+
});
|
|
3496
|
+
}
|
|
3497
|
+
async open() {
|
|
3498
|
+
(0, import_log14.log)("opening...", {}, {
|
|
3499
|
+
file: "service-context.ts",
|
|
3500
|
+
line: 94,
|
|
3501
|
+
scope: this,
|
|
3502
|
+
callSite: (f, a) => f(...a)
|
|
3503
|
+
});
|
|
3504
|
+
await this.networkManager.open();
|
|
3505
|
+
await this.spaceManager.open();
|
|
3506
|
+
await this.identityManager.open();
|
|
3507
|
+
if (this.identityManager.identity) {
|
|
3508
|
+
await this._initialize();
|
|
3509
|
+
}
|
|
3510
|
+
(0, import_log14.log)("opened", {}, {
|
|
3511
|
+
file: "service-context.ts",
|
|
3512
|
+
line: 101,
|
|
3513
|
+
scope: this,
|
|
3514
|
+
callSite: (f, a) => f(...a)
|
|
3515
|
+
});
|
|
3516
|
+
}
|
|
3517
|
+
async close() {
|
|
3518
|
+
var _a, _b;
|
|
3519
|
+
(0, import_log14.log)("closing...", {}, {
|
|
3520
|
+
file: "service-context.ts",
|
|
3521
|
+
line: 105,
|
|
3522
|
+
scope: this,
|
|
3523
|
+
callSite: (f, a) => f(...a)
|
|
3524
|
+
});
|
|
3525
|
+
await ((_a = this._deviceSpaceSync) == null ? void 0 : _a.close());
|
|
3526
|
+
await ((_b = this.dataSpaceManager) == null ? void 0 : _b.close());
|
|
3527
|
+
await this.identityManager.close();
|
|
3528
|
+
await this.spaceManager.close();
|
|
3529
|
+
await this.feedStore.close();
|
|
3530
|
+
await this.networkManager.close();
|
|
3531
|
+
this.dataServiceSubscriptions.clear();
|
|
3532
|
+
(0, import_log14.log)("closed", {}, {
|
|
3533
|
+
file: "service-context.ts",
|
|
3534
|
+
line: 113,
|
|
3535
|
+
scope: this,
|
|
3536
|
+
callSite: (f, a) => f(...a)
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
async reset() {
|
|
3540
|
+
(0, import_log14.log)("resetting...", {}, {
|
|
3541
|
+
file: "service-context.ts",
|
|
3542
|
+
line: 117,
|
|
3543
|
+
scope: this,
|
|
3544
|
+
callSite: (f, a) => f(...a)
|
|
3545
|
+
});
|
|
3546
|
+
await this.close();
|
|
3547
|
+
await this.storage.reset();
|
|
3548
|
+
(0, import_log14.log)("reset", {}, {
|
|
3549
|
+
file: "service-context.ts",
|
|
3550
|
+
line: 120,
|
|
3551
|
+
scope: this,
|
|
3552
|
+
callSite: (f, a) => f(...a)
|
|
3553
|
+
});
|
|
3554
|
+
}
|
|
3555
|
+
async createIdentity(params = {}) {
|
|
3556
|
+
const identity = await this.identityManager.createIdentity(params);
|
|
3557
|
+
await this._initialize();
|
|
3558
|
+
return identity;
|
|
3559
|
+
}
|
|
3560
|
+
async _acceptIdentity(params) {
|
|
3561
|
+
const identity = await this.identityManager.acceptIdentity(params);
|
|
3562
|
+
await this._initialize();
|
|
3563
|
+
return identity;
|
|
3564
|
+
}
|
|
3565
|
+
// Called when identity is created.
|
|
3566
|
+
async _initialize() {
|
|
3567
|
+
var _a;
|
|
3568
|
+
(0, import_log14.log)("initializing spaces...", {}, {
|
|
3569
|
+
file: "service-context.ts",
|
|
3570
|
+
line: 139,
|
|
3571
|
+
scope: this,
|
|
3572
|
+
callSite: (f, a) => f(...a)
|
|
3573
|
+
});
|
|
3574
|
+
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
|
|
3575
|
+
const signingContext = {
|
|
3576
|
+
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3577
|
+
identityKey: identity.identityKey,
|
|
3578
|
+
deviceKey: identity.deviceKey,
|
|
3579
|
+
profile: identity.profileDocument,
|
|
3580
|
+
recordCredential: async (credential) => {
|
|
3581
|
+
await identity.controlPipeline.writer.write({
|
|
3582
|
+
credential: {
|
|
3583
|
+
credential
|
|
3584
|
+
}
|
|
3585
|
+
});
|
|
3586
|
+
}
|
|
3587
|
+
};
|
|
3588
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.modelFactory, this.feedStore, this.snapshotStore);
|
|
3589
|
+
await this.dataSpaceManager.open();
|
|
3590
|
+
this.spaceInvitations = new SpaceInvitationsHandler(this.networkManager, this.dataSpaceManager, signingContext, this.keyring);
|
|
3591
|
+
this.initialized.wake();
|
|
3592
|
+
this._deviceSpaceSync = identity.space.spaceState.registerProcessor({
|
|
3593
|
+
process: async (credential) => {
|
|
3594
|
+
const assertion = (0, import_credentials11.getCredentialAssertion)(credential);
|
|
3595
|
+
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3596
|
+
return;
|
|
3597
|
+
}
|
|
3598
|
+
if (assertion.spaceKey.equals(identity.space.key)) {
|
|
3599
|
+
return;
|
|
3600
|
+
}
|
|
3601
|
+
if (!this.dataSpaceManager) {
|
|
3602
|
+
(0, import_log14.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3603
|
+
details: assertion
|
|
3604
|
+
}, {
|
|
3605
|
+
file: "service-context.ts",
|
|
3606
|
+
line: 182,
|
|
3607
|
+
scope: this,
|
|
3608
|
+
callSite: (f, a) => f(...a)
|
|
3609
|
+
});
|
|
3610
|
+
return;
|
|
3611
|
+
}
|
|
3612
|
+
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3613
|
+
(0, import_log14.log)("space already exists, ignoring space admission", {
|
|
3614
|
+
details: assertion
|
|
3615
|
+
}, {
|
|
3616
|
+
file: "service-context.ts",
|
|
3617
|
+
line: 186,
|
|
3618
|
+
scope: this,
|
|
3619
|
+
callSite: (f, a) => f(...a)
|
|
3620
|
+
});
|
|
3621
|
+
return;
|
|
3622
|
+
}
|
|
3623
|
+
try {
|
|
3624
|
+
(0, import_log14.log)("accepting space recorded in halo", {
|
|
3625
|
+
details: assertion
|
|
3626
|
+
}, {
|
|
3627
|
+
file: "service-context.ts",
|
|
3628
|
+
line: 191,
|
|
3629
|
+
scope: this,
|
|
3630
|
+
callSite: (f, a) => f(...a)
|
|
3631
|
+
});
|
|
3632
|
+
await this.dataSpaceManager.acceptSpace({
|
|
3633
|
+
spaceKey: assertion.spaceKey,
|
|
3634
|
+
genesisFeedKey: assertion.genesisFeedKey
|
|
3635
|
+
});
|
|
3636
|
+
} catch (err) {
|
|
3637
|
+
import_log14.log.catch(err, {}, {
|
|
3638
|
+
file: "service-context.ts",
|
|
3639
|
+
line: 197,
|
|
3640
|
+
scope: this,
|
|
3641
|
+
callSite: (f, a) => f(...a)
|
|
3642
|
+
});
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
});
|
|
3646
|
+
await this._deviceSpaceSync.open();
|
|
3647
|
+
}
|
|
3648
|
+
};
|
|
3649
|
+
|
|
3930
3650
|
// packages/sdk/client-services/src/packlets/services/service-registry.ts
|
|
3931
3651
|
var ServiceRegistry = class {
|
|
3932
3652
|
// prettier-ignore
|
|
3933
|
-
constructor(_serviceBundle, _handlers) {
|
|
3653
|
+
constructor(_serviceBundle, _handlers = {}) {
|
|
3934
3654
|
this._serviceBundle = _serviceBundle;
|
|
3935
3655
|
this._handlers = _handlers;
|
|
3936
3656
|
}
|
|
@@ -3943,28 +3663,35 @@ var ServiceRegistry = class {
|
|
|
3943
3663
|
setServices(services) {
|
|
3944
3664
|
this._handlers = services;
|
|
3945
3665
|
}
|
|
3666
|
+
addService(name, service) {
|
|
3667
|
+
this._handlers[name] = service;
|
|
3668
|
+
}
|
|
3669
|
+
removeService(name) {
|
|
3670
|
+
delete this._handlers[name];
|
|
3671
|
+
}
|
|
3946
3672
|
};
|
|
3947
3673
|
|
|
3948
3674
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3949
|
-
var createDefaultModelFactory = () => {
|
|
3950
|
-
return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
|
|
3951
|
-
};
|
|
3952
3675
|
var ClientServicesHost = class {
|
|
3953
3676
|
constructor({
|
|
3954
3677
|
config,
|
|
3955
|
-
modelFactory = createDefaultModelFactory(),
|
|
3678
|
+
modelFactory = (0, import_client6.createDefaultModelFactory)(),
|
|
3956
3679
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3957
3680
|
networkManager,
|
|
3958
|
-
storage
|
|
3681
|
+
storage,
|
|
3959
3682
|
// TODO(wittjosiah): Turn this on by default.
|
|
3960
3683
|
lockKey
|
|
3961
|
-
}) {
|
|
3962
|
-
this._statusUpdate = new
|
|
3684
|
+
} = {}) {
|
|
3685
|
+
this._statusUpdate = new import_async19.Event();
|
|
3963
3686
|
this._open = false;
|
|
3964
|
-
this._config = config;
|
|
3965
|
-
this._modelFactory = modelFactory;
|
|
3966
|
-
this._networkManager = networkManager;
|
|
3967
3687
|
this._storage = storage;
|
|
3688
|
+
this._modelFactory = modelFactory;
|
|
3689
|
+
if (config) {
|
|
3690
|
+
this.initialize({
|
|
3691
|
+
config,
|
|
3692
|
+
networkManager
|
|
3693
|
+
});
|
|
3694
|
+
}
|
|
3968
3695
|
this._resourceLock = lockKey ? new VaultResourceLock({
|
|
3969
3696
|
lockKey,
|
|
3970
3697
|
onAcquire: () => this.open(),
|
|
@@ -3973,41 +3700,66 @@ var ClientServicesHost = class {
|
|
|
3973
3700
|
this._systemService = new SystemServiceImpl({
|
|
3974
3701
|
config: this._config,
|
|
3975
3702
|
statusUpdate: this._statusUpdate,
|
|
3976
|
-
getCurrentStatus: () => this.isOpen ?
|
|
3703
|
+
getCurrentStatus: () => this.isOpen ? import_services8.SystemStatus.ACTIVE : import_services8.SystemStatus.INACTIVE,
|
|
3977
3704
|
onUpdateStatus: async (status) => {
|
|
3978
3705
|
var _a, _b;
|
|
3979
|
-
if (!this.isOpen && status ===
|
|
3706
|
+
if (!this.isOpen && status === import_services8.SystemStatus.ACTIVE) {
|
|
3980
3707
|
await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
|
|
3981
|
-
} else if (this.isOpen && status ===
|
|
3708
|
+
} else if (this.isOpen && status === import_services8.SystemStatus.INACTIVE) {
|
|
3982
3709
|
await ((_b = this._resourceLock) == null ? void 0 : _b.release());
|
|
3983
3710
|
}
|
|
3984
3711
|
},
|
|
3985
3712
|
onReset: async () => {
|
|
3986
|
-
(0,
|
|
3713
|
+
(0, import_node_assert12.default)(this._serviceContext, "service host is closed");
|
|
3987
3714
|
await this._serviceContext.reset();
|
|
3988
3715
|
}
|
|
3989
3716
|
});
|
|
3990
|
-
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
3717
|
+
this._serviceRegistry = new ServiceRegistry(import_client6.clientServiceBundle, {
|
|
3991
3718
|
SystemService: this._systemService
|
|
3992
3719
|
});
|
|
3993
3720
|
}
|
|
3994
3721
|
get isOpen() {
|
|
3995
3722
|
return this._open;
|
|
3996
3723
|
}
|
|
3724
|
+
get serviceRegistry() {
|
|
3725
|
+
return this._serviceRegistry;
|
|
3726
|
+
}
|
|
3997
3727
|
get descriptors() {
|
|
3998
3728
|
return this._serviceRegistry.descriptors;
|
|
3999
3729
|
}
|
|
4000
3730
|
get services() {
|
|
4001
3731
|
return this._serviceRegistry.services;
|
|
4002
3732
|
}
|
|
3733
|
+
/**
|
|
3734
|
+
* Initialize the service host with the config.
|
|
3735
|
+
* Config can also be provided in the constructor.
|
|
3736
|
+
* Can only be called once.
|
|
3737
|
+
*/
|
|
3738
|
+
initialize({ config, networkManager }) {
|
|
3739
|
+
(0, import_node_assert12.default)(!this._open, "service host is open");
|
|
3740
|
+
if (config) {
|
|
3741
|
+
(0, import_node_assert12.default)(!this._config, "config already set");
|
|
3742
|
+
this._config = config;
|
|
3743
|
+
if (!this._storage) {
|
|
3744
|
+
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3747
|
+
if (networkManager) {
|
|
3748
|
+
(0, import_node_assert12.default)(!this._networkManager, "network manager already set");
|
|
3749
|
+
this._networkManager = networkManager;
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
4003
3752
|
async open() {
|
|
4004
3753
|
var _a, _b;
|
|
4005
3754
|
if (this._open) {
|
|
4006
3755
|
return;
|
|
4007
3756
|
}
|
|
4008
|
-
(0,
|
|
3757
|
+
(0, import_node_assert12.default)(this._config, "config not set");
|
|
3758
|
+
(0, import_node_assert12.default)(this._storage, "storage not set");
|
|
3759
|
+
(0, import_node_assert12.default)(this._networkManager, "network manager not set");
|
|
3760
|
+
(0, import_log15.log)("opening...", {}, {
|
|
4009
3761
|
file: "service-host.ts",
|
|
4010
|
-
line:
|
|
3762
|
+
line: 166,
|
|
4011
3763
|
scope: this,
|
|
4012
3764
|
callSite: (f, a) => f(...a)
|
|
4013
3765
|
});
|
|
@@ -4020,10 +3772,10 @@ var ClientServicesHost = class {
|
|
|
4020
3772
|
DeviceInvitationsService: new DeviceInvitationsServiceImpl(this._serviceContext.identityManager, this._serviceContext.deviceInvitations),
|
|
4021
3773
|
SpaceInvitationsService: new SpaceInvitationsServiceImpl(this._serviceContext.identityManager, () => {
|
|
4022
3774
|
var _a2;
|
|
4023
|
-
return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 : (0,
|
|
3775
|
+
return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceInvitations not initialized"));
|
|
4024
3776
|
}, () => {
|
|
4025
3777
|
var _a2;
|
|
4026
|
-
return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : (0,
|
|
3778
|
+
return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceManager not initialized"));
|
|
4027
3779
|
}),
|
|
4028
3780
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
4029
3781
|
await this._serviceContext.initialized.wait();
|
|
@@ -4043,11 +3795,11 @@ var ClientServicesHost = class {
|
|
|
4043
3795
|
this._open = true;
|
|
4044
3796
|
this._statusUpdate.emit();
|
|
4045
3797
|
const deviceKey = (_b = this._serviceContext.identityManager.identity) == null ? void 0 : _b.deviceKey;
|
|
4046
|
-
(0,
|
|
3798
|
+
(0, import_log15.log)("opened", {
|
|
4047
3799
|
deviceKey
|
|
4048
3800
|
}, {
|
|
4049
3801
|
file: "service-host.ts",
|
|
4050
|
-
line:
|
|
3802
|
+
line: 219,
|
|
4051
3803
|
scope: this,
|
|
4052
3804
|
callSite: (f, a) => f(...a)
|
|
4053
3805
|
});
|
|
@@ -4058,11 +3810,11 @@ var ClientServicesHost = class {
|
|
|
4058
3810
|
return;
|
|
4059
3811
|
}
|
|
4060
3812
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
4061
|
-
(0,
|
|
3813
|
+
(0, import_log15.log)("closing...", {
|
|
4062
3814
|
deviceKey
|
|
4063
3815
|
}, {
|
|
4064
3816
|
file: "service-host.ts",
|
|
4065
|
-
line:
|
|
3817
|
+
line: 228,
|
|
4066
3818
|
scope: this,
|
|
4067
3819
|
callSite: (f, a) => f(...a)
|
|
4068
3820
|
});
|
|
@@ -4072,49 +3824,17 @@ var ClientServicesHost = class {
|
|
|
4072
3824
|
await this._serviceContext.close();
|
|
4073
3825
|
this._open = false;
|
|
4074
3826
|
this._statusUpdate.emit();
|
|
4075
|
-
(0,
|
|
3827
|
+
(0, import_log15.log)("closed", {
|
|
4076
3828
|
deviceKey
|
|
4077
3829
|
}, {
|
|
4078
3830
|
file: "service-host.ts",
|
|
4079
|
-
line:
|
|
3831
|
+
line: 233,
|
|
4080
3832
|
scope: this,
|
|
4081
3833
|
callSite: (f, a) => f(...a)
|
|
4082
3834
|
});
|
|
4083
3835
|
}
|
|
4084
3836
|
};
|
|
4085
3837
|
|
|
4086
|
-
// packages/sdk/client-services/src/packlets/services/service-proxy.ts
|
|
4087
|
-
var import_async23 = require("@dxos/async");
|
|
4088
|
-
var import_errors2 = require("@dxos/errors");
|
|
4089
|
-
var import_rpc7 = require("@dxos/rpc");
|
|
4090
|
-
var ClientServicesProxy = class {
|
|
4091
|
-
// prettier-ignore
|
|
4092
|
-
constructor(port, _timeout = 3e4) {
|
|
4093
|
-
this._timeout = _timeout;
|
|
4094
|
-
this._proxy = (0, import_rpc7.createProtoRpcPeer)({
|
|
4095
|
-
requested: clientServiceBundle,
|
|
4096
|
-
exposed: {},
|
|
4097
|
-
handlers: {},
|
|
4098
|
-
port
|
|
4099
|
-
});
|
|
4100
|
-
}
|
|
4101
|
-
get proxy() {
|
|
4102
|
-
return this._proxy;
|
|
4103
|
-
}
|
|
4104
|
-
get descriptors() {
|
|
4105
|
-
return clientServiceBundle;
|
|
4106
|
-
}
|
|
4107
|
-
get services() {
|
|
4108
|
-
return this._proxy.rpc;
|
|
4109
|
-
}
|
|
4110
|
-
async open() {
|
|
4111
|
-
await (0, import_async23.asyncTimeout)(this._proxy.open(), this._timeout, new import_errors2.RemoteServiceConnectionTimeout());
|
|
4112
|
-
}
|
|
4113
|
-
async close() {
|
|
4114
|
-
await this._proxy.close();
|
|
4115
|
-
}
|
|
4116
|
-
};
|
|
4117
|
-
|
|
4118
3838
|
// packages/sdk/client-services/src/packlets/services/local-client-services.ts
|
|
4119
3839
|
var LocalClientServices = class {
|
|
4120
3840
|
constructor(params) {
|
|
@@ -4126,6 +3846,9 @@ var LocalClientServices = class {
|
|
|
4126
3846
|
get services() {
|
|
4127
3847
|
return this._host.services;
|
|
4128
3848
|
}
|
|
3849
|
+
get host() {
|
|
3850
|
+
return this._host;
|
|
3851
|
+
}
|
|
4129
3852
|
async open() {
|
|
4130
3853
|
await this._host.open();
|
|
4131
3854
|
}
|
|
@@ -4133,58 +3856,77 @@ var LocalClientServices = class {
|
|
|
4133
3856
|
await this._host.close();
|
|
4134
3857
|
}
|
|
4135
3858
|
};
|
|
3859
|
+
|
|
3860
|
+
// packages/sdk/client-services/src/packlets/services/utils.ts
|
|
3861
|
+
var import_config2 = require("@dxos/config");
|
|
3862
|
+
var import_log16 = require("@dxos/log");
|
|
3863
|
+
var import_messaging3 = require("@dxos/messaging");
|
|
3864
|
+
var import_network_manager6 = require("@dxos/network-manager");
|
|
3865
|
+
var fromHost = (config = new import_config2.Config()) => {
|
|
3866
|
+
return new LocalClientServices({
|
|
3867
|
+
config,
|
|
3868
|
+
networkManager: createNetworkManager(config)
|
|
3869
|
+
});
|
|
3870
|
+
};
|
|
3871
|
+
var createNetworkManager = (config, options = {}) => {
|
|
3872
|
+
const signalServer = config.get("runtime.services.signal.server");
|
|
3873
|
+
if (signalServer) {
|
|
3874
|
+
const { log: log1 = true, signalManager = new import_messaging3.WebsocketSignalManager([
|
|
3875
|
+
signalServer
|
|
3876
|
+
]), transportFactory = (0, import_network_manager6.createWebRTCTransportFactory)({
|
|
3877
|
+
iceServers: config.get("runtime.services.ice")
|
|
3878
|
+
}) } = options;
|
|
3879
|
+
return new import_network_manager6.NetworkManager({
|
|
3880
|
+
log: log1,
|
|
3881
|
+
signalManager,
|
|
3882
|
+
transportFactory
|
|
3883
|
+
});
|
|
3884
|
+
}
|
|
3885
|
+
import_log16.log.warn("P2P network is not configured.", {}, {
|
|
3886
|
+
file: "utils.ts",
|
|
3887
|
+
line: 48,
|
|
3888
|
+
scope: void 0,
|
|
3889
|
+
callSite: (f, a) => f(...a)
|
|
3890
|
+
});
|
|
3891
|
+
return new import_network_manager6.NetworkManager({
|
|
3892
|
+
signalManager: new import_messaging3.MemorySignalManager(new import_messaging3.MemorySignalManagerContext()),
|
|
3893
|
+
transportFactory: import_network_manager6.MemoryTransportFactory
|
|
3894
|
+
});
|
|
3895
|
+
};
|
|
4136
3896
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4137
3897
|
0 && (module.exports = {
|
|
4138
|
-
AUTHENTICATION_CODE_LENGTH,
|
|
4139
|
-
AbstractInvitationsHandler,
|
|
4140
|
-
AbstractInvitationsProxy,
|
|
4141
3898
|
AbstractInvitationsService,
|
|
4142
|
-
AuthenticatingInvitationProvider,
|
|
4143
3899
|
ClientServicesHost,
|
|
4144
|
-
ClientServicesProxy,
|
|
4145
3900
|
DeviceInvitationsHandler,
|
|
4146
|
-
DeviceInvitationsProxy,
|
|
4147
3901
|
DeviceInvitationsServiceImpl,
|
|
4148
3902
|
DevtoolsHostEvents,
|
|
4149
3903
|
DevtoolsServiceImpl,
|
|
4150
3904
|
IFrameHostRuntime,
|
|
4151
3905
|
IFrameProxyRuntime,
|
|
4152
|
-
INVITATION_TIMEOUT,
|
|
4153
3906
|
Identity,
|
|
4154
3907
|
IdentityManager,
|
|
4155
3908
|
IdentityServiceImpl,
|
|
4156
|
-
InvitationEncoder,
|
|
4157
|
-
InvitationObservableProvider,
|
|
4158
3909
|
LocalClientServices,
|
|
4159
3910
|
MemoryShellRuntime,
|
|
4160
|
-
ON_CLOSE_DELAY,
|
|
4161
3911
|
ServiceContext,
|
|
4162
3912
|
ServiceRegistry,
|
|
4163
|
-
ShellController,
|
|
4164
3913
|
ShellRuntimeImpl,
|
|
4165
3914
|
SpaceInvitationsHandler,
|
|
4166
|
-
SpaceInvitationsProxy,
|
|
4167
3915
|
SpaceInvitationsServiceImpl,
|
|
4168
3916
|
TrustedKeySetAuthVerifier,
|
|
4169
3917
|
VaultResourceLock,
|
|
4170
3918
|
WorkerRuntime,
|
|
4171
3919
|
WorkerSession,
|
|
4172
|
-
appServiceBundle,
|
|
4173
|
-
clientServiceBundle,
|
|
4174
3920
|
createAuthProvider,
|
|
4175
|
-
createDefaultModelFactory,
|
|
4176
3921
|
createStorageObjects,
|
|
3922
|
+
fromHost,
|
|
4177
3923
|
getNetworkPeers,
|
|
4178
|
-
iframeServiceBundle,
|
|
4179
|
-
shellServiceBundle,
|
|
4180
3924
|
subscribeToFeedBlocks,
|
|
4181
3925
|
subscribeToFeeds,
|
|
4182
3926
|
subscribeToNetworkStatus,
|
|
4183
3927
|
subscribeToNetworkTopics,
|
|
4184
3928
|
subscribeToSignal,
|
|
4185
3929
|
subscribeToSpaces,
|
|
4186
|
-
subscribeToSwarmInfo
|
|
4187
|
-
workerServiceBundle,
|
|
4188
|
-
wrapObservable
|
|
3930
|
+
subscribeToSwarmInfo
|
|
4189
3931
|
});
|
|
4190
3932
|
//# sourceMappingURL=index.cjs.map
|