change name to Encrypted
This commit is contained in:
parent
1ce3f82d0a
commit
2849f773e2
8 changed files with 66 additions and 49 deletions
10
js/app.js
10
js/app.js
|
|
@ -37,9 +37,17 @@ var modules = [
|
|||
'copayApp.directives',
|
||||
];
|
||||
|
||||
if (config.plugins.googleDrive)
|
||||
if (config.plugins.length)
|
||||
modules.push('angularLoad');
|
||||
|
||||
if (config.plugins.googleDrive) {
|
||||
var googleDrive = require('../plugins/googleDrive');
|
||||
var a = new googleDrive();
|
||||
a.init();
|
||||
console.log('[app.js.41:new:]',a); //TODO
|
||||
}
|
||||
|
||||
|
||||
var copayApp = window.copayApp = angular.module('copayApp', modules);
|
||||
|
||||
copayApp.config(function($sceDelegateProvider) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ var _ = require('underscore');
|
|||
var log = require('../../log');
|
||||
var Async = module.exports.Async = require('../network/Async');
|
||||
var Insight = module.exports.Insight = require('../blockchain/Insight');
|
||||
var StorageLocalEncrypted = module.exports.StorageLocalEncrypted = require('../storage/LocalEncrypted');
|
||||
var StorageEncrypted = module.exports.StorageEncrypted = require('../storage/Encrypted');
|
||||
var preconditions = require('preconditions').singleton();
|
||||
|
||||
/**
|
||||
|
|
@ -36,7 +36,7 @@ function WalletFactory(config, version) {
|
|||
var self = this;
|
||||
config = config || {};
|
||||
|
||||
this.Storage = config.Storage || StorageLocalEncrypted;
|
||||
this.Storage = config.Storage || StorageEncrypted;
|
||||
this.Network = config.Network || Async;
|
||||
this.Blockchain = config.Blockchain || Insight;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,12 @@ function Storage(opts) {
|
|||
this._setPassphrase(opts.password);
|
||||
|
||||
try {
|
||||
this.localStorage = opts.localStorage || localStorage;
|
||||
this.storage = opts.storage || localStorage;
|
||||
this.sessionStorage = opts.sessionStorage || sessionStorage;
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
console.log('Error in storage:', e); //TODO
|
||||
};
|
||||
|
||||
preconditions.checkState(this.localStorage, 'No localstorage found');
|
||||
preconditions.checkState(this.sessionStorage, 'No sessionStorage found');
|
||||
}
|
||||
|
|
@ -54,7 +57,7 @@ Storage.prototype._decrypt = function(base64) {
|
|||
|
||||
Storage.prototype._read = function(k) {
|
||||
var ret;
|
||||
ret = this.localStorage.getItem(k);
|
||||
ret = this.storage.getItem(k);
|
||||
if (!ret) return null;
|
||||
ret = this._decrypt(ret);
|
||||
if (!ret) return null;
|
||||
|
|
@ -67,23 +70,23 @@ Storage.prototype._write = function(k, v) {
|
|||
v = JSON.stringify(v);
|
||||
v = this._encrypt(v);
|
||||
|
||||
this.localStorage.setItem(k, v);
|
||||
this.storage.setItem(k, v);
|
||||
};
|
||||
|
||||
// get value by key
|
||||
Storage.prototype.getGlobal = function(k) {
|
||||
var item = this.localStorage.getItem(k);
|
||||
var item = this.storage.getItem(k);
|
||||
return item == 'undefined' ? undefined : item;
|
||||
};
|
||||
|
||||
// set value for key
|
||||
Storage.prototype.setGlobal = function(k, v) {
|
||||
this.localStorage.setItem(k, typeof v === 'object' ? JSON.stringify(v) : v);
|
||||
this.storage.setItem(k, typeof v === 'object' ? JSON.stringify(v) : v);
|
||||
};
|
||||
|
||||
// remove value for key
|
||||
Storage.prototype.removeGlobal = function(k) {
|
||||
this.localStorage.removeItem(k);
|
||||
this.storage.removeItem(k);
|
||||
};
|
||||
|
||||
Storage.prototype.getSessionId = function() {
|
||||
|
|
@ -127,8 +130,8 @@ Storage.prototype.getWalletIds = function() {
|
|||
var walletIds = [];
|
||||
var uniq = {};
|
||||
|
||||
for (var i = 0; i < this.localStorage.length; i++) {
|
||||
var key = this.localStorage.key(i);
|
||||
for (var i = 0; i < this.storage.length; i++) {
|
||||
var key = this.storage.key(i);
|
||||
var split = key.split('::');
|
||||
if (split.length == 2) {
|
||||
var walletId = split[0];
|
||||
|
|
@ -162,8 +165,8 @@ Storage.prototype.deleteWallet = function(walletId) {
|
|||
var toDelete = {};
|
||||
toDelete['nameFor::' + walletId] = 1;
|
||||
|
||||
for (var i = 0; i < this.localStorage.length; i++) {
|
||||
var key = this.localStorage.key(i);
|
||||
for (var i = 0; i < this.storage.length; i++) {
|
||||
var key = this.storage.key(i);
|
||||
var split = key.split('::');
|
||||
if (split.length == 2 && split[0] === walletId) {
|
||||
toDelete[key] = 1;
|
||||
|
|
@ -192,7 +195,7 @@ Storage.prototype.setFromObj = function(walletId, obj) {
|
|||
|
||||
// remove all values
|
||||
Storage.prototype.clearAll = function() {
|
||||
this.localStorage.clear();
|
||||
this.storage.clear();
|
||||
};
|
||||
|
||||
Storage.prototype.import = function(base64) {
|
||||
Loading…
Add table
Add a link
Reference in a new issue