I am exporting a js module via module.exports. The caller function requires this module and calls the exported functions.
Code looks something likes this:
file1.js
module.exports = {
Info: showInfo
}
function showInfo(param1, callback) {
callback(null, getInfo(param1))
}
let secretCode = 'xyz';
function getInfo(p1) {
return EncodeInfo(param1, secretCode);
}
function EncodeInfo(p2, p3) {
//some code
}
file2.js
var f1 = require('./file1');
f1.Info("some value");
Now the thing is that file2.js is provided by the customer at runtime and code gets deployed to the server. Server entry point functions call an entry function in file2.js. file2.js just has access to core node libraries, a logging functionality and request module.
I need to hide whats written inside file1.js. Customer can do something like this to see the code
console.log(f1.Info.toString());
//this will print following
/*
function showInfo(param1, callback){
callback(null, getInfo(param1))
}
*/
This is ok, as getInfo()
code is hidden. Also, other private functions and variables are hidden. Also to mention that customer cannot install any other node modules and only provides file2.js
Please note that I cannot control what he is writing in file2.js, neither I can scan before merging the file2.js with rest of the code.
Question 1: The question is simply that is my assumption correct? Or is there any way where he can see the rest of the code implementation or any other details of imported(require) modules? Maybe through prototype?
Question 2: Is there any way he can see the details of servers entry point function implementation. The customer does have access to process and hence process.env, but that is ok. I am more bothered about other file's code.