Skip to content

Commit

Permalink
Glidera service
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgustavo committed Sep 1, 2016
1 parent 1f1007a commit 792c20b
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 44 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ i18n/po/*.mo
i18n/crowdin_api_key.txt
src/js/translations.js

# Coinbase API ClientID/Secret
coinbase.json
src/js/coinbase.js

# cordova
cordova/project-*/*
cordova/*.keystore
Expand Down Expand Up @@ -101,6 +97,7 @@ public/fonts

## templates
/appConfig.json
externalServices.json
cordova/Makefile
cordova/ProjectMakefile
app-template/bpapp
Expand All @@ -110,6 +107,7 @@ cordova/wp/Package.appxmanifest
public/img/logo-negative.svg
public/img/logo.svg
src/js/appConfig.js
src/js/externalServices.js


cordova/Makefile
Expand Down
8 changes: 4 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module.exports = function(grunt) {
appConfig: {
command: 'node ./util/buildAppConfig.js'
},
coinbase: {
command: 'node ./util/coinbase.js'
externalServices: {
command: 'node ./util/buildExternalServices.js'
},
clean: {
command: 'rm -Rf bower_components node_modules'
Expand Down Expand Up @@ -134,7 +134,7 @@ module.exports = function(grunt) {
'src/js/controllers/**/*.js',
'src/js/translations.js',
'src/js/appConfig.js',
'src/js/coinbase.js',
'src/js/externalServices.js',
'src/js/init.js',
'src/js/trezor-url.js',
'bower_components/trezor-connect/login.js'
Expand Down Expand Up @@ -245,7 +245,7 @@ module.exports = function(grunt) {
}
});

grunt.registerTask('default', ['nggettext_compile', 'exec:appConfig', 'exec:coinbase', 'browserify', 'sass', 'concat', 'copy:ionic_fonts', 'copy:ionic_js']);
grunt.registerTask('default', ['nggettext_compile', 'exec:appConfig', 'exec:externalServices', 'browserify', 'sass', 'concat', 'copy:ionic_fonts', 'copy:ionic_js']);
grunt.registerTask('prod', ['default', 'uglify']);
grunt.registerTask('translate', ['nggettext_extract']);
grunt.registerTask('test', ['karma:unit']);
Expand Down
11 changes: 10 additions & 1 deletion app-template/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,16 @@ console.log('Copying ' + configDir + '/appConfig.json' + ' to root');
configBlob = configBlob.replace('{', JSONheader);
fs.writeFileSync('../appConfig.json', configBlob, 'utf8');


////////////////
var externalServices;
try {
console.log('Copying ' + configDir + '/externalServices.json' + ' to root');
externalServices = fs.readFileSync(configDir + '/externalServices.json', 'utf8');
} catch(err) {
externalServices = '{}';
console.log('External services not configured');
}
fs.writeFileSync('../externalServices.json', externalServices, 'utf8');

function copyDir(from, to, cb) {
console.log('Copying dir ' + from + ' to');
Expand Down
4 changes: 4 additions & 0 deletions public/views/glidera.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

<ion-content ng-controller="glideraController as glidera" ng-init="init()">

<div class="box-notification error" ng-show="!network">
Glidera is disabled for this application
</div>

<div class="box-notification warning" ng-show="network == 'testnet'">
Testnet wallets only work with Glidera Sandbox Accounts
</div>
Expand Down
36 changes: 21 additions & 15 deletions src/js/services/glideraService.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
'use strict';

angular.module('copayApp.services').factory('glideraService', function($http, $log, platformInfo, storageService, configService, $rootScope) {
angular.module('copayApp.services').factory('glideraService', function($http, $log, $window, platformInfo, storageService, configService, $rootScope) {
var root = {};
var credentials = {};
var isCordova = platformInfo.isCordova;

var _setCredentials = function() {
if (!$window.externalServices || !$window.externalServices.glidera) {
return;
}

var glidera = $window.externalServices.glidera;

/*
* Development: 'testnet'
* Production: 'livenet'
*/
credentials.NETWORK = 'livenet';

if (credentials.NETWORK == 'testnet') {
credentials.HOST = 'https://sandbox.glidera.io';
credentials.HOST = glidera.sandbox.host;
if (isCordova) {
credentials.REDIRECT_URI = 'copay://glidera';
credentials.CLIENT_ID = '6163427a2f37d1b2022ececd6d6c9cdd';
credentials.CLIENT_SECRET = '599cc3af26108c6fece8ab17c3f35867';
credentials.REDIRECT_URI = glidera.sandbox.mobile.redirect_uri;
credentials.CLIENT_ID = glidera.sandbox.mobile.client_id;
credentials.CLIENT_SECRET = glidera.sandbox.mobile.client_secret;
} else {
credentials.REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
credentials.CLIENT_ID = 'c402f4a753755456e8c384fb65b7be1d';
credentials.CLIENT_SECRET = '3ce826198e3618d0b8ed341ab91fe4e5';
credentials.REDIRECT_URI = glidera.sandbox.desktop.redirect_uri;
credentials.CLIENT_ID = glidera.sandbox.desktop.client_id;
credentials.CLIENT_SECRET = glidera.sandbox.desktop.client_secret;
}
} else {
credentials.HOST = 'https://glidera.io';
credentials.HOST = glidera.production.host;
if (isCordova) {
credentials.REDIRECT_URI = 'copay://glidera';
credentials.CLIENT_ID = '9c8023f0ac0128235b7b27a6f2610c83';
credentials.CLIENT_SECRET = '30431511407b47f25a83bffd72881d55';
credentials.REDIRECT_URI = glidera.production.mobile.redirect_uri;
credentials.CLIENT_ID = glidera.production.mobile.client_id;
credentials.CLIENT_SECRET = glidera.production.mobile.client_secret;
} else {
credentials.REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
credentials.CLIENT_ID = '8a9e8a9cf155db430c1ea6c7889afed1';
credentials.CLIENT_SECRET = '24ddec578f38d5488bfe13601933c05f';
credentials.REDIRECT_URI = glidera.production.desktop.redirect_uri;
credentials.CLIENT_ID = glidera.production.desktop.client_id;
credentials.CLIENT_SECRET = glidera.production.desktop.client_secret;
}
};
};
Expand Down
30 changes: 30 additions & 0 deletions util/buildExternalServices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env node

'use strict';

var fs = require('fs');
var file;

try {
file = fs.readFileSync('./externalServices.json', 'utf8');
} catch(err) {
return;
}

var externalServices = JSON.parse(file);
if (externalServices.coinbase &&
externalServices.coinbase.production.client_id)
console.log('Coinbase Production Enabled');
if (externalServices.coinbase &&
externalServices.coinbase.sandbox.client_id)
console.log('Coinbase Sandbox Enabled');
if (externalServices.glidera &&
(externalServices.glidera.production.mobile.client_id || externalServices.glidera.production.desktop.client_id))
console.log('Glidera Production Enabled');
if (externalServices.glidera &&
(externalServices.glidera.sandbox.mobile.client_id || externalServices.glidera.sandbox.desktop.client_id))
console.log('Glidera Sandbox Enabled');

var content = 'window.externalServices=' + JSON.stringify(externalServices) + ';';
fs.writeFileSync("./src/js/externalServices.js", content);

20 changes: 0 additions & 20 deletions util/coinbase.js

This file was deleted.

0 comments on commit 792c20b

Please sign in to comment.