Compare commits

...

10 commits

Author SHA1 Message Date
Sebastiaan Pasma
3eada5ad7c Remove feature for desktopSecureStorage 2018-06-28 14:23:50 +02:00
Sebastiaan Pasma
4a97292748 compiled keytar packages 2018-06-27 17:33:37 +02:00
Sebastiaan Pasma
c7abf03d54 use secureStorage on Mac 2018-06-27 16:52:50 +02:00
Sebastiaan Pasma
5f4eb9747e added isMac isWindows isLinux & isDesktopApp to platformInfo 2018-06-27 16:50:55 +02:00
Sebastiaan Pasma
c40b6c168a Merge remote-tracking branch 'origin/wallet/sprint/18' into wallet/task/366 2018-06-26 14:11:34 +02:00
Sebastiaan Pasma
900630807a Desktop secure storage update, fallback to previous storage on error 2018-06-11 11:22:04 +02:00
Sebastiaan Pasma
80299cd99d Merge remote-tracking branch 'origin/wallet/task/351' into wallet/task/366 2018-06-06 14:23:59 +02:00
Sebastiaan Pasma
7c5a61a88b desktopSecureStorageService update 2018-06-01 13:54:46 +02:00
Sebastiaan Pasma
e4983d3604 Merge remote-tracking branch 'origin/wallet/task/351' into wallet/task/366
# Conflicts:
#	src/js/services/storageService.js
2018-06-01 10:20:20 +02:00
Sebastiaan Pasma
f70e8607ea DesktopSecureStorageService 2018-05-31 16:13:24 +02:00
10 changed files with 93 additions and 10 deletions

View file

@ -81,6 +81,7 @@
"grunt-exec": "^1.0.0", "grunt-exec": "^1.0.0",
"grunt-nw-builder": "^2.0.3", "grunt-nw-builder": "^2.0.3",
"grunt-sass": "^1.2.0", "grunt-sass": "^1.2.0",
"keytar": "git+https://github.com/spasma/node-keytar.git",
"load-grunt-tasks": "^3.5.0", "load-grunt-tasks": "^3.5.0",
"shelljs": "^0.3.0", "shelljs": "^0.3.0",
"android-versions": "^1.2.1", "android-versions": "^1.2.1",

View file

@ -1,6 +1,82 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('desktopSecureStorageService', function($log) { angular.module('copayApp.services').factory('desktopSecureStorageService', function($log, appConfigService, platformInfo, lodash, localStorageService) {
// Placeholder var root = {};
return {}; var storage = null;
var serviceName = appConfigService.packageNameId;
var initialisationFailed = false;
if (platformInfo.isNW) {
try {
var os = require('os');
var arch = (os.arch() === 'x64' || process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432')) ? 'x64':'ia32';
var file = './keytar/keytar-prebuild-v4.1.1-node-v51-'+process.platform+'-'+arch+'.node';
storage = require('keytar');
storage.setKeytarInstance(require(file));
} catch (e) {
console.log(e);
initialisationFailed = true;
}
}
root.get = function(key, cb) {
if (!platformInfo.isNW) {
cb(new Error('desktopSecureStorageService is only available on NW.js desktop.'));
return;
}
if (initialisationFailed)
return localStorageService.get(key, cb);
storage.getPassword(serviceName, key).then(function(result) {
return cb(null, result); // XX SP: result is null if no value is found as it should
}).catch(function (error) {
cb(new Error(error));
});
};
root.remove = function(key, cb) {
if (!platformInfo.isNW) {
cb(new Error('desktopSecureStorageService is only available on NW.js desktop.'));
return;
}
if (initialisationFailed)
return localStorageService.remove(key, cb);
storage.removePassword(serviceName, key).then(function (value) {
cb();
}).catch(function (error) {
console.log(error);
cb(new Error(error));
})
};
root.set = function(key, value, cb) {
if (!platformInfo.isNW) {
cb(new Error('desktopSecureStorageService is only available on NW.js desktop.'));
return;
}
if (initialisationFailed)
return localStorageService.set(key, value, cb);
if (lodash.isObject(value)) {
value = JSON.stringify(value);
}
if (value && !lodash.isString(value)) {
value = value.toString();
}
storage.deletePassword(serviceName, key).then(function (result) {
storage.setPassword(serviceName, key, value).then(function (value) {
cb();
}).catch(function (error) {
console.log(error);
cb(new Error(error));
})
});
};
return root;
}); });

View file

@ -66,5 +66,11 @@ angular.module('copayApp.services').factory('platformInfo', function($window) {
ret.versionIntelTEE = getVersionIntelTee(); ret.versionIntelTEE = getVersionIntelTee();
ret.supportsIntelTEE = ret.versionIntelTEE.length > 0; ret.supportsIntelTEE = ret.versionIntelTEE.length > 0;
ret.isMac = typeof process !== 'undefined'?process.platform === 'darwin':false;
ret.isWindows = typeof process !== 'undefined'?process.platform === 'win32':false;
ret.isLinux = typeof process !== 'undefined'?process.platform === 'linux':false;
ret.isDesktopApp = ret.isNW && (ret.isMac || ret.isWindows || ret.isLinux);
return ret; return ret;
}); });

View file

@ -528,7 +528,7 @@ angular.module('copayApp.services')
var walletId = client.credentials.walletId var walletId = client.credentials.walletId
if (!root.profile.addWallet(JSON.parse(client.export()))) if (root.profile && !root.profile.addWallet(JSON.parse(client.export())))
return cb(gettextCatalog.getString("Wallet already in {{appName}}", { return cb(gettextCatalog.getString("Wallet already in {{appName}}", {
appName: appConfigService.nameCase appName: appConfigService.nameCase
})); }));

View file

@ -121,7 +121,7 @@ angular.module('copayApp.services')
root.storeProfile = function(profile, cb) { root.storeProfile = function(profile, cb) {
var profileString = profile.toObj(); var profileString = profile.toObj();
if (platformInfo.isNW) { if (platformInfo.isNW && !platformInfo.isMac) {
storage.set('profile', profileString, cb); storage.set('profile', profileString, cb);
} else { } else {
secureStorageService.set('profile', profileString, cb); secureStorageService.set('profile', profileString, cb);
@ -205,7 +205,7 @@ angular.module('copayApp.services')
* @param {getProfileCallback} cb * @param {getProfileCallback} cb
*/ */
root.getProfile = function(cb) { root.getProfile = function(cb) {
if (platformInfo.isNW) { if (platformInfo.isNW && !platformInfo.isMac) {
storage.get('profile', function(getErr, getStr) { storage.get('profile', function(getErr, getStr) {
_onOldProfileRetrieved(getErr, getStr, cb); _onOldProfileRetrieved(getErr, getStr, cb);
}); });
@ -728,15 +728,15 @@ angular.module('copayApp.services')
root.setReceivedTransactions = function(walletId, txIds, cb) { root.setReceivedTransactions = function(walletId, txIds, cb) {
storage.set('receivedTxs-' + walletId, txIds, cb); storage.set('receivedTxs-' + walletId, txIds, cb);
} };
root.getReceivedTransactions = function(walletId, cb) { root.getReceivedTransactions = function(walletId, cb) {
storage.get('receivedTxs-' + walletId, cb); storage.get('receivedTxs-' + walletId, cb);
} };
root.removeReceivedTransactions = function(walletId, cb) { root.removeReceivedTransactions = function(walletId, cb) {
storage.remove('receivedTxs-' + walletId, cb); storage.remove('receivedTxs-' + walletId, cb);
} };
root.checkIfFlagIsSet = function(key) { root.checkIfFlagIsSet = function(key) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
@ -748,7 +748,7 @@ angular.module('copayApp.services')
} }
}); });
}); });
} };
return root; return root;
}); });

Binary file not shown.

Binary file not shown.

Binary file not shown.