Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Use Grunt To Lint And Uglify Your JavaScript Project

JavaScript is a forgiving language unlike Java or C#. Because of this, we can’t always trust that our code is correct. I don’t mean that the logic may not be correct, I’m talking about syntax and structure.

Lint via Wikipedia:

…modern lint checkers are often used to find code that doesn’t correspond to certain style guidelines. They can also be used as simple debuggers for common errors, or hard to find errors such as heisenbugs

In addition to needing to lint your code for errors, you may also consider compressing and obfuscating your source code. This can be done through the process of uglification or minification.

Minification via Wikipedia:

Minification (also minimisation or minimization), in computer programming languages and especially JavaScript, is the process of removing all unnecessary characters from source code without changing its functionality.

Linting and minification are two tasks that can easily be run with a task runner such as Grunt or Gulp. In this example, I’ll be demonstrating how to use Grunt to run these tasks.

Read More

Open Dynamic Links Using The Cordova InAppBrowser

Previously I had written a post regarding how to use the Apache Cordova InAppBrowser plugin to launch external URLs in an Ionic Framework application. This previous post was basic and was only enough to get you started.

Since then, I’ve been asked a few times how to use the InAppBrowser as the default method to launching URLs. More specifically, URLs that have been created dynamically by users.

Read More

Understanding Request Signing For Oauth 1.0a Providers

I am very familiar with Oauth 2.0, but recently I had to work with Twitter and it was not as smooth of an experience as other providers such as Google and Facebook. This is because Twitter uses Oauth 1.0a and requires request signing.

Oauth 1.0a requires requests to be signed using HMAC and a secret key. Using this protects communication between the client and the server, but how do we accomplish this task?

Read More

Implement AES Strength Encryption With JavaScript

I recently started playing around with the Dropbox Datastore JavaScript API and decided that I wanted an extra layer of security in the data I store on the Dropbox server. I figured the best way to accomplish this would be to encrypt all data in my application before syncing.

It took me a while to find an encryption library that I liked, but in the end, I chose the JavaScript library Forge. This library has plenty of cryptography tools that extend beyond just AES encryption, thus making it very worthy to check out.

Read More

Generate Time-Based One-Time Passwords With JavaScript

I recently released an iOS and Android application called OTP Safe to iTunes and Google Play. OTP Safe makes use of the time-based one-time password (TOTP) algorithm commonly used with two-factor authentication (2FA). How exactly, does this algorithm work, and how can we make it work with JavaScript?

Using the following resources as our framework, we can make use of the TOTP algorithm quickly and easily:

Read More

Bypass CORS Errors When Testing APIs Locally

Anyone who has worked with a RESTful API using JavaScript knows that testing can be a complete pain if the API owner hasn’t enabled CORS on their server. So what is CORS? According to Wikipedia, it is the following:

Cross-origin resource sharing (CORS) is a mechanism that allows many resources (e.g., fonts, JavaScript, etc.) on a web page to be requested from another domain outside the domain the resource originated from.

Often API owners will leave CORS disabled even though their API is open to the public. In my opinion it doesn’t feel public if the API owner is not allowing requests from all angles.

Here are a few tricks I’ve picked up in regards to bypassing the awful CORS errors you receive in your browser when testing.

Read More