Npm package inside Javascript policy

Hi all,

I have a Javascript policy and currently it calls a javascript file, that is uploaded as a resource and is referenced as jsc://prepare-error-variables.js.

Now I want to make this file global and available for all proxies. I’ve tried shared flow, but it applies future changes immediately in runtime. And I need to be able to deploy changes for only one proxy at a time and on demand.

One idea is to extract prepare-error-variables.js to npm package and use it inside javascript policy. So if a proxy needs the latest version of that file, it can update the package.

The problem is that I have an error, when I reference the file in Javascript policy like this: node://prepare-error-variables.js (it only accepts jsc files).

Could you please suggest any workaround to using npm package inside JS policy? Or is there any way to share a file among proxies, without introducing runtime dependency as with the use of shared flow?

Hi @Kirill Ianchuk,

How about versioning your shared flows, you can have The first version of the javascript file in shared flow named FC-Shared-JS-v1 while a later version 2 in a shared flow named FC-Shared-JS-v2, and then just update the of your Flow Callout policies as you need in your api proxies to point to the needed version.

Hope it helps

1 Like

Good idea! But is there an ability to force developers to create a new version of a shared flow every time and not to modify an existing version?

You can protect previous versions with RBAC using the management api

Thanks, I’ll try that