/orion-js

Client-side to Orion Project

Primary LanguageJavaScriptMIT LicenseMIT

Netlify Status

Orion-JS

Client-side library to Orion Project

logo https://orion-sample.netlify.com

To save persistence data to a file in the application's cache, it is necessary to install ServiceWorker (/dist/sw.js). Understand how this SW works by observing it on the way: /src/sw

Build

This script requires Babel & Gulp 4 or later

Before using, install the latest version of GULP-CLI and the necessary plugins:

npm i --save-dev @babel/cli @babel/core @babel/polyfill @babel/preset-env @babel/register gulp@4 gulp-concat gulp-if gulp-babel gulp-javascript-obfuscator gulp-uglify uglify-es yargs

Add these lines to your package.js

"babel": { "presets": [ "@babel/preset-env"] },

Using:

gulp [-pob]

Options:

-p = production mode (minified)

-o = obfuscated scripts

-b = use Babel (for oldies navigators)

Both script and the service worker file will be mounted in the "/dist" directory

Crypto

Load the script into your "index.html" using the appropriate tag:

<script src="/dist/gate.js"></script>

To encrypt with RSA:

var publicKey = "MIIBIjANBgkqhkiG9w0B ... your rsa public key

var data = {foo: "foo", bar: "bar"}

var rsaBase64String = RSA.encrypt(JSON.stringify(data)), RSA.getPublicKey(publicKey))

To encrypt and decrypt with AES:

var encrypted = AES.encrypt("Hello World!", "senha123")

var decrypted = AES.decrypt(encrypted, "senha123")


By Bill Rocha https://billrocha.netlify.com