@interopio/fdc3-web-bridge 1.1.1-beta.0 → 1.3.0

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Tick42
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 interop.io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @interopio/fdc3-web-bridge
2
+
3
+ io.Connect implementation of the [FDC3 Web Connection Protocol](https://fdc3.finos.org/docs/api/specs/webConnectionProtocol) used internally by the **io.Connect Browser** platform. Enables FDC3 client apps that use the `@finos/fdc3` library to acquire a `DesktopAgent` instance via the `getAgent()` method.
4
+
5
+ > ⚠️ *Note that the recommended method for acquiring access to the FDC3 API in your FDC3 apps that are part of an **io.Connect Browser** project is to use the `@interopio/fdc3` library instead.*
package/changelog.md CHANGED
@@ -1,2 +1,8 @@
1
- 1.0.0
1
+ 1.3.0
2
+ feat: io.Connect Browser 4.3
3
+ 1.2.0
4
+ feat: io.Connect Browser 4.2
5
+ 1.1.0
6
+ feat: io.Connect Browser 4.1
7
+ 1.0.0
2
8
  feat: Initial release with io.Connect Browser 4.0
@@ -1577,6 +1577,18 @@ Decoder.lazy;
1577
1577
 
1578
1578
  const nonEmptyStringDecoder$4 = string().where((s) => s.length > 0, "Expected a non-empty string");
1579
1579
  const nonNegativeNumberDecoder = number().where((num) => num >= 0, "Expected a non-negative number");
1580
+ const regexDecoder = anyJson().andThen((value) => {
1581
+ return value instanceof RegExp ? anyJson() : fail(`expected a regex, got a ${typeof value}`);
1582
+ });
1583
+ const urlDecoder = nonEmptyStringDecoder$4.andThen((url) => {
1584
+ try {
1585
+ new URL(url);
1586
+ return nonEmptyStringDecoder$4;
1587
+ }
1588
+ catch {
1589
+ return fail("Should be a valid URL");
1590
+ }
1591
+ });
1580
1592
 
1581
1593
  const intentDefinitionDecoder = object({
1582
1594
  name: nonEmptyStringDecoder$4,
@@ -1903,7 +1915,9 @@ class FDC3Service {
1903
1915
  const decoders$1 = {
1904
1916
  common: {
1905
1917
  nonEmptyStringDecoder: nonEmptyStringDecoder$4,
1906
- nonNegativeNumberDecoder
1918
+ nonNegativeNumberDecoder,
1919
+ regexDecoder,
1920
+ urlDecoder
1907
1921
  },
1908
1922
  fdc3: {
1909
1923
  allDefinitionsDecoder,
@@ -1993,7 +2007,7 @@ const wcp1HelloPayloadDecoder = object$1({
1993
2007
  channelSelector: optional$1(boolean$1()),
1994
2008
  fdc3Version: nonEmptyStringDecoder$3,
1995
2009
  identityUrl: nonEmptyStringDecoder$3,
1996
- resolver: optional$1(boolean$1())
2010
+ intentResolver: optional$1(boolean$1())
1997
2011
  });
1998
2012
  const wcp1HelloMetaDecoder = object$1({
1999
2013
  connectionAttemptUuid: nonEmptyStringDecoder$3,
@@ -2833,13 +2847,14 @@ class BridgeController {
2833
2847
  }
2834
2848
  handleHelloConnectionRequest(source, origin, data) {
2835
2849
  if (this._messageChannel) {
2836
- console.warn(`${WCPMessageTypes.WCP1Hello} already heard. Message channel port created`);
2850
+ this.logMessage({ level: "warn", message: `${WCPMessageTypes.WCP1Hello} already heard. Message channel port created` });
2837
2851
  return;
2838
2852
  }
2853
+ this.logMessage({ level: "info", message: `Received ${WCPMessageTypes.WCP1Hello} request: ${JSON.stringify(data)} from origin: ${origin}` });
2839
2854
  const decodedRequest = wcp1HelloDecoder.run(data);
2840
2855
  if (!decodedRequest.ok) {
2841
2856
  const errorMsg = `Received invalid '${WCPMessageTypes.WCP1Hello}' request: ${JSON.stringify(data)}. Reason: ${decodedRequest.error.message} at ${decodedRequest.error.at}`;
2842
- console.error(errorMsg);
2857
+ this.logMessage({ level: "error", message: errorMsg });
2843
2858
  source.postMessage({ error: "MalformedMessage", message: errorMsg }, origin);
2844
2859
  return;
2845
2860
  }
@@ -2850,9 +2865,9 @@ class BridgeController {
2850
2865
  window.removeEventListener("message", this._globalMessageHandler);
2851
2866
  }
2852
2867
  async handlePortMessage(event) {
2853
- this.logger?.info(`Received port message with data: ${JSON.stringify(event.data)}}`);
2868
+ this.logMessage({ level: "info", message: `Received port message with data: ${JSON.stringify(event.data)}` });
2854
2869
  if (!this._connectionCompleted && event.data?.type !== WCPMessageTypes.WCP6Goodbye && event.data.type !== WCPMessageTypes.WCP4ValidateAppIdentity) {
2855
- console.warn("Web Connection Protocol not completed yet. Ignoring message");
2870
+ this.logMessage({ level: "warn", message: "Web Connection Protocol not completed yet. Ignoring message" });
2856
2871
  return;
2857
2872
  }
2858
2873
  if (event.data?.type === WCPMessageTypes.WCP4ValidateAppIdentity) {
@@ -2862,33 +2877,36 @@ class BridgeController {
2862
2877
  return this.handleGoodbyeRequest(event.data);
2863
2878
  }
2864
2879
  const result = await this.ioc.domainsController.handleMessage(event.data);
2865
- this.logger?.info(`Sending response message: ${JSON.stringify(result)}`);
2880
+ this.logMessage({ level: "info", message: `Sending response message: ${JSON.stringify(result)}` });
2866
2881
  this.sendMessage(result);
2867
2882
  }
2868
2883
  async handleAppIdentityValidationRequest(data) {
2869
2884
  const decodedRequest = wcp4ValidateAppIdentityDecoder.run(data);
2870
2885
  if (!decodedRequest.ok) {
2871
2886
  const errorMsg = `Received invalid '${WCPMessageTypes.WCP4ValidateAppIdentity}' request: ${JSON.stringify(data)}. Reason: ${decodedRequest.error.message} at ${decodedRequest.error.at}`;
2872
- console.error(errorMsg);
2887
+ this.logMessage({ level: "error", message: errorMsg });
2873
2888
  this.sendMessage({ error: "MalformedMessage", message: errorMsg });
2874
2889
  return;
2875
2890
  }
2876
2891
  const { actualUrl, identityUrl } = data.payload;
2877
2892
  await this.ioController.initializeLibs();
2878
2893
  this.logger = this.ioController.io?.logger.subLogger("bridge.controller");
2879
- this.logger?.info(`IOBrowser and FDC3 libs are initialized. Received ${data.type} request: ${JSON.stringify(data)}`);
2894
+ this.logMessage({ level: "info", message: `IOBrowser and FDC3 libs are initialized. Received ${data.type} request: ${JSON.stringify(data)}` });
2880
2895
  const validationResult = this.ioController.validateIdentity({ actualUrl, identityUrl, helloMsgOrigin: this._helloMessageOrigin });
2881
2896
  if (!validationResult.isValid) {
2882
- this.logger?.info(`App validation failure. Reason: ${validationResult.message}`);
2883
2897
  this.sendValidationFailure(data.meta.connectionAttemptUuid, validationResult.message);
2884
2898
  this.cleanSetup();
2885
2899
  return;
2886
2900
  }
2887
2901
  await this.sendValidationSuccess(data.meta.connectionAttemptUuid, validationResult.appId);
2888
- this.logger?.info(`App validation is successful. Connection is completed`);
2902
+ this.logMessage({ level: "info", message: `App validation is successful. Connection is completed` });
2889
2903
  this._connectionCompleted = true;
2890
2904
  }
2891
2905
  sendHandshake(source, origin, data) {
2906
+ this.ioc.uiConfig = {
2907
+ isChannelSelectorEnabled: !!data.payload.channelSelector,
2908
+ isIntentResolverEnabled: !!data.payload.intentResolver,
2909
+ };
2892
2910
  const handshakeMsg = {
2893
2911
  type: WCPMessageTypes.WCP3Handshake,
2894
2912
  meta: {
@@ -2896,12 +2914,13 @@ class BridgeController {
2896
2914
  timestamp: new Date()
2897
2915
  },
2898
2916
  payload: {
2899
- channelSelectorUrl: true,
2900
- intentResolverUrl: true,
2901
- fdc3Version: window.fdc3Info.standardVersion,
2917
+ channelSelectorUrl: this.ioc.uiConfig.isChannelSelectorEnabled,
2918
+ intentResolverUrl: this.ioc.uiConfig.isIntentResolverEnabled,
2919
+ fdc3Version: window.fdc3Info?.standardVersion,
2902
2920
  }
2903
2921
  };
2904
2922
  const transfer = this._messageChannel ? [this._messageChannel.port2] : undefined;
2923
+ this.logMessage({ level: "info", message: `Sending ${WCPMessageTypes.WCP3Handshake} message: ${JSON.stringify(handshakeMsg)} to origin: ${origin}` });
2905
2924
  source.postMessage(handshakeMsg, origin, transfer);
2906
2925
  }
2907
2926
  sendValidationFailure(attempt, errorMsg) {
@@ -2915,7 +2934,7 @@ class BridgeController {
2915
2934
  message: errorMsg
2916
2935
  }
2917
2936
  };
2918
- console.warn(`App Identity Validation failed. Reason: ${errorMsg}`);
2937
+ this.logMessage({ level: "error", message: `App validation failure. Reason: ${errorMsg}. Sending ${WCPMessageTypes.WCP5ValidateAppIdentityFailedResponse} message: ${JSON.stringify(validationFailureMsg)}` });
2919
2938
  this.sendMessage(validationFailureMsg);
2920
2939
  }
2921
2940
  async sendValidationSuccess(attempt, appId) {
@@ -2936,6 +2955,7 @@ class BridgeController {
2936
2955
  implementationMetadata
2937
2956
  }
2938
2957
  };
2958
+ this.logMessage({ level: "info", message: `App Identity Validation successful. Sending ${WCPMessageTypes.WCP5ValidateAppIdentityResponse} message: ${JSON.stringify(validationSuccessMsg)}` });
2939
2959
  this.sendMessage(validationSuccessMsg);
2940
2960
  }
2941
2961
  cleanSetup() {
@@ -2945,20 +2965,29 @@ class BridgeController {
2945
2965
  this._connectionCompleted = false;
2946
2966
  this._messageChannel = undefined;
2947
2967
  if (window.__karma__) {
2948
- this.configure();
2949
- this.ioController._initializationStarted = false;
2968
+ this.testCleanupSetup();
2950
2969
  }
2951
2970
  }
2971
+ testCleanupSetup() {
2972
+ this.ioc.resetState();
2973
+ this.ioc.bridgeController.configure();
2974
+ }
2952
2975
  handleGoodbyeRequest(data) {
2953
2976
  const decodedRequest = wcp6GoodbyeRequestDecoder.run(data);
2954
2977
  if (!decodedRequest.ok) {
2955
2978
  const errorMsg = `Received invalid '${WCPMessageTypes.WCP6Goodbye}' request: ${JSON.stringify(data)}. Reason: ${decodedRequest.error.message} at ${decodedRequest.error.at}`;
2956
- console.error(errorMsg);
2979
+ this.logMessage({ level: "error", message: errorMsg });
2957
2980
  this.sendMessage({ error: "MalformedMessage", message: errorMsg });
2958
2981
  return;
2959
2982
  }
2960
2983
  this.cleanSetup();
2961
2984
  }
2985
+ logMessage({ level, message }) {
2986
+ if (this.logger) {
2987
+ return this.logger[level](message);
2988
+ }
2989
+ console[level](message);
2990
+ }
2962
2991
  }
2963
2992
 
2964
2993
  class DomainsController {
@@ -2987,14 +3016,12 @@ class DomainsController {
2987
3016
  this.logger?.error(`Cannot find domain for message type: ${data.type}`);
2988
3017
  return { error: "MalformedMessage", message: `Received unsupported message type: ${data.type}` };
2989
3018
  }
2990
- this.logger?.info(`Sending request ${data.type} to domain '${domain.name}'`);
2991
3019
  const result = await domain.controller.handleControl(data);
2992
3020
  const decodedResultTypeResponse = responseMessageTypeDecoder.run(result.type);
2993
3021
  if (!decodedResultTypeResponse.ok) {
2994
3022
  this.logger?.error(`Received invalid response type: ${JSON.stringify(data)}`);
2995
3023
  return { error: "MalformedMessage", message: `Received invalid response message type: ${decodedResultTypeResponse.error.message}` };
2996
3024
  }
2997
- this.logger?.info(`Returning domain result: ${JSON.stringify(result)}`);
2998
3025
  return result;
2999
3026
  }
3000
3027
  setupDomains() {
@@ -3348,6 +3375,7 @@ const raiseIntentResultResponseDecoder = object$1({
3348
3375
  class IntentsController {
3349
3376
  sendBridgeMessage;
3350
3377
  addPrivateChannel;
3378
+ isIntentResolverEnabled;
3351
3379
  logger;
3352
3380
  listenersCollection = {};
3353
3381
  intentResolutionsCollection = {};
@@ -3363,9 +3391,10 @@ class IntentsController {
3363
3391
  raiseIntentRequest: { requestType: "raiseIntentRequest", requestDecoder: raiseIntentRequestDecoder, responseType: "raiseIntentResponse", responseDecoder: raiseIntentResponseDecoder, execute: this.handleRaiseIntentRequest.bind(this) },
3364
3392
  raiseIntentResultRequest: { requestType: "raiseIntentResultRequest", requestDecoder: raiseIntentResultRequestDecoder, responseType: "raiseIntentResultResponse", responseDecoder: raiseIntentResultResponseDecoder, execute: this.handleRaiseIntentResultResponse.bind(this) },
3365
3393
  };
3366
- constructor(sendBridgeMessage, addPrivateChannel, logger) {
3394
+ constructor(sendBridgeMessage, addPrivateChannel, isIntentResolverEnabled, logger) {
3367
3395
  this.sendBridgeMessage = sendBridgeMessage;
3368
3396
  this.addPrivateChannel = addPrivateChannel;
3397
+ this.isIntentResolverEnabled = isIntentResolverEnabled;
3369
3398
  this.logger = logger;
3370
3399
  }
3371
3400
  async handleControl(request) {
@@ -3484,7 +3513,10 @@ class IntentsController {
3484
3513
  intentEventResultPromise.resolve(payload.intentResult);
3485
3514
  return {};
3486
3515
  }
3487
- async handleRaiseIntentForContextRequest({ meta, payload }) {
3516
+ async handleRaiseIntentForContextRequest({ meta, payload, type }) {
3517
+ if (this.isIntentResolverEnabled && !payload.app) {
3518
+ return this.handleRaiseIntentForContextRequestWithResolver({ payload, meta, type });
3519
+ }
3488
3520
  const intentResolution = await window.fdc3?.raiseIntentForContext(payload.context, payload.app);
3489
3521
  if (!intentResolution) {
3490
3522
  return { error: "IntentDeliveryFailed" };
@@ -3499,7 +3531,24 @@ class IntentsController {
3499
3531
  });
3500
3532
  return { intentResolution: intentResolutionToReturn };
3501
3533
  }
3502
- async handleRaiseIntentRequest({ payload, meta }) {
3534
+ async handleRaiseIntentForContextRequestWithResolver({ payload, meta, type }) {
3535
+ const appIntents = await window.fdc3?.findIntentsByContext(payload.context);
3536
+ if (!appIntents || !appIntents.length) {
3537
+ return { error: "NoAppsFound" };
3538
+ }
3539
+ const allAvailableHandlers = appIntents.map((intent) => intent.apps).flat();
3540
+ if (allAvailableHandlers.length > 1) {
3541
+ this.logger?.info(`Multiple apps found for context type '${payload.context.type}'. Requesting user to select app using the Intent Resolver UI. Apps: ${JSON.stringify(allAvailableHandlers)}`);
3542
+ return { appIntents };
3543
+ }
3544
+ const updatedPayload = { ...payload, app: allAvailableHandlers[0] };
3545
+ this.logger?.info(`Only one app found to handle context type '${payload.context.type}'. Proceeding to raise intent to app: '${updatedPayload.app}'`);
3546
+ return this.handleRaiseIntentForContextRequest({ type, meta, payload: updatedPayload });
3547
+ }
3548
+ async handleRaiseIntentRequest({ payload, meta, type }) {
3549
+ if (this.isIntentResolverEnabled && !payload.app) {
3550
+ return this.handleRaiseIntentRequestWithResolver({ payload, meta, type });
3551
+ }
3503
3552
  const intentResolution = await window.fdc3?.raiseIntent(payload.intent, payload.context, payload.app);
3504
3553
  if (!intentResolution) {
3505
3554
  return { error: "IntentDeliveryFailed" };
@@ -3514,6 +3563,19 @@ class IntentsController {
3514
3563
  });
3515
3564
  return { intentResolution: intentResolutionToReturn };
3516
3565
  }
3566
+ async handleRaiseIntentRequestWithResolver({ payload, meta, type }) {
3567
+ const appIntent = await window.fdc3?.findIntent(payload.intent, payload.context);
3568
+ if (!appIntent || !appIntent.apps.length) {
3569
+ return { error: "NoAppsFound" };
3570
+ }
3571
+ if (appIntent.apps.length > 1) {
3572
+ this.logger?.info(`Multiple apps found for intent '${payload.intent}'. Requesting user to select app using the Intent Resolver UI. Apps: ${JSON.stringify(appIntent.apps)}`);
3573
+ return { appIntent };
3574
+ }
3575
+ const updatedPayload = { ...payload, app: appIntent.apps[0] };
3576
+ this.logger?.info(`Only one app found to handle intent. Proceeding to raise intent to app: '${updatedPayload.app}'`);
3577
+ return this.handleRaiseIntentRequest({ type, meta, payload: updatedPayload });
3578
+ }
3517
3579
  async handleRaiseIntentResultResponse({ payload, meta }) {
3518
3580
  this.logger?.info(`handleRaiseIntentResultResponse called with payload: ${JSON.stringify(payload)} and meta: ${JSON.stringify(meta)}`);
3519
3581
  const intentResolution = await this.intentResolutionsCollection[meta.requestUuid];
@@ -3526,8 +3588,8 @@ class IntentsController {
3526
3588
  this.logger?.info(`Received intent result: ${JSON.stringify(result)}`);
3527
3589
  if (!result) {
3528
3590
  const intentStr = payload.intent ? "intent '" + payload.intent + "'" : "";
3529
- const contextStr = payload.context ? "context type '" + payload.context + "'" : "";
3530
- this.logger?.info(`Intent result is void for ${intentStr}${contextStr} and requestUuid: ${meta.requestUuid}`);
3591
+ const contextStr = payload.context ? "context type '" + payload.context.type + "'" : "";
3592
+ this.logger?.info(`Intent result is void for ${intentStr}, ${contextStr} and requestUuid: ${meta.requestUuid}`);
3531
3593
  return { intentResult: undefined };
3532
3594
  }
3533
3595
  const intentResult = this.extractRaiseIntentResult(result);
@@ -3595,6 +3657,22 @@ class IoC {
3595
3657
  _channelsController;
3596
3658
  _intentsController;
3597
3659
  _applicationsController;
3660
+ _uiConfig;
3661
+ resetState() {
3662
+ this._bridgeController = undefined;
3663
+ this._ioController = undefined;
3664
+ this._domainsController = undefined;
3665
+ this._channelsController = undefined;
3666
+ this._intentsController = undefined;
3667
+ this._applicationsController = undefined;
3668
+ this._uiConfig = undefined;
3669
+ }
3670
+ get uiConfig() {
3671
+ return this._uiConfig;
3672
+ }
3673
+ set uiConfig(value) {
3674
+ this._uiConfig = value;
3675
+ }
3598
3676
  get bridgeController() {
3599
3677
  if (!this._bridgeController) {
3600
3678
  this._bridgeController = new BridgeController(this.ioController, this);
@@ -3624,7 +3702,7 @@ class IoC {
3624
3702
  }
3625
3703
  get intentsController() {
3626
3704
  if (!this._intentsController) {
3627
- this._intentsController = new IntentsController(this.bridgeController.sendMessage.bind(this.bridgeController), this.channelsController.addPrivateChannel.bind(this.channelsController), this.ioController.getLogger("intents.controller"));
3705
+ this._intentsController = new IntentsController(this.bridgeController.sendMessage.bind(this.bridgeController), this.channelsController.addPrivateChannel.bind(this.channelsController), this.uiConfig.isIntentResolverEnabled, this.ioController.getLogger("intents.controller"));
3628
3706
  }
3629
3707
  return this._intentsController;
3630
3708
  }
@@ -3636,7 +3714,7 @@ class IoC {
3636
3714
  }
3637
3715
  }
3638
3716
 
3639
- var version = "1.1.1-beta.0";
3717
+ var version = "1.3.0";
3640
3718
 
3641
3719
  window.fdc3WebBridgeInfo = {
3642
3720
  version