• 0

Protecting/Hiding AngularJS Codes


Question

roosevelt

Hi,

 

Angular JS has been very useful to me lately and it's amazing how quick it makes web development. I am aware that Javascript isn't compiled, thus your Javascript codes or Angular JS codes are accessible to anyone with a web browser.

 

I really like how Angular works and actually love the fact that I can program most of my backend logic within Angular controllers, etc. But how do I protect proprietary codes or algorithm?

 

Currently, I'm making AJAX calls to a C++ binary/exe file to carry out a specific operation. This helps me protect the algorithm but I would love to compile the JS code to binary and no longer depend on C++, etc.

 

Any thoughts or ideas?

Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0
ramesees

Run your code through a minifier to produce a .min.js file ?

 

Then use that in your production index.html page and you should be fine.

 

Be aware though of minified javascript code with Angular - you must have specified your dependencies properly otherwise things will break.

 

Plenty of info searching around for that though.

 

Also you dont want to be putting logic into Controllers - they are to be kept as lightweight as possible.

Put the logic into Services as they can be tested much more easily and this promotes code reuse over your application if required.

Link to post
Share on other sites
  • 0
Obry

Minify and also uglify your javascript. Search on google for techniques of doing both. It will mangle up your production scripts to where they won't be human readable anymore. Note that you're still not 100% secure that way since you still have working scripts exposed to the client and someone (quite smart with the proper tools) can still reverse engineer your codes to certain extent but for the most part you should be OK.

 

That being said, for very sensitive codes and algorithms it is sometimes best to leave them on the server. That's why as nice as JavaScript frameworks like Angular are, there still will always be the need to have a server in the back-end to perform certain sensitive tasks such as security, authentication and hiding protected algorithms...

Link to post
Share on other sites
  • 0
Mulrian

I really like how Angular works and actually love the fact that I can program most of my backend logic within Angular controllers, etc.

 

You mean frontend logic right?

 

Currently, I'm making AJAX calls to a C++ binary/exe file to carry out a specific operation. This helps me protect the algorithm but I would love to compile the JS code to binary and no longer depend on C++, etc.

 

There is not really a whole lot you can do with your JS, but to be honest I don't really see why it would be a problem anyway. I agree with what the others have said, If you have some new super amazing algorithm, chances are you only need to be using it on the backend anyways where this isn't a problem.

 

The only thing you can really do with JS is run it through a minifier which will mash up the formatting and naming of everything. It will look pretty unreadable to most people but that doesn't stop anyone from simply running it through a formatter (there is a pretty print function in Chrome's Developer tools) and things suddenly get a lot more readable. You don't get the variable names which good, but to be honest if someone is willing enough to try and work it out, they probably will.. .eventually.

Link to post
Share on other sites
  • 0
Seahorsepip

Minifying and uglyfying isn't gonna work, it's just going to rename the variables and function names but the code stays the same for anyone who want's to steal your code.

 

Front end stuff will always be something users can copy from your website, there's no way to protect yourself against that.

 

That's one of the many reasons why adobe flash was so succesful, it was able to include drm however you liked it.

  • Like 1
Link to post
Share on other sites
  • 0
+LogicalApex

Security through obfuscation isn't security. You can't hide JavaScript code because it is compiled client side...

 

Move what you consider the most secret onto a server and call its output via APIs if you want to secure the code. Your client side code should be "dumb" and "thin" when you need to hide the details.

Link to post
Share on other sites
  • 0
roosevelt

Haha, yes you could say front end logic. Coming from cakephp MVC background, most of the things like rendering partials, handling routes, and dealing with arguments, etc are all handled by PHP and processed at the server level. But with angular I don't even need a web server and I could create a fully functional application with dummy/local json files.

You mean frontend logic right?

There is not really a whole lot you can do with your JS, but to be honest I don't really see why it would be a problem anyway. I agree with what the others have said, If you have some new super amazing algorithm, chances are you only need to be using it on the backend anyways where this isn't a problem.

The only thing you can really do with JS is run it through a minifier which will mash up the formatting and naming of everything. It will look pretty unreadable to most people but that doesn't stop anyone from simply running it through a formatter (there is a pretty print function in Chrome's Developer tools) and things suddenly get a lot more readable. You don't get the variable names which good, but to be honest if someone is willing enough to try and work it out, they probably will.. .eventually.

Link to post
Share on other sites
  • 0
Steve H.

AngularJS is javascript framework. Even if you minify it, ultimately it will be fetched by the browser to run it. JS, CSS and image which have reached browsers cannot be hidden then.

Link to post
Share on other sites
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By zikalify
      Beta version of ProtonMail 4.0 launches with an all-new look
      by Paul Hill

      ProtonMail has announced the launch of its ProtonMail 4.0 beta software. With the upgrade, users will experience an all-new look and underneath the surface, a new software framework is laying the groundwork for new features, products, and customisations in future updates.

      In terms of the front-facing features, you’ll immediately notice the work that has gone into the revamped user interface. According to the firm, the new interface has been designed to feel lighter and help you work faster. Additionally, you can access all of your other Proton services from the new UI including your ProtonVPN account, ProtonContacts, and other planned products such as ProtonCalendar and ProtonDrive. A dark theme will also be added in the future during the beta phase.

      On the back-end, ProtonMail is replacing AngularJS with React. This process is still on-going but the Settings and Contacts tools have already been ported. The inbox itself is still using AngularJS but will be moved over to React during the beta. With React, the web app will be much faster and new features can be more quickly deployed.

      All users can try out the new beta release of ProtonMail 4.0, all you need to do is head on over to beta.protonmail.com. If you ever want to revert to the current interface then just navigate to the usual ProtonMail domain.

    • By News Staff
      This Premium 2020 Learn to Code Certification Bundle is only $11.25 with promo code
      by Steven Parker

      Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where you can save 98% off this Premium 2020 Learn to Code Certification Bundle. Learn coding practices and programs and build effective websites with 12 coding courses and nearly 150 hours of content.



      What's the deal?
      This deal consists of the following courses:

      The Web Developer Bootcamp
      Become a Full Stack Web Developer & Launch an In-Demand Career Learn Python Programming in 150 Steps
      Learn Python 3 & Build Algorithms and Data Structures with Projects from Scratch Learn Java Programming in 250 Steps
      Start Learning Java Programming Step-by-Step with 200+ Code Examples Django 2 & Python: The Ultimate Web Development Bootcamp
      Streamline Your Web Development by Learning the New Features of Django 2 Python Programming, CS, Algorithms & Data Structures
      Learn to Implement the Most Up-to-Date Algorithms from Scratch The Deep Learning Masterclass: Classify Images with Keras
      Catalyze Your Foray Into AI by Building a Model That Classifies Images Learn Flutter & Dart: Complete App Development Projects
      Learn to Build Apps in Flutter, Google's Cross-Platform Framework & Code with Its Dart Programming Language Build Responsive Real World Websites with HTML5 & CSS3
      Learn Modern Web Design by Coding a Real Project Step-by-Step JavaScript: Understanding the Weird Parts
      Understand the Foundations of JavaScript & Learn How to Code Like a Pro Learn & Understand AngularJS
      Master AngularJS & the JavaScript Concepts Behind It, Design Custom Directives, and Build a Single Page Application The Ultimate MySQL Bootcamp: Go from SQL Beginner to Expert
      Become an In-Demand SQL Master by Creating Complex Databases & Building Reports through Real-World Projects JavaScript Beginner Bootcamp
      Understand the JavaScript Language & Learn to Create and Launch Interactive Webpages Good to know
      Length of time users can access this course: lifetime Certification of completion included Redemption deadline: redeem your code within 30 days of purchase For a full description, specs, and instructor info, click here.

      What's the benefit?
      This Premium 2020 Learn to Code Certification Bundle normally costs* $2,700, but you can pick it up for just $45 for a limited time - that represents a saving of $2,655 (98%) off.

      Promo Code
      For the whole month of October, you can get an additional 75% off many online courses at Neowin Deals when you use the LEARN75 promo code upon checking out, bringing the price down to just $11.25.

      >> Get this deal, or learn more about it <<
      See all discounted Online Courses. This is a time-limited offer.

      Save even more!
      Stick with Neowin Deals and earn credit or even deeper discounts.

      Check out our recent deals here or on the Neowin Deals site. For every $25 spent, you get $1 credit added to your Neowin Deals account. Refer the deal for $10 credit via social media or email and if it results in a purchase of at least $10, you'll get $10 credit added to your account. 10% off for first-time buyers: be sure not to dismiss the popup offer to subscribe to email updates on the deals page in order to profit! Not for you?
      If this offer doesn't interest you, why not check out our giveaways on the Neowin Deals website? There's also a bunch of freebies you can check out here.

      Miscellany and the fine print!
      In some cases, such as with Online Courses, a store credit refund within 15 days of purchase is possible if you are unhappy with it; this does not apply to all deals, so please do check the terms on the page before making a purchase.

      Check our other recent deals, before they expire, or our preferred partner software for Private Internet Access and NordVPN deals.

      How can I disable these posts? Click here.

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs. *Values or percentages mentioned above are subject to StackCommerce's own determination of retail pricing.

    • By News Staff
      Pay What You Want for this Learn to Code 2018 Bundle
      by Steven Parker

      Today's highlighted offer comes via our Online Courses section of the Neowin Deals store, where you can Pay What You Want for this Learn to Code 2018 Bundle. A price you pick gets you up to 140 hours of premium coding instruction, from Python to Angular and everything in between.

      Image via PexelsWhat's the deal?
      With the Pay What You Want bundles, you can get something incredible for as little as you want to pay. And if you beat the average price, you’ll receive the fully upgraded bundle! Included in this Pay What You Want deal, are the following courses:

      Pay What You Want (as little as $1) for the unlocked course:

      Introduction to R Programming
      Jump Into One of the Most Effective Statistical Analysis Tools on Earth

      Or beat the the average price to get these as well:

      Complete Python Web Course: Build 8 Python Web Apps
      Go From Beginner to Expert Using Python & Flask

      How to Make a Freaking iPhone App: iOS 11 and Swift 4
      Learn How to Make iOS Apps Using the Newest Tools Available

      JavaScript for Beginners
      Learn JavaScript Through Whiteboard Videos, Coding in the Browser, & Building a Website

      The Complete PHP MySQL Professional Course
      Learn PHP MySQL by Building 5 Projects From Scratch

      Learn React by Building Real Projects
      Discover the Top Web Coding Framework That Will Guarantee You Work

      Programming for Complete Beginners in C#
      Open Up a New Realm of Job Opportunities by Learning C#

      The Complete Java 9 Masterclass: Beginner to Expert
      Learn Java 9 by Building JavaFX, Springboot, & Vaadin Java Enterprise Applications

      Beginner Full Stack Web Development: HTML, CSS, React & Node
      Learn Web Development with HTML, CSS, Bootstrap 4, ES6 React, & Node

      Angular Crash Course for Busy Developers
      Learn Angular in 10 Hours

      Good to know
      The bundle represents an overall retail value of $1,479 But you can Pay What You Want for the unlocked course (as little as $1) Beat the average price and you'll take home the entire bundle. Qualify for the giveaway!
      Beat the Leader's price and get entered into the epic giveaway - plus get featured on the Leaderboard!

      >> Pay What You Want for this Learn to Code 2018 Bundle <<
      > See other Pay What You Want deals <
      This is a time limited deal that ends soon!

      Not for you?
      If this offer doesn't interest you, why not check out our giveaways on the Neowin Deals website? There's also a bunch of freebies you can check out here.

      Miscellany and the fine print!
      In some cases, such as with Online Courses, a store credit refund within 15 days of purchase is possible if you are unhappy with it; this does not apply to all deals, so please do check the terms on the page before making a purchase.

      Check our other recent deals, before they expire, or our preferred partner software.

      How can I disable these posts? Click here.

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerces privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs. *Values or percentages mentioned above are subject to StackCommerces own determination of retail pricing.

    • By News Staff
      Get this Learn to Code 2018 bundle by beating the average price, or PWYW
      by Steven Parker

      Today's highlighted offer comes via our Online Courses section of the Neowin Deals store, where you can Pay What You Want for the Learn to Code 2018 Bundle. A price you pick gets you up to 140 hours of premium coding instruction, from Python to Angular and everything in between.

      Image via PexelsWhat's the deal?
      With the Pay What You Want bundles, you can get something incredible for as little as you want to pay. And if you beat the average price, you’ll receive the fully upgraded bundle! Included in this Pay What You Want deal, are the following courses:

      Pay What You Want (as little as $1) for the unlocked course:

      Introduction to R Programming
      Jump Into One of the Most Effective Statistical Analysis Tools on Earth

      Or beat the the average price to get these as well:

      Complete Python Web Course: Build 8 Python Web Apps
      Go From Beginner to Expert Using Python & Flask

      How to Make a Freaking iPhone App: iOS 11 and Swift 4
      Learn How to Make iOS Apps Using the Newest Tools Available

      JavaScript for Beginners
      Learn JavaScript Through Whiteboard Videos, Coding in the Browser, & Building a Website

      The Complete PHP MySQL Professional Course
      Learn PHP MySQL by Building 5 Projects From Scratch

      Learn React by Building Real Projects
      Discover the Top Web Coding Framework That Will Guarantee You Work

      Programming for Complete Beginners in C#
      Open Up a New Realm of Job Opportunities by Learning C#

      The Complete Java 9 Masterclass: Beginner to Expert
      Learn Java 9 by Building JavaFX, Springboot, & Vaadin Java Enterprise Applications

      Beginner Full Stack Web Development: HTML, CSS, React & Node
      Learn Web Development with HTML, CSS, Bootstrap 4, ES6 React, & Node

      Angular Crash Course for Busy Developers
      Learn Angular in 10 Hours

      Good to know
      The bundle represents an overall retail value of $1,479 But you can Pay What You Want for the unlocked course (as little as $1) Beat the average price and you'll take home the entire bundle. Qualify for the giveaway!
      Beat the Leader's price and get entered into the epic giveaway - plus get featured on the Leaderboard!

      > Pay What You Want for the Learn to Code 2018 Bundle <
      > See other Pay What You Want deals <
      This is a time limited deal that ends soon!

      Not for you?
      If this offer doesn't interest you, why not check out our giveaways on the Neowin Deals website? There's also a bunch of freebies you can check out here.

      Miscellany and the fine print!
      In some cases, such as with Online Courses, a store credit refund within 15 days of purchase is possible if you are unhappy with it; this does not apply to all deals, so please do check the terms on the page before making a purchase.

      Check our other recent deals, before they expire, or our preferred partner software.

      How can I disable these posts? Click here.

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerces privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs. *Values or percentages mentioned above are subject to StackCommerces own determination of retail pricing.

    • By News Staff
      This 2019 Complete Computer Science Bundle is temporarily 97% off at only $39
      by Steven Parker

      Today's highlighted deal comes via our Online Courses section of the Neowin Deals store where you can save 97% off* this 2019 Complete Computer Science Bundle. Save the tuition payment — This 11-course bundle will give you the university Computer Science education you missed through.



      What's the deal?
      This bundle consists of the following eleven courses:

      An Easy Introduction to Python
      Become a Python Programmer in Just a Few Hours Scalable Programming with Scala and Spark
      Get Rich Using Scala & Spark for Data Analysis, Machine Learning & Analytics Break Away: Programming And Coding Interviews
      Ace Your Next Programming Interview with These Technical Fundamentals & Interview Tips The Web Development Omnibus: jQuery, AngularJS and ReactJS
      Master Web Dev Essentials All in One Course Building Voice Apps Using Amazon Alexa
      Alexa Skills for Echo & Other Amazon Devices Building Chatbots with Google DialogFlow
      Learn About Google's Answer to Amazon Lex Using Elasticsearch and Kibana
      Scalable Search & Analytics for Document Data From 0 to 1 : Spark for Data Science in Python
      Make Your Data Fly Using Spark for Analytics, Machine Learning, & Data Science Learn By Example: Scala
      Master This Highly Scalable General-Purpose Language with 65 Examples Software Testing Omnibus: Sikuli, Selenium, JUnit and Principles of Testing
      Cover 3 Technologies & All of the Underlying Principles of Software Testing Learn By Example: The Foundations of HTML, CSS & JavaScript
      Lay the Foundations for Your Web Development Career with Training in HTML, CSS & JavaScript Good to know
      Length of time users can access after purchase: lifetime Certification of completion not included Redemption deadline: redeem your code within 30 days of purchase Deal ends in 2 days For a full description, specs, and instructor info please click here.

      What's the benefit?
      This 2019 Complete Computer Science Bundle normally represents an overall recommended retail pricing* of $1450.99 but it can be yours for just $39, a saving of $1411.99.

      And today only, use the LABORDAY30 Promo code for an additional 30% off while checking out.

      >> Get this deal, or learn more about it here <<
      See all Online Courses on offer

      Save even more!
      Stick with Neowin Deals and earn credit or even deeper discounts.

      For every $25 spent, you get $1 credit added to your Neowin Deals account. Refer the deal for $10 credit via social media or email and if it results in a purchase of at least $10, you'll get $10 credit added to your account. 10% off for first-time buyers: be sure not to dismiss the popup offer to subscribe to email updates on the deals page in order to profit! Not for you?
      If this offer doesn't interest you, why not check out our giveaways on the Neowin Deals website? There's also a bunch of freebies you can check out here.

      Or try your luck on The Xiaomi Mi Electric Scooter Giveaway. Skip the apps and get your own personal electric scooter for free! All you have to do is sign up here to enter this giveaway.

      Miscellany and the fine print!
      In some cases, such as with Online Courses, a store credit refund within 15 days of purchase is possible if you are unhappy with it; this does not apply to all deals, so please do check the terms on the page before making a purchase.

      Check our other recent deals, before they expire, or our preferred partner software.

      How can I disable these posts? Click here.

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerces privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs. *Values or percentages mentioned above are subject to StackCommerces own determination of retail pricing.