mirror of
https://github.com/moparisthebest/mail
synced 2024-11-26 02:42:17 -05:00
inject pgpbuilder
This commit is contained in:
parent
debb06c943
commit
3d2fdc7f8c
@ -141,9 +141,8 @@ module.exports = function(grunt) {
|
|||||||
'imap-client/node_modules/mime/src/mime.js',
|
'imap-client/node_modules/mime/src/mime.js',
|
||||||
'pgpmailer/src/*.js',
|
'pgpmailer/src/*.js',
|
||||||
'pgpmailer/node_modules/simplesmtp/src/*',
|
'pgpmailer/node_modules/simplesmtp/src/*',
|
||||||
'pgpmailer/node_modules/pgpbuilder/src/*.js',
|
'pgpbuilder/src/*.js',
|
||||||
'pgpmailer/node_modules/pgpbuilder/node_modules/mailbuilder/src/*.js',
|
'pgpbuilder/node_modules/mailbuilder/src/*.js'
|
||||||
'pgpmailer/node_modules/mailbuilder/src/*.js'
|
|
||||||
],
|
],
|
||||||
dest: 'src/lib/'
|
dest: 'src/lib/'
|
||||||
},
|
},
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
"crypto-lib": "https://github.com/whiteout-io/crypto-lib/tarball/master",
|
"crypto-lib": "https://github.com/whiteout-io/crypto-lib/tarball/master",
|
||||||
"imap-client": "https://github.com/whiteout-io/imap-client/tarball/master",
|
"imap-client": "https://github.com/whiteout-io/imap-client/tarball/master",
|
||||||
"pgpmailer": "https://github.com/whiteout-io/pgpmailer/tarball/dev/pgpbuilder",
|
"pgpmailer": "https://github.com/whiteout-io/pgpmailer/tarball/dev/pgpbuilder",
|
||||||
|
"pgpbuilder": "https://github.com/whiteout-io/pgpbuilder/tarball/master",
|
||||||
"requirejs": "2.1.10"
|
"requirejs": "2.1.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -16,6 +16,7 @@ define(function(require) {
|
|||||||
InvitationDAO = require('js/dao/invitation-dao'),
|
InvitationDAO = require('js/dao/invitation-dao'),
|
||||||
OutboxBO = require('js/bo/outbox'),
|
OutboxBO = require('js/bo/outbox'),
|
||||||
PGP = require('js/crypto/pgp'),
|
PGP = require('js/crypto/pgp'),
|
||||||
|
PgpBuilder = require('pgpbuilder'),
|
||||||
config = require('js/app-config').config;
|
config = require('js/app-config').config;
|
||||||
|
|
||||||
var self = {};
|
var self = {};
|
||||||
@ -117,7 +118,7 @@ define(function(require) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
imapClient = new ImapClient(imapOptions);
|
imapClient = new ImapClient(imapOptions);
|
||||||
pgpMailer = new PgpMailer(smtpOptions);
|
pgpMailer = new PgpMailer(smtpOptions, self._pgpbuilder);
|
||||||
|
|
||||||
imapClient.onError = function(err) {
|
imapClient.onError = function(err) {
|
||||||
console.log('IMAP error.', err);
|
console.log('IMAP error.', err);
|
||||||
@ -341,7 +342,7 @@ define(function(require) {
|
|||||||
|
|
||||||
self.buildModules = function() {
|
self.buildModules = function() {
|
||||||
var lawnchairDao, restDao, pubkeyDao, invitationDao,
|
var lawnchairDao, restDao, pubkeyDao, invitationDao,
|
||||||
emailDao, keychain, pgp, userStorage;
|
emailDao, keychain, pgp, userStorage, pgpbuilder;
|
||||||
|
|
||||||
// init objects and inject dependencies
|
// init objects and inject dependencies
|
||||||
restDao = new RestDAO();
|
restDao = new RestDAO();
|
||||||
@ -354,7 +355,8 @@ define(function(require) {
|
|||||||
self._keychain = keychain;
|
self._keychain = keychain;
|
||||||
pgp = new PGP();
|
pgp = new PGP();
|
||||||
self._crypto = pgp;
|
self._crypto = pgp;
|
||||||
self._emailDao = emailDao = new EmailDAO(keychain, pgp, userStorage);
|
self._pgpbuilder = pgpbuilder = new PgpBuilder({}); // set the worker path?!
|
||||||
|
self._emailDao = emailDao = new EmailDAO(keychain, pgp, userStorage, pgpbuilder);
|
||||||
self._outboxBo = new OutboxBO(emailDao, keychain, userStorage, invitationDao);
|
self._outboxBo = new OutboxBO(emailDao, keychain, userStorage, invitationDao);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,12 +6,11 @@ define(function(require) {
|
|||||||
str = require('js/app-config').string,
|
str = require('js/app-config').string,
|
||||||
config = require('js/app-config').config;
|
config = require('js/app-config').config;
|
||||||
|
|
||||||
var EmailDAO = function(keychain, crypto, devicestorage) {
|
var EmailDAO = function(keychain, crypto, devicestorage, pgpbuilder) {
|
||||||
var self = this;
|
this._keychain = keychain;
|
||||||
|
this._crypto = crypto;
|
||||||
self._keychain = keychain;
|
this._devicestorage = devicestorage;
|
||||||
self._crypto = crypto;
|
this._pgpbuilder = pgpbuilder;
|
||||||
self._devicestorage = devicestorage;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -76,7 +75,7 @@ define(function(require) {
|
|||||||
self._pgpMailer = options.pgpMailer;
|
self._pgpMailer = options.pgpMailer;
|
||||||
// set private key
|
// set private key
|
||||||
if (self._crypto && self._crypto._privateKey) {
|
if (self._crypto && self._crypto._privateKey) {
|
||||||
self._pgpMailer._pgpbuilder._privateKey = self._crypto._privateKey;
|
self._pgpbuilder._privateKey = self._crypto._privateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
// delegation-esque pattern to mitigate between node-style events and plain js
|
// delegation-esque pattern to mitigate between node-style events and plain js
|
||||||
@ -143,9 +142,8 @@ define(function(require) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// HANDLE THIS PROPERLY!!!
|
|
||||||
// set decrypted privateKey to pgpMailer
|
// set decrypted privateKey to pgpMailer
|
||||||
self._pgpMailer._pgpbuilder._privateKey = self._crypto._privateKey;
|
self._pgpbuilder._privateKey = self._crypto._privateKey;
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -196,9 +194,8 @@ define(function(require) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// HANDLE THIS PROPERLY!!!
|
|
||||||
// set decrypted privateKey to pgpMailer
|
// set decrypted privateKey to pgpMailer
|
||||||
self._pgpMailer._pgpbuilder._privateKey = self._crypto._privateKey;
|
self._pgpbuilder._privateKey = self._crypto._privateKey;
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1060,11 +1057,11 @@ define(function(require) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EmailDAO.prototype.encrypt = function(options, callback) {
|
EmailDAO.prototype.encrypt = function(options, callback) {
|
||||||
this._pgpMailer.encrypt(options, callback);
|
this._pgpbuilder.encrypt(options, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
EmailDAO.prototype.reEncrypt = function(options, callback) {
|
EmailDAO.prototype.reEncrypt = function(options, callback) {
|
||||||
this._pgpMailer.reEncrypt(options, callback);
|
this._pgpbuilder.reEncrypt(options, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -5,6 +5,7 @@ define(function(require) {
|
|||||||
KeychainDAO = require('js/dao/keychain-dao'),
|
KeychainDAO = require('js/dao/keychain-dao'),
|
||||||
ImapClient = require('imap-client'),
|
ImapClient = require('imap-client'),
|
||||||
PgpMailer = require('pgpmailer'),
|
PgpMailer = require('pgpmailer'),
|
||||||
|
PgpBuilder = require('pgpbuilder'),
|
||||||
PGP = require('js/crypto/pgp'),
|
PGP = require('js/crypto/pgp'),
|
||||||
DeviceStorageDAO = require('js/dao/devicestorage-dao'),
|
DeviceStorageDAO = require('js/dao/devicestorage-dao'),
|
||||||
str = require('js/app-config').string,
|
str = require('js/app-config').string,
|
||||||
@ -13,7 +14,7 @@ define(function(require) {
|
|||||||
chai.Assertion.includeStack = true;
|
chai.Assertion.includeStack = true;
|
||||||
|
|
||||||
describe('Email DAO unit tests', function() {
|
describe('Email DAO unit tests', function() {
|
||||||
var dao, keychainStub, imapClientStub, pgpMailerStub, pgpStub, devicestorageStub;
|
var dao, keychainStub, imapClientStub, pgpMailerStub, pgpBuilderStub, pgpStub, devicestorageStub;
|
||||||
|
|
||||||
var emailAddress, passphrase, asymKeySize, mockkeyId, dummyEncryptedMail,
|
var emailAddress, passphrase, asymKeySize, mockkeyId, dummyEncryptedMail,
|
||||||
dummyDecryptedMail, mockKeyPair, account, verificationMail, verificationUuid,
|
dummyDecryptedMail, mockKeyPair, account, verificationMail, verificationUuid,
|
||||||
@ -111,10 +112,11 @@ define(function(require) {
|
|||||||
keychainStub = sinon.createStubInstance(KeychainDAO);
|
keychainStub = sinon.createStubInstance(KeychainDAO);
|
||||||
imapClientStub = sinon.createStubInstance(ImapClient);
|
imapClientStub = sinon.createStubInstance(ImapClient);
|
||||||
pgpMailerStub = sinon.createStubInstance(PgpMailer);
|
pgpMailerStub = sinon.createStubInstance(PgpMailer);
|
||||||
|
pgpBuilderStub = sinon.createStubInstance(PgpBuilder);
|
||||||
pgpStub = sinon.createStubInstance(PGP);
|
pgpStub = sinon.createStubInstance(PGP);
|
||||||
devicestorageStub = sinon.createStubInstance(DeviceStorageDAO);
|
devicestorageStub = sinon.createStubInstance(DeviceStorageDAO);
|
||||||
|
|
||||||
dao = new EmailDAO(keychainStub, pgpStub, devicestorageStub);
|
dao = new EmailDAO(keychainStub, pgpStub, devicestorageStub, pgpBuilderStub);
|
||||||
dao._account = account;
|
dao._account = account;
|
||||||
|
|
||||||
expect(dao._keychain).to.equal(keychainStub);
|
expect(dao._keychain).to.equal(keychainStub);
|
||||||
@ -2613,6 +2615,29 @@ define(function(require) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('encrypt', function() {
|
||||||
|
it('should encrypt', function(done) {
|
||||||
|
pgpBuilderStub.encrypt.yields();
|
||||||
|
|
||||||
|
dao.encrypt({}, function() {
|
||||||
|
expect(pgpBuilderStub.encrypt.calledOnce).to.be.true;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('reEncrypt', function() {
|
||||||
|
it('should re-encrypt', function(done) {
|
||||||
|
pgpBuilderStub.reEncrypt.yields();
|
||||||
|
|
||||||
|
dao.reEncrypt({}, function() {
|
||||||
|
expect(pgpBuilderStub.reEncrypt.calledOnce).to.be.true;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('syncOutbox', function() {
|
describe('syncOutbox', function() {
|
||||||
it('should sync the outbox', function(done) {
|
it('should sync the outbox', function(done) {
|
||||||
var folder = 'FOLDAAAA';
|
var folder = 'FOLDAAAA';
|
||||||
|
Loading…
Reference in New Issue
Block a user