Improve detection of supported hw wallets.

This commit is contained in:
Andy Phillipson 2017-03-16 14:37:41 -04:00
commit 8d63fa3507
6 changed files with 30 additions and 27 deletions

View file

@ -1,11 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('createController', angular.module('copayApp.controllers').controller('createController',
function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, intelTEE, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, appConfigService) { function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, intelTEE, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, appConfigService) {
var isChromeApp = platformInfo.isChromeApp;
var isCordova = platformInfo.isCordova;
var isDevel = platformInfo.isDevel;
/* For compressed keys, m*73 + n*34 <= 496 */ /* For compressed keys, m*73 + n*34 <= 496 */
var COPAYER_PAIR_LIMITS = { var COPAYER_PAIR_LIMITS = {
@ -67,9 +63,6 @@ angular.module('copayApp.controllers').controller('createController',
var seedOptions = [{ var seedOptions = [{
id: 'new', id: 'new',
label: gettextCatalog.getString('Random'), label: gettextCatalog.getString('Random'),
}, {
id: walletService.externalSource.intelTEE.id,
label: gettextCatalog(walletService.externalSource.intelTEE.name),
}, { }, {
id: 'set', id: 'set',
label: gettextCatalog.getString('Specify Recovery Phrase...'), label: gettextCatalog.getString('Specify Recovery Phrase...'),
@ -84,18 +77,25 @@ angular.module('copayApp.controllers').controller('createController',
*/ */
if (appConfigService.name == 'copay') { if (appConfigService.name == 'copay') {
if (n > 1 && isChromeApp) if (n > 1 && walletService.externalSource.ledger.supported)
seedOptions.push({ seedOptions.push({
id: walletService.externalSource.ledger.id, id: walletService.externalSource.ledger.id,
label: walletService.externalSource.ledger.longName, label: walletService.externalSource.ledger.longName,
}); });
if (isChromeApp || isDevel) { if (walletService.externalSource.trezor.supported) {
seedOptions.push({ seedOptions.push({
id: walletService.externalSource.trezor.id, id: walletService.externalSource.trezor.id,
label: walletService.externalSource.trezor.longName, label: walletService.externalSource.trezor.longName,
}); });
} }
if (walletService.externalSource.intelTEE.supported) {
seedOptions.push({
id: walletService.externalSource.intelTEE.id,
label: walletService.externalSource.intelTEE.longName,
});
}
} }
$scope.seedOptions = seedOptions; $scope.seedOptions = seedOptions;
@ -179,7 +179,7 @@ angular.module('copayApp.controllers').controller('createController',
src = intelTEE; src = intelTEE;
break; break;
default: default:
this.error = gettextCatalog('Invalid seed source id: ' + self.seedSourceId); this.error = gettextCatalog.getString('Invalid seed source id: ' + self.seedSourceId);
return; return;
} }

View file

@ -1,10 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('joinController', angular.module('copayApp.controllers').controller('joinController',
function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService, appConfigService) { function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService, appConfigService) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;
var self = this; var self = this;
var defaults = configService.getDefaults(); var defaults = configService.getDefaults();
@ -64,14 +61,14 @@ angular.module('copayApp.controllers').controller('joinController',
*/ */
if (appConfigService.name == 'copay') { if (appConfigService.name == 'copay') {
if (isChromeApp) { if (walletService.externalSource.ledger.supported) {
self.seedOptions.push({ self.seedOptions.push({
id: walletService.externalSource.ledger.id, id: walletService.externalSource.ledger.id,
label: walletService.externalSource.ledger.longName, label: walletService.externalSource.ledger.longName,
}); });
} }
if (isChromeApp || isDevel) { if (walletService.externalSource.trezor.supported) {
self.seedOptions.push({ self.seedOptions.push({
id: walletService.externalSource.trezor.id, id: walletService.externalSource.trezor.id,
label: walletService.externalSource.trezor.longName, label: walletService.externalSource.trezor.longName,

View file

@ -5,20 +5,21 @@ angular.module('copayApp.services')
var root = {}; var root = {};
if (!platformInfo.isIntelTEE) {
return root;
}
var IntelWallet = require('intelWalletCon');
var TEE_APP_ID = '63279de1b6cb4dcf8c206716bd318092f8c206716bd31809263279de1b6cb4dc';
root.description = { root.description = {
supports: platformInfo.supportsIntelTEE,
id: 'intelTEE', id: 'intelTEE',
name: 'Intel TEE', name: 'Intel TEE',
longName: 'Intel TEE Hardware Wallet', longName: 'Intel TEE Hardware Wallet',
derivationStrategy: 'BIP44' derivationStrategy: 'BIP44'
}; };
if (!root.description.isAvailable) {
return root;
}
var IntelWallet = require('intelWalletCon');
var TEE_APP_ID = '63279de1b6cb4dcf8c206716bd318092f8c206716bd31809263279de1b6cb4dc';
root.walletEnclave = new IntelWallet.Wallet(); root.walletEnclave = new IntelWallet.Wallet();
var walletEnclaveStatus = root.walletEnclave.initializeEnclave(); var walletEnclaveStatus = root.walletEnclave.initializeEnclave();
if (walletEnclaveStatus != 0) { if (walletEnclaveStatus != 0) {

View file

@ -1,11 +1,12 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('ledger', function($log, bwcService, gettext, hwWallet) { .factory('ledger', function($log, bwcService, gettext, hwWallet, platformInfo) {
var root = {}; var root = {};
var LEDGER_CHROME_ID = "kkdpmhnladdopljabkgpacgpliggeeaf"; var LEDGER_CHROME_ID = "kkdpmhnladdopljabkgpacgpliggeeaf";
root.description = { root.description = {
supports: platformInfo.supportsLedger,
id: 'ledger', id: 'ledger',
name: 'Ledger', name: 'Ledger',
longName: 'Ledger Hardware Wallet' longName: 'Ledger Hardware Wallet'

View file

@ -38,7 +38,10 @@ angular.module('copayApp.services').factory('platformInfo', function($window) {
ret.isMobile = ret.isAndroid || ret.isIOS || ret.isWP; ret.isMobile = ret.isAndroid || ret.isIOS || ret.isWP;
ret.isChromeApp = $window.chrome && chrome.runtime && chrome.runtime.id && !ret.isNW; ret.isChromeApp = $window.chrome && chrome.runtime && chrome.runtime.id && !ret.isNW;
ret.isDevel = !ret.isMobile && !ret.isChromeApp && !ret.isNW; ret.isDevel = !ret.isMobile && !ret.isChromeApp && !ret.isNW;
ret.isIntelTEE = true;
ret.supportsLedger = ret.isChromeApp;
ret.supportsTrezor = ret.isChromeApp || ret.isDevel;
ret.supportsIntelTEE = false;
return ret; return ret;
}); });

View file

@ -1,13 +1,14 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('trezor', function($log, $timeout, lodash, bitcore, hwWallet) { .factory('trezor', function($log, $timeout, lodash, bitcore, hwWallet, platformInfo) {
var root = {}; var root = {};
var SETTLE_TIME = 3000; var SETTLE_TIME = 3000;
root.callbacks = {}; root.callbacks = {};
root.description = { root.description = {
supported: platformInfo.supportsTrezor,
id: 'trezor', id: 'trezor',
name: 'Trezor', name: 'Trezor',
longName: 'Trezor Hardware Wallet', longName: 'Trezor Hardware Wallet',