@openfin/remote-adapter 43.100.90 → 43.100.92

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/remote-adapter.js +130 -71
  2. package/package.json +2 -2
@@ -523,7 +523,7 @@ Object.defineProperty(PrivateChannelProvider$1, "__esModule", { value: true });
523
523
  PrivateChannelProvider$1.PrivateChannelProvider = void 0;
524
524
  const utils_1$8 = utils$3;
525
525
  class PrivateChannelProvider {
526
- constructor(provider, id) {
526
+ constructor(provider, id, removePrivateChannelProvider) {
527
527
  this.provider = provider;
528
528
  this.id = id;
529
529
  this.clients = new Map();
@@ -531,6 +531,7 @@ class PrivateChannelProvider {
531
531
  this.contextByContextType = new Map();
532
532
  this.lastContext = undefined;
533
533
  this.provider.onConnection((clientIdentity) => this.registerNewClient(clientIdentity));
534
+ this.removePrivateChannelProvider = removePrivateChannelProvider;
534
535
  this.provider.onDisconnection(async (clientIdentity) => {
535
536
  const { endpointId } = clientIdentity;
536
537
  if (this.clients.has(endpointId)) {
@@ -538,6 +539,7 @@ class PrivateChannelProvider {
538
539
  }
539
540
  if ((await this.provider.getAllClientInfo()).length === 0) {
540
541
  this.provider.destroy();
542
+ this.removePrivateChannelProvider(this.id);
541
543
  }
542
544
  });
543
545
  }
@@ -789,8 +791,8 @@ class PrivateChannelProvider {
789
791
  });
790
792
  });
791
793
  }
792
- static init(channelProvider, id) {
793
- return new PrivateChannelProvider(channelProvider, id);
794
+ static init(channelProvider, id, removePrivateChannelProvider) {
795
+ return new PrivateChannelProvider(channelProvider, id, removePrivateChannelProvider);
794
796
  }
795
797
  }
796
798
  PrivateChannelProvider$1.PrivateChannelProvider = PrivateChannelProvider;
@@ -862,16 +864,16 @@ var __classPrivateFieldGet$h = (commonjsGlobal && commonjsGlobal.__classPrivateF
862
864
  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");
863
865
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
864
866
  };
865
- var __importDefault$6 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
867
+ var __importDefault$7 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
866
868
  return (mod && mod.__esModule) ? mod : { "default": mod };
867
869
  };
868
870
  var _InteropBroker_fdc3Info, _InteropBroker_contextGroups, _InteropBroker_providerPromise;
869
871
  Object.defineProperty(InteropBroker$1, "__esModule", { value: true });
870
872
  InteropBroker$1.InteropBroker = void 0;
871
873
  const base_1$n = base;
872
- const SessionContextGroupBroker_1 = __importDefault$6(SessionContextGroupBroker$1);
874
+ const SessionContextGroupBroker_1 = __importDefault$7(SessionContextGroupBroker$1);
873
875
  const utils_1$7 = utils$3;
874
- const isEqual_1$1 = __importDefault$6(require$$3);
876
+ const isEqual_1$2 = __importDefault$7(require$$3);
875
877
  const PrivateChannelProvider_1 = PrivateChannelProvider$1;
876
878
  const lazy_1$3 = lazy;
877
879
  const defaultContextGroups = [
@@ -1060,6 +1062,7 @@ class InteropBroker extends base_1$n.Base {
1060
1062
  this.intentClientMap = new Map();
1061
1063
  this.lastContextMap = new Map();
1062
1064
  this.sessionContextGroupMap = new Map();
1065
+ this.privateChannelProviderMap = new Map();
1063
1066
  __classPrivateFieldSet$g(this, _InteropBroker_providerPromise, new lazy_1$3.Lazy(createProvider), "f");
1064
1067
  this.setContextGroupMap();
1065
1068
  this.setupChannelProvider();
@@ -1069,7 +1072,7 @@ class InteropBroker extends base_1$n.Base {
1069
1072
  constructor(...unused) {
1070
1073
  if (unused.length) {
1071
1074
  const [_ignore1, ignore2, opts] = unused;
1072
- if (opts && typeof opts === 'object' && !(0, isEqual_1$1.default)(opts, args[2])) {
1075
+ if (opts && typeof opts === 'object' && !(0, isEqual_1$2.default)(opts, args[2])) {
1073
1076
  // eslint-disable-next-line no-console
1074
1077
  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.');
1075
1078
  super(args[0], args[1], opts);
@@ -2080,7 +2083,15 @@ class InteropBroker extends base_1$n.Base {
2080
2083
  channel.register('createPrivateChannelProvider', async (payload) => {
2081
2084
  const { channelId } = payload;
2082
2085
  const channelProvider = await this.fin.InterApplicationBus.Channel.create(channelId);
2083
- PrivateChannelProvider_1.PrivateChannelProvider.init(channelProvider, channelId);
2086
+ const removePrivateChannelProvider = (channelId) => {
2087
+ this.privateChannelProviderMap.delete(channelId);
2088
+ };
2089
+ const privateChannelProvider = PrivateChannelProvider_1.PrivateChannelProvider.init(channelProvider, channelId, removePrivateChannelProvider);
2090
+ this.privateChannelProviderMap.set(channelId, privateChannelProvider);
2091
+ });
2092
+ channel.register('isIdUsedByPrivateChannel', async (payload) => {
2093
+ const { channelId } = payload;
2094
+ return this.privateChannelProviderMap.has(channelId);
2084
2095
  });
2085
2096
  }
2086
2097
  /**
@@ -7591,7 +7602,7 @@ var __classPrivateFieldGet$g = (commonjsGlobal && commonjsGlobal.__classPrivateF
7591
7602
  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");
7592
7603
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
7593
7604
  };
7594
- var __importDefault$5 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
7605
+ var __importDefault$6 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
7595
7606
  return (mod && mod.__esModule) ? mod : { "default": mod };
7596
7607
  };
7597
7608
  var _Transport_wire, _Transport_fin;
@@ -7600,7 +7611,7 @@ var Transport_1 = transport.Transport = void 0;
7600
7611
  const events_1$5 = require$$0;
7601
7612
  const wire_1 = wire;
7602
7613
  const transport_errors_1$6 = transportErrors;
7603
- const eventAggregator_1 = __importDefault$5(eventAggregator);
7614
+ const eventAggregator_1 = __importDefault$6(eventAggregator);
7604
7615
  const me_1$1 = me;
7605
7616
  const errors_1$2 = errors;
7606
7617
  class Transport extends events_1$5.EventEmitter {
@@ -11475,7 +11486,7 @@ var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateF
11475
11486
  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");
11476
11487
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11477
11488
  };
11478
- var __importDefault$4 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
11489
+ var __importDefault$5 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
11479
11490
  return (mod && mod.__esModule) ? mod : { "default": mod };
11480
11491
  };
11481
11492
  var _ConnectionManager_messageReceiver, _ConnectionManager_rtcConnectionManager;
@@ -11489,7 +11500,7 @@ const ice_manager_1 = iceManager;
11489
11500
  const provider_1$1 = provider;
11490
11501
  const message_receiver_1 = messageReceiver;
11491
11502
  const protocol_manager_1 = protocolManager;
11492
- const strategy_3 = __importDefault$4(strategy);
11503
+ const strategy_3 = __importDefault$5(strategy);
11493
11504
  class ConnectionManager extends base_1$e.Base {
11494
11505
  static getProtocolOptionsFromStrings(protocols) {
11495
11506
  return protocols.map((protocol) => {
@@ -15314,14 +15325,14 @@ var __classPrivateFieldGet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateF
15314
15325
  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");
15315
15326
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15316
15327
  };
15317
- var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
15328
+ var __importDefault$4 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
15318
15329
  return (mod && mod.__esModule) ? mod : { "default": mod };
15319
15330
  };
15320
15331
  var _InteropClient_clientPromise, _InteropClient_sessionContextGroups, _InteropClient_fdc3Factory;
15321
15332
  Object.defineProperty(InteropClient$1, "__esModule", { value: true });
15322
15333
  InteropClient$1.InteropClient = void 0;
15323
15334
  const base_1$4 = base;
15324
- const SessionContextGroupClient_1 = __importDefault$3(SessionContextGroupClient$1);
15335
+ const SessionContextGroupClient_1 = __importDefault$4(SessionContextGroupClient$1);
15325
15336
  const utils_1$5 = utils$3;
15326
15337
  /**
15327
15338
  * The Interop Client API is broken up into two groups:
@@ -16026,15 +16037,86 @@ class PrivateChannelClient {
16026
16037
  }
16027
16038
  PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
16028
16039
 
16040
+ var fdc3Channels2_0 = {};
16041
+
16042
+ var fdc3Channels1_2 = {};
16043
+
16044
+ var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
16045
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16046
+ };
16047
+ Object.defineProperty(fdc3Channels1_2, "__esModule", { value: true });
16048
+ fdc3Channels1_2.createV1Channel = void 0;
16049
+ const isEqual_1$1 = __importDefault$3(require$$3);
16050
+ const createV1Channel = (sessionContextGroup) => {
16051
+ return {
16052
+ id: sessionContextGroup.id,
16053
+ type: 'app',
16054
+ broadcast: sessionContextGroup.setContext,
16055
+ getCurrentContext: async (contextType) => {
16056
+ const context = await sessionContextGroup.getCurrentContext(contextType);
16057
+ return context === undefined ? null : context;
16058
+ },
16059
+ // @ts-expect-error TODO [CORE-1524]
16060
+ addContextListener: (contextType, handler) => {
16061
+ let realHandler;
16062
+ let realType;
16063
+ if (typeof contextType === 'function') {
16064
+ console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
16065
+ realHandler = contextType;
16066
+ }
16067
+ else {
16068
+ realHandler = handler;
16069
+ if (typeof contextType === 'string') {
16070
+ realType = contextType;
16071
+ }
16072
+ }
16073
+ const listener = (async () => {
16074
+ let first = true;
16075
+ const currentContext = await sessionContextGroup.getCurrentContext(realType);
16076
+ const wrappedHandler = (context, contextMetadata) => {
16077
+ if (first) {
16078
+ first = false;
16079
+ if ((0, isEqual_1$1.default)(currentContext, context)) {
16080
+ return;
16081
+ }
16082
+ }
16083
+ // eslint-disable-next-line consistent-return
16084
+ return realHandler(context, contextMetadata);
16085
+ };
16086
+ return sessionContextGroup.addContextHandler(wrappedHandler, realType);
16087
+ })();
16088
+ return {
16089
+ ...listener,
16090
+ unsubscribe: () => listener.then((l) => l.unsubscribe())
16091
+ };
16092
+ }
16093
+ };
16094
+ };
16095
+ fdc3Channels1_2.createV1Channel = createV1Channel;
16096
+
16097
+ Object.defineProperty(fdc3Channels2_0, "__esModule", { value: true });
16098
+ fdc3Channels2_0.createV2Channel = void 0;
16099
+ const fdc3_channels_1_2_1$1 = fdc3Channels1_2;
16100
+ const createV2Channel = (sessionContextGroup) => {
16101
+ const channel = (0, fdc3_channels_1_2_1$1.createV1Channel)(sessionContextGroup);
16102
+ return {
16103
+ ...channel,
16104
+ // @ts-expect-error Type incompatibility on signature.
16105
+ addContextListener: async (...args) => channel.addContextListener(...args)
16106
+ };
16107
+ };
16108
+ fdc3Channels2_0.createV2Channel = createV2Channel;
16109
+
16029
16110
  (function (exports) {
16030
16111
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
16031
16112
  return (mod && mod.__esModule) ? mod : { "default": mod };
16032
16113
  };
16033
16114
  Object.defineProperty(exports, "__esModule", { value: true });
16034
- exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
16115
+ exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
16035
16116
  const utils_1 = utils$3;
16036
16117
  const PrivateChannelClient_1 = PrivateChannelClient$1;
16037
- const isEqual_1 = __importDefault(require$$3);
16118
+ __importDefault(require$$3);
16119
+ const fdc3_channels_2_0_1 = fdc3Channels2_0;
16038
16120
  const getUnsupportedChannelApis = (channelType) => {
16039
16121
  return {
16040
16122
  addContextListener: () => {
@@ -16133,52 +16215,6 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
16133
16215
  };
16134
16216
  };
16135
16217
  exports.buildPrivateChannelObject = buildPrivateChannelObject;
16136
- const buildAppChannelObject = (sessionContextGroup) => {
16137
- return {
16138
- id: sessionContextGroup.id,
16139
- type: 'app',
16140
- broadcast: sessionContextGroup.setContext,
16141
- getCurrentContext: async (contextType) => {
16142
- const context = await sessionContextGroup.getCurrentContext(contextType);
16143
- return context === undefined ? null : context;
16144
- },
16145
- // @ts-expect-error TODO [CORE-1524]
16146
- addContextListener: (contextType, handler) => {
16147
- let realHandler;
16148
- let realType;
16149
- if (typeof contextType === 'function') {
16150
- console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
16151
- realHandler = contextType;
16152
- }
16153
- else {
16154
- realHandler = handler;
16155
- if (typeof contextType === 'string') {
16156
- realType = contextType;
16157
- }
16158
- }
16159
- const listener = (async () => {
16160
- let first = true;
16161
- const currentContext = await sessionContextGroup.getCurrentContext(realType);
16162
- const wrappedHandler = (context, contextMetadata) => {
16163
- if (first) {
16164
- first = false;
16165
- if ((0, isEqual_1.default)(currentContext, context)) {
16166
- return;
16167
- }
16168
- }
16169
- // eslint-disable-next-line consistent-return
16170
- return realHandler(context, contextMetadata);
16171
- };
16172
- return sessionContextGroup.addContextHandler(wrappedHandler, realType);
16173
- })();
16174
- return {
16175
- ...listener,
16176
- unsubscribe: () => listener.then((l) => l.unsubscribe())
16177
- };
16178
- }
16179
- };
16180
- };
16181
- exports.buildAppChannelObject = buildAppChannelObject;
16182
16218
  const connectPrivateChannel = async (channelId) => {
16183
16219
  try {
16184
16220
  const channelClient = await fin.InterApplicationBus.Channel.connect(channelId);
@@ -16210,6 +16246,10 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
16210
16246
  // Generate an ID to make a session context group with. We will pass that ID to the Broker.
16211
16247
  // The broker will then setContext on that session context group later with our Intent Result,
16212
16248
  const guid = (0, utils_1.generateId)(); // TODO make this undefined in web
16249
+ let isPromiseSettled = false;
16250
+ // Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
16251
+ const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
16252
+ const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
16213
16253
  // Promise we'll use in getResult
16214
16254
  const getResultPromise = new Promise((resolve, reject) => {
16215
16255
  fin.InterApplicationBus.subscribe({ uuid: '*' }, guid, (intentResult) => {
@@ -16222,13 +16262,24 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
16222
16262
  reject(new Error('getResult is not supported in this environment'));
16223
16263
  });
16224
16264
  });
16225
- // Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
16226
- const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
16227
- const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
16265
+ getResultPromise
16266
+ .then(() => {
16267
+ isPromiseSettled = true;
16268
+ })
16269
+ .catch(() => {
16270
+ isPromiseSettled = true;
16271
+ });
16228
16272
  // Set up the getResult call.
16229
16273
  const getResult = async () => {
16274
+ // All this mumbo jumbo is needed to make sure that getResult resolves correctly and conforms to the FDC3 spec.
16275
+ if (!isPromiseSettled) {
16276
+ return undefined;
16277
+ }
16230
16278
  let intentResult = await getResultPromise;
16231
- if (!intentResult || typeof intentResult !== 'object') {
16279
+ if (isPromiseSettled && !intentResult) {
16280
+ return undefined;
16281
+ }
16282
+ if (typeof intentResult !== 'object') {
16232
16283
  throw new Error(ResultError.NoResultReturned);
16233
16284
  }
16234
16285
  const { error } = intentResult;
@@ -16244,7 +16295,7 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
16244
16295
  }
16245
16296
  case 'app': {
16246
16297
  const sessionContextGroup = await interopModule.joinSessionContextGroup(id);
16247
- intentResult = (0, exports.buildAppChannelObject)(sessionContextGroup);
16298
+ intentResult = (0, fdc3_channels_2_0_1.createV2Channel)(sessionContextGroup);
16248
16299
  break;
16249
16300
  }
16250
16301
  }
@@ -16354,10 +16405,16 @@ class FDC3ModuleBase {
16354
16405
  *
16355
16406
  * @tutorial fdc3.getOrCreateChannel
16356
16407
  */
16357
- async getOrCreateChannel(channelId) {
16408
+ async getOrCreateChannel(channelId, fdc3Factory) {
16358
16409
  this.wire.sendAction('fdc3-get-or-create-channel').catch((e) => {
16359
16410
  // we do not want to expose this error, just continue if this analytics-only call fails
16360
16411
  });
16412
+ const hasChannelIdBeenUsed = await InteropClient_1$2.InteropClient.ferryFdc3Call(this.client, 'isIdUsedByPrivateChannel', {
16413
+ channelId
16414
+ });
16415
+ if (hasChannelIdBeenUsed) {
16416
+ throw new Error(utils_1$4.ChannelError.AccessDenied);
16417
+ }
16361
16418
  const systemChannels = await this._getChannels();
16362
16419
  const userChannel = systemChannels.find((channel) => channel.id === channelId);
16363
16420
  if (userChannel) {
@@ -16365,7 +16422,7 @@ class FDC3ModuleBase {
16365
16422
  }
16366
16423
  try {
16367
16424
  const sessionContextGroup = await this.client.joinSessionContextGroup(channelId);
16368
- return (0, utils_1$4.buildAppChannelObject)(sessionContextGroup);
16425
+ return fdc3Factory(sessionContextGroup);
16369
16426
  }
16370
16427
  catch (error) {
16371
16428
  console.error(error.message);
@@ -16515,6 +16572,7 @@ Object.defineProperty(fdc31_2, "__esModule", { value: true });
16515
16572
  fdc31_2.Fdc3Module = void 0;
16516
16573
  const utils_1$3 = utils$3;
16517
16574
  const fdc3_common_1$1 = fdc3Common;
16575
+ const fdc3_channels_1_2_1 = fdc3Channels1_2;
16518
16576
  /**
16519
16577
  * @version 1.2
16520
16578
  * The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
@@ -16697,7 +16755,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16697
16755
  * @tutorial fdc3.getOrCreateChannel
16698
16756
  */
16699
16757
  async getOrCreateChannel(channelId) {
16700
- return super.getOrCreateChannel(channelId);
16758
+ return super.getOrCreateChannel(channelId, fdc3_channels_1_2_1.createV1Channel);
16701
16759
  }
16702
16760
  /**
16703
16761
  * 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.
@@ -16727,6 +16785,7 @@ const utils_1$2 = utils$3;
16727
16785
  const InteropClient_1$1 = InteropClient$1;
16728
16786
  const utils_2 = utils$2;
16729
16787
  const PrivateChannelClient_1 = PrivateChannelClient$1;
16788
+ const fdc3_channels_2_0_1 = fdc3Channels2_0;
16730
16789
  /**
16731
16790
  * @version 2.0
16732
16791
  * The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
@@ -16978,7 +17037,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16978
17037
  * @tutorial fdc3.getOrCreateChannel
16979
17038
  */
16980
17039
  async getOrCreateChannel(channelId) {
16981
- return super.getOrCreateChannel(channelId);
17040
+ return super.getOrCreateChannel(channelId, fdc3_channels_2_0_1.createV2Channel);
16982
17041
  }
16983
17042
  /**
16984
17043
  * 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/remote-adapter",
3
- "version": "43.100.90",
3
+ "version": "43.100.92",
4
4
  "description": "Establish intermachine runtime connections using webRTC.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "private": false,
@@ -20,6 +20,6 @@
20
20
  "author": "OpenFin",
21
21
  "dependencies": {
22
22
  "lodash": "^4.17.21",
23
- "@openfin/core": "43.100.90"
23
+ "@openfin/core": "43.100.92"
24
24
  }
25
25
  }