Merge pull request #40 from cmgustavo/ref/design-14

Glidera service
This commit is contained in:
Matias Alejo Garcia 2016-09-01 18:30:28 -03:00 committed by GitHub
commit f6f4a3fb28
7 changed files with 71 additions and 44 deletions

6
.gitignore vendored
View File

@ -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
@ -101,6 +97,7 @@ public/fonts
## templates
/appConfig.json
externalServices.json
cordova/Makefile
cordova/ProjectMakefile
app-template/bpapp
@ -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

View File

@ -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'
@ -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'
@ -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']);

View File

@ -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');

View File

@ -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>

View File

@ -1,11 +1,17 @@
'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'
@ -13,26 +19,26 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
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;
}
};
};

30
util/buildExternalServices.js Executable file
View File

@ -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);

View File

@ -1,20 +0,0 @@
#!/usr/bin/env node
'use strict';
var fs = require('fs');
var file;
try {
file = fs.readFileSync('./coinbase.json', 'utf8');
} catch(err) {
return;
}
var json = JSON.parse(file);
console.log('Coinbase Client ID: ' + json.client_id);
var content = 'window.coinbase_client_id="' + json.client_id + '";';
content = content + '\nwindow.coinbase_client_secret="' + json.client_secret + '";';
fs.writeFileSync("./src/js/coinbase.js", content);