Wallet/src/js/services/secureStorageService.js

32 lines
994 B
JavaScript
Raw Normal View History

'use strict';
angular.module('copayApp.services').factory('secureStorageService', function(desktopSecureStorageService, localStorageService, $log, mobileSecureStorageService, platformInfo) {
var root = {};
// To make wrong code look wrong
function alteredKeyIndicatingDesireForSecureStorage(key) {
return key + ":desiredSecure";
}
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);
2018-06-01 09:31:14 +12:00
}
}
return root;
});