@openfin/core 25.68.30 → 25.70.2
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/OpenFin.d.ts +30 -826
- package/README.md +12 -2
- package/package.json +1 -1
- package/src/api/application/Factory.d.ts +145 -145
- package/src/api/application/Factory.js +229 -229
- package/src/api/application/Instance.d.ts +301 -302
- package/src/api/application/Instance.js +412 -412
- package/src/api/application/index.d.ts +3 -3
- package/src/api/application/index.js +15 -15
- package/src/api/base.d.ts +43 -43
- package/src/api/base.js +177 -177
- package/src/api/clipboard/index.d.ts +69 -69
- package/src/api/clipboard/index.js +88 -88
- 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 -11
- package/src/api/events/channel.js +2 -2
- package/src/api/events/emitterMap.d.ts +11 -11
- package/src/api/events/emitterMap.js +35 -35
- package/src/api/events/eventAggregator.d.ts +5 -5
- package/src/api/events/eventAggregator.js +43 -43
- 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 +176 -0
- package/src/api/events/window.js +2 -0
- package/src/api/external-application/Factory.d.ts +26 -26
- package/src/api/external-application/Factory.js +40 -40
- package/src/api/external-application/Instance.d.ts +101 -102
- package/src/api/external-application/Instance.js +109 -109
- package/src/api/external-application/index.d.ts +3 -3
- package/src/api/external-application/index.js +15 -15
- package/src/api/fin.d.ts +49 -49
- package/src/api/fin.js +43 -43
- package/src/api/frame/Factory.d.ts +36 -36
- package/src/api/frame/Factory.js +69 -69
- package/src/api/frame/Instance.d.ts +121 -121
- package/src/api/frame/Instance.js +130 -130
- package/src/api/frame/index.d.ts +3 -3
- package/src/api/frame/index.js +15 -15
- package/src/api/global-hotkey/index.d.ts +38 -38
- package/src/api/global-hotkey/index.js +58 -58
- package/src/api/interappbus/channel/channel.d.ts +26 -26
- package/src/api/interappbus/channel/channel.js +77 -77
- package/src/api/interappbus/channel/channels-docs.d.ts +318 -318
- package/src/api/interappbus/channel/channels-docs.js +376 -376
- package/src/api/interappbus/channel/client.d.ts +22 -22
- package/src/api/interappbus/channel/client.js +84 -84
- package/src/api/interappbus/channel/connection-manager.d.ts +28 -28
- package/src/api/interappbus/channel/connection-manager.js +244 -244
- package/src/api/interappbus/channel/index.d.ts +22 -23
- package/src/api/interappbus/channel/index.js +121 -121
- package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +13 -13
- package/src/api/interappbus/channel/protocols/classic/message-receiver.js +73 -73
- package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +22 -22
- package/src/api/interappbus/channel/protocols/classic/strategy.js +84 -84
- package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +20 -20
- package/src/api/interappbus/channel/protocols/combined/strategy.js +58 -58
- package/src/api/interappbus/channel/protocols/index.d.ts +44 -44
- package/src/api/interappbus/channel/protocols/index.js +2 -2
- package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +10 -10
- package/src/api/interappbus/channel/protocols/protocol-manager.js +43 -43
- package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +23 -23
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +135 -135
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +30 -30
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +131 -131
- package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +22 -22
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +87 -87
- package/src/api/interappbus/channel/protocols/strategy-types.d.ts +13 -13
- package/src/api/interappbus/channel/protocols/strategy-types.js +2 -2
- package/src/api/interappbus/channel/protocols/strategy.d.ts +15 -15
- package/src/api/interappbus/channel/protocols/strategy.js +2 -2
- package/src/api/interappbus/channel/provider.d.ts +31 -31
- package/src/api/interappbus/channel/provider.js +160 -160
- package/src/api/interappbus/index.d.ts +85 -86
- package/src/api/interappbus/index.js +175 -175
- package/src/api/interop/Factory.d.ts +37 -37
- package/src/api/interop/Factory.js +54 -54
- package/src/api/interop/InteropBroker.d.ts +363 -363
- package/src/api/interop/InteropBroker.js +914 -914
- package/src/api/interop/InteropClient.d.ts +268 -268
- package/src/api/interop/InteropClient.js +450 -450
- package/src/api/interop/SessionContextGroupBroker.d.ts +26 -26
- package/src/api/interop/SessionContextGroupBroker.js +107 -107
- package/src/api/interop/SessionContextGroupClient.d.ts +20 -20
- package/src/api/interop/SessionContextGroupClient.js +85 -85
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +187 -187
- package/src/api/interop/fdc3/fdc3-1.2.js +385 -385
- package/src/api/interop/fdc3/fdc3.js +17 -17
- package/src/api/interop/fdc3/utils.d.ts +6 -6
- package/src/api/interop/fdc3/utils.js +17 -17
- package/src/api/interop/index.d.ts +4 -4
- package/src/api/interop/index.js +16 -16
- package/src/api/interop/utils.d.ts +11 -11
- package/src/api/interop/utils.js +36 -36
- package/src/api/me.d.ts +38 -35
- package/src/api/me.js +128 -60
- package/src/api/platform/Factory.d.ts +109 -109
- package/src/api/platform/Factory.js +188 -188
- package/src/api/platform/Instance.d.ts +122 -122
- package/src/api/platform/Instance.js +298 -298
- package/src/api/platform/common-utils.d.ts +6 -6
- package/src/api/platform/common-utils.js +16 -16
- package/src/api/platform/index.d.ts +3 -3
- package/src/api/platform/index.js +15 -15
- package/src/api/platform/layout/Factory.d.ts +108 -108
- package/src/api/platform/layout/Factory.js +189 -189
- package/src/api/platform/layout/Instance.d.ts +49 -49
- package/src/api/platform/layout/Instance.js +99 -99
- package/src/api/platform/layout/index.d.ts +2 -2
- package/src/api/platform/layout/index.js +14 -14
- package/src/api/platform/layout/shapes.d.ts +11 -0
- package/src/api/{window → platform/layout}/shapes.js +2 -2
- package/src/api/snapshot-source/Factory.d.ts +36 -36
- package/src/api/snapshot-source/Factory.js +65 -65
- package/src/api/snapshot-source/Instance.d.ts +30 -30
- package/src/api/snapshot-source/Instance.js +134 -134
- package/src/api/snapshot-source/index.d.ts +3 -3
- package/src/api/snapshot-source/index.js +15 -15
- package/src/api/snapshot-source/utils.d.ts +1 -1
- package/src/api/snapshot-source/utils.js +5 -5
- package/src/api/system/index.d.ts +960 -961
- package/src/api/system/index.js +1241 -1241
- package/src/api/view/Factory.d.ts +49 -49
- package/src/api/view/Factory.js +103 -103
- package/src/api/view/Instance.d.ts +387 -380
- package/src/api/view/Instance.js +422 -415
- package/src/api/view/index.d.ts +3 -3
- package/src/api/view/index.js +15 -15
- package/src/api/webcontents/main.d.ts +36 -36
- package/src/api/webcontents/main.js +82 -82
- package/src/api/window/Factory.d.ts +44 -44
- package/src/api/window/Factory.js +91 -91
- package/src/api/window/Instance.d.ts +972 -966
- package/src/api/window/Instance.js +1209 -1202
- package/src/api/window/index.d.ts +3 -5
- package/src/api/window/index.js +15 -17
- package/src/environment/environment.d.ts +28 -25
- package/src/environment/environment.js +4 -4
- package/src/environment/node-env.d.ts +25 -26
- package/src/environment/node-env.js +64 -64
- package/src/environment/openfin-env.d.ts +29 -30
- package/src/environment/openfin-env.js +107 -107
- package/src/mock.d.ts +3 -3
- package/src/mock.js +91 -90
- package/src/shapes/ERROR_BOX_TYPES.d.ts +1 -0
- package/src/shapes/ERROR_BOX_TYPES.js +2 -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 -4
- package/src/transport/fin_store.js +16 -16
- package/src/transport/transport-errors.d.ts +18 -18
- package/src/transport/transport-errors.js +37 -37
- package/src/transport/transport.d.ts +56 -43
- package/src/transport/transport.js +181 -181
- package/src/transport/wire.d.ts +71 -11
- package/src/transport/wire.js +32 -32
- package/src/util/asyncFilter.d.ts +1 -1
- package/src/util/asyncFilter.js +7 -7
- package/src/util/errors.d.ts +9 -5
- package/src/util/errors.js +11 -11
- package/src/util/exhaustive.d.ts +1 -1
- package/src/util/exhaustive.js +7 -7
- package/src/util/http.d.ts +11 -11
- package/src/util/http.js +83 -83
- package/src/util/normalize-config.d.ts +3 -5
- package/src/util/normalize-config.js +47 -47
- package/src/util/promises.d.ts +5 -5
- package/src/util/promises.js +27 -27
- package/src/util/ref-counter.d.ts +7 -7
- package/src/util/ref-counter.js +51 -51
- package/src/util/runtimeVersioning.d.ts +3 -3
- package/src/util/runtimeVersioning.js +25 -25
- package/src/util/utilTypes.d.ts +8 -8
- package/src/util/utilTypes.js +2 -2
- package/src/util/validate.d.ts +3 -3
- package/src/util/validate.js +11 -11
- package/docs.README(OLD).md +0 -82
- package/resources/win/OpenFinRVM.exe +0 -0
- package/src/api/window/bounds-changed.d.ts +0 -10
- package/src/api/window/bounds-changed.js +0 -6
- package/src/api/window/shapes.d.ts +0 -13
|
@@ -1,43 +1,56 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
protected
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { Wire, WireConstructor, 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 { ProtocolMap } from '../shapes/protocol';
|
|
9
|
+
import EntityType = OpenFin.EntityType;
|
|
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
|
+
sendAction<T extends keyof ProtocolMap = string>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): Promise<Message<{
|
|
31
|
+
data: ProtocolMap[T]['response'];
|
|
32
|
+
} & ProtocolMap[T]['specialResponse']>>;
|
|
33
|
+
ferryAction(origData: any): Promise<Message<any>>;
|
|
34
|
+
registerMessageHandler(handler: MessageHandler): void;
|
|
35
|
+
protected addWireListener(id: number, resolve: Function, reject: Function, uncorrelated: boolean): void;
|
|
36
|
+
protected onmessage(data: Message<Payload>): void;
|
|
37
|
+
protected handleMessage(data: Message<Payload>): boolean;
|
|
38
|
+
}
|
|
39
|
+
export default Transport;
|
|
40
|
+
export interface Message<T> {
|
|
41
|
+
action: string;
|
|
42
|
+
payload: T;
|
|
43
|
+
correlationId?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface EventMessage extends Message<RuntimeEvent> {
|
|
46
|
+
action: 'process-desktop-event';
|
|
47
|
+
payload: RuntimeEvent;
|
|
48
|
+
}
|
|
49
|
+
export interface Payload {
|
|
50
|
+
success: boolean;
|
|
51
|
+
data: any;
|
|
52
|
+
}
|
|
53
|
+
export interface AuthorizationPayload {
|
|
54
|
+
token: string;
|
|
55
|
+
file: string;
|
|
56
|
+
}
|
|
@@ -1,181 +1,181 @@
|
|
|
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
|
-
__classPrivateFieldSet(this, _wire, new WireType(this.onmessage.bind(this)));
|
|
43
|
-
this.environment = environment;
|
|
44
|
-
this.sendRaw = __classPrivateFieldGet(this, _wire).send.bind(__classPrivateFieldGet(this, _wire));
|
|
45
|
-
this.registerMessageHandler(this.handleMessage.bind(this));
|
|
46
|
-
__classPrivateFieldGet(this, _wire).on('disconnected', () => {
|
|
47
|
-
for (const [, { reject }] of this.wireListeners) {
|
|
48
|
-
reject('Remote connection has closed');
|
|
49
|
-
}
|
|
50
|
-
this.wireListeners.clear();
|
|
51
|
-
this.emit('disconnected');
|
|
52
|
-
});
|
|
53
|
-
const { uuid, name } = config;
|
|
54
|
-
const entityType = this.environment.getCurrentEntityType();
|
|
55
|
-
this.me = me_1.getBaseMe(entityType, uuid, name);
|
|
56
|
-
}
|
|
57
|
-
shutdown() {
|
|
58
|
-
const wire = __classPrivateFieldGet(this, _wire);
|
|
59
|
-
return wire.shutdown();
|
|
60
|
-
}
|
|
61
|
-
async connect(config) {
|
|
62
|
-
if (wire_1.isExistingConnectConfig(config)) {
|
|
63
|
-
return this.connectByPort(config);
|
|
64
|
-
}
|
|
65
|
-
if (wire_1.isNewConnectConfig(config)) {
|
|
66
|
-
const port = await this.environment.retrievePort(config);
|
|
67
|
-
return this.connectByPort({ ...config, address: `ws://localhost:${port}` });
|
|
68
|
-
}
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
async connectByPort(config) {
|
|
72
|
-
const { address, uuid } = config;
|
|
73
|
-
const reqAuthPayload = { ...config, type: 'file-token' };
|
|
74
|
-
const wire = __classPrivateFieldGet(this, _wire);
|
|
75
|
-
await wire.connect(address);
|
|
76
|
-
const requestExtAuthRet = await this.sendAction('request-external-authorization', {
|
|
77
|
-
uuid,
|
|
78
|
-
type: 'file-token'
|
|
79
|
-
}, true);
|
|
80
|
-
if (requestExtAuthRet.action !== 'external-authorization-response') {
|
|
81
|
-
throw new transport_errors_1.UnexpectedActionError(requestExtAuthRet.action);
|
|
82
|
-
}
|
|
83
|
-
const { token } = requestExtAuthRet.payload;
|
|
84
|
-
await this.environment.writeToken(requestExtAuthRet.payload.file, requestExtAuthRet.payload.token);
|
|
85
|
-
const requestAuthRet = await this.sendAction('request-authorization', reqAuthPayload, true);
|
|
86
|
-
if (requestAuthRet.action !== 'authorization-response') {
|
|
87
|
-
throw new transport_errors_1.UnexpectedActionError(requestAuthRet.action);
|
|
88
|
-
}
|
|
89
|
-
else if (requestAuthRet.payload.success !== true) {
|
|
90
|
-
throw new transport_errors_1.RuntimeError(requestAuthRet.payload);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
return token;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
sendAction(action, payload = {}, uncorrelated = false
|
|
97
|
-
// specialResponse type is only used for 'requestAuthorization'
|
|
98
|
-
) {
|
|
99
|
-
return new Promise((resolve, reject) => {
|
|
100
|
-
const id = this.environment.getNextMessageId();
|
|
101
|
-
const msg = {
|
|
102
|
-
action,
|
|
103
|
-
payload,
|
|
104
|
-
messageId: id
|
|
105
|
-
};
|
|
106
|
-
const wire = __classPrivateFieldGet(this, _wire);
|
|
107
|
-
this.addWireListener(id, resolve, reject, uncorrelated);
|
|
108
|
-
return wire.send(msg).catch(reject);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
ferryAction(origData) {
|
|
112
|
-
return new Promise((resolve, reject) => {
|
|
113
|
-
const id = this.environment.getNextMessageId();
|
|
114
|
-
origData.messageId = id;
|
|
115
|
-
const resolver = (data) => {
|
|
116
|
-
resolve(data.payload);
|
|
117
|
-
};
|
|
118
|
-
const wire = __classPrivateFieldGet(this, _wire);
|
|
119
|
-
return wire
|
|
120
|
-
.send(origData)
|
|
121
|
-
.then(() => this.addWireListener(id, resolver, reject, false))
|
|
122
|
-
.catch(reject);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
registerMessageHandler(handler) {
|
|
126
|
-
this.messageHandlers.push(handler);
|
|
127
|
-
}
|
|
128
|
-
addWireListener(id, resolve, reject, uncorrelated) {
|
|
129
|
-
if (uncorrelated) {
|
|
130
|
-
this.uncorrelatedListener = resolve;
|
|
131
|
-
}
|
|
132
|
-
else if (this.wireListeners.has(id)) {
|
|
133
|
-
reject(new transport_errors_1.DuplicateCorrelationError(String(id)));
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
this.wireListeners.set(id, { resolve, reject });
|
|
137
|
-
}
|
|
138
|
-
// Timeout and reject()?
|
|
139
|
-
}
|
|
140
|
-
// This method executes message handlers until the _one_ that handles the message (returns truthy) has run
|
|
141
|
-
onmessage(data) {
|
|
142
|
-
for (const h of this.messageHandlers) {
|
|
143
|
-
h.call(null, data);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
handleMessage(data) {
|
|
147
|
-
const id = data.correlationId || NaN;
|
|
148
|
-
if (!('correlationId' in data)) {
|
|
149
|
-
if (this.uncorrelatedListener) {
|
|
150
|
-
this.uncorrelatedListener.call(null, data);
|
|
151
|
-
}
|
|
152
|
-
this.uncorrelatedListener = () => {
|
|
153
|
-
// empty block
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
else if (!this.wireListeners.has(id)) {
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
// We just checked for existence above
|
|
161
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
162
|
-
const { resolve, reject } = this.wireListeners.get(id);
|
|
163
|
-
if (data.action !== 'ack') {
|
|
164
|
-
reject(new transport_errors_1.NoAckError(data.action));
|
|
165
|
-
}
|
|
166
|
-
else if (!('payload' in data)) {
|
|
167
|
-
reject(new transport_errors_1.RuntimeError(data));
|
|
168
|
-
}
|
|
169
|
-
else if (!data.payload.success) {
|
|
170
|
-
reject(new transport_errors_1.RuntimeError(data.payload));
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
resolve.call(null, data);
|
|
174
|
-
}
|
|
175
|
-
this.wireListeners.delete(id);
|
|
176
|
-
}
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
_wire = new WeakMap();
|
|
181
|
-
exports.default = Transport;
|
|
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
|
+
__classPrivateFieldSet(this, _wire, new WireType(this.onmessage.bind(this)));
|
|
43
|
+
this.environment = environment;
|
|
44
|
+
this.sendRaw = __classPrivateFieldGet(this, _wire).send.bind(__classPrivateFieldGet(this, _wire));
|
|
45
|
+
this.registerMessageHandler(this.handleMessage.bind(this));
|
|
46
|
+
__classPrivateFieldGet(this, _wire).on('disconnected', () => {
|
|
47
|
+
for (const [, { reject }] of this.wireListeners) {
|
|
48
|
+
reject('Remote connection has closed');
|
|
49
|
+
}
|
|
50
|
+
this.wireListeners.clear();
|
|
51
|
+
this.emit('disconnected');
|
|
52
|
+
});
|
|
53
|
+
const { uuid, name } = config;
|
|
54
|
+
const entityType = this.environment.getCurrentEntityType();
|
|
55
|
+
this.me = me_1.getBaseMe(entityType, uuid, name);
|
|
56
|
+
}
|
|
57
|
+
shutdown() {
|
|
58
|
+
const wire = __classPrivateFieldGet(this, _wire);
|
|
59
|
+
return wire.shutdown();
|
|
60
|
+
}
|
|
61
|
+
async connect(config) {
|
|
62
|
+
if (wire_1.isExistingConnectConfig(config)) {
|
|
63
|
+
return this.connectByPort(config);
|
|
64
|
+
}
|
|
65
|
+
if (wire_1.isNewConnectConfig(config)) {
|
|
66
|
+
const port = await this.environment.retrievePort(config);
|
|
67
|
+
return this.connectByPort({ ...config, address: `ws://localhost:${port}` });
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
async connectByPort(config) {
|
|
72
|
+
const { address, uuid } = config;
|
|
73
|
+
const reqAuthPayload = { ...config, type: 'file-token' };
|
|
74
|
+
const wire = __classPrivateFieldGet(this, _wire);
|
|
75
|
+
await wire.connect(address);
|
|
76
|
+
const requestExtAuthRet = await this.sendAction('request-external-authorization', {
|
|
77
|
+
uuid,
|
|
78
|
+
type: 'file-token'
|
|
79
|
+
}, true);
|
|
80
|
+
if (requestExtAuthRet.action !== 'external-authorization-response') {
|
|
81
|
+
throw new transport_errors_1.UnexpectedActionError(requestExtAuthRet.action);
|
|
82
|
+
}
|
|
83
|
+
const { token } = requestExtAuthRet.payload;
|
|
84
|
+
await this.environment.writeToken(requestExtAuthRet.payload.file, requestExtAuthRet.payload.token);
|
|
85
|
+
const requestAuthRet = await this.sendAction('request-authorization', reqAuthPayload, true);
|
|
86
|
+
if (requestAuthRet.action !== 'authorization-response') {
|
|
87
|
+
throw new transport_errors_1.UnexpectedActionError(requestAuthRet.action);
|
|
88
|
+
}
|
|
89
|
+
else if (requestAuthRet.payload.success !== true) {
|
|
90
|
+
throw new transport_errors_1.RuntimeError(requestAuthRet.payload);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return token;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
sendAction(action, payload = {}, uncorrelated = false
|
|
97
|
+
// specialResponse type is only used for 'requestAuthorization'
|
|
98
|
+
) {
|
|
99
|
+
return new Promise((resolve, reject) => {
|
|
100
|
+
const id = this.environment.getNextMessageId();
|
|
101
|
+
const msg = {
|
|
102
|
+
action,
|
|
103
|
+
payload,
|
|
104
|
+
messageId: id
|
|
105
|
+
};
|
|
106
|
+
const wire = __classPrivateFieldGet(this, _wire);
|
|
107
|
+
this.addWireListener(id, resolve, reject, uncorrelated);
|
|
108
|
+
return wire.send(msg).catch(reject);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
ferryAction(origData) {
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
const id = this.environment.getNextMessageId();
|
|
114
|
+
origData.messageId = id;
|
|
115
|
+
const resolver = (data) => {
|
|
116
|
+
resolve(data.payload);
|
|
117
|
+
};
|
|
118
|
+
const wire = __classPrivateFieldGet(this, _wire);
|
|
119
|
+
return wire
|
|
120
|
+
.send(origData)
|
|
121
|
+
.then(() => this.addWireListener(id, resolver, reject, false))
|
|
122
|
+
.catch(reject);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
registerMessageHandler(handler) {
|
|
126
|
+
this.messageHandlers.push(handler);
|
|
127
|
+
}
|
|
128
|
+
addWireListener(id, resolve, reject, uncorrelated) {
|
|
129
|
+
if (uncorrelated) {
|
|
130
|
+
this.uncorrelatedListener = resolve;
|
|
131
|
+
}
|
|
132
|
+
else if (this.wireListeners.has(id)) {
|
|
133
|
+
reject(new transport_errors_1.DuplicateCorrelationError(String(id)));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
this.wireListeners.set(id, { resolve, reject });
|
|
137
|
+
}
|
|
138
|
+
// Timeout and reject()?
|
|
139
|
+
}
|
|
140
|
+
// This method executes message handlers until the _one_ that handles the message (returns truthy) has run
|
|
141
|
+
onmessage(data) {
|
|
142
|
+
for (const h of this.messageHandlers) {
|
|
143
|
+
h.call(null, data);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
handleMessage(data) {
|
|
147
|
+
const id = data.correlationId || NaN;
|
|
148
|
+
if (!('correlationId' in data)) {
|
|
149
|
+
if (this.uncorrelatedListener) {
|
|
150
|
+
this.uncorrelatedListener.call(null, data);
|
|
151
|
+
}
|
|
152
|
+
this.uncorrelatedListener = () => {
|
|
153
|
+
// empty block
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
else if (!this.wireListeners.has(id)) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// We just checked for existence above
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
162
|
+
const { resolve, reject } = this.wireListeners.get(id);
|
|
163
|
+
if (data.action !== 'ack') {
|
|
164
|
+
reject(new transport_errors_1.NoAckError(data.action));
|
|
165
|
+
}
|
|
166
|
+
else if (!('payload' in data)) {
|
|
167
|
+
reject(new transport_errors_1.RuntimeError(data));
|
|
168
|
+
}
|
|
169
|
+
else if (!data.payload.success) {
|
|
170
|
+
reject(new transport_errors_1.RuntimeError(data.payload));
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
resolve.call(null, data);
|
|
174
|
+
}
|
|
175
|
+
this.wireListeners.delete(id);
|
|
176
|
+
}
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
_wire = new WeakMap();
|
|
181
|
+
exports.default = Transport;
|
package/src/transport/wire.d.ts
CHANGED
|
@@ -1,11 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare
|
|
11
|
-
|
|
1
|
+
/// <reference types="mocha" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import EventEmitter = NodeJS.EventEmitter;
|
|
4
|
+
export declare type Wire = EventEmitter & {
|
|
5
|
+
connect(address: string): Promise<any>;
|
|
6
|
+
connectSync(): any;
|
|
7
|
+
send(data: any): Promise<any>;
|
|
8
|
+
shutdown(): Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
export declare type WireConstructor = {
|
|
11
|
+
new (onmessage: (data: any) => void): Wire;
|
|
12
|
+
};
|
|
13
|
+
export declare type RuntimeConfig = {
|
|
14
|
+
version: string;
|
|
15
|
+
fallbackVersion?: string;
|
|
16
|
+
securityRealm?: string;
|
|
17
|
+
verboseLogging?: boolean;
|
|
18
|
+
arguments?: string;
|
|
19
|
+
rvmDir?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare type ServiceConfig = {
|
|
22
|
+
name: string;
|
|
23
|
+
manifestUrl: string;
|
|
24
|
+
};
|
|
25
|
+
export declare type BaseConfig = {
|
|
26
|
+
uuid?: string;
|
|
27
|
+
address?: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
nonPersistent?: boolean;
|
|
30
|
+
runtimeClient?: boolean;
|
|
31
|
+
licenseKey?: string;
|
|
32
|
+
client?: any;
|
|
33
|
+
manifestUrl?: string;
|
|
34
|
+
startupApp?: any;
|
|
35
|
+
lrsUrl?: string;
|
|
36
|
+
assetsUrl?: string;
|
|
37
|
+
devToolsPort?: number;
|
|
38
|
+
installerUI?: boolean;
|
|
39
|
+
runtime?: RuntimeConfig;
|
|
40
|
+
services?: ServiceConfig[];
|
|
41
|
+
appAssets?: [{
|
|
42
|
+
src: string;
|
|
43
|
+
alias: string;
|
|
44
|
+
target: string;
|
|
45
|
+
version: string;
|
|
46
|
+
args: string;
|
|
47
|
+
}];
|
|
48
|
+
customItems?: [any];
|
|
49
|
+
timeout?: number;
|
|
50
|
+
};
|
|
51
|
+
export declare type ConfigWithUuid = BaseConfig & {
|
|
52
|
+
uuid: string;
|
|
53
|
+
};
|
|
54
|
+
export declare type ExistingConnectConfig = ConfigWithUuid & {
|
|
55
|
+
address: string;
|
|
56
|
+
};
|
|
57
|
+
export declare type ConfigWithRuntime = BaseConfig & {
|
|
58
|
+
runtime: RuntimeConfig;
|
|
59
|
+
};
|
|
60
|
+
export declare type ExternalConfig = BaseConfig & {
|
|
61
|
+
manifestUrl: string;
|
|
62
|
+
};
|
|
63
|
+
export declare type NewConnectConfig = ConfigWithUuid & ConfigWithRuntime;
|
|
64
|
+
export declare type PortDiscoveryConfig = (ExternalConfig & ConfigWithRuntime) | NewConnectConfig;
|
|
65
|
+
export declare type ConnectConfig = ExistingConnectConfig | NewConnectConfig | ExternalConfig;
|
|
66
|
+
export declare type InternalConnectConfig = ExistingConnectConfig | NewConnectConfig;
|
|
67
|
+
export declare function isExternalConfig(config: ConnectConfig): config is ExternalConfig;
|
|
68
|
+
export declare function isExistingConnectConfig(config: any): config is ExistingConnectConfig;
|
|
69
|
+
export declare function isNewConnectConfig(config: any): config is NewConnectConfig;
|
|
70
|
+
export declare function isPortDiscoveryConfig(config: any): config is PortDiscoveryConfig;
|
|
71
|
+
export declare function isInternalConnectConfig(config: any): config is InternalConnectConfig;
|
package/src/transport/wire.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function asyncFilter<T>(values: T[], callback: (value: T) => Promise<boolean>): Promise<T[]>;
|
|
1
|
+
export declare function asyncFilter<T>(values: T[], callback: (value: T) => Promise<boolean>): Promise<T[]>;
|
package/src/util/asyncFilter.js
CHANGED
|
@@ -1,7 +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;
|
|
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;
|
package/src/util/errors.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This function converts JS errors into plain objects
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This function converts JS errors into plain objects
|
|
3
|
+
*/
|
|
4
|
+
export declare type ErrorPlainObject = {
|
|
5
|
+
stack: string;
|
|
6
|
+
message: string;
|
|
7
|
+
toString(): string;
|
|
8
|
+
};
|
|
9
|
+
export declare function errorToPOJO(error: Error): ErrorPlainObject;
|