TL;DR
How to download/save a file using Angular and JWT authentication without leaving a token trail in the browser?
My Angular/Node app is secured over HTTPS and uses JWT for authentication. The JWT is stored in sessionStorage and passed in the Authorization header field for all AJAX requests to the server.
I need functionality in the app to download a file so that it's automatically saved by the browser (or a popup displayed where to save etc.).
It should work ideally in any browser that can run Angular.
I have looked at the following:
AJAX requests. This doesn't work because of inherent security measures preventing a browser from saving a file locally.
Pass the JWT in a Cookie - cookies are something I want to avoid using, hence the reason for using sessionStorage.
Pass the JWT in a query string but this means it will be logged in the server logs, and more importantly can be seen in browser history.
iframe that contains a form that POSTS the data. Can't set a header with this method.
Any other options?