Private Variables in NPM Package
So I’m almost ready to release version 1.0.0 (working my way there :D) of my REPLAPI.it package but I need to know (if it’s even possible) how to make variables that cannot be tampered with by someone using a package. For example, is I have an array with secrets someone can change the array’s contents and if I have .env keys someone can just redefine them because it wouldn’t work. Any ideas?
Anyways yeah you don't use global variables in packages, and you also use module exports to export necessary functions. If you need a whitelist then no problem, the user can pass in their whitelist as a parameter.
@RayhanADev you're afraid a user can "change" the whitelist?? wdym, when you install a package, it essentially clones the files and adds it to your project, it doesn't link directly to the source and users aren't able to edit the source code silly goose.
If you're worried about private information then why tf are you storing private information in a package.
Nope, once someone HAS, they HAS. Just make the user pass them in themselves.
Anyways, why are you making a replapi.it package lol was mine not good enough xd
how is that even an issue
cough cough module exports
also don't use global variables in your package, just define everything in a function as well