Skip to content

Instantly share code, notes, and snippets.

View lholmquist's full-sized avatar

Lucas Holmquist lholmquist

View GitHub Profile
{
"variants" : ["c3f0a94f-48de-4b77-a08e-68114460857e", "444939cd-ae63-4ce1-96a4-de74b77e3737" ....],
"alias" : ["user@account.com", "someone@aerogear.org", ....],
"categories" : ["someCategory", "otherCategory"],
"deviceType" : ["iPad", "AndroidTablet"],
"ttl" : 3600,
"message": {
"alert":"HELLO!",
"sound":"default",
"badge":7,
/**
Encrypt data being saved or updated if applicable
@private
@augments base
*/
this.encrypt = function( data ) {
// IF encryption is true, do so cool stuff
// or if not, just return the data
if( crypto.agcrypto ) {
// should i also be doing cryptoOptions.key = crypto.agcrypto.deriveKey( cryptoOptions.key )
test( "Encrypt/Decrypt raw bytes providing password", function() {
var agCrypto = AeroGear.Crypto(), //Need to create a "Crypto" object to re-use
rawPassword = agCrypto.deriveKey( PASSWORD ),
utf8String = sjcl.codec.utf8String,
hex = sjcl.codec.hex,
cipherText,
options = {
AAD: hex.toBits( BOB_AAD ),
key: rawPassword,
AeroGear.Crypto = function() {
...
// Local Variables
var privateKey, publicKey, IV;
...
// Method to provide symmetric encryption with GCM by default
/**
Encrypts in GCM mode
@status Experimental
// this
AeroGear.crypto.getRandomValue = function() {
var random = new Uint32Array( 1 );
crypto.getRandomValues( random );
return random[ 0 ];
};
// can now be
//this is using promises.
dm.stores.demo.open().then( function( value ) {
var data = [
{
"id": 1,
"name": "Lea",
"type": "Skywalker"
}
];
var pouchdb = require('pouchdb');
var db = PouchDB('coolcool');
PouchDB.destroy( 'coolcool', function( error, response ) {
console.log( "error", error );
console.log( "response", response );
});
var pipeline = AeroGear.Pipeline();
var pipey = pipeline.add( {
name: "pipey",
settings: {
baseURL: "your base URL",
endpoint: "/{pushAppid}/android/{variantId}/"
}
}).pipes.pipey;
send( params, function( err ) {
if( err ) {
throw something;
}
do other cool stuff
});
//No criteria, just a normal send( what use to be broadcast )
{
message: {
alert: "...",
sound: "...",
badge: "...",
"simple-push": "version=123"
}
}