ProtectJS
ProtectJS copied to clipboard
Cant protect prototype and instances together.
ProtectJS can not protect the prototype and all of its instances at the same time. When protect prototype and an instance separately, the prototypes methods can access the instance protected attributes. I forked this repository to solve this situation. The fork only contents modified files. Check it.
Hi @PedroUrday
I've checked out your fork. Could you give a code example, showing the different objects gaining access?
Thanks!
Hi @TremayneChrist
When I said "the prototypes methods can access the instance protected attributes", I might say "the public prototype methods of a type can not access to each instance private attributes of the same type". Sorry for the mistake.
Here is an example of the issue:
function MyObject() {
this._value = "helloworld";
protect(this);
};
MyObject.prototype.public = function () {
console.log(this._value);
};
protect(MyObject);
var mo = new MyObject();
mo.public(); // Says undefined and it should says "helloworld" :(
Best regards!
Hey @PedroUrday
Confirmed, this definitely needs to be looked at.
Note to self: Look at automatically protecting the constructor and bond both of the protected objects