@openfin/core 25.68.26
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/LICENSE +13 -0
- package/NOTICE +16 -0
- package/OpenFin.d.ts +1340 -0
- package/README.md +41 -0
- package/docs.README(OLD).md +82 -0
- package/fin.d.ts +4 -0
- package/package.json +33 -0
- package/resources/win/OpenFinRVM.exe +0 -0
- package/src/api/application/Factory.d.ts +145 -0
- package/src/api/application/Factory.js +229 -0
- package/src/api/application/Instance.d.ts +302 -0
- package/src/api/application/Instance.js +412 -0
- package/src/api/application/index.d.ts +3 -0
- package/src/api/application/index.js +15 -0
- package/src/api/base.d.ts +43 -0
- package/src/api/base.js +177 -0
- package/src/api/clipboard/index.d.ts +69 -0
- package/src/api/clipboard/index.js +88 -0
- package/src/api/events/application.d.ts +69 -0
- package/src/api/events/application.js +2 -0
- package/src/api/events/base.d.ts +17 -0
- package/src/api/events/base.js +2 -0
- package/src/api/events/channel.d.ts +10 -0
- package/src/api/events/channel.js +2 -0
- package/src/api/events/emitterMap.d.ts +11 -0
- package/src/api/events/emitterMap.js +35 -0
- package/src/api/events/eventAggregator.d.ts +5 -0
- package/src/api/events/eventAggregator.js +43 -0
- package/src/api/events/externalApplication.d.ts +5 -0
- package/src/api/events/externalApplication.js +2 -0
- package/src/api/events/frame.d.ts +9 -0
- package/src/api/events/frame.js +2 -0
- package/src/api/events/globalHotkey.d.ts +10 -0
- package/src/api/events/globalHotkey.js +2 -0
- package/src/api/events/platform.d.ts +18 -0
- package/src/api/events/platform.js +2 -0
- package/src/api/events/system.d.ts +22 -0
- package/src/api/events/system.js +2 -0
- package/src/api/events/view.d.ts +56 -0
- package/src/api/events/view.js +2 -0
- package/src/api/events/webcontents.d.ts +48 -0
- package/src/api/events/webcontents.js +2 -0
- package/src/api/events/window.d.ts +169 -0
- package/src/api/events/window.js +2 -0
- package/src/api/external-application/Factory.d.ts +26 -0
- package/src/api/external-application/Factory.js +40 -0
- package/src/api/external-application/Instance.d.ts +102 -0
- package/src/api/external-application/Instance.js +109 -0
- package/src/api/external-application/index.d.ts +3 -0
- package/src/api/external-application/index.js +15 -0
- package/src/api/fin.d.ts +49 -0
- package/src/api/fin.js +43 -0
- package/src/api/frame/Factory.d.ts +36 -0
- package/src/api/frame/Factory.js +69 -0
- package/src/api/frame/Instance.d.ts +121 -0
- package/src/api/frame/Instance.js +130 -0
- package/src/api/frame/index.d.ts +3 -0
- package/src/api/frame/index.js +15 -0
- package/src/api/global-hotkey/index.d.ts +38 -0
- package/src/api/global-hotkey/index.js +58 -0
- package/src/api/interappbus/channel/channel.d.ts +26 -0
- package/src/api/interappbus/channel/channel.js +77 -0
- package/src/api/interappbus/channel/channels-docs.d.ts +318 -0
- package/src/api/interappbus/channel/channels-docs.js +376 -0
- package/src/api/interappbus/channel/client.d.ts +22 -0
- package/src/api/interappbus/channel/client.js +84 -0
- package/src/api/interappbus/channel/connection-manager.d.ts +28 -0
- package/src/api/interappbus/channel/connection-manager.js +244 -0
- package/src/api/interappbus/channel/index.d.ts +22 -0
- package/src/api/interappbus/channel/index.js +121 -0
- package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +13 -0
- package/src/api/interappbus/channel/protocols/classic/message-receiver.js +73 -0
- package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +22 -0
- package/src/api/interappbus/channel/protocols/classic/strategy.js +84 -0
- package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +20 -0
- package/src/api/interappbus/channel/protocols/combined/strategy.js +58 -0
- package/src/api/interappbus/channel/protocols/index.d.ts +44 -0
- package/src/api/interappbus/channel/protocols/index.js +2 -0
- package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +10 -0
- package/src/api/interappbus/channel/protocols/protocol-manager.js +43 -0
- package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +23 -0
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +135 -0
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +30 -0
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +131 -0
- package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +22 -0
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +87 -0
- package/src/api/interappbus/channel/protocols/strategy-types.d.ts +13 -0
- package/src/api/interappbus/channel/protocols/strategy-types.js +2 -0
- package/src/api/interappbus/channel/protocols/strategy.d.ts +15 -0
- package/src/api/interappbus/channel/protocols/strategy.js +2 -0
- package/src/api/interappbus/channel/provider.d.ts +31 -0
- package/src/api/interappbus/channel/provider.js +165 -0
- package/src/api/interappbus/index.d.ts +85 -0
- package/src/api/interappbus/index.js +175 -0
- package/src/api/interop/Factory.d.ts +37 -0
- package/src/api/interop/Factory.js +54 -0
- package/src/api/interop/InteropBroker.d.ts +363 -0
- package/src/api/interop/InteropBroker.js +914 -0
- package/src/api/interop/InteropClient.d.ts +268 -0
- package/src/api/interop/InteropClient.js +450 -0
- package/src/api/interop/SessionContextGroupBroker.d.ts +26 -0
- package/src/api/interop/SessionContextGroupBroker.js +107 -0
- package/src/api/interop/SessionContextGroupClient.d.ts +20 -0
- package/src/api/interop/SessionContextGroupClient.js +85 -0
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +187 -0
- package/src/api/interop/fdc3/fdc3-1.2.js +385 -0
- package/src/api/interop/fdc3/fdc3.js +17 -0
- package/src/api/interop/fdc3/utils.d.ts +6 -0
- package/src/api/interop/fdc3/utils.js +17 -0
- package/src/api/interop/index.d.ts +4 -0
- package/src/api/interop/index.js +16 -0
- package/src/api/interop/utils.d.ts +11 -0
- package/src/api/interop/utils.js +36 -0
- package/src/api/me.d.ts +35 -0
- package/src/api/me.js +60 -0
- package/src/api/platform/Factory.d.ts +109 -0
- package/src/api/platform/Factory.js +188 -0
- package/src/api/platform/Instance.d.ts +122 -0
- package/src/api/platform/Instance.js +299 -0
- package/src/api/platform/common-utils.d.ts +6 -0
- package/src/api/platform/common-utils.js +16 -0
- package/src/api/platform/index.d.ts +3 -0
- package/src/api/platform/index.js +15 -0
- package/src/api/platform/layout/Factory.d.ts +108 -0
- package/src/api/platform/layout/Factory.js +189 -0
- package/src/api/platform/layout/Instance.d.ts +48 -0
- package/src/api/platform/layout/Instance.js +99 -0
- package/src/api/platform/layout/index.d.ts +3 -0
- package/src/api/platform/layout/index.js +15 -0
- package/src/api/platform/layout/shapes.d.ts +11 -0
- package/src/api/platform/layout/shapes.js +2 -0
- package/src/api/snapshot-source/Factory.d.ts +36 -0
- package/src/api/snapshot-source/Factory.js +65 -0
- package/src/api/snapshot-source/Instance.d.ts +30 -0
- package/src/api/snapshot-source/Instance.js +134 -0
- package/src/api/snapshot-source/index.d.ts +3 -0
- package/src/api/snapshot-source/index.js +15 -0
- package/src/api/snapshot-source/utils.d.ts +1 -0
- package/src/api/snapshot-source/utils.js +5 -0
- package/src/api/system/application.d.ts +6 -0
- package/src/api/system/application.js +2 -0
- package/src/api/system/entity.d.ts +11 -0
- package/src/api/system/entity.js +2 -0
- package/src/api/system/index.d.ts +957 -0
- package/src/api/system/index.js +1241 -0
- package/src/api/system/installedApps.d.ts +6 -0
- package/src/api/system/installedApps.js +2 -0
- package/src/api/system/log.d.ts +11 -0
- package/src/api/system/log.js +2 -0
- package/src/api/system/process.d.ts +15 -0
- package/src/api/system/process.js +2 -0
- package/src/api/system/proxy.d.ts +15 -0
- package/src/api/system/proxy.js +2 -0
- package/src/api/system/queryPermissionTypes.d.ts +1 -0
- package/src/api/system/queryPermissionTypes.js +2 -0
- package/src/api/system/registry-info.d.ts +7 -0
- package/src/api/system/registry-info.js +2 -0
- package/src/api/system/window.d.ts +16 -0
- package/src/api/system/window.js +2 -0
- package/src/api/view/Factory.d.ts +49 -0
- package/src/api/view/Factory.js +103 -0
- package/src/api/view/Instance.d.ts +379 -0
- package/src/api/view/Instance.js +415 -0
- package/src/api/view/index.d.ts +3 -0
- package/src/api/view/index.js +15 -0
- package/src/api/webcontents/main.d.ts +36 -0
- package/src/api/webcontents/main.js +82 -0
- package/src/api/window/Factory.d.ts +44 -0
- package/src/api/window/Factory.js +91 -0
- package/src/api/window/Instance.d.ts +966 -0
- package/src/api/window/Instance.js +1202 -0
- package/src/api/window/bounds-changed.d.ts +10 -0
- package/src/api/window/bounds-changed.js +6 -0
- package/src/api/window/index.d.ts +5 -0
- package/src/api/window/index.js +17 -0
- package/src/api/window/shapes.d.ts +13 -0
- package/src/api/window/shapes.js +2 -0
- package/src/environment/environment.d.ts +28 -0
- package/src/environment/environment.js +4 -0
- package/src/environment/node-env.d.ts +25 -0
- package/src/environment/node-env.js +64 -0
- package/src/environment/openfin-env.d.ts +29 -0
- package/src/environment/openfin-env.js +105 -0
- package/src/mock.d.ts +4 -0
- package/src/mock.js +91 -0
- package/src/shapes/ERROR_BOX_TYPES.d.ts +6 -0
- package/src/shapes/ERROR_BOX_TYPES.js +10 -0
- package/src/shapes/EntityType.d.ts +1 -0
- package/src/shapes/EntityType.js +2 -0
- package/src/shapes/LayoutPresetType.d.ts +1 -0
- package/src/shapes/LayoutPresetType.js +2 -0
- package/src/shapes/Platform.d.ts +112 -0
- package/src/shapes/Platform.js +16 -0
- package/src/shapes/WebOptions.d.ts +12 -0
- package/src/shapes/WebOptions.js +2 -0
- package/src/shapes/WindowOptions.d.ts +42 -0
- package/src/shapes/WindowOptions.js +2 -0
- package/src/shapes/protocol.d.ts +178 -0
- package/src/shapes/protocol.js +2 -0
- package/src/transport/fin_store.d.ts +4 -0
- package/src/transport/fin_store.js +16 -0
- package/src/transport/transport-errors.d.ts +17 -0
- package/src/transport/transport-errors.js +39 -0
- package/src/transport/transport.d.ts +57 -0
- package/src/transport/transport.js +195 -0
- package/src/transport/wire.d.ts +76 -0
- package/src/transport/wire.js +39 -0
- package/src/util/asyncFilter.d.ts +1 -0
- package/src/util/asyncFilter.js +7 -0
- package/src/util/errors.d.ts +9 -0
- package/src/util/errors.js +14 -0
- package/src/util/exhaustive.d.ts +1 -0
- package/src/util/exhaustive.js +7 -0
- package/src/util/http.d.ts +11 -0
- package/src/util/http.js +83 -0
- package/src/util/normalize-config.d.ts +3 -0
- package/src/util/normalize-config.js +47 -0
- package/src/util/promises.d.ts +5 -0
- package/src/util/promises.js +27 -0
- package/src/util/ref-counter.d.ts +7 -0
- package/src/util/ref-counter.js +51 -0
- package/src/util/runtimeVersioning.d.ts +3 -0
- package/src/util/runtimeVersioning.js +25 -0
- package/src/util/utilTypes.d.ts +8 -0
- package/src/util/utilTypes.js +2 -0
- package/src/util/validate.d.ts +3 -0
- package/src/util/validate.js +11 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { AuthorizationPayload } from '../transport/transport';
|
|
2
|
+
export interface ProtocolMap extends ProtocolMapBase {
|
|
3
|
+
'request-external-authorization': {
|
|
4
|
+
request: any;
|
|
5
|
+
response: void;
|
|
6
|
+
specialResponse: AuthorizationPayload;
|
|
7
|
+
};
|
|
8
|
+
'application-get-views': {
|
|
9
|
+
request: OpenFin.ApplicationIdentity;
|
|
10
|
+
response: OpenFin.Identity[];
|
|
11
|
+
};
|
|
12
|
+
'set-jump-list': {
|
|
13
|
+
request: {
|
|
14
|
+
config: OpenFin.JumpListCategory[] | null;
|
|
15
|
+
} & OpenFin.ApplicationIdentity;
|
|
16
|
+
response: void;
|
|
17
|
+
};
|
|
18
|
+
'get-view-window': {
|
|
19
|
+
request: OpenFin.Identity;
|
|
20
|
+
response: OpenFin.Identity;
|
|
21
|
+
};
|
|
22
|
+
'window-get-views': {
|
|
23
|
+
request: OpenFin.Identity;
|
|
24
|
+
response: OpenFin.Identity[];
|
|
25
|
+
};
|
|
26
|
+
'hide-view': {
|
|
27
|
+
request: OpenFin.Identity;
|
|
28
|
+
response: void;
|
|
29
|
+
};
|
|
30
|
+
'launch-manifest': {
|
|
31
|
+
request: {
|
|
32
|
+
manifestUrl: string;
|
|
33
|
+
opts?: OpenFin.RvmLaunchOptions;
|
|
34
|
+
};
|
|
35
|
+
response: {
|
|
36
|
+
manifest: OpenFin.Manifest;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
'get-system-app-configuration': {
|
|
40
|
+
request: {
|
|
41
|
+
name: string;
|
|
42
|
+
};
|
|
43
|
+
response: any;
|
|
44
|
+
};
|
|
45
|
+
'show-popup-menu': {
|
|
46
|
+
request: OpenFin.Identity & {
|
|
47
|
+
options: OpenFin.ShowPopupMenuOptions;
|
|
48
|
+
};
|
|
49
|
+
response: OpenFin.MenuResult;
|
|
50
|
+
};
|
|
51
|
+
'enable-native-window-integration-provider': {
|
|
52
|
+
request: {
|
|
53
|
+
permissions: any;
|
|
54
|
+
};
|
|
55
|
+
response: OpenFin.NativeWindowIntegrationProviderAuthorization;
|
|
56
|
+
};
|
|
57
|
+
'get-permissions': {
|
|
58
|
+
request: void;
|
|
59
|
+
response: any;
|
|
60
|
+
};
|
|
61
|
+
'set-file-download-location': {
|
|
62
|
+
request: OpenFin.ApplicationIdentity & {
|
|
63
|
+
downloadLocation: string;
|
|
64
|
+
};
|
|
65
|
+
response: void;
|
|
66
|
+
};
|
|
67
|
+
'close-popup-menu': {
|
|
68
|
+
request: OpenFin.Identity;
|
|
69
|
+
response: void;
|
|
70
|
+
};
|
|
71
|
+
'fdc3-add-context-listener': {
|
|
72
|
+
request: void;
|
|
73
|
+
response: void;
|
|
74
|
+
};
|
|
75
|
+
'fdc3-broadcast': {
|
|
76
|
+
request: void;
|
|
77
|
+
response: void;
|
|
78
|
+
};
|
|
79
|
+
'fdc3-get-system-channels': {
|
|
80
|
+
request: void;
|
|
81
|
+
response: void;
|
|
82
|
+
};
|
|
83
|
+
'fdc3-join-channel': {
|
|
84
|
+
request: void;
|
|
85
|
+
response: void;
|
|
86
|
+
};
|
|
87
|
+
'fdc3-leave-current-channel': {
|
|
88
|
+
request: void;
|
|
89
|
+
response: void;
|
|
90
|
+
};
|
|
91
|
+
'interop-connect-sync': {
|
|
92
|
+
request: void;
|
|
93
|
+
response: void;
|
|
94
|
+
};
|
|
95
|
+
'interop-client-set-context': {
|
|
96
|
+
request: void;
|
|
97
|
+
response: void;
|
|
98
|
+
};
|
|
99
|
+
'interop-client-add-context-handler': {
|
|
100
|
+
request: void;
|
|
101
|
+
response: void;
|
|
102
|
+
};
|
|
103
|
+
'interop-client-get-context-groups': {
|
|
104
|
+
request: void;
|
|
105
|
+
response: void;
|
|
106
|
+
};
|
|
107
|
+
'interop-client-join-context-group': {
|
|
108
|
+
request: void;
|
|
109
|
+
response: void;
|
|
110
|
+
};
|
|
111
|
+
'interop-client-remove-from-context-group': {
|
|
112
|
+
request: void;
|
|
113
|
+
response: void;
|
|
114
|
+
};
|
|
115
|
+
'interop-client-get-all-clients-in-context-group': {
|
|
116
|
+
request: void;
|
|
117
|
+
response: void;
|
|
118
|
+
};
|
|
119
|
+
'interop-client-get-info-for-context-group': {
|
|
120
|
+
request: void;
|
|
121
|
+
response: void;
|
|
122
|
+
};
|
|
123
|
+
'interop-broker-add-client-to-context-group': {
|
|
124
|
+
request: void;
|
|
125
|
+
response: void;
|
|
126
|
+
};
|
|
127
|
+
'interop-broker-get-all-clients-in-context-group': {
|
|
128
|
+
request: void;
|
|
129
|
+
response: void;
|
|
130
|
+
};
|
|
131
|
+
'interop-broker-get-context-groups': {
|
|
132
|
+
request: void;
|
|
133
|
+
response: void;
|
|
134
|
+
};
|
|
135
|
+
'interop-broker-get-info-for-context-group': {
|
|
136
|
+
request: void;
|
|
137
|
+
response: void;
|
|
138
|
+
};
|
|
139
|
+
'interop-broker-is-action-authorized': {
|
|
140
|
+
request: void;
|
|
141
|
+
response: void;
|
|
142
|
+
};
|
|
143
|
+
'interop-broker-is-connection-authorized': {
|
|
144
|
+
request: void;
|
|
145
|
+
response: void;
|
|
146
|
+
};
|
|
147
|
+
'interop-broker-join-context-group': {
|
|
148
|
+
request: void;
|
|
149
|
+
response: void;
|
|
150
|
+
};
|
|
151
|
+
'interop-broker-remove-client-from-context-group': {
|
|
152
|
+
request: void;
|
|
153
|
+
response: void;
|
|
154
|
+
};
|
|
155
|
+
'interop-broker-remove-from-context-group': {
|
|
156
|
+
request: void;
|
|
157
|
+
response: void;
|
|
158
|
+
};
|
|
159
|
+
'interop-broker-set-context': {
|
|
160
|
+
request: void;
|
|
161
|
+
response: void;
|
|
162
|
+
};
|
|
163
|
+
'query-permission-for-current-context': {
|
|
164
|
+
request: {
|
|
165
|
+
apiName: string;
|
|
166
|
+
identity: OpenFin.Identity;
|
|
167
|
+
};
|
|
168
|
+
response: OpenFin.QueryPermissionResult;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
interface ProtocolMapBase {
|
|
172
|
+
[action: string]: {
|
|
173
|
+
request: any;
|
|
174
|
+
response: any;
|
|
175
|
+
specialResponse?: any;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFin = exports.registerFin = void 0;
|
|
4
|
+
const finMap = new WeakMap();
|
|
5
|
+
function registerFin(wire, fin) {
|
|
6
|
+
finMap.set(wire, fin);
|
|
7
|
+
}
|
|
8
|
+
exports.registerFin = registerFin;
|
|
9
|
+
function getFin(wire) {
|
|
10
|
+
const fin = finMap.get(wire);
|
|
11
|
+
if (!fin) {
|
|
12
|
+
throw new Error('Could not locate fin api for given transport');
|
|
13
|
+
}
|
|
14
|
+
return fin;
|
|
15
|
+
}
|
|
16
|
+
exports.getFin = getFin;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class DisconnectedError extends Error {
|
|
2
|
+
constructor(readyState: number);
|
|
3
|
+
readyState: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class UnexpectedActionError extends Error {
|
|
6
|
+
}
|
|
7
|
+
export declare class DuplicateCorrelationError extends Error {
|
|
8
|
+
}
|
|
9
|
+
export declare class NoAckError extends Error {
|
|
10
|
+
}
|
|
11
|
+
export declare class NotImplementedError extends Error {
|
|
12
|
+
}
|
|
13
|
+
export declare class NotSupportedError extends Error {
|
|
14
|
+
}
|
|
15
|
+
export declare class RuntimeError extends Error {
|
|
16
|
+
constructor(data: any);
|
|
17
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RuntimeError = exports.NotSupportedError = exports.NotImplementedError = exports.NoAckError = exports.DuplicateCorrelationError = exports.UnexpectedActionError = exports.DisconnectedError = void 0;
|
|
4
|
+
/* eslint-disable max-classes-per-file */
|
|
5
|
+
const wire_1 = require("./wire");
|
|
6
|
+
class DisconnectedError extends Error {
|
|
7
|
+
constructor(readyState) {
|
|
8
|
+
super(`Expected websocket state OPEN but found ${wire_1.READY_STATE[readyState]}`);
|
|
9
|
+
this.readyState = readyState;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.DisconnectedError = DisconnectedError;
|
|
13
|
+
class UnexpectedActionError extends Error {
|
|
14
|
+
}
|
|
15
|
+
exports.UnexpectedActionError = UnexpectedActionError;
|
|
16
|
+
class DuplicateCorrelationError extends Error {
|
|
17
|
+
}
|
|
18
|
+
exports.DuplicateCorrelationError = DuplicateCorrelationError;
|
|
19
|
+
class NoAckError extends Error {
|
|
20
|
+
}
|
|
21
|
+
exports.NoAckError = NoAckError;
|
|
22
|
+
class NotImplementedError extends Error {
|
|
23
|
+
}
|
|
24
|
+
exports.NotImplementedError = NotImplementedError;
|
|
25
|
+
class NotSupportedError extends Error {
|
|
26
|
+
}
|
|
27
|
+
exports.NotSupportedError = NotSupportedError;
|
|
28
|
+
class RuntimeError extends Error {
|
|
29
|
+
constructor(data) {
|
|
30
|
+
const payload = data.payload || data;
|
|
31
|
+
const { reason, error } = payload;
|
|
32
|
+
super(reason);
|
|
33
|
+
this.name = 'RuntimeError';
|
|
34
|
+
if (error === null || error === void 0 ? void 0 : error.stack) {
|
|
35
|
+
this.stack = error.stack;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.RuntimeError = RuntimeError;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { Wire, WireConstructor, READY_STATE, ExistingConnectConfig, InternalConnectConfig } from './wire';
|
|
4
|
+
import { Environment } from '../environment/environment';
|
|
5
|
+
import { RuntimeEvent } from '../api/events/base';
|
|
6
|
+
import EventAggregator from '../api/events/eventAggregator';
|
|
7
|
+
import { EntityTypeHelpers } from '../api/me';
|
|
8
|
+
import { EntityType } from '../shapes/EntityType';
|
|
9
|
+
import { ProtocolMap } from '../shapes/protocol';
|
|
10
|
+
export declare type MessageHandler = (data: any) => boolean;
|
|
11
|
+
declare class Transport<MeType extends EntityType = EntityType> extends EventEmitter {
|
|
12
|
+
#private;
|
|
13
|
+
protected wireListeners: Map<number, {
|
|
14
|
+
resolve: Function;
|
|
15
|
+
reject: Function;
|
|
16
|
+
}>;
|
|
17
|
+
protected uncorrelatedListener: Function;
|
|
18
|
+
me: OpenFin.EntityInfo & EntityTypeHelpers<MeType>;
|
|
19
|
+
environment: Environment;
|
|
20
|
+
topicRefMap: Map<string, number>;
|
|
21
|
+
sendRaw: Wire['send'];
|
|
22
|
+
eventAggregator: EventAggregator;
|
|
23
|
+
protected messageHandlers: MessageHandler[];
|
|
24
|
+
constructor(WireType: WireConstructor, environment: Environment, config: OpenFin.Identity);
|
|
25
|
+
connectSync: () => void;
|
|
26
|
+
getPort: () => string;
|
|
27
|
+
shutdown(): Promise<void>;
|
|
28
|
+
connect(config: InternalConnectConfig): Promise<string | void>;
|
|
29
|
+
connectByPort(config: ExistingConnectConfig): Promise<string>;
|
|
30
|
+
READY_STATE: typeof READY_STATE;
|
|
31
|
+
sendAction<T extends keyof ProtocolMap = string>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): Promise<Message<{
|
|
32
|
+
data: ProtocolMap[T]['response'];
|
|
33
|
+
} & ProtocolMap[T]['specialResponse']>>;
|
|
34
|
+
ferryAction(origData: any): Promise<Message<any>>;
|
|
35
|
+
registerMessageHandler(handler: MessageHandler): void;
|
|
36
|
+
protected addWireListener(id: number, resolve: Function, reject: Function, uncorrelated: boolean): void;
|
|
37
|
+
protected onmessage(data: Message<Payload>): void;
|
|
38
|
+
protected handleMessage(data: Message<Payload>): boolean;
|
|
39
|
+
}
|
|
40
|
+
export default Transport;
|
|
41
|
+
export interface Message<T> {
|
|
42
|
+
action: string;
|
|
43
|
+
payload: T;
|
|
44
|
+
correlationId?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface EventMessage extends Message<RuntimeEvent> {
|
|
47
|
+
action: 'process-desktop-event';
|
|
48
|
+
payload: RuntimeEvent;
|
|
49
|
+
}
|
|
50
|
+
export interface Payload {
|
|
51
|
+
success: boolean;
|
|
52
|
+
data: any;
|
|
53
|
+
}
|
|
54
|
+
export interface AuthorizationPayload {
|
|
55
|
+
token: string;
|
|
56
|
+
file: string;
|
|
57
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
|
|
3
|
+
if (!privateMap.has(receiver)) {
|
|
4
|
+
throw new TypeError("attempted to set private field on non-instance");
|
|
5
|
+
}
|
|
6
|
+
privateMap.set(receiver, value);
|
|
7
|
+
return value;
|
|
8
|
+
};
|
|
9
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
|
|
10
|
+
if (!privateMap.has(receiver)) {
|
|
11
|
+
throw new TypeError("attempted to get private field on non-instance");
|
|
12
|
+
}
|
|
13
|
+
return privateMap.get(receiver);
|
|
14
|
+
};
|
|
15
|
+
var _wire;
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const events_1 = require("events");
|
|
18
|
+
const wire_1 = require("./wire");
|
|
19
|
+
const transport_errors_1 = require("./transport-errors");
|
|
20
|
+
const eventAggregator_1 = require("../api/events/eventAggregator");
|
|
21
|
+
const me_1 = require("../api/me");
|
|
22
|
+
class Transport extends events_1.EventEmitter {
|
|
23
|
+
constructor(WireType, environment, config) {
|
|
24
|
+
super();
|
|
25
|
+
this.wireListeners = new Map();
|
|
26
|
+
this.topicRefMap = new Map();
|
|
27
|
+
this.eventAggregator = new eventAggregator_1.default();
|
|
28
|
+
this.messageHandlers = [this.eventAggregator.dispatchEvent];
|
|
29
|
+
_wire.set(this, void 0);
|
|
30
|
+
this.connectSync = () => {
|
|
31
|
+
const wire = __classPrivateFieldGet(this, _wire);
|
|
32
|
+
wire.connectSync();
|
|
33
|
+
};
|
|
34
|
+
// This function is only used in our tests.
|
|
35
|
+
this.getPort = () => {
|
|
36
|
+
if (this.environment.constructor.name !== 'NodeEnvironment') {
|
|
37
|
+
throw new transport_errors_1.NotImplementedError('Not Implemented');
|
|
38
|
+
}
|
|
39
|
+
const wire = __classPrivateFieldGet(this, _wire);
|
|
40
|
+
return wire.wire.url.split(':').slice(-1)[0];
|
|
41
|
+
};
|
|
42
|
+
/* `READY_STATE` is an instance var set by `constructor` to reference the `WebTransportSocket.READY_STATE` enum.
|
|
43
|
+
* This is syntactic sugar that makes the enum accessible through the `wire` property of the various `fin` singletons.
|
|
44
|
+
* For example, `fin.system.wire.READY_STATE` is a shortcut to `fin.system.wire.wire.constructor.READY_STATE`.
|
|
45
|
+
* However it is accessed, the enum is useful for interrogating the state of the web socket on send failure.
|
|
46
|
+
* The `err.readyState` value is passed to the `reject` handler of the promise returned by either of
|
|
47
|
+
* `sendAction` or `ferryAction`, and hence all the API methods in the various `fin` singletons that call them.
|
|
48
|
+
* The enum can be used in two distinct ways by the `reject` handler (using `fin.System.getVersion` by way of example):
|
|
49
|
+
* 1. State name by state value:
|
|
50
|
+
* fin.system.getVersion().catch(err => { console.log('State:', fin.system.wire.READY_STATE[err.readyState]); });
|
|
51
|
+
* 2. State value by state name:
|
|
52
|
+
* fin.system.getVersion().catch(err => { console.log('Closed:', err.readyState === fin.system.wire.READY_STATE.CLOSED); });
|
|
53
|
+
* Note that `reject` is called when and only when `readyState` is not `OPEN`.
|
|
54
|
+
*/
|
|
55
|
+
this.READY_STATE = wire_1.READY_STATE;
|
|
56
|
+
__classPrivateFieldSet(this, _wire, new WireType(this.onmessage.bind(this)));
|
|
57
|
+
this.environment = environment;
|
|
58
|
+
this.sendRaw = __classPrivateFieldGet(this, _wire).send.bind(__classPrivateFieldGet(this, _wire));
|
|
59
|
+
this.registerMessageHandler(this.handleMessage.bind(this));
|
|
60
|
+
__classPrivateFieldGet(this, _wire).on('disconnected', () => {
|
|
61
|
+
for (const [, { reject }] of this.wireListeners) {
|
|
62
|
+
reject('Remote connection has closed');
|
|
63
|
+
}
|
|
64
|
+
this.wireListeners.clear();
|
|
65
|
+
this.emit('disconnected');
|
|
66
|
+
});
|
|
67
|
+
const { uuid, name } = config;
|
|
68
|
+
const entityType = this.environment.getCurrentEntityType();
|
|
69
|
+
this.me = me_1.getBaseMe(entityType, uuid, name);
|
|
70
|
+
}
|
|
71
|
+
shutdown() {
|
|
72
|
+
const wire = __classPrivateFieldGet(this, _wire);
|
|
73
|
+
return wire.shutdown();
|
|
74
|
+
}
|
|
75
|
+
async connect(config) {
|
|
76
|
+
if (wire_1.isExistingConnectConfig(config)) {
|
|
77
|
+
return this.connectByPort(config);
|
|
78
|
+
}
|
|
79
|
+
if (wire_1.isNewConnectConfig(config)) {
|
|
80
|
+
const port = await this.environment.retrievePort(config);
|
|
81
|
+
return this.connectByPort({ ...config, address: `ws://localhost:${port}` });
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
async connectByPort(config) {
|
|
86
|
+
const { address, uuid } = config;
|
|
87
|
+
const reqAuthPayload = { ...config, type: 'file-token' };
|
|
88
|
+
const wire = __classPrivateFieldGet(this, _wire);
|
|
89
|
+
await wire.connect(address);
|
|
90
|
+
const requestExtAuthRet = await this.sendAction('request-external-authorization', {
|
|
91
|
+
uuid,
|
|
92
|
+
type: 'file-token'
|
|
93
|
+
}, true);
|
|
94
|
+
if (requestExtAuthRet.action !== 'external-authorization-response') {
|
|
95
|
+
throw new transport_errors_1.UnexpectedActionError(requestExtAuthRet.action);
|
|
96
|
+
}
|
|
97
|
+
const { token } = requestExtAuthRet.payload;
|
|
98
|
+
await this.environment.writeToken(requestExtAuthRet.payload.file, requestExtAuthRet.payload.token);
|
|
99
|
+
const requestAuthRet = await this.sendAction('request-authorization', reqAuthPayload, true);
|
|
100
|
+
if (requestAuthRet.action !== 'authorization-response') {
|
|
101
|
+
throw new transport_errors_1.UnexpectedActionError(requestAuthRet.action);
|
|
102
|
+
}
|
|
103
|
+
else if (requestAuthRet.payload.success !== true) {
|
|
104
|
+
throw new transport_errors_1.RuntimeError(requestAuthRet.payload);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return token;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
sendAction(action, payload = {}, uncorrelated = false
|
|
111
|
+
// specialResponse type is only used for 'requestAuthorization'
|
|
112
|
+
) {
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
const id = this.environment.getNextMessageId();
|
|
115
|
+
const msg = {
|
|
116
|
+
action,
|
|
117
|
+
payload,
|
|
118
|
+
messageId: id
|
|
119
|
+
};
|
|
120
|
+
const wire = __classPrivateFieldGet(this, _wire);
|
|
121
|
+
this.addWireListener(id, resolve, reject, uncorrelated);
|
|
122
|
+
return wire.send(msg).catch(reject);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
ferryAction(origData) {
|
|
126
|
+
return new Promise((resolve, reject) => {
|
|
127
|
+
const id = this.environment.getNextMessageId();
|
|
128
|
+
origData.messageId = id;
|
|
129
|
+
const resolver = (data) => {
|
|
130
|
+
resolve(data.payload);
|
|
131
|
+
};
|
|
132
|
+
const wire = __classPrivateFieldGet(this, _wire);
|
|
133
|
+
return wire
|
|
134
|
+
.send(origData)
|
|
135
|
+
.then(() => this.addWireListener(id, resolver, reject, false))
|
|
136
|
+
.catch(reject);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
registerMessageHandler(handler) {
|
|
140
|
+
this.messageHandlers.push(handler);
|
|
141
|
+
}
|
|
142
|
+
addWireListener(id, resolve, reject, uncorrelated) {
|
|
143
|
+
if (uncorrelated) {
|
|
144
|
+
this.uncorrelatedListener = resolve;
|
|
145
|
+
}
|
|
146
|
+
else if (this.wireListeners.has(id)) {
|
|
147
|
+
reject(new transport_errors_1.DuplicateCorrelationError(String(id)));
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
this.wireListeners.set(id, { resolve, reject });
|
|
151
|
+
}
|
|
152
|
+
// Timeout and reject()?
|
|
153
|
+
}
|
|
154
|
+
// This method executes message handlers until the _one_ that handles the message (returns truthy) has run
|
|
155
|
+
onmessage(data) {
|
|
156
|
+
for (const h of this.messageHandlers) {
|
|
157
|
+
h.call(null, data);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
handleMessage(data) {
|
|
161
|
+
const id = data.correlationId || NaN;
|
|
162
|
+
if (!('correlationId' in data)) {
|
|
163
|
+
if (this.uncorrelatedListener) {
|
|
164
|
+
this.uncorrelatedListener.call(null, data);
|
|
165
|
+
}
|
|
166
|
+
this.uncorrelatedListener = () => {
|
|
167
|
+
// empty block
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
else if (!this.wireListeners.has(id)) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
// We just checked for existence above
|
|
175
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
176
|
+
const { resolve, reject } = this.wireListeners.get(id);
|
|
177
|
+
if (data.action !== 'ack') {
|
|
178
|
+
reject(new transport_errors_1.NoAckError(data.action));
|
|
179
|
+
}
|
|
180
|
+
else if (!('payload' in data)) {
|
|
181
|
+
reject(new transport_errors_1.RuntimeError(data));
|
|
182
|
+
}
|
|
183
|
+
else if (!data.payload.success) {
|
|
184
|
+
reject(new transport_errors_1.RuntimeError(data.payload));
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
resolve.call(null, data);
|
|
188
|
+
}
|
|
189
|
+
this.wireListeners.delete(id);
|
|
190
|
+
}
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
_wire = new WeakMap();
|
|
195
|
+
exports.default = Transport;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
export interface Wire extends EventEmitter {
|
|
4
|
+
connect(address: string): Promise<any>;
|
|
5
|
+
connectSync(): any;
|
|
6
|
+
send(data: any): Promise<any>;
|
|
7
|
+
shutdown(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export interface WireConstructor {
|
|
10
|
+
new (onmessage: (data: any) => void): Wire;
|
|
11
|
+
}
|
|
12
|
+
export interface RuntimeConfig {
|
|
13
|
+
version: string;
|
|
14
|
+
fallbackVersion?: string;
|
|
15
|
+
securityRealm?: string;
|
|
16
|
+
verboseLogging?: boolean;
|
|
17
|
+
arguments?: string;
|
|
18
|
+
rvmDir?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ServiceConfig {
|
|
21
|
+
name: string;
|
|
22
|
+
manifestUrl: string;
|
|
23
|
+
}
|
|
24
|
+
export interface BaseConfig {
|
|
25
|
+
uuid?: string;
|
|
26
|
+
address?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
nonPersistent?: boolean;
|
|
29
|
+
runtimeClient?: boolean;
|
|
30
|
+
licenseKey?: string;
|
|
31
|
+
client?: any;
|
|
32
|
+
manifestUrl?: string;
|
|
33
|
+
startupApp?: any;
|
|
34
|
+
lrsUrl?: string;
|
|
35
|
+
assetsUrl?: string;
|
|
36
|
+
devToolsPort?: number;
|
|
37
|
+
installerUI?: boolean;
|
|
38
|
+
runtime?: RuntimeConfig;
|
|
39
|
+
services?: ServiceConfig[];
|
|
40
|
+
appAssets?: [{
|
|
41
|
+
src: string;
|
|
42
|
+
alias: string;
|
|
43
|
+
target: string;
|
|
44
|
+
version: string;
|
|
45
|
+
args: string;
|
|
46
|
+
}];
|
|
47
|
+
customItems?: [any];
|
|
48
|
+
timeout?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface ConfigWithUuid extends BaseConfig {
|
|
51
|
+
uuid: string;
|
|
52
|
+
}
|
|
53
|
+
export interface ExistingConnectConfig extends ConfigWithUuid {
|
|
54
|
+
address: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ConfigWithRuntime extends BaseConfig {
|
|
57
|
+
runtime: RuntimeConfig;
|
|
58
|
+
}
|
|
59
|
+
export interface ExternalConfig extends BaseConfig {
|
|
60
|
+
manifestUrl: string;
|
|
61
|
+
}
|
|
62
|
+
export declare type NewConnectConfig = ConfigWithUuid & ConfigWithRuntime;
|
|
63
|
+
export declare type PortDiscoveryConfig = (ExternalConfig & ConfigWithRuntime) | NewConnectConfig;
|
|
64
|
+
export declare type ConnectConfig = ExistingConnectConfig | NewConnectConfig | ExternalConfig;
|
|
65
|
+
export declare type InternalConnectConfig = ExistingConnectConfig | NewConnectConfig;
|
|
66
|
+
export declare function isExternalConfig(config: ConnectConfig): config is ExternalConfig;
|
|
67
|
+
export declare function isExistingConnectConfig(config: any): config is ExistingConnectConfig;
|
|
68
|
+
export declare function isNewConnectConfig(config: any): config is NewConnectConfig;
|
|
69
|
+
export declare function isPortDiscoveryConfig(config: any): config is PortDiscoveryConfig;
|
|
70
|
+
export declare function isInternalConnectConfig(config: any): config is InternalConnectConfig;
|
|
71
|
+
export declare enum READY_STATE {
|
|
72
|
+
CONNECTING = 0,
|
|
73
|
+
OPEN = 1,
|
|
74
|
+
CLOSING = 2,
|
|
75
|
+
CLOSED = 3
|
|
76
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.READY_STATE = exports.isInternalConnectConfig = exports.isPortDiscoveryConfig = exports.isNewConnectConfig = exports.isExistingConnectConfig = exports.isExternalConfig = void 0;
|
|
4
|
+
function isExternalConfig(config) {
|
|
5
|
+
if (typeof config.manifestUrl === 'string') {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
exports.isExternalConfig = isExternalConfig;
|
|
11
|
+
function isExistingConnectConfig(config) {
|
|
12
|
+
return hasUuid(config) && typeof config.address === 'string';
|
|
13
|
+
}
|
|
14
|
+
exports.isExistingConnectConfig = isExistingConnectConfig;
|
|
15
|
+
function hasUuid(config) {
|
|
16
|
+
return typeof config.uuid === 'string';
|
|
17
|
+
}
|
|
18
|
+
function hasRuntimeVersion(config) {
|
|
19
|
+
return config.runtime && typeof config.runtime.version === 'string';
|
|
20
|
+
}
|
|
21
|
+
function isNewConnectConfig(config) {
|
|
22
|
+
return hasUuid(config) && hasRuntimeVersion(config);
|
|
23
|
+
}
|
|
24
|
+
exports.isNewConnectConfig = isNewConnectConfig;
|
|
25
|
+
function isPortDiscoveryConfig(config) {
|
|
26
|
+
return (isExternalConfig(config) && hasRuntimeVersion(config)) || isNewConnectConfig(config);
|
|
27
|
+
}
|
|
28
|
+
exports.isPortDiscoveryConfig = isPortDiscoveryConfig;
|
|
29
|
+
function isInternalConnectConfig(config) {
|
|
30
|
+
return isExistingConnectConfig(config) || isNewConnectConfig(config);
|
|
31
|
+
}
|
|
32
|
+
exports.isInternalConnectConfig = isInternalConnectConfig;
|
|
33
|
+
var READY_STATE;
|
|
34
|
+
(function (READY_STATE) {
|
|
35
|
+
READY_STATE[READY_STATE["CONNECTING"] = 0] = "CONNECTING";
|
|
36
|
+
READY_STATE[READY_STATE["OPEN"] = 1] = "OPEN";
|
|
37
|
+
READY_STATE[READY_STATE["CLOSING"] = 2] = "CLOSING";
|
|
38
|
+
READY_STATE[READY_STATE["CLOSED"] = 3] = "CLOSED"; // The connection is closed.
|
|
39
|
+
})(READY_STATE = exports.READY_STATE || (exports.READY_STATE = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function asyncFilter<T>(values: T[], callback: (value: T) => Promise<boolean>): Promise<T[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asyncFilter = void 0;
|
|
4
|
+
async function asyncFilter(values, callback) {
|
|
5
|
+
return Promise.all(values.map(callback)).then((results) => values.filter((_, i) => results[i]));
|
|
6
|
+
}
|
|
7
|
+
exports.asyncFilter = asyncFilter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorToPOJO = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This function converts JS errors into plain objects
|
|
6
|
+
*/
|
|
7
|
+
function errorToPOJO(error) {
|
|
8
|
+
return {
|
|
9
|
+
stack: error.stack,
|
|
10
|
+
message: error.message,
|
|
11
|
+
toString: error.toString
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.errorToPOJO = errorToPOJO;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function exhaustiveCheck(value: string, allowed?: string[]): never;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exhaustiveCheck = void 0;
|
|
4
|
+
function exhaustiveCheck(value, allowed) {
|
|
5
|
+
throw new Error(`Unsupported value: ${value}${allowed ? `\n Supported values are: ${allowed.join('')}` : ''}`);
|
|
6
|
+
}
|
|
7
|
+
exports.exhaustiveCheck = exhaustiveCheck;
|