freedom-pgp-e2e
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -57,7 +57,10 @@ /*globals freedom, console, e2e, exports, ArrayBuffer, Uint8Array, Uint16Array, DataView*/ | ||
mye2e.prototype.exportKey = function() { | ||
var serialized = e2e.async.Result.getValue( | ||
this.pgpContext.searchPublicKey(this.pgpUser))[0].serialized; | ||
var keyResult = e2e.async.Result.getValue( | ||
this.pgpContext.searchPublicKey(this.pgpUser)); | ||
var serialized = keyResult[0].serialized; | ||
return Promise.resolve(e2e.openpgp.asciiArmor.encode( | ||
'PUBLIC KEY BLOCK', serialized)); | ||
return Promise.resolve({ | ||
"key": e2e.openpgp.asciiArmor.encode( | ||
'PUBLIC KEY BLOCK', serialized), | ||
"fingerprint": keyResult[0].key.fingerprintHex }); | ||
}; | ||
@@ -140,8 +143,8 @@ | ||
addCallback(function (keys) { | ||
if (keys.length == 2) { | ||
resolve(); | ||
} else { | ||
reject(new Error('Failed to generate key')); | ||
} | ||
}); | ||
if (keys.length == 2) { | ||
resolve(); | ||
} else { | ||
reject(new Error('Failed to generate key')); | ||
} | ||
}); | ||
}); | ||
@@ -148,0 +151,0 @@ }; |
@@ -48,6 +48,6 @@ { | ||
"exportKey": { | ||
"_comment": "Export your public key to share with buddies", | ||
"_comment": "Export your public key and fingerprint to share/check", | ||
"type": "method", | ||
"value": [], | ||
"ret": "string", | ||
"ret": { "key": "string", "fingerprint": "string" }, | ||
"err": { "errcode": "string", "message": "string" } | ||
@@ -54,0 +54,0 @@ }, |
@@ -62,3 +62,3 @@ /** | ||
}, | ||
single: { | ||
browsers: { | ||
singleRun: true, | ||
@@ -171,3 +171,4 @@ autoWatch: false | ||
'build', | ||
'karma:single', | ||
'karma:browsers', | ||
'karma:phantom', | ||
'jasmine_node', | ||
@@ -174,0 +175,0 @@ 'jasmine_chromeapp' |
@@ -62,3 +62,3 @@ // Karma configuration | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['Chrome', 'Firefox', 'PhantomJS'], | ||
browsers: ['Chrome', 'Firefox'], | ||
@@ -65,0 +65,0 @@ |
{ | ||
"name": "freedom-pgp-e2e", | ||
"description": "Library to provide freedom API wrapper of end-to-end library", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"contributors": [ | ||
@@ -13,24 +13,24 @@ "Aaron Gallant <ag@cs.washington.edu>" | ||
"devDependencies": { | ||
"e2e": "0.0.3", | ||
"es6-promise": "^2.0.1", | ||
"freedom": "^0.6.21", | ||
"freedom-for-chrome": "^0.4.15", | ||
"freedom-for-node": "^0.2.14", | ||
"e2e": "^0.0.5", | ||
"es6-promise": "^2.2.0", | ||
"freedom": "^0.6.25", | ||
"freedom-for-chrome": "^0.4.19", | ||
"freedom-for-node": "^0.2.17", | ||
"grunt": "^0.4.5", | ||
"grunt-bump": "^0.3.0", | ||
"grunt-bump": "^0.3.1", | ||
"grunt-contrib-clean": "^0.6.0", | ||
"grunt-contrib-connect": "^0.9.0", | ||
"grunt-contrib-connect": "^0.10.1", | ||
"grunt-contrib-copy": "^0.8.0", | ||
"grunt-contrib-jshint": "^0.11.1", | ||
"grunt-contrib-jshint": "^0.11.2", | ||
"grunt-jasmine-chromeapp": "^1.8.0", | ||
"grunt-jasmine-node2": "^0.4.0", | ||
"grunt-karma": "^0.10.1", | ||
"grunt-npm": "0.0.2", | ||
"grunt-karma": "^0.11.0", | ||
"grunt-npm": "^0.0.2", | ||
"grunt-prompt": "^1.3.0", | ||
"karma": "^0.12.31", | ||
"karma-chrome-launcher": "^0.1.7", | ||
"karma-coverage": "^0.2.7", | ||
"karma-firefox-launcher": "^0.1.4", | ||
"karma": "^0.12.36", | ||
"karma-chrome-launcher": "^0.1.12", | ||
"karma-coverage": "^0.3.1", | ||
"karma-firefox-launcher": "^0.1.6", | ||
"karma-jasmine": "^0.3.5", | ||
"karma-phantomjs-launcher": "^0.1.4", | ||
"karma-phantomjs-launcher": "^0.2.0", | ||
"karma-story-reporter": "^0.3.1", | ||
@@ -37,0 +37,0 @@ "karma-unicorn-reporter": "^0.1.4" |
@@ -24,2 +24,4 @@ /*globals describe, beforeEach, require, expect, it*/ | ||
var keyFingerprint = 'B734 A06E 3413 DD98 6774 3FB3 E9B8 201F 5B87 6D89'; | ||
var privateKeyStr = | ||
@@ -121,3 +123,4 @@ '-----BEGIN PGP PRIVATE KEY BLOCK-----\r\n' + | ||
}).then(function (publicKey) { | ||
expect(publicKey).toEqual(publicKeyStr); | ||
expect(publicKey.key).toEqual(publicKeyStr); | ||
expect(publicKey.fingerprint).toEqual(keyFingerprint); | ||
}).then(function () { | ||
@@ -139,6 +142,6 @@ return e2eImp.searchPrivateKey('<quantsword@gmail.com>'); | ||
}).then(function (publicKey) { | ||
return e2eImp.signEncrypt(buffer, publicKey, false); | ||
}).then(function (encryptedData) { | ||
return e2eImp.verifyDecrypt(encryptedData); | ||
}).then(function (result) { | ||
return e2eImp.signEncrypt(buffer, publicKey.key, false); | ||
}).then(function (encryptedData) { | ||
return e2eImp.verifyDecrypt(encryptedData); | ||
}).then(function (result) { | ||
expect(result.data).toEqual(buffer); | ||
@@ -156,6 +159,6 @@ }).catch(function (e) { | ||
}).then(function (publicKey) { | ||
return e2eImp.signEncrypt(buffer, publicKey, true).then( | ||
function (encryptedData) { | ||
return e2eImp.verifyDecrypt(encryptedData, publicKey); | ||
}); | ||
return e2eImp.signEncrypt(buffer, publicKey.key, true).then( | ||
function (encryptedData) { | ||
return e2eImp.verifyDecrypt(encryptedData, publicKey.key); | ||
}); | ||
}).then(function (result) { | ||
@@ -190,7 +193,7 @@ expect(result.data).toEqual(buffer); | ||
return e2eImp.exportKey(); | ||
}).then(function (publicKeyStr) { | ||
expect(publicKeyStr.length > 36); | ||
expect(publicKeyStr.substring(0, 36)).toEqual( | ||
'-----BEGIN PGP PUBLIC KEY BLOCK-----'); | ||
}).catch(function (e) { | ||
}).then(function (publicKey) { | ||
expect(publicKey.key.length > 36); | ||
expect(publicKey.key.substring(0, 36)).toEqual( | ||
'-----BEGIN PGP PUBLIC KEY BLOCK-----'); | ||
}).catch(function (e) { | ||
console.log(e.toString()); | ||
@@ -197,0 +200,0 @@ expect(false).toBeTruthy(); |
@@ -24,6 +24,6 @@ /*globals freedom,Uint8Array,ArrayBuffer*/ | ||
this.dispatch('print', 'Encrypting/signing...'); | ||
return e2e.signEncrypt(plaintext, publicKey, true).then( | ||
return e2e.signEncrypt(plaintext, publicKey.key, true).then( | ||
function (encryptedData) { | ||
this.dispatch('print', 'Decrypting...'); | ||
return e2e.verifyDecrypt(encryptedData, publicKey); | ||
return e2e.verifyDecrypt(encryptedData, publicKey.key); | ||
}.bind(this)); | ||
@@ -42,3 +42,6 @@ }.bind(this)).then(function (result) { | ||
function (e) { | ||
this.dispatch('print', 'Encryption test encountered error: ' + e.message); | ||
if (e.message) { | ||
e = e.message; | ||
} | ||
this.dispatch('print', 'Encryption test encountered error: ' + e); | ||
}.bind(this)); | ||
@@ -58,3 +61,3 @@ }; | ||
function (result) { | ||
if (result === publicKeyStr) { | ||
if (result.key === publicKeyStr) { | ||
this.dispatch('print', 'Keypair import test SUCCEEDED.'); | ||
@@ -61,0 +64,0 @@ } else { |
@@ -57,7 +57,10 @@ /*globals freedom, console, e2e, exports, ArrayBuffer, Uint8Array, Uint16Array, DataView*/ | ||
mye2e.prototype.exportKey = function() { | ||
var serialized = e2e.async.Result.getValue( | ||
this.pgpContext.searchPublicKey(this.pgpUser))[0].serialized; | ||
var keyResult = e2e.async.Result.getValue( | ||
this.pgpContext.searchPublicKey(this.pgpUser)); | ||
var serialized = keyResult[0].serialized; | ||
return Promise.resolve(e2e.openpgp.asciiArmor.encode( | ||
'PUBLIC KEY BLOCK', serialized)); | ||
return Promise.resolve({ | ||
"key": e2e.openpgp.asciiArmor.encode( | ||
'PUBLIC KEY BLOCK', serialized), | ||
"fingerprint": keyResult[0].key.fingerprintHex }); | ||
}; | ||
@@ -140,8 +143,8 @@ | ||
addCallback(function (keys) { | ||
if (keys.length == 2) { | ||
resolve(); | ||
} else { | ||
reject(new Error('Failed to generate key')); | ||
} | ||
}); | ||
if (keys.length == 2) { | ||
resolve(); | ||
} else { | ||
reject(new Error('Failed to generate key')); | ||
} | ||
}); | ||
}); | ||
@@ -148,0 +151,0 @@ }; |
@@ -48,6 +48,6 @@ { | ||
"exportKey": { | ||
"_comment": "Export your public key to share with buddies", | ||
"_comment": "Export your public key and fingerprint to share/check", | ||
"type": "method", | ||
"value": [], | ||
"ret": "string", | ||
"ret": { "key": "string", "fingerprint": "string" }, | ||
"err": { "errcode": "string", "message": "string" } | ||
@@ -54,0 +54,0 @@ }, |
Sorry, the diff of this file is too big to display
1821953
14681