@openfin/node-adapter 42.100.107 → 42.101.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.
Files changed (2) hide show
  1. package/out/node-adapter.js +129 -70
  2. package/package.json +2 -2
@@ -8747,7 +8747,7 @@ var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateF
8747
8747
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
8748
8748
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8749
8749
  };
8750
- var __importDefault$5 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
8750
+ var __importDefault$6 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
8751
8751
  return (mod && mod.__esModule) ? mod : { "default": mod };
8752
8752
  };
8753
8753
  var _ConnectionManager_messageReceiver, _ConnectionManager_rtcConnectionManager;
@@ -8761,7 +8761,7 @@ const ice_manager_1 = iceManager;
8761
8761
  const provider_1$1 = provider;
8762
8762
  const message_receiver_1 = messageReceiver$1;
8763
8763
  const protocol_manager_1 = protocolManager;
8764
- const strategy_3 = __importDefault$5(strategy);
8764
+ const strategy_3 = __importDefault$6(strategy);
8765
8765
  class ConnectionManager extends base_1$j.Base {
8766
8766
  static getProtocolOptionsFromStrings(protocols) {
8767
8767
  return protocols.map((protocol) => {
@@ -13143,7 +13143,7 @@ Object.defineProperty(PrivateChannelProvider$1, "__esModule", { value: true });
13143
13143
  PrivateChannelProvider$1.PrivateChannelProvider = void 0;
13144
13144
  const utils_1$8 = utils$3;
13145
13145
  class PrivateChannelProvider {
13146
- constructor(provider, id) {
13146
+ constructor(provider, id, removePrivateChannelProvider) {
13147
13147
  this.provider = provider;
13148
13148
  this.id = id;
13149
13149
  this.clients = new Map();
@@ -13151,6 +13151,7 @@ class PrivateChannelProvider {
13151
13151
  this.contextByContextType = new Map();
13152
13152
  this.lastContext = undefined;
13153
13153
  this.provider.onConnection((clientIdentity) => this.registerNewClient(clientIdentity));
13154
+ this.removePrivateChannelProvider = removePrivateChannelProvider;
13154
13155
  this.provider.onDisconnection(async (clientIdentity) => {
13155
13156
  const { endpointId } = clientIdentity;
13156
13157
  if (this.clients.has(endpointId)) {
@@ -13158,6 +13159,7 @@ class PrivateChannelProvider {
13158
13159
  }
13159
13160
  if ((await this.provider.getAllClientInfo()).length === 0) {
13160
13161
  this.provider.destroy();
13162
+ this.removePrivateChannelProvider(this.id);
13161
13163
  }
13162
13164
  });
13163
13165
  }
@@ -13409,8 +13411,8 @@ class PrivateChannelProvider {
13409
13411
  });
13410
13412
  });
13411
13413
  }
13412
- static init(channelProvider, id) {
13413
- return new PrivateChannelProvider(channelProvider, id);
13414
+ static init(channelProvider, id, removePrivateChannelProvider) {
13415
+ return new PrivateChannelProvider(channelProvider, id, removePrivateChannelProvider);
13414
13416
  }
13415
13417
  }
13416
13418
  PrivateChannelProvider$1.PrivateChannelProvider = PrivateChannelProvider;
@@ -13426,16 +13428,16 @@ var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateF
13426
13428
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
13427
13429
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13428
13430
  };
13429
- var __importDefault$4 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
13431
+ var __importDefault$5 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
13430
13432
  return (mod && mod.__esModule) ? mod : { "default": mod };
13431
13433
  };
13432
13434
  var _InteropBroker_fdc3Info, _InteropBroker_contextGroups, _InteropBroker_providerPromise;
13433
13435
  Object.defineProperty(InteropBroker$1, "__esModule", { value: true });
13434
13436
  InteropBroker$1.InteropBroker = void 0;
13435
13437
  const base_1$6 = base;
13436
- const SessionContextGroupBroker_1 = __importDefault$4(SessionContextGroupBroker$1);
13438
+ const SessionContextGroupBroker_1 = __importDefault$5(SessionContextGroupBroker$1);
13437
13439
  const utils_1$7 = utils$3;
13438
- const isEqual_1$1 = __importDefault$4(require$$3);
13440
+ const isEqual_1$2 = __importDefault$5(require$$3);
13439
13441
  const PrivateChannelProvider_1 = PrivateChannelProvider$1;
13440
13442
  const lazy_1$1 = lazy;
13441
13443
  const defaultContextGroups = [
@@ -13624,6 +13626,7 @@ class InteropBroker extends base_1$6.Base {
13624
13626
  this.intentClientMap = new Map();
13625
13627
  this.lastContextMap = new Map();
13626
13628
  this.sessionContextGroupMap = new Map();
13629
+ this.privateChannelProviderMap = new Map();
13627
13630
  __classPrivateFieldSet$6(this, _InteropBroker_providerPromise, new lazy_1$1.Lazy(createProvider), "f");
13628
13631
  this.setContextGroupMap();
13629
13632
  this.setupChannelProvider();
@@ -13633,7 +13636,7 @@ class InteropBroker extends base_1$6.Base {
13633
13636
  constructor(...unused) {
13634
13637
  if (unused.length) {
13635
13638
  const [_ignore1, ignore2, opts] = unused;
13636
- if (opts && typeof opts === 'object' && !(0, isEqual_1$1.default)(opts, args[2])) {
13639
+ if (opts && typeof opts === 'object' && !(0, isEqual_1$2.default)(opts, args[2])) {
13637
13640
  // eslint-disable-next-line no-console
13638
13641
  console.warn('You have modified the parameters of the InteropOverride constructor. This behavior is deprecated and will be removed in a future version. You can modify these options in your manifest. Please consult our Interop docs for guidance on migrating to the new override scheme.');
13639
13642
  super(args[0], args[1], opts);
@@ -14644,7 +14647,15 @@ class InteropBroker extends base_1$6.Base {
14644
14647
  channel.register('createPrivateChannelProvider', async (payload) => {
14645
14648
  const { channelId } = payload;
14646
14649
  const channelProvider = await this.fin.InterApplicationBus.Channel.create(channelId);
14647
- PrivateChannelProvider_1.PrivateChannelProvider.init(channelProvider, channelId);
14650
+ const removePrivateChannelProvider = (channelId) => {
14651
+ this.privateChannelProviderMap.delete(channelId);
14652
+ };
14653
+ const privateChannelProvider = PrivateChannelProvider_1.PrivateChannelProvider.init(channelProvider, channelId, removePrivateChannelProvider);
14654
+ this.privateChannelProviderMap.set(channelId, privateChannelProvider);
14655
+ });
14656
+ channel.register('isIdUsedByPrivateChannel', async (payload) => {
14657
+ const { channelId } = payload;
14658
+ return this.privateChannelProviderMap.has(channelId);
14648
14659
  });
14649
14660
  }
14650
14661
  /**
@@ -14777,14 +14788,14 @@ var __classPrivateFieldGet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateF
14777
14788
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14778
14789
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
14779
14790
  };
14780
- var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
14791
+ var __importDefault$4 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
14781
14792
  return (mod && mod.__esModule) ? mod : { "default": mod };
14782
14793
  };
14783
14794
  var _InteropClient_clientPromise, _InteropClient_sessionContextGroups, _InteropClient_fdc3Factory;
14784
14795
  Object.defineProperty(InteropClient$1, "__esModule", { value: true });
14785
14796
  InteropClient$1.InteropClient = void 0;
14786
14797
  const base_1$4 = base;
14787
- const SessionContextGroupClient_1 = __importDefault$3(SessionContextGroupClient$1);
14798
+ const SessionContextGroupClient_1 = __importDefault$4(SessionContextGroupClient$1);
14788
14799
  const utils_1$5 = utils$3;
14789
14800
  /**
14790
14801
  * The Interop Client API is broken up into two groups:
@@ -15526,15 +15537,86 @@ class PrivateChannelClient {
15526
15537
  }
15527
15538
  PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
15528
15539
 
15540
+ var fdc3Channels2_0 = {};
15541
+
15542
+ var fdc3Channels1_2 = {};
15543
+
15544
+ var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
15545
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15546
+ };
15547
+ Object.defineProperty(fdc3Channels1_2, "__esModule", { value: true });
15548
+ fdc3Channels1_2.createV1Channel = void 0;
15549
+ const isEqual_1$1 = __importDefault$3(require$$3);
15550
+ const createV1Channel = (sessionContextGroup) => {
15551
+ return {
15552
+ id: sessionContextGroup.id,
15553
+ type: 'app',
15554
+ broadcast: sessionContextGroup.setContext,
15555
+ getCurrentContext: async (contextType) => {
15556
+ const context = await sessionContextGroup.getCurrentContext(contextType);
15557
+ return context === undefined ? null : context;
15558
+ },
15559
+ // @ts-expect-error TODO [CORE-1524]
15560
+ addContextListener: (contextType, handler) => {
15561
+ let realHandler;
15562
+ let realType;
15563
+ if (typeof contextType === 'function') {
15564
+ console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
15565
+ realHandler = contextType;
15566
+ }
15567
+ else {
15568
+ realHandler = handler;
15569
+ if (typeof contextType === 'string') {
15570
+ realType = contextType;
15571
+ }
15572
+ }
15573
+ const listener = (async () => {
15574
+ let first = true;
15575
+ const currentContext = await sessionContextGroup.getCurrentContext(realType);
15576
+ const wrappedHandler = (context, contextMetadata) => {
15577
+ if (first) {
15578
+ first = false;
15579
+ if ((0, isEqual_1$1.default)(currentContext, context)) {
15580
+ return;
15581
+ }
15582
+ }
15583
+ // eslint-disable-next-line consistent-return
15584
+ return realHandler(context, contextMetadata);
15585
+ };
15586
+ return sessionContextGroup.addContextHandler(wrappedHandler, realType);
15587
+ })();
15588
+ return {
15589
+ ...listener,
15590
+ unsubscribe: () => listener.then((l) => l.unsubscribe())
15591
+ };
15592
+ }
15593
+ };
15594
+ };
15595
+ fdc3Channels1_2.createV1Channel = createV1Channel;
15596
+
15597
+ Object.defineProperty(fdc3Channels2_0, "__esModule", { value: true });
15598
+ fdc3Channels2_0.createV2Channel = void 0;
15599
+ const fdc3_channels_1_2_1$1 = fdc3Channels1_2;
15600
+ const createV2Channel = (sessionContextGroup) => {
15601
+ const channel = (0, fdc3_channels_1_2_1$1.createV1Channel)(sessionContextGroup);
15602
+ return {
15603
+ ...channel,
15604
+ // @ts-expect-error Type incompatibility on signature.
15605
+ addContextListener: async (...args) => channel.addContextListener(...args)
15606
+ };
15607
+ };
15608
+ fdc3Channels2_0.createV2Channel = createV2Channel;
15609
+
15529
15610
  (function (exports) {
15530
15611
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
15531
15612
  return (mod && mod.__esModule) ? mod : { "default": mod };
15532
15613
  };
15533
15614
  Object.defineProperty(exports, "__esModule", { value: true });
15534
- exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
15615
+ exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
15535
15616
  const utils_1 = utils$3;
15536
15617
  const PrivateChannelClient_1 = PrivateChannelClient$1;
15537
- const isEqual_1 = __importDefault(require$$3);
15618
+ __importDefault(require$$3);
15619
+ const fdc3_channels_2_0_1 = fdc3Channels2_0;
15538
15620
  const getUnsupportedChannelApis = (channelType) => {
15539
15621
  return {
15540
15622
  addContextListener: () => {
@@ -15633,52 +15715,6 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
15633
15715
  };
15634
15716
  };
15635
15717
  exports.buildPrivateChannelObject = buildPrivateChannelObject;
15636
- const buildAppChannelObject = (sessionContextGroup) => {
15637
- return {
15638
- id: sessionContextGroup.id,
15639
- type: 'app',
15640
- broadcast: sessionContextGroup.setContext,
15641
- getCurrentContext: async (contextType) => {
15642
- const context = await sessionContextGroup.getCurrentContext(contextType);
15643
- return context === undefined ? null : context;
15644
- },
15645
- // @ts-expect-error TODO [CORE-1524]
15646
- addContextListener: (contextType, handler) => {
15647
- let realHandler;
15648
- let realType;
15649
- if (typeof contextType === 'function') {
15650
- console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
15651
- realHandler = contextType;
15652
- }
15653
- else {
15654
- realHandler = handler;
15655
- if (typeof contextType === 'string') {
15656
- realType = contextType;
15657
- }
15658
- }
15659
- const listener = (async () => {
15660
- let first = true;
15661
- const currentContext = await sessionContextGroup.getCurrentContext(realType);
15662
- const wrappedHandler = (context, contextMetadata) => {
15663
- if (first) {
15664
- first = false;
15665
- if ((0, isEqual_1.default)(currentContext, context)) {
15666
- return;
15667
- }
15668
- }
15669
- // eslint-disable-next-line consistent-return
15670
- return realHandler(context, contextMetadata);
15671
- };
15672
- return sessionContextGroup.addContextHandler(wrappedHandler, realType);
15673
- })();
15674
- return {
15675
- ...listener,
15676
- unsubscribe: () => listener.then((l) => l.unsubscribe())
15677
- };
15678
- }
15679
- };
15680
- };
15681
- exports.buildAppChannelObject = buildAppChannelObject;
15682
15718
  const connectPrivateChannel = async (channelId) => {
15683
15719
  try {
15684
15720
  const channelClient = await fin.InterApplicationBus.Channel.connect(channelId);
@@ -15710,6 +15746,10 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
15710
15746
  // Generate an ID to make a session context group with. We will pass that ID to the Broker.
15711
15747
  // The broker will then setContext on that session context group later with our Intent Result,
15712
15748
  const guid = (0, utils_1.generateId)(); // TODO make this undefined in web
15749
+ let isPromiseSettled = false;
15750
+ // Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
15751
+ const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
15752
+ const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
15713
15753
  // Promise we'll use in getResult
15714
15754
  const getResultPromise = new Promise((resolve, reject) => {
15715
15755
  fin.InterApplicationBus.subscribe({ uuid: '*' }, guid, (intentResult) => {
@@ -15722,13 +15762,24 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
15722
15762
  reject(new Error('getResult is not supported in this environment'));
15723
15763
  });
15724
15764
  });
15725
- // Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
15726
- const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
15727
- const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
15765
+ getResultPromise
15766
+ .then(() => {
15767
+ isPromiseSettled = true;
15768
+ })
15769
+ .catch(() => {
15770
+ isPromiseSettled = true;
15771
+ });
15728
15772
  // Set up the getResult call.
15729
15773
  const getResult = async () => {
15774
+ // All this mumbo jumbo is needed to make sure that getResult resolves correctly and conforms to the FDC3 spec.
15775
+ if (!isPromiseSettled) {
15776
+ return undefined;
15777
+ }
15730
15778
  let intentResult = await getResultPromise;
15731
- if (!intentResult || typeof intentResult !== 'object') {
15779
+ if (isPromiseSettled && !intentResult) {
15780
+ return undefined;
15781
+ }
15782
+ if (typeof intentResult !== 'object') {
15732
15783
  throw new Error(ResultError.NoResultReturned);
15733
15784
  }
15734
15785
  const { error } = intentResult;
@@ -15744,7 +15795,7 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
15744
15795
  }
15745
15796
  case 'app': {
15746
15797
  const sessionContextGroup = await interopModule.joinSessionContextGroup(id);
15747
- intentResult = (0, exports.buildAppChannelObject)(sessionContextGroup);
15798
+ intentResult = (0, fdc3_channels_2_0_1.createV2Channel)(sessionContextGroup);
15748
15799
  break;
15749
15800
  }
15750
15801
  }
@@ -15854,10 +15905,16 @@ class FDC3ModuleBase {
15854
15905
  *
15855
15906
  * @tutorial fdc3.getOrCreateChannel
15856
15907
  */
15857
- async getOrCreateChannel(channelId) {
15908
+ async getOrCreateChannel(channelId, fdc3Factory) {
15858
15909
  this.wire.sendAction('fdc3-get-or-create-channel').catch((e) => {
15859
15910
  // we do not want to expose this error, just continue if this analytics-only call fails
15860
15911
  });
15912
+ const hasChannelIdBeenUsed = await InteropClient_1$2.InteropClient.ferryFdc3Call(this.client, 'isIdUsedByPrivateChannel', {
15913
+ channelId
15914
+ });
15915
+ if (hasChannelIdBeenUsed) {
15916
+ throw new Error(utils_1$4.ChannelError.AccessDenied);
15917
+ }
15861
15918
  const systemChannels = await this._getChannels();
15862
15919
  const userChannel = systemChannels.find((channel) => channel.id === channelId);
15863
15920
  if (userChannel) {
@@ -15865,7 +15922,7 @@ class FDC3ModuleBase {
15865
15922
  }
15866
15923
  try {
15867
15924
  const sessionContextGroup = await this.client.joinSessionContextGroup(channelId);
15868
- return (0, utils_1$4.buildAppChannelObject)(sessionContextGroup);
15925
+ return fdc3Factory(sessionContextGroup);
15869
15926
  }
15870
15927
  catch (error) {
15871
15928
  console.error(error.message);
@@ -16015,6 +16072,7 @@ Object.defineProperty(fdc31_2, "__esModule", { value: true });
16015
16072
  fdc31_2.Fdc3Module = void 0;
16016
16073
  const utils_1$3 = utils$3;
16017
16074
  const fdc3_common_1$1 = fdc3Common;
16075
+ const fdc3_channels_1_2_1 = fdc3Channels1_2;
16018
16076
  /**
16019
16077
  * @version 1.2
16020
16078
  * The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
@@ -16197,7 +16255,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16197
16255
  * @tutorial fdc3.getOrCreateChannel
16198
16256
  */
16199
16257
  async getOrCreateChannel(channelId) {
16200
- return super.getOrCreateChannel(channelId);
16258
+ return super.getOrCreateChannel(channelId, fdc3_channels_1_2_1.createV1Channel);
16201
16259
  }
16202
16260
  /**
16203
16261
  * Returns metadata relating to the FDC3 object and its provider, including the supported version of the FDC3 specification and the name of the provider of the implementation.
@@ -16227,6 +16285,7 @@ const utils_1$2 = utils$3;
16227
16285
  const InteropClient_1$1 = InteropClient$1;
16228
16286
  const utils_2 = utils$2;
16229
16287
  const PrivateChannelClient_1 = PrivateChannelClient$1;
16288
+ const fdc3_channels_2_0_1 = fdc3Channels2_0;
16230
16289
  /**
16231
16290
  * @version 2.0
16232
16291
  * The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
@@ -16478,7 +16537,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16478
16537
  * @tutorial fdc3.getOrCreateChannel
16479
16538
  */
16480
16539
  async getOrCreateChannel(channelId) {
16481
- return super.getOrCreateChannel(channelId);
16540
+ return super.getOrCreateChannel(channelId, fdc3_channels_2_0_1.createV2Channel);
16482
16541
  }
16483
16542
  /**
16484
16543
  * Returns a Channel with an auto-generated identity that is intended for private communication between applications. Primarily used to create channels that will be returned to other applications via an IntentResolution for a raised intent.
@@ -17999,7 +18058,7 @@ class NodeEnvironment extends BaseEnvironment_1 {
17999
18058
  };
18000
18059
  }
18001
18060
  getAdapterVersionSync() {
18002
- return "42.100.107";
18061
+ return "42.101.2";
18003
18062
  }
18004
18063
  observeBounds(element, onChange) {
18005
18064
  throw new Error('Method not implemented.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/node-adapter",
3
- "version": "42.100.107",
3
+ "version": "42.101.2",
4
4
  "description": "See README.md",
5
5
  "main": "out/node-adapter.js",
6
6
  "types": "out/node-adapter.d.ts",
@@ -24,7 +24,7 @@
24
24
  "author": "OpenFin",
25
25
  "dependencies": {
26
26
  "@types/node": "^20.14.2",
27
- "@openfin/core": "42.100.107",
27
+ "@openfin/core": "42.101.2",
28
28
  "lodash": "^4.17.21",
29
29
  "ws": "^7.3.0"
30
30
  }