HACKER Q&A
📣 01-_-

How do I hide sensitive parts of my JavaScript code?


How do I hide sensitive parts of my JavaScript code?


  👤 dlcarrier Accepted Answer ✓
Here's a good article about different methods for accessing and storing secrets in JavaScript: https://thenewstack.io/best-practices-for-storing-access-tok...

It's important to keep in mind that any secrets are the end users' secrets and not your secrets. Don't ever send your private keys to end users. You'll need to either act as a middle man between the end user and any third party, or have the third party generate user-specific tokens that only grant access to resources you have specifically allocated to that user.

If you can give some details of what the page will be doing, I may be able to help you with the general architecture of the data flow.


👤 not_your_vase
Keep it server side, and solve your problem without client side Javascript.

Otherwise you don't.



👤 doctor_radium
You can't have the user download something and then try to pretend they didn't download it. If it's that sensitive, it's gotta be server side.

👤 delanyoyoko
By using a Nodejs backend. Mostly that's where the business logic goes.

👤 bryanrasmussen
by definition any code that is not compiled that is delivered to a client application will be less secure than code that is run completely under your control, you say it needs to be on the client side but I have to admit I have a hard time envisioning where code that is sensitive absolutely HAS to be run in the client (I mean truly sensitive, like validating that this is really your bank account, as opposed to just code you don't want others to take and use)

👤 genezeta
What is sensitive about it?