With the latest version of our Agent, Connectifi has moved it’s API to the FDC3 2.0 interface. Going forward all of our interfaces will use FDC3 2.x and we want to share with you the good parts that we’re excited about, what the transition looks like with Connectifi, and some open questions we have for the community.
In FDC3 1.x, APIs were a mix of sync and async. In the 2.0 specification, all APIs are now async and return Promises. This change works really well with Connectifi’s cloud architecture.
With the fully async FDC3 2.0 API, we’ve added robust offline detection. If the connection has dropped, the promise on any FDC3 method will reject with a ‘NoConnectionAvailable’ error. In combination with the Connectifi Agent’s connected/disconnected callbacks, this can be used to build full-featured offline support. For example, providing end user notification, queuing actions, and replay of unsent commands.
Probably the most significant feature of FDC3 2.0 is the long anticipated data response on intents. There has been a placeholder for this feature since the very first version of the FDC3 API, but the mechanism for actually delivering a response from an intent remained elusive to the standard for some time. Intents with data results greatly expand the scope and value of use cases that FDC3 can support. And with the determinism and observability that cloud services provide, Connectifi brings even greater value to these use cases.
Getting the data response from an intent is relatively simple
-- CODE language-js --
const intentResult = await fdc3.raiseIntent('GetSomeData', context);
const theData = await intentResult.getResult();
Moving from 1.x to 2.x of the Connectifi Agent can be done with a few simple steps:
This signature:
-- CODE language-js --
const listener = fdc3.addContextListener('context', () => {});
becomes this:
-- CODE language-js --
const listener = await fdc3.addContextListener('context', () => {});
This pattern:
-- CODE language-js --
const contextHandler = (context)=> {
//do something
};
fdc3.addContextListener('fdc3.instrument', contextHandler);
fdc3.addIntentListener( 'ViewChart', 'fdc3.instrument', contextHandler);
Becomes this:
-- CODE language-js --
const contextHandler = (context) => {
//do something with the context
};
const intentHandler = async(context) => {
//do something
//return void
return;
};
const dataIntentHandler = async(context) => {
//do something
//return ContextData as IntentResolution
return {
type:'sandbox.PriceResult',
...
};
};
fdc3.addContextListener('fdc3.instrument', contextHandler);
fdc3.addIntentListener( 'ViewChart', 'fdc3.instrument', intentHandler);
fdc3.addIntentListener( 'GetPrice', 'fdc3.instrument', dataIntentHandler);
The following API name changes/deprecations happen with 2.0:
note: previously, joinChannel was agnostic to channel type. Technically, you could join an ‘app’ channel as well as a ‘system’ channel. 2.0 makes this behavior more prescriptive.
Some of the changes in 2.0 are big and Connectifi is rolling them out in an incremental manner so we can get full community feedback on use cases as well as the best and safest way to implement. Here are the open questions we currently have that we’d love to get your feedback on.
The findInstance API allows an app to get all of the unique instance identifiers for an App from a appId.
Since appIds are publicly knowable there are some data leakage concerns around this API. Particularly since the method makes it very easy for an app to monitor the usage of other apps in the environment. (note: this is a general concern, more details below). Beyond this, we are unclear on the use cases for an app retrieving the instances of another app. For now, we have opted to return instance data only for the caller’s own appId.
In FDC3 2.0, an intent can return either ContextData or a PrivateChannel instance as the result of its IntentResolution response. As noted above, we have implemented the ContextData part, but are currently holding on private channels. The main reasons are:
FDC3 2.0 adds instance identifiers for applications and a method for getting the metadata for an app from it’s identifier.
While this takes steps towards empowering apps to make some security related decisions at runtime, there are a number of open questions concerning the use of the FDC3 AppIdentifier as a security mechanism:
One final change in FDC3 2.0 is the requirement that all web implementations expose window.fdc3 as a global. In FDC3 1.x, this was a recommendation and de facto standard in desktop container environments, but never a hard requirement.
Implementing the global pattern with Connectifi is simple. However, in order to give the community maximum optionality to application and platform owners, we have chosen to leave the last mile of how the FDC3 API is accessed up to the specific implementation.
Connectifi is committed to making FDC3 as accessible and open as possible. To that end, there are a number of free and/or open source resources we’ve made available to the community.