mirror of https://github.com/BTCPrivate/copay.git
adding uuid and deleting crypto library
This commit is contained in:
parent
6dff2840c8
commit
92b49ce154
|
@ -108,7 +108,6 @@ module.exports = function(grunt) {
|
||||||
'bower_components/angular-sanitize/angular-sanitize.js',
|
'bower_components/angular-sanitize/angular-sanitize.js',
|
||||||
'bower_components/ng-csv/build/ng-csv.js',
|
'bower_components/ng-csv/build/ng-csv.js',
|
||||||
'bower_components/angular-mocks/angular-mocks.js',
|
'bower_components/angular-mocks/angular-mocks.js',
|
||||||
'bower_components/crypto-js/crypto-js.js',
|
|
||||||
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js'
|
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js'
|
||||||
],
|
],
|
||||||
dest: 'public/lib/angular.js'
|
dest: 'public/lib/angular.js'
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
"ng-lodash": "0.2.3",
|
"ng-lodash": "0.2.3",
|
||||||
"qrcode-decoder-js": "*",
|
"qrcode-decoder-js": "*",
|
||||||
"trezor-connect": "~1.0.1",
|
"trezor-connect": "~1.0.1",
|
||||||
"ng-csv": "~0.3.6",
|
"ng-csv": "~0.3.6"
|
||||||
"crypto-js": "^3.1.6"
|
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"angular": "1.5.3"
|
"angular": "1.5.3"
|
||||||
|
|
|
@ -17,6 +17,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
||||||
this.init = function() {
|
this.init = function() {
|
||||||
var network = configService.getSync().amazon.testnet ? 'testnet' : 'livenet';
|
var network = configService.getSync().amazon.testnet ? 'testnet' : 'livenet';
|
||||||
amazonService.setCredentials(network);
|
amazonService.setCredentials(network);
|
||||||
|
amazonService.initAmazonUUID(network);
|
||||||
self.allWallets = profileService.getWallets(network, 1);
|
self.allWallets = profileService.getWallets(network, 1);
|
||||||
client = profileService.focusedClient;
|
client = profileService.focusedClient;
|
||||||
if (client && client.credentials.m == 1 && client.credentials.network == network) {
|
if (client && client.credentials.m == 1 && client.credentials.network == network) {
|
||||||
|
@ -176,7 +177,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var now = moment().unix();
|
var now = moment().unix() * 1000;
|
||||||
|
|
||||||
var newData = giftCard;
|
var newData = giftCard;
|
||||||
newData['invoiceId'] = dataSrc.invoiceId;
|
newData['invoiceId'] = dataSrc.invoiceId;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.services').factory('amazonService', function($http, $log, lodash, moment, storageService, configService, platformInfo) {
|
angular.module('copayApp.services').factory('amazonService', function($http, $log, lodash, moment, storageService, configService, platformInfo) {
|
||||||
var root = {};
|
var root = {};
|
||||||
var credentials = {};
|
var credentials = {};
|
||||||
|
@ -14,19 +13,25 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var _getUuid = function(cb) {
|
root.initAmazonUUID = function(network) {
|
||||||
var isCordova = platformInfo.isCordova;
|
storageService.getAmazonUUID(network, function(err, uuid) {
|
||||||
|
if (err) $log.error(err);
|
||||||
if (isCordova) {
|
if (uuid) return;
|
||||||
window.plugins.uniqueDeviceID.get(function(uuid) {
|
var now = moment().unix();
|
||||||
return cb(uuid);
|
var random = Math.floor((Math.random() * 100) + 1);
|
||||||
}, function(err) {
|
var generateUUID = now + random;
|
||||||
$log.error(err);
|
storageService.setAmazonUUID(network, generateUUID, function(err) {
|
||||||
return cb();
|
if (err) $log.error(err);
|
||||||
});
|
});
|
||||||
} else {
|
});
|
||||||
return cb('XXX'); // Test purpose
|
}
|
||||||
}
|
|
||||||
|
var _getUUID = function(cb) {
|
||||||
|
var network = configService.getSync().amazon.testnet ? 'testnet' : 'livenet';
|
||||||
|
storageService.getAmazonUUID(network, function(err, uuid) {
|
||||||
|
if (err) $log.error(err);
|
||||||
|
return cb(uuid);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var _getBitPay = function(endpoint) {
|
var _getBitPay = function(endpoint) {
|
||||||
|
@ -85,8 +90,9 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
||||||
};
|
};
|
||||||
|
|
||||||
root.createBitPayInvoice = function(data, cb) {
|
root.createBitPayInvoice = function(data, cb) {
|
||||||
_getUuid(function(uuid) {
|
_getUUID(function(uuid) {
|
||||||
if (lodash.isEmpty(uuid)) return cb('CAN_NOT_GET_UUID');
|
if (lodash.isEmpty(uuid)) return cb('CAN_NOT_GET_UUID');
|
||||||
|
|
||||||
var dataSrc = {
|
var dataSrc = {
|
||||||
currency: data.currency,
|
currency: data.currency,
|
||||||
amount: data.amount,
|
amount: data.amount,
|
||||||
|
@ -114,7 +120,9 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
||||||
};
|
};
|
||||||
|
|
||||||
root.createGiftCard = function(dataInvoice, cb) {
|
root.createGiftCard = function(dataInvoice, cb) {
|
||||||
_getUuid(function(uuid) {
|
_getUUID(function(uuid) {
|
||||||
|
if (lodash.isEmpty(uuid)) return cb('CAN_NOT_GET_UUID');
|
||||||
|
|
||||||
var dataSrc = {
|
var dataSrc = {
|
||||||
"clientId": uuid,
|
"clientId": uuid,
|
||||||
"invoiceId": dataInvoice.invoiceId,
|
"invoiceId": dataInvoice.invoiceId,
|
||||||
|
@ -131,8 +139,7 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
||||||
$log.error('Amazon.com Gift Card Create/Update: ' + data.data.message);
|
$log.error('Amazon.com Gift Card Create/Update: ' + data.data.message);
|
||||||
return cb(data.data);
|
return cb(data.data);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
return root;
|
return root;
|
||||||
|
|
||||||
|
|
|
@ -330,5 +330,13 @@ angular.module('copayApp.services')
|
||||||
storage.remove('amazonGiftCards-' + network, cb);
|
storage.remove('amazonGiftCards-' + network, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.setAmazonUUID = function(network, uuid, cb) {
|
||||||
|
storage.set('amazonUUID-' + network, uuid, cb);
|
||||||
|
};
|
||||||
|
|
||||||
|
root.getAmazonUUID = function(network, cb) {
|
||||||
|
storage.get('amazonUUID-' + network, cb);
|
||||||
|
};
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue