@openfin/core 27.71.23 → 27.71.25

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 CHANGED
@@ -1546,7 +1546,7 @@ declare namespace OpenFin {
1546
1546
  topic: string,
1547
1547
  payload: unknown,
1548
1548
  senderIdentity: ProviderIdentity | OpenFin.ClientIdentity
1549
- ) => unknown;
1549
+ ) => Promise<unknown> |unknown;
1550
1550
 
1551
1551
  export type ErrorMiddleware = (
1552
1552
  topic: string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "27.71.23",
3
+ "version": "27.71.25",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./src/mock.js",
6
6
  "types": "./src/mock.d.ts",
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ChannelBase = exports.ProtectedItems = void 0;
4
- const resultOrPayload = (func) => (topic, payload, senderIdentity) => {
5
- const res = func(topic, payload, senderIdentity);
4
+ const resultOrPayload = (func) => async (topic, payload, senderIdentity) => {
5
+ const res = await func(topic, payload, senderIdentity);
6
6
  return res === undefined ? payload : res;
7
7
  };
8
8
  class ProtectedItems {
@@ -15,7 +15,6 @@ export default class ChannelClient extends ChannelBase {
15
15
  constructor(routingInfo: RoutingInfo, wire: Transport, strategy: AnyStrategy);
16
16
  protected processAction: (action: string, payload: any, senderIdentity: ProviderIdentity | OpenFin.ClientIdentity) => Promise<any>;
17
17
  get providerIdentity(): ProviderIdentity;
18
- getRTCConnection(): RTCPeerConnection;
19
18
  dispatch(action: string, payload?: any): Promise<any>;
20
19
  onDisconnection(listener: DisconnectionListener): void;
21
20
  disconnect(): Promise<void>;
@@ -49,9 +49,6 @@ class ChannelClient extends channel_1.ChannelBase {
49
49
  const protectedObj = __classPrivateFieldGet(this, _protectedObj);
50
50
  return protectedObj.providerIdentity;
51
51
  }
52
- getRTCConnection() {
53
- return __classPrivateFieldGet(this, _strategy).getRTCConnection(this.providerIdentity.channelId);
54
- }
55
52
  async dispatch(action, payload) {
56
53
  if (__classPrivateFieldGet(this, _strategy).isEndpointConnected(this.providerIdentity.channelId)) {
57
54
  return __classPrivateFieldGet(this, _strategy).send(this.providerIdentity.channelId, action, payload);
@@ -10,7 +10,6 @@ export declare class ClassicStrategy implements ChannelStrategy<EndpointPayload>
10
10
  private providerIdentity;
11
11
  constructor(wire: Transport, messageReceiver: MessageReceiver, endpointId: string, // Provider endpointId is channelId
12
12
  providerIdentity: ProviderIdentity);
13
- getRTCConnection(endpointId: string): RTCPeerConnection;
14
13
  onEndpointDisconnect(endpointId: string, listener: () => void): void;
15
14
  receive(listener: (action: string, payload: any, identity: OpenFin.ClientIdentity | OpenFin.ClientIdentityMultiRuntime | ProviderIdentity) => Promise<any>): void;
16
15
  send: (endpointId: string, action: string, payload: any) => Promise<any>;
@@ -57,9 +57,6 @@ class ClassicStrategy {
57
57
  };
58
58
  __classPrivateFieldSet(this, _wire, wire);
59
59
  }
60
- getRTCConnection(endpointId) {
61
- throw new Error("Not implemented");
62
- }
63
60
  onEndpointDisconnect(endpointId, listener) {
64
61
  // Never fires for 'classic'.
65
62
  }
@@ -15,7 +15,6 @@ export default class CombinedStrategy<A, B> implements ChannelStrategy<OnlyIfCom
15
15
  addEndpoint(endpoint: string, payload: OnlyIfCompatible<A, B>): Promise<void>;
16
16
  receive(listener: (action: string, payload: any, identity: any) => Promise<any>): void;
17
17
  send(endpointId: string, action: string, payload: any): Promise<any>;
18
- getRTCConnection(endpointId: string): RTCPeerConnection;
19
18
  close(): Promise<void>;
20
19
  }
21
20
  export {};
@@ -51,18 +51,6 @@ class CombinedStrategy {
51
51
  }
52
52
  return this.secondary.send(endpointId, action, payload);
53
53
  }
54
- getRTCConnection(endpointId) {
55
- let connection;
56
- try {
57
- if (this.primary.isEndpointConnected(endpointId)) {
58
- connection = this.primary.getRTCConnection(endpointId);
59
- }
60
- }
61
- catch (error) {
62
- console.log("error getting rtcpeer from primary");
63
- }
64
- return connection !== null && connection !== void 0 ? connection : this.secondary.getRTCConnection(endpointId);
65
- }
66
54
  async close() {
67
55
  await Promise.all([this.primary.close(), this.secondary.close()]);
68
56
  }
@@ -20,5 +20,4 @@ export declare class RTCEndpoint {
20
20
  send: (action: string, payload: any) => Promise<any>;
21
21
  close: () => void;
22
22
  get connected(): boolean;
23
- get peerConnection(): RTCPeerConnection;
24
23
  }
@@ -130,9 +130,6 @@ class RTCEndpoint {
130
130
  get connected() {
131
131
  return this.rtc.rtcClient.connectionState === 'connected';
132
132
  }
133
- get peerConnection() {
134
- return this.rtc.rtcClient;
135
- }
136
133
  }
137
134
  exports.RTCEndpoint = RTCEndpoint;
138
135
  _processAction = new WeakMap(), _disconnectListener = new WeakMap();
@@ -9,7 +9,6 @@ export interface RTCStrategyEndpointPayload {
9
9
  export declare class RTCStrategy implements ChannelStrategy<RTCStrategyEndpointPayload> {
10
10
  #private;
11
11
  onEndpointDisconnect(endpointId: string, listener: () => void): void;
12
- getRTCConnection(endpointId: string): RTCPeerConnection;
13
12
  receive(listener: (action: string, payload: any, identity: OpenFin.ClientIdentity | OpenFin.ClientIdentityMultiRuntime | ProviderIdentity) => Promise<any>): void;
14
13
  send: (endpointId: string, action: string, payload: any) => Promise<any>;
15
14
  close: () => Promise<void>;
@@ -38,13 +38,6 @@ class RTCStrategy {
38
38
  onEndpointDisconnect(endpointId, listener) {
39
39
  this.getEndpointById(endpointId).onDisconnect(listener);
40
40
  }
41
- getRTCConnection(endpointId) {
42
- const endpoint = __classPrivateFieldGet(this, _rtcEndpointMap).get(endpointId);
43
- if (!endpoint) {
44
- throw new Error('Could not find WebRTC connection');
45
- }
46
- return endpoint.peerConnection;
47
- }
48
41
  receive(listener) {
49
42
  if (__classPrivateFieldGet(this, _processAction)) {
50
43
  throw new Error('You have already set a listener for this RTC Strategy');
@@ -8,7 +8,6 @@ export interface ChannelStrategy<T extends unknown> {
8
8
  isEndpointConnected(endpointId: string): boolean;
9
9
  addEndpoint(endpointId: string, payload: T): void;
10
10
  isValidEndpointPayload(payload: unknown): payload is T;
11
- getRTCConnection(endpointId: string): RTCPeerConnection;
12
11
  }
13
12
  export declare type EndpointIdentity = OpenFin.ClientIdentity | ProviderIdentity;
14
13
  export declare type EndpointPayload = {
@@ -3,7 +3,7 @@ import Transport from '../../../transport/transport';
3
3
  import { AnyStrategy } from './protocols/strategy-types';
4
4
  import ProviderIdentity = OpenFin.ProviderIdentity;
5
5
  import ClientIdentity = OpenFin.ClientIdentity;
6
- export declare type ConnectionListener = (identity: ClientIdentity, connectionMessage?: any) => any;
6
+ export declare type ConnectionListener = (identity: ClientIdentity, connectionMessage?: any) => Promise<any> | any;
7
7
  export declare type DisconnectionListener = (identity: ClientIdentity) => any;
8
8
  export declare class ChannelProvider extends ChannelBase {
9
9
  #private;
@@ -13,7 +13,6 @@ export declare class ChannelProvider extends ChannelBase {
13
13
  get connections(): OpenFin.ClientIdentity[];
14
14
  static handleClientDisconnection(channel: ChannelProvider, payload: any): void;
15
15
  static setProviderRemoval(provider: ChannelProvider, remove: Function): void;
16
- getRTCPeerConnection(endpointId: string): RTCPeerConnection;
17
16
  constructor(providerIdentity: ProviderIdentity, wire: Transport, strategy: AnyStrategy);
18
17
  dispatch(to: OpenFin.ClientIdentity | OpenFin.Identity, action: string, payload?: any): Promise<any>;
19
18
  protected processAction: (action: string, payload: any, senderIdentity: OpenFin.ClientIdentity | OpenFin.ClientIdentityMultiRuntime) => Promise<any>;
@@ -73,9 +73,6 @@ let ChannelProvider = /** @class */ (() => {
73
73
  static setProviderRemoval(provider, remove) {
74
74
  ChannelProvider.removalMap.set(provider, remove);
75
75
  }
76
- getRTCPeerConnection(endpointId) {
77
- return __classPrivateFieldGet(this, _strategy).getRTCConnection(endpointId);
78
- }
79
76
  dispatch(to, action, payload) {
80
77
  var _a;
81
78
  const endpointId = (_a = to.endpointId) !== null && _a !== void 0 ? _a : this.getEndpointIdForOpenFinId(to, action);
@@ -351,7 +351,7 @@ export declare class InteropBroker extends Base {
351
351
  * @param _id the identity tryinc to connect
352
352
  * @param _connectionPayload optional payload to use in custom implementations, will be undefined by default
353
353
  */
354
- isConnectionAuthorized(_id: Identity, _connectionPayload?: any): Promise<boolean>;
354
+ isConnectionAuthorized(_id: Identity, _connectionPayload?: any): Promise<boolean> | boolean;
355
355
  /**
356
356
  * Called before every action to check if this entity should be allowed to take the action.
357
357
  * Return false to prevent the action
@@ -359,5 +359,5 @@ export declare class InteropBroker extends Base {
359
359
  * @param _payload the data being sent for this action
360
360
  * @param _identity the connection attempting to dispatch this action
361
361
  */
362
- isActionAuthorized(_action: string, _payload: any, _identity: OpenFin.ClientIdentity): Promise<boolean>;
362
+ isActionAuthorized(_action: string, _payload: any, _identity: OpenFin.ClientIdentity): Promise<boolean> | boolean;
363
363
  }
@@ -828,8 +828,8 @@ class InteropBroker extends base_1.Base {
828
828
  }
829
829
  // Setup Channel Connection Logic
830
830
  wireChannel(channel) {
831
- channel.onConnection((clientIdentity, payload) => {
832
- if (!this.isConnectionAuthorized(clientIdentity, payload)) {
831
+ channel.onConnection(async (clientIdentity, payload) => {
832
+ if (!(await this.isConnectionAuthorized(clientIdentity, payload))) {
833
833
  throw new Error(`Connection not authorized for ${clientIdentity.uuid}, ${clientIdentity.name}`);
834
834
  }
835
835
  if (!clientIdentity.endpointId) {
@@ -860,8 +860,8 @@ class InteropBroker extends base_1.Base {
860
860
  });
861
861
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
862
862
  // @ts-ignore
863
- channel.beforeAction((action, payload, clientIdentity) => {
864
- if (!this.isActionAuthorized(action, payload, clientIdentity)) {
863
+ channel.beforeAction(async (action, payload, clientIdentity) => {
864
+ if (!(await this.isActionAuthorized(action, payload, clientIdentity))) {
865
865
  throw new Error(`Action (${action}) not authorized for ${clientIdentity.uuid}, ${clientIdentity.name}`);
866
866
  }
867
867
  console.log(action, payload, clientIdentity);
@@ -891,11 +891,11 @@ class InteropBroker extends base_1.Base {
891
891
  * @param _id the identity tryinc to connect
892
892
  * @param _connectionPayload optional payload to use in custom implementations, will be undefined by default
893
893
  */
894
- async isConnectionAuthorized(_id, _connectionPayload) {
894
+ isConnectionAuthorized(_id, _connectionPayload) {
895
895
  this.wire.sendAction('interop-broker-is-connection-authorized').catch((e) => {
896
896
  // don't expose, analytics-only call
897
897
  });
898
- return true;
898
+ return Promise.resolve(true);
899
899
  }
900
900
  /**
901
901
  * Called before every action to check if this entity should be allowed to take the action.
@@ -904,11 +904,11 @@ class InteropBroker extends base_1.Base {
904
904
  * @param _payload the data being sent for this action
905
905
  * @param _identity the connection attempting to dispatch this action
906
906
  */
907
- async isActionAuthorized(_action, _payload, _identity) {
907
+ isActionAuthorized(_action, _payload, _identity) {
908
908
  this.wire.sendAction('interop-broker-is-action-authorized').catch((e) => {
909
909
  // don't expose, analytics-only call
910
910
  });
911
- return true;
911
+ return Promise.resolve(true);
912
912
  }
913
913
  }
914
914
  exports.InteropBroker = InteropBroker;