diff --git a/.gitignore b/.gitignore index de3b537c4..11a47b5cc 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Gruntfile.js b/Gruntfile.js index d49d5bf8f..ad4a457a5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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']); diff --git a/app-template/apply.js b/app-template/apply.js index 115044cae..7c17ff1ce 100755 --- a/app-template/apply.js +++ b/app-template/apply.js @@ -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'); diff --git a/public/views/glidera.html b/public/views/glidera.html index 3c32f93eb..10cfcc304 100644 --- a/public/views/glidera.html +++ b/public/views/glidera.html @@ -10,6 +10,10 @@ +
+ Glidera is disabled for this application +
+
Testnet wallets only work with Glidera Sandbox Accounts
diff --git a/src/js/services/glideraService.js b/src/js/services/glideraService.js index 7665a5767..3f9dfe440 100644 --- a/src/js/services/glideraService.js +++ b/src/js/services/glideraService.js @@ -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; } }; }; diff --git a/util/buildExternalServices.js b/util/buildExternalServices.js new file mode 100755 index 000000000..630d03609 --- /dev/null +++ b/util/buildExternalServices.js @@ -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); + diff --git a/util/coinbase.js b/util/coinbase.js deleted file mode 100755 index d0bd4006d..000000000 --- a/util/coinbase.js +++ /dev/null @@ -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); -