Replies: 4 comments 1 reply
-
Just to expand upon the above, one thing that's probably worth noting for the specific case of browser-based solutions is that even if you take care to freeze your object and make its methods non-configurable and non-writable, you don't have any guarantee that the underlying JavaScript / HTML5 APIs it relies upon are actually the (original) native versions. Since JavaScript / HTML5 APIs are not immutable, it's possible for the following to happen:
This was always possible for browser APIs by reassigning existing properties at runtime to use new functions. However, in modern JavaScript there is also the option of using the Proxy API - which I think makes it impossible to tell whether a native function was replaced or not i.e. because it will still report itself as Given the above, I now think any potential recommendations in this area intended to cover browser-based implementations would probably require quite a bit of discussion in order for it to be clear on the exact scope of the recommendation. By contrast, I believe the case of desktop container implementations is probably more straightforward (relatively speaking) in the sense that context isolation can be used to prevent native browser APIs being overridden. That is to say, a script running within an application in a desktop container could still override a JavaScript / HTML5 API method, but if an FDC3 API method exposed in that environment relied upon a JavaScript API method then it should actually use the (untampered) isolated version of that JavaScript API method. |
Beta Was this translation helpful? Give feedback.
-
Returning to my original comment about the behaviour with
My example of changing I was curious to see how other implementations handle the exposing of their FDC3 API. Looking at FDC3-Sail, I noticed that it prevents one from overwriting the method implementations on From what I can see, FDC3-Sail uses context isolation and leverages I believe the relevant part of the Electron docs is this: For comparison, I also came across a reference to an 'old way' of handling the exposing of client-side API objects in Electron by assigning to the It sounds like
Since desktop containers are a bigger part of the FDC3 picture than browser-based containers, I thought this info was perhaps relevant to the discussion of this issue. However, I should heavily caveat the above by stating that I'm not an Electron developer by any means - so I'd be happy to hear from someone with Electron experience who could either confirm or refute my findings above. |
Beta Was this translation helpful? Give feedback.
-
HI @novavi,
First off, at the time of writing, there are no browser-based FDC3 Desktop Agents because at present there is no way to inject the FDC3 API without including a vendor library containing one. As per the discussion in the meeting, the inclusion of a vendor library to provide the Desktop Agent Implementation is against both the letter and the spirit of FDC3 as it implies adoption of a particular Desktop Agent implementation (Platform Provider) by an application. The closest you could get is a browser-extension (that the user has to install) which injects the API. This is something we could look to solve in a future FDC3 version - perhaps utilizing the FDC3 NPM module as a vendor-independent library to import which then attempts to discover a DA running in the browser. But as of today, any purely browser-based solution cannot comply with FDC3 - and any proliferation of them is likely to cause exactly the problems that you identify. On to your main point. JavaScript does indeed allow you to override or monkey patch functions (for example I can monkey patch the
|
Beta Was this translation helpful? Give feedback.
-
For anyone reading this who somehow didn't see the other issue, it's worth noting that one of the items raised above (FDC3 npm package to support runtime-based discovery / selection of DA) has now become part of a much wider discussion about FDC3 For Web browsers #896 |
Beta Was this translation helpful? Give feedback.
-
One of the items touched upon briefly in the Nov 30th Standard WG meeting was the use of FDC3 within a web browser. One of the scenarios discussed was that when an app using FDC3 needed to be run in a browser environment, it must include an FDC3 implementation in either its main JS bundle or a preloaded JS bundle. (This is ignoring the separate case of things like Chrome Extensions, which are problematic for browser-based enterprise app deployment from an InfoSec perspective.)
It was mentioned in the meeting that if such an app is run within a container that already supports FDC3 then it is inappropriate / dangerous for the app to overwrite the container's FDC3 implementation that was originally exposed via
window.fdc3
.I have spent some time recently working on a proprietary (rough) FDC3 implementation which is browser-based (i.e. handling intents and channel broadcasts across iframe windows and external windows locally, using the native browser APIs that support cross-origin comms). In the course of this work, when I tested some of my apps in different containers I noticed that the FDC3 Desktop Agents in both OpenFin and Finsemble allow one to overwrite the FDC3 method implementations on
window.fdc3
, and even allow one to replace the wholewindow.fdc3
object completely. I haven't (yet) tested this issue in other other desktop containers.It seems to me that it would be worth considering whether to add a recommendation (SHOULD) or perhaps even a requirement (MUST) in the next version of the FDC3 spec to cover this issue.
In my browser-based FDC3 Agent implementation I take the following approach:
window.fdc3
object. If it exists (i.e. because the app that included my FDC3 Agent script is currently running in a desktop container instead of a browser) then I completely skip the bootstrapping and installation of my FDC3 Agent and leavewindow.fdc3
as-is.fdc3
object, I invokeObject.freeze(fdc3)
in order to prevent the object's methods from subsequently being deleted or reassigned by external code at runtime. I believe a shallow freeze should be sufficient here so long as the immediate properties of thefdc3
object are all functions (rather than nested objects).fdc3
object viawindow.fdc3
, I do so by usingObject.defineProperty(..)
rather than by using a simplewindow.fdc3 = fdc3
assignment. This preventswindow.fdc3
subsequently being deleted or reassigned by external code at runtime.I'm not sure of the exact mechanisms people are using to expose
fdc3
objects viawindow.fdc3
in Electron-based desktop implementations, but purely for reference this is the rough flow I'm using for a browser-based solution:I can't see a valid reason for an app to be allowed to overwrite the FDC3 Agent that has been provided to it by the environment the app is running in. Therefore I'd be interested to hear other people's thoughts are on this installation / overwriting issue, what they are currently doing, and whether or not this is something people think should perhaps be covered in the next version of the spec.
Beta Was this translation helpful? Give feedback.
All reactions