@openfin/fdc3-api 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.
@@ -4575,7 +4575,22 @@ declare type DomainSettings = {
4575
4575
  };
4576
4576
 
4577
4577
  /**
4578
- * Map of preload scripts that can enable new scripts or disable options defined preloadScripts.
4578
+ * Enables or disables specific preload scripts by URL.
4579
+ *
4580
+ * Uses the script's full URL as the key and an object
4581
+ * with an `enabled` boolean property as the value.
4582
+ * @example
4583
+ * ```js
4584
+ * {
4585
+ "match": ["<all_urls>"],
4586
+ "options": {
4587
+ "preloadScripts": {
4588
+ "http://localhost:53000/block-preload.js": { "enabled": false }
4589
+ "http://localhost:53000/allow-preload.js": { "enabled": true }
4590
+ }
4591
+ }
4592
+ }
4593
+ * ```
4579
4594
  */
4580
4595
  declare type DomainSettingsPreloadScripts = Record<string, {
4581
4596
  enabled: boolean;
@@ -5754,7 +5769,7 @@ declare class FDC3ModuleBase<ChannelType extends v1_2.Channel | v2_0.Channel> {
5754
5769
  *
5755
5770
  * @tutorial fdc3.getOrCreateChannel
5756
5771
  */
5757
- getOrCreateChannel(channelId: string): Promise<ChannelType>;
5772
+ protected getOrCreateChannel(channelId: string, fdc3Factory: (contextGroup: OpenFin.SessionContextGroup) => ChannelType): Promise<ChannelType>;
5758
5773
  /**
5759
5774
  * Returns the Interop-Broker-defined context groups available for an entity to join.
5760
5775
  *
@@ -6978,6 +6993,7 @@ declare class InteropBroker extends Base {
6978
6993
  private sessionContextGroupMap;
6979
6994
  private channel;
6980
6995
  private logging;
6996
+ private privateChannelProviderMap;
6981
6997
  /* Excluded from this release type: __constructor */
6982
6998
  private getProvider;
6983
6999
  static createClosedConstructor(...args: ConstructorParameters<typeof InteropBroker>): {
@@ -4575,7 +4575,22 @@ declare type DomainSettings = {
4575
4575
  };
4576
4576
 
4577
4577
  /**
4578
- * Map of preload scripts that can enable new scripts or disable options defined preloadScripts.
4578
+ * Enables or disables specific preload scripts by URL.
4579
+ *
4580
+ * Uses the script's full URL as the key and an object
4581
+ * with an `enabled` boolean property as the value.
4582
+ * @example
4583
+ * ```js
4584
+ * {
4585
+ "match": ["<all_urls>"],
4586
+ "options": {
4587
+ "preloadScripts": {
4588
+ "http://localhost:53000/block-preload.js": { "enabled": false }
4589
+ "http://localhost:53000/allow-preload.js": { "enabled": true }
4590
+ }
4591
+ }
4592
+ }
4593
+ * ```
4579
4594
  */
4580
4595
  declare type DomainSettingsPreloadScripts = Record<string, {
4581
4596
  enabled: boolean;
@@ -5754,7 +5769,7 @@ declare class FDC3ModuleBase<ChannelType extends v1_2.Channel | v2_0.Channel> {
5754
5769
  *
5755
5770
  * @tutorial fdc3.getOrCreateChannel
5756
5771
  */
5757
- getOrCreateChannel(channelId: string): Promise<ChannelType>;
5772
+ protected getOrCreateChannel(channelId: string, fdc3Factory: (contextGroup: OpenFin.SessionContextGroup) => ChannelType): Promise<ChannelType>;
5758
5773
  /**
5759
5774
  * Returns the Interop-Broker-defined context groups available for an entity to join.
5760
5775
  *
@@ -6978,6 +6993,7 @@ declare class InteropBroker extends Base {
6978
6993
  private sessionContextGroupMap;
6979
6994
  private channel;
6980
6995
  private logging;
6996
+ private privateChannelProviderMap;
6981
6997
  /* Excluded from this release type: __constructor */
6982
6998
  private getProvider;
6983
6999
  static createClosedConstructor(...args: ConstructorParameters<typeof InteropBroker>): {
@@ -4575,7 +4575,22 @@ declare type DomainSettings = {
4575
4575
  };
4576
4576
 
4577
4577
  /**
4578
- * Map of preload scripts that can enable new scripts or disable options defined preloadScripts.
4578
+ * Enables or disables specific preload scripts by URL.
4579
+ *
4580
+ * Uses the script's full URL as the key and an object
4581
+ * with an `enabled` boolean property as the value.
4582
+ * @example
4583
+ * ```js
4584
+ * {
4585
+ "match": ["<all_urls>"],
4586
+ "options": {
4587
+ "preloadScripts": {
4588
+ "http://localhost:53000/block-preload.js": { "enabled": false }
4589
+ "http://localhost:53000/allow-preload.js": { "enabled": true }
4590
+ }
4591
+ }
4592
+ }
4593
+ * ```
4579
4594
  */
4580
4595
  declare type DomainSettingsPreloadScripts = Record<string, {
4581
4596
  enabled: boolean;
@@ -5754,7 +5769,7 @@ declare class FDC3ModuleBase<ChannelType extends v1_2.Channel | v2_0.Channel> {
5754
5769
  *
5755
5770
  * @tutorial fdc3.getOrCreateChannel
5756
5771
  */
5757
- getOrCreateChannel(channelId: string): Promise<ChannelType>;
5772
+ protected getOrCreateChannel(channelId: string, fdc3Factory: (contextGroup: OpenFin.SessionContextGroup) => ChannelType): Promise<ChannelType>;
5758
5773
  /**
5759
5774
  * Returns the Interop-Broker-defined context groups available for an entity to join.
5760
5775
  *
@@ -6978,6 +6993,7 @@ declare class InteropBroker extends Base {
6978
6993
  private sessionContextGroupMap;
6979
6994
  private channel;
6980
6995
  private logging;
6996
+ private privateChannelProviderMap;
6981
6997
  /* Excluded from this release type: __constructor */
6982
6998
  private getProvider;
6983
6999
  static createClosedConstructor(...args: ConstructorParameters<typeof InteropBroker>): {
package/out/fdc3-api.d.ts CHANGED
@@ -4634,7 +4634,22 @@ declare type DomainSettings = {
4634
4634
  };
4635
4635
 
4636
4636
  /**
4637
- * Map of preload scripts that can enable new scripts or disable options defined preloadScripts.
4637
+ * Enables or disables specific preload scripts by URL.
4638
+ *
4639
+ * Uses the script's full URL as the key and an object
4640
+ * with an `enabled` boolean property as the value.
4641
+ * @example
4642
+ * ```js
4643
+ * {
4644
+ "match": ["<all_urls>"],
4645
+ "options": {
4646
+ "preloadScripts": {
4647
+ "http://localhost:53000/block-preload.js": { "enabled": false }
4648
+ "http://localhost:53000/allow-preload.js": { "enabled": true }
4649
+ }
4650
+ }
4651
+ }
4652
+ * ```
4638
4653
  */
4639
4654
  declare type DomainSettingsPreloadScripts = Record<string, {
4640
4655
  enabled: boolean;
@@ -5839,7 +5854,7 @@ declare class FDC3ModuleBase<ChannelType extends v1_2.Channel | v2_0.Channel> {
5839
5854
  *
5840
5855
  * @tutorial fdc3.getOrCreateChannel
5841
5856
  */
5842
- getOrCreateChannel(channelId: string): Promise<ChannelType>;
5857
+ protected getOrCreateChannel(channelId: string, fdc3Factory: (contextGroup: OpenFin.SessionContextGroup) => ChannelType): Promise<ChannelType>;
5843
5858
  /**
5844
5859
  * Returns the Interop-Broker-defined context groups available for an entity to join.
5845
5860
  *
@@ -7084,6 +7099,7 @@ declare class InteropBroker extends Base {
7084
7099
  private sessionContextGroupMap;
7085
7100
  private channel;
7086
7101
  private logging;
7102
+ private privateChannelProviderMap;
7087
7103
  /**
7088
7104
  * @internal
7089
7105
  */
package/out/fdc3-api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var require$$2 = require('lodash/isEqual');
3
+ var require$$0 = require('lodash/isEqual');
4
4
 
5
5
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6
6
 
@@ -203,15 +203,86 @@ class PrivateChannelClient {
203
203
  }
204
204
  PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
205
205
 
206
+ var fdc3Channels2_0 = {};
207
+
208
+ var fdc3Channels1_2 = {};
209
+
210
+ var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
211
+ return (mod && mod.__esModule) ? mod : { "default": mod };
212
+ };
213
+ Object.defineProperty(fdc3Channels1_2, "__esModule", { value: true });
214
+ fdc3Channels1_2.createV1Channel = void 0;
215
+ const isEqual_1$1 = __importDefault$2(require$$0);
216
+ const createV1Channel = (sessionContextGroup) => {
217
+ return {
218
+ id: sessionContextGroup.id,
219
+ type: 'app',
220
+ broadcast: sessionContextGroup.setContext,
221
+ getCurrentContext: async (contextType) => {
222
+ const context = await sessionContextGroup.getCurrentContext(contextType);
223
+ return context === undefined ? null : context;
224
+ },
225
+ // @ts-expect-error TODO [CORE-1524]
226
+ addContextListener: (contextType, handler) => {
227
+ let realHandler;
228
+ let realType;
229
+ if (typeof contextType === 'function') {
230
+ console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
231
+ realHandler = contextType;
232
+ }
233
+ else {
234
+ realHandler = handler;
235
+ if (typeof contextType === 'string') {
236
+ realType = contextType;
237
+ }
238
+ }
239
+ const listener = (async () => {
240
+ let first = true;
241
+ const currentContext = await sessionContextGroup.getCurrentContext(realType);
242
+ const wrappedHandler = (context, contextMetadata) => {
243
+ if (first) {
244
+ first = false;
245
+ if ((0, isEqual_1$1.default)(currentContext, context)) {
246
+ return;
247
+ }
248
+ }
249
+ // eslint-disable-next-line consistent-return
250
+ return realHandler(context, contextMetadata);
251
+ };
252
+ return sessionContextGroup.addContextHandler(wrappedHandler, realType);
253
+ })();
254
+ return {
255
+ ...listener,
256
+ unsubscribe: () => listener.then((l) => l.unsubscribe())
257
+ };
258
+ }
259
+ };
260
+ };
261
+ fdc3Channels1_2.createV1Channel = createV1Channel;
262
+
263
+ Object.defineProperty(fdc3Channels2_0, "__esModule", { value: true });
264
+ fdc3Channels2_0.createV2Channel = void 0;
265
+ const fdc3_channels_1_2_1$1 = fdc3Channels1_2;
266
+ const createV2Channel = (sessionContextGroup) => {
267
+ const channel = (0, fdc3_channels_1_2_1$1.createV1Channel)(sessionContextGroup);
268
+ return {
269
+ ...channel,
270
+ // @ts-expect-error Type incompatibility on signature.
271
+ addContextListener: async (...args) => channel.addContextListener(...args)
272
+ };
273
+ };
274
+ fdc3Channels2_0.createV2Channel = createV2Channel;
275
+
206
276
  (function (exports) {
207
277
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
208
278
  return (mod && mod.__esModule) ? mod : { "default": mod };
209
279
  };
210
280
  Object.defineProperty(exports, "__esModule", { value: true });
211
- exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
281
+ exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
212
282
  const utils_1 = utils$2;
213
283
  const PrivateChannelClient_1 = PrivateChannelClient$1;
214
- const isEqual_1 = __importDefault(require$$2);
284
+ __importDefault(require$$0);
285
+ const fdc3_channels_2_0_1 = fdc3Channels2_0;
215
286
  const getUnsupportedChannelApis = (channelType) => {
216
287
  return {
217
288
  addContextListener: () => {
@@ -310,52 +381,6 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
310
381
  };
311
382
  };
312
383
  exports.buildPrivateChannelObject = buildPrivateChannelObject;
313
- const buildAppChannelObject = (sessionContextGroup) => {
314
- return {
315
- id: sessionContextGroup.id,
316
- type: 'app',
317
- broadcast: sessionContextGroup.setContext,
318
- getCurrentContext: async (contextType) => {
319
- const context = await sessionContextGroup.getCurrentContext(contextType);
320
- return context === undefined ? null : context;
321
- },
322
- // @ts-expect-error TODO [CORE-1524]
323
- addContextListener: (contextType, handler) => {
324
- let realHandler;
325
- let realType;
326
- if (typeof contextType === 'function') {
327
- console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
328
- realHandler = contextType;
329
- }
330
- else {
331
- realHandler = handler;
332
- if (typeof contextType === 'string') {
333
- realType = contextType;
334
- }
335
- }
336
- const listener = (async () => {
337
- let first = true;
338
- const currentContext = await sessionContextGroup.getCurrentContext(realType);
339
- const wrappedHandler = (context, contextMetadata) => {
340
- if (first) {
341
- first = false;
342
- if ((0, isEqual_1.default)(currentContext, context)) {
343
- return;
344
- }
345
- }
346
- // eslint-disable-next-line consistent-return
347
- return realHandler(context, contextMetadata);
348
- };
349
- return sessionContextGroup.addContextHandler(wrappedHandler, realType);
350
- })();
351
- return {
352
- ...listener,
353
- unsubscribe: () => listener.then((l) => l.unsubscribe())
354
- };
355
- }
356
- };
357
- };
358
- exports.buildAppChannelObject = buildAppChannelObject;
359
384
  const connectPrivateChannel = async (channelId) => {
360
385
  try {
361
386
  const channelClient = await fin.InterApplicationBus.Channel.connect(channelId);
@@ -387,6 +412,10 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
387
412
  // Generate an ID to make a session context group with. We will pass that ID to the Broker.
388
413
  // The broker will then setContext on that session context group later with our Intent Result,
389
414
  const guid = (0, utils_1.generateId)(); // TODO make this undefined in web
415
+ let isPromiseSettled = false;
416
+ // Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
417
+ const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
418
+ const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
390
419
  // Promise we'll use in getResult
391
420
  const getResultPromise = new Promise((resolve, reject) => {
392
421
  fin.InterApplicationBus.subscribe({ uuid: '*' }, guid, (intentResult) => {
@@ -399,13 +428,24 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
399
428
  reject(new Error('getResult is not supported in this environment'));
400
429
  });
401
430
  });
402
- // Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
403
- const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
404
- const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
431
+ getResultPromise
432
+ .then(() => {
433
+ isPromiseSettled = true;
434
+ })
435
+ .catch(() => {
436
+ isPromiseSettled = true;
437
+ });
405
438
  // Set up the getResult call.
406
439
  const getResult = async () => {
440
+ // All this mumbo jumbo is needed to make sure that getResult resolves correctly and conforms to the FDC3 spec.
441
+ if (!isPromiseSettled) {
442
+ return undefined;
443
+ }
407
444
  let intentResult = await getResultPromise;
408
- if (!intentResult || typeof intentResult !== 'object') {
445
+ if (isPromiseSettled && !intentResult) {
446
+ return undefined;
447
+ }
448
+ if (typeof intentResult !== 'object') {
409
449
  throw new Error(ResultError.NoResultReturned);
410
450
  }
411
451
  const { error } = intentResult;
@@ -421,7 +461,7 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
421
461
  }
422
462
  case 'app': {
423
463
  const sessionContextGroup = await interopModule.joinSessionContextGroup(id);
424
- intentResult = (0, exports.buildAppChannelObject)(sessionContextGroup);
464
+ intentResult = (0, fdc3_channels_2_0_1.createV2Channel)(sessionContextGroup);
425
465
  break;
426
466
  }
427
467
  }
@@ -1473,7 +1513,7 @@ fdc3Common.FDC3ModuleBase = void 0;
1473
1513
  const utils_1$2 = utils$1;
1474
1514
  const utils_2$1 = utils$2;
1475
1515
  const InteropClient_1$1 = InteropClient$1;
1476
- const isEqual_1 = __importDefault(require$$2);
1516
+ const isEqual_1 = __importDefault(require$$0);
1477
1517
  class FDC3ModuleBase {
1478
1518
  get client() {
1479
1519
  return __classPrivateFieldGet(this, _FDC3ModuleBase_producer, "f").call(this);
@@ -1533,10 +1573,16 @@ class FDC3ModuleBase {
1533
1573
  *
1534
1574
  * @tutorial fdc3.getOrCreateChannel
1535
1575
  */
1536
- async getOrCreateChannel(channelId) {
1576
+ async getOrCreateChannel(channelId, fdc3Factory) {
1537
1577
  this.wire.sendAction('fdc3-get-or-create-channel').catch((e) => {
1538
1578
  // we do not want to expose this error, just continue if this analytics-only call fails
1539
1579
  });
1580
+ const hasChannelIdBeenUsed = await InteropClient_1$1.InteropClient.ferryFdc3Call(this.client, 'isIdUsedByPrivateChannel', {
1581
+ channelId
1582
+ });
1583
+ if (hasChannelIdBeenUsed) {
1584
+ throw new Error(utils_1$2.ChannelError.AccessDenied);
1585
+ }
1540
1586
  const systemChannels = await this._getChannels();
1541
1587
  const userChannel = systemChannels.find((channel) => channel.id === channelId);
1542
1588
  if (userChannel) {
@@ -1544,7 +1590,7 @@ class FDC3ModuleBase {
1544
1590
  }
1545
1591
  try {
1546
1592
  const sessionContextGroup = await this.client.joinSessionContextGroup(channelId);
1547
- return (0, utils_1$2.buildAppChannelObject)(sessionContextGroup);
1593
+ return fdc3Factory(sessionContextGroup);
1548
1594
  }
1549
1595
  catch (error) {
1550
1596
  console.error(error.message);
@@ -1694,6 +1740,7 @@ Object.defineProperty(fdc31_2, "__esModule", { value: true });
1694
1740
  exports.Fdc3Module = fdc31_2.Fdc3Module = void 0;
1695
1741
  const utils_1$1 = utils$2;
1696
1742
  const fdc3_common_1$1 = fdc3Common;
1743
+ const fdc3_channels_1_2_1 = fdc3Channels1_2;
1697
1744
  /**
1698
1745
  * @version 1.2
1699
1746
  * The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
@@ -1876,7 +1923,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
1876
1923
  * @tutorial fdc3.getOrCreateChannel
1877
1924
  */
1878
1925
  async getOrCreateChannel(channelId) {
1879
- return super.getOrCreateChannel(channelId);
1926
+ return super.getOrCreateChannel(channelId, fdc3_channels_1_2_1.createV1Channel);
1880
1927
  }
1881
1928
  /**
1882
1929
  * 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.
@@ -1908,6 +1955,7 @@ const utils_1 = utils$2;
1908
1955
  const InteropClient_1 = InteropClient$1;
1909
1956
  const utils_2 = utils$1;
1910
1957
  const PrivateChannelClient_1 = PrivateChannelClient$1;
1958
+ const fdc3_channels_2_0_1 = fdc3Channels2_0;
1911
1959
  /**
1912
1960
  * @version 2.0
1913
1961
  * The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
@@ -2159,7 +2207,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
2159
2207
  * @tutorial fdc3.getOrCreateChannel
2160
2208
  */
2161
2209
  async getOrCreateChannel(channelId) {
2162
- return super.getOrCreateChannel(channelId);
2210
+ return super.getOrCreateChannel(channelId, fdc3_channels_2_0_1.createV2Channel);
2163
2211
  }
2164
2212
  /**
2165
2213
  * 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/fdc3-api",
3
- "version": "43.100.90",
3
+ "version": "43.100.92",
4
4
  "description": "OpenFin fdc3 module utilities and types.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "private": false,