UPDATE: As the above answer says, it looks like there is a way to intercept the login, detect when it is a proxy, and give the auth details there. I'll leave my original answer, for the background links I found (plus I've not personally tested the proxy auth will work).
I think the answer is "You can't, by design". You give a PAC file to setProxy()
(or use proxyRules
, but that just offers the same options). It seems that they specifically don't allow username/password in PAC files for security. (Though that logic doesn't really apply to using proxyRules
directly, does it.)
This answer suggests setting up an ssh tunnel. You could pre-create one tunnel (one port) for each of your BrowserView objects, and then set localhost and the desired port as the proxy.
The chosen answer on the first link above suggests https://github.com/sjitech/proxy-login-automator which looks like it might that same idea. It seems to be a commandline script, but you should be able to pull out the bits you need and run it in the Electron main process.