ResourceReference from external javascript

I need to pass the URL of non public files to a javascript component.
I’m using ResourceReference but the given URL is prefixed with app://.
When I use the path replacing app:/ with my bas domain+path the files are accessible.
But what is the best practice to convert app resources URL to clean “external” urls ?

FileResource thumbResource = ....
setResource(thumbResource.getSourceFile().getName(), thumbResource);
ResourceReference rrThumb = ResourceReference.create(thumbResource, this, thumbResource.getSourceFile().getName());
rrThumb.getURL(); // => app://<...>

AbstractJavaScriptCompinent extends AbstractComponent, which gives it getResource() and setResource(String key, Resource resource) methods (infact inherited via AbstractClientConnector) What setResource(…) does is that it adds the resource to SharedState.resources which a HashMap. So if you need to access resources assosiated to your component in the JavaScript, you should be able to read them from SharedState.