rm encrypted to storage
This commit is contained in:
parent
b9881c1147
commit
bbd762a1fe
5 changed files with 21 additions and 21 deletions
2
copay.js
2
copay.js
|
|
@ -11,7 +11,7 @@ module.exports.HDParams = require('./js/models/core/HDParams');
|
||||||
// components
|
// components
|
||||||
var Async = module.exports.Async = require('./js/models/network/Async');
|
var Async = module.exports.Async = require('./js/models/network/Async');
|
||||||
var Insight = module.exports.Insight = require('./js/models/blockchain/Insight');
|
var Insight = module.exports.Insight = require('./js/models/blockchain/Insight');
|
||||||
var StorageEncrypted = module.exports.StorageEncrypted = require('./js/models/storage/Encrypted');
|
var Storage = module.exports.Storage = require('./js/models/Storage');
|
||||||
|
|
||||||
module.exports.WalletFactory = require('./js/models/core/WalletFactory');
|
module.exports.WalletFactory = require('./js/models/core/WalletFactory');
|
||||||
module.exports.Wallet = require('./js/models/core/Wallet');
|
module.exports.Wallet = require('./js/models/core/Wallet');
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,11 @@ var PrivateKey = require('./PrivateKey');
|
||||||
var Wallet = require('./Wallet');
|
var Wallet = require('./Wallet');
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
var log = require('../../log');
|
var log = require('../../log');
|
||||||
|
var PluginManager = require('./PluginManager');
|
||||||
var Async = module.exports.Async = require('../network/Async');
|
var Async = module.exports.Async = require('../network/Async');
|
||||||
var Insight = module.exports.Insight = require('../blockchain/Insight');
|
var Insight = module.exports.Insight = require('../blockchain/Insight');
|
||||||
var StorageEncrypted = module.exports.StorageEncrypted = require('../storage/Encrypted');
|
|
||||||
var preconditions = require('preconditions').singleton();
|
var preconditions = require('preconditions').singleton();
|
||||||
|
var Storage = module.exports.Storage = require('../Storage');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc
|
* @desc
|
||||||
|
|
@ -36,9 +37,9 @@ function WalletFactory(config, version) {
|
||||||
var self = this;
|
var self = this;
|
||||||
config = config || {};
|
config = config || {};
|
||||||
|
|
||||||
this.pluginManager = new copay.PluginManager(config);
|
this.pluginManager = new PluginManager(config);
|
||||||
|
|
||||||
this.Storage = config.Storage || StorageEncrypted;
|
this.Storage = config.Storage || Storage;
|
||||||
this.Network = config.Network || Async;
|
this.Network = config.Network || Async;
|
||||||
this.Blockchain = config.Blockchain || Insight;
|
this.Blockchain = config.Blockchain || Insight;
|
||||||
this.storage = new this.Storage({storage: this.pluginManager.get('STORAGE')});
|
this.storage = new this.Storage({storage: this.pluginManager.get('STORAGE')});
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var chai = chai || require('chai');
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
var is_browser = typeof process == 'undefined' || typeof process.versions === 'undefined';
|
var is_browser = typeof process == 'undefined' || typeof process.versions === 'undefined';
|
||||||
var copay = copay || require('../copay');
|
var copay = copay || require('../copay');
|
||||||
var Encrypted = copay.StorageEncrypted;
|
var Storage = copay.Storage;
|
||||||
|
|
||||||
var fakeWallet = 'fake-wallet-id';
|
var fakeWallet = 'fake-wallet-id';
|
||||||
var timeStamp = Date.now();
|
var timeStamp = Date.now();
|
||||||
|
|
@ -11,22 +11,22 @@ var localMock = require('./mocks/FakeLocalStorage');
|
||||||
var sessionMock = require('./mocks/FakeLocalStorage');
|
var sessionMock = require('./mocks/FakeLocalStorage');
|
||||||
|
|
||||||
|
|
||||||
describe('Storage/Encrypted model', function() {
|
describe('Storage model', function() {
|
||||||
var s = new Encrypted({
|
var s = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
});
|
});
|
||||||
s._setPassphrase('mysupercoolpassword');
|
s._setPassphrase('mysupercoolpassword');
|
||||||
|
|
||||||
it('should create an instance', function() {
|
it('should create an instance', function() {
|
||||||
var s2 = new Encrypted({
|
var s2 = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
});
|
});
|
||||||
should.exist(s2);
|
should.exist(s2);
|
||||||
});
|
});
|
||||||
it('should fail when encrypting without a password', function() {
|
it('should fail when encrypting without a password', function() {
|
||||||
var s2 = new Encrypted({
|
var s2 = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
});
|
});
|
||||||
|
|
@ -71,7 +71,7 @@ describe('Storage/Encrypted model', function() {
|
||||||
|
|
||||||
describe('#export', function() {
|
describe('#export', function() {
|
||||||
it('should export the encrypted wallet', function() {
|
it('should export the encrypted wallet', function() {
|
||||||
var storage = new Encrypted({
|
var storage = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
password: 'password',
|
password: 'password',
|
||||||
|
|
@ -89,7 +89,7 @@ describe('Storage/Encrypted model', function() {
|
||||||
|
|
||||||
describe('#remove', function() {
|
describe('#remove', function() {
|
||||||
it('should remove an item', function() {
|
it('should remove an item', function() {
|
||||||
var s = new Encrypted({
|
var s = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
password: 'password'
|
password: 'password'
|
||||||
|
|
@ -105,7 +105,7 @@ describe('Storage/Encrypted model', function() {
|
||||||
|
|
||||||
describe('#getWalletIds', function() {
|
describe('#getWalletIds', function() {
|
||||||
it('should get wallet ids', function() {
|
it('should get wallet ids', function() {
|
||||||
var s = new Encrypted({
|
var s = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
password: 'password'
|
password: 'password'
|
||||||
|
|
@ -118,7 +118,7 @@ describe('Storage/Encrypted model', function() {
|
||||||
|
|
||||||
describe('#getName #setName', function() {
|
describe('#getName #setName', function() {
|
||||||
it('should get/set names', function() {
|
it('should get/set names', function() {
|
||||||
var s = new Encrypted({
|
var s = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
password: 'password'
|
password: 'password'
|
||||||
|
|
@ -130,7 +130,7 @@ describe('Storage/Encrypted model', function() {
|
||||||
|
|
||||||
describe('#getLastOpened #setLastOpened', function() {
|
describe('#getLastOpened #setLastOpened', function() {
|
||||||
it('should get/set names', function() {
|
it('should get/set names', function() {
|
||||||
var s = new Encrypted({
|
var s = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
password: 'password'
|
password: 'password'
|
||||||
|
|
@ -143,7 +143,7 @@ describe('Storage/Encrypted model', function() {
|
||||||
if (is_browser) {
|
if (is_browser) {
|
||||||
describe('#getSessionId', function() {
|
describe('#getSessionId', function() {
|
||||||
it('should get SessionId', function() {
|
it('should get SessionId', function() {
|
||||||
var s = new Encrypted({
|
var s = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
password: 'password'
|
password: 'password'
|
||||||
|
|
@ -158,7 +158,7 @@ describe('Storage/Encrypted model', function() {
|
||||||
|
|
||||||
describe('#getWallets', function() {
|
describe('#getWallets', function() {
|
||||||
it('should retreive wallets from storage', function() {
|
it('should retreive wallets from storage', function() {
|
||||||
var s = new Encrypted({
|
var s = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
password: 'password'
|
password: 'password'
|
||||||
|
|
@ -178,7 +178,7 @@ describe('Storage/Encrypted model', function() {
|
||||||
});
|
});
|
||||||
describe('#deleteWallet', function() {
|
describe('#deleteWallet', function() {
|
||||||
it('should delete a wallet', function() {
|
it('should delete a wallet', function() {
|
||||||
var s = new Encrypted({
|
var s = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
password: 'password'
|
password: 'password'
|
||||||
|
|
@ -198,7 +198,7 @@ describe('Storage/Encrypted model', function() {
|
||||||
|
|
||||||
describe('#setFromObj', function() {
|
describe('#setFromObj', function() {
|
||||||
it('set localstorage from an object', function() {
|
it('set localstorage from an object', function() {
|
||||||
var s = new Encrypted({
|
var s = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
password: 'password'
|
password: 'password'
|
||||||
|
|
@ -218,7 +218,7 @@ describe('Storage/Encrypted model', function() {
|
||||||
|
|
||||||
describe('#globals', function() {
|
describe('#globals', function() {
|
||||||
it('should set, get and remove keys', function() {
|
it('should set, get and remove keys', function() {
|
||||||
var s = new Encrypted({
|
var s = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
password: 'password'
|
password: 'password'
|
||||||
|
|
@ -237,7 +237,7 @@ describe('Storage/Encrypted model', function() {
|
||||||
|
|
||||||
describe('session storage', function() {
|
describe('session storage', function() {
|
||||||
it('should get a session ID', function() {
|
it('should get a session ID', function() {
|
||||||
var s = new Encrypted({
|
var s = new Storage({
|
||||||
storage: localMock,
|
storage: localMock,
|
||||||
sessionStorage: sessionMock,
|
sessionStorage: sessionMock,
|
||||||
password: 'password'
|
password: 'password'
|
||||||
|
|
@ -94,7 +94,6 @@ var createBundle = function(opts) {
|
||||||
b.require('./plugins/LocalStorage', {
|
b.require('./plugins/LocalStorage', {
|
||||||
expose: '../plugins/LocalStorage'
|
expose: '../plugins/LocalStorage'
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b.require('./config', {
|
b.require('./config', {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue