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/ng-csv/build/ng-csv.js',
|
||||
'bower_components/angular-mocks/angular-mocks.js',
|
||||
'bower_components/crypto-js/crypto-js.js',
|
||||
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js'
|
||||
],
|
||||
dest: 'public/lib/angular.js'
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
"ng-lodash": "0.2.3",
|
||||
"qrcode-decoder-js": "*",
|
||||
"trezor-connect": "~1.0.1",
|
||||
"ng-csv": "~0.3.6",
|
||||
"crypto-js": "^3.1.6"
|
||||
"ng-csv": "~0.3.6"
|
||||
},
|
||||
"resolutions": {
|
||||
"angular": "1.5.3"
|
||||
|
|
|
@ -17,6 +17,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
this.init = function() {
|
||||
var network = configService.getSync().amazon.testnet ? 'testnet' : 'livenet';
|
||||
amazonService.setCredentials(network);
|
||||
amazonService.initAmazonUUID(network);
|
||||
self.allWallets = profileService.getWallets(network, 1);
|
||||
client = profileService.focusedClient;
|
||||
if (client && client.credentials.m == 1 && client.credentials.network == network) {
|
||||
|
@ -176,7 +177,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
return;
|
||||
}
|
||||
|
||||
var now = moment().unix();
|
||||
var now = moment().unix() * 1000;
|
||||
|
||||
var newData = giftCard;
|
||||
newData['invoiceId'] = dataSrc.invoiceId;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('amazonService', function($http, $log, lodash, moment, storageService, configService, platformInfo) {
|
||||
var root = {};
|
||||
var credentials = {};
|
||||
|
@ -14,19 +13,25 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
|||
};
|
||||
};
|
||||
|
||||
var _getUuid = function(cb) {
|
||||
var isCordova = platformInfo.isCordova;
|
||||
|
||||
if (isCordova) {
|
||||
window.plugins.uniqueDeviceID.get(function(uuid) {
|
||||
return cb(uuid);
|
||||
}, function(err) {
|
||||
$log.error(err);
|
||||
return cb();
|
||||
root.initAmazonUUID = function(network) {
|
||||
storageService.getAmazonUUID(network, function(err, uuid) {
|
||||
if (err) $log.error(err);
|
||||
if (uuid) return;
|
||||
var now = moment().unix();
|
||||
var random = Math.floor((Math.random() * 100) + 1);
|
||||
var generateUUID = now + random;
|
||||
storageService.setAmazonUUID(network, generateUUID, function(err) {
|
||||
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) {
|
||||
|
@ -85,8 +90,9 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
|||
};
|
||||
|
||||
root.createBitPayInvoice = function(data, cb) {
|
||||
_getUuid(function(uuid) {
|
||||
_getUUID(function(uuid) {
|
||||
if (lodash.isEmpty(uuid)) return cb('CAN_NOT_GET_UUID');
|
||||
|
||||
var dataSrc = {
|
||||
currency: data.currency,
|
||||
amount: data.amount,
|
||||
|
@ -114,7 +120,9 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
|||
};
|
||||
|
||||
root.createGiftCard = function(dataInvoice, cb) {
|
||||
_getUuid(function(uuid) {
|
||||
_getUUID(function(uuid) {
|
||||
if (lodash.isEmpty(uuid)) return cb('CAN_NOT_GET_UUID');
|
||||
|
||||
var dataSrc = {
|
||||
"clientId": uuid,
|
||||
"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);
|
||||
return cb(data.data);
|
||||
});
|
||||
})
|
||||
|
||||
});
|
||||
};
|
||||
return root;
|
||||
|
||||
|
|
|
@ -330,5 +330,13 @@ angular.module('copayApp.services')
|
|||
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;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue