Glidera service
This commit is contained in:
parent
1f1007a552
commit
792c20b040
7 changed files with 71 additions and 44 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -3,10 +3,6 @@ i18n/po/*.mo
|
||||||
i18n/crowdin_api_key.txt
|
i18n/crowdin_api_key.txt
|
||||||
src/js/translations.js
|
src/js/translations.js
|
||||||
|
|
||||||
# Coinbase API ClientID/Secret
|
|
||||||
coinbase.json
|
|
||||||
src/js/coinbase.js
|
|
||||||
|
|
||||||
# cordova
|
# cordova
|
||||||
cordova/project-*/*
|
cordova/project-*/*
|
||||||
cordova/*.keystore
|
cordova/*.keystore
|
||||||
|
|
@ -101,6 +97,7 @@ public/fonts
|
||||||
|
|
||||||
## templates
|
## templates
|
||||||
/appConfig.json
|
/appConfig.json
|
||||||
|
externalServices.json
|
||||||
cordova/Makefile
|
cordova/Makefile
|
||||||
cordova/ProjectMakefile
|
cordova/ProjectMakefile
|
||||||
app-template/bpapp
|
app-template/bpapp
|
||||||
|
|
@ -110,6 +107,7 @@ cordova/wp/Package.appxmanifest
|
||||||
public/img/logo-negative.svg
|
public/img/logo-negative.svg
|
||||||
public/img/logo.svg
|
public/img/logo.svg
|
||||||
src/js/appConfig.js
|
src/js/appConfig.js
|
||||||
|
src/js/externalServices.js
|
||||||
|
|
||||||
|
|
||||||
cordova/Makefile
|
cordova/Makefile
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ module.exports = function(grunt) {
|
||||||
appConfig: {
|
appConfig: {
|
||||||
command: 'node ./util/buildAppConfig.js'
|
command: 'node ./util/buildAppConfig.js'
|
||||||
},
|
},
|
||||||
coinbase: {
|
externalServices: {
|
||||||
command: 'node ./util/coinbase.js'
|
command: 'node ./util/buildExternalServices.js'
|
||||||
},
|
},
|
||||||
clean: {
|
clean: {
|
||||||
command: 'rm -Rf bower_components node_modules'
|
command: 'rm -Rf bower_components node_modules'
|
||||||
|
|
@ -134,7 +134,7 @@ module.exports = function(grunt) {
|
||||||
'src/js/controllers/**/*.js',
|
'src/js/controllers/**/*.js',
|
||||||
'src/js/translations.js',
|
'src/js/translations.js',
|
||||||
'src/js/appConfig.js',
|
'src/js/appConfig.js',
|
||||||
'src/js/coinbase.js',
|
'src/js/externalServices.js',
|
||||||
'src/js/init.js',
|
'src/js/init.js',
|
||||||
'src/js/trezor-url.js',
|
'src/js/trezor-url.js',
|
||||||
'bower_components/trezor-connect/login.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('prod', ['default', 'uglify']);
|
||||||
grunt.registerTask('translate', ['nggettext_extract']);
|
grunt.registerTask('translate', ['nggettext_extract']);
|
||||||
grunt.registerTask('test', ['karma:unit']);
|
grunt.registerTask('test', ['karma:unit']);
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,16 @@ console.log('Copying ' + configDir + '/appConfig.json' + ' to root');
|
||||||
configBlob = configBlob.replace('{', JSONheader);
|
configBlob = configBlob.replace('{', JSONheader);
|
||||||
fs.writeFileSync('../appConfig.json', configBlob, 'utf8');
|
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) {
|
function copyDir(from, to, cb) {
|
||||||
console.log('Copying dir ' + from + ' to');
|
console.log('Copying dir ' + from + ' to');
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,10 @@
|
||||||
|
|
||||||
<ion-content ng-controller="glideraController as glidera" ng-init="init()">
|
<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'">
|
<div class="box-notification warning" ng-show="network == 'testnet'">
|
||||||
Testnet wallets only work with Glidera Sandbox Accounts
|
Testnet wallets only work with Glidera Sandbox Accounts
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,17 @@
|
||||||
'use strict';
|
'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 root = {};
|
||||||
var credentials = {};
|
var credentials = {};
|
||||||
var isCordova = platformInfo.isCordova;
|
var isCordova = platformInfo.isCordova;
|
||||||
|
|
||||||
var _setCredentials = function() {
|
var _setCredentials = function() {
|
||||||
|
if (!$window.externalServices || !$window.externalServices.glidera) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var glidera = $window.externalServices.glidera;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Development: 'testnet'
|
* Development: 'testnet'
|
||||||
* Production: 'livenet'
|
* Production: 'livenet'
|
||||||
|
|
@ -13,26 +19,26 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
||||||
credentials.NETWORK = 'livenet';
|
credentials.NETWORK = 'livenet';
|
||||||
|
|
||||||
if (credentials.NETWORK == 'testnet') {
|
if (credentials.NETWORK == 'testnet') {
|
||||||
credentials.HOST = 'https://sandbox.glidera.io';
|
credentials.HOST = glidera.sandbox.host;
|
||||||
if (isCordova) {
|
if (isCordova) {
|
||||||
credentials.REDIRECT_URI = 'copay://glidera';
|
credentials.REDIRECT_URI = glidera.sandbox.mobile.redirect_uri;
|
||||||
credentials.CLIENT_ID = '6163427a2f37d1b2022ececd6d6c9cdd';
|
credentials.CLIENT_ID = glidera.sandbox.mobile.client_id;
|
||||||
credentials.CLIENT_SECRET = '599cc3af26108c6fece8ab17c3f35867';
|
credentials.CLIENT_SECRET = glidera.sandbox.mobile.client_secret;
|
||||||
} else {
|
} else {
|
||||||
credentials.REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
|
credentials.REDIRECT_URI = glidera.sandbox.desktop.redirect_uri;
|
||||||
credentials.CLIENT_ID = 'c402f4a753755456e8c384fb65b7be1d';
|
credentials.CLIENT_ID = glidera.sandbox.desktop.client_id;
|
||||||
credentials.CLIENT_SECRET = '3ce826198e3618d0b8ed341ab91fe4e5';
|
credentials.CLIENT_SECRET = glidera.sandbox.desktop.client_secret;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
credentials.HOST = 'https://glidera.io';
|
credentials.HOST = glidera.production.host;
|
||||||
if (isCordova) {
|
if (isCordova) {
|
||||||
credentials.REDIRECT_URI = 'copay://glidera';
|
credentials.REDIRECT_URI = glidera.production.mobile.redirect_uri;
|
||||||
credentials.CLIENT_ID = '9c8023f0ac0128235b7b27a6f2610c83';
|
credentials.CLIENT_ID = glidera.production.mobile.client_id;
|
||||||
credentials.CLIENT_SECRET = '30431511407b47f25a83bffd72881d55';
|
credentials.CLIENT_SECRET = glidera.production.mobile.client_secret;
|
||||||
} else {
|
} else {
|
||||||
credentials.REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
|
credentials.REDIRECT_URI = glidera.production.desktop.redirect_uri;
|
||||||
credentials.CLIENT_ID = '8a9e8a9cf155db430c1ea6c7889afed1';
|
credentials.CLIENT_ID = glidera.production.desktop.client_id;
|
||||||
credentials.CLIENT_SECRET = '24ddec578f38d5488bfe13601933c05f';
|
credentials.CLIENT_SECRET = glidera.production.desktop.client_secret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
30
util/buildExternalServices.js
Executable file
30
util/buildExternalServices.js
Executable 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);
|
||||||
|
|
||||||
|
|
@ -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);
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue