Use Proxy config when available#124
Conversation
albinohrn
left a comment
There was a problem hiding this comment.
Hello Erik!
Thanks for your contribution!
Would you mind providing a brief description of your PR it would give us some valuable background to why this change is important to you.
| body: formData, | ||
| headers: formData.getHeaders({ | ||
| var options = { | ||
| method: 'POST', |
There was a problem hiding this comment.
Your code formatting is a bit off from the rest of the file. We use Prettier it's a simple tool that formats the files automatically and let you focus on more important stuff. :)
There was a problem hiding this comment.
Jag måste tyvärr använda mig av online redigeringen så är lite begränsad till vad jag kan göra. Får titta mer på om jag kan ha någon vettigt dev miljö för detta.
| } | ||
| if (process.env.HTTPS_PROXY) { | ||
| console.log(`using ${process.env.HTTPS_PROXY} as HTTPS_PROXY`) | ||
| const HttpsProxyAgent = require('https-proxy-agent'); |
There was a problem hiding this comment.
I would suggest we add this as an explicit dependency now that it is used directly. Makes it more obvious that we actually use it.
There was a problem hiding this comment.
Vi la den där pga lazy loading, men du har rätt.
There was a problem hiding this comment.
Det är helt ok med lazy-loading. Det jag tänkte på var att den bör specificeras i package.json, nu är det med som ett transient beroende.
This enables you to use sign.js behind a WebProxy, which is sadly necessary in many "Enterprise" environments. This will automatically use the ENV variable HTTPS_PROXY that is standard for e.g. Curl and other unix utils. This should be compatible with MacOS, Linux and Windows environments with a posix like shell.
I have not tested this with a Authorization header against the Sitevision sign server, nor against the proxy. There is not support for proxy Authentication AFAIK at this time.
sign.js is impossible to use behind a WebProxy unless this is merged.
There are many things that could be improved upon here, e.g. doing a liveness check against the signing server, checking for errors that the proxy might introduce, or just making the client responsible for the signing. These are not in scope of this PR.