Reputation: 5012
Part of my npm module (typescript) is using axios to make web requests. One of the possible endpoints is using certificates for authentication. For this scenario I'm passing new https.Agent
to axios to send the certificates info. All is working fine if the module is used from within Node app.
The problem is if I try and use my module in browser environment. When in browser https
module do not exists and I'm unable to use my module.
https
module in the browser?https
be bundled within my module somehow? Do I have to use some bundler in this case (like Rollup) to build the typescript module?Upvotes: 4
Views: 3418
Reputation: 2448
You can't do it. Most browsers support TLS Client Certificate authentication, but it works differently: the user is presented with a window and asked to select a certificate to authenticate with. It's a similar story to how cookies work - you can't easily manipulate HttpOnly cookies from JS on the client side.
If you want TLS client auth in the browser, you are at the browser vendor's mercy.
Upvotes: 3