Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openfin-adapter

Package Overview
Dependencies
Maintainers
1
Versions
970
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openfin-adapter - npm Package Compare versions

Comparing version 19.56.4 to 19.56.5

6

fin.d.ts

@@ -24,2 +24,8 @@ declare namespace OpenFin {

}
export interface ClientIdentity {
uuid: string;
name: string;
endpointId: string;
}
export interface EntityInfo {

@@ -26,0 +32,0 @@ uuid: string;

2

package.json
{
"name": "openfin-adapter",
"version": "19.56.4",
"version": "19.56.5",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "main": "./src/main.js",

@@ -33,3 +33,3 @@ declare const InterApplicationBus: any;

* @hideconstructor
* @property {Identity[]} connections a read-only array containing all the identities of connecting clients.
* @property {InterApplicationBus.Channel~ClientIdentity[]} connections a read-only array containing all the identities of connecting clients.
*

@@ -48,3 +48,3 @@ */

* Dispatch an action to a specified client. Returns a promise for the result of executing that action on the client side.
* @param {Identity} to - Identity of the target client.
* @param {InterApplicationBus.Channel~ClientIdentity} to - Identity of the target client.
* @param {string} action - Name of the action to be invoked by the client.

@@ -248,3 +248,3 @@ * @param {*} payload - Payload to be sent along with the action.

* @param {any} payload - Payload sent along with the message.
* @param {Identity} identity - Identity of the sender.
* @param {InterApplicationBus.Channel~ClientIdentity} identity - Identity of the sender.
*/

@@ -274,3 +274,3 @@ /**

* @callback Channel#ChannelProvider~ConnectionListener
* @param {Identity} identity - Identity of the client attempting to connect to the channel.
* @param {InterApplicationBus.Channel~ClientIdentity} identity - Identity of the client attempting to connect to the channel.
* @param {any} payload - Payload sent with connection request.

@@ -303,1 +303,9 @@ */

*/
/**
* Client Identity.
* @typedef {object} InterApplicationBus.Channel~ClientIdentity
* @property {string} uuid - Channel client uuid.
* @property {string} name - Channel client name.
* @property {string} endpointId - Unique identifier for a client, because there can be multiple clients at one name/uuid entity.
*
*/

@@ -90,3 +90,3 @@ /* eslint-disable class-methods-use-this, @typescript-eslint/no-empty-function, @typescript-eslint/explicit-function-return-type */

* @hideconstructor
* @property {Identity[]} connections a read-only array containing all the identities of connecting clients.
* @property {InterApplicationBus.Channel~ClientIdentity[]} connections a read-only array containing all the identities of connecting clients.
*

@@ -105,3 +105,3 @@ */

* Dispatch an action to a specified client. Returns a promise for the result of executing that action on the client side.
* @param {Identity} to - Identity of the target client.
* @param {InterApplicationBus.Channel~ClientIdentity} to - Identity of the target client.
* @param {string} action - Name of the action to be invoked by the client.

@@ -305,3 +305,3 @@ * @param {*} payload - Payload to be sent along with the action.

* @param {any} payload - Payload sent along with the message.
* @param {Identity} identity - Identity of the sender.
* @param {InterApplicationBus.Channel~ClientIdentity} identity - Identity of the sender.
*/

@@ -331,3 +331,3 @@ /**

* @callback Channel#ChannelProvider~ConnectionListener
* @param {Identity} identity - Identity of the client attempting to connect to the channel.
* @param {InterApplicationBus.Channel~ClientIdentity} identity - Identity of the client attempting to connect to the channel.
* @param {any} payload - Payload sent with connection request.

@@ -360,1 +360,9 @@ */

*/
/**
* Client Identity.
* @typedef {object} InterApplicationBus.Channel~ClientIdentity
* @property {string} uuid - Channel client uuid.
* @property {string} name - Channel client name.
* @property {string} endpointId - Unique identifier for a client, because there can be multiple clients at one name/uuid entity.
*
*/
import { ChannelBase } from './channel';
import Transport from '../../../transport/transport';
import { Identity } from '../../../main';
import { ClientIdentity, ProviderIdentity } from '../../../shapes/Identity';
import { ProviderIdentity } from '../../../shapes/Identity';
export declare type ConnectionListener = (identity: Identity, connectionMessage?: any) => any;

@@ -10,7 +10,7 @@ export declare type DisconnectionListener = (identity: Identity) => any;

private disconnectListener;
connections: ClientIdentity[];
connections: OpenFin.ClientIdentity[];
constructor(providerIdentity: ProviderIdentity, send: Transport['sendAction']);
dispatch(to: Identity, action: string, payload?: any): Promise<any>;
processAction(action: string, payload: any, senderIdentity: ProviderIdentity): Promise<any>;
processConnection(senderId: Identity, payload: any): Promise<any>;
dispatch(to: OpenFin.ClientIdentity | OpenFin.Identity, action: string, payload?: any): Promise<any>;
processAction(action: string, payload: any, senderIdentity: OpenFin.ClientIdentity): Promise<any>;
processConnection(senderId: OpenFin.ClientIdentity, payload: any): Promise<any>;
publish(action: string, payload: any): Promise<any>[];

@@ -20,2 +20,5 @@ onConnection(listener: ConnectionListener): void;

destroy(): Promise<void>;
private isClientConnected;
private checkForMultipleClients;
private static clientIdentityIncludesEndpointId;
}

@@ -14,4 +14,6 @@ "use strict";

dispatch(to, action, payload) {
// verify if the client is valid
if (this.connections.some((c) => c.name === to.name && c.uuid === to.uuid)) {
if (!ChannelProvider.clientIdentityIncludesEndpointId(to)) {
this.checkForMultipleClients(to, action);
}
if (this.isClientConnected(to)) {
return providerProtectedMap.get(this).send(to, action, payload);

@@ -23,6 +25,3 @@ }

async processAction(action, payload, senderIdentity) {
const clientConnected = this.connections.some((identity) => {
return identity.uuid === senderIdentity.uuid && identity.name === senderIdentity.name;
});
if (!clientConnected) {
if (!this.isClientConnected(senderIdentity)) {
throw new Error('This action was sent from a client that is not connected to the provider.');

@@ -52,3 +51,40 @@ }

}
isClientConnected(clientIdentity) {
if (ChannelProvider.clientIdentityIncludesEndpointId(clientIdentity)) {
return this.connections.some((identity) => {
return (
// Might be redundant to check for uuid and name here after we get an endpointId match, but just in case
identity.endpointId === clientIdentity.endpointId &&
identity.uuid === clientIdentity.uuid &&
identity.name === clientIdentity.name);
});
}
return this.connections.some((identity) => {
return identity.uuid === clientIdentity.uuid && identity.name === clientIdentity.name;
});
}
checkForMultipleClients(clientIdentity, action) {
let count = 0;
this.connections.forEach((c) => {
if (c.name === clientIdentity.name && c.uuid === clientIdentity.uuid) {
count += 1;
}
});
if (count >= 2) {
const protectedObj = providerProtectedMap.get(this);
const { uuid, name } = clientIdentity;
const providerUuid = protectedObj === null || protectedObj === void 0 ? void 0 : protectedObj.providerIdentity.uuid;
const providerName = protectedObj === null || protectedObj === void 0 ? void 0 : protectedObj.providerIdentity.name;
// eslint-disable-next-line no-console
console.warn(`WARNING: Dispatch call may have unintended results. The "to" argument of your dispatch call is missing the
"endpointId" parameter. The identity you are dispatching to ({uuid: ${uuid}, name: ${name}})
has multiple channelClients for this channel. Your dispatched action: (${action}) from the provider:
({uuid: ${providerUuid}, name: ${providerName}}) will only be processed by the most recently-created client.`);
}
}
// eslint-disable-next-line class-methods-use-this
static clientIdentityIncludesEndpointId(subscriptionIdentity) {
return subscriptionIdentity.endpointId !== undefined;
}
}
exports.ChannelProvider = ChannelProvider;

@@ -46,5 +46,2 @@ /// <reference types="node" />

* Subscribes to messages from the specified application on the specified topic.
* If the subscription is for a uuid, [name], topic combination that has already
* been published to upon subscription you will receive the last 20 missed messages
* in the order they were published.
* @param { Identity } source This object is described in the Identity in the typedef

@@ -51,0 +48,0 @@ * @param { string } topic The topic on which the message is sent

@@ -71,5 +71,2 @@ "use strict";

* Subscribes to messages from the specified application on the specified topic.
* If the subscription is for a uuid, [name], topic combination that has already
* been published to upon subscription you will receive the last 20 missed messages
* in the order they were published.
* @param { Identity } source This object is described in the Identity in the typedef

@@ -76,0 +73,0 @@ * @param { string } topic The topic on which the message is sent

@@ -13,9 +13,5 @@ import EntityType from './EntityType';

isExternal?: boolean;
runtimeUuid?: string;
}
export interface ClientIdentity extends Identity {
endpointId?: string;
}
export interface ResourceFetchIdentity extends Identity {
resourceFetch?: boolean;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc