开发者

How to secure javascript code from being run on other domain (stolen) ? need more ideas

开发者 https://www.devze.com 2023-03-22 15:54 出处:网络
First, t开发者_StackOverflowhis could look like duplicate for How to prevent your JavaScript code from being stolen, copied, and viewed ?

First, t开发者_StackOverflowhis could look like duplicate for

How to prevent your JavaScript code from being stolen, copied, and viewed ?

And other, but it's not.

I search for ideas that can do, that stealing of JS can be very hard

Some of my examples:

  • of course obfuscate code
  • use a document.location an check if some letter in domain equals to letter on that position where script normally works
  • use part of this location in function call, something like eval('first_part_of_function_name'+part_from_location+'third_pard(parameters)');
  • store some important constant need in application in some element in your page-design, and get it from there in JS like $('#header div.onright a rel')
  • get some portion of script by AJAX and eval() it
  • add to script some unnecessary function, instructions.
  • check for existance of some elements in page (copyright text on footer)
  • generate some time-variable hash in PHP and put in JS, where will be function that checks this hash and current time to work or not
  • maybe use of other JS files ? or events binded to elements hidden in very common scripts (like bind some action in jquery-min.X.X.X.js file where all jquery is.

Are they good ideas ? Have some more ? I think that most important can be variety of things wich you can do with document location, is that the only element that will be driffrent than working in normal coditions on our site ?


No matter how complex you make your code, it can always be read, if necessary with abstract interpretation, i.e. automatically capturing the essence of your code. Code without knowledge of internals, variable names (I assume you're already using minimization, for example with the YUI compressor), documentation, support, and generalization is worthless for anyone else.

If a competitor (or potential customers) of yours is stealing your code, consider simply suing them. If it's some random guy on the internet, why do you care?


One more tool http://closure-compiler.appspot.com/home

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号