@dxos/client-services 0.1.30-next.7c60cd3 → 0.1.30
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-DFO3FW2W.mjs} +949 -1150
- package/dist/lib/browser/chunk-DFO3FW2W.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 +221 -50
- package/dist/lib/browser/packlets/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +837 -1062
- 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 +2937 -2719
- 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/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +8 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- 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/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +4 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/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 +32 -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/tests/text.test.d.ts +2 -0
- package/dist/types/src/packlets/tests/text.test.d.ts.map +1 -0
- package/dist/types/src/packlets/vault/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 +31 -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 +64 -4
- package/src/packlets/spaces/data-space-manager.ts +11 -7
- package/src/packlets/spaces/data-space.ts +13 -1
- package/src/packlets/spaces/index.ts +2 -0
- package/src/packlets/spaces/notarization-plugin.ts +9 -2
- package/src/packlets/spaces/spaces-service.ts +25 -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 +156 -138
- 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 +64 -0
- package/src/packlets/tests/spaces.test.ts +136 -0
- package/src/packlets/tests/text.test.ts +206 -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
|
|
2172
|
-
var
|
|
2022
|
+
var import_log8 = require("@dxos/log");
|
|
2023
|
+
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
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,20 +2033,21 @@ 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;
|
|
2045
|
+
var SUCCESS_DELAY = 1e3;
|
|
2194
2046
|
var NOTARIZE_TIMEOUT = 1e4;
|
|
2195
2047
|
var NotarizationPlugin = class {
|
|
2196
2048
|
constructor() {
|
|
2197
2049
|
this._ctx = new import_context5.Context();
|
|
2198
|
-
this._extensionOpened = new
|
|
2050
|
+
this._extensionOpened = new import_async9.Event();
|
|
2199
2051
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2200
2052
|
this._processedCredentials = new import_util3.ComplexSet(import_keys6.PublicKey.hash);
|
|
2201
2053
|
this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys6.PublicKey.hash);
|
|
@@ -2209,23 +2061,23 @@ var NotarizationPlugin = class {
|
|
|
2209
2061
|
* Request credentials to be notarized.
|
|
2210
2062
|
*/
|
|
2211
2063
|
async notarize(credentials) {
|
|
2212
|
-
(0,
|
|
2064
|
+
(0, import_log7.log)("notarize", {
|
|
2213
2065
|
credentials
|
|
2214
2066
|
}, {
|
|
2215
2067
|
file: "notarization-plugin.ts",
|
|
2216
|
-
line:
|
|
2068
|
+
line: 50,
|
|
2217
2069
|
scope: this,
|
|
2218
2070
|
callSite: (f, a) => f(...a)
|
|
2219
2071
|
});
|
|
2220
|
-
(0,
|
|
2221
|
-
const errors = new
|
|
2072
|
+
(0, import_node_assert8.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2073
|
+
const errors = new import_async9.Trigger();
|
|
2222
2074
|
const ctx = this._ctx.derive({
|
|
2223
2075
|
onError: (err) => {
|
|
2224
|
-
|
|
2076
|
+
import_log7.log.warn("Notarization error", {
|
|
2225
2077
|
err
|
|
2226
2078
|
}, {
|
|
2227
2079
|
file: "notarization-plugin.ts",
|
|
2228
|
-
line:
|
|
2080
|
+
line: 59,
|
|
2229
2081
|
scope: this,
|
|
2230
2082
|
callSite: (f, a) => f(...a)
|
|
2231
2083
|
});
|
|
@@ -2233,24 +2085,24 @@ var NotarizationPlugin = class {
|
|
|
2233
2085
|
errors.throw(err);
|
|
2234
2086
|
}
|
|
2235
2087
|
});
|
|
2236
|
-
(0,
|
|
2237
|
-
|
|
2088
|
+
(0, import_async9.scheduleTask)(ctx, () => {
|
|
2089
|
+
import_log7.log.warn("Notarization timeout", {}, {
|
|
2238
2090
|
file: "notarization-plugin.ts",
|
|
2239
|
-
line:
|
|
2091
|
+
line: 67,
|
|
2240
2092
|
scope: this,
|
|
2241
2093
|
callSite: (f, a) => f(...a)
|
|
2242
2094
|
});
|
|
2243
2095
|
void ctx.dispose();
|
|
2244
|
-
errors.throw(new
|
|
2096
|
+
errors.throw(new import_async9.TimeoutError(NOTARIZE_TIMEOUT, "Notarization timed out"));
|
|
2245
2097
|
}, NOTARIZE_TIMEOUT);
|
|
2246
2098
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
2247
2099
|
const peersTried = /* @__PURE__ */ new Set();
|
|
2248
|
-
const notarizeTask = new
|
|
2100
|
+
const notarizeTask = new import_async9.DeferredTask(ctx, async () => {
|
|
2249
2101
|
try {
|
|
2250
2102
|
if (this._extensions.size === 0) {
|
|
2251
|
-
|
|
2103
|
+
import_log7.log.warn("No peers to notarize with", {}, {
|
|
2252
2104
|
file: "notarization-plugin.ts",
|
|
2253
|
-
line:
|
|
2105
|
+
line: 82,
|
|
2254
2106
|
scope: this,
|
|
2255
2107
|
callSite: (f, a) => f(...a)
|
|
2256
2108
|
});
|
|
@@ -2260,41 +2112,42 @@ var NotarizationPlugin = class {
|
|
|
2260
2112
|
...this._extensions
|
|
2261
2113
|
].find((peer2) => !peersTried.has(peer2));
|
|
2262
2114
|
if (!peer) {
|
|
2263
|
-
|
|
2115
|
+
import_log7.log.warn("Exhausted all peers to notarize with", {
|
|
2264
2116
|
retryIn: RETRY_TIMEOUT
|
|
2265
2117
|
}, {
|
|
2266
2118
|
file: "notarization-plugin.ts",
|
|
2267
|
-
line:
|
|
2119
|
+
line: 89,
|
|
2268
2120
|
scope: this,
|
|
2269
2121
|
callSite: (f, a) => f(...a)
|
|
2270
2122
|
});
|
|
2271
2123
|
peersTried.clear();
|
|
2272
|
-
(0,
|
|
2124
|
+
(0, import_async9.scheduleTask)(ctx, () => notarizeTask.schedule(), RETRY_TIMEOUT);
|
|
2273
2125
|
return;
|
|
2274
2126
|
}
|
|
2275
2127
|
peersTried.add(peer);
|
|
2276
|
-
(0,
|
|
2128
|
+
(0, import_log7.log)("try notarizing", {
|
|
2277
2129
|
peer: peer.localPeerId,
|
|
2278
2130
|
credentialId: credentials.map((credential) => credential.id)
|
|
2279
2131
|
}, {
|
|
2280
2132
|
file: "notarization-plugin.ts",
|
|
2281
|
-
line:
|
|
2133
|
+
line: 96,
|
|
2282
2134
|
scope: this,
|
|
2283
2135
|
callSite: (f, a) => f(...a)
|
|
2284
2136
|
});
|
|
2285
2137
|
await peer.rpc.NotarizationService.notarize({
|
|
2286
2138
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2287
2139
|
});
|
|
2288
|
-
(0,
|
|
2140
|
+
(0, import_log7.log)("success", {}, {
|
|
2289
2141
|
file: "notarization-plugin.ts",
|
|
2290
|
-
line:
|
|
2142
|
+
line: 100,
|
|
2291
2143
|
scope: this,
|
|
2292
2144
|
callSite: (f, a) => f(...a)
|
|
2293
2145
|
});
|
|
2146
|
+
await (0, import_async9.sleep)(SUCCESS_DELAY);
|
|
2294
2147
|
} catch (err) {
|
|
2295
|
-
|
|
2148
|
+
import_log7.log.warn("error notarizing (recoverable)", err, {
|
|
2296
2149
|
file: "notarization-plugin.ts",
|
|
2297
|
-
line:
|
|
2150
|
+
line: 103,
|
|
2298
2151
|
scope: this,
|
|
2299
2152
|
callSite: (f, a) => f(...a)
|
|
2300
2153
|
});
|
|
@@ -2308,9 +2161,9 @@ var NotarizationPlugin = class {
|
|
|
2308
2161
|
allNotarized,
|
|
2309
2162
|
errors.wait()
|
|
2310
2163
|
]);
|
|
2311
|
-
(0,
|
|
2164
|
+
(0, import_log7.log)("done", {}, {
|
|
2312
2165
|
file: "notarization-plugin.ts",
|
|
2313
|
-
line:
|
|
2166
|
+
line: 114,
|
|
2314
2167
|
scope: this,
|
|
2315
2168
|
callSite: (f, a) => f(...a)
|
|
2316
2169
|
});
|
|
@@ -2331,14 +2184,14 @@ var NotarizationPlugin = class {
|
|
|
2331
2184
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2332
2185
|
}
|
|
2333
2186
|
setWriter(writer) {
|
|
2334
|
-
(0,
|
|
2187
|
+
(0, import_node_assert8.default)(!this._writer, "Writer already set.");
|
|
2335
2188
|
this._writer = writer;
|
|
2336
2189
|
}
|
|
2337
2190
|
async _waitUntilProcessed(id) {
|
|
2338
2191
|
if (this._processedCredentials.has(id)) {
|
|
2339
2192
|
return;
|
|
2340
2193
|
}
|
|
2341
|
-
await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new
|
|
2194
|
+
await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new import_async9.Trigger()).value.wait();
|
|
2342
2195
|
}
|
|
2343
2196
|
/**
|
|
2344
2197
|
* Requests from other peers to notarize credentials.
|
|
@@ -2349,7 +2202,7 @@ var NotarizationPlugin = class {
|
|
|
2349
2202
|
throw new Error("Writer not set");
|
|
2350
2203
|
}
|
|
2351
2204
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2352
|
-
(0,
|
|
2205
|
+
(0, import_node_assert8.default)(credential.id, "Credential must have an id");
|
|
2353
2206
|
if (this._processedCredentials.has(credential.id)) {
|
|
2354
2207
|
continue;
|
|
2355
2208
|
}
|
|
@@ -2359,11 +2212,11 @@ var NotarizationPlugin = class {
|
|
|
2359
2212
|
createExtension() {
|
|
2360
2213
|
const extension = new NotarizationTeleportExtension({
|
|
2361
2214
|
onOpen: async () => {
|
|
2362
|
-
(0,
|
|
2215
|
+
(0, import_log7.log)("extension opened", {
|
|
2363
2216
|
peer: extension.localPeerId
|
|
2364
2217
|
}, {
|
|
2365
2218
|
file: "notarization-plugin.ts",
|
|
2366
|
-
line:
|
|
2219
|
+
line: 163,
|
|
2367
2220
|
scope: this,
|
|
2368
2221
|
callSite: (f, a) => f(...a)
|
|
2369
2222
|
});
|
|
@@ -2371,11 +2224,11 @@ var NotarizationPlugin = class {
|
|
|
2371
2224
|
this._extensionOpened.emit();
|
|
2372
2225
|
},
|
|
2373
2226
|
onClose: async () => {
|
|
2374
|
-
(0,
|
|
2227
|
+
(0, import_log7.log)("extension closed", {
|
|
2375
2228
|
peer: extension.localPeerId
|
|
2376
2229
|
}, {
|
|
2377
2230
|
file: "notarization-plugin.ts",
|
|
2378
|
-
line:
|
|
2231
|
+
line: 168,
|
|
2379
2232
|
scope: this,
|
|
2380
2233
|
callSite: (f, a) => f(...a)
|
|
2381
2234
|
});
|
|
@@ -2390,10 +2243,10 @@ var NotarizationTeleportExtension = class extends import_teleport3.RpcExtension
|
|
|
2390
2243
|
constructor(_params) {
|
|
2391
2244
|
super({
|
|
2392
2245
|
requested: {
|
|
2393
|
-
NotarizationService:
|
|
2246
|
+
NotarizationService: import_protocols4.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2394
2247
|
},
|
|
2395
2248
|
exposed: {
|
|
2396
|
-
NotarizationService:
|
|
2249
|
+
NotarizationService: import_protocols4.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2397
2250
|
}
|
|
2398
2251
|
});
|
|
2399
2252
|
this._params = _params;
|
|
@@ -2434,6 +2287,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2434
2287
|
constructor(params) {
|
|
2435
2288
|
this._ctx = new import_context6.Context();
|
|
2436
2289
|
this._inner = params.inner;
|
|
2290
|
+
this._gossip = params.gossip;
|
|
2437
2291
|
this._presence = params.presence;
|
|
2438
2292
|
this._keyring = params.keyring;
|
|
2439
2293
|
this._feedStore = params.feedStore;
|
|
@@ -2490,6 +2344,12 @@ var DataSpace = class DataSpace2 {
|
|
|
2490
2344
|
await this.notarizationPlugin.close();
|
|
2491
2345
|
await this._presence.destroy();
|
|
2492
2346
|
}
|
|
2347
|
+
async postMessage(channel, message) {
|
|
2348
|
+
return this._gossip.postMessage(channel, message);
|
|
2349
|
+
}
|
|
2350
|
+
listen(channel, callback) {
|
|
2351
|
+
return this._gossip.listen(channel, callback);
|
|
2352
|
+
}
|
|
2493
2353
|
async initializeDataPipeline() {
|
|
2494
2354
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2495
2355
|
timeout: CONTROL_PIPELINE_READY_TIMEFRAME
|
|
@@ -2546,7 +2406,7 @@ __decorate([
|
|
|
2546
2406
|
(0, import_debug3.timed)(1e4)
|
|
2547
2407
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2548
2408
|
DataSpace = __decorate([
|
|
2549
|
-
(0,
|
|
2409
|
+
(0, import_async10.trackLeaks)("open", "close")
|
|
2550
2410
|
], DataSpace);
|
|
2551
2411
|
|
|
2552
2412
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
@@ -2572,7 +2432,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2572
2432
|
this._feedStore = _feedStore;
|
|
2573
2433
|
this._snapshotStore = _snapshotStore;
|
|
2574
2434
|
this._ctx = new import_context7.Context();
|
|
2575
|
-
this.updated = new
|
|
2435
|
+
this.updated = new import_async11.Event();
|
|
2576
2436
|
this._spaces = new import_util5.ComplexMap(import_keys8.PublicKey.hash);
|
|
2577
2437
|
}
|
|
2578
2438
|
// TODO(burdon): Remove.
|
|
@@ -2581,7 +2441,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2581
2441
|
}
|
|
2582
2442
|
async open() {
|
|
2583
2443
|
await this._metadataStore.load();
|
|
2584
|
-
(0,
|
|
2444
|
+
(0, import_log8.log)("metadata loaded", {
|
|
2585
2445
|
spaces: this._metadataStore.spaces.length
|
|
2586
2446
|
}, {
|
|
2587
2447
|
file: "data-space-manager.ts",
|
|
@@ -2590,7 +2450,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2590
2450
|
callSite: (f, a) => f(...a)
|
|
2591
2451
|
});
|
|
2592
2452
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2593
|
-
(0,
|
|
2453
|
+
(0, import_log8.log)("load space", {
|
|
2594
2454
|
spaceMetadata
|
|
2595
2455
|
}, {
|
|
2596
2456
|
file: "data-space-manager.ts",
|
|
@@ -2601,7 +2461,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2601
2461
|
const space = await this._constructSpace(spaceMetadata);
|
|
2602
2462
|
await space.initializeDataPipeline();
|
|
2603
2463
|
if (spaceMetadata.dataTimeframe) {
|
|
2604
|
-
(0,
|
|
2464
|
+
(0, import_log8.log)("waiting for latest timeframe", {
|
|
2605
2465
|
spaceMetadata
|
|
2606
2466
|
}, {
|
|
2607
2467
|
file: "data-space-manager.ts",
|
|
@@ -2636,7 +2496,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2636
2496
|
controlFeedKey,
|
|
2637
2497
|
dataFeedKey
|
|
2638
2498
|
};
|
|
2639
|
-
(0,
|
|
2499
|
+
(0, import_log8.log)("creating space...", {
|
|
2640
2500
|
spaceKey
|
|
2641
2501
|
}, {
|
|
2642
2502
|
file: "data-space-manager.ts",
|
|
@@ -2648,7 +2508,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2648
2508
|
const credentials = await (0, import_echo_pipeline2.spaceGenesis)(this._keyring, this._signingContext, space.inner);
|
|
2649
2509
|
await this._metadataStore.addSpace(metadata);
|
|
2650
2510
|
const memberCredential = credentials[1];
|
|
2651
|
-
(0,
|
|
2511
|
+
(0, import_node_assert9.default)((0, import_credentials10.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2652
2512
|
await this._signingContext.recordCredential(memberCredential);
|
|
2653
2513
|
await space.initializeDataPipeline();
|
|
2654
2514
|
this._dataServiceSubscriptions.registerSpace(space.key, space.dataPipelineController.databaseBackend.createDataServiceHost());
|
|
@@ -2657,7 +2517,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2657
2517
|
}
|
|
2658
2518
|
// TODO(burdon): Rename join space.
|
|
2659
2519
|
async acceptSpace(opts) {
|
|
2660
|
-
(0,
|
|
2520
|
+
(0, import_node_assert9.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2661
2521
|
const metadata = {
|
|
2662
2522
|
key: opts.spaceKey,
|
|
2663
2523
|
genesisFeedKey: opts.genesisFeedKey
|
|
@@ -2670,11 +2530,14 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2670
2530
|
return space;
|
|
2671
2531
|
}
|
|
2672
2532
|
async _constructSpace(metadata) {
|
|
2673
|
-
const
|
|
2674
|
-
localPeerId: this._signingContext.deviceKey
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2533
|
+
const gossip = new import_teleport_extension_gossip.Gossip({
|
|
2534
|
+
localPeerId: this._signingContext.deviceKey
|
|
2535
|
+
});
|
|
2536
|
+
const presence = new import_teleport_extension_gossip.Presence({
|
|
2537
|
+
announceInterval: 500,
|
|
2538
|
+
offlineTimeout: 5e3,
|
|
2539
|
+
identityKey: this._signingContext.identityKey,
|
|
2540
|
+
gossip
|
|
2678
2541
|
});
|
|
2679
2542
|
const snapshotManager = new import_echo_pipeline2.SnapshotManager(this._snapshotStore);
|
|
2680
2543
|
const controlFeed = metadata.controlFeedKey && await this._feedStore.openFeed(metadata.controlFeedKey, {
|
|
@@ -2691,7 +2554,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2691
2554
|
credentialAuthenticator: (0, import_util5.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
2692
2555
|
},
|
|
2693
2556
|
onNetworkConnection: (session) => {
|
|
2694
|
-
session.addExtension("dxos.mesh.teleport.
|
|
2557
|
+
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
2695
2558
|
remotePeerId: session.remotePeerId
|
|
2696
2559
|
}));
|
|
2697
2560
|
session.addExtension("dxos.mesh.teleport.objectsync", snapshotManager.objectSync.createExtension());
|
|
@@ -2705,6 +2568,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2705
2568
|
modelFactory: this._modelFactory,
|
|
2706
2569
|
metadataStore: this._metadataStore,
|
|
2707
2570
|
snapshotManager,
|
|
2571
|
+
gossip,
|
|
2708
2572
|
presence,
|
|
2709
2573
|
memberKey: this._signingContext.identityKey,
|
|
2710
2574
|
keyring: this._keyring,
|
|
@@ -2718,327 +2582,28 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2718
2582
|
}
|
|
2719
2583
|
};
|
|
2720
2584
|
__decorate2([
|
|
2721
|
-
|
|
2585
|
+
import_async11.synchronized
|
|
2722
2586
|
], DataSpaceManager.prototype, "open", null);
|
|
2723
2587
|
__decorate2([
|
|
2724
|
-
|
|
2588
|
+
import_async11.synchronized
|
|
2725
2589
|
], DataSpaceManager.prototype, "close", null);
|
|
2726
2590
|
__decorate2([
|
|
2727
|
-
|
|
2591
|
+
import_async11.synchronized
|
|
2728
2592
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2729
2593
|
__decorate2([
|
|
2730
|
-
|
|
2594
|
+
import_async11.synchronized
|
|
2731
2595
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2732
2596
|
DataSpaceManager = __decorate2([
|
|
2733
|
-
(0,
|
|
2597
|
+
(0, import_async11.trackLeaks)("open", "close")
|
|
2734
2598
|
], DataSpaceManager);
|
|
2735
2599
|
|
|
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
2600
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
3036
|
-
var
|
|
2601
|
+
var import_async12 = require("@dxos/async");
|
|
3037
2602
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
3038
|
-
var
|
|
3039
|
-
var
|
|
3040
|
-
var
|
|
3041
|
-
var
|
|
2603
|
+
var import_debug4 = require("@dxos/debug");
|
|
2604
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
2605
|
+
var import_log9 = require("@dxos/log");
|
|
2606
|
+
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3042
2607
|
var import_util6 = require("@dxos/util");
|
|
3043
2608
|
var SpacesServiceImpl = class {
|
|
3044
2609
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
@@ -3056,18 +2621,18 @@ var SpacesServiceImpl = class {
|
|
|
3056
2621
|
return this._transformSpace(space);
|
|
3057
2622
|
}
|
|
3058
2623
|
async updateSpace(request) {
|
|
3059
|
-
(0,
|
|
2624
|
+
(0, import_debug4.todo)();
|
|
3060
2625
|
}
|
|
3061
2626
|
querySpaces() {
|
|
3062
2627
|
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
3063
2628
|
const onUpdate = async () => {
|
|
3064
2629
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3065
2630
|
const spaces = Array.from(dataSpaceManager.spaces.values()).filter((space) => this._dataServiceSubscriptions.getDataService(space.key)).map((space) => this._transformSpace(space));
|
|
3066
|
-
(0,
|
|
2631
|
+
(0, import_log9.log)("update", {
|
|
3067
2632
|
spaces
|
|
3068
2633
|
}, {
|
|
3069
2634
|
file: "spaces-service.ts",
|
|
3070
|
-
line:
|
|
2635
|
+
line: 62,
|
|
3071
2636
|
scope: this,
|
|
3072
2637
|
callSite: (f, a) => f(...a)
|
|
3073
2638
|
});
|
|
@@ -3077,7 +2642,7 @@ var SpacesServiceImpl = class {
|
|
|
3077
2642
|
};
|
|
3078
2643
|
setTimeout(async () => {
|
|
3079
2644
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3080
|
-
const subscriptions = new
|
|
2645
|
+
const subscriptions = new import_async12.EventSubscriptions();
|
|
3081
2646
|
const subscribeSpaces = () => {
|
|
3082
2647
|
subscriptions.clear();
|
|
3083
2648
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
@@ -3093,7 +2658,7 @@ var SpacesServiceImpl = class {
|
|
|
3093
2658
|
void onUpdate();
|
|
3094
2659
|
});
|
|
3095
2660
|
ctx.onDispose(() => subscriptions.clear());
|
|
3096
|
-
(0,
|
|
2661
|
+
(0, import_async12.scheduleTask)(ctx, () => {
|
|
3097
2662
|
subscribeSpaces();
|
|
3098
2663
|
void onUpdate();
|
|
3099
2664
|
});
|
|
@@ -3105,22 +2670,41 @@ var SpacesServiceImpl = class {
|
|
|
3105
2670
|
}
|
|
3106
2671
|
});
|
|
3107
2672
|
}
|
|
2673
|
+
async postMessage({ spaceKey, channel, message }) {
|
|
2674
|
+
var _a;
|
|
2675
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2676
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug4.raise)(new import_echo_pipeline3.SpaceNotFoundError(spaceKey));
|
|
2677
|
+
await space.postMessage(getChannelId(channel), message);
|
|
2678
|
+
}
|
|
2679
|
+
subscribeMessages({ spaceKey, channel }) {
|
|
2680
|
+
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
2681
|
+
(0, import_async12.scheduleTask)(ctx, async () => {
|
|
2682
|
+
var _a;
|
|
2683
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2684
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug4.raise)(new import_echo_pipeline3.SpaceNotFoundError(spaceKey));
|
|
2685
|
+
const handle = space.listen(getChannelId(channel), (message) => {
|
|
2686
|
+
next(message);
|
|
2687
|
+
});
|
|
2688
|
+
ctx.onDispose(() => handle.unsubscribe());
|
|
2689
|
+
});
|
|
2690
|
+
});
|
|
2691
|
+
}
|
|
3108
2692
|
queryCredentials({ spaceKey }) {
|
|
3109
2693
|
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
3110
2694
|
var _a;
|
|
3111
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
2695
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug4.raise)(new import_echo_pipeline3.SpaceNotFoundError(spaceKey));
|
|
3112
2696
|
const processor = space.spaceState.registerProcessor({
|
|
3113
2697
|
process: async (credential) => {
|
|
3114
2698
|
next(credential);
|
|
3115
2699
|
}
|
|
3116
2700
|
});
|
|
3117
2701
|
ctx.onDispose(() => processor.close());
|
|
3118
|
-
(0,
|
|
2702
|
+
(0, import_async12.scheduleTask)(ctx, () => processor.open());
|
|
3119
2703
|
});
|
|
3120
2704
|
}
|
|
3121
2705
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3122
2706
|
var _a;
|
|
3123
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
2707
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug4.raise)(new import_echo_pipeline3.SpaceNotFoundError(spaceKey));
|
|
3124
2708
|
for (const credential of credentials != null ? credentials : []) {
|
|
3125
2709
|
await space.controlPipeline.writer.write({
|
|
3126
2710
|
credential: {
|
|
@@ -3132,7 +2716,7 @@ var SpacesServiceImpl = class {
|
|
|
3132
2716
|
_transformSpace(space) {
|
|
3133
2717
|
return {
|
|
3134
2718
|
spaceKey: space.key,
|
|
3135
|
-
status: space.isOpen ?
|
|
2719
|
+
status: space.isOpen ? import_services5.SpaceStatus.ACTIVE : import_services5.SpaceStatus.INACTIVE,
|
|
3136
2720
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3137
2721
|
var _a, _b, _c;
|
|
3138
2722
|
return {
|
|
@@ -3142,12 +2726,13 @@ var SpacesServiceImpl = class {
|
|
|
3142
2726
|
displayName: (_b = (_a = member.assertion.profile) == null ? void 0 : _a.displayName) != null ? _b : (0, import_util6.humanize)(member.key)
|
|
3143
2727
|
}
|
|
3144
2728
|
},
|
|
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 ?
|
|
2729
|
+
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
2730
|
};
|
|
3147
2731
|
})
|
|
3148
2732
|
};
|
|
3149
2733
|
}
|
|
3150
2734
|
};
|
|
2735
|
+
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3151
2736
|
|
|
3152
2737
|
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
3153
2738
|
var import_errors = require("@dxos/errors");
|
|
@@ -3205,7 +2790,8 @@ var SystemServiceImpl = class {
|
|
|
3205
2790
|
this._onReset = onReset;
|
|
3206
2791
|
}
|
|
3207
2792
|
async getConfig() {
|
|
3208
|
-
|
|
2793
|
+
var _a, _b;
|
|
2794
|
+
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
3209
2795
|
}
|
|
3210
2796
|
async updateStatus({ status }) {
|
|
3211
2797
|
await this._onUpdateStatus(status);
|
|
@@ -3232,40 +2818,75 @@ var SystemServiceImpl = class {
|
|
|
3232
2818
|
};
|
|
3233
2819
|
|
|
3234
2820
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3235
|
-
var
|
|
3236
|
-
var
|
|
2821
|
+
var import_async14 = require("@dxos/async");
|
|
2822
|
+
var import_log10 = require("@dxos/log");
|
|
3237
2823
|
var import_messaging = require("@dxos/messaging");
|
|
3238
2824
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
3239
|
-
var import_rpc3 = require("@dxos/rpc");
|
|
3240
2825
|
var import_util7 = require("@dxos/util");
|
|
3241
2826
|
|
|
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
|
-
|
|
2827
|
+
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
2828
|
+
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
2829
|
+
var import_debug5 = require("@dxos/debug");
|
|
2830
|
+
var import_rpc = require("@dxos/rpc");
|
|
2831
|
+
var ClientRpcServer = class {
|
|
2832
|
+
constructor(params) {
|
|
2833
|
+
this._handlerCache = /* @__PURE__ */ new Map();
|
|
2834
|
+
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
2835
|
+
this._handleCall = handleCall;
|
|
2836
|
+
this._handleStream = handleStream;
|
|
2837
|
+
this._serviceRegistry = serviceRegistry;
|
|
2838
|
+
this._rpcPeer = new import_rpc.RpcPeer({
|
|
2839
|
+
...rpcOptions,
|
|
2840
|
+
callHandler: (method, params2) => {
|
|
2841
|
+
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
2842
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
2843
|
+
if (this._handleCall) {
|
|
2844
|
+
return this._handleCall(methodName, params2, handler);
|
|
2845
|
+
} else {
|
|
2846
|
+
return handler(methodName, params2);
|
|
2847
|
+
}
|
|
2848
|
+
},
|
|
2849
|
+
streamHandler: (method, params2) => {
|
|
2850
|
+
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
2851
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
2852
|
+
if (this._handleStream) {
|
|
2853
|
+
return import_codec_protobuf12.Stream.unwrapPromise(this._handleStream(methodName, params2, handler));
|
|
2854
|
+
} else {
|
|
2855
|
+
return handler(methodName, params2);
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
});
|
|
2859
|
+
}
|
|
2860
|
+
async open() {
|
|
2861
|
+
await this._rpcPeer.open();
|
|
2862
|
+
}
|
|
2863
|
+
async close() {
|
|
2864
|
+
await this._rpcPeer.close();
|
|
2865
|
+
}
|
|
2866
|
+
_getServiceHandler(serviceName) {
|
|
2867
|
+
var _a;
|
|
2868
|
+
if (!this._handlerCache.has(serviceName)) {
|
|
2869
|
+
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}`));
|
|
2870
|
+
const service = this._serviceRegistry.services[key];
|
|
2871
|
+
if (!service) {
|
|
2872
|
+
throw new Error(`Service not available: ${serviceName}`);
|
|
2873
|
+
}
|
|
2874
|
+
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
2875
|
+
}
|
|
2876
|
+
return this._handlerCache.get(serviceName);
|
|
2877
|
+
}
|
|
3262
2878
|
};
|
|
3263
2879
|
|
|
3264
2880
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
2881
|
+
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2882
|
+
var import_async13 = require("@dxos/async");
|
|
2883
|
+
var import_client3 = require("@dxos/client");
|
|
2884
|
+
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
2885
|
+
var import_rpc2 = require("@dxos/rpc");
|
|
3265
2886
|
var ShellRuntimeImpl = class {
|
|
3266
2887
|
constructor(_port) {
|
|
3267
2888
|
this._port = _port;
|
|
3268
|
-
this.layoutUpdate = new
|
|
2889
|
+
this.layoutUpdate = new import_async13.Event();
|
|
3269
2890
|
this._layout = import_iframe.ShellLayout.DEFAULT;
|
|
3270
2891
|
}
|
|
3271
2892
|
get layout() {
|
|
@@ -3287,13 +2908,13 @@ var ShellRuntimeImpl = class {
|
|
|
3287
2908
|
});
|
|
3288
2909
|
}
|
|
3289
2910
|
async setAppContext(context) {
|
|
3290
|
-
(0,
|
|
2911
|
+
(0, import_node_assert10.default)(this._appRpc, "runtime not open");
|
|
3291
2912
|
await this._appRpc.rpc.AppService.setContext(context);
|
|
3292
2913
|
}
|
|
3293
2914
|
async open() {
|
|
3294
2915
|
this._appRpc = (0, import_rpc2.createProtoRpcPeer)({
|
|
3295
|
-
requested: appServiceBundle,
|
|
3296
|
-
exposed: shellServiceBundle,
|
|
2916
|
+
requested: import_client3.appServiceBundle,
|
|
2917
|
+
exposed: import_client3.shellServiceBundle,
|
|
3297
2918
|
handlers: {
|
|
3298
2919
|
ShellService: {
|
|
3299
2920
|
setLayout: async (request) => {
|
|
@@ -3316,8 +2937,8 @@ var ShellRuntimeImpl = class {
|
|
|
3316
2937
|
};
|
|
3317
2938
|
var MemoryShellRuntime = class {
|
|
3318
2939
|
constructor({ layout, invitationCode, spaceKey } = {}) {
|
|
3319
|
-
this.layoutUpdate = new
|
|
3320
|
-
this.contextUpdate = new
|
|
2940
|
+
this.layoutUpdate = new import_async13.Event();
|
|
2941
|
+
this.contextUpdate = new import_async13.Event();
|
|
3321
2942
|
this._layout = layout != null ? layout : import_iframe.ShellLayout.DEFAULT;
|
|
3322
2943
|
this._invitationCode = invitationCode;
|
|
3323
2944
|
this._spaceKey = spaceKey;
|
|
@@ -3360,21 +2981,10 @@ var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
|
3360
2981
|
var IFrameHostRuntime = class {
|
|
3361
2982
|
constructor({ configProvider, appPort, shellPort }) {
|
|
3362
2983
|
this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)();
|
|
3363
|
-
this._ready = new
|
|
2984
|
+
this._ready = new import_async14.Trigger();
|
|
3364
2985
|
this._configProvider = configProvider;
|
|
3365
2986
|
this._appPort = appPort;
|
|
3366
2987
|
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
2988
|
if (this._shellPort) {
|
|
3379
2989
|
this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
|
|
3380
2990
|
}
|
|
@@ -3387,9 +2997,9 @@ var IFrameHostRuntime = class {
|
|
|
3387
2997
|
}
|
|
3388
2998
|
async start() {
|
|
3389
2999
|
var _a;
|
|
3390
|
-
(0,
|
|
3000
|
+
(0, import_log10.log)("starting...", {}, {
|
|
3391
3001
|
file: "iframe-host-runtime.ts",
|
|
3392
|
-
line:
|
|
3002
|
+
line: 67,
|
|
3393
3003
|
scope: this,
|
|
3394
3004
|
callSite: (f, a) => f(...a)
|
|
3395
3005
|
});
|
|
@@ -3407,21 +3017,30 @@ var IFrameHostRuntime = class {
|
|
|
3407
3017
|
transportFactory: this._transportFactory
|
|
3408
3018
|
})
|
|
3409
3019
|
});
|
|
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)
|
|
3020
|
+
const middleware = {
|
|
3021
|
+
handleCall: async (method, params, handler) => {
|
|
3022
|
+
const error = await this._ready.wait({
|
|
3023
|
+
timeout: 3e3
|
|
3024
|
+
});
|
|
3025
|
+
if (error) {
|
|
3026
|
+
throw error;
|
|
3027
|
+
}
|
|
3028
|
+
return handler(method, params);
|
|
3423
3029
|
},
|
|
3424
|
-
|
|
3030
|
+
handleStream: async (method, params, handler) => {
|
|
3031
|
+
const error = await this._ready.wait({
|
|
3032
|
+
timeout: 3e3
|
|
3033
|
+
});
|
|
3034
|
+
if (error) {
|
|
3035
|
+
throw error;
|
|
3036
|
+
}
|
|
3037
|
+
return handler(method, params);
|
|
3038
|
+
}
|
|
3039
|
+
};
|
|
3040
|
+
this._clientRpc = new ClientRpcServer({
|
|
3041
|
+
serviceRegistry: this._clientServices.host.serviceRegistry,
|
|
3042
|
+
port: this._appPort,
|
|
3043
|
+
...middleware
|
|
3425
3044
|
});
|
|
3426
3045
|
await Promise.all([
|
|
3427
3046
|
this._clientServices.open(),
|
|
@@ -3429,17 +3048,17 @@ var IFrameHostRuntime = class {
|
|
|
3429
3048
|
(_a = this._shellRuntime) == null ? void 0 : _a.open()
|
|
3430
3049
|
]);
|
|
3431
3050
|
this._ready.wake(void 0);
|
|
3432
|
-
(0,
|
|
3051
|
+
(0, import_log10.log)("started", {}, {
|
|
3433
3052
|
file: "iframe-host-runtime.ts",
|
|
3434
|
-
line:
|
|
3053
|
+
line: 110,
|
|
3435
3054
|
scope: this,
|
|
3436
3055
|
callSite: (f, a) => f(...a)
|
|
3437
3056
|
});
|
|
3438
3057
|
} catch (err) {
|
|
3439
3058
|
this._ready.wake(err);
|
|
3440
|
-
|
|
3059
|
+
import_log10.log.catch(err, {}, {
|
|
3441
3060
|
file: "iframe-host-runtime.ts",
|
|
3442
|
-
line:
|
|
3061
|
+
line: 113,
|
|
3443
3062
|
scope: this,
|
|
3444
3063
|
callSite: (f, a) => f(...a)
|
|
3445
3064
|
});
|
|
@@ -3447,30 +3066,31 @@ var IFrameHostRuntime = class {
|
|
|
3447
3066
|
}
|
|
3448
3067
|
async stop() {
|
|
3449
3068
|
var _a;
|
|
3450
|
-
(0,
|
|
3069
|
+
(0, import_log10.log)("stopping...", {}, {
|
|
3451
3070
|
file: "iframe-host-runtime.ts",
|
|
3452
|
-
line:
|
|
3071
|
+
line: 118,
|
|
3453
3072
|
scope: this,
|
|
3454
3073
|
callSite: (f, a) => f(...a)
|
|
3455
3074
|
});
|
|
3456
3075
|
await this._clientRpc.close();
|
|
3457
3076
|
await this._clientServices.close();
|
|
3458
3077
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
3459
|
-
(0,
|
|
3078
|
+
(0, import_log10.log)("stopped", {}, {
|
|
3460
3079
|
file: "iframe-host-runtime.ts",
|
|
3461
|
-
line:
|
|
3080
|
+
line: 122,
|
|
3462
3081
|
scope: this,
|
|
3463
3082
|
callSite: (f, a) => f(...a)
|
|
3464
3083
|
});
|
|
3465
3084
|
}
|
|
3466
3085
|
};
|
|
3467
3086
|
__decorate3([
|
|
3468
|
-
|
|
3087
|
+
import_log10.logInfo
|
|
3469
3088
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
3470
3089
|
|
|
3471
3090
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
3091
|
+
var import_client4 = require("@dxos/client");
|
|
3472
3092
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
3473
|
-
var
|
|
3093
|
+
var import_rpc3 = require("@dxos/rpc");
|
|
3474
3094
|
var IFrameProxyRuntime = class {
|
|
3475
3095
|
constructor({ systemPort, workerAppPort, windowAppPort, shellPort }) {
|
|
3476
3096
|
this._transportService = new import_network_manager4.WebRTCTransportService();
|
|
@@ -3478,9 +3098,9 @@ var IFrameProxyRuntime = class {
|
|
|
3478
3098
|
this._windowAppPort = windowAppPort;
|
|
3479
3099
|
this._workerAppPort = workerAppPort;
|
|
3480
3100
|
this._shellPort = shellPort;
|
|
3481
|
-
this._systemRpc = (0,
|
|
3482
|
-
requested: workerServiceBundle,
|
|
3483
|
-
exposed: iframeServiceBundle,
|
|
3101
|
+
this._systemRpc = (0, import_rpc3.createProtoRpcPeer)({
|
|
3102
|
+
requested: import_client4.workerServiceBundle,
|
|
3103
|
+
exposed: import_client4.iframeServiceBundle,
|
|
3484
3104
|
handlers: {
|
|
3485
3105
|
BridgeService: this._transportService,
|
|
3486
3106
|
IframeService: {
|
|
@@ -3506,82 +3126,19 @@ var IFrameProxyRuntime = class {
|
|
|
3506
3126
|
await this._systemRpc.rpc.WorkerService.start({
|
|
3507
3127
|
origin
|
|
3508
3128
|
});
|
|
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();
|
|
3129
|
+
await ((_a = this._shellRuntime) == null ? void 0 : _a.open());
|
|
3574
3130
|
}
|
|
3575
3131
|
async close() {
|
|
3576
3132
|
var _a;
|
|
3577
|
-
await ((_a = this.
|
|
3578
|
-
this.
|
|
3133
|
+
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
3134
|
+
await this._systemRpc.rpc.WorkerService.stop();
|
|
3135
|
+
await this._systemRpc.close();
|
|
3579
3136
|
}
|
|
3580
3137
|
};
|
|
3581
3138
|
|
|
3582
3139
|
// packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
|
|
3583
|
-
var
|
|
3584
|
-
var
|
|
3140
|
+
var import_async15 = require("@dxos/async");
|
|
3141
|
+
var import_log11 = require("@dxos/log");
|
|
3585
3142
|
var Message;
|
|
3586
3143
|
(function(Message2) {
|
|
3587
3144
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -3589,7 +3146,7 @@ var Message;
|
|
|
3589
3146
|
var VaultResourceLock = class {
|
|
3590
3147
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
3591
3148
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
3592
|
-
this._releaseTrigger = new
|
|
3149
|
+
this._releaseTrigger = new import_async15.Trigger();
|
|
3593
3150
|
this._lockKey = lockKey;
|
|
3594
3151
|
this._onAcquire = onAcquire;
|
|
3595
3152
|
this._onRelease = onRelease;
|
|
@@ -3600,7 +3157,7 @@ var VaultResourceLock = class {
|
|
|
3600
3157
|
message: Message.ACQUIRING
|
|
3601
3158
|
});
|
|
3602
3159
|
try {
|
|
3603
|
-
await (0,
|
|
3160
|
+
await (0, import_async15.asyncTimeout)(this._requestLock(), 3e3);
|
|
3604
3161
|
} catch (e) {
|
|
3605
3162
|
await this._requestLock(true);
|
|
3606
3163
|
}
|
|
@@ -3614,7 +3171,7 @@ var VaultResourceLock = class {
|
|
|
3614
3171
|
}
|
|
3615
3172
|
}
|
|
3616
3173
|
async _requestLock(steal = false) {
|
|
3617
|
-
(0,
|
|
3174
|
+
(0, import_log11.log)("requesting lock...", {
|
|
3618
3175
|
steal
|
|
3619
3176
|
}, {
|
|
3620
3177
|
file: "vault-resource-lock.ts",
|
|
@@ -3622,23 +3179,23 @@ var VaultResourceLock = class {
|
|
|
3622
3179
|
scope: this,
|
|
3623
3180
|
callSite: (f, a) => f(...a)
|
|
3624
3181
|
});
|
|
3625
|
-
const acquired = new
|
|
3182
|
+
const acquired = new import_async15.Trigger();
|
|
3626
3183
|
void navigator.locks.request(this._lockKey, {
|
|
3627
3184
|
steal
|
|
3628
3185
|
}, async () => {
|
|
3629
3186
|
var _a, _b;
|
|
3630
3187
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3631
3188
|
acquired.wake();
|
|
3632
|
-
this._releaseTrigger = new
|
|
3189
|
+
this._releaseTrigger = new import_async15.Trigger();
|
|
3633
3190
|
await this._releaseTrigger.wait();
|
|
3634
|
-
(0,
|
|
3191
|
+
(0, import_log11.log)("releasing lock...", {}, {
|
|
3635
3192
|
file: "vault-resource-lock.ts",
|
|
3636
3193
|
line: 65,
|
|
3637
3194
|
scope: this,
|
|
3638
3195
|
callSite: (f, a) => f(...a)
|
|
3639
3196
|
});
|
|
3640
3197
|
await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
|
|
3641
|
-
(0,
|
|
3198
|
+
(0, import_log11.log)("released lock", {}, {
|
|
3642
3199
|
file: "vault-resource-lock.ts",
|
|
3643
3200
|
line: 67,
|
|
3644
3201
|
scope: this,
|
|
@@ -3649,7 +3206,7 @@ var VaultResourceLock = class {
|
|
|
3649
3206
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3650
3207
|
});
|
|
3651
3208
|
await acquired.wait();
|
|
3652
|
-
(0,
|
|
3209
|
+
(0, import_log11.log)("recieved lock", {
|
|
3653
3210
|
steal
|
|
3654
3211
|
}, {
|
|
3655
3212
|
file: "vault-resource-lock.ts",
|
|
@@ -3661,16 +3218,17 @@ var VaultResourceLock = class {
|
|
|
3661
3218
|
};
|
|
3662
3219
|
|
|
3663
3220
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
3664
|
-
var
|
|
3665
|
-
var
|
|
3221
|
+
var import_async17 = require("@dxos/async");
|
|
3222
|
+
var import_log13 = require("@dxos/log");
|
|
3666
3223
|
var import_messaging2 = require("@dxos/messaging");
|
|
3667
3224
|
var import_network_manager5 = require("@dxos/network-manager");
|
|
3668
3225
|
|
|
3669
3226
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
3670
|
-
var
|
|
3671
|
-
var
|
|
3672
|
-
var
|
|
3673
|
-
var
|
|
3227
|
+
var import_node_assert11 = __toESM(require("node:assert"));
|
|
3228
|
+
var import_async16 = require("@dxos/async");
|
|
3229
|
+
var import_client5 = require("@dxos/client");
|
|
3230
|
+
var import_log12 = require("@dxos/log");
|
|
3231
|
+
var import_rpc4 = require("@dxos/rpc");
|
|
3674
3232
|
var import_util8 = require("@dxos/util");
|
|
3675
3233
|
var __decorate4 = function(decorators, target, key, desc) {
|
|
3676
3234
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3683,40 +3241,48 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
3683
3241
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3684
3242
|
};
|
|
3685
3243
|
var WorkerSession = class {
|
|
3686
|
-
constructor({
|
|
3244
|
+
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal, options = {
|
|
3687
3245
|
heartbeatInterval: 1e3
|
|
3688
3246
|
} }) {
|
|
3689
|
-
this._startTrigger = new
|
|
3247
|
+
this._startTrigger = new import_async16.Trigger();
|
|
3690
3248
|
this.onClose = new import_util8.Callback();
|
|
3691
|
-
(0,
|
|
3692
|
-
(0,
|
|
3249
|
+
(0, import_node_assert11.default)(options);
|
|
3250
|
+
(0, import_node_assert11.default)(serviceHost);
|
|
3693
3251
|
this._options = options;
|
|
3694
|
-
this.
|
|
3695
|
-
const
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3252
|
+
this._serviceHost = serviceHost;
|
|
3253
|
+
const middleware = {
|
|
3254
|
+
handleCall: async (method, params, handler) => {
|
|
3255
|
+
const error = await readySignal.wait({
|
|
3256
|
+
timeout: 3e3
|
|
3257
|
+
});
|
|
3258
|
+
if (error) {
|
|
3259
|
+
throw error;
|
|
3260
|
+
}
|
|
3261
|
+
return handler(method, params);
|
|
3262
|
+
},
|
|
3263
|
+
handleStream: async (method, params, handler) => {
|
|
3264
|
+
const error = await readySignal.wait({
|
|
3265
|
+
timeout: 3e3
|
|
3266
|
+
});
|
|
3267
|
+
if (error) {
|
|
3268
|
+
throw error;
|
|
3269
|
+
}
|
|
3270
|
+
return handler(method, params);
|
|
3271
|
+
}
|
|
3706
3272
|
};
|
|
3707
|
-
this._clientRpc =
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
});
|
|
3712
|
-
this._shellClientRpc =
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
});
|
|
3717
|
-
this._iframeRpc = (0,
|
|
3718
|
-
requested: iframeServiceBundle,
|
|
3719
|
-
exposed: workerServiceBundle,
|
|
3273
|
+
this._clientRpc = new ClientRpcServer({
|
|
3274
|
+
serviceRegistry: this._serviceHost.serviceRegistry,
|
|
3275
|
+
port: appPort,
|
|
3276
|
+
...middleware
|
|
3277
|
+
});
|
|
3278
|
+
this._shellClientRpc = new ClientRpcServer({
|
|
3279
|
+
serviceRegistry: this._serviceHost.serviceRegistry,
|
|
3280
|
+
port: shellPort,
|
|
3281
|
+
...middleware
|
|
3282
|
+
});
|
|
3283
|
+
this._iframeRpc = (0, import_rpc4.createProtoRpcPeer)({
|
|
3284
|
+
requested: import_client5.iframeServiceBundle,
|
|
3285
|
+
exposed: import_client5.workerServiceBundle,
|
|
3720
3286
|
handlers: {
|
|
3721
3287
|
WorkerService: {
|
|
3722
3288
|
start: async (request) => {
|
|
@@ -3728,9 +3294,9 @@ var WorkerSession = class {
|
|
|
3728
3294
|
try {
|
|
3729
3295
|
await this.close();
|
|
3730
3296
|
} catch (err) {
|
|
3731
|
-
|
|
3297
|
+
import_log12.log.catch(err, {}, {
|
|
3732
3298
|
file: "worker-session.ts",
|
|
3733
|
-
line:
|
|
3299
|
+
line: 107,
|
|
3734
3300
|
scope: this,
|
|
3735
3301
|
callSite: (f, a) => f(...a)
|
|
3736
3302
|
});
|
|
@@ -3746,9 +3312,9 @@ var WorkerSession = class {
|
|
|
3746
3312
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
3747
3313
|
}
|
|
3748
3314
|
async open() {
|
|
3749
|
-
|
|
3315
|
+
import_log12.log.info("opening..", {}, {
|
|
3750
3316
|
file: "worker-session.ts",
|
|
3751
|
-
line:
|
|
3317
|
+
line: 121,
|
|
3752
3318
|
scope: this,
|
|
3753
3319
|
callSite: (f, a) => f(...a)
|
|
3754
3320
|
});
|
|
@@ -3764,20 +3330,20 @@ var WorkerSession = class {
|
|
|
3764
3330
|
try {
|
|
3765
3331
|
await this._iframeRpc.rpc.IframeService.heartbeat();
|
|
3766
3332
|
} catch (err1) {
|
|
3767
|
-
|
|
3333
|
+
import_log12.log.warn("Heartbeat failed", {
|
|
3768
3334
|
err: err1
|
|
3769
3335
|
}, {
|
|
3770
3336
|
file: "worker-session.ts",
|
|
3771
|
-
line:
|
|
3337
|
+
line: 133,
|
|
3772
3338
|
scope: this,
|
|
3773
3339
|
callSite: (f, a) => f(...a)
|
|
3774
3340
|
});
|
|
3775
3341
|
try {
|
|
3776
3342
|
await this.close();
|
|
3777
3343
|
} catch (err) {
|
|
3778
|
-
|
|
3344
|
+
import_log12.log.catch(err, {}, {
|
|
3779
3345
|
file: "worker-session.ts",
|
|
3780
|
-
line:
|
|
3346
|
+
line: 137,
|
|
3781
3347
|
scope: this,
|
|
3782
3348
|
callSite: (f, a) => f(...a)
|
|
3783
3349
|
});
|
|
@@ -3786,18 +3352,18 @@ var WorkerSession = class {
|
|
|
3786
3352
|
}, this._options.heartbeatInterval);
|
|
3787
3353
|
}
|
|
3788
3354
|
async close() {
|
|
3789
|
-
|
|
3355
|
+
import_log12.log.info("closing..", {}, {
|
|
3790
3356
|
file: "worker-session.ts",
|
|
3791
|
-
line:
|
|
3357
|
+
line: 144,
|
|
3792
3358
|
scope: this,
|
|
3793
3359
|
callSite: (f, a) => f(...a)
|
|
3794
3360
|
});
|
|
3795
3361
|
try {
|
|
3796
3362
|
await this.onClose.callIfSet();
|
|
3797
3363
|
} catch (err) {
|
|
3798
|
-
|
|
3364
|
+
import_log12.log.catch(err, {}, {
|
|
3799
3365
|
file: "worker-session.ts",
|
|
3800
|
-
line:
|
|
3366
|
+
line: 148,
|
|
3801
3367
|
scope: this,
|
|
3802
3368
|
callSite: (f, a) => f(...a)
|
|
3803
3369
|
});
|
|
@@ -3812,11 +3378,11 @@ var WorkerSession = class {
|
|
|
3812
3378
|
}
|
|
3813
3379
|
async _maybeOpenShell() {
|
|
3814
3380
|
try {
|
|
3815
|
-
await (0,
|
|
3381
|
+
await (0, import_async16.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
3816
3382
|
} catch (e) {
|
|
3817
|
-
|
|
3383
|
+
import_log12.log.info("No shell connected.", {}, {
|
|
3818
3384
|
file: "worker-session.ts",
|
|
3819
|
-
line:
|
|
3385
|
+
line: 162,
|
|
3820
3386
|
scope: this,
|
|
3821
3387
|
callSite: (f, a) => f(...a)
|
|
3822
3388
|
});
|
|
@@ -3824,7 +3390,7 @@ var WorkerSession = class {
|
|
|
3824
3390
|
}
|
|
3825
3391
|
};
|
|
3826
3392
|
__decorate4([
|
|
3827
|
-
|
|
3393
|
+
import_log12.logInfo
|
|
3828
3394
|
], WorkerSession.prototype, "origin", void 0);
|
|
3829
3395
|
|
|
3830
3396
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
@@ -3833,20 +3399,21 @@ var WorkerRuntime = class {
|
|
|
3833
3399
|
constructor(_configProvider) {
|
|
3834
3400
|
this._configProvider = _configProvider;
|
|
3835
3401
|
this._transportFactory = new import_network_manager5.WebRTCTransportProxyFactory();
|
|
3836
|
-
this._ready = new
|
|
3402
|
+
this._ready = new import_async17.Trigger();
|
|
3837
3403
|
this.sessions = /* @__PURE__ */ new Set();
|
|
3404
|
+
this._clientServices = new ClientServicesHost();
|
|
3838
3405
|
}
|
|
3839
3406
|
async start() {
|
|
3840
|
-
(0,
|
|
3407
|
+
(0, import_log13.log)("starting...", {}, {
|
|
3841
3408
|
file: "worker-runtime.ts",
|
|
3842
|
-
line:
|
|
3409
|
+
line: 44,
|
|
3843
3410
|
scope: this,
|
|
3844
3411
|
callSite: (f, a) => f(...a)
|
|
3845
3412
|
});
|
|
3846
3413
|
try {
|
|
3847
3414
|
this._config = await this._configProvider();
|
|
3848
3415
|
const signalServer = this._config.get("runtime.services.signal.server");
|
|
3849
|
-
this._clientServices
|
|
3416
|
+
this._clientServices.initialize({
|
|
3850
3417
|
config: this._config,
|
|
3851
3418
|
networkManager: new import_network_manager5.NetworkManager({
|
|
3852
3419
|
log: true,
|
|
@@ -3858,17 +3425,17 @@ var WorkerRuntime = class {
|
|
|
3858
3425
|
});
|
|
3859
3426
|
await this._clientServices.open();
|
|
3860
3427
|
this._ready.wake(void 0);
|
|
3861
|
-
(0,
|
|
3428
|
+
(0, import_log13.log)("started", {}, {
|
|
3862
3429
|
file: "worker-runtime.ts",
|
|
3863
|
-
line:
|
|
3430
|
+
line: 61,
|
|
3864
3431
|
scope: this,
|
|
3865
3432
|
callSite: (f, a) => f(...a)
|
|
3866
3433
|
});
|
|
3867
3434
|
} catch (err) {
|
|
3868
3435
|
this._ready.wake(err);
|
|
3869
|
-
|
|
3436
|
+
import_log13.log.catch(err, {}, {
|
|
3870
3437
|
file: "worker-runtime.ts",
|
|
3871
|
-
line:
|
|
3438
|
+
line: 64,
|
|
3872
3439
|
scope: this,
|
|
3873
3440
|
callSite: (f, a) => f(...a)
|
|
3874
3441
|
});
|
|
@@ -3882,17 +3449,7 @@ var WorkerRuntime = class {
|
|
|
3882
3449
|
*/
|
|
3883
3450
|
async createSession({ appPort, systemPort, shellPort }) {
|
|
3884
3451
|
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
|
-
},
|
|
3452
|
+
serviceHost: this._clientServices,
|
|
3896
3453
|
appPort,
|
|
3897
3454
|
systemPort,
|
|
3898
3455
|
shellPort,
|
|
@@ -3927,10 +3484,206 @@ var WorkerRuntime = class {
|
|
|
3927
3484
|
}
|
|
3928
3485
|
};
|
|
3929
3486
|
|
|
3487
|
+
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3488
|
+
var import_async18 = require("@dxos/async");
|
|
3489
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
3490
|
+
var import_debug6 = require("@dxos/debug");
|
|
3491
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3492
|
+
var import_feed_store4 = require("@dxos/feed-store");
|
|
3493
|
+
var import_keyring = require("@dxos/keyring");
|
|
3494
|
+
var import_log14 = require("@dxos/log");
|
|
3495
|
+
var ServiceContext = class {
|
|
3496
|
+
// prettier-ignore
|
|
3497
|
+
constructor(storage, networkManager, modelFactory) {
|
|
3498
|
+
this.storage = storage;
|
|
3499
|
+
this.networkManager = networkManager;
|
|
3500
|
+
this.modelFactory = modelFactory;
|
|
3501
|
+
this.initialized = new import_async18.Trigger();
|
|
3502
|
+
this.dataServiceSubscriptions = new import_echo_pipeline4.DataServiceSubscriptions();
|
|
3503
|
+
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
3504
|
+
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
3505
|
+
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
3506
|
+
this.feedStore = new import_feed_store4.FeedStore({
|
|
3507
|
+
factory: new import_feed_store4.FeedFactory({
|
|
3508
|
+
root: storage.createDirectory("feeds"),
|
|
3509
|
+
signer: this.keyring,
|
|
3510
|
+
hypercore: {
|
|
3511
|
+
valueEncoding: import_echo_pipeline4.valueEncoding
|
|
3512
|
+
}
|
|
3513
|
+
})
|
|
3514
|
+
});
|
|
3515
|
+
this.spaceManager = new import_echo_pipeline4.SpaceManager({
|
|
3516
|
+
feedStore: this.feedStore,
|
|
3517
|
+
networkManager: this.networkManager
|
|
3518
|
+
});
|
|
3519
|
+
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3520
|
+
this.deviceInvitations = new DeviceInvitationsHandler({
|
|
3521
|
+
networkManager: this.networkManager,
|
|
3522
|
+
getIdentity: () => {
|
|
3523
|
+
var _a;
|
|
3524
|
+
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
|
|
3525
|
+
},
|
|
3526
|
+
acceptIdentity: this._acceptIdentity.bind(this),
|
|
3527
|
+
keyring: this.keyring
|
|
3528
|
+
});
|
|
3529
|
+
}
|
|
3530
|
+
async open() {
|
|
3531
|
+
(0, import_log14.log)("opening...", {}, {
|
|
3532
|
+
file: "service-context.ts",
|
|
3533
|
+
line: 94,
|
|
3534
|
+
scope: this,
|
|
3535
|
+
callSite: (f, a) => f(...a)
|
|
3536
|
+
});
|
|
3537
|
+
await this.networkManager.open();
|
|
3538
|
+
await this.spaceManager.open();
|
|
3539
|
+
await this.identityManager.open();
|
|
3540
|
+
if (this.identityManager.identity) {
|
|
3541
|
+
await this._initialize();
|
|
3542
|
+
}
|
|
3543
|
+
(0, import_log14.log)("opened", {}, {
|
|
3544
|
+
file: "service-context.ts",
|
|
3545
|
+
line: 101,
|
|
3546
|
+
scope: this,
|
|
3547
|
+
callSite: (f, a) => f(...a)
|
|
3548
|
+
});
|
|
3549
|
+
}
|
|
3550
|
+
async close() {
|
|
3551
|
+
var _a, _b;
|
|
3552
|
+
(0, import_log14.log)("closing...", {}, {
|
|
3553
|
+
file: "service-context.ts",
|
|
3554
|
+
line: 105,
|
|
3555
|
+
scope: this,
|
|
3556
|
+
callSite: (f, a) => f(...a)
|
|
3557
|
+
});
|
|
3558
|
+
await ((_a = this._deviceSpaceSync) == null ? void 0 : _a.close());
|
|
3559
|
+
await ((_b = this.dataSpaceManager) == null ? void 0 : _b.close());
|
|
3560
|
+
await this.identityManager.close();
|
|
3561
|
+
await this.spaceManager.close();
|
|
3562
|
+
await this.feedStore.close();
|
|
3563
|
+
await this.networkManager.close();
|
|
3564
|
+
this.dataServiceSubscriptions.clear();
|
|
3565
|
+
(0, import_log14.log)("closed", {}, {
|
|
3566
|
+
file: "service-context.ts",
|
|
3567
|
+
line: 113,
|
|
3568
|
+
scope: this,
|
|
3569
|
+
callSite: (f, a) => f(...a)
|
|
3570
|
+
});
|
|
3571
|
+
}
|
|
3572
|
+
async reset() {
|
|
3573
|
+
(0, import_log14.log)("resetting...", {}, {
|
|
3574
|
+
file: "service-context.ts",
|
|
3575
|
+
line: 117,
|
|
3576
|
+
scope: this,
|
|
3577
|
+
callSite: (f, a) => f(...a)
|
|
3578
|
+
});
|
|
3579
|
+
await this.close();
|
|
3580
|
+
await this.storage.reset();
|
|
3581
|
+
(0, import_log14.log)("reset", {}, {
|
|
3582
|
+
file: "service-context.ts",
|
|
3583
|
+
line: 120,
|
|
3584
|
+
scope: this,
|
|
3585
|
+
callSite: (f, a) => f(...a)
|
|
3586
|
+
});
|
|
3587
|
+
}
|
|
3588
|
+
async createIdentity(params = {}) {
|
|
3589
|
+
const identity = await this.identityManager.createIdentity(params);
|
|
3590
|
+
await this._initialize();
|
|
3591
|
+
return identity;
|
|
3592
|
+
}
|
|
3593
|
+
async _acceptIdentity(params) {
|
|
3594
|
+
const identity = await this.identityManager.acceptIdentity(params);
|
|
3595
|
+
await this._initialize();
|
|
3596
|
+
return identity;
|
|
3597
|
+
}
|
|
3598
|
+
// Called when identity is created.
|
|
3599
|
+
async _initialize() {
|
|
3600
|
+
var _a;
|
|
3601
|
+
(0, import_log14.log)("initializing spaces...", {}, {
|
|
3602
|
+
file: "service-context.ts",
|
|
3603
|
+
line: 139,
|
|
3604
|
+
scope: this,
|
|
3605
|
+
callSite: (f, a) => f(...a)
|
|
3606
|
+
});
|
|
3607
|
+
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
|
|
3608
|
+
const signingContext = {
|
|
3609
|
+
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3610
|
+
identityKey: identity.identityKey,
|
|
3611
|
+
deviceKey: identity.deviceKey,
|
|
3612
|
+
profile: identity.profileDocument,
|
|
3613
|
+
recordCredential: async (credential) => {
|
|
3614
|
+
await identity.controlPipeline.writer.write({
|
|
3615
|
+
credential: {
|
|
3616
|
+
credential
|
|
3617
|
+
}
|
|
3618
|
+
});
|
|
3619
|
+
}
|
|
3620
|
+
};
|
|
3621
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.modelFactory, this.feedStore, this.snapshotStore);
|
|
3622
|
+
await this.dataSpaceManager.open();
|
|
3623
|
+
this.spaceInvitations = new SpaceInvitationsHandler(this.networkManager, this.dataSpaceManager, signingContext, this.keyring);
|
|
3624
|
+
this.initialized.wake();
|
|
3625
|
+
this._deviceSpaceSync = identity.space.spaceState.registerProcessor({
|
|
3626
|
+
process: async (credential) => {
|
|
3627
|
+
const assertion = (0, import_credentials11.getCredentialAssertion)(credential);
|
|
3628
|
+
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3629
|
+
return;
|
|
3630
|
+
}
|
|
3631
|
+
if (assertion.spaceKey.equals(identity.space.key)) {
|
|
3632
|
+
return;
|
|
3633
|
+
}
|
|
3634
|
+
if (!this.dataSpaceManager) {
|
|
3635
|
+
(0, import_log14.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3636
|
+
details: assertion
|
|
3637
|
+
}, {
|
|
3638
|
+
file: "service-context.ts",
|
|
3639
|
+
line: 182,
|
|
3640
|
+
scope: this,
|
|
3641
|
+
callSite: (f, a) => f(...a)
|
|
3642
|
+
});
|
|
3643
|
+
return;
|
|
3644
|
+
}
|
|
3645
|
+
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3646
|
+
(0, import_log14.log)("space already exists, ignoring space admission", {
|
|
3647
|
+
details: assertion
|
|
3648
|
+
}, {
|
|
3649
|
+
file: "service-context.ts",
|
|
3650
|
+
line: 186,
|
|
3651
|
+
scope: this,
|
|
3652
|
+
callSite: (f, a) => f(...a)
|
|
3653
|
+
});
|
|
3654
|
+
return;
|
|
3655
|
+
}
|
|
3656
|
+
try {
|
|
3657
|
+
(0, import_log14.log)("accepting space recorded in halo", {
|
|
3658
|
+
details: assertion
|
|
3659
|
+
}, {
|
|
3660
|
+
file: "service-context.ts",
|
|
3661
|
+
line: 191,
|
|
3662
|
+
scope: this,
|
|
3663
|
+
callSite: (f, a) => f(...a)
|
|
3664
|
+
});
|
|
3665
|
+
await this.dataSpaceManager.acceptSpace({
|
|
3666
|
+
spaceKey: assertion.spaceKey,
|
|
3667
|
+
genesisFeedKey: assertion.genesisFeedKey
|
|
3668
|
+
});
|
|
3669
|
+
} catch (err) {
|
|
3670
|
+
import_log14.log.catch(err, {}, {
|
|
3671
|
+
file: "service-context.ts",
|
|
3672
|
+
line: 197,
|
|
3673
|
+
scope: this,
|
|
3674
|
+
callSite: (f, a) => f(...a)
|
|
3675
|
+
});
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
});
|
|
3679
|
+
await this._deviceSpaceSync.open();
|
|
3680
|
+
}
|
|
3681
|
+
};
|
|
3682
|
+
|
|
3930
3683
|
// packages/sdk/client-services/src/packlets/services/service-registry.ts
|
|
3931
3684
|
var ServiceRegistry = class {
|
|
3932
3685
|
// prettier-ignore
|
|
3933
|
-
constructor(_serviceBundle, _handlers) {
|
|
3686
|
+
constructor(_serviceBundle, _handlers = {}) {
|
|
3934
3687
|
this._serviceBundle = _serviceBundle;
|
|
3935
3688
|
this._handlers = _handlers;
|
|
3936
3689
|
}
|
|
@@ -3943,28 +3696,35 @@ var ServiceRegistry = class {
|
|
|
3943
3696
|
setServices(services) {
|
|
3944
3697
|
this._handlers = services;
|
|
3945
3698
|
}
|
|
3699
|
+
addService(name, service) {
|
|
3700
|
+
this._handlers[name] = service;
|
|
3701
|
+
}
|
|
3702
|
+
removeService(name) {
|
|
3703
|
+
delete this._handlers[name];
|
|
3704
|
+
}
|
|
3946
3705
|
};
|
|
3947
3706
|
|
|
3948
3707
|
// 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
3708
|
var ClientServicesHost = class {
|
|
3953
3709
|
constructor({
|
|
3954
3710
|
config,
|
|
3955
|
-
modelFactory = createDefaultModelFactory(),
|
|
3711
|
+
modelFactory = (0, import_client6.createDefaultModelFactory)(),
|
|
3956
3712
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3957
3713
|
networkManager,
|
|
3958
|
-
storage
|
|
3714
|
+
storage,
|
|
3959
3715
|
// TODO(wittjosiah): Turn this on by default.
|
|
3960
3716
|
lockKey
|
|
3961
|
-
}) {
|
|
3962
|
-
this._statusUpdate = new
|
|
3717
|
+
} = {}) {
|
|
3718
|
+
this._statusUpdate = new import_async19.Event();
|
|
3963
3719
|
this._open = false;
|
|
3964
|
-
this._config = config;
|
|
3965
|
-
this._modelFactory = modelFactory;
|
|
3966
|
-
this._networkManager = networkManager;
|
|
3967
3720
|
this._storage = storage;
|
|
3721
|
+
this._modelFactory = modelFactory;
|
|
3722
|
+
if (config) {
|
|
3723
|
+
this.initialize({
|
|
3724
|
+
config,
|
|
3725
|
+
networkManager
|
|
3726
|
+
});
|
|
3727
|
+
}
|
|
3968
3728
|
this._resourceLock = lockKey ? new VaultResourceLock({
|
|
3969
3729
|
lockKey,
|
|
3970
3730
|
onAcquire: () => this.open(),
|
|
@@ -3973,41 +3733,66 @@ var ClientServicesHost = class {
|
|
|
3973
3733
|
this._systemService = new SystemServiceImpl({
|
|
3974
3734
|
config: this._config,
|
|
3975
3735
|
statusUpdate: this._statusUpdate,
|
|
3976
|
-
getCurrentStatus: () => this.isOpen ?
|
|
3736
|
+
getCurrentStatus: () => this.isOpen ? import_services8.SystemStatus.ACTIVE : import_services8.SystemStatus.INACTIVE,
|
|
3977
3737
|
onUpdateStatus: async (status) => {
|
|
3978
3738
|
var _a, _b;
|
|
3979
|
-
if (!this.isOpen && status ===
|
|
3739
|
+
if (!this.isOpen && status === import_services8.SystemStatus.ACTIVE) {
|
|
3980
3740
|
await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
|
|
3981
|
-
} else if (this.isOpen && status ===
|
|
3741
|
+
} else if (this.isOpen && status === import_services8.SystemStatus.INACTIVE) {
|
|
3982
3742
|
await ((_b = this._resourceLock) == null ? void 0 : _b.release());
|
|
3983
3743
|
}
|
|
3984
3744
|
},
|
|
3985
3745
|
onReset: async () => {
|
|
3986
|
-
(0,
|
|
3746
|
+
(0, import_node_assert12.default)(this._serviceContext, "service host is closed");
|
|
3987
3747
|
await this._serviceContext.reset();
|
|
3988
3748
|
}
|
|
3989
3749
|
});
|
|
3990
|
-
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
3750
|
+
this._serviceRegistry = new ServiceRegistry(import_client6.clientServiceBundle, {
|
|
3991
3751
|
SystemService: this._systemService
|
|
3992
3752
|
});
|
|
3993
3753
|
}
|
|
3994
3754
|
get isOpen() {
|
|
3995
3755
|
return this._open;
|
|
3996
3756
|
}
|
|
3757
|
+
get serviceRegistry() {
|
|
3758
|
+
return this._serviceRegistry;
|
|
3759
|
+
}
|
|
3997
3760
|
get descriptors() {
|
|
3998
3761
|
return this._serviceRegistry.descriptors;
|
|
3999
3762
|
}
|
|
4000
3763
|
get services() {
|
|
4001
3764
|
return this._serviceRegistry.services;
|
|
4002
3765
|
}
|
|
3766
|
+
/**
|
|
3767
|
+
* Initialize the service host with the config.
|
|
3768
|
+
* Config can also be provided in the constructor.
|
|
3769
|
+
* Can only be called once.
|
|
3770
|
+
*/
|
|
3771
|
+
initialize({ config, networkManager }) {
|
|
3772
|
+
(0, import_node_assert12.default)(!this._open, "service host is open");
|
|
3773
|
+
if (config) {
|
|
3774
|
+
(0, import_node_assert12.default)(!this._config, "config already set");
|
|
3775
|
+
this._config = config;
|
|
3776
|
+
if (!this._storage) {
|
|
3777
|
+
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
3778
|
+
}
|
|
3779
|
+
}
|
|
3780
|
+
if (networkManager) {
|
|
3781
|
+
(0, import_node_assert12.default)(!this._networkManager, "network manager already set");
|
|
3782
|
+
this._networkManager = networkManager;
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
4003
3785
|
async open() {
|
|
4004
3786
|
var _a, _b;
|
|
4005
3787
|
if (this._open) {
|
|
4006
3788
|
return;
|
|
4007
3789
|
}
|
|
4008
|
-
(0,
|
|
3790
|
+
(0, import_node_assert12.default)(this._config, "config not set");
|
|
3791
|
+
(0, import_node_assert12.default)(this._storage, "storage not set");
|
|
3792
|
+
(0, import_node_assert12.default)(this._networkManager, "network manager not set");
|
|
3793
|
+
(0, import_log15.log)("opening...", {}, {
|
|
4009
3794
|
file: "service-host.ts",
|
|
4010
|
-
line:
|
|
3795
|
+
line: 166,
|
|
4011
3796
|
scope: this,
|
|
4012
3797
|
callSite: (f, a) => f(...a)
|
|
4013
3798
|
});
|
|
@@ -4020,10 +3805,10 @@ var ClientServicesHost = class {
|
|
|
4020
3805
|
DeviceInvitationsService: new DeviceInvitationsServiceImpl(this._serviceContext.identityManager, this._serviceContext.deviceInvitations),
|
|
4021
3806
|
SpaceInvitationsService: new SpaceInvitationsServiceImpl(this._serviceContext.identityManager, () => {
|
|
4022
3807
|
var _a2;
|
|
4023
|
-
return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 : (0,
|
|
3808
|
+
return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceInvitations not initialized"));
|
|
4024
3809
|
}, () => {
|
|
4025
3810
|
var _a2;
|
|
4026
|
-
return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : (0,
|
|
3811
|
+
return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceManager not initialized"));
|
|
4027
3812
|
}),
|
|
4028
3813
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
4029
3814
|
await this._serviceContext.initialized.wait();
|
|
@@ -4043,11 +3828,11 @@ var ClientServicesHost = class {
|
|
|
4043
3828
|
this._open = true;
|
|
4044
3829
|
this._statusUpdate.emit();
|
|
4045
3830
|
const deviceKey = (_b = this._serviceContext.identityManager.identity) == null ? void 0 : _b.deviceKey;
|
|
4046
|
-
(0,
|
|
3831
|
+
(0, import_log15.log)("opened", {
|
|
4047
3832
|
deviceKey
|
|
4048
3833
|
}, {
|
|
4049
3834
|
file: "service-host.ts",
|
|
4050
|
-
line:
|
|
3835
|
+
line: 219,
|
|
4051
3836
|
scope: this,
|
|
4052
3837
|
callSite: (f, a) => f(...a)
|
|
4053
3838
|
});
|
|
@@ -4058,11 +3843,11 @@ var ClientServicesHost = class {
|
|
|
4058
3843
|
return;
|
|
4059
3844
|
}
|
|
4060
3845
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
4061
|
-
(0,
|
|
3846
|
+
(0, import_log15.log)("closing...", {
|
|
4062
3847
|
deviceKey
|
|
4063
3848
|
}, {
|
|
4064
3849
|
file: "service-host.ts",
|
|
4065
|
-
line:
|
|
3850
|
+
line: 228,
|
|
4066
3851
|
scope: this,
|
|
4067
3852
|
callSite: (f, a) => f(...a)
|
|
4068
3853
|
});
|
|
@@ -4072,49 +3857,17 @@ var ClientServicesHost = class {
|
|
|
4072
3857
|
await this._serviceContext.close();
|
|
4073
3858
|
this._open = false;
|
|
4074
3859
|
this._statusUpdate.emit();
|
|
4075
|
-
(0,
|
|
3860
|
+
(0, import_log15.log)("closed", {
|
|
4076
3861
|
deviceKey
|
|
4077
3862
|
}, {
|
|
4078
3863
|
file: "service-host.ts",
|
|
4079
|
-
line:
|
|
3864
|
+
line: 233,
|
|
4080
3865
|
scope: this,
|
|
4081
3866
|
callSite: (f, a) => f(...a)
|
|
4082
3867
|
});
|
|
4083
3868
|
}
|
|
4084
3869
|
};
|
|
4085
3870
|
|
|
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
3871
|
// packages/sdk/client-services/src/packlets/services/local-client-services.ts
|
|
4119
3872
|
var LocalClientServices = class {
|
|
4120
3873
|
constructor(params) {
|
|
@@ -4126,6 +3879,9 @@ var LocalClientServices = class {
|
|
|
4126
3879
|
get services() {
|
|
4127
3880
|
return this._host.services;
|
|
4128
3881
|
}
|
|
3882
|
+
get host() {
|
|
3883
|
+
return this._host;
|
|
3884
|
+
}
|
|
4129
3885
|
async open() {
|
|
4130
3886
|
await this._host.open();
|
|
4131
3887
|
}
|
|
@@ -4133,58 +3889,77 @@ var LocalClientServices = class {
|
|
|
4133
3889
|
await this._host.close();
|
|
4134
3890
|
}
|
|
4135
3891
|
};
|
|
3892
|
+
|
|
3893
|
+
// packages/sdk/client-services/src/packlets/services/utils.ts
|
|
3894
|
+
var import_config2 = require("@dxos/config");
|
|
3895
|
+
var import_log16 = require("@dxos/log");
|
|
3896
|
+
var import_messaging3 = require("@dxos/messaging");
|
|
3897
|
+
var import_network_manager6 = require("@dxos/network-manager");
|
|
3898
|
+
var fromHost = (config = new import_config2.Config()) => {
|
|
3899
|
+
return new LocalClientServices({
|
|
3900
|
+
config,
|
|
3901
|
+
networkManager: createNetworkManager(config)
|
|
3902
|
+
});
|
|
3903
|
+
};
|
|
3904
|
+
var createNetworkManager = (config, options = {}) => {
|
|
3905
|
+
const signalServer = config.get("runtime.services.signal.server");
|
|
3906
|
+
if (signalServer) {
|
|
3907
|
+
const { log: log1 = true, signalManager = new import_messaging3.WebsocketSignalManager([
|
|
3908
|
+
signalServer
|
|
3909
|
+
]), transportFactory = (0, import_network_manager6.createWebRTCTransportFactory)({
|
|
3910
|
+
iceServers: config.get("runtime.services.ice")
|
|
3911
|
+
}) } = options;
|
|
3912
|
+
return new import_network_manager6.NetworkManager({
|
|
3913
|
+
log: log1,
|
|
3914
|
+
signalManager,
|
|
3915
|
+
transportFactory
|
|
3916
|
+
});
|
|
3917
|
+
}
|
|
3918
|
+
import_log16.log.warn("P2P network is not configured.", {}, {
|
|
3919
|
+
file: "utils.ts",
|
|
3920
|
+
line: 48,
|
|
3921
|
+
scope: void 0,
|
|
3922
|
+
callSite: (f, a) => f(...a)
|
|
3923
|
+
});
|
|
3924
|
+
return new import_network_manager6.NetworkManager({
|
|
3925
|
+
signalManager: new import_messaging3.MemorySignalManager(new import_messaging3.MemorySignalManagerContext()),
|
|
3926
|
+
transportFactory: import_network_manager6.MemoryTransportFactory
|
|
3927
|
+
});
|
|
3928
|
+
};
|
|
4136
3929
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4137
3930
|
0 && (module.exports = {
|
|
4138
|
-
AUTHENTICATION_CODE_LENGTH,
|
|
4139
|
-
AbstractInvitationsHandler,
|
|
4140
|
-
AbstractInvitationsProxy,
|
|
4141
3931
|
AbstractInvitationsService,
|
|
4142
|
-
AuthenticatingInvitationProvider,
|
|
4143
3932
|
ClientServicesHost,
|
|
4144
|
-
ClientServicesProxy,
|
|
4145
3933
|
DeviceInvitationsHandler,
|
|
4146
|
-
DeviceInvitationsProxy,
|
|
4147
3934
|
DeviceInvitationsServiceImpl,
|
|
4148
3935
|
DevtoolsHostEvents,
|
|
4149
3936
|
DevtoolsServiceImpl,
|
|
4150
3937
|
IFrameHostRuntime,
|
|
4151
3938
|
IFrameProxyRuntime,
|
|
4152
|
-
INVITATION_TIMEOUT,
|
|
4153
3939
|
Identity,
|
|
4154
3940
|
IdentityManager,
|
|
4155
3941
|
IdentityServiceImpl,
|
|
4156
|
-
InvitationEncoder,
|
|
4157
|
-
InvitationObservableProvider,
|
|
4158
3942
|
LocalClientServices,
|
|
4159
3943
|
MemoryShellRuntime,
|
|
4160
|
-
ON_CLOSE_DELAY,
|
|
4161
3944
|
ServiceContext,
|
|
4162
3945
|
ServiceRegistry,
|
|
4163
|
-
ShellController,
|
|
4164
3946
|
ShellRuntimeImpl,
|
|
4165
3947
|
SpaceInvitationsHandler,
|
|
4166
|
-
SpaceInvitationsProxy,
|
|
4167
3948
|
SpaceInvitationsServiceImpl,
|
|
4168
3949
|
TrustedKeySetAuthVerifier,
|
|
4169
3950
|
VaultResourceLock,
|
|
4170
3951
|
WorkerRuntime,
|
|
4171
3952
|
WorkerSession,
|
|
4172
|
-
appServiceBundle,
|
|
4173
|
-
clientServiceBundle,
|
|
4174
3953
|
createAuthProvider,
|
|
4175
|
-
createDefaultModelFactory,
|
|
4176
3954
|
createStorageObjects,
|
|
3955
|
+
fromHost,
|
|
4177
3956
|
getNetworkPeers,
|
|
4178
|
-
iframeServiceBundle,
|
|
4179
|
-
shellServiceBundle,
|
|
4180
3957
|
subscribeToFeedBlocks,
|
|
4181
3958
|
subscribeToFeeds,
|
|
4182
3959
|
subscribeToNetworkStatus,
|
|
4183
3960
|
subscribeToNetworkTopics,
|
|
4184
3961
|
subscribeToSignal,
|
|
4185
3962
|
subscribeToSpaces,
|
|
4186
|
-
subscribeToSwarmInfo
|
|
4187
|
-
workerServiceBundle,
|
|
4188
|
-
wrapObservable
|
|
3963
|
+
subscribeToSwarmInfo
|
|
4189
3964
|
});
|
|
4190
3965
|
//# sourceMappingURL=index.cjs.map
|