diff --git a/src/js/controllers/create.js b/src/js/controllers/create.js index 6316fd4f8..343422369 100644 --- a/src/js/controllers/create.js +++ b/src/js/controllers/create.js @@ -1,11 +1,7 @@ 'use strict'; 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) { - - var isChromeApp = platformInfo.isChromeApp; - var isCordova = platformInfo.isCordova; - var isDevel = platformInfo.isDevel; + function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, intelTEE, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, appConfigService) { /* For compressed keys, m*73 + n*34 <= 496 */ var COPAYER_PAIR_LIMITS = { @@ -67,9 +63,6 @@ angular.module('copayApp.controllers').controller('createController', var seedOptions = [{ id: 'new', label: gettextCatalog.getString('Random'), - }, { - id: walletService.externalSource.intelTEE.id, - label: gettextCatalog(walletService.externalSource.intelTEE.name), }, { id: 'set', label: gettextCatalog.getString('Specify Recovery Phrase...'), @@ -84,18 +77,25 @@ angular.module('copayApp.controllers').controller('createController', */ if (appConfigService.name == 'copay') { - if (n > 1 && isChromeApp) + if (n > 1 && walletService.externalSource.ledger.supported) seedOptions.push({ id: walletService.externalSource.ledger.id, label: walletService.externalSource.ledger.longName, }); - if (isChromeApp || isDevel) { + if (walletService.externalSource.trezor.supported) { seedOptions.push({ id: walletService.externalSource.trezor.id, 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; @@ -179,7 +179,7 @@ angular.module('copayApp.controllers').controller('createController', src = intelTEE; break; default: - this.error = gettextCatalog('Invalid seed source id: ' + self.seedSourceId); + this.error = gettextCatalog.getString('Invalid seed source id: ' + self.seedSourceId); return; } diff --git a/src/js/controllers/join.js b/src/js/controllers/join.js index 3bbf4813b..73f3281bf 100644 --- a/src/js/controllers/join.js +++ b/src/js/controllers/join.js @@ -1,10 +1,7 @@ 'use strict'; 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) { - - var isChromeApp = platformInfo.isChromeApp; - var isDevel = platformInfo.isDevel; + function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService, appConfigService) { var self = this; var defaults = configService.getDefaults(); @@ -64,14 +61,14 @@ angular.module('copayApp.controllers').controller('joinController', */ if (appConfigService.name == 'copay') { - if (isChromeApp) { + if (walletService.externalSource.ledger.supported) { self.seedOptions.push({ id: walletService.externalSource.ledger.id, label: walletService.externalSource.ledger.longName, }); } - if (isChromeApp || isDevel) { + if (walletService.externalSource.trezor.supported) { self.seedOptions.push({ id: walletService.externalSource.trezor.id, label: walletService.externalSource.trezor.longName, diff --git a/src/js/services/intelTEE.js b/src/js/services/intelTEE.js index 6840d10bd..74ffd7734 100644 --- a/src/js/services/intelTEE.js +++ b/src/js/services/intelTEE.js @@ -5,20 +5,21 @@ angular.module('copayApp.services') var root = {}; - if (!platformInfo.isIntelTEE) { - return root; - } - - var IntelWallet = require('intelWalletCon'); - var TEE_APP_ID = '63279de1b6cb4dcf8c206716bd318092f8c206716bd31809263279de1b6cb4dc'; - root.description = { + supports: platformInfo.supportsIntelTEE, id: 'intelTEE', name: 'Intel TEE', longName: 'Intel TEE Hardware Wallet', derivationStrategy: 'BIP44' }; + if (!root.description.isAvailable) { + return root; + } + + var IntelWallet = require('intelWalletCon'); + var TEE_APP_ID = '63279de1b6cb4dcf8c206716bd318092f8c206716bd31809263279de1b6cb4dc'; + root.walletEnclave = new IntelWallet.Wallet(); var walletEnclaveStatus = root.walletEnclave.initializeEnclave(); if (walletEnclaveStatus != 0) { diff --git a/src/js/services/ledger.js b/src/js/services/ledger.js index 3e01811b1..d28df597f 100644 --- a/src/js/services/ledger.js +++ b/src/js/services/ledger.js @@ -1,11 +1,12 @@ 'use strict'; angular.module('copayApp.services') - .factory('ledger', function($log, bwcService, gettext, hwWallet) { + .factory('ledger', function($log, bwcService, gettext, hwWallet, platformInfo) { var root = {}; var LEDGER_CHROME_ID = "kkdpmhnladdopljabkgpacgpliggeeaf"; root.description = { + supports: platformInfo.supportsLedger, id: 'ledger', name: 'Ledger', longName: 'Ledger Hardware Wallet' diff --git a/src/js/services/platformInfo.js b/src/js/services/platformInfo.js index 2a6d75aea..459e96167 100644 --- a/src/js/services/platformInfo.js +++ b/src/js/services/platformInfo.js @@ -38,7 +38,10 @@ angular.module('copayApp.services').factory('platformInfo', function($window) { ret.isMobile = ret.isAndroid || ret.isIOS || ret.isWP; ret.isChromeApp = $window.chrome && chrome.runtime && chrome.runtime.id && !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; }); diff --git a/src/js/services/trezor.js b/src/js/services/trezor.js index c76860ed0..407d94c4b 100644 --- a/src/js/services/trezor.js +++ b/src/js/services/trezor.js @@ -1,13 +1,14 @@ 'use strict'; angular.module('copayApp.services') - .factory('trezor', function($log, $timeout, lodash, bitcore, hwWallet) { + .factory('trezor', function($log, $timeout, lodash, bitcore, hwWallet, platformInfo) { var root = {}; var SETTLE_TIME = 3000; root.callbacks = {}; root.description = { + supported: platformInfo.supportsTrezor, id: 'trezor', name: 'Trezor', longName: 'Trezor Hardware Wallet',