From cc2f5f6a145531a0df08eaf2bacc3eb02d191d16 Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Wed, 30 May 2018 16:28:32 +1200 Subject: [PATCH 1/9] Rudimentarily working with getting and setting the profile in the Keychain on iOS. --- app-template/config-template.xml | 1 + src/js/services/storageService.js | 55 ++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/app-template/config-template.xml b/app-template/config-template.xml index 8031c8110..32440782c 100644 --- a/app-template/config-template.xml +++ b/app-template/config-template.xml @@ -72,6 +72,7 @@ + diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 3d1ecfeef..ea0a975c0 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -116,19 +116,60 @@ angular.module('copayApp.services') }; root.storeNewProfile = function(profile, cb) { - storage.create('profile', profile.toObj(), cb); + console.log('storeNewProfile() 6'); + + SecureStorage.set('profile', profile.toObj(), function success(){ cb(); }, function error(err){ cb(err); }); + + //storage.create('profile', profile.toObj(), cb); }; root.storeProfile = function(profile, cb) { - storage.set('profile', profile.toObj(), cb); + console.log('storeProfile() 6'); + SecureStorage.set('profile', profile.toObj(), function success(){ cb(); }, function error(err){ cb(err); }); + //storage.set('profile', profile.toObj(), cb); }; root.getProfile = function(cb) { - storage.get('profile', function(err, str) { - if (err || !str) - return cb(err); + console.log("getProfile() 6"); + + SecureStorage.get( + 'profile', + function success(str) { + $log.debug('get profile returned success.'); + decryptOnMobile(str, function(err, str) { + if (err) return cb(err); + var p, err; + try { + p = Profile.fromString(str); + } catch (e) { + $log.debug('Could not read profile:', e); + err = new Error('Could not read profile:' + p); + } + return cb(err, p); + }); + }, + function error(err) { + $log.debug('get profile returned error.'); + $log.debug('returning error.'); + // Callback requires no error and no profile for creation of new profiles + return cb(); + } + ); + + + + /* + storage.get('profile', function(err, str) { + $log.debug('get profile returned.'); + if (err || !str) { + $log.debug('get profile returned error: ' + err + ' with string: ' + str); + return cb(err); + } + + $log.debug('calling decrypt'); decryptOnMobile(str, function(err, str) { + $log.debug('decrypt returned.'); if (err) return cb(err); var p, err; try { @@ -140,8 +181,12 @@ angular.module('copayApp.services') return cb(err, p); }); }); + */ + + }; + // Is this ever used? root.deleteProfile = function(cb) { storage.remove('profile', cb); }; From 90d321033bebcb0632c570abe581a57f41c1fa69 Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Thu, 31 May 2018 17:53:58 +1200 Subject: [PATCH 2/9] Working pretty roughly on iOS with cordova-plugin-secure-storage. --- app-template/config-template.xml | 1 + src/js/services/secureStorageService.js | 93 +++++++++++++++++++++++++ src/js/services/storageService.js | 14 ++-- 3 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 src/js/services/secureStorageService.js diff --git a/app-template/config-template.xml b/app-template/config-template.xml index 8031c8110..e348cbe52 100644 --- a/app-template/config-template.xml +++ b/app-template/config-template.xml @@ -72,6 +72,7 @@ + diff --git a/src/js/services/secureStorageService.js b/src/js/services/secureStorageService.js new file mode 100644 index 000000000..2c3a94703 --- /dev/null +++ b/src/js/services/secureStorageService.js @@ -0,0 +1,93 @@ +'use strict'; + +angular.module('copayApp.services').factory('secureStorageService', function($log, appConfigService, platformInfo) { + var root = {}; + + var ssIsReady = false; + var ssInitialisationFailed = false; + var pending = []; + + var ss = new cordova.plugins.SecureStorage( + function () { + console.log('ss Success'); + ssIsReady = true; + for (var i = 0; i < pending.length; i++) { + pending[i](); + } + pending = []; + }, + function (error) { + console.log('ss Error ' + error); + ssInitialisationFailed = true; + }, + appConfigService.packageNameId); + + + + root.get = function(key, cb) { + $log.debug('secureStorageService.get()'); + if (!ssIsReady) { + $log.debug("ss not ready."); + if (ssInitialisationFailed) { + $log.debug("returning error because initialisation failed."); + cb(new Error("Secure storage initialisation failed.")); + } else { + $log.debug("adding get to pending."); + pending.push(function(){ root.get(key, cb); }); + } + return + } + $log.debug("ss is ready."); + + ss.get( + function (value) { + console.log('ss Success, got ' + value); + cb(null, value); + }, + function (error) { + console.log('ss Error "' + error.message + '" ' + JSON.stringify(error)); + + if (error.message === 'Failure in SecureStorage.get() - The specified item could not be found in the keychain') { + $log.debug("Sending back null error."); + // The callback expects no error, but also no value, if it cannot be found. + cb(null); + } else { + cb(new Error(error)); + } + }, + key); + + }; + + root.set = function(key, value, cb) { + $log.debug('secureStorageService.set()'); + if (!ssIsReady) { + $log.debug("ss not ready."); + if (ssInitialisationFailed) { + $log.debug("returning error because initialisation failed."); + cb(new Error("Secure storage initialisation failed.")); + } else { + $log.debug("adding set to pending."); + pending.push(function(){ root.set(key, value, cb); }); + } + return + } + $log.debug("ss is ready."); + + ss.set( + function (value) { + console.log('ss Success, got ' + value); + cb(); + }, + function (error) { + console.log('ss Error ' + error); + cb(new Error(error)); + }, + key, value); + + }; + + + return root; +}); + diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 3d1ecfeef..05bf51a7a 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -1,6 +1,6 @@ 'use strict'; angular.module('copayApp.services') - .factory('storageService', function(logHeader, fileStorageService, localStorageService, sjcl, $log, lodash, platformInfo, $timeout) { + .factory('storageService', function(logHeader, fileStorageService, localStorageService, sjcl, $log, lodash, platformInfo, secureStorageService, $timeout) { var root = {}; var storage; @@ -116,15 +116,21 @@ angular.module('copayApp.services') }; root.storeNewProfile = function(profile, cb) { - storage.create('profile', profile.toObj(), cb); + //storage.create('profile', profile.toObj(), cb); + secureStorageService.set('profile', profile.toObj(), cb); }; root.storeProfile = function(profile, cb) { - storage.set('profile', profile.toObj(), cb); + //storage.set('profile', profile.toObj(), cb); + secureStorageService.set('profile', profile.toObj(), cb); }; root.getProfile = function(cb) { - storage.get('profile', function(err, str) { + $log.debug("getProfile() 31 7"); + + //storage.get('profile', function(err, str) { + secureStorageService.get('profile', function(err, str) { + if (err || !str) return cb(err); From 4e6eb3295d682bbb86b4ec0d4e632b2e12a6bc0f Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Thu, 31 May 2018 18:08:04 +1200 Subject: [PATCH 3/9] Now works on Android too. --- src/js/services/secureStorageService.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/services/secureStorageService.js b/src/js/services/secureStorageService.js index 2c3a94703..7c374521b 100644 --- a/src/js/services/secureStorageService.js +++ b/src/js/services/secureStorageService.js @@ -47,7 +47,8 @@ angular.module('copayApp.services').factory('secureStorageService', function($lo function (error) { console.log('ss Error "' + error.message + '" ' + JSON.stringify(error)); - if (error.message === 'Failure in SecureStorage.get() - The specified item could not be found in the keychain') { + if (error.message === 'Failure in SecureStorage.get() - The specified item could not be found in the keychain' || + error.message === 'Key [_SS_profile] not found.') { $log.debug("Sending back null error."); // The callback expects no error, but also no value, if it cannot be found. cb(null); From fdc9a8c37b8c620c0181c4f851a87cb93cc1f10b Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Fri, 1 Jun 2018 09:31:14 +1200 Subject: [PATCH 4/9] Tidy up. --- src/js/services/secureStorageService.js | 136 ++++++++++++------------ 1 file changed, 67 insertions(+), 69 deletions(-) diff --git a/src/js/services/secureStorageService.js b/src/js/services/secureStorageService.js index 7c374521b..989c1642a 100644 --- a/src/js/services/secureStorageService.js +++ b/src/js/services/secureStorageService.js @@ -3,89 +3,87 @@ angular.module('copayApp.services').factory('secureStorageService', function($log, appConfigService, platformInfo) { var root = {}; - var ssIsReady = false; - var ssInitialisationFailed = false; - var pending = []; + function CordovaSs() { + var isReady = false; + var initialisationFailed = false; + var pending = []; + + var storage = null; - var ss = new cordova.plugins.SecureStorage( - function () { - console.log('ss Success'); - ssIsReady = true; - for (var i = 0; i < pending.length; i++) { - pending[i](); - } - pending = []; - }, - function (error) { - console.log('ss Error ' + error); - ssInitialisationFailed = true; - }, - appConfigService.packageNameId); - - - root.get = function(key, cb) { - $log.debug('secureStorageService.get()'); - if (!ssIsReady) { - $log.debug("ss not ready."); - if (ssInitialisationFailed) { - $log.debug("returning error because initialisation failed."); + this.get = function(key, cb) { + if (!isReady) { + if (initialisationFailed) { cb(new Error("Secure storage initialisation failed.")); } else { - $log.debug("adding get to pending."); pending.push(function(){ root.get(key, cb); }); } return + } + + storage.get( + function (value) { + cb(null, value); + }, + function (error) { + if (error.message === 'Failure in SecureStorage.get() - The specified item could not be found in the keychain' || // iOS + error.message === 'Key [_SS_profile] not found.') { // Android + // The callback expects no error, but also no value, if it cannot be found. + cb(null); + } else { + cb(new Error(error)); + } + }, + key); } - $log.debug("ss is ready."); - ss.get( - function (value) { - console.log('ss Success, got ' + value); - cb(null, value); - }, - function (error) { - console.log('ss Error "' + error.message + '" ' + JSON.stringify(error)); - - if (error.message === 'Failure in SecureStorage.get() - The specified item could not be found in the keychain' || - error.message === 'Key [_SS_profile] not found.') { - $log.debug("Sending back null error."); - // The callback expects no error, but also no value, if it cannot be found. - cb(null); - } else { + this.set = function(key, value, cb) { + if (!isReady) { + if (initialisationFailed) { + cb(new Error("Secure storage initialisation failed.")); + } else { + pending.push(function(){ root.set(key, value, cb); }); + } + return + } + + storage.set( + function (value) { + cb(); + }, + function (error) { cb(new Error(error)); - } - }, - key); + }, + key, value); + } + if (platformInfo.isCordova) { + storage = new cordova.plugins.SecureStorage( + function () { + console.log('ss Success'); + isReady = true; + for (var i = 0; i < pending.length; i++) { + pending[i](); + } + spending = []; + }, + function (error) { + console.log('ss Error ' + error); + initialisationFailed = true; + }, + appConfigService.packageNameId); + } + + } + + var cordovaSs = new CordovaSs(); + + root.get = function(key, cb) { + cordovaSs.get(key, cb); }; root.set = function(key, value, cb) { - $log.debug('secureStorageService.set()'); - if (!ssIsReady) { - $log.debug("ss not ready."); - if (ssInitialisationFailed) { - $log.debug("returning error because initialisation failed."); - cb(new Error("Secure storage initialisation failed.")); - } else { - $log.debug("adding set to pending."); - pending.push(function(){ root.set(key, value, cb); }); - } - return - } - $log.debug("ss is ready."); - - ss.set( - function (value) { - console.log('ss Success, got ' + value); - cb(); - }, - function (error) { - console.log('ss Error ' + error); - cb(new Error(error)); - }, - key, value); - + cordovaSs.set(key, value, cb); }; From aaad6a1b4a7bfa5e940b23a0995a97a717f7f726 Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Fri, 1 Jun 2018 10:19:26 +1200 Subject: [PATCH 5/9] Refactored to have the mobile and desktop secure storage contained with a more generic secure storage service. --- app-template/config-template.xml | 3 +- src/js/services/mobileSecureStorageService.js | 93 +++++++++++++++ src/js/services/secureStorageService.js | 108 ++++-------------- src/js/services/storageService.js | 2 +- 4 files changed, 120 insertions(+), 86 deletions(-) create mode 100644 src/js/services/mobileSecureStorageService.js diff --git a/app-template/config-template.xml b/app-template/config-template.xml index e348cbe52..39b67d212 100644 --- a/app-template/config-template.xml +++ b/app-template/config-template.xml @@ -72,7 +72,8 @@ - + + diff --git a/src/js/services/mobileSecureStorageService.js b/src/js/services/mobileSecureStorageService.js new file mode 100644 index 000000000..93a2ec591 --- /dev/null +++ b/src/js/services/mobileSecureStorageService.js @@ -0,0 +1,93 @@ +'use strict'; + +angular.module('copayApp.services').factory('mobileSecureStorageService', function($log, appConfigService, platformInfo) { + var root = {}; + + var isReady = false; + var initialisationFailed = false; + var pending = []; + + var storage = null; + + this.get = function(key, cb) { + if (!isReady) { + if (initialisationFailed) { + cb(new Error("mobileSecureStorageService initialisation failed.")); + } else { + pending.push(function(){ root.get(key, cb); }); + } + return + } + + storage.get( + function (value) { + cb(null, value); + }, + function (error) { + if (error.message === 'Failure in SecureStorage.get() - The specified item could not be found in the keychain' || // iOS + error.message === 'Key [_SS_profile] not found.') { // Android + // The callback expects no error, but also no value, if it cannot be found. + cb(null, null); + } else { + cb(new Error(error)); + } + }, + key); + } + + this.set = function(key, value, cb) { + if (!isReady) { + if (initialisationFailed) { + cb(new Error("mobileSecureStorageService initialisation failed.")); + } else { + pending.push(function(){ root.set(key, value, cb); }); + } + return + } + + storage.set( + function (value) { + cb(); + }, + function (error) { + cb(new Error(error)); + }, + key, value); + } + + if (platformInfo.isCordova) { + storage = new cordova.plugins.SecureStorage( + function () { + $log.debug('mobileSecureStorageService initialised.'); + isReady = true; + for (var i = 0; i < pending.length; i++) { + pending[i](); + } + pending = []; + }, + function (error) { + c$log.debug('mobileSecureStorageService initialisation failed. ' + error); + initialisationFailed = true; + }, + appConfigService.packageNameId); + } + + root.get = function(key, cb) { + if (platformInfo.isMobile) { + storage.get(key, cb); + } else { + cb(new Error('mobileSecureStorageService is only available on mobile.')); + } + }; + + root.set = function(key, value, cb) { + if (platformInfo.isMobile) { + storage.set(key, v, cb); + } else { + cb(new Error('mobileSecureStorageService is only available on mobile.')); + } + }; + + return root; +}); + diff --git a/src/js/services/secureStorageService.js b/src/js/services/secureStorageService.js index 989c1642a..c066109c2 100644 --- a/src/js/services/secureStorageService.js +++ b/src/js/services/secureStorageService.js @@ -1,92 +1,32 @@ 'use strict'; -angular.module('copayApp.services').factory('secureStorageService', function($log, appConfigService, platformInfo) { +angular.module('copayApp.services').factory('secureStorageService', function(desktopSecureStorageService, localStorageService, $log, mobileSecureStorageService, platformInfo) { var root = {}; - function CordovaSs() { - var isReady = false; - var initialisationFailed = false; - var pending = []; - - var storage = null; - - - this.get = function(key, cb) { - if (!isReady) { - if (initialisationFailed) { - cb(new Error("Secure storage initialisation failed.")); - } else { - pending.push(function(){ root.get(key, cb); }); - } - return - } - - storage.get( - function (value) { - cb(null, value); - }, - function (error) { - if (error.message === 'Failure in SecureStorage.get() - The specified item could not be found in the keychain' || // iOS - error.message === 'Key [_SS_profile] not found.') { // Android - // The callback expects no error, but also no value, if it cannot be found. - cb(null); - } else { - cb(new Error(error)); - } - }, - key); - } - - this.set = function(key, value, cb) { - if (!isReady) { - if (initialisationFailed) { - cb(new Error("Secure storage initialisation failed.")); - } else { - pending.push(function(){ root.set(key, value, cb); }); - } - return - } - - storage.set( - function (value) { - cb(); - }, - function (error) { - cb(new Error(error)); - }, - key, value); - } - - if (platformInfo.isCordova) { - storage = new cordova.plugins.SecureStorage( - function () { - console.log('ss Success'); - isReady = true; - for (var i = 0; i < pending.length; i++) { - pending[i](); - } - spending = []; - }, - function (error) { - console.log('ss Error ' + error); - initialisationFailed = true; - }, - appConfigService.packageNameId); - } - + // To make wrong code look wrong + function alteredKeyIndicatingDesireForSecureStorage(key) { + return key + ":desiredSecure"; } - var cordovaSs = new CordovaSs(); - - root.get = function(key, cb) { - cordovaSs.get(key, cb); - }; - - root.set = function(key, value, cb) { - cordovaSs.set(key, value, cb); - }; - + root.get = function(k, cb) { + if (platformInfo.isMobile) { + mobileSecureStorageService.get(k, cb); + } else if (platformInfo.isNW) { + desktopSecureStorageService.get(k, cb); + } else { // Browser + localStorageService.get(alteredKeyIndicatingDesireForSecureStorage(k), cb); + } + } + root.set = function(k, v, cb) { + if (platformInfo.isMobile) { + mobileSecureStorageService.set(k, v, cb); + } else if (platformInfo.isNW) { + desktopSecureStorageService.set(k, v, cb); + } else { // Browser + localStorageService.set(alteredKeyIndicatingDesireForSecureStorage(k), v, cb); + } + } + return root; -}); - +}); \ No newline at end of file diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 05bf51a7a..2cc6da730 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -126,7 +126,7 @@ angular.module('copayApp.services') }; root.getProfile = function(cb) { - $log.debug("getProfile() 31 7"); + $log.debug("getProfile() 1 8"); //storage.get('profile', function(err, str) { secureStorageService.get('profile', function(err, str) { From 17685dd810d46895e04fa7489eb9fcca66f1e1a2 Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Fri, 1 Jun 2018 10:42:38 +1200 Subject: [PATCH 6/9] Fixed some issues after the refactor. --- src/js/services/mobileSecureStorageService.js | 104 +++++++++--------- src/js/services/secureStorageService.js | 3 + 2 files changed, 55 insertions(+), 52 deletions(-) diff --git a/src/js/services/mobileSecureStorageService.js b/src/js/services/mobileSecureStorageService.js index 93a2ec591..56c3e2df6 100644 --- a/src/js/services/mobileSecureStorageService.js +++ b/src/js/services/mobileSecureStorageService.js @@ -9,52 +9,6 @@ angular.module('copayApp.services').factory('mobileSecureStorageService', functi var storage = null; - this.get = function(key, cb) { - if (!isReady) { - if (initialisationFailed) { - cb(new Error("mobileSecureStorageService initialisation failed.")); - } else { - pending.push(function(){ root.get(key, cb); }); - } - return - } - - storage.get( - function (value) { - cb(null, value); - }, - function (error) { - if (error.message === 'Failure in SecureStorage.get() - The specified item could not be found in the keychain' || // iOS - error.message === 'Key [_SS_profile] not found.') { // Android - // The callback expects no error, but also no value, if it cannot be found. - cb(null, null); - } else { - cb(new Error(error)); - } - }, - key); - } - - this.set = function(key, value, cb) { - if (!isReady) { - if (initialisationFailed) { - cb(new Error("mobileSecureStorageService initialisation failed.")); - } else { - pending.push(function(){ root.set(key, value, cb); }); - } - return - } - - storage.set( - function (value) { - cb(); - }, - function (error) { - cb(new Error(error)); - }, - key, value); - } - if (platformInfo.isCordova) { storage = new cordova.plugins.SecureStorage( function () { @@ -73,19 +27,65 @@ angular.module('copayApp.services').factory('mobileSecureStorageService', functi } root.get = function(key, cb) { - if (platformInfo.isMobile) { - storage.get(key, cb); - } else { + + if (!platformInfo.isMobile) { cb(new Error('mobileSecureStorageService is only available on mobile.')); + return; } + + if (!isReady) { + if (initialisationFailed) { + cb(new Error('mobileSecureStorageService initialisation failed.')); + } else { + $log.debug('mss.get() queued.'); + pending.push(function(){ root.get(key, cb); }); + } + return; + } + + $log.debug('mss.get() running.'); + storage.get( + function (value) { + $log.debug('mss.get() succeeded.'); + cb(null, value); + }, + function (error) { + $log.debug('mss get failed. ' + error); + if (error.message === 'Failure in SecureStorage.get() - The specified item could not be found in the keychain' || // iOS + error.message === 'Key [_SS_profile] not found.') { // Android + // The callback expects no error, but also no value, if it cannot be found. + cb(null, null); + } else { + cb(new Error(error)); + } + }, + key); }; root.set = function(key, value, cb) { - if (platformInfo.isMobile) { - storage.set(key, v, cb); - } else { + + if (!platformInfo.isMobile) { cb(new Error('mobileSecureStorageService is only available on mobile.')); + } + + if (!isReady) { + if (initialisationFailed) { + cb(new Error('mobileSecureStorageService initialisation failed.')); + } else { + pending.push(function(){ root.set(key, value, cb); }); + } + return; } + + storage.set( + function (value) { + cb(); + }, + function (error) { + cb(new Error(error)); + }, + key, value); + }; return root; diff --git a/src/js/services/secureStorageService.js b/src/js/services/secureStorageService.js index c066109c2..e7179bf62 100644 --- a/src/js/services/secureStorageService.js +++ b/src/js/services/secureStorageService.js @@ -9,9 +9,12 @@ angular.module('copayApp.services').factory('secureStorageService', function(des } root.get = function(k, cb) { + $log.debug('ss.get()'); if (platformInfo.isMobile) { + $log.debug('ss.get() using mobile.'); mobileSecureStorageService.get(k, cb); } else if (platformInfo.isNW) { + $log.debug('ss.get() using desktop.'); desktopSecureStorageService.get(k, cb); } else { // Browser localStorageService.get(alteredKeyIndicatingDesireForSecureStorage(k), cb); From f483fd81d8902bcd01c05f740dc8ebfd309dbb77 Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Fri, 1 Jun 2018 11:53:04 +1200 Subject: [PATCH 7/9] Removed deleteProfile() as it is not used. --- src/js/services/storageService.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 2cc6da730..df135a946 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -116,19 +116,16 @@ angular.module('copayApp.services') }; root.storeNewProfile = function(profile, cb) { - //storage.create('profile', profile.toObj(), cb); secureStorageService.set('profile', profile.toObj(), cb); }; root.storeProfile = function(profile, cb) { - //storage.set('profile', profile.toObj(), cb); secureStorageService.set('profile', profile.toObj(), cb); }; root.getProfile = function(cb) { $log.debug("getProfile() 1 8"); - //storage.get('profile', function(err, str) { secureStorageService.get('profile', function(err, str) { if (err || !str) @@ -148,10 +145,6 @@ angular.module('copayApp.services') }); }; - root.deleteProfile = function(cb) { - storage.remove('profile', cb); - }; - root.setFeedbackInfo = function(feedbackValues, cb) { storage.set('feedback', feedbackValues, cb); }; From c5121afd7ccd99db0ba02f0ad7c7d755f88c799c Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Fri, 1 Jun 2018 15:04:52 +1200 Subject: [PATCH 8/9] Placeholder desktopSecureStorageService. --- src/js/services/desktopSecureStorageService.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/js/services/desktopSecureStorageService.js diff --git a/src/js/services/desktopSecureStorageService.js b/src/js/services/desktopSecureStorageService.js new file mode 100644 index 000000000..6e148da2c --- /dev/null +++ b/src/js/services/desktopSecureStorageService.js @@ -0,0 +1,6 @@ +'use strict'; + +angular.module('copayApp.services').factory('desktopSecureStorageService', function($log) { + // Placeholder + return {}; +}); \ No newline at end of file From 8d94a244bcfd71934b85305f750a0735c97977ca Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Fri, 1 Jun 2018 15:25:08 +1200 Subject: [PATCH 9/9] Removed some debug messages. --- src/js/services/mobileSecureStorageService.js | 5 ----- src/js/services/secureStorageService.js | 3 --- src/js/services/storageService.js | 2 -- 3 files changed, 10 deletions(-) diff --git a/src/js/services/mobileSecureStorageService.js b/src/js/services/mobileSecureStorageService.js index 56c3e2df6..f9994fdf8 100644 --- a/src/js/services/mobileSecureStorageService.js +++ b/src/js/services/mobileSecureStorageService.js @@ -12,7 +12,6 @@ angular.module('copayApp.services').factory('mobileSecureStorageService', functi if (platformInfo.isCordova) { storage = new cordova.plugins.SecureStorage( function () { - $log.debug('mobileSecureStorageService initialised.'); isReady = true; for (var i = 0; i < pending.length; i++) { pending[i](); @@ -20,7 +19,6 @@ angular.module('copayApp.services').factory('mobileSecureStorageService', functi pending = []; }, function (error) { - c$log.debug('mobileSecureStorageService initialisation failed. ' + error); initialisationFailed = true; }, appConfigService.packageNameId); @@ -37,16 +35,13 @@ angular.module('copayApp.services').factory('mobileSecureStorageService', functi if (initialisationFailed) { cb(new Error('mobileSecureStorageService initialisation failed.')); } else { - $log.debug('mss.get() queued.'); pending.push(function(){ root.get(key, cb); }); } return; } - $log.debug('mss.get() running.'); storage.get( function (value) { - $log.debug('mss.get() succeeded.'); cb(null, value); }, function (error) { diff --git a/src/js/services/secureStorageService.js b/src/js/services/secureStorageService.js index e7179bf62..c066109c2 100644 --- a/src/js/services/secureStorageService.js +++ b/src/js/services/secureStorageService.js @@ -9,12 +9,9 @@ angular.module('copayApp.services').factory('secureStorageService', function(des } root.get = function(k, cb) { - $log.debug('ss.get()'); if (platformInfo.isMobile) { - $log.debug('ss.get() using mobile.'); mobileSecureStorageService.get(k, cb); } else if (platformInfo.isNW) { - $log.debug('ss.get() using desktop.'); desktopSecureStorageService.get(k, cb); } else { // Browser localStorageService.get(alteredKeyIndicatingDesireForSecureStorage(k), cb); diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index df135a946..7c4ad0a60 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -124,8 +124,6 @@ angular.module('copayApp.services') }; root.getProfile = function(cb) { - $log.debug("getProfile() 1 8"); - secureStorageService.get('profile', function(err, str) { if (err || !str)